@bobannomi/app-host 0.1.1 → 0.2.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/README.md +16 -11
- package/dist/index.d.ts +281 -166
- package/dist/index.js +317 -152
- package/dist/index.js.map +3 -3
- package/dist/protocol.d.ts +264 -317
- package/dist/protocol.js +201 -276
- package/dist/protocol.js.map +3 -3
- package/package.json +4 -9
- package/dist/node/service-host.d.ts +0 -1447
- package/dist/node/service-host.js +0 -1408
- package/dist/node/service-host.js.map +0 -6
|
@@ -1,1447 +0,0 @@
|
|
|
1
|
-
/** Public values only. No filesystem paths, service addresses or credentials belong here. */
|
|
2
|
-
type JsonValue = null | boolean | number | string | JsonValue[] | {
|
|
3
|
-
[key: string]: JsonValue;
|
|
4
|
-
};
|
|
5
|
-
declare const APP_HOST_ERROR_RETRY: {
|
|
6
|
-
readonly incompatible: "never";
|
|
7
|
-
readonly permission_denied: "never";
|
|
8
|
-
readonly origin_denied: "never";
|
|
9
|
-
readonly connection_revoked: "safe";
|
|
10
|
-
readonly storage_full: "never";
|
|
11
|
-
readonly invalid_request: "never";
|
|
12
|
-
readonly host_unavailable: "never";
|
|
13
|
-
readonly dependency_missing: "never";
|
|
14
|
-
readonly service_start_failed: "safe";
|
|
15
|
-
readonly service_unavailable: "safe";
|
|
16
|
-
readonly activity_conflict: "query";
|
|
17
|
-
readonly result_unknown: "query";
|
|
18
|
-
readonly resource_unavailable: "never";
|
|
19
|
-
readonly missing_source_evidence: "never";
|
|
20
|
-
readonly control_conflict: "query";
|
|
21
|
-
readonly configuration_changed: "query";
|
|
22
|
-
readonly root_changed: "never";
|
|
23
|
-
readonly resource_revision_conflict: "query";
|
|
24
|
-
readonly request_conflict: "never";
|
|
25
|
-
readonly cursor_stale: "query";
|
|
26
|
-
};
|
|
27
|
-
type AppHostErrorCode = keyof typeof APP_HOST_ERROR_RETRY;
|
|
28
|
-
type AppHostRetry = "safe" | "never" | "query";
|
|
29
|
-
interface AppHostErrorInfo {
|
|
30
|
-
code: AppHostErrorCode;
|
|
31
|
-
message: string;
|
|
32
|
-
retry?: AppHostRetry;
|
|
33
|
-
requestId?: string;
|
|
34
|
-
details?: JsonValue;
|
|
35
|
-
}
|
|
36
|
-
type ServiceWorkState = "not_accepted" | "accepted" | "running" | "completed" | "failed" | "interrupted" | "unknown";
|
|
37
|
-
|
|
38
|
-
interface ExecutionInstructions {
|
|
39
|
-
revision: number;
|
|
40
|
-
content: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface ServiceWork {
|
|
44
|
-
requestId: string;
|
|
45
|
-
state: ServiceWorkState;
|
|
46
|
-
updatedAt: string;
|
|
47
|
-
result?: JsonValue;
|
|
48
|
-
error?: JsonValue;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
type FetchDirection = "upload" | "download";
|
|
52
|
-
type PageFetchFrame = {
|
|
53
|
-
protocol: 2;
|
|
54
|
-
} & ({
|
|
55
|
-
type: "fetch-open";
|
|
56
|
-
id: string;
|
|
57
|
-
connectionId: string;
|
|
58
|
-
url: string;
|
|
59
|
-
method: string;
|
|
60
|
-
headers: [string, string][];
|
|
61
|
-
hasBody: boolean;
|
|
62
|
-
inlineBody?: string;
|
|
63
|
-
} | {
|
|
64
|
-
type: "fetch-headers";
|
|
65
|
-
id: string;
|
|
66
|
-
status: number;
|
|
67
|
-
statusText: string;
|
|
68
|
-
headers: [string, string][];
|
|
69
|
-
hasBody: boolean;
|
|
70
|
-
} | {
|
|
71
|
-
type: "fetch-credit";
|
|
72
|
-
id: string;
|
|
73
|
-
direction: FetchDirection;
|
|
74
|
-
sequence: number;
|
|
75
|
-
chunks: number;
|
|
76
|
-
bytes: number;
|
|
77
|
-
} | {
|
|
78
|
-
type: "fetch-chunk";
|
|
79
|
-
id: string;
|
|
80
|
-
direction: FetchDirection;
|
|
81
|
-
sequence: number;
|
|
82
|
-
bytes: Uint8Array;
|
|
83
|
-
} | {
|
|
84
|
-
type: "fetch-end";
|
|
85
|
-
id: string;
|
|
86
|
-
direction: FetchDirection;
|
|
87
|
-
sequence: number;
|
|
88
|
-
} | {
|
|
89
|
-
type: "fetch-consumed";
|
|
90
|
-
id: string;
|
|
91
|
-
direction: "download";
|
|
92
|
-
sequence: number;
|
|
93
|
-
} | {
|
|
94
|
-
type: "fetch-cancel";
|
|
95
|
-
id: string;
|
|
96
|
-
} | {
|
|
97
|
-
type: "fetch-error";
|
|
98
|
-
id: string;
|
|
99
|
-
error: AppHostErrorInfo;
|
|
100
|
-
} | {
|
|
101
|
-
type: "fetch-close";
|
|
102
|
-
connectionId: string;
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
interface ServiceContext {
|
|
106
|
-
protocolVersion: 1;
|
|
107
|
-
registrationId: string;
|
|
108
|
-
instanceId: string;
|
|
109
|
-
dataScopeId: string;
|
|
110
|
-
scope: {
|
|
111
|
-
appId: string;
|
|
112
|
-
installationId: string;
|
|
113
|
-
contentDigest: string;
|
|
114
|
-
};
|
|
115
|
-
installationRevision: number;
|
|
116
|
-
phase: "starting" | "ready";
|
|
117
|
-
}
|
|
118
|
-
interface ServiceInvocation {
|
|
119
|
-
invocationId: string;
|
|
120
|
-
dataScopeId: string;
|
|
121
|
-
sessionId: string;
|
|
122
|
-
runId: string;
|
|
123
|
-
inputId?: string;
|
|
124
|
-
workspaceId?: string;
|
|
125
|
-
executionRoot?: string;
|
|
126
|
-
privateSessionId?: string;
|
|
127
|
-
}
|
|
128
|
-
interface CreateWorktree {
|
|
129
|
-
requestId: string;
|
|
130
|
-
workspaceId: string;
|
|
131
|
-
expectedHead: string;
|
|
132
|
-
branch: string;
|
|
133
|
-
}
|
|
134
|
-
interface WorktreeQuery {
|
|
135
|
-
requestId: string;
|
|
136
|
-
original: Omit<CreateWorktree, "requestId">;
|
|
137
|
-
}
|
|
138
|
-
interface WorktreeReceipt {
|
|
139
|
-
requestId: string;
|
|
140
|
-
state: "accepted" | "completed" | "failed" | "unknown";
|
|
141
|
-
result?: {
|
|
142
|
-
executionRoot: string;
|
|
143
|
-
workspaceId: string;
|
|
144
|
-
branch: string;
|
|
145
|
-
sourceHead: string;
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
interface RootReleaseReceipt {
|
|
149
|
-
requestId: string;
|
|
150
|
-
executionRoot: string;
|
|
151
|
-
state: "released" | "retained-dirty" | "in-use" | "unknown";
|
|
152
|
-
}
|
|
153
|
-
interface GitStatus {
|
|
154
|
-
root: string;
|
|
155
|
-
commonDir: string;
|
|
156
|
-
head: string;
|
|
157
|
-
branch: string;
|
|
158
|
-
changes: string[];
|
|
159
|
-
}
|
|
160
|
-
type Entry<P, R> = {
|
|
161
|
-
params: P;
|
|
162
|
-
result: R;
|
|
163
|
-
};
|
|
164
|
-
interface ServiceHostMethodMap {
|
|
165
|
-
"secrets.get": Entry<{
|
|
166
|
-
key: string;
|
|
167
|
-
}, string | null>;
|
|
168
|
-
"secrets.set": Entry<{
|
|
169
|
-
key: string;
|
|
170
|
-
value: string;
|
|
171
|
-
}, {
|
|
172
|
-
stored: true;
|
|
173
|
-
}>;
|
|
174
|
-
"secrets.delete": Entry<{
|
|
175
|
-
key: string;
|
|
176
|
-
}, {
|
|
177
|
-
deleted: true;
|
|
178
|
-
}>;
|
|
179
|
-
"context.get": Entry<Record<string, never>, ServiceContext>;
|
|
180
|
-
"context.resolveInvocation": Entry<{
|
|
181
|
-
ticket: string;
|
|
182
|
-
}, ServiceInvocation>;
|
|
183
|
-
"agent.listModels": Entry<Record<string, never>, {
|
|
184
|
-
id: string;
|
|
185
|
-
name: string;
|
|
186
|
-
}[]>;
|
|
187
|
-
"agent.getConnection": Entry<{
|
|
188
|
-
workspaceId?: string;
|
|
189
|
-
executionRoot?: string;
|
|
190
|
-
privateSessionId?: string;
|
|
191
|
-
}, {
|
|
192
|
-
connectionId: string;
|
|
193
|
-
baseUrl: string;
|
|
194
|
-
}>;
|
|
195
|
-
"agent.resolveSkills": Entry<{
|
|
196
|
-
skillIds: string[];
|
|
197
|
-
}, {
|
|
198
|
-
type: "skill";
|
|
199
|
-
name: string;
|
|
200
|
-
path: string;
|
|
201
|
-
}[]>;
|
|
202
|
-
"sessions.getConnection": Entry<{
|
|
203
|
-
dataScopeId: string;
|
|
204
|
-
sessionId: string;
|
|
205
|
-
}, {
|
|
206
|
-
connectionId: string;
|
|
207
|
-
baseUrl: string;
|
|
208
|
-
}>;
|
|
209
|
-
"workspace.gitStatus": Entry<{
|
|
210
|
-
workspaceId: string;
|
|
211
|
-
}, GitStatus>;
|
|
212
|
-
"workspace.createTaskWorktree": Entry<CreateWorktree, WorktreeReceipt>;
|
|
213
|
-
"workspace.getWorktree": Entry<WorktreeQuery, WorktreeReceipt | null>;
|
|
214
|
-
"workspace.releaseExecutionRoot": Entry<{
|
|
215
|
-
requestId: string;
|
|
216
|
-
workspaceId: string;
|
|
217
|
-
executionRoot: string;
|
|
218
|
-
}, RootReleaseReceipt>;
|
|
219
|
-
"work.list": Entry<Record<string, never>, ServiceWork[]>;
|
|
220
|
-
"work.get": Entry<{
|
|
221
|
-
requestId: string;
|
|
222
|
-
}, ServiceWork | null>;
|
|
223
|
-
}
|
|
224
|
-
type ServiceHostMethod = keyof ServiceHostMethodMap;
|
|
225
|
-
declare const SERVICE_HOST_METHODS: readonly ["secrets.get", "secrets.set", "secrets.delete", "context.get", "context.resolveInvocation", "agent.listModels", "agent.getConnection", "agent.resolveSkills", "sessions.getConnection", "workspace.gitStatus", "workspace.createTaskWorktree", "workspace.getWorktree", "workspace.releaseExecutionRoot", "work.list", "work.get"];
|
|
226
|
-
declare const SERVICE_HOST_MAX_FRAME_BYTES: number;
|
|
227
|
-
declare const SERVICE_HOST_MAX_PENDING = 64;
|
|
228
|
-
declare const validServiceContext: (v: unknown) => v is ServiceContext;
|
|
229
|
-
declare function validServiceHostInput(method: ServiceHostMethod, v: unknown): boolean;
|
|
230
|
-
declare function validServiceHostResult(method: ServiceHostMethod, v: unknown): boolean;
|
|
231
|
-
type ServiceHostFrame = PageFetchFrame | {
|
|
232
|
-
protocol: 1;
|
|
233
|
-
type: "service-host-connect";
|
|
234
|
-
id: string;
|
|
235
|
-
} | {
|
|
236
|
-
protocol: 1;
|
|
237
|
-
type: "service-host-ready";
|
|
238
|
-
id: string;
|
|
239
|
-
context: ServiceContext;
|
|
240
|
-
} | {
|
|
241
|
-
protocol: 1;
|
|
242
|
-
type: "service-host-context";
|
|
243
|
-
context: ServiceContext;
|
|
244
|
-
} | {
|
|
245
|
-
protocol: 1;
|
|
246
|
-
type: "service-host-request";
|
|
247
|
-
id: string;
|
|
248
|
-
method: ServiceHostMethod;
|
|
249
|
-
params: ServiceHostMethodMap[ServiceHostMethod]["params"];
|
|
250
|
-
} | ({
|
|
251
|
-
protocol: 1;
|
|
252
|
-
type: "service-host-response";
|
|
253
|
-
id: string;
|
|
254
|
-
} & ({
|
|
255
|
-
ok: true;
|
|
256
|
-
value: unknown;
|
|
257
|
-
} | {
|
|
258
|
-
ok: false;
|
|
259
|
-
error: AppHostErrorInfo;
|
|
260
|
-
})) | {
|
|
261
|
-
protocol: 1;
|
|
262
|
-
type: "service-host-close";
|
|
263
|
-
};
|
|
264
|
-
declare function isServiceHostFrame(v: unknown): v is ServiceHostFrame;
|
|
265
|
-
|
|
266
|
-
/** How an agent explains findings and delivers results, independently of update timing. */
|
|
267
|
-
type ReplyStyle = "collaborative" | "direct" | "explanatory";
|
|
268
|
-
|
|
269
|
-
/** User-facing authorization presets, independent from read-only planning. */
|
|
270
|
-
type ApprovalMode = "ask" | "auto_review" | "full_access";
|
|
271
|
-
type WorkMode = "execute" | "plan";
|
|
272
|
-
type PermissionMode = "default" | "plan" | "full_auto" | ApprovalMode;
|
|
273
|
-
/** Ordered user inputs already written to the model history of one Run. */
|
|
274
|
-
interface AppliedInputStateSnapshot {
|
|
275
|
-
revision: number;
|
|
276
|
-
inputIds: readonly string[];
|
|
277
|
-
}
|
|
278
|
-
interface AgentPermissionRequest {
|
|
279
|
-
toolName: string;
|
|
280
|
-
/** Captured from the actual tool registration by the execution pipeline. */
|
|
281
|
-
confirmationMode?: "manual" | "client";
|
|
282
|
-
/** Host-scoped concrete operation; never reuse or create a tool-wide session grant. */
|
|
283
|
-
confirmation?: "once";
|
|
284
|
-
/** Captured host registration; never supplied by the model. */
|
|
285
|
-
toolSource?: string;
|
|
286
|
-
toolDescription?: string;
|
|
287
|
-
reason?: string;
|
|
288
|
-
input?: Record<string, unknown>;
|
|
289
|
-
}
|
|
290
|
-
interface AgentPermissionDecision {
|
|
291
|
-
status: "approved" | "denied" | "expired";
|
|
292
|
-
decision?: "once" | "session";
|
|
293
|
-
reason?: string;
|
|
294
|
-
answer?: string;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
interface ControlOption {
|
|
298
|
-
id: string;
|
|
299
|
-
name: string;
|
|
300
|
-
}
|
|
301
|
-
type SessionControlAction = "readContext" | "configure" | "compact" | "edit" | "fork" | "resume" | "goalRead" | "goalWrite" | "goalStop";
|
|
302
|
-
interface SessionControls {
|
|
303
|
-
dataScopeId: string;
|
|
304
|
-
sessionId: string;
|
|
305
|
-
source: "instance" | "auxiliary" | "im";
|
|
306
|
-
revision: number;
|
|
307
|
-
optionsRevision: string;
|
|
308
|
-
actions: Record<SessionControlAction, boolean>;
|
|
309
|
-
models: ControlOption[];
|
|
310
|
-
roles: ControlOption[];
|
|
311
|
-
efforts: ControlOption[];
|
|
312
|
-
workModes: ControlOption[];
|
|
313
|
-
permissionModes?: ControlOption[];
|
|
314
|
-
appServiceBindings?: ControlOption[];
|
|
315
|
-
skills: (ControlOption & {
|
|
316
|
-
path: string;
|
|
317
|
-
source?: string;
|
|
318
|
-
})[];
|
|
319
|
-
commands: ControlOption[];
|
|
320
|
-
contexts: ControlOption[];
|
|
321
|
-
plugins?: (ControlOption & {
|
|
322
|
-
agents: ControlOption[];
|
|
323
|
-
})[];
|
|
324
|
-
}
|
|
325
|
-
type SessionControlOriginal = {
|
|
326
|
-
action: "compact";
|
|
327
|
-
body: {
|
|
328
|
-
requestId: string;
|
|
329
|
-
expectedRevision: number;
|
|
330
|
-
};
|
|
331
|
-
} | {
|
|
332
|
-
action: "fork";
|
|
333
|
-
body: {
|
|
334
|
-
requestId: string;
|
|
335
|
-
id: string;
|
|
336
|
-
copyHistory?: boolean;
|
|
337
|
-
beforeMessageId?: string;
|
|
338
|
-
afterMessageId?: string;
|
|
339
|
-
storage?: "sqlite";
|
|
340
|
-
};
|
|
341
|
-
};
|
|
342
|
-
interface SessionControlReceipt {
|
|
343
|
-
dataScopeId: string;
|
|
344
|
-
sessionId: string;
|
|
345
|
-
requestId: string;
|
|
346
|
-
action: SessionControlOriginal["action"] | "configure";
|
|
347
|
-
state: "prepared" | "created" | "completed" | "unknown";
|
|
348
|
-
revision?: number;
|
|
349
|
-
targetSessionId?: string;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
interface AppAgentModel {
|
|
353
|
-
id: string;
|
|
354
|
-
name: string;
|
|
355
|
-
reasoning?: boolean;
|
|
356
|
-
reasoningEfforts?: string[];
|
|
357
|
-
vision?: boolean;
|
|
358
|
-
contextWindow?: number;
|
|
359
|
-
outputLimit?: number;
|
|
360
|
-
inputModalities?: string[];
|
|
361
|
-
toolCalling?: boolean;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
interface AgentConnection {
|
|
365
|
-
/** Optional location hint. Execution always uses the Session/Run's persisted root. */
|
|
366
|
-
readonly cwd?: string;
|
|
367
|
-
readonly defaultTaskLocation?: "current" | "worktree";
|
|
368
|
-
readonly clientOptions: {
|
|
369
|
-
readonly baseUrl: string;
|
|
370
|
-
readonly fetch: typeof fetch;
|
|
371
|
-
};
|
|
372
|
-
/** True once this target or its document transport has closed. */
|
|
373
|
-
isClosed?(): boolean;
|
|
374
|
-
close(): void;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
interface AppHostAgent {
|
|
378
|
-
getConnection(input?: {
|
|
379
|
-
workspaceId?: string;
|
|
380
|
-
executionRoot?: string;
|
|
381
|
-
privateSessionId?: string;
|
|
382
|
-
}): Promise<AgentConnection>;
|
|
383
|
-
listModels(): Promise<AppAgentModel[]>;
|
|
384
|
-
resolveSkills(skillIds: string[]): Promise<{
|
|
385
|
-
type: "skill";
|
|
386
|
-
name: string;
|
|
387
|
-
path: string;
|
|
388
|
-
}[]>;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
interface TextBlock {
|
|
392
|
-
type: "text";
|
|
393
|
-
text: string;
|
|
394
|
-
}
|
|
395
|
-
interface ImageBlock {
|
|
396
|
-
type: "image";
|
|
397
|
-
source: ImageSource;
|
|
398
|
-
}
|
|
399
|
-
interface ImageSource {
|
|
400
|
-
type: "file";
|
|
401
|
-
mediaType: string;
|
|
402
|
-
path: string;
|
|
403
|
-
sizeBytes?: number;
|
|
404
|
-
prepared?: VisionImagePreparationMetadata;
|
|
405
|
-
}
|
|
406
|
-
interface VisionImagePreparationMetadata {
|
|
407
|
-
mediaType: string;
|
|
408
|
-
width: number;
|
|
409
|
-
height: number;
|
|
410
|
-
base64Bytes: number;
|
|
411
|
-
policyVersion: string;
|
|
412
|
-
}
|
|
413
|
-
type ContentBlock = TextBlock | ImageBlock;
|
|
414
|
-
/** Opaque handle into an authorized result store; never a filesystem path. */
|
|
415
|
-
interface ToolResultRef {
|
|
416
|
-
id: string;
|
|
417
|
-
toolName: string;
|
|
418
|
-
totalChars: number;
|
|
419
|
-
}
|
|
420
|
-
interface ToolResultPage {
|
|
421
|
-
ref: ToolResultRef;
|
|
422
|
-
text: string;
|
|
423
|
-
offset: number;
|
|
424
|
-
nextOffset?: number;
|
|
425
|
-
}
|
|
426
|
-
interface ToolResultSearch {
|
|
427
|
-
ref: ToolResultRef;
|
|
428
|
-
matches: Array<{
|
|
429
|
-
offset: number;
|
|
430
|
-
text: string;
|
|
431
|
-
}>;
|
|
432
|
-
nextOffset?: number;
|
|
433
|
-
}
|
|
434
|
-
interface ToolResultList {
|
|
435
|
-
items: ToolResultRef[];
|
|
436
|
-
nextOffset?: number;
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
interface ToolResult {
|
|
440
|
-
/** Checked builtin proof; free tool text/metadata cannot establish visible project rules. */
|
|
441
|
-
hostProjectInstructionKeys?: string[];
|
|
442
|
-
/** Added by the trusted result archive after preserving the original output. */
|
|
443
|
-
resultRef?: ToolResultRef;
|
|
444
|
-
content: ContentBlock[];
|
|
445
|
-
/** Original bounded MCP response; private to the authorized application host. */
|
|
446
|
-
mcpResult?: McpCallResultData;
|
|
447
|
-
isError?: boolean;
|
|
448
|
-
failureKind?: ToolFailureKind;
|
|
449
|
-
executionState?: ToolExecutionState;
|
|
450
|
-
recoveryHint?: string;
|
|
451
|
-
/** Controlled builtin/host summary, at most 1,000 characters; never an instruction. */
|
|
452
|
-
compactSummary?: string;
|
|
453
|
-
/** Set only by checked execution after verifying the captured builtin definition. */
|
|
454
|
-
hostFileFacts?: HostFileFacts;
|
|
455
|
-
metadata?: Record<string, unknown>;
|
|
456
|
-
}
|
|
457
|
-
/** File observations emitted by a captured builtin; free metadata is not a trust boundary. */
|
|
458
|
-
interface HostFileFacts {
|
|
459
|
-
environmentKey: string;
|
|
460
|
-
executionRoot?: string;
|
|
461
|
-
pathStyle?: "windows" | "posix";
|
|
462
|
-
files: Array<{
|
|
463
|
-
path: string;
|
|
464
|
-
subjectKey: string;
|
|
465
|
-
operation: "read" | "write" | "edit" | "patch";
|
|
466
|
-
beforeDigest?: "missing" | `sha256:${string}`;
|
|
467
|
-
afterDigest: "missing" | `sha256:${string}`;
|
|
468
|
-
completed: true;
|
|
469
|
-
bodyVisible?: boolean;
|
|
470
|
-
}>;
|
|
471
|
-
}
|
|
472
|
-
interface ToolExecutionResult extends ToolResult {
|
|
473
|
-
toolUseId: string;
|
|
474
|
-
toolName: string;
|
|
475
|
-
toolAttemptId?: string;
|
|
476
|
-
}
|
|
477
|
-
/** A definite result does not imply success or completion of the user's goal. */
|
|
478
|
-
type ToolExecutionState = "not_started" | "completed" | "unknown";
|
|
479
|
-
type ToolFailureKind = "permission" | "policy" | "timeout" | "command" | "transport" | "provider" | "interrupted" | "unknown_outcome" | "invalid_input" | "precondition" | "authentication" | "configuration";
|
|
480
|
-
/** JSON transported to an application; no runtime objects or host execution facts. */
|
|
481
|
-
type McpJsonValue = null | boolean | number | string | McpJsonValue[] | McpJsonObject;
|
|
482
|
-
interface McpJsonObject {
|
|
483
|
-
[key: string]: McpJsonValue;
|
|
484
|
-
}
|
|
485
|
-
interface McpCallResultData {
|
|
486
|
-
content: McpJsonObject[];
|
|
487
|
-
structuredContent?: McpJsonObject;
|
|
488
|
-
_meta?: McpJsonObject;
|
|
489
|
-
isError?: boolean;
|
|
490
|
-
[key: string]: McpJsonValue | undefined;
|
|
491
|
-
}
|
|
492
|
-
interface McpToolUiMetadata {
|
|
493
|
-
resourceUri?: string;
|
|
494
|
-
visibility: Array<"model" | "app">;
|
|
495
|
-
}
|
|
496
|
-
interface McpToolAnnotations {
|
|
497
|
-
title?: string;
|
|
498
|
-
readOnlyHint?: boolean;
|
|
499
|
-
destructiveHint?: boolean;
|
|
500
|
-
idempotentHint?: boolean;
|
|
501
|
-
openWorldHint?: boolean;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/** Capability already bound by the host to one Run and its current authorization. */
|
|
505
|
-
interface RunToolResultStore {
|
|
506
|
-
retain(result: ToolExecutionResult, source?: {
|
|
507
|
-
kind: string;
|
|
508
|
-
id?: string;
|
|
509
|
-
}): Promise<ToolResultRef>;
|
|
510
|
-
list(input?: {
|
|
511
|
-
offset?: number;
|
|
512
|
-
limit?: number;
|
|
513
|
-
}): Promise<ToolResultList>;
|
|
514
|
-
read(input: {
|
|
515
|
-
id: string;
|
|
516
|
-
offset?: number;
|
|
517
|
-
limit?: number;
|
|
518
|
-
}): Promise<ToolResultPage>;
|
|
519
|
-
search(input: {
|
|
520
|
-
id: string;
|
|
521
|
-
query: string;
|
|
522
|
-
offset?: number;
|
|
523
|
-
limit?: number;
|
|
524
|
-
}): Promise<ToolResultSearch>;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
/** Agent-reported progress; format validity alone does not prove completion. */
|
|
528
|
-
interface StructuredDelivery {
|
|
529
|
-
status: "done" | "partial" | "blocked" | "waiting";
|
|
530
|
-
summary: string;
|
|
531
|
-
data: unknown;
|
|
532
|
-
}
|
|
533
|
-
interface DeliveryReceipt extends StructuredDelivery {
|
|
534
|
-
validation: "schema_valid";
|
|
535
|
-
verification: "not_requested" | "passed";
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/** Trusted non-completion sources; never inferred from free-form error text. */
|
|
539
|
-
type ChildFailureKind = "max_turns" | "timeout" | "user_cancelled" | "parent_interrupted" | "model_error" | "tool_error" | "unknown";
|
|
540
|
-
/** Durable, length-bounded evidence of unfinished child work. */
|
|
541
|
-
interface ChildPartialResult {
|
|
542
|
-
version: 1;
|
|
543
|
-
childSessionId: string;
|
|
544
|
-
runId: string;
|
|
545
|
-
source: "committed_assistant_text" | "limit_finalization";
|
|
546
|
-
text: string;
|
|
547
|
-
truncated: boolean;
|
|
548
|
-
}
|
|
549
|
-
interface AgentChildResult {
|
|
550
|
-
delivery?: DeliveryReceipt;
|
|
551
|
-
status: "completed" | "failed" | "interrupted" | "stopped";
|
|
552
|
-
output: string;
|
|
553
|
-
error?: string;
|
|
554
|
-
failureKind?: ChildFailureKind;
|
|
555
|
-
partialResult?: ChildPartialResult;
|
|
556
|
-
}
|
|
557
|
-
interface AgentChildSpawnInput {
|
|
558
|
-
description: string;
|
|
559
|
-
prompt: string;
|
|
560
|
-
agent: string;
|
|
561
|
-
team?: string;
|
|
562
|
-
cwd: string;
|
|
563
|
-
sessionId?: string;
|
|
564
|
-
model?: string;
|
|
565
|
-
systemPrompt?: string;
|
|
566
|
-
/** Explicit child reply preference; omitted means inherit the parent's current preference. */
|
|
567
|
-
replyStyle?: ReplyStyle;
|
|
568
|
-
permissionMode?: "default" | "plan" | "full_auto";
|
|
569
|
-
/** Host-derived constrained modes for durable child projection; never caller authorization. */
|
|
570
|
-
approvalMode?: ApprovalMode;
|
|
571
|
-
workMode?: WorkMode;
|
|
572
|
-
allowedTools?: string[];
|
|
573
|
-
requiredMcpServers?: string[];
|
|
574
|
-
disallowedTools?: string[];
|
|
575
|
-
maxTurns?: number;
|
|
576
|
-
/** Caller-requested turn cap. At most it tightens the resolved role/configuration budget. */
|
|
577
|
-
requestedMaxTurns?: number;
|
|
578
|
-
timeoutSeconds?: number;
|
|
579
|
-
/** Caller-requested wall-clock cap. At most it tightens the resolved role budget. */
|
|
580
|
-
requestedTimeoutSeconds?: number;
|
|
581
|
-
/** Task boundary the child owns. Task context only, never a permission or path allowlist. */
|
|
582
|
-
scope?: string;
|
|
583
|
-
/** Deliverable the parent expects back. Task context only, never a permission or path allowlist. */
|
|
584
|
-
expectedResult?: string;
|
|
585
|
-
effort?: string;
|
|
586
|
-
isolate?: boolean;
|
|
587
|
-
metadata?: Record<string, unknown>;
|
|
588
|
-
}
|
|
589
|
-
interface AgentChildInput {
|
|
590
|
-
content: string;
|
|
591
|
-
/** Original host input, carried unchanged for durable projection, never parsed by the runtime. */
|
|
592
|
-
inputItems?: readonly unknown[];
|
|
593
|
-
id?: string;
|
|
594
|
-
delivery?: "queue" | "steer";
|
|
595
|
-
traceId?: string;
|
|
596
|
-
metadata?: Record<string, unknown>;
|
|
597
|
-
}
|
|
598
|
-
interface AgentInputReceipt {
|
|
599
|
-
sessionId: string;
|
|
600
|
-
inputId: string;
|
|
601
|
-
runId: string;
|
|
602
|
-
}
|
|
603
|
-
interface AgentChildInvocation {
|
|
604
|
-
id: string;
|
|
605
|
-
sessionId: string;
|
|
606
|
-
inputId: string;
|
|
607
|
-
runId: string;
|
|
608
|
-
result: Promise<AgentChildResult>;
|
|
609
|
-
worktree?: {
|
|
610
|
-
path: string;
|
|
611
|
-
branch: string;
|
|
612
|
-
};
|
|
613
|
-
notice?: string;
|
|
614
|
-
}
|
|
615
|
-
interface AgentChildController {
|
|
616
|
-
hasChildAgent(invocationId: string): boolean;
|
|
617
|
-
spawnChildAgent(input: AgentChildSpawnInput): Promise<AgentChildInvocation>;
|
|
618
|
-
sendChildInput(invocationId: string, input: AgentChildInput): Promise<AgentInputReceipt>;
|
|
619
|
-
interruptChildAgent(invocationId: string, reason?: string): Promise<void>;
|
|
620
|
-
awaitChildAgent(invocationId: string): Promise<AgentChildResult>;
|
|
621
|
-
}
|
|
622
|
-
interface AgentRunScope {
|
|
623
|
-
agentId: string;
|
|
624
|
-
sessionId: string;
|
|
625
|
-
runId: string;
|
|
626
|
-
/** Host MCP actions can have a real Run without a user Input. */
|
|
627
|
-
inputId?: string;
|
|
628
|
-
cwd: string;
|
|
629
|
-
traceId: string;
|
|
630
|
-
signal: AbortSignal;
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
interface ModelTokenMetering {
|
|
634
|
-
knownInputTokens: number;
|
|
635
|
-
knownOutputTokens: number;
|
|
636
|
-
completeness: "complete" | "partial" | "unknown";
|
|
637
|
-
inputIncludesCache: boolean;
|
|
638
|
-
/** Original usage fields only; never prompts, credentials, or response text. */
|
|
639
|
-
raw: Record<string, unknown>;
|
|
640
|
-
}
|
|
641
|
-
interface UsageSnapshot {
|
|
642
|
-
metering?: ModelTokenMetering;
|
|
643
|
-
inputTokens: number;
|
|
644
|
-
outputTokens: number;
|
|
645
|
-
cacheCreationTokens?: number;
|
|
646
|
-
cacheReadTokens?: number;
|
|
647
|
-
costUsd?: number;
|
|
648
|
-
/**
|
|
649
|
-
* 数字只是「已知小计」,部分请求的用量未知或因失败丢失。
|
|
650
|
-
* 未知请求不能被填成 0,也不能因为后续成功而清除该标记。
|
|
651
|
-
*/
|
|
652
|
-
usageIncomplete?: boolean;
|
|
653
|
-
}
|
|
654
|
-
|
|
655
|
-
type AssistantMessagePhase = "commentary" | "final_answer";
|
|
656
|
-
interface ToolUseBlock {
|
|
657
|
-
type: "tool_use";
|
|
658
|
-
id: string;
|
|
659
|
-
name: string;
|
|
660
|
-
input: Record<string, unknown>;
|
|
661
|
-
/** Unparsed input uses an empty placeholder and must never reach tool execution. */
|
|
662
|
-
inputError?: {
|
|
663
|
-
reason: "invalid_json" | "invalid_shape";
|
|
664
|
-
/** Character count, not a copy of potentially sensitive file content. */
|
|
665
|
-
argumentLength: number;
|
|
666
|
-
position?: number;
|
|
667
|
-
stopReason?: string;
|
|
668
|
-
};
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* 模型调用失败类别。用于决定是否重试以及向后端/界面报告的诊断信息。
|
|
673
|
-
* 这里是纯数据描述,不依赖 API 包,避免 core 反向依赖具体提供商实现。
|
|
674
|
-
*/
|
|
675
|
-
type ModelFailureKind = "network" | "timeout" | "rate_limit" | "server" | "stream_incomplete" | "authentication" | "invalid_request" | "quota" | "protocol" | "unknown";
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* 一次「模型调用」的稳定标识。重试同一次生成时 generationId 保持不变、
|
|
679
|
-
* attempt 递增;新的正常模型回合使用新的 generationId。
|
|
680
|
-
*/
|
|
681
|
-
interface GenerationIdentity {
|
|
682
|
-
generationId: string;
|
|
683
|
-
/** 从 1 开始;首次请求为 1。 */
|
|
684
|
-
attempt: number;
|
|
685
|
-
}
|
|
686
|
-
/**
|
|
687
|
-
* 引擎在等待下一次重试前发布的状态。`nextRetryAt` 与 `recoveryDeadlineAt`
|
|
688
|
-
* 都是绝对毫秒时间戳。
|
|
689
|
-
*/
|
|
690
|
-
interface ModelRetryState extends GenerationIdentity {
|
|
691
|
-
/** 下一次重试是第几次,从 1 开始。 */
|
|
692
|
-
retryNumber: number;
|
|
693
|
-
/** 本次生成允许的总重试上限。 */
|
|
694
|
-
maxRetries: number;
|
|
695
|
-
reason: ModelFailureKind;
|
|
696
|
-
nextRetryAt: number;
|
|
697
|
-
recoveryDeadlineAt: number;
|
|
698
|
-
}
|
|
699
|
-
/** 未知尝试计入用量时的完整性快照类型,供引擎与持久层共享。 */
|
|
700
|
-
type ModelAttemptUsageStatus = "complete" | "partial" | "unknown";
|
|
701
|
-
interface ModelAttemptStarted extends GenerationIdentity {
|
|
702
|
-
model: string;
|
|
703
|
-
provider?: string;
|
|
704
|
-
purpose: "generation" | "compaction" | "finalization" | "memory" | "plugin_selection";
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
type ReasoningSource = "reasoning_content" | "think";
|
|
708
|
-
interface AgentSerializedError {
|
|
709
|
-
name: string;
|
|
710
|
-
message: string;
|
|
711
|
-
code?: string;
|
|
712
|
-
stack?: string;
|
|
713
|
-
}
|
|
714
|
-
type AgentEventInput = {
|
|
715
|
-
type: "input.applied";
|
|
716
|
-
data: {
|
|
717
|
-
inputIds: string[];
|
|
718
|
-
revision: number;
|
|
719
|
-
};
|
|
720
|
-
} | {
|
|
721
|
-
type: "input.accepted";
|
|
722
|
-
data: {
|
|
723
|
-
content: string | ContentBlock[];
|
|
724
|
-
inputItems?: readonly unknown[];
|
|
725
|
-
delivery: "queue" | "steer";
|
|
726
|
-
metadata?: Record<string, unknown>;
|
|
727
|
-
};
|
|
728
|
-
} | {
|
|
729
|
-
type: "run.started";
|
|
730
|
-
data: {
|
|
731
|
-
tracksAppliedInputs?: true;
|
|
732
|
-
};
|
|
733
|
-
} | {
|
|
734
|
-
type: "run.completed";
|
|
735
|
-
data: {
|
|
736
|
-
output: string;
|
|
737
|
-
stopReason?: string;
|
|
738
|
-
delivery?: DeliveryReceipt;
|
|
739
|
-
};
|
|
740
|
-
} | {
|
|
741
|
-
type: "run.failed";
|
|
742
|
-
data: {
|
|
743
|
-
error: AgentSerializedError;
|
|
744
|
-
output?: string;
|
|
745
|
-
failureKind?: ChildFailureKind;
|
|
746
|
-
partialResult?: ChildPartialResult;
|
|
747
|
-
};
|
|
748
|
-
} | {
|
|
749
|
-
type: "run.interrupted";
|
|
750
|
-
data: {
|
|
751
|
-
error: AgentSerializedError;
|
|
752
|
-
output?: string;
|
|
753
|
-
failureKind?: ChildFailureKind;
|
|
754
|
-
partialResult?: ChildPartialResult;
|
|
755
|
-
};
|
|
756
|
-
} | {
|
|
757
|
-
type: "output.text.delta";
|
|
758
|
-
data: {
|
|
759
|
-
delta: string;
|
|
760
|
-
phase?: AssistantMessagePhase;
|
|
761
|
-
};
|
|
762
|
-
} | {
|
|
763
|
-
type: "output.reasoning.delta";
|
|
764
|
-
data: {
|
|
765
|
-
delta: string;
|
|
766
|
-
source: ReasoningSource;
|
|
767
|
-
};
|
|
768
|
-
} | {
|
|
769
|
-
type: "output.turn.completed";
|
|
770
|
-
data: {
|
|
771
|
-
stopReason: string;
|
|
772
|
-
};
|
|
773
|
-
} | {
|
|
774
|
-
type: "tool.started";
|
|
775
|
-
data: {
|
|
776
|
-
toolUse: {
|
|
777
|
-
type: "tool_use";
|
|
778
|
-
id: string;
|
|
779
|
-
name: string;
|
|
780
|
-
input: Record<string, unknown>;
|
|
781
|
-
};
|
|
782
|
-
};
|
|
783
|
-
} | {
|
|
784
|
-
type: "tool.completed";
|
|
785
|
-
data: {
|
|
786
|
-
toolUseId: string;
|
|
787
|
-
result: {
|
|
788
|
-
content: ContentBlock[];
|
|
789
|
-
isError?: boolean;
|
|
790
|
-
failureKind?: ToolFailureKind;
|
|
791
|
-
executionState?: ToolExecutionState;
|
|
792
|
-
recoveryHint?: string;
|
|
793
|
-
compactSummary?: string;
|
|
794
|
-
metadata?: Record<string, unknown>;
|
|
795
|
-
toolAttemptId?: string;
|
|
796
|
-
};
|
|
797
|
-
};
|
|
798
|
-
} | {
|
|
799
|
-
type: "usage.updated";
|
|
800
|
-
data: {
|
|
801
|
-
usage: UsageSnapshot;
|
|
802
|
-
};
|
|
803
|
-
} | {
|
|
804
|
-
type: "output.generation.started";
|
|
805
|
-
data: GenerationIdentity;
|
|
806
|
-
} | {
|
|
807
|
-
type: "model.retry.scheduled";
|
|
808
|
-
data: ModelRetryState;
|
|
809
|
-
} | {
|
|
810
|
-
type: "model.attempt.started";
|
|
811
|
-
data: ModelAttemptStarted;
|
|
812
|
-
} | {
|
|
813
|
-
type: "model.attempt.finished";
|
|
814
|
-
data: GenerationIdentity & {
|
|
815
|
-
status: "completed" | "failed" | "interrupted";
|
|
816
|
-
usageStatus: ModelAttemptUsageStatus;
|
|
817
|
-
usage?: UsageSnapshot;
|
|
818
|
-
notDispatched?: true;
|
|
819
|
-
};
|
|
820
|
-
} | {
|
|
821
|
-
type: "domain.event";
|
|
822
|
-
data: {
|
|
823
|
-
name: string;
|
|
824
|
-
payload?: Record<string, unknown>;
|
|
825
|
-
};
|
|
826
|
-
} | {
|
|
827
|
-
type: "permission.requested";
|
|
828
|
-
data: {
|
|
829
|
-
requestId: string;
|
|
830
|
-
request: AgentPermissionRequest;
|
|
831
|
-
};
|
|
832
|
-
} | {
|
|
833
|
-
type: "permission.resolved";
|
|
834
|
-
data: {
|
|
835
|
-
requestId: string;
|
|
836
|
-
decision: AgentPermissionDecision;
|
|
837
|
-
};
|
|
838
|
-
} | {
|
|
839
|
-
type: "child.created";
|
|
840
|
-
data: {
|
|
841
|
-
childId: string;
|
|
842
|
-
sessionId: string;
|
|
843
|
-
spawn: AgentChildSpawnInput;
|
|
844
|
-
postRunPurpose?: "review" | "maintenance";
|
|
845
|
-
parentRequestConfiguration?: AgentModelConfiguration;
|
|
846
|
-
/** Trusted effective policy, derived before constructing a scoped child runtime. */
|
|
847
|
-
cwd: string;
|
|
848
|
-
worktree?: {
|
|
849
|
-
path: string;
|
|
850
|
-
branch: string;
|
|
851
|
-
};
|
|
852
|
-
};
|
|
853
|
-
} | {
|
|
854
|
-
type: "child.suspended";
|
|
855
|
-
data: {
|
|
856
|
-
childId: string;
|
|
857
|
-
sessionId: string;
|
|
858
|
-
};
|
|
859
|
-
} | {
|
|
860
|
-
type: "child.resumed";
|
|
861
|
-
data: {
|
|
862
|
-
childId: string;
|
|
863
|
-
sessionId: string;
|
|
864
|
-
};
|
|
865
|
-
} | {
|
|
866
|
-
type: "child.closed";
|
|
867
|
-
data: {
|
|
868
|
-
childId: string;
|
|
869
|
-
sessionId: string;
|
|
870
|
-
result: AgentChildResult;
|
|
871
|
-
};
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
interface AgentExecutionLimits {
|
|
875
|
-
check(boundary: "run" | "model" | "tool" | "child" | "maintenance", tool?: {
|
|
876
|
-
toolName: string;
|
|
877
|
-
toolAttemptId: string;
|
|
878
|
-
}): void | Promise<void>;
|
|
879
|
-
/** Host restrictions rebound to a framework-generated child Run, never model input. */
|
|
880
|
-
forChildRun?(runId: string): AgentExecutionLimits;
|
|
881
|
-
}
|
|
882
|
-
/** Host-owned restrictions scoped to one Run, including every model retry. */
|
|
883
|
-
interface AgentExecutionProfile {
|
|
884
|
-
/** Host-selected bounded result references for captured tool calls. */
|
|
885
|
-
readonly toolResultReferences?: boolean;
|
|
886
|
-
maxOutputTokens?: number;
|
|
887
|
-
executableHooks?: boolean;
|
|
888
|
-
}
|
|
889
|
-
interface AgentEffectContext {
|
|
890
|
-
appliedInputState?: AppliedInputStateSnapshot;
|
|
891
|
-
agentId: string;
|
|
892
|
-
sessionId: string;
|
|
893
|
-
runId: string;
|
|
894
|
-
/** Absent only for a host action whose real Run has no user Input. */
|
|
895
|
-
inputId?: string;
|
|
896
|
-
cwd: string;
|
|
897
|
-
traceId: string;
|
|
898
|
-
childId?: string;
|
|
899
|
-
/** Captured by the runtime, never taken from tool arguments or a caller-supplied scope. */
|
|
900
|
-
approvalMode?: ApprovalMode;
|
|
901
|
-
signal: AbortSignal;
|
|
902
|
-
}
|
|
903
|
-
interface AgentEffects {
|
|
904
|
-
requestPermission(input: AgentPermissionRequest, context: AgentEffectContext): Promise<AgentPermissionDecision>;
|
|
905
|
-
askUserPrompt?(question: string, context: AgentEffectContext): Promise<string>;
|
|
906
|
-
}
|
|
907
|
-
interface AgentRunToolContribution {
|
|
908
|
-
/** Trusted finalization tools may require a batch with no sibling effects. */
|
|
909
|
-
readonly requiresSoloBatch?: true;
|
|
910
|
-
/** Trusted host validation after authorization and before taking dispatch rights. */
|
|
911
|
-
readonly beforeDispatch?: (input: Record<string, unknown>, context: ToolContext) => Promise<string | undefined>;
|
|
912
|
-
readonly definition: ToolDefinition;
|
|
913
|
-
readonly permission: "host-internal";
|
|
914
|
-
/** End only after this exact definition succeeds and the whole batch is delivered. */
|
|
915
|
-
readonly endRunOnSuccess?: true;
|
|
916
|
-
}
|
|
917
|
-
interface RequestImageCapabilities {
|
|
918
|
-
modelCapabilities: {
|
|
919
|
-
image: "native" | "unsupported" | "unknown";
|
|
920
|
-
};
|
|
921
|
-
providerCapabilities: {
|
|
922
|
-
image: "native" | "unsupported" | "unknown";
|
|
923
|
-
imageMediaTypes: readonly string[];
|
|
924
|
-
};
|
|
925
|
-
}
|
|
926
|
-
interface AgentRunContribution {
|
|
927
|
-
/** Prepare only this Run's initial input against the model selected for its first request. */
|
|
928
|
-
readonly prepareInitialContent?: (images: RequestImageCapabilities) => Promise<string | ContentBlock[]>;
|
|
929
|
-
readonly systemGuidance?: string;
|
|
930
|
-
readonly tools?: readonly AgentRunToolContribution[];
|
|
931
|
-
/** Include actual tool result IDs as model-visible reference data. */
|
|
932
|
-
readonly exposeToolResultIds?: true;
|
|
933
|
-
}
|
|
934
|
-
/** Objects captured from the host's already-filtered runtime for one Run. */
|
|
935
|
-
interface RunToolBinding {
|
|
936
|
-
/** Opaque identity of the original registered definition; omitted by JSON serialization. */
|
|
937
|
-
readonly definitionIdentity?: symbol;
|
|
938
|
-
readonly definition: ToolDefinition;
|
|
939
|
-
readonly source?: ToolRegistrationSource;
|
|
940
|
-
readonly invoke: ToolDefinition["execute"];
|
|
941
|
-
}
|
|
942
|
-
/** Framework-internal execution capabilities shared with tool packages. */
|
|
943
|
-
interface AgentExecutionContext {
|
|
944
|
-
readonly toolResults?: RunToolResultStore;
|
|
945
|
-
readonly checkToolDispatch?: ToolDispatchCheck;
|
|
946
|
-
readonly bindToolDispatch?: ToolDispatchCheckFactory;
|
|
947
|
-
readonly limits?: AgentExecutionLimits;
|
|
948
|
-
readonly modelAttempts?: ModelAttemptGate;
|
|
949
|
-
readonly profile?: AgentExecutionProfile;
|
|
950
|
-
readonly scope: AgentRunScope;
|
|
951
|
-
readonly tools?: ReadonlyMap<string, RunToolBinding>;
|
|
952
|
-
/** Optional host proof, consulted only after the ordinary checker returns ask. */
|
|
953
|
-
readonly confirmTool?: (input: {
|
|
954
|
-
toolUse: ToolUseBlock;
|
|
955
|
-
binding: RunToolBinding;
|
|
956
|
-
scope: AgentRunScope;
|
|
957
|
-
}) => Promise<boolean>;
|
|
958
|
-
/** Trusted, run-scoped ceiling for this Run only. Later configuration cannot raise it. */
|
|
959
|
-
readonly hardMaxTurns?: number;
|
|
960
|
-
/** Trusted, run-scoped capabilities supplied by the host. */
|
|
961
|
-
readonly contribution?: AgentRunContribution;
|
|
962
|
-
readonly effects: AgentEffects;
|
|
963
|
-
readonly children: AgentChildController;
|
|
964
|
-
emit(event: AgentEventInput): Promise<void>;
|
|
965
|
-
/** Optional, non-durable diagnostics; never used for execution decisions. */
|
|
966
|
-
observe?(event: AgentEventInput): void;
|
|
967
|
-
getAppliedInputState?(): AppliedInputStateSnapshot;
|
|
968
|
-
markInputsApplied?(inputIds: readonly string[]): Promise<void>;
|
|
969
|
-
takeSteeredInputs(options?: {
|
|
970
|
-
closeIfEmpty?: boolean;
|
|
971
|
-
}): Promise<AgentChildInput[]>;
|
|
972
|
-
closeSteering(): void;
|
|
973
|
-
/** Track the actual invocation, even when its timeout/abort race has returned. */
|
|
974
|
-
observeInvocation(settled: Promise<void>): void;
|
|
975
|
-
}
|
|
976
|
-
interface ModelAttemptIdentity {
|
|
977
|
-
scope: AgentRunScope;
|
|
978
|
-
generationId: string;
|
|
979
|
-
attempt: number;
|
|
980
|
-
}
|
|
981
|
-
interface ModelAttemptAdmission extends ModelAttemptIdentity {
|
|
982
|
-
model: string;
|
|
983
|
-
provider?: string;
|
|
984
|
-
purpose: "generation" | "compaction" | "finalization" | "memory" | "plugin_selection";
|
|
985
|
-
}
|
|
986
|
-
interface ModelAttemptSettlement extends ModelAttemptIdentity {
|
|
987
|
-
status: "completed" | "failed" | "interrupted";
|
|
988
|
-
usageStatus: "complete" | "partial" | "unknown";
|
|
989
|
-
usage?: UsageSnapshot;
|
|
990
|
-
notDispatched?: true;
|
|
991
|
-
}
|
|
992
|
-
/** Hosts admit actual dispatch and durably settle every admitted attempt. */
|
|
993
|
-
interface ModelAttemptGate {
|
|
994
|
-
beforeDispatch(input: ModelAttemptAdmission): Promise<void>;
|
|
995
|
-
settle(input: ModelAttemptSettlement): Promise<void>;
|
|
996
|
-
}
|
|
997
|
-
interface AgentModelConfiguration {
|
|
998
|
-
model: string;
|
|
999
|
-
provider?: string;
|
|
1000
|
-
apiFormat?: "anthropic" | "openai";
|
|
1001
|
-
effort?: string;
|
|
1002
|
-
maxTurns?: number;
|
|
1003
|
-
}
|
|
1004
|
-
/** Bound to the final Run tool view; cwd is the trusted host workspace directory, not an environment's execution path. A failure terminates this Run before invoking the tool. */
|
|
1005
|
-
type ToolDispatchCheck = (input: {
|
|
1006
|
-
scope: AgentRunScope;
|
|
1007
|
-
toolUse: ToolUseBlock;
|
|
1008
|
-
binding: RunToolBinding | undefined;
|
|
1009
|
-
cwd: string;
|
|
1010
|
-
}) => void | Promise<void>;
|
|
1011
|
-
/** Rebound for each Run, including manual and child calls. Never reuse a parent's bound check. */
|
|
1012
|
-
type ToolDispatchCheckFactory = (scope: AgentRunScope, tools: ReadonlyMap<string, RunToolBinding>) => ToolDispatchCheck;
|
|
1013
|
-
|
|
1014
|
-
type ShellFamily = "powershell" | "cmd" | "posix";
|
|
1015
|
-
type ShellDialect = "windows-powershell" | "pwsh" | "cmd" | "bash" | "posix-sh" | "zsh";
|
|
1016
|
-
interface ShellDescriptor {
|
|
1017
|
-
family: ShellFamily;
|
|
1018
|
-
dialect: ShellDialect;
|
|
1019
|
-
executable: string;
|
|
1020
|
-
argsPrefix: string[];
|
|
1021
|
-
displayName: string;
|
|
1022
|
-
version?: string;
|
|
1023
|
-
pathStyle: "windows" | "posix";
|
|
1024
|
-
tempDir: string;
|
|
1025
|
-
capabilities: {
|
|
1026
|
-
conditionalAndOr: boolean;
|
|
1027
|
-
supportsLoginShell: boolean;
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
type ExecutionEnvironmentKind = "local" | "wsl";
|
|
1032
|
-
interface WorkspaceBinding {
|
|
1033
|
-
kind: ExecutionEnvironmentKind;
|
|
1034
|
-
hostRoot: string;
|
|
1035
|
-
executionRoot: string;
|
|
1036
|
-
}
|
|
1037
|
-
type EnvironmentPathOperation = "read" | "write" | "execute";
|
|
1038
|
-
type EnvironmentMountMode = "ro" | "rw";
|
|
1039
|
-
interface EnvironmentMount {
|
|
1040
|
-
path: string;
|
|
1041
|
-
mode: EnvironmentMountMode;
|
|
1042
|
-
purpose: "workspace" | "user_skills" | string;
|
|
1043
|
-
}
|
|
1044
|
-
interface ResolvedEnvironmentPath {
|
|
1045
|
-
executionPath: string;
|
|
1046
|
-
hostPath?: string;
|
|
1047
|
-
mountPurpose: "workspace" | "user_skills" | "unmounted";
|
|
1048
|
-
mountMode?: EnvironmentMountMode;
|
|
1049
|
-
}
|
|
1050
|
-
interface EffectiveEnvironmentInfo {
|
|
1051
|
-
kind: ExecutionEnvironmentKind;
|
|
1052
|
-
hostOs: string;
|
|
1053
|
-
executionOs: string;
|
|
1054
|
-
shell: string;
|
|
1055
|
-
/** User account's default shell when known; shellDescriptor identifies the actual executor. */
|
|
1056
|
-
userShell?: string;
|
|
1057
|
-
shellDialect: "powershell" | "cmd" | "posix";
|
|
1058
|
-
pathStyle: "windows" | "posix";
|
|
1059
|
-
cwd: string;
|
|
1060
|
-
homeDir: string;
|
|
1061
|
-
tempDir: string;
|
|
1062
|
-
mounts: EnvironmentMount[];
|
|
1063
|
-
networkMode: string;
|
|
1064
|
-
git?: {
|
|
1065
|
-
repository: boolean;
|
|
1066
|
-
branch?: string;
|
|
1067
|
-
};
|
|
1068
|
-
limitations: string[];
|
|
1069
|
-
shellDescriptor: ShellDescriptor;
|
|
1070
|
-
}
|
|
1071
|
-
interface EnvironmentProcessResult {
|
|
1072
|
-
exitCode: number | null;
|
|
1073
|
-
signal?: string;
|
|
1074
|
-
}
|
|
1075
|
-
interface EnvironmentProcess {
|
|
1076
|
-
readonly pid?: number;
|
|
1077
|
-
write(data: string | Uint8Array): void;
|
|
1078
|
-
end(): void;
|
|
1079
|
-
onOutput(listener: (chunk: Uint8Array) => void): () => void;
|
|
1080
|
-
onErrorOutput?(listener: (chunk: Uint8Array) => void): () => void;
|
|
1081
|
-
wait(): Promise<EnvironmentProcessResult>;
|
|
1082
|
-
signal(signal: "interrupt" | "terminate"): Promise<void>;
|
|
1083
|
-
}
|
|
1084
|
-
interface EnvironmentProcessOptions {
|
|
1085
|
-
environmentMode?: "inherit" | "replace";
|
|
1086
|
-
cwd?: string;
|
|
1087
|
-
env?: Record<string, string>;
|
|
1088
|
-
owner?: EnvironmentExecutionOwner;
|
|
1089
|
-
signal?: AbortSignal;
|
|
1090
|
-
}
|
|
1091
|
-
interface EnvironmentExecutionOwner {
|
|
1092
|
-
kind: "agent" | "terminal" | "background" | "hook" | "mcp";
|
|
1093
|
-
id: string;
|
|
1094
|
-
}
|
|
1095
|
-
interface EnvironmentProcessExecutor {
|
|
1096
|
-
execShell(command: string, options?: EnvironmentProcessOptions): Promise<EnvironmentProcess>;
|
|
1097
|
-
execProcess(argv: string[], options?: EnvironmentProcessOptions & {
|
|
1098
|
-
/** Variables from the host-accepted process configuration. A managed base takes precedence. */
|
|
1099
|
-
configuredEnv?: Record<string, string>;
|
|
1100
|
-
}): Promise<EnvironmentProcess>;
|
|
1101
|
-
}
|
|
1102
|
-
interface EnvironmentTerminalPrepareOptions {
|
|
1103
|
-
cwd?: string;
|
|
1104
|
-
shell?: string;
|
|
1105
|
-
shellArgs?: string[];
|
|
1106
|
-
env?: Record<string, string>;
|
|
1107
|
-
owner?: EnvironmentExecutionOwner;
|
|
1108
|
-
cols: number;
|
|
1109
|
-
rows: number;
|
|
1110
|
-
}
|
|
1111
|
-
interface EnvironmentPtyTarget {
|
|
1112
|
-
environmentMode?: "inherit" | "replace";
|
|
1113
|
-
command: string;
|
|
1114
|
-
args: string[];
|
|
1115
|
-
hostCwd: string;
|
|
1116
|
-
executionCwd: string;
|
|
1117
|
-
shell: string;
|
|
1118
|
-
environmentKind?: "native" | "wsl";
|
|
1119
|
-
distribution?: string;
|
|
1120
|
-
env?: Record<string, string>;
|
|
1121
|
-
resize?(cols: number, rows: number): Promise<void>;
|
|
1122
|
-
signal(signal: "interrupt" | "terminate"): Promise<void>;
|
|
1123
|
-
close(): Promise<void>;
|
|
1124
|
-
}
|
|
1125
|
-
interface EnvironmentTerminalFactory {
|
|
1126
|
-
prepare(input: EnvironmentTerminalPrepareOptions): Promise<EnvironmentPtyTarget>;
|
|
1127
|
-
}
|
|
1128
|
-
interface EnvironmentFileStat {
|
|
1129
|
-
isFile: boolean;
|
|
1130
|
-
isDirectory: boolean;
|
|
1131
|
-
isSymbolicLink?: boolean;
|
|
1132
|
-
sizeBytes?: number;
|
|
1133
|
-
/** Unix timestamp in milliseconds. */
|
|
1134
|
-
modifiedAt?: number;
|
|
1135
|
-
}
|
|
1136
|
-
interface EnvironmentReadBytesOptions {
|
|
1137
|
-
/** Return at most this many bytes; omitted means read the whole file. */
|
|
1138
|
-
maxBytes?: number;
|
|
1139
|
-
signal?: AbortSignal;
|
|
1140
|
-
}
|
|
1141
|
-
/** One opened regular file. The path and metadata describe this object, not a later pathname lookup. */
|
|
1142
|
-
interface EnvironmentFileReader {
|
|
1143
|
-
canonicalPath: string;
|
|
1144
|
-
stat: EnvironmentFileStat;
|
|
1145
|
-
/** Consume one bounded read. A reader must not be reused after reading starts. */
|
|
1146
|
-
readBytes(options: {
|
|
1147
|
-
maxBytes: number;
|
|
1148
|
-
signal?: AbortSignal;
|
|
1149
|
-
}): Promise<Uint8Array>;
|
|
1150
|
-
/** Idempotent; wait for I/O cleanup. Read/startup errors are reported by openRead/readBytes. */
|
|
1151
|
-
close(): Promise<void>;
|
|
1152
|
-
}
|
|
1153
|
-
interface EnvironmentFileEntry {
|
|
1154
|
-
name: string;
|
|
1155
|
-
isDirectory: boolean;
|
|
1156
|
-
}
|
|
1157
|
-
interface EnvironmentDirectoryScanOptions {
|
|
1158
|
-
/** Return at most this many entries, with one truncation lookahead. Fixed I/O buffering is allowed. */
|
|
1159
|
-
maxEntries: number;
|
|
1160
|
-
signal?: AbortSignal;
|
|
1161
|
-
}
|
|
1162
|
-
interface EnvironmentDirectoryScanResult {
|
|
1163
|
-
/** Filesystem order; a partial scan does not establish global directory ordering. */
|
|
1164
|
-
entries: EnvironmentFileEntry[];
|
|
1165
|
-
truncated: boolean;
|
|
1166
|
-
}
|
|
1167
|
-
interface EnvironmentGrepOptions {
|
|
1168
|
-
include?: string;
|
|
1169
|
-
/** Host-provided subtree exclusions, relative to the verified search root. */
|
|
1170
|
-
excludedPaths?: readonly string[];
|
|
1171
|
-
caseSensitive: boolean;
|
|
1172
|
-
limit: number;
|
|
1173
|
-
maxBytes?: number;
|
|
1174
|
-
timeoutMs?: number;
|
|
1175
|
-
signal?: AbortSignal;
|
|
1176
|
-
}
|
|
1177
|
-
interface EnvironmentGrepResult {
|
|
1178
|
-
matches: string[];
|
|
1179
|
-
/** More matches exist, or a line/output budget prevented a complete search. */
|
|
1180
|
-
truncated: boolean;
|
|
1181
|
-
}
|
|
1182
|
-
interface EnvironmentFileSystem {
|
|
1183
|
-
/** Hold across the complete read/plan/check/mutate transaction, including actual I/O settlement.
|
|
1184
|
-
* Paths are resolved execution paths. Implementations must coordinate across sessions/instances;
|
|
1185
|
-
* cancellation may stop waiting but must not release an active transaction early.
|
|
1186
|
-
*/
|
|
1187
|
-
withMutationLock?<T>(paths: readonly string[], work: () => Promise<T>, signal?: AbortSignal): Promise<T>;
|
|
1188
|
-
/** No pathname fallback: implementations unable to identify the held object must fail closed. */
|
|
1189
|
-
openRead?(path: string, signal?: AbortSignal): Promise<EnvironmentFileReader>;
|
|
1190
|
-
stat(path: string, signal?: AbortSignal): Promise<EnvironmentFileStat>;
|
|
1191
|
-
listDir(path: string, signal?: AbortSignal): Promise<EnvironmentFileEntry[]>;
|
|
1192
|
-
/** Bounded enumeration; optional for existing environments. Never substitute an unbounded list. */
|
|
1193
|
-
scanDirectory?(path: string, options: EnvironmentDirectoryScanOptions): Promise<EnvironmentDirectoryScanResult>;
|
|
1194
|
-
readText(path: string): Promise<string>;
|
|
1195
|
-
readBytes(path: string, options?: EnvironmentReadBytesOptions): Promise<Uint8Array>;
|
|
1196
|
-
writeText(path: string, content: string): Promise<void>;
|
|
1197
|
-
writeBytes(path: string, content: Uint8Array): Promise<void>;
|
|
1198
|
-
/** Publish complete bytes only if the target does not exist; never overwrite or expose a partial target. */
|
|
1199
|
-
createBytesExclusive?(path: string, content: Uint8Array): Promise<void>;
|
|
1200
|
-
createTextExclusive(path: string, content: string): Promise<void>;
|
|
1201
|
-
writeTextAtomic(path: string, content: string): Promise<void>;
|
|
1202
|
-
removeFile(path: string): Promise<void>;
|
|
1203
|
-
glob(basePath: string, pattern: string, limit: number): Promise<string[]>;
|
|
1204
|
-
grep(basePath: string, pattern: string, options: EnvironmentGrepOptions): Promise<EnvironmentGrepResult>;
|
|
1205
|
-
}
|
|
1206
|
-
interface EnvironmentPathResolver {
|
|
1207
|
-
/** Resolve existing paths and links in the execution environment's filesystem. */
|
|
1208
|
-
canonicalize?(path: string, signal?: AbortSignal): Promise<string>;
|
|
1209
|
-
resolve(path: string, operation: EnvironmentPathOperation): Promise<ResolvedEnvironmentPath>;
|
|
1210
|
-
presentHostPath(path: string): string | undefined;
|
|
1211
|
-
toHostPath(path: string): string | undefined;
|
|
1212
|
-
}
|
|
1213
|
-
interface ExecutionEnvironmentHandle {
|
|
1214
|
-
readonly info: EffectiveEnvironmentInfo;
|
|
1215
|
-
readonly workspace: WorkspaceBinding;
|
|
1216
|
-
readonly process: EnvironmentProcessExecutor;
|
|
1217
|
-
readonly terminal: EnvironmentTerminalFactory;
|
|
1218
|
-
readonly files: EnvironmentFileSystem;
|
|
1219
|
-
readonly paths: EnvironmentPathResolver;
|
|
1220
|
-
/** Copy one invocation's process policy; false restores the configured baseline. */
|
|
1221
|
-
withFullAccess?(enabled: boolean): ExecutionEnvironmentHandle;
|
|
1222
|
-
release(): Promise<void>;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
interface ToolContext {
|
|
1226
|
-
/** Host-owned visible-history state for lazy, path-scoped project rules. */
|
|
1227
|
-
projectInstructions?: {
|
|
1228
|
-
claim(key: string): "new" | "pending" | "visible";
|
|
1229
|
-
/** Ordinary Read permission must allow this additional file without prompting. */
|
|
1230
|
-
canRead(path: string): Promise<boolean>;
|
|
1231
|
-
};
|
|
1232
|
-
/** Host-bound authorized archive; model input cannot choose another session. */
|
|
1233
|
-
toolResults?: RunToolResultStore;
|
|
1234
|
-
cwd: string;
|
|
1235
|
-
/** Effective execution environment. Runtime-owned contexts always provide it. */
|
|
1236
|
-
environment?: ExecutionEnvironmentHandle;
|
|
1237
|
-
/** Host-captured network policy of the actual calling session, including inherited tools. */
|
|
1238
|
-
canUseNetwork?: boolean;
|
|
1239
|
-
/** Approval policy captured for this actual tool call by the runtime. */
|
|
1240
|
-
approvalMode?: ApprovalMode;
|
|
1241
|
-
sessionId?: string;
|
|
1242
|
-
/** Stable model-issued tool call identity. Retries of the same call reuse this value. */
|
|
1243
|
-
toolCallId?: string;
|
|
1244
|
-
/** Identity of this concrete execution attempt. */
|
|
1245
|
-
toolAttemptId?: string;
|
|
1246
|
-
/** Current-Run, bounded actual results; never a persistent archive or model-provided body. */
|
|
1247
|
-
readToolResult?: (toolUseId: string) => ToolExecutionResult | undefined;
|
|
1248
|
-
/** Lifetime of the owning session run; use for detached work that outlives this tool call. */
|
|
1249
|
-
runAbortSignal?: AbortSignal;
|
|
1250
|
-
/** Lifetime of this tool invocation, including its execution timeout. */
|
|
1251
|
-
abortSignal?: AbortSignal;
|
|
1252
|
-
/** Absolute execution deadline (Unix milliseconds); bounded waits should return before it. */
|
|
1253
|
-
deadlineAt?: number;
|
|
1254
|
-
/** Runtime-owned narrowing/restoration only; never changes the user-selected ceiling. */
|
|
1255
|
-
setPlanMode?: (enabled: boolean) => PermissionMode;
|
|
1256
|
-
/** Selected model identity for the request that invoked this tool. */
|
|
1257
|
-
requestConfiguration?: {
|
|
1258
|
-
model: string;
|
|
1259
|
-
provider?: string;
|
|
1260
|
-
apiFormat?: "anthropic" | "openai";
|
|
1261
|
-
};
|
|
1262
|
-
/** Actual tools available to the current QueryEngine after host injection and allow/deny filtering. */
|
|
1263
|
-
toolRegistry?: ToolRegistryView;
|
|
1264
|
-
/** Host-owned, Run-local discovery; supplied only to the trusted search tool. */
|
|
1265
|
-
toolDiscovery?: ToolDiscovery;
|
|
1266
|
-
/** Invoke an already captured tool through the same checked execution pipeline. */
|
|
1267
|
-
invokeTool?: (name: string, input: Record<string, unknown>, options?: {
|
|
1268
|
-
signal?: AbortSignal;
|
|
1269
|
-
deadlineAt?: number;
|
|
1270
|
-
}) => Promise<ToolResult>;
|
|
1271
|
-
/** Host-owned interactive user question. */
|
|
1272
|
-
askUserPrompt?: (question: string) => Promise<string>;
|
|
1273
|
-
/** Request operation permission through current policy; an optional signal can only narrow its lifetime. */
|
|
1274
|
-
requestPermission?: (request: AgentPermissionRequest, options?: {
|
|
1275
|
-
signal?: AbortSignal;
|
|
1276
|
-
}) => Promise<AgentPermissionDecision>;
|
|
1277
|
-
agent?: AgentExecutionContext;
|
|
1278
|
-
}
|
|
1279
|
-
interface ToolExecutionSpec {
|
|
1280
|
-
domain: "environment" | "control_plane";
|
|
1281
|
-
supportedEnvironments?: Array<"local" | "wsl">;
|
|
1282
|
-
/** Whether this control-plane tool needs outbound network access. */
|
|
1283
|
-
network?: boolean;
|
|
1284
|
-
}
|
|
1285
|
-
interface ToolDefinition {
|
|
1286
|
-
name: string;
|
|
1287
|
-
description: string;
|
|
1288
|
-
inputSchema: Record<string, unknown>;
|
|
1289
|
-
/** Presentation hints, never authorization. */
|
|
1290
|
-
ui?: McpToolUiMetadata;
|
|
1291
|
-
annotations?: McpToolAnnotations;
|
|
1292
|
-
/** Resolve one parameter from a settled same-tool call before validation and authorization. */
|
|
1293
|
-
inputReuse?: {
|
|
1294
|
-
property: string;
|
|
1295
|
-
referenceProperty: string;
|
|
1296
|
-
};
|
|
1297
|
-
/** Automatic retry is forbidden unless this is explicitly true. */
|
|
1298
|
-
safeToRetry?: boolean;
|
|
1299
|
-
/** Calls in the same response and group authorize and execute in model order. */
|
|
1300
|
-
serialGroup?: string;
|
|
1301
|
-
/** Where this tool actually runs. Omission is fail-closed to local execution. */
|
|
1302
|
-
execution?: ToolExecutionSpec;
|
|
1303
|
-
execute: (input: Record<string, unknown>, context: ToolContext) => Promise<ToolResult>;
|
|
1304
|
-
}
|
|
1305
|
-
/** Immutable model-visible metadata; deliberately excludes execute(). */
|
|
1306
|
-
interface ToolDescriptor {
|
|
1307
|
-
readonly name: string;
|
|
1308
|
-
readonly description: string;
|
|
1309
|
-
readonly inputSchema: Readonly<Record<string, unknown>>;
|
|
1310
|
-
readonly ui?: McpToolUiMetadata;
|
|
1311
|
-
readonly annotations?: McpToolAnnotations;
|
|
1312
|
-
readonly safeToRetry?: boolean;
|
|
1313
|
-
readonly execution?: ToolExecutionSpec;
|
|
1314
|
-
}
|
|
1315
|
-
interface ToolRegistrationSource {
|
|
1316
|
-
readonly kind: "builtin" | "agent" | "extension" | "plugin" | "mcp" | "runtime";
|
|
1317
|
-
readonly id?: string;
|
|
1318
|
-
}
|
|
1319
|
-
/** Search metadata excludes schemas and execution handles; descriptions are untrusted data. */
|
|
1320
|
-
interface ToolDiscoveryEntry {
|
|
1321
|
-
readonly name: string;
|
|
1322
|
-
readonly description: string;
|
|
1323
|
-
readonly source?: ToolRegistrationSource;
|
|
1324
|
-
}
|
|
1325
|
-
interface ToolDiscovery {
|
|
1326
|
-
readonly catalog: readonly ToolDiscoveryEntry[];
|
|
1327
|
-
getEligibleNames(): ReadonlySet<string>;
|
|
1328
|
-
/** Request schemas for the next model request; never changes Run authorization. */
|
|
1329
|
-
expose(names: readonly string[]): readonly string[];
|
|
1330
|
-
}
|
|
1331
|
-
interface RegisteredToolInspection {
|
|
1332
|
-
name: string;
|
|
1333
|
-
source: ToolRegistrationSource;
|
|
1334
|
-
overrides?: ToolRegistrationSource;
|
|
1335
|
-
}
|
|
1336
|
-
interface ToolRegistryView {
|
|
1337
|
-
get(name: string): ToolDescriptor | undefined;
|
|
1338
|
-
getAll(): ToolDescriptor[];
|
|
1339
|
-
has(name: string): boolean;
|
|
1340
|
-
inspect(name: string): RegisteredToolInspection | undefined;
|
|
1341
|
-
}
|
|
1342
|
-
|
|
1343
|
-
interface AgentScheduledTaskInput {
|
|
1344
|
-
name: string;
|
|
1345
|
-
prompt: string;
|
|
1346
|
-
recurrence: string;
|
|
1347
|
-
recurrenceFormat: "rrule" | "once";
|
|
1348
|
-
timezone: string;
|
|
1349
|
-
destination: "standalone" | "chat";
|
|
1350
|
-
sessionId?: string;
|
|
1351
|
-
projectPaths: string[];
|
|
1352
|
-
executionMode?: "local" | "worktree";
|
|
1353
|
-
model?: string;
|
|
1354
|
-
effort?: string;
|
|
1355
|
-
skillNames?: string[];
|
|
1356
|
-
pluginNames?: string[];
|
|
1357
|
-
permissionModeId?: "ask" | "auto_review" | "full_access";
|
|
1358
|
-
workMode?: "execute" | "plan";
|
|
1359
|
-
pluginSelectionPolicy?: "auto" | "none";
|
|
1360
|
-
permissionProfile?: {
|
|
1361
|
-
mode: "read_only" | "workspace_write" | "full_access";
|
|
1362
|
-
network?: boolean;
|
|
1363
|
-
allowedTools?: string[];
|
|
1364
|
-
deniedTools?: string[];
|
|
1365
|
-
};
|
|
1366
|
-
overlapPolicy?: "skip" | "queue";
|
|
1367
|
-
missedRunPolicy?: "skip" | "run_once";
|
|
1368
|
-
stopPolicy?: {
|
|
1369
|
-
runOnce?: boolean;
|
|
1370
|
-
maxRuns?: number;
|
|
1371
|
-
stopWhenCompleted?: boolean;
|
|
1372
|
-
expiresAt?: number;
|
|
1373
|
-
};
|
|
1374
|
-
}
|
|
1375
|
-
interface AgentScheduledTask extends AgentScheduledTaskInput {
|
|
1376
|
-
id: string;
|
|
1377
|
-
status: "active" | "paused" | "completed";
|
|
1378
|
-
nextRunAt?: number;
|
|
1379
|
-
lastRunAt?: number;
|
|
1380
|
-
runCount: number;
|
|
1381
|
-
}
|
|
1382
|
-
interface AgentScheduledRun {
|
|
1383
|
-
id: string;
|
|
1384
|
-
taskId: string;
|
|
1385
|
-
status: "queued" | "running" | "succeeded" | "failed" | "interrupted" | "needs_attention" | "skipped";
|
|
1386
|
-
summary?: string;
|
|
1387
|
-
error?: string;
|
|
1388
|
-
sessionId?: string;
|
|
1389
|
-
runId?: string;
|
|
1390
|
-
}
|
|
1391
|
-
interface AgentScheduleEffects {
|
|
1392
|
-
create(input: AgentScheduledTaskInput): Promise<AgentScheduledTask>;
|
|
1393
|
-
update(id: string, patch: Partial<AgentScheduledTaskInput> & {
|
|
1394
|
-
status?: AgentScheduledTask["status"];
|
|
1395
|
-
}): Promise<AgentScheduledTask>;
|
|
1396
|
-
remove(id: string): Promise<void>;
|
|
1397
|
-
list(): Promise<AgentScheduledTask[]>;
|
|
1398
|
-
trigger(id: string): Promise<AgentScheduledRun>;
|
|
1399
|
-
listRuns(taskId?: string): Promise<AgentScheduledRun[]>;
|
|
1400
|
-
}
|
|
1401
|
-
/** A host can implement the operations directly or forward the checked tool call to its scheduler. */
|
|
1402
|
-
type AgentScheduleHost = AgentScheduleEffects | {
|
|
1403
|
-
invoke(name: string, input: Record<string, unknown>, context: ToolContext): Promise<ToolResult>;
|
|
1404
|
-
};
|
|
1405
|
-
|
|
1406
|
-
declare function createScheduleTools(host?: AgentScheduleHost): ToolDefinition[];
|
|
1407
|
-
|
|
1408
|
-
interface AppServiceHost {
|
|
1409
|
-
secrets: {
|
|
1410
|
-
get(key: string): Promise<string | null>;
|
|
1411
|
-
set(key: string, value: string): Promise<void>;
|
|
1412
|
-
delete(key: string): Promise<void>;
|
|
1413
|
-
};
|
|
1414
|
-
context: {
|
|
1415
|
-
get(): Promise<ServiceContext>;
|
|
1416
|
-
whenReady(): Promise<ServiceContext>;
|
|
1417
|
-
resolveInvocation(ticket: string): Promise<ServiceInvocation>;
|
|
1418
|
-
};
|
|
1419
|
-
agent: AppHostAgent;
|
|
1420
|
-
sessions: {
|
|
1421
|
-
getConnection(input: {
|
|
1422
|
-
dataScopeId: string;
|
|
1423
|
-
sessionId: string;
|
|
1424
|
-
}): Promise<AgentConnection>;
|
|
1425
|
-
};
|
|
1426
|
-
workspace: {
|
|
1427
|
-
gitStatus(input: {
|
|
1428
|
-
workspaceId: string;
|
|
1429
|
-
}): Promise<GitStatus>;
|
|
1430
|
-
createTaskWorktree(input: CreateWorktree): Promise<WorktreeReceipt>;
|
|
1431
|
-
getWorktree(input: WorktreeQuery): Promise<WorktreeReceipt | null>;
|
|
1432
|
-
releaseExecutionRoot(input: {
|
|
1433
|
-
requestId: string;
|
|
1434
|
-
workspaceId: string;
|
|
1435
|
-
executionRoot: string;
|
|
1436
|
-
}): Promise<RootReleaseReceipt>;
|
|
1437
|
-
};
|
|
1438
|
-
work: {
|
|
1439
|
-
list(): Promise<ServiceWork[]>;
|
|
1440
|
-
get(requestId: string): Promise<ServiceWork | null>;
|
|
1441
|
-
};
|
|
1442
|
-
close(): void;
|
|
1443
|
-
}
|
|
1444
|
-
declare function connectServiceHost(): Promise<AppServiceHost>;
|
|
1445
|
-
|
|
1446
|
-
export { SERVICE_HOST_MAX_FRAME_BYTES, SERVICE_HOST_MAX_PENDING, SERVICE_HOST_METHODS, connectServiceHost, createScheduleTools, isServiceHostFrame, validServiceContext, validServiceHostInput, validServiceHostResult };
|
|
1447
|
-
export type { AgentConnection, AgentScheduleEffects, AppAgentModel, AppHostAgent, AppServiceHost, CreateWorktree, ExecutionInstructions, GitStatus, RootReleaseReceipt, ServiceContext, ServiceHostFrame, ServiceHostMethod, ServiceHostMethodMap, ServiceInvocation, ServiceWork, SessionControlOriginal, SessionControlReceipt, SessionControls, WorktreeQuery, WorktreeReceipt };
|