openmeld 0.3.244 → 0.3.247

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 (116) hide show
  1. package/dist/{add-me-membership-CWS97GK8.js → add-me-membership-DUeJA9q4.js} +2 -2
  2. package/dist/{add-me-membership-CWS97GK8.js.map → add-me-membership-DUeJA9q4.js.map} +1 -1
  3. package/dist/{agents-BoapsuRq.js → agents-woAcH0O6.js} +10 -10
  4. package/dist/{agents-BoapsuRq.js.map → agents-woAcH0O6.js.map} +1 -1
  5. package/dist/{api-client-foundation-BYTxVhem.js → api-client-foundation-DMEfIARh.js} +3 -3
  6. package/dist/{api-client-foundation-BYTxVhem.js.map → api-client-foundation-DMEfIARh.js.map} +1 -1
  7. package/dist/{api-client-foundation-DDdQCc2T.js → api-client-foundation-mqLjUunz.js} +1 -1
  8. package/dist/{auth-session-CpKxiYC2.js → auth-session-D7hlE-47.js} +3 -3
  9. package/dist/{auth-session-CpKxiYC2.js.map → auth-session-D7hlE-47.js.map} +1 -1
  10. package/dist/auth-session-DXxmGll1.js +4 -0
  11. package/dist/{channel-BXovlRXN.js → channel-BeUv2bLR.js} +4 -4
  12. package/dist/{channel-BXovlRXN.js.map → channel-BeUv2bLR.js.map} +1 -1
  13. package/dist/{cli-binary-manifest-ETxqCzfS.js → cli-binary-manifest-ChuzORh3.js} +2 -2
  14. package/dist/{cli-binary-manifest-ETxqCzfS.js.map → cli-binary-manifest-ChuzORh3.js.map} +1 -1
  15. package/dist/{cloud-computer-D2VuZov1.js → cloud-computer-C81_vVOV.js} +4 -4
  16. package/dist/{cloud-computer-D2VuZov1.js.map → cloud-computer-C81_vVOV.js.map} +1 -1
  17. package/dist/{command-BZvpjGWe.js → command-qNknO9gl.js} +16 -16
  18. package/dist/{command-BZvpjGWe.js.map → command-qNknO9gl.js.map} +1 -1
  19. package/dist/{computer-connection-Cd5R-jnA.js → computer-connection-WpsIQfkh.js} +2 -2
  20. package/dist/{computer-connection-Cd5R-jnA.js.map → computer-connection-WpsIQfkh.js.map} +1 -1
  21. package/dist/{computer-connection-review-lBDHLC0c.js → computer-connection-review-Df2G8VWY.js} +5 -5
  22. package/dist/{computer-connection-review-lBDHLC0c.js.map → computer-connection-review-Df2G8VWY.js.map} +1 -1
  23. package/dist/{computer-disconnect-C6OH3940.js → computer-disconnect-ttAH9WgN.js} +7 -7
  24. package/dist/{computer-disconnect-C6OH3940.js.map → computer-disconnect-ttAH9WgN.js.map} +1 -1
  25. package/dist/{computer-setup-continuation-BsSM1pzW.js → computer-setup-continuation-tbuUZSe5.js} +3 -3
  26. package/dist/{computer-setup-continuation-BsSM1pzW.js.map → computer-setup-continuation-tbuUZSe5.js.map} +1 -1
  27. package/dist/{context-BbodhIFX.js → context-x0T_qTHp.js} +4 -4
  28. package/dist/{context-BbodhIFX.js.map → context-x0T_qTHp.js.map} +1 -1
  29. package/dist/{control-plane-TOfZ-veG.js → control-plane-B93wmVS6.js} +2 -2
  30. package/dist/{control-plane-TOfZ-veG.js.map → control-plane-B93wmVS6.js.map} +1 -1
  31. package/dist/{daemon-device-id-DwMFWGI5.js → daemon-device-id-DgwvQllt.js} +5 -5
  32. package/dist/{daemon-device-id-DwMFWGI5.js.map → daemon-device-id-DgwvQllt.js.map} +1 -1
  33. package/dist/{daemon-lifecycle-journal-NJaimyPD.js → daemon-lifecycle-journal-C32I8p4n.js} +7 -6
  34. package/dist/{daemon-lifecycle-journal-NJaimyPD.js.map → daemon-lifecycle-journal-C32I8p4n.js.map} +1 -1
  35. package/dist/{daemon-service-runtime-COC1JtWX.js → daemon-service-runtime-DVqzJKke.js} +4 -4
  36. package/dist/{daemon-service-runtime-COC1JtWX.js.map → daemon-service-runtime-DVqzJKke.js.map} +1 -1
  37. package/dist/{daemon-service-update-coordinator-BmZHGGiO.js → daemon-service-update-coordinator-BTlVzU-7.js} +17 -17
  38. package/dist/daemon-service-update-coordinator-BTlVzU-7.js.map +1 -0
  39. package/dist/{dispatch-owned-runtime-dLHDTL7f.js → dispatch-owned-runtime-g2lLeYtx.js} +211 -65
  40. package/dist/dispatch-owned-runtime-g2lLeYtx.js.map +1 -0
  41. package/dist/dist-CXB_bdSS.js +4 -0
  42. package/dist/{dist-Cu_yzOuS.js → dist-DGeoVaIx.js} +521 -288
  43. package/dist/dist-DGeoVaIx.js.map +1 -0
  44. package/dist/{dual-view-guide-catalog-8Pr5QO_z.js → dual-view-guide-catalog-CkcY09Kh.js} +4 -4
  45. package/dist/{dual-view-guide-catalog-8Pr5QO_z.js.map → dual-view-guide-catalog-CkcY09Kh.js.map} +1 -1
  46. package/dist/{elapsed-time-DCufUrLA.js → elapsed-time-BMG1CU23.js} +4 -4
  47. package/dist/{elapsed-time-DCufUrLA.js.map → elapsed-time-BMG1CU23.js.map} +1 -1
  48. package/dist/{entry-CJ289WR7.js → entry-CP7_Vgs4.js} +7 -7
  49. package/dist/{entry-CJ289WR7.js.map → entry-CP7_Vgs4.js.map} +1 -1
  50. package/dist/{installation-inventory-dvcGmUBg.js → installation-inventory-7JOtUjyG.js} +3 -3
  51. package/dist/{installation-inventory-dvcGmUBg.js.map → installation-inventory-7JOtUjyG.js.map} +1 -1
  52. package/dist/{installer-D0fh4fzg.js → installer-BRpAz1X_.js} +2 -2
  53. package/dist/{installer-D0fh4fzg.js.map → installer-BRpAz1X_.js.map} +1 -1
  54. package/dist/{local-components-DJiMS67S.js → local-components-jXECvlEY.js} +3 -2
  55. package/dist/local-components-jXECvlEY.js.map +1 -0
  56. package/dist/{meta-api-BdH7IJMv.js → meta-api-QskBmfuf.js} +5 -5
  57. package/dist/{meta-api-BdH7IJMv.js.map → meta-api-QskBmfuf.js.map} +1 -1
  58. package/dist/{open-code-permission-DHFJYc_o.js → open-code-permission-B5f1e5an.js} +2 -31
  59. package/dist/open-code-permission-B5f1e5an.js.map +1 -0
  60. package/dist/{openmeld-DQPDws0E.js → openmeld-BxTCCHMn.js} +224 -69
  61. package/dist/openmeld-BxTCCHMn.js.map +1 -0
  62. package/dist/{openmeld-maintenance-worker-ALfbSMyQ.js → openmeld-maintenance-worker-BQ2YbwA9.js} +9 -9
  63. package/dist/{openmeld-maintenance-worker-ALfbSMyQ.js.map → openmeld-maintenance-worker-BQ2YbwA9.js.map} +1 -1
  64. package/dist/{openmeld-tools-update-join-Cezc7ARc.js → openmeld-tools-update-join-Dj-MEQW_.js} +4 -4
  65. package/dist/{openmeld-tools-update-join-Cezc7ARc.js.map → openmeld-tools-update-join-Dj-MEQW_.js.map} +1 -1
  66. package/dist/{openmeld-tools-update-process-frame-YLOS82E3.js → openmeld-tools-update-process-frame-BtYOlJXu.js} +2 -2
  67. package/dist/{openmeld-tools-update-process-frame-YLOS82E3.js.map → openmeld-tools-update-process-frame-BtYOlJXu.js.map} +1 -1
  68. package/dist/{openmeld-tools-update-process-frame-Csy2XKUf.js → openmeld-tools-update-process-frame-CINV6Qt3.js} +1 -1
  69. package/dist/openmeld.js +5 -5
  70. package/dist/{prepare-provider-runtime-Cko0dLXN.js → prepare-provider-runtime-B6_dfpiZ.js} +1679 -1018
  71. package/dist/prepare-provider-runtime-B6_dfpiZ.js.map +1 -0
  72. package/dist/{prepare-session-executor-B-TWlSSd.js → prepare-session-executor-DA9saGAk.js} +19 -19
  73. package/dist/{prepare-session-executor-B-TWlSSd.js.map → prepare-session-executor-DA9saGAk.js.map} +1 -1
  74. package/dist/{process-channel-z_4u04-k.js → process-channel-HthE5ehS.js} +2 -2
  75. package/dist/{process-channel-z_4u04-k.js.map → process-channel-HthE5ehS.js.map} +1 -1
  76. package/dist/{runtime-C6SS6jm6.js → runtime-C7lY_Z2r.js} +104 -21
  77. package/dist/{runtime-C6SS6jm6.js.map → runtime-C7lY_Z2r.js.map} +1 -1
  78. package/dist/{runtime-agent-controller-reporting-submission-Cyb5OuVp.js → runtime-agent-controller-reporting-submission-IhxMO4UA.js} +80 -19
  79. package/dist/runtime-agent-controller-reporting-submission-IhxMO4UA.js.map +1 -0
  80. package/dist/{runtime-transport-DYbpUYBL.js → runtime-transport-DRb5__yP.js} +214 -37
  81. package/dist/runtime-transport-DRb5__yP.js.map +1 -0
  82. package/dist/{service-DjqXdt6p.js → service-DveGEdh3.js} +315 -24
  83. package/dist/service-DveGEdh3.js.map +1 -0
  84. package/dist/{service-account-authorization-BZFLy1E7.js → service-account-authorization-CAVkiKSF.js} +2 -2
  85. package/dist/{service-account-authorization-BZFLy1E7.js.map → service-account-authorization-CAVkiKSF.js.map} +1 -1
  86. package/dist/{service-account-control-CsXtCjRi.js → service-account-control-BtE73wcO.js} +9 -9
  87. package/dist/{service-account-control-CsXtCjRi.js.map → service-account-control-BtE73wcO.js.map} +1 -1
  88. package/dist/{service-control-capabilities-Ck-KcBXg.js → service-control-capabilities-BQrqIGBP.js} +3 -3
  89. package/dist/{service-control-capabilities-Ck-KcBXg.js.map → service-control-capabilities-BQrqIGBP.js.map} +1 -1
  90. package/dist/{service-control-capabilities-C4SOrFHN.js → service-control-capabilities-adDptMIH.js} +1 -1
  91. package/dist/{state-BmiyrHe4.js → state-DWwNdCy5.js} +2 -2
  92. package/dist/{state-BmiyrHe4.js.map → state-DWwNdCy5.js.map} +1 -1
  93. package/dist/{updates-api-DD3p5dx5.js → updates-api-9midbUU1.js} +71 -167
  94. package/dist/updates-api-9midbUU1.js.map +1 -0
  95. package/dist/upgrade-BvpBhL0U.js +4 -0
  96. package/dist/{upgrade-DIt6nkyo.js → upgrade-H-_QW75e.js} +9 -9
  97. package/dist/{upgrade-DIt6nkyo.js.map → upgrade-H-_QW75e.js.map} +1 -1
  98. package/package.json +13 -12
  99. package/skills/openmeld-cli/SKILL.md +5 -2
  100. package/skills/openmeld-cli/playbooks/computer.md +55 -0
  101. package/skills/openmeld-cli/playbooks/plugins.md +37 -0
  102. package/skills/openmeld-cli/references/commands.md +20 -0
  103. package/dist/auth-session-EhHX7q2K.js +0 -4
  104. package/dist/daemon-service-update-coordinator-BmZHGGiO.js.map +0 -1
  105. package/dist/dispatch-owned-runtime-dLHDTL7f.js.map +0 -1
  106. package/dist/dist-BDix0nxy.js +0 -4
  107. package/dist/dist-Cu_yzOuS.js.map +0 -1
  108. package/dist/local-components-DJiMS67S.js.map +0 -1
  109. package/dist/open-code-permission-DHFJYc_o.js.map +0 -1
  110. package/dist/openmeld-DQPDws0E.js.map +0 -1
  111. package/dist/prepare-provider-runtime-Cko0dLXN.js.map +0 -1
  112. package/dist/runtime-agent-controller-reporting-submission-Cyb5OuVp.js.map +0 -1
  113. package/dist/runtime-transport-DYbpUYBL.js.map +0 -1
  114. package/dist/service-DjqXdt6p.js.map +0 -1
  115. package/dist/updates-api-DD3p5dx5.js.map +0 -1
  116. package/dist/upgrade-3z755G8g.js +0 -4
@@ -1,24 +1,24 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { F as resolveOpenMeldRootDir, P as resolveOpenMeldEnvPreset, a as accountProfileWorkspacePath, b as normalizeOpenMeldProfileId, c as deviceOpenClawProfileBootstrapPath, h as isPublishedOpenMeldHome, l as deviceOpenClawProfileDir, n as accountProfileLocalMetaPath, u as deviceOpenClawProfileWorkspaceDir } from "./paths-De9xdA2h.js";
4
- import { Cn as normalizeMessageEnvelope, G as isOriginalErrorSafeForMessageDetails, J as openMeldDaemonProviderAccessEvidenceSchema, W as OPENMELD_ORIGINAL_ERROR_MAX_LENGTH, Wn as agentInteractionResolutionSchema, X as openMeldDaemonTaskResultOpenClawGatewayVisibilityStatusSchema, Y as openMeldDaemonTaskResultEnvelopeWriteSchema, Yr as resolveCommandAgentWorkActivity, bn as formatCanonicalMentionLiteral, t as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, tt as aiUsageObservationSchema } from "./runtime-transport-DYbpUYBL.js";
5
- import { C as conversationExecutionStateSchema, D as normalizeOptionalWorkingDirectory, P as profileWorkspaceModeSchema, T as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, o as openMeldDaemonControlPlaneRequestSchema, s as openMeldDaemonControlPlaneResponseSchema, x as providerDispatchRuntimeContextSchema } from "./control-plane-TOfZ-veG.js";
6
- import { Mi as modelCatalogSchema, Rt as createAgentProfileBindingApi, en as createLocalRuntimeExpectedRoutesApi, t as OpenMeldApiClientHttpError } from "./dist-Cu_yzOuS.js";
4
+ import { G as isOriginalErrorSafeForMessageDetails, J as openMeldDaemonProviderAccessEvidenceSchema, Jn as agentInteractionResolutionSchema, W as OPENMELD_ORIGINAL_ERROR_MAX_LENGTH, X as openMeldDaemonTaskResultOpenClawGatewayVisibilityStatusSchema, Xn as agentControllerPermissionModeSchema, Y as openMeldDaemonTaskResultEnvelopeWriteSchema, ei as resolveCommandAgentWorkActivity, t as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, tt as aiUsageObservationSchema, wn as normalizeMessageEnvelope, xn as formatCanonicalMentionLiteral } from "./runtime-transport-DRb5__yP.js";
5
+ import { C as conversationExecutionStateSchema, D as normalizeOptionalWorkingDirectory, P as profileWorkspaceModeSchema, T as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, o as openMeldDaemonControlPlaneRequestSchema, s as openMeldDaemonControlPlaneResponseSchema, x as providerDispatchRuntimeContextSchema } from "./control-plane-B93wmVS6.js";
6
+ import { Ki as modelCatalogSchema, Rt as createAgentProfileBindingApi, en as createLocalRuntimeExpectedRoutesApi, t as OpenMeldApiClientHttpError } from "./dist-DGeoVaIx.js";
7
7
  import { _ as canonicalizeAgentControllerRef, b as normalizeKnownBuiltinAgentControllerId, d as resolveBuiltinAgentControllerConversationKind, f as HOSTED_CENTER_AGENT_CONTROLLER_REF, g as buildAgentControllerRoutingKey, l as buildAgentControllerConversationRef, m as HOSTED_REMOTE_AGENT_CONTROLLER_REF, p as HOSTED_CENTER_AGENT_CONTROLLER_REF_ID, s as runtimeTransportModeSchema, v as canonicalizeBuiltinAgentControllerRef, x as parseAgentControllerRef$1 } from "./controller-contract-DAOCaefz.js";
8
- import { J as OPENCLAW_CLI_TIMEOUT_MS$1, d as getAuthSessionState } from "./auth-session-CpKxiYC2.js";
8
+ import { J as OPENCLAW_CLI_TIMEOUT_MS$1, d as getAuthSessionState } from "./auth-session-D7hlE-47.js";
9
9
  import { r as daemonServiceLaneSchema } from "./service-contract-CRyDcIIf.js";
10
- import { H as agentExecutionSteerRequestSchema, V as daemonRouteCatalogCacheSchema, _ as toErrorMessage$20, d as normalizeText$11, g as parseTransportMode$1, h as parseStreamingMode$1, m as parseRuntimeTransportMode, p as parseContextIdMappingSpec, s as emitRunLine, u as normalizeOptionalText$51, z as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME } from "./daemon-device-id-DwMFWGI5.js";
11
- import { n as agentControllerPermissionModeSchema, r as agentControllerCollaborationModeSchema } from "./open-code-permission-DHFJYc_o.js";
10
+ import { H as agentExecutionSteerRequestSchema, V as daemonRouteCatalogCacheSchema, _ as toErrorMessage$20, d as normalizeText$11, g as parseTransportMode$1, h as parseStreamingMode$1, m as parseRuntimeTransportMode, p as parseContextIdMappingSpec, s as emitRunLine, u as normalizeOptionalText$49, z as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME } from "./daemon-device-id-DgwvQllt.js";
11
+ import { n as agentControllerCollaborationModeSchema } from "./open-code-permission-B5f1e5an.js";
12
12
  import { c as readWindowsProcessStartFileTime, d as resolveWindowsNativeProcessHelper, f as windowsNativeProcessRequestSchema, l as resolveWindowsPowerShellPath, o as powerShellEncodedArguments, r as isProcessIdentityAlive, t as CURRENT_PROCESS_START_IDENTITY, u as WINDOWS_NATIVE_PROCESS_REQUEST_ENV } from "./process-identity-BRbhGGTM.js";
13
13
  import { a as isOpenMeldOrphanedLockError, d as runWithHeldLock, i as isOpenMeldLockError, t as acquireLock } from "./lock-BMI00i2F.js";
14
14
  import { C as updateConfiguredDeviceRuntimeState, T as updateConfiguredSkillsConfig, a as resolveBaseUrl, d as createDefaultRuntimeAgentControllerSettings, g as getConfiguredSkillsConfig, p as getConfiguredDeviceRuntimeState, v as getRuntimeConfigReadHealth, y as resolveRuntimeSkillsCustomTargetId } from "./base-url-0AoeTi3w.js";
15
15
  import { n as normalizeCommandEnvironment } from "./process-environment-BWSFeUu6.js";
16
- import { F as resolveCurrentOpenMeldAccountContext, _ as touchDaemonCatalogSyncSignal, d as listOpenMeldProfiles } from "./context-BbodhIFX.js";
16
+ import { F as resolveCurrentOpenMeldAccountContext, _ as touchDaemonCatalogSyncSignal, d as listOpenMeldProfiles } from "./context-x0T_qTHp.js";
17
17
  import { n as writeDaemonLocalStateFile, t as readDaemonLocalStateFile } from "./daemon-local-state-file-jOXuXrky.js";
18
18
  import { m as daemonRuntimeDataPath } from "./daemon-state-Dte9re5V.js";
19
- import { d as buildOpenMeldRequestContextFromProfile, t as createCliApiClientFoundation } from "./api-client-foundation-BYTxVhem.js";
19
+ import { d as buildOpenMeldRequestContextFromProfile, t as createCliApiClientFoundation } from "./api-client-foundation-DMEfIARh.js";
20
20
  import { i as readDaemonServiceContract } from "./daemon-service-contract-COPKbCy_.js";
21
- import { C as requestLocalSyncRouteCatalog } from "./daemon-lifecycle-journal-NJaimyPD.js";
21
+ import { C as requestLocalSyncRouteCatalog } from "./daemon-lifecycle-journal-C32I8p4n.js";
22
22
  import { i as resolveWindowsCommandPath, n as quoteWindowsProcessArgument, r as resolvePlatformCommand, t as execPlatformFile } from "./process-launch-B0pHlkV_.js";
23
23
  import { createRequire } from "node:module";
24
24
  import { createHash, randomUUID } from "node:crypto";
@@ -34,6 +34,7 @@ import { setTimeout as setTimeout$1 } from "node:timers/promises";
34
34
  import { connect, createServer } from "node:net";
35
35
  import { createSdkMcpServer, query, tool } from "@anthropic-ai/claude-agent-sdk";
36
36
  import { createOpencodeClient } from "@opencode-ai/sdk/v2";
37
+ import { OpenCode } from "@opencode/client";
37
38
  //#region \0rolldown/runtime.js
38
39
  var __create = Object.create;
39
40
  var __defProp = Object.defineProperty;
@@ -1377,12 +1378,12 @@ const CODEX_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS = [
1377
1378
  description: "Codex asks before editing files outside its working folder or using the internet.",
1378
1379
  label: "Ask for approval",
1379
1380
  requiresExplicitConfirmation: false,
1380
- technicalDetail: "codex -s workspace-write -a untrusted",
1381
+ technicalDetail: "codex -s workspace-write -a on-request -c approvals_reviewer=\"user\"",
1381
1382
  tone: "neutral",
1382
1383
  value: "codex:askForApproval"
1383
1384
  },
1384
1385
  {
1385
- description: "Codex automatically reviews eligible approval requests. It may approve or deny them; denied actions may stop or require a safer approach.",
1386
+ description: "Automatically review actions that need approval. Potentially unsafe actions may be blocked.",
1386
1387
  label: "Approve for me",
1387
1388
  requiresExplicitConfirmation: false,
1388
1389
  technicalDetail: "codex -s workspace-write -a on-request -c approvals_reviewer=\"auto_review\"",
@@ -1390,7 +1391,7 @@ const CODEX_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS = [
1390
1391
  value: "codex:approveForMe"
1391
1392
  },
1392
1393
  {
1393
- description: "Codex bypasses its sandbox and approval prompts for this Agent. Separate file-access limits on this Computer still apply.",
1394
+ description: "Allow internet and file access without Codex approval prompts. This Computer's file-access limits still apply.",
1394
1395
  label: "Full access",
1395
1396
  requiresExplicitConfirmation: true,
1396
1397
  technicalDetail: "codex --dangerously-bypass-approvals-and-sandbox",
@@ -1398,8 +1399,8 @@ const CODEX_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS = [
1398
1399
  value: "codex:fullAccess"
1399
1400
  },
1400
1401
  {
1401
- description: "Codex follows the permissions in config.toml. OpenMeld does not override its sandbox or approval settings.",
1402
- label: "Custom (config.toml)",
1402
+ description: "This Agent keeps its previous permission settings until you choose a mode.",
1403
+ label: "Previous settings",
1403
1404
  requiresExplicitConfirmation: false,
1404
1405
  technicalDetail: "codex (no OpenMeld permission overrides)",
1405
1406
  tone: "neutral",
@@ -1578,7 +1579,7 @@ function resolveNativeAgentControllerPermissionModeForController(value, input) {
1578
1579
  }
1579
1580
  function listAgentControllerPermissionModeOptions(input) {
1580
1581
  const controllerOptions = resolveControllerOptions(input?.agentControllerRef);
1581
- if (controllerOptions) return controllerOptions.map((option) => ({ ...option }));
1582
+ if (controllerOptions) return controllerOptions.filter((option) => option.value !== "codex:customConfig").map((option) => ({ ...option }));
1582
1583
  if (input) return [];
1583
1584
  return [
1584
1585
  ...ANTIGRAVITY_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS,
@@ -1586,10 +1587,10 @@ function listAgentControllerPermissionModeOptions(input) {
1586
1587
  ...CODEX_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS,
1587
1588
  ...CURSOR_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS,
1588
1589
  ...GROK_BUILD_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS
1589
- ].map((option) => ({ ...option }));
1590
+ ].filter((option) => option.value !== "codex:customConfig").map((option) => ({ ...option }));
1590
1591
  }
1591
1592
  function resolveAgentControllerPermissionModeOption(policy, input) {
1592
- return (resolveControllerOptions(input?.agentControllerRef) ?? listAgentControllerPermissionModeOptions()).find((option) => option.value === policy) ?? CLAUDE_CODE_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS[0];
1593
+ return (resolveControllerOptions(input?.agentControllerRef) ?? Object.values(AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS_BY_CONTROLLER_ID).flat()).find((option) => option.value === policy) ?? CLAUDE_CODE_AGENT_CONTROLLER_PERMISSION_MODE_OPTIONS[0];
1593
1594
  }
1594
1595
  function resolveControllerOptions(agentControllerRef) {
1595
1596
  const parsedRef = parseAgentControllerRef(agentControllerRef);
@@ -3908,7 +3909,7 @@ function resolveConversationPolicyFromModelSelection(input) {
3908
3909
  status: "accepted",
3909
3910
  conversationPolicy: {}
3910
3911
  };
3911
- if (parsedRef.kind === "builtin" && parsedRef.id === "codex" && normalizeOptionalText$50(input.agentControllerConversationId)) return {
3912
+ if (parsedRef.kind === "builtin" && parsedRef.id === "codex" && normalizeOptionalText$48(input.agentControllerConversationId)) return {
3912
3913
  status: "accepted",
3913
3914
  conversationPolicy: {}
3914
3915
  };
@@ -3920,7 +3921,7 @@ function resolveConversationPolicyFromModelSelection(input) {
3920
3921
  }
3921
3922
  };
3922
3923
  }
3923
- function normalizeOptionalText$50(value) {
3924
+ function normalizeOptionalText$48(value) {
3924
3925
  const normalized = String(value ?? "").trim();
3925
3926
  return normalized.length > 0 ? normalized : null;
3926
3927
  }
@@ -4915,8 +4916,8 @@ const MACOS_TEMP_FOLDER_RE = /^\/var\/folders\/[^/]+\/[^/]+\/t(?:\/|$)/u;
4915
4916
  const WRAPPER_PATH_SEGMENT_RE = /(?:^|[-_.])(?:shim|shims|wrapper|wrappers)(?:$|[-_.])/u;
4916
4917
  const MAX_LAUNCH_SCRIPT_INSPECTION_BYTES = 64 * 1024;
4917
4918
  const DEFAULT_LOGIN_SHELL_LOOKUP_TIMEOUT_MS = 1500;
4918
- const HOME_DIR = normalizeOptionalText$49(homedir());
4919
- const TEMP_DIR = normalizeOptionalText$49(tmpdir());
4919
+ const HOME_DIR = normalizeOptionalText$47(homedir());
4920
+ const TEMP_DIR = normalizeOptionalText$47(tmpdir());
4920
4921
  const loginShellExecutablePathsCache = /* @__PURE__ */ new Map();
4921
4922
  function buildExecutableLaunchContract(input) {
4922
4923
  return {
@@ -5123,7 +5124,7 @@ function resolveInstalledCommandPath(input) {
5123
5124
  return resolveInstalledCommandPaths(input)[0] ?? null;
5124
5125
  }
5125
5126
  function resolveInstalledCommandPaths(input) {
5126
- const configuredCommand = normalizeOptionalText$49(input.configuredCommand);
5127
+ const configuredCommand = normalizeOptionalText$47(input.configuredCommand);
5127
5128
  if (configuredCommand) {
5128
5129
  if (isAbsolute(configuredCommand)) return [configuredCommand];
5129
5130
  if (configuredCommand.includes("/") || configuredCommand.includes("\\")) return [];
@@ -5132,9 +5133,9 @@ function resolveInstalledCommandPaths(input) {
5132
5133
  return resolveExecutablePathsOnPath(input.commandName);
5133
5134
  }
5134
5135
  async function resolveInstalledCommandPathsForLaunch(input) {
5135
- const preferredCommandPath = normalizeOptionalText$49(input.preferredCommandPath);
5136
+ const preferredCommandPath = normalizeOptionalText$47(input.preferredCommandPath);
5136
5137
  const preferredCommandPaths = preferredCommandPath && isAbsolute(preferredCommandPath) ? [preferredCommandPath] : [];
5137
- const configuredCommand = normalizeOptionalText$49(input.configuredCommand);
5138
+ const configuredCommand = normalizeOptionalText$47(input.configuredCommand);
5138
5139
  if (configuredCommand) {
5139
5140
  if (isAbsolute(configuredCommand)) return mergeUniquePaths(preferredCommandPaths, [configuredCommand]);
5140
5141
  if (configuredCommand.includes("/") || configuredCommand.includes("\\")) return preferredCommandPaths;
@@ -5152,7 +5153,7 @@ function resolveExecutableOnPath(commandName) {
5152
5153
  return resolveExecutablePathsOnPath(commandName)[0] ?? null;
5153
5154
  }
5154
5155
  function resolveExecutablePathsOnPath(commandName) {
5155
- const normalizedCommandName = normalizeOptionalText$49(commandName);
5156
+ const normalizedCommandName = normalizeOptionalText$47(commandName);
5156
5157
  if (!normalizedCommandName) return [];
5157
5158
  const resolvedPaths = [];
5158
5159
  for (const directory of resolvePathDirectories()) for (const candidateName of resolveCommandFileNameCandidates(normalizedCommandName)) {
@@ -5174,7 +5175,7 @@ async function resolveExecutablePathsFromSearchSurface(input) {
5174
5175
  }
5175
5176
  function resolvePathDirectories() {
5176
5177
  const directories = [];
5177
- const pathValue = normalizeOptionalText$49(process.env.PATH);
5178
+ const pathValue = normalizeOptionalText$47(process.env.PATH);
5178
5179
  for (const pathEntry of pathValue?.split(delimiter) ?? []) addUniqueDirectory(directories, pathEntry);
5179
5180
  return directories;
5180
5181
  }
@@ -5185,7 +5186,7 @@ function resolveExecutablePathsFromKnownInstallDirectories(commandName) {
5185
5186
  });
5186
5187
  }
5187
5188
  function resolveExecutablePathsFromDirectories(input) {
5188
- const normalizedCommandName = normalizeOptionalText$49(input.commandName);
5189
+ const normalizedCommandName = normalizeOptionalText$47(input.commandName);
5189
5190
  if (!normalizedCommandName) return [];
5190
5191
  const resolvedPaths = [];
5191
5192
  for (const directory of input.directories) for (const candidateName of resolveCommandFileNameCandidates(normalizedCommandName)) {
@@ -5198,12 +5199,12 @@ function resolveKnownInstallDirectories() {
5198
5199
  const directories = [];
5199
5200
  if (process.platform === "win32") return directories;
5200
5201
  const home = resolveHomeDirectory();
5201
- const nvmDir = normalizeOptionalText$49(process.env.NVM_DIR) ?? join(home, ".nvm");
5202
- const pnpmHome = normalizeOptionalText$49(process.env.PNPM_HOME) ?? (process.platform === "darwin" ? join(home, "Library", "pnpm") : join(home, ".local", "share", "pnpm"));
5203
- const bunHome = normalizeOptionalText$49(process.env.BUN_INSTALL) ?? join(home, ".bun");
5204
- const voltaHome = normalizeOptionalText$49(process.env.VOLTA_HOME) ?? join(home, ".volta");
5205
- const asdfHome = normalizeOptionalText$49(process.env.ASDF_DIR) ?? join(home, ".asdf");
5206
- const fnmHome = normalizeOptionalText$49(process.env.FNM_DIR) ?? join(home, ".fnm");
5202
+ const nvmDir = normalizeOptionalText$47(process.env.NVM_DIR) ?? join(home, ".nvm");
5203
+ const pnpmHome = normalizeOptionalText$47(process.env.PNPM_HOME) ?? (process.platform === "darwin" ? join(home, "Library", "pnpm") : join(home, ".local", "share", "pnpm"));
5204
+ const bunHome = normalizeOptionalText$47(process.env.BUN_INSTALL) ?? join(home, ".bun");
5205
+ const voltaHome = normalizeOptionalText$47(process.env.VOLTA_HOME) ?? join(home, ".volta");
5206
+ const asdfHome = normalizeOptionalText$47(process.env.ASDF_DIR) ?? join(home, ".asdf");
5207
+ const fnmHome = normalizeOptionalText$47(process.env.FNM_DIR) ?? join(home, ".fnm");
5207
5208
  addUniqueDirectory(directories, join(home, ".local", "bin"));
5208
5209
  addUniqueDirectory(directories, "/usr/local/bin");
5209
5210
  addUniqueDirectory(directories, "/opt/homebrew/bin");
@@ -5218,18 +5219,18 @@ function resolveKnownInstallDirectories() {
5218
5219
  addUniqueDirectory(directories, join(home, ".local", "share", "fnm", "aliases", "default", "bin"));
5219
5220
  addUniqueDirectory(directories, join(home, ".local", "share", "fnm", "current", "bin"));
5220
5221
  for (const nvmBinDir of resolveNvmDefaultBinDirectories(nvmDir)) addUniqueDirectory(directories, nvmBinDir);
5221
- const npmConfigPrefix = normalizeOptionalText$49(process.env.NPM_CONFIG_PREFIX);
5222
+ const npmConfigPrefix = normalizeOptionalText$47(process.env.NPM_CONFIG_PREFIX);
5222
5223
  if (npmConfigPrefix) addUniqueDirectory(directories, join(npmConfigPrefix, "bin"));
5223
5224
  return directories;
5224
5225
  }
5225
5226
  function addUniqueDirectory(directories, value) {
5226
- const directory = normalizeOptionalText$49(value);
5227
+ const directory = normalizeOptionalText$47(value);
5227
5228
  if (directory && !directories.includes(directory)) directories.push(directory);
5228
5229
  }
5229
5230
  async function resolveExecutablePathsFromLoginShell(commandName) {
5230
- const normalizedCommandName = normalizeOptionalText$49(commandName);
5231
+ const normalizedCommandName = normalizeOptionalText$47(commandName);
5231
5232
  if (!(normalizedCommandName && process.platform !== "win32")) return [];
5232
- const shell = normalizeOptionalText$49(process.env.SHELL);
5233
+ const shell = normalizeOptionalText$47(process.env.SHELL);
5233
5234
  if (!(shell && isAbsolute(shell) && pathLooksExecutable(shell))) return [];
5234
5235
  const cacheKey = [
5235
5236
  shell,
@@ -5282,7 +5283,7 @@ async function runLoginShellExecutableLookup(input) {
5282
5283
  finish([]);
5283
5284
  return;
5284
5285
  }
5285
- finish(stdout.split(LOGIN_SHELL_OUTPUT_LINE_SPLIT_RE).map((line) => normalizeOptionalText$49(line)).filter((line) => Boolean(line && isAbsolute(line) && pathLooksExecutable(line))));
5286
+ finish(stdout.split(LOGIN_SHELL_OUTPUT_LINE_SPLIT_RE).map((line) => normalizeOptionalText$47(line)).filter((line) => Boolean(line && isAbsolute(line) && pathLooksExecutable(line))));
5286
5287
  });
5287
5288
  });
5288
5289
  }
@@ -5295,7 +5296,7 @@ function resolveNvmDefaultVersion(nvmDir) {
5295
5296
  let value = readNvmAlias(nvmDir, "default");
5296
5297
  const seenAliases = /* @__PURE__ */ new Set();
5297
5298
  for (let depth = 0; depth < 4; depth += 1) {
5298
- const normalizedValue = normalizeOptionalText$49(value);
5299
+ const normalizedValue = normalizeOptionalText$47(value);
5299
5300
  if (!normalizedValue) return null;
5300
5301
  if (isNvmVersionValue(normalizedValue)) return normalizedValue.startsWith("v") ? normalizedValue : `v${normalizedValue}`;
5301
5302
  if (seenAliases.has(normalizedValue)) return null;
@@ -5306,7 +5307,7 @@ function resolveNvmDefaultVersion(nvmDir) {
5306
5307
  }
5307
5308
  function readNvmAlias(nvmDir, alias) {
5308
5309
  try {
5309
- return normalizeOptionalText$49(readFileSync(join(nvmDir, "alias", alias), "utf8"));
5310
+ return normalizeOptionalText$47(readFileSync(join(nvmDir, "alias", alias), "utf8"));
5310
5311
  } catch {
5311
5312
  return null;
5312
5313
  }
@@ -5315,10 +5316,10 @@ function isNvmVersionValue(value) {
5315
5316
  return NVM_VERSION_VALUE_RE.test(value);
5316
5317
  }
5317
5318
  function resolveHomeDirectory() {
5318
- return normalizeOptionalText$49(process.env.HOME) ?? homedir();
5319
+ return normalizeOptionalText$47(process.env.HOME) ?? homedir();
5319
5320
  }
5320
5321
  function resolveLoginShellLookupTimeoutMs() {
5321
- const raw = normalizeOptionalText$49(process.env.OPENMELD_EXECUTABLE_LOGIN_SHELL_TIMEOUT_MS);
5322
+ const raw = normalizeOptionalText$47(process.env.OPENMELD_EXECUTABLE_LOGIN_SHELL_TIMEOUT_MS);
5322
5323
  if (!raw) return DEFAULT_LOGIN_SHELL_LOOKUP_TIMEOUT_MS;
5323
5324
  const parsed = Number.parseInt(raw, 10);
5324
5325
  return Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_LOGIN_SHELL_LOOKUP_TIMEOUT_MS;
@@ -5333,7 +5334,7 @@ function quotePosixShellToken$1(value) {
5333
5334
  return `'${value.replaceAll("'", "'\\''")}'`;
5334
5335
  }
5335
5336
  function resolveSiblingCommandPath(input) {
5336
- const normalizedCommandName = normalizeOptionalText$49(input.commandName);
5337
+ const normalizedCommandName = normalizeOptionalText$47(input.commandName);
5337
5338
  if (!normalizedCommandName) return null;
5338
5339
  const siblingDirectory = dirname(input.anchorPath);
5339
5340
  for (const candidateName of resolveCommandFileNameCandidates(normalizedCommandName)) {
@@ -5343,7 +5344,7 @@ function resolveSiblingCommandPath(input) {
5343
5344
  return null;
5344
5345
  }
5345
5346
  async function resolvePinnedNodePath(input) {
5346
- const firstLine = normalizeOptionalText$49(input.firstLine);
5347
+ const firstLine = normalizeOptionalText$47(input.firstLine);
5347
5348
  if (!firstLine) return null;
5348
5349
  if (firstLine === ENV_NODE_SHEBANG) {
5349
5350
  const nodeSiblings = [join(dirname(input.commandPath), "node"), join(dirname(input.scriptPath), "node")].filter((candidate, index, candidates) => {
@@ -5353,7 +5354,7 @@ async function resolvePinnedNodePath(input) {
5353
5354
  return null;
5354
5355
  }
5355
5356
  if (!firstLine.startsWith("#!")) return null;
5356
- const interpreter = normalizeOptionalText$49(firstLine.slice(2));
5357
+ const interpreter = normalizeOptionalText$47(firstLine.slice(2));
5357
5358
  if (!(interpreter && isAbsolute(interpreter))) return null;
5358
5359
  const normalizedInterpreter = interpreter.split(SHEBANG_ARGS_SPLIT_RE, 1)[0] ?? interpreter;
5359
5360
  try {
@@ -5401,11 +5402,11 @@ function resolveRunnablePathAccessMode() {
5401
5402
  return process.platform === "win32" ? constants.F_OK : constants.X_OK;
5402
5403
  }
5403
5404
  function resolveWindowsPathExtensions(value) {
5404
- const normalized = normalizeOptionalText$49(value);
5405
+ const normalized = normalizeOptionalText$47(value);
5405
5406
  if (!normalized) return [...WINDOWS_PATHEXT];
5406
5407
  return normalized.split(";").map((entry) => entry.trim().toLowerCase()).filter((entry, index, values) => entry && values.indexOf(entry) === index).map((entry) => entry.startsWith(".") ? entry : `.${entry}`);
5407
5408
  }
5408
- function normalizeOptionalText$49(value) {
5409
+ function normalizeOptionalText$47(value) {
5409
5410
  const normalized = String(value ?? "").trim();
5410
5411
  return normalized.length > 0 ? normalized : null;
5411
5412
  }
@@ -5499,7 +5500,7 @@ function shortenPathForDisplay(path) {
5499
5500
  return `~${path.slice(HOME_DIR.length)}`;
5500
5501
  }
5501
5502
  function resolveNodeVersionFromPath(path) {
5502
- return normalizeOptionalText$49(path.match(NODE_VERSION_PATH_RE)?.[1]);
5503
+ return normalizeOptionalText$47(path.match(NODE_VERSION_PATH_RE)?.[1]);
5503
5504
  }
5504
5505
  async function readLaunchScriptInspection(path) {
5505
5506
  const file = await open(path, "r");
@@ -5514,7 +5515,7 @@ async function readLaunchScriptInspection(path) {
5514
5515
  const firstLine = contents.split(FIRST_LINE_SPLIT_RE, 1)[0] ?? "";
5515
5516
  return {
5516
5517
  contents,
5517
- firstLine: normalizeOptionalText$49(firstLine)
5518
+ firstLine: normalizeOptionalText$47(firstLine)
5518
5519
  };
5519
5520
  }
5520
5521
  function isTransientPathWrapper(input) {
@@ -5531,7 +5532,7 @@ function hasWrapperPathSegment(path) {
5531
5532
  return normalizePathForDetection(path).split("/").filter((segment) => segment.length > 0).slice(-4).some((segment) => WRAPPER_PATH_SEGMENT_RE.test(segment));
5532
5533
  }
5533
5534
  function shellScriptLooksLikeWrapper(input) {
5534
- const firstLine = normalizeOptionalText$49(input.firstLine)?.toLowerCase() ?? "";
5535
+ const firstLine = normalizeOptionalText$47(input.firstLine)?.toLowerCase() ?? "";
5535
5536
  if (!(firstLine.includes("bash") || firstLine.includes("/sh") || firstLine.includes("zsh"))) return false;
5536
5537
  const contents = input.contents.toLowerCase();
5537
5538
  return contents.includes("wrapper_shim") || contents.includes("shim_root") || contents.includes("\nexec ") && (contents.includes("wrapper") || contents.includes("shim"));
@@ -5900,7 +5901,7 @@ var AcpProcessSession = class {
5900
5901
  let code = "protocol.request_failed";
5901
5902
  if (error.code === -32601) code = "protocol.method_not_found";
5902
5903
  else if (error.code === -32602) code = "protocol.invalid_params";
5903
- const message = normalizeOptionalText$48(error.message) ?? "ACP request failed";
5904
+ const message = normalizeOptionalText$46(error.message) ?? "ACP request failed";
5904
5905
  return this.#error({
5905
5906
  code,
5906
5907
  errorType: "adapter",
@@ -5978,7 +5979,7 @@ var AcpProcessSession = class {
5978
5979
  return this.#createError(input);
5979
5980
  }
5980
5981
  };
5981
- function normalizeOptionalText$48(value) {
5982
+ function normalizeOptionalText$46(value) {
5982
5983
  const normalized = String(value ?? "").trim();
5983
5984
  return normalized.length > 0 ? normalized : null;
5984
5985
  }
@@ -6170,18 +6171,18 @@ function extractAcpToolActivityObservation(value) {
6170
6171
  if (message?.method !== "session/update") return null;
6171
6172
  const params = toRecord$15(message.params);
6172
6173
  const update = toRecord$15(params?.update);
6173
- const updateType = normalizeOptionalText$47(update?.sessionUpdate);
6174
+ const updateType = normalizeOptionalText$45(update?.sessionUpdate);
6174
6175
  if (!(update && (updateType === "tool_call" || updateType === "tool_call_update"))) return null;
6175
- const toolCallId = normalizeOptionalText$47(update.toolCallId ?? update.tool_call_id);
6176
+ const toolCallId = normalizeOptionalText$45(update.toolCallId ?? update.tool_call_id);
6176
6177
  if (!toolCallId) return null;
6177
- const sessionId = normalizeOptionalText$47(params?.sessionId);
6178
+ const sessionId = normalizeOptionalText$45(params?.sessionId);
6178
6179
  return {
6179
6180
  ...Object.hasOwn(update, "rawInput") ? { providerInput: update.rawInput } : {},
6180
- providerKind: normalizeOptionalText$47(update.kind),
6181
+ providerKind: normalizeOptionalText$45(update.kind),
6181
6182
  ...Object.hasOwn(update, "locations") ? { providerLocations: update.locations } : {},
6182
- providerTitle: normalizeOptionalText$47(update.title ?? update.name),
6183
+ providerTitle: normalizeOptionalText$45(update.title ?? update.name),
6183
6184
  scopedToolCallId: sessionId ? `${sessionId}\0${toolCallId}` : toolCallId,
6184
- status: normalizeOptionalText$47(update.status)?.toLowerCase() ?? null,
6185
+ status: normalizeOptionalText$45(update.status)?.toLowerCase() ?? null,
6185
6186
  toolCallId
6186
6187
  };
6187
6188
  }
@@ -6224,11 +6225,11 @@ function readFilePath(value) {
6224
6225
  value.filePath,
6225
6226
  value.path
6226
6227
  ]) {
6227
- const path = normalizeOptionalText$47(candidate);
6228
+ const path = normalizeOptionalText$45(candidate);
6228
6229
  if (path) return path;
6229
6230
  }
6230
6231
  if (Array.isArray(value.changes)) for (const change of value.changes) {
6231
- const path = normalizeOptionalText$47(toRecord$15(change)?.path);
6232
+ const path = normalizeOptionalText$45(toRecord$15(change)?.path);
6232
6233
  if (path) return path;
6233
6234
  }
6234
6235
  return null;
@@ -6236,7 +6237,7 @@ function readFilePath(value) {
6236
6237
  function readLocationPath(value) {
6237
6238
  if (!Array.isArray(value)) return null;
6238
6239
  for (const location of value) {
6239
- const path = normalizeOptionalText$47(toRecord$15(location)?.path);
6240
+ const path = normalizeOptionalText$45(toRecord$15(location)?.path);
6240
6241
  if (path) return path;
6241
6242
  }
6242
6243
  return null;
@@ -6257,7 +6258,7 @@ function resolveToolActivityState$1(current, status) {
6257
6258
  if (status === "completed") return "output-available";
6258
6259
  return "input-available";
6259
6260
  }
6260
- function normalizeOptionalText$47(value) {
6261
+ function normalizeOptionalText$45(value) {
6261
6262
  const normalized = typeof value === "string" ? value.trim() : "";
6262
6263
  return normalized.length > 0 ? normalized : null;
6263
6264
  }
@@ -6352,10 +6353,10 @@ const OPENMELD_CLI_COMMANDS = /* @__PURE__ */ new Set([
6352
6353
  "openmeld-canary"
6353
6354
  ]);
6354
6355
  function resolveDispatchSpaceActionMcpServer(env) {
6355
- if (!normalizeOptionalText$46(env?.[SPACE_ACTION_CONTEXT_PATH_ENV])) return null;
6356
- const command = normalizeOptionalText$46(env?.[USER_FACING_CLI_COMMAND_ENV]);
6356
+ if (!normalizeOptionalText$44(env?.[SPACE_ACTION_CONTEXT_PATH_ENV])) return null;
6357
+ const command = normalizeOptionalText$44(env?.[USER_FACING_CLI_COMMAND_ENV]);
6357
6358
  if (!(command && OPENMELD_CLI_COMMANDS.has(command))) throw new Error("OpenMeld cannot start the dispatch Space Action tool because the active CLI command is invalid.");
6358
- const commandPath = normalizeOptionalText$46(env?.[SPACE_ACTION_TOOL_COMMAND_PATH_ENV]);
6359
+ const commandPath = normalizeOptionalText$44(env?.[SPACE_ACTION_TOOL_COMMAND_PATH_ENV]);
6359
6360
  if (!(commandPath && isAbsolute(commandPath) && (basename(commandPath) === command || basename(commandPath) === `${command}.exe`))) throw new Error("OpenMeld cannot start the dispatch Space Action tool because its dispatch-owned CLI path is invalid.");
6360
6361
  return {
6361
6362
  args: [
@@ -6366,7 +6367,7 @@ function resolveDispatchSpaceActionMcpServer(env) {
6366
6367
  command,
6367
6368
  commandPath,
6368
6369
  env: Object.fromEntries(FORWARDED_ENV_NAMES.flatMap((name) => {
6369
- const value = normalizeOptionalText$46(env?.[name]);
6370
+ const value = normalizeOptionalText$44(env?.[name]);
6370
6371
  return value ? [[name, value]] : [];
6371
6372
  })),
6372
6373
  id: OPENMELD_SPACE_ACTION_MCP_SERVER_ID,
@@ -6397,7 +6398,7 @@ function buildAcpDispatchSpaceActionMcpServers(env) {
6397
6398
  name: config.id
6398
6399
  }];
6399
6400
  }
6400
- function normalizeOptionalText$46(value) {
6401
+ function normalizeOptionalText$44(value) {
6401
6402
  const normalized = String(value ?? "").trim();
6402
6403
  return normalized.length > 0 ? normalized : null;
6403
6404
  }
@@ -6446,9 +6447,9 @@ const buildProviderExitError = (input) => {
6446
6447
  };
6447
6448
  };
6448
6449
  const hasVisibleText = (value) => {
6449
- return normalizeOptionalText$45(value) !== null;
6450
+ return normalizeOptionalText$43(value) !== null;
6450
6451
  };
6451
- const normalizeOptionalText$45 = (value) => {
6452
+ const normalizeOptionalText$43 = (value) => {
6452
6453
  if (typeof value !== "string") return null;
6453
6454
  const normalized = value.trim();
6454
6455
  return normalized.length > 0 ? normalized : null;
@@ -6645,13 +6646,13 @@ var AdapterRepairConversationError = class extends Error {
6645
6646
  };
6646
6647
  const resolveRequiredRepairConversationId = (input) => {
6647
6648
  if (input.policy !== "require_canonical" || input.request.executionMode !== "repair") return null;
6648
- const canonicalConversationId = normalizeOptionalText$44(input.invokeRequest.agentControllerConversationId);
6649
+ const canonicalConversationId = normalizeOptionalText$42(input.invokeRequest.agentControllerConversationId);
6649
6650
  if (!canonicalConversationId) throw new AdapterRepairConversationMissingError();
6650
6651
  return canonicalConversationId;
6651
6652
  };
6652
6653
  const requireCanonicalRepairConversation = (input) => {
6653
6654
  if (!input.canonicalConversationId) return input.contextDelta;
6654
- const observedConversationId = normalizeOptionalText$44(input.contextDelta?.agentControllerConversationId);
6655
+ const observedConversationId = normalizeOptionalText$42(input.contextDelta?.agentControllerConversationId);
6655
6656
  if (input.contextDelta?.refreshed === true || observedConversationId !== input.canonicalConversationId) throw new AdapterRepairConversationError();
6656
6657
  return input.contextDelta;
6657
6658
  };
@@ -7041,13 +7042,13 @@ const buildDefaultInvokeRequest = (input) => {
7041
7042
  agentControllerConversationId: input.request.agentControllerConversationId,
7042
7043
  bridgeSpec: input.bridgeSpec,
7043
7044
  agentControllerConversation: input.request.agentControllerConversation
7044
- }) : normalizeOptionalText$44(input.request.agentControllerConversationId);
7045
+ }) : normalizeOptionalText$42(input.request.agentControllerConversationId);
7045
7046
  return {
7046
7047
  ...input.request,
7047
7048
  agentControllerConversationId
7048
7049
  };
7049
7050
  };
7050
- const normalizeOptionalText$44 = (value) => {
7051
+ const normalizeOptionalText$42 = (value) => {
7051
7052
  if (typeof value !== "string") return null;
7052
7053
  const normalized = value.trim();
7053
7054
  return normalized.length > 0 ? normalized : null;
@@ -8303,7 +8304,7 @@ const removeConversationExecutionState = (input) => {
8303
8304
  return nextState;
8304
8305
  };
8305
8306
  const seedLegacyAgentContext = (input) => {
8306
- const normalizedLegacyAgentControllerConversationId = normalizeOptionalText$43(input.legacyAgentControllerConversationId);
8307
+ const normalizedLegacyAgentControllerConversationId = normalizeOptionalText$41(input.legacyAgentControllerConversationId);
8307
8308
  if (!normalizedLegacyAgentControllerConversationId) return input.state;
8308
8309
  if (input.state.agentContextByLookupKey[input.agentContextLookupKey]) return input.state;
8309
8310
  return upsertAgentContext({
@@ -8323,7 +8324,7 @@ const seedLegacyAgentContext = (input) => {
8323
8324
  });
8324
8325
  };
8325
8326
  const commitResolvedAgentContext = (input) => {
8326
- const normalizedAgentControllerConversationId = normalizeOptionalText$43(input.agentControllerConversationId);
8327
+ const normalizedAgentControllerConversationId = normalizeOptionalText$41(input.agentControllerConversationId);
8327
8328
  if (!normalizedAgentControllerConversationId) return input.state;
8328
8329
  const existing = input.state.agentContextByLookupKey[input.agentContextLookupKey] ?? null;
8329
8330
  return upsertAgentContext({
@@ -8361,7 +8362,7 @@ const appendAgentContextRotationRecord = (input) => {
8361
8362
  nextState.updatedAtMs = Date.now();
8362
8363
  return nextState;
8363
8364
  };
8364
- function normalizeOptionalText$43(value) {
8365
+ function normalizeOptionalText$41(value) {
8365
8366
  if (typeof value !== "string") return null;
8366
8367
  const normalized = value.trim();
8367
8368
  return normalized.length > 0 ? normalized : null;
@@ -9273,10 +9274,383 @@ function emitStructuredReconcileEvidence(eventName, payload) {
9273
9274
  });
9274
9275
  }
9275
9276
  //#endregion
9277
+ //#region ../../runtime/adapters/antigravity/dist/transport/antigravity-acp-interactions.js
9278
+ const CANCELLED = { outcome: { outcome: "cancelled" } };
9279
+ async function answerAntigravityAcpInteraction(request, callback, signal) {
9280
+ if (!(callback && request.toolCall && Array.isArray(request.options))) return CANCELLED;
9281
+ const options = request.options;
9282
+ if (!options.length || options.length > 20 || options.some((option) => !option.optionId || option.optionId.length > 256) || new Set(options.map((option) => option.optionId)).size !== options.length) return CANCELLED;
9283
+ if (signal?.aborted) return CANCELLED;
9284
+ const stopped = Promise.withResolvers();
9285
+ const onAbort = () => stopped.resolve(void 0);
9286
+ signal?.addEventListener("abort", onAbort, { once: true });
9287
+ let selected;
9288
+ try {
9289
+ selected = await Promise.race([request.toolCall.toolCallId.startsWith("interaction_") ? answerQuestion(request, callback) : answerPermission(request, callback), stopped.promise]);
9290
+ } finally {
9291
+ signal?.removeEventListener("abort", onAbort);
9292
+ }
9293
+ return selected && options.some((option) => option.optionId === selected) ? { outcome: {
9294
+ outcome: "selected",
9295
+ optionId: selected
9296
+ } } : CANCELLED;
9297
+ }
9298
+ async function answerQuestion(request, callback) {
9299
+ const response = await callback({
9300
+ kind: "question",
9301
+ title: "Antigravity needs your input",
9302
+ questions: [{
9303
+ questionId: "choice",
9304
+ prompt: (request.toolCall.title || "Choose an option.").slice(0, 4e3),
9305
+ allowOther: false,
9306
+ multiple: false,
9307
+ options: request.options.map((option) => ({
9308
+ optionId: option.optionId,
9309
+ label: option.name.slice(0, 240)
9310
+ }))
9311
+ }]
9312
+ });
9313
+ if (response.kind !== "question") return;
9314
+ const values = response.answers.find((answer) => answer.questionId === "choice")?.values;
9315
+ return values?.length === 1 ? values[0] : void 0;
9316
+ }
9317
+ async function answerPermission(request, callback) {
9318
+ const choices = request.options.flatMap((option) => {
9319
+ const intent = permissionIntent(option.kind);
9320
+ return intent ? [{
9321
+ optionId: option.optionId,
9322
+ intent,
9323
+ label: intent === "allow_session" ? "Allow for this conversation" : option.name.slice(0, 240)
9324
+ }] : [];
9325
+ });
9326
+ if (!choices.length) return;
9327
+ const response = await callback({
9328
+ kind: "permission",
9329
+ title: "Antigravity needs permission",
9330
+ description: [request.toolCall.title, ...request.options.flatMap(securityWarning)].filter(Boolean).join("\n").slice(0, 4e3),
9331
+ subject: { type: permissionSubject$1(request.toolCall.kind) },
9332
+ options: choices
9333
+ });
9334
+ return response.kind === "permission" && choices.some((option) => option.optionId === response.optionId) ? response.optionId : void 0;
9335
+ }
9336
+ function permissionIntent(kind) {
9337
+ switch (kind) {
9338
+ case "allow_once": return "allow_once";
9339
+ case "allow_always": return "allow_session";
9340
+ case "reject_once":
9341
+ case "reject_always": return "deny";
9342
+ default: return null;
9343
+ }
9344
+ }
9345
+ function permissionSubject$1(kind) {
9346
+ if (kind === "execute") return "command";
9347
+ return [
9348
+ "edit",
9349
+ "delete",
9350
+ "move"
9351
+ ].includes(kind ?? "") ? "file_change" : "tool";
9352
+ }
9353
+ function securityWarning(option) {
9354
+ const warning = option._meta?.["agy.security.warning"];
9355
+ if (!warning || typeof warning !== "object" || Array.isArray(warning)) return [];
9356
+ const record = warning;
9357
+ const value = record.message ?? record.title;
9358
+ return typeof value === "string" ? [value] : [];
9359
+ }
9360
+ //#endregion
9361
+ //#region ../../runtime/adapters/antigravity/dist/transport/antigravity-acp-transport.js
9362
+ function isAntigravityAcpLaunchContract(launch) {
9363
+ const path = launch.kind === "node_script" ? launch.scriptPath : launch.commandPath;
9364
+ return ["agy_acp_server.par", "agy_acp_server.exe"].includes(basename(path).toLowerCase());
9365
+ }
9366
+ function acpError(input) {
9367
+ if (input.code === "protocol.invalid" && input.message.includes("Open the following link to authenticate")) return Object.assign(/* @__PURE__ */ new Error("Sign in to Antigravity ACP, then try again."), {
9368
+ code: "auth.required",
9369
+ errorType: "auth"
9370
+ });
9371
+ return Object.assign(new Error(input.message, { cause: input.cause }), {
9372
+ code: input.code,
9373
+ errorType: input.errorType
9374
+ });
9375
+ }
9376
+ function acpEnvironment(launch, env) {
9377
+ const harness = join(dirname(launch.kind === "node_script" ? launch.scriptPath : launch.commandPath), process.platform === "win32" ? "localharness_external.exe" : "localharness_external");
9378
+ return {
9379
+ ...env,
9380
+ ...existsSync(harness) ? { ANTIGRAVITY_HARNESS_PATH: harness } : {},
9381
+ BROWSER: process.platform === "win32" ? "cmd /c exit 1" : "/usr/bin/false",
9382
+ PYTHONUNBUFFERED: "1"
9383
+ };
9384
+ }
9385
+ const initializeParams = {
9386
+ protocolVersion: 1,
9387
+ clientInfo: {
9388
+ name: "openmeld",
9389
+ version: "1"
9390
+ },
9391
+ clientCapabilities: {
9392
+ fs: {
9393
+ readTextFile: false,
9394
+ writeTextFile: false
9395
+ },
9396
+ terminal: false
9397
+ }
9398
+ };
9399
+ function readInitialize(value) {
9400
+ const result = value;
9401
+ if (!result || result.protocolVersion !== 1 || !result.agentCapabilities) throw acpError({
9402
+ code: "protocol.invalid",
9403
+ errorType: "adapter",
9404
+ message: "Antigravity did not negotiate ACP version 1."
9405
+ });
9406
+ return result;
9407
+ }
9408
+ async function admissionRequest(process, method, params) {
9409
+ const authentication = method === "authenticate";
9410
+ const timer = setTimeout(() => process.fail(acpError({
9411
+ code: authentication ? "auth.required" : "protocol.timeout",
9412
+ errorType: authentication ? "auth" : "timeout",
9413
+ message: authentication ? "Sign in to Antigravity ACP, then try again." : "Antigravity did not finish starting its ACP session."
9414
+ })), 15e3);
9415
+ try {
9416
+ return await process.request(method, params);
9417
+ } finally {
9418
+ clearTimeout(timer);
9419
+ }
9420
+ }
9421
+ async function probeAntigravityAcp(input) {
9422
+ const process = new AcpProcessSession({
9423
+ args: [],
9424
+ cwd: input.cwd,
9425
+ env: acpEnvironment(input.launchContract),
9426
+ launchContract: input.launchContract,
9427
+ createError: acpError,
9428
+ processLabel: "Antigravity",
9429
+ timeoutMs: input.timeoutMs ?? 15e3
9430
+ });
9431
+ try {
9432
+ process.start();
9433
+ return readInitialize(await process.request("initialize", initializeParams));
9434
+ } finally {
9435
+ await process.close();
9436
+ }
9437
+ }
9438
+ async function invokeAntigravityAcpTransport(input) {
9439
+ const { request } = input;
9440
+ if (isDispatchSpaceActionDeliveryOnly(request.env) || request.executionMode === "repair") throw acpError({
9441
+ code: "delivery_scope.unsupported",
9442
+ errorType: "config",
9443
+ message: "Antigravity ACP does not expose an exclusive reply-repair tool scope."
9444
+ });
9445
+ const invokedAtMs = Date.now();
9446
+ const interactions = new AbortController();
9447
+ let sessionId = null;
9448
+ let turnActive = false;
9449
+ let output = "";
9450
+ let firstOutputAtMs = null;
9451
+ let previewEmitted = false;
9452
+ let callbackFailure;
9453
+ let callbacks = Promise.resolve();
9454
+ const tracker = createAcpToolActivityTracker();
9455
+ const process = new AcpProcessSession({
9456
+ args: [],
9457
+ cwd: request.runtimeContext.providerRuntimeWorkingDirectory,
9458
+ env: acpEnvironment(input.launchContract, request.env),
9459
+ launchContract: input.launchContract,
9460
+ createError: acpError,
9461
+ processLabel: "Antigravity",
9462
+ timeoutMs: request.timeoutMs ?? null,
9463
+ mapJsonRpcError: (error) => {
9464
+ const message = error.message ?? "Antigravity rejected the request.";
9465
+ if (error.code === -32e3 || AUTH_ERROR_RE.test(message)) return acpError({
9466
+ code: "auth.required",
9467
+ errorType: "auth",
9468
+ message
9469
+ });
9470
+ return acpError({
9471
+ code: CONTEXT_ERROR_RE.test(message) ? "context_not_found" : "protocol.request_failed",
9472
+ errorType: "adapter",
9473
+ message
9474
+ });
9475
+ },
9476
+ onProcessControlEvent: (event) => {
9477
+ if (event.phase === "process_exit") interactions.abort();
9478
+ input.onProcessControlEvent?.(event);
9479
+ },
9480
+ onClientRequest: async ({ method, params }) => {
9481
+ if (method !== "session/request_permission") return { error: {
9482
+ code: -32601,
9483
+ message: `Unsupported ACP client method: ${method}`
9484
+ } };
9485
+ const permission = params;
9486
+ if (!turnActive || permission?.sessionId !== sessionId) return { result: { outcome: { outcome: "cancelled" } } };
9487
+ if (!request.onInteractionRequest) {
9488
+ process.fail(acpError({
9489
+ code: "interaction.required",
9490
+ errorType: "adapter",
9491
+ message: "Antigravity needs user input, but this run has no interaction channel."
9492
+ }));
9493
+ return { result: { outcome: { outcome: "cancelled" } } };
9494
+ }
9495
+ return { result: await answerAntigravityAcpInteraction(permission, request.onInteractionRequest, interactions.signal) };
9496
+ },
9497
+ onNotification: (notification) => {
9498
+ if (notification.method !== "session/update") return;
9499
+ const params = notification.params;
9500
+ if (!turnActive || params?.sessionId !== sessionId || !params.update) return;
9501
+ callbacks = callbacks.then(async () => {
9502
+ const update = params.update;
9503
+ const activity = tracker.observe(notification);
9504
+ if (activity) await request.onRuntimeEvent?.(activity);
9505
+ if (update.sessionUpdate === "agent_message_chunk" && update.content.type === "text") {
9506
+ output += update.content.text;
9507
+ firstOutputAtMs ??= Date.now();
9508
+ if (request.streamingMode === "stream" && request.onPreview) {
9509
+ await request.onPreview({ text: output });
9510
+ previewEmitted = true;
9511
+ }
9512
+ }
9513
+ if (update.sessionUpdate === "agent_thought_chunk" && update.content.type === "text") await request.onRuntimeEvent?.({
9514
+ phase: "reasoning",
9515
+ blockId: "antigravity-thought",
9516
+ mode: "append",
9517
+ text: update.content.text,
9518
+ tsMs: Date.now()
9519
+ });
9520
+ }).catch((error) => {
9521
+ callbackFailure = error;
9522
+ process.fail(error);
9523
+ });
9524
+ }
9525
+ });
9526
+ try {
9527
+ process.start();
9528
+ sessionId = await configureSession(process, input);
9529
+ input.registerCancel?.(() => {
9530
+ interactions.abort();
9531
+ process.notify("session/cancel", { sessionId });
9532
+ return Promise.resolve();
9533
+ });
9534
+ turnActive = true;
9535
+ const prompt = request.instructionPrompt ? `${request.instructionPrompt.developerInstructions}\n\n${request.instructionPrompt.userPrompt}` : request.prompt;
9536
+ const result = await process.request("session/prompt", {
9537
+ sessionId,
9538
+ prompt: [{
9539
+ type: "text",
9540
+ text: prompt
9541
+ }]
9542
+ });
9543
+ await callbacks;
9544
+ if (callbackFailure) throw callbackFailure;
9545
+ if (result.stopReason !== "end_turn") throw acpError({
9546
+ code: result.stopReason === "cancelled" ? "runtime.interrupted" : "runtime.incomplete",
9547
+ errorType: "adapter",
9548
+ message: `Antigravity ended the turn: ${result.stopReason}`
9549
+ });
9550
+ if (request.streamingMode !== "stream" && request.onPreview && output) {
9551
+ await request.onPreview({ text: output });
9552
+ previewEmitted = true;
9553
+ }
9554
+ return {
9555
+ sessionId,
9556
+ output,
9557
+ telemetry: process.buildTelemetry({
9558
+ invokedAtMs,
9559
+ firstOutputAtMs,
9560
+ previewEmitted,
9561
+ resumedContext: input.sessionId !== null,
9562
+ streamingMode: request.streamingMode ?? "final"
9563
+ })
9564
+ };
9565
+ } finally {
9566
+ turnActive = false;
9567
+ interactions.abort();
9568
+ await process.close();
9569
+ }
9570
+ }
9571
+ async function configureSession(process, input) {
9572
+ const { request } = input;
9573
+ const initialized = readInitialize(await admissionRequest(process, "initialize", initializeParams));
9574
+ const methodId = request.env?.OPENMELD_ANTIGRAVITY_ACP_AUTH_METHOD ?? "oauth-personal";
9575
+ if (!initialized.authMethods?.some((method) => method.id === methodId)) throw acpError({
9576
+ code: "auth.method_unavailable",
9577
+ errorType: "auth",
9578
+ message: `Antigravity does not offer authentication method '${methodId}'.`
9579
+ });
9580
+ await admissionRequest(process, "authenticate", { methodId });
9581
+ if (input.sessionId && !initialized.agentCapabilities?.sessionCapabilities?.resume) throw acpError({
9582
+ code: "context.resume_unsupported",
9583
+ errorType: "adapter",
9584
+ message: "This Antigravity version cannot resume ACP conversations."
9585
+ });
9586
+ const descriptor = await admissionRequest(process, input.sessionId ? "session/resume" : "session/new", {
9587
+ cwd: request.runtimeContext.providerRuntimeWorkingDirectory,
9588
+ mcpServers: buildAcpDispatchSpaceActionMcpServers(request.env),
9589
+ ...input.sessionId ? { sessionId: input.sessionId } : {}
9590
+ });
9591
+ const sessionId = input.sessionId ?? descriptor?.sessionId;
9592
+ if (!sessionId) throw acpError({
9593
+ code: "protocol.invalid",
9594
+ errorType: "adapter",
9595
+ message: "Antigravity did not return a conversation identifier."
9596
+ });
9597
+ await request.onRuntimeEvent?.({
9598
+ phase: "provider_conversation_observed",
9599
+ agentControllerConversationId: sessionId,
9600
+ tsMs: Date.now()
9601
+ });
9602
+ const mode = resolveAcpMode(request.agentControllerPermissionMode);
9603
+ if (!descriptor.modes?.availableModes.some((value) => value.id === mode)) throw acpError({
9604
+ code: "permission.mode_unsupported",
9605
+ errorType: "config",
9606
+ message: `Antigravity ACP does not offer the selected permission mode '${mode}'.`
9607
+ });
9608
+ await process.request("session/set_mode", {
9609
+ sessionId,
9610
+ modeId: mode
9611
+ });
9612
+ const model = request.conversationPolicy?.model;
9613
+ if (model) {
9614
+ const config = descriptor.configOptions?.find((option) => option.id === "model" && option.type === "select");
9615
+ if (!(config?.type === "select" ? config.options.flatMap((option) => "value" in option ? [option] : option.options) : []).some((option) => option.value === model)) throw acpError({
9616
+ code: "model.unavailable",
9617
+ errorType: "config",
9618
+ message: `Antigravity model '${model}' is not available for this account.`
9619
+ });
9620
+ await process.request("session/set_config_option", {
9621
+ sessionId,
9622
+ configId: "model",
9623
+ value: model
9624
+ });
9625
+ }
9626
+ if (request.conversationPolicy?.reasoningLevel) throw acpError({
9627
+ code: "model.reasoning_unsupported",
9628
+ errorType: "config",
9629
+ message: "Antigravity ACP does not expose a reasoning-level setting."
9630
+ });
9631
+ return sessionId;
9632
+ }
9633
+ const AUTH_ERROR_RE = /authentication|sign.in|login/iu;
9634
+ const CONTEXT_ERROR_RE = /session.+not found|unknown session/iu;
9635
+ function resolveAcpMode(mode) {
9636
+ switch (mode) {
9637
+ case void 0:
9638
+ case "antigravity:default": return "default";
9639
+ case "antigravity:acceptEdits": return "auto_edit";
9640
+ case "antigravity:bypassPermissions": return "yolo";
9641
+ case "antigravity:plan": return "plan";
9642
+ default: throw acpError({
9643
+ code: "permission.mode_unsupported",
9644
+ errorType: "config",
9645
+ message: "Select an Antigravity permission mode."
9646
+ });
9647
+ }
9648
+ }
9649
+ //#endregion
9276
9650
  //#region ../../runtime/adapters/antigravity/dist/config/antigravity-runtime-config.js
9277
9651
  const DEFAULT_ANTIGRAVITY_COMMAND = "agy";
9278
9652
  async function resolveInstalledAntigravityLaunchCandidates(input) {
9279
- const configuredCommand = normalizeOptionalText$42(process.env.OPENMELD_DAEMON_RUNTIME_ANTIGRAVITY_BIN);
9653
+ const configuredCommand = normalizeOptionalText$40(process.env.OPENMELD_DAEMON_RUNTIME_ANTIGRAVITY_BIN);
9280
9654
  const installed = await resolveInstalledNodeScriptLaunchCandidates({
9281
9655
  additionalCommandDirectories: [join(resolveHome$1(), ".local", "bin")],
9282
9656
  commandName: DEFAULT_ANTIGRAVITY_COMMAND,
@@ -9284,9 +9658,16 @@ async function resolveInstalledAntigravityLaunchCandidates(input) {
9284
9658
  displayName: "Antigravity CLI",
9285
9659
  preferredLaunchContract: input?.preferredLaunchContract
9286
9660
  });
9287
- if (!installed.ok) return installed;
9661
+ const acp = await resolveInstalledNodeScriptLaunchCandidates({
9662
+ additionalCommandDirectories: [join(resolveHome$1(), ".local", "bin")],
9663
+ commandName: process.platform === "win32" ? "agy_acp_server.exe" : "agy_acp_server.par",
9664
+ displayName: "Antigravity ACP",
9665
+ preferredLaunchContract: input?.preferredLaunchContract && isAntigravityAcpLaunchContract(input.preferredLaunchContract) ? input.preferredLaunchContract : void 0
9666
+ });
9667
+ if (!(installed.ok || acp.ok)) return installed.reason === "not_launchable" ? installed : acp;
9668
+ const discovered = [...installed.ok ? installed.candidates : [], ...acp.ok ? acp.candidates : []];
9288
9669
  const candidates = await resolveLaunchCandidatesAfterVerification({
9289
- candidates: installed.candidates,
9670
+ candidates: [...new Map(discovered.map((candidate) => [JSON.stringify(candidate.launchContract), candidate])).values()],
9290
9671
  verify: async (candidate) => await verifyAntigravityLaunchContract({
9291
9672
  launchContract: candidate.launchContract,
9292
9673
  timeoutMs: input?.timeoutMs
@@ -9303,6 +9684,30 @@ async function resolveInstalledAntigravityLaunchCandidates(input) {
9303
9684
  };
9304
9685
  }
9305
9686
  async function verifyAntigravityLaunchContract(input) {
9687
+ if (isAntigravityAcpLaunchContract(input.launchContract)) try {
9688
+ await probeAntigravityAcp({
9689
+ ...input,
9690
+ cwd: input.cwd ?? process.cwd()
9691
+ });
9692
+ const invocation = buildCliLaunchInvocation({
9693
+ launchContract: input.launchContract,
9694
+ args: []
9695
+ });
9696
+ return {
9697
+ ok: true,
9698
+ launchCommand: {
9699
+ bin: invocation.bin,
9700
+ argsPrefix: invocation.args,
9701
+ shell: invocation.shell
9702
+ }
9703
+ };
9704
+ } catch (error) {
9705
+ return {
9706
+ ok: false,
9707
+ failureKind: "incomplete_check",
9708
+ errorMessage: error instanceof Error ? error.message : String(error)
9709
+ };
9710
+ }
9306
9711
  return await verifyCliLaunchContract({
9307
9712
  cwd: input.cwd ?? process.cwd(),
9308
9713
  displayName: "Antigravity CLI",
@@ -9313,9 +9718,9 @@ async function verifyAntigravityLaunchContract(input) {
9313
9718
  });
9314
9719
  }
9315
9720
  function resolveHome$1() {
9316
- return normalizeOptionalText$42(process.env.HOME) ?? homedir();
9721
+ return normalizeOptionalText$40(process.env.HOME) ?? homedir();
9317
9722
  }
9318
- function normalizeOptionalText$42(value) {
9723
+ function normalizeOptionalText$40(value) {
9319
9724
  const normalized = String(value ?? "").trim();
9320
9725
  return normalized.length > 0 ? normalized : null;
9321
9726
  }
@@ -9802,7 +10207,7 @@ async function invokeAntigravityCliTransport(input) {
9802
10207
  }
9803
10208
  }
9804
10209
  async function invokeNativeAntigravity(input) {
9805
- const prompt = normalizeOptionalText$41(input.prompt);
10210
+ const prompt = normalizeOptionalText$39(input.prompt);
9806
10211
  if (!prompt) throw new AntigravityCliTransportError({
9807
10212
  code: "schema.invalid",
9808
10213
  errorType: "config",
@@ -9814,13 +10219,13 @@ async function invokeNativeAntigravity(input) {
9814
10219
  conversationPolicy: input.conversationPolicy,
9815
10220
  jsonSchema: input.jsonSchema,
9816
10221
  prompt,
9817
- sessionId: normalizeOptionalText$41(input.sessionId)
10222
+ sessionId: normalizeOptionalText$39(input.sessionId)
9818
10223
  }), ...input.deliveryAgentName ? ["--agent", input.deliveryAgentName] : []],
9819
10224
  launchContract: input.launchContract
9820
10225
  });
9821
10226
  const invokedAtMs = Date.now();
9822
10227
  let firstOutputAtMs = null;
9823
- let conversationId = normalizeOptionalText$41(input.sessionId);
10228
+ let conversationId = normalizeOptionalText$39(input.sessionId);
9824
10229
  const terminal = { result: null };
9825
10230
  let malformedOutput = false;
9826
10231
  const providerErrorMessages = [];
@@ -9835,7 +10240,7 @@ async function invokeNativeAntigravity(input) {
9835
10240
  onLifecycleEvent: input.onRuntimeEvent,
9836
10241
  onProcessControlEvent: input.onProcessControlEvent,
9837
10242
  onStderrLine: (lineEvent) => {
9838
- const message = normalizeOptionalText$41(lineEvent.line);
10243
+ const message = normalizeOptionalText$39(lineEvent.line);
9839
10244
  if (message) providerErrorMessages.push(message);
9840
10245
  },
9841
10246
  onStdoutLine: (lineEvent) => {
@@ -9888,8 +10293,8 @@ async function invokeNativeAntigravity(input) {
9888
10293
  stderr: driverResult.stderrText,
9889
10294
  telemetry
9890
10295
  });
9891
- const output = normalizeOptionalText$41(terminalResult.response);
9892
- const resolvedSessionId = normalizeOptionalText$41(terminalResult.conversationId) ?? conversationId;
10296
+ const output = normalizeOptionalText$39(terminalResult.response);
10297
+ const resolvedSessionId = normalizeOptionalText$39(terminalResult.conversationId) ?? conversationId;
9893
10298
  if (!(output && resolvedSessionId)) {
9894
10299
  const permissionFailure = classifyAntigravityPermissionFailure(providerErrorMessages);
9895
10300
  if (permissionFailure) throw new AntigravityCliTransportError({
@@ -9934,12 +10339,12 @@ function buildAntigravityArgs(input) {
9934
10339
  "--print-timeout",
9935
10340
  "0"
9936
10341
  ];
9937
- const jsonSchema = normalizeOptionalText$41(input.jsonSchema);
10342
+ const jsonSchema = normalizeOptionalText$39(input.jsonSchema);
9938
10343
  if (jsonSchema) args.push("--json-schema", jsonSchema);
9939
10344
  if (input.sessionId) args.push("--conversation", input.sessionId);
9940
- const model = normalizeOptionalText$41(input.conversationPolicy?.model);
10345
+ const model = normalizeOptionalText$39(input.conversationPolicy?.model);
9941
10346
  if (model) args.push("--model", model);
9942
- const effort = normalizeOptionalText$41(input.conversationPolicy?.reasoningLevel);
10347
+ const effort = normalizeOptionalText$39(input.conversationPolicy?.reasoningLevel);
9943
10348
  if (effort) {
9944
10349
  if (!ANTIGRAVITY_EFFORTS.has(effort)) throw new AntigravityCliTransportError({
9945
10350
  code: "model.reasoning_level.unsupported",
@@ -10000,7 +10405,7 @@ function buildTelemetry(input) {
10000
10405
  };
10001
10406
  }
10002
10407
  function classifyAntigravityFailure(input) {
10003
- const providerMessage = normalizeOptionalText$41(input.providerError) ?? normalizeOptionalText$41(input.stderr) ?? (input.signal ? `Antigravity CLI was interrupted by ${input.signal}.` : `Antigravity CLI exited with code ${String(input.exitCode)}.`);
10408
+ const providerMessage = normalizeOptionalText$39(input.providerError) ?? normalizeOptionalText$39(input.stderr) ?? (input.signal ? `Antigravity CLI was interrupted by ${input.signal}.` : `Antigravity CLI exited with code ${String(input.exitCode)}.`);
10004
10409
  const authFailure = AUTH_FAILURE_PATTERN.test(providerMessage);
10005
10410
  const contextFailure = CONTEXT_FAILURE_PATTERN.test(providerMessage);
10006
10411
  let code = "provider_exit_error";
@@ -10014,7 +10419,7 @@ function classifyAntigravityFailure(input) {
10014
10419
  telemetry: input.telemetry
10015
10420
  });
10016
10421
  }
10017
- function normalizeOptionalText$41(value) {
10422
+ function normalizeOptionalText$39(value) {
10018
10423
  const normalized = String(value ?? "").trim();
10019
10424
  return normalized.length > 0 ? normalized : null;
10020
10425
  }
@@ -10030,7 +10435,11 @@ function createAntigravityAdapter(options = {}) {
10030
10435
  const processInterruptSender = options.registerRuntimeProcess ? createProcessInterruptSender(activeTasks) : void 0;
10031
10436
  const controlShell = createSharedControlShell({
10032
10437
  gracefulTimeoutMs: options.gracefulTimeoutMs,
10033
- sendCancel: options.sendCancel,
10438
+ sendCancel: options.sendCancel ?? (processInterruptSender ? (request) => processInterruptSender({
10439
+ taskId: request.taskId,
10440
+ reason: request.reason ?? "cancel",
10441
+ mode: activeTasks.get(request.taskId)?.cancel ? "graceful" : "force"
10442
+ }) : void 0),
10034
10443
  sendInterrupt: options.sendInterrupt ?? processInterruptSender,
10035
10444
  waitForMs: options.waitForMs
10036
10445
  });
@@ -10073,7 +10482,7 @@ function createDefaultAntigravityInvoke(input) {
10073
10482
  message: "runtime.cancelled_before_start: Antigravity dispatch was canceled before launch"
10074
10483
  });
10075
10484
  const result = await invokeWithSingleContextHeal({
10076
- contextId: normalizeOptionalText$40(request.agentControllerConversationId),
10485
+ contextId: normalizeOptionalText$38(request.agentControllerConversationId),
10077
10486
  contextLossPolicy: request.executionMode === "repair" ? "fail" : "rebuild",
10078
10487
  createRebuildFailedError: (error) => new AntigravityCliTransportError({
10079
10488
  code: "context.rebuild_failed",
@@ -10081,6 +10490,30 @@ function createDefaultAntigravityInvoke(input) {
10081
10490
  message: `context.rebuild_failed: ${toErrorMessage$17(error)}`
10082
10491
  }),
10083
10492
  invokeOnce: async (sessionId) => {
10493
+ const onProcessControlEvent = (event) => {
10494
+ task.process = event.phase === "process_spawned" ? event : null;
10495
+ if (event.phase === "process_spawned" && task.cancellationRequested) signalProcess(event, "SIGINT");
10496
+ input.options.registerRuntimeProcess?.({
10497
+ ...event,
10498
+ taskId: request.taskId
10499
+ });
10500
+ };
10501
+ if (isAntigravityAcpLaunchContract(launchContract)) {
10502
+ const transportResult = await invokeAntigravityAcpTransport({
10503
+ request,
10504
+ launchContract,
10505
+ sessionId,
10506
+ onProcessControlEvent,
10507
+ registerCancel: (cancel) => {
10508
+ task.cancel = cancel;
10509
+ }
10510
+ });
10511
+ return {
10512
+ contextId: transportResult.sessionId,
10513
+ output: transportResult.output,
10514
+ telemetry: transportResult.telemetry
10515
+ };
10516
+ }
10084
10517
  const transportResult = await withAntigravityDispatchSpaceAction({
10085
10518
  env: request.env,
10086
10519
  prompt: request.prompt,
@@ -10092,14 +10525,7 @@ function createDefaultAntigravityInvoke(input) {
10092
10525
  jsonSchema,
10093
10526
  launchContract,
10094
10527
  onPreview: request.onPreview,
10095
- onProcessControlEvent: (event) => {
10096
- task.process = event.phase === "process_spawned" ? event : null;
10097
- if (event.phase === "process_spawned" && task.cancellationRequested) signalProcess(event, "SIGINT");
10098
- input.options.registerRuntimeProcess?.({
10099
- ...event,
10100
- taskId: request.taskId
10101
- });
10102
- },
10528
+ onProcessControlEvent,
10103
10529
  onRuntimeEvent: request.onRuntimeEvent,
10104
10530
  prompt,
10105
10531
  sessionId,
@@ -10113,7 +10539,7 @@ function createDefaultAntigravityInvoke(input) {
10113
10539
  telemetry: transportResult.telemetry
10114
10540
  };
10115
10541
  },
10116
- isContextLostError: (error) => error instanceof AntigravityCliTransportError && error.code === "context_not_found"
10542
+ isContextLostError: (error) => error instanceof Error && "code" in error && error.code === "context_not_found"
10117
10543
  });
10118
10544
  const agentControllerConversation = ANTIGRAVITY_CONVERSATION_BRIDGE_SPEC && result.contextId ? bridgeAgentControllerConversationRef({
10119
10545
  bridgeSpec: ANTIGRAVITY_CONVERSATION_BRIDGE_SPEC,
@@ -10134,12 +10560,13 @@ function createDefaultAntigravityInvoke(input) {
10134
10560
  };
10135
10561
  }
10136
10562
  async function resolveDispatchLaunchContract(input) {
10137
- const commandPath = normalizeOptionalText$40(input.antigravityBin);
10563
+ const commandPath = normalizeOptionalText$38(input.antigravityBin);
10138
10564
  const launchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (commandPath ? buildExecutableLaunchContract({ commandPath }) : null);
10139
10565
  if (!launchContract) throw Object.assign(/* @__PURE__ */ new Error("Antigravity CLI launch contract is required for dispatch."), {
10140
10566
  code: "controller.launch.needs_repair",
10141
10567
  errorType: "config"
10142
10568
  });
10569
+ if (isAntigravityAcpLaunchContract(launchContract)) return launchContract;
10143
10570
  const verification = await verifyAntigravityLaunchContract({ launchContract });
10144
10571
  if (!verification.ok) throw Object.assign(new Error(verification.errorMessage), {
10145
10572
  code: "controller.launch.needs_repair",
@@ -10152,6 +10579,7 @@ function createProcessInterruptSender(activeTasks) {
10152
10579
  const task = activeTasks.get(signal.taskId);
10153
10580
  if (!task) return Promise.reject(Object.assign(/* @__PURE__ */ new Error("Antigravity task is not running."), { code: "task.not_running" }));
10154
10581
  task.cancellationRequested = true;
10582
+ if (signal.mode !== "force" && task.cancel) return task.cancel();
10155
10583
  if (!task.process) return Promise.resolve();
10156
10584
  return signalProcess(task.process, signal.mode === "force" ? "SIGKILL" : "SIGINT") ? Promise.resolve() : Promise.reject(/* @__PURE__ */ new Error("Antigravity process signal was not sent."));
10157
10585
  };
@@ -10163,7 +10591,7 @@ function signalProcess(processEvent, signal) {
10163
10591
  signalTarget: processEvent.signalTarget
10164
10592
  });
10165
10593
  }
10166
- function normalizeOptionalText$40(value) {
10594
+ function normalizeOptionalText$38(value) {
10167
10595
  const normalized = String(value ?? "").trim();
10168
10596
  return normalized.length > 0 ? normalized : null;
10169
10597
  }
@@ -10190,7 +10618,7 @@ async function resolveInstalledClaudeCodeLaunchCandidates(input) {
10190
10618
  const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
10191
10619
  additionalCommandDirectories: resolveClaudeCodeCommandDirectories(),
10192
10620
  commandName: DEFAULT_CLAUDE_CODE_COMMAND,
10193
- configuredCommand: normalizeOptionalText$39(process.env.OPENMELD_DAEMON_RUNTIME_CLAUDE_CODE_BIN),
10621
+ configuredCommand: normalizeOptionalText$37(process.env.OPENMELD_DAEMON_RUNTIME_CLAUDE_CODE_BIN),
10194
10622
  displayName: "Claude Code",
10195
10623
  preferredLaunchContract: input?.preferredLaunchContract
10196
10624
  });
@@ -10222,16 +10650,16 @@ async function verifyClaudeCodeLaunchContract(input) {
10222
10650
  });
10223
10651
  }
10224
10652
  function resolveClaudeCodeTimeoutMs() {
10225
- const raw = normalizeOptionalText$39(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
10653
+ const raw = normalizeOptionalText$37(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
10226
10654
  if (!raw) return null;
10227
10655
  const parsed = Number.parseInt(raw, 10);
10228
10656
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
10229
10657
  return parsed;
10230
10658
  }
10231
10659
  function resolveClaudeCodeCommandDirectories() {
10232
- return [join(normalizeOptionalText$39(process.env.HOME) ?? homedir(), ".local", "bin")];
10660
+ return [join(normalizeOptionalText$37(process.env.HOME) ?? homedir(), ".local", "bin")];
10233
10661
  }
10234
- function normalizeOptionalText$39(value) {
10662
+ function normalizeOptionalText$37(value) {
10235
10663
  const normalized = String(value ?? "").trim();
10236
10664
  return normalized.length > 0 ? normalized : null;
10237
10665
  }
@@ -10280,8 +10708,8 @@ function extractClaudeToolLifecycleObservations(message) {
10280
10708
  const record = toRecord$12(message);
10281
10709
  if (!record) return [];
10282
10710
  if (record.type === "tool_progress") {
10283
- const toolCallId = normalizeOptionalText$38(record.tool_use_id);
10284
- const providerToolName = normalizeOptionalText$38(record.tool_name);
10711
+ const toolCallId = normalizeOptionalText$36(record.tool_use_id);
10712
+ const providerToolName = normalizeOptionalText$36(record.tool_name);
10285
10713
  return toolCallId ? [{
10286
10714
  providerToolInput: null,
10287
10715
  providerToolName,
@@ -10292,11 +10720,11 @@ function extractClaudeToolLifecycleObservations(message) {
10292
10720
  const content = readMessageContent(record.message);
10293
10721
  if (record.type === "assistant") return content.flatMap((block) => {
10294
10722
  if (block.type !== "tool_use") return [];
10295
- const toolCallId = normalizeOptionalText$38(block.id);
10723
+ const toolCallId = normalizeOptionalText$36(block.id);
10296
10724
  if (!toolCallId) return [];
10297
10725
  return [{
10298
10726
  providerToolInput: block.input,
10299
- providerToolName: normalizeOptionalText$38(block.name),
10727
+ providerToolName: normalizeOptionalText$36(block.name),
10300
10728
  state: "input-available",
10301
10729
  toolCallId
10302
10730
  }];
@@ -10304,7 +10732,7 @@ function extractClaudeToolLifecycleObservations(message) {
10304
10732
  if (record.type !== "user") return [];
10305
10733
  return content.flatMap((block) => {
10306
10734
  if (block.type !== "tool_result") return [];
10307
- const toolCallId = normalizeOptionalText$38(block.tool_use_id);
10735
+ const toolCallId = normalizeOptionalText$36(block.tool_use_id);
10308
10736
  if (!toolCallId) return [];
10309
10737
  return [{
10310
10738
  providerToolInput: null,
@@ -10325,7 +10753,7 @@ function readMessageContent(message) {
10325
10753
  function toRecord$12(value) {
10326
10754
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
10327
10755
  }
10328
- function normalizeOptionalText$38(value) {
10756
+ function normalizeOptionalText$36(value) {
10329
10757
  const normalized = typeof value === "string" ? value.trim() : "";
10330
10758
  return normalized.length > 0 ? normalized : null;
10331
10759
  }
@@ -10820,8 +11248,8 @@ function parseClaudeOutputLine(line) {
10820
11248
  }
10821
11249
  const record = toObjectRecord(parsed);
10822
11250
  if (!record) return null;
10823
- const sessionId = normalizeOptionalText$37(record.session_id);
10824
- const resultText = normalizeOptionalText$37(record.result);
11251
+ const sessionId = normalizeOptionalText$35(record.session_id);
11252
+ const resultText = normalizeOptionalText$35(record.result);
10825
11253
  const isErrorResult = typeof record.is_error === "boolean" ? record.is_error : null;
10826
11254
  if (record.type === "result") return {
10827
11255
  errorMessage: isErrorResult ? resultText : null,
@@ -10832,7 +11260,7 @@ function parseClaudeOutputLine(line) {
10832
11260
  terminal: true
10833
11261
  };
10834
11262
  if (record.type === "error") return {
10835
- errorMessage: normalizeOptionalText$37(record.message),
11263
+ errorMessage: normalizeOptionalText$35(record.message),
10836
11264
  isErrorResult: true,
10837
11265
  previewDeltaText: null,
10838
11266
  resultText: null,
@@ -10848,7 +11276,7 @@ function parseClaudeOutputLine(line) {
10848
11276
  function parseClaudeStreamEvent(record, sessionId) {
10849
11277
  const event = toObjectRecord(record.event);
10850
11278
  if (!event) return null;
10851
- const eventType = normalizeOptionalText$37(event.type);
11279
+ const eventType = normalizeOptionalText$35(event.type);
10852
11280
  if (eventType === "message_start") return {
10853
11281
  errorMessage: null,
10854
11282
  isErrorResult: null,
@@ -10875,7 +11303,7 @@ function toObjectRecord(value) {
10875
11303
  function normalizeText$9(value) {
10876
11304
  return String(value ?? "").trim();
10877
11305
  }
10878
- function normalizeOptionalText$37(value) {
11306
+ function normalizeOptionalText$35(value) {
10879
11307
  const normalized = normalizeText$9(value);
10880
11308
  return normalized.length > 0 ? normalized : null;
10881
11309
  }
@@ -10886,16 +11314,16 @@ function preserveOptionalText(value) {
10886
11314
  //#endregion
10887
11315
  //#region ../../runtime/adapters/claude-code/dist/transport/claude-conversation-policy.js
10888
11316
  function resolveClaudeConversationPolicyOptions(conversationPolicy) {
10889
- const model = normalizeOptionalText$36(conversationPolicy?.model);
10890
- const fallbackModel = normalizeOptionalText$36(conversationPolicy?.fallbackModel);
10891
- const reasoningLevel = normalizeOptionalText$36(conversationPolicy?.reasoningLevel);
11317
+ const model = normalizeOptionalText$34(conversationPolicy?.model);
11318
+ const fallbackModel = normalizeOptionalText$34(conversationPolicy?.fallbackModel);
11319
+ const reasoningLevel = normalizeOptionalText$34(conversationPolicy?.reasoningLevel);
10892
11320
  return {
10893
11321
  ...model ? { model } : {},
10894
11322
  ...fallbackModel && fallbackModel !== model ? { fallbackModel } : {},
10895
11323
  ...reasoningLevel ? { reasoningLevel } : {}
10896
11324
  };
10897
11325
  }
10898
- function normalizeOptionalText$36(value) {
11326
+ function normalizeOptionalText$34(value) {
10899
11327
  const normalized = String(value ?? "").trim();
10900
11328
  return normalized.length > 0 ? normalized : null;
10901
11329
  }
@@ -11001,7 +11429,7 @@ var ClaudeCliTransportError = class extends Error {
11001
11429
  }
11002
11430
  };
11003
11431
  async function invokeClaudeCliTransport(input) {
11004
- const prompt = normalizeOptionalText$35(input.prompt);
11432
+ const prompt = normalizeOptionalText$33(input.prompt);
11005
11433
  if (!prompt) throw new ClaudeCliTransportError({
11006
11434
  code: "schema.invalid",
11007
11435
  errorType: "config",
@@ -11014,16 +11442,16 @@ async function invokeClaudeCliTransport(input) {
11014
11442
  executionMode: input.executionMode,
11015
11443
  env: input.env,
11016
11444
  prompt,
11017
- sessionId: normalizeOptionalText$35(input.sessionId),
11445
+ sessionId: normalizeOptionalText$33(input.sessionId),
11018
11446
  streamingMode: input.streamingMode
11019
11447
  }),
11020
11448
  launchContract: input.launchContract
11021
11449
  });
11022
11450
  const invokedAtMs = Date.now();
11023
- const canonicalRepairSessionId = input.executionMode === "repair" ? normalizeOptionalText$35(input.sessionId) : null;
11451
+ const canonicalRepairSessionId = input.executionMode === "repair" ? normalizeOptionalText$33(input.sessionId) : null;
11024
11452
  let latestOutput = "";
11025
11453
  let latestResultIsError = false;
11026
- let resolvedSessionId = normalizeOptionalText$35(input.sessionId);
11454
+ let resolvedSessionId = normalizeOptionalText$33(input.sessionId);
11027
11455
  const providerErrorMessages = [];
11028
11456
  const providerOriginalErrorMessages = [];
11029
11457
  let firstStdoutAtMs = null;
@@ -11043,7 +11471,7 @@ async function invokeClaudeCliTransport(input) {
11043
11471
  onLifecycleEvent: input.onRuntimeEvent,
11044
11472
  onProcessControlEvent: input.onProcessControlEvent,
11045
11473
  onStderrLine: (event) => {
11046
- collectProviderErrorMessage$2(event.line, providerErrorMessages);
11474
+ collectProviderErrorMessage$1(event.line, providerErrorMessages);
11047
11475
  },
11048
11476
  onStdoutLine: (event) => {
11049
11477
  const nextState = handleClaudeStdoutLine({
@@ -11080,7 +11508,7 @@ async function invokeClaudeCliTransport(input) {
11080
11508
  firstStdoutAtMs,
11081
11509
  invokedAtMs,
11082
11510
  previewEmitted: previewEmitter.emitted,
11083
- resumedContext: normalizeOptionalText$35(input.sessionId) !== null,
11511
+ resumedContext: normalizeOptionalText$33(input.sessionId) !== null,
11084
11512
  streamingMode: input.streamingMode ?? "final"
11085
11513
  });
11086
11514
  const classifiedFailure = classifyClaudeFailure({
@@ -11099,7 +11527,7 @@ async function invokeClaudeCliTransport(input) {
11099
11527
  telemetry
11100
11528
  });
11101
11529
  }
11102
- const output = normalizeOptionalText$35(latestOutput);
11530
+ const output = normalizeOptionalText$33(latestOutput);
11103
11531
  if (!output) throw new ClaudeCliTransportError({
11104
11532
  code: "runtime.output.empty",
11105
11533
  errorType: "adapter",
@@ -11110,20 +11538,20 @@ async function invokeClaudeCliTransport(input) {
11110
11538
  firstStdoutAtMs,
11111
11539
  invokedAtMs,
11112
11540
  previewEmitted: previewEmitter.emitted,
11113
- resumedContext: normalizeOptionalText$35(input.sessionId) !== null,
11541
+ resumedContext: normalizeOptionalText$33(input.sessionId) !== null,
11114
11542
  streamingMode: input.streamingMode ?? "final"
11115
11543
  })
11116
11544
  });
11117
11545
  return {
11118
11546
  output,
11119
- sessionId: canonicalRepairSessionId ?? normalizeOptionalText$35(resolvedSessionId),
11547
+ sessionId: canonicalRepairSessionId ?? normalizeOptionalText$33(resolvedSessionId),
11120
11548
  telemetry: buildClaudeCliTelemetry({
11121
11549
  driverResult,
11122
11550
  firstOutputAtMs,
11123
11551
  firstStdoutAtMs,
11124
11552
  invokedAtMs,
11125
11553
  previewEmitted: previewEmitter.emitted,
11126
- resumedContext: normalizeOptionalText$35(input.sessionId) !== null,
11554
+ resumedContext: normalizeOptionalText$33(input.sessionId) !== null,
11127
11555
  streamingMode: input.streamingMode ?? "final"
11128
11556
  })
11129
11557
  };
@@ -11267,8 +11695,8 @@ const toClaudeCliTransportError = (error, timeoutMs) => {
11267
11695
  });
11268
11696
  };
11269
11697
  const classifyClaudeFailure = (input) => {
11270
- const trustedProviderMessages = /* @__PURE__ */ new Set([...input.providerOriginalErrorMessages ?? [], ...extractErrorMessagesFromStdout$2(input.stdoutText)]);
11271
- const providerMessage = resolveProviderFailureMessage$3(input);
11698
+ const trustedProviderMessages = /* @__PURE__ */ new Set([...input.providerOriginalErrorMessages ?? [], ...extractErrorMessagesFromStdout$1(input.stdoutText)]);
11699
+ const providerMessage = resolveProviderFailureMessage$2(input);
11272
11700
  const originalError = providerMessage && trustedProviderMessages.has(providerMessage) ? createProviderOriginalError(providerMessage) ?? void 0 : void 0;
11273
11701
  if (providerMessage) {
11274
11702
  const classified = classifyProviderMessageFailure(providerMessage, trustedProviderMessages.has(providerMessage));
@@ -11280,7 +11708,7 @@ const classifyClaudeFailure = (input) => {
11280
11708
  message: `provider.process_terminated: claude process was terminated by ${input.exitSignal} before returning a result`,
11281
11709
  originalError
11282
11710
  };
11283
- const stderrText = normalizeOptionalText$35(input.stderrText);
11711
+ const stderrText = normalizeOptionalText$33(input.stderrText);
11284
11712
  if (stderrText) return {
11285
11713
  code: "upstream_unreachable",
11286
11714
  errorType: "adapter",
@@ -11343,17 +11771,17 @@ const classifyProviderMessageFailure = (providerMessage, includeOriginalError) =
11343
11771
  });
11344
11772
  return null;
11345
11773
  };
11346
- const resolveProviderFailureMessage$3 = (input) => {
11774
+ const resolveProviderFailureMessage$2 = (input) => {
11347
11775
  const candidateMessages = [
11348
11776
  ...input.providerErrorMessages,
11349
- ...extractErrorMessagesFromStdout$2(input.stdoutText),
11350
- ...normalizeOptionalText$35(input.stderrText) ? [normalizeOptionalText$35(input.stderrText)] : []
11777
+ ...extractErrorMessagesFromStdout$1(input.stdoutText),
11778
+ ...normalizeOptionalText$33(input.stderrText) ? [normalizeOptionalText$33(input.stderrText)] : []
11351
11779
  ].filter((value) => Boolean(value));
11352
- for (const candidate of candidateMessages) if (looksLikeProviderFailure$3(candidate)) return candidate;
11780
+ for (const candidate of candidateMessages) if (looksLikeProviderFailure$2(candidate)) return candidate;
11353
11781
  return candidateMessages[0] ?? null;
11354
11782
  };
11355
- const extractErrorMessagesFromStdout$2 = (value) => {
11356
- const stdoutText = normalizeOptionalText$35(value);
11783
+ const extractErrorMessagesFromStdout$1 = (value) => {
11784
+ const stdoutText = normalizeOptionalText$33(value);
11357
11785
  if (!stdoutText) return [];
11358
11786
  const messages = [];
11359
11787
  const lines = stdoutText.split("\n");
@@ -11363,12 +11791,12 @@ const extractErrorMessagesFromStdout$2 = (value) => {
11363
11791
  }
11364
11792
  return messages;
11365
11793
  };
11366
- const collectProviderErrorMessage$2 = (line, messages) => {
11367
- const normalizedLine = normalizeOptionalText$35(line);
11794
+ const collectProviderErrorMessage$1 = (line, messages) => {
11795
+ const normalizedLine = normalizeOptionalText$33(line);
11368
11796
  if (!normalizedLine) return;
11369
11797
  messages.push(normalizedLine);
11370
11798
  };
11371
- const looksLikeProviderFailure$3 = (value) => {
11799
+ const looksLikeProviderFailure$2 = (value) => {
11372
11800
  const normalized = value.toLowerCase();
11373
11801
  return looksLikeRuntimePermissionDenialMessage(value) || isAuthFailure$1(normalized) || isQuotaFailure$1(normalized) || isRateLimitFailure$1(normalized) || isModelConfigFailure(normalized) || isLikelyClaudeContextLostError(normalized);
11374
11802
  };
@@ -11414,11 +11842,137 @@ const isProviderOverloadedFailure = (value) => {
11414
11842
  function normalizeText$8(value) {
11415
11843
  return String(value ?? "").trim();
11416
11844
  }
11417
- function normalizeOptionalText$35(value) {
11845
+ function normalizeOptionalText$33(value) {
11418
11846
  const normalized = normalizeText$8(value);
11419
11847
  return normalized.length > 0 ? normalized : null;
11420
11848
  }
11421
11849
  //#endregion
11850
+ //#region ../../runtime/adapters/claude-code/dist/transport/claude-live-input.js
11851
+ const CLAUDE_VERSION = /^(\d+)\.(\d+)\.(\d+)/;
11852
+ function createClaudeLiveInput(taskId, prompt) {
11853
+ const messages = [userMessage(prompt)];
11854
+ const pending = /* @__PURE__ */ new Map();
11855
+ const awaitingResults = /* @__PURE__ */ new Set();
11856
+ let wake;
11857
+ let closed = false;
11858
+ let sessionId;
11859
+ let supported = false;
11860
+ let resultWhilePending = false;
11861
+ function unconfirmed() {
11862
+ return {
11863
+ status: "unconfirmed",
11864
+ taskId,
11865
+ reasonCode: "execution_input.application_unconfirmed",
11866
+ diagnosticCode: "claude.input_receipt_unconfirmed"
11867
+ };
11868
+ }
11869
+ function close() {
11870
+ closed = true;
11871
+ messages.length = 0;
11872
+ wake?.();
11873
+ for (const receipt of pending.values()) {
11874
+ clearTimeout(receipt.timer);
11875
+ receipt.resolve(unconfirmed());
11876
+ }
11877
+ pending.clear();
11878
+ awaitingResults.clear();
11879
+ }
11880
+ const steer = async (input) => {
11881
+ if (closed || input.taskId !== taskId || !sessionId) return {
11882
+ status: "not_applied",
11883
+ taskId: input.taskId,
11884
+ reasonCode: "execution_input.target_unavailable"
11885
+ };
11886
+ if (!supported) return {
11887
+ status: "not_applied",
11888
+ taskId,
11889
+ reasonCode: "execution_input.unsupported"
11890
+ };
11891
+ const uuid = randomUUID();
11892
+ return await new Promise((resolve) => {
11893
+ const timer = setTimeout(() => {
11894
+ pending.delete(uuid);
11895
+ awaitingResults.delete(uuid);
11896
+ resolve(unconfirmed());
11897
+ if (resultWhilePending && awaitingResults.size === 0) close();
11898
+ }, 1e4);
11899
+ timer.unref?.();
11900
+ pending.set(uuid, {
11901
+ resolve,
11902
+ timer
11903
+ });
11904
+ awaitingResults.add(uuid);
11905
+ messages.push({
11906
+ ...userMessage(input.text, uuid),
11907
+ priority: "now"
11908
+ });
11909
+ wake?.();
11910
+ });
11911
+ };
11912
+ function observeResult(message) {
11913
+ for (const uuid of message.user_message_uuids ?? []) awaitingResults.delete(uuid);
11914
+ if (message.user_message_uuid) awaitingResults.delete(message.user_message_uuid);
11915
+ if (!message.is_error && awaitingResults.size > 0) resultWhilePending = true;
11916
+ else close();
11917
+ }
11918
+ return {
11919
+ close,
11920
+ steer,
11921
+ async *prompt() {
11922
+ while (!closed) {
11923
+ const message = messages.shift();
11924
+ if (message) yield message;
11925
+ else {
11926
+ await new Promise((resolve) => {
11927
+ wake = resolve;
11928
+ });
11929
+ wake = void 0;
11930
+ }
11931
+ }
11932
+ },
11933
+ observe(message) {
11934
+ if (message.type === "system" && message.subtype === "init") {
11935
+ sessionId = message.session_id;
11936
+ supported = supportsConsumedInputReceipt(message.claude_code_version);
11937
+ }
11938
+ if (message.type === "user" && "isReplay" in message && message.isReplay && message.parent_tool_use_id === null && message.session_id === sessionId) {
11939
+ const receipt = pending.get(message.uuid);
11940
+ if (receipt) {
11941
+ clearTimeout(receipt.timer);
11942
+ pending.delete(message.uuid);
11943
+ resultWhilePending = false;
11944
+ receipt.resolve({
11945
+ status: "applied",
11946
+ taskId,
11947
+ threadId: message.session_id,
11948
+ turnId: message.uuid
11949
+ });
11950
+ }
11951
+ }
11952
+ if (message.type === "result") observeResult(message);
11953
+ }
11954
+ };
11955
+ }
11956
+ function supportsConsumedInputReceipt(version) {
11957
+ const parts = version?.match(CLAUDE_VERSION);
11958
+ if (!parts) return false;
11959
+ const major = Number(parts[1]);
11960
+ const minor = Number(parts[2]);
11961
+ const patch = Number(parts[3]);
11962
+ return major > 2 || major === 2 && (minor > 1 || minor === 1 && patch >= 290);
11963
+ }
11964
+ function userMessage(text, uuid) {
11965
+ return {
11966
+ type: "user",
11967
+ message: {
11968
+ role: "user",
11969
+ content: text
11970
+ },
11971
+ parent_tool_use_id: null,
11972
+ ...uuid ? { uuid } : {}
11973
+ };
11974
+ }
11975
+ //#endregion
11422
11976
  //#region ../../runtime/adapters/claude-code/dist/transport/claude-space-action-tools.js
11423
11977
  function isClaudeDeliveryOnly(input) {
11424
11978
  return Boolean(input.spaceActionTools?.deliveryOnly || isDispatchSpaceActionDeliveryOnly(input.env));
@@ -11664,7 +12218,7 @@ function isFailedResultMessage(resultMessage) {
11664
12218
  }
11665
12219
  function resolveCanonicalRepairSessionId(input) {
11666
12220
  if (input.executionMode !== "repair") return null;
11667
- return normalizeOptionalText$34(input.sessionId);
12221
+ return normalizeOptionalText$32(input.sessionId);
11668
12222
  }
11669
12223
  async function observeClaudeReasoning(message, messageId, onRuntimeEvent) {
11670
12224
  if (message.type !== "stream_event") return messageId;
@@ -11680,13 +12234,13 @@ async function observeClaudeReasoning(message, messageId, onRuntimeEvent) {
11680
12234
  return messageId;
11681
12235
  }
11682
12236
  async function invokeClaudeAgentSdkTransport(input) {
11683
- const prompt = normalizeOptionalText$34(input.prompt);
12237
+ const prompt = normalizeOptionalText$32(input.prompt);
11684
12238
  if (!prompt) throw new ClaudeAgentSdkTransportError({
11685
12239
  code: "schema.invalid",
11686
12240
  errorType: "config",
11687
12241
  message: "schema.invalid: prompt is required"
11688
12242
  });
11689
- const resumedContext = normalizeOptionalText$34(input.sessionId) !== null;
12243
+ const resumedContext = normalizeOptionalText$32(input.sessionId) !== null;
11690
12244
  const canonicalRepairSessionId = resolveCanonicalRepairSessionId(input);
11691
12245
  const streamingMode = input.streamingMode ?? "final";
11692
12246
  const resources = await createClaudeAgentSdkInvocationResources({
@@ -11708,11 +12262,12 @@ async function invokeClaudeAgentSdkTransport(input) {
11708
12262
  let latestOutput = "";
11709
12263
  let latestPlanDocument = "";
11710
12264
  let resultMessage = null;
11711
- let resolvedSessionId = normalizeOptionalText$34(input.sessionId);
12265
+ let resolvedSessionId = normalizeOptionalText$32(input.sessionId);
11712
12266
  let timeoutTriggeredAtMs = null;
11713
12267
  let timeoutHandle = null;
11714
12268
  let queryRuntime = null;
11715
12269
  let unregisterQuery;
12270
+ let liveInput;
11716
12271
  const toolActivityTracker = createClaudeAgentSdkToolActivityTracker();
11717
12272
  if (input.claudeTimeoutMs !== null) timeoutHandle = setTimeout(() => {
11718
12273
  timeoutTriggeredAtMs = Date.now();
@@ -11740,7 +12295,7 @@ async function invokeClaudeAgentSdkTransport(input) {
11740
12295
  pathToClaudeCodeExecutable: resources.executable.pathToClaudeCodeExecutable,
11741
12296
  spawnProcess: resources.executable.spawnProcess,
11742
12297
  planDirectory: resources.planCapture.directory,
11743
- sessionId: normalizeOptionalText$34(input.sessionId),
12298
+ sessionId: normalizeOptionalText$32(input.sessionId),
11744
12299
  streamingMode: input.streamingMode
11745
12300
  });
11746
12301
  await applyClaudeDeliveryPermissions({
@@ -11749,11 +12304,14 @@ async function invokeClaudeAgentSdkTransport(input) {
11749
12304
  options,
11750
12305
  spaceActionTools: input.spaceActionTools
11751
12306
  });
12307
+ const userPrompt = [input.instructionPrompt?.userPrompt ?? prompt, ...input.spaceActionTools?.deliveryOnly ? ["Use only the supplied delivery tools. Do not repeat the user's work or change permission mode. After the final tool call, return the required small delivery report: recorded is true only after verifying a proposal_saved_locally receipt. This report is not a public reply and never authorizes publication."] : []].join("\n\n");
12308
+ liveInput = createInvocationLiveInput(input, userPrompt, options);
11752
12309
  queryRuntime = createQuery({
11753
12310
  options,
11754
- prompt: createSinglePrompt([input.instructionPrompt?.userPrompt ?? prompt, ...input.spaceActionTools?.deliveryOnly ? ["Use only the supplied delivery tools. Do not repeat the user's work or change permission mode. After the final tool call, return the required small delivery report: recorded is true only after verifying a proposal_saved_locally receipt. This report is not a public reply and never authorizes publication."] : []].join("\n\n"))
12311
+ prompt: liveInput?.prompt() ?? createSinglePrompt(userPrompt)
11755
12312
  });
11756
12313
  if (input.taskId) unregisterQuery = input.registerQuery?.({
12314
+ liveInput,
11757
12315
  permissionModeUpdatesAllowed: input.executionMode !== "repair",
11758
12316
  query: queryRuntime,
11759
12317
  taskId: input.taskId
@@ -11761,6 +12319,7 @@ async function invokeClaudeAgentSdkTransport(input) {
11761
12319
  let reasoningMessageId = "";
11762
12320
  const observeConnection = createClaudeDispatchConnectionObserver(input.spaceActionTools);
11763
12321
  for await (const message of queryRuntime) {
12322
+ liveInput?.observe(message);
11764
12323
  await observeConnection(message, queryRuntime);
11765
12324
  reasoningMessageId = await observeClaudeReasoning(message, reasoningMessageId, input.onRuntimeEvent);
11766
12325
  await emitClaudeCodeUsageLimits({
@@ -11814,6 +12373,7 @@ async function invokeClaudeAgentSdkTransport(input) {
11814
12373
  } finally {
11815
12374
  if (timeoutHandle) clearTimeout(timeoutHandle);
11816
12375
  unregisterQuery?.();
12376
+ liveInput?.close();
11817
12377
  queryRuntime?.close();
11818
12378
  await resources.cleanup();
11819
12379
  }
@@ -11890,7 +12450,7 @@ async function invokeClaudeAgentSdkTransport(input) {
11890
12450
  });
11891
12451
  return {
11892
12452
  output,
11893
- sessionId: canonicalRepairSessionId ?? normalizeOptionalText$34(resolvedSessionId),
12453
+ sessionId: canonicalRepairSessionId ?? normalizeOptionalText$32(resolvedSessionId),
11894
12454
  telemetry: buildClaudeAgentSdkTelemetry({
11895
12455
  aiUsage: [...aiUsage.values()],
11896
12456
  firstOutputAtMs,
@@ -11904,7 +12464,7 @@ async function invokeClaudeAgentSdkTransport(input) {
11904
12464
  };
11905
12465
  }
11906
12466
  async function resolveClaudeFinalOutput(input) {
11907
- if (!input.tools?.deliveryOnly) return normalizeOptionalText$34(input.privateOutput);
12467
+ if (!input.tools?.deliveryOnly) return normalizeOptionalText$32(input.privateOutput);
11908
12468
  return await verifyClaudeDeliveryReport(input.tools, input.result.subtype === "success" ? input.result.structured_output : void 0);
11909
12469
  }
11910
12470
  async function emitClaudeProviderConversationObservation(input) {
@@ -12057,7 +12617,7 @@ function buildClaudeAgentSdkOptions(input) {
12057
12617
  const options = {
12058
12618
  abortController: input.abortController,
12059
12619
  additionalDirectories: [input.claudeWorkdir],
12060
- allowDangerouslySkipPermissions: permissionMode === "bypassPermissions",
12620
+ allowDangerouslySkipPermissions: input.executionMode !== "repair",
12061
12621
  cwd: input.claudeWorkdir,
12062
12622
  env: {
12063
12623
  ...process.env,
@@ -12093,7 +12653,7 @@ function buildClaudeAgentSdkOptions(input) {
12093
12653
  };
12094
12654
  Object.assign(options, buildClaudeSpaceToolOptions(input));
12095
12655
  if (input.executionContext?.access === "workspace" && input.executionContext.permissionSource !== "agent_settings" && input.executionMode !== "repair" && !deliveryOnly) applyClaudeProjectToolBoundary(options, permissionMode);
12096
- const sessionId = normalizeOptionalText$34(input.sessionId);
12656
+ const sessionId = normalizeOptionalText$32(input.sessionId);
12097
12657
  if (sessionId) {
12098
12658
  options.resume = sessionId;
12099
12659
  if (input.executionMode === "repair") options.forkSession = true;
@@ -12137,7 +12697,15 @@ async function readLatestClaudePlanDocument(planDirectory) {
12137
12697
  planFiles.sort((left, right) => right.mtimeMs - left.mtimeMs);
12138
12698
  const latestPlanFile = planFiles[0];
12139
12699
  if (!latestPlanFile) return null;
12140
- return normalizeOptionalText$34((await readFile(latestPlanFile.path, "utf8")).slice(0, 64e3));
12700
+ return normalizeOptionalText$32((await readFile(latestPlanFile.path, "utf8")).slice(0, 64e3));
12701
+ }
12702
+ function createInvocationLiveInput(input, prompt, options) {
12703
+ if (!(input.taskId && input.registerQuery) || input.executionMode === "repair" || input.spaceActionTools?.deliveryOnly) return;
12704
+ options.extraArgs = {
12705
+ ...options.extraArgs,
12706
+ "replay-user-messages": null
12707
+ };
12708
+ return createClaudeLiveInput(input.taskId, prompt);
12141
12709
  }
12142
12710
  function createDefaultClaudeAgentSdkQuery(input) {
12143
12711
  return query(input);
@@ -12161,7 +12729,7 @@ function handleClaudeAgentSdkMessage(input) {
12161
12729
  let observedConversationId = null;
12162
12730
  let resolvedSessionId = input.resolvedSessionId;
12163
12731
  let resultMessage = input.resultMessage;
12164
- const sessionId = normalizeOptionalText$34(input.message.session_id);
12732
+ const sessionId = normalizeOptionalText$32(input.message.session_id);
12165
12733
  if (sessionId) observedConversationId = sessionId;
12166
12734
  const previewDeltaText = extractPreviewDeltaText(input.message);
12167
12735
  if (previewDeltaText) {
@@ -12214,7 +12782,7 @@ function extractAssistantMessageWrittenPlan(message) {
12214
12782
  if (block.type !== "tool_use" || block.name !== "Write") continue;
12215
12783
  const toolInput = block.input;
12216
12784
  if (!toolInput || typeof toolInput !== "object" || Array.isArray(toolInput)) continue;
12217
- const content = normalizeOptionalText$34(toolInput.content);
12785
+ const content = normalizeOptionalText$32(toolInput.content);
12218
12786
  if (content) writtenPlan = content.slice(0, 64e3);
12219
12787
  }
12220
12788
  return writtenPlan;
@@ -12256,7 +12824,7 @@ function toClaudeAgentSdkTransportError(input) {
12256
12824
  const classifiedFailure = classifyClaudeFailure({
12257
12825
  providerErrorMessages: input.providerErrorMessages,
12258
12826
  providerOriginalErrorMessages: input.providerErrorMessages,
12259
- stderrText: [fallbackMessage, input.stderrText].map(normalizeOptionalText$34).filter((value) => value !== null).join("\n")
12827
+ stderrText: [fallbackMessage, input.stderrText].map(normalizeOptionalText$32).filter((value) => value !== null).join("\n")
12260
12828
  });
12261
12829
  return new ClaudeAgentSdkTransportError({
12262
12830
  code: classifiedFailure.code,
@@ -12293,7 +12861,7 @@ function buildPosixWrapperScript(input) {
12293
12861
  function shellQuote(value) {
12294
12862
  return `'${value.replaceAll("'", "'\\''")}'`;
12295
12863
  }
12296
- function normalizeOptionalText$34(value) {
12864
+ function normalizeOptionalText$32(value) {
12297
12865
  const normalized = String(value ?? "").trim();
12298
12866
  return normalized.length > 0 ? normalized : null;
12299
12867
  }
@@ -12521,8 +13089,9 @@ const CLAUDE_CODE_CONVERSATION_BRIDGE_SPEC = resolveBuiltinAdapterConversationBr
12521
13089
  const EXPECTED_FORCE_CLOSE_INTERRUPT_ERROR_RE = /query closed before response received/i;
12522
13090
  const createClaudeCodeAdapter = (options) => {
12523
13091
  const activeAgentSdkQueries = /* @__PURE__ */ new Map();
12524
- const registerAgentSdkQuery = ({ permissionModeUpdatesAllowed, query, taskId }) => {
13092
+ const registerAgentSdkQuery = ({ liveInput, permissionModeUpdatesAllowed, query, taskId }) => {
12525
13093
  const activeQuery = {
13094
+ liveInput,
12526
13095
  permissionModeUpdatesAllowed,
12527
13096
  query
12528
13097
  };
@@ -12534,6 +13103,7 @@ const createClaudeCodeAdapter = (options) => {
12534
13103
  const sendInterrupt = async (signal) => {
12535
13104
  const activeQuery = activeAgentSdkQueries.get(signal.taskId);
12536
13105
  if (activeQuery) {
13106
+ activeQuery.liveInput?.close();
12537
13107
  if (signal.mode === "force") {
12538
13108
  Promise.resolve().then(() => activeQuery.query.interrupt()).catch((error) => {
12539
13109
  if (isExpectedForceCloseInterruptError(error)) return;
@@ -12601,6 +13171,22 @@ const createClaudeCodeAdapter = (options) => {
12601
13171
  cancel: controlShell.cancel,
12602
13172
  dispatch,
12603
13173
  interrupt: controlShell.interrupt,
13174
+ steer: async (request) => {
13175
+ const parsed = agentExecutionSteerRequestSchema.safeParse(request);
13176
+ if (!parsed.success) throw new Error("execution_input.invalid");
13177
+ const active = activeAgentSdkQueries.get(parsed.data.taskId);
13178
+ if (!active) return {
13179
+ status: "not_applied",
13180
+ taskId: parsed.data.taskId,
13181
+ reasonCode: "execution_input.target_unavailable"
13182
+ };
13183
+ if (!active.liveInput) return {
13184
+ status: "not_applied",
13185
+ taskId: parsed.data.taskId,
13186
+ reasonCode: "execution_input.unsupported"
13187
+ };
13188
+ return await active.liveInput.steer(parsed.data);
13189
+ },
12604
13190
  updatePermissionMode
12605
13191
  };
12606
13192
  };
@@ -12642,7 +13228,7 @@ const resolveDefaultClaudeCodeInvoke = (input) => {
12642
13228
  ...dispatchInput.onRuntimeEvent ? { onRuntimeEvent: dispatchInput.onRuntimeEvent } : {},
12643
13229
  prompt: dispatchInput.prompt,
12644
13230
  registerAgentSdkQuery,
12645
- sessionId: normalizeOptionalText$33(dispatchInput.agentControllerConversationId),
13231
+ sessionId: normalizeOptionalText$31(dispatchInput.agentControllerConversationId),
12646
13232
  ...dispatchInput.onPreview ? { onPreview: dispatchInput.onPreview } : {},
12647
13233
  streamingMode: dispatchInput.streamingMode,
12648
13234
  taskId: dispatchInput.taskId
@@ -12663,7 +13249,7 @@ const resolveDefaultClaudeCodeInvoke = (input) => {
12663
13249
  };
12664
13250
  };
12665
13251
  async function resolveClaudeDispatchLaunchContract(input) {
12666
- const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$33(input.claudeBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$33(input.claudeBin) }) : null);
13252
+ const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$31(input.claudeBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$31(input.claudeBin) }) : null);
12667
13253
  if (explicitLaunchContract) {
12668
13254
  const verification = await verifyClaudeCodeLaunchContract({ launchContract: explicitLaunchContract });
12669
13255
  if (verification.ok) return explicitLaunchContract;
@@ -12677,7 +13263,7 @@ async function resolveClaudeDispatchLaunchContract(input) {
12677
13263
  errorType: "config"
12678
13264
  });
12679
13265
  }
12680
- const normalizeOptionalText$33 = (value) => {
13266
+ const normalizeOptionalText$31 = (value) => {
12681
13267
  const normalized = String(value ?? "").trim();
12682
13268
  return normalized.length > 0 ? normalized : null;
12683
13269
  };
@@ -12732,7 +13318,7 @@ function isCodexSubscriptionAccessFailure(value) {
12732
13318
  const MODEL_NOT_FOUND = /^model not found [a-z0-9_./-]+$/i;
12733
13319
  const CHATGPT_MODEL_NOT_SUPPORTED = /^the '[a-z0-9_./-]+' model is not supported when using codex with a chatgpt account\.?$/i;
12734
13320
  function classifyCodexProviderAccountFailure(input) {
12735
- if (normalizeOptionalText$32(input.codexErrorInfo)?.toLowerCase() === "usagelimitexceeded") return buildHardProviderFailure({
13321
+ if (normalizeOptionalText$30(input.codexErrorInfo)?.toLowerCase() === "usagelimitexceeded") return buildHardProviderFailure({
12736
13322
  code: "usage_exhausted",
12737
13323
  originalError: createProviderOriginalError(input.message),
12738
13324
  reasonCode: "usage_exhausted"
@@ -12781,7 +13367,7 @@ function withOriginalError(classification, message) {
12781
13367
  ...originalError ? { originalError } : {}
12782
13368
  };
12783
13369
  }
12784
- function normalizeOptionalText$32(value) {
13370
+ function normalizeOptionalText$30(value) {
12785
13371
  const normalized = String(value ?? "").trim();
12786
13372
  return normalized.length > 0 ? normalized : null;
12787
13373
  }
@@ -12813,7 +13399,7 @@ function extractCodexToolActivityEvent(value, fallbackObservedAtMs = Date.now())
12813
13399
  const params = toRecord$9(record.params);
12814
13400
  const item = toRecord$9(params?.item ?? record.item);
12815
13401
  const itemType = normalizeCompactName(item?.type);
12816
- const toolCallId = normalizeOptionalText$31(item?.id);
13402
+ const toolCallId = normalizeOptionalText$29(item?.id);
12817
13403
  if (!(item && toolCallId && CODEX_TOOL_ITEM_TYPES.has(itemType))) return null;
12818
13404
  const work = resolveAdapterToolWorkActivity(itemType, item);
12819
13405
  return {
@@ -12857,7 +13443,7 @@ function resolveObservedAtMs(input) {
12857
13443
  function normalizeCompactName(value) {
12858
13444
  return typeof value === "string" ? value.trim().toLowerCase() : "";
12859
13445
  }
12860
- function normalizeOptionalText$31(value) {
13446
+ function normalizeOptionalText$29(value) {
12861
13447
  const normalized = typeof value === "string" ? value.trim() : "";
12862
13448
  return normalized.length > 0 ? normalized : null;
12863
13449
  }
@@ -12969,6 +13555,7 @@ const CONTROL_REQUEST_TIMEOUT_MS_BY_OPERATION = {
12969
13555
  "thread/resume": COLD_CONTROLLER_ADMISSION_TIMEOUT_MS,
12970
13556
  "thread/start": COLD_CONTROLLER_ADMISSION_TIMEOUT_MS,
12971
13557
  "turn/start": COLD_CONTROLLER_ADMISSION_TIMEOUT_MS,
13558
+ "turn/settings/update": FAST_METADATA_ADMISSION_TIMEOUT_MS,
12972
13559
  "turn/steer": FAST_METADATA_ADMISSION_TIMEOUT_MS
12973
13560
  };
12974
13561
  function resolveCodexAppServerControlRequestTimeoutMs(input) {
@@ -13753,7 +14340,7 @@ async function probeCodexAppServerAccount(input) {
13753
14340
  }
13754
14341
  async function invokeCodexAppServerTransport(input) {
13755
14342
  throwIfCodexDispatchCancelled(input.cancellationSignal);
13756
- const prompt = normalizeOptionalText$30(input.prompt);
14343
+ const prompt = normalizeOptionalText$28(input.prompt);
13757
14344
  if (!prompt) throw new CodexAppServerTransportError({
13758
14345
  code: "schema.invalid",
13759
14346
  errorType: "config",
@@ -13798,7 +14385,7 @@ async function invokeCodexAppServerTransport(input) {
13798
14385
  instructionPrompt: input.instructionPrompt
13799
14386
  });
13800
14387
  assertFileAccessBeforeTurn(threadContext.permissionResponse, input.computerFileAccessBoundary, input.codexWorkdir, permissionExecutionMode);
13801
- await session.verifyScopedMcp(threadContext.threadId);
14388
+ await session.verifyScopedMcp(threadContext.threadId, parseCodexAppServerVersion(initialized));
13802
14389
  const collaborationMode = await resolveCodexAppServerTurnCollaborationMode({
13803
14390
  conversationPolicy: input.conversationPolicy,
13804
14391
  conversationPolicyParams,
@@ -13806,7 +14393,7 @@ async function invokeCodexAppServerTransport(input) {
13806
14393
  threadModel: threadContext.model
13807
14394
  });
13808
14395
  const executionThreadId = threadContext.threadId;
13809
- const continuityThreadId = input.executionMode === "repair" ? normalizeOptionalText$30(input.threadId) ?? executionThreadId : executionThreadId;
14396
+ const continuityThreadId = input.executionMode === "repair" ? normalizeOptionalText$28(input.threadId) ?? executionThreadId : executionThreadId;
13810
14397
  const turnPrompt = resolveCodexTurnPrompt({
13811
14398
  fallbackPrompt: prompt,
13812
14399
  instructionPrompt: input.instructionPrompt,
@@ -13817,6 +14404,8 @@ async function invokeCodexAppServerTransport(input) {
13817
14404
  session.observeUsageForThread(executionThreadId, threadContext.model);
13818
14405
  throwIfCodexDispatchCancelled(input.cancellationSignal);
13819
14406
  const completedTurn = await startAndAwaitAppServerTurn({
14407
+ supportsLiveReviewer: supportsAgentControllerVersion(parseCodexAppServerVersion(initialized), ">=0.153.0-alpha.4"),
14408
+ permissionMode: resolveCodexAgentControllerPermissionMode$1(input.agentControllerPermissionMode),
13820
14409
  cancellationSignal: input.cancellationSignal,
13821
14410
  collaborationMode,
13822
14411
  conversationPolicyParams,
@@ -13838,7 +14427,7 @@ async function invokeCodexAppServerTransport(input) {
13838
14427
  errorType: "adapter",
13839
14428
  message: interactionFailure.message
13840
14429
  });
13841
- const output = normalizeOptionalText$30(readAgentMessageOutput(completedTurn) ?? session.readCollectedAgentMessageDeltaText());
14430
+ const output = normalizeOptionalText$28(readAgentMessageOutput(completedTurn) ?? session.readCollectedAgentMessageDeltaText());
13842
14431
  requireSuccessfulCodexTurn(completedTurn);
13843
14432
  if (output) session.markAgentOutputObserved();
13844
14433
  await emitPreviewIfRequested({
@@ -13851,7 +14440,7 @@ async function invokeCodexAppServerTransport(input) {
13851
14440
  telemetry: session.buildTelemetry({
13852
14441
  invokedAtMs,
13853
14442
  previewEmitted: input.streamingMode === "stream" && input.onPreview !== void 0,
13854
- resumedContext: normalizeOptionalText$30(input.threadId) !== null,
14443
+ resumedContext: normalizeOptionalText$28(input.threadId) !== null,
13855
14444
  streamingMode: input.streamingMode ?? "final"
13856
14445
  }),
13857
14446
  threadId: continuityThreadId
@@ -13875,6 +14464,44 @@ async function startAndAwaitAppServerTurn(input) {
13875
14464
  } catch {}
13876
14465
  };
13877
14466
  const unregisterActiveTurn = session.registerActiveTurn({
14467
+ updatePermissionMode: async (update) => {
14468
+ const next = update.agentControllerPermissionMode;
14469
+ const taskId = input.taskId;
14470
+ if (!next.startsWith("codex:")) return {
14471
+ status: "not_applied",
14472
+ taskId,
14473
+ reasonCode: "adapter.permission_mode_incompatible"
14474
+ };
14475
+ if (!activeTurnId || turnSettled || interruptRequested || input.cancellationSignal?.aborted) return {
14476
+ status: "not_applied",
14477
+ taskId,
14478
+ reasonCode: "adapter.task_not_active"
14479
+ };
14480
+ const reviewerMode = (mode) => mode === "codex:askForApproval" || mode === "codex:approveForMe";
14481
+ if (!input.supportsLiveReviewer || input.executionMode === "repair" || !reviewerMode(input.permissionMode) || !reviewerMode(next)) return {
14482
+ status: "not_applied",
14483
+ taskId,
14484
+ reasonCode: "adapter.permission_mode_update_unsupported"
14485
+ };
14486
+ if (toRecord$7(await session.requestControl("turn/settings/update", {
14487
+ threadId: executionThreadId,
14488
+ turnId: activeTurnId,
14489
+ approvalsReviewer: next === "codex:approveForMe" ? "auto_review" : "user"
14490
+ }, {
14491
+ code: "runtime.permission_mode_update_timeout",
14492
+ operation: "turn/settings/update",
14493
+ terminateSession: false
14494
+ }))?.status !== "applied" || turnSettled || interruptRequested) return {
14495
+ status: "not_applied",
14496
+ taskId,
14497
+ reasonCode: "adapter.task_not_active"
14498
+ };
14499
+ return {
14500
+ status: "applied",
14501
+ effectiveFrom: "subsequent_tool_requests",
14502
+ taskId
14503
+ };
14504
+ },
13878
14505
  steer: async (steeringInput) => {
13879
14506
  const targetTurnId = activeTurnId;
13880
14507
  if (!targetTurnId || turnSettled || interruptRequested || input.cancellationSignal?.aborted) return {
@@ -14015,7 +14642,7 @@ function requireSuccessfulCodexTurn(turn) {
14015
14642
  });
14016
14643
  }
14017
14644
  async function verifyCodexAppServerThread(input) {
14018
- const threadId = normalizeOptionalText$30(input.threadId);
14645
+ const threadId = normalizeOptionalText$28(input.threadId);
14019
14646
  if (!threadId) throw new CodexAppServerTransportError({
14020
14647
  code: "schema.invalid",
14021
14648
  errorType: "config",
@@ -14038,7 +14665,7 @@ async function verifyCodexAppServerThread(input) {
14038
14665
  });
14039
14666
  }
14040
14667
  async function resolveCodexAppServerCompletedTurn(input) {
14041
- const threadId = normalizeOptionalText$30(input.threadId);
14668
+ const threadId = normalizeOptionalText$28(input.threadId);
14042
14669
  if (!threadId) throw new CodexAppServerTransportError({
14043
14670
  code: "schema.invalid",
14044
14671
  errorType: "config",
@@ -14070,13 +14697,13 @@ async function resolveCodexAppServerCompletedTurn(input) {
14070
14697
  });
14071
14698
  }
14072
14699
  async function forkCodexAppServerThread(input) {
14073
- const sourceThreadId = normalizeOptionalText$30(input.sourceThreadId);
14700
+ const sourceThreadId = normalizeOptionalText$28(input.sourceThreadId);
14074
14701
  if (!sourceThreadId) throw new CodexAppServerTransportError({
14075
14702
  code: "schema.invalid",
14076
14703
  errorType: "config",
14077
14704
  message: "schema.invalid: sourceThreadId is required"
14078
14705
  });
14079
- const sourceCompletedTurnId = normalizeOptionalText$30(input.sourceCompletedTurnId);
14706
+ const sourceCompletedTurnId = normalizeOptionalText$28(input.sourceCompletedTurnId);
14080
14707
  const executionContextScoped = input.computerFileAccessBoundary?.executionContextAccess !== void 0;
14081
14708
  if (sourceCompletedTurnId && input.forkFullHistory) throw new CodexAppServerTransportError({
14082
14709
  code: "schema.invalid",
@@ -14131,7 +14758,7 @@ async function forkCodexAppServerThread(input) {
14131
14758
  code: "context.fork_timeout",
14132
14759
  operation: "thread/fork"
14133
14760
  }));
14134
- const title = normalizeOptionalText$30(input.title);
14761
+ const title = normalizeOptionalText$28(input.title);
14135
14762
  if (title) try {
14136
14763
  await session.requestControl("thread/name/set", {
14137
14764
  name: title,
@@ -14160,7 +14787,7 @@ function scopedRuntimeWorkspaceParams(permissions, workingDirectory) {
14160
14787
  return permissions.permissions ? { runtimeWorkspaceRoots: [workingDirectory] } : {};
14161
14788
  }
14162
14789
  async function resolveDispatchThreadContext(input) {
14163
- const existingThreadId = normalizeOptionalText$30(input.threadId);
14790
+ const existingThreadId = normalizeOptionalText$28(input.threadId);
14164
14791
  if (existingThreadId && input.executionMode === "repair" && (!input.executionContextScoped || input.session.deliveryOnly)) return await forkEphemeralCodexRepairThread({
14165
14792
  conversationPolicyParams: input.conversationPolicyParams,
14166
14793
  codexWorkdir: input.codexWorkdir,
@@ -14239,7 +14866,7 @@ function buildOpenMeldCodexThreadSource(instructionEpoch) {
14239
14866
  }
14240
14867
  async function resolveCodexAppServerCollaborationMode(input) {
14241
14868
  if (input.collaborationMode !== "plan") return null;
14242
- const model = normalizeOptionalText$30(input.model);
14869
+ const model = normalizeOptionalText$28(input.model);
14243
14870
  if (!model) throw new CodexAppServerTransportError({
14244
14871
  code: "protocol.invalid",
14245
14872
  errorType: "adapter",
@@ -14274,12 +14901,12 @@ async function resolveCodexAppServerTurnCollaborationMode(input) {
14274
14901
  }
14275
14902
  function readCodexAppServerCollaborationModePreset(value) {
14276
14903
  const preset = toRecord$7(value);
14277
- const mode = normalizeOptionalText$30(preset?.mode);
14904
+ const mode = normalizeOptionalText$28(preset?.mode);
14278
14905
  if (mode !== "default" && mode !== "plan") return null;
14279
14906
  return {
14280
14907
  mode,
14281
- model: normalizeOptionalText$30(preset?.model),
14282
- reasoningEffort: normalizeOptionalText$30(preset?.reasoning_effort)
14908
+ model: normalizeOptionalText$28(preset?.model),
14909
+ reasoningEffort: normalizeOptionalText$28(preset?.reasoning_effort)
14283
14910
  };
14284
14911
  }
14285
14912
  function resolveCodexAppServerPermissionModeParams(value, executionMode, hasComputerFileAccessBoundary = false, hasExecutionContextBoundary = false) {
@@ -14349,9 +14976,9 @@ function resolveCodexAgentControllerPermissionMode$1(value) {
14349
14976
  }
14350
14977
  function resolveCodexAppServerConversationPolicyParams(conversationPolicy) {
14351
14978
  const params = {};
14352
- const model = normalizeOptionalText$30(conversationPolicy?.model);
14979
+ const model = normalizeOptionalText$28(conversationPolicy?.model);
14353
14980
  if (model) params.model = model;
14354
- const reasoningLevel = normalizeOptionalText$30(conversationPolicy?.reasoningLevel);
14981
+ const reasoningLevel = normalizeOptionalText$28(conversationPolicy?.reasoningLevel);
14355
14982
  if (reasoningLevel) params.effort = reasoningLevel;
14356
14983
  return params;
14357
14984
  }
@@ -14640,7 +15267,7 @@ var CodexAppServerSession = class {
14640
15267
  }
14641
15268
  async selectSpaceToolCarrier(input) {
14642
15269
  if (!this.#spaceActionTools) return;
14643
- const existingThreadId = normalizeOptionalText$30(input.threadId);
15270
+ const existingThreadId = normalizeOptionalText$28(input.threadId);
14644
15271
  let nativeThread = false;
14645
15272
  if (existingThreadId) {
14646
15273
  nativeThread = await this.readSpaceToolCarrier({
@@ -14727,7 +15354,7 @@ var CodexAppServerSession = class {
14727
15354
  return this.deliveryOnly ? { environments: [] } : {};
14728
15355
  }
14729
15356
  async startDispatchThread(params) {
14730
- const source = normalizeOptionalText$30(params.threadSource) ?? "user";
15357
+ const source = normalizeOptionalText$28(params.threadSource) ?? "user";
14731
15358
  try {
14732
15359
  return await this.requestControl("thread/start", {
14733
15360
  ...params,
@@ -14776,12 +15403,13 @@ var CodexAppServerSession = class {
14776
15403
  }
14777
15404
  };
14778
15405
  }
14779
- async verifyScopedMcp(threadId) {
15406
+ async verifyScopedMcp(threadId, nativeVersion) {
14780
15407
  const scoped = this.#computerFileAccessBoundary?.executionContextAccess !== void 0 || this.deliveryOnly;
14781
15408
  if (!(scoped || this.spaceToolInvocation.enabled)) return;
14782
15409
  const inventory = await this.requestControl("mcpServerStatus/list", {
14783
15410
  threadId,
14784
15411
  detail: scoped ? "full" : "toolsAndAuthOnly",
15412
+ ...!scoped && supportsAgentControllerVersion(nativeVersion, ">=0.160.0") ? { serverName: OPENMELD_SPACE_ACTION_MCP_SERVER_ID } : {},
14785
15413
  limit: 100
14786
15414
  }, {
14787
15415
  code: "execution_context.mcp_inventory_timeout",
@@ -14906,7 +15534,7 @@ var CodexAppServerSession = class {
14906
15534
  });
14907
15535
  }
14908
15536
  setNewSessionTitleInBackground(input) {
14909
- if (normalizeOptionalText$30(input.existingThreadId) || input.executionMode === "repair" || !input.title) return;
15537
+ if (normalizeOptionalText$28(input.existingThreadId) || input.executionMode === "repair" || !input.title) return;
14910
15538
  this.request("thread/name/set", {
14911
15539
  name: input.title,
14912
15540
  threadId: input.threadId
@@ -14929,7 +15557,7 @@ var CodexAppServerSession = class {
14929
15557
  if (candidate.method !== "turn/completed") return false;
14930
15558
  const params = toRecord$7(candidate.params);
14931
15559
  const turn = toRecord$7(params?.turn);
14932
- return params?.threadId === input.threadId && normalizeOptionalText$30(turn?.id) === input.turnId;
15560
+ return params?.threadId === input.threadId && normalizeOptionalText$28(turn?.id) === input.turnId;
14933
15561
  })).params)?.turn);
14934
15562
  if (!turn) throw new CodexAppServerTransportError({
14935
15563
  code: "protocol.invalid",
@@ -14941,6 +15569,7 @@ var CodexAppServerSession = class {
14941
15569
  registerActiveTurn(input) {
14942
15570
  if (!input.onActiveTurn) return null;
14943
15571
  return input.onActiveTurn({
15572
+ updatePermissionMode: input.updatePermissionMode,
14944
15573
  steer: input.steer,
14945
15574
  taskId: input.taskId,
14946
15575
  threadId: input.threadId,
@@ -15063,8 +15692,8 @@ var CodexAppServerSession = class {
15063
15692
  }
15064
15693
  #observeContextTelemetry(message) {
15065
15694
  const params = toRecord$7(message.params);
15066
- if (message.method === "turn/started" && params?.threadId === this.#usageThreadId) this.#usageTurnId = normalizeOptionalText$30(toRecord$7(params.turn)?.id);
15067
- if (message.method === "model/rerouted" && params?.threadId === this.#usageThreadId) this.#usageModel = normalizeOptionalText$30(params.toModel);
15695
+ if (message.method === "turn/started" && params?.threadId === this.#usageThreadId) this.#usageTurnId = normalizeOptionalText$28(toRecord$7(params.turn)?.id);
15696
+ if (message.method === "model/rerouted" && params?.threadId === this.#usageThreadId) this.#usageModel = normalizeOptionalText$28(params.toModel);
15068
15697
  if (message.method === "thread/tokenUsage/updated") {
15069
15698
  const tokenUsage = readCodexTokenUsage(toRecord$7(message.params)?.tokenUsage);
15070
15699
  if (tokenUsage) {
@@ -15076,11 +15705,11 @@ var CodexAppServerSession = class {
15076
15705
  if ((message.method === "item/started" || message.method === "item/completed") && toRecord$7(toRecord$7(message.params)?.item)?.type === "contextCompaction") this.#contextCompactionObserved = true;
15077
15706
  }
15078
15707
  #observeAiUsage(params, tokenUsage) {
15079
- const threadId = normalizeOptionalText$30(params?.threadId);
15708
+ const threadId = normalizeOptionalText$28(params?.threadId);
15080
15709
  if (!threadId) return;
15081
15710
  const previousTotal = this.#usageTotalByThread.get(threadId);
15082
15711
  this.#usageTotalByThread.set(threadId, tokenUsage.total.totalTokens);
15083
- const turnId = normalizeOptionalText$30(params?.turnId);
15712
+ const turnId = normalizeOptionalText$28(params?.turnId);
15084
15713
  if (threadId !== this.#usageThreadId || !turnId || turnId !== this.#usageTurnId || previousTotal === tokenUsage.total.totalTokens) return;
15085
15714
  const eventId = `codex:${threadId}:${turnId}:${tokenUsage.total.totalTokens}`;
15086
15715
  if (this.#aiUsage.has(eventId)) return;
@@ -15170,7 +15799,7 @@ var CodexAppServerSession = class {
15170
15799
  #collectAgentMessageDelta(message) {
15171
15800
  if (message.method !== "item/agentMessage/delta") return;
15172
15801
  const params = toRecord$7(message.params);
15173
- const itemId = normalizeOptionalText$30(params?.itemId);
15802
+ const itemId = normalizeOptionalText$28(params?.itemId);
15174
15803
  const delta = readAgentMessageDeltaText(params?.delta);
15175
15804
  if (!(itemId && delta)) return;
15176
15805
  this.markAgentOutputObserved();
@@ -15256,7 +15885,7 @@ var CodexAppServerSession = class {
15256
15885
  });
15257
15886
  }
15258
15887
  emitProviderConversationObserved(threadId) {
15259
- const agentControllerConversationId = normalizeOptionalText$30(threadId);
15888
+ const agentControllerConversationId = normalizeOptionalText$28(threadId);
15260
15889
  if (!agentControllerConversationId) return;
15261
15890
  this.#emitRuntimeEvent({
15262
15891
  agentControllerConversationId,
@@ -15283,9 +15912,9 @@ function readThreadContextFromResponse(value) {
15283
15912
  const response = toRecord$7(value);
15284
15913
  return {
15285
15914
  permissionResponse: value,
15286
- model: normalizeOptionalText$30(response?.model),
15915
+ model: normalizeOptionalText$28(response?.model),
15287
15916
  threadId: readRequiredText(response?.thread?.id, "thread response thread.id"),
15288
- threadSource: normalizeOptionalText$30(response?.thread?.threadSource)
15917
+ threadSource: normalizeOptionalText$28(response?.thread?.threadSource)
15289
15918
  };
15290
15919
  }
15291
15920
  function readLastCompletedTurnId(value) {
@@ -15293,8 +15922,8 @@ function readLastCompletedTurnId(value) {
15293
15922
  const turns = Array.isArray(response?.thread?.turns) ? response.thread.turns : [];
15294
15923
  for (let index = turns.length - 1; index >= 0; index -= 1) {
15295
15924
  const turn = turns[index];
15296
- if (normalizeOptionalText$30(turn?.status) !== "completed") continue;
15297
- const turnId = normalizeOptionalText$30(turn?.id);
15925
+ if (normalizeOptionalText$28(turn?.status) !== "completed") continue;
15926
+ const turnId = normalizeOptionalText$28(turn?.id);
15298
15927
  if (turnId) return turnId;
15299
15928
  }
15300
15929
  return null;
@@ -15309,14 +15938,14 @@ function readTurnStartResponse(value) {
15309
15938
  return turn;
15310
15939
  }
15311
15940
  function readAgentMessageOutput(turn) {
15312
- const text = (Array.isArray(turn.items) ? turn.items : []).filter((item) => item.type === "agentMessage").map((item) => normalizeOptionalText$30(item.text)).filter((item) => item !== null).join("\n").trim();
15941
+ const text = (Array.isArray(turn.items) ? turn.items : []).filter((item) => item.type === "agentMessage").map((item) => normalizeOptionalText$28(item.text)).filter((item) => item !== null).join("\n").trim();
15313
15942
  return text.length > 0 ? text : null;
15314
15943
  }
15315
15944
  function readTurnFailureMessage(turn) {
15316
- return normalizeOptionalText$30(turn.error?.message) ?? "codex app-server turn failed";
15945
+ return normalizeOptionalText$28(turn.error?.message) ?? "codex app-server turn failed";
15317
15946
  }
15318
15947
  function readTurnFailureCodexErrorInfo(turn) {
15319
- return normalizeOptionalText$30(turn.error?.codexErrorInfo);
15948
+ return normalizeOptionalText$28(turn.error?.codexErrorInfo);
15320
15949
  }
15321
15950
  function readCodexTokenUsage(value) {
15322
15951
  const usage = toRecord$7(value);
@@ -15774,7 +16403,7 @@ function convertCodexMcpElicitationValues(values, schema) {
15774
16403
  return String(value);
15775
16404
  }
15776
16405
  function normalizeBoundedText$3(value, maxLength) {
15777
- const text = normalizeOptionalText$30(value);
16406
+ const text = normalizeOptionalText$28(value);
15778
16407
  return text ? text.slice(0, maxLength) : null;
15779
16408
  }
15780
16409
  function safeJsonStringify(value) {
@@ -15809,7 +16438,7 @@ function buildServerRequestDeclineResponse(method) {
15809
16438
  }
15810
16439
  }
15811
16440
  function toJsonRpcTransportError$1(error) {
15812
- const message = normalizeOptionalText$30(error.message) ?? "codex app-server error";
16441
+ const message = normalizeOptionalText$28(error.message) ?? "codex app-server error";
15813
16442
  const originalError = createProviderOriginalError(message) ?? void 0;
15814
16443
  if (error.code === -32601) return new CodexAppServerTransportError({
15815
16444
  code: "runtime.method_unsupported",
@@ -15898,7 +16527,7 @@ function toCodexAppServerTransportError(error, timeoutMs) {
15898
16527
  });
15899
16528
  }
15900
16529
  function readRequiredText(value, label) {
15901
- const text = normalizeOptionalText$30(value);
16530
+ const text = normalizeOptionalText$28(value);
15902
16531
  if (text) return text;
15903
16532
  throw new CodexAppServerTransportError({
15904
16533
  code: "protocol.invalid",
@@ -15913,7 +16542,7 @@ function toRecord$7(value) {
15913
16542
  function normalizeText$7(value) {
15914
16543
  return String(value ?? "").trim();
15915
16544
  }
15916
- function normalizeOptionalText$30(value) {
16545
+ function normalizeOptionalText$28(value) {
15917
16546
  const normalized = normalizeText$7(value);
15918
16547
  return normalized.length > 0 ? normalized : null;
15919
16548
  }
@@ -15926,7 +16555,7 @@ function isProcessGroupAbsent(processId) {
15926
16555
  }
15927
16556
  }
15928
16557
  function parseCodexAppServerVersion(response) {
15929
- return normalizeOptionalText$30(toRecord$7(response)?.userAgent)?.match(CODEX_APP_SERVER_VERSION_PATTERN)?.[1] ?? null;
16558
+ return normalizeOptionalText$28(toRecord$7(response)?.userAgent)?.match(CODEX_APP_SERVER_VERSION_PATTERN)?.[1] ?? null;
15930
16559
  }
15931
16560
  function resolveCodexAppServerAuthStatus(input) {
15932
16561
  if (input.account) return "authenticated";
@@ -15979,7 +16608,7 @@ async function resolveInstalledCodexLaunchCandidates(input) {
15979
16608
  const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
15980
16609
  additionalCommandDirectories: resolveCodexAppBundleCommandDirectories(input?.appBundleRoots),
15981
16610
  commandName: DEFAULT_CODEX_COMMAND,
15982
- configuredCommand: normalizeOptionalText$29(process.env.OPENMELD_DAEMON_RUNTIME_CODEX_BIN),
16611
+ configuredCommand: normalizeOptionalText$27(process.env.OPENMELD_DAEMON_RUNTIME_CODEX_BIN),
15983
16612
  displayName: "Codex",
15984
16613
  preferredLaunchContract: input?.preferredLaunchContract
15985
16614
  });
@@ -16040,7 +16669,7 @@ async function verifyCodexCommandLaunchContract(input) {
16040
16669
  });
16041
16670
  }
16042
16671
  function resolveCodexTimeoutMs() {
16043
- const raw = normalizeOptionalText$29(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
16672
+ const raw = normalizeOptionalText$27(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
16044
16673
  if (!raw) return null;
16045
16674
  const parsed = Number.parseInt(raw, 10);
16046
16675
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
@@ -16050,7 +16679,7 @@ function isCodexHostApplicationCommandPath(commandPath) {
16050
16679
  return resolveCodexAppLabel(commandPath) !== null;
16051
16680
  }
16052
16681
  function resolveCodexAppBundleCommandDirectories(appBundleRoots) {
16053
- const home = normalizeOptionalText$29(process.env.HOME) ?? homedir();
16682
+ const home = normalizeOptionalText$27(process.env.HOME) ?? homedir();
16054
16683
  return (appBundleRoots ?? ["/Applications", join(home, "Applications")]).flatMap((root) => CODEX_APP_BUNDLE_NAMES.flatMap((appBundleName) => CODEX_APP_COMMAND_LAYOUTS.map((layout) => dirname(join(root, appBundleName, "Contents", "Resources", ...layout)))));
16055
16684
  }
16056
16685
  async function inspectCodexLaunchCandidate(input) {
@@ -16111,7 +16740,7 @@ function resolveCodexControlProbeTimeoutMs(timeoutMs) {
16111
16740
  function toErrorMessage$14(error) {
16112
16741
  return error instanceof Error ? error.message : String(error);
16113
16742
  }
16114
- function normalizeOptionalText$29(value) {
16743
+ function normalizeOptionalText$27(value) {
16115
16744
  const normalized = String(value ?? "").trim();
16116
16745
  return normalized.length > 0 ? normalized : null;
16117
16746
  }
@@ -16172,9 +16801,9 @@ function extractOutputFromCodexLine(line) {
16172
16801
  const item = record.item && typeof record.item === "object" && !Array.isArray(record.item) ? record.item : null;
16173
16802
  const response = record.response && typeof record.response === "object" && !Array.isArray(record.response) ? record.response : null;
16174
16803
  if (record.type === "item.completed" && item?.type === "agent_message") {
16175
- const phase = normalizeOptionalText$28(item.phase ?? record.phase);
16804
+ const phase = normalizeOptionalText$26(item.phase ?? record.phase);
16176
16805
  if (phase && phase !== "final_answer") return null;
16177
- const text = normalizeOptionalText$28(item.text);
16806
+ const text = normalizeOptionalText$26(item.text);
16178
16807
  return text ? {
16179
16808
  previewable: false,
16180
16809
  terminal: true,
@@ -16182,7 +16811,7 @@ function extractOutputFromCodexLine(line) {
16182
16811
  } : null;
16183
16812
  }
16184
16813
  if (record.type === "response.completed") {
16185
- const text = normalizeOptionalText$28(response?.output_text);
16814
+ const text = normalizeOptionalText$26(response?.output_text);
16186
16815
  return text ? {
16187
16816
  previewable: false,
16188
16817
  terminal: true,
@@ -16212,12 +16841,12 @@ function extractThreadIdFromCodexLine(line) {
16212
16841
  const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
16213
16842
  if (!record) return null;
16214
16843
  if (record.type !== "thread.started") return null;
16215
- return normalizeOptionalText$28(record.thread_id);
16844
+ return normalizeOptionalText$26(record.thread_id);
16216
16845
  }
16217
16846
  function normalizeText$6(value) {
16218
16847
  return String(value ?? "").trim();
16219
16848
  }
16220
- function normalizeOptionalText$28(value) {
16849
+ function normalizeOptionalText$26(value) {
16221
16850
  const normalized = normalizeText$6(value);
16222
16851
  return normalized.length > 0 ? normalized : null;
16223
16852
  }
@@ -16243,7 +16872,7 @@ async function invokeCodexCliTransport(input) {
16243
16872
  errorType: "config",
16244
16873
  message: "This Codex CLI path cannot restrict correction to delivery tools. No correction turn was started."
16245
16874
  });
16246
- const prompt = normalizeOptionalText$27(input.prompt);
16875
+ const prompt = normalizeOptionalText$25(input.prompt);
16247
16876
  if (!prompt) throw new CodexCliTransportError({
16248
16877
  code: "schema.invalid",
16249
16878
  errorType: "config",
@@ -16336,7 +16965,7 @@ async function invokeCodexCliTransport(input) {
16336
16965
  providerAccessEvidence: classifiedFailure.providerAccessEvidence
16337
16966
  });
16338
16967
  }
16339
- const output = normalizeOptionalText$27(latestOutput);
16968
+ const output = normalizeOptionalText$25(latestOutput);
16340
16969
  if (!output) {
16341
16970
  if (providerErrorMessages.length > 0) {
16342
16971
  const classifiedFailure = classifyCodexFailure({
@@ -16372,12 +17001,12 @@ async function invokeCodexCliTransport(input) {
16372
17001
  previewEmitted: previewEmitter.emitted,
16373
17002
  ...driverResult.lifecycle.processId === null ? {} : { processId: driverResult.lifecycle.processId },
16374
17003
  ...driverResult.lifecycle.processSpawnedAtMs === null ? {} : { processSpawnedAtMs: driverResult.lifecycle.processSpawnedAtMs },
16375
- resumedContext: normalizeOptionalText$27(input.threadId) !== null,
17004
+ resumedContext: normalizeOptionalText$25(input.threadId) !== null,
16376
17005
  ...driverResult.lifecycle.stdinClosedAtMs === null ? {} : { stdinClosedAtMs: driverResult.lifecycle.stdinClosedAtMs },
16377
17006
  streamingMode: input.streamingMode ?? "final",
16378
17007
  ...driverResult.lifecycle.timeoutTriggeredAtMs === null ? {} : { timeoutTriggeredAtMs: driverResult.lifecycle.timeoutTriggeredAtMs }
16379
17008
  },
16380
- threadId: normalizeOptionalText$27(resolvedThreadId)
17009
+ threadId: normalizeOptionalText$25(resolvedThreadId)
16381
17010
  };
16382
17011
  }
16383
17012
  function extractCodexToolActivityEventFromLine(line) {
@@ -16481,9 +17110,9 @@ function resolveCodexAgentControllerPermissionMode(value) {
16481
17110
  }
16482
17111
  function buildCodexConversationPolicyArgs(conversationPolicy) {
16483
17112
  const args = [];
16484
- const model = normalizeOptionalText$27(conversationPolicy?.model);
17113
+ const model = normalizeOptionalText$25(conversationPolicy?.model);
16485
17114
  if (model) args.push("-m", model);
16486
- const reasoningLevel = normalizeOptionalText$27(conversationPolicy?.reasoningLevel);
17115
+ const reasoningLevel = normalizeOptionalText$25(conversationPolicy?.reasoningLevel);
16487
17116
  if (reasoningLevel) args.push("-c", `model_reasoning_effort=${reasoningLevel}`);
16488
17117
  return args;
16489
17118
  }
@@ -16570,7 +17199,7 @@ const toCodexCliTransportError = (error, timeoutMs) => {
16570
17199
  });
16571
17200
  };
16572
17201
  const collectCodexErrorMessage = (line, messages) => {
16573
- const normalizedLine = normalizeOptionalText$27(line);
17202
+ const normalizedLine = normalizeOptionalText$25(line);
16574
17203
  if (!normalizedLine) return;
16575
17204
  const jsonMessage = readCodexJsonErrorMessage(normalizedLine);
16576
17205
  if (jsonMessage) messages.push(jsonMessage);
@@ -16584,14 +17213,14 @@ const readCodexJsonErrorMessage = (line) => {
16584
17213
  }
16585
17214
  const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
16586
17215
  if (!record) return null;
16587
- const message = normalizeOptionalText$27(record.message);
17216
+ const message = normalizeOptionalText$25(record.message);
16588
17217
  if (record.type === "error" && message) return message;
16589
- const errorMessage = normalizeOptionalText$27((record.error && typeof record.error === "object" && !Array.isArray(record.error) ? record.error : null)?.message);
17218
+ const errorMessage = normalizeOptionalText$25((record.error && typeof record.error === "object" && !Array.isArray(record.error) ? record.error : null)?.message);
16590
17219
  if (record.type === "turn.failed" && errorMessage) return errorMessage;
16591
17220
  return null;
16592
17221
  };
16593
17222
  const classifyCodexFailure = (input) => {
16594
- const providerMessage = resolveProviderFailureMessage$2(input);
17223
+ const providerMessage = resolveProviderFailureMessage$1(input);
16595
17224
  const originalError = providerMessage && input.providerErrorMessages.includes(providerMessage) ? createProviderOriginalError(providerMessage) ?? void 0 : void 0;
16596
17225
  if (providerMessage) {
16597
17226
  const lowered = providerMessage.toLowerCase();
@@ -16623,7 +17252,7 @@ const classifyCodexFailure = (input) => {
16623
17252
  originalError
16624
17253
  };
16625
17254
  }
16626
- const stderrText = normalizeOptionalText$27(input.stderrText);
17255
+ const stderrText = normalizeOptionalText$25(input.stderrText);
16627
17256
  if (stderrText) return {
16628
17257
  code: "upstream_unreachable",
16629
17258
  errorType: "adapter",
@@ -16635,16 +17264,16 @@ const classifyCodexFailure = (input) => {
16635
17264
  originalError
16636
17265
  };
16637
17266
  };
16638
- const resolveProviderFailureMessage$2 = (input) => {
17267
+ const resolveProviderFailureMessage$1 = (input) => {
16639
17268
  const candidateMessages = [
16640
17269
  ...input.providerErrorMessages,
16641
- ...normalizeOptionalText$27(input.stderrText) ? [normalizeOptionalText$27(input.stderrText)] : [],
16642
- ...normalizeOptionalText$27(input.stdoutText) ? [normalizeOptionalText$27(input.stdoutText)] : []
17270
+ ...normalizeOptionalText$25(input.stderrText) ? [normalizeOptionalText$25(input.stderrText)] : [],
17271
+ ...normalizeOptionalText$25(input.stdoutText) ? [normalizeOptionalText$25(input.stdoutText)] : []
16643
17272
  ].filter((value) => Boolean(value));
16644
- for (const candidate of candidateMessages) if (looksLikeProviderFailure$2(candidate)) return candidate;
17273
+ for (const candidate of candidateMessages) if (looksLikeProviderFailure$1(candidate)) return candidate;
16645
17274
  return candidateMessages[0] ?? null;
16646
17275
  };
16647
- const looksLikeProviderFailure$2 = (value) => {
17276
+ const looksLikeProviderFailure$1 = (value) => {
16648
17277
  const normalized = value.toLowerCase();
16649
17278
  return looksLikeRuntimePermissionDenialMessage(value) || classifyCodexProviderAccountFailure({ message: normalized }) !== null;
16650
17279
  };
@@ -16663,7 +17292,7 @@ const toControllerClientUpgradeRequiredMessage = (value) => {
16663
17292
  function normalizeText$5(value) {
16664
17293
  return String(value ?? "").trim();
16665
17294
  }
16666
- function normalizeOptionalText$27(value) {
17295
+ function normalizeOptionalText$25(value) {
16667
17296
  const normalized = normalizeText$5(value);
16668
17297
  return normalized.length > 0 ? normalized : null;
16669
17298
  }
@@ -16939,6 +17568,7 @@ const createCodexAdapter = (options) => {
16939
17568
  const stoppedDispatches = /* @__PURE__ */ new Map();
16940
17569
  const registerAppServerTurn = (registration) => {
16941
17570
  const activeTurn = {
17571
+ updatePermissionMode: registration.updatePermissionMode,
16942
17572
  interrupt: registration.interrupt,
16943
17573
  steer: registration.steer,
16944
17574
  threadId: registration.threadId,
@@ -17135,6 +17765,14 @@ const createCodexAdapter = (options) => {
17135
17765
  dispatch,
17136
17766
  interrupt,
17137
17767
  steer,
17768
+ updatePermissionMode: async (input) => {
17769
+ const activeTurn = activeAppServerTurns.get(input.taskId);
17770
+ return activeTurn ? await activeTurn.updatePermissionMode(input) : {
17771
+ status: "not_applied",
17772
+ taskId: input.taskId,
17773
+ reasonCode: "adapter.task_not_active"
17774
+ };
17775
+ },
17138
17776
  verifyComputerFileAccessBoundary
17139
17777
  }, { [READ_CODEX_DISPATCH_STOP_EVIDENCE]: (taskId) => stoppedDispatches.get(taskId) ?? null });
17140
17778
  };
@@ -17321,7 +17959,7 @@ const resolveDefaultCodexInvoke = (options) => {
17321
17959
  ...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
17322
17960
  prompt: input.prompt,
17323
17961
  streamingMode: input.streamingMode,
17324
- threadId: normalizeOptionalText$26(input.agentControllerConversationId)
17962
+ threadId: normalizeOptionalText$24(input.agentControllerConversationId)
17325
17963
  });
17326
17964
  const agentControllerConversation = CODEX_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
17327
17965
  bridgeSpec: CODEX_CONVERSATION_BRIDGE_SPEC,
@@ -17382,7 +18020,7 @@ const resolveDefaultCodexAppServerInvoke = (input) => {
17382
18020
  prompt: dispatchInput.prompt,
17383
18021
  streamingMode: dispatchInput.streamingMode,
17384
18022
  taskId: dispatchInput.taskId,
17385
- threadId: normalizeOptionalText$26(dispatchInput.agentControllerConversationId)
18023
+ threadId: normalizeOptionalText$24(dispatchInput.agentControllerConversationId)
17386
18024
  });
17387
18025
  const agentControllerConversation = CODEX_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
17388
18026
  bridgeSpec: CODEX_CONVERSATION_BRIDGE_SPEC,
@@ -17443,9 +18081,9 @@ async function resolveCodexDispatchLaunchContract(input) {
17443
18081
  });
17444
18082
  }
17445
18083
  function resolveConfiguredCodexLaunchContract(input) {
17446
- return input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$26(input.codexBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$26(input.codexBin) }) : null);
18084
+ return input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$24(input.codexBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$24(input.codexBin) }) : null);
17447
18085
  }
17448
- const normalizeOptionalText$26 = (value) => {
18086
+ const normalizeOptionalText$24 = (value) => {
17449
18087
  const normalized = String(value ?? "").trim();
17450
18088
  return normalized.length > 0 ? normalized : null;
17451
18089
  };
@@ -17508,7 +18146,7 @@ async function resolveInstalledCursorLaunchCandidates(input) {
17508
18146
  const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
17509
18147
  additionalCommandDirectories: resolveCursorCommandDirectories(),
17510
18148
  commandName: DEFAULT_CURSOR_COMMAND,
17511
- configuredCommand: normalizeOptionalText$25(process.env.OPENMELD_DAEMON_RUNTIME_CURSOR_BIN),
18149
+ configuredCommand: normalizeOptionalText$23(process.env.OPENMELD_DAEMON_RUNTIME_CURSOR_BIN),
17512
18150
  displayName: "Cursor CLI",
17513
18151
  preferredLaunchContract: input?.preferredLaunchContract
17514
18152
  });
@@ -17531,7 +18169,7 @@ async function resolveInstalledCursorLaunchCandidates(input) {
17531
18169
  };
17532
18170
  }
17533
18171
  async function refreshCursorPersistedLaunchContract(input) {
17534
- const configuredCommand = normalizeOptionalText$25(process.env.OPENMELD_DAEMON_RUNTIME_CURSOR_BIN);
18172
+ const configuredCommand = normalizeOptionalText$23(process.env.OPENMELD_DAEMON_RUNTIME_CURSOR_BIN);
17535
18173
  if (configuredCommand) {
17536
18174
  const resolution = await resolveInstalledNodeScriptLaunchContract({
17537
18175
  commandName: DEFAULT_CURSOR_COMMAND,
@@ -17545,7 +18183,7 @@ async function refreshCursorPersistedLaunchContract(input) {
17545
18183
  }
17546
18184
  if (input.launchContract.kind !== "node_script") return input.launchContract;
17547
18185
  const persistedLaunchContract = input.launchContract;
17548
- const home = normalizeOptionalText$25(process.env.HOME) ?? homedir();
18186
+ const home = normalizeOptionalText$23(process.env.HOME) ?? homedir();
17549
18187
  const managedVersionsRoot = join(home, ".local", "share", "cursor-agent", "versions");
17550
18188
  const canonicalManagedVersionsRoot = await realpath(managedVersionsRoot).catch(() => managedVersionsRoot);
17551
18189
  const canonicalPersistedScriptPath = await realpath(persistedLaunchContract.scriptPath).catch(() => persistedLaunchContract.scriptPath);
@@ -17585,7 +18223,7 @@ async function verifyCursorLaunchContract(input) {
17585
18223
  });
17586
18224
  }
17587
18225
  function resolveCursorTimeoutMs() {
17588
- const raw = normalizeOptionalText$25(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
18226
+ const raw = normalizeOptionalText$23(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
17589
18227
  if (!raw) return null;
17590
18228
  const parsed = Number.parseInt(raw, 10);
17591
18229
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
@@ -17598,7 +18236,7 @@ function isIncompleteLaunchContractCheck(verification) {
17598
18236
  return !verification.ok && verification.failureKind === "incomplete_check";
17599
18237
  }
17600
18238
  function resolveCursorCommandDirectories() {
17601
- return resolveCursorCommandPaths(normalizeOptionalText$25(process.env.HOME) ?? homedir()).map(dirname);
18239
+ return resolveCursorCommandPaths(normalizeOptionalText$23(process.env.HOME) ?? homedir()).map(dirname);
17602
18240
  }
17603
18241
  function resolveCursorCommandPaths(home) {
17604
18242
  return [join(home, ".local", "bin", DEFAULT_CURSOR_COMMAND), join(home, ".cursor", "bin", DEFAULT_CURSOR_COMMAND)];
@@ -17607,7 +18245,7 @@ function isManagedCursorVersionScript(input) {
17607
18245
  const segments = relative(input.managedVersionsRoot, input.scriptPath).split(PATH_SEGMENT_SPLIT_RE);
17608
18246
  return segments.length === 2 && segments[0] !== ".." && segments[0] !== "." && segments[1] === DEFAULT_CURSOR_COMMAND;
17609
18247
  }
17610
- function normalizeOptionalText$25(value) {
18248
+ function normalizeOptionalText$23(value) {
17611
18249
  const normalized = String(value ?? "").trim();
17612
18250
  return normalized.length > 0 ? normalized : null;
17613
18251
  }
@@ -18041,13 +18679,13 @@ var CursorAcpTransportError = class extends Error {
18041
18679
  }
18042
18680
  };
18043
18681
  async function invokeCursorAcpTransport(input) {
18044
- const prompt = normalizeOptionalText$24(input.prompt);
18682
+ const prompt = normalizeOptionalText$22(input.prompt);
18045
18683
  if (!prompt) throw new CursorAcpTransportError({
18046
18684
  code: "schema.invalid",
18047
18685
  errorType: "config",
18048
18686
  message: "schema.invalid: prompt is required"
18049
18687
  });
18050
- if (normalizeOptionalText$24(input.conversationPolicy?.reasoningLevel)) throw new CursorAcpTransportError({
18688
+ if (normalizeOptionalText$22(input.conversationPolicy?.reasoningLevel)) throw new CursorAcpTransportError({
18051
18689
  code: "model.reasoning_unsupported",
18052
18690
  errorType: "config",
18053
18691
  message: "model.reasoning_unsupported: Cursor ACP does not expose reasoning strength as an independent session option; choose an exact Cursor ACP model variant instead"
@@ -18093,13 +18731,13 @@ async function invokeCursorAcpTransport(input) {
18093
18731
  }
18094
18732
  async function runCursorAcpTurn(input) {
18095
18733
  await input.session.initialize();
18096
- const existingSessionId = normalizeOptionalText$24(input.input.sessionId);
18734
+ const existingSessionId = normalizeOptionalText$22(input.input.sessionId);
18097
18735
  const initialDescriptor = await input.session.openSession({ sessionId: input.deliveryScope ? null : existingSessionId });
18098
18736
  const continuitySessionId = input.deliveryScope ? existingSessionId ?? initialDescriptor.sessionId : initialDescriptor.sessionId;
18099
18737
  input.session.emitProviderConversationObserved(continuitySessionId);
18100
18738
  const modelResolution = await resolveCursorSessionModel({
18101
18739
  descriptor: initialDescriptor,
18102
- model: normalizeOptionalText$24(input.input.conversationPolicy?.model),
18740
+ model: normalizeOptionalText$22(input.input.conversationPolicy?.model),
18103
18741
  session: input.session
18104
18742
  });
18105
18743
  const { descriptor } = modelResolution;
@@ -18366,7 +19004,7 @@ var CursorAcpSession = class {
18366
19004
  return readSessionDescriptor(result, input.sessionId, "load");
18367
19005
  }
18368
19006
  const result = await this.request("session/new", params);
18369
- const sessionId = normalizeOptionalText$24(toRecord$5(result)?.sessionId);
19007
+ const sessionId = normalizeOptionalText$22(toRecord$5(result)?.sessionId);
18370
19008
  if (!sessionId) throw new CursorAcpTransportError({
18371
19009
  code: "protocol.invalid",
18372
19010
  errorType: "adapter",
@@ -18529,8 +19167,8 @@ function readSessionDescriptor(value, sessionId, sessionOperation) {
18529
19167
  const modelConfig = readConfigOption(record, "model");
18530
19168
  const legacyAvailableModelIds = readLegacyAvailableModelIds(models);
18531
19169
  const configAvailableModelIds = readConfigAvailableModelIds(modelConfig);
18532
- const legacyCurrentModelId = normalizeOptionalText$24(models?.currentModelId);
18533
- const configCurrentModelId = normalizeOptionalText$24(modelConfig?.currentValue);
19170
+ const legacyCurrentModelId = normalizeOptionalText$22(models?.currentModelId);
19171
+ const configCurrentModelId = normalizeOptionalText$22(modelConfig?.currentValue);
18534
19172
  const modelInventory = resolveModelInventory({
18535
19173
  configAvailableModelIds,
18536
19174
  configCurrentModelId,
@@ -18542,7 +19180,7 @@ function readSessionDescriptor(value, sessionId, sessionOperation) {
18542
19180
  availableModelIds: modelInventory.availableModelIds,
18543
19181
  configAvailableModelIds,
18544
19182
  configCurrentModelId,
18545
- currentModeId: normalizeOptionalText$24(modes?.currentModeId) ?? readCurrentConfigValue(record, "mode"),
19183
+ currentModeId: normalizeOptionalText$22(modes?.currentModeId) ?? readCurrentConfigValue(record, "mode"),
18546
19184
  currentModelId: modelInventory.currentModelId,
18547
19185
  legacyAvailableModelIds,
18548
19186
  legacyCurrentModelId,
@@ -18558,7 +19196,7 @@ function readConfigAvailableModelIds(modelConfig) {
18558
19196
  return uniqueModelIds((Array.isArray(modelConfig?.options) ? modelConfig.options : []).map((option) => toRecord$5(option)?.value));
18559
19197
  }
18560
19198
  function uniqueModelIds(values) {
18561
- return [...new Set(values.map(normalizeOptionalText$24).filter((modelId) => modelId !== null))];
19199
+ return [...new Set(values.map(normalizeOptionalText$22).filter((modelId) => modelId !== null))];
18562
19200
  }
18563
19201
  function resolveModelInventory(input) {
18564
19202
  const currentModelId = input.configCurrentModelId ?? input.legacyCurrentModelId;
@@ -18630,10 +19268,10 @@ function sanitizeDiagnosticModelId$1(modelId) {
18630
19268
  return modelId === null ? null : modelId.slice(0, MAX_MODEL_DIAGNOSTIC_ID_CHARS$1);
18631
19269
  }
18632
19270
  function readCurrentConfigValue(record, id) {
18633
- return normalizeOptionalText$24(readConfigOption(record, id)?.currentValue);
19271
+ return normalizeOptionalText$22(readConfigOption(record, id)?.currentValue);
18634
19272
  }
18635
19273
  function readConfigOption(record, id) {
18636
- return (Array.isArray(record?.configOptions) ? record.configOptions : []).map(toRecord$5).find((option) => (normalizeOptionalText$24(option?.configId) ?? normalizeOptionalText$24(option?.id)) === id) ?? null;
19274
+ return (Array.isArray(record?.configOptions) ? record.configOptions : []).map(toRecord$5).find((option) => (normalizeOptionalText$22(option?.configId) ?? normalizeOptionalText$22(option?.id)) === id) ?? null;
18637
19275
  }
18638
19276
  function resolveCursorAcpMode(value) {
18639
19277
  switch (resolveCursorPermissionMode(value)) {
@@ -18660,7 +19298,7 @@ function buildCursorAcpArgs(permissionMode) {
18660
19298
  }
18661
19299
  }
18662
19300
  function assertSuccessfulStopReason$1(value) {
18663
- const stopReason = normalizeOptionalText$24(toRecord$5(value)?.stopReason);
19301
+ const stopReason = normalizeOptionalText$22(toRecord$5(value)?.stopReason);
18664
19302
  if (!stopReason) throw new CursorAcpTransportError({
18665
19303
  code: "protocol.invalid",
18666
19304
  errorType: "adapter",
@@ -18681,7 +19319,7 @@ async function emitFinalPreviewIfRequested$1(input) {
18681
19319
  await input.onPreview({ text: input.output });
18682
19320
  }
18683
19321
  function toJsonRpcTransportError(error) {
18684
- const message = normalizeOptionalText$24(error.message) ?? "Cursor ACP error";
19322
+ const message = normalizeOptionalText$22(error.message) ?? "Cursor ACP error";
18685
19323
  const originalError = createProviderOriginalError(message);
18686
19324
  if (error.code === -32601) return new CursorAcpTransportError({
18687
19325
  code: "protocol.method_not_found",
@@ -18705,7 +19343,7 @@ function toCursorAcpTransportError(error, stderr, diagnostics) {
18705
19343
  message: error.message,
18706
19344
  ...error.originalError ? { originalError: error.originalError } : {}
18707
19345
  });
18708
- const classified = classifyCursorFailure([toErrorMessage$11(error), normalizeOptionalText$24(stderr)].filter((value) => value !== null).join("\n"));
19346
+ const classified = classifyCursorFailure([toErrorMessage$11(error), normalizeOptionalText$22(stderr)].filter((value) => value !== null).join("\n"));
18709
19347
  return diagnostics ? new CursorAcpTransportError({
18710
19348
  code: classified.code,
18711
19349
  diagnostics,
@@ -18714,7 +19352,7 @@ function toCursorAcpTransportError(error, stderr, diagnostics) {
18714
19352
  }) : classified;
18715
19353
  }
18716
19354
  function classifyCursorFailure(message, originalError = null) {
18717
- const normalized = normalizeOptionalText$24(message) ?? "Cursor ACP error";
19355
+ const normalized = normalizeOptionalText$22(message) ?? "Cursor ACP error";
18718
19356
  const lowered = normalized.toLowerCase();
18719
19357
  if (isCursorPlanUpgradeRequired(normalized)) return new CursorAcpTransportError({
18720
19358
  code: "cursor.plan_upgrade_required",
@@ -18750,7 +19388,7 @@ function classifyCursorFailure(message, originalError = null) {
18750
19388
  function normalizeOutputText$2(value) {
18751
19389
  return typeof value === "string" && value.length > 0 ? value : null;
18752
19390
  }
18753
- function normalizeOptionalText$24(value) {
19391
+ function normalizeOptionalText$22(value) {
18754
19392
  const normalized = typeof value === "string" ? value.trim() : "";
18755
19393
  return normalized.length > 0 ? normalized : null;
18756
19394
  }
@@ -18851,7 +19489,7 @@ function createDefaultCursorInvoke(input) {
18851
19489
  });
18852
19490
  } : void 0;
18853
19491
  const result = await invokeWithSingleContextHeal({
18854
- contextId: normalizeOptionalText$23(dispatchInput.agentControllerConversationId),
19492
+ contextId: normalizeOptionalText$21(dispatchInput.agentControllerConversationId),
18855
19493
  contextLossPolicy: dispatchInput.executionMode === "repair" ? "fail" : "rebuild",
18856
19494
  createRebuildFailedError: (error) => error instanceof CursorAcpTransportError && error.code === "cursor.plan_upgrade_required" ? error : new CursorAcpTransportError({
18857
19495
  cause: error,
@@ -18906,7 +19544,7 @@ function createDefaultCursorInvoke(input) {
18906
19544
  };
18907
19545
  }
18908
19546
  async function resolveCursorDispatchLaunchContract(input) {
18909
- const launchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$23(input.cursorBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$23(input.cursorBin) }) : null);
19547
+ const launchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$21(input.cursorBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$21(input.cursorBin) }) : null);
18910
19548
  if (!launchContract) throw Object.assign(/* @__PURE__ */ new Error("Cursor CLI launch contract is required for runtime dispatch."), {
18911
19549
  code: "controller.launch.needs_repair",
18912
19550
  errorType: "config"
@@ -18979,7 +19617,7 @@ async function interruptActiveCursorTurn(input) {
18979
19617
  };
18980
19618
  }
18981
19619
  }
18982
- function normalizeOptionalText$23(value) {
19620
+ function normalizeOptionalText$21(value) {
18983
19621
  const normalized = typeof value === "string" ? value.trim() : "";
18984
19622
  return normalized.length > 0 ? normalized : null;
18985
19623
  }
@@ -19006,7 +19644,7 @@ async function resolveInstalledGrokBuildLaunchCandidates(input) {
19006
19644
  const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
19007
19645
  additionalCommandDirectories: [join(resolveHome(), ".grok", "bin")],
19008
19646
  commandName: DEFAULT_GROK_BUILD_COMMAND,
19009
- configuredCommand: normalizeOptionalText$22(process.env.OPENMELD_DAEMON_RUNTIME_GROK_BUILD_BIN),
19647
+ configuredCommand: normalizeOptionalText$20(process.env.OPENMELD_DAEMON_RUNTIME_GROK_BUILD_BIN),
19010
19648
  displayName: "Grok Build",
19011
19649
  preferredLaunchContract: input?.preferredLaunchContract
19012
19650
  });
@@ -19039,15 +19677,15 @@ async function verifyGrokBuildLaunchContract(input) {
19039
19677
  });
19040
19678
  }
19041
19679
  function resolveGrokBuildTimeoutMs() {
19042
- const raw = normalizeOptionalText$22(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
19680
+ const raw = normalizeOptionalText$20(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
19043
19681
  if (!raw) return null;
19044
19682
  const parsed = Number.parseInt(raw, 10);
19045
19683
  return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
19046
19684
  }
19047
19685
  function resolveHome() {
19048
- return normalizeOptionalText$22(process.env.HOME) ?? homedir();
19686
+ return normalizeOptionalText$20(process.env.HOME) ?? homedir();
19049
19687
  }
19050
- function normalizeOptionalText$22(value) {
19688
+ function normalizeOptionalText$20(value) {
19051
19689
  const normalized = String(value ?? "").trim();
19052
19690
  return normalized.length > 0 ? normalized : null;
19053
19691
  }
@@ -20423,7 +21061,7 @@ async function invokeGrokBuildAcpTransport(input) {
20423
21061
  errorType: "config",
20424
21062
  message: "The current Wake's delivery capability is missing. No correction turn was started."
20425
21063
  });
20426
- const prompt = normalizeOptionalText$21(input.prompt);
21064
+ const prompt = normalizeOptionalText$19(input.prompt);
20427
21065
  if (!prompt) throw new GrokBuildAcpTransportError({
20428
21066
  code: "schema.invalid",
20429
21067
  errorType: "config",
@@ -20450,9 +21088,9 @@ async function invokeGrokBuildAcpTransport(input) {
20450
21088
  try {
20451
21089
  session.start();
20452
21090
  await session.initialize({ collectUsageLimits: false });
20453
- const existingSessionId = normalizeOptionalText$21(input.sessionId);
21091
+ const existingSessionId = normalizeOptionalText$19(input.sessionId);
20454
21092
  const descriptor = await session.openSession({
20455
- requestedModelId: normalizeOptionalText$21(input.conversationPolicy?.model),
21093
+ requestedModelId: normalizeOptionalText$19(input.conversationPolicy?.model),
20456
21094
  sessionId: deliveryScope ? null : existingSessionId
20457
21095
  });
20458
21096
  await verifyOptionalDeliveryScope(deliveryScope, session, descriptor.sessionId);
@@ -20460,8 +21098,8 @@ async function invokeGrokBuildAcpTransport(input) {
20460
21098
  session.emitProviderConversationObserved(continuitySessionId);
20461
21099
  await session.applyModelSelection({
20462
21100
  descriptor,
20463
- reasoningEffort: normalizeOptionalText$21(input.conversationPolicy?.reasoningLevel),
20464
- requestedModelId: normalizeOptionalText$21(input.conversationPolicy?.model)
21101
+ reasoningEffort: normalizeOptionalText$19(input.conversationPolicy?.reasoningLevel),
21102
+ requestedModelId: normalizeOptionalText$19(input.conversationPolicy?.model)
20465
21103
  });
20466
21104
  const unregisterActiveTurn = input.onActiveTurn?.({
20467
21105
  cancel: () => session.cancelAndCloseSession(descriptor.sessionId),
@@ -20693,7 +21331,7 @@ var GrokBuildAcpSession = class {
20693
21331
  throw error;
20694
21332
  }
20695
21333
  const record = toRecord$2(result);
20696
- const sessionId = normalizeOptionalText$21(record?.sessionId) ?? input.sessionId ?? null;
21334
+ const sessionId = normalizeOptionalText$19(record?.sessionId) ?? input.sessionId ?? null;
20697
21335
  if (!sessionId) throw new GrokBuildAcpTransportError({
20698
21336
  code: "protocol.invalid",
20699
21337
  errorType: "adapter",
@@ -20808,7 +21446,7 @@ var GrokBuildAcpSession = class {
20808
21446
  if (toolActivity) this.#emitRuntimeEvent(toolActivity);
20809
21447
  }
20810
21448
  async #handleClientRequest(request) {
20811
- const requestSessionId = normalizeOptionalText$21(toRecord$2(request.params)?.sessionId);
21449
+ const requestSessionId = normalizeOptionalText$19(toRecord$2(request.params)?.sessionId);
20812
21450
  if (!(this.#turnActive && requestSessionId !== null && this.#sessionId !== null && requestSessionId === this.#sessionId)) {
20813
21451
  this.#recordInteractionFailure("interaction.session_mismatch", "interaction.session_mismatch: Grok Build requested input for a different session");
20814
21452
  return { error: {
@@ -20924,10 +21562,10 @@ function buildSessionDescriptor(input) {
20924
21562
  }
20925
21563
  function readModelState(value) {
20926
21564
  const record = toRecord$2(value);
20927
- const currentModelId = normalizeOptionalText$21(record?.currentModelId);
21565
+ const currentModelId = normalizeOptionalText$19(record?.currentModelId);
20928
21566
  const models = (Array.isArray(record?.availableModels) ? record.availableModels : []).flatMap((candidate) => {
20929
21567
  const model = toRecord$2(candidate);
20930
- const modelId = normalizeOptionalText$21(model?.modelId);
21568
+ const modelId = normalizeOptionalText$19(model?.modelId);
20931
21569
  if (!modelId) return [];
20932
21570
  const meta = toRecord$2(model?._meta);
20933
21571
  const efforts = Array.isArray(meta?.reasoningEfforts) ? uniqueStrings(meta.reasoningEfforts.map((effort) => {
@@ -20935,8 +21573,8 @@ function readModelState(value) {
20935
21573
  return record?.value ?? record?.id;
20936
21574
  })) : [];
20937
21575
  return [{
20938
- currentEffort: normalizeOptionalText$21(meta?.reasoningEffort),
20939
- displayName: normalizeOptionalText$21(model?.name) ?? modelId,
21576
+ currentEffort: normalizeOptionalText$19(meta?.reasoningEffort),
21577
+ displayName: normalizeOptionalText$19(model?.name) ?? modelId,
20940
21578
  efforts,
20941
21579
  modelId
20942
21580
  }];
@@ -20978,10 +21616,10 @@ function buildModelNegotiationDiagnostics(input) {
20978
21616
  }
20979
21617
  function resolveNonInteractiveAuthMethod(initializeResult) {
20980
21618
  const authMethodIds = (Array.isArray(initializeResult.authMethods) ? initializeResult.authMethods : []).flatMap((method) => {
20981
- const methodId = normalizeOptionalText$21(toRecord$2(method)?.id);
21619
+ const methodId = normalizeOptionalText$19(toRecord$2(method)?.id);
20982
21620
  return methodId ? [methodId] : [];
20983
21621
  });
20984
- const preferred = normalizeOptionalText$21(toRecord$2(initializeResult._meta)?.defaultAuthMethodId);
21622
+ const preferred = normalizeOptionalText$19(toRecord$2(initializeResult._meta)?.defaultAuthMethodId);
20985
21623
  if (preferred && (/* @__PURE__ */ new Set(["cached_token", "xai.api_key"])).has(preferred) && authMethodIds.includes(preferred)) return preferred;
20986
21624
  if (authMethodIds.includes("cached_token")) return "cached_token";
20987
21625
  if (authMethodIds.includes("xai.api_key")) return "xai.api_key";
@@ -21026,7 +21664,7 @@ async function resolveCanonicalDirectory(value) {
21026
21664
  }
21027
21665
  }
21028
21666
  function assertSuccessfulStopReason(value) {
21029
- const stopReason = normalizeOptionalText$21(toRecord$2(value)?.stopReason);
21667
+ const stopReason = normalizeOptionalText$19(toRecord$2(value)?.stopReason);
21030
21668
  if (!stopReason) throw new GrokBuildAcpTransportError({
21031
21669
  code: "protocol.invalid",
21032
21670
  errorType: "adapter",
@@ -21044,7 +21682,7 @@ async function emitFinalPreviewIfRequested(input) {
21044
21682
  await input.onPreview({ text: input.output });
21045
21683
  }
21046
21684
  function toGrokBuildTransportError(error, stderr, diagnostics) {
21047
- const combined = [toErrorMessage$9(error), normalizeOptionalText$21(stderr)].filter((value) => value !== null).join("\n");
21685
+ const combined = [toErrorMessage$9(error), normalizeOptionalText$19(stderr)].filter((value) => value !== null).join("\n");
21048
21686
  const providerFailure = !(error instanceof GrokBuildAcpTransportError) || error.code.startsWith("protocol.") ? classifyGrokBuildProviderFailure({
21049
21687
  message: combined,
21050
21688
  originalError: error instanceof GrokBuildAcpTransportError ? error.originalError : void 0
@@ -21068,7 +21706,7 @@ function toGrokBuildTransportError(error, stderr, diagnostics) {
21068
21706
  const classified = new GrokBuildAcpTransportError({
21069
21707
  code: "upstream_unreachable",
21070
21708
  errorType: "adapter",
21071
- message: `upstream_unreachable: ${normalizeOptionalText$21(combined) ?? "Grok Build ACP error"}`
21709
+ message: `upstream_unreachable: ${normalizeOptionalText$19(combined) ?? "Grok Build ACP error"}`
21072
21710
  });
21073
21711
  return diagnostics ? new GrokBuildAcpTransportError({
21074
21712
  cause: error,
@@ -21086,7 +21724,7 @@ function toGrokBuildJsonRpcTransportError(error) {
21086
21724
  code = "protocol.invalid_params";
21087
21725
  errorType = "config";
21088
21726
  }
21089
- const message = normalizeOptionalText$21(error.message) ?? "ACP request failed";
21727
+ const message = normalizeOptionalText$19(error.message) ?? "ACP request failed";
21090
21728
  const originalError = createProviderOriginalError(message);
21091
21729
  return new GrokBuildAcpTransportError({
21092
21730
  code,
@@ -21096,7 +21734,7 @@ function toGrokBuildJsonRpcTransportError(error) {
21096
21734
  });
21097
21735
  }
21098
21736
  function classifyGrokBuildProviderFailure(input) {
21099
- const normalized = normalizeOptionalText$21(input.message) ?? "Grok Build ACP error";
21737
+ const normalized = normalizeOptionalText$19(input.message) ?? "Grok Build ACP error";
21100
21738
  if (AUTH_FAILURE_RE.test(normalized)) return new GrokBuildAcpTransportError({
21101
21739
  code: "auth.failed",
21102
21740
  errorType: "auth",
@@ -21121,12 +21759,12 @@ function haveSameStrings(left, right) {
21121
21759
  return left.length === right.length && left.every((value) => right.includes(value));
21122
21760
  }
21123
21761
  function uniqueStrings(values) {
21124
- return [...new Set(values.map(normalizeOptionalText$21).filter((value) => value !== null))];
21762
+ return [...new Set(values.map(normalizeOptionalText$19).filter((value) => value !== null))];
21125
21763
  }
21126
21764
  function normalizeOutputText$1(value) {
21127
21765
  return typeof value === "string" && value.length > 0 ? value : null;
21128
21766
  }
21129
- function normalizeOptionalText$21(value) {
21767
+ function normalizeOptionalText$19(value) {
21130
21768
  const normalized = typeof value === "string" ? value.trim() : "";
21131
21769
  return normalized.length > 0 ? normalized : null;
21132
21770
  }
@@ -21197,7 +21835,7 @@ function createDefaultGrokBuildInvoke(input) {
21197
21835
  });
21198
21836
  } : void 0;
21199
21837
  const result = await invokeWithSingleContextHeal({
21200
- contextId: normalizeOptionalText$20(dispatchInput.agentControllerConversationId),
21838
+ contextId: normalizeOptionalText$18(dispatchInput.agentControllerConversationId),
21201
21839
  contextLossPolicy: dispatchInput.executionMode === "repair" ? "fail" : "rebuild",
21202
21840
  createRebuildFailedError: (error) => new GrokBuildAcpTransportError({
21203
21841
  cause: error,
@@ -21252,7 +21890,7 @@ function createDefaultGrokBuildInvoke(input) {
21252
21890
  };
21253
21891
  }
21254
21892
  async function resolveGrokBuildDispatchLaunchContract(input) {
21255
- const commandPath = normalizeOptionalText$20(input.grokBuildBin);
21893
+ const commandPath = normalizeOptionalText$18(input.grokBuildBin);
21256
21894
  const launchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (commandPath ? buildExecutableLaunchContract({ commandPath }) : null);
21257
21895
  if (!launchContract) throw Object.assign(/* @__PURE__ */ new Error("Grok Build launch contract is required for runtime dispatch."), {
21258
21896
  code: "controller.launch.needs_repair",
@@ -21311,7 +21949,7 @@ async function interruptActiveGrokBuildTurn(input) {
21311
21949
  taskId: result.taskId
21312
21950
  };
21313
21951
  }
21314
- function normalizeOptionalText$20(value) {
21952
+ function normalizeOptionalText$18(value) {
21315
21953
  const normalized = typeof value === "string" ? value.trim() : "";
21316
21954
  return normalized.length > 0 ? normalized : null;
21317
21955
  }
@@ -21338,7 +21976,7 @@ const DEFAULT_OPENCLAW_AGENT_ID = "main";
21338
21976
  async function resolveInstalledOpenClawLaunchCandidates(input) {
21339
21977
  const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
21340
21978
  commandName: DEFAULT_OPENCLAW_COMMAND,
21341
- configuredCommand: normalizeOptionalText$19(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_BIN),
21979
+ configuredCommand: normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_BIN),
21342
21980
  displayName: "OpenClaw",
21343
21981
  preferredLaunchContract: input?.preferredLaunchContract
21344
21982
  });
@@ -21372,9 +22010,9 @@ async function verifyOpenClawLaunchContract(input) {
21372
22010
  }
21373
22011
  function resolveOpenClawBinCandidates(explicitOpenClawBin) {
21374
22012
  const candidates = [];
21375
- const explicitCandidate = normalizeOptionalText$19(explicitOpenClawBin);
22013
+ const explicitCandidate = normalizeOptionalText$17(explicitOpenClawBin);
21376
22014
  if (explicitCandidate) candidates.push(explicitCandidate);
21377
- const configuredCandidate = normalizeOptionalText$19(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_BIN);
22015
+ const configuredCandidate = normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_BIN);
21378
22016
  if (configuredCandidate && !candidates.includes(configuredCandidate)) candidates.push(configuredCandidate);
21379
22017
  const nodeSiblingCandidate = resolveSiblingCommandPath({
21380
22018
  anchorPath: process.execPath,
@@ -21390,16 +22028,16 @@ function resolveOpenClawBinCandidates(explicitOpenClawBin) {
21390
22028
  return candidates;
21391
22029
  }
21392
22030
  function resolveOpenClawTimeoutMs() {
21393
- const raw = normalizeOptionalText$19(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
22031
+ const raw = normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
21394
22032
  if (!raw) return null;
21395
22033
  const parsed = Number.parseInt(raw, 10);
21396
22034
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
21397
22035
  return parsed;
21398
22036
  }
21399
22037
  function resolveOpenClawAgentId$1() {
21400
- return normalizeOptionalText$19(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_AGENT_ID) ?? DEFAULT_OPENCLAW_AGENT_ID;
22038
+ return normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_AGENT_ID) ?? DEFAULT_OPENCLAW_AGENT_ID;
21401
22039
  }
21402
- function normalizeOptionalText$19(value) {
22040
+ function normalizeOptionalText$17(value) {
21403
22041
  const normalized = String(value ?? "").trim();
21404
22042
  return normalized.length > 0 ? normalized : null;
21405
22043
  }
@@ -21469,10 +22107,10 @@ function parseOpenClawOutputLine(line) {
21469
22107
  }
21470
22108
  const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
21471
22109
  if (!record) return null;
21472
- const isErrorResult = resolveIsErrorResult$1(record);
21473
- const errorMessage = resolveErrorMessage$1(record, isErrorResult);
21474
- const resultText = resolveResultText$1(record, isErrorResult);
21475
- const sessionId = resolveSessionId$1(record);
22110
+ const isErrorResult = resolveIsErrorResult(record);
22111
+ const errorMessage = resolveErrorMessage(record, isErrorResult);
22112
+ const resultText = resolveResultText(record, isErrorResult);
22113
+ const sessionId = resolveSessionId(record);
21476
22114
  if (!errorMessage && resultText === null && sessionId === null) return null;
21477
22115
  return {
21478
22116
  errorMessage,
@@ -21493,8 +22131,8 @@ function parseOpenClawOutputDocument(text) {
21493
22131
  }
21494
22132
  const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
21495
22133
  if (!record) return null;
21496
- const isErrorResult = resolveIsErrorResult$1(record);
21497
- const errorMessage = resolveErrorMessage$1(record, isErrorResult);
22134
+ const isErrorResult = resolveIsErrorResult(record);
22135
+ const errorMessage = resolveErrorMessage(record, isErrorResult);
21498
22136
  const outputText = resolveDocumentOutputText(record, isErrorResult);
21499
22137
  const sessionId = resolveDocumentSessionId(record);
21500
22138
  if (!errorMessage && outputText === null && sessionId === null) return null;
@@ -21505,11 +22143,11 @@ function parseOpenClawOutputDocument(text) {
21505
22143
  sessionId
21506
22144
  };
21507
22145
  }
21508
- function resolveSessionId$1(record) {
21509
- return resolveStringByPaths$1(record, OPENCLAW_SESSION_ID_PATHS);
22146
+ function resolveSessionId(record) {
22147
+ return resolveStringByPaths(record, OPENCLAW_SESSION_ID_PATHS);
21510
22148
  }
21511
22149
  function resolveDocumentSessionId(record) {
21512
- return resolveStringByPaths$1(record, [
22150
+ return resolveStringByPaths(record, [
21513
22151
  ...OPENCLAW_SESSION_ID_PATHS,
21514
22152
  [
21515
22153
  "meta",
@@ -21519,35 +22157,35 @@ function resolveDocumentSessionId(record) {
21519
22157
  ["meta", "sessionId"]
21520
22158
  ]) ?? null;
21521
22159
  }
21522
- function resolveResultText$1(record, isErrorResult) {
22160
+ function resolveResultText(record, isErrorResult) {
21523
22161
  if (isErrorResult === true) return null;
21524
- return resolveStringByPaths$1(record, OPENCLAW_RESULT_TEXT_PATHS);
22162
+ return resolveStringByPaths(record, OPENCLAW_RESULT_TEXT_PATHS);
21525
22163
  }
21526
22164
  function resolveDocumentOutputText(record, isErrorResult) {
21527
22165
  if (isErrorResult === true) return null;
21528
22166
  const payloadText = resolvePayloadsText(record.payloads);
21529
22167
  if (payloadText) return payloadText;
21530
- return resolveResultText$1(record, isErrorResult);
22168
+ return resolveResultText(record, isErrorResult);
21531
22169
  }
21532
- function resolveErrorMessage$1(record, isErrorResult) {
22170
+ function resolveErrorMessage(record, isErrorResult) {
21533
22171
  if (isErrorResult !== true) return null;
21534
- return resolveStringByPaths$1(record, OPENCLAW_ERROR_MESSAGE_PATHS) ?? resolveStringByPaths$1(record, OPENCLAW_RESULT_TEXT_PATHS);
22172
+ return resolveStringByPaths(record, OPENCLAW_ERROR_MESSAGE_PATHS) ?? resolveStringByPaths(record, OPENCLAW_RESULT_TEXT_PATHS);
21535
22173
  }
21536
- function resolveIsErrorResult$1(record) {
22174
+ function resolveIsErrorResult(record) {
21537
22175
  if (typeof record.is_error === "boolean") return record.is_error;
21538
22176
  if (typeof record.isError === "boolean") return record.isError;
21539
22177
  if (typeof record.ok === "boolean") return !record.ok;
21540
22178
  if (typeof record.success === "boolean") return !record.success;
21541
- const status = normalizeOptionalText$18(record.status)?.toLowerCase();
22179
+ const status = normalizeOptionalText$16(record.status)?.toLowerCase();
21542
22180
  if (status === "error" || status === "failed" || status === "fail") return true;
21543
22181
  if (status === "ok" || status === "success" || status === "completed") return false;
21544
- const type = normalizeOptionalText$18(record.type)?.toLowerCase();
22182
+ const type = normalizeOptionalText$16(record.type)?.toLowerCase();
21545
22183
  if (type === "error" || type === "failure") return true;
21546
22184
  if (type === "result" || type === "success") return false;
21547
22185
  if (record.error !== void 0 || record.errors !== void 0) return true;
21548
22186
  return null;
21549
22187
  }
21550
- function resolveStringByPaths$1(record, paths) {
22188
+ function resolveStringByPaths(record, paths) {
21551
22189
  for (const path of paths) {
21552
22190
  const normalized = normalizeCandidateValue(getByPath(record, path));
21553
22191
  if (normalized) return normalized;
@@ -21590,7 +22228,7 @@ function normalizeCandidateValue(value) {
21590
22228
  }
21591
22229
  return null;
21592
22230
  }
21593
- function normalizeOptionalText$18(value) {
22231
+ function normalizeOptionalText$16(value) {
21594
22232
  const normalized = String(value ?? "").trim();
21595
22233
  return normalized.length > 0 ? normalized : null;
21596
22234
  }
@@ -21648,7 +22286,7 @@ function classifyOpenClawFailureMessage(input) {
21648
22286
  });
21649
22287
  }
21650
22288
  function normalizeOpenClawFailureMessage(value) {
21651
- const normalized = normalizeOptionalText$17(value);
22289
+ const normalized = normalizeOptionalText$15(value);
21652
22290
  if (!normalized) return null;
21653
22291
  return extractJsonFailureDetail(normalized) ?? normalized;
21654
22292
  }
@@ -21657,7 +22295,7 @@ function extractJsonFailureDetail(value) {
21657
22295
  const parsed = JSON.parse(value);
21658
22296
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
21659
22297
  const record = parsed;
21660
- return normalizeOptionalText$17(record.detail) ?? normalizeOptionalText$17(record.message) ?? (record.error && typeof record.error === "object" && !Array.isArray(record.error) ? normalizeOptionalText$17(record.error.message) : null);
22298
+ return normalizeOptionalText$15(record.detail) ?? normalizeOptionalText$15(record.message) ?? (record.error && typeof record.error === "object" && !Array.isArray(record.error) ? normalizeOptionalText$15(record.error.message) : null);
21661
22299
  } catch {
21662
22300
  return null;
21663
22301
  }
@@ -21677,7 +22315,7 @@ function isRateLimitFailure(value) {
21677
22315
  function isInputSelectorFailure(value) {
21678
22316
  return value.includes("pass --to") && value.includes("--session-id") && value.includes("--agent") || value.includes("unknown agent") || value.includes("agent not found");
21679
22317
  }
21680
- function normalizeOptionalText$17(value) {
22318
+ function normalizeOptionalText$15(value) {
21681
22319
  const normalized = typeof value === "string" ? value.trim() : "";
21682
22320
  return normalized.length > 0 ? normalized : null;
21683
22321
  }
@@ -21696,7 +22334,7 @@ var OpenClawCliTransportError = class extends Error {
21696
22334
  }
21697
22335
  };
21698
22336
  async function invokeOpenClawCliTransport(input) {
21699
- const prompt = normalizeOptionalText$16(input.prompt);
22337
+ const prompt = normalizeOptionalText$14(input.prompt);
21700
22338
  if (!prompt) throw new OpenClawCliTransportError({
21701
22339
  code: "schema.invalid",
21702
22340
  errorType: "config",
@@ -21705,7 +22343,7 @@ async function invokeOpenClawCliTransport(input) {
21705
22343
  const { args, sessionId: initialSessionId } = buildOpenClawArgs({
21706
22344
  openClawAgentId: input.openClawAgentId,
21707
22345
  prompt,
21708
- sessionId: normalizeOptionalText$16(input.sessionId)
22346
+ sessionId: normalizeOptionalText$14(input.sessionId)
21709
22347
  });
21710
22348
  const invocation = buildCliLaunchInvocation({
21711
22349
  args,
@@ -21731,13 +22369,13 @@ async function invokeOpenClawCliTransport(input) {
21731
22369
  onProcessControlEvent: input.onProcessControlEvent,
21732
22370
  onStderrLine: (event) => {
21733
22371
  if (firstStderrAtMs === null) firstStderrAtMs = Date.now();
21734
- collectProviderErrorMessage$1(event.line, providerErrorMessages);
22372
+ collectProviderErrorMessage(event.line, providerErrorMessages);
21735
22373
  },
21736
22374
  onStdoutLine: (event) => {
21737
22375
  if (firstStdoutAtMs === null) firstStdoutAtMs = Date.now();
21738
22376
  const parsedLine = parseOpenClawOutputLine(event.line);
21739
22377
  if (!parsedLine) {
21740
- collectRuntimePermissionDenialMessage$1(event.line, providerErrorMessages);
22378
+ collectRuntimePermissionDenialMessage(event.line, providerErrorMessages);
21741
22379
  return;
21742
22380
  }
21743
22381
  if (parsedLine.resultText) latestOutput = parsedLine.resultText;
@@ -21782,7 +22420,7 @@ async function invokeOpenClawCliTransport(input) {
21782
22420
  stdoutText: driverResult.stdoutText
21783
22421
  }));
21784
22422
  }
21785
- const output = normalizeOptionalText$16(latestOutput);
22423
+ const output = normalizeOptionalText$14(latestOutput);
21786
22424
  if (!output) {
21787
22425
  const fallbackOutput = resolveSuccessFallbackOutput(driverResult.stdoutText);
21788
22426
  if (!fallbackOutput) {
@@ -21800,25 +22438,25 @@ async function invokeOpenClawCliTransport(input) {
21800
22438
  }
21801
22439
  return {
21802
22440
  output: fallbackOutput,
21803
- sessionId: normalizeOptionalText$16(resolvedSessionId),
21804
- telemetry: buildTransportTelemetry$1({
22441
+ sessionId: normalizeOptionalText$14(resolvedSessionId),
22442
+ telemetry: buildTransportTelemetry({
21805
22443
  driverResult,
21806
22444
  firstStderrAtMs,
21807
22445
  firstStdoutAtMs,
21808
22446
  invokedAtMs,
21809
- resumedContext: normalizeOptionalText$16(input.sessionId) !== null
22447
+ resumedContext: normalizeOptionalText$14(input.sessionId) !== null
21810
22448
  })
21811
22449
  };
21812
22450
  }
21813
22451
  return {
21814
22452
  output,
21815
- sessionId: normalizeOptionalText$16(resolvedSessionId),
21816
- telemetry: buildTransportTelemetry$1({
22453
+ sessionId: normalizeOptionalText$14(resolvedSessionId),
22454
+ telemetry: buildTransportTelemetry({
21817
22455
  driverResult,
21818
22456
  firstStderrAtMs,
21819
22457
  firstStdoutAtMs,
21820
22458
  invokedAtMs,
21821
- resumedContext: normalizeOptionalText$16(input.sessionId) !== null
22459
+ resumedContext: normalizeOptionalText$14(input.sessionId) !== null
21822
22460
  })
21823
22461
  };
21824
22462
  }
@@ -21837,7 +22475,7 @@ const buildOpenClawArgs = (input) => {
21837
22475
  sessionId
21838
22476
  };
21839
22477
  };
21840
- const buildTransportTelemetry$1 = (input) => ({
22478
+ const buildTransportTelemetry = (input) => ({
21841
22479
  completedAtMs: Date.now(),
21842
22480
  ...input.driverResult.lifecycle.exitCode === null ? {} : { exitCode: input.driverResult.lifecycle.exitCode },
21843
22481
  ...input.driverResult.lifecycle.exitObservedAtMs === null ? {} : { exitObservedAtMs: input.driverResult.lifecycle.exitObservedAtMs },
@@ -21878,14 +22516,14 @@ const toOpenClawCliTransportError = (error, timeoutMs) => {
21878
22516
  });
21879
22517
  };
21880
22518
  const classifyOpenClawFailure = (input) => {
21881
- const trustedProviderMessages = /* @__PURE__ */ new Set([...input.providerOriginalErrorMessages ?? [], ...extractErrorMessagesFromStdout$1(input.stdoutText)]);
21882
- const providerMessage = resolveProviderFailureMessage$1(input);
22519
+ const trustedProviderMessages = /* @__PURE__ */ new Set([...input.providerOriginalErrorMessages ?? [], ...extractErrorMessagesFromStdout(input.stdoutText)]);
22520
+ const providerMessage = resolveProviderFailureMessage(input);
21883
22521
  if (providerMessage) return classifyOpenClawFailureMessage({
21884
22522
  includeOriginalError: trustedProviderMessages.has(providerMessage),
21885
22523
  isContextLost: isLikelyOpenClawContextLostError,
21886
22524
  message: providerMessage
21887
22525
  });
21888
- const stderrText = normalizeOptionalText$16(input.stderrText);
22526
+ const stderrText = normalizeOptionalText$14(input.stderrText);
21889
22527
  if (stderrText) return {
21890
22528
  code: "upstream_unreachable",
21891
22529
  errorType: "adapter",
@@ -21893,17 +22531,17 @@ const classifyOpenClawFailure = (input) => {
21893
22531
  };
21894
22532
  return { ...buildProviderExitError({ providerLabel: "openclaw" }) };
21895
22533
  };
21896
- const resolveProviderFailureMessage$1 = (input) => {
22534
+ const resolveProviderFailureMessage = (input) => {
21897
22535
  const candidateMessages = [
21898
22536
  ...input.providerErrorMessages,
21899
- ...extractErrorMessagesFromStdout$1(input.stdoutText),
21900
- ...normalizeOptionalText$16(input.stderrText) ? [normalizeOptionalText$16(input.stderrText)] : []
22537
+ ...extractErrorMessagesFromStdout(input.stdoutText),
22538
+ ...normalizeOptionalText$14(input.stderrText) ? [normalizeOptionalText$14(input.stderrText)] : []
21901
22539
  ].filter((value) => Boolean(value));
21902
- for (const candidate of candidateMessages) if (looksLikeRuntimePermissionDenialMessage(candidate) || looksLikeProviderFailure$1(candidate)) return candidate;
22540
+ for (const candidate of candidateMessages) if (looksLikeRuntimePermissionDenialMessage(candidate) || looksLikeProviderFailure(candidate)) return candidate;
21903
22541
  return candidateMessages[0] ?? null;
21904
22542
  };
21905
- const extractErrorMessagesFromStdout$1 = (value) => {
21906
- const stdoutText = normalizeOptionalText$16(value);
22543
+ const extractErrorMessagesFromStdout = (value) => {
22544
+ const stdoutText = normalizeOptionalText$14(value);
21907
22545
  if (!stdoutText) return [];
21908
22546
  const messages = [];
21909
22547
  const lines = stdoutText.split("\n");
@@ -21914,7 +22552,7 @@ const extractErrorMessagesFromStdout$1 = (value) => {
21914
22552
  return messages;
21915
22553
  };
21916
22554
  const resolveSuccessFallbackOutput = (value) => {
21917
- const stdoutText = normalizeOptionalText$16(value);
22555
+ const stdoutText = normalizeOptionalText$14(value);
21918
22556
  if (!stdoutText) return null;
21919
22557
  const lines = stdoutText.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
21920
22558
  if (lines.length !== 1) return null;
@@ -21923,24 +22561,24 @@ const resolveSuccessFallbackOutput = (value) => {
21923
22561
  if (singleLine.startsWith("{") || singleLine.startsWith("[")) return null;
21924
22562
  return singleLine;
21925
22563
  };
21926
- const collectProviderErrorMessage$1 = (line, output) => {
21927
- const normalized = normalizeOptionalText$16(line);
22564
+ const collectProviderErrorMessage = (line, output) => {
22565
+ const normalized = normalizeOptionalText$14(line);
21928
22566
  if (!normalized) return;
21929
22567
  output.push(normalized);
21930
22568
  };
21931
- const collectRuntimePermissionDenialMessage$1 = (line, output) => {
21932
- const normalized = normalizeOptionalText$16(line);
22569
+ const collectRuntimePermissionDenialMessage = (line, output) => {
22570
+ const normalized = normalizeOptionalText$14(line);
21933
22571
  if (!(normalized && looksLikeRuntimePermissionDenialMessage(normalized))) return;
21934
22572
  output.push(normalized);
21935
22573
  };
21936
- const looksLikeProviderFailure$1 = (value) => {
22574
+ const looksLikeProviderFailure = (value) => {
21937
22575
  const lowered = value.toLowerCase();
21938
22576
  return lowered.includes("error") || lowered.includes("failed") || lowered.includes("permission") || lowered.includes("reject") || lowered.includes("denied") || lowered.includes("approval") || lowered.includes("unauthorized") || lowered.includes("not logged in") || lowered.includes("invalid") || lowered.includes("quota") || lowered.includes("rate") || lowered.includes("session") || lowered.includes("unsupported model") || lowered.includes("model is not supported");
21939
22577
  };
21940
22578
  function normalizeText$2(value) {
21941
22579
  return String(value ?? "").trim();
21942
22580
  }
21943
- function normalizeOptionalText$16(value) {
22581
+ function normalizeOptionalText$14(value) {
21944
22582
  const normalized = normalizeText$2(value);
21945
22583
  return normalized.length > 0 ? normalized : null;
21946
22584
  }
@@ -22072,15 +22710,15 @@ async function readSessionIndex(input) {
22072
22710
  }
22073
22711
  }
22074
22712
  function resolveOpenClawStateDir(env) {
22075
- const configuredStateDir = normalizeOptionalText$15(env?.OPENCLAW_STATE_DIR);
22713
+ const configuredStateDir = normalizeOptionalText$13(env?.OPENCLAW_STATE_DIR);
22076
22714
  if (configuredStateDir) return configuredStateDir;
22077
22715
  return join(homedir(), ".openclaw");
22078
22716
  }
22079
22717
  function resolveSessionFilePath(input) {
22080
22718
  const sessionsDir = join(resolveOpenClawStateDir(input.env), "agents", input.agentId, "sessions");
22081
- const sessionFile = normalizeOptionalText$15(input.sessionEntry.sessionFile);
22719
+ const sessionFile = normalizeOptionalText$13(input.sessionEntry.sessionFile);
22082
22720
  if (sessionFile) return isAbsolute(sessionFile) ? sessionFile : join(sessionsDir, sessionFile);
22083
- const sessionId = normalizeOptionalText$15(input.sessionEntry.sessionId);
22721
+ const sessionId = normalizeOptionalText$13(input.sessionEntry.sessionId);
22084
22722
  if (!sessionId) return null;
22085
22723
  return join(sessionsDir, `${sessionId}.jsonl`);
22086
22724
  }
@@ -22101,11 +22739,11 @@ function parseSessionErrorRecord(line) {
22101
22739
  const parsed = JSON.parse(line);
22102
22740
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
22103
22741
  const record = parsed;
22104
- if (normalizeOptionalText$15(record.type) !== "message") return null;
22742
+ if (normalizeOptionalText$13(record.type) !== "message") return null;
22105
22743
  const message = record.message && typeof record.message === "object" ? record.message : null;
22106
22744
  if (!message) return null;
22107
- if (normalizeOptionalText$15(message.stopReason) !== "error") return null;
22108
- const errorMessage = normalizeOptionalText$15(message.errorMessage);
22745
+ if (normalizeOptionalText$13(message.stopReason) !== "error") return null;
22746
+ const errorMessage = normalizeOptionalText$13(message.errorMessage);
22109
22747
  if (!errorMessage) return null;
22110
22748
  const messageTimestampMs = normalizeOptionalNumber(message.timestamp) ?? normalizeIsoTimestampMs(record.timestamp);
22111
22749
  if (messageTimestampMs === null) return null;
@@ -22118,7 +22756,7 @@ function parseSessionErrorRecord(line) {
22118
22756
  }
22119
22757
  }
22120
22758
  function normalizeIsoTimestampMs(value) {
22121
- const normalized = normalizeOptionalText$15(value);
22759
+ const normalized = normalizeOptionalText$13(value);
22122
22760
  if (!normalized) return null;
22123
22761
  const parsed = Date.parse(normalized);
22124
22762
  return Number.isFinite(parsed) ? parsed : null;
@@ -22126,7 +22764,7 @@ function normalizeIsoTimestampMs(value) {
22126
22764
  function normalizeOptionalNumber(value) {
22127
22765
  return typeof value === "number" && Number.isFinite(value) ? value : null;
22128
22766
  }
22129
- function normalizeOptionalText$15(value) {
22767
+ function normalizeOptionalText$13(value) {
22130
22768
  const normalized = typeof value === "string" ? value.trim() : "";
22131
22769
  return normalized.length > 0 ? normalized : null;
22132
22770
  }
@@ -22147,8 +22785,8 @@ var OpenClawGatewayTransportError = class extends Error {
22147
22785
  }
22148
22786
  };
22149
22787
  async function invokeOpenClawGatewayTransport(input) {
22150
- const prompt = normalizeOptionalText$14(input.prompt);
22151
- const sessionKey = normalizeOptionalText$14(input.sessionKey);
22788
+ const prompt = normalizeOptionalText$12(input.prompt);
22789
+ const sessionKey = normalizeOptionalText$12(input.sessionKey);
22152
22790
  if (!prompt) throw new OpenClawGatewayTransportError({
22153
22791
  code: "schema.invalid",
22154
22792
  errorType: "config",
@@ -22261,9 +22899,9 @@ function normalizeOpenClawGatewayAgentResult(result, expectedSessionKey) {
22261
22899
  message: "upstream_unreachable: openclaw gateway returned a non-object payload for agent"
22262
22900
  });
22263
22901
  const record = result;
22264
- const status = normalizeOptionalText$14(record.status);
22902
+ const status = normalizeOptionalText$12(record.status);
22265
22903
  if (!status || status === "ok") return extractSuccessfulAgentResult(record.result, expectedSessionKey);
22266
- throw classifyGatewayFailure(normalizeOptionalText$14(record.summary) ?? normalizeOptionalText$14(record.error) ?? `openclaw gateway agent returned status '${status}'`, true);
22904
+ throw classifyGatewayFailure(normalizeOptionalText$12(record.summary) ?? normalizeOptionalText$12(record.error) ?? `openclaw gateway agent returned status '${status}'`, true);
22267
22905
  }
22268
22906
  function extractSuccessfulAgentResult(result, expectedSessionKey) {
22269
22907
  if (!result || typeof result !== "object") throw new OpenClawGatewayTransportError({
@@ -22288,7 +22926,7 @@ function normalizeAgentMeta(meta, expectedSessionKey) {
22288
22926
  const record = meta;
22289
22927
  const systemPromptReport = record.systemPromptReport;
22290
22928
  if (systemPromptReport && typeof systemPromptReport === "object") {
22291
- const actualSessionKey = normalizeOptionalText$14(systemPromptReport.sessionKey);
22929
+ const actualSessionKey = normalizeOptionalText$12(systemPromptReport.sessionKey);
22292
22930
  if (actualSessionKey && actualSessionKey !== expectedSessionKey) throw new OpenClawGatewayTransportError({
22293
22931
  code: "upstream_unreachable",
22294
22932
  errorType: "adapter",
@@ -22296,15 +22934,15 @@ function normalizeAgentMeta(meta, expectedSessionKey) {
22296
22934
  });
22297
22935
  }
22298
22936
  const agentMeta = record.agentMeta;
22299
- const agentSessionId = agentMeta && typeof agentMeta === "object" ? normalizeOptionalText$14(agentMeta.sessionId) : null;
22300
- const reportSessionId = systemPromptReport && typeof systemPromptReport === "object" ? normalizeOptionalText$14(systemPromptReport.sessionId) : null;
22937
+ const agentSessionId = agentMeta && typeof agentMeta === "object" ? normalizeOptionalText$12(agentMeta.sessionId) : null;
22938
+ const reportSessionId = systemPromptReport && typeof systemPromptReport === "object" ? normalizeOptionalText$12(systemPromptReport.sessionId) : null;
22301
22939
  return { sessionId: agentSessionId ?? reportSessionId };
22302
22940
  }
22303
22941
  function extractAgentPayloadText(payloads) {
22304
22942
  if (!Array.isArray(payloads)) return null;
22305
22943
  for (const payload of payloads) {
22306
22944
  if (!payload || typeof payload !== "object") continue;
22307
- const text = normalizeOptionalText$14(payload.text);
22945
+ const text = normalizeOptionalText$12(payload.text);
22308
22946
  if (text) return text;
22309
22947
  }
22310
22948
  return null;
@@ -22316,8 +22954,8 @@ function toOpenClawGatewayTransportError(error) {
22316
22954
  errorType: "adapter",
22317
22955
  message: "upstream_unreachable: openclaw is not installed or not on PATH"
22318
22956
  });
22319
- const stderr = normalizeOptionalText$14(error?.stderr);
22320
- const stdout = normalizeOptionalText$14(error?.stdout);
22957
+ const stderr = normalizeOptionalText$12(error?.stderr);
22958
+ const stdout = normalizeOptionalText$12(error?.stdout);
22321
22959
  return classifyGatewayFailure(stderr ?? stdout ?? toErrorMessage$6(error), false);
22322
22960
  }
22323
22961
  function classifyGatewayFailure(message, includeOriginalError) {
@@ -22326,7 +22964,7 @@ function classifyGatewayFailure(message, includeOriginalError) {
22326
22964
  message
22327
22965
  }));
22328
22966
  }
22329
- function normalizeOptionalText$14(value) {
22967
+ function normalizeOptionalText$12(value) {
22330
22968
  const normalized = String(value ?? "").trim();
22331
22969
  return normalized.length > 0 ? normalized : null;
22332
22970
  }
@@ -22699,7 +23337,7 @@ function record$2(value) {
22699
23337
  const OPENCLAW_CONVERSATION_BRIDGE_SPEC = resolveBuiltinAdapterConversationBridgeSpec("openclaw");
22700
23338
  const resolveOpenClawSessionConversation = (agentControllerConversation) => {
22701
23339
  if (!agentControllerConversation) return null;
22702
- const agentControllerConversationId = normalizeOptionalText$13(agentControllerConversation.agentControllerConversationId);
23340
+ const agentControllerConversationId = normalizeOptionalText$11(agentControllerConversation.agentControllerConversationId);
22703
23341
  if (!agentControllerConversationId) throw new Error("conversation.bridge.agent_controller_conversation_id_missing: expected builtin:openclaw session agentControllerConversationId");
22704
23342
  if (agentControllerConversation.agentControllerRef !== "builtin:openclaw" || agentControllerConversation.agentControllerConversationKind !== "session") throw new Error(`conversation.bridge.agent_controller_conversation_mismatch: expected builtin:openclaw session, received ${agentControllerConversation.agentControllerRef}/${agentControllerConversation.agentControllerConversationKind}`);
22705
23343
  return buildAdapterAgentControllerConversationRef({
@@ -22712,7 +23350,7 @@ const resolveOpenClawInvokeRequest = (input) => {
22712
23350
  const agentControllerConversation = resolveOpenClawSessionConversation(input.request.agentControllerConversation);
22713
23351
  return {
22714
23352
  ...input.request,
22715
- agentControllerConversationId: normalizeOptionalText$13(input.request.agentControllerConversationId),
23353
+ agentControllerConversationId: normalizeOptionalText$11(input.request.agentControllerConversationId),
22716
23354
  ...agentControllerConversation ? { agentControllerConversation } : {}
22717
23355
  };
22718
23356
  };
@@ -22775,7 +23413,7 @@ const resolveDefaultOpenClawInvoke = (options) => {
22775
23413
  optionAgentId: options.openClawAgentId
22776
23414
  });
22777
23415
  const correction = isDispatchSpaceActionDeliveryOnly(input.env);
22778
- const canonicalSessionId = normalizeOptionalText$13(input.agentControllerConversationId) ?? resolveOpenClawSessionKey(input);
23416
+ const canonicalSessionId = normalizeOptionalText$11(input.agentControllerConversationId) ?? resolveOpenClawSessionKey(input);
22779
23417
  const executionSessionId = correction ? randomUUID() : canonicalSessionId ?? randomUUID();
22780
23418
  const result = await withOpenClawDispatchSpaceActionPlugin({
22781
23419
  launchContract,
@@ -22821,7 +23459,7 @@ const resolveDefaultOpenClawInvoke = (options) => {
22821
23459
  };
22822
23460
  };
22823
23461
  async function resolveOpenClawDispatchLaunchContract(input) {
22824
- const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$13(input.openClawBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$13(input.openClawBin) }) : null);
23462
+ const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$11(input.openClawBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$11(input.openClawBin) }) : null);
22825
23463
  if (explicitLaunchContract) {
22826
23464
  const verification = isDispatchSpaceActionDeliveryOnly(input.env) ? await verifyLaunchContractFiles({ launchContract: explicitLaunchContract }) : await verifyOpenClawLaunchContract({
22827
23465
  launchContract: explicitLaunchContract,
@@ -22844,8 +23482,8 @@ const resolveRuntimeProcessRegistrar$1 = (input) => input.registerRuntimeProcess
22844
23482
  taskId: input.taskId
22845
23483
  });
22846
23484
  } : void 0;
22847
- const resolveOpenClawAgentId = (input) => normalizeOptionalText$13(input.dispatchEnvAgentId) ?? normalizeOptionalText$13(input.optionAgentId) ?? resolveOpenClawAgentId$1();
22848
- const resolveOpenClawSessionKey = (input) => normalizeOptionalText$13(input.agentControllerConversation?.agentControllerRef === "builtin:openclaw" && input.agentControllerConversation.agentControllerConversationKind === "session" ? input.agentControllerConversation.agentControllerConversationId : null);
23485
+ const resolveOpenClawAgentId = (input) => normalizeOptionalText$11(input.dispatchEnvAgentId) ?? normalizeOptionalText$11(input.optionAgentId) ?? resolveOpenClawAgentId$1();
23486
+ const resolveOpenClawSessionKey = (input) => normalizeOptionalText$11(input.agentControllerConversation?.agentControllerRef === "builtin:openclaw" && input.agentControllerConversation.agentControllerConversationKind === "session" ? input.agentControllerConversation.agentControllerConversationId : null);
22849
23487
  const invokeOpenClawGatewayPath = async (input) => {
22850
23488
  const gatewayResult = await invokeOpenClawGatewayTransport({
22851
23489
  agentId: input.openClawAgentId,
@@ -22856,7 +23494,7 @@ const invokeOpenClawGatewayPath = async (input) => {
22856
23494
  openClawTimeoutMs: input.openClawTimeoutMs,
22857
23495
  openClawWorkdir: input.openClawWorkdir,
22858
23496
  prompt: input.input.prompt,
22859
- resumedContext: normalizeOptionalText$13(input.input.agentControllerConversationId) !== null,
23497
+ resumedContext: normalizeOptionalText$11(input.input.agentControllerConversationId) !== null,
22860
23498
  sessionKey: input.sessionKey
22861
23499
  });
22862
23500
  return {
@@ -22883,7 +23521,7 @@ const invokeOpenClawLocalCliPath = async (input) => {
22883
23521
  ...input.onProcessControlEvent ? { onProcessControlEvent: input.onProcessControlEvent } : {},
22884
23522
  ...input.input.onRuntimeEvent ? { onRuntimeEvent: input.input.onRuntimeEvent } : {},
22885
23523
  prompt: input.input.prompt,
22886
- sessionId: normalizeOptionalText$13(input.input.agentControllerConversationId)
23524
+ sessionId: normalizeOptionalText$11(input.input.agentControllerConversationId)
22887
23525
  });
22888
23526
  const agentControllerConversation = OPENCLAW_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
22889
23527
  bridgeSpec: OPENCLAW_CONVERSATION_BRIDGE_SPEC,
@@ -22902,7 +23540,7 @@ const invokeOpenClawLocalCliPath = async (input) => {
22902
23540
  function normalizeText$1(value) {
22903
23541
  return String(value ?? "").trim();
22904
23542
  }
22905
- function normalizeOptionalText$13(value) {
23543
+ function normalizeOptionalText$11(value) {
22906
23544
  const normalized = normalizeText$1(value);
22907
23545
  return normalized.length > 0 ? normalized : null;
22908
23546
  }
@@ -22929,13 +23567,19 @@ async function resolveInstalledOpenCodeLaunchCandidates(input) {
22929
23567
  const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
22930
23568
  additionalCommandDirectories: resolveOpenCodeCommandDirectories(),
22931
23569
  commandName: DEFAULT_OPENCODE_COMMAND,
22932
- configuredCommand: normalizeOptionalText$12(process.env.OPENMELD_DAEMON_RUNTIME_OPENCODE_BIN),
23570
+ configuredCommand: normalizeOptionalText$10(process.env.OPENMELD_DAEMON_RUNTIME_OPENCODE_BIN),
22933
23571
  displayName: "OpenCode",
22934
23572
  preferredLaunchContract: input?.preferredLaunchContract
22935
23573
  });
22936
- if (!installedCandidates.ok) return installedCandidates;
23574
+ const v2 = await resolveInstalledNodeScriptLaunchCandidates({
23575
+ additionalCommandDirectories: resolveOpenCodeCommandDirectories(),
23576
+ commandName: "opencode2",
23577
+ displayName: "OpenCode 2"
23578
+ });
23579
+ if (!(installedCandidates.ok || v2.ok)) return installedCandidates;
23580
+ const discovered = [...installedCandidates.ok ? installedCandidates.candidates : [], ...v2.ok ? v2.candidates : []];
22937
23581
  const candidates = await resolveLaunchCandidatesAfterVerification({
22938
- candidates: installedCandidates.candidates,
23582
+ candidates: [...new Map(discovered.map((candidate) => [JSON.stringify(candidate.launchContract), candidate])).values()],
22939
23583
  verify: async (candidate) => await verifyOpenCodeLaunchContract({
22940
23584
  launchContract: candidate.launchContract,
22941
23585
  timeoutMs: input?.timeoutMs
@@ -22961,16 +23605,16 @@ async function verifyOpenCodeLaunchContract(input) {
22961
23605
  });
22962
23606
  }
22963
23607
  function resolveOpenCodeTimeoutMs() {
22964
- const raw = normalizeOptionalText$12(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
23608
+ const raw = normalizeOptionalText$10(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
22965
23609
  if (!raw) return null;
22966
23610
  const parsed = Number.parseInt(raw, 10);
22967
23611
  if (!Number.isFinite(parsed) || parsed <= 0) return null;
22968
23612
  return parsed;
22969
23613
  }
22970
23614
  function resolveOpenCodeCommandDirectories() {
22971
- return [join(normalizeOptionalText$12(process.env.HOME) ?? homedir(), ".opencode", "bin")];
23615
+ return [join(normalizeOptionalText$10(process.env.HOME) ?? homedir(), ".opencode", "bin")];
22972
23616
  }
22973
- function normalizeOptionalText$12(value) {
23617
+ function normalizeOptionalText$10(value) {
22974
23618
  const normalized = String(value ?? "").trim();
22975
23619
  return normalized.length > 0 ? normalized : null;
22976
23620
  }
@@ -22981,579 +23625,6 @@ function isLikelyOpenCodeContextLostError(message) {
22981
23625
  return normalized.includes("session") && (normalized.includes("not found") || normalized.includes("missing") || normalized.includes("invalid") || normalized.includes("expired") || normalized.includes("deleted"));
22982
23626
  }
22983
23627
  //#endregion
22984
- //#region ../../runtime/adapters/opencode/dist/output/opencode-output-parser.js
22985
- const OPENCODE_SESSION_ID_PATHS = [
22986
- ["sessionID"],
22987
- ["sessionId"],
22988
- ["session_id"],
22989
- ["session", "id"],
22990
- ["metadata", "sessionID"],
22991
- ["metadata", "sessionId"],
22992
- ["metadata", "session_id"],
22993
- ["context", "sessionID"],
22994
- ["context", "sessionId"],
22995
- ["context", "session_id"]
22996
- ];
22997
- const OPENCODE_TEXT_PATHS = [
22998
- ["part", "text"],
22999
- ["text"],
23000
- ["content"],
23001
- ["message"],
23002
- ["delta", "text"],
23003
- ["data", "text"],
23004
- ["data", "content"],
23005
- ["payload", "text"],
23006
- ["payload", "content"]
23007
- ];
23008
- const OPENCODE_ERROR_MESSAGE_PATHS = [
23009
- ["error", "message"],
23010
- ["error", "text"],
23011
- [
23012
- "error",
23013
- "data",
23014
- "message"
23015
- ],
23016
- [
23017
- "error",
23018
- "data",
23019
- "error"
23020
- ],
23021
- [
23022
- "error",
23023
- "cause",
23024
- "message"
23025
- ],
23026
- ["error"],
23027
- [
23028
- "errors",
23029
- "0",
23030
- "message"
23031
- ],
23032
- ["message"],
23033
- [
23034
- "data",
23035
- "error",
23036
- "message"
23037
- ],
23038
- [
23039
- "data",
23040
- "error",
23041
- "text"
23042
- ],
23043
- [
23044
- "data",
23045
- "error",
23046
- "data",
23047
- "message"
23048
- ],
23049
- ["data", "error"],
23050
- ["data", "message"]
23051
- ];
23052
- function parseOpenCodeOutputLine(line) {
23053
- const normalizedLine = line.trim();
23054
- if (!normalizedLine) return null;
23055
- let parsed;
23056
- try {
23057
- parsed = JSON.parse(normalizedLine);
23058
- } catch {
23059
- return null;
23060
- }
23061
- const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
23062
- if (!record) return null;
23063
- const isErrorResult = resolveIsErrorResult(record);
23064
- const errorMessage = resolveErrorMessage(record, isErrorResult);
23065
- const resultText = resolveResultText(record, isErrorResult);
23066
- const sessionId = resolveSessionId(record);
23067
- if (!errorMessage && resultText === null && sessionId === null && isErrorResult === null) return null;
23068
- return {
23069
- errorMessage,
23070
- isErrorResult,
23071
- resultText,
23072
- sessionId,
23073
- terminal: isErrorResult === true
23074
- };
23075
- }
23076
- function parseOpenCodeOutputDocument(text) {
23077
- const normalizedText = text.trim();
23078
- if (!normalizedText) return null;
23079
- const lines = normalizedText.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
23080
- if (lines.length === 0) return null;
23081
- let outputText = "";
23082
- let sessionId = null;
23083
- let errorMessage = null;
23084
- let isErrorResult = null;
23085
- let parsedAnyLine = false;
23086
- for (const line of lines) {
23087
- const parsedLine = parseOpenCodeOutputLine(line);
23088
- if (!parsedLine) continue;
23089
- parsedAnyLine = true;
23090
- if (parsedLine.sessionId) sessionId = parsedLine.sessionId;
23091
- if (parsedLine.resultText) outputText += parsedLine.resultText;
23092
- if (parsedLine.errorMessage) errorMessage = parsedLine.errorMessage;
23093
- if (parsedLine.isErrorResult !== null) isErrorResult = parsedLine.isErrorResult;
23094
- }
23095
- if (!parsedAnyLine) return null;
23096
- return {
23097
- errorMessage,
23098
- isErrorResult,
23099
- outputText: normalizeOptionalText$11(outputText),
23100
- sessionId
23101
- };
23102
- }
23103
- function resolveSessionId(record) {
23104
- return resolveStringByPaths(record, OPENCODE_SESSION_ID_PATHS);
23105
- }
23106
- function resolveResultText(record, isErrorResult) {
23107
- if (isErrorResult === true) return null;
23108
- if (record.type !== "text") return null;
23109
- return resolveTextByPaths(record, OPENCODE_TEXT_PATHS);
23110
- }
23111
- function resolveErrorMessage(record, isErrorResult) {
23112
- if (isErrorResult !== true) return null;
23113
- return resolveStringByPaths(record, OPENCODE_ERROR_MESSAGE_PATHS);
23114
- }
23115
- function resolveIsErrorResult(record) {
23116
- if (record.type === "error") return true;
23117
- if (typeof record.is_error === "boolean") return record.is_error;
23118
- if (typeof record.isError === "boolean") return record.isError;
23119
- if (typeof record.ok === "boolean") return !record.ok;
23120
- if (typeof record.success === "boolean") return !record.success;
23121
- const status = normalizeOptionalText$11(record.status)?.toLowerCase();
23122
- if (status === "error" || status === "failed" || status === "fail") return true;
23123
- if (status === "ok" || status === "success" || status === "completed") return false;
23124
- return null;
23125
- }
23126
- function resolveStringByPaths(record, paths) {
23127
- for (const path of paths) {
23128
- let current = record;
23129
- for (const segment of path) {
23130
- if (current && typeof current === "object" && !Array.isArray(current)) {
23131
- current = current[segment];
23132
- continue;
23133
- }
23134
- current = void 0;
23135
- break;
23136
- }
23137
- const normalized = normalizeScalarText(current);
23138
- if (normalized) return normalized;
23139
- }
23140
- return null;
23141
- }
23142
- function resolveTextByPaths(record, paths) {
23143
- for (const path of paths) {
23144
- let current = record;
23145
- for (const segment of path) {
23146
- if (current && typeof current === "object" && !Array.isArray(current)) {
23147
- current = current[segment];
23148
- continue;
23149
- }
23150
- current = void 0;
23151
- break;
23152
- }
23153
- if (typeof current === "string" && current.length > 0) return current;
23154
- }
23155
- return null;
23156
- }
23157
- function normalizeOptionalText$11(value) {
23158
- const normalized = String(value ?? "").trim();
23159
- return normalized.length > 0 ? normalized : null;
23160
- }
23161
- function normalizeScalarText(value) {
23162
- if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return null;
23163
- return normalizeOptionalText$11(value);
23164
- }
23165
- //#endregion
23166
- //#region ../../runtime/adapters/opencode/dist/transport/opencode-failure.js
23167
- function classifyOpenCodeFailureMessage(input) {
23168
- const normalized = input.message.trim();
23169
- const lowered = normalized.toLowerCase();
23170
- const originalError = input.includeOriginalError ? createProviderOriginalError(normalized) : null;
23171
- const withOriginalError = (value) => ({
23172
- ...value,
23173
- ...originalError ? { originalError } : {}
23174
- });
23175
- const permissionDenial = classifyRuntimePermissionDenialMessage({
23176
- message: normalized,
23177
- source: "opencode"
23178
- });
23179
- if (permissionDenial) return withOriginalError(permissionDenial);
23180
- if (input.isContextLost(normalized)) return withOriginalError({
23181
- code: "context.lost",
23182
- errorType: "adapter",
23183
- message: `context.lost: ${normalized}`
23184
- });
23185
- if (lowered.includes("not logged in") || lowered.includes("unauthorized") || lowered.includes("authentication") || lowered.includes("credentials")) return withOriginalError({
23186
- code: "auth.required",
23187
- errorType: "auth",
23188
- message: `auth.required: ${normalized}`
23189
- });
23190
- if (lowered.includes("unsupported model") || lowered.includes("model is not supported") || lowered.includes("invalid model") || lowered.includes("model not found")) return withOriginalError({
23191
- code: "model.unsupported",
23192
- errorType: "config",
23193
- message: `model.unsupported: ${normalized}`
23194
- });
23195
- if (isInsufficientBalanceFailure(lowered)) return withOriginalError({
23196
- code: "provider.insufficient_balance",
23197
- errorType: "adapter",
23198
- message: `provider.insufficient_balance: ${normalized}`,
23199
- providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
23200
- });
23201
- if (isDefinitiveHardQuotaFailure(lowered)) return withOriginalError({
23202
- code: "quota.exceeded",
23203
- errorType: "adapter",
23204
- message: `quota.exceeded: ${normalized}`,
23205
- providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
23206
- });
23207
- if (isTransientRateLimitFailure(lowered)) return withOriginalError({
23208
- code: "provider.rate_limited",
23209
- errorType: "network",
23210
- message: `provider.rate_limited: ${normalized}`
23211
- });
23212
- if (isSubscriptionAccessFailure(lowered)) return withOriginalError({
23213
- code: "provider.subscription_access_unavailable",
23214
- errorType: "adapter",
23215
- message: `provider.subscription_access_unavailable: ${normalized}`,
23216
- providerAccessEvidence: buildProviderAccessEvidence("provider_account.subscription_access_unavailable")
23217
- });
23218
- if (isProviderUnavailableFailure(lowered)) return withOriginalError({
23219
- code: "provider.unavailable",
23220
- errorType: "network",
23221
- message: `provider.unavailable: ${normalized}`
23222
- });
23223
- if (isHardQuotaFailure(lowered)) return withOriginalError({
23224
- code: "quota.exceeded",
23225
- errorType: "adapter",
23226
- message: `quota.exceeded: ${normalized}`,
23227
- providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
23228
- });
23229
- return withOriginalError({
23230
- code: "upstream_unreachable",
23231
- errorType: "adapter",
23232
- message: `upstream_unreachable: ${normalized}`
23233
- });
23234
- }
23235
- function buildProviderAccessEvidence(reasonCode) {
23236
- return {
23237
- observedAtMs: Date.now(),
23238
- provider: "opencode",
23239
- reasonCode,
23240
- source: "wake_failure"
23241
- };
23242
- }
23243
- function isHardQuotaFailure(value) {
23244
- return isDefinitiveHardQuotaFailure(value) || value.includes("usage limit") || value.includes("usage_limit");
23245
- }
23246
- function isDefinitiveHardQuotaFailure(value) {
23247
- return value.includes("insufficient quota") || value.includes("insufficient_quota") || value.includes("quota exceeded") || value.includes("exceeded your current quota");
23248
- }
23249
- function isSubscriptionAccessFailure(value) {
23250
- return value.includes("not included in your subscription") || value.includes("not available on your plan") || value.includes("subscription does not include") || value.includes("subscription access") || value.includes("upgrade your plan");
23251
- }
23252
- function isTransientRateLimitFailure(value) {
23253
- return value.includes("429") || value.includes("rate limit") || value.includes("too many requests");
23254
- }
23255
- function isInsufficientBalanceFailure(value) {
23256
- return value.includes("insufficient balance") || value.includes("insufficient_balance") || value.includes("not enough credits") || value.includes("out of credits") || value.includes("credits exhausted") || value.includes("credit balance") || value.includes("account balance") || value.includes("balance is too low") || value.includes("payment required");
23257
- }
23258
- function isProviderUnavailableFailure(value) {
23259
- return value.includes("bad gateway") || value.includes("gateway timeout") || value.includes("service unavailable") || value.includes("provider unavailable") || value.includes("socket hang up") || value.includes("econnreset") || value.includes("etimedout");
23260
- }
23261
- //#endregion
23262
- //#region ../../runtime/adapters/opencode/dist/transport/opencode-cli-transport.js
23263
- var OpenCodeCliTransportError = class extends Error {
23264
- code;
23265
- errorType;
23266
- originalError;
23267
- providerAccessEvidence;
23268
- constructor(input) {
23269
- super(input.message);
23270
- this.name = "OpenCodeCliTransportError";
23271
- this.code = input.code;
23272
- this.errorType = input.errorType;
23273
- this.originalError = input.originalError;
23274
- this.providerAccessEvidence = input.providerAccessEvidence;
23275
- }
23276
- };
23277
- const STREAMING_PROVIDER_FAILURE_THRESHOLD = 3;
23278
- async function invokeOpenCodeCliTransport(input) {
23279
- const prompt = normalizeOptionalText$10(input.prompt);
23280
- if (!prompt) throw new OpenCodeCliTransportError({
23281
- code: "schema.invalid",
23282
- errorType: "config",
23283
- message: "schema.invalid: prompt is required"
23284
- });
23285
- if (normalizeOptionalText$10(input.sessionId)) throw new OpenCodeCliTransportError({
23286
- code: "context.resume_requires_server",
23287
- errorType: "adapter",
23288
- message: "An existing OpenCode conversation requires the server connection to verify its working folder."
23289
- });
23290
- const invocation = buildCliLaunchInvocation({
23291
- args: buildOpenCodeArgs({
23292
- conversationPolicy: input.conversationPolicy,
23293
- prompt,
23294
- workdir: input.openCodeWorkdir
23295
- }),
23296
- launchContract: input.launchContract
23297
- });
23298
- let latestOutput = "";
23299
- let latestResultIsError = false;
23300
- let resolvedSessionId = null;
23301
- const providerErrorMessages = [];
23302
- const invokedAtMs = Date.now();
23303
- let firstStdoutAtMs = null;
23304
- let firstStderrAtMs = null;
23305
- let streamingProviderFailureCount = 0;
23306
- let stoppedForStreamingProviderFailure = false;
23307
- let driverResult;
23308
- try {
23309
- driverResult = await runCliDriver({
23310
- allowNonZeroExit: true,
23311
- args: invocation.args,
23312
- bin: invocation.bin,
23313
- cwd: input.openCodeWorkdir,
23314
- env: input.env,
23315
- onLifecycleEvent: input.onRuntimeEvent,
23316
- onProcessControlEvent: input.onProcessControlEvent,
23317
- onStderrLine: (event) => {
23318
- if (firstStderrAtMs === null) firstStderrAtMs = Date.now();
23319
- const providerErrorMessage = collectProviderErrorMessage(event.line, providerErrorMessages);
23320
- if (!providerErrorMessage) return;
23321
- if (looksLikeStreamingProviderFailure(providerErrorMessage)) {
23322
- streamingProviderFailureCount += 1;
23323
- if (streamingProviderFailureCount >= STREAMING_PROVIDER_FAILURE_THRESHOLD) {
23324
- stoppedForStreamingProviderFailure = true;
23325
- return {
23326
- complete: true,
23327
- terminateProcess: true
23328
- };
23329
- }
23330
- }
23331
- },
23332
- onStdoutLine: (event) => {
23333
- if (firstStdoutAtMs === null) firstStdoutAtMs = Date.now();
23334
- const parsedLine = parseOpenCodeOutputLine(event.line);
23335
- if (!parsedLine) {
23336
- collectRuntimePermissionDenialMessage(event.line, providerErrorMessages);
23337
- return;
23338
- }
23339
- if (parsedLine.resultText) latestOutput += parsedLine.resultText;
23340
- if (parsedLine.errorMessage) providerErrorMessages.push(parsedLine.errorMessage);
23341
- if (parsedLine.isErrorResult === true) {
23342
- latestResultIsError = true;
23343
- return;
23344
- }
23345
- if (parsedLine.isErrorResult === false) latestResultIsError = false;
23346
- if (parsedLine.sessionId) resolvedSessionId = parsedLine.sessionId;
23347
- if (parsedLine.terminal) return {
23348
- complete: true,
23349
- terminateProcess: true
23350
- };
23351
- },
23352
- timeoutMs: input.openCodeTimeoutMs
23353
- });
23354
- } catch (error) {
23355
- throw toOpenCodeCliTransportError(error, input.openCodeTimeoutMs);
23356
- }
23357
- if (stoppedForStreamingProviderFailure) {
23358
- const classifiedFailure = classifyOpenCodeFailure({
23359
- providerErrorMessages,
23360
- stderrText: driverResult.stderrText,
23361
- stdoutText: driverResult.stdoutText
23362
- });
23363
- throw new OpenCodeCliTransportError({
23364
- code: classifiedFailure.code,
23365
- errorType: classifiedFailure.errorType,
23366
- message: classifiedFailure.message,
23367
- originalError: classifiedFailure.originalError,
23368
- providerAccessEvidence: classifiedFailure.providerAccessEvidence
23369
- });
23370
- }
23371
- if (driverResult.exitCode !== 0 || latestResultIsError) {
23372
- const classifiedFailure = classifyOpenCodeFailure({
23373
- providerErrorMessages,
23374
- stderrText: driverResult.stderrText,
23375
- stdoutText: driverResult.stdoutText
23376
- });
23377
- throw new OpenCodeCliTransportError({
23378
- code: classifiedFailure.code,
23379
- errorType: classifiedFailure.errorType,
23380
- message: classifiedFailure.message,
23381
- originalError: classifiedFailure.originalError,
23382
- providerAccessEvidence: classifiedFailure.providerAccessEvidence
23383
- });
23384
- }
23385
- const documentParsed = parseOpenCodeOutputDocument(driverResult.stdoutText);
23386
- if (documentParsed) {
23387
- if (documentParsed.outputText) latestOutput = documentParsed.outputText;
23388
- if (documentParsed.sessionId) resolvedSessionId = documentParsed.sessionId;
23389
- if (documentParsed.errorMessage) providerErrorMessages.push(documentParsed.errorMessage);
23390
- if (documentParsed.isErrorResult === true) {
23391
- const classifiedFailure = classifyOpenCodeFailure({
23392
- providerErrorMessages,
23393
- stderrText: driverResult.stderrText,
23394
- stdoutText: driverResult.stdoutText
23395
- });
23396
- throw new OpenCodeCliTransportError({
23397
- code: classifiedFailure.code,
23398
- errorType: classifiedFailure.errorType,
23399
- message: classifiedFailure.message,
23400
- originalError: classifiedFailure.originalError,
23401
- providerAccessEvidence: classifiedFailure.providerAccessEvidence
23402
- });
23403
- }
23404
- }
23405
- const output = normalizeOptionalText$10(latestOutput);
23406
- if (!output) {
23407
- if (providerErrorMessages.length > 0) {
23408
- const classifiedFailure = classifyOpenCodeFailure({
23409
- providerErrorMessages,
23410
- stderrText: driverResult.stderrText,
23411
- stdoutText: driverResult.stdoutText
23412
- });
23413
- throw new OpenCodeCliTransportError({
23414
- code: classifiedFailure.code,
23415
- errorType: classifiedFailure.errorType,
23416
- message: classifiedFailure.message,
23417
- originalError: classifiedFailure.originalError,
23418
- providerAccessEvidence: classifiedFailure.providerAccessEvidence
23419
- });
23420
- }
23421
- throw new OpenCodeCliTransportError({
23422
- code: "runtime.output.empty",
23423
- errorType: "adapter",
23424
- message: "runtime.output.empty: opencode finished without agent output"
23425
- });
23426
- }
23427
- return {
23428
- output,
23429
- sessionId: normalizeOptionalText$10(resolvedSessionId),
23430
- telemetry: buildTransportTelemetry({
23431
- driverResult,
23432
- firstStderrAtMs,
23433
- firstStdoutAtMs,
23434
- invokedAtMs,
23435
- resumedContext: false
23436
- })
23437
- };
23438
- }
23439
- const buildOpenCodeArgs = (input) => {
23440
- const args = [
23441
- "run",
23442
- "--format",
23443
- "json",
23444
- "--print-logs",
23445
- "--dir",
23446
- input.workdir
23447
- ];
23448
- const model = normalizeOptionalText$10(input.conversationPolicy?.model);
23449
- if (model) args.push("--model", model);
23450
- const reasoningLevel = normalizeOptionalText$10(input.conversationPolicy?.reasoningLevel);
23451
- if (reasoningLevel) args.push("--variant", reasoningLevel);
23452
- args.push(input.prompt);
23453
- return args;
23454
- };
23455
- const buildTransportTelemetry = (input) => ({
23456
- completedAtMs: Date.now(),
23457
- ...input.driverResult.lifecycle.exitCode === null ? {} : { exitCode: input.driverResult.lifecycle.exitCode },
23458
- ...input.driverResult.lifecycle.exitObservedAtMs === null ? {} : { exitObservedAtMs: input.driverResult.lifecycle.exitObservedAtMs },
23459
- ...input.driverResult.lifecycle.exitSignal === null ? {} : { exitSignal: input.driverResult.lifecycle.exitSignal },
23460
- ...input.firstStderrAtMs === null ? {} : { firstStderrAtMs: input.firstStderrAtMs },
23461
- ...input.firstStdoutAtMs === null ? {} : { firstStdoutAtMs: input.firstStdoutAtMs },
23462
- invokedAtMs: input.invokedAtMs,
23463
- ...input.driverResult.lifecycle.processId === null ? {} : { processId: input.driverResult.lifecycle.processId },
23464
- ...input.driverResult.lifecycle.processSpawnedAtMs === null ? {} : { processSpawnedAtMs: input.driverResult.lifecycle.processSpawnedAtMs },
23465
- resumedContext: input.resumedContext,
23466
- ...input.driverResult.lifecycle.stdinClosedAtMs === null ? {} : { stdinClosedAtMs: input.driverResult.lifecycle.stdinClosedAtMs },
23467
- ...input.driverResult.lifecycle.timeoutTriggeredAtMs === null ? {} : { timeoutTriggeredAtMs: input.driverResult.lifecycle.timeoutTriggeredAtMs }
23468
- });
23469
- const toOpenCodeCliTransportError = (error, timeoutMs) => {
23470
- if (error instanceof OpenCodeCliTransportError) return error;
23471
- if (error instanceof CliDriverError) {
23472
- if (error.code === "process.timeout") return new OpenCodeCliTransportError(classifyCliDriverTimeoutFailure({
23473
- error,
23474
- providerLabel: "opencode",
23475
- timeoutMs
23476
- }));
23477
- if (error.code === "process.spawn_failed") return new OpenCodeCliTransportError({
23478
- code: "upstream_unreachable",
23479
- errorType: "adapter",
23480
- message: `upstream_unreachable: failed to spawn opencode (${error.message})`
23481
- });
23482
- if (error.code === "process.non_zero_exit") {
23483
- const classifiedFailure = classifyOpenCodeFailure({
23484
- providerErrorMessages: [],
23485
- stderrText: error.stderrText,
23486
- stdoutText: error.stdoutText
23487
- });
23488
- return new OpenCodeCliTransportError({
23489
- code: classifiedFailure.code,
23490
- errorType: classifiedFailure.errorType,
23491
- message: classifiedFailure.message,
23492
- originalError: classifiedFailure.originalError,
23493
- providerAccessEvidence: classifiedFailure.providerAccessEvidence
23494
- });
23495
- }
23496
- }
23497
- return new OpenCodeCliTransportError({
23498
- code: "upstream_unreachable",
23499
- errorType: "adapter",
23500
- message: `upstream_unreachable: failed to execute opencode (${error instanceof Error ? error.message : String(error)})`
23501
- });
23502
- };
23503
- const classifyOpenCodeFailure = (input) => {
23504
- const hasProviderOwnedMessage = input.providerErrorMessages.length > 0 || extractErrorMessagesFromStdout(input.stdoutText).length > 0;
23505
- const providerMessage = resolveProviderFailureMessage(input);
23506
- if (providerMessage) return classifyOpenCodeFailureMessage({
23507
- includeOriginalError: hasProviderOwnedMessage,
23508
- isContextLost: isLikelyOpenCodeContextLostError,
23509
- message: providerMessage
23510
- });
23511
- return { ...buildProviderExitError({ providerLabel: "opencode" }) };
23512
- };
23513
- const resolveProviderFailureMessage = (input) => {
23514
- const candidateMessages = [
23515
- ...input.providerErrorMessages,
23516
- ...extractErrorMessagesFromStdout(input.stdoutText),
23517
- ...normalizeOptionalText$10(input.stderrText) ? [normalizeOptionalText$10(input.stderrText)] : []
23518
- ].filter((value) => Boolean(value));
23519
- for (const candidate of candidateMessages) if (looksLikeRuntimePermissionDenialMessage(candidate) || looksLikeProviderFailure(candidate)) return candidate;
23520
- return candidateMessages[0] ?? null;
23521
- };
23522
- const extractErrorMessagesFromStdout = (value) => {
23523
- const stdoutText = normalizeOptionalText$10(value);
23524
- if (!stdoutText) return [];
23525
- const messages = [];
23526
- const lines = stdoutText.split("\n");
23527
- for (const line of lines) {
23528
- const parsedLine = parseOpenCodeOutputLine(line);
23529
- if (parsedLine?.errorMessage) messages.push(parsedLine.errorMessage);
23530
- }
23531
- return messages;
23532
- };
23533
- const collectProviderErrorMessage = (line, output) => {
23534
- const normalized = normalizeOptionalText$10(line);
23535
- if (!normalized) return null;
23536
- output.push(normalized);
23537
- return normalized;
23538
- };
23539
- const collectRuntimePermissionDenialMessage = (line, output) => {
23540
- const normalized = normalizeOptionalText$10(line);
23541
- if (!(normalized && looksLikeRuntimePermissionDenialMessage(normalized))) return;
23542
- output.push(normalized);
23543
- };
23544
- const looksLikeProviderFailure = (value) => {
23545
- const lowered = value.toLowerCase();
23546
- return lowered.includes("error") || lowered.includes("failed") || lowered.includes("permission") || lowered.includes("reject") || lowered.includes("denied") || lowered.includes("unauthorized") || lowered.includes("not logged in") || lowered.includes("invalid") || lowered.includes("quota") || lowered.includes("rate") || lowered.includes("balance") || lowered.includes("credit") || lowered.includes("billing") || lowered.includes("payment required") || lowered.includes("session") || lowered.includes("unsupported model") || lowered.includes("model is not supported");
23547
- };
23548
- const looksLikeStreamingProviderFailure = (value) => {
23549
- const lowered = value.toLowerCase();
23550
- return lowered.includes("ai_apicallerror") || lowered.includes("bad gateway") || lowered.includes("gateway timeout") || lowered.includes("econnreset") || lowered.includes("etimedout") || lowered.includes("socket hang up");
23551
- };
23552
- function normalizeOptionalText$10(value) {
23553
- const normalized = String(value ?? "").trim();
23554
- return normalized.length > 0 ? normalized : null;
23555
- }
23556
- //#endregion
23557
23628
  //#region ../../runtime/adapters/opencode/dist/transport/opencode-delivery-only.js
23558
23629
  const SAFE_TOOL_ID = /^[A-Za-z0-9_.:-]+$/u;
23559
23630
  /** Narrow only the disposable correction session; never grant a final tool. */
@@ -23624,6 +23695,102 @@ function scopeError(message) {
23624
23695
  });
23625
23696
  }
23626
23697
  //#endregion
23698
+ //#region ../../runtime/adapters/opencode/dist/transport/opencode-failure.js
23699
+ function classifyOpenCodeFailureMessage(input) {
23700
+ const normalized = input.message.trim();
23701
+ const lowered = normalized.toLowerCase();
23702
+ const originalError = input.includeOriginalError ? createProviderOriginalError(normalized) : null;
23703
+ const withOriginalError = (value) => ({
23704
+ ...value,
23705
+ ...originalError ? { originalError } : {}
23706
+ });
23707
+ const permissionDenial = classifyRuntimePermissionDenialMessage({
23708
+ message: normalized,
23709
+ source: "opencode"
23710
+ });
23711
+ if (permissionDenial) return withOriginalError(permissionDenial);
23712
+ if (input.isContextLost(normalized)) return withOriginalError({
23713
+ code: "context.lost",
23714
+ errorType: "adapter",
23715
+ message: `context.lost: ${normalized}`
23716
+ });
23717
+ if (lowered.includes("not logged in") || lowered.includes("unauthorized") || lowered.includes("authentication") || lowered.includes("credentials")) return withOriginalError({
23718
+ code: "auth.required",
23719
+ errorType: "auth",
23720
+ message: `auth.required: ${normalized}`
23721
+ });
23722
+ if (lowered.includes("unsupported model") || lowered.includes("model is not supported") || lowered.includes("invalid model") || lowered.includes("model not found")) return withOriginalError({
23723
+ code: "model.unsupported",
23724
+ errorType: "config",
23725
+ message: `model.unsupported: ${normalized}`
23726
+ });
23727
+ if (isInsufficientBalanceFailure(lowered)) return withOriginalError({
23728
+ code: "provider.insufficient_balance",
23729
+ errorType: "adapter",
23730
+ message: `provider.insufficient_balance: ${normalized}`,
23731
+ providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
23732
+ });
23733
+ if (isDefinitiveHardQuotaFailure(lowered)) return withOriginalError({
23734
+ code: "quota.exceeded",
23735
+ errorType: "adapter",
23736
+ message: `quota.exceeded: ${normalized}`,
23737
+ providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
23738
+ });
23739
+ if (isTransientRateLimitFailure(lowered)) return withOriginalError({
23740
+ code: "provider.rate_limited",
23741
+ errorType: "network",
23742
+ message: `provider.rate_limited: ${normalized}`
23743
+ });
23744
+ if (isSubscriptionAccessFailure(lowered)) return withOriginalError({
23745
+ code: "provider.subscription_access_unavailable",
23746
+ errorType: "adapter",
23747
+ message: `provider.subscription_access_unavailable: ${normalized}`,
23748
+ providerAccessEvidence: buildProviderAccessEvidence("provider_account.subscription_access_unavailable")
23749
+ });
23750
+ if (isProviderUnavailableFailure(lowered)) return withOriginalError({
23751
+ code: "provider.unavailable",
23752
+ errorType: "network",
23753
+ message: `provider.unavailable: ${normalized}`
23754
+ });
23755
+ if (isHardQuotaFailure(lowered)) return withOriginalError({
23756
+ code: "quota.exceeded",
23757
+ errorType: "adapter",
23758
+ message: `quota.exceeded: ${normalized}`,
23759
+ providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
23760
+ });
23761
+ return withOriginalError({
23762
+ code: "upstream_unreachable",
23763
+ errorType: "adapter",
23764
+ message: `upstream_unreachable: ${normalized}`
23765
+ });
23766
+ }
23767
+ function buildProviderAccessEvidence(reasonCode) {
23768
+ return {
23769
+ observedAtMs: Date.now(),
23770
+ provider: "opencode",
23771
+ reasonCode,
23772
+ source: "wake_failure"
23773
+ };
23774
+ }
23775
+ function isHardQuotaFailure(value) {
23776
+ return isDefinitiveHardQuotaFailure(value) || value.includes("usage limit") || value.includes("usage_limit");
23777
+ }
23778
+ function isDefinitiveHardQuotaFailure(value) {
23779
+ return value.includes("insufficient quota") || value.includes("insufficient_quota") || value.includes("quota exceeded") || value.includes("exceeded your current quota");
23780
+ }
23781
+ function isSubscriptionAccessFailure(value) {
23782
+ return value.includes("not included in your subscription") || value.includes("not available on your plan") || value.includes("subscription does not include") || value.includes("subscription access") || value.includes("upgrade your plan");
23783
+ }
23784
+ function isTransientRateLimitFailure(value) {
23785
+ return value.includes("429") || value.includes("rate limit") || value.includes("too many requests");
23786
+ }
23787
+ function isInsufficientBalanceFailure(value) {
23788
+ return value.includes("insufficient balance") || value.includes("insufficient_balance") || value.includes("not enough credits") || value.includes("out of credits") || value.includes("credits exhausted") || value.includes("credit balance") || value.includes("account balance") || value.includes("balance is too low") || value.includes("payment required");
23789
+ }
23790
+ function isProviderUnavailableFailure(value) {
23791
+ return value.includes("bad gateway") || value.includes("gateway timeout") || value.includes("service unavailable") || value.includes("provider unavailable") || value.includes("socket hang up") || value.includes("econnreset") || value.includes("etimedout");
23792
+ }
23793
+ //#endregion
23627
23794
  //#region ../../runtime/adapters/opencode/dist/transport/opencode-interactions.js
23628
23795
  var OpenCodeInteractionHandler = class {
23629
23796
  #client;
@@ -23804,8 +23971,449 @@ function normalizeBoundedText(value, maxLength) {
23804
23971
  return normalized.length > 0 ? normalized.slice(0, maxLength) : null;
23805
23972
  }
23806
23973
  //#endregion
23974
+ //#region ../../runtime/adapters/opencode/dist/transport/opencode2-server.js
23975
+ function createOpenCode2Client(baseUrl, password) {
23976
+ return OpenCode.make({
23977
+ baseUrl,
23978
+ headers: { Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}` }
23979
+ });
23980
+ }
23981
+ function openCode2Error(code, message) {
23982
+ return Object.assign(/* @__PURE__ */ new Error(`${code}: ${message}`), {
23983
+ code,
23984
+ errorType: "adapter"
23985
+ });
23986
+ }
23987
+ async function readOpenCode2Inventory(input) {
23988
+ const client = createOpenCode2Client(input.baseUrl, input.password);
23989
+ const options = { signal: AbortSignal.timeout(input.timeoutMs) };
23990
+ if (!(await client.server.info(options)).version.startsWith("2.")) throw openCode2Error("protocol.invalid", "OpenCode returned an unsupported API version.");
23991
+ return (await client.model.list({ location: { directory: input.directory } }, options)).data.filter((model) => model.enabled).slice(0, 256).map((model) => ({
23992
+ id: `${model.providerID}/${model.id}`,
23993
+ displayName: model.name
23994
+ }));
23995
+ }
23996
+ //#endregion
23997
+ //#region ../../runtime/adapters/opencode/dist/transport/opencode2-interactions.js
23998
+ async function answerOpenCode2Permission(client, request, onInteractionRequest, signal) {
23999
+ const options = [
24000
+ {
24001
+ optionId: "once",
24002
+ label: "Allow once",
24003
+ intent: "allow_once"
24004
+ },
24005
+ ...request.save?.length ? [{
24006
+ optionId: "always",
24007
+ label: "Always allow",
24008
+ intent: "allow_always"
24009
+ }] : [],
24010
+ {
24011
+ optionId: "reject",
24012
+ label: "Deny",
24013
+ intent: "deny"
24014
+ }
24015
+ ];
24016
+ const response = onInteractionRequest ? await requestInteraction(onInteractionRequest, {
24017
+ kind: "permission",
24018
+ title: "OpenCode needs permission",
24019
+ description: (request.message || `${request.action}: ${request.resources.join(", ")}`).slice(0, 4e3),
24020
+ subject: { type: permissionSubject(request.action) },
24021
+ options
24022
+ }, signal) : void 0;
24023
+ const selected = response?.kind === "permission" && options.some((option) => option.optionId === response.optionId) ? response.optionId : "reject";
24024
+ await client.permission.reply({
24025
+ sessionID: request.sessionID,
24026
+ requestID: request.id,
24027
+ decision: selected
24028
+ }, { signal });
24029
+ if (!onInteractionRequest) throw openCode2Error("interaction.permission_required", "OpenCode requested permission without a user interaction channel.");
24030
+ }
24031
+ async function answerOpenCode2Form(client, form, onInteractionRequest, signal) {
24032
+ const answer = {};
24033
+ try {
24034
+ if (!onInteractionRequest) throw openCode2Error("interaction.question_required", "OpenCode requested input without a user interaction channel.");
24035
+ for (const field of form.fields) {
24036
+ if (field.type === "external") throw openCode2Error("interaction.question_unsupported", "This OpenCode form requires an external browser action.");
24037
+ if (field.when?.some((condition) => answer[condition.key] === condition.value !== (condition.op === "eq"))) continue;
24038
+ if (applyHiddenField(field, answer)) continue;
24039
+ const options = fieldOptions(field);
24040
+ if (options.length > 20) throw openCode2Error("interaction.question_unsupported", "The OpenCode form has too many choices.");
24041
+ if (field.key.length > 256) throw openCode2Error("interaction.question_unsupported", "The OpenCode field identifier is too long.");
24042
+ const response = await requestInteraction(onInteractionRequest, {
24043
+ kind: "question",
24044
+ title: form.title.slice(0, 240),
24045
+ questions: [{
24046
+ questionId: field.key,
24047
+ prompt: [field.title || field.key, field.description].filter(Boolean).join("\n").slice(0, 4e3),
24048
+ options,
24049
+ multiple: field.type === "multiselect",
24050
+ allowOther: options.length === 0 || "custom" in field && field.custom === true
24051
+ }]
24052
+ }, signal);
24053
+ if (response.kind !== "question") {
24054
+ await client.session.form.cancel({
24055
+ sessionID: form.sessionID,
24056
+ formID: form.id
24057
+ }, { signal });
24058
+ return;
24059
+ }
24060
+ const values = response.answers.find((item) => item.questionId === field.key)?.values;
24061
+ if (!values?.length) throw openCode2Error("interaction.response_invalid", "The form answer is missing.");
24062
+ answer[field.key] = decodeField(field, values);
24063
+ }
24064
+ await client.session.form.reply({
24065
+ sessionID: form.sessionID,
24066
+ formID: form.id,
24067
+ answer
24068
+ }, { signal });
24069
+ } catch (error) {
24070
+ await client.session.form.cancel({
24071
+ sessionID: form.sessionID,
24072
+ formID: form.id
24073
+ }, { signal }).catch(() => void 0);
24074
+ throw error;
24075
+ }
24076
+ }
24077
+ async function requestInteraction(callback, request, signal) {
24078
+ signal?.throwIfAborted();
24079
+ if (!signal) return await callback(request);
24080
+ const stopped = Promise.withResolvers();
24081
+ const onAbort = () => stopped.reject(signal.reason);
24082
+ signal.addEventListener("abort", onAbort, { once: true });
24083
+ try {
24084
+ return await Promise.race([callback(request), stopped.promise]);
24085
+ } finally {
24086
+ signal.removeEventListener("abort", onAbort);
24087
+ }
24088
+ }
24089
+ function decodeField(field, values) {
24090
+ if (field.type !== "multiselect" && values.length !== 1) throw openCode2Error("interaction.response_invalid", "This field requires one answer.");
24091
+ if (field.type === "boolean") {
24092
+ if (values[0] !== "true" && values[0] !== "false") throw openCode2Error("interaction.response_invalid", "A boolean answer must be Yes or No.");
24093
+ return values[0] === "true";
24094
+ }
24095
+ if (field.type === "number" || field.type === "integer") {
24096
+ const value = Number(values[0]);
24097
+ if (!Number.isFinite(value) || field.type === "integer" && !Number.isInteger(value) || typeof field.minimum === "number" && value < field.minimum || typeof field.maximum === "number" && value > field.maximum) throw openCode2Error("interaction.response_invalid", "The number is outside the requested range.");
24098
+ return value;
24099
+ }
24100
+ const resolved = values.map((value) => {
24101
+ const option = field.options?.find((_item, index) => String(index) === value);
24102
+ if (option) return option.value;
24103
+ if (field.options?.length && !field.custom) throw openCode2Error("interaction.response_invalid", "The selected choice is unavailable.");
24104
+ return value;
24105
+ });
24106
+ if (field.type === "multiselect") return resolved;
24107
+ const first = resolved[0];
24108
+ if (first === void 0) throw openCode2Error("interaction.response_invalid", "The form answer is missing.");
24109
+ return first;
24110
+ }
24111
+ function permissionSubject(action) {
24112
+ if (action === "shell") return "command";
24113
+ return action === "edit" ? "file_change" : "tool";
24114
+ }
24115
+ function applyHiddenField(field, answer) {
24116
+ if (!field.hidden) return false;
24117
+ if (field.default !== void 0) answer[field.key] = field.default;
24118
+ else if (field.required) throw openCode2Error("interaction.question_unsupported", "A hidden required field has no default.");
24119
+ return true;
24120
+ }
24121
+ function fieldOptions(field) {
24122
+ if (field.type === "boolean") return [{
24123
+ optionId: "true",
24124
+ label: "Yes"
24125
+ }, {
24126
+ optionId: "false",
24127
+ label: "No"
24128
+ }];
24129
+ if (!("options" in field)) return [];
24130
+ return (field.options ?? []).map((option, index) => ({
24131
+ optionId: String(index),
24132
+ label: option.label.slice(0, 240),
24133
+ ...option.description ? { description: option.description.slice(0, 1e3) } : {}
24134
+ }));
24135
+ }
24136
+ //#endregion
24137
+ //#region ../../runtime/adapters/opencode/dist/transport/opencode2-transport.js
24138
+ async function runOpenCode2Turn(input) {
24139
+ const { client, signal } = input;
24140
+ if (isDispatchSpaceActionDeliveryOnly(input.env)) throw openCode2Error("delivery_scope.unsupported", "OpenCode 2 cannot yet attest an exclusive reply-repair tool scope.");
24141
+ const session = await prepareSession(input);
24142
+ const eventsAbort = new AbortController();
24143
+ const eventSignal = AbortSignal.any([signal, eventsAbort.signal]);
24144
+ const ready = Promise.withResolvers();
24145
+ const done = Promise.withResolvers();
24146
+ ready.promise.catch(() => void 0);
24147
+ done.promise.catch(() => void 0);
24148
+ const state = {
24149
+ sessionId: session.id,
24150
+ sessions: /* @__PURE__ */ new Set([session.id]),
24151
+ tools: /* @__PURE__ */ new Map(),
24152
+ delivered: /* @__PURE__ */ new Set(),
24153
+ assistantMessages: /* @__PURE__ */ new Set(),
24154
+ started: false,
24155
+ output: "",
24156
+ previewEmitted: false
24157
+ };
24158
+ const events = (async () => {
24159
+ for await (const event of client.event.subscribe({ signal: eventSignal })) {
24160
+ if (event.type === "server.connected") {
24161
+ ready.resolve();
24162
+ continue;
24163
+ }
24164
+ if (await observeEvent(input, state, event, eventSignal)) {
24165
+ done.resolve();
24166
+ return;
24167
+ }
24168
+ }
24169
+ throw openCode2Error("protocol.stream_closed", "OpenCode closed the event stream.");
24170
+ })().catch((error) => {
24171
+ ready.reject(error);
24172
+ done.reject(error);
24173
+ });
24174
+ try {
24175
+ await Promise.race([ready.promise, new Promise((_resolve, reject) => {
24176
+ AbortSignal.timeout(5e3).addEventListener("abort", () => reject(openCode2Error("protocol.timeout", "OpenCode did not confirm its event subscription.")), { once: true });
24177
+ })]);
24178
+ const receipt = await client.session.prompt({
24179
+ sessionID: session.id,
24180
+ text: input.instructionPrompt?.userPrompt ?? input.prompt
24181
+ }, { signal });
24182
+ await input.onRuntimeEvent?.({
24183
+ phase: "provider_turn_accepted",
24184
+ agentControllerConversationId: session.id,
24185
+ turnId: receipt.id,
24186
+ tsMs: Date.now()
24187
+ });
24188
+ await done.promise;
24189
+ if (!state.delivered.has(receipt.id)) throw openCode2Error("protocol.receipt_missing", "OpenCode ended an execution without confirming delivery of this prompt.");
24190
+ const messages = await client.message.list({
24191
+ sessionID: session.id,
24192
+ type: "assistant",
24193
+ order: "desc",
24194
+ limit: 100
24195
+ }, { signal });
24196
+ const latest = messages.data.find((message) => message.type === "assistant" && state.assistantMessages.has(message.id));
24197
+ const aiUsage = messages.data.flatMap((message) => {
24198
+ if (message.type !== "assistant" || !state.assistantMessages.has(message.id) || !message.tokens || !message.time.completed) return [];
24199
+ const tokens = message.tokens;
24200
+ const inputTokens = tokens.input + tokens.cache.read + tokens.cache.write;
24201
+ const outputTokens = tokens.output + tokens.reasoning;
24202
+ const observation = readAdapterAiUsageObservation({
24203
+ eventId: `opencode:${session.id}:${message.id}`,
24204
+ provider: message.model.providerID,
24205
+ model: message.model.id,
24206
+ source: "opencode_message",
24207
+ occurredAtMs: message.time.completed,
24208
+ tokens: {
24209
+ input: inputTokens,
24210
+ output: outputTokens,
24211
+ cacheRead: tokens.cache.read,
24212
+ cacheWrite: tokens.cache.write,
24213
+ reasoning: tokens.reasoning,
24214
+ total: inputTokens + outputTokens
24215
+ },
24216
+ cost: typeof message.cost === "number" ? {
24217
+ nanoUsd: Math.round(message.cost * 1e9),
24218
+ kind: "provider_estimate"
24219
+ } : null
24220
+ });
24221
+ return observation ? [observation] : [];
24222
+ });
24223
+ if (latest?.type === "assistant") state.output = latest.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
24224
+ if (input.onPreview && input.streamingMode !== "stream" && state.output) {
24225
+ await input.onPreview({ text: state.output });
24226
+ state.previewEmitted = true;
24227
+ }
24228
+ return {
24229
+ sessionId: session.id,
24230
+ output: state.output,
24231
+ previewEmitted: state.previewEmitted,
24232
+ aiUsage
24233
+ };
24234
+ } finally {
24235
+ eventsAbort.abort();
24236
+ await events;
24237
+ }
24238
+ }
24239
+ async function assertOpenCode2Directory(session, directory) {
24240
+ if (await realpath(session.location.directory) !== await realpath(directory)) throw openCode2Error("context.directory_mismatch", "The OpenCode session belongs to a different working folder.");
24241
+ }
24242
+ function readOpenCode2Permissions(value) {
24243
+ if (!value) return;
24244
+ const raw = JSON.parse(value);
24245
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw openCode2Error("permission.invalid", "OpenCode permission settings must be an object.");
24246
+ const rules = [];
24247
+ for (const [name, setting] of Object.entries(raw)) {
24248
+ const action = {
24249
+ bash: "shell",
24250
+ task: "subagent",
24251
+ write: "edit",
24252
+ patch: "edit"
24253
+ }[name] ?? name;
24254
+ const entries = permissionEntries(setting);
24255
+ if (!entries.length) throw openCode2Error("permission.invalid", "OpenCode permission settings are invalid.");
24256
+ for (const [resource, effect] of entries) {
24257
+ if (effect !== "ask" && effect !== "allow" && effect !== "deny") throw openCode2Error("permission.invalid", "OpenCode permission effects are invalid.");
24258
+ rules.push({
24259
+ action,
24260
+ resource,
24261
+ effect
24262
+ });
24263
+ }
24264
+ }
24265
+ return rules;
24266
+ }
24267
+ async function prepareSession(input) {
24268
+ const { client, signal } = input;
24269
+ const location = { directory: await realpath(input.directory) };
24270
+ const spaceAction = resolveDispatchSpaceActionMcpServer(input.env);
24271
+ if (spaceAction) {
24272
+ await client.mcp.add({
24273
+ location,
24274
+ server: spaceAction.id,
24275
+ config: {
24276
+ type: "local",
24277
+ command: [spaceAction.commandPath, ...spaceAction.args],
24278
+ environment: spaceAction.env,
24279
+ codemode: false
24280
+ }
24281
+ }, { signal });
24282
+ await client.mcp.connect({
24283
+ location,
24284
+ server: spaceAction.id
24285
+ }, { signal });
24286
+ await waitForSpaceActionMcp(client, location, spaceAction.id, signal);
24287
+ await setTimeout$1(500, void 0, { signal });
24288
+ }
24289
+ const modelId = input.conversationPolicy?.model;
24290
+ const split = modelId?.indexOf("/") ?? -1;
24291
+ if (modelId && split < 1) throw openCode2Error("model.unavailable", "OpenCode models require a provider/model identifier.");
24292
+ const model = modelId ? {
24293
+ providerID: modelId.slice(0, split),
24294
+ id: modelId.slice(split + 1),
24295
+ ...input.conversationPolicy?.reasoningLevel ? { variant: input.conversationPolicy.reasoningLevel } : {}
24296
+ } : void 0;
24297
+ const permissions = readOpenCode2Permissions(input.env?.OPENCODE_PERMISSION);
24298
+ let session;
24299
+ if (input.sessionId) {
24300
+ session = await client.session.get({ sessionID: input.sessionId }, { signal });
24301
+ await assertOpenCode2Directory(session, location.directory);
24302
+ if ((await client.session.active({ signal }))[session.id]) throw openCode2Error("conversation.busy", "The selected OpenCode session is already running.");
24303
+ if (permissions) await client.session.update({
24304
+ sessionID: session.id,
24305
+ permissions
24306
+ }, { signal });
24307
+ if (model) await client.session.switchModel({
24308
+ sessionID: session.id,
24309
+ model
24310
+ }, { signal });
24311
+ } else session = await client.session.create({
24312
+ location,
24313
+ ...model ? { model } : {},
24314
+ ...permissions ? { permissions } : {}
24315
+ }, { signal });
24316
+ await input.onRuntimeEvent?.({
24317
+ phase: "provider_conversation_observed",
24318
+ agentControllerConversationId: session.id,
24319
+ tsMs: Date.now()
24320
+ });
24321
+ if (input.instructionPrompt) await client.session.instructions.entry.put({
24322
+ sessionID: session.id,
24323
+ key: "openmeld.dispatch",
24324
+ value: input.instructionPrompt.developerInstructions
24325
+ }, { signal });
24326
+ return session;
24327
+ }
24328
+ function permissionEntries(setting) {
24329
+ if (typeof setting === "string") return [["*", setting]];
24330
+ return setting && typeof setting === "object" && !Array.isArray(setting) ? Object.entries(setting) : [];
24331
+ }
24332
+ async function waitForSpaceActionMcp(client, location, name, signal) {
24333
+ const startupSignal = AbortSignal.any([signal, AbortSignal.timeout(3e4)]);
24334
+ while (true) {
24335
+ const status = (await client.mcp.list({ location }, { signal: startupSignal })).data.find((server) => server.name === name)?.status;
24336
+ if (status?.status === "connected") return;
24337
+ if (status && status.status !== "pending") throw openCode2Error("space.action.unavailable", `OpenCode could not start the Space action tools: ${JSON.stringify(status)}`);
24338
+ await setTimeout$1(100, void 0, { signal: startupSignal });
24339
+ }
24340
+ }
24341
+ async function observeEvent(input, state, event, signal) {
24342
+ if (event.type === "session.created" && event.data.parentID && state.sessions.has(event.data.parentID)) state.sessions.add(event.data.sessionID);
24343
+ if (event.type === "form.created") {
24344
+ if (state.sessions.has(event.data.form.sessionID)) await answerOpenCode2Form(input.client, event.data.form, input.onInteractionRequest, signal);
24345
+ return false;
24346
+ }
24347
+ if (!("sessionID" in event.data && state.sessions.has(event.data.sessionID))) return false;
24348
+ if (event.type === "permission.asked") {
24349
+ await answerOpenCode2Permission(input.client, event.data, input.onInteractionRequest, signal);
24350
+ return false;
24351
+ }
24352
+ await observeTool(input, state, event);
24353
+ if (event.data.sessionID !== state.sessionId) return false;
24354
+ if ("assistantMessageID" in event.data && typeof event.data.assistantMessageID === "string") state.assistantMessages.add(event.data.assistantMessageID);
24355
+ return await observeRootEvent(input, state, event);
24356
+ }
24357
+ async function observeTool(input, state, event) {
24358
+ if (event.type === "session.tool.input.started") state.tools.set(event.data.id, event.data.name);
24359
+ if (event.type !== "session.tool.called" && event.type !== "session.tool.success" && event.type !== "session.tool.failed") return;
24360
+ await input.onRuntimeEvent?.({
24361
+ phase: "tool_activity",
24362
+ toolCallId: event.data.id,
24363
+ toolName: resolveAdapterToolActivityName(state.tools.get(event.data.id)),
24364
+ state: {
24365
+ "session.tool.called": "input-available",
24366
+ "session.tool.success": "output-available",
24367
+ "session.tool.failed": "output-error"
24368
+ }[event.type],
24369
+ tsMs: Date.now()
24370
+ });
24371
+ }
24372
+ async function observeRootEvent(input, state, event) {
24373
+ switch (event.type) {
24374
+ case "session.inbox.delivered":
24375
+ state.delivered.add(event.data.inboxID);
24376
+ break;
24377
+ case "session.execution.started":
24378
+ state.started = true;
24379
+ break;
24380
+ case "session.text.delta":
24381
+ state.output += event.data.delta;
24382
+ if (input.streamingMode === "stream" && input.onPreview) {
24383
+ await input.onPreview({ text: state.output });
24384
+ state.previewEmitted = true;
24385
+ }
24386
+ break;
24387
+ case "session.reasoning.delta":
24388
+ await input.onRuntimeEvent?.({
24389
+ phase: "reasoning",
24390
+ blockId: `${event.data.assistantMessageID}:${event.data.ordinal}`,
24391
+ mode: "append",
24392
+ text: event.data.delta,
24393
+ tsMs: Date.now()
24394
+ });
24395
+ break;
24396
+ case "session.execution.succeeded": return state.started;
24397
+ case "session.execution.failed": {
24398
+ if (!state.started) break;
24399
+ const failure = classifyOpenCodeFailureMessage({
24400
+ message: event.data.error.message,
24401
+ isContextLost: () => false,
24402
+ includeOriginalError: true
24403
+ });
24404
+ throw Object.assign(new Error(failure.message), failure);
24405
+ }
24406
+ case "session.execution.interrupted":
24407
+ if (state.started) throw openCode2Error("runtime.interrupted", `OpenCode interrupted the execution: ${event.data.reason}`);
24408
+ break;
24409
+ default: break;
24410
+ }
24411
+ return false;
24412
+ }
24413
+ //#endregion
23807
24414
  //#region ../../runtime/adapters/opencode/dist/transport/opencode-server-transport.js
23808
24415
  const SERVER_HOSTNAME = "127.0.0.1";
24416
+ const OPENCODE_V1_VERSION_RE = /^v?1\./u;
23809
24417
  const SERVER_HEALTH_TIMEOUT_MS = 5e3;
23810
24418
  const SERVER_STARTUP_TIMEOUT_MS = 15e3;
23811
24419
  const SERVER_MAX_START_ATTEMPTS = 2;
@@ -23813,7 +24421,7 @@ const SERVER_SLOW_START_MS = 5e3;
23813
24421
  const SERVER_DIAGNOSTIC_CONNECT_TIMEOUT_MS = 250;
23814
24422
  const SERVER_PROCESS_KILL_GRACE_MS = 1e3;
23815
24423
  const SERVER_PROCESS_CLOSE_TIMEOUT_MS = 2e3;
23816
- const SERVER_READY_LINE_PATTERN = /^opencode server listening on (https?:\/\/[^\s]+)$/;
24424
+ const SERVER_READY_LINE_PATTERN = /^(?:opencode )?server listening on (https?:\/\/[^\s]+)$/;
23817
24425
  var OpenCodeServerTransportError = class extends Error {
23818
24426
  telemetry;
23819
24427
  code;
@@ -23851,26 +24459,45 @@ async function invokeOpenCodeServerTransport(input) {
23851
24459
  const canonicalRepairSessionId = input.executionMode === "repair" || isDispatchSpaceActionDeliveryOnly(input.env) ? normalizeOptionalText$9(input.sessionId) : null;
23852
24460
  let result;
23853
24461
  try {
23854
- const executionSessionId = canonicalRepairSessionId ? await forkOpenCodeSessionWithClient({
23855
- client,
23856
- openCodeWorkdir: input.openCodeWorkdir,
23857
- sourceSessionId: canonicalRepairSessionId
23858
- }) : normalizeOptionalText$9(input.sessionId);
23859
- result = await runOpenCodeServerTurn({
23860
- env: input.env,
23861
- onRuntimeEvent: input.onRuntimeEvent,
23862
- client,
23863
- conversationPolicy: input.conversationPolicy,
23864
- instructionPrompt: input.instructionPrompt,
23865
- observedSessionId: canonicalRepairSessionId,
23866
- onInteractionRequest: input.onInteractionRequest,
23867
- onPreview: input.onPreview,
23868
- openCodeWorkdir: input.openCodeWorkdir,
23869
- prompt,
23870
- server,
23871
- sessionId: executionSessionId,
23872
- streamingMode: input.streamingMode ?? "final"
23873
- });
24462
+ if (server.apiMajor === 2) {
24463
+ if (canonicalRepairSessionId) throw new OpenCodeServerTransportError({
24464
+ code: "delivery_scope.unsupported",
24465
+ errorType: "config",
24466
+ message: "OpenCode 2 reply repair requires an attested restricted tool scope."
24467
+ });
24468
+ const abort = new AbortController();
24469
+ try {
24470
+ result = await Promise.race([runOpenCode2Turn({
24471
+ ...input,
24472
+ client: createOpenCode2Client(serverUrl, server.apiPassword),
24473
+ directory: input.openCodeWorkdir,
24474
+ signal: abort.signal
24475
+ }), server.waitForFailure()]);
24476
+ } finally {
24477
+ abort.abort();
24478
+ }
24479
+ } else {
24480
+ const executionSessionId = canonicalRepairSessionId ? await forkOpenCodeSessionWithClient({
24481
+ client,
24482
+ openCodeWorkdir: input.openCodeWorkdir,
24483
+ sourceSessionId: canonicalRepairSessionId
24484
+ }) : normalizeOptionalText$9(input.sessionId);
24485
+ result = await runOpenCodeServerTurn({
24486
+ env: input.env,
24487
+ onRuntimeEvent: input.onRuntimeEvent,
24488
+ client,
24489
+ conversationPolicy: input.conversationPolicy,
24490
+ instructionPrompt: input.instructionPrompt,
24491
+ observedSessionId: canonicalRepairSessionId,
24492
+ onInteractionRequest: input.onInteractionRequest,
24493
+ onPreview: input.onPreview,
24494
+ openCodeWorkdir: input.openCodeWorkdir,
24495
+ prompt,
24496
+ server,
24497
+ sessionId: executionSessionId,
24498
+ streamingMode: input.streamingMode ?? "final"
24499
+ });
24500
+ }
23874
24501
  } catch (error) {
23875
24502
  const failure = toOpenCodeServerTransportError(error, server.readStderr());
23876
24503
  failure.telemetry = server.buildTelemetry({
@@ -23891,12 +24518,15 @@ async function invokeOpenCodeServerTransport(input) {
23891
24518
  return {
23892
24519
  output: result.output,
23893
24520
  sessionId: canonicalRepairSessionId ?? result.sessionId,
23894
- telemetry: server.buildTelemetry({
23895
- invokedAtMs,
23896
- previewEmitted: result.previewEmitted,
23897
- resumedContext: normalizeOptionalText$9(input.sessionId) !== null,
23898
- streamingMode: input.streamingMode ?? "final"
23899
- })
24521
+ telemetry: {
24522
+ ...server.buildTelemetry({
24523
+ invokedAtMs,
24524
+ previewEmitted: result.previewEmitted,
24525
+ resumedContext: normalizeOptionalText$9(input.sessionId) !== null,
24526
+ streamingMode: input.streamingMode ?? "final"
24527
+ }),
24528
+ ...result.aiUsage ? { aiUsage: result.aiUsage } : {}
24529
+ }
23900
24530
  };
23901
24531
  }
23902
24532
  async function forkOpenCodeServerSession(input) {
@@ -23912,6 +24542,17 @@ async function forkOpenCodeServerSession(input) {
23912
24542
  deadlineMs
23913
24543
  });
23914
24544
  try {
24545
+ if (server.apiMajor === 2) {
24546
+ const client = createOpenCode2Client(serverUrl, server.apiPassword);
24547
+ const options = { signal: AbortSignal.timeout(15e3) };
24548
+ await assertOpenCode2Directory(await client.session.get({ sessionID: sourceSessionId }, options), input.openCodeWorkdir);
24549
+ const fork = await client.session.fork({ sessionID: sourceSessionId }, options);
24550
+ if (input.title) await client.session.update({
24551
+ sessionID: fork.id,
24552
+ title: input.title
24553
+ }, options);
24554
+ return { sessionId: fork.id };
24555
+ }
23915
24556
  const client = createOpencodeClient({
23916
24557
  baseUrl: serverUrl,
23917
24558
  directory: input.openCodeWorkdir,
@@ -23969,6 +24610,23 @@ async function forkOpenCodeSessionWithClient(input) {
23969
24610
  })).sessionId;
23970
24611
  }
23971
24612
  async function startHealthyOpenCodeServer(input) {
24613
+ const pure = isDispatchSpaceActionDeliveryOnly(input.env);
24614
+ if (pure) {
24615
+ const version = await runCliDriver({
24616
+ ...buildCliLaunchInvocation({
24617
+ launchContract: input.launchContract,
24618
+ args: ["--version"]
24619
+ }),
24620
+ cwd: input.openCodeWorkdir,
24621
+ env: input.env,
24622
+ timeoutMs: SERVER_STARTUP_TIMEOUT_MS
24623
+ });
24624
+ if (!OPENCODE_V1_VERSION_RE.test(version.stdoutText.trim())) throw new OpenCodeServerTransportError({
24625
+ code: "delivery_scope.unsupported",
24626
+ errorType: "config",
24627
+ message: "OpenCode reply repair requires the verified OpenCode 1 pure-server contract."
24628
+ });
24629
+ }
23972
24630
  let lastError = null;
23973
24631
  const startupEvidence = [];
23974
24632
  for (let attemptIndex = 0; attemptIndex < SERVER_MAX_START_ATTEMPTS; attemptIndex += 1) {
@@ -23977,6 +24635,7 @@ async function startHealthyOpenCodeServer(input) {
23977
24635
  const startupTimeoutMs = Math.min(remainingTimeoutMs ?? Number.POSITIVE_INFINITY, SERVER_STARTUP_TIMEOUT_MS);
23978
24636
  const attempt = await runOpenCodeServerStartAttempt({
23979
24637
  ...input,
24638
+ pure,
23980
24639
  openCodeTimeoutMs: remainingTimeoutMs,
23981
24640
  startupTimeoutMs
23982
24641
  });
@@ -24025,7 +24684,9 @@ async function runOpenCodeServerStartAttempt(input) {
24025
24684
  });
24026
24685
  }
24027
24686
  try {
24028
- await assertOpenCodeServerHealthy({
24687
+ if (server.apiMajor === 2) {
24688
+ if (!(await createOpenCode2Client(serverUrl, server.apiPassword).server.info({ signal: AbortSignal.timeout(SERVER_HEALTH_TIMEOUT_MS) })).version.startsWith("2.")) throw new Error("OpenCode returned an unsupported server API version.");
24689
+ } else await assertOpenCodeServerHealthy({
24029
24690
  deadlineMs: input.deadlineMs,
24030
24691
  directory: input.openCodeWorkdir,
24031
24692
  serverUrl
@@ -24498,6 +25159,9 @@ function throwInteractionFailure(failure) {
24498
25159
  });
24499
25160
  }
24500
25161
  var OpenCodeServerProcess = class {
25162
+ apiMajor = 1;
25163
+ apiPassword = randomUUID();
25164
+ #pure;
24501
25165
  #aiUsage = /* @__PURE__ */ new Map();
24502
25166
  #env;
24503
25167
  #failure = createDeferred();
@@ -24539,6 +25203,7 @@ var OpenCodeServerProcess = class {
24539
25203
  timeoutTriggeredAtMs: null
24540
25204
  };
24541
25205
  constructor(input) {
25206
+ this.#pure = input.pure === true;
24542
25207
  this.#env = input.env;
24543
25208
  this.#launchContract = input.launchContract;
24544
25209
  this.#onProcessControlEvent = input.onProcessControlEvent;
@@ -24555,11 +25220,9 @@ var OpenCodeServerProcess = class {
24555
25220
  const invocation = buildCliLaunchInvocation({
24556
25221
  args: [
24557
25222
  "serve",
24558
- ...isDispatchSpaceActionDeliveryOnly(this.#env) ? ["--pure"] : [],
25223
+ ...this.#pure ? ["--pure"] : [],
24559
25224
  `--hostname=${SERVER_HOSTNAME}`,
24560
- `--port=${port}`,
24561
- "--print-logs",
24562
- "--log-level=INFO"
25225
+ `--port=${port}`
24563
25226
  ],
24564
25227
  launchContract: this.#launchContract
24565
25228
  });
@@ -24569,7 +25232,8 @@ var OpenCodeServerProcess = class {
24569
25232
  cwd: this.#openCodeWorkdir,
24570
25233
  env: {
24571
25234
  ...process.env,
24572
- ...this.#env ?? {}
25235
+ ...this.#env ?? {},
25236
+ OPENCODE_PASSWORD: this.apiPassword
24573
25237
  },
24574
25238
  shell: invocation.shell ?? false
24575
25239
  });
@@ -24863,6 +25527,7 @@ var OpenCodeServerProcess = class {
24863
25527
  return;
24864
25528
  }
24865
25529
  this.#startupResolve?.(reportedUrl);
25530
+ this.apiMajor = line.startsWith("opencode ") ? 1 : 2;
24866
25531
  this.#readyLineObserved = true;
24867
25532
  this.#startupResolve = null;
24868
25533
  this.#startupReject = null;
@@ -24967,6 +25632,13 @@ function unwrapSdkData(value) {
24967
25632
  return record && "data" in record ? record.data : value;
24968
25633
  }
24969
25634
  function toOpenCodeServerTransportError(error, stderr) {
25635
+ if (!(error instanceof OpenCodeServerTransportError) && error instanceof Error && "code" in error && typeof error.code === "string" && "errorType" in error && typeof error.errorType === "string") return new OpenCodeServerTransportError({
25636
+ ...error,
25637
+ code: error.code,
25638
+ errorType: error.errorType,
25639
+ message: error.message,
25640
+ originalError: createProviderOriginalError(error.message) ?? void 0
25641
+ });
24970
25642
  if (error instanceof Error && toRecord$1(error)?.code === "space.action.delivery_only_unverified") return new OpenCodeServerTransportError({
24971
25643
  code: "space.action.delivery_only_unverified",
24972
25644
  errorType: "config",
@@ -25070,7 +25742,7 @@ async function invokeOpenCodeWithSingleContextHeal(input) {
25070
25742
  }
25071
25743
  async function invokeOpenCodeOnce(input) {
25072
25744
  try {
25073
- if (input.onInteractionRequest || input.sessionId) return await invokeOpenCodeServerTransport({
25745
+ return await invokeOpenCodeServerTransport({
25074
25746
  launchContract: input.launchContract,
25075
25747
  openCodeTimeoutMs: input.openCodeTimeoutMs,
25076
25748
  openCodeWorkdir: input.openCodeWorkdir,
@@ -25086,17 +25758,6 @@ async function invokeOpenCodeOnce(input) {
25086
25758
  sessionId: input.sessionId,
25087
25759
  streamingMode: input.streamingMode
25088
25760
  });
25089
- return await invokeOpenCodeCliTransport({
25090
- launchContract: input.launchContract,
25091
- openCodeTimeoutMs: input.openCodeTimeoutMs,
25092
- openCodeWorkdir: input.openCodeWorkdir,
25093
- conversationPolicy: input.conversationPolicy,
25094
- env: input.env,
25095
- ...input.onProcessControlEvent ? { onProcessControlEvent: input.onProcessControlEvent } : {},
25096
- ...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
25097
- prompt: input.prompt,
25098
- sessionId: input.sessionId
25099
- });
25100
25761
  } catch (error) {
25101
25762
  if (error instanceof OpenCodeRuntimeError) throw error;
25102
25763
  if (error && typeof error === "object" && "code" in error && typeof error.code === "string" && "errorType" in error && typeof error.errorType === "string" && error instanceof Error) throw new OpenCodeRuntimeError({
@@ -30534,9 +31195,9 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
30534
31195
  cancel: true,
30535
31196
  interrupt: true,
30536
31197
  modelSelection: true,
30537
- nativeEventStream: false,
31198
+ nativeEventStream: true,
30538
31199
  permissionModes: true,
30539
- structuredUserInput: false
31200
+ structuredUserInput: true
30540
31201
  },
30541
31202
  conversationOccupancy: {
30542
31203
  contractVersion: 1,
@@ -30571,7 +31232,7 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
30571
31232
  modelSelection: true,
30572
31233
  nativeEventStream: true,
30573
31234
  permissionModes: true,
30574
- structuredUserInput: false
31235
+ structuredUserInput: true
30575
31236
  },
30576
31237
  conversationOccupancy: {
30577
31238
  contractVersion: 1,
@@ -30612,13 +31273,13 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
30612
31273
  adapterId: "cursor",
30613
31274
  agentId: "cursor",
30614
31275
  capabilities: {
30615
- approvals: false,
31276
+ approvals: true,
30616
31277
  cancel: true,
30617
31278
  interrupt: true,
30618
31279
  modelSelection: true,
30619
31280
  nativeEventStream: true,
30620
31281
  permissionModes: true,
30621
- structuredUserInput: false
31282
+ structuredUserInput: true
30622
31283
  },
30623
31284
  conversationOccupancy: {
30624
31285
  contractVersion: 1,
@@ -30678,13 +31339,13 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
30678
31339
  adapterId: "opencode",
30679
31340
  agentId: "opencode",
30680
31341
  capabilities: {
30681
- approvals: false,
31342
+ approvals: true,
30682
31343
  cancel: false,
30683
31344
  interrupt: true,
30684
31345
  modelSelection: true,
30685
- nativeEventStream: false,
30686
- permissionModes: false,
30687
- structuredUserInput: false
31346
+ nativeEventStream: true,
31347
+ permissionModes: true,
31348
+ structuredUserInput: true
30688
31349
  },
30689
31350
  conversationOccupancy: {
30690
31351
  contractVersion: 1,
@@ -32571,9 +33232,9 @@ function createModelCatalogReadSession(input) {
32571
33232
  async function readModelCatalogOnce(baseUrl) {
32572
33233
  try {
32573
33234
  const [apiClient, baseUrlModule, clientFoundationModule] = await Promise.all([
32574
- import("./dist-BDix0nxy.js"),
33235
+ import("./dist-CXB_bdSS.js"),
32575
33236
  import("./base-url-Bdjp-5vy.js"),
32576
- import("./api-client-foundation-DDdQCc2T.js")
33237
+ import("./api-client-foundation-mqLjUunz.js")
32577
33238
  ]);
32578
33239
  if (typeof apiClient.createConfigApi !== "function") throw new Error("config api client is unavailable");
32579
33240
  const resolvedBaseUrl = baseUrl ?? await baseUrlModule.resolveBaseUrl();
@@ -32867,9 +33528,9 @@ function resolveBoundProfileLocalRouteCandidate(input) {
32867
33528
  const agentControllerCollaborationMode = resolveNativeAgentControllerCollaborationModeForController(binding.agentControllerCollaborationMode, { agentControllerRef: agentControllerRef.ref });
32868
33529
  return {
32869
33530
  agentControllerRef: agentControllerRef.ref,
32870
- agentControllerConversationId: normalizeOptionalText$51(executionTarget.agentControllerConversationId),
33531
+ agentControllerConversationId: normalizeOptionalText$49(executionTarget.agentControllerConversationId),
32871
33532
  openMeldServiceRuntimeId: executionTarget.openMeldServiceRuntimeId.value,
32872
- bindingId: normalizeOptionalText$51(binding.bindingId),
33533
+ bindingId: normalizeOptionalText$49(binding.bindingId),
32873
33534
  ...agentControllerCollaborationMode ? { agentControllerCollaborationMode } : {},
32874
33535
  ...agentControllerPermissionMode ? { agentControllerPermissionMode } : {},
32875
33536
  ...binding.modelSelection ? { modelSelection: binding.modelSelection } : {},
@@ -34334,7 +34995,7 @@ const DEFAULT_OPENCLAW_RUNTIME_PREPARATION_DEPS = {
34334
34995
  fetchGatewayHealth: fetchOpenClawGatewayHealth
34335
34996
  };
34336
34997
  async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PREPARATION_DEPS) {
34337
- const profileName = normalizeOptionalText$51(input.profileName);
34998
+ const profileName = normalizeOptionalText$49(input.profileName);
34338
34999
  if (!profileName) throw new DaemonServiceRunError({
34339
35000
  code: "controller.bootstrap.failed",
34340
35001
  message: "controller.bootstrap.failed: OpenClaw bootstrap requires an OpenMeld profile name"
@@ -34397,12 +35058,12 @@ function buildOpenClawGatewayVisibilityFailure(error) {
34397
35058
  }
34398
35059
  function extractErrorCode(error) {
34399
35060
  if (!(error && typeof error === "object" && "code" in error)) return;
34400
- return normalizeOptionalText$51(error.code) ?? void 0;
35061
+ return normalizeOptionalText$49(error.code) ?? void 0;
34401
35062
  }
34402
35063
  function resolveOpenClawGatewayVisibilityDiagnostics(error) {
34403
35064
  if (!(error instanceof Error)) return;
34404
35065
  const diagnostics = error.diagnostics;
34405
- if (!diagnostics || typeof diagnostics !== "object" || !normalizeOptionalText$51(diagnostics.agentId)) return;
35066
+ if (!diagnostics || typeof diagnostics !== "object" || !normalizeOptionalText$49(diagnostics.agentId)) return;
34406
35067
  const parsedGatewayVisibility = openMeldDaemonTaskResultOpenClawGatewayVisibilityStatusSchema.safeParse(diagnostics.gatewayVisibility);
34407
35068
  if (!parsedGatewayVisibility.success) return;
34408
35069
  return {
@@ -34429,6 +35090,6 @@ async function prepareProviderRuntime(input, options = {}) {
34429
35090
  return await preparer(input);
34430
35091
  }
34431
35092
  //#endregion
34432
- export { canManageRegistryAgentSkillTargets as $, resolveExecutablePathsOnPath as $n, mergeOpenClawGatewayVisibility as $t, createExpectedRoutesReadSession as A, emitReconcileCompletedEvidence as An, resolveNativeAgentControllerPermissionModeForController as Ar, ensureOpenMeldManagedProfileWorkspace as At, reconcileNewRunnableBuiltinAgentsForSetup as B, resolveConversationExecutionStateByLookupKey as Bn, resolveCatalogSyncIntervalMs as Br, createMutableRouteCatalogState as Bt, createModelCatalogReadSession as C, probeCodexAppServerAccount as Cn, renderInformationProtectionPrompt as Cr, resolveLocalProjectConnectionForPath as Ct, NO_LOCAL_AGENTS_NEED_OPENMELD_SERVICE_REASON as D, probeClaudeCodeUsageLimits as Dn, resolveAgentExecutionStatus as Dr, resolveRegistryOriginLaunchCommand as Dt, resolveProfileWorkspaceRuntime as E, projectCodexUsageLimits as En, resolveAgentControllerPermissionModeForController as Er, listBuiltinAgentsRegistryEntries as Et, listAgentRegistrations as F, buildTaskResultEnvelope as Fn, MIN_HEARTBEAT_INTERVAL_MS as Fr, resolveConfiguredProfileWorkspacePathForAccount as Ft, updateAgentRegistrations as G, buildAuthenticatedControlPlaneResponse as Gn, syncRuntimeEventToInflightTaskControlRegistry as Gt, resolveAgentTargetState as H, settleInflightTask as Hn, resolveBuiltinAgentControllerBrand as Hr, summarizeSkippedDaemonProfiles as Ht, listAgentTargetStates as I, appendLedgerHistoryEntry as In, applyAcceptedLeases as Ir, setCustomProfileWorkspace as It, normalizeAgentIds as J, createUnavailableProviderUsageLimits as Jn, isDaemonReconcileInProgressError as Jt, notifyDaemonRouteCatalogChanged as K, assertLegacyAgentContextAssociation as Kn, SPACE_ACTION_CONTEXT_GUIDANCE_LINES as Kt, manageAgentRegistrationInstallation as L, commitResolvedAgentContext as Ln, applyIntervalJitterMs as Lr, setOpenMeldManagedProfileWorkspace as Lt, addAgentCustomTarget as M, DaemonServiceRunError as Mn, resolveRouteRegistrationReconcileDecision as Mr, readProfileWorkspaceConfig as Mt, createRegistrationFromCatalogTarget as N, runRuntimeTask as Nn, ADAPTIVE_HEARTBEAT_JITTER_RATIO as Nr, readProfileWorkspaceConfigForAccount as Nt, syncDeviceRuntimeStateProjection as O, resolveInstalledClaudeCodeLaunchCandidates as On, resolveAgentProfileEditCapabilities as Or, resolveRegistryRuntimeAdapterCapabilitySnapshot as Ot, listAgentCustomTargets as P, buildRuntimeWorkspaceFingerprint as Pn, MAX_HEARTBEAT_INTERVAL_MS as Pr, resolveConfiguredProfileWorkspacePath as Pt, resolveLocalRegistryAgentIdFromAgentControllerRef as Q, materializeCliLaunchCommand as Qn, createPendingAgentInteractionRegistry as Qt, readAgentRuntimeConfigHealth as R, loadLedgerState as Rn, pruneStaleLeases as Rr, validateCustomProfileWorkspacePath as Rt, syncProfileWorkspaceState as S, forkCodexAppServerThread as Sn, projectPeopleComputersToLegacyLocalRuntimes as Sr, canonicalizeLocalProjectPath as St, resolveEffectiveProfileWorkingFolderRuntime as T, verifyCodexAppServerThread as Tn, renderWorkingLanguagePrompt as Tr, withAgentActivityLocalStateLock as Tt, setAgentRegistrationEnabled as U, upsertConversationExecutionState as Un, __toESM as Ur, syncDaemonRouteCatalogState as Ut, removeAgentCustomTarget as V, seedLegacyAgentContext as Vn, compareAgentControllerRefsForDisplay as Vr, createRouteCatalogFromMutableState as Vt, updateAgentCustomTarget as W, withLedgerStateTransaction as Wn, normalizeDispatchThreadAction as Wt, sortAgentRegistrations as X, resolveDispatchSpaceActionMcpServer as Xn, buildDispatchReplyContextSummary as Xt, parseAgentEnabledOption as Y, createUnsupportedProviderUsageLimits as Yn, createSerialAgentInteractionCallback as Yt, repairBuiltinControllerInstall as Z, buildCliLaunchInvocation as Zn, normalizeDispatchPostMessageAction as Zt, loadDaemonRouteCatalog as _, probeGrokBuildAcpInterface as _n, isAgentControllerUsageRefreshUnavailable as _r, removeProjectConnection as _t, buildOpenClawSpaceSessionKey as a, resolveDispatchContinuityObservation as an, TASK_KNOWLEDGE_GUIDANCE as ar, isHomebrewCommandPath as at, resolveLocalController as b, resolveCodexTimeoutMs as bn, parseAgentControllerRef as br, setDefaultProjectConnection as bt, findOpenClawAgentById as c, resolveLatestScopedConversationExecutionState as cn, buildInformationProtectionPromptPlan as cr, ProjectBindingOperationError as ct, resolveOpenClawAuthStatus as d, createLocalAdapterEntries as dn, createAgentControllerInterfaceDisplayRows as dr, isProjectBound as dt, createLocalTaskInterruptSender as en, listAgentControllerSupervisedProcessIds as er, detectInstalledSkillsAgents as et, resolveOpenClawProviderRuntimeWorkingDirectory as f, parseOpenRouterUsageResponse as fn, createAgentExecutionStatusDisplayRows as fr, listProjectBindings as ft, writeDaemonRouteCatalogCache as g, GrokBuildAcpTransportError as gn, isAgentControllerUsageAccountUnavailable as gr, removeMissingProjectConnections as gt, readDaemonRouteCatalogCache as h, resolveInstalledOpenCodeLaunchCandidates as hn, getAgentControllerPermissionModeFieldLabel as hr, removeAgentActivityBindingsWhileDeliveryLocked as ht, listOpenClawGatewayAgents as i, resolveDispatchQueueLogMeta as in, DEFAULT_TASK_LIFECYCLE_HEARTBEAT_INTERVAL_MS as ir, isBunGlobalCommandPath as it, resolveAgentProfilePrimaryAgentControllerReport as j, emitReconcileStartedEvidence as jn, resolveSelectableCandidates as jr, normalizeCustomProfileWorkspacePath as jt, createPrimaryBindingReadSession as k, emitDriftDetectedEvidence as kn, resolveEvidenceSyncHealth as kr, resolveRegistryRuntimeAdapterContractByAgentControllerRef as kt, findOpenClawAgentsByWorkspace as l, resolveCatalogSyncSkippedProfilesLogState as ln, buildWorkingLanguagePromptPlan as lr, ProjectBindingStoreUpdateRequiredError as lt, resolveOpenClawLocalBootstrapPaths as m, forkOpenCodeServerSession as mn, getAgentControllerPermissionModeDisplayMetadata as mr, migrateProjectBindingStore as mt, fetchOpenClawGatewayHealth as n, createLocalExecutionSlots as nn, DISPATCH_SPACE_ACTION_DELIVERY_ONLY_ENV as nr, EMPTY_AGENT_CONTROLLER_INTERFACE_CAPABILITIES as nt, normalizeOpenClawSpaceIdPrefix as o, resolveCompatibleAgentContextMatch as on, areAgentControllerInterfaceAccountsSame as or, isNpmGlobalCommandPath as ot, readOpenClawLocalBootstrapState as p, parseOpenCodeGoUsageResponse as pn, createAuthorityOpenMeldServiceRuntimeId as pr, listProjectConnectionsWithStatus as pt, normalizeAgentId as q, buildAgentContextLookupKey as qn, SPACE_ACTION_TARGET_GUIDANCE_LINES as qt, listOpenClawAgents as r, createInflightTaskControlRegistry as rn, isDispatchSpaceActionDeliveryOnly as rr, resolveBuiltinAgentControllerDefinition as rt, slugifyOpenClawNamePart as s, resolveCompatibleConversationExecutionState as sn, buildAgentControllerRef as sr, isPnpmGlobalCommandPath as st, prepareProviderRuntime as t, buildLocalServiceDiagnosticsPayload as tn, createProviderOriginalError as tr, resolveSkillsAgentRegistry as tt, matchesExpectedWorkspace as u, createLocalAdapterContainer as un, compareAgentControllerVersions as ur, bindProject as ut, buildRuntimeRouteTargets as v, resolveInstalledGrokBuildLaunchCandidates as vn, isAgentExecutionReadyOrConnecting as vr, resolveProjectBindingForPath as vt, resolveCurrentEffectiveProfileWorkingFolderRuntime as w, resolveCodexAppServerCompletedTurn as wn, renderTaskKnowledgeIndex as wr, withAgentActivityDeliveryLock as wt, resolveLocalRuntimeControllerSupport as x, resolveInstalledCodexLaunchCandidates as xn, peopleComputerContainsDevice as xr, unbindProject as xt, readLocalEnabledControllers as y, projectCursorUsageLimits as yn, listAgentControllerPermissionModeOptions as yr, runIfAgentActivityBindingGenerationIsCurrent as yt, reconcileNewRunnableBuiltinAgentRegistrations as z, removeConversationExecutionState as zn, resolveAdaptiveHeartbeatIntervalMs as zr, describeProfileWorkspacePathValidationFailure as zt };
35093
+ export { canManageRegistryAgentSkillTargets as $, resolveDispatchSpaceActionMcpServer as $n, mergeOpenClawGatewayVisibility as $t, createExpectedRoutesReadSession as A, isAntigravityAcpLaunchContract as An, resolveAgentExecutionStatus as Ar, ensureOpenMeldManagedProfileWorkspace as At, reconcileNewRunnableBuiltinAgentsForSetup as B, commitResolvedAgentContext as Bn, applyIntervalJitterMs as Br, createMutableRouteCatalogState as Bt, createModelCatalogReadSession as C, forkCodexAppServerThread as Cn, parseAgentControllerRef as Cr, resolveLocalProjectConnectionForPath as Ct, NO_LOCAL_AGENTS_NEED_OPENMELD_SERVICE_REASON as D, projectCodexUsageLimits as Dn, renderTaskKnowledgeIndex as Dr, resolveRegistryOriginLaunchCommand as Dt, resolveProfileWorkspaceRuntime as E, verifyCodexAppServerThread as En, renderInformationProtectionPrompt as Er, listBuiltinAgentsRegistryEntries as Et, listAgentRegistrations as F, DaemonServiceRunError as Fn, resolveRouteRegistrationReconcileDecision as Fr, resolveConfiguredProfileWorkspacePathForAccount as Ft, updateAgentRegistrations as G, settleInflightTask as Gn, resolveBuiltinAgentControllerBrand as Gr, syncRuntimeEventToInflightTaskControlRegistry as Gt, resolveAgentTargetState as H, removeConversationExecutionState as Hn, resolveAdaptiveHeartbeatIntervalMs as Hr, summarizeSkippedDaemonProfiles as Ht, listAgentTargetStates as I, runRuntimeTask as In, ADAPTIVE_HEARTBEAT_JITTER_RATIO as Ir, setCustomProfileWorkspace as It, normalizeAgentIds as J, buildAuthenticatedControlPlaneResponse as Jn, isDaemonReconcileInProgressError as Jt, notifyDaemonRouteCatalogChanged as K, upsertConversationExecutionState as Kn, __toESM as Kr, SPACE_ACTION_CONTEXT_GUIDANCE_LINES as Kt, manageAgentRegistrationInstallation as L, buildRuntimeWorkspaceFingerprint as Ln, MAX_HEARTBEAT_INTERVAL_MS as Lr, setOpenMeldManagedProfileWorkspace as Lt, addAgentCustomTarget as M, emitDriftDetectedEvidence as Mn, resolveEvidenceSyncHealth as Mr, readProfileWorkspaceConfig as Mt, createRegistrationFromCatalogTarget as N, emitReconcileCompletedEvidence as Nn, resolveNativeAgentControllerPermissionModeForController as Nr, readProfileWorkspaceConfigForAccount as Nt, syncDeviceRuntimeStateProjection as O, probeClaudeCodeUsageLimits as On, renderWorkingLanguagePrompt as Or, resolveRegistryRuntimeAdapterCapabilitySnapshot as Ot, listAgentCustomTargets as P, emitReconcileStartedEvidence as Pn, resolveSelectableCandidates as Pr, resolveConfiguredProfileWorkspacePath as Pt, resolveLocalRegistryAgentIdFromAgentControllerRef as Q, createUnsupportedProviderUsageLimits as Qn, createPendingAgentInteractionRegistry as Qt, readAgentRuntimeConfigHealth as R, buildTaskResultEnvelope as Rn, MIN_HEARTBEAT_INTERVAL_MS as Rr, validateCustomProfileWorkspacePath as Rt, syncProfileWorkspaceState as S, resolveInstalledCodexLaunchCandidates as Sn, listAgentControllerPermissionModeOptions as Sr, canonicalizeLocalProjectPath as St, resolveEffectiveProfileWorkingFolderRuntime as T, resolveCodexAppServerCompletedTurn as Tn, projectPeopleComputersToLegacyLocalRuntimes as Tr, withAgentActivityLocalStateLock as Tt, setAgentRegistrationEnabled as U, resolveConversationExecutionStateByLookupKey as Un, resolveCatalogSyncIntervalMs as Ur, syncDaemonRouteCatalogState as Ut, removeAgentCustomTarget as V, loadLedgerState as Vn, pruneStaleLeases as Vr, createRouteCatalogFromMutableState as Vt, updateAgentCustomTarget as W, seedLegacyAgentContext as Wn, compareAgentControllerRefsForDisplay as Wr, normalizeDispatchThreadAction as Wt, sortAgentRegistrations as X, buildAgentContextLookupKey as Xn, buildDispatchReplyContextSummary as Xt, parseAgentEnabledOption as Y, assertLegacyAgentContextAssociation as Yn, createSerialAgentInteractionCallback as Yt, repairBuiltinControllerInstall as Z, createUnavailableProviderUsageLimits as Zn, normalizeDispatchPostMessageAction as Zt, loadDaemonRouteCatalog as _, GrokBuildAcpTransportError as _n, getAgentControllerPermissionModeDisplayMetadata as _r, removeProjectConnection as _t, buildOpenClawSpaceSessionKey as a, resolveDispatchContinuityObservation as an, DISPATCH_SPACE_ACTION_DELIVERY_ONLY_ENV as ar, isHomebrewCommandPath as at, resolveLocalController as b, projectCursorUsageLimits as bn, isAgentControllerUsageRefreshUnavailable as br, setDefaultProjectConnection as bt, findOpenClawAgentById as c, resolveLatestScopedConversationExecutionState as cn, TASK_KNOWLEDGE_GUIDANCE as cr, ProjectBindingOperationError as ct, resolveOpenClawAuthStatus as d, createLocalAdapterEntries as dn, buildInformationProtectionPromptPlan as dr, isProjectBound as dt, createLocalTaskInterruptSender as en, buildCliLaunchInvocation as er, detectInstalledSkillsAgents as et, resolveOpenClawProviderRuntimeWorkingDirectory as f, parseOpenRouterUsageResponse as fn, buildWorkingLanguagePromptPlan as fr, listProjectBindings as ft, writeDaemonRouteCatalogCache as g, resolveInstalledOpenCodeLaunchCandidates as gn, createAuthorityOpenMeldServiceRuntimeId as gr, removeMissingProjectConnections as gt, readDaemonRouteCatalogCache as h, readOpenCode2Inventory as hn, createAgentExecutionStatusDisplayRows as hr, removeAgentActivityBindingsWhileDeliveryLocked as ht, listOpenClawGatewayAgents as i, resolveDispatchQueueLogMeta as in, createProviderOriginalError as ir, isBunGlobalCommandPath as it, resolveAgentProfilePrimaryAgentControllerReport as j, probeAntigravityAcp as jn, resolveAgentProfileEditCapabilities as jr, normalizeCustomProfileWorkspacePath as jt, createPrimaryBindingReadSession as k, resolveInstalledClaudeCodeLaunchCandidates as kn, resolveAgentControllerPermissionModeForController as kr, resolveRegistryRuntimeAdapterContractByAgentControllerRef as kt, findOpenClawAgentsByWorkspace as l, resolveCatalogSyncSkippedProfilesLogState as ln, areAgentControllerInterfaceAccountsSame as lr, ProjectBindingStoreUpdateRequiredError as lt, resolveOpenClawLocalBootstrapPaths as m, forkOpenCodeServerSession as mn, createAgentControllerInterfaceDisplayRows as mr, migrateProjectBindingStore as mt, fetchOpenClawGatewayHealth as n, createLocalExecutionSlots as nn, resolveExecutablePathsOnPath as nr, EMPTY_AGENT_CONTROLLER_INTERFACE_CAPABILITIES as nt, normalizeOpenClawSpaceIdPrefix as o, resolveCompatibleAgentContextMatch as on, isDispatchSpaceActionDeliveryOnly as or, isNpmGlobalCommandPath as ot, readOpenClawLocalBootstrapState as p, parseOpenCodeGoUsageResponse as pn, compareAgentControllerVersions as pr, listProjectConnectionsWithStatus as pt, normalizeAgentId as q, withLedgerStateTransaction as qn, SPACE_ACTION_TARGET_GUIDANCE_LINES as qt, listOpenClawAgents as r, createInflightTaskControlRegistry as rn, listAgentControllerSupervisedProcessIds as rr, resolveBuiltinAgentControllerDefinition as rt, slugifyOpenClawNamePart as s, resolveCompatibleConversationExecutionState as sn, DEFAULT_TASK_LIFECYCLE_HEARTBEAT_INTERVAL_MS as sr, isPnpmGlobalCommandPath as st, prepareProviderRuntime as t, buildLocalServiceDiagnosticsPayload as tn, materializeCliLaunchCommand as tr, resolveSkillsAgentRegistry as tt, matchesExpectedWorkspace as u, createLocalAdapterContainer as un, buildAgentControllerRef as ur, bindProject as ut, buildRuntimeRouteTargets as v, probeGrokBuildAcpInterface as vn, getAgentControllerPermissionModeFieldLabel as vr, resolveProjectBindingForPath as vt, resolveCurrentEffectiveProfileWorkingFolderRuntime as w, probeCodexAppServerAccount as wn, peopleComputerContainsDevice as wr, withAgentActivityDeliveryLock as wt, resolveLocalRuntimeControllerSupport as x, resolveCodexTimeoutMs as xn, isAgentExecutionReadyOrConnecting as xr, unbindProject as xt, readLocalEnabledControllers as y, resolveInstalledGrokBuildLaunchCandidates as yn, isAgentControllerUsageAccountUnavailable as yr, runIfAgentActivityBindingGenerationIsCurrent as yt, reconcileNewRunnableBuiltinAgentRegistrations as z, appendLedgerHistoryEntry as zn, applyAcceptedLeases as zr, describeProfileWorkspacePathValidationFailure as zt };
34433
35094
 
34434
- //# sourceMappingURL=prepare-provider-runtime-Cko0dLXN.js.map
35095
+ //# sourceMappingURL=prepare-provider-runtime-B6_dfpiZ.js.map