@tangle-network/agent-interface 0.45.0 → 0.46.1
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 +1 -1
- package/dist/agent-candidate-profile-schema.d.ts +2 -2
- package/dist/agent-candidate-promotion-schema.d.ts +22 -22
- package/dist/agent-candidate-schema-common.js +1 -1
- package/dist/agent-candidate-schema.d.ts +2 -2
- package/dist/agent-execution-preparation.d.ts +26 -26
- package/dist/agent-profile.d.ts +10 -3
- package/dist/agent-profile.js +45 -22
- package/dist/backend-message.d.ts +14 -0
- package/dist/backend-message.js +1 -0
- package/dist/contract-limits.d.ts +26 -0
- package/dist/contract-limits.js +175 -0
- package/dist/environment-exact-process.d.ts +161 -0
- package/dist/environment-exact-process.js +1 -0
- package/dist/environment-profile-capabilities.d.ts +26 -0
- package/dist/environment-profile-capabilities.js +34 -0
- package/dist/environment-provider.d.ts +3 -730
- package/dist/environment-provider.js +3 -245
- package/dist/environment-requests.d.ts +70 -0
- package/dist/environment-requests.js +1 -0
- package/dist/environment-runtime.d.ts +834 -0
- package/dist/environment-runtime.js +228 -0
- package/dist/execution-types.d.ts +50 -0
- package/dist/execution-types.js +1 -0
- package/dist/host-services.d.ts +91 -0
- package/dist/host-services.js +1 -0
- package/dist/index.d.ts +10 -617
- package/dist/index.js +10 -125
- package/dist/interaction-answer-validation.d.ts +13 -0
- package/dist/interaction-answer-validation.js +149 -0
- package/dist/interaction-data.d.ts +22 -0
- package/dist/interaction-data.js +46 -0
- package/dist/interaction-envelope.d.ts +267 -0
- package/dist/interaction-envelope.js +247 -0
- package/dist/interaction-fields.d.ts +130 -0
- package/dist/interaction-fields.js +227 -0
- package/dist/interaction-permissions.d.ts +28 -0
- package/dist/interaction-permissions.js +57 -0
- package/dist/interaction-resolution-validation.d.ts +9 -0
- package/dist/interaction-resolution-validation.js +50 -0
- package/dist/interaction-response-validation.d.ts +17 -0
- package/dist/interaction-response-validation.js +102 -0
- package/dist/interaction.d.ts +6 -397
- package/dist/interaction.js +6 -603
- package/dist/mcp.d.ts +38 -0
- package/dist/mcp.js +1 -0
- package/dist/parts.d.ts +104 -0
- package/dist/parts.js +55 -0
- package/dist/portable-context-base.d.ts +82 -0
- package/dist/portable-context-base.js +63 -0
- package/dist/portable-context-continuation.d.ts +168 -0
- package/dist/portable-context-continuation.js +194 -0
- package/dist/portable-context-plan-request.d.ts +86 -0
- package/dist/portable-context-plan-request.js +102 -0
- package/dist/portable-context-plan.d.ts +229 -0
- package/dist/portable-context-plan.js +241 -0
- package/dist/portable-context-shared.d.ts +36 -0
- package/dist/portable-context-shared.js +46 -0
- package/dist/portable-context-transfer.d.ts +319 -0
- package/dist/portable-context-transfer.js +206 -0
- package/dist/portable-context.d.ts +5 -753
- package/dist/portable-context.js +5 -754
- package/dist/profile-diff.js +56 -47
- package/dist/provider-adapter.d.ts +45 -0
- package/dist/provider-adapter.js +1 -0
- package/dist/provider-config.d.ts +58 -0
- package/dist/provider-config.js +42 -0
- package/dist/runtime-control.d.ts +87 -10
- package/dist/runtime-control.js +159 -38
- package/dist/stream-events.d.ts +55 -0
- package/dist/stream-events.js +1 -0
- package/dist/workspace-branching-shared.d.ts +7 -0
- package/dist/workspace-branching-shared.js +20 -0
- package/dist/workspace-branching.d.ts +4 -254
- package/dist/workspace-branching.js +4 -400
- package/dist/workspace-checkpoint.d.ts +99 -0
- package/dist/workspace-checkpoint.js +169 -0
- package/dist/workspace-cleanup.d.ts +85 -0
- package/dist/workspace-cleanup.js +156 -0
- package/dist/workspace-confidentiality.d.ts +59 -0
- package/dist/workspace-confidentiality.js +123 -0
- package/dist/workspace-fork.d.ts +182 -0
- package/dist/workspace-fork.js +267 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,625 +1,18 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
/** Shared types and interfaces for SDK provider adapters. */
|
|
2
|
+
export * from "./parts.js";
|
|
3
|
+
export * from "./stream-events.js";
|
|
4
|
+
export * from "./execution-types.js";
|
|
5
|
+
export * from "./backend-message.js";
|
|
6
|
+
export * from "./provider-config.js";
|
|
7
|
+
export * from "./host-services.js";
|
|
8
|
+
export * from "./mcp.js";
|
|
9
|
+
export * from "./provider-adapter.js";
|
|
9
10
|
export type * from "./environment-provider.js";
|
|
10
|
-
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, } from "./environment-provider.js";
|
|
11
|
+
export { AgentEnvironmentCapabilitiesSchema, AgentNativeContextContinuationResultSchema, AgentTurnInputSchema, AgentTurnResultSchema, agentNativeContextContinuationResultMatchesRequest, } from "./environment-provider.js";
|
|
11
12
|
export * from "./plan.js";
|
|
12
13
|
export * from "./runtime-control.js";
|
|
13
14
|
export * from "./portable-context.js";
|
|
14
15
|
export * from "./workspace-branching.js";
|
|
15
|
-
export type BackendCapabilities = {
|
|
16
|
-
streaming: boolean;
|
|
17
|
-
toolUse: boolean;
|
|
18
|
-
reasoning: boolean;
|
|
19
|
-
multimodal: boolean;
|
|
20
|
-
contextWindow: number;
|
|
21
|
-
/**
|
|
22
|
-
* Interaction kinds this provider can originate (e.g. `["question",
|
|
23
|
-
* "permission"]`). Empty/undefined means the provider never asks the user.
|
|
24
|
-
* Consumers use this to decide what human-in-the-loop UI to offer.
|
|
25
|
-
*/
|
|
26
|
-
interactions?: string[];
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* High-signal feature flags surfaced by each provider package. Routes
|
|
30
|
-
* (chat-completions, responses) consume these to fail fast on
|
|
31
|
-
* unsupported request shapes (vision against text-only providers,
|
|
32
|
-
* `logprobs` against providers that never emit them, etc.) rather than
|
|
33
|
-
* forwarding to a CLI that will silently drop the field.
|
|
34
|
-
*
|
|
35
|
-
* Each flag describes the provider's *general* capability — model-level
|
|
36
|
-
* overrides (e.g. a non-vision Sonnet variant) belong on a runtime
|
|
37
|
-
* resolution layer downstream.
|
|
38
|
-
*/
|
|
39
|
-
export type ProviderCapabilities = {
|
|
40
|
-
/** Provider can accept image inputs (image_url / input_image parts). */
|
|
41
|
-
supportsVision: boolean;
|
|
42
|
-
/** Provider emits per-token logprobs in its event stream. */
|
|
43
|
-
supportsLogprobs: boolean;
|
|
44
|
-
/** Provider supports tool/function calling. */
|
|
45
|
-
supportsToolCalls: boolean;
|
|
46
|
-
/** Provider supports the Anthropic `computer` / OpenAI `computer_use_preview` tool. */
|
|
47
|
-
supportsComputerUse: boolean;
|
|
48
|
-
};
|
|
49
|
-
/** Base fields shared by all parts */
|
|
50
|
-
export type PartBase = {
|
|
51
|
-
id: string;
|
|
52
|
-
sessionID: string;
|
|
53
|
-
messageID: string;
|
|
54
|
-
};
|
|
55
|
-
/** Text part - contains message text content */
|
|
56
|
-
export type TextPart = PartBase & {
|
|
57
|
-
type: "text";
|
|
58
|
-
text: string;
|
|
59
|
-
};
|
|
60
|
-
/** Tool state variants - matches OpenCode's ToolState union */
|
|
61
|
-
export type ToolStatePending = {
|
|
62
|
-
status: "pending";
|
|
63
|
-
input: Record<string, unknown>;
|
|
64
|
-
raw?: string;
|
|
65
|
-
};
|
|
66
|
-
export type ToolStateRunning = {
|
|
67
|
-
status: "running";
|
|
68
|
-
input: Record<string, unknown>;
|
|
69
|
-
title?: string;
|
|
70
|
-
metadata?: Record<string, unknown>;
|
|
71
|
-
time?: {
|
|
72
|
-
start: number;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
export type ToolStateCompleted = {
|
|
76
|
-
status: "completed";
|
|
77
|
-
input: Record<string, unknown>;
|
|
78
|
-
output: unknown;
|
|
79
|
-
title?: string;
|
|
80
|
-
metadata?: Record<string, unknown>;
|
|
81
|
-
time?: {
|
|
82
|
-
start: number;
|
|
83
|
-
end: number;
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
export type ToolStateError = {
|
|
87
|
-
status: "error" | "failed";
|
|
88
|
-
input: Record<string, unknown>;
|
|
89
|
-
error?: string;
|
|
90
|
-
output?: unknown;
|
|
91
|
-
metadata?: Record<string, unknown>;
|
|
92
|
-
time?: {
|
|
93
|
-
start: number;
|
|
94
|
-
end?: number;
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
/** Full tool state union */
|
|
98
|
-
export type ToolState = ToolStatePending | ToolStateRunning | ToolStateCompleted | ToolStateError;
|
|
99
|
-
/** Tool part - contains tool execution state */
|
|
100
|
-
export type ToolPart = PartBase & {
|
|
101
|
-
type: "tool";
|
|
102
|
-
callID?: string;
|
|
103
|
-
tool: string;
|
|
104
|
-
state: ToolState;
|
|
105
|
-
metadata?: Record<string, unknown>;
|
|
106
|
-
};
|
|
107
|
-
/** Reasoning part - contains model's thinking */
|
|
108
|
-
export type ReasoningPart = PartBase & {
|
|
109
|
-
type: "reasoning";
|
|
110
|
-
text: string;
|
|
111
|
-
};
|
|
112
|
-
/** File part - references a file */
|
|
113
|
-
export type FilePart = PartBase & {
|
|
114
|
-
type: "file";
|
|
115
|
-
filename?: string;
|
|
116
|
-
mediaType?: string;
|
|
117
|
-
url?: string;
|
|
118
|
-
};
|
|
119
|
-
/** Subtask part - represents a spawned sub-agent task */
|
|
120
|
-
export type SubtaskPart = PartBase & {
|
|
121
|
-
type: "subtask";
|
|
122
|
-
prompt: string;
|
|
123
|
-
description: string;
|
|
124
|
-
agent: string;
|
|
125
|
-
};
|
|
126
|
-
/** Union of all part types */
|
|
127
|
-
export type Part = TextPart | ToolPart | ReasoningPart | FilePart | SubtaskPart;
|
|
128
|
-
/** Helper to check part type */
|
|
129
|
-
export declare function isTextPart(part: Part): part is TextPart;
|
|
130
|
-
export declare function isToolPart(part: Part): part is ToolPart;
|
|
131
|
-
export declare function isReasoningPart(part: Part): part is ReasoningPart;
|
|
132
|
-
export declare function isFilePart(part: Part): part is FilePart;
|
|
133
|
-
export declare function isSubtaskPart(part: Part): part is SubtaskPart;
|
|
134
|
-
export type InputTextPart = {
|
|
135
|
-
type: "text";
|
|
136
|
-
text: string;
|
|
137
|
-
};
|
|
138
|
-
export type InputFilePart = {
|
|
139
|
-
type: "file";
|
|
140
|
-
filename?: string;
|
|
141
|
-
mediaType?: string;
|
|
142
|
-
url?: string;
|
|
143
|
-
path?: string;
|
|
144
|
-
content?: string;
|
|
145
|
-
};
|
|
146
|
-
export type InputImagePart = {
|
|
147
|
-
type: "image";
|
|
148
|
-
filename?: string;
|
|
149
|
-
mediaType?: string;
|
|
150
|
-
url?: string;
|
|
151
|
-
path?: string;
|
|
152
|
-
};
|
|
153
|
-
export type InputPart = InputTextPart | InputFilePart | InputImagePart;
|
|
154
|
-
export declare function isInputTextPart(part: InputPart): part is InputTextPart;
|
|
155
|
-
export declare function isInputFilePart(part: InputPart): part is InputFilePart;
|
|
156
|
-
export declare function isInputImagePart(part: InputPart): part is InputImagePart;
|
|
157
|
-
export declare function normalizeInputParts(input: {
|
|
158
|
-
message?: string;
|
|
159
|
-
parts?: InputPart[];
|
|
160
|
-
}): InputPart[];
|
|
161
|
-
export declare function renderInputPartsAsText(parts: InputPart[]): string;
|
|
162
|
-
/**
|
|
163
|
-
* The primary event for all part updates from OpenCode.
|
|
164
|
-
* This is the canonical event for all part updates.
|
|
165
|
-
*/
|
|
166
|
-
export type MessagePartUpdatedEvent = {
|
|
167
|
-
type: "message.part.updated";
|
|
168
|
-
/** The updated part (text, tool, reasoning, or file) */
|
|
169
|
-
part: Part;
|
|
170
|
-
/** Text delta for incremental updates (for text parts) */
|
|
171
|
-
delta?: string;
|
|
172
|
-
};
|
|
173
|
-
/**
|
|
174
|
-
* Stream events emitted during execution.
|
|
175
|
-
*
|
|
176
|
-
* PRIMARY: `message.part.updated` - the single canonical event for all part state changes.
|
|
177
|
-
* Contains text deltas, tool state, reasoning content, and file references.
|
|
178
|
-
*/
|
|
179
|
-
export type StreamEvent = MessagePartUpdatedEvent | {
|
|
180
|
-
type: "tool-heartbeat";
|
|
181
|
-
toolName: string;
|
|
182
|
-
partId: string;
|
|
183
|
-
elapsedMs: number;
|
|
184
|
-
} | {
|
|
185
|
-
type: "tool-slow";
|
|
186
|
-
toolName: string;
|
|
187
|
-
partId: string;
|
|
188
|
-
elapsedMs: number;
|
|
189
|
-
thresholdMs: number;
|
|
190
|
-
} | {
|
|
191
|
-
type: "model-processing";
|
|
192
|
-
phase: "tool-result" | "generating" | "thinking";
|
|
193
|
-
toolName?: string;
|
|
194
|
-
elapsedMs?: number;
|
|
195
|
-
} | {
|
|
196
|
-
type: "status";
|
|
197
|
-
status: "started" | "processing" | "completed" | "failed";
|
|
198
|
-
detail?: string;
|
|
199
|
-
} | {
|
|
200
|
-
type: "warning";
|
|
201
|
-
code: string;
|
|
202
|
-
message: string;
|
|
203
|
-
} | {
|
|
204
|
-
type: "raw";
|
|
205
|
-
backend: string;
|
|
206
|
-
event: unknown;
|
|
207
|
-
} | {
|
|
208
|
-
type: "session.updated";
|
|
209
|
-
sessionId: string;
|
|
210
|
-
title?: string;
|
|
211
|
-
time?: {
|
|
212
|
-
created?: number;
|
|
213
|
-
updated?: number;
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
/** Agent asks the user; answered via `respondToInteraction`. The generalized
|
|
217
|
-
* human-in-the-loop event (question, permission, plan, …). */
|
|
218
|
-
| {
|
|
219
|
-
type: "interaction";
|
|
220
|
-
request: InteractionRequest;
|
|
221
|
-
}
|
|
222
|
-
/** Agent withdraws an outstanding interaction (no longer needs the answer). */
|
|
223
|
-
| {
|
|
224
|
-
type: "interaction.cancel";
|
|
225
|
-
id: string;
|
|
226
|
-
reason?: string;
|
|
227
|
-
}
|
|
228
|
-
/** A durable plan was committed. This event is observational, not a live ask. */
|
|
229
|
-
| {
|
|
230
|
-
type: "plan.submitted";
|
|
231
|
-
plan: DurablePlan;
|
|
232
|
-
};
|
|
233
|
-
export type ToolInvocation = {
|
|
234
|
-
toolName: string;
|
|
235
|
-
input: unknown;
|
|
236
|
-
result?: unknown;
|
|
237
|
-
/**
|
|
238
|
-
* True when the tool call failed (errored, timed out, or was rejected).
|
|
239
|
-
* Failed tools are recorded — not dropped — so the run outcome can reflect
|
|
240
|
-
* them. Consumers deriving success must treat any `isError: true` invocation
|
|
241
|
-
* as a failure signal.
|
|
242
|
-
*/
|
|
243
|
-
isError?: boolean;
|
|
244
|
-
};
|
|
245
|
-
export type TokenUsage = {
|
|
246
|
-
inputTokens: number;
|
|
247
|
-
outputTokens: number;
|
|
248
|
-
totalTokens?: number;
|
|
249
|
-
cacheReadInputTokens?: number;
|
|
250
|
-
cacheCreationInputTokens?: number;
|
|
251
|
-
/** Reasoning/thinking tokens (separate from output tokens) */
|
|
252
|
-
reasoningTokens?: number;
|
|
253
|
-
/** Direct cost in USD from the provider (if available) */
|
|
254
|
-
cost?: number;
|
|
255
|
-
};
|
|
256
|
-
export type ExecutionTiming = {
|
|
257
|
-
startedAt: number;
|
|
258
|
-
completedAt: number;
|
|
259
|
-
durationMs: number;
|
|
260
|
-
};
|
|
261
|
-
export type AgentExecutionInput = {
|
|
262
|
-
message?: string;
|
|
263
|
-
parts?: InputPart[];
|
|
264
|
-
systemPrompt: string;
|
|
265
|
-
userId?: string;
|
|
266
|
-
traceId?: string;
|
|
267
|
-
sessionId?: string;
|
|
268
|
-
workspaceRoot?: string;
|
|
269
|
-
abortSignal?: AbortSignal;
|
|
270
|
-
headers?: Record<string, string>;
|
|
271
|
-
model?: ProviderConfig["model"];
|
|
272
|
-
/**
|
|
273
|
-
* Caller-supplied idempotency key for this turn. When set, the adapter
|
|
274
|
-
* persists it on the assistant message and caches the final result; a
|
|
275
|
-
* subsequent execute() with the same turnId returns the cached result
|
|
276
|
-
* instead of re-issuing the upstream LLM call. Callers should generate a
|
|
277
|
-
* fresh turnId per logical attempt and reuse the same id only for
|
|
278
|
-
* client-initiated retries of the same intent.
|
|
279
|
-
*/
|
|
280
|
-
turnId?: string;
|
|
281
|
-
/** Server-owned continuation of a previously committed plan decision. */
|
|
282
|
-
planContinuation?: PlanContinuation;
|
|
283
|
-
};
|
|
284
|
-
export type AgentExecutionResult = {
|
|
285
|
-
outcome: AgentExecutionOutcome;
|
|
286
|
-
text: string;
|
|
287
|
-
toolInvocations: ToolInvocation[];
|
|
288
|
-
reasoning?: string[];
|
|
289
|
-
sessionId?: string;
|
|
290
|
-
metadata?: Record<string, unknown>;
|
|
291
|
-
tokenUsage?: TokenUsage;
|
|
292
|
-
timing?: ExecutionTiming;
|
|
293
|
-
};
|
|
294
|
-
export type CliAuthFile = {
|
|
295
|
-
/** Relative path under the runtime home directory, for example `.codex/auth.json`. */
|
|
296
|
-
path: string;
|
|
297
|
-
/** UTF-8 file content. */
|
|
298
|
-
content: string;
|
|
299
|
-
/** Optional file mode, defaults to 0600 when materialized. */
|
|
300
|
-
mode?: number;
|
|
301
|
-
};
|
|
302
|
-
export type ProviderConfig = {
|
|
303
|
-
model: {
|
|
304
|
-
provider?: string;
|
|
305
|
-
model?: string;
|
|
306
|
-
apiKey?: string;
|
|
307
|
-
baseUrl?: string;
|
|
308
|
-
maxThinkingTokens?: number;
|
|
309
|
-
mode?: "api" | "cli";
|
|
310
|
-
/** CLI auth mode for providers that support both API-key and OAuth flows. */
|
|
311
|
-
authMode?: "api-key" | "oauth";
|
|
312
|
-
/** Optional auth payloads to materialize under the runtime home directory. */
|
|
313
|
-
authFiles?: CliAuthFile[];
|
|
314
|
-
};
|
|
315
|
-
server?: {
|
|
316
|
-
port?: number;
|
|
317
|
-
hostname?: string;
|
|
318
|
-
};
|
|
319
|
-
workspace?: {
|
|
320
|
-
rootPath: string;
|
|
321
|
-
};
|
|
322
|
-
metadata?: Record<string, unknown>;
|
|
323
|
-
/**
|
|
324
|
-
* Inline profile configuration for agent customization.
|
|
325
|
-
* Takes precedence over type-based profile resolution.
|
|
326
|
-
* Uses Record<string, unknown> to avoid circular dependency with sdk-provider-opencode.
|
|
327
|
-
*/
|
|
328
|
-
profile?: Record<string, unknown>;
|
|
329
|
-
};
|
|
330
|
-
/**
|
|
331
|
-
* OpenAI-compatible model gateway defaults that a harness adapter can project
|
|
332
|
-
* into its own env vars or config file without coupling to one concrete CLI.
|
|
333
|
-
* Explicit user config must be applied before these defaults so customer-owned
|
|
334
|
-
* workspace files and request fields keep precedence.
|
|
335
|
-
*/
|
|
336
|
-
export type ModelGatewayDefaults = {
|
|
337
|
-
/** Stable provider id used by harness config files. */
|
|
338
|
-
provider: string;
|
|
339
|
-
/** Human-readable provider name. */
|
|
340
|
-
name: string;
|
|
341
|
-
/** Root router URL without an API-version suffix. */
|
|
342
|
-
rootUrl: string;
|
|
343
|
-
/** OpenAI-compatible base URL including the API-version suffix. */
|
|
344
|
-
baseUrl: string;
|
|
345
|
-
/** Default model id exposed by the gateway. */
|
|
346
|
-
model: string;
|
|
347
|
-
/** Env var read by generated config files for gateway auth. */
|
|
348
|
-
apiKeyEnvVar: string;
|
|
349
|
-
};
|
|
350
|
-
export declare const TANGLE_ROUTER_DEFAULT_ROOT_URL = "https://router.tangle.tools";
|
|
351
|
-
export declare const TANGLE_ROUTER_DEFAULT_MODEL = "zai/glm-4.7";
|
|
352
|
-
/**
|
|
353
|
-
* Normalizes an OpenAI-compatible base URL for SDKs that append
|
|
354
|
-
* `/chat/completions` to the configured base. Existing `/vN` suffixes are
|
|
355
|
-
* preserved so explicit `/v2` endpoints do not become `/v2/v1`.
|
|
356
|
-
*/
|
|
357
|
-
export declare function normalizeOpenAiCompatibleBaseUrl(baseUrl: string): string;
|
|
358
|
-
/**
|
|
359
|
-
* Returns the platform model gateway defaults. Env overrides are read here so
|
|
360
|
-
* every harness adapter shares the same dynamic seam.
|
|
361
|
-
*/
|
|
362
|
-
export declare function resolveTangleRouterDefaults(env?: Record<string, string | undefined>): ModelGatewayDefaults;
|
|
363
|
-
/**
|
|
364
|
-
* Applies gateway defaults to a provider model config. Existing fields win.
|
|
365
|
-
*/
|
|
366
|
-
export declare function withModelGatewayDefaults<T extends ProviderConfig["model"]>(model: T, defaults?: ModelGatewayDefaults): T;
|
|
367
|
-
/**
|
|
368
|
-
* Enable/disable posture for a harness's built-in (native) web tools,
|
|
369
|
-
* resolved from an AgentProfile `tools` map. `undefined` leaves the harness
|
|
370
|
-
* default; an explicit boolean forces the tool on/off. Adapters translate
|
|
371
|
-
* this into their native control so one profile directive governs native web
|
|
372
|
-
* access uniformly: claude `--disallowed-tools WebSearch,WebFetch`, codex
|
|
373
|
-
* `-c tools.web_search=<bool>`, opencode `tools.{websearch,webfetch}`.
|
|
374
|
-
*/
|
|
375
|
-
export type NativeWebToolPosture = {
|
|
376
|
-
/** Web search tool (claude WebSearch, codex web_search, opencode websearch). */
|
|
377
|
-
search?: boolean;
|
|
378
|
-
/** Web fetch tool (claude WebFetch, opencode webfetch). codex has none. */
|
|
379
|
-
fetch?: boolean;
|
|
380
|
-
};
|
|
381
|
-
/**
|
|
382
|
-
* Map an AgentProfile `tools` map to a {@link NativeWebToolPosture}. Accepts
|
|
383
|
-
* the canonical `web_search`/`web_fetch` as well as each harness's native
|
|
384
|
-
* spelling (`WebSearch`, `webfetch`, …) — keys are normalized by stripping
|
|
385
|
-
* non-alphanumerics and lowercasing, so a single directive works everywhere.
|
|
386
|
-
* Non-boolean and unrelated tool entries are ignored.
|
|
387
|
-
*/
|
|
388
|
-
export declare function resolveNativeWebTools(tools: Record<string, boolean> | undefined): NativeWebToolPosture;
|
|
389
|
-
export type BackendMessage = {
|
|
390
|
-
id: string;
|
|
391
|
-
role: "user" | "assistant" | "system";
|
|
392
|
-
parts: Array<Part | InputPart | unknown>;
|
|
393
|
-
timestamp: string;
|
|
394
|
-
metadata?: Record<string, unknown>;
|
|
395
|
-
};
|
|
396
|
-
export type GetMessagesOptions = {
|
|
397
|
-
sessionId: string;
|
|
398
|
-
limit?: number;
|
|
399
|
-
offset?: number;
|
|
400
|
-
since?: number;
|
|
401
|
-
};
|
|
402
|
-
export type MemoryEntry = {
|
|
403
|
-
id: string;
|
|
404
|
-
type: "summary" | "fact" | "note";
|
|
405
|
-
content: string;
|
|
406
|
-
createdAt: string;
|
|
407
|
-
};
|
|
408
|
-
export type MemoryEntryInput = Omit<MemoryEntry, "id" | "createdAt">;
|
|
409
|
-
export interface SdkMemoryHost {
|
|
410
|
-
list(sessionId: string): Promise<MemoryEntry[]>;
|
|
411
|
-
remember(sessionId: string, entry: MemoryEntryInput): Promise<void>;
|
|
412
|
-
format(entries: MemoryEntry[]): string;
|
|
413
|
-
}
|
|
414
|
-
export type ToolExecutionContext = {
|
|
415
|
-
workspaceRoot?: string;
|
|
416
|
-
};
|
|
417
|
-
export type ToolDefinition = {
|
|
418
|
-
name: string;
|
|
419
|
-
description: string;
|
|
420
|
-
instruction?: string;
|
|
421
|
-
inputSchema: unknown;
|
|
422
|
-
inputSchemaJson: Record<string, unknown>;
|
|
423
|
-
outputSchema?: unknown;
|
|
424
|
-
outputSchemaJson?: Record<string, unknown>;
|
|
425
|
-
handler: (input: unknown, context: ToolExecutionContext) => Promise<unknown>;
|
|
426
|
-
};
|
|
427
|
-
export interface SdkToolHost {
|
|
428
|
-
buildPromptBlock(): string;
|
|
429
|
-
registerInstruction?(instruction: string, key?: string): void;
|
|
430
|
-
clear?(): void;
|
|
431
|
-
getRegisteredTools(): ToolDefinition[];
|
|
432
|
-
}
|
|
433
|
-
export interface SdkRecorder {
|
|
434
|
-
recordUserMessage(parts: BackendMessage["parts"]): Promise<void>;
|
|
435
|
-
appendAssistantParts(parts: BackendMessage["parts"]): Promise<void>;
|
|
436
|
-
setSessionId(sessionId?: string): Promise<void>;
|
|
437
|
-
/**
|
|
438
|
-
* Persist a streaming assistant part as it arrives. Called for every
|
|
439
|
-
* `message.part.updated` event during a turn so partial content survives
|
|
440
|
-
* a sidecar crash or abort. Implementations must dedupe per-part to
|
|
441
|
-
* avoid quadratic write amplification (the same part snapshot can be
|
|
442
|
-
* re-emitted across providers).
|
|
443
|
-
*/
|
|
444
|
-
recordAssistantPartUpdate?(part: Part, delta?: string): Promise<void>;
|
|
445
|
-
/** Carry the caller-supplied turnId; written into the assistant message
|
|
446
|
-
* metadata when that message is first persisted. */
|
|
447
|
-
setTurnId?(turnId: string): void;
|
|
448
|
-
/**
|
|
449
|
-
* Stamp the in-flight assistant message as completed and optionally cache
|
|
450
|
-
* the run result under `turnId` for idempotent retry.
|
|
451
|
-
*/
|
|
452
|
-
markTurnCompleted?(payload?: {
|
|
453
|
-
result?: Record<string, unknown>;
|
|
454
|
-
[extra: string]: unknown;
|
|
455
|
-
}): Promise<void>;
|
|
456
|
-
/**
|
|
457
|
-
* Stamp the in-flight assistant message as interrupted (graceful abort,
|
|
458
|
-
* upstream error, timeout). SIGKILL on the sidecar process bypasses this
|
|
459
|
-
* call — consumers must treat "assistant message exists with neither
|
|
460
|
-
* `completed` nor `interrupted` set" as the SIGKILL case.
|
|
461
|
-
*/
|
|
462
|
-
markTurnInterrupted?(payload?: {
|
|
463
|
-
reason?: string;
|
|
464
|
-
[extra: string]: unknown;
|
|
465
|
-
}): Promise<void>;
|
|
466
|
-
/**
|
|
467
|
-
* Look up the cached result of a previously-completed turn with this id.
|
|
468
|
-
* Returns null if no such turn has completed (yet) on the recorder's
|
|
469
|
-
* configured session. Adapters call this at execute() entry to short-
|
|
470
|
-
* circuit idempotent retries without re-issuing the upstream LLM call.
|
|
471
|
-
*/
|
|
472
|
-
findCompletedTurn?(turnId: string): Promise<AgentExecutionResult | null>;
|
|
473
|
-
}
|
|
474
|
-
export type TraceEventInput = {
|
|
475
|
-
type: "message.part.updated";
|
|
476
|
-
part: Part;
|
|
477
|
-
delta?: string;
|
|
478
|
-
} | {
|
|
479
|
-
type: "message.updated";
|
|
480
|
-
text?: string;
|
|
481
|
-
finalText?: string;
|
|
482
|
-
tokenUsage?: Record<string, unknown>;
|
|
483
|
-
timing?: Record<string, unknown>;
|
|
484
|
-
toolInvocations?: unknown[];
|
|
485
|
-
metadata?: Record<string, unknown>;
|
|
486
|
-
} | {
|
|
487
|
-
type: "error";
|
|
488
|
-
category: "runtime" | "syntax" | "type" | "network" | "timeout" | "unknown";
|
|
489
|
-
message: string;
|
|
490
|
-
stack?: string;
|
|
491
|
-
code?: string;
|
|
492
|
-
source?: string;
|
|
493
|
-
} | {
|
|
494
|
-
type: "custom";
|
|
495
|
-
name: string;
|
|
496
|
-
data: Record<string, unknown>;
|
|
497
|
-
};
|
|
498
|
-
export interface SdkTraceContext {
|
|
499
|
-
addEvent(event: TraceEventInput): void;
|
|
500
|
-
addSignal(signal: string, metadata?: Record<string, unknown>): void;
|
|
501
|
-
complete(metadata?: Record<string, unknown>): void;
|
|
502
|
-
fail(error: string | Error, metadata?: Record<string, unknown>): void;
|
|
503
|
-
trackSubAgent?(childSessionId: string, agentType?: string): void;
|
|
504
|
-
}
|
|
505
|
-
export type SdkHostServices = {
|
|
506
|
-
memoryHost: SdkMemoryHost;
|
|
507
|
-
toolHost: SdkToolHost;
|
|
508
|
-
planHost: SdkPlanHost;
|
|
509
|
-
recorder: SdkRecorder;
|
|
510
|
-
providerConfig: ProviderConfig;
|
|
511
|
-
traceContext?: SdkTraceContext;
|
|
512
|
-
};
|
|
513
|
-
/**
|
|
514
|
-
* Local/stdio MCP server configuration.
|
|
515
|
-
* Runs a command locally that communicates via stdio.
|
|
516
|
-
*/
|
|
517
|
-
export type LocalMcpConfig = {
|
|
518
|
-
type: "local" | "stdio";
|
|
519
|
-
/** Command to run (string or array) */
|
|
520
|
-
command: string | string[];
|
|
521
|
-
/** Additional arguments (when command is string) */
|
|
522
|
-
args?: string[];
|
|
523
|
-
/** Environment variables for the process */
|
|
524
|
-
env?: Record<string, string>;
|
|
525
|
-
/** Enable/disable on startup */
|
|
526
|
-
enabled?: boolean;
|
|
527
|
-
/** Timeout in ms */
|
|
528
|
-
timeout?: number;
|
|
529
|
-
};
|
|
530
|
-
/**
|
|
531
|
-
* Remote/http MCP server configuration.
|
|
532
|
-
* Connects to a remote MCP server via HTTP.
|
|
533
|
-
*/
|
|
534
|
-
export type RemoteMcpConfig = {
|
|
535
|
-
type: "remote" | "http";
|
|
536
|
-
/** URL of the remote MCP server */
|
|
537
|
-
url: string;
|
|
538
|
-
/** HTTP headers to send with requests */
|
|
539
|
-
headers?: Record<string, string>;
|
|
540
|
-
/** Enable/disable on startup */
|
|
541
|
-
enabled?: boolean;
|
|
542
|
-
/** Timeout in ms */
|
|
543
|
-
timeout?: number;
|
|
544
|
-
};
|
|
545
|
-
/**
|
|
546
|
-
* MCP server configuration (local/stdio or remote/http).
|
|
547
|
-
*/
|
|
548
|
-
export type McpConfig = LocalMcpConfig | RemoteMcpConfig;
|
|
549
|
-
/**
|
|
550
|
-
* MCP server status entry.
|
|
551
|
-
*/
|
|
552
|
-
export type McpServerStatus = {
|
|
553
|
-
name: string;
|
|
554
|
-
status: "connected" | "disconnected" | "error" | "unknown";
|
|
555
|
-
type?: "local" | "remote" | "stdio" | "http";
|
|
556
|
-
error?: string;
|
|
557
|
-
};
|
|
558
|
-
/**
|
|
559
|
-
* MCP status response from getMcpStatus.
|
|
560
|
-
*/
|
|
561
|
-
export type McpStatusResponse = {
|
|
562
|
-
servers: Record<string, McpServerStatus>;
|
|
563
|
-
};
|
|
564
|
-
export type BackendListOptions = {
|
|
565
|
-
limit?: number;
|
|
566
|
-
cursor?: string;
|
|
567
|
-
};
|
|
568
|
-
export type BackendListResult<TItem> = {
|
|
569
|
-
items: TItem[];
|
|
570
|
-
nextCursor?: string;
|
|
571
|
-
};
|
|
572
|
-
export type BackendArtifact = {
|
|
573
|
-
path: string;
|
|
574
|
-
sizeBytes?: number;
|
|
575
|
-
updatedAt?: string;
|
|
576
|
-
};
|
|
577
|
-
export interface SdkProviderAdapter {
|
|
578
|
-
readonly provider: string;
|
|
579
|
-
getCapabilities(): BackendCapabilities;
|
|
580
|
-
initialize(config: ProviderConfig): Promise<void>;
|
|
581
|
-
createSession?(options?: {
|
|
582
|
-
workspaceRoot?: string;
|
|
583
|
-
}): Promise<string>;
|
|
584
|
-
forkSession?(options: {
|
|
585
|
-
sessionId: string;
|
|
586
|
-
messageId?: string;
|
|
587
|
-
workspaceRoot?: string;
|
|
588
|
-
}): Promise<string>;
|
|
589
|
-
execute(input: AgentExecutionInput, services: SdkHostServices, onEvent?: (event: StreamEvent) => void): Promise<AgentExecutionResult>;
|
|
590
|
-
shutdown(): Promise<void>;
|
|
591
|
-
healthCheck(): Promise<boolean>;
|
|
592
|
-
getMessages?(options: GetMessagesOptions): Promise<BackendMessage[]>;
|
|
593
|
-
addMcp?(name: string, config: McpConfig): Promise<void>;
|
|
594
|
-
getMcpStatus?(): Promise<McpStatusResponse>;
|
|
595
|
-
ensureMcps?(required: Record<string, McpConfig>): Promise<void>;
|
|
596
|
-
updateConfig?(config: unknown): Promise<unknown>;
|
|
597
|
-
getAccount?(): Promise<unknown>;
|
|
598
|
-
listModels?(): Promise<unknown>;
|
|
599
|
-
listRepositories?(): Promise<unknown>;
|
|
600
|
-
listAgents?(options?: BackendListOptions): Promise<unknown>;
|
|
601
|
-
getAgent?(agentId: string): Promise<unknown>;
|
|
602
|
-
archiveAgent?(agentId: string): Promise<void>;
|
|
603
|
-
unarchiveAgent?(agentId: string): Promise<void>;
|
|
604
|
-
deleteAgent?(agentId: string): Promise<void>;
|
|
605
|
-
listRuns?(agentId: string, options?: BackendListOptions): Promise<unknown>;
|
|
606
|
-
getRun?(runId: string, agentId?: string): Promise<unknown>;
|
|
607
|
-
listAgentMessages?(agentId: string, options?: BackendListOptions): Promise<unknown>;
|
|
608
|
-
listArtifacts?(sessionId: string): Promise<BackendArtifact[]>;
|
|
609
|
-
downloadArtifact?(sessionId: string, path: string): Promise<Uint8Array>;
|
|
610
|
-
/**
|
|
611
|
-
* Respond to an outstanding interaction (question, permission, …). The
|
|
612
|
-
* original best-effort inbound channel. Kept source-compatible for existing
|
|
613
|
-
* adapters; durable callers should use `respondToInteractionCommand`.
|
|
614
|
-
*/
|
|
615
|
-
respondToInteraction?(response: InteractionResponse): Promise<void>;
|
|
616
|
-
/**
|
|
617
|
-
* Retry-safe interaction response bound to an exact run and caller operation.
|
|
618
|
-
*/
|
|
619
|
-
respondToInteractionCommand?(command: InteractionResponseCommand, options?: {
|
|
620
|
-
signal?: AbortSignal;
|
|
621
|
-
}): Promise<InteractionAcknowledgement>;
|
|
622
|
-
}
|
|
623
16
|
export * from "./interaction.js";
|
|
624
17
|
export * from "./agent-candidate.js";
|
|
625
18
|
export * from "./agent-candidate-schema.js";
|