@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,593 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ getTokenizer,
4
+ inferModelFamily,
5
+ openStore,
6
+ worstConfidence
7
+ } from "./chunk-BCHWFTV4.js";
8
+
9
+ // src/telemetry/surface-footprint.ts
10
+ function countParts(parts, family, tok) {
11
+ return tok.count(parts.join("\n"), family).tokens;
12
+ }
13
+ function computeSurfaceFootprints(connector, tok = getTokenizer()) {
14
+ const family = inferModelFamily("", connector.telemetry.modelFamilyHint);
15
+ const out = [];
16
+ for (const cmd of connector.commands) {
17
+ const parts = [];
18
+ if (cmd.description !== void 0) parts.push(cmd.description);
19
+ parts.push(cmd.prompt);
20
+ if (cmd.argumentHint !== void 0) parts.push(cmd.argumentHint);
21
+ out.push({
22
+ surfaceKind: "command",
23
+ name: cmd.name,
24
+ tokens: countParts(parts, family, tok)
25
+ });
26
+ }
27
+ for (const skill of connector.skills) {
28
+ const parts = [skill.description, skill.body];
29
+ if (skill.resources !== void 0) {
30
+ const paths = Object.keys(skill.resources).sort();
31
+ for (const p of paths) {
32
+ const value = skill.resources[p];
33
+ if (value !== void 0) parts.push(value);
34
+ }
35
+ }
36
+ out.push({
37
+ surfaceKind: "skill",
38
+ name: skill.name,
39
+ tokens: countParts(parts, family, tok)
40
+ });
41
+ }
42
+ for (const agent of connector.subagents) {
43
+ out.push({
44
+ surfaceKind: "subagent",
45
+ name: agent.name,
46
+ tokens: countParts([agent.description, agent.prompt], family, tok)
47
+ });
48
+ }
49
+ return out;
50
+ }
51
+
52
+ // src/telemetry/leaderboard.ts
53
+ var SCOPE_FILTER_VALUES = [
54
+ "user",
55
+ "project",
56
+ "npx",
57
+ "bunx",
58
+ "uvx",
59
+ "node",
60
+ "binary",
61
+ "http",
62
+ "unknown"
63
+ ];
64
+ function isScopeFilter(value) {
65
+ return SCOPE_FILTER_VALUES.includes(value);
66
+ }
67
+ var INSTALL_SCOPES = /* @__PURE__ */ new Set(["user", "project"]);
68
+ function matchesScope(record, scope) {
69
+ if (scope === "unknown") {
70
+ return record.installScope === void 0 && record.launchMethod === void 0;
71
+ }
72
+ if (INSTALL_SCOPES.has(scope)) {
73
+ return record.installScope === scope;
74
+ }
75
+ return record.launchMethod === scope;
76
+ }
77
+ function toFilter(opts) {
78
+ const filter = {};
79
+ if (opts.sinceMs !== void 0) filter.sinceMs = opts.sinceMs;
80
+ if (opts.connectorId !== void 0 && opts.connectorId !== "") {
81
+ filter.connectorId = opts.connectorId;
82
+ }
83
+ return filter;
84
+ }
85
+ function selectRecords(opts, includeModelTurn = false) {
86
+ const store = opts.store ?? openStore({});
87
+ const owned = opts.store === void 0;
88
+ try {
89
+ let rows = store.query(toFilter(opts));
90
+ rows = includeModelTurn ? rows.filter((r) => r.scope === "model_turn") : rows.filter((r) => r.scope !== "model_turn");
91
+ if (opts.scope === void 0) return rows;
92
+ const scope = opts.scope;
93
+ return rows.filter((r) => matchesScope(r, scope));
94
+ } finally {
95
+ if (owned) store.close();
96
+ }
97
+ }
98
+ function mcpLeaderboard(opts = {}) {
99
+ const groups = /* @__PURE__ */ new Map();
100
+ for (const r of selectRecords(opts)) {
101
+ let g = groups.get(r.connectorId);
102
+ if (g === void 0) {
103
+ g = {
104
+ connectorId: r.connectorId,
105
+ calls: 0,
106
+ inputTokens: 0,
107
+ outputTokens: 0,
108
+ totalTokens: 0,
109
+ tools: /* @__PURE__ */ new Set(),
110
+ hostPlatforms: /* @__PURE__ */ new Set(),
111
+ confidence: r.confidenceSource,
112
+ lastTs: r.ts
113
+ };
114
+ groups.set(r.connectorId, g);
115
+ }
116
+ if (r.scope === "call") {
117
+ g.calls += 1;
118
+ g.tools.add(r.toolName);
119
+ }
120
+ g.inputTokens += r.inputTokens;
121
+ g.outputTokens += r.outputTokens;
122
+ g.totalTokens += r.inputTokens + r.outputTokens;
123
+ g.hostPlatforms.add(r.hostPlatform);
124
+ g.confidence = worstConfidence(g.confidence, r.confidenceSource);
125
+ if (r.ts > g.lastTs) g.lastTs = r.ts;
126
+ }
127
+ const rows = [];
128
+ for (const g of groups.values()) {
129
+ rows.push({
130
+ connectorId: g.connectorId,
131
+ calls: g.calls,
132
+ inputTokens: g.inputTokens,
133
+ outputTokens: g.outputTokens,
134
+ totalTokens: g.totalTokens,
135
+ tools: g.tools.size,
136
+ hostPlatforms: [...g.hostPlatforms].sort(),
137
+ confidence: g.confidence,
138
+ lastTs: g.lastTs
139
+ });
140
+ }
141
+ rows.sort((a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs);
142
+ return rows;
143
+ }
144
+ function toolLeaderboard(opts = {}) {
145
+ const groups = /* @__PURE__ */ new Map();
146
+ for (const r of selectRecords(opts)) {
147
+ const key = `${r.connectorId}\0${r.toolName}\0${r.scope}`;
148
+ const g = groups.get(key);
149
+ if (g === void 0) {
150
+ groups.set(key, {
151
+ connectorId: r.connectorId,
152
+ toolName: r.toolName,
153
+ scope: r.scope,
154
+ calls: r.scope === "call" ? 1 : 0,
155
+ inputTokens: r.inputTokens,
156
+ outputTokens: r.outputTokens,
157
+ totalTokens: r.inputTokens + r.outputTokens,
158
+ confidence: r.confidenceSource,
159
+ lastTs: r.ts
160
+ });
161
+ } else {
162
+ if (r.scope === "call") g.calls += 1;
163
+ g.inputTokens += r.inputTokens;
164
+ g.outputTokens += r.outputTokens;
165
+ g.totalTokens += r.inputTokens + r.outputTokens;
166
+ g.confidence = worstConfidence(g.confidence, r.confidenceSource);
167
+ if (r.ts > g.lastTs) g.lastTs = r.ts;
168
+ }
169
+ }
170
+ const rows = [...groups.values()];
171
+ rows.sort((a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs);
172
+ return rows;
173
+ }
174
+ function hostNativeTurns(opts = {}) {
175
+ const groups = /* @__PURE__ */ new Map();
176
+ for (const r of selectRecords(
177
+ opts,
178
+ /* includeModelTurn */
179
+ true
180
+ )) {
181
+ const key = `${r.hostPlatform}\0${r.sessionId}`;
182
+ let g = groups.get(key);
183
+ if (g === void 0) {
184
+ g = {
185
+ hostPlatform: r.hostPlatform,
186
+ sessionId: r.sessionId,
187
+ turns: 0,
188
+ inputTokens: 0,
189
+ outputTokens: 0,
190
+ totalTokens: 0,
191
+ connectors: /* @__PURE__ */ new Set(),
192
+ confidence: r.confidenceSource,
193
+ lastTs: r.ts
194
+ };
195
+ groups.set(key, g);
196
+ }
197
+ g.turns += 1;
198
+ g.inputTokens += r.inputTokens;
199
+ g.outputTokens += r.outputTokens;
200
+ g.totalTokens += r.inputTokens + r.outputTokens;
201
+ g.connectors.add(r.connectorId);
202
+ g.confidence = worstConfidence(g.confidence, r.confidenceSource);
203
+ if (r.ts > g.lastTs) g.lastTs = r.ts;
204
+ }
205
+ const rows = [];
206
+ for (const g of groups.values()) {
207
+ rows.push({
208
+ hostPlatform: g.hostPlatform,
209
+ sessionId: g.sessionId,
210
+ turns: g.turns,
211
+ inputTokens: g.inputTokens,
212
+ outputTokens: g.outputTokens,
213
+ totalTokens: g.totalTokens,
214
+ connectors: [...g.connectors].sort(),
215
+ confidence: g.confidence,
216
+ lastTs: g.lastTs
217
+ });
218
+ }
219
+ rows.sort((a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs);
220
+ return rows;
221
+ }
222
+ function recordSurfaceKind(r) {
223
+ if (r.surfaceKind !== void 0) return r.surfaceKind;
224
+ return "server";
225
+ }
226
+ function surfaceLeaderboard(opts = {}) {
227
+ const runtime = /* @__PURE__ */ new Map();
228
+ for (const r of selectRecords(opts)) {
229
+ const surfaceKind = recordSurfaceKind(r);
230
+ const key = `${surfaceKind} ${r.toolName}`;
231
+ let g = runtime.get(key);
232
+ if (g === void 0) {
233
+ g = {
234
+ surfaceKind,
235
+ name: r.toolName,
236
+ calls: 0,
237
+ inputTokens: 0,
238
+ outputTokens: 0,
239
+ totalTokens: 0,
240
+ confidence: r.confidenceSource,
241
+ lastTs: r.ts
242
+ };
243
+ runtime.set(key, g);
244
+ }
245
+ if (r.scope === "call" || r.scope === "hook") g.calls += 1;
246
+ g.inputTokens += r.inputTokens;
247
+ g.outputTokens += r.outputTokens;
248
+ g.totalTokens += r.inputTokens + r.outputTokens;
249
+ g.confidence = worstConfidence(g.confidence, r.confidenceSource);
250
+ if (r.ts > g.lastTs) g.lastTs = r.ts;
251
+ }
252
+ const rows = [];
253
+ for (const g of runtime.values()) {
254
+ rows.push({
255
+ surfaceKind: g.surfaceKind,
256
+ name: g.name,
257
+ kind: "runtime",
258
+ calls: g.calls,
259
+ inputTokens: g.inputTokens,
260
+ outputTokens: g.outputTokens,
261
+ totalTokens: g.totalTokens,
262
+ confidence: g.confidence,
263
+ lastTs: g.lastTs
264
+ });
265
+ }
266
+ const staticRows = /* @__PURE__ */ new Map();
267
+ for (const connector of opts.connectors ?? []) {
268
+ for (const fp of computeSurfaceFootprints(connector)) {
269
+ const key = `${fp.surfaceKind} ${fp.name}`;
270
+ const existing = staticRows.get(key);
271
+ if (existing === void 0) {
272
+ staticRows.set(key, { surfaceKind: fp.surfaceKind, name: fp.name, tokens: fp.tokens });
273
+ } else {
274
+ existing.tokens += fp.tokens;
275
+ }
276
+ }
277
+ }
278
+ const staticConfidence = staticFootprintConfidence(opts.connectors ?? []);
279
+ for (const s of staticRows.values()) {
280
+ rows.push({
281
+ surfaceKind: s.surfaceKind,
282
+ name: s.name,
283
+ kind: "static",
284
+ calls: 0,
285
+ inputTokens: s.tokens,
286
+ outputTokens: 0,
287
+ totalTokens: s.tokens,
288
+ confidence: staticConfidence,
289
+ lastTs: 0
290
+ });
291
+ }
292
+ rows.sort((a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs);
293
+ return rows;
294
+ }
295
+ function staticFootprintConfidence(connectors) {
296
+ const first = connectors[0];
297
+ if (first === void 0) return "tokenizer-approx";
298
+ return first.telemetry.modelFamilyHint === "openai" ? "tokenizer-exact" : "tokenizer-approx";
299
+ }
300
+ var ESTIMATE_SOURCES = /* @__PURE__ */ new Set([
301
+ "heuristic",
302
+ "tokenizer-approx",
303
+ "tokenizer-calibrated"
304
+ ]);
305
+ function fmtInt(n) {
306
+ return n.toLocaleString("en-US");
307
+ }
308
+ function padRight(s, width) {
309
+ return s.length >= width ? s : s + " ".repeat(width - s.length);
310
+ }
311
+ function padLeft(s, width) {
312
+ return s.length >= width ? s : " ".repeat(width - s.length) + s;
313
+ }
314
+ function renderTable(headers, dataRows, leftAlignedCols, totalRow, emptyMessage) {
315
+ const widths = headers.map((h, col) => {
316
+ let w = h.length;
317
+ for (const row of dataRows) w = Math.max(w, (row[col] ?? "").length);
318
+ w = Math.max(w, (totalRow[col] ?? "").length);
319
+ return w;
320
+ });
321
+ const renderRow = (cells) => cells.map(
322
+ (c, col) => leftAlignedCols.has(col) ? padRight(c, widths[col] ?? 0) : padLeft(c, widths[col] ?? 0)
323
+ ).join(" ").trimEnd();
324
+ const ruleWidth = widths.reduce((a, b) => a + b, 0) + 2 * (widths.length - 1);
325
+ const rule = "-".repeat(ruleWidth);
326
+ const lines = [];
327
+ lines.push(renderRow(headers));
328
+ lines.push(rule);
329
+ if (dataRows.length === 0) {
330
+ lines.push(emptyMessage);
331
+ } else {
332
+ for (const row of dataRows) lines.push(renderRow(row));
333
+ }
334
+ lines.push(rule);
335
+ lines.push(renderRow(totalRow));
336
+ return lines;
337
+ }
338
+ function appendEstimateLegend(lines, confidences) {
339
+ if (confidences.some((c) => ESTIMATE_SOURCES.has(c))) {
340
+ lines.push("");
341
+ lines.push(
342
+ "note: heuristic and tokenizer-approx token counts are estimates, not exact host-reported usage."
343
+ );
344
+ if (confidences.some((c) => c === "tokenizer-calibrated")) {
345
+ lines.push(
346
+ "note: tokenizer-calibrated = local approx adjusted by a sampled Anthropic count_tokens factor (opt-in; content sampled off-box only when AGENT_CONNECTOR_CALIBRATE=anthropic)."
347
+ );
348
+ }
349
+ }
350
+ }
351
+ function formatMcpLeaderboard(rows) {
352
+ const sorted = [...rows].sort(
353
+ (a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs
354
+ );
355
+ const headers = [
356
+ "RANK",
357
+ "CONNECTOR",
358
+ "CALLS",
359
+ "TOOLS",
360
+ "IN",
361
+ "OUT",
362
+ "TOTAL",
363
+ "HOSTS",
364
+ "CONFIDENCE"
365
+ ];
366
+ const dataRows = sorted.map((r, i) => [
367
+ `${i + 1}`,
368
+ r.connectorId,
369
+ fmtInt(r.calls),
370
+ fmtInt(r.tools),
371
+ fmtInt(r.inputTokens),
372
+ fmtInt(r.outputTokens),
373
+ fmtInt(r.totalTokens),
374
+ r.hostPlatforms.length === 0 ? "-" : r.hostPlatforms.join(","),
375
+ r.confidence
376
+ ]);
377
+ const totals = sorted.reduce(
378
+ (acc, r) => {
379
+ acc.calls += r.calls;
380
+ acc.inputTokens += r.inputTokens;
381
+ acc.outputTokens += r.outputTokens;
382
+ acc.totalTokens += r.totalTokens;
383
+ return acc;
384
+ },
385
+ { calls: 0, inputTokens: 0, outputTokens: 0, totalTokens: 0 }
386
+ );
387
+ const totalRow = [
388
+ "",
389
+ "TOTAL",
390
+ fmtInt(totals.calls),
391
+ "",
392
+ fmtInt(totals.inputTokens),
393
+ fmtInt(totals.outputTokens),
394
+ fmtInt(totals.totalTokens),
395
+ "",
396
+ ""
397
+ ];
398
+ const leftCols = /* @__PURE__ */ new Set([0, 1, 7, 8]);
399
+ const lines = renderTable(
400
+ headers,
401
+ dataRows,
402
+ leftCols,
403
+ totalRow,
404
+ "(no MCP telemetry recorded)"
405
+ );
406
+ appendEstimateLegend(
407
+ lines,
408
+ sorted.map((r) => r.confidence)
409
+ );
410
+ return lines.join("\n");
411
+ }
412
+ function formatToolLeaderboard(rows) {
413
+ const sorted = [...rows].sort(
414
+ (a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs
415
+ );
416
+ const headers = [
417
+ "RANK",
418
+ "CONNECTOR",
419
+ "TOOL",
420
+ "SCOPE",
421
+ "CALLS",
422
+ "IN",
423
+ "OUT",
424
+ "TOTAL",
425
+ "CONFIDENCE"
426
+ ];
427
+ const dataRows = sorted.map((r, i) => [
428
+ `${i + 1}`,
429
+ r.connectorId,
430
+ r.toolName,
431
+ r.scope,
432
+ fmtInt(r.calls),
433
+ fmtInt(r.inputTokens),
434
+ fmtInt(r.outputTokens),
435
+ fmtInt(r.totalTokens),
436
+ r.confidence
437
+ ]);
438
+ const totals = sorted.reduce(
439
+ (acc, r) => {
440
+ acc.calls += r.calls;
441
+ acc.inputTokens += r.inputTokens;
442
+ acc.outputTokens += r.outputTokens;
443
+ acc.totalTokens += r.totalTokens;
444
+ return acc;
445
+ },
446
+ { calls: 0, inputTokens: 0, outputTokens: 0, totalTokens: 0 }
447
+ );
448
+ const totalRow = [
449
+ "",
450
+ "TOTAL",
451
+ "",
452
+ "",
453
+ fmtInt(totals.calls),
454
+ fmtInt(totals.inputTokens),
455
+ fmtInt(totals.outputTokens),
456
+ fmtInt(totals.totalTokens),
457
+ ""
458
+ ];
459
+ const leftCols = /* @__PURE__ */ new Set([0, 1, 2, 3, 8]);
460
+ const lines = renderTable(
461
+ headers,
462
+ dataRows,
463
+ leftCols,
464
+ totalRow,
465
+ "(no MCP telemetry recorded)"
466
+ );
467
+ appendEstimateLegend(
468
+ lines,
469
+ sorted.map((r) => r.confidence)
470
+ );
471
+ return lines.join("\n");
472
+ }
473
+ function formatHostNativeTurns(rows) {
474
+ const sorted = [...rows].sort(
475
+ (a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs
476
+ );
477
+ const headers = [
478
+ "RANK",
479
+ "HOST",
480
+ "SESSION",
481
+ "TURNS",
482
+ "IN",
483
+ "OUT",
484
+ "TOTAL",
485
+ "CONNECTORS",
486
+ "CONFIDENCE"
487
+ ];
488
+ const dataRows = sorted.map((r, i) => [
489
+ `${i + 1}`,
490
+ r.hostPlatform,
491
+ r.sessionId === "" ? "-" : r.sessionId,
492
+ fmtInt(r.turns),
493
+ fmtInt(r.inputTokens),
494
+ fmtInt(r.outputTokens),
495
+ fmtInt(r.totalTokens),
496
+ r.connectors.length === 0 ? "-" : r.connectors.join(","),
497
+ r.confidence
498
+ ]);
499
+ const totals = sorted.reduce(
500
+ (acc, r) => {
501
+ acc.turns += r.turns;
502
+ acc.inputTokens += r.inputTokens;
503
+ acc.outputTokens += r.outputTokens;
504
+ acc.totalTokens += r.totalTokens;
505
+ return acc;
506
+ },
507
+ { turns: 0, inputTokens: 0, outputTokens: 0, totalTokens: 0 }
508
+ );
509
+ const totalRow = [
510
+ "",
511
+ "TOTAL",
512
+ "",
513
+ fmtInt(totals.turns),
514
+ fmtInt(totals.inputTokens),
515
+ fmtInt(totals.outputTokens),
516
+ fmtInt(totals.totalTokens),
517
+ "",
518
+ ""
519
+ ];
520
+ const leftCols = /* @__PURE__ */ new Set([0, 1, 2, 7, 8]);
521
+ const lines = renderTable(
522
+ headers,
523
+ dataRows,
524
+ leftCols,
525
+ totalRow,
526
+ "(no host-native turns recorded \u2014 enable opt-in host-native usage)"
527
+ );
528
+ return lines.join("\n");
529
+ }
530
+ function formatSurfaceLeaderboard(rows) {
531
+ const sorted = [...rows].sort(
532
+ (a, b) => b.totalTokens - a.totalTokens || b.lastTs - a.lastTs
533
+ );
534
+ const headers = ["SURFACE", "NAME", "IN", "OUT", "TOTAL", "KIND"];
535
+ const dataRows = sorted.map((r) => [
536
+ r.surfaceKind,
537
+ r.name,
538
+ fmtInt(r.inputTokens),
539
+ fmtInt(r.outputTokens),
540
+ fmtInt(r.totalTokens),
541
+ r.kind
542
+ ]);
543
+ const totals = sorted.reduce(
544
+ (acc, r) => {
545
+ acc.inputTokens += r.inputTokens;
546
+ acc.outputTokens += r.outputTokens;
547
+ acc.totalTokens += r.totalTokens;
548
+ return acc;
549
+ },
550
+ { inputTokens: 0, outputTokens: 0, totalTokens: 0 }
551
+ );
552
+ const totalRow = [
553
+ "TOTAL",
554
+ "",
555
+ fmtInt(totals.inputTokens),
556
+ fmtInt(totals.outputTokens),
557
+ fmtInt(totals.totalTokens),
558
+ ""
559
+ ];
560
+ const leftCols = /* @__PURE__ */ new Set([0, 1, 5]);
561
+ const lines = renderTable(
562
+ headers,
563
+ dataRows,
564
+ leftCols,
565
+ totalRow,
566
+ "(no developer surfaces recorded)"
567
+ );
568
+ if (sorted.some((r) => r.kind === "static")) {
569
+ lines.push("");
570
+ lines.push(
571
+ "note: KIND=static rows are the tokenized FOOTPRINT a command/skill/subagent imposes on a host that loads it as context \u2014 not intercepted usage rows."
572
+ );
573
+ }
574
+ appendEstimateLegend(
575
+ lines,
576
+ sorted.map((r) => r.confidence)
577
+ );
578
+ return lines.join("\n");
579
+ }
580
+
581
+ export {
582
+ SCOPE_FILTER_VALUES,
583
+ isScopeFilter,
584
+ mcpLeaderboard,
585
+ toolLeaderboard,
586
+ hostNativeTurns,
587
+ surfaceLeaderboard,
588
+ formatMcpLeaderboard,
589
+ formatToolLeaderboard,
590
+ formatHostNativeTurns,
591
+ formatSurfaceLeaderboard
592
+ };
593
+ //# sourceMappingURL=chunk-JNM3TPLX.js.map