@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,427 @@
1
+ /**
2
+ * core/types — the shared contract surface for agent-connector.
3
+ *
4
+ * Everything in this file is type-only (no runtime), so it is safe to import
5
+ * from anywhere without creating module cycles. It is the single source of
6
+ * truth that every adapter, the telemetry layer, the CLI, and the public API
7
+ * code against.
8
+ *
9
+ * Grounded in the understand-phase report (docs/research/understand-report.md)
10
+ * and generalized from context-mode's proven 15-platform adapter SPI:
11
+ * - context-mode hardcoded the served identity ("context-mode"); here the
12
+ * identity is a parameter the developer supplies via defineConnector().
13
+ * - context-mode's session/memory/FTS domain logic is removed from the SPI.
14
+ * - MCP server registration is modeled here (root key + format differ per
15
+ * platform, so adapters must render it — it is NOT "100% portable").
16
+ */
17
+ /**
18
+ * Stable identifiers for every host platform agent-connector can target.
19
+ *
20
+ * NOTE on usage-only platforms: `"synthetic"` is a TELEMETRY-ONLY id
21
+ * (Octofriend / synthetic.new). It has a usage reader (usage/readers/synthetic)
22
+ * but DELIBERATELY no deploy adapter and no ADAPTER_REGISTRY entry — Octofriend
23
+ * exposes no writable MCP config to install into. The registry-completeness test
24
+ * (tests/adapters/registry-completeness.test.ts) allowlists it for this reason.
25
+ */
26
+ type PlatformId = "claude-code" | "codex" | "cursor" | "vscode-copilot" | "jetbrains-copilot" | "copilot-cli" | "gemini-cli" | "opencode" | "kilo" | "kilo-cli" | "warp" | "hermes" | "openclaw" | "zed" | "antigravity" | "antigravity-cli" | "kiro" | "qwen-code" | "kimi" | "pi" | "omp" | "droid" | "roo-code" | "trae" | "amp" | "codebuff" | "mux" | "crush" | "goose" | "synthetic" | "unknown";
27
+ /**
28
+ * Hook I/O paradigm — the deepest cross-platform divergence (report §4).
29
+ * Canonical shipped sets (keep in sync with src/adapters/registry.ts — this
30
+ * comment once drifted and seeded a docs-wide misclassification):
31
+ * - "json-stdio" (16): host pipes JSON to a command on stdin, reads
32
+ * JSON/exit-code back — Claude Code, Codex, Cursor, VS Code/JetBrains
33
+ * Copilot, Copilot CLI, Gemini CLI, Qwen, Kiro, Kimi, Crush, Goose, Hermes,
34
+ * Droid (Factory), Antigravity (+ the agy CLI). One universal entrypoint
35
+ * binary handles all of them.
36
+ * - "ts-plugin" (4): host loads a JS/TS module exporting lifecycle functions
37
+ * — OpenCode, Kilo CLI, OMP, OpenClaw. Framework generates the module.
38
+ * - "mcp-only" (9): no hook layer at all — Warp, Kilo, Roo Code, Trae, Zed,
39
+ * Amp, Codebuff, Mux, Pi. Only the MCP server (or skills surface) is
40
+ * installed; hooks are reported unavailable.
41
+ */
42
+ type HookParadigm = "json-stdio" | "ts-plugin" | "mcp-only";
43
+ /**
44
+ * Install scope, normalized across platforms and ordered low→high precedence.
45
+ * Each adapter maps these to a concrete config path and knows which it supports.
46
+ */
47
+ type InstallScope = "system" | "user" | "project" | "profile" | "managed";
48
+ type Transport = "stdio" | "http" | "sse" | "ws";
49
+ interface ToolFilter {
50
+ /** Glob/exact tool names to expose. Default: ["*"]. */
51
+ include?: string[];
52
+ /** Glob/exact tool names to hide. */
53
+ exclude?: string[];
54
+ }
55
+ interface AuthSpec {
56
+ type: "oauth" | "bearerEnv" | "none";
57
+ /** Env var holding the bearer token when type === "bearerEnv". */
58
+ bearerEnvVar?: string;
59
+ }
60
+ /**
61
+ * A normalized, transport-polymorphic MCP server descriptor. Declared ONCE by
62
+ * the developer; each adapter renders it into that platform's native dialect
63
+ * (root key, field names, format). Adapters that cannot honor a requested
64
+ * transport downgrade-or-skip and report it — they never throw.
65
+ */
66
+ interface ServerDef {
67
+ transport: Transport;
68
+ command?: string;
69
+ args?: string[];
70
+ /** Env vars passed to the server process. Values support ${env:VAR} interpolation. */
71
+ env?: Record<string, string>;
72
+ cwd?: string;
73
+ url?: string;
74
+ headers?: Record<string, string>;
75
+ auth?: AuthSpec;
76
+ tools?: ToolFilter;
77
+ timeoutMs?: number;
78
+ /** Default true. When false, the entry is written disabled where supported. */
79
+ enabled?: boolean;
80
+ /**
81
+ * Wrap the server with `agent-connector serve` so per-tool telemetry is
82
+ * captured transparently. Default: true for stdio servers when telemetry is
83
+ * enabled; false for remote servers (cannot intercept) and when explicitly off.
84
+ */
85
+ wrapForTelemetry?: boolean;
86
+ }
87
+ /** Canonical, platform-agnostic lifecycle event names. */
88
+ type HookEventName = "SessionStart" | "SessionEnd" | "UserPromptSubmit" | "PreToolUse" | "PostToolUse" | "PreCompact" | "Stop" | "Notification";
89
+ interface BaseEvent {
90
+ /** Which host produced this event (from runtime detection). */
91
+ hostPlatform: PlatformId;
92
+ /** Connector id this event is dispatched to. */
93
+ connectorId: string;
94
+ /** Host session id (adapter-extracted; "" when the host provides none). */
95
+ sessionId: string;
96
+ /** Project directory if the host exposes one. */
97
+ projectDir?: string;
98
+ /** Raw host-specific payload for passthrough/escape-hatch use. */
99
+ raw: unknown;
100
+ }
101
+ interface PreToolUseEvent extends BaseEvent {
102
+ toolName: string;
103
+ toolInput: Record<string, unknown>;
104
+ }
105
+ interface PostToolUseEvent extends BaseEvent {
106
+ toolName: string;
107
+ toolInput: Record<string, unknown>;
108
+ toolOutput?: string;
109
+ isError?: boolean;
110
+ }
111
+ interface SessionStartEvent extends BaseEvent {
112
+ source: "startup" | "compact" | "resume" | "clear";
113
+ }
114
+ interface SessionEndEvent extends BaseEvent {
115
+ reason?: string;
116
+ }
117
+ interface UserPromptSubmitEvent extends BaseEvent {
118
+ prompt: string;
119
+ }
120
+ interface PreCompactEvent extends BaseEvent {
121
+ trigger?: "auto" | "manual";
122
+ }
123
+ interface StopEvent extends BaseEvent {
124
+ /** True when the stop hook itself was triggered during a previous stop hook. */
125
+ stopHookActive?: boolean;
126
+ }
127
+ interface NotificationEvent extends BaseEvent {
128
+ message: string;
129
+ }
130
+ /** Map of event name → its normalized payload type. */
131
+ interface EventPayloadMap {
132
+ SessionStart: SessionStartEvent;
133
+ SessionEnd: SessionEndEvent;
134
+ UserPromptSubmit: UserPromptSubmitEvent;
135
+ PreToolUse: PreToolUseEvent;
136
+ PostToolUse: PostToolUseEvent;
137
+ PreCompact: PreCompactEvent;
138
+ Stop: StopEvent;
139
+ Notification: NotificationEvent;
140
+ }
141
+ /**
142
+ * Normalized hook response. A handler returns a subset of these; the adapter
143
+ * formats it into the host's native reply (exit codes / JSON / control fields).
144
+ * Adapters drop fields the host cannot honor (e.g. updatedOutput where the host
145
+ * cannot rewrite tool output) and the framework reports the degradation.
146
+ */
147
+ interface HookResponse {
148
+ /**
149
+ * - "allow": pass through (default when handler returns void)
150
+ * - "deny": block tool execution / stop the action
151
+ * - "modify": replace tool input (PreToolUse) with `updatedInput`
152
+ * - "context": inject `additionalContext` as soft guidance
153
+ * - "ask": prompt the user to confirm
154
+ */
155
+ decision?: "allow" | "deny" | "modify" | "context" | "ask";
156
+ /** Shown to the model/user; required in spirit for deny/ask. */
157
+ reason?: string;
158
+ /** Replacement tool input — only meaningful with decision "modify". */
159
+ updatedInput?: Record<string, unknown>;
160
+ /** Extra context to inject — meaningful with "context" or on SessionStart. */
161
+ additionalContext?: string;
162
+ /** Rewritten tool output — only where the host supports it (PostToolUse). */
163
+ updatedOutput?: string;
164
+ }
165
+ /** A handler bound to one event, optionally filtered by a tool matcher. */
166
+ interface HookDefinition<E extends HookEventName = HookEventName> {
167
+ /**
168
+ * Regex string matched against the tool name (tool events only). Empty/omitted
169
+ * matches all. Rendered into each host's native matcher syntax where supported,
170
+ * else evaluated by the universal entrypoint at runtime.
171
+ */
172
+ matcher?: string;
173
+ handler(event: EventPayloadMap[E]): HookResponse | void | Promise<HookResponse | void>;
174
+ }
175
+ /** Developer-declared hooks, keyed by canonical event name. */
176
+ interface HooksConfig {
177
+ SessionStart?: HookDefinition<"SessionStart">;
178
+ SessionEnd?: HookDefinition<"SessionEnd">;
179
+ UserPromptSubmit?: HookDefinition<"UserPromptSubmit">;
180
+ PreToolUse?: HookDefinition<"PreToolUse">;
181
+ PostToolUse?: HookDefinition<"PostToolUse">;
182
+ PreCompact?: HookDefinition<"PreCompact">;
183
+ Stop?: HookDefinition<"Stop">;
184
+ Notification?: HookDefinition<"Notification">;
185
+ }
186
+ /** What a given host can actually honor. The single-API layer degrades to it. */
187
+ interface PlatformCapabilities {
188
+ preToolUse: boolean;
189
+ postToolUse: boolean;
190
+ preCompact: boolean;
191
+ sessionStart: boolean;
192
+ sessionEnd: boolean;
193
+ userPromptSubmit: boolean;
194
+ stop: boolean;
195
+ notification: boolean;
196
+ /** Can a PreToolUse hook rewrite tool arguments? */
197
+ canModifyArgs: boolean;
198
+ /** Can a PostToolUse hook rewrite tool output? */
199
+ canModifyOutput: boolean;
200
+ /** Can a hook inject context at session start / compaction? */
201
+ canInjectSessionContext: boolean;
202
+ /** MCP transports this host can register. */
203
+ transports: Transport[];
204
+ /**
205
+ * Content-surface support (all OPTIONAL so existing adapter capability
206
+ * literals compile unchanged; read as `?? false`). Only surface-supporting
207
+ * adapters set these true. The BaseAdapter install/uninstall defaults
208
+ * handle the "unsupported" skip/warn regardless of the flag.
209
+ */
210
+ supportsCommands?: boolean;
211
+ supportsSkills?: boolean;
212
+ supportsSubagents?: boolean;
213
+ }
214
+ /** Tool access expressed once; adapters render to allowed-tools / tools[] / readonly. */
215
+ interface SurfaceToolPolicy {
216
+ allow?: string[];
217
+ deny?: string[];
218
+ }
219
+ /** A slash command (= a Skill on 2026 Claude; adapters pick the right surface). */
220
+ interface CommandDef {
221
+ /** kebab-case; becomes the slash name and the filename stem. Source of truth. */
222
+ name: string;
223
+ /** One-line description for /help + model auto-selection. */
224
+ description?: string;
225
+ /** Prompt template body (markdown). The portable core of the command. */
226
+ prompt: string;
227
+ /** Shown in argument completion, e.g. "[environment]". */
228
+ argumentHint?: string;
229
+ tools?: SurfaceToolPolicy;
230
+ /** Model override (raw id or alias; adapters pass through or drop+warn). */
231
+ model?: string;
232
+ /** Force subagent / forked context where the platform supports it. */
233
+ subtask?: boolean;
234
+ /** Verbatim per-platform frontmatter additions (escape hatch). */
235
+ extra?: Record<string, unknown>;
236
+ }
237
+ /** An Agent Skill (folder + SKILL.md, Agent Skills open standard). */
238
+ interface SkillDef {
239
+ /** <=64 chars, [a-z0-9-]; MUST equal the skill dir name. Source of truth. */
240
+ name: string;
241
+ /** <=1024 chars, 3rd-person "what + when"; drives model auto-selection. Required. */
242
+ description: string;
243
+ /** SKILL.md markdown body (instructions). */
244
+ body: string;
245
+ tools?: SurfaceToolPolicy;
246
+ model?: string;
247
+ disableModelInvocation?: boolean;
248
+ /** Extra files bundled beside SKILL.md, relative path → contents. */
249
+ resources?: Record<string, string>;
250
+ extra?: Record<string, unknown>;
251
+ }
252
+ /** A named subagent (system-prompt + tool/model scoping). */
253
+ interface SubagentDef {
254
+ /** kebab-case identifier. Source of truth (filename stem on most platforms). */
255
+ name: string;
256
+ /** Delegation hint shown to the orchestrator. Required. */
257
+ description: string;
258
+ /** System prompt = the agent's instructions (markdown body / developer_instructions). */
259
+ prompt: string;
260
+ tools?: SurfaceToolPolicy;
261
+ /** Model: alias|full-id|"inherit". Default left to platform. */
262
+ model?: string;
263
+ /** Coarse permission knob → Cursor readonly, opencode/kilo permission map. */
264
+ readonly?: boolean;
265
+ extra?: Record<string, unknown>;
266
+ }
267
+ interface TelemetryConfig {
268
+ /** On by default. Global kill switch also via AGENT_CONNECTOR_TELEMETRY=0. */
269
+ enabled?: boolean;
270
+ /** Tokenizer family selection. "auto" infers from client/host. */
271
+ modelFamilyHint?: "auto" | "openai" | "anthropic" | "generic";
272
+ /** Tokenize tools/list schemas once → fixed per-turn tool-definition overhead. */
273
+ measureToolDefs?: boolean;
274
+ /** Opt-in network calibration (sends content off-box — off by default). */
275
+ calibration?: {
276
+ anthropicCountTokens?: boolean;
277
+ };
278
+ /**
279
+ * OPT-IN host-native turn-usage capture (off by default). When enabled, the
280
+ * Gemini / Antigravity adapters ALSO install an AfterModel / PostInvocation hook
281
+ * that reads the host's `usageMetadata` and records a DISTINCT `model_turn`
282
+ * telemetry row (confidence `host-native`). Whole-conversation, never summed with
283
+ * the per-MCP `call` rows. May also be forced on at install via the env switch
284
+ * AGENT_CONNECTOR_HOST_NATIVE=1. Aggregate counts only; no raw content stored.
285
+ */
286
+ hostNativeUsage?: boolean;
287
+ /** Storage backend. NDJSON (default) needs no native deps; sqlite is an upgrade. */
288
+ store?: "ndjson" | "sqlite";
289
+ }
290
+ /** Per-platform override / escape hatch (report §3.2). */
291
+ interface PlatformOverride {
292
+ /** false → do not install hooks on this platform; object → merge/replace hooks. */
293
+ hooks?: boolean | Partial<HooksConfig>;
294
+ /** false → do not register the MCP server here; object → shallow-merge into ServerDef. */
295
+ server?: Partial<ServerDef> | false;
296
+ /** Force a specific scope for this platform. */
297
+ scope?: InstallScope;
298
+ /** false → skip command files on this platform. */
299
+ commands?: boolean;
300
+ /** false → skip skill files on this platform. */
301
+ skills?: boolean;
302
+ /** false → skip subagent files on this platform. */
303
+ subagents?: boolean;
304
+ /** Verbatim fields merged into the native config (reach platform-exclusive features). */
305
+ extra?: Record<string, unknown>;
306
+ }
307
+ /**
308
+ * Distribution metadata for the OFFICIAL MCP standard artifacts `package` can
309
+ * emit — the registry `server.json` and the MCPB `.mcpb` bundle. These describe
310
+ * the developer's REAL upstream MCP server (what a registry installer / Claude
311
+ * Desktop runs directly), NOT agent-connector's telemetry `serve` wrapper, so
312
+ * they need inputs the cross-platform install does not: the namespace the dev
313
+ * proved ownership of, their published package name, and bundle author info.
314
+ *
315
+ * All optional — a connector that never publishes to the registry or as a
316
+ * bundle can omit this entirely; the relevant `package --format` raises a clear,
317
+ * actionable error only when its required field is missing.
318
+ */
319
+ interface PublishConfig {
320
+ /**
321
+ * Reverse-DNS namespace the developer OWNS, e.g. "io.github.acme" or
322
+ * "com.acme". server.json `name` is rendered as `${registryNamespace}/${id}`.
323
+ * agent-connector never mints a namespace on the dev's behalf — the registry
324
+ * requires proven ownership (the `mcp-publisher login` step the dev runs).
325
+ */
326
+ registryNamespace?: string;
327
+ /**
328
+ * The developer's REAL published package that runs the MCP server, e.g.
329
+ * "@acme/acme-db-mcp" — server.json packages[].identifier. Required to emit a
330
+ * registry npm package entry (we cannot guess the published name).
331
+ */
332
+ packageName?: string;
333
+ /** Package registry base URL. Default https://registry.npmjs.org for npm. */
334
+ registryBaseUrl?: string;
335
+ /** Bundle author. The MCPB manifest requires author.name. */
336
+ author?: {
337
+ name: string;
338
+ email?: string;
339
+ url?: string;
340
+ };
341
+ }
342
+ /** What a developer passes to defineConnector(). */
343
+ interface ConnectorConfig {
344
+ /** Stable connector id (kebab-case). Replaces context-mode's hardcoded identity. */
345
+ id: string;
346
+ displayName?: string;
347
+ version?: string;
348
+ /** The MCP server to deploy. Omit for a hooks-only connector. */
349
+ server?: ServerDef;
350
+ /** Lifecycle hooks. Omit for a server-only connector. */
351
+ hooks?: HooksConfig;
352
+ /** Telemetry options. Telemetry is ON by default even if this is omitted. */
353
+ telemetry?: TelemetryConfig;
354
+ /** Slash commands to deploy as native content files. */
355
+ commands?: CommandDef[];
356
+ /** Agent Skills to deploy as native content files. */
357
+ skills?: SkillDef[];
358
+ /** Named subagents to deploy as native content files. */
359
+ subagents?: SubagentDef[];
360
+ /** Per-platform overrides / escape hatches. */
361
+ platforms?: Partial<Record<PlatformId, PlatformOverride>>;
362
+ /** "auto" (all detected) or an explicit allow-list. Default "auto". */
363
+ targets?: "auto" | PlatformId[];
364
+ /** Distribution metadata for the registry server.json + MCPB bundle formats. */
365
+ publish?: PublishConfig;
366
+ }
367
+ /**
368
+ * A validated, normalized connector — what defineConnector() returns and what
369
+ * adapters/CLI consume. All optional config fields are resolved to defaults.
370
+ */
371
+ interface ResolvedConnector {
372
+ id: string;
373
+ displayName: string;
374
+ version: string;
375
+ server?: ServerDef;
376
+ hooks: HooksConfig;
377
+ hookEvents: HookEventName[];
378
+ telemetry: Required<Omit<TelemetryConfig, "calibration">> & {
379
+ calibration: {
380
+ anthropicCountTokens: boolean;
381
+ };
382
+ };
383
+ /** Normalized commands; defaults applied; [] when none. */
384
+ commands: CommandDef[];
385
+ /** Normalized skills; defaults applied; [] when none. */
386
+ skills: SkillDef[];
387
+ /** Normalized subagents; defaults applied; [] when none. */
388
+ subagents: SubagentDef[];
389
+ platforms: Partial<Record<PlatformId, PlatformOverride>>;
390
+ targets: "auto" | PlatformId[];
391
+ /** Distribution metadata (registry server.json + MCPB bundle); passed through verbatim. */
392
+ publish?: PublishConfig;
393
+ }
394
+ /** Result of detecting one platform on this machine. */
395
+ interface DetectedPlatform {
396
+ id: PlatformId;
397
+ name: string;
398
+ installed: boolean;
399
+ paradigm: HookParadigm;
400
+ capabilities: PlatformCapabilities;
401
+ /** Native config path that would be written for `scope`. */
402
+ configPath: string;
403
+ scope: InstallScope;
404
+ reason: string;
405
+ confidence: "high" | "medium" | "low";
406
+ }
407
+ interface ChangeRecord {
408
+ platform: PlatformId;
409
+ action: "create" | "update" | "skip" | "remove" | "warn";
410
+ /** File touched (when applicable). */
411
+ path?: string;
412
+ detail: string;
413
+ }
414
+ interface InstallResult {
415
+ connectorId: string;
416
+ dryRun: boolean;
417
+ changes: ChangeRecord[];
418
+ warnings: string[];
419
+ }
420
+ interface DiagnosticResult {
421
+ check: string;
422
+ status: "pass" | "fail" | "warn";
423
+ message: string;
424
+ fix?: string;
425
+ }
426
+
427
+ export type { AuthSpec as A, ConnectorConfig as C, DetectedPlatform as D, EventPayloadMap as E, HookDefinition as H, InstallResult as I, NotificationEvent as N, PlatformCapabilities as P, ResolvedConnector as R, ServerDef as S, TelemetryConfig as T, UserPromptSubmitEvent as U, ChangeRecord as a, DiagnosticResult as b, HookEventName as c, HookParadigm as d, HookResponse as e, HooksConfig as f, InstallScope as g, PlatformId as h, PlatformOverride as i, PostToolUseEvent as j, PreCompactEvent as k, PreToolUseEvent as l, SessionEndEvent as m, SessionStartEvent as n, StopEvent as o, ToolFilter as p, Transport as q };
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ uninstallConnector
4
+ } from "./chunk-7MSDGHJW.js";
5
+ import {
6
+ fail,
7
+ parseScope,
8
+ parseTargets,
9
+ print,
10
+ renderInstallResult
11
+ } from "./chunk-54EMKTTX.js";
12
+ import "./chunk-KHO5WNTP.js";
13
+ import "./chunk-XUCWLJY5.js";
14
+ import {
15
+ findConnectorConfig,
16
+ loadConnectorFromPath
17
+ } from "./chunk-LTT56GI3.js";
18
+ import "./chunk-XNAM7F35.js";
19
+ import "./chunk-TRQKHP7D.js";
20
+
21
+ // src/cli/commands/uninstall.ts
22
+ import { parseArgs } from "util";
23
+ async function resolveConnectorId(explicitId, connectorPath, projectDir) {
24
+ if (explicitId && explicitId.trim() !== "") return explicitId;
25
+ const configPath = connectorPath ?? findConnectorConfig(projectDir);
26
+ if (!configPath) return null;
27
+ const { connector } = await loadConnectorFromPath(configPath);
28
+ return connector.id;
29
+ }
30
+ async function run(argv) {
31
+ const { values } = parseArgs({
32
+ args: argv,
33
+ options: {
34
+ scope: { type: "string", default: "user" },
35
+ targets: { type: "string" },
36
+ connector: { type: "string" },
37
+ "connector-id": { type: "string" },
38
+ project: { type: "string" },
39
+ "dry-run": { type: "boolean", default: false },
40
+ purge: { type: "boolean", default: false }
41
+ },
42
+ allowPositionals: false
43
+ });
44
+ const projectDir = values.project ?? process.cwd();
45
+ const scope = parseScope(values.scope);
46
+ if (scope == null) return fail(`invalid --scope "${values.scope}" (use user|project)`);
47
+ const connectorId = await resolveConnectorId(
48
+ values["connector-id"],
49
+ values.connector,
50
+ projectDir
51
+ );
52
+ if (!connectorId) {
53
+ return fail(
54
+ "could not determine connector id. Pass --connector-id <id>, --connector <path>, or run inside a project with an agent-connector config."
55
+ );
56
+ }
57
+ const targets = parseTargets(values.targets);
58
+ const result = await uninstallConnector({
59
+ connectorId,
60
+ scope,
61
+ projectDir,
62
+ dryRun: values["dry-run"],
63
+ purge: values.purge,
64
+ ...targets ? { targets } : {}
65
+ });
66
+ print(renderInstallResult(result, "uninstall"));
67
+ return result.changes.some((c) => c.action === "warn") ? 1 : 0;
68
+ }
69
+ export {
70
+ run
71
+ };
72
+ //# sourceMappingURL=uninstall-IGCKNOSF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/commands/uninstall.ts"],"sourcesContent":["/**\n * cli/commands/uninstall — strip a connector's MCP + hook registrations.\n *\n * The connector id is taken from --connector-id, or inferred from the local\n * connector config (--connector <path> / findConnectorConfig). The installer's\n * uninstall orchestration loads the registered connector for context and removes\n * its entries from every resolved target.\n *\n * --purge additionally removes the framework-state this connector left behind:\n * its DATA-dir connector record (connectorDir(id)) and, when no connectors\n * remain, the shared home-bin launcher. Without --purge those linger so the\n * connector can be re-synced without re-registering.\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport { uninstallConnector } from \"../../core/installer.js\";\nimport { findConnectorConfig, loadConnectorFromPath } from \"../../core/load-connector.js\";\nimport { fail, parseScope, parseTargets, print, renderInstallResult } from \"../app.js\";\n\n/** Resolve the connector id from flags, then from a local config file. */\nasync function resolveConnectorId(\n explicitId: string | undefined,\n connectorPath: string | undefined,\n projectDir: string,\n): Promise<string | null> {\n if (explicitId && explicitId.trim() !== \"\") return explicitId;\n const configPath = connectorPath ?? findConnectorConfig(projectDir);\n if (!configPath) return null;\n const { connector } = await loadConnectorFromPath(configPath);\n return connector.id;\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 targets: { type: \"string\" },\n connector: { type: \"string\" },\n \"connector-id\": { type: \"string\" },\n project: { type: \"string\" },\n \"dry-run\": { type: \"boolean\", default: false },\n purge: { type: \"boolean\", default: false },\n },\n allowPositionals: false,\n });\n\n const projectDir = values.project ?? process.cwd();\n\n const scope = parseScope(values.scope);\n if (scope == null) return fail(`invalid --scope \"${values.scope}\" (use user|project)`);\n\n const connectorId = await resolveConnectorId(\n values[\"connector-id\"],\n values.connector,\n projectDir,\n );\n if (!connectorId) {\n return fail(\n \"could not determine connector id. Pass --connector-id <id>, \" +\n \"--connector <path>, or run inside a project with an agent-connector config.\",\n );\n }\n\n const targets = parseTargets(values.targets);\n\n const result = await uninstallConnector({\n connectorId,\n scope,\n projectDir,\n dryRun: values[\"dry-run\"],\n purge: values.purge,\n ...(targets ? { targets } : {}),\n });\n\n print(renderInstallResult(result, \"uninstall\"));\n return result.changes.some((c) => c.action === \"warn\") ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAcA,SAAS,iBAAiB;AAO1B,eAAe,mBACb,YACA,eACA,YACwB;AACxB,MAAI,cAAc,WAAW,KAAK,MAAM,GAAI,QAAO;AACnD,QAAM,aAAa,iBAAiB,oBAAoB,UAAU;AAClE,MAAI,CAAC,WAAY,QAAO;AACxB,QAAM,EAAE,UAAU,IAAI,MAAM,sBAAsB,UAAU;AAC5D,SAAO,UAAU;AACnB;AAEA,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,SAAS,EAAE,MAAM,SAAS;AAAA,MAC1B,WAAW,EAAE,MAAM,SAAS;AAAA,MAC5B,gBAAgB,EAAE,MAAM,SAAS;AAAA,MACjC,SAAS,EAAE,MAAM,SAAS;AAAA,MAC1B,WAAW,EAAE,MAAM,WAAW,SAAS,MAAM;AAAA,MAC7C,OAAO,EAAE,MAAM,WAAW,SAAS,MAAM;AAAA,IAC3C;AAAA,IACA,kBAAkB;AAAA,EACpB,CAAC;AAED,QAAM,aAAa,OAAO,WAAW,QAAQ,IAAI;AAEjD,QAAM,QAAQ,WAAW,OAAO,KAAK;AACrC,MAAI,SAAS,KAAM,QAAO,KAAK,oBAAoB,OAAO,KAAK,sBAAsB;AAErF,QAAM,cAAc,MAAM;AAAA,IACxB,OAAO,cAAc;AAAA,IACrB,OAAO;AAAA,IACP;AAAA,EACF;AACA,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,MACL;AAAA,IAEF;AAAA,EACF;AAEA,QAAM,UAAU,aAAa,OAAO,OAAO;AAE3C,QAAM,SAAS,MAAM,mBAAmB;AAAA,IACtC;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ,OAAO,SAAS;AAAA,IACxB,OAAO,OAAO;AAAA,IACd,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,EAC/B,CAAC;AAED,QAAM,oBAAoB,QAAQ,WAAW,CAAC;AAC9C,SAAO,OAAO,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,IAAI,IAAI;AAC/D;","names":[]}
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ resolveCliEntry,
4
+ syncConnector
5
+ } from "./chunk-7MSDGHJW.js";
6
+ import {
7
+ fail,
8
+ parseScope,
9
+ parseTargets,
10
+ print,
11
+ renderInstallResult
12
+ } from "./chunk-54EMKTTX.js";
13
+ import "./chunk-KHO5WNTP.js";
14
+ import "./chunk-XUCWLJY5.js";
15
+ import {
16
+ findConnectorConfig,
17
+ loadConnectorFromPath
18
+ } from "./chunk-LTT56GI3.js";
19
+ import "./chunk-XNAM7F35.js";
20
+ import {
21
+ ensureHomeBin,
22
+ homeBinPath
23
+ } from "./chunk-TRQKHP7D.js";
24
+
25
+ // src/cli/commands/upgrade.ts
26
+ import { parseArgs } from "util";
27
+ function looksNpmManaged() {
28
+ const entry = resolveCliEntry().replace(/\\/g, "/");
29
+ return entry.includes("/node_modules/");
30
+ }
31
+ async function run(argv) {
32
+ const { values } = parseArgs({
33
+ args: argv,
34
+ options: {
35
+ channel: { type: "string", default: "stable" },
36
+ scope: { type: "string", default: "user" },
37
+ targets: { type: "string" },
38
+ connector: { type: "string" },
39
+ project: { type: "string" },
40
+ "dry-run": { type: "boolean", default: false }
41
+ },
42
+ allowPositionals: false
43
+ });
44
+ const channel = values.channel;
45
+ if (channel !== "stable" && channel !== "latest") {
46
+ return fail(`invalid --channel "${channel}" (use stable|latest)`);
47
+ }
48
+ const ch = channel;
49
+ const scope = parseScope(values.scope);
50
+ if (scope == null) return fail(`invalid --scope "${values.scope}" (use user|project)`);
51
+ let hadWarn = false;
52
+ const projectDir = values.project ?? process.cwd();
53
+ const configPath = values.connector ?? findConnectorConfig(projectDir);
54
+ if (configPath) {
55
+ const { connector, modulePath } = await loadConnectorFromPath(configPath);
56
+ const targets = parseTargets(values.targets);
57
+ const result = await syncConnector({
58
+ connector,
59
+ modulePath,
60
+ scope,
61
+ projectDir,
62
+ dryRun: values["dry-run"],
63
+ ...targets ? { targets } : {}
64
+ });
65
+ print(renderInstallResult(result, "upgrade"));
66
+ if (result.changes.some((c) => c.action === "warn")) hadWarn = true;
67
+ print("");
68
+ } else {
69
+ print("upgrade: no connector config found \u2014 refreshing the tool only.");
70
+ print(
71
+ "(pass --connector <path> or run inside a project to also re-render host config.)\n"
72
+ );
73
+ }
74
+ print("agent-connector uses managed (explicit) updates \u2014 never silent");
75
+ print("auto-update \u2014 so one bad release can't break every project at once.\n");
76
+ const dist = ch === "stable" ? "latest" : "next";
77
+ if (looksNpmManaged()) {
78
+ print(`To update the ${ch} channel, run:`);
79
+ print(` npm i -g @ken-jo/agent-connector@${dist}`);
80
+ } else {
81
+ print(
82
+ `This install does not look npm-managed. Update it the way you installed it,`
83
+ );
84
+ print(`then re-run \`agent-connector upgrade\` to refresh the home pointer.`);
85
+ print(`(npm installs would use: npm i -g @ken-jo/agent-connector@${dist})`);
86
+ }
87
+ if (!values["dry-run"]) {
88
+ try {
89
+ const binPath = ensureHomeBin(resolveCliEntry());
90
+ print(`
91
+ Refreshed home binary pointer: ${binPath}`);
92
+ } catch (err) {
93
+ const message = err instanceof Error ? err.message : String(err);
94
+ print(`
95
+ [warn] could not refresh home binary at ${homeBinPath()}: ${message}`);
96
+ return 1;
97
+ }
98
+ }
99
+ return hadWarn ? 1 : 0;
100
+ }
101
+ export {
102
+ run
103
+ };
104
+ //# sourceMappingURL=upgrade-JV2VK242.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/commands/upgrade.ts"],"sourcesContent":["/**\n * cli/commands/upgrade — bring an agent-connector install current.\n *\n * `upgrade` (aliases: `update`, `sync`) consolidates the two former verbs into\n * ONE the way npm/brew pair `install` + `upgrade`, so there is a single verb to\n * learn for \"make everything current\". It:\n *\n * 1. re-renders the connector's config into every target host idempotently\n * (identical entries report \"skip\"), exactly like the old `sync` — this is\n * also the self-heal path: run `upgrade` to repair a drifted install; then\n * 2. refreshes the stable home-bin pointer and prints managed (never-silent)\n * update guidance for the chosen channel, exactly like the old `update`.\n *\n * When no connector config is resolvable it still does step 2, so `upgrade`\n * works as a pure tool-refresh from anywhere. By design agent-connector NEVER\n * silently auto-updates (docs/ARCHITECTURE.md §3 R1).\n */\n\nimport { parseArgs } from \"node:util\";\n\nimport { resolveCliEntry, syncConnector } from \"../../core/installer.js\";\nimport { findConnectorConfig, loadConnectorFromPath } from \"../../core/load-connector.js\";\nimport { ensureHomeBin, homeBinPath } from \"../../core/paths.js\";\nimport { fail, parseScope, parseTargets, print, renderInstallResult } from \"../app.js\";\n\ntype Channel = \"stable\" | \"latest\";\n\n/** Heuristic: does the running CLI live under an npm-style node_modules tree? */\nfunction looksNpmManaged(): boolean {\n const entry = resolveCliEntry().replace(/\\\\/g, \"/\");\n return entry.includes(\"/node_modules/\");\n}\n\nexport async function run(argv: string[]): Promise<number> {\n const { values } = parseArgs({\n args: argv,\n options: {\n channel: { type: \"string\", default: \"stable\" },\n scope: { type: \"string\", default: \"user\" },\n targets: { type: \"string\" },\n connector: { type: \"string\" },\n project: { type: \"string\" },\n \"dry-run\": { type: \"boolean\", default: false },\n },\n allowPositionals: false,\n });\n\n const channel = values.channel;\n if (channel !== \"stable\" && channel !== \"latest\") {\n return fail(`invalid --channel \"${channel}\" (use stable|latest)`);\n }\n const ch: Channel = channel;\n\n const scope = parseScope(values.scope);\n if (scope == null) return fail(`invalid --scope \"${values.scope}\" (use user|project)`);\n\n let hadWarn = false;\n\n // ── Step 1: re-render the connector into every target host (former `sync`). ──\n const projectDir = values.project ?? process.cwd();\n const configPath = values.connector ?? findConnectorConfig(projectDir);\n if (configPath) {\n const { connector, modulePath } = await loadConnectorFromPath(configPath);\n const targets = parseTargets(values.targets);\n const result = await syncConnector({\n connector,\n modulePath,\n scope,\n projectDir,\n dryRun: values[\"dry-run\"],\n ...(targets ? { targets } : {}),\n });\n print(renderInstallResult(result, \"upgrade\"));\n if (result.changes.some((c) => c.action === \"warn\")) hadWarn = true;\n print(\"\");\n } else {\n print(\"upgrade: no connector config found — refreshing the tool only.\");\n print(\n \"(pass --connector <path> or run inside a project to also re-render host config.)\\n\",\n );\n }\n\n // ── Step 2: managed update guidance + home-bin pointer refresh (former `update`). ──\n print(\"agent-connector uses managed (explicit) updates — never silent\");\n print(\"auto-update — so one bad release can't break every project at once.\\n\");\n\n const dist = ch === \"stable\" ? \"latest\" : \"next\";\n if (looksNpmManaged()) {\n print(`To update the ${ch} channel, run:`);\n print(` npm i -g @ken-jo/agent-connector@${dist}`);\n } else {\n print(\n `This install does not look npm-managed. Update it the way you installed it,`,\n );\n print(`then re-run \\`agent-connector upgrade\\` to refresh the home pointer.`);\n print(`(npm installs would use: npm i -g @ken-jo/agent-connector@${dist})`);\n }\n\n // Refresh the stable home-bin pointer so hosts keep execing a working CLI.\n if (!values[\"dry-run\"]) {\n try {\n const binPath = ensureHomeBin(resolveCliEntry());\n print(`\\nRefreshed home binary pointer: ${binPath}`);\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n print(`\\n[warn] could not refresh home binary at ${homeBinPath()}: ${message}`);\n return 1;\n }\n }\n\n return hadWarn ? 1 : 0;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,iBAAiB;AAU1B,SAAS,kBAA2B;AAClC,QAAM,QAAQ,gBAAgB,EAAE,QAAQ,OAAO,GAAG;AAClD,SAAO,MAAM,SAAS,gBAAgB;AACxC;AAEA,eAAsB,IAAI,MAAiC;AACzD,QAAM,EAAE,OAAO,IAAI,UAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,MACP,SAAS,EAAE,MAAM,UAAU,SAAS,SAAS;AAAA,MAC7C,OAAO,EAAE,MAAM,UAAU,SAAS,OAAO;AAAA,MACzC,SAAS,EAAE,MAAM,SAAS;AAAA,MAC1B,WAAW,EAAE,MAAM,SAAS;AAAA,MAC5B,SAAS,EAAE,MAAM,SAAS;AAAA,MAC1B,WAAW,EAAE,MAAM,WAAW,SAAS,MAAM;AAAA,IAC/C;AAAA,IACA,kBAAkB;AAAA,EACpB,CAAC;AAED,QAAM,UAAU,OAAO;AACvB,MAAI,YAAY,YAAY,YAAY,UAAU;AAChD,WAAO,KAAK,sBAAsB,OAAO,uBAAuB;AAAA,EAClE;AACA,QAAM,KAAc;AAEpB,QAAM,QAAQ,WAAW,OAAO,KAAK;AACrC,MAAI,SAAS,KAAM,QAAO,KAAK,oBAAoB,OAAO,KAAK,sBAAsB;AAErF,MAAI,UAAU;AAGd,QAAM,aAAa,OAAO,WAAW,QAAQ,IAAI;AACjD,QAAM,aAAa,OAAO,aAAa,oBAAoB,UAAU;AACrE,MAAI,YAAY;AACd,UAAM,EAAE,WAAW,WAAW,IAAI,MAAM,sBAAsB,UAAU;AACxE,UAAM,UAAU,aAAa,OAAO,OAAO;AAC3C,UAAM,SAAS,MAAM,cAAc;AAAA,MACjC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,QAAQ,OAAO,SAAS;AAAA,MACxB,GAAI,UAAU,EAAE,QAAQ,IAAI,CAAC;AAAA,IAC/B,CAAC;AACD,UAAM,oBAAoB,QAAQ,SAAS,CAAC;AAC5C,QAAI,OAAO,QAAQ,KAAK,CAAC,MAAM,EAAE,WAAW,MAAM,EAAG,WAAU;AAC/D,UAAM,EAAE;AAAA,EACV,OAAO;AACL,UAAM,qEAAgE;AACtE;AAAA,MACE;AAAA,IACF;AAAA,EACF;AAGA,QAAM,qEAAgE;AACtE,QAAM,4EAAuE;AAE7E,QAAM,OAAO,OAAO,WAAW,WAAW;AAC1C,MAAI,gBAAgB,GAAG;AACrB,UAAM,iBAAiB,EAAE,gBAAgB;AACzC,UAAM,sCAAsC,IAAI,EAAE;AAAA,EACpD,OAAO;AACL;AAAA,MACE;AAAA,IACF;AACA,UAAM,sEAAsE;AAC5E,UAAM,6DAA6D,IAAI,GAAG;AAAA,EAC5E;AAGA,MAAI,CAAC,OAAO,SAAS,GAAG;AACtB,QAAI;AACF,YAAM,UAAU,cAAc,gBAAgB,CAAC;AAC/C,YAAM;AAAA,iCAAoC,OAAO,EAAE;AAAA,IACrD,SAAS,KAAK;AACZ,YAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;AAC/D,YAAM;AAAA,0CAA6C,YAAY,CAAC,KAAK,OAAO,EAAE;AAC9E,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO,UAAU,IAAI;AACvB;","names":[]}