Repository navigation
Expand file tree
/
Copy pathsession.html
More file actions
742 lines (553 loc) · 61.1 KB
/
Copy pathsession.html
File metadata and controls
742 lines (553 loc) · 61.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This file is generated by Nim. -->
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en" data-theme="auto">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>threecode/session</title>
<!-- Google fonts -->
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
<!-- Favicon -->
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="../nimdoc.out.css?v=2.2.10">
<!-- JS -->
<script type="text/javascript" src="../dochack.js?v=2.2.10"></script>
</head>
<body>
<div class="document" id="documentId">
<input type="checkbox" id="nav-toggle" hidden>
<label for="nav-toggle" id="nav-burger">☰</label>
<label for="nav-toggle" id="nav-overlay"></label>
<div class="container">
<h1 class="title">threecode/session</h1>
<div class="row">
<div class="three columns">
<div class="theme-select-wrapper">
<label for="theme-select">Theme: </label>
<select id="theme-select" onchange="setTheme(this.value)">
<option value="auto">🌗 Match OS</option>
<option value="dark">🌑 Dark</option>
<option value="light">🌕 Light</option>
</select>
</div>
<div id="global-links">
<ul class="simple">
<li><a id="indexLink" href="../theindex.html">Index</a></li>
</ul>
</div>
<div id="searchInputDiv">
Search: <input type="search" id="searchInput" oninput="search()"/>
</div>
<div>
Group by:
<select onchange="groupBy(this.value)">
<option value="section">Section</option>
<option value="type">Type</option>
</select>
</div>
<ul class="simple simple-toc" id="toc-list">
<li>
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#SessionLocked" title="SessionLocked = object of CatchableError">SessionLocked</a></li>
<li><a class="reference" href="#SessionPreview" title="SessionPreview = object
cwd*: string
profile*: string
msgCount*: int
firstUser*: string">SessionPreview</a></li>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#8" id="58">Vars</a></summary>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#activeLockPath" title="activeLockPath = """>activeLockPath</a></li>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
<ul class="simple simple-toc-section">
<li><a class="reference" href="#SessionExt" title="SessionExt = ".3log"">SessionExt</a></li>
</ul>
</details>
</li>
<li>
<details open>
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
<ul class="simple simple-toc-section">
<ul class="simple nested-toc-section">acquireSessionLock
<li><a class="reference" href="#acquireSessionLock%2Cstring" title="acquireSessionLock(path: string)">acquireSessionLock(path: string)</a></li>
</ul>
<ul class="simple nested-toc-section">appendIndexAt
<li><a class="reference" href="#appendIndexAt%2Cstring%2Cstring%2Cstring" title="appendIndexAt(indexDir, cwd, id: string)">appendIndexAt(indexDir, cwd, id: string)</a></li>
</ul>
<ul class="simple nested-toc-section">appendSessionIndex
<li><a class="reference" href="#appendSessionIndex%2Cstring%2Cstring" title="appendSessionIndex(cwd, id: string)">appendSessionIndex(cwd, id: string)</a></li>
</ul>
<ul class="simple nested-toc-section">clearDraft
<li><a class="reference" href="#clearDraft%2CSession" title="clearDraft(session: Session)">clearDraft(session: Session)</a></li>
</ul>
<ul class="simple nested-toc-section">clearPendingDraft
<li><a class="reference" href="#clearPendingDraft%2Cstring" title="clearPendingDraft(cwd: string)">clearPendingDraft(cwd: string)</a></li>
</ul>
<ul class="simple nested-toc-section">currentDraftPath
<li><a class="reference" href="#currentDraftPath%2CSession" title="currentDraftPath(session: Session): string">currentDraftPath(session: Session): string</a></li>
</ul>
<ul class="simple nested-toc-section">draftDir
<li><a class="reference" href="#draftDir" title="draftDir(): string">draftDir(): string</a></li>
</ul>
<ul class="simple nested-toc-section">draftPathFor
<li><a class="reference" href="#draftPathFor%2Cstring" title="draftPathFor(sessionPath: string): string">draftPathFor(sessionPath: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">firstUserMessage
<li><a class="reference" href="#firstUserMessage%2CJsonNode" title="firstUserMessage(messages: JsonNode): string">firstUserMessage(messages: JsonNode): string</a></li>
</ul>
<ul class="simple nested-toc-section">historyFile
<li><a class="reference" href="#historyFile" title="historyFile(): string">historyFile(): string</a></li>
</ul>
<ul class="simple nested-toc-section">indexIdsAt
<li><a class="reference" href="#indexIdsAt%2Cstring%2Cstring" title="indexIdsAt(indexDir, cwd: string): seq[string]">indexIdsAt(indexDir, cwd: string): seq[string]</a></li>
</ul>
<ul class="simple nested-toc-section">indexPathAt
<li><a class="reference" href="#indexPathAt%2Cstring%2Cstring" title="indexPathAt(indexDir, cwd: string): string">indexPathAt(indexDir, cwd: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">listSessionPaths
<li><a class="reference" href="#listSessionPaths" title="listSessionPaths(): seq[string]">listSessionPaths(): seq[string]</a></li>
</ul>
<ul class="simple nested-toc-section">listSessionPathsForCwd
<li><a class="reference" href="#listSessionPathsForCwd%2Cstring" title="listSessionPathsForCwd(cwd: string): seq[string]">listSessionPathsForCwd(cwd: string): seq[string]</a></li>
</ul>
<ul class="simple nested-toc-section">loadDraft
<li><a class="reference" href="#loadDraft%2Cstring" title="loadDraft(sessionPath: string): string">loadDraft(sessionPath: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">loadPendingDraft
<li><a class="reference" href="#loadPendingDraft%2Cstring" title="loadPendingDraft(cwd: string): string">loadPendingDraft(cwd: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">loadSessionFile
<li><a class="reference" href="#loadSessionFile%2Cstring" title="loadSessionFile(path: string): (Session, JsonNode)">loadSessionFile(path: string): (Session, JsonNode)</a></li>
</ul>
<ul class="simple nested-toc-section">mangleCwd
<li><a class="reference" href="#mangleCwd%2Cstring" title="mangleCwd(cwd: string): string">mangleCwd(cwd: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">newSessionPath
<li><a class="reference" href="#newSessionPath" title="newSessionPath(): string">newSessionPath(): string</a></li>
</ul>
<ul class="simple nested-toc-section">pendingDraftDir
<li><a class="reference" href="#pendingDraftDir" title="pendingDraftDir(): string">pendingDraftDir(): string</a></li>
</ul>
<ul class="simple nested-toc-section">pendingDraftPathFor
<li><a class="reference" href="#pendingDraftPathFor%2Cstring" title="pendingDraftPathFor(cwd: string): string">pendingDraftPathFor(cwd: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">previewSession
<li><a class="reference" href="#previewSession%2Cstring" title="previewSession(path: string): SessionPreview">previewSession(path: string): SessionPreview</a></li>
</ul>
<ul class="simple nested-toc-section">releaseActiveSessionLock
<li><a class="reference" href="#releaseActiveSessionLock" title="releaseActiveSessionLock()">releaseActiveSessionLock()</a></li>
</ul>
<ul class="simple nested-toc-section">releaseSessionLock
<li><a class="reference" href="#releaseSessionLock%2Cstring" title="releaseSessionLock(path: string)">releaseSessionLock(path: string)</a></li>
</ul>
<ul class="simple nested-toc-section">renderSession
<li><a class="reference" href="#renderSession%2CSession%2CJsonNode" title="renderSession(session: Session; messages: JsonNode): string">renderSession(session: Session; messages: JsonNode): string</a></li>
</ul>
<ul class="simple nested-toc-section">resolveSessionPath
<li><a class="reference" href="#resolveSessionPath%2Cstring%2Cstring" title="resolveSessionPath(id: string; cwd = ""): string">resolveSessionPath(id: string; cwd = ""): string</a></li>
</ul>
<ul class="simple nested-toc-section">saveDraft
<li><a class="reference" href="#saveDraft%2CSession%2Cstring" title="saveDraft(session: Session; text: string)">saveDraft(session: Session; text: string)</a></li>
</ul>
<ul class="simple nested-toc-section">saveSession
<li><a class="reference" href="#saveSession%2CSession%2CJsonNode" title="saveSession(session: Session; messages: JsonNode)">saveSession(session: Session; messages: JsonNode)</a></li>
</ul>
<ul class="simple nested-toc-section">sessionDir
<li><a class="reference" href="#sessionDir" title="sessionDir(): string">sessionDir(): string</a></li>
</ul>
<ul class="simple nested-toc-section">sessionIdFromPath
<li><a class="reference" href="#sessionIdFromPath%2Cstring" title="sessionIdFromPath(path: string): string">sessionIdFromPath(path: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">sessionLockDir
<li><a class="reference" href="#sessionLockDir" title="sessionLockDir(): string">sessionLockDir(): string</a></li>
</ul>
<ul class="simple nested-toc-section">sessionLockPathFor
<li><a class="reference" href="#sessionLockPathFor%2Cstring" title="sessionLockPathFor(path: string): string">sessionLockPathFor(path: string): string</a></li>
</ul>
<ul class="simple nested-toc-section">sessionPathIndexDir
<li><a class="reference" href="#sessionPathIndexDir" title="sessionPathIndexDir(): string">sessionPathIndexDir(): string</a></li>
</ul>
<ul class="simple nested-toc-section">usageFromJson
<li><a class="reference" href="#usageFromJson%2CJsonNode" title="usageFromJson(j: JsonNode): Usage">usageFromJson(j: JsonNode): Usage</a></li>
</ul>
</ul>
</details>
</li>
</ul>
</div>
<div class="nine columns" id="content">
<div id="tocRoot"></div>
<p class="module-desc"><p>Session persistence in the human-readable <tt class="docutils literal"><span class="pre"><span class="Operator">.</span><span class="DecNumber">3</span><span class="Identifier">log</span></span></tt> format.</p>
<p><tt class="docutils literal"><span class="pre"><span class="Operator">.</span><span class="DecNumber">3</span><span class="Identifier">log</span></span></tt> is an append-friendly, diff-friendly flat-text format. Each record is a header line (role and space-separated args) followed by body lines indented two spaces. The format is both the on-disk representation and the session audit trail - readable without tooling and diffable in git.</p>
<p>The system prompt is intentionally omitted on save: it is rebuilt from the profile on every resume, saving several KB per session and ensuring the prompt is always current (not a stale snapshot from when the session started).</p>
<p>On load, the full OpenAI-shape <tt class="docutils literal"><span class="pre"><span class="Identifier">messages</span></span></tt> JsonNode array is reconstructed from the records so the session can be resumed mid-conversation with no loss.</p>
</p>
<div class="section" id="6">
<h1><a class="toc-backref" href="#6">Imports</a></h1>
<dl class="item">
<a class="reference external" href="types.html">types</a>, <a class="reference external" href="prompts.html">prompts</a>, <a class="reference external" href="util.html">util</a>, <a class="reference external" href="actions.html">actions</a>
</dl>
</div>
<div class="section" id="7">
<h1><a class="toc-backref" href="#7">Types</a></h1>
<dl class="item">
<div id="SessionLocked">
<dt><pre><a href="#SessionLocked"><span class="Identifier">SessionLocked</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">CatchableError</span></pre></dt>
<dd>
</dd>
</div>
<div id="SessionPreview">
<dt><pre><a href="#SessionPreview"><span class="Identifier">SessionPreview</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
<span class="Identifier">cwd</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Identifier">profile</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
<span class="Identifier">msgCount</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">int</span>
<span class="Identifier">firstUser</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span></pre></dt>
<dd>
</dd>
</div>
</dl>
</div>
<div class="section" id="8">
<h1><a class="toc-backref" href="#8">Vars</a></h1>
<dl class="item">
<div id="activeLockPath">
<dt><pre><a href="#activeLockPath"><span class="Identifier">activeLockPath</span></a> <span class="Other">=</span> <span class="StringLit">""</span></pre></dt>
<dd>
</dd>
</div>
</dl>
</div>
<div class="section" id="10">
<h1><a class="toc-backref" href="#10">Consts</a></h1>
<dl class="item">
<div id="SessionExt">
<dt><pre><a href="#SessionExt"><span class="Identifier">SessionExt</span></a> <span class="Other">=</span> <span class="StringLit">".3log"</span></pre></dt>
<dd>
</dd>
</div>
</dl>
</div>
<div class="section" id="12">
<h1><a class="toc-backref" href="#12">Procs</a></h1>
<dl class="item">
<div id="acquireSessionLock-procs-all">
<div id="acquireSessionLock,string">
<dt><pre><span class="Keyword">proc</span> <a href="#acquireSessionLock%2Cstring"><span class="Identifier">acquireSessionLock</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">SessionLocked</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<p>Atomically claim the lock for <tt class="docutils literal"><span class="pre"><span class="Identifier">path</span></span></tt>.</p>
<p>If a lock exists but its owner process is no longer alive, it's treated as stale (left behind by a crash) and removed automatically, then acquisition retries once. Raises SessionLocked only when another live 3code process genuinely holds the lock (or a second racer grabbed it in the retry window).</p>
</dd>
</div>
</div>
<div id="appendIndexAt-procs-all">
<div id="appendIndexAt,string,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#appendIndexAt%2Cstring%2Cstring%2Cstring"><span class="Identifier">appendIndexAt</span></a><span class="Other">(</span><span class="Identifier">indexDir</span><span class="Other">,</span> <span class="Identifier">cwd</span><span class="Other">,</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Append <tt class="docutils literal"><span class="pre"><span class="Identifier">id</span></span></tt> to the cwd's index file. Silent on failure: a missing index entry only means the session won't show in resume-latest, never a crash.
</dd>
</div>
</div>
<div id="appendSessionIndex-procs-all">
<div id="appendSessionIndex,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#appendSessionIndex%2Cstring%2Cstring"><span class="Identifier">appendSessionIndex</span></a><span class="Other">(</span><span class="Identifier">cwd</span><span class="Other">,</span> <span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteDirEffect</span><span class="Other">,</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="clearDraft-procs-all">
<div id="clearDraft,Session">
<dt><pre><span class="Keyword">proc</span> <a href="#clearDraft%2CSession"><span class="Identifier">clearDraft</span></a><span class="Other">(</span><span class="Identifier">session</span><span class="Other">:</span> <a href="types.html#Session"><span class="Identifier">Session</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span>
<span class="Identifier">WriteDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Remove the prompt draft sidecar(s). Called when a prompt is committed so a clean exit doesn't leave a stale draft. Removes both scopes — whichever was active at submit time — so this is correct regardless of pre/post-first-turn state. Cheap and a no-op when neither exists.
</dd>
</div>
</div>
<div id="clearPendingDraft-procs-all">
<div id="clearPendingDraft,string">
<dt><pre><span class="Keyword">proc</span> <a href="#clearPendingDraft%2Cstring"><span class="Identifier">clearPendingDraft</span></a><span class="Other">(</span><span class="Identifier">cwd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span>
<span class="Identifier">WriteDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Remove the cwd-keyed pending prompt draft for <tt class="docutils literal"><span class="pre"><span class="Identifier">cwd</span></span></tt>. No-op when none exists.
</dd>
</div>
</div>
<div id="currentDraftPath-procs-all">
<div id="currentDraftPath,Session">
<dt><pre><span class="Keyword">proc</span> <a href="#currentDraftPath%2CSession"><span class="Identifier">currentDraftPath</span></a><span class="Other">(</span><span class="Identifier">session</span><span class="Other">:</span> <a href="types.html#Session"><span class="Identifier">Session</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
The draft path for the live session: id-keyed once a <tt class="docutils literal"><span class="pre"><span class="Operator">.</span><span class="DecNumber">3</span><span class="Identifier">log</span></span></tt> exists (post-first-turn), otherwise the cwd-keyed pending path. This is the single decision point for which scope a draft lives in.
</dd>
</div>
</div>
<div id="draftDir-procs-all">
<div id="draftDir">
<dt><pre><span class="Keyword">proc</span> <a href="#draftDir"><span class="Identifier">draftDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="draftPathFor-procs-all">
<div id="draftPathFor,string">
<dt><pre><span class="Keyword">proc</span> <a href="#draftPathFor%2Cstring"><span class="Identifier">draftPathFor</span></a><span class="Other">(</span><span class="Identifier">sessionPath</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="firstUserMessage-procs-all">
<div id="firstUserMessage,JsonNode">
<dt><pre><span class="Keyword">proc</span> <a href="#firstUserMessage%2CJsonNode"><span class="Identifier">firstUserMessage</span></a><span class="Other">(</span><span class="Identifier">messages</span><span class="Other">:</span> <span class="Identifier">JsonNode</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="historyFile-procs-all">
<div id="historyFile">
<dt><pre><span class="Keyword">proc</span> <a href="#historyFile"><span class="Identifier">historyFile</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span>
<span class="Identifier">WriteDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="indexIdsAt-procs-all">
<div id="indexIdsAt,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#indexIdsAt%2Cstring%2Cstring"><span class="Identifier">indexIdsAt</span></a><span class="Other">(</span><span class="Identifier">indexDir</span><span class="Other">,</span> <span class="Identifier">cwd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Session ids for <tt class="docutils literal"><span class="pre"><span class="Identifier">cwd</span></span></tt>, latest-first. Reads the single small index file (one line per session) — never touches a <tt class="docutils literal"><span class="pre"><span class="Operator">.</span><span class="DecNumber">3</span><span class="Identifier">log</span></span></tt>.
</dd>
</div>
</div>
<div id="indexPathAt-procs-all">
<div id="indexPathAt,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#indexPathAt%2Cstring%2Cstring"><span class="Identifier">indexPathAt</span></a><span class="Other">(</span><span class="Identifier">indexDir</span><span class="Other">,</span> <span class="Identifier">cwd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="listSessionPaths-procs-all">
<div id="listSessionPaths">
<dt><pre><span class="Keyword">proc</span> <a href="#listSessionPaths"><span class="Identifier">listSessionPaths</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="listSessionPathsForCwd-procs-all">
<div id="listSessionPathsForCwd,string">
<dt><pre><span class="Keyword">proc</span> <a href="#listSessionPathsForCwd%2Cstring"><span class="Identifier">listSessionPathsForCwd</span></a><span class="Other">(</span><span class="Identifier">cwd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Sessions saved under <tt class="docutils literal"><span class="pre"><span class="Identifier">cwd</span></span></tt>, latest-first — read straight from the cwd index, so it never parses a <tt class="docutils literal"><span class="pre"><span class="Operator">.</span><span class="DecNumber">3</span><span class="Identifier">log</span></span></tt>. A missing/stale index entry is skipped via the <tt class="docutils literal"><span class="pre"><span class="Identifier">fileExists</span></span></tt> check (e.g. a session deleted on disk).
</dd>
</div>
</div>
<div id="loadDraft-procs-all">
<div id="loadDraft,string">
<dt><pre><span class="Keyword">proc</span> <a href="#loadDraft%2Cstring"><span class="Identifier">loadDraft</span></a><span class="Other">(</span><span class="Identifier">sessionPath</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Read the session-id-keyed prompt draft for <tt class="docutils literal"><span class="pre"><span class="Identifier">sessionPath</span></span></tt>, or "" if there is none or it is unreadable. Used by resume (post-first-turn drafts). The empty string is indistinguishable from absence, which is fine: an empty draft restores to an empty editor.
</dd>
</div>
</div>
<div id="loadPendingDraft-procs-all">
<div id="loadPendingDraft,string">
<dt><pre><span class="Keyword">proc</span> <a href="#loadPendingDraft%2Cstring"><span class="Identifier">loadPendingDraft</span></a><span class="Other">(</span><span class="Identifier">cwd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Read the cwd-keyed pending prompt draft for <tt class="docutils literal"><span class="pre"><span class="Identifier">cwd</span></span></tt>, or "" if there is none or it is unreadable. Used to restore an unsent prompt from a previous, killed-before-first-turn run when starting a fresh session in the same directory.
</dd>
</div>
</div>
<div id="loadSessionFile-procs-all">
<div id="loadSessionFile,string">
<dt><pre><span class="Keyword">proc</span> <a href="#loadSessionFile%2Cstring"><span class="Identifier">loadSessionFile</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><a href="types.html#Session"><span class="Identifier">Session</span></a><span class="Other">,</span> <span class="Identifier">JsonNode</span><span class="Other">)</span> {.
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="mangleCwd-procs-all">
<div id="mangleCwd,string">
<dt><pre><span class="Keyword">proc</span> <a href="#mangleCwd%2Cstring"><span class="Identifier">mangleCwd</span></a><span class="Other">(</span><span class="Identifier">cwd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="newSessionPath-procs-all">
<div id="newSessionPath">
<dt><pre><span class="Keyword">proc</span> <a href="#newSessionPath"><span class="Identifier">newSessionPath</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">TimeEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="pendingDraftDir-procs-all">
<div id="pendingDraftDir">
<dt><pre><span class="Keyword">proc</span> <a href="#pendingDraftDir"><span class="Identifier">pendingDraftDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="pendingDraftPathFor-procs-all">
<div id="pendingDraftPathFor,string">
<dt><pre><span class="Keyword">proc</span> <a href="#pendingDraftPathFor%2Cstring"><span class="Identifier">pendingDraftPathFor</span></a><span class="Other">(</span><span class="Identifier">cwd</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
The pre-first-turn draft for a working directory. Keyed by the collision-free mangled cwd (same scheme as the cwd session index) so distinct directories never share a draft. One per directory: a singleton, overwritten as the user edits.
</dd>
</div>
</div>
<div id="previewSession-procs-all">
<div id="previewSession,string">
<dt><pre><span class="Keyword">proc</span> <a href="#previewSession%2Cstring"><span class="Identifier">previewSession</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <a href="#SessionPreview"><span class="Identifier">SessionPreview</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Fast peek for <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">list</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Punctuation">:</span><span class="Identifier">sessions</span></span></tt> — reads the file, parses just enough to show cwd / profile / count / first user line. Doesn't reconstruct the full message tree.
</dd>
</div>
</div>
<div id="releaseActiveSessionLock-procs-all">
<div id="releaseActiveSessionLock">
<dt><pre><span class="Keyword">proc</span> <a href="#releaseActiveSessionLock"><span class="Identifier">releaseActiveSessionLock</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteDirEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="releaseSessionLock-procs-all">
<div id="releaseSessionLock,string">
<dt><pre><span class="Keyword">proc</span> <a href="#releaseSessionLock%2Cstring"><span class="Identifier">releaseSessionLock</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span>
<span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="renderSession-procs-all">
<div id="renderSession,Session,JsonNode">
<dt><pre><span class="Keyword">proc</span> <a href="#renderSession%2CSession%2CJsonNode"><span class="Identifier">renderSession</span></a><span class="Other">(</span><span class="Identifier">session</span><span class="Other">:</span> <a href="types.html#Session"><span class="Identifier">Session</span></a><span class="Other">;</span> <span class="Identifier">messages</span><span class="Other">:</span> <span class="Identifier">JsonNode</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="resolveSessionPath-procs-all">
<div id="resolveSessionPath,string,string">
<dt><pre><span class="Keyword">proc</span> <a href="#resolveSessionPath%2Cstring%2Cstring"><span class="Identifier">resolveSessionPath</span></a><span class="Other">(</span><span class="Identifier">id</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">cwd</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
<tt class="docutils literal"><span class="pre"><span class="Identifier">id</span></span></tt> is bare (no extension) or a full path. Returns "" if not found. When <tt class="docutils literal"><span class="pre"><span class="Identifier">id</span></span></tt> is empty and <tt class="docutils literal"><span class="pre"><span class="Identifier">cwd</span></span></tt> is set, returns the latest session for that cwd via the cwd index (no session parsed); with <tt class="docutils literal"><span class="pre"><span class="Identifier">cwd</span></span></tt> unset, the latest of any via a plain directory listing.
</dd>
</div>
</div>
<div id="saveDraft-procs-all">
<div id="saveDraft,Session,string">
<dt><pre><span class="Keyword">proc</span> <a href="#saveDraft%2CSession%2Cstring"><span class="Identifier">saveDraft</span></a><span class="Other">(</span><span class="Identifier">session</span><span class="Other">:</span> <a href="types.html#Session"><span class="Identifier">Session</span></a><span class="Other">;</span> <span class="Identifier">text</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">WriteDirEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
Persist the current prompt-editor text as an atomic draft sidecar so an unexpected shutdown never loses a half-typed prompt. Writes to whichever scope <tt class="docutils literal"><span class="pre"><span class="Identifier">currentDraftPath</span></span></tt> picks (cwd-keyed pending before the first turn, session-id-keyed after). A blank draft removes the sidecar rather than leaving an empty file, so an idle editor produces no draft. No-op without a cwd to key on (and no savePath).
</dd>
</div>
</div>
<div id="saveSession-procs-all">
<div id="saveSession,Session,JsonNode">
<dt><pre><span class="Keyword">proc</span> <a href="#saveSession%2CSession%2CJsonNode"><span class="Identifier">saveSession</span></a><span class="Other">(</span><span class="Identifier">session</span><span class="Other">:</span> <a href="types.html#Session"><span class="Identifier">Session</span></a><span class="Other">;</span> <span class="Identifier">messages</span><span class="Other">:</span> <span class="Identifier">JsonNode</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
<span class="Identifier">ReadDirEffect</span><span class="Other">,</span> <span class="Identifier">WriteDirEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span>
<span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="sessionDir-procs-all">
<div id="sessionDir">
<dt><pre><span class="Keyword">proc</span> <a href="#sessionDir"><span class="Identifier">sessionDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="sessionIdFromPath-procs-all">
<div id="sessionIdFromPath,string">
<dt><pre><span class="Keyword">proc</span> <a href="#sessionIdFromPath%2Cstring"><span class="Identifier">sessionIdFromPath</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="sessionLockDir-procs-all">
<div id="sessionLockDir">
<dt><pre><span class="Keyword">proc</span> <a href="#sessionLockDir"><span class="Identifier">sessionLockDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="sessionLockPathFor-procs-all">
<div id="sessionLockPathFor,string">
<dt><pre><span class="Keyword">proc</span> <a href="#sessionLockPathFor%2Cstring"><span class="Identifier">sessionLockPathFor</span></a><span class="Other">(</span><span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="sessionPathIndexDir-procs-all">
<div id="sessionPathIndexDir">
<dt><pre><span class="Keyword">proc</span> <a href="#sessionPathIndexDir"><span class="Identifier">sessionPathIndexDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
<div id="usageFromJson-procs-all">
<div id="usageFromJson,JsonNode">
<dt><pre><span class="Keyword">proc</span> <a href="#usageFromJson%2CJsonNode"><span class="Identifier">usageFromJson</span></a><span class="Other">(</span><span class="Identifier">j</span><span class="Other">:</span> <span class="Identifier">JsonNode</span><span class="Other">)</span><span class="Other">:</span> <a href="types.html#Usage"><span class="Identifier">Usage</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
<dd>
</dd>
</div>
</div>
</dl>
</div>
</div>
</div>
<div class="twelve-columns footer">
<span class="nim-sprite"></span>
<br>
<small style="color: var(--hint);">Made with Nim. Generated: 2026-06-27 09:42:01 UTC</small>
</div>
</div>
</div>
</body>
</html>