@github/copilot-sdk-darwin-arm64 0.0.1 → 1.0.13-preview.6
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/animations/app-install-nudge.json.gz +0 -0
- package/animations/banner.json.gz +0 -0
- package/builtin/customize-cloud-agent/SKILL.md +254 -0
- package/builtin/discover-resources/SKILL.md +35 -0
- package/builtin/github-pr-media/SKILL.md +108 -0
- package/builtin-skills/customize-cloud-agent/SKILL.md +254 -0
- package/builtin-skills/discover-resources/SKILL.md +35 -0
- package/builtin-skills/github-pr-media/SKILL.md +108 -0
- package/copilot-sdk/canvas.d.ts +126 -0
- package/copilot-sdk/client.d.ts +478 -0
- package/copilot-sdk/copilotRequestHandler.d.ts +85 -0
- package/copilot-sdk/docs/agent-author.md +295 -0
- package/copilot-sdk/docs/examples.md +682 -0
- package/copilot-sdk/docs/extensions.md +81 -0
- package/copilot-sdk/docs/factories.md +279 -0
- package/copilot-sdk/docs/factory-patterns.md +194 -0
- package/copilot-sdk/extension.d.ts +59 -0
- package/copilot-sdk/extension.js +11399 -0
- package/copilot-sdk/factory.d.ts +301 -0
- package/copilot-sdk/ffiRuntimeHost.d.ts +35 -0
- package/copilot-sdk/generated/rpc.d.ts +24623 -0
- package/copilot-sdk/generated/session-events.d.ts +11117 -0
- package/copilot-sdk/index.d.ts +15 -0
- package/copilot-sdk/index.js +11540 -0
- package/copilot-sdk/runtimeArtifacts.d.ts +6 -0
- package/copilot-sdk/sdkProtocolVersion.d.ts +10 -0
- package/copilot-sdk/session.d.ts +331 -0
- package/copilot-sdk/sessionFsProvider.d.ts +107 -0
- package/copilot-sdk/telemetry.d.ts +14 -0
- package/copilot-sdk/toolSet.d.ts +75 -0
- package/copilot-sdk/types.d.ts +2974 -0
- package/definitions/code-review.agent.yaml +94 -0
- package/definitions/explore.agent.yaml +75 -0
- package/definitions/rem-agent.agent.yaml +22 -0
- package/definitions/research.agent.yaml +111 -0
- package/definitions/rubber-duck.agent.yaml +67 -0
- package/definitions/security-review.agent.yaml +261 -0
- package/definitions/sidekick/cloud-session-search.yaml +37 -0
- package/definitions/sidekick/github-context-memory.yaml +46 -0
- package/definitions/sidekick/github-context.yaml +44 -0
- package/definitions/sidekick/session-search.yaml +37 -0
- package/definitions/sidekick/subconscious-agent.yaml +60 -0
- package/definitions/sidekick/test-sidekick-context-changed.yaml +24 -0
- package/definitions/sidekick/test-sidekick-persistent.yaml +23 -0
- package/definitions/sidekick/test-sidekick-restart.yaml +23 -0
- package/definitions/sidekick/test-sidekick-trigger-once.yaml +22 -0
- package/definitions/task.agent.yaml +44 -0
- package/package.json +14 -11
- package/plugins/computer-use/.mcp.json +10 -0
- package/plugins/computer-use/.plugin/plugin.json +6 -0
- package/plugins/computer-use/.release-target +1 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/CodeResources +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/Info.plist +38 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/MacOS/Copilot Computer Use +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/PkgInfo +1 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/Resources/Assets.car +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/Resources/icon.icns +0 -0
- package/plugins/computer-use/Copilot Computer Use.app/Contents/_CodeSignature/CodeResources +139 -0
- package/plugins/computer-use/computer-use-mcp +0 -0
- package/prebuilds/darwin-arm64/copilot-runtime +0 -0
- package/prebuilds/darwin-arm64/runtime.node +0 -0
- package/preloads/extension_bootstrap.mjs +68 -0
- package/preloads/extension_sdk_resolver.mjs +34 -0
- package/ripgrep/bin/darwin-arm64/rg +0 -0
- package/schemas/api.schema.json +41931 -0
- package/schemas/session-events.schema.json +20937 -0
- package/sdk/index.js +1489 -0
- package/tgrep/bin/darwin-arm64/tgrep +0 -0
- package/README.md +0 -3
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface RuntimeArtifactSources {
|
|
2
|
+
packageRoot: string;
|
|
3
|
+
platform: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function defaultRuntimeCacheRoot(platform?: NodeJS.Platform, home?: string, environment?: NodeJS.ProcessEnv): string;
|
|
6
|
+
export declare function materializeRuntimeBundle(sources: RuntimeArtifactSources, cacheRoot?: string): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK protocol version.
|
|
3
|
+
* This must match the version expected by the copilot-agent-runtime server.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SDK_PROTOCOL_VERSION = 3;
|
|
6
|
+
/**
|
|
7
|
+
* Gets the SDK protocol version.
|
|
8
|
+
* @returns The protocol version number
|
|
9
|
+
*/
|
|
10
|
+
export declare function getSdkProtocolVersion(): number;
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { createSessionRpc } from "./generated/rpc.js";
|
|
2
|
+
import type { OpenCanvasInstance } from "./generated/rpc.js";
|
|
3
|
+
import type { MessageOptions, ContextTier, ReasoningEffort, ReasoningSummary, ModelCapabilitiesOverride, SessionCapabilities, SessionEvent, SessionEventHandler, SessionEventType, SessionUiApi, TypedSessionEventHandler } from "./types.js";
|
|
4
|
+
import { type SessionFactoryApi } from "./factory.js";
|
|
5
|
+
/** Assistant message event - the final response from the assistant. */
|
|
6
|
+
export type AssistantMessageEvent = Extract<SessionEvent, {
|
|
7
|
+
type: "assistant.message";
|
|
8
|
+
}>;
|
|
9
|
+
/**
|
|
10
|
+
* Represents a single conversation session with the Copilot CLI.
|
|
11
|
+
*
|
|
12
|
+
* A session maintains conversation state, handles events, and manages tool execution.
|
|
13
|
+
* Sessions are created via {@link CopilotClient.createSession} or resumed via
|
|
14
|
+
* {@link CopilotClient.resumeSession}.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const session = await client.createSession({ model: "gpt-4" });
|
|
19
|
+
*
|
|
20
|
+
* // Subscribe to events
|
|
21
|
+
* session.on((event) => {
|
|
22
|
+
* if (event.type === "assistant.message") {
|
|
23
|
+
* console.log(event.data.content);
|
|
24
|
+
* }
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* // Send a message and wait for completion
|
|
28
|
+
* await session.sendAndWait({ prompt: "Hello, world!" });
|
|
29
|
+
*
|
|
30
|
+
* // Clean up
|
|
31
|
+
* await session.disconnect();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* Fixed name of the runtime's built-in tool-search tool. A client can replace
|
|
36
|
+
* its behavior by registering a {@link Tool} with this exact name and
|
|
37
|
+
* `overridesBuiltInTool: true`.
|
|
38
|
+
*/
|
|
39
|
+
export declare class CopilotSession {
|
|
40
|
+
readonly sessionId: string;
|
|
41
|
+
private connection;
|
|
42
|
+
private _workspacePath?;
|
|
43
|
+
private eventHandlers;
|
|
44
|
+
private typedEventHandlers;
|
|
45
|
+
private toolHandlers;
|
|
46
|
+
private canvases;
|
|
47
|
+
private bearerTokenProviders;
|
|
48
|
+
private commandHandlers;
|
|
49
|
+
private factories;
|
|
50
|
+
private factoryAbortControllers;
|
|
51
|
+
private permissionHandler?;
|
|
52
|
+
private mcpAuthHandler?;
|
|
53
|
+
private userInputHandler?;
|
|
54
|
+
private elicitationHandler?;
|
|
55
|
+
private exitPlanModeHandler?;
|
|
56
|
+
private autoModeSwitchHandler?;
|
|
57
|
+
private hooks?;
|
|
58
|
+
private transformCallbacks?;
|
|
59
|
+
private _rpc;
|
|
60
|
+
private traceContextProvider?;
|
|
61
|
+
private readonly managedSettingsEnabled;
|
|
62
|
+
private _capabilities;
|
|
63
|
+
private openCanvasInstances;
|
|
64
|
+
private disconnected;
|
|
65
|
+
private onDisconnected?;
|
|
66
|
+
/**
|
|
67
|
+
* Friendly factory API for running registered factories by name or handle.
|
|
68
|
+
*
|
|
69
|
+
* @experimental Part of the experimental Agent Factories surface and may
|
|
70
|
+
* change or be removed in future SDK or CLI releases.
|
|
71
|
+
*/
|
|
72
|
+
readonly factory: SessionFactoryApi;
|
|
73
|
+
/**
|
|
74
|
+
* Resolve a start/resume envelope into the terminal envelope callers expect.
|
|
75
|
+
*
|
|
76
|
+
* The CLI may answer `session.factory.run` and `session.factory.resume`
|
|
77
|
+
* before the run settles, so a non-terminal envelope is followed by a wait
|
|
78
|
+
* on the run's terminal state.
|
|
79
|
+
*/
|
|
80
|
+
private settleFactoryRun;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve when a factory run reaches a terminal status.
|
|
83
|
+
*
|
|
84
|
+
* The subscription is installed *before* the first read so a transition
|
|
85
|
+
* landing between the two cannot be missed, and re-reads are serialized so
|
|
86
|
+
* overlapping invalidation events cannot interleave — the run's revision
|
|
87
|
+
* advances once per operation, so a burst of events is common and must
|
|
88
|
+
* collapse into a single in-flight read. A bounded periodic re-read keeps a
|
|
89
|
+
* dropped invalidation from leaving the wait pending forever.
|
|
90
|
+
*/
|
|
91
|
+
private waitForFactoryRun;
|
|
92
|
+
/**
|
|
93
|
+
* Typed session-scoped RPC methods.
|
|
94
|
+
*/
|
|
95
|
+
get rpc(): ReturnType<typeof createSessionRpc>;
|
|
96
|
+
/**
|
|
97
|
+
* Path to the session workspace directory when infinite sessions are enabled.
|
|
98
|
+
* Contains checkpoints/, plan.md, and files/ subdirectories.
|
|
99
|
+
* Undefined if infinite sessions are disabled.
|
|
100
|
+
*/
|
|
101
|
+
get workspacePath(): string | undefined;
|
|
102
|
+
/**
|
|
103
|
+
* Host capabilities reported when the session was created or resumed.
|
|
104
|
+
* Use this to check feature support before calling capability-gated APIs.
|
|
105
|
+
*/
|
|
106
|
+
get capabilities(): SessionCapabilities;
|
|
107
|
+
/**
|
|
108
|
+
* Interactive UI methods for showing dialogs to the user.
|
|
109
|
+
* Only available when the CLI host supports elicitation
|
|
110
|
+
* (`session.capabilities.ui?.elicitation === true`).
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* if (session.capabilities.ui?.elicitation) {
|
|
115
|
+
* const ok = await session.ui.confirm("Deploy to production?");
|
|
116
|
+
* }
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
get ui(): SessionUiApi;
|
|
120
|
+
/**
|
|
121
|
+
* Sends a message to this session and waits for the response.
|
|
122
|
+
*
|
|
123
|
+
* The message is processed asynchronously. Subscribe to events via {@link on}
|
|
124
|
+
* to receive streaming responses and other session events.
|
|
125
|
+
*
|
|
126
|
+
* @param options - The message options including the prompt and optional attachments
|
|
127
|
+
* @returns A promise that resolves with the message ID of the response
|
|
128
|
+
* @throws Error if the session has been disconnected or the connection fails
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* ```typescript
|
|
132
|
+
* const messageId = await session.send({
|
|
133
|
+
* prompt: "Explain this code",
|
|
134
|
+
* attachments: [{ type: "file", path: "./src/index.ts" }]
|
|
135
|
+
* });
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
send(prompt: string): Promise<string>;
|
|
139
|
+
send(options: MessageOptions): Promise<string>;
|
|
140
|
+
/**
|
|
141
|
+
* Sends a message to this session and waits until the session becomes idle.
|
|
142
|
+
*
|
|
143
|
+
* This is a convenience method that combines {@link send} with waiting for
|
|
144
|
+
* the `session.idle` event. Use this when you want to block until the
|
|
145
|
+
* assistant has finished processing the message.
|
|
146
|
+
*
|
|
147
|
+
* Events are still delivered to handlers registered via {@link on} while waiting.
|
|
148
|
+
*
|
|
149
|
+
* @param options - The message options including the prompt and optional attachments
|
|
150
|
+
* @param timeout - Timeout in milliseconds (default: 60000). Controls how long to wait; does not abort in-flight agent work.
|
|
151
|
+
* @returns A promise that resolves with the final assistant message when the session becomes idle,
|
|
152
|
+
* or undefined if no assistant message was received
|
|
153
|
+
* @throws Error if the timeout is reached before the session becomes idle
|
|
154
|
+
* @throws Error if the session has been disconnected or the connection fails
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* // Send and wait for completion with default 60s timeout
|
|
159
|
+
* const response = await session.sendAndWait({ prompt: "What is 2+2?" });
|
|
160
|
+
* console.log(response?.data.content); // "4"
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
sendAndWait(prompt: string, timeout?: number): Promise<AssistantMessageEvent | undefined>;
|
|
164
|
+
sendAndWait(options: MessageOptions, timeout?: number): Promise<AssistantMessageEvent | undefined>;
|
|
165
|
+
/**
|
|
166
|
+
* Subscribes to events from this session.
|
|
167
|
+
*
|
|
168
|
+
* Events include assistant messages, tool executions, errors, and session state changes.
|
|
169
|
+
* Multiple handlers can be registered and will all receive events.
|
|
170
|
+
*
|
|
171
|
+
* @param eventType - The specific event type to listen for (e.g., "assistant.message", "session.idle")
|
|
172
|
+
* @param handler - A callback function that receives events of the specified type
|
|
173
|
+
* @returns A function that, when called, unsubscribes the handler
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```typescript
|
|
177
|
+
* // Listen for a specific event type
|
|
178
|
+
* const unsubscribe = session.on("assistant.message", (event) => {
|
|
179
|
+
* console.log("Assistant:", event.data.content);
|
|
180
|
+
* });
|
|
181
|
+
*
|
|
182
|
+
* // Later, to stop receiving events:
|
|
183
|
+
* unsubscribe();
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
on<K extends SessionEventType>(eventType: K, handler: TypedSessionEventHandler<K>): () => void;
|
|
187
|
+
/**
|
|
188
|
+
* Subscribes to all events from this session.
|
|
189
|
+
*
|
|
190
|
+
* @param handler - A callback function that receives all session events
|
|
191
|
+
* @returns A function that, when called, unsubscribes the handler
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```typescript
|
|
195
|
+
* const unsubscribe = session.on((event) => {
|
|
196
|
+
* switch (event.type) {
|
|
197
|
+
* case "assistant.message":
|
|
198
|
+
* console.log("Assistant:", event.data.content);
|
|
199
|
+
* break;
|
|
200
|
+
* case "session.error":
|
|
201
|
+
* console.error("Error:", event.data.message);
|
|
202
|
+
* break;
|
|
203
|
+
* }
|
|
204
|
+
* });
|
|
205
|
+
*
|
|
206
|
+
* // Later, to stop receiving events:
|
|
207
|
+
* unsubscribe();
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
on(handler: SessionEventHandler): () => void;
|
|
211
|
+
private upsertOpenCanvasFromEvent;
|
|
212
|
+
private removeOpenCanvasFromEvent;
|
|
213
|
+
private removeOpenCanvas;
|
|
214
|
+
private upsertOpenCanvas;
|
|
215
|
+
/**
|
|
216
|
+
* Snapshot of canvas instances currently known to be open for this session.
|
|
217
|
+
* Populated from the `session.resume` response and live `session.canvas.opened`
|
|
218
|
+
* and `session.canvas.closed` events. Returns a defensive copy — mutating the
|
|
219
|
+
* returned array has no effect on the session.
|
|
220
|
+
*/
|
|
221
|
+
get openCanvases(): OpenCanvasInstance[];
|
|
222
|
+
private assertElicitation;
|
|
223
|
+
private _elicitation;
|
|
224
|
+
private _confirm;
|
|
225
|
+
private _select;
|
|
226
|
+
private _input;
|
|
227
|
+
/**
|
|
228
|
+
* Retrieves all events and messages from this session's history.
|
|
229
|
+
*
|
|
230
|
+
* This returns the complete conversation history including user messages,
|
|
231
|
+
* assistant responses, tool executions, and other session events.
|
|
232
|
+
*
|
|
233
|
+
* @returns A promise that resolves with an array of all session events
|
|
234
|
+
* @throws Error if the session has been disconnected or the connection fails
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```typescript
|
|
238
|
+
* const events = await session.getEvents();
|
|
239
|
+
* for (const event of events) {
|
|
240
|
+
* if (event.type === "assistant.message") {
|
|
241
|
+
* console.log("Assistant:", event.data.content);
|
|
242
|
+
* }
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
getEvents(): Promise<SessionEvent[]>;
|
|
247
|
+
/**
|
|
248
|
+
* Disconnects this session and releases all in-memory resources (event handlers,
|
|
249
|
+
* tool handlers, permission handlers).
|
|
250
|
+
*
|
|
251
|
+
* Session state on disk (conversation history, planning state, artifacts) is
|
|
252
|
+
* preserved, so the conversation can be resumed later by calling
|
|
253
|
+
* {@link CopilotClient.resumeSession} with the session ID. To permanently
|
|
254
|
+
* remove all session data including files on disk, use
|
|
255
|
+
* {@link CopilotClient.deleteSession} instead.
|
|
256
|
+
*
|
|
257
|
+
* After calling this method, the session object can no longer be used.
|
|
258
|
+
*
|
|
259
|
+
* @returns A promise that resolves when the session is disconnected
|
|
260
|
+
* @throws Error if the connection fails
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* // Clean up when done — session can still be resumed later
|
|
265
|
+
* await session.disconnect();
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
disconnect(): Promise<void>;
|
|
269
|
+
/** Enables `await using session = ...` syntax for automatic cleanup. */
|
|
270
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
271
|
+
/**
|
|
272
|
+
* Aborts the currently processing message in this session.
|
|
273
|
+
*
|
|
274
|
+
* Use this to cancel a long-running request. The session remains valid
|
|
275
|
+
* and can continue to be used for new messages.
|
|
276
|
+
*
|
|
277
|
+
* @returns A promise that resolves when the abort request is acknowledged
|
|
278
|
+
* @throws Error if the session has been disconnected or the connection fails
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* // Start a long-running request
|
|
283
|
+
* const messagePromise = session.send({ prompt: "Write a very long story..." });
|
|
284
|
+
*
|
|
285
|
+
* // Abort after 5 seconds
|
|
286
|
+
* setTimeout(async () => {
|
|
287
|
+
* await session.abort();
|
|
288
|
+
* }, 5000);
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
abort(): Promise<void>;
|
|
292
|
+
/**
|
|
293
|
+
* Change the model for this session.
|
|
294
|
+
* The new model takes effect for the next message. Conversation history is preserved.
|
|
295
|
+
*
|
|
296
|
+
* @param model - Model ID to switch to
|
|
297
|
+
* @param options - Optional settings for the new model
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```typescript
|
|
301
|
+
* await session.setModel("gpt-5.4");
|
|
302
|
+
* await session.setModel("claude-sonnet-4.6", { reasoningEffort: "high" });
|
|
303
|
+
* ```
|
|
304
|
+
*/
|
|
305
|
+
setModel(model: string, options?: {
|
|
306
|
+
reasoningEffort?: ReasoningEffort;
|
|
307
|
+
reasoningSummary?: ReasoningSummary;
|
|
308
|
+
contextTier?: ContextTier;
|
|
309
|
+
modelCapabilities?: ModelCapabilitiesOverride;
|
|
310
|
+
}): Promise<void>;
|
|
311
|
+
/**
|
|
312
|
+
* Log a message to the session timeline.
|
|
313
|
+
* The message appears in the session event stream and is visible to SDK consumers
|
|
314
|
+
* and (for non-ephemeral messages) persisted to the session event log on disk.
|
|
315
|
+
*
|
|
316
|
+
* @param message - Human-readable message text
|
|
317
|
+
* @param options - Optional log level and ephemeral flag
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* await session.log("Processing started");
|
|
322
|
+
* await session.log("Disk usage high", { level: "warning" });
|
|
323
|
+
* await session.log("Connection failed", { level: "error" });
|
|
324
|
+
* await session.log("Debug info", { ephemeral: true });
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
log(message: string, options?: {
|
|
328
|
+
level?: "info" | "warning" | "error";
|
|
329
|
+
ephemeral?: boolean;
|
|
330
|
+
}): Promise<void>;
|
|
331
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { SessionFsHandler, SessionFsStatResult, SessionFsReaddirWithTypesEntry, SessionFsSqliteQueryResult as GeneratedSqliteQueryResult, SessionFsSqliteTransactionErrorClass, SessionFsSqliteQueryType } from "./generated/rpc.js";
|
|
2
|
+
export type { SessionFsSqliteQueryType, SessionFsSqliteTransactionErrorClass };
|
|
3
|
+
/**
|
|
4
|
+
* File metadata returned by {@link SessionFsProvider.stat}.
|
|
5
|
+
* Same shape as the generated {@link SessionFsStatResult} but without the
|
|
6
|
+
* `error` field, since providers signal errors by throwing.
|
|
7
|
+
*/
|
|
8
|
+
export type SessionFsFileInfo = Omit<SessionFsStatResult, "error">;
|
|
9
|
+
/**
|
|
10
|
+
* Result of a SQLite query execution via {@link SessionFsSqliteProvider.query}.
|
|
11
|
+
* Same shape as the generated {@link GeneratedSqliteQueryResult} but without the
|
|
12
|
+
* `error` field, since providers signal errors by throwing.
|
|
13
|
+
*/
|
|
14
|
+
export type SessionFsSqliteQueryResult = Omit<GeneratedSqliteQueryResult, "error">;
|
|
15
|
+
/**
|
|
16
|
+
* One statement in an atomic SQLite transaction passed to
|
|
17
|
+
* {@link SessionFsSqliteProvider.transaction}.
|
|
18
|
+
*/
|
|
19
|
+
export interface SessionFsSqliteStatement {
|
|
20
|
+
/** How to execute: `"exec"` for DDL/multi-statement, `"query"` for SELECT, `"run"` for INSERT/UPDATE/DELETE. */
|
|
21
|
+
queryType: SessionFsSqliteQueryType;
|
|
22
|
+
/** SQL statement to execute. */
|
|
23
|
+
query: string;
|
|
24
|
+
/** Optional named bind parameters. */
|
|
25
|
+
params?: Record<string, string | number | null>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Error thrown by {@link SessionFsSqliteProvider.transaction} to classify a
|
|
29
|
+
* transaction failure for the runtime.
|
|
30
|
+
*
|
|
31
|
+
* Any other thrown value is reported as `"fatal"`. Throw this with
|
|
32
|
+
* `"busyOrLocked"` when SQLite reported BUSY/LOCKED before commit and the
|
|
33
|
+
* transaction was rolled back, so the runtime knows the call is safe to retry.
|
|
34
|
+
*/
|
|
35
|
+
export declare class SessionFsSqliteTransactionFailure extends Error {
|
|
36
|
+
/** Failure classification reported to the runtime. */
|
|
37
|
+
readonly errorClass: SessionFsSqliteTransactionErrorClass;
|
|
38
|
+
constructor(message: string, errorClass?: SessionFsSqliteTransactionErrorClass);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* SQLite operations for the per-session database.
|
|
42
|
+
* Implementers provide query execution and existence checking.
|
|
43
|
+
*/
|
|
44
|
+
export interface SessionFsSqliteProvider {
|
|
45
|
+
/**
|
|
46
|
+
* Execute a SQLite query against the per-session database.
|
|
47
|
+
*
|
|
48
|
+
* @param queryType - How to execute: `"exec"` for DDL/multi-statement, `"query"` for SELECT, `"run"` for INSERT/UPDATE/DELETE.
|
|
49
|
+
* @param query - SQL query to execute.
|
|
50
|
+
* @param params - Optional named bind parameters.
|
|
51
|
+
*/
|
|
52
|
+
query(queryType: SessionFsSqliteQueryType, query: string, params?: Record<string, string | number | null>): Promise<SessionFsSqliteQueryResult | undefined>;
|
|
53
|
+
/**
|
|
54
|
+
* Execute `statements` atomically against the per-session database.
|
|
55
|
+
*
|
|
56
|
+
* Apply busy handling to every statement and roll back the whole batch if
|
|
57
|
+
* any statement fails. Throw {@link SessionFsSqliteTransactionFailure} to
|
|
58
|
+
* classify the failure; any other thrown value is reported as `"fatal"`.
|
|
59
|
+
*
|
|
60
|
+
* @param statements - Statements to execute in order inside a single transaction.
|
|
61
|
+
* @returns One result per statement, in the same order.
|
|
62
|
+
*/
|
|
63
|
+
transaction?(statements: SessionFsSqliteStatement[]): Promise<SessionFsSqliteQueryResult[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Check whether the per-session database already exists, without creating it.
|
|
66
|
+
*/
|
|
67
|
+
exists(): Promise<boolean>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Interface for session filesystem providers. Implementers use idiomatic
|
|
71
|
+
* TypeScript patterns: throw on error, return values directly. Use
|
|
72
|
+
* {@link createSessionFsAdapter} to convert a provider into the
|
|
73
|
+
* {@link SessionFsHandler} expected by the SDK.
|
|
74
|
+
*
|
|
75
|
+
* Errors with a `code` property of `"ENOENT"` are mapped to the ENOENT
|
|
76
|
+
* error code; all others map to UNKNOWN.
|
|
77
|
+
*/
|
|
78
|
+
export interface SessionFsProvider {
|
|
79
|
+
/** Reads the full content of a file. Throw if the file does not exist. */
|
|
80
|
+
readFile(path: string): Promise<string>;
|
|
81
|
+
/** Writes content to a file, creating parent directories if needed. */
|
|
82
|
+
writeFile(path: string, content: string, mode?: number): Promise<void>;
|
|
83
|
+
/** Appends content to a file, creating parent directories if needed. */
|
|
84
|
+
appendFile(path: string, content: string, mode?: number): Promise<void>;
|
|
85
|
+
/** Checks whether a path exists. */
|
|
86
|
+
exists(path: string): Promise<boolean>;
|
|
87
|
+
/** Gets metadata about a file or directory. Throw if it does not exist. */
|
|
88
|
+
stat(path: string): Promise<SessionFsFileInfo>;
|
|
89
|
+
/** Creates a directory. If recursive is true, creates parents as needed. */
|
|
90
|
+
mkdir(path: string, recursive: boolean, mode?: number): Promise<void>;
|
|
91
|
+
/** Lists entry names in a directory. Throw if it does not exist. */
|
|
92
|
+
readdir(path: string): Promise<string[]>;
|
|
93
|
+
/** Lists entries with type info. Throw if the directory does not exist. */
|
|
94
|
+
readdirWithTypes(path: string): Promise<SessionFsReaddirWithTypesEntry[]>;
|
|
95
|
+
/** Removes a file or directory. If force is true, do not throw on ENOENT. */
|
|
96
|
+
rm(path: string, recursive: boolean, force: boolean): Promise<void>;
|
|
97
|
+
/** Renames/moves a file or directory. */
|
|
98
|
+
rename(src: string, dest: string): Promise<void>;
|
|
99
|
+
/** Per-session SQLite database operations. Optional — omit if the provider does not support SQLite. */
|
|
100
|
+
sqlite?: SessionFsSqliteProvider;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Wraps a {@link SessionFsProvider} into the {@link SessionFsHandler}
|
|
104
|
+
* interface expected by the SDK, converting thrown errors into
|
|
105
|
+
* {@link SessionFsError} results.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createSessionFsAdapter(provider: SessionFsProvider): SessionFsHandler;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace-context helpers.
|
|
3
|
+
*
|
|
4
|
+
* The SDK does not depend on any OpenTelemetry packages. Instead, users
|
|
5
|
+
* provide an {@link TraceContextProvider} callback via client options.
|
|
6
|
+
*
|
|
7
|
+
* @module telemetry
|
|
8
|
+
*/
|
|
9
|
+
import type { TraceContext, TraceContextProvider } from "./types.js";
|
|
10
|
+
/**
|
|
11
|
+
* Calls the user-provided {@link TraceContextProvider} to obtain the current
|
|
12
|
+
* W3C Trace Context. Returns `{}` when no provider is configured.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getTraceContext(provider?: TraceContextProvider): Promise<TraceContext>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builder that produces a list of source-qualified tool filter strings for
|
|
3
|
+
* {@link SessionConfigBase.availableTools}.
|
|
4
|
+
*
|
|
5
|
+
* Tools are classified by the runtime at registration time (not from name
|
|
6
|
+
* parsing), so `addBuiltIn("foo")` matches only tools the runtime registered
|
|
7
|
+
* as built-in, even if an MCP server or custom-agent extension happens to
|
|
8
|
+
* register a tool with the same wire name.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const tools = new ToolSet()
|
|
13
|
+
* .addBuiltIn(BuiltInTools.Isolated)
|
|
14
|
+
* .addMcp("*")
|
|
15
|
+
* .addCustom("*");
|
|
16
|
+
*
|
|
17
|
+
* const session = await client.createSession({
|
|
18
|
+
* availableTools: tools,
|
|
19
|
+
* // ...
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class ToolSet {
|
|
24
|
+
private readonly items;
|
|
25
|
+
/**
|
|
26
|
+
* Adds one or more built-in tool patterns.
|
|
27
|
+
*
|
|
28
|
+
* @param name A specific built-in tool name (e.g. `"bash"`) or `"*"` to match all
|
|
29
|
+
* built-in tools.
|
|
30
|
+
*/
|
|
31
|
+
addBuiltIn(name: string): ToolSet;
|
|
32
|
+
/**
|
|
33
|
+
* Adds a list of built-in tool patterns (e.g. {@link BuiltInTools.Isolated}).
|
|
34
|
+
*/
|
|
35
|
+
addBuiltIn(names: readonly string[]): ToolSet;
|
|
36
|
+
/**
|
|
37
|
+
* Adds a custom tool pattern. Matches tools registered via the SDK's
|
|
38
|
+
* `tools` option or via custom agents.
|
|
39
|
+
*
|
|
40
|
+
* @param name A specific custom tool name or `"*"` to match all custom tools.
|
|
41
|
+
*/
|
|
42
|
+
addCustom(name: string): ToolSet;
|
|
43
|
+
/**
|
|
44
|
+
* Adds an MCP tool pattern. Matches tools advertised by any configured
|
|
45
|
+
* MCP server.
|
|
46
|
+
*
|
|
47
|
+
* @param toolName The runtime's canonical wire name for the MCP tool
|
|
48
|
+
* (e.g. `"github-list_issues"`), or `"*"` to match all MCP tools from
|
|
49
|
+
* any server.
|
|
50
|
+
*/
|
|
51
|
+
addMcp(toolName: string): ToolSet;
|
|
52
|
+
/**
|
|
53
|
+
* Returns a defensive copy of the accumulated filter strings, suitable for
|
|
54
|
+
* passing as {@link SessionConfigBase.availableTools}.
|
|
55
|
+
*/
|
|
56
|
+
toArray(): string[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Curated sets of built-in tool names for common scenarios. Each constant is
|
|
60
|
+
* meant to be passed to {@link ToolSet.addBuiltIn}.
|
|
61
|
+
*/
|
|
62
|
+
export declare const BuiltInTools: {
|
|
63
|
+
/**
|
|
64
|
+
* Built-in tools that operate only within the bounds of a single session —
|
|
65
|
+
* no host filesystem access outside the session, no cross-session state,
|
|
66
|
+
* no host environment access, no network. Safe to enable in `Mode = "empty"`
|
|
67
|
+
* scenarios (e.g. multi-tenant servers) without leaking host capabilities.
|
|
68
|
+
*
|
|
69
|
+
* **Contract:** tools in this set MUST NOT be extended (even behind options
|
|
70
|
+
* or args) to read or write state outside the session boundary. Adding
|
|
71
|
+
* cross-session or host-state behavior to one of these tools is a
|
|
72
|
+
* breaking change that requires removing it from this set.
|
|
73
|
+
*/
|
|
74
|
+
readonly Isolated: readonly string[];
|
|
75
|
+
};
|