@nathanstephenson/flow 0.1.3 → 0.1.5
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/README.md +46 -2
- package/build/workflow-runtime.cjs +1 -46
- package/dist/backend/claude/index.js +109 -35
- package/dist/backend/claude/permissions.js +26 -15
- package/dist/backend/claude/subagents.js +4 -0
- package/dist/backend/mcp-stdio-supervisor.js +196 -0
- package/dist/backend/mcp.js +146 -51
- package/dist/backend/permission-errors.js +3 -0
- package/dist/backend/pi/agent-permissions.js +74 -0
- package/dist/backend/pi/index.js +29 -9
- package/dist/backend/registry.js +5 -30
- package/dist/backend/worker/assets.js +16 -0
- package/dist/backend/worker/claude-state.js +183 -0
- package/dist/backend/worker/entry.js +186 -0
- package/dist/backend/worker/index.js +257 -0
- package/dist/backend/worker/launcher.js +67 -0
- package/dist/backend/worker/protocol.js +11 -0
- package/dist/backend/worker/rpc.js +108 -0
- package/dist/build-id +1 -1
- package/dist/cli/bootstrap.js +1 -1
- package/dist/cli/main.js +9 -1
- package/dist/client/connection.js +107 -2
- package/dist/client/diff.js +43 -0
- package/dist/client/reduce.js +3 -0
- package/dist/daemon/config-store.js +36 -1
- package/dist/daemon/config.js +54 -18
- package/dist/daemon/host.js +279 -29
- package/dist/daemon/log.js +98 -0
- package/dist/daemon/runtime.js +10 -1
- package/dist/daemon/server.js +67 -1
- package/dist/daemon/workflow-execution-routes.js +1 -1
- package/dist/daemon/workflow-executions.js +63 -25
- package/dist/daemon/workflow-mcp.js +2 -4
- package/dist/daemon/workflow-routes.js +4 -3
- package/dist/isolation/filesystem.js +382 -0
- package/dist/isolation/launcher.js +40 -0
- package/dist/isolation/node-assets.js +84 -0
- package/dist/isolation/support.js +40 -0
- package/dist/isolation/toolchain-assets.js +62 -0
- package/dist/protocol/presentation.js +230 -0
- package/dist/protocol/settings.js +1 -4
- package/dist/workflows/executors.js +118 -62
- package/dist/workflows/graph.js +3 -6
- package/dist/workflows/json-schema.js +8 -3
- package/dist/workflows/mcp.js +15 -1
- package/dist/workflows/runtime-settings.js +7 -7
- package/dist/workflows/runtime.js +1 -34
- package/package.json +1 -1
- package/web/dist/assets/index-2oJWC9JF.css +2 -0
- package/web/dist/assets/index-6BD3ul5N.js +174 -0
- package/web/dist/assets/input-CqyJUgIE.js +6 -0
- package/web/dist/assets/settings-mcp-DOQOULdG.js +1 -0
- package/web/dist/assets/settings-secrets-D3zCO2H1.js +1 -0
- package/web/dist/assets/settings-workflows-BSVIqm4R.js +23 -0
- package/web/dist/assets/switch-ehZe7Kr5.js +1 -0
- package/web/dist/assets/workflows-DC1k1O8g.js +7 -0
- package/web/dist/assets/workflows-pane-B0hL69SD.js +1 -0
- package/web/dist/index.html +4 -4
- package/web/dist/assets/index-BmX_AxCZ.js +0 -170
- package/web/dist/assets/index-DWF4-3Fh.css +0 -2
- package/web/dist/assets/select-6i3wxovH.js +0 -1
- package/web/dist/assets/settings-mcp-CSLXJftV.js +0 -1
- package/web/dist/assets/settings-secrets-DpEwZLL4.js +0 -1
- package/web/dist/assets/settings-workflows-Dt-GaRtX.js +0 -23
- package/web/dist/assets/switch-ftZleVB8.js +0 -6
- package/web/dist/assets/workflows-DDRfFnAE.js +0 -7
- package/web/dist/assets/workflows-pane-g5njqean.js +0 -1
|
@@ -2,6 +2,7 @@ import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { applyPatch, formatDuration, loadConfig, } from "./config.js";
|
|
4
4
|
import { DEFAULT_WORKFLOW_RUNTIME } from "../protocol/settings.js";
|
|
5
|
+
import { detectFilesystemIsolationSupport, } from "../isolation/support.js";
|
|
5
6
|
import { expandHome } from "./projects.js";
|
|
6
7
|
import { defaultStateRoot } from "./store.js";
|
|
7
8
|
/**
|
|
@@ -20,15 +21,43 @@ export class ConfigStore {
|
|
|
20
21
|
path;
|
|
21
22
|
root;
|
|
22
23
|
config;
|
|
24
|
+
isolationSupport;
|
|
25
|
+
isolationInitialization;
|
|
26
|
+
isolationDetector;
|
|
23
27
|
/** Why part of the file on disk was ignored, for the daemon to print on the way up. */
|
|
24
28
|
warning;
|
|
25
|
-
constructor(root = defaultStateRoot()) {
|
|
29
|
+
constructor(root = defaultStateRoot(), detector = detectFilesystemIsolationSupport) {
|
|
30
|
+
this.isolationDetector = detector;
|
|
26
31
|
this.root = root;
|
|
27
32
|
this.path = join(root, "config.json");
|
|
28
33
|
const loaded = loadConfig(root);
|
|
29
34
|
this.config = loaded.config;
|
|
30
35
|
this.warning = loaded.warning;
|
|
31
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Probe once, including concurrent callers, and latch the automatic startup decision.
|
|
39
|
+
* A later failed restricted launch must never turn this policy off.
|
|
40
|
+
*/
|
|
41
|
+
async initializeFilesystemIsolation() {
|
|
42
|
+
this.isolationInitialization ??= Promise.resolve().then(async () => {
|
|
43
|
+
try {
|
|
44
|
+
this.isolationSupport = { ...await this.isolationDetector({ stateRoot: this.root }) };
|
|
45
|
+
}
|
|
46
|
+
catch (error) {
|
|
47
|
+
this.isolationSupport = { supported: false, reason: error instanceof Error ? error.message : String(error) };
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
await this.isolationInitialization;
|
|
51
|
+
}
|
|
52
|
+
/** Pending automatic selection is fail-closed; explicit true stays enabled even if unsupported. */
|
|
53
|
+
filesystemIsolationEnabled = () => this.config.filesystemIsolation ?? this.isolationSupport?.supported ?? true;
|
|
54
|
+
filesystemIsolationStatus = () => ({
|
|
55
|
+
supported: this.isolationSupport?.supported ?? false,
|
|
56
|
+
enabled: this.filesystemIsolationEnabled(),
|
|
57
|
+
automatic: this.config.filesystemIsolation === undefined,
|
|
58
|
+
checking: this.isolationSupport === undefined,
|
|
59
|
+
...(this.isolationSupport?.reason === undefined ? {} : { reason: this.isolationSupport.reason }),
|
|
60
|
+
});
|
|
32
61
|
/** The current Config, in the file's own units. Cheap: held in memory, not re-read. */
|
|
33
62
|
current() {
|
|
34
63
|
return this.config;
|
|
@@ -97,6 +126,7 @@ export class ConfigStore {
|
|
|
97
126
|
return { backend, ...summary };
|
|
98
127
|
return providers?.summary?.backend === backend ? providers.summary : undefined;
|
|
99
128
|
};
|
|
129
|
+
defaultPermissionMode = (backend) => this.config.providers?.permissionModes?.[backend];
|
|
100
130
|
defaultEffort = (backend) => this.config.providers?.efforts?.[backend];
|
|
101
131
|
/**
|
|
102
132
|
* Grant a Standing Authorisation for one tool — what an Always decision leaves behind.
|
|
@@ -132,6 +162,10 @@ export class ConfigStore {
|
|
|
132
162
|
// cleared. Both optional sections can be cleared, so both are deleted when absent — and for
|
|
133
163
|
// `permissions` that is not tidiness: a section left behind would keep a Standing Authorisation
|
|
134
164
|
// the human had just revoked.
|
|
165
|
+
// Keep automatic selection absent, including after reset or a leniently ignored disk value.
|
|
166
|
+
// Persisting the resolved default here would pin the next host to today's probe result.
|
|
167
|
+
if (next.filesystemIsolation === undefined)
|
|
168
|
+
delete document["filesystemIsolation"];
|
|
135
169
|
if (next.projects === undefined)
|
|
136
170
|
delete document["projects"];
|
|
137
171
|
if (next.permissions === undefined)
|
|
@@ -175,6 +209,7 @@ function settingsOf(config) {
|
|
|
175
209
|
fonts: config.fonts,
|
|
176
210
|
mcp: config.mcp ?? [],
|
|
177
211
|
workflowRuntime: { ...DEFAULT_WORKFLOW_RUNTIME, ...config.workflowRuntime },
|
|
212
|
+
...(config.filesystemIsolation === undefined ? {} : { filesystemIsolation: config.filesystemIsolation }),
|
|
178
213
|
// Omitted rather than defaulted when there is no Project Root, which is what
|
|
179
214
|
// `Settings["projects"]` being optional means — see src/protocol/settings.ts.
|
|
180
215
|
...(config.projects === undefined ? {} : { projects: config.projects }),
|
package/dist/daemon/config.js
CHANGED
|
@@ -31,10 +31,12 @@ export function loadConfig(stateRoot) {
|
|
|
31
31
|
const projects = parseProjects(parsed, warnings);
|
|
32
32
|
const permissions = parsePermissions(parsed, warnings);
|
|
33
33
|
const providers = parseProviders(parsed, warnings);
|
|
34
|
+
const filesystemIsolation = readFilesystemIsolation(parsed, warnings);
|
|
34
35
|
return {
|
|
35
36
|
config: {
|
|
36
37
|
retention,
|
|
37
38
|
fonts,
|
|
39
|
+
...(filesystemIsolation === undefined ? {} : { filesystemIsolation }),
|
|
38
40
|
mcp: readMcp(parsed, warnings),
|
|
39
41
|
workflowRuntime: readWorkflowRuntime(parsed, warnings),
|
|
40
42
|
...(projects === undefined ? {} : { projects }),
|
|
@@ -59,24 +61,19 @@ function patchWorkflowRuntime(current, patch) {
|
|
|
59
61
|
if (!patch || typeof patch !== 'object' || Array.isArray(patch))
|
|
60
62
|
throw new ConfigError('workflowRuntime must be an object');
|
|
61
63
|
for (const [key, value] of Object.entries(patch)) {
|
|
62
|
-
if (key === '
|
|
63
|
-
if (typeof value !== 'boolean')
|
|
64
|
-
throw new ConfigError('workflowRuntime.externalSandbox must be boolean');
|
|
65
|
-
next.externalSandbox = value;
|
|
66
|
-
}
|
|
67
|
-
else if (key === 'dockerImage' || key === 'nodePath' || key === 'dockerPath') {
|
|
64
|
+
if (key === 'nodePath') {
|
|
68
65
|
if (typeof value !== 'string' || value.length > 4096 || /[\x00-\x1f]/.test(value))
|
|
69
|
-
throw new ConfigError('
|
|
70
|
-
if (
|
|
71
|
-
delete next
|
|
66
|
+
throw new ConfigError('workflowRuntime.nodePath must be an absolute executable path');
|
|
67
|
+
if (value === '') {
|
|
68
|
+
delete next.nodePath;
|
|
72
69
|
continue;
|
|
73
70
|
}
|
|
74
|
-
if (
|
|
75
|
-
throw new ConfigError('
|
|
76
|
-
next
|
|
71
|
+
if (!value.startsWith('/'))
|
|
72
|
+
throw new ConfigError('workflowRuntime.nodePath must be absolute');
|
|
73
|
+
next.nodePath = value;
|
|
77
74
|
}
|
|
78
75
|
else
|
|
79
|
-
throw new ConfigError(
|
|
76
|
+
throw new ConfigError(`Unknown workflowRuntime field: ${key}`);
|
|
80
77
|
}
|
|
81
78
|
return next;
|
|
82
79
|
}
|
|
@@ -90,17 +87,39 @@ function readWorkflowRuntime(parsed, warnings) {
|
|
|
90
87
|
return result;
|
|
91
88
|
}
|
|
92
89
|
for (const [key, value] of Object.entries(section)) {
|
|
93
|
-
if (
|
|
90
|
+
if (['externalSandbox', 'dockerImage', 'dockerPath'].includes(key)) {
|
|
91
|
+
warnings.push(`Retired workflowRuntime.${key} ignored: Docker Workflow execution was removed; local execution follows the machine-wide filesystem isolation setting`);
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
if (key !== 'nodePath')
|
|
94
95
|
continue;
|
|
95
96
|
try {
|
|
96
97
|
result = patchWorkflowRuntime(result, { [key]: value });
|
|
97
98
|
}
|
|
98
99
|
catch {
|
|
99
|
-
warnings.push('Invalid workflowRuntime
|
|
100
|
+
warnings.push('Invalid workflowRuntime.nodePath; using automatic discovery');
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
return result;
|
|
103
104
|
}
|
|
105
|
+
function readFilesystemIsolation(parsed, warnings) {
|
|
106
|
+
const value = parsed?.filesystemIsolation;
|
|
107
|
+
if (value === undefined)
|
|
108
|
+
return undefined;
|
|
109
|
+
if (typeof value === "boolean")
|
|
110
|
+
return value;
|
|
111
|
+
warnings.push("filesystemIsolation must be true or false; using automatic selection");
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
function patchFilesystemIsolation(current, value) {
|
|
115
|
+
if (value === undefined)
|
|
116
|
+
return current;
|
|
117
|
+
if (value === null)
|
|
118
|
+
return undefined;
|
|
119
|
+
if (typeof value !== "boolean")
|
|
120
|
+
throw new ConfigError("filesystemIsolation must be true, false, or null");
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
104
123
|
function parseProviders(parsed, warnings) {
|
|
105
124
|
const section = parsed?.providers;
|
|
106
125
|
if (section === undefined || section === null)
|
|
@@ -156,7 +175,7 @@ function parseProviders(parsed, warnings) {
|
|
|
156
175
|
};
|
|
157
176
|
}
|
|
158
177
|
}
|
|
159
|
-
for (const field of ["efforts", "summaries", "autoCompaction", "compactionModels"]) {
|
|
178
|
+
for (const field of ["efforts", "summaries", "autoCompaction", "compactionModels", "permissionModes"]) {
|
|
160
179
|
const entries = section[field];
|
|
161
180
|
if (entries === undefined)
|
|
162
181
|
continue;
|
|
@@ -384,11 +403,13 @@ export function applyPatch(current, patch) {
|
|
|
384
403
|
throw new ConfigError("expected an object");
|
|
385
404
|
}
|
|
386
405
|
const body = patch;
|
|
387
|
-
refuseUnknownKeys(body, ["retention", "fonts", "projects", "permissions", "providers", "workflowRuntime", "mcp"], "config");
|
|
406
|
+
refuseUnknownKeys(body, ["retention", "fonts", "projects", "permissions", "providers", "workflowRuntime", "mcp", "filesystemIsolation"], "config");
|
|
388
407
|
const projects = patchProjects(current.projects, body.projects);
|
|
389
408
|
const permissions = patchPermissions(current.permissions, body.permissions);
|
|
390
409
|
const providers = patchProviders(current.providers, body.providers);
|
|
410
|
+
const filesystemIsolation = patchFilesystemIsolation(current.filesystemIsolation, body.filesystemIsolation);
|
|
391
411
|
return {
|
|
412
|
+
...(filesystemIsolation === undefined ? {} : { filesystemIsolation }),
|
|
392
413
|
mcp: body.mcp === undefined ? current.mcp ?? [] : parseMcp(body.mcp),
|
|
393
414
|
workflowRuntime: patchWorkflowRuntime(current.workflowRuntime, body.workflowRuntime),
|
|
394
415
|
retention: { settled: patchRetention(current.retention.settled, body.retention) },
|
|
@@ -413,12 +434,13 @@ export function applyPatch(current, patch) {
|
|
|
413
434
|
function patchProviders(current, patch) {
|
|
414
435
|
if (patch === undefined)
|
|
415
436
|
return current;
|
|
416
|
-
refuseUnknownKeys(patch, ["defaultBackend", "defaults", "summary", "efforts", "summaries", "autoCompaction", "compactionModels"], "providers");
|
|
437
|
+
refuseUnknownKeys(patch, ["defaultBackend", "defaults", "summary", "efforts", "summaries", "autoCompaction", "compactionModels", "permissionModes"], "providers");
|
|
417
438
|
const next = {
|
|
418
439
|
...(current?.autoCompaction === undefined ? {} : { autoCompaction: { ...current.autoCompaction } }),
|
|
419
440
|
...(current?.compactionModels === undefined ? {} : { compactionModels: { ...current.compactionModels } }),
|
|
420
441
|
...(current?.defaultBackend === undefined ? {} : { defaultBackend: current.defaultBackend }),
|
|
421
442
|
...(current?.efforts === undefined ? {} : { efforts: { ...current.efforts } }),
|
|
443
|
+
...(current?.permissionModes === undefined ? {} : { permissionModes: { ...current.permissionModes } }),
|
|
422
444
|
...(current?.summaries === undefined ? {} : { summaries: { ...current.summaries } }),
|
|
423
445
|
...(current?.defaults === undefined ? {} : { defaults: { ...current.defaults } }),
|
|
424
446
|
...(current?.summary === undefined ? {} : { summary: current.summary }),
|
|
@@ -534,6 +556,20 @@ function patchProviders(current, patch) {
|
|
|
534
556
|
};
|
|
535
557
|
}
|
|
536
558
|
}
|
|
559
|
+
if (patch.permissionModes !== undefined) {
|
|
560
|
+
if (typeof patch.permissionModes !== "object" || patch.permissionModes === null || Array.isArray(patch.permissionModes))
|
|
561
|
+
throw new ConfigError("providers.permissionModes must be an object");
|
|
562
|
+
const modes = { ...next.permissionModes };
|
|
563
|
+
for (const [backend, mode] of Object.entries(patch.permissionModes)) {
|
|
564
|
+
if (mode === "")
|
|
565
|
+
delete modes[backend];
|
|
566
|
+
else if ((backend === "claude" && ["ask", "auto", "always"].includes(mode)) || (backend === "pi" && ["ask", "always"].includes(mode)))
|
|
567
|
+
modes[backend] = mode;
|
|
568
|
+
else
|
|
569
|
+
throw new ConfigError(`Unsupported permission mode for ${backend}`);
|
|
570
|
+
}
|
|
571
|
+
next.permissionModes = modes;
|
|
572
|
+
}
|
|
537
573
|
for (const field of ["efforts", "summaries"]) {
|
|
538
574
|
const entries = patch[field];
|
|
539
575
|
if (entries === undefined)
|