@chatcode/chatcode-cli 3.0.6-rc.1 → 3.0.6-rc.3
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/lib/{command-errors-CnbcOM1a.js → command-errors-vCFKCJFq.js} +12 -12
- package/lib/{command-trees-CU7BxVJo.js → command-trees-N2_LR4f-.js} +2 -2
- package/lib/{component-identity-kZK1_hFy.js → component-identity-CaV_MmmE.js} +3 -3
- package/lib/{extension-events-hLxwPvpg.js → extension-events-B5qKP0-X.js} +20 -20
- package/lib/{host-access-kT-u85k_.js → host-access-BRXW3V8i.js} +1 -1
- package/lib/{keymap-DS1M8sDo.js → keymap-BYjklwli.js} +2 -2
- package/lib/{plugin-BccFcAte.js → plugin-VYAv2o0K.js} +497 -347
- package/lib/{scenes-DG6T8t-A.js → scenes-B-iDMpgW.js} +3 -3
- package/lib/{settings-sections-2SuE0biI.js → settings-sections-CYCrZKUk.js} +3 -3
- package/lib/{statusBarSettings-B2MEAwnI.js → statusBarSettings-Cu-b_o4Q.js} +3 -3
- package/lib/{themes-DUO7kGW-.js → themes-DC9GpV6q.js} +12 -12
- package/lib/tui-compat-command-trees.js +1 -1
- package/lib/tui-compat-extensions.js +3 -3
- package/lib/tui-compat-plugin-host.js +5 -5
- package/lib/tui-compat-scenes.js +1 -1
- package/lib/tui-compat-settings-sections.js +1 -1
- package/lib/tui-compat-working-activity.js +1 -1
- package/lib/tui-compat-workspaces.js +1 -1
- package/lib/tui-compat.js +6 -6
- package/lib/{workspaces-CLOkL_yE.js → workspaces-BchdRzlw.js} +2 -2
- package/package.json +25 -25
- package/runtime/manifest.json +1 -1
- package/runtime/node_modules/@chatcode/runtime-client/README.md +11 -8
- package/runtime/node_modules/@chatcode/runtime-client/index.d.ts +6 -12
- package/runtime/node_modules/@chatcode/runtime-client/package.json +1 -1
- package/runtime/node_modules/@chatcode/runtime-client/runtime-connector.mjs +16 -16
- package/runtime/node_modules/@chatcode/runtime-client/session-browser.mjs +1 -0
- package/runtime/node_modules/@deepseek-ai/dsh-agent-loop/lib/index.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-agent-preset-registry/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-api-remotes/lib/client.js +14 -4
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +1 -0
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/index.js +23 -10
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.host.js +23 -13
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.remote-client.d.ts +2 -2
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.remote-client.js +10 -0
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.d.ts +2 -1
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.js +5 -3
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/commands.js +8 -3
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/history/controller.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.d.ts +1 -0
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/list.js +7 -3
- package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/types.d.ts +9 -0
- package/runtime/node_modules/@deepseek-ai/dsh-api-terminal-controller/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-client-file-upload/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +2 -2
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/types/index.d.ts +2 -2
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-commands/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-cordis-host-runner/lib/typert.host.js +6 -6
- package/runtime/node_modules/@deepseek-ai/dsh-goal/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/index.js +17 -1
- package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/typert.host.js +6 -6
- package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/typert.remote-client.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/call-config.d.ts +4 -0
- package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/call-config.js +1 -0
- package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/index.js +24 -0
- package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/types.d.ts +2 -0
- package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js +7 -0
- package/runtime/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +15 -4
- package/runtime/node_modules/@deepseek-ai/dsh-permission-presets/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/lib/index.js +16 -1
- package/runtime/node_modules/@deepseek-ai/dsh-session/lib/index.js +12 -1
- package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/index.d.ts +2 -0
- package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/index.js +13 -1
- package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/known-event-types.js +1 -0
- package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/types.d.ts +5 -0
- package/runtime/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/worker.cjs +22 -1
- package/runtime/node_modules/@deepseek-ai/dsh-session-reference/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/index.js +1 -0
- package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/typert.host.js +3 -3
- package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/types/child-agent.js +1 -0
- package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/types/control.d.ts +1 -1
- package/runtime/node_modules/@deepseek-ai/dsh-tmux-context/lib/index.js +16 -1
- package/runtime/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +83 -20
- package/runtime/node_modules/@deepseek-ai/node-addon-system/lib/.tsbuildinfo +1 -1
|
@@ -775,7 +775,7 @@ export const TYPERT = {
|
|
|
775
775
|
},
|
|
776
776
|
{
|
|
777
777
|
"name": "LlmCallConfig",
|
|
778
|
-
"declaration": "export interface LlmCallConfig {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
778
|
+
"declaration": "export interface LlmCallConfig {\n baseUrl?: string;\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
779
779
|
},
|
|
780
780
|
{
|
|
781
781
|
"name": "LlmCallConfigAdapterDefaults",
|
|
@@ -907,7 +907,7 @@ export const TYPERT = {
|
|
|
907
907
|
},
|
|
908
908
|
{
|
|
909
909
|
"name": "Session",
|
|
910
|
-
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
910
|
+
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n get appId(): string | undefined;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
911
911
|
},
|
|
912
912
|
{
|
|
913
913
|
"name": "SessionEvent",
|
|
@@ -915,7 +915,7 @@ export const TYPERT = {
|
|
|
915
915
|
},
|
|
916
916
|
{
|
|
917
917
|
"name": "SessionEventMap",
|
|
918
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'schedule/change': ScheduleChange;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
918
|
+
"declaration": "export interface SessionEventMap {\n 'session/application': { appId: string; };\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'schedule/change': ScheduleChange;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
919
919
|
},
|
|
920
920
|
{
|
|
921
921
|
"name": "SessionEventType",
|
|
@@ -418,7 +418,7 @@ const AGENT_LOOP_REQUESTS = /* @__PURE__ */ new WeakSet();
|
|
|
418
418
|
* @returns whether every field (including the `stop` list, element-wise) matches.
|
|
419
419
|
*/
|
|
420
420
|
function callConfigEquals(a, b) {
|
|
421
|
-
if (a.provider !== b.provider || a.model !== b.model || a.reasoningEffort !== b.reasoningEffort || a.temperature !== b.temperature || a.maxTokens !== b.maxTokens || a.contextWindow !== b.contextWindow || a.protocol !== b.protocol || !deepEqualJson(a.protocolOptions, b.protocolOptions)) return false;
|
|
421
|
+
if (a.provider !== b.provider || a.model !== b.model || a.reasoningEffort !== b.reasoningEffort || a.temperature !== b.temperature || a.maxTokens !== b.maxTokens || a.contextWindow !== b.contextWindow || a.protocol !== b.protocol || a.baseUrl !== b.baseUrl || !deepEqualJson(a.protocolOptions, b.protocolOptions)) return false;
|
|
422
422
|
if (a.stop === void 0 || b.stop === void 0) return a.stop === b.stop;
|
|
423
423
|
return a.stop.length === b.stop.length && a.stop.every((s, i) => s === b.stop?.[i]);
|
|
424
424
|
}
|
|
@@ -1862,6 +1862,7 @@ var LlmAdapter = class {
|
|
|
1862
1862
|
* @param config - Common controls and protocol options for the registered route.
|
|
1863
1863
|
*/
|
|
1864
1864
|
validatePromptProtocol(config) {
|
|
1865
|
+
if (config.baseUrl !== void 0) throw new LlmError("baseUrl", "UNSUPPORTED_OPTION");
|
|
1865
1866
|
if (config.protocol !== void 0) throw new LlmError("protocol", "UNSUPPORTED_OPTION");
|
|
1866
1867
|
const option = Object.keys(config.protocolOptions ?? {})[0];
|
|
1867
1868
|
if (option !== void 0) throw new LlmError(`protocolOptions.${option}`, "UNSUPPORTED_OPTION");
|
|
@@ -2308,6 +2309,17 @@ let LlmRuntime = (() => {
|
|
|
2308
2309
|
model,
|
|
2309
2310
|
...protocol === void 0 ? {} : { protocol }
|
|
2310
2311
|
};
|
|
2312
|
+
if (request.baseUrl !== void 0) {
|
|
2313
|
+
let endpoint;
|
|
2314
|
+
try {
|
|
2315
|
+
endpoint = new URL(request.baseUrl);
|
|
2316
|
+
} catch (_invalidEndpoint) {
|
|
2317
|
+
throw new LlmError("baseUrl", "UNSUPPORTED_OPTION");
|
|
2318
|
+
}
|
|
2319
|
+
if (typeof request.baseUrl !== "string" || request.baseUrl !== request.baseUrl.trim() || !["http:", "https:"].includes(endpoint.protocol) || !endpoint.hostname || endpoint.username || endpoint.password || endpoint.search || endpoint.hash) throw new LlmError("baseUrl", "UNSUPPORTED_OPTION");
|
|
2320
|
+
if (request.apiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
2321
|
+
config.baseUrl = request.baseUrl;
|
|
2322
|
+
}
|
|
2311
2323
|
const forwarded = new Map(Object.entries(protocolOptions ?? {}));
|
|
2312
2324
|
for (const [key, value] of Object.entries(options)) {
|
|
2313
2325
|
const invalid = () => new LlmError(`options.${key}`, "UNSUPPORTED_OPTION");
|
|
@@ -2375,6 +2387,10 @@ let LlmRuntime = (() => {
|
|
|
2375
2387
|
async prepareCall(config, signal, promptApiKey) {
|
|
2376
2388
|
const registration = this.registration(config.provider);
|
|
2377
2389
|
if (promptApiKey !== void 0 && !registration.adapter.supportsPromptApiKey(config.provider, config.model)) throw new LlmError("This model route cannot use a prompt API key", "UNSUPPORTED_OPTION");
|
|
2390
|
+
if (config.baseUrl !== void 0) {
|
|
2391
|
+
if (promptApiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
2392
|
+
registration.adapter.validatePromptProtocol(config);
|
|
2393
|
+
}
|
|
2378
2394
|
const adapterCall = await registration.adapter.prepareCall(config.provider, config.model, signal);
|
|
2379
2395
|
const modelInfo = this.normalizeModelInfo(registration, config.model, adapterCall.model);
|
|
2380
2396
|
const resolved = this.resolveCallWithInfo(config, modelInfo);
|
|
@@ -74,7 +74,7 @@ export const TYPERT = {
|
|
|
74
74
|
typeSymbol: '@deepseek-ai/dsh-llm#llm/discoverModels:result',
|
|
75
75
|
create: _deepseek_ai_dsh_llm_llm_discoverModels_result$schema,
|
|
76
76
|
},
|
|
77
|
-
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":
|
|
77
|
+
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":713,"column":9},
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
id: '@deepseek-ai/dsh-llm#llm/listConfigurableProviders',
|
|
@@ -89,7 +89,7 @@ export const TYPERT = {
|
|
|
89
89
|
typeSymbol: '@deepseek-ai/dsh-llm#llm/listConfigurableProviders:result',
|
|
90
90
|
create: _deepseek_ai_dsh_llm_llm_listConfigurableProviders_result$schema,
|
|
91
91
|
},
|
|
92
|
-
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":
|
|
92
|
+
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":625,"column":3},
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
id: '@deepseek-ai/dsh-llm#llm/listProviders',
|
|
@@ -104,7 +104,7 @@ export const TYPERT = {
|
|
|
104
104
|
typeSymbol: '@deepseek-ai/dsh-llm#llm/listProviders:result',
|
|
105
105
|
create: _deepseek_ai_dsh_llm_llm_listProviders_result$schema,
|
|
106
106
|
},
|
|
107
|
-
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":
|
|
107
|
+
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":553,"column":3},
|
|
108
108
|
},
|
|
109
109
|
],
|
|
110
110
|
model: {
|
|
@@ -317,7 +317,7 @@ export const TYPERT = {
|
|
|
317
317
|
},
|
|
318
318
|
{
|
|
319
319
|
"name": "GenerateOptions",
|
|
320
|
-
"declaration": "export interface GenerateOptions {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n messages: RequestMessage[];\n system?: string;\n tools?: ToolSchema[];\n toolHistory?: ToolHistory;\n temperature?: number;\n maxTokens?: number;\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n stop?: string[];\n signal?: AbortSignal;\n sessionId?: Branded<'SessionId'>;\n purpose?: 'compaction' | 'session-title';\n}"
|
|
320
|
+
"declaration": "export interface GenerateOptions {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n messages: RequestMessage[];\n system?: string;\n tools?: ToolSchema[];\n toolHistory?: ToolHistory;\n temperature?: number;\n maxTokens?: number;\n baseUrl?: string;\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n stop?: string[];\n signal?: AbortSignal;\n sessionId?: Branded<'SessionId'>;\n purpose?: 'compaction' | 'session-title';\n}"
|
|
321
321
|
},
|
|
322
322
|
{
|
|
323
323
|
"name": "GoalId",
|
|
@@ -349,7 +349,7 @@ export const TYPERT = {
|
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
351
|
"name": "LlmCallConfig",
|
|
352
|
-
"declaration": "export interface LlmCallConfig {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
352
|
+
"declaration": "export interface LlmCallConfig {\n baseUrl?: string;\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
353
353
|
},
|
|
354
354
|
{
|
|
355
355
|
"name": "LlmCallConfigAdapterDefaults",
|
|
@@ -393,7 +393,7 @@ export const TYPERT = {
|
|
|
393
393
|
},
|
|
394
394
|
{
|
|
395
395
|
"name": "LlmPromptModelConfig",
|
|
396
|
-
"declaration": "export interface LlmPromptModelConfig {\n readonly provider: string;\n readonly model: string;\n readonly protocol?: string;\n readonly apiKey?: string;\n readonly options: Readonly<Record<string, JsonValue>>;\n readonly protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
396
|
+
"declaration": "export interface LlmPromptModelConfig {\n readonly provider: string;\n readonly model: string;\n readonly protocol?: string;\n readonly baseUrl?: string;\n readonly apiKey?: string;\n readonly options: Readonly<Record<string, JsonValue>>;\n readonly protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
397
397
|
},
|
|
398
398
|
{
|
|
399
399
|
"name": "LlmProviderInfo",
|
|
@@ -71,7 +71,7 @@ export const TYPERT_REMOTE = {
|
|
|
71
71
|
typeSymbol: '@deepseek-ai/dsh-llm#llm/discoverModels:result',
|
|
72
72
|
create: _deepseek_ai_dsh_llm_llm_discoverModels_result$schema,
|
|
73
73
|
},
|
|
74
|
-
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":
|
|
74
|
+
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":713,"column":9},
|
|
75
75
|
},
|
|
76
76
|
{
|
|
77
77
|
id: '@deepseek-ai/dsh-llm#llm/listConfigurableProviders',
|
|
@@ -86,7 +86,7 @@ export const TYPERT_REMOTE = {
|
|
|
86
86
|
typeSymbol: '@deepseek-ai/dsh-llm#llm/listConfigurableProviders:result',
|
|
87
87
|
create: _deepseek_ai_dsh_llm_llm_listConfigurableProviders_result$schema,
|
|
88
88
|
},
|
|
89
|
-
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":
|
|
89
|
+
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":625,"column":3},
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
id: '@deepseek-ai/dsh-llm#llm/listProviders',
|
|
@@ -101,7 +101,7 @@ export const TYPERT_REMOTE = {
|
|
|
101
101
|
typeSymbol: '@deepseek-ai/dsh-llm#llm/listProviders:result',
|
|
102
102
|
create: _deepseek_ai_dsh_llm_llm_listProviders_result$schema,
|
|
103
103
|
},
|
|
104
|
-
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":
|
|
104
|
+
sourceLocation: {"file":"packages/llm/llm/src/index.ts","line":553,"column":3},
|
|
105
105
|
},
|
|
106
106
|
],
|
|
107
107
|
}
|
|
@@ -15,6 +15,8 @@ import type { ReasoningEffortId } from './brand.ts';
|
|
|
15
15
|
* per call.
|
|
16
16
|
*/
|
|
17
17
|
export interface LlmCallConfig {
|
|
18
|
+
/** HTTP(S) service URL supplied for this prompt; requires a prompt API key. */
|
|
19
|
+
baseUrl?: string;
|
|
18
20
|
provider: string;
|
|
19
21
|
model: string;
|
|
20
22
|
reasoningEffort?: ReasoningEffortId;
|
|
@@ -33,6 +35,8 @@ export interface LlmPromptModelConfig {
|
|
|
33
35
|
readonly provider: string;
|
|
34
36
|
readonly model: string;
|
|
35
37
|
readonly protocol?: string;
|
|
38
|
+
/** HTTP(S) service URL supplied for this prompt; requires a prompt API key. */
|
|
39
|
+
readonly baseUrl?: string;
|
|
36
40
|
/** Desktop-supplied API key for this prompt only. */
|
|
37
41
|
readonly apiKey?: string;
|
|
38
42
|
/** Common Runtime controls and generation fields for the selected protocol. */
|
|
@@ -24,6 +24,7 @@ export function callConfigEquals(a, b) {
|
|
|
24
24
|
|| a.maxTokens !== b.maxTokens
|
|
25
25
|
|| a.contextWindow !== b.contextWindow
|
|
26
26
|
|| a.protocol !== b.protocol
|
|
27
|
+
|| a.baseUrl !== b.baseUrl
|
|
27
28
|
|| !deepEqualJson(a.protocolOptions, b.protocolOptions))
|
|
28
29
|
return false;
|
|
29
30
|
if (a.stop === undefined || b.stop === undefined)
|
|
@@ -248,6 +248,8 @@ export class LlmAdapter {
|
|
|
248
248
|
* @param config - Common controls and protocol options for the registered route.
|
|
249
249
|
*/
|
|
250
250
|
validatePromptProtocol(config) {
|
|
251
|
+
if (config.baseUrl !== undefined)
|
|
252
|
+
throw new LlmError('baseUrl', 'UNSUPPORTED_OPTION');
|
|
251
253
|
if (config.protocol !== undefined)
|
|
252
254
|
throw new LlmError('protocol', 'UNSUPPORTED_OPTION');
|
|
253
255
|
const option = Object.keys(config.protocolOptions ?? {})[0];
|
|
@@ -752,6 +754,23 @@ let LlmRuntime = (() => {
|
|
|
752
754
|
throw new LlmError('apiKey', 'UNSUPPORTED_OPTION');
|
|
753
755
|
}
|
|
754
756
|
const config = { provider, model, ...protocol === undefined ? {} : { protocol } };
|
|
757
|
+
if (request.baseUrl !== undefined) {
|
|
758
|
+
let endpoint;
|
|
759
|
+
try {
|
|
760
|
+
endpoint = new URL(request.baseUrl);
|
|
761
|
+
}
|
|
762
|
+
catch (_invalidEndpoint) {
|
|
763
|
+
throw new LlmError('baseUrl', 'UNSUPPORTED_OPTION');
|
|
764
|
+
}
|
|
765
|
+
if (typeof request.baseUrl !== 'string' || request.baseUrl !== request.baseUrl.trim()
|
|
766
|
+
|| !['http:', 'https:'].includes(endpoint.protocol) || !endpoint.hostname
|
|
767
|
+
|| endpoint.username || endpoint.password || endpoint.search || endpoint.hash) {
|
|
768
|
+
throw new LlmError('baseUrl', 'UNSUPPORTED_OPTION');
|
|
769
|
+
}
|
|
770
|
+
if (request.apiKey === undefined)
|
|
771
|
+
throw new LlmError('apiKey', 'UNSUPPORTED_OPTION');
|
|
772
|
+
config.baseUrl = request.baseUrl;
|
|
773
|
+
}
|
|
755
774
|
const forwarded = new Map(Object.entries(protocolOptions ?? {}));
|
|
756
775
|
for (const [key, value] of Object.entries(options)) {
|
|
757
776
|
const invalid = () => new LlmError(`options.${key}`, 'UNSUPPORTED_OPTION');
|
|
@@ -831,6 +850,11 @@ let LlmRuntime = (() => {
|
|
|
831
850
|
if (promptApiKey !== undefined && !registration.adapter.supportsPromptApiKey(config.provider, config.model)) {
|
|
832
851
|
throw new LlmError('This model route cannot use a prompt API key', 'UNSUPPORTED_OPTION');
|
|
833
852
|
}
|
|
853
|
+
if (config.baseUrl !== undefined) {
|
|
854
|
+
if (promptApiKey === undefined)
|
|
855
|
+
throw new LlmError('apiKey', 'UNSUPPORTED_OPTION');
|
|
856
|
+
registration.adapter.validatePromptProtocol(config);
|
|
857
|
+
}
|
|
834
858
|
const adapterCall = await registration.adapter.prepareCall(config.provider, config.model, signal);
|
|
835
859
|
const modelInfo = this.normalizeModelInfo(registration, config.model, adapterCall.model);
|
|
836
860
|
const resolved = this.resolveCallWithInfo(config, modelInfo);
|
|
@@ -511,6 +511,8 @@ export interface GenerateOptions {
|
|
|
511
511
|
toolHistory?: ToolHistory;
|
|
512
512
|
temperature?: number;
|
|
513
513
|
maxTokens?: number;
|
|
514
|
+
/** HTTP(S) service URL supplied for this prompt; requires a prompt API key. */
|
|
515
|
+
baseUrl?: string;
|
|
514
516
|
/** Context budget supplied by the current prompt. */
|
|
515
517
|
contextWindow?: number;
|
|
516
518
|
/** Optional protocol assertion for the bound model route. */
|
|
@@ -1708,6 +1708,13 @@ var DeepSeekProtocolAdapter = class extends LlmAdapter {
|
|
|
1708
1708
|
};
|
|
1709
1709
|
try {
|
|
1710
1710
|
this.validatePromptProtocol(options);
|
|
1711
|
+
if (options.baseUrl !== void 0) {
|
|
1712
|
+
if (promptApiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
1713
|
+
connection = {
|
|
1714
|
+
...connection,
|
|
1715
|
+
baseURL: options.baseUrl
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1711
1718
|
const consumer = new AbortController();
|
|
1712
1719
|
const watchdog = __addDisposableResource(env_1, idleWatchdog(options.signal === void 0 ? consumer.signal : AbortSignal.any([consumer.signal, options.signal]), connection.streamIdleTimeoutMs, "MESSAGES_IDLE"), false);
|
|
1713
1720
|
const iterator = this.request(options, connection, watchdog.signal, () => {
|
|
@@ -1604,6 +1604,12 @@ function record(value) {
|
|
|
1604
1604
|
* @param protocol - Protocol of the resolved pi-ai model.
|
|
1605
1605
|
*/
|
|
1606
1606
|
function validatePiPromptOptions(config, protocol) {
|
|
1607
|
+
if (config.baseUrl !== void 0 && ![
|
|
1608
|
+
"openai-completions",
|
|
1609
|
+
"openai-responses",
|
|
1610
|
+
"anthropic-messages",
|
|
1611
|
+
"google-generative-ai"
|
|
1612
|
+
].includes(protocol)) invalid("baseUrl");
|
|
1607
1613
|
if (config.protocol !== void 0 && config.protocol !== protocol) invalid("protocol");
|
|
1608
1614
|
const options = config.protocolOptions;
|
|
1609
1615
|
const first = Object.keys(options ?? {})[0];
|
|
@@ -1932,7 +1938,7 @@ var PiAiAdapter = class extends LlmAdapter {
|
|
|
1932
1938
|
}
|
|
1933
1939
|
supportsPromptApiKey(provider, model) {
|
|
1934
1940
|
const api = this.modelOf(this.current(), provider, model).api;
|
|
1935
|
-
return api === "openai-completions" || api === "anthropic-messages" || api === "openai-responses";
|
|
1941
|
+
return api === "openai-completions" || api === "anthropic-messages" || api === "openai-responses" || api === "google-generative-ai";
|
|
1936
1942
|
}
|
|
1937
1943
|
validatePromptProtocol(config) {
|
|
1938
1944
|
validatePiPromptOptions(config, this.modelOf(this.current(), config.provider, config.model).api);
|
|
@@ -1958,12 +1964,17 @@ var PiAiAdapter = class extends LlmAdapter {
|
|
|
1958
1964
|
const profile = this.profileOf(snapshot, options.provider);
|
|
1959
1965
|
const resolvedModel = this.modelOf(snapshot, options.provider, options.model);
|
|
1960
1966
|
validatePiPromptOptions(options, resolvedModel.api);
|
|
1961
|
-
|
|
1967
|
+
if (options.baseUrl !== void 0 && promptApiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
1968
|
+
const model = options.baseUrl === void 0 && options.contextWindow === void 0 ? resolvedModel : {
|
|
1962
1969
|
...resolvedModel,
|
|
1963
|
-
contextWindow: options.contextWindow
|
|
1970
|
+
...options.contextWindow === void 0 ? {} : { contextWindow: options.contextWindow },
|
|
1971
|
+
...options.baseUrl === void 0 ? {} : {
|
|
1972
|
+
baseUrl: options.baseUrl,
|
|
1973
|
+
headers: {}
|
|
1974
|
+
}
|
|
1964
1975
|
};
|
|
1965
1976
|
const protocolOptions = options.protocolOptions;
|
|
1966
|
-
const headers = promptApiKey === void 0 ? profile.headers : Object.fromEntries(Object.entries(profile.headers ?? {}).filter(([name]) => !/^(?:authorization|x-api-key|api-key)$/iu.test(name)));
|
|
1977
|
+
const headers = options.baseUrl !== void 0 ? void 0 : promptApiKey === void 0 ? profile.headers : Object.fromEntries(Object.entries(profile.headers ?? {}).filter(([name]) => !/^(?:authorization|x-api-key|api-key)$/iu.test(name)));
|
|
1967
1978
|
const reasoning = resolveReasoningLevel(model, options.reasoningEffort ?? profile.reasoning);
|
|
1968
1979
|
const apiKey = promptApiKey ?? await this.config.resolveApiKey(options.provider, profile);
|
|
1969
1980
|
const consumer = new AbortController();
|
|
@@ -328,7 +328,7 @@ export const TYPERT = {
|
|
|
328
328
|
},
|
|
329
329
|
{
|
|
330
330
|
"name": "LlmCallConfig",
|
|
331
|
-
"declaration": "export interface LlmCallConfig {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
331
|
+
"declaration": "export interface LlmCallConfig {\n baseUrl?: string;\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n contextWindow?: number;\n protocol?: string;\n protocolOptions?: Readonly<Record<string, JsonValue>>;\n}"
|
|
332
332
|
},
|
|
333
333
|
{
|
|
334
334
|
"name": "LlmCallConfigAdapterDefaults",
|
|
@@ -472,7 +472,7 @@ export const TYPERT = {
|
|
|
472
472
|
},
|
|
473
473
|
{
|
|
474
474
|
"name": "Session",
|
|
475
|
-
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
475
|
+
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n get appId(): string | undefined;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
476
476
|
},
|
|
477
477
|
{
|
|
478
478
|
"name": "SessionEvent",
|
|
@@ -480,7 +480,7 @@ export const TYPERT = {
|
|
|
480
480
|
},
|
|
481
481
|
{
|
|
482
482
|
"name": "SessionEventMap",
|
|
483
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'schedule/change': ScheduleChange;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
483
|
+
"declaration": "export interface SessionEventMap {\n 'session/application': { appId: string; };\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'agent-preset/selected': { agentPreset: string; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'model/selection': ModelSelection;\n 'subagent/descriptor': SubagentDescriptorData;\n 'permission/preset': { preset: string; };\n 'subagent/catalog': SubagentCatalogEvent;\n 'feedback/record': FeedbackRecord;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'schedule/change': ScheduleChange;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n}"
|
|
484
484
|
},
|
|
485
485
|
{
|
|
486
486
|
"name": "SessionEventType",
|
|
@@ -478,7 +478,7 @@ function ReasoningEffortId(id) {
|
|
|
478
478
|
* @returns whether every field (including the `stop` list, element-wise) matches.
|
|
479
479
|
*/
|
|
480
480
|
function callConfigEquals(a, b) {
|
|
481
|
-
if (a.provider !== b.provider || a.model !== b.model || a.reasoningEffort !== b.reasoningEffort || a.temperature !== b.temperature || a.maxTokens !== b.maxTokens || a.contextWindow !== b.contextWindow || a.protocol !== b.protocol || !deepEqualJson(a.protocolOptions, b.protocolOptions)) return false;
|
|
481
|
+
if (a.provider !== b.provider || a.model !== b.model || a.reasoningEffort !== b.reasoningEffort || a.temperature !== b.temperature || a.maxTokens !== b.maxTokens || a.contextWindow !== b.contextWindow || a.protocol !== b.protocol || a.baseUrl !== b.baseUrl || !deepEqualJson(a.protocolOptions, b.protocolOptions)) return false;
|
|
482
482
|
if (a.stop === void 0 || b.stop === void 0) return a.stop === b.stop;
|
|
483
483
|
return a.stop.length === b.stop.length && a.stop.every((s, i) => s === b.stop?.[i]);
|
|
484
484
|
}
|
|
@@ -1369,6 +1369,17 @@ function validatePromptProtocolOptions(options) {
|
|
|
1369
1369
|
model,
|
|
1370
1370
|
...protocol === void 0 ? {} : { protocol }
|
|
1371
1371
|
};
|
|
1372
|
+
if (request.baseUrl !== void 0) {
|
|
1373
|
+
let endpoint;
|
|
1374
|
+
try {
|
|
1375
|
+
endpoint = new URL(request.baseUrl);
|
|
1376
|
+
} catch (_invalidEndpoint) {
|
|
1377
|
+
throw new LlmError("baseUrl", "UNSUPPORTED_OPTION");
|
|
1378
|
+
}
|
|
1379
|
+
if (typeof request.baseUrl !== "string" || request.baseUrl !== request.baseUrl.trim() || !["http:", "https:"].includes(endpoint.protocol) || !endpoint.hostname || endpoint.username || endpoint.password || endpoint.search || endpoint.hash) throw new LlmError("baseUrl", "UNSUPPORTED_OPTION");
|
|
1380
|
+
if (request.apiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
1381
|
+
config.baseUrl = request.baseUrl;
|
|
1382
|
+
}
|
|
1372
1383
|
const forwarded = new Map(Object.entries(protocolOptions ?? {}));
|
|
1373
1384
|
for (const [key, value] of Object.entries(options)) {
|
|
1374
1385
|
const invalid = () => new LlmError(`options.${key}`, "UNSUPPORTED_OPTION");
|
|
@@ -1436,6 +1447,10 @@ function validatePromptProtocolOptions(options) {
|
|
|
1436
1447
|
async prepareCall(config, signal, promptApiKey) {
|
|
1437
1448
|
const registration = this.registration(config.provider);
|
|
1438
1449
|
if (promptApiKey !== void 0 && !registration.adapter.supportsPromptApiKey(config.provider, config.model)) throw new LlmError("This model route cannot use a prompt API key", "UNSUPPORTED_OPTION");
|
|
1450
|
+
if (config.baseUrl !== void 0) {
|
|
1451
|
+
if (promptApiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
1452
|
+
registration.adapter.validatePromptProtocol(config);
|
|
1453
|
+
}
|
|
1439
1454
|
const adapterCall = await registration.adapter.prepareCall(config.provider, config.model, signal);
|
|
1440
1455
|
const modelInfo = this.normalizeModelInfo(registration, config.model, adapterCall.model);
|
|
1441
1456
|
const resolved = this.resolveCallWithInfo(config, modelInfo);
|
|
@@ -109,6 +109,7 @@ const KNOWN_SESSION_EVENT_TYPES = new Set([
|
|
|
109
109
|
"sandbox/mode",
|
|
110
110
|
"schedule/change",
|
|
111
111
|
"session-log-deepseek/delivery-accepted",
|
|
112
|
+
"session/application",
|
|
112
113
|
"session/end-seed",
|
|
113
114
|
"session/title",
|
|
114
115
|
"session/title-llm-request",
|
|
@@ -1312,6 +1313,10 @@ var Session = class Session {
|
|
|
1312
1313
|
if (seed !== void 0 && mode === "snapshot" && this.header.isSeeded && !markedSeed) this.append("session/end-seed", { inherited: true });
|
|
1313
1314
|
else if (seed !== void 0 && !(mode === "snapshot" && this.header.isSeeded) && this.log.at(-1)?.type !== "session/end-seed") this.append("session/end-seed", {});
|
|
1314
1315
|
}
|
|
1316
|
+
/** Application that created the Session, if the log records one. */
|
|
1317
|
+
get appId() {
|
|
1318
|
+
return this.log.find((event) => event.type === "session/application")?.data.appId;
|
|
1319
|
+
}
|
|
1315
1320
|
/** Cached immutable full snapshot of the private append-only log. */
|
|
1316
1321
|
eventsSnapshot;
|
|
1317
1322
|
/**
|
|
@@ -1416,6 +1421,7 @@ var Session = class Session {
|
|
|
1416
1421
|
seq: SessionSeq(this.log.length),
|
|
1417
1422
|
time: Date.now(),
|
|
1418
1423
|
data: dataSnapshot,
|
|
1424
|
+
...type === "session/application" ? { ignorable: true } : {},
|
|
1419
1425
|
...surfaceMetadataSnapshot
|
|
1420
1426
|
});
|
|
1421
1427
|
validateSessionEventData(event, `session event "${type}" at seq ${event.seq}`);
|
|
@@ -1668,7 +1674,12 @@ var SessionStore = class extends Service {
|
|
|
1668
1674
|
...meta?.delegationDepth === void 0 ? {} : { delegationDepth: meta.delegationDepth },
|
|
1669
1675
|
...meta?.agentPreset === void 0 ? {} : { agentPreset: meta.agentPreset }
|
|
1670
1676
|
};
|
|
1671
|
-
|
|
1677
|
+
const session = Session.create(sessionId, seed, header, options?.inheritedEventCount, this.projections);
|
|
1678
|
+
if (meta?.appId !== void 0 && session.appId === void 0) {
|
|
1679
|
+
if (typeof meta.appId !== "string" || !/^[\x21-\x7e]{1,128}$/u.test(meta.appId)) throw new Error("session appId must contain 1 to 128 visible ASCII characters");
|
|
1680
|
+
session.append("session/application", { appId: meta.appId });
|
|
1681
|
+
}
|
|
1682
|
+
return session;
|
|
1672
1683
|
}
|
|
1673
1684
|
/**
|
|
1674
1685
|
* Enter a {@link prepare}d session into the store: install the module-private
|
|
@@ -191,6 +191,8 @@ export declare class Session {
|
|
|
191
191
|
*/
|
|
192
192
|
static fromRestore(id: SessionId, seed: readonly SessionEvent[], header: SessionHeader, inheritedEventCount: SessionLogOffset, eventState: SessionSeedEventState, projections?: readonly SessionMessageProjection[]): Session;
|
|
193
193
|
private constructor();
|
|
194
|
+
/** Application that created the Session, if the log records one. */
|
|
195
|
+
get appId(): string | undefined;
|
|
194
196
|
/** Cached immutable full snapshot of the private append-only log. */
|
|
195
197
|
private eventsSnapshot;
|
|
196
198
|
/**
|
|
@@ -476,6 +476,10 @@ export class Session {
|
|
|
476
476
|
this.append('session/end-seed', {});
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
|
+
/** Application that created the Session, if the log records one. */
|
|
480
|
+
get appId() {
|
|
481
|
+
return this.log.find(event => event.type === 'session/application')?.data.appId;
|
|
482
|
+
}
|
|
479
483
|
/** Cached immutable full snapshot of the private append-only log. */
|
|
480
484
|
eventsSnapshot;
|
|
481
485
|
/**
|
|
@@ -587,6 +591,7 @@ export class Session {
|
|
|
587
591
|
seq: SessionSeq(this.log.length),
|
|
588
592
|
time: Date.now(),
|
|
589
593
|
data: dataSnapshot,
|
|
594
|
+
...(type === 'session/application' ? { ignorable: true } : {}),
|
|
590
595
|
...surfaceMetadataSnapshot,
|
|
591
596
|
});
|
|
592
597
|
validateSessionEventData(event, `session event "${type}" at seq ${event.seq}`);
|
|
@@ -869,7 +874,14 @@ export class SessionStore extends Service {
|
|
|
869
874
|
...meta?.delegationDepth === undefined ? {} : { delegationDepth: meta.delegationDepth },
|
|
870
875
|
...meta?.agentPreset === undefined ? {} : { agentPreset: meta.agentPreset },
|
|
871
876
|
};
|
|
872
|
-
|
|
877
|
+
const session = Session.create(sessionId, seed, header, options?.inheritedEventCount, this.projections);
|
|
878
|
+
if (meta?.appId !== undefined && session.appId === undefined) {
|
|
879
|
+
if (typeof meta.appId !== 'string' || !/^[\x21-\x7e]{1,128}$/u.test(meta.appId)) {
|
|
880
|
+
throw new Error('session appId must contain 1 to 128 visible ASCII characters');
|
|
881
|
+
}
|
|
882
|
+
session.append('session/application', { appId: meta.appId });
|
|
883
|
+
}
|
|
884
|
+
return session;
|
|
873
885
|
}
|
|
874
886
|
/**
|
|
875
887
|
* Enter a {@link prepare}d session into the store: install the module-private
|
|
@@ -113,6 +113,7 @@ export interface CreateSessionOptions {
|
|
|
113
113
|
*/
|
|
114
114
|
readonly meta?: {
|
|
115
115
|
readonly cwd?: string;
|
|
116
|
+
readonly appId?: string;
|
|
116
117
|
readonly parentSession?: SessionId;
|
|
117
118
|
readonly createdAt?: number;
|
|
118
119
|
readonly isSeeded?: boolean;
|
|
@@ -255,6 +256,10 @@ export type RequestHeaderReason = 'initial' | 'resume' | 'change' | 'series';
|
|
|
255
256
|
* compact raw streams so persistence stores one durable settlement per attempt.
|
|
256
257
|
*/
|
|
257
258
|
export interface SessionEventMap {
|
|
259
|
+
/** Informational application identity written when the Session is created. */
|
|
260
|
+
'session/application': {
|
|
261
|
+
appId: string;
|
|
262
|
+
};
|
|
258
263
|
/**
|
|
259
264
|
* Opens turn `turn` before the loop claims queued input or runs pre-step.
|
|
260
265
|
* Rejection, empty input, cancellation, or failure may close it with no
|
|
@@ -2534,6 +2534,7 @@ const KNOWN_SESSION_EVENT_TYPES = new Set([
|
|
|
2534
2534
|
"sandbox/mode",
|
|
2535
2535
|
"schedule/change",
|
|
2536
2536
|
"session-log-deepseek/delivery-accepted",
|
|
2537
|
+
"session/application",
|
|
2537
2538
|
"session/end-seed",
|
|
2538
2539
|
"session/title",
|
|
2539
2540
|
"session/title-llm-request",
|
|
@@ -3976,7 +3977,7 @@ function ReasoningEffortId(id) {
|
|
|
3976
3977
|
* @returns whether every field (including the `stop` list, element-wise) matches.
|
|
3977
3978
|
*/
|
|
3978
3979
|
function callConfigEquals(a, b) {
|
|
3979
|
-
if (a.provider !== b.provider || a.model !== b.model || a.reasoningEffort !== b.reasoningEffort || a.temperature !== b.temperature || a.maxTokens !== b.maxTokens || a.contextWindow !== b.contextWindow || a.protocol !== b.protocol || !deepEqualJson(a.protocolOptions, b.protocolOptions)) return false;
|
|
3980
|
+
if (a.provider !== b.provider || a.model !== b.model || a.reasoningEffort !== b.reasoningEffort || a.temperature !== b.temperature || a.maxTokens !== b.maxTokens || a.contextWindow !== b.contextWindow || a.protocol !== b.protocol || a.baseUrl !== b.baseUrl || !deepEqualJson(a.protocolOptions, b.protocolOptions)) return false;
|
|
3980
3981
|
if (a.stop === void 0 || b.stop === void 0) return a.stop === b.stop;
|
|
3981
3982
|
return a.stop.length === b.stop.length && a.stop.every((s, i) => s === b.stop?.[i]);
|
|
3982
3983
|
}
|
|
@@ -5315,6 +5316,17 @@ function validatePromptProtocolOptions(options) {
|
|
|
5315
5316
|
model,
|
|
5316
5317
|
...protocol === void 0 ? {} : { protocol }
|
|
5317
5318
|
};
|
|
5319
|
+
if (request.baseUrl !== void 0) {
|
|
5320
|
+
let endpoint;
|
|
5321
|
+
try {
|
|
5322
|
+
endpoint = new URL(request.baseUrl);
|
|
5323
|
+
} catch (_invalidEndpoint) {
|
|
5324
|
+
throw new LlmError("baseUrl", "UNSUPPORTED_OPTION");
|
|
5325
|
+
}
|
|
5326
|
+
if (typeof request.baseUrl !== "string" || request.baseUrl !== request.baseUrl.trim() || !["http:", "https:"].includes(endpoint.protocol) || !endpoint.hostname || endpoint.username || endpoint.password || endpoint.search || endpoint.hash) throw new LlmError("baseUrl", "UNSUPPORTED_OPTION");
|
|
5327
|
+
if (request.apiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
5328
|
+
config.baseUrl = request.baseUrl;
|
|
5329
|
+
}
|
|
5318
5330
|
const forwarded = new Map(Object.entries(protocolOptions ?? {}));
|
|
5319
5331
|
for (const [key, value] of Object.entries(options)) {
|
|
5320
5332
|
const invalid = () => new LlmError(`options.${key}`, "UNSUPPORTED_OPTION");
|
|
@@ -5382,6 +5394,10 @@ function validatePromptProtocolOptions(options) {
|
|
|
5382
5394
|
async prepareCall(config, signal, promptApiKey) {
|
|
5383
5395
|
const registration = this.registration(config.provider);
|
|
5384
5396
|
if (promptApiKey !== void 0 && !registration.adapter.supportsPromptApiKey(config.provider, config.model)) throw new LlmError("This model route cannot use a prompt API key", "UNSUPPORTED_OPTION");
|
|
5397
|
+
if (config.baseUrl !== void 0) {
|
|
5398
|
+
if (promptApiKey === void 0) throw new LlmError("apiKey", "UNSUPPORTED_OPTION");
|
|
5399
|
+
registration.adapter.validatePromptProtocol(config);
|
|
5400
|
+
}
|
|
5385
5401
|
const adapterCall = await registration.adapter.prepareCall(config.provider, config.model, signal);
|
|
5386
5402
|
const modelInfo = this.normalizeModelInfo(registration, config.model, adapterCall.model);
|
|
5387
5403
|
const resolved = this.resolveCallWithInfo(config, modelInfo);
|
|
@@ -6004,6 +6020,10 @@ var Session = class Session {
|
|
|
6004
6020
|
if (seed !== void 0 && mode === "snapshot" && this.header.isSeeded && !markedSeed) this.append("session/end-seed", { inherited: true });
|
|
6005
6021
|
else if (seed !== void 0 && !(mode === "snapshot" && this.header.isSeeded) && this.log.at(-1)?.type !== "session/end-seed") this.append("session/end-seed", {});
|
|
6006
6022
|
}
|
|
6023
|
+
/** Application that created the Session, if the log records one. */
|
|
6024
|
+
get appId() {
|
|
6025
|
+
return this.log.find((event) => event.type === "session/application")?.data.appId;
|
|
6026
|
+
}
|
|
6007
6027
|
/** Cached immutable full snapshot of the private append-only log. */
|
|
6008
6028
|
eventsSnapshot;
|
|
6009
6029
|
/**
|
|
@@ -6108,6 +6128,7 @@ var Session = class Session {
|
|
|
6108
6128
|
seq: SessionSeq(this.log.length),
|
|
6109
6129
|
time: Date.now(),
|
|
6110
6130
|
data: dataSnapshot,
|
|
6131
|
+
...type === "session/application" ? { ignorable: true } : {},
|
|
6111
6132
|
...surfaceMetadataSnapshot
|
|
6112
6133
|
});
|
|
6113
6134
|
validateSessionEventData(event, `session event "${type}" at seq ${event.seq}`);
|