@anthropic-ai/claude-agent-sdk 0.2.112 → 0.2.114
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 +106 -106
- package/bridge.mjs +21 -21
- package/browser-sdk.js +26 -26
- package/manifest.json +18 -18
- package/manifest.zst.json +22 -22
- package/package.json +11 -23
- package/sdk.d.ts +298 -21
- package/sdk.mjs +59 -59
- package/cli.js +0 -18412
- package/embed.d.ts +0 -2
- package/embed.js +0 -26
- package/extractFromBunfs.d.ts +0 -1
- package/extractFromBunfs.js +0 -57
- package/vendor/audio-capture/arm64-darwin/audio-capture.node +0 -0
- package/vendor/audio-capture/arm64-linux/audio-capture.node +0 -0
- package/vendor/audio-capture/arm64-win32/audio-capture.node +0 -0
- package/vendor/audio-capture/x64-darwin/audio-capture.node +0 -0
- package/vendor/audio-capture/x64-linux/audio-capture.node +0 -0
- package/vendor/audio-capture/x64-win32/audio-capture.node +0 -0
- package/vendor/ripgrep/COPYING +0 -3
- package/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/ripgrep/arm64-win32/rg.exe +0 -0
- package/vendor/ripgrep/x64-darwin/rg +0 -0
- package/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/ripgrep/x64-win32/rg.exe +0 -0
package/sdk.d.ts
CHANGED
|
@@ -351,6 +351,7 @@ declare namespace coreTypes {
|
|
|
351
351
|
SDKMemoryRecallMessage,
|
|
352
352
|
SDKMessageOrigin,
|
|
353
353
|
SDKMessage,
|
|
354
|
+
SDKMirrorErrorMessage,
|
|
354
355
|
SDKNotificationMessage,
|
|
355
356
|
SDKPartialAssistantMessage,
|
|
356
357
|
SDKPermissionDenial,
|
|
@@ -431,6 +432,22 @@ export declare type CwdChangedHookSpecificOutput = {
|
|
|
431
432
|
watchPaths?: string[];
|
|
432
433
|
};
|
|
433
434
|
|
|
435
|
+
/**
|
|
436
|
+
* Delete a session.
|
|
437
|
+
*
|
|
438
|
+
* With `sessionStore`: calls `sessionStore.delete()` if implemented; no-op
|
|
439
|
+
* otherwise (per the SessionStore contract — appropriate for WORM/append-only
|
|
440
|
+
* backends).
|
|
441
|
+
*
|
|
442
|
+
* Without `sessionStore`: removes `{sessionId}.jsonl` and the `{sessionId}/`
|
|
443
|
+
* subagent-transcript subdirectory from the local projects dir. Throws if the
|
|
444
|
+
* session is not found.
|
|
445
|
+
*
|
|
446
|
+
* @param sessionId - UUID of the session
|
|
447
|
+
* @param options - `{ dir?, sessionStore? }`
|
|
448
|
+
*/
|
|
449
|
+
export declare function deleteSession(_sessionId: string, _options?: SessionMutationOptions): Promise<void>;
|
|
450
|
+
|
|
434
451
|
/**
|
|
435
452
|
* Effort level for controlling how much thinking/reasoning Claude applies.
|
|
436
453
|
*
|
|
@@ -589,7 +606,12 @@ export declare type GetSessionInfoOptions = {
|
|
|
589
606
|
* When omitted, all project directories are searched for the session file.
|
|
590
607
|
*/
|
|
591
608
|
dir?: string;
|
|
592
|
-
|
|
609
|
+
/**
|
|
610
|
+
* When provided, load session info from this store instead of the local
|
|
611
|
+
* filesystem.
|
|
612
|
+
* @alpha
|
|
613
|
+
*/
|
|
614
|
+
sessionStore?: SessionStore;
|
|
593
615
|
};
|
|
594
616
|
|
|
595
617
|
/**
|
|
@@ -621,7 +643,12 @@ export declare type GetSessionMessagesOptions = {
|
|
|
621
643
|
* Defaults to false for backwards compatibility.
|
|
622
644
|
*/
|
|
623
645
|
includeSystemMessages?: boolean;
|
|
624
|
-
|
|
646
|
+
/**
|
|
647
|
+
* When provided, load session messages from this store instead of the
|
|
648
|
+
* local filesystem.
|
|
649
|
+
* @alpha
|
|
650
|
+
*/
|
|
651
|
+
sessionStore?: SessionStore;
|
|
625
652
|
};
|
|
626
653
|
|
|
627
654
|
/**
|
|
@@ -647,7 +674,12 @@ export declare type GetSubagentMessagesOptions = {
|
|
|
647
674
|
limit?: number;
|
|
648
675
|
/** Number of messages to skip from the start. */
|
|
649
676
|
offset?: number;
|
|
650
|
-
|
|
677
|
+
/**
|
|
678
|
+
* When provided, load subagent messages from this store instead of the
|
|
679
|
+
* local filesystem.
|
|
680
|
+
* @alpha
|
|
681
|
+
*/
|
|
682
|
+
sessionStore?: SessionStore;
|
|
651
683
|
};
|
|
652
684
|
|
|
653
685
|
export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "Notification", "UserPromptSubmit", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged"];
|
|
@@ -677,6 +709,45 @@ export declare type HookJSONOutput = AsyncHookJSONOutput | SyncHookJSONOutput;
|
|
|
677
709
|
|
|
678
710
|
export declare type HookPermissionDecision = 'allow' | 'deny' | 'ask' | 'defer';
|
|
679
711
|
|
|
712
|
+
/**
|
|
713
|
+
* Copy a local JSONL session into a SessionStore.
|
|
714
|
+
*
|
|
715
|
+
* Reads the session file (and optionally subagent transcripts) from disk
|
|
716
|
+
* and calls `store.append()` for each. Entries are appended in batches of
|
|
717
|
+
* `batchSize` to avoid backend payload limits; the store's `append()` is
|
|
718
|
+
* called multiple times per session. Useful for migrating existing local
|
|
719
|
+
* sessions to a remote backend.
|
|
720
|
+
*
|
|
721
|
+
* @alpha
|
|
722
|
+
* @param sessionId - UUID of the local session to import
|
|
723
|
+
* @param store - Destination SessionStore
|
|
724
|
+
* @param options - `{ dir?, includeSubagents?, batchSize? }`
|
|
725
|
+
*/
|
|
726
|
+
export declare function importSessionToStore(_sessionId: string, _store: SessionStore, _options?: ImportSessionToStoreOptions): Promise<void>;
|
|
727
|
+
|
|
728
|
+
/**
|
|
729
|
+
* Options for importing a local JSONL session into a SessionStore.
|
|
730
|
+
* @alpha
|
|
731
|
+
*/
|
|
732
|
+
export declare type ImportSessionToStoreOptions = {
|
|
733
|
+
/**
|
|
734
|
+
* Project directory path (same semantics as `listSessions({ dir })`).
|
|
735
|
+
* When omitted, all project directories are searched for the session file
|
|
736
|
+
* and the destination projectKey is derived from the resolved cwd.
|
|
737
|
+
*/
|
|
738
|
+
dir?: string;
|
|
739
|
+
/**
|
|
740
|
+
* If true, also import subagent transcripts. Default: true.
|
|
741
|
+
*/
|
|
742
|
+
includeSubagents?: boolean;
|
|
743
|
+
/**
|
|
744
|
+
* Maximum entries per `store.append()` call. Entries are appended in
|
|
745
|
+
* batches of this size to avoid backend payload limits; the store's
|
|
746
|
+
* `append()` is called multiple times per session. Default: 500.
|
|
747
|
+
*/
|
|
748
|
+
batchSize?: number;
|
|
749
|
+
};
|
|
750
|
+
|
|
680
751
|
/**
|
|
681
752
|
* A user message typed on claude.ai, extracted from the bridge WS.
|
|
682
753
|
* @alpha
|
|
@@ -692,6 +763,35 @@ export declare type InferShape<T extends AnyZodRawShape> = {
|
|
|
692
763
|
} ? O : never;
|
|
693
764
|
} & {};
|
|
694
765
|
|
|
766
|
+
/**
|
|
767
|
+
* In-memory SessionStore implementation for testing and development.
|
|
768
|
+
* Stores entries in a Map keyed by a composite string.
|
|
769
|
+
* Not suitable for production -- data is lost when the process exits.
|
|
770
|
+
* @alpha
|
|
771
|
+
*/
|
|
772
|
+
export declare class InMemorySessionStore implements SessionStore {
|
|
773
|
+
private store;
|
|
774
|
+
private mtimes;
|
|
775
|
+
private keyToString;
|
|
776
|
+
append(key: SessionKey, entries: SessionStoreEntry[]): Promise<void>;
|
|
777
|
+
load(key: SessionKey): Promise<SessionStoreEntry[] | null>;
|
|
778
|
+
listSessions(projectKey: string): Promise<Array<{
|
|
779
|
+
sessionId: string;
|
|
780
|
+
mtime: number;
|
|
781
|
+
}>>;
|
|
782
|
+
delete(key: SessionKey): Promise<void>;
|
|
783
|
+
listSubkeys(key: {
|
|
784
|
+
projectKey: string;
|
|
785
|
+
sessionId: string;
|
|
786
|
+
}): Promise<string[]>;
|
|
787
|
+
/** Test helper -- get all entries for a key */
|
|
788
|
+
getEntries(key: SessionKey): SessionStoreEntry[];
|
|
789
|
+
/** Test helper -- number of stored sessions (main transcripts only) */
|
|
790
|
+
get size(): number;
|
|
791
|
+
/** Test helper -- clear all stored data */
|
|
792
|
+
clear(): void;
|
|
793
|
+
}
|
|
794
|
+
|
|
695
795
|
export declare type InstructionsLoadedHookInput = BaseHookInput & {
|
|
696
796
|
hook_event_name: 'InstructionsLoaded';
|
|
697
797
|
file_path: string;
|
|
@@ -752,7 +852,12 @@ export declare type ListSessionsOptions = {
|
|
|
752
852
|
* Only applies when reading from the local filesystem.
|
|
753
853
|
*/
|
|
754
854
|
includeWorktrees?: boolean;
|
|
755
|
-
|
|
855
|
+
/**
|
|
856
|
+
* When provided, list sessions from this store instead of the local
|
|
857
|
+
* filesystem. Requires `store.listSessions` to be defined.
|
|
858
|
+
* @alpha
|
|
859
|
+
*/
|
|
860
|
+
sessionStore?: SessionStore;
|
|
756
861
|
};
|
|
757
862
|
|
|
758
863
|
/**
|
|
@@ -773,7 +878,12 @@ export declare function listSubagents(_sessionId: string, _options?: ListSubagen
|
|
|
773
878
|
export declare type ListSubagentsOptions = {
|
|
774
879
|
/** Project directory to find the session in. If omitted, searches all projects. */
|
|
775
880
|
dir?: string;
|
|
776
|
-
|
|
881
|
+
/**
|
|
882
|
+
* When provided, list subagents from this store instead of the local
|
|
883
|
+
* filesystem. Requires `store.listSubkeys` to be defined.
|
|
884
|
+
* @alpha
|
|
885
|
+
*/
|
|
886
|
+
sessionStore?: SessionStore;
|
|
777
887
|
};
|
|
778
888
|
|
|
779
889
|
export declare type McpClaudeAIProxyServerConfig = {
|
|
@@ -1058,11 +1168,7 @@ export declare type Options = {
|
|
|
1058
1168
|
};
|
|
1059
1169
|
/**
|
|
1060
1170
|
* Environment variables to pass to the Claude Code process.
|
|
1061
|
-
*
|
|
1062
|
-
* process's variables, and anything not set here is inherited.
|
|
1063
|
-
* Set a key to `undefined` to remove an inherited variable. Note:
|
|
1064
|
-
* `GITHUB_ACTIONS` and a few SDK-managed vars are stripped and are
|
|
1065
|
-
* not inherited unless set explicitly here.
|
|
1171
|
+
* Defaults to `process.env`.
|
|
1066
1172
|
*
|
|
1067
1173
|
* SDK consumers can identify their app/library to include in the User-Agent header by setting:
|
|
1068
1174
|
* - `CLAUDE_AGENT_SDK_CLIENT_APP` - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")
|
|
@@ -1169,8 +1275,28 @@ export declare type Options = {
|
|
|
1169
1275
|
* @default true
|
|
1170
1276
|
*/
|
|
1171
1277
|
persistSession?: boolean;
|
|
1172
|
-
|
|
1173
|
-
|
|
1278
|
+
/**
|
|
1279
|
+
* Mirror session transcripts to an external store. When set, the subprocess
|
|
1280
|
+
* still writes to CLAUDE_CONFIG_DIR (set it to /tmp for ephemeral local copy)
|
|
1281
|
+
* AND emits entries to this adapter via dual-write.
|
|
1282
|
+
*
|
|
1283
|
+
* Cannot be used with persistSession: false -- local writes are required
|
|
1284
|
+
* for the mirror to function (the mirror hook fires after local write success).
|
|
1285
|
+
*
|
|
1286
|
+
* Default: undefined (no mirroring, today's behavior).
|
|
1287
|
+
* @alpha
|
|
1288
|
+
*/
|
|
1289
|
+
sessionStore?: SessionStore;
|
|
1290
|
+
/**
|
|
1291
|
+
* Timeout for each `sessionStore.load()` / `sessionStore.listSubkeys()` call
|
|
1292
|
+
* during resume materialization. If the adapter doesn't settle within this
|
|
1293
|
+
* window the query fails with a clear error instead of hanging the iterator
|
|
1294
|
+
* forever (the deferred-spawn path otherwise has no upper bound).
|
|
1295
|
+
*
|
|
1296
|
+
* @default 60_000
|
|
1297
|
+
* @alpha
|
|
1298
|
+
*/
|
|
1299
|
+
loadTimeoutMs?: number;
|
|
1174
1300
|
/**
|
|
1175
1301
|
* Include hook lifecycle events in the output stream.
|
|
1176
1302
|
* When true, `hook_started`, `hook_progress`, and `hook_response` system
|
|
@@ -1510,6 +1636,15 @@ export declare type Options = {
|
|
|
1510
1636
|
append?: string;
|
|
1511
1637
|
excludeDynamicSections?: boolean;
|
|
1512
1638
|
};
|
|
1639
|
+
/**
|
|
1640
|
+
* Custom title for a new session. When provided, the session uses this title
|
|
1641
|
+
* instead of auto-generating one from the first user message.
|
|
1642
|
+
*
|
|
1643
|
+
* When resuming via `resume` or `continue`, the resumed session's persisted
|
|
1644
|
+
* title takes precedence — use `renameSession()` to retitle an existing
|
|
1645
|
+
* session.
|
|
1646
|
+
*/
|
|
1647
|
+
title?: string;
|
|
1513
1648
|
|
|
1514
1649
|
/**
|
|
1515
1650
|
* Custom function to spawn the Claude Code process.
|
|
@@ -1970,6 +2105,7 @@ export declare type SandboxNetworkConfig = NonNullable<z.infer<ReturnType<typeof
|
|
|
1970
2105
|
*/
|
|
1971
2106
|
declare const SandboxNetworkConfigSchema: () => z.ZodOptional<z.ZodObject<{
|
|
1972
2107
|
allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2108
|
+
deniedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1973
2109
|
allowManagedDomainsOnly: z.ZodOptional<z.ZodBoolean>;
|
|
1974
2110
|
allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1975
2111
|
allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -1991,6 +2127,7 @@ declare const SandboxSettingsSchema: () => z.ZodObject<{
|
|
|
1991
2127
|
allowUnsandboxedCommands: z.ZodOptional<z.ZodBoolean>;
|
|
1992
2128
|
network: z.ZodOptional<z.ZodObject<{
|
|
1993
2129
|
allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2130
|
+
deniedDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1994
2131
|
allowManagedDomainsOnly: z.ZodOptional<z.ZodBoolean>;
|
|
1995
2132
|
allowUnixSockets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1996
2133
|
allowAllUnixSockets: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -2123,6 +2260,14 @@ declare type SDKControlElicitationRequest = {
|
|
|
2123
2260
|
description?: string;
|
|
2124
2261
|
};
|
|
2125
2262
|
|
|
2263
|
+
/**
|
|
2264
|
+
* Requests at-mention file autocomplete suggestions for a partial path prefix. Returns the same fuzzy-matched results the TUI shows.
|
|
2265
|
+
*/
|
|
2266
|
+
declare type SDKControlFileSuggestionsRequest = {
|
|
2267
|
+
subtype: 'file_suggestions';
|
|
2268
|
+
query: string;
|
|
2269
|
+
};
|
|
2270
|
+
|
|
2126
2271
|
/**
|
|
2127
2272
|
* Requests a breakdown of current context window usage by category.
|
|
2128
2273
|
*/
|
|
@@ -2248,6 +2393,10 @@ declare type SDKControlInitializeRequest = {
|
|
|
2248
2393
|
*/
|
|
2249
2394
|
excludeDynamicSections?: boolean;
|
|
2250
2395
|
agents?: Record<string, coreTypes.AgentDefinition>;
|
|
2396
|
+
/**
|
|
2397
|
+
* Custom session title. When provided, the session uses this title and skips automatic title generation. Has no effect on the persisted title when resuming an existing session.
|
|
2398
|
+
*/
|
|
2399
|
+
title?: string;
|
|
2251
2400
|
promptSuggestions?: boolean;
|
|
2252
2401
|
agentProgressSummaries?: boolean;
|
|
2253
2402
|
};
|
|
@@ -2370,7 +2519,7 @@ export declare type SDKControlRequest = {
|
|
|
2370
2519
|
request: SDKControlRequestInner;
|
|
2371
2520
|
};
|
|
2372
2521
|
|
|
2373
|
-
declare type SDKControlRequestInner = SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlRenameSessionRequest | SDKControlMcpStatusRequest | SDKControlGetContextUsageRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlCancelAsyncMessageRequest | SDKControlSeedReadStateRequest | SDKControlMcpSetServersRequest | SDKControlReloadPluginsRequest | SDKControlMcpReconnectRequest | SDKControlMcpToggleRequest | SDKControlChannelEnableRequest | SDKControlEndSessionRequest | SDKControlMcpAuthenticateRequest | SDKControlMcpClearAuthRequest | SDKControlMcpOAuthCallbackUrlRequest | SDKControlClaudeAuthenticateRequest | SDKControlClaudeOAuthCallbackRequest | SDKControlClaudeOAuthWaitForCompletionRequest | SDKControlRemoteControlRequest | SDKControlGenerateSessionTitleRequest | SDKControlSideQuestionRequest | SDKControlUltrareviewLaunchRequest | SDKControlOAuthTokenRefreshRequest | SDKControlStopTaskRequest | SDKControlApplyFlagSettingsRequest | SDKControlGetSettingsRequest | SDKControlElicitationRequest | SDKControlRequestUserDialogRequest;
|
|
2522
|
+
declare type SDKControlRequestInner = SDKControlInterruptRequest | SDKControlPermissionRequest | SDKControlInitializeRequest | SDKControlSetPermissionModeRequest | SDKControlSetModelRequest | SDKControlSetMaxThinkingTokensRequest | SDKControlRenameSessionRequest | SDKControlMcpStatusRequest | SDKControlGetContextUsageRequest | SDKControlFileSuggestionsRequest | SDKHookCallbackRequest | SDKControlMcpMessageRequest | SDKControlRewindFilesRequest | SDKControlCancelAsyncMessageRequest | SDKControlSeedReadStateRequest | SDKControlMcpSetServersRequest | SDKControlReloadPluginsRequest | SDKControlMcpReconnectRequest | SDKControlMcpToggleRequest | SDKControlChannelEnableRequest | SDKControlEndSessionRequest | SDKControlMcpAuthenticateRequest | SDKControlMcpClearAuthRequest | SDKControlMcpOAuthCallbackUrlRequest | SDKControlClaudeAuthenticateRequest | SDKControlClaudeOAuthCallbackRequest | SDKControlClaudeOAuthWaitForCompletionRequest | SDKControlRemoteControlRequest | SDKControlGenerateSessionTitleRequest | SDKControlSideQuestionRequest | SDKControlUltrareviewLaunchRequest | SDKControlOAuthTokenRefreshRequest | SDKControlStopTaskRequest | SDKControlApplyFlagSettingsRequest | SDKControlGetSettingsRequest | SDKControlElicitationRequest | SDKControlRequestUserDialogRequest;
|
|
2374
2523
|
|
|
2375
2524
|
/**
|
|
2376
2525
|
* Requests the SDK consumer to render a tool-driven blocking dialog and return the user choice. Used by tools that previously rendered Ink JSX via setToolJSX with an onDone callback.
|
|
@@ -2595,7 +2744,7 @@ export declare type SDKMemoryRecallMessage = {
|
|
|
2595
2744
|
session_id: string;
|
|
2596
2745
|
};
|
|
2597
2746
|
|
|
2598
|
-
export declare type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKUserMessageReplay | SDKResultMessage | SDKSystemMessage | SDKPartialAssistantMessage | SDKCompactBoundaryMessage | SDKStatusMessage | SDKAPIRetryMessage | SDKLocalCommandOutputMessage | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKPluginInstallMessage | SDKToolProgressMessage | SDKAuthStatusMessage | SDKTaskNotificationMessage | SDKTaskStartedMessage | SDKTaskUpdatedMessage | SDKTaskProgressMessage | SDKSessionStateChangedMessage | SDKNotificationMessage | SDKFilesPersistedEvent | SDKToolUseSummaryMessage | SDKMemoryRecallMessage | SDKRateLimitEvent | SDKElicitationCompleteMessage | SDKPromptSuggestionMessage;
|
|
2747
|
+
export declare type SDKMessage = SDKAssistantMessage | SDKUserMessage | SDKUserMessageReplay | SDKResultMessage | SDKSystemMessage | SDKPartialAssistantMessage | SDKCompactBoundaryMessage | SDKStatusMessage | SDKAPIRetryMessage | SDKLocalCommandOutputMessage | SDKHookStartedMessage | SDKHookProgressMessage | SDKHookResponseMessage | SDKPluginInstallMessage | SDKToolProgressMessage | SDKAuthStatusMessage | SDKTaskNotificationMessage | SDKTaskStartedMessage | SDKTaskUpdatedMessage | SDKTaskProgressMessage | SDKSessionStateChangedMessage | SDKNotificationMessage | SDKFilesPersistedEvent | SDKToolUseSummaryMessage | SDKMemoryRecallMessage | SDKRateLimitEvent | SDKElicitationCompleteMessage | SDKPromptSuggestionMessage | SDKMirrorErrorMessage;
|
|
2599
2748
|
|
|
2600
2749
|
/**
|
|
2601
2750
|
* Provenance of a user-role message (peer session, team lead, channel). Absent or `human` means keyboard input from the user.
|
|
@@ -2615,6 +2764,22 @@ export declare type SDKMessageOrigin = {
|
|
|
2615
2764
|
kind: 'coordinator';
|
|
2616
2765
|
};
|
|
2617
2766
|
|
|
2767
|
+
/**
|
|
2768
|
+
* Emitted when SessionStore.append() rejects or times out for a transcript-mirror batch. The batch is dropped (at-most-once delivery); this surfaces the failure so consumers are not silent on data loss.
|
|
2769
|
+
*/
|
|
2770
|
+
export declare type SDKMirrorErrorMessage = {
|
|
2771
|
+
type: 'system';
|
|
2772
|
+
subtype: 'mirror_error';
|
|
2773
|
+
error: string;
|
|
2774
|
+
key: {
|
|
2775
|
+
projectKey: string;
|
|
2776
|
+
sessionId: string;
|
|
2777
|
+
subpath?: string;
|
|
2778
|
+
};
|
|
2779
|
+
uuid: UUID;
|
|
2780
|
+
session_id: string;
|
|
2781
|
+
};
|
|
2782
|
+
|
|
2618
2783
|
/**
|
|
2619
2784
|
* Loop-side text notification. Mirrors the interactive REPL notification queue (key/priority/timeout). JSX notifications are not emitted on this channel.
|
|
2620
2785
|
*/
|
|
@@ -2838,11 +3003,7 @@ export declare type SDKSessionOptions = {
|
|
|
2838
3003
|
executableArgs?: string[];
|
|
2839
3004
|
/**
|
|
2840
3005
|
* Environment variables to pass to the Claude Code process.
|
|
2841
|
-
*
|
|
2842
|
-
* process's variables, and anything not set here is inherited.
|
|
2843
|
-
* Set a key to `undefined` to remove an inherited variable. Note:
|
|
2844
|
-
* `GITHUB_ACTIONS` and a few SDK-managed vars are stripped and are
|
|
2845
|
-
* not inherited unless set explicitly here.
|
|
3006
|
+
* Defaults to `process.env`.
|
|
2846
3007
|
*
|
|
2847
3008
|
* SDK consumers can identify their app/library to include in the User-Agent header by setting:
|
|
2848
3009
|
* - `CLAUDE_AGENT_SDK_CLIENT_APP` - Your app/library identifier (e.g., "my-app/1.0.0", "my-library/2.1")
|
|
@@ -3111,6 +3272,25 @@ export declare type SessionEndHookInput = BaseHookInput & {
|
|
|
3111
3272
|
reason: ExitReason;
|
|
3112
3273
|
};
|
|
3113
3274
|
|
|
3275
|
+
/**
|
|
3276
|
+
* Identifies a session transcript or subagent transcript in the store.
|
|
3277
|
+
* Main transcripts have no subpath; subagent transcripts include a subpath
|
|
3278
|
+
* like 'subagents/agent-{id}' that mirrors the on-disk directory structure.
|
|
3279
|
+
* @alpha
|
|
3280
|
+
*/
|
|
3281
|
+
export declare type SessionKey = {
|
|
3282
|
+
/** Caller-defined scope. Default: sanitized cwd. Multi-tenant deployments
|
|
3283
|
+
* should set this to a tenant ID or project name. Paths longer than 200
|
|
3284
|
+
* characters are truncated and suffixed with a portable djb2 hash so the
|
|
3285
|
+
* same path yields the same key under both Bun and Node.js. */
|
|
3286
|
+
projectKey: string;
|
|
3287
|
+
sessionId: string;
|
|
3288
|
+
/** Undefined = main transcript. Set for subagent files.
|
|
3289
|
+
* Empty string is invalid — omit the field for the main transcript.
|
|
3290
|
+
* Opaque to the adapter — just use it as a storage key suffix. */
|
|
3291
|
+
subpath?: string;
|
|
3292
|
+
};
|
|
3293
|
+
|
|
3114
3294
|
/**
|
|
3115
3295
|
* A message from a session transcript.
|
|
3116
3296
|
* Returned by `getSessionMessages` for reading historical session data.
|
|
@@ -3133,7 +3313,12 @@ export declare type SessionMutationOptions = {
|
|
|
3133
3313
|
* When omitted, all project directories are searched for the session file.
|
|
3134
3314
|
*/
|
|
3135
3315
|
dir?: string;
|
|
3136
|
-
|
|
3316
|
+
/**
|
|
3317
|
+
* When provided, read/write session data via this store instead of the
|
|
3318
|
+
* local filesystem.
|
|
3319
|
+
* @alpha
|
|
3320
|
+
*/
|
|
3321
|
+
sessionStore?: SessionStore;
|
|
3137
3322
|
};
|
|
3138
3323
|
|
|
3139
3324
|
export declare type SessionStartHookInput = BaseHookInput & {
|
|
@@ -3150,6 +3335,94 @@ export declare type SessionStartHookSpecificOutput = {
|
|
|
3150
3335
|
watchPaths?: string[];
|
|
3151
3336
|
};
|
|
3152
3337
|
|
|
3338
|
+
/**
|
|
3339
|
+
* Adapter for mirroring session transcripts to external storage.
|
|
3340
|
+
* The subprocess still writes to local disk (set CLAUDE_CONFIG_DIR=/tmp
|
|
3341
|
+
* for ephemeral local copy); the adapter receives a secondary copy.
|
|
3342
|
+
*
|
|
3343
|
+
* The SDK never deletes from your store unless you call deleteSession()
|
|
3344
|
+
* with delete? implemented. Retention is the adapter's responsibility —
|
|
3345
|
+
* implement TTL, S3 lifecycle policies, or scheduled cleanup according
|
|
3346
|
+
* to your compliance requirements (e.g., ZDR/HIPAA retention windows).
|
|
3347
|
+
* Local-disk transcripts under CLAUDE_CONFIG_DIR are swept by the
|
|
3348
|
+
* existing cleanupPeriodDays setting independently of this adapter.
|
|
3349
|
+
* @alpha
|
|
3350
|
+
*/
|
|
3351
|
+
export declare type SessionStore = {
|
|
3352
|
+
/**
|
|
3353
|
+
* Mirror a batch of transcript entries. Called AFTER the subprocess's
|
|
3354
|
+
* local write succeeds — durability is already guaranteed locally.
|
|
3355
|
+
*
|
|
3356
|
+
* Batches arrive at ~100ms cadence during active turns. Entries are
|
|
3357
|
+
* JSON-safe POJOs — one per line in the local JSONL file.
|
|
3358
|
+
*
|
|
3359
|
+
* Within a single process, persist entries in append-call order; across
|
|
3360
|
+
* concurrent processes, order is by storage commit time, not call time.
|
|
3361
|
+
*
|
|
3362
|
+
* Rejection is logged; the subprocess continues unaffected.
|
|
3363
|
+
* At-most-once delivery — failed batches are not retried.
|
|
3364
|
+
*/
|
|
3365
|
+
append(key: SessionKey, entries: SessionStoreEntry[]): Promise<void>;
|
|
3366
|
+
/**
|
|
3367
|
+
* Load a full session for resume. Called once, in the SDK parent, before
|
|
3368
|
+
* subprocess spawn. The result is materialized to a temporary JSONL file;
|
|
3369
|
+
* the subprocess resumes from that file using its existing resume code.
|
|
3370
|
+
*
|
|
3371
|
+
* Return `null` for a key that was never written; adapters that cannot
|
|
3372
|
+
* distinguish "never written" from "emptied" (e.g. Redis LRANGE) may
|
|
3373
|
+
* return `null` for both. Returned entries must be deep-equal to what was
|
|
3374
|
+
* appended — byte-equal serialization is NOT required (e.g. Postgres
|
|
3375
|
+
* JSONB may reorder object keys); the SDK never hashes or byte-compares
|
|
3376
|
+
* entries.
|
|
3377
|
+
*/
|
|
3378
|
+
load(key: SessionKey): Promise<SessionStoreEntry[] | null>;
|
|
3379
|
+
/**
|
|
3380
|
+
* List sessions for a projectKey. Returns IDs + modification times.
|
|
3381
|
+
* `mtime` is Unix epoch milliseconds; adapters without native modification
|
|
3382
|
+
* time (e.g. Redis) must maintain their own index. Result order is
|
|
3383
|
+
* unspecified — the SDK sorts by mtime descending.
|
|
3384
|
+
* Optional — if undefined, listSessions() with a sessionStore throws.
|
|
3385
|
+
*/
|
|
3386
|
+
listSessions?(projectKey: string): Promise<Array<{
|
|
3387
|
+
sessionId: string;
|
|
3388
|
+
mtime: number;
|
|
3389
|
+
}>>;
|
|
3390
|
+
/**
|
|
3391
|
+
* Delete a session. Optional — if undefined, deletion is a no-op
|
|
3392
|
+
* (appropriate for WORM/append-only backends like S3).
|
|
3393
|
+
*/
|
|
3394
|
+
delete?(key: SessionKey): Promise<void>;
|
|
3395
|
+
/**
|
|
3396
|
+
* List all subpath keys under a session (e.g., subagent transcripts).
|
|
3397
|
+
* Used during resume to discover and materialize all subagent data.
|
|
3398
|
+
* If undefined, resume only materializes the main transcript.
|
|
3399
|
+
*/
|
|
3400
|
+
listSubkeys?(key: {
|
|
3401
|
+
projectKey: string;
|
|
3402
|
+
sessionId: string;
|
|
3403
|
+
}): Promise<string[]>;
|
|
3404
|
+
};
|
|
3405
|
+
|
|
3406
|
+
/**
|
|
3407
|
+
* One JSONL transcript line as observed by a {@link SessionStore} adapter.
|
|
3408
|
+
*
|
|
3409
|
+
* The concrete entry shape is the on-disk transcript format (a large
|
|
3410
|
+
* discriminated union over `type` covering user/assistant messages, summaries,
|
|
3411
|
+
* titles, tags, mode changes, etc.). That union is CLI-internal and not part
|
|
3412
|
+
* of the SDK API surface, so this is exposed as a minimal structural supertype
|
|
3413
|
+
* — every entry has a string `type` discriminant, most carry a `uuid` and ISO
|
|
3414
|
+
* `timestamp`, and the rest of the payload is opaque JSON. Adapters should
|
|
3415
|
+
* treat entries as pass-through blobs; round-tripping `JSON.stringify` /
|
|
3416
|
+
* `JSON.parse` is the only required invariant.
|
|
3417
|
+
* @alpha
|
|
3418
|
+
*/
|
|
3419
|
+
export declare type SessionStoreEntry = {
|
|
3420
|
+
type: string;
|
|
3421
|
+
uuid?: string;
|
|
3422
|
+
timestamp?: string;
|
|
3423
|
+
[k: string]: unknown;
|
|
3424
|
+
};
|
|
3425
|
+
|
|
3153
3426
|
/**
|
|
3154
3427
|
* AUTO-GENERATED - DO NOT EDIT
|
|
3155
3428
|
*
|
|
@@ -4192,6 +4465,10 @@ export declare interface Settings {
|
|
|
4192
4465
|
allowUnsandboxedCommands?: boolean;
|
|
4193
4466
|
network?: {
|
|
4194
4467
|
allowedDomains?: string[];
|
|
4468
|
+
/**
|
|
4469
|
+
* Domains that are always blocked, even if matched by allowedDomains. Supports the same wildcard syntax as allowedDomains. Merged from all settings sources regardless of allowManagedDomainsOnly.
|
|
4470
|
+
*/
|
|
4471
|
+
deniedDomains?: string[];
|
|
4195
4472
|
/**
|
|
4196
4473
|
* When true (and set in managed settings), only allowedDomains and WebFetch(domain:...) allow rules from managed settings are respected. User, project, local, and flag settings domains are ignored. Denied domains are still respected from all sources.
|
|
4197
4474
|
*/
|
|
@@ -4356,7 +4633,7 @@ export declare interface Settings {
|
|
|
4356
4633
|
/**
|
|
4357
4634
|
* Release channel for auto-updates (latest or stable)
|
|
4358
4635
|
*/
|
|
4359
|
-
autoUpdatesChannel?: 'latest' | 'stable';
|
|
4636
|
+
autoUpdatesChannel?: 'latest' | 'stable' | 'rc';
|
|
4360
4637
|
/**
|
|
4361
4638
|
* Minimum version to stay on - prevents downgrades when switching to stable channel
|
|
4362
4639
|
*/
|