@browserstack/mcp-server 1.5.0-beta.9 → 1.5.1-beta.1

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 (103) hide show
  1. package/README.md +48 -32
  2. package/dist/config.d.ts +4 -1
  3. package/dist/config.js +23 -2
  4. package/dist/index.d.ts +2 -1
  5. package/dist/index.js +7 -3
  6. package/dist/lib/constants.d.ts +3 -0
  7. package/dist/lib/constants.js +3 -0
  8. package/dist/lib/instrumentation.d.ts +14 -2
  9. package/dist/lib/instrumentation.js +104 -29
  10. package/dist/lib/node-version-notice.d.ts +1 -0
  11. package/dist/lib/node-version-notice.js +9 -0
  12. package/dist/lib/tool-latency.d.ts +4 -0
  13. package/dist/lib/tool-latency.js +16 -0
  14. package/dist/lib/untrusted-content.d.ts +15 -0
  15. package/dist/lib/untrusted-content.js +24 -0
  16. package/dist/lib/upload-validator.d.ts +3 -2
  17. package/dist/lib/upload-validator.js +18 -15
  18. package/dist/lib/utils.js +10 -3
  19. package/dist/lib/version-resolver.d.ts +0 -5
  20. package/dist/lib/version-resolver.js +8 -2
  21. package/dist/logger.js +1 -10
  22. package/dist/server-factory.js +10 -6
  23. package/dist/tools/accessibility.js +10 -6
  24. package/dist/tools/accessiblity-utils/accessibility-rag.js +3 -1
  25. package/dist/tools/accessiblity-utils/auth-config.js +15 -2
  26. package/dist/tools/appautomate-utils/native-execution/constants.js +4 -2
  27. package/dist/tools/appautomate.js +3 -1
  28. package/dist/tools/applive.js +1 -1
  29. package/dist/tools/ask-browserstack/central-oauth.d.ts +120 -0
  30. package/dist/tools/ask-browserstack/central-oauth.js +277 -0
  31. package/dist/tools/ask-browserstack/config.d.ts +102 -0
  32. package/dist/tools/ask-browserstack/config.js +140 -0
  33. package/dist/tools/ask-browserstack/egress.d.ts +34 -0
  34. package/dist/tools/ask-browserstack/egress.js +31 -0
  35. package/dist/tools/ask-browserstack/register.d.ts +61 -0
  36. package/dist/tools/ask-browserstack/register.js +416 -0
  37. package/dist/tools/ask-browserstack/relay.d.ts +201 -0
  38. package/dist/tools/ask-browserstack/relay.js +577 -0
  39. package/dist/tools/ask-browserstack/stream.d.ts +116 -0
  40. package/dist/tools/ask-browserstack/stream.js +236 -0
  41. package/dist/tools/ask-browserstack/types.d.ts +196 -0
  42. package/dist/tools/ask-browserstack/types.js +14 -0
  43. package/dist/tools/automate-utils/list-session-ids.d.ts +28 -0
  44. package/dist/tools/automate-utils/list-session-ids.js +87 -0
  45. package/dist/tools/automate-utils/resolve-hashed-build-id.d.ts +30 -0
  46. package/dist/tools/automate-utils/resolve-hashed-build-id.js +124 -0
  47. package/dist/tools/automate.d.ts +7 -0
  48. package/dist/tools/automate.js +104 -1
  49. package/dist/tools/bstack-sdk.js +2 -2
  50. package/dist/tools/build-insights.js +41 -2
  51. package/dist/tools/failurelogs-utils/app-automate.js +4 -3
  52. package/dist/tools/failurelogs-utils/automate.js +5 -4
  53. package/dist/tools/failurelogs-utils/resolve-app-build-id.d.ts +2 -0
  54. package/dist/tools/failurelogs-utils/resolve-app-build-id.js +5 -0
  55. package/dist/tools/failurelogs-utils/video.d.ts +3 -0
  56. package/dist/tools/failurelogs-utils/video.js +25 -0
  57. package/dist/tools/get-failure-logs.js +30 -11
  58. package/dist/tools/observability.js +3 -1
  59. package/dist/tools/percy-sdk.js +9 -9
  60. package/dist/tools/rca-agent-utils/constants.js +2 -2
  61. package/dist/tools/rca-agent-utils/format-rca.js +5 -4
  62. package/dist/tools/rca-agent-utils/get-failed-test-id.js +12 -0
  63. package/dist/tools/rca-agent-utils/types.d.ts +1 -0
  64. package/dist/tools/rca-agent.js +18 -6
  65. package/dist/tools/review-agent.js +2 -1
  66. package/dist/tools/sdk-utils/common/constants.d.ts +1 -1
  67. package/dist/tools/sdk-utils/common/constants.js +2 -1
  68. package/dist/tools/sdk-utils/common/utils.js +1 -1
  69. package/dist/tools/selfheal-utils/fetch-test-code.d.ts +3 -4
  70. package/dist/tools/selfheal-utils/fetch-test-code.js +30 -57
  71. package/dist/tools/selfheal.js +28 -35
  72. package/dist/tools/testmanagement-utils/TCG-utils/api.js +26 -7
  73. package/dist/tools/testmanagement-utils/TCG-utils/config.d.ts +2 -0
  74. package/dist/tools/testmanagement-utils/TCG-utils/config.js +5 -0
  75. package/dist/tools/testmanagement-utils/get-sub-testplan.js +6 -3
  76. package/dist/tools/testmanagement-utils/get-testplan.js +6 -3
  77. package/dist/tools/testmanagement-utils/testcase-from-file.js +2 -1
  78. package/dist/tools/testmanagement-utils/upload-file.js +16 -2
  79. package/dist/tools/testmanagement.js +39 -17
  80. package/dist/tools/tfa-rca-collaboration.js +1 -1
  81. package/dist/tools/tool-handoff.d.ts +66 -0
  82. package/dist/tools/tool-handoff.js +78 -0
  83. package/package.json +4 -5
  84. package/capability/loadtesting.capability-index.json +0 -1791
  85. package/capability/tm.capability-index.json +0 -19966
  86. package/dist/tools/capability-registry/bind.d.ts +0 -29
  87. package/dist/tools/capability-registry/bind.js +0 -134
  88. package/dist/tools/capability-registry/config.d.ts +0 -62
  89. package/dist/tools/capability-registry/config.js +0 -218
  90. package/dist/tools/capability-registry/discovery.d.ts +0 -44
  91. package/dist/tools/capability-registry/discovery.js +0 -99
  92. package/dist/tools/capability-registry/egress.d.ts +0 -44
  93. package/dist/tools/capability-registry/egress.js +0 -128
  94. package/dist/tools/capability-registry/index-loader.d.ts +0 -133
  95. package/dist/tools/capability-registry/index-loader.js +0 -369
  96. package/dist/tools/capability-registry/register.d.ts +0 -34
  97. package/dist/tools/capability-registry/register.js +0 -373
  98. package/dist/tools/capability-registry/resolve.d.ts +0 -38
  99. package/dist/tools/capability-registry/resolve.js +0 -45
  100. package/dist/tools/capability-registry/search.d.ts +0 -66
  101. package/dist/tools/capability-registry/search.js +0 -416
  102. package/dist/tools/capability-registry/types.d.ts +0 -219
  103. package/dist/tools/capability-registry/types.js +0 -33
@@ -1,416 +0,0 @@
1
- /**
2
- * Ranking capabilities against a plain-language query.
3
- *
4
- * Ported from the Python `discover._score`, including the two properties that were each
5
- * fixed after a live mis-ranking:
6
- *
7
- * * PENALTIES REORDER, THEY DO NOT EXCLUDE. `matched` is the pre-penalty term score and is
8
- * what decides inclusion; `ranked` carries the preferences. Conflating them dropped 40
9
- * legitimate matches outright, because a cardinality penalty took an otherwise-valid
10
- * score to zero and the caller saw "no such capability".
11
- * * CARDINALITY. A "list" query answered by a single-record getter sends the caller to a
12
- * capability needing an id it cannot possibly have yet.
13
- */
14
- /**
15
- * Every non-alphanumeric character separates, `_` included.
16
- *
17
- * `_` used to be a word character, which made `test_case` a single token while every
18
- * haystack rendered it as "test case" — so the two could never match. That is the exact
19
- * string `listEntities` hands back, so a caller following the documented flow searched with
20
- * a term guaranteed to score zero: "list test_runs" matched 19 capabilities and put an
21
- * admin settings endpoint first, where "list test runs" matched 103 and put the test-runs
22
- * listing first.
23
- */
24
- const WORD = /[a-z0-9]+/g;
25
- const STOPWORDS = new Set([
26
- "a",
27
- "an",
28
- "and",
29
- "are",
30
- "as",
31
- "at",
32
- "be",
33
- "by",
34
- "can",
35
- "do",
36
- "for",
37
- "from",
38
- "how",
39
- "i",
40
- "in",
41
- "is",
42
- "it",
43
- "me",
44
- "my",
45
- "of",
46
- "on",
47
- "or",
48
- "has",
49
- "have",
50
- "that",
51
- "the",
52
- "these",
53
- "this",
54
- "those",
55
- "to",
56
- "want",
57
- "what",
58
- "which",
59
- "with",
60
- "you",
61
- ]);
62
- // Verbs that reveal what the caller means to DO. A preference, not a filter — an explicit
63
- // `mode` argument is the filter.
64
- const READ_VERBS = new Set([
65
- "list",
66
- "get",
67
- "show",
68
- "find",
69
- "fetch",
70
- "read",
71
- "count",
72
- "search",
73
- "view",
74
- "which",
75
- "how",
76
- ]);
77
- const WRITE_VERBS = new Set([
78
- "create",
79
- "add",
80
- "update",
81
- "edit",
82
- "delete",
83
- "remove",
84
- "move",
85
- "copy",
86
- "archive",
87
- "assign",
88
- "restore",
89
- "reorder",
90
- "bulk",
91
- "set",
92
- "upload",
93
- "import",
94
- "clone",
95
- ]);
96
- // Words that mean "give me many", which is what makes a single-record getter the wrong answer.
97
- const PLURAL_INTENT = new Set([
98
- "list",
99
- "all",
100
- "every",
101
- "many",
102
- "count",
103
- "search",
104
- "find",
105
- "which",
106
- "each",
107
- ]);
108
- /**
109
- * Query/haystack terms. Verbs are deliberately NOT stopwords — they carry the intent.
110
- *
111
- * camelCase is split before lowercasing, so `testRunId`, `test_run_id` and `test run id`
112
- * all tokenize alike.
113
- */
114
- export function terms(text) {
115
- return [
116
- ...(text || "")
117
- .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
118
- .toLowerCase()
119
- .matchAll(WORD),
120
- ]
121
- .map((match) => match[0])
122
- .filter((word) => !STOPWORDS.has(word));
123
- }
124
- /**
125
- * A term plus its naive singular variants.
126
- *
127
- * QUERY SIDE ONLY, which is what makes this cheap and safe. Matching is one-directional
128
- * substring containment, so indexed `attachments` already contains a query of `attachment`;
129
- * only the reverse — a plural query against singular text — needs help. Stemming the
130
- * indexed side too would mean rewriting the product's own vocabulary to guess at English,
131
- * for no additional match.
132
- */
133
- export function termForms(term) {
134
- const forms = [term];
135
- // A stripped form must still be three characters. `has` -> `ha` matched more than half
136
- // the surface as a substring and pushed a correct answer out of the top 8 entirely;
137
- // short fragments are noise, not variants.
138
- const add = (form) => {
139
- if (form.length >= 3)
140
- forms.push(form);
141
- };
142
- if (term.endsWith("es"))
143
- add(term.slice(0, -2));
144
- if (term.endsWith("s") && !term.endsWith("ss"))
145
- add(term.slice(0, -1));
146
- return forms;
147
- }
148
- /** A haystack as one lowercased, space-separated string, ready for containment tests. */
149
- function haystack(text) {
150
- return terms(text).join(" ");
151
- }
152
- export function modeHint(query) {
153
- const words = new Set(terms(query));
154
- const wantsWrite = [...words].some((word) => WRITE_VERBS.has(word));
155
- if (wantsWrite)
156
- return "write";
157
- const wantsRead = [...words].some((word) => READ_VERBS.has(word));
158
- return wantsRead ? "read" : "";
159
- }
160
- export function wantsCollection(query) {
161
- return [...(query || "").toLowerCase().matchAll(WORD)].some((match) => PLURAL_INTENT.has(match[0]));
162
- }
163
- /**
164
- * True when a capability answers with many records rather than one.
165
- *
166
- * Pagination is the reliable signal — a paged operation is a listing by construction. The
167
- * plural terminal path segment is a weaker fallback for unpaged collections. (The Python
168
- * side used the capability NAME here. tm now publishes one, but its verbs are not
169
- * consistent — the endpoint that lists folders is `get_root_folders_v1` — so the path's
170
- * terminal noun remains the better signal.)
171
- */
172
- export function isCollection(capability) {
173
- if (capability.paginated)
174
- return true;
175
- const segments = capability.path
176
- .split("/")
177
- .filter((s) => s && !s.startsWith("{"));
178
- const tail = segments[segments.length - 1] || "";
179
- return tail.endsWith("s") && !tail.endsWith("ss");
180
- }
181
- /** Everything a caller might say that lives on a parameter rather than in the prose. */
182
- function parameterText(capability) {
183
- const parts = [];
184
- for (const group of [
185
- capability.path_params,
186
- capability.query,
187
- capability.body,
188
- ]) {
189
- for (const param of group || []) {
190
- parts.push(param.name);
191
- if (param.description)
192
- parts.push(param.description);
193
- if (param.values)
194
- parts.push(param.values.map(String).join(" "));
195
- }
196
- }
197
- return parts.join(" ");
198
- }
199
- /**
200
- * Path words are the identity haystack. The published `name` is deliberately NOT scored.
201
- *
202
- * That is a measured result, not an oversight. tm now names every capability, and adding
203
- * the name to the ranking was tried three ways against tests/fixtures/search-eval.json,
204
- * which the pre-names index serves 18/18:
205
- *
206
- * folded into this field, weight 6 17/18
207
- * its own field, weights 1 / 2 / 3 / 4 / 6 17 / 17 / 17 / 17 / 16
208
- * only the words the path lacks, 1..6 17 / 16 / 15 / 15 / 14
209
- *
210
- * Every variant loses, for two reasons. The nouns in a name are the route restated — the
211
- * name is snake-cased from the operationId, itself derived from the path — so scoring them
212
- * again rewards verbose names for repeating themselves: `get_test_cases_for_v1_test_run`
213
- * displaced `create_test_result_for_test_case` on "record a pass or fail for a test case in
214
- * a run", putting a read above the write that answers it. And what a name adds beyond the
215
- * route is mostly its verb, which tm applies inconsistently (`get_root_folders_v1` lists,
216
- * `list_folder_test_cases_v1` also lists), so the verb is noise as often as signal.
217
- *
218
- * The query this was meant to fix, "list all projects", only went 7 -> 4 even where it
219
- * helped: `projects` is in 156 of 173 paths as a scope prefix, so rarity correctly values it
220
- * near zero and no amount of name weighting recovers it. That one is fixed instead by the
221
- * terminal-segment bonus in `score`, which tells "is that thing" from "is scoped by it".
222
- *
223
- * Revisit when a product ships a consistent verb convention — then the verb becomes signal.
224
- */
225
- /**
226
- * The terminal path segment — the thing this endpoint is actually ABOUT.
227
- *
228
- * A REST path mixes two different things: the resources it is SCOPED BY, and the resource it
229
- * ADDRESSES. Only the last segment is the latter. See the bonus in `score` for why that
230
- * distinction matters and why it is applied flat rather than weighted.
231
- *
232
- * Trailing placeholders are skipped, so `/test-cases/{id}` is still about test cases.
233
- * Action tails (`close`, `edit`, `delete`) are kept rather than skipped: for "close a test
234
- * run" the tail IS the most specific thing the caller said.
235
- */
236
- function resourceText(capability) {
237
- const segments = capability.path
238
- .split("/")
239
- .filter((s) => s && !s.startsWith("{") && s !== "api");
240
- return (segments[segments.length - 1] || "").replace(/[-_]/g, " ");
241
- }
242
- function identityText(capability) {
243
- return capability.path
244
- .split("/")
245
- .filter((segment) => segment && !segment.startsWith("{") && segment !== "api")
246
- .join(" ")
247
- .replace(/[-_]/g, " ");
248
- }
249
- /**
250
- * How much one term is worth, by how rare it is.
251
- *
252
- * Containment made every project-scoped endpoint match the term `project` — ~150 of tm's
253
- * 173 capabilities — so that word carried as much weight as `access`, which appears in
254
- * exactly one. Rarity is what separates them: a term matching everything scores near zero,
255
- * a term matching one capability scores near one.
256
- *
257
- * This is the IDF idea alone, not BM25. The term-frequency saturation and length
258
- * normalisation BM25 adds would rescale every score, and the mode and cardinality
259
- * adjustments below are absolute constants fitted against live mis-rankings. Bounding the
260
- * factor to 0..1 keeps those constants meaningful.
261
- */
262
- function rarity(documents, forms) {
263
- let df = 0;
264
- for (const text of documents) {
265
- if (forms.some((form) => text.includes(form)))
266
- df += 1;
267
- }
268
- const total = documents.length || 1;
269
- return Math.log((total + 1) / (df + 1)) / Math.log(total + 1);
270
- }
271
- /**
272
- * Sized to sit alongside the mode (+6) and cardinality (+8) constants, not to dwarf them.
273
- * The pinned eval is unchanged at every value from 2 to 14 — the bonus only ever fires on
274
- * queries it does not cover — so this was chosen on the wider sweep: at 10, "close a test
275
- * run" starts pulling `close_exploratory_session` into second place on the tail match alone.
276
- */
277
- const RESOURCE_BONUS = 6;
278
- function score(capability, wanted, weights, aliases, hint, plural) {
279
- if (wanted.length === 0)
280
- return { matched: 1, ranked: 1 };
281
- const haystacks = [
282
- [identityText(capability), 6],
283
- [capability.entity, 4],
284
- [(aliases[capability.entity] || []).join(" "), 4],
285
- [capability.intent || "", 2],
286
- // `returns` is scored BELOW identity, not gated on it. At parity with intent it put a
287
- // projects listing at #2 for "list test cases in a project" (its returns carries
288
- // `test_cases_count`); gating it on an identity match instead made a field reachable
289
- // only through returns unreachable, which is worse.
290
- [(capability.returns || []).join(" "), 1],
291
- [(capability.guidance || []).join(" "), 1],
292
- // Parameter names, their descriptions, and their enum values — 330 descriptions and 34
293
- // value lists that the artifact already carries and nothing was reading. The vocabulary
294
- // a caller uses is often the value they mean to send: `pass` and `fail` appear nowhere
295
- // else in the index, only as the `status` enum on the test-result writes.
296
- [parameterText(capability), 1],
297
- ];
298
- // CONTAINMENT, not set membership. A query of `attachment` has to reach an endpoint whose
299
- // path says `attachments`; under exact token equality it did not, and that endpoint fell
300
- // out of the results entirely. A term scores its field once however many forms match.
301
- let ranked = 0;
302
- for (const [text, weight] of haystacks) {
303
- const blob = haystack(text);
304
- if (!blob)
305
- continue;
306
- for (let i = 0; i < wanted.length; i += 1) {
307
- if (wanted[i].some((form) => blob.includes(form)))
308
- ranked += weight * weights[i];
309
- }
310
- }
311
- // PHRASE. Adjacent query terms occurring together say more than the same two words
312
- // scattered: "test case" is one noun in this vocabulary, "test" and "case" separately
313
- // are two of the commonest words in the index. Scored at half the field's weight and
314
- // still scaled by rarity, so it sharpens an existing match rather than creating one.
315
- for (const [text, weight] of haystacks) {
316
- const blob = haystack(text);
317
- if (!blob)
318
- continue;
319
- for (let i = 0; i + 1 < wanted.length; i += 1) {
320
- if (blob.includes(`${wanted[i][0]} ${wanted[i + 1][0]}`)) {
321
- ranked += weight * 0.5 * (weights[i] + weights[i + 1]);
322
- }
323
- }
324
- }
325
- const matched = ranked;
326
- // THE ENDPOINT IS THAT THING, not merely scoped by it.
327
- //
328
- // A REST path mixes the resources it is SCOPED BY with the one it ADDRESSES. `projects` is
329
- // in 156 of tm's 173 paths but is the terminal segment in 3, so whole-corpus rarity —
330
- // correctly — values it near nothing, and every project-scoped listing scored the same as
331
- // the projects listing itself. The top 8 for "list all projects" spanned 15.9 to 14.8,
332
- // where +8 collection and +6 mode already account for 14: the term signal was ~1 point of
333
- // noise and the right answer sat 7th.
334
- //
335
- // Flat, and deliberately NOT rarity-scaled. Rarity would reintroduce the same problem in
336
- // reverse — a rare scope noun outranking the real target, which is exactly how a weighted
337
- // version of this put `/projects/{id}/folders` above `/folder/{id}/test-cases` for "tc list
338
- // for a folder". This asks one yes/no question instead: is the caller's own word the last
339
- // thing in the path?
340
- //
341
- // Equality is against the QUERY's forms, never the haystack's — the same one-directional
342
- // rule as containment. `projects` is in forms("projects"), so the projects listing hits;
343
- // `folders` is not in forms("folder"), so a folder-scoped query does not drag in the
344
- // folders listing.
345
- const tail = terms(resourceText(capability));
346
- if (tail.length &&
347
- wanted.some((forms) => tail.every((word) => forms.includes(word)))) {
348
- ranked += RESOURCE_BONUS;
349
- }
350
- if (hint && capability.mode !== hint)
351
- ranked -= 20;
352
- else if (hint && capability.mode === hint)
353
- ranked += 6;
354
- if (plural)
355
- ranked += isCollection(capability) ? 8 : -8;
356
- return { matched, ranked };
357
- }
358
- export function searchCapabilities(products, query, options = {}) {
359
- const limit = options.limit && options.limit > 0 ? options.limit : 8;
360
- // Forms are computed once per query, not per capability: 173 capabilities x 6 haystacks
361
- // would otherwise rebuild the same handful of strings a thousand times.
362
- const wanted = terms(query).map(termForms);
363
- const hint = options.mode ? "" : modeHint(query);
364
- const plural = wantsCollection(query);
365
- const scored = [];
366
- const searched = Object.entries(products).filter(([name]) => !options.product || name === options.product);
367
- const aliasesByProduct = {};
368
- for (const [name, bundle] of searched) {
369
- const aliases = {};
370
- for (const [entity, doc] of Object.entries(bundle.entities)) {
371
- aliases[entity] = (doc.aliases || []);
372
- }
373
- aliasesByProduct[name] = aliases;
374
- }
375
- // ONE CORPUS ACROSS EVERY SEARCHED PRODUCT, not one per product.
376
- //
377
- // Measured per product, a term's rarity inverts across them: `load` appears in nearly
378
- // every Load Testing capability, so it scored as noise there, while it appears in 16 of
379
- // tm's 173 (`upload`, `download`, reached by containment), so it scored as gold there.
380
- // The word that identifies a product was worth least inside it, and "list load tests"
381
- // returned five tm results and no Load Testing ones at all.
382
- //
383
- // It is also measured against EVERY capability, not the entity- or mode-filtered subset:
384
- // narrowing a search must not make a common word look rare.
385
- const corpus = searched.flatMap(([name, bundle]) => bundle.capabilities.map((capability) => [
386
- identityText(capability),
387
- capability.entity,
388
- (aliasesByProduct[name][capability.entity] || []).join(" "),
389
- capability.intent || "",
390
- (capability.returns || []).join(" "),
391
- parameterText(capability),
392
- ]
393
- .map(haystack)
394
- .join(" ")));
395
- const weights = wanted.map((forms) => rarity(corpus, forms));
396
- for (const [name, bundle] of searched) {
397
- const aliases = aliasesByProduct[name];
398
- for (const capability of bundle.capabilities) {
399
- if (options.entity && capability.entity !== options.entity)
400
- continue;
401
- if (options.mode && capability.mode !== options.mode)
402
- continue;
403
- const { matched, ranked } = score(capability, wanted, weights, aliases, hint, plural);
404
- if (matched > 0)
405
- scored.push({ matched, ranked, product: name, capability });
406
- }
407
- }
408
- scored.sort((a, b) => b.ranked - a.ranked || a.capability.path.localeCompare(b.capability.path));
409
- return {
410
- hits: scored
411
- .slice(0, limit)
412
- .map(({ product, capability }) => ({ product, capability })),
413
- truncated: scored.length > limit,
414
- total_matched: scored.length,
415
- };
416
- }
@@ -1,219 +0,0 @@
1
- /**
2
- * The shape of the index artifact, which is the contract with the export pipeline.
3
- *
4
- * The artifact is generated by the capability-registry build and transformed into its
5
- * released envelope by the export pipeline's merge step. It contains ONLY data that has
6
- * already passed that side's outbound boundary. Nothing here is parsed from an OpenAPI spec
7
- * at runtime: if this half parsed specs it would become the boundary, and every gate (route
8
- * lint, vocabulary rule, intent lint, discovery denylist) would have to be reimplemented and
9
- * re-tested here. Reading a pre-projected index means the internal data is not in the
10
- * package at all.
11
- *
12
- * ONE FILE PER PRODUCT. The released artifact is `capability/<product>.capability-index.json`,
13
- * with the
14
- * product object at the top level under its own name. The plural `products` wrapper belonged
15
- * to the pre-release shape and implied multi-product files that never existed.
16
- */
17
- /**
18
- * The envelope's format marker, for FUTURE shape changes.
19
- *
20
- * BOTH the released and the pre-release shapes claim 1, so this number cannot distinguish
21
- * them — `readIndexFile` shape-detects on the `products` wrapper instead. The check is still
22
- * worth keeping: it is what refuses a shape the generator has announced but this build does
23
- * not read.
24
- */
25
- export declare const SUPPORTED_SCHEMA_VERSION = 1;
26
- /** Envelope keys, i.e. everything at the top level that is NOT the product object. */
27
- export declare const ENVELOPE_KEYS: readonly ["schema_version", "version", "build_id", "harness_commit", "products"];
28
- export type Mode = "read" | "write" | "destructive";
29
- /** One parameter, under the name the OpenAPI spec itself gives it. */
30
- export interface WireParam {
31
- name: string;
32
- type: string;
33
- required?: true;
34
- values?: unknown[];
35
- example?: unknown;
36
- description?: string;
37
- /** Field names/types one level inside an array item or nested object. */
38
- fields?: {
39
- name: string;
40
- type: string;
41
- required?: true;
42
- }[];
43
- /**
44
- * Where a body field sits in the JSON, when that differs from its name. Published
45
- * because the nesting is not guessable and getting it wrong fails silently — tm's folder
46
- * create really wants `{folder: {name}}` while the spec's flat `{name}` is what a reader
47
- * would assume.
48
- */
49
- json_path?: string;
50
- }
51
- /**
52
- * A reference into a product-level lookup table.
53
- *
54
- * Named components are stored ONCE, already dereferenced and allOf-flattened at build time,
55
- * so resolution is a single dict lookup rather than a recursive $ref walk at runtime.
56
- */
57
- export interface ComponentRef {
58
- $response?: string;
59
- $schema?: string;
60
- }
61
- /** A JSON Schema fragment, or a reference to a named one. */
62
- export type SchemaNode = ComponentRef & Record<string, unknown>;
63
- /** One declared response, or a reference to a named one. */
64
- export interface ResponseDoc extends ComponentRef {
65
- description?: string;
66
- schema?: SchemaNode;
67
- }
68
- /** A capability, keyed by the endpoint it exposes. There is deliberately no name. */
69
- export interface Capability {
70
- /**
71
- * The caller-facing handle — the snake-cased `operationId`, unique within its product.
72
- *
73
- * This is what `invokeCapability` takes, and what `entities[*].capabilities[]` lists. It
74
- * is stable where a route is not: `/edit` becoming `/edit-v2` must not break a caller
75
- * holding a handle.
76
- *
77
- * OPTIONAL because not every product publishes it yet — loadtesting's index carries none.
78
- * For those, the endpoint remains the handle, so nothing may assume this is present.
79
- */
80
- name?: string;
81
- method: string;
82
- path: string;
83
- mode: Mode;
84
- entity: string;
85
- path_params?: WireParam[];
86
- query?: WireParam[];
87
- body?: WireParam[];
88
- intent?: string;
89
- /**
90
- * How to call the endpoint correctly.
91
- *
92
- * ABSENT from the released artifact — the export dropped it, and the shape-change note
93
- * does not say whether that was intended. Kept optional and still scored by search so the
94
- * server works either way; nothing may depend on it being present.
95
- */
96
- guidance?: string[];
97
- /** Allowlisted row fields. Absent when `shape` is "discovered". */
98
- returns?: string[];
99
- /** "discovered" when the product declares no response schema for this operation. */
100
- shape?: "discovered";
101
- requires?: string[];
102
- paginated?: boolean;
103
- /** The largest page the operation declares. */
104
- max_page_size?: number;
105
- /**
106
- * Declared responses by status code, values possibly `{$response: "Name"}` references.
107
- *
108
- * ADDITIVE and not yet emitted: no capability in the current export carries it. Absence
109
- * means "no response schema available", never an error. Resolve with `resolveComponent`.
110
- */
111
- responses?: Record<string, ResponseDoc>;
112
- }
113
- export interface EntityDoc {
114
- title?: string;
115
- aliases?: string[];
116
- id_convention?: string;
117
- parents?: string[];
118
- relations?: {
119
- entity?: string;
120
- via?: string;
121
- }[];
122
- [key: string]: unknown;
123
- }
124
- /**
125
- * Paging controls, keyed "METHOD /path".
126
- *
127
- * NOT USED BY THIS SERVER: it performs one request and returns the response, so paging
128
- * belongs to the caller and the page parameters are published with the endpoint's other
129
- * query parameters. The field is still emitted by the build, so it stays described here
130
- * rather than silently ignored — a consumer that DOES page can use it.
131
- */
132
- export interface PagingRule {
133
- page?: string;
134
- size?: string;
135
- /** The largest page the operation declares. Absent when the spec states no maximum. */
136
- max?: number;
137
- }
138
- /**
139
- * How a product wants the caller's credentials presented.
140
- *
141
- * The OpenAPI `securityScheme` vocabulary, verbatim — `type` / `in` / `name` / `scheme` —
142
- * because the spec already describes this and inventing a parallel taxonomy would mean
143
- * translating between two of them forever. ONE scheme per product, not OpenAPI's list of
144
- * alternatives: this server holds a username and an access key and nothing else, so
145
- * "the first alternative we can satisfy" only ever had one answer.
146
- *
147
- * `template` is what makes it a contract rather than a guess — a product taking
148
- * `{username}_{access_key}` is expressible instead of being a special case in the server.
149
- * It names placeholders, never values: the credential itself stays in config, and the
150
- * harness's `{ env: … }` value sources must NOT cross the boundary into the artifact.
151
- */
152
- export interface AuthScheme {
153
- /** "apiKey" puts the rendered template in a header; "http" with scheme "basic" encodes it. */
154
- type: "apiKey" | "http";
155
- /** apiKey only. Header is the sole supported location — see `egress.authHeaders`. */
156
- in?: "header" | "cookie" | "query";
157
- /** apiKey only: the header name, e.g. "Api-Token". */
158
- name?: string;
159
- /** http only. */
160
- scheme?: string;
161
- /** Defaults to `{username}:{access_key}`. */
162
- template?: string;
163
- }
164
- export interface ProductIndex {
165
- summary: string;
166
- /**
167
- * How to authenticate to this product. Absent means the historical default: the caller's
168
- * credentials as `Api-Token: {username}:{access_key}`, which is what every shipped index
169
- * relies on today.
170
- */
171
- auth?: AuthScheme;
172
- /**
173
- * The single host this product is served from, when it has one.
174
- *
175
- * A default, not the last word: config overrides it, and for a region-sharded product
176
- * (one declaring `base_urls`) account discovery outranks it and this is the fallback.
177
- */
178
- base_url?: string;
179
- /**
180
- * Candidate regional hosts, in probe order, for a product whose host depends on the
181
- * ACCOUNT rather than the deployment.
182
- *
183
- * Declaring these makes the product region-sharded: the server asks each in turn with the
184
- * caller's credentials and keeps the one that answers. A single fixed `base_url` cannot
185
- * express this — it would send every account outside the default region to the wrong host,
186
- * a failure invisible to anyone testing from inside that region.
187
- */
188
- base_urls?: string[];
189
- /**
190
- * The endpoint to probe the candidates with. Derived from the capabilities when absent
191
- * (see `discovery.probePath`); declare it when the derived choice would be wrong.
192
- */
193
- probe_path?: string;
194
- capabilities: Capability[];
195
- entities: Record<string, EntityDoc>;
196
- paging?: Record<string, PagingRule>;
197
- /** Named responses, referenced as `{$response: "Name"}`. Additive; not yet emitted. */
198
- responses?: Record<string, ResponseDoc>;
199
- /** Named schemas, referenced as `{$schema: "Name"}`. Additive; not yet emitted. */
200
- schemas?: Record<string, SchemaNode>;
201
- }
202
- /** Where one product's data came from. Logging and cache-busting only. */
203
- export interface Provenance {
204
- /** `<commit>_<UTC timestamp>` in the released shape. */
205
- build_id: string;
206
- /** Dotted content-generation counter, e.g. "1.2". Absent in the pre-release shape. */
207
- version?: string;
208
- }
209
- /**
210
- * The merged, in-memory model: every loaded file's product under its own name.
211
- *
212
- * This is the server's own structure, not the file format — one file carries one product,
213
- * and the registry holds all of them so a caller can search across products.
214
- */
215
- export interface RegistryIndex {
216
- schema_version: number;
217
- build_id: string;
218
- products: Record<string, ProductIndex>;
219
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * The shape of the index artifact, which is the contract with the export pipeline.
3
- *
4
- * The artifact is generated by the capability-registry build and transformed into its
5
- * released envelope by the export pipeline's merge step. It contains ONLY data that has
6
- * already passed that side's outbound boundary. Nothing here is parsed from an OpenAPI spec
7
- * at runtime: if this half parsed specs it would become the boundary, and every gate (route
8
- * lint, vocabulary rule, intent lint, discovery denylist) would have to be reimplemented and
9
- * re-tested here. Reading a pre-projected index means the internal data is not in the
10
- * package at all.
11
- *
12
- * ONE FILE PER PRODUCT. The released artifact is `capability/<product>.capability-index.json`,
13
- * with the
14
- * product object at the top level under its own name. The plural `products` wrapper belonged
15
- * to the pre-release shape and implied multi-product files that never existed.
16
- */
17
- /**
18
- * The envelope's format marker, for FUTURE shape changes.
19
- *
20
- * BOTH the released and the pre-release shapes claim 1, so this number cannot distinguish
21
- * them — `readIndexFile` shape-detects on the `products` wrapper instead. The check is still
22
- * worth keeping: it is what refuses a shape the generator has announced but this build does
23
- * not read.
24
- */
25
- export const SUPPORTED_SCHEMA_VERSION = 1;
26
- /** Envelope keys, i.e. everything at the top level that is NOT the product object. */
27
- export const ENVELOPE_KEYS = [
28
- "schema_version",
29
- "version",
30
- "build_id",
31
- "harness_commit",
32
- "products",
33
- ];