@staix/agent-hub 0.52.0 → 0.54.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 +37 -0
- package/README.md +4 -3
- package/docs/addons/open-code-review.md +3 -6
- package/docs/agent-notes/README.md +1 -1
- package/docs/agent-notes/adapters.md +5 -4
- package/docs/agent-notes/budget.md +2 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +6 -5
- package/docs/agent-notes/models.md +1 -1
- package/docs/agent-notes/tasks.md +3 -3
- package/docs/agent-notes/tests.md +4 -4
- package/docs/contracts/companion-cli-v2.json +90 -0
- package/docs/contracts/companion-cli-v3.json +348 -0
- package/docs/design/adapters.md +1 -1
- package/docs/design/agent-hub-architecture.md +8 -5
- package/docs/design/bus.md +1 -1
- package/docs/design/cli-output-inventory.md +4 -2
- package/docs/design/execution-reference.md +1 -1
- package/docs/design/guidance-experiments.md +1 -0
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/model-routes.md +20 -5
- package/docs/design/roadmap.md +6 -4
- package/docs/design/task-board.md +21 -2
- package/docs/dogfood.md +13 -6
- package/docs/events.md +1 -1
- package/docs/memory.md +2 -2
- package/docs/operations.md +158 -50
- package/docs/quickstart.md +14 -2
- package/docs/security.md +17 -9
- package/docs/specs/2026-09-19-agent-hub-design.md +5 -3
- package/docs/specs/2026-09-19-multi-project-design.md +1 -1
- package/docs/specs/2026-09-20-upgrade-recovery-design.md +24 -0
- package/docs/specs/2026-12-04-arev-adoption-design.md +84 -0
- package/docs/specs/mcp-endpoint.md +15 -4
- package/docs/specs/relay-contract.md +38 -0
- package/docs/verification/2026-12-04-host-shared-receipts.md +43 -0
- package/docs/verification/2026-12-05-0.53.0.md +101 -0
- package/docs/verification/2026-12-05-agy-1.5.24.md +55 -0
- package/docs/verification/2026-12-05-claude-implementer-2.1.337.md +43 -0
- package/docs/verification/2026-12-06-0.54.0.md +76 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-isolation.md +43 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-tool-call.md +34 -0
- package/docs/verification/2026-12-06-compat-codex-capabilities-0.174.0.md +25 -0
- package/docs/verification/2026-12-06-compat-pi-1.8.0.md +23 -0
- package/docs/verified.json +38 -29
- package/package.json +9 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/.mcp.json +1 -1
- package/plugins/agent-hub/compat.json +9 -5
- package/plugins/agent-hub/kimi-hook.js +892 -874
- package/plugins/agent-hub/relay-launcher.js +24 -0
- package/plugins/agent-hub/server.js +27271 -25146
- package/src/adapters/acp-session-model.ts +1 -1
- package/src/adapters/acp.ts +5 -4
- package/src/adapters/agy/definition.ts +1 -1
- package/src/adapters/agy/hooks.ts +1 -1
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel-evidence.ts +26 -1
- package/src/adapters/claude-channel.ts +27 -30
- package/src/adapters/claude-connection-policy.ts +62 -0
- package/src/adapters/claude-relay.ts +255 -0
- package/src/adapters/codex-review-isolation.ts +1 -2
- package/src/adapters/compat.ts +28 -18
- package/src/adapters/definitions/native-cli-preview-pi.ts +2 -1
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-context.ts +1 -2
- package/src/adapters/definitions/native-factories.ts +4 -1
- package/src/adapters/definitions/native-quota.ts +1 -1
- package/src/adapters/definitions/native-recovery.ts +3 -1
- package/src/adapters/external-modules.ts +2 -2
- package/src/adapters/kimi-review.ts +1 -1
- package/src/adapters/kimi-tui-facts.ts +1 -1
- package/src/adapters/local-worker.ts +3 -3
- package/src/adapters/native-capabilities.ts +1 -1
- package/src/adapters/pi.ts +26 -7
- package/src/adapters/registry-types.ts +2 -0
- package/src/adapters/relay-launcher.ts +27 -0
- package/src/adapters/reviewer-mcp.ts +1 -1
- package/src/cli/agents.ts +20 -8
- package/src/cli/agy-mcp.ts +1 -1
- package/src/cli/claude-profile-hook.ts +1 -1
- package/src/cli/command-table.ts +1 -0
- package/src/cli/commands/agents.ts +18 -1
- package/src/cli/commands/doctor.ts +18 -4
- package/src/cli/commands/launch-line.ts +32 -0
- package/src/cli/commands/status.ts +14 -3
- package/src/cli/help.ts +7 -4
- package/src/cli/identity.ts +1 -1
- package/src/cli/init-roles.ts +1 -1
- package/src/cli/init-settings.ts +1 -1
- package/src/cli/launch-line-plan.ts +82 -0
- package/src/cli/launch-line-project.ts +13 -0
- package/src/cli/main.ts +10 -9
- package/src/cli/pi-steps-warning.ts +14 -0
- package/src/cli/recovery-package.ts +60 -6
- package/src/cli/reset.ts +1 -1
- package/src/cli/shell-quote.ts +1 -3
- package/src/cli/upgrade-interactive.ts +7 -2
- package/src/cli/upgrade-keep-plan.ts +47 -0
- package/src/cli/upgrade-restore-state.ts +1 -1
- package/src/cli/upgrade-runtime.ts +119 -18
- package/src/cli/upgrade.ts +17 -2
- package/src/hub/accounts.ts +8 -4
- package/src/hub/action-class.ts +1 -3
- package/src/hub/adec-triage.ts +105 -0
- package/src/hub/autonomy.ts +1 -1
- package/src/hub/board.ts +3 -27
- package/src/hub/bus.ts +39 -6
- package/src/hub/capabilities.ts +1 -1
- package/src/hub/channel-project-base.ts +46 -0
- package/src/hub/channel-project.ts +21 -46
- package/src/hub/config-apply.ts +1 -1
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +1 -1
- package/src/hub/config.ts +2 -2
- package/src/hub/confirmation-matrix.ts +1 -1
- package/src/hub/control/board-messages.ts +415 -0
- package/src/hub/control/dashboard-messages.ts +221 -0
- package/src/hub/control/delivery-messages.ts +356 -0
- package/src/hub/control/dispatch.ts +114 -0
- package/src/hub/control/hub-tool-helpers.ts +243 -0
- package/src/hub/control/hub-tools.ts +147 -0
- package/src/hub/control/native-messages.ts +665 -0
- package/src/hub/control/operations-messages.ts +269 -0
- package/src/hub/control/peer-messages.ts +126 -0
- package/src/hub/control/recovery-messages.ts +391 -0
- package/src/hub/control/recovery-operation.ts +480 -0
- package/src/hub/control/scope.ts +460 -0
- package/src/hub/control/sdlc-messages.ts +373 -0
- package/src/hub/control/task-ops-more.ts +245 -0
- package/src/hub/control/task-ops.ts +553 -0
- package/src/hub/control/ui-actions.ts +241 -0
- package/src/hub/control-write-trace.ts +1 -4
- package/src/hub/daemon.ts +485 -4324
- package/src/hub/delivery-hints.ts +2 -0
- package/src/hub/delivery-journal.ts +17 -6
- package/src/hub/events.ts +2 -1
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/host.ts +41 -9
- package/src/hub/hub-tools.ts +3 -4
- package/src/hub/invocations.ts +1 -1
- package/src/hub/lifecycle.ts +4 -3
- package/src/hub/mcp-endpoint-serve.ts +4 -3
- package/src/hub/mcp-endpoint.ts +15 -6
- package/src/hub/memory-profile-check.ts +1 -1
- package/src/hub/no-writes.ts +1 -1
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-exit-policy.ts +27 -0
- package/src/hub/progress.ts +1 -1
- package/src/hub/project-runtime-state.ts +17 -4
- package/src/hub/project-runtime.ts +3 -1
- package/src/hub/protocol-window.ts +1 -1
- package/src/hub/recovery-continuity.ts +3 -3
- package/src/hub/recovery-kept-roster.ts +50 -0
- package/src/hub/review-anchor.ts +13 -181
- package/src/hub/review-brief.ts +78 -28
- package/src/hub/review-findings.ts +15 -193
- package/src/hub/review-ledger.ts +162 -0
- package/src/hub/review-material.ts +3 -3
- package/src/hub/reviewer-pool.ts +4 -2
- package/src/hub/roadmap-issue-states.ts +65 -14
- package/src/hub/roadmap-sync.ts +39 -14
- package/src/hub/routing.ts +9 -0
- package/src/hub/runtime-capture-prune.ts +8 -2
- package/src/hub/runtime-package-assets.ts +3 -0
- package/src/hub/sdlc-release-policy.ts +1 -2
- package/src/hub/settings.ts +1 -1
- package/src/hub/spec-ack-tool.ts +4 -0
- package/src/hub/spec-report-history.ts +36 -0
- package/src/hub/specs.ts +1 -4
- package/src/hub/supervision.ts +33 -6
- package/src/hub/tasks-audit.ts +390 -0
- package/src/hub/tasks-backlog.ts +522 -0
- package/src/hub/tasks-handoff.ts +208 -0
- package/src/hub/tasks-release.ts +257 -0
- package/src/hub/tasks-roadmap.ts +17 -3
- package/src/hub/tasks-specs.ts +672 -0
- package/src/hub/tasks-types.ts +334 -0
- package/src/hub/tasks.ts +286 -1961
- package/src/hub/upgrade-session-contract.ts +11 -0
- package/src/local/probe-sandbox.ts +1 -2
- package/src/local/probe-workspace.ts +1 -1
- package/src/models/route/config.ts +4 -4
- package/src/models/route/decision.ts +18 -10
- package/src/models/route/observation-signals.ts +1 -2
- package/src/models/route/runtime.ts +8 -5
- package/src/npm-artifact.ts +76 -0
- package/src/omniroute/client.ts +6 -0
- package/src/pi/extension.ts +5 -2
- package/src/pi/install.ts +77 -0
- package/src/pi/pin.ts +49 -0
- package/src/primitives.ts +14 -0
- package/src/version.ts +2 -0
- package/templates/adec/README.md +10 -6
- package/templates/config.json +1 -1
- package/templates/specs.block.md +1 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
// #1830 S2a: the second half of the `hub_*` dispatch, moved unchanged from taskOpBody in src/hub/daemon.ts.
|
|
2
|
+
import { isFixedBuiltinDefinition } from "../../adapters/registry.ts";
|
|
3
|
+
import { type TaskClass } from "../board.ts";
|
|
4
|
+
import { readShare, shareView } from "../capabilities.ts";
|
|
5
|
+
import { USER, sanitize, type PeerId } from "../envelope.ts";
|
|
6
|
+
import { readInstanceRoleConfig } from "../instance-config.ts";
|
|
7
|
+
import { effectiveInstanceRoles, instanceDefinitionOf } from "../instances.ts";
|
|
8
|
+
import { FOLLOWUP_DEFAULTS } from "../learn-followup.ts";
|
|
9
|
+
import { withChecklistLine, withoutChecklistLine } from "../learning.ts";
|
|
10
|
+
import { MEMORY_REVIEW_DEFAULTS, MEMORY_REVIEW_SCHEDULE_ID } from "../memory-review.ts";
|
|
11
|
+
import { CONDUCTOR_TASK_OPS } from "../operational-authority.ts";
|
|
12
|
+
import { profileName, resolveProfile } from "../profiles.ts";
|
|
13
|
+
import { scheduleViews } from "../schedules.ts";
|
|
14
|
+
import { LEARN_CHECKLIST, writeConfigSetting } from "../settings.ts";
|
|
15
|
+
import { PreEffectToolRefusal } from "../tool-refusal.ts";
|
|
16
|
+
import type { Sock } from "../daemon.ts";
|
|
17
|
+
import type { DaemonScope } from "./scope.ts";
|
|
18
|
+
|
|
19
|
+
export async function taskOpPart2(scope: DaemonScope, by: PeerId, op: string, a: Record<string, any>, inProcess: boolean, piiTurn: boolean, toolSocket: Sock | undefined, onPrem: boolean, line: (t: { id: number; state: string; owner: PeerId | null; reviewer: PeerId | null }) => string, need: (cap: "propose" | "assign" | "remember" | "memory_read" | "memory_correct" | "spec_read" | "check_run" | "invoke", what: string) => void): Promise<string> {
|
|
20
|
+
switch (op) {
|
|
21
|
+
case "release_new":
|
|
22
|
+
return JSON.stringify(await scope.tasks.newRelease(by, { name: a.name, goal: a.goal, order: a.order }));
|
|
23
|
+
case "claim_verdict": { // #901: same person-only record; a synthesis descriptor is validated transiently, never retained.
|
|
24
|
+
const claim = { slot: a.slot, verdict: a.verdict, ...(a.model === undefined ? {} : { model: a.model }), ...(a.modelVerdict === undefined ? {} : { modelVerdict: a.modelVerdict }), ...(a.synthesis === undefined ? {} : { synthesis: a.synthesis }) };
|
|
25
|
+
const task = a.synthesis === undefined ? scope.tasks.recordClaimVerdict(by, a.id, claim) : await scope.tasks.recordSynthesisClaimVerdict(by, a.id, claim, a.manifest);
|
|
26
|
+
return JSON.stringify({ task: task.id, recorded: task.history.at(-1)?.claim });
|
|
27
|
+
}
|
|
28
|
+
case "github_import":
|
|
29
|
+
return JSON.stringify(await scope.tasks.importGitHub(by, { repo: a.repo, label: a.label, milestone: a.milestone }));
|
|
30
|
+
// R3 (#1481): not in CONDUCTOR_TASK_OPS on purpose: only the person imports GitHub milestones, and a dry run is the default.
|
|
31
|
+
case "roadmap_import_github":
|
|
32
|
+
return JSON.stringify(await scope.tasks.roadmapImportGitHub(by, { repo: a.repo, apply: a.apply }));
|
|
33
|
+
case "roadmap_sync_apply":
|
|
34
|
+
if (!a || typeof a !== "object" || Array.isArray(a) || Object.keys(a).some(key => !["apply", "confirm"].includes(key)) || a.apply !== true) throw new PreEffectToolRefusal("invalid roadmap sync operation; preview before applying");
|
|
35
|
+
return JSON.stringify(await scope.tasks.roadmapSync(by, a));
|
|
36
|
+
case "roadmap_export_apply":
|
|
37
|
+
if (!a || typeof a !== "object" || Array.isArray(a) || Object.keys(a).some(key => !["issue", "apply", "confirm"].includes(key)) || a.apply !== true) throw new PreEffectToolRefusal("invalid roadmap export operation; preview before applying");
|
|
38
|
+
return JSON.stringify(await scope.tasks.roadmapExport(by, a));
|
|
39
|
+
case "release_show": {
|
|
40
|
+
const release = a.id !== undefined ? (Number.isSafeInteger(a.id) && a.id > 0 ? scope.board.release(a.id) : undefined) : scope.board.releases().find(release => release.name === a.name);
|
|
41
|
+
if (!release) throw new PreEffectToolRefusal("no such release");
|
|
42
|
+
return JSON.stringify(scope.tasks.releaseList(USER).find(row => row.id === release.id));
|
|
43
|
+
}
|
|
44
|
+
case "release_change": {
|
|
45
|
+
const release = a.id !== undefined ? (Number.isSafeInteger(a.id) && a.id > 0 ? scope.board.release(a.id) : undefined) : scope.board.releases().find(release => release.name === a.name);
|
|
46
|
+
if (!release) throw new PreEffectToolRefusal("no such release");
|
|
47
|
+
if (!a.fields || typeof a.fields !== "object" || Array.isArray(a.fields) || Object.hasOwn(a.fields, "id") || Object.hasOwn(a.fields, "revision")) throw new PreEffectToolRefusal("invalid release fields");
|
|
48
|
+
const updated = scope.tasks.changeRelease(by, { ...a.fields, id: release.id, revision: a.revision });
|
|
49
|
+
return JSON.stringify(scope.tasks.releaseList(USER).find(row => row.id === updated.id));
|
|
50
|
+
}
|
|
51
|
+
case "backlog_pull":
|
|
52
|
+
case "backlog_return":
|
|
53
|
+
return line(await scope.tasks.moveBacklog(by, a.id, op === "backlog_pull"));
|
|
54
|
+
// #335: the person's schedule commands; #933: the admitted conductor's too. Tasks refuses any other actor.
|
|
55
|
+
case "schedule_list":
|
|
56
|
+
if (by !== USER) throw new PreEffectToolRefusal("schedule list is a console command");
|
|
57
|
+
return JSON.stringify(scheduleViews(scope.scheduleEntries(), scope.schedulesStore.rows(), scope.scheduleNow(), scope.tasks.openScheduled(), scope.tasks.schedulesHeld() || scope.opts.schedulesHeld?.() === true));
|
|
58
|
+
case "schedule_run": {
|
|
59
|
+
// The run is registered with the shutdown drain, so `stopOnce` waits for it, as for a timer pass, before the board and the store close (#335). A run that arrives
|
|
60
|
+
// once stop has begun is refused earlier still, by the control layer ("hub is stopping"); the test below holds that, so nothing here repeats it.
|
|
61
|
+
const run = scope.tasks.runScheduleNow(by, scope.schedulesStore, scope.scheduleEntries(), a.id, scope.scheduleNow(), () => scope.opts.schedulesHeld?.() === true);
|
|
62
|
+
const drained = run.then(() => undefined, () => undefined);
|
|
63
|
+
scope.manualSchedulePasses.add(drained); void drained.finally(() => scope.manualSchedulePasses.delete(drained));
|
|
64
|
+
return JSON.stringify(await run);
|
|
65
|
+
}
|
|
66
|
+
case "schedule_pause":
|
|
67
|
+
case "schedule_resume":
|
|
68
|
+
scope.tasks.setSchedulePaused(by, scope.schedulesStore, scope.scheduleEntries(), a.id, op === "schedule_pause", scope.scheduleNow());
|
|
69
|
+
return JSON.stringify(scheduleViews(scope.scheduleEntries(), scope.schedulesStore.rows(), scope.scheduleNow(), scope.tasks.openScheduled(), scope.tasks.schedulesHeld() || scope.opts.schedulesHeld?.() === true).filter(view => view.id === a.id));
|
|
70
|
+
// #1329 part 1: `ahub memory review on|off|status`. Person only: it is deliberately absent from CONDUCTOR_TASK_OPS, so the
|
|
71
|
+
// gate above refuses every other caller. The switch is the machine-local `memory.review.enabled` key, written through the
|
|
72
|
+
// same writer and loader check as `ahub settings set`, so enabling without both caps is refused by the config, not here;
|
|
73
|
+
// a store write beside it makes the change take effect now instead of at the next period, and `off` cancels the card the
|
|
74
|
+
// last run left open through `Tasks.cancel`, the normal cancel path (AC2).
|
|
75
|
+
case "memory_review": {
|
|
76
|
+
const reviewView = () => scheduleViews(scope.scheduleEntries(), scope.schedulesStore.rows(), scope.scheduleNow(), scope.tasks.openScheduled(), scope.tasks.schedulesHeld() || scope.opts.schedulesHeld?.() === true).find(candidate => candidate.id === MEMORY_REVIEW_SCHEDULE_ID);
|
|
77
|
+
const action = a.action;
|
|
78
|
+
if (action === "status") {
|
|
79
|
+
const view = reviewView();
|
|
80
|
+
// #1329 AC5: the spend is the hub's own counted tokens for the last card and, when one is open, for this week.
|
|
81
|
+
const open = scope.tasks.openScheduled().get(MEMORY_REVIEW_SCHEDULE_ID);
|
|
82
|
+
const card = open === undefined ? undefined : scope.board.get(open);
|
|
83
|
+
const spend = card ? scope.reviewSpend(card) : undefined;
|
|
84
|
+
return JSON.stringify({ action: "status", enabled: scope.config.memory.review?.enabled === true, review: scope.config.memory.review ?? MEMORY_REVIEW_DEFAULTS,
|
|
85
|
+
...(spend ? { spend, ...(card ? { task: card.id } : {}) } : {}), ...(view ? { schedule: view } : {}) });
|
|
86
|
+
}
|
|
87
|
+
if (action !== "on" && action !== "off") throw new PreEffectToolRefusal("memory review takes on, off or status; ahub memory review status shows the switch");
|
|
88
|
+
const def = scope.settingDef("memory.review.enabled");
|
|
89
|
+
if (typeof def === "string") throw new PreEffectToolRefusal(`this hub has no memory.review setting; upgrade it, then run ahub memory review ${action}`);
|
|
90
|
+
// The fence and the cancellation come before the config write: the write reloads the entries, and a pass already past its
|
|
91
|
+
// hold check must meet the paused epoch rather than a schedule list that no longer explains why it is running.
|
|
92
|
+
let cancelled: number | undefined;
|
|
93
|
+
if (action === "off") {
|
|
94
|
+
// #335's epoch, set before the write on purpose: the `tasks.cancel` below yields, so a timer pass can begin while the
|
|
95
|
+
// config still says enabled, and that pass has to meet the paused epoch. Nothing has to undo it afterwards: the row
|
|
96
|
+
// goes with the entry the reload drops (`Tasks.proposeFromSchedules` prunes a removed schedule).
|
|
97
|
+
scope.schedulesStore.setPaused(MEMORY_REVIEW_SCHEDULE_ID, true, scope.scheduleNow());
|
|
98
|
+
const open = scope.tasks.openScheduled().get(MEMORY_REVIEW_SCHEDULE_ID);
|
|
99
|
+
if (open !== undefined) { await scope.tasks.cancel(open, by, { reason: "ahub memory review off stopped the schedule" }); cancelled = open; }
|
|
100
|
+
}
|
|
101
|
+
writeConfigSetting(scope.opts.cwd, scope.opts.stateDir, def, action === "on", scratch => scope.configWriteCheck(scratch, "terminal", def.path.join(".")));
|
|
102
|
+
const reloaded = await scope.reloadConfig("terminal", def.key);
|
|
103
|
+
// The write is on disk, so the switch survives a restart either way; only this daemon's view of it failed to catch up.
|
|
104
|
+
if (reloaded.ok !== true) throw new Error(`memory.review.enabled was ${action === "on" ? "set" : "cleared"} in .agenthub/config.local.json but this hub did not apply it: ${sanitize(typeof reloaded.error === "string" ? reloaded.error : "the reload failed")}; fix the config and run ahub memory review status`);
|
|
105
|
+
// `on` clears the pause here rather than leaving it to the reload: a key that is already `true` changes nothing, so
|
|
106
|
+
// there is no reload to carry the fence, and this command must still resume a schedule a person paused by hand.
|
|
107
|
+
if (action === "on") scope.schedulesStore.setPaused(MEMORY_REVIEW_SCHEDULE_ID, false, scope.scheduleNow());
|
|
108
|
+
const view = reviewView();
|
|
109
|
+
return JSON.stringify({ action, enabled: action === "on", review: scope.config.memory.review ?? MEMORY_REVIEW_DEFAULTS, ...(cancelled === undefined ? {} : { cancelled }), ...(view ? { schedule: view } : {}) });
|
|
110
|
+
}
|
|
111
|
+
// #334: natural-language intake. Person only, except approve for the admitted conductor (#933): Tasks refuses any other actor.
|
|
112
|
+
case "intake": {
|
|
113
|
+
const result = await scope.tasks.intake(by, { text: a.text, sources: a.sources });
|
|
114
|
+
return JSON.stringify({ draft: scope.tasks.publicView(result.draft), children: result.children.map(child => scope.tasks.publicView(child)), split: result.split, ...(result.reason ? { reason: result.reason } : {}) });
|
|
115
|
+
}
|
|
116
|
+
case "intake_approve":
|
|
117
|
+
return JSON.stringify((await scope.tasks.approveIntake(by, a.id)).map(task => scope.tasks.publicView(task)));
|
|
118
|
+
case "intake_discard":
|
|
119
|
+
return JSON.stringify((await scope.tasks.discardIntake(by, a.id)).map(task => scope.tasks.publicView(task)));
|
|
120
|
+
// #514b: the person's verdict on a recurring-criterion candidate. Person only (Tasks refuses any other `by`, and the generic gate above already refuses every non-person caller, the configured
|
|
121
|
+
// conductor included: none of these is in CONDUCTOR_TASK_OPS). Accept writes ONE key, derived from the card's key line, through the settings writer.
|
|
122
|
+
// #1642 T2: `--accepted` reads what each followed line did, against the checklist this project uses now. A config that does not load reads no checklist: refused, never an empty one.
|
|
123
|
+
case "learn_list": {
|
|
124
|
+
if (a.accepted !== true) return JSON.stringify(scope.tasks.learnCandidates(by, { all: a.all === true }));
|
|
125
|
+
const stored = scope.storedConfig();
|
|
126
|
+
if (!stored) throw new PreEffectToolRefusal("the config files do not load; no checklist was read. Fix .agenthub/config.json or config.local.json in your editor, then run ahub learn list --accepted again");
|
|
127
|
+
const current = resolveProfile(stored.profile, stored.profile_overrides).review_checklist ?? [];
|
|
128
|
+
return JSON.stringify({ view: "accepted", minReviewed: FOLLOWUP_DEFAULTS.minReviewed, ...scope.tasks.learnFollowed(by, current) });
|
|
129
|
+
}
|
|
130
|
+
// #445 C1: the person's view of every peer's capabilities, shared or not. Person only (not in CONDUCTOR_TASK_OPS); it shows what a peer offers, never calls it.
|
|
131
|
+
case "capabilities_list": {
|
|
132
|
+
const share = readShare(scope.config.invocation?.share), peers: unknown[] = [];
|
|
133
|
+
for (const id of [...scope.bus.peers.keys()].sort()) {
|
|
134
|
+
const manifest = await scope.manifestOf(id);
|
|
135
|
+
if (manifest?.capabilities.length) peers.push({ peer: id, observedAt: manifest.observedAt, permission_mode: scope.permissionMode(id), entries: shareView(id, manifest, share) });
|
|
136
|
+
}
|
|
137
|
+
return JSON.stringify({ peers });
|
|
138
|
+
}
|
|
139
|
+
case "learn_reject":
|
|
140
|
+
return JSON.stringify(scope.tasks.publicView(await scope.tasks.learnClose(by, a.id, "rejected")));
|
|
141
|
+
case "learn_accept": {
|
|
142
|
+
// A card the person already accepted answers with a success that writes nothing: no config, no undo record, no event. A rejected or otherwise closed card falls through and is refused.
|
|
143
|
+
const decided = scope.tasks.learnAccepted(by, a.id);
|
|
144
|
+
if (decided) return JSON.stringify({ card: scope.tasks.publicView(scope.board.get(decided.id)!), accepted: { profile: decided.profile, class: decided.class, criterion: decided.criterion, alreadyAccepted: true, file: ".agenthub/config.local.json" } });
|
|
145
|
+
const plan = scope.tasks.learnAcceptPlan(by, a.id);
|
|
146
|
+
const stored = scope.storedConfig();
|
|
147
|
+
if (!stored) throw new PreEffectToolRefusal("the config files do not load; fix them in your editor first: nothing was written");
|
|
148
|
+
const active = profileName(stored.profile);
|
|
149
|
+
if (plan.profile !== active) throw new PreEffectToolRefusal(`this card is for the ${plan.profile} profile and the project's profile is ${active}: nothing was written; reject the card, or switch profile first`);
|
|
150
|
+
// review_checklist replaces as a unit: extend, or for a removal card shorten, the checklist the profile uses now (the person's, else the shipped one), never start from one line.
|
|
151
|
+
const current = resolveProfile(stored.profile, stored.profile_overrides).review_checklist ?? [];
|
|
152
|
+
if ("marker" in plan) {
|
|
153
|
+
// #1642 T3: exactly the one line the card's criterion names, and only while it is the checklist's own generated line.
|
|
154
|
+
const removed = withoutChecklistLine(current, plan.marker);
|
|
155
|
+
if ("refused" in removed) throw new PreEffectToolRefusal(`${removed.refused}. ahub learn reject ${plan.id} closes this card; ahub learn list --all shows the removal cards and their windows`);
|
|
156
|
+
const written = await scope.settingsSet(LEARN_CHECKLIST.key, removed.list, "terminal", undefined, undefined, `ahub learn accept #${plan.id}: remove the checklist line`, LEARN_CHECKLIST);
|
|
157
|
+
if (written.ok !== true) throw new PreEffectToolRefusal(`${written.error ?? "the checklist could not be written"}; the removal card stays open: fix what the error names, then run ahub learn accept on it again`);
|
|
158
|
+
const closed = await scope.tasks.learnClose(by, a.id, "accepted");
|
|
159
|
+
return JSON.stringify({ card: scope.tasks.publicView(closed), accepted: { kind: "removal", profile: plan.profile, class: plan.class, criterion: plan.criterion, removed: true, lines: removed.list.length, file: ".agenthub/config.local.json", applies: "after a restart (profile contracts are bound at startup)", undo: "ahub settings undo" } });
|
|
160
|
+
}
|
|
161
|
+
const next = withChecklistLine(current, plan.line);
|
|
162
|
+
if ("refused" in next) throw new PreEffectToolRefusal(next.refused);
|
|
163
|
+
const already = next.list.length === current.length;
|
|
164
|
+
if (!already) {
|
|
165
|
+
const written = await scope.settingsSet(LEARN_CHECKLIST.key, next.list, "terminal", undefined, undefined, `ahub learn accept #${plan.id}`, LEARN_CHECKLIST);
|
|
166
|
+
if (written.ok !== true) throw new PreEffectToolRefusal(String(written.error ?? "the checklist could not be written") + "; the candidate stays open");
|
|
167
|
+
}
|
|
168
|
+
// #1642 T1: the before rate rides the closed card's own note, so the outcome view compares against what was true at acceptance.
|
|
169
|
+
const before = scope.tasks.learnBeforeRate(by, a.id);
|
|
170
|
+
const closed = await scope.tasks.learnClose(by, a.id, "accepted", before);
|
|
171
|
+
return JSON.stringify({ card: scope.tasks.publicView(closed), accepted: { kind: "addition", profile: plan.profile, class: plan.class, criterion: plan.criterion, line: plan.line, tasks: plan.tasks, before, lines: next.list.length, alreadyPresent: already, file: ".agenthub/config.local.json", applies: "after a restart (profile contracts are bound at startup)", undo: already ? undefined : "ahub settings undo" } });
|
|
172
|
+
}
|
|
173
|
+
case "review_brief": {
|
|
174
|
+
const task = scope.board.get(Number(a.id));
|
|
175
|
+
return task ? scope.tasks.briefText(task) || `task #${task.id} names no commit, or is private: no brief` : `no task #${a.id}`;
|
|
176
|
+
}
|
|
177
|
+
case "task_show": {
|
|
178
|
+
const task = scope.board.get(Number(a.id));
|
|
179
|
+
if (!task) return JSON.stringify(`no task #${a.id}`);
|
|
180
|
+
const { codeSymbols: _storedCodeSymbols, ...detail } = task;
|
|
181
|
+
const publicTask = scope.tasks.publicView(task), codeSymbols = publicTask.codeSymbols;
|
|
182
|
+
const consoleDeliverables = await scope.tasks.deliverableStatus(task);
|
|
183
|
+
const related = scope.tasks.isPii(task) ? undefined : await scope.taskMemoryResult(task, true).catch(() => ({ items: [], state: "unknown" as const }));
|
|
184
|
+
const fresh = scope.board.get(task.id);
|
|
185
|
+
const relatedMemory = related && fresh?.updated === task.updated && !scope.tasks.isPii(fresh) ? { state: related.state, count: related.items.length, ...("head" in related ? { head: related.head } : {}) } : { state: "unknown" };
|
|
186
|
+
return JSON.stringify({ ...detail, ...scope.holderReasons(publicTask), relatedMemory, ...(publicTask.claims !== undefined ? { claims: publicTask.claims } : {}), ...(publicTask.handoffOrigin ? { handoffOrigin: publicTask.handoffOrigin } : {}), ...(codeSymbols ? { codeSymbols } : {}), ...(consoleDeliverables ? { deliverables: consoleDeliverables } : {}), symbolOverlaps: scope.tasks.symbolOverlaps(task), flowRevision: task.history.length, reviews: scope.board.reviews({ task: task.id }) }, null, 2);
|
|
187
|
+
}
|
|
188
|
+
case "deliverables": {
|
|
189
|
+
// #317 (`ahub deliverables`): the board's deliverable records, person only. `check` measures the files now; without it nothing is opened.
|
|
190
|
+
if (a.task !== undefined && (!Number.isSafeInteger(a.task) || (a.task as number) <= 0)) throw new PreEffectToolRefusal("task must be a positive integer");
|
|
191
|
+
return JSON.stringify(await scope.tasks.deliverableList({ ...(a.task !== undefined ? { task: a.task as number } : {}), approvedOnly: a.approved === true, check: a.check === true }));
|
|
192
|
+
}
|
|
193
|
+
case "task_assign":
|
|
194
|
+
case "task_assign_checked": {
|
|
195
|
+
const peer = scope.peerArg(a.peer, "peer");
|
|
196
|
+
if (!peer) throw new Error("peer is required");
|
|
197
|
+
if (a.role !== undefined && a.role !== "owner" && a.role !== "reviewer" && a.role !== "planner") throw new Error("role must be owner, reviewer or planner");
|
|
198
|
+
if (op === "task_assign_checked" && (typeof a.revision !== "number" || !Number.isSafeInteger(a.revision) || a.revision < 0)) throw new Error("revision must be a nonnegative integer");
|
|
199
|
+
return line(await scope.tasks.assignTo(a.id, peer, USER, true, a.role, op === "task_assign_checked" ? a.revision : undefined));
|
|
200
|
+
}
|
|
201
|
+
case "task_unassign": {
|
|
202
|
+
if (a.role !== undefined && a.role !== "owner" && a.role !== "reviewer") throw new Error("role must be owner or reviewer");
|
|
203
|
+
if (a.revision !== undefined && (typeof a.revision !== "number" || !Number.isSafeInteger(a.revision) || a.revision < 0)) throw new Error("revision must be a nonnegative integer");
|
|
204
|
+
return line(await scope.tasks.unassign(a.id, USER, true, a.role, a.revision));
|
|
205
|
+
}
|
|
206
|
+
case "task_escalate":
|
|
207
|
+
return line(await scope.tasks.escalate(USER, a.id, undefined, undefined, true));
|
|
208
|
+
case "route_explain": {
|
|
209
|
+
const trace = scope.tasks.explain(a.id !== undefined ? Number(a.id) : { title: String(a.title ?? ""), class: a.class as TaskClass });
|
|
210
|
+
return [...trace, ...scope.bus.knownPeers().flatMap(peer => {
|
|
211
|
+
if (trace.some(line => line.startsWith(` hold: ${peer}'s queue is held:`))) return [];
|
|
212
|
+
const hold = scope.queueHold(peer); return hold ? [`${peer} queue: ${hold}`] : [];
|
|
213
|
+
})].join("\n");
|
|
214
|
+
}
|
|
215
|
+
case "turn_revert": {
|
|
216
|
+
// `ahub undo --context` (issue #33): the conversation half of an undo; the CLI restores the files itself.
|
|
217
|
+
const turn = scope.turnLog?.get(String(a.turn));
|
|
218
|
+
if (!turn) throw new Error(`no turn ${a.turn} recorded`);
|
|
219
|
+
if (!isFixedBuiltinDefinition(scope.definitionOf(turn.peer)) || !scope.definitionOf(turn.peer)?.session.nativeRevert || !turn.native) throw new Error(`turn ${turn.id} has no Codex conversation turn to revert`);
|
|
220
|
+
if (scope.turnLog!.latest(turn.peer)?.id !== turn.id) throw new Error(`turn ${turn.id} is not Codex's latest turn; reverting it would drop the later ones too`);
|
|
221
|
+
const codex = scope.bus.peers.get(turn.peer);
|
|
222
|
+
if (!codex?.revertTurn) throw new Error("codex is not attached");
|
|
223
|
+
const workspace = scope.turnLog!.workspace(turn.id);
|
|
224
|
+
if (workspace !== undefined) {
|
|
225
|
+
const current = readInstanceRoleConfig(scope.opts.cwd), adapter = instanceDefinitionOf(turn.peer, current.instances, current.catalog);
|
|
226
|
+
if (!current.instances?.[turn.peer] || adapter?.kind !== scope.definitionOf(turn.peer)?.kind) throw new Error("turn workspace declaration changed; inspect before reverting");
|
|
227
|
+
const validated = scope.resolveExecutionCwd(turn.peer, current.instances, effectiveInstanceRoles(turn.peer, current.instances, current.roles, current.catalog), current.catalog);
|
|
228
|
+
const bound = scope.executionOwners.get(turn.peer);
|
|
229
|
+
if (validated !== workspace || scope.executionRoot(turn.peer) !== workspace || bound?.owner !== codex || bound.cwd !== workspace) throw new Error("turn workspace differs from the current native owner; inspect before reverting");
|
|
230
|
+
}
|
|
231
|
+
// Nothing may reach Codex while its history is rewritten: a turn started meanwhile would go with the reverted ones.
|
|
232
|
+
const held = scope.bus.stateOf(turn.peer) !== "paused";
|
|
233
|
+
if (held) scope.bus.pause(turn.peer);
|
|
234
|
+
try {
|
|
235
|
+
await codex.revertTurn(turn.native);
|
|
236
|
+
} finally {
|
|
237
|
+
if (held && !scope.manualPaused.has(turn.peer) && !scope.budget.record(turn.peer) && !scope.conductorHolds.has(turn.peer)) scope.bus.resume(turn.peer);
|
|
238
|
+
}
|
|
239
|
+
scope.log(`turn_revert ${turn.id}: Codex conversation reverted to before ${turn.native}`);
|
|
240
|
+
return `Codex's conversation no longer holds turn ${turn.id}`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (op.startsWith("hub_roadmap_")) throw new PreEffectToolRefusal("unknown roadmap operation; use hub_roadmap_list or ahub roadmap list");
|
|
244
|
+
throw new Error(`unknown task operation ${op}`);
|
|
245
|
+
}
|