openmeld 0.3.243 → 0.3.246
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{add-me-membership-FVD0x_9l.js → add-me-membership-C7dYkfPz.js} +2 -2
- package/dist/{add-me-membership-FVD0x_9l.js.map → add-me-membership-C7dYkfPz.js.map} +1 -1
- package/dist/{agents-Cfx3N1rf.js → agents-QisYIlFS.js} +10 -10
- package/dist/{agents-Cfx3N1rf.js.map → agents-QisYIlFS.js.map} +1 -1
- package/dist/{api-client-foundation-DjzQysm8.js → api-client-foundation-B1aTRrIy.js} +1 -1
- package/dist/{api-client-foundation-CytD8TbL.js → api-client-foundation-CYbEdm9o.js} +3 -3
- package/dist/{api-client-foundation-CytD8TbL.js.map → api-client-foundation-CYbEdm9o.js.map} +1 -1
- package/dist/auth-session-DUYOBXO3.js +4 -0
- package/dist/{auth-session-Injt39gv.js → auth-session-JhILeJRO.js} +3 -3
- package/dist/{auth-session-Injt39gv.js.map → auth-session-JhILeJRO.js.map} +1 -1
- package/dist/{channel-UCuauH8X.js → channel-C6tm9T7P.js} +4 -4
- package/dist/{channel-UCuauH8X.js.map → channel-C6tm9T7P.js.map} +1 -1
- package/dist/{cli-binary-manifest-ETxqCzfS.js → cli-binary-manifest-ChuzORh3.js} +2 -2
- package/dist/{cli-binary-manifest-ETxqCzfS.js.map → cli-binary-manifest-ChuzORh3.js.map} +1 -1
- package/dist/{cloud-computer-Tm9YAbeL.js → cloud-computer-J2tdcTPm.js} +4 -4
- package/dist/{cloud-computer-Tm9YAbeL.js.map → cloud-computer-J2tdcTPm.js.map} +1 -1
- package/dist/{command-DSAT4Dvl.js → command-BXJ-OwBD.js} +18 -18
- package/dist/{command-DSAT4Dvl.js.map → command-BXJ-OwBD.js.map} +1 -1
- package/dist/{computer-connection-CSa8O0op.js → computer-connection-BKtrn0d2.js} +2 -2
- package/dist/{computer-connection-CSa8O0op.js.map → computer-connection-BKtrn0d2.js.map} +1 -1
- package/dist/{computer-connection-review-pWI1btuC.js → computer-connection-review-bUqNKi6q.js} +5 -5
- package/dist/{computer-connection-review-pWI1btuC.js.map → computer-connection-review-bUqNKi6q.js.map} +1 -1
- package/dist/{computer-disconnect-Cahboj3J.js → computer-disconnect-D_Apsn9P.js} +7 -7
- package/dist/{computer-disconnect-Cahboj3J.js.map → computer-disconnect-D_Apsn9P.js.map} +1 -1
- package/dist/{computer-setup-continuation-DmKqN6Kf.js → computer-setup-continuation-occq0LmS.js} +3 -3
- package/dist/{computer-setup-continuation-DmKqN6Kf.js.map → computer-setup-continuation-occq0LmS.js.map} +1 -1
- package/dist/{context--QS-5kJ8.js → context-M7dvalCp.js} +4 -4
- package/dist/{context--QS-5kJ8.js.map → context-M7dvalCp.js.map} +1 -1
- package/dist/{control-plane-QqGL-jtT.js → control-plane-B93wmVS6.js} +2 -2
- package/dist/{control-plane-QqGL-jtT.js.map → control-plane-B93wmVS6.js.map} +1 -1
- package/dist/{daemon-device-id-Bo1QzbXB.js → daemon-device-id-C3gKch4E.js} +4 -4
- package/dist/{daemon-device-id-Bo1QzbXB.js.map → daemon-device-id-C3gKch4E.js.map} +1 -1
- package/dist/{daemon-lifecycle-journal-DFZyoyx9.js → daemon-lifecycle-journal-CGUuJshv.js} +7 -6
- package/dist/{daemon-lifecycle-journal-DFZyoyx9.js.map → daemon-lifecycle-journal-CGUuJshv.js.map} +1 -1
- package/dist/{daemon-service-runtime-Cn8K1WAb.js → daemon-service-runtime-CktU3ER4.js} +4 -4
- package/dist/{daemon-service-runtime-Cn8K1WAb.js.map → daemon-service-runtime-CktU3ER4.js.map} +1 -1
- package/dist/{daemon-service-update-coordinator-Bk4reE6J.js → daemon-service-update-coordinator-D0-15tZW.js} +13 -13
- package/dist/{daemon-service-update-coordinator-Bk4reE6J.js.map → daemon-service-update-coordinator-D0-15tZW.js.map} +1 -1
- package/dist/{dispatch-owned-runtime-CAgSp4Sk.js → dispatch-owned-runtime-gOluDX5_.js} +31 -22
- package/dist/dispatch-owned-runtime-gOluDX5_.js.map +1 -0
- package/dist/{dist-CfvQIuzK.js → dist-DMlKqjUf.js} +1 -1
- package/dist/{dist-D2adiC2P.js → dist-KibLweLD.js} +307 -199
- package/dist/dist-KibLweLD.js.map +1 -0
- package/dist/{dual-view-guide-catalog-D7DcI-F8.js → dual-view-guide-catalog-0kSizTFt.js} +4 -4
- package/dist/{dual-view-guide-catalog-D7DcI-F8.js.map → dual-view-guide-catalog-0kSizTFt.js.map} +1 -1
- package/dist/{elapsed-time-BvqrpioR.js → elapsed-time-Bo1CJczC.js} +4 -4
- package/dist/{elapsed-time-BvqrpioR.js.map → elapsed-time-Bo1CJczC.js.map} +1 -1
- package/dist/{entry-BSMXdz-n.js → entry-B11DkH2I.js} +7 -7
- package/dist/{entry-BSMXdz-n.js.map → entry-B11DkH2I.js.map} +1 -1
- package/dist/{installation-inventory-CUB5QFBF.js → installation-inventory-BZgQmVup.js} +3 -3
- package/dist/{installation-inventory-CUB5QFBF.js.map → installation-inventory-BZgQmVup.js.map} +1 -1
- package/dist/{installer-DslRR89F.js → installer-k2gOOs58.js} +2 -2
- package/dist/{installer-DslRR89F.js.map → installer-k2gOOs58.js.map} +1 -1
- package/dist/{local-components-DJiMS67S.js → local-components-jXECvlEY.js} +3 -2
- package/dist/local-components-jXECvlEY.js.map +1 -0
- package/dist/{meta-api-DcbI4Cjm.js → meta-api-DruuiAx-.js} +5 -5
- package/dist/{meta-api-DcbI4Cjm.js.map → meta-api-DruuiAx-.js.map} +1 -1
- package/dist/{openmeld-CpdXY6Fv.js → openmeld-DUdN78WD.js} +61 -40
- package/dist/{openmeld-CpdXY6Fv.js.map → openmeld-DUdN78WD.js.map} +1 -1
- package/dist/{openmeld-maintenance-worker-CJqQfm0t.js → openmeld-maintenance-worker-DwkvZD0q.js} +9 -9
- package/dist/{openmeld-maintenance-worker-CJqQfm0t.js.map → openmeld-maintenance-worker-DwkvZD0q.js.map} +1 -1
- package/dist/{openmeld-tools-update-join-C8NHNJPy.js → openmeld-tools-update-join-BNUIw_Lo.js} +4 -4
- package/dist/{openmeld-tools-update-join-C8NHNJPy.js.map → openmeld-tools-update-join-BNUIw_Lo.js.map} +1 -1
- package/dist/{openmeld-tools-update-process-frame-YLOS82E3.js → openmeld-tools-update-process-frame-BtYOlJXu.js} +2 -2
- package/dist/{openmeld-tools-update-process-frame-YLOS82E3.js.map → openmeld-tools-update-process-frame-BtYOlJXu.js.map} +1 -1
- package/dist/{openmeld-tools-update-process-frame-Csy2XKUf.js → openmeld-tools-update-process-frame-CINV6Qt3.js} +1 -1
- package/dist/openmeld.js +5 -5
- package/dist/{prepare-provider-runtime-CDs1nV-P.js → prepare-provider-runtime-_XRIioDp.js} +1615 -1006
- package/dist/prepare-provider-runtime-_XRIioDp.js.map +1 -0
- package/dist/{prepare-session-executor-BLPG3mLl.js → prepare-session-executor-B5AjN0qz.js} +19 -19
- package/dist/{prepare-session-executor-BLPG3mLl.js.map → prepare-session-executor-B5AjN0qz.js.map} +1 -1
- package/dist/{process-channel-DyKbHNH7.js → process-channel-CTXWjlBP.js} +2 -2
- package/dist/{process-channel-DyKbHNH7.js.map → process-channel-CTXWjlBP.js.map} +1 -1
- package/dist/{runtime-CMxGDQR2.js → runtime-DCBc6YOq.js} +17 -17
- package/dist/{runtime-CMxGDQR2.js.map → runtime-DCBc6YOq.js.map} +1 -1
- package/dist/{runtime-agent-controller-reporting-submission-DVZfWBM7.js → runtime-agent-controller-reporting-submission-CGa3GGL6.js} +80 -19
- package/dist/runtime-agent-controller-reporting-submission-CGa3GGL6.js.map +1 -0
- package/dist/{runtime-transport-BPK70mkB.js → runtime-transport-BzCp9hM3.js} +3671 -3664
- package/dist/runtime-transport-BzCp9hM3.js.map +1 -0
- package/dist/{service-DzRwreWp.js → service-BEH6-P8U.js} +22 -22
- package/dist/{service-DzRwreWp.js.map → service-BEH6-P8U.js.map} +1 -1
- package/dist/{service-account-authorization-C6wZHidB.js → service-account-authorization-CtvSn02O.js} +2 -2
- package/dist/{service-account-authorization-C6wZHidB.js.map → service-account-authorization-CtvSn02O.js.map} +1 -1
- package/dist/{service-account-control-rYk3uHAE.js → service-account-control-BUPiFEGo.js} +9 -9
- package/dist/{service-account-control-rYk3uHAE.js.map → service-account-control-BUPiFEGo.js.map} +1 -1
- package/dist/{service-control-capabilities-BpqpJM9N.js → service-control-capabilities-D-Nhqqgo.js} +1 -1
- package/dist/{service-control-capabilities-JqmrqJGu.js → service-control-capabilities-PMvSlaJj.js} +3 -3
- package/dist/{service-control-capabilities-JqmrqJGu.js.map → service-control-capabilities-PMvSlaJj.js.map} +1 -1
- package/dist/{state-C-Esm899.js → state-C_iJAzKh.js} +2 -2
- package/dist/{state-C-Esm899.js.map → state-C_iJAzKh.js.map} +1 -1
- package/dist/{updates-api-DWLii54q.js → updates-api-s2-QB929.js} +69 -41
- package/dist/updates-api-s2-QB929.js.map +1 -0
- package/dist/upgrade-Dikfgr8z.js +4 -0
- package/dist/{upgrade-gwIwzrdg.js → upgrade-JmhCNmvs.js} +9 -9
- package/dist/{upgrade-gwIwzrdg.js.map → upgrade-JmhCNmvs.js.map} +1 -1
- package/package.json +13 -12
- package/skills/openmeld-cli/SKILL.md +3 -2
- package/skills/openmeld-cli/references/commands.md +20 -0
- package/dist/auth-session-j1EhJkpg.js +0 -4
- package/dist/dispatch-owned-runtime-CAgSp4Sk.js.map +0 -1
- package/dist/dist-D2adiC2P.js.map +0 -1
- package/dist/local-components-DJiMS67S.js.map +0 -1
- package/dist/prepare-provider-runtime-CDs1nV-P.js.map +0 -1
- package/dist/runtime-agent-controller-reporting-submission-DVZfWBM7.js.map +0 -1
- package/dist/runtime-transport-BPK70mkB.js.map +0 -1
- package/dist/updates-api-DWLii54q.js.map +0 -1
- package/dist/upgrade-Dw6-zvES.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 {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { G as isOriginalErrorSafeForMessageDetails, Gn as agentInteractionResolutionSchema, J as openMeldDaemonProviderAccessEvidenceSchema, W as OPENMELD_ORIGINAL_ERROR_MAX_LENGTH, X as openMeldDaemonTaskResultOpenClawGatewayVisibilityStatusSchema, Xr as resolveCommandAgentWorkActivity, Y as openMeldDaemonTaskResultEnvelopeWriteSchema, t as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, tt as aiUsageObservationSchema, wn as normalizeMessageEnvelope, xn as formatCanonicalMentionLiteral } from "./runtime-transport-BzCp9hM3.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 { Ii as modelCatalogSchema, Rt as createAgentProfileBindingApi, en as createLocalRuntimeExpectedRoutesApi, t as OpenMeldApiClientHttpError } from "./dist-KibLweLD.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-
|
|
8
|
+
import { J as OPENCLAW_CLI_TIMEOUT_MS$1, d as getAuthSessionState } from "./auth-session-JhILeJRO.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$
|
|
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-C3gKch4E.js";
|
|
11
11
|
import { n as agentControllerPermissionModeSchema, r as agentControllerCollaborationModeSchema } from "./open-code-permission-DHFJYc_o.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
|
|
16
|
+
import { F as resolveCurrentOpenMeldAccountContext, _ as touchDaemonCatalogSyncSignal, d as listOpenMeldProfiles } from "./context-M7dvalCp.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-
|
|
19
|
+
import { d as buildOpenMeldRequestContextFromProfile, t as createCliApiClientFoundation } from "./api-client-foundation-CYbEdm9o.js";
|
|
20
20
|
import { i as readDaemonServiceContract } from "./daemon-service-contract-COPKbCy_.js";
|
|
21
|
-
import { C as requestLocalSyncRouteCatalog } from "./daemon-lifecycle-journal-
|
|
21
|
+
import { C as requestLocalSyncRouteCatalog } from "./daemon-lifecycle-journal-CGUuJshv.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;
|
|
@@ -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$
|
|
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$
|
|
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$
|
|
4919
|
-
const TEMP_DIR = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
5136
|
+
const preferredCommandPath = normalizeOptionalText$47(input.preferredCommandPath);
|
|
5136
5137
|
const preferredCommandPaths = preferredCommandPath && isAbsolute(preferredCommandPath) ? [preferredCommandPath] : [];
|
|
5137
|
-
const configuredCommand = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
5202
|
-
const pnpmHome = normalizeOptionalText$
|
|
5203
|
-
const bunHome = normalizeOptionalText$
|
|
5204
|
-
const voltaHome = normalizeOptionalText$
|
|
5205
|
-
const asdfHome = normalizeOptionalText$
|
|
5206
|
-
const fnmHome = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
5231
|
+
const normalizedCommandName = normalizeOptionalText$47(commandName);
|
|
5231
5232
|
if (!(normalizedCommandName && process.platform !== "win32")) return [];
|
|
5232
|
-
const shell = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
5319
|
+
return normalizeOptionalText$47(process.env.HOME) ?? homedir();
|
|
5319
5320
|
}
|
|
5320
5321
|
function resolveLoginShellLookupTimeoutMs() {
|
|
5321
|
-
const raw = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
6174
|
+
const updateType = normalizeOptionalText$45(update?.sessionUpdate);
|
|
6174
6175
|
if (!(update && (updateType === "tool_call" || updateType === "tool_call_update"))) return null;
|
|
6175
|
-
const toolCallId = normalizeOptionalText$
|
|
6176
|
+
const toolCallId = normalizeOptionalText$45(update.toolCallId ?? update.tool_call_id);
|
|
6176
6177
|
if (!toolCallId) return null;
|
|
6177
|
-
const sessionId = normalizeOptionalText$
|
|
6178
|
+
const sessionId = normalizeOptionalText$45(params?.sessionId);
|
|
6178
6179
|
return {
|
|
6179
6180
|
...Object.hasOwn(update, "rawInput") ? { providerInput: update.rawInput } : {},
|
|
6180
|
-
providerKind: normalizeOptionalText$
|
|
6181
|
+
providerKind: normalizeOptionalText$45(update.kind),
|
|
6181
6182
|
...Object.hasOwn(update, "locations") ? { providerLocations: update.locations } : {},
|
|
6182
|
-
providerTitle: normalizeOptionalText$
|
|
6183
|
+
providerTitle: normalizeOptionalText$45(update.title ?? update.name),
|
|
6183
6184
|
scopedToolCallId: sessionId ? `${sessionId}\0${toolCallId}` : toolCallId,
|
|
6184
|
-
status: normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
6356
|
-
const command = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
6450
|
+
return normalizeOptionalText$43(value) !== null;
|
|
6450
6451
|
};
|
|
6451
|
-
const normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
7045
|
+
}) : normalizeOptionalText$42(input.request.agentControllerConversationId);
|
|
7045
7046
|
return {
|
|
7046
7047
|
...input.request,
|
|
7047
7048
|
agentControllerConversationId
|
|
7048
7049
|
};
|
|
7049
7050
|
};
|
|
7050
|
-
const normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
-
|
|
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:
|
|
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$
|
|
9721
|
+
return normalizeOptionalText$40(process.env.HOME) ?? homedir();
|
|
9317
9722
|
}
|
|
9318
|
-
function normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
9892
|
-
const resolvedSessionId = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
10345
|
+
const model = normalizeOptionalText$39(input.conversationPolicy?.model);
|
|
9941
10346
|
if (model) args.push("--model", model);
|
|
9942
|
-
const effort = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
|
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
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
10660
|
+
return [join(normalizeOptionalText$37(process.env.HOME) ?? homedir(), ".local", "bin")];
|
|
10233
10661
|
}
|
|
10234
|
-
function normalizeOptionalText$
|
|
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$
|
|
10284
|
-
const providerToolName = normalizeOptionalText$
|
|
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$
|
|
10723
|
+
const toolCallId = normalizeOptionalText$36(block.id);
|
|
10296
10724
|
if (!toolCallId) return [];
|
|
10297
10725
|
return [{
|
|
10298
10726
|
providerToolInput: block.input,
|
|
10299
|
-
providerToolName: normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
10824
|
-
const resultText = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
10890
|
-
const fallbackModel = normalizeOptionalText$
|
|
10891
|
-
const reasoningLevel = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
11451
|
+
const canonicalRepairSessionId = input.executionMode === "repair" ? normalizeOptionalText$33(input.sessionId) : null;
|
|
11024
11452
|
let latestOutput = "";
|
|
11025
11453
|
let latestResultIsError = false;
|
|
11026
|
-
let resolvedSessionId = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
11271
|
-
const providerMessage = resolveProviderFailureMessage$
|
|
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$
|
|
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$
|
|
11774
|
+
const resolveProviderFailureMessage$2 = (input) => {
|
|
11347
11775
|
const candidateMessages = [
|
|
11348
11776
|
...input.providerErrorMessages,
|
|
11349
|
-
...extractErrorMessagesFromStdout$
|
|
11350
|
-
...normalizeOptionalText$
|
|
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$
|
|
11780
|
+
for (const candidate of candidateMessages) if (looksLikeProviderFailure$2(candidate)) return candidate;
|
|
11353
11781
|
return candidateMessages[0] ?? null;
|
|
11354
11782
|
};
|
|
11355
|
-
const extractErrorMessagesFromStdout$
|
|
11356
|
-
const stdoutText = normalizeOptionalText$
|
|
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$
|
|
11367
|
-
const normalizedLine = normalizeOptionalText$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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:
|
|
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$
|
|
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$
|
|
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) {
|
|
@@ -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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
13446
|
+
function normalizeOptionalText$29(value) {
|
|
12861
13447
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
12862
13448
|
return normalized.length > 0 ? normalized : null;
|
|
12863
13449
|
}
|
|
@@ -13753,7 +14339,7 @@ async function probeCodexAppServerAccount(input) {
|
|
|
13753
14339
|
}
|
|
13754
14340
|
async function invokeCodexAppServerTransport(input) {
|
|
13755
14341
|
throwIfCodexDispatchCancelled(input.cancellationSignal);
|
|
13756
|
-
const prompt = normalizeOptionalText$
|
|
14342
|
+
const prompt = normalizeOptionalText$28(input.prompt);
|
|
13757
14343
|
if (!prompt) throw new CodexAppServerTransportError({
|
|
13758
14344
|
code: "schema.invalid",
|
|
13759
14345
|
errorType: "config",
|
|
@@ -13806,7 +14392,7 @@ async function invokeCodexAppServerTransport(input) {
|
|
|
13806
14392
|
threadModel: threadContext.model
|
|
13807
14393
|
});
|
|
13808
14394
|
const executionThreadId = threadContext.threadId;
|
|
13809
|
-
const continuityThreadId = input.executionMode === "repair" ? normalizeOptionalText$
|
|
14395
|
+
const continuityThreadId = input.executionMode === "repair" ? normalizeOptionalText$28(input.threadId) ?? executionThreadId : executionThreadId;
|
|
13810
14396
|
const turnPrompt = resolveCodexTurnPrompt({
|
|
13811
14397
|
fallbackPrompt: prompt,
|
|
13812
14398
|
instructionPrompt: input.instructionPrompt,
|
|
@@ -13838,7 +14424,7 @@ async function invokeCodexAppServerTransport(input) {
|
|
|
13838
14424
|
errorType: "adapter",
|
|
13839
14425
|
message: interactionFailure.message
|
|
13840
14426
|
});
|
|
13841
|
-
const output = normalizeOptionalText$
|
|
14427
|
+
const output = normalizeOptionalText$28(readAgentMessageOutput(completedTurn) ?? session.readCollectedAgentMessageDeltaText());
|
|
13842
14428
|
requireSuccessfulCodexTurn(completedTurn);
|
|
13843
14429
|
if (output) session.markAgentOutputObserved();
|
|
13844
14430
|
await emitPreviewIfRequested({
|
|
@@ -13851,7 +14437,7 @@ async function invokeCodexAppServerTransport(input) {
|
|
|
13851
14437
|
telemetry: session.buildTelemetry({
|
|
13852
14438
|
invokedAtMs,
|
|
13853
14439
|
previewEmitted: input.streamingMode === "stream" && input.onPreview !== void 0,
|
|
13854
|
-
resumedContext: normalizeOptionalText$
|
|
14440
|
+
resumedContext: normalizeOptionalText$28(input.threadId) !== null,
|
|
13855
14441
|
streamingMode: input.streamingMode ?? "final"
|
|
13856
14442
|
}),
|
|
13857
14443
|
threadId: continuityThreadId
|
|
@@ -14015,7 +14601,7 @@ function requireSuccessfulCodexTurn(turn) {
|
|
|
14015
14601
|
});
|
|
14016
14602
|
}
|
|
14017
14603
|
async function verifyCodexAppServerThread(input) {
|
|
14018
|
-
const threadId = normalizeOptionalText$
|
|
14604
|
+
const threadId = normalizeOptionalText$28(input.threadId);
|
|
14019
14605
|
if (!threadId) throw new CodexAppServerTransportError({
|
|
14020
14606
|
code: "schema.invalid",
|
|
14021
14607
|
errorType: "config",
|
|
@@ -14038,7 +14624,7 @@ async function verifyCodexAppServerThread(input) {
|
|
|
14038
14624
|
});
|
|
14039
14625
|
}
|
|
14040
14626
|
async function resolveCodexAppServerCompletedTurn(input) {
|
|
14041
|
-
const threadId = normalizeOptionalText$
|
|
14627
|
+
const threadId = normalizeOptionalText$28(input.threadId);
|
|
14042
14628
|
if (!threadId) throw new CodexAppServerTransportError({
|
|
14043
14629
|
code: "schema.invalid",
|
|
14044
14630
|
errorType: "config",
|
|
@@ -14070,13 +14656,13 @@ async function resolveCodexAppServerCompletedTurn(input) {
|
|
|
14070
14656
|
});
|
|
14071
14657
|
}
|
|
14072
14658
|
async function forkCodexAppServerThread(input) {
|
|
14073
|
-
const sourceThreadId = normalizeOptionalText$
|
|
14659
|
+
const sourceThreadId = normalizeOptionalText$28(input.sourceThreadId);
|
|
14074
14660
|
if (!sourceThreadId) throw new CodexAppServerTransportError({
|
|
14075
14661
|
code: "schema.invalid",
|
|
14076
14662
|
errorType: "config",
|
|
14077
14663
|
message: "schema.invalid: sourceThreadId is required"
|
|
14078
14664
|
});
|
|
14079
|
-
const sourceCompletedTurnId = normalizeOptionalText$
|
|
14665
|
+
const sourceCompletedTurnId = normalizeOptionalText$28(input.sourceCompletedTurnId);
|
|
14080
14666
|
const executionContextScoped = input.computerFileAccessBoundary?.executionContextAccess !== void 0;
|
|
14081
14667
|
if (sourceCompletedTurnId && input.forkFullHistory) throw new CodexAppServerTransportError({
|
|
14082
14668
|
code: "schema.invalid",
|
|
@@ -14131,7 +14717,7 @@ async function forkCodexAppServerThread(input) {
|
|
|
14131
14717
|
code: "context.fork_timeout",
|
|
14132
14718
|
operation: "thread/fork"
|
|
14133
14719
|
}));
|
|
14134
|
-
const title = normalizeOptionalText$
|
|
14720
|
+
const title = normalizeOptionalText$28(input.title);
|
|
14135
14721
|
if (title) try {
|
|
14136
14722
|
await session.requestControl("thread/name/set", {
|
|
14137
14723
|
name: title,
|
|
@@ -14160,7 +14746,7 @@ function scopedRuntimeWorkspaceParams(permissions, workingDirectory) {
|
|
|
14160
14746
|
return permissions.permissions ? { runtimeWorkspaceRoots: [workingDirectory] } : {};
|
|
14161
14747
|
}
|
|
14162
14748
|
async function resolveDispatchThreadContext(input) {
|
|
14163
|
-
const existingThreadId = normalizeOptionalText$
|
|
14749
|
+
const existingThreadId = normalizeOptionalText$28(input.threadId);
|
|
14164
14750
|
if (existingThreadId && input.executionMode === "repair" && (!input.executionContextScoped || input.session.deliveryOnly)) return await forkEphemeralCodexRepairThread({
|
|
14165
14751
|
conversationPolicyParams: input.conversationPolicyParams,
|
|
14166
14752
|
codexWorkdir: input.codexWorkdir,
|
|
@@ -14239,7 +14825,7 @@ function buildOpenMeldCodexThreadSource(instructionEpoch) {
|
|
|
14239
14825
|
}
|
|
14240
14826
|
async function resolveCodexAppServerCollaborationMode(input) {
|
|
14241
14827
|
if (input.collaborationMode !== "plan") return null;
|
|
14242
|
-
const model = normalizeOptionalText$
|
|
14828
|
+
const model = normalizeOptionalText$28(input.model);
|
|
14243
14829
|
if (!model) throw new CodexAppServerTransportError({
|
|
14244
14830
|
code: "protocol.invalid",
|
|
14245
14831
|
errorType: "adapter",
|
|
@@ -14274,12 +14860,12 @@ async function resolveCodexAppServerTurnCollaborationMode(input) {
|
|
|
14274
14860
|
}
|
|
14275
14861
|
function readCodexAppServerCollaborationModePreset(value) {
|
|
14276
14862
|
const preset = toRecord$7(value);
|
|
14277
|
-
const mode = normalizeOptionalText$
|
|
14863
|
+
const mode = normalizeOptionalText$28(preset?.mode);
|
|
14278
14864
|
if (mode !== "default" && mode !== "plan") return null;
|
|
14279
14865
|
return {
|
|
14280
14866
|
mode,
|
|
14281
|
-
model: normalizeOptionalText$
|
|
14282
|
-
reasoningEffort: normalizeOptionalText$
|
|
14867
|
+
model: normalizeOptionalText$28(preset?.model),
|
|
14868
|
+
reasoningEffort: normalizeOptionalText$28(preset?.reasoning_effort)
|
|
14283
14869
|
};
|
|
14284
14870
|
}
|
|
14285
14871
|
function resolveCodexAppServerPermissionModeParams(value, executionMode, hasComputerFileAccessBoundary = false, hasExecutionContextBoundary = false) {
|
|
@@ -14349,9 +14935,9 @@ function resolveCodexAgentControllerPermissionMode$1(value) {
|
|
|
14349
14935
|
}
|
|
14350
14936
|
function resolveCodexAppServerConversationPolicyParams(conversationPolicy) {
|
|
14351
14937
|
const params = {};
|
|
14352
|
-
const model = normalizeOptionalText$
|
|
14938
|
+
const model = normalizeOptionalText$28(conversationPolicy?.model);
|
|
14353
14939
|
if (model) params.model = model;
|
|
14354
|
-
const reasoningLevel = normalizeOptionalText$
|
|
14940
|
+
const reasoningLevel = normalizeOptionalText$28(conversationPolicy?.reasoningLevel);
|
|
14355
14941
|
if (reasoningLevel) params.effort = reasoningLevel;
|
|
14356
14942
|
return params;
|
|
14357
14943
|
}
|
|
@@ -14640,7 +15226,7 @@ var CodexAppServerSession = class {
|
|
|
14640
15226
|
}
|
|
14641
15227
|
async selectSpaceToolCarrier(input) {
|
|
14642
15228
|
if (!this.#spaceActionTools) return;
|
|
14643
|
-
const existingThreadId = normalizeOptionalText$
|
|
15229
|
+
const existingThreadId = normalizeOptionalText$28(input.threadId);
|
|
14644
15230
|
let nativeThread = false;
|
|
14645
15231
|
if (existingThreadId) {
|
|
14646
15232
|
nativeThread = await this.readSpaceToolCarrier({
|
|
@@ -14727,7 +15313,7 @@ var CodexAppServerSession = class {
|
|
|
14727
15313
|
return this.deliveryOnly ? { environments: [] } : {};
|
|
14728
15314
|
}
|
|
14729
15315
|
async startDispatchThread(params) {
|
|
14730
|
-
const source = normalizeOptionalText$
|
|
15316
|
+
const source = normalizeOptionalText$28(params.threadSource) ?? "user";
|
|
14731
15317
|
try {
|
|
14732
15318
|
return await this.requestControl("thread/start", {
|
|
14733
15319
|
...params,
|
|
@@ -14906,7 +15492,7 @@ var CodexAppServerSession = class {
|
|
|
14906
15492
|
});
|
|
14907
15493
|
}
|
|
14908
15494
|
setNewSessionTitleInBackground(input) {
|
|
14909
|
-
if (normalizeOptionalText$
|
|
15495
|
+
if (normalizeOptionalText$28(input.existingThreadId) || input.executionMode === "repair" || !input.title) return;
|
|
14910
15496
|
this.request("thread/name/set", {
|
|
14911
15497
|
name: input.title,
|
|
14912
15498
|
threadId: input.threadId
|
|
@@ -14929,7 +15515,7 @@ var CodexAppServerSession = class {
|
|
|
14929
15515
|
if (candidate.method !== "turn/completed") return false;
|
|
14930
15516
|
const params = toRecord$7(candidate.params);
|
|
14931
15517
|
const turn = toRecord$7(params?.turn);
|
|
14932
|
-
return params?.threadId === input.threadId && normalizeOptionalText$
|
|
15518
|
+
return params?.threadId === input.threadId && normalizeOptionalText$28(turn?.id) === input.turnId;
|
|
14933
15519
|
})).params)?.turn);
|
|
14934
15520
|
if (!turn) throw new CodexAppServerTransportError({
|
|
14935
15521
|
code: "protocol.invalid",
|
|
@@ -15063,8 +15649,8 @@ var CodexAppServerSession = class {
|
|
|
15063
15649
|
}
|
|
15064
15650
|
#observeContextTelemetry(message) {
|
|
15065
15651
|
const params = toRecord$7(message.params);
|
|
15066
|
-
if (message.method === "turn/started" && params?.threadId === this.#usageThreadId) this.#usageTurnId = normalizeOptionalText$
|
|
15067
|
-
if (message.method === "model/rerouted" && params?.threadId === this.#usageThreadId) this.#usageModel = normalizeOptionalText$
|
|
15652
|
+
if (message.method === "turn/started" && params?.threadId === this.#usageThreadId) this.#usageTurnId = normalizeOptionalText$28(toRecord$7(params.turn)?.id);
|
|
15653
|
+
if (message.method === "model/rerouted" && params?.threadId === this.#usageThreadId) this.#usageModel = normalizeOptionalText$28(params.toModel);
|
|
15068
15654
|
if (message.method === "thread/tokenUsage/updated") {
|
|
15069
15655
|
const tokenUsage = readCodexTokenUsage(toRecord$7(message.params)?.tokenUsage);
|
|
15070
15656
|
if (tokenUsage) {
|
|
@@ -15076,11 +15662,11 @@ var CodexAppServerSession = class {
|
|
|
15076
15662
|
if ((message.method === "item/started" || message.method === "item/completed") && toRecord$7(toRecord$7(message.params)?.item)?.type === "contextCompaction") this.#contextCompactionObserved = true;
|
|
15077
15663
|
}
|
|
15078
15664
|
#observeAiUsage(params, tokenUsage) {
|
|
15079
|
-
const threadId = normalizeOptionalText$
|
|
15665
|
+
const threadId = normalizeOptionalText$28(params?.threadId);
|
|
15080
15666
|
if (!threadId) return;
|
|
15081
15667
|
const previousTotal = this.#usageTotalByThread.get(threadId);
|
|
15082
15668
|
this.#usageTotalByThread.set(threadId, tokenUsage.total.totalTokens);
|
|
15083
|
-
const turnId = normalizeOptionalText$
|
|
15669
|
+
const turnId = normalizeOptionalText$28(params?.turnId);
|
|
15084
15670
|
if (threadId !== this.#usageThreadId || !turnId || turnId !== this.#usageTurnId || previousTotal === tokenUsage.total.totalTokens) return;
|
|
15085
15671
|
const eventId = `codex:${threadId}:${turnId}:${tokenUsage.total.totalTokens}`;
|
|
15086
15672
|
if (this.#aiUsage.has(eventId)) return;
|
|
@@ -15170,7 +15756,7 @@ var CodexAppServerSession = class {
|
|
|
15170
15756
|
#collectAgentMessageDelta(message) {
|
|
15171
15757
|
if (message.method !== "item/agentMessage/delta") return;
|
|
15172
15758
|
const params = toRecord$7(message.params);
|
|
15173
|
-
const itemId = normalizeOptionalText$
|
|
15759
|
+
const itemId = normalizeOptionalText$28(params?.itemId);
|
|
15174
15760
|
const delta = readAgentMessageDeltaText(params?.delta);
|
|
15175
15761
|
if (!(itemId && delta)) return;
|
|
15176
15762
|
this.markAgentOutputObserved();
|
|
@@ -15256,7 +15842,7 @@ var CodexAppServerSession = class {
|
|
|
15256
15842
|
});
|
|
15257
15843
|
}
|
|
15258
15844
|
emitProviderConversationObserved(threadId) {
|
|
15259
|
-
const agentControllerConversationId = normalizeOptionalText$
|
|
15845
|
+
const agentControllerConversationId = normalizeOptionalText$28(threadId);
|
|
15260
15846
|
if (!agentControllerConversationId) return;
|
|
15261
15847
|
this.#emitRuntimeEvent({
|
|
15262
15848
|
agentControllerConversationId,
|
|
@@ -15283,9 +15869,9 @@ function readThreadContextFromResponse(value) {
|
|
|
15283
15869
|
const response = toRecord$7(value);
|
|
15284
15870
|
return {
|
|
15285
15871
|
permissionResponse: value,
|
|
15286
|
-
model: normalizeOptionalText$
|
|
15872
|
+
model: normalizeOptionalText$28(response?.model),
|
|
15287
15873
|
threadId: readRequiredText(response?.thread?.id, "thread response thread.id"),
|
|
15288
|
-
threadSource: normalizeOptionalText$
|
|
15874
|
+
threadSource: normalizeOptionalText$28(response?.thread?.threadSource)
|
|
15289
15875
|
};
|
|
15290
15876
|
}
|
|
15291
15877
|
function readLastCompletedTurnId(value) {
|
|
@@ -15293,8 +15879,8 @@ function readLastCompletedTurnId(value) {
|
|
|
15293
15879
|
const turns = Array.isArray(response?.thread?.turns) ? response.thread.turns : [];
|
|
15294
15880
|
for (let index = turns.length - 1; index >= 0; index -= 1) {
|
|
15295
15881
|
const turn = turns[index];
|
|
15296
|
-
if (normalizeOptionalText$
|
|
15297
|
-
const turnId = normalizeOptionalText$
|
|
15882
|
+
if (normalizeOptionalText$28(turn?.status) !== "completed") continue;
|
|
15883
|
+
const turnId = normalizeOptionalText$28(turn?.id);
|
|
15298
15884
|
if (turnId) return turnId;
|
|
15299
15885
|
}
|
|
15300
15886
|
return null;
|
|
@@ -15309,14 +15895,14 @@ function readTurnStartResponse(value) {
|
|
|
15309
15895
|
return turn;
|
|
15310
15896
|
}
|
|
15311
15897
|
function readAgentMessageOutput(turn) {
|
|
15312
|
-
const text = (Array.isArray(turn.items) ? turn.items : []).filter((item) => item.type === "agentMessage").map((item) => normalizeOptionalText$
|
|
15898
|
+
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
15899
|
return text.length > 0 ? text : null;
|
|
15314
15900
|
}
|
|
15315
15901
|
function readTurnFailureMessage(turn) {
|
|
15316
|
-
return normalizeOptionalText$
|
|
15902
|
+
return normalizeOptionalText$28(turn.error?.message) ?? "codex app-server turn failed";
|
|
15317
15903
|
}
|
|
15318
15904
|
function readTurnFailureCodexErrorInfo(turn) {
|
|
15319
|
-
return normalizeOptionalText$
|
|
15905
|
+
return normalizeOptionalText$28(turn.error?.codexErrorInfo);
|
|
15320
15906
|
}
|
|
15321
15907
|
function readCodexTokenUsage(value) {
|
|
15322
15908
|
const usage = toRecord$7(value);
|
|
@@ -15774,7 +16360,7 @@ function convertCodexMcpElicitationValues(values, schema) {
|
|
|
15774
16360
|
return String(value);
|
|
15775
16361
|
}
|
|
15776
16362
|
function normalizeBoundedText$3(value, maxLength) {
|
|
15777
|
-
const text = normalizeOptionalText$
|
|
16363
|
+
const text = normalizeOptionalText$28(value);
|
|
15778
16364
|
return text ? text.slice(0, maxLength) : null;
|
|
15779
16365
|
}
|
|
15780
16366
|
function safeJsonStringify(value) {
|
|
@@ -15809,7 +16395,7 @@ function buildServerRequestDeclineResponse(method) {
|
|
|
15809
16395
|
}
|
|
15810
16396
|
}
|
|
15811
16397
|
function toJsonRpcTransportError$1(error) {
|
|
15812
|
-
const message = normalizeOptionalText$
|
|
16398
|
+
const message = normalizeOptionalText$28(error.message) ?? "codex app-server error";
|
|
15813
16399
|
const originalError = createProviderOriginalError(message) ?? void 0;
|
|
15814
16400
|
if (error.code === -32601) return new CodexAppServerTransportError({
|
|
15815
16401
|
code: "runtime.method_unsupported",
|
|
@@ -15898,7 +16484,7 @@ function toCodexAppServerTransportError(error, timeoutMs) {
|
|
|
15898
16484
|
});
|
|
15899
16485
|
}
|
|
15900
16486
|
function readRequiredText(value, label) {
|
|
15901
|
-
const text = normalizeOptionalText$
|
|
16487
|
+
const text = normalizeOptionalText$28(value);
|
|
15902
16488
|
if (text) return text;
|
|
15903
16489
|
throw new CodexAppServerTransportError({
|
|
15904
16490
|
code: "protocol.invalid",
|
|
@@ -15913,7 +16499,7 @@ function toRecord$7(value) {
|
|
|
15913
16499
|
function normalizeText$7(value) {
|
|
15914
16500
|
return String(value ?? "").trim();
|
|
15915
16501
|
}
|
|
15916
|
-
function normalizeOptionalText$
|
|
16502
|
+
function normalizeOptionalText$28(value) {
|
|
15917
16503
|
const normalized = normalizeText$7(value);
|
|
15918
16504
|
return normalized.length > 0 ? normalized : null;
|
|
15919
16505
|
}
|
|
@@ -15926,7 +16512,7 @@ function isProcessGroupAbsent(processId) {
|
|
|
15926
16512
|
}
|
|
15927
16513
|
}
|
|
15928
16514
|
function parseCodexAppServerVersion(response) {
|
|
15929
|
-
return normalizeOptionalText$
|
|
16515
|
+
return normalizeOptionalText$28(toRecord$7(response)?.userAgent)?.match(CODEX_APP_SERVER_VERSION_PATTERN)?.[1] ?? null;
|
|
15930
16516
|
}
|
|
15931
16517
|
function resolveCodexAppServerAuthStatus(input) {
|
|
15932
16518
|
if (input.account) return "authenticated";
|
|
@@ -15979,7 +16565,7 @@ async function resolveInstalledCodexLaunchCandidates(input) {
|
|
|
15979
16565
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
15980
16566
|
additionalCommandDirectories: resolveCodexAppBundleCommandDirectories(input?.appBundleRoots),
|
|
15981
16567
|
commandName: DEFAULT_CODEX_COMMAND,
|
|
15982
|
-
configuredCommand: normalizeOptionalText$
|
|
16568
|
+
configuredCommand: normalizeOptionalText$27(process.env.OPENMELD_DAEMON_RUNTIME_CODEX_BIN),
|
|
15983
16569
|
displayName: "Codex",
|
|
15984
16570
|
preferredLaunchContract: input?.preferredLaunchContract
|
|
15985
16571
|
});
|
|
@@ -16040,7 +16626,7 @@ async function verifyCodexCommandLaunchContract(input) {
|
|
|
16040
16626
|
});
|
|
16041
16627
|
}
|
|
16042
16628
|
function resolveCodexTimeoutMs() {
|
|
16043
|
-
const raw = normalizeOptionalText$
|
|
16629
|
+
const raw = normalizeOptionalText$27(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
16044
16630
|
if (!raw) return null;
|
|
16045
16631
|
const parsed = Number.parseInt(raw, 10);
|
|
16046
16632
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
@@ -16050,7 +16636,7 @@ function isCodexHostApplicationCommandPath(commandPath) {
|
|
|
16050
16636
|
return resolveCodexAppLabel(commandPath) !== null;
|
|
16051
16637
|
}
|
|
16052
16638
|
function resolveCodexAppBundleCommandDirectories(appBundleRoots) {
|
|
16053
|
-
const home = normalizeOptionalText$
|
|
16639
|
+
const home = normalizeOptionalText$27(process.env.HOME) ?? homedir();
|
|
16054
16640
|
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
16641
|
}
|
|
16056
16642
|
async function inspectCodexLaunchCandidate(input) {
|
|
@@ -16111,7 +16697,7 @@ function resolveCodexControlProbeTimeoutMs(timeoutMs) {
|
|
|
16111
16697
|
function toErrorMessage$14(error) {
|
|
16112
16698
|
return error instanceof Error ? error.message : String(error);
|
|
16113
16699
|
}
|
|
16114
|
-
function normalizeOptionalText$
|
|
16700
|
+
function normalizeOptionalText$27(value) {
|
|
16115
16701
|
const normalized = String(value ?? "").trim();
|
|
16116
16702
|
return normalized.length > 0 ? normalized : null;
|
|
16117
16703
|
}
|
|
@@ -16172,9 +16758,9 @@ function extractOutputFromCodexLine(line) {
|
|
|
16172
16758
|
const item = record.item && typeof record.item === "object" && !Array.isArray(record.item) ? record.item : null;
|
|
16173
16759
|
const response = record.response && typeof record.response === "object" && !Array.isArray(record.response) ? record.response : null;
|
|
16174
16760
|
if (record.type === "item.completed" && item?.type === "agent_message") {
|
|
16175
|
-
const phase = normalizeOptionalText$
|
|
16761
|
+
const phase = normalizeOptionalText$26(item.phase ?? record.phase);
|
|
16176
16762
|
if (phase && phase !== "final_answer") return null;
|
|
16177
|
-
const text = normalizeOptionalText$
|
|
16763
|
+
const text = normalizeOptionalText$26(item.text);
|
|
16178
16764
|
return text ? {
|
|
16179
16765
|
previewable: false,
|
|
16180
16766
|
terminal: true,
|
|
@@ -16182,7 +16768,7 @@ function extractOutputFromCodexLine(line) {
|
|
|
16182
16768
|
} : null;
|
|
16183
16769
|
}
|
|
16184
16770
|
if (record.type === "response.completed") {
|
|
16185
|
-
const text = normalizeOptionalText$
|
|
16771
|
+
const text = normalizeOptionalText$26(response?.output_text);
|
|
16186
16772
|
return text ? {
|
|
16187
16773
|
previewable: false,
|
|
16188
16774
|
terminal: true,
|
|
@@ -16212,12 +16798,12 @@ function extractThreadIdFromCodexLine(line) {
|
|
|
16212
16798
|
const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
16213
16799
|
if (!record) return null;
|
|
16214
16800
|
if (record.type !== "thread.started") return null;
|
|
16215
|
-
return normalizeOptionalText$
|
|
16801
|
+
return normalizeOptionalText$26(record.thread_id);
|
|
16216
16802
|
}
|
|
16217
16803
|
function normalizeText$6(value) {
|
|
16218
16804
|
return String(value ?? "").trim();
|
|
16219
16805
|
}
|
|
16220
|
-
function normalizeOptionalText$
|
|
16806
|
+
function normalizeOptionalText$26(value) {
|
|
16221
16807
|
const normalized = normalizeText$6(value);
|
|
16222
16808
|
return normalized.length > 0 ? normalized : null;
|
|
16223
16809
|
}
|
|
@@ -16243,7 +16829,7 @@ async function invokeCodexCliTransport(input) {
|
|
|
16243
16829
|
errorType: "config",
|
|
16244
16830
|
message: "This Codex CLI path cannot restrict correction to delivery tools. No correction turn was started."
|
|
16245
16831
|
});
|
|
16246
|
-
const prompt = normalizeOptionalText$
|
|
16832
|
+
const prompt = normalizeOptionalText$25(input.prompt);
|
|
16247
16833
|
if (!prompt) throw new CodexCliTransportError({
|
|
16248
16834
|
code: "schema.invalid",
|
|
16249
16835
|
errorType: "config",
|
|
@@ -16336,7 +16922,7 @@ async function invokeCodexCliTransport(input) {
|
|
|
16336
16922
|
providerAccessEvidence: classifiedFailure.providerAccessEvidence
|
|
16337
16923
|
});
|
|
16338
16924
|
}
|
|
16339
|
-
const output = normalizeOptionalText$
|
|
16925
|
+
const output = normalizeOptionalText$25(latestOutput);
|
|
16340
16926
|
if (!output) {
|
|
16341
16927
|
if (providerErrorMessages.length > 0) {
|
|
16342
16928
|
const classifiedFailure = classifyCodexFailure({
|
|
@@ -16372,12 +16958,12 @@ async function invokeCodexCliTransport(input) {
|
|
|
16372
16958
|
previewEmitted: previewEmitter.emitted,
|
|
16373
16959
|
...driverResult.lifecycle.processId === null ? {} : { processId: driverResult.lifecycle.processId },
|
|
16374
16960
|
...driverResult.lifecycle.processSpawnedAtMs === null ? {} : { processSpawnedAtMs: driverResult.lifecycle.processSpawnedAtMs },
|
|
16375
|
-
resumedContext: normalizeOptionalText$
|
|
16961
|
+
resumedContext: normalizeOptionalText$25(input.threadId) !== null,
|
|
16376
16962
|
...driverResult.lifecycle.stdinClosedAtMs === null ? {} : { stdinClosedAtMs: driverResult.lifecycle.stdinClosedAtMs },
|
|
16377
16963
|
streamingMode: input.streamingMode ?? "final",
|
|
16378
16964
|
...driverResult.lifecycle.timeoutTriggeredAtMs === null ? {} : { timeoutTriggeredAtMs: driverResult.lifecycle.timeoutTriggeredAtMs }
|
|
16379
16965
|
},
|
|
16380
|
-
threadId: normalizeOptionalText$
|
|
16966
|
+
threadId: normalizeOptionalText$25(resolvedThreadId)
|
|
16381
16967
|
};
|
|
16382
16968
|
}
|
|
16383
16969
|
function extractCodexToolActivityEventFromLine(line) {
|
|
@@ -16481,9 +17067,9 @@ function resolveCodexAgentControllerPermissionMode(value) {
|
|
|
16481
17067
|
}
|
|
16482
17068
|
function buildCodexConversationPolicyArgs(conversationPolicy) {
|
|
16483
17069
|
const args = [];
|
|
16484
|
-
const model = normalizeOptionalText$
|
|
17070
|
+
const model = normalizeOptionalText$25(conversationPolicy?.model);
|
|
16485
17071
|
if (model) args.push("-m", model);
|
|
16486
|
-
const reasoningLevel = normalizeOptionalText$
|
|
17072
|
+
const reasoningLevel = normalizeOptionalText$25(conversationPolicy?.reasoningLevel);
|
|
16487
17073
|
if (reasoningLevel) args.push("-c", `model_reasoning_effort=${reasoningLevel}`);
|
|
16488
17074
|
return args;
|
|
16489
17075
|
}
|
|
@@ -16570,7 +17156,7 @@ const toCodexCliTransportError = (error, timeoutMs) => {
|
|
|
16570
17156
|
});
|
|
16571
17157
|
};
|
|
16572
17158
|
const collectCodexErrorMessage = (line, messages) => {
|
|
16573
|
-
const normalizedLine = normalizeOptionalText$
|
|
17159
|
+
const normalizedLine = normalizeOptionalText$25(line);
|
|
16574
17160
|
if (!normalizedLine) return;
|
|
16575
17161
|
const jsonMessage = readCodexJsonErrorMessage(normalizedLine);
|
|
16576
17162
|
if (jsonMessage) messages.push(jsonMessage);
|
|
@@ -16584,14 +17170,14 @@ const readCodexJsonErrorMessage = (line) => {
|
|
|
16584
17170
|
}
|
|
16585
17171
|
const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
16586
17172
|
if (!record) return null;
|
|
16587
|
-
const message = normalizeOptionalText$
|
|
17173
|
+
const message = normalizeOptionalText$25(record.message);
|
|
16588
17174
|
if (record.type === "error" && message) return message;
|
|
16589
|
-
const errorMessage = normalizeOptionalText$
|
|
17175
|
+
const errorMessage = normalizeOptionalText$25((record.error && typeof record.error === "object" && !Array.isArray(record.error) ? record.error : null)?.message);
|
|
16590
17176
|
if (record.type === "turn.failed" && errorMessage) return errorMessage;
|
|
16591
17177
|
return null;
|
|
16592
17178
|
};
|
|
16593
17179
|
const classifyCodexFailure = (input) => {
|
|
16594
|
-
const providerMessage = resolveProviderFailureMessage$
|
|
17180
|
+
const providerMessage = resolveProviderFailureMessage$1(input);
|
|
16595
17181
|
const originalError = providerMessage && input.providerErrorMessages.includes(providerMessage) ? createProviderOriginalError(providerMessage) ?? void 0 : void 0;
|
|
16596
17182
|
if (providerMessage) {
|
|
16597
17183
|
const lowered = providerMessage.toLowerCase();
|
|
@@ -16623,7 +17209,7 @@ const classifyCodexFailure = (input) => {
|
|
|
16623
17209
|
originalError
|
|
16624
17210
|
};
|
|
16625
17211
|
}
|
|
16626
|
-
const stderrText = normalizeOptionalText$
|
|
17212
|
+
const stderrText = normalizeOptionalText$25(input.stderrText);
|
|
16627
17213
|
if (stderrText) return {
|
|
16628
17214
|
code: "upstream_unreachable",
|
|
16629
17215
|
errorType: "adapter",
|
|
@@ -16635,16 +17221,16 @@ const classifyCodexFailure = (input) => {
|
|
|
16635
17221
|
originalError
|
|
16636
17222
|
};
|
|
16637
17223
|
};
|
|
16638
|
-
const resolveProviderFailureMessage$
|
|
17224
|
+
const resolveProviderFailureMessage$1 = (input) => {
|
|
16639
17225
|
const candidateMessages = [
|
|
16640
17226
|
...input.providerErrorMessages,
|
|
16641
|
-
...normalizeOptionalText$
|
|
16642
|
-
...normalizeOptionalText$
|
|
17227
|
+
...normalizeOptionalText$25(input.stderrText) ? [normalizeOptionalText$25(input.stderrText)] : [],
|
|
17228
|
+
...normalizeOptionalText$25(input.stdoutText) ? [normalizeOptionalText$25(input.stdoutText)] : []
|
|
16643
17229
|
].filter((value) => Boolean(value));
|
|
16644
|
-
for (const candidate of candidateMessages) if (looksLikeProviderFailure$
|
|
17230
|
+
for (const candidate of candidateMessages) if (looksLikeProviderFailure$1(candidate)) return candidate;
|
|
16645
17231
|
return candidateMessages[0] ?? null;
|
|
16646
17232
|
};
|
|
16647
|
-
const looksLikeProviderFailure$
|
|
17233
|
+
const looksLikeProviderFailure$1 = (value) => {
|
|
16648
17234
|
const normalized = value.toLowerCase();
|
|
16649
17235
|
return looksLikeRuntimePermissionDenialMessage(value) || classifyCodexProviderAccountFailure({ message: normalized }) !== null;
|
|
16650
17236
|
};
|
|
@@ -16663,7 +17249,7 @@ const toControllerClientUpgradeRequiredMessage = (value) => {
|
|
|
16663
17249
|
function normalizeText$5(value) {
|
|
16664
17250
|
return String(value ?? "").trim();
|
|
16665
17251
|
}
|
|
16666
|
-
function normalizeOptionalText$
|
|
17252
|
+
function normalizeOptionalText$25(value) {
|
|
16667
17253
|
const normalized = normalizeText$5(value);
|
|
16668
17254
|
return normalized.length > 0 ? normalized : null;
|
|
16669
17255
|
}
|
|
@@ -17321,7 +17907,7 @@ const resolveDefaultCodexInvoke = (options) => {
|
|
|
17321
17907
|
...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
|
|
17322
17908
|
prompt: input.prompt,
|
|
17323
17909
|
streamingMode: input.streamingMode,
|
|
17324
|
-
threadId: normalizeOptionalText$
|
|
17910
|
+
threadId: normalizeOptionalText$24(input.agentControllerConversationId)
|
|
17325
17911
|
});
|
|
17326
17912
|
const agentControllerConversation = CODEX_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
|
|
17327
17913
|
bridgeSpec: CODEX_CONVERSATION_BRIDGE_SPEC,
|
|
@@ -17382,7 +17968,7 @@ const resolveDefaultCodexAppServerInvoke = (input) => {
|
|
|
17382
17968
|
prompt: dispatchInput.prompt,
|
|
17383
17969
|
streamingMode: dispatchInput.streamingMode,
|
|
17384
17970
|
taskId: dispatchInput.taskId,
|
|
17385
|
-
threadId: normalizeOptionalText$
|
|
17971
|
+
threadId: normalizeOptionalText$24(dispatchInput.agentControllerConversationId)
|
|
17386
17972
|
});
|
|
17387
17973
|
const agentControllerConversation = CODEX_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
|
|
17388
17974
|
bridgeSpec: CODEX_CONVERSATION_BRIDGE_SPEC,
|
|
@@ -17443,9 +18029,9 @@ async function resolveCodexDispatchLaunchContract(input) {
|
|
|
17443
18029
|
});
|
|
17444
18030
|
}
|
|
17445
18031
|
function resolveConfiguredCodexLaunchContract(input) {
|
|
17446
|
-
return input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$
|
|
18032
|
+
return input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$24(input.codexBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$24(input.codexBin) }) : null);
|
|
17447
18033
|
}
|
|
17448
|
-
const normalizeOptionalText$
|
|
18034
|
+
const normalizeOptionalText$24 = (value) => {
|
|
17449
18035
|
const normalized = String(value ?? "").trim();
|
|
17450
18036
|
return normalized.length > 0 ? normalized : null;
|
|
17451
18037
|
};
|
|
@@ -17508,7 +18094,7 @@ async function resolveInstalledCursorLaunchCandidates(input) {
|
|
|
17508
18094
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
17509
18095
|
additionalCommandDirectories: resolveCursorCommandDirectories(),
|
|
17510
18096
|
commandName: DEFAULT_CURSOR_COMMAND,
|
|
17511
|
-
configuredCommand: normalizeOptionalText$
|
|
18097
|
+
configuredCommand: normalizeOptionalText$23(process.env.OPENMELD_DAEMON_RUNTIME_CURSOR_BIN),
|
|
17512
18098
|
displayName: "Cursor CLI",
|
|
17513
18099
|
preferredLaunchContract: input?.preferredLaunchContract
|
|
17514
18100
|
});
|
|
@@ -17531,7 +18117,7 @@ async function resolveInstalledCursorLaunchCandidates(input) {
|
|
|
17531
18117
|
};
|
|
17532
18118
|
}
|
|
17533
18119
|
async function refreshCursorPersistedLaunchContract(input) {
|
|
17534
|
-
const configuredCommand = normalizeOptionalText$
|
|
18120
|
+
const configuredCommand = normalizeOptionalText$23(process.env.OPENMELD_DAEMON_RUNTIME_CURSOR_BIN);
|
|
17535
18121
|
if (configuredCommand) {
|
|
17536
18122
|
const resolution = await resolveInstalledNodeScriptLaunchContract({
|
|
17537
18123
|
commandName: DEFAULT_CURSOR_COMMAND,
|
|
@@ -17545,7 +18131,7 @@ async function refreshCursorPersistedLaunchContract(input) {
|
|
|
17545
18131
|
}
|
|
17546
18132
|
if (input.launchContract.kind !== "node_script") return input.launchContract;
|
|
17547
18133
|
const persistedLaunchContract = input.launchContract;
|
|
17548
|
-
const home = normalizeOptionalText$
|
|
18134
|
+
const home = normalizeOptionalText$23(process.env.HOME) ?? homedir();
|
|
17549
18135
|
const managedVersionsRoot = join(home, ".local", "share", "cursor-agent", "versions");
|
|
17550
18136
|
const canonicalManagedVersionsRoot = await realpath(managedVersionsRoot).catch(() => managedVersionsRoot);
|
|
17551
18137
|
const canonicalPersistedScriptPath = await realpath(persistedLaunchContract.scriptPath).catch(() => persistedLaunchContract.scriptPath);
|
|
@@ -17585,7 +18171,7 @@ async function verifyCursorLaunchContract(input) {
|
|
|
17585
18171
|
});
|
|
17586
18172
|
}
|
|
17587
18173
|
function resolveCursorTimeoutMs() {
|
|
17588
|
-
const raw = normalizeOptionalText$
|
|
18174
|
+
const raw = normalizeOptionalText$23(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
17589
18175
|
if (!raw) return null;
|
|
17590
18176
|
const parsed = Number.parseInt(raw, 10);
|
|
17591
18177
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
@@ -17598,7 +18184,7 @@ function isIncompleteLaunchContractCheck(verification) {
|
|
|
17598
18184
|
return !verification.ok && verification.failureKind === "incomplete_check";
|
|
17599
18185
|
}
|
|
17600
18186
|
function resolveCursorCommandDirectories() {
|
|
17601
|
-
return resolveCursorCommandPaths(normalizeOptionalText$
|
|
18187
|
+
return resolveCursorCommandPaths(normalizeOptionalText$23(process.env.HOME) ?? homedir()).map(dirname);
|
|
17602
18188
|
}
|
|
17603
18189
|
function resolveCursorCommandPaths(home) {
|
|
17604
18190
|
return [join(home, ".local", "bin", DEFAULT_CURSOR_COMMAND), join(home, ".cursor", "bin", DEFAULT_CURSOR_COMMAND)];
|
|
@@ -17607,7 +18193,7 @@ function isManagedCursorVersionScript(input) {
|
|
|
17607
18193
|
const segments = relative(input.managedVersionsRoot, input.scriptPath).split(PATH_SEGMENT_SPLIT_RE);
|
|
17608
18194
|
return segments.length === 2 && segments[0] !== ".." && segments[0] !== "." && segments[1] === DEFAULT_CURSOR_COMMAND;
|
|
17609
18195
|
}
|
|
17610
|
-
function normalizeOptionalText$
|
|
18196
|
+
function normalizeOptionalText$23(value) {
|
|
17611
18197
|
const normalized = String(value ?? "").trim();
|
|
17612
18198
|
return normalized.length > 0 ? normalized : null;
|
|
17613
18199
|
}
|
|
@@ -18041,13 +18627,13 @@ var CursorAcpTransportError = class extends Error {
|
|
|
18041
18627
|
}
|
|
18042
18628
|
};
|
|
18043
18629
|
async function invokeCursorAcpTransport(input) {
|
|
18044
|
-
const prompt = normalizeOptionalText$
|
|
18630
|
+
const prompt = normalizeOptionalText$22(input.prompt);
|
|
18045
18631
|
if (!prompt) throw new CursorAcpTransportError({
|
|
18046
18632
|
code: "schema.invalid",
|
|
18047
18633
|
errorType: "config",
|
|
18048
18634
|
message: "schema.invalid: prompt is required"
|
|
18049
18635
|
});
|
|
18050
|
-
if (normalizeOptionalText$
|
|
18636
|
+
if (normalizeOptionalText$22(input.conversationPolicy?.reasoningLevel)) throw new CursorAcpTransportError({
|
|
18051
18637
|
code: "model.reasoning_unsupported",
|
|
18052
18638
|
errorType: "config",
|
|
18053
18639
|
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 +18679,13 @@ async function invokeCursorAcpTransport(input) {
|
|
|
18093
18679
|
}
|
|
18094
18680
|
async function runCursorAcpTurn(input) {
|
|
18095
18681
|
await input.session.initialize();
|
|
18096
|
-
const existingSessionId = normalizeOptionalText$
|
|
18682
|
+
const existingSessionId = normalizeOptionalText$22(input.input.sessionId);
|
|
18097
18683
|
const initialDescriptor = await input.session.openSession({ sessionId: input.deliveryScope ? null : existingSessionId });
|
|
18098
18684
|
const continuitySessionId = input.deliveryScope ? existingSessionId ?? initialDescriptor.sessionId : initialDescriptor.sessionId;
|
|
18099
18685
|
input.session.emitProviderConversationObserved(continuitySessionId);
|
|
18100
18686
|
const modelResolution = await resolveCursorSessionModel({
|
|
18101
18687
|
descriptor: initialDescriptor,
|
|
18102
|
-
model: normalizeOptionalText$
|
|
18688
|
+
model: normalizeOptionalText$22(input.input.conversationPolicy?.model),
|
|
18103
18689
|
session: input.session
|
|
18104
18690
|
});
|
|
18105
18691
|
const { descriptor } = modelResolution;
|
|
@@ -18366,7 +18952,7 @@ var CursorAcpSession = class {
|
|
|
18366
18952
|
return readSessionDescriptor(result, input.sessionId, "load");
|
|
18367
18953
|
}
|
|
18368
18954
|
const result = await this.request("session/new", params);
|
|
18369
|
-
const sessionId = normalizeOptionalText$
|
|
18955
|
+
const sessionId = normalizeOptionalText$22(toRecord$5(result)?.sessionId);
|
|
18370
18956
|
if (!sessionId) throw new CursorAcpTransportError({
|
|
18371
18957
|
code: "protocol.invalid",
|
|
18372
18958
|
errorType: "adapter",
|
|
@@ -18529,8 +19115,8 @@ function readSessionDescriptor(value, sessionId, sessionOperation) {
|
|
|
18529
19115
|
const modelConfig = readConfigOption(record, "model");
|
|
18530
19116
|
const legacyAvailableModelIds = readLegacyAvailableModelIds(models);
|
|
18531
19117
|
const configAvailableModelIds = readConfigAvailableModelIds(modelConfig);
|
|
18532
|
-
const legacyCurrentModelId = normalizeOptionalText$
|
|
18533
|
-
const configCurrentModelId = normalizeOptionalText$
|
|
19118
|
+
const legacyCurrentModelId = normalizeOptionalText$22(models?.currentModelId);
|
|
19119
|
+
const configCurrentModelId = normalizeOptionalText$22(modelConfig?.currentValue);
|
|
18534
19120
|
const modelInventory = resolveModelInventory({
|
|
18535
19121
|
configAvailableModelIds,
|
|
18536
19122
|
configCurrentModelId,
|
|
@@ -18542,7 +19128,7 @@ function readSessionDescriptor(value, sessionId, sessionOperation) {
|
|
|
18542
19128
|
availableModelIds: modelInventory.availableModelIds,
|
|
18543
19129
|
configAvailableModelIds,
|
|
18544
19130
|
configCurrentModelId,
|
|
18545
|
-
currentModeId: normalizeOptionalText$
|
|
19131
|
+
currentModeId: normalizeOptionalText$22(modes?.currentModeId) ?? readCurrentConfigValue(record, "mode"),
|
|
18546
19132
|
currentModelId: modelInventory.currentModelId,
|
|
18547
19133
|
legacyAvailableModelIds,
|
|
18548
19134
|
legacyCurrentModelId,
|
|
@@ -18558,7 +19144,7 @@ function readConfigAvailableModelIds(modelConfig) {
|
|
|
18558
19144
|
return uniqueModelIds((Array.isArray(modelConfig?.options) ? modelConfig.options : []).map((option) => toRecord$5(option)?.value));
|
|
18559
19145
|
}
|
|
18560
19146
|
function uniqueModelIds(values) {
|
|
18561
|
-
return [...new Set(values.map(normalizeOptionalText$
|
|
19147
|
+
return [...new Set(values.map(normalizeOptionalText$22).filter((modelId) => modelId !== null))];
|
|
18562
19148
|
}
|
|
18563
19149
|
function resolveModelInventory(input) {
|
|
18564
19150
|
const currentModelId = input.configCurrentModelId ?? input.legacyCurrentModelId;
|
|
@@ -18630,10 +19216,10 @@ function sanitizeDiagnosticModelId$1(modelId) {
|
|
|
18630
19216
|
return modelId === null ? null : modelId.slice(0, MAX_MODEL_DIAGNOSTIC_ID_CHARS$1);
|
|
18631
19217
|
}
|
|
18632
19218
|
function readCurrentConfigValue(record, id) {
|
|
18633
|
-
return normalizeOptionalText$
|
|
19219
|
+
return normalizeOptionalText$22(readConfigOption(record, id)?.currentValue);
|
|
18634
19220
|
}
|
|
18635
19221
|
function readConfigOption(record, id) {
|
|
18636
|
-
return (Array.isArray(record?.configOptions) ? record.configOptions : []).map(toRecord$5).find((option) => (normalizeOptionalText$
|
|
19222
|
+
return (Array.isArray(record?.configOptions) ? record.configOptions : []).map(toRecord$5).find((option) => (normalizeOptionalText$22(option?.configId) ?? normalizeOptionalText$22(option?.id)) === id) ?? null;
|
|
18637
19223
|
}
|
|
18638
19224
|
function resolveCursorAcpMode(value) {
|
|
18639
19225
|
switch (resolveCursorPermissionMode(value)) {
|
|
@@ -18660,7 +19246,7 @@ function buildCursorAcpArgs(permissionMode) {
|
|
|
18660
19246
|
}
|
|
18661
19247
|
}
|
|
18662
19248
|
function assertSuccessfulStopReason$1(value) {
|
|
18663
|
-
const stopReason = normalizeOptionalText$
|
|
19249
|
+
const stopReason = normalizeOptionalText$22(toRecord$5(value)?.stopReason);
|
|
18664
19250
|
if (!stopReason) throw new CursorAcpTransportError({
|
|
18665
19251
|
code: "protocol.invalid",
|
|
18666
19252
|
errorType: "adapter",
|
|
@@ -18681,7 +19267,7 @@ async function emitFinalPreviewIfRequested$1(input) {
|
|
|
18681
19267
|
await input.onPreview({ text: input.output });
|
|
18682
19268
|
}
|
|
18683
19269
|
function toJsonRpcTransportError(error) {
|
|
18684
|
-
const message = normalizeOptionalText$
|
|
19270
|
+
const message = normalizeOptionalText$22(error.message) ?? "Cursor ACP error";
|
|
18685
19271
|
const originalError = createProviderOriginalError(message);
|
|
18686
19272
|
if (error.code === -32601) return new CursorAcpTransportError({
|
|
18687
19273
|
code: "protocol.method_not_found",
|
|
@@ -18705,7 +19291,7 @@ function toCursorAcpTransportError(error, stderr, diagnostics) {
|
|
|
18705
19291
|
message: error.message,
|
|
18706
19292
|
...error.originalError ? { originalError: error.originalError } : {}
|
|
18707
19293
|
});
|
|
18708
|
-
const classified = classifyCursorFailure([toErrorMessage$11(error), normalizeOptionalText$
|
|
19294
|
+
const classified = classifyCursorFailure([toErrorMessage$11(error), normalizeOptionalText$22(stderr)].filter((value) => value !== null).join("\n"));
|
|
18709
19295
|
return diagnostics ? new CursorAcpTransportError({
|
|
18710
19296
|
code: classified.code,
|
|
18711
19297
|
diagnostics,
|
|
@@ -18714,7 +19300,7 @@ function toCursorAcpTransportError(error, stderr, diagnostics) {
|
|
|
18714
19300
|
}) : classified;
|
|
18715
19301
|
}
|
|
18716
19302
|
function classifyCursorFailure(message, originalError = null) {
|
|
18717
|
-
const normalized = normalizeOptionalText$
|
|
19303
|
+
const normalized = normalizeOptionalText$22(message) ?? "Cursor ACP error";
|
|
18718
19304
|
const lowered = normalized.toLowerCase();
|
|
18719
19305
|
if (isCursorPlanUpgradeRequired(normalized)) return new CursorAcpTransportError({
|
|
18720
19306
|
code: "cursor.plan_upgrade_required",
|
|
@@ -18750,7 +19336,7 @@ function classifyCursorFailure(message, originalError = null) {
|
|
|
18750
19336
|
function normalizeOutputText$2(value) {
|
|
18751
19337
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
18752
19338
|
}
|
|
18753
|
-
function normalizeOptionalText$
|
|
19339
|
+
function normalizeOptionalText$22(value) {
|
|
18754
19340
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
18755
19341
|
return normalized.length > 0 ? normalized : null;
|
|
18756
19342
|
}
|
|
@@ -18851,7 +19437,7 @@ function createDefaultCursorInvoke(input) {
|
|
|
18851
19437
|
});
|
|
18852
19438
|
} : void 0;
|
|
18853
19439
|
const result = await invokeWithSingleContextHeal({
|
|
18854
|
-
contextId: normalizeOptionalText$
|
|
19440
|
+
contextId: normalizeOptionalText$21(dispatchInput.agentControllerConversationId),
|
|
18855
19441
|
contextLossPolicy: dispatchInput.executionMode === "repair" ? "fail" : "rebuild",
|
|
18856
19442
|
createRebuildFailedError: (error) => error instanceof CursorAcpTransportError && error.code === "cursor.plan_upgrade_required" ? error : new CursorAcpTransportError({
|
|
18857
19443
|
cause: error,
|
|
@@ -18906,7 +19492,7 @@ function createDefaultCursorInvoke(input) {
|
|
|
18906
19492
|
};
|
|
18907
19493
|
}
|
|
18908
19494
|
async function resolveCursorDispatchLaunchContract(input) {
|
|
18909
|
-
const launchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$
|
|
19495
|
+
const launchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$21(input.cursorBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$21(input.cursorBin) }) : null);
|
|
18910
19496
|
if (!launchContract) throw Object.assign(/* @__PURE__ */ new Error("Cursor CLI launch contract is required for runtime dispatch."), {
|
|
18911
19497
|
code: "controller.launch.needs_repair",
|
|
18912
19498
|
errorType: "config"
|
|
@@ -18979,7 +19565,7 @@ async function interruptActiveCursorTurn(input) {
|
|
|
18979
19565
|
};
|
|
18980
19566
|
}
|
|
18981
19567
|
}
|
|
18982
|
-
function normalizeOptionalText$
|
|
19568
|
+
function normalizeOptionalText$21(value) {
|
|
18983
19569
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
18984
19570
|
return normalized.length > 0 ? normalized : null;
|
|
18985
19571
|
}
|
|
@@ -19006,7 +19592,7 @@ async function resolveInstalledGrokBuildLaunchCandidates(input) {
|
|
|
19006
19592
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
19007
19593
|
additionalCommandDirectories: [join(resolveHome(), ".grok", "bin")],
|
|
19008
19594
|
commandName: DEFAULT_GROK_BUILD_COMMAND,
|
|
19009
|
-
configuredCommand: normalizeOptionalText$
|
|
19595
|
+
configuredCommand: normalizeOptionalText$20(process.env.OPENMELD_DAEMON_RUNTIME_GROK_BUILD_BIN),
|
|
19010
19596
|
displayName: "Grok Build",
|
|
19011
19597
|
preferredLaunchContract: input?.preferredLaunchContract
|
|
19012
19598
|
});
|
|
@@ -19039,15 +19625,15 @@ async function verifyGrokBuildLaunchContract(input) {
|
|
|
19039
19625
|
});
|
|
19040
19626
|
}
|
|
19041
19627
|
function resolveGrokBuildTimeoutMs() {
|
|
19042
|
-
const raw = normalizeOptionalText$
|
|
19628
|
+
const raw = normalizeOptionalText$20(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
19043
19629
|
if (!raw) return null;
|
|
19044
19630
|
const parsed = Number.parseInt(raw, 10);
|
|
19045
19631
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
|
|
19046
19632
|
}
|
|
19047
19633
|
function resolveHome() {
|
|
19048
|
-
return normalizeOptionalText$
|
|
19634
|
+
return normalizeOptionalText$20(process.env.HOME) ?? homedir();
|
|
19049
19635
|
}
|
|
19050
|
-
function normalizeOptionalText$
|
|
19636
|
+
function normalizeOptionalText$20(value) {
|
|
19051
19637
|
const normalized = String(value ?? "").trim();
|
|
19052
19638
|
return normalized.length > 0 ? normalized : null;
|
|
19053
19639
|
}
|
|
@@ -20423,7 +21009,7 @@ async function invokeGrokBuildAcpTransport(input) {
|
|
|
20423
21009
|
errorType: "config",
|
|
20424
21010
|
message: "The current Wake's delivery capability is missing. No correction turn was started."
|
|
20425
21011
|
});
|
|
20426
|
-
const prompt = normalizeOptionalText$
|
|
21012
|
+
const prompt = normalizeOptionalText$19(input.prompt);
|
|
20427
21013
|
if (!prompt) throw new GrokBuildAcpTransportError({
|
|
20428
21014
|
code: "schema.invalid",
|
|
20429
21015
|
errorType: "config",
|
|
@@ -20450,9 +21036,9 @@ async function invokeGrokBuildAcpTransport(input) {
|
|
|
20450
21036
|
try {
|
|
20451
21037
|
session.start();
|
|
20452
21038
|
await session.initialize({ collectUsageLimits: false });
|
|
20453
|
-
const existingSessionId = normalizeOptionalText$
|
|
21039
|
+
const existingSessionId = normalizeOptionalText$19(input.sessionId);
|
|
20454
21040
|
const descriptor = await session.openSession({
|
|
20455
|
-
requestedModelId: normalizeOptionalText$
|
|
21041
|
+
requestedModelId: normalizeOptionalText$19(input.conversationPolicy?.model),
|
|
20456
21042
|
sessionId: deliveryScope ? null : existingSessionId
|
|
20457
21043
|
});
|
|
20458
21044
|
await verifyOptionalDeliveryScope(deliveryScope, session, descriptor.sessionId);
|
|
@@ -20460,8 +21046,8 @@ async function invokeGrokBuildAcpTransport(input) {
|
|
|
20460
21046
|
session.emitProviderConversationObserved(continuitySessionId);
|
|
20461
21047
|
await session.applyModelSelection({
|
|
20462
21048
|
descriptor,
|
|
20463
|
-
reasoningEffort: normalizeOptionalText$
|
|
20464
|
-
requestedModelId: normalizeOptionalText$
|
|
21049
|
+
reasoningEffort: normalizeOptionalText$19(input.conversationPolicy?.reasoningLevel),
|
|
21050
|
+
requestedModelId: normalizeOptionalText$19(input.conversationPolicy?.model)
|
|
20465
21051
|
});
|
|
20466
21052
|
const unregisterActiveTurn = input.onActiveTurn?.({
|
|
20467
21053
|
cancel: () => session.cancelAndCloseSession(descriptor.sessionId),
|
|
@@ -20693,7 +21279,7 @@ var GrokBuildAcpSession = class {
|
|
|
20693
21279
|
throw error;
|
|
20694
21280
|
}
|
|
20695
21281
|
const record = toRecord$2(result);
|
|
20696
|
-
const sessionId = normalizeOptionalText$
|
|
21282
|
+
const sessionId = normalizeOptionalText$19(record?.sessionId) ?? input.sessionId ?? null;
|
|
20697
21283
|
if (!sessionId) throw new GrokBuildAcpTransportError({
|
|
20698
21284
|
code: "protocol.invalid",
|
|
20699
21285
|
errorType: "adapter",
|
|
@@ -20808,7 +21394,7 @@ var GrokBuildAcpSession = class {
|
|
|
20808
21394
|
if (toolActivity) this.#emitRuntimeEvent(toolActivity);
|
|
20809
21395
|
}
|
|
20810
21396
|
async #handleClientRequest(request) {
|
|
20811
|
-
const requestSessionId = normalizeOptionalText$
|
|
21397
|
+
const requestSessionId = normalizeOptionalText$19(toRecord$2(request.params)?.sessionId);
|
|
20812
21398
|
if (!(this.#turnActive && requestSessionId !== null && this.#sessionId !== null && requestSessionId === this.#sessionId)) {
|
|
20813
21399
|
this.#recordInteractionFailure("interaction.session_mismatch", "interaction.session_mismatch: Grok Build requested input for a different session");
|
|
20814
21400
|
return { error: {
|
|
@@ -20924,10 +21510,10 @@ function buildSessionDescriptor(input) {
|
|
|
20924
21510
|
}
|
|
20925
21511
|
function readModelState(value) {
|
|
20926
21512
|
const record = toRecord$2(value);
|
|
20927
|
-
const currentModelId = normalizeOptionalText$
|
|
21513
|
+
const currentModelId = normalizeOptionalText$19(record?.currentModelId);
|
|
20928
21514
|
const models = (Array.isArray(record?.availableModels) ? record.availableModels : []).flatMap((candidate) => {
|
|
20929
21515
|
const model = toRecord$2(candidate);
|
|
20930
|
-
const modelId = normalizeOptionalText$
|
|
21516
|
+
const modelId = normalizeOptionalText$19(model?.modelId);
|
|
20931
21517
|
if (!modelId) return [];
|
|
20932
21518
|
const meta = toRecord$2(model?._meta);
|
|
20933
21519
|
const efforts = Array.isArray(meta?.reasoningEfforts) ? uniqueStrings(meta.reasoningEfforts.map((effort) => {
|
|
@@ -20935,8 +21521,8 @@ function readModelState(value) {
|
|
|
20935
21521
|
return record?.value ?? record?.id;
|
|
20936
21522
|
})) : [];
|
|
20937
21523
|
return [{
|
|
20938
|
-
currentEffort: normalizeOptionalText$
|
|
20939
|
-
displayName: normalizeOptionalText$
|
|
21524
|
+
currentEffort: normalizeOptionalText$19(meta?.reasoningEffort),
|
|
21525
|
+
displayName: normalizeOptionalText$19(model?.name) ?? modelId,
|
|
20940
21526
|
efforts,
|
|
20941
21527
|
modelId
|
|
20942
21528
|
}];
|
|
@@ -20978,10 +21564,10 @@ function buildModelNegotiationDiagnostics(input) {
|
|
|
20978
21564
|
}
|
|
20979
21565
|
function resolveNonInteractiveAuthMethod(initializeResult) {
|
|
20980
21566
|
const authMethodIds = (Array.isArray(initializeResult.authMethods) ? initializeResult.authMethods : []).flatMap((method) => {
|
|
20981
|
-
const methodId = normalizeOptionalText$
|
|
21567
|
+
const methodId = normalizeOptionalText$19(toRecord$2(method)?.id);
|
|
20982
21568
|
return methodId ? [methodId] : [];
|
|
20983
21569
|
});
|
|
20984
|
-
const preferred = normalizeOptionalText$
|
|
21570
|
+
const preferred = normalizeOptionalText$19(toRecord$2(initializeResult._meta)?.defaultAuthMethodId);
|
|
20985
21571
|
if (preferred && (/* @__PURE__ */ new Set(["cached_token", "xai.api_key"])).has(preferred) && authMethodIds.includes(preferred)) return preferred;
|
|
20986
21572
|
if (authMethodIds.includes("cached_token")) return "cached_token";
|
|
20987
21573
|
if (authMethodIds.includes("xai.api_key")) return "xai.api_key";
|
|
@@ -21026,7 +21612,7 @@ async function resolveCanonicalDirectory(value) {
|
|
|
21026
21612
|
}
|
|
21027
21613
|
}
|
|
21028
21614
|
function assertSuccessfulStopReason(value) {
|
|
21029
|
-
const stopReason = normalizeOptionalText$
|
|
21615
|
+
const stopReason = normalizeOptionalText$19(toRecord$2(value)?.stopReason);
|
|
21030
21616
|
if (!stopReason) throw new GrokBuildAcpTransportError({
|
|
21031
21617
|
code: "protocol.invalid",
|
|
21032
21618
|
errorType: "adapter",
|
|
@@ -21044,7 +21630,7 @@ async function emitFinalPreviewIfRequested(input) {
|
|
|
21044
21630
|
await input.onPreview({ text: input.output });
|
|
21045
21631
|
}
|
|
21046
21632
|
function toGrokBuildTransportError(error, stderr, diagnostics) {
|
|
21047
|
-
const combined = [toErrorMessage$9(error), normalizeOptionalText$
|
|
21633
|
+
const combined = [toErrorMessage$9(error), normalizeOptionalText$19(stderr)].filter((value) => value !== null).join("\n");
|
|
21048
21634
|
const providerFailure = !(error instanceof GrokBuildAcpTransportError) || error.code.startsWith("protocol.") ? classifyGrokBuildProviderFailure({
|
|
21049
21635
|
message: combined,
|
|
21050
21636
|
originalError: error instanceof GrokBuildAcpTransportError ? error.originalError : void 0
|
|
@@ -21068,7 +21654,7 @@ function toGrokBuildTransportError(error, stderr, diagnostics) {
|
|
|
21068
21654
|
const classified = new GrokBuildAcpTransportError({
|
|
21069
21655
|
code: "upstream_unreachable",
|
|
21070
21656
|
errorType: "adapter",
|
|
21071
|
-
message: `upstream_unreachable: ${normalizeOptionalText$
|
|
21657
|
+
message: `upstream_unreachable: ${normalizeOptionalText$19(combined) ?? "Grok Build ACP error"}`
|
|
21072
21658
|
});
|
|
21073
21659
|
return diagnostics ? new GrokBuildAcpTransportError({
|
|
21074
21660
|
cause: error,
|
|
@@ -21086,7 +21672,7 @@ function toGrokBuildJsonRpcTransportError(error) {
|
|
|
21086
21672
|
code = "protocol.invalid_params";
|
|
21087
21673
|
errorType = "config";
|
|
21088
21674
|
}
|
|
21089
|
-
const message = normalizeOptionalText$
|
|
21675
|
+
const message = normalizeOptionalText$19(error.message) ?? "ACP request failed";
|
|
21090
21676
|
const originalError = createProviderOriginalError(message);
|
|
21091
21677
|
return new GrokBuildAcpTransportError({
|
|
21092
21678
|
code,
|
|
@@ -21096,7 +21682,7 @@ function toGrokBuildJsonRpcTransportError(error) {
|
|
|
21096
21682
|
});
|
|
21097
21683
|
}
|
|
21098
21684
|
function classifyGrokBuildProviderFailure(input) {
|
|
21099
|
-
const normalized = normalizeOptionalText$
|
|
21685
|
+
const normalized = normalizeOptionalText$19(input.message) ?? "Grok Build ACP error";
|
|
21100
21686
|
if (AUTH_FAILURE_RE.test(normalized)) return new GrokBuildAcpTransportError({
|
|
21101
21687
|
code: "auth.failed",
|
|
21102
21688
|
errorType: "auth",
|
|
@@ -21121,12 +21707,12 @@ function haveSameStrings(left, right) {
|
|
|
21121
21707
|
return left.length === right.length && left.every((value) => right.includes(value));
|
|
21122
21708
|
}
|
|
21123
21709
|
function uniqueStrings(values) {
|
|
21124
|
-
return [...new Set(values.map(normalizeOptionalText$
|
|
21710
|
+
return [...new Set(values.map(normalizeOptionalText$19).filter((value) => value !== null))];
|
|
21125
21711
|
}
|
|
21126
21712
|
function normalizeOutputText$1(value) {
|
|
21127
21713
|
return typeof value === "string" && value.length > 0 ? value : null;
|
|
21128
21714
|
}
|
|
21129
|
-
function normalizeOptionalText$
|
|
21715
|
+
function normalizeOptionalText$19(value) {
|
|
21130
21716
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
21131
21717
|
return normalized.length > 0 ? normalized : null;
|
|
21132
21718
|
}
|
|
@@ -21197,7 +21783,7 @@ function createDefaultGrokBuildInvoke(input) {
|
|
|
21197
21783
|
});
|
|
21198
21784
|
} : void 0;
|
|
21199
21785
|
const result = await invokeWithSingleContextHeal({
|
|
21200
|
-
contextId: normalizeOptionalText$
|
|
21786
|
+
contextId: normalizeOptionalText$18(dispatchInput.agentControllerConversationId),
|
|
21201
21787
|
contextLossPolicy: dispatchInput.executionMode === "repair" ? "fail" : "rebuild",
|
|
21202
21788
|
createRebuildFailedError: (error) => new GrokBuildAcpTransportError({
|
|
21203
21789
|
cause: error,
|
|
@@ -21252,7 +21838,7 @@ function createDefaultGrokBuildInvoke(input) {
|
|
|
21252
21838
|
};
|
|
21253
21839
|
}
|
|
21254
21840
|
async function resolveGrokBuildDispatchLaunchContract(input) {
|
|
21255
|
-
const commandPath = normalizeOptionalText$
|
|
21841
|
+
const commandPath = normalizeOptionalText$18(input.grokBuildBin);
|
|
21256
21842
|
const launchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (commandPath ? buildExecutableLaunchContract({ commandPath }) : null);
|
|
21257
21843
|
if (!launchContract) throw Object.assign(/* @__PURE__ */ new Error("Grok Build launch contract is required for runtime dispatch."), {
|
|
21258
21844
|
code: "controller.launch.needs_repair",
|
|
@@ -21311,7 +21897,7 @@ async function interruptActiveGrokBuildTurn(input) {
|
|
|
21311
21897
|
taskId: result.taskId
|
|
21312
21898
|
};
|
|
21313
21899
|
}
|
|
21314
|
-
function normalizeOptionalText$
|
|
21900
|
+
function normalizeOptionalText$18(value) {
|
|
21315
21901
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
21316
21902
|
return normalized.length > 0 ? normalized : null;
|
|
21317
21903
|
}
|
|
@@ -21338,7 +21924,7 @@ const DEFAULT_OPENCLAW_AGENT_ID = "main";
|
|
|
21338
21924
|
async function resolveInstalledOpenClawLaunchCandidates(input) {
|
|
21339
21925
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
21340
21926
|
commandName: DEFAULT_OPENCLAW_COMMAND,
|
|
21341
|
-
configuredCommand: normalizeOptionalText$
|
|
21927
|
+
configuredCommand: normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_BIN),
|
|
21342
21928
|
displayName: "OpenClaw",
|
|
21343
21929
|
preferredLaunchContract: input?.preferredLaunchContract
|
|
21344
21930
|
});
|
|
@@ -21372,9 +21958,9 @@ async function verifyOpenClawLaunchContract(input) {
|
|
|
21372
21958
|
}
|
|
21373
21959
|
function resolveOpenClawBinCandidates(explicitOpenClawBin) {
|
|
21374
21960
|
const candidates = [];
|
|
21375
|
-
const explicitCandidate = normalizeOptionalText$
|
|
21961
|
+
const explicitCandidate = normalizeOptionalText$17(explicitOpenClawBin);
|
|
21376
21962
|
if (explicitCandidate) candidates.push(explicitCandidate);
|
|
21377
|
-
const configuredCandidate = normalizeOptionalText$
|
|
21963
|
+
const configuredCandidate = normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_BIN);
|
|
21378
21964
|
if (configuredCandidate && !candidates.includes(configuredCandidate)) candidates.push(configuredCandidate);
|
|
21379
21965
|
const nodeSiblingCandidate = resolveSiblingCommandPath({
|
|
21380
21966
|
anchorPath: process.execPath,
|
|
@@ -21390,16 +21976,16 @@ function resolveOpenClawBinCandidates(explicitOpenClawBin) {
|
|
|
21390
21976
|
return candidates;
|
|
21391
21977
|
}
|
|
21392
21978
|
function resolveOpenClawTimeoutMs() {
|
|
21393
|
-
const raw = normalizeOptionalText$
|
|
21979
|
+
const raw = normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
21394
21980
|
if (!raw) return null;
|
|
21395
21981
|
const parsed = Number.parseInt(raw, 10);
|
|
21396
21982
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
21397
21983
|
return parsed;
|
|
21398
21984
|
}
|
|
21399
21985
|
function resolveOpenClawAgentId$1() {
|
|
21400
|
-
return normalizeOptionalText$
|
|
21986
|
+
return normalizeOptionalText$17(process.env.OPENMELD_DAEMON_RUNTIME_OPENCLAW_AGENT_ID) ?? DEFAULT_OPENCLAW_AGENT_ID;
|
|
21401
21987
|
}
|
|
21402
|
-
function normalizeOptionalText$
|
|
21988
|
+
function normalizeOptionalText$17(value) {
|
|
21403
21989
|
const normalized = String(value ?? "").trim();
|
|
21404
21990
|
return normalized.length > 0 ? normalized : null;
|
|
21405
21991
|
}
|
|
@@ -21469,10 +22055,10 @@ function parseOpenClawOutputLine(line) {
|
|
|
21469
22055
|
}
|
|
21470
22056
|
const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
21471
22057
|
if (!record) return null;
|
|
21472
|
-
const isErrorResult = resolveIsErrorResult
|
|
21473
|
-
const errorMessage = resolveErrorMessage
|
|
21474
|
-
const resultText = resolveResultText
|
|
21475
|
-
const sessionId = resolveSessionId
|
|
22058
|
+
const isErrorResult = resolveIsErrorResult(record);
|
|
22059
|
+
const errorMessage = resolveErrorMessage(record, isErrorResult);
|
|
22060
|
+
const resultText = resolveResultText(record, isErrorResult);
|
|
22061
|
+
const sessionId = resolveSessionId(record);
|
|
21476
22062
|
if (!errorMessage && resultText === null && sessionId === null) return null;
|
|
21477
22063
|
return {
|
|
21478
22064
|
errorMessage,
|
|
@@ -21493,8 +22079,8 @@ function parseOpenClawOutputDocument(text) {
|
|
|
21493
22079
|
}
|
|
21494
22080
|
const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
21495
22081
|
if (!record) return null;
|
|
21496
|
-
const isErrorResult = resolveIsErrorResult
|
|
21497
|
-
const errorMessage = resolveErrorMessage
|
|
22082
|
+
const isErrorResult = resolveIsErrorResult(record);
|
|
22083
|
+
const errorMessage = resolveErrorMessage(record, isErrorResult);
|
|
21498
22084
|
const outputText = resolveDocumentOutputText(record, isErrorResult);
|
|
21499
22085
|
const sessionId = resolveDocumentSessionId(record);
|
|
21500
22086
|
if (!errorMessage && outputText === null && sessionId === null) return null;
|
|
@@ -21505,11 +22091,11 @@ function parseOpenClawOutputDocument(text) {
|
|
|
21505
22091
|
sessionId
|
|
21506
22092
|
};
|
|
21507
22093
|
}
|
|
21508
|
-
function resolveSessionId
|
|
21509
|
-
return resolveStringByPaths
|
|
22094
|
+
function resolveSessionId(record) {
|
|
22095
|
+
return resolveStringByPaths(record, OPENCLAW_SESSION_ID_PATHS);
|
|
21510
22096
|
}
|
|
21511
22097
|
function resolveDocumentSessionId(record) {
|
|
21512
|
-
return resolveStringByPaths
|
|
22098
|
+
return resolveStringByPaths(record, [
|
|
21513
22099
|
...OPENCLAW_SESSION_ID_PATHS,
|
|
21514
22100
|
[
|
|
21515
22101
|
"meta",
|
|
@@ -21519,35 +22105,35 @@ function resolveDocumentSessionId(record) {
|
|
|
21519
22105
|
["meta", "sessionId"]
|
|
21520
22106
|
]) ?? null;
|
|
21521
22107
|
}
|
|
21522
|
-
function resolveResultText
|
|
22108
|
+
function resolveResultText(record, isErrorResult) {
|
|
21523
22109
|
if (isErrorResult === true) return null;
|
|
21524
|
-
return resolveStringByPaths
|
|
22110
|
+
return resolveStringByPaths(record, OPENCLAW_RESULT_TEXT_PATHS);
|
|
21525
22111
|
}
|
|
21526
22112
|
function resolveDocumentOutputText(record, isErrorResult) {
|
|
21527
22113
|
if (isErrorResult === true) return null;
|
|
21528
22114
|
const payloadText = resolvePayloadsText(record.payloads);
|
|
21529
22115
|
if (payloadText) return payloadText;
|
|
21530
|
-
return resolveResultText
|
|
22116
|
+
return resolveResultText(record, isErrorResult);
|
|
21531
22117
|
}
|
|
21532
|
-
function resolveErrorMessage
|
|
22118
|
+
function resolveErrorMessage(record, isErrorResult) {
|
|
21533
22119
|
if (isErrorResult !== true) return null;
|
|
21534
|
-
return resolveStringByPaths
|
|
22120
|
+
return resolveStringByPaths(record, OPENCLAW_ERROR_MESSAGE_PATHS) ?? resolveStringByPaths(record, OPENCLAW_RESULT_TEXT_PATHS);
|
|
21535
22121
|
}
|
|
21536
|
-
function resolveIsErrorResult
|
|
22122
|
+
function resolveIsErrorResult(record) {
|
|
21537
22123
|
if (typeof record.is_error === "boolean") return record.is_error;
|
|
21538
22124
|
if (typeof record.isError === "boolean") return record.isError;
|
|
21539
22125
|
if (typeof record.ok === "boolean") return !record.ok;
|
|
21540
22126
|
if (typeof record.success === "boolean") return !record.success;
|
|
21541
|
-
const status = normalizeOptionalText$
|
|
22127
|
+
const status = normalizeOptionalText$16(record.status)?.toLowerCase();
|
|
21542
22128
|
if (status === "error" || status === "failed" || status === "fail") return true;
|
|
21543
22129
|
if (status === "ok" || status === "success" || status === "completed") return false;
|
|
21544
|
-
const type = normalizeOptionalText$
|
|
22130
|
+
const type = normalizeOptionalText$16(record.type)?.toLowerCase();
|
|
21545
22131
|
if (type === "error" || type === "failure") return true;
|
|
21546
22132
|
if (type === "result" || type === "success") return false;
|
|
21547
22133
|
if (record.error !== void 0 || record.errors !== void 0) return true;
|
|
21548
22134
|
return null;
|
|
21549
22135
|
}
|
|
21550
|
-
function resolveStringByPaths
|
|
22136
|
+
function resolveStringByPaths(record, paths) {
|
|
21551
22137
|
for (const path of paths) {
|
|
21552
22138
|
const normalized = normalizeCandidateValue(getByPath(record, path));
|
|
21553
22139
|
if (normalized) return normalized;
|
|
@@ -21590,7 +22176,7 @@ function normalizeCandidateValue(value) {
|
|
|
21590
22176
|
}
|
|
21591
22177
|
return null;
|
|
21592
22178
|
}
|
|
21593
|
-
function normalizeOptionalText$
|
|
22179
|
+
function normalizeOptionalText$16(value) {
|
|
21594
22180
|
const normalized = String(value ?? "").trim();
|
|
21595
22181
|
return normalized.length > 0 ? normalized : null;
|
|
21596
22182
|
}
|
|
@@ -21648,7 +22234,7 @@ function classifyOpenClawFailureMessage(input) {
|
|
|
21648
22234
|
});
|
|
21649
22235
|
}
|
|
21650
22236
|
function normalizeOpenClawFailureMessage(value) {
|
|
21651
|
-
const normalized = normalizeOptionalText$
|
|
22237
|
+
const normalized = normalizeOptionalText$15(value);
|
|
21652
22238
|
if (!normalized) return null;
|
|
21653
22239
|
return extractJsonFailureDetail(normalized) ?? normalized;
|
|
21654
22240
|
}
|
|
@@ -21657,7 +22243,7 @@ function extractJsonFailureDetail(value) {
|
|
|
21657
22243
|
const parsed = JSON.parse(value);
|
|
21658
22244
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
21659
22245
|
const record = parsed;
|
|
21660
|
-
return normalizeOptionalText$
|
|
22246
|
+
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
22247
|
} catch {
|
|
21662
22248
|
return null;
|
|
21663
22249
|
}
|
|
@@ -21677,7 +22263,7 @@ function isRateLimitFailure(value) {
|
|
|
21677
22263
|
function isInputSelectorFailure(value) {
|
|
21678
22264
|
return value.includes("pass --to") && value.includes("--session-id") && value.includes("--agent") || value.includes("unknown agent") || value.includes("agent not found");
|
|
21679
22265
|
}
|
|
21680
|
-
function normalizeOptionalText$
|
|
22266
|
+
function normalizeOptionalText$15(value) {
|
|
21681
22267
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
21682
22268
|
return normalized.length > 0 ? normalized : null;
|
|
21683
22269
|
}
|
|
@@ -21696,7 +22282,7 @@ var OpenClawCliTransportError = class extends Error {
|
|
|
21696
22282
|
}
|
|
21697
22283
|
};
|
|
21698
22284
|
async function invokeOpenClawCliTransport(input) {
|
|
21699
|
-
const prompt = normalizeOptionalText$
|
|
22285
|
+
const prompt = normalizeOptionalText$14(input.prompt);
|
|
21700
22286
|
if (!prompt) throw new OpenClawCliTransportError({
|
|
21701
22287
|
code: "schema.invalid",
|
|
21702
22288
|
errorType: "config",
|
|
@@ -21705,7 +22291,7 @@ async function invokeOpenClawCliTransport(input) {
|
|
|
21705
22291
|
const { args, sessionId: initialSessionId } = buildOpenClawArgs({
|
|
21706
22292
|
openClawAgentId: input.openClawAgentId,
|
|
21707
22293
|
prompt,
|
|
21708
|
-
sessionId: normalizeOptionalText$
|
|
22294
|
+
sessionId: normalizeOptionalText$14(input.sessionId)
|
|
21709
22295
|
});
|
|
21710
22296
|
const invocation = buildCliLaunchInvocation({
|
|
21711
22297
|
args,
|
|
@@ -21731,13 +22317,13 @@ async function invokeOpenClawCliTransport(input) {
|
|
|
21731
22317
|
onProcessControlEvent: input.onProcessControlEvent,
|
|
21732
22318
|
onStderrLine: (event) => {
|
|
21733
22319
|
if (firstStderrAtMs === null) firstStderrAtMs = Date.now();
|
|
21734
|
-
collectProviderErrorMessage
|
|
22320
|
+
collectProviderErrorMessage(event.line, providerErrorMessages);
|
|
21735
22321
|
},
|
|
21736
22322
|
onStdoutLine: (event) => {
|
|
21737
22323
|
if (firstStdoutAtMs === null) firstStdoutAtMs = Date.now();
|
|
21738
22324
|
const parsedLine = parseOpenClawOutputLine(event.line);
|
|
21739
22325
|
if (!parsedLine) {
|
|
21740
|
-
collectRuntimePermissionDenialMessage
|
|
22326
|
+
collectRuntimePermissionDenialMessage(event.line, providerErrorMessages);
|
|
21741
22327
|
return;
|
|
21742
22328
|
}
|
|
21743
22329
|
if (parsedLine.resultText) latestOutput = parsedLine.resultText;
|
|
@@ -21782,7 +22368,7 @@ async function invokeOpenClawCliTransport(input) {
|
|
|
21782
22368
|
stdoutText: driverResult.stdoutText
|
|
21783
22369
|
}));
|
|
21784
22370
|
}
|
|
21785
|
-
const output = normalizeOptionalText$
|
|
22371
|
+
const output = normalizeOptionalText$14(latestOutput);
|
|
21786
22372
|
if (!output) {
|
|
21787
22373
|
const fallbackOutput = resolveSuccessFallbackOutput(driverResult.stdoutText);
|
|
21788
22374
|
if (!fallbackOutput) {
|
|
@@ -21800,25 +22386,25 @@ async function invokeOpenClawCliTransport(input) {
|
|
|
21800
22386
|
}
|
|
21801
22387
|
return {
|
|
21802
22388
|
output: fallbackOutput,
|
|
21803
|
-
sessionId: normalizeOptionalText$
|
|
21804
|
-
telemetry: buildTransportTelemetry
|
|
22389
|
+
sessionId: normalizeOptionalText$14(resolvedSessionId),
|
|
22390
|
+
telemetry: buildTransportTelemetry({
|
|
21805
22391
|
driverResult,
|
|
21806
22392
|
firstStderrAtMs,
|
|
21807
22393
|
firstStdoutAtMs,
|
|
21808
22394
|
invokedAtMs,
|
|
21809
|
-
resumedContext: normalizeOptionalText$
|
|
22395
|
+
resumedContext: normalizeOptionalText$14(input.sessionId) !== null
|
|
21810
22396
|
})
|
|
21811
22397
|
};
|
|
21812
22398
|
}
|
|
21813
22399
|
return {
|
|
21814
22400
|
output,
|
|
21815
|
-
sessionId: normalizeOptionalText$
|
|
21816
|
-
telemetry: buildTransportTelemetry
|
|
22401
|
+
sessionId: normalizeOptionalText$14(resolvedSessionId),
|
|
22402
|
+
telemetry: buildTransportTelemetry({
|
|
21817
22403
|
driverResult,
|
|
21818
22404
|
firstStderrAtMs,
|
|
21819
22405
|
firstStdoutAtMs,
|
|
21820
22406
|
invokedAtMs,
|
|
21821
|
-
resumedContext: normalizeOptionalText$
|
|
22407
|
+
resumedContext: normalizeOptionalText$14(input.sessionId) !== null
|
|
21822
22408
|
})
|
|
21823
22409
|
};
|
|
21824
22410
|
}
|
|
@@ -21837,7 +22423,7 @@ const buildOpenClawArgs = (input) => {
|
|
|
21837
22423
|
sessionId
|
|
21838
22424
|
};
|
|
21839
22425
|
};
|
|
21840
|
-
const buildTransportTelemetry
|
|
22426
|
+
const buildTransportTelemetry = (input) => ({
|
|
21841
22427
|
completedAtMs: Date.now(),
|
|
21842
22428
|
...input.driverResult.lifecycle.exitCode === null ? {} : { exitCode: input.driverResult.lifecycle.exitCode },
|
|
21843
22429
|
...input.driverResult.lifecycle.exitObservedAtMs === null ? {} : { exitObservedAtMs: input.driverResult.lifecycle.exitObservedAtMs },
|
|
@@ -21878,14 +22464,14 @@ const toOpenClawCliTransportError = (error, timeoutMs) => {
|
|
|
21878
22464
|
});
|
|
21879
22465
|
};
|
|
21880
22466
|
const classifyOpenClawFailure = (input) => {
|
|
21881
|
-
const trustedProviderMessages = /* @__PURE__ */ new Set([...input.providerOriginalErrorMessages ?? [], ...extractErrorMessagesFromStdout
|
|
21882
|
-
const providerMessage = resolveProviderFailureMessage
|
|
22467
|
+
const trustedProviderMessages = /* @__PURE__ */ new Set([...input.providerOriginalErrorMessages ?? [], ...extractErrorMessagesFromStdout(input.stdoutText)]);
|
|
22468
|
+
const providerMessage = resolveProviderFailureMessage(input);
|
|
21883
22469
|
if (providerMessage) return classifyOpenClawFailureMessage({
|
|
21884
22470
|
includeOriginalError: trustedProviderMessages.has(providerMessage),
|
|
21885
22471
|
isContextLost: isLikelyOpenClawContextLostError,
|
|
21886
22472
|
message: providerMessage
|
|
21887
22473
|
});
|
|
21888
|
-
const stderrText = normalizeOptionalText$
|
|
22474
|
+
const stderrText = normalizeOptionalText$14(input.stderrText);
|
|
21889
22475
|
if (stderrText) return {
|
|
21890
22476
|
code: "upstream_unreachable",
|
|
21891
22477
|
errorType: "adapter",
|
|
@@ -21893,17 +22479,17 @@ const classifyOpenClawFailure = (input) => {
|
|
|
21893
22479
|
};
|
|
21894
22480
|
return { ...buildProviderExitError({ providerLabel: "openclaw" }) };
|
|
21895
22481
|
};
|
|
21896
|
-
const resolveProviderFailureMessage
|
|
22482
|
+
const resolveProviderFailureMessage = (input) => {
|
|
21897
22483
|
const candidateMessages = [
|
|
21898
22484
|
...input.providerErrorMessages,
|
|
21899
|
-
...extractErrorMessagesFromStdout
|
|
21900
|
-
...normalizeOptionalText$
|
|
22485
|
+
...extractErrorMessagesFromStdout(input.stdoutText),
|
|
22486
|
+
...normalizeOptionalText$14(input.stderrText) ? [normalizeOptionalText$14(input.stderrText)] : []
|
|
21901
22487
|
].filter((value) => Boolean(value));
|
|
21902
|
-
for (const candidate of candidateMessages) if (looksLikeRuntimePermissionDenialMessage(candidate) || looksLikeProviderFailure
|
|
22488
|
+
for (const candidate of candidateMessages) if (looksLikeRuntimePermissionDenialMessage(candidate) || looksLikeProviderFailure(candidate)) return candidate;
|
|
21903
22489
|
return candidateMessages[0] ?? null;
|
|
21904
22490
|
};
|
|
21905
|
-
const extractErrorMessagesFromStdout
|
|
21906
|
-
const stdoutText = normalizeOptionalText$
|
|
22491
|
+
const extractErrorMessagesFromStdout = (value) => {
|
|
22492
|
+
const stdoutText = normalizeOptionalText$14(value);
|
|
21907
22493
|
if (!stdoutText) return [];
|
|
21908
22494
|
const messages = [];
|
|
21909
22495
|
const lines = stdoutText.split("\n");
|
|
@@ -21914,7 +22500,7 @@ const extractErrorMessagesFromStdout$1 = (value) => {
|
|
|
21914
22500
|
return messages;
|
|
21915
22501
|
};
|
|
21916
22502
|
const resolveSuccessFallbackOutput = (value) => {
|
|
21917
|
-
const stdoutText = normalizeOptionalText$
|
|
22503
|
+
const stdoutText = normalizeOptionalText$14(value);
|
|
21918
22504
|
if (!stdoutText) return null;
|
|
21919
22505
|
const lines = stdoutText.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
21920
22506
|
if (lines.length !== 1) return null;
|
|
@@ -21923,24 +22509,24 @@ const resolveSuccessFallbackOutput = (value) => {
|
|
|
21923
22509
|
if (singleLine.startsWith("{") || singleLine.startsWith("[")) return null;
|
|
21924
22510
|
return singleLine;
|
|
21925
22511
|
};
|
|
21926
|
-
const collectProviderErrorMessage
|
|
21927
|
-
const normalized = normalizeOptionalText$
|
|
22512
|
+
const collectProviderErrorMessage = (line, output) => {
|
|
22513
|
+
const normalized = normalizeOptionalText$14(line);
|
|
21928
22514
|
if (!normalized) return;
|
|
21929
22515
|
output.push(normalized);
|
|
21930
22516
|
};
|
|
21931
|
-
const collectRuntimePermissionDenialMessage
|
|
21932
|
-
const normalized = normalizeOptionalText$
|
|
22517
|
+
const collectRuntimePermissionDenialMessage = (line, output) => {
|
|
22518
|
+
const normalized = normalizeOptionalText$14(line);
|
|
21933
22519
|
if (!(normalized && looksLikeRuntimePermissionDenialMessage(normalized))) return;
|
|
21934
22520
|
output.push(normalized);
|
|
21935
22521
|
};
|
|
21936
|
-
const looksLikeProviderFailure
|
|
22522
|
+
const looksLikeProviderFailure = (value) => {
|
|
21937
22523
|
const lowered = value.toLowerCase();
|
|
21938
22524
|
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
22525
|
};
|
|
21940
22526
|
function normalizeText$2(value) {
|
|
21941
22527
|
return String(value ?? "").trim();
|
|
21942
22528
|
}
|
|
21943
|
-
function normalizeOptionalText$
|
|
22529
|
+
function normalizeOptionalText$14(value) {
|
|
21944
22530
|
const normalized = normalizeText$2(value);
|
|
21945
22531
|
return normalized.length > 0 ? normalized : null;
|
|
21946
22532
|
}
|
|
@@ -22072,15 +22658,15 @@ async function readSessionIndex(input) {
|
|
|
22072
22658
|
}
|
|
22073
22659
|
}
|
|
22074
22660
|
function resolveOpenClawStateDir(env) {
|
|
22075
|
-
const configuredStateDir = normalizeOptionalText$
|
|
22661
|
+
const configuredStateDir = normalizeOptionalText$13(env?.OPENCLAW_STATE_DIR);
|
|
22076
22662
|
if (configuredStateDir) return configuredStateDir;
|
|
22077
22663
|
return join(homedir(), ".openclaw");
|
|
22078
22664
|
}
|
|
22079
22665
|
function resolveSessionFilePath(input) {
|
|
22080
22666
|
const sessionsDir = join(resolveOpenClawStateDir(input.env), "agents", input.agentId, "sessions");
|
|
22081
|
-
const sessionFile = normalizeOptionalText$
|
|
22667
|
+
const sessionFile = normalizeOptionalText$13(input.sessionEntry.sessionFile);
|
|
22082
22668
|
if (sessionFile) return isAbsolute(sessionFile) ? sessionFile : join(sessionsDir, sessionFile);
|
|
22083
|
-
const sessionId = normalizeOptionalText$
|
|
22669
|
+
const sessionId = normalizeOptionalText$13(input.sessionEntry.sessionId);
|
|
22084
22670
|
if (!sessionId) return null;
|
|
22085
22671
|
return join(sessionsDir, `${sessionId}.jsonl`);
|
|
22086
22672
|
}
|
|
@@ -22101,11 +22687,11 @@ function parseSessionErrorRecord(line) {
|
|
|
22101
22687
|
const parsed = JSON.parse(line);
|
|
22102
22688
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
22103
22689
|
const record = parsed;
|
|
22104
|
-
if (normalizeOptionalText$
|
|
22690
|
+
if (normalizeOptionalText$13(record.type) !== "message") return null;
|
|
22105
22691
|
const message = record.message && typeof record.message === "object" ? record.message : null;
|
|
22106
22692
|
if (!message) return null;
|
|
22107
|
-
if (normalizeOptionalText$
|
|
22108
|
-
const errorMessage = normalizeOptionalText$
|
|
22693
|
+
if (normalizeOptionalText$13(message.stopReason) !== "error") return null;
|
|
22694
|
+
const errorMessage = normalizeOptionalText$13(message.errorMessage);
|
|
22109
22695
|
if (!errorMessage) return null;
|
|
22110
22696
|
const messageTimestampMs = normalizeOptionalNumber(message.timestamp) ?? normalizeIsoTimestampMs(record.timestamp);
|
|
22111
22697
|
if (messageTimestampMs === null) return null;
|
|
@@ -22118,7 +22704,7 @@ function parseSessionErrorRecord(line) {
|
|
|
22118
22704
|
}
|
|
22119
22705
|
}
|
|
22120
22706
|
function normalizeIsoTimestampMs(value) {
|
|
22121
|
-
const normalized = normalizeOptionalText$
|
|
22707
|
+
const normalized = normalizeOptionalText$13(value);
|
|
22122
22708
|
if (!normalized) return null;
|
|
22123
22709
|
const parsed = Date.parse(normalized);
|
|
22124
22710
|
return Number.isFinite(parsed) ? parsed : null;
|
|
@@ -22126,7 +22712,7 @@ function normalizeIsoTimestampMs(value) {
|
|
|
22126
22712
|
function normalizeOptionalNumber(value) {
|
|
22127
22713
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
22128
22714
|
}
|
|
22129
|
-
function normalizeOptionalText$
|
|
22715
|
+
function normalizeOptionalText$13(value) {
|
|
22130
22716
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
22131
22717
|
return normalized.length > 0 ? normalized : null;
|
|
22132
22718
|
}
|
|
@@ -22147,8 +22733,8 @@ var OpenClawGatewayTransportError = class extends Error {
|
|
|
22147
22733
|
}
|
|
22148
22734
|
};
|
|
22149
22735
|
async function invokeOpenClawGatewayTransport(input) {
|
|
22150
|
-
const prompt = normalizeOptionalText$
|
|
22151
|
-
const sessionKey = normalizeOptionalText$
|
|
22736
|
+
const prompt = normalizeOptionalText$12(input.prompt);
|
|
22737
|
+
const sessionKey = normalizeOptionalText$12(input.sessionKey);
|
|
22152
22738
|
if (!prompt) throw new OpenClawGatewayTransportError({
|
|
22153
22739
|
code: "schema.invalid",
|
|
22154
22740
|
errorType: "config",
|
|
@@ -22261,9 +22847,9 @@ function normalizeOpenClawGatewayAgentResult(result, expectedSessionKey) {
|
|
|
22261
22847
|
message: "upstream_unreachable: openclaw gateway returned a non-object payload for agent"
|
|
22262
22848
|
});
|
|
22263
22849
|
const record = result;
|
|
22264
|
-
const status = normalizeOptionalText$
|
|
22850
|
+
const status = normalizeOptionalText$12(record.status);
|
|
22265
22851
|
if (!status || status === "ok") return extractSuccessfulAgentResult(record.result, expectedSessionKey);
|
|
22266
|
-
throw classifyGatewayFailure(normalizeOptionalText$
|
|
22852
|
+
throw classifyGatewayFailure(normalizeOptionalText$12(record.summary) ?? normalizeOptionalText$12(record.error) ?? `openclaw gateway agent returned status '${status}'`, true);
|
|
22267
22853
|
}
|
|
22268
22854
|
function extractSuccessfulAgentResult(result, expectedSessionKey) {
|
|
22269
22855
|
if (!result || typeof result !== "object") throw new OpenClawGatewayTransportError({
|
|
@@ -22288,7 +22874,7 @@ function normalizeAgentMeta(meta, expectedSessionKey) {
|
|
|
22288
22874
|
const record = meta;
|
|
22289
22875
|
const systemPromptReport = record.systemPromptReport;
|
|
22290
22876
|
if (systemPromptReport && typeof systemPromptReport === "object") {
|
|
22291
|
-
const actualSessionKey = normalizeOptionalText$
|
|
22877
|
+
const actualSessionKey = normalizeOptionalText$12(systemPromptReport.sessionKey);
|
|
22292
22878
|
if (actualSessionKey && actualSessionKey !== expectedSessionKey) throw new OpenClawGatewayTransportError({
|
|
22293
22879
|
code: "upstream_unreachable",
|
|
22294
22880
|
errorType: "adapter",
|
|
@@ -22296,15 +22882,15 @@ function normalizeAgentMeta(meta, expectedSessionKey) {
|
|
|
22296
22882
|
});
|
|
22297
22883
|
}
|
|
22298
22884
|
const agentMeta = record.agentMeta;
|
|
22299
|
-
const agentSessionId = agentMeta && typeof agentMeta === "object" ? normalizeOptionalText$
|
|
22300
|
-
const reportSessionId = systemPromptReport && typeof systemPromptReport === "object" ? normalizeOptionalText$
|
|
22885
|
+
const agentSessionId = agentMeta && typeof agentMeta === "object" ? normalizeOptionalText$12(agentMeta.sessionId) : null;
|
|
22886
|
+
const reportSessionId = systemPromptReport && typeof systemPromptReport === "object" ? normalizeOptionalText$12(systemPromptReport.sessionId) : null;
|
|
22301
22887
|
return { sessionId: agentSessionId ?? reportSessionId };
|
|
22302
22888
|
}
|
|
22303
22889
|
function extractAgentPayloadText(payloads) {
|
|
22304
22890
|
if (!Array.isArray(payloads)) return null;
|
|
22305
22891
|
for (const payload of payloads) {
|
|
22306
22892
|
if (!payload || typeof payload !== "object") continue;
|
|
22307
|
-
const text = normalizeOptionalText$
|
|
22893
|
+
const text = normalizeOptionalText$12(payload.text);
|
|
22308
22894
|
if (text) return text;
|
|
22309
22895
|
}
|
|
22310
22896
|
return null;
|
|
@@ -22316,8 +22902,8 @@ function toOpenClawGatewayTransportError(error) {
|
|
|
22316
22902
|
errorType: "adapter",
|
|
22317
22903
|
message: "upstream_unreachable: openclaw is not installed or not on PATH"
|
|
22318
22904
|
});
|
|
22319
|
-
const stderr = normalizeOptionalText$
|
|
22320
|
-
const stdout = normalizeOptionalText$
|
|
22905
|
+
const stderr = normalizeOptionalText$12(error?.stderr);
|
|
22906
|
+
const stdout = normalizeOptionalText$12(error?.stdout);
|
|
22321
22907
|
return classifyGatewayFailure(stderr ?? stdout ?? toErrorMessage$6(error), false);
|
|
22322
22908
|
}
|
|
22323
22909
|
function classifyGatewayFailure(message, includeOriginalError) {
|
|
@@ -22326,7 +22912,7 @@ function classifyGatewayFailure(message, includeOriginalError) {
|
|
|
22326
22912
|
message
|
|
22327
22913
|
}));
|
|
22328
22914
|
}
|
|
22329
|
-
function normalizeOptionalText$
|
|
22915
|
+
function normalizeOptionalText$12(value) {
|
|
22330
22916
|
const normalized = String(value ?? "").trim();
|
|
22331
22917
|
return normalized.length > 0 ? normalized : null;
|
|
22332
22918
|
}
|
|
@@ -22699,7 +23285,7 @@ function record$2(value) {
|
|
|
22699
23285
|
const OPENCLAW_CONVERSATION_BRIDGE_SPEC = resolveBuiltinAdapterConversationBridgeSpec("openclaw");
|
|
22700
23286
|
const resolveOpenClawSessionConversation = (agentControllerConversation) => {
|
|
22701
23287
|
if (!agentControllerConversation) return null;
|
|
22702
|
-
const agentControllerConversationId = normalizeOptionalText$
|
|
23288
|
+
const agentControllerConversationId = normalizeOptionalText$11(agentControllerConversation.agentControllerConversationId);
|
|
22703
23289
|
if (!agentControllerConversationId) throw new Error("conversation.bridge.agent_controller_conversation_id_missing: expected builtin:openclaw session agentControllerConversationId");
|
|
22704
23290
|
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
23291
|
return buildAdapterAgentControllerConversationRef({
|
|
@@ -22712,7 +23298,7 @@ const resolveOpenClawInvokeRequest = (input) => {
|
|
|
22712
23298
|
const agentControllerConversation = resolveOpenClawSessionConversation(input.request.agentControllerConversation);
|
|
22713
23299
|
return {
|
|
22714
23300
|
...input.request,
|
|
22715
|
-
agentControllerConversationId: normalizeOptionalText$
|
|
23301
|
+
agentControllerConversationId: normalizeOptionalText$11(input.request.agentControllerConversationId),
|
|
22716
23302
|
...agentControllerConversation ? { agentControllerConversation } : {}
|
|
22717
23303
|
};
|
|
22718
23304
|
};
|
|
@@ -22775,7 +23361,7 @@ const resolveDefaultOpenClawInvoke = (options) => {
|
|
|
22775
23361
|
optionAgentId: options.openClawAgentId
|
|
22776
23362
|
});
|
|
22777
23363
|
const correction = isDispatchSpaceActionDeliveryOnly(input.env);
|
|
22778
|
-
const canonicalSessionId = normalizeOptionalText$
|
|
23364
|
+
const canonicalSessionId = normalizeOptionalText$11(input.agentControllerConversationId) ?? resolveOpenClawSessionKey(input);
|
|
22779
23365
|
const executionSessionId = correction ? randomUUID() : canonicalSessionId ?? randomUUID();
|
|
22780
23366
|
const result = await withOpenClawDispatchSpaceActionPlugin({
|
|
22781
23367
|
launchContract,
|
|
@@ -22821,7 +23407,7 @@ const resolveDefaultOpenClawInvoke = (options) => {
|
|
|
22821
23407
|
};
|
|
22822
23408
|
};
|
|
22823
23409
|
async function resolveOpenClawDispatchLaunchContract(input) {
|
|
22824
|
-
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$
|
|
23410
|
+
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$11(input.openClawBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$11(input.openClawBin) }) : null);
|
|
22825
23411
|
if (explicitLaunchContract) {
|
|
22826
23412
|
const verification = isDispatchSpaceActionDeliveryOnly(input.env) ? await verifyLaunchContractFiles({ launchContract: explicitLaunchContract }) : await verifyOpenClawLaunchContract({
|
|
22827
23413
|
launchContract: explicitLaunchContract,
|
|
@@ -22844,8 +23430,8 @@ const resolveRuntimeProcessRegistrar$1 = (input) => input.registerRuntimeProcess
|
|
|
22844
23430
|
taskId: input.taskId
|
|
22845
23431
|
});
|
|
22846
23432
|
} : void 0;
|
|
22847
|
-
const resolveOpenClawAgentId = (input) => normalizeOptionalText$
|
|
22848
|
-
const resolveOpenClawSessionKey = (input) => normalizeOptionalText$
|
|
23433
|
+
const resolveOpenClawAgentId = (input) => normalizeOptionalText$11(input.dispatchEnvAgentId) ?? normalizeOptionalText$11(input.optionAgentId) ?? resolveOpenClawAgentId$1();
|
|
23434
|
+
const resolveOpenClawSessionKey = (input) => normalizeOptionalText$11(input.agentControllerConversation?.agentControllerRef === "builtin:openclaw" && input.agentControllerConversation.agentControllerConversationKind === "session" ? input.agentControllerConversation.agentControllerConversationId : null);
|
|
22849
23435
|
const invokeOpenClawGatewayPath = async (input) => {
|
|
22850
23436
|
const gatewayResult = await invokeOpenClawGatewayTransport({
|
|
22851
23437
|
agentId: input.openClawAgentId,
|
|
@@ -22856,7 +23442,7 @@ const invokeOpenClawGatewayPath = async (input) => {
|
|
|
22856
23442
|
openClawTimeoutMs: input.openClawTimeoutMs,
|
|
22857
23443
|
openClawWorkdir: input.openClawWorkdir,
|
|
22858
23444
|
prompt: input.input.prompt,
|
|
22859
|
-
resumedContext: normalizeOptionalText$
|
|
23445
|
+
resumedContext: normalizeOptionalText$11(input.input.agentControllerConversationId) !== null,
|
|
22860
23446
|
sessionKey: input.sessionKey
|
|
22861
23447
|
});
|
|
22862
23448
|
return {
|
|
@@ -22883,7 +23469,7 @@ const invokeOpenClawLocalCliPath = async (input) => {
|
|
|
22883
23469
|
...input.onProcessControlEvent ? { onProcessControlEvent: input.onProcessControlEvent } : {},
|
|
22884
23470
|
...input.input.onRuntimeEvent ? { onRuntimeEvent: input.input.onRuntimeEvent } : {},
|
|
22885
23471
|
prompt: input.input.prompt,
|
|
22886
|
-
sessionId: normalizeOptionalText$
|
|
23472
|
+
sessionId: normalizeOptionalText$11(input.input.agentControllerConversationId)
|
|
22887
23473
|
});
|
|
22888
23474
|
const agentControllerConversation = OPENCLAW_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
|
|
22889
23475
|
bridgeSpec: OPENCLAW_CONVERSATION_BRIDGE_SPEC,
|
|
@@ -22902,7 +23488,7 @@ const invokeOpenClawLocalCliPath = async (input) => {
|
|
|
22902
23488
|
function normalizeText$1(value) {
|
|
22903
23489
|
return String(value ?? "").trim();
|
|
22904
23490
|
}
|
|
22905
|
-
function normalizeOptionalText$
|
|
23491
|
+
function normalizeOptionalText$11(value) {
|
|
22906
23492
|
const normalized = normalizeText$1(value);
|
|
22907
23493
|
return normalized.length > 0 ? normalized : null;
|
|
22908
23494
|
}
|
|
@@ -22929,13 +23515,19 @@ async function resolveInstalledOpenCodeLaunchCandidates(input) {
|
|
|
22929
23515
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
22930
23516
|
additionalCommandDirectories: resolveOpenCodeCommandDirectories(),
|
|
22931
23517
|
commandName: DEFAULT_OPENCODE_COMMAND,
|
|
22932
|
-
configuredCommand: normalizeOptionalText$
|
|
23518
|
+
configuredCommand: normalizeOptionalText$10(process.env.OPENMELD_DAEMON_RUNTIME_OPENCODE_BIN),
|
|
22933
23519
|
displayName: "OpenCode",
|
|
22934
23520
|
preferredLaunchContract: input?.preferredLaunchContract
|
|
22935
23521
|
});
|
|
22936
|
-
|
|
23522
|
+
const v2 = await resolveInstalledNodeScriptLaunchCandidates({
|
|
23523
|
+
additionalCommandDirectories: resolveOpenCodeCommandDirectories(),
|
|
23524
|
+
commandName: "opencode2",
|
|
23525
|
+
displayName: "OpenCode 2"
|
|
23526
|
+
});
|
|
23527
|
+
if (!(installedCandidates.ok || v2.ok)) return installedCandidates;
|
|
23528
|
+
const discovered = [...installedCandidates.ok ? installedCandidates.candidates : [], ...v2.ok ? v2.candidates : []];
|
|
22937
23529
|
const candidates = await resolveLaunchCandidatesAfterVerification({
|
|
22938
|
-
candidates:
|
|
23530
|
+
candidates: [...new Map(discovered.map((candidate) => [JSON.stringify(candidate.launchContract), candidate])).values()],
|
|
22939
23531
|
verify: async (candidate) => await verifyOpenCodeLaunchContract({
|
|
22940
23532
|
launchContract: candidate.launchContract,
|
|
22941
23533
|
timeoutMs: input?.timeoutMs
|
|
@@ -22961,16 +23553,16 @@ async function verifyOpenCodeLaunchContract(input) {
|
|
|
22961
23553
|
});
|
|
22962
23554
|
}
|
|
22963
23555
|
function resolveOpenCodeTimeoutMs() {
|
|
22964
|
-
const raw = normalizeOptionalText$
|
|
23556
|
+
const raw = normalizeOptionalText$10(process.env.OPENMELD_DAEMON_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
22965
23557
|
if (!raw) return null;
|
|
22966
23558
|
const parsed = Number.parseInt(raw, 10);
|
|
22967
23559
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
22968
23560
|
return parsed;
|
|
22969
23561
|
}
|
|
22970
23562
|
function resolveOpenCodeCommandDirectories() {
|
|
22971
|
-
return [join(normalizeOptionalText$
|
|
23563
|
+
return [join(normalizeOptionalText$10(process.env.HOME) ?? homedir(), ".opencode", "bin")];
|
|
22972
23564
|
}
|
|
22973
|
-
function normalizeOptionalText$
|
|
23565
|
+
function normalizeOptionalText$10(value) {
|
|
22974
23566
|
const normalized = String(value ?? "").trim();
|
|
22975
23567
|
return normalized.length > 0 ? normalized : null;
|
|
22976
23568
|
}
|
|
@@ -22981,579 +23573,6 @@ function isLikelyOpenCodeContextLostError(message) {
|
|
|
22981
23573
|
return normalized.includes("session") && (normalized.includes("not found") || normalized.includes("missing") || normalized.includes("invalid") || normalized.includes("expired") || normalized.includes("deleted"));
|
|
22982
23574
|
}
|
|
22983
23575
|
//#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
23576
|
//#region ../../runtime/adapters/opencode/dist/transport/opencode-delivery-only.js
|
|
23558
23577
|
const SAFE_TOOL_ID = /^[A-Za-z0-9_.:-]+$/u;
|
|
23559
23578
|
/** Narrow only the disposable correction session; never grant a final tool. */
|
|
@@ -23624,6 +23643,102 @@ function scopeError(message) {
|
|
|
23624
23643
|
});
|
|
23625
23644
|
}
|
|
23626
23645
|
//#endregion
|
|
23646
|
+
//#region ../../runtime/adapters/opencode/dist/transport/opencode-failure.js
|
|
23647
|
+
function classifyOpenCodeFailureMessage(input) {
|
|
23648
|
+
const normalized = input.message.trim();
|
|
23649
|
+
const lowered = normalized.toLowerCase();
|
|
23650
|
+
const originalError = input.includeOriginalError ? createProviderOriginalError(normalized) : null;
|
|
23651
|
+
const withOriginalError = (value) => ({
|
|
23652
|
+
...value,
|
|
23653
|
+
...originalError ? { originalError } : {}
|
|
23654
|
+
});
|
|
23655
|
+
const permissionDenial = classifyRuntimePermissionDenialMessage({
|
|
23656
|
+
message: normalized,
|
|
23657
|
+
source: "opencode"
|
|
23658
|
+
});
|
|
23659
|
+
if (permissionDenial) return withOriginalError(permissionDenial);
|
|
23660
|
+
if (input.isContextLost(normalized)) return withOriginalError({
|
|
23661
|
+
code: "context.lost",
|
|
23662
|
+
errorType: "adapter",
|
|
23663
|
+
message: `context.lost: ${normalized}`
|
|
23664
|
+
});
|
|
23665
|
+
if (lowered.includes("not logged in") || lowered.includes("unauthorized") || lowered.includes("authentication") || lowered.includes("credentials")) return withOriginalError({
|
|
23666
|
+
code: "auth.required",
|
|
23667
|
+
errorType: "auth",
|
|
23668
|
+
message: `auth.required: ${normalized}`
|
|
23669
|
+
});
|
|
23670
|
+
if (lowered.includes("unsupported model") || lowered.includes("model is not supported") || lowered.includes("invalid model") || lowered.includes("model not found")) return withOriginalError({
|
|
23671
|
+
code: "model.unsupported",
|
|
23672
|
+
errorType: "config",
|
|
23673
|
+
message: `model.unsupported: ${normalized}`
|
|
23674
|
+
});
|
|
23675
|
+
if (isInsufficientBalanceFailure(lowered)) return withOriginalError({
|
|
23676
|
+
code: "provider.insufficient_balance",
|
|
23677
|
+
errorType: "adapter",
|
|
23678
|
+
message: `provider.insufficient_balance: ${normalized}`,
|
|
23679
|
+
providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
|
|
23680
|
+
});
|
|
23681
|
+
if (isDefinitiveHardQuotaFailure(lowered)) return withOriginalError({
|
|
23682
|
+
code: "quota.exceeded",
|
|
23683
|
+
errorType: "adapter",
|
|
23684
|
+
message: `quota.exceeded: ${normalized}`,
|
|
23685
|
+
providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
|
|
23686
|
+
});
|
|
23687
|
+
if (isTransientRateLimitFailure(lowered)) return withOriginalError({
|
|
23688
|
+
code: "provider.rate_limited",
|
|
23689
|
+
errorType: "network",
|
|
23690
|
+
message: `provider.rate_limited: ${normalized}`
|
|
23691
|
+
});
|
|
23692
|
+
if (isSubscriptionAccessFailure(lowered)) return withOriginalError({
|
|
23693
|
+
code: "provider.subscription_access_unavailable",
|
|
23694
|
+
errorType: "adapter",
|
|
23695
|
+
message: `provider.subscription_access_unavailable: ${normalized}`,
|
|
23696
|
+
providerAccessEvidence: buildProviderAccessEvidence("provider_account.subscription_access_unavailable")
|
|
23697
|
+
});
|
|
23698
|
+
if (isProviderUnavailableFailure(lowered)) return withOriginalError({
|
|
23699
|
+
code: "provider.unavailable",
|
|
23700
|
+
errorType: "network",
|
|
23701
|
+
message: `provider.unavailable: ${normalized}`
|
|
23702
|
+
});
|
|
23703
|
+
if (isHardQuotaFailure(lowered)) return withOriginalError({
|
|
23704
|
+
code: "quota.exceeded",
|
|
23705
|
+
errorType: "adapter",
|
|
23706
|
+
message: `quota.exceeded: ${normalized}`,
|
|
23707
|
+
providerAccessEvidence: buildProviderAccessEvidence("provider_account.capacity_exhausted")
|
|
23708
|
+
});
|
|
23709
|
+
return withOriginalError({
|
|
23710
|
+
code: "upstream_unreachable",
|
|
23711
|
+
errorType: "adapter",
|
|
23712
|
+
message: `upstream_unreachable: ${normalized}`
|
|
23713
|
+
});
|
|
23714
|
+
}
|
|
23715
|
+
function buildProviderAccessEvidence(reasonCode) {
|
|
23716
|
+
return {
|
|
23717
|
+
observedAtMs: Date.now(),
|
|
23718
|
+
provider: "opencode",
|
|
23719
|
+
reasonCode,
|
|
23720
|
+
source: "wake_failure"
|
|
23721
|
+
};
|
|
23722
|
+
}
|
|
23723
|
+
function isHardQuotaFailure(value) {
|
|
23724
|
+
return isDefinitiveHardQuotaFailure(value) || value.includes("usage limit") || value.includes("usage_limit");
|
|
23725
|
+
}
|
|
23726
|
+
function isDefinitiveHardQuotaFailure(value) {
|
|
23727
|
+
return value.includes("insufficient quota") || value.includes("insufficient_quota") || value.includes("quota exceeded") || value.includes("exceeded your current quota");
|
|
23728
|
+
}
|
|
23729
|
+
function isSubscriptionAccessFailure(value) {
|
|
23730
|
+
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");
|
|
23731
|
+
}
|
|
23732
|
+
function isTransientRateLimitFailure(value) {
|
|
23733
|
+
return value.includes("429") || value.includes("rate limit") || value.includes("too many requests");
|
|
23734
|
+
}
|
|
23735
|
+
function isInsufficientBalanceFailure(value) {
|
|
23736
|
+
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");
|
|
23737
|
+
}
|
|
23738
|
+
function isProviderUnavailableFailure(value) {
|
|
23739
|
+
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");
|
|
23740
|
+
}
|
|
23741
|
+
//#endregion
|
|
23627
23742
|
//#region ../../runtime/adapters/opencode/dist/transport/opencode-interactions.js
|
|
23628
23743
|
var OpenCodeInteractionHandler = class {
|
|
23629
23744
|
#client;
|
|
@@ -23804,8 +23919,449 @@ function normalizeBoundedText(value, maxLength) {
|
|
|
23804
23919
|
return normalized.length > 0 ? normalized.slice(0, maxLength) : null;
|
|
23805
23920
|
}
|
|
23806
23921
|
//#endregion
|
|
23922
|
+
//#region ../../runtime/adapters/opencode/dist/transport/opencode2-server.js
|
|
23923
|
+
function createOpenCode2Client(baseUrl, password) {
|
|
23924
|
+
return OpenCode.make({
|
|
23925
|
+
baseUrl,
|
|
23926
|
+
headers: { Authorization: `Basic ${Buffer.from(`opencode:${password}`).toString("base64")}` }
|
|
23927
|
+
});
|
|
23928
|
+
}
|
|
23929
|
+
function openCode2Error(code, message) {
|
|
23930
|
+
return Object.assign(/* @__PURE__ */ new Error(`${code}: ${message}`), {
|
|
23931
|
+
code,
|
|
23932
|
+
errorType: "adapter"
|
|
23933
|
+
});
|
|
23934
|
+
}
|
|
23935
|
+
async function readOpenCode2Inventory(input) {
|
|
23936
|
+
const client = createOpenCode2Client(input.baseUrl, input.password);
|
|
23937
|
+
const options = { signal: AbortSignal.timeout(input.timeoutMs) };
|
|
23938
|
+
if (!(await client.server.info(options)).version.startsWith("2.")) throw openCode2Error("protocol.invalid", "OpenCode returned an unsupported API version.");
|
|
23939
|
+
return (await client.model.list({ location: { directory: input.directory } }, options)).data.filter((model) => model.enabled).slice(0, 256).map((model) => ({
|
|
23940
|
+
id: `${model.providerID}/${model.id}`,
|
|
23941
|
+
displayName: model.name
|
|
23942
|
+
}));
|
|
23943
|
+
}
|
|
23944
|
+
//#endregion
|
|
23945
|
+
//#region ../../runtime/adapters/opencode/dist/transport/opencode2-interactions.js
|
|
23946
|
+
async function answerOpenCode2Permission(client, request, onInteractionRequest, signal) {
|
|
23947
|
+
const options = [
|
|
23948
|
+
{
|
|
23949
|
+
optionId: "once",
|
|
23950
|
+
label: "Allow once",
|
|
23951
|
+
intent: "allow_once"
|
|
23952
|
+
},
|
|
23953
|
+
...request.save?.length ? [{
|
|
23954
|
+
optionId: "always",
|
|
23955
|
+
label: "Always allow",
|
|
23956
|
+
intent: "allow_always"
|
|
23957
|
+
}] : [],
|
|
23958
|
+
{
|
|
23959
|
+
optionId: "reject",
|
|
23960
|
+
label: "Deny",
|
|
23961
|
+
intent: "deny"
|
|
23962
|
+
}
|
|
23963
|
+
];
|
|
23964
|
+
const response = onInteractionRequest ? await requestInteraction(onInteractionRequest, {
|
|
23965
|
+
kind: "permission",
|
|
23966
|
+
title: "OpenCode needs permission",
|
|
23967
|
+
description: (request.message || `${request.action}: ${request.resources.join(", ")}`).slice(0, 4e3),
|
|
23968
|
+
subject: { type: permissionSubject(request.action) },
|
|
23969
|
+
options
|
|
23970
|
+
}, signal) : void 0;
|
|
23971
|
+
const selected = response?.kind === "permission" && options.some((option) => option.optionId === response.optionId) ? response.optionId : "reject";
|
|
23972
|
+
await client.permission.reply({
|
|
23973
|
+
sessionID: request.sessionID,
|
|
23974
|
+
requestID: request.id,
|
|
23975
|
+
decision: selected
|
|
23976
|
+
}, { signal });
|
|
23977
|
+
if (!onInteractionRequest) throw openCode2Error("interaction.permission_required", "OpenCode requested permission without a user interaction channel.");
|
|
23978
|
+
}
|
|
23979
|
+
async function answerOpenCode2Form(client, form, onInteractionRequest, signal) {
|
|
23980
|
+
const answer = {};
|
|
23981
|
+
try {
|
|
23982
|
+
if (!onInteractionRequest) throw openCode2Error("interaction.question_required", "OpenCode requested input without a user interaction channel.");
|
|
23983
|
+
for (const field of form.fields) {
|
|
23984
|
+
if (field.type === "external") throw openCode2Error("interaction.question_unsupported", "This OpenCode form requires an external browser action.");
|
|
23985
|
+
if (field.when?.some((condition) => answer[condition.key] === condition.value !== (condition.op === "eq"))) continue;
|
|
23986
|
+
if (applyHiddenField(field, answer)) continue;
|
|
23987
|
+
const options = fieldOptions(field);
|
|
23988
|
+
if (options.length > 20) throw openCode2Error("interaction.question_unsupported", "The OpenCode form has too many choices.");
|
|
23989
|
+
if (field.key.length > 256) throw openCode2Error("interaction.question_unsupported", "The OpenCode field identifier is too long.");
|
|
23990
|
+
const response = await requestInteraction(onInteractionRequest, {
|
|
23991
|
+
kind: "question",
|
|
23992
|
+
title: form.title.slice(0, 240),
|
|
23993
|
+
questions: [{
|
|
23994
|
+
questionId: field.key,
|
|
23995
|
+
prompt: [field.title || field.key, field.description].filter(Boolean).join("\n").slice(0, 4e3),
|
|
23996
|
+
options,
|
|
23997
|
+
multiple: field.type === "multiselect",
|
|
23998
|
+
allowOther: options.length === 0 || "custom" in field && field.custom === true
|
|
23999
|
+
}]
|
|
24000
|
+
}, signal);
|
|
24001
|
+
if (response.kind !== "question") {
|
|
24002
|
+
await client.session.form.cancel({
|
|
24003
|
+
sessionID: form.sessionID,
|
|
24004
|
+
formID: form.id
|
|
24005
|
+
}, { signal });
|
|
24006
|
+
return;
|
|
24007
|
+
}
|
|
24008
|
+
const values = response.answers.find((item) => item.questionId === field.key)?.values;
|
|
24009
|
+
if (!values?.length) throw openCode2Error("interaction.response_invalid", "The form answer is missing.");
|
|
24010
|
+
answer[field.key] = decodeField(field, values);
|
|
24011
|
+
}
|
|
24012
|
+
await client.session.form.reply({
|
|
24013
|
+
sessionID: form.sessionID,
|
|
24014
|
+
formID: form.id,
|
|
24015
|
+
answer
|
|
24016
|
+
}, { signal });
|
|
24017
|
+
} catch (error) {
|
|
24018
|
+
await client.session.form.cancel({
|
|
24019
|
+
sessionID: form.sessionID,
|
|
24020
|
+
formID: form.id
|
|
24021
|
+
}, { signal }).catch(() => void 0);
|
|
24022
|
+
throw error;
|
|
24023
|
+
}
|
|
24024
|
+
}
|
|
24025
|
+
async function requestInteraction(callback, request, signal) {
|
|
24026
|
+
signal?.throwIfAborted();
|
|
24027
|
+
if (!signal) return await callback(request);
|
|
24028
|
+
const stopped = Promise.withResolvers();
|
|
24029
|
+
const onAbort = () => stopped.reject(signal.reason);
|
|
24030
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
24031
|
+
try {
|
|
24032
|
+
return await Promise.race([callback(request), stopped.promise]);
|
|
24033
|
+
} finally {
|
|
24034
|
+
signal.removeEventListener("abort", onAbort);
|
|
24035
|
+
}
|
|
24036
|
+
}
|
|
24037
|
+
function decodeField(field, values) {
|
|
24038
|
+
if (field.type !== "multiselect" && values.length !== 1) throw openCode2Error("interaction.response_invalid", "This field requires one answer.");
|
|
24039
|
+
if (field.type === "boolean") {
|
|
24040
|
+
if (values[0] !== "true" && values[0] !== "false") throw openCode2Error("interaction.response_invalid", "A boolean answer must be Yes or No.");
|
|
24041
|
+
return values[0] === "true";
|
|
24042
|
+
}
|
|
24043
|
+
if (field.type === "number" || field.type === "integer") {
|
|
24044
|
+
const value = Number(values[0]);
|
|
24045
|
+
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.");
|
|
24046
|
+
return value;
|
|
24047
|
+
}
|
|
24048
|
+
const resolved = values.map((value) => {
|
|
24049
|
+
const option = field.options?.find((_item, index) => String(index) === value);
|
|
24050
|
+
if (option) return option.value;
|
|
24051
|
+
if (field.options?.length && !field.custom) throw openCode2Error("interaction.response_invalid", "The selected choice is unavailable.");
|
|
24052
|
+
return value;
|
|
24053
|
+
});
|
|
24054
|
+
if (field.type === "multiselect") return resolved;
|
|
24055
|
+
const first = resolved[0];
|
|
24056
|
+
if (first === void 0) throw openCode2Error("interaction.response_invalid", "The form answer is missing.");
|
|
24057
|
+
return first;
|
|
24058
|
+
}
|
|
24059
|
+
function permissionSubject(action) {
|
|
24060
|
+
if (action === "shell") return "command";
|
|
24061
|
+
return action === "edit" ? "file_change" : "tool";
|
|
24062
|
+
}
|
|
24063
|
+
function applyHiddenField(field, answer) {
|
|
24064
|
+
if (!field.hidden) return false;
|
|
24065
|
+
if (field.default !== void 0) answer[field.key] = field.default;
|
|
24066
|
+
else if (field.required) throw openCode2Error("interaction.question_unsupported", "A hidden required field has no default.");
|
|
24067
|
+
return true;
|
|
24068
|
+
}
|
|
24069
|
+
function fieldOptions(field) {
|
|
24070
|
+
if (field.type === "boolean") return [{
|
|
24071
|
+
optionId: "true",
|
|
24072
|
+
label: "Yes"
|
|
24073
|
+
}, {
|
|
24074
|
+
optionId: "false",
|
|
24075
|
+
label: "No"
|
|
24076
|
+
}];
|
|
24077
|
+
if (!("options" in field)) return [];
|
|
24078
|
+
return (field.options ?? []).map((option, index) => ({
|
|
24079
|
+
optionId: String(index),
|
|
24080
|
+
label: option.label.slice(0, 240),
|
|
24081
|
+
...option.description ? { description: option.description.slice(0, 1e3) } : {}
|
|
24082
|
+
}));
|
|
24083
|
+
}
|
|
24084
|
+
//#endregion
|
|
24085
|
+
//#region ../../runtime/adapters/opencode/dist/transport/opencode2-transport.js
|
|
24086
|
+
async function runOpenCode2Turn(input) {
|
|
24087
|
+
const { client, signal } = input;
|
|
24088
|
+
if (isDispatchSpaceActionDeliveryOnly(input.env)) throw openCode2Error("delivery_scope.unsupported", "OpenCode 2 cannot yet attest an exclusive reply-repair tool scope.");
|
|
24089
|
+
const session = await prepareSession(input);
|
|
24090
|
+
const eventsAbort = new AbortController();
|
|
24091
|
+
const eventSignal = AbortSignal.any([signal, eventsAbort.signal]);
|
|
24092
|
+
const ready = Promise.withResolvers();
|
|
24093
|
+
const done = Promise.withResolvers();
|
|
24094
|
+
ready.promise.catch(() => void 0);
|
|
24095
|
+
done.promise.catch(() => void 0);
|
|
24096
|
+
const state = {
|
|
24097
|
+
sessionId: session.id,
|
|
24098
|
+
sessions: /* @__PURE__ */ new Set([session.id]),
|
|
24099
|
+
tools: /* @__PURE__ */ new Map(),
|
|
24100
|
+
delivered: /* @__PURE__ */ new Set(),
|
|
24101
|
+
assistantMessages: /* @__PURE__ */ new Set(),
|
|
24102
|
+
started: false,
|
|
24103
|
+
output: "",
|
|
24104
|
+
previewEmitted: false
|
|
24105
|
+
};
|
|
24106
|
+
const events = (async () => {
|
|
24107
|
+
for await (const event of client.event.subscribe({ signal: eventSignal })) {
|
|
24108
|
+
if (event.type === "server.connected") {
|
|
24109
|
+
ready.resolve();
|
|
24110
|
+
continue;
|
|
24111
|
+
}
|
|
24112
|
+
if (await observeEvent(input, state, event, eventSignal)) {
|
|
24113
|
+
done.resolve();
|
|
24114
|
+
return;
|
|
24115
|
+
}
|
|
24116
|
+
}
|
|
24117
|
+
throw openCode2Error("protocol.stream_closed", "OpenCode closed the event stream.");
|
|
24118
|
+
})().catch((error) => {
|
|
24119
|
+
ready.reject(error);
|
|
24120
|
+
done.reject(error);
|
|
24121
|
+
});
|
|
24122
|
+
try {
|
|
24123
|
+
await Promise.race([ready.promise, new Promise((_resolve, reject) => {
|
|
24124
|
+
AbortSignal.timeout(5e3).addEventListener("abort", () => reject(openCode2Error("protocol.timeout", "OpenCode did not confirm its event subscription.")), { once: true });
|
|
24125
|
+
})]);
|
|
24126
|
+
const receipt = await client.session.prompt({
|
|
24127
|
+
sessionID: session.id,
|
|
24128
|
+
text: input.instructionPrompt?.userPrompt ?? input.prompt
|
|
24129
|
+
}, { signal });
|
|
24130
|
+
await input.onRuntimeEvent?.({
|
|
24131
|
+
phase: "provider_turn_accepted",
|
|
24132
|
+
agentControllerConversationId: session.id,
|
|
24133
|
+
turnId: receipt.id,
|
|
24134
|
+
tsMs: Date.now()
|
|
24135
|
+
});
|
|
24136
|
+
await done.promise;
|
|
24137
|
+
if (!state.delivered.has(receipt.id)) throw openCode2Error("protocol.receipt_missing", "OpenCode ended an execution without confirming delivery of this prompt.");
|
|
24138
|
+
const messages = await client.message.list({
|
|
24139
|
+
sessionID: session.id,
|
|
24140
|
+
type: "assistant",
|
|
24141
|
+
order: "desc",
|
|
24142
|
+
limit: 100
|
|
24143
|
+
}, { signal });
|
|
24144
|
+
const latest = messages.data.find((message) => message.type === "assistant" && state.assistantMessages.has(message.id));
|
|
24145
|
+
const aiUsage = messages.data.flatMap((message) => {
|
|
24146
|
+
if (message.type !== "assistant" || !state.assistantMessages.has(message.id) || !message.tokens || !message.time.completed) return [];
|
|
24147
|
+
const tokens = message.tokens;
|
|
24148
|
+
const inputTokens = tokens.input + tokens.cache.read + tokens.cache.write;
|
|
24149
|
+
const outputTokens = tokens.output + tokens.reasoning;
|
|
24150
|
+
const observation = readAdapterAiUsageObservation({
|
|
24151
|
+
eventId: `opencode:${session.id}:${message.id}`,
|
|
24152
|
+
provider: message.model.providerID,
|
|
24153
|
+
model: message.model.id,
|
|
24154
|
+
source: "opencode_message",
|
|
24155
|
+
occurredAtMs: message.time.completed,
|
|
24156
|
+
tokens: {
|
|
24157
|
+
input: inputTokens,
|
|
24158
|
+
output: outputTokens,
|
|
24159
|
+
cacheRead: tokens.cache.read,
|
|
24160
|
+
cacheWrite: tokens.cache.write,
|
|
24161
|
+
reasoning: tokens.reasoning,
|
|
24162
|
+
total: inputTokens + outputTokens
|
|
24163
|
+
},
|
|
24164
|
+
cost: typeof message.cost === "number" ? {
|
|
24165
|
+
nanoUsd: Math.round(message.cost * 1e9),
|
|
24166
|
+
kind: "provider_estimate"
|
|
24167
|
+
} : null
|
|
24168
|
+
});
|
|
24169
|
+
return observation ? [observation] : [];
|
|
24170
|
+
});
|
|
24171
|
+
if (latest?.type === "assistant") state.output = latest.content.filter((part) => part.type === "text").map((part) => part.text).join("\n");
|
|
24172
|
+
if (input.onPreview && input.streamingMode !== "stream" && state.output) {
|
|
24173
|
+
await input.onPreview({ text: state.output });
|
|
24174
|
+
state.previewEmitted = true;
|
|
24175
|
+
}
|
|
24176
|
+
return {
|
|
24177
|
+
sessionId: session.id,
|
|
24178
|
+
output: state.output,
|
|
24179
|
+
previewEmitted: state.previewEmitted,
|
|
24180
|
+
aiUsage
|
|
24181
|
+
};
|
|
24182
|
+
} finally {
|
|
24183
|
+
eventsAbort.abort();
|
|
24184
|
+
await events;
|
|
24185
|
+
}
|
|
24186
|
+
}
|
|
24187
|
+
async function assertOpenCode2Directory(session, directory) {
|
|
24188
|
+
if (await realpath(session.location.directory) !== await realpath(directory)) throw openCode2Error("context.directory_mismatch", "The OpenCode session belongs to a different working folder.");
|
|
24189
|
+
}
|
|
24190
|
+
function readOpenCode2Permissions(value) {
|
|
24191
|
+
if (!value) return;
|
|
24192
|
+
const raw = JSON.parse(value);
|
|
24193
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) throw openCode2Error("permission.invalid", "OpenCode permission settings must be an object.");
|
|
24194
|
+
const rules = [];
|
|
24195
|
+
for (const [name, setting] of Object.entries(raw)) {
|
|
24196
|
+
const action = {
|
|
24197
|
+
bash: "shell",
|
|
24198
|
+
task: "subagent",
|
|
24199
|
+
write: "edit",
|
|
24200
|
+
patch: "edit"
|
|
24201
|
+
}[name] ?? name;
|
|
24202
|
+
const entries = permissionEntries(setting);
|
|
24203
|
+
if (!entries.length) throw openCode2Error("permission.invalid", "OpenCode permission settings are invalid.");
|
|
24204
|
+
for (const [resource, effect] of entries) {
|
|
24205
|
+
if (effect !== "ask" && effect !== "allow" && effect !== "deny") throw openCode2Error("permission.invalid", "OpenCode permission effects are invalid.");
|
|
24206
|
+
rules.push({
|
|
24207
|
+
action,
|
|
24208
|
+
resource,
|
|
24209
|
+
effect
|
|
24210
|
+
});
|
|
24211
|
+
}
|
|
24212
|
+
}
|
|
24213
|
+
return rules;
|
|
24214
|
+
}
|
|
24215
|
+
async function prepareSession(input) {
|
|
24216
|
+
const { client, signal } = input;
|
|
24217
|
+
const location = { directory: await realpath(input.directory) };
|
|
24218
|
+
const spaceAction = resolveDispatchSpaceActionMcpServer(input.env);
|
|
24219
|
+
if (spaceAction) {
|
|
24220
|
+
await client.mcp.add({
|
|
24221
|
+
location,
|
|
24222
|
+
server: spaceAction.id,
|
|
24223
|
+
config: {
|
|
24224
|
+
type: "local",
|
|
24225
|
+
command: [spaceAction.commandPath, ...spaceAction.args],
|
|
24226
|
+
environment: spaceAction.env,
|
|
24227
|
+
codemode: false
|
|
24228
|
+
}
|
|
24229
|
+
}, { signal });
|
|
24230
|
+
await client.mcp.connect({
|
|
24231
|
+
location,
|
|
24232
|
+
server: spaceAction.id
|
|
24233
|
+
}, { signal });
|
|
24234
|
+
await waitForSpaceActionMcp(client, location, spaceAction.id, signal);
|
|
24235
|
+
await setTimeout$1(500, void 0, { signal });
|
|
24236
|
+
}
|
|
24237
|
+
const modelId = input.conversationPolicy?.model;
|
|
24238
|
+
const split = modelId?.indexOf("/") ?? -1;
|
|
24239
|
+
if (modelId && split < 1) throw openCode2Error("model.unavailable", "OpenCode models require a provider/model identifier.");
|
|
24240
|
+
const model = modelId ? {
|
|
24241
|
+
providerID: modelId.slice(0, split),
|
|
24242
|
+
id: modelId.slice(split + 1),
|
|
24243
|
+
...input.conversationPolicy?.reasoningLevel ? { variant: input.conversationPolicy.reasoningLevel } : {}
|
|
24244
|
+
} : void 0;
|
|
24245
|
+
const permissions = readOpenCode2Permissions(input.env?.OPENCODE_PERMISSION);
|
|
24246
|
+
let session;
|
|
24247
|
+
if (input.sessionId) {
|
|
24248
|
+
session = await client.session.get({ sessionID: input.sessionId }, { signal });
|
|
24249
|
+
await assertOpenCode2Directory(session, location.directory);
|
|
24250
|
+
if ((await client.session.active({ signal }))[session.id]) throw openCode2Error("conversation.busy", "The selected OpenCode session is already running.");
|
|
24251
|
+
if (permissions) await client.session.update({
|
|
24252
|
+
sessionID: session.id,
|
|
24253
|
+
permissions
|
|
24254
|
+
}, { signal });
|
|
24255
|
+
if (model) await client.session.switchModel({
|
|
24256
|
+
sessionID: session.id,
|
|
24257
|
+
model
|
|
24258
|
+
}, { signal });
|
|
24259
|
+
} else session = await client.session.create({
|
|
24260
|
+
location,
|
|
24261
|
+
...model ? { model } : {},
|
|
24262
|
+
...permissions ? { permissions } : {}
|
|
24263
|
+
}, { signal });
|
|
24264
|
+
await input.onRuntimeEvent?.({
|
|
24265
|
+
phase: "provider_conversation_observed",
|
|
24266
|
+
agentControllerConversationId: session.id,
|
|
24267
|
+
tsMs: Date.now()
|
|
24268
|
+
});
|
|
24269
|
+
if (input.instructionPrompt) await client.session.instructions.entry.put({
|
|
24270
|
+
sessionID: session.id,
|
|
24271
|
+
key: "openmeld.dispatch",
|
|
24272
|
+
value: input.instructionPrompt.developerInstructions
|
|
24273
|
+
}, { signal });
|
|
24274
|
+
return session;
|
|
24275
|
+
}
|
|
24276
|
+
function permissionEntries(setting) {
|
|
24277
|
+
if (typeof setting === "string") return [["*", setting]];
|
|
24278
|
+
return setting && typeof setting === "object" && !Array.isArray(setting) ? Object.entries(setting) : [];
|
|
24279
|
+
}
|
|
24280
|
+
async function waitForSpaceActionMcp(client, location, name, signal) {
|
|
24281
|
+
const startupSignal = AbortSignal.any([signal, AbortSignal.timeout(3e4)]);
|
|
24282
|
+
while (true) {
|
|
24283
|
+
const status = (await client.mcp.list({ location }, { signal: startupSignal })).data.find((server) => server.name === name)?.status;
|
|
24284
|
+
if (status?.status === "connected") return;
|
|
24285
|
+
if (status && status.status !== "pending") throw openCode2Error("space.action.unavailable", `OpenCode could not start the Space action tools: ${JSON.stringify(status)}`);
|
|
24286
|
+
await setTimeout$1(100, void 0, { signal: startupSignal });
|
|
24287
|
+
}
|
|
24288
|
+
}
|
|
24289
|
+
async function observeEvent(input, state, event, signal) {
|
|
24290
|
+
if (event.type === "session.created" && event.data.parentID && state.sessions.has(event.data.parentID)) state.sessions.add(event.data.sessionID);
|
|
24291
|
+
if (event.type === "form.created") {
|
|
24292
|
+
if (state.sessions.has(event.data.form.sessionID)) await answerOpenCode2Form(input.client, event.data.form, input.onInteractionRequest, signal);
|
|
24293
|
+
return false;
|
|
24294
|
+
}
|
|
24295
|
+
if (!("sessionID" in event.data && state.sessions.has(event.data.sessionID))) return false;
|
|
24296
|
+
if (event.type === "permission.asked") {
|
|
24297
|
+
await answerOpenCode2Permission(input.client, event.data, input.onInteractionRequest, signal);
|
|
24298
|
+
return false;
|
|
24299
|
+
}
|
|
24300
|
+
await observeTool(input, state, event);
|
|
24301
|
+
if (event.data.sessionID !== state.sessionId) return false;
|
|
24302
|
+
if ("assistantMessageID" in event.data && typeof event.data.assistantMessageID === "string") state.assistantMessages.add(event.data.assistantMessageID);
|
|
24303
|
+
return await observeRootEvent(input, state, event);
|
|
24304
|
+
}
|
|
24305
|
+
async function observeTool(input, state, event) {
|
|
24306
|
+
if (event.type === "session.tool.input.started") state.tools.set(event.data.id, event.data.name);
|
|
24307
|
+
if (event.type !== "session.tool.called" && event.type !== "session.tool.success" && event.type !== "session.tool.failed") return;
|
|
24308
|
+
await input.onRuntimeEvent?.({
|
|
24309
|
+
phase: "tool_activity",
|
|
24310
|
+
toolCallId: event.data.id,
|
|
24311
|
+
toolName: resolveAdapterToolActivityName(state.tools.get(event.data.id)),
|
|
24312
|
+
state: {
|
|
24313
|
+
"session.tool.called": "input-available",
|
|
24314
|
+
"session.tool.success": "output-available",
|
|
24315
|
+
"session.tool.failed": "output-error"
|
|
24316
|
+
}[event.type],
|
|
24317
|
+
tsMs: Date.now()
|
|
24318
|
+
});
|
|
24319
|
+
}
|
|
24320
|
+
async function observeRootEvent(input, state, event) {
|
|
24321
|
+
switch (event.type) {
|
|
24322
|
+
case "session.inbox.delivered":
|
|
24323
|
+
state.delivered.add(event.data.inboxID);
|
|
24324
|
+
break;
|
|
24325
|
+
case "session.execution.started":
|
|
24326
|
+
state.started = true;
|
|
24327
|
+
break;
|
|
24328
|
+
case "session.text.delta":
|
|
24329
|
+
state.output += event.data.delta;
|
|
24330
|
+
if (input.streamingMode === "stream" && input.onPreview) {
|
|
24331
|
+
await input.onPreview({ text: state.output });
|
|
24332
|
+
state.previewEmitted = true;
|
|
24333
|
+
}
|
|
24334
|
+
break;
|
|
24335
|
+
case "session.reasoning.delta":
|
|
24336
|
+
await input.onRuntimeEvent?.({
|
|
24337
|
+
phase: "reasoning",
|
|
24338
|
+
blockId: `${event.data.assistantMessageID}:${event.data.ordinal}`,
|
|
24339
|
+
mode: "append",
|
|
24340
|
+
text: event.data.delta,
|
|
24341
|
+
tsMs: Date.now()
|
|
24342
|
+
});
|
|
24343
|
+
break;
|
|
24344
|
+
case "session.execution.succeeded": return state.started;
|
|
24345
|
+
case "session.execution.failed": {
|
|
24346
|
+
if (!state.started) break;
|
|
24347
|
+
const failure = classifyOpenCodeFailureMessage({
|
|
24348
|
+
message: event.data.error.message,
|
|
24349
|
+
isContextLost: () => false,
|
|
24350
|
+
includeOriginalError: true
|
|
24351
|
+
});
|
|
24352
|
+
throw Object.assign(new Error(failure.message), failure);
|
|
24353
|
+
}
|
|
24354
|
+
case "session.execution.interrupted":
|
|
24355
|
+
if (state.started) throw openCode2Error("runtime.interrupted", `OpenCode interrupted the execution: ${event.data.reason}`);
|
|
24356
|
+
break;
|
|
24357
|
+
default: break;
|
|
24358
|
+
}
|
|
24359
|
+
return false;
|
|
24360
|
+
}
|
|
24361
|
+
//#endregion
|
|
23807
24362
|
//#region ../../runtime/adapters/opencode/dist/transport/opencode-server-transport.js
|
|
23808
24363
|
const SERVER_HOSTNAME = "127.0.0.1";
|
|
24364
|
+
const OPENCODE_V1_VERSION_RE = /^v?1\./u;
|
|
23809
24365
|
const SERVER_HEALTH_TIMEOUT_MS = 5e3;
|
|
23810
24366
|
const SERVER_STARTUP_TIMEOUT_MS = 15e3;
|
|
23811
24367
|
const SERVER_MAX_START_ATTEMPTS = 2;
|
|
@@ -23813,7 +24369,7 @@ const SERVER_SLOW_START_MS = 5e3;
|
|
|
23813
24369
|
const SERVER_DIAGNOSTIC_CONNECT_TIMEOUT_MS = 250;
|
|
23814
24370
|
const SERVER_PROCESS_KILL_GRACE_MS = 1e3;
|
|
23815
24371
|
const SERVER_PROCESS_CLOSE_TIMEOUT_MS = 2e3;
|
|
23816
|
-
const SERVER_READY_LINE_PATTERN = /^opencode server listening on (https?:\/\/[^\s]+)$/;
|
|
24372
|
+
const SERVER_READY_LINE_PATTERN = /^(?:opencode )?server listening on (https?:\/\/[^\s]+)$/;
|
|
23817
24373
|
var OpenCodeServerTransportError = class extends Error {
|
|
23818
24374
|
telemetry;
|
|
23819
24375
|
code;
|
|
@@ -23851,26 +24407,45 @@ async function invokeOpenCodeServerTransport(input) {
|
|
|
23851
24407
|
const canonicalRepairSessionId = input.executionMode === "repair" || isDispatchSpaceActionDeliveryOnly(input.env) ? normalizeOptionalText$9(input.sessionId) : null;
|
|
23852
24408
|
let result;
|
|
23853
24409
|
try {
|
|
23854
|
-
|
|
23855
|
-
|
|
23856
|
-
|
|
23857
|
-
|
|
23858
|
-
|
|
23859
|
-
|
|
23860
|
-
|
|
23861
|
-
|
|
23862
|
-
|
|
23863
|
-
|
|
23864
|
-
|
|
23865
|
-
|
|
23866
|
-
|
|
23867
|
-
|
|
23868
|
-
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
23872
|
-
|
|
23873
|
-
|
|
24410
|
+
if (server.apiMajor === 2) {
|
|
24411
|
+
if (canonicalRepairSessionId) throw new OpenCodeServerTransportError({
|
|
24412
|
+
code: "delivery_scope.unsupported",
|
|
24413
|
+
errorType: "config",
|
|
24414
|
+
message: "OpenCode 2 reply repair requires an attested restricted tool scope."
|
|
24415
|
+
});
|
|
24416
|
+
const abort = new AbortController();
|
|
24417
|
+
try {
|
|
24418
|
+
result = await Promise.race([runOpenCode2Turn({
|
|
24419
|
+
...input,
|
|
24420
|
+
client: createOpenCode2Client(serverUrl, server.apiPassword),
|
|
24421
|
+
directory: input.openCodeWorkdir,
|
|
24422
|
+
signal: abort.signal
|
|
24423
|
+
}), server.waitForFailure()]);
|
|
24424
|
+
} finally {
|
|
24425
|
+
abort.abort();
|
|
24426
|
+
}
|
|
24427
|
+
} else {
|
|
24428
|
+
const executionSessionId = canonicalRepairSessionId ? await forkOpenCodeSessionWithClient({
|
|
24429
|
+
client,
|
|
24430
|
+
openCodeWorkdir: input.openCodeWorkdir,
|
|
24431
|
+
sourceSessionId: canonicalRepairSessionId
|
|
24432
|
+
}) : normalizeOptionalText$9(input.sessionId);
|
|
24433
|
+
result = await runOpenCodeServerTurn({
|
|
24434
|
+
env: input.env,
|
|
24435
|
+
onRuntimeEvent: input.onRuntimeEvent,
|
|
24436
|
+
client,
|
|
24437
|
+
conversationPolicy: input.conversationPolicy,
|
|
24438
|
+
instructionPrompt: input.instructionPrompt,
|
|
24439
|
+
observedSessionId: canonicalRepairSessionId,
|
|
24440
|
+
onInteractionRequest: input.onInteractionRequest,
|
|
24441
|
+
onPreview: input.onPreview,
|
|
24442
|
+
openCodeWorkdir: input.openCodeWorkdir,
|
|
24443
|
+
prompt,
|
|
24444
|
+
server,
|
|
24445
|
+
sessionId: executionSessionId,
|
|
24446
|
+
streamingMode: input.streamingMode ?? "final"
|
|
24447
|
+
});
|
|
24448
|
+
}
|
|
23874
24449
|
} catch (error) {
|
|
23875
24450
|
const failure = toOpenCodeServerTransportError(error, server.readStderr());
|
|
23876
24451
|
failure.telemetry = server.buildTelemetry({
|
|
@@ -23891,12 +24466,15 @@ async function invokeOpenCodeServerTransport(input) {
|
|
|
23891
24466
|
return {
|
|
23892
24467
|
output: result.output,
|
|
23893
24468
|
sessionId: canonicalRepairSessionId ?? result.sessionId,
|
|
23894
|
-
telemetry:
|
|
23895
|
-
|
|
23896
|
-
|
|
23897
|
-
|
|
23898
|
-
|
|
23899
|
-
|
|
24469
|
+
telemetry: {
|
|
24470
|
+
...server.buildTelemetry({
|
|
24471
|
+
invokedAtMs,
|
|
24472
|
+
previewEmitted: result.previewEmitted,
|
|
24473
|
+
resumedContext: normalizeOptionalText$9(input.sessionId) !== null,
|
|
24474
|
+
streamingMode: input.streamingMode ?? "final"
|
|
24475
|
+
}),
|
|
24476
|
+
...result.aiUsage ? { aiUsage: result.aiUsage } : {}
|
|
24477
|
+
}
|
|
23900
24478
|
};
|
|
23901
24479
|
}
|
|
23902
24480
|
async function forkOpenCodeServerSession(input) {
|
|
@@ -23912,6 +24490,17 @@ async function forkOpenCodeServerSession(input) {
|
|
|
23912
24490
|
deadlineMs
|
|
23913
24491
|
});
|
|
23914
24492
|
try {
|
|
24493
|
+
if (server.apiMajor === 2) {
|
|
24494
|
+
const client = createOpenCode2Client(serverUrl, server.apiPassword);
|
|
24495
|
+
const options = { signal: AbortSignal.timeout(15e3) };
|
|
24496
|
+
await assertOpenCode2Directory(await client.session.get({ sessionID: sourceSessionId }, options), input.openCodeWorkdir);
|
|
24497
|
+
const fork = await client.session.fork({ sessionID: sourceSessionId }, options);
|
|
24498
|
+
if (input.title) await client.session.update({
|
|
24499
|
+
sessionID: fork.id,
|
|
24500
|
+
title: input.title
|
|
24501
|
+
}, options);
|
|
24502
|
+
return { sessionId: fork.id };
|
|
24503
|
+
}
|
|
23915
24504
|
const client = createOpencodeClient({
|
|
23916
24505
|
baseUrl: serverUrl,
|
|
23917
24506
|
directory: input.openCodeWorkdir,
|
|
@@ -23969,6 +24558,23 @@ async function forkOpenCodeSessionWithClient(input) {
|
|
|
23969
24558
|
})).sessionId;
|
|
23970
24559
|
}
|
|
23971
24560
|
async function startHealthyOpenCodeServer(input) {
|
|
24561
|
+
const pure = isDispatchSpaceActionDeliveryOnly(input.env);
|
|
24562
|
+
if (pure) {
|
|
24563
|
+
const version = await runCliDriver({
|
|
24564
|
+
...buildCliLaunchInvocation({
|
|
24565
|
+
launchContract: input.launchContract,
|
|
24566
|
+
args: ["--version"]
|
|
24567
|
+
}),
|
|
24568
|
+
cwd: input.openCodeWorkdir,
|
|
24569
|
+
env: input.env,
|
|
24570
|
+
timeoutMs: SERVER_STARTUP_TIMEOUT_MS
|
|
24571
|
+
});
|
|
24572
|
+
if (!OPENCODE_V1_VERSION_RE.test(version.stdoutText.trim())) throw new OpenCodeServerTransportError({
|
|
24573
|
+
code: "delivery_scope.unsupported",
|
|
24574
|
+
errorType: "config",
|
|
24575
|
+
message: "OpenCode reply repair requires the verified OpenCode 1 pure-server contract."
|
|
24576
|
+
});
|
|
24577
|
+
}
|
|
23972
24578
|
let lastError = null;
|
|
23973
24579
|
const startupEvidence = [];
|
|
23974
24580
|
for (let attemptIndex = 0; attemptIndex < SERVER_MAX_START_ATTEMPTS; attemptIndex += 1) {
|
|
@@ -23977,6 +24583,7 @@ async function startHealthyOpenCodeServer(input) {
|
|
|
23977
24583
|
const startupTimeoutMs = Math.min(remainingTimeoutMs ?? Number.POSITIVE_INFINITY, SERVER_STARTUP_TIMEOUT_MS);
|
|
23978
24584
|
const attempt = await runOpenCodeServerStartAttempt({
|
|
23979
24585
|
...input,
|
|
24586
|
+
pure,
|
|
23980
24587
|
openCodeTimeoutMs: remainingTimeoutMs,
|
|
23981
24588
|
startupTimeoutMs
|
|
23982
24589
|
});
|
|
@@ -24025,7 +24632,9 @@ async function runOpenCodeServerStartAttempt(input) {
|
|
|
24025
24632
|
});
|
|
24026
24633
|
}
|
|
24027
24634
|
try {
|
|
24028
|
-
|
|
24635
|
+
if (server.apiMajor === 2) {
|
|
24636
|
+
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.");
|
|
24637
|
+
} else await assertOpenCodeServerHealthy({
|
|
24029
24638
|
deadlineMs: input.deadlineMs,
|
|
24030
24639
|
directory: input.openCodeWorkdir,
|
|
24031
24640
|
serverUrl
|
|
@@ -24498,6 +25107,9 @@ function throwInteractionFailure(failure) {
|
|
|
24498
25107
|
});
|
|
24499
25108
|
}
|
|
24500
25109
|
var OpenCodeServerProcess = class {
|
|
25110
|
+
apiMajor = 1;
|
|
25111
|
+
apiPassword = randomUUID();
|
|
25112
|
+
#pure;
|
|
24501
25113
|
#aiUsage = /* @__PURE__ */ new Map();
|
|
24502
25114
|
#env;
|
|
24503
25115
|
#failure = createDeferred();
|
|
@@ -24539,6 +25151,7 @@ var OpenCodeServerProcess = class {
|
|
|
24539
25151
|
timeoutTriggeredAtMs: null
|
|
24540
25152
|
};
|
|
24541
25153
|
constructor(input) {
|
|
25154
|
+
this.#pure = input.pure === true;
|
|
24542
25155
|
this.#env = input.env;
|
|
24543
25156
|
this.#launchContract = input.launchContract;
|
|
24544
25157
|
this.#onProcessControlEvent = input.onProcessControlEvent;
|
|
@@ -24555,11 +25168,9 @@ var OpenCodeServerProcess = class {
|
|
|
24555
25168
|
const invocation = buildCliLaunchInvocation({
|
|
24556
25169
|
args: [
|
|
24557
25170
|
"serve",
|
|
24558
|
-
...
|
|
25171
|
+
...this.#pure ? ["--pure"] : [],
|
|
24559
25172
|
`--hostname=${SERVER_HOSTNAME}`,
|
|
24560
|
-
`--port=${port}
|
|
24561
|
-
"--print-logs",
|
|
24562
|
-
"--log-level=INFO"
|
|
25173
|
+
`--port=${port}`
|
|
24563
25174
|
],
|
|
24564
25175
|
launchContract: this.#launchContract
|
|
24565
25176
|
});
|
|
@@ -24569,7 +25180,8 @@ var OpenCodeServerProcess = class {
|
|
|
24569
25180
|
cwd: this.#openCodeWorkdir,
|
|
24570
25181
|
env: {
|
|
24571
25182
|
...process.env,
|
|
24572
|
-
...this.#env ?? {}
|
|
25183
|
+
...this.#env ?? {},
|
|
25184
|
+
OPENCODE_PASSWORD: this.apiPassword
|
|
24573
25185
|
},
|
|
24574
25186
|
shell: invocation.shell ?? false
|
|
24575
25187
|
});
|
|
@@ -24863,6 +25475,7 @@ var OpenCodeServerProcess = class {
|
|
|
24863
25475
|
return;
|
|
24864
25476
|
}
|
|
24865
25477
|
this.#startupResolve?.(reportedUrl);
|
|
25478
|
+
this.apiMajor = line.startsWith("opencode ") ? 1 : 2;
|
|
24866
25479
|
this.#readyLineObserved = true;
|
|
24867
25480
|
this.#startupResolve = null;
|
|
24868
25481
|
this.#startupReject = null;
|
|
@@ -24967,6 +25580,13 @@ function unwrapSdkData(value) {
|
|
|
24967
25580
|
return record && "data" in record ? record.data : value;
|
|
24968
25581
|
}
|
|
24969
25582
|
function toOpenCodeServerTransportError(error, stderr) {
|
|
25583
|
+
if (!(error instanceof OpenCodeServerTransportError) && error instanceof Error && "code" in error && typeof error.code === "string" && "errorType" in error && typeof error.errorType === "string") return new OpenCodeServerTransportError({
|
|
25584
|
+
...error,
|
|
25585
|
+
code: error.code,
|
|
25586
|
+
errorType: error.errorType,
|
|
25587
|
+
message: error.message,
|
|
25588
|
+
originalError: createProviderOriginalError(error.message) ?? void 0
|
|
25589
|
+
});
|
|
24970
25590
|
if (error instanceof Error && toRecord$1(error)?.code === "space.action.delivery_only_unverified") return new OpenCodeServerTransportError({
|
|
24971
25591
|
code: "space.action.delivery_only_unverified",
|
|
24972
25592
|
errorType: "config",
|
|
@@ -25070,7 +25690,7 @@ async function invokeOpenCodeWithSingleContextHeal(input) {
|
|
|
25070
25690
|
}
|
|
25071
25691
|
async function invokeOpenCodeOnce(input) {
|
|
25072
25692
|
try {
|
|
25073
|
-
|
|
25693
|
+
return await invokeOpenCodeServerTransport({
|
|
25074
25694
|
launchContract: input.launchContract,
|
|
25075
25695
|
openCodeTimeoutMs: input.openCodeTimeoutMs,
|
|
25076
25696
|
openCodeWorkdir: input.openCodeWorkdir,
|
|
@@ -25086,17 +25706,6 @@ async function invokeOpenCodeOnce(input) {
|
|
|
25086
25706
|
sessionId: input.sessionId,
|
|
25087
25707
|
streamingMode: input.streamingMode
|
|
25088
25708
|
});
|
|
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
25709
|
} catch (error) {
|
|
25101
25710
|
if (error instanceof OpenCodeRuntimeError) throw error;
|
|
25102
25711
|
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 +31143,9 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
|
|
|
30534
31143
|
cancel: true,
|
|
30535
31144
|
interrupt: true,
|
|
30536
31145
|
modelSelection: true,
|
|
30537
|
-
nativeEventStream:
|
|
31146
|
+
nativeEventStream: true,
|
|
30538
31147
|
permissionModes: true,
|
|
30539
|
-
structuredUserInput:
|
|
31148
|
+
structuredUserInput: true
|
|
30540
31149
|
},
|
|
30541
31150
|
conversationOccupancy: {
|
|
30542
31151
|
contractVersion: 1,
|
|
@@ -30571,7 +31180,7 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
|
|
|
30571
31180
|
modelSelection: true,
|
|
30572
31181
|
nativeEventStream: true,
|
|
30573
31182
|
permissionModes: true,
|
|
30574
|
-
structuredUserInput:
|
|
31183
|
+
structuredUserInput: true
|
|
30575
31184
|
},
|
|
30576
31185
|
conversationOccupancy: {
|
|
30577
31186
|
contractVersion: 1,
|
|
@@ -30612,13 +31221,13 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
|
|
|
30612
31221
|
adapterId: "cursor",
|
|
30613
31222
|
agentId: "cursor",
|
|
30614
31223
|
capabilities: {
|
|
30615
|
-
approvals:
|
|
31224
|
+
approvals: true,
|
|
30616
31225
|
cancel: true,
|
|
30617
31226
|
interrupt: true,
|
|
30618
31227
|
modelSelection: true,
|
|
30619
31228
|
nativeEventStream: true,
|
|
30620
31229
|
permissionModes: true,
|
|
30621
|
-
structuredUserInput:
|
|
31230
|
+
structuredUserInput: true
|
|
30622
31231
|
},
|
|
30623
31232
|
conversationOccupancy: {
|
|
30624
31233
|
contractVersion: 1,
|
|
@@ -30678,13 +31287,13 @@ const BUILTIN_AGENT_CONTROLLER_DEFINITIONS = [
|
|
|
30678
31287
|
adapterId: "opencode",
|
|
30679
31288
|
agentId: "opencode",
|
|
30680
31289
|
capabilities: {
|
|
30681
|
-
approvals:
|
|
31290
|
+
approvals: true,
|
|
30682
31291
|
cancel: false,
|
|
30683
31292
|
interrupt: true,
|
|
30684
31293
|
modelSelection: true,
|
|
30685
|
-
nativeEventStream:
|
|
30686
|
-
permissionModes:
|
|
30687
|
-
structuredUserInput:
|
|
31294
|
+
nativeEventStream: true,
|
|
31295
|
+
permissionModes: true,
|
|
31296
|
+
structuredUserInput: true
|
|
30688
31297
|
},
|
|
30689
31298
|
conversationOccupancy: {
|
|
30690
31299
|
contractVersion: 1,
|
|
@@ -32571,9 +33180,9 @@ function createModelCatalogReadSession(input) {
|
|
|
32571
33180
|
async function readModelCatalogOnce(baseUrl) {
|
|
32572
33181
|
try {
|
|
32573
33182
|
const [apiClient, baseUrlModule, clientFoundationModule] = await Promise.all([
|
|
32574
|
-
import("./dist-
|
|
33183
|
+
import("./dist-DMlKqjUf.js"),
|
|
32575
33184
|
import("./base-url-Bdjp-5vy.js"),
|
|
32576
|
-
import("./api-client-foundation-
|
|
33185
|
+
import("./api-client-foundation-B1aTRrIy.js")
|
|
32577
33186
|
]);
|
|
32578
33187
|
if (typeof apiClient.createConfigApi !== "function") throw new Error("config api client is unavailable");
|
|
32579
33188
|
const resolvedBaseUrl = baseUrl ?? await baseUrlModule.resolveBaseUrl();
|
|
@@ -32867,9 +33476,9 @@ function resolveBoundProfileLocalRouteCandidate(input) {
|
|
|
32867
33476
|
const agentControllerCollaborationMode = resolveNativeAgentControllerCollaborationModeForController(binding.agentControllerCollaborationMode, { agentControllerRef: agentControllerRef.ref });
|
|
32868
33477
|
return {
|
|
32869
33478
|
agentControllerRef: agentControllerRef.ref,
|
|
32870
|
-
agentControllerConversationId: normalizeOptionalText$
|
|
33479
|
+
agentControllerConversationId: normalizeOptionalText$49(executionTarget.agentControllerConversationId),
|
|
32871
33480
|
openMeldServiceRuntimeId: executionTarget.openMeldServiceRuntimeId.value,
|
|
32872
|
-
bindingId: normalizeOptionalText$
|
|
33481
|
+
bindingId: normalizeOptionalText$49(binding.bindingId),
|
|
32873
33482
|
...agentControllerCollaborationMode ? { agentControllerCollaborationMode } : {},
|
|
32874
33483
|
...agentControllerPermissionMode ? { agentControllerPermissionMode } : {},
|
|
32875
33484
|
...binding.modelSelection ? { modelSelection: binding.modelSelection } : {},
|
|
@@ -34334,7 +34943,7 @@ const DEFAULT_OPENCLAW_RUNTIME_PREPARATION_DEPS = {
|
|
|
34334
34943
|
fetchGatewayHealth: fetchOpenClawGatewayHealth
|
|
34335
34944
|
};
|
|
34336
34945
|
async function prepareOpenClawRuntime(input, deps = DEFAULT_OPENCLAW_RUNTIME_PREPARATION_DEPS) {
|
|
34337
|
-
const profileName = normalizeOptionalText$
|
|
34946
|
+
const profileName = normalizeOptionalText$49(input.profileName);
|
|
34338
34947
|
if (!profileName) throw new DaemonServiceRunError({
|
|
34339
34948
|
code: "controller.bootstrap.failed",
|
|
34340
34949
|
message: "controller.bootstrap.failed: OpenClaw bootstrap requires an OpenMeld profile name"
|
|
@@ -34397,12 +35006,12 @@ function buildOpenClawGatewayVisibilityFailure(error) {
|
|
|
34397
35006
|
}
|
|
34398
35007
|
function extractErrorCode(error) {
|
|
34399
35008
|
if (!(error && typeof error === "object" && "code" in error)) return;
|
|
34400
|
-
return normalizeOptionalText$
|
|
35009
|
+
return normalizeOptionalText$49(error.code) ?? void 0;
|
|
34401
35010
|
}
|
|
34402
35011
|
function resolveOpenClawGatewayVisibilityDiagnostics(error) {
|
|
34403
35012
|
if (!(error instanceof Error)) return;
|
|
34404
35013
|
const diagnostics = error.diagnostics;
|
|
34405
|
-
if (!diagnostics || typeof diagnostics !== "object" || !normalizeOptionalText$
|
|
35014
|
+
if (!diagnostics || typeof diagnostics !== "object" || !normalizeOptionalText$49(diagnostics.agentId)) return;
|
|
34406
35015
|
const parsedGatewayVisibility = openMeldDaemonTaskResultOpenClawGatewayVisibilityStatusSchema.safeParse(diagnostics.gatewayVisibility);
|
|
34407
35016
|
if (!parsedGatewayVisibility.success) return;
|
|
34408
35017
|
return {
|
|
@@ -34429,6 +35038,6 @@ async function prepareProviderRuntime(input, options = {}) {
|
|
|
34429
35038
|
return await preparer(input);
|
|
34430
35039
|
}
|
|
34431
35040
|
//#endregion
|
|
34432
|
-
export { canManageRegistryAgentSkillTargets as $,
|
|
35041
|
+
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
35042
|
|
|
34434
|
-
//# sourceMappingURL=prepare-provider-runtime-
|
|
35043
|
+
//# sourceMappingURL=prepare-provider-runtime-_XRIioDp.js.map
|