agent-transport-system 0.7.18 → 0.7.19
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 +149 -5
- 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.19";
|
|
31
31
|
var package_default = {
|
|
32
32
|
$schema: "https://www.schemastore.org/package.json",
|
|
33
33
|
name: "agent-transport-system",
|
|
@@ -39584,6 +39584,7 @@ function normalizeOptionalText$12(value) {
|
|
|
39584
39584
|
//#region src/daemon/dispatch/execute-dispatch-task.ts
|
|
39585
39585
|
const BOOTSTRAP_IDLE_STALE_MS = 1440 * 60 * 1e3;
|
|
39586
39586
|
const BOOTSTRAP_DISPATCH_STALE_THRESHOLD = 12;
|
|
39587
|
+
const CLI_SPACE_ACTION_RECORD_POLL_INTERVAL_MS = 25;
|
|
39587
39588
|
const DEFAULT_CONVERSATION_POLICY = {};
|
|
39588
39589
|
const STRUCTURED_SPACE_ACTION_BLOCK_HEADER_REGEX = /^\s*\r?\n?/u;
|
|
39589
39590
|
function mergeOpenClawGatewayVisibility(input) {
|
|
@@ -40275,7 +40276,7 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
40275
40276
|
phase: "runtime_invocation_started",
|
|
40276
40277
|
result: "started"
|
|
40277
40278
|
});
|
|
40278
|
-
|
|
40279
|
+
const runtimeExecutionPromise = Promise.resolve(runDispatchRuntimeExecution({
|
|
40279
40280
|
contextId: contextIdForDispatch,
|
|
40280
40281
|
executionMode: "normal",
|
|
40281
40282
|
io: ledgerIo,
|
|
@@ -40356,12 +40357,15 @@ async function handleDispatchDeliverFrame(input) {
|
|
|
40356
40357
|
runtimeEnvOverrides,
|
|
40357
40358
|
runtimeControllerSupport,
|
|
40358
40359
|
agentControllerConversationOverride
|
|
40359
|
-
});
|
|
40360
|
-
runtimeResult =
|
|
40360
|
+
}));
|
|
40361
|
+
let runtimeResult = await resolveRuntimeResultFromRuntimeOrCliSpaceAction({
|
|
40362
|
+
contextIdForDispatch,
|
|
40361
40363
|
dispatchSpaceActionContext,
|
|
40364
|
+
ledgerIo,
|
|
40365
|
+
ledgerPaths: input.ledgerPaths,
|
|
40362
40366
|
parsedTask,
|
|
40363
40367
|
presenter: input.presenter,
|
|
40364
|
-
|
|
40368
|
+
runtimeExecutionPromise
|
|
40365
40369
|
});
|
|
40366
40370
|
const structuredSpaceActionOutcome = await resolveRuntimeResultStructuredSpaceAction({
|
|
40367
40371
|
ledgerIo,
|
|
@@ -40874,6 +40878,146 @@ function createDispatchSpaceActionRuntimeContext(input) {
|
|
|
40874
40878
|
}
|
|
40875
40879
|
};
|
|
40876
40880
|
}
|
|
40881
|
+
async function resolveRuntimeResultFromRuntimeOrCliSpaceAction(input) {
|
|
40882
|
+
if (!input.dispatchSpaceActionContext) return await input.runtimeExecutionPromise;
|
|
40883
|
+
const cliSpaceActionAbortController = new AbortController();
|
|
40884
|
+
let completion;
|
|
40885
|
+
try {
|
|
40886
|
+
completion = await Promise.race([input.runtimeExecutionPromise.then((runtimeResult) => ({
|
|
40887
|
+
kind: "runtime",
|
|
40888
|
+
runtimeResult
|
|
40889
|
+
})), waitForCliSpaceActionRecord({
|
|
40890
|
+
dispatchSpaceActionContext: input.dispatchSpaceActionContext,
|
|
40891
|
+
signal: cliSpaceActionAbortController.signal
|
|
40892
|
+
})]);
|
|
40893
|
+
} finally {
|
|
40894
|
+
cliSpaceActionAbortController.abort();
|
|
40895
|
+
}
|
|
40896
|
+
if (completion.kind === "runtime") return applyCliSpaceActionRecordIfPresent({
|
|
40897
|
+
dispatchSpaceActionContext: input.dispatchSpaceActionContext,
|
|
40898
|
+
parsedTask: input.parsedTask,
|
|
40899
|
+
presenter: input.presenter,
|
|
40900
|
+
runtimeResult: completion.runtimeResult
|
|
40901
|
+
});
|
|
40902
|
+
if (completion.kind === "cli_space_action_poll_aborted") return await input.runtimeExecutionPromise;
|
|
40903
|
+
input.runtimeExecutionPromise.catch((error) => {
|
|
40904
|
+
emitRunLine({
|
|
40905
|
+
presenter: input.presenter,
|
|
40906
|
+
code: "daemon.run.runtime_ignored_after_cli_space_action",
|
|
40907
|
+
text: `runtime completed after CLI ATS Space Action finalized task ${input.parsedTask.taskId}`,
|
|
40908
|
+
payload: {
|
|
40909
|
+
dispatchId: input.parsedTask.dispatchId,
|
|
40910
|
+
errorMessage: toErrorMessage$34(error),
|
|
40911
|
+
targetProfileId: input.parsedTask.targetProfileId,
|
|
40912
|
+
taskId: input.parsedTask.taskId
|
|
40913
|
+
}
|
|
40914
|
+
});
|
|
40915
|
+
});
|
|
40916
|
+
if (completion.kind === "cli_space_action_invalid") throw new DaemonServiceRunError({
|
|
40917
|
+
code: "dispatch.cli_space_action.invalid",
|
|
40918
|
+
message: completion.errorMessage
|
|
40919
|
+
});
|
|
40920
|
+
emitRunLine({
|
|
40921
|
+
presenter: input.presenter,
|
|
40922
|
+
code: "daemon.run.cli_space_action_finalized",
|
|
40923
|
+
text: `CLI ATS Space Action finalized task ${input.parsedTask.taskId}`,
|
|
40924
|
+
payload: {
|
|
40925
|
+
command: completion.record.command,
|
|
40926
|
+
dispatchId: input.parsedTask.dispatchId,
|
|
40927
|
+
spaceActionType: completion.record.action.type,
|
|
40928
|
+
targetProfileId: input.parsedTask.targetProfileId,
|
|
40929
|
+
taskId: input.parsedTask.taskId
|
|
40930
|
+
}
|
|
40931
|
+
});
|
|
40932
|
+
return await buildCliSpaceActionRuntimeResult({
|
|
40933
|
+
contextIdForDispatch: input.contextIdForDispatch,
|
|
40934
|
+
ledgerIo: input.ledgerIo,
|
|
40935
|
+
ledgerPaths: input.ledgerPaths,
|
|
40936
|
+
parsedTask: input.parsedTask,
|
|
40937
|
+
record: completion.record
|
|
40938
|
+
});
|
|
40939
|
+
}
|
|
40940
|
+
async function waitForCliSpaceActionRecord(input) {
|
|
40941
|
+
while (!input.signal.aborted) {
|
|
40942
|
+
const readResult = readDispatchSpaceActionRecord({ context: input.dispatchSpaceActionContext });
|
|
40943
|
+
if (readResult.status === "loaded") return {
|
|
40944
|
+
kind: "cli_space_action_recorded",
|
|
40945
|
+
record: readResult.record
|
|
40946
|
+
};
|
|
40947
|
+
if (readResult.status === "invalid") return {
|
|
40948
|
+
kind: "cli_space_action_invalid",
|
|
40949
|
+
errorMessage: readResult.errorMessage
|
|
40950
|
+
};
|
|
40951
|
+
try {
|
|
40952
|
+
await setTimeout$1(CLI_SPACE_ACTION_RECORD_POLL_INTERVAL_MS, void 0, { signal: input.signal });
|
|
40953
|
+
} catch (error) {
|
|
40954
|
+
if (input.signal.aborted) return { kind: "cli_space_action_poll_aborted" };
|
|
40955
|
+
throw error;
|
|
40956
|
+
}
|
|
40957
|
+
}
|
|
40958
|
+
return { kind: "cli_space_action_poll_aborted" };
|
|
40959
|
+
}
|
|
40960
|
+
async function buildCliSpaceActionRuntimeResult(input) {
|
|
40961
|
+
const output = resolveStructuredActionOutputFallback({
|
|
40962
|
+
action: input.record.action,
|
|
40963
|
+
cleanedOutput: ""
|
|
40964
|
+
});
|
|
40965
|
+
const resultPayload = {
|
|
40966
|
+
...buildTaskResultPayloadFromOutcome({
|
|
40967
|
+
agentId: input.parsedTask.targetProfileId,
|
|
40968
|
+
attemptId: input.parsedTask.attemptId,
|
|
40969
|
+
deduped: false,
|
|
40970
|
+
emitFailed: false,
|
|
40971
|
+
output,
|
|
40972
|
+
sourceEventId: input.parsedTask.sourceEventId,
|
|
40973
|
+
taskId: input.parsedTask.taskId
|
|
40974
|
+
}),
|
|
40975
|
+
spaceAction: input.record.action,
|
|
40976
|
+
spaceActionProvenance: "cli_action"
|
|
40977
|
+
};
|
|
40978
|
+
const state = await withLedgerStateTransaction({
|
|
40979
|
+
invalidStateStrategy: "backup_and_reset",
|
|
40980
|
+
io: input.ledgerIo,
|
|
40981
|
+
mutate: (state) => {
|
|
40982
|
+
const nextState = settleInflightTask({
|
|
40983
|
+
state,
|
|
40984
|
+
taskId: input.parsedTask.taskId
|
|
40985
|
+
});
|
|
40986
|
+
return {
|
|
40987
|
+
nextState,
|
|
40988
|
+
value: nextState
|
|
40989
|
+
};
|
|
40990
|
+
},
|
|
40991
|
+
paths: input.ledgerPaths
|
|
40992
|
+
});
|
|
40993
|
+
await appendLedgerHistoryEntry({
|
|
40994
|
+
entry: {
|
|
40995
|
+
message: "task finalized from CLI Space Action",
|
|
40996
|
+
reasonCode: "task.cli_space_action",
|
|
40997
|
+
status: resultPayload.status,
|
|
40998
|
+
taskId: input.parsedTask.taskId,
|
|
40999
|
+
ts: (/* @__PURE__ */ new Date()).toISOString()
|
|
41000
|
+
},
|
|
41001
|
+
io: input.ledgerIo,
|
|
41002
|
+
paths: input.ledgerPaths
|
|
41003
|
+
});
|
|
41004
|
+
return {
|
|
41005
|
+
agentContextLifecycleCounters: state.agentContextLifecycleCounters,
|
|
41006
|
+
deduped: false,
|
|
41007
|
+
dispatchResult: {
|
|
41008
|
+
adapterResult: {
|
|
41009
|
+
...input.contextIdForDispatch ? { contextDelta: { agentControllerConversationId: input.contextIdForDispatch } } : {},
|
|
41010
|
+
output,
|
|
41011
|
+
status: "success"
|
|
41012
|
+
},
|
|
41013
|
+
dispatched: true,
|
|
41014
|
+
reason: "dispatched"
|
|
41015
|
+
},
|
|
41016
|
+
resultPayload,
|
|
41017
|
+
runtimeState: "idle",
|
|
41018
|
+
state
|
|
41019
|
+
};
|
|
41020
|
+
}
|
|
40877
41021
|
function applyCliSpaceActionRecordIfPresent(input) {
|
|
40878
41022
|
if (!input.dispatchSpaceActionContext) return input.runtimeResult;
|
|
40879
41023
|
const readResult = readDispatchSpaceActionRecord({ context: input.dispatchSpaceActionContext });
|