agent-transport-system 0.7.35 → 0.7.36
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 +78 -86
- 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.36";
|
|
31
31
|
var package_default = {
|
|
32
32
|
$schema: "https://www.schemastore.org/package.json",
|
|
33
33
|
name: "agent-transport-system",
|
|
@@ -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();
|
|
@@ -38338,6 +38293,8 @@ function buildDispatchPromptWithBootstrap(input) {
|
|
|
38338
38293
|
if (input.shouldInjectBootstrap && isEntryBriefEnabled(input)) sections.push(renderEntryBriefSection(input));
|
|
38339
38294
|
if ((input.spaceContractSnapshot?.dispatchBrief ?? "default") !== "none") sections.push(renderDispatchBriefSection(input));
|
|
38340
38295
|
sections.push(["Current Wake message:", prompt].join("\n"));
|
|
38296
|
+
const completionSection = renderMandatoryCompletionSection(input);
|
|
38297
|
+
if (completionSection) sections.push(completionSection);
|
|
38341
38298
|
return sections.filter(Boolean).join("\n\n");
|
|
38342
38299
|
}
|
|
38343
38300
|
function buildDispatchBootstrapTemplateFacts(input) {
|
|
@@ -38407,6 +38364,23 @@ function renderDispatchBriefSection(input) {
|
|
|
38407
38364
|
...buildSendTargetReferenceLines(input)
|
|
38408
38365
|
].filter(Boolean).join("\n");
|
|
38409
38366
|
}
|
|
38367
|
+
function renderMandatoryCompletionSection(input) {
|
|
38368
|
+
const publicationRequirement = resolveSpacePublicationRequirement(input.spaceContractSnapshot);
|
|
38369
|
+
if (publicationRequirement.allowsRawReplyWithoutAction) return null;
|
|
38370
|
+
return [
|
|
38371
|
+
"Mandatory completion:",
|
|
38372
|
+
"- 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.",
|
|
38373
|
+
buildMandatoryCompletionActionLine(input, publicationRequirement),
|
|
38374
|
+
"- After the Space Action command succeeds, stop. ATS reads that command as the public outcome.",
|
|
38375
|
+
`- Use fallback JSON only if the Space Action command cannot run: \`${buildPromptSpaceActionCommand(input)}\`.`
|
|
38376
|
+
].join("\n");
|
|
38377
|
+
}
|
|
38378
|
+
function buildMandatoryCompletionActionLine(input, publicationRequirement) {
|
|
38379
|
+
if (publicationRequirement.allowedActions.includes("post_message")) return `- Normal completion: run \`${buildSpaceActionCommand(input, "reply \"your public message\"")}\` and wait for it to finish.`;
|
|
38380
|
+
if (publicationRequirement.allowedActions.includes("post_status")) return `- Normal completion: run \`${buildSpaceActionCommand(input, "status done \"short completion update\"")}\` and wait for it to finish.`;
|
|
38381
|
+
if (publicationRequirement.allowedActions.includes("stay_silent")) return `- Normal completion: run \`${buildSpaceActionCommand(input, "silent --reason \"reason\"")}\` and wait for it to finish.`;
|
|
38382
|
+
return `- Normal completion: run \`${buildPromptSpaceActionCommand(input)}\` and return one valid trailing ats-space-action block.`;
|
|
38383
|
+
}
|
|
38410
38384
|
function buildServiceFreshnessWarningLines(input) {
|
|
38411
38385
|
return input.serviceFreshnessWarningLines?.filter(Boolean) ?? [];
|
|
38412
38386
|
}
|
|
@@ -42375,9 +42349,27 @@ function buildStructuredActionRepairPrompt(input) {
|
|
|
42375
42349
|
...buildStructuredActionRepairSendTargetReferenceLines(input.sendTargetReferenceLines),
|
|
42376
42350
|
`If you need recent public room context, use \`${historyCommand}\`.`,
|
|
42377
42351
|
`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}\`.`] : []
|
|
42352
|
+
...normalizedSpaceId ? [`For this room, you can inspect the current guide with \`${spaceGuideCommand}\`.`] : [],
|
|
42353
|
+
...buildStructuredActionRepairCompletionLines({
|
|
42354
|
+
cliEntry,
|
|
42355
|
+
publicationRequirement
|
|
42356
|
+
})
|
|
42379
42357
|
].join("\n");
|
|
42380
42358
|
}
|
|
42359
|
+
function buildStructuredActionRepairCompletionLines(input) {
|
|
42360
|
+
return [
|
|
42361
|
+
"Repair completion rule:",
|
|
42362
|
+
buildStructuredActionRepairPrimaryCommandLine(input),
|
|
42363
|
+
"If the command cannot run, finish with the corrected public answer followed by exactly one valid trailing ```ats-space-action``` block.",
|
|
42364
|
+
"Do not finish with an explanation of what you will do."
|
|
42365
|
+
];
|
|
42366
|
+
}
|
|
42367
|
+
function buildStructuredActionRepairPrimaryCommandLine(input) {
|
|
42368
|
+
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.`;
|
|
42369
|
+
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.`;
|
|
42370
|
+
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.`;
|
|
42371
|
+
return `Run \`${input.cliEntry} prompt space-action --raw\` now and return one valid trailing ats-space-action block.`;
|
|
42372
|
+
}
|
|
42381
42373
|
function buildStructuredActionRepairSendTargetReferenceLines(sendTargetReferenceLines) {
|
|
42382
42374
|
if (!(sendTargetReferenceLines && sendTargetReferenceLines.length > 0)) return [];
|
|
42383
42375
|
return ["Current send target reference:", ...sendTargetReferenceLines.map((line) => line)];
|