agent-transport-system 0.7.36 → 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 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.36";
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$52(input.dispatch);
2119
- const task = normalizeOptionalText$52(input.task);
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$52(value) {
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$51(homedir());
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$51(input.configuredCommand);
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$51(commandName);
4368
+ const normalizedCommandName = normalizeOptionalText$52(commandName);
4369
4369
  if (!normalizedCommandName) return [];
4370
- const pathValue = normalizeOptionalText$51(process.env.PATH);
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$51(input.commandName);
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$51(input.firstLine);
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$51(firstLine.slice(2));
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$51((await readFile(path, "utf8")).split(FIRST_LINE_SPLIT_RE, 1)[0] ?? "");
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$51(value);
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$51(value) {
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$51(path.match(NODE_VERSION_PATH_RE)?.[1]);
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$50(value) !== null;
4572
+ return normalizeOptionalText$51(value) !== null;
4573
4573
  };
4574
- const normalizeOptionalText$50 = (value) => {
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$49(input.request.agentControllerConversationId);
4879
+ }) : normalizeOptionalText$50(input.request.agentControllerConversationId);
4880
4880
  return {
4881
4881
  ...input.request,
4882
4882
  agentControllerConversationId
4883
4883
  };
4884
4884
  };
4885
- const normalizeOptionalText$49 = (value) => {
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$48(process.env.ATSD_RUNTIME_CLAUDE_CODE_BIN),
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$48(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
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$48(value) {
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$47(record.session_id);
4993
- const resultText = normalizeOptionalText$47(record.result);
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$47(record.message),
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$47(event.type);
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$47(value) {
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$46(input.prompt);
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$46(input.sessionId),
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$46(input.sessionId);
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$46(latestOutput);
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$46(resolvedSessionId),
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$46(input.sessionId) !== null,
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$46(input.stderrText);
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$46(input.stderrText) ? [normalizeOptionalText$46(input.stderrText)] : []
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$46(value);
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$46(line);
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$46(value) {
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$45(input.agentControllerConversationId),
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$45(input.claudeBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$45(input.claudeBin) }) : null);
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$45 = (value) => {
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$44(process.env.ATSD_RUNTIME_CODEX_BIN),
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$44(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
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$44(value) {
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$43(item.phase ?? record.phase);
5720
+ const phase = normalizeOptionalText$44(item.phase ?? record.phase);
5721
5721
  if (phase && phase !== "final_answer") return null;
5722
- const text = normalizeOptionalText$43(item.text);
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$43(response?.output_text);
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$43(record.thread_id);
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$43(value) {
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$42(input.prompt);
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$42(latestOutput);
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$42(input.threadId) !== null,
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$42(resolvedThreadId)
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$42(line);
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$42(record.message);
6022
+ const message = normalizeOptionalText$43(record.message);
6023
6023
  if (record.type === "error" && message) return message;
6024
- const errorMessage = normalizeOptionalText$42((record.error && typeof record.error === "object" && !Array.isArray(record.error) ? record.error : null)?.message);
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$42(input.stderrText);
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$42(input.stderrText) ? [normalizeOptionalText$42(input.stderrText)] : [],
6070
- ...normalizeOptionalText$42(input.stdoutText) ? [normalizeOptionalText$42(input.stdoutText)] : []
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$42(value) {
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$41(input.agentControllerConversationId)
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$41(input.codexBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$41(input.codexBin) }) : null);
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$41 = (value) => {
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$40(process.env.ATSD_RUNTIME_OPENCLAW_BIN),
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$40(explicitOpenClawBin);
6329
+ const explicitCandidate = normalizeOptionalText$41(explicitOpenClawBin);
6330
6330
  if (explicitCandidate) candidates.push(explicitCandidate);
6331
- const configuredCandidate = normalizeOptionalText$40(process.env.ATSD_RUNTIME_OPENCLAW_BIN);
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$40(process.env.ATSD_RUNTIME_REQUEST_TIMEOUT_MS);
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$40(process.env.ATSD_RUNTIME_OPENCLAW_AGENT_ID) ?? DEFAULT_OPENCLAW_AGENT_ID;
6354
+ return normalizeOptionalText$41(process.env.ATSD_RUNTIME_OPENCLAW_AGENT_ID) ?? DEFAULT_OPENCLAW_AGENT_ID;
6355
6355
  }
6356
- function normalizeOptionalText$40(value) {
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$39(record.status)?.toLowerCase();
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$39(record.type)?.toLowerCase();
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$39(value) {
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$38(value);
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$38(record.detail) ?? normalizeOptionalText$38(record.message) ?? (record.error && typeof record.error === "object" && !Array.isArray(record.error) ? normalizeOptionalText$38(record.error.message) : null);
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$38(value) {
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$37(input.prompt);
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$37(input.sessionId)
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$37(latestOutput);
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$37(resolvedSessionId),
6766
+ sessionId: normalizeOptionalText$38(resolvedSessionId),
6767
6767
  telemetry: buildTransportTelemetry({
6768
6768
  driverResult,
6769
6769
  firstStderrAtMs,
6770
6770
  firstStdoutAtMs,
6771
6771
  invokedAtMs,
6772
- resumedContext: normalizeOptionalText$37(input.sessionId) !== null
6772
+ resumedContext: normalizeOptionalText$38(input.sessionId) !== null
6773
6773
  })
6774
6774
  };
6775
6775
  }
6776
6776
  return {
6777
6777
  output,
6778
- sessionId: normalizeOptionalText$37(resolvedSessionId),
6778
+ sessionId: normalizeOptionalText$38(resolvedSessionId),
6779
6779
  telemetry: buildTransportTelemetry({
6780
6780
  driverResult,
6781
6781
  firstStderrAtMs,
6782
6782
  firstStdoutAtMs,
6783
6783
  invokedAtMs,
6784
- resumedContext: normalizeOptionalText$37(input.sessionId) !== null
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$37(input.stderrText);
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$37(input.stderrText) ? [normalizeOptionalText$37(input.stderrText)] : []
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$37(value);
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$37(value);
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$37(line);
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$37(value) {
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$36(env?.OPENCLAW_STATE_DIR);
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$36(input.sessionEntry.sessionFile);
7041
+ const sessionFile = normalizeOptionalText$37(input.sessionEntry.sessionFile);
7042
7042
  if (sessionFile) return isAbsolute(sessionFile) ? sessionFile : join(sessionsDir, sessionFile);
7043
- const sessionId = normalizeOptionalText$36(input.sessionEntry.sessionId);
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$36(record.type) !== "message") return null;
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$36(message.stopReason) !== "error") return null;
7068
- const errorMessage = normalizeOptionalText$36(message.errorMessage);
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$36(value);
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$36(value) {
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$35(input.prompt);
7110
- const sessionKey = normalizeOptionalText$35(input.sessionKey);
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$35(record.status);
7219
+ const status = normalizeOptionalText$36(record.status);
7220
7220
  if (!status || status === "ok") return extractSuccessfulAgentResult(record.result, expectedSessionKey);
7221
- throw classifyGatewayFailure(normalizeOptionalText$35(record.summary) ?? normalizeOptionalText$35(record.error) ?? `openclaw gateway agent returned status '${status}'`);
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$35(systemPromptReport.sessionKey);
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$35(agentMeta.sessionId) : null;
7255
- const reportSessionId = systemPromptReport && typeof systemPromptReport === "object" ? normalizeOptionalText$35(systemPromptReport.sessionId) : null;
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$35(payload.text);
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$35(error?.stderr);
7275
- const stdout = normalizeOptionalText$35(error?.stdout);
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$35(value) {
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$34(agentControllerConversation.agentControllerConversationId);
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$34(input.request.agentControllerConversationId),
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$34(input.openClawBin) ? buildExecutableLaunchContract({ commandPath: normalizeOptionalText$34(input.openClawBin) }) : null);
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$34(input.dispatchEnvAgentId) ?? normalizeOptionalText$34(input.optionAgentId) ?? resolveOpenClawAgentId$1();
7409
- const resolveOpenClawSessionKey = (input) => normalizeOptionalText$34(input.agentControllerConversation?.agentControllerRef === "builtin:openclaw" && input.agentControllerConversation.agentControllerConversationKind === "session" ? input.agentControllerConversation.agentControllerConversationId : null);
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$34(input.input.agentControllerConversationId) !== null,
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$34(input.input.agentControllerConversationId)
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$34(value) {
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$33(input.legacyAgentControllerConversationId);
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$33(input.agentControllerConversationId);
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$33(value) {
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$32(input.agentControllerConversationId);
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$32(parsedTask.targetProfileMentionLabel);
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$32(value) {
11175
+ function normalizeOptionalText$33(value) {
11176
11176
  const normalized = value?.trim();
11177
11177
  return normalized ? normalized : null;
11178
11178
  }
@@ -11615,6 +11615,113 @@ function mergeOpenClawGatewayVisibility(input) {
11615
11615
  };
11616
11616
  }
11617
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
+
11618
11725
  //#endregion
11619
11726
  //#region ../../runtime/local-service/src/service-reconcile-decision.ts
11620
11727
  function resolveProjectionReconcileDecision(input) {
@@ -31845,7 +31952,7 @@ var SpaceComposerSubmissionError = class extends Error {
31845
31952
  };
31846
31953
  function prepareSpaceComposerSubmission(input) {
31847
31954
  const canonicalFragments = collectCanonicalMentionTextFragments(input.text);
31848
- const replyToSignalId = normalizeReplyToSignalId$1(input.replyTo);
31955
+ const replyToSignalId = normalizeReplyToSignalId(input.replyTo);
31849
31956
  const replyTo = replyToSignalId ? { signalId: replyToSignalId } : null;
31850
31957
  if (canonicalFragments.length === 0) {
31851
31958
  const normalizedText = normalizePlainTextOrThrow(input.text);
@@ -31928,7 +32035,7 @@ function createEnvelopeInput(text, replyToSignalId) {
31928
32035
  text
31929
32036
  };
31930
32037
  }
31931
- function normalizeReplyToSignalId$1(replyTo) {
32038
+ function normalizeReplyToSignalId(replyTo) {
31932
32039
  if (!replyTo) return null;
31933
32040
  const signalId = replyTo.signalId.trim();
31934
32041
  if (signalId.length === 0) throw createSubmissionError("addressing.invalid_reply_target", "replyTo.signalId must be a non-empty string.");
@@ -38125,31 +38232,6 @@ function projectSpaceProfileCache(spaceConfig) {
38125
38232
  };
38126
38233
  }
38127
38234
 
38128
- //#endregion
38129
- //#region src/local-service/dispatch/reply-context.ts
38130
- function buildDispatchReplyContextSummary(replyToSnapshot) {
38131
- const previewText = normalizeOptionalText$29(replyToSnapshot?.previewText);
38132
- const replyToSignalId = normalizeOptionalText$29(replyToSnapshot?.signalId);
38133
- if (previewText) return {
38134
- previewText,
38135
- replyToSignalId,
38136
- resolved: true,
38137
- summary: previewText
38138
- };
38139
- if (replyToSignalId) return {
38140
- previewText: null,
38141
- replyToSignalId,
38142
- resolved: true,
38143
- summary: `signal ${replyToSignalId}`
38144
- };
38145
- return {
38146
- previewText: null,
38147
- replyToSignalId: null,
38148
- resolved: false,
38149
- summary: "the current source message"
38150
- };
38151
- }
38152
-
38153
38235
  //#endregion
38154
38236
  //#region src/local-service/dispatch/parse-dispatch-task.ts
38155
38237
  const ATS_SPACE_DEFINITION = buildAgentFacingMentalModelLines().slice(0, 2).join(" ");
@@ -40084,84 +40166,6 @@ function normalizeOptionalText$12(value) {
40084
40166
  return normalized.length > 0 ? normalized : null;
40085
40167
  }
40086
40168
 
40087
- //#endregion
40088
- //#region src/local-service/dispatch/post-message-envelope.ts
40089
- const TARGET_VALIDATION_RULES = [
40090
- {
40091
- fieldName: "activationTargets",
40092
- relationName: "wake"
40093
- },
40094
- {
40095
- fieldName: "referenceTargets",
40096
- relationName: "reference"
40097
- },
40098
- {
40099
- fieldName: "ccTargets",
40100
- relationName: "cc"
40101
- }
40102
- ];
40103
- function normalizeDispatchPostMessageAction(input) {
40104
- const normalizedEnvelope = normalizeMessageEnvelope(input.action.messageEnvelope);
40105
- const replyToSignalId = normalizeReplyToSignalId({
40106
- currentReplyToSignalId: input.currentReplyToSignalId,
40107
- envelopeReplyToSignalId: normalizedEnvelope.replyToSignalId ?? null
40108
- });
40109
- const canonicalAction = {
40110
- ...input.action,
40111
- messageEnvelope: {
40112
- ...normalizedEnvelope,
40113
- ...replyToSignalId ? { replyToSignalId } : {}
40114
- }
40115
- };
40116
- validateDispatchPostMessageTargets({
40117
- action: canonicalAction,
40118
- sendTargetReference: input.sendTargetReference
40119
- });
40120
- return {
40121
- action: canonicalAction,
40122
- tracePayload: {
40123
- activationTargetsCount: canonicalAction.messageEnvelope.activationTargets.length,
40124
- ccTargetsCount: canonicalAction.messageEnvelope.ccTargets.length,
40125
- inputKind: input.inputKind,
40126
- membersProjectionLoaded: input.sendTargetReference.status === "loaded",
40127
- referenceTargetsCount: canonicalAction.messageEnvelope.referenceTargets.length,
40128
- replyToSignalIdResolved: Boolean(canonicalAction.messageEnvelope.replyToSignalId)
40129
- }
40130
- };
40131
- }
40132
- function normalizeReplyToSignalId(input) {
40133
- if (!input.currentReplyToSignalId) {
40134
- if (input.envelopeReplyToSignalId) throw new Error("post_message.messageEnvelope.replyToSignalId must match the current dispatch reply target");
40135
- return null;
40136
- }
40137
- if (input.envelopeReplyToSignalId && input.envelopeReplyToSignalId !== input.currentReplyToSignalId) throw new Error("post_message.messageEnvelope.replyToSignalId must match the current dispatch reply target");
40138
- return input.currentReplyToSignalId;
40139
- }
40140
- function validateDispatchPostMessageTargets(input) {
40141
- const { activationTargets, ccTargets, referenceTargets } = input.action.messageEnvelope;
40142
- if (activationTargets.length === 0 && referenceTargets.length === 0 && ccTargets.length === 0) return;
40143
- if (input.sendTargetReference.status !== "loaded") throw new Error("post_message.messageEnvelope targets require a current space members projection");
40144
- const targetByProfileId = new Map(input.sendTargetReference.projection.map((target) => [target.profileId, target]));
40145
- for (const rule of TARGET_VALIDATION_RULES) {
40146
- const targets = input.action.messageEnvelope[rule.fieldName];
40147
- for (const [index, targetProfileId] of targets.entries()) validateDispatchTargetProfileId({
40148
- fieldName: rule.fieldName,
40149
- index,
40150
- relationName: rule.relationName,
40151
- targetByProfileId,
40152
- targetProfileId
40153
- });
40154
- }
40155
- }
40156
- function validateDispatchTargetProfileId(input) {
40157
- const target = input.targetByProfileId.get(input.targetProfileId);
40158
- const fieldPath = `post_message.messageEnvelope.${input.fieldName}[${String(input.index)}]`;
40159
- if (!target) throw new Error(`${fieldPath} must reference an active profile in this space`);
40160
- if (input.relationName === "wake" && !target.allowedRelations.wake) throw new Error(`${fieldPath} must reference an agent profile in this space`);
40161
- if (input.relationName === "wake" && target.wakeAvailability.status !== "ready") throw new Error(`${fieldPath} must reference an agent profile available for Wake`);
40162
- if ((input.relationName === "reference" || input.relationName === "cc") && !target.allowedRelations[input.relationName]) throw new Error(`${fieldPath} must reference an active profile in this space`);
40163
- }
40164
-
40165
40169
  //#endregion
40166
40170
  //#region src/space/cli-space-api.ts
40167
40171
  function createCliSpaceApi(baseUrl) {
@@ -45717,7 +45721,7 @@ function formatDaemonStartStartedNextStep() {
45717
45721
  }
45718
45722
 
45719
45723
  //#endregion
45720
- //#region src/commands/daemon.ts
45724
+ //#region src/commands/service.ts
45721
45725
  const STATUS_CLEANUP_SIGNIFICANT_ANOMALIES = DAEMON_SERVICE_REPAIR_ANOMALIES;
45722
45726
  const AGENT_READINESS_DETAIL_PATTERN = /\b(agents?|profiles?|workspaces?|controllers?)\b|reply route|reply from space|space replies/i;
45723
45727
  const DAEMON_STARTUP_BLOCKING_ANOMALIES = new Set([