@staix/agent-hub 0.51.0 → 0.52.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 +35 -0
- package/README.md +1 -1
- package/docs/adding-an-ai-tool.md +24 -2
- package/docs/agent-notes/adapters.md +1 -0
- package/docs/agent-notes/budget.md +8 -2
- package/docs/agent-notes/daemon.md +13 -8
- package/docs/agent-notes/security-review.md +6 -5
- package/docs/agent-notes/tasks.md +5 -2
- package/docs/agent-notes/tests.md +4 -3
- package/docs/cooperbench.md +1 -1
- package/docs/design/adapters.md +4 -0
- package/docs/design/cli-output-inventory.md +162 -152
- package/docs/design/cli-output.md +4 -3
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/roadmap.md +2 -0
- package/docs/design/task-board.md +1 -0
- package/docs/dogfood.md +14 -0
- package/docs/events.md +4 -2
- package/docs/memory.md +5 -3
- package/docs/operations.md +210 -16
- package/docs/quickstart.md +12 -2
- package/docs/roles.md +1 -1
- package/docs/sdlc.md +26 -3
- package/docs/security.md +11 -5
- package/docs/specs/2026-09-19-agent-hub-design.md +43 -0
- package/docs/specs/2026-09-19-multi-project-design.md +4 -0
- package/docs/specs/2026-09-20-upgrade-recovery-design.md +17 -0
- package/docs/specs/mcp-endpoint.md +63 -0
- package/docs/verification/2026-11-30-capability-listing-shape-1808.md +45 -0
- package/docs/verification/2026-11-30-upgrade-keep-1807.md +174 -0
- package/docs/verification/2026-12-01-1811-confirmation-receipt.md +19 -0
- package/docs/verification/2026-12-01-1811-orca-agent-list.md +20 -0
- package/docs/verification/2026-12-01-1811-orca-pane-key.md +21 -0
- package/docs/verification/2026-12-02-1819-claude-process-after-renewal.md +54 -0
- package/docs/verification/2026-12-02-agy-1.5.21.md +74 -0
- package/docs/verification/2026-12-02-claude-implementer-2.1.334.md +44 -0
- package/docs/verification/2026-12-02-cli-import-graph.md +33 -0
- package/docs/verification/2026-12-03-0.52.0.md +150 -0
- package/docs/verification/2026-12-03-codex-0173-reviewer-isolation.md +53 -0
- package/docs/verification/2026-12-03-codex-0173-reviewer-tool-call.md +34 -0
- package/docs/verification/2026-12-03-jcode-1.3.0.md +25 -0
- package/docs/verification/agy/README.md +17 -0
- package/docs/verification/agy/cli-surface.ts +68 -0
- package/docs/verification/agy/interactive-bridge.ts +92 -0
- package/docs/verification/agy/interactive-session.ts +131 -0
- package/docs/verification/agy/launcher-nonce.ts +215 -0
- package/docs/verification/agy/native-hooks.ts +210 -0
- package/docs/verification/agy/originals/agent-hub-681/cli-surface.ts +87 -0
- package/docs/verification/agy/originals/agent-hub-681/native-hooks-adapted.ts +91 -0
- package/docs/verification/agy/originals/agent-hub-681/tui-actual.ts +200 -0
- package/docs/verification/agy/originals/agent-hub-684/probe.ts +107 -0
- package/docs/verification/agy/originals.json +25 -0
- package/docs/verification/agy/permission-new-functions.ts +128 -0
- package/docs/verification/agy/run-probe.py +108 -0
- package/docs/verification/agy/runtime.ts +171 -0
- package/docs/verification/agy/tmux-helper-control.ts +6 -0
- package/docs/verification/agy/tmux-session.ts +235 -0
- package/docs/verified.json +82 -41
- package/package.json +3 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/compat.json +157 -0
- package/plugins/agent-hub/kimi-hook.js +621 -865
- package/plugins/agent-hub/server.js +17423 -32962
- package/src/adapters/agy/definition.ts +7 -24
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel.ts +38 -257
- package/src/adapters/claude-implementer.ts +3 -1
- package/src/adapters/codex-appserver.ts +77 -15
- package/src/adapters/compat.ts +74 -11
- package/src/adapters/configured-acp.ts +23 -163
- package/src/adapters/configured-adapter-policy.ts +160 -0
- package/src/adapters/configured-pull-entry.ts +53 -0
- package/src/adapters/configured-pull.ts +38 -0
- package/src/adapters/conformance/fakes/app-server.ts +9 -2
- package/src/adapters/declaration-catalog.ts +25 -0
- package/src/adapters/declaration-data.ts +342 -0
- package/src/adapters/declaration-resolution.ts +53 -0
- package/src/adapters/definitions/builtin-metadata.ts +61 -83
- package/src/adapters/definitions/jcode-launch.ts +13 -0
- package/src/adapters/definitions/native-adapter-policy.ts +390 -0
- package/src/adapters/definitions/native-cli-claude-launch.ts +3 -2
- package/src/adapters/definitions/native-cli-codex-launch.ts +2 -1
- package/src/adapters/definitions/native-cli-entry-jcode.ts +4 -2
- package/src/adapters/definitions/native-cli-entry-types.ts +9 -2
- package/src/adapters/definitions/native-cli-launch-common.ts +2 -2
- package/src/adapters/definitions/native-cli-retained.ts +1 -1
- package/src/adapters/definitions/native-configuration.ts +18 -0
- package/src/adapters/definitions/native-help.ts +24 -0
- package/src/adapters/definitions/native-launch-declarations.ts +34 -0
- package/src/adapters/definitions/native-launch-policy.ts +4 -0
- package/src/adapters/definitions/native-launch-settings.ts +72 -0
- package/src/adapters/definitions/native-light-cli.ts +18 -0
- package/src/adapters/definitions/native-light-preview.ts +10 -0
- package/src/adapters/definitions/native-wrapper-launch.ts +10 -0
- package/src/adapters/definitions/qwen.ts +6 -29
- package/src/adapters/definitions/reviewer-variants.ts +7 -8
- package/src/adapters/external-declarations.ts +31 -0
- package/src/adapters/external-modules.ts +4 -29
- package/src/adapters/jcode.ts +3 -12
- package/src/adapters/native-capabilities.ts +18 -8
- package/src/adapters/native-proof-ports.ts +1 -1
- package/src/adapters/presets.ts +136 -0
- package/src/adapters/qwen-dual.ts +2 -2
- package/src/adapters/registry-types.ts +3 -0
- package/src/adapters/registry.ts +20 -81
- package/src/adapters/reviewer-print.ts +26 -9
- package/src/adapters/role-eligibility.ts +2 -1
- package/src/cli/accounts-import.ts +72 -0
- package/src/cli/agents-latest-table.ts +88 -0
- package/src/cli/agents-latest.ts +22 -0
- package/src/cli/agents-output.ts +10 -0
- package/src/cli/agents-presets.ts +100 -0
- package/src/cli/agents.ts +1 -1
- package/src/cli/attention.ts +3 -2
- package/src/cli/autonomy-homes.ts +7 -2
- package/src/cli/budget-renew-guidance.ts +129 -0
- package/src/cli/claude-homes.ts +9 -5
- package/src/cli/command-context.ts +3 -0
- package/src/cli/command-table.ts +123 -0
- package/src/cli/commands/accounts.ts +8 -0
- package/src/cli/commands/agents.ts +18 -0
- package/src/cli/commands/answer.ts +28 -0
- package/src/cli/commands/ask.ts +17 -0
- package/src/cli/commands/autonomy.ts +83 -0
- package/src/cli/commands/backlog.ts +46 -0
- package/src/cli/commands/bench.ts +60 -0
- package/src/cli/commands/board.ts +48 -0
- package/src/cli/commands/broker.ts +9 -0
- package/src/cli/commands/budget.ts +96 -0
- package/src/cli/commands/capabilities.ts +12 -0
- package/src/cli/commands/check-path.ts +55 -0
- package/src/cli/commands/completion.ts +8 -0
- package/src/cli/commands/console.ts +12 -0
- package/src/cli/commands/daemon.ts +8 -0
- package/src/cli/commands/deliverables.ts +25 -0
- package/src/cli/commands/doctor.ts +249 -0
- package/src/cli/commands/down.ts +3 -0
- package/src/cli/commands/export.ts +15 -0
- package/src/cli/commands/facts.ts +15 -0
- package/src/cli/commands/goal.ts +22 -0
- package/src/cli/commands/guidance.ts +102 -0
- package/src/cli/commands/help.ts +17 -0
- package/src/cli/commands/host.ts +45 -0
- package/src/cli/commands/init.ts +121 -0
- package/src/cli/commands/instructed.ts +19 -0
- package/src/cli/commands/instruction-hook.ts +15 -0
- package/src/cli/commands/intake.ts +24 -0
- package/src/cli/commands/kill.ts +15 -0
- package/src/cli/commands/learn.ts +23 -0
- package/src/cli/commands/lineage.ts +30 -0
- package/src/cli/commands/logs.ts +21 -0
- package/src/cli/commands/manager.ts +15 -0
- package/src/cli/commands/memory.ts +21 -0
- package/src/cli/commands/model.ts +25 -0
- package/src/cli/commands/models.ts +40 -0
- package/src/cli/commands/native.ts +39 -0
- package/src/cli/commands/pause.ts +5 -0
- package/src/cli/commands/peer.ts +32 -0
- package/src/cli/commands/permission.ts +26 -0
- package/src/cli/commands/permit.ts +12 -0
- package/src/cli/commands/pet.ts +24 -0
- package/src/cli/commands/projects.ts +49 -0
- package/src/cli/commands/queue.ts +70 -0
- package/src/cli/commands/recovery-run.ts +13 -0
- package/src/cli/commands/recovery.ts +130 -0
- package/src/cli/commands/release.ts +23 -0
- package/src/cli/commands/releases.ts +9 -0
- package/src/cli/commands/remember.ts +6 -0
- package/src/cli/commands/report.ts +27 -0
- package/src/cli/commands/research.ts +53 -0
- package/src/cli/commands/reset.ts +89 -0
- package/src/cli/commands/restart.ts +5 -0
- package/src/cli/commands/results.ts +31 -0
- package/src/cli/commands/resume.ts +5 -0
- package/src/cli/commands/review.ts +24 -0
- package/src/cli/commands/roadmap.ts +21 -0
- package/src/cli/commands/role.ts +34 -0
- package/src/cli/commands/roles.ts +30 -0
- package/src/cli/commands/room.ts +14 -0
- package/src/cli/commands/roster.ts +48 -0
- package/src/cli/commands/route.ts +9 -0
- package/src/cli/commands/say.ts +21 -0
- package/src/cli/commands/schedule.ts +17 -0
- package/src/cli/commands/sdlc.ts +321 -0
- package/src/cli/commands/settings.ts +148 -0
- package/src/cli/commands/setup.ts +89 -0
- package/src/cli/commands/shared-refusals.ts +25 -0
- package/src/cli/commands/smoke.ts +44 -0
- package/src/cli/commands/source.ts +64 -0
- package/src/cli/commands/specs.ts +13 -0
- package/src/cli/commands/status.ts +28 -0
- package/src/cli/commands/stop.ts +17 -0
- package/src/cli/commands/structure.ts +60 -0
- package/src/cli/commands/study.ts +39 -0
- package/src/cli/commands/tail.ts +19 -0
- package/src/cli/commands/task.ts +114 -0
- package/src/cli/commands/title.ts +17 -0
- package/src/cli/commands/turns.ts +10 -0
- package/src/cli/commands/ui.ts +47 -0
- package/src/cli/commands/undo.ts +77 -0
- package/src/cli/commands/up.ts +39 -0
- package/src/cli/commands/upgrade.ts +5 -0
- package/src/cli/commands/usage.ts +33 -0
- package/src/cli/commands/version.ts +5 -0
- package/src/cli/commands/watch.ts +30 -0
- package/src/cli/commands/worktrees.ts +31 -0
- package/src/cli/console-state.ts +5 -138
- package/src/cli/console-versions.ts +1 -1
- package/src/cli/help.ts +37 -15
- package/src/cli/identity.ts +23 -4
- package/src/cli/launch-check.ts +1 -2
- package/src/cli/launch.ts +13 -82
- package/src/cli/light-dispatch.ts +29 -0
- package/src/cli/main.js +8 -1
- package/src/cli/main.ts +233 -2816
- package/src/cli/orca-probe.ts +119 -0
- package/src/cli/output.ts +31 -2
- package/src/cli/preview.ts +10 -5
- package/src/cli/recovery-version-preflight.ts +28 -9
- package/src/cli/replace-process.ts +22 -0
- package/src/cli/report-layout.ts +142 -0
- package/src/cli/roadmap-usage.ts +16 -0
- package/src/cli/roadmap.ts +3 -16
- package/src/cli/sdlc-doctor.ts +27 -0
- package/src/cli/sdlc-output.ts +55 -1
- package/src/cli/setup-homes.ts +1 -1
- package/src/cli/start-agents-run.ts +1 -1
- package/src/cli/statusline-tee.ts +25 -4
- package/src/cli/terminal-recovery.ts +53 -10
- package/src/cli/upgrade-interactive.ts +1 -0
- package/src/cli/upgrade-runtime.ts +11 -0
- package/src/cli/upgrade.ts +4 -15
- package/src/hub/accounts.ts +148 -0
- package/src/hub/addons.ts +20 -0
- package/src/hub/agent-drift.ts +2 -1
- package/src/hub/budget-projection.ts +39 -7
- package/src/hub/budget.ts +231 -16
- package/src/hub/channel-project.ts +3 -3
- package/src/hub/conductor-peer.ts +24 -0
- package/src/hub/conductor.ts +2 -21
- package/src/hub/config-apply.ts +24 -13
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +2 -0
- package/src/hub/config.ts +31 -14
- package/src/hub/control-client.ts +48 -0
- package/src/hub/daemon.ts +421 -61
- package/src/hub/events.ts +3 -0
- package/src/hub/home-tag.ts +12 -0
- package/src/hub/host.ts +217 -0
- package/src/hub/hub-tools.ts +2 -1
- package/src/hub/instance-budget.ts +2 -2
- package/src/hub/instance-config.ts +15 -126
- package/src/hub/instances.ts +22 -6
- package/src/hub/instruction-receipt.ts +2 -2
- package/src/hub/kimi-usage.ts +38 -11
- package/src/hub/lifecycle.ts +86 -4
- package/src/hub/mcp-bridge-core.ts +98 -0
- package/src/hub/mcp-channel-push.ts +20 -0
- package/src/hub/mcp-endpoint-serve.ts +178 -0
- package/src/hub/mcp-endpoint.ts +226 -0
- package/src/hub/mcp-tool-call.ts +181 -0
- package/src/hub/operational-settings.ts +2 -0
- package/src/hub/orca-env.ts +6 -0
- package/src/hub/orca-state.ts +84 -0
- package/src/hub/peers.ts +5 -1
- package/src/hub/permission-mode.ts +2 -1
- package/src/hub/project.ts +20 -0
- package/src/hub/protocol-window.ts +58 -0
- package/src/hub/quota-origin.ts +20 -0
- package/src/hub/registry.ts +36 -2
- package/src/hub/report.ts +1 -1
- package/src/hub/research.ts +1 -1
- package/src/hub/review-brief.ts +47 -2
- package/src/hub/roster.ts +6 -3
- package/src/hub/routing.ts +9 -2
- package/src/hub/sdlc-check.ts +205 -0
- package/src/hub/sdlc-sync.ts +146 -0
- package/src/hub/sdlc.ts +33 -4
- package/src/hub/settings.ts +7 -4
- package/src/hub/start-agents.ts +1 -1
- package/src/hub/start-mode.ts +11 -4
- package/src/hub/structure-budget.ts +131 -0
- package/src/hub/structure-scan.ts +149 -0
- package/src/hub/tasks-experiment.ts +455 -0
- package/src/hub/tasks-guidance.ts +606 -0
- package/src/hub/tasks-roadmap-plan.ts +419 -0
- package/src/hub/tasks-roadmap.ts +491 -0
- package/src/hub/tasks-study.ts +661 -0
- package/src/hub/tasks-survey.ts +192 -0
- package/src/hub/tasks.ts +319 -2548
- package/src/hub/terminal-open.ts +5 -3
- package/src/hub/tooling.ts +3 -19
- package/src/hub/usage-rollup.ts +9 -3
- package/src/local/tools.ts +5 -0
- package/src/ui/index.html +1 -1
- package/src/ui/needs.ts +17 -5
- package/src/ui/peer-palette.ts +2 -4
- package/templates/presets/agents.json +60 -0
- package/templates/presets/confirmation-matrix.json +8 -8
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NATIVE_ADAPTER_POLICY as policy } from "./native-adapter-policy.ts";
|
|
2
|
+
import type { NativeCliDispatchEntry, NativeCliEntryContext } from "./native-cli-entry-types.ts";
|
|
3
|
+
|
|
4
|
+
function entry(
|
|
5
|
+
kind: "claude" | "codex" | "jcode",
|
|
6
|
+
execute: (context: NativeCliEntryContext) => Promise<void>,
|
|
7
|
+
): NativeCliDispatchEntry {
|
|
8
|
+
const { metadata, cli } = policy[kind];
|
|
9
|
+
return Object.freeze({ command: cli.command, lifecycleAdmission: true, execute,
|
|
10
|
+
definition: Object.freeze({ transport: metadata.transport, cli, session: {} }),
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const LIGHT_NATIVE_CLI_ENTRIES = Object.freeze({
|
|
15
|
+
claude: entry("claude", async context => (await import("./native-cli-entry-claude.ts")).runClaudeEntry(context)),
|
|
16
|
+
codex: entry("codex", async context => (await import("./native-cli-entry-codex.ts")).runCodexEntry(context)),
|
|
17
|
+
jcode: entry("jcode", async context => (await import("./native-cli-entry-jcode.ts")).runJcodeEntry(context)),
|
|
18
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { previewClaude } from "./native-cli-preview-claude.ts";
|
|
2
|
+
import { previewCodex } from "./native-cli-preview-codex.ts";
|
|
3
|
+
import { previewJcode } from "./native-cli-preview-jcode.ts";
|
|
4
|
+
import type { NativePreviewBuilder } from "./native-cli-preview-common.ts";
|
|
5
|
+
|
|
6
|
+
const lightPreviews: Readonly<Partial<Record<string, NativePreviewBuilder>>> = Object.freeze({ claude: previewClaude, codex: previewCodex, jcode: previewJcode });
|
|
7
|
+
|
|
8
|
+
export function lightNativePreview(tool: string): NativePreviewBuilder | undefined {
|
|
9
|
+
return Object.hasOwn(lightPreviews, tool) ? lightPreviews[tool] : undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { claudeNativeLaunch } from "./native-cli-claude-launch.ts";
|
|
2
|
+
import { codexNativeLaunch } from "./native-cli-codex-launch.ts";
|
|
3
|
+
import type { LaunchContext, LaunchPlan } from "../registry-types.ts";
|
|
4
|
+
|
|
5
|
+
const launchers = { claude: claudeNativeLaunch, codex: codexNativeLaunch };
|
|
6
|
+
|
|
7
|
+
export function nativeWrapperLaunch(kind: keyof typeof launchers, context: LaunchContext): LaunchPlan {
|
|
8
|
+
if (!Object.hasOwn(launchers, kind)) throw new Error("native launch definition unavailable");
|
|
9
|
+
return launchers[kind](context);
|
|
10
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NATIVE_WATCH_CAPABILITIES, NATIVE_ADAPTER_POLICY } from "./native-adapter-policy.ts";
|
|
2
2
|
import { runQwenEntry } from "./native-cli-entry-qwen.ts";
|
|
3
3
|
import { previewQwen } from "./native-cli-preview-qwen.ts";
|
|
4
4
|
import { QWEN_DISPLAY } from "./native-display.ts";
|
|
@@ -11,25 +11,11 @@ import { createQwenDual } from "./native-factories.ts";
|
|
|
11
11
|
|
|
12
12
|
/** Production Qwen policy. Legacy AcpPeer callers opt in separately through qwen025. */
|
|
13
13
|
export const QWEN_DEFINITION: AdapterDefinition = {
|
|
14
|
-
|
|
15
|
-
kind: "qwen",
|
|
16
|
-
projection: { roleRank: 5, helpRank: 5, plannerEligible: true, conductorEligible: false, reviewerEligible: true },
|
|
17
|
-
displayName: "Qwen Code",
|
|
18
|
-
family: "qwen",
|
|
19
|
-
transport: "acp",
|
|
20
|
-
roles: ["implementer", "verifier"],
|
|
21
|
-
optional: true,
|
|
14
|
+
...NATIVE_ADAPTER_POLICY.qwen.metadata,
|
|
22
15
|
defaultOnRoster: false,
|
|
23
|
-
|
|
16
|
+
|
|
24
17
|
start: {
|
|
25
|
-
|
|
26
|
-
forms: ["headless"],
|
|
27
|
-
defaultForm: "headless",
|
|
28
|
-
conductorStartable: true,
|
|
29
|
-
// #608: the TUI is explicit only, so `ahub up` never starts Qwen from the start set; the text names why.
|
|
30
|
-
upStart: { allowed: false, refusal: "the hub never opens its TUI, and a Qwen is started only by ahub qwen" },
|
|
31
|
-
hubSwitches: [],
|
|
32
|
-
ownedFlags: [],
|
|
18
|
+
...NATIVE_ADAPTER_POLICY.qwen.start,
|
|
33
19
|
// The TUI (#286 Part 3) is explicit only: forms stays headless, so Qwen never becomes a start-mode peer and the hub never opens it by itself.
|
|
34
20
|
preflight: request => request.form !== undefined && request.form !== "headless" && request.form !== "tui"
|
|
35
21
|
? "unknown Qwen mode; usage: ahub qwen [--mode headless|tui]" : undefined,
|
|
@@ -47,15 +33,6 @@ export const QWEN_DEFINITION: AdapterDefinition = {
|
|
|
47
33
|
},
|
|
48
34
|
conductorStartArgs: args => args.length ? new Error("conductor starts accept no launch overrides; use ahub qwen") : {},
|
|
49
35
|
},
|
|
50
|
-
identity: { mcp: "acp-session" },
|
|
51
|
-
instances: { mode: "headless" },
|
|
52
|
-
permission: {
|
|
53
|
-
grants: {
|
|
54
|
-
ask: "every write, edit and shell command asks",
|
|
55
|
-
"ask-when-needed": "Qwen auto-edit approves file edits; shell commands ask; NO hub sandbox",
|
|
56
|
-
"never-ask": "Qwen yolo approves every tool; NO hub sandbox",
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
36
|
session: {
|
|
60
37
|
idField: "sessionId",
|
|
61
38
|
currentId: peer => {
|
|
@@ -73,8 +50,8 @@ export const QWEN_DEFINITION: AdapterDefinition = {
|
|
|
73
50
|
turnEnd: "adapter",
|
|
74
51
|
settle: { signal: "message-stop" },
|
|
75
52
|
budget: { account: "qwen" },
|
|
76
|
-
capabilities:
|
|
77
|
-
cli: {
|
|
53
|
+
capabilities: NATIVE_WATCH_CAPABILITIES,
|
|
54
|
+
cli: { ...NATIVE_ADAPTER_POLICY.qwen.cli, entry: { lifecycleAdmission: true, execute: runQwenEntry }, preview: previewQwen },
|
|
78
55
|
display: QWEN_DISPLAY,
|
|
79
56
|
hooks: { recallPlatform: "qwen" },
|
|
80
57
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { freshReviewerPolicy, NATIVE_FRESH_REVIEWER_FACTORY } from "./native-adapter-policy.ts";
|
|
1
2
|
import type { AdapterDefinition } from "../registry-types.ts";
|
|
2
3
|
import { claudeReviewerBackend } from "../claude-print.ts";
|
|
3
4
|
import { codexReviewerBackend } from "../codex-review-isolation.ts";
|
|
@@ -6,19 +7,17 @@ import { createReviewer, createCodexReviewer } from "./native-factories.ts";
|
|
|
6
7
|
import { CODEX_DISPLAY, KIMI_DISPLAY } from "./native-display.ts";
|
|
7
8
|
|
|
8
9
|
export { claudeReviewerBackend };
|
|
9
|
-
function reviewerVariant(kind:
|
|
10
|
+
function reviewerVariant(kind: keyof typeof NATIVE_FRESH_REVIEWER_FACTORY, displayName: string, reviewer: NonNullable<AdapterDefinition["reviewer"]>, display: AdapterDefinition["display"]): AdapterDefinition {
|
|
11
|
+
const hasFactory = NATIVE_FRESH_REVIEWER_FACTORY[kind];
|
|
12
|
+
const policy = freshReviewerPolicy(kind, displayName, hasFactory);
|
|
10
13
|
return {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
start: { ...(reviewer.backend ? { create: createReviewer, daemonPort: "reviewer-print" as const } : {}), forms: ["headless"], defaultForm: "headless",
|
|
14
|
-
conductorStartable: true, hubSwitches: [], ownedFlags: [] },
|
|
15
|
-
identity: { mcp: "env" }, instances: { mode: "headless" },
|
|
16
|
-
permission: { unmanaged: "fresh read-only reviewer; an isolation receipt is required before startup" },
|
|
14
|
+
...policy,
|
|
15
|
+
start: { ...policy.start, ...(hasFactory ? { create: createReviewer } : {}) },
|
|
17
16
|
session: { idField: "sessionId", currentId: () => undefined, freshOnRestore: true, launchKind: "reviewer-print", crashPlan: () => ({ resume: {}, how: "starts a fresh isolated review session" }) },
|
|
18
17
|
turnEnd: "adapter", budget: { account: kind }, routing: { reviewOnly: true },
|
|
19
18
|
// A fresh reviewer never inherits a long-lived ACP setter through a base/variant merge.
|
|
20
19
|
modelOverride: undefined,
|
|
21
|
-
reviewer,
|
|
20
|
+
reviewer, display,
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
23
|
const codexVariant = reviewerVariant("codex", "Codex reviewer", { backend: codexReviewerBackend, defaultPool: true, declaration: "explicit", scope: "code" }, CODEX_DISPLAY);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { moduleDataObject as dataObject, moduleText as text, moduleArray as array } from "./external-metadata.ts";
|
|
2
|
+
import { configRefusal } from "../hub/config-trust.ts";
|
|
3
|
+
|
|
4
|
+
export interface AdapterModuleDeclaration { readonly path: string; readonly sha256: string }
|
|
5
|
+
export interface ModuleConfigLayer { name: string; raw: Record<string, unknown> }
|
|
6
|
+
const MAX_MODULES = 16;
|
|
7
|
+
export class ExternalAdapterRefusal extends Error {}
|
|
8
|
+
export const refuseExternalAdapter = (reason: string): never => { throw new ExternalAdapterRefusal(`external adapter: ${reason}`); };
|
|
9
|
+
export function adapterModuleDeclarations(raw: unknown): readonly AdapterModuleDeclaration[] {
|
|
10
|
+
if (raw === undefined) return Object.freeze([]);
|
|
11
|
+
return Object.freeze(array(raw, MAX_MODULES).map(value => {
|
|
12
|
+
const row = dataObject(value);
|
|
13
|
+
if (Object.keys(row).some(key => !["path", "sha256"].includes(key))) return refuseExternalAdapter("unknown module declaration field");
|
|
14
|
+
const path = text(row.path, 4096), hash = row.sha256;
|
|
15
|
+
if (typeof hash !== "string" || !/^[a-f0-9]{64}$/i.test(hash)) return refuseExternalAdapter("a SHA-256 content pin is required");
|
|
16
|
+
return Object.freeze({ path, sha256: hash.toLowerCase() });
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** This reads declarations only. It never imports code, including for reloads and CLI reads. */
|
|
21
|
+
export function readAdapterModuleDeclarations(cwd: string, layers: readonly ModuleConfigLayer[]) {
|
|
22
|
+
const ignored: string[] = [];
|
|
23
|
+
let modules: readonly AdapterModuleDeclaration[] = Object.freeze([]);
|
|
24
|
+
for (const { name, raw } of layers) {
|
|
25
|
+
if (raw.adapter_modules === undefined) continue;
|
|
26
|
+
const refusal = name !== "config.local.json" ? "modules are machine-local config.local.json values" : configRefusal(cwd, name);
|
|
27
|
+
if (refusal) { ignored.push(`adapter_modules in .agenthub/${name} ignored: ${refusal}`); continue; }
|
|
28
|
+
modules = adapterModuleDeclarations(raw.adapter_modules);
|
|
29
|
+
}
|
|
30
|
+
return { modules, ignored };
|
|
31
|
+
}
|
|
@@ -11,12 +11,11 @@ import { configRefusal } from "../hub/config-trust.ts";
|
|
|
11
11
|
import { realPath } from "../hub/project.ts";
|
|
12
12
|
import { scanModuleSource } from "./external-module-scan.ts";
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
import { readAdapterModuleDeclarations, ExternalAdapterRefusal, refuseExternalAdapter as fail, type AdapterModuleDeclaration, type ModuleConfigLayer } from "./external-declarations.ts";
|
|
15
|
+
export { adapterModuleDeclarations, readAdapterModuleDeclarations, type AdapterModuleDeclaration } from "./external-declarations.ts";
|
|
16
|
+
|
|
17
|
+
const MAX_MODULE_BYTES = 2 * 1024 * 1024;
|
|
17
18
|
const ADAPTER_IMPORT = "@staix/agent-hub/adapter";
|
|
18
|
-
class ExternalAdapterRefusal extends Error {}
|
|
19
|
-
const fail = (reason: string): never => { throw new ExternalAdapterRefusal(`external adapter: ${reason}`); };
|
|
20
19
|
const digest = (bytes: Uint8Array) => createHash("sha256").update(bytes).digest("hex");
|
|
21
20
|
export interface ExternalModuleIdentity {
|
|
22
21
|
readonly projectRoot: string;
|
|
@@ -50,30 +49,6 @@ export function externalModuleIdentityCurrent(definition: AdapterDefinition): bo
|
|
|
50
49
|
&& (current.mode & 0o002) === 0 && readFileSync(file, "utf8") === source && !configRefusal(root, "config.local.json");
|
|
51
50
|
} catch { return false; }
|
|
52
51
|
}
|
|
53
|
-
export function adapterModuleDeclarations(raw: unknown): readonly AdapterModuleDeclaration[] {
|
|
54
|
-
if (raw === undefined) return Object.freeze([]);
|
|
55
|
-
return Object.freeze(array(raw, MAX_MODULES).map(value => {
|
|
56
|
-
const row = dataObject(value);
|
|
57
|
-
if (Object.keys(row).some(key => !["path", "sha256"].includes(key))) return fail("unknown module declaration field");
|
|
58
|
-
const path = text(row.path, 4096), hash = row.sha256;
|
|
59
|
-
if (typeof hash !== "string" || !/^[a-f0-9]{64}$/i.test(hash)) return fail("a SHA-256 content pin is required");
|
|
60
|
-
return Object.freeze({ path, sha256: hash.toLowerCase() });
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** This reads declarations only. It never imports code, including for reloads and CLI reads. */
|
|
65
|
-
export function readAdapterModuleDeclarations(cwd: string, layers: readonly ModuleConfigLayer[]) {
|
|
66
|
-
const ignored: string[] = [];
|
|
67
|
-
let modules: readonly AdapterModuleDeclaration[] = Object.freeze([]);
|
|
68
|
-
for (const { name, raw } of layers) {
|
|
69
|
-
if (raw.adapter_modules === undefined) continue;
|
|
70
|
-
const refusal = name !== "config.local.json" ? "modules are machine-local config.local.json values" : configRefusal(cwd, name);
|
|
71
|
-
if (refusal) { ignored.push(`adapter_modules in .agenthub/${name} ignored: ${refusal}`); continue; }
|
|
72
|
-
modules = adapterModuleDeclarations(raw.adapter_modules);
|
|
73
|
-
}
|
|
74
|
-
return { modules, ignored };
|
|
75
|
-
}
|
|
76
|
-
|
|
77
52
|
const inside = (root: string, file: string) => { const part = relative(root, file); return part !== "" && part !== ".." && !part.startsWith(`..${sep}`) && !isAbsolute(part); };
|
|
78
53
|
function regularPath(root: string, file: string) {
|
|
79
54
|
if (!inside(root, file)) return fail("module must be inside the project root");
|
package/src/adapters/jcode.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { jcodeCommand, jcodeTuiCommand, JCODE_HEADLESS_AFTER_RECOVERY } from "./definitions/jcode-launch.ts";
|
|
2
|
+
export { jcodeCommand, jcodeTuiCommand, JCODE_HEADLESS_AFTER_RECOVERY } from "./definitions/jcode-launch.ts";
|
|
1
3
|
import type { ActivityTable } from "./definitions/native-activity.ts";
|
|
2
4
|
import { spawn, spawnSync, type ChildProcess } from "node:child_process";
|
|
3
5
|
import { assessVersion, COMPAT, type CompatVerdict } from "./compat.ts";
|
|
@@ -23,11 +25,6 @@ export interface JcodeOptions extends Omit<AcpOptions, "cmd" | "qwen025" | "expe
|
|
|
23
25
|
/** #1085: what the hub knows that the adapter does not, asked when status is built: is this peer's start mode tui, and did this hub run start after a crash report. */
|
|
24
26
|
tuiHintContext?: () => { tui: boolean; afterCrash: boolean };
|
|
25
27
|
}
|
|
26
|
-
export function jcodeCommand(command: string[], kind: "serve" | "acp", socket: string, cwd: string, model?: string, profile?: string, provider?: string, peer = "jcode"): string[] {
|
|
27
|
-
if (!command.length || command.some(word => typeof word !== "string" || !word)) throw new Error("jcode_cmd must name an executable argv");
|
|
28
|
-
return [...command, kind, "--socket", socket, "--cwd", cwd, "--no-update", "--no-selfdev", ...(provider ? ["-p", provider] : []), ...(model ? ["--model", model] : []), ...(profile ? ["--provider-profile", profile] : []),
|
|
29
|
-
...(kind === "serve" ? ["--temporary-server", "--owner-pid", String(process.pid), "--server-name", `agent-hub-${peer}`] : ["--mcp-tools", "eager"])];
|
|
30
|
-
}
|
|
31
28
|
/**
|
|
32
29
|
* #1601: the one host sentence a configured Jcode may write to hub.log, because the daemon replaces every line this adapter's
|
|
33
30
|
* own `log` port would carry with "Jcode native diagnostic: details withheld". It names the cause class, the ceiling's minutes,
|
|
@@ -46,12 +43,6 @@ export interface JcodeTuiBinding { launchId: string; sessionId: string }
|
|
|
46
43
|
export type JcodeTuiState = { state: "waiting"; binding: JcodeTuiBinding } |
|
|
47
44
|
{ state: "ready"; binding: JcodeTuiBinding; launch: { cmd: string; args: string[]; env: NodeJS.ProcessEnv } };
|
|
48
45
|
|
|
49
|
-
export function jcodeTuiCommand(command: string[], socket: string, sessionId: string, model?: string, profile?: string, provider?: string): string[] {
|
|
50
|
-
if (!command.length || command.some(word => typeof word !== "string" || !word)) throw new Error("jcode_cmd must name an executable argv");
|
|
51
|
-
return [...command, "--socket", socket, "--resume", sessionId, "--no-update", "--no-selfdev", ...(provider ? ["-p", provider] : []),
|
|
52
|
-
...(model ? ["--model", model] : []), ...(profile ? ["--provider-profile", profile] : [])];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
46
|
/** Read native persistence only. Never synthesize a native session or send a save-inducing prompt. */
|
|
56
47
|
function savedSession(home: string, id: string): boolean {
|
|
57
48
|
if (!/^[A-Za-z0-9_-]{1,128}$/.test(id)) throw new Error("invalid native session identity");
|
|
@@ -95,7 +86,7 @@ export class JcodeTuiRefusal extends Error {
|
|
|
95
86
|
constructor(readonly code: JcodeTuiRefusalCode) { super(`owned Jcode TUI launch refused: ${code}`); }
|
|
96
87
|
}
|
|
97
88
|
/** #1085: said by `ahub status` while a recovered headless Jcode has not yet opened its TUI, and by the launcher when `ahub jcode` finds it running headless. */
|
|
98
|
-
|
|
89
|
+
|
|
99
90
|
/**
|
|
100
91
|
* #1668: what `ahub status` says while a rostered Jcode peer's socket is served by a server the hub did not start, handed to the daemon by the hello that
|
|
101
92
|
* admission refused. It names the cause class and the launch that puts the peer back under the hub, and carries no launch id, socket or path.
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
// #445 C1: what the hub can read of a native peer's own skills and commands, and the only versions it was probed on (C0 receipt, 2026-10-30).
|
|
2
2
|
// Vendor identities and listing shapes live here, in the adapter layer, never in the core rules of `src/hub/capabilities.ts` (the #451 registry guard).
|
|
3
|
+
import { COMPAT, assessVersion } from "./compat.ts";
|
|
3
4
|
import { buildManifest, type Candidate, type CapabilityManifest, type FlatSchema } from "../hub/capabilities.ts";
|
|
4
5
|
|
|
5
6
|
const object = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// used-by: src/adapters/native-capabilities.ts
|
|
9
|
+
/** The vendor names of the three listings and the version their C0 receipt probed, read from the `COMPAT` entry (`verified[0]`), never held here (#1808). */
|
|
8
10
|
export const NATIVE_PINS = Object.freeze({
|
|
9
|
-
kimi: { agent: "Kimi Code CLI", version: "
|
|
10
|
-
qwen: { agent: "qwen-code", version: "0
|
|
11
|
-
codex: { agent: "codex", version: "
|
|
11
|
+
kimi: { agent: "Kimi Code CLI", version: COMPAT["kimi-capabilities"].verified[0] },
|
|
12
|
+
qwen: { agent: "qwen-code", version: COMPAT["qwen-capabilities"].verified[0] },
|
|
13
|
+
codex: { agent: "codex", version: COMPAT["codex-capabilities"].verified[0] },
|
|
12
14
|
} as const);
|
|
15
|
+
/**
|
|
16
|
+
* The one decision whether a capability listing of this version may be shown (#1808, owner choice): a verified version, or an exact version this machine's person trusted
|
|
17
|
+
* with `ahub agents trust`. The trust record is read on every call and never cached, so a revoke works without a restart; an unreadable record trusts nothing, and a
|
|
18
|
+
* version that is refused or cannot be read lists nothing.
|
|
19
|
+
*/
|
|
20
|
+
export function listable(id: "kimi-capabilities" | "qwen-capabilities" | "codex-capabilities", version: unknown): boolean {
|
|
21
|
+
return assessVersion(id, version).ok;
|
|
22
|
+
}
|
|
13
23
|
const STRING_INPUT: FlatSchema = { type: "object", properties: { input: { type: "string" } }, additionalProperties: false };
|
|
14
24
|
const QWEN_SKILL_SOURCES = ["bundled-skill", "skill-dir-command"];
|
|
15
25
|
|
|
@@ -21,8 +31,8 @@ const QWEN_SKILL_SOURCES = ["bundled-skill", "skill-dir-command"];
|
|
|
21
31
|
*/
|
|
22
32
|
export function acpManifest(agent: unknown, version: unknown, update: unknown, observedAt: number): CapabilityManifest {
|
|
23
33
|
const empty: CapabilityManifest = { capabilities: [], observedAt };
|
|
24
|
-
const kind = agent === NATIVE_PINS.kimi.agent &&
|
|
25
|
-
: agent === NATIVE_PINS.qwen.agent &&
|
|
34
|
+
const kind = agent === NATIVE_PINS.kimi.agent && listable("kimi-capabilities", version) ? "kimi"
|
|
35
|
+
: agent === NATIVE_PINS.qwen.agent && listable("qwen-capabilities", version) ? "qwen" : undefined;
|
|
26
36
|
if (!kind || !object(update) || !Array.isArray(update.availableCommands)) return empty;
|
|
27
37
|
const candidates: Candidate[] = [];
|
|
28
38
|
for (const command of update.availableCommands) {
|
|
@@ -34,10 +44,10 @@ export function acpManifest(agent: unknown, version: unknown, update: unknown, o
|
|
|
34
44
|
return buildManifest(candidates, observedAt);
|
|
35
45
|
}
|
|
36
46
|
|
|
37
|
-
/** A Codex `skills/list` answer as capabilities, on
|
|
47
|
+
/** A Codex `skills/list` answer as capabilities, on a verified version, or an exact version the person trusted with `ahub agents trust`, only. Only a skill that says `enabled: true` is listed: a flag that is missing or unreadable is not consent. */
|
|
38
48
|
export function codexSkillsManifest(version: unknown, result: unknown, observedAt: number): CapabilityManifest {
|
|
39
49
|
const candidates: Candidate[] = [];
|
|
40
|
-
if (
|
|
50
|
+
if (listable("codex-capabilities", version) && object(result) && Array.isArray(result.data)) {
|
|
41
51
|
for (const entry of result.data) {
|
|
42
52
|
if (!object(entry) || !Array.isArray(entry.skills)) continue;
|
|
43
53
|
for (const skill of entry.skills) {
|
|
@@ -4,7 +4,7 @@ import { isFixedBuiltinDefinition, type AdapterDefinition } from "./registry.ts"
|
|
|
4
4
|
/** Presence is forbidden on a foreign runtime, including a member whose value is undefined. */
|
|
5
5
|
export function assertNativeProofPorts(definition: AdapterDefinition | undefined, product: PeerAdapter): void {
|
|
6
6
|
if (isFixedBuiltinDefinition(definition)) return;
|
|
7
|
-
for (const port of ["frontendProxy", "statusNotice", "revertTurn"] as const) {
|
|
7
|
+
for (const port of ["frontendProxy", "statusNotice", "revertTurn", "compareQuotaHome", "readQuotaNow"] as const) {
|
|
8
8
|
if (port in product) throw new Error(`${definition?.kind ?? product.id}: ${port} is restricted to fixed builtin adapter products`);
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { shellQuote } from "../cli/shell-quote.ts";
|
|
5
|
+
import presetsJson from "../../templates/presets/agents.json";
|
|
6
|
+
|
|
7
|
+
/** #1809 T1: a known agent CLI as data. A preset names no code; `ahub agents add` turns it into the same declaration a person could write by hand. */
|
|
8
|
+
export interface AgentPreset {
|
|
9
|
+
id: string;
|
|
10
|
+
displayName: string;
|
|
11
|
+
executable: string;
|
|
12
|
+
acp?: { args: string[]; identity: { name: string } };
|
|
13
|
+
versionArgs: string[];
|
|
14
|
+
mcp: { add: string[] | null; check: { file: string; key: string } };
|
|
15
|
+
recorded: string;
|
|
16
|
+
status: "verified" | "untested";
|
|
17
|
+
receipt: string | null;
|
|
18
|
+
}
|
|
19
|
+
interface PresetRow { id: string; displayName: string; executable: string; acp: boolean; status: "verified" | "untested"; receipt: string | null; recorded: string }
|
|
20
|
+
|
|
21
|
+
const REPOSITORY_ROOT = new URL("../../", import.meta.url);
|
|
22
|
+
const KIND = /^[a-z][a-z0-9-]{0,31}$/;
|
|
23
|
+
|
|
24
|
+
function text(value: unknown, at: string): string {
|
|
25
|
+
if (typeof value !== "string" || !value || value.length > 512) throw new Error(`presets: ${at} must be a short nonempty string`);
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
function words(value: unknown, at: string): string[] {
|
|
29
|
+
if (!Array.isArray(value) || value.length > 32) throw new Error(`presets: ${at} must be a short list`);
|
|
30
|
+
return value.map((item, index) => text(item, `${at}[${index}]`));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The presets file read strictly: an unknown field or a wrong type refuses the whole file, so a typo never becomes a launch line. */
|
|
34
|
+
export function loadPresets(raw: unknown = presetsJson): readonly AgentPreset[] {
|
|
35
|
+
const file = raw as { schemaVersion?: unknown; presets?: unknown };
|
|
36
|
+
if (file?.schemaVersion !== 1 || !Array.isArray(file.presets)) throw new Error("presets: unsupported file");
|
|
37
|
+
const seen = new Set<string>();
|
|
38
|
+
return Object.freeze(file.presets.map((entry: Record<string, unknown>, index): AgentPreset => {
|
|
39
|
+
const at = `presets[${index}]`;
|
|
40
|
+
const unknown = Object.keys(entry).filter(key => !["id", "displayName", "executable", "acp", "versionArgs", "mcp", "recorded", "status", "receipt"].includes(key));
|
|
41
|
+
if (unknown.length) throw new Error(`presets: ${at} has unknown field ${unknown[0]}`);
|
|
42
|
+
const id = text(entry.id, `${at}.id`);
|
|
43
|
+
if (!KIND.test(id) || seen.has(id)) throw new Error(`presets: ${at}.id is invalid or repeated`);
|
|
44
|
+
seen.add(id);
|
|
45
|
+
const acp = entry.acp as { args?: unknown; identity?: { name?: unknown } } | undefined;
|
|
46
|
+
const mcp = entry.mcp as { add?: unknown; check?: { file?: unknown; key?: unknown } };
|
|
47
|
+
if (entry.status !== "verified" && entry.status !== "untested") throw new Error(`presets: ${at}.status must be verified or untested`);
|
|
48
|
+
if (entry.receipt !== null && typeof entry.receipt !== "string") throw new Error(`presets: ${at}.receipt must be a path or null`);
|
|
49
|
+
return {
|
|
50
|
+
id, displayName: text(entry.displayName, `${at}.displayName`), executable: text(entry.executable, `${at}.executable`),
|
|
51
|
+
...(acp ? { acp: { args: words(acp.args, `${at}.acp.args`), identity: { name: text(acp.identity?.name, `${at}.acp.identity.name`) } } } : {}),
|
|
52
|
+
versionArgs: words(entry.versionArgs, `${at}.versionArgs`),
|
|
53
|
+
mcp: { add: mcp?.add === null ? null : words(mcp?.add, `${at}.mcp.add`), check: { file: text(mcp?.check?.file, `${at}.mcp.check.file`), key: text(mcp?.check?.key, `${at}.mcp.check.key`) } },
|
|
54
|
+
recorded: text(entry.recorded, `${at}.recorded`), status: entry.status, receipt: entry.receipt as string | null,
|
|
55
|
+
};
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** `verified` only when the row says so and its receipt file is there; every other preset is `untested`, whatever the row claims. */
|
|
60
|
+
function presetStatus(preset: AgentPreset, root: URL = REPOSITORY_ROOT): "verified" | "untested" {
|
|
61
|
+
return preset.status === "verified" && preset.receipt !== null && preset.receipt.startsWith("docs/verification/") && !preset.receipt.includes("..") && existsSync(new URL(preset.receipt, root)) ? "verified" : "untested";
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The status word of a preset id; an id the presets file does not know is `untested`, never an error. */
|
|
65
|
+
export function presetStatusById(id: string, presets: readonly AgentPreset[] = loadPresets()): "verified" | "untested" {
|
|
66
|
+
const row = presets.find(preset => preset.id === id);
|
|
67
|
+
return row ? presetStatus(row) : "untested";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function presetRows(presets: readonly AgentPreset[] = loadPresets(), root?: URL): PresetRow[] {
|
|
71
|
+
return presets.map(preset => ({ id: preset.id, displayName: preset.displayName, executable: preset.executable, acp: preset.acp !== undefined, status: presetStatus(preset, root), receipt: preset.receipt, recorded: preset.recorded }));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The first dotted-number token of a version probe's output, or undefined: the pin a start checks `initialize` against. */
|
|
75
|
+
export function parseProbeVersion(output: string): string | undefined {
|
|
76
|
+
return /\b\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?\b/.exec(output)?.[0];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The `adapters.<kind>` declaration for a preset: exactly the fields a hand-written ACP declaration has, so it passes the same validation. */
|
|
80
|
+
export function presetDeclaration(preset: AgentPreset, resolvedExecutable: string, version: string): Record<string, unknown> {
|
|
81
|
+
if (!preset.acp) throw new Error(`${preset.id} has no headless launch line`);
|
|
82
|
+
return {
|
|
83
|
+
transport: "acp", command: resolvedExecutable, args: [...preset.acp.args], displayName: preset.displayName,
|
|
84
|
+
roles: ["implementer", "verifier"], identity: { name: preset.acp.identity.name, version }, preset: preset.id,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The bridge bundle a pull CLI registers, in the installed package; `agents add --pull` and `ahub doctor` print the same path. */
|
|
89
|
+
export const BRIDGE_BUNDLE = fileURLToPath(new URL("../../plugins/agent-hub/server.js", import.meta.url));
|
|
90
|
+
|
|
91
|
+
/** The name the hub's bridge is registered under in a pull CLI's MCP settings. */
|
|
92
|
+
const BRIDGE_NAME = "agent-hub";
|
|
93
|
+
|
|
94
|
+
/** The `adapters.<kind>` declaration of a pull kind for a preset: the person's own TUI, `tasks: false`, the same fields a hand-written one has. */
|
|
95
|
+
export function presetPullDeclaration(preset: AgentPreset, resolvedExecutable: string): Record<string, unknown> {
|
|
96
|
+
return { transport: "pull", command: resolvedExecutable, args: [], displayName: preset.displayName, roles: ["implementer", "verifier"], versionArgs: [...preset.versionArgs], tasks: false, preset: preset.id };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* What the person runs to register the hub's bridge in the CLI, printed and never run. `{name}`, `{command}` and `{args}` of the preset's template take
|
|
101
|
+
* the bridge name, the Bun that runs it and the bundle path; a preset with no scripted form (`add: null`) says where to put the entry instead.
|
|
102
|
+
*/
|
|
103
|
+
export function registrationText(preset: AgentPreset, bun: string, bridge: string): string {
|
|
104
|
+
if (preset.mcp.add === null) return `${preset.displayName} has no scripted registration: add an MCP server named ${BRIDGE_NAME} that runs ${shellQuote(bun)} ${shellQuote(bridge)} to ${preset.mcp.check.file} under ${preset.mcp.check.key}`;
|
|
105
|
+
const words = preset.mcp.add.flatMap(word => word === "{args}" ? [bridge] : [word.replace("{name}", BRIDGE_NAME).replace("{command}", bun)]);
|
|
106
|
+
return words.map(shellQuote).join(" ");
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Whether the CLI's settings file names the bridge: `present`, `missing` (a readable file without it, or no file) or `unknown` (a file this check cannot read). Reads one file, writes nothing. */
|
|
110
|
+
function registrationState(preset: AgentPreset, home: string): "present" | "missing" | "unknown" {
|
|
111
|
+
const file = preset.mcp.check.file.startsWith("~/") ? join(home, preset.mcp.check.file.slice(2)) : preset.mcp.check.file;
|
|
112
|
+
if (!existsSync(file)) return "missing";
|
|
113
|
+
try {
|
|
114
|
+
const parsed = JSON.parse(readFileSync(file, "utf8")) as Record<string, unknown>;
|
|
115
|
+
const block = parsed?.[preset.mcp.check.key];
|
|
116
|
+
return block && typeof block === "object" && !Array.isArray(block) ? (Object.hasOwn(block, BRIDGE_NAME) ? "present" : "missing") : "missing";
|
|
117
|
+
} catch { return "unknown"; }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** One doctor row for each configured pull kind written from a known preset. */
|
|
121
|
+
export function pullRegistrationChecks(adapters: unknown, home: string, presets: readonly AgentPreset[] = loadPresets()): { kind: string; preset: string; state: "present" | "missing" | "unknown"; command: string }[] {
|
|
122
|
+
if (!adapters || typeof adapters !== "object") return [];
|
|
123
|
+
return Object.entries(adapters as Record<string, unknown>).flatMap(([kind, raw]) => {
|
|
124
|
+
const declared = raw as { transport?: unknown; preset?: unknown } | null;
|
|
125
|
+
const preset = declared?.transport === "pull" && typeof declared.preset === "string" ? presets.find(row => row.id === declared.preset) : undefined;
|
|
126
|
+
return preset ? [{ kind, preset: preset.id, state: registrationState(preset, home), command: registrationText(preset, process.execPath, BRIDGE_BUNDLE) }] : [];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/** Reads a JSON file that may not exist: absent is undefined; a file that is not valid JSON throws, so a write never replaces what it cannot read. */
|
|
131
|
+
export function readJsonFile(file: string): Record<string, unknown> | undefined {
|
|
132
|
+
if (!existsSync(file)) return undefined;
|
|
133
|
+
const value = JSON.parse(readFileSync(file, "utf8")) as unknown;
|
|
134
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${file} is not a JSON object`);
|
|
135
|
+
return value as Record<string, unknown>;
|
|
136
|
+
}
|
|
@@ -106,10 +106,10 @@ const NOTIFICATION_CAP = 64 * 1024;
|
|
|
106
106
|
export function isQwenTaskNotification(text: string): boolean { return text.length <= NOTIFICATION_CAP && QWEN_TASK_NOTIFICATIONS.test(text); }
|
|
107
107
|
|
|
108
108
|
/** `qwen --version` against the dual-output compat entry. Never throws: a refusal is a reason. */
|
|
109
|
-
export async function qwenDualVersionAsync(cmd: readonly string[], cwd: string): Promise<{ ok: true; version: string; note?: string } | { ok: false; reason: string }> {
|
|
109
|
+
export async function qwenDualVersionAsync(cmd: readonly string[], cwd: string, env: NodeJS.ProcessEnv = process.env): Promise<{ ok: true; version: string; note?: string } | { ok: false; reason: string }> {
|
|
110
110
|
const [bin, ...prefix] = cmd.filter(word => word !== "--acp");
|
|
111
111
|
try {
|
|
112
|
-
const child = Bun.spawn([bin ?? "qwen", ...prefix, "--version"], { cwd, stdout: "pipe", stderr: "ignore", stdin: "ignore", env: withoutOrcaEnv(childEnv(
|
|
112
|
+
const child = Bun.spawn([bin ?? "qwen", ...prefix, "--version"], { cwd, stdout: "pipe", stderr: "ignore", stdin: "ignore", env: withoutOrcaEnv(childEnv(env)) });
|
|
113
113
|
const timer = setTimeout(() => child.kill("SIGKILL"), 10_000);
|
|
114
114
|
const out = await new Response(child.stdout).text(); await child.exited; clearTimeout(timer);
|
|
115
115
|
const verdict = assessVersion("qwen-dual", out.trim());
|
|
@@ -209,6 +209,8 @@ export interface AdapterDefinition {
|
|
|
209
209
|
family: string;
|
|
210
210
|
transport: "acp" | "codex-appserver" | "claude-channel" | "ws-pull" | "hub-native";
|
|
211
211
|
roles: readonly string[];
|
|
212
|
+
/** #1809: `false` means the kind owns no task. Every ownership view reads this field, never the transport; only a configured pull kind sets it, and nothing sets it to `true` yet. */
|
|
213
|
+
tasks?: false;
|
|
212
214
|
optional?: boolean;
|
|
213
215
|
defaultOnRoster?: boolean;
|
|
214
216
|
/** A legacy enable switch gates new starts, not retained sockets or queues. */
|
|
@@ -381,6 +383,7 @@ export type KindMap = Readonly<Record<string, { readonly kind: string; readonly
|
|
|
381
383
|
export interface ProjectAdapterCatalog {
|
|
382
384
|
readonly definitions: readonly AdapterDefinition[];
|
|
383
385
|
readonly externalDefinitions: readonly AdapterDefinition[];
|
|
386
|
+
declaredHeadlessFactory?(definition: AdapterDefinition): boolean | undefined;
|
|
384
387
|
definitionOf(id: string, instances?: KindMap): AdapterDefinition | undefined;
|
|
385
388
|
kindOf(id: string, instances?: KindMap): string | undefined;
|
|
386
389
|
familyOf(id: string, instances?: KindMap): string | undefined;
|