@hosty-sdk/app 0.47.0 → 0.49.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/dist/agent-client.d.ts +102 -0
- package/dist/agent-client.js +500 -0
- package/dist/agent-schemas.d.ts +6 -0
- package/dist/agent-schemas.js +150 -0
- package/dist/agent-server.d.ts +63 -0
- package/dist/agent-server.js +605 -0
- package/dist/agent.d.ts +539 -0
- package/dist/agent.js +35 -0
- package/dist/providers-server.d.ts +6 -1
- package/dist/providers-server.js +18 -2
- package/dist/providers.d.ts +3 -1
- package/package.json +25 -8
- package/schemas/agent-event-v1.schema.json +2988 -0
- package/schemas/agent-v1.fixtures.json +166 -0
- package/schemas/agent-v1.openapi.json +5618 -0
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
1
|
+
import type { ConversationRef, NativeSessionRef, ProviderRef, Revision, RunRef } from "./agent-sessions.js";
|
|
2
|
+
/** Public execution identities never reveal a native SDK thread, filesystem path or process ID. */
|
|
3
|
+
export type AgentProviderRef = ProviderRef;
|
|
4
|
+
export type AgentSessionRef = NativeSessionRef;
|
|
5
|
+
export type AgentRunRef = RunRef;
|
|
6
|
+
export declare const AGENT_API_VERSION: 1;
|
|
7
|
+
export declare const AGENT_EVENT_VERSION: "agent-event.1";
|
|
8
|
+
export declare const AGENT_CAPABILITIES: {
|
|
9
|
+
readonly installationHistory: "installation-history";
|
|
10
|
+
readonly resume: "session.resume";
|
|
11
|
+
readonly configuration: "configuration.resume-compatible";
|
|
12
|
+
readonly images: "input.images";
|
|
13
|
+
readonly noNativeTools: "native-tools.none";
|
|
14
|
+
readonly skills: "skills.catalog";
|
|
15
|
+
readonly exclusiveSkills: "skills.exclusive-selection";
|
|
16
|
+
readonly coreMcp: "mcp.core";
|
|
17
|
+
readonly externalMcp: "mcp.external";
|
|
18
|
+
readonly modelChange: "model.change-on-resume";
|
|
19
|
+
readonly nextTurnDecisions: "decisions.next-turn";
|
|
20
|
+
readonly nativeSubagents: "subagents.native";
|
|
21
|
+
readonly park: "runs.park";
|
|
22
|
+
readonly barrier: "runs.barrier";
|
|
23
|
+
readonly reconcile: "runs.reconcile";
|
|
24
|
+
readonly liveConfigure: "runs.live-configure";
|
|
25
|
+
readonly predictions: "predictions";
|
|
26
|
+
readonly connectionUsage: "connections.usage";
|
|
27
|
+
readonly approvalMode: "configuration.approval-mode";
|
|
28
|
+
readonly mcpPolicy: "mcp.policy-update";
|
|
29
|
+
readonly consumerWorkflow: "workflow.consumer";
|
|
30
|
+
};
|
|
31
|
+
export type AgentCapability = typeof AGENT_CAPABILITIES[keyof typeof AGENT_CAPABILITIES] | (string & {});
|
|
32
|
+
export type AgentLimits = {
|
|
33
|
+
maxCommandBytes: number;
|
|
34
|
+
maxEventBytes: number;
|
|
35
|
+
maxSnapshotBytes: number;
|
|
36
|
+
maxReplayBytes: number;
|
|
37
|
+
replayRetentionMs: number;
|
|
38
|
+
maxControls: number;
|
|
39
|
+
maxPageSize: number;
|
|
40
|
+
maxDurationMs?: number;
|
|
41
|
+
maxSkillSnapshotBytes?: number;
|
|
42
|
+
maxSkillSnapshotFiles?: number;
|
|
43
|
+
};
|
|
44
|
+
export type AgentCapabilities = {
|
|
45
|
+
version: 1;
|
|
46
|
+
eventVersions: string[];
|
|
47
|
+
capabilities: AgentCapability[];
|
|
48
|
+
limits: AgentLimits;
|
|
49
|
+
configuration: {
|
|
50
|
+
resumeCompatible: string[];
|
|
51
|
+
};
|
|
52
|
+
nativeTools?: {
|
|
53
|
+
default: "none" | "provider_default";
|
|
54
|
+
none: boolean;
|
|
55
|
+
};
|
|
56
|
+
subagents?: {
|
|
57
|
+
defaultEnabled: boolean;
|
|
58
|
+
policy: "enforceable" | "observed" | "unavailable";
|
|
59
|
+
observation: "full" | "partial" | "summary" | "unavailable";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type AgentConnection = {
|
|
63
|
+
id: string;
|
|
64
|
+
revision: Revision;
|
|
65
|
+
name: string;
|
|
66
|
+
ready: boolean;
|
|
67
|
+
reason?: string;
|
|
68
|
+
capabilities?: AgentCapability[];
|
|
69
|
+
};
|
|
70
|
+
export type AgentConnectionPage = {
|
|
71
|
+
connections: AgentConnection[];
|
|
72
|
+
nextCursor: string | null;
|
|
73
|
+
};
|
|
74
|
+
export type AgentModel = {
|
|
75
|
+
id: string;
|
|
76
|
+
name?: string;
|
|
77
|
+
reasoningEfforts: Array<string | null>;
|
|
78
|
+
defaultReasoningEffort?: string | null;
|
|
79
|
+
capabilities?: AgentCapability[];
|
|
80
|
+
unavailableReason?: string;
|
|
81
|
+
};
|
|
82
|
+
/** Catalog revisions are opaque content identities, independent of session/control counters. */
|
|
83
|
+
export type AgentModelCatalog = {
|
|
84
|
+
revision: string;
|
|
85
|
+
models: AgentModel[];
|
|
86
|
+
defaultModel: string | null;
|
|
87
|
+
nextCursor?: string | null;
|
|
88
|
+
};
|
|
89
|
+
export type AgentConnectionUsage = {
|
|
90
|
+
observedAt: string;
|
|
91
|
+
available: boolean;
|
|
92
|
+
data?: Record<string, unknown>;
|
|
93
|
+
};
|
|
94
|
+
export type AgentInstruction = {
|
|
95
|
+
id: string;
|
|
96
|
+
text: string;
|
|
97
|
+
};
|
|
98
|
+
export type AgentSkillSelection = {
|
|
99
|
+
skillId: string;
|
|
100
|
+
expectedDigest?: string;
|
|
101
|
+
};
|
|
102
|
+
export type AgentMcpTarget = {
|
|
103
|
+
kind: "core";
|
|
104
|
+
} | {
|
|
105
|
+
kind: "app";
|
|
106
|
+
appId: string;
|
|
107
|
+
installationId: string;
|
|
108
|
+
key: string;
|
|
109
|
+
};
|
|
110
|
+
export type AgentMcpPolicy = {
|
|
111
|
+
default: "ask" | "run";
|
|
112
|
+
autoAllowReadOnly?: boolean;
|
|
113
|
+
tools?: Record<string, {
|
|
114
|
+
mode: "ask" | "run" | "disabled";
|
|
115
|
+
definition?: string;
|
|
116
|
+
}>;
|
|
117
|
+
};
|
|
118
|
+
export type AgentMcpSelection = {
|
|
119
|
+
targets?: Array<{
|
|
120
|
+
target: AgentMcpTarget;
|
|
121
|
+
tools?: string[];
|
|
122
|
+
policy?: AgentMcpPolicy;
|
|
123
|
+
}>;
|
|
124
|
+
connections?: Array<{
|
|
125
|
+
id: string;
|
|
126
|
+
revision: Revision;
|
|
127
|
+
}>;
|
|
128
|
+
};
|
|
129
|
+
export type AgentConfiguration = {
|
|
130
|
+
connection: {
|
|
131
|
+
id: string;
|
|
132
|
+
revision: Revision;
|
|
133
|
+
};
|
|
134
|
+
instructions?: AgentInstruction[];
|
|
135
|
+
systemPrompt?: {
|
|
136
|
+
mode: "append";
|
|
137
|
+
text: string;
|
|
138
|
+
};
|
|
139
|
+
skills?: AgentSkillSelection[];
|
|
140
|
+
nativeTools?: "provider_default" | "none";
|
|
141
|
+
approvalMode?: "normal" | "autonomous";
|
|
142
|
+
predictions?: {
|
|
143
|
+
enabled: boolean;
|
|
144
|
+
};
|
|
145
|
+
subagents?: {
|
|
146
|
+
enabled: boolean;
|
|
147
|
+
maxConcurrency?: number;
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
export type AgentSessionCreate = {
|
|
151
|
+
configuration: AgentConfiguration;
|
|
152
|
+
requiredCapabilities?: AgentCapability[];
|
|
153
|
+
correlation?: {
|
|
154
|
+
conversation?: ConversationRef;
|
|
155
|
+
task?: {
|
|
156
|
+
provider: ProviderRef;
|
|
157
|
+
id: string;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
export type AgentConfigurationCreate = {
|
|
162
|
+
requestId: string;
|
|
163
|
+
expectedSessionRevision: Revision;
|
|
164
|
+
configuration: AgentConfiguration;
|
|
165
|
+
requiredCapabilities?: AgentCapability[];
|
|
166
|
+
};
|
|
167
|
+
export type AgentSession = {
|
|
168
|
+
ref: AgentSessionRef;
|
|
169
|
+
revision: Revision;
|
|
170
|
+
configurationRevision: Revision;
|
|
171
|
+
configurationDigest: string;
|
|
172
|
+
nativeState: "not_created" | "available" | "missing" | "unavailable" | "unknown";
|
|
173
|
+
activeRun: AgentRunRef | null;
|
|
174
|
+
resolvedSkills: Array<{
|
|
175
|
+
skillId: string;
|
|
176
|
+
digest: string;
|
|
177
|
+
}>;
|
|
178
|
+
configuration?: AgentConfiguration;
|
|
179
|
+
correlation?: AgentSessionCreate["correlation"];
|
|
180
|
+
};
|
|
181
|
+
export type AgentSessionPage = {
|
|
182
|
+
sessions: AgentSession[];
|
|
183
|
+
nextCursor: string | null;
|
|
184
|
+
};
|
|
185
|
+
export type AgentAttachment = {
|
|
186
|
+
owner: ProviderRef;
|
|
187
|
+
id: string;
|
|
188
|
+
digest: string;
|
|
189
|
+
sizeBytes: number;
|
|
190
|
+
mediaType: string;
|
|
191
|
+
name?: string;
|
|
192
|
+
};
|
|
193
|
+
export type AgentAttachmentChunk = {
|
|
194
|
+
digest: string;
|
|
195
|
+
sizeBytes: number;
|
|
196
|
+
mediaType: string;
|
|
197
|
+
name?: string;
|
|
198
|
+
count: number;
|
|
199
|
+
data: string;
|
|
200
|
+
};
|
|
201
|
+
export type AgentAttachmentChunkReceipt = {
|
|
202
|
+
attachment: AgentAttachment | null;
|
|
203
|
+
received: number[];
|
|
204
|
+
};
|
|
205
|
+
export type AgentResource = {
|
|
206
|
+
kind: string;
|
|
207
|
+
id: string;
|
|
208
|
+
revision: string;
|
|
209
|
+
provider?: ProviderRef;
|
|
210
|
+
};
|
|
211
|
+
export type AgentRunInput = {
|
|
212
|
+
expectedSessionRevision: Revision;
|
|
213
|
+
configurationRevision: Revision;
|
|
214
|
+
continuation: "start" | "resume";
|
|
215
|
+
input: {
|
|
216
|
+
text: string;
|
|
217
|
+
attachments?: AgentAttachment[];
|
|
218
|
+
} | {
|
|
219
|
+
decisionResponseRef: {
|
|
220
|
+
runId: string;
|
|
221
|
+
requestId: string;
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
context?: AgentInstruction[];
|
|
225
|
+
selection?: {
|
|
226
|
+
model: string | null;
|
|
227
|
+
reasoningEffort: string | null;
|
|
228
|
+
};
|
|
229
|
+
resources?: AgentResource[];
|
|
230
|
+
mcp?: AgentMcpSelection;
|
|
231
|
+
requiredCapabilities?: AgentCapability[];
|
|
232
|
+
limits?: {
|
|
233
|
+
maxDurationMs?: number;
|
|
234
|
+
maxOutputTokens?: number;
|
|
235
|
+
maxToolCalls?: number;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
export type AgentRunState = "queued" | "running" | "waiting_for_input" | "succeeded" | "failed" | "cancelled" | "unknown";
|
|
239
|
+
export type AgentRunPhase = "preparing" | "executing" | "waiting" | "finalizing" | "cancelling" | "parked" | "interrupted" | "terminal";
|
|
240
|
+
export type AgentSource = {
|
|
241
|
+
agentId: string;
|
|
242
|
+
parentAgentId?: string;
|
|
243
|
+
parentToolCallId?: string;
|
|
244
|
+
};
|
|
245
|
+
export type AgentPendingDecision = {
|
|
246
|
+
id: string;
|
|
247
|
+
revision: Revision;
|
|
248
|
+
kind: "approval" | "question";
|
|
249
|
+
delivery: "continue_run" | "next_turn";
|
|
250
|
+
source?: AgentSource;
|
|
251
|
+
title?: string;
|
|
252
|
+
toolCallId?: string;
|
|
253
|
+
toolName?: string;
|
|
254
|
+
input?: unknown;
|
|
255
|
+
questions?: Array<{
|
|
256
|
+
id: string;
|
|
257
|
+
text: string;
|
|
258
|
+
header?: string;
|
|
259
|
+
allowText?: boolean;
|
|
260
|
+
options?: Array<{
|
|
261
|
+
id: string;
|
|
262
|
+
label: string;
|
|
263
|
+
description?: string;
|
|
264
|
+
preview?: string;
|
|
265
|
+
}>;
|
|
266
|
+
multiple?: boolean;
|
|
267
|
+
required?: boolean;
|
|
268
|
+
}>;
|
|
269
|
+
};
|
|
270
|
+
export type AgentMessageBlock = {
|
|
271
|
+
id: string;
|
|
272
|
+
source?: AgentSource;
|
|
273
|
+
role: "assistant" | "user" | "system";
|
|
274
|
+
text: string;
|
|
275
|
+
state: "streaming" | "complete" | "interrupted";
|
|
276
|
+
};
|
|
277
|
+
export type AgentToolBlock = {
|
|
278
|
+
id: string;
|
|
279
|
+
source?: AgentSource;
|
|
280
|
+
name: string;
|
|
281
|
+
input?: unknown;
|
|
282
|
+
output?: string;
|
|
283
|
+
state: "running" | "completed" | "failed" | "cancelled" | "unknown";
|
|
284
|
+
truncated?: boolean;
|
|
285
|
+
command?: {
|
|
286
|
+
status: "completed" | "failed" | "cancelled" | "unknown";
|
|
287
|
+
exitCode?: number;
|
|
288
|
+
durationMs?: number;
|
|
289
|
+
summary?: string;
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
export type AgentResult = {
|
|
293
|
+
status: "succeeded" | "failed" | "cancelled";
|
|
294
|
+
messageId?: string;
|
|
295
|
+
text?: string;
|
|
296
|
+
value?: unknown;
|
|
297
|
+
schemaValid?: boolean;
|
|
298
|
+
error?: AgentErrorDetail;
|
|
299
|
+
};
|
|
300
|
+
export type AgentRunSnapshot = {
|
|
301
|
+
ref: AgentRunRef;
|
|
302
|
+
sessionId: string;
|
|
303
|
+
generation: string;
|
|
304
|
+
revision: Revision;
|
|
305
|
+
state: AgentRunState;
|
|
306
|
+
phase: AgentRunPhase;
|
|
307
|
+
stopConfirmed: boolean;
|
|
308
|
+
freshness: "current" | "last_known" | "unavailable";
|
|
309
|
+
observedAt: string;
|
|
310
|
+
configurationRevision: Revision;
|
|
311
|
+
lastSequence: Revision;
|
|
312
|
+
cursor: string;
|
|
313
|
+
pending: AgentPendingDecision[];
|
|
314
|
+
effects: {
|
|
315
|
+
certainty: "known" | "unknown";
|
|
316
|
+
unresolvedCallIds: string[];
|
|
317
|
+
};
|
|
318
|
+
result?: AgentResult;
|
|
319
|
+
messages?: AgentMessageBlock[];
|
|
320
|
+
tools?: AgentToolBlock[];
|
|
321
|
+
agents?: Array<AgentSource & {
|
|
322
|
+
state: AgentRunState;
|
|
323
|
+
stopConfirmed?: boolean;
|
|
324
|
+
}>;
|
|
325
|
+
selection?: {
|
|
326
|
+
requested: {
|
|
327
|
+
model: string | null;
|
|
328
|
+
reasoningEffort: string | null;
|
|
329
|
+
};
|
|
330
|
+
effective: {
|
|
331
|
+
model: string | null;
|
|
332
|
+
reasoningEffort: string | null;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
admissionRef?: string;
|
|
336
|
+
coverage?: {
|
|
337
|
+
messages: "complete" | "truncated";
|
|
338
|
+
tools: "complete" | "truncated";
|
|
339
|
+
decisions?: "complete" | "truncated";
|
|
340
|
+
};
|
|
341
|
+
executionUsage?: {
|
|
342
|
+
sequence: Revision;
|
|
343
|
+
activeMs: number;
|
|
344
|
+
unknown: boolean;
|
|
345
|
+
};
|
|
346
|
+
/** Latest root context.updated observation; null usage explicitly clears it. */
|
|
347
|
+
latestContext?: {
|
|
348
|
+
sequence: Revision;
|
|
349
|
+
usage: Record<string, unknown> | null;
|
|
350
|
+
};
|
|
351
|
+
decisions?: Array<{
|
|
352
|
+
decision: AgentPendingDecision;
|
|
353
|
+
state: "pending" | "resolved" | "superseded" | "unknown";
|
|
354
|
+
response?: AgentApprovalResponse | AgentQuestionResponse;
|
|
355
|
+
}>;
|
|
356
|
+
pendingContinuations?: Array<{
|
|
357
|
+
requestId: string;
|
|
358
|
+
run: AgentRunRef;
|
|
359
|
+
state: "pending" | "awaiting_authorization" | "admitted" | "superseded";
|
|
360
|
+
}>;
|
|
361
|
+
};
|
|
362
|
+
export type AgentApprovalResponse = {
|
|
363
|
+
kind: "approval";
|
|
364
|
+
decision: "allow" | "deny";
|
|
365
|
+
message?: string;
|
|
366
|
+
};
|
|
367
|
+
export type AgentQuestionResponse = {
|
|
368
|
+
kind: "question";
|
|
369
|
+
answers: Record<string, string | string[]>;
|
|
370
|
+
};
|
|
371
|
+
export type AgentResponseInput = {
|
|
372
|
+
requestId: string;
|
|
373
|
+
expectedGeneration: string;
|
|
374
|
+
expectedRevision: Revision;
|
|
375
|
+
decisionId: string;
|
|
376
|
+
decisionRevision: Revision;
|
|
377
|
+
response: AgentApprovalResponse | AgentQuestionResponse;
|
|
378
|
+
};
|
|
379
|
+
export type AgentCancelInput = {
|
|
380
|
+
requestId: string;
|
|
381
|
+
} & ({
|
|
382
|
+
expectedGeneration: string;
|
|
383
|
+
expectedRevision: Revision;
|
|
384
|
+
fenceIfNotAdmitted?: never;
|
|
385
|
+
} | {
|
|
386
|
+
fenceIfNotAdmitted: {
|
|
387
|
+
sessionId: string;
|
|
388
|
+
startDigest: string;
|
|
389
|
+
};
|
|
390
|
+
expectedGeneration?: never;
|
|
391
|
+
expectedRevision?: never;
|
|
392
|
+
});
|
|
393
|
+
/** Optional execution controls share the same durable public control journal. */
|
|
394
|
+
export type AgentRunControlInput = {
|
|
395
|
+
requestId: string;
|
|
396
|
+
expectedGeneration: string;
|
|
397
|
+
expectedRevision: Revision;
|
|
398
|
+
} & ({
|
|
399
|
+
command: "park";
|
|
400
|
+
decisionId: string;
|
|
401
|
+
decisionRevision: Revision;
|
|
402
|
+
reason?: string;
|
|
403
|
+
} | {
|
|
404
|
+
command: "barrier";
|
|
405
|
+
barrierId: string;
|
|
406
|
+
kind: "task_adoption" | "child_wait" | "source_rebind" | "limits" | "human_input";
|
|
407
|
+
generation: Revision;
|
|
408
|
+
acknowledgedSequence: Revision;
|
|
409
|
+
snapshot?: string;
|
|
410
|
+
} | {
|
|
411
|
+
command: "reconcile";
|
|
412
|
+
stopped: true;
|
|
413
|
+
evidence?: string;
|
|
414
|
+
} | {
|
|
415
|
+
command: "liveConfigure";
|
|
416
|
+
mcp: AgentMcpSelection;
|
|
417
|
+
} | {
|
|
418
|
+
command: "mcpPolicy";
|
|
419
|
+
mcp: AgentMcpSelection;
|
|
420
|
+
} | {
|
|
421
|
+
command: "predictions";
|
|
422
|
+
enabled: boolean;
|
|
423
|
+
});
|
|
424
|
+
export type AgentControlReceipt = {
|
|
425
|
+
requestId: string;
|
|
426
|
+
state: "accepted" | "applied" | "rejected" | "superseded" | "unknown";
|
|
427
|
+
run: AgentRunRef;
|
|
428
|
+
revision: Revision;
|
|
429
|
+
generation?: string;
|
|
430
|
+
error?: AgentErrorDetail;
|
|
431
|
+
continuation?: {
|
|
432
|
+
run: AgentRunRef;
|
|
433
|
+
state: "pending" | "awaiting_authorization" | "admitted" | "superseded";
|
|
434
|
+
};
|
|
435
|
+
};
|
|
436
|
+
export type AgentEventType = "run.updated" | "session.bound" | "selection.updated" | "message.started" | "message.delta" | "message.completed" | "tool.started" | "tool.output" | "tool.completed" | "decision.requested" | "decision.updated" | "decision.resolved" | "control.updated" | "result.available" | "usage.updated" | "context.updated" | "agent.updated" | "warning" | "extension";
|
|
437
|
+
export type AgentEvent = {
|
|
438
|
+
schemaVersion: typeof AGENT_EVENT_VERSION;
|
|
439
|
+
runId: string;
|
|
440
|
+
generation: string;
|
|
441
|
+
sequence: Revision;
|
|
442
|
+
revision: Revision;
|
|
443
|
+
occurredAt: string;
|
|
444
|
+
type: AgentEventType;
|
|
445
|
+
source: AgentSource;
|
|
446
|
+
data: Record<string, unknown>;
|
|
447
|
+
};
|
|
448
|
+
export type AgentWatchItem = {
|
|
449
|
+
kind: "snapshot";
|
|
450
|
+
snapshot: AgentRunSnapshot;
|
|
451
|
+
} | {
|
|
452
|
+
kind: "event";
|
|
453
|
+
event: AgentEvent;
|
|
454
|
+
cursor: string;
|
|
455
|
+
};
|
|
456
|
+
/** One installation feed receipt. Its cursor is independent of the per-run replay position. */
|
|
457
|
+
export type AgentHistoryObservation = {
|
|
458
|
+
sessionId: string;
|
|
459
|
+
runId: string;
|
|
460
|
+
generation: string;
|
|
461
|
+
userId: string;
|
|
462
|
+
principalId: string;
|
|
463
|
+
item: AgentWatchItem;
|
|
464
|
+
cursor: string;
|
|
465
|
+
};
|
|
466
|
+
export type AgentErrorDetail = {
|
|
467
|
+
code: string;
|
|
468
|
+
message: string;
|
|
469
|
+
retryable: boolean;
|
|
470
|
+
requestId?: string;
|
|
471
|
+
details?: Record<string, unknown>;
|
|
472
|
+
};
|
|
473
|
+
export declare class AgentApiError extends Error {
|
|
474
|
+
readonly code: string;
|
|
475
|
+
readonly status: number;
|
|
476
|
+
readonly retryable: boolean;
|
|
477
|
+
readonly details?: Record<string, unknown> | undefined;
|
|
478
|
+
readonly requestId?: string | undefined;
|
|
479
|
+
constructor(code: string, message: string, status: number, retryable?: boolean, details?: Record<string, unknown> | undefined, requestId?: string | undefined);
|
|
480
|
+
}
|
|
481
|
+
export type AgentOperation = "capabilities" | "connections.list" | "connections.models" | "connections.usage" | "attachments.write" | "sessions.create" | "sessions.configure" | "sessions.read" | "sessions.list" | "runs.start" | "runs.read" | "runs.events" | "runs.respond" | "runs.cancel" | "runs.control" | "runs.controls.read";
|
|
482
|
+
/** Core transport names for the optional consumer-bound task workflow, without general Core tools. */
|
|
483
|
+
export declare const AGENT_SESSION_WORKFLOW_TOOLS: readonly ["task_executor_options", "task_options", "task_list", "task_get", "task_create", "task_edit", "task_action", "task_result", "task_fail", "task_request_input", "task_adopt", "task_prepare_executor", "task_delegate", "task_wait", "task_plan", "task_bind_workspace", "task_execution_get"];
|
|
484
|
+
/** Optional business workflow owned by the invoking consumer, separate from native execution. */
|
|
485
|
+
export type AgentSessionWorkflowTool = typeof AGENT_SESSION_WORKFLOW_TOOLS[number];
|
|
486
|
+
export type AgentSessionWorkflowBinding = {
|
|
487
|
+
executor: ProviderRef;
|
|
488
|
+
sessionId: string;
|
|
489
|
+
tools?: AgentSessionWorkflowTool[];
|
|
490
|
+
policy?: AgentMcpPolicy;
|
|
491
|
+
};
|
|
492
|
+
/** Public provider identities carried by exact Core mediation; never native engine IDs. */
|
|
493
|
+
export type AgentExecutionReference = {
|
|
494
|
+
provider: AgentProviderRef;
|
|
495
|
+
sessionId: string;
|
|
496
|
+
runId: string;
|
|
497
|
+
};
|
|
498
|
+
export type AgentSessionWorkflowRequest = {
|
|
499
|
+
action: string;
|
|
500
|
+
input: Record<string, unknown>;
|
|
501
|
+
agent: AgentExecutionReference;
|
|
502
|
+
source?: ProviderRef;
|
|
503
|
+
};
|
|
504
|
+
export type AgentAuthorizationRequest = {
|
|
505
|
+
operation: AgentOperation;
|
|
506
|
+
method: "GET" | "PUT" | "POST";
|
|
507
|
+
path: string;
|
|
508
|
+
bodyHash: string;
|
|
509
|
+
resources?: AgentResource[];
|
|
510
|
+
sessionId?: string;
|
|
511
|
+
runId?: string;
|
|
512
|
+
configurationDigest?: string;
|
|
513
|
+
/** Originating chat on runs.start. The consumer supplies its own app-relative viewer route. */
|
|
514
|
+
conversation?: {
|
|
515
|
+
sessionId: string;
|
|
516
|
+
viewerPath: string;
|
|
517
|
+
title: string;
|
|
518
|
+
};
|
|
519
|
+
ceiling?: {
|
|
520
|
+
mcp?: AgentMcpSelection;
|
|
521
|
+
resources?: AgentResource[];
|
|
522
|
+
deadline?: string;
|
|
523
|
+
configurationRevision?: Revision;
|
|
524
|
+
workflow?: AgentSessionWorkflowBinding;
|
|
525
|
+
};
|
|
526
|
+
};
|
|
527
|
+
export type AgentOperationAuthorization = {
|
|
528
|
+
provider: AgentProviderRef;
|
|
529
|
+
baseUrl: string;
|
|
530
|
+
token: string;
|
|
531
|
+
expiresAt: string;
|
|
532
|
+
admissionRef?: string;
|
|
533
|
+
};
|
|
534
|
+
export type AgentAuthorizer = (request: AgentAuthorizationRequest, signal?: AbortSignal) => Promise<AgentOperationAuthorization>;
|
|
535
|
+
/** Persist this value before a mutation; body is the exact UTF-8 JSON string used on every retry. */
|
|
536
|
+
export type AgentPreparedRequest<T = unknown> = AgentAuthorizationRequest & {
|
|
537
|
+
body: string;
|
|
538
|
+
readonly __result?: T;
|
|
539
|
+
};
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const AGENT_API_VERSION = 1;
|
|
2
|
+
export const AGENT_EVENT_VERSION = "agent-event.1";
|
|
3
|
+
export const AGENT_CAPABILITIES = {
|
|
4
|
+
installationHistory: "installation-history",
|
|
5
|
+
resume: "session.resume", configuration: "configuration.resume-compatible", images: "input.images",
|
|
6
|
+
noNativeTools: "native-tools.none", skills: "skills.catalog", exclusiveSkills: "skills.exclusive-selection",
|
|
7
|
+
coreMcp: "mcp.core", externalMcp: "mcp.external", modelChange: "model.change-on-resume",
|
|
8
|
+
nextTurnDecisions: "decisions.next-turn", nativeSubagents: "subagents.native", park: "runs.park",
|
|
9
|
+
barrier: "runs.barrier", reconcile: "runs.reconcile", liveConfigure: "runs.live-configure",
|
|
10
|
+
predictions: "predictions", connectionUsage: "connections.usage",
|
|
11
|
+
approvalMode: "configuration.approval-mode",
|
|
12
|
+
mcpPolicy: "mcp.policy-update", consumerWorkflow: "workflow.consumer",
|
|
13
|
+
};
|
|
14
|
+
export class AgentApiError extends Error {
|
|
15
|
+
code;
|
|
16
|
+
status;
|
|
17
|
+
retryable;
|
|
18
|
+
details;
|
|
19
|
+
requestId;
|
|
20
|
+
constructor(code, message, status, retryable = false, details, requestId) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.status = status;
|
|
24
|
+
this.retryable = retryable;
|
|
25
|
+
this.details = details;
|
|
26
|
+
this.requestId = requestId;
|
|
27
|
+
this.name = "AgentApiError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Core transport names for the optional consumer-bound task workflow, without general Core tools. */
|
|
31
|
+
export const AGENT_SESSION_WORKFLOW_TOOLS = [
|
|
32
|
+
"task_executor_options", "task_options", "task_list", "task_get", "task_create", "task_edit", "task_action",
|
|
33
|
+
"task_result", "task_fail", "task_request_input", "task_adopt", "task_prepare_executor", "task_delegate",
|
|
34
|
+
"task_wait", "task_plan", "task_bind_workspace", "task_execution_get",
|
|
35
|
+
];
|
|
@@ -39,7 +39,12 @@ export declare class ProviderClient {
|
|
|
39
39
|
signal?: AbortSignal; /** Total deadline, 1–930000 ms; defaults to five minutes. */
|
|
40
40
|
timeoutMs?: number;
|
|
41
41
|
}): Promise<SpeechResult>;
|
|
42
|
-
translationCapabilities(provider: Pick<ProviderDescriptor, "appId" | "key">, signal?: AbortSignal
|
|
42
|
+
translationCapabilities(provider: Pick<ProviderDescriptor, "appId" | "key">, signal?: AbortSignal, options?: {
|
|
43
|
+
connection: {
|
|
44
|
+
id: string;
|
|
45
|
+
revision: string;
|
|
46
|
+
};
|
|
47
|
+
}): Promise<TranslationCapabilities>;
|
|
43
48
|
/** Translate text or Markdown through the explicitly selected provider; never retries or falls back. */
|
|
44
49
|
translate(provider: Pick<ProviderDescriptor, "appId" | "key">, input: TranslationRequest, signal?: AbortSignal): Promise<TranslationResult>;
|
|
45
50
|
/** User-attributed requests preserve the assistant's existing handoff and dispatch policy. */
|
package/dist/providers-server.js
CHANGED
|
@@ -92,9 +92,18 @@ export class ProviderClient {
|
|
|
92
92
|
await dispatcher.close();
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
async translationCapabilities(provider, signal) {
|
|
95
|
+
async translationCapabilities(provider, signal, options) {
|
|
96
|
+
const connection = options?.connection;
|
|
97
|
+
if (options && (!connection || typeof connection.id !== "string" || !connection.id || connection.id.length > 200
|
|
98
|
+
|| /[\u0000-\u001f\u007f]/.test(connection.id) || typeof connection.revision !== "string" || !/^(0|[1-9][0-9]{0,19})$/.test(connection.revision)))
|
|
99
|
+
throw new ProviderError("translation_connection_invalid", "Select an exact provider connection and decimal revision.", 400);
|
|
96
100
|
const binding = await this.connect({ ...provider, kind: "translation" }, signal);
|
|
97
|
-
|
|
101
|
+
const url = new URL(`${binding.url}/capabilities`);
|
|
102
|
+
if (connection) {
|
|
103
|
+
url.searchParams.set("connectionId", connection.id);
|
|
104
|
+
url.searchParams.set("connectionRevision", connection.revision);
|
|
105
|
+
}
|
|
106
|
+
return read(await fetch(url.href, { redirect: "error", signal: signal ? AbortSignal.any([signal, AbortSignal.timeout(10_000)]) : AbortSignal.timeout(10_000), headers: { authorization: `Bearer ${binding.token}` } }));
|
|
98
107
|
}
|
|
99
108
|
/** Translate text or Markdown through the explicitly selected provider; never retries or falls back. */
|
|
100
109
|
async translate(provider, input, signal) {
|
|
@@ -142,6 +151,13 @@ export class ProviderClient {
|
|
|
142
151
|
if (invocation.version !== 2 || invocation.kind !== kind || invocation.key !== key || invocation.operation !== request.operation
|
|
143
152
|
|| !invocation.userId || !invocation.principalId || !Array.isArray(invocation.resourceIds))
|
|
144
153
|
throw new ProviderError("token_invalid", "Core returned an invalid mediated invocation.", 401);
|
|
154
|
+
const execution = invocation.agentExecution;
|
|
155
|
+
const identity = (value) => typeof value === "string" && value.length > 0 && value.length <= 512
|
|
156
|
+
&& value.trim() === value && !/[\u0000-\u001f\u007f]/.test(value);
|
|
157
|
+
if (request.operation === "session.workflow" && (kind !== "task-executor" || !execution)
|
|
158
|
+
|| execution && (!identity(execution.sessionId) || !identity(execution.runId)
|
|
159
|
+
|| !execution.provider || !identity(execution.provider.appId) || !identity(execution.provider.installationId) || !identity(execution.provider.key)))
|
|
160
|
+
throw new ProviderError("token_invalid", "Core returned an invalid admitted agent workflow binding.", 401);
|
|
145
161
|
return invocation;
|
|
146
162
|
}
|
|
147
163
|
/** Provider-side validation checks live grants on every request; never cache this result. */
|
package/dist/providers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Provider categories supported by Core. Task execution does not expose model/profile configuration. */
|
|
2
|
-
export type ProviderKind = "speech-to-text" | "assistant" | "translation" | "tasks" | "task-executor" | "conversation-history" | "agent-sessions";
|
|
2
|
+
export type ProviderKind = "agent" | "speech-to-text" | "assistant" | "translation" | "tasks" | "task-executor" | "conversation-history" | "agent-sessions";
|
|
3
3
|
export type ProviderDescriptor = {
|
|
4
4
|
appId: string;
|
|
5
5
|
displayName: string;
|
|
@@ -38,6 +38,8 @@ export type ProviderInvocation = {
|
|
|
38
38
|
};
|
|
39
39
|
/** Core-mediated v2 invocations carry the original principal; direct clients have no app identity. */
|
|
40
40
|
export type MediatedProviderInvocation = {
|
|
41
|
+
/** Present for exact session.workflow requests under retained admitted agent authority. */
|
|
42
|
+
agentExecution?: import("./agent.js").AgentExecutionReference;
|
|
41
43
|
taskWorkflow?: TaskWorkflowBinding;
|
|
42
44
|
version: 2;
|
|
43
45
|
callerAppId: string | null;
|