@nathanstephenson/flow 0.1.10-beta.3 → 0.1.10-beta.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 +11 -3
- package/build/backend-worker-chunks/{chunk-LO7O6NAM.mjs → chunk-JOI2POLP.mjs} +1 -1
- package/build/backend-worker-chunks/{chunk-UQDH2COY.mjs → chunk-K774KOGL.mjs} +2 -7
- package/build/backend-worker-chunks/chunk-LAEUXDNH.mjs +130 -0
- package/build/backend-worker-chunks/{chunk-MLOUI3ZM.mjs → chunk-NZZME2I3.mjs} +6 -1
- package/build/backend-worker-chunks/claude-GY27HBAY.mjs +35739 -0
- package/build/backend-worker-chunks/{pi-QNU2YE4G.mjs → pi-JV6MWPW7.mjs} +1891 -35
- package/build/backend-worker.mjs +25 -126
- package/build/workflow-runtime.cjs +12 -12
- package/dist/backend/claude/index.js +69 -11
- package/dist/backend/claude/subagents.js +11 -0
- package/dist/backend/claude/workflow-parent.js +1 -1
- package/dist/backend/fake/index.js +8 -2
- package/dist/backend/pi/cache-warming.js +8 -0
- package/dist/backend/pi/canonical-json.js +120 -0
- package/dist/backend/pi/compaction-model.js +3 -2
- package/dist/backend/pi/host-auth.js +258 -0
- package/dist/backend/pi/index.js +37 -12
- package/dist/backend/pi/model-auth.js +159 -0
- package/dist/backend/pi/model-catalog.js +120 -0
- package/dist/backend/pi/model-config.js +5 -0
- package/dist/backend/pi/model-selection.js +32 -0
- package/dist/backend/pi/work.js +9 -1
- package/dist/backend/pi/workflow-parent.js +1 -1
- package/dist/backend/pi/workflow-subagent.js +4 -3
- package/dist/backend/worker/entry.js +13 -1
- package/dist/backend/worker/index.js +69 -7
- package/dist/backend/worker/launcher.js +11 -4
- package/dist/build-id +1 -1
- package/dist/cli/application.js +5 -5
- package/dist/cli/bootstrap.js +1 -1
- package/dist/cli/host-control.js +1 -1
- package/dist/cli/install-guard.js +1 -1
- package/dist/cli/main.js +4 -4
- package/dist/cli/systemd-update.js +3 -3
- package/dist/cli/update.js +6 -6
- package/dist/cli/web-update.js +6 -6
- package/dist/client/reduce.js +2 -0
- package/dist/client/tool-summary.js +26 -15
- package/dist/daemon/changes.js +116 -0
- package/dist/daemon/commit.js +84 -0
- package/dist/daemon/config-store.js +3 -3
- package/dist/daemon/git-state.js +197 -0
- package/dist/daemon/github.js +54 -0
- package/dist/daemon/host-control-routes.js +1 -1
- package/dist/daemon/host.js +147 -78
- package/dist/daemon/log.js +3 -0
- package/dist/daemon/mcp-auth.js +1 -1
- package/dist/daemon/models.js +2 -2
- package/dist/daemon/pi-model-cache.js +44 -0
- package/dist/daemon/pull-request.js +156 -129
- package/dist/daemon/push.js +43 -0
- package/dist/daemon/repository.js +106 -0
- package/dist/daemon/runtime.js +27 -20
- package/dist/daemon/secret-store.js +1 -1
- package/dist/daemon/server.js +11 -10
- package/dist/daemon/stack-metadata.js +12 -5
- package/dist/daemon/stack.js +127 -656
- package/dist/daemon/summariser.js +19 -8
- package/dist/daemon/workflow-authoring-scope-checks.js +1 -1
- package/dist/daemon/workflow-authoring-scope.js +1 -1
- package/dist/daemon/workflow-builder-files.js +2 -2
- package/dist/daemon/workflow-builder-routes.js +2 -2
- package/dist/daemon/workflow-builder.js +5 -5
- package/dist/daemon/workflow-environment.js +5 -5
- package/dist/daemon/workflow-execution-launch.js +5 -5
- package/dist/daemon/workflow-execution-resources.js +3 -3
- package/dist/daemon/workflow-execution-routes.js +3 -3
- package/dist/daemon/workflow-execution-values.js +5 -5
- package/dist/daemon/workflow-executions.js +19 -19
- package/dist/daemon/workflow-mcp-authoring-routes.js +2 -2
- package/dist/daemon/workflow-mcp-authoring.js +4 -4
- package/dist/daemon/workflow-mcp.js +1 -1
- package/dist/daemon/workflow-routes.js +3 -3
- package/dist/daemon/workflow-schedule-driver.js +8 -8
- package/dist/daemon/workflow-schedule-routes.js +5 -5
- package/dist/daemon/workflow-schedules.js +3 -3
- package/dist/isolation/filesystem.js +5 -1
- package/dist/isolation/sandbox.js +31 -4
- package/dist/isolation/toolchain-assets.js +1 -1
- package/dist/protocol/stack.js +1 -41
- package/dist/workflows/calls.js +2 -2
- package/dist/workflows/executors.js +3 -3
- package/dist/workflows/graph.js +6 -6
- package/dist/workflows/invocations.js +1 -1
- package/dist/workflows/mcp.js +1 -1
- package/dist/workflows/records.js +6 -6
- package/dist/workflows/recovery.js +2 -2
- package/dist/workflows/runtime-settings.js +1 -1
- package/dist/workflows/runtime.js +2 -2
- package/dist/workflows/schedule-store.js +2 -2
- package/dist/workflows/scheduler.js +9 -9
- package/dist/workflows/schema.js +1 -1
- package/dist/workflows/store.js +3 -3
- package/package.json +9 -6
- package/web/dist/assets/index-BqZ_iUmY.css +2 -0
- package/web/dist/assets/index-CxdSb7k0.js +51 -0
- package/web/dist/assets/{settings-mcp-Vf_fCXyE.js → settings-mcp-BwOPXAfH.js} +1 -1
- package/web/dist/assets/settings-workflows-DocTa31_.js +23 -0
- package/web/dist/assets/{switch-DIogWclb.js → switch-B00FEUA7.js} +1 -1
- package/web/dist/assets/{workflows-Dobqzjg-.js → workflows-DJqUuGyg.js} +41 -41
- package/web/dist/assets/{workflows-pane-KB-Q76KZ.js → workflows-pane-oM1fO_BC.js} +1 -1
- package/web/dist/index.html +4 -4
- package/build/backend-worker-chunks/claude-6L5KCQWJ.mjs +0 -30894
- package/dist/daemon/publish.js +0 -289
- package/dist/protocol/publish.js +0 -1
- package/web/dist/assets/index-BGu3YSP7.css +0 -2
- package/web/dist/assets/index-Miy2nveb.js +0 -40
- package/web/dist/assets/settings-workflows-DVKxJWQm.js +0 -23
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
export function registerPiNativeProvider(runtime, provider) {
|
|
2
|
+
const refresh = runtime.refresh;
|
|
3
|
+
runtime.refresh = async () => ({ aborted: false, errors: new Map() });
|
|
4
|
+
try {
|
|
5
|
+
runtime.registerNativeProvider(provider);
|
|
6
|
+
}
|
|
7
|
+
finally {
|
|
8
|
+
runtime.refresh = refresh;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function unregisterPiNativeProvider(runtime, providerId) {
|
|
12
|
+
const refresh = runtime.refresh;
|
|
13
|
+
runtime.refresh = async () => ({ aborted: false, errors: new Map() });
|
|
14
|
+
try {
|
|
15
|
+
runtime.unregisterProvider(providerId);
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
runtime.refresh = refresh;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function object(value) {
|
|
22
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
23
|
+
}
|
|
24
|
+
function finite(value) {
|
|
25
|
+
return typeof value === 'number' && Number.isFinite(value) && value >= 0;
|
|
26
|
+
}
|
|
27
|
+
function rates(value) {
|
|
28
|
+
if (!object(value) || !finite(value.input) || !finite(value.output) || !finite(value.cacheRead) || !finite(value.cacheWrite))
|
|
29
|
+
return undefined;
|
|
30
|
+
return { input: value.input, output: value.output, cacheRead: value.cacheRead, cacheWrite: value.cacheWrite };
|
|
31
|
+
}
|
|
32
|
+
export function projectPi099RadiusCatalog(providerId, value) {
|
|
33
|
+
if (!object(value) || typeof value.baseUrl !== 'string' || !Array.isArray(value.models))
|
|
34
|
+
return undefined;
|
|
35
|
+
try {
|
|
36
|
+
const url = new URL(value.baseUrl);
|
|
37
|
+
if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password || url.search || url.hash)
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const baseUrl = value.baseUrl;
|
|
44
|
+
return value.models.flatMap(model => {
|
|
45
|
+
if (!object(model) || typeof model.id !== 'string' || typeof model.name !== 'string' || typeof model.reasoning !== 'boolean'
|
|
46
|
+
|| !Array.isArray(model.input) || !model.input.every(input => input === 'text' || input === 'image')
|
|
47
|
+
|| !finite(model.contextWindow) || !finite(model.maxTokens))
|
|
48
|
+
return [];
|
|
49
|
+
const cost = rates(model.cost);
|
|
50
|
+
if (!cost)
|
|
51
|
+
return [];
|
|
52
|
+
if (object(model.cost) && Array.isArray(model.cost.tiers)) {
|
|
53
|
+
cost.tiers = model.cost.tiers.flatMap(tier => {
|
|
54
|
+
const tierRates = rates(tier);
|
|
55
|
+
return object(tier) && finite(tier.inputTokensAbove) && tierRates ? [{ ...tierRates, inputTokensAbove: tier.inputTokensAbove }] : [];
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const projected = { id: model.id, name: model.name, api: 'pi-messages', provider: providerId, baseUrl,
|
|
59
|
+
reasoning: model.reasoning, input: [...model.input], cost, contextWindow: model.contextWindow, maxTokens: model.maxTokens };
|
|
60
|
+
if (object(model.thinkingLevelMap)) {
|
|
61
|
+
projected.thinkingLevelMap = {};
|
|
62
|
+
for (const level of ['off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']) {
|
|
63
|
+
const value = model.thinkingLevelMap[level];
|
|
64
|
+
if (value === null || typeof value === 'string')
|
|
65
|
+
projected.thinkingLevelMap[level] = value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (object(model.promptCache)) {
|
|
69
|
+
projected.promptCache = {};
|
|
70
|
+
for (const tier of ['short', 'long'])
|
|
71
|
+
if (finite(model.promptCache[tier]))
|
|
72
|
+
projected.promptCache[tier] = model.promptCache[tier];
|
|
73
|
+
}
|
|
74
|
+
if (object(model.inputLimits)) {
|
|
75
|
+
const limits = model.inputLimits;
|
|
76
|
+
projected.inputLimits = {};
|
|
77
|
+
if (finite(limits.maxRequestBytes))
|
|
78
|
+
projected.inputLimits.maxRequestBytes = limits.maxRequestBytes;
|
|
79
|
+
if (object(limits.images)) {
|
|
80
|
+
projected.inputLimits.images = {};
|
|
81
|
+
for (const key of ['maxPerMessage', 'maxPerRequest']) {
|
|
82
|
+
if (finite(limits.images[key]))
|
|
83
|
+
projected.inputLimits.images[key] = limits.images[key];
|
|
84
|
+
}
|
|
85
|
+
if (object(limits.images.resize)) {
|
|
86
|
+
projected.inputLimits.images.resize = {};
|
|
87
|
+
for (const key of ['maxWidth', 'maxHeight', 'maxBytes', 'jpegQuality']) {
|
|
88
|
+
if (finite(limits.images.resize[key]))
|
|
89
|
+
projected.inputLimits.images.resize[key] = limits.images.resize[key];
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return [projected];
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
export function projectPiStoredRadiusCatalog(providerId, value) {
|
|
98
|
+
if (!object(value) || !Array.isArray(value.models))
|
|
99
|
+
return undefined;
|
|
100
|
+
return value.models.flatMap(model => {
|
|
101
|
+
if (!object(model) || model.provider !== providerId || model.api !== 'pi-messages')
|
|
102
|
+
return [];
|
|
103
|
+
return projectPi099RadiusCatalog(providerId, { baseUrl: model.baseUrl, models: [model] }) ?? [];
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
export function withPi099RadiusCatalog(provider, cached) {
|
|
107
|
+
return {
|
|
108
|
+
...provider,
|
|
109
|
+
async refreshModels(context) {
|
|
110
|
+
const legacy = context.stored ? undefined : cached();
|
|
111
|
+
if (legacy) {
|
|
112
|
+
const stored = { models: [...legacy], checkedAt: Date.now() };
|
|
113
|
+
if (!await context.publish({ persist: stored }))
|
|
114
|
+
return;
|
|
115
|
+
context = { ...context, stored };
|
|
116
|
+
}
|
|
117
|
+
await provider.refreshModels?.(context);
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export function parsePiModelConfig(content) {
|
|
2
|
+
return JSON.parse(content.replace(/^\uFEFF/, "")
|
|
3
|
+
.replace(/"(?:\\.|[^"\\])*"|\/\/[^\n]*/g, (match) => match.startsWith('"') ? match : "")
|
|
4
|
+
.replace(/"(?:\\.|[^"\\])*"|,(\s*[}\]])/g, (match, closing) => closing ?? match));
|
|
5
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
4
|
+
import { parsePiModelConfig } from "./model-config.js";
|
|
5
|
+
const legacyAzure = "azure-openai-responses";
|
|
6
|
+
export function findPiModel(available, modelId, allowBareId = false, agentDir = getAgentDir()) {
|
|
7
|
+
const canonicalId = modelId.startsWith(`${legacyAzure}/`) ? `azure/${modelId.slice(legacyAzure.length + 1)}` : modelId;
|
|
8
|
+
if (canonicalId.startsWith("azure/")) {
|
|
9
|
+
for (const name of ["auth.json", "models.json"]) {
|
|
10
|
+
const path = join(agentDir, name);
|
|
11
|
+
if (!existsSync(path))
|
|
12
|
+
continue;
|
|
13
|
+
const content = readFileSync(path, "utf8");
|
|
14
|
+
const data = name === "models.json" ? parsePiModelConfig(content) : JSON.parse(content.replace(/^\uFEFF/, ""));
|
|
15
|
+
const providers = name === "models.json" ? data.providers : data;
|
|
16
|
+
if (providers && Object.hasOwn(providers, legacyAzure) && !Object.hasOwn(providers, "azure")) {
|
|
17
|
+
throw new Error(`Pi 1.6 renamed Provider ${legacyAzure} to azure. Rename its Provider key in ${path} to azure; keep the API name azure-openai-responses unchanged. Flow did not change this file or select another model.`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const qualified = available.find((model) => (model.provider ? `${model.provider}/${model.id}` : model.id) === canonicalId);
|
|
22
|
+
if (qualified || !allowBareId || canonicalId.startsWith("azure/"))
|
|
23
|
+
return qualified;
|
|
24
|
+
const bare = available.filter((model) => model.id === modelId);
|
|
25
|
+
return bare.length === 1 ? bare[0] : undefined;
|
|
26
|
+
}
|
|
27
|
+
export function piModelUnavailable(modelId, label = "Unknown model") {
|
|
28
|
+
const azure = modelId.startsWith(`${legacyAzure}/`) || modelId.startsWith("azure/");
|
|
29
|
+
return `${label}: ${modelId}. Select an available model explicitly; no replacement was used.${azure
|
|
30
|
+
? " Pi 1.6 uses Provider azure. Check the azure Provider keys in Pi auth.json and models.json, and confirm the exact model ID is still available. The API name remains azure-openai-responses."
|
|
31
|
+
: ""}`;
|
|
32
|
+
}
|
package/dist/backend/pi/work.js
CHANGED
|
@@ -38,7 +38,7 @@ export class PiWork {
|
|
|
38
38
|
work.result = completion.result;
|
|
39
39
|
if (brief.type === "subagent")
|
|
40
40
|
this.jobs.delete(id);
|
|
41
|
-
this.emit({ ...brief, state: completion.state });
|
|
41
|
+
this.emit({ ...work.brief, state: completion.state });
|
|
42
42
|
if (background && !this.disposed)
|
|
43
43
|
this.completed(completion);
|
|
44
44
|
return completion;
|
|
@@ -53,6 +53,14 @@ export class PiWork {
|
|
|
53
53
|
throw new Error(resultText(completion.result));
|
|
54
54
|
return completion.result;
|
|
55
55
|
}
|
|
56
|
+
/** Record the model and Effort a running Subagent resolved to. */
|
|
57
|
+
refine(id, patch) {
|
|
58
|
+
const work = this.jobs.get(id);
|
|
59
|
+
if (!work || work.brief.type !== "subagent")
|
|
60
|
+
return;
|
|
61
|
+
work.brief = { ...work.brief, ...patch };
|
|
62
|
+
this.emit({ ...work.brief, state: "running" });
|
|
63
|
+
}
|
|
56
64
|
waiting(id, waiting) {
|
|
57
65
|
const work = this.jobs.get(id);
|
|
58
66
|
if (!work || work.brief.type !== "subagent" || !["running", "waiting"].includes(work.state))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from 'typebox';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { workflowInspectInput, workflowRecoverInput, workflowRelayInput, inspectDescription, recoverDescription, relayEnquiryDescription, relayPermissionDescription } from
|
|
3
|
+
import { workflowInspectInput, workflowRecoverInput, workflowRelayInput, inspectDescription, recoverDescription, relayEnquiryDescription, relayPermissionDescription } from '../workflow-tools.js';
|
|
4
4
|
export function workflowParentTools(parent) {
|
|
5
5
|
if (!parent)
|
|
6
6
|
return [];
|
|
@@ -2,6 +2,7 @@ import { piMcpTools } from "./mcp.js";
|
|
|
2
2
|
import { createAgentSession, DefaultPackageManager, DefaultResourceLoader, getAgentDir, SessionManager, SettingsManager, createReadToolDefinition, createEditToolDefinition, createWriteToolDefinition, createGrepToolDefinition, createFindToolDefinition, createLsToolDefinition, createPowerShellToolDefinition, } from "@earendil-works/pi-coding-agent";
|
|
3
3
|
import { PiSession } from "./index.js";
|
|
4
4
|
import { piAcceptsWorkflowEffort, piEffortLevels } from "./effort-capabilities.js";
|
|
5
|
+
import { findPiModel, piModelUnavailable } from "./model-selection.js";
|
|
5
6
|
import { piAutoCompaction } from "./auto-compaction.js";
|
|
6
7
|
import { compactionExtensionError, compactionModelExtension } from "./compaction-model.js";
|
|
7
8
|
import { PiEnquiries } from "./enquiries.js";
|
|
@@ -83,13 +84,13 @@ export class PiWorkflowSubagent {
|
|
|
83
84
|
let compacting = false;
|
|
84
85
|
try {
|
|
85
86
|
controller.signal.throwIfAborted();
|
|
86
|
-
const model = parent.modelRuntime.getAvailableSnapshot()
|
|
87
|
+
const model = findPiModel(parent.modelRuntime.getAvailableSnapshot(), options.modelId);
|
|
87
88
|
if (!model)
|
|
88
|
-
throw new Error(
|
|
89
|
+
throw new Error(piModelUnavailable(options.modelId, "Unknown workflow model"));
|
|
89
90
|
if (!["ask", "auto-accept"].includes(options.permissionMode))
|
|
90
91
|
throw new Error("Unsupported workflow permission mode");
|
|
91
92
|
const scope = parent.sessionManager.getCwd();
|
|
92
|
-
const settingsManager = SettingsManager.inMemory({ retry: { enabled: false } });
|
|
93
|
+
const settingsManager = SettingsManager.inMemory({ retry: { enabled: false }, cacheWarming: "streaming" });
|
|
93
94
|
const skillContext = options.skill
|
|
94
95
|
? `The leading Skill invocation is expanded as the user prompt. Follow it together with the mapped workflow input below.\n\nMapped workflow input (JSON):\n${JSON.stringify(options.input)}\n\nWorkflow constraints:${options.instructions.slice(options.skill.invocation.length)}`
|
|
95
96
|
: options.instructions;
|
|
@@ -58,7 +58,7 @@ export function runWorker() {
|
|
|
58
58
|
if (creating || closing)
|
|
59
59
|
throw new Error("Backend worker already initialized");
|
|
60
60
|
creating = true;
|
|
61
|
-
const { mcpTools, mcpConnectionIds, mcpSandbox, workflowEnabled, sessionToolsEnabled, workflowBuilderInstructions, backendModule, backend: backendName = "pi", ...options } = args[0];
|
|
61
|
+
const { mcpTools, mcpConnectionIds, mcpSandbox, workflowEnabled, sessionToolsEnabled, workflowBuilderInstructions, piAuth, backendModule, backend: backendName = "pi", ...options } = args[0];
|
|
62
62
|
const workflowBuilder = workflowBuilderInstructions === undefined ? undefined : {
|
|
63
63
|
instructions: workflowBuilderInstructions,
|
|
64
64
|
read: (path) => rpc.call("workflowBuilder.read", [path]),
|
|
@@ -99,8 +99,20 @@ export function runWorker() {
|
|
|
99
99
|
throw new Error(`Backend "${backendName}" is not available in this build: ${errorText(error)}`);
|
|
100
100
|
}
|
|
101
101
|
const imported = performance.now();
|
|
102
|
+
let initialAuth = piAuth;
|
|
102
103
|
session = await backend.create({
|
|
103
104
|
...options,
|
|
105
|
+
...(piAuth ? { piAuth: {
|
|
106
|
+
snapshot: async (signal) => {
|
|
107
|
+
signal?.throwIfAborted();
|
|
108
|
+
if (!initialAuth)
|
|
109
|
+
return rpc.call('pi.auth.snapshot', [], signal);
|
|
110
|
+
const metadata = initialAuth;
|
|
111
|
+
initialAuth = undefined;
|
|
112
|
+
return metadata;
|
|
113
|
+
},
|
|
114
|
+
resolve: (providerId, signal) => rpc.call('pi.auth.resolve', [providerId], signal),
|
|
115
|
+
} } : {}),
|
|
104
116
|
...(workflowBuilder ? { workflowBuilder } : {
|
|
105
117
|
...(localMcp ? { mcp: localMcp }
|
|
106
118
|
: mcpTools ? { mcp: { connections: (mcpConnectionIds ?? []).map((id) => ({ id })), tools: () => tools } } : {}),
|
|
@@ -5,12 +5,12 @@ import { dirname, join, resolve, sep } from "node:path";
|
|
|
5
5
|
import { isSea } from "node:sea";
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { prepareFilesystemIsolation } from "../../isolation/filesystem.js";
|
|
8
|
-
import { createSandbox, sandboxMounts, sandboxUnavailable } from "../../isolation/sandbox.js";
|
|
8
|
+
import { createSandbox, hostClaude, sandboxMounts, sandboxUnavailable } from "../../isolation/sandbox.js";
|
|
9
9
|
import { validateFilesystemScope } from "../../isolation/filesystem.js";
|
|
10
10
|
import { workflowBuilderFolder } from "../../isolation/shared-sandbox.js";
|
|
11
11
|
import { nodeExecutionAssets } from "../../isolation/node-assets.js";
|
|
12
12
|
import { launchWorker, workerCommand } from "./launcher.js";
|
|
13
|
-
import { seaSdkExecutionAssets } from
|
|
13
|
+
import { seaSdkExecutionAssets } from './assets.js';
|
|
14
14
|
import { WorkerRpc } from "./rpc.js";
|
|
15
15
|
import { SandboxMcpSession } from "./sandbox-mcp.js";
|
|
16
16
|
import { mcpMetadata } from "./protocol.js";
|
|
@@ -18,12 +18,23 @@ import { workflowInspectInput, workflowRecoverInput, workflowRelayInput } from "
|
|
|
18
18
|
import { sessionListInput, sessionInspectInput, sessionCreateInput, sessionSendInput } from "../session-tools.js";
|
|
19
19
|
import { migrateLegacyClaudeState, prepareClaudeState, relocateClaudeState, forkClaudeState } from "./claude-state.js";
|
|
20
20
|
import { relocatePiState, forkPiState } from "../pi/state.js";
|
|
21
|
+
import { createPiModelAuth } from '../pi/model-auth.js';
|
|
21
22
|
import { recordTiming } from "../../daemon/timings.js";
|
|
22
23
|
/** One owned worker per Backend Session, optionally enforcing a filesystem boundary. */
|
|
23
24
|
export class WorkerBackend {
|
|
24
25
|
name;
|
|
25
26
|
options;
|
|
27
|
+
piAuth;
|
|
28
|
+
stopped = false;
|
|
26
29
|
constructor(options = {}) { this.options = options; this.name = options.backend ?? "pi"; }
|
|
30
|
+
async shutdown() {
|
|
31
|
+
this.stopped = true;
|
|
32
|
+
await this.piAuth?.close?.();
|
|
33
|
+
}
|
|
34
|
+
assertRunning() {
|
|
35
|
+
if (this.stopped)
|
|
36
|
+
throw new Error("Backend Adapter stopped");
|
|
37
|
+
}
|
|
27
38
|
scheduledSandboxMounts(scope) {
|
|
28
39
|
const packageRoot = fileURLToPath(new URL("../../..", import.meta.url));
|
|
29
40
|
const readable = [packageRoot, ...(this.options.readablePaths ?? [])];
|
|
@@ -77,6 +88,18 @@ export class WorkerBackend {
|
|
|
77
88
|
if (this.options.backendModule)
|
|
78
89
|
assets.push(fileURLToPath(this.options.backendModule));
|
|
79
90
|
assets.push(...nodeExecutionAssets(assets));
|
|
91
|
+
let claudePath = support.provider.claudePath;
|
|
92
|
+
if (support.provider.hostClaudePath && (shared || this.name === "claude")) {
|
|
93
|
+
let host;
|
|
94
|
+
try {
|
|
95
|
+
host = hostClaude(support.provider.hostClaudePath);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
throw new Error(`${sandboxUnavailable().message}: ${error.message}`);
|
|
99
|
+
}
|
|
100
|
+
claudePath = host.executable;
|
|
101
|
+
assets.push(host.directory);
|
|
102
|
+
}
|
|
80
103
|
const env = { FLOW_BACKEND_WORKER: "1",
|
|
81
104
|
...Object.fromEntries(Object.entries(this.options.env ?? {}).filter((entry) => entry[1] !== undefined)) };
|
|
82
105
|
const cleanups = [];
|
|
@@ -87,7 +110,10 @@ export class WorkerBackend {
|
|
|
87
110
|
env.CLAUDE_CONFIG_DIR = claude.env.CLAUDE_CONFIG_DIR;
|
|
88
111
|
if (claude.env.CLAUDE_SECURESTORAGE_CONFIG_DIR)
|
|
89
112
|
env.CLAUDE_SECURESTORAGE_CONFIG_DIR = claude.env.CLAUDE_SECURESTORAGE_CONFIG_DIR;
|
|
90
|
-
|
|
113
|
+
if (claudePath)
|
|
114
|
+
env.FLOW_CLAUDE_PATH = claudePath;
|
|
115
|
+
if (support.provider.hostClaudePath)
|
|
116
|
+
env.DISABLE_AUTOUPDATER = "1";
|
|
91
117
|
for (const entry of readdirSync(env.CLAUDE_CONFIG_DIR)) {
|
|
92
118
|
const link = join(env.CLAUDE_CONFIG_DIR, entry);
|
|
93
119
|
if (!options.workflowBuilder && lstatSync(link).isSymbolicLink() && !["projects", "file-history"].includes(entry))
|
|
@@ -100,7 +126,7 @@ export class WorkerBackend {
|
|
|
100
126
|
rmSync(agent, { recursive: true, force: true });
|
|
101
127
|
mkdirSync(agent, { recursive: true, mode: 0o700 });
|
|
102
128
|
cleanups.push(() => rmSync(agent, { recursive: true, force: true }));
|
|
103
|
-
for (const name of ["
|
|
129
|
+
for (const name of ["models.json", "settings.json"]) {
|
|
104
130
|
if (existsSync(join(source, name)))
|
|
105
131
|
copyFileSync(join(source, name), join(agent, name));
|
|
106
132
|
}
|
|
@@ -140,6 +166,7 @@ export class WorkerBackend {
|
|
|
140
166
|
({ startup } = sandbox);
|
|
141
167
|
cleanups.push(() => { removed = sandbox.close().catch((error) => console.error(`Sandbox ${sandbox.name} removal failed: ${error.message}`)); });
|
|
142
168
|
}
|
|
169
|
+
this.assertRunning();
|
|
143
170
|
const launch = sandbox.command(scope, [support.provider.nodePath, ...plan.args], env);
|
|
144
171
|
proxy = new WorkerSession({ ...options, scope, stateDir }, { ...this.options, sandboxed: sandbox, startupTimeoutMs: this.options.startupTimeoutMs ?? 300_000, command: launch.command, args: launch.args, env: {} }, cleanup);
|
|
145
172
|
await this.opened(proxy, options.signal, "sandbox", begin, { sharing: shared ? "shared" : "own", remove: Math.round(startup.remove), create: Math.round(startup.create) });
|
|
@@ -163,8 +190,14 @@ export class WorkerBackend {
|
|
|
163
190
|
return this.name === "claude" ? forkClaudeState(from, to) : forkPiState(from.stateDir, to.stateDir, to.scope);
|
|
164
191
|
}
|
|
165
192
|
async create(options) {
|
|
193
|
+
this.assertRunning();
|
|
166
194
|
const begin = performance.now();
|
|
167
195
|
options.signal?.throwIfAborted();
|
|
196
|
+
if (this.name === 'pi' && !this.options.backendModule && !options.piAuth) {
|
|
197
|
+
const directory = this.options.env?.PI_CODING_AGENT_DIR;
|
|
198
|
+
this.piAuth ??= createPiModelAuth(directory ? { authPath: join(directory, 'auth.json') } : {});
|
|
199
|
+
options = { ...options, piAuth: this.piAuth };
|
|
200
|
+
}
|
|
168
201
|
const isolationMode = options.isolationMode ?? this.options.isolationMode?.() ?? "bubblewrap";
|
|
169
202
|
if (isolationMode === "sandbox")
|
|
170
203
|
return this.createSandboxed(options);
|
|
@@ -210,6 +243,7 @@ export class WorkerBackend {
|
|
|
210
243
|
env: this.options.env ?? {}, credentials: this.name, workflowBuilder: !!options.workflowBuilder, worker: true, readablePaths: assets });
|
|
211
244
|
let proxy;
|
|
212
245
|
try {
|
|
246
|
+
this.assertRunning();
|
|
213
247
|
options.signal?.throwIfAborted();
|
|
214
248
|
if (this.name === "claude")
|
|
215
249
|
migrateLegacyClaudeState(options.stateDir, { ...process.env, ...this.options.env }, isolation.scope, options.resume);
|
|
@@ -233,6 +267,7 @@ class WorkerSession {
|
|
|
233
267
|
worker;
|
|
234
268
|
rpc;
|
|
235
269
|
failed;
|
|
270
|
+
piAuthProviders = new Set();
|
|
236
271
|
disposing = false;
|
|
237
272
|
disposal;
|
|
238
273
|
workflows = new Map();
|
|
@@ -260,11 +295,25 @@ class WorkerSession {
|
|
|
260
295
|
if (this.disposing || this.failed)
|
|
261
296
|
throw new Error("Backend Session stopped");
|
|
262
297
|
// Builders never inherit other host capabilities, even if the worker asks directly.
|
|
263
|
-
if (this.options.workflowBuilder && !["workflowBuilder.read", "workflowBuilder.list", "workflowBuilder.write"].includes(method)) {
|
|
298
|
+
if (this.options.workflowBuilder && !["pi.auth.snapshot", "pi.auth.resolve", "workflowBuilder.read", "workflowBuilder.list", "workflowBuilder.write"].includes(method)) {
|
|
264
299
|
throw new Error("Host capability is not enabled for workflow builder");
|
|
265
300
|
}
|
|
266
301
|
// Never look up host functions by a worker-supplied property name.
|
|
267
302
|
switch (method) {
|
|
303
|
+
case 'pi.auth.snapshot': return this.snapshotPiAuth(signal);
|
|
304
|
+
case 'pi.auth.resolve': {
|
|
305
|
+
const auth = this.requirePiAuth();
|
|
306
|
+
const provider = args[0];
|
|
307
|
+
if (typeof provider !== 'string' || !this.piAuthProviders.has(provider))
|
|
308
|
+
throw new Error('Unknown Pi provider');
|
|
309
|
+
try {
|
|
310
|
+
return await auth.resolve(provider, signal);
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
signal.throwIfAborted();
|
|
314
|
+
throw new Error(`Pi authentication failed for ${provider}. Check sign-in and auth.json access. Move any !command credentials to models.json.`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
268
317
|
case "mcp.token": {
|
|
269
318
|
if (!(this.options.mcp instanceof SandboxMcpSession) || typeof args[0] !== "string")
|
|
270
319
|
throw new Error("Host capability is not enabled");
|
|
@@ -298,9 +347,20 @@ class WorkerSession {
|
|
|
298
347
|
}, (name, value) => this.notify(name, value));
|
|
299
348
|
this.worker.onMessage((message) => this.rpc.receive(message), (error) => this.fail(error));
|
|
300
349
|
child.once("error", (error) => this.fail(error));
|
|
301
|
-
child.stdout?.once("close", () => this.
|
|
350
|
+
child.stdout?.once("close", () => void Promise.race([this.worker.exited, new Promise((resolve) => setTimeout(resolve, 1000).unref())])
|
|
351
|
+
.then(() => this.fail(new Error("Backend worker disconnected"))));
|
|
302
352
|
child.once("exit", (code, signal) => this.fail(new Error(`Backend worker exited (${signal ?? code ?? "unknown"})${this.worker.diagnostics() ? `: ${this.worker.diagnostics()}` : ""}`)));
|
|
303
353
|
}
|
|
354
|
+
requirePiAuth() {
|
|
355
|
+
if ((this.launchOptions.backend ?? 'pi') !== 'pi' || !this.options.piAuth)
|
|
356
|
+
throw new Error('Pi auth is not enabled');
|
|
357
|
+
return this.options.piAuth;
|
|
358
|
+
}
|
|
359
|
+
async snapshotPiAuth(signal) {
|
|
360
|
+
const metadata = await this.requirePiAuth().snapshot(signal);
|
|
361
|
+
this.piAuthProviders = new Set(metadata.map(({ providerId }) => providerId));
|
|
362
|
+
return metadata;
|
|
363
|
+
}
|
|
304
364
|
requireWorkflowBuilder(input) {
|
|
305
365
|
if (!this.options.workflowBuilder)
|
|
306
366
|
throw new Error("Workflow builder tools are not enabled");
|
|
@@ -319,7 +379,7 @@ class WorkerSession {
|
|
|
319
379
|
return this.options.sessionTools;
|
|
320
380
|
}
|
|
321
381
|
async open(signal) {
|
|
322
|
-
const { emit: _emit, onFailure: _onFailure, signal: _signal, evict: _evict, mcp, workflow, workflowBuilder, sessionTools, ...options } = this.options;
|
|
382
|
+
const { emit: _emit, onFailure: _onFailure, signal: _signal, evict: _evict, mcp, workflow, workflowBuilder, sessionTools, piAuth, ...options } = this.options;
|
|
323
383
|
const controller = new AbortController();
|
|
324
384
|
const cancel = () => controller.abort(signal?.reason);
|
|
325
385
|
if (signal?.aborted)
|
|
@@ -328,7 +388,9 @@ class WorkerSession {
|
|
|
328
388
|
signal?.addEventListener('abort', cancel, { once: true });
|
|
329
389
|
const timer = setTimeout(() => controller.abort(), this.launchOptions.startupTimeoutMs ?? 60_000);
|
|
330
390
|
try {
|
|
391
|
+
const auth = piAuth ? await this.snapshotPiAuth(controller.signal) : undefined;
|
|
331
392
|
const state = await this.rpc.call("create", [{ ...options, backend: this.launchOptions.backend ?? "pi",
|
|
393
|
+
...(auth ? { piAuth: auth } : {}),
|
|
332
394
|
workflowEnabled: !workflowBuilder && !!workflow,
|
|
333
395
|
sessionToolsEnabled: !workflowBuilder && options.tools !== "none" && !!sessionTools,
|
|
334
396
|
...(workflowBuilder ? { workflowBuilderInstructions: workflowBuilder.instructions }
|
|
@@ -2,6 +2,7 @@ import { spawn } from "node:child_process";
|
|
|
2
2
|
import { encodeFrame, frameDecoder } from "./frames.js";
|
|
3
3
|
import { isSea } from "node:sea";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
const sdkShadowWarning = /^\(node:\d+\) \[CLAUDE_SDK_CAN_USE_TOOL_SHADOWED\].*\n(?:\(Use `node --trace-warnings .*\n)?/gm;
|
|
5
6
|
export function workerCommand(options = {}) {
|
|
6
7
|
const source = import.meta.url.endsWith(".ts");
|
|
7
8
|
const entry = options.entry ?? fileURLToPath(new URL(source ? "./entry.ts" : "./entry.js", import.meta.url));
|
|
@@ -19,9 +20,15 @@ export function launchWorker(options = {}) {
|
|
|
19
20
|
stdio: ["pipe", "pipe", "pipe", ...(options.stdioFds ?? [])],
|
|
20
21
|
});
|
|
21
22
|
child.stdin?.on("error", () => { });
|
|
22
|
-
// Drain diagnostics so a chatty SDK cannot block on stderr. Keep only a bounded failure tail.
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
// Drain diagnostics so a chatty SDK cannot block on stderr. Keep only a bounded, recent failure tail.
|
|
24
|
+
const windowMs = options.diagnosticsWindowMs ?? 10_000;
|
|
25
|
+
let diagnostics = [];
|
|
26
|
+
const recent = () => diagnostics.filter(({ at }) => at >= performance.now() - windowMs);
|
|
27
|
+
child.stderr?.on("data", (chunk) => {
|
|
28
|
+
diagnostics = [...recent(), { at: performance.now(), text: chunk.toString() }];
|
|
29
|
+
while (diagnostics.length > 1 && diagnostics.reduce((length, { text }) => length + text.length, 0) > 8192)
|
|
30
|
+
diagnostics.shift();
|
|
31
|
+
});
|
|
25
32
|
const exited = new Promise((resolve) => {
|
|
26
33
|
child.once("close", () => resolve());
|
|
27
34
|
});
|
|
@@ -45,7 +52,7 @@ export function launchWorker(options = {}) {
|
|
|
45
52
|
}
|
|
46
53
|
});
|
|
47
54
|
},
|
|
48
|
-
diagnostics: () =>
|
|
55
|
+
diagnostics: () => recent().map(({ text }) => text).join("").replace(sdkShadowWarning, "").slice(-8192).trim(),
|
|
49
56
|
/** Await the process, then kill its entire process group if cooperative disposal stalled. */
|
|
50
57
|
stop: (graceful) => stopping ??= (async () => {
|
|
51
58
|
let timer;
|
package/dist/build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
c0812b29-3bd1-4f02-be7b-5147006e3476
|
package/dist/cli/application.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import { getHostStatus, launchBackground, requestHostStop, requireRestartable, waitUntil } from
|
|
4
|
-
import { readHost, oidcFingerprint } from
|
|
5
|
-
import { startRuntime } from
|
|
3
|
+
import { getHostStatus, launchBackground, requestHostStop, requireRestartable, waitUntil } from './host-control.js';
|
|
4
|
+
import { readHost, oidcFingerprint } from '../daemon/ownership.js';
|
|
5
|
+
import { startRuntime } from '../daemon/runtime.js';
|
|
6
6
|
import { join, resolve } from "node:path";
|
|
7
7
|
import { ConfigStore } from "../daemon/config-store.js";
|
|
8
|
-
import { embeddedWorkflowRuntime } from
|
|
8
|
+
import { embeddedWorkflowRuntime } from '../workflows/runtime-asset.js';
|
|
9
9
|
import { fileURLToPath } from 'node:url';
|
|
10
10
|
import { getAsset, isSea } from 'node:sea';
|
|
11
11
|
import { EMBEDDED } from "../web/embedded.js";
|
|
@@ -16,7 +16,7 @@ import { answerLines } from "../client/enquiry.js";
|
|
|
16
16
|
import { authorisationLabel } from "../client/permission.js";
|
|
17
17
|
import { initialState, reduce } from "../client/reduce.js";
|
|
18
18
|
import { runTui } from "../tui/app.js";
|
|
19
|
-
import { updateUnsupportedReason } from
|
|
19
|
+
import { updateUnsupportedReason } from './install-guard.js';
|
|
20
20
|
let webUpdateSupport;
|
|
21
21
|
const USAGE = `usage:
|
|
22
22
|
flow --version print the installed version
|
package/dist/cli/bootstrap.js
CHANGED
|
@@ -889,7 +889,7 @@ async function bootstrap() {
|
|
|
889
889
|
if (!managed) throw new Error("Missing systemd update configuration");
|
|
890
890
|
await assertSystemdOwner(managed, managed.updater, process.pid);
|
|
891
891
|
}
|
|
892
|
-
const lease = await install.register("
|
|
892
|
+
const lease = await install.register("c0812b29-3bd1-4f02-be7b-5147006e3476", root, args, process.env.FLOW_UPDATE_CAPABILITY ?? systemdCapability(root));
|
|
893
893
|
delete process.env.FLOW_UPDATE_CAPABILITY;
|
|
894
894
|
process.on("exit", lease.release);
|
|
895
895
|
if (args[0] === "update") {
|
package/dist/cli/host-control.js
CHANGED
|
@@ -2,7 +2,7 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { closeSync, constants, fchmodSync, mkdirSync, openSync, realpathSync, statSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
|
-
import { oidcFingerprint, readHost } from
|
|
5
|
+
import { oidcFingerprint, readHost } from '../daemon/ownership.js';
|
|
6
6
|
export class HostRefusal extends Error {
|
|
7
7
|
}
|
|
8
8
|
export function processAlive(pid) {
|
|
@@ -2,7 +2,7 @@ import { mkdirSync, realpathSync, lstatSync, readFileSync, writeFileSync, readdi
|
|
|
2
2
|
import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
3
3
|
import { createHash, randomUUID } from 'node:crypto';
|
|
4
4
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
|
-
import { processAlive } from
|
|
5
|
+
import { processAlive } from './host-control.js';
|
|
6
6
|
export const packageName = '@nathanstephenson/flow';
|
|
7
7
|
function record(path) {
|
|
8
8
|
try {
|
package/dist/cli/main.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { isSea } from 'node:sea';
|
|
3
3
|
if (process.argv[2] === '--flow-workflow-authoring-scope-reader' && process.env.FLOW_WORKFLOW_AUTHORING_SCOPE_READER === '1') {
|
|
4
|
-
void import(
|
|
4
|
+
void import('../daemon/workflow-authoring-scope-reader.js').then(({ runWorkflowAuthoringScopeReader }) => runWorkflowAuthoringScopeReader()).catch(() => {
|
|
5
5
|
process.exitCode = 1;
|
|
6
6
|
});
|
|
7
7
|
}
|
|
8
8
|
else if (process.argv[2] === '--flow-workflow-builder-reader' && process.env.FLOW_WORKFLOW_BUILDER_READER === '1') {
|
|
9
|
-
void import(
|
|
9
|
+
void import('../daemon/workflow-builder-reader.js').then(({ runWorkflowBuilderReader }) => runWorkflowBuilderReader()).catch(() => {
|
|
10
10
|
process.exitCode = 1;
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
else if (process.argv[2] === '--flow-isolation-launch' ||
|
|
14
14
|
(process.argv[2] === '--flow-backend-worker' && process.env.FLOW_BACKEND_WORKER === '1')) {
|
|
15
|
-
void import(
|
|
15
|
+
void import('../backend/worker/entry.js').catch(error => {
|
|
16
16
|
console.error(error instanceof Error ? error.message : error);
|
|
17
17
|
process.exitCode = 1;
|
|
18
18
|
});
|
|
@@ -22,7 +22,7 @@ else if (!isSea() && import.meta.url.endsWith('.js')) {
|
|
|
22
22
|
process.exitCode = 1;
|
|
23
23
|
}
|
|
24
24
|
else {
|
|
25
|
-
void import(
|
|
25
|
+
void import('./application.js').then(({ runCli }) => runCli()).catch(error => {
|
|
26
26
|
console.error(error instanceof Error ? error.message : error);
|
|
27
27
|
process.exitCode = 1;
|
|
28
28
|
});
|
|
@@ -2,9 +2,9 @@ import { execFile } from 'node:child_process';
|
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
3
|
import { readFileSync, writeFileSync, unlinkSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
-
import { getHostStatus, waitUntil } from
|
|
6
|
-
import { readHost } from
|
|
7
|
-
import { isReleaseVersion } from
|
|
5
|
+
import { getHostStatus, waitUntil } from './host-control.js';
|
|
6
|
+
import { readHost } from '../daemon/ownership.js';
|
|
7
|
+
import { isReleaseVersion } from '../daemon/release-checker.js';
|
|
8
8
|
const exec = promisify(execFile);
|
|
9
9
|
export function parseSystemdUpdate(value) {
|
|
10
10
|
const c = value;
|
package/dist/cli/update.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { execFileSync } from 'node:child_process';
|
|
2
2
|
import { accessSync, constants, readFileSync, realpathSync } from 'node:fs';
|
|
3
3
|
import { delimiter, join, resolve } from 'node:path';
|
|
4
|
-
import { packageName, privatePath } from
|
|
5
|
-
import { readHost } from
|
|
6
|
-
import { backgroundHostArgs, getHostStatus, HostRefusal, launchBackground, processAlive, requestHostStop, requireRestartable, waitUntil } from
|
|
7
|
-
import { InstallationProcessUncertain, replacePackage } from
|
|
8
|
-
import { assertSystemdOwner, restoreSystemd, resumeSystemdAdmission, systemctl, SystemdCommandFailed } from
|
|
9
|
-
import { newerReleaseVersion } from
|
|
4
|
+
import { packageName, privatePath } from './install-guard.js';
|
|
5
|
+
import { readHost } from '../daemon/ownership.js';
|
|
6
|
+
import { backgroundHostArgs, getHostStatus, HostRefusal, launchBackground, processAlive, requestHostStop, requireRestartable, waitUntil } from './host-control.js';
|
|
7
|
+
import { InstallationProcessUncertain, replacePackage } from './install-process.js';
|
|
8
|
+
import { assertSystemdOwner, restoreSystemd, resumeSystemdAdmission, systemctl, SystemdCommandFailed } from './systemd-update.js';
|
|
9
|
+
import { newerReleaseVersion } from '../daemon/release-checker.js';
|
|
10
10
|
export function npmExecutable() {
|
|
11
11
|
for (const directory of (process.env.PATH ?? '').split(delimiter)) {
|
|
12
12
|
const path = resolve(directory, 'npm');
|
package/dist/cli/web-update.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { systemdUpdate, launchSystemdUpdate, SystemdLaunchUncertain } from
|
|
1
|
+
import { systemdUpdate, launchSystemdUpdate, SystemdLaunchUncertain } from './systemd-update.js';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { closeSync, constants, fchmodSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmdirSync, unlinkSync, writeFileSync, } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { spawn } from 'node:child_process';
|
|
6
|
-
import { newerReleaseVersion, ReleaseChecker } from
|
|
7
|
-
import { UpdateRefusal } from
|
|
8
|
-
export { UpdateRefusal } from
|
|
9
|
-
import { processAlive } from
|
|
10
|
-
import { inspectUpdateInstallation } from
|
|
6
|
+
import { newerReleaseVersion, ReleaseChecker } from '../daemon/release-checker.js';
|
|
7
|
+
import { UpdateRefusal } from '../daemon/update-api.js';
|
|
8
|
+
export { UpdateRefusal } from '../daemon/update-api.js';
|
|
9
|
+
import { processAlive } from './host-control.js';
|
|
10
|
+
import { inspectUpdateInstallation } from './update.js';
|
|
11
11
|
const STATUS_FILE = 'web-update.json';
|
|
12
12
|
const STATUS_LOCK = 'web-update-lock';
|
|
13
13
|
const STATUS_LOCK_ATTEMPTS = 100;
|
package/dist/client/reduce.js
CHANGED
|
@@ -188,6 +188,8 @@ function applyEvent(state, event, at) {
|
|
|
188
188
|
id: event.subagentId,
|
|
189
189
|
name: event.name,
|
|
190
190
|
...(event.description === undefined ? {} : { description: event.description }),
|
|
191
|
+
...(event.model === undefined ? {} : { model: event.model }),
|
|
192
|
+
...(event.effort === undefined ? {} : { effort: event.effort }),
|
|
191
193
|
...(event.producer === undefined ? {} : { producer: event.producer }),
|
|
192
194
|
status: event.state,
|
|
193
195
|
// Only ever set alongside "waiting", so a Subagent that resumes drops it rather than
|