@bastani/atomic 0.9.82-alpha.1 → 0.9.83-alpha.1
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 +23 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/extension/index.bundle.mjs +2 -16
- package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +2 -16
- package/dist/builtin/workflows/src/index.js +2 -16
- package/dist/builtin/workflows/src/local-worker-entry.mjs +2 -16
- package/dist/cli/storage-command.d.ts +11 -1
- package/dist/cli/storage-command.d.ts.map +1 -1
- package/dist/cli/storage-command.js +102 -4
- package/dist/cli/storage-command.js.map +1 -1
- package/dist/core/storage/journal-adoption.d.ts +48 -0
- package/dist/core/storage/journal-adoption.d.ts.map +1 -1
- package/dist/core/storage/journal-adoption.js +41 -1
- package/dist/core/storage/journal-adoption.js.map +1 -1
- package/dist/core/storage/journal-transfer.d.ts +126 -0
- package/dist/core/storage/journal-transfer.d.ts.map +1 -0
- package/dist/core/storage/journal-transfer.js +690 -0
- package/dist/core/storage/journal-transfer.js.map +1 -0
- package/docs/reference/cli.md +4 -0
- package/docs/storage.md +54 -0
- package/npm-shrinkwrap.json +32 -32
- package/package.json +3 -3
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow runs as versioned JSONL files (#4716): `exportWorkflowRuns` writes each run of a local workflow journal to
|
|
3
|
+
* `<dir>/<runId>.jsonl`, and `importWorkflowRuns` restores such files into one. The journal stays the working store;
|
|
4
|
+
* the files are the form runs take at rest, so a host that persists only files can carry them between machines.
|
|
5
|
+
*
|
|
6
|
+
* Line 1 of a file is the run's header: the row of the journal's runs table. Every later line is one row of its
|
|
7
|
+
* events table, in sequence order, with its payload as a JSON value instead of JSON text. Leases, local-worker pool
|
|
8
|
+
* state and worktree snapshot blobs are not exported: they belong to the machine that wrote them.
|
|
9
|
+
*/
|
|
10
|
+
import { StorageError, type StorageFailureCause } from "./errors.js";
|
|
11
|
+
/** The `type` of an export file's header line. */
|
|
12
|
+
export declare const WORKFLOW_RUN_EXPORT_TYPE = "atomic.workflow-run";
|
|
13
|
+
/** The export format version this Atomic writes and reads. */
|
|
14
|
+
export declare const WORKFLOW_RUN_EXPORT_VERSION = 1;
|
|
15
|
+
/** The file name extension of an exported run; import reads every file with it and ignores the rest. */
|
|
16
|
+
export declare const WORKFLOW_RUN_EXPORT_EXTENSION = ".jsonl";
|
|
17
|
+
/**
|
|
18
|
+
* A lease renewed this recently belongs to a process that may still be running the run on this machine, so an import
|
|
19
|
+
* does not add events to that run. It matches the window in which the workflows runtime treats a running run's owner
|
|
20
|
+
* as live.
|
|
21
|
+
*/
|
|
22
|
+
export declare const WORKFLOW_RUN_IMPORT_LIVE_LEASE_MS = 120000;
|
|
23
|
+
/** A JSON value as an export file holds it. */
|
|
24
|
+
export type WorkflowRunExportValue = string | number | boolean | null | readonly WorkflowRunExportValue[] | {
|
|
25
|
+
readonly [key: string]: WorkflowRunExportValue;
|
|
26
|
+
};
|
|
27
|
+
/** Line 1 of an export file. */
|
|
28
|
+
export interface WorkflowRunExportHeader {
|
|
29
|
+
readonly type: typeof WORKFLOW_RUN_EXPORT_TYPE;
|
|
30
|
+
readonly version: typeof WORKFLOW_RUN_EXPORT_VERSION;
|
|
31
|
+
readonly runId: string;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly cwd: string;
|
|
34
|
+
readonly createdAt: number;
|
|
35
|
+
/** The run's latest status. */
|
|
36
|
+
readonly status: string;
|
|
37
|
+
/** How many event lines follow. */
|
|
38
|
+
readonly events: number;
|
|
39
|
+
/** The run header the journal recorded when the run was created. */
|
|
40
|
+
readonly header: {
|
|
41
|
+
readonly [key: string]: WorkflowRunExportValue;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** One event line of an export file: one journal entry. */
|
|
45
|
+
export interface WorkflowRunExportEvent {
|
|
46
|
+
readonly type: string;
|
|
47
|
+
readonly seq: number;
|
|
48
|
+
readonly epoch: number;
|
|
49
|
+
readonly key: string | null;
|
|
50
|
+
readonly at: number;
|
|
51
|
+
readonly payload: WorkflowRunExportValue;
|
|
52
|
+
}
|
|
53
|
+
/** The local workflow journal storage that runs are exported from and imported into. */
|
|
54
|
+
export type WorkflowRunTransferStorage = {
|
|
55
|
+
readonly kind: "store";
|
|
56
|
+
readonly directory: string;
|
|
57
|
+
} | {
|
|
58
|
+
readonly kind: "sqlite";
|
|
59
|
+
readonly path: string;
|
|
60
|
+
readonly prefix?: string;
|
|
61
|
+
};
|
|
62
|
+
export interface WorkflowRunTransferErrorInit {
|
|
63
|
+
/** The file or storage location the error is about. */
|
|
64
|
+
readonly path: string;
|
|
65
|
+
/** The 1-based line of `path`. */
|
|
66
|
+
readonly line?: number;
|
|
67
|
+
readonly runId?: string;
|
|
68
|
+
readonly reason: string;
|
|
69
|
+
readonly cause?: StorageFailureCause;
|
|
70
|
+
}
|
|
71
|
+
/** An export or import that could not be done; an import that fails this way changed nothing. */
|
|
72
|
+
export declare class WorkflowRunTransferError extends StorageError {
|
|
73
|
+
readonly name: "WorkflowRunTransferError";
|
|
74
|
+
readonly path: string;
|
|
75
|
+
readonly line: number | undefined;
|
|
76
|
+
readonly runId: string | undefined;
|
|
77
|
+
readonly reason: string;
|
|
78
|
+
constructor(init: WorkflowRunTransferErrorInit);
|
|
79
|
+
}
|
|
80
|
+
export declare function isWorkflowRunTransferError(value: unknown): value is WorkflowRunTransferError;
|
|
81
|
+
export interface WorkflowRunExportOptions {
|
|
82
|
+
/** Only these runs; a run the storage does not hold fails the export before any file is written. */
|
|
83
|
+
readonly runs?: readonly string[];
|
|
84
|
+
/** Only runs that are not completed, failed or cancelled. */
|
|
85
|
+
readonly unfinished?: boolean;
|
|
86
|
+
/** At most this many runs, newest first. */
|
|
87
|
+
readonly limit?: number;
|
|
88
|
+
}
|
|
89
|
+
export interface WorkflowRunExportReport {
|
|
90
|
+
/** Runs whose file was written. */
|
|
91
|
+
readonly written: readonly string[];
|
|
92
|
+
/** Runs whose file already held exactly this export, left untouched. */
|
|
93
|
+
readonly unchanged: readonly string[];
|
|
94
|
+
/** Journal files that could not be read, and runs the catalog lists that no readable journal holds. */
|
|
95
|
+
readonly skipped: readonly {
|
|
96
|
+
readonly path: string;
|
|
97
|
+
readonly runId?: string;
|
|
98
|
+
readonly reason: string;
|
|
99
|
+
}[];
|
|
100
|
+
}
|
|
101
|
+
export interface WorkflowRunImportReport {
|
|
102
|
+
/** Runs the storage did not hold. */
|
|
103
|
+
readonly added: readonly string[];
|
|
104
|
+
/** Runs the storage held an earlier part of, which now have the file's later events. */
|
|
105
|
+
readonly updated: readonly string[];
|
|
106
|
+
/** Runs the storage already held every event of. */
|
|
107
|
+
readonly unchanged: readonly string[];
|
|
108
|
+
}
|
|
109
|
+
/** The file an exported run is written to in `directory`. */
|
|
110
|
+
export declare function workflowRunExportFile(directory: string, runId: string): string;
|
|
111
|
+
/**
|
|
112
|
+
* Exports runs of a local workflow journal to `<directory>/<runId>.jsonl`, one file per run. Each journal file is read
|
|
113
|
+
* in one read transaction, and each export file is written whole or not at all. The same journal state gives the same
|
|
114
|
+
* bytes, and a file that already holds them is not rewritten.
|
|
115
|
+
*/
|
|
116
|
+
export declare function exportWorkflowRuns(storage: WorkflowRunTransferStorage, directory: string, options?: WorkflowRunExportOptions): Promise<WorkflowRunExportReport>;
|
|
117
|
+
/**
|
|
118
|
+
* Imports every `<name>.jsonl` export file in `directory` into a local workflow journal. Every file is read and checked,
|
|
119
|
+
* and every run compared with the storage's copy, before anything is written: a malformed file, an unsupported version,
|
|
120
|
+
* a run that continued differently here, or a run a process here may still be running fails the import with the file
|
|
121
|
+
* and line, and nothing changes. A run the storage does not hold is added; one whose earlier events it holds gets the
|
|
122
|
+
* file's later ones; one it holds every event of is left as it is, so importing again changes nothing. String values
|
|
123
|
+
* inside the records are not compared, so a file whose strings a tool redacted imports as the run it was exported from.
|
|
124
|
+
*/
|
|
125
|
+
export declare function importWorkflowRuns(storage: WorkflowRunTransferStorage, directory: string): Promise<WorkflowRunImportReport>;
|
|
126
|
+
//# sourceMappingURL=journal-transfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal-transfer.d.ts","sourceRoot":"","sources":["../../../src/core/storage/journal-transfer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAoBrE,kDAAkD;AAClD,eAAO,MAAM,wBAAwB,wBAAwB,CAAC;AAC9D,8DAA8D;AAC9D,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,wGAAwG;AACxG,eAAO,MAAM,6BAA6B,WAAW,CAAC;AACtD;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,SAAU,CAAC;AAEzD,+CAA+C;AAC/C,MAAM,MAAM,sBAAsB,GAC/B,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,sBAAsB,EAAE,GACjC;IAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,sBAAsB,CAAA;CAAE,CAAC;AAEtD,gCAAgC;AAChC,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,IAAI,EAAE,OAAO,wBAAwB,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,OAAO,2BAA2B,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,mCAAmC;IACnC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