@staix/agent-hub 0.49.1 → 0.51.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.
Files changed (99) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +1 -1
  3. package/docs/adding-an-ai-tool.md +2 -2
  4. package/docs/agent-notes/README.md +1 -0
  5. package/docs/agent-notes/adapters.md +3 -3
  6. package/docs/agent-notes/daemon.md +1 -1
  7. package/docs/agent-notes/local-worker.md +3 -3
  8. package/docs/agent-notes/tasks.md +5 -1
  9. package/docs/design/adapters.md +17 -0
  10. package/docs/design/agent-hub.md +1 -1
  11. package/docs/design/cli-output-inventory.md +24 -19
  12. package/docs/design/cli-output.md +1 -1
  13. package/docs/design/roadmap.md +2 -2
  14. package/docs/design/task-board.md +34 -0
  15. package/docs/dogfood.md +8 -3
  16. package/docs/operations.md +53 -4
  17. package/docs/quickstart.md +26 -2
  18. package/docs/roadmap.json +20 -20
  19. package/docs/roadmap.md +2 -2
  20. package/docs/sdlc.md +3 -2
  21. package/docs/specs/2026-09-19-agent-hub-design.md +1 -0
  22. package/docs/verification/2026-11-29-0.50.0.md +54 -0
  23. package/docs/verification/2026-11-29-agy-1.5.20.md +33 -0
  24. package/docs/verification/2026-11-29-claude-profile-hook.md +12 -0
  25. package/docs/verification/2026-11-29-idle-daemon-footprint.md +75 -0
  26. package/docs/verification/2026-11-29-kimi-281-reviewer-compat.md +38 -0
  27. package/docs/verification/2026-11-29-kimi-tui-281.md +12 -0
  28. package/docs/verification/2026-11-30-0.51.0.md +91 -0
  29. package/docs/verification/2026-11-30-account-switch-1806.md +445 -0
  30. package/docs/verified.json +31 -27
  31. package/package.json +1 -1
  32. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  33. package/plugins/agent-hub/kimi-hook.js +1329 -24629
  34. package/plugins/agent-hub/server.js +638 -414
  35. package/scripts/check-docs.mjs +1 -1
  36. package/src/adapters/acp.ts +13 -13
  37. package/src/adapters/agy/definition.ts +2 -2
  38. package/src/adapters/agy/entry.ts +2 -0
  39. package/src/adapters/claude-channel-evidence.ts +7 -3
  40. package/src/adapters/compat.ts +4 -3
  41. package/src/adapters/definitions/builtin-metadata.ts +2 -2
  42. package/src/adapters/definitions/native-cli-claude-launch.ts +3 -1
  43. package/src/adapters/definitions/native-cli-entry-claude.ts +17 -2
  44. package/src/adapters/definitions/native-cli-entry-codex.ts +2 -0
  45. package/src/adapters/definitions/native-cli-entry-jcode.ts +2 -0
  46. package/src/adapters/definitions/native-cli-entry-kimi.ts +2 -0
  47. package/src/adapters/definitions/native-cli-entry-pi.ts +2 -0
  48. package/src/adapters/definitions/native-cli-entry-qwen.ts +2 -0
  49. package/src/adapters/definitions/native-cli-entry-types.ts +3 -1
  50. package/src/adapters/definitions/native-cli-jcode-home-init.ts +1 -1
  51. package/src/adapters/definitions/native-cli-preview-common.ts +1 -1
  52. package/src/adapters/definitions/native-config-defaults.ts +1 -1
  53. package/src/adapters/jcode.ts +16 -0
  54. package/src/adapters/native-facts-hooks.ts +12 -0
  55. package/src/cli/autonomy-offline.ts +1 -1
  56. package/src/cli/bench.ts +1 -1
  57. package/src/cli/claude-profile-hook.ts +31 -11
  58. package/src/cli/commands/releases.ts +82 -0
  59. package/src/cli/conductor-recovery.ts +1 -1
  60. package/src/cli/facts-hook.ts +11 -4
  61. package/src/cli/help.ts +12 -10
  62. package/src/cli/identity.ts +5 -1
  63. package/src/cli/init-prompt.ts +1 -1
  64. package/src/cli/init-settings.ts +4 -35
  65. package/src/cli/init.ts +1 -1
  66. package/src/cli/json-text-spans.ts +57 -0
  67. package/src/cli/launch-check.ts +157 -0
  68. package/src/cli/launch.ts +19 -1
  69. package/src/cli/main.ts +63 -10
  70. package/src/cli/memory.ts +1 -1
  71. package/src/cli/output.ts +14 -1
  72. package/src/cli/preview.ts +1 -1
  73. package/src/cli/recovery-launch.ts +1 -1
  74. package/src/cli/setup-homes.ts +2 -2
  75. package/src/cli/start-agents-run.ts +85 -7
  76. package/src/cli/start-check.ts +28 -0
  77. package/src/cli/upgrade-runtime.ts +1 -1
  78. package/src/cli/warn-line.ts +1 -1
  79. package/src/hub/ci-watch.ts +311 -79
  80. package/src/hub/config-apply.ts +1 -1
  81. package/src/hub/config.ts +518 -0
  82. package/src/hub/control-client.ts +1 -1
  83. package/src/hub/daemon.ts +76 -513
  84. package/src/hub/delivery-public.ts +11 -0
  85. package/src/hub/hub-check.ts +125 -0
  86. package/src/hub/path-policy.ts +1 -1
  87. package/src/hub/permission-mode.ts +3 -40
  88. package/src/hub/permission-paths.ts +41 -0
  89. package/src/hub/recovery-policy.ts +1 -1
  90. package/src/hub/releases-inventory.ts +198 -0
  91. package/src/hub/runtime-capture-prune.ts +25 -3
  92. package/src/hub/runtime-prune-health.ts +8 -1
  93. package/src/hub/sdlc-release-authorization.ts +42 -21
  94. package/src/hub/sdlc-release-diagnostics.ts +5 -0
  95. package/src/hub/sdlc-release-policy.ts +21 -7
  96. package/src/hub/sdlc-release.ts +80 -20
  97. package/src/hub/sdlc.ts +7 -3
  98. package/src/hub/tasks.ts +138 -36
  99. package/src/ui/plugin.ts +1 -1
@@ -0,0 +1,518 @@
1
+ import { queueBackpressurePolicy, type QueueBackpressurePolicy } from "./queue-backpressure.ts";
2
+ import { actionPolicyConfig, type ActionPolicyConfig } from "./action-policy.ts";
3
+ import { type AdapterModuleDeclaration } from "../adapters/external-modules.ts";
4
+ import { remoteRunnerConfig, type RemoteRunnerConfig } from "./check-runner.ts";
5
+ import { planningWipLimits } from "./planning.ts";
6
+ import { PET_WINDOW_RETIRED_NOTICE, stripLegacyPetWindow } from "../pet/config.ts";
7
+ import { projectionConfig, type ProjectionConfig } from "./text-projection.ts";
8
+ import { policyPaths } from "./path-policy.ts";
9
+ import { profileName, resolveProfile, mergeProfileOverrides, type ProfileName } from "./profiles.ts";
10
+ import { catalogAssignments } from "./roles.ts";
11
+ import { peerRosterConfig, type PeerRoster } from "./roster.ts";
12
+ import { NATIVE_CONFIG_BLOCKS, nativeConfigurationDefaults, mergeNativeConfiguration, definitionOf } from "../adapters/registry.ts";
13
+ import { effectiveInstanceRoles, type InstancesConfig } from "./instances.ts";
14
+ import { INSTANCE_CONFIG_FILES, readInstanceConfig, withoutInertInstancePolicy, readInstanceConfigLayers } from "./instance-config.ts";
15
+ import { readFileSync } from "node:fs";
16
+ import { join, resolve } from "node:path";
17
+ import { homedir } from "node:os";
18
+ import { DEFAULT_TASK_SWEEP, taskSweepConfig, type TaskSweepConfig } from "./task-sweep.ts";
19
+ import { CONTRADICTION_WINDOW_SETTING, DEMOTE_AT_SETTING, DEMOTION_HALF_LIFE_SETTING, GROOM_FYI_WINDOW_SETTING, RESCREEN_MAX_SETTING, SPLIT_FAILURE_SHARE_SETTING, SPLIT_MIN_SETTING } from "./operational-settings.ts";
20
+ import { CONSOLE_POLL_SETTING, CONSOLE_NOTICE_SETTING, CONSOLE_HISTORY_SETTING, CONSOLE_PENDING_STREAM_SETTING, CONSOLE_ATTENTION_SETTING, type ConsoleOperationalConfig } from "./operational-settings.ts";
21
+ import { MODEL_COOLDOWN_FAILURES_SETTING, MODEL_COOLDOWN_SETTING, MODEL_COOLDOWN_CAP_SETTING, MODEL_TERMINAL_HISTORY_SETTING, type ModelOperationalConfig } from "./operational-settings.ts";
22
+ import { ACP_TOOL_CEILING_SETTING, ACP_ACTIVITY_BATCH_SETTING, JCODE_STEER_TIMEOUT_SETTING, type AdapterTimingConfig } from "./operational-settings.ts";
23
+ import { BUS_ACCEPTED_SETTLE_MS_SETTING, BUS_DIGEST_MAX_SETTING, BUS_MAX_ATTEMPTS_SETTING, BUS_NOTES_KEPT_SETTING, BUS_PULL_BUDGET_BYTES_SETTING, BUS_TERMINAL_HISTORY_LIMIT_SETTING, RECOVERY_CONTROL_TIMEOUT_SETTING, RECOVERY_RECONNECT_WAIT_SETTING, RECOVERY_SHUTDOWN_WAIT_SETTING, RECOVERY_TERMINAL_IDLE_WAIT_SETTING, RECOVERY_UNMANAGED_RECONNECT_WAIT_SETTING } from "./operational-settings.ts";
24
+ import { foldersConfig, schedulesConfig, type FolderEntry, type ScheduleEntry } from "./schedules.ts";
25
+ import { MEMORY_REVIEW_DEFAULTS, memoryReviewConfig, type MemoryReviewConfig } from "./memory-review.ts";
26
+ import { corpusConfig } from "./corpus-config.ts";
27
+ import { roadmapConfig, type RoadmapConfig } from "./roadmap.ts";
28
+ import { mcpAllowNames } from "./instances.ts";
29
+ import { configTracked, stripUntrusted } from "./config-trust.ts";
30
+ import { instructedMode } from "./instructed-exact.ts";
31
+ import { validateOperationalConfig, validatePetConfig } from "./config-apply.ts";
32
+ import { type MlxOptions } from "../models/mlx.ts";
33
+ import { DEFAULT_NETWORK_ALLOW } from "../local/proxy.ts";
34
+ import { DEFAULT_REVIEW_GATE, DEFAULT_REVIEW_MAX_MINUTES, DEFAULT_REVIEW_UNKNOWN_QUOTA, type ReviewGate, type ReviewUnknownQuota } from "./review-budget.ts";
35
+ import { DEFAULT_OMNIROUTE, type OmniRouteConfig } from "../omniroute/client.ts";
36
+ import { DEFAULT_BUDGET, type BudgetConfig } from "./budget.ts";
37
+ import { isAbsolute } from "node:path";
38
+ import { DEFAULT_ROLES } from "./hub-tools.ts";
39
+ import { conductorPeer } from "./conductor.ts";
40
+ import { ESCALATE_AFTER } from "./tasks.ts";
41
+ import { DEFAULT_INFERENCE, type InferenceConfig } from "./inference.ts";
42
+ import { loadRouting } from "./routing.ts";
43
+ import { checkSettingValue, settingDef as instanceSettingDef } from "./settings.ts";
44
+ import { DEFAULT_WATCHDOG_MS } from "./peers.ts";
45
+ import { parseResearchRunners, type RegisteredRunnerV1 } from "./research-runner.ts";
46
+ import { parseEditGovernance, type EditGuardArm } from "./edit-guard.ts";
47
+ import { DEFAULT_LIMITS, PROJECT_LIMITS, type LimitsConfig } from "./limits.ts";
48
+ import { START_AGENTS_DEFAULT, checkStartAgents } from "./start-agents.ts";
49
+ import { adapterCeiling, applyRoleCeiling } from "../adapters/role-eligibility.ts";
50
+ import { peerStartConfig, terminalTemplate, type PeerStartConfig, type StartMode } from "./start-mode.ts";
51
+ import { instructionProtection, permissionDefaults, type PermissionMode } from "./permission-mode.ts";
52
+ import { DEFAULT_CONTEXT, type ContextConfig } from "./context-window.ts";
53
+ import { DEFAULT_SPECS_CONFIG, parseSpecsConfig, type SpecsConfig } from "./specs-config.ts";
54
+
55
+ export interface HubConfig {
56
+ adapter_modules?: readonly AdapterModuleDeclaration[];
57
+ adapters?: Readonly<Record<string, import("../adapters/configured-acp.ts").ConfiguredAdapterConfig>>;
58
+ /** Person-owned declarations, read only from an untracked machine-local file. Bound for this daemon lifetime. */
59
+ instances?: InstancesConfig;
60
+ watchdog_ms: number;
61
+ kimi_cmd: string[];
62
+ qwen_cmd: string[];
63
+ jcode_cmd: string[];
64
+ jcode_home: string;
65
+ /** Machine-local names of jcode MCP servers `ahub doctor` accepts for the hub-owned jcode (#1621). Names only; launch is unchanged. */
66
+ jcode_mcp_allow?: string[];
67
+ jcode_provider_profile: string;
68
+ action_policy?: ActionPolicyConfig;
69
+ permission_modes: Record<string, PermissionMode>;
70
+ protect_instruction_files: boolean;
71
+ instructed?: { mode: "off" | "exact" | "intent" };
72
+ /** Loader-owned provenance of requested defaults, before machine-local filtering. */
73
+ permission_default_sources?: Record<string, { mode: PermissionMode; source: string }>;
74
+ codex_bin: string;
75
+ batch_max: number;
76
+ batch_ms: number;
77
+ queue_cap: number;
78
+ /** #489 H3: accepted delivery policy, read at the next delivery operation without rewriting queued work. */
79
+ bus?: { max_attempts?: number; digest_max?: number; pull_budget_bytes?: number; notes_kept?: number; terminal_history_limit?: number; accepted_settle_ms?: number };
80
+ /** #489 H5: accepted timing captured only when a new native adapter is constructed. */
81
+ adapter_timing?: AdapterTimingConfig["adapter_timing"];
82
+ /** #489 H6: relay policy is captured from restart-bound accepted configuration. */
83
+ model_relay?: ModelOperationalConfig["model_relay"];
84
+ /** #489 H7: accepted presentation preferences read by a new console through settings_get. */
85
+ console?: ConsoleOperationalConfig["console"];
86
+ /** `native` (#258): the hub's own store in ~/.agenthub/memory, on with any project config; `short_ttl_days`: short-term lifetime after approval; `sync_interval_min`: machine sync while a remote is set (default 10, 0 off); `preface_unused_after` (#1330): a long-term preface line delivered at least this many times and never cited moves to the end of its section, so the cap cuts it first (default 20, 0 keeps the store order). */
87
+ memory: { enabled: boolean; worker_url?: string; inject_tokens: number; brief_items: number; native?: boolean; short_ttl_days?: number; sync_interval_min?: number; suggest_edges?: boolean; preface_unused_after?: number; review?: MemoryReviewConfig };
88
+ roster: PeerRoster;
89
+ roles: Record<string, string[]>;
90
+ /** #455: the one peer that holds the planner role; unset, the `roles` planners stand, or the hub assigns one. */
91
+ planner?: string | string[];
92
+ profile?: ProfileName;
93
+ profile_overrides?: Record<string, unknown>;
94
+ pii?: { paths: string[] };
95
+ data?: { readonly: string[] };
96
+ text_projection?: ProjectionConfig;
97
+ /** #510: machine-local folders of plain notes the hub may index, read-only; vault folders are refused when the index reads them. */
98
+ corpus: { paths: string[] };
99
+ roadmap?: RoadmapConfig;
100
+ specs: SpecsConfig;
101
+ catalog_roles?: Record<string, string[]>;
102
+ conductor: { feed: "own" | "all" | "off"; approval_wait_s: number };
103
+ /** #1221 T2: what the supervision queue may do. `off` evaluates nothing, `shadow` stores bounded proposals with no inbox row or notice, `advisory` may also show a pending one in the console inbox. Machine-local and off by default. */
104
+ supervision: { mode: "off" | "shadow" | "advisory" };
105
+ edit_governance?: { arm: EditGuardArm };
106
+ budget: BudgetConfig;
107
+ context: ContextConfig;
108
+ inference: InferenceConfig;
109
+ omniroute: OmniRouteConfig;
110
+ pi: { enabled: boolean; auto_start: boolean; cmd: string[]; backend: "auto" | "dgx" | "mlx"; dgx_coding: string; dgx_fast: string; max_steps: number; max_continuations: number };
111
+ mlx: { enabled: boolean } & Pick<MlxOptions, "provider" | "host" | "runtimeDir" | "modelPath" | "port" | "model" | "sourceModel" | "contextWindow" | "maxInputTokens" | "maxTokens" | "maxConcurrency">;
112
+ /** `bash_network`: true is network through the egress proxy to `network_allow` (#65); "direct" is everything, until 0.13.0 (#83). */
113
+ local: { deny: string[]; bash_network: boolean | "direct"; network_allow: string[]; max_steps: number; read_allow: string[]; /** #515: offer the local worker `doc_read` (PDF, DOCX, HWPX through `text_projection`); off by default, machine-local. */ doc_read: boolean; /** #515b: the hosts the local worker's `web_fetch` may read; empty (the default) means the tool does not exist. Machine-local. */ web_fetch: { allow: string[] } };
114
+ /** Pending permission requests: how long they wait, and whether the desktop is told (issue #5). */
115
+ approvals: { timeout_s: number; notify: boolean };
116
+ /** An owner offline this long loses its open tasks back to routing; 0 turns it off (issue #6). */
117
+ tasks: { release_after_min: number; wip_limits?: Record<string, number>; escalate_after: number; groom_fyi_window_min?: number; demote_at?: number; demotion_half_life_h?: number; contradiction_window_days?: number; rescreen_max?: number; split_min_observations?: number; split_max_failure_share?: number; /** #785 P1c: pull the top explicitly reserved ready card when a slot frees; machine-local, default off. */ auto_pull?: boolean; queue_backpressure?: Partial<QueueBackpressurePolicy> };
118
+ /** Between-turn task escalation, disabled unless explicitly enabled (#186). */
119
+ task_sweep: TaskSweepConfig;
120
+ /** #512a: machine-local schedules; checked by `schedulesConfig`, never set from a committed file. */
121
+ schedules: ScheduleEntry[];
122
+ /** #512c: machine-local folder triggers, polled on the schedules timer; checked by `foldersConfig`, never set from a committed file. */
123
+ folder_triggers: FolderEntry[];
124
+ /** A command per task class run when the owner marks the task done, and its timeout (issue #7). */
125
+ checks: { timeout_s: number; runner?: "container" | "remote"; remote?: RemoteRunnerConfig; [cls: string]: string | number | RemoteRunnerConfig | undefined };
126
+ /** A git tree at each turn boundary for `ahub turns` and `ahub undo`, the last `keep` per peer (issue #33). */
127
+ snapshots: { enabled: boolean; keep: number };
128
+ /** Unbound visuals expire; task-bound records retain the task lifetime. */
129
+ visuals: { retention_days: number };
130
+ /** #1057: the worktree shelf. `quiet_days` shelves a worktree idle that long (0 = never); `alert_over` is the settled count that raises one inbox alert (0 = never). */
131
+ worktrees: { quiet_days: number; alert_over: number };
132
+ /** #1053: `ttl_s` expires an unanswered question (default 86400); `wait_ms` overrides an adapter definition's `questionWaitMs` per kind. */
133
+ questions: { ttl_s: number; wait_ms: Record<string, number> };
134
+ /** #247: opt-in research records of each approved task in ~/.agenthub/research (ids, counts and tokens only). */
135
+ research: { enabled: boolean; runners?: Record<string, RegisteredRunnerV1> };
136
+ /** #251: a project kept for benchmarks: `ahub bench run` resets its work tree between attempts. */
137
+ bench: { enabled: boolean };
138
+ /** #269: per peer, how a start comes up when nothing more specific was asked: `tui` (the default) or `headless`. Pi and Codex only. */
139
+ peers: PeerStartConfig;
140
+ /** #269: a machine-local argv that opens a terminal for a hub-made TUI start; `{command}` in one element is the command to run. */
141
+ terminal: { open: string[] };
142
+ /** #608: the peers `ahub up` asks the hub to start, machine-local. Read by the CLI at a person's `ahub up` and by the dashboard manager's start; the daemon itself never starts one from it. */
143
+ start: { agents: string[] };
144
+ /** Per-sender rate limits and repeat suppression for what agents send (issue #38). */
145
+ limits: LimitsConfig;
146
+ /** Reviewer choice from recorded review outcomes, once a reviewer has `min_reviews` of an implementer (issue #35). */
147
+ review: { adaptive: boolean; min_reviews: number; pool?: string[]; rerotate?: boolean; same_family?: "fallback" | "never"; gate?: ReviewGate; unknown_quota?: ReviewUnknownQuota; max_minutes?: number };
148
+ /** After an unplanned stop, start Kimi, Pi and the local worker again with their recorded sessions (issue #37). */
149
+ /** #489 H4: the five waits the upgrade coordinator reads from this project's config at the start of each wait; the daemon itself only validates and carries them. */
150
+ recovery: { auto_resume_after_crash: boolean; reconnect_wait_s?: number; unmanaged_reconnect_wait_s?: number; control_timeout_s?: number; shutdown_wait_s?: number; terminal_idle_wait_s?: number };
151
+ /** Per peer, the hub-tool capabilities it has (issue #39); a peer not listed has all of them. */
152
+ capabilities: Record<string, string[]>;
153
+ /** #445 C1: machine-local invocation settings. `share` is the person's allowlist of native capabilities by peer id, each pinned by digest (`src/hub/capabilities.ts`). */
154
+ invocation?: { share?: Record<string, Record<string, { digest: string; class?: string }>>; /** Seconds a request may wait for its result, 10 to 86400, default 600 (#445 C2). */ timeout_s?: number };
155
+ /**
156
+ * How owners of overlapping tasks coordinate (issue #107): "advisory" lets them message each other; "turn-free" has
157
+ * them work without messages while the hub derives what they need to know. Anything else is advisory.
158
+ */
159
+ coordination: "advisory" | "turn-free";
160
+ /** Switches for controlled ablations only (issue #110): `stale_notices: "deliver"` turns #106's dropping off. */
161
+ experiments?: { stale_notices?: "drop" | "deliver" };
162
+ /** Console-local terminal presentation (#280, #483); grants no authority. */
163
+ pet?: false | Record<string, unknown>;
164
+ /** Machine-local fields a config file set but git could not vouch for, and why (issue #17). */
165
+ ignored?: string[];
166
+ /** Reporting-only notice that machine-local release policy was ignored; never part of accepted policy authority. */
167
+ releasePolicyNotices?: string[];
168
+ /** Settings that were removed or are about to be (issue #83): what each does now, for `hub.log` and `ahub doctor`. */
169
+ retired?: string[];
170
+ }
171
+ const nativeDefaults = nativeConfigurationDefaults({ home: homedir(), env: process.env, networkAllow: DEFAULT_NETWORK_ALLOW });
172
+ export const DEFAULT_CONFIG: HubConfig = {
173
+ watchdog_ms: DEFAULT_WATCHDOG_MS,
174
+ ...nativeDefaults.commands,
175
+ action_policy: actionPolicyConfig(),
176
+ permission_modes: {},
177
+ protect_instruction_files: false,
178
+ instructed: { mode: "intent" },
179
+ ...nativeDefaults.proxy,
180
+ batch_max: 3,
181
+ batch_ms: 15_000,
182
+ queue_cap: 200,
183
+ bus: { max_attempts: BUS_MAX_ATTEMPTS_SETTING.defaultValue, digest_max: BUS_DIGEST_MAX_SETTING.defaultValue, pull_budget_bytes: BUS_PULL_BUDGET_BYTES_SETTING.defaultValue, notes_kept: BUS_NOTES_KEPT_SETTING.defaultValue, terminal_history_limit: BUS_TERMINAL_HISTORY_LIMIT_SETTING.defaultValue, accepted_settle_ms: BUS_ACCEPTED_SETTLE_MS_SETTING.defaultValue },
184
+ adapter_timing: { acp_tool_ceiling_min: ACP_TOOL_CEILING_SETTING.defaultValue, acp_activity_batch_ms: ACP_ACTIVITY_BATCH_SETTING.defaultValue, jcode_steer_timeout_s: JCODE_STEER_TIMEOUT_SETTING.defaultValue },
185
+ memory: { enabled: true, inject_tokens: 2000, brief_items: 8, preface_unused_after: 20, review: MEMORY_REVIEW_DEFAULTS },
186
+ roster: {},
187
+ roles: DEFAULT_ROLES,
188
+ conductor: { feed: "own", approval_wait_s: 30 },
189
+ supervision: { mode: "off" },
190
+ edit_governance: { arm: "baseline" },
191
+ budget: DEFAULT_BUDGET,
192
+ context: DEFAULT_CONTEXT,
193
+ model_relay: { cooldown_failures: MODEL_COOLDOWN_FAILURES_SETTING.defaultValue, cooldown_s: MODEL_COOLDOWN_SETTING.defaultValue, cooldown_cap_s: MODEL_COOLDOWN_CAP_SETTING.defaultValue, terminal_history_limit: MODEL_TERMINAL_HISTORY_SETTING.defaultValue },
194
+ console: { poll_ms: CONSOLE_POLL_SETTING.defaultValue, notice_ms: CONSOLE_NOTICE_SETTING.defaultValue, history_limit: CONSOLE_HISTORY_SETTING.defaultValue, pending_stream_limit: CONSOLE_PENDING_STREAM_SETTING.defaultValue, attention_limit: CONSOLE_ATTENTION_SETTING.defaultValue },
195
+ inference: DEFAULT_INFERENCE,
196
+ omniroute: DEFAULT_OMNIROUTE,
197
+ ...nativeDefaults.rpc,
198
+ mlx: { enabled: true, provider: "ollama", model: "agenthub-fast-mlx:4b-8k", sourceModel: "qwen3.5:4b-mlx", contextWindow: 8192, maxInputTokens: 6000, maxTokens: 2048, maxConcurrency: 1 },
199
+ ...nativeDefaults.sandbox,
200
+ // Off here, so tests and a hub without a config file stay silent; a project's config defaults it on for macOS.
201
+ approvals: { timeout_s: 120, notify: false },
202
+ tasks: { release_after_min: 30, escalate_after: ESCALATE_AFTER, groom_fyi_window_min: GROOM_FYI_WINDOW_SETTING.defaultValue, demote_at: DEMOTE_AT_SETTING.defaultValue, demotion_half_life_h: DEMOTION_HALF_LIFE_SETTING.defaultValue, contradiction_window_days: CONTRADICTION_WINDOW_SETTING.defaultValue, rescreen_max: RESCREEN_MAX_SETTING.defaultValue, split_min_observations: SPLIT_MIN_SETTING.defaultValue, split_max_failure_share: SPLIT_FAILURE_SHARE_SETTING.defaultValue, auto_pull: false },
203
+ task_sweep: DEFAULT_TASK_SWEEP,
204
+ schedules: [],
205
+ folder_triggers: [],
206
+ corpus: { paths: [] },
207
+ roadmap: roadmapConfig(undefined),
208
+ specs: { ...DEFAULT_SPECS_CONFIG, roots: [] },
209
+ checks: { timeout_s: 600 },
210
+ // Off here like approvals.notify, so tests (whose cwd is this repository) write no objects; a project's config turns it on.
211
+ snapshots: { enabled: false, keep: 20 },
212
+ worktrees: { quiet_days: 7, alert_over: 10 },
213
+ questions: { ttl_s: 86_400, wait_ms: {} },
214
+ visuals: { retention_days: 30 },
215
+ research: { enabled: false },
216
+ bench: { enabled: false },
217
+ peers: {},
218
+ terminal: { open: [] },
219
+ start: { agents: [...START_AGENTS_DEFAULT] },
220
+ limits: DEFAULT_LIMITS,
221
+ review: { adaptive: false, min_reviews: 5, gate: DEFAULT_REVIEW_GATE, unknown_quota: DEFAULT_REVIEW_UNKNOWN_QUOTA, max_minutes: DEFAULT_REVIEW_MAX_MINUTES },
222
+ recovery: { auto_resume_after_crash: false, reconnect_wait_s: RECOVERY_RECONNECT_WAIT_SETTING.defaultValue, unmanaged_reconnect_wait_s: RECOVERY_UNMANAGED_RECONNECT_WAIT_SETTING.defaultValue, control_timeout_s: RECOVERY_CONTROL_TIMEOUT_SETTING.defaultValue, shutdown_wait_s: RECOVERY_SHUTDOWN_WAIT_SETTING.defaultValue, terminal_idle_wait_s: RECOVERY_TERMINAL_IDLE_WAIT_SETTING.defaultValue },
223
+ capabilities: {},
224
+ coordination: "advisory",
225
+ };
226
+
227
+ /** The shared project config, then the machine's own file, which overrides it block by block (issue #17). */
228
+ export const CONFIG_FILES = INSTANCE_CONFIG_FILES;
229
+ export interface ConfigLayer { name: typeof CONFIG_FILES[number]; raw: Record<string, any> }
230
+ const CONFIG_BLOCKS = ["instructed", "action_policy", "memory", "roster", "roles", "catalog_roles", "pii", "data", "conductor", "budget", "context", "inference", "omniroute", ...NATIVE_CONFIG_BLOCKS, "approvals", "tasks", "task_sweep", "bus", "adapter_timing", "model_relay", "console", "corpus", "specs", "checks", "snapshots", "worktrees", "visuals", "research", "bench", "limits", "review", "recovery", "capabilities", "mlx", "permission_modes", "peers", "terminal", "start", "pet", "questions"];
231
+
232
+ /** Connection-time policy refresh reads role/feed fields only, never launches or machine-local configuration. */
233
+ export function loadConductorPolicy(cwd: string, layers?: readonly ConfigLayer[], scope: Pick<ReturnType<typeof readInstanceConfig>, "instances" | "catalog"> = readInstanceConfig(cwd, layers)): { roles: Record<string, string[]>; conductor: HubConfig["conductor"]; planner?: string | string[]; notices?: string[] } {
234
+ const roles: Record<string, string[]> = { ...DEFAULT_ROLES };
235
+ const conductor = { ...DEFAULT_CONFIG.conductor };
236
+ const notices: string[] = [];
237
+ // #1063: what the layers declare after the adapter ceiling and before the #1408 eligibility drop. At most one conductor is checked on this map (as on main), so an eligible-ceiling kind that cannot conduct is refused, never ignored, and a conductor the ceiling never allowed does not count.
238
+ const declaredRoles: Record<string, string[]> = { ...DEFAULT_ROLES };
239
+ let planner: string | string[] | undefined;
240
+ // #1408 R2: the conductor role needs an interactive session, so the loader reads each peer's effective start mode (config.local.json wins per peer) before it reads roles.
241
+ const startModes: Record<string, StartMode> = {};
242
+ for (const name of CONFIG_FILES) {
243
+ const raw = layers ? layers.find(layer => layer.name === name)?.raw : (() => { try { return JSON.parse(readFileSync(join(cwd, ".agenthub", name), "utf8")) as Record<string, unknown>; } catch { return undefined; } })();
244
+ const peers = raw?.peers;
245
+ if (peers && typeof peers === "object" && !Array.isArray(peers)) for (const [peer, block] of Object.entries(peers)) {
246
+ const mode = block && typeof block === "object" ? (block as { start_mode?: unknown }).start_mode : undefined;
247
+ if (mode === "tui" || mode === "headless") startModes[peer] = mode;
248
+ }
249
+ }
250
+ for (const name of CONFIG_FILES) {
251
+ let file: Record<string, unknown>;
252
+ if (layers && !layers.some(layer => layer.name === name)) continue;
253
+ try { file = layers ? structuredClone(layers.find(layer => layer.name === name)!.raw) : JSON.parse(readFileSync(join(cwd, ".agenthub", name), "utf8")); }
254
+ catch (error) { if ((error as NodeJS.ErrnoException).code === "ENOENT") continue; throw error; }
255
+ if (file.roles !== undefined) {
256
+ if (!file.roles || typeof file.roles !== "object" || Array.isArray(file.roles)) throw new Error("roles must be an object of peer role lists");
257
+ for (const [peer, assigned] of Object.entries(file.roles)) {
258
+ conductorPeer({ [peer]: assigned });
259
+ const declared = assigned as string[];
260
+ declaredRoles[peer] = adapterCeiling(peer, declared);
261
+ // #525 R1: planner needs a kind that can plan; #1408 R2: conductor needs an eligible kind in an interactive form. Such an entry is dropped with a notice, never thrown, and nobody else gains it.
262
+ // The builtin registry only, exactly as before: a project-configured ACP kind keeps the roles it is given (#525, #735).
263
+ const kept = applyRoleCeiling(peer, declared, startModes[peer]);
264
+ roles[peer] = kept.roles;
265
+ notices.push(...kept.notices);
266
+ }
267
+ }
268
+ if (file.planner !== undefined) {
269
+ if (file.planner === null) throw new Error("planner takes a peer id or a nonempty list of up to eight ids");
270
+ const def = instanceSettingDef("planner", scope.instances, scope.catalog);
271
+ if (typeof def === "string") throw new Error(def);
272
+ const normalized = checkSettingValue(def, file.planner) as string | string[];
273
+ planner = Array.isArray(file.planner) ? [...file.planner] as string[] : normalized;
274
+ }
275
+ if (file.conductor !== undefined) {
276
+ if (!file.conductor || typeof file.conductor !== "object" || Array.isArray(file.conductor)) throw new Error("conductor must be an object");
277
+ const block = file.conductor as Record<string, unknown>;
278
+ if (block.feed !== undefined) {
279
+ if (!["own", "all", "off"].includes(String(block.feed))) throw new Error("conductor.feed must be own, all or off");
280
+ conductor.feed = block.feed as "own" | "all" | "off";
281
+ }
282
+ if (block.approval_wait_s !== undefined) {
283
+ if (typeof block.approval_wait_s !== "number" || !Number.isFinite(block.approval_wait_s) || block.approval_wait_s < 0) throw new Error("conductor.approval_wait_s must be a nonnegative number");
284
+ conductor.approval_wait_s = block.approval_wait_s;
285
+ }
286
+ }
287
+ }
288
+ conductorPeer(declaredRoles);
289
+ conductorPeer(roles);
290
+ return { roles, conductor, ...(planner ? { planner } : {}), ...(notices.length ? { notices } : {}) };
291
+ }
292
+
293
+ /** `memory.short_ttl_days`: a whole number of days from 1 to 3650; anything else would make every short-term deadline invalid. */
294
+ function ttlDays(v: unknown): number {
295
+ if (typeof v !== "number" || !Number.isInteger(v) || v < 1 || v > 3650) throw new Error("memory.short_ttl_days must be a whole number of days from 1 to 3650");
296
+ return v;
297
+ }
298
+ /** `memory.sync_interval_min`: 0 (off) or a whole number of minutes up to a day. */
299
+ function syncMinutes(v: unknown): number {
300
+ if (typeof v !== "number" || !Number.isInteger(v) || v < 0 || v > 1440) throw new Error("memory.sync_interval_min must be 0 (off) or a whole number of minutes up to 1440");
301
+ return v;
302
+ }
303
+
304
+ /** Routing diagnostics must not make independent config reads depend on valid routing. */
305
+ function retiredRoutingSettings(cwd: string): readonly string[] {
306
+ try { return loadRouting(cwd).retired ?? []; }
307
+ catch { return []; } // Routing admission and reload report parse errors using their own last-good state.
308
+ }
309
+
310
+ /** #1057: a whole non-negative number of days or alert count; anything else (a negative, a fraction, a string) is the default, so a bad value never changes the shelf. The reload schema refuses it by name. */
311
+ const wholeDays = (value: unknown, fallback: number): number => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= 100_000 ? value : fallback;
312
+ /** #1053: `questions.ttl_s` (60 s to 30 days) and a per-kind `wait_ms` (1 s to 10 min); anything else keeps the default, so a bad value never changes what the person is asked. */
313
+ const questionsConfig = (value: unknown): HubConfig["questions"] => {
314
+ const raw = value && typeof value === "object" && !Array.isArray(value) ? value as Record<string, unknown> : {};
315
+ const ttl = typeof raw.ttl_s === "number" && Number.isSafeInteger(raw.ttl_s) && raw.ttl_s >= 60 && raw.ttl_s <= 2_592_000 ? raw.ttl_s : DEFAULT_CONFIG.questions.ttl_s;
316
+ const wait: Record<string, number> = {};
317
+ if (raw.wait_ms && typeof raw.wait_ms === "object" && !Array.isArray(raw.wait_ms)) for (const [kind, ms] of Object.entries(raw.wait_ms as Record<string, unknown>)) if (/^[a-z][a-z0-9-]{0,31}$/.test(kind) && typeof ms === "number" && Number.isSafeInteger(ms) && ms >= 1000 && ms <= 600_000) wait[kind] = ms;
318
+ return { ttl_s: ttl, wait_ms: wait };
319
+ };
320
+ export function loadConfig(cwd: string, layers?: readonly ConfigLayer[], routingRetired: readonly string[] = retiredRoutingSettings(cwd), externalDefinitions?: readonly import("../adapters/registry-types.ts").AdapterDefinition[]): HubConfig {
321
+ const captured = layers ?? readInstanceConfigLayers(cwd);
322
+ const instanceConfig = readInstanceConfig(cwd, captured, externalDefinitions);
323
+ const instances = instanceConfig.instances;
324
+ const adapterCatalog = instanceConfig.catalog;
325
+ const ignored: string[] = [...instanceConfig.ignored];
326
+ const releasePolicyNotices: string[] = [];
327
+ const inertModuleRoster = !!instanceConfig.adapter_modules?.length;
328
+ const appliedPermissionSources: NonNullable<HubConfig["permission_default_sources"]> = {};
329
+ let retiredPetWindow = false;
330
+ const files = CONFIG_FILES.flatMap((name) => {
331
+ let file: Record<string, any>; // parsed JSON, checked field by field below
332
+ if (!captured.some(layer => layer.name === name)) return [];
333
+ try {
334
+ file = withoutInertInstancePolicy(structuredClone(captured.find(layer => layer.name === name)!.raw), instanceConfig.declaredExternalInstances);
335
+ } catch (error) {
336
+ if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
337
+ throw error;
338
+ }
339
+ delete file.adapter_modules; // Code provenance is captured separately and never evaluated by configuration reads.
340
+ delete file.adapters; // Adapter provenance is compiled by the same project-local loader.
341
+ delete file.instances; // Declaration authority was checked against its exact captured origin above.
342
+ peerRosterConfig(file.roster, instances, adapterCatalog, inertModuleRoster);
343
+ catalogAssignments(file.catalog_roles);
344
+ profileName(file.profile);
345
+ resolveProfile(file.profile, file.profile_overrides);
346
+ projectionConfig(file.text_projection);
347
+ corpusConfig(file.corpus);
348
+ roadmapConfig(file.roadmap);
349
+ if (file.specs !== undefined) parseSpecsConfig(file.specs);
350
+ queueBackpressurePolicy(file.tasks?.queue_backpressure);
351
+ validateOperationalConfig(file);
352
+ for (const [block, key] of [["pii", "paths"], ["data", "readonly"]] as const) {
353
+ const raw = file[block];
354
+ if (raw !== undefined && (!raw || typeof raw !== "object" || Array.isArray(raw) || Object.keys(raw).some(k => k !== key))) throw new Error(block + " must be a bounded path policy block");
355
+ policyPaths(raw?.[key], block + "." + key);
356
+ }
357
+ if (file.jcode_cmd !== undefined && (!Array.isArray(file.jcode_cmd) || !file.jcode_cmd.length || file.jcode_cmd.some((word: unknown) => typeof word !== "string" || !word))) throw new Error("jcode_cmd must be a nonempty executable argv");
358
+ if (file.jcode_home !== undefined && (typeof file.jcode_home !== "string" || !isAbsolute(file.jcode_home))) throw new Error("jcode_home must be an absolute path");
359
+ if (file.jcode_mcp_allow !== undefined) mcpAllowNames(file.jcode_mcp_allow, "jcode_mcp_allow");
360
+ for (const key of ["jcode_home", "jcode_provider_profile"]) if (file[key] !== undefined && typeof file[key] !== "string") throw new Error(`${key} must be a string`);
361
+ if (file.qwen_cmd !== undefined && (!Array.isArray(file.qwen_cmd) || !file.qwen_cmd.length || file.qwen_cmd.some((word: unknown) => typeof word !== "string" || !word))) throw new Error("qwen_cmd must be a nonempty executable argv");
362
+ actionPolicyConfig(file.action_policy);
363
+ if (file.edit_governance !== undefined) parseEditGovernance(file.edit_governance);
364
+ instructionProtection(file.protect_instruction_files);
365
+ if (file.instructed !== undefined) {
366
+ if (!file.instructed || typeof file.instructed !== "object" || Array.isArray(file.instructed) || Object.keys(file.instructed).some(key => key !== "mode")) throw new Error("instructed must contain only mode");
367
+ instructedMode(file.instructed.mode);
368
+ }
369
+ permissionDefaults(file.permission_modes, instances, adapterCatalog); // malformed declarations fail even when trust would drop them
370
+ peerStartConfig(file.peers, instances, adapterCatalog);
371
+ if (file.terminal != null && (typeof file.terminal !== "object" || Array.isArray(file.terminal))) throw new Error("terminal must be an object");
372
+ terminalTemplate(file.terminal?.open);
373
+ if (file.start != null && (typeof file.start !== "object" || Array.isArray(file.start) || Object.keys(file.start).some((key: string) => key !== "agents"))) throw new Error("start must be an object with an agents list");
374
+ if (file.start?.agents !== undefined) checkStartAgents(file.start.agents);
375
+ const pet = stripLegacyPetWindow(file.pet);
376
+ if (pet !== file.pet) { retiredPetWindow = true; if (pet && typeof pet === "object" && !Object.keys(pet).length) delete file.pet; else file.pet = pet; }
377
+ if (file.pet !== undefined) validatePetConfig(file.pet, "config.pet");
378
+ if (file.pet && typeof file.pet === "object" && !Object.keys(file.pet).length) delete file.pet;
379
+ delete file.declaredExternalInstances; // host-derived refusal rows, never a file claim
380
+ delete file.permission_default_sources; // provenance is loader-owned, never a file claim
381
+ delete file._autonomy; // Inert restoration metadata, never policy or approval provenance.
382
+ if (file.checks?.runner === "remote" || file.checks?.remote !== undefined) {
383
+ if (name !== "config.local.json" || configTracked(cwd, name) !== false) throw new Error("remote checks require untracked config.local.json");
384
+ if (file.checks.remote !== undefined) remoteRunnerConfig(file.checks.remote);
385
+ }
386
+ if (file.research !== undefined && (!file.research || typeof file.research !== "object" || Array.isArray(file.research))) throw new Error("research must be an object");
387
+ const hasRunners = file.research && Object.hasOwn(file.research, "runners"), runnerDeclarations: unknown = hasRunners ? file.research.runners : undefined;
388
+ const why = stripUntrusted(file, DEFAULT_CONFIG, cwd, name);
389
+ if (why) {
390
+ const notices = why.split("; ");
391
+ releasePolicyNotices.push(...notices.filter(notice => notice.startsWith("release in .agenthub/config.local.json ignored:")));
392
+ const existingNotices = notices.filter(notice => !notice.startsWith("release in .agenthub/config.local.json ignored:"));
393
+ if (existingNotices.length) ignored.push(existingNotices.join("; "));
394
+ }
395
+ if (file.edit_governance && !Object.keys(file.edit_governance).length) delete file.edit_governance;
396
+ // Release policy is read directly from the candidate commit by the S6 host reader, never runtime config.
397
+ delete file.release;
398
+ if (hasRunners) file.research.runners = parseResearchRunners(runnerDeclarations);
399
+ for (const [peer, mode] of Object.entries(permissionDefaults(file.permission_modes, instances, adapterCatalog))) appliedPermissionSources[peer] = { mode, source: `.agenthub/${name}` };
400
+ return [file];
401
+ });
402
+ if (!files.length) return routingRetired.length ? { ...DEFAULT_CONFIG, retired: [...routingRetired] } : DEFAULT_CONFIG;
403
+ const file = files.reduce((a, b) => ({ ...a, ...b, ...Object.fromEntries(CONFIG_BLOCKS.filter((k) => a[k] !== undefined && b[k] !== undefined).map((k) => [k, { ...a[k], ...b[k] }])) }));
404
+ const pressureLayers = files.filter(layer => layer.tasks?.queue_backpressure !== undefined);
405
+ if (pressureLayers.length) file.tasks = { ...file.tasks, queue_backpressure: pressureLayers.reduce((prior, layer) => ({ ...prior, ...layer.tasks.queue_backpressure }), {}) };
406
+ const wipLayers = files.filter(layer => layer.tasks?.wip_limits !== undefined);
407
+ if (wipLayers.length) file.tasks = { ...file.tasks, wip_limits: wipLayers.reduce((prior, layer) => ({ ...prior, ...planningWipLimits(layer.tasks.wip_limits) }), {} as Record<string, number>) };
408
+ const overrides = files.reduce<unknown>((prior, layer) => mergeProfileOverrides(prior, layer.profile_overrides), undefined);
409
+ if (overrides !== undefined) file.profile_overrides = overrides;
410
+ resolveProfile(file.profile, file.profile_overrides);
411
+ delete file.ignored; // the hub's own record, never a file's
412
+ delete file.retired;
413
+ // Escape hatches with a stated end (issue #83). A removed one is ignored, never an error: an old config.local.json
414
+ // must not stop a hub from starting.
415
+ const retired: string[] = [...routingRetired];
416
+ if (retiredPetWindow && !retired.includes(PET_WINDOW_RETIRED_NOTICE)) retired.push(PET_WINDOW_RETIRED_NOTICE);
417
+ if (file.local?.sandbox !== undefined) {
418
+ if (file.local.sandbox === "allow-default") retired.push('local.sandbox "allow-default" was removed in 0.12.0: the deny-default sandbox applies (local.read_allow adds paths)');
419
+ file.local = { ...file.local };
420
+ delete file.local.sandbox;
421
+ }
422
+ if (file.local?.bash_network === "direct") retired.push('local.bash_network "direct" (the open network) goes in 0.13.0: set it to true and list the hosts in local.network_allow');
423
+ if (file.mlx != null && (typeof file.mlx !== "object" || Array.isArray(file.mlx))) throw new Error("mlx configuration must be an object");
424
+ if (file.mlx?.enabled !== undefined && typeof file.mlx.enabled !== "boolean") throw new Error("mlx.enabled must be a boolean");
425
+ if (file.mlx?.provider !== undefined && !["ollama", "legacy"].includes(file.mlx.provider)) throw new Error("mlx.provider must be ollama or legacy");
426
+ if (file.mlx?.provider === undefined && (file.mlx?.modelPath || file.mlx?.runtimeDir || file.mlx?.bin || file.mlx?.port)) {
427
+ throw new Error("legacy MLX configuration requires explicit mlx.provider=legacy; migrate to provider=ollama to avoid Python serving");
428
+ }
429
+ const mlx = { ...(file.mlx?.provider === "legacy" ? { enabled: true, provider: "legacy" as const, maxInputTokens: 16_000, maxTokens: 2048 } : DEFAULT_CONFIG.mlx), ...file.mlx };
430
+ const conductorPolicy = loadConductorPolicy(cwd, captured, instanceConfig);
431
+ retired.push(...conductorPolicy.notices ?? []);
432
+ const configuredRoles = Object.fromEntries(adapterCatalog.definitions.filter(d => !definitionOf(d.kind)).map(d => [d.kind, [...d.roles]]));
433
+ const extraRoles = Object.fromEntries(Object.keys(instances ?? {}).map(id => [id, effectiveInstanceRoles(id, instances, conductorPolicy.roles, adapterCatalog)]));
434
+ const instancePermissions: Record<string, PermissionMode> = {};
435
+ const instanceModes: PeerStartConfig = {};
436
+ for (const [id, declaration] of Object.entries(instances ?? {})) {
437
+ instanceModes[id] = { start_mode: declaration.start_mode ?? "headless" };
438
+ if (declaration.permission_mode !== undefined) {
439
+ instancePermissions[id] = declaration.permission_mode;
440
+ appliedPermissionSources[id] = { mode: declaration.permission_mode, source: ".agenthub/config.local.json" };
441
+ }
442
+ }
443
+ if (!mlx.enabled && file.pi?.backend === "mlx") throw new Error("Pi backend mlx conflicts with mlx.enabled=false");
444
+ if (typeof mlx.runtimeDir === "string" && mlx.runtimeDir) mlx.runtimeDir = resolve(cwd, mlx.runtimeDir);
445
+ if (typeof mlx.modelPath === "string" && mlx.modelPath) mlx.modelPath = resolve(cwd, mlx.modelPath);
446
+ // #1329 part 1: the scheduled memory review is derived from `memory.review` at every read (`scheduleEntries` below)
447
+ // rather than copied into `config.schedules`, because a config reload applies per-key deltas to this live object: a copy
448
+ // would go stale the moment a person flips the switch.
449
+ const memoryReview = memoryReviewConfig(file.memory?.review);
450
+ return {
451
+ ...DEFAULT_CONFIG,
452
+ ...file,
453
+ ...(instanceConfig.adapters ? { adapters: instanceConfig.adapters } : {}),
454
+ ...(instanceConfig.adapter_modules ? { adapter_modules: instanceConfig.adapter_modules } : {}),
455
+ ...(instances ? { instances } : {}),
456
+ ...(file.text_projection !== undefined ? { text_projection: projectionConfig(file.text_projection) } : {}),
457
+ ...(file.pii !== undefined ? { pii: { paths: policyPaths(file.pii.paths, "pii.paths") } } : {}),
458
+ ...(file.data !== undefined ? { data: { readonly: policyPaths(file.data.readonly, "data.readonly") } } : {}),
459
+ action_policy: actionPolicyConfig(file.action_policy),
460
+ ...(file.edit_governance !== undefined ? { edit_governance: parseEditGovernance(file.edit_governance) } : {}),
461
+ permission_modes: { ...instancePermissions, ...permissionDefaults(file.permission_modes, instances, adapterCatalog) },
462
+ protect_instruction_files: instructionProtection(file.protect_instruction_files),
463
+ instructed: { mode: instructedMode(file.instructed?.mode) },
464
+ permission_default_sources: appliedPermissionSources,
465
+ memory: { ...DEFAULT_CONFIG.memory, native: true, ...file.memory, ...(file.memory?.short_ttl_days !== undefined ? { short_ttl_days: ttlDays(file.memory.short_ttl_days) } : {}),
466
+ ...(file.memory?.sync_interval_min !== undefined ? { sync_interval_min: syncMinutes(file.memory.sync_interval_min) } : {}), review: memoryReview }, // the native store is on with any project config (#258)
467
+ roster: peerRosterConfig(file.roster, instances, adapterCatalog, inertModuleRoster),
468
+ roles: Object.fromEntries(Object.entries({ ...configuredRoles, ...conductorPolicy.roles, ...extraRoles }).filter(([id]) => !instanceConfig.declaredExternalInstances?.some(row => row.id === id || row.kind === id))),
469
+ planner: conductorPolicy.planner,
470
+ conductor: conductorPolicy.conductor,
471
+ budget: { ...DEFAULT_CONFIG.budget, wait_max_min: 30, ...file.budget }, // on with any project config (issue #36)
472
+ context: { ...DEFAULT_CONTEXT, ...file.context },
473
+ inference: { ...DEFAULT_CONFIG.inference, ...file.inference },
474
+ omniroute: { ...DEFAULT_CONFIG.omniroute, ...file.omniroute },
475
+ ...mergeNativeConfiguration(file, DEFAULT_CONFIG),
476
+ approvals: {
477
+ timeout_s: file.approvals?.timeout_s ?? DEFAULT_CONFIG.approvals.timeout_s,
478
+ notify: typeof file.approvals?.notify === "boolean" ? file.approvals.notify : process.platform === "darwin",
479
+ },
480
+ tasks: { ...DEFAULT_CONFIG.tasks, ...file.tasks, ...(file.tasks?.wip_limits !== undefined ? { wip_limits: planningWipLimits(file.tasks.wip_limits) } : {}) },
481
+ bus: { ...DEFAULT_CONFIG.bus, ...file.bus },
482
+ adapter_timing: { ...DEFAULT_CONFIG.adapter_timing, ...file.adapter_timing },
483
+ model_relay: { ...DEFAULT_CONFIG.model_relay, ...file.model_relay },
484
+ console: { ...DEFAULT_CONFIG.console, ...file.console },
485
+ task_sweep: taskSweepConfig(file.task_sweep),
486
+ schedules: schedulesConfig(file.schedules),
487
+ folder_triggers: foldersConfig(file.folder_triggers),
488
+ corpus: corpusConfig(file.corpus),
489
+ roadmap: roadmapConfig(file.roadmap),
490
+ specs: parseSpecsConfig(file.specs),
491
+ checks: { ...DEFAULT_CONFIG.checks, ...file.checks, runner: file.checks?.runner === "remote" ? "remote" : file.checks?.runner === "container" ? "container" : undefined,
492
+ ...(file.checks?.remote !== undefined || file.checks?.runner === "remote" ? { remote: remoteRunnerConfig(file.checks?.remote) } : {}) },
493
+ snapshots: { ...DEFAULT_CONFIG.snapshots, enabled: true, ...file.snapshots },
494
+ worktrees: { quiet_days: wholeDays(file.worktrees?.quiet_days, DEFAULT_CONFIG.worktrees.quiet_days), alert_over: wholeDays(file.worktrees?.alert_over, DEFAULT_CONFIG.worktrees.alert_over) },
495
+ questions: questionsConfig(file.questions),
496
+ visuals: { retention_days: typeof file.visuals?.retention_days === "number" && Number.isSafeInteger(file.visuals.retention_days) && file.visuals.retention_days >= 1 && file.visuals.retention_days <= 3650 ? file.visuals.retention_days : DEFAULT_CONFIG.visuals.retention_days },
497
+ research: { enabled: file.research?.enabled === true, ...(file.research?.runners !== undefined ? { runners: parseResearchRunners(file.research.runners) } : {}) }, // opt-in: anything but true is off
498
+ bench: { enabled: file.bench?.enabled === true }, // opt-in: a run resets this project's work tree
499
+ peers: { ...instanceModes, ...peerStartConfig(file.peers, instances, adapterCatalog) },
500
+ terminal: { open: terminalTemplate(file.terminal?.open) },
501
+ start: { agents: file.start?.agents === undefined ? [...START_AGENTS_DEFAULT] : checkStartAgents(file.start.agents) },
502
+ limits: { ...PROJECT_LIMITS, ...file.limits }, // on with any project config (issue #38)
503
+ review: { ...DEFAULT_CONFIG.review, ...file.review },
504
+ recovery: { ...DEFAULT_CONFIG.recovery, ...file.recovery },
505
+ capabilities: { ...file.capabilities },
506
+ mlx,
507
+ ...(ignored.length ? { ignored } : {}),
508
+ ...(releasePolicyNotices.length ? { releasePolicyNotices } : {}),
509
+ ...(retired.length ? { retired } : {}),
510
+ };
511
+ }
512
+
513
+ /** Explicit launch choices are never replaced when the local capability is disabled. */
514
+ export function mlxLaunchProblem(config: HubConfig, args: { backend?: unknown; model?: unknown }): string | undefined {
515
+ if (config.mlx.enabled !== false) return undefined;
516
+ if (args.backend === "mlx" || args.model === "mlx/fast") return "Pi MLX launch conflicts with mlx.enabled=false; select auto or a DGX alias";
517
+ return undefined;
518
+ }
@@ -242,7 +242,7 @@ export class ControlClient {
242
242
  client.pending.delete(msg.rid);
243
243
  done(msg);
244
244
  };
245
- ws.onopen = () => void client.request({ t: "hello", token: control.token, ...hello, ...expected, clientVersion: VERSION, v: selected, vMin: remote?.vMin === undefined ? selected : Math.max(local.vMin, remote.vMin) }, timeoutMs).then((reply) => {
245
+ ws.onopen = () => void client.request({ t: "hello", token: control.token, ...(hello.role === "tools" && hello.clientPid === undefined ? { clientPid: process.pid } : {}), ...hello, ...expected, clientVersion: VERSION, v: selected, vMin: remote?.vMin === undefined ? selected : Math.max(local.vMin, remote.vMin) }, timeoutMs).then((reply) => {
246
246
  if (reply.t !== "welcome" || reply.ok === false) return refuse(new Error(reply.error ?? "hub refused handshake"));
247
247
  if ((expected.projectId && reply.projectId !== expected.projectId) ||
248
248
  (expected.instanceId && reply.instanceId !== expected.instanceId) ||