session-peer 0.3.6 → 0.4.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.
@@ -0,0 +1,112 @@
1
+ export declare const HANDOFF_LIMITS: Readonly<{
2
+ privateFrame: 4096;
3
+ publicFrame: 8192;
4
+ outerFrame: 1048576;
5
+ fanout: 32;
6
+ aggregateFrame: 34603008;
7
+ intents: 10000;
8
+ journal: 33554432;
9
+ waits: 64;
10
+ detailMs: number;
11
+ capabilityMs: 86400000;
12
+ cleanupMs: 5000;
13
+ }>;
14
+ export type WaitFor = 'none' | 'delivered' | 'acknowledged';
15
+ export type WaitStatus = 'not_requested' | 'pending' | 'satisfied' | 'timed_out_unknown' | 'stopped' | 'unsupported' | 'failed';
16
+ export type WaitReason = 'insufficient_budget' | 'deadline_before_effect' | 'evidence_unsupported' | 'evidence_failed' | 'history_unavailable' | 'stopped_by_operator' | 'invalid_handoff';
17
+ export type Handoff = {
18
+ schemaVersion: 1;
19
+ correlationId: string;
20
+ ledgerEpoch: string;
21
+ state: 'validated' | 'refused' | 'submitted' | 'delivered' | 'acknowledged' | 'unknown' | 'timed_out_unknown';
22
+ submission: {
23
+ status: 'not_attempted' | 'submitted' | 'refused' | 'unknown';
24
+ };
25
+ observation: {
26
+ status: 'not_requested' | 'pending' | 'observed' | 'unsupported' | 'failed';
27
+ injectionObserved: boolean;
28
+ clientUserMessageId?: string;
29
+ turn?: {
30
+ id: string;
31
+ status: 'running' | 'completed' | 'failed' | 'interrupted' | 'unknown';
32
+ };
33
+ };
34
+ ack: {
35
+ status: 'not_requested' | 'pending' | 'acknowledged' | 'unsupported';
36
+ assurance?: 'token_possession' | 'operator_confirmed';
37
+ receivedAtUtcMs?: number;
38
+ late?: boolean;
39
+ };
40
+ wait: {
41
+ for: WaitFor;
42
+ status: WaitStatus;
43
+ operationId?: string;
44
+ deadlineAtUtcMs?: number;
45
+ reason?: WaitReason;
46
+ };
47
+ targetGeneration: string | null;
48
+ decisionOwner: 'sender_operator';
49
+ retry: {
50
+ allowed: false;
51
+ reason: 'receiver_dedup_unavailable';
52
+ };
53
+ nextActions: ('keep_waiting' | 'reconcile' | 'stop_waiting')[];
54
+ };
55
+ export type PublicHandoff = Handoff;
56
+ export type Clock = {
57
+ monotonic: () => number;
58
+ utc: () => number;
59
+ };
60
+ export declare const systemClock: Clock;
61
+ export declare function fail(code?: string, exitCode?: number): never;
62
+ export declare function canonicalId(value: unknown): value is string;
63
+ export declare function safeInteger(value: unknown): value is number;
64
+ export declare function safeId(value: unknown, bytes?: number): value is string;
65
+ export declare function parseWaitTimeout(value: string): number;
66
+ export declare class HandoffBudget {
67
+ readonly seconds: number;
68
+ readonly clock: Clock;
69
+ readonly startedAt: number;
70
+ readonly cutoff: number;
71
+ readonly deadline: number;
72
+ readonly deadlineAtUtcMs: number;
73
+ constructor(seconds?: number, clock?: Clock);
74
+ static fromRemainingMs(remainingMs: number, clock?: Clock, startedAt?: number): HandoffBudget;
75
+ remainingMs(): number;
76
+ observationRemainingMs(): number;
77
+ beforeEffect(): void;
78
+ }
79
+ export declare function parseStrictJson(raw: string | Uint8Array, options?: {
80
+ scope?: 'private' | 'handoff' | 'query' | 'outer';
81
+ maxBytes?: number;
82
+ }): unknown;
83
+ export declare function closed(value: unknown, required: string[], optional?: string[]): Record<string, unknown>;
84
+ export declare function validateHandoff(value: unknown): Handoff;
85
+ export type Receipt = {
86
+ schemaVersion: 1;
87
+ kind: 'receipt';
88
+ ledgerEpoch: string;
89
+ correlationId: string;
90
+ targetGeneration: string;
91
+ receiptId: string;
92
+ capability: string;
93
+ };
94
+ export type Confirmation = {
95
+ schemaVersion: 1;
96
+ ledgerEpoch: string;
97
+ correlationId: string;
98
+ targetGeneration: string;
99
+ confirmed: true;
100
+ };
101
+ export declare function validateHandoffQuery(value: unknown): {
102
+ schemaVersion: 1;
103
+ correlationId: string;
104
+ status: 'unknown';
105
+ context: 'ledger_missing' | 'ledger_corrupt' | 'id_unknown';
106
+ retry: {
107
+ allowed: false;
108
+ reason: 'history_unavailable';
109
+ };
110
+ };
111
+ export declare function validateReceipt(raw: string | Uint8Array): Receipt;
112
+ export declare function validateConfirmation(raw: string | Uint8Array): Confirmation;
@@ -0,0 +1,261 @@
1
+ // Pure opt-in protocol helpers. Importing this module performs no filesystem IO.
2
+ import { Refusal } from './discovery.js';
3
+ export const HANDOFF_LIMITS = Object.freeze({ privateFrame: 4096, publicFrame: 8192, outerFrame: 1048576,
4
+ fanout: 32, aggregateFrame: 34603008, intents: 10000, journal: 33554432, waits: 64,
5
+ detailMs: 30 * 86400000, capabilityMs: 86400000, cleanupMs: 5000 });
6
+ export const systemClock = { monotonic: () => performance.now(), utc: () => Date.now() };
7
+ export function fail(code = 'invalid_handoff', exitCode = 1) { throw new Refusal(code, exitCode); }
8
+ export function canonicalId(value) {
9
+ return typeof value === 'string' && /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(value);
10
+ }
11
+ export function safeInteger(value) { return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0; }
12
+ export function safeId(value, bytes = 128) {
13
+ return typeof value === 'string' && value.length > 0 && Buffer.byteLength(value, 'utf8') <= bytes &&
14
+ !/[\x00-\x1f\x7f-\x9f]/.test(value) && !/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(value);
15
+ }
16
+ export function parseWaitTimeout(value) {
17
+ if (!/^(?:[1-9]|[1-5][0-9]|60)$/.test(value))
18
+ fail('invalid_wait_timeout', 2);
19
+ return Number(value);
20
+ }
21
+ export class HandoffBudget {
22
+ seconds;
23
+ clock;
24
+ startedAt;
25
+ cutoff;
26
+ deadline;
27
+ deadlineAtUtcMs;
28
+ constructor(seconds = 30, clock = systemClock) {
29
+ this.seconds = seconds;
30
+ this.clock = clock;
31
+ parseWaitTimeout(String(seconds));
32
+ this.startedAt = clock.monotonic();
33
+ this.deadline = this.startedAt + seconds * 1000;
34
+ this.cutoff = this.deadline - HANDOFF_LIMITS.cleanupMs;
35
+ this.deadlineAtUtcMs = Math.max(0, Math.floor(clock.utc() + Math.max(0, seconds * 1000 - HANDOFF_LIMITS.cleanupMs)));
36
+ }
37
+ // Private SSH frames carry a remaining duration, never a renewed CLI budget
38
+ // or a UTC authorization deadline. Charge frame-reading time to that duration.
39
+ static fromRemainingMs(remainingMs, clock = systemClock, startedAt = clock.monotonic()) {
40
+ if (!safeInteger(remainingMs) || remainingMs < 1 || remainingMs > 60000 || !Number.isFinite(startedAt) || startedAt > clock.monotonic())
41
+ fail('invalid_handoff_budget', 2);
42
+ const budget = new HandoffBudget(Math.ceil(remainingMs / 1000), clock);
43
+ const deadline = startedAt + remainingMs, cutoff = deadline - HANDOFF_LIMITS.cleanupMs;
44
+ Object.assign(budget, { startedAt, deadline, cutoff,
45
+ deadlineAtUtcMs: Math.max(0, Math.floor(clock.utc() + Math.max(0, cutoff - clock.monotonic()))) });
46
+ return budget;
47
+ }
48
+ remainingMs() { return Math.max(0, this.deadline - this.clock.monotonic()); }
49
+ observationRemainingMs() { return Math.max(0, this.cutoff - this.clock.monotonic()); }
50
+ beforeEffect() {
51
+ if (this.seconds <= 5)
52
+ fail('insufficient_budget');
53
+ if (this.clock.monotonic() >= this.cutoff)
54
+ fail('deadline_before_effect');
55
+ }
56
+ }
57
+ // Recursive token parser keeps integer lexemes before JavaScript can round them.
58
+ // Outer mode restricts new-schema subtrees only; native numeric siblings retain
59
+ // their existing grammar. Duplicate keys/nonfinite numbers always fail closed.
60
+ export function parseStrictJson(raw, options = {}) {
61
+ if (typeof raw === 'string' && /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(raw))
62
+ fail('invalid_handoff_json');
63
+ const scope = options.scope ?? 'private', bytes = typeof raw === 'string' ? Buffer.from(raw, 'utf8') : raw;
64
+ const maximum = options.maxBytes ?? (scope === 'outer' ? HANDOFF_LIMITS.outerFrame : scope === 'handoff' ? HANDOFF_LIMITS.publicFrame : HANDOFF_LIMITS.privateFrame);
65
+ if (bytes.byteLength > maximum)
66
+ fail('handoff_frame_too_large');
67
+ let text;
68
+ try {
69
+ text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
70
+ }
71
+ catch {
72
+ fail('invalid_handoff_json');
73
+ }
74
+ let position = 0;
75
+ const space = () => { while (/[\x20\t\r\n]/.test(text[position] ?? 'x'))
76
+ position++; };
77
+ const string = () => {
78
+ const start = position++;
79
+ while (position < text.length) {
80
+ const c = text[position++];
81
+ if (c === '"') {
82
+ try {
83
+ return JSON.parse(text.slice(start, position));
84
+ }
85
+ catch {
86
+ fail('invalid_handoff_json');
87
+ }
88
+ }
89
+ if (c === '\\')
90
+ position++;
91
+ }
92
+ fail('invalid_handoff_json');
93
+ };
94
+ const value = (strict, depth) => {
95
+ if (depth > 64)
96
+ fail('invalid_handoff_json');
97
+ space();
98
+ const c = text[position];
99
+ if (c === '"')
100
+ return string();
101
+ if (c === '{') {
102
+ position++;
103
+ space();
104
+ const result = Object.create(null), keys = new Set();
105
+ if (text[position] === '}') {
106
+ position++;
107
+ return result;
108
+ }
109
+ while (true) {
110
+ space();
111
+ if (text[position] !== '"')
112
+ fail('invalid_handoff_json');
113
+ const key = string();
114
+ if (keys.has(key))
115
+ fail('invalid_handoff_json');
116
+ keys.add(key);
117
+ space();
118
+ if (text[position++] !== ':')
119
+ fail('invalid_handoff_json');
120
+ result[key] = value(strict || (scope === 'outer' && depth === 0 && ['handoff', 'handoffQuery'].includes(key)), depth + 1);
121
+ space();
122
+ const separator = text[position++];
123
+ if (separator === '}')
124
+ break;
125
+ if (separator !== ',')
126
+ fail('invalid_handoff_json');
127
+ }
128
+ return result;
129
+ }
130
+ if (c === '[') {
131
+ position++;
132
+ space();
133
+ const result = [];
134
+ if (text[position] === ']') {
135
+ position++;
136
+ return result;
137
+ }
138
+ while (true) {
139
+ result.push(value(strict, depth + 1));
140
+ space();
141
+ const separator = text[position++];
142
+ if (separator === ']')
143
+ break;
144
+ if (separator !== ',')
145
+ fail('invalid_handoff_json');
146
+ }
147
+ return result;
148
+ }
149
+ for (const [literal, item] of [['true', true], ['false', false], ['null', null]]) {
150
+ if (text.startsWith(literal, position)) {
151
+ position += literal.length;
152
+ return item;
153
+ }
154
+ }
155
+ const token = /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?/.exec(text.slice(position))?.[0];
156
+ if (!token)
157
+ fail('invalid_handoff_json');
158
+ position += token.length;
159
+ const number = Number(token);
160
+ if (!Number.isFinite(number) || (strict && (!/^(?:0|[1-9][0-9]*)$/.test(token) || !safeInteger(number))))
161
+ fail('invalid_handoff_json');
162
+ return number;
163
+ };
164
+ const result = value(scope !== 'outer', 0);
165
+ space();
166
+ if (position !== text.length)
167
+ fail('invalid_handoff_json');
168
+ return result;
169
+ }
170
+ export function closed(value, required, optional = []) {
171
+ if (!value || typeof value !== 'object' || Array.isArray(value))
172
+ fail();
173
+ const row = value;
174
+ if (required.some(key => !Object.hasOwn(row, key)) || Object.keys(row).some(key => !required.includes(key) && !optional.includes(key)))
175
+ fail();
176
+ return row;
177
+ }
178
+ const member = (value, values) => typeof value === 'string' && values.includes(value);
179
+ export function validateHandoff(value) {
180
+ const row = closed(value, ['schemaVersion', 'correlationId', 'ledgerEpoch', 'state', 'submission', 'observation', 'ack', 'wait', 'targetGeneration', 'decisionOwner', 'retry', 'nextActions']);
181
+ const sub = closed(row.submission, ['status']), obs = closed(row.observation, ['status', 'injectionObserved'], ['clientUserMessageId', 'turn']);
182
+ const ack = closed(row.ack, ['status'], ['assurance', 'receivedAtUtcMs', 'late']);
183
+ const wait = closed(row.wait, ['for', 'status'], ['operationId', 'deadlineAtUtcMs', 'reason']);
184
+ const retry = closed(row.retry, ['allowed', 'reason']);
185
+ if (row.schemaVersion !== 1 || !canonicalId(row.correlationId) || !canonicalId(row.ledgerEpoch) ||
186
+ !member(row.state, ['validated', 'refused', 'submitted', 'delivered', 'acknowledged', 'unknown', 'timed_out_unknown']) ||
187
+ !member(sub.status, ['not_attempted', 'submitted', 'refused', 'unknown']) ||
188
+ !member(obs.status, ['not_requested', 'pending', 'observed', 'unsupported', 'failed']) || typeof obs.injectionObserved !== 'boolean' ||
189
+ !member(ack.status, ['not_requested', 'pending', 'acknowledged', 'unsupported']) ||
190
+ !member(wait.for, ['none', 'delivered', 'acknowledged']) || !member(wait.status, ['not_requested', 'pending', 'satisfied', 'timed_out_unknown', 'stopped', 'unsupported', 'failed']) ||
191
+ (row.targetGeneration !== null && !safeId(row.targetGeneration, 256)) || row.decisionOwner !== 'sender_operator' ||
192
+ retry.allowed !== false || retry.reason !== 'receiver_dedup_unavailable' || !Array.isArray(row.nextActions) ||
193
+ row.nextActions.some(item => !member(item, ['keep_waiting', 'reconcile', 'stop_waiting'])) || new Set(row.nextActions).size !== row.nextActions.length)
194
+ fail();
195
+ if (Object.hasOwn(obs, 'clientUserMessageId') && !safeId(obs.clientUserMessageId))
196
+ fail();
197
+ if (obs.injectionObserved !== (obs.status === 'observed') ||
198
+ (obs.injectionObserved && (!safeId(obs.clientUserMessageId) || row.targetGeneration === null || sub.status !== 'submitted')) ||
199
+ (!obs.injectionObserved && Object.hasOwn(obs, 'clientUserMessageId')))
200
+ fail();
201
+ if (Object.hasOwn(obs, 'turn')) {
202
+ const turn = closed(obs.turn, ['id', 'status']);
203
+ if (!obs.injectionObserved || !safeId(turn.id) || !member(turn.status, ['running', 'completed', 'failed', 'interrupted', 'unknown']))
204
+ fail();
205
+ }
206
+ if (ack.status === 'acknowledged') {
207
+ if (!member(ack.assurance, ['token_possession', 'operator_confirmed']) || !safeInteger(ack.receivedAtUtcMs) || typeof ack.late !== 'boolean' || row.state !== 'acknowledged' || sub.status !== 'submitted' || row.targetGeneration === null)
208
+ fail();
209
+ }
210
+ else if (['assurance', 'receivedAtUtcMs', 'late'].some(key => Object.hasOwn(ack, key)))
211
+ fail();
212
+ if (row.targetGeneration === null && (ack.status === 'pending' || ack.status === 'acknowledged' || wait.status === 'pending' || wait.status === 'satisfied'))
213
+ fail();
214
+ const states = { validated: 'not_attempted', refused: 'refused', submitted: 'submitted', delivered: 'submitted', acknowledged: 'submitted', unknown: 'unknown' };
215
+ if ((row.state !== 'timed_out_unknown' && sub.status !== states[row.state]) ||
216
+ (row.state === 'timed_out_unknown' && !['submitted', 'unknown'].includes(sub.status)) ||
217
+ (row.state === 'delivered' && !obs.injectionObserved) || (row.state === 'acknowledged' && ack.status !== 'acknowledged'))
218
+ fail();
219
+ if (wait.for === 'none') {
220
+ if (wait.status !== 'not_requested' || Object.keys(wait).length !== 2)
221
+ fail();
222
+ }
223
+ else if (wait.status === 'not_requested' || !canonicalId(wait.operationId) || !safeInteger(wait.deadlineAtUtcMs))
224
+ fail();
225
+ if (Object.hasOwn(wait, 'reason') && !member(wait.reason, ['insufficient_budget', 'deadline_before_effect', 'evidence_unsupported', 'evidence_failed', 'history_unavailable', 'stopped_by_operator', 'invalid_handoff']))
226
+ fail();
227
+ if (wait.status === 'stopped' && wait.reason !== 'stopped_by_operator')
228
+ fail();
229
+ if (wait.status === 'satisfied' && (wait.for === 'delivered' ? !obs.injectionObserved : ack.status !== 'acknowledged'))
230
+ fail();
231
+ if (row.nextActions.includes('keep_waiting') && (row.targetGeneration === null || wait.status === 'unsupported' ||
232
+ (wait.for === 'delivered' ? obs.status !== 'pending' : wait.for !== 'acknowledged' || ack.status !== 'pending') ||
233
+ !['submitted', 'unknown'].includes(sub.status)))
234
+ fail();
235
+ if (row.nextActions.includes('stop_waiting') && wait.status !== 'pending')
236
+ fail();
237
+ if (Buffer.byteLength(JSON.stringify(row), 'utf8') > HANDOFF_LIMITS.publicFrame)
238
+ fail('handoff_frame_too_large');
239
+ return structuredClone(row);
240
+ }
241
+ export function validateHandoffQuery(value) {
242
+ const row = closed(value, ['schemaVersion', 'correlationId', 'status', 'context', 'retry']);
243
+ const retry = closed(row.retry, ['allowed', 'reason']);
244
+ if (row.schemaVersion !== 1 || !canonicalId(row.correlationId) || row.status !== 'unknown' ||
245
+ !member(row.context, ['ledger_missing', 'ledger_corrupt', 'id_unknown']) || retry.allowed !== false || retry.reason !== 'history_unavailable')
246
+ fail();
247
+ return structuredClone(row);
248
+ }
249
+ export function validateReceipt(raw) {
250
+ const row = closed(parseStrictJson(raw), ['schemaVersion', 'kind', 'ledgerEpoch', 'correlationId', 'targetGeneration', 'receiptId', 'capability']);
251
+ if (row.schemaVersion !== 1 || row.kind !== 'receipt' || !canonicalId(row.ledgerEpoch) || !canonicalId(row.correlationId) || !canonicalId(row.receiptId) || !safeId(row.targetGeneration, 256) ||
252
+ typeof row.capability !== 'string' || !/^[A-Za-z0-9_-]{43}$/.test(row.capability) || Buffer.from(row.capability, 'base64url').length !== 32 || Buffer.from(row.capability, 'base64url').toString('base64url') !== row.capability)
253
+ fail('invalid_receipt');
254
+ return row;
255
+ }
256
+ export function validateConfirmation(raw) {
257
+ const row = closed(parseStrictJson(raw), ['schemaVersion', 'ledgerEpoch', 'correlationId', 'targetGeneration', 'confirmed']);
258
+ if (row.schemaVersion !== 1 || !canonicalId(row.ledgerEpoch) || !canonicalId(row.correlationId) || !safeId(row.targetGeneration, 256) || row.confirmed !== true)
259
+ fail('invalid_confirmation');
260
+ return row;
261
+ }
package/dist/help.js CHANGED
@@ -17,6 +17,17 @@ Transport:
17
17
  known online peers use their MagicDNS name, known offline peers are refused.
18
18
  --no-update-notice Suppress the opt-in cached update notice
19
19
  -h, --help Show command help`;
20
+ if (command === 'handoff' || command === 'ack')
21
+ return `Usage: session-peer handoff init|prepare|status|wait|confirm --json
22
+ init Initialize private POSIX sender ledger explicitly
23
+ prepare --to TARGET --message-file FILE Reserve a fresh ID without submitting (FILE mode 0600)
24
+ status --correlation-id UUID Inspect retained evidence; never submit again
25
+ wait --correlation-id UUID --wait-for delivered|acknowledged --wait-timeout SECONDS
26
+ confirm --receipt - Read private operator-confirmation JSON from stdin
27
+ ack --receipt - Record a qualified private receipt; never prompt an agent
28
+ SESSION_PEER_HANDOFF_HOME selects an absolute private ledger directory.
29
+ Production automated receipt bootstrap and Windows ledger are unsupported.
30
+ Missing history never authorizes retry. Secrets must never be passed through argv.`;
20
31
  if (command === 'list')
21
32
  return `Usage: session-peer list [options]
22
33
  List reachable Claude and saved Codex sessions. Listing is not send authorization.
@@ -51,6 +62,12 @@ Notices on other commands are opt-in: SESSION_PEER_UPDATE_NOTICE=1.`;
51
62
  TARGET: Claude name/PID, claude:NAME/PID, codex:UUID, or session-peer reply URI.
52
63
  Omit the body or use - for UTF-8 stdin. Only one body source is permitted.
53
64
  Unicode names use exact Unicode 14.0.0 default casefold; collisions require PID.
65
+ --correlation-id UUID Use an already-prepared private handoff ID (opt-in)
66
+ --request-ack Add handoff metadata; automated ACK currently unsupported
67
+ --observe-delivery Request optional body-free observation (qualified routes only)
68
+ --wait-for delivered|acknowledged Refuse before submission if required evidence is unsupported
69
+ --wait-timeout SECONDS Total budget 1..60 (default 30, includes 5 s cleanup)
70
+ --message-file FILE Private UTF-8 input file (POSIX mode 0600)
54
71
  --dry-run Validate without submission
55
72
  --codex-home HOME Explicit Codex home; otherwise select unique live writer
56
73
  --codex-bin PATH Native Codex executable
@@ -70,6 +87,7 @@ Usage: session-peer <command> [options]
70
87
  send Submit one guarded message
71
88
  doctor Inspect read-only metadata and capabilities
72
89
  update --check Check npm for a newer version (no self-update)
90
+ handoff / ack Opt-in private evidence operations (see handoff --help)
73
91
  --version Print exact runtime version
74
92
  --help, -h Show help; <command> --help for details
75
93
  ${common}
@@ -0,0 +1,48 @@
1
+ export declare const METADATA_SOURCE: Readonly<{
2
+ version: "0.160.1";
3
+ commit: "d27764b82f7118f674371e6d6e76271d9d606edb";
4
+ database: "thread_history_1.sqlite";
5
+ recentUsers: 256;
6
+ maxCellBytes: number;
7
+ childMs: 1000;
8
+ }>;
9
+ export type MetadataScope = Readonly<{
10
+ home: string;
11
+ threadId: string;
12
+ generation: string | null;
13
+ }>;
14
+ export declare const METADATA_RESUME_QUALIFICATION: Readonly<{
15
+ version: "0.160.1";
16
+ commit: "d27764b82f7118f674371e6d6e76271d9d606edb";
17
+ platform: "darwin-arm64";
18
+ }>;
19
+ export type MetadataQualification = Readonly<{
20
+ version: string;
21
+ commit: string;
22
+ platform: string;
23
+ }>;
24
+ export declare function metadataQualification(version: string): MetadataQualification | undefined;
25
+ export type MetadataBudget = {
26
+ observationRemainingMs(): number;
27
+ };
28
+ export type VerifyMetadataOwner = (scope: MetadataScope, signal: AbortSignal) => boolean | Promise<boolean>;
29
+ export type MetadataReason = 'metadata_version_unsupported' | 'metadata_platform_unsupported' | 'metadata_scope_invalid' | 'metadata_storage_untrusted' | 'metadata_history_unavailable' | 'metadata_schema_unsupported' | 'metadata_owner_changed' | 'metadata_deadline' | 'metadata_probe_failed' | 'metadata_probe_stopped' | 'metadata_ambiguous';
30
+ export type MetadataCapability = {
31
+ supported: boolean;
32
+ reason?: MetadataReason;
33
+ };
34
+ export type MetadataObservation = MetadataCapability & {
35
+ injectionObserved: boolean;
36
+ clientUserMessageId?: string;
37
+ turn?: {
38
+ id: string;
39
+ status: 'running' | 'completed' | 'failed' | 'interrupted' | 'unknown';
40
+ };
41
+ };
42
+ export declare function metadataCapability(scope: MetadataScope, version: string, budget: MetadataBudget | undefined, verifyOwner: VerifyMetadataOwner): Promise<MetadataCapability>;
43
+ export declare function observeMetadata(scope: MetadataScope & {
44
+ clientUserMessageId: string;
45
+ }, budget: MetadataBudget, verifyOwner: VerifyMetadataOwner): Promise<MetadataObservation>;
46
+ export declare function resumeMetadataObservation(scope: MetadataScope & {
47
+ clientUserMessageId: string;
48
+ }, qualification: MetadataQualification, budget: MetadataBudget, verifyOwner: VerifyMetadataOwner): Promise<MetadataObservation>;