@staix/agent-hub 0.39.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 +39 -0
- package/README.md +12 -6
- package/docs/adding-an-ai-tool.md +1 -1
- package/docs/agent-notes/README.md +7 -0
- package/docs/agent-notes/adapters.md +5 -3
- package/docs/agent-notes/benchmarks.md +2 -0
- package/docs/agent-notes/budget.md +1 -0
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +8 -3
- package/docs/agent-notes/local-worker.md +3 -1
- package/docs/agent-notes/security-review.md +1 -0
- package/docs/agent-notes/tasks.md +7 -2
- package/docs/agent-notes/tests.md +7 -7
- package/docs/contracts/companion-cli-v1.json +4 -0
- package/docs/design/adapters.md +91 -0
- package/docs/design/agent-hub-architecture.md +17 -0
- 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 +34 -0
- package/docs/dogfood.md +11 -4
- package/docs/events.md +4 -4
- package/docs/memory.md +3 -3
- package/docs/operations.md +153 -41
- package/docs/profiles.md +1 -0
- package/docs/quickstart.md +17 -4
- package/docs/sdlc.md +3 -1
- package/docs/security.md +40 -4
- 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 +22 -22
- package/package.json +3 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +332 -89
- package/plugins/agent-hub/kimi-review-policy-worker.js +16 -11
- package/plugins/agent-hub/server.js +417 -160
- package/src/adapters/agy/definition.ts +1 -1
- package/src/adapters/claude-channel.ts +1 -1
- package/src/adapters/codex-review-isolation.ts +61 -17
- package/src/adapters/compat.ts +7 -7
- package/src/adapters/definitions/builtin-metadata.ts +6 -6
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-config-policy.ts +1 -1
- package/src/adapters/definitions/qwen.ts +1 -1
- package/src/adapters/local-worker.ts +5 -3
- package/src/adapters/pi.ts +54 -11
- package/src/adapters/registry-types.ts +2 -1
- package/src/adapters/reviewer-print.ts +2 -1
- package/src/cli/answer-args.ts +11 -3
- package/src/cli/console-question.ts +1 -1
- package/src/cli/console-state.ts +95 -10
- package/src/cli/console.ts +6 -2
- package/src/cli/error-format.ts +19 -0
- package/src/cli/help.ts +290 -25
- package/src/cli/identity-audit.ts +8 -7
- package/src/cli/identity.ts +17 -0
- package/src/cli/init.ts +102 -9
- package/src/cli/main.js +2 -2
- package/src/cli/main.ts +57 -21
- package/src/cli/output-standard.ts +56 -0
- package/src/cli/output.ts +143 -8
- package/src/cli/roadmap.ts +215 -0
- package/src/cli/smoke-pty-bridge.ts +7 -24
- package/src/cli/task-output.ts +3 -1
- package/src/cli/upgrade-presentation-flags.ts +2 -2
- package/src/hub/board.ts +200 -3
- 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/control-client.ts +1 -1
- package/src/hub/daemon.ts +245 -43
- package/src/hub/events.ts +2 -2
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/github-import.ts +81 -0
- package/src/hub/hub-tools.ts +34 -9
- package/src/hub/install-policy.ts +23 -0
- package/src/hub/lifecycle-schema.ts +2 -2
- package/src/hub/no-writes.ts +3 -0
- package/src/hub/operational-authority.ts +3 -1
- package/src/hub/operational-view.ts +1 -1
- package/src/hub/pi-failure.ts +7 -0
- package/src/hub/question-desk.ts +26 -7
- package/src/hub/questions.ts +33 -5
- package/src/hub/restart.ts +7 -0
- 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/sdlc-merge.ts +5 -4
- package/src/hub/sdlc-queue.ts +3 -3
- package/src/hub/sdlc.ts +37 -2
- package/src/hub/specs-task.ts +7 -0
- package/src/hub/task-sweep.ts +29 -2
- package/src/hub/task-worktree.ts +37 -0
- package/src/hub/tasks.ts +381 -7
- 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 +53 -13
- package/src/ui/plugin-questions.ts +5 -0
- package/src/ui/plugin.ts +6 -1
- package/templates/config.json +1 -1
|
@@ -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;
|
|
@@ -991,7 +1017,15 @@ function renderStructure(target, edit, raise) {
|
|
|
991
1017
|
}
|
|
992
1018
|
const tier3 = el('div', undefined, 'structure-tier3');
|
|
993
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'));
|
|
994
|
-
|
|
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));
|
|
995
1029
|
group.append(tier3);
|
|
996
1030
|
const backups = el('div', undefined, 'structure-backups');
|
|
997
1031
|
backups.append(el('p', 'Backups (the last ' + (edit.backups || []).length + ')', 'label'));
|
|
@@ -1522,6 +1556,11 @@ async function refreshReviewComments(id) {
|
|
|
1522
1556
|
if (lastSnapshot) { lastSnapshot = {...lastSnapshot, reviewComments:reviewCommentsCache.get(cacheKey)}; render(lastSnapshot); }
|
|
1523
1557
|
} catch (error) { if (taskDetailId === id) notice('Review comments unavailable: ' + error.message, true); }
|
|
1524
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'; }
|
|
1525
1564
|
function renderBoard(snapshot, peers, ids) {
|
|
1526
1565
|
if (columnFocus === undefined) {
|
|
1527
1566
|
columnFocus = dashboardCookie.get('agent-hub-column-focus') || null;
|
|
@@ -1541,7 +1580,7 @@ function renderBoard(snapshot, peers, ids) {
|
|
|
1541
1580
|
peerOptions(peerFilter,ids,'All agents'); if (ids.includes(previous)) peerFilter.value=previous;
|
|
1542
1581
|
const taskFilter=$('task-filter').value, ownerFilter=peerFilter.value, releaseFilter=$('task-release-filter').value, lanes=$('task-lanes').value;
|
|
1543
1582
|
const eligible=ids.filter(id=>['idle','busy'].includes(peers[id].state) && peers[id].attached!==false && peers[id].rostered!==false);
|
|
1544
|
-
$('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));
|
|
1545
1584
|
$('board-back').hidden = columnFocus === null; $('board-focus-title').hidden = columnFocus === null;
|
|
1546
1585
|
$('board-focus-title').textContent = columnFocus ? model.columns.find(column => column.id === columnFocus)?.label || '' : '';
|
|
1547
1586
|
update('task-legend',[snapshot.boardLegend,peers],target=>{
|
|
@@ -1561,7 +1600,7 @@ function renderBoard(snapshot, peers, ids) {
|
|
|
1561
1600
|
update('tasks',[snapshot.tasks,peers,snapshot.boardCapabilities,taskFilter,ownerFilter,releaseFilter,lanes,showAllDone,[...overdue],columnFocus],target=>{
|
|
1562
1601
|
taskRows.clear(); const keyed=keyedStart('cards',true);
|
|
1563
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'));
|
|
1564
|
-
const visible=snapshot.tasks.filter(task=>(
|
|
1603
|
+
const visible=snapshot.tasks.filter(task=>boardTaskVisible(task,taskFilter,ownerFilter,releaseFilter));
|
|
1565
1604
|
const visibleIds=new Set(visible.map(task=>task.id));
|
|
1566
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];
|
|
1567
1606
|
if (!owners.length) owners.push(null);
|
|
@@ -1658,8 +1697,8 @@ function renderNeedsAttention(snapshot) {
|
|
|
1658
1697
|
if(signature===attentionSignature)return;
|
|
1659
1698
|
attentionSignature=signature;attentionFirst=value?.items[0];
|
|
1660
1699
|
const target=$('attention-badge');target.hidden=!value;target.disabled=!value?.items.length;
|
|
1661
|
-
target.textContent=value?'('+value.act+')'+(value.watch?' +'+value.watch+' watch':''):'(0)';
|
|
1662
|
-
|
|
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;
|
|
1663
1702
|
const approvals=$('agents-approval-count');approvals.textContent=approvalCount?'('+approvalCount+')':'';approvals.hidden=!approvalCount;
|
|
1664
1703
|
const title=value?.act?'('+value.act+') agent-hub':attentionBaseTitle;if(document.title!==title)document.title=title;
|
|
1665
1704
|
}
|
|
@@ -1881,7 +1920,7 @@ function renderUsage(usage, tasks, budget) {
|
|
|
1881
1920
|
if (pii) {
|
|
1882
1921
|
taskCell.append(el('span', '#' + id + ' [pii]', 'usage-tag pii'));
|
|
1883
1922
|
} else {
|
|
1884
|
-
|
|
1923
|
+
const clip = el('span', '#' + id + (bt?.title ? ' ' + bt.title : ''), 'task-clip'); clip.title = clip.textContent; taskCell.append(clip);
|
|
1885
1924
|
}
|
|
1886
1925
|
const stateCell = el('td', bt?.state ? bt.state.replaceAll('_', ' ') : '-');
|
|
1887
1926
|
const ownerCell = el('td', bt?.owner || '-');
|
|
@@ -2031,6 +2070,7 @@ function render(snapshot) {
|
|
|
2031
2070
|
renderBoard(snapshot, peers, ids);
|
|
2032
2071
|
renderSources(snapshot.sources);
|
|
2033
2072
|
renderApprovals(snapshot.permissions);
|
|
2073
|
+
renderInstructedAnswers(snapshot.answeredQuestions);
|
|
2034
2074
|
update('budget', snapshot.budget, (target) => {
|
|
2035
2075
|
if (!Object.keys(snapshot.budget).length) return empty(target, 'No usage readings yet. Usage appears when a peer reports it.');
|
|
2036
2076
|
for (const [peer, budget] of Object.entries(snapshot.budget)) {
|
|
@@ -2591,7 +2631,7 @@ function renderResults(results) {
|
|
|
2591
2631
|
const tools = el('div', undefined, 'row-head');
|
|
2592
2632
|
if (unread.length) tools.append(button('Mark all read', {action: 'results_read_all'}));
|
|
2593
2633
|
if (results.canUnread) tools.append(button('Mark last unread again', {action: 'results_unread_last'}));
|
|
2594
|
-
if (!unread.length) target
|
|
2634
|
+
if (!unread.length) empty(target, 'Nothing unread.');
|
|
2595
2635
|
for (const item of unread) {
|
|
2596
2636
|
const block = el('div', undefined, 'row'), head = el('div', undefined, 'row-head');
|
|
2597
2637
|
head.append(el('span', String(item.title), 'label'));
|
|
@@ -54,3 +54,8 @@ export function personEvidence(features: readonly string[] | undefined, meta: Ac
|
|
|
54
54
|
return { ok: false, error: "The person's identity and the target come from the console; remove those fields and retry." };
|
|
55
55
|
return { ok: true, identity: value.identity.trim().slice(0, 200) };
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
/** Settled instructed answers are read-only provenance, never another answer form or the stored quote. */
|
|
59
|
+
export function instructedAnswerItem(row: { set: string; peer: string; created: number; person: string; provenance: string }, project: { id: string; name: string }): QuestionItem {
|
|
60
|
+
return { id: questionItemId(project.id, row.set), group: "decision", kind: "decision", title: `${flat(row.set, 64)}: ${flat(row.provenance, 240)}`, actor: row.person, project: project.name, at: new Date(row.created).toISOString(), chip: { text: "answered", tone: "warn" }, verbs: [{ id: "open", label: "Open Agents" }], link: { panel: "agents", params: { project: project.id } } };
|
|
61
|
+
}
|
package/src/ui/plugin.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { DASHBOARD_VIEWS, renderDashboard } from "../hub/ui.ts";
|
|
|
21
21
|
import { parseLineageResult } from "../hub/execution-lineage.ts";
|
|
22
22
|
import { executionLineageLines } from "./lineage-view.ts";
|
|
23
23
|
import { officeModel, type OfficeScene } from "./office-model.ts";
|
|
24
|
-
import { personEvidence, questionItem, QUESTION_ITEM, type InboxAnswers, type QuestionRowView } from "./plugin-questions.ts";
|
|
24
|
+
import { instructedAnswerItem, personEvidence, questionItem, QUESTION_ITEM, type InboxAnswers, type QuestionRowView } from "./plugin-questions.ts";
|
|
25
25
|
import { canPublishResults, receiptEvidence, resultItem, RESULT_ACTIONS, RESULT_ITEM, type ResultAction, type ResultRowView } from "./plugin-results.ts";
|
|
26
26
|
import { mergeSpaces, officeSpace } from "./office-space.ts";
|
|
27
27
|
import type { DeliverablePorts } from "../hub/deliverable-files.ts";
|
|
@@ -275,6 +275,11 @@ export function createProvider(options: { visualPolicy?: (cwd: string) => Promis
|
|
|
275
275
|
seen.set(item.id, item.at);
|
|
276
276
|
items.push(item);
|
|
277
277
|
}
|
|
278
|
+
for (const row of Array.isArray(snap.answeredQuestions) ? snap.answeredQuestions : []) {
|
|
279
|
+
if (typeof row?.set !== "string" || typeof row.peer !== "string" || typeof row.person !== "string" || typeof row.provenance !== "string" || !Number.isSafeInteger(row.created)) continue;
|
|
280
|
+
const item = instructedAnswerItem(row, { id: project.id, name });
|
|
281
|
+
seen.set(item.id, item.at); items.push(item);
|
|
282
|
+
}
|
|
278
283
|
// #1054 T6: unread results, only to a console that renders the `result` group AND gives a receipt person evidence. Otherwise they stay in the ahub panel, `ahub console`, `ahub status`
|
|
279
284
|
// and `ahub results`. A row that is not well formed is dropped, never rendered; the detail is what the hub built at display (a stub when private).
|
|
280
285
|
if (canPublishResults(options.features)) {
|
package/templates/config.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"qwen_cmd": ["qwen", "--acp"],
|
|
5
5
|
"jcode_cmd": ["jcode"],
|
|
6
6
|
"codex_bin": "codex",
|
|
7
|
-
"pi": { "enabled": false, "auto_start": false, "cmd": ["pi"], "backend": "auto", "dgx_coding": "coding", "dgx_fast": "fast", "max_steps":
|
|
7
|
+
"pi": { "enabled": false, "auto_start": false, "cmd": ["pi"], "backend": "auto", "dgx_coding": "coding", "dgx_fast": "fast", "max_steps": 100 },
|
|
8
8
|
"batch_max": 3,
|
|
9
9
|
"batch_ms": 15000,
|
|
10
10
|
"queue_cap": 200,
|