@ai-agent-forge/plugin-sdk 0.85.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 +27 -0
- package/dist/artifact.d.ts +20 -0
- package/dist/artifact.d.ts.map +1 -0
- package/dist/artifact.js +63 -0
- package/dist/artifact.js.map +1 -0
- package/dist/capability-manifest.d.ts +11 -0
- package/dist/capability-manifest.d.ts.map +1 -0
- package/dist/capability-manifest.js +188 -0
- package/dist/capability-manifest.js.map +1 -0
- package/dist/common.d.ts +24 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +115 -0
- package/dist/common.js.map +1 -0
- package/dist/context-budget.d.ts +33 -0
- package/dist/context-budget.d.ts.map +1 -0
- package/dist/context-budget.js +124 -0
- package/dist/context-budget.js.map +1 -0
- package/dist/diff.d.ts +38 -0
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +164 -0
- package/dist/diff.js.map +1 -0
- package/dist/durable.d.ts +108 -0
- package/dist/durable.d.ts.map +1 -0
- package/dist/durable.js +15 -0
- package/dist/durable.js.map +1 -0
- package/dist/ecosystem-manifest.d.ts +56 -0
- package/dist/ecosystem-manifest.d.ts.map +1 -0
- package/dist/ecosystem-manifest.js +11 -0
- package/dist/ecosystem-manifest.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/memory.d.ts +370 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +26 -0
- package/dist/memory.js.map +1 -0
- package/dist/observability.d.ts +354 -0
- package/dist/observability.d.ts.map +1 -0
- package/dist/observability.js +33 -0
- package/dist/observability.js.map +1 -0
- package/dist/operation.d.ts +60 -0
- package/dist/operation.d.ts.map +1 -0
- package/dist/operation.js +202 -0
- package/dist/operation.js.map +1 -0
- package/dist/public-api.d.ts +1977 -0
- package/dist/public-api.d.ts.map +1 -0
- package/dist/public-api.js +237 -0
- package/dist/public-api.js.map +1 -0
- package/dist/render.d.ts +38 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +112 -0
- package/dist/render.js.map +1 -0
- package/dist/session-lineage.d.ts +36 -0
- package/dist/session-lineage.d.ts.map +1 -0
- package/dist/session-lineage.js +134 -0
- package/dist/session-lineage.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,1977 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Experimental, host-facing contracts for capability plugins.
|
|
3
|
+
*
|
|
4
|
+
* This module deliberately contains no product policy. It describes the
|
|
5
|
+
* capabilities a host may expose; policy plugins decide how to compose them.
|
|
6
|
+
*
|
|
7
|
+
* Authority: `@agent-forge/plugin-sdk` is the single authoring source for this
|
|
8
|
+
* surface (D-075 S2); the host (`@agent-forge/agent-forge`) re-exports it from
|
|
9
|
+
* its historical module path so existing imports keep resolving.
|
|
10
|
+
*/
|
|
11
|
+
import type { MemoryStorageComponentsV1 } from "./memory.ts";
|
|
12
|
+
import type { ObservabilityHostAdapterV1, TraceSinkOptionsV1 } from "./observability.ts";
|
|
13
|
+
/** @experimental Promoted out of draft only when a real consumer drives stabilization. */
|
|
14
|
+
export declare const EXPERIMENTAL_PUBLIC_API_VERSION: "1-draft";
|
|
15
|
+
/**
|
|
16
|
+
* Thinking/reasoning level for models that support it.
|
|
17
|
+
* Note: "xhigh" and "max" are only supported by selected model families. Use model
|
|
18
|
+
* thinking-level metadata from the host to detect support for a concrete model.
|
|
19
|
+
*
|
|
20
|
+
* Authority moved from `@agent-forge/agent-core` (D-075 S2); agent-core
|
|
21
|
+
* re-exports it from here.
|
|
22
|
+
*/
|
|
23
|
+
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
24
|
+
export type HostMode = "readonly" | "full-control";
|
|
25
|
+
/** Estimated context usage for the active model; the session read face (`getContextUsage`) projects it. */
|
|
26
|
+
export interface ContextUsage {
|
|
27
|
+
/** Estimated context tokens, or null if unknown (e.g. right after compaction, before next LLM response). */
|
|
28
|
+
tokens: number | null;
|
|
29
|
+
contextWindow: number;
|
|
30
|
+
/** Context usage as percentage of context window, or null if tokens is unknown. */
|
|
31
|
+
percent: number | null;
|
|
32
|
+
}
|
|
33
|
+
export type PluginConfigValue = null | boolean | number | string | readonly PluginConfigValue[] | {
|
|
34
|
+
readonly [key: string]: PluginConfigValue;
|
|
35
|
+
};
|
|
36
|
+
/** JSON configuration declared by a plugin's own manifest. */
|
|
37
|
+
export type PluginConfig = Readonly<Record<string, PluginConfigValue>>;
|
|
38
|
+
/** Draft plugin-provided capability contract. Version is an exact integer schema version. */
|
|
39
|
+
export interface PluginCapabilityDeclaration {
|
|
40
|
+
id: string;
|
|
41
|
+
version: number;
|
|
42
|
+
kind: "service" | "contribution" | "transform";
|
|
43
|
+
}
|
|
44
|
+
/** Draft plugin capability dependency. Requirements use exact version matching. */
|
|
45
|
+
export interface PluginCapabilityRequirement {
|
|
46
|
+
id: string;
|
|
47
|
+
version: number;
|
|
48
|
+
optional?: boolean;
|
|
49
|
+
}
|
|
50
|
+
/** Roles that a plugin may expose through the experimental Agent composition facade. */
|
|
51
|
+
export type PluginAgentRole = "root-agent-controller" | "child-agent-controller";
|
|
52
|
+
/** Manifest declaration for an AgentDefinition that a plugin may register. */
|
|
53
|
+
export interface AgentDefinitionDeclaration {
|
|
54
|
+
id: string;
|
|
55
|
+
version: number;
|
|
56
|
+
role: PluginAgentRole;
|
|
57
|
+
entry: string;
|
|
58
|
+
}
|
|
59
|
+
export interface PluginManifest {
|
|
60
|
+
id: string;
|
|
61
|
+
version: string;
|
|
62
|
+
/**
|
|
63
|
+
* Semver range of host (agent-forge application) versions this plugin
|
|
64
|
+
* supports, e.g. `">=0.84.0 <1.0.0"`. When declared and the running host
|
|
65
|
+
* version is outside the range, the plugin is rejected at discovery
|
|
66
|
+
* (D-073). Paired with the plugin's own `version` (the "two version
|
|
67
|
+
* numbers" contract).
|
|
68
|
+
*/
|
|
69
|
+
hostVersion?: string;
|
|
70
|
+
apiVersion: typeof EXPERIMENTAL_PUBLIC_API_VERSION;
|
|
71
|
+
entry: string;
|
|
72
|
+
requiredCapabilities?: string[];
|
|
73
|
+
optionalCapabilities?: string[];
|
|
74
|
+
/** Plugin capabilities provided to the runtime directory. */
|
|
75
|
+
provides?: readonly PluginCapabilityDeclaration[];
|
|
76
|
+
/** Plugin capabilities required from other loaded plugins. */
|
|
77
|
+
requires?: readonly PluginCapabilityRequirement[];
|
|
78
|
+
/** Experimental Agent controller roles exposed by this plugin. */
|
|
79
|
+
roles?: readonly PluginAgentRole[];
|
|
80
|
+
/** Experimental Agent definitions that the plugin factory may register. */
|
|
81
|
+
agents?: readonly AgentDefinitionDeclaration[];
|
|
82
|
+
config?: PluginConfig;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* 子↔子/子→父的有界信箱消息(D-060 S4)。第一方信箱实现(`@agent-forge/protocol`
|
|
86
|
+
* subagent mailbox)与宿主通信接线共用此形状。
|
|
87
|
+
*/
|
|
88
|
+
export interface SubagentInboxMessageV1 {
|
|
89
|
+
/** 发送方子会话 id。 */
|
|
90
|
+
readonly from: string;
|
|
91
|
+
readonly text: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* 通信面的宿主接线(D-060 S4,与通信配置开关分离):身份绑定与血缘校验都在宿主侧,
|
|
95
|
+
* capability 只暴露模型工具面。迁自宿主 `subagent-delegate.ts`(D-075 S4 第三批)。
|
|
96
|
+
*/
|
|
97
|
+
export interface SubagentCommunicationWiringV1 {
|
|
98
|
+
/** 父侧:取走某子会话的 escalation 队列(有界、取后即清)。 */
|
|
99
|
+
drainEscalations?(sessionId: string): string[];
|
|
100
|
+
/** 子侧:向父上抛一条有界消息(发送者身份由宿主绑定,调用方无法伪造)。 */
|
|
101
|
+
postEscalate?(text: string): void;
|
|
102
|
+
/** 子侧:向同父兄弟投递一条有界消息(宿主校验双方血缘,越界同型拒绝)。 */
|
|
103
|
+
sendSibling?(toSessionId: string, text: string): void;
|
|
104
|
+
/** 子侧:取走自己收件箱里最早的至多 `limit` 条(取后即清)。 */
|
|
105
|
+
drainInbox?(limit: number): SubagentInboxMessageV1[];
|
|
106
|
+
}
|
|
107
|
+
export interface HostCapabilities {
|
|
108
|
+
apiVersion: typeof EXPERIMENTAL_PUBLIC_API_VERSION;
|
|
109
|
+
mode: HostMode;
|
|
110
|
+
features: readonly string[];
|
|
111
|
+
transports: readonly ("in-process" | "stdio" | "http" | "rpc")[];
|
|
112
|
+
/**
|
|
113
|
+
* Host agent directory (D-075 S4 second batch). Present on hosts that own
|
|
114
|
+
* an on-disk agent dir; lets plugins that keep disk state locate their
|
|
115
|
+
* config files, e.g. `<agentDir>/capabilities/<id>.json` — the same
|
|
116
|
+
* channel the host's embedded builtins used before the package split.
|
|
117
|
+
* Absent on hosts without an agent dir; plugins must treat it as optional.
|
|
118
|
+
*/
|
|
119
|
+
agentDir?: string;
|
|
120
|
+
/**
|
|
121
|
+
* Subagent communication wiring (D-075 S4 third batch, host service
|
|
122
|
+
* contract). Present on hosts that assemble a subagent mailbox for the
|
|
123
|
+
* session's delegation domain; the first-party subagent-delegate plugin
|
|
124
|
+
* binds its escalate/sibling tool faces to these callbacks (identity
|
|
125
|
+
* binding and lineage scoping stay host-side). Absent = communication
|
|
126
|
+
* tools stay unregistered (D-060 S4 default-off).
|
|
127
|
+
*/
|
|
128
|
+
communication?: SubagentCommunicationWiringV1;
|
|
129
|
+
/**
|
|
130
|
+
* Turn-scoped host context (D-075 S4 third batch, host service contract).
|
|
131
|
+
* `backgroundDigestSink` receives one bounded JSON line per settled
|
|
132
|
+
* background delegation (taskId/sessionId/status/reasonCode) for the host
|
|
133
|
+
* to inject into the parent's next model turn; `getTurnCorrelationId`
|
|
134
|
+
* returns the correlation id of the parent turn at submission time — an
|
|
135
|
+
* absent getter or undefined return means the lineage key is not written
|
|
136
|
+
* and behavior falls back. Absent = background tasks still run, just
|
|
137
|
+
* without push notification or turn-lineage attribution.
|
|
138
|
+
*/
|
|
139
|
+
turnContext?: {
|
|
140
|
+
backgroundDigestSink?: (line: string) => void;
|
|
141
|
+
getTurnCorrelationId?: () => string | undefined;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Role ids associated with the active suite (D-075 S4 third batch, host
|
|
145
|
+
* service contract). Roles are disk-only definitions
|
|
146
|
+
* (`<agentDir>/roles/<id>.json`); only associated ids surface in the
|
|
147
|
+
* delegation tool menu. Absent = the session exposes no roles (there is
|
|
148
|
+
* no built-in fallback — the engine ships none).
|
|
149
|
+
*/
|
|
150
|
+
roleAssociations?: readonly string[];
|
|
151
|
+
/**
|
|
152
|
+
* Memory storage components (D-075 S4 fourth batch, host service
|
|
153
|
+
* contract). Runtime services, not just types: a host that assembles the
|
|
154
|
+
* memory capability passes the A1/A2 storage injection face here
|
|
155
|
+
* (store/ledger factories plus optional vector components) and the
|
|
156
|
+
* first-party memory plugin binds them in place of its built-in
|
|
157
|
+
* defaults. Absent = the plugin runs its default local implementation
|
|
158
|
+
* (in-memory store + JSONL ledger under `<agentDir>/memory/`); hosts
|
|
159
|
+
* without memory support leave it undefined and the plugin registers
|
|
160
|
+
* nothing when no agentDir is declared.
|
|
161
|
+
*/
|
|
162
|
+
memoryStorage?: MemoryStorageComponentsV1;
|
|
163
|
+
}
|
|
164
|
+
export interface DisposableRegistration {
|
|
165
|
+
id: string;
|
|
166
|
+
kind: string;
|
|
167
|
+
dispose(): void | Promise<void>;
|
|
168
|
+
}
|
|
169
|
+
export type OperationStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled" | "timed_out";
|
|
170
|
+
export interface OperationHandle<TResult = unknown> {
|
|
171
|
+
id: string;
|
|
172
|
+
signal: AbortSignal;
|
|
173
|
+
status(): OperationStatus;
|
|
174
|
+
result: Promise<TResult>;
|
|
175
|
+
cancel(reason?: string): Promise<void>;
|
|
176
|
+
}
|
|
177
|
+
/** A detached, serializable progress fact emitted by a running operation. */
|
|
178
|
+
export interface OperationProgress {
|
|
179
|
+
message?: string;
|
|
180
|
+
data?: PluginConfigValue;
|
|
181
|
+
}
|
|
182
|
+
/** Execution controls available to a registered Capability operation. */
|
|
183
|
+
export interface OperationExecutionContext {
|
|
184
|
+
readonly operationId: string;
|
|
185
|
+
readonly signal: AbortSignal;
|
|
186
|
+
/** Returns false after cancellation, terminal settlement, or owner revoke. */
|
|
187
|
+
reportProgress(progress: OperationProgress): boolean;
|
|
188
|
+
}
|
|
189
|
+
export interface EventEnvelope<TData = unknown> {
|
|
190
|
+
id: string;
|
|
191
|
+
type: string;
|
|
192
|
+
version: number;
|
|
193
|
+
source: string;
|
|
194
|
+
timestamp: number;
|
|
195
|
+
correlationId: string;
|
|
196
|
+
causationId?: string;
|
|
197
|
+
data: TData;
|
|
198
|
+
}
|
|
199
|
+
/** @experimental Stage 1A draft data phase for a host lifecycle event. */
|
|
200
|
+
export type LifecyclePhase = "raw" | "candidate" | "committed";
|
|
201
|
+
/** @experimental Stage 1A draft registration kinds for the lifecycle directory. */
|
|
202
|
+
export type LifecycleRegistrationKind = "observe" | "transform" | "execute" | "after-commit";
|
|
203
|
+
/** Optional host-side buffering for an observation subscription. */
|
|
204
|
+
export interface LifecycleDeliveryOptions {
|
|
205
|
+
/** Maximum in-flight plus queued events for this one subscription. */
|
|
206
|
+
maxPendingEvents: number;
|
|
207
|
+
/** Optional UTF-8 serialized-event budget for this one subscription. */
|
|
208
|
+
maxPendingBytes?: number;
|
|
209
|
+
}
|
|
210
|
+
export type LifecycleDeliveryMode = "inline" | "bounded-queue";
|
|
211
|
+
/** Read-only subscription delivery state exposed by the runtime inspector. */
|
|
212
|
+
export interface LifecycleDeliverySnapshot {
|
|
213
|
+
mode: LifecycleDeliveryMode;
|
|
214
|
+
maxPendingEvents?: number;
|
|
215
|
+
maxPendingBytes?: number;
|
|
216
|
+
status?: "active" | "overflowed" | "closed";
|
|
217
|
+
pendingEvents?: number;
|
|
218
|
+
pendingBytes?: number;
|
|
219
|
+
accepted?: number;
|
|
220
|
+
delivered?: number;
|
|
221
|
+
rejected?: number;
|
|
222
|
+
}
|
|
223
|
+
/** @experimental Stage 1A draft lifecycle event definition. */
|
|
224
|
+
export interface LifecycleEventDefinition<TData = unknown> {
|
|
225
|
+
id: string;
|
|
226
|
+
version: number;
|
|
227
|
+
phase: LifecyclePhase;
|
|
228
|
+
/** Optional additional phases accepted by multi-phase events. */
|
|
229
|
+
allowedPhases?: readonly LifecyclePhase[];
|
|
230
|
+
schema: string;
|
|
231
|
+
/**
|
|
232
|
+
* Registration kinds permitted by this event contract. Omitted keeps the
|
|
233
|
+
* phase-compatible default for custom draft events; standard events should
|
|
234
|
+
* declare the narrowest set they support.
|
|
235
|
+
*/
|
|
236
|
+
allowedRegistrationKinds?: readonly LifecycleRegistrationKind[];
|
|
237
|
+
validate(value: unknown): TData;
|
|
238
|
+
}
|
|
239
|
+
/** A reference accepted by lifecycle registration methods. */
|
|
240
|
+
export interface LifecycleEventReference {
|
|
241
|
+
id: string;
|
|
242
|
+
version: number;
|
|
243
|
+
}
|
|
244
|
+
/** An immutable event delivered to a lifecycle handler. */
|
|
245
|
+
export interface LifecycleEvent<TData = unknown> {
|
|
246
|
+
id: string;
|
|
247
|
+
deliveryId: string;
|
|
248
|
+
type: string;
|
|
249
|
+
version: number;
|
|
250
|
+
phase: LifecyclePhase;
|
|
251
|
+
source: string;
|
|
252
|
+
timestamp: number;
|
|
253
|
+
operationId?: string;
|
|
254
|
+
correlationId?: string;
|
|
255
|
+
causationId?: string;
|
|
256
|
+
data: TData;
|
|
257
|
+
}
|
|
258
|
+
/** Input accepted by the host lifecycle dispatcher. */
|
|
259
|
+
export interface LifecycleDispatchRequest<TData = unknown> {
|
|
260
|
+
type: string;
|
|
261
|
+
version: number;
|
|
262
|
+
phase: LifecyclePhase;
|
|
263
|
+
data: TData;
|
|
264
|
+
/** Optional host cancellation fence for an in-flight lifecycle delivery. */
|
|
265
|
+
signal?: AbortSignal;
|
|
266
|
+
operationId?: string;
|
|
267
|
+
correlationId?: string;
|
|
268
|
+
causationId?: string;
|
|
269
|
+
source?: string;
|
|
270
|
+
}
|
|
271
|
+
export type LifecycleObserveHandler<TData = unknown> = (event: LifecycleEvent<TData>, signal?: AbortSignal) => void | Promise<void>;
|
|
272
|
+
export type LifecycleTransformHandler<TData = unknown> = (event: LifecycleEvent<TData>, signal?: AbortSignal) => TData | Promise<TData>;
|
|
273
|
+
/**
|
|
274
|
+
* An owner-side execution step. Execution is awaited for completion but does
|
|
275
|
+
* not replace the lifecycle event data; any owner result belongs to the
|
|
276
|
+
* operation facade that initiated the lifecycle dispatch.
|
|
277
|
+
*/
|
|
278
|
+
export type LifecycleExecuteHandler<TData = unknown> = (event: LifecycleEvent<TData>, signal?: AbortSignal) => unknown | Promise<unknown>;
|
|
279
|
+
export type LifecycleAfterCommitHandler<TData = unknown> = LifecycleObserveHandler<TData>;
|
|
280
|
+
/** A failed lifecycle delivery, retaining the original handler error. */
|
|
281
|
+
export interface LifecycleDeliveryFailure {
|
|
282
|
+
pluginId: string;
|
|
283
|
+
registrationId: string;
|
|
284
|
+
kind: LifecycleRegistrationKind;
|
|
285
|
+
error: unknown;
|
|
286
|
+
}
|
|
287
|
+
/** The delivery result is separate from the underlying operation or commit result. */
|
|
288
|
+
export interface LifecycleDeliveryReport {
|
|
289
|
+
eventId: string;
|
|
290
|
+
type: string;
|
|
291
|
+
version: number;
|
|
292
|
+
phase: LifecyclePhase;
|
|
293
|
+
status: "delivered" | "queued" | "transform-failed" | "execute-failed";
|
|
294
|
+
attempted: number;
|
|
295
|
+
succeeded: number;
|
|
296
|
+
/** Number accepted by detached subscriber queues, when non-zero. */
|
|
297
|
+
queued?: number;
|
|
298
|
+
failed: number;
|
|
299
|
+
failures: readonly LifecycleDeliveryFailure[];
|
|
300
|
+
}
|
|
301
|
+
export interface LifecycleDispatchResult<TData = unknown> {
|
|
302
|
+
event: LifecycleEvent<TData>;
|
|
303
|
+
data: TData;
|
|
304
|
+
executeResults: readonly unknown[];
|
|
305
|
+
report: LifecycleDeliveryReport;
|
|
306
|
+
}
|
|
307
|
+
/** @experimental Rejected candidate transform, with an independent delivery report. */
|
|
308
|
+
export declare class LifecycleTransformError extends Error {
|
|
309
|
+
readonly report: LifecycleDeliveryReport;
|
|
310
|
+
readonly cause: unknown;
|
|
311
|
+
constructor(cause: unknown, report: LifecycleDeliveryReport);
|
|
312
|
+
}
|
|
313
|
+
/** @experimental Rejected owner execution, with an independent delivery report. */
|
|
314
|
+
export declare class LifecycleExecuteError extends Error {
|
|
315
|
+
readonly report: LifecycleDeliveryReport;
|
|
316
|
+
readonly cause: unknown;
|
|
317
|
+
constructor(cause: unknown, report: LifecycleDeliveryReport);
|
|
318
|
+
}
|
|
319
|
+
/** @experimental Stage 1A draft lifecycle registration facade. */
|
|
320
|
+
export interface LifecycleAPI {
|
|
321
|
+
define<TData>(definition: LifecycleEventDefinition<TData>): LifecycleEventDefinition<TData>;
|
|
322
|
+
get<TData = unknown>(id: string, version: number): LifecycleEventDefinition<TData>;
|
|
323
|
+
registerObserve<TData = unknown>(event: LifecycleEventDefinition<TData> | LifecycleEventReference | string, handler: LifecycleObserveHandler<TData>, version?: number, options?: LifecycleDeliveryOptions): DisposableRegistration;
|
|
324
|
+
registerTransform<TData = unknown>(event: LifecycleEventDefinition<TData> | LifecycleEventReference | string, handler: LifecycleTransformHandler<TData>, version?: number): DisposableRegistration;
|
|
325
|
+
registerExecute<TData = unknown>(event: LifecycleEventDefinition<TData> | LifecycleEventReference | string, handler: LifecycleExecuteHandler<TData>, version?: number): DisposableRegistration;
|
|
326
|
+
registerAfterCommit<TData = unknown>(event: LifecycleEventDefinition<TData> | LifecycleEventReference | string, handler: LifecycleAfterCommitHandler<TData>, version?: number, options?: LifecycleDeliveryOptions): DisposableRegistration;
|
|
327
|
+
}
|
|
328
|
+
/** @experimental Stage 1A draft lifecycle semantics for a generic contribution point. */
|
|
329
|
+
export type ContributionLifecycle = "observe" | "transform" | "execute" | "after-commit";
|
|
330
|
+
/** @experimental Stage 1A draft contribution point declaration. */
|
|
331
|
+
export interface ContributionPointDefinition<TValue = unknown> {
|
|
332
|
+
id: string;
|
|
333
|
+
version: number;
|
|
334
|
+
schema: string;
|
|
335
|
+
lifecycle?: ContributionLifecycle;
|
|
336
|
+
validate(value: unknown): TValue;
|
|
337
|
+
}
|
|
338
|
+
/** @experimental Stage 1A draft contribution entry snapshot. */
|
|
339
|
+
export interface ContributionEntry<TValue = unknown> {
|
|
340
|
+
id: string;
|
|
341
|
+
pointId: string;
|
|
342
|
+
version: number;
|
|
343
|
+
owner: string;
|
|
344
|
+
lifecycle: ContributionLifecycle;
|
|
345
|
+
value: TValue;
|
|
346
|
+
}
|
|
347
|
+
/** @experimental Stage 1A draft contribution change notification. */
|
|
348
|
+
export interface ContributionChangeEvent<TValue = unknown> {
|
|
349
|
+
pointId: string;
|
|
350
|
+
version: number;
|
|
351
|
+
action: "added" | "removed";
|
|
352
|
+
contributionId: string;
|
|
353
|
+
owner: string;
|
|
354
|
+
entry?: ContributionEntry<TValue>;
|
|
355
|
+
}
|
|
356
|
+
/** @experimental Stage 1A draft contribution lifecycle handle. */
|
|
357
|
+
export interface ContributionHandle {
|
|
358
|
+
readonly id: string;
|
|
359
|
+
readonly pointId: string;
|
|
360
|
+
readonly version: number;
|
|
361
|
+
readonly owner: string;
|
|
362
|
+
dispose(): void | Promise<void>;
|
|
363
|
+
}
|
|
364
|
+
/** @experimental Stage 1A draft contribution point facade. */
|
|
365
|
+
export interface ContributionPoint<TValue = unknown> {
|
|
366
|
+
readonly id: string;
|
|
367
|
+
readonly version: number;
|
|
368
|
+
readonly schema: string;
|
|
369
|
+
readonly lifecycle: ContributionLifecycle;
|
|
370
|
+
add(input: {
|
|
371
|
+
id: string;
|
|
372
|
+
value: TValue;
|
|
373
|
+
}): Promise<ContributionHandle>;
|
|
374
|
+
remove(id: string): Promise<void>;
|
|
375
|
+
list(): readonly ContributionEntry<TValue>[];
|
|
376
|
+
subscribe(handler: (event: ContributionChangeEvent<TValue>) => void | Promise<void>): DisposableRegistration;
|
|
377
|
+
}
|
|
378
|
+
/** @experimental Stage 1A draft contribution registry facade. */
|
|
379
|
+
export interface ContributionAPI {
|
|
380
|
+
define<TValue>(definition: ContributionPointDefinition<TValue>): ContributionPoint<TValue>;
|
|
381
|
+
get<TValue = unknown>(id: string, version: number): ContributionPoint<TValue>;
|
|
382
|
+
list(): readonly {
|
|
383
|
+
id: string;
|
|
384
|
+
version: number;
|
|
385
|
+
schema: string;
|
|
386
|
+
lifecycle: ContributionLifecycle;
|
|
387
|
+
owner: string;
|
|
388
|
+
}[];
|
|
389
|
+
}
|
|
390
|
+
export type LoggerLevel = "debug" | "info" | "warn" | "error";
|
|
391
|
+
export interface LoggerRecord {
|
|
392
|
+
version: 1;
|
|
393
|
+
level: LoggerLevel;
|
|
394
|
+
message: string;
|
|
395
|
+
fields?: PluginConfigValue;
|
|
396
|
+
cause?: unknown;
|
|
397
|
+
pluginId: string;
|
|
398
|
+
timestamp: number;
|
|
399
|
+
sessionId?: string;
|
|
400
|
+
operationId?: string;
|
|
401
|
+
correlationId?: string;
|
|
402
|
+
phase?: string;
|
|
403
|
+
}
|
|
404
|
+
export interface LoggerAPI {
|
|
405
|
+
debug(message: string, fields?: PluginConfigValue): void;
|
|
406
|
+
info(message: string, fields?: PluginConfigValue): void;
|
|
407
|
+
warn(message: string, fields?: PluginConfigValue): void;
|
|
408
|
+
error(message: string, fields?: PluginConfigValue, cause?: unknown): void;
|
|
409
|
+
}
|
|
410
|
+
export interface DiagnosticsSpanEnd {
|
|
411
|
+
status: "ok" | "error" | "cancelled";
|
|
412
|
+
result?: PluginConfigValue;
|
|
413
|
+
cause?: unknown;
|
|
414
|
+
}
|
|
415
|
+
export interface DiagnosticsSpanSnapshot {
|
|
416
|
+
version: 1;
|
|
417
|
+
traceId: string;
|
|
418
|
+
spanId: string;
|
|
419
|
+
parentSpanId?: string;
|
|
420
|
+
name: string;
|
|
421
|
+
pluginId: string;
|
|
422
|
+
sessionId?: string;
|
|
423
|
+
startedAt: number;
|
|
424
|
+
endedAt?: number;
|
|
425
|
+
status: "running" | "ok" | "error" | "cancelled";
|
|
426
|
+
attributes: PluginConfigValue;
|
|
427
|
+
result?: PluginConfigValue;
|
|
428
|
+
cause?: unknown;
|
|
429
|
+
operationId?: string;
|
|
430
|
+
correlationId?: string;
|
|
431
|
+
phase?: string;
|
|
432
|
+
}
|
|
433
|
+
export interface DiagnosticsSpan {
|
|
434
|
+
readonly traceId: string;
|
|
435
|
+
readonly spanId: string;
|
|
436
|
+
annotate(fields: PluginConfigValue): void;
|
|
437
|
+
end(outcome?: DiagnosticsSpanEnd): void;
|
|
438
|
+
}
|
|
439
|
+
export interface DiagnosticsAPI {
|
|
440
|
+
start(name: string, attributes?: PluginConfigValue, parentSpanId?: string): DiagnosticsSpan;
|
|
441
|
+
}
|
|
442
|
+
/** @experimental Read-only runtime plugin facts exposed by the inspector. */
|
|
443
|
+
export interface RuntimeInspectorPluginSnapshot {
|
|
444
|
+
id: string;
|
|
445
|
+
version: string;
|
|
446
|
+
active: boolean;
|
|
447
|
+
manifest: PluginManifest;
|
|
448
|
+
provides: readonly PluginCapabilityDeclaration[];
|
|
449
|
+
requires: readonly PluginCapabilityRequirement[];
|
|
450
|
+
}
|
|
451
|
+
/** @experimental Read-only contribution entry facts exposed by the inspector. */
|
|
452
|
+
export interface RuntimeInspectorContributionSnapshot {
|
|
453
|
+
id: string;
|
|
454
|
+
pointId: string;
|
|
455
|
+
version: number;
|
|
456
|
+
owner: string;
|
|
457
|
+
lifecycle: ContributionLifecycle;
|
|
458
|
+
value: unknown;
|
|
459
|
+
}
|
|
460
|
+
/** @experimental Read-only contribution point facts exposed by the inspector. */
|
|
461
|
+
export interface RuntimeInspectorContributionPointSnapshot {
|
|
462
|
+
id: string;
|
|
463
|
+
version: number;
|
|
464
|
+
schema: string;
|
|
465
|
+
lifecycle: ContributionLifecycle;
|
|
466
|
+
owner: string;
|
|
467
|
+
active: boolean;
|
|
468
|
+
}
|
|
469
|
+
/** @experimental Read-only lifecycle registration facts exposed by the inspector. */
|
|
470
|
+
export interface RuntimeInspectorLifecycleRegistrationSnapshot {
|
|
471
|
+
id: string;
|
|
472
|
+
kind: LifecycleRegistrationKind;
|
|
473
|
+
owner: string;
|
|
474
|
+
active: boolean;
|
|
475
|
+
delivery: LifecycleDeliverySnapshot;
|
|
476
|
+
}
|
|
477
|
+
/** @experimental Read-only lifecycle event facts exposed by the inspector. */
|
|
478
|
+
export interface RuntimeInspectorLifecycleSnapshot {
|
|
479
|
+
id: string;
|
|
480
|
+
version: number;
|
|
481
|
+
phase: LifecyclePhase;
|
|
482
|
+
allowedPhases?: readonly LifecyclePhase[];
|
|
483
|
+
schema: string;
|
|
484
|
+
owner: string;
|
|
485
|
+
active: boolean;
|
|
486
|
+
registrations: readonly RuntimeInspectorLifecycleRegistrationSnapshot[];
|
|
487
|
+
}
|
|
488
|
+
/** Immutable error facts retained by the runtime inspector. */
|
|
489
|
+
export interface RuntimeInspectorErrorSnapshot {
|
|
490
|
+
readonly name: string;
|
|
491
|
+
readonly message: string;
|
|
492
|
+
readonly cause?: RuntimeInspectorErrorSnapshot;
|
|
493
|
+
readonly code?: string;
|
|
494
|
+
}
|
|
495
|
+
/** A normalized lifecycle delivery failure suitable for an immutable inspector snapshot. */
|
|
496
|
+
export interface RuntimeInspectorLifecycleDeliveryFailureSnapshot {
|
|
497
|
+
readonly pluginId: string;
|
|
498
|
+
readonly registrationId: string;
|
|
499
|
+
readonly kind: LifecycleRegistrationKind;
|
|
500
|
+
readonly error: RuntimeInspectorErrorSnapshot;
|
|
501
|
+
}
|
|
502
|
+
/** A bounded, immutable record of one completed lifecycle delivery. */
|
|
503
|
+
export interface RuntimeInspectorLifecycleDeliveryReportSnapshot {
|
|
504
|
+
readonly eventId: string;
|
|
505
|
+
readonly type: string;
|
|
506
|
+
readonly version: number;
|
|
507
|
+
readonly phase: LifecyclePhase;
|
|
508
|
+
readonly status: LifecycleDeliveryReport["status"];
|
|
509
|
+
readonly attempted: number;
|
|
510
|
+
readonly succeeded: number;
|
|
511
|
+
readonly queued?: number;
|
|
512
|
+
readonly failed: number;
|
|
513
|
+
readonly completedAt: number;
|
|
514
|
+
readonly failures: readonly RuntimeInspectorLifecycleDeliveryFailureSnapshot[];
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* Reason a discovered capability plugin was rejected during session startup
|
|
518
|
+
* without preventing the remaining plugins from loading (D-028).
|
|
519
|
+
*/
|
|
520
|
+
export type PluginRejectionCode = "invalid_manifest" | "host_version_incompatible" | "duplicate_plugin_id" | "missing_dependency" | "plugin_load_failed";
|
|
521
|
+
/** Structured, immutable record of one rejected capability plugin. */
|
|
522
|
+
export interface PluginRejection {
|
|
523
|
+
readonly code: PluginRejectionCode;
|
|
524
|
+
readonly manifestPath: string;
|
|
525
|
+
readonly pluginId?: string;
|
|
526
|
+
readonly message: string;
|
|
527
|
+
}
|
|
528
|
+
export interface RuntimeInspectorSnapshot {
|
|
529
|
+
version: 1;
|
|
530
|
+
host: HostCapabilities;
|
|
531
|
+
plugins: readonly RuntimeInspectorPluginSnapshot[];
|
|
532
|
+
pluginRejections: readonly PluginRejection[];
|
|
533
|
+
registrations: readonly {
|
|
534
|
+
kind: string;
|
|
535
|
+
name: string;
|
|
536
|
+
owner: string;
|
|
537
|
+
}[];
|
|
538
|
+
contributionPoints: readonly RuntimeInspectorContributionPointSnapshot[];
|
|
539
|
+
contributions: readonly RuntimeInspectorContributionSnapshot[];
|
|
540
|
+
lifecycle: readonly RuntimeInspectorLifecycleSnapshot[];
|
|
541
|
+
lifecycleReports: readonly RuntimeInspectorLifecycleDeliveryReportSnapshot[];
|
|
542
|
+
subscriptions: readonly {
|
|
543
|
+
id: string;
|
|
544
|
+
type: string;
|
|
545
|
+
owner: string;
|
|
546
|
+
}[];
|
|
547
|
+
operations: readonly {
|
|
548
|
+
id: string;
|
|
549
|
+
status: OperationStatus;
|
|
550
|
+
}[];
|
|
551
|
+
logs: readonly LoggerRecord[];
|
|
552
|
+
spans: readonly DiagnosticsSpanSnapshot[];
|
|
553
|
+
}
|
|
554
|
+
export interface RuntimeInspectorAPI {
|
|
555
|
+
snapshot(): RuntimeInspectorSnapshot;
|
|
556
|
+
}
|
|
557
|
+
export interface StateEntry {
|
|
558
|
+
key: string;
|
|
559
|
+
revision: number;
|
|
560
|
+
value: PluginConfigValue;
|
|
561
|
+
}
|
|
562
|
+
export interface StateSetOptions {
|
|
563
|
+
expectedRevision?: number;
|
|
564
|
+
operationId?: string;
|
|
565
|
+
correlationId?: string;
|
|
566
|
+
}
|
|
567
|
+
export interface StateChange {
|
|
568
|
+
/** Stable owner namespace that produced this state transition. */
|
|
569
|
+
pluginId: string;
|
|
570
|
+
key: string;
|
|
571
|
+
revision: number;
|
|
572
|
+
value?: PluginConfigValue;
|
|
573
|
+
operationId?: string;
|
|
574
|
+
correlationId?: string;
|
|
575
|
+
}
|
|
576
|
+
export interface StateAPI {
|
|
577
|
+
get(key: string): StateEntry | undefined;
|
|
578
|
+
set(key: string, value: PluginConfigValue, options?: StateSetOptions): number;
|
|
579
|
+
delete(key: string, options?: StateSetOptions): number;
|
|
580
|
+
list(prefix?: string): readonly StateEntry[];
|
|
581
|
+
watch(prefix: string | undefined, handler: (change: StateChange) => void): DisposableRegistration;
|
|
582
|
+
}
|
|
583
|
+
/** A branch-local, append-only view for plugins that persist their own state. */
|
|
584
|
+
export interface SessionEntryView {
|
|
585
|
+
id: string;
|
|
586
|
+
parentId: string | null;
|
|
587
|
+
timestamp: string;
|
|
588
|
+
type: string;
|
|
589
|
+
/** Structured message view carried by `type: "message"` entries only. */
|
|
590
|
+
message?: SessionEntryMessageView;
|
|
591
|
+
customType?: string;
|
|
592
|
+
data?: unknown;
|
|
593
|
+
}
|
|
594
|
+
/**
|
|
595
|
+
* Minimal structured projection of a message entry: only the fields consumers
|
|
596
|
+
* actually branch on (role/content). The host projects these instead of the
|
|
597
|
+
* full internal message so the view stays a stable public contract.
|
|
598
|
+
*/
|
|
599
|
+
export interface SessionEntryMessageView {
|
|
600
|
+
role: string;
|
|
601
|
+
content?: unknown;
|
|
602
|
+
}
|
|
603
|
+
/** Snapshot of a tool/command registration source, mirroring the core SourceInfo fields. */
|
|
604
|
+
export interface SourceInfoViewV1 {
|
|
605
|
+
path: string;
|
|
606
|
+
source: string;
|
|
607
|
+
scope: "user" | "project" | "temporary";
|
|
608
|
+
origin: "package" | "top-level";
|
|
609
|
+
baseDir?: string;
|
|
610
|
+
}
|
|
611
|
+
/** Tool enumeration entry: name, description, JSON-schema parameters, prompt guidelines, and source metadata. */
|
|
612
|
+
export interface ToolInfoViewV1 {
|
|
613
|
+
name: string;
|
|
614
|
+
description: string;
|
|
615
|
+
/** Parameter schema as declared on the tool definition (TypeBox). */
|
|
616
|
+
parameters: unknown;
|
|
617
|
+
promptGuidelines?: readonly string[];
|
|
618
|
+
sourceInfo: SourceInfoViewV1;
|
|
619
|
+
}
|
|
620
|
+
export type CommandSourceViewV1 = "extension" | "prompt" | "skill";
|
|
621
|
+
/** Slash command enumeration entry across extension, prompt-template, and skill sources. */
|
|
622
|
+
export interface CommandInfoViewV1 {
|
|
623
|
+
name: string;
|
|
624
|
+
description?: string;
|
|
625
|
+
source: CommandSourceViewV1;
|
|
626
|
+
sourceInfo: SourceInfoViewV1;
|
|
627
|
+
}
|
|
628
|
+
/** Provider-agnostic facts about a model, mirroring the modelRuntime.getModelFacts projection. */
|
|
629
|
+
export interface ModelFactsViewV1 {
|
|
630
|
+
provider: string;
|
|
631
|
+
id: string;
|
|
632
|
+
contextWindow: number;
|
|
633
|
+
maxTokens: number;
|
|
634
|
+
reasoning: boolean;
|
|
635
|
+
}
|
|
636
|
+
/** Scoped model entry: model facts plus the pattern's explicit thinking level, if any. */
|
|
637
|
+
export interface ScopedModelFactsViewV1 {
|
|
638
|
+
model: ModelFactsViewV1;
|
|
639
|
+
thinkingLevel?: ThinkingLevel;
|
|
640
|
+
}
|
|
641
|
+
/** A versioned, in-memory export of the current session branch. */
|
|
642
|
+
export interface SessionExportArtifact {
|
|
643
|
+
version: 1;
|
|
644
|
+
format: "jsonl";
|
|
645
|
+
mediaType: "application/x-ndjson";
|
|
646
|
+
fileName: string;
|
|
647
|
+
bytes: Uint8Array;
|
|
648
|
+
}
|
|
649
|
+
export interface SessionExportRequest {
|
|
650
|
+
format: SessionExportArtifact["format"];
|
|
651
|
+
}
|
|
652
|
+
/** Versioned, opaque session fact for optimistic host operations. */
|
|
653
|
+
export interface SessionRevisionV1 {
|
|
654
|
+
version: 1;
|
|
655
|
+
sessionId: string;
|
|
656
|
+
sequence: number;
|
|
657
|
+
leafId: string | null;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* One serializable, optimistic request to append a compaction entry.
|
|
661
|
+
*
|
|
662
|
+
* The host owns the commit decision. This value only carries the immutable
|
|
663
|
+
* facts that make retries and stale work observable to the host.
|
|
664
|
+
*/
|
|
665
|
+
export interface CompactionCommitRequestV1<TDetails = unknown> {
|
|
666
|
+
version: 1;
|
|
667
|
+
operationId: string;
|
|
668
|
+
expectedRevision: SessionRevisionV1;
|
|
669
|
+
summary: string;
|
|
670
|
+
firstKeptEntryId: string;
|
|
671
|
+
tokensBefore: number;
|
|
672
|
+
details?: TDetails;
|
|
673
|
+
fromHook?: boolean;
|
|
674
|
+
usage?: unknown;
|
|
675
|
+
}
|
|
676
|
+
export interface CompactionCommitAppliedV1 {
|
|
677
|
+
version: 1;
|
|
678
|
+
status: "committed" | "replayed";
|
|
679
|
+
entryId: string;
|
|
680
|
+
/** The revision produced by the original successful commit. */
|
|
681
|
+
revision: SessionRevisionV1;
|
|
682
|
+
}
|
|
683
|
+
export interface CompactionCommitRevisionConflictV1 {
|
|
684
|
+
version: 1;
|
|
685
|
+
status: "revision_conflict";
|
|
686
|
+
currentRevision: SessionRevisionV1;
|
|
687
|
+
}
|
|
688
|
+
export type CompactionCommitResultV1 = CompactionCommitAppliedV1 | CompactionCommitRevisionConflictV1;
|
|
689
|
+
/** A versioned execution boundary supplied by the host to an orchestration plugin. */
|
|
690
|
+
export type ExecutionPhaseV1 = "agent" | "compaction" | "overflow" | "retry" | "branch_summary" | "reload" | "tree";
|
|
691
|
+
/**
|
|
692
|
+
* Immutable input facts for a single host operation. These facts identify an
|
|
693
|
+
* optimistic commit boundary; they do not themselves grant commit authority.
|
|
694
|
+
*/
|
|
695
|
+
export interface ExecutionFactsV1 {
|
|
696
|
+
readonly version: 1;
|
|
697
|
+
readonly operationId: string;
|
|
698
|
+
readonly sessionId: string;
|
|
699
|
+
readonly inputRevision: SessionRevisionV1;
|
|
700
|
+
readonly phase: ExecutionPhaseV1;
|
|
701
|
+
}
|
|
702
|
+
/** A validated retry outcome attached to one immutable execution boundary. */
|
|
703
|
+
export interface RetryScheduleV1 extends ExecutionFactsV1 {
|
|
704
|
+
readonly action: "retry" | "stop";
|
|
705
|
+
/** `retry` is one-based; `stop` records the number of attempts already made. */
|
|
706
|
+
readonly attempt: number;
|
|
707
|
+
/** A `stop` action must not request a delay. */
|
|
708
|
+
readonly delayMs: number;
|
|
709
|
+
}
|
|
710
|
+
export type CapabilityProviderHandler<TInput = unknown, TResult = unknown> = (input: TInput, context: {
|
|
711
|
+
signal: AbortSignal;
|
|
712
|
+
}) => TResult | Promise<TResult>;
|
|
713
|
+
export interface CapabilityHandle<TResult = unknown> {
|
|
714
|
+
readonly declaration: PluginCapabilityDeclaration;
|
|
715
|
+
readonly owner: string;
|
|
716
|
+
call(input: unknown, options?: {
|
|
717
|
+
signal?: AbortSignal;
|
|
718
|
+
}): OperationHandle<TResult>;
|
|
719
|
+
}
|
|
720
|
+
export interface CapabilityDirectoryAPI {
|
|
721
|
+
provide<TInput = unknown, TResult = unknown>(declaration: PluginCapabilityDeclaration, handler: CapabilityProviderHandler<TInput, TResult>): DisposableRegistration;
|
|
722
|
+
require<TResult = unknown>(id: string, options?: {
|
|
723
|
+
version?: number;
|
|
724
|
+
}): CapabilityHandle<TResult>;
|
|
725
|
+
list(options?: {
|
|
726
|
+
kind?: PluginCapabilityDeclaration["kind"];
|
|
727
|
+
}): readonly {
|
|
728
|
+
declaration: PluginCapabilityDeclaration;
|
|
729
|
+
owner: string;
|
|
730
|
+
}[];
|
|
731
|
+
}
|
|
732
|
+
export interface OutputArtifactRef {
|
|
733
|
+
sessionId: string;
|
|
734
|
+
operationId: string;
|
|
735
|
+
artifactId: string;
|
|
736
|
+
kind: string;
|
|
737
|
+
mediaType: string;
|
|
738
|
+
sizeBytes?: number;
|
|
739
|
+
truncated: boolean;
|
|
740
|
+
createdAt: number;
|
|
741
|
+
}
|
|
742
|
+
export interface OutputArtifactChunk {
|
|
743
|
+
data: Uint8Array;
|
|
744
|
+
nextOffset?: number;
|
|
745
|
+
eof: boolean;
|
|
746
|
+
}
|
|
747
|
+
export type OutputArtifactErrorCode = "invalid_ref" | "not_found" | "cancelled";
|
|
748
|
+
export type OutputArtifactPutInput = Omit<OutputArtifactRef, "artifactId" | "sizeBytes" | "createdAt"> & {
|
|
749
|
+
data: Uint8Array | AsyncIterable<Uint8Array>;
|
|
750
|
+
};
|
|
751
|
+
export interface OutputArtifactAPI {
|
|
752
|
+
put(input: OutputArtifactPutInput, options?: {
|
|
753
|
+
signal?: AbortSignal;
|
|
754
|
+
}): Promise<OutputArtifactRef>;
|
|
755
|
+
stat(ref: OutputArtifactRef): Promise<OutputArtifactRef>;
|
|
756
|
+
read(ref: OutputArtifactRef, options?: {
|
|
757
|
+
offset?: number;
|
|
758
|
+
maxBytes?: number;
|
|
759
|
+
}): Promise<OutputArtifactChunk>;
|
|
760
|
+
}
|
|
761
|
+
export interface CredentialResolveRequest {
|
|
762
|
+
providerId: string;
|
|
763
|
+
minValidityMs?: number;
|
|
764
|
+
signal?: AbortSignal;
|
|
765
|
+
}
|
|
766
|
+
/** Resolved provider auth facts for a plugin's explicit request. */
|
|
767
|
+
export interface CredentialResolution {
|
|
768
|
+
apiKey?: string;
|
|
769
|
+
headers: Readonly<Record<string, string | null>>;
|
|
770
|
+
baseUrl?: string;
|
|
771
|
+
source?: string;
|
|
772
|
+
}
|
|
773
|
+
export interface CredentialAPI {
|
|
774
|
+
resolve(request: CredentialResolveRequest): Promise<CredentialResolution | undefined>;
|
|
775
|
+
}
|
|
776
|
+
/**
|
|
777
|
+
* Structural skill shape accepted by {@link BuildSystemPromptOptions.skills}
|
|
778
|
+
* (D-075 S2). The host's full `Skill` type carries host-owned source facts;
|
|
779
|
+
* host skill objects are structurally assignable to this projection.
|
|
780
|
+
*/
|
|
781
|
+
export interface BuildSystemPromptSkill {
|
|
782
|
+
name: string;
|
|
783
|
+
description: string;
|
|
784
|
+
filePath: string;
|
|
785
|
+
baseDir: string;
|
|
786
|
+
sourceInfo: unknown;
|
|
787
|
+
disableModelInvocation: boolean;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* System prompt assembly options (authority moved from the host's
|
|
791
|
+
* `core/system-prompt.ts`, D-075 S2; the host re-exports it from here).
|
|
792
|
+
*/
|
|
793
|
+
export interface BuildSystemPromptOptions {
|
|
794
|
+
/** Custom system prompt (replaces default). */
|
|
795
|
+
customPrompt?: string;
|
|
796
|
+
/**
|
|
797
|
+
* Session-nature orientation text (suite persona, 设计 §6.2) injected right
|
|
798
|
+
* after the opening paragraph (customPrompt branch: right after the custom
|
|
799
|
+
* prompt body), before tools, guidelines, and context files.
|
|
800
|
+
*/
|
|
801
|
+
orientationPrompt?: string;
|
|
802
|
+
/**
|
|
803
|
+
* Assistant preference card (统一修复轮 A 交付3, H2 接线): the durable
|
|
804
|
+
* user-profile card, injected immediately after the orientation section
|
|
805
|
+
* (same M2 pattern — it can also appear alone when no persona is set),
|
|
806
|
+
* before tools, guidelines, and context files.
|
|
807
|
+
*/
|
|
808
|
+
preferenceCard?: string;
|
|
809
|
+
/** Tools to include in prompt. Default: [read, bash, edit, write] */
|
|
810
|
+
selectedTools?: string[];
|
|
811
|
+
/** Optional one-line tool snippets keyed by tool name. */
|
|
812
|
+
toolSnippets?: Record<string, string>;
|
|
813
|
+
/** Additional guideline bullets appended to the default system prompt guidelines. */
|
|
814
|
+
promptGuidelines?: string[];
|
|
815
|
+
/** Text to append to system prompt. */
|
|
816
|
+
appendSystemPrompt?: string;
|
|
817
|
+
/** Working directory. */
|
|
818
|
+
cwd: string;
|
|
819
|
+
/** Pre-loaded context files. */
|
|
820
|
+
contextFiles?: Array<{
|
|
821
|
+
path: string;
|
|
822
|
+
content: string;
|
|
823
|
+
}>;
|
|
824
|
+
/** Pre-loaded skills. */
|
|
825
|
+
skills?: readonly BuildSystemPromptSkill[];
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* Public session mechanism. Product state remains plugin-owned and is written
|
|
829
|
+
* as append-only custom entries, so a plugin never mutates SessionManager
|
|
830
|
+
* internals or another branch's history.
|
|
831
|
+
*/
|
|
832
|
+
/**
|
|
833
|
+
* Terminal outcome of a prompt run. User-initiated aborts are normal outcomes:
|
|
834
|
+
* the promise resolves with `status: "aborted"` instead of rejecting.
|
|
835
|
+
*/
|
|
836
|
+
export type PromptOutcome = {
|
|
837
|
+
status: "done";
|
|
838
|
+
} | {
|
|
839
|
+
status: "aborted";
|
|
840
|
+
reason: "interrupted" | "replaced";
|
|
841
|
+
};
|
|
842
|
+
/**
|
|
843
|
+
* Content accepted by {@link SessionAPI.sendMessage}. Verbatim structural
|
|
844
|
+
* equivalent of the host's `sendCustomMessage` content type (`TextContent` /
|
|
845
|
+
* `ImageContent`), registered inline so this contract does not depend on
|
|
846
|
+
* `@agent-forge/ai`.
|
|
847
|
+
*/
|
|
848
|
+
export type SessionMessageContent = string | ({
|
|
849
|
+
type: "text";
|
|
850
|
+
text: string;
|
|
851
|
+
textSignature?: string;
|
|
852
|
+
} | {
|
|
853
|
+
type: "image";
|
|
854
|
+
data: string;
|
|
855
|
+
mimeType: string;
|
|
856
|
+
})[];
|
|
857
|
+
export interface SessionAPI {
|
|
858
|
+
getSessionId(): string;
|
|
859
|
+
/**
|
|
860
|
+
* 会话**自身**的身份(D-060 S1)。当宿主可见的 `getSessionId()` 是一个宿主侧标识
|
|
861
|
+
* (池化 runner 下是 wire 任务 id)时,本成员给出底层 agent 会话的真实 id;缺省表示
|
|
862
|
+
* 两者相同(shared 模式即如此)。
|
|
863
|
+
*/
|
|
864
|
+
getAgentSessionId?(): string;
|
|
865
|
+
/** Available on hosts that expose revision facts; required by future commit APIs. */
|
|
866
|
+
getRevision?: () => SessionRevisionV1;
|
|
867
|
+
/** Optional immutable context projection for operation-scoped Agent hosts. */
|
|
868
|
+
getContextSnapshot?: <TValue = unknown>() => AgentContextSnapshotV1<TValue>;
|
|
869
|
+
/** Optional revision-checked context commit for operation-scoped Agent hosts. */
|
|
870
|
+
commitContext?: <TValue = unknown>(request: AgentContextCommitRequestV1<TValue>) => Promise<AgentContextCommitResultV1<TValue>>;
|
|
871
|
+
getMessages(): readonly unknown[];
|
|
872
|
+
isIdle(): boolean;
|
|
873
|
+
prompt(text: string): Promise<PromptOutcome>;
|
|
874
|
+
/** Queue a steering message when the host session is running. */
|
|
875
|
+
steer?(text: string): Promise<void>;
|
|
876
|
+
/** Experimental: queue a follow-up message that waits for the active run instead of interrupting it. */
|
|
877
|
+
queueFollowUp?(text: string): Promise<void>;
|
|
878
|
+
abort(): Promise<void>;
|
|
879
|
+
waitForIdle(): Promise<void>;
|
|
880
|
+
/** Current active (prompt-visible) tool names. Available on hosts that expose the tool registry. */
|
|
881
|
+
getActiveTools?(): string[];
|
|
882
|
+
/** Replace the active tool set by name; names not in the registry are ignored. */
|
|
883
|
+
setActiveTools?(toolNames: string[]): void;
|
|
884
|
+
/** Experimental (R3 tool-enumeration slice): all configured tools with name, description, parameter schema, prompt guidelines, and source metadata. */
|
|
885
|
+
getAllTools?(): readonly ToolInfoViewV1[];
|
|
886
|
+
/**
|
|
887
|
+
* Registers a GENERIC entry projection on the underlying session
|
|
888
|
+
* (see {@link EntryProjection}). Optional: hosts without session-entry
|
|
889
|
+
* projection support reject the registration with a visible error.
|
|
890
|
+
* Returns a disposer that removes the projection.
|
|
891
|
+
*/
|
|
892
|
+
registerEntryProjection?(projection: EntryProjection): () => void;
|
|
893
|
+
/** Experimental (R3 tool-enumeration slice): slash command enumeration across extension, prompt-template, and skill sources. */
|
|
894
|
+
getCommands?(): readonly CommandInfoViewV1[];
|
|
895
|
+
/** Experimental (R3 model-domain slice): provider-agnostic facts about the current session model. */
|
|
896
|
+
getModel?(): ModelFactsViewV1 | undefined;
|
|
897
|
+
/** Experimental (R3 model-domain slice): scoped model facts with their explicit thinking levels. */
|
|
898
|
+
getScopedModels?(): readonly ScopedModelFactsViewV1[];
|
|
899
|
+
/** Experimental (R3 model-domain slice): current thinking level. */
|
|
900
|
+
getThinkingLevel?(): ThinkingLevel;
|
|
901
|
+
/** Experimental (R3 model-domain slice): set the thinking level. */
|
|
902
|
+
setThinkingLevel?(level: ThinkingLevel): void;
|
|
903
|
+
/** Experimental (R3 model-domain slice): set the session model by id (resolved against the scoped models). Resolves to false when the id is unknown or auth is not configured. */
|
|
904
|
+
setModel?(modelId: string): Promise<boolean>;
|
|
905
|
+
/** Experimental (R3 prompt-facts slice): the current system prompt. */
|
|
906
|
+
getSystemPrompt?(): string;
|
|
907
|
+
/** Experimental (R3 prompt-facts slice): the system prompt assembly options. */
|
|
908
|
+
getSystemPromptOptions?(): BuildSystemPromptOptions;
|
|
909
|
+
/** Experimental (context-facts slice): estimated usage of the current context; undefined when the host cannot measure it. */
|
|
910
|
+
getContextUsage?(): ContextUsage | undefined;
|
|
911
|
+
/**
|
|
912
|
+
* Experimental: inject a custom message into the session. Verbatim passthrough of
|
|
913
|
+
* AgentSession.sendCustomMessage (without deliverAs): streamed hosts steer with it,
|
|
914
|
+
* idle hosts append it, and `options.triggerTurn` starts a new turn.
|
|
915
|
+
*/
|
|
916
|
+
sendMessage?(message: {
|
|
917
|
+
customType: string;
|
|
918
|
+
content: SessionMessageContent;
|
|
919
|
+
display: boolean;
|
|
920
|
+
}, options?: {
|
|
921
|
+
triggerTurn?: boolean;
|
|
922
|
+
}): Promise<void>;
|
|
923
|
+
compact?(customInstructions?: string): Promise<unknown>;
|
|
924
|
+
navigateTree?(targetId: string, options?: {
|
|
925
|
+
summarize?: boolean;
|
|
926
|
+
customInstructions?: string;
|
|
927
|
+
replaceInstructions?: boolean;
|
|
928
|
+
label?: string;
|
|
929
|
+
}): Promise<unknown>;
|
|
930
|
+
appendEntry(customType: string, data?: unknown): string;
|
|
931
|
+
/** Experimental (R3 session-metadata slice): renames the session. Delegates to AgentSession.setSessionName. */
|
|
932
|
+
setSessionName?(name: string): void;
|
|
933
|
+
/** Experimental (R3 session-metadata slice): current session display name. */
|
|
934
|
+
getSessionName?(): string | undefined;
|
|
935
|
+
/** Experimental (R3 session-metadata slice): appends a label-change entry; returns the new entry id. Mirrors facade appendLabelChange. */
|
|
936
|
+
setLabel?(entryId: string, label: string | undefined): string;
|
|
937
|
+
/** Experimental (R3 session-metadata slice): current label of the branch entry. */
|
|
938
|
+
getLabel?(entryId: string): string | undefined;
|
|
939
|
+
getBranchEntries(): readonly SessionEntryView[];
|
|
940
|
+
/** Available when the host declares the `session-export` feature. */
|
|
941
|
+
exportArtifact?(request: SessionExportRequest): SessionExportArtifact;
|
|
942
|
+
}
|
|
943
|
+
/** A session view scoped to one AgentInstance execution. */
|
|
944
|
+
export interface AgentSessionFacadeV1 {
|
|
945
|
+
readonly version: 1;
|
|
946
|
+
getSessionId(): string;
|
|
947
|
+
getRevision?(): SessionRevisionV1;
|
|
948
|
+
getMessages(): readonly unknown[];
|
|
949
|
+
getBranchEntries(): readonly SessionEntryView[];
|
|
950
|
+
isIdle(): boolean;
|
|
951
|
+
prompt?(text: string): Promise<PromptOutcome>;
|
|
952
|
+
/** Queue a steering message when the host session is running. */
|
|
953
|
+
steer?(text: string): Promise<void>;
|
|
954
|
+
abort?(): Promise<void>;
|
|
955
|
+
waitForIdle(): Promise<void>;
|
|
956
|
+
appendEntry(customType: string, data?: unknown): string;
|
|
957
|
+
}
|
|
958
|
+
/** Immutable context value returned by an Agent host. */
|
|
959
|
+
export interface AgentContextSnapshotV1<TValue = unknown> {
|
|
960
|
+
readonly version: 1;
|
|
961
|
+
readonly revision: number;
|
|
962
|
+
readonly value: TValue;
|
|
963
|
+
}
|
|
964
|
+
export interface AgentContextCommitRequestV1<TValue = unknown> {
|
|
965
|
+
readonly version: 1;
|
|
966
|
+
readonly operationId: string;
|
|
967
|
+
readonly expectedRevision: number;
|
|
968
|
+
readonly value: TValue;
|
|
969
|
+
signal?: AbortSignal;
|
|
970
|
+
}
|
|
971
|
+
export interface AgentContextCommitResultV1<TValue = unknown> {
|
|
972
|
+
readonly version: 1;
|
|
973
|
+
readonly status: "committed" | "replayed";
|
|
974
|
+
readonly revision: number;
|
|
975
|
+
readonly value: TValue;
|
|
976
|
+
}
|
|
977
|
+
/** Per-instance context snapshot/commit boundary. */
|
|
978
|
+
export interface AgentContextFacadeV1 {
|
|
979
|
+
readonly version: 1;
|
|
980
|
+
get<TValue = unknown>(): AgentContextSnapshotV1<TValue>;
|
|
981
|
+
commit<TValue = unknown>(request: AgentContextCommitRequestV1<TValue>): Promise<AgentContextCommitResultV1<TValue>>;
|
|
982
|
+
}
|
|
983
|
+
/** Operation facts and cancellation boundary visible to an AgentDefinition. */
|
|
984
|
+
export interface AgentOperationFacadeV1 {
|
|
985
|
+
readonly version: 1;
|
|
986
|
+
readonly id: string;
|
|
987
|
+
readonly signal: AbortSignal;
|
|
988
|
+
status(): OperationStatus;
|
|
989
|
+
isActive(): boolean;
|
|
990
|
+
reportProgress(progress: OperationProgress): boolean;
|
|
991
|
+
onCancel(handler: (reason: unknown) => void | Promise<void>): DisposableRegistration;
|
|
992
|
+
cancel(reason?: string): Promise<void>;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Optional, host-injected primitives for one AgentDefinition execution.
|
|
996
|
+
* Implementations are scoped to the active operation and become revoked once
|
|
997
|
+
* that operation is cancelled, completes, or its controller lease is released.
|
|
998
|
+
*/
|
|
999
|
+
export interface AgentHostPrimitivesV1 {
|
|
1000
|
+
readonly version: 1;
|
|
1001
|
+
readonly session?: AgentSessionFacadeV1;
|
|
1002
|
+
readonly context?: AgentContextFacadeV1;
|
|
1003
|
+
readonly state?: StateAPI;
|
|
1004
|
+
/**
|
|
1005
|
+
* Instance-private StateAPI view for this Agent instance execution only.
|
|
1006
|
+
* Same shape and semantics as `state` (CAS, detached snapshots, watchers),
|
|
1007
|
+
* but scoped to `owner + instanceId`: invisible to sibling instances and to
|
|
1008
|
+
* the owner namespace. Runtime-memory scoped; cleared on instance dispose;
|
|
1009
|
+
* not restored on rebuild.
|
|
1010
|
+
*/
|
|
1011
|
+
readonly instanceState?: StateAPI;
|
|
1012
|
+
readonly artifact?: OutputArtifactAPI;
|
|
1013
|
+
readonly operation?: AgentOperationFacadeV1;
|
|
1014
|
+
/** Agent-only host model binding. */
|
|
1015
|
+
readonly model?: AgentModelFacadeV1;
|
|
1016
|
+
/** Agent-only host tool binding. */
|
|
1017
|
+
readonly tool?: AgentToolFacadeV1;
|
|
1018
|
+
}
|
|
1019
|
+
/**
|
|
1020
|
+
* Model facts and invoke surface bound to one Agent instance execution.
|
|
1021
|
+
*
|
|
1022
|
+
* `facts` carries provider-agnostic model metadata; `invocation` is a
|
|
1023
|
+
* single-shot completion boundary — the host resolves auth, transport and
|
|
1024
|
+
* cache routing, and provider internals never cross to the plugin. Each
|
|
1025
|
+
* invoke is exactly one completion without tools or session state.
|
|
1026
|
+
*/
|
|
1027
|
+
export interface AgentModelFacadeV1 {
|
|
1028
|
+
readonly version: 1;
|
|
1029
|
+
/** Provider-agnostic facts about the current session model. */
|
|
1030
|
+
readonly facts: AgentModelFactsV1;
|
|
1031
|
+
/** Single-shot completion boundary. */
|
|
1032
|
+
readonly invocation: AgentModelInvocationV1;
|
|
1033
|
+
}
|
|
1034
|
+
/** Provider-agnostic facts about the model the host will use for model calls. */
|
|
1035
|
+
export interface AgentModelFactsV1 {
|
|
1036
|
+
readonly provider: string;
|
|
1037
|
+
readonly id: string;
|
|
1038
|
+
readonly contextWindow: number;
|
|
1039
|
+
readonly maxTokens: number;
|
|
1040
|
+
readonly reasoning: boolean;
|
|
1041
|
+
}
|
|
1042
|
+
export interface AgentModelInvocationRequestV1 {
|
|
1043
|
+
readonly version: 1;
|
|
1044
|
+
readonly systemPrompt?: string;
|
|
1045
|
+
readonly prompt: string;
|
|
1046
|
+
readonly maxTokens?: number;
|
|
1047
|
+
readonly thinkingLevel?: ThinkingLevel;
|
|
1048
|
+
}
|
|
1049
|
+
export type AgentModelInvocationResultV1 = {
|
|
1050
|
+
readonly version: 1;
|
|
1051
|
+
readonly status: "completed";
|
|
1052
|
+
readonly text: string;
|
|
1053
|
+
readonly usage?: unknown;
|
|
1054
|
+
} | {
|
|
1055
|
+
readonly version: 1;
|
|
1056
|
+
readonly status: "aborted";
|
|
1057
|
+
} | {
|
|
1058
|
+
readonly version: 1;
|
|
1059
|
+
readonly status: "failed";
|
|
1060
|
+
readonly error: {
|
|
1061
|
+
readonly code: string;
|
|
1062
|
+
readonly message: string;
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
1065
|
+
export interface AgentModelInvocationV1 {
|
|
1066
|
+
readonly invoke: (input: AgentModelInvocationRequestV1, signal: AbortSignal) => Promise<AgentModelInvocationResultV1>;
|
|
1067
|
+
}
|
|
1068
|
+
/**
|
|
1069
|
+
* Tool invocation surface bound to one Agent instance execution. The plugin
|
|
1070
|
+
* can list and invoke tools registered in the CapabilityRuntime without
|
|
1071
|
+
* importing internal execution paths.
|
|
1072
|
+
*/
|
|
1073
|
+
export interface AgentToolFacadeV1 {
|
|
1074
|
+
readonly version: 1;
|
|
1075
|
+
/** Tool definitions keyed by name (definition + source per tool). */
|
|
1076
|
+
readonly listTools: () => readonly {
|
|
1077
|
+
readonly name: string;
|
|
1078
|
+
readonly definition: unknown;
|
|
1079
|
+
readonly source: string;
|
|
1080
|
+
/** Owning-plugin readonly-mode declaration (宪法 §6), read off the definition. */
|
|
1081
|
+
readonly readonlySafe: boolean;
|
|
1082
|
+
}[];
|
|
1083
|
+
/** Invoke a registered tool by name. */
|
|
1084
|
+
invokeTool: (name: string, input: unknown, options?: {
|
|
1085
|
+
readonly signal?: AbortSignal;
|
|
1086
|
+
}) => Promise<unknown>;
|
|
1087
|
+
}
|
|
1088
|
+
export interface AgentHostPrimitivesFactoryContext {
|
|
1089
|
+
readonly instance: AgentInstanceSnapshot;
|
|
1090
|
+
readonly operationId: string;
|
|
1091
|
+
readonly signal: AbortSignal;
|
|
1092
|
+
readonly leaseOwner: string;
|
|
1093
|
+
}
|
|
1094
|
+
export type AgentHostPrimitivesFactory = (context: AgentHostPrimitivesFactoryContext) => AgentHostPrimitivesV1 | undefined | Promise<AgentHostPrimitivesV1 | undefined>;
|
|
1095
|
+
/**
|
|
1096
|
+
* A slash command declared by a capability plugin. Names omit the leading
|
|
1097
|
+
* slash so every host can render and route the same command metadata.
|
|
1098
|
+
*/
|
|
1099
|
+
export interface CapabilityCommandDefinition {
|
|
1100
|
+
name: string;
|
|
1101
|
+
description: string;
|
|
1102
|
+
argumentHint?: string;
|
|
1103
|
+
execute(args: string, context: CapabilityCommandContext): CapabilityCommandResult | undefined | Promise<CapabilityCommandResult | undefined>;
|
|
1104
|
+
}
|
|
1105
|
+
export interface CapabilityCommandContext {
|
|
1106
|
+
signal: AbortSignal;
|
|
1107
|
+
/** Experimental: the session working directory, for commands that need cwd facts. */
|
|
1108
|
+
cwd?: string;
|
|
1109
|
+
}
|
|
1110
|
+
/**
|
|
1111
|
+
* Experimental: second argument the runtime invoke face passes to a capability
|
|
1112
|
+
* tool's execute (additive; existing single-parameter tools are unaffected).
|
|
1113
|
+
* The host injects the session working directory through
|
|
1114
|
+
* CapabilityRuntimeOptions.toolExecutionContext; without that injection the
|
|
1115
|
+
* argument stays undefined. Mirrors CapabilityCommandContext.cwd.
|
|
1116
|
+
*/
|
|
1117
|
+
export interface CapabilityToolContext {
|
|
1118
|
+
/** Experimental: the session working directory, mirroring CapabilityCommandContext.cwd. */
|
|
1119
|
+
cwd?: string;
|
|
1120
|
+
}
|
|
1121
|
+
export interface CapabilityCommandLink {
|
|
1122
|
+
label: string;
|
|
1123
|
+
url: string;
|
|
1124
|
+
}
|
|
1125
|
+
/** Host-independent, serializable result returned by a capability command. */
|
|
1126
|
+
export interface CapabilityCommandResult {
|
|
1127
|
+
status: "success" | "error";
|
|
1128
|
+
message: string;
|
|
1129
|
+
links?: readonly CapabilityCommandLink[];
|
|
1130
|
+
data?: PluginConfigValue;
|
|
1131
|
+
}
|
|
1132
|
+
export type AgentTaskStatus = "created" | "running" | "succeeded" | "failed" | "cancelled";
|
|
1133
|
+
export interface AgentTaskCreateRequest {
|
|
1134
|
+
prompt: string;
|
|
1135
|
+
metadata?: Record<string, unknown>;
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* 子任务档案(child task profile)——版本化的公共契约,经
|
|
1139
|
+
* `AgentTaskCreateRequest.metadata[AGENT_TASK_CHILD_PROFILE_KEY]` 传递。
|
|
1140
|
+
*
|
|
1141
|
+
* 用途:调用方(如子代理角色)要求宿主在**创建子会话时**收窄它的模型 / 思考级别 /
|
|
1142
|
+
* 工具面 / 会话模式,或给子会话追加一段系统提示词。所有字段都是"收窄"语义:工具面只会
|
|
1143
|
+
* 被裁到更小(与宿主自身继承面求交),模式只能更严(`readonly` 不会被放宽)。
|
|
1144
|
+
*
|
|
1145
|
+
* 契约义务(宿主 adapter 侧):
|
|
1146
|
+
* - 支持的宿主必须落地这些字段,并在 `AgentTaskHandle.session` 上暴露可核验事实
|
|
1147
|
+
* (`getActiveTools` / `getModel`)——调用方据此确认"要求已生效",而不是相信约定;
|
|
1148
|
+
* - 不支持的宿主**不得静默忽略**:应让 `create` 失败(结构化错误指名字段),因为静默
|
|
1149
|
+
* 忽略会让上层的"只读评审者"变成一句空话。
|
|
1150
|
+
*/
|
|
1151
|
+
export declare const AGENT_TASK_CHILD_PROFILE_KEY: "agent-forge.agentTaskChildProfile";
|
|
1152
|
+
/**
|
|
1153
|
+
* metadata 键:发起 create 的**父 agent 会话 id**(D-060 S1 血缘)。宿主把它写进子会话文件头
|
|
1154
|
+
* 的 `parentAgentSession`,池化下随协议 `create` 过线;读取方据此做父作用域校验与按父反查。
|
|
1155
|
+
*/
|
|
1156
|
+
export declare const AGENT_TASK_PARENT_SESSION_KEY: "agent-forge.agentTaskParentSession";
|
|
1157
|
+
/**
|
|
1158
|
+
* metadata 键:创建子会话的父回合 correlationId(第 3 期第二批,委派提交时刻捕获)。
|
|
1159
|
+
* 契约义务(宿主 adapter 侧):**仅 create 新建子会话消费**——宿主 adapter 读取该键并传入
|
|
1160
|
+
* `NewSessionOptions.parentTraceId`;resume 打开既有会话不适用(`SessionHeader.parentTraceId`
|
|
1161
|
+
* 随头定格,不重写)。shared 模式 embedder adapter 不读取时行为安全降级(子轨迹缺
|
|
1162
|
+
* parentTraceId,无回归)。
|
|
1163
|
+
*/
|
|
1164
|
+
export declare const AGENT_TASK_PARENT_TRACE_KEY: "agent-forge.agentTaskParentTrace";
|
|
1165
|
+
/**
|
|
1166
|
+
* metadata 键:resume 目标的子会话 id(D-060 S4)。宿主据此**打开既有会话文件**继续跑
|
|
1167
|
+
* (同一份 JSONL 续写,形成多轮子任务),而不是新建会话。宿主必须核验文件头
|
|
1168
|
+
* `parentAgentSession` 等于发起方父会话 id,否则结构化拒绝——越界与不存在同型。
|
|
1169
|
+
*/
|
|
1170
|
+
export declare const AGENT_TASK_RESUME_SESSION_KEY: "agent-forge.agentTaskResumeSession";
|
|
1171
|
+
export interface AgentTaskChildProfileV1 {
|
|
1172
|
+
readonly version: 1;
|
|
1173
|
+
/** 目标模型 id:必须能在父会话的 scoped models 里解析,否则 create 失败并列出可用 id。 */
|
|
1174
|
+
readonly model?: string;
|
|
1175
|
+
/** 思考级别(minimal/low/medium/high/xhigh/max);越界值 create 失败。 */
|
|
1176
|
+
readonly thinkingLevel?: string;
|
|
1177
|
+
/** 工具面白名单:与宿主继承面求交;空数组表示"一个工具都不给"。 */
|
|
1178
|
+
readonly tools?: readonly string[];
|
|
1179
|
+
/** 会话模式:`readonly` 只收窄不放宽(父会话已是 readonly 时保持 readonly)。 */
|
|
1180
|
+
readonly mode?: "readonly" | "full-control";
|
|
1181
|
+
/** 追加到子会话 system prompt 末尾的文本(不替换继承来的系统提示词)。 */
|
|
1182
|
+
readonly systemPromptAppend?: string;
|
|
1183
|
+
/**
|
|
1184
|
+
* 创建该子会话的角色 id(血缘/审计用途,写进子会话文件头;**不是权限判据**,也不参与收窄)。
|
|
1185
|
+
* 由子代理能力从角色定义注入;手工构造档案的调用方可以省略。
|
|
1186
|
+
*/
|
|
1187
|
+
readonly roleId?: string;
|
|
1188
|
+
}
|
|
1189
|
+
/** 档案解析结果:合法则给出规范化副本,否则给出可直接回给调用方的原因。 */
|
|
1190
|
+
export type AgentTaskChildProfileParseResultV1 = {
|
|
1191
|
+
readonly ok: true;
|
|
1192
|
+
readonly profile: AgentTaskChildProfileV1;
|
|
1193
|
+
} | {
|
|
1194
|
+
readonly ok: false;
|
|
1195
|
+
readonly message: string;
|
|
1196
|
+
};
|
|
1197
|
+
/**
|
|
1198
|
+
* 解析并校验一份子任务档案:类型/取值范围/未知键都在这里拦下,错误文本指名键,
|
|
1199
|
+
* 由调用方决定是本地失败还是回给上层(子代理能力把它变成条目级 rejected)。
|
|
1200
|
+
*/
|
|
1201
|
+
export declare function parseAgentTaskChildProfileV1(value: unknown): AgentTaskChildProfileParseResultV1;
|
|
1202
|
+
/** 便捷读取:从 metadata 里取出并校验档案;undefined 表示没带档案。 */
|
|
1203
|
+
export declare function readAgentTaskChildProfileV1(metadata: Record<string, unknown> | undefined): AgentTaskChildProfileParseResultV1 | undefined;
|
|
1204
|
+
export interface AgentTaskWaitResult {
|
|
1205
|
+
sessionId: string;
|
|
1206
|
+
messages: readonly unknown[];
|
|
1207
|
+
}
|
|
1208
|
+
/** Frozen terminal outcome of an agent task; the replay read survives dispose. */
|
|
1209
|
+
export interface AgentTaskResultV1 {
|
|
1210
|
+
readonly taskId: string;
|
|
1211
|
+
readonly parentSessionId: string;
|
|
1212
|
+
/** Terminal only: succeeded | failed | cancelled. */
|
|
1213
|
+
readonly status: AgentTaskStatus;
|
|
1214
|
+
readonly sessionId: string;
|
|
1215
|
+
readonly messages: readonly unknown[];
|
|
1216
|
+
}
|
|
1217
|
+
export interface AgentTaskHandle {
|
|
1218
|
+
readonly id: string;
|
|
1219
|
+
readonly parentSessionId: string;
|
|
1220
|
+
readonly session: SessionAPI;
|
|
1221
|
+
status(): AgentTaskStatus;
|
|
1222
|
+
run(): Promise<void>;
|
|
1223
|
+
wait(options?: {
|
|
1224
|
+
signal?: AbortSignal;
|
|
1225
|
+
}): Promise<AgentTaskWaitResult>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Terminal replay read: undefined until the task settles; afterwards the
|
|
1228
|
+
* frozen terminal outcome, even after dispose (no liveness assertion).
|
|
1229
|
+
*/
|
|
1230
|
+
result(): AgentTaskResultV1 | undefined;
|
|
1231
|
+
cancel(reason?: string): Promise<void>;
|
|
1232
|
+
dispose(): Promise<void>;
|
|
1233
|
+
}
|
|
1234
|
+
/** Host adapter for isolated child sessions. It contains lifecycle mechanics, not scheduling policy. */
|
|
1235
|
+
export interface AgentTaskHost {
|
|
1236
|
+
readonly session: SessionAPI;
|
|
1237
|
+
run(prompt: string, signal: AbortSignal): Promise<void>;
|
|
1238
|
+
cancel(reason?: string): Promise<void>;
|
|
1239
|
+
dispose(): Promise<void>;
|
|
1240
|
+
}
|
|
1241
|
+
export interface AgentTaskAdapter {
|
|
1242
|
+
create(request: AgentTaskCreateRequest): Promise<AgentTaskHost>;
|
|
1243
|
+
dispose?(): Promise<void>;
|
|
1244
|
+
}
|
|
1245
|
+
/** 会话回读视图(D-060):按 sessionId 读到的有界 transcript 片段。 */
|
|
1246
|
+
export interface AgentTaskSessionViewV1 {
|
|
1247
|
+
readonly sessionId: string;
|
|
1248
|
+
/** 血缘:父 agent 会话 id(子会话必有)。 */
|
|
1249
|
+
readonly parentAgentSession?: string;
|
|
1250
|
+
/** 血缘:创建该会话的角色 id(审计用途)。 */
|
|
1251
|
+
readonly agentRole?: string;
|
|
1252
|
+
readonly createdAt?: string;
|
|
1253
|
+
/** 整份 transcript 的字节数(不是返回片段的)。 */
|
|
1254
|
+
readonly bytes: number;
|
|
1255
|
+
/** 返回的消息/entry 条数;`truncated` 为真时是已返回的条数。 */
|
|
1256
|
+
readonly entryCount: number;
|
|
1257
|
+
/** 达到返回上限、只给了前段时为 true。 */
|
|
1258
|
+
readonly truncated: boolean;
|
|
1259
|
+
readonly entries: readonly unknown[];
|
|
1260
|
+
}
|
|
1261
|
+
export interface AgentTaskAPI {
|
|
1262
|
+
/**
|
|
1263
|
+
* 创建子任务(宿主 adapter 驱动)。宿主只注入会话回读面(无任务 adapter)时该
|
|
1264
|
+
* 成员不存在——此时 agents 只承载 `session`/`list` 回读面,不承载委派。
|
|
1265
|
+
*/
|
|
1266
|
+
create?(request: AgentTaskCreateRequest): Promise<AgentTaskHandle>;
|
|
1267
|
+
/**
|
|
1268
|
+
* Durable replay read by task id: loads the terminal record persisted at
|
|
1269
|
+
* settle from the host-injected durable store. Undefined when the store is
|
|
1270
|
+
* absent, the task has not settled, or no record exists under the id.
|
|
1271
|
+
*
|
|
1272
|
+
* The store is host-owned and shared per runtime: any plugin holding the
|
|
1273
|
+
* agents capability can read any task's record by id, including tasks of
|
|
1274
|
+
* other owners. Unlike the handle's in-memory `result()` (deep-frozen
|
|
1275
|
+
* projection), records reloaded from the durable backend are reparsed plain
|
|
1276
|
+
* objects and carry no freeze guarantee.
|
|
1277
|
+
*/
|
|
1278
|
+
/**
|
|
1279
|
+
* Durable replay read(宿主 adapter 驱动)。宿主只注入会话回读面(无任务 adapter)
|
|
1280
|
+
* 时该成员不存在。
|
|
1281
|
+
*/
|
|
1282
|
+
result?(taskId: string): Promise<AgentTaskResultV1 | undefined>;
|
|
1283
|
+
/**
|
|
1284
|
+
* 父→子引导(D-060 S4,程序面):对**运行中**的任务投递一条有界引导消息
|
|
1285
|
+
* (≤2048 utf-8 字节,复用子会话自身 steer 语义,不新增队列)。只在发起方
|
|
1286
|
+
* runtime 的活跃任务里定位:未启动/已终态的按 `subagent_not_running`、宿主
|
|
1287
|
+
* 会话无 steer 面按 `subagent_steer_unsupported`、未知 id 按
|
|
1288
|
+
* `subagent_unknown_task` 以带 code 的错误拒绝。父回合不被打断。
|
|
1289
|
+
* runtime 桥接总是提供;宿主适配器自身无需实现。
|
|
1290
|
+
*/
|
|
1291
|
+
steer?(request: {
|
|
1292
|
+
readonly taskId: string;
|
|
1293
|
+
readonly text: string;
|
|
1294
|
+
}): Promise<void>;
|
|
1295
|
+
/**
|
|
1296
|
+
* 按 `sessionId` 回读子会话 transcript(有界)。宿主未注入会话读取器时该成员不存在;
|
|
1297
|
+
* 作用域由宿主强制(默认宿主只放行本会话自己的子会话),越界与不存在同型返回 undefined。
|
|
1298
|
+
*/
|
|
1299
|
+
session?(sessionId: string): Promise<AgentTaskSessionViewV1 | undefined>;
|
|
1300
|
+
/**
|
|
1301
|
+
* 列出本会话**自己的**子代理会话摘要(按最近活动倒序,D-060 模型面盘点通道)。
|
|
1302
|
+
* 宿主未注入列举器时该成员不存在;作用域由宿主强制(只回本会话的子会话),
|
|
1303
|
+
* 摘要不含消息正文。跨进程重启仍可列出(读的是落盘目录,不是内存)。
|
|
1304
|
+
*/
|
|
1305
|
+
list?(): Promise<AgentTaskSessionSummaryV1[]>;
|
|
1306
|
+
}
|
|
1307
|
+
/**
|
|
1308
|
+
* 子代理会话摘要(`agents.list()` 的条目):只读头行信息,不含消息正文。
|
|
1309
|
+
* `modifiedAt` 为最后活动时间(epoch 毫秒),按它倒序返回。
|
|
1310
|
+
*/
|
|
1311
|
+
export interface AgentTaskSessionSummaryV1 {
|
|
1312
|
+
readonly sessionId: string;
|
|
1313
|
+
/** 血缘:创建该会话的角色 id(审计用途)。 */
|
|
1314
|
+
readonly agentRole?: string;
|
|
1315
|
+
readonly createdAt?: string;
|
|
1316
|
+
readonly modifiedAt: number;
|
|
1317
|
+
/** 整份 transcript 的字节数。 */
|
|
1318
|
+
readonly bytes: number;
|
|
1319
|
+
}
|
|
1320
|
+
export type InteractionNotifyLevel = "info" | "warning" | "error";
|
|
1321
|
+
export type InteractionRequestV1 = {
|
|
1322
|
+
kind: "notify";
|
|
1323
|
+
message: string;
|
|
1324
|
+
level?: InteractionNotifyLevel;
|
|
1325
|
+
} | {
|
|
1326
|
+
kind: "confirm";
|
|
1327
|
+
title: string;
|
|
1328
|
+
message: string;
|
|
1329
|
+
} | {
|
|
1330
|
+
kind: "select";
|
|
1331
|
+
title: string;
|
|
1332
|
+
options: readonly string[];
|
|
1333
|
+
}
|
|
1334
|
+
/** `placeholder` and `defaultValue` are part of the frozen wire shape, but current TUI/RPC hosts have no prefill support and silently ignore both (plain free-text input only). */
|
|
1335
|
+
| {
|
|
1336
|
+
kind: "input";
|
|
1337
|
+
title: string;
|
|
1338
|
+
placeholder?: string;
|
|
1339
|
+
defaultValue?: string;
|
|
1340
|
+
};
|
|
1341
|
+
/**
|
|
1342
|
+
* Outcome production conditions (frozen 1A.8 semantics):
|
|
1343
|
+
* - `delivered` — notify prompts only; the host accepted the fire-and-forget
|
|
1344
|
+
* notification.
|
|
1345
|
+
* - `answered` — the user completed a confirm/select/input prompt.
|
|
1346
|
+
* - `cancelled` — the user dismissed the prompt, `options.signal` aborted, or
|
|
1347
|
+
* the plugin's registration was disposed. Never produced by `timeoutMs`.
|
|
1348
|
+
* - `timeout` — `options.timeoutMs` elapsed before settlement; only that
|
|
1349
|
+
* source produces it.
|
|
1350
|
+
* - `unavailable` — the host's prompt implementation failed (including hosts
|
|
1351
|
+
* without an installed interaction UI settling "unavailable").
|
|
1352
|
+
*
|
|
1353
|
+
* The wrapper validates host-resolved outcomes against these conditions: an
|
|
1354
|
+
* unknown status, a missing/invalid `answered` value, extra fields, a
|
|
1355
|
+
* host-produced `timeout`, or a `delivered` outside a notify request makes
|
|
1356
|
+
* request() reject instead of handing a malformed outcome to the plugin.
|
|
1357
|
+
*/
|
|
1358
|
+
export type InteractionOutcomeV1 = {
|
|
1359
|
+
status: "delivered";
|
|
1360
|
+
} | {
|
|
1361
|
+
status: "answered";
|
|
1362
|
+
value: boolean | string;
|
|
1363
|
+
} | {
|
|
1364
|
+
status: "cancelled";
|
|
1365
|
+
} | {
|
|
1366
|
+
status: "timeout";
|
|
1367
|
+
} | {
|
|
1368
|
+
status: "unavailable";
|
|
1369
|
+
};
|
|
1370
|
+
export interface InteractionPromptContextV1 {
|
|
1371
|
+
readonly signal: AbortSignal;
|
|
1372
|
+
}
|
|
1373
|
+
/** Host-side implementation. Hosts MUST honor prompt ctx.signal and settle promptly when aborted. */
|
|
1374
|
+
/** Options for extension UI dialogs. */
|
|
1375
|
+
export interface InteractionDialogOptions {
|
|
1376
|
+
/** AbortSignal to programmatically dismiss the dialog. */
|
|
1377
|
+
signal?: AbortSignal;
|
|
1378
|
+
/** Timeout in milliseconds. Dialog auto-dismisses with live countdown display. */
|
|
1379
|
+
timeout?: number;
|
|
1380
|
+
}
|
|
1381
|
+
export interface InteractionHostV1 {
|
|
1382
|
+
notify(request: {
|
|
1383
|
+
message: string;
|
|
1384
|
+
level?: InteractionNotifyLevel;
|
|
1385
|
+
}): void;
|
|
1386
|
+
prompt(request: InteractionRequestV1, context: InteractionPromptContextV1): Promise<InteractionOutcomeV1>;
|
|
1387
|
+
/**
|
|
1388
|
+
* Implementations must be idempotent; the session dispose path and the
|
|
1389
|
+
* per-plugin registration may each invoke it.
|
|
1390
|
+
*/
|
|
1391
|
+
dispose?(): void | Promise<void>;
|
|
1392
|
+
}
|
|
1393
|
+
export interface InteractionAPI {
|
|
1394
|
+
/**
|
|
1395
|
+
* Fire-and-forget notification; mirrors the legacy sync void semantics.
|
|
1396
|
+
* Info-level notifications surface as transient host state (a later status
|
|
1397
|
+
* update may overwrite them) and persistent display is not guaranteed;
|
|
1398
|
+
* plugins that need a persistent notice should render their own durable UI.
|
|
1399
|
+
*/
|
|
1400
|
+
notify(request: {
|
|
1401
|
+
message: string;
|
|
1402
|
+
level?: InteractionNotifyLevel;
|
|
1403
|
+
}): void;
|
|
1404
|
+
/**
|
|
1405
|
+
* Cancellable interaction task. Resolves with a structured outcome (see
|
|
1406
|
+
* {@link InteractionOutcomeV1} for the per-outcome production conditions);
|
|
1407
|
+
* user dismissal yields "cancelled", never a rejection. Rejections only for
|
|
1408
|
+
* invalid input (thrown synchronously), a revoked API, or a malformed host
|
|
1409
|
+
* outcome. Cancellation is per request: `options.signal` and `timeoutMs`
|
|
1410
|
+
* affect only this request, never concurrent requests of the same plugin.
|
|
1411
|
+
*/
|
|
1412
|
+
request(request: InteractionRequestV1, options?: {
|
|
1413
|
+
signal?: AbortSignal;
|
|
1414
|
+
timeoutMs?: number;
|
|
1415
|
+
}): Promise<InteractionOutcomeV1>;
|
|
1416
|
+
}
|
|
1417
|
+
/** Experimental, host-independent Agent composition contract. */
|
|
1418
|
+
export type AgentInstanceStatus = "created" | "running" | "succeeded" | "failed" | "cancelled" | "disposed";
|
|
1419
|
+
export type AgentControllerRole = PluginAgentRole;
|
|
1420
|
+
export interface AgentInstanceSnapshot {
|
|
1421
|
+
readonly id: string;
|
|
1422
|
+
readonly definitionId: string;
|
|
1423
|
+
readonly definitionVersion: number;
|
|
1424
|
+
readonly role: AgentControllerRole;
|
|
1425
|
+
readonly parentInstanceId?: string;
|
|
1426
|
+
readonly status: AgentInstanceStatus;
|
|
1427
|
+
readonly revision: number;
|
|
1428
|
+
readonly leaseOwner?: string;
|
|
1429
|
+
}
|
|
1430
|
+
export interface AgentExecutionContext {
|
|
1431
|
+
readonly instance: AgentInstanceSnapshot;
|
|
1432
|
+
readonly signal: AbortSignal;
|
|
1433
|
+
readonly inputRevision: number;
|
|
1434
|
+
/** Optional host primitives; absent when the host did not negotiate them. */
|
|
1435
|
+
readonly host?: AgentHostPrimitivesV1;
|
|
1436
|
+
}
|
|
1437
|
+
export interface AgentDefinition<TInput = unknown, TResult = unknown> {
|
|
1438
|
+
readonly id: string;
|
|
1439
|
+
readonly version: number;
|
|
1440
|
+
readonly role: AgentControllerRole;
|
|
1441
|
+
readonly owner?: string;
|
|
1442
|
+
run(input: TInput, context: AgentExecutionContext): TResult | Promise<TResult>;
|
|
1443
|
+
}
|
|
1444
|
+
export interface AgentControllerLease {
|
|
1445
|
+
readonly id: string;
|
|
1446
|
+
readonly instanceId: string;
|
|
1447
|
+
readonly owner: string;
|
|
1448
|
+
readonly revision: number;
|
|
1449
|
+
isActive(): boolean;
|
|
1450
|
+
release(): Promise<void>;
|
|
1451
|
+
}
|
|
1452
|
+
export interface AgentInstanceResult<TResult = unknown> {
|
|
1453
|
+
readonly status: "succeeded" | "failed" | "cancelled" | "disposed";
|
|
1454
|
+
readonly output?: TResult;
|
|
1455
|
+
readonly error?: unknown;
|
|
1456
|
+
readonly revision: number;
|
|
1457
|
+
}
|
|
1458
|
+
export interface AgentInstance<TInput = unknown, TResult = unknown> {
|
|
1459
|
+
readonly id: string;
|
|
1460
|
+
readonly definition: AgentDefinition<TInput, TResult>;
|
|
1461
|
+
snapshot(): AgentInstanceSnapshot;
|
|
1462
|
+
acquireControllerLease(owner?: string): Promise<AgentControllerLease>;
|
|
1463
|
+
run(input: TInput, options?: {
|
|
1464
|
+
lease?: AgentControllerLease;
|
|
1465
|
+
signal?: AbortSignal;
|
|
1466
|
+
}): OperationHandle<TResult>;
|
|
1467
|
+
wait(): Promise<AgentInstanceResult<TResult>>;
|
|
1468
|
+
cancel(reason?: string): Promise<void>;
|
|
1469
|
+
dispose(): Promise<void>;
|
|
1470
|
+
}
|
|
1471
|
+
export interface AgentCompositionAPI {
|
|
1472
|
+
define<TInput = unknown, TResult = unknown>(definition: AgentDefinition<TInput, TResult>): AgentDefinition<TInput, TResult>;
|
|
1473
|
+
get<TInput = unknown, TResult = unknown>(id: string, version: number): AgentDefinition<TInput, TResult>;
|
|
1474
|
+
create<TInput = unknown, TResult = unknown>(definition: AgentDefinition<TInput, TResult> | {
|
|
1475
|
+
id: string;
|
|
1476
|
+
version: number;
|
|
1477
|
+
}, options?: {
|
|
1478
|
+
id?: string;
|
|
1479
|
+
parentInstanceId?: string;
|
|
1480
|
+
}): AgentInstance<TInput, TResult>;
|
|
1481
|
+
listInstances(): readonly AgentInstanceSnapshot[];
|
|
1482
|
+
}
|
|
1483
|
+
/** Optional host binding implemented by the built-in composition runtime. */
|
|
1484
|
+
export interface AgentCompositionHostBinding {
|
|
1485
|
+
setHostPrimitivesFactory(factory?: AgentHostPrimitivesFactory): void;
|
|
1486
|
+
}
|
|
1487
|
+
/** Optional owner-scoped cleanup implemented by the built-in composition runtime. */
|
|
1488
|
+
export interface AgentCompositionDefinitionBinding {
|
|
1489
|
+
disposeDefinitions(definitions: readonly AgentDefinition[]): void;
|
|
1490
|
+
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Optional host-only binding for the built-in composition runtime. It lets a
|
|
1493
|
+
* CapabilityRuntime add owner-scoped primitives without exposing that control
|
|
1494
|
+
* to capability plugins.
|
|
1495
|
+
*/
|
|
1496
|
+
export interface AgentCompositionScopedHostBinding {
|
|
1497
|
+
createWithHostPrimitives<TInput = unknown, TResult = unknown>(definition: AgentDefinition<TInput, TResult> | {
|
|
1498
|
+
id: string;
|
|
1499
|
+
version: number;
|
|
1500
|
+
}, options: {
|
|
1501
|
+
id?: string;
|
|
1502
|
+
parentInstanceId?: string;
|
|
1503
|
+
} | undefined, hostPrimitivesFactory: AgentHostPrimitivesFactory): AgentInstance<TInput, TResult>;
|
|
1504
|
+
}
|
|
1505
|
+
export interface ContextStrategy<TContext = unknown, TSnapshot = unknown> {
|
|
1506
|
+
transform(context: TContext, options?: ContextOperationOptions): TContext | Promise<TContext>;
|
|
1507
|
+
snapshot?(context: TContext, options?: ContextOperationOptions): TSnapshot | Promise<TSnapshot>;
|
|
1508
|
+
restore?(snapshot: TSnapshot, options?: ContextOperationOptions): TContext | Promise<TContext>;
|
|
1509
|
+
replace?(context: TContext, options?: ContextOperationOptions): TContext | Promise<TContext>;
|
|
1510
|
+
}
|
|
1511
|
+
export interface ContextOperationOptions {
|
|
1512
|
+
signal?: AbortSignal;
|
|
1513
|
+
reason?: "request" | "reload" | "session_replace" | "compaction" | "overflow_recovery" | "retry" | "tree";
|
|
1514
|
+
sessionId?: string;
|
|
1515
|
+
}
|
|
1516
|
+
/**
|
|
1517
|
+
* Generic transform over the projected session entry list, registered per
|
|
1518
|
+
* session. The kernel applies registered projections verbatim; semantics
|
|
1519
|
+
* belong to the registering plugin.
|
|
1520
|
+
*/
|
|
1521
|
+
export interface EntryProjection {
|
|
1522
|
+
/** The plugin-owned custom entry type this projection is associated with. */
|
|
1523
|
+
readonly customType: string;
|
|
1524
|
+
readonly project: (entries: readonly unknown[]) => readonly unknown[];
|
|
1525
|
+
}
|
|
1526
|
+
export interface SkillDefinition {
|
|
1527
|
+
name: string;
|
|
1528
|
+
description: string;
|
|
1529
|
+
filePath: string;
|
|
1530
|
+
baseDir: string;
|
|
1531
|
+
disableModelInvocation?: boolean;
|
|
1532
|
+
}
|
|
1533
|
+
/** Versioned, provider-agnostic facts shared by replaceable policy calls. */
|
|
1534
|
+
export interface PolicyInvocationContextV1 {
|
|
1535
|
+
version: 1;
|
|
1536
|
+
sessionId: string;
|
|
1537
|
+
phase: "agent" | "compaction" | "overflow" | "retry" | "branch_summary";
|
|
1538
|
+
operationId?: string;
|
|
1539
|
+
}
|
|
1540
|
+
export interface RetryPolicyRequest {
|
|
1541
|
+
signal?: AbortSignal;
|
|
1542
|
+
retryable: boolean;
|
|
1543
|
+
enabled: boolean;
|
|
1544
|
+
attempt: number;
|
|
1545
|
+
maxAttempts: number;
|
|
1546
|
+
baseDelayMs: number;
|
|
1547
|
+
errorMessage?: string;
|
|
1548
|
+
context?: PolicyInvocationContextV1;
|
|
1549
|
+
execution?: ExecutionFactsV1;
|
|
1550
|
+
}
|
|
1551
|
+
export interface RetryClassificationRequest {
|
|
1552
|
+
signal?: AbortSignal;
|
|
1553
|
+
message: unknown;
|
|
1554
|
+
context?: PolicyInvocationContextV1;
|
|
1555
|
+
execution?: ExecutionFactsV1;
|
|
1556
|
+
}
|
|
1557
|
+
export interface RetryPolicyDecision {
|
|
1558
|
+
retry: boolean;
|
|
1559
|
+
delayMs?: number;
|
|
1560
|
+
}
|
|
1561
|
+
export interface RetryPolicy {
|
|
1562
|
+
classify?(request: RetryClassificationRequest): boolean | Promise<boolean>;
|
|
1563
|
+
decide(request: RetryPolicyRequest): RetryPolicyDecision | Promise<RetryPolicyDecision>;
|
|
1564
|
+
}
|
|
1565
|
+
export interface CompactionPolicyRequest {
|
|
1566
|
+
signal?: AbortSignal;
|
|
1567
|
+
enabled: boolean;
|
|
1568
|
+
reason: "overflow" | "threshold";
|
|
1569
|
+
contextOverflow: boolean;
|
|
1570
|
+
recoverableLength: boolean;
|
|
1571
|
+
/** Facts measured by the host; the policy owns the threshold decision. */
|
|
1572
|
+
contextUsage?: CompactionContextUsage;
|
|
1573
|
+
recoveryAttempted: boolean;
|
|
1574
|
+
canContinue: boolean;
|
|
1575
|
+
/**
|
|
1576
|
+
* Branch path entry snapshot (threshold requests only). Provided so a
|
|
1577
|
+
* policy can plan CHEAP RELIEF (see {@link CompactionPolicyDecision.relief})
|
|
1578
|
+
* from real history facts instead of ordering a summarization run.
|
|
1579
|
+
*/
|
|
1580
|
+
branchEntries?: readonly unknown[];
|
|
1581
|
+
/** Recent-tail protection budget (settings fact) for relief planning. */
|
|
1582
|
+
keepRecentTokens?: number;
|
|
1583
|
+
context?: PolicyInvocationContextV1;
|
|
1584
|
+
execution?: ExecutionFactsV1;
|
|
1585
|
+
}
|
|
1586
|
+
export interface CompactionContextUsage {
|
|
1587
|
+
contextTokens: number;
|
|
1588
|
+
contextWindow: number;
|
|
1589
|
+
reserveTokens: number;
|
|
1590
|
+
}
|
|
1591
|
+
export interface CompactionPreparationRequest {
|
|
1592
|
+
signal?: AbortSignal;
|
|
1593
|
+
entries: unknown;
|
|
1594
|
+
settings: unknown;
|
|
1595
|
+
context?: PolicyInvocationContextV1;
|
|
1596
|
+
execution?: ExecutionFactsV1;
|
|
1597
|
+
}
|
|
1598
|
+
export interface CompactionPolicyDecision {
|
|
1599
|
+
compact: boolean;
|
|
1600
|
+
retry?: boolean;
|
|
1601
|
+
failureMessage?: string;
|
|
1602
|
+
/**
|
|
1603
|
+
* Cheap RELIEF plan: the host appends this custom entry (generic
|
|
1604
|
+
* `appendCustomEntry`) and reprojects the context instead of running a
|
|
1605
|
+
* summarization. The semantics of the entry belong entirely to the policy;
|
|
1606
|
+
* the projection that interprets it is registered separately via
|
|
1607
|
+
* {@link CapabilityAPI.registerEntryProjection}. When relief is present the
|
|
1608
|
+
* host skips compaction, so `compact` must be false.
|
|
1609
|
+
*/
|
|
1610
|
+
relief?: {
|
|
1611
|
+
readonly customType: string;
|
|
1612
|
+
readonly data?: unknown;
|
|
1613
|
+
};
|
|
1614
|
+
}
|
|
1615
|
+
/** Provider-agnostic facts about the model the host will use for a summary call. */
|
|
1616
|
+
export interface SummaryModelFactsV1 {
|
|
1617
|
+
readonly id: string;
|
|
1618
|
+
readonly contextWindow: number;
|
|
1619
|
+
readonly maxTokens: number;
|
|
1620
|
+
readonly reasoning: boolean;
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Host-owned, provider-agnostic single-shot completion boundary for summary
|
|
1624
|
+
* policies. The host resolves the model, auth, transport, retry budget and
|
|
1625
|
+
* cache routing; provider internals never cross to the plugin. Each invoke is
|
|
1626
|
+
* exactly one completion without tools or session state, and never writes the
|
|
1627
|
+
* prompt cache. A plugin that can read these types can implement a summary
|
|
1628
|
+
* strategy without importing provider internals.
|
|
1629
|
+
*/
|
|
1630
|
+
export interface SummaryModelInvocationV1 {
|
|
1631
|
+
readonly invoke: (input: SummaryModelInvocationRequestV1, signal: AbortSignal) => Promise<SummaryModelInvocationResultV1>;
|
|
1632
|
+
}
|
|
1633
|
+
/** One host-mediated summary completion request. */
|
|
1634
|
+
export interface SummaryModelInvocationRequestV1 {
|
|
1635
|
+
readonly version: 1;
|
|
1636
|
+
readonly systemPrompt?: string;
|
|
1637
|
+
readonly prompt: string;
|
|
1638
|
+
/** Requested output budget; the host clamps it to the summary model cap. */
|
|
1639
|
+
readonly maxTokens?: number;
|
|
1640
|
+
readonly thinkingLevel?: ThinkingLevel;
|
|
1641
|
+
}
|
|
1642
|
+
/** Stable failure codes reported through {@link SummaryModelInvocationResultV1} errors. */
|
|
1643
|
+
export declare const SUMMARY_MODEL_INVOCATION_ERROR_CODES: {
|
|
1644
|
+
/** Provider returned an error stop; `message` mirrors the provider error text. */
|
|
1645
|
+
readonly providerError: "summary_provider_error";
|
|
1646
|
+
/** Generation hit the requested output cap and the summary is incomplete. */
|
|
1647
|
+
readonly lengthCap: "summary_length_cap";
|
|
1648
|
+
/** The model attempted a tool call in a tool-less completion. */
|
|
1649
|
+
readonly toolCall: "summary_tool_call";
|
|
1650
|
+
/** The transport threw; `message` mirrors the original error text. */
|
|
1651
|
+
readonly transportError: "summary_transport_error";
|
|
1652
|
+
};
|
|
1653
|
+
/**
|
|
1654
|
+
* One host-mediated summary completion outcome, as a discriminated union:
|
|
1655
|
+
* `completed` always carries text, `failed` always carries structured error
|
|
1656
|
+
* facts whose `code` is one of {@link SUMMARY_MODEL_INVOCATION_ERROR_CODES}.
|
|
1657
|
+
*/
|
|
1658
|
+
export type SummaryModelInvocationResultV1 = {
|
|
1659
|
+
readonly version: 1;
|
|
1660
|
+
readonly status: "completed";
|
|
1661
|
+
readonly text: string;
|
|
1662
|
+
readonly usage?: unknown;
|
|
1663
|
+
} | {
|
|
1664
|
+
readonly version: 1;
|
|
1665
|
+
readonly status: "aborted";
|
|
1666
|
+
} | {
|
|
1667
|
+
readonly version: 1;
|
|
1668
|
+
readonly status: "failed";
|
|
1669
|
+
readonly error: {
|
|
1670
|
+
readonly code: string;
|
|
1671
|
+
readonly message: string;
|
|
1672
|
+
};
|
|
1673
|
+
};
|
|
1674
|
+
export interface CompactionSummaryRequest {
|
|
1675
|
+
preparation: unknown;
|
|
1676
|
+
model: SummaryModelFactsV1;
|
|
1677
|
+
invocation: SummaryModelInvocationV1;
|
|
1678
|
+
customInstructions?: string;
|
|
1679
|
+
signal: AbortSignal;
|
|
1680
|
+
reason: "manual" | "threshold" | "overflow";
|
|
1681
|
+
thinkingLevel?: ThinkingLevel;
|
|
1682
|
+
sessionId?: string;
|
|
1683
|
+
context?: PolicyInvocationContextV1;
|
|
1684
|
+
execution?: ExecutionFactsV1;
|
|
1685
|
+
}
|
|
1686
|
+
export interface CompactionSummaryResult {
|
|
1687
|
+
summary: string;
|
|
1688
|
+
firstKeptEntryId: string;
|
|
1689
|
+
tokensBefore: number;
|
|
1690
|
+
usage?: unknown;
|
|
1691
|
+
details?: unknown;
|
|
1692
|
+
}
|
|
1693
|
+
export interface CompactionPolicy {
|
|
1694
|
+
prepare?(request: CompactionPreparationRequest): unknown | Promise<unknown>;
|
|
1695
|
+
decide(request: CompactionPolicyRequest): CompactionPolicyDecision | Promise<CompactionPolicyDecision>;
|
|
1696
|
+
summarize?(request: CompactionSummaryRequest): CompactionSummaryResult | Promise<CompactionSummaryResult>;
|
|
1697
|
+
}
|
|
1698
|
+
/** Provider-agnostic overflow classification supplied by a capability plugin. */
|
|
1699
|
+
export interface OverflowPolicyRequest {
|
|
1700
|
+
signal?: AbortSignal;
|
|
1701
|
+
message: unknown;
|
|
1702
|
+
contextWindow?: number;
|
|
1703
|
+
desiredMaxOutput: number;
|
|
1704
|
+
context?: PolicyInvocationContextV1;
|
|
1705
|
+
execution?: ExecutionFactsV1;
|
|
1706
|
+
}
|
|
1707
|
+
export interface OverflowPolicyDecision {
|
|
1708
|
+
contextOverflow: boolean;
|
|
1709
|
+
recoverableLength: boolean;
|
|
1710
|
+
}
|
|
1711
|
+
export interface OverflowPolicy {
|
|
1712
|
+
decide(request: OverflowPolicyRequest): OverflowPolicyDecision | Promise<OverflowPolicyDecision>;
|
|
1713
|
+
}
|
|
1714
|
+
export interface BranchSummaryRequest {
|
|
1715
|
+
entries: unknown;
|
|
1716
|
+
model: SummaryModelFactsV1;
|
|
1717
|
+
invocation: SummaryModelInvocationV1;
|
|
1718
|
+
signal: AbortSignal;
|
|
1719
|
+
customInstructions?: string;
|
|
1720
|
+
replaceInstructions?: boolean;
|
|
1721
|
+
reserveTokens?: number;
|
|
1722
|
+
context?: PolicyInvocationContextV1;
|
|
1723
|
+
execution?: ExecutionFactsV1;
|
|
1724
|
+
}
|
|
1725
|
+
export interface BranchSummaryResult {
|
|
1726
|
+
summary?: string;
|
|
1727
|
+
usage?: unknown;
|
|
1728
|
+
readFiles?: string[];
|
|
1729
|
+
modifiedFiles?: string[];
|
|
1730
|
+
aborted?: boolean;
|
|
1731
|
+
error?: string;
|
|
1732
|
+
}
|
|
1733
|
+
export interface BranchSummaryPolicy {
|
|
1734
|
+
summarize(request: BranchSummaryRequest): BranchSummaryResult | Promise<BranchSummaryResult>;
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Experimental provider request header boundary. `null` retains the provider
|
|
1738
|
+
* header deletion semantics used by the host model runtime.
|
|
1739
|
+
*/
|
|
1740
|
+
export interface ProviderHeaderTransformRequest {
|
|
1741
|
+
model: unknown;
|
|
1742
|
+
sessionId?: string;
|
|
1743
|
+
headers: Record<string, string | null>;
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Experimental request-time hook for plugins that own provider header policy.
|
|
1747
|
+
* Transforms run in registration order and receive the previous transform's
|
|
1748
|
+
* result.
|
|
1749
|
+
*/
|
|
1750
|
+
export type ProviderHeaderTransform = (request: ProviderHeaderTransformRequest) => Record<string, string | null> | Promise<Record<string, string | null>>;
|
|
1751
|
+
/**
|
|
1752
|
+
* Hook positions on the default agent loop. Links run in registration order
|
|
1753
|
+
* after the host's legacy chain head.
|
|
1754
|
+
*/
|
|
1755
|
+
export type AgentLoopHookPositionV1 = "beforeInput" | "beforeToolCall" | "afterToolCall" | "transformContext" | "prepareNextTurn" | "shouldStopAfterTurn";
|
|
1756
|
+
/**
|
|
1757
|
+
* One ordered link of the input gate chain (输入 gate,扩展位盘点 A3). Runs at
|
|
1758
|
+
* prompt submission — before the input is accepted (`input.received@1` is the
|
|
1759
|
+
* observe fact of an ACCEPTED input and never fires for blocked inputs) and
|
|
1760
|
+
* before skill/template expansion. A `{ block: true, reason? }` result rejects
|
|
1761
|
+
* the input: the session dispatches `input.gate.blocked@1` and the prompt call
|
|
1762
|
+
* fails with the reason. A `{ text }` result rewrites the input for everything
|
|
1763
|
+
* downstream (later gates, expansion, the turn). `undefined` keeps the input.
|
|
1764
|
+
*/
|
|
1765
|
+
export type AgentLoopBeforeInputHookV1 = (input: {
|
|
1766
|
+
readonly text: string;
|
|
1767
|
+
readonly source: string;
|
|
1768
|
+
readonly signal?: AbortSignal;
|
|
1769
|
+
}) => Promise<AgentLoopBeforeInputOutputV1 | undefined>;
|
|
1770
|
+
export interface AgentLoopBeforeInputOutputV1 {
|
|
1771
|
+
block?: boolean;
|
|
1772
|
+
reason?: string;
|
|
1773
|
+
text?: string;
|
|
1774
|
+
}
|
|
1775
|
+
export interface AgentLoopBeforeToolCallInputV1 {
|
|
1776
|
+
toolCallId: string;
|
|
1777
|
+
toolName: string;
|
|
1778
|
+
args: unknown;
|
|
1779
|
+
signal?: AbortSignal;
|
|
1780
|
+
}
|
|
1781
|
+
/**
|
|
1782
|
+
* One ordered link of the default tool-call gating chain. Return
|
|
1783
|
+
* `{ block: true, reason? }` to block, `{ args }` to replace the candidate
|
|
1784
|
+
* arguments, or `undefined` to keep the input.
|
|
1785
|
+
*/
|
|
1786
|
+
export interface AgentLoopBeforeToolCallOutputV1 {
|
|
1787
|
+
block?: boolean;
|
|
1788
|
+
reason?: string;
|
|
1789
|
+
args?: unknown;
|
|
1790
|
+
}
|
|
1791
|
+
export type AgentLoopBeforeToolCallHookV1 = (input: AgentLoopBeforeToolCallInputV1) => Promise<AgentLoopBeforeToolCallOutputV1 | undefined>;
|
|
1792
|
+
export interface AgentLoopAfterToolCallInputV1 {
|
|
1793
|
+
toolCallId: string;
|
|
1794
|
+
toolName: string;
|
|
1795
|
+
args: unknown;
|
|
1796
|
+
/** The result produced by the previous link, or the executed tool result for the first link. */
|
|
1797
|
+
result: unknown;
|
|
1798
|
+
isError: boolean;
|
|
1799
|
+
signal?: AbortSignal;
|
|
1800
|
+
}
|
|
1801
|
+
/**
|
|
1802
|
+
* One ordered link of the post-execution chain. Return a partial tool-result
|
|
1803
|
+
* override to rewrite the result, or `undefined` to keep the input.
|
|
1804
|
+
*/
|
|
1805
|
+
export type AgentLoopAfterToolCallHookV1 = (input: AgentLoopAfterToolCallInputV1) => Promise<unknown | undefined>;
|
|
1806
|
+
/**
|
|
1807
|
+
* One ordered link of the request-time context transform chain. Receives and
|
|
1808
|
+
* returns the message array; `undefined` keeps the input.
|
|
1809
|
+
*/
|
|
1810
|
+
export type AgentLoopTransformContextHookV1 = (messages: readonly unknown[], signal?: AbortSignal) => Promise<readonly unknown[] | undefined>;
|
|
1811
|
+
/**
|
|
1812
|
+
* One ordered link of the next-turn preparation chain. Receives the turn
|
|
1813
|
+
* snapshot, returns a revised snapshot or `undefined`.
|
|
1814
|
+
*/
|
|
1815
|
+
export type AgentLoopPrepareNextTurnHookV1 = (turn: unknown, signal?: AbortSignal) => Promise<unknown | undefined>;
|
|
1816
|
+
/**
|
|
1817
|
+
* One ordered link of the post-turn stop chain. Receives the completed turn's
|
|
1818
|
+
* stop context; return `true` to request stopping after the current turn. The
|
|
1819
|
+
* host OR-composes the chain: the first link returning `true` stops the run
|
|
1820
|
+
* without consulting later links.
|
|
1821
|
+
*
|
|
1822
|
+
* The stop context stays kernel-typed (`@agent-forge/agent-core`
|
|
1823
|
+
* `ShouldStopAfterTurnContext`: its fields reference the provider message
|
|
1824
|
+
* model, which must not cross into the SDK — D-075 S2). Hosts hand the same
|
|
1825
|
+
* runtime object they hand the kernel callback; `context` is therefore typed
|
|
1826
|
+
* `any` here so kernel-typed handlers remain assignable.
|
|
1827
|
+
*/
|
|
1828
|
+
export type AgentLoopShouldStopAfterTurnHookV1 = (context: any, signal?: AbortSignal) => boolean | Promise<boolean>;
|
|
1829
|
+
export type AgentLoopHookForV1<P extends AgentLoopHookPositionV1> = P extends "beforeInput" ? AgentLoopBeforeInputHookV1 : P extends "beforeToolCall" ? AgentLoopBeforeToolCallHookV1 : P extends "afterToolCall" ? AgentLoopAfterToolCallHookV1 : P extends "transformContext" ? AgentLoopTransformContextHookV1 : P extends "prepareNextTurn" ? AgentLoopPrepareNextTurnHookV1 : P extends "shouldStopAfterTurn" ? AgentLoopShouldStopAfterTurnHookV1 : never;
|
|
1830
|
+
export type AgentLoopHookHandlerV1 = AgentLoopBeforeInputHookV1 | AgentLoopBeforeToolCallHookV1 | AgentLoopAfterToolCallHookV1 | AgentLoopTransformContextHookV1 | AgentLoopPrepareNextTurnHookV1 | AgentLoopShouldStopAfterTurnHookV1;
|
|
1831
|
+
/**
|
|
1832
|
+
* Post-run continuation facts for the default agent loop. The host evaluates
|
|
1833
|
+
* its own candidate decision first; the strategy makes the final
|
|
1834
|
+
* continue/stop call for the post-run loop.
|
|
1835
|
+
*/
|
|
1836
|
+
export interface AgentRunLoopStrategyRequestV1 {
|
|
1837
|
+
/** The policy decision signal for the current prompt run. */
|
|
1838
|
+
readonly signal?: AbortSignal;
|
|
1839
|
+
/** The retry path fired: a retry was prepared and the host would continue into it. */
|
|
1840
|
+
readonly willRetry: boolean;
|
|
1841
|
+
/** The compaction path fired: compaction was prepared and the host would continue into it. */
|
|
1842
|
+
readonly willCompact: boolean;
|
|
1843
|
+
/** The agent still holds queued steering/follow-up messages. */
|
|
1844
|
+
readonly queuedFollowUp: boolean;
|
|
1845
|
+
/** The host's own continuation decision (the replaceable default behavior). */
|
|
1846
|
+
readonly hostWillContinue: boolean;
|
|
1847
|
+
}
|
|
1848
|
+
export interface AgentRunLoopStrategyDecisionV1 {
|
|
1849
|
+
readonly continueLoop: boolean;
|
|
1850
|
+
readonly reason?: string;
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Post-run continuation strategy for the default agent loop. The host proposes
|
|
1854
|
+
* the continuation (retry, compaction, or queued input); the strategy may veto
|
|
1855
|
+
* it per cycle. `continueLoop: true` without a host-proposed continuation is
|
|
1856
|
+
* clamped to stop: the agent loop can only continue from pending retry,
|
|
1857
|
+
* compaction, or queued input.
|
|
1858
|
+
*/
|
|
1859
|
+
export interface AgentRunLoopStrategyV1 {
|
|
1860
|
+
decideNextCycle(request: AgentRunLoopStrategyRequestV1): AgentRunLoopStrategyDecisionV1 | Promise<AgentRunLoopStrategyDecisionV1>;
|
|
1861
|
+
}
|
|
1862
|
+
export interface CapabilityAPI {
|
|
1863
|
+
readonly manifest: PluginManifest;
|
|
1864
|
+
readonly host: HostCapabilities;
|
|
1865
|
+
readonly config: PluginConfig;
|
|
1866
|
+
readonly session?: SessionAPI;
|
|
1867
|
+
/** Available when the host declares the `output-artifacts` feature. */
|
|
1868
|
+
readonly output?: OutputArtifactAPI;
|
|
1869
|
+
readonly credentials?: CredentialAPI;
|
|
1870
|
+
readonly agents?: AgentTaskAPI;
|
|
1871
|
+
/**
|
|
1872
|
+
* 宿主会话取消栅栏(D-044 §4.2):getter 形态,按调用时刻返回当前 epoch 的
|
|
1873
|
+
* AbortSignal(用户中止/销毁会话时触发;epoch 刷新后旧信号不再影响新任务)。
|
|
1874
|
+
* 宿主未注入 parentSignal 时为 undefined。插件编排(如 subagent delegate)用它级联取消。
|
|
1875
|
+
*/
|
|
1876
|
+
sessionAbortSignal?: () => AbortSignal | undefined;
|
|
1877
|
+
/** Available when the host declares `interaction` feature. */
|
|
1878
|
+
readonly interaction?: InteractionAPI;
|
|
1879
|
+
/** Available when the host declares `agent-composition-v1`. */
|
|
1880
|
+
readonly composition?: AgentCompositionAPI;
|
|
1881
|
+
/** Available when the host declares `logger-v1`. */
|
|
1882
|
+
readonly logger?: LoggerAPI;
|
|
1883
|
+
/** Available when the host declares `diagnostics-v1`. */
|
|
1884
|
+
readonly diagnostics?: DiagnosticsAPI;
|
|
1885
|
+
/** Available when the host declares `plugin-state-v1`. */
|
|
1886
|
+
readonly state?: StateAPI;
|
|
1887
|
+
/** Available when the host declares `runtime-inspector-v1`. */
|
|
1888
|
+
readonly inspector?: RuntimeInspectorAPI;
|
|
1889
|
+
/**
|
|
1890
|
+
* Host trace adapter service (D-075 S4 second batch, observability host
|
|
1891
|
+
* contract). Present when the host runs session trace collection; the
|
|
1892
|
+
* first-party observability plugin binds it as its trace sink adapter.
|
|
1893
|
+
* Optional probe: hosts without tracing (or third-party hosts) leave it
|
|
1894
|
+
* undefined and the plugin stays trace-free.
|
|
1895
|
+
*/
|
|
1896
|
+
readonly trace?: ObservabilityHostAdapterV1;
|
|
1897
|
+
/**
|
|
1898
|
+
* Trace-sink budget overrides accompanying {@link CapabilityAPI.trace}
|
|
1899
|
+
* (host `traceOptions` face, design §6 control plane). Present only
|
|
1900
|
+
* together with `trace`; omitted fields fall back to the plugin defaults.
|
|
1901
|
+
*/
|
|
1902
|
+
readonly traceSinkOptions?: TraceSinkOptionsV1;
|
|
1903
|
+
readonly contributions: ContributionAPI;
|
|
1904
|
+
/** Draft host lifecycle event directory. */
|
|
1905
|
+
readonly lifecycle: LifecycleAPI;
|
|
1906
|
+
/** Draft plugin-to-plugin capability directory. */
|
|
1907
|
+
readonly capabilities: CapabilityDirectoryAPI;
|
|
1908
|
+
/**
|
|
1909
|
+
* Register a tool. `definition` stays loosely typed (any `{ name, execute }`
|
|
1910
|
+
* shape the host can normalize); when the host configures
|
|
1911
|
+
* CapabilityRuntimeOptions.toolExecutionContext, `execute` receives a
|
|
1912
|
+
* {@link CapabilityToolContext} as its second argument on the runtime invoke
|
|
1913
|
+
* face. Re-registering an existing name replaces the current registration
|
|
1914
|
+
* (last load wins) and it is restored when the replacing registration
|
|
1915
|
+
* disposes. Experimental.
|
|
1916
|
+
*/
|
|
1917
|
+
registerTool(definition: unknown): DisposableRegistration;
|
|
1918
|
+
registerCommand(definition: CapabilityCommandDefinition): DisposableRegistration;
|
|
1919
|
+
registerOperation(name: string, handler: (input: unknown, context: OperationExecutionContext) => unknown | Promise<unknown>): DisposableRegistration;
|
|
1920
|
+
registerRpcMethod(name: string, handler: (input: unknown) => unknown | Promise<unknown>): DisposableRegistration;
|
|
1921
|
+
registerContextStrategy(name: string, strategy: ContextStrategy): DisposableRegistration;
|
|
1922
|
+
/**
|
|
1923
|
+
* Registers a GENERIC entry projection for this session's context
|
|
1924
|
+
* projection: `project` receives the projected session entry list and may
|
|
1925
|
+
* replace entries. The kernel applies registered projections verbatim and
|
|
1926
|
+
* knows nothing about their semantics — first-party and third-party plugins
|
|
1927
|
+
* use the same channel for custom-entry-based context policies (e.g. a
|
|
1928
|
+
* compaction policy eliding bulky old tool results). The returned disposer
|
|
1929
|
+
* removes the projection.
|
|
1930
|
+
*/
|
|
1931
|
+
registerEntryProjection(projection: EntryProjection): DisposableRegistration;
|
|
1932
|
+
registerProviderHeaderTransform(name: string, transform: ProviderHeaderTransform): DisposableRegistration;
|
|
1933
|
+
registerSkill(definition: SkillDefinition): DisposableRegistration;
|
|
1934
|
+
registerRetryPolicy(name: string, policy: RetryPolicy): DisposableRegistration;
|
|
1935
|
+
registerCompactionPolicy(name: string, policy: CompactionPolicy): DisposableRegistration;
|
|
1936
|
+
registerOverflowPolicy(name: string, policy: OverflowPolicy): DisposableRegistration;
|
|
1937
|
+
registerBranchSummaryPolicy(name: string, policy: BranchSummaryPolicy): DisposableRegistration;
|
|
1938
|
+
registerLoopHook(position: "beforeInput", handler: AgentLoopBeforeInputHookV1): DisposableRegistration;
|
|
1939
|
+
registerLoopHook(position: "beforeToolCall", handler: AgentLoopBeforeToolCallHookV1): DisposableRegistration;
|
|
1940
|
+
registerLoopHook(position: "afterToolCall", handler: AgentLoopAfterToolCallHookV1): DisposableRegistration;
|
|
1941
|
+
registerLoopHook(position: "transformContext", handler: AgentLoopTransformContextHookV1): DisposableRegistration;
|
|
1942
|
+
registerLoopHook(position: "prepareNextTurn", handler: AgentLoopPrepareNextTurnHookV1): DisposableRegistration;
|
|
1943
|
+
registerLoopHook(position: "shouldStopAfterTurn", handler: AgentLoopShouldStopAfterTurnHookV1): DisposableRegistration;
|
|
1944
|
+
registerRunLoopStrategy(name: string, strategy: AgentRunLoopStrategyV1): DisposableRegistration;
|
|
1945
|
+
subscribe<TEvent>(type: string, handler: (event: EventEnvelope<TEvent>) => void | Promise<void>): DisposableRegistration;
|
|
1946
|
+
publish<TData>(event: Omit<EventEnvelope<TData>, "id" | "timestamp" | "source">): Promise<EventEnvelope<TData>>;
|
|
1947
|
+
call<TResult = unknown>(operation: string, input: unknown, options?: {
|
|
1948
|
+
signal?: AbortSignal;
|
|
1949
|
+
}): OperationHandle<TResult>;
|
|
1950
|
+
}
|
|
1951
|
+
/** Resources owned by a capability plugin beyond runtime registrations. */
|
|
1952
|
+
export interface CapabilityPluginInstance {
|
|
1953
|
+
dispose(): void | Promise<void>;
|
|
1954
|
+
}
|
|
1955
|
+
/** Resources returned by a synchronous embedded plugin factory. */
|
|
1956
|
+
export interface CapabilityPluginSyncInstance {
|
|
1957
|
+
dispose(): void;
|
|
1958
|
+
}
|
|
1959
|
+
export type CapabilityPluginFactoryResult = void | CapabilityPluginInstance;
|
|
1960
|
+
export type CapabilityPluginFactory = (api: CapabilityAPI) => CapabilityPluginFactoryResult | Promise<CapabilityPluginFactoryResult>;
|
|
1961
|
+
export type CapabilityPluginSyncFactory = (api: CapabilityAPI) => void | CapabilityPluginSyncInstance;
|
|
1962
|
+
export declare function createDisposableRegistration(kind: string, dispose: () => void | Promise<void>, id: string): DisposableRegistration;
|
|
1963
|
+
export declare function createEventEnvelope<TData>(event: Omit<EventEnvelope<TData>, "id" | "timestamp">, options: {
|
|
1964
|
+
id: string;
|
|
1965
|
+
timestamp?: number;
|
|
1966
|
+
}): EventEnvelope<TData>;
|
|
1967
|
+
/**
|
|
1968
|
+
* Detach a session value into a read-only projection: the value is deep-cloned
|
|
1969
|
+
* via `structuredClone` and the clone is frozen recursively (ArrayBuffer views
|
|
1970
|
+
* are cloned but not frozen). Lifecycle payload builders use this so handlers
|
|
1971
|
+
* receive data that cannot be mutated in place and share no identity with live
|
|
1972
|
+
* session state. Available to hosts and plugins alike through the public face;
|
|
1973
|
+
* the default loop bootstrap uses it for tool-call inputs and tool-result
|
|
1974
|
+
* content.
|
|
1975
|
+
*/
|
|
1976
|
+
export declare function detachedSessionSnapshot<T>(value: T): T;
|
|
1977
|
+
//# sourceMappingURL=public-api.d.ts.map
|