agent-transport-system 0.7.35 → 0.7.37
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.js +308 -312
- package/dist/ats.js.map +1 -1
- package/package.json +1 -1
package/dist/ats.js
CHANGED
|
@@ -27,7 +27,7 @@ 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.37";
|
|
31
31
|
var package_default = {
|
|
32
32
|
$schema: "https://www.schemastore.org/package.json",
|
|
33
33
|
name: "agent-transport-system",
|
|
@@ -2115,8 +2115,8 @@ function buildDaemonControlTargetExamples(input) {
|
|
|
2115
2115
|
})];
|
|
2116
2116
|
}
|
|
2117
2117
|
function validateDaemonControlTargetInput(input) {
|
|
2118
|
-
const dispatch = normalizeOptionalText$
|
|
2119
|
-
const task = normalizeOptionalText$
|
|
2118
|
+
const dispatch = normalizeOptionalText$53(input.dispatch);
|
|
2119
|
+
const task = normalizeOptionalText$53(input.task);
|
|
2120
2120
|
if (dispatch && task || !(dispatch || task)) throw createCommandContractError("daemon.control.invalid_target_selector", DAEMON_CONTROL_TARGET_ERROR);
|
|
2121
2121
|
return {
|
|
2122
2122
|
dispatch,
|
|
@@ -2135,7 +2135,7 @@ function buildDaemonControlTargetCommand(input) {
|
|
|
2135
2135
|
if (input.includeViewFlag) tokens.push("--view", "agent");
|
|
2136
2136
|
return tokens.join(" ");
|
|
2137
2137
|
}
|
|
2138
|
-
function normalizeOptionalText$
|
|
2138
|
+
function normalizeOptionalText$53(value) {
|
|
2139
2139
|
const normalized = String(value ?? "").trim();
|
|
2140
2140
|
return normalized.length > 0 ? normalized : null;
|
|
2141
2141
|
}
|
|
@@ -4215,7 +4215,7 @@ const WINDOWS_PATHEXT = [
|
|
|
4215
4215
|
const SHEBANG_ARGS_SPLIT_RE = /\s+/;
|
|
4216
4216
|
const FIRST_LINE_SPLIT_RE = /\r?\n/u;
|
|
4217
4217
|
const NODE_VERSION_PATH_RE = /(?:^|\/)v?(\d+\.\d+\.\d+)(?:\/|$)/u;
|
|
4218
|
-
const HOME_DIR = normalizeOptionalText$
|
|
4218
|
+
const HOME_DIR = normalizeOptionalText$52(homedir());
|
|
4219
4219
|
function buildExecutableLaunchContract(input) {
|
|
4220
4220
|
return {
|
|
4221
4221
|
kind: "executable",
|
|
@@ -4356,7 +4356,7 @@ function resolveInstalledCommandPath(input) {
|
|
|
4356
4356
|
return resolveInstalledCommandPaths(input)[0] ?? null;
|
|
4357
4357
|
}
|
|
4358
4358
|
function resolveInstalledCommandPaths(input) {
|
|
4359
|
-
const configuredCommand = normalizeOptionalText$
|
|
4359
|
+
const configuredCommand = normalizeOptionalText$52(input.configuredCommand);
|
|
4360
4360
|
if (configuredCommand) {
|
|
4361
4361
|
if (isAbsolute(configuredCommand)) return [configuredCommand];
|
|
4362
4362
|
if (configuredCommand.includes("/") || configuredCommand.includes("\\")) return [];
|
|
@@ -4365,9 +4365,9 @@ function resolveInstalledCommandPaths(input) {
|
|
|
4365
4365
|
return resolveExecutablePathsOnPath(input.commandName);
|
|
4366
4366
|
}
|
|
4367
4367
|
function resolveExecutablePathsOnPath(commandName) {
|
|
4368
|
-
const normalizedCommandName = normalizeOptionalText$
|
|
4368
|
+
const normalizedCommandName = normalizeOptionalText$52(commandName);
|
|
4369
4369
|
if (!normalizedCommandName) return [];
|
|
4370
|
-
const pathValue = normalizeOptionalText$
|
|
4370
|
+
const pathValue = normalizeOptionalText$52(process.env.PATH);
|
|
4371
4371
|
if (!pathValue) return [];
|
|
4372
4372
|
const resolvedPaths = [];
|
|
4373
4373
|
for (const pathEntry of pathValue.split(delimiter)) {
|
|
@@ -4381,7 +4381,7 @@ function resolveExecutablePathsOnPath(commandName) {
|
|
|
4381
4381
|
return resolvedPaths;
|
|
4382
4382
|
}
|
|
4383
4383
|
function resolveSiblingCommandPath(input) {
|
|
4384
|
-
const normalizedCommandName = normalizeOptionalText$
|
|
4384
|
+
const normalizedCommandName = normalizeOptionalText$52(input.commandName);
|
|
4385
4385
|
if (!normalizedCommandName) return null;
|
|
4386
4386
|
const siblingDirectory = dirname(input.anchorPath);
|
|
4387
4387
|
for (const candidateName of resolveCommandFileNameCandidates(normalizedCommandName)) {
|
|
@@ -4391,7 +4391,7 @@ function resolveSiblingCommandPath(input) {
|
|
|
4391
4391
|
return null;
|
|
4392
4392
|
}
|
|
4393
4393
|
async function resolvePinnedNodePath(input) {
|
|
4394
|
-
const firstLine = normalizeOptionalText$
|
|
4394
|
+
const firstLine = normalizeOptionalText$52(input.firstLine);
|
|
4395
4395
|
if (!firstLine) return null;
|
|
4396
4396
|
if (firstLine === ENV_NODE_SHEBANG) {
|
|
4397
4397
|
const nodeSibling = join(dirname(input.commandPath), "node");
|
|
@@ -4403,7 +4403,7 @@ async function resolvePinnedNodePath(input) {
|
|
|
4403
4403
|
}
|
|
4404
4404
|
}
|
|
4405
4405
|
if (!firstLine.startsWith("#!")) return null;
|
|
4406
|
-
const interpreter = normalizeOptionalText$
|
|
4406
|
+
const interpreter = normalizeOptionalText$52(firstLine.slice(2));
|
|
4407
4407
|
if (!(interpreter && isAbsolute(interpreter))) return null;
|
|
4408
4408
|
const normalizedInterpreter = interpreter.split(SHEBANG_ARGS_SPLIT_RE, 1)[0] ?? interpreter;
|
|
4409
4409
|
try {
|
|
@@ -4414,7 +4414,7 @@ async function resolvePinnedNodePath(input) {
|
|
|
4414
4414
|
}
|
|
4415
4415
|
}
|
|
4416
4416
|
async function readFirstLine(path) {
|
|
4417
|
-
return normalizeOptionalText$
|
|
4417
|
+
return normalizeOptionalText$52((await readFile(path, "utf8")).split(FIRST_LINE_SPLIT_RE, 1)[0] ?? "");
|
|
4418
4418
|
}
|
|
4419
4419
|
async function assertExecutablePath(path) {
|
|
4420
4420
|
await access(path, resolveRunnablePathAccessMode());
|
|
@@ -4446,11 +4446,11 @@ function resolveRunnablePathAccessMode() {
|
|
|
4446
4446
|
return process.platform === "win32" ? constants.F_OK : constants.X_OK;
|
|
4447
4447
|
}
|
|
4448
4448
|
function resolveWindowsPathExtensions(value) {
|
|
4449
|
-
const normalized = normalizeOptionalText$
|
|
4449
|
+
const normalized = normalizeOptionalText$52(value);
|
|
4450
4450
|
if (!normalized) return [...WINDOWS_PATHEXT];
|
|
4451
4451
|
return normalized.split(";").map((entry) => entry.trim().toLowerCase()).filter((entry, index, values) => entry && values.indexOf(entry) === index).map((entry) => entry.startsWith(".") ? entry : `.${entry}`);
|
|
4452
4452
|
}
|
|
4453
|
-
function normalizeOptionalText$
|
|
4453
|
+
function normalizeOptionalText$52(value) {
|
|
4454
4454
|
const normalized = String(value ?? "").trim();
|
|
4455
4455
|
return normalized.length > 0 ? normalized : null;
|
|
4456
4456
|
}
|
|
@@ -4542,7 +4542,7 @@ function shortenPathForDisplay(path) {
|
|
|
4542
4542
|
return `~${path.slice(HOME_DIR.length)}`;
|
|
4543
4543
|
}
|
|
4544
4544
|
function resolveNodeVersionFromPath(path) {
|
|
4545
|
-
return normalizeOptionalText$
|
|
4545
|
+
return normalizeOptionalText$52(path.match(NODE_VERSION_PATH_RE)?.[1]);
|
|
4546
4546
|
}
|
|
4547
4547
|
function toErrorMessage$35(error) {
|
|
4548
4548
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -4569,9 +4569,9 @@ const buildProviderExitError = (input) => {
|
|
|
4569
4569
|
};
|
|
4570
4570
|
};
|
|
4571
4571
|
const hasVisibleText = (value) => {
|
|
4572
|
-
return normalizeOptionalText$
|
|
4572
|
+
return normalizeOptionalText$51(value) !== null;
|
|
4573
4573
|
};
|
|
4574
|
-
const normalizeOptionalText$
|
|
4574
|
+
const normalizeOptionalText$51 = (value) => {
|
|
4575
4575
|
if (typeof value !== "string") return null;
|
|
4576
4576
|
const normalized = value.trim();
|
|
4577
4577
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -4876,13 +4876,13 @@ const buildDefaultInvokeRequest = (input) => {
|
|
|
4876
4876
|
agentControllerConversationId: input.request.agentControllerConversationId,
|
|
4877
4877
|
bridgeSpec: input.bridgeSpec,
|
|
4878
4878
|
agentControllerConversation: input.request.agentControllerConversation
|
|
4879
|
-
}) : normalizeOptionalText$
|
|
4879
|
+
}) : normalizeOptionalText$50(input.request.agentControllerConversationId);
|
|
4880
4880
|
return {
|
|
4881
4881
|
...input.request,
|
|
4882
4882
|
agentControllerConversationId
|
|
4883
4883
|
};
|
|
4884
4884
|
};
|
|
4885
|
-
const normalizeOptionalText$
|
|
4885
|
+
const normalizeOptionalText$50 = (value) => {
|
|
4886
4886
|
if (typeof value !== "string") return null;
|
|
4887
4887
|
const normalized = value.trim();
|
|
4888
4888
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -4924,7 +4924,7 @@ const DEFAULT_CLAUDE_CODE_COMMAND = "claude";
|
|
|
4924
4924
|
async function resolveInstalledClaudeCodeLaunchCandidates() {
|
|
4925
4925
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
4926
4926
|
commandName: DEFAULT_CLAUDE_CODE_COMMAND,
|
|
4927
|
-
configuredCommand: normalizeOptionalText$
|
|
4927
|
+
configuredCommand: normalizeOptionalText$49(process.env.ATSD_RUNTIME_CLAUDE_CODE_BIN),
|
|
4928
4928
|
displayName: "Claude Code"
|
|
4929
4929
|
});
|
|
4930
4930
|
if (!installedCandidates.ok) return installedCandidates;
|
|
@@ -4952,13 +4952,13 @@ async function verifyClaudeCodeLaunchContract(input) {
|
|
|
4952
4952
|
});
|
|
4953
4953
|
}
|
|
4954
4954
|
function resolveClaudeCodeTimeoutMs() {
|
|
4955
|
-
const raw = normalizeOptionalText$
|
|
4955
|
+
const raw = normalizeOptionalText$49(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
4956
4956
|
if (!raw) return null;
|
|
4957
4957
|
const parsed = Number.parseInt(raw, 10);
|
|
4958
4958
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
4959
4959
|
return parsed;
|
|
4960
4960
|
}
|
|
4961
|
-
function normalizeOptionalText$
|
|
4961
|
+
function normalizeOptionalText$49(value) {
|
|
4962
4962
|
const normalized = String(value ?? "").trim();
|
|
4963
4963
|
return normalized.length > 0 ? normalized : null;
|
|
4964
4964
|
}
|
|
@@ -4989,8 +4989,8 @@ function parseClaudeOutputLine(line) {
|
|
|
4989
4989
|
}
|
|
4990
4990
|
const record = toObjectRecord(parsed);
|
|
4991
4991
|
if (!record) return null;
|
|
4992
|
-
const sessionId = normalizeOptionalText$
|
|
4993
|
-
const resultText = normalizeOptionalText$
|
|
4992
|
+
const sessionId = normalizeOptionalText$48(record.session_id);
|
|
4993
|
+
const resultText = normalizeOptionalText$48(record.result);
|
|
4994
4994
|
const isErrorResult = typeof record.is_error === "boolean" ? record.is_error : null;
|
|
4995
4995
|
if (record.type === "result") return {
|
|
4996
4996
|
errorMessage: isErrorResult ? resultText : null,
|
|
@@ -5001,7 +5001,7 @@ function parseClaudeOutputLine(line) {
|
|
|
5001
5001
|
terminal: true
|
|
5002
5002
|
};
|
|
5003
5003
|
if (record.type === "error") return {
|
|
5004
|
-
errorMessage: normalizeOptionalText$
|
|
5004
|
+
errorMessage: normalizeOptionalText$48(record.message),
|
|
5005
5005
|
isErrorResult: true,
|
|
5006
5006
|
previewDeltaText: null,
|
|
5007
5007
|
resultText: null,
|
|
@@ -5017,7 +5017,7 @@ function parseClaudeOutputLine(line) {
|
|
|
5017
5017
|
function parseClaudeStreamEvent(record, sessionId) {
|
|
5018
5018
|
const event = toObjectRecord(record.event);
|
|
5019
5019
|
if (!event) return null;
|
|
5020
|
-
const eventType = normalizeOptionalText$
|
|
5020
|
+
const eventType = normalizeOptionalText$48(event.type);
|
|
5021
5021
|
if (eventType === "message_start") return {
|
|
5022
5022
|
errorMessage: null,
|
|
5023
5023
|
isErrorResult: null,
|
|
@@ -5044,7 +5044,7 @@ function toObjectRecord(value) {
|
|
|
5044
5044
|
function normalizeText$8(value) {
|
|
5045
5045
|
return String(value ?? "").trim();
|
|
5046
5046
|
}
|
|
5047
|
-
function normalizeOptionalText$
|
|
5047
|
+
function normalizeOptionalText$48(value) {
|
|
5048
5048
|
const normalized = normalizeText$8(value);
|
|
5049
5049
|
return normalized.length > 0 ? normalized : null;
|
|
5050
5050
|
}
|
|
@@ -5069,7 +5069,7 @@ var ClaudeCliTransportError = class extends Error {
|
|
|
5069
5069
|
}
|
|
5070
5070
|
};
|
|
5071
5071
|
async function invokeClaudeCliTransport(input) {
|
|
5072
|
-
const prompt = normalizeOptionalText$
|
|
5072
|
+
const prompt = normalizeOptionalText$47(input.prompt);
|
|
5073
5073
|
if (!prompt) throw new ClaudeCliTransportError({
|
|
5074
5074
|
code: "schema.invalid",
|
|
5075
5075
|
errorType: "config",
|
|
@@ -5079,7 +5079,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5079
5079
|
args: buildClaudeArgs({
|
|
5080
5080
|
executionMode: input.executionMode,
|
|
5081
5081
|
prompt,
|
|
5082
|
-
sessionId: normalizeOptionalText$
|
|
5082
|
+
sessionId: normalizeOptionalText$47(input.sessionId),
|
|
5083
5083
|
streamingMode: input.streamingMode
|
|
5084
5084
|
}),
|
|
5085
5085
|
launchContract: input.launchContract
|
|
@@ -5087,7 +5087,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5087
5087
|
const invokedAtMs = Date.now();
|
|
5088
5088
|
let latestOutput = "";
|
|
5089
5089
|
let latestResultIsError = false;
|
|
5090
|
-
let resolvedSessionId = normalizeOptionalText$
|
|
5090
|
+
let resolvedSessionId = normalizeOptionalText$47(input.sessionId);
|
|
5091
5091
|
const providerErrorMessages = [];
|
|
5092
5092
|
let firstStdoutAtMs = null;
|
|
5093
5093
|
let firstOutputAtMs = null;
|
|
@@ -5148,7 +5148,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5148
5148
|
...classifiedFailure.providerAccessEvidence ? { providerAccessEvidence: classifiedFailure.providerAccessEvidence } : {}
|
|
5149
5149
|
});
|
|
5150
5150
|
}
|
|
5151
|
-
const output = normalizeOptionalText$
|
|
5151
|
+
const output = normalizeOptionalText$47(latestOutput);
|
|
5152
5152
|
if (!output) throw new ClaudeCliTransportError({
|
|
5153
5153
|
code: "runtime.output.empty",
|
|
5154
5154
|
errorType: "adapter",
|
|
@@ -5156,7 +5156,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5156
5156
|
});
|
|
5157
5157
|
return {
|
|
5158
5158
|
output,
|
|
5159
|
-
sessionId: normalizeOptionalText$
|
|
5159
|
+
sessionId: normalizeOptionalText$47(resolvedSessionId),
|
|
5160
5160
|
telemetry: {
|
|
5161
5161
|
completedAtMs: Date.now(),
|
|
5162
5162
|
...driverResult.lifecycle.exitCode === null ? {} : { exitCode: driverResult.lifecycle.exitCode },
|
|
@@ -5169,7 +5169,7 @@ async function invokeClaudeCliTransport(input) {
|
|
|
5169
5169
|
previewEmitted: previewEmitter.emitted,
|
|
5170
5170
|
...driverResult.lifecycle.processId === null ? {} : { processId: driverResult.lifecycle.processId },
|
|
5171
5171
|
...driverResult.lifecycle.processSpawnedAtMs === null ? {} : { processSpawnedAtMs: driverResult.lifecycle.processSpawnedAtMs },
|
|
5172
|
-
resumedContext: normalizeOptionalText$
|
|
5172
|
+
resumedContext: normalizeOptionalText$47(input.sessionId) !== null,
|
|
5173
5173
|
...driverResult.lifecycle.stdinClosedAtMs === null ? {} : { stdinClosedAtMs: driverResult.lifecycle.stdinClosedAtMs },
|
|
5174
5174
|
streamingMode: input.streamingMode ?? "final",
|
|
5175
5175
|
...driverResult.lifecycle.timeoutTriggeredAtMs === null ? {} : { timeoutTriggeredAtMs: driverResult.lifecycle.timeoutTriggeredAtMs }
|
|
@@ -5337,7 +5337,7 @@ const classifyClaudeFailure = (input) => {
|
|
|
5337
5337
|
message: providerMessage
|
|
5338
5338
|
};
|
|
5339
5339
|
}
|
|
5340
|
-
const stderrText = normalizeOptionalText$
|
|
5340
|
+
const stderrText = normalizeOptionalText$47(input.stderrText);
|
|
5341
5341
|
if (stderrText) return {
|
|
5342
5342
|
code: "upstream_unreachable",
|
|
5343
5343
|
errorType: "adapter",
|
|
@@ -5349,13 +5349,13 @@ const resolveProviderFailureMessage$2 = (input) => {
|
|
|
5349
5349
|
const candidateMessages = [
|
|
5350
5350
|
...input.providerErrorMessages,
|
|
5351
5351
|
...extractErrorMessagesFromStdout$1(input.stdoutText),
|
|
5352
|
-
...normalizeOptionalText$
|
|
5352
|
+
...normalizeOptionalText$47(input.stderrText) ? [normalizeOptionalText$47(input.stderrText)] : []
|
|
5353
5353
|
].filter((value) => Boolean(value));
|
|
5354
5354
|
for (const candidate of candidateMessages) if (looksLikeProviderFailure$2(candidate)) return candidate;
|
|
5355
5355
|
return candidateMessages[0] ?? null;
|
|
5356
5356
|
};
|
|
5357
5357
|
const extractErrorMessagesFromStdout$1 = (value) => {
|
|
5358
|
-
const stdoutText = normalizeOptionalText$
|
|
5358
|
+
const stdoutText = normalizeOptionalText$47(value);
|
|
5359
5359
|
if (!stdoutText) return [];
|
|
5360
5360
|
const messages = [];
|
|
5361
5361
|
const lines = stdoutText.split("\n");
|
|
@@ -5366,7 +5366,7 @@ const extractErrorMessagesFromStdout$1 = (value) => {
|
|
|
5366
5366
|
return messages;
|
|
5367
5367
|
};
|
|
5368
5368
|
const collectProviderErrorMessage$1 = (line, messages) => {
|
|
5369
|
-
const normalizedLine = normalizeOptionalText$
|
|
5369
|
+
const normalizedLine = normalizeOptionalText$47(line);
|
|
5370
5370
|
if (!normalizedLine) return;
|
|
5371
5371
|
messages.push(normalizedLine);
|
|
5372
5372
|
};
|
|
@@ -5407,7 +5407,7 @@ const isRateLimitFailure$2 = (value) => {
|
|
|
5407
5407
|
function normalizeText$7(value) {
|
|
5408
5408
|
return String(value ?? "").trim();
|
|
5409
5409
|
}
|
|
5410
|
-
function normalizeOptionalText$
|
|
5410
|
+
function normalizeOptionalText$47(value) {
|
|
5411
5411
|
const normalized = normalizeText$7(value);
|
|
5412
5412
|
return normalized.length > 0 ? normalized : null;
|
|
5413
5413
|
}
|
|
@@ -5558,7 +5558,7 @@ const resolveDefaultClaudeCodeInvoke = (options) => {
|
|
|
5558
5558
|
...onProcessControlEvent ? { onProcessControlEvent } : {},
|
|
5559
5559
|
...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
|
|
5560
5560
|
prompt: input.prompt,
|
|
5561
|
-
sessionId: normalizeOptionalText$
|
|
5561
|
+
sessionId: normalizeOptionalText$46(input.agentControllerConversationId),
|
|
5562
5562
|
...input.onPreview ? { onPreview: input.onPreview } : {},
|
|
5563
5563
|
streamingMode: input.streamingMode
|
|
5564
5564
|
});
|
|
@@ -5578,7 +5578,7 @@ const resolveDefaultClaudeCodeInvoke = (options) => {
|
|
|
5578
5578
|
};
|
|
5579
5579
|
};
|
|
5580
5580
|
async function resolveClaudeDispatchLaunchContract(input) {
|
|
5581
|
-
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$
|
|
5581
|
+
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$46(input.claudeBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$46(input.claudeBin) }) : null);
|
|
5582
5582
|
if (explicitLaunchContract) {
|
|
5583
5583
|
const verification = await verifyClaudeCodeLaunchContract({ launchContract: explicitLaunchContract });
|
|
5584
5584
|
if (verification.ok) return explicitLaunchContract;
|
|
@@ -5592,7 +5592,7 @@ async function resolveClaudeDispatchLaunchContract(input) {
|
|
|
5592
5592
|
errorType: "config"
|
|
5593
5593
|
});
|
|
5594
5594
|
}
|
|
5595
|
-
const normalizeOptionalText$
|
|
5595
|
+
const normalizeOptionalText$46 = (value) => {
|
|
5596
5596
|
const normalized = String(value ?? "").trim();
|
|
5597
5597
|
return normalized.length > 0 ? normalized : null;
|
|
5598
5598
|
};
|
|
@@ -5620,7 +5620,7 @@ const DEFAULT_CODEX_COMMAND = "codex";
|
|
|
5620
5620
|
async function resolveInstalledCodexLaunchCandidates() {
|
|
5621
5621
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
5622
5622
|
commandName: DEFAULT_CODEX_COMMAND,
|
|
5623
|
-
configuredCommand: normalizeOptionalText$
|
|
5623
|
+
configuredCommand: normalizeOptionalText$45(process.env.ATSD_RUNTIME_CODEX_BIN),
|
|
5624
5624
|
displayName: "Codex"
|
|
5625
5625
|
});
|
|
5626
5626
|
if (!installedCandidates.ok) return installedCandidates;
|
|
@@ -5648,13 +5648,13 @@ async function verifyCodexLaunchContract(input) {
|
|
|
5648
5648
|
});
|
|
5649
5649
|
}
|
|
5650
5650
|
function resolveCodexTimeoutMs() {
|
|
5651
|
-
const raw = normalizeOptionalText$
|
|
5651
|
+
const raw = normalizeOptionalText$45(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
5652
5652
|
if (!raw) return null;
|
|
5653
5653
|
const parsed = Number.parseInt(raw, 10);
|
|
5654
5654
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
5655
5655
|
return parsed;
|
|
5656
5656
|
}
|
|
5657
|
-
function normalizeOptionalText$
|
|
5657
|
+
function normalizeOptionalText$45(value) {
|
|
5658
5658
|
const normalized = String(value ?? "").trim();
|
|
5659
5659
|
return normalized.length > 0 ? normalized : null;
|
|
5660
5660
|
}
|
|
@@ -5717,9 +5717,9 @@ function extractOutputFromCodexLine(line) {
|
|
|
5717
5717
|
const item = record.item && typeof record.item === "object" && !Array.isArray(record.item) ? record.item : null;
|
|
5718
5718
|
const response = record.response && typeof record.response === "object" && !Array.isArray(record.response) ? record.response : null;
|
|
5719
5719
|
if (record.type === "item.completed" && item?.type === "agent_message") {
|
|
5720
|
-
const phase = normalizeOptionalText$
|
|
5720
|
+
const phase = normalizeOptionalText$44(item.phase ?? record.phase);
|
|
5721
5721
|
if (phase && phase !== "final_answer") return null;
|
|
5722
|
-
const text = normalizeOptionalText$
|
|
5722
|
+
const text = normalizeOptionalText$44(item.text);
|
|
5723
5723
|
return text ? {
|
|
5724
5724
|
previewable: false,
|
|
5725
5725
|
terminal: true,
|
|
@@ -5727,7 +5727,7 @@ function extractOutputFromCodexLine(line) {
|
|
|
5727
5727
|
} : null;
|
|
5728
5728
|
}
|
|
5729
5729
|
if (record.type === "response.completed") {
|
|
5730
|
-
const text = normalizeOptionalText$
|
|
5730
|
+
const text = normalizeOptionalText$44(response?.output_text);
|
|
5731
5731
|
return text ? {
|
|
5732
5732
|
previewable: false,
|
|
5733
5733
|
terminal: true,
|
|
@@ -5757,12 +5757,12 @@ function extractThreadIdFromCodexLine(line) {
|
|
|
5757
5757
|
const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
5758
5758
|
if (!record) return null;
|
|
5759
5759
|
if (record.type !== "thread.started") return null;
|
|
5760
|
-
return normalizeOptionalText$
|
|
5760
|
+
return normalizeOptionalText$44(record.thread_id);
|
|
5761
5761
|
}
|
|
5762
5762
|
function normalizeText$6(value) {
|
|
5763
5763
|
return String(value ?? "").trim();
|
|
5764
5764
|
}
|
|
5765
|
-
function normalizeOptionalText$
|
|
5765
|
+
function normalizeOptionalText$44(value) {
|
|
5766
5766
|
const normalized = normalizeText$6(value);
|
|
5767
5767
|
return normalized.length > 0 ? normalized : null;
|
|
5768
5768
|
}
|
|
@@ -5780,7 +5780,7 @@ var CodexCliTransportError = class extends Error {
|
|
|
5780
5780
|
}
|
|
5781
5781
|
};
|
|
5782
5782
|
async function invokeCodexCliTransport(input) {
|
|
5783
|
-
const prompt = normalizeOptionalText$
|
|
5783
|
+
const prompt = normalizeOptionalText$43(input.prompt);
|
|
5784
5784
|
if (!prompt) throw new CodexCliTransportError({
|
|
5785
5785
|
code: "schema.invalid",
|
|
5786
5786
|
errorType: "config",
|
|
@@ -5865,7 +5865,7 @@ async function invokeCodexCliTransport(input) {
|
|
|
5865
5865
|
message: classifiedFailure.message
|
|
5866
5866
|
});
|
|
5867
5867
|
}
|
|
5868
|
-
const output = normalizeOptionalText$
|
|
5868
|
+
const output = normalizeOptionalText$43(latestOutput);
|
|
5869
5869
|
if (!output) {
|
|
5870
5870
|
if (providerErrorMessages.length > 0) {
|
|
5871
5871
|
const classifiedFailure = classifyCodexFailure({
|
|
@@ -5899,12 +5899,12 @@ async function invokeCodexCliTransport(input) {
|
|
|
5899
5899
|
previewEmitted: previewEmitter.emitted,
|
|
5900
5900
|
...driverResult.lifecycle.processId === null ? {} : { processId: driverResult.lifecycle.processId },
|
|
5901
5901
|
...driverResult.lifecycle.processSpawnedAtMs === null ? {} : { processSpawnedAtMs: driverResult.lifecycle.processSpawnedAtMs },
|
|
5902
|
-
resumedContext: normalizeOptionalText$
|
|
5902
|
+
resumedContext: normalizeOptionalText$43(input.threadId) !== null,
|
|
5903
5903
|
...driverResult.lifecycle.stdinClosedAtMs === null ? {} : { stdinClosedAtMs: driverResult.lifecycle.stdinClosedAtMs },
|
|
5904
5904
|
streamingMode: input.streamingMode ?? "final",
|
|
5905
5905
|
...driverResult.lifecycle.timeoutTriggeredAtMs === null ? {} : { timeoutTriggeredAtMs: driverResult.lifecycle.timeoutTriggeredAtMs }
|
|
5906
5906
|
},
|
|
5907
|
-
threadId: normalizeOptionalText$
|
|
5907
|
+
threadId: normalizeOptionalText$43(resolvedThreadId)
|
|
5908
5908
|
};
|
|
5909
5909
|
}
|
|
5910
5910
|
function buildCodexExecArgs(input) {
|
|
@@ -6005,7 +6005,7 @@ const toCodexCliTransportError = (error, timeoutMs) => {
|
|
|
6005
6005
|
});
|
|
6006
6006
|
};
|
|
6007
6007
|
const collectCodexErrorMessage = (line, messages) => {
|
|
6008
|
-
const normalizedLine = normalizeOptionalText$
|
|
6008
|
+
const normalizedLine = normalizeOptionalText$43(line);
|
|
6009
6009
|
if (!normalizedLine) return;
|
|
6010
6010
|
const jsonMessage = readCodexJsonErrorMessage(normalizedLine);
|
|
6011
6011
|
if (jsonMessage) messages.push(jsonMessage);
|
|
@@ -6019,9 +6019,9 @@ const readCodexJsonErrorMessage = (line) => {
|
|
|
6019
6019
|
}
|
|
6020
6020
|
const record = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
6021
6021
|
if (!record) return null;
|
|
6022
|
-
const message = normalizeOptionalText$
|
|
6022
|
+
const message = normalizeOptionalText$43(record.message);
|
|
6023
6023
|
if (record.type === "error" && message) return message;
|
|
6024
|
-
const errorMessage = normalizeOptionalText$
|
|
6024
|
+
const errorMessage = normalizeOptionalText$43((record.error && typeof record.error === "object" && !Array.isArray(record.error) ? record.error : null)?.message);
|
|
6025
6025
|
if (record.type === "turn.failed" && errorMessage) return errorMessage;
|
|
6026
6026
|
return null;
|
|
6027
6027
|
};
|
|
@@ -6055,7 +6055,7 @@ const classifyCodexFailure = (input) => {
|
|
|
6055
6055
|
message: toConfigInvalidMessage(providerMessage)
|
|
6056
6056
|
};
|
|
6057
6057
|
}
|
|
6058
|
-
const stderrText = normalizeOptionalText$
|
|
6058
|
+
const stderrText = normalizeOptionalText$43(input.stderrText);
|
|
6059
6059
|
if (stderrText) return {
|
|
6060
6060
|
code: "upstream_unreachable",
|
|
6061
6061
|
errorType: "adapter",
|
|
@@ -6066,8 +6066,8 @@ const classifyCodexFailure = (input) => {
|
|
|
6066
6066
|
const resolveProviderFailureMessage$1 = (input) => {
|
|
6067
6067
|
const candidateMessages = [
|
|
6068
6068
|
...input.providerErrorMessages,
|
|
6069
|
-
...normalizeOptionalText$
|
|
6070
|
-
...normalizeOptionalText$
|
|
6069
|
+
...normalizeOptionalText$43(input.stderrText) ? [normalizeOptionalText$43(input.stderrText)] : [],
|
|
6070
|
+
...normalizeOptionalText$43(input.stdoutText) ? [normalizeOptionalText$43(input.stdoutText)] : []
|
|
6071
6071
|
].filter((value) => Boolean(value));
|
|
6072
6072
|
for (const candidate of candidateMessages) if (looksLikeProviderFailure$1(candidate)) return candidate;
|
|
6073
6073
|
return candidateMessages[0] ?? null;
|
|
@@ -6100,7 +6100,7 @@ const toControllerClientUpgradeRequiredMessage = (value) => {
|
|
|
6100
6100
|
function normalizeText$5(value) {
|
|
6101
6101
|
return String(value ?? "").trim();
|
|
6102
6102
|
}
|
|
6103
|
-
function normalizeOptionalText$
|
|
6103
|
+
function normalizeOptionalText$43(value) {
|
|
6104
6104
|
const normalized = normalizeText$5(value);
|
|
6105
6105
|
return normalized.length > 0 ? normalized : null;
|
|
6106
6106
|
}
|
|
@@ -6236,7 +6236,7 @@ const resolveDefaultCodexInvoke = (options) => {
|
|
|
6236
6236
|
...input.onRuntimeEvent ? { onRuntimeEvent: input.onRuntimeEvent } : {},
|
|
6237
6237
|
prompt: input.prompt,
|
|
6238
6238
|
streamingMode: input.streamingMode,
|
|
6239
|
-
threadId: normalizeOptionalText$
|
|
6239
|
+
threadId: normalizeOptionalText$42(input.agentControllerConversationId)
|
|
6240
6240
|
});
|
|
6241
6241
|
const agentControllerConversation = CODEX_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
|
|
6242
6242
|
bridgeSpec: CODEX_CONVERSATION_BRIDGE_SPEC,
|
|
@@ -6254,7 +6254,7 @@ const resolveDefaultCodexInvoke = (options) => {
|
|
|
6254
6254
|
};
|
|
6255
6255
|
};
|
|
6256
6256
|
async function resolveCodexDispatchLaunchContract(input) {
|
|
6257
|
-
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$
|
|
6257
|
+
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$42(input.codexBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$42(input.codexBin) }) : null);
|
|
6258
6258
|
if (explicitLaunchContract) {
|
|
6259
6259
|
const verification = await verifyCodexLaunchContract({ launchContract: explicitLaunchContract });
|
|
6260
6260
|
if (verification.ok) return explicitLaunchContract;
|
|
@@ -6268,7 +6268,7 @@ async function resolveCodexDispatchLaunchContract(input) {
|
|
|
6268
6268
|
errorType: "config"
|
|
6269
6269
|
});
|
|
6270
6270
|
}
|
|
6271
|
-
const normalizeOptionalText$
|
|
6271
|
+
const normalizeOptionalText$42 = (value) => {
|
|
6272
6272
|
const normalized = String(value ?? "").trim();
|
|
6273
6273
|
return normalized.length > 0 ? normalized : null;
|
|
6274
6274
|
};
|
|
@@ -6297,7 +6297,7 @@ const DEFAULT_OPENCLAW_AGENT_ID = "main";
|
|
|
6297
6297
|
async function resolveInstalledOpenClawLaunchCandidates() {
|
|
6298
6298
|
const installedCandidates = await resolveInstalledNodeScriptLaunchCandidates({
|
|
6299
6299
|
commandName: DEFAULT_OPENCLAW_COMMAND,
|
|
6300
|
-
configuredCommand: normalizeOptionalText$
|
|
6300
|
+
configuredCommand: normalizeOptionalText$41(process.env.ATSD_RUNTIME_OPENCLAW_BIN),
|
|
6301
6301
|
displayName: "OpenClaw"
|
|
6302
6302
|
});
|
|
6303
6303
|
if (!installedCandidates.ok) return installedCandidates;
|
|
@@ -6326,9 +6326,9 @@ async function verifyOpenClawLaunchContract(input) {
|
|
|
6326
6326
|
}
|
|
6327
6327
|
function resolveOpenClawBinCandidates(explicitOpenClawBin) {
|
|
6328
6328
|
const candidates = [];
|
|
6329
|
-
const explicitCandidate = normalizeOptionalText$
|
|
6329
|
+
const explicitCandidate = normalizeOptionalText$41(explicitOpenClawBin);
|
|
6330
6330
|
if (explicitCandidate) candidates.push(explicitCandidate);
|
|
6331
|
-
const configuredCandidate = normalizeOptionalText$
|
|
6331
|
+
const configuredCandidate = normalizeOptionalText$41(process.env.ATSD_RUNTIME_OPENCLAW_BIN);
|
|
6332
6332
|
if (configuredCandidate && !candidates.includes(configuredCandidate)) candidates.push(configuredCandidate);
|
|
6333
6333
|
const nodeSiblingCandidate = resolveSiblingCommandPath({
|
|
6334
6334
|
anchorPath: process.execPath,
|
|
@@ -6344,16 +6344,16 @@ function resolveOpenClawBinCandidates(explicitOpenClawBin) {
|
|
|
6344
6344
|
return candidates;
|
|
6345
6345
|
}
|
|
6346
6346
|
function resolveOpenClawTimeoutMs() {
|
|
6347
|
-
const raw = normalizeOptionalText$
|
|
6347
|
+
const raw = normalizeOptionalText$41(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
|
|
6348
6348
|
if (!raw) return null;
|
|
6349
6349
|
const parsed = Number.parseInt(raw, 10);
|
|
6350
6350
|
if (!Number.isFinite(parsed) || parsed <= 0) return null;
|
|
6351
6351
|
return parsed;
|
|
6352
6352
|
}
|
|
6353
6353
|
function resolveOpenClawAgentId$1() {
|
|
6354
|
-
return normalizeOptionalText$
|
|
6354
|
+
return normalizeOptionalText$41(process.env.ATSD_RUNTIME_OPENCLAW_AGENT_ID) ?? DEFAULT_OPENCLAW_AGENT_ID;
|
|
6355
6355
|
}
|
|
6356
|
-
function normalizeOptionalText$
|
|
6356
|
+
function normalizeOptionalText$41(value) {
|
|
6357
6357
|
const normalized = String(value ?? "").trim();
|
|
6358
6358
|
return normalized.length > 0 ? normalized : null;
|
|
6359
6359
|
}
|
|
@@ -6499,10 +6499,10 @@ function resolveIsErrorResult(record) {
|
|
|
6499
6499
|
if (typeof record.isError === "boolean") return record.isError;
|
|
6500
6500
|
if (typeof record.ok === "boolean") return !record.ok;
|
|
6501
6501
|
if (typeof record.success === "boolean") return !record.success;
|
|
6502
|
-
const status = normalizeOptionalText$
|
|
6502
|
+
const status = normalizeOptionalText$40(record.status)?.toLowerCase();
|
|
6503
6503
|
if (status === "error" || status === "failed" || status === "fail") return true;
|
|
6504
6504
|
if (status === "ok" || status === "success" || status === "completed") return false;
|
|
6505
|
-
const type = normalizeOptionalText$
|
|
6505
|
+
const type = normalizeOptionalText$40(record.type)?.toLowerCase();
|
|
6506
6506
|
if (type === "error" || type === "failure") return true;
|
|
6507
6507
|
if (type === "result" || type === "success") return false;
|
|
6508
6508
|
if (record.error !== void 0 || record.errors !== void 0) return true;
|
|
@@ -6555,7 +6555,7 @@ function looksLikeErrorSignal(value) {
|
|
|
6555
6555
|
const lowered = value.toLowerCase();
|
|
6556
6556
|
return lowered.includes("error") || lowered.includes("failed") || lowered.includes("unauthorized") || lowered.includes("not logged in") || lowered.includes("invalid");
|
|
6557
6557
|
}
|
|
6558
|
-
function normalizeOptionalText$
|
|
6558
|
+
function normalizeOptionalText$40(value) {
|
|
6559
6559
|
const normalized = String(value ?? "").trim();
|
|
6560
6560
|
return normalized.length > 0 ? normalized : null;
|
|
6561
6561
|
}
|
|
@@ -6604,7 +6604,7 @@ function classifyOpenClawFailureMessage(input) {
|
|
|
6604
6604
|
};
|
|
6605
6605
|
}
|
|
6606
6606
|
function normalizeOpenClawFailureMessage(value) {
|
|
6607
|
-
const normalized = normalizeOptionalText$
|
|
6607
|
+
const normalized = normalizeOptionalText$39(value);
|
|
6608
6608
|
if (!normalized) return null;
|
|
6609
6609
|
return extractJsonFailureDetail(normalized) ?? normalized;
|
|
6610
6610
|
}
|
|
@@ -6613,7 +6613,7 @@ function extractJsonFailureDetail(value) {
|
|
|
6613
6613
|
const parsed = JSON.parse(value);
|
|
6614
6614
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
6615
6615
|
const record = parsed;
|
|
6616
|
-
return normalizeOptionalText$
|
|
6616
|
+
return normalizeOptionalText$39(record.detail) ?? normalizeOptionalText$39(record.message) ?? (record.error && typeof record.error === "object" && !Array.isArray(record.error) ? normalizeOptionalText$39(record.error.message) : null);
|
|
6617
6617
|
} catch {
|
|
6618
6618
|
return null;
|
|
6619
6619
|
}
|
|
@@ -6633,7 +6633,7 @@ function isRateLimitFailure(value) {
|
|
|
6633
6633
|
function isInputSelectorFailure(value) {
|
|
6634
6634
|
return value.includes("pass --to") && value.includes("--session-id") && value.includes("--agent") || value.includes("unknown agent") || value.includes("agent not found");
|
|
6635
6635
|
}
|
|
6636
|
-
function normalizeOptionalText$
|
|
6636
|
+
function normalizeOptionalText$39(value) {
|
|
6637
6637
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
6638
6638
|
return normalized.length > 0 ? normalized : null;
|
|
6639
6639
|
}
|
|
@@ -6651,7 +6651,7 @@ var OpenClawCliTransportError = class extends Error {
|
|
|
6651
6651
|
}
|
|
6652
6652
|
};
|
|
6653
6653
|
async function invokeOpenClawCliTransport(input) {
|
|
6654
|
-
const prompt = normalizeOptionalText$
|
|
6654
|
+
const prompt = normalizeOptionalText$38(input.prompt);
|
|
6655
6655
|
if (!prompt) throw new OpenClawCliTransportError({
|
|
6656
6656
|
code: "schema.invalid",
|
|
6657
6657
|
errorType: "config",
|
|
@@ -6660,7 +6660,7 @@ async function invokeOpenClawCliTransport(input) {
|
|
|
6660
6660
|
const { args, sessionId: initialSessionId } = buildOpenClawArgs({
|
|
6661
6661
|
openClawAgentId: input.openClawAgentId,
|
|
6662
6662
|
prompt,
|
|
6663
|
-
sessionId: normalizeOptionalText$
|
|
6663
|
+
sessionId: normalizeOptionalText$38(input.sessionId)
|
|
6664
6664
|
});
|
|
6665
6665
|
const invocation = buildCliLaunchInvocation({
|
|
6666
6666
|
args,
|
|
@@ -6739,7 +6739,7 @@ async function invokeOpenClawCliTransport(input) {
|
|
|
6739
6739
|
});
|
|
6740
6740
|
}
|
|
6741
6741
|
}
|
|
6742
|
-
const output = normalizeOptionalText$
|
|
6742
|
+
const output = normalizeOptionalText$38(latestOutput);
|
|
6743
6743
|
if (!output) {
|
|
6744
6744
|
const fallbackOutput = resolveSuccessFallbackOutput(driverResult.stdoutText);
|
|
6745
6745
|
if (!fallbackOutput) {
|
|
@@ -6763,25 +6763,25 @@ async function invokeOpenClawCliTransport(input) {
|
|
|
6763
6763
|
}
|
|
6764
6764
|
return {
|
|
6765
6765
|
output: fallbackOutput,
|
|
6766
|
-
sessionId: normalizeOptionalText$
|
|
6766
|
+
sessionId: normalizeOptionalText$38(resolvedSessionId),
|
|
6767
6767
|
telemetry: buildTransportTelemetry({
|
|
6768
6768
|
driverResult,
|
|
6769
6769
|
firstStderrAtMs,
|
|
6770
6770
|
firstStdoutAtMs,
|
|
6771
6771
|
invokedAtMs,
|
|
6772
|
-
resumedContext: normalizeOptionalText$
|
|
6772
|
+
resumedContext: normalizeOptionalText$38(input.sessionId) !== null
|
|
6773
6773
|
})
|
|
6774
6774
|
};
|
|
6775
6775
|
}
|
|
6776
6776
|
return {
|
|
6777
6777
|
output,
|
|
6778
|
-
sessionId: normalizeOptionalText$
|
|
6778
|
+
sessionId: normalizeOptionalText$38(resolvedSessionId),
|
|
6779
6779
|
telemetry: buildTransportTelemetry({
|
|
6780
6780
|
driverResult,
|
|
6781
6781
|
firstStderrAtMs,
|
|
6782
6782
|
firstStdoutAtMs,
|
|
6783
6783
|
invokedAtMs,
|
|
6784
|
-
resumedContext: normalizeOptionalText$
|
|
6784
|
+
resumedContext: normalizeOptionalText$38(input.sessionId) !== null
|
|
6785
6785
|
})
|
|
6786
6786
|
};
|
|
6787
6787
|
}
|
|
@@ -6852,7 +6852,7 @@ const classifyOpenClawFailure = (input) => {
|
|
|
6852
6852
|
isContextLost: isLikelyOpenClawContextLostError,
|
|
6853
6853
|
message: providerMessage
|
|
6854
6854
|
});
|
|
6855
|
-
const stderrText = normalizeOptionalText$
|
|
6855
|
+
const stderrText = normalizeOptionalText$38(input.stderrText);
|
|
6856
6856
|
if (stderrText) return {
|
|
6857
6857
|
code: "upstream_unreachable",
|
|
6858
6858
|
errorType: "adapter",
|
|
@@ -6864,13 +6864,13 @@ const resolveProviderFailureMessage = (input) => {
|
|
|
6864
6864
|
const candidateMessages = [
|
|
6865
6865
|
...input.providerErrorMessages,
|
|
6866
6866
|
...extractErrorMessagesFromStdout(input.stdoutText),
|
|
6867
|
-
...normalizeOptionalText$
|
|
6867
|
+
...normalizeOptionalText$38(input.stderrText) ? [normalizeOptionalText$38(input.stderrText)] : []
|
|
6868
6868
|
].filter((value) => Boolean(value));
|
|
6869
6869
|
for (const candidate of candidateMessages) if (looksLikeProviderFailure(candidate)) return candidate;
|
|
6870
6870
|
return candidateMessages[0] ?? null;
|
|
6871
6871
|
};
|
|
6872
6872
|
const extractErrorMessagesFromStdout = (value) => {
|
|
6873
|
-
const stdoutText = normalizeOptionalText$
|
|
6873
|
+
const stdoutText = normalizeOptionalText$38(value);
|
|
6874
6874
|
if (!stdoutText) return [];
|
|
6875
6875
|
const messages = [];
|
|
6876
6876
|
const lines = stdoutText.split("\n");
|
|
@@ -6881,7 +6881,7 @@ const extractErrorMessagesFromStdout = (value) => {
|
|
|
6881
6881
|
return messages;
|
|
6882
6882
|
};
|
|
6883
6883
|
const resolveSuccessFallbackOutput = (value) => {
|
|
6884
|
-
const stdoutText = normalizeOptionalText$
|
|
6884
|
+
const stdoutText = normalizeOptionalText$38(value);
|
|
6885
6885
|
if (!stdoutText) return null;
|
|
6886
6886
|
const lines = stdoutText.split("\n").map((line) => line.trim()).filter((line) => line.length > 0);
|
|
6887
6887
|
if (lines.length !== 1) return null;
|
|
@@ -6891,7 +6891,7 @@ const resolveSuccessFallbackOutput = (value) => {
|
|
|
6891
6891
|
return singleLine;
|
|
6892
6892
|
};
|
|
6893
6893
|
const collectProviderErrorMessage = (line, output) => {
|
|
6894
|
-
const normalized = normalizeOptionalText$
|
|
6894
|
+
const normalized = normalizeOptionalText$38(line);
|
|
6895
6895
|
if (!normalized) return;
|
|
6896
6896
|
output.push(normalized);
|
|
6897
6897
|
};
|
|
@@ -6902,7 +6902,7 @@ const looksLikeProviderFailure = (value) => {
|
|
|
6902
6902
|
function normalizeText$4(value) {
|
|
6903
6903
|
return String(value ?? "").trim();
|
|
6904
6904
|
}
|
|
6905
|
-
function normalizeOptionalText$
|
|
6905
|
+
function normalizeOptionalText$38(value) {
|
|
6906
6906
|
const normalized = normalizeText$4(value);
|
|
6907
6907
|
return normalized.length > 0 ? normalized : null;
|
|
6908
6908
|
}
|
|
@@ -7032,15 +7032,15 @@ async function readSessionIndex(input) {
|
|
|
7032
7032
|
}
|
|
7033
7033
|
}
|
|
7034
7034
|
function resolveOpenClawStateDir(env) {
|
|
7035
|
-
const configuredStateDir = normalizeOptionalText$
|
|
7035
|
+
const configuredStateDir = normalizeOptionalText$37(env?.OPENCLAW_STATE_DIR);
|
|
7036
7036
|
if (configuredStateDir) return configuredStateDir;
|
|
7037
7037
|
return join(homedir(), ".openclaw");
|
|
7038
7038
|
}
|
|
7039
7039
|
function resolveSessionFilePath(input) {
|
|
7040
7040
|
const sessionsDir = join(resolveOpenClawStateDir(input.env), "agents", input.agentId, "sessions");
|
|
7041
|
-
const sessionFile = normalizeOptionalText$
|
|
7041
|
+
const sessionFile = normalizeOptionalText$37(input.sessionEntry.sessionFile);
|
|
7042
7042
|
if (sessionFile) return isAbsolute(sessionFile) ? sessionFile : join(sessionsDir, sessionFile);
|
|
7043
|
-
const sessionId = normalizeOptionalText$
|
|
7043
|
+
const sessionId = normalizeOptionalText$37(input.sessionEntry.sessionId);
|
|
7044
7044
|
if (!sessionId) return null;
|
|
7045
7045
|
return join(sessionsDir, `${sessionId}.jsonl`);
|
|
7046
7046
|
}
|
|
@@ -7061,11 +7061,11 @@ function parseSessionErrorRecord(line) {
|
|
|
7061
7061
|
const parsed = JSON.parse(line);
|
|
7062
7062
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return null;
|
|
7063
7063
|
const record = parsed;
|
|
7064
|
-
if (normalizeOptionalText$
|
|
7064
|
+
if (normalizeOptionalText$37(record.type) !== "message") return null;
|
|
7065
7065
|
const message = record.message && typeof record.message === "object" ? record.message : null;
|
|
7066
7066
|
if (!message) return null;
|
|
7067
|
-
if (normalizeOptionalText$
|
|
7068
|
-
const errorMessage = normalizeOptionalText$
|
|
7067
|
+
if (normalizeOptionalText$37(message.stopReason) !== "error") return null;
|
|
7068
|
+
const errorMessage = normalizeOptionalText$37(message.errorMessage);
|
|
7069
7069
|
if (!errorMessage) return null;
|
|
7070
7070
|
const messageTimestampMs = normalizeOptionalNumber(message.timestamp) ?? normalizeIsoTimestampMs(record.timestamp);
|
|
7071
7071
|
if (messageTimestampMs === null) return null;
|
|
@@ -7078,7 +7078,7 @@ function parseSessionErrorRecord(line) {
|
|
|
7078
7078
|
}
|
|
7079
7079
|
}
|
|
7080
7080
|
function normalizeIsoTimestampMs(value) {
|
|
7081
|
-
const normalized = normalizeOptionalText$
|
|
7081
|
+
const normalized = normalizeOptionalText$37(value);
|
|
7082
7082
|
if (!normalized) return null;
|
|
7083
7083
|
const parsed = Date.parse(normalized);
|
|
7084
7084
|
return Number.isFinite(parsed) ? parsed : null;
|
|
@@ -7086,7 +7086,7 @@ function normalizeIsoTimestampMs(value) {
|
|
|
7086
7086
|
function normalizeOptionalNumber(value) {
|
|
7087
7087
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
7088
7088
|
}
|
|
7089
|
-
function normalizeOptionalText$
|
|
7089
|
+
function normalizeOptionalText$37(value) {
|
|
7090
7090
|
const normalized = typeof value === "string" ? value.trim() : "";
|
|
7091
7091
|
return normalized.length > 0 ? normalized : null;
|
|
7092
7092
|
}
|
|
@@ -7106,8 +7106,8 @@ var OpenClawGatewayTransportError = class extends Error {
|
|
|
7106
7106
|
}
|
|
7107
7107
|
};
|
|
7108
7108
|
async function invokeOpenClawGatewayTransport(input) {
|
|
7109
|
-
const prompt = normalizeOptionalText$
|
|
7110
|
-
const sessionKey = normalizeOptionalText$
|
|
7109
|
+
const prompt = normalizeOptionalText$36(input.prompt);
|
|
7110
|
+
const sessionKey = normalizeOptionalText$36(input.sessionKey);
|
|
7111
7111
|
if (!prompt) throw new OpenClawGatewayTransportError({
|
|
7112
7112
|
code: "schema.invalid",
|
|
7113
7113
|
errorType: "config",
|
|
@@ -7216,9 +7216,9 @@ function normalizeOpenClawGatewayAgentResult(result, expectedSessionKey) {
|
|
|
7216
7216
|
message: "upstream_unreachable: openclaw gateway returned a non-object payload for agent"
|
|
7217
7217
|
});
|
|
7218
7218
|
const record = result;
|
|
7219
|
-
const status = normalizeOptionalText$
|
|
7219
|
+
const status = normalizeOptionalText$36(record.status);
|
|
7220
7220
|
if (!status || status === "ok") return extractSuccessfulAgentResult(record.result, expectedSessionKey);
|
|
7221
|
-
throw classifyGatewayFailure(normalizeOptionalText$
|
|
7221
|
+
throw classifyGatewayFailure(normalizeOptionalText$36(record.summary) ?? normalizeOptionalText$36(record.error) ?? `openclaw gateway agent returned status '${status}'`);
|
|
7222
7222
|
}
|
|
7223
7223
|
function extractSuccessfulAgentResult(result, expectedSessionKey) {
|
|
7224
7224
|
if (!result || typeof result !== "object") throw new OpenClawGatewayTransportError({
|
|
@@ -7243,7 +7243,7 @@ function normalizeAgentMeta(meta, expectedSessionKey) {
|
|
|
7243
7243
|
const record = meta;
|
|
7244
7244
|
const systemPromptReport = record.systemPromptReport;
|
|
7245
7245
|
if (systemPromptReport && typeof systemPromptReport === "object") {
|
|
7246
|
-
const actualSessionKey = normalizeOptionalText$
|
|
7246
|
+
const actualSessionKey = normalizeOptionalText$36(systemPromptReport.sessionKey);
|
|
7247
7247
|
if (actualSessionKey && actualSessionKey !== expectedSessionKey) throw new OpenClawGatewayTransportError({
|
|
7248
7248
|
code: "upstream_unreachable",
|
|
7249
7249
|
errorType: "adapter",
|
|
@@ -7251,15 +7251,15 @@ function normalizeAgentMeta(meta, expectedSessionKey) {
|
|
|
7251
7251
|
});
|
|
7252
7252
|
}
|
|
7253
7253
|
const agentMeta = record.agentMeta;
|
|
7254
|
-
const agentSessionId = agentMeta && typeof agentMeta === "object" ? normalizeOptionalText$
|
|
7255
|
-
const reportSessionId = systemPromptReport && typeof systemPromptReport === "object" ? normalizeOptionalText$
|
|
7254
|
+
const agentSessionId = agentMeta && typeof agentMeta === "object" ? normalizeOptionalText$36(agentMeta.sessionId) : null;
|
|
7255
|
+
const reportSessionId = systemPromptReport && typeof systemPromptReport === "object" ? normalizeOptionalText$36(systemPromptReport.sessionId) : null;
|
|
7256
7256
|
return { sessionId: agentSessionId ?? reportSessionId };
|
|
7257
7257
|
}
|
|
7258
7258
|
function extractAgentPayloadText(payloads) {
|
|
7259
7259
|
if (!Array.isArray(payloads)) return null;
|
|
7260
7260
|
for (const payload of payloads) {
|
|
7261
7261
|
if (!payload || typeof payload !== "object") continue;
|
|
7262
|
-
const text = normalizeOptionalText$
|
|
7262
|
+
const text = normalizeOptionalText$36(payload.text);
|
|
7263
7263
|
if (text) return text;
|
|
7264
7264
|
}
|
|
7265
7265
|
return null;
|
|
@@ -7271,14 +7271,14 @@ function toOpenClawGatewayTransportError(error) {
|
|
|
7271
7271
|
errorType: "adapter",
|
|
7272
7272
|
message: "upstream_unreachable: openclaw is not installed or not on PATH"
|
|
7273
7273
|
});
|
|
7274
|
-
const stderr = normalizeOptionalText$
|
|
7275
|
-
const stdout = normalizeOptionalText$
|
|
7274
|
+
const stderr = normalizeOptionalText$36(error?.stderr);
|
|
7275
|
+
const stdout = normalizeOptionalText$36(error?.stdout);
|
|
7276
7276
|
return classifyGatewayFailure(stderr ?? stdout ?? toErrorMessage$31(error));
|
|
7277
7277
|
}
|
|
7278
7278
|
function classifyGatewayFailure(message) {
|
|
7279
7279
|
return new OpenClawGatewayTransportError(classifyOpenClawFailureMessage({ message }));
|
|
7280
7280
|
}
|
|
7281
|
-
function normalizeOptionalText$
|
|
7281
|
+
function normalizeOptionalText$36(value) {
|
|
7282
7282
|
const normalized = String(value ?? "").trim();
|
|
7283
7283
|
return normalized.length > 0 ? normalized : null;
|
|
7284
7284
|
}
|
|
@@ -7291,7 +7291,7 @@ function toErrorMessage$31(error) {
|
|
|
7291
7291
|
const OPENCLAW_CONVERSATION_BRIDGE_SPEC = resolveBuiltinAdapterConversationBridgeSpec("openclaw");
|
|
7292
7292
|
const resolveOpenClawSessionConversation = (agentControllerConversation) => {
|
|
7293
7293
|
if (!agentControllerConversation) return null;
|
|
7294
|
-
const agentControllerConversationId = normalizeOptionalText$
|
|
7294
|
+
const agentControllerConversationId = normalizeOptionalText$35(agentControllerConversation.agentControllerConversationId);
|
|
7295
7295
|
if (!agentControllerConversationId) throw new Error("conversation.bridge.agent_controller_conversation_id_missing: expected builtin:openclaw session agentControllerConversationId");
|
|
7296
7296
|
if (agentControllerConversation.agentControllerRef !== "builtin:openclaw" || agentControllerConversation.agentControllerConversationKind !== "session") throw new Error(`conversation.bridge.agent_controller_conversation_mismatch: expected builtin:openclaw session, received ${agentControllerConversation.agentControllerRef}/${agentControllerConversation.agentControllerConversationKind}`);
|
|
7297
7297
|
return buildAdapterAgentControllerConversationRef({
|
|
@@ -7304,7 +7304,7 @@ const resolveOpenClawInvokeRequest = (input) => {
|
|
|
7304
7304
|
const agentControllerConversation = resolveOpenClawSessionConversation(input.request.agentControllerConversation);
|
|
7305
7305
|
return {
|
|
7306
7306
|
...input.request,
|
|
7307
|
-
agentControllerConversationId: normalizeOptionalText$
|
|
7307
|
+
agentControllerConversationId: normalizeOptionalText$35(input.request.agentControllerConversationId),
|
|
7308
7308
|
...agentControllerConversation ? { agentControllerConversation } : {}
|
|
7309
7309
|
};
|
|
7310
7310
|
};
|
|
@@ -7385,7 +7385,7 @@ const resolveDefaultOpenClawInvoke = (options) => {
|
|
|
7385
7385
|
};
|
|
7386
7386
|
};
|
|
7387
7387
|
async function resolveOpenClawDispatchLaunchContract(input) {
|
|
7388
|
-
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$
|
|
7388
|
+
const explicitLaunchContract = input.inputLaunchContract ?? input.optionLaunchContract ?? (normalizeOptionalText$35(input.openClawBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$35(input.openClawBin) }) : null);
|
|
7389
7389
|
if (explicitLaunchContract) {
|
|
7390
7390
|
const verification = await verifyOpenClawLaunchContract({ launchContract: explicitLaunchContract });
|
|
7391
7391
|
if (verification.ok) return explicitLaunchContract;
|
|
@@ -7405,8 +7405,8 @@ const resolveRuntimeProcessRegistrar = (input) => input.registerRuntimeProcess ?
|
|
|
7405
7405
|
taskId: input.taskId
|
|
7406
7406
|
});
|
|
7407
7407
|
} : void 0;
|
|
7408
|
-
const resolveOpenClawAgentId = (input) => normalizeOptionalText$
|
|
7409
|
-
const resolveOpenClawSessionKey = (input) => normalizeOptionalText$
|
|
7408
|
+
const resolveOpenClawAgentId = (input) => normalizeOptionalText$35(input.dispatchEnvAgentId) ?? normalizeOptionalText$35(input.optionAgentId) ?? resolveOpenClawAgentId$1();
|
|
7409
|
+
const resolveOpenClawSessionKey = (input) => normalizeOptionalText$35(input.agentControllerConversation?.agentControllerRef === "builtin:openclaw" && input.agentControllerConversation.agentControllerConversationKind === "session" ? input.agentControllerConversation.agentControllerConversationId : null);
|
|
7410
7410
|
const invokeOpenClawGatewayPath = async (input) => {
|
|
7411
7411
|
const gatewayResult = await invokeOpenClawGatewayTransport({
|
|
7412
7412
|
agentId: input.openClawAgentId,
|
|
@@ -7416,7 +7416,7 @@ const invokeOpenClawGatewayPath = async (input) => {
|
|
|
7416
7416
|
openClawTimeoutMs: input.openClawTimeoutMs,
|
|
7417
7417
|
openClawWorkdir: input.openClawWorkdir,
|
|
7418
7418
|
prompt: input.input.prompt,
|
|
7419
|
-
resumedContext: normalizeOptionalText$
|
|
7419
|
+
resumedContext: normalizeOptionalText$35(input.input.agentControllerConversationId) !== null,
|
|
7420
7420
|
sessionKey: input.sessionKey
|
|
7421
7421
|
});
|
|
7422
7422
|
return {
|
|
@@ -7443,7 +7443,7 @@ const invokeOpenClawLocalCliPath = async (input) => {
|
|
|
7443
7443
|
...input.onProcessControlEvent ? { onProcessControlEvent: input.onProcessControlEvent } : {},
|
|
7444
7444
|
...input.input.onRuntimeEvent ? { onRuntimeEvent: input.input.onRuntimeEvent } : {},
|
|
7445
7445
|
prompt: input.input.prompt,
|
|
7446
|
-
sessionId: normalizeOptionalText$
|
|
7446
|
+
sessionId: normalizeOptionalText$35(input.input.agentControllerConversationId)
|
|
7447
7447
|
});
|
|
7448
7448
|
const agentControllerConversation = OPENCLAW_CONVERSATION_BRIDGE_SPEC ? bridgeAgentControllerConversationRef({
|
|
7449
7449
|
bridgeSpec: OPENCLAW_CONVERSATION_BRIDGE_SPEC,
|
|
@@ -7462,7 +7462,7 @@ const invokeOpenClawLocalCliPath = async (input) => {
|
|
|
7462
7462
|
function normalizeText$3(value) {
|
|
7463
7463
|
return String(value ?? "").trim();
|
|
7464
7464
|
}
|
|
7465
|
-
function normalizeOptionalText$
|
|
7465
|
+
function normalizeOptionalText$35(value) {
|
|
7466
7466
|
const normalized = normalizeText$3(value);
|
|
7467
7467
|
return normalized.length > 0 ? normalized : null;
|
|
7468
7468
|
}
|
|
@@ -10170,7 +10170,7 @@ const removeConversationExecutionState = (input) => {
|
|
|
10170
10170
|
return nextState;
|
|
10171
10171
|
};
|
|
10172
10172
|
const seedLegacyAgentContext = (input) => {
|
|
10173
|
-
const normalizedLegacyAgentControllerConversationId = normalizeOptionalText$
|
|
10173
|
+
const normalizedLegacyAgentControllerConversationId = normalizeOptionalText$34(input.legacyAgentControllerConversationId);
|
|
10174
10174
|
if (!normalizedLegacyAgentControllerConversationId) return input.state;
|
|
10175
10175
|
if (input.state.agentContextByLookupKey[input.agentContextLookupKey]) return input.state;
|
|
10176
10176
|
return upsertAgentContext({
|
|
@@ -10190,7 +10190,7 @@ const seedLegacyAgentContext = (input) => {
|
|
|
10190
10190
|
});
|
|
10191
10191
|
};
|
|
10192
10192
|
const commitResolvedAgentContext = (input) => {
|
|
10193
|
-
const normalizedAgentControllerConversationId = normalizeOptionalText$
|
|
10193
|
+
const normalizedAgentControllerConversationId = normalizeOptionalText$34(input.agentControllerConversationId);
|
|
10194
10194
|
if (!normalizedAgentControllerConversationId) return input.state;
|
|
10195
10195
|
const existing = input.state.agentContextByLookupKey[input.agentContextLookupKey] ?? null;
|
|
10196
10196
|
return upsertAgentContext({
|
|
@@ -10228,7 +10228,7 @@ const appendAgentContextRotationRecord = (input) => {
|
|
|
10228
10228
|
nextState.updatedAtMs = Date.now();
|
|
10229
10229
|
return nextState;
|
|
10230
10230
|
};
|
|
10231
|
-
function normalizeOptionalText$
|
|
10231
|
+
function normalizeOptionalText$34(value) {
|
|
10232
10232
|
if (typeof value !== "string") return null;
|
|
10233
10233
|
const normalized = value.trim();
|
|
10234
10234
|
return normalized.length > 0 ? normalized : null;
|
|
@@ -11160,19 +11160,19 @@ function buildDispatchControllerKey(input) {
|
|
|
11160
11160
|
return `profile:${input.profileId}`;
|
|
11161
11161
|
}
|
|
11162
11162
|
function buildDispatchLocalExecutionLaneKey(input) {
|
|
11163
|
-
const agentControllerConversationId = normalizeOptionalText$
|
|
11163
|
+
const agentControllerConversationId = normalizeOptionalText$33(input.agentControllerConversationId);
|
|
11164
11164
|
if (agentControllerConversationId) return `agent-controller-conversation:${input.controllerKey}:${agentControllerConversationId}`;
|
|
11165
11165
|
return `agent-profile:${input.profileId}`;
|
|
11166
11166
|
}
|
|
11167
11167
|
function resolveDispatchQueueTargetLabel(parsedTask) {
|
|
11168
|
-
const mentionLabel = normalizeOptionalText$
|
|
11168
|
+
const mentionLabel = normalizeOptionalText$33(parsedTask.targetProfileMentionLabel);
|
|
11169
11169
|
if (mentionLabel) return formatCanonicalMentionLiteral({
|
|
11170
11170
|
name: mentionLabel,
|
|
11171
11171
|
type: "wake"
|
|
11172
11172
|
});
|
|
11173
11173
|
return `profile:${parsedTask.targetProfileId}`;
|
|
11174
11174
|
}
|
|
11175
|
-
function normalizeOptionalText$
|
|
11175
|
+
function normalizeOptionalText$33(value) {
|
|
11176
11176
|
const normalized = value?.trim();
|
|
11177
11177
|
return normalized ? normalized : null;
|
|
11178
11178
|
}
|
|
@@ -11316,6 +11316,27 @@ function createLocalExecutionSlots(input) {
|
|
|
11316
11316
|
waitReason
|
|
11317
11317
|
};
|
|
11318
11318
|
};
|
|
11319
|
+
const buildTaskLifecycleEvent = (task, inputEvent) => {
|
|
11320
|
+
return {
|
|
11321
|
+
adapterId: task.adapterId,
|
|
11322
|
+
attemptId: task.attemptId,
|
|
11323
|
+
controllerKey: task.controllerKey,
|
|
11324
|
+
dispatchId: task.dispatchId,
|
|
11325
|
+
localExecutionLaneKey: task.localExecutionLaneKey,
|
|
11326
|
+
localQueue: buildLocalQueueDiagnostics({
|
|
11327
|
+
localExecutionLaneKey: task.localExecutionLaneKey,
|
|
11328
|
+
queuePosition: inputEvent.queuePosition,
|
|
11329
|
+
status: inputEvent.status,
|
|
11330
|
+
waitReason: inputEvent.waitReason
|
|
11331
|
+
}),
|
|
11332
|
+
profileId: task.profileId,
|
|
11333
|
+
spaceId: task.spaceId,
|
|
11334
|
+
taskId: task.taskId,
|
|
11335
|
+
targetLabel: task.targetLabel,
|
|
11336
|
+
transportMode: task.transportMode,
|
|
11337
|
+
...buildSnapshot(task.localExecutionLaneKey)
|
|
11338
|
+
};
|
|
11339
|
+
};
|
|
11319
11340
|
const buildTaskOwnerSnapshot = (owner) => {
|
|
11320
11341
|
return {
|
|
11321
11342
|
attemptId: owner.attemptId,
|
|
@@ -11350,75 +11371,37 @@ function createLocalExecutionSlots(input) {
|
|
|
11350
11371
|
const selectedTask = selectedPendingTask.task;
|
|
11351
11372
|
activeGlobal += 1;
|
|
11352
11373
|
activeCountByLaneKey.set(selectedTask.localExecutionLaneKey, resolveActiveForLane(selectedTask.localExecutionLaneKey) + 1);
|
|
11353
|
-
const startedEvent = {
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
localExecutionLaneKey: selectedTask.localExecutionLaneKey,
|
|
11359
|
-
localQueue: buildLocalQueueDiagnostics({
|
|
11360
|
-
localExecutionLaneKey: selectedTask.localExecutionLaneKey,
|
|
11361
|
-
queuePosition: null,
|
|
11362
|
-
status: "starting_runtime",
|
|
11363
|
-
waitReason: "none"
|
|
11364
|
-
}),
|
|
11365
|
-
profileId: selectedTask.profileId,
|
|
11366
|
-
spaceId: selectedTask.spaceId,
|
|
11367
|
-
taskId: selectedTask.taskId,
|
|
11368
|
-
targetLabel: selectedTask.targetLabel,
|
|
11369
|
-
transportMode: selectedTask.transportMode,
|
|
11370
|
-
...buildSnapshot(selectedTask.localExecutionLaneKey)
|
|
11371
|
-
};
|
|
11374
|
+
const startedEvent = buildTaskLifecycleEvent(selectedTask, {
|
|
11375
|
+
queuePosition: null,
|
|
11376
|
+
status: "starting_runtime",
|
|
11377
|
+
waitReason: "none"
|
|
11378
|
+
});
|
|
11372
11379
|
input.onTaskStarted?.(startedEvent);
|
|
11373
11380
|
const startedAtMs = Date.now();
|
|
11374
11381
|
Promise.resolve().then(async () => {
|
|
11375
11382
|
const completionResult = resolveTaskCompletionResult(await selectedTask.run());
|
|
11376
11383
|
input.onTaskCompleted?.({
|
|
11377
|
-
|
|
11378
|
-
attemptId: selectedTask.attemptId,
|
|
11379
|
-
...buildSnapshot(selectedTask.localExecutionLaneKey),
|
|
11380
|
-
controllerKey: selectedTask.controllerKey,
|
|
11381
|
-
dispatchId: selectedTask.dispatchId,
|
|
11382
|
-
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
11383
|
-
errorCode: completionResult.errorCode,
|
|
11384
|
-
errorMessage: completionResult.errorMessage,
|
|
11385
|
-
localExecutionLaneKey: selectedTask.localExecutionLaneKey,
|
|
11386
|
-
localQueue: buildLocalQueueDiagnostics({
|
|
11387
|
-
localExecutionLaneKey: selectedTask.localExecutionLaneKey,
|
|
11384
|
+
...buildTaskLifecycleEvent(selectedTask, {
|
|
11388
11385
|
queuePosition: null,
|
|
11389
11386
|
status: "starting_runtime",
|
|
11390
11387
|
waitReason: "none"
|
|
11391
11388
|
}),
|
|
11392
|
-
|
|
11393
|
-
|
|
11394
|
-
|
|
11395
|
-
|
|
11396
|
-
targetLabel: selectedTask.targetLabel,
|
|
11397
|
-
transportMode: selectedTask.transportMode
|
|
11389
|
+
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
11390
|
+
errorCode: completionResult.errorCode,
|
|
11391
|
+
errorMessage: completionResult.errorMessage,
|
|
11392
|
+
result: completionResult.result
|
|
11398
11393
|
});
|
|
11399
11394
|
}).catch((error) => {
|
|
11400
11395
|
input.onTaskCompleted?.({
|
|
11401
|
-
|
|
11402
|
-
attemptId: selectedTask.attemptId,
|
|
11403
|
-
...buildSnapshot(selectedTask.localExecutionLaneKey),
|
|
11404
|
-
controllerKey: selectedTask.controllerKey,
|
|
11405
|
-
dispatchId: selectedTask.dispatchId,
|
|
11406
|
-
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
11407
|
-
errorCode: null,
|
|
11408
|
-
errorMessage: toErrorMessage$30(error),
|
|
11409
|
-
localExecutionLaneKey: selectedTask.localExecutionLaneKey,
|
|
11410
|
-
localQueue: buildLocalQueueDiagnostics({
|
|
11411
|
-
localExecutionLaneKey: selectedTask.localExecutionLaneKey,
|
|
11396
|
+
...buildTaskLifecycleEvent(selectedTask, {
|
|
11412
11397
|
queuePosition: null,
|
|
11413
11398
|
status: "starting_runtime",
|
|
11414
11399
|
waitReason: "none"
|
|
11415
11400
|
}),
|
|
11416
|
-
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
targetLabel: selectedTask.targetLabel,
|
|
11421
|
-
transportMode: selectedTask.transportMode
|
|
11401
|
+
durationMs: Math.max(0, Date.now() - startedAtMs),
|
|
11402
|
+
errorCode: null,
|
|
11403
|
+
errorMessage: toErrorMessage$30(error),
|
|
11404
|
+
result: "failed"
|
|
11422
11405
|
});
|
|
11423
11406
|
}).finally(() => {
|
|
11424
11407
|
releaseTaskOwnership(selectedTask);
|
|
@@ -11467,23 +11450,7 @@ function createLocalExecutionSlots(input) {
|
|
|
11467
11450
|
const snapshot = buildSnapshot(task.localExecutionLaneKey);
|
|
11468
11451
|
if (task.onQueued) try {
|
|
11469
11452
|
const queuePosition = pendingTasks.indexOf(pendingTask) + 1;
|
|
11470
|
-
const stopQueuedLifecycle = task.onQueued({
|
|
11471
|
-
adapterId: task.adapterId,
|
|
11472
|
-
attemptId: task.attemptId,
|
|
11473
|
-
controllerKey: task.controllerKey,
|
|
11474
|
-
dispatchId: task.dispatchId,
|
|
11475
|
-
localExecutionLaneKey: task.localExecutionLaneKey,
|
|
11476
|
-
localQueue: buildLocalQueueDiagnostics({
|
|
11477
|
-
localExecutionLaneKey: task.localExecutionLaneKey,
|
|
11478
|
-
queuePosition
|
|
11479
|
-
}),
|
|
11480
|
-
profileId: task.profileId,
|
|
11481
|
-
spaceId: task.spaceId,
|
|
11482
|
-
taskId: task.taskId,
|
|
11483
|
-
targetLabel: task.targetLabel,
|
|
11484
|
-
transportMode: task.transportMode,
|
|
11485
|
-
...snapshot
|
|
11486
|
-
});
|
|
11453
|
+
const stopQueuedLifecycle = task.onQueued(buildTaskLifecycleEvent(task, { queuePosition }));
|
|
11487
11454
|
pendingTask.stopQueuedLifecycle = typeof stopQueuedLifecycle === "function" ? stopQueuedLifecycle : null;
|
|
11488
11455
|
} catch (error) {
|
|
11489
11456
|
pendingTasks.pop();
|
|
@@ -11509,23 +11476,11 @@ function createLocalExecutionSlots(input) {
|
|
|
11509
11476
|
releaseTaskOwnership(pendingTask.task);
|
|
11510
11477
|
droppedCount += 1;
|
|
11511
11478
|
input.onTaskDropped?.({
|
|
11512
|
-
|
|
11513
|
-
attemptId: pendingTask.task.attemptId,
|
|
11514
|
-
controllerKey: pendingTask.task.controllerKey,
|
|
11515
|
-
dispatchId: pendingTask.task.dispatchId,
|
|
11516
|
-
localExecutionLaneKey: pendingTask.task.localExecutionLaneKey,
|
|
11517
|
-
localQueue: buildLocalQueueDiagnostics({
|
|
11518
|
-
localExecutionLaneKey: pendingTask.task.localExecutionLaneKey,
|
|
11479
|
+
...buildTaskLifecycleEvent(pendingTask.task, {
|
|
11519
11480
|
queuePosition: null,
|
|
11520
11481
|
status: "queued"
|
|
11521
11482
|
}),
|
|
11522
|
-
|
|
11523
|
-
reason,
|
|
11524
|
-
spaceId: pendingTask.task.spaceId,
|
|
11525
|
-
taskId: pendingTask.task.taskId,
|
|
11526
|
-
targetLabel: pendingTask.task.targetLabel,
|
|
11527
|
-
transportMode: pendingTask.task.transportMode,
|
|
11528
|
-
...buildSnapshot(pendingTask.task.profileId)
|
|
11483
|
+
reason
|
|
11529
11484
|
});
|
|
11530
11485
|
}
|
|
11531
11486
|
notifyDrainWaitersIfIdle();
|
|
@@ -11660,6 +11615,113 @@ function mergeOpenClawGatewayVisibility(input) {
|
|
|
11660
11615
|
};
|
|
11661
11616
|
}
|
|
11662
11617
|
|
|
11618
|
+
//#endregion
|
|
11619
|
+
//#region ../../runtime/local-service/src/post-message-envelope.ts
|
|
11620
|
+
const TARGET_VALIDATION_RULES = [
|
|
11621
|
+
{
|
|
11622
|
+
fieldName: "activationTargets",
|
|
11623
|
+
relationName: "wake"
|
|
11624
|
+
},
|
|
11625
|
+
{
|
|
11626
|
+
fieldName: "referenceTargets",
|
|
11627
|
+
relationName: "reference"
|
|
11628
|
+
},
|
|
11629
|
+
{
|
|
11630
|
+
fieldName: "ccTargets",
|
|
11631
|
+
relationName: "cc"
|
|
11632
|
+
}
|
|
11633
|
+
];
|
|
11634
|
+
function normalizeDispatchPostMessageAction(input) {
|
|
11635
|
+
const normalizedEnvelope = normalizeMessageEnvelope(input.action.messageEnvelope);
|
|
11636
|
+
const replyToSignalId = normalizeReplyToSignalId$1({
|
|
11637
|
+
currentReplyToSignalId: input.currentReplyToSignalId,
|
|
11638
|
+
envelopeReplyToSignalId: normalizedEnvelope.replyToSignalId ?? null
|
|
11639
|
+
});
|
|
11640
|
+
const canonicalAction = {
|
|
11641
|
+
...input.action,
|
|
11642
|
+
messageEnvelope: {
|
|
11643
|
+
...normalizedEnvelope,
|
|
11644
|
+
...replyToSignalId ? { replyToSignalId } : {}
|
|
11645
|
+
}
|
|
11646
|
+
};
|
|
11647
|
+
validateDispatchPostMessageTargets({
|
|
11648
|
+
action: canonicalAction,
|
|
11649
|
+
sendTargetReference: input.sendTargetReference
|
|
11650
|
+
});
|
|
11651
|
+
return {
|
|
11652
|
+
action: canonicalAction,
|
|
11653
|
+
tracePayload: {
|
|
11654
|
+
activationTargetsCount: canonicalAction.messageEnvelope.activationTargets.length,
|
|
11655
|
+
ccTargetsCount: canonicalAction.messageEnvelope.ccTargets.length,
|
|
11656
|
+
inputKind: input.inputKind,
|
|
11657
|
+
membersProjectionLoaded: input.sendTargetReference.status === "loaded",
|
|
11658
|
+
referenceTargetsCount: canonicalAction.messageEnvelope.referenceTargets.length,
|
|
11659
|
+
replyToSignalIdResolved: Boolean(canonicalAction.messageEnvelope.replyToSignalId)
|
|
11660
|
+
}
|
|
11661
|
+
};
|
|
11662
|
+
}
|
|
11663
|
+
function normalizeReplyToSignalId$1(input) {
|
|
11664
|
+
if (!input.currentReplyToSignalId) {
|
|
11665
|
+
if (input.envelopeReplyToSignalId) throw new Error("post_message.messageEnvelope.replyToSignalId must match the current dispatch reply target");
|
|
11666
|
+
return null;
|
|
11667
|
+
}
|
|
11668
|
+
if (input.envelopeReplyToSignalId && input.envelopeReplyToSignalId !== input.currentReplyToSignalId) throw new Error("post_message.messageEnvelope.replyToSignalId must match the current dispatch reply target");
|
|
11669
|
+
return input.currentReplyToSignalId;
|
|
11670
|
+
}
|
|
11671
|
+
function validateDispatchPostMessageTargets(input) {
|
|
11672
|
+
const { activationTargets, ccTargets, referenceTargets } = input.action.messageEnvelope;
|
|
11673
|
+
if (activationTargets.length === 0 && referenceTargets.length === 0 && ccTargets.length === 0) return;
|
|
11674
|
+
if (input.sendTargetReference.status !== "loaded") throw new Error("post_message.messageEnvelope targets require a current space members projection");
|
|
11675
|
+
const targetByProfileId = new Map(input.sendTargetReference.projection.map((target) => [target.profileId, target]));
|
|
11676
|
+
for (const rule of TARGET_VALIDATION_RULES) {
|
|
11677
|
+
const targets = input.action.messageEnvelope[rule.fieldName];
|
|
11678
|
+
for (const [index, targetProfileId] of targets.entries()) validateDispatchTargetProfileId({
|
|
11679
|
+
fieldName: rule.fieldName,
|
|
11680
|
+
index,
|
|
11681
|
+
relationName: rule.relationName,
|
|
11682
|
+
targetByProfileId,
|
|
11683
|
+
targetProfileId
|
|
11684
|
+
});
|
|
11685
|
+
}
|
|
11686
|
+
}
|
|
11687
|
+
function validateDispatchTargetProfileId(input) {
|
|
11688
|
+
const target = input.targetByProfileId.get(input.targetProfileId);
|
|
11689
|
+
const fieldPath = `post_message.messageEnvelope.${input.fieldName}[${String(input.index)}]`;
|
|
11690
|
+
if (!target) throw new Error(`${fieldPath} must reference an active profile in this space`);
|
|
11691
|
+
if (input.relationName === "wake" && !target.allowedRelations.wake) throw new Error(`${fieldPath} must reference an agent profile in this space`);
|
|
11692
|
+
if (input.relationName === "wake" && target.wakeAvailability.status !== "ready") throw new Error(`${fieldPath} must reference an agent profile available for Wake`);
|
|
11693
|
+
if ((input.relationName === "reference" || input.relationName === "cc") && !target.allowedRelations[input.relationName]) throw new Error(`${fieldPath} must reference an active profile in this space`);
|
|
11694
|
+
}
|
|
11695
|
+
|
|
11696
|
+
//#endregion
|
|
11697
|
+
//#region ../../runtime/local-service/src/reply-context.ts
|
|
11698
|
+
function buildDispatchReplyContextSummary(replyToSnapshot) {
|
|
11699
|
+
const previewText = normalizeOptionalText$32(replyToSnapshot?.previewText);
|
|
11700
|
+
const replyToSignalId = normalizeOptionalText$32(replyToSnapshot?.signalId);
|
|
11701
|
+
if (previewText) return {
|
|
11702
|
+
previewText,
|
|
11703
|
+
replyToSignalId,
|
|
11704
|
+
resolved: true,
|
|
11705
|
+
summary: previewText
|
|
11706
|
+
};
|
|
11707
|
+
if (replyToSignalId) return {
|
|
11708
|
+
previewText: null,
|
|
11709
|
+
replyToSignalId,
|
|
11710
|
+
resolved: true,
|
|
11711
|
+
summary: `signal ${replyToSignalId}`
|
|
11712
|
+
};
|
|
11713
|
+
return {
|
|
11714
|
+
previewText: null,
|
|
11715
|
+
replyToSignalId: null,
|
|
11716
|
+
resolved: false,
|
|
11717
|
+
summary: "the current source message"
|
|
11718
|
+
};
|
|
11719
|
+
}
|
|
11720
|
+
function normalizeOptionalText$32(value) {
|
|
11721
|
+
const normalized = String(value ?? "").trim();
|
|
11722
|
+
return normalized.length > 0 ? normalized : null;
|
|
11723
|
+
}
|
|
11724
|
+
|
|
11663
11725
|
//#endregion
|
|
11664
11726
|
//#region ../../runtime/local-service/src/service-reconcile-decision.ts
|
|
11665
11727
|
function resolveProjectionReconcileDecision(input) {
|
|
@@ -31890,7 +31952,7 @@ var SpaceComposerSubmissionError = class extends Error {
|
|
|
31890
31952
|
};
|
|
31891
31953
|
function prepareSpaceComposerSubmission(input) {
|
|
31892
31954
|
const canonicalFragments = collectCanonicalMentionTextFragments(input.text);
|
|
31893
|
-
const replyToSignalId = normalizeReplyToSignalId
|
|
31955
|
+
const replyToSignalId = normalizeReplyToSignalId(input.replyTo);
|
|
31894
31956
|
const replyTo = replyToSignalId ? { signalId: replyToSignalId } : null;
|
|
31895
31957
|
if (canonicalFragments.length === 0) {
|
|
31896
31958
|
const normalizedText = normalizePlainTextOrThrow(input.text);
|
|
@@ -31973,7 +32035,7 @@ function createEnvelopeInput(text, replyToSignalId) {
|
|
|
31973
32035
|
text
|
|
31974
32036
|
};
|
|
31975
32037
|
}
|
|
31976
|
-
function normalizeReplyToSignalId
|
|
32038
|
+
function normalizeReplyToSignalId(replyTo) {
|
|
31977
32039
|
if (!replyTo) return null;
|
|
31978
32040
|
const signalId = replyTo.signalId.trim();
|
|
31979
32041
|
if (signalId.length === 0) throw createSubmissionError("addressing.invalid_reply_target", "replyTo.signalId must be a non-empty string.");
|
|
@@ -38170,31 +38232,6 @@ function projectSpaceProfileCache(spaceConfig) {
|
|
|
38170
38232
|
};
|
|
38171
38233
|
}
|
|
38172
38234
|
|
|
38173
|
-
//#endregion
|
|
38174
|
-
//#region src/local-service/dispatch/reply-context.ts
|
|
38175
|
-
function buildDispatchReplyContextSummary(replyToSnapshot) {
|
|
38176
|
-
const previewText = normalizeOptionalText$29(replyToSnapshot?.previewText);
|
|
38177
|
-
const replyToSignalId = normalizeOptionalText$29(replyToSnapshot?.signalId);
|
|
38178
|
-
if (previewText) return {
|
|
38179
|
-
previewText,
|
|
38180
|
-
replyToSignalId,
|
|
38181
|
-
resolved: true,
|
|
38182
|
-
summary: previewText
|
|
38183
|
-
};
|
|
38184
|
-
if (replyToSignalId) return {
|
|
38185
|
-
previewText: null,
|
|
38186
|
-
replyToSignalId,
|
|
38187
|
-
resolved: true,
|
|
38188
|
-
summary: `signal ${replyToSignalId}`
|
|
38189
|
-
};
|
|
38190
|
-
return {
|
|
38191
|
-
previewText: null,
|
|
38192
|
-
replyToSignalId: null,
|
|
38193
|
-
resolved: false,
|
|
38194
|
-
summary: "the current source message"
|
|
38195
|
-
};
|
|
38196
|
-
}
|
|
38197
|
-
|
|
38198
38235
|
//#endregion
|
|
38199
38236
|
//#region src/local-service/dispatch/parse-dispatch-task.ts
|
|
38200
38237
|
const ATS_SPACE_DEFINITION = buildAgentFacingMentalModelLines().slice(0, 2).join(" ");
|
|
@@ -38338,6 +38375,8 @@ function buildDispatchPromptWithBootstrap(input) {
|
|
|
38338
38375
|
if (input.shouldInjectBootstrap && isEntryBriefEnabled(input)) sections.push(renderEntryBriefSection(input));
|
|
38339
38376
|
if ((input.spaceContractSnapshot?.dispatchBrief ?? "default") !== "none") sections.push(renderDispatchBriefSection(input));
|
|
38340
38377
|
sections.push(["Current Wake message:", prompt].join("\n"));
|
|
38378
|
+
const completionSection = renderMandatoryCompletionSection(input);
|
|
38379
|
+
if (completionSection) sections.push(completionSection);
|
|
38341
38380
|
return sections.filter(Boolean).join("\n\n");
|
|
38342
38381
|
}
|
|
38343
38382
|
function buildDispatchBootstrapTemplateFacts(input) {
|
|
@@ -38407,6 +38446,23 @@ function renderDispatchBriefSection(input) {
|
|
|
38407
38446
|
...buildSendTargetReferenceLines(input)
|
|
38408
38447
|
].filter(Boolean).join("\n");
|
|
38409
38448
|
}
|
|
38449
|
+
function renderMandatoryCompletionSection(input) {
|
|
38450
|
+
const publicationRequirement = resolveSpacePublicationRequirement(input.spaceContractSnapshot);
|
|
38451
|
+
if (publicationRequirement.allowsRawReplyWithoutAction) return null;
|
|
38452
|
+
return [
|
|
38453
|
+
"Mandatory completion:",
|
|
38454
|
+
"- Do not finish this Wake with a plain-text final answer. Plain prose stays local and is not a public Space reply in Collaboration mode.",
|
|
38455
|
+
buildMandatoryCompletionActionLine(input, publicationRequirement),
|
|
38456
|
+
"- After the Space Action command succeeds, stop. ATS reads that command as the public outcome.",
|
|
38457
|
+
`- Use fallback JSON only if the Space Action command cannot run: \`${buildPromptSpaceActionCommand(input)}\`.`
|
|
38458
|
+
].join("\n");
|
|
38459
|
+
}
|
|
38460
|
+
function buildMandatoryCompletionActionLine(input, publicationRequirement) {
|
|
38461
|
+
if (publicationRequirement.allowedActions.includes("post_message")) return `- Normal completion: run \`${buildSpaceActionCommand(input, "reply \"your public message\"")}\` and wait for it to finish.`;
|
|
38462
|
+
if (publicationRequirement.allowedActions.includes("post_status")) return `- Normal completion: run \`${buildSpaceActionCommand(input, "status done \"short completion update\"")}\` and wait for it to finish.`;
|
|
38463
|
+
if (publicationRequirement.allowedActions.includes("stay_silent")) return `- Normal completion: run \`${buildSpaceActionCommand(input, "silent --reason \"reason\"")}\` and wait for it to finish.`;
|
|
38464
|
+
return `- Normal completion: run \`${buildPromptSpaceActionCommand(input)}\` and return one valid trailing ats-space-action block.`;
|
|
38465
|
+
}
|
|
38410
38466
|
function buildServiceFreshnessWarningLines(input) {
|
|
38411
38467
|
return input.serviceFreshnessWarningLines?.filter(Boolean) ?? [];
|
|
38412
38468
|
}
|
|
@@ -40110,84 +40166,6 @@ function normalizeOptionalText$12(value) {
|
|
|
40110
40166
|
return normalized.length > 0 ? normalized : null;
|
|
40111
40167
|
}
|
|
40112
40168
|
|
|
40113
|
-
//#endregion
|
|
40114
|
-
//#region src/local-service/dispatch/post-message-envelope.ts
|
|
40115
|
-
const TARGET_VALIDATION_RULES = [
|
|
40116
|
-
{
|
|
40117
|
-
fieldName: "activationTargets",
|
|
40118
|
-
relationName: "wake"
|
|
40119
|
-
},
|
|
40120
|
-
{
|
|
40121
|
-
fieldName: "referenceTargets",
|
|
40122
|
-
relationName: "reference"
|
|
40123
|
-
},
|
|
40124
|
-
{
|
|
40125
|
-
fieldName: "ccTargets",
|
|
40126
|
-
relationName: "cc"
|
|
40127
|
-
}
|
|
40128
|
-
];
|
|
40129
|
-
function normalizeDispatchPostMessageAction(input) {
|
|
40130
|
-
const normalizedEnvelope = normalizeMessageEnvelope(input.action.messageEnvelope);
|
|
40131
|
-
const replyToSignalId = normalizeReplyToSignalId({
|
|
40132
|
-
currentReplyToSignalId: input.currentReplyToSignalId,
|
|
40133
|
-
envelopeReplyToSignalId: normalizedEnvelope.replyToSignalId ?? null
|
|
40134
|
-
});
|
|
40135
|
-
const canonicalAction = {
|
|
40136
|
-
...input.action,
|
|
40137
|
-
messageEnvelope: {
|
|
40138
|
-
...normalizedEnvelope,
|
|
40139
|
-
...replyToSignalId ? { replyToSignalId } : {}
|
|
40140
|
-
}
|
|
40141
|
-
};
|
|
40142
|
-
validateDispatchPostMessageTargets({
|
|
40143
|
-
action: canonicalAction,
|
|
40144
|
-
sendTargetReference: input.sendTargetReference
|
|
40145
|
-
});
|
|
40146
|
-
return {
|
|
40147
|
-
action: canonicalAction,
|
|
40148
|
-
tracePayload: {
|
|
40149
|
-
activationTargetsCount: canonicalAction.messageEnvelope.activationTargets.length,
|
|
40150
|
-
ccTargetsCount: canonicalAction.messageEnvelope.ccTargets.length,
|
|
40151
|
-
inputKind: input.inputKind,
|
|
40152
|
-
membersProjectionLoaded: input.sendTargetReference.status === "loaded",
|
|
40153
|
-
referenceTargetsCount: canonicalAction.messageEnvelope.referenceTargets.length,
|
|
40154
|
-
replyToSignalIdResolved: Boolean(canonicalAction.messageEnvelope.replyToSignalId)
|
|
40155
|
-
}
|
|
40156
|
-
};
|
|
40157
|
-
}
|
|
40158
|
-
function normalizeReplyToSignalId(input) {
|
|
40159
|
-
if (!input.currentReplyToSignalId) {
|
|
40160
|
-
if (input.envelopeReplyToSignalId) throw new Error("post_message.messageEnvelope.replyToSignalId must match the current dispatch reply target");
|
|
40161
|
-
return null;
|
|
40162
|
-
}
|
|
40163
|
-
if (input.envelopeReplyToSignalId && input.envelopeReplyToSignalId !== input.currentReplyToSignalId) throw new Error("post_message.messageEnvelope.replyToSignalId must match the current dispatch reply target");
|
|
40164
|
-
return input.currentReplyToSignalId;
|
|
40165
|
-
}
|
|
40166
|
-
function validateDispatchPostMessageTargets(input) {
|
|
40167
|
-
const { activationTargets, ccTargets, referenceTargets } = input.action.messageEnvelope;
|
|
40168
|
-
if (activationTargets.length === 0 && referenceTargets.length === 0 && ccTargets.length === 0) return;
|
|
40169
|
-
if (input.sendTargetReference.status !== "loaded") throw new Error("post_message.messageEnvelope targets require a current space members projection");
|
|
40170
|
-
const targetByProfileId = new Map(input.sendTargetReference.projection.map((target) => [target.profileId, target]));
|
|
40171
|
-
for (const rule of TARGET_VALIDATION_RULES) {
|
|
40172
|
-
const targets = input.action.messageEnvelope[rule.fieldName];
|
|
40173
|
-
for (const [index, targetProfileId] of targets.entries()) validateDispatchTargetProfileId({
|
|
40174
|
-
fieldName: rule.fieldName,
|
|
40175
|
-
index,
|
|
40176
|
-
relationName: rule.relationName,
|
|
40177
|
-
targetByProfileId,
|
|
40178
|
-
targetProfileId
|
|
40179
|
-
});
|
|
40180
|
-
}
|
|
40181
|
-
}
|
|
40182
|
-
function validateDispatchTargetProfileId(input) {
|
|
40183
|
-
const target = input.targetByProfileId.get(input.targetProfileId);
|
|
40184
|
-
const fieldPath = `post_message.messageEnvelope.${input.fieldName}[${String(input.index)}]`;
|
|
40185
|
-
if (!target) throw new Error(`${fieldPath} must reference an active profile in this space`);
|
|
40186
|
-
if (input.relationName === "wake" && !target.allowedRelations.wake) throw new Error(`${fieldPath} must reference an agent profile in this space`);
|
|
40187
|
-
if (input.relationName === "wake" && target.wakeAvailability.status !== "ready") throw new Error(`${fieldPath} must reference an agent profile available for Wake`);
|
|
40188
|
-
if ((input.relationName === "reference" || input.relationName === "cc") && !target.allowedRelations[input.relationName]) throw new Error(`${fieldPath} must reference an active profile in this space`);
|
|
40189
|
-
}
|
|
40190
|
-
|
|
40191
40169
|
//#endregion
|
|
40192
40170
|
//#region src/space/cli-space-api.ts
|
|
40193
40171
|
function createCliSpaceApi(baseUrl) {
|
|
@@ -42375,9 +42353,27 @@ function buildStructuredActionRepairPrompt(input) {
|
|
|
42375
42353
|
...buildStructuredActionRepairSendTargetReferenceLines(input.sendTargetReferenceLines),
|
|
42376
42354
|
`If you need recent public room context, use \`${historyCommand}\`.`,
|
|
42377
42355
|
`If you need the ATS action rules again, read the official guidance with \`${promptCommand}\` or \`${spaceGuideCommand}\`.`,
|
|
42378
|
-
...normalizedSpaceId ? [`For this room, you can inspect the current guide with \`${spaceGuideCommand}\`.`] : []
|
|
42356
|
+
...normalizedSpaceId ? [`For this room, you can inspect the current guide with \`${spaceGuideCommand}\`.`] : [],
|
|
42357
|
+
...buildStructuredActionRepairCompletionLines({
|
|
42358
|
+
cliEntry,
|
|
42359
|
+
publicationRequirement
|
|
42360
|
+
})
|
|
42379
42361
|
].join("\n");
|
|
42380
42362
|
}
|
|
42363
|
+
function buildStructuredActionRepairCompletionLines(input) {
|
|
42364
|
+
return [
|
|
42365
|
+
"Repair completion rule:",
|
|
42366
|
+
buildStructuredActionRepairPrimaryCommandLine(input),
|
|
42367
|
+
"If the command cannot run, finish with the corrected public answer followed by exactly one valid trailing ```ats-space-action``` block.",
|
|
42368
|
+
"Do not finish with an explanation of what you will do."
|
|
42369
|
+
];
|
|
42370
|
+
}
|
|
42371
|
+
function buildStructuredActionRepairPrimaryCommandLine(input) {
|
|
42372
|
+
if (input.publicationRequirement.allowedActions.includes("post_message")) return `For a normal reply, run \`${input.cliEntry} space action reply "corrected public message"\` now and wait for it to finish.`;
|
|
42373
|
+
if (input.publicationRequirement.allowedActions.includes("post_status")) return `For a final status, run \`${input.cliEntry} space action status done "short completion update"\` now and wait for it to finish.`;
|
|
42374
|
+
if (input.publicationRequirement.allowedActions.includes("stay_silent")) return `If no public reply is needed, run \`${input.cliEntry} space action silent --reason "reason"\` now and wait for it to finish.`;
|
|
42375
|
+
return `Run \`${input.cliEntry} prompt space-action --raw\` now and return one valid trailing ats-space-action block.`;
|
|
42376
|
+
}
|
|
42381
42377
|
function buildStructuredActionRepairSendTargetReferenceLines(sendTargetReferenceLines) {
|
|
42382
42378
|
if (!(sendTargetReferenceLines && sendTargetReferenceLines.length > 0)) return [];
|
|
42383
42379
|
return ["Current send target reference:", ...sendTargetReferenceLines.map((line) => line)];
|
|
@@ -45725,7 +45721,7 @@ function formatDaemonStartStartedNextStep() {
|
|
|
45725
45721
|
}
|
|
45726
45722
|
|
|
45727
45723
|
//#endregion
|
|
45728
|
-
//#region src/commands/
|
|
45724
|
+
//#region src/commands/service.ts
|
|
45729
45725
|
const STATUS_CLEANUP_SIGNIFICANT_ANOMALIES = DAEMON_SERVICE_REPAIR_ANOMALIES;
|
|
45730
45726
|
const AGENT_READINESS_DETAIL_PATTERN = /\b(agents?|profiles?|workspaces?|controllers?)\b|reply route|reply from space|space replies/i;
|
|
45731
45727
|
const DAEMON_STARTUP_BLOCKING_ANOMALIES = new Set([
|