@arnilo/prism 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +139 -0
- package/dist/agents.d.ts +5 -0
- package/dist/agents.js +439 -0
- package/dist/cli-runner.d.ts +33 -0
- package/dist/cli-runner.js +167 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +10 -0
- package/dist/compaction.d.ts +9 -0
- package/dist/compaction.js +67 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +69 -0
- package/dist/contracts.d.ts +670 -0
- package/dist/contracts.js +2 -0
- package/dist/contributions.d.ts +35 -0
- package/dist/contributions.js +47 -0
- package/dist/credentials.d.ts +22 -0
- package/dist/credentials.js +63 -0
- package/dist/extensions.d.ts +25 -0
- package/dist/extensions.js +131 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.js +28 -0
- package/dist/input.d.ts +57 -0
- package/dist/input.js +225 -0
- package/dist/manifests.d.ts +28 -0
- package/dist/manifests.js +108 -0
- package/dist/middleware.d.ts +15 -0
- package/dist/middleware.js +49 -0
- package/dist/mock-provider.d.ts +6 -0
- package/dist/mock-provider.js +14 -0
- package/dist/models.d.ts +8 -0
- package/dist/models.js +25 -0
- package/dist/node/config.d.ts +9 -0
- package/dist/node/config.js +51 -0
- package/dist/node/session-store-jsonl.d.ts +17 -0
- package/dist/node/session-store-jsonl.js +134 -0
- package/dist/node/settings.d.ts +7 -0
- package/dist/node/settings.js +26 -0
- package/dist/node/trust.d.ts +13 -0
- package/dist/node/trust.js +56 -0
- package/dist/provider-events.d.ts +15 -0
- package/dist/provider-events.js +30 -0
- package/dist/provider-packages.d.ts +4 -0
- package/dist/provider-packages.js +12 -0
- package/dist/provider-request-policy.d.ts +9 -0
- package/dist/provider-request-policy.js +49 -0
- package/dist/providers/openai-compatible.d.ts +9 -0
- package/dist/providers/openai-compatible.js +197 -0
- package/dist/providers.d.ts +8 -0
- package/dist/providers.js +25 -0
- package/dist/redaction.d.ts +11 -0
- package/dist/redaction.js +68 -0
- package/dist/resources.d.ts +5 -0
- package/dist/resources.js +30 -0
- package/dist/retry.d.ts +11 -0
- package/dist/retry.js +48 -0
- package/dist/rpc.d.ts +18 -0
- package/dist/rpc.js +187 -0
- package/dist/security.d.ts +51 -0
- package/dist/security.js +60 -0
- package/dist/session-stores.d.ts +25 -0
- package/dist/session-stores.js +116 -0
- package/dist/settings.d.ts +3 -0
- package/dist/settings.js +26 -0
- package/dist/skills.d.ts +8 -0
- package/dist/skills.js +34 -0
- package/dist/system-prompts.d.ts +6 -0
- package/dist/system-prompts.js +47 -0
- package/dist/testing/provider-conformance.d.ts +36 -0
- package/dist/testing/provider-conformance.js +164 -0
- package/dist/tools.d.ts +25 -0
- package/dist/tools.js +109 -0
- package/docs/agent-session-runtime.md +167 -0
- package/docs/api-page-template.md +32 -0
- package/docs/cli-rpc.md +140 -0
- package/docs/compaction-and-retry.md +177 -0
- package/docs/compaction-llm.md +108 -0
- package/docs/compaction-observational-memory.md +123 -0
- package/docs/configuration-and-manifests.md +142 -0
- package/docs/context-and-skills.md +113 -0
- package/docs/contribution-registries.md +118 -0
- package/docs/credentials-and-redaction.md +122 -0
- package/docs/extensions.md +139 -0
- package/docs/index.md +56 -0
- package/docs/input-and-prompt-assembly.md +168 -0
- package/docs/middleware-hooks.md +123 -0
- package/docs/node-filesystem-config.md +85 -0
- package/docs/node-jsonl-session-store.md +81 -0
- package/docs/provider-conformance.md +109 -0
- package/docs/provider-layer.md +172 -0
- package/docs/provider-packages.md +171 -0
- package/docs/providers/kimi.md +110 -0
- package/docs/providers/openai-compatible.md +125 -0
- package/docs/providers/openai.md +131 -0
- package/docs/providers/opencode-go.md +103 -0
- package/docs/providers/openrouter.md +105 -0
- package/docs/providers/zai.md +108 -0
- package/docs/public-contracts.md +375 -0
- package/docs/release-and-install.md +141 -0
- package/docs/resource-loading.md +97 -0
- package/docs/session-stores-and-branching.md +119 -0
- package/docs/settings-auth-trust-security.md +73 -0
- package/docs/system-prompts.md +116 -0
- package/docs/tools.md +151 -0
- package/package.json +93 -0
|
@@ -0,0 +1,670 @@
|
|
|
1
|
+
import type { ContributionRegistries } from "./contributions.js";
|
|
2
|
+
import type { Middleware, MiddlewareHookName, MiddlewareRegistry } from "./middleware.js";
|
|
3
|
+
import type { SecretRedactor } from "./redaction.js";
|
|
4
|
+
import type { PermissionPolicy } from "./security.js";
|
|
5
|
+
export type JsonPrimitive = string | number | boolean | null;
|
|
6
|
+
export type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
|
|
7
|
+
export interface JsonObject {
|
|
8
|
+
readonly [key: string]: JsonValue;
|
|
9
|
+
}
|
|
10
|
+
export interface ErrorInfo {
|
|
11
|
+
readonly name?: string;
|
|
12
|
+
readonly message: string;
|
|
13
|
+
readonly code?: string | number;
|
|
14
|
+
readonly cause?: unknown;
|
|
15
|
+
}
|
|
16
|
+
export type ContentBlock = TextContent | ImageContent | ThinkingContent | ToolCallContent | ToolResultContent;
|
|
17
|
+
export interface TextContent {
|
|
18
|
+
readonly type: "text";
|
|
19
|
+
readonly text: string;
|
|
20
|
+
}
|
|
21
|
+
export interface ImageContent {
|
|
22
|
+
readonly type: "image";
|
|
23
|
+
readonly mimeType?: string;
|
|
24
|
+
readonly data?: string;
|
|
25
|
+
readonly url?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ThinkingContent {
|
|
28
|
+
readonly type: "thinking";
|
|
29
|
+
readonly text: string;
|
|
30
|
+
readonly signature?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ToolCallContent {
|
|
33
|
+
readonly type: "tool_call";
|
|
34
|
+
readonly id: string;
|
|
35
|
+
readonly name: string;
|
|
36
|
+
readonly arguments: JsonObject;
|
|
37
|
+
}
|
|
38
|
+
export interface ToolResultContent {
|
|
39
|
+
readonly type: "tool_result";
|
|
40
|
+
readonly toolCallId: string;
|
|
41
|
+
readonly name: string;
|
|
42
|
+
readonly result?: unknown;
|
|
43
|
+
readonly error?: ErrorInfo;
|
|
44
|
+
}
|
|
45
|
+
export interface Message {
|
|
46
|
+
readonly id?: string;
|
|
47
|
+
readonly role: "system" | "user" | "assistant" | "tool";
|
|
48
|
+
readonly content: readonly ContentBlock[];
|
|
49
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
50
|
+
}
|
|
51
|
+
export interface ModelConfig {
|
|
52
|
+
readonly provider: string;
|
|
53
|
+
readonly model: string;
|
|
54
|
+
readonly displayName?: string;
|
|
55
|
+
readonly capabilities?: ModelCapabilities;
|
|
56
|
+
readonly limits?: ModelLimits;
|
|
57
|
+
readonly cost?: ModelCost;
|
|
58
|
+
readonly compat?: JsonObject;
|
|
59
|
+
readonly parameters?: Readonly<Record<string, unknown>>;
|
|
60
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
61
|
+
}
|
|
62
|
+
export interface ModelCapabilities {
|
|
63
|
+
readonly input?: readonly string[];
|
|
64
|
+
readonly output?: readonly string[];
|
|
65
|
+
readonly reasoning?: boolean;
|
|
66
|
+
readonly tools?: boolean;
|
|
67
|
+
readonly streaming?: boolean;
|
|
68
|
+
}
|
|
69
|
+
export interface ModelLimits {
|
|
70
|
+
readonly contextWindow?: number;
|
|
71
|
+
readonly maxOutputTokens?: number;
|
|
72
|
+
}
|
|
73
|
+
export interface ModelCost {
|
|
74
|
+
readonly input?: number;
|
|
75
|
+
readonly output?: number;
|
|
76
|
+
readonly cacheRead?: number;
|
|
77
|
+
readonly cacheWrite?: number;
|
|
78
|
+
readonly currency?: string;
|
|
79
|
+
readonly unit?: string;
|
|
80
|
+
}
|
|
81
|
+
export interface Usage {
|
|
82
|
+
readonly inputTokens?: number;
|
|
83
|
+
readonly outputTokens?: number;
|
|
84
|
+
readonly totalTokens?: number;
|
|
85
|
+
readonly cacheReadTokens?: number;
|
|
86
|
+
readonly cacheWriteTokens?: number;
|
|
87
|
+
readonly cost?: number;
|
|
88
|
+
readonly currency?: string;
|
|
89
|
+
}
|
|
90
|
+
export type CacheRetention = "none" | "short" | "long";
|
|
91
|
+
export interface ProviderRequestOptions {
|
|
92
|
+
readonly sessionId?: string;
|
|
93
|
+
readonly cacheRetention?: CacheRetention;
|
|
94
|
+
readonly cacheKey?: string;
|
|
95
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
96
|
+
readonly timeoutMs?: number;
|
|
97
|
+
readonly maxRetries?: number;
|
|
98
|
+
readonly maxRetryDelayMs?: number;
|
|
99
|
+
readonly compat?: JsonObject;
|
|
100
|
+
readonly extra?: JsonObject;
|
|
101
|
+
}
|
|
102
|
+
export interface ProviderRequest {
|
|
103
|
+
readonly model: ModelConfig;
|
|
104
|
+
readonly messages: readonly Message[];
|
|
105
|
+
readonly tools?: readonly ToolDefinition[];
|
|
106
|
+
readonly context?: readonly ContextBlock[];
|
|
107
|
+
readonly options?: ProviderRequestOptions;
|
|
108
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
109
|
+
readonly signal?: AbortSignal;
|
|
110
|
+
}
|
|
111
|
+
export type ProviderEvent = {
|
|
112
|
+
readonly type: "message_start";
|
|
113
|
+
readonly messageId?: string;
|
|
114
|
+
} | {
|
|
115
|
+
readonly type: "content_delta";
|
|
116
|
+
readonly content: ContentBlock;
|
|
117
|
+
} | {
|
|
118
|
+
readonly type: "tool_call_delta";
|
|
119
|
+
readonly index: number;
|
|
120
|
+
readonly id?: string;
|
|
121
|
+
readonly name?: string;
|
|
122
|
+
readonly argumentsText?: string;
|
|
123
|
+
} | {
|
|
124
|
+
readonly type: "tool_call";
|
|
125
|
+
readonly call: ToolCallContent;
|
|
126
|
+
} | {
|
|
127
|
+
readonly type: "usage";
|
|
128
|
+
readonly usage: Usage;
|
|
129
|
+
} | {
|
|
130
|
+
readonly type: "done";
|
|
131
|
+
readonly usage?: Usage;
|
|
132
|
+
} | {
|
|
133
|
+
readonly type: "error";
|
|
134
|
+
readonly error: ErrorInfo;
|
|
135
|
+
};
|
|
136
|
+
export interface AIProvider {
|
|
137
|
+
readonly id: string;
|
|
138
|
+
generate(request: ProviderRequest): AsyncIterable<ProviderEvent>;
|
|
139
|
+
}
|
|
140
|
+
export interface RunOptions {
|
|
141
|
+
readonly signal?: AbortSignal;
|
|
142
|
+
readonly model?: ModelConfig;
|
|
143
|
+
readonly maxToolRounds?: number;
|
|
144
|
+
readonly providerOptions?: ProviderRequestOptions;
|
|
145
|
+
readonly providerRequestPolicies?: ProviderRequestPolicy | readonly ProviderRequestPolicy[];
|
|
146
|
+
readonly systemPrompt?: SystemPromptConfig;
|
|
147
|
+
readonly compaction?: false | CompactionOptions;
|
|
148
|
+
readonly retry?: false | RetryOptions;
|
|
149
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
150
|
+
readonly redactor?: SecretRedactor;
|
|
151
|
+
}
|
|
152
|
+
export interface AgentDefinition {
|
|
153
|
+
readonly name: string;
|
|
154
|
+
readonly description?: string;
|
|
155
|
+
create(config?: AgentConfig): Promise<Agent> | Agent;
|
|
156
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
157
|
+
}
|
|
158
|
+
export interface AgentConfig {
|
|
159
|
+
readonly id?: string;
|
|
160
|
+
readonly name?: string;
|
|
161
|
+
readonly instructions?: string;
|
|
162
|
+
readonly model: ModelConfig;
|
|
163
|
+
readonly provider?: AIProvider;
|
|
164
|
+
readonly tools?: ToolRegistry | readonly ToolDefinition[];
|
|
165
|
+
readonly context?: readonly ContextProvider[];
|
|
166
|
+
readonly skills?: SkillRegistry | readonly Skill[];
|
|
167
|
+
readonly inputBuilder?: InputBuilder;
|
|
168
|
+
readonly promptBuilder?: PromptBuilder;
|
|
169
|
+
readonly middleware?: MiddlewareRegistry;
|
|
170
|
+
readonly resourceLoader?: ResourceLoader;
|
|
171
|
+
readonly extensions?: readonly Extension[];
|
|
172
|
+
readonly store?: SessionStore;
|
|
173
|
+
readonly settings?: SettingsProvider;
|
|
174
|
+
readonly credentials?: CredentialResolver;
|
|
175
|
+
readonly permission?: PermissionPolicy;
|
|
176
|
+
readonly providerOptions?: ProviderRequestOptions;
|
|
177
|
+
readonly providerRequestPolicies?: ProviderRequestPolicy | readonly ProviderRequestPolicy[];
|
|
178
|
+
readonly systemPrompt?: SystemPromptConfig;
|
|
179
|
+
readonly redactor?: SecretRedactor;
|
|
180
|
+
readonly compaction?: false | CompactionOptions;
|
|
181
|
+
readonly retry?: false | RetryOptions;
|
|
182
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
183
|
+
}
|
|
184
|
+
export interface Agent {
|
|
185
|
+
readonly config: AgentConfig;
|
|
186
|
+
createSession(config?: AgentSessionConfig): AgentSession;
|
|
187
|
+
}
|
|
188
|
+
export interface AgentSessionConfig {
|
|
189
|
+
readonly id?: string;
|
|
190
|
+
readonly agent?: Agent;
|
|
191
|
+
readonly store?: SessionStore;
|
|
192
|
+
readonly leafId?: string;
|
|
193
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
194
|
+
}
|
|
195
|
+
export interface AgentSessionForkOptions {
|
|
196
|
+
readonly leafId?: string;
|
|
197
|
+
}
|
|
198
|
+
export interface AgentSessionCloneOptions {
|
|
199
|
+
readonly id?: string;
|
|
200
|
+
readonly leafId?: string;
|
|
201
|
+
}
|
|
202
|
+
export interface AgentSession {
|
|
203
|
+
readonly id: string;
|
|
204
|
+
run(input: string | Message | readonly Message[], options?: RunOptions): Promise<void>;
|
|
205
|
+
prompt(input: string, options?: RunOptions): Promise<void>;
|
|
206
|
+
compact(options?: CompactionOptions): Promise<CompactionResult>;
|
|
207
|
+
subscribe(): AsyncIterable<AgentEvent>;
|
|
208
|
+
abort(reason?: unknown): void;
|
|
209
|
+
entries(): Promise<readonly SessionEntry[]>;
|
|
210
|
+
checkout(leafId?: string): Promise<void>;
|
|
211
|
+
fork(options?: AgentSessionForkOptions): AgentSession;
|
|
212
|
+
clone(options?: AgentSessionCloneOptions): Promise<AgentSession>;
|
|
213
|
+
}
|
|
214
|
+
export type AgentEvent = {
|
|
215
|
+
readonly type: "agent_started";
|
|
216
|
+
readonly sessionId: string;
|
|
217
|
+
readonly runId: string;
|
|
218
|
+
} | {
|
|
219
|
+
readonly type: "agent_finished";
|
|
220
|
+
readonly sessionId: string;
|
|
221
|
+
readonly runId: string;
|
|
222
|
+
readonly usage?: Usage;
|
|
223
|
+
} | {
|
|
224
|
+
readonly type: "turn_started";
|
|
225
|
+
readonly sessionId: string;
|
|
226
|
+
readonly runId: string;
|
|
227
|
+
readonly turn: number;
|
|
228
|
+
} | {
|
|
229
|
+
readonly type: "turn_finished";
|
|
230
|
+
readonly sessionId: string;
|
|
231
|
+
readonly runId: string;
|
|
232
|
+
readonly turn: number;
|
|
233
|
+
} | {
|
|
234
|
+
readonly type: "message_started";
|
|
235
|
+
readonly sessionId: string;
|
|
236
|
+
readonly runId: string;
|
|
237
|
+
readonly message: Message;
|
|
238
|
+
} | {
|
|
239
|
+
readonly type: "message_delta";
|
|
240
|
+
readonly sessionId: string;
|
|
241
|
+
readonly runId: string;
|
|
242
|
+
readonly content: ContentBlock;
|
|
243
|
+
} | {
|
|
244
|
+
readonly type: "message_finished";
|
|
245
|
+
readonly sessionId: string;
|
|
246
|
+
readonly runId: string;
|
|
247
|
+
readonly message: Message;
|
|
248
|
+
} | {
|
|
249
|
+
readonly type: "tool_execution_started";
|
|
250
|
+
readonly sessionId: string;
|
|
251
|
+
readonly runId: string;
|
|
252
|
+
readonly call: ToolCallContent;
|
|
253
|
+
} | {
|
|
254
|
+
readonly type: "tool_execution_progress";
|
|
255
|
+
readonly sessionId: string;
|
|
256
|
+
readonly runId: string;
|
|
257
|
+
readonly toolCallId: string;
|
|
258
|
+
readonly name: string;
|
|
259
|
+
readonly progress?: unknown;
|
|
260
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
261
|
+
} | {
|
|
262
|
+
readonly type: "tool_execution_finished";
|
|
263
|
+
readonly sessionId: string;
|
|
264
|
+
readonly runId: string;
|
|
265
|
+
readonly result: ToolResult;
|
|
266
|
+
} | {
|
|
267
|
+
readonly type: "tool_execution_error";
|
|
268
|
+
readonly sessionId: string;
|
|
269
|
+
readonly runId: string;
|
|
270
|
+
readonly call: ToolCallContent;
|
|
271
|
+
readonly error: ErrorInfo;
|
|
272
|
+
} | {
|
|
273
|
+
readonly type: "tool_execution_blocked";
|
|
274
|
+
readonly sessionId: string;
|
|
275
|
+
readonly runId: string;
|
|
276
|
+
readonly toolCallId: string;
|
|
277
|
+
readonly name: string;
|
|
278
|
+
readonly reason: string;
|
|
279
|
+
readonly error: ErrorInfo;
|
|
280
|
+
} | {
|
|
281
|
+
readonly type: "queue_updated";
|
|
282
|
+
readonly sessionId: string;
|
|
283
|
+
readonly runId: string;
|
|
284
|
+
readonly size: number;
|
|
285
|
+
} | {
|
|
286
|
+
readonly type: "compaction_started";
|
|
287
|
+
readonly sessionId: string;
|
|
288
|
+
readonly runId?: string;
|
|
289
|
+
} | {
|
|
290
|
+
readonly type: "compaction_finished";
|
|
291
|
+
readonly sessionId: string;
|
|
292
|
+
readonly runId?: string;
|
|
293
|
+
readonly summary: string;
|
|
294
|
+
} | {
|
|
295
|
+
readonly type: "retry_scheduled";
|
|
296
|
+
readonly sessionId: string;
|
|
297
|
+
readonly runId: string;
|
|
298
|
+
readonly attempt: number;
|
|
299
|
+
readonly delayMs: number;
|
|
300
|
+
readonly error: ErrorInfo;
|
|
301
|
+
} | {
|
|
302
|
+
readonly type: "error";
|
|
303
|
+
readonly sessionId?: string;
|
|
304
|
+
readonly runId?: string;
|
|
305
|
+
readonly error: ErrorInfo;
|
|
306
|
+
};
|
|
307
|
+
export interface ToolDefinition {
|
|
308
|
+
readonly name: string;
|
|
309
|
+
readonly description?: string;
|
|
310
|
+
readonly parameters?: JsonObject;
|
|
311
|
+
execute(args: JsonObject, context: ToolExecutionContext): Promise<ToolResult> | ToolResult;
|
|
312
|
+
}
|
|
313
|
+
export interface ToolRegistry {
|
|
314
|
+
register(tool: ToolDefinition): void;
|
|
315
|
+
get(name: string): ToolDefinition | undefined;
|
|
316
|
+
resolve(name: string): ToolDefinition;
|
|
317
|
+
list(): readonly ToolDefinition[];
|
|
318
|
+
}
|
|
319
|
+
export interface ToolExecutionContext {
|
|
320
|
+
readonly sessionId: string;
|
|
321
|
+
readonly runId: string;
|
|
322
|
+
readonly toolCallId: string;
|
|
323
|
+
readonly signal?: AbortSignal;
|
|
324
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
325
|
+
progress?(progress?: unknown, metadata?: Readonly<Record<string, unknown>>): void | Promise<void>;
|
|
326
|
+
}
|
|
327
|
+
export interface ToolResult {
|
|
328
|
+
readonly toolCallId: string;
|
|
329
|
+
readonly name: string;
|
|
330
|
+
readonly content?: readonly ContentBlock[];
|
|
331
|
+
readonly value?: unknown;
|
|
332
|
+
readonly error?: ErrorInfo;
|
|
333
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
334
|
+
}
|
|
335
|
+
export interface CommandDefinition {
|
|
336
|
+
readonly name: string;
|
|
337
|
+
readonly description?: string;
|
|
338
|
+
readonly parameters?: JsonObject;
|
|
339
|
+
execute(args: JsonObject, context: CommandExecutionContext): Promise<CommandResult> | CommandResult;
|
|
340
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
341
|
+
}
|
|
342
|
+
export interface CommandExecutionContext {
|
|
343
|
+
readonly sessionId?: string;
|
|
344
|
+
readonly runId?: string;
|
|
345
|
+
readonly signal?: AbortSignal;
|
|
346
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
347
|
+
}
|
|
348
|
+
export interface CommandResult {
|
|
349
|
+
readonly name: string;
|
|
350
|
+
readonly content?: readonly ContentBlock[];
|
|
351
|
+
readonly value?: unknown;
|
|
352
|
+
readonly error?: ErrorInfo;
|
|
353
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
354
|
+
}
|
|
355
|
+
export interface ContextBlock {
|
|
356
|
+
readonly id?: string;
|
|
357
|
+
readonly title?: string;
|
|
358
|
+
readonly content: string | readonly ContentBlock[];
|
|
359
|
+
readonly priority?: number;
|
|
360
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
361
|
+
}
|
|
362
|
+
export interface ContextProvider {
|
|
363
|
+
readonly name: string;
|
|
364
|
+
resolve(context: ContextResolutionContext): Promise<readonly ContextBlock[]> | readonly ContextBlock[];
|
|
365
|
+
}
|
|
366
|
+
export interface ContextResolutionContext {
|
|
367
|
+
readonly sessionId?: string;
|
|
368
|
+
readonly runId?: string;
|
|
369
|
+
readonly messages: readonly Message[];
|
|
370
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
371
|
+
readonly signal?: AbortSignal;
|
|
372
|
+
}
|
|
373
|
+
export interface InputBuilder {
|
|
374
|
+
readonly name: string;
|
|
375
|
+
build(input: string | Message | readonly Message[], context?: InputBuildContext): Promise<readonly Message[]> | readonly Message[];
|
|
376
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
377
|
+
}
|
|
378
|
+
export interface InputBuildContext {
|
|
379
|
+
readonly sessionId?: string;
|
|
380
|
+
readonly runId?: string;
|
|
381
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
382
|
+
readonly signal?: AbortSignal;
|
|
383
|
+
}
|
|
384
|
+
export interface PromptBuilder {
|
|
385
|
+
readonly name: string;
|
|
386
|
+
build(request: PromptBuildRequest): Promise<readonly Message[]> | readonly Message[];
|
|
387
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
388
|
+
}
|
|
389
|
+
export interface PromptBuildRequest {
|
|
390
|
+
readonly messages: readonly Message[];
|
|
391
|
+
readonly context?: readonly ContextBlock[];
|
|
392
|
+
readonly skills?: readonly Skill[];
|
|
393
|
+
readonly tools?: readonly ToolDefinition[];
|
|
394
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
395
|
+
readonly signal?: AbortSignal;
|
|
396
|
+
}
|
|
397
|
+
export interface Skill {
|
|
398
|
+
readonly name: string;
|
|
399
|
+
readonly description?: string;
|
|
400
|
+
readonly instructions?: string;
|
|
401
|
+
readonly context?: readonly ContextProvider[];
|
|
402
|
+
readonly toolNames?: readonly string[];
|
|
403
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
404
|
+
}
|
|
405
|
+
export interface SkillRegistry {
|
|
406
|
+
register(skill: Skill): void;
|
|
407
|
+
get(name: string): Skill | undefined;
|
|
408
|
+
resolve(name: string): Skill;
|
|
409
|
+
list(): readonly Skill[];
|
|
410
|
+
}
|
|
411
|
+
export type ExtensionLifecycleEventName = "resource_discovery" | "session_start" | "session_shutdown" | "before_agent_start" | "turn" | "context" | "provider_request" | "tool_call" | "tool_result" | "compaction" | "retry";
|
|
412
|
+
export interface ExtensionEvent {
|
|
413
|
+
readonly type: ExtensionLifecycleEventName | "extension_error" | string;
|
|
414
|
+
readonly payload?: unknown;
|
|
415
|
+
readonly extension?: string;
|
|
416
|
+
readonly error?: ErrorInfo;
|
|
417
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
418
|
+
}
|
|
419
|
+
export interface Extension {
|
|
420
|
+
readonly name: string;
|
|
421
|
+
setup(api: ExtensionAPI): void | Promise<void>;
|
|
422
|
+
}
|
|
423
|
+
export interface ProviderPackage {
|
|
424
|
+
readonly name: string;
|
|
425
|
+
readonly version?: string;
|
|
426
|
+
readonly description?: string;
|
|
427
|
+
readonly docs?: ProviderPackageDocs;
|
|
428
|
+
setup(api: ProviderPackageAPI): void | Promise<void>;
|
|
429
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
430
|
+
}
|
|
431
|
+
export interface ProviderPackageDocs {
|
|
432
|
+
readonly description?: string;
|
|
433
|
+
readonly links?: readonly string[];
|
|
434
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
435
|
+
}
|
|
436
|
+
export interface ProviderPackageAPI extends ExtensionAPI {
|
|
437
|
+
}
|
|
438
|
+
export type AuthMethod = ApiKeyAuthMethod | OAuthAuthMethod | CustomAuthMethod;
|
|
439
|
+
export interface ApiKeyAuthMethod {
|
|
440
|
+
readonly kind: "api_key";
|
|
441
|
+
readonly provider: string;
|
|
442
|
+
readonly name?: string;
|
|
443
|
+
readonly credentialName?: string;
|
|
444
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
445
|
+
}
|
|
446
|
+
export interface OAuthAuthMethod {
|
|
447
|
+
readonly kind: "oauth";
|
|
448
|
+
readonly provider: string;
|
|
449
|
+
readonly name?: string;
|
|
450
|
+
readonly oauth?: OAuthProvider;
|
|
451
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
452
|
+
}
|
|
453
|
+
export interface OAuthLoginCallbacks {
|
|
454
|
+
onAuth?(url: string): void | Promise<void>;
|
|
455
|
+
onDeviceCode?(code: {
|
|
456
|
+
readonly userCode: string;
|
|
457
|
+
readonly verificationUri: string;
|
|
458
|
+
readonly expiresAt?: string;
|
|
459
|
+
}): void | Promise<void>;
|
|
460
|
+
onPrompt?(message: string): string | undefined | Promise<string | undefined>;
|
|
461
|
+
onSelect?(prompt: {
|
|
462
|
+
readonly message: string;
|
|
463
|
+
readonly choices: readonly string[];
|
|
464
|
+
}): string | undefined | Promise<string | undefined>;
|
|
465
|
+
}
|
|
466
|
+
export interface OAuthCredentials {
|
|
467
|
+
readonly access?: string;
|
|
468
|
+
readonly refresh?: string;
|
|
469
|
+
readonly expires?: string | number;
|
|
470
|
+
readonly accountId?: string;
|
|
471
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
472
|
+
}
|
|
473
|
+
export interface OAuthProvider {
|
|
474
|
+
readonly id: string;
|
|
475
|
+
login(callbacks?: OAuthLoginCallbacks): Promise<OAuthCredentials> | OAuthCredentials;
|
|
476
|
+
refresh?(credentials: OAuthCredentials): Promise<OAuthCredentials> | OAuthCredentials;
|
|
477
|
+
getCredential?(credentials: OAuthCredentials): Promise<Credential | undefined> | Credential | undefined;
|
|
478
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
479
|
+
}
|
|
480
|
+
export interface CustomAuthMethod {
|
|
481
|
+
readonly kind: "custom" | string;
|
|
482
|
+
readonly provider: string;
|
|
483
|
+
readonly name?: string;
|
|
484
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
485
|
+
}
|
|
486
|
+
export interface ProviderRequestPolicy {
|
|
487
|
+
readonly name: string;
|
|
488
|
+
apply(context: ProviderRequestPolicyContext): Promise<ProviderRequest | ProviderRequestPolicyResult> | ProviderRequest | ProviderRequestPolicyResult;
|
|
489
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
490
|
+
}
|
|
491
|
+
export interface ProviderRequestPolicyContext {
|
|
492
|
+
readonly request: ProviderRequest;
|
|
493
|
+
readonly sessionId?: string;
|
|
494
|
+
readonly runId?: string;
|
|
495
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
496
|
+
readonly signal?: AbortSignal;
|
|
497
|
+
}
|
|
498
|
+
export interface ProviderRequestPolicyResult {
|
|
499
|
+
readonly request: ProviderRequest;
|
|
500
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
501
|
+
}
|
|
502
|
+
export type SystemPromptMode = "append" | "prepend" | "replace" | "disable";
|
|
503
|
+
export type SystemPromptSource = "package" | "app" | "user" | "run" | string;
|
|
504
|
+
export interface SystemPromptContribution {
|
|
505
|
+
readonly id: string;
|
|
506
|
+
readonly source?: SystemPromptSource;
|
|
507
|
+
readonly mode?: SystemPromptMode;
|
|
508
|
+
readonly text: string;
|
|
509
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
510
|
+
}
|
|
511
|
+
export type SystemPromptConfig = false | SystemPromptContribution | readonly SystemPromptContribution[];
|
|
512
|
+
export interface ExtensionAPI {
|
|
513
|
+
readonly registries: ContributionRegistries;
|
|
514
|
+
readonly middleware: MiddlewareRegistry;
|
|
515
|
+
on(type: ExtensionLifecycleEventName | string, handler: (event: ExtensionEvent) => void | Promise<void>): () => void;
|
|
516
|
+
emit(event: ExtensionEvent): Promise<void>;
|
|
517
|
+
use<T>(hook: MiddlewareHookName | string, middleware: Middleware<T>): () => void;
|
|
518
|
+
registerProvider(provider: AIProvider): void;
|
|
519
|
+
registerModel(model: ModelConfig): void;
|
|
520
|
+
registerTool(tool: ToolDefinition): void;
|
|
521
|
+
registerContextProvider(provider: ContextProvider): void;
|
|
522
|
+
registerSkill(skill: Skill): void;
|
|
523
|
+
registerCommand(command: CommandDefinition): void;
|
|
524
|
+
registerAgent(agent: AgentDefinition): void;
|
|
525
|
+
registerInputBuilder(builder: InputBuilder): void;
|
|
526
|
+
registerPromptBuilder(builder: PromptBuilder): void;
|
|
527
|
+
registerCompactionStrategy(strategy: CompactionStrategy): void;
|
|
528
|
+
registerRetryPolicy(policy: RetryPolicy): void;
|
|
529
|
+
registerStoreFactory(factory: StoreFactory): void;
|
|
530
|
+
registerResourceLoader(key: string, loader: ResourceLoader): void;
|
|
531
|
+
registerSettingsProvider(key: string, provider: SettingsProvider): void;
|
|
532
|
+
registerCredentialResolver(key: string, resolver: CredentialResolver): void;
|
|
533
|
+
registerProviderPackage(providerPackage: ProviderPackage): void;
|
|
534
|
+
registerAuthMethod(method: AuthMethod): void;
|
|
535
|
+
registerProviderRequestPolicy(policy: ProviderRequestPolicy): void;
|
|
536
|
+
registerSystemPromptContribution(contribution: SystemPromptContribution): void;
|
|
537
|
+
}
|
|
538
|
+
export interface SessionEntry {
|
|
539
|
+
readonly id: string;
|
|
540
|
+
readonly parentId?: string;
|
|
541
|
+
readonly sessionId: string;
|
|
542
|
+
readonly timestamp: string;
|
|
543
|
+
readonly kind: "message" | "event" | "summary" | "metadata" | "model_change" | "label" | "custom" | "compaction";
|
|
544
|
+
readonly runId?: string;
|
|
545
|
+
readonly message?: Message;
|
|
546
|
+
readonly event?: AgentEvent;
|
|
547
|
+
readonly model?: ModelConfig;
|
|
548
|
+
readonly previousModel?: ModelConfig;
|
|
549
|
+
readonly label?: string;
|
|
550
|
+
readonly summary?: string;
|
|
551
|
+
readonly data?: unknown;
|
|
552
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
553
|
+
}
|
|
554
|
+
export interface SessionStore {
|
|
555
|
+
append(entry: SessionEntry): Promise<void>;
|
|
556
|
+
list(sessionId: string): Promise<readonly SessionEntry[]>;
|
|
557
|
+
get?(id: string): Promise<SessionEntry | undefined>;
|
|
558
|
+
}
|
|
559
|
+
export interface StoreFactory {
|
|
560
|
+
readonly name: string;
|
|
561
|
+
create(config?: JsonObject): Promise<SessionStore> | SessionStore;
|
|
562
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
563
|
+
}
|
|
564
|
+
export interface CompactionStrategy {
|
|
565
|
+
readonly name: string;
|
|
566
|
+
compact(context: CompactionContext): Promise<CompactionResult> | CompactionResult;
|
|
567
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
568
|
+
}
|
|
569
|
+
export interface CompactionContext {
|
|
570
|
+
readonly sessionId: string;
|
|
571
|
+
readonly entries: readonly SessionEntry[];
|
|
572
|
+
readonly keepRecentEntries?: number;
|
|
573
|
+
readonly trigger?: "manual" | "auto" | string;
|
|
574
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
575
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
576
|
+
readonly signal?: AbortSignal;
|
|
577
|
+
}
|
|
578
|
+
export interface CompactionResult {
|
|
579
|
+
readonly summary: string;
|
|
580
|
+
readonly entries?: readonly SessionEntry[];
|
|
581
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
582
|
+
}
|
|
583
|
+
export interface CompactionOptions {
|
|
584
|
+
readonly strategy?: CompactionStrategy;
|
|
585
|
+
readonly thresholdEntries?: number;
|
|
586
|
+
readonly keepRecentEntries?: number;
|
|
587
|
+
readonly maxSummaryChars?: number;
|
|
588
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
589
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
590
|
+
readonly signal?: AbortSignal;
|
|
591
|
+
}
|
|
592
|
+
export interface CompactionMiddlewarePayload {
|
|
593
|
+
readonly context: CompactionContext;
|
|
594
|
+
readonly result: CompactionResult;
|
|
595
|
+
}
|
|
596
|
+
export interface CompactionEntryData {
|
|
597
|
+
readonly throughEntryId?: string;
|
|
598
|
+
readonly keepEntryIds?: readonly string[];
|
|
599
|
+
readonly strategy?: string;
|
|
600
|
+
readonly trigger?: "manual" | "auto" | string;
|
|
601
|
+
}
|
|
602
|
+
export interface RetryPolicy {
|
|
603
|
+
readonly name: string;
|
|
604
|
+
decide(context: RetryContext): Promise<RetryDecision> | RetryDecision;
|
|
605
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
606
|
+
}
|
|
607
|
+
export interface RetryContext {
|
|
608
|
+
readonly sessionId: string;
|
|
609
|
+
readonly runId: string;
|
|
610
|
+
readonly attempt: number;
|
|
611
|
+
readonly error: ErrorInfo;
|
|
612
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
613
|
+
readonly signal?: AbortSignal;
|
|
614
|
+
}
|
|
615
|
+
export interface RetryDecision {
|
|
616
|
+
readonly retry: boolean;
|
|
617
|
+
readonly delayMs?: number;
|
|
618
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
619
|
+
}
|
|
620
|
+
export interface RetryOptions {
|
|
621
|
+
readonly policy?: RetryPolicy;
|
|
622
|
+
readonly maxAttempts?: number;
|
|
623
|
+
readonly baseDelayMs?: number;
|
|
624
|
+
readonly maxDelayMs?: number;
|
|
625
|
+
readonly secrets?: readonly (string | undefined)[];
|
|
626
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
627
|
+
}
|
|
628
|
+
export interface RetryMiddlewarePayload {
|
|
629
|
+
readonly context: RetryContext;
|
|
630
|
+
readonly decision: RetryDecision;
|
|
631
|
+
}
|
|
632
|
+
export interface Resource {
|
|
633
|
+
readonly uri: string;
|
|
634
|
+
readonly mediaType?: string;
|
|
635
|
+
readonly text?: string;
|
|
636
|
+
readonly data?: Uint8Array;
|
|
637
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
638
|
+
}
|
|
639
|
+
export interface ResourceLoader {
|
|
640
|
+
load(uri: string, context?: ResourceLoadContext): Promise<Resource>;
|
|
641
|
+
list?(context?: ResourceLoadContext): Promise<readonly Resource[]>;
|
|
642
|
+
}
|
|
643
|
+
export interface ResourceLoadContext {
|
|
644
|
+
readonly signal?: AbortSignal;
|
|
645
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
646
|
+
readonly permission?: PermissionPolicy;
|
|
647
|
+
}
|
|
648
|
+
export interface SettingsProvider {
|
|
649
|
+
get<T = unknown>(key: string): Promise<T | undefined> | T | undefined;
|
|
650
|
+
}
|
|
651
|
+
export interface CredentialRequest {
|
|
652
|
+
readonly name: string;
|
|
653
|
+
readonly provider?: string;
|
|
654
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
655
|
+
}
|
|
656
|
+
export interface Credential {
|
|
657
|
+
readonly type: "bearer" | "api_key" | "basic" | "custom";
|
|
658
|
+
readonly value: string;
|
|
659
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
660
|
+
}
|
|
661
|
+
export interface CredentialResolver {
|
|
662
|
+
resolve(request: CredentialRequest): Promise<Credential | undefined> | Credential | undefined;
|
|
663
|
+
}
|
|
664
|
+
export interface CredentialResolverSource {
|
|
665
|
+
readonly name: string;
|
|
666
|
+
readonly resolver: CredentialResolver;
|
|
667
|
+
}
|
|
668
|
+
export interface OAuthCredentialStore {
|
|
669
|
+
set(provider: string, credentials: OAuthCredentials): void | Promise<void>;
|
|
670
|
+
}
|