@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,160 @@
|
|
|
1
|
+
import { basename } from "node:path";
|
|
2
|
+
import { types } from "node:util";
|
|
3
|
+
import type { ConfiguredPrintAdapterConfig } from "./configured-print.ts";
|
|
4
|
+
import type { PermissionMode } from "../hub/permission-mode.ts";
|
|
5
|
+
|
|
6
|
+
interface ConfiguredAcpAdapterConfig {
|
|
7
|
+
transport: "acp";
|
|
8
|
+
command: string;
|
|
9
|
+
args?: readonly string[];
|
|
10
|
+
displayName: string;
|
|
11
|
+
roles: readonly string[];
|
|
12
|
+
identity?: { name: string; version: string };
|
|
13
|
+
/** #1809: the preset this declaration was written from; the status word shown beside the kind comes from it. */
|
|
14
|
+
preset?: string;
|
|
15
|
+
permission?: Partial<Record<PermissionMode, string>>;
|
|
16
|
+
readOnly?: string;
|
|
17
|
+
}
|
|
18
|
+
/** #1809: a pull kind runs the person's own TUI; it reads its inbox through the bridge and is never pushed to. `tasks` only ever reads `false`. */
|
|
19
|
+
export interface ConfiguredPullAdapterConfig {
|
|
20
|
+
transport: "pull";
|
|
21
|
+
command: string;
|
|
22
|
+
args: readonly string[];
|
|
23
|
+
displayName: string;
|
|
24
|
+
roles: readonly string[];
|
|
25
|
+
versionArgs: readonly string[];
|
|
26
|
+
tasks: false;
|
|
27
|
+
preset?: string;
|
|
28
|
+
}
|
|
29
|
+
export type ConfiguredAdapterConfig = ConfiguredAcpAdapterConfig | ConfiguredPrintAdapterConfig | ConfiguredPullAdapterConfig;
|
|
30
|
+
|
|
31
|
+
type ConfiguredPolicy =
|
|
32
|
+
| { type: "print"; kind: string; declaration: ConfiguredPrintAdapterConfig }
|
|
33
|
+
| { type: "pull"; kind: string; declaration: ConfiguredPullAdapterConfig }
|
|
34
|
+
| { type: "acp"; kind: string; command: string; args: string[]; argv: string[]; displayName: string; roles: string[];
|
|
35
|
+
identity: ConfiguredAcpAdapterConfig["identity"]; preset: string | undefined; modes: ConfiguredAcpAdapterConfig["permission"]; readOnly: string | undefined;
|
|
36
|
+
nativePolicy: { modes?: ConfiguredAcpAdapterConfig["permission"]; readOnly?: string } };
|
|
37
|
+
|
|
38
|
+
const fail = (field: string, reason: string): never => { throw new Error(`${field}: ${reason}`); };
|
|
39
|
+
/** Core command namespace is reserved; configured kinds cannot shadow operational CLI actions. */
|
|
40
|
+
export const CONFIGURED_ACP_RESERVED_COMMANDS = Object.freeze(["help", "version", "completion", "projects", "ui", "manager", "setup", "init", "daemon", "up", "console", "recovery-run", "upgrade", "restart", "recovery", "models", "say", "queue", "watch", "tail", "budget", "backlog", "release", "board", "sdlc", "task", "review", "remember", "ask", "route", "pause", "resume", "stop", "permission", "roster", "settings", "permit", "pet", "status", "logs", "export", "bench", "memory", "goal", "research", "report", "facts", "check-path", "turns", "undo", "kill", "reset", "role", "doctor"]);
|
|
41
|
+
export const MODES = ["ask", "ask-when-needed", "never-ask"];
|
|
42
|
+
const ROLES = ["planner", "implementer", "verifier", "reviewer"];
|
|
43
|
+
function fields(raw: unknown, at: string): Record<string, PropertyDescriptor> {
|
|
44
|
+
if (!raw || typeof raw !== "object" || types.isProxy(raw) || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw)) || Object.getOwnPropertySymbols(raw).length) return fail(at, "must be a plain own-data object");
|
|
45
|
+
const result: Record<string, PropertyDescriptor> = Object.assign(Object.create(null), Object.getOwnPropertyDescriptors(raw));
|
|
46
|
+
if (Object.values(result).some(d => !Object.hasOwn(d, "value") || !d.enumerable)) return fail(at, "enumerable data fields required");
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
function text(raw: unknown, at: string, max = 4096): string {
|
|
50
|
+
if (typeof raw !== "string" || !raw.trim() || Buffer.byteLength(raw) > max || /[\p{Cc}\p{Cf}]/u.test(raw)) return fail(at, `must be nonempty control-free text of at most ${max} bytes`);
|
|
51
|
+
return raw;
|
|
52
|
+
}
|
|
53
|
+
function list(raw: unknown, at: string, max: number): string[] {
|
|
54
|
+
if (!Array.isArray(raw) || types.isProxy(raw) || Object.getPrototypeOf(raw) !== Array.prototype || Object.getOwnPropertySymbols(raw).length) return fail(at, "must be a string array");
|
|
55
|
+
const descriptors: Record<string, PropertyDescriptor> = Object.assign(Object.create(null), Object.getOwnPropertyDescriptors(raw));
|
|
56
|
+
const length = descriptors.length?.value;
|
|
57
|
+
if (!Number.isSafeInteger(length) || length > max || Object.keys(descriptors).length !== length + 1) return fail(at, "array is sparse or too large");
|
|
58
|
+
return Array.from({ length }, (_, index) => {
|
|
59
|
+
const d = descriptors[String(index)];
|
|
60
|
+
if (!d || !Object.hasOwn(d, "value") || !d.enumerable) return fail(at, "array data fields required");
|
|
61
|
+
return text(d.value, `${at}.${index}`);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export function freeze<T>(value: T): T {
|
|
65
|
+
if (value && typeof value === "object") { for (const item of Object.values(value)) freeze(item); Object.freeze(value); }
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function parsePrint(input: Record<string, PropertyDescriptor>, at: string): ConfiguredPrintAdapterConfig {
|
|
70
|
+
if (Object.keys(input).some(key => !["transport", "command", "args", "stdin", "versionArgs", "versionPin", "timeoutS", "displayName", "roles"].includes(key)))
|
|
71
|
+
return fail(at, "unknown or privileged print field");
|
|
72
|
+
const command = text(input.command?.value, `${at}.command`);
|
|
73
|
+
const args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
|
|
74
|
+
const stdin = input.stdin?.value;
|
|
75
|
+
const placeholders = args.reduce((count, arg) => count + arg.split("{prompt}").length - 1, 0);
|
|
76
|
+
if (input.stdin && stdin !== true || (stdin === true ? placeholders !== 0 : placeholders !== 1))
|
|
77
|
+
return fail(at, "choose stdin: true or exactly one {prompt} placeholder");
|
|
78
|
+
const versionArgs = list(input.versionArgs?.value, `${at}.versionArgs`, 128);
|
|
79
|
+
if (!versionArgs.length || versionArgs.some(arg => arg.includes("{prompt}"))) return fail(`${at}.versionArgs`, "requires fixed version probe arguments");
|
|
80
|
+
const versionPin = text(input.versionPin?.value, `${at}.versionPin`, 256).trim();
|
|
81
|
+
const timeoutS = input.timeoutS?.value;
|
|
82
|
+
if (!Number.isInteger(timeoutS) || timeoutS < 1 || timeoutS > 300) return fail(`${at}.timeoutS`, "must be an integer from 1 to 300");
|
|
83
|
+
const displayName = text(input.displayName?.value, `${at}.displayName`, 256);
|
|
84
|
+
const roles = list(input.roles?.value, `${at}.roles`, 2);
|
|
85
|
+
const advisory = roles.filter((role): role is "reviewer" | "advisor" => role === "reviewer" || role === "advisor");
|
|
86
|
+
if (!roles.length || advisory.length !== roles.length || new Set(roles).size !== roles.length) return fail(`${at}.roles`, "only unique reviewer and advisor roles are supported");
|
|
87
|
+
return freeze<ConfiguredPrintAdapterConfig>({ transport: "print", command, args, ...(stdin === true ? { stdin } : {}), versionArgs, versionPin, timeoutS, displayName, roles: advisory });
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function parsePull(input: Record<string, PropertyDescriptor>, at: string): ConfiguredPullAdapterConfig {
|
|
91
|
+
if (Object.keys(input).some(key => !["transport", "command", "args", "displayName", "roles", "versionArgs", "tasks", "preset"].includes(key))) return fail(at, "unknown or privileged pull field");
|
|
92
|
+
// The way to let a pull peer own tasks later stays open (#1809): every ownership check reads this field, so allowing it is a validation change.
|
|
93
|
+
if (input.tasks && input.tasks.value !== false) return fail(`${at}.tasks`, "a pull peer cannot own tasks; only false is accepted (spec #1809, decision on pull ownership)");
|
|
94
|
+
const command = text(input.command?.value, `${at}.command`), args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
|
|
95
|
+
if ([command, ...args].some(arg => /^--(?:leader|attach|connect|remote)(?:-|=|$)/.test(arg))) return fail(`${at}.args`, "attach/leader selectors are unsupported");
|
|
96
|
+
const versionArgs = list(input.versionArgs?.value, `${at}.versionArgs`, 128);
|
|
97
|
+
if (!versionArgs.length) return fail(`${at}.versionArgs`, "requires fixed version probe arguments");
|
|
98
|
+
const displayName = text(input.displayName?.value, `${at}.displayName`, 256), roles = list(input.roles?.value, `${at}.roles`, 3);
|
|
99
|
+
if (roles.includes("reviewer")) return fail(`${at}.roles`, "a pull kind cannot be a reviewer (spec #1809): it reads only when it asks, so it cannot meet a review deadline");
|
|
100
|
+
if (!roles.length || new Set(roles).size !== roles.length || roles.some(role => !["planner", "implementer", "verifier"].includes(role))) return fail(`${at}.roles`, "pull roles must be unique planner, implementer or verifier");
|
|
101
|
+
const preset = input.preset ? text(input.preset.value, `${at}.preset`, 32) : undefined;
|
|
102
|
+
if (preset !== undefined && !/^[a-z][a-z0-9-]{0,31}$/.test(preset)) return fail(`${at}.preset`, "must be a preset id");
|
|
103
|
+
return freeze<ConfiguredPullAdapterConfig>({ transport: "pull", command, args, displayName, roles, versionArgs, tasks: false, ...(preset ? { preset } : {}) });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Pure local declaration compiler; file provenance and runtime process ownership remain host checks. */
|
|
107
|
+
/** A configured print or ACP declaration can bind a headless factory. Pull declarations never do. */
|
|
108
|
+
export function configuredHeadlessFactory(policy: { type: "acp" | "print" | "pull" }): boolean {
|
|
109
|
+
return policy.type !== "pull";
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function readConfiguredAdapters(raw: unknown, builtinKinds: readonly string[]): readonly ConfiguredPolicy[] {
|
|
113
|
+
if (raw === undefined) return Object.freeze([]);
|
|
114
|
+
const declarations = fields(raw, "adapters");
|
|
115
|
+
if (Object.keys(declarations).length > 64) return fail("adapters", "at most 64 configured kinds supported");
|
|
116
|
+
const reserved = new Set([...builtinKinds, ...CONFIGURED_ACP_RESERVED_COMMANDS, "user", "hub", "digest", "constructor", "prototype", "__proto__"]);
|
|
117
|
+
return Object.freeze(Object.entries(declarations).map<ConfiguredPolicy>(([kind, descriptor]) => {
|
|
118
|
+
const at = `adapters.${kind}`;
|
|
119
|
+
if (!/^[a-z][a-z0-9-]{0,31}$/.test(kind) || reserved.has(kind)) return fail(at, "kind is invalid, reserved or collides with a builtin");
|
|
120
|
+
const input = fields(descriptor.value, at);
|
|
121
|
+
if (input.transport?.value === "print") return { type: "print", kind, declaration: parsePrint(input, at) };
|
|
122
|
+
if (input.transport?.value === "pull") return { type: "pull", kind, declaration: parsePull(input, at) };
|
|
123
|
+
if (Object.keys(input).some(key => !["transport", "command", "args", "displayName", "roles", "identity", "permission", "readOnly", "preset"].includes(key))) return fail(at, "unknown or privileged field");
|
|
124
|
+
if (input.transport?.value !== "acp") return fail(`${at}.transport`, "must be acp, print or pull");
|
|
125
|
+
const command = text(input.command?.value, `${at}.command`), args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
|
|
126
|
+
// The supported contract is a foreground owned stdio process, never an attachment/proxy selector.
|
|
127
|
+
if ([command, ...args].some(arg => /^--(?:leader|attach|connect|remote)(?:-|=|$)/.test(arg))) return fail(`${at}.args`, "attach/leader selectors are unsupported; command must run foreground owned ACP stdio");
|
|
128
|
+
const displayName = text(input.displayName?.value, `${at}.displayName`, 256), roles = list(input.roles?.value, `${at}.roles`, ROLES.length);
|
|
129
|
+
if (roles.includes("conductor")) return fail(`${at}.roles`, "conductor requires explicit project role policy, not adapter defaults");
|
|
130
|
+
if (!roles.length || new Set(roles).size !== roles.length || roles.some(role => !ROLES.includes(role))) return fail(`${at}.roles`, "roles must be nonempty, known and unique");
|
|
131
|
+
let identity: ConfiguredAcpAdapterConfig["identity"];
|
|
132
|
+
if (input.identity) {
|
|
133
|
+
const value = fields(input.identity.value, `${at}.identity`);
|
|
134
|
+
if (Object.keys(value).some(key => !["name", "version"].includes(key))) return fail(`${at}.identity`, "unknown identity field");
|
|
135
|
+
identity = { name: text(value.name?.value, `${at}.identity.name`, 256), version: text(value.version?.value, `${at}.identity.version`, 256) };
|
|
136
|
+
}
|
|
137
|
+
const grokContract = kind === "grok" || /^grok(?:\.exe)?$/i.test(basename(command)) || identity?.name.toLowerCase() === "grok";
|
|
138
|
+
const noLeader = args.indexOf("--no-leader"), endOptions = args.indexOf("--");
|
|
139
|
+
if (grokContract && (noLeader < 0 || (endOptions >= 0 && noLeader > endOptions) || args.some(arg => arg.startsWith("--no-leader=")))) {
|
|
140
|
+
return fail(`${at}.args`, "Grok requires explicit --no-leader before argv termination; valued opt-outs are unsupported");
|
|
141
|
+
}
|
|
142
|
+
let modes: ConfiguredAcpAdapterConfig["permission"];
|
|
143
|
+
if (input.permission) {
|
|
144
|
+
const value = fields(input.permission.value, `${at}.permission`);
|
|
145
|
+
modes = {};
|
|
146
|
+
for (const [mode, d] of Object.entries(value)) {
|
|
147
|
+
if (!MODES.includes(mode)) return fail(`${at}.permission.${mode}`, "unknown hub mode");
|
|
148
|
+
modes[mode as PermissionMode] = text(d.value, `${at}.permission.${mode}`, 256);
|
|
149
|
+
}
|
|
150
|
+
if (!Object.keys(modes).length) modes = undefined; // `permission: {}` maps nothing: unmanaged, exactly like an omitted map
|
|
151
|
+
}
|
|
152
|
+
const readOnly = input.readOnly ? text(input.readOnly.value, `${at}.readOnly`, 256) : undefined;
|
|
153
|
+
const preset = input.preset ? text(input.preset.value, `${at}.preset`, 32) : undefined;
|
|
154
|
+
if (preset !== undefined && !/^[a-z][a-z0-9-]{0,31}$/.test(preset)) return fail(`${at}.preset`, "must be a preset id");
|
|
155
|
+
const nativePolicy = freeze({ ...(modes ? { modes } : {}), ...(readOnly ? { readOnly } : {}) });
|
|
156
|
+
const argv = freeze([command, ...args]);
|
|
157
|
+
identity = identity && freeze(identity);
|
|
158
|
+
return { type: "acp", kind, command, args, argv, displayName, roles, identity, preset, modes, readOnly, nativePolicy };
|
|
159
|
+
}));
|
|
160
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import type { ProjectAdapterCatalog } from "./registry.ts";
|
|
3
|
+
import { CONFIGURED_PULL_NOTICE } from "./configured-pull.ts";
|
|
4
|
+
import { peerChildEnv } from "../hub/child-process.ts";
|
|
5
|
+
import { rosterInStatus } from "../hub/status-roster.ts";
|
|
6
|
+
|
|
7
|
+
/** The words `ahub <kind>` passes through to the TUI; everything else is the declaration's. */
|
|
8
|
+
export interface ConfiguredPullLaunch { command: string; args: string[]; preview: boolean }
|
|
9
|
+
|
|
10
|
+
export function parseConfiguredPullArguments(raw: readonly string[], declared: { command: string; args: readonly string[] }): ConfiguredPullLaunch {
|
|
11
|
+
const preview = raw.some(arg => arg === "--print-command" || arg === "--dry-run");
|
|
12
|
+
const extra = raw.filter(arg => arg !== "--print-command" && arg !== "--dry-run");
|
|
13
|
+
if (extra.some(arg => Buffer.byteLength(arg) > 4096 || /[\p{Cc}\p{Cf}]/u.test(arg))) throw new Error("launch arguments must be bounded and control-free");
|
|
14
|
+
return { command: declared.command, args: [...declared.args, ...extra], preview };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface ConfiguredPullControl { features: readonly string[]; request(message: Record<string, unknown>, timeout?: number): Promise<any>; close(): void }
|
|
18
|
+
|
|
19
|
+
/** The environment of the person's TUI: its own identity, the project, and never a tools socket or another peer's marker. */
|
|
20
|
+
export function configuredPullEnv(kind: string, source: NodeJS.ProcessEnv, stateDir: string, projectRoot: string): NodeJS.ProcessEnv {
|
|
21
|
+
const env: NodeJS.ProcessEnv = { ...peerChildEnv(kind, source, { preserveOrca: true }), AGENTHUB_STATE_DIR: stateDir, AGENTHUB_PROJECT_DIR: projectRoot };
|
|
22
|
+
for (const name of ["AGENTHUB_UNATTENDED", "AGENTHUB_MODE", "AGENTHUB_CHANNEL", "AGENTHUB_RECOVERY_OPERATION"]) delete env[name];
|
|
23
|
+
return env;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* #1809 AC4: `ahub <kind>` for a configured pull kind runs the person's command in their terminal with the kind's peer identity.
|
|
28
|
+
* The TUI reaches the hub through the MCP server the person registered in that CLI; the hub never writes that registration.
|
|
29
|
+
* ponytail: no terminal-launch record yet; a pull session has no recovery driver (its definition refuses recovery), so the record would feed nothing. Add it with the recovery driver.
|
|
30
|
+
*/
|
|
31
|
+
export async function runConfiguredPullEntry(context: {
|
|
32
|
+
kind: string; raw: readonly string[]; catalog: ProjectAdapterCatalog; projectRoot: string; stateDir: string; env: NodeJS.ProcessEnv;
|
|
33
|
+
declared: { command: string; args: readonly string[]; versionArgs: readonly string[] };
|
|
34
|
+
connect(): Promise<ConfiguredPullControl>; warn(text: string): void;
|
|
35
|
+
run(command: string, args: string[], env: NodeJS.ProcessEnv): number | Promise<number>;
|
|
36
|
+
}): Promise<number> {
|
|
37
|
+
const launch = parseConfiguredPullArguments(context.raw, context.declared);
|
|
38
|
+
if (launch.preview) {
|
|
39
|
+
console.log(JSON.stringify({ command: launch.command, args: launch.args, mode: "tui", peer: context.kind, env: ["AGENTHUB_PEER_ID", "AGENTHUB_STATE_DIR", "AGENTHUB_PROJECT_DIR"], writes: false }, null, 2));
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
const probe = spawnSync(context.declared.command, [...context.declared.versionArgs], { encoding: "utf8", timeout: 5000, maxBuffer: 4096, env: peerChildEnv(context.kind, context.env) });
|
|
43
|
+
if (probe.error || probe.status !== 0) throw new Error(`${context.declared.command} did not answer its version probe; install it or fix adapters.${context.kind}.versionArgs`);
|
|
44
|
+
const hub = await context.connect();
|
|
45
|
+
try {
|
|
46
|
+
const reply = await hub.request({ t: "status" });
|
|
47
|
+
const active = reply.status?.configuredAdapters;
|
|
48
|
+
if (!Array.isArray(active) || !active.includes(context.kind)) throw new Error(`running hub has not loaded ${context.kind}; restart it after declaring the adapter`);
|
|
49
|
+
if (rosterInStatus(reply.status, context.kind) !== true) throw new Error(`${context.kind} is off roster; add it with ahub roster add ${context.kind}`);
|
|
50
|
+
} finally { hub.close(); }
|
|
51
|
+
context.warn(CONFIGURED_PULL_NOTICE);
|
|
52
|
+
return await context.run(launch.command, launch.args, configuredPullEnv(context.kind, context.env, context.stateDir, context.projectRoot));
|
|
53
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { AdapterDefinition } from "./registry-types.ts";
|
|
2
|
+
import type { ConfiguredPullAdapterConfig } from "./configured-adapter-policy.ts";
|
|
3
|
+
import { freeze } from "./configured-adapter-policy.ts";
|
|
4
|
+
import { presetStatusById } from "./presets.ts";
|
|
5
|
+
import { shellQuote } from "../cli/shell-quote.ts";
|
|
6
|
+
|
|
7
|
+
/** One status line shown for a pull kind: what its session can and cannot do. */
|
|
8
|
+
export const CONFIGURED_PULL_NOTICE = "pull-only TUI: messages wait for hub_inbox; no pushed delivery, no task ownership, no hub permission mode or session recovery";
|
|
9
|
+
|
|
10
|
+
const declarations = new WeakMap<AdapterDefinition, ConfiguredPullAdapterConfig>();
|
|
11
|
+
/** The checked declaration behind a pull definition, for the launcher; `undefined` for any other definition. */
|
|
12
|
+
export function pullDeclarationOf(definition: AdapterDefinition | undefined): ConfiguredPullAdapterConfig | undefined {
|
|
13
|
+
return definition === undefined ? undefined : declarations.get(definition);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** #1809: a person's own TUI that reaches the hub through the MCP bridge in its pull-only peer mode (as agy does). Cloud trust, off roster, never pushed to, never an owner. */
|
|
17
|
+
export function configuredPullDefinition(kind: string, declaration: ConfiguredPullAdapterConfig): AdapterDefinition {
|
|
18
|
+
const { command, args, roles, preset } = declaration;
|
|
19
|
+
const displayName = preset === undefined ? declaration.displayName : `${declaration.displayName} (${presetStatusById(preset)})`;
|
|
20
|
+
const argv = [command, ...args];
|
|
21
|
+
const definition = freeze<AdapterDefinition>({
|
|
22
|
+
api: 1, kind, family: kind, displayName, roles, tasks: false, transport: "ws-pull", optional: true, defaultOnRoster: false,
|
|
23
|
+
trust: { onPrem: false, hubSandboxed: false }, identity: { mcp: "channel-plugin" },
|
|
24
|
+
start: {
|
|
25
|
+
forms: ["tui"], defaultForm: "tui", conductorStartable: false, hubSwitches: [], ownedFlags: [],
|
|
26
|
+
launch: context => ({ cmd: command, args: [...args, ...context.userArgs], metadata: { packageEntrypoint: context.entrypoint, argv: [...argv, ...context.userArgs], command: [...argv, ...context.userArgs].map(shellQuote).join(" "), env: {} } }),
|
|
27
|
+
conductorStartArgs: given => given.length ? new Error(`conductor starts accept no launch overrides; use ahub ${kind}`) : {},
|
|
28
|
+
},
|
|
29
|
+
attach: { externalHello: true, pullOnlyForms: ["tui"], pullOnlyNotice: CONFIGURED_PULL_NOTICE },
|
|
30
|
+
permission: { unmanaged: `${kind} selects its own permission mode in its TUI; no hub permission mode`, unmanagedForms: ["tui"], unmanagedNote: `${kind} approves tools in its own TUI; no hub permission mode`, unmanagedStatusNote: "unmanaged native permission policy" },
|
|
31
|
+
session: { idField: "sessionId", currentId: () => undefined, freshOnRestore: true, recoveryRefusal: () => `${kind} is a pull-only session with no retained state; start it again with ahub ${kind}` },
|
|
32
|
+
turnEnd: "adapter",
|
|
33
|
+
cli: { command: kind, startWords: () => [kind] },
|
|
34
|
+
display: { palette: { fg: "white", bg: "black" } },
|
|
35
|
+
});
|
|
36
|
+
declarations.set(definition, declaration);
|
|
37
|
+
return definition;
|
|
38
|
+
}
|
|
@@ -24,6 +24,7 @@ export function startFakeAppServer(
|
|
|
24
24
|
return srv.upgrade(req) ? undefined : new Response("no", { status: 400 });
|
|
25
25
|
},
|
|
26
26
|
websocket: {
|
|
27
|
+
open(ws) { ws.subscribe("fixture-account-notifications"); },
|
|
27
28
|
async message(ws, data) {
|
|
28
29
|
const msg = JSON.parse(String(data));
|
|
29
30
|
requests.push(msg); onRequest?.(msg);
|
|
@@ -37,7 +38,10 @@ export function startFakeAppServer(
|
|
|
37
38
|
reply({ thread: { id: msg.params.threadId }, model: "fake", ...(reportApprovalPolicy ? { approvalPolicy: msg.params.approvalPolicy ?? "untrusted" } : {}) });
|
|
38
39
|
return note("thread/tokenUsage/updated", { threadId: msg.params.threadId, turnId: "old", tokenUsage: { total: usage(threadTotal), last: usage(800) } });
|
|
39
40
|
}
|
|
40
|
-
if (msg.method === "account/rateLimits/read")
|
|
41
|
+
if (msg.method === "account/rateLimits/read") {
|
|
42
|
+
const value = rateLimitsRead ? rateLimitsRead() : { rateLimits: { primary: { usedPercent, windowDurationMins: 300, resetsAt: 1_900_000_000 }, secondary: null } };
|
|
43
|
+
return reply(value instanceof Promise ? await value : value);
|
|
44
|
+
}
|
|
41
45
|
if (msg.method === "thread/revert") {
|
|
42
46
|
reverted.push(msg.params);
|
|
43
47
|
onRevert?.(msg.params);
|
|
@@ -119,5 +123,8 @@ export function startFakeAppServer(
|
|
|
119
123
|
},
|
|
120
124
|
},
|
|
121
125
|
});
|
|
122
|
-
return { url: `ws://127.0.0.1:${server.port}`, stop: () => server.stop(true), reverted, requests
|
|
126
|
+
return { url: `ws://127.0.0.1:${server.port}`, stop: () => server.stop(true), reverted, requests,
|
|
127
|
+
notifyAccountUpdated: () => server.publish("fixture-account-notifications", JSON.stringify({ method: "account/updated", params: {} })),
|
|
128
|
+
notify: (method: string, params: unknown) => server.publish("fixture-account-notifications", JSON.stringify({ method, params })),
|
|
129
|
+
};
|
|
123
130
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LIGHT_NATIVE_CLI_ENTRIES } from "./definitions/native-light-cli.ts";
|
|
2
|
+
import { isBuiltinAdapterKind } from "./definitions/native-help.ts";
|
|
3
|
+
import { createPolicyCatalog } from "./declaration-data.ts";
|
|
4
|
+
import type { AdapterDefinition, ProjectAdapterCatalog } from "./registry-types.ts";
|
|
5
|
+
|
|
6
|
+
export { CONDUCTOR_START_PEERS, conductorStartText, DECLARATION_SUPPORTED_PEERS, DECLARATION_PLANNER_PEERS,
|
|
7
|
+
DECLARATION_REVIEW_POOL_KINDS, DECLARATION_DEFAULT_REVIEW_POOL, DECLARATION_START_MODE_PEERS } from "./declaration-data.ts";
|
|
8
|
+
|
|
9
|
+
function entryFor(kind: string): AdapterDefinition["cli"]["entry"] {
|
|
10
|
+
if (!isBuiltinAdapterKind(kind)) return;
|
|
11
|
+
if (Object.hasOwn(LIGHT_NATIVE_CLI_ENTRIES, kind)) {
|
|
12
|
+
const { lifecycleAdmission, execute } = LIGHT_NATIVE_CLI_ENTRIES[kind as keyof typeof LIGHT_NATIVE_CLI_ENTRIES];
|
|
13
|
+
return { lifecycleAdmission, execute };
|
|
14
|
+
}
|
|
15
|
+
return { lifecycleAdmission: kind !== "pi" && kind !== "local", execute: async context => {
|
|
16
|
+
const { definitionOf } = await import("./registry.ts");
|
|
17
|
+
await definitionOf(kind)!.cli.entry!.execute(context);
|
|
18
|
+
} };
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function createProjectDeclarationCatalog(raw?: unknown, external: readonly AdapterDefinition[] = []): ProjectAdapterCatalog {
|
|
22
|
+
return createPolicyCatalog(raw, external, entryFor);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const builtinDeclarationOf = createProjectDeclarationCatalog().definitionOf;
|