@chatcode/chatcode-cli 3.0.6-rc.2 → 3.0.6-rc.4

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.
Files changed (58) hide show
  1. package/package.json +15 -15
  2. package/runtime/manifest.json +2 -2
  3. package/runtime/node_modules/@chatcode/runtime-client/README.md +13 -10
  4. package/runtime/node_modules/@chatcode/runtime-client/desktop-history.mjs +49 -48
  5. package/runtime/node_modules/@chatcode/runtime-client/index.d.ts +9 -15
  6. package/runtime/node_modules/@chatcode/runtime-client/local-platform.mjs +81 -0
  7. package/runtime/node_modules/@chatcode/runtime-client/model-preferences.mjs +7 -12
  8. package/runtime/node_modules/@chatcode/runtime-client/package.json +4 -3
  9. package/runtime/node_modules/@chatcode/runtime-client/runtime-connector.mjs +27 -26
  10. package/runtime/node_modules/@chatcode/runtime-client/session-browser.mjs +1 -0
  11. package/runtime/node_modules/@deepseek-ai/dsh-agent-loop/lib/index.js +1 -1
  12. package/runtime/node_modules/@deepseek-ai/dsh-agent-preset-registry/lib/typert.host.js +3 -3
  13. package/runtime/node_modules/@deepseek-ai/dsh-api-remotes/lib/client.js +14 -4
  14. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/client.js +1 -0
  15. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/index.js +23 -10
  16. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.host.js +23 -13
  17. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.remote-client.d.ts +2 -2
  18. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/typert.remote-client.js +10 -0
  19. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.d.ts +2 -1
  20. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/agent.js +5 -3
  21. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/commands.js +8 -3
  22. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.d.ts +1 -0
  23. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/index.js +1 -1
  24. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/list.js +7 -3
  25. package/runtime/node_modules/@deepseek-ai/dsh-api-session-controller/lib/types/types.d.ts +9 -0
  26. package/runtime/node_modules/@deepseek-ai/dsh-api-terminal-controller/lib/typert.host.js +3 -3
  27. package/runtime/node_modules/@deepseek-ai/dsh-client-file-upload/lib/typert.host.js +3 -3
  28. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/client.js +2 -2
  29. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-account/lib/types/index.d.ts +2 -2
  30. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-settings-general/lib/client.js +1 -1
  31. package/runtime/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
  32. package/runtime/node_modules/@deepseek-ai/dsh-commands/lib/typert.host.js +3 -3
  33. package/runtime/node_modules/@deepseek-ai/dsh-cordis-host-runner/lib/typert.host.js +6 -6
  34. package/runtime/node_modules/@deepseek-ai/dsh-goal/lib/typert.host.js +3 -3
  35. package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/index.js +17 -1
  36. package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/typert.host.js +6 -6
  37. package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/typert.remote-client.js +3 -3
  38. package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/call-config.d.ts +4 -0
  39. package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/call-config.js +1 -0
  40. package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/index.js +24 -0
  41. package/runtime/node_modules/@deepseek-ai/dsh-llm/lib/types/types.d.ts +2 -0
  42. package/runtime/node_modules/@deepseek-ai/dsh-llm-deepseek/lib/index.js +7 -0
  43. package/runtime/node_modules/@deepseek-ai/dsh-llm-pi-ai/lib/index.js +15 -4
  44. package/runtime/node_modules/@deepseek-ai/dsh-permission-presets/lib/typert.host.js +3 -3
  45. package/runtime/node_modules/@deepseek-ai/dsh-repeat-tool-reminder/lib/index.js +16 -1
  46. package/runtime/node_modules/@deepseek-ai/dsh-session/lib/index.js +12 -1
  47. package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/index.d.ts +2 -0
  48. package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/index.js +13 -1
  49. package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/known-event-types.js +1 -0
  50. package/runtime/node_modules/@deepseek-ai/dsh-session/lib/types/types.d.ts +5 -0
  51. package/runtime/node_modules/@deepseek-ai/dsh-session-persistence-jsonl/lib/worker.cjs +22 -1
  52. package/runtime/node_modules/@deepseek-ai/dsh-session-reference/lib/typert.host.js +3 -3
  53. package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/index.js +1 -0
  54. package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/typert.host.js +3 -3
  55. package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/types/child-agent.js +1 -0
  56. package/runtime/node_modules/@deepseek-ai/dsh-subagent/lib/types/control.d.ts +1 -1
  57. package/runtime/node_modules/@deepseek-ai/dsh-tmux-context/lib/index.js +16 -1
  58. package/runtime/node_modules/@deepseek-ai/dsh-tool-cordis/lib/types/api-catalog.js +83 -20
@@ -26,7 +26,6 @@ function redact(text) { return text.replace(/([?&]token=)[^\s&]+/gu, '$1[redacte
26
26
 
27
27
  const APP_ID_HEADER = 'x-chatcode-app-id'
28
28
  const APP_SECRET_HEADER = 'x-chatcode-app-secret'
29
- const APP_AUTHENTICATED_HEADER = 'x-chatcode-app-authenticated'
30
29
 
31
30
  /** Owns one public-profile Runtime and one multiplexed WebSocket. */
32
31
  export class RuntimeConnector {
@@ -58,14 +57,12 @@ export class RuntimeConnector {
58
57
  throw new Error('nodePath, launcherPath and home are required')
59
58
  }
60
59
  const { appCredentials, ...launchOptions } = options
61
- if (appCredentials !== undefined) {
62
- const { appId, secret } = appCredentials ?? {}
63
- if (typeof appId !== 'string' || !appId || appId.length > 128 || /[^\x21-\x7e]/u.test(appId)
64
- || typeof secret !== 'string' || !secret || secret.length > 1024 || /[^\x21-\x7e]/u.test(secret)) {
65
- throw failure('Application credentials require a valid appId and secret', 'runtime/app-credentials')
66
- }
67
- this.#appCredentials = { appId, secret }
60
+ const { appId, secret } = appCredentials ?? {}
61
+ if (typeof appId !== 'string' || !appId || appId.length > 128 || /[^\x21-\x7e]/u.test(appId)
62
+ || typeof secret !== 'string' || !secret || secret.length > 1024 || /[^\x21-\x7e]/u.test(secret)) {
63
+ throw failure('Application credentials require a valid appId and secret', 'runtime/app-credentials')
68
64
  }
65
+ this.#appCredentials = { appId, secret }
69
66
  this.options = {
70
67
  startupTimeoutMs: 20000, requestTimeoutMs: 10000,
71
68
  shutdownTimeoutMs: 10000, socketTimeoutMs: 10000, childReadyTimeoutMs: 1000,
@@ -137,8 +134,11 @@ export class RuntimeConnector {
137
134
  ready.reject(error)
138
135
  if (!this.#closed) {
139
136
  this.#failed = error
140
- this.#state('failed', error)
137
+ const followers = [...this.#followers.entries()]
141
138
  this.#socket?.terminate()
139
+ for (const [streamId] of followers) this.#disposeFollower(streamId, error)
140
+ this.#state('failed', error)
141
+ for (const [, follower] of followers) this.#notify(follower.onFailure, error)
142
142
  }
143
143
  resolveExit({ code, signal })
144
144
  }))
@@ -146,17 +146,14 @@ export class RuntimeConnector {
146
146
  if (launchURL.protocol !== 'http:' || launchURL.hostname !== '127.0.0.1') {
147
147
  throw new Error('Runtime reported an unexpected non-loopback URL')
148
148
  }
149
- const auth = await this.#http(launchURL, undefined, credentials && {
149
+ const auth = await this.#http(launchURL, undefined, {
150
150
  [APP_ID_HEADER]: credentials.appId,
151
151
  [APP_SECRET_HEADER]: credentials.secret,
152
152
  })
153
- if (credentials && (auth.status === 401 || auth.status === 403)) {
153
+ if (auth.status === 401 || auth.status === 403) {
154
154
  throw failure('Runtime rejected application authentication', 'runtime/app-auth')
155
155
  }
156
156
  if (auth.status !== 303 || !auth.headers['set-cookie']?.length) throw failure('Host authentication failed', 'runtime/auth')
157
- if (credentials && auth.headers[APP_AUTHENTICATED_HEADER] !== '1') {
158
- throw failure('Runtime did not confirm application authentication', 'runtime/app-auth-unsupported')
159
- }
160
157
  this.#cookie = auth.headers['set-cookie'].map(value => value.split(';')[0]).join('; ')
161
158
  this.#origin = launchURL.origin
162
159
  if (this.#closed || child.exitCode !== null || child.signalCode !== null) throw new Error('Runtime stopped during startup')
@@ -221,15 +218,6 @@ export class RuntimeConnector {
221
218
  return message.result.value
222
219
  }
223
220
 
224
- /**
225
- * With sessionId, restore that Session instead of minting a new one.
226
- * @param request - Absolute workspace and optional persisted Session identity.
227
- * @returns The Runtime-owned Session identity.
228
- */
229
- /** Read safe model names and routes from the live Runtime registry. */
230
- modelCatalog(options = {}) { return this.#rpcArgs(options.refresh ? 'session/refreshModelCatalog' : 'session/modelCatalog', {}) }
231
- /** Select an available route for the next request on the same Session. */
232
- selectModel(request) { return this.#rpc('session/selectModel', request) }
233
221
  permissionCatalog() { return this.#rpcArgs('permissionPresets/catalog', {}) }
234
222
  getWorkspaceAccess(sessionId) { return this.#rpc('session/workspaceAccess', { sessionId }) }
235
223
  setWorkspaceAccess(request) { return this.#rpc('session/setWorkspaceAccess', request) }
@@ -292,10 +280,20 @@ export class RuntimeConnector {
292
280
  }
293
281
  return this.#rpc('session/create', { ...location, resumeOnly: true })
294
282
  }
295
- createSession(request) { return this.#rpc('session/create', request) }
283
+ /**
284
+ * Create a Session with the Connector's application identity or adopt an existing identity.
285
+ * @param request - Workspace and optional persisted Session identity.
286
+ * @returns The Runtime-owned Session identity and its original application ID.
287
+ */
288
+ createSession(request) {
289
+ return this.#rpc('session/create', {
290
+ ...request,
291
+ appId: this.#appCredentials.appId,
292
+ })
293
+ }
296
294
  /**
297
295
  * Confirm this Runtime supports request-local prompt model configuration.
298
- * @param options - require support for prompt API keys or unified model options.
296
+ * @param options - require support for prompt API keys, service URLs, or unified model options.
299
297
  * @returns A promise that rejects when the requested capability is unavailable.
300
298
  */
301
299
  async assertPromptModelConfig(options = {}) {
@@ -312,6 +310,9 @@ export class RuntimeConnector {
312
310
  if (options.apiKey && capability.requestApiKey !== true) {
313
311
  throw failure('Runtime does not support API keys supplied with prompts', 'runtime/model-config-unsupported')
314
312
  }
313
+ if (options.baseUrl && capability.requestBaseUrl !== true) {
314
+ throw failure('Runtime does not support service URLs supplied with prompts', 'runtime/model-config-unsupported')
315
+ }
315
316
  if (options.unifiedOptions && capability.unifiedOptions !== true) {
316
317
  throw failure('Runtime does not support unified prompt model options', 'runtime/model-config-unsupported')
317
318
  }
@@ -348,7 +349,7 @@ export class RuntimeConnector {
348
349
  return existing.promise
349
350
  }
350
351
  const submit = () => this.#rpc('session/prompt', wire)
351
- const promise = (configured ? this.assertPromptModelConfig({ apiKey: wire.modelConfig.apiKey !== undefined }).then(submit) : submit()).finally(() => this.#prompts.delete(key))
352
+ const promise = (configured ? this.assertPromptModelConfig({ apiKey: wire.modelConfig.apiKey !== undefined, baseUrl: wire.modelConfig.baseUrl !== undefined }).then(submit) : submit()).finally(() => this.#prompts.delete(key))
352
353
  this.#prompts.set(key, { payload, wire, promise })
353
354
  return promise
354
355
  }
@@ -58,6 +58,7 @@ export function readSessionSummaries(value) {
58
58
  running: row.running,
59
59
  blank: row.blank,
60
60
  ...(row.cwd === undefined ? {} : { cwd: string(row.cwd) }),
61
+ ...(row.appId === undefined ? {} : { appId: string(row.appId) }),
61
62
  ...(row.origin === undefined ? {} : { origin: row.origin }),
62
63
  ...(row.parentSessionId === undefined ? {} : { parentSessionId: string(row.parentSessionId) })
63
64
  }
@@ -1222,7 +1222,7 @@ var ReactLoopAgent = class {
1222
1222
  }, () => Promise.resolve(seedConfig));
1223
1223
  signal.throwIfAborted();
1224
1224
  if (!proposedConfig.provider || !proposedConfig.model) throw new Error(`agent "${this.id}" has no provider/model: set AgentOptions.provider and AgentOptions.model or supply both via the agent/request waterfall`);
1225
- if (promptApiKey !== void 0 && (proposedConfig.provider !== promptConfig?.provider || proposedConfig.model !== promptConfig.model)) throw new LlmError("A prompt API key can only be used with its submitted model route", "INVALID_REQUEST");
1225
+ if (promptApiKey !== void 0 && (proposedConfig.provider !== promptConfig?.provider || proposedConfig.model !== promptConfig.model || proposedConfig.baseUrl !== promptConfig.baseUrl)) throw new LlmError("A prompt API key can only be used with its submitted model route", "INVALID_REQUEST");
1226
1226
  let config;
1227
1227
  let preparedCall;
1228
1228
  try {
@@ -496,7 +496,7 @@ export const TYPERT = {
496
496
  },
497
497
  {
498
498
  "name": "LlmCallConfig",
499
- "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}"
499
+ "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}"
500
500
  },
501
501
  {
502
502
  "name": "LlmCallConfigAdapterDefaults",
@@ -636,7 +636,7 @@ export const TYPERT = {
636
636
  },
637
637
  {
638
638
  "name": "Session",
639
- "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}"
639
+ "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}"
640
640
  },
641
641
  {
642
642
  "name": "SessionEvent",
@@ -644,7 +644,7 @@ export const TYPERT = {
644
644
  },
645
645
  {
646
646
  "name": "SessionEventMap",
647
- "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}"
647
+ "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}"
648
648
  },
649
649
  {
650
650
  "name": "SessionEventType",
@@ -6986,7 +6986,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6986
6986
  },
6987
6987
  sourceLocation: {
6988
6988
  "file": "packages/llm/llm/src/index.ts",
6989
- "line": 712,
6989
+ "line": 713,
6990
6990
  "column": 9
6991
6991
  }
6992
6992
  },
@@ -7004,7 +7004,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7004
7004
  },
7005
7005
  sourceLocation: {
7006
7006
  "file": "packages/llm/llm/src/index.ts",
7007
- "line": 624,
7007
+ "line": 625,
7008
7008
  "column": 3
7009
7009
  }
7010
7010
  },
@@ -7022,7 +7022,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
7022
7022
  },
7023
7023
  sourceLocation: {
7024
7024
  "file": "packages/llm/llm/src/index.ts",
7025
- "line": 552,
7025
+ "line": 553,
7026
7026
  "column": 3
7027
7027
  }
7028
7028
  }
@@ -9799,6 +9799,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9799
9799
  ])
9800
9800
  }))]).optional(),
9801
9801
  "sessionListMetadata": object({
9802
+ "appId": union([_undefined(), string()]).readonly().optional(),
9802
9803
  "hasUserPrompt": boolean().readonly().optional(),
9803
9804
  "blank": boolean().readonly(),
9804
9805
  "lastPromptAt": union([literal(null), number()]).readonly()
@@ -9920,6 +9921,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9920
9921
  }))]);
9921
9922
  let _deepseek_ai_dsh_api_session_controller_session_create_parameter_0$schema$value;
9922
9923
  const _deepseek_ai_dsh_api_session_controller_session_create_parameter_0$schema = () => _deepseek_ai_dsh_api_session_controller_session_create_parameter_0$schema$value ??= object({
9924
+ "appId": string().readonly().optional(),
9923
9925
  "resumeOnly": boolean().readonly().optional(),
9924
9926
  "workspaceId": intersection(string(), unknown()).readonly().optional(),
9925
9927
  "cwd": string().readonly().optional(),
@@ -9930,6 +9932,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
9930
9932
  });
9931
9933
  let _deepseek_ai_dsh_api_session_controller_session_create_result$schema$value;
9932
9934
  const _deepseek_ai_dsh_api_session_controller_session_create_result$schema = () => _deepseek_ai_dsh_api_session_controller_session_create_result$schema$value ??= object({
9935
+ "appId": string().readonly().optional(),
9933
9936
  "sessionId": intersection(string(), unknown()).readonly(),
9934
9937
  "agentPreset": string().readonly().optional()
9935
9938
  });
@@ -10078,6 +10081,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10078
10081
  ])
10079
10082
  }))]).optional(),
10080
10083
  "sessionListMetadata": object({
10084
+ "appId": union([_undefined(), string()]).readonly().optional(),
10081
10085
  "hasUserPrompt": boolean().readonly().optional(),
10082
10086
  "blank": boolean().readonly(),
10083
10087
  "lastPromptAt": union([literal(null), number()]).readonly()
@@ -10257,6 +10261,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10257
10261
  const _deepseek_ai_dsh_api_session_controller_session_list_parameter_0$schema = () => _deepseek_ai_dsh_api_session_controller_session_list_parameter_0$schema$value ??= object({ "cursor": string().readonly().optional() });
10258
10262
  let _deepseek_ai_dsh_api_session_controller_session_list_result$schema$value;
10259
10263
  const _deepseek_ai_dsh_api_session_controller_session_list_result$schema = () => _deepseek_ai_dsh_api_session_controller_session_list_result$schema$value ??= object({ "items": array(object({
10264
+ "appId": string().readonly().optional(),
10260
10265
  "agentAvailable": boolean().readonly(),
10261
10266
  "sessionId": intersection(string(), unknown()).readonly(),
10262
10267
  "updatedAt": number().readonly(),
@@ -10300,6 +10305,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10300
10305
  ])
10301
10306
  }))]).optional(),
10302
10307
  "sessionListMetadata": object({
10308
+ "appId": union([_undefined(), string()]).readonly().optional(),
10303
10309
  "hasUserPrompt": boolean().readonly().optional(),
10304
10310
  "blank": boolean().readonly(),
10305
10311
  "lastPromptAt": union([literal(null), number()]).readonly()
@@ -10553,6 +10559,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10553
10559
  ])
10554
10560
  }))]).optional(),
10555
10561
  "sessionListMetadata": object({
10562
+ "appId": union([_undefined(), string()]).readonly().optional(),
10556
10563
  "hasUserPrompt": boolean().readonly().optional(),
10557
10564
  "blank": boolean().readonly(),
10558
10565
  "lastPromptAt": union([literal(null), number()]).readonly()
@@ -10691,6 +10698,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10691
10698
  "provider": string().readonly(),
10692
10699
  "model": string().readonly(),
10693
10700
  "protocol": string().readonly().optional(),
10701
+ "baseUrl": string().readonly().optional(),
10694
10702
  "apiKey": string().readonly().optional(),
10695
10703
  "options": record(string(), union([
10696
10704
  literal(null),
@@ -10718,7 +10726,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10718
10726
  const _deepseek_ai_dsh_api_session_controller_session_promptModelConfig_result$schema = () => _deepseek_ai_dsh_api_session_controller_session_promptModelConfig_result$schema$value ??= object({
10719
10727
  "version": literal(1),
10720
10728
  "requestApiKey": literal(true),
10721
- "unifiedOptions": literal(true)
10729
+ "unifiedOptions": literal(true),
10730
+ "requestBaseUrl": literal(true)
10722
10731
  });
10723
10732
  let _deepseek_ai_dsh_api_session_controller_session_refreshModelCatalog_result$schema$value;
10724
10733
  const _deepseek_ai_dsh_api_session_controller_session_refreshModelCatalog_result$schema = () => _deepseek_ai_dsh_api_session_controller_session_refreshModelCatalog_result$schema$value ??= object({
@@ -10781,6 +10790,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
10781
10790
  });
10782
10791
  let _deepseek_ai_dsh_api_session_controller_session_resume_result$schema$value;
10783
10792
  const _deepseek_ai_dsh_api_session_controller_session_resume_result$schema = () => _deepseek_ai_dsh_api_session_controller_session_resume_result$schema$value ??= object({
10793
+ "appId": string().readonly().optional(),
10784
10794
  "sessionId": intersection(string(), unknown()).readonly(),
10785
10795
  "selected": object({
10786
10796
  "provider": string().readonly(),
@@ -167,6 +167,7 @@ window.__ModuleLoader__.load({
167
167
  "sandbox/mode",
168
168
  "schedule/change",
169
169
  "session-log-deepseek/delivery-accepted",
170
+ "session/application",
170
171
  "session/end-seed",
171
172
  "session/title",
172
173
  "session/title-llm-request",
@@ -388,14 +388,15 @@ var ApiSessionAgentController = class {
388
388
  * @param existingOnly - refuse a cold identity that does not exist instead of creating it.
389
389
  * @param provider - optional provider override for the model selection.
390
390
  * @param model - optional model override for the model selection.
391
+ * @param appId - application identity for new Sessions.
391
392
  * @returns the matching live ordinary Agent.
392
393
  */
393
- async ensureSession(sessionId, cwd, checkPersistedIdentity, presetId, existingOnly = false, provider, model) {
394
+ async ensureSession(sessionId, cwd, checkPersistedIdentity, presetId, existingOnly = false, provider, model, appId) {
394
395
  const releasing = this.releases.get(sessionId);
395
396
  if (releasing !== void 0) await releasing;
396
397
  let creation = this.creations.get(sessionId);
397
398
  if (creation === void 0) {
398
- creation = this.createOrAdopt(sessionId, cwd, checkPersistedIdentity, presetId, existingOnly, provider, model).catch((error) => {
399
+ creation = this.createOrAdopt(sessionId, cwd, checkPersistedIdentity, presetId, existingOnly, provider, model, appId).catch((error) => {
399
400
  const live = this.ctx.agents.get(sessionId);
400
401
  if (live !== void 0) {
401
402
  if (hasApiSessionSubagentOwner(this.ctx, live.session, live)) throw new ApiSessionSubagentOwnership(sessionId);
@@ -556,7 +557,7 @@ var ApiSessionAgentController = class {
556
557
  setup: composition.setup
557
558
  }))).agent;
558
559
  }
559
- async createOrAdopt(sessionId, cwd, checkPersistedIdentity, presetId, existingOnly, provider, model) {
560
+ async createOrAdopt(sessionId, cwd, checkPersistedIdentity, presetId, existingOnly, provider, model, appId) {
560
561
  const attached = this.ctx.sessions.get(sessionId);
561
562
  const live = this.ctx.agents.get(sessionId);
562
563
  if (attached !== void 0 && hasApiSessionSubagentOwner(this.ctx, attached, live)) throw new ApiSessionSubagentOwnership(sessionId);
@@ -601,6 +602,7 @@ var ApiSessionAgentController = class {
601
602
  agentOptions: this.agentOptions(provider, model),
602
603
  meta: {
603
604
  cwd,
605
+ ...appId === void 0 ? {} : { appId },
604
606
  ...composition.agentPreset === void 0 ? {} : { agentPreset: composition.agentPreset }
605
607
  },
606
608
  setup: composition.setup
@@ -857,6 +859,7 @@ var SessionCommandController = class {
857
859
  * @returns the Session identity and resolved preset when configured.
858
860
  */
859
861
  async create(request) {
862
+ if (request.appId !== void 0 && (typeof request.appId !== "string" || !/^[\x21-\x7e]{1,128}$/u.test(request.appId))) throw new RemoteError("gateway/bad-request", "appId must contain 1 to 128 visible ASCII characters", {});
860
863
  if (request.resumeOnly === true && !request.sessionId) throw new RemoteError("gateway/bad-request", "resumeOnly requires a sessionId", {});
861
864
  if (request.workspaceId !== void 0 && request.cwd !== void 0) throw new RemoteError("gateway/bad-request", "session.create accepts workspaceId or cwd, not both", {});
862
865
  this.ctx.logger.info("session-controller.commands: create", {
@@ -873,7 +876,7 @@ var SessionCommandController = class {
873
876
  const cwd = workspace?.path ?? request.cwd ?? this.defaultCwd;
874
877
  let adopted;
875
878
  try {
876
- adopted = await this.agents.ensureSession(sessionId, cwd, request.sessionId !== void 0, request.agentPreset, request.resumeOnly === true, request.provider, request.model);
879
+ adopted = await this.agents.ensureSession(sessionId, cwd, request.sessionId !== void 0, request.agentPreset, request.resumeOnly === true, request.provider, request.model, request.appId);
877
880
  } catch (error) {
878
881
  this.rejectCreation(sessionId, error);
879
882
  }
@@ -886,9 +889,11 @@ var SessionCommandController = class {
886
889
  });
887
890
  }
888
891
  const agentPreset = this.agents.presetForSession(adopted.session);
892
+ const appId = adopted.session.appId;
889
893
  return {
890
894
  sessionId,
891
- ...agentPreset === void 0 ? {} : { agentPreset }
895
+ ...agentPreset === void 0 ? {} : { agentPreset },
896
+ ...appId === void 0 ? {} : { appId }
892
897
  };
893
898
  }
894
899
  /**
@@ -1259,6 +1264,7 @@ var SessionCommandController = class {
1259
1264
  const current = selection.current;
1260
1265
  return {
1261
1266
  sessionId,
1267
+ ...agent.session.appId === void 0 ? {} : { appId: agent.session.appId },
1262
1268
  selected: {
1263
1269
  provider: current.provider,
1264
1270
  model: current.model,
@@ -1348,7 +1354,8 @@ function validatePromptModelConfig(request) {
1348
1354
  "protocol",
1349
1355
  "options",
1350
1356
  "protocolOptions",
1351
- "apiKey"
1357
+ "apiKey",
1358
+ "baseUrl"
1352
1359
  ].includes(key)) || Buffer.byteLength(JSON.stringify(config)) > 16384) throw invalidModelConfig("modelConfig");
1353
1360
  for (const key of [
1354
1361
  "provider",
@@ -2197,6 +2204,7 @@ const SEARCH_PROVIDER_CALL_LIMIT = 100;
2197
2204
  const SESSION_SEARCH_QUERY_MAX_CHARS = 500;
2198
2205
  const MESSAGE_TYPES = new Set(["user/message", "assistant/message"]);
2199
2206
  const sessionListMetadataSchema = z$1.object({
2207
+ appId: z$1.string().optional(),
2200
2208
  hasUserPrompt: z$1.boolean().default(false),
2201
2209
  blank: z$1.boolean(),
2202
2210
  lastPromptAt: z$1.number().nullable()
@@ -2219,10 +2227,12 @@ function applySessionListMetadata(state, event) {
2219
2227
  const blank = state.blank && event.type !== "turn/start";
2220
2228
  const hasUserPrompt = state.hasUserPrompt === true || hasHumanInput(event);
2221
2229
  const lastPromptAt = event.type === "user/message" && event.data.source.kind === "user" ? event.time : state.lastPromptAt;
2222
- return blank === state.blank && lastPromptAt === state.lastPromptAt && hasUserPrompt === state.hasUserPrompt ? state : {
2230
+ const appId = state.appId ?? (event.type === "session/application" ? event.data.appId : void 0);
2231
+ return appId === state.appId && blank === state.blank && lastPromptAt === state.lastPromptAt && hasUserPrompt === state.hasUserPrompt ? state : {
2223
2232
  blank,
2224
2233
  lastPromptAt,
2225
- hasUserPrompt
2234
+ hasUserPrompt,
2235
+ ...appId === void 0 ? {} : { appId }
2226
2236
  };
2227
2237
  }
2228
2238
  /** User-origin text or media is conversation input; injected context is not. */
@@ -2271,7 +2281,7 @@ var ApiSessionList = class {
2271
2281
  viewSchema: sessionListMetadataSchema,
2272
2282
  view: (state) => state
2273
2283
  },
2274
- stateVersion: 2
2284
+ stateVersion: 3
2275
2285
  });
2276
2286
  ctx.effect(() => async () => {
2277
2287
  this.backfillAbort.abort();
@@ -2309,6 +2319,7 @@ var ApiSessionList = class {
2309
2319
  running: this.ctx.agents.get(session.id)?.status === "running",
2310
2320
  blank: metadata?.blank ?? session.seq === 0,
2311
2321
  ...listFields(session.header),
2322
+ ...session.appId === void 0 ? {} : { appId: session.appId },
2312
2323
  ...projections === void 0 ? {} : { projections }
2313
2324
  };
2314
2325
  }
@@ -2353,6 +2364,7 @@ var ApiSessionList = class {
2353
2364
  running: false,
2354
2365
  blank: metadata?.blank ?? false,
2355
2366
  ...listFields(header),
2367
+ ...metadata?.appId === void 0 ? {} : { appId: metadata.appId },
2356
2368
  ...projections === void 0 ? {} : { projections }
2357
2369
  };
2358
2370
  }
@@ -3894,7 +3906,8 @@ let SessionController = (() => {
3894
3906
  return {
3895
3907
  version: 1,
3896
3908
  requestApiKey: true,
3897
- unifiedOptions: true
3909
+ unifiedOptions: true,
3910
+ requestBaseUrl: true
3898
3911
  };
3899
3912
  }
3900
3913
  /**