@sctg/cline-shared 3.84.0-beta.20260524130712
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 +47 -0
- package/dist/agent.d.ts +388 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/types.d.ts +967 -0
- package/dist/automation/index.d.ts +3 -0
- package/dist/automation/index.js +65 -0
- package/dist/automation/schemas.d.ts +89 -0
- package/dist/automation/types.d.ts +151 -0
- package/dist/connectors/events.d.ts +93 -0
- package/dist/connectors/options.d.ts +174 -0
- package/dist/cron/cron-spec-types.d.ts +94 -0
- package/dist/cron/index.d.ts +1 -0
- package/dist/db/index.d.ts +2 -0
- package/dist/db/index.js +80 -0
- package/dist/db/sqlite-db.d.ts +24 -0
- package/dist/dispose.d.ts +13 -0
- package/dist/extensions/context.d.ts +76 -0
- package/dist/extensions/contribution-registry.d.ts +195 -0
- package/dist/extensions/plugin.d.ts +1 -0
- package/dist/hooks/contracts.d.ts +9 -0
- package/dist/hooks/events.d.ts +194 -0
- package/dist/hub.d.ts +470 -0
- package/dist/index.browser.d.ts +61 -0
- package/dist/index.browser.js +76 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +163 -0
- package/dist/llms/ai-sdk-format.d.ts +55 -0
- package/dist/llms/gateway.d.ts +145 -0
- package/dist/llms/messages.d.ts +149 -0
- package/dist/llms/model-info.d.ts +120 -0
- package/dist/llms/reasoning-effort.d.ts +21 -0
- package/dist/llms/requests.d.ts +2 -0
- package/dist/llms/tokens.d.ts +7 -0
- package/dist/llms/tools.d.ts +86 -0
- package/dist/logging/logger.d.ts +37 -0
- package/dist/parse/error.d.ts +2 -0
- package/dist/parse/headers/utils.d.ts +1 -0
- package/dist/parse/json.d.ts +3 -0
- package/dist/parse/shell.d.ts +2 -0
- package/dist/parse/string.d.ts +4 -0
- package/dist/parse/time.d.ts +9 -0
- package/dist/parse/zod.d.ts +12 -0
- package/dist/prompt/cline.d.ts +24 -0
- package/dist/prompt/format.d.ts +11 -0
- package/dist/prompt/system.d.ts +2 -0
- package/dist/remote-config/artifact-store.d.ts +13 -0
- package/dist/remote-config/blob-storage.d.ts +47 -0
- package/dist/remote-config/bundle.d.ts +136 -0
- package/dist/remote-config/constants.d.ts +5 -0
- package/dist/remote-config/index.d.ts +9 -0
- package/dist/remote-config/index.js +76 -0
- package/dist/remote-config/materializer.d.ts +4 -0
- package/dist/remote-config/paths.d.ts +10 -0
- package/dist/remote-config/runtime.d.ts +20 -0
- package/dist/remote-config/schema.d.ts +408 -0
- package/dist/remote-config/telemetry.d.ts +9 -0
- package/dist/rpc/index.d.ts +5 -0
- package/dist/rpc/runtime.d.ts +322 -0
- package/dist/rpc/team-progress.d.ts +53 -0
- package/dist/runtime/build-env.d.ts +13 -0
- package/dist/runtime/cline-environment.d.ts +17 -0
- package/dist/runtime/hub-daemon-env.d.ts +2 -0
- package/dist/services/telemetry-config.d.ts +6 -0
- package/dist/services/telemetry.d.ts +133 -0
- package/dist/session/hook-context.d.ts +12 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/records.d.ts +31 -0
- package/dist/session/runtime-config.d.ts +26 -0
- package/dist/session/runtime-env.d.ts +8 -0
- package/dist/session/workspace.d.ts +28 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/index.js +1 -0
- package/dist/storage/path-resolution.d.ts +11 -0
- package/dist/storage/paths.d.ts +86 -0
- package/dist/team/index.d.ts +2 -0
- package/dist/team/schema.d.ts +411 -0
- package/dist/team/types.d.ts +196 -0
- package/dist/tools/create.d.ts +22 -0
- package/dist/types/auth.d.ts +20 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/vcr.d.ts +14 -0
- package/dist/vcr.d.ts +41 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# [experimental] @cline/shared
|
|
2
|
+
|
|
3
|
+
Package-level docs are centralized:
|
|
4
|
+
|
|
5
|
+
- Overview: [`packages/README.md`](../README.md)
|
|
6
|
+
- Architecture and interactions: [`ARCHITECTURE.md`](./ARCHITECTURE.md)
|
|
7
|
+
|
|
8
|
+
`@cline/shared` owns shared cross-package primitives (session common types/utilities).
|
|
9
|
+
|
|
10
|
+
Node-only filesystem path resolvers live under the storage subpath export:
|
|
11
|
+
|
|
12
|
+
- `@cline/shared/storage`
|
|
13
|
+
- examples: `resolveClineDataDir`, `resolveDbDataDir`, `resolveSessionDataDir`, `resolveTeamDataDir`
|
|
14
|
+
|
|
15
|
+
It also exports cross-client logging contracts, including `BasicLogger`, so
|
|
16
|
+
runtime, SDK, and host applications can share a single logger type.
|
|
17
|
+
|
|
18
|
+
Session config primitives are also centralized here so hosts/runtimes can
|
|
19
|
+
compose one base shape instead of redefining similar fields repeatedly:
|
|
20
|
+
|
|
21
|
+
- `AgentMode`
|
|
22
|
+
- `SessionPromptConfig`
|
|
23
|
+
- `SessionWorkspaceConfig`
|
|
24
|
+
- `SessionExecutionConfig` (includes canonical `ToolPolicy` map shape)
|
|
25
|
+
|
|
26
|
+
It now also exports hook session context primitives used across agents/core/CLI:
|
|
27
|
+
|
|
28
|
+
- `HookSessionContext`
|
|
29
|
+
- `resolveHookSessionContext(...)`
|
|
30
|
+
- `resolveRootSessionId(...)`
|
|
31
|
+
- `resolveHookLogPath(...)`
|
|
32
|
+
|
|
33
|
+
It also exports cross-client runtime payload DTOs used by multiple hosts
|
|
34
|
+
(`@cline/cli`, `@cline/code`) so request/response contracts are not duplicated
|
|
35
|
+
outside transport wiring:
|
|
36
|
+
|
|
37
|
+
- chat runtime payloads (`ChatStartSessionRequest`, `ChatRunTurnRequest`, `ChatTurnResult`)
|
|
38
|
+
- provider runtime payloads (`ProviderActionRequest`, `ProviderCatalogResponse`, `ProviderOAuthLoginResponse`)
|
|
39
|
+
- Cline account action payloads (`ClineAccountActionRequest`)
|
|
40
|
+
- provider action requests include provider catalog/model operations plus provider add/save operations for settings hosts
|
|
41
|
+
- provider action payloads now expose granular request/type contracts for reuse:
|
|
42
|
+
`AddProviderActionRequest`, `SaveProviderSettingsActionRequest`,
|
|
43
|
+
`ProviderCapability`, and `OAuthProviderId`
|
|
44
|
+
|
|
45
|
+
Chat runtime payload notes:
|
|
46
|
+
- `ChatStartSessionRequest` supports `initialMessages`, optional `toolPolicies`, optional `rules` for default system prompt assembly, and optional `logger` runtime config (`RuntimeLoggerConfig`) so hosts can pass serialized logger settings across transport boundaries.
|
|
47
|
+
- `RuntimeLoggerConfig.bindings` lets hosts attach stable context fields (for example `clientId`, `clientType`, `clientApp`) to all runtime log records.
|
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgentRuntime contract types (ported from clinee `@cline/shared`).
|
|
3
|
+
*
|
|
4
|
+
* These are the canonical type definitions consumed by `AgentRuntime`.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
import type { ModelInfo } from "./llms/model-info";
|
|
8
|
+
import type { ToolApprovalRequest, ToolApprovalResult, ToolPolicy } from "./llms/tools";
|
|
9
|
+
import type { BasicLogger } from "./logging/logger";
|
|
10
|
+
import type { ITelemetryService } from "./services/telemetry";
|
|
11
|
+
export interface AgentTextPart {
|
|
12
|
+
type: "text";
|
|
13
|
+
text: string;
|
|
14
|
+
}
|
|
15
|
+
export interface AgentReasoningPart {
|
|
16
|
+
type: "reasoning";
|
|
17
|
+
text: string;
|
|
18
|
+
redacted?: boolean;
|
|
19
|
+
metadata?: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentImagePart {
|
|
22
|
+
type: "image";
|
|
23
|
+
image: string | Uint8Array | ArrayBuffer | URL;
|
|
24
|
+
mediaType?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface AgentFilePart {
|
|
27
|
+
type: "file";
|
|
28
|
+
path: string;
|
|
29
|
+
content: string;
|
|
30
|
+
}
|
|
31
|
+
export interface AgentToolCallPart {
|
|
32
|
+
type: "tool-call";
|
|
33
|
+
toolCallId: string;
|
|
34
|
+
toolName: string;
|
|
35
|
+
input: unknown;
|
|
36
|
+
metadata?: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface AgentToolResultPart {
|
|
39
|
+
type: "tool-result";
|
|
40
|
+
toolCallId: string;
|
|
41
|
+
toolName: string;
|
|
42
|
+
output: unknown;
|
|
43
|
+
isError?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export type AgentMessagePart = AgentTextPart | AgentReasoningPart | AgentImagePart | AgentFilePart | AgentToolCallPart | AgentToolResultPart;
|
|
46
|
+
export type AgentMessageRole = "user" | "assistant" | "tool";
|
|
47
|
+
export interface AgentTokenUsage {
|
|
48
|
+
inputTokens: number;
|
|
49
|
+
outputTokens: number;
|
|
50
|
+
cacheReadTokens: number;
|
|
51
|
+
cacheWriteTokens: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Canonical `AgentUsage` shape for the new runtime.
|
|
55
|
+
*
|
|
56
|
+
* This supersedes the legacy `AgentUsage` (now `LegacyAgentUsage` in
|
|
57
|
+
* `./agents/types`). The old, host-facing shape is
|
|
58
|
+
* retained for `AgentResult`/`AgentUsageEvent` consumers via the facade.
|
|
59
|
+
*/
|
|
60
|
+
export interface AgentUsage extends AgentTokenUsage {
|
|
61
|
+
totalCost?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface AgentMessage {
|
|
64
|
+
id: string;
|
|
65
|
+
role: AgentMessageRole;
|
|
66
|
+
content: AgentMessagePart[];
|
|
67
|
+
createdAt: number;
|
|
68
|
+
metadata?: Record<string, unknown>;
|
|
69
|
+
modelInfo?: {
|
|
70
|
+
id: string;
|
|
71
|
+
provider: string;
|
|
72
|
+
family?: string;
|
|
73
|
+
};
|
|
74
|
+
metrics?: AgentTokenUsage & {
|
|
75
|
+
cost?: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export type AgentRole = string;
|
|
79
|
+
export type AgentRunStatus = "idle" | "running" | "completed" | "aborted" | "failed";
|
|
80
|
+
export interface AgentRuntimeStateSnapshot {
|
|
81
|
+
agentId: string;
|
|
82
|
+
agentRole?: AgentRole;
|
|
83
|
+
parentAgentId?: string | null;
|
|
84
|
+
conversationId?: string;
|
|
85
|
+
runId?: string;
|
|
86
|
+
status: AgentRunStatus;
|
|
87
|
+
iteration: number;
|
|
88
|
+
messages: readonly AgentMessage[];
|
|
89
|
+
pendingToolCalls: readonly string[];
|
|
90
|
+
usage: AgentUsage;
|
|
91
|
+
lastError?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface AgentToolDefinition {
|
|
94
|
+
name: string;
|
|
95
|
+
description: string;
|
|
96
|
+
inputSchema: Record<string, unknown>;
|
|
97
|
+
lifecycle?: {
|
|
98
|
+
/**
|
|
99
|
+
* Whether a successful call to this tool completes the current run.
|
|
100
|
+
*/
|
|
101
|
+
completesRun?: boolean;
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export interface AgentToolResult<TOutput = unknown> {
|
|
105
|
+
output: TOutput;
|
|
106
|
+
isError?: boolean;
|
|
107
|
+
metadata?: Record<string, unknown>;
|
|
108
|
+
}
|
|
109
|
+
export interface AgentToolContext {
|
|
110
|
+
sessionId?: string;
|
|
111
|
+
agentId: string;
|
|
112
|
+
conversationId?: string;
|
|
113
|
+
runId?: string;
|
|
114
|
+
iteration: number;
|
|
115
|
+
toolCallId?: string;
|
|
116
|
+
signal?: AbortSignal;
|
|
117
|
+
metadata?: Record<string, unknown>;
|
|
118
|
+
snapshot?: AgentRuntimeStateSnapshot;
|
|
119
|
+
emitUpdate?: (update: unknown) => void;
|
|
120
|
+
}
|
|
121
|
+
export interface AgentTool<TInput = unknown, TOutput = unknown> extends AgentToolDefinition {
|
|
122
|
+
timeoutMs?: number;
|
|
123
|
+
retryable?: boolean;
|
|
124
|
+
maxRetries?: number;
|
|
125
|
+
execute: (input: TInput, context: AgentToolContext) => Promise<TOutput> | TOutput;
|
|
126
|
+
}
|
|
127
|
+
export interface AgentModelRequest {
|
|
128
|
+
systemPrompt?: string;
|
|
129
|
+
messages: readonly AgentMessage[];
|
|
130
|
+
tools: readonly AgentToolDefinition[];
|
|
131
|
+
signal?: AbortSignal;
|
|
132
|
+
options?: Record<string, unknown>;
|
|
133
|
+
}
|
|
134
|
+
export interface AgentRuntimePrepareTurnContext {
|
|
135
|
+
agentId: string;
|
|
136
|
+
conversationId?: string;
|
|
137
|
+
parentAgentId?: string | null;
|
|
138
|
+
iteration: number;
|
|
139
|
+
messages: readonly AgentMessage[];
|
|
140
|
+
systemPrompt?: string;
|
|
141
|
+
tools: readonly AgentToolDefinition[];
|
|
142
|
+
model: {
|
|
143
|
+
id?: string;
|
|
144
|
+
provider?: string;
|
|
145
|
+
info?: ModelInfo;
|
|
146
|
+
};
|
|
147
|
+
signal?: AbortSignal;
|
|
148
|
+
emitStatusNotice?: (message: string, metadata?: Record<string, unknown>) => void;
|
|
149
|
+
}
|
|
150
|
+
export interface AgentRuntimePrepareTurnResult {
|
|
151
|
+
messages?: readonly AgentMessage[];
|
|
152
|
+
systemPrompt?: string;
|
|
153
|
+
}
|
|
154
|
+
export type AgentModelFinishReason = "stop" | "tool-calls" | "max-tokens" | "aborted" | "error";
|
|
155
|
+
export type AgentModelEvent = {
|
|
156
|
+
type: "text-delta";
|
|
157
|
+
text: string;
|
|
158
|
+
} | {
|
|
159
|
+
type: "reasoning-delta";
|
|
160
|
+
text: string;
|
|
161
|
+
redacted?: boolean;
|
|
162
|
+
metadata?: unknown;
|
|
163
|
+
} | {
|
|
164
|
+
type: "tool-call-delta";
|
|
165
|
+
index?: number;
|
|
166
|
+
toolCallId?: string;
|
|
167
|
+
toolName?: string;
|
|
168
|
+
inputText?: string;
|
|
169
|
+
input?: unknown;
|
|
170
|
+
metadata?: unknown;
|
|
171
|
+
} | {
|
|
172
|
+
type: "usage";
|
|
173
|
+
usage: Partial<AgentUsage>;
|
|
174
|
+
} | {
|
|
175
|
+
type: "finish";
|
|
176
|
+
reason: AgentModelFinishReason;
|
|
177
|
+
error?: string;
|
|
178
|
+
};
|
|
179
|
+
export interface AgentModel {
|
|
180
|
+
stream: (request: AgentModelRequest) => AsyncIterable<AgentModelEvent> | Promise<AsyncIterable<AgentModelEvent>>;
|
|
181
|
+
}
|
|
182
|
+
export interface AgentBeforeModelContext {
|
|
183
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
184
|
+
request: AgentModelRequest;
|
|
185
|
+
}
|
|
186
|
+
export interface AgentStopControl {
|
|
187
|
+
stop?: boolean;
|
|
188
|
+
reason?: string;
|
|
189
|
+
}
|
|
190
|
+
export interface AgentBeforeModelResult {
|
|
191
|
+
stop?: boolean;
|
|
192
|
+
reason?: string;
|
|
193
|
+
messages?: readonly AgentMessage[];
|
|
194
|
+
tools?: readonly AgentToolDefinition[];
|
|
195
|
+
options?: Record<string, unknown>;
|
|
196
|
+
}
|
|
197
|
+
export interface AgentAfterModelContext {
|
|
198
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
199
|
+
assistantMessage: AgentMessage;
|
|
200
|
+
finishReason: AgentModelFinishReason;
|
|
201
|
+
}
|
|
202
|
+
export interface AgentBeforeToolContext {
|
|
203
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
204
|
+
tool: AgentTool;
|
|
205
|
+
toolCall: AgentToolCallPart;
|
|
206
|
+
input: unknown;
|
|
207
|
+
}
|
|
208
|
+
export interface AgentBeforeToolResult {
|
|
209
|
+
skip?: boolean;
|
|
210
|
+
stop?: boolean;
|
|
211
|
+
reason?: string;
|
|
212
|
+
input?: unknown;
|
|
213
|
+
}
|
|
214
|
+
export interface AgentAfterToolContext {
|
|
215
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
216
|
+
tool: AgentTool;
|
|
217
|
+
toolCall: AgentToolCallPart;
|
|
218
|
+
input: unknown;
|
|
219
|
+
result: AgentToolResult;
|
|
220
|
+
startedAt: Date;
|
|
221
|
+
endedAt: Date;
|
|
222
|
+
durationMs: number;
|
|
223
|
+
}
|
|
224
|
+
export interface AgentAfterToolResult {
|
|
225
|
+
stop?: boolean;
|
|
226
|
+
reason?: string;
|
|
227
|
+
result?: AgentToolResult;
|
|
228
|
+
}
|
|
229
|
+
export interface AgentRunLifecycleContext {
|
|
230
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* 7-callback hook bag consumed by `AgentRuntime`.
|
|
234
|
+
*/
|
|
235
|
+
export interface AgentRuntimeHooks {
|
|
236
|
+
beforeRun?: (context: AgentRunLifecycleContext) => AgentStopControl | undefined | Promise<AgentStopControl | undefined>;
|
|
237
|
+
afterRun?: (context: AgentRunLifecycleContext & {
|
|
238
|
+
result: AgentRunResult;
|
|
239
|
+
}) => void | Promise<void>;
|
|
240
|
+
beforeModel?: (context: AgentBeforeModelContext) => AgentBeforeModelResult | undefined | Promise<AgentBeforeModelResult | undefined>;
|
|
241
|
+
afterModel?: (context: AgentAfterModelContext) => AgentStopControl | undefined | Promise<AgentStopControl | undefined>;
|
|
242
|
+
beforeTool?: (context: AgentBeforeToolContext) => AgentBeforeToolResult | undefined | Promise<AgentBeforeToolResult | undefined>;
|
|
243
|
+
afterTool?: (context: AgentAfterToolContext) => AgentAfterToolResult | undefined | Promise<AgentAfterToolResult | undefined>;
|
|
244
|
+
onEvent?: (event: AgentRuntimeEvent) => void | Promise<void>;
|
|
245
|
+
}
|
|
246
|
+
export interface AgentRuntimePluginContext {
|
|
247
|
+
agentId: string;
|
|
248
|
+
agentRole?: AgentRole;
|
|
249
|
+
systemPrompt?: string;
|
|
250
|
+
}
|
|
251
|
+
export interface AgentRuntimePluginSetup {
|
|
252
|
+
tools?: readonly AgentTool<any, any>[];
|
|
253
|
+
hooks?: Partial<AgentRuntimeHooks>;
|
|
254
|
+
}
|
|
255
|
+
export interface AgentRuntimePlugin {
|
|
256
|
+
name: string;
|
|
257
|
+
setup?: (context: AgentRuntimePluginContext) => AgentRuntimePluginSetup | undefined | Promise<AgentRuntimePluginSetup | undefined>;
|
|
258
|
+
}
|
|
259
|
+
export interface AgentRuntimeConfig {
|
|
260
|
+
/**
|
|
261
|
+
* Core/hub runtime session identifier.
|
|
262
|
+
*
|
|
263
|
+
* The host-owned lifecycle id for the task/session containing this runtime.
|
|
264
|
+
* It is stable for hub subscriptions, session persistence, abort/stop
|
|
265
|
+
* commands, and approval routing. It can differ from `conversationId`, which
|
|
266
|
+
* tracks the agent transcript.
|
|
267
|
+
*/
|
|
268
|
+
sessionId?: string;
|
|
269
|
+
agentId?: string;
|
|
270
|
+
/**
|
|
271
|
+
* Agent conversation/transcript identifier.
|
|
272
|
+
*
|
|
273
|
+
* Used by the stateless agent loop, tools, hooks, telemetry, and model
|
|
274
|
+
* history correlation. This id follows the current conversation store and
|
|
275
|
+
* should not be used as the hub/session routing key.
|
|
276
|
+
*/
|
|
277
|
+
conversationId?: string;
|
|
278
|
+
parentAgentId?: string | null;
|
|
279
|
+
agentRole?: AgentRole;
|
|
280
|
+
systemPrompt?: string;
|
|
281
|
+
messageModelInfo?: AgentMessage["modelInfo"];
|
|
282
|
+
model: AgentModel;
|
|
283
|
+
modelOptions?: Record<string, unknown>;
|
|
284
|
+
tools?: readonly AgentTool<any, any>[];
|
|
285
|
+
hooks?: Partial<AgentRuntimeHooks>;
|
|
286
|
+
plugins?: readonly AgentRuntimePlugin[];
|
|
287
|
+
logger?: BasicLogger;
|
|
288
|
+
telemetry?: ITelemetryService;
|
|
289
|
+
initialMessages?: readonly AgentMessage[];
|
|
290
|
+
maxIterations?: number;
|
|
291
|
+
completionPolicy?: {
|
|
292
|
+
requireCompletionTool?: boolean;
|
|
293
|
+
completionGuard?: () => string | undefined;
|
|
294
|
+
};
|
|
295
|
+
toolExecution?: "sequential" | "parallel";
|
|
296
|
+
toolPolicies?: Record<string, ToolPolicy>;
|
|
297
|
+
toolContextMetadata?: Record<string, unknown>;
|
|
298
|
+
requestToolApproval?: (request: ToolApprovalRequest) => Promise<ToolApprovalResult> | ToolApprovalResult;
|
|
299
|
+
/**
|
|
300
|
+
* Optional host-owned context pipeline that can rewrite the transcript
|
|
301
|
+
* before each model request. When it returns messages, the runtime replaces
|
|
302
|
+
* its in-memory transcript so compaction persists into the final run result.
|
|
303
|
+
*/
|
|
304
|
+
prepareTurn?: (context: AgentRuntimePrepareTurnContext) => Promise<AgentRuntimePrepareTurnResult | undefined> | AgentRuntimePrepareTurnResult | undefined;
|
|
305
|
+
consumePendingUserMessage?: () => string | undefined | Promise<string | undefined>;
|
|
306
|
+
}
|
|
307
|
+
export type AgentRuntimeEvent = {
|
|
308
|
+
type: "run-started";
|
|
309
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
310
|
+
} | {
|
|
311
|
+
type: "message-added";
|
|
312
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
313
|
+
message: AgentMessage;
|
|
314
|
+
} | {
|
|
315
|
+
type: "turn-started";
|
|
316
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
317
|
+
iteration: number;
|
|
318
|
+
} | {
|
|
319
|
+
type: "assistant-text-delta";
|
|
320
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
321
|
+
iteration: number;
|
|
322
|
+
text: string;
|
|
323
|
+
accumulatedText: string;
|
|
324
|
+
} | {
|
|
325
|
+
type: "assistant-reasoning-delta";
|
|
326
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
327
|
+
iteration: number;
|
|
328
|
+
text: string;
|
|
329
|
+
accumulatedText: string;
|
|
330
|
+
redacted?: boolean;
|
|
331
|
+
metadata?: unknown;
|
|
332
|
+
} | {
|
|
333
|
+
type: "assistant-message";
|
|
334
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
335
|
+
iteration: number;
|
|
336
|
+
message: AgentMessage;
|
|
337
|
+
finishReason: AgentModelFinishReason;
|
|
338
|
+
} | {
|
|
339
|
+
type: "tool-started";
|
|
340
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
341
|
+
iteration: number;
|
|
342
|
+
toolCall: AgentToolCallPart;
|
|
343
|
+
} | {
|
|
344
|
+
type: "tool-updated";
|
|
345
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
346
|
+
iteration: number;
|
|
347
|
+
toolCall: AgentToolCallPart;
|
|
348
|
+
update: unknown;
|
|
349
|
+
} | {
|
|
350
|
+
type: "tool-finished";
|
|
351
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
352
|
+
iteration: number;
|
|
353
|
+
toolCall: AgentToolCallPart;
|
|
354
|
+
message: AgentMessage;
|
|
355
|
+
} | {
|
|
356
|
+
type: "usage-updated";
|
|
357
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
358
|
+
usage: AgentUsage;
|
|
359
|
+
} | {
|
|
360
|
+
type: "turn-finished";
|
|
361
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
362
|
+
iteration: number;
|
|
363
|
+
toolCallCount: number;
|
|
364
|
+
} | {
|
|
365
|
+
type: "status-notice";
|
|
366
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
367
|
+
message: string;
|
|
368
|
+
metadata?: Record<string, unknown>;
|
|
369
|
+
} | {
|
|
370
|
+
type: "run-finished";
|
|
371
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
372
|
+
result: AgentRunResult;
|
|
373
|
+
} | {
|
|
374
|
+
type: "run-failed";
|
|
375
|
+
snapshot: AgentRuntimeStateSnapshot;
|
|
376
|
+
error: Error;
|
|
377
|
+
};
|
|
378
|
+
export interface AgentRunResult {
|
|
379
|
+
agentId: string;
|
|
380
|
+
agentRole?: AgentRole;
|
|
381
|
+
runId: string;
|
|
382
|
+
status: Exclude<AgentRunStatus, "idle" | "running">;
|
|
383
|
+
iterations: number;
|
|
384
|
+
outputText: string;
|
|
385
|
+
messages: readonly AgentMessage[];
|
|
386
|
+
usage: AgentUsage;
|
|
387
|
+
error?: Error;
|
|
388
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./types";
|