neurastream 0.2.86 → 0.3.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 +22 -7
- package/package.json +1 -1
- package/src/adapters/omp/doctor.ts +10 -3
- package/src/adapters/omp/index.ts +21 -5
- package/src/cli/claim.ts +48 -17
- package/src/cli/dispatch.ts +23 -8
- package/src/cli/setup.ts +3 -3
- package/src/cli/team.ts +311 -0
- package/src/cli/workspace.ts +235 -0
- package/src/core/claims.ts +29 -11
- package/src/core/config.ts +16 -5
- package/src/core/guards.ts +182 -46
- package/src/core/incident-detectors.ts +1 -1
- package/src/core/mr-sweep.ts +33 -6
- package/src/core/owner-ui.ts +353 -132
- package/src/core/pages.ts +1 -1
- package/src/core/queue/lib.ts +23 -9
- package/src/core/queue-check.ts +5 -3
- package/src/core/queue-close.ts +3 -3
- package/src/core/team-client.ts +813 -0
- package/src/core/team-labels.ts +127 -0
- package/src/core/team-server.ts +1008 -0
- package/src/core/ui-setup.ts +186 -41
- package/templates/config.yml +5 -3
- package/templates/queue/TEMPLATE.md +2 -0
- package/templates/systemd/neurastream-workspace.service +17 -0
- package/src/cli/ui.ts +0 -104
- package/templates/systemd/neurastream-ui.service +0 -16
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ flowchart LR
|
|
|
37
37
|
| Unlanded work (`wip-check`, `wip-snapshot`, `wip-backup`) | Lists branches on no remote and dirty worktrees; snapshots them as hidden commits; can push them to a backup repo. |
|
|
38
38
|
| Session rollover | When the main session file passes 5 MB, or the installed neurastream version differs from the running plugin, Main writes a handoff note; a fresh session then starts on its own under `neurastream main`. |
|
|
39
39
|
A request written by an older version in the legacy dir is still picked up: when the new-path file is missing or stale, the launcher falls back to the legacy `rollover/relaunch.json` (main id only) and clears both copies once consumed.
|
|
40
|
-
| Owner page (`neurastream
|
|
40
|
+
| Owner page (`neurastream workspace`) | One phone-sized page over Tailscale (`workspace.*` config): the plans waiting on the owner with answer buttons, the guard unlock, running agents, the queue, recent merges/CI, open incidents (a finding carries Main's reason and False alarm / It's a bug buttons), agent scores, machine health. Serves only a tailnet peer whose `tailscale whois` login equals `workspace.owner_login`, only with a Host header naming the tailnet address or the MagicDNS name — DNS rebinding and every other visitor get a 403. Answers land in the owner inbox and reach Main once each; agents cannot start the page or write the inbox. |
|
|
41
41
|
|
|
42
42
|
## Main vs plain omp
|
|
43
43
|
|
|
@@ -179,17 +179,17 @@ The omp adapter samples machine pressure every `machine.pressure.sample_sec` (de
|
|
|
179
179
|
|
|
180
180
|
This is tell-only: neurastream never pauses, kills or renices a process. The level state lives in `<queue_state>/pressure.json`. `neurastream pressure` prints the current level, the sample and the line Main would read now.
|
|
181
181
|
|
|
182
|
-
## Owner page (`neurastream
|
|
182
|
+
## Owner page (`neurastream workspace`)
|
|
183
183
|
|
|
184
|
-
`neurastream
|
|
184
|
+
`neurastream workspace on --login <tailscale login> [--port N]` does the whole setup in one sentence: it writes `workspace.enabled: true` and `workspace.owner_login` (plus `workspace.port` with `--port`) into `~/.config/neurastream/config.yml` — every other line of the file is kept byte-for-byte — copies `templates/systemd/neurastream-workspace.service` to `~/.config/systemd/user/neurastream-workspace.service`, disables and removes the old `neurastream-ui` unit from before the rename, runs `systemctl --user daemon-reload`, `enable` and `restart`, then prints the phone link `http://<MagicDNS name>:<port>`. The login must be one the tailnet knows (`tailscale status --json`); when tailscale cannot answer, the check is skipped with a printed warning, never a refusal. `neurastream workspace off` stops and disables the unit and sets `workspace.enabled: false`, keeping `workspace.owner_login` for the next `on`.
|
|
185
185
|
|
|
186
|
-
With `
|
|
186
|
+
With `workspace.enabled: true` and `workspace.owner_login` set (`neurastream config`, `docs/config.md`), `neurastream workspace` serves one page bound to this machine's tailnet address only (port `workspace.port`, default 7787; `templates/systemd/neurastream-workspace.service` runs it as a user unit). A sticky top bar holds the "ns" logo, five pill tabs — Now, Queue, Agents, Spend, Base (see "Base tab" below), each a server-rendered view (`/?tab=…`, an unknown value falls back to Now) — and the lock pill ("🔒 Off" / "🔓 12 min") that opens the guard unlock ("Unlock 15 min", "Unlock 30 min", "Lock now"; when `guards.chat_unlock` is off it says so in plain words with the exact config line). Now is the home tab: a Today tile card over the last 24 h (needs-you count in warn color, list-price spend with a sparkline and the Main/agents split, agent runs with running/died counts and a sparkline, open plans), then one card per open `WAITING on owner:` plan that says why it needs him — the plan's `#` title, then Do (what to do), Stuck until then (what stays blocked, including plans this answer unblocks), and Why you (why Main cannot do it), with the goal folded into a Background block. A question ask gets "Yes"/"No"/"Reply…"; a task ask gets "Done". The answer shows as a one-time receipt ("Sent to Main · 08:12"); once the owner inbox already holds an answer for a plan, the card says so ("You answered ‘yes' · 14:19 — Main is on it") with a small change-answer link. The queue is one flat ranked list in `INDEX.md` order. Each card shows the plan title, a two-line summary from the plan's `Summary:` header (one or two plain sentences under Branch; if that line is missing, the first Goal bullet with a leading Owner or INCIDENT prefix cut off), and a status chip — waits you, waits on another plan, not started, phase K of N, or all N done. Drag a card by its ≡ handle, or tap "↑ top"/"↑"/"↓"; the drop rewrites `INDEX.md`, Main gets the move as a message and the page confirms "Moved to #2". Now shows the first 8 rows with a "Show all N ›" link to the Queue tab. The Agents tab lists working-now rows (a run that died before its first reply shows the model from the spawning agent's `model:` frontmatter, never "?"), the agent-score table, open incidents, recent merges/CI and machine health; the Spend tab pairs the spend tile with per-model spend over 24 h. The Now tab also has a "Tell Main" message box for a text note and up to four images; Main receives the text and pictures, and the page keeps a "Sent today" list for 12 hours before removing those messages and their image files. Light and dark follow the OS; there are no external assets and no build step — one server-rendered HTML string, inline CSS and one small inline script under a per-response CSP nonce (`bun scripts/ui-preview.ts <out.html> [--tab <name>]` renders a preview without a server). No chat, no plan editing, no shell.
|
|
187
187
|
|
|
188
188
|
When `tailscale ip -4` answers a new address, the server exits within 30 s and its user unit's `Restart=on-failure` starts it on the new address; no manual restart.
|
|
189
189
|
|
|
190
|
-
A request is served only when the peer is a tailnet address that is neither loopback nor this machine's own tailnet IP, `tailscale whois` names the `
|
|
190
|
+
A request is served only when the peer is a tailnet address that is neither loopback nor this machine's own tailnet IP, `tailscale whois` names the `workspace.owner_login` login — and the Host header is this machine: the tailnet address or the MagicDNS name, with the served port. The Host check runs on every request before whois, and a POST's Origin must match it, so a DNS-rebinding page (foreign Host, matching Origin, owner's phone) gets a 403 like everyone else. `workspace.allow_this_machine: true` skips only the two this-machine refusals — loopback and the machine's own tailnet IP are then served as the owner, GET and POST — with the risk in one line: any local process can then press the buttons. Every request logs one `UI <method> <path> login=<l> → <code>` line to the guard log.
|
|
191
191
|
|
|
192
|
-
An answer appends one record to `<queue_state>/owner-inbox.jsonl` (plan, question, answer, login); unlock/lock go through the core unlock and log `UNLOCK ui source=ui:<login> minutes=N`. Main's session delivers each record once as a user message — at turn end and on a 15 s poll while idle — and marks the consumed rows in `<queue_state>/owner-inbox.cursor`; subagent sessions never deliver. Both files sit under the queue state dir, so guards refuse agent writes to them: an agent cannot forge an owner answer. Guards also refuse agent commands that start the page (`neurastream
|
|
192
|
+
An answer appends one record to `<queue_state>/owner-inbox.jsonl` (plan, question, answer, login); unlock/lock go through the core unlock and log `UNLOCK ui source=ui:<login> minutes=N`. Main's session delivers each record once as a user message — at turn end and on a 15 s poll while idle — and marks the consumed rows in `<queue_state>/owner-inbox.cursor`; subagent sessions never deliver. Both files sit under the queue state dir, so guards refuse agent writes to them: an agent cannot forge an owner answer. Guards also refuse agent commands that start the page (`neurastream workspace`, or `systemctl --user start/restart/enable` of `neurastream-workspace`): starting it is the owner's move.
|
|
193
193
|
|
|
194
194
|
## Static pages (`neurastream pages`)
|
|
195
195
|
|
|
@@ -266,7 +266,7 @@ Guard rules around it:
|
|
|
266
266
|
- A blocked stop still posts its final reply once when it has text; agent_end skips that blocked stop to avoid a duplicate. Every post is serialized in call order; Discord 429 responses wait for `retry_after` (or `Retry-After`, default 1 s; capped at 10 s) and retry the chunk once.
|
|
267
267
|
- Posts time out at 5 seconds per attempt. Long replies are split per channel (Discord 2000, Slack 3000 characters) on line boundaries where possible; failures are logged without delaying the stop decision.
|
|
268
268
|
|
|
269
|
-
"Needs you" pings use the same channels so the owner learns on the phone that a decision is his: when a Main turn ends with an open plan whose `WAITING on owner:` line was not pinged before, neurastream posts `🔔 Needs you — <plan>: <question>` (with the `neurastream
|
|
269
|
+
"Needs you" pings use the same channels so the owner learns on the phone that a decision is his: when a Main turn ends with an open plan whose `WAITING on owner:` line was not pinged before, neurastream posts `🔔 Needs you — <plan>: <question>` (with the `neurastream workspace` phone-page link when `workspace.enabled: true`), and when the guard refuses a Main tool call because it touches a protected guard file, it posts `🔓 Main needs an unlock to continue (<file>)` — the unlock ping at most once per 30 minutes, each waiting question once until its line changes or disappears, remembered in `<queue_state>/notify-waiting.json`. Every decision logs one `notify: needs-you posted|skipped (<why>)` guard-log line.
|
|
270
270
|
|
|
271
271
|
## Continuous feedback (watch)
|
|
272
272
|
|
|
@@ -323,6 +323,21 @@ The 30-minute rule: a claim lives by its heartbeat — the adapter beats every c
|
|
|
323
323
|
|
|
324
324
|
Claim heartbeats are not the job heartbeats of the watch section above. A job heartbeat says a cron job ran (`<queue_state>/heartbeats/<name>.json`, stale per `watch.expect`); a claim heartbeat is per-Main liveness recorded in the claim itself, under `<queue_state>/claims/` — one JSON file per plan, its `beat` refreshed every minute. Claims are never wired into `watch`.
|
|
325
325
|
|
|
326
|
+
## Team queue
|
|
327
|
+
|
|
328
|
+
A team queue shares one plan queue between the members of a team, through a server the team runs on its own Tailscale network. Your personal Tailscale is separate and is never used for the team server. The full server reference (auth, data, backup, routes) is [docs/team-server.md](docs/team-server.md); the config is `teams:` in [config.md](docs/config.md).
|
|
329
|
+
|
|
330
|
+
- Setup: `neurastream workspace on --team <name> --admin <login> --repo <glob>` starts the server as the systemd user unit `neurastream-team-<name>`; `workspace off --team <name>` stops it and keeps its database. Members join with `neurastream team join <url> --name <name> --repo <path>`, and leave with `team leave`.
|
|
331
|
+
- Labels: a plan reaches the team queue only when its header says `Queue: team` and it sits in a repo the team lists under `teams[].repos`. Personal plans and plans in other repos never leave your PC. `neurastream team share <plan>` sends one plan, and `team unshare <plan>` takes it back.
|
|
332
|
+
- Who approves: a plan is approved by a member who did not last claim it (cross review). With fewer than two members, the one member may approve its own plan; that approval is audited with the note `solo`.
|
|
333
|
+
- The 30-minute rule is the same as the personal queue: a team claim lives by its heartbeat and is free `queue.claim_ttl_min` (default 30) minutes after the last beat.
|
|
334
|
+
- Order: the leader's override (`POST /order/override`) comes first, in its order; then voted plans by rank sum, lowest first; then unvoted plans. Each member's ranks are replaced whole on every vote.
|
|
335
|
+
- First answer wins: when a question is waiting on the team, the first owner answer is the one that counts.
|
|
336
|
+
- Pause: `neurastream team pause <name>` refuses your claims on that team and releases your own claims there; `team resume` reopens it.
|
|
337
|
+
- Same goal: sharing a plan whose goal matches one already on the queue is refused unless you give `--distinct "<reason>"`.
|
|
338
|
+
- Share cap: `teams[].max_share` (above 0, at most 1) caps the team's share of today's model calls. This is a soft rule. The spawn log is not locked, so concurrent spawns can overshoot the cap. When a team sets `max_share`, a spawn without a name is refused so its calls count against the cap; that refusal is not covered by a test yet.
|
|
339
|
+
- Cross review is soft too: it checks only the last claimer, so handing a claim to another member lets the same person claim and approve.
|
|
340
|
+
|
|
326
341
|
## Secrets never reach the chat
|
|
327
342
|
|
|
328
343
|
A value the machine holds is hidden before the model, the chat and the session log see it (`src/core/secret-redact.ts`, plan 20261025_2204, incident I-20261025-197). Detection is by **content**, not by file name — the old name list never knew about `~/.npmrc`.
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import { allowedAgents, readIndex, reviewAgentsProblem } from "../../core/queue/
|
|
|
17
17
|
import { systemRunner, type Runner } from "../../core/pages-setup.ts";
|
|
18
18
|
import { packageJsonPath } from "./package-root.ts";
|
|
19
19
|
import { realTailscale, type Tailscale } from "../../core/tailscale.ts";
|
|
20
|
+
import { teamViews } from "../../core/team-client.ts";
|
|
20
21
|
import { wipHealth } from "../../core/wip-setup.ts";
|
|
21
22
|
import { readOmpProviders } from "./providers.ts";
|
|
22
23
|
|
|
@@ -235,12 +236,18 @@ export function doctorReport(home: string, env: NodeJS.ProcessEnv = process.env,
|
|
|
235
236
|
}
|
|
236
237
|
// The owner page (plan 20261024_2230): when it is switched on, the login must be set and
|
|
237
238
|
// tailscale must answer, or the unit will start and refuse, or serve nobody.
|
|
238
|
-
if (cfg.
|
|
239
|
+
if (cfg.workspace.enabled) {
|
|
239
240
|
const state = tailscale.state();
|
|
240
241
|
if (state === "running") ok.push("tailscale: ok");
|
|
241
242
|
else problems.push(`tailscale: ${state === "missing" ? "missing" : "logged out"}`);
|
|
242
|
-
if (!cfg.
|
|
243
|
-
else if (state === "running") ok.push(`
|
|
243
|
+
if (!cfg.workspace.owner_login) problems.push("workspace.enabled but workspace.owner_login is empty");
|
|
244
|
+
else if (state === "running") ok.push(`workspace owner page: login ${cfg.workspace.owner_login}`);
|
|
245
|
+
}
|
|
246
|
+
// Teams (plan 20261027_1305 P6): each teams: entry must answer its view for this login. A team that
|
|
247
|
+
// is down, or refuses this login (not a member), is a problem; a reachable one shows the claims held here.
|
|
248
|
+
for (const [teamName, view] of teamViews(cfg)) {
|
|
249
|
+
if ("unreachable" in view) problems.push(`team ${teamName}: ${view.unreachable} did not answer — down, or this login is not a member`);
|
|
250
|
+
else ok.push(`team ${teamName}: ${view.claims.filter(c => c.mine).length} claim(s) held by this login`);
|
|
244
251
|
}
|
|
245
252
|
// WIP timers (plan 20261027_1130 P6): roots set with nothing scheduled is a silent stop, and so
|
|
246
253
|
// is a run that failed — the state that went unnoticed for a week before this plan.
|
|
@@ -27,7 +27,8 @@ import { configFile, loadConfig, reloadingConfig, type Config } from "../../core
|
|
|
27
27
|
import { checkWrite, deferSteer, type WriteCheckConfig } from "../../core/write-check.ts";
|
|
28
28
|
import { nowSec, strftime } from "../../core/clock.ts";
|
|
29
29
|
import { runDetectors, type DetectorInput } from "../../core/incident-detectors.ts";
|
|
30
|
-
import { fileClaimStore } from "../../core/claims.ts";
|
|
30
|
+
import { fileClaimStore, type ClaimStore } from "../../core/claims.ts";
|
|
31
|
+
import { remoteStoreFor } from "../../core/team-client.ts";
|
|
31
32
|
import { appendOwnerAnswer, readOwnerAnswers, readOwnerMessages } from "../../core/incidents.ts";
|
|
32
33
|
import { checkInject, checkPlanEdit, checkStop, checkTool, findingsValue, MAIN_PLAN_FILE, mainId, mainStateDir, newProgressEntries, planReadNote, plannerSpawnPlan, recordMainResult, resetMainCalls, revertMainEdit, rekeySpawnFile, reviewSpawnEnd, STOP_PLAN_OFFER_REFUSAL } from "../../core/guards.ts";
|
|
33
34
|
import { rateLimited } from "../../core/rate-limit.ts";
|
|
@@ -857,10 +858,10 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
|
|
|
857
858
|
// computed at most once per process (tailscale status is a subprocess call).
|
|
858
859
|
let phonePageSuffix: string | null = null;
|
|
859
860
|
const phonePage = (): string => {
|
|
860
|
-
if (!cfg.
|
|
861
|
+
if (!cfg.workspace.enabled) return "";
|
|
861
862
|
if (phonePageSuffix === null) {
|
|
862
863
|
const dns = realTailscale.dnsName();
|
|
863
|
-
phonePageSuffix = dns ? ` Answer on the phone page: http://${dns}:${cfg.
|
|
864
|
+
phonePageSuffix = dns ? ` Answer on the phone page: http://${dns}:${cfg.workspace.port}` : "";
|
|
864
865
|
}
|
|
865
866
|
return phonePageSuffix;
|
|
866
867
|
};
|
|
@@ -959,9 +960,23 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
|
|
|
959
960
|
// so a live Main never loses a plan to queue.claim_ttl_min. session_shutdown releases
|
|
960
961
|
// nothing: the TTL frees a crashed or restarted Main's claims the same way.
|
|
961
962
|
const beat = (): void => {
|
|
962
|
-
const store = fileClaimStore(cfg.paths.queue_state, nowSec, cfg.queue.claim_ttl_min);
|
|
963
963
|
const id = mainId();
|
|
964
|
-
|
|
964
|
+
// P3 (plan 20261027_1305): the file store lists only personal claims (the chooser
|
|
965
|
+
// never sends a team plan to it); each team's remote store lists that team's claims
|
|
966
|
+
// with ids mapped to local paths. Every claim is beaten through the store that
|
|
967
|
+
// listed it; a team whose list() is Unreachable is skipped for this tick (its
|
|
968
|
+
// claims lapse at the TTL) and the file beats still run.
|
|
969
|
+
const stores: ClaimStore[] = [
|
|
970
|
+
fileClaimStore(cfg.paths.queue_state, nowSec, cfg.queue.claim_ttl_min),
|
|
971
|
+
...(cfg.teams ?? []).map(team => remoteStoreFor(team, cfg)),
|
|
972
|
+
];
|
|
973
|
+
for (const store of stores) {
|
|
974
|
+
const rows = store.list();
|
|
975
|
+
if (!Array.isArray(rows)) continue;
|
|
976
|
+
// `mine !== false`: never beat another login's row that happens to share the
|
|
977
|
+
// main string; the server would answer 403 (P2b (7c)).
|
|
978
|
+
for (const claim of rows) if (claim.main === id && claim.mine !== false) store.heartbeat(claim.plan, id);
|
|
979
|
+
}
|
|
965
980
|
};
|
|
966
981
|
const hb: unknown = c.setInterval ? c.setInterval(beat, CLAIM_BEAT_MS) : setInterval(beat, CLAIM_BEAT_MS);
|
|
967
982
|
if (hb && typeof hb === "object" && "unref" in hb && typeof hb.unref === "function") hb.unref();
|
|
@@ -1111,6 +1126,7 @@ export function createOmpAdapter(pi: ExtensionHost, initial: Config, freshConfig
|
|
|
1111
1126
|
const d = checkTool(
|
|
1112
1127
|
{ tool, input, cwd, agent, agentId: id, calls: n - 1, paths: [], writes: [], command: asString(input.command), runningJobs },
|
|
1113
1128
|
cfg,
|
|
1129
|
+
defaultRunSource(cfg),
|
|
1114
1130
|
);
|
|
1115
1131
|
if (!d.allow) {
|
|
1116
1132
|
// P3b: Main refused on a protected guard file sits blocked until the owner unlocks.
|
package/src/cli/claim.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
// `neurastream claim` (plan 20261027_1300 P4): picking work across
|
|
2
|
-
// `next` claims the highest free plan in index order with the
|
|
3
|
-
// not WAITING on the owner, not waiting on another open
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
1
|
+
// `neurastream claim` (plan 20261027_1300 P4; team plans 20261027_1305 P3): picking work across
|
|
2
|
+
// several Mains over one queue. `next` claims the highest free plan in index order with the
|
|
3
|
+
// queue's own skip rules — open only, not WAITING on the owner, not waiting on another open
|
|
4
|
+
// plan (the queueSummary waits-on rule), not held by another Main or member, not on a team
|
|
5
|
+
// server that does not answer; `list` prints the live claims (the file store's list plus each
|
|
6
|
+
// team's remote list); `release <plan>` frees this Main's claim and `--force` frees another
|
|
7
|
+
// Main's or member's, refused for agents by the guard (the owner runs it in a terminal).
|
|
7
8
|
import path from "node:path";
|
|
8
|
-
import { fileClaimStore } from "../core/claims.ts";
|
|
9
|
+
import { fileClaimStore, heldByOther, type Claim, type ClaimStore } from "../core/claims.ts";
|
|
9
10
|
import { nowSec, strftime } from "../core/clock.ts";
|
|
10
11
|
import { mainId } from "../core/guards.ts";
|
|
11
12
|
import { applyQueueEnv } from "../core/queue/env.ts";
|
|
12
13
|
import { activePlans, openWaits } from "../core/queue/lib.ts";
|
|
14
|
+
import { claimStoreFor, remoteStoreFor, type TeamEntry } from "../core/team-client.ts";
|
|
13
15
|
import type { Config } from "../core/config.ts";
|
|
14
16
|
|
|
15
17
|
const USAGE = [
|
|
@@ -20,7 +22,6 @@ const USAGE = [
|
|
|
20
22
|
|
|
21
23
|
export function claimCli(args: string[], cfg: Config): number {
|
|
22
24
|
applyQueueEnv(cfg);
|
|
23
|
-
const store = fileClaimStore(cfg.paths.queue_state, nowSec, cfg.queue.claim_ttl_min);
|
|
24
25
|
const me = mainId();
|
|
25
26
|
|
|
26
27
|
if (args[0] === "next") {
|
|
@@ -30,23 +31,41 @@ export function claimCli(args: string[], cfg: Config): number {
|
|
|
30
31
|
const rank = new Map(plans.map((p, i) => [p.file, i + 1] as const));
|
|
31
32
|
for (const p of plans) {
|
|
32
33
|
if (p.status !== "open" || p.waiting || openWaits(p, plans, rank).length) continue;
|
|
34
|
+
const store = claimStoreFor(p.file, cfg);
|
|
33
35
|
const h = store.holder(p.file);
|
|
34
|
-
|
|
36
|
+
// heldByOther covers an unreachable server too: the plan is skipped either way.
|
|
37
|
+
if (h !== null && heldByOther(h, me)) continue;
|
|
35
38
|
const c = store.claim(p.file, me);
|
|
39
|
+
if ("unreachable" in c) continue;
|
|
36
40
|
if ("heldBy" in c) continue;
|
|
37
41
|
console.log(`claim: ${p.file} for Main ${me} since ${strftime(c.since, "%H:%M")}`);
|
|
38
42
|
return 0;
|
|
39
43
|
}
|
|
40
|
-
console.error("claim: no free plan (open plans are held by another Main, WAITING on the owner, or waiting on another open plan)");
|
|
44
|
+
console.error("claim: no free plan (open plans are held by another Main or their team server is unreachable, WAITING on the owner, or waiting on another open plan)");
|
|
41
45
|
return 1;
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
if (args[0] === "list") {
|
|
45
|
-
// holder() applies
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
// Each store's holder() applies its own liveness rule (claim_ttl_min), so list and next
|
|
50
|
+
// agree. A team whose list() is Unreachable prints its line and the rest still list.
|
|
51
|
+
const file = fileClaimStore(cfg.paths.queue_state, nowSec, cfg.queue.claim_ttl_min);
|
|
52
|
+
const stores: { store: ClaimStore; team?: TeamEntry }[] = [{ store: file }];
|
|
53
|
+
for (const team of cfg.teams ?? []) stores.push({ store: remoteStoreFor(team, cfg), team });
|
|
54
|
+
const live: Claim[] = [];
|
|
55
|
+
for (const { store, team } of stores) {
|
|
56
|
+
const rows = store.list();
|
|
57
|
+
if (!Array.isArray(rows)) {
|
|
58
|
+
console.error(`claim: team server ${team?.server ?? rows.unreachable} unreachable`);
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
for (const c of rows) {
|
|
62
|
+
// Compares a listed row with its own live holder, not with this Main; an
|
|
63
|
+
// Unreachable holder only drops its own row.
|
|
64
|
+
const h = store.holder(c.plan);
|
|
65
|
+
if (h !== null && !("unreachable" in h) && h.main === c.main) live.push(c);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
live.sort((a, b) => a.since - b.since || a.plan.localeCompare(b.plan));
|
|
50
69
|
if (!live.length) console.log("claim: no live claims");
|
|
51
70
|
for (const c of live) console.log(`${c.plan} — held by Main ${c.main} since ${strftime(c.since, "%H:%M")}`);
|
|
52
71
|
return 0;
|
|
@@ -60,15 +79,27 @@ export function claimCli(args: string[], cfg: Config): number {
|
|
|
60
79
|
return 2;
|
|
61
80
|
}
|
|
62
81
|
const file = path.resolve(planArg);
|
|
82
|
+
const store = claimStoreFor(file, cfg);
|
|
63
83
|
const h = store.holder(file);
|
|
64
84
|
if (!h) {
|
|
65
85
|
console.log(`claim: ${file} is free`);
|
|
66
86
|
return 0;
|
|
67
87
|
}
|
|
68
|
-
if (
|
|
69
|
-
console.error(`claim:
|
|
88
|
+
if ("unreachable" in h) {
|
|
89
|
+
console.error(`claim: team server ${h.unreachable} unreachable`);
|
|
70
90
|
return 1;
|
|
71
91
|
}
|
|
92
|
+
if (heldByOther(h, me)) {
|
|
93
|
+
if (!force) {
|
|
94
|
+
console.error(`claim: ${file} is held by Main ${h.main} since ${strftime(h.since, "%H:%M")}; freeing another Main's claim needs --force and is the owner's move, in a terminal.`);
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
if (h.mine === false) {
|
|
98
|
+
// The server would answer 403 (P2b (7c)): nothing is sent.
|
|
99
|
+
console.error(`claim: ${file} is held by another member's Main; it frees at the TTL or when the admin removes that member`);
|
|
100
|
+
return 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
72
103
|
store.release(file, h.main);
|
|
73
104
|
console.log(`claim: released ${file}${h.main !== me ? ` (held by Main ${h.main})` : ""}`);
|
|
74
105
|
return 0;
|
package/src/cli/dispatch.ts
CHANGED
|
@@ -21,7 +21,8 @@ import { runMetrics } from "./metrics.ts";
|
|
|
21
21
|
import { runPressure } from "./pressure.ts";
|
|
22
22
|
import { runIncident } from "./incident.ts";
|
|
23
23
|
import { runTraces } from "./traces.ts";
|
|
24
|
-
import {
|
|
24
|
+
import { runWorkspace } from "./workspace.ts";
|
|
25
|
+
import { runTeam } from "./team.ts";
|
|
25
26
|
import { runConfigKeys } from "./config-set.ts";
|
|
26
27
|
import { runDiagram } from "./diagram.ts";
|
|
27
28
|
import { runNotes } from "./notes.ts";
|
|
@@ -93,7 +94,7 @@ export function helpText(): string {
|
|
|
93
94
|
" move a listed plan to rank N; the index file itself is 0444,",
|
|
94
95
|
" these two commands are the only agent writes to it",
|
|
95
96
|
" neurastream config [--json] print the merged config (defaults + file + env)",
|
|
96
|
-
" neurastream config set|get|list <key> [value] read or write one key (
|
|
97
|
+
" neurastream config set|get|list <key> [value] read or write one key (workspace.port, paths.work_roots, ...)",
|
|
97
98
|
" neurastream wip add|remove|list [path] add or remove a root in wip.roots, or list them",
|
|
98
99
|
" neurastream wip on [--backup-url <url>]|off hourly snapshot (+ nightly private backup) on or off",
|
|
99
100
|
" neurastream wip restore [<worktree>] [--pick N] list the hidden saves, or put one back",
|
|
@@ -129,11 +130,24 @@ export function helpText(): string {
|
|
|
129
130
|
" count the run's wasted tool calls (same file re-read, failed",
|
|
130
131
|
" command rerun, failed edit, repeated guard block, idle poll):",
|
|
131
132
|
" calls, wasted, waste % and the count per waste rule",
|
|
132
|
-
" neurastream
|
|
133
|
-
" neurastream
|
|
134
|
-
" one go: writes
|
|
135
|
-
" installs and restarts the neurastream-
|
|
136
|
-
"
|
|
133
|
+
" neurastream workspace serve the owner's phone page on the tailnet address (workspace.enabled, workspace.owner_login)",
|
|
134
|
+
" neurastream workspace on --login <tailscale login> [--port N]",
|
|
135
|
+
" one go: writes workspace.enabled/owner_login (and port) into the config,",
|
|
136
|
+
" installs and restarts the neurastream-workspace user unit (disabling",
|
|
137
|
+
" the old neurastream-ui unit), prints the phone link;",
|
|
138
|
+
" `neurastream workspace off` stops and disables it, sets enabled: false",
|
|
139
|
+
" neurastream workspace on --team <name> --admin <tailscale login> --repo <glob>... [--port N]",
|
|
140
|
+
" set up one team's queue server on the tailnet (its own user unit);",
|
|
141
|
+
" `neurastream workspace off --team <name>` undoes that team only;",
|
|
142
|
+
" neurastream workspace members add|remove <login> --team <name> | members list --team <name>",
|
|
143
|
+
" neurastream team share <plan> add Queue: team when the repo's origin matches a teams: glob",
|
|
144
|
+
" neurastream team unshare <plan>",
|
|
145
|
+
" remove Queue: team (only while you hold the claim, or it is free)",
|
|
146
|
+
" neurastream team sync [--team <name>] pull and push team plans (no hook and no heartbeat runs it)",
|
|
147
|
+
" neurastream team join <url> --name <name> --repo <glob>...",
|
|
148
|
+
" add a teams: entry; asks the server for its view first and writes nothing",
|
|
149
|
+
" if it does not answer this login",
|
|
150
|
+
" neurastream team leave <name> remove that teams: entry",
|
|
137
151
|
" neurastream pages on|off|serve|publish|list host static files over the tailnet",
|
|
138
152
|
" publish --plan <plan.md> adds the Approve bar that records the plan's approval",
|
|
139
153
|
" neurastream notes check <page> list the notes without an answer, exit 1 while any is open",
|
|
@@ -162,7 +176,8 @@ export async function run(cmd: string, args: string[]): Promise<number> {
|
|
|
162
176
|
if (cmd === "traces") return runTraces(args);
|
|
163
177
|
if (cmd === "labels") return runLabels(args);
|
|
164
178
|
if (cmd === "diff-check") return runDiffCheck(args);
|
|
165
|
-
if (cmd === "
|
|
179
|
+
if (cmd === "workspace") return runWorkspace(args);
|
|
180
|
+
if (cmd === "team") return runTeam(args);
|
|
166
181
|
if (cmd === "pages") return runPages(args);
|
|
167
182
|
if (cmd === "notes") return runNotes(args);
|
|
168
183
|
if (cmd === "diagram") return runDiagram(args);
|
package/src/cli/setup.ts
CHANGED
|
@@ -96,7 +96,7 @@ const GROUPS: { name: string; keys: string[] }[] = [
|
|
|
96
96
|
{ name: "Paths", keys: ["paths.work_roots"] },
|
|
97
97
|
{ name: "Harness", keys: ["harness"] },
|
|
98
98
|
{ name: "Autonomy", keys: ["autonomy.tier", "autonomy.planner", "autonomy.strict_edit_limit", "autonomy.go_minutes", "autonomy.go_phrase"] },
|
|
99
|
-
{ name: "Phone page", keys: ["
|
|
99
|
+
{ name: "Phone page", keys: ["workspace.enabled", "workspace.owner_login"] },
|
|
100
100
|
{ name: "Static pages", keys: ["pages.enabled", "pages.port", "pages.dir"] },
|
|
101
101
|
{ name: "Notify", keys: ["notify.discord_webhook_file", "notify.slack_webhook_file"] },
|
|
102
102
|
{ name: "Secrets", keys: ["secrets.redact", "secrets.known_value_files", "secrets.proxy"] },
|
|
@@ -204,10 +204,10 @@ function runGroup(ctx: Ctx, name: string, keys: string[]): number {
|
|
|
204
204
|
const picks: Record<string, unknown> = {};
|
|
205
205
|
const asking = ctx.auto === "none";
|
|
206
206
|
for (const key of keys) {
|
|
207
|
-
if (key === "
|
|
207
|
+
if (key === "workspace.owner_login" && picks["workspace.enabled"] !== true) continue;
|
|
208
208
|
const proposed = proposal(ctx, key, valueAt(now, key));
|
|
209
209
|
let value = askKey(ctx, key, kindOf(key), proposed);
|
|
210
|
-
if (key === "
|
|
210
|
+
if (key === "workspace.enabled" && value === true && !phoneReady(ctx)) value = false;
|
|
211
211
|
picks[key] = value;
|
|
212
212
|
}
|
|
213
213
|
if (asking && Object.keys(picks).some((key) => key.startsWith("notify.") && picks[key] !== "")) {
|