@bastani/atomic 0.9.38-alpha.7 → 0.9.38-alpha.9
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/CHANGELOG.md +16 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/README.md +9 -4
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/subagents/src/extension/index.bundle.mjs +23 -13
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/CHANGELOG.md +6 -0
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/durable/journal/legacy-journal-tables.d.ts +42 -0
- package/dist/builtin/workflows/src/durable/journal/sql-run-journal.d.ts +3 -0
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +204 -51
- package/dist/builtin/workflows/src/index.js +170 -17
- package/dist/core/session-manager-storage.d.ts +1 -1
- package/dist/core/session-manager-storage.d.ts.map +1 -1
- package/dist/core/session-manager-storage.js +2 -3
- package/dist/core/session-manager-storage.js.map +1 -1
- package/dist/core/session-storage.d.ts.map +1 -1
- package/dist/core/session-storage.js +20 -4
- package/dist/core/session-storage.js.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.d.ts +7 -1
- package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
- package/dist/core/storage/session/jsonl-session-store.js +29 -20
- package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
- package/dist/core/storage/session/legacy-format.d.ts +2 -0
- package/dist/core/storage/session/legacy-format.d.ts.map +1 -1
- package/dist/core/storage/session/legacy-format.js +55 -29
- package/dist/core/storage/session/legacy-format.js.map +1 -1
- package/dist/core/storage/session/legacy-session-store.d.ts +63 -0
- package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -0
- package/dist/core/storage/session/legacy-session-store.js +239 -0
- package/dist/core/storage/session/legacy-session-store.js.map +1 -0
- package/dist/core/storage/session/legacy-session-summary.d.ts +11 -0
- package/dist/core/storage/session/legacy-session-summary.d.ts.map +1 -0
- package/dist/core/storage/session/legacy-session-summary.js +103 -0
- package/dist/core/storage/session/legacy-session-summary.js.map +1 -0
- package/dist/main-session.d.ts.map +1 -1
- package/dist/main-session.js +4 -1
- package/dist/main-session.js.map +1 -1
- package/docs/docs.json +5 -2
- package/docs/llama-cpp.md +94 -1
- package/docs/session-format.md +1 -1
- package/docs/sessions.md +4 -2
- package/docs/subagents.md +19 -6
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
- package/docs/nvidia-rtx-llama-cpp.md +0 -101
|
@@ -52496,12 +52496,42 @@ function inheritedRunElapsedMs(input) {
|
|
|
52496
52496
|
// dist/builtin/workflows/src/shared/resume-continuation.ts
|
|
52497
52497
|
var RESUME_CONTINUATION_PROMPT = "Continue where you left off. If you believe you are finished with your original task (or a redefined task if the user told you), stop.";
|
|
52498
52498
|
|
|
52499
|
+
// dist/builtin/workflows/src/durable/backend.ts
|
|
52500
|
+
import { closeSync, openSync, readSync } from "node:fs";
|
|
52501
|
+
|
|
52499
52502
|
// dist/builtin/workflows/src/durable/types.ts
|
|
52500
52503
|
var DURABLE_TOOL_TOPOLOGY_VERSION = 1;
|
|
52501
52504
|
var DURABLE_STAGE_TOPOLOGY_VERSION = 1;
|
|
52502
52505
|
var DURABLE_BOUNDARY_TOPOLOGY_VERSION = 1;
|
|
52503
52506
|
|
|
52504
52507
|
// dist/builtin/workflows/src/durable/backend.ts
|
|
52508
|
+
var SESSION_HEADER_READ_LIMIT_BYTES = 64 * 1024;
|
|
52509
|
+
function readSessionHeaderId(sessionFile) {
|
|
52510
|
+
let fd;
|
|
52511
|
+
try {
|
|
52512
|
+
fd = openSync(sessionFile, "r");
|
|
52513
|
+
} catch {
|
|
52514
|
+
return;
|
|
52515
|
+
}
|
|
52516
|
+
try {
|
|
52517
|
+
const buffer = Buffer.alloc(SESSION_HEADER_READ_LIMIT_BYTES);
|
|
52518
|
+
const bytesRead = readSync(fd, buffer, 0, buffer.length, 0);
|
|
52519
|
+
const firstLine = buffer.subarray(0, bytesRead).toString("utf8").replace(/^\uFEFF/, "").split(`
|
|
52520
|
+
`)[0];
|
|
52521
|
+
const header = JSON.parse(firstLine ?? "");
|
|
52522
|
+
return header.type === "session" && typeof header.id === "string" ? header.id : undefined;
|
|
52523
|
+
} catch {
|
|
52524
|
+
return;
|
|
52525
|
+
} finally {
|
|
52526
|
+
closeSync(fd);
|
|
52527
|
+
}
|
|
52528
|
+
}
|
|
52529
|
+
function migrateStageSessionCheckpoint(checkpoint) {
|
|
52530
|
+
if (checkpoint.sessionId !== undefined || checkpoint.sessionFile === undefined)
|
|
52531
|
+
return checkpoint;
|
|
52532
|
+
const sessionId = readSessionHeaderId(checkpoint.sessionFile);
|
|
52533
|
+
return sessionId === undefined ? checkpoint : { ...checkpoint, sessionId };
|
|
52534
|
+
}
|
|
52505
52535
|
function replacePendingStageMessagesForRun(existing, logicalRunId, messages) {
|
|
52506
52536
|
if (messages.some((entry) => entry.runId !== logicalRunId)) {
|
|
52507
52537
|
throw new Error(`atomic-workflows: pending-stage persistence mixed logical run ${logicalRunId}`);
|
|
@@ -52636,7 +52666,8 @@ class JournalProjection {
|
|
|
52636
52666
|
return this.stickyReceipts.get(workflowId)?.has(name) ?? false;
|
|
52637
52667
|
});
|
|
52638
52668
|
}
|
|
52639
|
-
recordCheckpoint(
|
|
52669
|
+
recordCheckpoint(recorded) {
|
|
52670
|
+
const checkpoint = recorded.kind === "stage" ? migrateStageSessionCheckpoint(recorded) : recorded;
|
|
52640
52671
|
const currentCheckpoint = checkpoint.kind === "stage" && checkpoint.topology === undefined ? {
|
|
52641
52672
|
...checkpoint,
|
|
52642
52673
|
topology: {
|
|
@@ -53823,6 +53854,7 @@ function createDurableStagePrimitive(input) {
|
|
|
53823
53854
|
...durableIntercomGroup !== undefined ? { durableIntercomGroup } : {},
|
|
53824
53855
|
...isMidSessionResume ? {
|
|
53825
53856
|
resumeFromSessionId: session.sessionId,
|
|
53857
|
+
...session.sessionFile !== undefined ? { resumeFromLegacySessionFile: session.sessionFile } : {},
|
|
53826
53858
|
routerSelection: session.routerSelection,
|
|
53827
53859
|
durableAccumulatedDurationMs: session.durationMs ?? 0
|
|
53828
53860
|
} : {}
|
|
@@ -53882,6 +53914,7 @@ function createDurableTaskPrimitive(input) {
|
|
|
53882
53914
|
...durableIntercomGroup !== undefined ? { durableIntercomGroup } : {},
|
|
53883
53915
|
...session?.sessionId !== undefined ? {
|
|
53884
53916
|
resumeFromSessionId: session.sessionId,
|
|
53917
|
+
...session.sessionFile !== undefined ? { resumeFromLegacySessionFile: session.sessionFile } : {},
|
|
53885
53918
|
routerSelection: session.routerSelection,
|
|
53886
53919
|
durableAccumulatedDurationMs: session.durationMs ?? 0
|
|
53887
53920
|
} : {}
|
|
@@ -56901,6 +56934,7 @@ function hasUsableContentBlock(block) {
|
|
|
56901
56934
|
|
|
56902
56935
|
// dist/builtin/workflows/src/shared/stage-session-store.ts
|
|
56903
56936
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
56937
|
+
import { dirname, resolve as resolve2 } from "node:path";
|
|
56904
56938
|
import {
|
|
56905
56939
|
JsonlSessionStore,
|
|
56906
56940
|
resolveSessionStore,
|
|
@@ -56933,6 +56967,24 @@ async function forkStageSession(store, sessionId, cwd, options, destination = st
|
|
|
56933
56967
|
}, source.entries);
|
|
56934
56968
|
return SessionManager.open(destination, id, cwd);
|
|
56935
56969
|
}
|
|
56970
|
+
async function migrateLegacyStageSession(store, sessionId, sessionFile) {
|
|
56971
|
+
if (sessionFile === undefined || await store.readHeader(sessionId) !== undefined)
|
|
56972
|
+
return;
|
|
56973
|
+
const location = resolve2(sessionFile);
|
|
56974
|
+
const legacy = await JsonlSessionStore.open(dirname(location), { exactDirectory: true, scanExisting: false });
|
|
56975
|
+
try {
|
|
56976
|
+
for await (const file of legacy.scanFiles()) {
|
|
56977
|
+
if (resolve2(file.location) !== location || file.header.id !== sessionId)
|
|
56978
|
+
continue;
|
|
56979
|
+
const snapshot = await file.read();
|
|
56980
|
+
if (await store.readHeader(sessionId) === undefined)
|
|
56981
|
+
await store.create(snapshot.header, snapshot.entries);
|
|
56982
|
+
return;
|
|
56983
|
+
}
|
|
56984
|
+
} finally {
|
|
56985
|
+
await legacy.close();
|
|
56986
|
+
}
|
|
56987
|
+
}
|
|
56936
56988
|
|
|
56937
56989
|
// dist/builtin/workflows/src/durable/stage-topology-validation.ts
|
|
56938
56990
|
function immutableStageGroupError(stages) {
|
|
@@ -58898,7 +58950,7 @@ class JournalDurableBackend {
|
|
|
58898
58950
|
}
|
|
58899
58951
|
|
|
58900
58952
|
// dist/builtin/workflows/src/durable/journal/resolution.ts
|
|
58901
|
-
import { dirname, isAbsolute as isAbsolute2, join as join2 } from "node:path";
|
|
58953
|
+
import { dirname as dirname2, isAbsolute as isAbsolute2, join as join2 } from "node:path";
|
|
58902
58954
|
import { getAgentDir as getAgentDir2 } from "@bastani/atomic";
|
|
58903
58955
|
import {
|
|
58904
58956
|
StorageConfigError,
|
|
@@ -58909,10 +58961,89 @@ import {
|
|
|
58909
58961
|
// dist/builtin/workflows/src/durable/journal/sql-run-journal.ts
|
|
58910
58962
|
import {
|
|
58911
58963
|
assertStorageSchemaVersion,
|
|
58912
|
-
renderStorageIdentifiers,
|
|
58964
|
+
renderStorageIdentifiers as renderStorageIdentifiers2,
|
|
58913
58965
|
StorageSchemaVersionError as StorageSchemaVersionError2,
|
|
58914
58966
|
StorageUnavailableError as StorageUnavailableError2
|
|
58915
58967
|
} from "@bastani/atomic/storage";
|
|
58968
|
+
|
|
58969
|
+
// dist/builtin/workflows/src/durable/journal/legacy-journal-tables.ts
|
|
58970
|
+
import {
|
|
58971
|
+
renderStorageIdentifiers
|
|
58972
|
+
} from "@bastani/atomic/storage";
|
|
58973
|
+
var CURRENT = renderStorageIdentifiers("journal", {
|
|
58974
|
+
...JOURNAL_TABLES,
|
|
58975
|
+
legacyDeleted: "legacy_deleted",
|
|
58976
|
+
migrations: "migrations"
|
|
58977
|
+
});
|
|
58978
|
+
var COPIED_ALL_MARKER = "unprefixed-journal-tables";
|
|
58979
|
+
var LEGACY_COLUMNS = {
|
|
58980
|
+
meta: [JOURNAL_COLUMNS.schemaVersion],
|
|
58981
|
+
runs: [JOURNAL_COLUMNS.runId, JOURNAL_COLUMNS.name, JOURNAL_COLUMNS.cwd, JOURNAL_COLUMNS.createdAt, JOURNAL_COLUMNS.status, JOURNAL_COLUMNS.headerJson],
|
|
58982
|
+
events: [JOURNAL_COLUMNS.runId, JOURNAL_COLUMNS.seq, JOURNAL_COLUMNS.epoch, JOURNAL_COLUMNS.key, JOURNAL_COLUMNS.type, JOURNAL_COLUMNS.payload, JOURNAL_COLUMNS.at],
|
|
58983
|
+
leases: [JOURNAL_COLUMNS.runId, JOURNAL_COLUMNS.holderId, JOURNAL_COLUMNS.epoch, JOURNAL_COLUMNS.renewedAt]
|
|
58984
|
+
};
|
|
58985
|
+
var PENDING_LEGACY_RUNS = `SELECT ${JOURNAL_COLUMNS.runId}, ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${JOURNAL_TABLES.runs}
|
|
58986
|
+
WHERE ${JOURNAL_COLUMNS.runId} NOT IN (SELECT ${JOURNAL_COLUMNS.runId} FROM ${CURRENT.runs})
|
|
58987
|
+
AND ${JOURNAL_COLUMNS.runId} NOT IN (SELECT ${JOURNAL_COLUMNS.runId} FROM ${CURRENT.legacyDeleted})`;
|
|
58988
|
+
async function hasLegacyTable(tx, table) {
|
|
58989
|
+
const columns = await tx.all("SELECT name FROM pragma_table_info(?)", JOURNAL_TABLES[table]);
|
|
58990
|
+
const names = new Set(columns.map((column) => column.name));
|
|
58991
|
+
return columns.length === LEGACY_COLUMNS[table].length && LEGACY_COLUMNS[table].every((name) => names.has(name));
|
|
58992
|
+
}
|
|
58993
|
+
|
|
58994
|
+
class LegacyJournalRuns {
|
|
58995
|
+
static async open(database) {
|
|
58996
|
+
try {
|
|
58997
|
+
return await database.transaction(async (tx) => {
|
|
58998
|
+
for (const table of ["meta", "runs", "events"]) {
|
|
58999
|
+
if (!await hasLegacyTable(tx, table))
|
|
59000
|
+
return;
|
|
59001
|
+
}
|
|
59002
|
+
const versions = await tx.all(`SELECT ${JOURNAL_COLUMNS.schemaVersion} FROM ${JOURNAL_TABLES.meta}`);
|
|
59003
|
+
if (versions.length !== 1 || Number(versions[0][JOURNAL_COLUMNS.schemaVersion]) !== JOURNAL_SCHEMA_VERSION)
|
|
59004
|
+
return;
|
|
59005
|
+
const copiedAll = await tx.get(`SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?`, CURRENT.migrations) !== undefined && await tx.get(`SELECT name FROM ${CURRENT.migrations} WHERE name = ?`, COPIED_ALL_MARKER) !== undefined;
|
|
59006
|
+
if (copiedAll)
|
|
59007
|
+
return;
|
|
59008
|
+
await tx.exec(`CREATE TABLE IF NOT EXISTS ${CURRENT.legacyDeleted}(${JOURNAL_COLUMNS.runId} TEXT PRIMARY KEY, deleted_at INTEGER NOT NULL)`);
|
|
59009
|
+
return new LegacyJournalRuns;
|
|
59010
|
+
});
|
|
59011
|
+
} catch {
|
|
59012
|
+
return;
|
|
59013
|
+
}
|
|
59014
|
+
}
|
|
59015
|
+
async pending(executor, filter) {
|
|
59016
|
+
return executor.all(`${PENDING_LEGACY_RUNS}${filter?.cwd === undefined ? "" : ` AND ${JOURNAL_COLUMNS.cwd} = ?`}`, ...filter?.cwd === undefined ? [] : [filter.cwd]);
|
|
59017
|
+
}
|
|
59018
|
+
async find(executor, runId) {
|
|
59019
|
+
return executor.get(`${PENDING_LEGACY_RUNS} AND ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
59020
|
+
}
|
|
59021
|
+
async events(executor, runId, fromSeq, limit) {
|
|
59022
|
+
return executor.all(`SELECT ${LEGACY_COLUMNS.events.join(", ")} FROM ${JOURNAL_TABLES.events} WHERE ${JOURNAL_COLUMNS.runId} = ? AND ${JOURNAL_COLUMNS.seq} >= ? ORDER BY ${JOURNAL_COLUMNS.seq} LIMIT ?`, runId, fromSeq, limit);
|
|
59023
|
+
}
|
|
59024
|
+
async eventByKey(executor, runId, key) {
|
|
59025
|
+
return executor.get(`SELECT ${LEGACY_COLUMNS.events.join(", ")} FROM ${JOURNAL_TABLES.events} WHERE ${JOURNAL_COLUMNS.runId} = ? AND ${JOURNAL_COLUMNS.key} = ?`, runId, key);
|
|
59026
|
+
}
|
|
59027
|
+
async convert(tx, runId) {
|
|
59028
|
+
if (await this.find(tx, runId) === undefined)
|
|
59029
|
+
return false;
|
|
59030
|
+
const eventColumns = LEGACY_COLUMNS.events.join(", ");
|
|
59031
|
+
await tx.run(`INSERT OR IGNORE INTO ${CURRENT.events}(${eventColumns}) SELECT ${eventColumns} FROM ${JOURNAL_TABLES.events} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
59032
|
+
if (await hasLegacyTable(tx, "leases")) {
|
|
59033
|
+
await tx.run(`INSERT OR IGNORE INTO ${CURRENT.leases}(${JOURNAL_COLUMNS.runId}, ${JOURNAL_COLUMNS.holderId}, ${JOURNAL_COLUMNS.epoch}, ${JOURNAL_COLUMNS.renewedAt}) SELECT ${JOURNAL_COLUMNS.runId}, NULL, ${JOURNAL_COLUMNS.epoch}, ${JOURNAL_COLUMNS.renewedAt} FROM ${JOURNAL_TABLES.leases} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
59034
|
+
}
|
|
59035
|
+
const runColumns = LEGACY_COLUMNS.runs.join(", ");
|
|
59036
|
+
await tx.run(`INSERT INTO ${CURRENT.runs}(${runColumns}) SELECT ${runColumns} FROM ${JOURNAL_TABLES.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
59037
|
+
return true;
|
|
59038
|
+
}
|
|
59039
|
+
async markDeleted(tx, runId) {
|
|
59040
|
+
if (await tx.get(`SELECT ${JOURNAL_COLUMNS.runId} FROM ${JOURNAL_TABLES.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId) === undefined)
|
|
59041
|
+
return;
|
|
59042
|
+
await tx.run(`INSERT OR IGNORE INTO ${CURRENT.legacyDeleted} VALUES (?, ?)`, runId, Date.now());
|
|
59043
|
+
}
|
|
59044
|
+
}
|
|
59045
|
+
|
|
59046
|
+
// dist/builtin/workflows/src/durable/journal/sql-run-journal.ts
|
|
58916
59047
|
var STORE_NOW = "CAST(unixepoch('subsec') * 1000 AS INTEGER)";
|
|
58917
59048
|
function entryFromRow(row) {
|
|
58918
59049
|
const key = row[JOURNAL_COLUMNS.key];
|
|
@@ -58932,12 +59063,14 @@ class SqlRunJournal {
|
|
|
58932
59063
|
closePromise;
|
|
58933
59064
|
database;
|
|
58934
59065
|
tables;
|
|
58935
|
-
|
|
59066
|
+
legacy;
|
|
59067
|
+
constructor(database, tables, legacy) {
|
|
58936
59068
|
this.database = database;
|
|
58937
59069
|
this.tables = tables;
|
|
59070
|
+
this.legacy = legacy;
|
|
58938
59071
|
}
|
|
58939
59072
|
static async open(database, options = {}) {
|
|
58940
|
-
const t =
|
|
59073
|
+
const t = renderStorageIdentifiers2("journal", JOURNAL_TABLES, options.prefix);
|
|
58941
59074
|
await database.transaction(async (tx) => {
|
|
58942
59075
|
await tx.exec(`CREATE TABLE IF NOT EXISTS ${t.meta}(${JOURNAL_COLUMNS.schemaVersion} INTEGER NOT NULL)`);
|
|
58943
59076
|
const versions = await tx.all(`SELECT ${JOURNAL_COLUMNS.schemaVersion} FROM ${t.meta}`);
|
|
@@ -58971,7 +59104,8 @@ class SqlRunJournal {
|
|
|
58971
59104
|
);
|
|
58972
59105
|
`);
|
|
58973
59106
|
});
|
|
58974
|
-
|
|
59107
|
+
const legacy = options.prefix ? undefined : await LegacyJournalRuns.open(database);
|
|
59108
|
+
return new SqlRunJournal(database, t, legacy);
|
|
58975
59109
|
}
|
|
58976
59110
|
get descriptor() {
|
|
58977
59111
|
return { ...this.database.descriptor };
|
|
@@ -59007,6 +59141,8 @@ class SqlRunJournal {
|
|
|
59007
59141
|
throw json;
|
|
59008
59142
|
const { runs } = this.tables;
|
|
59009
59143
|
return this.operation(async () => {
|
|
59144
|
+
if (await this.legacy?.find(this.database, header.runId))
|
|
59145
|
+
return "exists";
|
|
59010
59146
|
const result = await this.database.run(`INSERT INTO ${runs} VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(${JOURNAL_COLUMNS.runId}) DO NOTHING`, header.runId, header.name, header.cwd, header.createdAt, header.status, json);
|
|
59011
59147
|
return result.changes === 1 ? "created" : "exists";
|
|
59012
59148
|
});
|
|
@@ -59016,7 +59152,8 @@ class SqlRunJournal {
|
|
|
59016
59152
|
validateText("runId", runId);
|
|
59017
59153
|
return this.operation(async () => {
|
|
59018
59154
|
const row = await this.database.get(`SELECT ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${this.tables.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
59019
|
-
|
|
59155
|
+
const found = row ?? await this.legacy?.find(this.database, runId);
|
|
59156
|
+
return found ? { ...JSON.parse(found[JOURNAL_COLUMNS.headerJson]), status: found[JOURNAL_COLUMNS.status] } : undefined;
|
|
59020
59157
|
});
|
|
59021
59158
|
}
|
|
59022
59159
|
async listRuns(filter) {
|
|
@@ -59025,13 +59162,23 @@ class SqlRunJournal {
|
|
|
59025
59162
|
validateText("cwd", filter.cwd);
|
|
59026
59163
|
return this.operation(async () => {
|
|
59027
59164
|
const rows = await this.database.all(`SELECT ${JOURNAL_COLUMNS.headerJson}, ${JOURNAL_COLUMNS.status} FROM ${this.tables.runs} ${filter?.cwd === undefined ? "" : `WHERE ${JOURNAL_COLUMNS.cwd} = ?`} ORDER BY ${JOURNAL_COLUMNS.runId}`, ...filter?.cwd === undefined ? [] : [filter.cwd]);
|
|
59028
|
-
|
|
59165
|
+
const legacy = await this.legacy?.pending(this.database, filter) ?? [];
|
|
59166
|
+
return [...rows, ...legacy].map((row) => ({ ...JSON.parse(row[JOURNAL_COLUMNS.headerJson]), status: row[JOURNAL_COLUMNS.status] })).sort((left, right) => left.runId < right.runId ? -1 : left.runId > right.runId ? 1 : 0);
|
|
59029
59167
|
});
|
|
59030
59168
|
}
|
|
59031
59169
|
async requireRun(tx, runId) {
|
|
59032
|
-
if (
|
|
59170
|
+
if (await tx.get(`SELECT ${JOURNAL_COLUMNS.runId} FROM ${this.tables.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId))
|
|
59171
|
+
return;
|
|
59172
|
+
if (!await this.legacy?.convert(tx, runId))
|
|
59033
59173
|
throw new RunNotFoundError(runId);
|
|
59034
59174
|
}
|
|
59175
|
+
async isUnconvertedLegacyRun(runId) {
|
|
59176
|
+
if (this.legacy === undefined)
|
|
59177
|
+
return false;
|
|
59178
|
+
if (await this.database.get(`SELECT ${JOURNAL_COLUMNS.runId} FROM ${this.tables.runs} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId))
|
|
59179
|
+
return false;
|
|
59180
|
+
return await this.legacy.find(this.database, runId) !== undefined;
|
|
59181
|
+
}
|
|
59035
59182
|
async leaseRow(tx, runId) {
|
|
59036
59183
|
const row = await tx.get(`SELECT * FROM ${this.tables.leases} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
59037
59184
|
return row ? { ...row, [JOURNAL_COLUMNS.epoch]: journalCounter(runId, "epoch", row[JOURNAL_COLUMNS.epoch]) } : undefined;
|
|
@@ -59171,9 +59318,11 @@ class SqlRunJournal {
|
|
|
59171
59318
|
this.assertOpen();
|
|
59172
59319
|
validateText("runId", runId);
|
|
59173
59320
|
let nextSeq = fromSeq;
|
|
59321
|
+
const legacy = this.legacy;
|
|
59322
|
+
const readsLegacy = legacy !== undefined && await this.operation(() => this.isUnconvertedLegacyRun(runId));
|
|
59174
59323
|
for (;; ) {
|
|
59175
59324
|
const page = await this.operation(async () => {
|
|
59176
|
-
const rows = await this.database.all(`SELECT * FROM ${this.tables.events} WHERE ${JOURNAL_COLUMNS.runId} = ? AND ${JOURNAL_COLUMNS.seq} >= ? ORDER BY ${JOURNAL_COLUMNS.seq} LIMIT ?`, runId, nextSeq, JOURNAL_READ_PAGE_SIZE);
|
|
59325
|
+
const rows = readsLegacy ? await legacy.events(this.database, runId, nextSeq, JOURNAL_READ_PAGE_SIZE) : await this.database.all(`SELECT * FROM ${this.tables.events} WHERE ${JOURNAL_COLUMNS.runId} = ? AND ${JOURNAL_COLUMNS.seq} >= ? ORDER BY ${JOURNAL_COLUMNS.seq} LIMIT ?`, runId, nextSeq, JOURNAL_READ_PAGE_SIZE);
|
|
59177
59326
|
return rows.map(entryFromRow);
|
|
59178
59327
|
});
|
|
59179
59328
|
for (const entry of page) {
|
|
@@ -59192,7 +59341,7 @@ class SqlRunJournal {
|
|
|
59192
59341
|
validateText("runId", runId);
|
|
59193
59342
|
validateText("key", key);
|
|
59194
59343
|
return this.operation(async () => {
|
|
59195
|
-
const row = await this.database.get(`SELECT * FROM ${this.tables.events} WHERE ${JOURNAL_COLUMNS.runId} = ? AND ${JOURNAL_COLUMNS.key} = ?`, runId, key);
|
|
59344
|
+
const row = this.legacy !== undefined && await this.isUnconvertedLegacyRun(runId) ? await this.legacy.eventByKey(this.database, runId, key) : await this.database.get(`SELECT * FROM ${this.tables.events} WHERE ${JOURNAL_COLUMNS.runId} = ? AND ${JOURNAL_COLUMNS.key} = ?`, runId, key);
|
|
59196
59345
|
return row ? entryFromRow(row) : undefined;
|
|
59197
59346
|
});
|
|
59198
59347
|
}
|
|
@@ -59217,6 +59366,7 @@ class SqlRunJournal {
|
|
|
59217
59366
|
}));
|
|
59218
59367
|
}
|
|
59219
59368
|
async deleteRunData(tx, runId) {
|
|
59369
|
+
await this.legacy?.markDeleted(tx, runId);
|
|
59220
59370
|
await this.leaseRow(tx, runId);
|
|
59221
59371
|
await tx.run(`UPDATE ${this.tables.leases} SET ${JOURNAL_COLUMNS.holderId} = ? WHERE ${JOURNAL_COLUMNS.runId} = ?`, JOURNAL_LEASE.unheld, runId);
|
|
59222
59372
|
await tx.run(`DELETE FROM ${this.tables.events} WHERE ${JOURNAL_COLUMNS.runId} = ?`, runId);
|
|
@@ -59239,7 +59389,7 @@ var provider = new StorageProvider({
|
|
|
59239
59389
|
var settingsSelections = new WeakSet;
|
|
59240
59390
|
function selectRunJournal(options = {}) {
|
|
59241
59391
|
const agentDir = getAgentDir2();
|
|
59242
|
-
const defaultPath = join2(
|
|
59392
|
+
const defaultPath = join2(dirname2(agentDir), "workflows", "journal.sqlite");
|
|
59243
59393
|
if (options.journal !== undefined) {
|
|
59244
59394
|
if (options.journal !== null && typeof options.journal === "object" && "createRun" in options.journal) {
|
|
59245
59395
|
const journal = options.journal;
|
|
@@ -59274,8 +59424,8 @@ function selectRunJournal(options = {}) {
|
|
|
59274
59424
|
const value2 = journal !== undefined ? journal : options.settings?.storage;
|
|
59275
59425
|
if (value2 === undefined)
|
|
59276
59426
|
return { kind: "sqlite", path: defaultPath };
|
|
59277
|
-
const selection = selectStorage(value2, "settings", journal !== undefined ? "workflows.journal" : "storage", journal !== undefined ? defaultPath : join2(
|
|
59278
|
-
const resolved = selection.kind === "sqlite" && !isAbsolute2(selection.path) ? { ...selection, path: join2(
|
|
59427
|
+
const selection = selectStorage(value2, "settings", journal !== undefined ? "workflows.journal" : "storage", journal !== undefined ? defaultPath : join2(dirname2(agentDir), "storage.sqlite"));
|
|
59428
|
+
const resolved = selection.kind === "sqlite" && !isAbsolute2(selection.path) ? { ...selection, path: join2(dirname2(agentDir), selection.path) } : selection;
|
|
59279
59429
|
settingsSelections.add(resolved);
|
|
59280
59430
|
return resolved;
|
|
59281
59431
|
}
|
|
@@ -60681,14 +60831,14 @@ function createDurableChildWorkflowPrimitive(input) {
|
|
|
60681
60831
|
}
|
|
60682
60832
|
|
|
60683
60833
|
// dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts
|
|
60684
|
-
import { isAbsolute as isAbsolute9, join as join10, resolve as
|
|
60834
|
+
import { isAbsolute as isAbsolute9, join as join10, resolve as resolve10 } from "node:path";
|
|
60685
60835
|
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME2 } from "@bastani/atomic";
|
|
60686
60836
|
|
|
60687
60837
|
// dist/builtin/workflows/src/shared/workflow-artifacts.ts
|
|
60688
60838
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
60689
60839
|
import { existsSync } from "node:fs";
|
|
60690
60840
|
import { mkdir, readdir, rm, stat } from "node:fs/promises";
|
|
60691
|
-
import { dirname as
|
|
60841
|
+
import { dirname as dirname3, join as join3 } from "node:path";
|
|
60692
60842
|
import { getAgentDir as getAgentDir4, getEnvValue as getEnvValue2 } from "@bastani/atomic";
|
|
60693
60843
|
|
|
60694
60844
|
// dist/builtin/workflows/src/shared/workflow-artifact-env.ts
|
|
@@ -60703,7 +60853,7 @@ function workflowArtifactRoot() {
|
|
|
60703
60853
|
const override = getEnvValue2(ENV_WORKFLOW_ARTIFACT_DIR);
|
|
60704
60854
|
if (override !== undefined && override.length > 0)
|
|
60705
60855
|
return override;
|
|
60706
|
-
return join3(
|
|
60856
|
+
return join3(dirname3(getAgentDir4()), "workflows");
|
|
60707
60857
|
}
|
|
60708
60858
|
function workflowArtifactRunsRoot() {
|
|
60709
60859
|
return join3(workflowArtifactRoot(), "runs");
|
|
@@ -62027,7 +62177,7 @@ function cleanupWorktrees(setup) {
|
|
|
62027
62177
|
}
|
|
62028
62178
|
// dist/builtin/workflows/src/runs/shared/worktree-cwd.ts
|
|
62029
62179
|
import { lstatSync as lstatSync4, realpathSync as realpathSync5 } from "node:fs";
|
|
62030
|
-
import { dirname as
|
|
62180
|
+
import { dirname as dirname8, isAbsolute as isAbsolute7, relative as relative4, resolve as resolve8, sep as sep5 } from "node:path";
|
|
62031
62181
|
function relativePathWithin(root, candidate) {
|
|
62032
62182
|
const path = relative4(root, candidate);
|
|
62033
62183
|
return path === ".." || path.startsWith(`..${sep5}`) || isAbsolute7(path) ? undefined : path;
|
|
@@ -62046,14 +62196,14 @@ function resolveWorktreeStageCwd(cwd, setup) {
|
|
|
62046
62196
|
if (cwd === undefined || cwd.length === 0)
|
|
62047
62197
|
return;
|
|
62048
62198
|
const absoluteInput = isAbsolute7(cwd);
|
|
62049
|
-
const candidate = absoluteInput ? cwd :
|
|
62199
|
+
const candidate = absoluteInput ? cwd : resolve8(setup.cwd, cwd);
|
|
62050
62200
|
if (!absoluteInput && relativePathWithin(setup.worktreeRoot, candidate) === undefined) {
|
|
62051
62201
|
throw new Error(`atomic-workflows: relative cwd ${cwd} escapes gitWorktreeDir ${setup.worktreeRoot}; choose a cwd inside the worktree.`);
|
|
62052
62202
|
}
|
|
62053
62203
|
const candidateRealPath = existingRealPath(candidate, "cwd");
|
|
62054
62204
|
const worktreeRelative = relativePathWithin(worktreeRoot, candidateRealPath);
|
|
62055
62205
|
if (worktreeRelative !== undefined)
|
|
62056
|
-
return
|
|
62206
|
+
return resolve8(setup.worktreeRoot, worktreeRelative);
|
|
62057
62207
|
if (!isAbsolute7(cwd)) {
|
|
62058
62208
|
throw new Error(`atomic-workflows: relative cwd ${cwd} escapes gitWorktreeDir ${setup.worktreeRoot}; choose a path that remains inside the selected worktree.`);
|
|
62059
62209
|
}
|
|
@@ -62064,7 +62214,7 @@ function resolveWorktreeStageCwd(cwd, setup) {
|
|
|
62064
62214
|
if (repositoryRelative === undefined) {
|
|
62065
62215
|
throw new Error(`atomic-workflows: cwd ${cwd} is outside gitWorktreeDir ${setup.worktreeRoot}; use a cwd inside the invoking repository so Atomic can remap it, or omit cwd.`);
|
|
62066
62216
|
}
|
|
62067
|
-
const mappedCwd =
|
|
62217
|
+
const mappedCwd = resolve8(setup.worktreeRoot, repositoryRelative);
|
|
62068
62218
|
const mappedRealPath = existingRealPath(mappedCwd, "remapped worktree cwd");
|
|
62069
62219
|
if (relativePathWithin(worktreeRoot, mappedRealPath) === undefined) {
|
|
62070
62220
|
throw new Error(`atomic-workflows: cwd ${cwd} remaps through a path that resolves outside gitWorktreeDir ${setup.worktreeRoot}; remove the escaping symlink or omit cwd.`);
|
|
@@ -62074,7 +62224,7 @@ function resolveWorktreeStageCwd(cwd, setup) {
|
|
|
62074
62224
|
|
|
62075
62225
|
// dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts
|
|
62076
62226
|
import { existsSync as existsSync4 } from "node:fs";
|
|
62077
|
-
import { isAbsolute as isAbsolute8, resolve as
|
|
62227
|
+
import { isAbsolute as isAbsolute8, resolve as resolve9 } from "node:path";
|
|
62078
62228
|
function normalizeTaskContexts(previous) {
|
|
62079
62229
|
if (previous === undefined)
|
|
62080
62230
|
return [];
|
|
@@ -62127,7 +62277,7 @@ function taskPrevious(options) {
|
|
|
62127
62277
|
function resolveWorkflowPath(filePath, baseDir) {
|
|
62128
62278
|
if (isAbsolute8(filePath))
|
|
62129
62279
|
return filePath;
|
|
62130
|
-
return
|
|
62280
|
+
return resolve9(baseDir ?? process.cwd(), filePath);
|
|
62131
62281
|
}
|
|
62132
62282
|
function taskBaseDir(options) {
|
|
62133
62283
|
if (typeof options.chainDir === "string" && options.chainDir.trim().length > 0) {
|
|
@@ -62427,7 +62577,7 @@ function workflowInvocationMetadata(inputDefaults, workflowInvocationCwd, cache,
|
|
|
62427
62577
|
function resolvedTaskCwd(cwd, workflowInvocationCwd) {
|
|
62428
62578
|
if (cwd === undefined)
|
|
62429
62579
|
return;
|
|
62430
|
-
return isAbsolute9(cwd) ? cwd :
|
|
62580
|
+
return isAbsolute9(cwd) ? cwd : resolve10(workflowInvocationCwd, cwd);
|
|
62431
62581
|
}
|
|
62432
62582
|
function taskWorktreeOutputsRoot(runId) {
|
|
62433
62583
|
return join10(workflowArtifactRunPath(runId), "task-outputs");
|
|
@@ -62440,7 +62590,7 @@ function prepareTaskWorktrees(tasks, options, runId, scope, workflowInvocationCw
|
|
|
62440
62590
|
throw new Error("atomic-workflows: worktree and gitWorktreeDir are mutually exclusive; use gitWorktreeDir for a reusable worktree or worktree:true for temporary isolated worktrees.");
|
|
62441
62591
|
}
|
|
62442
62592
|
const explicitCwd = tasks.find((task) => typeof task.cwd === "string")?.cwd;
|
|
62443
|
-
const sharedCwd = explicitCwd === undefined ? workflowInvocationCwd : isAbsolute9(explicitCwd) ? explicitCwd :
|
|
62593
|
+
const sharedCwd = explicitCwd === undefined ? workflowInvocationCwd : isAbsolute9(explicitCwd) ? explicitCwd : resolve10(workflowInvocationCwd, explicitCwd);
|
|
62444
62594
|
const conflict = findWorktreeTaskCwdConflict(tasks.map((task) => ({ agent: task.name, cwd: resolvedTaskCwd(task.cwd, workflowInvocationCwd) })), sharedCwd);
|
|
62445
62595
|
if (conflict !== undefined)
|
|
62446
62596
|
throw new Error(formatWorktreeTaskCwdConflict(conflict, sharedCwd));
|
|
@@ -63741,7 +63891,7 @@ function createRunLimiter(defaultConcurrency) {
|
|
|
63741
63891
|
|
|
63742
63892
|
// dist/builtin/workflows/src/shared/possible-stages.ts
|
|
63743
63893
|
import { existsSync as existsSync5, readFileSync as readFileSync2 } from "node:fs";
|
|
63744
|
-
import { dirname as
|
|
63894
|
+
import { dirname as dirname9, join as join11, resolve as resolve11 } from "node:path";
|
|
63745
63895
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
63746
63896
|
var DEFAULT_MAX_DEPTH = 4;
|
|
63747
63897
|
var BUILTIN_BARREL_SPECIFIERS = new Set(["@bastani/atomic/workflows/builtin"]);
|
|
@@ -63750,7 +63900,7 @@ var TRACKED_NODE_METHODS = new Set(["stage", "task", "chain", "parallel", "workf
|
|
|
63750
63900
|
function scanPossibleStagesFromSource(entrySourcePath, options = {}) {
|
|
63751
63901
|
const maxDepth = options.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
63752
63902
|
const scanner = new PossibleStagesScanner(maxDepth);
|
|
63753
|
-
scanner.scanSubtree(
|
|
63903
|
+
scanner.scanSubtree(resolve11(entrySourcePath), "", 0, [resolve11(entrySourcePath)]);
|
|
63754
63904
|
return {
|
|
63755
63905
|
hasTrackedNodes: scanner.hasTrackedNodes,
|
|
63756
63906
|
stages: [...scanner.stages].sort(),
|
|
@@ -65204,9 +65354,9 @@ function resolveRelativeSpecifier(specifier, importingFile) {
|
|
|
65204
65354
|
return;
|
|
65205
65355
|
const candidates = [];
|
|
65206
65356
|
if (specifier.endsWith(".js")) {
|
|
65207
|
-
candidates.push(join11(
|
|
65357
|
+
candidates.push(join11(dirname9(importingFile), `${specifier.slice(0, -3)}.ts`));
|
|
65208
65358
|
}
|
|
65209
|
-
candidates.push(join11(
|
|
65359
|
+
candidates.push(join11(dirname9(importingFile), specifier), join11(dirname9(importingFile), `${specifier}.ts`), join11(dirname9(importingFile), `${specifier}.js`), join11(dirname9(importingFile), specifier, "index.ts"), join11(dirname9(importingFile), specifier, "index.js"));
|
|
65210
65360
|
return candidates.find((candidate) => isFileSync(candidate));
|
|
65211
65361
|
}
|
|
65212
65362
|
function isFileSync(path) {
|
|
@@ -69341,6 +69491,7 @@ async function stripWorkflowOnlyOptions(options, defaultSessionDir, meta, pendin
|
|
|
69341
69491
|
context,
|
|
69342
69492
|
forkFromSessionId,
|
|
69343
69493
|
resumeFromSessionId,
|
|
69494
|
+
resumeFromLegacySessionFile,
|
|
69344
69495
|
sessionStore,
|
|
69345
69496
|
durableReplayKey: _durableReplayKey,
|
|
69346
69497
|
durableAccumulatedDurationMs: _durableAccumulatedDurationMs,
|
|
@@ -69355,7 +69506,9 @@ async function stripWorkflowOnlyOptions(options, defaultSessionDir, meta, pendin
|
|
|
69355
69506
|
} = options;
|
|
69356
69507
|
const cwd = sessionOptions.cwd ?? process.cwd();
|
|
69357
69508
|
if (resumeFromSessionId !== undefined) {
|
|
69358
|
-
|
|
69509
|
+
const store = await stageSessionStore(options, defaultSessionDir);
|
|
69510
|
+
await migrateLegacyStageSession(store, resumeFromSessionId, resumeFromLegacySessionFile);
|
|
69511
|
+
sessionOptions.sessionManager = await SessionManager2.open(store, resumeFromSessionId, cwd);
|
|
69359
69512
|
} else if (context === "fork" && forkFromSessionId !== undefined) {
|
|
69360
69513
|
sessionOptions.sessionManager = await forkStageSession(await stageSessionStore(options, defaultSessionDir), forkFromSessionId, cwd, classification);
|
|
69361
69514
|
} else if (sessionOptions.sessionManager === undefined) {
|
|
@@ -71444,7 +71597,7 @@ class StageSessionController {
|
|
|
71444
71597
|
// dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts
|
|
71445
71598
|
import { createHash as createHash3 } from "node:crypto";
|
|
71446
71599
|
import { mkdir as mkdir2, writeFile } from "node:fs/promises";
|
|
71447
|
-
import { basename as basename4, dirname as
|
|
71600
|
+
import { basename as basename4, dirname as dirname10, isAbsolute as isAbsolute10, join as join12, resolve as resolve12 } from "node:path";
|
|
71448
71601
|
var DEFAULT_MAX_OUTPUT_BYTES = 200 * 1024;
|
|
71449
71602
|
var DEFAULT_MAX_OUTPUT_LINES = 5000;
|
|
71450
71603
|
function normalizeMaxOutput2(maxOutput) {
|
|
@@ -71554,7 +71707,7 @@ function renderTranscript(messages, fallbackOutput) {
|
|
|
71554
71707
|
`);
|
|
71555
71708
|
}
|
|
71556
71709
|
function savedOutputReference(outputPath, fullOutput, transcriptPathValue, transcriptText, transcriptAvailable, warning) {
|
|
71557
|
-
const absolutePath =
|
|
71710
|
+
const absolutePath = resolve12(outputPath);
|
|
71558
71711
|
const bytes = Buffer.byteLength(fullOutput, "utf8");
|
|
71559
71712
|
const lines = countLines(fullOutput);
|
|
71560
71713
|
const transcriptBytes = Buffer.byteLength(transcriptText, "utf8");
|
|
@@ -71569,8 +71722,8 @@ function resolveOutputPath(output, runtimeCwd, requestedCwd) {
|
|
|
71569
71722
|
return;
|
|
71570
71723
|
if (isAbsolute10(output))
|
|
71571
71724
|
return output;
|
|
71572
|
-
const baseCwd = requestedCwd === undefined ? runtimeCwd : isAbsolute10(requestedCwd) ? requestedCwd :
|
|
71573
|
-
return
|
|
71725
|
+
const baseCwd = requestedCwd === undefined ? runtimeCwd : isAbsolute10(requestedCwd) ? requestedCwd : resolve12(runtimeCwd, requestedCwd);
|
|
71726
|
+
return resolve12(baseCwd, output);
|
|
71574
71727
|
}
|
|
71575
71728
|
function degenerateWarning(fullOutput) {
|
|
71576
71729
|
return fullOutput.trim().length === 0 ? "WARNING: the stage artifact is empty; search the companion transcript for this stage's work." : undefined;
|
|
@@ -71629,7 +71782,7 @@ async function finalizePromptOutput(fullOutput, outputOptions, runtimeCwd, runId
|
|
|
71629
71782
|
const transcriptFile = transcriptPath(runId, outputPath);
|
|
71630
71783
|
const transcript = renderTranscript(messages, fullOutput);
|
|
71631
71784
|
try {
|
|
71632
|
-
await mkdir2(
|
|
71785
|
+
await mkdir2(dirname10(outputPath), { recursive: true });
|
|
71633
71786
|
await writeFile(outputPath, fullOutput, "utf8");
|
|
71634
71787
|
} catch (err) {
|
|
71635
71788
|
return `${displayOutput}
|
|
@@ -71641,7 +71794,7 @@ ${err instanceof Error ? err.message : String(err)}`;
|
|
|
71641
71794
|
let transcriptError;
|
|
71642
71795
|
try {
|
|
71643
71796
|
await ensureWorkflowArtifactRunDirectory(runId);
|
|
71644
|
-
await mkdir2(
|
|
71797
|
+
await mkdir2(dirname10(transcriptFile), { recursive: true });
|
|
71645
71798
|
await writeFile(transcriptFile, transcript, "utf8");
|
|
71646
71799
|
transcriptAvailable = true;
|
|
71647
71800
|
} catch (err) {
|
|
@@ -77609,7 +77762,7 @@ async function writeReviewRoundArtifact(artifactDir, reviews, consolidatedFindin
|
|
|
77609
77762
|
// dist/builtin/workflows/builtin/goal-ledger.ts
|
|
77610
77763
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
77611
77764
|
import { readFile as readFile3, rename, rm as rm2, writeFile as writeFile7 } from "node:fs/promises";
|
|
77612
|
-
import { dirname as
|
|
77765
|
+
import { dirname as dirname11, join as join19 } from "node:path";
|
|
77613
77766
|
import { isDeepStrictEqual } from "node:util";
|
|
77614
77767
|
|
|
77615
77768
|
// dist/builtin/workflows/builtin/goal-reducer.ts
|
|
@@ -77847,7 +78000,7 @@ function modelVisibleLedger(ledger) {
|
|
|
77847
78000
|
};
|
|
77848
78001
|
}
|
|
77849
78002
|
function goalLedgerStatePath(ledgerPath) {
|
|
77850
|
-
return join19(
|
|
78003
|
+
return join19(dirname11(ledgerPath), LEDGER_STATE_FILENAME);
|
|
77851
78004
|
}
|
|
77852
78005
|
function appendLifecycleEvent(ledger, event, summary, turn = ledger.turns) {
|
|
77853
78006
|
ledger.lifecycle.push({
|
|
@@ -80142,7 +80295,7 @@ import { Type as Type21 } from "typebox";
|
|
|
80142
80295
|
|
|
80143
80296
|
// dist/builtin/workflows/builtin/ralph-core.ts
|
|
80144
80297
|
import { mkdir as mkdir5, writeFile as writeFile9 } from "node:fs/promises";
|
|
80145
|
-
import { dirname as
|
|
80298
|
+
import { dirname as dirname12, join as join24 } from "node:path";
|
|
80146
80299
|
import { Type as Type20 } from "typebox";
|
|
80147
80300
|
// dist/builtin/workflows/builtin/ralph-review-gate.ts
|
|
80148
80301
|
function reviewDecisionApproved(decision) {
|
|
@@ -80340,7 +80493,7 @@ function artifactSafeName2(value2) {
|
|
|
80340
80493
|
return safe.length > 0 ? safe : "artifact";
|
|
80341
80494
|
}
|
|
80342
80495
|
async function writeJsonArtifact(path, content) {
|
|
80343
|
-
await mkdir5(
|
|
80496
|
+
await mkdir5(dirname12(path), { recursive: true });
|
|
80344
80497
|
await writeFile9(path, `${JSON.stringify(content, null, 2)}
|
|
80345
80498
|
`, {
|
|
80346
80499
|
encoding: "utf8"
|
|
@@ -80410,7 +80563,7 @@ function renderResearchPrompt(args) {
|
|
|
80410
80563
|
|
|
80411
80564
|
// dist/builtin/workflows/builtin/ralph-runner.ts
|
|
80412
80565
|
import { existsSync as existsSync6 } from "node:fs";
|
|
80413
|
-
import { join as join25, resolve as
|
|
80566
|
+
import { join as join25, resolve as resolve13 } from "node:path";
|
|
80414
80567
|
|
|
80415
80568
|
// dist/builtin/workflows/builtin/ralph-reviewer-prompt.ts
|
|
80416
80569
|
function renderRalphReviewerPrompt(args) {
|
|
@@ -80617,7 +80770,7 @@ async function runRalphWorkflow(ctx, options) {
|
|
|
80617
80770
|
let finalPrReport;
|
|
80618
80771
|
const workflowCwdContext = workflowCwdContextSection(workflowStartCwd);
|
|
80619
80772
|
const workflowPrompt = prompt;
|
|
80620
|
-
const workflowResearchPath =
|
|
80773
|
+
const workflowResearchPath = resolve13(workflowStartCwd, defaultResearchPath(workflowPrompt));
|
|
80621
80774
|
const implementationNotesPath = await createImplementationNotesFile(workflowPrompt, runId);
|
|
80622
80775
|
const qaVideoPath = await createQaEvidenceVideoPath(runId);
|
|
80623
80776
|
const artifactDir = await createWorkflowArtifactDirectory(runId);
|
|
@@ -81039,7 +81192,7 @@ import { Type as Type23 } from "typebox";
|
|
|
81039
81192
|
|
|
81040
81193
|
// dist/builtin/workflows/builtin/tournament-runner.ts
|
|
81041
81194
|
import { mkdir as mkdir6, readFile as readFile4, writeFile as writeFile10 } from "node:fs/promises";
|
|
81042
|
-
import { join as join26, isAbsolute as isAbsolute11, relative as relative5, resolve as
|
|
81195
|
+
import { join as join26, isAbsolute as isAbsolute11, relative as relative5, resolve as resolve14 } from "node:path";
|
|
81043
81196
|
import { Type as Type22 } from "typebox";
|
|
81044
81197
|
|
|
81045
81198
|
// dist/builtin/workflows/builtin/selection-math.ts
|
|
@@ -81254,8 +81407,8 @@ function criterionSlug(id) {
|
|
|
81254
81407
|
}
|
|
81255
81408
|
function judgeArtifactPath(judgesDir, job, criterionIndex) {
|
|
81256
81409
|
const filename = `judge-${job.a}-${job.b}-c${criterionIndex}-${criterionSlug(job.criterionId)}-r${job.rep}.json`;
|
|
81257
|
-
const root =
|
|
81258
|
-
const path =
|
|
81410
|
+
const root = resolve14(judgesDir);
|
|
81411
|
+
const path = resolve14(judgesDir, filename);
|
|
81259
81412
|
const fromRoot = relative5(root, path);
|
|
81260
81413
|
if (fromRoot.startsWith("..") || isAbsolute11(fromRoot)) {
|
|
81261
81414
|
throw new Error(`tournament: judge artifact escaped its directory: ${path}`);
|
|
@@ -81655,7 +81808,7 @@ function createRegistry(initial = []) {
|
|
|
81655
81808
|
|
|
81656
81809
|
// dist/builtin/workflows/src/extension/discovery-loaders.ts
|
|
81657
81810
|
import { readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
81658
|
-
import { extname, isAbsolute as isAbsolute12, join as join29, resolve as
|
|
81811
|
+
import { extname, isAbsolute as isAbsolute12, join as join29, resolve as resolve15 } from "node:path";
|
|
81659
81812
|
|
|
81660
81813
|
// ../../node_modules/jiti/lib/jiti-static.mjs
|
|
81661
81814
|
var import_jiti = __toESM(require_jiti(), 1);
|
|
@@ -82220,11 +82373,11 @@ function registerRunJournalConformance(runner, name, open, observeRead) {
|
|
|
82220
82373
|
});
|
|
82221
82374
|
}
|
|
82222
82375
|
// dist/builtin/workflows/src/durable/journal/sqlite-run-journal.ts
|
|
82223
|
-
import { dirname as
|
|
82376
|
+
import { dirname as dirname13, join as join27 } from "node:path";
|
|
82224
82377
|
import { getAgentDir as getAgentDir5, openNodeSqliteDatabase, validateStoragePrefix, wrapNodeSqliteDatabase } from "@bastani/atomic";
|
|
82225
82378
|
function workflowJournalPath() {
|
|
82226
82379
|
const override = process.env.ATOMIC_WORKFLOW_JOURNAL_PATH;
|
|
82227
|
-
return override !== undefined && override.length > 0 ? override : join27(
|
|
82380
|
+
return override !== undefined && override.length > 0 ? override : join27(dirname13(getAgentDir5()), "workflows", "journal.sqlite");
|
|
82228
82381
|
}
|
|
82229
82382
|
async function openSqlRunJournal(source = workflowJournalPath(), options = {}) {
|
|
82230
82383
|
validateStoragePrefix(options.prefix);
|
|
@@ -83077,7 +83230,7 @@ async function loadFromPaths(pathsOrMap, kind, baseCwd, diagnostics, getWorkflow
|
|
|
83077
83230
|
const all = [];
|
|
83078
83231
|
const entries = Array.isArray(pathsOrMap) ? pathsOrMap.map((p) => ({ rawPath: p })) : Object.entries(pathsOrMap).map(([name, p]) => ({ rawPath: p, configuredName: name }));
|
|
83079
83232
|
for (const { rawPath, configuredName } of entries) {
|
|
83080
|
-
const absPath = isAbsolute12(rawPath) ? rawPath :
|
|
83233
|
+
const absPath = isAbsolute12(rawPath) ? rawPath : resolve15(baseCwd, rawPath);
|
|
83081
83234
|
let pathStats;
|
|
83082
83235
|
try {
|
|
83083
83236
|
pathStats = await stat2(absPath);
|
|
@@ -84093,7 +84246,7 @@ function createExtensionRuntime(opts = {}) {
|
|
|
84093
84246
|
|
|
84094
84247
|
// dist/builtin/workflows/src/extension/status-writer.ts
|
|
84095
84248
|
import { mkdir as mkdir7, rename as rename2, writeFile as writeFile11 } from "node:fs/promises";
|
|
84096
|
-
import { dirname as
|
|
84249
|
+
import { dirname as dirname14, join as join31 } from "node:path";
|
|
84097
84250
|
import { CONFIG_DIR_NAME as CONFIG_DIR_NAME4 } from "@bastani/atomic";
|
|
84098
84251
|
var DEFAULT_STATUS_SUBPATH = join31(CONFIG_DIR_NAME4, "workflows", "status.json");
|
|
84099
84252
|
function resolveStatusFilePath(config, opts = {}) {
|
|
@@ -84103,7 +84256,7 @@ function resolveStatusFilePath(config, opts = {}) {
|
|
|
84103
84256
|
return join31(root, DEFAULT_STATUS_SUBPATH);
|
|
84104
84257
|
}
|
|
84105
84258
|
async function atomicWriteJson(path, content) {
|
|
84106
|
-
const dir =
|
|
84259
|
+
const dir = dirname14(path);
|
|
84107
84260
|
await mkdir7(dir, { recursive: true });
|
|
84108
84261
|
const tmpPath = `${path}.tmp`;
|
|
84109
84262
|
await writeFile11(tmpPath, content, "utf8");
|