@staix/agent-hub 0.45.0 → 0.46.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 +10 -4
- package/docs/adding-an-ai-tool.md +1 -0
- package/docs/agent-notes/adapters.md +33 -4
- package/docs/agent-notes/budget.md +2 -1
- package/docs/agent-notes/daemon.md +5 -1
- package/docs/agent-notes/security-review.md +3 -2
- package/docs/agent-notes/tasks.md +3 -1
- package/docs/agent-notes/tests.md +1 -1
- package/docs/design/adapters.md +16 -0
- package/docs/design/agent-hub-architecture.md +12 -0
- package/docs/design/cli-output.md +2 -0
- package/docs/design/roadmap.md +86 -5
- package/docs/design/task-board.md +2 -2
- package/docs/dogfood.md +15 -0
- package/docs/events.md +2 -2
- package/docs/operations.md +102 -20
- package/docs/quickstart.md +9 -3
- package/docs/security.md +7 -5
- package/docs/smoke.md +1 -1
- package/docs/verification/2026-11-05-hardcoded-values-classification-rules.md +28 -0
- package/docs/verification/2026-11-22-agy-1.5.14.md +27 -0
- package/docs/verification/2026-11-22-claude-instruction-hook.md +35 -0
- package/docs/verification/2026-11-22-instructed-ipc.md +9 -0
- package/docs/verification/2026-11-22-jcode-1.0.3.md +71 -0
- package/docs/verification/2026-11-22-jcode-separate-home.md +14 -0
- package/docs/verification/2026-11-22-qwen-0283-acp.md +28 -0
- package/docs/verification/2026-11-22-qwen-0283-dual-output.md +33 -0
- package/docs/verification/2026-11-22-roadmap-r5-view-receipt.md +63 -0
- package/docs/verification/2026-11-23-0.46.0.md +44 -0
- package/docs/verification/assets/1483-r5-detail-1440-light.png +0 -0
- package/docs/verification/assets/1483-r5-detail-390-light.png +0 -0
- package/docs/verification/assets/1483-r5-view-1440-dark.png +0 -0
- package/docs/verification/assets/1483-r5-view-1440-light.png +0 -0
- package/docs/verification/assets/1483-r5-view-390-dark.png +0 -0
- package/docs/verification/assets/1483-r5-view-390-light.png +0 -0
- package/docs/verification/assets/1483-r5-view-820-dark.png +0 -0
- package/docs/verification/assets/1483-r5-view-820-light.png +0 -0
- package/docs/verified.json +23 -23
- package/package.json +3 -2
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/kimi-hook.js +5951 -5499
- package/plugins/agent-hub/server.js +1136 -1015
- package/plugins/agent-hub/skills/ahub/SKILL.md +17 -0
- package/plugins/agent-hub/skills/ahub-manage/SKILL.md +37 -0
- package/plugins/agent-hub/skills/ahub-status/SKILL.md +14 -0
- package/plugins/agent-hub/skills/ahub-use/SKILL.md +12 -0
- package/src/adapters/claude-channel.ts +2 -1
- package/src/adapters/compat.ts +12 -11
- package/src/adapters/definitions/native-cli-claude-setup.ts +9 -1
- package/src/adapters/definitions/native-cli-doctor.ts +8 -5
- package/src/adapters/definitions/native-cli-jcode-home-init.ts +158 -0
- package/src/adapters/definitions/native-cli-jcode-home.ts +72 -0
- package/src/adapters/definitions/native-cli-jcode-mcp.ts +20 -0
- package/src/adapters/definitions/native-cli-skills.ts +29 -0
- package/src/cli/claude-profile-hook.ts +40 -3
- package/src/cli/console-state.ts +55 -26
- package/src/cli/console-usage.ts +5 -3
- package/src/cli/console.ts +35 -4
- package/src/cli/help.ts +15 -10
- package/src/cli/identity.ts +2 -1
- package/src/cli/instruction-hook.ts +28 -0
- package/src/cli/jcode-mcp.ts +2 -1
- package/src/cli/main.js +8 -0
- package/src/cli/main.ts +138 -18
- package/src/cli/output-standard.ts +3 -55
- package/src/cli/output.ts +8 -2
- package/src/cli/recovery-package.ts +47 -11
- package/src/cli/roadmap.ts +37 -3
- package/src/cli/setup-homes.ts +1 -0
- package/src/cli/setup.ts +1 -1
- package/src/cli/skills-install.ts +463 -0
- package/src/cli/task-output.ts +1 -1
- package/src/cli/upgrade-presentation-flags.ts +1 -1
- package/src/hub/board.ts +42 -4
- package/src/hub/budget-projection.ts +99 -0
- package/src/hub/claude-launch-proof.ts +5 -1
- package/src/hub/conductor.ts +8 -3
- package/src/hub/config-apply.ts +3 -2
- package/src/hub/config-tier.ts +1 -1
- package/src/hub/config-trust.ts +1 -1
- package/src/hub/control-client.ts +9 -2
- package/src/hub/daemon.ts +457 -26
- package/src/hub/events.ts +1 -1
- package/src/hub/execution-budget.ts +29 -8
- package/src/hub/hub-tools.ts +2 -2
- package/src/hub/inference.ts +1 -1
- package/src/hub/instances.ts +10 -1
- package/src/hub/instructed-exact.ts +95 -0
- package/src/hub/instructed-intent.ts +64 -0
- package/src/hub/instructed-ipc.ts +33 -0
- package/src/hub/instructed-runtime.ts +19 -0
- package/src/hub/instruction-receipt.ts +218 -0
- package/src/hub/manager.ts +46 -3
- package/src/hub/registry.ts +1 -1
- package/src/hub/roadmap-decompose.ts +60 -1
- package/src/hub/roadmap-sync.ts +2 -2
- package/src/hub/roadmap.ts +19 -1
- package/src/hub/routing.ts +18 -1
- package/src/hub/runtime-capture-prune.ts +2 -1
- package/src/hub/settings.ts +2 -1
- package/src/hub/tasks.ts +194 -12
- package/src/hub/ui.ts +6 -2
- package/src/hub/usage-rollup.ts +42 -2
- package/src/ui/index.html +342 -8
- package/src/ui/plugin.ts +6 -2
- package/src/ui/roadmap-model.ts +70 -0
package/src/hub/board.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { instructedExecution, instructedHistory } from "./instructed-exact.ts";
|
|
1
2
|
import { PreEffectToolRefusal } from "./tool-refusal.ts";
|
|
2
3
|
import { GUIDANCE_VARIANT_LIMITS, GUIDANCE_PAGE_MAX_RECORDS, GUIDANCE_HASH_HEX_LENGTH, parseGuidanceVariantV1, parseGuidanceExperiment, parseGuidanceStoredRecord, validateGuidanceVariantV1, type GuidanceVariantV1, type GuidanceExperimentRecord, type GuidanceStoredRecord, type GuidanceWriteFence } from "./guidance-variants.ts";
|
|
3
4
|
import { ExecutionLinkError, EXECUTION_LINK_LIMITS, executionLinkActor, executionLinkInteger, executionLinkId, executionLinkReferences, executionReferenceDigest, parseExecutionLinkInput, parseExecutionLinkRecord, type ExecutionLinkInput, type ExecutionLinkRecord, type ExecutionLinkFence } from "./execution-links.ts";
|
|
@@ -262,6 +263,9 @@ export type TaskMoveReason = (typeof TASK_MOVE_REASONS)[number];
|
|
|
262
263
|
export type InvocationHistory = Pick<InvocationRow, "id" | "caller" | "target" | "capability" | "digest" | "class" | "approval" | "argsSha256" | "outcome">;
|
|
263
264
|
|
|
264
265
|
export interface HistoryEntry {
|
|
266
|
+
instructed?: true;
|
|
267
|
+
instructedPeer?: string;
|
|
268
|
+
instructionReceipt?: string;
|
|
265
269
|
/** Host-owned invocation metadata only, never arguments or results. */
|
|
266
270
|
invocation?: InvocationHistory;
|
|
267
271
|
at: number;
|
|
@@ -664,6 +668,11 @@ export class Board {
|
|
|
664
668
|
this.db.run(`CREATE TABLE IF NOT EXISTS milestone_decomposition_accepts (
|
|
665
669
|
decomposition INTEGER NOT NULL, milestone INTEGER NOT NULL, part INTEGER NOT NULL, task INTEGER NOT NULL,
|
|
666
670
|
intake TEXT NOT NULL, by TEXT NOT NULL, at INTEGER NOT NULL, PRIMARY KEY(decomposition,part))`);
|
|
671
|
+
// R2 part 3 (#1480): the one issue a published part created, additive like the accept row. A lost row publishes the part
|
|
672
|
+
// again; the issue's own marker names the draft it came from.
|
|
673
|
+
this.db.run(`CREATE TABLE IF NOT EXISTS milestone_decomposition_publishes (
|
|
674
|
+
decomposition INTEGER NOT NULL, milestone INTEGER NOT NULL, part INTEGER NOT NULL, issue INTEGER NOT NULL,
|
|
675
|
+
by TEXT NOT NULL, at INTEGER NOT NULL, PRIMARY KEY(decomposition,part))`);
|
|
667
676
|
|
|
668
677
|
this.db.run(`CREATE TABLE IF NOT EXISTS research_campaigns (
|
|
669
678
|
id TEXT NOT NULL, project TEXT NOT NULL, parent_task_id INTEGER NOT NULL, revision INTEGER NOT NULL,
|
|
@@ -2455,7 +2464,7 @@ export class Board {
|
|
|
2455
2464
|
}
|
|
2456
2465
|
const now = Date.now(), planner = plannerValue(t.planner);
|
|
2457
2466
|
const chosen = Object.hasOwn(t, "planner") || t.plannerReason !== undefined ? plannerMetadata(planner, t.plannerReason) : {};
|
|
2458
|
-
const history: HistoryEntry[] = [{ at: now, by, ...chosen, event: t.backlog ? "backlogged" : "proposed", ...(this.trackPlanRevisions?.() && t.plan && Object.keys(t.plan).length ? { planRevision: { revision: 1, fingerprint: planFingerprint(t.plan) } } : {}) }];
|
|
2467
|
+
const history: HistoryEntry[] = [{ at: now, by, ...instructedHistory(by), ...chosen, event: t.backlog ? "backlogged" : "proposed", ...(this.trackPlanRevisions?.() && t.plan && Object.keys(t.plan).length ? { planRevision: { revision: 1, fingerprint: planFingerprint(t.plan) } } : {}) }];
|
|
2459
2468
|
const { lastInsertRowid } = this.taskWrite(() => {
|
|
2460
2469
|
const inserted = this.db
|
|
2461
2470
|
.query("INSERT INTO tasks (title, detail, class, state, refs, plan, deps, reserved, signals, history, created, updated, project_profile, task_role, external_repo, external_issue, planner, draft) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
|
@@ -2727,6 +2736,8 @@ export class Board {
|
|
|
2727
2736
|
/** The only way a task changes. Validates the move, records who did what, returns the new row. */
|
|
2728
2737
|
/** A `plan` in the patch replaces the old one whole: a new plan is the owner's current intent, not an addition. */
|
|
2729
2738
|
update(id: number, by: PeerId, event: string, patch: Partial<Pick<Task, "state" | "owner" | "planner" | "reviewer" | "reserved" | "refs" | "plan" | "rejections" | "signals" | "sdlc" | "role" | "cancelled" | "codeSymbols">>, note?: string, extra: Pick<HistoryEntry, "invocation" | "plannerReason" | "planAuthor" | "selfReview" | "profile" | "sweep" | "wait" | "reason" | "from" | "capacity" | "conductorManual" | "withheld" | "noWrites" | "reviewCost" | "requestHead" | "reviewContext" | "reviewScope" | "evidenceOnly" | "reviewedHead" | "reviewFindings" | "unmetCriteria" | "deliverables" | "checkKey" | "missingKeys" | "claim" | "planObservation" | "planDeparture" | "planDepartureInvalidated" | "specReport" | "specRefBinding" | "resolvedReviewComments" | "securityPass" | keyof ReviewerHistory> = {}, expectedFlowRevision?: number, codeSymbolsAuthority?: typeof HOST_CODE_SYMBOLS, adoptionAuthority?: typeof HOST_MERGE_ADOPTION): Task {
|
|
2739
|
+
const instruction = instructedExecution.getStore();
|
|
2740
|
+
if (instruction?.active && instruction.taskId === id) instruction.current();
|
|
2730
2741
|
if (extra.resolvedReviewComments?.length && !this.db.inTransaction) return this.atomic(() => this.update(id, by, event, patch, note, extra, expectedFlowRevision, codeSymbolsAuthority, adoptionAuthority));
|
|
2731
2742
|
const task = this.get(id);
|
|
2732
2743
|
if (!task) throw new Error(`no task #${id}`);
|
|
@@ -2824,7 +2835,7 @@ export class Board {
|
|
|
2824
2835
|
&& priorHead !== undefined && /^[a-f0-9]{40}$/.test(priorHead);
|
|
2825
2836
|
const previousHistory = backfill ? task.history.map((entry, index) => index === priorApproval && !entry.reviewedHead
|
|
2826
2837
|
? { ...entry, reviewedHead: entry.reviewFindings?.head ?? priorHead } : entry) : task.history;
|
|
2827
|
-
const history = [...previousHistory, { at: Date.now(), by, event, ...(resolvedReviewComments?.length ? { resolvedReviewComments } : {}), ...(returnPlanning ? { planning: returnPlanning } : {}), ...(extra.invocation ? { invocation: extra.invocation } : {}), ...plannerHistory, ...authorHistory, ...(extra.selfReview === true ? { selfReview: true as const } : {}), ...(planRevision ? { planRevision } : {}), ...(extra.planObservation ? { planObservation: extra.planObservation } : {}), ...(extra.planDeparture ? { planDeparture: extra.planDeparture } : {}), ...(departureInvalidated ? { planDepartureInvalidated: true as const } : {}), ...reviewMetadata, ...specMetadata, ...(note ? { note } : {}), ...(patch.cancelled?.supersededBy ? { supersededBy: patch.cancelled.supersededBy } : {}), ...("owner" in patch ? { owner: next.owner } : {}), ...(extra.profile ? { profile: extra.profile } : {}), ...(extra.sweep ? { sweep: extra.sweep } : {}), ...(event === "wait recorded" && extra.wait && Number.isSafeInteger(extra.wait.until) && extra.wait.until > 0 ? { wait: { until: extra.wait.until, owner: extra.wait.owner } } : {}), ...(extra.reason && TASK_MOVE_REASONS.includes(extra.reason) ? { reason: extra.reason } : {}), ...(extra.from ? { from: extra.from } : {}), ...(extra.capacity === true ? { capacity: true as const } : {}), ...(extra.conductorManual === true ? { conductorManual: true as const } : {}), ...(extra.withheld && (note || reviewFindings) ? { withheld: true as const } : {}), ...(reviewFindings ? { reviewFindings } : {}), ...(extra.reviewedHead ? { reviewedHead: extra.reviewedHead } : {}), ...(unmetCriteria?.length ? { unmetCriteria } : {}), ...(securityPass ? { securityPass } : {}), ...(deliverables ? { deliverables } : {}), ...(extra.reviewContext === "fresh" || extra.reviewContext === "continuing" ? { reviewContext: extra.reviewContext } : {}), ...(extra.reviewScope === "code" ? { reviewScope: "code" as const } : {}), ...(extra.evidenceOnly === true && event === "changes_requested" ? { evidenceOnly: true as const } : {}), ...(extra.reviewCost ? { reviewCost: extra.reviewCost } : {}), ...(["done", "check run passed", "check run failed"].includes(event) && extra.requestHead && /^[a-f0-9]{40}$/.test(extra.requestHead) ? { requestHead: extra.requestHead } : {}), ...(event === "done" && extra.noWrites === true ? { noWrites: true as const } : {}), ...(["check passed", "check failed", "check run passed", "check run failed"].includes(event) && typeof extra.checkKey === "string" && /^[a-z][a-z0-9_]{0,47}$/.test(extra.checkKey) ? { checkKey: extra.checkKey } : {}), ...(["check passed", "check failed"].includes(event) && Number.isSafeInteger(extra.missingKeys) && extra.missingKeys! >= 0 && extra.missingKeys! <= 100_000 ? { missingKeys: extra.missingKeys } : {}), ...(event === "claim verdict" && extra.claim ? { claim: extra.claim } : {}) }];
|
|
2838
|
+
const history = [...previousHistory, { at: Date.now(), by, event, ...instructedHistory(by), ...(resolvedReviewComments?.length ? { resolvedReviewComments } : {}), ...(returnPlanning ? { planning: returnPlanning } : {}), ...(extra.invocation ? { invocation: extra.invocation } : {}), ...plannerHistory, ...authorHistory, ...(extra.selfReview === true ? { selfReview: true as const } : {}), ...(planRevision ? { planRevision } : {}), ...(extra.planObservation ? { planObservation: extra.planObservation } : {}), ...(extra.planDeparture ? { planDeparture: extra.planDeparture } : {}), ...(departureInvalidated ? { planDepartureInvalidated: true as const } : {}), ...reviewMetadata, ...specMetadata, ...(note ? { note } : {}), ...(patch.cancelled?.supersededBy ? { supersededBy: patch.cancelled.supersededBy } : {}), ...("owner" in patch ? { owner: next.owner } : {}), ...(extra.profile ? { profile: extra.profile } : {}), ...(extra.sweep ? { sweep: extra.sweep } : {}), ...(event === "wait recorded" && extra.wait && Number.isSafeInteger(extra.wait.until) && extra.wait.until > 0 ? { wait: { until: extra.wait.until, owner: extra.wait.owner } } : {}), ...(extra.reason && TASK_MOVE_REASONS.includes(extra.reason) ? { reason: extra.reason } : {}), ...(extra.from ? { from: extra.from } : {}), ...(extra.capacity === true ? { capacity: true as const } : {}), ...(extra.conductorManual === true ? { conductorManual: true as const } : {}), ...(extra.withheld && (note || reviewFindings) ? { withheld: true as const } : {}), ...(reviewFindings ? { reviewFindings } : {}), ...(extra.reviewedHead ? { reviewedHead: extra.reviewedHead } : {}), ...(unmetCriteria?.length ? { unmetCriteria } : {}), ...(securityPass ? { securityPass } : {}), ...(deliverables ? { deliverables } : {}), ...(extra.reviewContext === "fresh" || extra.reviewContext === "continuing" ? { reviewContext: extra.reviewContext } : {}), ...(extra.reviewScope === "code" ? { reviewScope: "code" as const } : {}), ...(extra.evidenceOnly === true && event === "changes_requested" ? { evidenceOnly: true as const } : {}), ...(extra.reviewCost ? { reviewCost: extra.reviewCost } : {}), ...(["done", "check run passed", "check run failed"].includes(event) && extra.requestHead && /^[a-f0-9]{40}$/.test(extra.requestHead) ? { requestHead: extra.requestHead } : {}), ...(event === "done" && extra.noWrites === true ? { noWrites: true as const } : {}), ...(["check passed", "check failed", "check run passed", "check run failed"].includes(event) && typeof extra.checkKey === "string" && /^[a-z][a-z0-9_]{0,47}$/.test(extra.checkKey) ? { checkKey: extra.checkKey } : {}), ...(["check passed", "check failed"].includes(event) && Number.isSafeInteger(extra.missingKeys) && extra.missingKeys! >= 0 && extra.missingKeys! <= 100_000 ? { missingKeys: extra.missingKeys } : {}), ...(event === "claim verdict" && extra.claim ? { claim: extra.claim } : {}) }];
|
|
2828
2839
|
this.taskWrite(() => {
|
|
2829
2840
|
if (resolvedReviewComments?.length) for (const record of this.reviewComments(task.id, task.created)) {
|
|
2830
2841
|
if (!resolvedReviewComments.includes(record.thread.id) || record.lifecycle !== "sent") continue;
|
|
@@ -2854,7 +2865,7 @@ export class Board {
|
|
|
2854
2865
|
if (next.plannedStart != null && next.due != null && next.plannedStart > next.due) throw new Error("planned start must not follow due");
|
|
2855
2866
|
if (next.release != null && !this.release(next.release)) throw new Error("no such release");
|
|
2856
2867
|
const fields = Object.keys(patch) as (keyof PlanningFields)[], previous = Object.fromEntries(fields.map(key => [key, key === "sdlc" ? { repo: task.sdlc?.repo ?? null, issue: task.sdlc?.issue ?? null } : task[key] ?? (key === "pinned" || key === "needsPerson" ? false : key === "deps" ? [] : null)])) as PlanningFields;
|
|
2857
|
-
const now = Date.now(), entry: HistoryEntry = { at: now, by, event: "planned", planning: { revision: revision + 1, fields, previous }, ...(note ? { note } : {}), ...(withheld && note ? { withheld: true as const } : {}) };
|
|
2868
|
+
const now = Date.now(), entry: HistoryEntry = { at: now, by, ...instructedHistory(by), event: "planned", planning: { revision: revision + 1, fields, previous }, ...(note ? { note } : {}), ...(withheld && note ? { withheld: true as const } : {}) };
|
|
2858
2869
|
const result = this.taskWrite(() => this.db.query(`UPDATE tasks SET rank=?, priority=?, "release"=?, planned_start=?, due=?, pinned=?, needs_person=?, deps=?, reserved=?, planning_revision=planning_revision+1, history=?, updated=?, sdlc=? WHERE id=? AND planning_revision=?`)
|
|
2859
2870
|
.run(next.rank ?? null, next.priority ?? null, next.release ?? null, next.plannedStart ?? null, next.due ?? null, next.pinned ? 1 : 0, next.needsPerson ? 1 : 0, JSON.stringify(next.deps ?? []), next.reserved ?? null, JSON.stringify([...task.history, entry]), now, next.sdlc === undefined ? null : JSON.stringify(next.sdlc), id, revision));
|
|
2860
2871
|
if (result.changes !== 1) throw new Error("planning revision changed");
|
|
@@ -2867,7 +2878,7 @@ export class Board {
|
|
|
2867
2878
|
if (!task || (task.planningRevision ?? 0) !== revision || task.state !== "backlog" || task.owner || !taskCanPlan(task)) throw new Error("planner pull changed or already started");
|
|
2868
2879
|
if (task.draft) throw new Error(`task #${id} is an intake draft; the person approves it first`);
|
|
2869
2880
|
const selected = binding ? plannerMetadata(binding.planner, binding.plannerReason) : {};
|
|
2870
|
-
const now = Date.now(), entry: HistoryEntry = { at: now, by, ...selected, event: "backlog pulled", planning: { revision: revision + 1, fields: ["reserved"], previous: { reserved: task.reserved ?? null }, pull: true }, note, ...(withheld ? { withheld: true as const } : {}) };
|
|
2881
|
+
const now = Date.now(), entry: HistoryEntry = { at: now, by, ...instructedHistory(by), ...selected, event: "backlog pulled", planning: { revision: revision + 1, fields: ["reserved"], previous: { reserved: task.reserved ?? null }, pull: true }, note, ...(withheld ? { withheld: true as const } : {}) };
|
|
2871
2882
|
const result = this.taskWrite(() => this.db.query("UPDATE tasks SET state='proposed',owner=NULL,reviewer=NULL,offer=NULL,reserved=?,planning_revision=planning_revision+1,history=?,updated=?,planner=? WHERE id=? AND planning_revision=? AND state='backlog' AND owner IS NULL")
|
|
2872
2883
|
.run(reserved, JSON.stringify([...task.history, entry]), now, binding ? selected.planner ?? null : task.planner ?? null, id, revision));
|
|
2873
2884
|
if (result.changes !== 1) throw new Error("planner pull changed");
|
|
@@ -2998,6 +3009,12 @@ export class Board {
|
|
|
2998
3009
|
ref: milestoneLinkRef(row.kind as MilestoneLinkKind, row.ref), by: milestoneActor(row.by), at: milestoneId(row.at) }));
|
|
2999
3010
|
}
|
|
3000
3011
|
|
|
3012
|
+
/** #1622 family 4: whether any milestone history holds an instructed entry; a daemon without `roadmap_instructed` cannot read such a row. */
|
|
3013
|
+
hasInstructedMilestoneHistory(): boolean {
|
|
3014
|
+
const row = this.db.query("SELECT EXISTS(SELECT 1 FROM milestones WHERE history LIKE '%\"instructed\"%') AS present").get() as { present: number };
|
|
3015
|
+
return row.present === 1;
|
|
3016
|
+
}
|
|
3017
|
+
|
|
3001
3018
|
hasMilestoneState(): boolean {
|
|
3002
3019
|
const row = this.db.query("SELECT EXISTS(SELECT 1 FROM milestones) OR EXISTS(SELECT 1 FROM milestone_links) AS present").get() as { present: number };
|
|
3003
3020
|
return row.present === 1;
|
|
@@ -3118,6 +3135,26 @@ export class Board {
|
|
|
3118
3135
|
return this.decompositionAccept(row.decomposition, row.part)!;
|
|
3119
3136
|
}
|
|
3120
3137
|
|
|
3138
|
+
/** R2 part 3: every part held for one milestone, oldest answer and lowest position first, whatever answer it came from. */
|
|
3139
|
+
decompositionAcceptsFor(milestone: number): DecompositionAccept[] {
|
|
3140
|
+
const rows = this.db.query("SELECT * FROM milestone_decomposition_accepts WHERE milestone=? ORDER BY decomposition, part").all(milestoneId(milestone)) as Record<string, unknown>[];
|
|
3141
|
+
return rows.map(parseDecompositionAccept);
|
|
3142
|
+
}
|
|
3143
|
+
|
|
3144
|
+
/** R2 part 3: the issue a published part created, if an earlier apply made one. */
|
|
3145
|
+
decompositionPublish(decomposition: number, part: number): number | undefined {
|
|
3146
|
+
const row = this.db.query("SELECT issue FROM milestone_decomposition_publishes WHERE decomposition=? AND part=?").get(milestoneId(decomposition), milestoneId(part)) as Record<string, unknown> | null;
|
|
3147
|
+
return row ? milestoneId(row.issue) : undefined;
|
|
3148
|
+
}
|
|
3149
|
+
|
|
3150
|
+
/** R2 part 3: record the issue one apply created. A repeated apply of the same part keeps the first row. */
|
|
3151
|
+
recordDecompositionPublish(row: { decomposition: number; milestone: number; part: number; issue: number }, by: string, now = Date.now()): number {
|
|
3152
|
+
const actor = milestoneActor(by), at = milestoneId(now);
|
|
3153
|
+
this.db.query("INSERT OR IGNORE INTO milestone_decomposition_publishes(decomposition,milestone,part,issue,by,at) VALUES(?,?,?,?,?,?)")
|
|
3154
|
+
.run(milestoneId(row.decomposition), milestoneId(row.milestone), milestoneId(row.part), milestoneId(row.issue), actor, at);
|
|
3155
|
+
return this.decompositionPublish(row.decomposition, row.part)!;
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3121
3158
|
/** Compare-and-set from pending: a second settle of the same suggestion changes nothing. */
|
|
3122
3159
|
settleSuggestion(id: number, state: "accepted" | "rejected" | "superseded", by: string, now = Date.now()): MilestoneSuggestion {
|
|
3123
3160
|
const actor = milestoneActor(by), at = milestoneId(now);
|
|
@@ -3185,6 +3222,7 @@ export class Board {
|
|
|
3185
3222
|
const current = this.currentMilestone(id, revision), next = { ...current, ...patch };
|
|
3186
3223
|
this.milestoneParent(id, next.parent);
|
|
3187
3224
|
const settling = current.state !== next.state && (next.state === "done" || next.state === "dropped");
|
|
3225
|
+
if (event.instructed && !(settling && event.event === "state")) throw new PreEffectToolRefusal("instructed provenance is recorded only on a done or dropped verdict; ask the person to run ahub roadmap state");
|
|
3188
3226
|
if (current.history.length >= MILESTONE_HISTORY_LIMIT - 1 && !settling)
|
|
3189
3227
|
throw new PreEffectToolRefusal(`roadmap history reserves its last slot for settlement; ask the person to run ahub roadmap state ${id} done or ahub roadmap state ${id} dropped`);
|
|
3190
3228
|
const history = milestoneHistory([...current.history, event]);
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// #1513 AC1: when a quota window reaches its limit, at the burn rate seen over a lookback. Pure: the clock, the
|
|
2
|
+
// roll-up and the window all arrive as arguments, so a fixture needs no daemon and no database.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One hour of burn inside the window. `at` is epoch ms of the bucket's **start**, so a bucket holds everything burned
|
|
6
|
+
* from `at` until the next one and the last bucket is a partial hour; `tokens` is that bucket's whole burn. The rate is
|
|
7
|
+
* therefore measured to `now`, never to the last `at`.
|
|
8
|
+
*/
|
|
9
|
+
export interface ProjectionPoint {
|
|
10
|
+
at: number;
|
|
11
|
+
tokens: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* `projected`: the window reaches its limit at `at`. `basis` says which span the rate was measured over — the whole
|
|
16
|
+
* lookback, or the window itself when it opened inside the lookback (a reset) and only that much history exists.
|
|
17
|
+
* `unknown`: no time is claimed, and `cause` says why. It is never rendered as a date.
|
|
18
|
+
*/
|
|
19
|
+
export type ExhaustionProjection =
|
|
20
|
+
| { state: "projected"; at: number; basis: "lookback" | "window" }
|
|
21
|
+
| { state: "unknown"; cause: "few_points" | "no_burn" | "reset_first" | "unknown_usage" };
|
|
22
|
+
|
|
23
|
+
export interface ProjectionInput {
|
|
24
|
+
/** The window's used fraction, 0..1. */
|
|
25
|
+
used: number | null;
|
|
26
|
+
/** When the current window opened, epoch ms. */
|
|
27
|
+
windowStart: number | null;
|
|
28
|
+
/** When it resets, epoch ms; a window without one has no bound to project against. */
|
|
29
|
+
resetsAt: number | null;
|
|
30
|
+
now: number;
|
|
31
|
+
/** How far back the rate is measured; the current window may be shorter than this. */
|
|
32
|
+
lookbackMs: number;
|
|
33
|
+
/** The reading behind this window is older than the hub's freshness bound, so none of these numbers describe it now. */
|
|
34
|
+
stale?: boolean;
|
|
35
|
+
points: readonly ProjectionPoint[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const finite = (v: number | null | undefined): v is number => typeof v === "number" && Number.isFinite(v);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A steady burn projects a time; too few points, no burn at all, an unbounded or already stale window, and a
|
|
42
|
+
* projection that lands after the window's own reset each answer `unknown` with the cause named, never a time.
|
|
43
|
+
*/
|
|
44
|
+
export function projectExhaustion(input: ProjectionInput): ExhaustionProjection {
|
|
45
|
+
const { used, windowStart, resetsAt, now, lookbackMs, points, stale } = input;
|
|
46
|
+
// A stale reading is no usable reading, exactly like a window whose reset has passed: the numbers it still carries
|
|
47
|
+
// describe an earlier window, so no time is claimed from them.
|
|
48
|
+
if (stale === true || !finite(used) || used < 0 || used > 1) return { state: "unknown", cause: "unknown_usage" };
|
|
49
|
+
if (!finite(windowStart) || !finite(resetsAt) || windowStart >= now || resetsAt <= now) return { state: "unknown", cause: "unknown_usage" };
|
|
50
|
+
if (!finite(lookbackMs) || lookbackMs <= 0) return { state: "unknown", cause: "few_points" };
|
|
51
|
+
// A reset inside the lookback: the window opened after the lookback did, so the rate is measured from the window
|
|
52
|
+
// start and never across the reset. The projection says which span it used.
|
|
53
|
+
const lookbackFrom = now - lookbackMs;
|
|
54
|
+
const from = Math.max(windowStart, lookbackFrom);
|
|
55
|
+
const basis: "lookback" | "window" = from > lookbackFrom ? "window" : "lookback";
|
|
56
|
+
const inside = points.filter(p => finite(p.at) && finite(p.tokens) && p.tokens >= 0 && p.at >= from && p.at <= now).sort((a, b) => a.at - b.at);
|
|
57
|
+
const total = points.filter(p => finite(p.at) && finite(p.tokens) && p.tokens > 0 && p.at >= windowStart && p.at <= now).reduce((sum, p) => sum + p.tokens, 0);
|
|
58
|
+
if (used >= 1) return { state: "projected", at: now, basis };
|
|
59
|
+
if (inside.length < 2) return { state: "unknown", cause: "few_points" };
|
|
60
|
+
// The points are buckets stamped at their start, so their burn covers the time from the first bucket's start to `now`,
|
|
61
|
+
// the partial last hour included. Measuring between the two stamps would count n buckets over n-1 hours and overstate
|
|
62
|
+
// the rate (two points, the minimum: doubled, and the forecast an hour early).
|
|
63
|
+
const elapsed = now - inside[0]!.at;
|
|
64
|
+
if (elapsed <= 0) return { state: "unknown", cause: "few_points" };
|
|
65
|
+
const burned = inside.reduce((sum, p) => sum + p.tokens, 0);
|
|
66
|
+
// No tokens at all in the window is no data, not a zero rate: a window nobody used cannot be projected either way.
|
|
67
|
+
if (total <= 0 || burned <= 0) return { state: "unknown", cause: "no_burn" };
|
|
68
|
+
// The window's own numbers give its capacity: what is burnt now is `used` of it.
|
|
69
|
+
const capacity = total / used, remaining = (1 - used) * capacity;
|
|
70
|
+
const at = now + remaining / (burned / elapsed);
|
|
71
|
+
if (!Number.isFinite(at)) return { state: "unknown", cause: "few_points" };
|
|
72
|
+
if (at > resetsAt) return { state: "unknown", cause: "reset_first" };
|
|
73
|
+
return { state: "projected", at: Math.round(at), basis };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const CAUSE_TEXT: Record<Extract<ExhaustionProjection, { state: "unknown" }>["cause"], string> = {
|
|
77
|
+
few_points: "too few points yet",
|
|
78
|
+
no_burn: "no burn yet",
|
|
79
|
+
reset_first: "it resets first",
|
|
80
|
+
unknown_usage: "no usable reading",
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* #1513 AC2: one sentence every surface renders, so the dashboard, the console and `ahub budget` say the same thing.
|
|
85
|
+
* A projected window names the time; an unknown one names why, never a date.
|
|
86
|
+
*/
|
|
87
|
+
export function projectionText(projection: ExhaustionProjection, when: (at: number) => string): string {
|
|
88
|
+
return projection.state === "projected"
|
|
89
|
+
? `reaches its limit ${when(projection.at)}${projection.basis === "window" ? " (rate since the window opened)" : ""}`
|
|
90
|
+
: `no forecast: ${CAUSE_TEXT[projection.cause]}`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The window's own length, for the lookback cap: a 5 h window is never measured over more than 5 h. */
|
|
94
|
+
export const WINDOW_MINS: Record<string, number> = { "5h": 300, week: 10_080, tokens: 300 };
|
|
95
|
+
|
|
96
|
+
/** The left fraction of a window, or null when the reading is not a usable number. Never a negative or a faked zero. */
|
|
97
|
+
export function windowLeft(used: number | null | undefined): number | null {
|
|
98
|
+
return finite(used) && used >= 0 && used <= 1 ? 1 - used : null;
|
|
99
|
+
}
|
|
@@ -8,6 +8,8 @@ import type { PeerAdapter } from "./peers.ts";
|
|
|
8
8
|
|
|
9
9
|
export interface ClaudeLaunchRecordProof {
|
|
10
10
|
launchId: string;
|
|
11
|
+
launcherPid?: number;
|
|
12
|
+
launcherSignature?: string;
|
|
11
13
|
executionCwd?: string;
|
|
12
14
|
privateRecord: boolean;
|
|
13
15
|
permissionHook: boolean;
|
|
@@ -28,7 +30,9 @@ export function readClaudeLaunchProof(stateDir: string, peer: string, instanceId
|
|
|
28
30
|
if (count > 16 * 1024) return;
|
|
29
31
|
const row = JSON.parse(bytes.subarray(0, count).toString("utf8"));
|
|
30
32
|
if (row?.instanceId !== instanceId || typeof row.launchId !== "string" || !row.launchId || row.launchId.length > 128) return;
|
|
31
|
-
return { launchId: row.launchId,
|
|
33
|
+
return { launchId: row.launchId,
|
|
34
|
+
...(Number.isSafeInteger(row.launcherPid) && row.launcherPid > 0 ? { launcherPid: row.launcherPid } : {}),
|
|
35
|
+
...(typeof row.launcherSignature === "string" && row.launcherSignature.length > 0 && row.launcherSignature.length <= 256 && !/[\p{Cc}\p{Cf}]/u.test(row.launcherSignature) ? { launcherSignature: row.launcherSignature } : {}), privateRecord: stat.nlink === 1 && (stat.mode & 0o777) === 0o600 && !!process.getuid && stat.uid === process.getuid(),
|
|
32
36
|
...(typeof row.executionCwd === "string" && row.executionCwd.length <= 4096 && isAbsolute(row.executionCwd) ? { executionCwd: row.executionCwd } : {}),
|
|
33
37
|
permissionHook: row.permissionHook === true, unattended: row.unattended === true,
|
|
34
38
|
...(typeof row.hookPurpose === "string" ? { hookPurpose: row.hookPurpose } : {}) };
|
package/src/hub/conductor.ts
CHANGED
|
@@ -21,12 +21,15 @@ export function conductorProgressSink(record: (event: HubEvent) => void, feed: P
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/** What `Budget.status` returns, with the fields added after it optional so an older shape still projects. */
|
|
24
|
-
type PublicBudgetStatus = Record<string, { windows: (Omit<ReturnType<Budget["status"]>[string]["windows"][number], "kind" | "superseded"> & { kind?: WindowKind; superseded?: boolean })[]; paused?: ReturnType<Budget["status"]>[string]["paused"]; accountUsage?: QuotaAccountReading }>;
|
|
24
|
+
type PublicBudgetStatus = Record<string, { windows: (Omit<ReturnType<Budget["status"]>[string]["windows"][number], "kind" | "superseded"> & { kind?: WindowKind; superseded?: boolean; left?: number | null; projection?: unknown })[]; paused?: ReturnType<Budget["status"]>[string]["paused"]; accountUsage?: QuotaAccountReading }>;
|
|
25
25
|
export function publicPeerBudget(status: PublicBudgetStatus, nameable: (text: string) => boolean): Record<string, unknown> {
|
|
26
26
|
return Object.fromEntries(Object.entries(status).map(([peer, value]) => [peer, {
|
|
27
27
|
windows: value.windows.map(window => ({ id: window.id, kind: windowKind(window), used: window.used, at: window.at, stale: window.stale, ...(window.superseded ? { superseded: true } : {}),
|
|
28
28
|
...(window.resetsAt === undefined ? {} : { resetsAt: window.resetsAt }),
|
|
29
29
|
...(window.windowMins === undefined ? {} : { windowMins: window.windowMins }),
|
|
30
|
+
// #1513 AC2: the window's remainder and its forecast travel with it, so the console, `ahub budget --json` and the page agree.
|
|
31
|
+
...(window.left === undefined ? {} : { left: window.left }),
|
|
32
|
+
...(window.projection === undefined ? {} : { projection: window.projection }),
|
|
30
33
|
source: nameable(window.source) ? window.source : "[quota source withheld]",
|
|
31
34
|
})),
|
|
32
35
|
...(value.paused ? { paused: { since: value.paused.since, resetsAt: value.paused.resetsAt, reason: "quota" } } : {}),
|
|
@@ -132,7 +135,7 @@ export function conductorStart(peer: unknown, mode: unknown, preview: (peer: str
|
|
|
132
135
|
|
|
133
136
|
const numberOrNull = (v: unknown): number | null => typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null;
|
|
134
137
|
export interface ConductorStatusInput {
|
|
135
|
-
peers: Array<{ peer: string; state?: string; attached?: boolean; queued?: number; needsReview?: number; manualHeld?: boolean; hold?: ConductorHold | null; budgetPause?: { since?: number; resetsAt?: number } | null; windows?: Array<{ id: string; used?: number; resetsAt?: number; at?: number; source?: string }>; doing?: PeerDoing | null }>;
|
|
138
|
+
peers: Array<{ peer: string; state?: string; attached?: boolean; queued?: number; needsReview?: number; manualHeld?: boolean; hold?: ConductorHold | null; budgetPause?: { since?: number; resetsAt?: number } | null; windows?: Array<{ id: string; used?: number; resetsAt?: number; at?: number; source?: string; left?: number | null; projection?: unknown }>; doing?: PeerDoing | null }>;
|
|
136
139
|
taskCounts: Record<string, number>;
|
|
137
140
|
approvals: Array<{ peer: string; tool?: string; at?: number }>;
|
|
138
141
|
}
|
|
@@ -146,7 +149,9 @@ export function publicConductorStatus(input: ConductorStatusInput, now = Date.no
|
|
|
146
149
|
manualHold: p.manualHeld === undefined ? null : { held: p.manualHeld, actor: p.manualHeld ? "user" : null },
|
|
147
150
|
conductorHold: p.hold ? { actor: p.hold.actor, since: numberOrNull(p.hold.since) } : null,
|
|
148
151
|
budgetPause: p.budgetPause ? { since: numberOrNull(p.budgetPause.since), resetsAt: numberOrNull(p.budgetPause.resetsAt) } : null,
|
|
149
|
-
|
|
152
|
+
// #1513 AC2: hub_status reports the same remainder and forecast the dashboard and the console render.
|
|
153
|
+
windows: p.windows === undefined ? null : p.windows.map((w) => ({ id: w.id, used: numberOrNull(w.used), resetsAt: numberOrNull(w.resetsAt), at: numberOrNull(w.at), source: w.source ?? null,
|
|
154
|
+
...(w.left === undefined ? {} : { left: numberOrNull(w.left) }), ...(w.projection === undefined ? {} : { projection: w.projection }) })),
|
|
150
155
|
// Native reports retain peer authorship; incoming message labels carry their own display provenance.
|
|
151
156
|
doing: !p.doing ? null : p.doing.text === DOING_STUB ? { text: DOING_STUB, source: p.doing.source, at: numberOrNull(p.doing.at) }
|
|
152
157
|
: p.doing.source === "label" ? { text: sanitize(p.doing.text), source: "label", at: numberOrNull(p.doing.at), note: INCOMING_LABEL_NOTE, untrusted: true }
|
package/src/hub/config-apply.ts
CHANGED
|
@@ -189,9 +189,10 @@ shapes.set(researchRunners, { item: block({ publicKey: text, projects: strings,
|
|
|
189
189
|
const schema: Record<string, Check> = {
|
|
190
190
|
_autonomy: v => { autonomyOwnership(v); },
|
|
191
191
|
...Object.assign({}, ...ADAPTERS.map(adapter => adapter.configuration?.schema?.(nativeValidators) ?? {})),
|
|
192
|
-
watchdog_ms: number(1, 2_147_483_647), kimi_cmd: argv, qwen_cmd: argv, jcode_cmd: argv, codex_bin: text, jcode_home: text, jcode_provider_profile: text,
|
|
192
|
+
watchdog_ms: number(1, 2_147_483_647), kimi_cmd: argv, qwen_cmd: argv, jcode_cmd: argv, codex_bin: text, jcode_home: text, jcode_mcp_allow: strings, jcode_provider_profile: text,
|
|
193
193
|
action_policy: block({ enabled: bool, floor: bool, always_ask: (v, k) => { actionPolicyConfig({ always_ask: v }); }, budgets: map(number(0, 1000, true), ACTION_CLASSES) }),
|
|
194
194
|
permission_modes: v => { permissionDefaults(v); }, protect_instruction_files: bool,
|
|
195
|
+
instructed: block({ mode: words(["off", "exact", "intent"]) }),
|
|
195
196
|
adapter_modules: v => { adapterModuleDeclarations(v); },
|
|
196
197
|
adapters: v => { createProjectAdapterCatalog(v); }, instances: v => { validateInstances(v, createProjectAdapterCatalog()); }, pet: validatePetConfig,
|
|
197
198
|
batch_max: number(1, 100_000, true), batch_ms: number(0, 2_147_483_647), queue_cap: number(1, 1_000_000, true),
|
|
@@ -283,7 +284,7 @@ const restart: Record<string, string> = {
|
|
|
283
284
|
profile: "Session tool schemas and profile contracts are bound at startup", profile_overrides: "Session tool schemas and profile contracts are bound at startup",
|
|
284
285
|
text_projection: "Converter and cache ownership are bound at startup", corpus: "The corpus index is bound to its roots at startup", roadmap: "GitHub mirror authority is bound at startup", terminal: "Terminal provider is supplied by the daemon lifecycle", bench: "Benchmark execution environment is selected before work starts",
|
|
285
286
|
};
|
|
286
|
-
const live = new Set(["visuals", "action_policy", "permission", "roster", "roles", "planner", "conductor", "protect_instruction_files", "task_sweep", "capabilities", "invocation", "research", "snapshots", "worktrees", "tasks.wip_limits", "tasks.escalate_after", "tasks.auto_pull", "tasks.queue_backpressure", "schedules", "approvals.notify", "questions", "pet", "specs", "supervision", "edit_governance"]);
|
|
287
|
+
const live = new Set(["instructed", "visuals", "action_policy", "permission", "roster", "roles", "planner", "conductor", "protect_instruction_files", "task_sweep", "capabilities", "invocation", "research", "snapshots", "worktrees", "tasks.wip_limits", "tasks.escalate_after", "tasks.auto_pull", "tasks.queue_backpressure", "schedules", "approvals.notify", "questions", "pet", "specs", "supervision", "edit_governance"]);
|
|
287
288
|
const nextMemory = new Set(["memory.inject_tokens", "memory.brief_items", "memory.suggest_edges", "memory.preface_unused_after"]);
|
|
288
289
|
/** Closed top-level schema; leaf overrides retain the existing session/runtime boundaries. */
|
|
289
290
|
export function configApply(key: string, scopes: readonly ConfigIdentityScope[] = []): ApplyRule {
|
package/src/hub/config-tier.ts
CHANGED
|
@@ -15,7 +15,7 @@ const UNSAFE = new Set(["__proto__", "constructor", "prototype"]);
|
|
|
15
15
|
/** Instance fields that choose no executable and no home. */
|
|
16
16
|
export const TIER2_INSTANCE_FIELDS = ["kind", "roles", "start_mode", "review_mode", "readOnly", "worktree", "permission_mode"] as const;
|
|
17
17
|
/** Instance fields that choose a native home, account or model, or widen what a reviewer verdict may skip (`review_scope`, #852): tier 3 (#685). */
|
|
18
|
-
export const TIER3_INSTANCE_FIELDS = ["jcode_home", "provider", "model", "provider_profile", "review_scope"] as const;
|
|
18
|
+
export const TIER3_INSTANCE_FIELDS = ["jcode_home", "jcode_mcp_allow", "provider", "model", "provider_profile", "review_scope"] as const;
|
|
19
19
|
/** Every NEVER_EDITABLE key except `instances`, which splits by field. */
|
|
20
20
|
export const TIER3_PREFIXES: readonly string[] = NEVER_EDITABLE.filter(key => key !== "instances");
|
|
21
21
|
const TIER2_BLOCKS: Readonly<Record<string, readonly string[]>> = {
|
package/src/hub/config-trust.ts
CHANGED
|
@@ -37,7 +37,7 @@ export const MACHINE_LOCAL = [
|
|
|
37
37
|
"invocation", // #445 C1: what another agent may be offered from this machine's agents (a digest-pinned allowlist); a committed config may not share a person's agents' commands with someone else's peers
|
|
38
38
|
] as const;
|
|
39
39
|
/** Legacy exported field list stays compatible; new policies use the complete list below. */
|
|
40
|
-
export const ALL_MACHINE_LOCAL = [...MACHINE_LOCAL, "edit_governance.arm", "roadmap.github_mirror", "roadmap.github_write", "research.runners", "rooms", "tasks.queue_backpressure", "context.max_assignment_used", "action_policy", "protect_instruction_files", "qwen_cmd", "jcode_cmd", "jcode_home", "jcode_provider_profile", "start.agents", "adapters", "adapter_modules", "text_projection", "instances"] as const;
|
|
40
|
+
export const ALL_MACHINE_LOCAL = [...MACHINE_LOCAL, "instructed", "edit_governance.arm", "roadmap.github_mirror", "roadmap.github_write", "research.runners", "rooms", "tasks.queue_backpressure", "context.max_assignment_used", "action_policy", "protect_instruction_files", "qwen_cmd", "jcode_cmd", "jcode_home", "jcode_mcp_allow", "jcode_provider_profile", "start.agents", "adapters", "adapter_modules", "text_projection", "instances"] as const;
|
|
41
41
|
/** An empty list of these is a value (`start.agents` empty starts no agent), not "the default", so the empty-value drop below skips them. */
|
|
42
42
|
const EMPTY_IS_VALUE: readonly string[] = ["start.agents"];
|
|
43
43
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
+
import { InstructedIpcSocket } from "./instructed-ipc.ts";
|
|
2
3
|
import { join, resolve } from "node:path";
|
|
3
4
|
import { projectContext } from "./project.ts";
|
|
4
5
|
import { newToolRequestId, TOOL_WRITE_FEATURE, toolWriteOperation, toolWriteUnknownReply, toolWriteRefusedReply } from "./tool-request.ts";
|
|
@@ -22,7 +23,7 @@ export const PROTOCOL = 17;
|
|
|
22
23
|
/** The descriptor's legacy protocol field remains this floor for previous published clients. */
|
|
23
24
|
export const PROTOCOL_MIN = 16;
|
|
24
25
|
// Literal metadata is read without executing a recovery target; consistency is pinned in tests.
|
|
25
|
-
export const DAEMON_FEATURES = ["roadmap", "guidance_views", "guidance_variants", "guidance_probes", "guidance_probe_receipts", "execution_lineage", "model_overrides", "visuals", "project_autonomy", "conductor_recovery", "encrypted_rooms", "external_adapter_instances", "external_adapter_modules", "configured_acp", "native_hook_launch", "task_cancel", "invocation", "recovery_deferred_hub", "peer_instances", "role_stages", "task_planners", "release_trains", "reviewer_pool", "reviewer_quota", "native_tui_launch", "terminal_owner", "cli_audit_delegated", "action_policy_floor", "calendar_schedules", "research_records", "research_dispatch", "research_dropped_offers", "research_experiments", "research_comparisons", "research_runners", "task_handoff", "session_identity", "schema_guard", "design_specs", "queue_discard_states", "tool_write_idempotency", "research_evidence", "research_synthesis", "research_evidence_withdrawal", "advisor_surveys", "review_comments", "questions", "accepted_delivery_settlement", "completions", "review_observer_input_state", "task_handoff_key", "task_handoff_seq", "peer_takeover"] as const;
|
|
26
|
+
export const DAEMON_FEATURES = ["instructed_intent", "instructed_exact", "roadmap", "roadmap_instructed", "guidance_views", "guidance_variants", "guidance_probes", "guidance_probe_receipts", "execution_lineage", "model_overrides", "visuals", "project_autonomy", "conductor_recovery", "encrypted_rooms", "external_adapter_instances", "external_adapter_modules", "configured_acp", "native_hook_launch", "task_cancel", "invocation", "recovery_deferred_hub", "peer_instances", "role_stages", "task_planners", "release_trains", "reviewer_pool", "reviewer_quota", "native_tui_launch", "terminal_owner", "cli_audit_delegated", "action_policy_floor", "calendar_schedules", "research_records", "research_dispatch", "research_dropped_offers", "research_experiments", "research_comparisons", "research_runners", "task_handoff", "session_identity", "schema_guard", "design_specs", "queue_discard_states", "tool_write_idempotency", "research_evidence", "research_synthesis", "research_evidence_withdrawal", "advisor_surveys", "review_comments", "questions", "accepted_delivery_settlement", "completions", "review_observer_input_state", "task_handoff_key", "task_handoff_seq", "peer_takeover"] as const;
|
|
26
27
|
/** Protocols a current coordinator may authenticate while upgrading a running source. */
|
|
27
28
|
export const RECOVERY_SOURCE_PROTOCOLS = [9, 10, 11, 12, 13, 14, 15, 16, PROTOCOL] as const;
|
|
28
29
|
|
|
@@ -121,6 +122,8 @@ export function readControl(stateDir: string): ControlDescriptor | undefined {
|
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
|
|
125
|
+
let instructedIpcClaimed = false;
|
|
126
|
+
|
|
124
127
|
const instancePins = new Map<string, { instanceId: string }>();
|
|
125
128
|
|
|
126
129
|
/** Maximum supported 3600 s approval plus admission/transport margin; applies to every hub_invoke client path. */
|
|
@@ -204,8 +207,12 @@ export class ControlClient {
|
|
|
204
207
|
}
|
|
205
208
|
const expected = { projectId: hello.projectId ?? control.projectId, instanceId: pin?.instanceId ?? hello.instanceId ?? control.instanceId,
|
|
206
209
|
projectRoot: hello.projectRoot ?? control.cwd };
|
|
210
|
+
const instructedIpc = process.env.AGENTHUB_INSTRUCTED_IPC;
|
|
211
|
+
if (instructedIpc !== undefined && (instructedIpc !== "1" || hello.role !== "console" || instructedIpcClaimed)) return Promise.reject(new Error("invalid or already used instructed control channel"));
|
|
212
|
+
if (instructedIpc !== undefined) instructedIpcClaimed = true;
|
|
207
213
|
return new Promise((resolve, reject) => {
|
|
208
|
-
|
|
214
|
+
// A daemon-launched instructed CLI can use only its inherited socket, never a WebSocket.
|
|
215
|
+
const ws = instructedIpc === undefined ? new WebSocket(control.url) : new InstructedIpcSocket(1024 * 1024) as unknown as WebSocket;
|
|
209
216
|
const client = new ControlClient(ws);
|
|
210
217
|
const timer = setTimeout(() => refuse(Object.assign(new Error(`hub connection timed out at ${control.url}`), { code: "AHUB_CONNECT_TIMEOUT" })), timeoutMs);
|
|
211
218
|
const refuse = (error: Error) => { clearTimeout(timer); reject(error); ws.close(); };
|