@staix/agent-hub 0.35.0 → 0.36.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 +26 -0
- package/README.md +21 -4
- package/docs/agent-notes/README.md +60 -0
- package/docs/agent-notes/adapters.md +5 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +5 -4
- package/docs/agent-notes/models.md +4 -3
- package/docs/agent-notes/tasks.md +8 -1
- package/docs/agent-notes/tests.md +1 -0
- package/docs/design/adapters.md +72 -0
- package/docs/design/agent-hub-architecture.md +1 -1
- package/docs/design/bus.md +8 -0
- package/docs/design/execution-reference.md +171 -11
- package/docs/design/guidance-experiments.md +438 -0
- package/docs/design/model-routes.md +628 -0
- package/docs/design/supervision.md +121 -0
- package/docs/design/task-board.md +111 -0
- package/docs/dogfood.md +15 -4
- package/docs/operations.md +291 -22
- package/docs/profiles.md +2 -2
- package/docs/quickstart.md +106 -1
- package/docs/research.md +4 -2
- package/docs/sdlc.md +108 -4
- package/docs/security.md +67 -5
- package/docs/specs/2026-09-19-agent-hub-design.md +5 -4
- package/docs/verification/2026-10-25-qwen-dual-output-t0.md +22 -0
- package/docs/verification/2026-11-09-qwen-0270-acp.md +181 -0
- package/docs/verification/2026-11-09-qwen-0270-model-setter-1317.md +46 -0
- package/docs/verification/2026-11-10-0.36.0.md +59 -0
- package/docs/verification/2026-11-10-claude-implementer-2.1.322.md +59 -0
- package/docs/verification/2026-11-10-qwen-0270-dual-output.md +367 -0
- package/docs/verification/2026-11-10-qwen-0271-dual-output.md +101 -0
- package/docs/verification/claude-shell-wrapper-native.py +1 -1
- package/docs/verified.json +27 -27
- package/package.json +1 -1
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +1201 -368
- package/plugins/agent-hub/server.js +1682 -431
- package/src/adapters/claude-channel.ts +7 -4
- package/src/adapters/compat.ts +10 -10
- package/src/adapters/local-worker.ts +1 -1
- package/src/adapters/qwen-dual.ts +324 -44
- package/src/cli/guidance.ts +67 -0
- package/src/cli/help.ts +10 -3
- package/src/cli/identity.ts +10 -3
- package/src/cli/init-prompt.ts +15 -2
- package/src/cli/init-required-checks.ts +122 -0
- package/src/cli/init-settings.ts +10 -4
- package/src/cli/init.ts +39 -3
- package/src/cli/lineage.ts +78 -0
- package/src/cli/main.ts +111 -10
- package/src/cli/setup-research.ts +10 -0
- package/src/hub/autonomy-defaults.ts +20 -9
- package/src/hub/board.ts +346 -4
- package/src/hub/build-entry.ts +11 -0
- package/src/hub/bus.ts +12 -0
- package/src/hub/ci-watch.ts +4 -4
- package/src/hub/config-apply.ts +2 -1
- package/src/hub/config-trust.ts +1 -0
- package/src/hub/control-client.ts +1 -1
- package/src/hub/daemon.ts +342 -20
- package/src/hub/delivery-hints.ts +4 -2
- package/src/hub/delivery-journal.ts +50 -2
- package/src/hub/delivery-public.ts +51 -0
- package/src/hub/dogfood-profile.ts +8 -4
- package/src/hub/execution-lineage-owner.ts +272 -0
- package/src/hub/execution-lineage.ts +52 -8
- package/src/hub/execution-links.ts +85 -0
- package/src/hub/guidance-variants.ts +398 -0
- package/src/hub/handoff.ts +1 -0
- package/src/hub/hub-tools.ts +43 -2
- package/src/hub/manager.ts +44 -2
- package/src/hub/memory-policy.ts +2 -2
- package/src/hub/peers.ts +1 -1
- package/src/hub/planning.ts +1 -1
- package/src/hub/progress.ts +24 -7
- package/src/hub/restart.ts +13 -0
- package/src/hub/roles.ts +26 -0
- package/src/hub/routing.ts +4 -1
- package/src/hub/sdlc-merge.ts +39 -1
- package/src/hub/sdlc-release.ts +1 -1
- package/src/hub/sdlc.ts +62 -11
- package/src/hub/settings.ts +2 -0
- package/src/hub/supervision-proposals.ts +405 -0
- package/src/hub/supervision-rules.ts +388 -0
- package/src/hub/supervision.ts +2 -0
- package/src/hub/task-approval.ts +2 -2
- package/src/hub/task-repository.ts +5 -0
- package/src/hub/tasks.ts +603 -50
- package/src/memory/capture.ts +2 -2
- package/src/models/relay.ts +9 -2
- package/src/models/route/config.ts +27 -0
- package/src/models/route/decision.ts +87 -15
- package/src/models/route/relay-selector.ts +8 -7
- package/src/models/route/runtime.ts +22 -16
- package/src/models/route/stage-diagnostics.ts +22 -0
- package/src/models/route/stage-evidence.ts +55 -0
- package/src/models/route/stage-fallback.ts +58 -0
- package/src/models/route/stage-input.ts +155 -0
- package/src/models/route/stage.ts +5 -147
- package/src/ui/guidance-panel.ts +156 -0
- package/src/ui/guidance-view.ts +43 -0
- package/src/ui/lineage-view.ts +34 -0
- package/src/ui/plugin.ts +71 -7
package/src/cli/main.ts
CHANGED
|
@@ -46,6 +46,7 @@ import { autonomyHomeStatus, usedClaudeHomes } from "./autonomy-homes.ts";
|
|
|
46
46
|
import { shellQuote } from "./shell-quote.ts";
|
|
47
47
|
import { discoverClaudeHomes } from "./claude-homes.ts";
|
|
48
48
|
import { setupClaudeHomes } from "./setup-homes.ts";
|
|
49
|
+
import { setupResearchDefault } from "./setup-research.ts";
|
|
49
50
|
import { registerAconPlugin } from "./acon-register.ts";
|
|
50
51
|
import { petView, readPet, renderPet } from "./pet.ts";
|
|
51
52
|
import { PET_WINDOW_RETIRED_NOTICE, petPalette } from "../pet/config.ts";
|
|
@@ -76,7 +77,8 @@ import { inspectProject, startProject, stopProject, runProjectDaemon } from "../
|
|
|
76
77
|
import { processLiveness, processSignature } from "../pi/process-signature.ts";
|
|
77
78
|
import { openManager, startManager, stopManager } from "../hub/manager.ts";
|
|
78
79
|
import { OmniRoute } from "../omniroute/client.ts";
|
|
79
|
-
import { autonomyInheritanceChange, init, initSettingRows, planInit } from "./init.ts";
|
|
80
|
+
import { autonomyInheritanceChange, init, initNextSteps, initResearchDefault, withInitResearch, initSettingRows, planInit } from "./init.ts";
|
|
81
|
+
import { discoverInitChecks, withInitChecks } from "./init-required-checks.ts";
|
|
80
82
|
import { INIT_USAGE, parseInitSettings } from "./init-settings.ts";
|
|
81
83
|
import { promptGate, runInitPrompt, settingLines, shadowOffered, type InitAnswers } from "./init-prompt.ts";
|
|
82
84
|
import { loadPacks } from "../hub/packs.ts";
|
|
@@ -1065,9 +1067,13 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1065
1067
|
recoveryLauncherCurrent?.();
|
|
1066
1068
|
assertLifecycleAvailable(cwd);
|
|
1067
1069
|
const root = join(import.meta.dir, "..", "..");
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
+
if (args.includes("--research") && args.includes("--no-research")) fail("--research conflicts with --no-research; give one; nothing was written");
|
|
1071
|
+
const research = args.includes("--research") ? true : args.includes("--no-research") ? false : undefined;
|
|
1072
|
+
const setupFlags = takeFlags(args.filter(arg => !["--yes", "--research", "--no-research"].includes(arg)), ["--agents"], []);
|
|
1073
|
+
if (setupFlags.rest.length) fail("usage: ahub setup [--yes] [--agents <a,b>] [--research|--no-research]");
|
|
1074
|
+
if (research !== undefined && (liveTest || delegatedPeer || recoveryLauncherCurrent)) fail("the machine research default requires the person's own ahub setup; nothing was written");
|
|
1070
1075
|
const registry = new Registry(), rl = process.stdin.isTTY ? createInterface({ input: process.stdin, output: process.stdout }) : undefined;
|
|
1076
|
+
let machineRoots = [cwd];
|
|
1071
1077
|
let homesFailed = false, homesFailure: unknown;
|
|
1072
1078
|
try {
|
|
1073
1079
|
const found = recoveryLauncherCurrent || delegatedPeer ? await discoverClaudeHomes({ home: homedir(), env: process.env }) : await usedClaudeHomes(registry, homedir(), process.env);
|
|
@@ -1088,8 +1094,11 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1088
1094
|
...(rl ? { ask: async (prompt: string) => { try { return await rl.question(prompt); } catch { return null; } } } : {}), print: line => console.log(terminalText(line)) });
|
|
1089
1095
|
if (refused) fail(refused);
|
|
1090
1096
|
}
|
|
1097
|
+
if (research !== undefined) machineRoots = [...registry.list().map(row => row.root), cwd];
|
|
1091
1098
|
} finally { registry.close(); rl?.close(); }
|
|
1092
1099
|
if (homesFailed) fail(startupDiagnostic(homesFailure));
|
|
1100
|
+
try { if (research !== undefined) assertLifecycleAvailable(cwd); const line = setupResearchDefault(hubHome(), machineRoots, research); if (line) console.log(terminalText(line)); }
|
|
1101
|
+
catch (error) { return fail((error as Error).message); }
|
|
1093
1102
|
// #935: register the acon console plugin (acon reads it at its next start; no acon install is needed for this).
|
|
1094
1103
|
const acon = registerAconPlugin(hubHome(), join(root, "src", "ui", "plugin.ts"));
|
|
1095
1104
|
console.log("error" in acon ? `acon plugin not registered: ${acon.error}` : acon.changed ? `acon plugin registered: ${acon.path}` : `acon plugin up to date: ${acon.path}`);
|
|
@@ -1106,6 +1115,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1106
1115
|
// A pack is a project file in .agenthub/roles/<name>.pack.json (#513a); init resolves the name and refuses an unknown one with the profiles and packs it knows.
|
|
1107
1116
|
let requestedProfile = flags.one["--profile"];
|
|
1108
1117
|
const newProject = !existsSync(join(cwd, ".agenthub/config.json"));
|
|
1118
|
+
const initMachine = newProject ? readAutonomyDefaults(hubHome(), [cwd]) : undefined;
|
|
1109
1119
|
let request = settings.request, asked = Object.keys(request.values).length > 0;
|
|
1110
1120
|
let shadow = args.includes("--shadow"), releaseGuard = args.includes("--release-guard");
|
|
1111
1121
|
// #1065 T2: a person at a terminal on a new project, with no flag that sets anything and no --yes, is asked each setting (init-prompt.ts). Every other run, including a delegated peer, a live test and any run
|
|
@@ -1118,8 +1128,9 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1118
1128
|
const ask = (question: string): Promise<string | null> => Promise.race([rl.question(question).catch(() => null), interrupted]);
|
|
1119
1129
|
const machine = readAutonomyDefaults(hubHome(), [cwd]);
|
|
1120
1130
|
const preview = (answers: InitAnswers): string[] => {
|
|
1121
|
-
const
|
|
1122
|
-
const
|
|
1131
|
+
const planned = withInitResearch(cwd, answers.request, initMachine?.researchEnabled);
|
|
1132
|
+
const rows = initSettingRows(cwd, answers.profile, answers.shadow, answers.releaseGuard, planned);
|
|
1133
|
+
const plan = planInit(cwd, answers.profile, answers.shadow, answers.releaseGuard, planned);
|
|
1123
1134
|
// The same autonomy-inheritance row `--dry-run` shows, from the one helper: a new project inherits the trusted machine preset after the writes unless the answer was off.
|
|
1124
1135
|
const inherit = autonomyInheritanceChange(cwd, machine.enabled, answers.request.autonomy);
|
|
1125
1136
|
if (inherit) plan.push(inherit);
|
|
@@ -1128,11 +1139,13 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1128
1139
|
let result: Awaited<ReturnType<typeof runInitPrompt>>;
|
|
1129
1140
|
try {
|
|
1130
1141
|
result = await runInitPrompt({ ask, print: line => console.log(terminalText(line)) },
|
|
1131
|
-
{ ...(machine.startAgents ? { machineAgents: machine.startAgents } : {}), packs: [...loadPacks(cwd).packs.keys()], shadowAvailable: shadowOffered(repoOf(cwd)) }, preview);
|
|
1142
|
+
{ ...(machine.startAgents ? { machineAgents: machine.startAgents } : {}), machineResearch: initResearchDefault(cwd, initMachine?.researchEnabled), packs: [...loadPacks(cwd).packs.keys()], discoverChecks: async () => (await discoverInitChecks(cwd)).names, shadowAvailable: shadowOffered(repoOf(cwd)) }, preview);
|
|
1132
1143
|
} finally { rl.close(); }
|
|
1133
1144
|
if (!result.ok) { console.error(`ahub init: ${result.reason === "refused" ? result.message : result.reason === "interrupted" ? `interrupted; ${result.message}` : result.message}`); process.exitCode = result.reason === "refused" ? 1 : 0; return; }
|
|
1134
1145
|
requestedProfile = result.answers.profile; request = result.answers.request; asked = Object.keys(request.values).length > 0; shadow = result.answers.shadow; releaseGuard = result.answers.releaseGuard;
|
|
1135
1146
|
}
|
|
1147
|
+
request = withInitResearch(cwd, request, initMachine?.researchEnabled);
|
|
1148
|
+
try { request = await withInitChecks(cwd, request); } catch (error) { return fail((error as Error).message); }
|
|
1136
1149
|
// `--autonomy off` skips the machine inheritance on a new project; `inherit` is today's behaviour. Neither changes an existing project.
|
|
1137
1150
|
const inheritAutonomy = newProject && request.autonomy !== "off";
|
|
1138
1151
|
if (!newProject && request.autonomy !== undefined) console.error("note: --autonomy applies to a new project only; this project already exists, so its autonomy settings are unchanged");
|
|
@@ -1150,8 +1163,8 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1150
1163
|
}
|
|
1151
1164
|
assertLifecycleAvailable(cwd);
|
|
1152
1165
|
if (inheritAutonomy && delegatedPeer && readAutonomyDefaults(hubHome(), [cwd]).enabled) fail("machine autonomy inheritance is person-only; delegated live tests cannot apply it (ahub init --autonomy off skips it)");
|
|
1153
|
-
let changed: string[];
|
|
1154
|
-
try { changed = init(cwd, requestedProfile, shadow, releaseGuard, request); } catch (error) { return fail((error as Error).message); }
|
|
1166
|
+
let changed: string[], nextSteps: string[];
|
|
1167
|
+
try { nextSteps = initNextSteps(cwd, request); changed = init(cwd, requestedProfile, shadow, releaseGuard, request); } catch (error) { return fail((error as Error).message); }
|
|
1155
1168
|
const project = registeredProject();
|
|
1156
1169
|
console.log(changed.length ? changed.map((p) => `${existsSync(p) ? "wrote" : "removed"} ${p}`).join("\n") : "already up to date");
|
|
1157
1170
|
if (newProject) {
|
|
@@ -1165,6 +1178,7 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1165
1178
|
}
|
|
1166
1179
|
const config = projectConfig(), examples = resolveProfile(config.profile, config.profile_overrides).example_checks;
|
|
1167
1180
|
if (examples.length) console.log(terminalText("Example checks (advisory):\n" + examples.map(example => "- " + example).join("\n")));
|
|
1181
|
+
console.log(nextSteps.join("\n"));
|
|
1168
1182
|
},
|
|
1169
1183
|
|
|
1170
1184
|
// Internal: the detached daemon process started by ahub up or the manager.
|
|
@@ -1225,6 +1239,71 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1225
1239
|
return entry.execute(context);
|
|
1226
1240
|
}])),
|
|
1227
1241
|
|
|
1242
|
+
guidance: async () => {
|
|
1243
|
+
const { parseGuidanceCommand, validateGuidancePageReply, validateGuidanceDiffReply, validateGuidanceReceipt, renderGuidance, renderGuidanceReceipt } = await import("./guidance.ts");
|
|
1244
|
+
const { parseGuidanceVariantV1, GUIDANCE_RECORD_MAX_BYTES } = await import("../hub/guidance-variants.ts");
|
|
1245
|
+
let command; try { command = parseGuidanceCommand(args); } catch (error) { return fail((error as Error).message); }
|
|
1246
|
+
if (liveTest && (command.op === "create" || command.op === "withdraw")) return fail("live-test cannot write guidance declarations as the person; use the current task actor without --live-test");
|
|
1247
|
+
let variant: ReturnType<typeof parseGuidanceVariantV1> | undefined;
|
|
1248
|
+
if (command.op === "create") {
|
|
1249
|
+
try {
|
|
1250
|
+
const fd = openSync(resolve(invokedFrom, command.file), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
|
|
1251
|
+
try {
|
|
1252
|
+
if (!fstatSync(fd).isFile()) return fail("the guidance file must be a bounded regular JSON file");
|
|
1253
|
+
const bytes = Buffer.alloc(GUIDANCE_RECORD_MAX_BYTES + 1); let got = 0;
|
|
1254
|
+
while (got < bytes.length) { const read = readSync(fd, bytes, got, bytes.length - got, null); if (!read) break; got += read; }
|
|
1255
|
+
if (got > GUIDANCE_RECORD_MAX_BYTES) return fail("the guidance file exceeds the 32 KiB input bound");
|
|
1256
|
+
variant = parseGuidanceVariantV1(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, got))));
|
|
1257
|
+
} finally { closeSync(fd); }
|
|
1258
|
+
} catch { return fail("cannot read a valid bounded GuidanceVariantV1 file; check its shape, content id and protected role bytes"); }
|
|
1259
|
+
}
|
|
1260
|
+
const hub = await connect();
|
|
1261
|
+
try {
|
|
1262
|
+
if (!hub.features.includes("guidance_views")) return fail("running hub lacks guidance_views; upgrade and restart the hub and refresh the client plugin, then retry ahub guidance");
|
|
1263
|
+
const { op, json, ...fields } = command;
|
|
1264
|
+
const message = op === "create" ? { variant } : fields;
|
|
1265
|
+
const result = await hub.request({ t: `guidance_${op}`, ...message });
|
|
1266
|
+
if (result.ok !== true) return fail(`${terminalText(result.error ?? "guidance request is unconfirmed").replace(/[\r\n]+/g, " ").slice(0, 512)}; inspect ahub guidance list for the task before explicitly retrying a write`, result.refusalAudited === true, result.authorityRefused);
|
|
1267
|
+
const options = { json };
|
|
1268
|
+
if (command.op === "create" || command.op === "withdraw") {
|
|
1269
|
+
let receipt;
|
|
1270
|
+
try { receipt = validateGuidanceReceipt(result.receipt, command.op === "create" ? { id: variant!.id, taskId: variant!.taskId } : { id: command.id, taskId: command.taskId, status: "withdrawn" }); }
|
|
1271
|
+
catch (error) { return fail((error as Error).message); }
|
|
1272
|
+
if (options.json) console.log(JSON.stringify(receipt, null, 2)); else console.log(renderGuidanceReceipt(receipt).join("\n"));
|
|
1273
|
+
} else {
|
|
1274
|
+
let page;
|
|
1275
|
+
try { page = command.op === "list" ? validateGuidancePageReply(result.guidance, command) : validateGuidanceDiffReply(result.guidance, command); }
|
|
1276
|
+
catch { return fail("guidance reply is unavailable or malformed; refresh the task scope and upgrade the hub/client before retrying"); }
|
|
1277
|
+
if (options.json) console.log(JSON.stringify(page, null, 2)); else console.log(renderGuidance(page).join("\n"));
|
|
1278
|
+
}
|
|
1279
|
+
} finally { hub.close(); }
|
|
1280
|
+
},
|
|
1281
|
+
|
|
1282
|
+
lineage: async () => {
|
|
1283
|
+
const { parseLineageCommand, renderExecutionLineage, validateLineageReply, validateLineageLink } = await import("./lineage.ts");
|
|
1284
|
+
let command;
|
|
1285
|
+
try { command = parseLineageCommand(args); } catch (error) { return fail((error as Error).message); }
|
|
1286
|
+
if (liveTest && command.op === "link") return fail("live-test cannot register execution links; retry without --live-test as the task's authorized actor");
|
|
1287
|
+
const hub = await connect();
|
|
1288
|
+
try {
|
|
1289
|
+
if (!hub.features.includes("execution_lineage")) return fail("running hub lacks execution_lineage support; upgrade and restart the hub, then retry ahub lineage");
|
|
1290
|
+
const { op, json, ...message } = command;
|
|
1291
|
+
const result = await hub.request({ t: op === "show" ? "lineage_show" : "lineage_link", ...message });
|
|
1292
|
+
if (result.ok !== true) return fail(`${terminalText(result.error ?? "lineage request refused").replace(/[\r\n]+/g, " ").slice(0, 512)}; check task scope, current flow revision and source access before retrying ahub lineage`, result.refusalAudited === true, result.authorityRefused);
|
|
1293
|
+
const options = { json };
|
|
1294
|
+
if (op === "show") {
|
|
1295
|
+
let lineage;
|
|
1296
|
+
try { lineage = validateLineageReply(result.lineage); } catch (error) { return fail((error as Error).message); }
|
|
1297
|
+
if (options.json) console.log(JSON.stringify(lineage, null, 2));
|
|
1298
|
+
else console.log(renderExecutionLineage(lineage).join("\n"));
|
|
1299
|
+
} else {
|
|
1300
|
+
let link;
|
|
1301
|
+
try { link = validateLineageLink(result.link, command); } catch (error) { return fail((error as Error).message); }
|
|
1302
|
+
if (options.json) console.log(JSON.stringify(link, null, 2));
|
|
1303
|
+
else console.log(`Declared execution metadata link ${link.already ? "already registered" : "registered"} for task #${link.taskId}; this does not attest to producer execution.`);
|
|
1304
|
+
}
|
|
1305
|
+
} finally { hub.close(); }
|
|
1306
|
+
},
|
|
1228
1307
|
model: async () => {
|
|
1229
1308
|
const { parseModelCommand, projectModelStatus } = await import("./model.ts");
|
|
1230
1309
|
let command;
|
|
@@ -1862,6 +1941,21 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
1862
1941
|
} finally { hub.close(); }
|
|
1863
1942
|
return;
|
|
1864
1943
|
}
|
|
1944
|
+
if (sub === "adopt-merge") {
|
|
1945
|
+
const flags = takeFlags(args.slice(2), ["--pr"], []), pr = Number(flags.one["--pr"]);
|
|
1946
|
+
if (flags.rest.length || !Number.isSafeInteger(id) || id! <= 0 || !Number.isSafeInteger(pr) || pr <= 0) fail("usage: ahub sdlc adopt-merge <task> --pr <n>");
|
|
1947
|
+
const hub = await connect();
|
|
1948
|
+
try {
|
|
1949
|
+
const reply = await hub.request({ t: "sdlc", op: "adopt-merge", id, pr }, 60_000);
|
|
1950
|
+
if (!reply.ok) {
|
|
1951
|
+
const reason = typeof reply.error === "string" ? reply.error : "merge adoption failed without a reason; inspect the hub log and retry ahub sdlc adopt-merge";
|
|
1952
|
+
if (/unknown SDLC operation|does not know|SDLC readback is console only/.test(reason)) fail(`${reason}; the running hub does not support adopt-merge; upgrade agent-hub and run ahub restart before retrying ahub sdlc adopt-merge`);
|
|
1953
|
+
fail(reason);
|
|
1954
|
+
}
|
|
1955
|
+
console.log(`task #${id}: merged outside the hub; approved`);
|
|
1956
|
+
} finally { hub.close(); }
|
|
1957
|
+
return;
|
|
1958
|
+
}
|
|
1865
1959
|
if (sub === "merge") {
|
|
1866
1960
|
// #786 T1: the guarded merge of one approved task; a person or the configured conductor asks, the daemon re-reads every gate.
|
|
1867
1961
|
// #899: the decision prints for a person; `--json` is the same view as a document. The presentation flags are read before the
|
|
@@ -2238,7 +2332,8 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2238
2332
|
if (!Object.hasOwn(allowed, sub) || flags.some((flag) => !allowed[sub]!.includes(flag)) || extra.length) fail(usage);
|
|
2239
2333
|
if ((sub === "get" && (!key || text !== undefined)) || (sub === "set" && (!key || text === undefined)) || ((sub === "list" || sub === "undo" || sub === "reload") && key !== undefined)) fail(usage);
|
|
2240
2334
|
const { scope: settingScope, error: settingScopeError } = localDeclarations();
|
|
2241
|
-
const
|
|
2335
|
+
const sdlcRead = sub === "get" && ["sdlc.mode", "sdlc.required_checks"].includes(key ?? "");
|
|
2336
|
+
const def = key === undefined || sdlcRead ? undefined : settingDef(key, settingScope.instances, settingScope.catalog);
|
|
2242
2337
|
if (typeof def === "string") fail(settingScopeError && def.startsWith("unknown setting") ? `${key}: ${def}; the project config could not be read: ${settingScopeError}` : `${key}: ${def}`);
|
|
2243
2338
|
if (flags.includes("--now") && (typeof def !== "object" || def.group !== "Roster")) fail(usage);
|
|
2244
2339
|
const value = sub === "set" ? parseSettingText(def!, text!) : undefined;
|
|
@@ -2257,6 +2352,12 @@ const commands: Record<string, () => Promise<void> | void> = {
|
|
|
2257
2352
|
}
|
|
2258
2353
|
return reply;
|
|
2259
2354
|
};
|
|
2355
|
+
if (sdlcRead) {
|
|
2356
|
+
const view = await request({ t: "settings_get" }), entry = view.sdlc?.[key!];
|
|
2357
|
+
if (!entry || !Object.hasOwn(entry, "value") || !Object.hasOwn(entry, "fileValue")) fail("running hub lacks SDLC settings reads; upgrade and restart it first");
|
|
2358
|
+
if (flags.includes("--json")) return console.log(JSON.stringify({ key, ...entry }, null, 2));
|
|
2359
|
+
return console.log(terminalText(`${key}: running ${JSON.stringify(entry.value)}; file ${JSON.stringify(entry.fileValue)}${entry.problem ? "; file unavailable" : ""}`));
|
|
2360
|
+
}
|
|
2260
2361
|
if (sub === "reload") {
|
|
2261
2362
|
let result = await request({ t: "settings_reload" });
|
|
2262
2363
|
const confirmation = result.confirmation;
|
|
@@ -3146,7 +3247,7 @@ async function runConductorCommand(): Promise<void> {
|
|
|
3146
3247
|
}
|
|
3147
3248
|
let op: string;
|
|
3148
3249
|
let input: Record<string, unknown>;
|
|
3149
|
-
if (cmd === "sdlc") return commands.sdlc!(); //
|
|
3250
|
+
if (cmd === "sdlc") return commands.sdlc!(); // SDLC operational subcommands are role-checked by the daemon.
|
|
3150
3251
|
if (cmd === "task") {
|
|
3151
3252
|
op = args[0] === "assign" ? "hub_task_assign" : "hub_task_escalate";
|
|
3152
3253
|
const { one, rest: positional } = takeFlags(args.slice(1), args[0] === "assign" ? ["--role"] : [], []);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { readAutonomyDefaults, writeMachineResearch } from "../hub/autonomy-defaults.ts";
|
|
2
|
+
|
|
3
|
+
/** Explicit person-only setup choice. Ordinary setup neither reads nor writes the research default. */
|
|
4
|
+
export function setupResearchDefault(home: string, roots: readonly string[], enabled: boolean | undefined): string | undefined {
|
|
5
|
+
if (enabled === undefined) return undefined;
|
|
6
|
+
const held = readAutonomyDefaults(home, roots);
|
|
7
|
+
try { writeMachineResearch(home, enabled, held.fingerprint, roots); }
|
|
8
|
+
catch { throw new Error("Research default was not saved: defaults.json is unsafe or changed; check its ownership, mode and schema, then rerun ahub setup --research or --no-research."); }
|
|
9
|
+
return `Research records for new projects: ${enabled ? "on" : "off"} (saved in this machine's defaults; ahub init inherits it). Upgrade every hub and CLI on this machine to 0.36 or later first: a version from before 0.36 treats the whole file as untrusted, so its machine autonomy preset falls back to off and its start-agent default to the shipped one.`;
|
|
10
|
+
}
|
|
@@ -6,7 +6,7 @@ import { insideRoot } from "./path-policy.ts";
|
|
|
6
6
|
import { checkStartAgents } from "./start-agents.ts";
|
|
7
7
|
|
|
8
8
|
/** `startAgents` is the machine default of `start.agents` (#608), present only when `ahub setup` chose one. */
|
|
9
|
-
export interface AutonomyDefaultsRead { enabled: boolean; fingerprint: string; notice?: string; startAgents?: string[] }
|
|
9
|
+
export interface AutonomyDefaultsRead { enabled: boolean; fingerprint: string; notice?: string; startAgents?: string[]; researchEnabled?: boolean }
|
|
10
10
|
const MAX_BYTES = 4096;
|
|
11
11
|
const same = (a: Stats, b: Stats) => a.dev === b.dev && a.ino === b.ino && a.size === b.size && a.mtimeMs === b.mtimeMs && a.ctimeMs === b.ctimeMs;
|
|
12
12
|
const refusal = () => new Error("machine autonomy defaults are unsafe or changed; nothing was written");
|
|
@@ -32,12 +32,12 @@ function capture(home: string, roots: readonly string[]): { stat?: Stats; text?:
|
|
|
32
32
|
return { stat: after, text, fingerprint: createHash("sha256").update(`${after.dev}:${after.ino}:${after.ctimeMs}:`).update(text).digest("hex") };
|
|
33
33
|
} finally { closeSync(fd); }
|
|
34
34
|
}
|
|
35
|
-
interface DefaultsDocument { autonomy?: boolean; startAgents?: string[] }
|
|
36
|
-
/** The file's content, or the refusal. `{schema:1}` alone and any key but schema, autonomy and
|
|
35
|
+
interface DefaultsDocument { autonomy?: boolean; startAgents?: string[]; researchEnabled?: boolean }
|
|
36
|
+
/** The file's content, or the refusal. `{schema:1}` alone and any key but schema, autonomy, start and research are refused. */
|
|
37
37
|
function parseDefaults(text: string): DefaultsDocument {
|
|
38
38
|
const raw: unknown = JSON.parse(text);
|
|
39
39
|
const document = raw && typeof raw === "object" && !Array.isArray(raw) ? raw as Record<string, unknown> : undefined;
|
|
40
|
-
if (!document || Object.keys(document).some(key => !["schema", "autonomy", "start"].includes(key)) || document.schema !== 1) throw refusal();
|
|
40
|
+
if (!document || Object.keys(document).some(key => !["schema", "autonomy", "start", "research"].includes(key)) || document.schema !== 1) throw refusal();
|
|
41
41
|
if (document.autonomy !== undefined && typeof document.autonomy !== "boolean") throw refusal();
|
|
42
42
|
let startAgents: string[] | undefined;
|
|
43
43
|
if (document.start !== undefined) {
|
|
@@ -45,8 +45,14 @@ function parseDefaults(text: string): DefaultsDocument {
|
|
|
45
45
|
if (!start || typeof start !== "object" || Array.isArray(start) || Object.keys(start).some(key => key !== "agents")) throw refusal();
|
|
46
46
|
try { startAgents = checkStartAgents((start as Record<string, unknown>).agents); } catch { throw refusal(); }
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
let researchEnabled: boolean | undefined;
|
|
49
|
+
if (document.research !== undefined) {
|
|
50
|
+
const research = document.research;
|
|
51
|
+
if (!research || typeof research !== "object" || Array.isArray(research) || Object.keys(research).some(key => key !== "enabled") || typeof (research as Record<string, unknown>).enabled !== "boolean") throw refusal();
|
|
52
|
+
researchEnabled = (research as { enabled: boolean }).enabled;
|
|
53
|
+
}
|
|
54
|
+
if (document.autonomy === undefined && startAgents === undefined && researchEnabled === undefined) throw refusal();
|
|
55
|
+
return { ...(document.autonomy === undefined ? {} : { autonomy: document.autonomy }), ...(startAgents ? { startAgents } : {}), ...(researchEnabled === undefined ? {} : { researchEnabled }) };
|
|
50
56
|
}
|
|
51
57
|
/** Missing or untrusted machine files never change the shipped ask default. */
|
|
52
58
|
export function readAutonomyDefaults(home: string, roots: readonly string[] = []): AutonomyDefaultsRead {
|
|
@@ -54,17 +60,22 @@ export function readAutonomyDefaults(home: string, roots: readonly string[] = []
|
|
|
54
60
|
const held = capture(home, roots);
|
|
55
61
|
if (held.text === undefined) return { enabled: false, fingerprint: held.fingerprint };
|
|
56
62
|
const document = parseDefaults(held.text);
|
|
57
|
-
return { enabled: document.autonomy === true, fingerprint: held.fingerprint, ...(document.startAgents ? { startAgents: document.startAgents } : {}) };
|
|
63
|
+
return { enabled: document.autonomy === true, fingerprint: held.fingerprint, ...(document.startAgents ? { startAgents: document.startAgents } : {}), ...(document.researchEnabled === undefined ? {} : { researchEnabled: document.researchEnabled }) };
|
|
58
64
|
} catch { return { enabled: false, fingerprint: "untrusted", notice: "Machine autonomy defaults ignored: defaults.json must be an owner-only regular file with a valid schema, outside project roots." }; }
|
|
59
65
|
}
|
|
60
66
|
/** Person CLI only. Exact prior evidence is rechecked after confirmation and before replacement. The other half of the file (the start set) is kept. */
|
|
61
67
|
export function writeAutonomyDefaults(home: string, enabled: boolean, expected: string, roots: readonly string[] = []): void {
|
|
62
|
-
writeDefaults(home, expected, roots, kept => ({ schema: 1, autonomy: enabled, ...(kept.startAgents ? { start: { agents: kept.startAgents } } : {}) }));
|
|
68
|
+
writeDefaults(home, expected, roots, kept => ({ schema: 1, autonomy: enabled, ...(kept.startAgents ? { start: { agents: kept.startAgents } } : {}), ...(kept.researchEnabled === undefined ? {} : { research: { enabled: kept.researchEnabled } }) }));
|
|
63
69
|
}
|
|
64
70
|
/** Person CLI only (`ahub setup`): the machine default of `start.agents`. The autonomy half of the file is kept, and absent stays absent. */
|
|
65
71
|
export function writeMachineStartAgents(home: string, agents: readonly string[], expected: string, roots: readonly string[] = []): void {
|
|
66
72
|
const checked = checkStartAgents([...agents]);
|
|
67
|
-
writeDefaults(home, expected, roots, kept => ({ schema: 1, ...(kept.autonomy === undefined ? {} : { autonomy: kept.autonomy }), start: { agents: checked } }));
|
|
73
|
+
writeDefaults(home, expected, roots, kept => ({ schema: 1, ...(kept.autonomy === undefined ? {} : { autonomy: kept.autonomy }), start: { agents: checked }, ...(kept.researchEnabled === undefined ? {} : { research: { enabled: kept.researchEnabled } }) }));
|
|
74
|
+
}
|
|
75
|
+
/** Person CLI only (`ahub setup --research|--no-research`); preserve autonomy and the chosen agent set. */
|
|
76
|
+
export function writeMachineResearch(home: string, enabled: boolean, expected: string, roots: readonly string[] = []): void {
|
|
77
|
+
if (typeof enabled !== "boolean") throw refusal();
|
|
78
|
+
writeDefaults(home, expected, roots, kept => ({ schema: 1, ...(kept.autonomy === undefined ? {} : { autonomy: kept.autonomy }), ...(kept.startAgents ? { start: { agents: kept.startAgents } } : {}), research: { enabled } }));
|
|
68
79
|
}
|
|
69
80
|
function writeDefaults(home: string, expected: string, roots: readonly string[], build: (kept: DefaultsDocument) => Record<string, unknown>): void {
|
|
70
81
|
const before = capture(home, roots);
|