@margay/ccl-core 1.5.0-alpha.4 → 1.5.1-alpha.3
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/dist/cli.js +108954 -103254
- package/dist/sdk/background.d.ts +48 -0
- package/dist/sdk/background.js +87 -0
- package/dist/sdk/backgroundRunTypes.d.ts +101 -0
- package/dist/sdk/backgroundRunTypes.js +1 -0
- package/dist/sdk/cancellation.d.ts +15 -0
- package/dist/sdk/cancellation.js +18 -0
- package/dist/sdk/commandAdapter.d.ts +77 -0
- package/dist/sdk/commandAdapter.js +180 -0
- package/dist/sdk/commandProcess.d.ts +27 -0
- package/dist/sdk/commandProcess.js +130 -0
- package/dist/sdk/executionGuidance.d.ts +7 -0
- package/dist/sdk/executionGuidance.js +37 -0
- package/dist/sdk/index.d.ts +14 -0
- package/dist/sdk/index.js +9 -0
- package/dist/sdk/mcpServer.d.ts +9 -5
- package/dist/sdk/mcpServer.js +51 -9
- package/dist/sdk/operations/command.d.ts +24 -0
- package/dist/sdk/operations/command.js +48 -0
- package/dist/sdk/operations/host.d.ts +3 -0
- package/dist/sdk/operations/host.js +376 -0
- package/dist/sdk/operations/json.d.ts +6 -0
- package/dist/sdk/operations/json.js +24 -0
- package/dist/sdk/operations/reference.d.ts +15 -0
- package/dist/sdk/operations/reference.js +19 -0
- package/dist/sdk/operations/store.d.ts +26 -0
- package/dist/sdk/operations/store.js +300 -0
- package/dist/sdk/operations/types.d.ts +171 -0
- package/dist/sdk/operations/types.js +8 -0
- package/dist/sdk/pendingApprovalIdentity.d.ts +35 -0
- package/dist/sdk/pendingApprovalIdentity.js +27 -0
- package/dist/sdk/permissionDelegation.d.ts +19 -0
- package/dist/sdk/permissionDelegation.js +11 -0
- package/dist/sdk/query.d.ts +3 -1
- package/dist/sdk/query.js +142 -30
- package/dist/sdk/queryHandle.js +28 -8
- package/dist/sdk/queryLifecycle.d.ts +19 -0
- package/dist/sdk/queryLifecycle.js +93 -0
- package/dist/sdk/queryLifecycleTypes.d.ts +160 -0
- package/dist/sdk/queryLifecycleTypes.js +47 -0
- package/dist/sdk/scheduledOccurrenceTypes.d.ts +103 -0
- package/dist/sdk/scheduledOccurrenceTypes.js +12 -0
- package/dist/sdk/types.d.ts +21 -3
- package/docs/background-runs.md +229 -0
- package/docs/command-tool-recovery.md +62 -0
- package/docs/dev-quickstart.md +29 -7
- package/docs/error-recovery-usage.md +18 -0
- package/docs/hook-input-provenance.md +77 -0
- package/docs/index.md +2 -0
- package/docs/mcp-tool-recovery.md +82 -0
- package/docs/releases/1.5.0-alpha.5.md +26 -0
- package/docs/releases/1.5.0-alpha.6.md +15 -0
- package/docs/releases/1.5.1-alpha.1.md +11 -0
- package/docs/releases/1.5.1-alpha.2.md +17 -0
- package/docs/releases/1.5.1-alpha.3.md +23 -0
- package/docs/releases/1.5.1-alpha.md +22 -0
- package/docs/runtime-resources.md +6 -3
- package/examples/background-runs/agents/background-reviewer.md +6 -0
- package/examples/background-runs/agents/background-worker.md +6 -0
- package/examples/background-runs/worker-reviewer.mjs +42 -0
- package/examples/command-recovery/durable-server.mjs +44 -0
- package/examples/command-recovery/receipt-command.mjs +40 -0
- package/package.json +17 -2
- package/sdk/API.md +206 -1
- package/sdk/README.md +6 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
/** Host observations of one query loop. Neither an authorization nor a business result. */
|
|
3
|
+
export declare const QueryLifecycleSchema: z.ZodObject<{
|
|
4
|
+
version: z.ZodLiteral<1>;
|
|
5
|
+
event_id: z.ZodString;
|
|
6
|
+
query_id: z.ZodString;
|
|
7
|
+
session_id: z.ZodString;
|
|
8
|
+
sequence: z.ZodNumber;
|
|
9
|
+
timestamp: z.ZodString;
|
|
10
|
+
scope: z.ZodEnum<{
|
|
11
|
+
main: "main";
|
|
12
|
+
subagent: "subagent";
|
|
13
|
+
auxiliary: "auxiliary";
|
|
14
|
+
}>;
|
|
15
|
+
agent_id: z.ZodNullable<z.ZodString>;
|
|
16
|
+
phase: z.ZodEnum<{
|
|
17
|
+
start: "start";
|
|
18
|
+
stop_attempt: "stop_attempt";
|
|
19
|
+
stop_failure: "stop_failure";
|
|
20
|
+
terminal: "terminal";
|
|
21
|
+
}>;
|
|
22
|
+
attempt: z.ZodNumber;
|
|
23
|
+
accepted_inputs: z.ZodArray<z.ZodObject<{
|
|
24
|
+
message_id: z.ZodString;
|
|
25
|
+
origin: z.ZodString;
|
|
26
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
version: z.ZodLiteral<1>;
|
|
28
|
+
actor: z.ZodEnum<{
|
|
29
|
+
unknown: "unknown";
|
|
30
|
+
agent: "agent";
|
|
31
|
+
host: "host";
|
|
32
|
+
human: "human";
|
|
33
|
+
}>;
|
|
34
|
+
source: z.ZodString;
|
|
35
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
36
|
+
request_id: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
}, z.core.$strip>>;
|
|
39
|
+
input_message_ids: z.ZodArray<z.ZodString>;
|
|
40
|
+
input_association: z.ZodEnum<{
|
|
41
|
+
unknown: "unknown";
|
|
42
|
+
known: "known";
|
|
43
|
+
}>;
|
|
44
|
+
last_assistant_message_id: z.ZodNullable<z.ZodString>;
|
|
45
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
46
|
+
completed: "completed";
|
|
47
|
+
failed: "failed";
|
|
48
|
+
cancelled: "cancelled";
|
|
49
|
+
interrupted: "interrupted";
|
|
50
|
+
stopped: "stopped";
|
|
51
|
+
}>>;
|
|
52
|
+
terminal_reason: z.ZodNullable<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
54
|
+
export type QueryLifecycleRecord = z.infer<typeof QueryLifecycleSchema>;
|
|
55
|
+
export type QueryLifecycleWrite = {
|
|
56
|
+
state: 'saved';
|
|
57
|
+
} | {
|
|
58
|
+
state: 'unavailable';
|
|
59
|
+
reason: 'persistence_disabled' | 'no_transcript';
|
|
60
|
+
} | {
|
|
61
|
+
state: 'failed';
|
|
62
|
+
reason: 'write_failed';
|
|
63
|
+
} | {
|
|
64
|
+
state: 'unknown';
|
|
65
|
+
reason: 'write_timeout';
|
|
66
|
+
};
|
|
67
|
+
export declare const QueryLifecycleWriteSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
68
|
+
state: z.ZodLiteral<"saved">;
|
|
69
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
70
|
+
state: z.ZodLiteral<"unavailable">;
|
|
71
|
+
reason: z.ZodEnum<{
|
|
72
|
+
persistence_disabled: "persistence_disabled";
|
|
73
|
+
no_transcript: "no_transcript";
|
|
74
|
+
}>;
|
|
75
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
76
|
+
state: z.ZodLiteral<"failed">;
|
|
77
|
+
reason: z.ZodLiteral<"write_failed">;
|
|
78
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
79
|
+
state: z.ZodLiteral<"unknown">;
|
|
80
|
+
reason: z.ZodLiteral<"write_timeout">;
|
|
81
|
+
}, z.core.$strip>]>;
|
|
82
|
+
export type QueryLifecycleObservation = {
|
|
83
|
+
record: QueryLifecycleRecord;
|
|
84
|
+
persistence: QueryLifecycleWrite;
|
|
85
|
+
transcript_path: string | null;
|
|
86
|
+
};
|
|
87
|
+
export declare const QueryLifecycleObservationSchema: z.ZodObject<{
|
|
88
|
+
record: z.ZodObject<{
|
|
89
|
+
version: z.ZodLiteral<1>;
|
|
90
|
+
event_id: z.ZodString;
|
|
91
|
+
query_id: z.ZodString;
|
|
92
|
+
session_id: z.ZodString;
|
|
93
|
+
sequence: z.ZodNumber;
|
|
94
|
+
timestamp: z.ZodString;
|
|
95
|
+
scope: z.ZodEnum<{
|
|
96
|
+
main: "main";
|
|
97
|
+
subagent: "subagent";
|
|
98
|
+
auxiliary: "auxiliary";
|
|
99
|
+
}>;
|
|
100
|
+
agent_id: z.ZodNullable<z.ZodString>;
|
|
101
|
+
phase: z.ZodEnum<{
|
|
102
|
+
start: "start";
|
|
103
|
+
stop_attempt: "stop_attempt";
|
|
104
|
+
stop_failure: "stop_failure";
|
|
105
|
+
terminal: "terminal";
|
|
106
|
+
}>;
|
|
107
|
+
attempt: z.ZodNumber;
|
|
108
|
+
accepted_inputs: z.ZodArray<z.ZodObject<{
|
|
109
|
+
message_id: z.ZodString;
|
|
110
|
+
origin: z.ZodString;
|
|
111
|
+
provenance: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
version: z.ZodLiteral<1>;
|
|
113
|
+
actor: z.ZodEnum<{
|
|
114
|
+
unknown: "unknown";
|
|
115
|
+
agent: "agent";
|
|
116
|
+
host: "host";
|
|
117
|
+
human: "human";
|
|
118
|
+
}>;
|
|
119
|
+
source: z.ZodString;
|
|
120
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
121
|
+
request_id: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
}, z.core.$strip>>;
|
|
124
|
+
input_message_ids: z.ZodArray<z.ZodString>;
|
|
125
|
+
input_association: z.ZodEnum<{
|
|
126
|
+
unknown: "unknown";
|
|
127
|
+
known: "known";
|
|
128
|
+
}>;
|
|
129
|
+
last_assistant_message_id: z.ZodNullable<z.ZodString>;
|
|
130
|
+
status: z.ZodNullable<z.ZodEnum<{
|
|
131
|
+
completed: "completed";
|
|
132
|
+
failed: "failed";
|
|
133
|
+
cancelled: "cancelled";
|
|
134
|
+
interrupted: "interrupted";
|
|
135
|
+
stopped: "stopped";
|
|
136
|
+
}>>;
|
|
137
|
+
terminal_reason: z.ZodNullable<z.ZodString>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
persistence: z.ZodUnion<readonly [z.ZodObject<{
|
|
140
|
+
state: z.ZodLiteral<"saved">;
|
|
141
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
142
|
+
state: z.ZodLiteral<"unavailable">;
|
|
143
|
+
reason: z.ZodEnum<{
|
|
144
|
+
persistence_disabled: "persistence_disabled";
|
|
145
|
+
no_transcript: "no_transcript";
|
|
146
|
+
}>;
|
|
147
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
148
|
+
state: z.ZodLiteral<"failed">;
|
|
149
|
+
reason: z.ZodLiteral<"write_failed">;
|
|
150
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
151
|
+
state: z.ZodLiteral<"unknown">;
|
|
152
|
+
reason: z.ZodLiteral<"write_timeout">;
|
|
153
|
+
}, z.core.$strip>]>;
|
|
154
|
+
transcript_path: z.ZodNullable<z.ZodString>;
|
|
155
|
+
}, z.core.$strip>;
|
|
156
|
+
/** Metadata entry deliberately has no conversation uuid/parentUuid chain fields. */
|
|
157
|
+
export type QueryLifecycleEntry = {
|
|
158
|
+
type: 'query_lifecycle';
|
|
159
|
+
record: QueryLifecycleRecord;
|
|
160
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
const identity = z.string().min(1).max(256);
|
|
3
|
+
const provenance = z.object({
|
|
4
|
+
version: z.literal(1), actor: z.enum(['human', 'host', 'agent', 'unknown']),
|
|
5
|
+
source: z.string(), session_id: z.string().optional(), request_id: z.string().optional(),
|
|
6
|
+
});
|
|
7
|
+
/** Host observations of one query loop. Neither an authorization nor a business result. */
|
|
8
|
+
export const QueryLifecycleSchema = z.object({
|
|
9
|
+
version: z.literal(1), event_id: identity, query_id: identity, session_id: identity,
|
|
10
|
+
sequence: z.number().int().nonnegative(), timestamp: z.string(),
|
|
11
|
+
scope: z.enum(['main', 'subagent', 'auxiliary']), agent_id: identity.nullable(),
|
|
12
|
+
phase: z.enum(['start', 'stop_attempt', 'stop_failure', 'terminal']),
|
|
13
|
+
attempt: z.number().int().nonnegative(),
|
|
14
|
+
accepted_inputs: z.array(z.object({ message_id: identity, origin: z.string(), provenance: provenance.optional() })),
|
|
15
|
+
// Handed to the host model adapter, not proof of server receipt or understanding.
|
|
16
|
+
input_message_ids: z.array(identity), input_association: z.enum(['known', 'unknown']),
|
|
17
|
+
last_assistant_message_id: identity.nullable(),
|
|
18
|
+
status: z.enum(['completed', 'failed', 'cancelled', 'stopped', 'interrupted']).nullable(),
|
|
19
|
+
terminal_reason: z.string().nullable(),
|
|
20
|
+
}).superRefine((event, ctx) => {
|
|
21
|
+
const invalid = (message) => ctx.addIssue({ code: z.ZodIssueCode.custom, message });
|
|
22
|
+
if ((event.phase === 'terminal') !== (event.status !== null))
|
|
23
|
+
invalid('Only terminal events have a status');
|
|
24
|
+
if (event.phase !== 'terminal' && event.terminal_reason !== null)
|
|
25
|
+
invalid('Only terminal events have a terminal reason');
|
|
26
|
+
const accepted = event.accepted_inputs.map(input => input.message_id);
|
|
27
|
+
if (new Set(accepted).size !== accepted.length)
|
|
28
|
+
invalid('Duplicate accepted input');
|
|
29
|
+
if (new Set(event.input_message_ids).size !== event.input_message_ids.length)
|
|
30
|
+
invalid('Duplicate dispatched input');
|
|
31
|
+
if (event.input_message_ids.some(id => !accepted.includes(id)))
|
|
32
|
+
invalid('Dispatched input was not accepted');
|
|
33
|
+
if (event.phase === 'start' && (event.sequence !== 0 || event.attempt !== 0 || event.input_message_ids.length !== 0))
|
|
34
|
+
invalid('Invalid query start');
|
|
35
|
+
if (event.scope === 'subagent' && event.agent_id === null)
|
|
36
|
+
invalid('Subagent identity missing');
|
|
37
|
+
});
|
|
38
|
+
export const QueryLifecycleWriteSchema = z.union([
|
|
39
|
+
z.object({ state: z.literal('saved') }),
|
|
40
|
+
z.object({ state: z.literal('unavailable'), reason: z.enum(['persistence_disabled', 'no_transcript']) }),
|
|
41
|
+
z.object({ state: z.literal('failed'), reason: z.literal('write_failed') }),
|
|
42
|
+
z.object({ state: z.literal('unknown'), reason: z.literal('write_timeout') }),
|
|
43
|
+
]);
|
|
44
|
+
export const QueryLifecycleObservationSchema = z.object({
|
|
45
|
+
record: QueryLifecycleSchema, persistence: QueryLifecycleWriteSchema,
|
|
46
|
+
transcript_path: z.string().nullable(),
|
|
47
|
+
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
import type { PendingApproval } from './types.js';
|
|
3
|
+
import type { PendingApprovalIdentity } from './pendingApprovalIdentity.js';
|
|
4
|
+
export declare const occurrenceApprovalRequestSchema: z.ZodObject<{
|
|
5
|
+
occurrenceId: z.ZodString;
|
|
6
|
+
expectedRevision: z.ZodNumber;
|
|
7
|
+
requestId: z.ZodString;
|
|
8
|
+
toolUseId: z.ZodString;
|
|
9
|
+
actionId: z.ZodString;
|
|
10
|
+
decision: z.ZodEnum<{
|
|
11
|
+
allow: "allow";
|
|
12
|
+
deny: "deny";
|
|
13
|
+
}>;
|
|
14
|
+
message: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export type OccurrenceApprovalRequest = z.infer<typeof occurrenceApprovalRequestSchema>;
|
|
17
|
+
export type OccurrenceExecution = 'queued' | 'resuming' | 'running' | 'succeeded' | 'denied' | 'failed' | 'interrupted' | 'waiting_permission' | 'missed' | 'cancelled';
|
|
18
|
+
export type OccurrenceApprovalReceipt = {
|
|
19
|
+
request: OccurrenceApprovalRequest;
|
|
20
|
+
approval: PendingApprovalIdentity;
|
|
21
|
+
originalApproval: PendingApproval;
|
|
22
|
+
acceptedAt: number;
|
|
23
|
+
outcome: 'accepted' | 'running' | 'succeeded' | 'denied' | 'waiting_permission' | 'failed' | 'interrupted';
|
|
24
|
+
completedAt?: number;
|
|
25
|
+
resumedRequestId?: string;
|
|
26
|
+
resumedToolUseId?: string;
|
|
27
|
+
error?: string;
|
|
28
|
+
};
|
|
29
|
+
export type OccurrenceEvent = {
|
|
30
|
+
sequence: number;
|
|
31
|
+
at: number;
|
|
32
|
+
revision: number;
|
|
33
|
+
kind: OccurrenceExecution | 'resume_requested' | 'coalesced' | 'delivery_updated' | 'cancel_requested';
|
|
34
|
+
execution: OccurrenceExecution;
|
|
35
|
+
requestId?: string;
|
|
36
|
+
toolUseId?: string;
|
|
37
|
+
};
|
|
38
|
+
export type ScheduledOccurrence = {
|
|
39
|
+
id: string;
|
|
40
|
+
task: {
|
|
41
|
+
id: string;
|
|
42
|
+
createdAt: number;
|
|
43
|
+
prompt: string;
|
|
44
|
+
delegation?: {
|
|
45
|
+
revision: number;
|
|
46
|
+
sourceSessionId: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
scheduledAt: number;
|
|
50
|
+
acceptedAt: number;
|
|
51
|
+
revision: number;
|
|
52
|
+
execution: OccurrenceExecution;
|
|
53
|
+
delivery: 'pending' | 'delivered' | 'failed';
|
|
54
|
+
sessionId?: string;
|
|
55
|
+
result?: string;
|
|
56
|
+
error?: string;
|
|
57
|
+
deliveryError?: string;
|
|
58
|
+
skippedOccurrences?: number;
|
|
59
|
+
coalescedThrough?: number;
|
|
60
|
+
delegationRevision?: number;
|
|
61
|
+
pendingPermission?: {
|
|
62
|
+
revision: number;
|
|
63
|
+
approval: PendingApproval;
|
|
64
|
+
};
|
|
65
|
+
approvalRecoveryError?: string;
|
|
66
|
+
cancellation?: {
|
|
67
|
+
request: OccurrenceCancelRequest;
|
|
68
|
+
requestedAt: number;
|
|
69
|
+
};
|
|
70
|
+
approvalDecisions: OccurrenceApprovalReceipt[];
|
|
71
|
+
events: OccurrenceEvent[];
|
|
72
|
+
};
|
|
73
|
+
export type OccurrenceLookup = {
|
|
74
|
+
status: 'not_found';
|
|
75
|
+
ownerAvailable: boolean;
|
|
76
|
+
} | {
|
|
77
|
+
status: 'found';
|
|
78
|
+
snapshot: ScheduledOccurrence;
|
|
79
|
+
ownerAvailable: boolean;
|
|
80
|
+
};
|
|
81
|
+
export type OccurrenceEvents = {
|
|
82
|
+
events: OccurrenceEvent[];
|
|
83
|
+
nextSequence: number;
|
|
84
|
+
hasMore: boolean;
|
|
85
|
+
};
|
|
86
|
+
export declare const occurrenceSelectorSchema: z.ZodObject<{
|
|
87
|
+
occurrenceId: z.ZodString;
|
|
88
|
+
}, z.core.$strict>;
|
|
89
|
+
export declare const occurrenceListSchema: z.ZodObject<{
|
|
90
|
+
taskId: z.ZodOptional<z.ZodString>;
|
|
91
|
+
sourceSessionId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strict>;
|
|
93
|
+
export declare const occurrenceEventsSchema: z.ZodObject<{
|
|
94
|
+
occurrenceId: z.ZodString;
|
|
95
|
+
afterSequence: z.ZodOptional<z.ZodNumber>;
|
|
96
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
export declare const occurrenceCancelRequestSchema: z.ZodObject<{
|
|
99
|
+
occurrenceId: z.ZodString;
|
|
100
|
+
expectedRevision: z.ZodNumber;
|
|
101
|
+
actionId: z.ZodString;
|
|
102
|
+
}, z.core.$strict>;
|
|
103
|
+
export type OccurrenceCancelRequest = z.infer<typeof occurrenceCancelRequestSchema>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from 'zod/v4';
|
|
2
|
+
export const occurrenceApprovalRequestSchema = z.strictObject({
|
|
3
|
+
occurrenceId: z.string().regex(/^[a-f0-9]{64}$/),
|
|
4
|
+
expectedRevision: z.number().int().nonnegative(),
|
|
5
|
+
requestId: z.string().min(1), toolUseId: z.string().min(1),
|
|
6
|
+
actionId: z.string().min(1).max(200), decision: z.enum(['allow', 'deny']),
|
|
7
|
+
message: z.string().optional(),
|
|
8
|
+
});
|
|
9
|
+
export const occurrenceSelectorSchema = z.strictObject({ occurrenceId: z.string().regex(/^[a-f0-9]{64}$/) });
|
|
10
|
+
export const occurrenceListSchema = z.strictObject({ taskId: z.string().min(1).optional(), sourceSessionId: z.string().min(1).optional() });
|
|
11
|
+
export const occurrenceEventsSchema = occurrenceSelectorSchema.extend({ afterSequence: z.number().int().nonnegative().optional(), limit: z.number().int().min(1).max(1000).optional() });
|
|
12
|
+
export const occurrenceCancelRequestSchema = occurrenceSelectorSchema.extend({ expectedRevision: z.number().int().nonnegative(), actionId: z.string().min(1).max(200) });
|
package/dist/sdk/types.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export type CanUseToolResult = {
|
|
|
29
29
|
interaction?: import('./interactionResponseSchema.js').InteractionResponse;
|
|
30
30
|
/** Also interrupt the current turn instead of letting the agent continue. */
|
|
31
31
|
interrupt?: boolean;
|
|
32
|
+
/** Host control-channel provenance; not a human refusal or a new authorization. */
|
|
33
|
+
cancellation?: import('./cancellation.js').HostCancellation;
|
|
32
34
|
} | {
|
|
33
35
|
/**
|
|
34
36
|
* Suspend the session at this tool call (issue P0-2 pending): the tool
|
|
@@ -71,6 +73,10 @@ export type QueryOptions = {
|
|
|
71
73
|
* deny, the tool does not execute.
|
|
72
74
|
*/
|
|
73
75
|
canUseTool?: CanUseToolFn;
|
|
76
|
+
/** Default review preserves SDK host review of ambient allows; ask_only trusts local policy. */
|
|
77
|
+
permissionCallbackMode?: 'review' | 'ask_only';
|
|
78
|
+
/** Host-supplied task grants, applied before any input/resume. Never model-supplied. */
|
|
79
|
+
permissionDelegation?: import('./permissionDelegation.js').PermissionDelegation;
|
|
74
80
|
/**
|
|
75
81
|
* Milliseconds before an unresolved canUseTool callback is treated as a
|
|
76
82
|
* deny (fail-closed). Default 300_000. Pass 0 to disable the timeout
|
|
@@ -234,6 +240,7 @@ export type LifecycleHooks = {
|
|
|
234
240
|
toolName?: string;
|
|
235
241
|
content: unknown;
|
|
236
242
|
isError: boolean;
|
|
243
|
+
operationReference?: import('./operations/reference.js').OperationReference;
|
|
237
244
|
sessionId?: string;
|
|
238
245
|
}) => void | Promise<void>;
|
|
239
246
|
/**
|
|
@@ -261,16 +268,21 @@ export type PendingApproval = {
|
|
|
261
268
|
toolName: string;
|
|
262
269
|
input: Record<string, unknown>;
|
|
263
270
|
createdAt: string;
|
|
271
|
+
/** New suspension requests are resumable only after the CLI confirms durable preservation. */
|
|
272
|
+
suspension?: 'requested' | 'confirmed';
|
|
264
273
|
};
|
|
265
274
|
/** Host decision applied on resume for a recorded pending approval. */
|
|
266
275
|
export type PendingDecision = {
|
|
276
|
+
/** Bind a durable decision to the original approval and enforce matching before CLI tool execution. */
|
|
277
|
+
expectedApproval?: import('./pendingApprovalIdentity.js').PendingApprovalIdentity;
|
|
278
|
+
} & ({
|
|
267
279
|
behavior: 'allow';
|
|
268
|
-
/** Override the approved input;
|
|
280
|
+
/** Override the approved input in legacy mode; strict expectedApproval permits only identical input. */
|
|
269
281
|
updatedInput?: Record<string, unknown>;
|
|
270
282
|
} | {
|
|
271
283
|
behavior: 'deny';
|
|
272
284
|
message?: string;
|
|
273
|
-
};
|
|
285
|
+
});
|
|
274
286
|
export type AccumulatedUsage = {
|
|
275
287
|
queries: number;
|
|
276
288
|
inputTokens: number;
|
|
@@ -351,6 +363,10 @@ export type SessionLifecycleEvent = {
|
|
|
351
363
|
reason: string;
|
|
352
364
|
});
|
|
353
365
|
type SDKEventPayload = {
|
|
366
|
+
type: 'query_lifecycle';
|
|
367
|
+
lifecycle: import('./queryLifecycleTypes.js').QueryLifecycleObservation;
|
|
368
|
+
sessionId: string;
|
|
369
|
+
} | {
|
|
354
370
|
type: 'assistant_text';
|
|
355
371
|
text: string;
|
|
356
372
|
sessionId?: string;
|
|
@@ -373,6 +389,7 @@ type SDKEventPayload = {
|
|
|
373
389
|
toolUseId: string;
|
|
374
390
|
content: unknown;
|
|
375
391
|
isError: boolean;
|
|
392
|
+
operationReference?: import('./operations/reference.js').OperationReference;
|
|
376
393
|
sessionId?: string;
|
|
377
394
|
} | {
|
|
378
395
|
type: 'permission_request';
|
|
@@ -388,6 +405,7 @@ type SDKEventPayload = {
|
|
|
388
405
|
behavior: 'allow' | 'deny';
|
|
389
406
|
/** Why the SDK decided this way when the host callback did not decide. */
|
|
390
407
|
failClosedReason?: string;
|
|
408
|
+
cancellation?: import('./cancellation.js').HostCancellation;
|
|
391
409
|
interaction?: import('./interactionResponseSchema.js').InteractionResponse;
|
|
392
410
|
/** 'pending_decision' when resolved by resumeWithDecision, not the live callback. */
|
|
393
411
|
source?: 'callback' | 'pending_decision';
|
|
@@ -464,7 +482,7 @@ export type InitializationResult = {
|
|
|
464
482
|
* the stream is identical to the bare queryWithTransport generator.
|
|
465
483
|
*/
|
|
466
484
|
export interface Query extends AsyncGenerator<SDKEvent, void, unknown> {
|
|
467
|
-
interrupt(): Promise<unknown>;
|
|
485
|
+
interrupt(cancellation?: import('./cancellation.js').HostCancellation): Promise<unknown>;
|
|
468
486
|
setPermissionMode(mode: string): Promise<unknown>;
|
|
469
487
|
setModel(model?: string): Promise<unknown>;
|
|
470
488
|
setMaxThinkingTokens(n: number | null): Promise<unknown>;
|