@skaile/workspaces 4.25.0 → 4.27.0

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 (153) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/{asset-feeds-72RJOE4E.js → asset-feeds-2KMVU67Q.js} +4 -4
  3. package/dist/{asset-feeds-72RJOE4E.js.map → asset-feeds-2KMVU67Q.js.map} +1 -1
  4. package/dist/asset-manager/index.js +1 -1
  5. package/dist/bridge/drivers/claude-sdk.js +20 -8
  6. package/dist/bridge/drivers/claude-sdk.js.map +1 -1
  7. package/dist/bridge/drivers/codex.js +2 -2
  8. package/dist/bridge/drivers/continue.js +3 -3
  9. package/dist/bridge/drivers/echo.js +3 -5
  10. package/dist/bridge/drivers/echo.js.map +1 -1
  11. package/dist/bridge/drivers/gemini.js +5 -5
  12. package/dist/bridge/drivers/goose.js +3 -3
  13. package/dist/bridge/drivers/omp.js +22 -8
  14. package/dist/bridge/drivers/omp.js.map +1 -1
  15. package/dist/bridge/drivers/opencode.js +3 -3
  16. package/dist/bridge/drivers/qwen.js +5 -5
  17. package/dist/bridge/index.js +5 -4
  18. package/dist/bridge/src/capability-dispatch.d.ts +16 -31
  19. package/dist/bridge/src/capability-dispatch.d.ts.map +1 -1
  20. package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
  21. package/dist/bridge/src/drivers/echo.d.ts.map +1 -1
  22. package/dist/bridge/src/drivers/omp.d.ts.map +1 -1
  23. package/dist/bridge/src/index.d.ts +1 -0
  24. package/dist/bridge/src/index.d.ts.map +1 -1
  25. package/dist/bridge/src/reconfigure-model-ref.d.ts +37 -0
  26. package/dist/bridge/src/reconfigure-model-ref.d.ts.map +1 -0
  27. package/dist/bridge/src/types.d.ts +10 -2
  28. package/dist/bridge/src/types.d.ts.map +1 -1
  29. package/dist/{chunk-EZOFQW3G.js → chunk-2L4KARVG.js} +5 -5
  30. package/dist/{chunk-EZOFQW3G.js.map → chunk-2L4KARVG.js.map} +1 -1
  31. package/dist/{chunk-73ZXUUL6.js → chunk-5LKOAX7I.js} +43 -2
  32. package/dist/chunk-5LKOAX7I.js.map +1 -0
  33. package/dist/{chunk-H4XNX2FG.js → chunk-746DTX5S.js} +2 -2
  34. package/dist/{chunk-H4XNX2FG.js.map → chunk-746DTX5S.js.map} +1 -1
  35. package/dist/{chunk-OQRSSFTU.js → chunk-A2F7D47N.js} +4 -4
  36. package/dist/{chunk-OQRSSFTU.js.map → chunk-A2F7D47N.js.map} +1 -1
  37. package/dist/{chunk-Y6QVVKFN.js → chunk-AVYBLJ3A.js} +3 -3
  38. package/dist/{chunk-Y6QVVKFN.js.map → chunk-AVYBLJ3A.js.map} +1 -1
  39. package/dist/{chunk-IN466NSZ.js → chunk-BADVX5LG.js} +3 -3
  40. package/dist/{chunk-IN466NSZ.js.map → chunk-BADVX5LG.js.map} +1 -1
  41. package/dist/{chunk-SSODNBSC.js → chunk-CCHZLELJ.js} +3 -3
  42. package/dist/{chunk-SSODNBSC.js.map → chunk-CCHZLELJ.js.map} +1 -1
  43. package/dist/{chunk-253427M3.js → chunk-D5Q5MOOH.js} +3 -3
  44. package/dist/{chunk-253427M3.js.map → chunk-D5Q5MOOH.js.map} +1 -1
  45. package/dist/{chunk-SB4U7HLP.js → chunk-DOKEJ6H3.js} +6 -6
  46. package/dist/{chunk-SB4U7HLP.js.map → chunk-DOKEJ6H3.js.map} +1 -1
  47. package/dist/{chunk-PIY5NTXY.js → chunk-GKE66NTN.js} +3 -3
  48. package/dist/{chunk-PIY5NTXY.js.map → chunk-GKE66NTN.js.map} +1 -1
  49. package/dist/{chunk-XZCRIPWT.js → chunk-H3YO74Z5.js} +3 -3
  50. package/dist/{chunk-XZCRIPWT.js.map → chunk-H3YO74Z5.js.map} +1 -1
  51. package/dist/{chunk-IRGI7Q62.js → chunk-IQID7X6P.js} +2 -2
  52. package/dist/{chunk-IRGI7Q62.js.map → chunk-IQID7X6P.js.map} +1 -1
  53. package/dist/{chunk-2JGUFDKZ.js → chunk-JBSCY34V.js} +3 -3
  54. package/dist/{chunk-2JGUFDKZ.js.map → chunk-JBSCY34V.js.map} +1 -1
  55. package/dist/{chunk-47MUF565.js → chunk-LFYAU2H3.js} +6 -6
  56. package/dist/{chunk-47MUF565.js.map → chunk-LFYAU2H3.js.map} +1 -1
  57. package/dist/{chunk-JIPPMYOM.js → chunk-NLUW3IJL.js} +3 -3
  58. package/dist/{chunk-JIPPMYOM.js.map → chunk-NLUW3IJL.js.map} +1 -1
  59. package/dist/{chunk-JKJ7XYLG.js → chunk-OBYKJB4U.js} +50 -13
  60. package/dist/chunk-OBYKJB4U.js.map +1 -0
  61. package/dist/{chunk-YR3CLEQG.js → chunk-OGOQYOM4.js} +6 -6
  62. package/dist/{chunk-YR3CLEQG.js.map → chunk-OGOQYOM4.js.map} +1 -1
  63. package/dist/chunk-TJRNJVGU.js +59 -0
  64. package/dist/chunk-TJRNJVGU.js.map +1 -0
  65. package/dist/{chunk-D3UARV3Z.js → chunk-TRRFUVDJ.js} +8 -7
  66. package/dist/chunk-TRRFUVDJ.js.map +1 -0
  67. package/dist/{chunk-2N6NQUVB.js → chunk-VQGEH6WL.js} +97 -45
  68. package/dist/chunk-VQGEH6WL.js.map +1 -0
  69. package/dist/{chunk-IHFQTKUP.js → chunk-YOA4YBMR.js} +2 -2
  70. package/dist/{chunk-IHFQTKUP.js.map → chunk-YOA4YBMR.js.map} +1 -1
  71. package/dist/cli/index.js +35 -34
  72. package/dist/cli/index.js.map +1 -1
  73. package/dist/connectors/index.js +6 -5
  74. package/dist/{ensure-sources-HEOQJ4CS.js → ensure-sources-WQNMDENC.js} +4 -4
  75. package/dist/{ensure-sources-HEOQJ4CS.js.map → ensure-sources-WQNMDENC.js.map} +1 -1
  76. package/dist/factory-assets/connectors/box.js +6 -5
  77. package/dist/factory-assets/connectors/deploy.js +6 -5
  78. package/dist/factory-assets/connectors/devserver.js +6 -5
  79. package/dist/factory-assets/connectors/flow/adapter.js +6 -5
  80. package/dist/factory-assets/connectors/flow/run-flow.js +7 -6
  81. package/dist/factory-assets/connectors/flow.js +6 -5
  82. package/dist/factory-assets/connectors/git.js +6 -5
  83. package/dist/factory-assets/connectors/gmail.js +6 -5
  84. package/dist/factory-assets/connectors/googledrive.js +6 -5
  85. package/dist/factory-assets/connectors/local.js +6 -5
  86. package/dist/factory-assets/connectors/mattermost.js +6 -5
  87. package/dist/factory-assets/connectors/memory.js +6 -5
  88. package/dist/factory-assets/connectors/minio.js +6 -5
  89. package/dist/factory-assets/connectors/postgres.js +6 -5
  90. package/dist/factory-assets/connectors/s3.js +6 -5
  91. package/dist/factory-assets/connectors/sharepoint.js +6 -5
  92. package/dist/factory-assets/connectors/sqlite.js +6 -5
  93. package/dist/factory-assets/connectors/static-server.js +6 -5
  94. package/dist/factory-assets/connectors/tunnel.js +6 -5
  95. package/dist/factory-assets/connectors/webdav.js +6 -5
  96. package/dist/factory-assets/connectors/xstate-store.js +6 -5
  97. package/dist/factory-assets/connectors/xstate.js +6 -5
  98. package/dist/{helpers-VZJCQSLY.js → helpers-JLK7VJJK.js} +4 -4
  99. package/dist/{helpers-VZJCQSLY.js.map → helpers-JLK7VJJK.js.map} +1 -1
  100. package/dist/{library-publish-VBLSTO7S.js → library-publish-KTCHVGLN.js} +6 -6
  101. package/dist/{library-publish-VBLSTO7S.js.map → library-publish-KTCHVGLN.js.map} +1 -1
  102. package/dist/{open-library-SJ54ZBGJ.js → open-library-TJWAJRJS.js} +5 -5
  103. package/dist/{open-library-SJ54ZBGJ.js.map → open-library-TJWAJRJS.js.map} +1 -1
  104. package/dist/{project-GLZR4SLT.js → project-JBMJ44HH.js} +5 -5
  105. package/dist/{project-GLZR4SLT.js.map → project-JBMJ44HH.js.map} +1 -1
  106. package/dist/runner/index.js +11 -10
  107. package/dist/runner/src/capability-registry.d.ts +4 -5
  108. package/dist/runner/src/capability-registry.d.ts.map +1 -1
  109. package/dist/runner/src/capability-roundtrip.d.ts +2 -1
  110. package/dist/runner/src/capability-roundtrip.d.ts.map +1 -1
  111. package/dist/runner/src/codex-tools.d.ts.map +1 -1
  112. package/dist/runner/src/define-capability.d.ts +9 -0
  113. package/dist/runner/src/define-capability.d.ts.map +1 -1
  114. package/dist/runner/src/driver-swap-gate.d.ts +12 -0
  115. package/dist/runner/src/driver-swap-gate.d.ts.map +1 -1
  116. package/dist/runner/src/reconfigure-handler.d.ts +22 -5
  117. package/dist/runner/src/reconfigure-handler.d.ts.map +1 -1
  118. package/dist/runner/src/reply-routing.d.ts +1 -1
  119. package/dist/runner/src/serve.d.ts.map +1 -1
  120. package/dist/runner/src/session-capability-wiring.d.ts +2 -0
  121. package/dist/runner/src/session-capability-wiring.d.ts.map +1 -1
  122. package/dist/sdk/asset-manager.js +1 -1
  123. package/dist/sdk/bridge.js +5 -4
  124. package/dist/sdk/index.js +11 -10
  125. package/dist/sdk/index.js.map +1 -1
  126. package/dist/sdk/runner.js +11 -10
  127. package/dist/sdk/transport/ws/client.js +1 -1
  128. package/dist/sdk/transport/ws/server.js +1 -1
  129. package/dist/sdk/transport/ws.js +2 -2
  130. package/dist/sdk/transport.js +2 -2
  131. package/dist/{setup-X73AWRMD.js → setup-6QBZIBW2.js} +10 -9
  132. package/dist/setup-6QBZIBW2.js.map +1 -0
  133. package/dist/{source-HYXJO2IE.js → source-AEBW5RRF.js} +6 -6
  134. package/dist/{source-HYXJO2IE.js.map → source-AEBW5RRF.js.map} +1 -1
  135. package/dist/{source-manifest-publish-V5LCVOYZ.js → source-manifest-publish-E2FTXASK.js} +7 -7
  136. package/dist/{source-manifest-publish-V5LCVOYZ.js.map → source-manifest-publish-E2FTXASK.js.map} +1 -1
  137. package/dist/transport/index.js +2 -2
  138. package/dist/transport/src/ws/client.d.ts +15 -0
  139. package/dist/transport/src/ws/client.d.ts.map +1 -1
  140. package/dist/transport/src/ws/server.d.ts +17 -0
  141. package/dist/transport/src/ws/server.d.ts.map +1 -1
  142. package/dist/transport/ws/client.js +1 -1
  143. package/dist/transport/ws/server.js +1 -1
  144. package/dist/transport/ws.js +2 -2
  145. package/dist/tui/index.js +11 -10
  146. package/dist/tui/index.js.map +1 -1
  147. package/dist/workspace-plugin/index.js +1 -1
  148. package/package.json +1 -1
  149. package/dist/chunk-2N6NQUVB.js.map +0 -1
  150. package/dist/chunk-73ZXUUL6.js.map +0 -1
  151. package/dist/chunk-D3UARV3Z.js.map +0 -1
  152. package/dist/chunk-JKJ7XYLG.js.map +0 -1
  153. package/dist/setup-X73AWRMD.js.map +0 -1
@@ -1,20 +1,21 @@
1
- import { WorkspacePlugin } from './chunk-H4XNX2FG.js';
1
+ import { WorkspacePlugin } from './chunk-746DTX5S.js';
2
2
  import { buildWorkspaceToolDefs } from './chunk-HMUFI3L5.js';
3
3
  import { findAiAssetsRoot } from './chunk-7IH3RKKK.js';
4
- import { WebSocketServerTransport } from './chunk-73ZXUUL6.js';
4
+ import { WebSocketServerTransport } from './chunk-5LKOAX7I.js';
5
5
  import { assembleSystemPrompt, buildCapabilitiesPromptSection } from './chunk-W3UDISS2.js';
6
6
  import { prepareNativePolicy, codexInstanceEnvironment, parseCodexCredential, parseCodexRefreshInput, parseCodexRefreshResult } from './chunk-PE3A6FFW.js';
7
- import { resolveFlowPath } from './chunk-253427M3.js';
7
+ import { resolveFlowPath } from './chunk-D5Q5MOOH.js';
8
8
  import { findAiAssetsRoot as findAiAssetsRoot$1, deployCatalogEntry, undeployCatalogEntry } from './chunk-Q6NDQ6BH.js';
9
- import { registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, buildSdkConnectorTools, buildLazySdkFlowTools, describeFlowOperations, buildConnectorToolDefs, buildFlowToolDefs, driveOrchestratorTurn, SessionNodeExecutor, SessionSubpromptRunner, ClassifierSubpromptRunner, SessionInlineSubFlowRunner, buildSdkFlowTools } from './chunk-EZOFQW3G.js';
9
+ import { registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, buildSdkConnectorTools, buildLazySdkFlowTools, describeFlowOperations, buildConnectorToolDefs, buildFlowToolDefs, driveOrchestratorTurn, SessionNodeExecutor, SessionSubpromptRunner, ClassifierSubpromptRunner, SessionInlineSubFlowRunner, buildSdkFlowTools } from './chunk-2L4KARVG.js';
10
10
  import { loadYamlConnectorDeclarations, withMaterializedConnectorDeclarations, SecretProviderChain, ConnectorStartupError, PreMintedSecretProvider, InMemorySecretProvider, resolvedConfigToDeclarations, isKnownSecretRef, deriveSingleMaterializedConnectorDeclaration } from './chunk-2OLNNQKT.js';
11
- import { EventNormalizer } from './chunk-IN466NSZ.js';
11
+ import { EventNormalizer } from './chunk-BADVX5LG.js';
12
12
  import { probeResumeTranscript, transcriptStoreForRuntime } from './chunk-6S5KL76M.js';
13
+ import { scopeReconfigureModel } from './chunk-TJRNJVGU.js';
13
14
  import { CodexNativeStateUnavailable } from './chunk-LOO5CB5M.js';
14
- import { dispatchCapability } from './chunk-D3UARV3Z.js';
15
+ import { dispatchCapability } from './chunk-TRRFUVDJ.js';
15
16
  import { classifyClaudeSdkError } from './chunk-BGY4KTU6.js';
16
17
  import { agentExecRequested } from './chunk-YROR332M.js';
17
- import { toAgentEffort, createDriver, catalogLayer, providerCredentialEnvName, toMergedRegistry, registryCredentialEnv, AI_PROVIDER_PRESETS, AgentDriver } from './chunk-IRGI7Q62.js';
18
+ import { toAgentEffort, createDriver, catalogLayer, providerCredentialEnvName, toMergedRegistry, registryCredentialEnv, AI_PROVIDER_PRESETS, AgentDriver } from './chunk-IQID7X6P.js';
18
19
  import { loadFlow } from './chunk-KTCMBEEB.js';
19
20
  import { parseFlowDefinition } from './chunk-ALLCAFHQ.js';
20
21
  import { renderStimulusPrompt } from './chunk-D6YOE2DB.js';
@@ -863,7 +864,6 @@ async function prepareCodexTools(options) {
863
864
  const { result } = await cancellable(
864
865
  dispatchCapability(
865
866
  hooks,
866
- randomUUID(),
867
867
  call.params.name,
868
868
  call.params.arguments ?? {},
869
869
  () => {
@@ -3400,13 +3400,15 @@ var CapabilityRegistry = class {
3400
3400
  * error still reaches the caller unchanged. `SKAILE_LOG_CONTENT=1` adds the
3401
3401
  * content back on a developer machine (see `log-content.ts`).
3402
3402
  *
3403
- * `baseCtx.callId` (the bridge's dispatch call id) correlates the rows; a random id is
3404
- * used when the caller has none.
3403
+ * `baseCtx.callId` (the bridge's dispatch call id) correlates the rows and is
3404
+ * forwarded to the handler as `ctx.callId`; a random id is used when the caller
3405
+ * has none.
3405
3406
  *
3406
3407
  * @throws when the capability is unknown or the input fails validation
3407
3408
  */
3408
3409
  async invoke(name, input, baseCtx) {
3409
3410
  const { callId: givenCallId, ...handlerCtx } = baseCtx;
3411
+ const callId = givenCallId ?? randomUUID();
3410
3412
  handlerCtx.signal?.throwIfAborted();
3411
3413
  const cap = this.resolve(name);
3412
3414
  if (!cap) {
@@ -3417,7 +3419,6 @@ var CapabilityRegistry = class {
3417
3419
  subkind: cap.origin.kind,
3418
3420
  instance: capabilityLogInstance(cap)
3419
3421
  });
3420
- const callId = givenCallId ?? randomUUID();
3421
3422
  const withContent = isContentLoggingEnabled();
3422
3423
  const startedAt = performance.now();
3423
3424
  const durationMs = () => Math.round(performance.now() - startedAt);
@@ -3429,7 +3430,7 @@ var CapabilityRegistry = class {
3429
3430
  });
3430
3431
  try {
3431
3432
  const validated = cap.inputZod.parse(input);
3432
- const result = await cap.handler(validated, { ...handlerCtx, log });
3433
+ const result = await cap.handler(validated, { ...handlerCtx, callId, log });
3433
3434
  log.info("ok", {
3434
3435
  callId,
3435
3436
  outcome: "ok",
@@ -3513,8 +3514,8 @@ function resolveCapabilityCallTimeoutMs(cap, approvalTimeoutMs) {
3513
3514
  function buildClientCapabilityHandler(args) {
3514
3515
  const timeoutMs = args.timeoutMs ?? DEFAULT_CAPABILITY_CALL_TIMEOUT_MS;
3515
3516
  const gen = args.generateCallId ?? (() => `cap-${Date.now()}-${Math.floor(Math.random() * 1e9)}`);
3516
- return async (input) => {
3517
- const callId = gen();
3517
+ return async (input, ctx) => {
3518
+ const callId = ctx?.callId ?? gen();
3518
3519
  if (args.wire.fireAndForget) {
3519
3520
  args.emit({
3520
3521
  type: "capability_invoked",
@@ -3525,6 +3526,11 @@ function buildClientCapabilityHandler(args) {
3525
3526
  });
3526
3527
  return {};
3527
3528
  }
3529
+ if (args.pending.has(callId)) {
3530
+ throw new Error(
3531
+ `Capability ${args.wire.name} (callId=${callId}) rejected: a call with this id is already in flight`
3532
+ );
3533
+ }
3528
3534
  return new Promise((resolve4, reject) => {
3529
3535
  const timer = setTimeout(() => {
3530
3536
  args.pending.delete(callId);
@@ -4512,7 +4518,8 @@ function driverAppliesReconfigure(driver) {
4512
4518
  function applyReconfigurePatch(config, patch) {
4513
4519
  if (patch.model !== void 0) {
4514
4520
  config.model = patch.model;
4515
- if (config.modelRef !== void 0) config.modelRef = patch.model;
4521
+ if (patch.modelRef !== void 0) config.modelRef = patch.modelRef;
4522
+ else if (config.modelRef !== void 0) config.modelRef = patch.model;
4516
4523
  }
4517
4524
  if (patch.thinking !== void 0) config.thinking = patch.thinking;
4518
4525
  if (patch.effort !== void 0) config.effort = patch.effort;
@@ -4523,7 +4530,7 @@ function carryLiveReconfigure(config, patch, wireAgentConfigChanged) {
4523
4530
  return patch;
4524
4531
  }
4525
4532
  function buildReconfigureHandler(deps) {
4526
- const { getDriver, rememberPatch, log } = deps;
4533
+ const { getDriver, getModelSelection, rememberPatch, log } = deps;
4527
4534
  return async (patch) => {
4528
4535
  const fields = Object.keys(patch).join(", ");
4529
4536
  const driver = getDriver();
@@ -4546,8 +4553,18 @@ function buildReconfigureHandler(deps) {
4546
4553
  message: `The ${driverId} driver cannot change ${fields} live; the change applies when the session next starts.`
4547
4554
  };
4548
4555
  }
4556
+ let modelRef;
4557
+ const selection = patch.model !== void 0 ? getModelSelection?.() : void 0;
4558
+ if (patch.model !== void 0 && selection) {
4559
+ const scope = scopeReconfigureModel({ ...selection, model: patch.model });
4560
+ if (!scope.ok) {
4561
+ log(`[reconfigure] ${scope.message} (${fields} not applied)`);
4562
+ return { ok: false, code: scope.code, message: scope.message };
4563
+ }
4564
+ modelRef = scope.modelRef;
4565
+ }
4549
4566
  driver.reconfigure(patch);
4550
- rememberPatch(patch);
4567
+ rememberPatch(modelRef === void 0 ? patch : { ...patch, modelRef });
4551
4568
  const model = driver.getModel() ?? null;
4552
4569
  log(`[reconfigure] driver ${driverId} took ${fields} (model=${model ?? "(default)"})`);
4553
4570
  return { ok: true, model };
@@ -4678,6 +4695,8 @@ var DriverSwapGate = class {
4678
4695
  activeDriverSwap = null;
4679
4696
  /** FIFO chain; resolves once every started turn has settled. */
4680
4697
  turnTail = Promise.resolve();
4698
+ /** FIFO chain of swaps; never rejects, resolves once every queued swap settled. */
4699
+ swapTail = Promise.resolve();
4681
4700
  /**
4682
4701
  * Mark a turn as in flight. Call at the real `driver.prompt()` dispatch — not
4683
4702
  * earlier — so a same-handler restart (e.g. restaging skills before the turn)
@@ -4733,6 +4752,28 @@ var DriverSwapGate = class {
4733
4752
  } catch {
4734
4753
  }
4735
4754
  }
4755
+ /**
4756
+ * Run a driver swap: queued behind every earlier swap, then behind every
4757
+ * in-flight turn. Registers synchronously, so a prompt arriving before the
4758
+ * swap starts already defers to it, and `isSwapping` stays true until the last
4759
+ * queued swap settles. A rejecting swap rejects only for its own caller — the
4760
+ * queue moves on. Never call from inside a swap: it would wait on itself.
4761
+ */
4762
+ runSwap(swap) {
4763
+ const earlier = this.swapTail;
4764
+ const run = (async () => {
4765
+ await earlier;
4766
+ await this.awaitActiveTurn();
4767
+ return swap();
4768
+ })();
4769
+ const settled = run.then(
4770
+ () => void 0,
4771
+ () => void 0
4772
+ );
4773
+ this.swapTail = settled;
4774
+ this.beginSwap(settled);
4775
+ return run;
4776
+ }
4736
4777
  /**
4737
4778
  * Register the in-flight recreate promise so concurrent prompts defer to it.
4738
4779
  * Auto-clears when `recreate` settles (resolve OR reject) so a failed recreate
@@ -7126,6 +7167,7 @@ function wireSessionCapabilities(deps) {
7126
7167
  registerLiveAttachedMcp,
7127
7168
  scheduleDriverRestartForToolChanges,
7128
7169
  getDriver,
7170
+ getModelSelection,
7129
7171
  rememberReconfigure,
7130
7172
  log
7131
7173
  } = deps;
@@ -7187,6 +7229,7 @@ function wireSessionCapabilities(deps) {
7187
7229
  }),
7188
7230
  reconfigure: buildReconfigureHandler({
7189
7231
  getDriver,
7232
+ getModelSelection,
7190
7233
  rememberPatch: rememberReconfigure,
7191
7234
  log
7192
7235
  })
@@ -8928,19 +8971,20 @@ async function startAgentServer(opts) {
8928
8971
  return resourceManager;
8929
8972
  }
8930
8973
  async function recreateDriverForFlowTools() {
8931
- if (!flowStartNeedsDriverRestart({
8974
+ const needsRestart = () => flowStartNeedsDriverRestart({
8932
8975
  driverStarted,
8933
8976
  driverType: agentSession?.driverType,
8934
8977
  flowToolsBaked
8935
- })) {
8936
- return false;
8937
- }
8938
- const prevSessionId = driver.runtimeSessionId;
8939
- log(
8940
- `[serve] restarting driver to register flow connector tools (resume=${prevSessionId ?? "none"})`
8941
- );
8942
- await recreateAgentSession({ resumeSessionId: prevSessionId });
8943
- return true;
8978
+ });
8979
+ if (!needsRestart()) return false;
8980
+ return recreateAgentSession(() => {
8981
+ if (!needsRestart()) return null;
8982
+ const prevSessionId = driver.runtimeSessionId;
8983
+ log(
8984
+ `[serve] restarting driver to register flow connector tools (resume=${prevSessionId ?? "none"})`
8985
+ );
8986
+ return { resumeSessionId: prevSessionId };
8987
+ });
8944
8988
  }
8945
8989
  async function createActiveFlow(flowDef, seedOrExecution) {
8946
8990
  const bus = getOrCreateStimulusBus();
@@ -9330,6 +9374,11 @@ async function startAgentServer(opts) {
9330
9374
  registerLiveAttachedMcp,
9331
9375
  scheduleDriverRestartForToolChanges,
9332
9376
  getDriver: () => driver ?? null,
9377
+ // The selector the live driver runs: the last scoped patch, else the build's.
9378
+ getModelSelection: () => agentSession ? {
9379
+ registry: agentSession.registry,
9380
+ modelRef: liveReconfigurePatch?.modelRef ?? agentSession.modelRef
9381
+ } : void 0,
9333
9382
  rememberReconfigure: (patch) => {
9334
9383
  liveReconfigurePatch = { ...liveReconfigurePatch, ...patch };
9335
9384
  applyReconfigurePatch(sessionConfig, patch);
@@ -9339,18 +9388,12 @@ async function startAgentServer(opts) {
9339
9388
  return { needsWireFallbackRecreate, needsWireAgentConfigRecreate };
9340
9389
  }
9341
9390
  async function recreateAgentSession(overrides) {
9342
- let markSwapDone;
9343
- driverSwapGate.beginSwap(
9344
- new Promise((resolve4) => {
9345
- markSwapDone = resolve4;
9346
- })
9347
- );
9348
- try {
9349
- await driverSwapGate.awaitActiveTurn();
9350
- await recreateAgentSessionInner(overrides);
9351
- } finally {
9352
- markSwapDone();
9353
- }
9391
+ return driverSwapGate.runSwap(async () => {
9392
+ const resolved = typeof overrides === "function" ? overrides() : overrides;
9393
+ if (!resolved) return false;
9394
+ await recreateAgentSessionInner(resolved);
9395
+ return true;
9396
+ });
9354
9397
  }
9355
9398
  async function recreateAgentSessionInner(overrides) {
9356
9399
  const disposedManager = agentSession.resourceManager;
@@ -9566,9 +9609,15 @@ async function startAgentServer(opts) {
9566
9609
  log(`[serve] ${reason} applied before driver start \u2014 picked up on the first prompt`);
9567
9610
  return;
9568
9611
  }
9569
- const prevSessionId = driver.runtimeSessionId;
9570
- log(`[serve] restarting driver to pick up ${reason} (resume=${prevSessionId ?? "none"})`);
9571
- await recreateAgentSession({ resumeSessionId: prevSessionId });
9612
+ await recreateAgentSession(() => {
9613
+ if (!driverStarted) {
9614
+ log(`[serve] ${reason} applied after an earlier recreate \u2014 picked up on the first prompt`);
9615
+ return null;
9616
+ }
9617
+ const prevSessionId = driver.runtimeSessionId;
9618
+ log(`[serve] restarting driver to pick up ${reason} (resume=${prevSessionId ?? "none"})`);
9619
+ return { resumeSessionId: prevSessionId };
9620
+ });
9572
9621
  }
9573
9622
  function enqueueDriverRestart(reason) {
9574
9623
  const next = driverRestartChain.then(() => restartDriverForToolChanges(reason));
@@ -10250,7 +10299,10 @@ async function startAgentServer(opts) {
10250
10299
  await dispatchRunnerCapabilityInvocation(
10251
10300
  { callId: cmd.callId, name: cmd.name, input: cmd.input },
10252
10301
  {
10253
- invoke: (name, input) => capabilityRegistry.invoke(name, input, { sessionId, callId: cmd.callId }),
10302
+ // No `callId` here: the platform's id belongs to the platform's pending
10303
+ // map, and a client-origin cap would otherwise emit its own outbound
10304
+ // `capability_invoked` under it. The registry mints a fresh one.
10305
+ invoke: (name, input) => capabilityRegistry.invoke(name, input, { sessionId }),
10254
10306
  // `capability_result` is a CapabilityEvent; `sendEvent` and
10255
10307
  // `ServerTransport.send` are typed to AgentEvent alone though both
10256
10308
  // unions ride one wire. Widening that is a consumer-breaking change.
@@ -10577,5 +10629,5 @@ function touchSession(state) {
10577
10629
  }
10578
10630
 
10579
10631
  export { CLAUDE_CODE_CREDENTIALS_KEY, COMPILE_MANIFEST_FILENAME, CapabilityRegistry, DEFAULT_CAPABILITY_CALL_TIMEOUT_MS, DEFAULT_COALESCE_MS, DEFAULT_FLOW_MUTATE_CONNECTOR_WAIT_MS, MOUNT_LIST_MAX_DEPTH, MOUNT_LIST_MAX_ENTRIES, MOUNT_READ_DEADLINE_FACTOR, MOUNT_STAT_BUDGET_MS, MOUNT_STAT_MAX_ENTRIES, MOUNT_TREE_OP_DEADLINE_FACTOR, MarkdownStreamer, PreInitRingSink, ResourceOperationError, SESSION_ROOT_WRITABLE_DIRS, SESSION_ROOT_WRITABLE_FILES, WS_AUTH_TOKEN_ENV, WS_AUTH_TOKEN_FILE_ENV, agentDefinitionExists, bootstrapCapabilityRegistry, bootstrapRunnerLogStore, buildAgentResources, buildClientCapabilityHandler, buildConnectorTokenMediator, buildContextSection, buildEnvironmentSection, buildResourcesAvailablePayload, buildStoreSnapshotReplay, builtinCapabilities, capabilityLogInstance, clearPreInitRingSink, clearSession, compileComposition, computeCapabilitySignature, computeDirectoryTotals, connectorRefreshKind, createAgentSession, createFlowConnectorReadiness, createManagedCodexSubpromptDriver, createSessionStimulusBus, defineCapability, deleteSession, dispatchResourceRequest, dispatchRunnerCapabilityInvocation, emitSystemPromptComposed, ensureClaudeSettingsDisablesConnectors, ensureGitConfigInclude, executeConnectorMutate, extractClaudeAiOauthExpiresAt, flowRunDrivesTurns, flowStartNeedsDriverRestart, getPreInitRingSink, handleMountResourceRequest, handleResourceRequest, handleSessionRootResourceRequest, hasNonTerminalFlow, hostOpResumeStimulus, installPreInitRingSink, isSessionRootPathAllowed, isTerminalFlowStatus, listSessions, loadAgentManifest, loadCompileManifest, loadCompileManifestFromDir, loadManagedCodexHostConfig, loadSession, loadSessionById, mcpAuthSecretKey, newSession, nulTailPaddingLength, pickChatFlowTarget, pickFlowToolTarget, pickRepointedManager, planFlowMutate, prepareCodexTools, reconcilePendingDecisions, registerActiveFlow, registerCompositionCapabilities, rejectCapabilityOnApprovalDeny, rejectPendingCapabilityCallsOnDisconnect, resetRunnerLogStore, resolveAgentComposition, resolveAgentMixins, resolveBinding, resolveCapabilityCallTimeoutMs, resolveCapabilityResult, resolveComposition, resolveFlowMutateConnectorWaitMs, resolveMixin, runAgentChat, saveSession, setCurrentSession, setUpFlowConnector, startAgentServer, stimulusFromMetas, supportsLiveToolUpdates, takeRunnerWsAuthToken, touchSession, validateInputResponse, writeClaudeCodeCredentialsFile };
10580
- //# sourceMappingURL=chunk-2N6NQUVB.js.map
10581
- //# sourceMappingURL=chunk-2N6NQUVB.js.map
10632
+ //# sourceMappingURL=chunk-VQGEH6WL.js.map
10633
+ //# sourceMappingURL=chunk-VQGEH6WL.js.map