@theokit/agents 13.0.0-next.2 → 13.0.0-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/dist/session.d.ts +113 -33
- package/dist/session.js +98 -47
- package/dist/session.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# @theokit/agents
|
|
2
2
|
|
|
3
|
+
## 13.0.0-next.4
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a7f4d3d: `deleteSession` stops reporting a registry removal it cannot confirm
|
|
8
|
+
|
|
9
|
+
`registryRemoved` was computed as `outcome !== false`, so a remover that resolved saying **nothing**
|
|
10
|
+
was reported as a removal. That is the shape `Agent.delete` has — `Promise<void>` — and below
|
|
11
|
+
`@theokit/sdk@5.3.1` it is what a no-op returns: measured in `4.52.1`, `removeRegisteredAgent`
|
|
12
|
+
mutates an in-memory map and schedules a save only when the entry was in it, while `delete` — unlike
|
|
13
|
+
`list` — never hydrates from disk. In any freshly started process the entry is not in memory, so the
|
|
14
|
+
call resolves having left `registry.json` untouched and throws nothing.
|
|
15
|
+
|
|
16
|
+
Breaking, inside the unreleased 13.0.0 line:
|
|
17
|
+
|
|
18
|
+
- `DeleteSessionResult.registryRemoved: boolean` is replaced by
|
|
19
|
+
`registryOutcome: 'removed' | 'nothing-to-remove' | 'unconfirmed' | 'failed' | 'not-attempted'`.
|
|
20
|
+
Renamed rather than retyped: `if (result.registryRemoved)` would have kept compiling while
|
|
21
|
+
silently changing which branch it took.
|
|
22
|
+
- `SessionInUseError.registryRemoved` becomes `registryOutcome`, and the refusal no longer advertises
|
|
23
|
+
"the registry entry was already removed" for a half it cannot confirm — it tells the caller to
|
|
24
|
+
verify instead.
|
|
25
|
+
|
|
26
|
+
`not-attempted` and `unconfirmed` are distinct on purpose: "nobody asked" and "we asked and got
|
|
27
|
+
silence" lead a caller to opposite actions, and the old boolean said `false` to both.
|
|
28
|
+
|
|
29
|
+
The declared SDK range is unchanged. `5.3.1` fixes the behaviour and not the signature — `delete`
|
|
30
|
+
still returns `Promise<void>` — so `unconfirmed` remains the honest answer on every admitted version,
|
|
31
|
+
and raising the floor is a separate decision that would make the removal happen without making it
|
|
32
|
+
reportable.
|
|
33
|
+
|
|
34
|
+
Closes usetheokit/theokit#675.
|
|
35
|
+
|
|
36
|
+
## 13.0.0-next.3
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- 59d6dcc: A transcript nobody can read is listed without an id, and keeps its protection
|
|
41
|
+
|
|
42
|
+
`listSessions` fell back to the filename stem whenever the first record could not be read. Under
|
|
43
|
+
`@theokit/sdk` 5.x that stem is a one-way hash of the id, so the fallback did not return a degraded
|
|
44
|
+
id — it returned an identifier belonging to no session. Session GC keyed protection on it, so a
|
|
45
|
+
session someone had DECLARED protected lost its protection and was planned for deletion, while the
|
|
46
|
+
registry removal was called with the hash and left the real entry behind.
|
|
47
|
+
|
|
48
|
+
Protection now runs in the direction that has a function. `transcriptPath(root, cwd, id)` is total on
|
|
49
|
+
both majors and its inverse is not, so protection is keyed by transcript PATH and caller-supplied ids
|
|
50
|
+
are mapped forward onto paths. Whether a transcript can be read stops mattering to whether it is
|
|
51
|
+
protected.
|
|
52
|
+
|
|
53
|
+
Breaking, inside the unreleased 13.0.0 line:
|
|
54
|
+
|
|
55
|
+
- `SessionSummary.id` is `string | undefined`, alongside a new `idSource: 'transcript' | 'unavailable'`.
|
|
56
|
+
It is never derived from the filename.
|
|
57
|
+
- **`protectedTranscripts` is RENAMED to `protectedTranscriptPaths`, and the rename is the fix.** Its
|
|
58
|
+
keys changed from session ids to transcript paths while the signature stayed `Map<string, string>`,
|
|
59
|
+
so a consumer that mapped the keys forward through `transcriptPath` — correct when they were ids —
|
|
60
|
+
kept compiling and started double-mapping, leaving its protection array matching nothing. Measured
|
|
61
|
+
on a real consumer against this build: `deleteSession` collected a session holding a LIVE writer
|
|
62
|
+
lease. The old name is gone rather than aliased; a silent break that loses data is worse than a
|
|
63
|
+
loud one, and an alias would have preserved the silence. `transcriptOf(id, cwd, root)` maps forward
|
|
64
|
+
for callers that hold an id.
|
|
65
|
+
- `GCCandidate.id`, `GCKept.id` and `GCError.id` admit `undefined` for the same reason.
|
|
66
|
+
- `RunTranscriptGCResult` gains `orphaned` — transcripts collected whose session id could not be
|
|
67
|
+
read, by path. A separate list rather than a second meaning inside `removed`, which answers "which
|
|
68
|
+
sessions did I collect"; `theo sessions gc` reports both, and never prints a filename where an id
|
|
69
|
+
belongs.
|
|
70
|
+
|
|
71
|
+
Closes usetheokit/theokit#668.
|
|
72
|
+
|
|
3
73
|
## 13.0.0-next.2
|
|
4
74
|
|
|
5
75
|
### Minor Changes
|
package/dist/session.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ declare class SessionRegistryRemoverError extends TheokitAgentError {
|
|
|
50
50
|
*
|
|
51
51
|
* `Agent.delete` clears the REGISTRY ENTRY and never touches the transcript on disk. A consumer had
|
|
52
52
|
* to discover that by measuring. {@link deleteSession} is the answer: it returns
|
|
53
|
-
* `{
|
|
53
|
+
* `{ registryOutcome, transcriptRemoved }` so the two are impossible to confuse, and a caller that
|
|
54
54
|
* wanted both and got one can see it.
|
|
55
55
|
*/
|
|
56
56
|
/** Raised when a lifecycle operation is refused because the session is live. */
|
|
@@ -65,31 +65,46 @@ declare class SessionInUseError extends TheokitAgentError {
|
|
|
65
65
|
/** Why it is protected — a writer lease, the resumable pointer, or being the most recent. */
|
|
66
66
|
readonly reason: string;
|
|
67
67
|
/**
|
|
68
|
-
*
|
|
68
|
+
* What the registry half reported before the refusal, or `undefined` when it never ran.
|
|
69
69
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* needs
|
|
73
|
-
*
|
|
70
|
+
* Set only when the session became protected DURING the registry removal — the re-check fires
|
|
71
|
+
* after the await, so that half has already been attempted while the transcript stays. The
|
|
72
|
+
* caller needs it: retrying a removal that is already done reports "nothing to remove", which
|
|
73
|
+
* reads as a failure and is not one.
|
|
74
|
+
*
|
|
75
|
+
* Carries the OUTCOME rather than a boolean since #675. `unconfirmed` must not be advertised as
|
|
76
|
+
* "already removed" — that is the assertion the issue is about, and telling a caller not to
|
|
77
|
+
* retry a half that may never have happened is the expensive direction to be wrong in.
|
|
74
78
|
*/
|
|
75
|
-
readonly
|
|
79
|
+
readonly registryOutcome?: RegistryOutcome | undefined;
|
|
76
80
|
readonly name = "SessionInUseError";
|
|
77
81
|
constructor(sessionId: string,
|
|
78
82
|
/** Why it is protected — a writer lease, the resumable pointer, or being the most recent. */
|
|
79
83
|
reason: string,
|
|
80
84
|
/**
|
|
81
|
-
*
|
|
85
|
+
* What the registry half reported before the refusal, or `undefined` when it never ran.
|
|
86
|
+
*
|
|
87
|
+
* Set only when the session became protected DURING the registry removal — the re-check fires
|
|
88
|
+
* after the await, so that half has already been attempted while the transcript stays. The
|
|
89
|
+
* caller needs it: retrying a removal that is already done reports "nothing to remove", which
|
|
90
|
+
* reads as a failure and is not one.
|
|
82
91
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* which reads as a failure and is not one.
|
|
92
|
+
* Carries the OUTCOME rather than a boolean since #675. `unconfirmed` must not be advertised as
|
|
93
|
+
* "already removed" — that is the assertion the issue is about, and telling a caller not to
|
|
94
|
+
* retry a half that may never have happened is the expensive direction to be wrong in.
|
|
87
95
|
*/
|
|
88
|
-
|
|
96
|
+
registryOutcome?: RegistryOutcome | undefined);
|
|
89
97
|
}
|
|
90
98
|
/** One session as the lifecycle vocabulary sees it. */
|
|
91
99
|
interface SessionSummary {
|
|
92
|
-
|
|
100
|
+
/**
|
|
101
|
+
* The session id read from the transcript's first record, or `undefined` when the record could
|
|
102
|
+
* not be read. It is NEVER derived from the filename: on `@theokit/sdk` 5.x the name is a one-way
|
|
103
|
+
* hash of the id, so a name-derived value would name no session at all (usetheokit/theokit#668).
|
|
104
|
+
*/
|
|
105
|
+
readonly id: string | undefined;
|
|
106
|
+
/** Where {@link SessionSummary.id} came from — so a caller can tell absence from a value. */
|
|
107
|
+
readonly idSource: 'transcript' | 'unavailable';
|
|
93
108
|
/** Absolute path of the transcript file. */
|
|
94
109
|
readonly transcript: string;
|
|
95
110
|
/** Last modification, for recency ordering. */
|
|
@@ -111,19 +126,80 @@ declare function listSessions(cwd: string, root?: string): SessionSummary[];
|
|
|
111
126
|
* is far less useful than one reporting why each was skipped, and retention policy is exactly where
|
|
112
127
|
* an operator asks that question.
|
|
113
128
|
*/
|
|
114
|
-
|
|
129
|
+
/**
|
|
130
|
+
* RENAMED from `protectedTranscripts` by usetheokit/theokit#668, and the rename IS the fix for the
|
|
131
|
+
* second half of that issue.
|
|
132
|
+
*
|
|
133
|
+
* The keys changed from session ids to transcript paths, and the signature did not:
|
|
134
|
+
* `Map<string, string>` before and `Map<string, string>` after. A consumer that mapped the keys
|
|
135
|
+
* forward through `transcriptPath` — the correct thing to do when they were ids — went on compiling
|
|
136
|
+
* and started double-mapping, so its protection array matched nothing and its delete guard passed.
|
|
137
|
+
* Measured on TheoCode against this very build: `deleteSession` collected a session with a LIVE
|
|
138
|
+
* writer lease, and no type could have caught it.
|
|
139
|
+
*
|
|
140
|
+
* A silent break that loses data is worse than a loud one. The old name is GONE rather than aliased,
|
|
141
|
+
* so a caller finds out at compile time instead of at delete time. Aliasing it would have preserved
|
|
142
|
+
* exactly the silence this rename exists to remove.
|
|
143
|
+
*/
|
|
144
|
+
declare function protectedTranscriptPaths(cwd: string, root?: string): Map<string, string>;
|
|
145
|
+
/**
|
|
146
|
+
* The transcript a session id would occupy, for keying protection.
|
|
147
|
+
*
|
|
148
|
+
* Protection runs id → PATH and never the reverse, because that is the direction with a function:
|
|
149
|
+
* `transcriptPath` is total on both majors, while 5.x's naming is a one-way hash. Keying on the id
|
|
150
|
+
* meant a transcript nobody could read could not be matched against anything, so a session someone
|
|
151
|
+
* had DECLARED protected became collectable (usetheokit/theokit#668).
|
|
152
|
+
*/
|
|
153
|
+
declare function transcriptOf(id: string, cwd: string, root?: string): string;
|
|
115
154
|
/** What `deleteSession` did, per store. */
|
|
155
|
+
/**
|
|
156
|
+
* What the injected registry remover actually told us — REPLACES the `registryRemoved` boolean
|
|
157
|
+
* (usetheokit/theokit#675).
|
|
158
|
+
*
|
|
159
|
+
* There are three outcomes and a boolean could carry two, so the third was folded into `true`:
|
|
160
|
+
*
|
|
161
|
+
* - `removed` the remover reported that it removed an entry
|
|
162
|
+
* - `nothing-to-remove` the remover reported that there was none — a report, and an ordinary one
|
|
163
|
+
* - `unconfirmed` the remover ran, resolved, and said NOTHING
|
|
164
|
+
* - `failed` it threw or timed out; see `registryError`
|
|
165
|
+
* - `not-attempted` no remover was supplied, so the registry was never touched
|
|
166
|
+
*
|
|
167
|
+
* `not-attempted` and `unconfirmed` are deliberately not the same value. "Nobody asked" and "we
|
|
168
|
+
* asked and got silence" lead a caller to opposite actions, and the old boolean said `false` to
|
|
169
|
+
* both.
|
|
170
|
+
*
|
|
171
|
+
* `unconfirmed` is the one that matters, and it is the common case rather than an exotic one.
|
|
172
|
+
* `Agent.delete` returns `Promise<void>`: measured in `@theokit/sdk@4.52.1` and confirmed by the
|
|
173
|
+
* SDK's changelog for `5.3.1`, it mutates an in-memory map and — unlike `Agent.list` — never
|
|
174
|
+
* hydrates from disk, so in any freshly started process it resolves having removed nothing and
|
|
175
|
+
* throws nothing. Reporting that as a removal was this package asserting something no version below
|
|
176
|
+
* 5.3.1 gives it any way to know.
|
|
177
|
+
*
|
|
178
|
+
* `5.3.1` fixes the BEHAVIOUR and not the signature: `Agent.delete` still returns `Promise<void>`,
|
|
179
|
+
* so `unconfirmed` stays the honest answer on every version this package admits. Raising the floor
|
|
180
|
+
* would make the removal actually happen; it would not make it reportable, which is why the two are
|
|
181
|
+
* separate decisions.
|
|
182
|
+
*
|
|
183
|
+
* A caller that needs certainty verifies from its own side; this package deliberately does not own
|
|
184
|
+
* the registry (see `gc/registry-remover.ts`). `Agent.list` hydrates from disk — which `delete`
|
|
185
|
+
* never does, and that asymmetry IS the upstream defect — so it is the read that can answer.
|
|
186
|
+
*/
|
|
187
|
+
type RegistryOutcome = 'removed' | 'nothing-to-remove' | 'unconfirmed' | 'failed' | 'not-attempted';
|
|
116
188
|
interface DeleteSessionResult {
|
|
117
|
-
/**
|
|
118
|
-
|
|
189
|
+
/**
|
|
190
|
+
* What the registry remover reported. RENAMED from `registryRemoved` by #675: the meaning
|
|
191
|
+
* changed, and a boolean under the old name would have kept `if (result.registryRemoved)`
|
|
192
|
+
* compiling while silently flipping which branch it took.
|
|
193
|
+
*/
|
|
194
|
+
readonly registryOutcome: RegistryOutcome;
|
|
119
195
|
/** Whether the transcript file was removed. */
|
|
120
196
|
readonly transcriptRemoved: boolean;
|
|
121
197
|
/**
|
|
122
198
|
* Why the registry removal failed, when it did.
|
|
123
199
|
*
|
|
124
|
-
* Kept SEPARATE from `
|
|
125
|
-
* exactly how the original silent success hid. A caller that only
|
|
126
|
-
* `
|
|
200
|
+
* Kept SEPARATE from `registryOutcome` on purpose: collapsing the outcomes into one value is
|
|
201
|
+
* exactly how the original silent success hid. A caller that only reads the outcome sees
|
|
202
|
+
* `failed` and can still surface the reason.
|
|
127
203
|
*/
|
|
128
204
|
readonly registryError?: unknown;
|
|
129
205
|
}
|
|
@@ -278,13 +354,15 @@ declare class GCFloorError extends TheokitAgentError {
|
|
|
278
354
|
}
|
|
279
355
|
/** A transcript the policy would collect. */
|
|
280
356
|
interface GCCandidate {
|
|
281
|
-
|
|
357
|
+
/** `undefined` when the transcript could not be read — see `SessionSummary.id` (#668). */
|
|
358
|
+
readonly id: string | undefined;
|
|
282
359
|
readonly transcript: string;
|
|
283
360
|
readonly modifiedAt: Date;
|
|
284
361
|
}
|
|
285
362
|
/** A transcript the policy keeps, and why. */
|
|
286
363
|
interface GCKept {
|
|
287
|
-
|
|
364
|
+
/** `undefined` when the transcript could not be read — see `SessionSummary.id` (#668). */
|
|
365
|
+
readonly id: string | undefined;
|
|
288
366
|
/** Human-readable protection reason — recency, policy, lease, or unreadable age. */
|
|
289
367
|
readonly reason: string;
|
|
290
368
|
}
|
|
@@ -300,7 +378,7 @@ interface TranscriptGCOptions {
|
|
|
300
378
|
/**
|
|
301
379
|
* Extra sessions this framework cannot see are live.
|
|
302
380
|
*
|
|
303
|
-
* `
|
|
381
|
+
* `protectedTranscriptPaths` derives protection from THIS framework's pointer convention. A consumer
|
|
304
382
|
* whose live-session registry lives elsewhere gets an INERT guard — silently, inside a guard that
|
|
305
383
|
* deletes user transcripts. That is the shape of the consumer's own PS-002: declared, wired, never
|
|
306
384
|
* called, and therefore reading as protection while protecting nothing.
|
|
@@ -324,24 +402,26 @@ interface TranscriptGCPlan {
|
|
|
324
402
|
declare function planTranscriptGC(options: TranscriptGCOptions): TranscriptGCPlan;
|
|
325
403
|
/** What one candidate's removal did, or why it did not. */
|
|
326
404
|
interface GCError {
|
|
327
|
-
|
|
405
|
+
/** `undefined` when the failure IS that no id could be read (#668). */
|
|
406
|
+
readonly id: string | undefined;
|
|
328
407
|
readonly message: string;
|
|
329
408
|
}
|
|
330
409
|
interface RunTranscriptGCResult {
|
|
331
410
|
readonly dryRun: boolean;
|
|
332
411
|
/** Ids that were (or, in a dry run, would be) removed. */
|
|
333
412
|
readonly removed: readonly string[];
|
|
413
|
+
/**
|
|
414
|
+
* Transcripts collected whose session id could NOT be read, by path.
|
|
415
|
+
*
|
|
416
|
+
* A separate list rather than a second meaning inside `removed`: that one answers "which sessions
|
|
417
|
+
* did I collect", this one answers "which files did I collect that I could not name". Folding them
|
|
418
|
+
* together would put two kinds of string in one array and make every consumer guess which it held
|
|
419
|
+
* (usetheokit/theokit#668).
|
|
420
|
+
*/
|
|
421
|
+
readonly orphaned: readonly string[];
|
|
334
422
|
/** One entry per candidate that failed — the rest still ran. */
|
|
335
423
|
readonly errors: readonly GCError[];
|
|
336
424
|
}
|
|
337
|
-
/**
|
|
338
|
-
* Execute a plan. `apply: false` reports what would happen and changes nothing.
|
|
339
|
-
*
|
|
340
|
-
* Errors accumulate PER CANDIDATE (fail-open): one undeletable file must not leave the rest of the
|
|
341
|
-
* disk uncollected, and the operator must still learn which one failed. `ENOENT` counts as success —
|
|
342
|
-
* absent is the desired end state, and reporting it as failure would make the second run of an
|
|
343
|
-
* interrupted GC look broken.
|
|
344
|
-
*/
|
|
345
425
|
declare function runTranscriptGC(plan: TranscriptGCPlan, options: {
|
|
346
426
|
readonly apply: boolean;
|
|
347
427
|
/** Same additive, fail-closed contract as on the plan — see `TranscriptGCOptions.protectedIds`. */
|
|
@@ -577,4 +657,4 @@ declare class LivenessBudgetError extends TheokitAgentError {
|
|
|
577
657
|
*/
|
|
578
658
|
declare function classifyProjects(encoded: readonly string[], opts: ClassifyProjectsOptions): Map<string, LivenessVerdict>;
|
|
579
659
|
|
|
580
|
-
export { type ClassifyProjectsOptions, type DeleteSessionOptions, type DeleteSessionResult, type FsSeam, type GCCandidate, type GCError, GCFloorError, type GCKept, GCProtectionUnavailableError, type Liveness, LivenessBudgetError, type LivenessVerdict, type ReadThreadHistoryOptions, type RunTranscriptGCResult, SessionInUseError, SessionRegistryRemoverError, type SessionSummary, type ThreadHistory, type ThreadHistoryState, type TranscriptGCOptions, type TranscriptGCPlan, classifyProjects, deleteSession, forkBeforeUserTurn, listSessions, loadOrCreateSessionId, persistSessionId, planTranscriptGC, projectDirFor, projectDirMatches, projectsRoot,
|
|
660
|
+
export { type ClassifyProjectsOptions, type DeleteSessionOptions, type DeleteSessionResult, type FsSeam, type GCCandidate, type GCError, GCFloorError, type GCKept, GCProtectionUnavailableError, type Liveness, LivenessBudgetError, type LivenessVerdict, type ReadThreadHistoryOptions, type RunTranscriptGCResult, SessionInUseError, SessionRegistryRemoverError, type SessionSummary, type ThreadHistory, type ThreadHistoryState, type TranscriptGCOptions, type TranscriptGCPlan, classifyProjects, deleteSession, forkBeforeUserTurn, listSessions, loadOrCreateSessionId, persistSessionId, planTranscriptGC, projectDirFor, projectDirMatches, projectsRoot, protectedTranscriptPaths, readThreadHistory, recordProjectDir, resolveProjectDir, runTranscriptGC, sessionPointerPath, transcriptOf, transcriptRootHint };
|
package/dist/session.js
CHANGED
|
@@ -133,12 +133,22 @@ var SessionInUseError = class extends TheokitAgentError2 {
|
|
|
133
133
|
}
|
|
134
134
|
sessionId;
|
|
135
135
|
reason;
|
|
136
|
-
|
|
136
|
+
registryOutcome;
|
|
137
137
|
name = "SessionInUseError";
|
|
138
|
-
constructor(sessionId, reason,
|
|
139
|
-
super(`session "${sessionId}" is protected (${reason}). Deleting it would discard state something is still using. Stop the run, or pass { force: true } to delete anyway.` + (
|
|
138
|
+
constructor(sessionId, reason, registryOutcome) {
|
|
139
|
+
super(`session "${sessionId}" is protected (${reason}). Deleting it would discard state something is still using. Stop the run, or pass { force: true } to delete anyway.` + registryNote(registryOutcome)), this.sessionId = sessionId, this.reason = reason, this.registryOutcome = registryOutcome;
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
+
function registryNote(outcome) {
|
|
143
|
+
if (outcome === "removed") {
|
|
144
|
+
return ` The registry entry was already removed before this was noticed \u2014 do not retry that half, only the transcript.`;
|
|
145
|
+
}
|
|
146
|
+
if (outcome === "unconfirmed") {
|
|
147
|
+
return ` The registry removal was already attempted and reported nothing, so whether the entry is gone is unknown \u2014 verify it before retrying.`;
|
|
148
|
+
}
|
|
149
|
+
return "";
|
|
150
|
+
}
|
|
151
|
+
__name(registryNote, "registryNote");
|
|
142
152
|
function listSessions(cwd, root = transcriptRoot3()) {
|
|
143
153
|
const dir = projectDirFor(cwd, root);
|
|
144
154
|
let entries;
|
|
@@ -161,8 +171,10 @@ function listSessions(cwd, root = transcriptRoot3()) {
|
|
|
161
171
|
}
|
|
162
172
|
const kind = classifySessionArtifact(entry, isDirectory);
|
|
163
173
|
if (kind !== "transcript") continue;
|
|
174
|
+
const id = sessionIdOf(path);
|
|
164
175
|
found.push({
|
|
165
|
-
id
|
|
176
|
+
id,
|
|
177
|
+
idSource: id === void 0 ? "unavailable" : "transcript",
|
|
166
178
|
transcript: path,
|
|
167
179
|
modifiedAt
|
|
168
180
|
});
|
|
@@ -170,8 +182,7 @@ function listSessions(cwd, root = transcriptRoot3()) {
|
|
|
170
182
|
return found.sort((a, b) => b.modifiedAt.getTime() - a.modifiedAt.getTime());
|
|
171
183
|
}
|
|
172
184
|
__name(listSessions, "listSessions");
|
|
173
|
-
function sessionIdOf(path
|
|
174
|
-
const stem = entry.replace(/\.jsonl$/, "");
|
|
185
|
+
function sessionIdOf(path) {
|
|
175
186
|
let fd;
|
|
176
187
|
try {
|
|
177
188
|
fd = openSync(path, "r");
|
|
@@ -188,25 +199,31 @@ function sessionIdOf(path, entry) {
|
|
|
188
199
|
} finally {
|
|
189
200
|
if (fd !== void 0) closeSync(fd);
|
|
190
201
|
}
|
|
191
|
-
return
|
|
202
|
+
return void 0;
|
|
192
203
|
}
|
|
193
204
|
__name(sessionIdOf, "sessionIdOf");
|
|
194
205
|
var FIRST_RECORD_BYTES = 64 * 1024;
|
|
195
|
-
function
|
|
206
|
+
function protectedTranscriptPaths(cwd, root = transcriptRoot3()) {
|
|
196
207
|
const protectedBy = /* @__PURE__ */ new Map();
|
|
197
208
|
const sessions = listSessions(cwd, root);
|
|
198
209
|
const pointer = readPointer(cwd, root);
|
|
199
|
-
if (pointer !== void 0)
|
|
200
|
-
|
|
201
|
-
|
|
210
|
+
if (pointer !== void 0) {
|
|
211
|
+
protectedBy.set(transcriptPath(root, cwd, pointer), "resumable session pointer");
|
|
212
|
+
}
|
|
213
|
+
if (sessions.length > 0 && !protectedBy.has(sessions[0].transcript)) {
|
|
214
|
+
protectedBy.set(sessions[0].transcript, "most recent session");
|
|
202
215
|
}
|
|
203
216
|
for (const session of sessions) {
|
|
204
217
|
const hasWriter = sessionHasWriter(session.transcript);
|
|
205
|
-
if (hasWriter) protectedBy.set(session.
|
|
218
|
+
if (hasWriter) protectedBy.set(session.transcript, "active writer lease");
|
|
206
219
|
}
|
|
207
220
|
return protectedBy;
|
|
208
221
|
}
|
|
209
|
-
__name(
|
|
222
|
+
__name(protectedTranscriptPaths, "protectedTranscriptPaths");
|
|
223
|
+
function transcriptOf(id, cwd, root = transcriptRoot3()) {
|
|
224
|
+
return transcriptPath(root, cwd, id);
|
|
225
|
+
}
|
|
226
|
+
__name(transcriptOf, "transcriptOf");
|
|
210
227
|
function readPointer(cwd, root) {
|
|
211
228
|
try {
|
|
212
229
|
const id = readFileSync3(sessionPointerPath(cwd, root), "utf8").trim();
|
|
@@ -219,27 +236,29 @@ __name(readPointer, "readPointer");
|
|
|
219
236
|
async function deleteSession(sessionId, options) {
|
|
220
237
|
const root = options.root ?? transcriptRoot3();
|
|
221
238
|
if (options.force !== true) {
|
|
222
|
-
const reason =
|
|
239
|
+
const reason = protectedTranscriptPaths(options.cwd, root).get(transcriptOf(sessionId, options.cwd, root));
|
|
223
240
|
if (reason !== void 0) throw new SessionInUseError(sessionId, reason);
|
|
224
241
|
}
|
|
225
|
-
let
|
|
242
|
+
let registryOutcome = "not-attempted";
|
|
226
243
|
let registryError;
|
|
227
244
|
if (options.removeFromRegistry !== void 0) {
|
|
228
245
|
try {
|
|
229
246
|
const outcome = await awaitRegistryRemoval(options.removeFromRegistry(sessionId), sessionId, options.registryTimeoutMs);
|
|
230
|
-
|
|
247
|
+
if (outcome === false) registryOutcome = "nothing-to-remove";
|
|
248
|
+
else if (outcome === void 0) registryOutcome = "unconfirmed";
|
|
249
|
+
else registryOutcome = "removed";
|
|
231
250
|
} catch (error) {
|
|
232
251
|
return {
|
|
233
|
-
|
|
252
|
+
registryOutcome: "failed",
|
|
234
253
|
transcriptRemoved: false,
|
|
235
254
|
registryError: error
|
|
236
255
|
};
|
|
237
256
|
}
|
|
238
257
|
}
|
|
239
258
|
if (options.force !== true) {
|
|
240
|
-
const nowProtected =
|
|
259
|
+
const nowProtected = protectedTranscriptPaths(options.cwd, root).get(transcriptOf(sessionId, options.cwd, root));
|
|
241
260
|
if (nowProtected !== void 0) {
|
|
242
|
-
throw new SessionInUseError(sessionId, nowProtected,
|
|
261
|
+
throw new SessionInUseError(sessionId, nowProtected, registryOutcome);
|
|
243
262
|
}
|
|
244
263
|
}
|
|
245
264
|
let transcriptRemoved = false;
|
|
@@ -249,7 +268,7 @@ async function deleteSession(sessionId, options) {
|
|
|
249
268
|
} catch {
|
|
250
269
|
}
|
|
251
270
|
return {
|
|
252
|
-
|
|
271
|
+
registryOutcome,
|
|
253
272
|
transcriptRemoved,
|
|
254
273
|
registryError
|
|
255
274
|
};
|
|
@@ -273,7 +292,7 @@ function forkBeforeUserTurn(srcId, newId, nth, options) {
|
|
|
273
292
|
forkTranscript(src, dst, {
|
|
274
293
|
beforeRecordIndex: selected.index,
|
|
275
294
|
liveSessionPaths: [
|
|
276
|
-
...
|
|
295
|
+
...protectedTranscriptPaths(options.cwd, root).keys()
|
|
277
296
|
].map((id) => transcriptPath(root, options.cwd, id))
|
|
278
297
|
});
|
|
279
298
|
return {
|
|
@@ -319,7 +338,7 @@ __name(reachableUserTurns, "reachableUserTurns");
|
|
|
319
338
|
// src/session/gc/transcript-gc.ts
|
|
320
339
|
import { rmSync as rmSync2 } from "fs";
|
|
321
340
|
import { TheokitAgentError as TheokitAgentError3 } from "@theokit/sdk/errors";
|
|
322
|
-
import {
|
|
341
|
+
import { transcriptRoot as transcriptRoot4 } from "@theokit/sdk/persistence";
|
|
323
342
|
var FLOOR = {
|
|
324
343
|
keepLast: 1,
|
|
325
344
|
maxAgeDays: 1
|
|
@@ -349,7 +368,7 @@ var GCFloorError = class extends TheokitAgentError3 {
|
|
|
349
368
|
super(`transcript GC: \`${field}\` must be at least ${String(FLOOR[field])}, received ${String(received)}. This is refused rather than clamped: a policy silently replaced by a different one is a policy nobody reviewed.`), this.field = field, this.received = received;
|
|
350
369
|
}
|
|
351
370
|
};
|
|
352
|
-
function resolveProtection(builtin, provider) {
|
|
371
|
+
function resolveProtection(builtin, provider, cwd, root) {
|
|
353
372
|
if (provider === void 0) return builtin;
|
|
354
373
|
let extra;
|
|
355
374
|
try {
|
|
@@ -357,8 +376,9 @@ function resolveProtection(builtin, provider) {
|
|
|
357
376
|
} catch (cause) {
|
|
358
377
|
throw new GCProtectionUnavailableError(cause);
|
|
359
378
|
}
|
|
360
|
-
const union = new Map(
|
|
361
|
-
for (const [id, reason] of
|
|
379
|
+
const union = /* @__PURE__ */ new Map();
|
|
380
|
+
for (const [id, reason] of extra) union.set(transcriptOf(id, cwd, root), reason);
|
|
381
|
+
for (const [path, reason] of builtin) union.set(path, reason);
|
|
362
382
|
return union;
|
|
363
383
|
}
|
|
364
384
|
__name(resolveProtection, "resolveProtection");
|
|
@@ -373,11 +393,11 @@ function planTranscriptGC(options) {
|
|
|
373
393
|
const now = options.now ?? Date.now();
|
|
374
394
|
const cutoff = now - options.maxAgeDays * 864e5;
|
|
375
395
|
const sessions = listSessions(options.cwd, root);
|
|
376
|
-
const protectedBy = resolveProtection(
|
|
396
|
+
const protectedBy = resolveProtection(protectedTranscriptPaths(options.cwd, root), options.protectedIds, options.cwd, root);
|
|
377
397
|
const candidates = [];
|
|
378
398
|
const kept = [];
|
|
379
399
|
for (const [index, session] of sessions.entries()) {
|
|
380
|
-
const protection = protectedBy.get(session.
|
|
400
|
+
const protection = protectedBy.get(session.transcript);
|
|
381
401
|
if (protection !== void 0) {
|
|
382
402
|
kept.push({
|
|
383
403
|
id: session.id,
|
|
@@ -421,33 +441,62 @@ function planTranscriptGC(options) {
|
|
|
421
441
|
};
|
|
422
442
|
}
|
|
423
443
|
__name(planTranscriptGC, "planTranscriptGC");
|
|
444
|
+
async function releaseFromRegistry(candidate, options) {
|
|
445
|
+
if (candidate.id === void 0) {
|
|
446
|
+
return {
|
|
447
|
+
note: {
|
|
448
|
+
id: void 0,
|
|
449
|
+
message: UNNAMEABLE_COLLECTION
|
|
450
|
+
},
|
|
451
|
+
unlink: true
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
if (options.removeFromRegistry === void 0) return {
|
|
455
|
+
unlink: true
|
|
456
|
+
};
|
|
457
|
+
try {
|
|
458
|
+
await awaitRegistryRemoval(options.removeFromRegistry(candidate.id), candidate.id, options.registryTimeoutMs);
|
|
459
|
+
return {
|
|
460
|
+
unlink: true
|
|
461
|
+
};
|
|
462
|
+
} catch (error) {
|
|
463
|
+
return {
|
|
464
|
+
note: {
|
|
465
|
+
id: candidate.id,
|
|
466
|
+
message: `registry removal failed, transcript kept: ${error.message}`
|
|
467
|
+
},
|
|
468
|
+
unlink: false
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
__name(releaseFromRegistry, "releaseFromRegistry");
|
|
473
|
+
var UNNAMEABLE_COLLECTION = "transcript collected without a registry removal: its session id could not be read, and a fabricated one would name no session";
|
|
474
|
+
function recordRemoval(candidate, removed, orphaned) {
|
|
475
|
+
if (candidate.id === void 0) orphaned.push(candidate.transcript);
|
|
476
|
+
else removed.push(candidate.id);
|
|
477
|
+
}
|
|
478
|
+
__name(recordRemoval, "recordRemoval");
|
|
424
479
|
async function runTranscriptGC(plan, options) {
|
|
425
480
|
const removed = [];
|
|
481
|
+
const orphaned = [];
|
|
426
482
|
const errors = [];
|
|
427
|
-
const protectedNow = options.apply ? resolveProtection(
|
|
483
|
+
const protectedNow = options.apply ? resolveProtection(protectedTranscriptPaths(plan.cwd, plan.root), options.protectedIds, plan.cwd, plan.root) : /* @__PURE__ */ new Map();
|
|
428
484
|
for (const candidate of plan.candidates) {
|
|
429
|
-
if (protectedNow.has(candidate.
|
|
485
|
+
if (protectedNow.has(candidate.transcript)) continue;
|
|
430
486
|
if (!options.apply) {
|
|
431
|
-
|
|
487
|
+
if (candidate.id === void 0) orphaned.push(candidate.transcript);
|
|
488
|
+
else removed.push(candidate.id);
|
|
432
489
|
continue;
|
|
433
490
|
}
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
} catch (error) {
|
|
438
|
-
errors.push({
|
|
439
|
-
id: candidate.id,
|
|
440
|
-
message: `registry removal failed, transcript kept: ${error.message}`
|
|
441
|
-
});
|
|
442
|
-
continue;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
491
|
+
const registry = await releaseFromRegistry(candidate, options);
|
|
492
|
+
if (registry.note !== void 0) errors.push(registry.note);
|
|
493
|
+
if (!registry.unlink) continue;
|
|
445
494
|
try {
|
|
446
|
-
rmSync2(
|
|
447
|
-
|
|
495
|
+
rmSync2(candidate.transcript);
|
|
496
|
+
recordRemoval(candidate, removed, orphaned);
|
|
448
497
|
} catch (error) {
|
|
449
498
|
if (error.code === "ENOENT") {
|
|
450
|
-
|
|
499
|
+
recordRemoval(candidate, removed, orphaned);
|
|
451
500
|
continue;
|
|
452
501
|
}
|
|
453
502
|
errors.push({
|
|
@@ -459,6 +508,7 @@ async function runTranscriptGC(plan, options) {
|
|
|
459
508
|
return {
|
|
460
509
|
dryRun: !options.apply,
|
|
461
510
|
removed,
|
|
511
|
+
orphaned,
|
|
462
512
|
errors
|
|
463
513
|
};
|
|
464
514
|
}
|
|
@@ -483,13 +533,13 @@ function transcriptRootHint(found, previousRoot, env = process.env) {
|
|
|
483
533
|
__name(transcriptRootHint, "transcriptRootHint");
|
|
484
534
|
|
|
485
535
|
// src/session/thread-history.ts
|
|
486
|
-
import { loadJsonl as loadJsonl2, transcriptPath as
|
|
536
|
+
import { loadJsonl as loadJsonl2, transcriptPath as transcriptPath2, transcriptRoot as transcriptRoot5 } from "@theokit/sdk/persistence";
|
|
487
537
|
var ABSENT = {
|
|
488
538
|
state: "absent",
|
|
489
539
|
messages: []
|
|
490
540
|
};
|
|
491
541
|
function readThreadHistory(sessionId, options) {
|
|
492
|
-
const path =
|
|
542
|
+
const path = transcriptPath2(options.root ?? transcriptRoot5(), options.cwd, sessionId);
|
|
493
543
|
try {
|
|
494
544
|
return {
|
|
495
545
|
state: "present",
|
|
@@ -708,12 +758,13 @@ export {
|
|
|
708
758
|
projectDirFor,
|
|
709
759
|
projectDirMatches,
|
|
710
760
|
projectsRoot,
|
|
711
|
-
|
|
761
|
+
protectedTranscriptPaths,
|
|
712
762
|
readThreadHistory,
|
|
713
763
|
recordProjectDir,
|
|
714
764
|
resolveProjectDir,
|
|
715
765
|
runTranscriptGC,
|
|
716
766
|
sessionPointerPath,
|
|
767
|
+
transcriptOf,
|
|
717
768
|
transcriptRootHint
|
|
718
769
|
};
|
|
719
770
|
//# sourceMappingURL=session.js.map
|
package/dist/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/session/session-lifecycle.ts","../src/session/gc/registry-remover.ts","../src/session/project-index.ts","../src/session/session-pointer.ts","../src/session/gc/transcript-gc.ts","../src/session/transcript-root-hint.ts","../src/session/thread-history.ts","../src/session/liveness-oracle.ts"],"mappings":";;;;;;;;AAKA,SAASA,WAAWC,UAAUC,gBAAAA,eAAcC,aAAaC,UAAUC,QAAQC,gBAAgB;AAC3F,SAASC,QAAAA,aAAY;AAErB,SAASC,qBAAAA,0BAAyB;AAClC,SACEC,yBACAC,gBACAC,WACAC,kBACAC,gBACAC,kBAAAA,uBACK;;;ACEP,SAASC,yBAAyB;AAQ3B,IAAMC,8BAAN,cAA0CC,kBAAAA;EA1BjD,OA0BiDA;;;EAC7BC,OAAO;EAChBC;EAET,YAAYA,WAAmBC,WAAmB;AAChD,UACE,uDAAuDD,SAAAA,yCACpCE,OAAOD,SAAAA,CAAAA,8MAEqB;AAEjD,SAAKD,YAAYA;EACnB;AACF;AAeO,IAAMG,8BAA8B;AAE3C,SAASC,WAAWC,OAAc;AAChC,SAAO,OAAQA,OAAuCC,SAAS;AACjE;AAFSF;AAmBT,eAAsBG,qBACpBC,SACAR,WACAC,YAAgCE,6BAA2B;AAE3D,MAAI,CAACC,WAAWI,OAAAA,KAAY,CAACC,OAAOC,SAAST,SAAAA,EAAY,QAAOO;AAChE,MAAIG;AACJ,MAAI;AACF,WAAO,MAAMC,QAAQC,K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AAgBC,QAAQqC;IAAiB,CAAA;EAE7D;AAEA,SAAO/B;AACT;AA1KgBH;","names":["closeSync","openSync","readFileSync","readdirSync","readSync","rmSync","statSync","join","TheokitAgentError","classifySessionArtifact","forkTranscript","loadJsonl","sessionHasWriter","transcriptPath","transcriptRoot","TheokitAgentError","SessionRegistryRemoverError","TheokitAgentError","name","sessionId","timeoutMs","String","DEFAULT_REGISTRY_TIMEOUT_MS","isThenable","value","then","awaitRegistryRemoval","outcome","Number","isFinite","timer","Promise","race","_resolve","reject","setTimeout","undefined","clearTimeout","readFileSync","writeFileSync","join","encodeProjectDir","transcriptRoot","CWD_SIDECAR","projectsRoot","root","transcriptRoot","join","projectDirFor","cwd","encodeProjectDir","recordProjectDir","sidecar","ensureSecureDir","writeFileSync","resolveProjectDir","encodedName","raw","readFileSync","trim","length","undefined","projectDirMatches","readFileSync","join","atomicWriteText","transcriptRoot","POINTER","sessionPointerPath","cwd","root","transcriptRoot","join","projectDirFor","loadOrCreateSessionId","mintId","existing","readFileSync","trim","length","sessionId","resumed","persistSessionId","target","ensureSecureDir","atomicWriteText","persisted","SessionInUseError","TheokitAgentError","name","sessionId","reason","registryRemoved","listSessions","cwd","root","transcriptRoot","dir","projectDirFor","entries","readdirSync","found","entry","path","join","isDirectory","modifiedAt","stats","statSync","mtime","kind","classifySessionArtifact","push","id","sessionIdOf","transcript","sort","a","b","getTime","stem","replace","fd","openSync","buffer","Buffer","alloc","FIRST_RECORD_BYTES","read","readSync","newline","indexOf","end","first","JSON","parse","toString","length","undefined","closeSync","protectedTranscripts","protectedBy","Map","sessions","pointer","readPointer","set","has","session","hasWriter","sessionHasWriter","readFileSync","sessionPointerPath","trim","deleteSession","options","force","get","registryError","removeFromRegistry","outcome","awaitRegistryRemoval","registryTimeoutMs","error","transcriptRemoved","nowProtected","rmSync","transcriptPath","forkBeforeUserTurn","srcId","newId","nth","Number","isInteger","String","src","dst","turns","reachableUserTurns","selected","forkTranscript","beforeRecordIndex","index","liveSessionPaths","keys","map","recordIndex","selectedText","text","GOAL_CONTINUATION_MARKER","textOfRecord","record","message","content","filter","block","type","isGenuineUserTurn","startsWith","records","loadJsonl","floor","i","subtype","rmSync","TheokitAgentError","transcriptPath","transcriptRoot","FLOOR","keepLast","maxAgeDays","GCProtectionUnavailableError","TheokitAgentError","name","reason","Error","message","String","code","isRetryable","cause","GCFloorError","field","received","resolveProtection","builtin","provider","undefined","extra","union","Map","id","set","planTranscriptGC","options","Number","isFinite","root","transcriptRoot","now","Date","cutoff","sessions","listSessions","cwd","protectedBy","protectedTranscripts","protectedIds","candidates","kept","index","session","entries","protection","get","push","age","modifiedAt","getTime","isNaN","transcript","runTranscriptGC","plan","removed","errors","protectedNow","apply","candidate","has","removeFromRegistry","awaitRegistryRemoval","registryTimeoutMs","error","rmSync","transcriptPath","dryRun","readdirSync","transcriptRootHint","found","previousRoot","env","process","undefined","current","THEOKIT_HOME","trim","length","projects","readdirSync","projectsRoot","String","loadJsonl","transcriptPath","transcriptRoot","ABSENT","state","messages","readThreadHistory","sessionId","options","path","transcriptPath","root","transcriptRoot","cwd","loadJsonl","err","isNotFound","reason","messageOf","code","Error","message","String","TheokitAgentError","DEFAULT_TRANSCRIPT_SAMPLES","encodeProjectDir","cwd","replace","LivenessBudgetError","TheokitAgentError","budget","String","assertUsableBudget","Number","isInteger","verdictFromRecordedCwds","cwds","probe","budgetLeft","unprobeable","at","error","found","liveness","reason","undefined","join","classifyProjects","encoded","opts","out","Map","remaining","path","answer","fs","exists","Error","message","recordedCwd","name","dir","projectsRoot","entries","listEntries","kind","samples","transcriptSamples","file","filter","f","endsWith","slice","record","JSON","parse","firstLine","length","includes","push","candidates","enumerationError","enumerate","candidatePaths","searchPool","pool","seen","Set","candidate","has","add","hit","set","recorded"]}
|
|
1
|
+
{"version":3,"sources":["../src/session/session-lifecycle.ts","../src/session/gc/registry-remover.ts","../src/session/project-index.ts","../src/session/session-pointer.ts","../src/session/gc/transcript-gc.ts","../src/session/transcript-root-hint.ts","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a9D,KAAK8D;QAAU;MACxF;IACF;AAUA,WAAOpC,aAAa,IAChB;MAAET,UAAU;MAAgBC,QAAQ;IAA0B,IAC9D;MACED,UAAU;MACVC,QAAQ;IACV;EACN,GA/BmB;AAiCnB,aAAWgB,QAAQZ,SAAS;AAC1B,QAAII,aAAa,GAAG;AAClBF,UAAI0C,IAAIhC,MAAM;QAAEjB,UAAU;QAAgBC,QAAQ;MAA0B,CAAA;AAC5E;IACF;AAGA,UAAMiD,WAAWlC,YAAYC,IAAAA;AAC7B,QAAIiC,SAAS5B,SAAS,cAAc;AAElCf,UAAI0C,IAAIhC,MAAM;QACZjB,UAAU;QACVC,QAAQ,kBAAkBK,KAAKa,YAAY,IAAIF,IAAAA,KAASiC,SAASpD,KAAK;MACxE,CAAA;AACA;IACF;AACA,QAAIoD,SAAS5B,SAAS,SAAS;AAC7Bf,UAAI0C,IACFhC,MACAzB,wBAAwB0D,SAASzD,MAAMC,OAAO,MAAMe,YAAY,CAAA,CAAA;AAElE;IACF;AAEA,UAAMiC,OAAOH,UAAAA;AACbhC,QAAI0C,IACFhC,MACAqB,qBAAqBpC,SACjBuC,WAAWxB,MAAMyB,IAAAA,IACjB;MAAE1C,UAAU;MAAgBC,QAAQqC;IAAiB,CAAA;EAE7D;AAEA,SAAO/B;AACT;AA1KgBH;","names":["closeSync","openSync","readFileSync","readdirSync","readSync","rmSync","statSync","join","TheokitAgentError","classifySessionArtifact","forkTranscript","loadJsonl","sessionHasWriter","transcriptPath","transcriptRoot","TheokitAgentError","SessionRegistryRemoverError","TheokitAgentError","name","sessionId","timeoutMs","String","DEFAULT_REGISTRY_TIMEOUT_MS","isThenable","value","then","awaitRegistryRemoval","outcome","Number","isFinite","timer","Promise","race","_resolve","reject","setTimeout","undefined","clearTimeout","readFileSync","writeFileSync","join","encodeProjectDir","transcriptRoot","CWD_SIDECAR","projectsRoot","root","transcriptRoot","join","projectDirFor","cwd","encodeProjectDir","recordProjectDir","sidecar","ensureSecureDir","writeFileSync","resolveProjectDir","encodedName","raw","readFileSync","trim","length","undefined","projectDirMatches","readFileSync","join","atomicWriteText","transcriptRoot","POINTER","sessionPointerPath","cwd","root","transcriptRoot","join","projectDirFor","loadOrCreateSessionId","mintId","existing","readFileSync","trim","length","sessionId","resumed","persistSessionId","target","ensureSecureDir","atomicWriteText","persisted","SessionInUseError","TheokitAgentError","name","sessionId","reason","registryOutcome","registryNote","outcome","listSessions","cwd","root","transcriptRoot","dir","projectDirFor","entries","readdirSync","found","entry","path","join","isDirectory","modifiedAt","stats","statSync","mtime","kind","classifySessionArtifact","id","sessionIdOf","push","idSource","undefined","transcript","sort","a","b","getTime","fd","openSync","buffer","Buffer","alloc","FIRST_RECORD_BYTES","read","readSync","newline","indexOf","end","first","JSON","parse","toString","length","closeSync","protectedTranscriptPaths","protectedBy","Map","sessions","pointer","readPointer","set","transcriptPath","has","session","hasWriter","sessionHasWriter","transcriptOf","readFileSync","sessionPointerPath","trim","deleteSession","options","force","get","registryError","removeFromRegistry","awaitRegistryRemoval","registryTimeoutMs","error","transcriptRemoved","nowProtected","rmSync","forkBeforeUserTurn","srcId","newId","nth","Number","isInteger","String","src","dst","turns","reachableUserTurns","selected","forkTranscript","beforeRecordIndex","index","liveSessionPaths","keys","map","recordIndex","selectedText","text","GOAL_CONTINUATION_MARKER","textOfRecord","record","message","content","filter","block","type","isGenuineUserTurn","startsWith","records","loadJsonl","floor","i","subtype","rmSync","TheokitAgentError","transcriptRoot","FLOOR","keepLast","maxAgeDays","GCProtectionUnavailableError","TheokitAgentError","name","reason","Error","message","String","code","isRetryable","cause","GCFloorError","field","received","resolveProtection","builtin","provider","cwd","root","undefined","extra","union","Map","id","set","transcriptOf","path","planTranscriptGC","options","Number","isFinite","transcriptRoot","now","Date","cutoff","sessions","listSessions","protectedBy","protectedTranscriptPaths","protectedIds","candidates","kept","index","session","entries","protection","get","transcript","push","age","modifiedAt","getTime","isNaN","releaseFromRegistry","candidate","note","UNNAMEABLE_COLLECTION","unlink","removeFromRegistry","awaitRegistryRemoval","registryTimeoutMs","error","recordRemoval","removed","orphaned","runTranscriptGC","plan","errors","protectedNow","apply","has","registry","rmSync","dryRun","readdirSync","transcriptRootHint","found","previousRoot","env","process","undefined","current","THEOKIT_HOME","trim","length","projects","readdirSync","projectsRoot","String","loadJsonl","transcriptPath","transcriptRoot","ABSENT","state","messages","readThreadHistory","sessionId","options","path","transcriptPath","root","transcriptRoot","cwd","loadJsonl","err","isNotFound","reason","messageOf","code","Error","message","String","TheokitAgentError","DEFAULT_TRANSCRIPT_SAMPLES","encodeProjectDir","cwd","replace","LivenessBudgetError","TheokitAgentError","budget","String","assertUsableBudget","Number","isInteger","verdictFromRecordedCwds","cwds","probe","budgetLeft","unprobeable","at","error","found","liveness","reason","undefined","join","classifyProjects","encoded","opts","out","Map","remaining","path","answer","fs","exists","Error","message","recordedCwd","name","dir","projectsRoot","entries","listEntries","kind","samples","transcriptSamples","file","filter","f","endsWith","slice","record","JSON","parse","firstLine","length","includes","push","candidates","enumerationError","enumerate","candidatePaths","searchPool","pool","seen","Set","candidate","has","add","hit","set","recorded"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/agents",
|
|
3
|
-
"version": "13.0.0-next.
|
|
3
|
+
"version": "13.0.0-next.4",
|
|
4
4
|
"description": "AI agents as first-class citizens of the TheoKit pipeline. The AgentBuilder.create() authoring chain compiles to the @theokit/sdk runtime.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|