@staix/agent-hub 0.38.0 → 0.40.0
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/CHANGELOG.md +84 -0
- package/README.md +28 -12
- package/docs/adding-an-ai-tool.md +7 -5
- package/docs/agent-notes/README.md +23 -0
- package/docs/agent-notes/adapters.md +9 -5
- package/docs/agent-notes/benchmarks.md +2 -0
- package/docs/agent-notes/budget.md +9 -0
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +21 -9
- package/docs/agent-notes/local-worker.md +4 -2
- package/docs/agent-notes/security-review.md +56 -0
- package/docs/agent-notes/tasks.md +22 -6
- package/docs/agent-notes/tests.md +10 -9
- package/docs/contracts/companion-cli-v1.json +4 -0
- package/docs/design/adapters.md +142 -0
- package/docs/design/agent-hub-architecture.md +46 -1
- package/docs/design/agent-hub.md +10 -0
- package/docs/design/bus.md +7 -0
- package/docs/design/cli-output.md +183 -0
- package/docs/design/execution-reference.md +6 -1
- package/docs/design/roadmap.md +191 -0
- package/docs/design/task-board.md +185 -5
- package/docs/dogfood.md +30 -9
- package/docs/events.md +7 -7
- package/docs/memory.md +5 -5
- package/docs/operations.md +315 -54
- package/docs/profiles.md +101 -8
- package/docs/quickstart.md +47 -6
- package/docs/research.md +6 -3
- package/docs/roles.md +52 -0
- package/docs/sdlc.md +190 -2
- package/docs/security.md +90 -15
- package/docs/text-projection.md +1 -0
- package/docs/verification/2026-11-13-claude-implementer-2.1.323.md +59 -0
- package/docs/verification/2026-11-13-codex-01672-reviewer-isolation.md +69 -0
- package/docs/verification/2026-11-14-0.39.0.md +51 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-isolation.md +70 -0
- package/docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md +48 -0
- package/docs/verification/2026-11-14-pi-152-compat.md +45 -0
- package/docs/verification/2026-11-15-0.40.0.md +39 -0
- package/docs/verification/2026-11-16-pi-loopback-1447.md +39 -0
- package/docs/verification/pi-152-model-free.ts +57 -0
- package/docs/verification/pi-152-native.mjs +21 -0
- package/docs/verified.json +48 -25
- package/package.json +4 -4
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +2266 -530
- package/plugins/agent-hub/kimi-review-policy-worker.js +16 -11
- package/plugins/agent-hub/server.js +2423 -645
- package/src/adapters/acp-model-policy.ts +1 -1
- package/src/adapters/acp-session-model.ts +35 -0
- package/src/adapters/acp.ts +14 -0
- package/src/adapters/agy/definition.ts +2 -2
- package/src/adapters/agy/hooks.ts +7 -0
- package/src/adapters/claude-channel.ts +1 -1
- package/src/adapters/claude-implementer.ts +8 -0
- package/src/adapters/claude-print-child.ts +26 -2
- package/src/adapters/claude-print.ts +4 -0
- package/src/adapters/codex-appserver.ts +90 -16
- package/src/adapters/codex-review-isolation.ts +63 -17
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/conformance/fakes/acp-server.ts +11 -2
- package/src/adapters/conformance/fakes/app-server.ts +5 -1
- package/src/adapters/conformance/fakes/pi-rpc.ts +1 -1
- package/src/adapters/definitions/builtin-metadata.ts +12 -12
- package/src/adapters/definitions/native-cli-jcode-mcp.ts +18 -3
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-config-policy.ts +1 -1
- package/src/adapters/definitions/native-quota.ts +122 -0
- package/src/adapters/definitions/native-recovery.ts +3 -0
- package/src/adapters/definitions/qwen.ts +2 -2
- package/src/adapters/kimi-review.ts +23 -0
- package/src/adapters/kimi-wire-usage.ts +39 -16
- package/src/adapters/local-worker.ts +9 -4
- package/src/adapters/pi-state-model.ts +12 -0
- package/src/adapters/pi.ts +76 -11
- package/src/adapters/print-result-model.ts +24 -0
- package/src/adapters/registry-types.ts +12 -2
- package/src/adapters/registry.ts +19 -2
- package/src/adapters/reviewer-print.ts +132 -16
- package/src/adapters/role-eligibility.ts +99 -0
- package/src/adapters/same-directory.ts +16 -0
- package/src/cli/agy-mcp.ts +18 -7
- package/src/cli/answer-args.ts +11 -3
- package/src/cli/console-question.ts +1 -1
- package/src/cli/console-state.ts +98 -11
- package/src/cli/console.ts +6 -2
- package/src/cli/error-format.ts +19 -0
- package/src/cli/free-text.ts +20 -0
- package/src/cli/handoff-args.ts +1 -1
- package/src/cli/help.ts +350 -30
- package/src/cli/identity-audit.ts +8 -7
- package/src/cli/identity.ts +27 -4
- package/src/cli/init-prompt.ts +31 -2
- package/src/cli/init-roles.ts +156 -0
- package/src/cli/init-settings.ts +24 -2
- package/src/cli/init.ts +232 -17
- package/src/cli/main.js +2 -2
- package/src/cli/main.ts +250 -69
- package/src/cli/model.ts +1 -1
- package/src/cli/output-standard.ts +56 -0
- package/src/cli/output.ts +199 -9
- package/src/cli/preview.ts +1 -1
- package/src/cli/recovery-launch.ts +114 -0
- package/src/cli/recovery-package.ts +14 -7
- package/src/cli/recovery-version-preflight.ts +104 -0
- package/src/cli/roadmap.ts +215 -0
- package/src/cli/role-doctor.ts +39 -0
- package/src/cli/sdlc-output.ts +66 -1
- package/src/cli/smoke-pty-bridge.ts +7 -24
- package/src/cli/study-output.ts +54 -0
- package/src/cli/study.ts +14 -1
- package/src/cli/task-output.ts +3 -1
- package/src/cli/terminal-recovery.ts +14 -0
- package/src/cli/upgrade-presentation-flags.ts +2 -2
- package/src/cli/upgrade-presentation.ts +4 -0
- package/src/cli/upgrade-restore-state.ts +12 -3
- package/src/cli/upgrade-runtime.ts +40 -2
- package/src/cli/upgrade.ts +8 -4
- package/src/hub/advisor-survey.ts +139 -0
- package/src/hub/audit-source.ts +66 -0
- package/src/hub/board.ts +677 -15
- package/src/hub/budget.ts +54 -4
- package/src/hub/bus.ts +9 -0
- package/src/hub/check-runner.ts +3 -4
- package/src/hub/ci-watch.ts +19 -4
- package/src/hub/conductor.ts +14 -8
- package/src/hub/config-apply.ts +2 -1
- package/src/hub/config-edit-host.ts +77 -5
- package/src/hub/considered-findings.ts +47 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +585 -98
- package/src/hub/deliverable-files.ts +17 -1
- package/src/hub/dogfood-profile.ts +3 -2
- package/src/hub/events.ts +25 -4
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/folder-trigger.ts +11 -4
- package/src/hub/github-import.ts +81 -0
- package/src/hub/hub-tools.ts +117 -20
- package/src/hub/install-policy.ts +23 -0
- package/src/hub/kimi-usage.ts +34 -2
- package/src/hub/lifecycle-schema.ts +3 -3
- package/src/hub/memory-profile.ts +9 -1
- package/src/hub/memory-sync-state.ts +1 -0
- package/src/hub/model-overrides.ts +2 -1
- package/src/hub/no-writes.ts +5 -0
- package/src/hub/operational-authority.ts +8 -1
- package/src/hub/operational-view.ts +6 -2
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-failure.ts +7 -0
- package/src/hub/plan-conformance.ts +20 -2
- package/src/hub/question-desk.ts +26 -7
- package/src/hub/questions.ts +33 -5
- package/src/hub/quota-account.ts +34 -0
- package/src/hub/recovery-policy.ts +18 -4
- package/src/hub/research-evidence.ts +51 -3
- package/src/hub/research.ts +77 -13
- package/src/hub/restart.ts +21 -0
- package/src/hub/review-budget.ts +88 -0
- package/src/hub/review-findings.ts +93 -12
- package/src/hub/reviewer-pool-config.ts +6 -2
- package/src/hub/reviewer-pool.ts +39 -6
- package/src/hub/roadmap-triage.ts +86 -0
- package/src/hub/roadmap-unplaced.ts +169 -0
- package/src/hub/roadmap-view.ts +83 -0
- package/src/hub/roadmap.ts +127 -0
- package/src/hub/routing.ts +7 -3
- package/src/hub/sdlc-merge.ts +6 -5
- package/src/hub/sdlc-queue.ts +17 -7
- package/src/hub/sdlc-release.ts +1 -1
- package/src/hub/sdlc.ts +47 -8
- package/src/hub/security-audit.ts +178 -0
- package/src/hub/security-pass.ts +115 -0
- package/src/hub/settings.ts +11 -5
- package/src/hub/source-read.ts +80 -2
- package/src/hub/sources.ts +57 -9
- package/src/hub/specs-task.ts +7 -0
- package/src/hub/startup-event-seeds.ts +5 -3
- package/src/hub/startup-timing.ts +1 -0
- package/src/hub/synthesis-readiness.ts +279 -0
- package/src/hub/task-sweep.ts +29 -2
- package/src/hub/task-worktree.ts +37 -0
- package/src/hub/tasks.ts +1464 -76
- package/src/hub/text-projection.ts +11 -1
- package/src/memory/capture.ts +2 -1
- package/src/pi/dependency-publish.ts +50 -0
- package/src/pi/extension.ts +1 -1
- package/src/pi/launch.ts +1 -1
- package/src/pi/task-dependencies.ts +249 -0
- package/src/ui/index.html +56 -13
- package/src/ui/office-model.ts +11 -3
- package/src/ui/office-space.ts +50 -30
- package/src/ui/plugin-questions.ts +5 -0
- package/src/ui/plugin.ts +27 -12
- package/templates/config.json +1 -1
|
@@ -10,7 +10,8 @@ import { profile, sandboxAvailable } from "../local/sandbox.ts";
|
|
|
10
10
|
export type ProjectionConfig = Record<string, string[]>;
|
|
11
11
|
const EMPTY_ROOT = "/var/empty";
|
|
12
12
|
export const MAX_PROJECTION_INPUT = 16 * 1024 * 1024;
|
|
13
|
-
const
|
|
13
|
+
export const MAX_PROJECTION_TEXT = 256 * 1024;
|
|
14
|
+
const MAX_INPUT = MAX_PROJECTION_INPUT, MAX_TEXT = MAX_PROJECTION_TEXT;
|
|
14
15
|
/** Only machine-local config chooses programs; no implicit shell or command-string parsing. */
|
|
15
16
|
export function projectionConfig(raw: unknown): ProjectionConfig {
|
|
16
17
|
if (raw === undefined) return {};
|
|
@@ -67,6 +68,15 @@ export class TextProjections {
|
|
|
67
68
|
}
|
|
68
69
|
get enabled(): boolean { return Object.keys(this.options.config).length > 0; }
|
|
69
70
|
handles(file: string): boolean { return !!this.options.config[extname(file).toLowerCase()]; }
|
|
71
|
+
/** Current configured converter identity, without reading a source or running conversion. */
|
|
72
|
+
fingerprint(file: string): string | undefined {
|
|
73
|
+
const argv = this.options.config[extname(file).toLowerCase()];
|
|
74
|
+
if (!argv) return undefined;
|
|
75
|
+
try {
|
|
76
|
+
const commandHash = commandFingerprint(this.options.cwd, argv);
|
|
77
|
+
return this.options.projectRoot === undefined ? commandHash : hash(commandHash + "\nproject-root:" + realPath(this.options.projectRoot));
|
|
78
|
+
} catch { return undefined; }
|
|
79
|
+
}
|
|
70
80
|
project(file: string): ProjectedText | undefined {
|
|
71
81
|
const ext = extname(file).toLowerCase(), argv = this.options.config[ext];
|
|
72
82
|
if (!argv) return undefined;
|
package/src/memory/capture.ts
CHANGED
|
@@ -40,7 +40,8 @@ export class Capture {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
observe(call: { tool: string; args: string; output: string; id: string; paths: string[]; sourceId?: string }): void {
|
|
43
|
-
if (
|
|
43
|
+
if (call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_survey_report") return;
|
|
44
|
+
if (!this.sessionId || GUIDANCE_TOOL_NAMES.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_audit_report" || LINEAGE_TOOL_NAMES.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || reviewCaptureExcluded(call.tool, call.args) || ((MEMORY_READ_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || BOUNDED_TASK_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || CAPABILITY_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || STUDY_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, "")) || HANDOFF_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, ""))) || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_memory_correct") || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_source_read" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_set_title" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_evidence_read" || call.tool.replace(/^mcp__[^ ]+__/, "") === "hub_evidence_record" || this.opts.skip?.includes(call.tool)) return;
|
|
44
45
|
// #1053: a question and its answer are the person's and the peer's words: never memory evidence, whatever the call's paths say.
|
|
45
46
|
if (QUESTION_TOOLS.has(call.tool.replace(/^mcp__[^ ]+__/, ""))) return;
|
|
46
47
|
// Anything that names a denylisted path is kept out of memory entirely, input and output alike.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { stopOwnedProcess, trackGroup } from "../hub/child-process.ts";
|
|
5
|
+
import { realPath } from "../hub/project.ts";
|
|
6
|
+
|
|
7
|
+
export interface DependencyPublishTarget { cwd: string; dev: number; ino: number; timeoutMs: number }
|
|
8
|
+
|
|
9
|
+
// CWD is a kernel-held directory reference. Verify it after spawn, then use a relative
|
|
10
|
+
// destination so replacing an ancestor path cannot redirect this host write elsewhere.
|
|
11
|
+
const PUBLISH = `
|
|
12
|
+
import {lstatSync,renameSync,statSync} from "node:fs";
|
|
13
|
+
try {
|
|
14
|
+
const [source,device,inode]=Bun.argv.slice(2);
|
|
15
|
+
const cwd=statSync(".");
|
|
16
|
+
if(String(cwd.dev)!==device||String(cwd.ino)!==inode)throw new Error("worktree changed");
|
|
17
|
+
try{lstatSync("node_modules");throw new Error("target exists")}catch(error){if(error.code!=="ENOENT")throw error}
|
|
18
|
+
const input=lstatSync(source);
|
|
19
|
+
if(!input.isDirectory()||input.isSymbolicLink()||input.dev!==cwd.dev)throw new Error("unsupported publication");
|
|
20
|
+
renameSync(source,"node_modules");
|
|
21
|
+
const output=lstatSync("node_modules");
|
|
22
|
+
if(!output.isDirectory()||output.dev!==input.dev||output.ino!==input.ino)throw new Error("publication changed");
|
|
23
|
+
}catch{process.exitCode=1}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
/** Trusted host helper only. No project configuration or inherited environment is loaded. */
|
|
27
|
+
export async function publishPiDependencies(source: string, target: DependencyPublishTarget, current: () => boolean): Promise<boolean> {
|
|
28
|
+
if (!current() || !Number.isSafeInteger(target.dev) || !Number.isSafeInteger(target.ino) || !(target.timeoutMs > 0)) return false;
|
|
29
|
+
const privateRoot = dirname(source), config = join(privateRoot, ".hub-publish-bunfig.toml"), home = join(privateRoot, ".hub-publish-home"), script = join(privateRoot, ".hub-publish.ts");
|
|
30
|
+
try {
|
|
31
|
+
writeFileSync(config, "", { flag: "wx", mode: 0o600 }); mkdirSync(home, { mode: 0o700 });
|
|
32
|
+
writeFileSync(script, PUBLISH, { flag: "wx", mode: 0o600 });
|
|
33
|
+
const executable = realPath(process.execPath);
|
|
34
|
+
return await new Promise<boolean>(resolve => {
|
|
35
|
+
const child = spawn(executable, ["--no-env-file", `--config=${config}`, script, source, String(target.dev), String(target.ino)], {
|
|
36
|
+
cwd: target.cwd, env: { HOME: home }, detached: true, stdio: "ignore",
|
|
37
|
+
});
|
|
38
|
+
trackGroup(child);
|
|
39
|
+
let settled = false;
|
|
40
|
+
const finish = async (ok: boolean) => {
|
|
41
|
+
if (settled) return; settled = true; clearTimeout(timer);
|
|
42
|
+
if (!ok) { try { await stopOwnedProcess(child, { group: true }); } catch { /* No success is certified after uncertain teardown. */ } }
|
|
43
|
+
resolve(ok && current());
|
|
44
|
+
};
|
|
45
|
+
const timer = setTimeout(() => { void finish(false); }, target.timeoutMs);
|
|
46
|
+
child.once("error", () => { void finish(false); });
|
|
47
|
+
child.once("close", code => { void finish(code === 0); });
|
|
48
|
+
});
|
|
49
|
+
} catch { return false; }
|
|
50
|
+
}
|
package/src/pi/extension.ts
CHANGED
|
@@ -28,7 +28,7 @@ let titleEpoch = "";
|
|
|
28
28
|
let pendingPromptId: string | undefined;
|
|
29
29
|
let activePromptId: string | undefined;
|
|
30
30
|
let settlement: Promise<void> | undefined;
|
|
31
|
-
const maxSteps = Number(process.env.AGENTHUB_PI_MAX_STEPS ??
|
|
31
|
+
const maxSteps = Number(process.env.AGENTHUB_PI_MAX_STEPS ?? 100);
|
|
32
32
|
let shutdown: (() => void) | undefined;
|
|
33
33
|
let runtimeCtx: any;
|
|
34
34
|
let modelRegistry: any;
|
package/src/pi/launch.ts
CHANGED
|
@@ -15,7 +15,7 @@ const modelFor = (backend: PiOptions["backend"], models: PiModelDescriptor[]): s
|
|
|
15
15
|
/** Pure native launch; bridge/relay setup and session validation remain with the adapter. */
|
|
16
16
|
export function buildPiLaunch(opts: Pick<PiOptions, "stateDir" | "hubStateDir" | "cmd" | "mode" | "backend" | "model" | "relay" | "tools" | "preamble" | "maxSteps" | "sessionFile" | "sessionId"> & { instance?: string }, inherited: NodeJS.ProcessEnv, extension: string, bridgePort: number | string, bridgeToken: string): PiTuiLaunch {
|
|
17
17
|
const adapter = ADAPTERS.find(adapter => adapter.start.daemonPort === "pi-rpc")!;
|
|
18
|
-
const env: NodeJS.ProcessEnv = { ...peerChildEnv(opts.instance ?? adapter.kind, inherited), ...(opts.hubStateDir !== undefined ? { AGENTHUB_STATE_DIR: opts.hubStateDir } : {}), PI_CODING_AGENT_DIR: join(opts.stateDir, "pi"), AGENTHUB_PI_BRIDGE_URL: `http://127.0.0.1:${bridgePort}`, AGENTHUB_PI_BRIDGE_TOKEN: bridgeToken, AGENTHUB_PI_OWNER_TOKEN: bridgeToken, AGENTHUB_PI_RELAY_URL: opts.relay.url, AGENTHUB_PI_RELAY_TOKEN: opts.relay.token, AGENTHUB_PI_MODELS: JSON.stringify(opts.relay.models), AGENTHUB_PI_TOOLS: JSON.stringify(opts.tools), AGENTHUB_PI_MAX_STEPS: String(opts.maxSteps ??
|
|
18
|
+
const env: NodeJS.ProcessEnv = { ...peerChildEnv(opts.instance ?? adapter.kind, inherited), ...(opts.hubStateDir !== undefined ? { AGENTHUB_STATE_DIR: opts.hubStateDir } : {}), PI_CODING_AGENT_DIR: join(opts.stateDir, "pi"), AGENTHUB_PI_BRIDGE_URL: `http://127.0.0.1:${bridgePort}`, AGENTHUB_PI_BRIDGE_TOKEN: bridgeToken, AGENTHUB_PI_OWNER_TOKEN: bridgeToken, AGENTHUB_PI_RELAY_URL: opts.relay.url, AGENTHUB_PI_RELAY_TOKEN: opts.relay.token, AGENTHUB_PI_MODELS: JSON.stringify(opts.relay.models), AGENTHUB_PI_TOOLS: JSON.stringify(opts.tools), AGENTHUB_PI_MAX_STEPS: String(opts.maxSteps ?? 100) };
|
|
19
19
|
const args = [ ...(opts.mode === "headless" ? ["--mode", "rpc"] : []), "--provider", "agent-hub-local", "--model", opts.model ?? modelFor(opts.backend, opts.relay.models), "--models", opts.relay.models.map((model) => `agent-hub-local/${model.id}`).join(","), "--no-builtin-tools", "--no-skills", "--no-prompt-templates", "--no-extensions", "--extension", extension, ...(opts.preamble ? ["--append-system-prompt", opts.preamble] : []), "--session-dir", join(opts.stateDir, "pi-sessions")];
|
|
20
20
|
if (opts.sessionFile) args.push("--session", opts.sessionFile); else if (opts.sessionId) args.push("--session-id", opts.sessionId);
|
|
21
21
|
const command = opts.cmd ?? [adapter.cli.command];
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { constants, fstatSync, lstatSync, mkdtempSync, rmSync } from "node:fs";
|
|
4
|
+
import { lstat, mkdir, opendir, open, stat, writeFile, type FileHandle } from "node:fs/promises";
|
|
5
|
+
import { homedir, tmpdir } from "node:os";
|
|
6
|
+
import { dirname, isAbsolute, join, posix } from "node:path";
|
|
7
|
+
import { realPath } from "../hub/project.ts";
|
|
8
|
+
import { stopOwnedProcess, trackGroup } from "../hub/child-process.ts";
|
|
9
|
+
import { InstallPolicyError, parseInstallManifest } from "../hub/install-policy.ts";
|
|
10
|
+
import { hubGitEnv, hubGitSync } from "../hub/git.ts";
|
|
11
|
+
|
|
12
|
+
export const PI_DEPENDENCY_TIMEOUT_MS = 15_000;
|
|
13
|
+
/** Safety ceiling on every traversed directory entry, excluding the contents of Git and installed modules. */
|
|
14
|
+
export const PI_DEPENDENCY_ENTRY_LIMIT = 10_000;
|
|
15
|
+
export const PI_DEPENDENCY_MANIFEST_BYTES = 64 * 1024;
|
|
16
|
+
export const PI_DEPENDENCY_INPUT_BYTES = 4 * 1024 * 1024;
|
|
17
|
+
export const PI_DEPENDENCY_SNAPSHOT_BYTES = 16 * 1024 * 1024;
|
|
18
|
+
export type DependencyPreparation = { ready: true } | { ready: false; reason: "missing bun.lock" | "lifecycle script" | "invalid manifest" | "task changed" | "installer unavailable" | "install failed" | "install timed out" | "staging unavailable" | "node_modules exists" | "unsupported workspace layout" | "unsupported dependency layout" | "different filesystem" | "install inputs changed in task" | "unsupported install inputs" };
|
|
19
|
+
type DependencyReason = Exclude<DependencyPreparation, { ready: true }>["reason"];
|
|
20
|
+
export interface DependencyInstallRequest {
|
|
21
|
+
executable: string; args: readonly ["install", "--frozen-lockfile"]; cwd: string;
|
|
22
|
+
env: { HOME: string; BUN_INSTALL_CACHE_DIR: string }; timeoutMs: number;
|
|
23
|
+
}
|
|
24
|
+
export type DependencyRunner = (request: DependencyInstallRequest) => Promise<{ code: number | null; timedOut?: boolean }>;
|
|
25
|
+
export interface DependencyPublishTarget { cwd: string; dev: number; ino: number; timeoutMs: number }
|
|
26
|
+
/** Host-owned test/authority seams only; never populated from peer tool arguments or project config. */
|
|
27
|
+
export interface PiDependencyOptions {
|
|
28
|
+
/** Trusted TaskWorktrees record and original repository; never supplied by a peer. */
|
|
29
|
+
base?: string; repositoryRoot?: string;
|
|
30
|
+
/** Parent attests this is hub-owned state denied to the entire peer sandbox, not sibling .worktrees space. */
|
|
31
|
+
stagingParent?: string;
|
|
32
|
+
/** Host publisher must pin CWD to this held identity; absolute target-path rename is not a safe implementation. */
|
|
33
|
+
publish?: (source: string, target: DependencyPublishTarget, current: () => boolean) => Promise<boolean>;
|
|
34
|
+
current?: () => boolean; run?: DependencyRunner; now?: () => number;
|
|
35
|
+
}
|
|
36
|
+
class PreparationStopped extends Error {
|
|
37
|
+
constructor(readonly reason: DependencyReason) { super(reason); }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const install: DependencyRunner = request => new Promise(resolve => {
|
|
41
|
+
const child = spawn(request.executable, [...request.args], { cwd: request.cwd, env: request.env, detached: true, stdio: "ignore" });
|
|
42
|
+
trackGroup(child);
|
|
43
|
+
let settling = false;
|
|
44
|
+
const finish = async (code: number | null, timedOut = false) => {
|
|
45
|
+
if (settling) return; settling = true; clearTimeout(timer);
|
|
46
|
+
try { await stopOwnedProcess(child, { group: true }); resolve({ code, ...(timedOut ? { timedOut: true } : {}) }); }
|
|
47
|
+
catch { resolve({ code: null, ...(timedOut ? { timedOut: true } : {}) }); }
|
|
48
|
+
};
|
|
49
|
+
const timer = setTimeout(() => { void finish(null, true); }, request.timeoutMs);
|
|
50
|
+
child.once("error", () => { void finish(null); });
|
|
51
|
+
child.once("close", code => { void finish(code); });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/** Prepare only this worktree. Failure is advisory; acceptance authority remains entirely with Tasks. */
|
|
55
|
+
export async function preparePiDependencies(cwd: string, options: PiDependencyOptions = {}): Promise<DependencyPreparation> {
|
|
56
|
+
let home: string | undefined, staging: string | undefined, root: string | undefined, rootFd: FileHandle | undefined;
|
|
57
|
+
const now = options.now ?? (() => performance.now()), deadline = now() + PI_DEPENDENCY_TIMEOUT_MS;
|
|
58
|
+
const current = () => { try { return options.current?.() !== false; } catch { return false; } };
|
|
59
|
+
const check = () => {
|
|
60
|
+
if (!current()) throw new PreparationStopped("task changed");
|
|
61
|
+
if (now() >= deadline) throw new PreparationStopped("install timed out");
|
|
62
|
+
if (rootFd && root) {
|
|
63
|
+
try {
|
|
64
|
+
const held = fstatSync(rootFd.fd), actual = lstatSync(root);
|
|
65
|
+
if (!actual.isDirectory() || actual.isSymbolicLink() || held.dev !== actual.dev || held.ino !== actual.ino) throw new Error("changed");
|
|
66
|
+
} catch { throw new PreparationStopped("task changed"); }
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const input = (name: string) => /(?:^|\/)(?:package\.json|bun\.lock|bunfig\.toml|\.npmrc)$|(?:^|\/)patches\//.test(name);
|
|
70
|
+
const excluded = (name: string) => name.split("/").some(part => part.toLowerCase() === ".git" || part === "node_modules");
|
|
71
|
+
const hash = (data: Uint8Array) => createHash("sha256").update(data).digest("hex");
|
|
72
|
+
const byteLimit = (name: string) => name.endsWith("package.json") || name.endsWith("bunfig.toml") || name.endsWith(".npmrc") ? PI_DEPENDENCY_MANIFEST_BYTES : PI_DEPENDENCY_INPUT_BYTES;
|
|
73
|
+
const fail = (reason: DependencyReason): never => { throw new PreparationStopped(reason); };
|
|
74
|
+
try {
|
|
75
|
+
check(); root = realPath(cwd);
|
|
76
|
+
if (root !== cwd) return { ready: false, reason: "task changed" };
|
|
77
|
+
if (!options.base || !/^[0-9a-f]{40}$/.test(options.base) || !options.repositoryRoot) return { ready: false, reason: "unsupported install inputs" };
|
|
78
|
+
if (!options.stagingParent) return { ready: false, reason: "staging unavailable" };
|
|
79
|
+
const repository = realPath(options.repositoryRoot), parent = realPath(options.stagingParent);
|
|
80
|
+
rootFd = await open(root, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW); check();
|
|
81
|
+
const target = join(root, "node_modules");
|
|
82
|
+
const targetAbsent = async () => {
|
|
83
|
+
try { await lstat(target); check(); fail("node_modules exists"); }
|
|
84
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error; check(); }
|
|
85
|
+
};
|
|
86
|
+
await targetAbsent();
|
|
87
|
+
staging = mkdtempSync(join(parent, "pi-dependencies-")); staging = realPath(staging);
|
|
88
|
+
const rootInfo = await rootFd.stat(), stagedInfo = await lstat(staging); check();
|
|
89
|
+
if (rootInfo.dev !== stagedInfo.dev) return { ready: false, reason: "different filesystem" };
|
|
90
|
+
const git = (args: string[], limit: number): Buffer => {
|
|
91
|
+
check();
|
|
92
|
+
const timeout = Math.ceil(deadline - now()); if (timeout <= 0) fail("install timed out");
|
|
93
|
+
const result = hubGitSync(["-C", repository, ...args], { env: hubGitEnv({}, { repositoryIsolation: true }), timeout, maxBuffer: limit });
|
|
94
|
+
check(); if (result.error || result.status !== 0) fail("unsupported install inputs");
|
|
95
|
+
const data = typeof result.stdout === "string" ? Buffer.from(result.stdout, "utf8") : Buffer.from(result.stdout ?? []);
|
|
96
|
+
if (data.length > limit) fail("unsupported install inputs"); return data;
|
|
97
|
+
};
|
|
98
|
+
const paths = new Map<string, string>();
|
|
99
|
+
const tree = git(["ls-tree", "-r", "-z", "--full-tree", options.base], PI_DEPENDENCY_SNAPSHOT_BYTES).toString("utf8");
|
|
100
|
+
let count = 0;
|
|
101
|
+
for (const entry of tree.split("\0").filter(Boolean)) {
|
|
102
|
+
if (++count > PI_DEPENDENCY_ENTRY_LIMIT) fail("unsupported install inputs");
|
|
103
|
+
const match = /^([0-7]{6}) (blob|commit) ([0-9a-f]{40})\t([\s\S]+)$/.exec(entry);
|
|
104
|
+
if (!match) fail("unsupported install inputs");
|
|
105
|
+
const name = match![4]!;
|
|
106
|
+
if (excluded(name) || !input(name)) continue;
|
|
107
|
+
if (isAbsolute(name) || name.split("/").some(part => !part || part === "." || part === "..") || match![1] === "120000" || match![2] !== "blob") fail("unsupported install inputs");
|
|
108
|
+
paths.set(name, match![3]!);
|
|
109
|
+
}
|
|
110
|
+
if (!paths.has("bun.lock")) return { ready: false, reason: "missing bun.lock" };
|
|
111
|
+
if (!paths.has("package.json")) return { ready: false, reason: "invalid manifest" };
|
|
112
|
+
let bytes = 0;
|
|
113
|
+
for (const [name, oid] of paths) {
|
|
114
|
+
const data = git(["cat-file", "blob", oid], byteLimit(name) + 1);
|
|
115
|
+
if (data.length > byteLimit(name) || (bytes += data.length) > PI_DEPENDENCY_SNAPSHOT_BYTES) return { ready: false, reason: "invalid manifest" };
|
|
116
|
+
const destination = join(staging, name); await mkdir(dirname(destination), { recursive: true }); check();
|
|
117
|
+
await writeFile(destination, data, { flag: "wx", mode: 0o600 }); check();
|
|
118
|
+
}
|
|
119
|
+
const readBounded = async (file: string, limit: number): Promise<Buffer> => {
|
|
120
|
+
const fd = await open(file, constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
121
|
+
try {
|
|
122
|
+
check(); const info = await fd.stat(); check();
|
|
123
|
+
if (!info.isFile()) throw new InstallPolicyError("invalid manifest");
|
|
124
|
+
const data = Buffer.alloc(limit + 1); let used = 0;
|
|
125
|
+
while (used < data.length) {
|
|
126
|
+
const { bytesRead } = await fd.read(data, used, data.length - used, used); check();
|
|
127
|
+
if (!bytesRead) break; used += bytesRead;
|
|
128
|
+
}
|
|
129
|
+
if (used > limit) throw new InstallPolicyError("invalid manifest");
|
|
130
|
+
return data.subarray(0, used);
|
|
131
|
+
} finally { await fd.close(); }
|
|
132
|
+
};
|
|
133
|
+
const stagedInputs = new Map<string, string>();
|
|
134
|
+
for (const name of paths.keys()) {
|
|
135
|
+
const data = await readBounded(join(staging, name), byteLimit(name)); check(); stagedInputs.set(name, hash(data));
|
|
136
|
+
if (name.endsWith("package.json")) {
|
|
137
|
+
const manifest = parseInstallManifest(data);
|
|
138
|
+
if (Object.hasOwn(manifest, "trustedDependencies")) return { ready: false, reason: "unsupported install inputs" };
|
|
139
|
+
// No reviewed path reference may re-enter mutable files outside the snapshot.
|
|
140
|
+
const contained = (value: string) => {
|
|
141
|
+
const normalized = posix.normalize(posix.join(posix.dirname(name), value));
|
|
142
|
+
return !value.includes("\\") && !posix.isAbsolute(value) && !/^[a-z]:/i.test(value)
|
|
143
|
+
&& normalized !== ".." && !normalized.startsWith("../");
|
|
144
|
+
};
|
|
145
|
+
const workspaces = Array.isArray(manifest.workspaces) ? manifest.workspaces
|
|
146
|
+
: manifest.workspaces && typeof manifest.workspaces === "object" ? (manifest.workspaces as Record<string, unknown>).packages : undefined;
|
|
147
|
+
if (manifest.workspaces !== undefined && (!Array.isArray(workspaces) || workspaces.some(value => typeof value !== "string" || !contained(value.replace(/^!/, ""))))) return { ready: false, reason: "unsupported install inputs" };
|
|
148
|
+
const escapingReference = (value: unknown): boolean => {
|
|
149
|
+
if (typeof value === "string") {
|
|
150
|
+
const local = /^(file|link):/.test(value) ? value.slice(value.indexOf(":") + 1)
|
|
151
|
+
: /^(\.\.?\/|\/|~\/|[a-z]:[\\/])/i.test(value) ? value : undefined;
|
|
152
|
+
return local !== undefined && (!contained(local) || local.startsWith("~/"));
|
|
153
|
+
}
|
|
154
|
+
return !!value && typeof value === "object" && Object.values(value).some(escapingReference);
|
|
155
|
+
};
|
|
156
|
+
if ([manifest.dependencies, manifest.devDependencies, manifest.optionalDependencies, manifest.peerDependencies,
|
|
157
|
+
manifest.overrides, manifest.resolutions, manifest.catalog, manifest.catalogs, manifest.workspaces].some(escapingReference)) return { ready: false, reason: "unsupported install inputs" };
|
|
158
|
+
if (manifest.patchedDependencies && typeof manifest.patchedDependencies === "object"
|
|
159
|
+
&& Object.values(manifest.patchedDependencies).some(value => typeof value !== "string" || !contained(value))) return { ready: false, reason: "unsupported install inputs" };
|
|
160
|
+
} else if (name.endsWith("bunfig.toml")) {
|
|
161
|
+
const config = Bun.TOML.parse(data.toString("utf8")) as Record<string, unknown>;
|
|
162
|
+
const installKeysUnsafe = (value: unknown): boolean => !!value && typeof value === "object" && Object.entries(value).some(([key, item]) => /preload|lifecycle|script|trustedDependencies/i.test(key) || installKeysUnsafe(item));
|
|
163
|
+
// Test-only preload does not execute during install and stays byte-for-byte in the reviewed snapshot.
|
|
164
|
+
if (Object.hasOwn(config, "preload") || installKeysUnsafe(config.install)) return { ready: false, reason: "unsupported install inputs" };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const currentInputs = async (): Promise<Map<string, string>> => {
|
|
168
|
+
const result = new Map<string, string>(); let entries = 0, total = 0;
|
|
169
|
+
const walk = async (dir: string, prefix: string): Promise<void> => {
|
|
170
|
+
const children = await opendir(dir);
|
|
171
|
+
for await (const entry of children) {
|
|
172
|
+
check();
|
|
173
|
+
if (++entries > PI_DEPENDENCY_ENTRY_LIMIT) fail("install inputs changed in task");
|
|
174
|
+
if (entry.name === ".git") continue;
|
|
175
|
+
if (entry.name === "node_modules") { if (prefix) fail("unsupported workspace layout"); continue; }
|
|
176
|
+
const file = join(dir, entry.name), name = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
177
|
+
if (entry.isSymbolicLink()) {
|
|
178
|
+
if (input(name)) fail("install inputs changed in task");
|
|
179
|
+
const target = await stat(file); check();
|
|
180
|
+
if (target.isDirectory()) fail("install inputs changed in task");
|
|
181
|
+
} else if (entry.isDirectory()) await walk(file, name);
|
|
182
|
+
else if (input(name)) {
|
|
183
|
+
if (!entry.isFile()) fail("install inputs changed in task");
|
|
184
|
+
const data = await readBounded(file, byteLimit(name)); check();
|
|
185
|
+
if ((total += data.length) > PI_DEPENDENCY_SNAPSHOT_BYTES) fail("install inputs changed in task");
|
|
186
|
+
result.set(name, hash(data));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
await walk(root!, ""); check(); return result;
|
|
191
|
+
};
|
|
192
|
+
const unchanged = async () => {
|
|
193
|
+
let actual: Map<string, string>;
|
|
194
|
+
try { actual = await currentInputs(); }
|
|
195
|
+
catch (error) { if (error instanceof PreparationStopped) throw error; fail("install inputs changed in task"); }
|
|
196
|
+
if (actual!.size !== stagedInputs.size || [...stagedInputs].some(([name, digest]) => actual!.get(name) !== digest)) fail("install inputs changed in task");
|
|
197
|
+
};
|
|
198
|
+
await unchanged(); check();
|
|
199
|
+
let executable: string;
|
|
200
|
+
try {
|
|
201
|
+
executable = realPath(process.execPath);
|
|
202
|
+
if (!isAbsolute(executable)) return { ready: false, reason: "installer unavailable" };
|
|
203
|
+
} catch { return { ready: false, reason: "installer unavailable" }; }
|
|
204
|
+
home = mkdtempSync(join(parent, "pi-install-home-")); home = realPath(home);
|
|
205
|
+
const request: DependencyInstallRequest = { executable, args: ["install", "--frozen-lockfile"], cwd: staging,
|
|
206
|
+
env: { HOME: home, BUN_INSTALL_CACHE_DIR: join(homedir(), ".bun", "install", "cache") }, timeoutMs: deadline - now() };
|
|
207
|
+
check(); const result = await (options.run ?? install)(request); check();
|
|
208
|
+
if (result.timedOut) return { ready: false, reason: "install timed out" };
|
|
209
|
+
if (result.code !== 0) return { ready: false, reason: "install failed" };
|
|
210
|
+
let modules;
|
|
211
|
+
try { modules = await lstat(join(staging, "node_modules")); check(); }
|
|
212
|
+
catch (error) { if (error instanceof PreparationStopped) throw error; return { ready: false, reason: "unsupported workspace layout" }; }
|
|
213
|
+
if (!modules.isDirectory() || modules.isSymbolicLink()) return { ready: false, reason: "unsupported workspace layout" };
|
|
214
|
+
let layouts = 0;
|
|
215
|
+
const workspaceLayout = async (dir: string, top = true): Promise<void> => {
|
|
216
|
+
for await (const entry of await opendir(dir)) {
|
|
217
|
+
check(); if (++layouts > PI_DEPENDENCY_ENTRY_LIMIT) fail("unsupported workspace layout");
|
|
218
|
+
if (entry.name === "node_modules") { if (!top) fail("unsupported workspace layout"); continue; }
|
|
219
|
+
if (entry.isDirectory()) await workspaceLayout(join(dir, entry.name), false);
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
await workspaceLayout(staging);
|
|
223
|
+
let moduleEntries = 0;
|
|
224
|
+
const privateModuleFiles = async (dir: string): Promise<void> => {
|
|
225
|
+
for await (const entry of await opendir(dir)) {
|
|
226
|
+
check(); if (++moduleEntries > PI_DEPENDENCY_ENTRY_LIMIT) fail("unsupported dependency layout");
|
|
227
|
+
const file = join(dir, entry.name), info = await lstat(file); check();
|
|
228
|
+
if (info.isSymbolicLink()) continue; // Never follow a package/bin/workspace link.
|
|
229
|
+
if (info.isDirectory()) await privateModuleFiles(file);
|
|
230
|
+
else if (!info.isFile() || info.nlink > 1) fail("unsupported dependency layout");
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
await privateModuleFiles(join(staging, "node_modules"));
|
|
234
|
+
await unchanged(); await targetAbsent(); check();
|
|
235
|
+
// No cooperative path-based fallback: the daemon supplies the CWD-pinned trusted publisher.
|
|
236
|
+
const publicationCurrent = () => { try { check(); return true; } catch { return false; } };
|
|
237
|
+
try { if (!options.publish || !await options.publish(join(staging, "node_modules"), { cwd: root, dev: rootInfo.dev, ino: rootInfo.ino, timeoutMs: deadline - now() }, publicationCurrent)) return { ready: false, reason: "install failed" }; }
|
|
238
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code === "EXDEV") return { ready: false, reason: "different filesystem" }; throw error; }
|
|
239
|
+
check(); return { ready: true };
|
|
240
|
+
} catch (error) {
|
|
241
|
+
if (!current()) return { ready: false, reason: "task changed" };
|
|
242
|
+
if (error instanceof PreparationStopped) return { ready: false, reason: error.reason };
|
|
243
|
+
if (error instanceof InstallPolicyError) return { ready: false, reason: error.reason };
|
|
244
|
+
return { ready: false, reason: "install failed" };
|
|
245
|
+
} finally {
|
|
246
|
+
await rootFd?.close().catch(() => {});
|
|
247
|
+
for (const own of [home, staging]) if (own) { try { rmSync(own, { recursive: true, force: true }); } catch { /* Advisory cleanup never changes an accepted task. */ } }
|
|
248
|
+
}
|
|
249
|
+
}
|
package/src/ui/index.html
CHANGED
|
@@ -212,6 +212,8 @@ details.settings-group .row{border-bottom:1px dashed var(--line)}
|
|
|
212
212
|
details.settings-group .row:last-child{border-bottom:0}
|
|
213
213
|
/* Structure (#689): instances, lifecycle and the executable keys. Tier 3 is text only: no control, a command to run in the console. */
|
|
214
214
|
.structure-group .row{padding:var(--space-3) var(--space-4)}
|
|
215
|
+
.structure-group>.row-head,.structure-group>p,.structure-instance,.structure-sdlc,.structure-add,.structure-backups{padding:var(--space-3) var(--space-4)}
|
|
216
|
+
.structure-keys{display:flex;flex-wrap:wrap;gap:var(--space-2);margin:var(--space-2) 0 0}
|
|
215
217
|
.structure-instance,.structure-sdlc,.structure-add,.structure-backups{border-bottom:1px dashed var(--line)}
|
|
216
218
|
.structure-tier3{background:var(--panel-soft);color:var(--ink);border:1px solid var(--line);border-radius:var(--radius-surface);padding:var(--space-3) var(--space-4);margin:var(--space-3) var(--space-4)}
|
|
217
219
|
.structure-tier3 code{display:block;overflow-wrap:anywhere;color:var(--muted)}
|
|
@@ -240,18 +242,19 @@ details.settings-group .row:last-child{border-bottom:0}
|
|
|
240
242
|
.board-lane{border-top:1px solid var(--line)}
|
|
241
243
|
.board-lane>h3{padding:var(--space-3) var(--space-4) 0;font-size:var(--text-lg)}
|
|
242
244
|
.peer-mark{display:inline-flex;align-items:center;gap:var(--space-2)}
|
|
245
|
+
.detail-group>.peer-mark{margin:0 var(--space-4) var(--space-2) 0}
|
|
243
246
|
.peer-color-dot{width:9px;height:9px;display:inline-block;border-radius:var(--radius-full);background:var(--peer-color);flex-shrink:0}
|
|
244
247
|
.peer-color-dot.reviewer{background:transparent;border:2px solid var(--peer-color)}
|
|
245
248
|
.agent-legend{display:flex;flex-wrap:wrap;gap:var(--space-2);padding:var(--space-3) var(--space-4);border-bottom:1px solid var(--line)}
|
|
246
249
|
.agent-legend .agent-slot{border:1px solid var(--line);border-radius:var(--radius-surface);padding:var(--space-3);flex:1 1 180px;min-width:0}
|
|
247
250
|
.board-drop-active{outline:2px solid var(--accent);outline-offset:2px}
|
|
248
251
|
.board-toolbar{padding:var(--space-3) var(--space-4);display:flex;gap:var(--space-4);flex-wrap:wrap;align-items:center}
|
|
249
|
-
.board-toolbar label{margin:0}
|
|
252
|
+
.board-toolbar label{margin:0;display:inline-flex;align-items:center;gap:var(--space-2)}
|
|
250
253
|
.board-toolbar select{width:auto;max-width:220px}
|
|
251
254
|
.board-unknown{padding:var(--space-3) var(--space-4);color:var(--amber)}
|
|
252
255
|
@media(max-width:1100px){.board-columns{grid-template-columns:repeat(2,minmax(0,1fr))}}
|
|
253
256
|
@media(max-width:900px){.stack{gap:var(--space-4)}.stream{height:300px}footer{padding:var(--space-4)}}
|
|
254
|
-
@media(max-width:600px){.structure-field{grid-template-columns:minmax(0,1fr)}.structure-tier3{margin:var(--space-3)}.split{grid-template-columns:minmax(0,1fr)}.board-columns{grid-template-columns:1fr;padding:var(--space-3)}.board-toolbar{align-items:stretch}.board-toolbar select{max-width:none;width:100%}.board-toolbar label{width:100
|
|
257
|
+
@media(max-width:600px){.structure-field{grid-template-columns:minmax(0,1fr)}.structure-tier3{margin:var(--space-3)}.split{grid-template-columns:minmax(0,1fr)}.board-columns{grid-template-columns:1fr;padding:var(--space-3)}.board-toolbar{align-items:stretch}.board-toolbar select{max-width:none;width:100%}.board-toolbar label{width:100%;display:flex}}
|
|
255
258
|
/* Reduced motion (#469 R6): one rule for the whole page. Every transition and animation is off, whatever rule declares it. */
|
|
256
259
|
@media(prefers-reduced-motion:reduce){*,*::before,*::after{transition:none!important;animation:none!important;scroll-behavior:auto!important}}
|
|
257
260
|
|
|
@@ -288,7 +291,7 @@ details.settings-group .row:last-child{border-bottom:0}
|
|
|
288
291
|
.theme-field select{width:auto}
|
|
289
292
|
.icon-button{display:inline-flex;align-items:center;justify-content:center;min-width:44px;min-height:44px;padding:0}
|
|
290
293
|
.attention-badge{min-height:44px}
|
|
291
|
-
.view-nav{grid-row:2;display:flex;gap:var(--space-1);padding:var(--space-2) var(--space-4);overflow-x:auto;overscroll-behavior-x:contain;background:var(--panel);border-bottom:1px solid var(--line);scrollbar-width:thin}
|
|
294
|
+
.view-nav{grid-row:2;display:flex;gap:var(--space-1);padding:var(--space-2) var(--space-4);overflow-x:auto;overscroll-behavior-x:contain;background:linear-gradient(to right,var(--panel) 30%,transparent) 0 0/40px 100% no-repeat local,linear-gradient(to left,var(--panel) 30%,transparent) 100% 0/40px 100% no-repeat local,linear-gradient(to right,var(--line),transparent) 0 0/14px 100% no-repeat scroll,linear-gradient(to left,var(--line),transparent) 100% 0/14px 100% no-repeat scroll,var(--panel);border-bottom:1px solid var(--line);scrollbar-width:thin}
|
|
292
295
|
.view-nav button{display:inline-flex;align-items:center;gap:var(--space-2);flex:none;min-height:44px;border-color:transparent;background:transparent;white-space:nowrap}
|
|
293
296
|
.view-nav button:hover{background:var(--hover)}
|
|
294
297
|
.view-nav button[aria-current="page"]{background:var(--accent-soft);color:var(--accent);border-color:var(--accent);font-weight:600}
|
|
@@ -306,7 +309,7 @@ kbd{display:inline-block;min-width:24px;padding:1px var(--space-2);border:1px so
|
|
|
306
309
|
@media(min-width:1024px){
|
|
307
310
|
.shell{grid-template-columns:200px minmax(0,1fr);grid-template-rows:auto minmax(0,1fr)}
|
|
308
311
|
.topbar{grid-column:1/-1}
|
|
309
|
-
.view-nav{grid-row:2;grid-column:1;flex-direction:column;overflow-x:visible;overflow-y:auto;padding:var(--space-3);border-bottom:0;border-right:1px solid var(--line);position:sticky;top:56px;align-self:start;height:calc(100vh - 56px)}
|
|
312
|
+
.view-nav{grid-row:2;grid-column:1;background:var(--panel);flex-direction:column;overflow-x:visible;overflow-y:auto;padding:var(--space-3);border-bottom:0;border-right:1px solid var(--line);position:sticky;top:56px;align-self:start;height:calc(100vh - 56px)}
|
|
310
313
|
.view-nav button{width:100%;justify-content:flex-start}
|
|
311
314
|
.view-nav .badge{margin-left:auto}
|
|
312
315
|
.shell-body{grid-row:2;grid-column:2}
|
|
@@ -406,6 +409,7 @@ main[data-stale]>:not(#notice):not(#disconnected){opacity:.6;transition:opacity
|
|
|
406
409
|
.usage-table th{font-size:var(--text-xs);color:var(--muted);text-transform:uppercase;letter-spacing:.05em;background:var(--panel-soft)}
|
|
407
410
|
.usage-table tr:hover td{background:var(--hover)}
|
|
408
411
|
.usage-table .num{font-family:var(--font-mono);text-align:right}
|
|
412
|
+
.usage-table .task-clip{display:block;max-width:32ch;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
409
413
|
.usage-tag{display:inline-block;padding:1px var(--space-2);border-radius:var(--radius-control);font-size:var(--text-xs);font-family:var(--font-mono)}
|
|
410
414
|
.usage-tag.pii{background:var(--amber-soft);color:var(--amber);border:1px solid var(--amber)}
|
|
411
415
|
.meta.usage-behind{color:var(--amber);background:var(--amber-soft);border:1px solid var(--amber);border-radius:var(--radius-control);padding:var(--space-2) var(--space-3)}
|
|
@@ -431,7 +435,7 @@ main[data-stale]>:not(#notice):not(#disconnected){opacity:.6;transition:opacity
|
|
|
431
435
|
</defs></svg>
|
|
432
436
|
<a class="skip-link" href="#main-content">Skip to content</a>
|
|
433
437
|
<div class="shell">
|
|
434
|
-
<header class="topbar"><div class="brand"><div class="eyebrow">Local control room</div><h1>agent-hub <span>/ dashboard</span></h1></div><div id="project-context" class="meta"></div><div class="topbar-end"><div id="connection" class="connection" role="status">Connecting...</div><button type="button" id="attention-badge" class="attention-badge" aria-label="Global attention" hidden>(0)</button><div class="theme-field"><label for="theme">Theme</label><select id="theme" class="theme-choice"><option value="system">System</option><option value="light">Light</option><option value="dark">Dark</option></select></div><button type="button" id="keys-open" class="icon-button" aria-label="Keyboard shortcuts" aria-haspopup="dialog"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-help"/></svg></button></div></header>
|
|
438
|
+
<header class="topbar"><div class="brand"><div class="eyebrow">Local control room</div><h1>agent-hub <span>/ dashboard</span></h1></div><div id="project-context" class="meta"></div><div class="topbar-end"><div id="connection" class="connection" role="status">Connecting...</div><button type="button" id="attention-badge" class="attention-badge" aria-label="Global attention" title="Global attention" hidden>Attention (0)</button><div class="theme-field"><label for="theme">Theme</label><select id="theme" class="theme-choice"><option value="system">System</option><option value="light">Light</option><option value="dark">Dark</option></select></div><button type="button" id="keys-open" class="icon-button" aria-label="Keyboard shortcuts" aria-haspopup="dialog"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-help"/></svg></button></div></header>
|
|
435
439
|
<nav id="dashboard-nav" class="view-nav" aria-label="Dashboard views">
|
|
436
440
|
<button type="button" data-view-target="board" aria-current="page"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-board"/></svg><span class="nav-label">Board</span></button>
|
|
437
441
|
<button type="button" data-view-target="office"><svg class="icon" aria-hidden="true" focusable="false"><use href="#i-office"/></svg><span class="nav-label">Office</span></button>
|
|
@@ -459,6 +463,7 @@ main[data-stale]>:not(#notice):not(#disconnected){opacity:.6;transition:opacity
|
|
|
459
463
|
<section id="schedules-section" aria-labelledby="schedules-title" data-view="agents" hidden><div class="section-head"><h2 id="schedules-title">Schedules</h2><span id="schedule-count" class="meta"></span></div><div id="schedules"></div></section>
|
|
460
464
|
<section id="rooms-section" aria-labelledby="rooms-title" data-view="agents" data-empty="true" hidden><div class="section-head"><h2 id="rooms-title">Rooms</h2><span id="room-count" class="meta"></span></div><div id="rooms"></div></section>
|
|
461
465
|
<section aria-labelledby="peers-title" data-view="agents" hidden><div class="section-head"><h2 id="peers-title">Peers & queues</h2><span id="peer-count" class="meta"></span></div><p id="runtime-models-notice" class="meta notice-warn" role="status" hidden></p><div id="peers"><div class="skeleton" aria-hidden="true"><span class="skeleton-bar skeleton-tall"></span><span class="skeleton-bar skeleton-tall"></span><span class="skeleton-bar skeleton-tall"></span></div><p class="empty">Loading peers...</p></div></section>
|
|
466
|
+
<section id="instructed-answers-section" aria-labelledby="instructed-answers-title" data-view="agents" data-empty="true" hidden><div class="section-head"><h2 id="instructed-answers-title">Recorded answers</h2></div><div id="instructed-answers"></div></section>
|
|
462
467
|
<section id="results-section" aria-labelledby="results-title" data-view="agents" hidden><div class="section-head"><h2 id="results-title">Results</h2><span id="results-count" class="meta"></span></div><div id="results"></div></section>
|
|
463
468
|
<section aria-labelledby="permissions-title" data-view="agents" hidden><div class="section-head"><h2 id="permissions-title">Pending approvals</h2><span id="permission-count" class="meta"></span></div><div id="permissions"></div></section>
|
|
464
469
|
<section aria-labelledby="budget-title" data-view="agents" hidden><div class="section-head"><h2 id="budget-title">Usage budgets</h2></div><div id="budget"></div>
|
|
@@ -538,6 +543,15 @@ function applyDashboardView() {
|
|
|
538
543
|
for (const section of document.querySelectorAll('main section[data-view]')) section.hidden = section.dataset.view !== currentView;
|
|
539
544
|
for (const stack of document.querySelectorAll('main > .stack')) stack.hidden = ![...stack.children].some(section => section.dataset.view === currentView);
|
|
540
545
|
for (const button of document.querySelectorAll('button[data-view-target]')) button.setAttribute('aria-current', button.dataset.viewTarget === currentView ? 'page' : 'false');
|
|
546
|
+
revealActiveView();
|
|
547
|
+
}
|
|
548
|
+
// #1477: the strip scrolls sideways on a phone, so a view picked by key or link is brought into sight once per change (a poll redraw never fights the person's own scrolling).
|
|
549
|
+
let revealedView = null;
|
|
550
|
+
function revealActiveView() {
|
|
551
|
+
if (revealedView === currentView) return;
|
|
552
|
+
revealedView = currentView;
|
|
553
|
+
const active = [...document.querySelectorAll('button[data-view-target]')].find(button => button.dataset.viewTarget === currentView);
|
|
554
|
+
if (active && typeof active.scrollIntoView === 'function') active.scrollIntoView({block:'nearest', inline:'nearest'});
|
|
541
555
|
}
|
|
542
556
|
function switchView(view) {
|
|
543
557
|
if (!DASHBOARD_VIEWS.includes(view)) return;
|
|
@@ -792,6 +806,18 @@ function renderTaskStage(stage) {
|
|
|
792
806
|
for (const [index, label] of ['Proposed', 'In progress', 'In review', 'Approved'].entries()) row.append(el('span', `${index < stage.stage ? '[x]' : '[ ]'} ${label}${index < 3 ? ' > ' : ''}`, index < stage.stage ? 'reached' : ''));
|
|
793
807
|
row.append(el('span', ` / Stage ${stage.stage}/4: ${stage.label}`)); return row;
|
|
794
808
|
}
|
|
809
|
+
function renderInstructedAnswers(input) {
|
|
810
|
+
const rows = Array.isArray(input) ? input.filter(row => row && row.instructed === true && typeof row.set === 'string' && typeof row.provenance === 'string') : [];
|
|
811
|
+
$('instructed-answers-section').dataset.empty = rows.length ? 'false' : 'true';
|
|
812
|
+
update('instructed-answers', rows, target => {
|
|
813
|
+
for (const row of rows) {
|
|
814
|
+
const card = el('div', undefined, 'row');
|
|
815
|
+
card.append(el('p', row.set + ': ' + row.provenance, 'meta'));
|
|
816
|
+
if (Array.isArray(row.answers)) card.append(el('pre', JSON.stringify(row.answers), 'meta'));
|
|
817
|
+
target.append(card);
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
}
|
|
795
821
|
function renderApprovals(permissions) {
|
|
796
822
|
const terminalWaiting = permissions.filter((permission) => adapterDisplay[permission.peer]?.terminalApproval).length;
|
|
797
823
|
$('permission-count').textContent = permissions.length + ' waiting' + (terminalWaiting ? ', ' + terminalWaiting + ' Pi/local: answer in the console or ahub tail / ahub permit' : '');
|
|
@@ -807,7 +833,7 @@ function renderApprovals(permissions) {
|
|
|
807
833
|
});
|
|
808
834
|
}
|
|
809
835
|
const SETTING_GROUPS = ['Roster', 'Permissions', 'Roles', 'Start', 'Routing', 'Switches'], INHERIT = '__inherit__';
|
|
810
|
-
const settingsOpen = new Set(
|
|
836
|
+
const settingsOpen = new Set();
|
|
811
837
|
const settingText = (value) => value === null || value === undefined ? '(not set)' : Array.isArray(value) ? (value.join(', ') || '(none)') : String(value);
|
|
812
838
|
async function previewSetting(row, value, out, control) {
|
|
813
839
|
if (stopped) return;
|
|
@@ -855,6 +881,9 @@ function settingRow(row, raise) {
|
|
|
855
881
|
select.value = current[index] || ''; actions.append(select); return select;
|
|
856
882
|
});
|
|
857
883
|
read = () => choices.map(select => select.value).filter(Boolean);
|
|
884
|
+
} else if (row.type === 'number-or-off') {
|
|
885
|
+
const input=el('input');input.type='text';input.id=id;input.name=row.key;input.value=fileValue===null ? '' : String(fileValue);input.placeholder='0..1 or off; empty inherits';input.autocomplete='off';input.autocapitalize='none';input.setAttribute('autocorrect','off');input.spellcheck=false;
|
|
886
|
+
read=()=>{const value=input.value.trim();return value==='' ? null : value==='off' ? 'off' : Number.isFinite(Number(value)) ? Number(value) : value;};actions.append(input);
|
|
858
887
|
} else if (row.type === 'integer' || row.type === 'number') {
|
|
859
888
|
const input=el('input');input.type='number';input.id=id;input.step=row.type === 'number' ? 'any' : '1';input.min=String(row.min ?? 0);input.max=String(row.max ?? Number.MAX_SAFE_INTEGER);const current=fileValue;input.value=current===null ? '' : String(current);input.placeholder='Empty inherits';
|
|
860
889
|
read=()=>input.value==='' ? null : Number(input.value);actions.append(input);
|
|
@@ -988,7 +1017,15 @@ function renderStructure(target, edit, raise) {
|
|
|
988
1017
|
}
|
|
989
1018
|
const tier3 = el('div', undefined, 'structure-tier3');
|
|
990
1019
|
tier3.append(el('p', 'Executable and secret-locating keys', 'label'), el('p', "Changing one runs code with the daemon's rights or chooses where secrets are read from. It is never done from a browser: use the console command.", 'meta'));
|
|
991
|
-
|
|
1020
|
+
// One command template and a compact key list (#1477): a key whose command is not the template shows its own.
|
|
1021
|
+
const tier3Template = 'ahub settings edit config.local.json set <key> <json>', tier3Keys = el('div', undefined, 'structure-keys'), tier3Own = [];
|
|
1022
|
+
tier3.append(el('code', tier3Template));
|
|
1023
|
+
for (const item of edit.tier3 || []) {
|
|
1024
|
+
tier3Keys.append(el('span', item.key + (item.set ? ' (set)' : ' (not set)'), 'badge'));
|
|
1025
|
+
if (item.command !== tier3Template.replace('<key>', item.key)) tier3Own.push(item);
|
|
1026
|
+
}
|
|
1027
|
+
tier3.append(tier3Keys);
|
|
1028
|
+
for (const item of tier3Own) tier3.append(el('p', item.key, 'meta'), el('code', item.command));
|
|
992
1029
|
group.append(tier3);
|
|
993
1030
|
const backups = el('div', undefined, 'structure-backups');
|
|
994
1031
|
backups.append(el('p', 'Backups (the last ' + (edit.backups || []).length + ')', 'label'));
|
|
@@ -1519,6 +1556,11 @@ async function refreshReviewComments(id) {
|
|
|
1519
1556
|
if (lastSnapshot) { lastSnapshot = {...lastSnapshot, reviewComments:reviewCommentsCache.get(cacheKey)}; render(lastSnapshot); }
|
|
1520
1557
|
} catch (error) { if (taskDetailId === id) notice('Review comments unavailable: ' + error.message, true); }
|
|
1521
1558
|
}
|
|
1559
|
+
// #1477: the one filter the board and its count share; a count that ignored the filter said "5 tasks" over an empty board.
|
|
1560
|
+
function boardTaskVisible(task, taskFilter, ownerFilter, releaseFilter) {
|
|
1561
|
+
return (!taskFilter || (taskFilter === 'work' ? ['in_progress','changes_requested'].includes(task.state) : task.state === taskFilter)) && (!ownerFilter || task.owner === ownerFilter || task.reviewer === ownerFilter) && (!releaseFilter || task.release === Number(releaseFilter));
|
|
1562
|
+
}
|
|
1563
|
+
function taskCountText(total, shown, filtered) { return (filtered ? shown + ' of ' + total : String(total)) + ' tasks'; }
|
|
1522
1564
|
function renderBoard(snapshot, peers, ids) {
|
|
1523
1565
|
if (columnFocus === undefined) {
|
|
1524
1566
|
columnFocus = dashboardCookie.get('agent-hub-column-focus') || null;
|
|
@@ -1538,7 +1580,7 @@ function renderBoard(snapshot, peers, ids) {
|
|
|
1538
1580
|
peerOptions(peerFilter,ids,'All agents'); if (ids.includes(previous)) peerFilter.value=previous;
|
|
1539
1581
|
const taskFilter=$('task-filter').value, ownerFilter=peerFilter.value, releaseFilter=$('task-release-filter').value, lanes=$('task-lanes').value;
|
|
1540
1582
|
const eligible=ids.filter(id=>['idle','busy'].includes(peers[id].state) && peers[id].attached!==false && peers[id].rostered!==false);
|
|
1541
|
-
$('task-count').textContent=snapshot.tasks.length
|
|
1583
|
+
$('task-count').textContent=taskCountText(snapshot.tasks.length,snapshot.tasks.filter(task=>boardTaskVisible(task,taskFilter,ownerFilter,releaseFilter)).length,Boolean(taskFilter||ownerFilter||releaseFilter));
|
|
1542
1584
|
$('board-back').hidden = columnFocus === null; $('board-focus-title').hidden = columnFocus === null;
|
|
1543
1585
|
$('board-focus-title').textContent = columnFocus ? model.columns.find(column => column.id === columnFocus)?.label || '' : '';
|
|
1544
1586
|
update('task-legend',[snapshot.boardLegend,peers],target=>{
|
|
@@ -1558,7 +1600,7 @@ function renderBoard(snapshot, peers, ids) {
|
|
|
1558
1600
|
update('tasks',[snapshot.tasks,peers,snapshot.boardCapabilities,taskFilter,ownerFilter,releaseFilter,lanes,showAllDone,[...overdue],columnFocus],target=>{
|
|
1559
1601
|
taskRows.clear(); const keyed=keyedStart('cards',true);
|
|
1560
1602
|
if(!snapshot.tasks.length)target.append(el('p','No tasks yet. Plan one with the Plan button, or run ahub task propose <title>.','empty'));
|
|
1561
|
-
const visible=snapshot.tasks.filter(task=>(
|
|
1603
|
+
const visible=snapshot.tasks.filter(task=>boardTaskVisible(task,taskFilter,ownerFilter,releaseFilter));
|
|
1562
1604
|
const visibleIds=new Set(visible.map(task=>task.id));
|
|
1563
1605
|
const owners=columnFocus ? [null] : lanes==='agents' ? [...new Set(visible.map(task=>task.owner || ''))] : lanes==='releases' ? [...new Set(visible.map(task=>task.release ?? 0))] : [null];
|
|
1564
1606
|
if (!owners.length) owners.push(null);
|
|
@@ -1655,8 +1697,8 @@ function renderNeedsAttention(snapshot) {
|
|
|
1655
1697
|
if(signature===attentionSignature)return;
|
|
1656
1698
|
attentionSignature=signature;attentionFirst=value?.items[0];
|
|
1657
1699
|
const target=$('attention-badge');target.hidden=!value;target.disabled=!value?.items.length;
|
|
1658
|
-
target.textContent=value?'('+value.act+')'+(value.watch?' +'+value.watch+' watch':''):'(0)';
|
|
1659
|
-
|
|
1700
|
+
target.textContent=value?'Attention ('+value.act+')'+(value.watch?' +'+value.watch+' watch':''):'Attention (0)';
|
|
1701
|
+
const attentionLabel=value?'Global attention: '+value.act+' action, '+value.watch+' watch':'Attention unavailable';target.setAttribute('aria-label',attentionLabel);target.title=attentionLabel;
|
|
1660
1702
|
const approvals=$('agents-approval-count');approvals.textContent=approvalCount?'('+approvalCount+')':'';approvals.hidden=!approvalCount;
|
|
1661
1703
|
const title=value?.act?'('+value.act+') agent-hub':attentionBaseTitle;if(document.title!==title)document.title=title;
|
|
1662
1704
|
}
|
|
@@ -1878,7 +1920,7 @@ function renderUsage(usage, tasks, budget) {
|
|
|
1878
1920
|
if (pii) {
|
|
1879
1921
|
taskCell.append(el('span', '#' + id + ' [pii]', 'usage-tag pii'));
|
|
1880
1922
|
} else {
|
|
1881
|
-
|
|
1923
|
+
const clip = el('span', '#' + id + (bt?.title ? ' ' + bt.title : ''), 'task-clip'); clip.title = clip.textContent; taskCell.append(clip);
|
|
1882
1924
|
}
|
|
1883
1925
|
const stateCell = el('td', bt?.state ? bt.state.replaceAll('_', ' ') : '-');
|
|
1884
1926
|
const ownerCell = el('td', bt?.owner || '-');
|
|
@@ -2028,6 +2070,7 @@ function render(snapshot) {
|
|
|
2028
2070
|
renderBoard(snapshot, peers, ids);
|
|
2029
2071
|
renderSources(snapshot.sources);
|
|
2030
2072
|
renderApprovals(snapshot.permissions);
|
|
2073
|
+
renderInstructedAnswers(snapshot.answeredQuestions);
|
|
2031
2074
|
update('budget', snapshot.budget, (target) => {
|
|
2032
2075
|
if (!Object.keys(snapshot.budget).length) return empty(target, 'No usage readings yet. Usage appears when a peer reports it.');
|
|
2033
2076
|
for (const [peer, budget] of Object.entries(snapshot.budget)) {
|
|
@@ -2588,7 +2631,7 @@ function renderResults(results) {
|
|
|
2588
2631
|
const tools = el('div', undefined, 'row-head');
|
|
2589
2632
|
if (unread.length) tools.append(button('Mark all read', {action: 'results_read_all'}));
|
|
2590
2633
|
if (results.canUnread) tools.append(button('Mark last unread again', {action: 'results_unread_last'}));
|
|
2591
|
-
if (!unread.length) target
|
|
2634
|
+
if (!unread.length) empty(target, 'Nothing unread.');
|
|
2592
2635
|
for (const item of unread) {
|
|
2593
2636
|
const block = el('div', undefined, 'row'), head = el('div', undefined, 'row-head');
|
|
2594
2637
|
head.append(el('span', String(item.title), 'label'));
|