smithers-orchestrator 0.25.0 → 0.25.2
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/package.json +23 -23
- package/src/MigrateSmithersStoreOptions.ts +2 -1
- package/src/OpenSmithersStoreOptions.ts +9 -0
- package/src/OpenSmithersStoreResult.ts +10 -0
- package/src/ResolveSmithersBackendChoiceOptions.ts +3 -0
- package/src/SmithersBackendChoice.ts +12 -1
- package/src/SmithersMigrationResult.ts +9 -2
- package/src/bin/smithers-delegation.js +98 -0
- package/src/bin/smithers.js +7 -98
- package/src/index.js +1 -0
- package/src/migrateSmithersStore.js +589 -28
- package/src/openSmithersBackend.js +3 -0
- package/src/openSmithersStore.js +227 -0
- package/src/resolveSmithersBackendChoice.js +276 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smithers-orchestrator",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.2",
|
|
4
4
|
"description": "Public Smithers facade for durable coding-agent workflows and Gateway operation",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://smithers.sh",
|
|
@@ -92,28 +92,28 @@
|
|
|
92
92
|
"incur": "^0.4.1",
|
|
93
93
|
"react": "^19.2.5",
|
|
94
94
|
"zod": "^4.3.6",
|
|
95
|
-
"@smithers-orchestrator/agents": "0.25.
|
|
96
|
-
"@smithers-orchestrator/components": "0.25.
|
|
97
|
-
"@smithers-orchestrator/control-plane": "0.25.
|
|
98
|
-
"@smithers-orchestrator/db": "0.25.
|
|
99
|
-
"@smithers-orchestrator/
|
|
100
|
-
"@smithers-orchestrator/driver": "0.25.
|
|
101
|
-
"@smithers-orchestrator/
|
|
102
|
-
"@smithers-orchestrator/
|
|
103
|
-
"@smithers-orchestrator/
|
|
104
|
-
"@smithers-orchestrator/
|
|
105
|
-
"@smithers-orchestrator/
|
|
106
|
-
"@smithers-orchestrator/
|
|
107
|
-
"@smithers-orchestrator/
|
|
108
|
-
"@smithers-orchestrator/
|
|
109
|
-
"@smithers-orchestrator/sandbox": "0.25.
|
|
110
|
-
"@smithers-orchestrator/scorers": "0.25.
|
|
111
|
-
"@smithers-orchestrator/
|
|
112
|
-
"@smithers-orchestrator/server": "0.25.
|
|
113
|
-
"@smithers-orchestrator/
|
|
114
|
-
"@smithers-orchestrator/
|
|
115
|
-
"@smithers-orchestrator/
|
|
116
|
-
"@smithers-orchestrator/
|
|
95
|
+
"@smithers-orchestrator/agents": "0.25.2",
|
|
96
|
+
"@smithers-orchestrator/components": "0.25.2",
|
|
97
|
+
"@smithers-orchestrator/control-plane": "0.25.2",
|
|
98
|
+
"@smithers-orchestrator/db": "0.25.2",
|
|
99
|
+
"@smithers-orchestrator/cli": "0.25.2",
|
|
100
|
+
"@smithers-orchestrator/driver": "0.25.2",
|
|
101
|
+
"@smithers-orchestrator/gateway-client": "0.25.2",
|
|
102
|
+
"@smithers-orchestrator/engine": "0.25.2",
|
|
103
|
+
"@smithers-orchestrator/graph": "0.25.2",
|
|
104
|
+
"@smithers-orchestrator/errors": "0.25.2",
|
|
105
|
+
"@smithers-orchestrator/gateway-react": "0.25.2",
|
|
106
|
+
"@smithers-orchestrator/memory": "0.25.2",
|
|
107
|
+
"@smithers-orchestrator/react-reconciler": "0.25.2",
|
|
108
|
+
"@smithers-orchestrator/observability": "0.25.2",
|
|
109
|
+
"@smithers-orchestrator/sandbox": "0.25.2",
|
|
110
|
+
"@smithers-orchestrator/scorers": "0.25.2",
|
|
111
|
+
"@smithers-orchestrator/openapi": "0.25.2",
|
|
112
|
+
"@smithers-orchestrator/server": "0.25.2",
|
|
113
|
+
"@smithers-orchestrator/scheduler": "0.25.2",
|
|
114
|
+
"@smithers-orchestrator/time-travel": "0.25.2",
|
|
115
|
+
"@smithers-orchestrator/tool-context": "0.25.2",
|
|
116
|
+
"@smithers-orchestrator/vcs": "0.25.2"
|
|
117
117
|
},
|
|
118
118
|
"optionalDependencies": {
|
|
119
119
|
"@electric-sql/pglite": "0.5.1",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export type MigrateSmithersStoreOptions = {
|
|
2
2
|
cwd?: string;
|
|
3
3
|
dbPath?: string;
|
|
4
|
-
|
|
4
|
+
from?: "sqlite" | "pglite" | "postgres";
|
|
5
|
+
to?: "sqlite" | "pglite" | "postgres";
|
|
5
6
|
url?: string;
|
|
6
7
|
env?: Record<string, string | undefined>;
|
|
7
8
|
pgliteDataDir?: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SmithersDb } from "@smithers-orchestrator/db/adapter";
|
|
2
|
+
import type { SmithersBackendChoice } from "./SmithersBackendChoice";
|
|
3
|
+
|
|
4
|
+
export type OpenSmithersStoreResult = {
|
|
5
|
+
choice: SmithersBackendChoice;
|
|
6
|
+
adapter: SmithersDb;
|
|
7
|
+
db: unknown;
|
|
8
|
+
dbPath?: string;
|
|
9
|
+
cleanup: () => Promise<void> | void;
|
|
10
|
+
};
|
|
@@ -2,6 +2,9 @@ export type ResolveSmithersBackendChoiceOptions = {
|
|
|
2
2
|
backend?: "sqlite" | "pglite" | "postgres";
|
|
3
3
|
cwd?: string;
|
|
4
4
|
dbPath?: string;
|
|
5
|
+
pgliteDataDir?: string;
|
|
6
|
+
connectionString?: string;
|
|
7
|
+
connection?: { query?: (...args: any[]) => Promise<any> };
|
|
5
8
|
configPath?: string;
|
|
6
9
|
env?: Record<string, string | undefined>;
|
|
7
10
|
};
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
export type SmithersBackendChoice = {
|
|
2
2
|
backend: "sqlite" | "pglite" | "postgres";
|
|
3
|
-
source: "options" | "env" | "config" | "default";
|
|
3
|
+
source: "options" | "env" | "config" | "marker" | "default";
|
|
4
4
|
dbPath: string;
|
|
5
5
|
workspaceRoot: string;
|
|
6
6
|
runCount: number;
|
|
7
7
|
schemaVersion: string;
|
|
8
|
+
sqlite: { dbPath: string; exists: boolean; runCount: number; schemaVersion: string };
|
|
9
|
+
pglite: { dataDir: string; exists: boolean; initialized: boolean; hasRunsTable?: boolean; runCount: number; schemaVersion: string; error?: string };
|
|
10
|
+
postgres: {
|
|
11
|
+
exists: boolean;
|
|
12
|
+
initialized: boolean;
|
|
13
|
+
hasRunsTable?: boolean;
|
|
14
|
+
runCount: number;
|
|
15
|
+
schemaVersion: string;
|
|
16
|
+
connectionString?: "set";
|
|
17
|
+
error?: string;
|
|
18
|
+
};
|
|
8
19
|
migratedMarker: boolean;
|
|
9
20
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
export type SmithersMigrationResult = {
|
|
2
|
-
backend: "pglite" | "postgres";
|
|
2
|
+
backend: "sqlite" | "pglite" | "postgres";
|
|
3
|
+
source: {
|
|
4
|
+
backend: "sqlite" | "pglite" | "postgres";
|
|
5
|
+
dbPath?: string;
|
|
6
|
+
dataDir?: string;
|
|
7
|
+
url?: string;
|
|
8
|
+
};
|
|
3
9
|
dbPath: string;
|
|
4
10
|
markerPath: string;
|
|
5
11
|
target: {
|
|
6
|
-
backend: "pglite" | "postgres";
|
|
12
|
+
backend: "sqlite" | "pglite" | "postgres";
|
|
13
|
+
dbPath?: string;
|
|
7
14
|
dataDir?: string;
|
|
8
15
|
url?: string;
|
|
9
16
|
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, parse, resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
const WORKFLOW_PATH_COMMANDS = new Set([
|
|
5
|
+
"up",
|
|
6
|
+
"graph",
|
|
7
|
+
"fork",
|
|
8
|
+
"replay",
|
|
9
|
+
"revert",
|
|
10
|
+
"timetravel",
|
|
11
|
+
]);
|
|
12
|
+
const WORKFLOW_EXTENSIONS = new Set([".js", ".jsx", ".ts", ".tsx", ".mjs", ".mts"]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} value
|
|
16
|
+
*/
|
|
17
|
+
export function isOptionLike(value) {
|
|
18
|
+
return value.startsWith("-");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @param {string} value
|
|
23
|
+
*/
|
|
24
|
+
export function looksLikeWorkflowPath(value) {
|
|
25
|
+
if (isOptionLike(value))
|
|
26
|
+
return false;
|
|
27
|
+
return WORKFLOW_EXTENSIONS.has(parse(value).ext);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @param {string[]} args
|
|
32
|
+
*/
|
|
33
|
+
export function getExplicitWorkflowPath(args) {
|
|
34
|
+
if (args.length === 0)
|
|
35
|
+
return null;
|
|
36
|
+
if (looksLikeWorkflowPath(args[0]))
|
|
37
|
+
return args[0];
|
|
38
|
+
for (let index = 0; index < args.length; index++) {
|
|
39
|
+
const arg = args[index];
|
|
40
|
+
if (!WORKFLOW_PATH_COMMANDS.has(arg))
|
|
41
|
+
continue;
|
|
42
|
+
for (let nextIndex = index + 1; nextIndex < args.length; nextIndex++) {
|
|
43
|
+
const candidate = args[nextIndex];
|
|
44
|
+
if (looksLikeWorkflowPath(candidate))
|
|
45
|
+
return candidate;
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
for (const arg of args) {
|
|
50
|
+
if (looksLikeWorkflowPath(arg))
|
|
51
|
+
return arg;
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the local `smithers-orchestrator` package's bin JS file under
|
|
58
|
+
* `<directory>/node_modules/`. Going through `package.json` (instead of the
|
|
59
|
+
* `.bin/smithers` shell shim npm/pnpm generate) is the whole point: the shim
|
|
60
|
+
* is `#!/bin/sh` and re-execing it with `process.execPath` (bun) makes bun
|
|
61
|
+
* parse shell as JavaScript, which crashes with `Expected ")" but found
|
|
62
|
+
* "$(echo "`.
|
|
63
|
+
*
|
|
64
|
+
* @param {string} directory
|
|
65
|
+
*/
|
|
66
|
+
export function resolveLocalSmithersBinJs(directory) {
|
|
67
|
+
const pkgJsonPath = resolve(directory, "node_modules/smithers-orchestrator/package.json");
|
|
68
|
+
if (!existsSync(pkgJsonPath))
|
|
69
|
+
return null;
|
|
70
|
+
let pkg;
|
|
71
|
+
try {
|
|
72
|
+
pkg = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const binEntry = typeof pkg?.bin === "string" ? pkg.bin : pkg?.bin?.smithers;
|
|
77
|
+
if (typeof binEntry !== "string" || binEntry.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
const binPath = resolve(dirname(pkgJsonPath), binEntry);
|
|
80
|
+
return existsSync(binPath) ? binPath : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {string} cwd
|
|
85
|
+
* @param {string} workflowPath
|
|
86
|
+
*/
|
|
87
|
+
export function findNearestWorkflowLocalCli(cwd, workflowPath) {
|
|
88
|
+
let current = dirname(resolve(cwd, workflowPath));
|
|
89
|
+
while (true) {
|
|
90
|
+
const localBin = resolveLocalSmithersBinJs(current);
|
|
91
|
+
if (localBin)
|
|
92
|
+
return localBin;
|
|
93
|
+
const parent = dirname(current);
|
|
94
|
+
if (parent === current)
|
|
95
|
+
return null;
|
|
96
|
+
current = parent;
|
|
97
|
+
}
|
|
98
|
+
}
|
package/src/bin/smithers.js
CHANGED
|
@@ -1,104 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"replay",
|
|
12
|
-
"revert",
|
|
13
|
-
"timetravel",
|
|
14
|
-
]);
|
|
15
|
-
const WORKFLOW_EXTENSIONS = new Set([".js", ".jsx", ".ts", ".tsx", ".mjs", ".mts"]);
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {string} value
|
|
19
|
-
*/
|
|
20
|
-
function isOptionLike(value) {
|
|
21
|
-
return value.startsWith("-");
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* @param {string} value
|
|
26
|
-
*/
|
|
27
|
-
function looksLikeWorkflowPath(value) {
|
|
28
|
-
if (isOptionLike(value))
|
|
29
|
-
return false;
|
|
30
|
-
return WORKFLOW_EXTENSIONS.has(parse(value).ext);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* @param {string[]} args
|
|
35
|
-
*/
|
|
36
|
-
function getExplicitWorkflowPath(args) {
|
|
37
|
-
if (args.length === 0)
|
|
38
|
-
return null;
|
|
39
|
-
if (looksLikeWorkflowPath(args[0]))
|
|
40
|
-
return args[0];
|
|
41
|
-
for (let index = 0; index < args.length; index++) {
|
|
42
|
-
const arg = args[index];
|
|
43
|
-
if (!WORKFLOW_PATH_COMMANDS.has(arg))
|
|
44
|
-
continue;
|
|
45
|
-
for (let nextIndex = index + 1; nextIndex < args.length; nextIndex++) {
|
|
46
|
-
const candidate = args[nextIndex];
|
|
47
|
-
if (looksLikeWorkflowPath(candidate))
|
|
48
|
-
return candidate;
|
|
49
|
-
}
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
for (const arg of args) {
|
|
53
|
-
if (looksLikeWorkflowPath(arg))
|
|
54
|
-
return arg;
|
|
55
|
-
}
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Resolve the local `smithers-orchestrator` package's bin JS file under
|
|
61
|
-
* `<directory>/node_modules/`. Going through `package.json` (instead of the
|
|
62
|
-
* `.bin/smithers` shell shim npm/pnpm generate) is the whole point: the shim
|
|
63
|
-
* is `#!/bin/sh` and re-execing it with `process.execPath` (bun) makes bun
|
|
64
|
-
* parse shell as JavaScript, which crashes with `Expected ")" but found
|
|
65
|
-
* "$(echo "`.
|
|
66
|
-
*
|
|
67
|
-
* @param {string} directory
|
|
68
|
-
*/
|
|
69
|
-
function resolveLocalSmithersBinJs(directory) {
|
|
70
|
-
const pkgJsonPath = resolve(directory, "node_modules/smithers-orchestrator/package.json");
|
|
71
|
-
if (!existsSync(pkgJsonPath))
|
|
72
|
-
return null;
|
|
73
|
-
let pkg;
|
|
74
|
-
try {
|
|
75
|
-
pkg = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
76
|
-
} catch {
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
const binEntry = typeof pkg?.bin === "string" ? pkg.bin : pkg?.bin?.smithers;
|
|
80
|
-
if (typeof binEntry !== "string" || binEntry.length === 0)
|
|
81
|
-
return null;
|
|
82
|
-
const binPath = resolve(dirname(pkgJsonPath), binEntry);
|
|
83
|
-
return existsSync(binPath) ? binPath : null;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* @param {string} cwd
|
|
88
|
-
* @param {string} workflowPath
|
|
89
|
-
*/
|
|
90
|
-
function findNearestWorkflowLocalCli(cwd, workflowPath) {
|
|
91
|
-
let current = dirname(resolve(cwd, workflowPath));
|
|
92
|
-
while (true) {
|
|
93
|
-
const localBin = resolveLocalSmithersBinJs(current);
|
|
94
|
-
if (localBin)
|
|
95
|
-
return localBin;
|
|
96
|
-
const parent = dirname(current);
|
|
97
|
-
if (parent === current)
|
|
98
|
-
return null;
|
|
99
|
-
current = parent;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
6
|
+
import {
|
|
7
|
+
getExplicitWorkflowPath,
|
|
8
|
+
findNearestWorkflowLocalCli,
|
|
9
|
+
resolveLocalSmithersBinJs,
|
|
10
|
+
} from "./smithers-delegation.js";
|
|
102
11
|
|
|
103
12
|
/**
|
|
104
13
|
* When a workflow directory (`.smithers/`) exists in the user's cwd and it's
|
package/src/index.js
CHANGED
|
@@ -188,6 +188,7 @@ export { runJj, getJjPointer, revertToJjPointer, isJjRepo, workspaceAdd, workspa
|
|
|
188
188
|
// Core API
|
|
189
189
|
export { createSmithers, createSmithersPostgres } from "./create.js";
|
|
190
190
|
export { openSmithersBackend } from "./openSmithersBackend.js";
|
|
191
|
+
export { openSmithersStore } from "./openSmithersStore.js";
|
|
191
192
|
export { resolveSmithersBackendChoice } from "./resolveSmithersBackendChoice.js";
|
|
192
193
|
export { migrateSmithersStore } from "./migrateSmithersStore.js";
|
|
193
194
|
export {
|