@nathanstephenson/flow 0.1.0 → 0.1.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/README.md +10 -2
- package/dist/backend/fake/index.js +3 -1
- package/dist/backend/pi/effort-capabilities.js +12 -0
- package/dist/backend/pi/index.js +25 -36
- package/dist/backend/pi/workflow-subagent.js +8 -3
- package/dist/build-id +1 -1
- package/dist/cli/application.js +9 -1
- package/dist/cli/bootstrap.js +424 -37
- package/dist/cli/host-control.js +2 -2
- package/dist/cli/install-guard.js +57 -11
- package/dist/cli/systemd-update.js +129 -0
- package/dist/cli/update.js +64 -17
- package/dist/cli/web-update.js +376 -0
- package/dist/client/model-choices.js +22 -4
- package/dist/client/reduce.js +18 -6
- package/dist/client/status.js +34 -20
- package/dist/client/workflow-effort.js +30 -0
- package/dist/daemon/credential-redaction.js +97 -4
- package/dist/daemon/host-control-routes.js +18 -2
- package/dist/daemon/host.js +341 -74
- package/dist/daemon/release-checker.js +104 -0
- package/dist/daemon/runtime.js +12 -4
- package/dist/daemon/server.js +98 -15
- package/dist/daemon/summariser.js +81 -15
- package/dist/daemon/update-api.js +3 -0
- package/dist/daemon/workflow-executions.js +146 -15
- package/dist/protocol/update.js +1 -0
- package/dist/tui/app.js +104 -10
- package/dist/tui/keys.js +46 -10
- package/dist/tui/render.js +58 -13
- package/dist/workflows/records.js +3 -1
- package/dist/workflows/scheduler.js +15 -1
- package/package.json +1 -1
- package/web/dist/apple-touch-icon.png +0 -0
- package/web/dist/assets/index-BlZBshi8.js +170 -0
- package/web/dist/assets/index-DWF4-3Fh.css +2 -0
- package/web/dist/assets/{settings-mcp-CcT0ADJR.js → settings-mcp-ZMIfuuZU.js} +1 -1
- package/web/dist/assets/{settings-secrets-CK4uF7fd.js → settings-secrets-CgTrBpi2.js} +1 -1
- package/web/dist/assets/settings-workflows-1DMYfZtn.js +23 -0
- package/web/dist/assets/{workflows-D4T4Gy_7.css → workflows-9aO6cptD.css} +1 -1
- package/web/dist/assets/workflows-CBuB_bva.js +7 -0
- package/web/dist/assets/workflows-pane-DPXGg0na.js +1 -0
- package/web/dist/favicon-16x16.png +0 -0
- package/web/dist/favicon-32x32.png +0 -0
- package/web/dist/favicon.ico +0 -0
- package/web/dist/favicon.svg +8 -0
- package/web/dist/index.html +8 -3
- package/web/dist/safari-pinned-tab.svg +4 -0
- package/web/dist/assets/index-BC0gLS53.js +0 -106
- package/web/dist/assets/index-CCeZYKES.css +0 -2
- package/web/dist/assets/settings-workflows-CrbZF-nM.js +0 -23
- package/web/dist/assets/workflow-editors-naPqAmYO.js +0 -65
- package/web/dist/assets/workflows-hh6ioeEA.js +0 -7
- package/web/dist/assets/workflows-pane-Db-MHf7Z.js +0 -1
package/README.md
CHANGED
|
@@ -60,7 +60,12 @@ do not tag a version until its license and release contents are approved.
|
|
|
60
60
|
## Updating Flow
|
|
61
61
|
|
|
62
62
|
Run `flow update` to install `@nathanstephenson/flow@latest` with the npm selected by PATH.
|
|
63
|
-
|
|
63
|
+
An authorised browser connected to a background or configured systemd-owned Session Host can perform the same guarded operation
|
|
64
|
+
from **Settings → General → Flow update** after explicit confirmation. The browser checks only npm's
|
|
65
|
+
stable `latest` tag, cannot select a package/version/path or force active work to stop, and reconnects
|
|
66
|
+
on the same address and port to verify the running version. Updates are never automatic.
|
|
67
|
+
|
|
68
|
+
The global prefix must match this exact installation. Only user-owned prefixes without group or
|
|
64
69
|
other write access are supported; their ancestor directories must also prevent replacement by other users. Source, npm-link, root/sudo, shared prefixes, and SEA self-update
|
|
65
70
|
are not supported. Ordinary commands still work for these installations. Update shared or system
|
|
66
71
|
installations manually with npm after stopping all Flow processes.
|
|
@@ -68,7 +73,10 @@ installations manually with npm after stopping all Flow processes.
|
|
|
68
73
|
Close all CLI/TUI clients and stop other Session Hosts that use this installation, including those
|
|
69
74
|
under other `FLOW_STATE_DIR` roots. The selected root's background Session Host can stay running:
|
|
70
75
|
Flow stops it, updates, and restores its saved address, port, working directory and OIDC settings
|
|
71
|
-
with a new process. Use `--force` to interrupt active work.
|
|
76
|
+
with a new process. Use `--force` to interrupt active work. Unmanaged foreground and embedded hosts are refused.
|
|
77
|
+
For foreground systemd services (including system units with `User=agent`), see
|
|
78
|
+
[systemd update setup](docs/systemd-updates.md): a separate non-root updater unit retains service ownership
|
|
79
|
+
and needs only narrowly scoped start/stop authority configured once by an administrator.
|
|
72
80
|
The same OIDC configuration must be present when you update. No version argument is accepted.
|
|
73
81
|
|
|
74
82
|
Before first adopting this release, stop **all** older Flow processes. Old processes have no
|
|
@@ -208,8 +208,10 @@ export class FakeSession {
|
|
|
208
208
|
this.wantedEffort = effort;
|
|
209
209
|
const levels = FAKE_CAPABILITIES.models.find((model) => model.id === this.modelId)?.effortLevels;
|
|
210
210
|
const level = clampEffort(effort, levels);
|
|
211
|
-
if (!level)
|
|
211
|
+
if (!level) {
|
|
212
|
+
this.effort = undefined;
|
|
212
213
|
return;
|
|
214
|
+
}
|
|
213
215
|
this.effort = level;
|
|
214
216
|
this.emit({ type: "effort_changed", effort: level });
|
|
215
217
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getSupportedThinkingLevels } from "@earendil-works/pi-ai";
|
|
2
|
+
export function piEffortLevels(model) {
|
|
3
|
+
if (!model.reasoning)
|
|
4
|
+
return [];
|
|
5
|
+
// The SDK helper reads only the two fields retained above; registry models carry the full shape.
|
|
6
|
+
return getSupportedThinkingLevels(model);
|
|
7
|
+
}
|
|
8
|
+
/** Exact workflow validation, including the internal sentinel for a confirmed no-control model. */
|
|
9
|
+
export function piAcceptsWorkflowEffort(model, effort) {
|
|
10
|
+
const levels = piEffortLevels(model);
|
|
11
|
+
return levels.length === 0 ? effort === "off" : levels.includes(effort);
|
|
12
|
+
}
|
package/dist/backend/pi/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { piMcpTools } from "./mcp.js";
|
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
import { createAgentSession, DefaultResourceLoader, getAgentDir, SessionManager, SettingsManager, } from "@earendil-works/pi-coding-agent";
|
|
5
5
|
import { PiWorkflowSubagent } from "./workflow-subagent.js";
|
|
6
|
+
import { piEffortLevels } from "./effort-capabilities.js";
|
|
6
7
|
import { clampEffort } from "../effort.js";
|
|
7
8
|
import { piAutoCompaction } from "./auto-compaction.js";
|
|
8
9
|
import { ASK_TOOL, PiEnquiries } from "./enquiries.js";
|
|
@@ -102,8 +103,10 @@ export class PiSession {
|
|
|
102
103
|
// Which levels are on offer follows the model, and pi may have clamped its own thinking level
|
|
103
104
|
// on the way through, so both the list and the level in force are re-read here.
|
|
104
105
|
this.capabilities = capabilitiesOf(this.session, this.enquiries !== undefined, this.capabilities.subagents);
|
|
105
|
-
|
|
106
|
+
// Publish the new list first. A client that receives the model first would briefly classify its
|
|
107
|
+
// Effort support as unknown (or, worse, reuse the old model's list).
|
|
106
108
|
this.emit({ type: "capabilities_changed", capabilities: this.capabilities });
|
|
109
|
+
this.emit({ type: "model_changed", model: describeModel(model) });
|
|
107
110
|
this.reapplyEffort();
|
|
108
111
|
}
|
|
109
112
|
async setEffort(effort) {
|
|
@@ -448,10 +451,21 @@ export class PiBackend {
|
|
|
448
451
|
const listed = piSession.capabilities.models.find((model) => model.id === described.id);
|
|
449
452
|
options.emit({ type: "model_changed", model: listed ?? described });
|
|
450
453
|
}
|
|
451
|
-
// Announced after the model, because which model is in force
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
+
// Announced after the model, because which model is in force decides whether an Effort level
|
|
455
|
+
// means anything. A persisted/default value is configuration, not a live model switch: reject
|
|
456
|
+
// an invalid one for explicit correction instead of silently clamping it. Live setEffort keeps
|
|
457
|
+
// the normal nearest-level clamp below.
|
|
458
|
+
if (options.effort) {
|
|
459
|
+
const levels = session.model ? piEffortLevels(session.model) : [];
|
|
460
|
+
const accepted = levels.length === 0 ? options.effort === "off" : levels.includes(options.effort);
|
|
461
|
+
if (!accepted) {
|
|
462
|
+
await piSession.dispose();
|
|
463
|
+
throw new Error(levels.length > 0
|
|
464
|
+
? `Unsupported saved Effort “${options.effort}” for ${describeModel(session.model).id}. Choose one of ${levels.join(", ")}.`
|
|
465
|
+
: `Unsupported saved Effort “${options.effort}” for a model with no Effort control. Clear it or use off.`);
|
|
466
|
+
}
|
|
454
467
|
await piSession.setEffort(options.effort);
|
|
468
|
+
}
|
|
455
469
|
else
|
|
456
470
|
piSession.noteStartingEffort();
|
|
457
471
|
return piSession;
|
|
@@ -524,17 +538,9 @@ async function runSubagent(parent, scope, agentDir, work, id, input, signal, emi
|
|
|
524
538
|
}
|
|
525
539
|
}
|
|
526
540
|
function capabilitiesOf(session, enquiries, subagents) {
|
|
527
|
-
|
|
528
|
-
//
|
|
529
|
-
const models = session.modelRuntime.getAvailableSnapshot().map(
|
|
530
|
-
const described = describeModel(model);
|
|
531
|
-
// pi will only answer for the model it has selected, and that answer is the authoritative one.
|
|
532
|
-
// Every other entry is inferred from the registry and firms up if you switch to it.
|
|
533
|
-
if (described.id !== current)
|
|
534
|
-
return described;
|
|
535
|
-
const available = availableEffort(session);
|
|
536
|
-
return available.length > 0 ? { ...described, effortLevels: available } : omitEffort(described);
|
|
537
|
-
});
|
|
541
|
+
// The SDK populates this auth-filtered snapshot before createAgentSession resolves. Every model is
|
|
542
|
+
// described directly: effort discovery is observational and must never switch the active model.
|
|
543
|
+
const models = session.modelRuntime.getAvailableSnapshot().map(describeModel);
|
|
538
544
|
const providers = [...new Set(models.map((model) => model.provider).filter(isString))];
|
|
539
545
|
return {
|
|
540
546
|
providers: providers.length > 0 ? providers : ["pi"],
|
|
@@ -547,8 +553,8 @@ function capabilitiesOf(session, enquiries, subagents) {
|
|
|
547
553
|
permissions: false,
|
|
548
554
|
};
|
|
549
555
|
}
|
|
550
|
-
function describeModel(model) {
|
|
551
|
-
const effortLevels =
|
|
556
|
+
export function describeModel(model) {
|
|
557
|
+
const effortLevels = piEffortLevels(model);
|
|
552
558
|
return {
|
|
553
559
|
id: model.provider ? `${model.provider}/${model.id}` : model.id,
|
|
554
560
|
...(model.contextWindow !== undefined && Number.isFinite(model.contextWindow) && model.contextWindow > 0 ? { contextWindow: model.contextWindow } : {}),
|
|
@@ -561,26 +567,9 @@ function describeModel(model) {
|
|
|
561
567
|
...(model.input?.includes("image") ? { acceptsImages: true } : {}),
|
|
562
568
|
};
|
|
563
569
|
}
|
|
564
|
-
/** The
|
|
570
|
+
/** The same per-model SDK answer used for non-selected catalogue entries. */
|
|
565
571
|
function availableEffort(session) {
|
|
566
|
-
return session.
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* What a model that is not currently selected probably offers. A model that cannot reason offers
|
|
570
|
-
* nothing; otherwise its thinkingLevelMap names the levels it was configured with.
|
|
571
|
-
*/
|
|
572
|
-
function inferredEffort(model) {
|
|
573
|
-
if (model.reasoning === false)
|
|
574
|
-
return [];
|
|
575
|
-
const map = model.thinkingLevelMap;
|
|
576
|
-
if (!map)
|
|
577
|
-
return model.reasoning ? PI_EFFORT_LEVELS : [];
|
|
578
|
-
return PI_EFFORT_LEVELS.filter((level) => map[level] !== undefined && map[level] !== null);
|
|
579
|
-
}
|
|
580
|
-
const PI_EFFORT_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
581
|
-
function omitEffort(model) {
|
|
582
|
-
const { effortLevels: _dropped, ...rest } = model;
|
|
583
|
-
return rest;
|
|
572
|
+
return session.model ? piEffortLevels(session.model) : [];
|
|
584
573
|
}
|
|
585
574
|
function joinBlocks(content, kind) {
|
|
586
575
|
if (typeof content === "string")
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
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
|
+
import { piAcceptsWorkflowEffort, piEffortLevels } from "./effort-capabilities.js";
|
|
4
5
|
import { piAutoCompaction } from "./auto-compaction.js";
|
|
5
6
|
import { PiEnquiries } from "./enquiries.js";
|
|
6
7
|
import { backgroundTools } from "./background-calls.js";
|
|
@@ -111,6 +112,13 @@ export class PiWorkflowSubagent {
|
|
|
111
112
|
throw error;
|
|
112
113
|
}
|
|
113
114
|
controller.signal.throwIfAborted();
|
|
115
|
+
// Validate against the registry model before creating a child. This is the same SDK-backed
|
|
116
|
+
// rule used by the catalogue and parent capabilities, and guarantees invalid workflow input
|
|
117
|
+
// cannot launch agent work first and fail afterwards.
|
|
118
|
+
if (!piAcceptsWorkflowEffort(model, options.effort)) {
|
|
119
|
+
const available = model.reasoning ? ` Choose one of ${piEffortLevels(model).join(", ")}.` : " This model has no Effort control; use off.";
|
|
120
|
+
throw new Error(`Unsupported workflow Effort “${options.effort}” for ${options.modelId}.${available}`);
|
|
121
|
+
}
|
|
114
122
|
let prompt = JSON.stringify(options.input);
|
|
115
123
|
if (options.skill) {
|
|
116
124
|
const promptTemplate = resourceLoader.getPrompts().prompts.some(candidate => candidate.name === options.skill.name);
|
|
@@ -137,9 +145,6 @@ export class PiWorkflowSubagent {
|
|
|
137
145
|
piAutoCompaction(settingsManager, this.autoCompaction)(model);
|
|
138
146
|
this.child = session;
|
|
139
147
|
controller.signal.throwIfAborted();
|
|
140
|
-
if (!session.getAvailableThinkingLevels().includes(options.effort)) {
|
|
141
|
-
throw new Error(`Unsupported workflow Effort: ${options.effort}`);
|
|
142
|
-
}
|
|
143
148
|
session.setThinkingLevel(options.effort);
|
|
144
149
|
let output = "";
|
|
145
150
|
let failure;
|
package/dist/build-id
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
a05670ad-d8b7-4859-afde-7cc8ad2f6548
|
package/dist/cli/application.js
CHANGED
|
@@ -16,6 +16,8 @@ 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 "./install-guard.js";
|
|
20
|
+
let webUpdateSupport;
|
|
19
21
|
const USAGE = `usage:
|
|
20
22
|
flow --version print the installed version
|
|
21
23
|
flow update [--force] update a private global npm installation
|
|
@@ -159,6 +161,11 @@ const LOOPBACK = "127.0.0.1";
|
|
|
159
161
|
async function startHost(port, address, mode = 'embedded') {
|
|
160
162
|
const runtime = await startRuntime({
|
|
161
163
|
root: defaultStateRoot(), version: installedVersion(), mode, assets: webClient,
|
|
164
|
+
...(webUpdateSupport?.installation && webUpdateSupport.bootstrapEntry
|
|
165
|
+
? { updateInstallation: { installation: webUpdateSupport.installation, bootstrapEntry: webUpdateSupport.bootstrapEntry } }
|
|
166
|
+
: { updateUnsupportedReason: isSea()
|
|
167
|
+
? updateUnsupportedReason('sea')
|
|
168
|
+
: webUpdateSupport?.unsupportedReason ?? updateUnsupportedReason('source') }),
|
|
162
169
|
workflowRuntime: () => isSea() ? embeddedWorkflowRuntime() : fileURLToPath(new URL('../../build/workflow-runtime.cjs', import.meta.url)),
|
|
163
170
|
...(port === undefined ? {} : { port }), ...(address === undefined ? {} : { address }),
|
|
164
171
|
});
|
|
@@ -385,7 +392,8 @@ async function reachable(daemon) {
|
|
|
385
392
|
return false;
|
|
386
393
|
}
|
|
387
394
|
}
|
|
388
|
-
export function runCli() {
|
|
395
|
+
export function runCli(updateSupport) {
|
|
396
|
+
webUpdateSupport = updateSupport;
|
|
389
397
|
return main()
|
|
390
398
|
.then((code) => process.exit(code))
|
|
391
399
|
.catch((error) => {
|