@opencow-ai/opencow-agent-sdk 0.4.6 → 0.4.7
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 +1 -1
- package/dist/capabilities/tools/AgentTool/agentMerge.d.ts +8 -0
- package/dist/capabilities/tools/AgentTool/builtInAgents.d.ts +15 -0
- package/dist/capabilities/tools/AgentTool/runAgent.d.ts +13 -2
- package/dist/cli.mjs +343 -105
- package/dist/client.d.ts +10 -0
- package/dist/client.js +332 -77
- package/dist/constants/tools.d.ts +1 -1
- package/dist/controller/hooks.d.ts +17 -2
- package/dist/controller/loop.d.ts +2 -5
- package/dist/entrypoints/sdk/controlSchemas.d.ts +73 -1
- package/dist/entrypoints/sdk/coreSchemas.d.ts +17 -1
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +22 -0
- package/dist/lib/envDynamic.d.ts +1 -1
- package/dist/providers/anthropic/teleport/api.d.ts +1 -1
- package/dist/providers/openai/shim.d.ts +2 -5
- package/dist/providers/provider.d.ts +2 -5
- package/dist/providers/shared/clientFactory.d.ts +2 -5
- package/dist/providers/shared/routing.d.ts +37 -6
- package/dist/sdk.js +332 -77
- package/dist/session/backgroundAbortRegistry.d.ts +23 -0
- package/dist/types/toolRuntime.d.ts +8 -5
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@ export declare const ASYNC_AGENT_ALLOWED_TOOLS: Set<string>;
|
|
|
6
6
|
* These are injected by inProcessRunner.ts and allowed through filterToolsForAgent
|
|
7
7
|
* via isInProcessTeammate() check.
|
|
8
8
|
*/
|
|
9
|
-
export declare const IN_PROCESS_TEAMMATE_ALLOWED_TOOLS: Set<
|
|
9
|
+
export declare const IN_PROCESS_TEAMMATE_ALLOWED_TOOLS: Set<string>;
|
|
10
10
|
/**
|
|
11
11
|
* Tools allowed in coordinator mode - only output and agent management tools for the coordinator
|
|
12
12
|
*/
|
|
@@ -218,7 +218,10 @@ export declare function executeStopFailureHooks(lastMessage: AssistantMessage, t
|
|
|
218
218
|
* @param messages Optional conversation history for prompt/function hooks
|
|
219
219
|
* @returns Async generator that yields progress messages and blocking errors
|
|
220
220
|
*/
|
|
221
|
-
export declare function executeStopHooks(permissionMode?: string, signal?: AbortSignal, timeoutMs?: number, stopHookActive?: boolean, subagentId?: AgentId, toolUseContext?: ToolRuntimeContext, messages?: Message[], agentType?: string, requestPrompt?: (sourceName: string, toolInputSummary?: string | null) => (request: PromptRequest) => Promise<PromptResponse
|
|
221
|
+
export declare function executeStopHooks(permissionMode?: string, signal?: AbortSignal, timeoutMs?: number, stopHookActive?: boolean, subagentId?: AgentId, toolUseContext?: ToolRuntimeContext, messages?: Message[], agentType?: string, requestPrompt?: (sourceName: string, toolInputSummary?: string | null) => (request: PromptRequest) => Promise<PromptResponse>, terminal?: {
|
|
222
|
+
status: 'completed' | 'failed' | 'stopped';
|
|
223
|
+
errorMessage?: string;
|
|
224
|
+
}): AsyncGenerator<AggregatedHookResult>;
|
|
222
225
|
/**
|
|
223
226
|
* Execute TeammateIdle hooks when a teammate is about to go idle.
|
|
224
227
|
* If a hook blocks (exit code 2), the teammate should continue working instead of going idle.
|
|
@@ -296,7 +299,19 @@ export declare function executeSetupHooks(trigger: 'init' | 'maintenance', signa
|
|
|
296
299
|
* @param timeoutMs Optional timeout in milliseconds for hook execution
|
|
297
300
|
* @returns Async generator that yields progress messages and hook results
|
|
298
301
|
*/
|
|
299
|
-
export declare function executeSubagentStartHooks(agentId: string, agentType: string, signal?: AbortSignal, timeoutMs?: number): AsyncGenerator<AggregatedHookResult>;
|
|
302
|
+
export declare function executeSubagentStartHooks(agentId: string, agentType: string, signal?: AbortSignal, timeoutMs?: number, toolUseId?: string, isBackground?: boolean): AsyncGenerator<AggregatedHookResult>;
|
|
303
|
+
/**
|
|
304
|
+
* Fire a SubagentProgress hook carrying one of a background sub-agent's
|
|
305
|
+
* completed messages (its content blocks, already simplified). Lets a host
|
|
306
|
+
* stream a background sub-agent's running sub-conversation (thinking / text /
|
|
307
|
+
* tool calls) into its UI out-of-band — i.e. while the main turn is idle —
|
|
308
|
+
* reusing the same per-message reduction it uses for foreground sub-agents.
|
|
309
|
+
*
|
|
310
|
+
* Fire-and-forget by design: callers must NOT await the per-message firing in
|
|
311
|
+
* the agent's hot loop. `blocks` is intentionally loosely typed (hook inputs
|
|
312
|
+
* are `any` in coreTypes) and mirrors the host's normalized event shapes.
|
|
313
|
+
*/
|
|
314
|
+
export declare function executeSubagentProgressHooks(agentId: string, agentType: string, messageId: string, parentToolUseId: string | undefined, blocks: Array<Record<string, unknown>>, signal?: AbortSignal): Promise<void>;
|
|
300
315
|
/**
|
|
301
316
|
* Execute pre-compact hooks if configured
|
|
302
317
|
* @param compactData The compact data to pass to hooks
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderOverride } from '../providers/shared/routing.js';
|
|
1
2
|
import type { BetaJSONOutputFormat, BetaMessage, BetaMessageStreamParams, BetaToolChoiceAuto, BetaToolChoiceTool, BetaToolUnion } from '@anthropic-ai/sdk/resources/beta/messages/messages.mjs';
|
|
2
3
|
import { type QueryChainTracking, type ToolPermissionContext, type Tools } from '../Tool.js';
|
|
3
4
|
import type { AgentDefinition } from '../capabilities/tools/AgentTool/loadAgentsDir.js';
|
|
@@ -54,11 +55,7 @@ export type Options = {
|
|
|
54
55
|
total: number;
|
|
55
56
|
remaining?: number;
|
|
56
57
|
};
|
|
57
|
-
providerOverride?:
|
|
58
|
-
model: string;
|
|
59
|
-
baseURL: string;
|
|
60
|
-
apiKey: string;
|
|
61
|
-
};
|
|
58
|
+
providerOverride?: ProviderOverride;
|
|
62
59
|
};
|
|
63
60
|
export declare function queryModelWithoutStreaming({ messages, systemPrompt, thinkingConfig, tools, signal, options, }: {
|
|
64
61
|
messages: Message[];
|
|
@@ -601,6 +601,8 @@ export declare const SDKHookCallbackRequestSchema: () => z.ZodObject<{
|
|
|
601
601
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
602
602
|
agent_id: z.ZodString;
|
|
603
603
|
agent_type: z.ZodString;
|
|
604
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
605
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
604
606
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
605
607
|
session_id: z.ZodString;
|
|
606
608
|
transcript_path: z.ZodString;
|
|
@@ -615,6 +617,12 @@ export declare const SDKHookCallbackRequestSchema: () => z.ZodObject<{
|
|
|
615
617
|
agent_transcript_path: z.ZodString;
|
|
616
618
|
agent_type: z.ZodString;
|
|
617
619
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
620
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
621
|
+
failed: "failed";
|
|
622
|
+
completed: "completed";
|
|
623
|
+
stopped: "stopped";
|
|
624
|
+
}>>;
|
|
625
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
618
626
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
619
627
|
session_id: z.ZodString;
|
|
620
628
|
transcript_path: z.ZodString;
|
|
@@ -1458,6 +1466,8 @@ export declare const SDKControlRequestInnerSchema: () => z.ZodUnion<readonly [z.
|
|
|
1458
1466
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
1459
1467
|
agent_id: z.ZodString;
|
|
1460
1468
|
agent_type: z.ZodString;
|
|
1469
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
1470
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
1461
1471
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
1462
1472
|
session_id: z.ZodString;
|
|
1463
1473
|
transcript_path: z.ZodString;
|
|
@@ -1472,6 +1482,12 @@ export declare const SDKControlRequestInnerSchema: () => z.ZodUnion<readonly [z.
|
|
|
1472
1482
|
agent_transcript_path: z.ZodString;
|
|
1473
1483
|
agent_type: z.ZodString;
|
|
1474
1484
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
1485
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
1486
|
+
failed: "failed";
|
|
1487
|
+
completed: "completed";
|
|
1488
|
+
stopped: "stopped";
|
|
1489
|
+
}>>;
|
|
1490
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
1475
1491
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
1476
1492
|
session_id: z.ZodString;
|
|
1477
1493
|
transcript_path: z.ZodString;
|
|
@@ -2218,6 +2234,8 @@ export declare const SDKControlRequestSchema: () => z.ZodObject<{
|
|
|
2218
2234
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
2219
2235
|
agent_id: z.ZodString;
|
|
2220
2236
|
agent_type: z.ZodString;
|
|
2237
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
2238
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
2221
2239
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
2222
2240
|
session_id: z.ZodString;
|
|
2223
2241
|
transcript_path: z.ZodString;
|
|
@@ -2232,6 +2250,12 @@ export declare const SDKControlRequestSchema: () => z.ZodObject<{
|
|
|
2232
2250
|
agent_transcript_path: z.ZodString;
|
|
2233
2251
|
agent_type: z.ZodString;
|
|
2234
2252
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
2253
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
2254
|
+
failed: "failed";
|
|
2255
|
+
completed: "completed";
|
|
2256
|
+
stopped: "stopped";
|
|
2257
|
+
}>>;
|
|
2258
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
2235
2259
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
2236
2260
|
session_id: z.ZodString;
|
|
2237
2261
|
transcript_path: z.ZodString;
|
|
@@ -2988,6 +3012,8 @@ export declare const ControlErrorResponseSchema: () => z.ZodObject<{
|
|
|
2988
3012
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
2989
3013
|
agent_id: z.ZodString;
|
|
2990
3014
|
agent_type: z.ZodString;
|
|
3015
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
3016
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
2991
3017
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
2992
3018
|
session_id: z.ZodString;
|
|
2993
3019
|
transcript_path: z.ZodString;
|
|
@@ -3002,6 +3028,12 @@ export declare const ControlErrorResponseSchema: () => z.ZodObject<{
|
|
|
3002
3028
|
agent_transcript_path: z.ZodString;
|
|
3003
3029
|
agent_type: z.ZodString;
|
|
3004
3030
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
3031
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
3032
|
+
failed: "failed";
|
|
3033
|
+
completed: "completed";
|
|
3034
|
+
stopped: "stopped";
|
|
3035
|
+
}>>;
|
|
3036
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
3005
3037
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
3006
3038
|
session_id: z.ZodString;
|
|
3007
3039
|
transcript_path: z.ZodString;
|
|
@@ -3760,6 +3792,8 @@ export declare const SDKControlResponseSchema: () => z.ZodObject<{
|
|
|
3760
3792
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
3761
3793
|
agent_id: z.ZodString;
|
|
3762
3794
|
agent_type: z.ZodString;
|
|
3795
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
3796
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
3763
3797
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
3764
3798
|
session_id: z.ZodString;
|
|
3765
3799
|
transcript_path: z.ZodString;
|
|
@@ -3774,6 +3808,12 @@ export declare const SDKControlResponseSchema: () => z.ZodObject<{
|
|
|
3774
3808
|
agent_transcript_path: z.ZodString;
|
|
3775
3809
|
agent_type: z.ZodString;
|
|
3776
3810
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
3811
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
3812
|
+
failed: "failed";
|
|
3813
|
+
completed: "completed";
|
|
3814
|
+
stopped: "stopped";
|
|
3815
|
+
}>>;
|
|
3816
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
3777
3817
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
3778
3818
|
session_id: z.ZodString;
|
|
3779
3819
|
transcript_path: z.ZodString;
|
|
@@ -4579,9 +4619,9 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
4579
4619
|
summarizes_uuid: z.ZodString;
|
|
4580
4620
|
status_category: z.ZodEnum<{
|
|
4581
4621
|
failed: "failed";
|
|
4622
|
+
completed: "completed";
|
|
4582
4623
|
blocked: "blocked";
|
|
4583
4624
|
waiting: "waiting";
|
|
4584
|
-
completed: "completed";
|
|
4585
4625
|
review_ready: "review_ready";
|
|
4586
4626
|
}>;
|
|
4587
4627
|
status_detail: z.ZodString;
|
|
@@ -4974,6 +5014,8 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
4974
5014
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
4975
5015
|
agent_id: z.ZodString;
|
|
4976
5016
|
agent_type: z.ZodString;
|
|
5017
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
5018
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
4977
5019
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
4978
5020
|
session_id: z.ZodString;
|
|
4979
5021
|
transcript_path: z.ZodString;
|
|
@@ -4988,6 +5030,12 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
4988
5030
|
agent_transcript_path: z.ZodString;
|
|
4989
5031
|
agent_type: z.ZodString;
|
|
4990
5032
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
5033
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
5034
|
+
failed: "failed";
|
|
5035
|
+
completed: "completed";
|
|
5036
|
+
stopped: "stopped";
|
|
5037
|
+
}>>;
|
|
5038
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
4991
5039
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
4992
5040
|
session_id: z.ZodString;
|
|
4993
5041
|
transcript_path: z.ZodString;
|
|
@@ -5736,6 +5784,8 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
5736
5784
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
5737
5785
|
agent_id: z.ZodString;
|
|
5738
5786
|
agent_type: z.ZodString;
|
|
5787
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
5788
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
5739
5789
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
5740
5790
|
session_id: z.ZodString;
|
|
5741
5791
|
transcript_path: z.ZodString;
|
|
@@ -5750,6 +5800,12 @@ export declare const StdoutMessageSchema: () => z.ZodUnion<readonly [z.ZodUnion<
|
|
|
5750
5800
|
agent_transcript_path: z.ZodString;
|
|
5751
5801
|
agent_type: z.ZodString;
|
|
5752
5802
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
5803
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
5804
|
+
failed: "failed";
|
|
5805
|
+
completed: "completed";
|
|
5806
|
+
stopped: "stopped";
|
|
5807
|
+
}>>;
|
|
5808
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
5753
5809
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
5754
5810
|
session_id: z.ZodString;
|
|
5755
5811
|
transcript_path: z.ZodString;
|
|
@@ -6516,6 +6572,8 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
6516
6572
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
6517
6573
|
agent_id: z.ZodString;
|
|
6518
6574
|
agent_type: z.ZodString;
|
|
6575
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
6576
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
6519
6577
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
6520
6578
|
session_id: z.ZodString;
|
|
6521
6579
|
transcript_path: z.ZodString;
|
|
@@ -6530,6 +6588,12 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
6530
6588
|
agent_transcript_path: z.ZodString;
|
|
6531
6589
|
agent_type: z.ZodString;
|
|
6532
6590
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
6591
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
6592
|
+
failed: "failed";
|
|
6593
|
+
completed: "completed";
|
|
6594
|
+
stopped: "stopped";
|
|
6595
|
+
}>>;
|
|
6596
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
6533
6597
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
6534
6598
|
session_id: z.ZodString;
|
|
6535
6599
|
transcript_path: z.ZodString;
|
|
@@ -7286,6 +7350,8 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
7286
7350
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
7287
7351
|
agent_id: z.ZodString;
|
|
7288
7352
|
agent_type: z.ZodString;
|
|
7353
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
7354
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
7289
7355
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
7290
7356
|
session_id: z.ZodString;
|
|
7291
7357
|
transcript_path: z.ZodString;
|
|
@@ -7300,6 +7366,12 @@ export declare const StdinMessageSchema: () => z.ZodUnion<readonly [z.ZodObject<
|
|
|
7300
7366
|
agent_transcript_path: z.ZodString;
|
|
7301
7367
|
agent_type: z.ZodString;
|
|
7302
7368
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
7369
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
7370
|
+
failed: "failed";
|
|
7371
|
+
completed: "completed";
|
|
7372
|
+
stopped: "stopped";
|
|
7373
|
+
}>>;
|
|
7374
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
7303
7375
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
7304
7376
|
session_id: z.ZodString;
|
|
7305
7377
|
transcript_path: z.ZodString;
|
|
@@ -704,6 +704,8 @@ export declare const SubagentStartHookInputSchema: () => z.ZodIntersection<z.Zod
|
|
|
704
704
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
705
705
|
agent_id: z.ZodString;
|
|
706
706
|
agent_type: z.ZodString;
|
|
707
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
708
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
707
709
|
}, z.core.$strip>>;
|
|
708
710
|
export declare const SubagentStopHookInputSchema: () => z.ZodIntersection<z.ZodObject<{
|
|
709
711
|
session_id: z.ZodString;
|
|
@@ -719,6 +721,12 @@ export declare const SubagentStopHookInputSchema: () => z.ZodIntersection<z.ZodO
|
|
|
719
721
|
agent_transcript_path: z.ZodString;
|
|
720
722
|
agent_type: z.ZodString;
|
|
721
723
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
724
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
725
|
+
failed: "failed";
|
|
726
|
+
completed: "completed";
|
|
727
|
+
stopped: "stopped";
|
|
728
|
+
}>>;
|
|
729
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
722
730
|
}, z.core.$strip>>;
|
|
723
731
|
export declare const PreCompactHookInputSchema: () => z.ZodIntersection<z.ZodObject<{
|
|
724
732
|
session_id: z.ZodString;
|
|
@@ -1117,6 +1125,8 @@ export declare const HookInputSchema: () => z.ZodUnion<readonly [z.ZodIntersecti
|
|
|
1117
1125
|
hook_event_name: z.ZodLiteral<"SubagentStart">;
|
|
1118
1126
|
agent_id: z.ZodString;
|
|
1119
1127
|
agent_type: z.ZodString;
|
|
1128
|
+
tool_use_id: z.ZodOptional<z.ZodString>;
|
|
1129
|
+
is_background: z.ZodOptional<z.ZodBoolean>;
|
|
1120
1130
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
1121
1131
|
session_id: z.ZodString;
|
|
1122
1132
|
transcript_path: z.ZodString;
|
|
@@ -1131,6 +1141,12 @@ export declare const HookInputSchema: () => z.ZodUnion<readonly [z.ZodIntersecti
|
|
|
1131
1141
|
agent_transcript_path: z.ZodString;
|
|
1132
1142
|
agent_type: z.ZodString;
|
|
1133
1143
|
last_assistant_message: z.ZodOptional<z.ZodString>;
|
|
1144
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
1145
|
+
failed: "failed";
|
|
1146
|
+
completed: "completed";
|
|
1147
|
+
stopped: "stopped";
|
|
1148
|
+
}>>;
|
|
1149
|
+
error_message: z.ZodOptional<z.ZodString>;
|
|
1134
1150
|
}, z.core.$strip>>, z.ZodIntersection<z.ZodObject<{
|
|
1135
1151
|
session_id: z.ZodString;
|
|
1136
1152
|
transcript_path: z.ZodString;
|
|
@@ -2515,9 +2531,9 @@ export declare const SDKPostTurnSummaryMessageSchema: () => z.ZodObject<{
|
|
|
2515
2531
|
summarizes_uuid: z.ZodString;
|
|
2516
2532
|
status_category: z.ZodEnum<{
|
|
2517
2533
|
failed: "failed";
|
|
2534
|
+
completed: "completed";
|
|
2518
2535
|
blocked: "blocked";
|
|
2519
2536
|
waiting: "waiting";
|
|
2520
|
-
completed: "completed";
|
|
2521
2537
|
review_ready: "review_ready";
|
|
2522
2538
|
}>;
|
|
2523
2539
|
status_detail: z.ZodString;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
|
+
import type { ModelProviders } from '../../providers/shared/routing.js';
|
|
3
|
+
export type { ModelProviders, ModelProviderConfig } from '../../providers/shared/routing.js';
|
|
2
4
|
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
5
|
import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
4
6
|
import type { z } from 'zod/v4';
|
|
@@ -15,6 +17,15 @@ export type Query = AsyncIterable<SDKMessage> & {
|
|
|
15
17
|
* cancel a long turn without ending the whole query.
|
|
16
18
|
*/
|
|
17
19
|
interrupt(): Promise<void> | void;
|
|
20
|
+
/**
|
|
21
|
+
* Abort a single in-flight run_in_background sub-agent by its agentId, without
|
|
22
|
+
* touching the main turn or other agents. The agent's AbortController is
|
|
23
|
+
* signalled (killAsyncAgent), so its in-flight tool calls unwind cleanly.
|
|
24
|
+
* No-op if the agent is unknown or already settled. Lets a host surface a
|
|
25
|
+
* per-agent "stop" affordance (desktop UI) on top of the model-facing
|
|
26
|
+
* TaskStop tool.
|
|
27
|
+
*/
|
|
28
|
+
killAgent(agentId: string): void;
|
|
18
29
|
};
|
|
19
30
|
/** @internal */
|
|
20
31
|
export type InternalQuery = Query;
|
|
@@ -271,6 +282,17 @@ export type Options = {
|
|
|
271
282
|
* Accepted at runtime with console.warn; remove call sites by 0.3.0.
|
|
272
283
|
*/
|
|
273
284
|
transport?: ProviderTransport | DeprecatedProviderTransportName | 'auto';
|
|
285
|
+
/**
|
|
286
|
+
* Host model → provider-route catalog, keyed by model id. Consulted AFTER
|
|
287
|
+
* subagent model resolution (tier aliases / Agent tool `model` param), so
|
|
288
|
+
* a subagent whose model lives on a different wire or endpoint than the
|
|
289
|
+
* main session routes to its own baseURL/key/transport instead of
|
|
290
|
+
* inheriting the session's (which 404s for cross-protocol tier models).
|
|
291
|
+
* Models absent from the catalog use the session provider config as
|
|
292
|
+
* before. Entries may carry `providerSpecific.openaiResponses` extras
|
|
293
|
+
* applied when that model's request uses the openai_responses wire.
|
|
294
|
+
*/
|
|
295
|
+
modelProviders?: ModelProviders;
|
|
274
296
|
/**
|
|
275
297
|
* Per-protocol passthrough channel for fields the wire supports but the
|
|
276
298
|
* SDK does not surface as first-class options. The shim merges these
|
package/dist/lib/envDynamic.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export declare const envDynamic: {
|
|
|
23
23
|
initJetBrainsDetection: typeof initJetBrainsDetection;
|
|
24
24
|
hasInternetAccess: any;
|
|
25
25
|
isCI: boolean;
|
|
26
|
-
platform: "
|
|
26
|
+
platform: "linux" | "win32" | "darwin";
|
|
27
27
|
arch: NodeJS.Architecture;
|
|
28
28
|
nodeVersion: string;
|
|
29
29
|
isSSH: () => boolean;
|
|
@@ -68,9 +68,9 @@ export declare const CodeSessionSchema: () => z.ZodObject<{
|
|
|
68
68
|
title: z.ZodString;
|
|
69
69
|
description: z.ZodString;
|
|
70
70
|
status: z.ZodEnum<{
|
|
71
|
+
completed: "completed";
|
|
71
72
|
rejected: "rejected";
|
|
72
73
|
waiting: "waiting";
|
|
73
|
-
completed: "completed";
|
|
74
74
|
cancelled: "cancelled";
|
|
75
75
|
idle: "idle";
|
|
76
76
|
working: "working";
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
* GITHUB_TOKEN or GH_TOKEN — PAT with models access (mapped to Bearer auth)
|
|
21
21
|
* OPENAI_MODEL — optional; use github:copilot or openai/gpt-4.1 style IDs
|
|
22
22
|
*/
|
|
23
|
+
import type { ProviderOverride } from '../shared/routing.js';
|
|
23
24
|
import { type AnthropicStreamEvent, type ShimCreateParams } from '../../providers/codex/shim.js';
|
|
24
25
|
interface OpenAIMessage {
|
|
25
26
|
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
@@ -199,10 +200,6 @@ export declare function createOpenAIShimClient(options: {
|
|
|
199
200
|
maxRetries?: number;
|
|
200
201
|
timeout?: number;
|
|
201
202
|
reasoningEffort?: 'low' | 'medium' | 'high' | 'xhigh';
|
|
202
|
-
providerOverride?:
|
|
203
|
-
model: string;
|
|
204
|
-
baseURL: string;
|
|
205
|
-
apiKey: string;
|
|
206
|
-
};
|
|
203
|
+
providerOverride?: ProviderOverride;
|
|
207
204
|
}): unknown;
|
|
208
205
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type Anthropic from '@anthropic-ai/sdk';
|
|
2
|
+
import type { ProviderOverride } from './shared/routing.js';
|
|
2
3
|
import type { ClientOptions } from '@anthropic-ai/sdk';
|
|
3
4
|
import type { ModelOutputTokenCap, NormalizedRequest, NormalizedResponse, ProviderError, ProviderFeature, ProviderId, ProviderProtocol, StreamEvent } from './types.js';
|
|
4
5
|
/**
|
|
@@ -19,11 +20,7 @@ export interface CreateClientOptions {
|
|
|
19
20
|
* without forcing hosts to rebuild a whole Provider object when
|
|
20
21
|
* the swap is temporary.
|
|
21
22
|
*/
|
|
22
|
-
readonly providerOverride?:
|
|
23
|
-
readonly model: string;
|
|
24
|
-
readonly baseURL: string;
|
|
25
|
-
readonly apiKey: string;
|
|
26
|
-
};
|
|
23
|
+
readonly providerOverride?: ProviderOverride;
|
|
27
24
|
}
|
|
28
25
|
export interface Provider {
|
|
29
26
|
/** Stable id for logs / telemetry / per-session pinning. Not used for dispatch. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Anthropic, { type ClientOptions } from '@anthropic-ai/sdk';
|
|
2
|
+
import type { ProviderOverride } from './routing.js';
|
|
2
3
|
/**
|
|
3
4
|
* @internal γ.6c
|
|
4
5
|
*
|
|
@@ -22,10 +23,6 @@ export declare function getNormalizedClient({ apiKey, maxRetries, model, fetchOv
|
|
|
22
23
|
model?: string;
|
|
23
24
|
fetchOverride?: ClientOptions['fetch'];
|
|
24
25
|
source?: string;
|
|
25
|
-
providerOverride?:
|
|
26
|
-
model: string;
|
|
27
|
-
baseURL: string;
|
|
28
|
-
apiKey: string;
|
|
29
|
-
};
|
|
26
|
+
providerOverride?: ProviderOverride;
|
|
30
27
|
}): Promise<Anthropic>;
|
|
31
28
|
export declare const CLIENT_REQUEST_ID_HEADER = "x-client-request-id";
|
|
@@ -1,16 +1,47 @@
|
|
|
1
1
|
import type { SettingsJson } from '../../session/settings/types.js';
|
|
2
|
+
import type { ProviderTransport } from './config.js';
|
|
2
3
|
/**
|
|
3
|
-
* Provider override resolved
|
|
4
|
-
* When present, the API client
|
|
4
|
+
* Provider override resolved for a specific agent/model.
|
|
5
|
+
* When present, the API client uses these instead of the session-global
|
|
6
|
+
* env-derived provider config (baseURL/key/transport).
|
|
5
7
|
*/
|
|
6
8
|
export interface ProviderOverride {
|
|
7
9
|
/** Model name to send to the API (e.g. "deepseek-chat", "gpt-4o") */
|
|
8
10
|
model: string;
|
|
9
|
-
/**
|
|
10
|
-
baseURL
|
|
11
|
-
/** API key
|
|
12
|
-
apiKey
|
|
11
|
+
/** Base URL. Optional — falls back to the session's OPENAI_BASE_URL env. */
|
|
12
|
+
baseURL?: string;
|
|
13
|
+
/** API key. Optional — falls back to the session's env credential chain. */
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Wire transport for this override. Without it the session-level
|
|
17
|
+
* transport/sniff applies — which is exactly the cross-protocol subagent
|
|
18
|
+
* bug: a tier model living on a different wire (e.g. openai_responses)
|
|
19
|
+
* than the main session (chat_completions) hits the wrong endpoint and
|
|
20
|
+
* 404s. 'anthropic' routes to the native Anthropic client instead of the
|
|
21
|
+
* OpenAI shim.
|
|
22
|
+
*/
|
|
23
|
+
transport?: ProviderTransport | 'anthropic';
|
|
24
|
+
/** Per-wire extras (e.g. openai-responses reasoning summary config). */
|
|
25
|
+
providerSpecific?: {
|
|
26
|
+
openaiResponses?: Record<string, unknown>;
|
|
27
|
+
};
|
|
13
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Host-supplied model → provider-route catalog (`Options.modelProviders`).
|
|
31
|
+
* Key is the model id as it appears after subagent model resolution (tier
|
|
32
|
+
* env values / Agent tool `model` param). The host owns the model catalog
|
|
33
|
+
* (which channel/protocol each model lives on); the SDK consults this AFTER
|
|
34
|
+
* resolving a subagent's model so any resolution path — tier alias, explicit
|
|
35
|
+
* model param, inherit — lands on the right wire.
|
|
36
|
+
*/
|
|
37
|
+
export type ModelProviderConfig = Omit<ProviderOverride, 'model'>;
|
|
38
|
+
export type ModelProviders = Record<string, ModelProviderConfig>;
|
|
39
|
+
/**
|
|
40
|
+
* Resolve a model's provider route from the host catalog. Returns null when
|
|
41
|
+
* the catalog has no entry — the model is served by the session's default
|
|
42
|
+
* provider config (the common case: same wire as the main session).
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveModelProvider(model: string, modelProviders: ModelProviders | undefined): ProviderOverride | null;
|
|
14
45
|
/**
|
|
15
46
|
* Look up agent.routing by name or subagent_type, then resolve via agent.models.
|
|
16
47
|
*
|