@ken-jo/agent-connector 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (203) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +6 -0
  3. package/README.md +348 -0
  4. package/dist/amp-QSFH2V7Y.js +217 -0
  5. package/dist/amp-QSFH2V7Y.js.map +1 -0
  6. package/dist/amp-TULUPXXL.js +237 -0
  7. package/dist/amp-TULUPXXL.js.map +1 -0
  8. package/dist/antigravity-CX2YLSY7.js +17 -0
  9. package/dist/antigravity-CX2YLSY7.js.map +1 -0
  10. package/dist/antigravity-STHZWMP3.js +171 -0
  11. package/dist/antigravity-STHZWMP3.js.map +1 -0
  12. package/dist/antigravity-cli-P6HADOAO.js +121 -0
  13. package/dist/antigravity-cli-P6HADOAO.js.map +1 -0
  14. package/dist/antigravity-cli-YQDFVV4U.js +86 -0
  15. package/dist/antigravity-cli-YQDFVV4U.js.map +1 -0
  16. package/dist/chunk-54EMKTTX.js +191 -0
  17. package/dist/chunk-54EMKTTX.js.map +1 -0
  18. package/dist/chunk-7L6ITC4T.js +54 -0
  19. package/dist/chunk-7L6ITC4T.js.map +1 -0
  20. package/dist/chunk-7MSDGHJW.js +316 -0
  21. package/dist/chunk-7MSDGHJW.js.map +1 -0
  22. package/dist/chunk-BCHWFTV4.js +196 -0
  23. package/dist/chunk-BCHWFTV4.js.map +1 -0
  24. package/dist/chunk-DBQMX75U.js +36 -0
  25. package/dist/chunk-DBQMX75U.js.map +1 -0
  26. package/dist/chunk-EXLS7BSI.js +29 -0
  27. package/dist/chunk-EXLS7BSI.js.map +1 -0
  28. package/dist/chunk-JNM3TPLX.js +593 -0
  29. package/dist/chunk-JNM3TPLX.js.map +1 -0
  30. package/dist/chunk-JWNT5KW7.js +197 -0
  31. package/dist/chunk-JWNT5KW7.js.map +1 -0
  32. package/dist/chunk-KHO5WNTP.js +30 -0
  33. package/dist/chunk-KHO5WNTP.js.map +1 -0
  34. package/dist/chunk-LTT56GI3.js +155 -0
  35. package/dist/chunk-LTT56GI3.js.map +1 -0
  36. package/dist/chunk-MEH7GC7R.js +111 -0
  37. package/dist/chunk-MEH7GC7R.js.map +1 -0
  38. package/dist/chunk-MQPNU2CY.js +64 -0
  39. package/dist/chunk-MQPNU2CY.js.map +1 -0
  40. package/dist/chunk-OPXAP3AC.js +12 -0
  41. package/dist/chunk-OPXAP3AC.js.map +1 -0
  42. package/dist/chunk-RK6VBLXP.js +50 -0
  43. package/dist/chunk-RK6VBLXP.js.map +1 -0
  44. package/dist/chunk-TIIP3RG2.js +420 -0
  45. package/dist/chunk-TIIP3RG2.js.map +1 -0
  46. package/dist/chunk-TRKWUNO4.js +702 -0
  47. package/dist/chunk-TRKWUNO4.js.map +1 -0
  48. package/dist/chunk-TRQKHP7D.js +93 -0
  49. package/dist/chunk-TRQKHP7D.js.map +1 -0
  50. package/dist/chunk-WCETQWWK.js +59 -0
  51. package/dist/chunk-WCETQWWK.js.map +1 -0
  52. package/dist/chunk-WV63X7IK.js +357 -0
  53. package/dist/chunk-WV63X7IK.js.map +1 -0
  54. package/dist/chunk-XD7MY6HB.js +343 -0
  55. package/dist/chunk-XD7MY6HB.js.map +1 -0
  56. package/dist/chunk-XNAM7F35.js +276 -0
  57. package/dist/chunk-XNAM7F35.js.map +1 -0
  58. package/dist/chunk-XUCWLJY5.js +238 -0
  59. package/dist/chunk-XUCWLJY5.js.map +1 -0
  60. package/dist/chunk-YNZU6PAV.js +800 -0
  61. package/dist/chunk-YNZU6PAV.js.map +1 -0
  62. package/dist/chunk-YT43MUSJ.js +146 -0
  63. package/dist/chunk-YT43MUSJ.js.map +1 -0
  64. package/dist/claude-code-HKDV7T32.js +637 -0
  65. package/dist/claude-code-HKDV7T32.js.map +1 -0
  66. package/dist/claude-code-W74MNTAC.js +652 -0
  67. package/dist/claude-code-W74MNTAC.js.map +1 -0
  68. package/dist/cli/sdk.d.ts +54 -0
  69. package/dist/cli/sdk.js +82 -0
  70. package/dist/cli/sdk.js.map +1 -0
  71. package/dist/cli.d.ts +2 -0
  72. package/dist/cli.js +15 -0
  73. package/dist/cli.js.map +1 -0
  74. package/dist/codebuff-3PMZJJHP.js +307 -0
  75. package/dist/codebuff-3PMZJJHP.js.map +1 -0
  76. package/dist/codebuff-QX57FJDN.js +220 -0
  77. package/dist/codebuff-QX57FJDN.js.map +1 -0
  78. package/dist/codex-JFQTS6LU.js +593 -0
  79. package/dist/codex-JFQTS6LU.js.map +1 -0
  80. package/dist/codex-Q3ATRRX3.js +364 -0
  81. package/dist/codex-Q3ATRRX3.js.map +1 -0
  82. package/dist/copilot-cli-MTCGHZ2T.js +622 -0
  83. package/dist/copilot-cli-MTCGHZ2T.js.map +1 -0
  84. package/dist/copilot-cli-SJGIXVSD.js +369 -0
  85. package/dist/copilot-cli-SJGIXVSD.js.map +1 -0
  86. package/dist/crush-I7PK3FGI.js +360 -0
  87. package/dist/crush-I7PK3FGI.js.map +1 -0
  88. package/dist/crush-LN5QFFR2.js +183 -0
  89. package/dist/crush-LN5QFFR2.js.map +1 -0
  90. package/dist/cursor-4TMXKJOZ.js +603 -0
  91. package/dist/cursor-4TMXKJOZ.js.map +1 -0
  92. package/dist/cursor-QZ6MTO74.js +194 -0
  93. package/dist/cursor-QZ6MTO74.js.map +1 -0
  94. package/dist/detect-WIAGVYS4.js +68 -0
  95. package/dist/detect-WIAGVYS4.js.map +1 -0
  96. package/dist/doctor-EZW2K4NI.js +372 -0
  97. package/dist/doctor-EZW2K4NI.js.map +1 -0
  98. package/dist/droid-KN6VRMMT.js +424 -0
  99. package/dist/droid-KN6VRMMT.js.map +1 -0
  100. package/dist/droid-W5WF5XEX.js +224 -0
  101. package/dist/droid-W5WF5XEX.js.map +1 -0
  102. package/dist/gemini-cli-CIRW37TU.js +369 -0
  103. package/dist/gemini-cli-CIRW37TU.js.map +1 -0
  104. package/dist/gemini-cli-Y35FFK4M.js +705 -0
  105. package/dist/gemini-cli-Y35FFK4M.js.map +1 -0
  106. package/dist/goose-A3M5GODH.js +212 -0
  107. package/dist/goose-A3M5GODH.js.map +1 -0
  108. package/dist/goose-ZTGTSUFJ.js +480 -0
  109. package/dist/goose-ZTGTSUFJ.js.map +1 -0
  110. package/dist/hermes-H2KV44GK.js +470 -0
  111. package/dist/hermes-H2KV44GK.js.map +1 -0
  112. package/dist/hermes-ZYLMOFLZ.js +196 -0
  113. package/dist/hermes-ZYLMOFLZ.js.map +1 -0
  114. package/dist/hook-YVDILAMZ.js +75 -0
  115. package/dist/hook-YVDILAMZ.js.map +1 -0
  116. package/dist/index.d.ts +22 -0
  117. package/dist/index.js +10 -0
  118. package/dist/index.js.map +1 -0
  119. package/dist/install-HQRYZOQ2.js +60 -0
  120. package/dist/install-HQRYZOQ2.js.map +1 -0
  121. package/dist/jetbrains-copilot-HWA3DMH7.js +633 -0
  122. package/dist/jetbrains-copilot-HWA3DMH7.js.map +1 -0
  123. package/dist/kilo-NSWAVP6P.js +235 -0
  124. package/dist/kilo-NSWAVP6P.js.map +1 -0
  125. package/dist/kilo-QXJRCSLT.js +384 -0
  126. package/dist/kilo-QXJRCSLT.js.map +1 -0
  127. package/dist/kilo-cli-EAQTHXUW.js +587 -0
  128. package/dist/kilo-cli-EAQTHXUW.js.map +1 -0
  129. package/dist/kilo-cli-EVBKUODA.js +160 -0
  130. package/dist/kilo-cli-EVBKUODA.js.map +1 -0
  131. package/dist/kimi-EI3UM3ZV.js +155 -0
  132. package/dist/kimi-EI3UM3ZV.js.map +1 -0
  133. package/dist/kimi-GQ7VXNYT.js +423 -0
  134. package/dist/kimi-GQ7VXNYT.js.map +1 -0
  135. package/dist/kiro-UCLSLBW2.js +217 -0
  136. package/dist/kiro-UCLSLBW2.js.map +1 -0
  137. package/dist/kiro-VQTT6LO2.js +451 -0
  138. package/dist/kiro-VQTT6LO2.js.map +1 -0
  139. package/dist/leaderboard-K6ON3SWW.js +137 -0
  140. package/dist/leaderboard-K6ON3SWW.js.map +1 -0
  141. package/dist/mux-T2TV4CIQ.js +211 -0
  142. package/dist/mux-T2TV4CIQ.js.map +1 -0
  143. package/dist/mux-ZMLVAXOO.js +96 -0
  144. package/dist/mux-ZMLVAXOO.js.map +1 -0
  145. package/dist/omp-PB4VDKS6.js +586 -0
  146. package/dist/omp-PB4VDKS6.js.map +1 -0
  147. package/dist/openclaw-ETN2M63O.js +751 -0
  148. package/dist/openclaw-ETN2M63O.js.map +1 -0
  149. package/dist/openclaw-IYA7ASL6.js +150 -0
  150. package/dist/openclaw-IYA7ASL6.js.map +1 -0
  151. package/dist/opencode-FZ33JKUZ.js +734 -0
  152. package/dist/opencode-FZ33JKUZ.js.map +1 -0
  153. package/dist/opencode-HWT3RSMN.js +216 -0
  154. package/dist/opencode-HWT3RSMN.js.map +1 -0
  155. package/dist/package-DLOVE2E4.js +1132 -0
  156. package/dist/package-DLOVE2E4.js.map +1 -0
  157. package/dist/pi-CIU2QHT4.js +208 -0
  158. package/dist/pi-CIU2QHT4.js.map +1 -0
  159. package/dist/pi-UFX2OYFV.js +139 -0
  160. package/dist/pi-UFX2OYFV.js.map +1 -0
  161. package/dist/qwen-code-5POCNU6P.js +573 -0
  162. package/dist/qwen-code-5POCNU6P.js.map +1 -0
  163. package/dist/qwen-code-W7NUCDEN.js +134 -0
  164. package/dist/qwen-code-W7NUCDEN.js.map +1 -0
  165. package/dist/roo-code-IOIUXRDE.js +242 -0
  166. package/dist/roo-code-IOIUXRDE.js.map +1 -0
  167. package/dist/roo-code-ZLKH4A7N.js +229 -0
  168. package/dist/roo-code-ZLKH4A7N.js.map +1 -0
  169. package/dist/runtime/index.d.ts +157 -0
  170. package/dist/runtime/index.js +20 -0
  171. package/dist/runtime/index.js.map +1 -0
  172. package/dist/serve-HVWWY4B6.js +65 -0
  173. package/dist/serve-HVWWY4B6.js.map +1 -0
  174. package/dist/status-FE7TECZD.js +128 -0
  175. package/dist/status-FE7TECZD.js.map +1 -0
  176. package/dist/synthetic-UKR6SMGS.js +178 -0
  177. package/dist/synthetic-UKR6SMGS.js.map +1 -0
  178. package/dist/telemetry-36GESKQQ.js +349 -0
  179. package/dist/telemetry-36GESKQQ.js.map +1 -0
  180. package/dist/trae-JSNDZFKL.js +204 -0
  181. package/dist/trae-JSNDZFKL.js.map +1 -0
  182. package/dist/trae-PA26DPBW.js +157 -0
  183. package/dist/trae-PA26DPBW.js.map +1 -0
  184. package/dist/types-CYUB1OTr.d.ts +427 -0
  185. package/dist/uninstall-IGCKNOSF.js +72 -0
  186. package/dist/uninstall-IGCKNOSF.js.map +1 -0
  187. package/dist/upgrade-JV2VK242.js +104 -0
  188. package/dist/upgrade-JV2VK242.js.map +1 -0
  189. package/dist/usage-6ER6EMEY.js +324 -0
  190. package/dist/usage-6ER6EMEY.js.map +1 -0
  191. package/dist/usage-event-JKBI6XCF.js +48 -0
  192. package/dist/usage-event-JKBI6XCF.js.map +1 -0
  193. package/dist/vscode-copilot-CK3NO54M.js +715 -0
  194. package/dist/vscode-copilot-CK3NO54M.js.map +1 -0
  195. package/dist/warp-JNQA7PBU.js +126 -0
  196. package/dist/warp-JNQA7PBU.js.map +1 -0
  197. package/dist/warp-QNVDXOG4.js +199 -0
  198. package/dist/warp-QNVDXOG4.js.map +1 -0
  199. package/dist/zed-NNNX5MNT.js +272 -0
  200. package/dist/zed-NNNX5MNT.js.map +1 -0
  201. package/dist/zed-VRJKWYUR.js +209 -0
  202. package/dist/zed-VRJKWYUR.js.map +1 -0
  203. package/package.json +79 -0
@@ -0,0 +1,276 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/core/define-connector.ts
4
+ import { isAbsolute, normalize } from "path";
5
+
6
+ // src/core/mcp-standard.ts
7
+ var MCP_SERVER_SCHEMA_URL = "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json";
8
+ var MCPB_MANIFEST_VERSION = "0.3";
9
+ var MCP_PROTOCOL_VERSION = "2025-11-25";
10
+ var NPM_REGISTRY_BASE_URL = "https://registry.npmjs.org";
11
+ function registryTransportType(transport) {
12
+ switch (transport) {
13
+ case "stdio":
14
+ return "stdio";
15
+ case "http":
16
+ return "streamable-http";
17
+ case "sse":
18
+ return "sse";
19
+ case "ws":
20
+ return null;
21
+ }
22
+ }
23
+ function isConcreteSemver(v) {
24
+ return /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(v);
25
+ }
26
+ function isPlaceholderVersion(v) {
27
+ return v === "0.0.0";
28
+ }
29
+ var REGISTRY_NAMESPACE_RE = /^[a-zA-Z0-9.-]+$/;
30
+ var REGISTRY_NAME_RE = /^[a-zA-Z0-9.-]+\/[a-zA-Z0-9._-]+$/;
31
+
32
+ // src/core/define-connector.ts
33
+ var ID_RE = /^[a-z0-9][a-z0-9-]*$/;
34
+ var SURFACE_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;
35
+ var SKILL_DESCRIPTION_MAX = 1024;
36
+ var ALL_EVENTS = [
37
+ "SessionStart",
38
+ "SessionEnd",
39
+ "UserPromptSubmit",
40
+ "PreToolUse",
41
+ "PostToolUse",
42
+ "PreCompact",
43
+ "Stop",
44
+ "Notification"
45
+ ];
46
+ var ConnectorConfigError = class extends Error {
47
+ constructor(message) {
48
+ super(`Invalid connector config: ${message}`);
49
+ this.name = "ConnectorConfigError";
50
+ }
51
+ };
52
+ function declaredEvents(hooks) {
53
+ if (!hooks) return [];
54
+ return ALL_EVENTS.filter((e) => typeof hooks[e]?.handler === "function");
55
+ }
56
+ function defineConnector(config) {
57
+ if (!config || typeof config !== "object") {
58
+ throw new ConnectorConfigError("config must be an object");
59
+ }
60
+ if (typeof config.id !== "string" || !ID_RE.test(config.id)) {
61
+ throw new ConnectorConfigError(
62
+ `id must be kebab-case matching ${ID_RE} (got ${JSON.stringify(config.id)})`
63
+ );
64
+ }
65
+ const hasCommands = Array.isArray(config.commands) && config.commands.length > 0;
66
+ const hasSkills = Array.isArray(config.skills) && config.skills.length > 0;
67
+ const hasSubagents = Array.isArray(config.subagents) && config.subagents.length > 0;
68
+ if (!config.server && !config.hooks && !hasCommands && !hasSkills && !hasSubagents) {
69
+ throw new ConnectorConfigError(
70
+ "a connector must declare at least one of `server`, `hooks`, `commands`, `skills`, or `subagents`"
71
+ );
72
+ }
73
+ if (config.server) {
74
+ const s = config.server;
75
+ if (s.transport === "stdio") {
76
+ if (!s.command || typeof s.command !== "string") {
77
+ throw new ConnectorConfigError(
78
+ "server.command is required for stdio transport"
79
+ );
80
+ }
81
+ } else {
82
+ if (!s.url || typeof s.url !== "string") {
83
+ throw new ConnectorConfigError(
84
+ `server.url is required for ${s.transport} transport`
85
+ );
86
+ }
87
+ }
88
+ }
89
+ if (config.hooks) {
90
+ for (const ev of ALL_EVENTS) {
91
+ const def = config.hooks[ev];
92
+ if (def != null && typeof def.handler !== "function") {
93
+ throw new ConnectorConfigError(`hooks.${ev}.handler must be a function`);
94
+ }
95
+ }
96
+ }
97
+ const commands = normalizeCommands(config.commands);
98
+ const skills = normalizeSkills(config.skills);
99
+ const subagents = normalizeSubagents(config.subagents);
100
+ const t = config.telemetry ?? {};
101
+ const resolved = {
102
+ id: config.id,
103
+ displayName: config.displayName ?? config.id,
104
+ version: config.version ?? "0.0.0",
105
+ ...config.server ? { server: normalizeServer(config.server) } : {},
106
+ hooks: config.hooks ?? {},
107
+ hookEvents: declaredEvents(config.hooks),
108
+ telemetry: {
109
+ enabled: t.enabled ?? true,
110
+ modelFamilyHint: t.modelFamilyHint ?? "auto",
111
+ measureToolDefs: t.measureToolDefs ?? true,
112
+ // OPT-IN: host-native turn-usage capture is OFF unless explicitly enabled
113
+ // in config (or forced on at install via AGENT_CONNECTOR_HOST_NATIVE=1).
114
+ hostNativeUsage: t.hostNativeUsage ?? false,
115
+ store: t.store ?? "ndjson",
116
+ calibration: {
117
+ anthropicCountTokens: t.calibration?.anthropicCountTokens ?? false
118
+ }
119
+ },
120
+ commands,
121
+ skills,
122
+ subagents,
123
+ platforms: config.platforms ?? {},
124
+ targets: config.targets ?? "auto",
125
+ ...config.publish ? { publish: normalizePublish(config.publish) } : {}
126
+ };
127
+ return resolved;
128
+ }
129
+ function normalizePublish(publish) {
130
+ if (typeof publish !== "object" || Array.isArray(publish)) {
131
+ throw new ConnectorConfigError("publish must be an object");
132
+ }
133
+ if (publish.registryNamespace !== void 0) {
134
+ const ns = publish.registryNamespace;
135
+ if (typeof ns !== "string" || !REGISTRY_NAMESPACE_RE.test(ns)) {
136
+ throw new ConnectorConfigError(
137
+ `publish.registryNamespace must be a reverse-DNS namespace matching ${REGISTRY_NAMESPACE_RE} (e.g. "io.github.acme" or "com.acme"); got ${JSON.stringify(ns)}`
138
+ );
139
+ }
140
+ }
141
+ if (publish.packageName !== void 0 && typeof publish.packageName !== "string") {
142
+ throw new ConnectorConfigError("publish.packageName must be a string");
143
+ }
144
+ if (publish.author !== void 0) {
145
+ const a = publish.author;
146
+ if (typeof a !== "object" || a == null || typeof a.name !== "string" || a.name === "") {
147
+ throw new ConnectorConfigError("publish.author.name must be a non-empty string");
148
+ }
149
+ }
150
+ return { ...publish };
151
+ }
152
+ function assertSurfaceName(surface, name, index) {
153
+ if (typeof name !== "string" || !SURFACE_NAME_RE.test(name)) {
154
+ throw new ConnectorConfigError(
155
+ `${surface}[${index}].name must be kebab-case matching ${SURFACE_NAME_RE} (got ${JSON.stringify(name)})`
156
+ );
157
+ }
158
+ return name;
159
+ }
160
+ function assertNonEmptyString(surface, index, field, value) {
161
+ if (typeof value !== "string" || value.length === 0) {
162
+ throw new ConnectorConfigError(`${surface}[${index}].${field} must be a non-empty string`);
163
+ }
164
+ return value;
165
+ }
166
+ function assertNoDuplicate(surface, seen, name, index) {
167
+ if (seen.has(name)) {
168
+ throw new ConnectorConfigError(`${surface}[${index}] duplicate name "${name}"`);
169
+ }
170
+ seen.add(name);
171
+ }
172
+ function normalizeCommands(input) {
173
+ if (input == null) return [];
174
+ if (!Array.isArray(input)) {
175
+ throw new ConnectorConfigError("commands must be an array");
176
+ }
177
+ const seen = /* @__PURE__ */ new Set();
178
+ return input.map((cmd, i) => {
179
+ if (!cmd || typeof cmd !== "object") {
180
+ throw new ConnectorConfigError(`commands[${i}] must be an object`);
181
+ }
182
+ const name = assertSurfaceName("commands", cmd.name, i);
183
+ assertNoDuplicate("commands", seen, name, i);
184
+ assertNonEmptyString("commands", i, "prompt", cmd.prompt);
185
+ return { ...cmd, name };
186
+ });
187
+ }
188
+ function normalizeSkills(input) {
189
+ if (input == null) return [];
190
+ if (!Array.isArray(input)) {
191
+ throw new ConnectorConfigError("skills must be an array");
192
+ }
193
+ const seen = /* @__PURE__ */ new Set();
194
+ return input.map((skill, i) => {
195
+ if (!skill || typeof skill !== "object") {
196
+ throw new ConnectorConfigError(`skills[${i}] must be an object`);
197
+ }
198
+ const name = assertSurfaceName("skills", skill.name, i);
199
+ assertNoDuplicate("skills", seen, name, i);
200
+ const description = assertNonEmptyString("skills", i, "description", skill.description);
201
+ if (description.length > SKILL_DESCRIPTION_MAX) {
202
+ throw new ConnectorConfigError(
203
+ `skills[${i}].description exceeds ${SKILL_DESCRIPTION_MAX} chars (got ${description.length})`
204
+ );
205
+ }
206
+ assertNonEmptyString("skills", i, "body", skill.body);
207
+ assertSafeResourceKeys("skills", i, skill.resources);
208
+ return { ...skill, name };
209
+ });
210
+ }
211
+ function assertSafeResourceKeys(surface, index, resources) {
212
+ if (resources == null) return;
213
+ if (typeof resources !== "object" || Array.isArray(resources)) {
214
+ throw new ConnectorConfigError(`${surface}[${index}].resources must be an object`);
215
+ }
216
+ for (const rel of Object.keys(resources)) {
217
+ if (rel === "" || rel === "." || rel.trim() === "") {
218
+ throw new ConnectorConfigError(
219
+ `${surface}[${index}].resources key must be a non-empty relative path (got ${JSON.stringify(rel)})`
220
+ );
221
+ }
222
+ if (isAbsolute(rel)) {
223
+ throw new ConnectorConfigError(
224
+ `${surface}[${index}].resources key must be a relative path inside the skill dir, not absolute (got ${JSON.stringify(rel)})`
225
+ );
226
+ }
227
+ const norm = normalize(rel.replace(/\\/g, "/"));
228
+ const segs = norm.split(/[/\\]/);
229
+ if (norm === ".." || norm.startsWith("../") || norm.startsWith("..\\") || segs.includes("..")) {
230
+ throw new ConnectorConfigError(
231
+ `${surface}[${index}].resources key must not escape the skill dir via ".." (got ${JSON.stringify(rel)})`
232
+ );
233
+ }
234
+ }
235
+ }
236
+ function normalizeSubagents(input) {
237
+ if (input == null) return [];
238
+ if (!Array.isArray(input)) {
239
+ throw new ConnectorConfigError("subagents must be an array");
240
+ }
241
+ const seen = /* @__PURE__ */ new Set();
242
+ return input.map((agent, i) => {
243
+ if (!agent || typeof agent !== "object") {
244
+ throw new ConnectorConfigError(`subagents[${i}] must be an object`);
245
+ }
246
+ const name = assertSurfaceName("subagents", agent.name, i);
247
+ assertNoDuplicate("subagents", seen, name, i);
248
+ assertNonEmptyString("subagents", i, "description", agent.description);
249
+ assertNonEmptyString("subagents", i, "prompt", agent.prompt);
250
+ return { ...agent, name };
251
+ });
252
+ }
253
+ function normalizeServer(server) {
254
+ if (!server) return void 0;
255
+ const wrapDefault = server.transport === "stdio";
256
+ return {
257
+ ...server,
258
+ enabled: server.enabled ?? true,
259
+ tools: server.tools ?? { include: ["*"] },
260
+ wrapForTelemetry: server.wrapForTelemetry ?? wrapDefault
261
+ };
262
+ }
263
+
264
+ export {
265
+ MCP_SERVER_SCHEMA_URL,
266
+ MCPB_MANIFEST_VERSION,
267
+ MCP_PROTOCOL_VERSION,
268
+ NPM_REGISTRY_BASE_URL,
269
+ registryTransportType,
270
+ isConcreteSemver,
271
+ isPlaceholderVersion,
272
+ REGISTRY_NAME_RE,
273
+ ConnectorConfigError,
274
+ defineConnector
275
+ };
276
+ //# sourceMappingURL=chunk-XNAM7F35.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/define-connector.ts","../src/core/mcp-standard.ts"],"sourcesContent":["/**\n * core/define-connector — the public write-once entry point.\n *\n * Validates a ConnectorConfig and normalizes it into a ResolvedConnector with\n * every optional field resolved to a default. Validation is intentionally\n * dependency-free (no zod) to keep the single-binary install lean.\n */\n\nimport { isAbsolute, normalize } from \"node:path\";\n\nimport type {\n CommandDef,\n ConnectorConfig,\n HookEventName,\n HooksConfig,\n PublishConfig,\n ResolvedConnector,\n SkillDef,\n SubagentDef,\n} from \"./types.js\";\nimport { REGISTRY_NAMESPACE_RE } from \"./mcp-standard.js\";\n\nconst ID_RE = /^[a-z0-9][a-z0-9-]*$/;\n\n/** kebab-case name regex shared by command/skill/subagent names. */\nconst SURFACE_NAME_RE = /^[a-z0-9][a-z0-9-]*$/;\n\n/** Max length of a skill description (Agent Skills open standard). */\nconst SKILL_DESCRIPTION_MAX = 1024;\n\nconst ALL_EVENTS: HookEventName[] = [\n \"SessionStart\",\n \"SessionEnd\",\n \"UserPromptSubmit\",\n \"PreToolUse\",\n \"PostToolUse\",\n \"PreCompact\",\n \"Stop\",\n \"Notification\",\n];\n\n/** Thrown on an invalid connector configuration. */\nexport class ConnectorConfigError extends Error {\n constructor(message: string) {\n super(`Invalid connector config: ${message}`);\n this.name = \"ConnectorConfigError\";\n }\n}\n\nfunction declaredEvents(hooks: HooksConfig | undefined): HookEventName[] {\n if (!hooks) return [];\n return ALL_EVENTS.filter((e) => typeof hooks[e]?.handler === \"function\");\n}\n\n/**\n * Validate + normalize a connector definition.\n * Returns a ResolvedConnector that adapters and the CLI consume directly.\n */\nexport function defineConnector(config: ConnectorConfig): ResolvedConnector {\n if (!config || typeof config !== \"object\") {\n throw new ConnectorConfigError(\"config must be an object\");\n }\n if (typeof config.id !== \"string\" || !ID_RE.test(config.id)) {\n throw new ConnectorConfigError(\n `id must be kebab-case matching ${ID_RE} (got ${JSON.stringify(config.id)})`,\n );\n }\n const hasCommands = Array.isArray(config.commands) && config.commands.length > 0;\n const hasSkills = Array.isArray(config.skills) && config.skills.length > 0;\n const hasSubagents = Array.isArray(config.subagents) && config.subagents.length > 0;\n if (!config.server && !config.hooks && !hasCommands && !hasSkills && !hasSubagents) {\n throw new ConnectorConfigError(\n \"a connector must declare at least one of `server`, `hooks`, `commands`, `skills`, or `subagents`\",\n );\n }\n\n if (config.server) {\n const s = config.server;\n if (s.transport === \"stdio\") {\n if (!s.command || typeof s.command !== \"string\") {\n throw new ConnectorConfigError(\n \"server.command is required for stdio transport\",\n );\n }\n } else {\n if (!s.url || typeof s.url !== \"string\") {\n throw new ConnectorConfigError(\n `server.url is required for ${s.transport} transport`,\n );\n }\n }\n }\n\n // Validate hook handlers are functions.\n if (config.hooks) {\n for (const ev of ALL_EVENTS) {\n const def = config.hooks[ev];\n if (def != null && typeof def.handler !== \"function\") {\n throw new ConnectorConfigError(`hooks.${ev}.handler must be a function`);\n }\n }\n }\n\n const commands = normalizeCommands(config.commands);\n const skills = normalizeSkills(config.skills);\n const subagents = normalizeSubagents(config.subagents);\n\n const t = config.telemetry ?? {};\n\n const resolved: ResolvedConnector = {\n id: config.id,\n displayName: config.displayName ?? config.id,\n version: config.version ?? \"0.0.0\",\n ...(config.server ? { server: normalizeServer(config.server) } : {}),\n hooks: config.hooks ?? {},\n hookEvents: declaredEvents(config.hooks),\n telemetry: {\n enabled: t.enabled ?? true,\n modelFamilyHint: t.modelFamilyHint ?? \"auto\",\n measureToolDefs: t.measureToolDefs ?? true,\n // OPT-IN: host-native turn-usage capture is OFF unless explicitly enabled\n // in config (or forced on at install via AGENT_CONNECTOR_HOST_NATIVE=1).\n hostNativeUsage: t.hostNativeUsage ?? false,\n store: t.store ?? \"ndjson\",\n calibration: {\n anthropicCountTokens: t.calibration?.anthropicCountTokens ?? false,\n },\n },\n commands,\n skills,\n subagents,\n platforms: config.platforms ?? {},\n targets: config.targets ?? \"auto\",\n ...(config.publish ? { publish: normalizePublish(config.publish) } : {}),\n };\n\n return resolved;\n}\n\n/**\n * Validate the optional `publish` block (registry server.json + MCPB bundle\n * distribution metadata). Light, dependency-free: we only reject shapes that\n * would emit a clearly INVALID standard artifact. The per-format required-field\n * checks (e.g. server.json needs registryNamespace, mcpb needs author.name)\n * live in the emitters so a connector that never publishes pays nothing.\n */\nfunction normalizePublish(publish: PublishConfig): PublishConfig {\n if (typeof publish !== \"object\" || Array.isArray(publish)) {\n throw new ConnectorConfigError(\"publish must be an object\");\n }\n if (publish.registryNamespace !== undefined) {\n const ns = publish.registryNamespace;\n if (typeof ns !== \"string\" || !REGISTRY_NAMESPACE_RE.test(ns)) {\n throw new ConnectorConfigError(\n `publish.registryNamespace must be a reverse-DNS namespace matching ${REGISTRY_NAMESPACE_RE} ` +\n `(e.g. \"io.github.acme\" or \"com.acme\"); got ${JSON.stringify(ns)}`,\n );\n }\n }\n if (publish.packageName !== undefined && typeof publish.packageName !== \"string\") {\n throw new ConnectorConfigError(\"publish.packageName must be a string\");\n }\n if (publish.author !== undefined) {\n const a = publish.author;\n if (typeof a !== \"object\" || a == null || typeof a.name !== \"string\" || a.name === \"\") {\n throw new ConnectorConfigError(\"publish.author.name must be a non-empty string\");\n }\n }\n return { ...publish };\n}\n\n/** Validate a surface name (kebab-case) or throw a ConnectorConfigError. */\nfunction assertSurfaceName(surface: string, name: unknown, index: number): string {\n if (typeof name !== \"string\" || !SURFACE_NAME_RE.test(name)) {\n throw new ConnectorConfigError(\n `${surface}[${index}].name must be kebab-case matching ${SURFACE_NAME_RE} (got ${JSON.stringify(name)})`,\n );\n }\n return name;\n}\n\n/** Require a non-empty string field on a surface entry. */\nfunction assertNonEmptyString(\n surface: string,\n index: number,\n field: string,\n value: unknown,\n): string {\n if (typeof value !== \"string\" || value.length === 0) {\n throw new ConnectorConfigError(`${surface}[${index}].${field} must be a non-empty string`);\n }\n return value;\n}\n\n/** Detect a duplicate surface name within one array, throwing on collision. */\nfunction assertNoDuplicate(\n surface: string,\n seen: Set<string>,\n name: string,\n index: number,\n): void {\n if (seen.has(name)) {\n throw new ConnectorConfigError(`${surface}[${index}] duplicate name \"${name}\"`);\n }\n seen.add(name);\n}\n\nfunction normalizeCommands(input: CommandDef[] | undefined): CommandDef[] {\n if (input == null) return [];\n if (!Array.isArray(input)) {\n throw new ConnectorConfigError(\"commands must be an array\");\n }\n const seen = new Set<string>();\n return input.map((cmd, i) => {\n if (!cmd || typeof cmd !== \"object\") {\n throw new ConnectorConfigError(`commands[${i}] must be an object`);\n }\n const name = assertSurfaceName(\"commands\", cmd.name, i);\n assertNoDuplicate(\"commands\", seen, name, i);\n assertNonEmptyString(\"commands\", i, \"prompt\", cmd.prompt);\n // Pass through verbatim (content); arrays are content, not handlers.\n return { ...cmd, name };\n });\n}\n\nfunction normalizeSkills(input: SkillDef[] | undefined): SkillDef[] {\n if (input == null) return [];\n if (!Array.isArray(input)) {\n throw new ConnectorConfigError(\"skills must be an array\");\n }\n const seen = new Set<string>();\n return input.map((skill, i) => {\n if (!skill || typeof skill !== \"object\") {\n throw new ConnectorConfigError(`skills[${i}] must be an object`);\n }\n const name = assertSurfaceName(\"skills\", skill.name, i);\n assertNoDuplicate(\"skills\", seen, name, i);\n const description = assertNonEmptyString(\"skills\", i, \"description\", skill.description);\n if (description.length > SKILL_DESCRIPTION_MAX) {\n throw new ConnectorConfigError(\n `skills[${i}].description exceeds ${SKILL_DESCRIPTION_MAX} chars (got ${description.length})`,\n );\n }\n assertNonEmptyString(\"skills\", i, \"body\", skill.body);\n assertSafeResourceKeys(\"skills\", i, skill.resources);\n return { ...skill, name };\n });\n}\n\n/**\n * Validate every `skill.resources` key as a SAFE relative path that stays inside\n * the skill dir. Each resource is later written/removed via join(skillDir, rel)\n * by every adapter, so an unvalidated key like \"../../settings.json\" would\n * escape the skill dir → arbitrary file write/delete. Reject (throw) when a key\n * is empty/\".\", absolute, or normalizes to a path that begins with \"..\" or\n * contains a \"/..\" (or platform-sep) traversal segment.\n */\nfunction assertSafeResourceKeys(\n surface: string,\n index: number,\n resources: Record<string, string> | undefined,\n): void {\n if (resources == null) return;\n if (typeof resources !== \"object\" || Array.isArray(resources)) {\n throw new ConnectorConfigError(`${surface}[${index}].resources must be an object`);\n }\n for (const rel of Object.keys(resources)) {\n if (rel === \"\" || rel === \".\" || rel.trim() === \"\") {\n throw new ConnectorConfigError(\n `${surface}[${index}].resources key must be a non-empty relative path (got ${JSON.stringify(rel)})`,\n );\n }\n if (isAbsolute(rel)) {\n throw new ConnectorConfigError(\n `${surface}[${index}].resources key must be a relative path inside the skill dir, not absolute (got ${JSON.stringify(rel)})`,\n );\n }\n // Normalize with BOTH posix and native separators flattened so a Windows\n // \"..\\\\x\" or a posix \"../x\" is caught regardless of the host OS.\n const norm = normalize(rel.replace(/\\\\/g, \"/\"));\n const segs = norm.split(/[/\\\\]/);\n if (norm === \"..\" || norm.startsWith(\"../\") || norm.startsWith(\"..\\\\\") || segs.includes(\"..\")) {\n throw new ConnectorConfigError(\n `${surface}[${index}].resources key must not escape the skill dir via \"..\" (got ${JSON.stringify(rel)})`,\n );\n }\n }\n}\n\nfunction normalizeSubagents(input: SubagentDef[] | undefined): SubagentDef[] {\n if (input == null) return [];\n if (!Array.isArray(input)) {\n throw new ConnectorConfigError(\"subagents must be an array\");\n }\n const seen = new Set<string>();\n return input.map((agent, i) => {\n if (!agent || typeof agent !== \"object\") {\n throw new ConnectorConfigError(`subagents[${i}] must be an object`);\n }\n const name = assertSurfaceName(\"subagents\", agent.name, i);\n assertNoDuplicate(\"subagents\", seen, name, i);\n assertNonEmptyString(\"subagents\", i, \"description\", agent.description);\n assertNonEmptyString(\"subagents\", i, \"prompt\", agent.prompt);\n return { ...agent, name };\n });\n}\n\nfunction normalizeServer(server: ConnectorConfig[\"server\"]): ResolvedConnector[\"server\"] {\n if (!server) return undefined;\n const wrapDefault = server.transport === \"stdio\";\n return {\n ...server,\n enabled: server.enabled ?? true,\n tools: server.tools ?? { include: [\"*\"] },\n wrapForTelemetry: server.wrapForTelemetry ?? wrapDefault,\n };\n}\n","/**\n * core/mcp-standard — pinned literals + guards for the official MCP standards\n * agent-connector EMITS (registry server.json, MCPB bundle) or SPEAKS (the\n * connection-lifecycle wire used by `doctor --probe`).\n *\n * Each pinned constant is the CURRENT released value verified 2026-06-05 against\n * the upstream spec/schema. They are deliberately centralized + annotated\n * MUST-VERIFY-AT-IMPLEMENTATION: a newer spec revision can supersede any of them\n * without breaking us, so the bump is a one-line change here, never scattered.\n *\n * Sources:\n * • server.schema.json 2025-12-11 — https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json\n * • MCPB manifest 0.3 — github.com/anthropics/mcpb (MANIFEST.md)\n * • MCP protocol 2025-11-25 — modelcontextprotocol.io/specification/2025-11-25\n * (latest RELEASED revision. 2026-07-28 is a release-candidate only — do NOT\n * advance to it until it publishes as a stable dated revision. The probe\n * offers this version but ACCEPTS whatever a server negotiates, so the\n * offered literal being stale never breaks interop — only this constant.)\n */\n\nimport type { Transport } from \"./types.js\";\n\n/** Registry server.json JSON Schema URL (released 2025-12-11). MUST-VERIFY on bump. */\nexport const MCP_SERVER_SCHEMA_URL =\n \"https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json\";\n\n/** Current MCPB bundle manifest_version (anthropics/mcpb). MUST-VERIFY on bump. */\nexport const MCPB_MANIFEST_VERSION = \"0.3\";\n\n/**\n * Latest RELEASED MCP protocol revision `doctor --probe` offers in `initialize`.\n * Current = 2025-11-25. MUST-VERIFY on bump; stay on the latest *released*\n * revision (2026-07-28 is RC-only as of 2026-06). Negotiation accepts whatever\n * the server returns, so this is the offered value, not a hard requirement.\n */\nexport const MCP_PROTOCOL_VERSION = \"2025-11-25\";\n\n/** Default npm registry base URL stamped into server.json npm packages. */\nexport const NPM_REGISTRY_BASE_URL = \"https://registry.npmjs.org\";\n\n/**\n * server.json transport.type enum — the EXACT values the 2025-12-11 schema\n * accepts (packages[].transport.type and remotes[].type). Our `http` Transport\n * maps to the spec slug \"streamable-http\"; \"ws\" is non-spec (see below).\n */\nexport type RegistryTransportType = \"stdio\" | \"streamable-http\" | \"sse\";\n\n/**\n * Map our {@link Transport} union to the registry/server.json transport slug.\n * Returns null for \"ws\" — WebSocket is NOT a spec transport (it can only exist\n * as a vendor custom transport, e.g. Claude Code's non-spec type:\"ws\"), so a\n * conformant artifact must REJECT it rather than emit an invalid type. The spec\n * defines exactly stdio + streamable-http, with sse the deprecated HTTP+SSE.\n */\nexport function registryTransportType(transport: Transport): RegistryTransportType | null {\n switch (transport) {\n case \"stdio\":\n return \"stdio\";\n case \"http\":\n return \"streamable-http\";\n case \"sse\":\n return \"sse\";\n case \"ws\":\n return null;\n }\n}\n\n/**\n * Is `v` a CONCRETE version the MCP Registry accepts? The registry rejects\n * ranges (\"^1.2.3\", \"~1.2.3\", \">=1.2.3\", \"1.x\", \"1.*\"); only a pinned SemVer\n * (optionally with a -prerelease / +build suffix) is valid. \"0.0.0\" is concrete\n * (so it passes this guard) but is the unset placeholder — callers warn on it\n * separately via {@link isPlaceholderVersion}.\n */\nexport function isConcreteSemver(v: string): boolean {\n return /^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/.test(v);\n}\n\n/** The unset default version a connector ships with until the dev sets a real one. */\nexport function isPlaceholderVersion(v: string): boolean {\n return v === \"0.0.0\";\n}\n\n/**\n * Reverse-DNS registry namespace pattern (the part BEFORE the \"/\" in a\n * server.json `name`). The full name regex is\n * `^[a-zA-Z0-9.-]+/[a-zA-Z0-9._-]+$`; the namespace side allows letters, digits,\n * dots and hyphens (NO underscore) — e.g. \"io.github.acme\" or \"com.acme\".\n */\nexport const REGISTRY_NAMESPACE_RE = /^[a-zA-Z0-9.-]+$/;\n\n/** The full server.json `name` regex (namespace \"/\" server-name), per the schema. */\nexport const REGISTRY_NAME_RE = /^[a-zA-Z0-9.-]+\\/[a-zA-Z0-9._-]+$/;\n"],"mappings":";;;AAQA,SAAS,YAAY,iBAAiB;;;ACe/B,IAAM,wBACX;AAGK,IAAM,wBAAwB;AAQ9B,IAAM,uBAAuB;AAG7B,IAAM,wBAAwB;AAgB9B,SAAS,sBAAsB,WAAoD;AACxF,UAAQ,WAAW;AAAA,IACjB,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT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,UAAU,GAAG,CAAC;AAAA,MACvG;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,mBAAmB,OAAiD;AAC3E,MAAI,SAAS,KAAM,QAAO,CAAC;AAC3B,MAAI,CAAC,MAAM,QAAQ,KAAK,GAAG;AACzB,UAAM,IAAI,qBAAqB,4BAA4B;AAAA,EAC7D;AACA,QAAM,OAAO,oBAAI,IAAY;AAC7B,SAAO,MAAM,IAAI,CAAC,OAAO,MAAM;AAC7B,QAAI,CAAC,SAAS,OAAO,UAAU,UAAU;AACvC,YAAM,IAAI,qBAAqB,aAAa,CAAC,qBAAqB;AAAA,IACpE;AACA,UAAM,OAAO,kBAAkB,aAAa,MAAM,MAAM,CAAC;AACzD,sBAAkB,aAAa,MAAM,MAAM,CAAC;AAC5C,yBAAqB,aAAa,GAAG,eAAe,MAAM,WAAW;AACrE,yBAAqB,aAAa,GAAG,UAAU,MAAM,MAAM;AAC3D,WAAO,EAAE,GAAG,OAAO,KAAK;AAAA,EAC1B,CAAC;AACH;AAEA,SAAS,gBAAgB,QAAgE;AACvF,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,cAAc,OAAO,cAAc;AACzC,SAAO;AAAA,IACL,GAAG;AAAA,IACH,SAAS,OAAO,WAAW;AAAA,IAC3B,OAAO,OAAO,SAAS,EAAE,SAAS,CAAC,GAAG,EAAE;AAAA,IACxC,kBAAkB,OAAO,oBAAoB;AAAA,EAC/C;AACF;","names":[]}
@@ -0,0 +1,238 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/adapters/registry.ts
4
+ var ADAPTER_REGISTRY = [
5
+ {
6
+ id: "claude-code",
7
+ load: () => import("./claude-code-HKDV7T32.js").then((m) => m.default)
8
+ },
9
+ {
10
+ id: "codex",
11
+ load: () => import("./codex-JFQTS6LU.js").then((m) => m.default)
12
+ },
13
+ {
14
+ id: "cursor",
15
+ load: () => import("./cursor-4TMXKJOZ.js").then((m) => m.default)
16
+ },
17
+ // vscode-copilot after cursor: cursor is a VS Code fork, so the fork's runtime
18
+ // markers must be checked first during host detection.
19
+ {
20
+ id: "vscode-copilot",
21
+ load: () => import("./vscode-copilot-CK3NO54M.js").then((m) => m.default)
22
+ },
23
+ {
24
+ id: "copilot-cli",
25
+ load: () => import("./copilot-cli-MTCGHZ2T.js").then((m) => m.default)
26
+ },
27
+ {
28
+ id: "gemini-cli",
29
+ load: () => import("./gemini-cli-Y35FFK4M.js").then((m) => m.default)
30
+ },
31
+ {
32
+ id: "warp",
33
+ load: () => import("./warp-QNVDXOG4.js").then((m) => m.default)
34
+ },
35
+ // ts-plugin paradigm: OpenCode loads a generated plugin module that bridges
36
+ // its in-process events to the universal hook entrypoint.
37
+ {
38
+ id: "opencode",
39
+ load: () => import("./opencode-FZ33JKUZ.js").then((m) => m.default)
40
+ },
41
+ // kilo-cli is the SQLite-backed OpenCode FORK command-line product (ts-plugin,
42
+ // loads @kilocode/plugin modules registered in kilo.jsonc's "plugin" array;
43
+ // MCP root key "mcp", ~/.config/kilo/kilo.jsonc). Grouped beside the OpenCode
44
+ // family whose plugin contract + config dialect it shares; distinct host from
45
+ // the "kilo" extension so there is no fork-ordering constraint between them.
46
+ {
47
+ id: "kilo-cli",
48
+ load: () => import("./kilo-cli-EAQTHXUW.js").then((m) => m.default)
49
+ },
50
+ // Wave 1 — mcp-only adapters (no lifecycle hooks; MCP registration only).
51
+ {
52
+ id: "droid",
53
+ load: () => import("./droid-KN6VRMMT.js").then((m) => m.default)
54
+ },
55
+ {
56
+ id: "roo-code",
57
+ load: () => import("./roo-code-IOIUXRDE.js").then((m) => m.default)
58
+ },
59
+ // kilo is the Kilo Code VS Code extension (kilocode.kilo-code) — a Roo/Cline
60
+ // fork, so it sits beside roo-code (mcp-only, root key "mcpServers", VS Code
61
+ // globalStorage / .kilocode project scope). Distinct host from "kilo-cli".
62
+ {
63
+ id: "kilo",
64
+ load: () => import("./kilo-QXJRCSLT.js").then((m) => m.default)
65
+ },
66
+ {
67
+ id: "trae",
68
+ load: () => import("./trae-JSNDZFKL.js").then((m) => m.default)
69
+ },
70
+ // antigravity-cli BEFORE antigravity: the `agy` CLI is a fork of the IDE
71
+ // adapter with its own runtime markers (the universal hook command tags the
72
+ // host as "antigravity-cli"), so the more-specific CLI marker must be checked
73
+ // before the IDE/parent during host detection.
74
+ {
75
+ id: "antigravity-cli",
76
+ load: () => import("./antigravity-cli-YQDFVV4U.js").then((m) => m.default)
77
+ },
78
+ {
79
+ id: "antigravity",
80
+ load: () => import("./antigravity-CX2YLSY7.js").then((m) => m.default)
81
+ },
82
+ {
83
+ id: "zed",
84
+ load: () => import("./zed-VRJKWYUR.js").then((m) => m.default)
85
+ },
86
+ {
87
+ id: "amp",
88
+ load: () => import("./amp-QSFH2V7Y.js").then((m) => m.default)
89
+ },
90
+ {
91
+ id: "codebuff",
92
+ load: () => import("./codebuff-QX57FJDN.js").then((m) => m.default)
93
+ },
94
+ {
95
+ id: "mux",
96
+ load: () => import("./mux-T2TV4CIQ.js").then((m) => m.default)
97
+ },
98
+ // Pi — mcp-only host with no writable MCP config; drives the Agent Skills
99
+ // surface only (writes <piDir>/skills/<name>/SKILL.md).
100
+ {
101
+ id: "pi",
102
+ load: () => import("./pi-CIU2QHT4.js").then((m) => m.default)
103
+ },
104
+ // Wave 2 — json-stdio adapters (full hook dispatch via the universal entrypoint).
105
+ // jetbrains-copilot before vscode-copilot is unnecessary (distinct hosts); grouped here.
106
+ {
107
+ id: "jetbrains-copilot",
108
+ load: () => import("./jetbrains-copilot-HWA3DMH7.js").then((m) => m.default)
109
+ },
110
+ {
111
+ id: "qwen-code",
112
+ load: () => import("./qwen-code-5POCNU6P.js").then((m) => m.default)
113
+ },
114
+ {
115
+ id: "kiro",
116
+ load: () => import("./kiro-VQTT6LO2.js").then((m) => m.default)
117
+ },
118
+ {
119
+ id: "kimi",
120
+ load: () => import("./kimi-GQ7VXNYT.js").then((m) => m.default)
121
+ },
122
+ {
123
+ id: "crush",
124
+ load: () => import("./crush-I7PK3FGI.js").then((m) => m.default)
125
+ },
126
+ // Wave 3 — json-stdio adapters with YAML config (MCP in YAML; hooks per host).
127
+ {
128
+ id: "goose",
129
+ load: () => import("./goose-ZTGTSUFJ.js").then((m) => m.default)
130
+ },
131
+ {
132
+ id: "hermes",
133
+ load: () => import("./hermes-H2KV44GK.js").then((m) => m.default)
134
+ },
135
+ // Wave 4 — ts-plugin adapters (generate a bridge module to the universal entrypoint).
136
+ {
137
+ id: "omp",
138
+ load: () => import("./omp-PB4VDKS6.js").then((m) => m.default)
139
+ },
140
+ {
141
+ id: "openclaw",
142
+ load: () => import("./openclaw-ETN2M63O.js").then((m) => m.default)
143
+ }
144
+ ];
145
+ var REGISTRY_BY_ID = new Map(
146
+ ADAPTER_REGISTRY.map((factory) => [factory.id, factory])
147
+ );
148
+ var REGISTERED_PLATFORM_IDS = new Set(
149
+ ADAPTER_REGISTRY.map((factory) => factory.id)
150
+ );
151
+ function getFactory(id) {
152
+ return REGISTRY_BY_ID.get(id);
153
+ }
154
+ async function loadAdapter(id) {
155
+ const factory = getFactory(id);
156
+ return factory ? factory.load() : void 0;
157
+ }
158
+
159
+ // src/adapters/detect.ts
160
+ async function detectInstalledPlatforms(projectDir) {
161
+ const adapters = await Promise.all(
162
+ ADAPTER_REGISTRY.map(async (factory) => {
163
+ try {
164
+ return await factory.load();
165
+ } catch {
166
+ return void 0;
167
+ }
168
+ })
169
+ );
170
+ const detected = [];
171
+ for (const adapter of adapters) {
172
+ if (!adapter) continue;
173
+ try {
174
+ const result = adapter.detectInstalled(projectDir);
175
+ if (result.installed) detected.push(result);
176
+ } catch {
177
+ }
178
+ }
179
+ return detected;
180
+ }
181
+ var RUNTIME_SIGNALS = [
182
+ {
183
+ platform: "claude-code",
184
+ vars: ["CLAUDE_CODE_ENTRYPOINT", "CLAUDE_PLUGIN_ROOT", "CLAUDE_PROJECT_DIR", "CLAUDE_SESSION_ID"],
185
+ note: "Claude Code env marker set"
186
+ },
187
+ {
188
+ platform: "cursor",
189
+ vars: ["CURSOR_TRACE_ID", "CURSOR_CLI", "CURSOR_CWD"],
190
+ note: "Cursor env marker set"
191
+ },
192
+ {
193
+ platform: "codex",
194
+ vars: ["CODEX_THREAD_ID", "CODEX_CI"],
195
+ note: "Codex env marker set"
196
+ }
197
+ ];
198
+ function detectRuntimeHost(env = process.env) {
199
+ const override = env.AGENT_CONNECTOR_PLATFORM;
200
+ if (override && override.trim() !== "") {
201
+ if (REGISTERED_RUNTIME_IDS.has(override)) {
202
+ return {
203
+ platform: override,
204
+ confidence: "high",
205
+ reason: `AGENT_CONNECTOR_PLATFORM=${override} override`
206
+ };
207
+ }
208
+ }
209
+ for (const rule of RUNTIME_SIGNALS) {
210
+ const hit = rule.vars.find((name) => {
211
+ const value = env[name];
212
+ return typeof value === "string" && value !== "";
213
+ });
214
+ if (hit) {
215
+ return {
216
+ platform: rule.platform,
217
+ confidence: "high",
218
+ reason: `${rule.note} (${hit})`
219
+ };
220
+ }
221
+ }
222
+ return {
223
+ platform: "unknown",
224
+ confidence: "low",
225
+ reason: "no host runtime env marker detected"
226
+ };
227
+ }
228
+ var REGISTERED_RUNTIME_IDS = new Set(
229
+ RUNTIME_SIGNALS.map((rule) => rule.platform)
230
+ );
231
+
232
+ export {
233
+ REGISTERED_PLATFORM_IDS,
234
+ loadAdapter,
235
+ detectInstalledPlatforms,
236
+ detectRuntimeHost
237
+ };
238
+ //# sourceMappingURL=chunk-XUCWLJY5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/adapters/registry.ts","../src/adapters/detect.ts"],"sourcesContent":["/**\n * adapters/registry — single source of truth for the platforms agent-connector\n * targets. Generalized from context-mode's `ADAPTER_REGISTRY` pattern, adapted\n * to our `Adapter` / `AdapterFactory` contract (adapters/spi.ts).\n *\n * In context-mode the same platform set was redeclared in four places (env-var\n * detection, session-dir lookup, the lazy adapter loader, and per-adapter base\n * constructors); adding a platform meant editing all of them and missing one\n * was silent. Here the list lives ONCE below: each platform is one entry with a\n * lazy `load()` thunk that resolves the adapter singleton. Adding a platform is\n * a single new entry — `getFactory` / `loadAdapter` / `allAdapters` and the\n * detection cascade in detect.ts all derive from this list.\n *\n * `load()` returns the module's default export, which every adapter file is\n * required to provide as its singleton (`export default adapter;`). It is a\n * function (not an eager import) so module loading stays lazy: an adapter is\n * only imported when it is actually needed, keeping startup cheap.\n *\n * Order is load-bearing for runtime host detection (detect.ts iterates env\n * markers in registry order): forks MUST precede their parent so a session\n * running inside a derived shell is not misclassified as the parent. For the\n * three Phase-1 adapters this is moot, but the ordering convention is fixed now\n * so later additions (cursor is a VS Code fork, etc.) slot in correctly.\n */\n\nimport type { PlatformId } from \"../core/types.js\";\nimport type { Adapter, AdapterFactory } from \"./spi.js\";\n\n/**\n * Authoritative list of installable platforms. One entry per platform; the\n * `load` thunk lazily imports the adapter module and returns its default-export\n * singleton. To add a platform: drop its `src/adapters/<id>/index.ts` in place\n * (default-exporting an `Adapter`) and add one entry here.\n */\nexport const ADAPTER_REGISTRY: readonly AdapterFactory[] = [\n {\n id: \"claude-code\",\n load: () => import(\"./claude-code/index.js\").then((m) => m.default),\n },\n {\n id: \"codex\",\n load: () => import(\"./codex/index.js\").then((m) => m.default),\n },\n {\n id: \"cursor\",\n load: () => import(\"./cursor/index.js\").then((m) => m.default),\n },\n // vscode-copilot after cursor: cursor is a VS Code fork, so the fork's runtime\n // markers must be checked first during host detection.\n {\n id: \"vscode-copilot\",\n load: () => import(\"./vscode-copilot/index.js\").then((m) => m.default),\n },\n {\n id: \"copilot-cli\",\n load: () => import(\"./copilot-cli/index.js\").then((m) => m.default),\n },\n {\n id: \"gemini-cli\",\n load: () => import(\"./gemini-cli/index.js\").then((m) => m.default),\n },\n {\n id: \"warp\",\n load: () => import(\"./warp/index.js\").then((m) => m.default),\n },\n // ts-plugin paradigm: OpenCode loads a generated plugin module that bridges\n // its in-process events to the universal hook entrypoint.\n {\n id: \"opencode\",\n load: () => import(\"./opencode/index.js\").then((m) => m.default),\n },\n // kilo-cli is the SQLite-backed OpenCode FORK command-line product (ts-plugin,\n // loads @kilocode/plugin modules registered in kilo.jsonc's \"plugin\" array;\n // MCP root key \"mcp\", ~/.config/kilo/kilo.jsonc). Grouped beside the OpenCode\n // family whose plugin contract + config dialect it shares; distinct host from\n // the \"kilo\" extension so there is no fork-ordering constraint between them.\n {\n id: \"kilo-cli\",\n load: () => import(\"./kilo-cli/index.js\").then((m) => m.default),\n },\n // Wave 1 — mcp-only adapters (no lifecycle hooks; MCP registration only).\n {\n id: \"droid\",\n load: () => import(\"./droid/index.js\").then((m) => m.default),\n },\n {\n id: \"roo-code\",\n load: () => import(\"./roo-code/index.js\").then((m) => m.default),\n },\n // kilo is the Kilo Code VS Code extension (kilocode.kilo-code) — a Roo/Cline\n // fork, so it sits beside roo-code (mcp-only, root key \"mcpServers\", VS Code\n // globalStorage / .kilocode project scope). Distinct host from \"kilo-cli\".\n {\n id: \"kilo\",\n load: () => import(\"./kilo/index.js\").then((m) => m.default),\n },\n {\n id: \"trae\",\n load: () => import(\"./trae/index.js\").then((m) => m.default),\n },\n // antigravity-cli BEFORE antigravity: the `agy` CLI is a fork of the IDE\n // adapter with its own runtime markers (the universal hook command tags the\n // host as \"antigravity-cli\"), so the more-specific CLI marker must be checked\n // before the IDE/parent during host detection.\n {\n id: \"antigravity-cli\",\n load: () => import(\"./antigravity-cli/index.js\").then((m) => m.default),\n },\n {\n id: \"antigravity\",\n load: () => import(\"./antigravity/index.js\").then((m) => m.default),\n },\n {\n id: \"zed\",\n load: () => import(\"./zed/index.js\").then((m) => m.default),\n },\n {\n id: \"amp\",\n load: () => import(\"./amp/index.js\").then((m) => m.default),\n },\n {\n id: \"codebuff\",\n load: () => import(\"./codebuff/index.js\").then((m) => m.default),\n },\n {\n id: \"mux\",\n load: () => import(\"./mux/index.js\").then((m) => m.default),\n },\n // Pi — mcp-only host with no writable MCP config; drives the Agent Skills\n // surface only (writes <piDir>/skills/<name>/SKILL.md).\n {\n id: \"pi\",\n load: () => import(\"./pi/index.js\").then((m) => m.default),\n },\n // Wave 2 — json-stdio adapters (full hook dispatch via the universal entrypoint).\n // jetbrains-copilot before vscode-copilot is unnecessary (distinct hosts); grouped here.\n {\n id: \"jetbrains-copilot\",\n load: () => import(\"./jetbrains-copilot/index.js\").then((m) => m.default),\n },\n {\n id: \"qwen-code\",\n load: () => import(\"./qwen-code/index.js\").then((m) => m.default),\n },\n {\n id: \"kiro\",\n load: () => import(\"./kiro/index.js\").then((m) => m.default),\n },\n {\n id: \"kimi\",\n load: () => import(\"./kimi/index.js\").then((m) => m.default),\n },\n {\n id: \"crush\",\n load: () => import(\"./crush/index.js\").then((m) => m.default),\n },\n // Wave 3 — json-stdio adapters with YAML config (MCP in YAML; hooks per host).\n {\n id: \"goose\",\n load: () => import(\"./goose/index.js\").then((m) => m.default),\n },\n {\n id: \"hermes\",\n load: () => import(\"./hermes/index.js\").then((m) => m.default),\n },\n // Wave 4 — ts-plugin adapters (generate a bridge module to the universal entrypoint).\n {\n id: \"omp\",\n load: () => import(\"./omp/index.js\").then((m) => m.default),\n },\n {\n id: \"openclaw\",\n load: () => import(\"./openclaw/index.js\").then((m) => m.default),\n },\n];\n\n/** O(1) lookup index, built once at module-load time. */\nconst REGISTRY_BY_ID: ReadonlyMap<PlatformId, AdapterFactory> = new Map(\n ADAPTER_REGISTRY.map((factory) => [factory.id, factory] as const),\n);\n\n/** Every platform id present in the registry (useful for matrix tests). */\nexport const REGISTERED_PLATFORM_IDS: ReadonlySet<PlatformId> = new Set(\n ADAPTER_REGISTRY.map((factory) => factory.id),\n);\n\n/**\n * Look up the lazy factory for a platform id. Returns `undefined` for ids that\n * are not registered (including `\"unknown\"` and typos) so callers can fall back\n * deliberately rather than crash.\n */\nexport function getFactory(id: PlatformId | string): AdapterFactory | undefined {\n return REGISTRY_BY_ID.get(id as PlatformId);\n}\n\n/**\n * Resolve a platform id to its adapter singleton. Returns `undefined` when the\n * id is not registered — callers decide whether to skip or fall back.\n */\nexport async function loadAdapter(id: PlatformId | string): Promise<Adapter | undefined> {\n const factory = getFactory(id);\n return factory ? factory.load() : undefined;\n}\n\n/**\n * Load every registered adapter. Imports run in parallel; the result preserves\n * registry order so downstream detection/install logic sees forks before\n * parents.\n */\nexport async function allAdapters(): Promise<Adapter[]> {\n return Promise.all(ADAPTER_REGISTRY.map((factory) => factory.load()));\n}\n","/**\n * adapters/detect — two complementary detection answers.\n *\n * 1. detectInstalledPlatforms(projectDir): which hosts are INSTALLED on this\n * machine (probe each adapter's config dirs / marker files). Drives the\n * install planner (\"auto\" target expansion, `doctor`).\n *\n * 2. detectRuntimeHost(env): which host is EXECUTING right now (read env\n * markers the host runtime injects into its child processes). Drives the\n * universal hook entrypoint — it must know which adapter's wire format the\n * stdin payload is in before it can parse it.\n *\n * Both derive their platform set from `ADAPTER_REGISTRY` (the single source of\n * truth in registry.ts), generalizing context-mode's detection cascade\n * (env-var tier → config-dir tier → low-confidence fallback) to our\n * Adapter/AdapterFactory contract. The config-dir tier is delegated to each\n * adapter's `detectInstalled()` rather than duplicated here, so adding a\n * platform never requires editing this file.\n */\n\nimport type { DetectedPlatform, DetectionSignal, PlatformId } from \"../core/types.js\";\nimport { ADAPTER_REGISTRY, loadAdapter } from \"./registry.js\";\n\n/**\n * Detect every platform installed on this machine.\n *\n * Loads each registered adapter and calls its `detectInstalled(projectDir)`\n * (which probes the platform's native config dirs + marker files), returning\n * only those reported `installed === true`, in registry order. Adapters never\n * throw from detection, but we guard each call so one misbehaving adapter\n * cannot abort the whole probe.\n *\n * @param projectDir Resolved project root — lets project-scoped adapters look\n * for `<projectDir>/.mcp.json`, `<projectDir>/.cursor`, etc.\n */\nexport async function detectInstalledPlatforms(\n projectDir: string,\n): Promise<DetectedPlatform[]> {\n const adapters = await Promise.all(\n ADAPTER_REGISTRY.map(async (factory) => {\n try {\n return await factory.load();\n } catch {\n return undefined;\n }\n }),\n );\n\n const detected: DetectedPlatform[] = [];\n for (const adapter of adapters) {\n if (!adapter) continue;\n try {\n const result = adapter.detectInstalled(projectDir);\n if (result.installed) detected.push(result);\n } catch {\n // A single adapter's detection failure must not sink the whole probe.\n }\n }\n return detected;\n}\n\n/**\n * One env-marker rule for runtime-host detection. `vars` is checked in order;\n * the FIRST rule with any non-empty matching env var wins, so the table order\n * is the detection precedence (forks before parents). Each var is documented at\n * the rule so the source of the marker is auditable.\n */\ninterface RuntimeSignalRule {\n readonly platform: PlatformId;\n /** Env var names that prove \"this host is executing me\". */\n readonly vars: readonly string[];\n /** Human-readable note (printed in the DetectionSignal.reason). */\n readonly note: string;\n}\n\n/**\n * Ordered env-marker table. Forks BEFORE parents (cursor — a VS Code fork —\n * precedes any future vscode-copilot entry so a Cursor session inside a\n * VS Code-derived shell is not misclassified). Markers are verified against\n * each host's source:\n *\n * - claude-code: CLAUDE_CODE_ENTRYPOINT is set on every Claude Code session;\n * CLAUDE_PLUGIN_ROOT is set when a plugin is loaded. Both are CC-exclusive\n * and serve as the disambiguators when CC runs inside another IDE's shell.\n * - codex: CODEX_THREAD_ID is set per exec (codex-rs/core exec_env);\n * CODEX_CI is set in CI mode (unified_exec process_manager).\n * - cursor: CURSOR_TRACE_ID is the widely-observed Cursor marker (Cursor\n * CLI / agent); CURSOR_CLI marks the Cursor terminal; CURSOR_CWD is the\n * documented workspace var.\n */\nconst RUNTIME_SIGNALS: readonly RuntimeSignalRule[] = [\n {\n platform: \"claude-code\",\n vars: [\"CLAUDE_CODE_ENTRYPOINT\", \"CLAUDE_PLUGIN_ROOT\", \"CLAUDE_PROJECT_DIR\", \"CLAUDE_SESSION_ID\"],\n note: \"Claude Code env marker set\",\n },\n {\n platform: \"cursor\",\n vars: [\"CURSOR_TRACE_ID\", \"CURSOR_CLI\", \"CURSOR_CWD\"],\n note: \"Cursor env marker set\",\n },\n {\n platform: \"codex\",\n vars: [\"CODEX_THREAD_ID\", \"CODEX_CI\"],\n note: \"Codex env marker set\",\n },\n];\n\n/**\n * Identify which host runtime is executing the current process from environment\n * markers. High confidence on an env-marker hit; otherwise an explicit\n * `AGENT_CONNECTOR_PLATFORM` override (high confidence, validated against the\n * registry) is honored; failing both, returns `unknown` at low confidence so\n * the caller can decide on a safe default.\n *\n * Pure with respect to its `env` argument (defaults to `process.env`) so it is\n * trivially testable — pass a synthetic env to assert each rule.\n */\nexport function detectRuntimeHost(env: NodeJS.ProcessEnv = process.env): DetectionSignal {\n // ── Explicit override (highest priority, validated against the registry) ──\n const override = env.AGENT_CONNECTOR_PLATFORM;\n if (override && override.trim() !== \"\") {\n if (REGISTERED_RUNTIME_IDS.has(override as PlatformId)) {\n return {\n platform: override as PlatformId,\n confidence: \"high\",\n reason: `AGENT_CONNECTOR_PLATFORM=${override} override`,\n };\n }\n }\n\n // ── Env-marker tier (forks before parents; first hit wins) ──────────────\n for (const rule of RUNTIME_SIGNALS) {\n const hit = rule.vars.find((name) => {\n const value = env[name];\n return typeof value === \"string\" && value !== \"\";\n });\n if (hit) {\n return {\n platform: rule.platform,\n confidence: \"high\",\n reason: `${rule.note} (${hit})`,\n };\n }\n }\n\n // ── Fallback: no host marker present ────────────────────────────────────\n return {\n platform: \"unknown\",\n confidence: \"low\",\n reason: \"no host runtime env marker detected\",\n };\n}\n\n/** Platform ids the runtime-signal table knows how to detect. */\nconst REGISTERED_RUNTIME_IDS: ReadonlySet<PlatformId> = new Set(\n RUNTIME_SIGNALS.map((rule) => rule.platform),\n);\n\n// Re-export for callers that resolve an adapter straight from a detection\n// result without reaching into registry.ts.\nexport { loadAdapter };\n"],"mappings":";;;AAkCO,IAAM,mBAA8C;AAAA,EACzD;AAAA,IACE,IAAI;AAAA,IACJ,MAAM,MAAM,OAAO,2BAAwB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,EACpE;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM,MAAM,OAAO,qBAAkB,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO;AAAA,EAC9D;AAAA,EACA;AAAA,IACE,IAAI;AAAA,IACJ,MAAM,MAAM,OAAO,sBAAmB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