@anthropic-ai/claude-agent-sdk 0.2.140 → 0.3.142
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/assistant.mjs +86 -86
- package/bridge.mjs +104 -76
- package/browser-sdk.js +23 -23
- package/manifest.json +19 -19
- package/manifest.zst.json +23 -23
- package/package.json +11 -11
- package/sdk-tools.d.ts +119 -1
- package/sdk.d.ts +77 -138
- package/sdk.mjs +58 -58
package/sdk.d.ts
CHANGED
|
@@ -635,7 +635,7 @@ export declare type ForkSessionOptions = SessionMutationOptions & {
|
|
|
635
635
|
* Result of a fork operation.
|
|
636
636
|
*/
|
|
637
637
|
export declare type ForkSessionResult = {
|
|
638
|
-
/** New session UUID. Resumable via `
|
|
638
|
+
/** New session UUID. Resumable via `query({ options: { resume: sessionId } })`. */
|
|
639
639
|
sessionId: string;
|
|
640
640
|
};
|
|
641
641
|
|
|
@@ -954,7 +954,7 @@ export declare type McpHttpServerConfig = {
|
|
|
954
954
|
headers?: Record<string, string>;
|
|
955
955
|
tools?: McpServerToolPolicy[];
|
|
956
956
|
/**
|
|
957
|
-
* When true, all tools from this server are always included in the prompt and never deferred behind tool search. Equivalent to setting defer_loading: false on the API. Default: tools are deferred when tool search is enabled. As a side effect this also blocks startup until the server is connected (capped at the standard 5s connect timeout) even
|
|
957
|
+
* When true, all tools from this server are always included in the prompt and never deferred behind tool search. Equivalent to setting defer_loading: false on the API. Default: tools are deferred when tool search is enabled. As a side effect this also blocks startup until the server is connected (capped at the standard 5s connect timeout) even though MCP startup is otherwise non-blocking by default, since the tools must be present when the turn-1 prompt is built.
|
|
958
958
|
*/
|
|
959
959
|
alwaysLoad?: boolean;
|
|
960
960
|
};
|
|
@@ -1059,7 +1059,7 @@ export declare type McpSSEServerConfig = {
|
|
|
1059
1059
|
headers?: Record<string, string>;
|
|
1060
1060
|
tools?: McpServerToolPolicy[];
|
|
1061
1061
|
/**
|
|
1062
|
-
* When true, all tools from this server are always included in the prompt and never deferred behind tool search. Equivalent to setting defer_loading: false on the API. Default: tools are deferred when tool search is enabled. As a side effect this also blocks startup until the server is connected (capped at the standard 5s connect timeout) even
|
|
1062
|
+
* When true, all tools from this server are always included in the prompt and never deferred behind tool search. Equivalent to setting defer_loading: false on the API. Default: tools are deferred when tool search is enabled. As a side effect this also blocks startup until the server is connected (capped at the standard 5s connect timeout) even though MCP startup is otherwise non-blocking by default, since the tools must be present when the turn-1 prompt is built.
|
|
1063
1063
|
*/
|
|
1064
1064
|
alwaysLoad?: boolean;
|
|
1065
1065
|
};
|
|
@@ -1070,7 +1070,7 @@ export declare type McpStdioServerConfig = {
|
|
|
1070
1070
|
args?: string[];
|
|
1071
1071
|
env?: Record<string, string>;
|
|
1072
1072
|
/**
|
|
1073
|
-
* When true, all tools from this server are always included in the prompt and never deferred behind tool search. Equivalent to setting defer_loading: false on the API. Default: tools are deferred when tool search is enabled. As a side effect this also blocks startup until the server is connected (capped at the standard 5s connect timeout) even
|
|
1073
|
+
* When true, all tools from this server are always included in the prompt and never deferred behind tool search. Equivalent to setting defer_loading: false on the API. Default: tools are deferred when tool search is enabled. As a side effect this also blocks startup until the server is connected (capped at the standard 5s connect timeout) even though MCP startup is otherwise non-blocking by default, since the tools must be present when the turn-1 prompt is built.
|
|
1074
1074
|
*/
|
|
1075
1075
|
alwaysLoad?: boolean;
|
|
1076
1076
|
};
|
|
@@ -1226,6 +1226,32 @@ export declare type Options = {
|
|
|
1226
1226
|
* otherwise be allowed.
|
|
1227
1227
|
*/
|
|
1228
1228
|
disallowedTools?: string[];
|
|
1229
|
+
/**
|
|
1230
|
+
* Map of tool-name aliases applied before name resolution. When the
|
|
1231
|
+
* model emits a `tool_use` whose name is a key in this map, the tool
|
|
1232
|
+
* execution path resolves the mapped name instead.
|
|
1233
|
+
*
|
|
1234
|
+
* This lets SDK consumers redirect built-in tool names to their own
|
|
1235
|
+
* tools. For example, a host that runs Bash inside a remote sandbox via
|
|
1236
|
+
* an MCP tool can set `{ Bash: 'mcp__workspace__bash' }` so that if the
|
|
1237
|
+
* model emits `Bash` (e.g. because a skill document instructed it to),
|
|
1238
|
+
* the call is routed to the MCP tool instead of failing as unknown.
|
|
1239
|
+
*
|
|
1240
|
+
* The redirect is single-hop: an alias that points at another aliased
|
|
1241
|
+
* name resolves that target literally rather than following a chain, so
|
|
1242
|
+
* cycles like `{A: 'B', B: 'A'}` cannot loop.
|
|
1243
|
+
*
|
|
1244
|
+
* `toolAliases` is complementary to `disallowedTools`, not a replacement
|
|
1245
|
+
* for it: the alias only affects name-based lookup of model-emitted
|
|
1246
|
+
* `tool_use` blocks, whereas `disallowedTools` also blocks harness-internal
|
|
1247
|
+
* direct calls that hold the tool object without a name lookup.
|
|
1248
|
+
*
|
|
1249
|
+
* @example
|
|
1250
|
+
* ```typescript
|
|
1251
|
+
* toolAliases: { Bash: 'mcp__workspace__bash' }
|
|
1252
|
+
* ```
|
|
1253
|
+
*/
|
|
1254
|
+
toolAliases?: Record<string, string>;
|
|
1229
1255
|
/**
|
|
1230
1256
|
* Specify the base set of available built-in tools.
|
|
1231
1257
|
* - `string[]` - Array of specific tool names (e.g., `['Bash', 'Read', 'Edit']`)
|
|
@@ -2465,6 +2491,15 @@ export declare type SDKAssistantMessage = {
|
|
|
2465
2491
|
error?: SDKAssistantMessageError;
|
|
2466
2492
|
uuid: UUID;
|
|
2467
2493
|
session_id: string;
|
|
2494
|
+
request_id?: string;
|
|
2495
|
+
/**
|
|
2496
|
+
* Subagent type that produced this message.
|
|
2497
|
+
*/
|
|
2498
|
+
subagent_type?: string;
|
|
2499
|
+
/**
|
|
2500
|
+
* Description of the subagent task that produced this message.
|
|
2501
|
+
*/
|
|
2502
|
+
task_description?: string;
|
|
2468
2503
|
};
|
|
2469
2504
|
|
|
2470
2505
|
export declare type SDKAssistantMessageError = 'authentication_failed' | 'oauth_org_not_allowed' | 'billing_error' | 'rate_limit' | 'invalid_request' | 'server_error' | 'unknown' | 'max_output_tokens';
|
|
@@ -2496,6 +2531,13 @@ export declare type SDKCompactBoundaryMessage = {
|
|
|
2496
2531
|
anchor_uuid: UUID;
|
|
2497
2532
|
tail_uuid: UUID;
|
|
2498
2533
|
};
|
|
2534
|
+
/**
|
|
2535
|
+
* Ordered messagesToKeep UUIDs. Supersedes preserved_segment — readers look up each UUID directly and relink uuids[i] to uuids[i-1] (uuids[0] to anchor_uuid) instead of walking the parentUuid chain. Unset when compaction summarizes everything.
|
|
2536
|
+
*/
|
|
2537
|
+
preserved_messages?: {
|
|
2538
|
+
anchor_uuid: UUID;
|
|
2539
|
+
uuids: UUID[];
|
|
2540
|
+
};
|
|
2499
2541
|
};
|
|
2500
2542
|
uuid: UUID;
|
|
2501
2543
|
session_id: string;
|
|
@@ -2707,6 +2749,10 @@ declare type SDKControlInitializeRequest = {
|
|
|
2707
2749
|
*/
|
|
2708
2750
|
planModeInstructions?: string;
|
|
2709
2751
|
|
|
2752
|
+
/**
|
|
2753
|
+
* Map of tool-name aliases applied before name resolution. When the model emits a tool_use whose name is a key in this map, the tool execution path resolves the mapped name instead. Single-hop (no chains). See Options.toolAliases.
|
|
2754
|
+
*/
|
|
2755
|
+
toolAliases?: Record<string, string>;
|
|
2710
2756
|
/**
|
|
2711
2757
|
* When true, omit per-user dynamic sections (working directory, auto-memory path) from the cached system prompt and re-inject them as the first user message. Lets cross-user prompt caching hit on a static system prompt prefix. Tradeoff: the model sees this context slightly later in the prompt, so steering on the working directory and memory location is marginally less authoritative. Has no effect when a custom (non-preset) system prompt is in use.
|
|
2712
2758
|
*/
|
|
@@ -3309,6 +3355,7 @@ export declare type SDKResultSuccess = {
|
|
|
3309
3355
|
subtype: 'success';
|
|
3310
3356
|
duration_ms: number;
|
|
3311
3357
|
duration_api_ms: number;
|
|
3358
|
+
ttft_ms?: number;
|
|
3312
3359
|
is_error: boolean;
|
|
3313
3360
|
api_error_status?: number | null;
|
|
3314
3361
|
num_turns: number;
|
|
@@ -3327,30 +3374,6 @@ export declare type SDKResultSuccess = {
|
|
|
3327
3374
|
session_id: string;
|
|
3328
3375
|
};
|
|
3329
3376
|
|
|
3330
|
-
/**
|
|
3331
|
-
* V2 API - UNSTABLE
|
|
3332
|
-
* Session interface for multi-turn conversations.
|
|
3333
|
-
* Has methods, so not serializable.
|
|
3334
|
-
* @deprecated Use `query()` instead. The V2 session API will be removed in a future release.
|
|
3335
|
-
* @alpha
|
|
3336
|
-
*/
|
|
3337
|
-
export declare interface SDKSession {
|
|
3338
|
-
/**
|
|
3339
|
-
* The session ID. Available after receiving the first message.
|
|
3340
|
-
* For resumed sessions, available immediately.
|
|
3341
|
-
* Throws if accessed before the session is initialized.
|
|
3342
|
-
*/
|
|
3343
|
-
readonly sessionId: string;
|
|
3344
|
-
/** Send a message to the agent */
|
|
3345
|
-
send(message: string | SDKUserMessage): Promise<void>;
|
|
3346
|
-
/** Stream messages from the agent */
|
|
3347
|
-
stream(): AsyncGenerator<SDKMessage, void>;
|
|
3348
|
-
/** Close the session */
|
|
3349
|
-
close(): void;
|
|
3350
|
-
/** Async disposal support (calls close if not already closed) */
|
|
3351
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
3352
|
-
}
|
|
3353
|
-
|
|
3354
3377
|
/**
|
|
3355
3378
|
* Session metadata returned by listSessions and getSessionInfo.
|
|
3356
3379
|
*/
|
|
@@ -3397,85 +3420,6 @@ export declare type SDKSessionInfo = {
|
|
|
3397
3420
|
createdAt?: number;
|
|
3398
3421
|
};
|
|
3399
3422
|
|
|
3400
|
-
/**
|
|
3401
|
-
* V2 API - UNSTABLE
|
|
3402
|
-
* Options for creating a session.
|
|
3403
|
-
* @deprecated Use `query()` instead. The V2 session API will be removed in a future release.
|
|
3404
|
-
* @alpha
|
|
3405
|
-
*/
|
|
3406
|
-
export declare type SDKSessionOptions = {
|
|
3407
|
-
/** Model to use */
|
|
3408
|
-
model: string;
|
|
3409
|
-
/** Path to Claude Code executable */
|
|
3410
|
-
pathToClaudeCodeExecutable?: string;
|
|
3411
|
-
/** Executable to use (node, bun) */
|
|
3412
|
-
executable?: 'node' | 'bun';
|
|
3413
|
-
/** Arguments to pass to executable */
|
|
3414
|
-
executableArgs?: string[];
|
|
3415
|
-
/**
|
|
3416
|
-
* Environment variables to pass to the Claude Code process.
|
|
3417
|
-
* Defaults to `process.env`.
|
|
3418
|
-
*
|
|
3419
|
-
* SDK consumers can identify their app/library to include in the User-Agent header by setting:
|
|
3420
|
-
* - `CLAUDE_AGENT_SDK_CLIENT_APP` - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")
|
|
3421
|
-
*/
|
|
3422
|
-
env?: {
|
|
3423
|
-
[envVar: string]: string | undefined;
|
|
3424
|
-
};
|
|
3425
|
-
/**
|
|
3426
|
-
* Working directory for the Claude Code process. Defaults to the current
|
|
3427
|
-
* process's working directory.
|
|
3428
|
-
*/
|
|
3429
|
-
cwd?: string;
|
|
3430
|
-
/**
|
|
3431
|
-
* Which settings sources to load (CLAUDE.md, `.claude/settings.json`).
|
|
3432
|
-
* Defaults to `[]`: no project/user settings are loaded unless specified.
|
|
3433
|
-
* Note that `query()` has the opposite default and loads all sources when
|
|
3434
|
-
* this is omitted.
|
|
3435
|
-
*/
|
|
3436
|
-
settingSources?: SettingSource[];
|
|
3437
|
-
/**
|
|
3438
|
-
* Must be set to `true` when using `permissionMode: 'bypassPermissions'`.
|
|
3439
|
-
* This is a safety measure to ensure intentional bypassing of permissions.
|
|
3440
|
-
*/
|
|
3441
|
-
allowDangerouslySkipPermissions?: boolean;
|
|
3442
|
-
/**
|
|
3443
|
-
* List of tool names that are auto-allowed without prompting for permission.
|
|
3444
|
-
* These tools will execute automatically without asking the user for approval.
|
|
3445
|
-
*/
|
|
3446
|
-
allowedTools?: string[];
|
|
3447
|
-
/**
|
|
3448
|
-
* List of tool names that are disallowed. These tools will be removed
|
|
3449
|
-
* from the model's context and cannot be used.
|
|
3450
|
-
*/
|
|
3451
|
-
disallowedTools?: string[];
|
|
3452
|
-
/**
|
|
3453
|
-
* Custom permission handler for controlling tool usage. Called before each
|
|
3454
|
-
* tool execution to determine if it should be allowed, denied, or prompt the user.
|
|
3455
|
-
*/
|
|
3456
|
-
canUseTool?: CanUseTool;
|
|
3457
|
-
/**
|
|
3458
|
-
* Hook callbacks for responding to various events during execution.
|
|
3459
|
-
*/
|
|
3460
|
-
hooks?: Partial<Record<HookEvent, HookCallbackMatcher[]>>;
|
|
3461
|
-
/**
|
|
3462
|
-
* Permission mode for the session.
|
|
3463
|
-
* - `'default'` - Standard permission behavior, prompts for dangerous operations
|
|
3464
|
-
* - `'acceptEdits'` - Auto-accept file edit operations
|
|
3465
|
-
* - `'bypassPermissions'` - Bypass all permission checks (requires `allowDangerouslySkipPermissions`)
|
|
3466
|
-
* - `'plan'` - Planning mode, no execution of tools
|
|
3467
|
-
* - `'dontAsk'` - Don't prompt for permissions, deny if not pre-approved
|
|
3468
|
-
*/
|
|
3469
|
-
permissionMode?: PermissionMode;
|
|
3470
|
-
/**
|
|
3471
|
-
* Custom workflow instructions for plan mode. When `permissionMode` is
|
|
3472
|
-
* `'plan'`, this string replaces the default code-implementation workflow
|
|
3473
|
-
* body in the plan-mode system reminder. The CLI still wraps it with the
|
|
3474
|
-
* read-only enforcement preamble and the ExitPlanMode protocol footer.
|
|
3475
|
-
*/
|
|
3476
|
-
planModeInstructions?: string;
|
|
3477
|
-
};
|
|
3478
|
-
|
|
3479
3423
|
/**
|
|
3480
3424
|
* Mirrors notifySessionStateChanged. 'idle' fires after heldBackResult flushes and the bg-agent do-while exits — authoritative turn-over signal.
|
|
3481
3425
|
*/
|
|
@@ -3577,6 +3521,10 @@ export declare type SDKTaskProgressMessage = {
|
|
|
3577
3521
|
task_id: string;
|
|
3578
3522
|
tool_use_id?: string;
|
|
3579
3523
|
description: string;
|
|
3524
|
+
/**
|
|
3525
|
+
* Subagent type for Task tool subagents.
|
|
3526
|
+
*/
|
|
3527
|
+
subagent_type?: string;
|
|
3580
3528
|
usage: {
|
|
3581
3529
|
total_tokens: number;
|
|
3582
3530
|
tool_uses: number;
|
|
@@ -3595,6 +3543,10 @@ export declare type SDKTaskStartedMessage = {
|
|
|
3595
3543
|
task_id: string;
|
|
3596
3544
|
tool_use_id?: string;
|
|
3597
3545
|
description: string;
|
|
3546
|
+
/**
|
|
3547
|
+
* Subagent type for Task tool subagents.
|
|
3548
|
+
*/
|
|
3549
|
+
subagent_type?: string;
|
|
3598
3550
|
task_type?: string;
|
|
3599
3551
|
/**
|
|
3600
3552
|
* meta.name from the workflow script (e.g. 'spec'). Only set when task_type is 'local_workflow'.
|
|
@@ -3666,6 +3618,14 @@ export declare type SDKUserMessage = {
|
|
|
3666
3618
|
timestamp?: string;
|
|
3667
3619
|
uuid?: UUID;
|
|
3668
3620
|
session_id?: string;
|
|
3621
|
+
/**
|
|
3622
|
+
* Subagent type that produced this message.
|
|
3623
|
+
*/
|
|
3624
|
+
subagent_type?: string;
|
|
3625
|
+
/**
|
|
3626
|
+
* Description of the subagent task that produced this message.
|
|
3627
|
+
*/
|
|
3628
|
+
task_description?: string;
|
|
3669
3629
|
};
|
|
3670
3630
|
|
|
3671
3631
|
export declare type SDKUserMessageReplay = {
|
|
@@ -4468,6 +4428,8 @@ export declare interface Settings {
|
|
|
4468
4428
|
* Local directory containing .claude-plugin/marketplace.json
|
|
4469
4429
|
*/
|
|
4470
4430
|
path: string;
|
|
4431
|
+
} | {
|
|
4432
|
+
source: 'skills-dir';
|
|
4471
4433
|
} | {
|
|
4472
4434
|
source: 'hostPattern';
|
|
4473
4435
|
/**
|
|
@@ -4658,6 +4620,8 @@ export declare interface Settings {
|
|
|
4658
4620
|
* Local directory containing .claude-plugin/marketplace.json
|
|
4659
4621
|
*/
|
|
4660
4622
|
path: string;
|
|
4623
|
+
} | {
|
|
4624
|
+
source: 'skills-dir';
|
|
4661
4625
|
} | {
|
|
4662
4626
|
source: 'hostPattern';
|
|
4663
4627
|
/**
|
|
@@ -4838,6 +4802,8 @@ export declare interface Settings {
|
|
|
4838
4802
|
* Local directory containing .claude-plugin/marketplace.json
|
|
4839
4803
|
*/
|
|
4840
4804
|
path: string;
|
|
4805
|
+
} | {
|
|
4806
|
+
source: 'skills-dir';
|
|
4841
4807
|
} | {
|
|
4842
4808
|
source: 'hostPattern';
|
|
4843
4809
|
/**
|
|
@@ -5530,6 +5496,10 @@ export declare type SyncHookJSONOutput = {
|
|
|
5530
5496
|
stopReason?: string;
|
|
5531
5497
|
decision?: 'approve' | 'block';
|
|
5532
5498
|
systemMessage?: string;
|
|
5499
|
+
/**
|
|
5500
|
+
* A terminal escape sequence (e.g. OSC 9 / OSC 777 desktop-notification) for Claude Code to emit on your behalf. Only notification/title OSCs (0, 1, 2, 9, 99, 777) and BEL are permitted; anything else is dropped.
|
|
5501
|
+
*/
|
|
5502
|
+
terminalSequence?: string;
|
|
5533
5503
|
reason?: string;
|
|
5534
5504
|
|
|
5535
5505
|
|
|
@@ -5675,37 +5645,6 @@ export declare interface Transport {
|
|
|
5675
5645
|
[Symbol.dispose]?(): void;
|
|
5676
5646
|
}
|
|
5677
5647
|
|
|
5678
|
-
/**
|
|
5679
|
-
* V2 API - UNSTABLE
|
|
5680
|
-
* Create a persistent session for multi-turn conversations.
|
|
5681
|
-
* @deprecated Use `query()` instead. The V2 session API will be removed in a future release.
|
|
5682
|
-
* @alpha
|
|
5683
|
-
*/
|
|
5684
|
-
export declare function unstable_v2_createSession(_options: SDKSessionOptions): SDKSession;
|
|
5685
|
-
|
|
5686
|
-
/**
|
|
5687
|
-
* V2 API - UNSTABLE
|
|
5688
|
-
* One-shot convenience function for single prompts.
|
|
5689
|
-
* @deprecated Use `query()` instead. The V2 session API will be removed in a future release.
|
|
5690
|
-
* @alpha
|
|
5691
|
-
*
|
|
5692
|
-
* @example
|
|
5693
|
-
* ```typescript
|
|
5694
|
-
* const result = await unstable_v2_prompt("What files are here?", {
|
|
5695
|
-
* model: 'claude-sonnet-4-6'
|
|
5696
|
-
* })
|
|
5697
|
-
* ```
|
|
5698
|
-
*/
|
|
5699
|
-
export declare function unstable_v2_prompt(_message: string, _options: SDKSessionOptions): Promise<SDKResultMessage>;
|
|
5700
|
-
|
|
5701
|
-
/**
|
|
5702
|
-
* V2 API - UNSTABLE
|
|
5703
|
-
* Resume an existing session by ID.
|
|
5704
|
-
* @deprecated Use `query()` instead. The V2 session API will be removed in a future release.
|
|
5705
|
-
* @alpha
|
|
5706
|
-
*/
|
|
5707
|
-
export declare function unstable_v2_resumeSession(_sessionId: string, _options: SDKSessionOptions): SDKSession;
|
|
5708
|
-
|
|
5709
5648
|
export declare type UserPromptExpansionHookInput = BaseHookInput & {
|
|
5710
5649
|
hook_event_name: 'UserPromptExpansion';
|
|
5711
5650
|
expansion_type: 'slash_command' | 'mcp_prompt';
|