agent-relay 4.0.22 → 4.0.24
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/index.cjs +18 -7
- package/dist/src/cli/commands/setup.d.ts.map +1 -1
- package/dist/src/cli/commands/setup.js +28 -7
- package/dist/src/cli/commands/setup.js.map +1 -1
- package/dist/src/cli/lib/broker-lifecycle.d.ts.map +1 -1
- package/dist/src/cli/lib/broker-lifecycle.js +9 -2
- package/dist/src/cli/lib/broker-lifecycle.js.map +1 -1
- package/node_modules/@agent-relay/cloud/package.json +2 -2
- package/node_modules/@agent-relay/config/package.json +1 -1
- package/node_modules/@agent-relay/hooks/package.json +4 -4
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.d.ts.map +1 -1
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.js +13 -4
- package/node_modules/@agent-relay/sdk/dist/workflows/trajectory.js.map +1 -1
- package/node_modules/@agent-relay/sdk/package.json +2 -2
- package/node_modules/@agent-relay/telemetry/package.json +1 -1
- package/node_modules/@agent-relay/trajectory/package.json +2 -2
- package/node_modules/@agent-relay/user-directory/package.json +2 -2
- package/node_modules/@agent-relay/utils/package.json +2 -2
- package/node_modules/agent-trajectories/README.md +7 -4
- package/node_modules/agent-trajectories/dist/{chunk-W222QB6V.js → chunk-2XT3DOJC.js} +11 -5
- package/node_modules/agent-trajectories/dist/chunk-2XT3DOJC.js.map +1 -0
- package/node_modules/agent-trajectories/dist/cli/index.js +98 -6
- package/node_modules/agent-trajectories/dist/cli/index.js.map +1 -1
- package/node_modules/agent-trajectories/dist/{index-7tzw_CMS.d.ts → index-thTh5iI8.d.ts} +208 -190
- package/node_modules/agent-trajectories/dist/index.d.ts +2 -2
- package/node_modules/agent-trajectories/dist/index.js +1 -1
- package/node_modules/agent-trajectories/dist/sdk/index.d.ts +1 -1
- package/node_modules/agent-trajectories/dist/sdk/index.js +1 -1
- package/node_modules/agent-trajectories/package.json +6 -3
- package/package.json +9 -9
- package/packages/cloud/package.json +2 -2
- package/packages/config/package.json +1 -1
- package/packages/hooks/package.json +4 -4
- package/packages/sdk/dist/workflows/trajectory.d.ts.map +1 -1
- package/packages/sdk/dist/workflows/trajectory.js +13 -4
- package/packages/sdk/dist/workflows/trajectory.js.map +1 -1
- package/packages/sdk/package.json +2 -2
- package/packages/telemetry/package.json +1 -1
- package/packages/trajectory/package.json +2 -2
- package/packages/user-directory/package.json +2 -2
- package/packages/utils/package.json +2 -2
- package/node_modules/agent-trajectories/dist/chunk-W222QB6V.js.map +0 -1
|
@@ -61,8 +61,10 @@ var TrajectoryEventTypeSchema = z.union([
|
|
|
61
61
|
z.literal("reflection"),
|
|
62
62
|
z.literal("note"),
|
|
63
63
|
z.literal("error"),
|
|
64
|
+
z.literal("completion-evidence"),
|
|
65
|
+
z.literal("completion-marker"),
|
|
64
66
|
z.string()
|
|
65
|
-
// Allow event types emitted by other tools
|
|
67
|
+
// Allow event types emitted by other tools. Downstream code filters to known types.
|
|
66
68
|
]);
|
|
67
69
|
var EventSignificanceSchema = z.enum([
|
|
68
70
|
"low",
|
|
@@ -857,7 +859,7 @@ var FileStorage = class {
|
|
|
857
859
|
return sortOrder === "asc" ? cmp : -cmp;
|
|
858
860
|
});
|
|
859
861
|
const offset = query.offset ?? 0;
|
|
860
|
-
const limit = query.limit ??
|
|
862
|
+
const limit = query.limit ?? 500;
|
|
861
863
|
entries = entries.slice(offset, offset + limit);
|
|
862
864
|
return Promise.all(
|
|
863
865
|
entries.map(async ([id, entry]) => {
|
|
@@ -1030,7 +1032,13 @@ function registerAbandonCommand(program2) {
|
|
|
1030
1032
|
|
|
1031
1033
|
// src/cli/commands/compact.ts
|
|
1032
1034
|
import { execFileSync } from "child_process";
|
|
1033
|
-
import {
|
|
1035
|
+
import {
|
|
1036
|
+
existsSync as existsSync3,
|
|
1037
|
+
mkdirSync,
|
|
1038
|
+
readFileSync as readFileSync2,
|
|
1039
|
+
unlinkSync,
|
|
1040
|
+
writeFileSync
|
|
1041
|
+
} from "fs";
|
|
1034
1042
|
import { dirname, join as join4 } from "path";
|
|
1035
1043
|
|
|
1036
1044
|
// src/compact/config.ts
|
|
@@ -2176,7 +2184,10 @@ function registerCompactCommand(program2) {
|
|
|
2176
2184
|
).option("--all", "Include all trajectories, even previously compacted ones").option("--llm", "Use LLM-based compaction when a provider is available").option("--no-llm", "Disable LLM-based compaction").option("--mechanical", "Force the original mechanical compaction flow").option(
|
|
2177
2185
|
"--focus <areas>",
|
|
2178
2186
|
"Comma-separated focus areas to emphasize in LLM compaction"
|
|
2179
|
-
).option("--markdown", "Also write a Markdown companion file").option("--no-markdown", "Skip writing a Markdown companion file").option(
|
|
2187
|
+
).option("--markdown", "Also write a Markdown companion file").option("--no-markdown", "Skip writing a Markdown companion file").option(
|
|
2188
|
+
"--discard-sources",
|
|
2189
|
+
"After saving the compaction, delete source trajectory JSON/MD/trace files and remove their index entries"
|
|
2190
|
+
).option("--dry-run", "Preview what would be compacted without saving").option("--output <path>", "Output path for compacted trajectory").action(async (options) => {
|
|
2180
2191
|
const trajectories = await loadTrajectories(options);
|
|
2181
2192
|
if (trajectories.length === 0) {
|
|
2182
2193
|
if (options.all || options.since || options.ids || options.workflow || options.pr || options.branch || options.commits) {
|
|
@@ -2215,7 +2226,15 @@ function registerCompactCommand(program2) {
|
|
|
2215
2226
|
outputPath2,
|
|
2216
2227
|
markdownEnabled
|
|
2217
2228
|
);
|
|
2218
|
-
|
|
2229
|
+
if (options.discardSources) {
|
|
2230
|
+
const discardSummary = discardSourceTrajectories(trajectories);
|
|
2231
|
+
printDiscardSummary(discardSummary);
|
|
2232
|
+
} else {
|
|
2233
|
+
await markTrajectoriesAsCompacted(
|
|
2234
|
+
trajectories,
|
|
2235
|
+
mechanicalCompacted.id
|
|
2236
|
+
);
|
|
2237
|
+
}
|
|
2219
2238
|
console.log(`
|
|
2220
2239
|
Compacted trajectory saved to: ${outputPath2}`);
|
|
2221
2240
|
if (markdownEnabled) {
|
|
@@ -2268,7 +2287,12 @@ Compacted trajectory saved to: ${outputPath2}`);
|
|
|
2268
2287
|
};
|
|
2269
2288
|
const outputPath = options.output || getDefaultOutputPath(compacted, options.workflow);
|
|
2270
2289
|
saveCompactionArtifacts(compacted, outputPath, markdownEnabled);
|
|
2271
|
-
|
|
2290
|
+
if (options.discardSources) {
|
|
2291
|
+
const discardSummary = discardSourceTrajectories(trajectories);
|
|
2292
|
+
printDiscardSummary(discardSummary);
|
|
2293
|
+
} else {
|
|
2294
|
+
await markTrajectoriesAsCompacted(trajectories, compacted.id);
|
|
2295
|
+
}
|
|
2272
2296
|
console.log(`
|
|
2273
2297
|
Compacted trajectory saved to: ${outputPath}`);
|
|
2274
2298
|
if (markdownEnabled) {
|
|
@@ -2416,6 +2440,74 @@ async function markTrajectoriesAsCompacted(trajectories, compactedIntoId) {
|
|
|
2416
2440
|
}
|
|
2417
2441
|
}
|
|
2418
2442
|
}
|
|
2443
|
+
function discardSourceTrajectories(trajectories) {
|
|
2444
|
+
const sourceIds = new Set(trajectories.map((trajectory) => trajectory.id));
|
|
2445
|
+
const summary = {
|
|
2446
|
+
removedIndexEntries: 0,
|
|
2447
|
+
deletedJsonFiles: 0,
|
|
2448
|
+
deletedMarkdownFiles: 0,
|
|
2449
|
+
deletedTraceFiles: 0
|
|
2450
|
+
};
|
|
2451
|
+
for (const searchPath of getSearchPaths()) {
|
|
2452
|
+
const indexPath = join4(searchPath, "index.json");
|
|
2453
|
+
if (!existsSync3(indexPath)) continue;
|
|
2454
|
+
let index;
|
|
2455
|
+
try {
|
|
2456
|
+
const indexContent = readFileSync2(indexPath, "utf-8");
|
|
2457
|
+
const parsedIndex = JSON.parse(indexContent);
|
|
2458
|
+
if (!isTrajectoryIndex(parsedIndex)) {
|
|
2459
|
+
continue;
|
|
2460
|
+
}
|
|
2461
|
+
index = parsedIndex;
|
|
2462
|
+
} catch {
|
|
2463
|
+
continue;
|
|
2464
|
+
}
|
|
2465
|
+
let updated = false;
|
|
2466
|
+
for (const id of sourceIds) {
|
|
2467
|
+
const entry = index.trajectories[id];
|
|
2468
|
+
if (!entry) continue;
|
|
2469
|
+
if (deleteFileIfExists(entry.path)) {
|
|
2470
|
+
summary.deletedJsonFiles += 1;
|
|
2471
|
+
}
|
|
2472
|
+
if (deleteFileIfExists(getMarkdownOutputPath(entry.path))) {
|
|
2473
|
+
summary.deletedMarkdownFiles += 1;
|
|
2474
|
+
}
|
|
2475
|
+
if (deleteFileIfExists(getTraceOutputPath(entry.path))) {
|
|
2476
|
+
summary.deletedTraceFiles += 1;
|
|
2477
|
+
}
|
|
2478
|
+
delete index.trajectories[id];
|
|
2479
|
+
summary.removedIndexEntries += 1;
|
|
2480
|
+
updated = true;
|
|
2481
|
+
}
|
|
2482
|
+
if (updated) {
|
|
2483
|
+
index.lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
2484
|
+
writeFileSync(indexPath, JSON.stringify(index, null, 2));
|
|
2485
|
+
}
|
|
2486
|
+
}
|
|
2487
|
+
return summary;
|
|
2488
|
+
}
|
|
2489
|
+
function deleteFileIfExists(path2) {
|
|
2490
|
+
if (!existsSync3(path2)) {
|
|
2491
|
+
return false;
|
|
2492
|
+
}
|
|
2493
|
+
unlinkSync(path2);
|
|
2494
|
+
return true;
|
|
2495
|
+
}
|
|
2496
|
+
function isTrajectoryIndex(value) {
|
|
2497
|
+
if (value === null || typeof value !== "object") {
|
|
2498
|
+
return false;
|
|
2499
|
+
}
|
|
2500
|
+
const candidate = value;
|
|
2501
|
+
return candidate.trajectories !== null && typeof candidate.trajectories === "object" && !Array.isArray(candidate.trajectories);
|
|
2502
|
+
}
|
|
2503
|
+
function getTraceOutputPath(outputPath) {
|
|
2504
|
+
return outputPath.endsWith(".json") ? outputPath.slice(0, -".json".length).concat(".trace.json") : `${outputPath}.trace.json`;
|
|
2505
|
+
}
|
|
2506
|
+
function printDiscardSummary(summary) {
|
|
2507
|
+
console.log(
|
|
2508
|
+
`Discarded source trajectories: ${summary.removedIndexEntries} index entries, ${summary.deletedJsonFiles} JSON files, ${summary.deletedMarkdownFiles} Markdown files, ${summary.deletedTraceFiles} trace files`
|
|
2509
|
+
);
|
|
2510
|
+
}
|
|
2419
2511
|
function parseRelativeDate(input) {
|
|
2420
2512
|
const match = input.match(/^(\d+)([dwmh])$/);
|
|
2421
2513
|
if (match) {
|