@staix/agent-hub 0.50.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 +51 -0
- package/README.md +1 -1
- package/docs/adding-an-ai-tool.md +26 -4
- package/docs/agent-notes/README.md +1 -0
- package/docs/agent-notes/adapters.md +4 -3
- package/docs/agent-notes/budget.md +8 -2
- package/docs/agent-notes/daemon.md +13 -8
- package/docs/agent-notes/local-worker.md +3 -3
- package/docs/agent-notes/security-review.md +6 -5
- package/docs/agent-notes/tasks.md +10 -3
- package/docs/agent-notes/tests.md +4 -3
- package/docs/cooperbench.md +1 -1
- package/docs/design/adapters.md +21 -0
- package/docs/design/cli-output-inventory.md +165 -150
- package/docs/design/cli-output.md +4 -3
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/roadmap.md +3 -1
- package/docs/design/task-board.md +35 -0
- package/docs/dogfood.md +21 -3
- package/docs/events.md +4 -2
- package/docs/memory.md +5 -3
- package/docs/operations.md +259 -19
- package/docs/quickstart.md +29 -2
- package/docs/roadmap.json +20 -20
- package/docs/roadmap.md +2 -2
- package/docs/roles.md +1 -1
- package/docs/sdlc.md +29 -5
- package/docs/security.md +11 -5
- package/docs/specs/2026-09-19-agent-hub-design.md +44 -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-29-agy-1.5.20.md +33 -0
- package/docs/verification/2026-11-29-claude-profile-hook.md +12 -0
- package/docs/verification/2026-11-29-idle-daemon-footprint.md +75 -0
- package/docs/verification/2026-11-29-kimi-281-reviewer-compat.md +38 -0
- package/docs/verification/2026-11-29-kimi-tui-281.md +12 -0
- package/docs/verification/2026-11-30-0.51.0.md +91 -0
- package/docs/verification/2026-11-30-account-switch-1806.md +445 -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 +87 -42
- 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 +1416 -24985
- package/plugins/agent-hub/server.js +17415 -32755
- package/scripts/check-docs.mjs +1 -1
- package/src/adapters/acp.ts +13 -13
- package/src/adapters/agy/definition.ts +9 -26
- package/src/adapters/agy/entry.ts +2 -0
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel-evidence.ts +7 -3
- 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 +78 -14
- 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 +62 -84
- 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 +6 -3
- package/src/adapters/definitions/native-cli-codex-launch.ts +2 -1
- package/src/adapters/definitions/native-cli-entry-claude.ts +17 -2
- package/src/adapters/definitions/native-cli-entry-codex.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-jcode.ts +6 -2
- package/src/adapters/definitions/native-cli-entry-kimi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-pi.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-qwen.ts +2 -0
- package/src/adapters/definitions/native-cli-entry-types.ts +12 -3
- package/src/adapters/definitions/native-cli-jcode-home-init.ts +1 -1
- package/src/adapters/definitions/native-cli-launch-common.ts +2 -2
- package/src/adapters/definitions/native-cli-preview-common.ts +1 -1
- package/src/adapters/definitions/native-cli-retained.ts +1 -1
- package/src/adapters/definitions/native-config-defaults.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 +19 -12
- package/src/adapters/native-capabilities.ts +18 -8
- package/src/adapters/native-facts-hooks.ts +12 -0
- 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/autonomy-offline.ts +1 -1
- package/src/cli/bench.ts +1 -1
- package/src/cli/budget-renew-guidance.ts +129 -0
- package/src/cli/claude-homes.ts +9 -5
- package/src/cli/claude-profile-hook.ts +31 -11
- 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 +91 -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/conductor-recovery.ts +1 -1
- package/src/cli/console-state.ts +5 -138
- package/src/cli/console-versions.ts +1 -1
- package/src/cli/facts-hook.ts +11 -4
- package/src/cli/help.ts +44 -20
- package/src/cli/identity.ts +27 -4
- package/src/cli/init-prompt.ts +1 -1
- package/src/cli/init-settings.ts +4 -35
- package/src/cli/init.ts +1 -1
- package/src/cli/json-text-spans.ts +57 -0
- package/src/cli/launch-check.ts +156 -0
- package/src/cli/launch.ts +19 -70
- package/src/cli/light-dispatch.ts +29 -0
- package/src/cli/main.js +8 -1
- package/src/cli/main.ts +257 -2799
- package/src/cli/memory.ts +1 -1
- package/src/cli/orca-probe.ts +119 -0
- package/src/cli/output.ts +45 -3
- package/src/cli/preview.ts +11 -6
- package/src/cli/recovery-launch.ts +1 -1
- 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 +2 -2
- package/src/cli/start-agents-run.ts +85 -7
- package/src/cli/start-check.ts +28 -0
- 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 +12 -1
- package/src/cli/upgrade.ts +4 -15
- package/src/cli/warn-line.ts +1 -1
- 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/ci-watch.ts +311 -79
- package/src/hub/conductor-peer.ts +24 -0
- package/src/hub/conductor.ts +2 -21
- package/src/hub/config-apply.ts +25 -14
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +2 -0
- package/src/hub/config.ts +535 -0
- package/src/hub/control-client.ts +49 -1
- package/src/hub/daemon.ts +492 -569
- package/src/hub/delivery-public.ts +11 -0
- 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-check.ts +125 -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/path-policy.ts +1 -1
- package/src/hub/peers.ts +5 -1
- package/src/hub/permission-mode.ts +5 -41
- package/src/hub/permission-paths.ts +41 -0
- 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/recovery-policy.ts +1 -1
- package/src/hub/registry.ts +36 -2
- package/src/hub/releases-inventory.ts +198 -0
- 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/runtime-capture-prune.ts +25 -3
- package/src/hub/runtime-prune-health.ts +8 -1
- package/src/hub/sdlc-check.ts +205 -0
- package/src/hub/sdlc-release-authorization.ts +42 -21
- package/src/hub/sdlc-release-diagnostics.ts +5 -0
- package/src/hub/sdlc-release-policy.ts +21 -7
- package/src/hub/sdlc-release.ts +80 -20
- package/src/hub/sdlc-sync.ts +146 -0
- package/src/hub/sdlc.ts +38 -5
- 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 +457 -2584
- 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/src/ui/plugin.ts +1 -1
- package/templates/presets/agents.json +60 -0
- package/templates/presets/confirmation-matrix.json +8 -8
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AdapterDefinition } from "../registry-types.ts";
|
|
2
|
+
import {
|
|
3
|
+
piConfigSchema, localConfigSchema, piRoutingSchema, localRoutingSchema,
|
|
4
|
+
PI_SETTINGS, PI_RESTART_REASONS, LOCAL_RESTART_REASONS, piEffectiveConfig,
|
|
5
|
+
} from "./native-config-policy.ts";
|
|
6
|
+
|
|
7
|
+
type NativeConfigurationPolicy = NonNullable<AdapterDefinition["configuration"]>;
|
|
8
|
+
|
|
9
|
+
export const PI_CONFIGURATION: NativeConfigurationPolicy = Object.freeze({
|
|
10
|
+
schema: piConfigSchema, routingSchema: piRoutingSchema, settings: PI_SETTINGS,
|
|
11
|
+
restartReasons: PI_RESTART_REASONS, validateEffective: piEffectiveConfig,
|
|
12
|
+
});
|
|
13
|
+
export const LOCAL_CONFIGURATION: NativeConfigurationPolicy = Object.freeze({
|
|
14
|
+
schema: localConfigSchema, routingSchema: localRoutingSchema, restartReasons: LOCAL_RESTART_REASONS,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** Fixed native configuration providers in the registry's validation order. */
|
|
18
|
+
export const NATIVE_CONFIGURATION: readonly NativeConfigurationPolicy[] = Object.freeze([PI_CONFIGURATION, LOCAL_CONFIGURATION]);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe } from "../compat.ts";
|
|
2
|
+
|
|
3
|
+
/** CLI presentation and declaration facts shared by help and the executable definitions. */
|
|
4
|
+
export const NATIVE_CLI_HELP = {
|
|
5
|
+
claude: { kind: "claude", projection: { helpRank: 0 }, cli: { usage: [["ahub claude [--print-command] [--unattended] [args...]", "launch Claude Code with the hub channel", "launch Claude Code with the hub channel"]] }, instances: { mode: "external", roles: ["planner", "implementer", "verifier", "reviewer"] } },
|
|
6
|
+
codex: { kind: "codex", projection: { helpRank: 1 }, cli: { usage: [["ahub codex [--print-command] [--unattended] [args...]", "start the Codex adapter and attach the TUI", "start the Codex adapter and attach the TUI"]] }, instances: { mode: "headless" } },
|
|
7
|
+
kimi: { kind: "kimi", projection: { helpRank: 2 }, cli: { usage: [["ahub kimi [--print-command] [--mode tui|headless] [--model <alias>]", "default: Kimi's own TUI, pull-only via hub_inbox; no push, steer, watchdog, console approvals or automatic quota handoff. Select headless for ACP", "start Kimi in its own TUI, or headless over ACP"]] }, instances: { mode: "headless" } },
|
|
8
|
+
pi: { kind: "pi", projection: { helpRank: 6 }, cli: { usage: [["ahub pi [--print-command] [--mode headless|tui | --headless] [--backend auto|dgx|mlx] [--model <alias>] [--session-id <id>] [--session-file <path>] [--replace-session]", "start Pi: its TUI in this terminal unless --headless or the start mode setting (peers.pi.start_mode) says headless; without a terminal the hub opens one or says how", "start Pi in a terminal, or headless"]] }, instances: { mode: "headless" } },
|
|
9
|
+
local: { kind: "local", projection: { helpRank: 7 }, cli: { usage: [["ahub local [--route <id> | --model <id>]", "start the hub-native worker on the self-hosted models (routing.toml)", "start the hub-native worker on self-hosted models"]] }, instances: { mode: "headless" } },
|
|
10
|
+
jcode: { kind: "jcode", projection: { helpRank: 3 }, cli: { usage: [["ahub jcode [--mode tui|headless] [--model <alias>] [--provider-profile <name>] [--session-id <id>] [--print-command]", "optional Jcode (roster.jcode, default off): its TUI on the hub-owned ACP session, opened once that session is saved; --mode headless for ACP only; native policy unmanaged, no hub sandbox", "start optional Jcode, in its TUI or headless"]] }, instances: { mode: "headless", nativeHome: true } },
|
|
11
|
+
qwen: { kind: "qwen", projection: { helpRank: 5 }, cli: { usage: [["ahub qwen [--mode headless|tui] [--model <alias>] [--session-id <id>] [--print-command]", `start optional Qwen Code ACP (${describe("qwen")}; roster.qwen, default off); --mode tui runs Qwen's own TUI in this terminal, driven through its dual-output files (${describe("qwen-dual")}); a hub deny ends the turn without an answer and a stalled turn is stopped with Esc in the Qwen terminal`, "start optional Qwen Code, headless or in its TUI"]] }, instances: { mode: "headless" } },
|
|
12
|
+
agy: { kind: "agy", projection: { helpRank: 4 }, cli: { usage: [["ahub agy [--print-command | --dry-run] [args...]", "optional Antigravity CLI 1.4.x TUI (1.4.2 verified) in this terminal (roster.agy, default off): pull-only via hub_inbox, implementer/verifier only; native permissions unmanaged, no hub sandbox", "start optional Antigravity CLI in this terminal"]] } },
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
/** Ranked definitions sort before unranked definitions; ties retain source order. */
|
|
16
|
+
export function isBuiltinAdapterKind(kind: string): kind is keyof typeof NATIVE_CLI_HELP {
|
|
17
|
+
return Object.hasOwn(NATIVE_CLI_HELP, kind);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function compareNativeRank(left: number | undefined, right: number | undefined): number {
|
|
21
|
+
if (left === undefined) return right === undefined ? 0 : 1;
|
|
22
|
+
if (right === undefined) return -1;
|
|
23
|
+
return left - right;
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { declaredKind, resolvedDefinition } from "../declaration-resolution.ts";
|
|
2
|
+
import type { AdapterDefinition, KindMap } from "../registry-types.ts";
|
|
3
|
+
import { NATIVE_ADAPTER_POLICY as policy } from "./native-adapter-policy.ts";
|
|
4
|
+
import { isBuiltinAdapterKind } from "./native-help.ts";
|
|
5
|
+
|
|
6
|
+
interface LaunchDeclaration {
|
|
7
|
+
identity: AdapterDefinition["identity"];
|
|
8
|
+
pullOnly?: true;
|
|
9
|
+
reviewer?: Pick<NonNullable<AdapterDefinition["reviewer"]>, "declaration">;
|
|
10
|
+
reviewerVariant?: LaunchDeclaration;
|
|
11
|
+
headlessVariant?: LaunchDeclaration;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const reviewers = {
|
|
15
|
+
claude: { identity: policy.claudeReviewer.metadata.identity, reviewer: { declaration: "automatic" } },
|
|
16
|
+
codex: { identity: { mcp: "env" }, reviewer: { declaration: "explicit" } },
|
|
17
|
+
kimi: { identity: { mcp: "env" }, reviewer: { declaration: "explicit" } },
|
|
18
|
+
agy: { identity: { mcp: "env" }, reviewer: { declaration: "automatic" } },
|
|
19
|
+
} satisfies Record<string, LaunchDeclaration>;
|
|
20
|
+
|
|
21
|
+
const declarations = new Map<string, LaunchDeclaration>(Object.keys(policy).filter(isBuiltinAdapterKind).map(kind => {
|
|
22
|
+
const reviewer = Object.hasOwn(reviewers, kind) ? reviewers[kind as keyof typeof reviewers] : undefined;
|
|
23
|
+
const value: LaunchDeclaration = {
|
|
24
|
+
identity: policy[kind].metadata.identity,
|
|
25
|
+
...(kind === "kimi" || kind === "agy" ? { pullOnly: true } : {}),
|
|
26
|
+
...(reviewer ? { reviewerVariant: reviewer } : {}),
|
|
27
|
+
...(kind === "claude" ? { headlessVariant: { identity: policy.claudeImplementer.metadata.identity } } : {}),
|
|
28
|
+
};
|
|
29
|
+
return [kind, value];
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
export function nativeLaunchDeclaration(id: string, instances?: KindMap): LaunchDeclaration | undefined {
|
|
33
|
+
return resolvedDefinition(id, declarations.has(id) ? id : declaredKind(id, instances, declarations), instances, declarations);
|
|
34
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Launch admission flags shared by the native planners and runtime definitions. */
|
|
2
|
+
const hubSwitches = Object.freeze(["--unattended", "--safe", "--new"]);
|
|
3
|
+
export const CLAUDE_LAUNCH_POLICY = Object.freeze({ hubSwitches: hubSwitches, ownedFlags: Object.freeze(["--dangerously-load-development-channels", "--dangerously-skip-permissions"]), unattended: true, passthrough: true });
|
|
4
|
+
export const CODEX_LAUNCH_POLICY = Object.freeze({ hubSwitches: hubSwitches, ownedFlags: Object.freeze(["--remote", "--remote-auth-token-env", "--yolo", "--dangerously-bypass-approvals-and-sandbox"]), unattended: true, passthrough: true });
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const CLAUDE_CHANNEL = "plugin:agent-hub@agent-hub";
|
|
2
|
+
/** The timeout registered for the start entry; the total above must stay under it with room for the process to start. */
|
|
3
|
+
export const START_HOOK_TIMEOUT_S = 5;
|
|
4
|
+
|
|
5
|
+
export const UNATTENDED_WARNING =
|
|
6
|
+
"WARNING: --unattended disables permission prompts. Other agents' messages are untrusted input and this agent will act on its own judgment without asking you.";
|
|
7
|
+
|
|
8
|
+
export interface Launch {
|
|
9
|
+
cmd: string;
|
|
10
|
+
args: string[];
|
|
11
|
+
warning?: string;
|
|
12
|
+
permissionHook?: boolean;
|
|
13
|
+
hookPurpose?: FactsHook["purpose"];
|
|
14
|
+
settingsFile?: string;
|
|
15
|
+
unattended?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface StatusLineTee {
|
|
19
|
+
/** absolute path of src/cli/statusline-tee.ts */
|
|
20
|
+
script: string;
|
|
21
|
+
stateDir: string;
|
|
22
|
+
/** the user's own statusLine setting, wrapped so the status line looks the same */
|
|
23
|
+
original?: { command?: string; refreshInterval?: number; padding?: number };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const sh = (s: string) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Settings for one session that put the tee in front of the user's status line command. Claude Code's status line
|
|
30
|
+
* input carries `rate_limits`; this is the hub's Claude quota source. `~/.claude/settings.json` is never edited.
|
|
31
|
+
*/
|
|
32
|
+
export function statusLineSettings(tee: StatusLineTee): string {
|
|
33
|
+
const command = `AGENTHUB_STATE_DIR=${sh(tee.stateDir)} AGENTHUB_STATUSLINE_CMD=${sh(tee.original?.command ?? "")} bun ${sh(tee.script)}`;
|
|
34
|
+
return JSON.stringify({ statusLine: { type: "command", command, refreshInterval: tee.original?.refreshInterval ?? 10, ...(tee.original?.padding !== undefined ? { padding: tee.original.padding } : {}) } });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Shared facts, native observation and permission hook transport. */
|
|
38
|
+
export interface FactsHook {
|
|
39
|
+
script: string;
|
|
40
|
+
stateDir: string;
|
|
41
|
+
/** The same hook transport can observe native turns without injecting facts. */
|
|
42
|
+
purpose?: "facts" | "idle" | "facts-and-idle" | "permission";
|
|
43
|
+
/** Observe native sessions/turns for every enabled facts, idle or conductor hook configuration. */
|
|
44
|
+
observeNative?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* #1798 T3: add the session-start Hub check entry. Opt-in: only the interactive `ahub claude` entry and its preview set it.
|
|
47
|
+
* `claudeObservationHooks` never does, and the headless implementer and benchmarks call `sessionSettings` without it.
|
|
48
|
+
*/
|
|
49
|
+
startCheck?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The one `--settings` value of a hub-launched Claude session: the status line tee, and in a turn-free project the
|
|
54
|
+
* facts hook before and after every tool call and at the end of each turn (issue #108; the turn end is the quiescence
|
|
55
|
+
* evidence of issue #107).
|
|
56
|
+
*/
|
|
57
|
+
export function sessionSettings(tee?: StatusLineTee, facts?: FactsHook): string {
|
|
58
|
+
const settings = (tee ? JSON.parse(statusLineSettings(tee)) : {}) as Record<string, unknown>;
|
|
59
|
+
if (facts) {
|
|
60
|
+
const hooks = [{ type: "command", command: `AGENTHUB_STATE_DIR=${sh(facts.stateDir)} AGENTHUB_HOOK_PURPOSE=${sh(facts.purpose ?? "facts")} bun ${sh(facts.script)}`, timeout: 5 }];
|
|
61
|
+
settings.hooks = { PreToolUse: [{ matcher: "*", hooks }], ...(facts.purpose !== "permission" ? { PostToolUse: [{ matcher: "*", hooks }], Stop: [{ hooks }] } : {}) };
|
|
62
|
+
if (facts.observeNative) Object.assign(settings.hooks as object, { SessionStart: [{ matcher: "*", hooks }], UserPromptSubmit: [{ hooks }] });
|
|
63
|
+
}
|
|
64
|
+
if (facts?.startCheck) {
|
|
65
|
+
// Reads and prints only: its own command, so it records no native session or turn facts and turns on no idle, facts or sweep behavior. Where the
|
|
66
|
+
// observation entry also fires on SessionStart the notice is a second, separate entry in the same array (the check appears once per session start).
|
|
67
|
+
const check = { type: "command", command: `AGENTHUB_STATE_DIR=${sh(facts.stateDir)} AGENTHUB_HOOK_PURPOSE='start-check' bun ${sh(facts.script)}`, timeout: START_HOOK_TIMEOUT_S };
|
|
68
|
+
const hooks = (settings.hooks ?? (settings.hooks = {})) as Record<string, unknown[]>;
|
|
69
|
+
hooks.SessionStart = [...(hooks.SessionStart ?? []), { matcher: "startup|resume", hooks: [check] }];
|
|
70
|
+
}
|
|
71
|
+
return JSON.stringify(settings);
|
|
72
|
+
}
|
|
@@ -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.
|
|
@@ -103,6 +94,22 @@ export const JCODE_HEADLESS_AFTER_RECOVERY = "jcode is running headless after re
|
|
|
103
94
|
export function jcodeDetachedNotice(peer: string): { cause: string; command: string } {
|
|
104
95
|
return { cause: "a Jcode server the hub did not start is serving this peer's socket, so its work continues outside the hub", command: peer === "jcode" ? "ahub jcode" : `ahub jcode --as ${peer}` };
|
|
105
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* #1795: a hub-tools hello the hub refused while this peer's owned launch is live and attached (a jcode child session, an older MCP child). It names the
|
|
99
|
+
* process so the person can end it; it never changes the peer's state. Display only: the pid comes from the hello and is not authority, and the command
|
|
100
|
+
* is one bounded `ps` read, control characters removed, never an environment or argument vector beyond that one line.
|
|
101
|
+
*/
|
|
102
|
+
export function refusedHelloProcess(pid: unknown, read: (pid: number) => string | undefined = defaultProcessCommand): { pid?: number; command?: string } {
|
|
103
|
+
const id = typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 && pid <= 2_147_483_647 ? pid : undefined;
|
|
104
|
+
if (id === undefined) return {};
|
|
105
|
+
let command: string | undefined;
|
|
106
|
+
try { command = read(id)?.replace(/[\x00-\x1f\x7f]/g, " ").trim().slice(0, 200) || undefined; } catch { command = undefined; }
|
|
107
|
+
return { pid: id, ...(command ? { command } : {}) };
|
|
108
|
+
}
|
|
109
|
+
function defaultProcessCommand(pid: number): string | undefined {
|
|
110
|
+
const result = Bun.spawnSync(["/bin/ps", "-p", String(pid), "-o", "command="], { stdout: "pipe", stderr: "ignore", timeout: 2000 });
|
|
111
|
+
return result.exitCode === 0 ? result.stdout.toString() : undefined;
|
|
112
|
+
}
|
|
106
113
|
const JCODE_OWNED_ENV = { JCODE_DISABLE_CLAUDE_MCP: "1", JCODE_NO_TELEMETRY: "1" } as const;
|
|
107
114
|
/** #691: the verdict lives in `src/adapters/compat.ts` (line, verified versions, the person's trust); never pin here. */
|
|
108
115
|
export const jcodeVersionSupported = (version: unknown): boolean => assessVersion("jcode", version).ok;
|
|
@@ -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) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AGY_FACTS_HOOK } from "./agy/hooks.ts";
|
|
2
|
+
import { KIMI_TUI_FACTS_HOOK } from "./kimi-tui-facts.ts";
|
|
3
|
+
import type { NativeFactsPort } from "./registry-types.ts";
|
|
4
|
+
|
|
5
|
+
export const NATIVE_FACTS_HOOKS = Object.freeze({
|
|
6
|
+
agy: AGY_FACTS_HOOK,
|
|
7
|
+
kimi: KIMI_TUI_FACTS_HOOK,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export function nativeFactsHook(peer: string): NativeFactsPort | undefined {
|
|
11
|
+
return Object.hasOwn(NATIVE_FACTS_HOOKS, peer) ? NATIVE_FACTS_HOOKS[peer as keyof typeof NATIVE_FACTS_HOOKS] : undefined;
|
|
12
|
+
}
|
|
@@ -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
|
}
|