agent-transport-system 0.7.39 → 0.7.41
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/ats-dev.js +2 -2
- package/dist/ats.js +1357 -215
- package/dist/ats.js.map +1 -1
- package/dist/{base-url-Gd_RGCHM.js → base-url-CjrWhAM1.js} +2 -2
- package/dist/base-url-CjrWhAM1.js.map +1 -0
- package/dist/{daemon-runtime-lease-BzvcJMMC.js → daemon-runtime-lease-B8Ox_m9_.js} +1 -1
- package/dist/{lock-DV2_jevB.js → lock-BJ3j8Z9n.js} +24 -11
- package/dist/lock-BJ3j8Z9n.js.map +1 -0
- package/package.json +2 -2
- package/dist/base-url-Gd_RGCHM.js.map +0 -1
- package/dist/lock-DV2_jevB.js.map +0 -1
package/dist/ats.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { $ as gatewayErrorCodeSchema, $n as
|
|
3
|
+
import { $ as gatewayErrorCodeSchema, $n as canonicalizeBuiltinAgentControllerRef, $t as setLocalRuntimeDisplayNameBodySchema, A as createSpaceBodySchema, An as CONVERSATION_CONTINUITY_WARNING_PURPOSE, Ar as resolveSingleSpaceMentionLabels, At as observabilityWakeTraceSelectorSchema, B as daemonRouteObservationResponseSchema, Bn as SPACE_MEMBER_JOIN_NOTICE_PURPOSE, Bt as postSpaceThreadSignalResponseSchema, C as agentProfileBindingRouteParamsSchema, Cn as writeSetupTokenLocalRuntimeObservedMetadataBodySchema, Cr as normalizeOptionalWorkingDirectory, Ct as listSpaceThreadsResponseSchema, D as atsdControlPlaneResponseSchema, Dn as AGENT_REPLY_PREVIEW_END_PURPOSE, Dr as profileWorkspaceModeSchema, Dt as normalizeSpaceCursorPatch, E as atsdControlPlaneRequestSchema, En as AGENT_REPLYING_PURPOSE, Er as parseOptionalClientMessageId, Et as normalizeListSignalsReadQuerySemantics, F as createSpaceThreadResponseSchema, Fn as DISPATCH_ACTIVITY_RETRYING_PURPOSE, Fr as sanitizeSignalTextPreview, Ft as postNormalMessageBodySchema, G as ensureAgentProfilePrimaryBindingResponseSchema, Gn as atsRuntimeProfileIdSchema, Gt as providerDispatchRuntimeContextSchema, H as deleteSpaceResponseSchema, Hn as SPACE_MENTION_REJECT_NOTICE_PURPOSE, Ht as prepareSessionStreamServerFrameSchema, I as createStartSessionBodySchema, In as LEGACY_RUNTIME_DISPATCH_POLICY, It as postNormalMessageResponseSchema, J as forgetCurrentComputerResponseSchema, Jn as atsdTaskResultOpenClawGatewayVisibilityStatusSchema, Jt as resolveSpaceDispatchTraceRootCause, K as entryBriefSchema, Kn as atsSpaceEgressActionSchema, Kt as querySpaceDeletionTombstonesResponseSchema, L as currentDeviceTargetResponseSchema, Ln as MAX_PROFILE_WORKING_DIRECTORY_LENGTH, Lt as postSpaceMembersBodySchema, M as createSpaceDiagnosticReportResponseSchema, Mn as DAEMON_HUB_SCHEMA_VERSION, Mt as patchSpaceContractBodySchema, N as createSpaceResponseSchema, Nn as DISPATCH_ACTIVITY_DISPATCHING_PURPOSE, Nt as patchSpaceContractResponseSchema, O as catchupResponseSchema, On as AGENT_REPLY_PREVIEW_PURPOSE, Or as resolveBuiltinAgentControllerConversationKind, Ot as notifyAgentProfileRouteCatalogChangedBodySchema, P as createSpaceThreadBodySchema, Pn as DISPATCH_ACTIVITY_FAILED_PURPOSE, Pr as runtimeCoordinatorExecutionTokenEnvelopeSchema, Pt as patchStartSessionBodySchema, Q as formatLocalSetupActionLabel, Qn as canonicalizeAgentControllerRef, Qt as setCurrentDeviceTargetBodySchema, R as currentLocalRuntimeReplyReadinessResponseSchema, Rn as MAX_SIGNAL_REPLY_TO_PREVIEW_LENGTH, Rt as postSpaceMembersResponseSchema, S as agentExecutionReadinessRouteParamsSchema, Sn as writeCurrentDeviceObservedMetadataResponseSchema, Sr as normalizeMessageEnvelope, St as listSpaceThreadSignalsResponseSchema, T as atsRequestContextSchema, Tn as AGENT_REPLYING_END_PURPOSE, Tr as parseAgentControllerRef$1, Tt as localRuntimesResponseSchema, U as dispatchBriefSchema, Un as SPACE_PASSWORD_MIN_LENGTH, Ut as projectObservabilityWakeCorrelation, V as daemonRuntimeLeaseSchema, Vn as SPACE_MEMBER_REMOVE_NOTICE_PURPOSE, Vt as prepareSessionResponseSchema, W as ensureAgentProfilePrimaryBindingBodySchema, Wn as SPACE_UPDATES_MAX_LIMIT, Wt as projectSpaceDispatchTraceFinalVisibleOutcome, X as formatLocalComponentsSummaryLabel, Xn as buildAgentControllerConversationRef, Xt as resolveStartHandoffResponseSchema, Y as formatLocalComponentsSummaryDescription, Yn as atsdTaskResultPayloadSchema, Yt as resolveStartHandoffBodySchema, Z as formatLocalSetupActionDescription, Zn as buildAgentControllerRoutingKey, Zt as serverErrorFrameSchema, _ as ATSD_CONTROL_PLANE_SCHEMA_VERSION, _n as submitRuntimeRegistrationBodySchema, _r as daemonStreamFrameSchema, _t as incomingServerMessageSchema, a as runWithHeldLock, an as spaceMetaSchema, ar as daemonHubDispatchLifecycleRequestSchema, at as getAgentProfilePrimaryBindingResponseSchema, b as LOCAL_COMPONENTS_SCHEMA_VERSION, bn as upsertSpaceDeletionTombstoneResponseSchema, br as normalizeBuiltinAgentControllerId, bt as listProfileSpaceHistoryResponseSchema, c as LEGACY_ATS_CLI_CONTEXT_ENV_KEY, cn as startProfileReadinessSummarySchema, cr as daemonHubDispatchRuntimeEvidenceRequestSchema, ct as getSpaceContractResponseSchema, d as resolveCliContext, dn as startSessionSpaceChoiceBodySchema, dr as daemonHubRegisterSessionRequestSchema, dt as getSpaceMessageDetailsResponseSchema, en as signalEnvelopeSchema, er as collectCanonicalMentionTextFragments, et as gatewayErrorEnvelopeSchema, f as resolveCliContextId, fn as startSessionSpaceChoiceResponseSchema, fr as daemonHubRegisterSessionResponseSchema, ft as getSpaceStatusResponseSchema, g as resolveMappedPublicAgentFailureReason, gn as submitRuntimeAgentControllerReportsResponseSchema, gr as daemonServiceLaneSchema, gt as getSpaceWakeTraceWaterfallResponseSchema, h as resolveBuiltinAgentControllerBrand, hn as submitRuntimeAgentControllerReportsBodySchema, hr as daemonServiceContractSchema, ht as getSpaceWakeProgressResponseSchema, i as releaseLock, in as spaceMembersSnapshotSchema, ir as daemonHubDeliveryExecutionIdentitySchema, it as getAgentExecutionReadinessResponseSchema, j as createSpaceDiagnosticReportBodySchema, jn as CURRENT_DAEMON_EXECUTION_CONTRACT_EPOCH, jr as resolveSpaceMentionLabels, jt as patchProfileSpaceHistoryStatusResponseSchema, k as continuitySchema, kn as ATSD_TASK_RESULT_SCHEMA_VERSION, kr as resolveMessageEnvelopeTargetField, kt as notifyAgentProfileRouteCatalogChangedResponseSchema, l as listCliContextStates, ln as startSessionProgressSchema, lr as daemonHubHeartbeatRequestSchema, lt as getSpaceDispatchLookupResponseSchema, m as CODEX_UPGRADE_REQUIRED_REASON, mn as structuredGuidePayloadFromInputSchema, mr as daemonHubSubmitTaskResultRequestSchema, mt as getSpaceUpdatesResponseSchema, n as isAtsLockError, nn as spaceDispatchTraceResponseSchema, nr as createDaemonRouteObservationSummary, nt as getAgentExecutionReadinessBatchBodySchema, o as tryCleanupStaleLock, on as spaceViewerMembershipResponseSchema, or as daemonHubDispatchPreviewEndRequestSchema, ot as getPrepareReadinessQuerySchema, p as writeCliContextState, pn as startSessionWithTokenResponseSchema, pr as daemonHubRouteCatalogChangedFramePayloadSchema, pt as getSpaceThreadResponseSchema, q as forgetComputerResponseSchema, qn as atsdTaskResultEnvelopeWriteSchema, qt as removeSpaceMembersResponseSchema, r as readLockMeta, rn as spaceIdentityDirectorySchema, rr as daemonHubDeliverDispatchRequestSchema, rt as getAgentExecutionReadinessBatchResponseSchema, s as ATS_CLI_CONTEXT_ENV_KEY, sn as startDeviceProjectionSchema, sr as daemonHubDispatchPreviewRequestSchema, st as getPrepareReadinessResponseSchema, t as acquireLock, tn as spaceCreatorSchema, tr as conversationExecutionStateSchema, tt as getActiveSpaceWakeProgressResponseSchema, u as readCliContextState, un as startSessionResponseSchema, ur as daemonHubHeartbeatResponseSchema, ut as getSpaceDispatchResultResponseSchema, v as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_NAME, vn as submitRuntimeRegistrationResponseSchema, vr as formatCanonicalMentionLiteral, vt as installedLocalComponentsSnapshotSchema, w as atsProfileIdSchema, wn as writeSetupTokenLocalRuntimeObservedMetadataResponseSchema, wr as normalizeSpacePasswordText, wt as localRuntimesQuerySchema, x as SPACE_DISPATCH_TRACE_PROMPT_PREVIEW_MAX_CHARS, xn as writeCurrentDeviceObservedMetadataBodySchema, xr as normalizeKnownBuiltinAgentControllerId, xt as listSpaceThreadEventsResponseSchema, y as DAEMON_ROUTE_CATALOG_CACHE_SCHEMA_VERSION, yn as upsertProfileSpaceHistoryResponseSchema, yr as getSpaceMessageAddressingRelationSupportForTargetKind, yt as leaveSpaceResponseSchema, z as daemonRouteCatalogCacheSchema, zn as MESSAGE_MENTION_TYPE_VALUES, zt as postSpaceThreadSignalBodySchema } from "./lock-BJ3j8Z9n.js";
|
|
4
4
|
import { A as runtimeDir, C as normalizeAtsProfileId, D as resolveAtsEnvPreset, E as resolveAtsCliEntryNameFromArgv, F as systemDir, N as skillsDir, O as resolveAtsRootDir, P as spacesDir, S as normalizeAccountKey, T as profileViewPath, a as accountProfileWorkspacePath, c as atsRootDir, d as deviceOpenClawProfileBootstrapPath, f as deviceOpenClawProfileDir, i as accountProfileViewPath, j as runtimeLogsDir, k as resolveDefaultAtsHomeDirname, n as accountProfileLocalMetaPath, o as accountsDir, p as deviceOpenClawProfileWorkspaceDir, r as accountProfileSpaceCacheDir, s as atsBackupsDir, t as ATS_HOME_ENV_KEY, w as profileDir, y as legacyAccountProfileSpacesDir } from "./paths-DFiopT5Y.js";
|
|
5
|
-
import { A as toSpaceDeleteUrl, B as toSpaceUpdatesUrl, C as updateConfiguredSkillsConfig, D as toSpaceContractUrl, E as toDaemonRouteObservationUrl, F as toSpaceMetaUrl, I as toSpacePasswordUrl, L as toSpaceRemoveMembersUrl, M as toSpaceDispatchTraceUrl, N as toSpaceLeaveUrl, O as toSpaceCreateUrl, P as toSpaceMembersUrl, R as toSpaceResultUrl, S as updateConfiguredOnboardingConfig, T as normalizeBaseUrl, V as toSpaceWsUrl, _ as getRuntimeConfigReadHealth, a as resolveBaseUrlOrNull, b as setConfiguredSkillsConfig, c as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, d as getConfiguredDaemonDispatchLimits, f as getConfiguredDeviceRuntimeState, g as getConfiguredViewCustomization, h as getConfiguredStartV1OnboardingState, i as resolveBaseUrl, j as toSpaceDispatchLookupUrl, k as toSpaceCursorUrl, l as alignRuntimeConfigStorage, m as getConfiguredSkillsConfig, n as normalizeGatewayBaseUrl, o as resolveDefaultGatewayBaseUrl, p as getConfiguredOnboardingDisclaimerAcceptedAt, r as normalizeGatewayBaseUrlOrNull, s as resolveExplicitGatewayUrlOrThrow, u as createDefaultRuntimeAgentControllerSettings, v as resolveRuntimeSkillsCustomTargetId, w as updateConfiguredStartV1OnboardingState, x as updateConfiguredDeviceRuntimeState, y as setConfiguredBaseUrl, z as toSpaceSignalsUrl } from "./base-url-
|
|
5
|
+
import { A as toSpaceDeleteUrl, B as toSpaceUpdatesUrl, C as updateConfiguredSkillsConfig, D as toSpaceContractUrl, E as toDaemonRouteObservationUrl, F as toSpaceMetaUrl, I as toSpacePasswordUrl, L as toSpaceRemoveMembersUrl, M as toSpaceDispatchTraceUrl, N as toSpaceLeaveUrl, O as toSpaceCreateUrl, P as toSpaceMembersUrl, R as toSpaceResultUrl, S as updateConfiguredOnboardingConfig, T as normalizeBaseUrl, V as toSpaceWsUrl, _ as getRuntimeConfigReadHealth, a as resolveBaseUrlOrNull, b as setConfiguredSkillsConfig, c as DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE, d as getConfiguredDaemonDispatchLimits, f as getConfiguredDeviceRuntimeState, g as getConfiguredViewCustomization, h as getConfiguredStartV1OnboardingState, i as resolveBaseUrl, j as toSpaceDispatchLookupUrl, k as toSpaceCursorUrl, l as alignRuntimeConfigStorage, m as getConfiguredSkillsConfig, n as normalizeGatewayBaseUrl, o as resolveDefaultGatewayBaseUrl, p as getConfiguredOnboardingDisclaimerAcceptedAt, r as normalizeGatewayBaseUrlOrNull, s as resolveExplicitGatewayUrlOrThrow, u as createDefaultRuntimeAgentControllerSettings, v as resolveRuntimeSkillsCustomTargetId, w as updateConfiguredStartV1OnboardingState, x as updateConfiguredDeviceRuntimeState, y as setConfiguredBaseUrl, z as toSpaceSignalsUrl } from "./base-url-CjrWhAM1.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { Command, Option } from "commander";
|
|
8
8
|
import { accessSync, appendFileSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, writeFileSync } from "node:fs";
|
|
@@ -27,12 +27,12 @@ import wrapAnsi from "wrap-ansi";
|
|
|
27
27
|
import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybindings, matchesKey } from "@mariozechner/pi-tui";
|
|
28
28
|
|
|
29
29
|
//#region package.json
|
|
30
|
-
var version = "0.7.
|
|
30
|
+
var version = "0.7.41";
|
|
31
31
|
var package_default = {
|
|
32
32
|
$schema: "https://www.schemastore.org/package.json",
|
|
33
33
|
name: "agent-transport-system",
|
|
34
34
|
version,
|
|
35
|
-
atsReleaseDate: "2026-06-
|
|
35
|
+
atsReleaseDate: "2026-06-06",
|
|
36
36
|
description: "Agent Transport System CLI - https://ats.sh",
|
|
37
37
|
license: "MIT",
|
|
38
38
|
type: "module",
|
|
@@ -363,7 +363,7 @@ var registry_default$1 = {
|
|
|
363
363
|
"kind": "contains",
|
|
364
364
|
"values": ["codex"]
|
|
365
365
|
},
|
|
366
|
-
"transportModes": ["
|
|
366
|
+
"transportModes": ["codex-app-server"],
|
|
367
367
|
"capabilityDeclaration": {
|
|
368
368
|
"streamingCapability": "preview_capable",
|
|
369
369
|
"runtimeWorkingDirectoryMode": "spawn_cwd",
|
|
@@ -375,8 +375,8 @@ var registry_default$1 = {
|
|
|
375
375
|
},
|
|
376
376
|
"originLaunch": { "commandTemplate": "cd {workingDirectory} && codex resume {agentControllerConversationId}" },
|
|
377
377
|
"notes": "Primary runnable agent in current environment.",
|
|
378
|
-
"transportModes": ["
|
|
379
|
-
"defaultTransportMode": "
|
|
378
|
+
"transportModes": ["codex-app-server"],
|
|
379
|
+
"defaultTransportMode": "codex-app-server",
|
|
380
380
|
"defaultStreamingMode": "final"
|
|
381
381
|
},
|
|
382
382
|
{
|
|
@@ -1068,7 +1068,7 @@ const SUPPORTED_PLATFORMS = new Set([
|
|
|
1068
1068
|
"linux",
|
|
1069
1069
|
"win32"
|
|
1070
1070
|
]);
|
|
1071
|
-
const SUPPORTED_TRANSPORT_MODES = new Set(["local-cli"]);
|
|
1071
|
+
const SUPPORTED_TRANSPORT_MODES = new Set(["local-cli", "codex-app-server"]);
|
|
1072
1072
|
const SUPPORTED_STREAMING_MODES = new Set(["final", "stream"]);
|
|
1073
1073
|
const SUPPORTED_RUNTIME_MATCHER_KINDS = new Set([
|
|
1074
1074
|
"contains",
|
|
@@ -1128,6 +1128,7 @@ function resolveRegistryRuntimeAdapterByAgentControllerRef(agentControllerRef) {
|
|
|
1128
1128
|
agentId: runtimeAdapterContract.agentId,
|
|
1129
1129
|
adapterId: runtimeAdapterContract.adapterId,
|
|
1130
1130
|
controllerRefMatcher: runtimeAdapterContract.controllerRefMatcher,
|
|
1131
|
+
...runtimeAdapterContract.defaultTransportMode ? { defaultTransportMode: runtimeAdapterContract.defaultTransportMode } : {},
|
|
1131
1132
|
transportModes: runtimeAdapterContract.transportModes,
|
|
1132
1133
|
...runtimeAdapterContract.defaultStreamingMode ? { defaultStreamingMode: runtimeAdapterContract.defaultStreamingMode } : {}
|
|
1133
1134
|
};
|
|
@@ -1159,6 +1160,7 @@ function resolveRegistryRuntimeAdapterContractByAgentControllerRef(agentControll
|
|
|
1159
1160
|
values: [...adapter.controllerRefMatcher.values]
|
|
1160
1161
|
},
|
|
1161
1162
|
transportModes: [...adapter.transportModes],
|
|
1163
|
+
...agent.defaultTransportMode ? { defaultTransportMode: agent.defaultTransportMode } : {},
|
|
1162
1164
|
...buildRuntimeAdapterStreamingDefaults({
|
|
1163
1165
|
capabilityDeclaration: adapter.capabilityDeclaration,
|
|
1164
1166
|
defaultStreamingMode: agent.defaultStreamingMode
|
|
@@ -1412,7 +1414,7 @@ function parseOptionalStreamingMode(value, context) {
|
|
|
1412
1414
|
return parseStreamingMode$1(value, context);
|
|
1413
1415
|
}
|
|
1414
1416
|
function parseTransportMode$1(value, context) {
|
|
1415
|
-
const transportMode = readEnumValue(value, context, ["local-cli"]);
|
|
1417
|
+
const transportMode = readEnumValue(value, context, ["local-cli", "codex-app-server"]);
|
|
1416
1418
|
if (!SUPPORTED_TRANSPORT_MODES.has(transportMode)) throw new Error(`Unsupported transport mode at ${context}: ${transportMode}`);
|
|
1417
1419
|
return transportMode;
|
|
1418
1420
|
}
|
|
@@ -1600,12 +1602,12 @@ const PROFILE_AWARE_SPACE_COMMANDS = new Set([
|
|
|
1600
1602
|
]);
|
|
1601
1603
|
const SPACE_PARENT_OPTIONS_WITH_VALUE = new Set(["--gateway-url"]);
|
|
1602
1604
|
function resolveUserFacingCliEntryCommand(input = {}) {
|
|
1603
|
-
const explicitCommand = normalizeText$
|
|
1605
|
+
const explicitCommand = normalizeText$11((input.env ?? process$1.env)[ATS_USER_FACING_CLI_COMMAND_ENV$2]);
|
|
1604
1606
|
if (explicitCommand.length > 0) return explicitCommand;
|
|
1605
1607
|
return isNpxCliInvocation(input) ? ATS_CLI_NPX_COMMAND$1 : ATS_CLI_COMMAND;
|
|
1606
1608
|
}
|
|
1607
1609
|
function resolveSetupFollowUpCliEntryCommand(input = {}) {
|
|
1608
|
-
const setupCommand = normalizeText$
|
|
1610
|
+
const setupCommand = normalizeText$11((input.env ?? process$1.env)[ATS_SETUP_FOLLOW_UP_CLI_COMMAND_ENV]);
|
|
1609
1611
|
if (setupCommand.length > 0) return setupCommand;
|
|
1610
1612
|
return resolveUserFacingCliEntryCommand(input);
|
|
1611
1613
|
}
|
|
@@ -1641,9 +1643,9 @@ function formatAtsCliTextBlock(text, input = {}) {
|
|
|
1641
1643
|
function isNpxCliInvocation(input) {
|
|
1642
1644
|
const env = input.env ?? process$1.env;
|
|
1643
1645
|
const argv = input.argv ?? process$1.argv;
|
|
1644
|
-
const npmCommand = normalizeText$
|
|
1646
|
+
const npmCommand = normalizeText$11(env.npm_command).toLowerCase();
|
|
1645
1647
|
const npmExecPath = normalizePath$1(env.npm_execpath);
|
|
1646
|
-
const npmUserAgent = normalizeText$
|
|
1648
|
+
const npmUserAgent = normalizeText$11(env.npm_config_user_agent).toLowerCase();
|
|
1647
1649
|
if (npmCommand === "exec" && (npmUserAgent.startsWith("npm/") || npmExecPath.includes("/npm/") || npmExecPath.endsWith("/npm-cli.js"))) return true;
|
|
1648
1650
|
const scriptPath = normalizePath$1(argv[1]);
|
|
1649
1651
|
return scriptPath.includes("/.npm/") && scriptPath.includes("_npx");
|
|
@@ -1656,7 +1658,7 @@ function formatBareAtsCliMentions(text, input = {}) {
|
|
|
1656
1658
|
function applyProfileAwareCommandScope(command, input) {
|
|
1657
1659
|
if (!ATS_COMMAND_PREFIX_RE$1.test(command)) return command;
|
|
1658
1660
|
let scopedCommand = command.trimEnd();
|
|
1659
|
-
const profileId = normalizeText$
|
|
1661
|
+
const profileId = normalizeText$11(input.profileId ?? void 0);
|
|
1660
1662
|
if (profileId.length > 0) scopedCommand = appendCliOption(scopedCommand, "profile", profileId);
|
|
1661
1663
|
if (input.resolvedView === "agent") scopedCommand = appendCliOption(scopedCommand, "view", "agent");
|
|
1662
1664
|
return scopedCommand;
|
|
@@ -1708,9 +1710,9 @@ function resolveProfileOptionInsertionIndex(tokens) {
|
|
|
1708
1710
|
return index + 1;
|
|
1709
1711
|
}
|
|
1710
1712
|
function normalizePath$1(value) {
|
|
1711
|
-
return normalizeText$
|
|
1713
|
+
return normalizeText$11(value).replaceAll("\\", "/").toLowerCase();
|
|
1712
1714
|
}
|
|
1713
|
-
function normalizeText$
|
|
1715
|
+
function normalizeText$11(value) {
|
|
1714
1716
|
return String(value ?? "").trim();
|
|
1715
1717
|
}
|
|
1716
1718
|
|
|
@@ -2115,8 +2117,8 @@ function buildDaemonControlTargetExamples(input) {
|
|
|
2115
2117
|
})];
|
|
2116
2118
|
}
|
|
2117
2119
|
function validateDaemonControlTargetInput(input) {
|
|
2118
|
-
const dispatch = normalizeOptionalText$
|
|
2119
|
-
const task = normalizeOptionalText$
|
|
2120
|
+
const dispatch = normalizeOptionalText$54(input.dispatch);
|
|
2121
|
+
const task = normalizeOptionalText$54(input.task);
|
|
2120
2122
|
if (dispatch && task || !(dispatch || task)) throw createCommandContractError("daemon.control.invalid_target_selector", DAEMON_CONTROL_TARGET_ERROR);
|
|
2121
2123
|
return {
|
|
2122
2124
|
dispatch,
|
|
@@ -2135,7 +2137,7 @@ function buildDaemonControlTargetCommand(input) {
|
|
|
2135
2137
|
if (input.includeViewFlag) tokens.push("--view", "agent");
|
|
2136
2138
|
return tokens.join(" ");
|
|
2137
2139
|
}
|
|
2138
|
-
function normalizeOptionalText$
|
|
2140
|
+
function normalizeOptionalText$54(value) {
|
|
2139
2141
|
const normalized = String(value ?? "").trim();
|
|
2140
2142
|
return normalized.length > 0 ? normalized : null;
|
|
2141
2143
|
}
|
|
@@ -3798,7 +3800,7 @@ async function requestLatestPackageVersion(packageName) {
|
|
|
3798
3800
|
if (!version) throw new Error("missing version");
|
|
3799
3801
|
return version;
|
|
3800
3802
|
} catch (error) {
|
|
3801
|
-
throw new Error(`version check failed: invalid registry response: ${toErrorMessage$
|
|
3803
|
+
throw new Error(`version check failed: invalid registry response: ${toErrorMessage$37(error)}`);
|
|
3802
3804
|
}
|
|
3803
3805
|
}
|
|
3804
3806
|
function compareSemver(a, b) {
|
|
@@ -3863,20 +3865,20 @@ function toNonEmptyString(value) {
|
|
|
3863
3865
|
const normalized = value.trim();
|
|
3864
3866
|
return normalized.length > 0 ? normalized : null;
|
|
3865
3867
|
}
|
|
3866
|
-
function toErrorMessage$
|
|
3868
|
+
function toErrorMessage$37(error) {
|
|
3867
3869
|
if (error instanceof Error) return error.message;
|
|
3868
3870
|
return String(error);
|
|
3869
3871
|
}
|
|
3870
3872
|
|
|
3871
3873
|
//#endregion
|
|
3872
3874
|
//#region ../../runtime/adapters/core/dist/conversation-bridge.js
|
|
3873
|
-
const normalizeText$
|
|
3875
|
+
const normalizeText$10 = (value) => {
|
|
3874
3876
|
if (typeof value !== "string") return null;
|
|
3875
3877
|
const normalized = value.trim();
|
|
3876
3878
|
return normalized.length > 0 ? normalized : null;
|
|
3877
3879
|
};
|
|
3878
3880
|
const resolveBuiltinAdapterConversationBridgeSpec = (adapterId) => {
|
|
3879
|
-
const rawAgentControllerRef = normalizeText$
|
|
3881
|
+
const rawAgentControllerRef = normalizeText$10(adapterId);
|
|
3880
3882
|
if (!rawAgentControllerRef) return null;
|
|
3881
3883
|
const agentControllerRef = canonicalizeBuiltinAgentControllerRef(rawAgentControllerRef);
|
|
3882
3884
|
if (!agentControllerRef) return null;
|
|
@@ -3893,7 +3895,7 @@ const buildAdapterAgentControllerConversationRef = (input) => buildAgentControll
|
|
|
3893
3895
|
agentControllerConversationKind: input.agentControllerConversationKind
|
|
3894
3896
|
});
|
|
3895
3897
|
const resolveBridgedAgentControllerConversationId = (input) => {
|
|
3896
|
-
const agentControllerConversationId = normalizeText$
|
|
3898
|
+
const agentControllerConversationId = normalizeText$10(input.agentControllerConversationId);
|
|
3897
3899
|
const agentControllerConversation = input.agentControllerConversation;
|
|
3898
3900
|
if (!agentControllerConversation) return agentControllerConversationId;
|
|
3899
3901
|
if (agentControllerConversation.agentControllerRef !== input.bridgeSpec.agentControllerRef) throw new Error(`conversation.bridge.agent_controller_ref_mismatch: expected agentControllerRef=${input.bridgeSpec.agentControllerRef}, received agentControllerRef=${agentControllerConversation.agentControllerRef}`);
|
|
@@ -4215,7 +4217,7 @@ const WINDOWS_PATHEXT = [
|
|
|
4215
4217
|
const SHEBANG_ARGS_SPLIT_RE = /\s+/;
|
|
4216
4218
|
const FIRST_LINE_SPLIT_RE = /\r?\n/u;
|
|
4217
4219
|
const NODE_VERSION_PATH_RE = /(?:^|\/)v?(\d+\.\d+\.\d+)(?:\/|$)/u;
|
|
4218
|
-
const HOME_DIR = normalizeOptionalText$
|
|
4220
|
+
const HOME_DIR = normalizeOptionalText$53(homedir());
|
|
4219
4221
|
function buildExecutableLaunchContract(input) {
|
|
4220
4222
|
return {
|
|
4221
4223
|
kind: "executable",
|
|
@@ -4259,7 +4261,7 @@ async function verifyLaunchContractFiles(input) {
|
|
|
4259
4261
|
};
|
|
4260
4262
|
} catch (error) {
|
|
4261
4263
|
return {
|
|
4262
|
-
errorMessage: toErrorMessage$
|
|
4264
|
+
errorMessage: toErrorMessage$36(error),
|
|
4263
4265
|
ok: false
|
|
4264
4266
|
};
|
|
4265
4267
|
}
|
|
@@ -4286,7 +4288,7 @@ async function verifyCliLaunchContract(input) {
|
|
|
4286
4288
|
return fileCheck;
|
|
4287
4289
|
} catch (error) {
|
|
4288
4290
|
return {
|
|
4289
|
-
errorMessage: `${input.displayName} can't start on this device: ${toErrorMessage$
|
|
4291
|
+
errorMessage: `${input.displayName} can't start on this device: ${toErrorMessage$36(error)}`,
|
|
4290
4292
|
ok: false
|
|
4291
4293
|
};
|
|
4292
4294
|
}
|
|
@@ -4347,7 +4349,7 @@ async function inspectInstalledNodeScriptLaunchCandidate(input) {
|
|
|
4347
4349
|
};
|
|
4348
4350
|
} catch (error) {
|
|
4349
4351
|
return {
|
|
4350
|
-
errorMessage: `${input.displayName} is installed, but ATS could not inspect its launch files: ${toErrorMessage$
|
|
4352
|
+
errorMessage: `${input.displayName} is installed, but ATS could not inspect its launch files: ${toErrorMessage$36(error)}`,
|
|
4351
4353
|
ok: false
|
|
4352
4354
|
};
|
|
4353
4355
|
}
|
|
@@ -4356,7 +4358,7 @@ function resolveInstalledCommandPath(input) {
|
|
|
4356
4358
|
return resolveInstalledCommandPaths(input)[0] ?? null;
|
|
4357
4359
|
}
|
|
4358
4360
|
function resolveInstalledCommandPaths(input) {
|
|
4359
|
-
const configuredCommand = normalizeOptionalText$
|
|
4361
|
+
const configuredCommand = normalizeOptionalText$53(input.configuredCommand);
|
|
4360
4362
|
if (configuredCommand) {
|
|
4361
4363
|
if (isAbsolute(configuredCommand)) return [configuredCommand];
|
|
4362
4364
|
if (configuredCommand.includes("/") || configuredCommand.includes("\\")) return [];
|
|
@@ -4365,9 +4367,9 @@ function resolveInstalledCommandPaths(input) {
|
|
|
4365
4367
|
return resolveExecutablePathsOnPath(input.commandName);
|
|
4366
4368
|
}
|
|
4367
4369
|
function resolveExecutablePathsOnPath(commandName) {
|
|
4368
|
-
const normalizedCommandName = normalizeOptionalText$
|
|
4370
|
+
const normalizedCommandName = normalizeOptionalText$53(commandName);
|
|
4369
4371
|
if (!normalizedCommandName) return [];
|
|
4370
|
-
const pathValue = normalizeOptionalText$
|
|
4372
|
+
const pathValue = normalizeOptionalText$53(process.env.PATH);
|
|
4371
4373
|
if (!pathValue) return [];
|
|
4372
4374
|
const resolvedPaths = [];
|
|
4373
4375
|
for (const pathEntry of pathValue.split(delimiter)) {
|
|
@@ -4381,7 +4383,7 @@ function resolveExecutablePathsOnPath(commandName) {
|
|
|
4381
4383
|
return resolvedPaths;
|
|
4382
4384
|
}
|
|
4383
4385
|
function resolveSiblingCommandPath(input) {
|
|
4384
|
-
const normalizedCommandName = normalizeOptionalText$
|
|
4386
|
+
const normalizedCommandName = normalizeOptionalText$53(input.commandName);
|
|
4385
4387
|
if (!normalizedCommandName) return null;
|
|
4386
4388
|
const siblingDirectory = dirname(input.anchorPath);
|
|
4387
4389
|
for (const candidateName of resolveCommandFileNameCandidates(normalizedCommandName)) {
|
|
@@ -4391,7 +4393,7 @@ function resolveSiblingCommandPath(input) {
|
|
|
4391
4393
|
return null;
|
|
4392
4394
|
}
|
|
4393
4395
|
async function resolvePinnedNodePath(input) {
|
|
4394
|
-
const firstLine = normalizeOptionalText$
|
|
4396
|
+
const firstLine = normalizeOptionalText$53(input.firstLine);
|
|
4395
4397
|
if (!firstLine) return null;
|
|
4396
4398
|
if (firstLine === ENV_NODE_SHEBANG) {
|
|
4397
4399
|
const nodeSibling = join(dirname(input.commandPath), "node");
|
|
@@ -4403,7 +4405,7 @@ async function resolvePinnedNodePath(input) {
|
|
|
4403
4405
|
}
|
|
4404
4406
|
}
|
|
4405
4407
|
if (!firstLine.startsWith("#!")) return null;
|
|
4406
|
-
const interpreter = normalizeOptionalText$
|
|
4408
|
+
const interpreter = normalizeOptionalText$53(firstLine.slice(2));
|
|
4407
4409
|
if (!(interpreter && isAbsolute(interpreter))) return null;
|
|
4408
4410
|
const normalizedInterpreter = interpreter.split(SHEBANG_ARGS_SPLIT_RE, 1)[0] ?? interpreter;
|
|
4409
4411
|
try {
|
|
@@ -4414,7 +4416,7 @@ async function resolvePinnedNodePath(input) {
|
|
|
4414
4416
|
}
|
|
4415
4417
|
}
|
|
4416
4418
|
async function readFirstLine(path) {
|
|
4417
|
-
return normalizeOptionalText$
|
|
4419
|
+
return normalizeOptionalText$53((await readFile(path, "utf8")).split(FIRST_LINE_SPLIT_RE, 1)[0] ?? "");
|
|
4418
4420
|
}
|
|
4419
4421
|
async function assertExecutablePath(path) {
|
|
4420
4422
|
await access(path, resolveRunnablePathAccessMode());
|
|
@@ -4446,11 +4448,11 @@ function resolveRunnablePathAccessMode() {
|
|
|
4446
4448
|
return process.platform === "win32" ? constants.F_OK : constants.X_OK;
|
|
4447
4449
|
}
|
|
4448
4450
|
function resolveWindowsPathExtensions(value) {
|
|
4449
|
-
const normalized = normalizeOptionalText$
|
|
4451
|
+
const normalized = normalizeOptionalText$53(value);
|
|
4450
4452
|
if (!normalized) return [...WINDOWS_PATHEXT];
|
|
4451
4453
|
return normalized.split(";").map((entry) => entry.trim().toLowerCase()).filter((entry, index, values) => entry && values.indexOf(entry) === index).map((entry) => entry.startsWith(".") ? entry : `.${entry}`);
|
|
4452
4454
|
}
|
|
4453
|
-
function normalizeOptionalText$
|
|
4455
|
+
function normalizeOptionalText$53(value) {
|
|
4454
4456
|
const normalized = String(value ?? "").trim();
|
|
4455
4457
|
return normalized.length > 0 ? normalized : null;
|
|
4456
4458
|
}
|
|
@@ -4542,9 +4544,9 @@ function shortenPathForDisplay(path) {
|
|
|
4542
4544
|
return `~${path.slice(HOME_DIR.length)}`;
|
|
4543
4545
|
}
|
|
4544
4546
|
function resolveNodeVersionFromPath(path) {
|
|
4545
|
-
return normalizeOptionalText$
|
|
4547
|
+
return normalizeOptionalText$53(path.match(NODE_VERSION_PATH_RE)?.[1]);
|
|
4546
4548
|
}
|
|
4547
|
-
function toErrorMessage$
|
|
4549
|
+
function toErrorMessage$36(error) {
|
|
4548
4550
|
return error instanceof Error ? error.message : String(error);
|
|
4549
4551
|
}
|
|
4550
4552
|
|
|
@@ -4569,9 +4571,9 @@ const buildProviderExitError = (input) => {
|
|
|
4569
4571
|
};
|
|
4570
4572
|
};
|
|
4571
4573
|
const hasVisibleText = (value) => {
|
|
4572
|
-
return normalizeOptionalText$
|
|
4574
|
+
return normalizeOptionalText$52(value) !== null;
|
|
4573
4575
|
};
|
|
4574
|
-
const normalizeOptionalText$
|
|
4576
|
+
const normalizeOptionalText$52 = (value) => {
|
|
4575
4577
|
if (typeof value !== "string") return null;
|
|
4576
4578
|
const normalized = value.trim();
|
|
4577
4579
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -4582,7 +4584,7 @@ const normalizeOptionalText$51 = (value) => {
|
|
|
4582
4584
|
const DEFAULT_GRACEFUL_INTERRUPT_TIMEOUT_MS = 1e4;
|
|
4583
4585
|
const DEFAULT_INTERRUPT_REASON = "service.interrupt";
|
|
4584
4586
|
const DEFAULT_CANCEL_REASON = "service.cancel";
|
|
4585
|
-
const TEST_DISABLE_DEFAULT_INVOKE = Symbol.for("ats.test.disableDefaultInvoke");
|
|
4587
|
+
const TEST_DISABLE_DEFAULT_INVOKE$1 = Symbol.for("ats.test.disableDefaultInvoke");
|
|
4586
4588
|
const createSharedDispatchShell = (input) => {
|
|
4587
4589
|
const bridgeSpec = input.bridgeSpec ?? null;
|
|
4588
4590
|
return async (dispatchInput) => {
|
|
@@ -4594,7 +4596,7 @@ const createSharedDispatchShell = (input) => {
|
|
|
4594
4596
|
errorType: "adapter",
|
|
4595
4597
|
status: "failed"
|
|
4596
4598
|
};
|
|
4597
|
-
const defaultInvoke = isDefaultInvokeDisabledForTests(input.runtimeOptions) ? null : input.resolveDefaultInvoke() ?? null;
|
|
4599
|
+
const defaultInvoke = isDefaultInvokeDisabledForTests$1(input.runtimeOptions) ? null : input.resolveDefaultInvoke() ?? null;
|
|
4598
4600
|
const resolvedInvoke = transportInvoke ?? input.invoke ?? defaultInvoke;
|
|
4599
4601
|
if (!resolvedInvoke) return {
|
|
4600
4602
|
errorCode: "controller.runtime.missing",
|
|
@@ -4876,18 +4878,18 @@ const buildDefaultInvokeRequest = (input) => {
|
|
|
4876
4878
|
agentControllerConversationId: input.request.agentControllerConversationId,
|
|
4877
4879
|
bridgeSpec: input.bridgeSpec,
|
|
4878
4880
|
agentControllerConversation: input.request.agentControllerConversation
|
|
4879
|
-
}) : normalizeOptionalText$
|
|
4881
|
+
}) : normalizeOptionalText$51(input.request.agentControllerConversationId);
|
|
4880
4882
|
return {
|
|
4881
4883
|
...input.request,
|
|
4882
4884
|
agentControllerConversationId
|
|
4883
4885
|
};
|
|
4884
4886
|
};
|
|
4885
|
-
const normalizeOptionalText$
|
|
4887
|
+
const normalizeOptionalText$51 = (value) => {
|
|
4886
4888
|
if (typeof value !== "string") return null;
|
|
4887
4889
|
const normalized = value.trim();
|
|
4888
4890
|
return normalized.length > 0 ? normalized : null;
|
|
4889
4891
|
};
|
|
4890
|
-
const isDefaultInvokeDisabledForTests = (runtimeOptions) => runtimeOptions?.[TEST_DISABLE_DEFAULT_INVOKE] === true;
|
|
4892
|
+
const isDefaultInvokeDisabledForTests$1 = (runtimeOptions) => runtimeOptions?.[TEST_DISABLE_DEFAULT_INVOKE$1] === true;
|
|
4891
4893
|
const resolveCancelSignalSender = (input) => {
|
|
4892
4894
|
if (input.sendCancel) return {
|
|
4893
4895
|
deliveryPath: "cancel",
|
|
@@ -4924,7 +4926,7 @@ const DEFAULT_CLAUDE_CODE_COMMAND = "claude";
|
|
|
4924
4926
|
async function resolveInstalledClaudeCodeLaunchCandidates() {
|
|
4925
4927
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
4926
4928
|
commandName: DEFAULT_CLAUDE_CODE_COMMAND,
|
|
4927
|
-
configuredCommand: normalizeOptionalText$
|
|
4929
|
+
configuredCommand: normalizeOptionalText$50(process.env.ATSD_RUNTIME_CLAUDE_CODE_BIN),
|
|
4928
4930
|
displayName: "Claude Code"
|
|
4929
4931
|
});
|
|
4930
4932
|
if (!installedCandidates.ok) return installedCandidates;
|
|
@@ -4952,13 +4954,13 @@ async function verifyClaudeCodeLaunchContract(input) {
|
|
|
4952
4954
|
});
|
|
4953
4955
|
}
|
|
4954
4956
|
function resolveClaudeCodeTimeoutMs() {
|
|
4955
|
-
const raw = normalizeOptionalText$
|
|
4957
|
+
const raw = normalizeOptionalText$50(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
4956
4958
|
if (!raw) return null;
|
|
4957
4959
|
const parsed = Number.parseInt(raw, 10);
|
|
4958
4960
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
4959
4961
|
return parsed;
|
|
4960
4962
|
}
|
|
4961
|
-
function normalizeOptionalText$
|
|
4963
|
+
function normalizeOptionalText$50(value) {
|
|
4962
4964
|
const normalized = String(value ?? "").trim();
|
|
4963
4965
|
return normalized.length > 0 ? normalized : null;
|
|
4964
4966
|
}
|
|
@@ -4989,8 +4991,8 @@ function parseClaudeOutputLine(line) {
|
|
|
4989
4991
|
}
|
|
4990
4992
|
const record = toObjectRecord(parsed);
|
|
4991
4993
|
if (!record) return null;
|
|
4992
|
-
const sessionId = normalizeOptionalText$
|
|
4993
|
-
const resultText = normalizeOptionalText$
|
|
4994
|
+
const sessionId = normalizeOptionalText$49(record.session_id);
|
|
4995
|
+
const resultText = normalizeOptionalText$49(record.result);
|
|
4994
4996
|
const isErrorResult = typeof record.is_error === "boolean" ? record.is_error : null;
|
|
4995
4997
|
if (record.type === "result") return {
|
|
4996
4998
|
errorMessage: isErrorResult ? resultText : null,
|
|
@@ -5001,7 +5003,7 @@ function parseClaudeOutputLine(line) {
|
|
|
5001
5003
|
terminal: true
|
|
5002
5004
|
};
|
|
5003
5005
|
if (record.type === "error") return {
|
|
5004
|
-
errorMessage: normalizeOptionalText$
|
|
5006
|
+
errorMessage: normalizeOptionalText$49(record.message),
|
|
5005
5007
|
isErrorResult: true,
|
|
5006
5008
|
previewDeltaText: null,
|
|
5007
5009
|
resultText: null,
|
|
@@ -5017,7 +5019,7 @@ function parseClaudeOutputLine(line) {
|
|
|
5017
5019
|
function parseClaudeStreamEvent(record, sessionId) {
|
|
5018
5020
|
const event = toObjectRecord(record.event);
|
|
5019
5021
|
if (!event) return null;
|
|
5020
|
-
const eventType = normalizeOptionalText$
|
|
5022
|
+
const eventType = normalizeOptionalText$49(event.type);
|
|
5021
5023
|
if (eventType === "message_start") return {
|
|
5022
5024
|
errorMessage: null,
|
|
5023
5025
|
isErrorResult: null,
|
|
@@ -5041,11 +5043,11 @@ function parseClaudeStreamEvent(record, sessionId) {
|
|
|
5041
5043
|
function toObjectRecord(value) {
|
|
5042
5044
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
5043
5045
|
}
|
|
5044
|
-
function normalizeText$
|
|
5046
|
+
function normalizeText$9(value) {
|
|
5045
5047
|
return String(value ?? "").trim();
|
|
5046
5048
|
}
|
|
5047
|
-
function normalizeOptionalText$
|
|
5048
|
-
const normalized = normalizeText$
|
|
5049
|
+
function normalizeOptionalText$49(value) {
|
|
5050
|
+
const normalized = normalizeText$9(value);
|
|
5049
5051
|
return normalized.length > 0 ? normalized : null;
|
|
5050
5052
|
}
|
|
5051
5053
|
function preserveOptionalText(value) {
|
|
@@ -5069,7 +5071,7 @@ var ClaudeCliTransportError = class extends Error {
|
|
|
5069
5071
|
}
|
|
5070
5072
|
};
|
|
5071
5073
|
async function invokeClaudeCliTransport(input) {
|
|
5072
|
-
const prompt = normalizeOptionalText$
|
|
5074
|
+
const prompt = normalizeOptionalText$48(input.prompt);
|
|
5073
5075
|
if (!prompt) throw new ClaudeCliTransportError({
|
|
5074
5076
|
code: "schema.invalid",
|
|
5075
5077
|
errorType: "config",
|
|
@@ -5079,7 +5081,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5079
5081
|
args: buildClaudeArgs({
|
|
5080
5082
|
executionMode: input.executionMode,
|
|
5081
5083
|
prompt,
|
|
5082
|
-
sessionId: normalizeOptionalText$
|
|
5084
|
+
sessionId: normalizeOptionalText$48(input.sessionId),
|
|
5083
5085
|
streamingMode: input.streamingMode
|
|
5084
5086
|
}),
|
|
5085
5087
|
launchContract: input.launchContract
|
|
@@ -5087,7 +5089,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5087
5089
|
const invokedAtMs = Date.now();
|
|
5088
5090
|
let latestOutput = "";
|
|
5089
5091
|
let latestResultIsError = false;
|
|
5090
|
-
let resolvedSessionId = normalizeOptionalText$
|
|
5092
|
+
let resolvedSessionId = normalizeOptionalText$48(input.sessionId);
|
|
5091
5093
|
const providerErrorMessages = [];
|
|
5092
5094
|
let firstStdoutAtMs = null;
|
|
5093
5095
|
let firstOutputAtMs = null;
|
|
@@ -5148,7 +5150,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5148
5150
|
...classifiedFailure.providerAccessEvidence ? { providerAccessEvidence: classifiedFailure.providerAccessEvidence } : {}
|
|
5149
5151
|
});
|
|
5150
5152
|
}
|
|
5151
|
-
const output = normalizeOptionalText$
|
|
5153
|
+
const output = normalizeOptionalText$48(latestOutput);
|
|
5152
5154
|
if (!output) throw new ClaudeCliTransportError({
|
|
5153
5155
|
code: "runtime.output.empty",
|
|
5154
5156
|
errorType: "adapter",
|
|
@@ -5156,7 +5158,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5156
5158
|
});
|
|
5157
5159
|
return {
|
|
5158
5160
|
output,
|
|
5159
|
-
sessionId: normalizeOptionalText$
|
|
5161
|
+
sessionId: normalizeOptionalText$48(resolvedSessionId),
|
|
5160
5162
|
telemetry: {
|
|
5161
5163
|
completedAtMs: Date.now(),
|
|
5162
5164
|
...driverResult.lifecycle.exitCode === null ? {} : { exitCode: driverResult.lifecycle.exitCode },
|
|
@@ -5169,7 +5171,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5169
5171
|
previewEmitted: previewEmitter.emitted,
|
|
5170
5172
|
...driverResult.lifecycle.processId === null ? {} : { processId: driverResult.lifecycle.processId },
|
|
5171
5173
|
...driverResult.lifecycle.processSpawnedAtMs === null ? {} : { processSpawnedAtMs: driverResult.lifecycle.processSpawnedAtMs },
|
|
5172
|
-
resumedContext: normalizeOptionalText$
|
|
5174
|
+
resumedContext: normalizeOptionalText$48(input.sessionId) !== null,
|
|
5173
5175
|
...driverResult.lifecycle.stdinClosedAtMs === null ? {} : { stdinClosedAtMs: driverResult.lifecycle.stdinClosedAtMs },
|
|
5174
5176
|
streamingMode: input.streamingMode ?? "final",
|
|
5175
5177
|
...driverResult.lifecycle.timeoutTriggeredAtMs === null ? {} : { timeoutTriggeredAtMs: driverResult.lifecycle.timeoutTriggeredAtMs }
|
|
@@ -5337,7 +5339,7 @@ const classifyClaudeFailure = (input) => {
|
|
|
5337
5339
|
message: providerMessage
|
|
5338
5340
|
};
|
|
5339
5341
|
}
|
|
5340
|
-
const stderrText = normalizeOptionalText$
|
|
5342
|
+
const stderrText = normalizeOptionalText$48(input.stderrText);
|
|
5341
5343
|
if (stderrText) return {
|
|
5342
5344
|
code: "upstream_unreachable",
|
|
5343
5345
|
errorType: "adapter",
|
|
@@ -5349,13 +5351,13 @@ const resolveProviderFailureMessage$2 = (input) => {
|
|
|
5349
5351
|
const candidateMessages = [
|
|
5350
5352
|
...input.providerErrorMessages,
|
|
5351
5353
|
...extractErrorMessagesFromStdout$1(input.stdoutText),
|
|
5352
|
-
...normalizeOptionalText$
|
|
5354
|
+
...normalizeOptionalText$48(input.stderrText) ? [normalizeOptionalText$48(input.stderrText)] : []
|
|
5353
5355
|
].filter((value) => Boolean(value));
|
|
5354
5356
|
for (const candidate of candidateMessages) if (looksLikeProviderFailure$2(candidate)) return candidate;
|
|
5355
5357
|
return candidateMessages[0] ?? null;
|
|
5356
5358
|
};
|
|
5357
5359
|
const extractErrorMessagesFromStdout$1 = (value) => {
|
|
5358
|
-
const stdoutText = normalizeOptionalText$
|
|
5360
|
+
const stdoutText = normalizeOptionalText$48(value);
|
|
5359
5361
|
if (!stdoutText) return [];
|
|
5360
5362
|
const messages = [];
|
|
5361
5363
|
const lines = stdoutText.split("\n");
|
|
@@ -5366,7 +5368,7 @@ const extractErrorMessagesFromStdout$1 = (value) => {
|
|
|
5366
5368
|
return messages;
|
|
5367
5369
|
};
|
|
5368
5370
|
const collectProviderErrorMessage$1 = (line, messages) => {
|
|
5369
|
-
const normalizedLine = normalizeOptionalText$
|
|
5371
|
+
const normalizedLine = normalizeOptionalText$48(line);
|
|
5370
5372
|
if (!normalizedLine) return;
|
|
5371
5373
|
messages.push(normalizedLine);
|
|
5372
5374
|
};
|
|
@@ -5404,11 +5406,11 @@ const buildClaudeCodeProviderAccessEvidence = (normalizedProviderMessage) => {
|
|
|
5404
5406
|
const isRateLimitFailure$2 = (value) => {
|
|
5405
5407
|
return value.includes("429") || value.includes("rate limit") || value.includes("too many requests");
|
|
5406
5408
|
};
|
|
5407
|
-
function normalizeText$
|
|
5409
|
+
function normalizeText$8(value) {
|
|
5408
5410
|
return String(value ?? "").trim();
|
|
5409
5411
|
}
|
|
5410
|
-
function normalizeOptionalText$
|
|
5411
|
-
const normalized = normalizeText$
|
|
5412
|
+
function normalizeOptionalText$48(value) {
|
|
5413
|
+
const normalized = normalizeText$8(value);
|
|
5412
5414
|
return normalized.length > 0 ? normalized : null;
|
|
5413
5415
|
}
|
|
5414
5416
|
|
|
@@ -5434,7 +5436,7 @@ async function invokeClaudeWithSingleContextHeal(input) {
|
|
|
5434
5436
|
return new ClaudeRuntimeError({
|
|
5435
5437
|
code: "context.rebuild_failed",
|
|
5436
5438
|
errorType: "adapter",
|
|
5437
|
-
message: `context.rebuild_failed: ${toErrorMessage$
|
|
5439
|
+
message: `context.rebuild_failed: ${toErrorMessage$35(error)}`,
|
|
5438
5440
|
...providerAccessEvidence ? { providerAccessEvidence } : {}
|
|
5439
5441
|
});
|
|
5440
5442
|
},
|
|
@@ -5494,7 +5496,7 @@ async function invokeClaudeOnce(input) {
|
|
|
5494
5496
|
throw new ClaudeRuntimeError({
|
|
5495
5497
|
code: "upstream_unreachable",
|
|
5496
5498
|
errorType: "adapter",
|
|
5497
|
-
message: `upstream_unreachable: ${toErrorMessage$
|
|
5499
|
+
message: `upstream_unreachable: ${toErrorMessage$35(error)}`
|
|
5498
5500
|
});
|
|
5499
5501
|
}
|
|
5500
5502
|
}
|
|
@@ -5504,7 +5506,7 @@ function getClaudeProviderAccessEvidence(error) {
|
|
|
5504
5506
|
if (!evidence || typeof evidence !== "object") return null;
|
|
5505
5507
|
return evidence;
|
|
5506
5508
|
}
|
|
5507
|
-
function toErrorMessage$
|
|
5509
|
+
function toErrorMessage$35(error) {
|
|
5508
5510
|
if (error instanceof Error) return error.message;
|
|
5509
5511
|
return String(error);
|
|
5510
5512
|
}
|
|
@@ -5558,7 +5560,7 @@ const resolveDefaultClaudeCodeInvoke = (options) => {
|
|
|
5558
5560
|
...onProcessControlEvent ? { onProcessControlEvent } : {},
|
|
5559
5561
|
...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
|
|
5560
5562
|
prompt: input.prompt,
|
|
5561
|
-
sessionId: normalizeOptionalText$
|
|
5563
|
+
sessionId: normalizeOptionalText$47(input.agentControllerConversationId),
|
|
5562
5564
|
...input.onPreview ? { onPreview: input.onPreview } : {},
|
|
5563
5565
|
streamingMode: input.streamingMode
|
|
5564
5566
|
});
|
|
@@ -5578,7 +5580,7 @@ const resolveDefaultClaudeCodeInvoke = (options) => {
|
|
|
5578
5580
|
};
|
|
5579
5581
|
};
|
|
5580
5582
|
async function resolveClaudeDispatchLaunchContract(input) {
|
|
5581
|
-
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$
|
|
5583
|
+
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$47(input.claudeBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$47(input.claudeBin) }) : null);
|
|
5582
5584
|
if (explicitLaunchContract) {
|
|
5583
5585
|
const verification = await verifyClaudeCodeLaunchContract({ launchContract: explicitLaunchContract });
|
|
5584
5586
|
if (verification.ok) return explicitLaunchContract;
|
|
@@ -5592,7 +5594,7 @@ async function resolveClaudeDispatchLaunchContract(input) {
|
|
|
5592
5594
|
errorType: "config"
|
|
5593
5595
|
});
|
|
5594
5596
|
}
|
|
5595
|
-
const normalizeOptionalText$
|
|
5597
|
+
const normalizeOptionalText$47 = (value) => {
|
|
5596
5598
|
const normalized = String(value ?? "").trim();
|
|
5597
5599
|
return normalized.length > 0 ? normalized : null;
|
|
5598
5600
|
};
|
|
@@ -5620,7 +5622,7 @@ const DEFAULT_CODEX_COMMAND = "codex";
|
|
|
5620
5622
|
async function resolveInstalledCodexLaunchCandidates() {
|
|
5621
5623
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
5622
5624
|
commandName: DEFAULT_CODEX_COMMAND,
|
|
5623
|
-
configuredCommand: normalizeOptionalText$
|
|
5625
|
+
configuredCommand: normalizeOptionalText$46(process.env.ATSD_RUNTIME_CODEX_BIN),
|
|
5624
5626
|
displayName: "Codex"
|
|
5625
5627
|
});
|
|
5626
5628
|
if (!installedCandidates.ok) return installedCandidates;
|
|
@@ -5648,13 +5650,13 @@ async function verifyCodexLaunchContract(input) {
|
|
|
5648
5650
|
});
|
|
5649
5651
|
}
|
|
5650
5652
|
function resolveCodexTimeoutMs() {
|
|
5651
|
-
const raw = normalizeOptionalText$
|
|
5653
|
+
const raw = normalizeOptionalText$46(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
5652
5654
|
if (!raw) return null;
|
|
5653
5655
|
const parsed = Number.parseInt(raw, 10);
|
|
5654
5656
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
5655
5657
|
return parsed;
|
|
5656
5658
|
}
|
|
5657
|
-
function normalizeOptionalText$
|
|
5659
|
+
function normalizeOptionalText$46(value) {
|
|
5658
5660
|
const normalized = String(value ?? "").trim();
|
|
5659
5661
|
return normalized.length > 0 ? normalized : null;
|
|
5660
5662
|
}
|
|
@@ -5674,6 +5676,619 @@ function isLikelyContextLostError(message) {
|
|
|
5674
5676
|
return CONTEXT_LOST_ERROR_PATTERNS.some((pattern) => pattern.test(message));
|
|
5675
5677
|
}
|
|
5676
5678
|
|
|
5679
|
+
//#endregion
|
|
5680
|
+
//#region ../../runtime/adapters/codex/dist/transport/codex-app-server-transport.js
|
|
5681
|
+
const APP_SERVER_APPROVAL_POLICY = "never";
|
|
5682
|
+
const APP_SERVER_PROCESS_KILL_GRACE_MS = 1e3;
|
|
5683
|
+
var CodexAppServerTransportError = class extends Error {
|
|
5684
|
+
code;
|
|
5685
|
+
errorType;
|
|
5686
|
+
constructor(input) {
|
|
5687
|
+
super(input.message);
|
|
5688
|
+
this.name = "CodexAppServerTransportError";
|
|
5689
|
+
this.code = input.code;
|
|
5690
|
+
this.errorType = input.errorType;
|
|
5691
|
+
}
|
|
5692
|
+
};
|
|
5693
|
+
async function invokeCodexAppServerTransport(input) {
|
|
5694
|
+
const prompt = normalizeOptionalText$45(input.prompt);
|
|
5695
|
+
if (!prompt) throw new CodexAppServerTransportError({
|
|
5696
|
+
code: "schema.invalid",
|
|
5697
|
+
errorType: "config",
|
|
5698
|
+
message: "schema.invalid: prompt is required"
|
|
5699
|
+
});
|
|
5700
|
+
const invokedAtMs = Date.now();
|
|
5701
|
+
return await withCodexAppServerSession({
|
|
5702
|
+
codexTimeoutMs: input.codexTimeoutMs,
|
|
5703
|
+
codexWorkdir: input.codexWorkdir,
|
|
5704
|
+
env: input.env,
|
|
5705
|
+
launchContract: input.launchContract,
|
|
5706
|
+
onProcessControlEvent: input.onProcessControlEvent,
|
|
5707
|
+
onRuntimeEvent: input.onRuntimeEvent
|
|
5708
|
+
}, async (session) => {
|
|
5709
|
+
const threadId = await resolveDispatchThreadId({
|
|
5710
|
+
codexWorkdir: input.codexWorkdir,
|
|
5711
|
+
session,
|
|
5712
|
+
threadId: input.threadId
|
|
5713
|
+
});
|
|
5714
|
+
session.emitProviderConversationObserved(threadId);
|
|
5715
|
+
const turn = readTurnStartResponse(await session.request("turn/start", {
|
|
5716
|
+
approvalPolicy: APP_SERVER_APPROVAL_POLICY,
|
|
5717
|
+
cwd: input.codexWorkdir,
|
|
5718
|
+
input: [{
|
|
5719
|
+
text: prompt,
|
|
5720
|
+
text_elements: [],
|
|
5721
|
+
type: "text"
|
|
5722
|
+
}],
|
|
5723
|
+
threadId
|
|
5724
|
+
}));
|
|
5725
|
+
const turnId = readRequiredText(turn.id, "turn/start response turn.id");
|
|
5726
|
+
const completedTurn = turn.status === "completed" ? turn : await session.waitForTurnCompleted({
|
|
5727
|
+
threadId,
|
|
5728
|
+
turnId
|
|
5729
|
+
});
|
|
5730
|
+
const output = normalizeOptionalText$45(readAgentMessageOutput(completedTurn) ?? session.readCollectedAgentMessageDeltaText());
|
|
5731
|
+
if (completedTurn.status === "failed") throw new CodexAppServerTransportError({
|
|
5732
|
+
code: "runtime.turn.failed",
|
|
5733
|
+
errorType: "adapter",
|
|
5734
|
+
message: `runtime.turn.failed: ${readTurnFailureMessage(completedTurn)}`
|
|
5735
|
+
});
|
|
5736
|
+
if (output) session.markAgentOutputObserved();
|
|
5737
|
+
await emitPreviewIfRequested({
|
|
5738
|
+
onPreview: input.onPreview,
|
|
5739
|
+
output: output ?? "",
|
|
5740
|
+
streamingMode: input.streamingMode
|
|
5741
|
+
});
|
|
5742
|
+
return {
|
|
5743
|
+
output: output ?? "",
|
|
5744
|
+
telemetry: session.buildTelemetry({
|
|
5745
|
+
invokedAtMs,
|
|
5746
|
+
previewEmitted: input.streamingMode === "stream" && input.onPreview !== void 0,
|
|
5747
|
+
resumedContext: normalizeOptionalText$45(input.threadId) !== null,
|
|
5748
|
+
streamingMode: input.streamingMode ?? "final"
|
|
5749
|
+
}),
|
|
5750
|
+
threadId
|
|
5751
|
+
};
|
|
5752
|
+
});
|
|
5753
|
+
}
|
|
5754
|
+
async function verifyCodexAppServerThread(input) {
|
|
5755
|
+
const threadId = normalizeOptionalText$45(input.threadId);
|
|
5756
|
+
if (!threadId) throw new CodexAppServerTransportError({
|
|
5757
|
+
code: "schema.invalid",
|
|
5758
|
+
errorType: "config",
|
|
5759
|
+
message: "schema.invalid: threadId is required"
|
|
5760
|
+
});
|
|
5761
|
+
return await withCodexAppServerSession({
|
|
5762
|
+
codexTimeoutMs: input.codexTimeoutMs,
|
|
5763
|
+
codexWorkdir: input.codexWorkdir,
|
|
5764
|
+
env: input.env,
|
|
5765
|
+
launchContract: input.launchContract
|
|
5766
|
+
}, async (session) => {
|
|
5767
|
+
return { threadId: readThreadIdFromResponse(await session.request("thread/resume", {
|
|
5768
|
+
approvalPolicy: APP_SERVER_APPROVAL_POLICY,
|
|
5769
|
+
cwd: input.codexWorkdir,
|
|
5770
|
+
threadId
|
|
5771
|
+
})) };
|
|
5772
|
+
});
|
|
5773
|
+
}
|
|
5774
|
+
async function resolveDispatchThreadId(input) {
|
|
5775
|
+
const existingThreadId = normalizeOptionalText$45(input.threadId);
|
|
5776
|
+
if (existingThreadId) return readThreadIdFromResponse(await input.session.request("thread/resume", {
|
|
5777
|
+
approvalPolicy: APP_SERVER_APPROVAL_POLICY,
|
|
5778
|
+
cwd: input.codexWorkdir,
|
|
5779
|
+
threadId: existingThreadId
|
|
5780
|
+
}));
|
|
5781
|
+
return readThreadIdFromResponse(await input.session.request("thread/start", {
|
|
5782
|
+
approvalPolicy: APP_SERVER_APPROVAL_POLICY,
|
|
5783
|
+
cwd: input.codexWorkdir,
|
|
5784
|
+
threadSource: "user"
|
|
5785
|
+
}));
|
|
5786
|
+
}
|
|
5787
|
+
async function withCodexAppServerSession(input, callback) {
|
|
5788
|
+
const session = new CodexAppServerSession(input);
|
|
5789
|
+
try {
|
|
5790
|
+
await session.start();
|
|
5791
|
+
return await callback(session);
|
|
5792
|
+
} catch (error) {
|
|
5793
|
+
throw toCodexAppServerTransportError(error, input.codexTimeoutMs);
|
|
5794
|
+
} finally {
|
|
5795
|
+
await session.close();
|
|
5796
|
+
}
|
|
5797
|
+
}
|
|
5798
|
+
var CodexAppServerSession = class {
|
|
5799
|
+
#codexTimeoutMs;
|
|
5800
|
+
#codexWorkdir;
|
|
5801
|
+
#env;
|
|
5802
|
+
#launchContract;
|
|
5803
|
+
#notifications = [];
|
|
5804
|
+
#onProcessControlEvent;
|
|
5805
|
+
#onRuntimeEvent;
|
|
5806
|
+
#pending = /* @__PURE__ */ new Map();
|
|
5807
|
+
#turnAgentMessageDeltas = /* @__PURE__ */ new Map();
|
|
5808
|
+
#child = null;
|
|
5809
|
+
#forceKillTimeout = null;
|
|
5810
|
+
#firstOutputAtMs = null;
|
|
5811
|
+
#lineBuffer = "";
|
|
5812
|
+
#nextRequestId = 1;
|
|
5813
|
+
#processTimeout = null;
|
|
5814
|
+
#settledFailure = null;
|
|
5815
|
+
#waiters = /* @__PURE__ */ new Set();
|
|
5816
|
+
#lifecycle = {
|
|
5817
|
+
exitCode: null,
|
|
5818
|
+
exitObservedAtMs: null,
|
|
5819
|
+
exitSignal: null,
|
|
5820
|
+
firstStderrAtMs: null,
|
|
5821
|
+
firstStdoutAtMs: null,
|
|
5822
|
+
processId: null,
|
|
5823
|
+
processSpawnedAtMs: null,
|
|
5824
|
+
stdinClosedAtMs: null,
|
|
5825
|
+
timeoutTriggeredAtMs: null
|
|
5826
|
+
};
|
|
5827
|
+
constructor(input) {
|
|
5828
|
+
this.#codexTimeoutMs = input.codexTimeoutMs;
|
|
5829
|
+
this.#codexWorkdir = input.codexWorkdir;
|
|
5830
|
+
this.#env = input.env;
|
|
5831
|
+
this.#launchContract = input.launchContract;
|
|
5832
|
+
this.#onProcessControlEvent = input.onProcessControlEvent;
|
|
5833
|
+
this.#onRuntimeEvent = input.onRuntimeEvent;
|
|
5834
|
+
}
|
|
5835
|
+
async start() {
|
|
5836
|
+
const invocation = buildCliLaunchInvocation({
|
|
5837
|
+
args: [
|
|
5838
|
+
"app-server",
|
|
5839
|
+
"--listen",
|
|
5840
|
+
"stdio://"
|
|
5841
|
+
],
|
|
5842
|
+
launchContract: this.#launchContract
|
|
5843
|
+
});
|
|
5844
|
+
const child = spawn(invocation.bin, invocation.args, {
|
|
5845
|
+
cwd: this.#codexWorkdir,
|
|
5846
|
+
env: {
|
|
5847
|
+
...process.env,
|
|
5848
|
+
...this.#env ?? {}
|
|
5849
|
+
},
|
|
5850
|
+
shell: invocation.shell ?? false,
|
|
5851
|
+
stdio: [
|
|
5852
|
+
"pipe",
|
|
5853
|
+
"pipe",
|
|
5854
|
+
"pipe"
|
|
5855
|
+
]
|
|
5856
|
+
});
|
|
5857
|
+
this.#child = child;
|
|
5858
|
+
const processId = typeof child.pid === "number" ? child.pid : null;
|
|
5859
|
+
const processSpawnedAtMs = Date.now();
|
|
5860
|
+
this.#lifecycle.processId = processId;
|
|
5861
|
+
this.#lifecycle.processSpawnedAtMs = processSpawnedAtMs;
|
|
5862
|
+
this.#emitRuntimeEvent({
|
|
5863
|
+
phase: "process_spawned",
|
|
5864
|
+
processId,
|
|
5865
|
+
tsMs: processSpawnedAtMs
|
|
5866
|
+
});
|
|
5867
|
+
this.#onProcessControlEvent?.({
|
|
5868
|
+
phase: "process_spawned",
|
|
5869
|
+
processId
|
|
5870
|
+
});
|
|
5871
|
+
child.stdout.setEncoding("utf8");
|
|
5872
|
+
child.stdout.on("data", (chunk) => {
|
|
5873
|
+
const text = String(chunk);
|
|
5874
|
+
if (this.#lifecycle.firstStdoutAtMs === null) {
|
|
5875
|
+
const firstStdoutAtMs = Date.now();
|
|
5876
|
+
this.#lifecycle.firstStdoutAtMs = firstStdoutAtMs;
|
|
5877
|
+
this.#emitRuntimeEvent({
|
|
5878
|
+
phase: "first_stdout",
|
|
5879
|
+
processId,
|
|
5880
|
+
tsMs: firstStdoutAtMs
|
|
5881
|
+
});
|
|
5882
|
+
}
|
|
5883
|
+
this.#consumeStdoutText(text);
|
|
5884
|
+
});
|
|
5885
|
+
child.stderr.setEncoding("utf8");
|
|
5886
|
+
child.stderr.on("data", () => {
|
|
5887
|
+
if (this.#lifecycle.firstStderrAtMs !== null) return;
|
|
5888
|
+
const firstStderrAtMs = Date.now();
|
|
5889
|
+
this.#lifecycle.firstStderrAtMs = firstStderrAtMs;
|
|
5890
|
+
this.#emitRuntimeEvent({
|
|
5891
|
+
phase: "first_stderr",
|
|
5892
|
+
processId,
|
|
5893
|
+
tsMs: firstStderrAtMs
|
|
5894
|
+
});
|
|
5895
|
+
});
|
|
5896
|
+
child.on("error", (error) => {
|
|
5897
|
+
this.#failAll(new CodexAppServerTransportError({
|
|
5898
|
+
code: "upstream_unreachable",
|
|
5899
|
+
errorType: "adapter",
|
|
5900
|
+
message: `upstream_unreachable: failed to spawn codex app-server (${error.message})`
|
|
5901
|
+
}));
|
|
5902
|
+
});
|
|
5903
|
+
child.on("close", (exitCode, signal) => {
|
|
5904
|
+
this.#clearTimers();
|
|
5905
|
+
this.#lifecycle.exitCode = exitCode;
|
|
5906
|
+
this.#lifecycle.exitObservedAtMs = Date.now();
|
|
5907
|
+
this.#lifecycle.exitSignal = signal;
|
|
5908
|
+
this.#emitRuntimeEvent({
|
|
5909
|
+
exitCode,
|
|
5910
|
+
phase: "process_exit",
|
|
5911
|
+
processId,
|
|
5912
|
+
signal,
|
|
5913
|
+
tsMs: this.#lifecycle.exitObservedAtMs
|
|
5914
|
+
});
|
|
5915
|
+
this.#onProcessControlEvent?.({
|
|
5916
|
+
phase: "process_exit",
|
|
5917
|
+
processId
|
|
5918
|
+
});
|
|
5919
|
+
if (this.#pending.size > 0 || this.#waiters.size > 0) this.#failAll(new CodexAppServerTransportError({
|
|
5920
|
+
code: "upstream_unreachable",
|
|
5921
|
+
errorType: "adapter",
|
|
5922
|
+
message: "upstream_unreachable: codex app-server exited early"
|
|
5923
|
+
}));
|
|
5924
|
+
});
|
|
5925
|
+
this.#processTimeout = this.#codexTimeoutMs === null ? null : setTimeout(() => {
|
|
5926
|
+
const timeoutTriggeredAtMs = Date.now();
|
|
5927
|
+
this.#lifecycle.timeoutTriggeredAtMs = timeoutTriggeredAtMs;
|
|
5928
|
+
this.#emitRuntimeEvent({
|
|
5929
|
+
phase: "timeout_triggered",
|
|
5930
|
+
processId,
|
|
5931
|
+
tsMs: timeoutTriggeredAtMs
|
|
5932
|
+
});
|
|
5933
|
+
this.#failAll(new CodexAppServerTransportError({
|
|
5934
|
+
code: "process.timeout",
|
|
5935
|
+
errorType: "timeout",
|
|
5936
|
+
message: this.#codexTimeoutMs === null ? "process.timeout: codex app-server timed out" : `process.timeout: codex app-server did not complete within ${this.#codexTimeoutMs}ms`
|
|
5937
|
+
}));
|
|
5938
|
+
this.#requestProcessTermination();
|
|
5939
|
+
}, this.#codexTimeoutMs);
|
|
5940
|
+
await this.request("initialize", {
|
|
5941
|
+
capabilities: { experimentalApi: true },
|
|
5942
|
+
clientInfo: {
|
|
5943
|
+
name: "agent-transport-system",
|
|
5944
|
+
version: "0.0.0"
|
|
5945
|
+
}
|
|
5946
|
+
});
|
|
5947
|
+
this.notify("initialized", {});
|
|
5948
|
+
}
|
|
5949
|
+
async close() {
|
|
5950
|
+
this.#clearTimers();
|
|
5951
|
+
const child = this.#child;
|
|
5952
|
+
if (!child) return;
|
|
5953
|
+
if (this.#lifecycle.stdinClosedAtMs === null) {
|
|
5954
|
+
this.#lifecycle.stdinClosedAtMs = Date.now();
|
|
5955
|
+
this.#emitRuntimeEvent({
|
|
5956
|
+
phase: "stdin_closed",
|
|
5957
|
+
processId: this.#lifecycle.processId,
|
|
5958
|
+
tsMs: this.#lifecycle.stdinClosedAtMs
|
|
5959
|
+
});
|
|
5960
|
+
}
|
|
5961
|
+
child.stdin.end();
|
|
5962
|
+
if (this.#lifecycle.exitObservedAtMs !== null) return;
|
|
5963
|
+
this.#requestProcessTermination();
|
|
5964
|
+
await new Promise((resolve) => {
|
|
5965
|
+
const timeout = setTimeout(() => {
|
|
5966
|
+
resolve();
|
|
5967
|
+
}, APP_SERVER_PROCESS_KILL_GRACE_MS);
|
|
5968
|
+
child.once("close", () => {
|
|
5969
|
+
clearTimeout(timeout);
|
|
5970
|
+
resolve();
|
|
5971
|
+
});
|
|
5972
|
+
});
|
|
5973
|
+
}
|
|
5974
|
+
async request(method, params) {
|
|
5975
|
+
if (this.#settledFailure) throw this.#settledFailure;
|
|
5976
|
+
const id = this.#nextRequestId;
|
|
5977
|
+
this.#nextRequestId += 1;
|
|
5978
|
+
const requestPromise = new Promise((resolve, reject) => {
|
|
5979
|
+
this.#pending.set(id, {
|
|
5980
|
+
reject,
|
|
5981
|
+
resolve
|
|
5982
|
+
});
|
|
5983
|
+
});
|
|
5984
|
+
this.#write({
|
|
5985
|
+
id,
|
|
5986
|
+
jsonrpc: "2.0",
|
|
5987
|
+
method,
|
|
5988
|
+
params
|
|
5989
|
+
});
|
|
5990
|
+
return await requestPromise;
|
|
5991
|
+
}
|
|
5992
|
+
notify(method, params) {
|
|
5993
|
+
this.#write({
|
|
5994
|
+
jsonrpc: "2.0",
|
|
5995
|
+
method,
|
|
5996
|
+
...params === void 0 ? {} : { params }
|
|
5997
|
+
});
|
|
5998
|
+
}
|
|
5999
|
+
async waitForTurnCompleted(input) {
|
|
6000
|
+
const turn = toRecord$2(toRecord$2((await this.#waitForNotification((candidate) => {
|
|
6001
|
+
if (candidate.method !== "turn/completed") return false;
|
|
6002
|
+
const params = toRecord$2(candidate.params);
|
|
6003
|
+
const turn = toRecord$2(params?.turn);
|
|
6004
|
+
return params?.threadId === input.threadId && normalizeOptionalText$45(turn?.id) === input.turnId;
|
|
6005
|
+
})).params)?.turn);
|
|
6006
|
+
if (!turn) throw new CodexAppServerTransportError({
|
|
6007
|
+
code: "protocol.invalid",
|
|
6008
|
+
errorType: "adapter",
|
|
6009
|
+
message: "protocol.invalid: turn/completed did not include turn"
|
|
6010
|
+
});
|
|
6011
|
+
return turn;
|
|
6012
|
+
}
|
|
6013
|
+
buildTelemetry(input) {
|
|
6014
|
+
return {
|
|
6015
|
+
completedAtMs: Date.now(),
|
|
6016
|
+
...this.#lifecycle.exitCode === null ? {} : { exitCode: this.#lifecycle.exitCode },
|
|
6017
|
+
...this.#lifecycle.exitObservedAtMs === null ? {} : { exitObservedAtMs: this.#lifecycle.exitObservedAtMs },
|
|
6018
|
+
...this.#lifecycle.exitSignal === null ? {} : { exitSignal: this.#lifecycle.exitSignal },
|
|
6019
|
+
...this.#firstOutputAtMs === null ? {} : { firstOutputAtMs: this.#firstOutputAtMs },
|
|
6020
|
+
...this.#lifecycle.firstStderrAtMs === null ? {} : { firstStderrAtMs: this.#lifecycle.firstStderrAtMs },
|
|
6021
|
+
...this.#lifecycle.firstStdoutAtMs === null ? {} : { firstStdoutAtMs: this.#lifecycle.firstStdoutAtMs },
|
|
6022
|
+
invokedAtMs: input.invokedAtMs,
|
|
6023
|
+
previewEmitted: input.previewEmitted,
|
|
6024
|
+
...this.#lifecycle.processId === null ? {} : { processId: this.#lifecycle.processId },
|
|
6025
|
+
...this.#lifecycle.processSpawnedAtMs === null ? {} : { processSpawnedAtMs: this.#lifecycle.processSpawnedAtMs },
|
|
6026
|
+
resumedContext: input.resumedContext,
|
|
6027
|
+
...this.#lifecycle.stdinClosedAtMs === null ? {} : { stdinClosedAtMs: this.#lifecycle.stdinClosedAtMs },
|
|
6028
|
+
streamingMode: input.streamingMode,
|
|
6029
|
+
...this.#lifecycle.timeoutTriggeredAtMs === null ? {} : { timeoutTriggeredAtMs: this.#lifecycle.timeoutTriggeredAtMs }
|
|
6030
|
+
};
|
|
6031
|
+
}
|
|
6032
|
+
readCollectedAgentMessageDeltaText() {
|
|
6033
|
+
const output = [...this.#turnAgentMessageDeltas.values()].join("").trim();
|
|
6034
|
+
return output.length > 0 ? output : null;
|
|
6035
|
+
}
|
|
6036
|
+
markAgentOutputObserved() {
|
|
6037
|
+
if (this.#firstOutputAtMs !== null) return;
|
|
6038
|
+
this.#firstOutputAtMs = Date.now();
|
|
6039
|
+
}
|
|
6040
|
+
#consumeStdoutText(text) {
|
|
6041
|
+
this.#lineBuffer += text;
|
|
6042
|
+
while (true) {
|
|
6043
|
+
const newlineIndex = this.#lineBuffer.indexOf("\n");
|
|
6044
|
+
if (newlineIndex < 0) return;
|
|
6045
|
+
const line = this.#lineBuffer.slice(0, newlineIndex).trim();
|
|
6046
|
+
this.#lineBuffer = this.#lineBuffer.slice(newlineIndex + 1);
|
|
6047
|
+
if (!line) continue;
|
|
6048
|
+
this.#handleStdoutLine(line);
|
|
6049
|
+
}
|
|
6050
|
+
}
|
|
6051
|
+
#handleStdoutLine(line) {
|
|
6052
|
+
let message;
|
|
6053
|
+
try {
|
|
6054
|
+
message = JSON.parse(line);
|
|
6055
|
+
} catch (error) {
|
|
6056
|
+
this.#failAll(new CodexAppServerTransportError({
|
|
6057
|
+
code: "protocol.invalid",
|
|
6058
|
+
errorType: "adapter",
|
|
6059
|
+
message: `protocol.invalid: codex app-server emitted non-JSON output (${toErrorMessage$34(error)})`
|
|
6060
|
+
}));
|
|
6061
|
+
return;
|
|
6062
|
+
}
|
|
6063
|
+
if (message.id !== void 0 && message.method) {
|
|
6064
|
+
this.#handleServerRequest(message);
|
|
6065
|
+
return;
|
|
6066
|
+
}
|
|
6067
|
+
if (message.id !== void 0) {
|
|
6068
|
+
this.#handleResponse(message);
|
|
6069
|
+
return;
|
|
6070
|
+
}
|
|
6071
|
+
if (message.method) this.#handleNotification(message);
|
|
6072
|
+
}
|
|
6073
|
+
#handleResponse(message) {
|
|
6074
|
+
const id = message.id;
|
|
6075
|
+
if (!(typeof id === "number" || typeof id === "string")) return;
|
|
6076
|
+
const pending = this.#pending.get(id);
|
|
6077
|
+
if (!pending) return;
|
|
6078
|
+
this.#pending.delete(id);
|
|
6079
|
+
if (message.error) {
|
|
6080
|
+
pending.reject(toJsonRpcTransportError(message.error));
|
|
6081
|
+
return;
|
|
6082
|
+
}
|
|
6083
|
+
pending.resolve(message.result);
|
|
6084
|
+
}
|
|
6085
|
+
#handleNotification(message) {
|
|
6086
|
+
this.#notifications.push(message);
|
|
6087
|
+
this.#collectAgentMessageDelta(message);
|
|
6088
|
+
for (const waiter of [...this.#waiters]) {
|
|
6089
|
+
if (!waiter.predicate(message)) continue;
|
|
6090
|
+
this.#waiters.delete(waiter);
|
|
6091
|
+
waiter.resolve(message);
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
#handleServerRequest(message) {
|
|
6095
|
+
const id = message.id;
|
|
6096
|
+
if (!(typeof id === "number" || typeof id === "string")) return;
|
|
6097
|
+
const result = buildServerRequestDeclineResponse(message.method);
|
|
6098
|
+
if (result === null) {
|
|
6099
|
+
this.#write({
|
|
6100
|
+
error: {
|
|
6101
|
+
code: -32601,
|
|
6102
|
+
message: `ATS Codex App Server transport does not handle server request '${message.method}'.`
|
|
6103
|
+
},
|
|
6104
|
+
id,
|
|
6105
|
+
jsonrpc: "2.0"
|
|
6106
|
+
});
|
|
6107
|
+
return;
|
|
6108
|
+
}
|
|
6109
|
+
this.#write({
|
|
6110
|
+
id,
|
|
6111
|
+
jsonrpc: "2.0",
|
|
6112
|
+
result
|
|
6113
|
+
});
|
|
6114
|
+
}
|
|
6115
|
+
#waitForNotification(predicate) {
|
|
6116
|
+
for (const notification of this.#notifications) if (predicate(notification)) return Promise.resolve(notification);
|
|
6117
|
+
if (this.#settledFailure) return Promise.reject(this.#settledFailure);
|
|
6118
|
+
return new Promise((resolve, reject) => {
|
|
6119
|
+
this.#waiters.add({
|
|
6120
|
+
predicate,
|
|
6121
|
+
reject,
|
|
6122
|
+
resolve
|
|
6123
|
+
});
|
|
6124
|
+
});
|
|
6125
|
+
}
|
|
6126
|
+
#collectAgentMessageDelta(message) {
|
|
6127
|
+
if (message.method !== "item/agentMessage/delta") return;
|
|
6128
|
+
const params = toRecord$2(message.params);
|
|
6129
|
+
const itemId = normalizeOptionalText$45(params?.itemId);
|
|
6130
|
+
const delta = normalizeOptionalText$45(params?.delta);
|
|
6131
|
+
if (!(itemId && delta)) return;
|
|
6132
|
+
this.markAgentOutputObserved();
|
|
6133
|
+
this.#turnAgentMessageDeltas.set(itemId, `${this.#turnAgentMessageDeltas.get(itemId) ?? ""}${delta}`);
|
|
6134
|
+
}
|
|
6135
|
+
#write(message) {
|
|
6136
|
+
const child = this.#child;
|
|
6137
|
+
if (!child) throw new CodexAppServerTransportError({
|
|
6138
|
+
code: "upstream_unreachable",
|
|
6139
|
+
errorType: "adapter",
|
|
6140
|
+
message: "upstream_unreachable: codex app-server is not running"
|
|
6141
|
+
});
|
|
6142
|
+
child.stdin.write(`${JSON.stringify(message)}\n`);
|
|
6143
|
+
}
|
|
6144
|
+
#failAll(error) {
|
|
6145
|
+
if (!this.#settledFailure) this.#settledFailure = error;
|
|
6146
|
+
for (const pending of this.#pending.values()) pending.reject(error);
|
|
6147
|
+
this.#pending.clear();
|
|
6148
|
+
for (const waiter of this.#waiters) waiter.reject(error);
|
|
6149
|
+
this.#waiters.clear();
|
|
6150
|
+
}
|
|
6151
|
+
#requestProcessTermination() {
|
|
6152
|
+
const child = this.#child;
|
|
6153
|
+
if (!child || child.killed) return;
|
|
6154
|
+
child.kill("SIGTERM");
|
|
6155
|
+
this.#forceKillTimeout = setTimeout(() => {
|
|
6156
|
+
child.kill("SIGKILL");
|
|
6157
|
+
}, APP_SERVER_PROCESS_KILL_GRACE_MS);
|
|
6158
|
+
this.#forceKillTimeout.unref?.();
|
|
6159
|
+
}
|
|
6160
|
+
#clearTimers() {
|
|
6161
|
+
if (this.#processTimeout !== null) {
|
|
6162
|
+
clearTimeout(this.#processTimeout);
|
|
6163
|
+
this.#processTimeout = null;
|
|
6164
|
+
}
|
|
6165
|
+
if (this.#forceKillTimeout !== null) {
|
|
6166
|
+
clearTimeout(this.#forceKillTimeout);
|
|
6167
|
+
this.#forceKillTimeout = null;
|
|
6168
|
+
}
|
|
6169
|
+
}
|
|
6170
|
+
emitProviderConversationObserved(threadId) {
|
|
6171
|
+
const agentControllerConversationId = normalizeOptionalText$45(threadId);
|
|
6172
|
+
if (!agentControllerConversationId) return;
|
|
6173
|
+
this.#emitRuntimeEvent({
|
|
6174
|
+
agentControllerConversationId,
|
|
6175
|
+
phase: "provider_conversation_observed",
|
|
6176
|
+
tsMs: Date.now()
|
|
6177
|
+
});
|
|
6178
|
+
}
|
|
6179
|
+
#emitRuntimeEvent(event) {
|
|
6180
|
+
this.#onRuntimeEvent?.(event);
|
|
6181
|
+
}
|
|
6182
|
+
};
|
|
6183
|
+
function readThreadIdFromResponse(value) {
|
|
6184
|
+
return readRequiredText(toRecord$2(value)?.thread?.id, "thread response thread.id");
|
|
6185
|
+
}
|
|
6186
|
+
function readTurnStartResponse(value) {
|
|
6187
|
+
const turn = toRecord$2(value)?.turn;
|
|
6188
|
+
if (!turn || typeof turn !== "object") throw new CodexAppServerTransportError({
|
|
6189
|
+
code: "protocol.invalid",
|
|
6190
|
+
errorType: "adapter",
|
|
6191
|
+
message: "protocol.invalid: turn/start response did not include turn"
|
|
6192
|
+
});
|
|
6193
|
+
return turn;
|
|
6194
|
+
}
|
|
6195
|
+
function readAgentMessageOutput(turn) {
|
|
6196
|
+
const text = (Array.isArray(turn.items) ? turn.items : []).filter((item) => item.type === "agentMessage").map((item) => normalizeOptionalText$45(item.text)).filter((item) => item !== null).join("\n").trim();
|
|
6197
|
+
return text.length > 0 ? text : null;
|
|
6198
|
+
}
|
|
6199
|
+
function readTurnFailureMessage(turn) {
|
|
6200
|
+
return normalizeOptionalText$45(turn.error?.message) ?? "codex app-server turn failed";
|
|
6201
|
+
}
|
|
6202
|
+
async function emitPreviewIfRequested(input) {
|
|
6203
|
+
if (!(input.onPreview && input.streamingMode === "stream")) return;
|
|
6204
|
+
await input.onPreview({ text: input.output });
|
|
6205
|
+
}
|
|
6206
|
+
function buildServerRequestDeclineResponse(method) {
|
|
6207
|
+
switch (method) {
|
|
6208
|
+
case "item/commandExecution/requestApproval": return { decision: "decline" };
|
|
6209
|
+
case "item/fileChange/requestApproval": return { decision: "decline" };
|
|
6210
|
+
case "execCommandApproval": return { decision: "denied" };
|
|
6211
|
+
case "applyPatchApproval": return { decision: "denied" };
|
|
6212
|
+
case "item/tool/requestUserInput": return { answers: {} };
|
|
6213
|
+
case "mcpServer/elicitation/request": return {
|
|
6214
|
+
_meta: null,
|
|
6215
|
+
action: "decline",
|
|
6216
|
+
content: null
|
|
6217
|
+
};
|
|
6218
|
+
case "item/tool/call": return {
|
|
6219
|
+
contentItems: [],
|
|
6220
|
+
success: false
|
|
6221
|
+
};
|
|
6222
|
+
case "item/permissions/requestApproval": return {
|
|
6223
|
+
permissions: {},
|
|
6224
|
+
scope: "turn",
|
|
6225
|
+
strictAutoReview: true
|
|
6226
|
+
};
|
|
6227
|
+
default: return null;
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
6230
|
+
function toJsonRpcTransportError(error) {
|
|
6231
|
+
const message = normalizeOptionalText$45(error.message) ?? "codex app-server error";
|
|
6232
|
+
const lowered = message.toLowerCase();
|
|
6233
|
+
if (lowered.includes("not logged in") || lowered.includes("unauthorized") || lowered.includes("authentication") || lowered.includes("401")) return new CodexAppServerTransportError({
|
|
6234
|
+
code: "auth.required",
|
|
6235
|
+
errorType: "auth",
|
|
6236
|
+
message
|
|
6237
|
+
});
|
|
6238
|
+
if (lowered.includes("thread not found") || lowered.includes("thread not loaded") || lowered.includes("no thread") || lowered.includes("not found")) return new CodexAppServerTransportError({
|
|
6239
|
+
code: "context_not_found",
|
|
6240
|
+
errorType: "config",
|
|
6241
|
+
message
|
|
6242
|
+
});
|
|
6243
|
+
return new CodexAppServerTransportError({
|
|
6244
|
+
code: "upstream_unreachable",
|
|
6245
|
+
errorType: "adapter",
|
|
6246
|
+
message
|
|
6247
|
+
});
|
|
6248
|
+
}
|
|
6249
|
+
function toCodexAppServerTransportError(error, timeoutMs) {
|
|
6250
|
+
if (error instanceof CodexAppServerTransportError) return error;
|
|
6251
|
+
if (error && typeof error === "object" && "code" in error && typeof error.code === "string" && "errorType" in error && typeof error.errorType === "string" && error instanceof Error) return new CodexAppServerTransportError({
|
|
6252
|
+
code: error.code,
|
|
6253
|
+
errorType: error.errorType,
|
|
6254
|
+
message: error.message
|
|
6255
|
+
});
|
|
6256
|
+
if (timeoutMs !== null && toErrorMessage$34(error).includes("timed out")) return new CodexAppServerTransportError({
|
|
6257
|
+
code: "process.timeout",
|
|
6258
|
+
errorType: "timeout",
|
|
6259
|
+
message: toErrorMessage$34(error)
|
|
6260
|
+
});
|
|
6261
|
+
return new CodexAppServerTransportError({
|
|
6262
|
+
code: "upstream_unreachable",
|
|
6263
|
+
errorType: "adapter",
|
|
6264
|
+
message: `upstream_unreachable: failed to execute codex app-server (${toErrorMessage$34(error)})`
|
|
6265
|
+
});
|
|
6266
|
+
}
|
|
6267
|
+
function readRequiredText(value, label) {
|
|
6268
|
+
const text = normalizeOptionalText$45(value);
|
|
6269
|
+
if (text) return text;
|
|
6270
|
+
throw new CodexAppServerTransportError({
|
|
6271
|
+
code: "protocol.invalid",
|
|
6272
|
+
errorType: "adapter",
|
|
6273
|
+
message: `protocol.invalid: missing ${label}`
|
|
6274
|
+
});
|
|
6275
|
+
}
|
|
6276
|
+
function toRecord$2(value) {
|
|
6277
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
6278
|
+
return value;
|
|
6279
|
+
}
|
|
6280
|
+
function normalizeText$7(value) {
|
|
6281
|
+
return String(value ?? "").trim();
|
|
6282
|
+
}
|
|
6283
|
+
function normalizeOptionalText$45(value) {
|
|
6284
|
+
const normalized = normalizeText$7(value);
|
|
6285
|
+
return normalized.length > 0 ? normalized : null;
|
|
6286
|
+
}
|
|
6287
|
+
function toErrorMessage$34(error) {
|
|
6288
|
+
if (error instanceof Error) return error.message;
|
|
6289
|
+
return String(error);
|
|
6290
|
+
}
|
|
6291
|
+
|
|
5677
6292
|
//#endregion
|
|
5678
6293
|
//#region ../../runtime/adapters/codex/dist/output/codex-output-parser.js
|
|
5679
6294
|
function processCodexStdoutLine(input) {
|
|
@@ -6152,6 +6767,35 @@ async function invokeCodexWithSingleContextHeal(input) {
|
|
|
6152
6767
|
threadId: result.contextId
|
|
6153
6768
|
};
|
|
6154
6769
|
}
|
|
6770
|
+
async function invokeCodexAppServer(input) {
|
|
6771
|
+
try {
|
|
6772
|
+
return await invokeCodexAppServerTransport({
|
|
6773
|
+
launchContract: input.launchContract,
|
|
6774
|
+
codexTimeoutMs: input.codexTimeoutMs,
|
|
6775
|
+
codexWorkdir: input.codexWorkdir,
|
|
6776
|
+
env: input.env,
|
|
6777
|
+
executionMode: input.executionMode,
|
|
6778
|
+
...input.onProcessControlEvent ? { onProcessControlEvent: input.onProcessControlEvent } : {},
|
|
6779
|
+
...input.onPreview ? { onPreview: input.onPreview } : {},
|
|
6780
|
+
...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
|
|
6781
|
+
prompt: input.prompt,
|
|
6782
|
+
streamingMode: input.streamingMode,
|
|
6783
|
+
threadId: input.threadId
|
|
6784
|
+
});
|
|
6785
|
+
} catch (error) {
|
|
6786
|
+
if (error instanceof CodexRuntimeError) throw error;
|
|
6787
|
+
if (error && typeof error === "object" && "code" in error && typeof error.code === "string" && "errorType" in error && typeof error.errorType === "string" && error instanceof Error) throw new CodexRuntimeError({
|
|
6788
|
+
code: error.code,
|
|
6789
|
+
errorType: error.errorType,
|
|
6790
|
+
message: error.message
|
|
6791
|
+
});
|
|
6792
|
+
throw new CodexRuntimeError({
|
|
6793
|
+
code: "upstream_unreachable",
|
|
6794
|
+
errorType: "adapter",
|
|
6795
|
+
message: `upstream_unreachable: ${toErrorMessage$33(error)}`
|
|
6796
|
+
});
|
|
6797
|
+
}
|
|
6798
|
+
}
|
|
6155
6799
|
async function invokeCodexOnce(input) {
|
|
6156
6800
|
try {
|
|
6157
6801
|
return await invokeCodexCliTransport({
|
|
@@ -6189,6 +6833,7 @@ function toErrorMessage$33(error) {
|
|
|
6189
6833
|
//#endregion
|
|
6190
6834
|
//#region ../../runtime/adapters/codex/dist/index.js
|
|
6191
6835
|
const CODEX_CONVERSATION_BRIDGE_SPEC = resolveBuiltinAdapterConversationBridgeSpec("codex");
|
|
6836
|
+
const TEST_DISABLE_DEFAULT_INVOKE = Symbol.for("ats.test.disableDefaultInvoke");
|
|
6192
6837
|
const createCodexAdapter = (options) => {
|
|
6193
6838
|
const controlShell = createSharedControlShell({
|
|
6194
6839
|
gracefulTimeoutMs: options.gracefulTimeoutMs,
|
|
@@ -6200,7 +6845,7 @@ const createCodexAdapter = (options) => {
|
|
|
6200
6845
|
adapterId: "codex",
|
|
6201
6846
|
bridgeSpec: CODEX_CONVERSATION_BRIDGE_SPEC,
|
|
6202
6847
|
invoke: options.invoke,
|
|
6203
|
-
invokeByMode: options
|
|
6848
|
+
invokeByMode: resolveCodexInvokeByTransportMode(options),
|
|
6204
6849
|
resolveDefaultInvoke: () => resolveDefaultCodexInvoke(options),
|
|
6205
6850
|
runtimeOptions: options
|
|
6206
6851
|
});
|
|
@@ -6253,6 +6898,55 @@ const resolveDefaultCodexInvoke = (options) => {
|
|
|
6253
6898
|
};
|
|
6254
6899
|
};
|
|
6255
6900
|
};
|
|
6901
|
+
const resolveCodexInvokeByTransportMode = (options) => {
|
|
6902
|
+
if (options.invoke || isDefaultInvokeDisabledForTests(options)) return options.invokeByMode;
|
|
6903
|
+
return {
|
|
6904
|
+
"codex-app-server": resolveDefaultCodexAppServerInvoke(options),
|
|
6905
|
+
...options.enableLocalCliTransport ? { "local-cli": resolveDefaultCodexInvoke(options) } : {},
|
|
6906
|
+
...options.invokeByMode ?? {}
|
|
6907
|
+
};
|
|
6908
|
+
};
|
|
6909
|
+
const resolveDefaultCodexAppServerInvoke = (options) => {
|
|
6910
|
+
const codexTimeoutMs = options.codexTimeoutMs ?? resolveCodexTimeoutMs();
|
|
6911
|
+
return async (input) => {
|
|
6912
|
+
const launchContract = await resolveCodexDispatchLaunchContract({
|
|
6913
|
+
codexBin: options.codexBin,
|
|
6914
|
+
inputLaunchContract: input.launchContract,
|
|
6915
|
+
optionLaunchContract: options.launchContract
|
|
6916
|
+
});
|
|
6917
|
+
const onProcessControlEvent = options.registerRuntimeProcess ? (event) => {
|
|
6918
|
+
options.registerRuntimeProcess?.({
|
|
6919
|
+
...event,
|
|
6920
|
+
taskId: input.taskId
|
|
6921
|
+
});
|
|
6922
|
+
} : void 0;
|
|
6923
|
+
const result = await invokeCodexAppServer({
|
|
6924
|
+
launchContract,
|
|
6925
|
+
codexTimeoutMs,
|
|
6926
|
+
codexWorkdir: input.runtimeContext.providerRuntimeWorkingDirectory,
|
|
6927
|
+
env: input.env,
|
|
6928
|
+
executionMode: input.executionMode,
|
|
6929
|
+
...onProcessControlEvent ? { onProcessControlEvent } : {},
|
|
6930
|
+
...input.onPreview ? { onPreview: input.onPreview } : {},
|
|
6931
|
+
...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
|
|
6932
|
+
prompt: input.prompt,
|
|
6933
|
+
streamingMode: input.streamingMode,
|
|
6934
|
+
threadId: normalizeOptionalText$42(input.agentControllerConversationId)
|
|
6935
|
+
});
|
|
6936
|
+
const agentControllerConversation = CODEX_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
|
|
6937
|
+
bridgeSpec: CODEX_CONVERSATION_BRIDGE_SPEC,
|
|
6938
|
+
agentControllerConversationId: result.threadId
|
|
6939
|
+
}) : null;
|
|
6940
|
+
return {
|
|
6941
|
+
contextDelta: {
|
|
6942
|
+
agentControllerConversationId: result.threadId,
|
|
6943
|
+
...agentControllerConversation ? { agentControllerConversation } : {}
|
|
6944
|
+
},
|
|
6945
|
+
output: result.output,
|
|
6946
|
+
...result.telemetry ? { telemetry: result.telemetry } : {}
|
|
6947
|
+
};
|
|
6948
|
+
};
|
|
6949
|
+
};
|
|
6256
6950
|
async function resolveCodexDispatchLaunchContract(input) {
|
|
6257
6951
|
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$42(input.codexBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$42(input.codexBin) }) : null);
|
|
6258
6952
|
if (explicitLaunchContract) {
|
|
@@ -6272,6 +6966,7 @@ const normalizeOptionalText$42 = (value) => {
|
|
|
6272
6966
|
const normalized = String(value ?? "").trim();
|
|
6273
6967
|
return normalized.length > 0 ? normalized : null;
|
|
6274
6968
|
};
|
|
6969
|
+
const isDefaultInvokeDisabledForTests = (options) => options[TEST_DISABLE_DEFAULT_INVOKE] === true;
|
|
6275
6970
|
|
|
6276
6971
|
//#endregion
|
|
6277
6972
|
//#region ../../runtime/local-service/src/adapters/installers/install-codex.ts
|
|
@@ -6285,7 +6980,7 @@ const installCodexAdapter = {
|
|
|
6285
6980
|
return {
|
|
6286
6981
|
adapter: codexAdapter,
|
|
6287
6982
|
adapterId: codexAdapter.adapterId,
|
|
6288
|
-
transportModes: ["
|
|
6983
|
+
transportModes: ["codex-app-server"]
|
|
6289
6984
|
};
|
|
6290
6985
|
}
|
|
6291
6986
|
};
|
|
@@ -9262,22 +9957,32 @@ const resolveAgentControllerRefKind = (input) => {
|
|
|
9262
9957
|
const areAgentControllerRefsEquivalent = (input) => resolveCanonicalAgentControllerRef({ agentControllerRef: input.leftAgentControllerRef }) === resolveCanonicalAgentControllerRef({ agentControllerRef: input.rightAgentControllerRef });
|
|
9263
9958
|
const listCompatibleAgentControllerRefs = (input) => [resolveCanonicalAgentControllerRef({ agentControllerRef: input.agentControllerRef })];
|
|
9264
9959
|
const buildLookupKey = (input) => [
|
|
9960
|
+
input.targetProfileId,
|
|
9961
|
+
input.agentControllerRef,
|
|
9962
|
+
input.transportMode,
|
|
9963
|
+
input.runtimeWorkspaceFingerprint
|
|
9964
|
+
].map(encodeLookupKeyPart).join(AGENT_CONTEXT_LOOKUP_KEY_SEPARATOR$1);
|
|
9965
|
+
const buildLegacySpaceScopedLookupKey = (input) => [
|
|
9265
9966
|
input.spaceId,
|
|
9266
9967
|
input.targetProfileId,
|
|
9267
9968
|
input.agentControllerRef,
|
|
9268
9969
|
input.transportMode,
|
|
9269
9970
|
input.runtimeWorkspaceFingerprint
|
|
9270
9971
|
].map(encodeLookupKeyPart).join(AGENT_CONTEXT_LOOKUP_KEY_SEPARATOR$1);
|
|
9271
|
-
const listCompatibleAgentContextLookupKeys = (input) => listCompatibleAgentControllerRefs(input).
|
|
9972
|
+
const listCompatibleAgentContextLookupKeys = (input) => listCompatibleAgentControllerRefs(input).flatMap((agentControllerRef) => [buildLookupKey({
|
|
9973
|
+
agentControllerRef,
|
|
9974
|
+
targetProfileId: input.targetProfileId,
|
|
9975
|
+
transportMode: input.transportMode,
|
|
9976
|
+
runtimeWorkspaceFingerprint: input.runtimeWorkspaceFingerprint
|
|
9977
|
+
}), buildLegacySpaceScopedLookupKey({
|
|
9272
9978
|
agentControllerRef,
|
|
9273
9979
|
spaceId: input.spaceId,
|
|
9274
9980
|
targetProfileId: input.targetProfileId,
|
|
9275
9981
|
transportMode: input.transportMode,
|
|
9276
9982
|
runtimeWorkspaceFingerprint: input.runtimeWorkspaceFingerprint
|
|
9277
|
-
}));
|
|
9983
|
+
})]).filter((lookupKey, index, values) => values.indexOf(lookupKey) === index);
|
|
9278
9984
|
const buildAgentContextLookupKey = (input) => buildLookupKey({
|
|
9279
9985
|
agentControllerRef: resolveCanonicalAgentControllerRef(input),
|
|
9280
|
-
spaceId: input.spaceId,
|
|
9281
9986
|
targetProfileId: input.targetProfileId,
|
|
9282
9987
|
transportMode: input.transportMode,
|
|
9283
9988
|
runtimeWorkspaceFingerprint: input.runtimeWorkspaceFingerprint
|
|
@@ -9291,7 +9996,11 @@ const isAgentContextCompatibleWithLookupKeyInput = (input) => isAgentContextComp
|
|
|
9291
9996
|
agentContext: input.agentContext,
|
|
9292
9997
|
scope: input.key
|
|
9293
9998
|
}) && input.agentContext.runtimeWorkspaceFingerprint === input.key.runtimeWorkspaceFingerprint;
|
|
9294
|
-
const
|
|
9999
|
+
const isAgentContextStoredUnderCompatibleLookupKeyInput = (input) => listCompatibleAgentContextLookupKeys({
|
|
10000
|
+
...input.key,
|
|
10001
|
+
spaceId: input.agentContext.spaceId
|
|
10002
|
+
}).includes(input.agentContext.agentContextLookupKey);
|
|
10003
|
+
const isAgentContextCompatibleWithScopeInput = (input) => input.agentContext.targetProfileId === input.scope.targetProfileId && input.agentContext.transportMode === input.scope.transportMode && areAgentControllerRefsEquivalent({
|
|
9295
10004
|
leftAgentControllerRef: input.agentContext.agentControllerRef,
|
|
9296
10005
|
rightAgentControllerRef: input.scope.agentControllerRef
|
|
9297
10006
|
});
|
|
@@ -9315,11 +10024,21 @@ const resolveExistingAgentContext = (input) => {
|
|
|
9315
10024
|
key: input.key
|
|
9316
10025
|
})) return agentContext;
|
|
9317
10026
|
}
|
|
9318
|
-
return
|
|
10027
|
+
return Object.values(input.state.agentContextByLookupKey).filter((agentContext) => isAgentContextCompatibleWithLookupKeyInput({
|
|
10028
|
+
agentContext,
|
|
10029
|
+
key: input.key
|
|
10030
|
+
}) && isAgentContextStoredUnderCompatibleLookupKeyInput({
|
|
10031
|
+
agentContext,
|
|
10032
|
+
key: input.key
|
|
10033
|
+
})).sort((left, right) => {
|
|
10034
|
+
if (left.updatedAtMs !== right.updatedAtMs) return right.updatedAtMs - left.updatedAtMs;
|
|
10035
|
+
if (left.createdAtMs !== right.createdAtMs) return right.createdAtMs - left.createdAtMs;
|
|
10036
|
+
return right.agentContextLookupKey.localeCompare(left.agentContextLookupKey);
|
|
10037
|
+
})[0] ?? null;
|
|
9319
10038
|
};
|
|
9320
10039
|
const resolveNextAgentContextLookupKey = (input) => resolveAgentControllerRefKind({ agentControllerRef: input.existing.agentControllerRef }) === "builtin" ? buildAgentContextLookupKey(input.key) : input.existing.agentContextLookupKey;
|
|
9321
10040
|
const resolveIncompatibleAgentContext = (input) => {
|
|
9322
|
-
const candidates = Object.values(input.state.agentContextByLookupKey).filter((agentContext) => agentContext.
|
|
10041
|
+
const candidates = Object.values(input.state.agentContextByLookupKey).filter((agentContext) => agentContext.targetProfileId === input.key.targetProfileId && agentContext.runtimeWorkspaceFingerprint === input.key.runtimeWorkspaceFingerprint);
|
|
9323
10042
|
candidates.sort((left, right) => {
|
|
9324
10043
|
if (left.updatedAtMs !== right.updatedAtMs) return right.updatedAtMs - left.updatedAtMs;
|
|
9325
10044
|
if (left.createdAtMs !== right.createdAtMs) return right.createdAtMs - left.createdAtMs;
|
|
@@ -9370,6 +10089,8 @@ const resolveAgentContextForDispatch = (input) => {
|
|
|
9370
10089
|
}),
|
|
9371
10090
|
agentControllerRef: resolveCanonicalAgentControllerRef({ agentControllerRef: existing.agentControllerRef }),
|
|
9372
10091
|
lastTaskId: input.taskId,
|
|
10092
|
+
runtimeWorkspaceFingerprint: input.key.runtimeWorkspaceFingerprint,
|
|
10093
|
+
spaceId: input.key.spaceId,
|
|
9373
10094
|
updatedAtMs: input.nowMs
|
|
9374
10095
|
};
|
|
9375
10096
|
const replacedAgentContextLookupKey = existing.agentContextLookupKey === nextAgentContext.agentContextLookupKey ? null : existing.agentContextLookupKey;
|
|
@@ -9570,7 +10291,7 @@ async function buildConversationExecutionStatusControlPlaneResponse(input) {
|
|
|
9570
10291
|
errorCode: null,
|
|
9571
10292
|
errorMessage: null,
|
|
9572
10293
|
errorType: null,
|
|
9573
|
-
message: "
|
|
10294
|
+
message: "Provider conversation proof was not run. Re-run with --validate to confirm wake readiness on this device.",
|
|
9574
10295
|
status: "not_run"
|
|
9575
10296
|
},
|
|
9576
10297
|
runtimeWorkspace: {
|
|
@@ -9692,6 +10413,7 @@ const AGENT_CONTEXT_MAX_ENTRIES = 2e3;
|
|
|
9692
10413
|
const AGENT_CONTEXT_LOOKUP_KEY_SEPARATOR = "|";
|
|
9693
10414
|
const isRecord$6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9694
10415
|
const isPositiveInteger = (value) => Number.isInteger(value) && typeof value === "number" && value >= 0;
|
|
10416
|
+
const isRuntimeTransportMode$1 = (value) => value === "local-cli" || value === "codex-app-server";
|
|
9695
10417
|
const utf8ByteLength = (value) => {
|
|
9696
10418
|
let byteLength = 0;
|
|
9697
10419
|
for (const char of value) {
|
|
@@ -9720,6 +10442,12 @@ const toErrorCode = (error) => {
|
|
|
9720
10442
|
};
|
|
9721
10443
|
const encodeAgentContextLookupKeyPart = (value) => encodeURIComponent(value);
|
|
9722
10444
|
const buildStoredAgentContextLookupKey = (input) => [
|
|
10445
|
+
input.targetProfileId,
|
|
10446
|
+
input.agentControllerRef,
|
|
10447
|
+
input.transportMode,
|
|
10448
|
+
input.runtimeWorkspaceFingerprint
|
|
10449
|
+
].map(encodeAgentContextLookupKeyPart).join(AGENT_CONTEXT_LOOKUP_KEY_SEPARATOR);
|
|
10450
|
+
const buildLegacySpaceScopedAgentContextLookupKey = (input) => [
|
|
9723
10451
|
input.spaceId,
|
|
9724
10452
|
input.targetProfileId,
|
|
9725
10453
|
input.agentControllerRef,
|
|
@@ -9744,14 +10472,21 @@ const parseAgentContextState = (agentContextLookupKey, value) => {
|
|
|
9744
10472
|
if (!isRecord$6(value)) return null;
|
|
9745
10473
|
const { agentControllerConversationId, agentControllerRef, createdAtMs, lastTaskId, spaceId, targetProfileId, transportMode, runtimeWorkspaceFingerprint, updatedAtMs } = value;
|
|
9746
10474
|
const parsedAgentControllerRef = typeof agentControllerRef === "string" ? parseAgentControllerRef$1(agentControllerRef) : null;
|
|
9747
|
-
if (transportMode
|
|
9748
|
-
|
|
10475
|
+
if (!isRuntimeTransportMode$1(transportMode) || typeof agentContextLookupKey !== "string" || agentContextLookupKey.length === 0 || typeof spaceId !== "string" || spaceId.length === 0 || typeof targetProfileId !== "string" || targetProfileId.length === 0 || !parsedAgentControllerRef || typeof runtimeWorkspaceFingerprint !== "string" || runtimeWorkspaceFingerprint.length === 0 || typeof agentControllerConversationId !== "string" || agentControllerConversationId.length === 0 || !isPositiveInteger(createdAtMs) || !isPositiveInteger(updatedAtMs) || typeof lastTaskId !== "string" || lastTaskId.length === 0) return null;
|
|
10476
|
+
const canonicalLookupKey = buildStoredAgentContextLookupKey({
|
|
10477
|
+
agentControllerRef: parsedAgentControllerRef.ref,
|
|
10478
|
+
runtimeWorkspaceFingerprint,
|
|
10479
|
+
targetProfileId,
|
|
10480
|
+
transportMode
|
|
10481
|
+
});
|
|
10482
|
+
const legacySpaceScopedLookupKey = buildLegacySpaceScopedAgentContextLookupKey({
|
|
9749
10483
|
agentControllerRef: parsedAgentControllerRef.ref,
|
|
9750
10484
|
runtimeWorkspaceFingerprint,
|
|
9751
10485
|
spaceId,
|
|
9752
10486
|
targetProfileId,
|
|
9753
10487
|
transportMode
|
|
9754
|
-
})
|
|
10488
|
+
});
|
|
10489
|
+
if (agentContextLookupKey !== canonicalLookupKey && agentContextLookupKey !== legacySpaceScopedLookupKey) return null;
|
|
9755
10490
|
return {
|
|
9756
10491
|
agentControllerConversationId,
|
|
9757
10492
|
agentControllerRef: parsedAgentControllerRef.ref,
|
|
@@ -10383,44 +11118,46 @@ const settleRecoveredTask = (input) => settleInflightTask({
|
|
|
10383
11118
|
const buildTaskResultPayloadFromOutcome = (input) => {
|
|
10384
11119
|
const output = normalizeOutput$1(input.output);
|
|
10385
11120
|
const errorType = input.errorType ?? "internal";
|
|
11121
|
+
const commonFields = buildTaskResultCommonFields(input);
|
|
11122
|
+
const errorFields = buildTaskResultErrorFields(input);
|
|
10386
11123
|
if (output && input.emitFailed) return {
|
|
10387
|
-
|
|
10388
|
-
attemptId: input.attemptId,
|
|
10389
|
-
deduped: input.deduped,
|
|
11124
|
+
...commonFields,
|
|
10390
11125
|
errorType: input.errorType ?? "network",
|
|
10391
|
-
...
|
|
10392
|
-
...input.errorMessage ? { errorMessage: input.errorMessage } : {},
|
|
11126
|
+
...errorFields,
|
|
10393
11127
|
output,
|
|
10394
11128
|
partialReason: input.partialReason ?? "emit_failed",
|
|
10395
|
-
|
|
10396
|
-
status: "partial_success",
|
|
10397
|
-
taskId: input.taskId,
|
|
10398
|
-
...input.telemetry ? { telemetry: input.telemetry } : {}
|
|
11129
|
+
status: "partial_success"
|
|
10399
11130
|
};
|
|
10400
11131
|
if (output) return {
|
|
10401
|
-
|
|
10402
|
-
attemptId: input.attemptId,
|
|
10403
|
-
deduped: input.deduped,
|
|
11132
|
+
...commonFields,
|
|
10404
11133
|
output,
|
|
10405
|
-
|
|
10406
|
-
status: "success",
|
|
10407
|
-
taskId: input.taskId,
|
|
10408
|
-
...input.telemetry ? { telemetry: input.telemetry } : {}
|
|
11134
|
+
status: "success"
|
|
10409
11135
|
};
|
|
11136
|
+
return {
|
|
11137
|
+
...commonFields,
|
|
11138
|
+
errorType,
|
|
11139
|
+
...errorFields,
|
|
11140
|
+
...input.providerAccessEvidence ? { providerAccessEvidence: input.providerAccessEvidence } : {},
|
|
11141
|
+
status: "failed"
|
|
11142
|
+
};
|
|
11143
|
+
};
|
|
11144
|
+
function buildTaskResultCommonFields(input) {
|
|
10410
11145
|
return {
|
|
10411
11146
|
agentId: input.agentId,
|
|
10412
11147
|
attemptId: input.attemptId,
|
|
10413
11148
|
deduped: input.deduped,
|
|
10414
|
-
errorType,
|
|
10415
|
-
...input.errorCode ? { errorCode: input.errorCode } : {},
|
|
10416
|
-
...input.errorMessage ? { errorMessage: input.errorMessage } : {},
|
|
10417
|
-
...input.providerAccessEvidence ? { providerAccessEvidence: input.providerAccessEvidence } : {},
|
|
10418
11149
|
sourceEventId: input.sourceEventId,
|
|
10419
|
-
status: "failed",
|
|
10420
11150
|
taskId: input.taskId,
|
|
10421
|
-
...input.telemetry ? { telemetry: input.telemetry } : {}
|
|
11151
|
+
...input.telemetry ? { telemetry: input.telemetry } : {},
|
|
11152
|
+
...input.transportMode ? { transportMode: input.transportMode } : {}
|
|
10422
11153
|
};
|
|
10423
|
-
}
|
|
11154
|
+
}
|
|
11155
|
+
function buildTaskResultErrorFields(input) {
|
|
11156
|
+
return {
|
|
11157
|
+
...input.errorCode ? { errorCode: input.errorCode } : {},
|
|
11158
|
+
...input.errorMessage ? { errorMessage: input.errorMessage } : {}
|
|
11159
|
+
};
|
|
11160
|
+
}
|
|
10424
11161
|
|
|
10425
11162
|
//#endregion
|
|
10426
11163
|
//#region ../../runtime/local-execution/dist/result-envelope.js
|
|
@@ -10718,6 +11455,40 @@ const resolveProviderContextId = (route) => {
|
|
|
10718
11455
|
const normalized = raw.trim();
|
|
10719
11456
|
return normalized.length > 0 ? normalized : null;
|
|
10720
11457
|
};
|
|
11458
|
+
const normalizeContextDeltaConversationId = (value) => {
|
|
11459
|
+
if (typeof value !== "string") return null;
|
|
11460
|
+
const normalized = value.trim();
|
|
11461
|
+
return normalized.length > 0 ? normalized : null;
|
|
11462
|
+
};
|
|
11463
|
+
const resolveDispatchResultContextDeltaConversationId = (dispatchResult) => {
|
|
11464
|
+
if (!(dispatchResult.dispatched && "adapterResult" in dispatchResult)) return null;
|
|
11465
|
+
if (dispatchResult.adapterResult.status !== "success") return null;
|
|
11466
|
+
return normalizeContextDeltaConversationId(dispatchResult.adapterResult.contextDelta?.agentControllerConversationId);
|
|
11467
|
+
};
|
|
11468
|
+
const resolvePostDispatchAgentContextInput = (input) => {
|
|
11469
|
+
if (!input.route || input.committedAgentContextResolution?.agentContext) return null;
|
|
11470
|
+
const providerContextId = resolveDispatchResultContextDeltaConversationId(input.dispatchResult);
|
|
11471
|
+
if (!providerContextId) return null;
|
|
11472
|
+
return {
|
|
11473
|
+
nowMs: input.nowMs,
|
|
11474
|
+
providerContextId,
|
|
11475
|
+
route: input.route,
|
|
11476
|
+
task: input.task
|
|
11477
|
+
};
|
|
11478
|
+
};
|
|
11479
|
+
const resolvePostDispatchAgentContextResolution = (input) => resolveAgentContextForDispatch({
|
|
11480
|
+
key: {
|
|
11481
|
+
agentControllerRef: input.postDispatchAgentContext.route.agentControllerRef,
|
|
11482
|
+
runtimeWorkspaceFingerprint: input.postDispatchAgentContext.route.runtimeWorkspaceFingerprint ?? buildRuntimeWorkspaceFingerprint(input.postDispatchAgentContext.task.runtimeContext.providerRuntimeWorkingDirectory),
|
|
11483
|
+
spaceId: input.postDispatchAgentContext.task.spaceId,
|
|
11484
|
+
targetProfileId: input.postDispatchAgentContext.task.agentId,
|
|
11485
|
+
transportMode: input.postDispatchAgentContext.route.transportMode
|
|
11486
|
+
},
|
|
11487
|
+
nowMs: input.postDispatchAgentContext.nowMs,
|
|
11488
|
+
providerContextId: input.postDispatchAgentContext.providerContextId,
|
|
11489
|
+
state: input.state,
|
|
11490
|
+
taskId: input.postDispatchAgentContext.task.taskId
|
|
11491
|
+
});
|
|
10721
11492
|
const commitAgentContextResolutionToState = (input) => {
|
|
10722
11493
|
if (!input.committedAgentContextResolution) return input.state;
|
|
10723
11494
|
let nextState = input.state;
|
|
@@ -10862,7 +11633,8 @@ const resolveRuntimeTaskOutcomeResult = (input) => {
|
|
|
10862
11633
|
...outcome.providerAccessEvidence ? { providerAccessEvidence: outcome.providerAccessEvidence } : {},
|
|
10863
11634
|
...outcome.telemetry ? { telemetry: outcome.telemetry } : {},
|
|
10864
11635
|
sourceEventId: input.sourceEventId,
|
|
10865
|
-
taskId: input.taskId
|
|
11636
|
+
taskId: input.taskId,
|
|
11637
|
+
...input.transportMode ? { transportMode: input.transportMode } : {}
|
|
10866
11638
|
})
|
|
10867
11639
|
};
|
|
10868
11640
|
};
|
|
@@ -10900,12 +11672,20 @@ const settleRuntimeTaskState = async (input) => withLedgerStateTransaction({
|
|
|
10900
11672
|
invalidStateStrategy: "backup_and_reset",
|
|
10901
11673
|
io: input.io,
|
|
10902
11674
|
mutate: (state) => {
|
|
11675
|
+
let committedAgentContextResolution = input.committedAgentContextResolution;
|
|
11676
|
+
if (!committedAgentContextResolution?.agentContext && input.postDispatchAgentContext) committedAgentContextResolution = resolvePostDispatchAgentContextResolution({
|
|
11677
|
+
postDispatchAgentContext: input.postDispatchAgentContext,
|
|
11678
|
+
state
|
|
11679
|
+
});
|
|
10903
11680
|
if (input.persistExecutionState === false) return {
|
|
10904
11681
|
nextState: state,
|
|
10905
|
-
value:
|
|
11682
|
+
value: {
|
|
11683
|
+
committedAgentContextResolution,
|
|
11684
|
+
state
|
|
11685
|
+
}
|
|
10906
11686
|
};
|
|
10907
11687
|
let nextState = commitAgentContextResolutionToState({
|
|
10908
|
-
committedAgentContextResolution
|
|
11688
|
+
committedAgentContextResolution,
|
|
10909
11689
|
state
|
|
10910
11690
|
});
|
|
10911
11691
|
nextState = settleRecoveredTask({
|
|
@@ -10914,7 +11694,10 @@ const settleRuntimeTaskState = async (input) => withLedgerStateTransaction({
|
|
|
10914
11694
|
});
|
|
10915
11695
|
return {
|
|
10916
11696
|
nextState,
|
|
10917
|
-
value:
|
|
11697
|
+
value: {
|
|
11698
|
+
committedAgentContextResolution,
|
|
11699
|
+
state: nextState
|
|
11700
|
+
}
|
|
10918
11701
|
};
|
|
10919
11702
|
},
|
|
10920
11703
|
paths: input.paths
|
|
@@ -10967,13 +11750,21 @@ const runRuntimeTask = async (input) => {
|
|
|
10967
11750
|
dispatchResult,
|
|
10968
11751
|
agentContextResolution
|
|
10969
11752
|
});
|
|
11753
|
+
const postDispatchAgentContext = isRepairExecutionMode(input.task.executionMode) ? null : resolvePostDispatchAgentContextInput({
|
|
11754
|
+
committedAgentContextResolution,
|
|
11755
|
+
dispatchResult,
|
|
11756
|
+
nowMs,
|
|
11757
|
+
route: input.route,
|
|
11758
|
+
task: input.task
|
|
11759
|
+
});
|
|
10970
11760
|
const runtimeTaskOutcome = resolveRuntimeTaskOutcomeResult({
|
|
10971
11761
|
agentId: input.task.agentId,
|
|
10972
11762
|
attemptId: input.task.attemptId,
|
|
10973
11763
|
deduped,
|
|
10974
11764
|
dispatchResult,
|
|
10975
11765
|
sourceEventId: input.task.sourceEventId,
|
|
10976
|
-
taskId: input.task.taskId
|
|
11766
|
+
taskId: input.task.taskId,
|
|
11767
|
+
transportMode: input.route?.transportMode ?? null
|
|
10977
11768
|
});
|
|
10978
11769
|
emitRuntimeTaskOutcomeHealthFindings({
|
|
10979
11770
|
humanContext: runtimeHealthContext,
|
|
@@ -10982,13 +11773,16 @@ const runRuntimeTask = async (input) => {
|
|
|
10982
11773
|
runtimeState
|
|
10983
11774
|
});
|
|
10984
11775
|
const { resultPayload } = runtimeTaskOutcome;
|
|
10985
|
-
const
|
|
11776
|
+
const settledRuntimeTaskState = await settleRuntimeTaskState({
|
|
10986
11777
|
committedAgentContextResolution,
|
|
10987
11778
|
io: input.io,
|
|
10988
11779
|
paths: input.paths,
|
|
10989
11780
|
persistExecutionState: !isRepairExecutionMode(input.task.executionMode),
|
|
11781
|
+
postDispatchAgentContext,
|
|
10990
11782
|
taskId: input.task.taskId
|
|
10991
11783
|
});
|
|
11784
|
+
const finalCommittedAgentContextResolution = settledRuntimeTaskState.committedAgentContextResolution;
|
|
11785
|
+
const state = settledRuntimeTaskState.state;
|
|
10992
11786
|
if (!isRepairExecutionMode(input.task.executionMode)) await appendLedgerHistoryEntry({
|
|
10993
11787
|
entry: buildHistoryEntry({
|
|
10994
11788
|
deduped,
|
|
@@ -11000,7 +11794,7 @@ const runRuntimeTask = async (input) => {
|
|
|
11000
11794
|
paths: input.paths
|
|
11001
11795
|
});
|
|
11002
11796
|
const contextResolution = resolveRuntimeContextResolution(dispatchResult);
|
|
11003
|
-
const lifecycleMetadata = resolveRuntimeLifecycleMetadata(
|
|
11797
|
+
const lifecycleMetadata = resolveRuntimeLifecycleMetadata(finalCommittedAgentContextResolution);
|
|
11004
11798
|
return {
|
|
11005
11799
|
...contextResolution ? { contextResolution } : {},
|
|
11006
11800
|
deduped,
|
|
@@ -11020,6 +11814,20 @@ const listOrderedCompatibleLookupKeys = (input) => {
|
|
|
11020
11814
|
if (!input.preferredLookupKey) return lookupKeys;
|
|
11021
11815
|
return [input.preferredLookupKey, ...lookupKeys].filter((lookupKey, index, values) => values.indexOf(lookupKey) === index);
|
|
11022
11816
|
};
|
|
11817
|
+
const listCompatibleAgentContextMatches = (input) => Object.values(input.state.agentContextByLookupKey).filter((agentContext) => isAgentContextCompatibleWithLookupKeyInput({
|
|
11818
|
+
agentContext,
|
|
11819
|
+
key: input.key
|
|
11820
|
+
}) && listCompatibleAgentContextLookupKeys({
|
|
11821
|
+
...input.key,
|
|
11822
|
+
spaceId: agentContext.spaceId
|
|
11823
|
+
}).includes(agentContext.agentContextLookupKey)).sort((left, right) => {
|
|
11824
|
+
if (left.updatedAtMs !== right.updatedAtMs) return right.updatedAtMs - left.updatedAtMs;
|
|
11825
|
+
if (left.createdAtMs !== right.createdAtMs) return right.createdAtMs - left.createdAtMs;
|
|
11826
|
+
return right.agentContextLookupKey.localeCompare(left.agentContextLookupKey);
|
|
11827
|
+
}).map((agentContext) => ({
|
|
11828
|
+
agentContext,
|
|
11829
|
+
agentContextLookupKey: agentContext.agentContextLookupKey
|
|
11830
|
+
}));
|
|
11023
11831
|
const resolveCompatibleAgentContextMatch = (input) => {
|
|
11024
11832
|
for (const agentContextLookupKey of listCompatibleAgentContextLookupKeys(input.key)) {
|
|
11025
11833
|
const agentContext = resolveAgentContextByLookupKey({
|
|
@@ -11035,7 +11843,7 @@ const resolveCompatibleAgentContextMatch = (input) => {
|
|
|
11035
11843
|
agentContextLookupKey
|
|
11036
11844
|
};
|
|
11037
11845
|
}
|
|
11038
|
-
return null;
|
|
11846
|
+
return listCompatibleAgentContextMatches(input)[0] ?? null;
|
|
11039
11847
|
};
|
|
11040
11848
|
const resolveCompatibleConversationExecutionState = (input) => {
|
|
11041
11849
|
for (const agentContextLookupKey of listOrderedCompatibleLookupKeys(input)) {
|
|
@@ -11053,6 +11861,13 @@ const resolveCompatibleConversationExecutionState = (input) => {
|
|
|
11053
11861
|
});
|
|
11054
11862
|
if (executionState) return executionState;
|
|
11055
11863
|
}
|
|
11864
|
+
for (const match of listCompatibleAgentContextMatches(input)) {
|
|
11865
|
+
const executionState = resolveConversationExecutionStateByLookupKey({
|
|
11866
|
+
agentContextLookupKey: match.agentContextLookupKey,
|
|
11867
|
+
state: input.state
|
|
11868
|
+
});
|
|
11869
|
+
if (executionState) return executionState;
|
|
11870
|
+
}
|
|
11056
11871
|
return null;
|
|
11057
11872
|
};
|
|
11058
11873
|
const resolveLatestScopedConversationExecutionState = (input) => {
|
|
@@ -11861,6 +12676,11 @@ function syncRuntimeEventToInflightTaskControlRegistry(input) {
|
|
|
11861
12676
|
updated: record !== null
|
|
11862
12677
|
};
|
|
11863
12678
|
}
|
|
12679
|
+
if (!("processId" in input.event)) return {
|
|
12680
|
+
processId: null,
|
|
12681
|
+
taskId: input.taskId,
|
|
12682
|
+
updated: false
|
|
12683
|
+
};
|
|
11864
12684
|
const processId = input.event.processId;
|
|
11865
12685
|
if (typeof processId === "number" && Number.isInteger(processId) && processId > 0) {
|
|
11866
12686
|
const record = input.registry.updateTaskProcess({
|
|
@@ -12007,7 +12827,7 @@ async function setDaemonServiceRuntimeState(state, pathInput = {}) {
|
|
|
12007
12827
|
await writeDaemonServiceRuntimeState(state, pathInput);
|
|
12008
12828
|
}
|
|
12009
12829
|
async function clearDaemonServiceRuntimeState(pathInput = {}) {
|
|
12010
|
-
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-
|
|
12830
|
+
const { clearDaemonRuntimeLease } = await import("./daemon-runtime-lease-B8Ox_m9_.js");
|
|
12011
12831
|
await Promise.all([rm(daemonServiceRuntimeStatePath(pathInput), { force: true }), clearDaemonRuntimeLease(pathInput)]);
|
|
12012
12832
|
}
|
|
12013
12833
|
async function withDaemonServiceRunLock(callback, meta = {
|
|
@@ -14025,7 +14845,7 @@ function normalizeHeartbeatIntervalMs(value) {
|
|
|
14025
14845
|
return clampInteger$1(value, MIN_HEARTBEAT_INTERVAL_MS, MAX_HEARTBEAT_INTERVAL_MS);
|
|
14026
14846
|
}
|
|
14027
14847
|
function parseTransportMode(value) {
|
|
14028
|
-
if (value === "local-cli") return value;
|
|
14848
|
+
if (value === "local-cli" || value === "codex-app-server") return value;
|
|
14029
14849
|
return null;
|
|
14030
14850
|
}
|
|
14031
14851
|
function parseStreamingMode(value) {
|
|
@@ -14033,7 +14853,7 @@ function parseStreamingMode(value) {
|
|
|
14033
14853
|
return null;
|
|
14034
14854
|
}
|
|
14035
14855
|
function parseRuntimeTransportMode(value) {
|
|
14036
|
-
if (value === "local-cli") return value;
|
|
14856
|
+
if (value === "local-cli" || value === "codex-app-server") return value;
|
|
14037
14857
|
return null;
|
|
14038
14858
|
}
|
|
14039
14859
|
function parseContextIdMappingSpec(value) {
|
|
@@ -19311,8 +20131,8 @@ function createAgentRegistration(input) {
|
|
|
19311
20131
|
displayName,
|
|
19312
20132
|
enabled: true,
|
|
19313
20133
|
...input.launchContract ? { launchContract: input.launchContract } : {},
|
|
19314
|
-
transportMode: controllerSettings.transportMode,
|
|
19315
|
-
streamingMode: controllerSettings.streamingMode,
|
|
20134
|
+
transportMode: input.transportMode ?? controllerSettings.transportMode,
|
|
20135
|
+
streamingMode: input.streamingMode ?? controllerSettings.streamingMode,
|
|
19316
20136
|
timeoutMs: controllerSettings.timeoutMs,
|
|
19317
20137
|
retry: controllerSettings.retry,
|
|
19318
20138
|
contextIdMappingSpec: controllerSettings.contextIdMappingSpec,
|
|
@@ -19473,11 +20293,17 @@ function normalizeReason(value) {
|
|
|
19473
20293
|
|
|
19474
20294
|
//#endregion
|
|
19475
20295
|
//#region src/skills/agents.ts
|
|
19476
|
-
const SUPPORTED_RUNTIME_TRANSPORT_MODES = new Set(["local-cli"]);
|
|
19477
|
-
const TRANSPORT_MODE_METADATA = {
|
|
19478
|
-
|
|
19479
|
-
|
|
19480
|
-
|
|
20296
|
+
const SUPPORTED_RUNTIME_TRANSPORT_MODES = new Set(["local-cli", "codex-app-server"]);
|
|
20297
|
+
const TRANSPORT_MODE_METADATA = {
|
|
20298
|
+
"local-cli": {
|
|
20299
|
+
label: "Local CLI (Default)",
|
|
20300
|
+
description: "Run via local CLI on this computer, with session continuation when available."
|
|
20301
|
+
},
|
|
20302
|
+
"codex-app-server": {
|
|
20303
|
+
label: "Codex App Server",
|
|
20304
|
+
description: "Run Codex through the local Codex App Server with native thread control."
|
|
20305
|
+
}
|
|
20306
|
+
};
|
|
19481
20307
|
const SUPPORTED_RUNTIME_STREAMING_MODES = new Set(["final", "stream"]);
|
|
19482
20308
|
function resolveSkillsAgentRegistry(skillsConfig) {
|
|
19483
20309
|
const overrides = skillsConfig?.agents ?? {};
|
|
@@ -19621,8 +20447,54 @@ async function listAgentRegistrations() {
|
|
|
19621
20447
|
const runtimeSupportedAgentIds = new Set(Object.entries(registry).filter((entry) => entry[1].runtimeSupported).map((entry) => entry[0]));
|
|
19622
20448
|
const hasUnknownRegistrations = registrations.some((registration) => !knownAgentIds.has(registration.agentId));
|
|
19623
20449
|
const hasUnsupportedRegistrations = registrations.some((registration) => !runtimeSupportedAgentIds.has(registration.agentId));
|
|
19624
|
-
|
|
19625
|
-
|
|
20450
|
+
const reconciliationTimestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
20451
|
+
const reconciled = reconcileAgentRegistrationsForCurrentRegistry({
|
|
20452
|
+
knownAgentIds,
|
|
20453
|
+
registrations,
|
|
20454
|
+
registry,
|
|
20455
|
+
runtimeSupportedAgentIds,
|
|
20456
|
+
timestamp: reconciliationTimestamp
|
|
20457
|
+
});
|
|
20458
|
+
if (!(hasUnknownRegistrations || hasUnsupportedRegistrations || reconciled.changed)) return registrations;
|
|
20459
|
+
return updateAgentRegistrations((current) => reconcileAgentRegistrationsForCurrentRegistry({
|
|
20460
|
+
knownAgentIds,
|
|
20461
|
+
registrations: current,
|
|
20462
|
+
registry,
|
|
20463
|
+
runtimeSupportedAgentIds,
|
|
20464
|
+
timestamp: reconciliationTimestamp
|
|
20465
|
+
}).registrations);
|
|
20466
|
+
}
|
|
20467
|
+
function reconcileAgentRegistrationsForCurrentRegistry(input) {
|
|
20468
|
+
let changed = false;
|
|
20469
|
+
const registrations = [];
|
|
20470
|
+
for (const registration of input.registrations) {
|
|
20471
|
+
if (!(input.knownAgentIds.has(registration.agentId) && input.runtimeSupportedAgentIds.has(registration.agentId))) {
|
|
20472
|
+
changed = true;
|
|
20473
|
+
continue;
|
|
20474
|
+
}
|
|
20475
|
+
const reconciled = reconcileAgentRegistrationRuntimeDefaults({
|
|
20476
|
+
registration,
|
|
20477
|
+
registryEntry: input.registry[registration.agentId],
|
|
20478
|
+
timestamp: input.timestamp
|
|
20479
|
+
});
|
|
20480
|
+
if (reconciled !== registration) changed = true;
|
|
20481
|
+
registrations.push(reconciled);
|
|
20482
|
+
}
|
|
20483
|
+
return {
|
|
20484
|
+
changed,
|
|
20485
|
+
registrations: sortAgentRegistrations(registrations)
|
|
20486
|
+
};
|
|
20487
|
+
}
|
|
20488
|
+
function reconcileAgentRegistrationRuntimeDefaults(input) {
|
|
20489
|
+
const supportedTransportModes = input.registryEntry?.transportModes.map((transportMode) => transportMode.mode) ?? [];
|
|
20490
|
+
const defaultTransportMode = input.registryEntry?.defaultTransportMode ?? supportedTransportModes[0] ?? null;
|
|
20491
|
+
const transportModeSupported = input.registration.transportMode ? supportedTransportModes.includes(input.registration.transportMode) : false;
|
|
20492
|
+
if (!defaultTransportMode || transportModeSupported) return input.registration;
|
|
20493
|
+
return {
|
|
20494
|
+
...input.registration,
|
|
20495
|
+
transportMode: defaultTransportMode,
|
|
20496
|
+
updatedAt: input.timestamp
|
|
20497
|
+
};
|
|
19626
20498
|
}
|
|
19627
20499
|
async function listAgentTargetStates() {
|
|
19628
20500
|
const [catalog, registrations] = await Promise.all([loadAgentCatalog(), listAgentRegistrations()]);
|
|
@@ -19781,7 +20653,9 @@ function createRegistrationFromCatalogTarget(target) {
|
|
|
19781
20653
|
return createAgentRegistration({
|
|
19782
20654
|
agentId: target.agentId,
|
|
19783
20655
|
displayName: target.displayName,
|
|
19784
|
-
...target.launchContract ? { launchContract: target.launchContract } : {}
|
|
20656
|
+
...target.launchContract ? { launchContract: target.launchContract } : {},
|
|
20657
|
+
...target.defaultStreamingMode ? { streamingMode: target.defaultStreamingMode } : {},
|
|
20658
|
+
...target.defaultTransportMode ? { transportMode: target.defaultTransportMode } : {}
|
|
19785
20659
|
});
|
|
19786
20660
|
}
|
|
19787
20661
|
async function toAgentTargetState(target, registration) {
|
|
@@ -20641,6 +21515,9 @@ function buildSpaceUpdatesPath(spaceId) {
|
|
|
20641
21515
|
function buildSpaceWakeProgressPath(spaceId) {
|
|
20642
21516
|
return buildSpaceRoutePath(spaceId, "wake-progress");
|
|
20643
21517
|
}
|
|
21518
|
+
function buildActiveSpaceWakeProgressPath(spaceId) {
|
|
21519
|
+
return buildSpaceRoutePath(spaceId, "active-wake-progress");
|
|
21520
|
+
}
|
|
20644
21521
|
function buildSpaceWakeTraceWaterfallPath(spaceId) {
|
|
20645
21522
|
return buildSpaceRoutePath(spaceId, "wake-trace-waterfall");
|
|
20646
21523
|
}
|
|
@@ -21030,6 +21907,20 @@ async function getSpaceWakeProgress(client, input) {
|
|
|
21030
21907
|
invalidMessage: "invalid wake progress response"
|
|
21031
21908
|
});
|
|
21032
21909
|
}
|
|
21910
|
+
async function getActiveSpaceWakeProgress(client, input) {
|
|
21911
|
+
const searchParams = new URLSearchParams();
|
|
21912
|
+
if (input.targetProfileId) searchParams.set("targetProfileId", input.targetProfileId);
|
|
21913
|
+
const query = searchParams.toString();
|
|
21914
|
+
return await client.requestJson({
|
|
21915
|
+
url: query ? `${buildActiveSpaceWakeProgressPath(input.spaceId)}?${query}` : buildActiveSpaceWakeProgressPath(input.spaceId),
|
|
21916
|
+
operation: "space.active_wake_progress",
|
|
21917
|
+
method: "GET",
|
|
21918
|
+
requestContext: input.requestContext,
|
|
21919
|
+
...input.spacePassword === void 0 ? {} : { spacePassword: input.spacePassword },
|
|
21920
|
+
schema: getActiveSpaceWakeProgressResponseSchema,
|
|
21921
|
+
invalidMessage: "invalid active wake progress response"
|
|
21922
|
+
});
|
|
21923
|
+
}
|
|
21033
21924
|
async function getSpaceWakeTraceWaterfall(client, input) {
|
|
21034
21925
|
const searchParams = new URLSearchParams();
|
|
21035
21926
|
if (input.clientMessageId) searchParams.set("clientMessageId", input.clientMessageId);
|
|
@@ -21059,6 +21950,7 @@ const createSpaceApi = (client) => {
|
|
|
21059
21950
|
listSignals: async (input) => await listSpaceSignals(client, input),
|
|
21060
21951
|
listSignalEnvelopes: async (input) => await listSpaceSignalEnvelopes(client, input),
|
|
21061
21952
|
getUpdates: async (input) => await getSpaceUpdates(client, input),
|
|
21953
|
+
getActiveWakeProgress: async (input) => await getActiveSpaceWakeProgress(client, input),
|
|
21062
21954
|
getWakeProgress: async (input) => await getSpaceWakeProgress(client, input),
|
|
21063
21955
|
getWakeTraceWaterfall: async (input) => await getSpaceWakeTraceWaterfall(client, input),
|
|
21064
21956
|
getMessageDetails: async (input) => await getSpaceMessageDetails(client, input),
|
|
@@ -22555,11 +23447,29 @@ function buildAcceptedLocalDaemonRouteCandidate(input) {
|
|
|
22555
23447
|
launchContract: input.localController.launchContract,
|
|
22556
23448
|
profileId: input.profileId,
|
|
22557
23449
|
streamingMode: parseStreamingMode(input.localController.streamingMode) ?? parseStreamingMode(input.runtimeControllerSupport.runtimeAdapterMatch.defaultStreamingMode) ?? defaults.streamingMode,
|
|
22558
|
-
transportMode:
|
|
23450
|
+
transportMode: resolveAcceptedRouteTransportMode({
|
|
23451
|
+
defaults,
|
|
23452
|
+
localController: input.localController,
|
|
23453
|
+
runtimeControllerSupport: input.runtimeControllerSupport
|
|
23454
|
+
})
|
|
22559
23455
|
},
|
|
22560
23456
|
status: "accepted"
|
|
22561
23457
|
};
|
|
22562
23458
|
}
|
|
23459
|
+
function resolveAcceptedRouteTransportMode(input) {
|
|
23460
|
+
const supportedTransportModes = /* @__PURE__ */ new Set();
|
|
23461
|
+
for (const transportMode of input.runtimeControllerSupport.runtimeAdapterMatch.transportModes) {
|
|
23462
|
+
const parsedTransportMode = parseRuntimeTransportMode(transportMode);
|
|
23463
|
+
if (parsedTransportMode) supportedTransportModes.add(parsedTransportMode);
|
|
23464
|
+
}
|
|
23465
|
+
const configuredTransportMode = parseTransportMode(input.localController.transportMode);
|
|
23466
|
+
if (configuredTransportMode && supportedTransportModes.has(configuredTransportMode)) return configuredTransportMode;
|
|
23467
|
+
const registryDefaultTransportMode = parseRuntimeTransportMode(input.runtimeControllerSupport.runtimeAdapterMatch.defaultTransportMode);
|
|
23468
|
+
if (registryDefaultTransportMode && supportedTransportModes.has(registryDefaultTransportMode)) return registryDefaultTransportMode;
|
|
23469
|
+
const firstSupportedTransportMode = [...supportedTransportModes][0] ?? null;
|
|
23470
|
+
if (firstSupportedTransportMode) return firstSupportedTransportMode;
|
|
23471
|
+
return input.defaults.transportMode;
|
|
23472
|
+
}
|
|
22563
23473
|
function buildSkippedLocalDaemonRouteCandidate(input) {
|
|
22564
23474
|
return {
|
|
22565
23475
|
...input?.profileId ? { profileId: input.profileId } : {},
|
|
@@ -37866,7 +38776,7 @@ async function resolveLocalConversationExecutionStatus(input) {
|
|
|
37866
38776
|
transportMode: input.transportMode,
|
|
37867
38777
|
workspaceResolution
|
|
37868
38778
|
});
|
|
37869
|
-
const liveResumeCheck = input.validate === true ? await
|
|
38779
|
+
const liveResumeCheck = input.validate === true ? await runProviderConversationProof({
|
|
37870
38780
|
boundAgentControllerRef: input.boundAgentControllerRef,
|
|
37871
38781
|
agentControllerConversationId: input.agentControllerConversationId,
|
|
37872
38782
|
launchContract: localController?.launchContract ?? null,
|
|
@@ -37945,11 +38855,11 @@ function buildLiveResumeCheckNotRun() {
|
|
|
37945
38855
|
errorCode: null,
|
|
37946
38856
|
errorMessage: null,
|
|
37947
38857
|
errorType: null,
|
|
37948
|
-
message: "
|
|
38858
|
+
message: "Provider conversation proof was not run. Re-run with --validate to confirm Wake availability on this device.",
|
|
37949
38859
|
status: "not_run"
|
|
37950
38860
|
};
|
|
37951
38861
|
}
|
|
37952
|
-
async function
|
|
38862
|
+
async function runProviderConversationProof(input) {
|
|
37953
38863
|
if (!input.agentControllerConversationId) return {
|
|
37954
38864
|
checkedAt: null,
|
|
37955
38865
|
errorCode: null,
|
|
@@ -37980,7 +38890,7 @@ async function runProviderResumeProbe(input) {
|
|
|
37980
38890
|
errorCode: "controller_ref_mismatch",
|
|
37981
38891
|
errorMessage: "The bound agent controller conversation controller does not match the current agent profile controller.",
|
|
37982
38892
|
errorType: "config",
|
|
37983
|
-
message: "
|
|
38893
|
+
message: "Provider conversation proof was skipped because the bound controller does not match the current agent profile controller.",
|
|
37984
38894
|
status: "skipped"
|
|
37985
38895
|
};
|
|
37986
38896
|
const providerId = normalizeKnownBuiltinAgentControllerId(input.profileAgentControllerRef);
|
|
@@ -37988,9 +38898,9 @@ async function runProviderResumeProbe(input) {
|
|
|
37988
38898
|
if (!(providerId && agentControllerConversationKind)) return {
|
|
37989
38899
|
checkedAt,
|
|
37990
38900
|
errorCode: "provider_unsupported",
|
|
37991
|
-
errorMessage: `
|
|
38901
|
+
errorMessage: `Provider conversation proof is not available for ${input.profileAgentControllerRef}.`,
|
|
37992
38902
|
errorType: "config",
|
|
37993
|
-
message: `
|
|
38903
|
+
message: `Provider conversation proof is not available for ${input.profileAgentControllerRef} in this phase.`,
|
|
37994
38904
|
status: "skipped"
|
|
37995
38905
|
};
|
|
37996
38906
|
const agentControllerConversation = buildAgentControllerConversationRef({
|
|
@@ -37999,15 +38909,14 @@ async function runProviderResumeProbe(input) {
|
|
|
37999
38909
|
agentControllerConversationKind
|
|
38000
38910
|
});
|
|
38001
38911
|
try {
|
|
38002
|
-
if (providerId === "codex") await
|
|
38003
|
-
codexTimeoutMs:
|
|
38912
|
+
if (providerId === "codex") await verifyCodexAppServerThread({
|
|
38913
|
+
codexTimeoutMs: resolveProviderConversationProofTimeoutMs(resolveCodexTimeoutMs()),
|
|
38004
38914
|
codexWorkdir: input.runtimeWorkingDirectory,
|
|
38005
38915
|
launchContract: input.launchContract,
|
|
38006
|
-
prompt: LIVE_RESUME_PROBE_PROMPT,
|
|
38007
38916
|
threadId: agentControllerConversation.agentControllerConversationId
|
|
38008
38917
|
});
|
|
38009
38918
|
else if (providerId === "claude-code") await invokeClaudeCliTransport({
|
|
38010
|
-
claudeTimeoutMs:
|
|
38919
|
+
claudeTimeoutMs: resolveProviderConversationProofTimeoutMs(resolveClaudeCodeTimeoutMs()),
|
|
38011
38920
|
claudeWorkdir: input.runtimeWorkingDirectory,
|
|
38012
38921
|
launchContract: input.launchContract,
|
|
38013
38922
|
prompt: LIVE_RESUME_PROBE_PROMPT,
|
|
@@ -38016,9 +38925,9 @@ async function runProviderResumeProbe(input) {
|
|
|
38016
38925
|
else return {
|
|
38017
38926
|
checkedAt,
|
|
38018
38927
|
errorCode: "provider_unsupported",
|
|
38019
|
-
errorMessage: `
|
|
38928
|
+
errorMessage: `Provider conversation proof is not available for ${agentControllerConversation.agentControllerRef}.`,
|
|
38020
38929
|
errorType: "config",
|
|
38021
|
-
message: `
|
|
38930
|
+
message: `Provider conversation proof is not available for ${agentControllerConversation.agentControllerRef} in this phase.`,
|
|
38022
38931
|
status: "skipped"
|
|
38023
38932
|
};
|
|
38024
38933
|
return {
|
|
@@ -38026,7 +38935,7 @@ async function runProviderResumeProbe(input) {
|
|
|
38026
38935
|
errorCode: null,
|
|
38027
38936
|
errorMessage: null,
|
|
38028
38937
|
errorType: null,
|
|
38029
|
-
message: "
|
|
38938
|
+
message: providerId === "codex" ? "Codex App Server thread proof passed. ATS can control this Agent Profile thread on this device without adding a probe turn." : "Provider conversation proof passed. ATS can resume this Agent Profile conversation on this device.",
|
|
38030
38939
|
status: "passed"
|
|
38031
38940
|
};
|
|
38032
38941
|
} catch (error) {
|
|
@@ -38035,7 +38944,7 @@ async function runProviderResumeProbe(input) {
|
|
|
38035
38944
|
errorCode: readErrorCode$1(error),
|
|
38036
38945
|
errorMessage: readErrorMessage(error),
|
|
38037
38946
|
errorType: readErrorType(error),
|
|
38038
|
-
message: "
|
|
38947
|
+
message: providerId === "codex" ? "Codex App Server thread proof failed. ATS should not wake this Agent Profile until the Codex thread or local App Server runtime is fixed." : "Provider conversation proof failed. ATS should not wake this Agent Profile until the agent controller conversation or local runtime is fixed.",
|
|
38039
38948
|
status: "failed"
|
|
38040
38949
|
};
|
|
38041
38950
|
}
|
|
@@ -38103,10 +39012,10 @@ function readErrorType(error) {
|
|
|
38103
39012
|
return null;
|
|
38104
39013
|
}
|
|
38105
39014
|
const LIVE_RESUME_PROBE_PROMPT = "ATS resume probe. Reply with one short confirmation sentence.";
|
|
38106
|
-
const
|
|
38107
|
-
function
|
|
38108
|
-
if (runtimeTimeoutMs === null) return
|
|
38109
|
-
return Math.min(runtimeTimeoutMs,
|
|
39015
|
+
const PROVIDER_CONVERSATION_PROOF_TIMEOUT_MS = 3e4;
|
|
39016
|
+
function resolveProviderConversationProofTimeoutMs(runtimeTimeoutMs) {
|
|
39017
|
+
if (runtimeTimeoutMs === null) return PROVIDER_CONVERSATION_PROOF_TIMEOUT_MS;
|
|
39018
|
+
return Math.min(runtimeTimeoutMs, PROVIDER_CONVERSATION_PROOF_TIMEOUT_MS);
|
|
38110
39019
|
}
|
|
38111
39020
|
|
|
38112
39021
|
//#endregion
|
|
@@ -40780,6 +41689,8 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
40780
41689
|
let contextIdForDispatch = null;
|
|
40781
41690
|
let bootstrapPlan = null;
|
|
40782
41691
|
let plannedAgentControllerConversation = null;
|
|
41692
|
+
let observedProviderConversationId = null;
|
|
41693
|
+
let observedProviderConversation = null;
|
|
40783
41694
|
let runtimePrompt = "";
|
|
40784
41695
|
let runtimePromptTrace = null;
|
|
40785
41696
|
let stopRunningKeepalive = null;
|
|
@@ -40863,9 +41774,11 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
40863
41774
|
agentControllerConversationResumePlan
|
|
40864
41775
|
});
|
|
40865
41776
|
plannedAgentControllerConversation = resolvePlannedAgentControllerConversation({
|
|
40866
|
-
agentControllerConversationId:
|
|
41777
|
+
agentControllerConversationId: contextIdForDispatch,
|
|
40867
41778
|
agentControllerRef: parsedTask.agentControllerRef
|
|
40868
41779
|
});
|
|
41780
|
+
observedProviderConversationId = contextIdForDispatch;
|
|
41781
|
+
observedProviderConversation = plannedAgentControllerConversation;
|
|
40869
41782
|
bootstrapPlan = resolveBootstrapPlan({
|
|
40870
41783
|
bootstrapTemplateFacts: bootstrapContext.bootstrapTemplateFacts,
|
|
40871
41784
|
executionState: currentExecutionState,
|
|
@@ -40992,6 +41905,55 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
40992
41905
|
phase: "runtime_invocation_started",
|
|
40993
41906
|
result: "started"
|
|
40994
41907
|
});
|
|
41908
|
+
const providerConversationLedgerIo = ledgerIo;
|
|
41909
|
+
if (!providerConversationLedgerIo) throw new DaemonServiceRunError({
|
|
41910
|
+
code: "dispatch.ledger.unavailable",
|
|
41911
|
+
message: "dispatch.ledger.unavailable: dispatch ledger is not initialized"
|
|
41912
|
+
});
|
|
41913
|
+
const recordProviderConversationObservation = (observation) => {
|
|
41914
|
+
const agentControllerConversationId = normalizeOptionalContextId(observation.agentControllerConversationId);
|
|
41915
|
+
if (!agentControllerConversationId) return null;
|
|
41916
|
+
const agentControllerConversation = observation.agentControllerConversation ?? buildAgentControllerConversationRefFromAgentControllerConversation({
|
|
41917
|
+
agentControllerConversationId,
|
|
41918
|
+
agentControllerRef: parsedTask.agentControllerRef
|
|
41919
|
+
});
|
|
41920
|
+
observedProviderConversationId = agentControllerConversationId;
|
|
41921
|
+
observedProviderConversation = agentControllerConversation;
|
|
41922
|
+
withLedgerStateTransaction({
|
|
41923
|
+
invalidStateStrategy: "backup_and_reset",
|
|
41924
|
+
io: providerConversationLedgerIo,
|
|
41925
|
+
mutate: (state) => ({
|
|
41926
|
+
nextState: commitResolvedAgentContext({
|
|
41927
|
+
state,
|
|
41928
|
+
agentContextLookupKey: contextLookupKey,
|
|
41929
|
+
agentControllerConversationId,
|
|
41930
|
+
agentControllerRef: parsedTask.agentControllerRef,
|
|
41931
|
+
spaceId: parsedTask.spaceId,
|
|
41932
|
+
targetProfileId: parsedTask.targetProfileId,
|
|
41933
|
+
transportMode: parsedTask.transportMode,
|
|
41934
|
+
runtimeWorkspaceFingerprint: buildRuntimeWorkspaceFingerprint(activeRuntimeContext.providerRuntimeWorkingDirectory),
|
|
41935
|
+
taskId: parsedTask.taskId,
|
|
41936
|
+
nowMs: Date.now()
|
|
41937
|
+
}),
|
|
41938
|
+
value: void 0
|
|
41939
|
+
}),
|
|
41940
|
+
paths: input.ledgerPaths
|
|
41941
|
+
}).catch((error) => {
|
|
41942
|
+
emitRunLine({
|
|
41943
|
+
presenter: input.presenter,
|
|
41944
|
+
code: "daemon.run.provider_conversation_observation_ignored",
|
|
41945
|
+
text: `provider conversation observation could not be persisted for task ${parsedTask.taskId}`,
|
|
41946
|
+
payload: {
|
|
41947
|
+
dispatchId: parsedTask.dispatchId,
|
|
41948
|
+
errorMessage: toErrorMessage$28(error),
|
|
41949
|
+
source: observation.source,
|
|
41950
|
+
targetProfileId: parsedTask.targetProfileId,
|
|
41951
|
+
taskId: parsedTask.taskId
|
|
41952
|
+
}
|
|
41953
|
+
});
|
|
41954
|
+
});
|
|
41955
|
+
return agentControllerConversationId;
|
|
41956
|
+
};
|
|
40995
41957
|
const runtimeExecutionPromise = Promise.resolve(runDispatchRuntimeExecution({
|
|
40996
41958
|
contextId: contextIdForDispatch,
|
|
40997
41959
|
executionMode: "normal",
|
|
@@ -41011,6 +41973,11 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
41011
41973
|
});
|
|
41012
41974
|
},
|
|
41013
41975
|
onRuntimeEvent: (event) => {
|
|
41976
|
+
if (event.phase === "provider_conversation_observed") recordProviderConversationObservation({
|
|
41977
|
+
agentControllerConversation: event.agentControllerConversation ?? null,
|
|
41978
|
+
agentControllerConversationId: event.agentControllerConversationId,
|
|
41979
|
+
source: "runtime_event"
|
|
41980
|
+
});
|
|
41014
41981
|
if (!firstOutputEvidenceSent && (event.phase === "first_stdout" || event.phase === "first_stderr")) {
|
|
41015
41982
|
firstOutputEvidenceSent = true;
|
|
41016
41983
|
emitDispatchRuntimeEvidenceTransition({
|
|
@@ -41077,8 +42044,18 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
41077
42044
|
let runtimeResult = await resolveRuntimeResultFromRuntimeOrCliSpaceAction({
|
|
41078
42045
|
contextIdForDispatch,
|
|
41079
42046
|
dispatchSpaceActionContext,
|
|
42047
|
+
getObservedAgentControllerConversation: () => observedProviderConversation,
|
|
42048
|
+
getObservedAgentControllerConversationId: () => observedProviderConversationId,
|
|
41080
42049
|
ledgerIo,
|
|
41081
42050
|
ledgerPaths: input.ledgerPaths,
|
|
42051
|
+
onRuntimeResultAfterCliSpaceAction: (runtimeResult) => {
|
|
42052
|
+
const runtimeContextDelta = resolveDispatchContextDeltaFromRuntimeResult(runtimeResult.dispatchResult);
|
|
42053
|
+
recordProviderConversationObservation({
|
|
42054
|
+
agentControllerConversation: runtimeResult.contextResolution?.agentControllerConversation ?? runtimeContextDelta?.agentControllerConversation ?? null,
|
|
42055
|
+
agentControllerConversationId: runtimeResult.contextResolution?.agentControllerConversationId ?? runtimeContextDelta?.agentControllerConversationId ?? null,
|
|
42056
|
+
source: "runtime_result"
|
|
42057
|
+
});
|
|
42058
|
+
},
|
|
41082
42059
|
parsedTask,
|
|
41083
42060
|
presenter: input.presenter,
|
|
41084
42061
|
runtimeExecutionPromise
|
|
@@ -41614,19 +42591,6 @@ async function resolveRuntimeResultFromRuntimeOrCliSpaceAction(input) {
|
|
|
41614
42591
|
runtimeResult: completion.runtimeResult
|
|
41615
42592
|
});
|
|
41616
42593
|
if (completion.kind === "cli_space_action_poll_aborted") return await input.runtimeExecutionPromise;
|
|
41617
|
-
input.runtimeExecutionPromise.catch((error) => {
|
|
41618
|
-
emitRunLine({
|
|
41619
|
-
presenter: input.presenter,
|
|
41620
|
-
code: "daemon.run.runtime_ignored_after_cli_space_action",
|
|
41621
|
-
text: `runtime completed after CLI ATS Space Action finalized task ${input.parsedTask.taskId}`,
|
|
41622
|
-
payload: {
|
|
41623
|
-
dispatchId: input.parsedTask.dispatchId,
|
|
41624
|
-
errorMessage: toErrorMessage$28(error),
|
|
41625
|
-
targetProfileId: input.parsedTask.targetProfileId,
|
|
41626
|
-
taskId: input.parsedTask.taskId
|
|
41627
|
-
}
|
|
41628
|
-
});
|
|
41629
|
-
});
|
|
41630
42594
|
if (completion.kind === "cli_space_action_invalid") throw new DaemonServiceRunError({
|
|
41631
42595
|
code: "dispatch.cli_space_action.invalid",
|
|
41632
42596
|
message: completion.errorMessage
|
|
@@ -41643,8 +42607,28 @@ async function resolveRuntimeResultFromRuntimeOrCliSpaceAction(input) {
|
|
|
41643
42607
|
taskId: input.parsedTask.taskId
|
|
41644
42608
|
}
|
|
41645
42609
|
});
|
|
42610
|
+
const completedRuntimeResult = await resolveAlreadyCompletedRuntimeResultAfterCliSpaceAction({
|
|
42611
|
+
parsedTask: input.parsedTask,
|
|
42612
|
+
presenter: input.presenter,
|
|
42613
|
+
runtimeExecutionPromise: input.runtimeExecutionPromise
|
|
42614
|
+
});
|
|
42615
|
+
if (completedRuntimeResult) return applyCliSpaceActionRecordToRuntimeResult({
|
|
42616
|
+
record: completion.record,
|
|
42617
|
+
runtimeResult: completedRuntimeResult
|
|
42618
|
+
});
|
|
42619
|
+
observeRuntimeResultAfterCliSpaceAction({
|
|
42620
|
+
onRuntimeResultAfterCliSpaceAction: input.onRuntimeResultAfterCliSpaceAction,
|
|
42621
|
+
parsedTask: input.parsedTask,
|
|
42622
|
+
presenter: input.presenter,
|
|
42623
|
+
runtimeExecutionPromise: input.runtimeExecutionPromise
|
|
42624
|
+
});
|
|
42625
|
+
const observedAgentControllerConversationId = normalizeOptionalContextId(input.getObservedAgentControllerConversationId?.() ?? null) ?? input.contextIdForDispatch;
|
|
41646
42626
|
return await buildCliSpaceActionRuntimeResult({
|
|
41647
|
-
|
|
42627
|
+
agentControllerConversation: input.getObservedAgentControllerConversation?.() ?? buildAgentControllerConversationRefFromAgentControllerConversation({
|
|
42628
|
+
agentControllerConversationId: observedAgentControllerConversationId,
|
|
42629
|
+
agentControllerRef: input.parsedTask.agentControllerRef
|
|
42630
|
+
}),
|
|
42631
|
+
agentControllerConversationId: observedAgentControllerConversationId,
|
|
41648
42632
|
ledgerIo: input.ledgerIo,
|
|
41649
42633
|
ledgerPaths: input.ledgerPaths,
|
|
41650
42634
|
parsedTask: input.parsedTask,
|
|
@@ -41672,23 +42656,20 @@ async function waitForCliSpaceActionRecord(input) {
|
|
|
41672
42656
|
return { kind: "cli_space_action_poll_aborted" };
|
|
41673
42657
|
}
|
|
41674
42658
|
async function buildCliSpaceActionRuntimeResult(input) {
|
|
41675
|
-
const
|
|
41676
|
-
|
|
41677
|
-
cleanedOutput: ""
|
|
41678
|
-
});
|
|
41679
|
-
const resultPayload = {
|
|
41680
|
-
...buildTaskResultPayloadFromOutcome({
|
|
42659
|
+
const resultPayload = buildCliSpaceActionSuccessPayload({
|
|
42660
|
+
basePayload: {
|
|
41681
42661
|
agentId: input.parsedTask.targetProfileId,
|
|
41682
42662
|
attemptId: input.parsedTask.attemptId,
|
|
41683
42663
|
deduped: false,
|
|
41684
|
-
emitFailed: false,
|
|
41685
|
-
output,
|
|
41686
42664
|
sourceEventId: input.parsedTask.sourceEventId,
|
|
41687
|
-
taskId: input.parsedTask.taskId
|
|
41688
|
-
|
|
41689
|
-
|
|
41690
|
-
|
|
41691
|
-
|
|
42665
|
+
taskId: input.parsedTask.taskId,
|
|
42666
|
+
...input.agentControllerConversation ? { agentControllerConversation: input.agentControllerConversation } : {},
|
|
42667
|
+
...input.agentControllerConversationId ? { agentControllerConversationId: input.agentControllerConversationId } : {},
|
|
42668
|
+
...input.parsedTask.agentControllerRef ? { agentControllerRef: input.parsedTask.agentControllerRef } : {},
|
|
42669
|
+
...input.parsedTask.transportMode ? { transportMode: input.parsedTask.transportMode } : {}
|
|
42670
|
+
},
|
|
42671
|
+
record: input.record
|
|
42672
|
+
});
|
|
41692
42673
|
const state = await withLedgerStateTransaction({
|
|
41693
42674
|
invalidStateStrategy: "backup_and_reset",
|
|
41694
42675
|
io: input.ledgerIo,
|
|
@@ -41720,8 +42701,11 @@ async function buildCliSpaceActionRuntimeResult(input) {
|
|
|
41720
42701
|
deduped: false,
|
|
41721
42702
|
dispatchResult: {
|
|
41722
42703
|
adapterResult: {
|
|
41723
|
-
...input.
|
|
41724
|
-
|
|
42704
|
+
...input.agentControllerConversationId ? { contextDelta: {
|
|
42705
|
+
...input.agentControllerConversation ? { agentControllerConversation: input.agentControllerConversation } : {},
|
|
42706
|
+
agentControllerConversationId: input.agentControllerConversationId
|
|
42707
|
+
} } : {},
|
|
42708
|
+
output: resultPayload.output,
|
|
41725
42709
|
status: "success"
|
|
41726
42710
|
},
|
|
41727
42711
|
dispatched: true,
|
|
@@ -41765,13 +42749,86 @@ async function applyCliSpaceActionRecordIfPresent(input) {
|
|
|
41765
42749
|
taskId: input.parsedTask.taskId
|
|
41766
42750
|
}
|
|
41767
42751
|
});
|
|
42752
|
+
return applyCliSpaceActionRecordToRuntimeResult({
|
|
42753
|
+
record: readResult.record,
|
|
42754
|
+
runtimeResult: input.runtimeResult
|
|
42755
|
+
});
|
|
42756
|
+
}
|
|
42757
|
+
async function resolveAlreadyCompletedRuntimeResultAfterCliSpaceAction(input) {
|
|
42758
|
+
try {
|
|
42759
|
+
const result = await Promise.race([input.runtimeExecutionPromise.then((runtimeResult) => ({
|
|
42760
|
+
runtimeResult,
|
|
42761
|
+
status: "runtime"
|
|
42762
|
+
})), setTimeout$1(0).then(() => ({ status: "pending" }))]);
|
|
42763
|
+
if (result.status === "runtime") return result.runtimeResult;
|
|
42764
|
+
} catch (error) {
|
|
42765
|
+
emitRunLine({
|
|
42766
|
+
presenter: input.presenter,
|
|
42767
|
+
code: "daemon.run.runtime_ignored_after_cli_space_action",
|
|
42768
|
+
text: `runtime failed after CLI ATS Space Action finalized task ${input.parsedTask.taskId}`,
|
|
42769
|
+
payload: {
|
|
42770
|
+
dispatchId: input.parsedTask.dispatchId,
|
|
42771
|
+
errorMessage: toErrorMessage$28(error),
|
|
42772
|
+
targetProfileId: input.parsedTask.targetProfileId,
|
|
42773
|
+
taskId: input.parsedTask.taskId
|
|
42774
|
+
}
|
|
42775
|
+
});
|
|
42776
|
+
}
|
|
42777
|
+
return null;
|
|
42778
|
+
}
|
|
42779
|
+
function observeRuntimeResultAfterCliSpaceAction(input) {
|
|
42780
|
+
input.runtimeExecutionPromise.then(async (runtimeResult) => {
|
|
42781
|
+
await input.onRuntimeResultAfterCliSpaceAction?.(runtimeResult);
|
|
42782
|
+
}).catch((error) => {
|
|
42783
|
+
emitRunLine({
|
|
42784
|
+
presenter: input.presenter,
|
|
42785
|
+
code: "daemon.run.runtime_ignored_after_cli_space_action",
|
|
42786
|
+
text: `runtime failed after CLI ATS Space Action finalized task ${input.parsedTask.taskId}`,
|
|
42787
|
+
payload: {
|
|
42788
|
+
dispatchId: input.parsedTask.dispatchId,
|
|
42789
|
+
errorMessage: toErrorMessage$28(error),
|
|
42790
|
+
targetProfileId: input.parsedTask.targetProfileId,
|
|
42791
|
+
taskId: input.parsedTask.taskId
|
|
42792
|
+
}
|
|
42793
|
+
});
|
|
42794
|
+
});
|
|
42795
|
+
}
|
|
42796
|
+
function applyCliSpaceActionRecordToRuntimeResult(input) {
|
|
41768
42797
|
return {
|
|
41769
42798
|
...input.runtimeResult,
|
|
41770
|
-
resultPayload: {
|
|
41771
|
-
|
|
41772
|
-
|
|
41773
|
-
|
|
41774
|
-
|
|
42799
|
+
resultPayload: buildCliSpaceActionSuccessPayload({
|
|
42800
|
+
basePayload: input.runtimeResult.resultPayload,
|
|
42801
|
+
record: input.record
|
|
42802
|
+
})
|
|
42803
|
+
};
|
|
42804
|
+
}
|
|
42805
|
+
function buildCliSpaceActionSuccessPayload(input) {
|
|
42806
|
+
const output = resolveStructuredActionOutputFallback({
|
|
42807
|
+
action: input.record.action,
|
|
42808
|
+
cleanedOutput: ""
|
|
42809
|
+
});
|
|
42810
|
+
return {
|
|
42811
|
+
agentId: input.basePayload.agentId,
|
|
42812
|
+
attemptId: input.basePayload.attemptId,
|
|
42813
|
+
deduped: input.basePayload.deduped,
|
|
42814
|
+
sourceEventId: input.basePayload.sourceEventId,
|
|
42815
|
+
taskId: input.basePayload.taskId,
|
|
42816
|
+
...input.basePayload.agentControllerConversation ? { agentControllerConversation: input.basePayload.agentControllerConversation } : {},
|
|
42817
|
+
...input.basePayload.agentControllerConversationId ? { agentControllerConversationId: input.basePayload.agentControllerConversationId } : {},
|
|
42818
|
+
...input.basePayload.agentControllerRef ? { agentControllerRef: input.basePayload.agentControllerRef } : {},
|
|
42819
|
+
...input.basePayload.bootstrapTemplateFacts ? { bootstrapTemplateFacts: input.basePayload.bootstrapTemplateFacts } : {},
|
|
42820
|
+
...input.basePayload.dispatchExecution ? { dispatchExecution: input.basePayload.dispatchExecution } : {},
|
|
42821
|
+
...input.basePayload.effectiveRuntimeWorkingDirectory ? { effectiveRuntimeWorkingDirectory: input.basePayload.effectiveRuntimeWorkingDirectory } : {},
|
|
42822
|
+
...input.basePayload.openClawBinding ? { openClawBinding: input.basePayload.openClawBinding } : {},
|
|
42823
|
+
...input.basePayload.openClawGatewayVisibility ? { openClawGatewayVisibility: input.basePayload.openClawGatewayVisibility } : {},
|
|
42824
|
+
...input.basePayload.promptTrace ? { promptTrace: input.basePayload.promptTrace } : {},
|
|
42825
|
+
...input.basePayload.runtimeWorkspaceFingerprint ? { runtimeWorkspaceFingerprint: input.basePayload.runtimeWorkspaceFingerprint } : {},
|
|
42826
|
+
...input.basePayload.telemetry ? { telemetry: input.basePayload.telemetry } : {},
|
|
42827
|
+
...input.basePayload.transportMode ? { transportMode: input.basePayload.transportMode } : {},
|
|
42828
|
+
output,
|
|
42829
|
+
spaceAction: input.record.action,
|
|
42830
|
+
spaceActionProvenance: "cli_action",
|
|
42831
|
+
status: "success"
|
|
41775
42832
|
};
|
|
41776
42833
|
}
|
|
41777
42834
|
async function readCliSpaceActionRecordWithGrace(input) {
|
|
@@ -42971,7 +44028,7 @@ function emitProviderRuntimePhaseLine(input) {
|
|
|
42971
44028
|
agentControllerRef: input.agentControllerRef,
|
|
42972
44029
|
dispatchId: input.dispatchId,
|
|
42973
44030
|
phase: input.event.phase,
|
|
42974
|
-
processId: input.event.processId,
|
|
44031
|
+
processId: "processId" in input.event ? input.event.processId : null,
|
|
42975
44032
|
sinceRuntimeStartedMs,
|
|
42976
44033
|
targetProfileId: input.targetProfileId,
|
|
42977
44034
|
taskId: input.taskId
|
|
@@ -43029,6 +44086,17 @@ function emitProviderRuntimePhaseLine(input) {
|
|
|
43029
44086
|
}
|
|
43030
44087
|
});
|
|
43031
44088
|
return;
|
|
44089
|
+
case "provider_conversation_observed":
|
|
44090
|
+
emitRunLine({
|
|
44091
|
+
presenter: input.presenter,
|
|
44092
|
+
code: "daemon.run.provider_conversation_observed",
|
|
44093
|
+
text: `provider conversation observed for task ${input.taskId}`,
|
|
44094
|
+
payload: {
|
|
44095
|
+
...basePayload,
|
|
44096
|
+
agentControllerConversationId: input.event.agentControllerConversationId
|
|
44097
|
+
}
|
|
44098
|
+
});
|
|
44099
|
+
return;
|
|
43032
44100
|
default: return;
|
|
43033
44101
|
}
|
|
43034
44102
|
}
|
|
@@ -55342,6 +56410,7 @@ function formatTransportModeDisplay(value) {
|
|
|
55342
56410
|
const normalized = String(value ?? "").trim();
|
|
55343
56411
|
if (!normalized || normalized === "not configured") return DISPLAY_NOT_SET_UP;
|
|
55344
56412
|
if (normalized === "local-cli") return "Local CLI";
|
|
56413
|
+
if (normalized === "codex-app-server") return "Codex App Server";
|
|
55345
56414
|
return normalized;
|
|
55346
56415
|
}
|
|
55347
56416
|
|
|
@@ -55350,6 +56419,9 @@ function formatTransportModeDisplay(value) {
|
|
|
55350
56419
|
function isBuiltinEnableChoiceCandidate(value) {
|
|
55351
56420
|
return value?.targetKind === "builtin";
|
|
55352
56421
|
}
|
|
56422
|
+
function hasAgentRegistration(value) {
|
|
56423
|
+
return value?.registration !== null && value?.registration !== void 0;
|
|
56424
|
+
}
|
|
55353
56425
|
const AGENTS_MENU_CHOICE = {
|
|
55354
56426
|
quickEnable: "quick_enable",
|
|
55355
56427
|
manage: "manage",
|
|
@@ -56531,7 +57603,7 @@ async function runAgentsList(input) {
|
|
|
56531
57603
|
command: "list"
|
|
56532
57604
|
});
|
|
56533
57605
|
const states = await listAgentTargetStates();
|
|
56534
|
-
const registrations = states.
|
|
57606
|
+
const registrations = states.filter(hasAgentRegistration).map((state) => buildAgentRegistrationAgentView(state)).sort((left, right) => left.agentId.localeCompare(right.agentId));
|
|
56535
57607
|
const payload = {
|
|
56536
57608
|
registrations,
|
|
56537
57609
|
count: registrations.length
|
|
@@ -56651,14 +57723,14 @@ async function runAgentsShow(input) {
|
|
|
56651
57723
|
const agentId = normalizeAgentId(input.agentId ?? "");
|
|
56652
57724
|
if (!agentId) throw new Error("agents.invalid_agent_id: provide a non-empty <agent-id> for show");
|
|
56653
57725
|
const state = await resolveAgentTargetState(agentId);
|
|
56654
|
-
|
|
56655
|
-
|
|
57726
|
+
if (!hasAgentRegistration(state)) throw new Error(`agents.not_registered: agent is not registered: ${agentId}`);
|
|
57727
|
+
const registration = state.registration;
|
|
56656
57728
|
const payload = {
|
|
56657
|
-
agent:
|
|
57729
|
+
agent: buildAgentRegistrationAgentView(state),
|
|
56658
57730
|
installChoices: state.installChoices,
|
|
56659
57731
|
launchStatus: formatAgentViewLaunchStatus(state.launchStatus),
|
|
56660
57732
|
launchStatusDetail: state.launchStatusDetail,
|
|
56661
|
-
effectiveConfig: buildEffectiveConfig(
|
|
57733
|
+
effectiveConfig: buildEffectiveConfig(state)
|
|
56662
57734
|
};
|
|
56663
57735
|
if (runtime.resolvedView === "agent") {
|
|
56664
57736
|
presenter.data({
|
|
@@ -56697,7 +57769,7 @@ async function runAgentsShow(input) {
|
|
|
56697
57769
|
},
|
|
56698
57770
|
{
|
|
56699
57771
|
label: "Connection Type",
|
|
56700
|
-
value: `${resolveTransportModeForDisplay(
|
|
57772
|
+
value: `${resolveTransportModeForDisplay(state)} ${pc.dim("on this computer")}`
|
|
56701
57773
|
},
|
|
56702
57774
|
...state.launchStatusDetail ? [{
|
|
56703
57775
|
label: "Why",
|
|
@@ -57134,11 +58206,14 @@ function applySingleEnableSelection(input) {
|
|
|
57134
58206
|
return;
|
|
57135
58207
|
}
|
|
57136
58208
|
if (existing.enabled && selectedLaunchContract) {
|
|
57137
|
-
input.next[existingIndex] = {
|
|
57138
|
-
|
|
57139
|
-
|
|
57140
|
-
|
|
57141
|
-
|
|
58209
|
+
input.next[existingIndex] = applyTargetRuntimeDefaults({
|
|
58210
|
+
registration: {
|
|
58211
|
+
...existing,
|
|
58212
|
+
launchContract: selectedLaunchContract,
|
|
58213
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
58214
|
+
},
|
|
58215
|
+
targetState
|
|
58216
|
+
});
|
|
57142
58217
|
input.summary.reenabled.push(targetState.agentId);
|
|
57143
58218
|
return;
|
|
57144
58219
|
}
|
|
@@ -57149,14 +58224,24 @@ function applySingleEnableSelection(input) {
|
|
|
57149
58224
|
});
|
|
57150
58225
|
return;
|
|
57151
58226
|
}
|
|
57152
|
-
input.next[existingIndex] = {
|
|
57153
|
-
|
|
57154
|
-
|
|
57155
|
-
|
|
57156
|
-
|
|
57157
|
-
|
|
58227
|
+
input.next[existingIndex] = applyTargetRuntimeDefaults({
|
|
58228
|
+
registration: {
|
|
58229
|
+
...existing,
|
|
58230
|
+
enabled: true,
|
|
58231
|
+
...resolvedLaunchContract ? { launchContract: resolvedLaunchContract } : {},
|
|
58232
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
58233
|
+
},
|
|
58234
|
+
targetState
|
|
58235
|
+
});
|
|
57158
58236
|
input.summary.reenabled.push(targetState.agentId);
|
|
57159
58237
|
}
|
|
58238
|
+
function applyTargetRuntimeDefaults(input) {
|
|
58239
|
+
return {
|
|
58240
|
+
...input.registration,
|
|
58241
|
+
...input.targetState.defaultStreamingMode ? { streamingMode: input.targetState.defaultStreamingMode } : {},
|
|
58242
|
+
...input.targetState.defaultTransportMode ? { transportMode: input.targetState.defaultTransportMode } : {}
|
|
58243
|
+
};
|
|
58244
|
+
}
|
|
57160
58245
|
function resolveRepairCandidate(input) {
|
|
57161
58246
|
const state = input.targetStateById.get(input.requestedId) ?? null;
|
|
57162
58247
|
if (!isBuiltinEnableChoiceCandidate(state)) {
|
|
@@ -57569,10 +58654,30 @@ async function runAgentsCustomRemove(input) {
|
|
|
57569
58654
|
text: formatInlineAtsCliCommands("Installs records are kept; cleanup via `ats skills uninstall`.")
|
|
57570
58655
|
});
|
|
57571
58656
|
}
|
|
57572
|
-
function
|
|
58657
|
+
function buildAgentRegistrationAgentView(state) {
|
|
58658
|
+
const transportProjection = resolveTransportModeProjection(state);
|
|
57573
58659
|
return {
|
|
57574
|
-
|
|
57575
|
-
|
|
58660
|
+
...state.registration,
|
|
58661
|
+
configuredTransportMode: transportProjection.configuredTransportMode,
|
|
58662
|
+
configuredTransportModeStatus: transportProjection.configuredTransportModeStatus,
|
|
58663
|
+
defaultTransportMode: transportProjection.defaultTransportMode,
|
|
58664
|
+
effectiveConfig: buildEffectiveConfig(state),
|
|
58665
|
+
effectiveTransportMode: transportProjection.effectiveTransportMode,
|
|
58666
|
+
supportedTransportModes: transportProjection.supportedTransportModes,
|
|
58667
|
+
transportModeSource: transportProjection.transportModeSource
|
|
58668
|
+
};
|
|
58669
|
+
}
|
|
58670
|
+
function buildEffectiveConfig(state) {
|
|
58671
|
+
const transportProjection = resolveTransportModeProjection(state);
|
|
58672
|
+
return {
|
|
58673
|
+
configuredTransportMode: transportProjection.configuredTransportMode,
|
|
58674
|
+
configuredTransportModeStatus: transportProjection.configuredTransportModeStatus,
|
|
58675
|
+
defaultTransportMode: transportProjection.defaultTransportMode,
|
|
58676
|
+
enabled: state.registration.enabled,
|
|
58677
|
+
effectiveTransportMode: transportProjection.effectiveTransportMode,
|
|
58678
|
+
supportedTransportModes: transportProjection.supportedTransportModes,
|
|
58679
|
+
transportMode: transportProjection.effectiveTransportMode,
|
|
58680
|
+
transportModeSource: transportProjection.transportModeSource
|
|
57576
58681
|
};
|
|
57577
58682
|
}
|
|
57578
58683
|
function emitAgentsOverviewIfAgent(input) {
|
|
@@ -57582,11 +58687,41 @@ function emitAgentsOverviewIfAgent(input) {
|
|
|
57582
58687
|
command: input.command
|
|
57583
58688
|
});
|
|
57584
58689
|
}
|
|
57585
|
-
function resolveTransportModeForDisplay(
|
|
57586
|
-
return formatTransportModeDisplay(
|
|
57587
|
-
}
|
|
57588
|
-
function
|
|
57589
|
-
|
|
58690
|
+
function resolveTransportModeForDisplay(state) {
|
|
58691
|
+
return formatTransportModeDisplay(resolveTransportModeProjection(state).effectiveTransportMode);
|
|
58692
|
+
}
|
|
58693
|
+
function resolveTransportModeProjection(state) {
|
|
58694
|
+
const supportedTransportModes = state.transportModes.map((transportMode) => transportMode.mode);
|
|
58695
|
+
const configuredTransportMode = state.registration.transportMode ?? null;
|
|
58696
|
+
let configuredTransportModeStatus;
|
|
58697
|
+
if (configuredTransportMode === null) configuredTransportModeStatus = "missing";
|
|
58698
|
+
else if (supportedTransportModes.length === 0 || supportedTransportModes.includes(configuredTransportMode)) configuredTransportModeStatus = "supported";
|
|
58699
|
+
else configuredTransportModeStatus = "unsupported";
|
|
58700
|
+
if (configuredTransportModeStatus === "supported" && configuredTransportMode) return {
|
|
58701
|
+
configuredTransportMode,
|
|
58702
|
+
configuredTransportModeStatus,
|
|
58703
|
+
defaultTransportMode: state.defaultTransportMode ?? null,
|
|
58704
|
+
effectiveTransportMode: configuredTransportMode,
|
|
58705
|
+
supportedTransportModes,
|
|
58706
|
+
transportModeSource: "registration"
|
|
58707
|
+
};
|
|
58708
|
+
const registryTransportMode = state.defaultTransportMode ?? supportedTransportModes[0] ?? null;
|
|
58709
|
+
if (registryTransportMode) return {
|
|
58710
|
+
configuredTransportMode,
|
|
58711
|
+
configuredTransportModeStatus,
|
|
58712
|
+
defaultTransportMode: state.defaultTransportMode ?? null,
|
|
58713
|
+
effectiveTransportMode: registryTransportMode,
|
|
58714
|
+
supportedTransportModes,
|
|
58715
|
+
transportModeSource: "registry_default"
|
|
58716
|
+
};
|
|
58717
|
+
return {
|
|
58718
|
+
configuredTransportMode,
|
|
58719
|
+
configuredTransportModeStatus,
|
|
58720
|
+
defaultTransportMode: null,
|
|
58721
|
+
effectiveTransportMode: DEFAULT_RUNTIME_AGENT_TRANSPORT_MODE,
|
|
58722
|
+
supportedTransportModes,
|
|
58723
|
+
transportModeSource: "global_default"
|
|
58724
|
+
};
|
|
57590
58725
|
}
|
|
57591
58726
|
function normalizeOptionalString$11(value) {
|
|
57592
58727
|
if (typeof value !== "string") return null;
|
|
@@ -59637,9 +60772,16 @@ async function bindAgentProfileToExplicitLocalAgent(input) {
|
|
|
59637
60772
|
});
|
|
59638
60773
|
await persistAgentTransportSelection({
|
|
59639
60774
|
agentControllerRef,
|
|
59640
|
-
transportMode:
|
|
60775
|
+
transportMode: resolveDefaultTransportModeForLocalAgent({
|
|
60776
|
+
agentControllerRef,
|
|
60777
|
+
localAgentId: input.localAgentId
|
|
60778
|
+
})
|
|
59641
60779
|
});
|
|
59642
60780
|
}
|
|
60781
|
+
function resolveDefaultTransportModeForLocalAgent(input) {
|
|
60782
|
+
const runtimeAdapterContract = resolveRegistryRuntimeAdapterContractByAgentControllerRef(input.agentControllerRef);
|
|
60783
|
+
return runtimeAdapterContract?.defaultTransportMode ?? runtimeAdapterContract?.transportModes[0] ?? createDefaultRuntimeAgentControllerSettings(input.localAgentId).transportMode;
|
|
60784
|
+
}
|
|
59643
60785
|
async function prepareLocalAgentLaunchIfNeeded(input) {
|
|
59644
60786
|
if (needsLocalAgentLaunchChoice(input.reasonCodes)) {
|
|
59645
60787
|
const enableResult = await runAgentsEnable({
|