agent-transport-system 0.2.7 → 0.2.8
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 +113 -31
- package/dist/ats.js.map +1 -1
- package/package.json +1 -1
package/dist/ats.js
CHANGED
|
@@ -23,7 +23,7 @@ import wrapAnsi from "wrap-ansi";
|
|
|
23
23
|
import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybindings, matchesKey } from "@mariozechner/pi-tui";
|
|
24
24
|
|
|
25
25
|
//#region package.json
|
|
26
|
-
var version$1 = "0.2.
|
|
26
|
+
var version$1 = "0.2.8";
|
|
27
27
|
var package_default = {
|
|
28
28
|
name: "agent-transport-system",
|
|
29
29
|
version: version$1,
|
|
@@ -2934,6 +2934,9 @@ async function getDaemonRuntimeStatus(pathInput = {}) {
|
|
|
2934
2934
|
autoStart: state.autoStart
|
|
2935
2935
|
};
|
|
2936
2936
|
}
|
|
2937
|
+
async function readDaemonServiceRuntimeSnapshot(pathInput = {}) {
|
|
2938
|
+
return await readDaemonServiceRuntimeState(pathInput);
|
|
2939
|
+
}
|
|
2937
2940
|
function resolveDaemonServiceRuntimeMetadata(input = {}) {
|
|
2938
2941
|
const env = input.env ?? process.env;
|
|
2939
2942
|
const managedBySystemService = input.managedBySystemService === true || env[DAEMON_SERVICE_RUNTIME_SYSTEM_SERVICE_ENV] === "1";
|
|
@@ -14399,12 +14402,26 @@ function matchesDaemonCliLane(normalizedCommand, preset, pathInput) {
|
|
|
14399
14402
|
return normalizedCommand.includes(ATS_PACKAGE_INSTALL_ENTRY_SEGMENT) && !normalizedCommand.includes(canaryPackageInstallRoot) && !normalizedCommand.includes(ATS_DEV_LOCAL_ENTRY_SEGMENT);
|
|
14400
14403
|
}
|
|
14401
14404
|
function collapseLauncherWrapperProcesses(processes) {
|
|
14402
|
-
const launcherPidSet =
|
|
14405
|
+
const launcherPidSet = /* @__PURE__ */ new Set();
|
|
14406
|
+
for (const processInfo of processes) if (processInfo.ownership === "stable_launcher") launcherPidSet.add(processInfo.pid);
|
|
14403
14407
|
if (launcherPidSet.size === 0) return processes;
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
+
const collapsedProcesses = [];
|
|
14409
|
+
for (const processInfo of processes) {
|
|
14410
|
+
if (processInfo.ownership === "stable_launcher") {
|
|
14411
|
+
if (processes.some((candidate) => candidate.pid !== processInfo.pid && candidate.parentPid === processInfo.pid && candidate.ownership !== "stable_launcher")) continue;
|
|
14412
|
+
collapsedProcesses.push(processInfo);
|
|
14413
|
+
continue;
|
|
14414
|
+
}
|
|
14415
|
+
if (processInfo.parentPid !== null && launcherPidSet.has(processInfo.parentPid)) {
|
|
14416
|
+
collapsedProcesses.push({
|
|
14417
|
+
...processInfo,
|
|
14418
|
+
ownership: processInfo.ownership === "unknown" ? processInfo.ownership : "stable_launcher"
|
|
14419
|
+
});
|
|
14420
|
+
continue;
|
|
14421
|
+
}
|
|
14422
|
+
collapsedProcesses.push(processInfo);
|
|
14423
|
+
}
|
|
14424
|
+
return collapsedProcesses;
|
|
14408
14425
|
}
|
|
14409
14426
|
async function listWindowsProcesses() {
|
|
14410
14427
|
const output = await runCommand$1("powershell", [
|
|
@@ -15307,8 +15324,9 @@ function buildBlockedAlignmentResult(input) {
|
|
|
15307
15324
|
};
|
|
15308
15325
|
}
|
|
15309
15326
|
async function resolveAlignmentCommandOptions(input) {
|
|
15310
|
-
const [currentContract, runtimePaths, fallbackProfile] = await Promise.all([
|
|
15327
|
+
const [currentContract, runtimeSnapshot, runtimePaths, fallbackProfile] = await Promise.all([
|
|
15311
15328
|
Promise.resolve(input.inventory.serviceContract ?? readDaemonServiceContract()).catch(() => null),
|
|
15329
|
+
readDaemonServiceRuntimeSnapshot().catch(() => null),
|
|
15312
15330
|
ensureDaemonRuntimePaths().catch(() => null),
|
|
15313
15331
|
resolveAtsProfileOrNull({
|
|
15314
15332
|
allowDefaultFallback: true,
|
|
@@ -15316,8 +15334,8 @@ async function resolveAlignmentCommandOptions(input) {
|
|
|
15316
15334
|
persistSelection: false
|
|
15317
15335
|
}).catch(() => null)
|
|
15318
15336
|
]);
|
|
15319
|
-
const gatewayUrl = await Promise.resolve(resolveBaseUrl(input.gatewayUrl ?? currentContract?.gatewayUrl ?? void 0)).catch(() => input.gatewayUrl ?? currentContract?.gatewayUrl);
|
|
15320
|
-
const profile =
|
|
15337
|
+
const gatewayUrl = await Promise.resolve(resolveBaseUrl(input.gatewayUrl ?? currentContract?.gatewayUrl ?? runtimeSnapshot?.gatewayUrl ?? void 0)).catch(() => input.gatewayUrl ?? currentContract?.gatewayUrl ?? runtimeSnapshot?.gatewayUrl);
|
|
15338
|
+
const profile = normalizeOptionalText$21(input.profile) ?? currentContract?.profileId ?? normalizeOptionalText$21(runtimeSnapshot?.profile) ?? fallbackProfile?.atsProfileId;
|
|
15321
15339
|
const deviceId = runtimePaths ? await resolveDaemonDeviceId({
|
|
15322
15340
|
deviceId: input.deviceId ?? currentContract?.deviceId,
|
|
15323
15341
|
deviceIdPath: runtimePaths.deviceIdPath
|
|
@@ -22699,6 +22717,11 @@ const classifyCodexFailure = (input) => {
|
|
|
22699
22717
|
errorType: "adapter",
|
|
22700
22718
|
message: providerMessage
|
|
22701
22719
|
};
|
|
22720
|
+
if (isConfigFailure(lowered)) return {
|
|
22721
|
+
code: "config.invalid",
|
|
22722
|
+
errorType: "config",
|
|
22723
|
+
message: toConfigInvalidMessage(providerMessage)
|
|
22724
|
+
};
|
|
22702
22725
|
}
|
|
22703
22726
|
const stderrText = normalizeOptionalText$12(input.stderrText);
|
|
22704
22727
|
if (stderrText) return {
|
|
@@ -22730,6 +22753,12 @@ const isQuotaFailure$1 = (value) => {
|
|
|
22730
22753
|
const isRateLimitFailure$1 = (value) => {
|
|
22731
22754
|
return value.includes("429") || value.includes("rate limit") || value.includes("too many requests");
|
|
22732
22755
|
};
|
|
22756
|
+
const isConfigFailure = (value) => {
|
|
22757
|
+
return value.includes("model_not_found") || value.includes("requested model") || value.includes("unknown model") || value.includes("invalid model") || value.includes("does not exist") && value.includes("model") || value.includes("invalid_request_error") && value.includes("model") || value.includes("\"param\": \"model\"");
|
|
22758
|
+
};
|
|
22759
|
+
const toConfigInvalidMessage = (value) => {
|
|
22760
|
+
return value.toLowerCase().startsWith("config.invalid:") ? value : `config.invalid: ${value}`;
|
|
22761
|
+
};
|
|
22733
22762
|
function normalizeText$4(value) {
|
|
22734
22763
|
return String(value ?? "").trim();
|
|
22735
22764
|
}
|
|
@@ -33552,11 +33581,11 @@ function emitDaemonRecoveredStartedState(input) {
|
|
|
33552
33581
|
});
|
|
33553
33582
|
}
|
|
33554
33583
|
async function resolveDaemonServiceProfileId(input) {
|
|
33555
|
-
const explicitProfile =
|
|
33584
|
+
const explicitProfile = normalizeOptionalText$21(input.explicitProfile);
|
|
33556
33585
|
if (explicitProfile) return explicitProfile;
|
|
33557
|
-
const sessionProfile =
|
|
33586
|
+
const sessionProfile = normalizeOptionalText$21(input.runtime.profile) ?? normalizeOptionalText$21(input.runtime.atsProfileId);
|
|
33558
33587
|
if (sessionProfile) return sessionProfile;
|
|
33559
|
-
const selectedProfileId =
|
|
33588
|
+
const selectedProfileId = normalizeOptionalText$21(getCurrentCommandCheckState().selectedProfile?.atsProfileId);
|
|
33560
33589
|
if (selectedProfileId) return selectedProfileId;
|
|
33561
33590
|
return (await resolveAtsProfileOrNull({
|
|
33562
33591
|
allowDefaultFallback: input.runtime.resolvedView === "human",
|
|
@@ -34650,7 +34679,7 @@ async function resolveServiceStatus() {
|
|
|
34650
34679
|
installedVersion: daemonStatus.state.daemonVersion
|
|
34651
34680
|
};
|
|
34652
34681
|
const runtime = await readCurrentDaemonRuntimeContext({ status: daemonStatus }).catch(() => null);
|
|
34653
|
-
if (!runtime || runtime.effectiveRuntimeStatus !== "running"
|
|
34682
|
+
if (!runtime || runtime.effectiveRuntimeStatus !== "running") return {
|
|
34654
34683
|
kind: "not_running",
|
|
34655
34684
|
runtimeStatus: runtime?.runtimeStatus ?? null
|
|
34656
34685
|
};
|
|
@@ -49262,17 +49291,16 @@ function buildHumanLogsSections(input) {
|
|
|
49262
49291
|
lines: buildMembershipTraceRows(block)
|
|
49263
49292
|
}];
|
|
49264
49293
|
});
|
|
49265
|
-
const systemItems = input.allBlocks.flatMap((block, index) => {
|
|
49266
|
-
if (block.kind !== "system_group") return [];
|
|
49267
|
-
return [{
|
|
49268
|
-
id: `system:${String(index)}`,
|
|
49269
|
-
lines: buildSystemClusterRowsFromSystemLines(block.lines)
|
|
49270
|
-
}];
|
|
49271
|
-
});
|
|
49272
49294
|
return [
|
|
49273
|
-
buildHumanLogsSection("
|
|
49295
|
+
buildHumanLogsSection("system", "System", input.allBlocks.flatMap((block, index) => {
|
|
49296
|
+
if (block.kind !== "system_group") return [];
|
|
49297
|
+
return [{
|
|
49298
|
+
id: `system:${String(index)}`,
|
|
49299
|
+
lines: buildSystemClusterRowsFromSystemLines(block.lines)
|
|
49300
|
+
}];
|
|
49301
|
+
})),
|
|
49274
49302
|
buildHumanLogsSection("membership", "Membership", membershipItems),
|
|
49275
|
-
buildHumanLogsSection("
|
|
49303
|
+
buildHumanLogsSection("presence", "Presence", presenceItems)
|
|
49276
49304
|
];
|
|
49277
49305
|
}
|
|
49278
49306
|
function buildHumanLogsSection(kind, title, items) {
|
|
@@ -50478,6 +50506,7 @@ function toComposerActivityRowCandidate(input) {
|
|
|
50478
50506
|
return {
|
|
50479
50507
|
key: input.row.rowId,
|
|
50480
50508
|
mode: previewText ? "streaming" : "replying",
|
|
50509
|
+
targetLabel: input.row.targetLabel,
|
|
50481
50510
|
actors: actor ? [actor] : [],
|
|
50482
50511
|
leadActor: actor,
|
|
50483
50512
|
elapsedSeconds: Math.max(0, Math.floor((input.nowMs - input.row.createdAtMs) / 1e3)),
|
|
@@ -50491,6 +50520,7 @@ function toComposerActivityRowCandidate(input) {
|
|
|
50491
50520
|
if (input.row.stage === "sending") return {
|
|
50492
50521
|
key: input.row.rowId,
|
|
50493
50522
|
mode: "sending",
|
|
50523
|
+
targetLabel: input.row.targetLabel,
|
|
50494
50524
|
actors: [],
|
|
50495
50525
|
leadActor: null,
|
|
50496
50526
|
elapsedSeconds: Math.max(0, Math.floor((input.nowMs - input.row.createdAtMs) / 1e3)),
|
|
@@ -50506,6 +50536,7 @@ function toComposerActivityRowCandidate(input) {
|
|
|
50506
50536
|
return {
|
|
50507
50537
|
key: input.row.rowId,
|
|
50508
50538
|
mode,
|
|
50539
|
+
targetLabel: input.row.targetLabel,
|
|
50509
50540
|
actors: actor ? [actor] : [],
|
|
50510
50541
|
leadActor: actor,
|
|
50511
50542
|
elapsedSeconds: Math.max(0, Math.floor((input.nowMs - input.row.createdAtMs) / 1e3)),
|
|
@@ -50959,6 +50990,7 @@ const STATUS_TRAILING_DOT_FRAMES = [
|
|
|
50959
50990
|
"..."
|
|
50960
50991
|
];
|
|
50961
50992
|
const PREVIEW_GAP = " ";
|
|
50993
|
+
const ACTIVITY_TARGET_LABEL_PREFIX_REGEX = /^@/u;
|
|
50962
50994
|
var ComposerActivityStrip = class {
|
|
50963
50995
|
#tui;
|
|
50964
50996
|
#activity = {
|
|
@@ -51068,15 +51100,17 @@ function buildActivityLines(input) {
|
|
|
51068
51100
|
}
|
|
51069
51101
|
function buildActivityRowLine(input) {
|
|
51070
51102
|
const spinner = STRIP_SPINNER_FRAMES[input.tick % STRIP_SPINNER_FRAMES.length] ?? "⠋";
|
|
51071
|
-
if (input.row.mode === "sending") {
|
|
51072
|
-
|
|
51073
|
-
|
|
51074
|
-
|
|
51075
|
-
|
|
51076
|
-
|
|
51077
|
-
input.row.mode === "warning" ? pc.
|
|
51078
|
-
|
|
51079
|
-
|
|
51103
|
+
if (input.row.mode === "sending") return buildSendingStatusLine({
|
|
51104
|
+
row: input.row,
|
|
51105
|
+
spaceMembersSnapshot: input.spaceMembersSnapshot,
|
|
51106
|
+
spinner
|
|
51107
|
+
});
|
|
51108
|
+
if (input.row.mode === "dispatching" || input.row.mode === "retrying" || input.row.mode === "warning") return buildStatusHintLine({
|
|
51109
|
+
glyph: input.row.mode === "warning" ? pc.yellow("!") : spacePiTuiTheme.accentText(spinner),
|
|
51110
|
+
elapsedLabel: input.row.mode === "warning" ? pc.dim("now") : pc.dim(`${input.elapsedSeconds}s`),
|
|
51111
|
+
row: input.row,
|
|
51112
|
+
spaceMembersSnapshot: input.spaceMembersSnapshot
|
|
51113
|
+
});
|
|
51080
51114
|
const statusLine = [
|
|
51081
51115
|
spacePiTuiTheme.accentText(spinner),
|
|
51082
51116
|
pc.dim(`${input.elapsedSeconds}s`),
|
|
@@ -51099,6 +51133,54 @@ function buildActivityRowLine(input) {
|
|
|
51099
51133
|
});
|
|
51100
51134
|
return `${statusLine}${separator}${pc.dim(windowText)}`;
|
|
51101
51135
|
}
|
|
51136
|
+
function buildSendingStatusLine(input) {
|
|
51137
|
+
const sendingText = input.row.hint || "sending...";
|
|
51138
|
+
return [spacePiTuiTheme.accentText(input.spinner), formatHintWithColoredTargetLabel({
|
|
51139
|
+
hint: sendingText,
|
|
51140
|
+
targetLabel: input.row.targetLabel,
|
|
51141
|
+
spaceMembersSnapshot: input.spaceMembersSnapshot
|
|
51142
|
+
})].join(` ${pc.dim("·")} `);
|
|
51143
|
+
}
|
|
51144
|
+
function buildStatusHintLine(input) {
|
|
51145
|
+
return [
|
|
51146
|
+
input.glyph,
|
|
51147
|
+
input.elapsedLabel,
|
|
51148
|
+
formatHintWithColoredTargetLabel({
|
|
51149
|
+
hint: input.row.hint ?? "",
|
|
51150
|
+
targetLabel: input.row.targetLabel,
|
|
51151
|
+
spaceMembersSnapshot: input.spaceMembersSnapshot
|
|
51152
|
+
})
|
|
51153
|
+
].join(` ${pc.dim("·")} `);
|
|
51154
|
+
}
|
|
51155
|
+
function formatHintWithColoredTargetLabel(input) {
|
|
51156
|
+
const targetLabel = input.targetLabel?.trim() ?? "";
|
|
51157
|
+
if (!(targetLabel && input.hint.includes(targetLabel))) return pc.white(input.hint);
|
|
51158
|
+
const coloredTargetLabel = resolveColoredTargetLabel({
|
|
51159
|
+
spaceMembersSnapshot: input.spaceMembersSnapshot,
|
|
51160
|
+
targetLabel
|
|
51161
|
+
});
|
|
51162
|
+
const [prefix, suffix = ""] = input.hint.split(targetLabel, 2);
|
|
51163
|
+
return `${pc.white(prefix)}${coloredTargetLabel}${pc.white(suffix)}`;
|
|
51164
|
+
}
|
|
51165
|
+
function resolveColoredTargetLabel(input) {
|
|
51166
|
+
const normalizedTargetLabel = normalizeActivityTargetLabel(input.targetLabel);
|
|
51167
|
+
const matchingAgent = input.spaceMembersSnapshot?.agents.find((candidate) => {
|
|
51168
|
+
return [
|
|
51169
|
+
candidate.wakeToken,
|
|
51170
|
+
candidate.wakeLabel,
|
|
51171
|
+
candidate.profileName,
|
|
51172
|
+
candidate.profileId
|
|
51173
|
+
].some((value) => normalizeActivityTargetLabel(value) === normalizedTargetLabel);
|
|
51174
|
+
}) ?? null;
|
|
51175
|
+
return colorizeAgentLabel(input.targetLabel, {
|
|
51176
|
+
controllerRef: matchingAgent?.controllerRef,
|
|
51177
|
+
profileId: matchingAgent?.profileId,
|
|
51178
|
+
profileName: matchingAgent?.profileName || normalizedTargetLabel || input.targetLabel
|
|
51179
|
+
}, { spaceMembersSnapshot: input.spaceMembersSnapshot });
|
|
51180
|
+
}
|
|
51181
|
+
function normalizeActivityTargetLabel(value) {
|
|
51182
|
+
return stripVTControlCharacters(String(value ?? "")).trim().replace(ACTIVITY_TARGET_LABEL_PREFIX_REGEX, "");
|
|
51183
|
+
}
|
|
51102
51184
|
function resolveRowElapsedSeconds(input) {
|
|
51103
51185
|
return (input.row.elapsedSeconds ?? 0) + input.elapsedDeltaSeconds;
|
|
51104
51186
|
}
|