@timmyjl12/pi-subagents 0.20.0 → 0.21.0
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 +862 -827
- package/README.md +1125 -1080
- package/dist/active-agents-prompt.d.ts +31 -9
- package/dist/active-agents-prompt.js +73 -9
- package/dist/agent-color.js +9 -1
- package/dist/agent-file-toggle.d.ts +1 -1
- package/dist/agent-manager.d.ts +405 -18
- package/dist/agent-manager.js +1661 -131
- package/dist/agent-runner.d.ts +45 -6
- package/dist/agent-runner.js +109 -18
- package/dist/agent-types.d.ts +30 -7
- package/dist/agent-types.js +38 -9
- package/dist/awaited-result.d.ts +37 -0
- package/dist/awaited-result.js +150 -0
- package/dist/child-session-shutdown.d.ts +19 -1
- package/dist/child-session-shutdown.js +60 -11
- package/dist/cleanup-plans.d.ts +10 -0
- package/dist/cleanup-plans.js +112 -0
- package/dist/cross-extension-rpc.d.ts +8 -1
- package/dist/cross-extension-rpc.js +59 -5
- package/dist/custom-agents.d.ts +34 -9
- package/dist/custom-agents.js +308 -111
- package/dist/default-agents.d.ts +1 -1
- package/dist/env.d.ts +1 -1
- package/dist/error-log.d.ts +6 -0
- package/dist/error-log.js +8 -0
- package/dist/force-main-model.d.ts +21 -0
- package/dist/force-main-model.js +28 -0
- package/dist/goal-bridge.d.ts +155 -0
- package/dist/goal-bridge.js +305 -0
- package/dist/group-join.d.ts +5 -1
- package/dist/group-join.js +52 -7
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2827 -333
- package/dist/invocation-config.d.ts +30 -3
- package/dist/invocation-config.js +30 -1
- package/dist/memory.d.ts +1 -1
- package/dist/mention-clone.d.ts +1 -1
- package/dist/model-scope.d.ts +1 -1
- package/dist/nested-tools.d.ts +22 -1
- package/dist/nested-tools.js +120 -26
- package/dist/output-file.d.ts +15 -4
- package/dist/output-file.js +146 -43
- package/dist/prompts.d.ts +1 -1
- package/dist/recovery.d.ts +1 -1
- package/dist/report-cleanup.d.ts +204 -0
- package/dist/report-cleanup.js +1632 -0
- package/dist/report-store.d.ts +738 -0
- package/dist/report-store.js +3612 -0
- package/dist/schedule-store.d.ts +14 -6
- package/dist/schedule-store.js +88 -58
- package/dist/schedule.d.ts +20 -8
- package/dist/schedule.js +135 -74
- package/dist/settings.d.ts +39 -11
- package/dist/settings.js +22 -5
- package/dist/status-note.d.ts +1 -1
- package/dist/structured-output.d.ts +1 -1
- package/dist/types.d.ts +32 -3
- package/dist/ui/agent-mention.d.ts +2 -2
- package/dist/ui/agent-widget.d.ts +82 -13
- package/dist/ui/agent-widget.js +155 -37
- package/dist/ui/cleanup-preview.d.ts +59 -0
- package/dist/ui/cleanup-preview.js +466 -0
- package/dist/ui/conversation-viewer.d.ts +4 -4
- package/dist/ui/conversation-viewer.js +10 -6
- package/dist/ui/fleet-list.d.ts +3 -3
- package/dist/ui/fleet-list.js +3 -3
- package/dist/ui/fleet-overlay.d.ts +37 -6
- package/dist/ui/fleet-overlay.js +214 -18
- package/dist/ui/hub-feed.d.ts +52 -0
- package/dist/ui/hub-feed.js +148 -0
- package/dist/ui/native-transcript.js +5 -1
- package/dist/ui/schedule-menu.d.ts +1 -1
- package/dist/ui/schedule-menu.js +1 -1
- package/dist/ui/workflow-card.d.ts +4 -4
- package/dist/ui/workflow-dialog.d.ts +4 -4
- package/dist/ui/workflow-dialog.js +8 -3
- package/dist/ui/workflow-menu.d.ts +2 -2
- package/dist/usage.d.ts +12 -0
- package/dist/usage.js +28 -1
- package/dist/workflow/entry.d.ts +3 -3
- package/dist/workflow/host.d.ts +7 -4
- package/dist/workflow/host.js +162 -48
- package/dist/workflow/journal.d.ts +23 -7
- package/dist/workflow/journal.js +80 -23
- package/dist/workflow/progress.d.ts +1 -1
- package/dist/workflow/runtime.d.ts +45 -6
- package/dist/workflow/runtime.js +105 -16
- package/dist/workflow/task.d.ts +13 -4
- package/dist/workflow/task.js +7 -1
- package/dist/workflow/tool-description.d.ts +7 -2
- package/dist/workflow/tool-description.js +10 -5
- package/docs/{FORK.md → DEVELOPMENT.md} +4 -4
- package/docs/artifacts.md +93 -0
- package/docs/rpc.md +252 -189
- package/docs/runtime-performance.md +53 -0
- package/docs/workflows.md +48 -18
- package/examples/agent-tool-description.md +2 -2
- package/examples/workflows/review-panel.js +6 -3
- package/package.json +5 -5
- package/src/active-agents-prompt.ts +115 -39
- package/src/agent-color.ts +10 -2
- package/src/agent-file-toggle.ts +2 -2
- package/src/agent-manager.ts +3312 -1601
- package/src/agent-runner.ts +164 -36
- package/src/agent-types.ts +56 -11
- package/src/awaited-result.ts +187 -0
- package/src/child-session-shutdown.ts +114 -46
- package/src/cleanup-plans.ts +112 -0
- package/src/cross-extension-rpc.ts +68 -9
- package/src/custom-agents.ts +384 -112
- package/src/default-agents.ts +1 -1
- package/src/enabled-models.ts +1 -1
- package/src/env.ts +1 -1
- package/src/error-log.ts +10 -1
- package/src/force-main-model.ts +29 -0
- package/src/goal-bridge.ts +468 -0
- package/src/group-join.ts +56 -9
- package/src/index.ts +2987 -349
- package/src/invocation-config.ts +50 -4
- package/src/memory.ts +1 -1
- package/src/mention-clone.ts +3 -3
- package/src/model-scope.ts +1 -1
- package/src/nested-tools.ts +164 -33
- package/src/output-file.ts +168 -46
- package/src/prompts.ts +1 -1
- package/src/recovery.ts +2 -2
- package/src/report-cleanup.ts +2044 -0
- package/src/report-store.ts +4130 -0
- package/src/schedule-store.ts +244 -201
- package/src/schedule.ts +144 -80
- package/src/settings.ts +61 -16
- package/src/skill-loader.ts +1 -1
- package/src/standalone-fallback.ts +2 -2
- package/src/status-note.ts +1 -1
- package/src/structured-output.ts +1 -1
- package/src/types.ts +33 -3
- package/src/ui/agent-mention.ts +3 -3
- package/src/ui/agent-widget.ts +179 -45
- package/src/ui/cleanup-preview.ts +518 -0
- package/src/ui/conversation-viewer.ts +19 -15
- package/src/ui/fleet-list.ts +7 -7
- package/src/ui/fleet-overlay.ts +1048 -847
- package/src/ui/hub-feed.ts +179 -0
- package/src/ui/native-transcript.ts +7 -3
- package/src/ui/schedule-menu.ts +4 -4
- package/src/ui/workflow-card.ts +4 -4
- package/src/ui/workflow-dialog.ts +10 -6
- package/src/ui/workflow-menu.ts +4 -4
- package/src/usage.ts +53 -3
- package/src/workflow/collisions.ts +1 -1
- package/src/workflow/entry.ts +3 -3
- package/src/workflow/host.ts +174 -54
- package/src/workflow/journal.ts +80 -23
- package/src/workflow/progress.ts +1 -1
- package/src/workflow/runtime.ts +146 -23
- package/src/workflow/saved.ts +3 -3
- package/src/workflow/task.ts +18 -7
- package/src/workflow/tool-description.ts +10 -5
|
@@ -0,0 +1,738 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* report-store.ts — Durable, plain-data completed reports, per root session.
|
|
3
|
+
*
|
|
4
|
+
* Runtime records are evicted after ten minutes and do not survive a reload.
|
|
5
|
+
* This module keeps the completed report itself — verbatim, with no character
|
|
6
|
+
* cap and no truncation markers — under
|
|
7
|
+
* `<getAgentDir()>/pi-subagents/reports/<rootSessionId>/`, one atomic JSON per
|
|
8
|
+
* agent plus small root metadata, lease and cleanup-lock files. It deliberately
|
|
9
|
+
* keeps no global mutable index and no raw transcript copies.
|
|
10
|
+
*
|
|
11
|
+
* Ownership rules:
|
|
12
|
+
* - an entry carries its root provenance and the same owner ids as the live
|
|
13
|
+
* record (`parentAgentId` / `workflowId`);
|
|
14
|
+
* - `find` is a top-level reader and never surfaces an owned entry as a root
|
|
15
|
+
* report;
|
|
16
|
+
* - `findOwned` is the narrow async reader an owner (the parent or the
|
|
17
|
+
* workflow) uses for its own archived entry;
|
|
18
|
+
* - aliases resolve only inside the bound root; canonical ids resolve across
|
|
19
|
+
* every root, exactly (the 17-character id `randomUUID().slice(0, 17)`
|
|
20
|
+
* produces) — there is intentionally no prefix matcher.
|
|
21
|
+
*
|
|
22
|
+
* Lifetime handshake:
|
|
23
|
+
* - every activation writes a unique `<pid>-<nonce>.json` lease;
|
|
24
|
+
* - cleanup creates an exclusive `cleanup.lock` first and then rechecks
|
|
25
|
+
* foreign leases;
|
|
26
|
+
* - activation checks the lock, writes its lease, rechecks the lock and
|
|
27
|
+
* refuses artifact writes when a lock appeared.
|
|
28
|
+
*
|
|
29
|
+
* Retention:
|
|
30
|
+
* - report bodies/details expire 30 days after `completedAt`; startup/save
|
|
31
|
+
* maintenance replaces them with a minimal ownership stub;
|
|
32
|
+
* - a deletion receipt lives 30 days and blocks re-import from parent history
|
|
33
|
+
* or a leftover transcript;
|
|
34
|
+
* - no read deletes anything and no timer is created here.
|
|
35
|
+
*/
|
|
36
|
+
import type { AgentInvocation, AgentRecord } from "./types.ts";
|
|
37
|
+
import type { LifetimeUsage } from "./usage.ts";
|
|
38
|
+
/** Custom entry a child session carries to prove pi-subagents owns it. */
|
|
39
|
+
export declare const SESSION_OWNERSHIP_ENTRY_TYPE = "pi-subagents:ownership";
|
|
40
|
+
/** One month, in milliseconds. */
|
|
41
|
+
export declare const REPORT_RETENTION_MS: number;
|
|
42
|
+
/** Store format version, written on every entry. */
|
|
43
|
+
export declare const REPORT_STORE_VERSION = 1;
|
|
44
|
+
/** Cleanup scope: one root session, or every project/session. */
|
|
45
|
+
export type CleanupScope = "session" | "global";
|
|
46
|
+
export type TerminalAgentStatus = "completed" | "steered" | "aborted" | "stopped" | "error";
|
|
47
|
+
export declare function isCanonicalAgentId(value: string): boolean;
|
|
48
|
+
export declare function isTerminalAgentStatus(value: string): value is TerminalAgentStatus;
|
|
49
|
+
export declare function isSafePathComponent(value: string): boolean;
|
|
50
|
+
/** The root context an activation binds. Plain data only, never an ExtensionContext. */
|
|
51
|
+
export interface ReportContext {
|
|
52
|
+
cwd: string;
|
|
53
|
+
rootSessionId: string;
|
|
54
|
+
rootSessionFile?: string;
|
|
55
|
+
/** false = keep results only in memory/current-parent recovery, write nothing. */
|
|
56
|
+
persistReports?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/** What a child session writes to prove pi-subagents, not the user, owns it. */
|
|
59
|
+
export interface SessionOwnershipData {
|
|
60
|
+
version: 1;
|
|
61
|
+
agentId: string;
|
|
62
|
+
rootSessionId: string;
|
|
63
|
+
rootCwd: string;
|
|
64
|
+
rootSessionFile?: string;
|
|
65
|
+
childSessionId: string;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A complete completed report. Every string is verbatim; `toolUses`,
|
|
69
|
+
* `startedAt`, `lifetimeUsage` etc. stay absent when a legacy source never
|
|
70
|
+
* recorded them rather than being invented as zero.
|
|
71
|
+
*/
|
|
72
|
+
export interface ReportSnapshot {
|
|
73
|
+
id: string;
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
status: TerminalAgentStatus;
|
|
77
|
+
result?: string;
|
|
78
|
+
error?: string;
|
|
79
|
+
toolUses?: number;
|
|
80
|
+
startedAt?: number;
|
|
81
|
+
completedAt?: number;
|
|
82
|
+
sessionFile?: string;
|
|
83
|
+
sessionId?: string;
|
|
84
|
+
outputFile?: string;
|
|
85
|
+
invocation?: AgentInvocation;
|
|
86
|
+
lifetimeUsage?: LifetimeUsage;
|
|
87
|
+
compactionCount?: number;
|
|
88
|
+
isBackground?: boolean;
|
|
89
|
+
depth?: number;
|
|
90
|
+
handle?: string;
|
|
91
|
+
alias?: string;
|
|
92
|
+
groupId?: string;
|
|
93
|
+
runGeneration?: number;
|
|
94
|
+
structuredJson?: string;
|
|
95
|
+
structuredRetried?: boolean;
|
|
96
|
+
droppedSteers?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Stale diagnostic only, never a read-state source: the runtime flag may have
|
|
99
|
+
* changed after settle. Cleanup derives unread/unknown exclusively from the
|
|
100
|
+
* refreshed live state getter.
|
|
101
|
+
*/
|
|
102
|
+
resultConsumed?: boolean;
|
|
103
|
+
parentAgentId?: string;
|
|
104
|
+
workflowId?: string;
|
|
105
|
+
/** Flat owner set; an entry with any owner is never a top-level report. */
|
|
106
|
+
ownerIds: string[];
|
|
107
|
+
rootSessionId: string;
|
|
108
|
+
rootCwd: string;
|
|
109
|
+
rootSessionFile?: string;
|
|
110
|
+
legacy?: boolean;
|
|
111
|
+
recoveredFrom?: "archive" | "parent-record" | "legacy-output";
|
|
112
|
+
}
|
|
113
|
+
interface ReportEntryBase {
|
|
114
|
+
version: typeof REPORT_STORE_VERSION;
|
|
115
|
+
id: string;
|
|
116
|
+
/** Bumped on every write; combined with the file hash for cleanup identity. */
|
|
117
|
+
entryGeneration: number;
|
|
118
|
+
createdAt: number;
|
|
119
|
+
updatedAt: number;
|
|
120
|
+
completedAt: number;
|
|
121
|
+
rootSessionId: string;
|
|
122
|
+
rootCwd: string;
|
|
123
|
+
rootSessionFile?: string;
|
|
124
|
+
type: string;
|
|
125
|
+
description: string;
|
|
126
|
+
handle?: string;
|
|
127
|
+
alias?: string;
|
|
128
|
+
parentAgentId?: string;
|
|
129
|
+
workflowId?: string;
|
|
130
|
+
ownerIds: string[];
|
|
131
|
+
sessionFile?: string;
|
|
132
|
+
sessionId?: string;
|
|
133
|
+
outputFile?: string;
|
|
134
|
+
runGeneration?: number;
|
|
135
|
+
}
|
|
136
|
+
export interface FullReportEntry extends ReportEntryBase {
|
|
137
|
+
state: "full";
|
|
138
|
+
report: ReportSnapshot;
|
|
139
|
+
}
|
|
140
|
+
/** Body/details expired; only the ownership index survives so cleanup can find it. */
|
|
141
|
+
export interface ExpiredReportEntry extends ReportEntryBase {
|
|
142
|
+
state: "expired";
|
|
143
|
+
expiredAt: number;
|
|
144
|
+
}
|
|
145
|
+
/** Deliberate removal receipt: blocks re-import from parent history/transcripts. */
|
|
146
|
+
export interface DeletedReportEntry extends ReportEntryBase {
|
|
147
|
+
state: "deleted";
|
|
148
|
+
deletedAt: number;
|
|
149
|
+
deletionReason?: string;
|
|
150
|
+
}
|
|
151
|
+
export type ReportEntry = FullReportEntry | ExpiredReportEntry | DeletedReportEntry;
|
|
152
|
+
/** Strict owner context for `findOwned`; parent and workflow namespaces never cross. */
|
|
153
|
+
export interface ReportOwnerContext {
|
|
154
|
+
kind: "parent" | "workflow";
|
|
155
|
+
id: string;
|
|
156
|
+
}
|
|
157
|
+
export type ReportLookup = {
|
|
158
|
+
status: "found";
|
|
159
|
+
report: ReportSnapshot;
|
|
160
|
+
entry: ReportEntry;
|
|
161
|
+
rootSessionId: string;
|
|
162
|
+
provenance: "archive" | "parent-record" | "legacy-output";
|
|
163
|
+
} | {
|
|
164
|
+
status: "expired";
|
|
165
|
+
entry: ReportEntry;
|
|
166
|
+
rootSessionId: string;
|
|
167
|
+
expiredAt: number;
|
|
168
|
+
reason: string;
|
|
169
|
+
} | {
|
|
170
|
+
status: "deleted";
|
|
171
|
+
entry: ReportEntry;
|
|
172
|
+
rootSessionId: string;
|
|
173
|
+
deletedAt: number;
|
|
174
|
+
reason?: string;
|
|
175
|
+
} | {
|
|
176
|
+
status: "missing";
|
|
177
|
+
ref: string;
|
|
178
|
+
reason: string;
|
|
179
|
+
candidates?: string[];
|
|
180
|
+
} | {
|
|
181
|
+
status: "ambiguous";
|
|
182
|
+
ref: string;
|
|
183
|
+
reason: string;
|
|
184
|
+
candidates: {
|
|
185
|
+
rootSessionId: string;
|
|
186
|
+
id: string;
|
|
187
|
+
alias?: string;
|
|
188
|
+
}[];
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* One combined artifact scope for cleanup admission. Ids and session files are
|
|
192
|
+
* matched in a SINGLE scan; an empty scope matches any live selection, exactly
|
|
193
|
+
* like the legacy no-argument `isCleaning()`.
|
|
194
|
+
*/
|
|
195
|
+
export interface ReportArtifactScope {
|
|
196
|
+
agentId?: string;
|
|
197
|
+
sessionFiles?: readonly string[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Status-rich durable entry read. `absent` is only reported when absence is
|
|
201
|
+
* proven; an unreadable/unsafe root or entry is `uncertain` and must be refused
|
|
202
|
+
* by the caller instead of being treated as "no entry".
|
|
203
|
+
*/
|
|
204
|
+
export type ReportEntryState = {
|
|
205
|
+
status: "verified";
|
|
206
|
+
entry: ReportEntry;
|
|
207
|
+
path: string;
|
|
208
|
+
} | {
|
|
209
|
+
status: "absent";
|
|
210
|
+
} | {
|
|
211
|
+
status: "uncertain";
|
|
212
|
+
reason: string;
|
|
213
|
+
};
|
|
214
|
+
export type ReportBinding = {
|
|
215
|
+
active: true;
|
|
216
|
+
rootSessionId: string;
|
|
217
|
+
persistence: boolean;
|
|
218
|
+
leaseId?: string;
|
|
219
|
+
reason?: undefined;
|
|
220
|
+
} | {
|
|
221
|
+
active: false;
|
|
222
|
+
rootSessionId?: string;
|
|
223
|
+
persistence: false;
|
|
224
|
+
reason: string;
|
|
225
|
+
leaseId?: undefined;
|
|
226
|
+
};
|
|
227
|
+
export type ReportSaveResult = {
|
|
228
|
+
saved: true;
|
|
229
|
+
path: string;
|
|
230
|
+
entry: ReportEntry | WorkflowArtifactEntry;
|
|
231
|
+
} | {
|
|
232
|
+
saved: false;
|
|
233
|
+
reason: string;
|
|
234
|
+
};
|
|
235
|
+
export interface ReportFlushOptions {
|
|
236
|
+
/** Total wall-clock budget across every pass, including newly accepted writes. */
|
|
237
|
+
timeoutMs?: number;
|
|
238
|
+
/** Maximum snapshots of the ordered write chains to await. */
|
|
239
|
+
maxPasses?: number;
|
|
240
|
+
}
|
|
241
|
+
export type ReportFlushResult = {
|
|
242
|
+
status: "flushed";
|
|
243
|
+
pendingChains: 0;
|
|
244
|
+
passes: number;
|
|
245
|
+
} | {
|
|
246
|
+
status: "incomplete";
|
|
247
|
+
reason: "timeout" | "max-passes";
|
|
248
|
+
pendingChains: number;
|
|
249
|
+
passes: number;
|
|
250
|
+
};
|
|
251
|
+
export type WorkflowRunStatus = "running" | "completed" | "failed" | "killed" | "paused";
|
|
252
|
+
/** Registered independently of agents, so zero-agent workflows are still owned. */
|
|
253
|
+
export interface WorkflowArtifactRegistration {
|
|
254
|
+
id: string;
|
|
255
|
+
/** Exact generated inline copies/journals; always the copy, never the source. */
|
|
256
|
+
generatedPaths: readonly string[];
|
|
257
|
+
/** External/saved source paths; recorded for provenance and never deleted. */
|
|
258
|
+
externalPaths?: readonly string[];
|
|
259
|
+
status: WorkflowRunStatus;
|
|
260
|
+
startedAt: number;
|
|
261
|
+
completedAt?: number;
|
|
262
|
+
}
|
|
263
|
+
export interface WorkflowArtifactEntry extends WorkflowArtifactRegistration {
|
|
264
|
+
version: typeof REPORT_STORE_VERSION;
|
|
265
|
+
rootSessionId: string;
|
|
266
|
+
rootCwd: string;
|
|
267
|
+
rootSessionFile?: string;
|
|
268
|
+
updatedAt: number;
|
|
269
|
+
}
|
|
270
|
+
export interface ReportLease {
|
|
271
|
+
version: typeof REPORT_STORE_VERSION;
|
|
272
|
+
pid: number;
|
|
273
|
+
nonce: string;
|
|
274
|
+
rootSessionId: string;
|
|
275
|
+
/** Plain bind identity: the main/root session path this activation owns. */
|
|
276
|
+
rootSessionFile?: string;
|
|
277
|
+
rootCwd?: string;
|
|
278
|
+
createdAt: number;
|
|
279
|
+
updatedAt: number;
|
|
280
|
+
own: boolean;
|
|
281
|
+
}
|
|
282
|
+
/** Shared cleanup-lock liveness. Corrupt/unreadable is never "stale". */
|
|
283
|
+
export type CleanupLockStatus = "absent" | "live" | "dead" | "uncertain";
|
|
284
|
+
export interface CleanupLockRead {
|
|
285
|
+
status: CleanupLockStatus;
|
|
286
|
+
lock?: CleanupLockData;
|
|
287
|
+
raw?: string;
|
|
288
|
+
reason?: string;
|
|
289
|
+
}
|
|
290
|
+
export interface CleanupLockOptions {
|
|
291
|
+
/**
|
|
292
|
+
* Legacy-only roots may not have a managed folder yet. The caller must have
|
|
293
|
+
* explicit legacy confirmation; this creates only the control namespace.
|
|
294
|
+
*/
|
|
295
|
+
createRoot?: boolean;
|
|
296
|
+
}
|
|
297
|
+
export interface CleanupSelection {
|
|
298
|
+
scope: CleanupScope;
|
|
299
|
+
agentIds: readonly string[];
|
|
300
|
+
sessionFiles: readonly string[];
|
|
301
|
+
}
|
|
302
|
+
export interface CleanupLockData extends CleanupSelection {
|
|
303
|
+
version: typeof REPORT_STORE_VERSION;
|
|
304
|
+
pid: number;
|
|
305
|
+
nonce: string;
|
|
306
|
+
rootSessionId: string;
|
|
307
|
+
createdAt: number;
|
|
308
|
+
}
|
|
309
|
+
export interface CleanupLockHandle {
|
|
310
|
+
rootSessionId: string;
|
|
311
|
+
nonce: string;
|
|
312
|
+
selection: CleanupSelection;
|
|
313
|
+
acquiredAt: number;
|
|
314
|
+
}
|
|
315
|
+
export interface ReportRootState {
|
|
316
|
+
rootSessionId: string;
|
|
317
|
+
rootDir: string;
|
|
318
|
+
rootCwd?: string;
|
|
319
|
+
rootSessionFile?: string;
|
|
320
|
+
generation: number;
|
|
321
|
+
metadataPresent: boolean;
|
|
322
|
+
reportEntries: ReportEntry[];
|
|
323
|
+
workflows: WorkflowArtifactEntry[];
|
|
324
|
+
leases: ReportLease[];
|
|
325
|
+
/** Present only for a parsed, valid lock; `cleanupLockState` is authoritative. */
|
|
326
|
+
cleanupLock?: CleanupLockData;
|
|
327
|
+
cleanupLockState: CleanupLockStatus;
|
|
328
|
+
cleanupLockReason?: string;
|
|
329
|
+
/** Why lease metadata could not be fully trusted (fail closed). */
|
|
330
|
+
leasesUncertain?: string;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Strict global identity inventory for cleanup protection. Unlike `list`, a
|
|
334
|
+
* partial read is reported as uncertainty instead of shrinking to an empty or
|
|
335
|
+
* shorter result: every root's main-session identity must be proven.
|
|
336
|
+
*/
|
|
337
|
+
export interface ReportIdentityScan {
|
|
338
|
+
states: ReportRootState[];
|
|
339
|
+
uncertainty?: string;
|
|
340
|
+
}
|
|
341
|
+
export interface ReportStorage {
|
|
342
|
+
agentDir: string;
|
|
343
|
+
reportsRoot: string;
|
|
344
|
+
tempRoot: string;
|
|
345
|
+
sessionRoots: readonly string[];
|
|
346
|
+
}
|
|
347
|
+
export interface ReportStoreOptions {
|
|
348
|
+
/** Injected root for fixtures; defaults to `getAgentDir()` at call time. */
|
|
349
|
+
agentDir?: string;
|
|
350
|
+
/** Injected OS-temp root for `.output`/workflow ownership validation. */
|
|
351
|
+
tempRoot?: string;
|
|
352
|
+
/** Bounded pi session roots scanned only for legacy parent-record proof. */
|
|
353
|
+
sessionRoots?: readonly string[];
|
|
354
|
+
now?: () => number;
|
|
355
|
+
nonce?: () => string;
|
|
356
|
+
retentionMs?: number;
|
|
357
|
+
pidAlive?: (pid: number) => boolean;
|
|
358
|
+
diagnostics?: (message: string) => void;
|
|
359
|
+
/**
|
|
360
|
+
* Narrow deterministic interleaving seam for maintenance tests and callers that
|
|
361
|
+
* need an explicit checkpoint. Not a general observer: it only reports the
|
|
362
|
+
* shared lock acquisition and the pre-rewrite entry read.
|
|
363
|
+
*/
|
|
364
|
+
maintenanceHook?: (event: MaintenanceEvent) => void | Promise<void>;
|
|
365
|
+
}
|
|
366
|
+
export interface MaintenanceEvent {
|
|
367
|
+
phase: "locked" | "entry-read";
|
|
368
|
+
rootSessionId: string;
|
|
369
|
+
agentId?: string;
|
|
370
|
+
}
|
|
371
|
+
export interface FileIdentity {
|
|
372
|
+
path: string;
|
|
373
|
+
size: number;
|
|
374
|
+
mtimeMs: number;
|
|
375
|
+
fingerprint: string;
|
|
376
|
+
}
|
|
377
|
+
export type FileInspection = {
|
|
378
|
+
ok: true;
|
|
379
|
+
identity: FileIdentity;
|
|
380
|
+
} | {
|
|
381
|
+
ok: false;
|
|
382
|
+
reason: string;
|
|
383
|
+
};
|
|
384
|
+
export interface DeletionReceiptRequest {
|
|
385
|
+
deletedAt?: number;
|
|
386
|
+
reason?: string;
|
|
387
|
+
expectedEntryGeneration?: number;
|
|
388
|
+
/** Final authorization immediately before publication; a throw refuses the write. */
|
|
389
|
+
beforeCommit?: () => Promise<void>;
|
|
390
|
+
}
|
|
391
|
+
export interface DeletionReceiptResult {
|
|
392
|
+
entry: DeletedReportEntry;
|
|
393
|
+
rootGeneration: number;
|
|
394
|
+
}
|
|
395
|
+
export interface LegacyOutputInspection {
|
|
396
|
+
path: string;
|
|
397
|
+
agentId: string;
|
|
398
|
+
verified: boolean;
|
|
399
|
+
reason?: string;
|
|
400
|
+
snapshot?: ReportSnapshot;
|
|
401
|
+
}
|
|
402
|
+
export declare class ReportUnavailableError extends Error {
|
|
403
|
+
readonly reason: string;
|
|
404
|
+
constructor(reason: string);
|
|
405
|
+
}
|
|
406
|
+
export declare function normalizeReportPath(path: string): string;
|
|
407
|
+
export declare function isPathWithin(child: string, parent: string): boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Capture every field synchronously, before any await. The caller may mutate
|
|
410
|
+
* the live record (or its session) immediately after the snapshot call.
|
|
411
|
+
*/
|
|
412
|
+
export declare function captureReportSnapshot(record: AgentRecord, context: ReportContext, now: number): ReportSnapshot | undefined;
|
|
413
|
+
/**
|
|
414
|
+
* Inspect one regular file below an allowed root. Every ancestor below the root
|
|
415
|
+
* is lstat-checked, so a symlinked/junctioned ancestor or file is refused even
|
|
416
|
+
* when the final `stat` would follow it. The root itself may be a symlink (macOS
|
|
417
|
+
* temp lives under `/var`); its real path is the boundary.
|
|
418
|
+
*/
|
|
419
|
+
export declare function inspectRegularFile(path: string, allowedRoots: readonly string[]): Promise<FileInspection>;
|
|
420
|
+
export interface SessionHeader {
|
|
421
|
+
id: string;
|
|
422
|
+
cwd: string;
|
|
423
|
+
timestamp?: string;
|
|
424
|
+
}
|
|
425
|
+
export interface ParsedSessionFile {
|
|
426
|
+
header: SessionHeader;
|
|
427
|
+
entries: unknown[];
|
|
428
|
+
}
|
|
429
|
+
export declare function readSessionOwnershipData(data: unknown): SessionOwnershipData | undefined;
|
|
430
|
+
export declare class ReportStore {
|
|
431
|
+
private readonly options;
|
|
432
|
+
private readonly writeChains;
|
|
433
|
+
private readonly lastMaintenance;
|
|
434
|
+
private readonly maintenanceAttempts;
|
|
435
|
+
private readonly cleanupLocks;
|
|
436
|
+
/** Manual lock admission is exclusive before its first filesystem await. */
|
|
437
|
+
private readonly pendingCleanupLocks;
|
|
438
|
+
/**
|
|
439
|
+
* Exact maintenance exemption: root session id -> the nonce reserved by THIS
|
|
440
|
+
* store's maintenance attempt. Disk proof still requires our PID and nonce;
|
|
441
|
+
* the row spans publication, validation and the awaited release.
|
|
442
|
+
*/
|
|
443
|
+
private readonly maintenanceLocks;
|
|
444
|
+
private readonly diagnosticsLog;
|
|
445
|
+
private context?;
|
|
446
|
+
private activation?;
|
|
447
|
+
private closed;
|
|
448
|
+
private closing;
|
|
449
|
+
private closePromise?;
|
|
450
|
+
constructor(options?: ReportStoreOptions);
|
|
451
|
+
/** Non-fatal store diagnostics (unreadable entries, skipped writes). */
|
|
452
|
+
get diagnostics(): readonly string[];
|
|
453
|
+
private diagnose;
|
|
454
|
+
private now;
|
|
455
|
+
private nonce;
|
|
456
|
+
private retentionMs;
|
|
457
|
+
private pidAlive;
|
|
458
|
+
private agentDir;
|
|
459
|
+
storage(): ReportStorage;
|
|
460
|
+
private lockPath;
|
|
461
|
+
/**
|
|
462
|
+
* The maintenance exemption is this store's in-memory ownership row, so the
|
|
463
|
+
* nonce alone decides it. Only ever used for this store's own handle.
|
|
464
|
+
*/
|
|
465
|
+
private localMaintenanceExempt;
|
|
466
|
+
/**
|
|
467
|
+
* Disk proof for the same exemption: the lock must have been written by THIS
|
|
468
|
+
* process with our recorded nonce. A replacement that copies the nonce but
|
|
469
|
+
* carries a foreign (live) pid is a cleanup by someone else and must never
|
|
470
|
+
* inherit the exemption.
|
|
471
|
+
*/
|
|
472
|
+
private maintenanceExempt;
|
|
473
|
+
/** Drop this store's in-memory ownership of exactly this handle. */
|
|
474
|
+
private forgetLocalOwnership;
|
|
475
|
+
/**
|
|
476
|
+
* End a maintenance exemption and its local ownership together. The exemption
|
|
477
|
+
* must stay valid until the awaited release finishes, and must never survive a
|
|
478
|
+
* failed one: the on-disk lock then stays in place and keeps failing closed.
|
|
479
|
+
*/
|
|
480
|
+
private endMaintenanceLock;
|
|
481
|
+
private ensureReportRootReal;
|
|
482
|
+
private ensureRootDirectory;
|
|
483
|
+
private existingRootDirectory;
|
|
484
|
+
/**
|
|
485
|
+
* Same best-effort resolution as `existingRootDirectory`, but a non-ENOENT
|
|
486
|
+
* failure is reported instead of collapsing into "no such root". Strict
|
|
487
|
+
* callers (the cleanup identity inventory) also pass `vanishedIsUncertain`:
|
|
488
|
+
* for an already-enumerated root, ENOENT means it disappeared between the
|
|
489
|
+
* listing and the lookup, which is partial evidence, never "absent".
|
|
490
|
+
*/
|
|
491
|
+
private existingRootDirectoryScan;
|
|
492
|
+
/**
|
|
493
|
+
* `lstat` that never follows a link: a missing path is proven absence, every
|
|
494
|
+
* other failure is uncertainty, and the caller decides what shape is allowed.
|
|
495
|
+
*/
|
|
496
|
+
private lstatScan;
|
|
497
|
+
private enqueue;
|
|
498
|
+
/**
|
|
499
|
+
* Await accepted writes, including writes appended while an earlier pass was
|
|
500
|
+
* in flight. Both the total wait and the number of passes are bounded: an
|
|
501
|
+
* incomplete result never means that a durable read is current.
|
|
502
|
+
*/
|
|
503
|
+
flush(options?: ReportFlushOptions): Promise<ReportFlushResult>;
|
|
504
|
+
private readJson;
|
|
505
|
+
/**
|
|
506
|
+
* Best-effort reader plus an explicit reason when the stored value cannot be
|
|
507
|
+
* trusted. `readJson` keeps the historic ignore-and-continue behavior.
|
|
508
|
+
*/
|
|
509
|
+
private readJsonScan;
|
|
510
|
+
/**
|
|
511
|
+
* Lease metadata is proof material: a malformed, unreadable or unrecognized
|
|
512
|
+
* lease is uncertainty, never "no lease". A canonical filename pid that
|
|
513
|
+
* disagrees with its JSON body is an identity mismatch for the same reason.
|
|
514
|
+
*/
|
|
515
|
+
private scanLeaseFiles;
|
|
516
|
+
private classifyCleanupLock;
|
|
517
|
+
private readCleanupLockRead;
|
|
518
|
+
private readCleanupLockReadSync;
|
|
519
|
+
/**
|
|
520
|
+
* Async guard shared by save/registerWorkflow write barriers. Dead locks do
|
|
521
|
+
* not block; live locks block unless this is our own maintenance lock; anything
|
|
522
|
+
* uncertain fails closed with an explicit reason (never silently active).
|
|
523
|
+
*/
|
|
524
|
+
private writeBlockReason;
|
|
525
|
+
/**
|
|
526
|
+
* Publish a JSON control file atomically and exclusively: the full body is
|
|
527
|
+
* written to a temp sibling first, then hard-linked into place. A crash can
|
|
528
|
+
* leave an ignored temp file, never a truncated authoritative lock.
|
|
529
|
+
*/
|
|
530
|
+
private publishExclusiveJson;
|
|
531
|
+
private recoveryIntentPath;
|
|
532
|
+
private removeRecoveryIntent;
|
|
533
|
+
/**
|
|
534
|
+
* Cross-process reaper exclusion. Every reaper publishes a unique intent and
|
|
535
|
+
* then refuses when another live/unknown intent is visible. Unknown metadata
|
|
536
|
+
* fails closed; a provably dead intent is removable because its unique name
|
|
537
|
+
* can never belong to a newer reaper.
|
|
538
|
+
*/
|
|
539
|
+
private reaperIntentsClear;
|
|
540
|
+
/**
|
|
541
|
+
* Recover a dead lock and publish this caller's replacement while still
|
|
542
|
+
* holding the reaper intent. A new owner's lock is never unlinked: ordinary
|
|
543
|
+
* creators use atomic EXCL publication, and a later reaper sees the intent.
|
|
544
|
+
*/
|
|
545
|
+
private recoverAndPublishLock;
|
|
546
|
+
/**
|
|
547
|
+
* Persist the minimal main-session identity for a persistent binding, before the
|
|
548
|
+
* first agent report can create root metadata. Existing valid metadata and its
|
|
549
|
+
* generation are preserved, a missing root file is filled, and unreadable or
|
|
550
|
+
* malformed metadata refuses the binding instead of being blindly overwritten.
|
|
551
|
+
*/
|
|
552
|
+
private ensureMainIdentityKeeper;
|
|
553
|
+
private writeRootMetadata;
|
|
554
|
+
private bumpGenerationLocked;
|
|
555
|
+
private createLease;
|
|
556
|
+
private removeLeaseFile;
|
|
557
|
+
private releaseActivation;
|
|
558
|
+
private validateContext;
|
|
559
|
+
/**
|
|
560
|
+
* Acquire-side exclusion: check the lock, create this activation's lease,
|
|
561
|
+
* recheck the lock, and refuse artifact work if a cleanup acquired it in the
|
|
562
|
+
* window. Reads remain available even when the binding is inactive.
|
|
563
|
+
*/
|
|
564
|
+
bind(context: ReportContext): Promise<ReportBinding>;
|
|
565
|
+
get bindingContext(): ReportContext | undefined;
|
|
566
|
+
/**
|
|
567
|
+
* Stop accepting new writes BEFORE draining accepted ones. Releases the lease
|
|
568
|
+
* only when the caller proved quiescence and the bounded drain completed.
|
|
569
|
+
* Concurrent/repeated close calls share the same outcome.
|
|
570
|
+
*/
|
|
571
|
+
close(options?: {
|
|
572
|
+
quiescent?: boolean;
|
|
573
|
+
}): Promise<ReportFlushResult>;
|
|
574
|
+
private finishClose;
|
|
575
|
+
get isClosed(): boolean;
|
|
576
|
+
private selectionMatches;
|
|
577
|
+
private localLockCleans;
|
|
578
|
+
/**
|
|
579
|
+
* Combined sync cleanup scan: local selections first, then every root's lock in
|
|
580
|
+
* ONE listing. A verified non-directory stray cannot hold a lock and is
|
|
581
|
+
* ignored; a symlink/unknown entry or unreadable listing/metadata fails
|
|
582
|
+
* closed. The maintenance exemption applies only to this store's exact nonce.
|
|
583
|
+
*/
|
|
584
|
+
isCleaningAny(scope: ReportArtifactScope): boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Awaited form of `isCleaningAny`: bounded async filesystem work only (one
|
|
587
|
+
* listing plus at most one lock read per root) and a fresh read on every call,
|
|
588
|
+
* so no negative/positive result is cached across a cleanup window.
|
|
589
|
+
*/
|
|
590
|
+
isCleaningAnyAsync(scope: ReportArtifactScope): Promise<boolean>;
|
|
591
|
+
/** Refuse artifact work while cleanup holds a lock for this id/session. */
|
|
592
|
+
isCleaning(agentId?: string, sessionFile?: string): boolean;
|
|
593
|
+
/** Sync combined-scope refusal; see `isCleaningAny`. */
|
|
594
|
+
assertAvailableAny(scope: ReportArtifactScope): void;
|
|
595
|
+
/** Async combined-scope refusal; see `isCleaningAnyAsync`. */
|
|
596
|
+
assertAvailableAnyAsync(scope: ReportArtifactScope): Promise<void>;
|
|
597
|
+
/**
|
|
598
|
+
* Barrier used by spawn/resume/read acquisition and by selected cleanup:
|
|
599
|
+
* a no-argument call checks this activation against the root lock; with an
|
|
600
|
+
* id/session file it checks every root lock's selection.
|
|
601
|
+
*/
|
|
602
|
+
assertAvailable(agentId?: string, sessionFile?: string): void;
|
|
603
|
+
/**
|
|
604
|
+
* Awaited no-argument barrier with the same own-activation/own-root contract as
|
|
605
|
+
* `assertAvailable()`: no synchronous filesystem read, so a caller that has
|
|
606
|
+
* already suspended never blocks the main thread on its own root's lock.
|
|
607
|
+
*/
|
|
608
|
+
assertAvailableAsync(): Promise<void>;
|
|
609
|
+
/** Persist one settled generation. Snapshot is captured before the first await. */
|
|
610
|
+
save(record: AgentRecord): Promise<ReportSaveResult>;
|
|
611
|
+
/**
|
|
612
|
+
* Register a workflow's exact generated artifacts at creation and settlement,
|
|
613
|
+
* independently of how many agents it eventually runs (zero included). The
|
|
614
|
+
* caller captures inline copies before a saved/external scriptPath can replace
|
|
615
|
+
* them; external paths are provenance only and never deletion candidates.
|
|
616
|
+
*/
|
|
617
|
+
registerWorkflow(registration: WorkflowArtifactRegistration): Promise<ReportSaveResult>;
|
|
618
|
+
private readRootState;
|
|
619
|
+
/**
|
|
620
|
+
* One root state plus the first reason any part of it could not be read. The
|
|
621
|
+
* cleanup identity inventory never treats a partial read as "nothing here".
|
|
622
|
+
*/
|
|
623
|
+
private readRootStateScan;
|
|
624
|
+
private enumerateRootIds;
|
|
625
|
+
/** Enumeration that reports a partial listing instead of returning "no roots". */
|
|
626
|
+
private enumerateRootIdsScan;
|
|
627
|
+
/**
|
|
628
|
+
* Strict global identity inventory for cleanup: complete, or an explicit
|
|
629
|
+
* reason why a root's main-session identity may be missing.
|
|
630
|
+
*/
|
|
631
|
+
scanRootIdentities(): Promise<ReportIdentityScan>;
|
|
632
|
+
list(scope: CleanupScope, previewRootSessionId?: string): Promise<ReportRootState[]>;
|
|
633
|
+
/** Current persisted generation, or undefined when no metadata exists. */
|
|
634
|
+
getRootGeneration(rootSessionId: string): Promise<number | undefined>;
|
|
635
|
+
/**
|
|
636
|
+
* Status-rich durable entry read for final verification. Unlike `readEntry`,
|
|
637
|
+
* absence is only reported when it is PROVEN: an unreadable reports root, root
|
|
638
|
+
* directory, entry file or entry metadata is `uncertain` and the caller must
|
|
639
|
+
* refuse its captured body. `readEntry` keeps the historic best-effort
|
|
640
|
+
* undefined contract for every non-verified state.
|
|
641
|
+
*/
|
|
642
|
+
readEntryState(rootSessionId: string, agentId: string): Promise<ReportEntryState>;
|
|
643
|
+
readEntry(rootSessionId: string, agentId: string): Promise<ReportEntry | undefined>;
|
|
644
|
+
private entriesById;
|
|
645
|
+
private freshDeleted;
|
|
646
|
+
private deletedLookup;
|
|
647
|
+
private fullLookup;
|
|
648
|
+
/**
|
|
649
|
+
* A lookup view for a body that is past retention but not yet stubbed on disk.
|
|
650
|
+
* The on-disk body is untouched (no read-time deletion), yet the returned
|
|
651
|
+
* entry cannot silently hand an expired body to a caller as current.
|
|
652
|
+
*/
|
|
653
|
+
private expiredLookup;
|
|
654
|
+
find(ref: string, parentEntries?: readonly unknown[]): Promise<ReportLookup>;
|
|
655
|
+
/**
|
|
656
|
+
* Owner-scoped archived read for nested tools/workflows. The owner context is
|
|
657
|
+
* strict: a normal parent id matches `parentAgentId` or its ancestor-chain
|
|
658
|
+
* `ownerIds`, never a workflow row (even if the strings collide). A workflow
|
|
659
|
+
* context matches only that workflow. Siblings, top-level and unrelated owners
|
|
660
|
+
* stay invisible even to an exact-id request.
|
|
661
|
+
*/
|
|
662
|
+
findOwned(ref: string, ownerId: string, context?: ReportOwnerContext): Promise<ReportLookup>;
|
|
663
|
+
private parentSnapshotFresh;
|
|
664
|
+
private syntheticEntry;
|
|
665
|
+
private findLegacyOutput;
|
|
666
|
+
/**
|
|
667
|
+
* Read-only legacy inventory for cleanup previews: every generated `.output`
|
|
668
|
+
* file in the known temp layout, with a verified authoritative snapshot when
|
|
669
|
+
* its matching parent session record proves a top-level finished report.
|
|
670
|
+
*/
|
|
671
|
+
inspectLegacyOutputs(): Promise<LegacyOutputInspection[]>;
|
|
672
|
+
private legacyOutputPaths;
|
|
673
|
+
/** Exact temp layout: `<temp>/pi-subagents-<uid>/<encoded>/<session>/tasks/<id>.output`. */
|
|
674
|
+
private allLegacyOutputCandidates;
|
|
675
|
+
private verifyLegacyOutput;
|
|
676
|
+
private findParentSessionFile;
|
|
677
|
+
readSessionFile(path: string): Promise<ParsedSessionFile | undefined>;
|
|
678
|
+
/**
|
|
679
|
+
* Opt-in verbose conversation read. Existing files only; no live session is
|
|
680
|
+
* touched and the final report above it is never affected by a missing file.
|
|
681
|
+
*/
|
|
682
|
+
readConversation(report: ReportSnapshot): Promise<string | undefined>;
|
|
683
|
+
private maybeMaintainRootLocked;
|
|
684
|
+
private expireRootLocked;
|
|
685
|
+
private maintenanceContext;
|
|
686
|
+
private maintainRoot;
|
|
687
|
+
private expireRoot;
|
|
688
|
+
/** Startup/explicit maintenance: expire bodies and old receipts across roots. */
|
|
689
|
+
maintain(): Promise<void>;
|
|
690
|
+
/** Foreign live/unknown leases and locks protect the whole root from cleanup. */
|
|
691
|
+
rootProtectionReason(rootSessionId: string): Promise<string | undefined>;
|
|
692
|
+
/**
|
|
693
|
+
* Cleanup acquires the exclusive per-root lock FIRST, then rechecks foreign
|
|
694
|
+
* leases. A foreign live/unknown lease makes the whole root ineligible.
|
|
695
|
+
*/
|
|
696
|
+
acquireCleanupLock(rootSessionId: string, selection: CleanupSelection, options?: CleanupLockOptions): Promise<{
|
|
697
|
+
ok: true;
|
|
698
|
+
handle: CleanupLockHandle;
|
|
699
|
+
} | {
|
|
700
|
+
ok: false;
|
|
701
|
+
reason: string;
|
|
702
|
+
}>;
|
|
703
|
+
private localCleanupLockBusy;
|
|
704
|
+
/** Own-nonce exemption spans publication itself, validation and final release. */
|
|
705
|
+
private acquireMaintenanceLock;
|
|
706
|
+
private acquireCleanupLockWithNonce;
|
|
707
|
+
releaseCleanupLock(handle: CleanupLockHandle): Promise<void>;
|
|
708
|
+
/**
|
|
709
|
+
* Replace a report body with a minimal deletion receipt. Done before any
|
|
710
|
+
* artifact unlink so a parent-transcript/legacy re-import cannot resurrect it.
|
|
711
|
+
*/
|
|
712
|
+
writeDeletionReceipt(rootSessionId: string, expected: ReportEntry, request?: DeletionReceiptRequest): Promise<DeletionReceiptResult>;
|
|
713
|
+
/**
|
|
714
|
+
* Minimal durable receipt for a verified legacy report. The main parent
|
|
715
|
+
* conversation is never touched; only the archive ownership index is written,
|
|
716
|
+
* and no root metadata is seeded for a legacy-only control namespace.
|
|
717
|
+
*/
|
|
718
|
+
writeLegacyDeletionReceipt(snapshot: ReportSnapshot, request?: {
|
|
719
|
+
deletedAt?: number;
|
|
720
|
+
reason?: string;
|
|
721
|
+
beforeCommit?: () => Promise<void>;
|
|
722
|
+
}): Promise<DeletionReceiptResult>;
|
|
723
|
+
/** Remove a workflow ownership entry once its generated files are gone. */
|
|
724
|
+
removeWorkflowRegistration(rootSessionId: string, workflowId: string, expectedUpdatedAt?: number, beforeRemove?: () => Promise<void>): Promise<{
|
|
725
|
+
removed: boolean;
|
|
726
|
+
reason?: string;
|
|
727
|
+
rootGeneration?: number;
|
|
728
|
+
}>;
|
|
729
|
+
/**
|
|
730
|
+
* Remove root metadata only when no report/workflow entry remains. The caller
|
|
731
|
+
* holds the cleanup lock; the lock file itself is not metadata.
|
|
732
|
+
*/
|
|
733
|
+
removeRootMetadata(rootSessionId: string, expectedGeneration: number, beforeRemove?: () => Promise<void>): Promise<{
|
|
734
|
+
removed: boolean;
|
|
735
|
+
reason?: string;
|
|
736
|
+
}>;
|
|
737
|
+
}
|
|
738
|
+
export {};
|