@opencow-ai/opencow-agent-sdk 0.4.26 → 0.4.28
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/dist/capabilities/mcp/types.d.ts +3 -0
- package/dist/capabilities/plugins/pluginOptionsStorage.d.ts +6 -0
- package/dist/capabilities/plugins/schemas.d.ts +6 -0
- package/dist/capabilities/plugins/sdkPluginRuntime.d.ts +2 -0
- package/dist/cli.mjs +228 -241
- package/dist/client.js +288 -257
- package/dist/constants/oauth.d.ts +0 -8
- package/dist/controller/compact/compact.d.ts +8 -2
- package/dist/controller/dispatch/toolHooks.d.ts +4 -3
- package/dist/controller/loop.d.ts +2 -1
- package/dist/entrypoints/sdk/controlSchemas.d.ts +25 -0
- package/dist/entrypoints/sdk/coreSchemas.d.ts +16 -0
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +21 -0
- package/dist/providers/shared/retry.d.ts +13 -1
- package/dist/sdk.js +288 -257
- package/dist/session/branding.d.ts +4 -0
- package/dist/session/brandingConfig.d.ts +16 -0
- package/dist/session/contextSnapshot.d.ts +14 -0
- package/dist/session/state/index.d.ts +1 -1
- package/dist/session/state/registries.d.ts +8 -1
- package/dist/session/state/types.d.ts +2 -0
- package/dist/types/contextSnapshot.d.ts +17 -0
- package/package.json +1 -1
- package/dist/capabilities/tools/AgentTool/built-in/claudeCodeGuideAgent.d.ts +0 -3
|
@@ -27,13 +27,5 @@ type OauthConfig = {
|
|
|
27
27
|
MCP_PROXY_URL: string;
|
|
28
28
|
MCP_PROXY_PATH: string;
|
|
29
29
|
};
|
|
30
|
-
/**
|
|
31
|
-
* Client ID Metadata Document URL for MCP OAuth (CIMD / SEP-991).
|
|
32
|
-
* When an MCP auth server advertises client_id_metadata_document_supported: true,
|
|
33
|
-
* Claude Code uses this URL as its client_id instead of Dynamic Client Registration.
|
|
34
|
-
* The URL must point to a JSON document hosted by Anthropic.
|
|
35
|
-
* See: https://datatracker.ietf.org/doc/html/draft-ietf-oauth-client-id-metadata-document-00
|
|
36
|
-
*/
|
|
37
|
-
export declare const MCP_CLIENT_METADATA_URL = "https://claude.ai/oauth/claude-code-client-metadata";
|
|
38
30
|
export declare function getOauthConfig(): OauthConfig;
|
|
39
31
|
export {};
|
|
@@ -3,7 +3,7 @@ import type { QuerySource } from '../../constants/querySource.js';
|
|
|
3
3
|
import type { CanUseToolFn } from '../../types/canUseTool.js';
|
|
4
4
|
import type { ToolUseContext } from '../../Tool.js';
|
|
5
5
|
import type { AgentId } from '../../types/ids.js';
|
|
6
|
-
import type { AssistantMessage, AttachmentMessage, HookResultMessage, Message, PartialCompactDirection, SystemCompactBoundaryMessage,
|
|
6
|
+
import type { AssistantMessage, AttachmentMessage, HookResultMessage, Message, PartialCompactDirection, SystemCompactBoundaryMessage, UserMessage } from '../../types/message.js';
|
|
7
7
|
import { type CacheSafeParams } from '../../session/forkedAgent.js';
|
|
8
8
|
import { getTokenUsage } from '../../session/tokens.js';
|
|
9
9
|
export declare const POST_COMPACT_MAX_FILES_TO_RESTORE = 5;
|
|
@@ -53,7 +53,7 @@ export declare const ERROR_MESSAGE_PROMPT_TOO_LONG = "Conversation too long. Pre
|
|
|
53
53
|
export declare const ERROR_MESSAGE_USER_ABORT = "API Error: Request was aborted.";
|
|
54
54
|
export declare const ERROR_MESSAGE_INCOMPLETE_RESPONSE = "Compaction interrupted \u00B7 This may be due to network issues \u2014 please try again.";
|
|
55
55
|
export interface CompactionResult {
|
|
56
|
-
boundaryMarker:
|
|
56
|
+
boundaryMarker: SystemCompactBoundaryMessage;
|
|
57
57
|
summaryMessages: UserMessage[];
|
|
58
58
|
attachments: AttachmentMessage[];
|
|
59
59
|
hookResults: HookResultMessage[];
|
|
@@ -82,6 +82,12 @@ export type RecompactionInfo = {
|
|
|
82
82
|
* Order: boundaryMarker, summaryMessages, messagesToKeep, attachments, hookResults
|
|
83
83
|
*/
|
|
84
84
|
export declare function buildPostCompactMessages(result: CompactionResult): Message[];
|
|
85
|
+
/**
|
|
86
|
+
* Attach the complete post-compact context to the public boundary metadata.
|
|
87
|
+
* The snapshot is built before the boundary is annotated so its embedded copy
|
|
88
|
+
* cannot reference itself.
|
|
89
|
+
*/
|
|
90
|
+
export declare function attachContextSnapshot(result: CompactionResult): CompactionResult;
|
|
85
91
|
/**
|
|
86
92
|
* Annotate a compact boundary with relink metadata for messagesToKeep.
|
|
87
93
|
* Preserved messages keep their original parentUuids on disk (dedup-skipped);
|
|
@@ -13,9 +13,10 @@ export declare function runPostToolUseFailureHooks<Input extends AnyObject>(tool
|
|
|
13
13
|
/**
|
|
14
14
|
* Resolve a PreToolUse hook's permission result into a final PermissionDecision.
|
|
15
15
|
*
|
|
16
|
-
* Encapsulates the invariant that hook 'allow'
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* Encapsulates the invariant that hook 'allow' is advisory: the host's
|
|
17
|
+
* canUseTool still decides, so a hook can never bypass the host's gate nor
|
|
18
|
+
* settings.json deny/ask rules. The only exemption is an interactive tool whose
|
|
19
|
+
* answers were supplied by the hook itself (updatedInput). Also handles the
|
|
19
20
|
* 'ask' forceDecision passthrough.
|
|
20
21
|
*
|
|
21
22
|
* Shared by toolExecution.ts (main query loop) and REPLTool/toolWrappers.ts
|
|
@@ -28,7 +28,8 @@ export declare function adjustParamsForNonStreaming<T extends {
|
|
|
28
28
|
export type Options = {
|
|
29
29
|
/**
|
|
30
30
|
* 内部:由 replayStreamOnTransportError 置位。为 true 时,读流阶段的可重放传输错误
|
|
31
|
-
*
|
|
31
|
+
* (且尚无完整消息送出)优先作为异常抛给调用方重放,而不是先走 non-streaming
|
|
32
|
+
* fallback 或转成 assistant 错误消息;预算用尽后该标记为 false,恢复原路径。
|
|
32
33
|
*/
|
|
33
34
|
streamReplayEscape?: boolean;
|
|
34
35
|
getToolPermissionContext: () => Promise<ToolPermissionContext>;
|
|
@@ -63,6 +63,7 @@ export declare const SDKControlInitializeRequestSchema: () => z.ZodObject<{
|
|
|
63
63
|
command: z.ZodString;
|
|
64
64
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
65
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
66
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
66
67
|
}, z.core.$strip>, z.ZodObject<{
|
|
67
68
|
type: z.ZodLiteral<"sse">;
|
|
68
69
|
url: z.ZodString;
|
|
@@ -298,6 +299,7 @@ export declare const SDKControlMcpStatusResponseSchema: () => z.ZodObject<{
|
|
|
298
299
|
command: z.ZodString;
|
|
299
300
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
300
301
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
302
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
301
303
|
}, z.core.$strip>, z.ZodObject<{
|
|
302
304
|
type: z.ZodLiteral<"sse">;
|
|
303
305
|
url: z.ZodString;
|
|
@@ -948,6 +950,7 @@ export declare const SDKControlMcpSetServersRequestSchema: () => z.ZodObject<{
|
|
|
948
950
|
command: z.ZodString;
|
|
949
951
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
950
952
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
953
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
951
954
|
}, z.core.$strip>, z.ZodObject<{
|
|
952
955
|
type: z.ZodLiteral<"sse">;
|
|
953
956
|
url: z.ZodString;
|
|
@@ -1004,6 +1007,7 @@ export declare const SDKControlReloadPluginsResponseSchema: () => z.ZodObject<{
|
|
|
1004
1007
|
command: z.ZodString;
|
|
1005
1008
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1006
1009
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1010
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
1007
1011
|
}, z.core.$strip>, z.ZodObject<{
|
|
1008
1012
|
type: z.ZodLiteral<"sse">;
|
|
1009
1013
|
url: z.ZodString;
|
|
@@ -1252,6 +1256,7 @@ export declare const SDKControlRequestInnerSchema: () => z.ZodUnion<readonly [z.
|
|
|
1252
1256
|
command: z.ZodString;
|
|
1253
1257
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1254
1258
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1259
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
1255
1260
|
}, z.core.$strip>, z.ZodObject<{
|
|
1256
1261
|
type: z.ZodLiteral<"sse">;
|
|
1257
1262
|
url: z.ZodString;
|
|
@@ -1822,6 +1827,7 @@ export declare const SDKControlRequestInnerSchema: () => z.ZodUnion<readonly [z.
|
|
|
1822
1827
|
command: z.ZodString;
|
|
1823
1828
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
1824
1829
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
1830
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
1825
1831
|
}, z.core.$strip>, z.ZodObject<{
|
|
1826
1832
|
type: z.ZodLiteral<"sse">;
|
|
1827
1833
|
url: z.ZodString;
|
|
@@ -2020,6 +2026,7 @@ export declare const SDKControlRequestSchema: () => z.ZodObject<{
|
|
|
2020
2026
|
command: z.ZodString;
|
|
2021
2027
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2022
2028
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2029
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
2023
2030
|
}, z.core.$strip>, z.ZodObject<{
|
|
2024
2031
|
type: z.ZodLiteral<"sse">;
|
|
2025
2032
|
url: z.ZodString;
|
|
@@ -2590,6 +2597,7 @@ export declare const SDKControlRequestSchema: () => z.ZodObject<{
|
|
|
2590
2597
|
command: z.ZodString;
|
|
2591
2598
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2592
2599
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2600
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
2593
2601
|
}, z.core.$strip>, z.ZodObject<{
|
|
2594
2602
|
type: z.ZodLiteral<"sse">;
|
|
2595
2603
|
url: z.ZodString;
|
|
@@ -2798,6 +2806,7 @@ export declare const ControlErrorResponseSchema: () => z.ZodObject<{
|
|
|
2798
2806
|
command: z.ZodString;
|
|
2799
2807
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2800
2808
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2809
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
2801
2810
|
}, z.core.$strip>, z.ZodObject<{
|
|
2802
2811
|
type: z.ZodLiteral<"sse">;
|
|
2803
2812
|
url: z.ZodString;
|
|
@@ -3368,6 +3377,7 @@ export declare const ControlErrorResponseSchema: () => z.ZodObject<{
|
|
|
3368
3377
|
command: z.ZodString;
|
|
3369
3378
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3370
3379
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3380
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
3371
3381
|
}, z.core.$strip>, z.ZodObject<{
|
|
3372
3382
|
type: z.ZodLiteral<"sse">;
|
|
3373
3383
|
url: z.ZodString;
|
|
@@ -3578,6 +3588,7 @@ export declare const SDKControlResponseSchema: () => z.ZodObject<{
|
|
|
3578
3588
|
command: z.ZodString;
|
|
3579
3589
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
3580
3590
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
3591
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
3581
3592
|
}, z.core.$strip>, z.ZodObject<{
|
|
3582
3593
|
type: z.ZodLiteral<"sse">;
|
|
3583
3594
|
url: z.ZodString;
|
|
@@ -4148,6 +4159,7 @@ export declare const SDKControlResponseSchema: () => z.ZodObject<{
|
|
|
4148
4159
|
command: z.ZodString;
|
|
4149
4160
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
4150
4161
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4162
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
4151
4163
|
}, z.core.$strip>, z.ZodObject<{
|
|
4152
4164
|
type: z.ZodLiteral<"sse">;
|
|
4153
4165
|
url: z.ZodString;
|
|
@@ -4377,6 +4389,11 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
4377
4389
|
}>;
|
|
4378
4390
|
pre_tokens: z.ZodNumber;
|
|
4379
4391
|
post_tokens: z.ZodOptional<z.ZodNumber>;
|
|
4392
|
+
context_snapshot: z.ZodOptional<z.ZodObject<{
|
|
4393
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
4394
|
+
messages: z.ZodArray<z.ZodUnknown>;
|
|
4395
|
+
baselineTokens: z.ZodNumber;
|
|
4396
|
+
}, z.core.$strip>>;
|
|
4380
4397
|
preserved_segment: z.ZodOptional<z.ZodObject<{
|
|
4381
4398
|
head_uuid: z.ZodString;
|
|
4382
4399
|
anchor_uuid: z.ZodString;
|
|
@@ -4801,6 +4818,7 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
4801
4818
|
command: z.ZodString;
|
|
4802
4819
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
4803
4820
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
4821
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
4804
4822
|
}, z.core.$strip>, z.ZodObject<{
|
|
4805
4823
|
type: z.ZodLiteral<"sse">;
|
|
4806
4824
|
url: z.ZodString;
|
|
@@ -5371,6 +5389,7 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
5371
5389
|
command: z.ZodString;
|
|
5372
5390
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5373
5391
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
5392
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
5374
5393
|
}, z.core.$strip>, z.ZodObject<{
|
|
5375
5394
|
type: z.ZodLiteral<"sse">;
|
|
5376
5395
|
url: z.ZodString;
|
|
@@ -5571,6 +5590,7 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
5571
5590
|
command: z.ZodString;
|
|
5572
5591
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5573
5592
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
5593
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
5574
5594
|
}, z.core.$strip>, z.ZodObject<{
|
|
5575
5595
|
type: z.ZodLiteral<"sse">;
|
|
5576
5596
|
url: z.ZodString;
|
|
@@ -6141,6 +6161,7 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
6141
6161
|
command: z.ZodString;
|
|
6142
6162
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6143
6163
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
6164
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
6144
6165
|
}, z.core.$strip>, z.ZodObject<{
|
|
6145
6166
|
type: z.ZodLiteral<"sse">;
|
|
6146
6167
|
url: z.ZodString;
|
|
@@ -6359,6 +6380,7 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
6359
6380
|
command: z.ZodString;
|
|
6360
6381
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6361
6382
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
6383
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
6362
6384
|
}, z.core.$strip>, z.ZodObject<{
|
|
6363
6385
|
type: z.ZodLiteral<"sse">;
|
|
6364
6386
|
url: z.ZodString;
|
|
@@ -6929,6 +6951,7 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
6929
6951
|
command: z.ZodString;
|
|
6930
6952
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6931
6953
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
6954
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
6932
6955
|
}, z.core.$strip>, z.ZodObject<{
|
|
6933
6956
|
type: z.ZodLiteral<"sse">;
|
|
6934
6957
|
url: z.ZodString;
|
|
@@ -7137,6 +7160,7 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
7137
7160
|
command: z.ZodString;
|
|
7138
7161
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7139
7162
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
7163
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
7140
7164
|
}, z.core.$strip>, z.ZodObject<{
|
|
7141
7165
|
type: z.ZodLiteral<"sse">;
|
|
7142
7166
|
url: z.ZodString;
|
|
@@ -7707,6 +7731,7 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
7707
7731
|
command: z.ZodString;
|
|
7708
7732
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7709
7733
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
7734
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
7710
7735
|
}, z.core.$strip>, z.ZodObject<{
|
|
7711
7736
|
type: z.ZodLiteral<"sse">;
|
|
7712
7737
|
url: z.ZodString;
|
|
@@ -65,6 +65,7 @@ export declare const McpStdioServerConfigSchema: () => z.ZodObject<{
|
|
|
65
65
|
command: z.ZodString;
|
|
66
66
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
67
67
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
68
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
68
69
|
}, z.core.$strip>;
|
|
69
70
|
export declare const McpSSEServerConfigSchema: () => z.ZodObject<{
|
|
70
71
|
type: z.ZodLiteral<"sse">;
|
|
@@ -85,6 +86,7 @@ export declare const McpServerConfigForProcessTransportSchema: () => z.ZodUnion<
|
|
|
85
86
|
command: z.ZodString;
|
|
86
87
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
87
88
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
89
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
88
90
|
}, z.core.$strip>, z.ZodObject<{
|
|
89
91
|
type: z.ZodLiteral<"sse">;
|
|
90
92
|
url: z.ZodString;
|
|
@@ -107,6 +109,7 @@ export declare const McpServerStatusConfigSchema: () => z.ZodUnion<readonly [z.Z
|
|
|
107
109
|
command: z.ZodString;
|
|
108
110
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
109
111
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
112
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
110
113
|
}, z.core.$strip>, z.ZodObject<{
|
|
111
114
|
type: z.ZodLiteral<"sse">;
|
|
112
115
|
url: z.ZodString;
|
|
@@ -142,6 +145,7 @@ export declare const McpServerStatusSchema: () => z.ZodObject<{
|
|
|
142
145
|
command: z.ZodString;
|
|
143
146
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
144
147
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
148
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
145
149
|
}, z.core.$strip>, z.ZodObject<{
|
|
146
150
|
type: z.ZodLiteral<"sse">;
|
|
147
151
|
url: z.ZodString;
|
|
@@ -2054,6 +2058,7 @@ export declare const AgentMcpServerSpecSchema: () => z.ZodUnion<readonly [z.ZodS
|
|
|
2054
2058
|
command: z.ZodString;
|
|
2055
2059
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2056
2060
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2061
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
2057
2062
|
}, z.core.$strip>, z.ZodObject<{
|
|
2058
2063
|
type: z.ZodLiteral<"sse">;
|
|
2059
2064
|
url: z.ZodString;
|
|
@@ -2077,6 +2082,7 @@ export declare const AgentDefinitionSchema: () => z.ZodObject<{
|
|
|
2077
2082
|
command: z.ZodString;
|
|
2078
2083
|
args: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2079
2084
|
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2085
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
2080
2086
|
}, z.core.$strip>, z.ZodObject<{
|
|
2081
2087
|
type: z.ZodLiteral<"sse">;
|
|
2082
2088
|
url: z.ZodString;
|
|
@@ -2503,6 +2509,11 @@ export declare const SDKCompactBoundaryMessageSchema: () => z.ZodObject<{
|
|
|
2503
2509
|
}>;
|
|
2504
2510
|
pre_tokens: z.ZodNumber;
|
|
2505
2511
|
post_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2512
|
+
context_snapshot: z.ZodOptional<z.ZodObject<{
|
|
2513
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
2514
|
+
messages: z.ZodArray<z.ZodUnknown>;
|
|
2515
|
+
baselineTokens: z.ZodNumber;
|
|
2516
|
+
}, z.core.$strip>>;
|
|
2506
2517
|
preserved_segment: z.ZodOptional<z.ZodObject<{
|
|
2507
2518
|
head_uuid: z.ZodString;
|
|
2508
2519
|
anchor_uuid: z.ZodString;
|
|
@@ -2912,6 +2923,11 @@ export declare const SDKMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<{
|
|
|
2912
2923
|
}>;
|
|
2913
2924
|
pre_tokens: z.ZodNumber;
|
|
2914
2925
|
post_tokens: z.ZodOptional<z.ZodNumber>;
|
|
2926
|
+
context_snapshot: z.ZodOptional<z.ZodObject<{
|
|
2927
|
+
schemaVersion: z.ZodLiteral<1>;
|
|
2928
|
+
messages: z.ZodArray<z.ZodUnknown>;
|
|
2929
|
+
baselineTokens: z.ZodNumber;
|
|
2930
|
+
}, z.core.$strip>>;
|
|
2915
2931
|
preserved_segment: z.ZodOptional<z.ZodObject<{
|
|
2916
2932
|
head_uuid: z.ZodString;
|
|
2917
2933
|
anchor_uuid: z.ZodString;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
2
|
import type { ModelProviders } from '../../providers/shared/routing.js';
|
|
3
3
|
import type { UploadMediaFn } from '../../types/toolRuntime.js';
|
|
4
|
+
import type { SDKContextSnapshot } from '../../types/contextSnapshot.js';
|
|
5
|
+
export type { SDKContextSnapshot } from '../../types/contextSnapshot.js';
|
|
4
6
|
export type { ModelProviders, ModelProviderConfig, } from '../../providers/shared/routing.js';
|
|
5
7
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
6
8
|
import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
@@ -62,6 +64,8 @@ export type McpStdioServerConfig = {
|
|
|
62
64
|
command: string;
|
|
63
65
|
args?: string[];
|
|
64
66
|
env?: Record<string, string>;
|
|
67
|
+
/** Working directory the server process is spawned in. */
|
|
68
|
+
cwd?: string;
|
|
65
69
|
};
|
|
66
70
|
export type McpSSEServerConfig = {
|
|
67
71
|
type: 'sse';
|
|
@@ -159,6 +163,12 @@ export type SdkManagedPlugin = {
|
|
|
159
163
|
export type SdkPluginSnapshot = {
|
|
160
164
|
revision: string;
|
|
161
165
|
plugins: readonly SdkManagedPlugin[];
|
|
166
|
+
/**
|
|
167
|
+
* Host-defined `${NAME}` values substituted into managed plugin skill and
|
|
168
|
+
* command bodies when they are invoked (e.g. host-specific directories).
|
|
169
|
+
* Names must match `[A-Z][A-Z0-9_]*`; unknown placeholders stay literal.
|
|
170
|
+
*/
|
|
171
|
+
contentVariables?: Readonly<Record<string, string>>;
|
|
162
172
|
};
|
|
163
173
|
export type SdkPluginDiagnostic = {
|
|
164
174
|
severity: 'warning' | 'error';
|
|
@@ -519,6 +529,17 @@ export type Options = {
|
|
|
519
529
|
*/
|
|
520
530
|
spawnClaudeCodeProcess?: (opts: SpawnOptions) => SpawnedProcess;
|
|
521
531
|
initialMessages?: unknown[];
|
|
532
|
+
/**
|
|
533
|
+
* Opaque canonical post-compact context returned by a previous
|
|
534
|
+
* `compact_metadata.context_snapshot`. Hosts persist it unchanged and pass
|
|
535
|
+
* it back after restart. When both this and `initialMessages` are provided,
|
|
536
|
+
* the snapshot is restored first and `initialMessages` are appended as the
|
|
537
|
+
* tail (normally events recorded after the snapshot).
|
|
538
|
+
*
|
|
539
|
+
* Invalid snapshots throw instead of silently falling back to a smaller
|
|
540
|
+
* context.
|
|
541
|
+
*/
|
|
542
|
+
initialContextSnapshot?: SDKContextSnapshot;
|
|
522
543
|
/**
|
|
523
544
|
* Controls whether the SDK performs ANY filesystem reads of its own
|
|
524
545
|
* during session execution.
|
|
@@ -10,7 +10,19 @@ export declare const BASE_DELAY_MS = 500;
|
|
|
10
10
|
* 只认传输特征(cause 带系统错误码或固定文案),普通 TypeError 仍按程序错误处理。
|
|
11
11
|
*/
|
|
12
12
|
export declare function wrapBodyTransportError(error: unknown): unknown;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* 已收到 message_start、但流在任何完整 content block / stop_reason 之前结束。
|
|
15
|
+
* 这类空流可能由代理瞬断造成,且尚未提交任何模型输出,可以安全地整条请求重放。
|
|
16
|
+
* 没有 message_start 的 200 空响应不归入此类:它更像网关不兼容 SSE,保留
|
|
17
|
+
* non-streaming fallback(见 controller/loop.ts)。
|
|
18
|
+
*
|
|
19
|
+
* 重放前可能已经向消费方 yield 过半截 stream_event。消费方必须在新的
|
|
20
|
+
* message_start 到达时重置未完成的流式内容;SDK 不保证撤回已经展示的部分。
|
|
21
|
+
*/
|
|
22
|
+
export declare class EmptyStreamError extends Error {
|
|
23
|
+
constructor(message?: string);
|
|
24
|
+
}
|
|
25
|
+
/** 读流阶段的传输中断(对端关闭、socket 断开、空闲看门狗中止、空流)可以整条请求重放;其余不行。 */
|
|
14
26
|
export declare function toReplayableStreamError(error: unknown): APIConnectionError | null;
|
|
15
27
|
/**
|
|
16
28
|
* 流式响应读到一半断开、且还没有任何完整消息送出时,整个流式请求重放。
|