@skaile/workspaces 5.16.0 → 5.17.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 (162) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/app-sdk/index.js +1 -1
  3. package/dist/{asset-feeds-BELBSJEE.js → asset-feeds-MALYFZUM.js} +4 -4
  4. package/dist/{asset-feeds-BELBSJEE.js.map → asset-feeds-MALYFZUM.js.map} +1 -1
  5. package/dist/asset-manager/index.js +1 -1
  6. package/dist/bridge/drivers/claude-sdk.js +279 -96
  7. package/dist/bridge/drivers/claude-sdk.js.map +1 -1
  8. package/dist/bridge/drivers/codex.js +4 -4
  9. package/dist/bridge/drivers/continue.js +4 -4
  10. package/dist/bridge/drivers/echo.js +4 -4
  11. package/dist/bridge/drivers/gemini.js +6 -6
  12. package/dist/bridge/drivers/goose.js +4 -4
  13. package/dist/bridge/drivers/omp.js +6 -6
  14. package/dist/bridge/drivers/opencode.js +4 -4
  15. package/dist/bridge/drivers/qwen.js +6 -6
  16. package/dist/bridge/index.js +8 -8
  17. package/dist/bridge/src/drivers/claude-sdk.d.ts +74 -20
  18. package/dist/bridge/src/drivers/claude-sdk.d.ts.map +1 -1
  19. package/dist/bridge/src/drivers/claude-self-turns.d.ts +25 -6
  20. package/dist/bridge/src/drivers/claude-self-turns.d.ts.map +1 -1
  21. package/dist/bridge/src/drivers/sanitize-assistant-text.d.ts +10 -0
  22. package/dist/bridge/src/drivers/sanitize-assistant-text.d.ts.map +1 -1
  23. package/dist/bridge/src/drivers/scrub-transcript.d.ts +20 -0
  24. package/dist/bridge/src/drivers/scrub-transcript.d.ts.map +1 -1
  25. package/dist/{chunk-NSNM2ZXF.js → chunk-3OYOBTY4.js} +44 -4
  26. package/dist/chunk-3OYOBTY4.js.map +1 -0
  27. package/dist/{chunk-6RTEUWXX.js → chunk-5SWED2LW.js} +3 -3
  28. package/dist/{chunk-6RTEUWXX.js.map → chunk-5SWED2LW.js.map} +1 -1
  29. package/dist/{chunk-PW3TYWOI.js → chunk-AJ7EGIFR.js} +3 -3
  30. package/dist/{chunk-PW3TYWOI.js.map → chunk-AJ7EGIFR.js.map} +1 -1
  31. package/dist/{chunk-E634MBP6.js → chunk-BBRMS4IC.js} +3 -3
  32. package/dist/{chunk-E634MBP6.js.map → chunk-BBRMS4IC.js.map} +1 -1
  33. package/dist/{chunk-SMUIYYCH.js → chunk-BVXXBZWA.js} +7 -7
  34. package/dist/{chunk-SMUIYYCH.js.map → chunk-BVXXBZWA.js.map} +1 -1
  35. package/dist/{chunk-ISSYT5AZ.js → chunk-CWAWYXD5.js} +3 -3
  36. package/dist/{chunk-ISSYT5AZ.js.map → chunk-CWAWYXD5.js.map} +1 -1
  37. package/dist/{chunk-OHNNCXMB.js → chunk-DR5ZOEYI.js} +7 -7
  38. package/dist/{chunk-OHNNCXMB.js.map → chunk-DR5ZOEYI.js.map} +1 -1
  39. package/dist/{chunk-YIDZJHY6.js → chunk-EFLKSMCO.js} +3 -3
  40. package/dist/{chunk-YIDZJHY6.js.map → chunk-EFLKSMCO.js.map} +1 -1
  41. package/dist/{chunk-CQFVKN6S.js → chunk-EOKWTN4N.js} +207 -66
  42. package/dist/chunk-EOKWTN4N.js.map +1 -0
  43. package/dist/{chunk-Y25V2MW2.js → chunk-EYDRONKO.js} +3 -3
  44. package/dist/{chunk-Y25V2MW2.js.map → chunk-EYDRONKO.js.map} +1 -1
  45. package/dist/{chunk-DQOAPR4M.js → chunk-FACRITOL.js} +2 -2
  46. package/dist/{chunk-DQOAPR4M.js.map → chunk-FACRITOL.js.map} +1 -1
  47. package/dist/{chunk-TXGVG7VH.js → chunk-GYZJKZPJ.js} +3 -3
  48. package/dist/{chunk-TXGVG7VH.js.map → chunk-GYZJKZPJ.js.map} +1 -1
  49. package/dist/{chunk-TADJCATD.js → chunk-HLETG3CX.js} +3 -3
  50. package/dist/{chunk-TADJCATD.js.map → chunk-HLETG3CX.js.map} +1 -1
  51. package/dist/{chunk-FWAJUWXQ.js → chunk-KZWZRNIY.js} +4 -4
  52. package/dist/{chunk-FWAJUWXQ.js.map → chunk-KZWZRNIY.js.map} +1 -1
  53. package/dist/{chunk-X5O56UO4.js → chunk-L2AMXONH.js} +3 -3
  54. package/dist/chunk-L2AMXONH.js.map +1 -0
  55. package/dist/{chunk-6Q7NKTDG.js → chunk-LQT2IKYY.js} +2 -2
  56. package/dist/{chunk-6Q7NKTDG.js.map → chunk-LQT2IKYY.js.map} +1 -1
  57. package/dist/{chunk-A7AZ3RL5.js → chunk-MMARPEV7.js} +4 -4
  58. package/dist/{chunk-A7AZ3RL5.js.map → chunk-MMARPEV7.js.map} +1 -1
  59. package/dist/{chunk-J4RRH2NP.js → chunk-OQN7PCI4.js} +3 -3
  60. package/dist/{chunk-J4RRH2NP.js.map → chunk-OQN7PCI4.js.map} +1 -1
  61. package/dist/{chunk-5CE6J4DB.js → chunk-OXUCYHL5.js} +5 -5
  62. package/dist/{chunk-5CE6J4DB.js.map → chunk-OXUCYHL5.js.map} +1 -1
  63. package/dist/{chunk-A26MUUN7.js → chunk-QBY74UBH.js} +7 -7
  64. package/dist/{chunk-A26MUUN7.js.map → chunk-QBY74UBH.js.map} +1 -1
  65. package/dist/{chunk-VJ2DZLDM.js → chunk-QEX75L77.js} +3 -3
  66. package/dist/{chunk-VJ2DZLDM.js.map → chunk-QEX75L77.js.map} +1 -1
  67. package/dist/{chunk-HG52NGAV.js → chunk-QSLXB44M.js} +3 -3
  68. package/dist/{chunk-HG52NGAV.js.map → chunk-QSLXB44M.js.map} +1 -1
  69. package/dist/{chunk-TKI7YDWE.js → chunk-QW534EZB.js} +6 -6
  70. package/dist/{chunk-TKI7YDWE.js.map → chunk-QW534EZB.js.map} +1 -1
  71. package/dist/{chunk-XGR7IDTY.js → chunk-QXA2W6UB.js} +3 -3
  72. package/dist/{chunk-XGR7IDTY.js.map → chunk-QXA2W6UB.js.map} +1 -1
  73. package/dist/{chunk-OJHPG6HK.js → chunk-V5CDPKDA.js} +7 -7
  74. package/dist/{chunk-OJHPG6HK.js.map → chunk-V5CDPKDA.js.map} +1 -1
  75. package/dist/{chunk-DADAZLFW.js → chunk-W44KA24A.js} +2 -2
  76. package/dist/{chunk-DADAZLFW.js.map → chunk-W44KA24A.js.map} +1 -1
  77. package/dist/{chunk-SAGBVBY2.js → chunk-WY22FMZF.js} +4 -4
  78. package/dist/{chunk-SAGBVBY2.js.map → chunk-WY22FMZF.js.map} +1 -1
  79. package/dist/{chunk-D5WTOVLG.js → chunk-Y56YIT6J.js} +2 -2
  80. package/dist/chunk-Y56YIT6J.js.map +1 -0
  81. package/dist/{chunk-ZIW34FGO.js → chunk-YIF2IJUA.js} +3 -3
  82. package/dist/{chunk-ZIW34FGO.js.map → chunk-YIF2IJUA.js.map} +1 -1
  83. package/dist/{chunk-RTNWU2UD.js → chunk-ZPCABSSW.js} +3 -3
  84. package/dist/{chunk-RTNWU2UD.js.map → chunk-ZPCABSSW.js.map} +1 -1
  85. package/dist/{chunk-72KZJE3G.js → chunk-ZWUJ22RF.js} +4 -4
  86. package/dist/{chunk-72KZJE3G.js.map → chunk-ZWUJ22RF.js.map} +1 -1
  87. package/dist/cli/index.js +47 -47
  88. package/dist/connectors/index.js +10 -10
  89. package/dist/{connectors-44RE2QEM.js → connectors-CIEIMJY2.js} +13 -13
  90. package/dist/{connectors-44RE2QEM.js.map → connectors-CIEIMJY2.js.map} +1 -1
  91. package/dist/connectors-shared/index.js +2 -2
  92. package/dist/{ensure-sources-R6AHZ7RV.js → ensure-sources-I62QMZZP.js} +4 -4
  93. package/dist/{ensure-sources-R6AHZ7RV.js.map → ensure-sources-I62QMZZP.js.map} +1 -1
  94. package/dist/factory-assets/connectors/box.js +10 -10
  95. package/dist/factory-assets/connectors/deploy.js +10 -10
  96. package/dist/factory-assets/connectors/devserver.js +10 -10
  97. package/dist/factory-assets/connectors/flow/adapter.js +10 -10
  98. package/dist/factory-assets/connectors/flow/run-flow.js +11 -11
  99. package/dist/factory-assets/connectors/flow.js +10 -10
  100. package/dist/factory-assets/connectors/git.js +10 -10
  101. package/dist/factory-assets/connectors/gmail.js +10 -10
  102. package/dist/factory-assets/connectors/googledrive.js +10 -10
  103. package/dist/factory-assets/connectors/local.js +10 -10
  104. package/dist/factory-assets/connectors/mattermost.js +10 -10
  105. package/dist/factory-assets/connectors/memory.js +10 -10
  106. package/dist/factory-assets/connectors/minio.js +10 -10
  107. package/dist/factory-assets/connectors/postgres.js +10 -10
  108. package/dist/factory-assets/connectors/s3.js +10 -10
  109. package/dist/factory-assets/connectors/sharepoint.js +10 -10
  110. package/dist/factory-assets/connectors/sqlite.js +10 -10
  111. package/dist/factory-assets/connectors/static-server.js +10 -10
  112. package/dist/factory-assets/connectors/tunnel.js +10 -10
  113. package/dist/factory-assets/connectors/webdav.js +10 -10
  114. package/dist/factory-assets/connectors/xstate-store.js +10 -10
  115. package/dist/factory-assets/connectors/xstate.js +10 -10
  116. package/dist/{helpers-FNQL5PI7.js → helpers-3FOM37BO.js} +4 -4
  117. package/dist/{helpers-FNQL5PI7.js.map → helpers-3FOM37BO.js.map} +1 -1
  118. package/dist/{library-publish-GHPVY42Y.js → library-publish-EFKITCGE.js} +26 -26
  119. package/dist/{library-publish-GHPVY42Y.js.map → library-publish-EFKITCGE.js.map} +1 -1
  120. package/dist/model-endpoint/index.js +3 -3
  121. package/dist/{open-library-YSUGNP36.js → open-library-NZUI4XGF.js} +5 -5
  122. package/dist/{open-library-YSUGNP36.js.map → open-library-NZUI4XGF.js.map} +1 -1
  123. package/dist/{project-NDSLXERO.js → project-2BNFZ2CR.js} +22 -22
  124. package/dist/{project-NDSLXERO.js.map → project-2BNFZ2CR.js.map} +1 -1
  125. package/dist/runner/index.js +17 -17
  126. package/dist/runner/src/coalesced-restart.d.ts +41 -0
  127. package/dist/runner/src/coalesced-restart.d.ts.map +1 -0
  128. package/dist/runner/src/compaction/prompt.d.ts.map +1 -1
  129. package/dist/runner/src/mcp-runtime-handlers.d.ts +27 -0
  130. package/dist/runner/src/mcp-runtime-handlers.d.ts.map +1 -1
  131. package/dist/runner/src/runner-capabilities.d.ts +7 -0
  132. package/dist/runner/src/runner-capabilities.d.ts.map +1 -1
  133. package/dist/runner/src/serve.d.ts.map +1 -1
  134. package/dist/runner/src/session-capability-wiring.d.ts +2 -0
  135. package/dist/runner/src/session-capability-wiring.d.ts.map +1 -1
  136. package/dist/sdk/asset-manager.js +1 -1
  137. package/dist/sdk/bridge.js +8 -8
  138. package/dist/sdk/index.js +17 -17
  139. package/dist/sdk/runner.js +17 -17
  140. package/dist/sdk/session.js +2 -2
  141. package/dist/sdk/types.js +1 -1
  142. package/dist/{serve-preflight-ON2LS3SD.js → serve-preflight-V5GM33T3.js} +2 -2
  143. package/dist/{serve-preflight-ON2LS3SD.js.map → serve-preflight-V5GM33T3.js.map} +1 -1
  144. package/dist/session/index.js +2 -2
  145. package/dist/{setup-MFPEQS2I.js → setup-ZMAPTKJW.js} +13 -13
  146. package/dist/{setup-MFPEQS2I.js.map → setup-ZMAPTKJW.js.map} +1 -1
  147. package/dist/{source-4QVRD5NV.js → source-6BZA34F5.js} +24 -24
  148. package/dist/{source-4QVRD5NV.js.map → source-6BZA34F5.js.map} +1 -1
  149. package/dist/{source-manifest-publish-ZIO24GUM.js → source-manifest-publish-MJXCSUKT.js} +26 -26
  150. package/dist/{source-manifest-publish-ZIO24GUM.js.map → source-manifest-publish-MJXCSUKT.js.map} +1 -1
  151. package/dist/tui/index.js +17 -17
  152. package/dist/types/index.js +1 -1
  153. package/dist/types/src/events.d.ts +7 -4
  154. package/dist/types/src/events.d.ts.map +1 -1
  155. package/dist/workspace-plugin/adapters/mcp.js +12 -12
  156. package/dist/workspace-plugin/adapters/omp.js +7 -7
  157. package/dist/workspace-plugin/index.js +1 -1
  158. package/package.json +1 -1
  159. package/dist/chunk-CQFVKN6S.js.map +0 -1
  160. package/dist/chunk-D5WTOVLG.js.map +0 -1
  161. package/dist/chunk-NSNM2ZXF.js.map +0 -1
  162. package/dist/chunk-X5O56UO4.js.map +0 -1
@@ -1,26 +1,26 @@
1
- import { WorkspacePlugin } from './chunk-DQOAPR4M.js';
2
- import { buildWorkspaceToolDefs } from './chunk-A7AZ3RL5.js';
1
+ import { WorkspacePlugin } from './chunk-FACRITOL.js';
2
+ import { buildWorkspaceToolDefs } from './chunk-MMARPEV7.js';
3
3
  import { findAiAssetsRoot } from './chunk-PGZDSDOB.js';
4
- import { startModelEndpoint } from './chunk-72KZJE3G.js';
4
+ import { startModelEndpoint } from './chunk-ZWUJ22RF.js';
5
5
  import { WebSocketServerTransport } from './chunk-L6UMSKDF.js';
6
6
  import { assembleSystemPrompt, buildCapabilitiesPromptSection } from './chunk-W3UDISS2.js';
7
7
  import { prepareNativePolicy, codexInstanceEnvironment, parseCodexCredential, parseCodexRefreshInput, parseCodexRefreshResult } from './chunk-PHRNUTSG.js';
8
- import { resolveFlowPath } from './chunk-E634MBP6.js';
8
+ import { resolveFlowPath } from './chunk-BBRMS4IC.js';
9
9
  import { findAiAssetsRoot as findAiAssetsRoot$1, deployCatalogEntry, undeployCatalogEntry } from './chunk-AP24HESN.js';
10
- import { ConnectFailureCarryOver, registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, buildSdkConnectorTools, buildLazySdkFlowTools, describeFlowOperations, buildConnectorToolDefs, buildFlowToolDefs, SessionNodeExecutor, SessionSubpromptRunner, ClassifierSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn, buildSdkFlowTools } from './chunk-OJHPG6HK.js';
10
+ import { ConnectFailureCarryOver, registerBuiltinConnectors, buildConnectorPromptSection, findMissingPackages, installNpmPackages, ConnectorManager, buildSdkConnectorTools, buildLazySdkFlowTools, describeFlowOperations, buildConnectorToolDefs, buildFlowToolDefs, SessionNodeExecutor, SessionSubpromptRunner, ClassifierSubpromptRunner, SessionInlineSubFlowRunner, driveOrchestratorTurn, buildSdkFlowTools } from './chunk-V5CDPKDA.js';
11
11
  import { loadYamlConnectorDeclarations, withMaterializedConnectorDeclarations, SecretProviderChain, ConnectorStartupError, isKnownSecretRef, EnvSecretProvider, PreMintedSecretProvider, InMemorySecretProvider, resolvedConfigToDeclarations, deriveSingleMaterializedConnectorDeclaration } from './chunk-FSSRBWYL.js';
12
- import { EventNormalizer } from './chunk-TKI7YDWE.js';
13
- import { approvalCardOf, APPROVE_ONCE, DENY, probeResumeTranscript, transcriptStoreForRuntime } from './chunk-NSNM2ZXF.js';
12
+ import { EventNormalizer } from './chunk-QW534EZB.js';
13
+ import { approvalCardOf, APPROVE_ONCE, DENY, probeResumeTranscript, transcriptStoreForRuntime } from './chunk-3OYOBTY4.js';
14
14
  import { CodexNativeStateUnavailable } from './chunk-LOO5CB5M.js';
15
- import { dispatchCapability } from './chunk-PW3TYWOI.js';
15
+ import { dispatchCapability } from './chunk-AJ7EGIFR.js';
16
16
  import { classifyClaudeSdkError } from './chunk-B4X2N7JQ.js';
17
17
  import { agentExecRequested } from './chunk-YROR332M.js';
18
- import { toAgentEffort, toMergedRegistry } from './chunk-HG52NGAV.js';
19
- import { unresolvedProviderCredentials, driverCapabilities, createDriver, catalogLayer, providerCredentialEnvName, registryCredentialEnv, AI_PROVIDER_PRESETS, supportsLiveToolUpdates } from './chunk-6Q7NKTDG.js';
18
+ import { toAgentEffort, toMergedRegistry } from './chunk-QSLXB44M.js';
19
+ import { unresolvedProviderCredentials, driverCapabilities, createDriver, catalogLayer, providerCredentialEnvName, registryCredentialEnv, AI_PROVIDER_PRESETS, supportsLiveToolUpdates } from './chunk-LQT2IKYY.js';
20
20
  import { loadFlow } from './chunk-SPV2CXJ3.js';
21
21
  import { parseFlowDefinition } from './chunk-X3RMRJNR.js';
22
22
  import { renderStimulusPrompt } from './chunk-M3WPBTGJ.js';
23
- import { TERMINAL_AGENT_RUN_STATUSES, withActivityLabelJsonSchema, TOOL_ACTIVITY_PROMPT_SECTION, SESSION_ROOT_CONNECTOR_ID, PLATFORM_BLOCKS_RUNTIME_FEATURE, PROTOCOL_VERSION, deliveryClassOf } from './chunk-D5WTOVLG.js';
23
+ import { TERMINAL_AGENT_RUN_STATUSES, withActivityLabelJsonSchema, TOOL_ACTIVITY_PROMPT_SECTION, SESSION_ROOT_CONNECTOR_ID, PLATFORM_BLOCKS_RUNTIME_FEATURE, PROTOCOL_VERSION, deliveryClassOf } from './chunk-Y56YIT6J.js';
24
24
  import { knowledgeKindProvider, scanLibraryRoot, LocalIndex } from './chunk-D3PU3C6F.js';
25
25
  import { createDefaultKindRegistry } from './chunk-ES6ARJPQ.js';
26
26
  import { BindingSchema, effectiveComposes, AgentManifestSchema, AgentTriggerSchema, ANTHROPIC_MODEL_ALIASES } from './chunk-YK3XLEQJ.js';
@@ -8466,6 +8466,46 @@ function createCoalescedTask(lock, fn) {
8466
8466
  return run;
8467
8467
  };
8468
8468
  }
8469
+
8470
+ // runner/src/coalesced-restart.ts
8471
+ function createCoalescedRestartScheduler(deps) {
8472
+ const quietMs = deps.quietMs ?? 250;
8473
+ const maxWaitMs = deps.maxWaitMs ?? 2e3;
8474
+ const now = deps.now ?? Date.now;
8475
+ const sleep = deps.sleep ?? ((ms) => new Promise((resolve4) => setTimeout(resolve4, ms)));
8476
+ let open4 = null;
8477
+ return (reason) => {
8478
+ if (open4) {
8479
+ open4.reasons.push(reason);
8480
+ open4.lastJoinedAt = now();
8481
+ return;
8482
+ }
8483
+ const state = { reasons: [reason], lastJoinedAt: now() };
8484
+ open4 = state;
8485
+ const close = () => {
8486
+ if (open4 === state) open4 = null;
8487
+ };
8488
+ const batch = {
8489
+ settle: async () => {
8490
+ const deadline = now() + maxWaitMs;
8491
+ for (; ; ) {
8492
+ const wait = Math.min(state.lastJoinedAt + quietMs, deadline) - now();
8493
+ if (wait <= 0 || open4 !== state) break;
8494
+ await sleep(wait);
8495
+ }
8496
+ close();
8497
+ },
8498
+ reasons: () => state.reasons
8499
+ };
8500
+ let started;
8501
+ try {
8502
+ started = deps.start(batch);
8503
+ } catch (err) {
8504
+ started = Promise.reject(err);
8505
+ }
8506
+ void started.catch((err) => deps.onError(state.reasons, err)).finally(close);
8507
+ };
8508
+ }
8469
8509
  async function recordStagedSkills(staged, projectDir, skillsDir, names, timeoutMs) {
8470
8510
  for (const name of names) {
8471
8511
  const path11 = join(projectDir, skillsDir, name);
@@ -9563,11 +9603,32 @@ DROP (omit entirely):
9563
9603
  - Redundant back-and-forth (corrections already applied)
9564
9604
  - Transient UI state
9565
9605
 
9606
+ ## Conversation Language
9607
+
9608
+ Write the summary in the language the user writes in, not in English by
9609
+ default. If the user writes German, the whole summary is in German, section
9610
+ headings included. When users write in more than one language, use the
9611
+ language of the most recent message a user wrote before this compaction
9612
+ request (this request itself does not count). Do this even when a previous
9613
+ summary below is in another language: restate it in the conversation's
9614
+ language.
9615
+
9616
+ Keep file paths, code identifiers, commands, error messages and quoted user
9617
+ text exactly as they were -- never translate them.
9618
+
9619
+ Record the language explicitly in the "Conversation Language" section of the
9620
+ summary, so the agent keeps replying in it after the session is restored.
9621
+
9566
9622
  ## Format
9567
9623
 
9568
9624
  Write a structured summary using these sections. Omit any section that
9569
9625
  has no content.
9570
9626
 
9627
+ ### Conversation Language
9628
+ The language the user writes in (for example "German"). Always include this
9629
+ section. If users write in more than one language, name each and say which
9630
+ one to reply in.
9631
+
9571
9632
  ### Goal
9572
9633
  What the user is trying to accomplish.
9573
9634
 
@@ -11084,9 +11145,9 @@ function asDeclaration(declaration) {
11084
11145
  }
11085
11146
  return null;
11086
11147
  }
11087
- function isLive(rm3, id) {
11148
+ function isLive(rm4, id) {
11088
11149
  try {
11089
- return typeof rm3.has === "function" && rm3.has(id);
11150
+ return typeof rm4.has === "function" && rm4.has(id);
11090
11151
  } catch {
11091
11152
  return false;
11092
11153
  }
@@ -11097,8 +11158,8 @@ function toPreMinted(token) {
11097
11158
  function buildSessionResourceHandlers(deps) {
11098
11159
  const { getResourceManager, getPreMintedSecrets, emitResourcesAvailable, log, getProjectDir } = deps;
11099
11160
  async function add(kind, input) {
11100
- const rm3 = getResourceManager();
11101
- if (!rm3) return { ok: false, code: "no_session", message: "session resources not ready" };
11161
+ const rm4 = getResourceManager();
11162
+ if (!rm4) return { ok: false, code: "no_session", message: "session resources not ready" };
11102
11163
  const decl = asDeclaration(input.declaration);
11103
11164
  if (!decl) {
11104
11165
  return { ok: false, code: "invalid_declaration", message: "declaration missing id/driver" };
@@ -11111,14 +11172,14 @@ function buildSessionResourceHandlers(deps) {
11111
11172
  `[session-resource] preMintedToken provided but secret store not ready \u2014 ${kind}:${decl.id}`
11112
11173
  );
11113
11174
  }
11114
- const wasLive = isLive(rm3, decl.id);
11175
+ const wasLive = isLive(rm4, decl.id);
11115
11176
  try {
11116
- await rm3.connect(decl);
11177
+ await rm4.connect(decl);
11117
11178
  } catch (err) {
11118
11179
  if (input.preMintedToken) {
11119
11180
  getPreMintedSecrets()?.unset(kind, decl.id);
11120
11181
  }
11121
- if (wasLive && !isLive(rm3, decl.id)) emitResourcesAvailable();
11182
+ if (wasLive && !isLive(rm4, decl.id)) emitResourcesAvailable();
11122
11183
  const message = err instanceof Error ? err.message : String(err);
11123
11184
  log(`[session-resource] runner.add_${kind} failed for ${decl.id}: ${message}`);
11124
11185
  return { ok: false, code: "connect_failed", message };
@@ -11151,8 +11212,8 @@ function buildSessionResourceHandlers(deps) {
11151
11212
  message: `no materialized connector at ${join(root, name)}`
11152
11213
  };
11153
11214
  }
11154
- const rm3 = getResourceManager();
11155
- if (!rm3) return { ok: false, code: "no_session", message: "session resources not ready" };
11215
+ const rm4 = getResourceManager();
11216
+ if (!rm4) return { ok: false, code: "no_session", message: "session resources not ready" };
11156
11217
  if (preMintedToken) {
11157
11218
  const ps = getPreMintedSecrets();
11158
11219
  if (ps) ps.set("connector", decl.id, toPreMinted(preMintedToken));
@@ -11161,14 +11222,14 @@ function buildSessionResourceHandlers(deps) {
11161
11222
  `[session-resource] preMintedToken provided but secret store not ready \u2014 connector:${decl.id}`
11162
11223
  );
11163
11224
  }
11164
- const wasLive = isLive(rm3, decl.id);
11225
+ const wasLive = isLive(rm4, decl.id);
11165
11226
  try {
11166
- await rm3.connect(decl);
11227
+ await rm4.connect(decl);
11167
11228
  } catch (err) {
11168
11229
  if (preMintedToken) {
11169
11230
  getPreMintedSecrets()?.unset("connector", decl.id);
11170
11231
  }
11171
- if (wasLive && !isLive(rm3, decl.id)) emitResourcesAvailable();
11232
+ if (wasLive && !isLive(rm4, decl.id)) emitResourcesAvailable();
11172
11233
  const message = err instanceof Error ? err.message : String(err);
11173
11234
  log(`[session-resource] runner.attach_instance connector failed for ${decl.id}: ${message}`);
11174
11235
  return { ok: false, code: "connector_connect_failed", message };
@@ -11182,13 +11243,13 @@ function buildSessionResourceHandlers(deps) {
11182
11243
  addMount: (input) => add("mount", input),
11183
11244
  attachConnectorInstance,
11184
11245
  removeResource: async (input) => {
11185
- const rm3 = getResourceManager();
11186
- if (!rm3) return { ok: false, code: "no_session", message: "session resources not ready" };
11187
- if (!rm3.has(input.id)) {
11246
+ const rm4 = getResourceManager();
11247
+ if (!rm4) return { ok: false, code: "no_session", message: "session resources not ready" };
11248
+ if (!rm4.has(input.id)) {
11188
11249
  return { ok: false, code: "not_found", message: `no resource with id ${input.id}` };
11189
11250
  }
11190
11251
  try {
11191
- await rm3.disconnect(input.id);
11252
+ await rm4.disconnect(input.id);
11192
11253
  } catch (err) {
11193
11254
  const message = err instanceof Error ? err.message : String(err);
11194
11255
  log(`[session-resource] runner.remove_resource failed for ${input.id}: ${message}`);
@@ -11204,8 +11265,8 @@ function buildSessionResourceHandlers(deps) {
11204
11265
  updateCredential: async (input) => {
11205
11266
  const ps = getPreMintedSecrets();
11206
11267
  if (!ps) return { ok: false, code: "no_session", message: "session resources not ready" };
11207
- const rm3 = getResourceManager();
11208
- if (rm3 && !rm3.has(input.id)) {
11268
+ const rm4 = getResourceManager();
11269
+ if (rm4 && !rm4.has(input.id)) {
11209
11270
  return { ok: false, code: "not_found", message: `no resource with id ${input.id}` };
11210
11271
  }
11211
11272
  ps.set(input.kind, input.id, input.mint);
@@ -11216,6 +11277,13 @@ function buildSessionResourceHandlers(deps) {
11216
11277
  }
11217
11278
 
11218
11279
  // runner/src/mcp-runtime-handlers.ts
11280
+ function invalidAssetName(name) {
11281
+ if (!name) return "name is required";
11282
+ if (name === "." || name.includes("/") || name.includes("\\") || name.includes("..")) {
11283
+ return "name must not contain path separators or traversal segments";
11284
+ }
11285
+ return null;
11286
+ }
11219
11287
  function buildMcpRuntimeHandlers(deps) {
11220
11288
  const resolveManager = () => {
11221
11289
  try {
@@ -11274,16 +11342,8 @@ function buildMcpRuntimeHandlers(deps) {
11274
11342
  message: `attach_instance supports mcp-server only; '${input.kind}' is not yet supported`
11275
11343
  };
11276
11344
  }
11277
- if (!input.name) {
11278
- return { ok: false, code: "invalid_input", message: "name is required" };
11279
- }
11280
- if (input.name.includes("/") || input.name.includes("\\") || input.name.includes("..")) {
11281
- return {
11282
- ok: false,
11283
- code: "invalid_input",
11284
- message: "name must not contain path separators or traversal segments"
11285
- };
11286
- }
11345
+ const invalidName = invalidAssetName(input.name);
11346
+ if (invalidName) return { ok: false, code: "invalid_input", message: invalidName };
11287
11347
  if (!deps.getProjectDir) {
11288
11348
  return { ok: false, code: "no_project_dir", message: "getProjectDir not configured" };
11289
11349
  }
@@ -11315,6 +11375,65 @@ function buildMcpRuntimeHandlers(deps) {
11315
11375
  const code = err instanceof McpServerAlreadyRegisteredError ? "mcp_already_registered" : "mcp_connect_failed";
11316
11376
  return { ok: false, code, message };
11317
11377
  }
11378
+ },
11379
+ // Order matters: the on-disk asset and the live-attach record go first, so
11380
+ // a session rebuild that starts meanwhile cannot respawn the server.
11381
+ detachInstance: async (input) => {
11382
+ if (input.kind !== "mcp-server") {
11383
+ return {
11384
+ ok: false,
11385
+ code: "unsupported_kind",
11386
+ message: `detach_instance supports mcp-server here; '${input.kind}' is not`
11387
+ };
11388
+ }
11389
+ const invalid = invalidAssetName(input.name);
11390
+ if (invalid) return { ok: false, code: "invalid_input", message: invalid };
11391
+ if (!deps.unregisterLiveAttachedMcp) {
11392
+ return {
11393
+ ok: false,
11394
+ code: "not_implemented",
11395
+ message: "detach_instance for mcp-server is not configured"
11396
+ };
11397
+ }
11398
+ const mgr = resolveManager();
11399
+ if (!mgr) return { ok: false, code: "no_session", message: "session resources not ready" };
11400
+ const id = input.name;
11401
+ if (deps.getProjectDir) {
11402
+ const assetDir = join(deps.getProjectDir(), ".skaile/assets/mcp-server", id);
11403
+ try {
11404
+ await rm(assetDir, { recursive: true, force: true });
11405
+ } catch (err) {
11406
+ const message = err instanceof Error ? err.message : String(err);
11407
+ deps.log(`[mcp-runtime] runner.detach_instance could not remove ${assetDir}: ${message}`);
11408
+ return { ok: false, code: "asset_remove_failed", message };
11409
+ }
11410
+ }
11411
+ deps.unregisterLiveAttachedMcp(id);
11412
+ const wasConnected = mgr.listServers().some((s) => s.id === id);
11413
+ try {
11414
+ await mgr.removeServer(id);
11415
+ } catch (err) {
11416
+ const message = err instanceof Error ? err.message : String(err);
11417
+ deps.log(`[mcp-runtime] runner.detach_instance failed to remove ${id}: ${message}`);
11418
+ return { ok: false, code: "mcp_remove_failed", message };
11419
+ }
11420
+ deps.getPreMintedSecrets()?.unset("mcp", id);
11421
+ let live = true;
11422
+ if (wasConnected && !deps.driverPicksUpToolsLive()) {
11423
+ live = false;
11424
+ try {
11425
+ deps.scheduleDriverRestartForToolChanges(`MCP server '${id}' removal`);
11426
+ } catch (err) {
11427
+ deps.log(
11428
+ `[mcp-runtime] scheduling the restart for ${id} failed: ${err instanceof Error ? err.message : String(err)}`
11429
+ );
11430
+ }
11431
+ }
11432
+ deps.emitResourcesAvailable();
11433
+ deps.log(
11434
+ wasConnected ? `[mcp-runtime] runner.detach_instance removed ${id}${live ? "" : " (driver restart queued)"}` : `[mcp-runtime] runner.detach_instance: ${id} was not connected; records cleared`
11435
+ );
11436
+ return { ok: true, id, removed: wasConnected, live };
11318
11437
  }
11319
11438
  };
11320
11439
  }
@@ -11424,7 +11543,6 @@ function buildRunnerCapabilities(handlers) {
11424
11543
  });
11425
11544
  }
11426
11545
  }),
11427
- // TODO(mcp-detach): no runner.remove_mcp_server yet — live MCP detach + mcp: credential cleanup deferred with the attach-by-ref rework.
11428
11546
  defineCapability({
11429
11547
  name: "runner.add_mcp_server",
11430
11548
  displayName: "Add MCP server",
@@ -11463,7 +11581,7 @@ function buildRunnerCapabilities(handlers) {
11463
11581
  defineCapability({
11464
11582
  name: "runner.detach_instance",
11465
11583
  displayName: "Detach instance",
11466
- description: "Unload an instance the platform unassigned from the live session. Skills only: removes the runner-staged copy and materialized asset, then restarts the driver without killing an in-flight turn. A same-named dir the runner did not stage is left in place (reason: not_staged).",
11584
+ description: "Unload an instance the platform unassigned from the live session. kind 'skill': removes the runner-staged copy and materialized asset, then restarts the driver without killing an in-flight turn; a same-named dir the runner did not stage is left in place (reason: not_staged). kind 'mcp-server': removes the server's tools, its mcp: credential and its materialized asset; restarts the driver (once per burst of detaches) only when the driver cannot drop tools live.",
11467
11585
  side: "agent",
11468
11586
  origin: RUNNER_CAP_ORIGIN,
11469
11587
  audience: ["runtime"],
@@ -11597,6 +11715,7 @@ function wireSessionCapabilities(deps) {
11597
11715
  attachSkillInstance,
11598
11716
  detachSkillInstance,
11599
11717
  registerLiveAttachedMcp,
11718
+ unregisterLiveAttachedMcp,
11600
11719
  scheduleDriverRestartForToolChanges,
11601
11720
  getDriver,
11602
11721
  rememberReconfigure,
@@ -11615,6 +11734,7 @@ function wireSessionCapabilities(deps) {
11615
11734
  getPreMintedSecrets: () => getPreMintedSecrets() ?? null,
11616
11735
  driverPicksUpToolsLive,
11617
11736
  registerLiveAttachedMcp,
11737
+ unregisterLiveAttachedMcp,
11618
11738
  scheduleDriverRestartForToolChanges,
11619
11739
  emitResourcesAvailable,
11620
11740
  log,
@@ -11639,12 +11759,15 @@ function wireSessionCapabilities(deps) {
11639
11759
  message: "attach_instance handler not configured"
11640
11760
  };
11641
11761
  },
11642
- // Only skills have a live unload path; a connector or mount detaches
11643
- // through remove_resource, and MCP servers have no detach yet.
11762
+ // Skills and MCP servers have a live unload path; a connector or mount
11763
+ // detaches through remove_resource.
11644
11764
  detachInstance: async (input) => {
11645
11765
  if (input.kind === "skill") {
11646
11766
  return detachSkillInstance(input.name);
11647
11767
  }
11768
+ if (input.kind === "mcp-server" && mcpHandlers.detachInstance) {
11769
+ return mcpHandlers.detachInstance(input);
11770
+ }
11648
11771
  return {
11649
11772
  ok: false,
11650
11773
  code: "unsupported_kind",
@@ -11653,16 +11776,16 @@ function wireSessionCapabilities(deps) {
11653
11776
  },
11654
11777
  // setLogLevel left undefined (the cap self-falls-back to getLogStore).
11655
11778
  setState: async (input) => {
11656
- const rm3 = getResourceManager();
11657
- if (!rm3) return { ok: false, code: "no_session", message: "session resources not ready" };
11658
- if (!isSharedStateStore(input.store) || !rm3.has(input.store)) {
11779
+ const rm4 = getResourceManager();
11780
+ if (!rm4) return { ok: false, code: "no_session", message: "session resources not ready" };
11781
+ if (!isSharedStateStore(input.store) || !rm4.has(input.store)) {
11659
11782
  return {
11660
11783
  ok: false,
11661
11784
  code: "store_not_found",
11662
11785
  message: `no shared state store "${input.store}" \u2014 declare it in session_init.sharedState`
11663
11786
  };
11664
11787
  }
11665
- const connector = rm3.get(input.store).connector;
11788
+ const connector = rm4.get(input.store).connector;
11666
11789
  if (typeof connector.onStoreChange !== "function") {
11667
11790
  return {
11668
11791
  ok: false,
@@ -11671,7 +11794,7 @@ function wireSessionCapabilities(deps) {
11671
11794
  };
11672
11795
  }
11673
11796
  try {
11674
- await rm3.executeOp(input.store, "set", {
11797
+ await rm4.executeOp(input.store, "set", {
11675
11798
  key: input.key,
11676
11799
  value: typeof input.value === "string" ? JSON.stringify(input.value) : input.value
11677
11800
  });
@@ -13540,6 +13663,12 @@ async function startAgentServer(opts) {
13540
13663
  liveAttachedMcpDeclarations.set(decl.id, decl);
13541
13664
  bakedMcpServerIds = /* @__PURE__ */ new Set([...bakedMcpServerIds, decl.id]);
13542
13665
  };
13666
+ const unregisterLiveAttachedMcp = (id) => {
13667
+ liveAttachedMcpDeclarations.delete(id);
13668
+ if (bakedMcpServerIds.has(id)) {
13669
+ bakedMcpServerIds = new Set([...bakedMcpServerIds].filter((baked) => baked !== id));
13670
+ }
13671
+ };
13543
13672
  const modelEndpointConfig = {
13544
13673
  ...wsConfig.model_endpoint,
13545
13674
  ...opts.modelEndpoint
@@ -13701,6 +13830,7 @@ async function startAgentServer(opts) {
13701
13830
  logPhase
13702
13831
  });
13703
13832
  let driverRestartChain = Promise.resolve();
13833
+ let toolRestartScheduler;
13704
13834
  let liveDriverActiveAfterTurn = false;
13705
13835
  let driver = secretsMode === "env" ? agentSession.driver : void 0;
13706
13836
  let secretsProvisioned = secretsMode === "env";
@@ -14292,6 +14422,7 @@ async function startAgentServer(opts) {
14292
14422
  attachSkillInstance,
14293
14423
  detachSkillInstance,
14294
14424
  registerLiveAttachedMcp,
14425
+ unregisterLiveAttachedMcp,
14295
14426
  scheduleDriverRestartForToolChanges,
14296
14427
  getDriver: () => driver ?? null,
14297
14428
  rememberReconfigure: (patch) => {
@@ -14357,8 +14488,9 @@ async function startAgentServer(opts) {
14357
14488
  }
14358
14489
  return { needsWireFallbackRecreate, needsWireAgentConfigRecreate };
14359
14490
  }
14360
- async function recreateAgentSession(overrides) {
14491
+ async function recreateAgentSession(overrides, opts2) {
14361
14492
  return turnScheduler.runSwap(async () => {
14493
+ await opts2?.settle?.();
14362
14494
  const resolved = typeof overrides === "function" ? overrides() : overrides;
14363
14495
  if (!resolved) return false;
14364
14496
  await recreateAgentSessionInner(resolved);
@@ -14671,20 +14803,27 @@ async function startAgentServer(opts) {
14671
14803
  return detachStagedSkill(skillStagingDeps, name);
14672
14804
  }
14673
14805
  async function restartDriverForToolChanges(reason) {
14806
+ const batch = typeof reason === "string" ? void 0 : reason;
14807
+ const label = () => batch ? batch.reasons().join(", ") : reason;
14674
14808
  if (!driverStarted) {
14675
- log(`[serve] ${reason} applied before driver start \u2014 picked up on the first prompt`);
14809
+ log(`[serve] ${label()} applied before driver start \u2014 picked up on the first prompt`);
14676
14810
  return;
14677
14811
  }
14678
- await recreateAgentSession(() => {
14679
- if (!driverStarted) {
14680
- log(`[serve] ${reason} applied after an earlier recreate \u2014 picked up on the first prompt`);
14681
- return null;
14682
- }
14683
- const prevSessionId = driver.runtimeSessionId;
14684
- log(`[serve] restarting driver to pick up ${reason} (resume=${prevSessionId ?? "none"})`);
14685
- markPhase(`driver restart: ${reason}`);
14686
- return { resumeSessionId: prevSessionId };
14687
- });
14812
+ await recreateAgentSession(
14813
+ () => {
14814
+ if (!driverStarted) {
14815
+ log(
14816
+ `[serve] ${label()} applied after an earlier recreate \u2014 picked up on the first prompt`
14817
+ );
14818
+ return null;
14819
+ }
14820
+ const prevSessionId = driver.runtimeSessionId;
14821
+ log(`[serve] restarting driver to pick up ${label()} (resume=${prevSessionId ?? "none"})`);
14822
+ markPhase(`driver restart: ${label()}`);
14823
+ return { resumeSessionId: prevSessionId };
14824
+ },
14825
+ batch ? { settle: () => batch.settle() } : void 0
14826
+ );
14688
14827
  }
14689
14828
  function enqueueDriverRestart(reason) {
14690
14829
  const next = driverRestartChain.then(() => restartDriverForToolChanges(reason));
@@ -14693,11 +14832,13 @@ async function startAgentServer(opts) {
14693
14832
  return next;
14694
14833
  }
14695
14834
  function scheduleDriverRestartForToolChanges(reason) {
14696
- void enqueueDriverRestart(reason).catch((err) => {
14697
- log(
14698
- `[serve] background driver restart for ${reason} failed: ${err instanceof Error ? err.message : String(err)}`
14699
- );
14835
+ toolRestartScheduler ??= createCoalescedRestartScheduler({
14836
+ start: (batch) => enqueueDriverRestart(batch),
14837
+ onError: (reasons, err) => log(
14838
+ `[serve] background driver restart for ${reasons.join(", ")} failed: ${err instanceof Error ? err.message : String(err)}`
14839
+ )
14700
14840
  });
14841
+ toolRestartScheduler(reason);
14701
14842
  }
14702
14843
  async function restartDriverForSkillChanges(catalogActions) {
14703
14844
  const restarted = driverStarted;
@@ -15814,5 +15955,5 @@ function touchSession(state) {
15814
15955
  }
15815
15956
 
15816
15957
  export { AgentRunError, CLAUDE_CODE_CREDENTIALS_KEY, COMPILE_MANIFEST_FILENAME, CONNECTOR_MUTATE_NOT_READY, CapabilityRegistry, CompileManifestEntrySchema, CompositionError, DEFAULT_CAPABILITY_CALL_TIMEOUT_MS, DEFAULT_COALESCE_MS, DEFAULT_FLOW_MUTATE_CONNECTOR_WAIT_MS, DEFAULT_MAX_FINISHED_TREES, DEFAULT_RUN_LIMITS, MOUNT_LIST_MAX_DEPTH, MOUNT_LIST_MAX_ENTRIES, MOUNT_READ_DEADLINE_FACTOR, MOUNT_READ_MAX_CHUNK_BYTES, MOUNT_STAT_BUDGET_MS, MOUNT_STAT_MAX_ENTRIES, MOUNT_TREE_OP_DEADLINE_FACTOR, MOUNT_WRITE_MAX_CHUNK_BYTES, MarkdownStreamer, PreInitRingSink, ResourceOperationError, SESSION_ROOT_WRITABLE_DIRS, SESSION_ROOT_WRITABLE_FILES, UnknownCompositionKindError, WRITE_RANGE_PARTIAL_TTL_MS, WS_AUTH_TOKEN_ENV, WS_AUTH_TOKEN_FILE_ENV, agentDefinitionExists, bootstrapCapabilityRegistry, bootstrapRunnerLogStore, buildAgentResources, buildClientCapabilityHandler, buildCompositionRunSnapshot, buildConnectorTokenMediator, buildContextSection, buildEnvironmentSection, buildResourcesAvailablePayload, buildRunnerAgentSections, buildStoreSnapshotReplay, builtinCapabilities, canonicalJson, capabilityLogInstance, capabilitySignatureInputs, clearPreInitRingSink, clearSession, compileComposition, compositionRunSnapshotPath, computeCapabilitySignature, computeDirectoryTotals, computeRevisionHash, connectorRefreshKind, createAgentSession, createCompositionContentSource, createFinalTextFallback, createFlowConnectorReadiness, createInMemoryRunStore, createManagedCodexSubpromptDriver, createRunController, createSessionStimulusBus, defineCapability, deleteSession, describeComposition, dispatchResourceRequest, dispatchRunnerCapabilityInvocation, driverActiveAfterTurnEnd, emitSystemPromptComposed, ensureClaudeSettingsDisablesConnectors, ensureGitConfigInclude, executeConnectorMutate, extractClaudeAiOauthExpiresAt, flowStartNeedsDriverRestart, getPreInitRingSink, handleMountResourceRequest, handleResourceRequest, handleSessionRootResourceRequest, hasNonTerminalFlow, hashAgentFiles, hashContent, hostOpResumeStimulus, installPreInitRingSink, instanceForSession, instanceSessionOverrides, isCompositionError, isEmptyKnowledgeIndex, isSessionRootPathAllowed, listSessions, loadAgentManifest, loadCompileManifest, loadCompileManifestFromDir, loadCompositionRunSnapshot, loadKnowledgeDir, loadManagedCodexHostConfig, loadSession, loadSessionById, manifestModelForDriver, mcpAuthSecretKey, newSession, nulTailPaddingLength, pickChatFlowTarget, pickFlowToolTarget, pickRepointedManager, planFlowMutate, prepareCodexTools, reconcilePendingDecisions, reconnectedRunNeedsAgentTurn, recreateKeepingLiveFlows, registerActiveFlow, registerCompositionCapabilities, rejectCapabilityOnApprovalDeny, rejectPendingCapabilityCallsOnDisconnect, resetRunnerLogStore, resolveAgentInstance, resolveBinding, resolveCapabilityCallTimeoutMs, resolveCapabilityResult, resolveComposition, resolveFlowMutateConnectorWaitMs, resolveInstanceAgentDir, resolveMixin, resolveSessionId, restoredRunHasWorkToResume, runAgentChat, saveCompositionRunSnapshot, saveSession, setCurrentSession, setUpFlowConnector, startAgentServer, stimulusFromMetas, stripFrontmatter, takeRunnerWsAuthToken, toActiveFlowTarget, touchSession, unresolvedCredentialNotices, validateInputResponse, verifyConventionItems, writeClaudeCodeCredentialsFile, writeRangeChunk, writeRangePartialPath };
15817
- //# sourceMappingURL=chunk-CQFVKN6S.js.map
15818
- //# sourceMappingURL=chunk-CQFVKN6S.js.map
15958
+ //# sourceMappingURL=chunk-EOKWTN4N.js.map
15959
+ //# sourceMappingURL=chunk-EOKWTN4N.js.map