@ken-jo/agent-connector 0.3.1 → 0.4.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/README.md +178 -14
- package/dist/action-PLZW5BGX.js +54 -0
- package/dist/action-PLZW5BGX.js.map +1 -0
- package/dist/{amp-YGV66GJT.js → amp-B524U6LO.js} +81 -5
- package/dist/amp-B524U6LO.js.map +1 -0
- package/dist/{antigravity-7IBYFO6P.js → antigravity-ANDKF3K7.js} +4 -4
- package/dist/{antigravity-cli-JEOUP2VN.js → antigravity-cli-LLRPDDOT.js} +4 -4
- package/dist/chunk-22Y24V7O.js +21 -0
- package/dist/chunk-22Y24V7O.js.map +1 -0
- package/dist/chunk-3PFFTFCU.js +190 -0
- package/dist/chunk-3PFFTFCU.js.map +1 -0
- package/dist/{chunk-SCVBYSF7.js → chunk-6XHB6BE3.js} +1 -1
- package/dist/chunk-76FUSVIA.js +43 -0
- package/dist/chunk-76FUSVIA.js.map +1 -0
- package/dist/{chunk-GSGDG2BV.js → chunk-ADTHT2FN.js} +109 -16
- package/dist/chunk-ADTHT2FN.js.map +1 -0
- package/dist/{chunk-ZAM4M7LI.js → chunk-BHUCB6LY.js} +135 -296
- package/dist/chunk-BHUCB6LY.js.map +1 -0
- package/dist/{chunk-MEH7GC7R.js → chunk-BXGFUENQ.js} +20 -3
- package/dist/chunk-BXGFUENQ.js.map +1 -0
- package/dist/chunk-CIRDOY2V.js +351 -0
- package/dist/chunk-CIRDOY2V.js.map +1 -0
- package/dist/{chunk-KMAKDD3Z.js → chunk-G3ER4SY5.js} +37 -12
- package/dist/chunk-G3ER4SY5.js.map +1 -0
- package/dist/{chunk-PD4VFEBY.js → chunk-IW77FFNX.js} +39 -1
- package/dist/chunk-IW77FFNX.js.map +1 -0
- package/dist/chunk-J3D5W5T2.js +83 -0
- package/dist/chunk-J3D5W5T2.js.map +1 -0
- package/dist/{openclaw-UZ5BMCGQ.js → chunk-KGGBNKI4.js} +125 -33
- package/dist/chunk-KGGBNKI4.js.map +1 -0
- package/dist/{chunk-3JCRUROU.js → chunk-KGJWE6A2.js} +13 -4
- package/dist/chunk-KGJWE6A2.js.map +1 -0
- package/dist/{chunk-3RBLIHPZ.js → chunk-KGXDYGNJ.js} +26 -16
- package/dist/chunk-KGXDYGNJ.js.map +1 -0
- package/dist/{chunk-KVAAFYRR.js → chunk-KHO5WNTP.js} +2 -18
- package/dist/chunk-KHO5WNTP.js.map +1 -0
- package/dist/{chunk-KQSNDFBN.js → chunk-LL4OBGRU.js} +3 -3
- package/dist/{chunk-WNREHWKL.js → chunk-MAH6QQTO.js} +3 -3
- package/dist/{claude-code-4275HQU4.js → claude-code-MLWS7CW6.js} +180 -28
- package/dist/claude-code-MLWS7CW6.js.map +1 -0
- package/dist/cli/sdk.js +4 -3
- package/dist/cli/sdk.js.map +1 -1
- package/dist/cli.js +1 -1
- package/dist/{codebuff-LE3KBZGM.js → codebuff-SH2S3QAN.js} +102 -5
- package/dist/codebuff-SH2S3QAN.js.map +1 -0
- package/dist/{codex-4BY2ZJIW.js → codex-BXA4FIF4.js} +3 -3
- package/dist/{copilot-cli-IPISKO3V.js → copilot-cli-ROIBTTDT.js} +3 -3
- package/dist/{crush-X3E25EQG.js → crush-QLEFLHUC.js} +3 -3
- package/dist/{cursor-UH3W622V.js → cursor-ASJPWZ4R.js} +6 -3
- package/dist/cursor-ASJPWZ4R.js.map +1 -0
- package/dist/{detect-U3E7NVNW.js → detect-ZIIS55LD.js} +4 -3
- package/dist/{detect-U3E7NVNW.js.map → detect-ZIIS55LD.js.map} +1 -1
- package/dist/{doctor-DZTWED4O.js → doctor-TJUGSQ5C.js} +16 -12
- package/dist/doctor-TJUGSQ5C.js.map +1 -0
- package/dist/{droid-T5VBRXZF.js → droid-NCSS3B5Y.js} +170 -4
- package/dist/droid-NCSS3B5Y.js.map +1 -0
- package/dist/{gemini-cli-ZSUK55UA.js → gemini-cli-SLVWLXJW.js} +3 -3
- package/dist/{goose-M3RR3CZG.js → goose-PBA7KTE5.js} +100 -5
- package/dist/goose-PBA7KTE5.js.map +1 -0
- package/dist/{hermes-CUNKIAR5.js → hermes-ONDCECP2.js} +3 -3
- package/dist/{hook-EVY7LOUQ.js → hook-OU522ABV.js} +12 -9
- package/dist/{hook-EVY7LOUQ.js.map → hook-OU522ABV.js.map} +1 -1
- package/dist/index.d.ts +71 -3
- package/dist/index.js +22 -3
- package/dist/{install-OWAS5UIE.js → install-UDCBL7HP.js} +11 -9
- package/dist/{install-OWAS5UIE.js.map → install-UDCBL7HP.js.map} +1 -1
- package/dist/introspect-DuZSPSHB.d.ts +53 -0
- package/dist/{jetbrains-copilot-C3HDGGML.js → jetbrains-copilot-YABZ3HFA.js} +3 -3
- package/dist/{kilo-PKAJCWPX.js → kilo-F3ZDZKCT.js} +3 -3
- package/dist/{kilo-cli-QWUVXG2O.js → kilo-cli-3HWPWBY4.js} +3 -3
- package/dist/{kimi-EVD7YKXS.js → kimi-NV72FVAO.js} +3 -3
- package/dist/{kiro-UQRY6EIO.js → kiro-C5W6AGDR.js} +3 -3
- package/dist/{leaderboard-CSWHI4UY.js → leaderboard-TIBVONVT.js} +3 -3
- package/dist/mimo-code-IMM5YM3M.js +754 -0
- package/dist/mimo-code-IMM5YM3M.js.map +1 -0
- package/dist/{mux-5CI5FP2W.js → mux-DSSH4AFS.js} +3 -3
- package/dist/nemoclaw-3EVNKD3I.js +58 -0
- package/dist/nemoclaw-3EVNKD3I.js.map +1 -0
- package/dist/{omp-AXA7XY22.js → omp-Z6FRNDPN.js} +3 -3
- package/dist/openclaw-7G437NT7.js +18 -0
- package/dist/openclaw-7G437NT7.js.map +1 -0
- package/dist/{opencode-NZBRLJN3.js → opencode-Q6KBSAKW.js} +3 -3
- package/dist/{package-WFOS4QVU.js → package-RMPN57YZ.js} +7 -6
- package/dist/{package-WFOS4QVU.js.map → package-RMPN57YZ.js.map} +1 -1
- package/dist/{pi-WMTUX6ES.js → pi-LZT6WWAZ.js} +2 -2
- package/dist/{qwen-code-MRRIUQ3P.js → qwen-code-WQBKRPWJ.js} +3 -3
- package/dist/{roo-code-NI5UU6JB.js → roo-code-GWSNU3OW.js} +137 -4
- package/dist/roo-code-GWSNU3OW.js.map +1 -0
- package/dist/runtime/index.d.ts +96 -2
- package/dist/runtime/index.js +18 -10
- package/dist/sdk/index.d.ts +52 -0
- package/dist/sdk/index.js +81 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/test.d.ts +74 -0
- package/dist/sdk/test.js +291 -0
- package/dist/sdk/test.js.map +1 -0
- package/dist/{serve-3C2VFPAY.js → serve-D3GO36UT.js} +12 -9
- package/dist/{serve-3C2VFPAY.js.map → serve-D3GO36UT.js.map} +1 -1
- package/dist/{status-MKQYX5MW.js → status-KOSKCETC.js} +9 -7
- package/dist/{status-MKQYX5MW.js.map → status-KOSKCETC.js.map} +1 -1
- package/dist/statusline-ZNTCL5YC.js +59 -0
- package/dist/statusline-ZNTCL5YC.js.map +1 -0
- package/dist/{telemetry-3DN6XGYB.js → telemetry-XIKUUGTQ.js} +5 -4
- package/dist/{telemetry-3DN6XGYB.js.map → telemetry-XIKUUGTQ.js.map} +1 -1
- package/dist/{trae-CQC72RHH.js → trae-NWT3TMSZ.js} +99 -5
- package/dist/trae-NWT3TMSZ.js.map +1 -0
- package/dist/{types-CNigfEuR.d.ts → types-BEKsAium.d.ts} +268 -6
- package/dist/{uninstall-WG6PFWF3.js → uninstall-2LBLQVFA.js} +11 -9
- package/dist/{uninstall-WG6PFWF3.js.map → uninstall-2LBLQVFA.js.map} +1 -1
- package/dist/{upgrade-32NC2RKI.js → upgrade-ZC2S7VRN.js} +11 -9
- package/dist/{upgrade-32NC2RKI.js.map → upgrade-ZC2S7VRN.js.map} +1 -1
- package/dist/{usage-CJOM2WQM.js → usage-E2A4O2CY.js} +3 -3
- package/dist/{usage-event-472X3DOY.js → usage-event-JKMC4QC4.js} +11 -8
- package/dist/{usage-event-472X3DOY.js.map → usage-event-JKMC4QC4.js.map} +1 -1
- package/dist/{vscode-copilot-4RVRTCKV.js → vscode-copilot-ALV45XF6.js} +3 -3
- package/dist/{warp-X6MB67NT.js → warp-H6IX4U3J.js} +3 -3
- package/dist/{zed-NTCYW4V2.js → zed-RH34TNSW.js} +3 -3
- package/package.json +9 -1
- package/dist/amp-YGV66GJT.js.map +0 -1
- package/dist/chunk-3JCRUROU.js.map +0 -1
- package/dist/chunk-3RBLIHPZ.js.map +0 -1
- package/dist/chunk-GSGDG2BV.js.map +0 -1
- package/dist/chunk-KMAKDD3Z.js.map +0 -1
- package/dist/chunk-KVAAFYRR.js.map +0 -1
- package/dist/chunk-MEH7GC7R.js.map +0 -1
- package/dist/chunk-NJU275US.js +0 -238
- package/dist/chunk-NJU275US.js.map +0 -1
- package/dist/chunk-PD4VFEBY.js.map +0 -1
- package/dist/chunk-ZAM4M7LI.js.map +0 -1
- package/dist/claude-code-4275HQU4.js.map +0 -1
- package/dist/codebuff-LE3KBZGM.js.map +0 -1
- package/dist/cursor-UH3W622V.js.map +0 -1
- package/dist/doctor-DZTWED4O.js.map +0 -1
- package/dist/droid-T5VBRXZF.js.map +0 -1
- package/dist/goose-M3RR3CZG.js.map +0 -1
- package/dist/openclaw-UZ5BMCGQ.js.map +0 -1
- package/dist/roo-code-NI5UU6JB.js.map +0 -1
- package/dist/trae-CQC72RHH.js.map +0 -1
- /package/dist/{antigravity-7IBYFO6P.js.map → antigravity-ANDKF3K7.js.map} +0 -0
- /package/dist/{antigravity-cli-JEOUP2VN.js.map → antigravity-cli-LLRPDDOT.js.map} +0 -0
- /package/dist/{chunk-SCVBYSF7.js.map → chunk-6XHB6BE3.js.map} +0 -0
- /package/dist/{chunk-KQSNDFBN.js.map → chunk-LL4OBGRU.js.map} +0 -0
- /package/dist/{chunk-WNREHWKL.js.map → chunk-MAH6QQTO.js.map} +0 -0
- /package/dist/{codex-4BY2ZJIW.js.map → codex-BXA4FIF4.js.map} +0 -0
- /package/dist/{copilot-cli-IPISKO3V.js.map → copilot-cli-ROIBTTDT.js.map} +0 -0
- /package/dist/{crush-X3E25EQG.js.map → crush-QLEFLHUC.js.map} +0 -0
- /package/dist/{gemini-cli-ZSUK55UA.js.map → gemini-cli-SLVWLXJW.js.map} +0 -0
- /package/dist/{hermes-CUNKIAR5.js.map → hermes-ONDCECP2.js.map} +0 -0
- /package/dist/{jetbrains-copilot-C3HDGGML.js.map → jetbrains-copilot-YABZ3HFA.js.map} +0 -0
- /package/dist/{kilo-PKAJCWPX.js.map → kilo-F3ZDZKCT.js.map} +0 -0
- /package/dist/{kilo-cli-QWUVXG2O.js.map → kilo-cli-3HWPWBY4.js.map} +0 -0
- /package/dist/{kimi-EVD7YKXS.js.map → kimi-NV72FVAO.js.map} +0 -0
- /package/dist/{kiro-UQRY6EIO.js.map → kiro-C5W6AGDR.js.map} +0 -0
- /package/dist/{leaderboard-CSWHI4UY.js.map → leaderboard-TIBVONVT.js.map} +0 -0
- /package/dist/{mux-5CI5FP2W.js.map → mux-DSSH4AFS.js.map} +0 -0
- /package/dist/{omp-AXA7XY22.js.map → omp-Z6FRNDPN.js.map} +0 -0
- /package/dist/{opencode-NZBRLJN3.js.map → opencode-Q6KBSAKW.js.map} +0 -0
- /package/dist/{pi-WMTUX6ES.js.map → pi-LZT6WWAZ.js.map} +0 -0
- /package/dist/{qwen-code-MRRIUQ3P.js.map → qwen-code-WQBKRPWJ.js.map} +0 -0
- /package/dist/{usage-CJOM2WQM.js.map → usage-E2A4O2CY.js.map} +0 -0
- /package/dist/{vscode-copilot-4RVRTCKV.js.map → vscode-copilot-ALV45XF6.js.map} +0 -0
- /package/dist/{warp-X6MB67NT.js.map → warp-H6IX4U3J.js.map} +0 -0
- /package/dist/{zed-NTCYW4V2.js.map → zed-RH34TNSW.js.map} +0 -0
package/dist/sdk/test.js
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
compileMatcher,
|
|
4
|
+
eventMatcherSubject
|
|
5
|
+
} from "../chunk-CIRDOY2V.js";
|
|
6
|
+
import "../chunk-BCHWFTV4.js";
|
|
7
|
+
import "../chunk-KHO5WNTP.js";
|
|
8
|
+
import {
|
|
9
|
+
SURFACE_PREDICATES
|
|
10
|
+
} from "../chunk-76FUSVIA.js";
|
|
11
|
+
import "../chunk-KGJWE6A2.js";
|
|
12
|
+
import "../chunk-ADTHT2FN.js";
|
|
13
|
+
import {
|
|
14
|
+
allAdapters,
|
|
15
|
+
loadAdapter
|
|
16
|
+
} from "../chunk-3PFFTFCU.js";
|
|
17
|
+
import "../chunk-N6HH7K6P.js";
|
|
18
|
+
import "../chunk-TRQKHP7D.js";
|
|
19
|
+
|
|
20
|
+
// src/sdk/test-harness.ts
|
|
21
|
+
function declaredGlobalSurfaces(connector) {
|
|
22
|
+
const out = [];
|
|
23
|
+
if (connector.server) out.push("server");
|
|
24
|
+
if (Object.keys(connector.hooks).length > 0) out.push("hooks");
|
|
25
|
+
if (connector.commands.length > 0) out.push("commands");
|
|
26
|
+
if (connector.skills.length > 0) out.push("skills");
|
|
27
|
+
if (connector.subagents.length > 0) out.push("subagents");
|
|
28
|
+
if (connector.memory.length > 0) out.push("memory");
|
|
29
|
+
if (connector.statusline) out.push("statusline");
|
|
30
|
+
if (connector.actions.length > 0) out.push("actions");
|
|
31
|
+
return out;
|
|
32
|
+
}
|
|
33
|
+
function platformScopedSurfacesFor(override) {
|
|
34
|
+
const out = [];
|
|
35
|
+
if (!override) return out;
|
|
36
|
+
if ((override.configPatch?.length ?? 0) > 0) out.push("configPatch");
|
|
37
|
+
if (override.nativeHooks != null && Object.keys(override.nativeHooks).length > 0) {
|
|
38
|
+
out.push("nativeHooks");
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
function isDisabledForHost(connector, host, surface) {
|
|
43
|
+
const override = connector.platforms[host];
|
|
44
|
+
if (!override) return false;
|
|
45
|
+
switch (surface) {
|
|
46
|
+
case "server":
|
|
47
|
+
return override.server === false;
|
|
48
|
+
case "hooks":
|
|
49
|
+
return override.hooks === false;
|
|
50
|
+
case "commands":
|
|
51
|
+
return override.commands === false;
|
|
52
|
+
case "skills":
|
|
53
|
+
return override.skills === false;
|
|
54
|
+
case "subagents":
|
|
55
|
+
return override.subagents === false;
|
|
56
|
+
case "memory":
|
|
57
|
+
return override.memory === false;
|
|
58
|
+
case "statusline":
|
|
59
|
+
return override.statusline === false;
|
|
60
|
+
case "actions":
|
|
61
|
+
case "configPatch":
|
|
62
|
+
case "nativeHooks":
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
async function explain(connector) {
|
|
67
|
+
const globalSurfaces = declaredGlobalSurfaces(connector);
|
|
68
|
+
const adapters = await allAdapters();
|
|
69
|
+
const rows = [];
|
|
70
|
+
for (const adapter of adapters) {
|
|
71
|
+
const override = connector.platforms[adapter.id];
|
|
72
|
+
const surfaces = [
|
|
73
|
+
...globalSurfaces,
|
|
74
|
+
...platformScopedSurfacesFor(override)
|
|
75
|
+
];
|
|
76
|
+
for (const surface of surfaces) {
|
|
77
|
+
if (isDisabledForHost(connector, adapter.id, surface)) {
|
|
78
|
+
rows.push({
|
|
79
|
+
host: adapter.id,
|
|
80
|
+
surface,
|
|
81
|
+
support: "disabled",
|
|
82
|
+
reason: `connector opted out for ${adapter.id} (platforms.${adapter.id}.${surface} = false)`
|
|
83
|
+
});
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const native = SURFACE_PREDICATES[surface](adapter.capabilities);
|
|
87
|
+
rows.push({
|
|
88
|
+
host: adapter.id,
|
|
89
|
+
surface,
|
|
90
|
+
support: native ? "native" : "skip-warn",
|
|
91
|
+
reason: explainReason(adapter.id, surface, native)
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
rows.sort(
|
|
96
|
+
(a, b) => a.host === b.host ? a.surface.localeCompare(b.surface) : a.host.localeCompare(b.host)
|
|
97
|
+
);
|
|
98
|
+
return rows;
|
|
99
|
+
}
|
|
100
|
+
function explainReason(host, surface, native) {
|
|
101
|
+
if (surface === "server") {
|
|
102
|
+
return native ? `${host} advertises an MCP transport (capability-based; registration may be host-managed)` : `${host} advertises no MCP transport; install skip-warns`;
|
|
103
|
+
}
|
|
104
|
+
return native ? `${host} natively supports ${surface}` : `${host} cannot honor ${surface}; install skip-warns`;
|
|
105
|
+
}
|
|
106
|
+
function coerceInput(input) {
|
|
107
|
+
if (input == null) return {};
|
|
108
|
+
if (typeof input === "string") {
|
|
109
|
+
const trimmed = input.trim();
|
|
110
|
+
if (trimmed === "") return {};
|
|
111
|
+
try {
|
|
112
|
+
return JSON.parse(trimmed);
|
|
113
|
+
} catch {
|
|
114
|
+
return {};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return input;
|
|
118
|
+
}
|
|
119
|
+
function normalizeResponse(value) {
|
|
120
|
+
if (value == null || typeof value !== "object") return {};
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
function parseReplyStdout(stdout) {
|
|
124
|
+
if (stdout == null || stdout.trim() === "") return void 0;
|
|
125
|
+
try {
|
|
126
|
+
const value = JSON.parse(stdout);
|
|
127
|
+
return value != null && typeof value === "object" ? value : void 0;
|
|
128
|
+
} catch {
|
|
129
|
+
return void 0;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
function deepEqual(a, b) {
|
|
133
|
+
if (a === b) return true;
|
|
134
|
+
if (typeof a !== typeof b || a == null || b == null) return false;
|
|
135
|
+
if (typeof a !== "object") return false;
|
|
136
|
+
const aArr = Array.isArray(a);
|
|
137
|
+
if (aArr !== Array.isArray(b)) return false;
|
|
138
|
+
if (aArr) {
|
|
139
|
+
const x2 = a;
|
|
140
|
+
const y2 = b;
|
|
141
|
+
return x2.length === y2.length && x2.every((v, i) => deepEqual(v, y2[i]));
|
|
142
|
+
}
|
|
143
|
+
const x = a;
|
|
144
|
+
const y = b;
|
|
145
|
+
const xk = Object.keys(x);
|
|
146
|
+
const yk = Object.keys(y);
|
|
147
|
+
return xk.length === yk.length && xk.every((k) => deepEqual(x[k], y[k]));
|
|
148
|
+
}
|
|
149
|
+
function judgeHookHonor(host, event, response, stdout) {
|
|
150
|
+
const decision = response.decision;
|
|
151
|
+
if (decision === void 0 || decision === "allow") {
|
|
152
|
+
return { honored: true, reason: "pass-through allow" };
|
|
153
|
+
}
|
|
154
|
+
const reply = parseReplyStdout(stdout);
|
|
155
|
+
const hso = reply?.hookSpecificOutput;
|
|
156
|
+
if (decision === "context") {
|
|
157
|
+
const want = response.additionalContext;
|
|
158
|
+
const got = hso?.additionalContext ?? reply?.systemMessage;
|
|
159
|
+
if (reply && got === want) {
|
|
160
|
+
return { honored: true, reason: `${host} injects context on ${event}` };
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
honored: false,
|
|
164
|
+
reason: `${host} drops context on ${event} (no stdout path)`
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (decision === "deny") {
|
|
168
|
+
if (!reply) {
|
|
169
|
+
return {
|
|
170
|
+
honored: false,
|
|
171
|
+
reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
if (hso?.permissionDecision === "deny" || hso?.decision?.behavior === "deny") {
|
|
175
|
+
return { honored: true, reason: `${host} blocks ${event}` };
|
|
176
|
+
}
|
|
177
|
+
if (reply.decision === "block") {
|
|
178
|
+
return {
|
|
179
|
+
honored: true,
|
|
180
|
+
reason: `${host} continues the session/subagent on ${event} (persistence) \u2014 NOT a block`
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
if (hso?.additionalContext != null) {
|
|
184
|
+
return {
|
|
185
|
+
honored: false,
|
|
186
|
+
reason: `${host} degrades deny to a context note on ${event}; spawn/failure not blocked`
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
honored: false,
|
|
191
|
+
reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
if (decision === "ask") {
|
|
195
|
+
if (hso?.permissionDecision === "ask") {
|
|
196
|
+
return { honored: true, reason: `${host} asks on ${event}` };
|
|
197
|
+
}
|
|
198
|
+
if (event === "PermissionRequest" && !reply) {
|
|
199
|
+
return {
|
|
200
|
+
honored: true,
|
|
201
|
+
reason: `${host} shows the native confirmation dialog on ${event} (the ask)`
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
return {
|
|
205
|
+
honored: false,
|
|
206
|
+
reason: `${host} drops ask on ${event} (no ask path)`
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const wrote = hso?.updatedInput ?? hso?.decision?.updatedInput;
|
|
210
|
+
if (reply && wrote !== void 0 && deepEqual(wrote, response.updatedInput)) {
|
|
211
|
+
return { honored: true, reason: `${host} rewrites tool input on ${event}` };
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
honored: false,
|
|
215
|
+
reason: `${host} drops modify on ${event} (modify not honored)`
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
async function simulate(connector, opts) {
|
|
219
|
+
try {
|
|
220
|
+
const adapter = await loadAdapter(opts.host);
|
|
221
|
+
if (!adapter) {
|
|
222
|
+
return { honored: false, reason: `unknown host "${opts.host}"` };
|
|
223
|
+
}
|
|
224
|
+
if (opts.surface === "statusline") {
|
|
225
|
+
if (!(adapter.capabilities.supportsStatusline ?? false) || !adapter.parseStatusInput || !adapter.formatStatusOutput) {
|
|
226
|
+
return { honored: false, reason: `${opts.host} has no statusline surface` };
|
|
227
|
+
}
|
|
228
|
+
if (!connector.statusline || typeof connector.statusline.render !== "function") {
|
|
229
|
+
return { honored: false, reason: "connector declares no statusline" };
|
|
230
|
+
}
|
|
231
|
+
const ctx = adapter.parseStatusInput(coerceInput(opts.input));
|
|
232
|
+
ctx.connectorId = connector.id;
|
|
233
|
+
if (ctx.capabilities == null) ctx.capabilities = adapter.capabilities;
|
|
234
|
+
const perHost2 = connector.statusline.hosts?.[opts.host]?.render;
|
|
235
|
+
const render = typeof perHost2 === "function" ? perHost2 : connector.statusline.render;
|
|
236
|
+
const rendered = await render(ctx);
|
|
237
|
+
const line = rendered == null ? "" : String(rendered);
|
|
238
|
+
const reply2 = adapter.formatStatusOutput(line);
|
|
239
|
+
return {
|
|
240
|
+
honored: true,
|
|
241
|
+
...reply2.stdout !== void 0 ? { hostReply: reply2.stdout } : {},
|
|
242
|
+
reason: "rendered"
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
const event = opts.event;
|
|
246
|
+
if (!event) {
|
|
247
|
+
return { honored: false, reason: 'event is required when surface === "hooks"' };
|
|
248
|
+
}
|
|
249
|
+
if (!adapter.parseEvent || !adapter.formatReply) {
|
|
250
|
+
return { honored: false, reason: `${opts.host} has no hook runtime (mcp-only)` };
|
|
251
|
+
}
|
|
252
|
+
const evt = adapter.parseEvent(event, coerceInput(opts.input));
|
|
253
|
+
evt.connectorId = connector.id;
|
|
254
|
+
evt.capabilities = adapter.capabilities;
|
|
255
|
+
const definition = connector.hooks[event];
|
|
256
|
+
if (!definition || typeof definition.handler !== "function") {
|
|
257
|
+
return { honored: false, reason: `connector declares no ${event} handler` };
|
|
258
|
+
}
|
|
259
|
+
const subject = eventMatcherSubject(evt);
|
|
260
|
+
if (subject !== void 0) {
|
|
261
|
+
const re = compileMatcher(definition.matcher);
|
|
262
|
+
if (re && !re.test(subject)) {
|
|
263
|
+
return {
|
|
264
|
+
honored: true,
|
|
265
|
+
reason: `matcher excludes ${subject} (handler not run)`
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
const perHost = definition.hosts?.[opts.host]?.handler;
|
|
270
|
+
const handler = typeof perHost === "function" ? perHost : definition.handler;
|
|
271
|
+
const response = normalizeResponse(
|
|
272
|
+
await handler(evt)
|
|
273
|
+
);
|
|
274
|
+
const reply = adapter.formatReply(event, response);
|
|
275
|
+
const verdict = judgeHookHonor(String(opts.host), event, response, reply.stdout);
|
|
276
|
+
return {
|
|
277
|
+
honored: verdict.honored,
|
|
278
|
+
...reply.stdout !== void 0 ? { hostReply: reply.stdout } : {},
|
|
279
|
+
reason: verdict.reason
|
|
280
|
+
};
|
|
281
|
+
} catch (err) {
|
|
282
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
283
|
+
const verb = opts.surface === "statusline" ? "render" : "handler";
|
|
284
|
+
return { honored: false, reason: `${verb} threw: ${message}` };
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
export {
|
|
288
|
+
explain,
|
|
289
|
+
simulate
|
|
290
|
+
};
|
|
291
|
+
//# sourceMappingURL=test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/test-harness.ts"],"sourcesContent":["/**\n * sdk/test-harness — the SHIPPED, OFFLINE behavioral harness.\n *\n * Two read-only tools a connector author runs WITHOUT installing anything or\n * touching the host's filesystem:\n *\n * • `explain(connector)` — the static per-host × per-DECLARED-surface matrix:\n * for every registered host and every surface the connector actually ships,\n * is it `native` (the host can honor it), `disabled` (the connector opted\n * out for that host via `platforms[host].<surface> === false`), or\n * `skip-warn` (the host cannot honor it → install would skip-warn)?\n *\n * • `simulate(connector, opts)` — runs the REAL adapter parse → handler →\n * format chain INLINE against a host-shaped raw payload and reports whether\n * the host actually HONORS the connector's response (the trustworthy part:\n * it surfaces the documented degradations, e.g. Codex silently dropping a\n * UserPromptSubmit \"context\" injection that has no stdout path).\n *\n * It deliberately does NOT import the runtime entrypoints (runHook /\n * runStatusline) — those load the REGISTERED connector from disk and record\n * telemetry. The harness instead re-implements the tiny parse→handler→format\n * chain against the in-memory connector + the adapter, mirroring the runtime's\n * input tolerance (empty/malformed payload → `{}`) and its fail-safe envelope.\n */\n\nimport type {\n HookEventName,\n HookResponse,\n PlatformId,\n PlatformOverride,\n ResolvedConnector,\n} from \"../core/types.js\";\nimport { allAdapters, loadAdapter } from \"../adapters/registry.js\";\nimport type { NormalizedEvent } from \"../adapters/spi.js\";\nimport {\n compileMatcher,\n eventMatcherSubject,\n} from \"../runtime/hook-entrypoint.js\";\nimport type { SurfaceName } from \"./introspect.js\";\nimport { SURFACE_PREDICATES } from \"./introspect.js\";\n\n// ─────────────────────────────────────────────────────────────────────────\n// explain — the static per-host × per-declared-surface matrix\n// ─────────────────────────────────────────────────────────────────────────\n\n/** One cell of the {@link explain} matrix: a host × a declared surface. */\nexport interface ExplainRow {\n host: PlatformId;\n surface: SurfaceName;\n /**\n * - \"native\" — the host's capabilities pass the surface predicate.\n * - \"disabled\" — the connector opted out for this host\n * (`platforms[host].<surface> === false`).\n * - \"skip-warn\" — the host cannot honor it; install would skip-warn.\n */\n support: \"native\" | \"skip-warn\" | \"disabled\";\n reason: string;\n}\n\n/**\n * The GLOBAL surfaces a connector declares (these apply to every host — only\n * declared surfaces get a matrix row). The two platform-scoped surfaces\n * (`configPatch` / `nativeHooks`) are deliberately EXCLUDED here: they are\n * declared under one specific `platforms[host]`, so each is added PER HOST in\n * {@link explain} (see {@link platformScopedSurfacesFor}) — adding them globally\n * would falsely promise a configPatch row on hosts that never declared it.\n */\nfunction declaredGlobalSurfaces(connector: ResolvedConnector): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (connector.server) out.push(\"server\");\n if (Object.keys(connector.hooks).length > 0) out.push(\"hooks\");\n if (connector.commands.length > 0) out.push(\"commands\");\n if (connector.skills.length > 0) out.push(\"skills\");\n if (connector.subagents.length > 0) out.push(\"subagents\");\n if (connector.memory.length > 0) out.push(\"memory\");\n if (connector.statusline) out.push(\"statusline\");\n if (connector.actions.length > 0) out.push(\"actions\");\n return out;\n}\n\n/**\n * The platform-scoped surfaces (`configPatch` / `nativeHooks`) THIS host\n * actually declares — keyed off the host's own `platforms[host]` override, so a\n * configPatch declared under claude-code never shows up as a row for codex.\n */\nfunction platformScopedSurfacesFor(\n override: PlatformOverride | undefined,\n): SurfaceName[] {\n const out: SurfaceName[] = [];\n if (!override) return out;\n if ((override.configPatch?.length ?? 0) > 0) out.push(\"configPatch\");\n if (override.nativeHooks != null && Object.keys(override.nativeHooks).length > 0) {\n out.push(\"nativeHooks\");\n }\n return out;\n}\n\n/**\n * Is the surface explicitly DISABLED for this host? Mirrors the per-host opt-out\n * the installer honors: a boolean-or-object surface override is \"disabled\" only\n * when set to the literal `false` (the object form is a tuning, not an opt-out).\n * `configPatch` / `nativeHooks` have no boolean opt-out form — declaring them is\n * the opt-in, so they are never \"disabled\".\n */\nfunction isDisabledForHost(\n connector: ResolvedConnector,\n host: PlatformId,\n surface: SurfaceName,\n): boolean {\n const override = connector.platforms[host];\n if (!override) return false;\n switch (surface) {\n case \"server\":\n return override.server === false;\n case \"hooks\":\n return override.hooks === false;\n case \"commands\":\n return override.commands === false;\n case \"skills\":\n return override.skills === false;\n case \"subagents\":\n return override.subagents === false;\n case \"memory\":\n return override.memory === false;\n case \"statusline\":\n return override.statusline === false;\n case \"actions\":\n case \"configPatch\":\n case \"nativeHooks\":\n // No per-host boolean opt-out form (declaring them is the opt-in).\n return false;\n }\n}\n\n/**\n * The static support matrix: every registered host × every surface the\n * connector declares. Rows are sorted by host then surface for stable output.\n * Pure read of the adapter capabilities — installs nothing, writes nothing.\n */\nexport async function explain(connector: ResolvedConnector): Promise<ExplainRow[]> {\n const globalSurfaces = declaredGlobalSurfaces(connector);\n const adapters = await allAdapters();\n const rows: ExplainRow[] = [];\n\n for (const adapter of adapters) {\n // Per-host surface set = the global surfaces every host gets a row for, plus\n // the platform-scoped surfaces THIS host actually declares (configPatch /\n // nativeHooks live under platforms[host], so they are host-local).\n const override = connector.platforms[adapter.id];\n const surfaces = [\n ...globalSurfaces,\n ...platformScopedSurfacesFor(override),\n ];\n for (const surface of surfaces) {\n if (isDisabledForHost(connector, adapter.id, surface)) {\n rows.push({\n host: adapter.id,\n surface,\n support: \"disabled\",\n reason: `connector opted out for ${adapter.id} (platforms.${adapter.id}.${surface} = false)`,\n });\n continue;\n }\n const native = SURFACE_PREDICATES[surface](adapter.capabilities);\n rows.push({\n host: adapter.id,\n surface,\n support: native ? \"native\" : \"skip-warn\",\n reason: explainReason(adapter.id, surface, native),\n });\n }\n }\n\n rows.sort((a, b) =>\n a.host === b.host ? a.surface.localeCompare(b.surface) : a.host.localeCompare(b.host),\n );\n return rows;\n}\n\n/**\n * The human-readable reason for a native/skip-warn cell. `server` is a special\n * case: the predicate is CAPABILITY-based (the host advertises ≥1 MCP\n * transport), but advertising a transport does NOT guarantee a writable\n * registration — e.g. jetbrains-copilot advertises stdio yet its installServer\n * skip-warns because MCP is managed in IDE settings. So the server reason states\n * the verdict is capability-based and registration may be host-managed, rather\n * than promising a write. (A precise per-adapter installServer dry-run is a\n * Phase-2 enhancement — until then this avoids over-promising.)\n */\nfunction explainReason(host: PlatformId, surface: SurfaceName, native: boolean): string {\n if (surface === \"server\") {\n return native\n ? `${host} advertises an MCP transport (capability-based; registration may be host-managed)`\n : `${host} advertises no MCP transport; install skip-warns`;\n }\n return native\n ? `${host} natively supports ${surface}`\n : `${host} cannot honor ${surface}; install skip-warns`;\n}\n\n// ─────────────────────────────────────────────────────────────────────────\n// simulate — the real adapter parse → handler → format chain, inline\n// ─────────────────────────────────────────────────────────────────────────\n\n/** What to drive through the harness: one host, one surface, one raw payload. */\nexport interface SimulateOptions {\n surface: \"hooks\" | \"statusline\";\n host: PlatformId | string;\n /** REQUIRED when `surface === \"hooks\"`: which normalized lifecycle event. */\n event?: HookEventName;\n /** The host-shaped RAW payload (what the host would pipe in on stdin). */\n input: unknown;\n}\n\n/** The harness verdict: did the host actually honor the connector's response? */\nexport interface SimulateResult {\n /** True when the host's native reply carries the connector's intent. */\n honored: boolean;\n /** The host-native stdout the adapter would emit (when there is one). */\n hostReply?: string;\n /** Human-readable why — names the documented degradation when honored:false. */\n reason: string;\n}\n\n/**\n * Tolerantly coerce the raw payload, mirroring the runtime's parseStdin: a\n * string is JSON-parsed (empty/malformed → `{}`); a nullish value → `{}`; any\n * other value (already-parsed object) is passed through untouched.\n */\nfunction coerceInput(input: unknown): unknown {\n if (input == null) return {};\n if (typeof input === \"string\") {\n const trimmed = input.trim();\n if (trimmed === \"\") return {};\n try {\n return JSON.parse(trimmed);\n } catch {\n return {};\n }\n }\n return input;\n}\n\n/** Normalize a handler's return into a concrete response (void/non-object → `{}`). */\nfunction normalizeResponse(value: HookResponse | void): HookResponse {\n if (value == null || typeof value !== \"object\") return {};\n return value;\n}\n\n/**\n * The decoded shape of a host's native hook reply on stdout. Every json-stdio\n * adapter writes a SUBSET of these fields (claude-code / codex share the\n * `hookSpecificOutput` envelope; Stop-class continuation uses the TOP-LEVEL\n * `decision:\"block\"`). We read the DECODED fields — never substring-match the\n * serialized JSON, which a path/newline/quote in the payload would break.\n */\ninterface ParsedReply {\n /** Top-level Stop-class continuation: {\"decision\":\"block\",\"reason\"}. */\n decision?: unknown;\n reason?: unknown;\n /** Top-level Claude context channel (no adapter emits it yet; future-proofing). */\n systemMessage?: unknown;\n hookSpecificOutput?: {\n hookEventName?: unknown;\n additionalContext?: unknown;\n permissionDecision?: unknown;\n permissionDecisionReason?: unknown;\n updatedInput?: unknown;\n /** PermissionRequest nested envelope: decision:{behavior:\"allow\"|\"deny\", updatedInput?}. */\n decision?: { behavior?: unknown; updatedInput?: unknown };\n };\n}\n\n/**\n * Tolerantly decode a reply's stdout into {@link ParsedReply}. Empty / absent /\n * unparseable stdout is a legitimate \"no payload\" signal (the adapter wrote a\n * bare exit-0) → `undefined`, the honest \"this decision had no stdout path\"\n * verdict input.\n */\nfunction parseReplyStdout(stdout: string | undefined): ParsedReply | undefined {\n if (stdout == null || stdout.trim() === \"\") return undefined;\n try {\n const value = JSON.parse(stdout);\n return value != null && typeof value === \"object\"\n ? (value as ParsedReply)\n : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** Structural deep-equal for plain JSON values (objects/arrays/primitives). */\nfunction deepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true;\n if (typeof a !== typeof b || a == null || b == null) return false;\n if (typeof a !== \"object\") return false;\n const aArr = Array.isArray(a);\n if (aArr !== Array.isArray(b)) return false;\n if (aArr) {\n const x = a as unknown[];\n const y = b as unknown[];\n return x.length === y.length && x.every((v, i) => deepEqual(v, y[i]));\n }\n const x = a as Record<string, unknown>;\n const y = b as Record<string, unknown>;\n const xk = Object.keys(x);\n const yk = Object.keys(y);\n return xk.length === yk.length && xk.every((k) => deepEqual(x[k], y[k]));\n}\n\n/**\n * Decide whether the host HONORED a decision-bearing response, judging the\n * PARSED reply against each adapter's ACTUAL (event, decision) contract — never\n * by substring-matching the serialized JSON. `allow`/no-decision is always\n * pass-through honored; every other decision is honored only when the decoded\n * reply carries that exact intent, and the verdict names the documented\n * degradation when it does not.\n */\nfunction judgeHookHonor(\n host: string,\n event: HookEventName,\n response: HookResponse,\n stdout: string | undefined,\n): { honored: boolean; reason: string } {\n const decision = response.decision;\n if (decision === undefined || decision === \"allow\") {\n return { honored: true, reason: \"pass-through allow\" };\n }\n\n const reply = parseReplyStdout(stdout);\n const hso = reply?.hookSpecificOutput;\n\n if (decision === \"context\") {\n // Honored only when the DECODED additionalContext equals what the handler\n // asked to inject (claude-code's hookSpecificOutput.additionalContext, or a\n // future top-level systemMessage). codex only emits this on\n // SessionStart/PostToolUse — every other event silently drops it.\n const want = response.additionalContext;\n const got = hso?.additionalContext ?? reply?.systemMessage;\n if (reply && got === want) {\n return { honored: true, reason: `${host} injects context on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops context on ${event} (no stdout path)`,\n };\n }\n\n if (decision === \"deny\") {\n if (!reply) {\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n // A real block: PreToolUse's permissionDecision:\"deny\", or the\n // PermissionRequest nested decision.behavior:\"deny\".\n if (hso?.permissionDecision === \"deny\" || hso?.decision?.behavior === \"deny\") {\n return { honored: true, reason: `${host} blocks ${event}` };\n }\n // Stop-class continuation: top-level decision:\"block\" KEEPS the session /\n // subagent running (persistence) — the SEMANTIC OPPOSITE of a block. Honored\n // (the reply carried the intent), but the reason must not say \"blocks\".\n if (reply.decision === \"block\") {\n return {\n honored: true,\n reason: `${host} continues the session/subagent on ${event} (persistence) — NOT a block`,\n };\n }\n // SubagentStart / PostToolUseFailure DEGRADE a deny to a context note — the\n // spawn/failure is not actually blocked.\n if (hso?.additionalContext != null) {\n return {\n honored: false,\n reason: `${host} degrades deny to a context note on ${event}; spawn/failure not blocked`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops deny on ${event} (deny not honored; fails open to allow)`,\n };\n }\n\n if (decision === \"ask\") {\n if (hso?.permissionDecision === \"ask\") {\n return { honored: true, reason: `${host} asks on ${event}` };\n }\n // On PermissionRequest, ask/void falls through to the host's NATIVE dialog\n // (the dialog IS the ask), which the adapter expresses as a bare exit-0.\n if (event === \"PermissionRequest\" && !reply) {\n return {\n honored: true,\n reason: `${host} shows the native confirmation dialog on ${event} (the ask)`,\n };\n }\n return {\n honored: false,\n reason: `${host} drops ask on ${event} (no ask path)`,\n };\n }\n\n // decision === \"modify\": honored only when the decoded updatedInput deep-equals\n // what the handler asked to write (hookSpecificOutput.updatedInput, or the\n // PermissionRequest nested decision.updatedInput).\n const wrote = hso?.updatedInput ?? hso?.decision?.updatedInput;\n if (reply && wrote !== undefined && deepEqual(wrote, response.updatedInput)) {\n return { honored: true, reason: `${host} rewrites tool input on ${event}` };\n }\n return {\n honored: false,\n reason: `${host} drops modify on ${event} (modify not honored)`,\n };\n}\n\n/**\n * Run the connector against ONE host-shaped payload through the REAL adapter\n * path and report whether the host honors the response. Self-contained (does not\n * touch the registered-connector loader or telemetry) and fail-safe: any throw\n * in the chain degrades to `honored:false` with the error message, never rejects.\n */\nexport async function simulate(\n connector: ResolvedConnector,\n opts: SimulateOptions,\n): Promise<SimulateResult> {\n try {\n const adapter = await loadAdapter(opts.host);\n if (!adapter) {\n return { honored: false, reason: `unknown host \"${opts.host}\"` };\n }\n\n if (opts.surface === \"statusline\") {\n if (\n !(adapter.capabilities.supportsStatusline ?? false) ||\n !adapter.parseStatusInput ||\n !adapter.formatStatusOutput\n ) {\n return { honored: false, reason: `${opts.host} has no statusline surface` };\n }\n // Guarding on the TOP-LEVEL render is sufficient: a `hosts`-only statusline\n // (a hosts: map with no top-level render) is rejected at defineConnector, so\n // a connector that targets `opts.host` only via hosts[] still has a top-level\n // render here. (If that author-time invariant ever relaxes, revisit this.)\n if (!connector.statusline || typeof connector.statusline.render !== \"function\") {\n return { honored: false, reason: \"connector declares no statusline\" };\n }\n const ctx = adapter.parseStatusInput(coerceInput(opts.input));\n ctx.connectorId = connector.id;\n // Defensive: parseStatusInput now sets ctx.capabilities (it is required on\n // StatuslineContext), but a future adapter could omit it — backfill from\n // the adapter so render() can always read ctx.capabilities.\n if (ctx.capabilities == null) ctx.capabilities = adapter.capabilities;\n // Per-host render override, mirroring the runtime: hosts[host].render wins\n // over the top-level render; an unlisted host falls back to top-level.\n const perHost = connector.statusline.hosts?.[opts.host as PlatformId]?.render;\n const render =\n typeof perHost === \"function\" ? perHost : connector.statusline.render;\n const rendered = await render(ctx);\n const line = rendered == null ? \"\" : String(rendered);\n const reply = adapter.formatStatusOutput(line);\n return {\n honored: true,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: \"rendered\",\n };\n }\n\n // surface === \"hooks\"\n const event = opts.event;\n if (!event) {\n return { honored: false, reason: \"event is required when surface === \\\"hooks\\\"\" };\n }\n if (!adapter.parseEvent || !adapter.formatReply) {\n return { honored: false, reason: `${opts.host} has no hook runtime (mcp-only)` };\n }\n\n const evt = adapter.parseEvent(event, coerceInput(opts.input));\n evt.connectorId = connector.id;\n // Mirror the runtime: runHook backfills evt.capabilities from the adapter so\n // a handler reading evt.capabilities behaves the same here. (scope/telemetry\n // are runtime-only — recovered from the registered meta / store, which the\n // offline harness deliberately never touches — so they stay undefined.)\n evt.capabilities = adapter.capabilities;\n\n // Guarding on the TOP-LEVEL handler is sufficient: a `hosts`-only hook (a\n // hosts: map with no top-level handler) is rejected at defineConnector, so a\n // host targeted only via hosts[] still has a top-level handler here. (If that\n // author-time invariant ever relaxes, revisit this.)\n const definition = connector.hooks[event];\n if (!definition || typeof definition.handler !== \"function\") {\n return { honored: false, reason: `connector declares no ${event} handler` };\n }\n\n // Matcher filtering, in lockstep with runHook: when the connector's matcher\n // is set and the event's subject (tool name, or agent type for Subagent*\n // events) does not match, the host never runs the handler — so the harness\n // must NOT run it either, and reports the (honored) exclusion. Reuses the\n // runtime helpers directly so the two stay byte-for-byte aligned.\n const subject = eventMatcherSubject(evt as NormalizedEvent);\n if (subject !== undefined) {\n const re = compileMatcher(definition.matcher);\n if (re && !re.test(subject)) {\n return {\n honored: true,\n reason: `matcher excludes ${subject} (handler not run)`,\n };\n }\n }\n\n // Per-host handler override, mirroring runHook: hosts[host].handler wins\n // over the top-level handler; an unlisted host falls back to top-level.\n const perHost = definition.hosts?.[opts.host as PlatformId]?.handler;\n const handler = typeof perHost === \"function\" ? perHost : definition.handler;\n const response = normalizeResponse(\n await handler(evt as never),\n );\n const reply = adapter.formatReply(event, response);\n const verdict = judgeHookHonor(String(opts.host), event, response, reply.stdout);\n return {\n honored: verdict.honored,\n ...(reply.stdout !== undefined ? { hostReply: reply.stdout } : {}),\n reason: verdict.reason,\n };\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n const verb = opts.surface === \"statusline\" ? \"render\" : \"handler\";\n return { honored: false, reason: `${verb} threw: ${message}` };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmEA,SAAS,uBAAuB,WAA6C;AAC3E,QAAM,MAAqB,CAAC;AAC5B,MAAI,UAAU,OAAQ,KAAI,KAAK,QAAQ;AACvC,MAAI,OAAO,KAAK,UAAU,KAAK,EAAE,SAAS,EAAG,KAAI,KAAK,OAAO;AAC7D,MAAI,UAAU,SAAS,SAAS,EAAG,KAAI,KAAK,UAAU;AACtD,MAAI,UAAU,OAAO,SAAS,EAAG,KAAI,K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AAU,OAAO,GAAG;AAC/D,UAAM,OAAO,KAAK,YAAY,eAAe,WAAW;AACxD,WAAO,EAAE,SAAS,OAAO,QAAQ,GAAG,IAAI,WAAW,OAAO,GAAG;AAAA,EAC/D;AACF;","names":["x","y","perHost","reply"]}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
fail
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-KGXDYGNJ.js";
|
|
5
5
|
import {
|
|
6
6
|
runServe
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-BCHWFTV4.js";
|
|
7
|
+
} from "./chunk-BHUCB6LY.js";
|
|
9
8
|
import "./chunk-OP4KBXUO.js";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-22Y24V7O.js";
|
|
10
|
+
import "./chunk-J3D5W5T2.js";
|
|
11
|
+
import "./chunk-CIRDOY2V.js";
|
|
12
|
+
import "./chunk-BCHWFTV4.js";
|
|
13
|
+
import "./chunk-KHO5WNTP.js";
|
|
14
|
+
import "./chunk-KGJWE6A2.js";
|
|
15
|
+
import "./chunk-ADTHT2FN.js";
|
|
16
|
+
import "./chunk-3PFFTFCU.js";
|
|
17
|
+
import "./chunk-BXGFUENQ.js";
|
|
15
18
|
import "./chunk-N6HH7K6P.js";
|
|
16
19
|
import "./chunk-TRQKHP7D.js";
|
|
17
20
|
|
|
@@ -63,4 +66,4 @@ async function run(argv) {
|
|
|
63
66
|
export {
|
|
64
67
|
run
|
|
65
68
|
};
|
|
66
|
-
//# sourceMappingURL=serve-
|
|
69
|
+
//# sourceMappingURL=serve-D3GO36UT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/commands/serve.ts"],"sourcesContent":["/**\n * cli/commands/serve — the telemetry-wrapping MCP stdio proxy entrypoint.\n *\n * agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <realCommand> <realArgs...>\n *\n * A stdio MCP server that opts into transparent telemetry has its host config\n * rewritten to launch THIS instead of the server directly. We split argv at the\n * literal `--` separator: flags on the left, the real server command + args on\n * the right (taken verbatim). The optional `--scope` flag records the install\n * dimension (global user vs project-local) onto telemetry; it is absent for\n * configs written before scope plumbing existed → the runtime reads \"unknown\".\n * The optional `--host` flag carries the install TARGET platform id so the proxy\n * stamps hostPlatform correctly under a headless spawn; absent configs fall back\n * to runtime env detection.\n * runServe stands up the per-session telemetry context and proxies bytes both\n * ways, resolving with the child's exit code.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport type { PlatformId } from \"../../core/types.js\";\nimport type { TelemetryInstallScope } from \"../../telemetry/types.js\";\nimport { runServe } from \"../../runtime/index.js\";\nimport { fail } from \"../app.js\";\n\nexport async function run(argv: string[]): Promise<number> {\n // Split at the FIRST literal \"--\": everything after it is the real server\n // invocation and must be passed through verbatim (never re-parsed as flags).\n const sepIndex = argv.indexOf(\"--\");\n if (sepIndex === -1) {\n return fail(\n \"usage: agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <command> [args...]\",\n );\n }\n const flagArgs = argv.slice(0, sepIndex);\n const serverInvocation = argv.slice(sepIndex + 1);\n\n // strict:false so an unknown FUTURE flag before `--` (written by a newer host\n // config) is ignored instead of throwing — a parse throw here would prevent the\n // real MCP server from ever spawning and wedge the host's tool call. We only\n // read the two flags we understand; everything else is tolerated.\n const { values } = parseArgs({\n args: flagArgs,\n options: {\n connector: { type: \"string\" },\n scope: { type: \"string\" },\n // `--host <platformId>` bakes the install TARGET platform into the wrapper\n // so the proxy stamps hostPlatform correctly under a headless spawn (where\n // runtime env markers are absent). Optional + tolerated (strict:false).\n host: { type: \"string\" },\n },\n allowPositionals: true,\n strict: false,\n });\n\n // With strict:false, parseArgs types each value as string | boolean; we only\n // accept the string form (a bare `--connector` flag with no value is invalid).\n const connectorId = typeof values.connector === \"string\" ? values.connector : undefined;\n if (!connectorId || connectorId.trim() === \"\") {\n return fail(\"serve requires --connector <id>\");\n }\n\n // `--scope` is optional and only ever \"user\" | \"project\" (the wrapper emits\n // exactly those). An unrecognized value is ignored rather than fatal so a\n // future/older wrapper can never break a real tool call over a flag mismatch.\n const rawScope = values.scope;\n const installScope: TelemetryInstallScope | undefined =\n rawScope === \"user\" || rawScope === \"project\" ? rawScope : undefined;\n\n // `--host` carries the install TARGET platform id (string only). runServe\n // validates it against the registry and falls back to runtime detection when\n // it is absent or unrecognized — so a future/older wrapper never breaks here.\n const hostPlatformOverride =\n typeof values.host === \"string\" ? (values.host as PlatformId) : undefined;\n\n const serverCommand = serverInvocation[0];\n if (!serverCommand) {\n return fail(\"serve requires a command after `--`\");\n }\n const serverArgs = serverInvocation.slice(1);\n\n const code = await runServe({\n connectorId,\n serverCommand,\n serverArgs,\n installScope,\n hostPlatformOverride,\n });\n process.exit(code);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/serve.ts"],"sourcesContent":["/**\n * cli/commands/serve — the telemetry-wrapping MCP stdio proxy entrypoint.\n *\n * agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <realCommand> <realArgs...>\n *\n * A stdio MCP server that opts into transparent telemetry has its host config\n * rewritten to launch THIS instead of the server directly. We split argv at the\n * literal `--` separator: flags on the left, the real server command + args on\n * the right (taken verbatim). The optional `--scope` flag records the install\n * dimension (global user vs project-local) onto telemetry; it is absent for\n * configs written before scope plumbing existed → the runtime reads \"unknown\".\n * The optional `--host` flag carries the install TARGET platform id so the proxy\n * stamps hostPlatform correctly under a headless spawn; absent configs fall back\n * to runtime env detection.\n * runServe stands up the per-session telemetry context and proxies bytes both\n * ways, resolving with the child's exit code.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport type { PlatformId } from \"../../core/types.js\";\nimport type { TelemetryInstallScope } from \"../../telemetry/types.js\";\nimport { runServe } from \"../../runtime/index.js\";\nimport { fail } from \"../app.js\";\n\nexport async function run(argv: string[]): Promise<number> {\n // Split at the FIRST literal \"--\": everything after it is the real server\n // invocation and must be passed through verbatim (never re-parsed as flags).\n const sepIndex = argv.indexOf(\"--\");\n if (sepIndex === -1) {\n return fail(\n \"usage: agent-connector serve --connector <id> [--scope <user|project>] [--host <platformId>] -- <command> [args...]\",\n );\n }\n const flagArgs = argv.slice(0, sepIndex);\n const serverInvocation = argv.slice(sepIndex + 1);\n\n // strict:false so an unknown FUTURE flag before `--` (written by a newer host\n // config) is ignored instead of throwing — a parse throw here would prevent the\n // real MCP server from ever spawning and wedge the host's tool call. We only\n // read the two flags we understand; everything else is tolerated.\n const { values } = parseArgs({\n args: flagArgs,\n options: {\n connector: { type: \"string\" },\n scope: { type: \"string\" },\n // `--host <platformId>` bakes the install TARGET platform into the wrapper\n // so the proxy stamps hostPlatform correctly under a headless spawn (where\n // runtime env markers are absent). Optional + tolerated (strict:false).\n host: { type: \"string\" },\n },\n allowPositionals: true,\n strict: false,\n });\n\n // With strict:false, parseArgs types each value as string | boolean; we only\n // accept the string form (a bare `--connector` flag with no value is invalid).\n const connectorId = typeof values.connector === \"string\" ? values.connector : undefined;\n if (!connectorId || connectorId.trim() === \"\") {\n return fail(\"serve requires --connector <id>\");\n }\n\n // `--scope` is optional and only ever \"user\" | \"project\" (the wrapper emits\n // exactly those). An unrecognized value is ignored rather than fatal so a\n // future/older wrapper can never break a real tool call over a flag mismatch.\n const rawScope = values.scope;\n const installScope: TelemetryInstallScope | undefined =\n rawScope === \"user\" || rawScope === \"project\" ? rawScope : undefined;\n\n // `--host` carries the install TARGET platform id (string only). runServe\n // validates it against the registry and falls back to runtime detection when\n // it is absent or unrecognized — so a future/older wrapper never breaks here.\n const hostPlatformOverride =\n typeof values.host === \"string\" ? (values.host as PlatformId) : undefined;\n\n const serverCommand = serverInvocation[0];\n if (!serverCommand) {\n return fail(\"serve requires a command after `--`\");\n }\n const serverArgs = serverInvocation.slice(1);\n\n const code = await runServe({\n connectorId,\n serverCommand,\n serverArgs,\n installScope,\n hostPlatformOverride,\n });\n process.exit(code);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,iBAAiB;AAO1B,eAAsB,IAAI,MAAiC;AAGzD,QAAM,WAAW,KAAK,QAAQ,IAAI;AAClC,MAAI,aAAa,IAAI;AACnB,WAAO;AAAA,MACL;AAAA,IACF;AAAA,EACF;AACA,QAAM,WAAW,KAAK,MAAM,GAAG,QAAQ;AACvC,QAAM,mBAAmB,KAAK,MAAM,WAAW,CAAC;AAMhD,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,WAAW,EAAE,MAAM,SAAS;AAAA,MAC5B,OAAO,EAAE,MAAM,SAAS;AAAA;AAAA;AAAA;AAAA,MAIxB,MAAM,EAAE,MAAM,SAAS;AAAA,IACzB;AAAA,IACA,kBAAkB;AAAA,IAClB,QAAQ;AAAA,EACV,CAAC;AAID,QAAM,cAAc,OAAO,OAAO,cAAc,WAAW,OAAO,YAAY;AAC9E,MAAI,CAAC,eAAe,YAAY,KAAK,MAAM,IAAI;AAC7C,WAAO,KAAK,iCAAiC;AAAA,EAC/C;AAKA,QAAM,WAAW,OAAO;AACxB,QAAM,eACJ,aAAa,UAAU,aAAa,YAAY,WAAW;AAK7D,QAAM,uBACJ,OAAO,OAAO,SAAS,WAAY,OAAO,OAAsB;AAElE,QAAM,gBAAgB,iBAAiB,CAAC;AACxC,MAAI,CAAC,eAAe;AAClB,WAAO,KAAK,qCAAqC;AAAA,EACnD;AACA,QAAM,aAAa,iBAAiB,MAAM,CAAC;AAE3C,QAAM,OAAO,MAAM,SAAS;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AACD,UAAQ,KAAK,IAAI;AACnB;","names":[]}
|
|
@@ -6,17 +6,19 @@ import {
|
|
|
6
6
|
fail,
|
|
7
7
|
parseScope,
|
|
8
8
|
print
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KGXDYGNJ.js";
|
|
10
10
|
import {
|
|
11
|
-
detectInstalledPlatforms
|
|
12
|
-
|
|
13
|
-
} from "./chunk-NJU275US.js";
|
|
11
|
+
detectInstalledPlatforms
|
|
12
|
+
} from "./chunk-J3D5W5T2.js";
|
|
14
13
|
import {
|
|
15
14
|
findConnectorConfig,
|
|
16
15
|
listRegisteredConnectors,
|
|
17
16
|
loadConnectorFromPath
|
|
18
|
-
} from "./chunk-
|
|
19
|
-
import "./chunk-
|
|
17
|
+
} from "./chunk-KGJWE6A2.js";
|
|
18
|
+
import "./chunk-ADTHT2FN.js";
|
|
19
|
+
import {
|
|
20
|
+
loadAdapter
|
|
21
|
+
} from "./chunk-3PFFTFCU.js";
|
|
20
22
|
import "./chunk-N6HH7K6P.js";
|
|
21
23
|
import {
|
|
22
24
|
dataRoot,
|
|
@@ -135,4 +137,4 @@ async function run(argv) {
|
|
|
135
137
|
export {
|
|
136
138
|
run
|
|
137
139
|
};
|
|
138
|
-
//# sourceMappingURL=status-
|
|
140
|
+
//# sourceMappingURL=status-KOSKCETC.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli/commands/status.ts"],"sourcesContent":["/**\n * cli/commands/status — a light, glanceable install-state summary.\n *\n * There is NO MCP standard for \"which connectors are installed into which host\n * configs on this machine\" — distribution/wire standards (server.json, MCPB,\n * the lifecycle) cover publishing + the protocol, not local install state. So\n * `status` is purely agent-connector infrastructure, and we design it for the\n * everyday question it answers in one line per platform:\n *\n * \"which of my connectors are present on which hosts?\"\n *\n * It REUSES detect (host enumeration) + the adapters' own config-path resolvers\n * (a read-only presence check) — NO new adapter SPI methods. Unlike `doctor`\n * (deep health checks, non-zero exit on failure) and `doctor --probe` (a live\n * protocol probe that FAILs on a dead server), `status` ALWAYS exits 0: it\n * describes, it never gates. A connector being absent is informational.\n */\n\nimport { parseArgs } from \"node:util\";\nimport { readFileSync } from \"node:fs\";\n\nimport type { InstallScope, PlatformId, ResolvedConnector } from \"../../core/types.js\";\nimport type { InstallContext } from \"../../adapters/spi.js\";\nimport { detectInstalledPlatforms } from \"../../adapters/detect.js\";\nimport { loadAdapter } from \"../../adapters/registry.js\";\nimport {\n findConnectorConfig,\n listRegisteredConnectors,\n loadConnectorFromPath,\n} from \"../../core/load-connector.js\";\nimport { marketplaceEvidence } from \"../../core/marketplace-state.js\";\nimport { dataRoot, homeBinPath } from \"../../core/paths.js\";\nimport { fail, parseScope, print } from \"../app.js\";\n\n/**\n * Resolve which connector(s) status reports on: an explicit --connector path or\n * a local config first, else every connector registered under the data-root\n * (what is actually installed). Empty array when none — status still lists the\n * detected platforms.\n */\nasync function resolveConnectors(\n connectorPath: string | undefined,\n projectDir: string,\n): Promise<ResolvedConnector[]> {\n const configPath = connectorPath ?? findConnectorConfig(projectDir);\n if (configPath) {\n try {\n const { connector } = await loadConnectorFromPath(configPath);\n return [connector];\n } catch {\n /* fall through to the registry */\n }\n }\n return listRegisteredConnectors();\n}\n\nfunction buildContext(\n connector: ResolvedConnector,\n id: PlatformId,\n scope: InstallScope,\n projectDir: string,\n): InstallContext {\n return {\n connector,\n scope: connector.platforms[id]?.scope ?? scope,\n projectDir,\n homeBinPath: homeBinPath(),\n dataRoot: dataRoot(),\n dryRun: true,\n };\n}\n\n/** Read-only: does the file at `path` mention `needle`? Missing/unreadable → false. */\nfunction fileMentions(path: string, needle: string): boolean {\n try {\n return readFileSync(path, \"utf8\").includes(needle);\n } catch {\n return false;\n }\n}\n\ninterface ConnStatus {\n id: string;\n serverPresent: boolean;\n hooksPresent: boolean;\n /**\n * Delivery method actually present on this host: `direct` (managed entries in\n * the host config), `marketplace` (the host's own plugin state / our install\n * record), `both` (the double-install invariant is VIOLATED — doctor FAILs\n * it), or null when absent.\n */\n method: \"direct\" | \"marketplace\" | \"both\" | null;\n}\ninterface StatusRow {\n platform: PlatformId;\n scope: InstallScope;\n configPath: string;\n connectors: ConnStatus[];\n}\n\nexport async function run(argv: string[]): Promise<number> {\n const { values } = parseArgs({\n args: argv,\n options: {\n scope: { type: \"string\", default: \"user\" },\n connector: { type: \"string\" },\n project: { type: \"string\" },\n json: { type: \"boolean\", default: false },\n },\n allowPositionals: false,\n });\n\n const projectDir = values.project ?? process.cwd();\n const scope = parseScope(values.scope);\n if (scope == null) return fail(`invalid --scope \"${values.scope}\" (use user|project)`);\n\n const connectors = await resolveConnectors(values.connector, projectDir);\n const detected = await detectInstalledPlatforms(projectDir);\n\n const rows: StatusRow[] = [];\n for (const p of detected) {\n const adapter = await loadAdapter(p.id);\n if (!adapter) continue;\n const connStatuses: ConnStatus[] = connectors.map((connector) => {\n const ctx = buildContext(connector, p.id, scope, projectDir);\n let serverPath = \"\";\n let hookPath = \"\";\n try {\n serverPath = adapter.getServerConfigPath(ctx);\n } catch {\n /* adapter has no server config path */\n }\n try {\n hookPath = adapter.getHookConfigPath(ctx);\n } catch {\n /* adapter has no hook config path */\n }\n const serverPresent = serverPath\n ? fileMentions(serverPath, connector.id)\n : false;\n const hooksPresent = hookPath ? fileMentions(hookPath, connector.id) : false;\n const direct = serverPresent || hooksPresent;\n const viaMarketplace = marketplaceEvidence(connector.id, p.id) != null;\n return {\n id: connector.id,\n serverPresent,\n hooksPresent,\n method: direct && viaMarketplace\n ? (\"both\" as const)\n : direct\n ? (\"direct\" as const)\n : viaMarketplace\n ? (\"marketplace\" as const)\n : null,\n };\n });\n rows.push({\n platform: p.id,\n scope: p.scope,\n configPath: p.configPath,\n connectors: connStatuses,\n });\n }\n\n if (values.json) {\n print(JSON.stringify(rows, null, 2));\n return 0;\n }\n\n if (rows.length === 0) {\n print(\"status: no agent platforms detected.\");\n return 0;\n }\n if (connectors.length === 0) {\n print(\"status: no connectors found (pass --connector <path> or install one).\\n\");\n }\n\n for (const r of rows) {\n print(`${r.platform} [${r.scope}] ${r.configPath}`);\n if (r.connectors.length === 0) {\n print(\" (no connectors to check)\");\n } else {\n for (const c of r.connectors) {\n const mark = c.method != null ? \"[installed]\" : \"[absent ]\";\n const server = c.serverPresent ? \"server ✓\" : \"server ·\";\n const hooks = c.hooksPresent ? \"hooks ✓\" : \"hooks ·\";\n // `both(!)` flags a violated one-method-per-host invariant — doctor's\n // duplicate-registration check FAILs it with the fix.\n const method =\n c.method == null ? \"\" : c.method === \"both\" ? \" (both!)\" : ` (${c.method})`;\n print(` ${mark} ${c.id} ${server} ${hooks}${method}`);\n }\n }\n print(\"\");\n }\n\n // Always 0: status is descriptive (what is installed where), never a gate —\n // that contrast with doctor (non-zero on FAIL) is the reason it exists.\n return 0;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/status.ts"],"sourcesContent":["/**\n * cli/commands/status — a light, glanceable install-state summary.\n *\n * There is NO MCP standard for \"which connectors are installed into which host\n * configs on this machine\" — distribution/wire standards (server.json, MCPB,\n * the lifecycle) cover publishing + the protocol, not local install state. So\n * `status` is purely agent-connector infrastructure, and we design it for the\n * everyday question it answers in one line per platform:\n *\n * \"which of my connectors are present on which hosts?\"\n *\n * It REUSES detect (host enumeration) + the adapters' own config-path resolvers\n * (a read-only presence check) — NO new adapter SPI methods. Unlike `doctor`\n * (deep health checks, non-zero exit on failure) and `doctor --probe` (a live\n * protocol probe that FAILs on a dead server), `status` ALWAYS exits 0: it\n * describes, it never gates. A connector being absent is informational.\n */\n\nimport { parseArgs } from \"node:util\";\nimport { readFileSync } from \"node:fs\";\n\nimport type { InstallScope, PlatformId, ResolvedConnector } from \"../../core/types.js\";\nimport type { InstallContext } from \"../../adapters/spi.js\";\nimport { detectInstalledPlatforms } from \"../../adapters/detect.js\";\nimport { loadAdapter } from \"../../adapters/registry.js\";\nimport {\n findConnectorConfig,\n listRegisteredConnectors,\n loadConnectorFromPath,\n} from \"../../core/load-connector.js\";\nimport { marketplaceEvidence } from \"../../core/marketplace-state.js\";\nimport { dataRoot, homeBinPath } from \"../../core/paths.js\";\nimport { fail, parseScope, print } from \"../app.js\";\n\n/**\n * Resolve which connector(s) status reports on: an explicit --connector path or\n * a local config first, else every connector registered under the data-root\n * (what is actually installed). Empty array when none — status still lists the\n * detected platforms.\n */\nasync function resolveConnectors(\n connectorPath: string | undefined,\n projectDir: string,\n): Promise<ResolvedConnector[]> {\n const configPath = connectorPath ?? findConnectorConfig(projectDir);\n if (configPath) {\n try {\n const { connector } = await loadConnectorFromPath(configPath);\n return [connector];\n } catch {\n /* fall through to the registry */\n }\n }\n return listRegisteredConnectors();\n}\n\nfunction buildContext(\n connector: ResolvedConnector,\n id: PlatformId,\n scope: InstallScope,\n projectDir: string,\n): InstallContext {\n return {\n connector,\n scope: connector.platforms[id]?.scope ?? scope,\n projectDir,\n homeBinPath: homeBinPath(),\n dataRoot: dataRoot(),\n dryRun: true,\n };\n}\n\n/** Read-only: does the file at `path` mention `needle`? Missing/unreadable → false. */\nfunction fileMentions(path: string, needle: string): boolean {\n try {\n return readFileSync(path, \"utf8\").includes(needle);\n } catch {\n return false;\n }\n}\n\ninterface ConnStatus {\n id: string;\n serverPresent: boolean;\n hooksPresent: boolean;\n /**\n * Delivery method actually present on this host: `direct` (managed entries in\n * the host config), `marketplace` (the host's own plugin state / our install\n * record), `both` (the double-install invariant is VIOLATED — doctor FAILs\n * it), or null when absent.\n */\n method: \"direct\" | \"marketplace\" | \"both\" | null;\n}\ninterface StatusRow {\n platform: PlatformId;\n scope: InstallScope;\n configPath: string;\n connectors: ConnStatus[];\n}\n\nexport async function run(argv: string[]): Promise<number> {\n const { values } = parseArgs({\n args: argv,\n options: {\n scope: { type: \"string\", default: \"user\" },\n connector: { type: \"string\" },\n project: { type: \"string\" },\n json: { type: \"boolean\", default: false },\n },\n allowPositionals: false,\n });\n\n const projectDir = values.project ?? process.cwd();\n const scope = parseScope(values.scope);\n if (scope == null) return fail(`invalid --scope \"${values.scope}\" (use user|project)`);\n\n const connectors = await resolveConnectors(values.connector, projectDir);\n const detected = await detectInstalledPlatforms(projectDir);\n\n const rows: StatusRow[] = [];\n for (const p of detected) {\n const adapter = await loadAdapter(p.id);\n if (!adapter) continue;\n const connStatuses: ConnStatus[] = connectors.map((connector) => {\n const ctx = buildContext(connector, p.id, scope, projectDir);\n let serverPath = \"\";\n let hookPath = \"\";\n try {\n serverPath = adapter.getServerConfigPath(ctx);\n } catch {\n /* adapter has no server config path */\n }\n try {\n hookPath = adapter.getHookConfigPath(ctx);\n } catch {\n /* adapter has no hook config path */\n }\n const serverPresent = serverPath\n ? fileMentions(serverPath, connector.id)\n : false;\n const hooksPresent = hookPath ? fileMentions(hookPath, connector.id) : false;\n const direct = serverPresent || hooksPresent;\n const viaMarketplace = marketplaceEvidence(connector.id, p.id) != null;\n return {\n id: connector.id,\n serverPresent,\n hooksPresent,\n method: direct && viaMarketplace\n ? (\"both\" as const)\n : direct\n ? (\"direct\" as const)\n : viaMarketplace\n ? (\"marketplace\" as const)\n : null,\n };\n });\n rows.push({\n platform: p.id,\n scope: p.scope,\n configPath: p.configPath,\n connectors: connStatuses,\n });\n }\n\n if (values.json) {\n print(JSON.stringify(rows, null, 2));\n return 0;\n }\n\n if (rows.length === 0) {\n print(\"status: no agent platforms detected.\");\n return 0;\n }\n if (connectors.length === 0) {\n print(\"status: no connectors found (pass --connector <path> or install one).\\n\");\n }\n\n for (const r of rows) {\n print(`${r.platform} [${r.scope}] ${r.configPath}`);\n if (r.connectors.length === 0) {\n print(\" (no connectors to check)\");\n } else {\n for (const c of r.connectors) {\n const mark = c.method != null ? \"[installed]\" : \"[absent ]\";\n const server = c.serverPresent ? \"server ✓\" : \"server ·\";\n const hooks = c.hooksPresent ? \"hooks ✓\" : \"hooks ·\";\n // `both(!)` flags a violated one-method-per-host invariant — doctor's\n // duplicate-registration check FAILs it with the fix.\n const method =\n c.method == null ? \"\" : c.method === \"both\" ? \" (both!)\" : ` (${c.method})`;\n print(` ${mark} ${c.id} ${server} ${hooks}${method}`);\n }\n }\n print(\"\");\n }\n\n // Always 0: status is descriptive (what is installed where), never a gate —\n // that contrast with doctor (non-zero on FAIL) is the reason it exists.\n return 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAqB7B,eAAe,kBACb,eACA,YAC8B;AAC9B,QAAM,aAAa,iBAAiB,oBAAoB,UAAU;AAClE,MAAI,YAAY;AACd,QAAI;AACF,YAAM,EAAE,UAAU,IAAI,MAAM,sBAAsB,UAAU;AAC5D,aAAO,CAAC,SAAS;AAAA,IACnB,QAAQ;AAAA,IAER;AAAA,EACF;AACA,SAAO,yBAAyB;AAClC;AAEA,SAAS,aACP,WACA,IACA,OACA,YACgB;AAChB,SAAO;AAAA,IACL;AAAA,IACA,OAAO,UAAU,UAAU,EAAE,GAAG,SAAS;AAAA,IACzC;AAAA,IACA,aAAa,YAAY;AAAA,IACzB,UAAU,SAAS;AAAA,IACnB,QAAQ;AAAA,EACV;AACF;AAGA,SAAS,aAAa,MAAc,QAAyB;AAC3D,MAAI;AACF,WAAO,aAAa,MAAM,MAAM,EAAE,SAAS,MAAM;AAAA,EACnD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAqBA,eAAsB,IAAI,MAAiC;AACzD,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,OAAO,EAAE,MAAM,UAAU,SAAS,OAAO;AAAA,MACzC,WAAW,EAAE,MAAM,SAAS;AAAA,MAC5B,SAAS,EAAE,MAAM,SAAS;AAAA,MAC1B,MAAM,EAAE,MAAM,WAAW,SAAS,MAAM;AAAA,IAC1C;AAAA,IACA,kBAAkB;AAAA,EACpB,CAAC;AAED,QAAM,aAAa,OAAO,WAAW,QAAQ,IAAI;AACjD,QAAM,QAAQ,WAAW,OAAO,KAAK;AACrC,MAAI,SAAS,KAAM,QAAO,KAAK,oBAAoB,OAAO,KAAK,sBAAsB;AAErF,QAAM,aAAa,MAAM,kBAAk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K,MAAM,EAAE,UAAU,EAAE;AACpD,QAAI,EAAE,WAAW,WAAW,GAAG;AAC7B,YAAM,4BAA4B;AAAA,IACpC,OAAO;AACL,iBAAW,KAAK,EAAE,YAAY;AAC5B,cAAM,OAAO,EAAE,UAAU,OAAO,gBAAgB;AAChD,cAAM,SAAS,EAAE,gBAAgB,kBAAa;AAC9C,cAAM,QAAQ,EAAE,eAAe,iBAAY;AAG3C,cAAM,SACJ,EAAE,UAAU,OAAO,KAAK,EAAE,WAAW,SAAS,cAAc,MAAM,EAAE,MAAM;AAC5E,cAAM,KAAK,IAAI,IAAI,EAAE,EAAE,KAAK,MAAM,KAAK,KAAK,GAAG,MAAM,EAAE;AAAA,MACzD;AAAA,IACF;AACA,UAAM,EAAE;AAAA,EACV;AAIA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
runStatusline
|
|
4
|
+
} from "./chunk-BHUCB6LY.js";
|
|
5
|
+
import "./chunk-OP4KBXUO.js";
|
|
6
|
+
import "./chunk-22Y24V7O.js";
|
|
7
|
+
import "./chunk-J3D5W5T2.js";
|
|
8
|
+
import "./chunk-CIRDOY2V.js";
|
|
9
|
+
import "./chunk-BCHWFTV4.js";
|
|
10
|
+
import "./chunk-KHO5WNTP.js";
|
|
11
|
+
import "./chunk-KGJWE6A2.js";
|
|
12
|
+
import "./chunk-ADTHT2FN.js";
|
|
13
|
+
import "./chunk-3PFFTFCU.js";
|
|
14
|
+
import "./chunk-BXGFUENQ.js";
|
|
15
|
+
import "./chunk-N6HH7K6P.js";
|
|
16
|
+
import "./chunk-TRQKHP7D.js";
|
|
17
|
+
|
|
18
|
+
// src/cli/commands/statusline.ts
|
|
19
|
+
import { parseArgs } from "util";
|
|
20
|
+
async function readAll(stream) {
|
|
21
|
+
const chunks = [];
|
|
22
|
+
for await (const chunk of stream) {
|
|
23
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
24
|
+
}
|
|
25
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
26
|
+
}
|
|
27
|
+
async function run(argv) {
|
|
28
|
+
let platformId = "";
|
|
29
|
+
let connectorId = "";
|
|
30
|
+
try {
|
|
31
|
+
const { values, positionals } = parseArgs({
|
|
32
|
+
args: argv,
|
|
33
|
+
options: { connector: { type: "string" } },
|
|
34
|
+
allowPositionals: true,
|
|
35
|
+
strict: false
|
|
36
|
+
});
|
|
37
|
+
platformId = positionals[0] ?? "";
|
|
38
|
+
connectorId = typeof values.connector === "string" ? values.connector : "";
|
|
39
|
+
} catch {
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
const stdin = await readAll(process.stdin).catch(() => "");
|
|
43
|
+
if (platformId === "" || connectorId === "") {
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
const reply = await runStatusline({ platformId, connectorId, stdin });
|
|
47
|
+
if (reply.stdout !== void 0 && reply.stdout !== "") {
|
|
48
|
+
process.stdout.write(reply.stdout);
|
|
49
|
+
}
|
|
50
|
+
if (reply.stderr !== void 0 && reply.stderr !== "") {
|
|
51
|
+
process.stderr.write(reply.stderr.endsWith("\n") ? reply.stderr : `${reply.stderr}
|
|
52
|
+
`);
|
|
53
|
+
}
|
|
54
|
+
return reply.exitCode;
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
run
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=statusline-ZNTCL5YC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/cli/commands/statusline.ts"],"sourcesContent":["/**\n * cli/commands/statusline — the universal statusline (HUD) entrypoint.\n *\n * agent-connector statusline <platform> --connector <id>\n *\n * A statusline-supporting host points its status line config at the single stable\n * home binary (via core/spawn.buildHomeBinStatuslineCommand). This command reads\n * the ENTIRE host payload from stdin, dispatches through runStatusline, writes the\n * rendered line to stdout, and exits with the adapter's exit code.\n *\n * FAIL-SAFE is the runtime's contract: a status line must NEVER wedge the host or\n * spew an error into the status bar. runStatusline never rejects (always exits 0\n * with at most a rendered line), and even a malformed invocation here degrades to\n * exit 0 with no output — never the strict `fail()` non-zero used by other\n * commands.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport { runStatusline } from \"../../runtime/index.js\";\n\n/** Read all of a readable stream to a UTF-8 string. */\nasync function readAll(stream: NodeJS.ReadStream): Promise<string> {\n const chunks: Buffer[] = [];\n for await (const chunk of stream) {\n chunks.push(typeof chunk === \"string\" ? Buffer.from(chunk) : chunk);\n }\n return Buffer.concat(chunks).toString(\"utf8\");\n}\n\nexport async function run(argv: string[]): Promise<number> {\n // strict:false so a future flag from a newer install can never make this throw\n // and surface a non-zero exit into the host's status bar.\n let platformId = \"\";\n let connectorId = \"\";\n try {\n const { values, positionals } = parseArgs({\n args: argv,\n options: { connector: { type: \"string\" } },\n allowPositionals: true,\n strict: false,\n });\n platformId = positionals[0] ?? \"\";\n connectorId = typeof values.connector === \"string\" ? values.connector : \"\";\n } catch {\n // A malformed invocation must still fail-safe (render nothing, exit 0).\n return 0;\n }\n\n // Drain stdin regardless — a host expects the command to consume its payload.\n const stdin = await readAll(process.stdin).catch(() => \"\");\n\n // Missing platform/connector → render nothing, exit 0 (never a non-zero exit).\n if (platformId === \"\" || connectorId === \"\") {\n return 0;\n }\n\n const reply = await runStatusline({ platformId, connectorId, stdin });\n if (reply.stdout !== undefined && reply.stdout !== \"\") {\n process.stdout.write(reply.stdout);\n }\n if (reply.stderr !== undefined && reply.stderr !== \"\") {\n process.stderr.write(reply.stderr.endsWith(\"\\n\") ? reply.stderr : `${reply.stderr}\\n`);\n }\n return reply.exitCode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,SAAS,iBAAiB;AAK1B,eAAe,QAAQ,QAA4C;AACjE,QAAM,SAAmB,CAAC;AAC1B,mBAAiB,SAAS,QAAQ;AAChC,WAAO,KAAK,OAAO,UAAU,WAAW,OAAO,KAAK,KAAK,IAAI,KAAK;AAAA,EACpE;AACA,SAAO,OAAO,OAAO,MAAM,EAAE,SAAS,MAAM;AAC9C;AAEA,eAAsB,IAAI,MAAiC;AAGzD,MAAI,aAAa;AACjB,MAAI,cAAc;AAClB,MAAI;AACF,UAAM,EAAE,QAAQ,YAAY,IAAI,UAAU;AAAA,MACxC,MAAM;AAAA,MACN,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,EAAE;AAAA,MACzC,kBAAkB;AAAA,MAClB,QAAQ;AAAA,IACV,CAAC;AACD,iBAAa,YAAY,CAAC,KAAK;AAC/B,kBAAc,OAAO,OAAO,cAAc,WAAW,OAAO,YAAY;AAAA,EAC1E,QAAQ;AAEN,WAAO;AAAA,EACT;AAGA,QAAM,QAAQ,MAAM,QAAQ,QAAQ,KAAK,EAAE,MAAM,MAAM,EAAE;AAGzD,MAAI,eAAe,MAAM,gBAAgB,IAAI;AAC3C,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,MAAM,cAAc,EAAE,YAAY,aAAa,MAAM,CAAC;AACpE,MAAI,MAAM,WAAW,UAAa,MAAM,WAAW,IAAI;AACrD,YAAQ,OAAO,MAAM,MAAM,MAAM;AAAA,EACnC;AACA,MAAI,MAAM,WAAW,UAAa,MAAM,WAAW,IAAI;AACrD,YAAQ,OAAO,MAAM,MAAM,OAAO,SAAS,IAAI,IAAI,MAAM,SAAS,GAAG,MAAM,MAAM;AAAA,CAAI;AAAA,EACvF;AACA,SAAO,MAAM;AACf;","names":[]}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
fail,
|
|
14
14
|
print
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-KGXDYGNJ.js";
|
|
16
16
|
import {
|
|
17
17
|
openStore
|
|
18
18
|
} from "./chunk-BCHWFTV4.js";
|
|
@@ -21,8 +21,9 @@ import {
|
|
|
21
21
|
listRegisteredConnectors,
|
|
22
22
|
loadRegisteredConnector,
|
|
23
23
|
readRegisteredMeta
|
|
24
|
-
} from "./chunk-
|
|
25
|
-
import "./chunk-
|
|
24
|
+
} from "./chunk-KGJWE6A2.js";
|
|
25
|
+
import "./chunk-ADTHT2FN.js";
|
|
26
|
+
import "./chunk-3PFFTFCU.js";
|
|
26
27
|
import "./chunk-N6HH7K6P.js";
|
|
27
28
|
import "./chunk-TRQKHP7D.js";
|
|
28
29
|
|
|
@@ -347,4 +348,4 @@ export {
|
|
|
347
348
|
parseSince,
|
|
348
349
|
run
|
|
349
350
|
};
|
|
350
|
-
//# sourceMappingURL=telemetry-
|
|
351
|
+
//# sourceMappingURL=telemetry-XIKUUGTQ.js.map
|