@wootsup/mcp 0.1.0-rc.9 → 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.
- package/README.md +7 -7
- package/dist/index.d.ts +19 -0
- package/dist/index.js +71 -5
- package/dist/index.js.map +1 -1
- package/dist/modules/apimapper/cache.d.ts +2 -2
- package/dist/modules/apimapper/cache.js +107 -25
- package/dist/modules/apimapper/cache.js.map +1 -1
- package/dist/modules/apimapper/client.d.ts +40 -0
- package/dist/modules/apimapper/client.js +82 -12
- package/dist/modules/apimapper/client.js.map +1 -1
- package/dist/modules/apimapper/connections-format.d.ts +51 -0
- package/dist/modules/apimapper/connections-format.js +261 -0
- package/dist/modules/apimapper/connections-format.js.map +1 -0
- package/dist/modules/apimapper/connections-trim.d.ts +82 -0
- package/dist/modules/apimapper/connections-trim.js +224 -0
- package/dist/modules/apimapper/connections-trim.js.map +1 -0
- package/dist/modules/apimapper/connections.d.ts +14 -2
- package/dist/modules/apimapper/connections.js +447 -143
- package/dist/modules/apimapper/connections.js.map +1 -1
- package/dist/modules/apimapper/credentials-format.d.ts +21 -0
- package/dist/modules/apimapper/credentials-format.js +145 -0
- package/dist/modules/apimapper/credentials-format.js.map +1 -0
- package/dist/modules/apimapper/credentials.d.ts +12 -2
- package/dist/modules/apimapper/credentials.js +253 -72
- package/dist/modules/apimapper/credentials.js.map +1 -1
- package/dist/modules/apimapper/diagnose.d.ts +54 -2
- package/dist/modules/apimapper/diagnose.js +193 -11
- package/dist/modules/apimapper/diagnose.js.map +1 -1
- package/dist/modules/apimapper/elicitation.d.ts +54 -0
- package/dist/modules/apimapper/elicitation.js +90 -0
- package/dist/modules/apimapper/elicitation.js.map +1 -0
- package/dist/modules/apimapper/flows-format.d.ts +50 -0
- package/dist/modules/apimapper/flows-format.js +318 -0
- package/dist/modules/apimapper/flows-format.js.map +1 -0
- package/dist/modules/apimapper/flows.d.ts +13 -2
- package/dist/modules/apimapper/flows.js +325 -118
- package/dist/modules/apimapper/flows.js.map +1 -1
- package/dist/modules/apimapper/gateway/advanced-tool.d.ts +9 -0
- package/dist/modules/apimapper/gateway/advanced-tool.js +214 -0
- package/dist/modules/apimapper/gateway/advanced-tool.js.map +1 -0
- package/dist/modules/apimapper/gateway/capturing-server.d.ts +81 -0
- package/dist/modules/apimapper/gateway/capturing-server.js +87 -0
- package/dist/modules/apimapper/gateway/capturing-server.js.map +1 -0
- package/dist/modules/apimapper/gateway/essentials.d.ts +4 -0
- package/dist/modules/apimapper/gateway/essentials.js +28 -0
- package/dist/modules/apimapper/gateway/essentials.js.map +1 -0
- package/dist/modules/apimapper/gateway/test-support.d.ts +17 -0
- package/dist/modules/apimapper/gateway/test-support.js +43 -0
- package/dist/modules/apimapper/gateway/test-support.js.map +1 -0
- package/dist/modules/apimapper/get-skill.d.ts +3 -3
- package/dist/modules/apimapper/get-skill.js +4 -2
- package/dist/modules/apimapper/get-skill.js.map +1 -1
- package/dist/modules/apimapper/graph-builder.js +1 -1
- package/dist/modules/apimapper/graph-builder.js.map +1 -1
- package/dist/modules/apimapper/graph.d.ts +2 -2
- package/dist/modules/apimapper/graph.js +165 -34
- package/dist/modules/apimapper/graph.js.map +1 -1
- package/dist/modules/apimapper/index.d.ts +17 -1
- package/dist/modules/apimapper/index.js +66 -17
- package/dist/modules/apimapper/index.js.map +1 -1
- package/dist/modules/apimapper/inspect.d.ts +3 -2
- package/dist/modules/apimapper/inspect.js +97 -13
- package/dist/modules/apimapper/inspect.js.map +1 -1
- package/dist/modules/apimapper/library.d.ts +2 -2
- package/dist/modules/apimapper/library.js +303 -60
- package/dist/modules/apimapper/library.js.map +1 -1
- package/dist/modules/apimapper/license-format.d.ts +22 -0
- package/dist/modules/apimapper/license-format.js +149 -0
- package/dist/modules/apimapper/license-format.js.map +1 -0
- package/dist/modules/apimapper/license.d.ts +16 -2
- package/dist/modules/apimapper/license.js +85 -37
- package/dist/modules/apimapper/license.js.map +1 -1
- package/dist/modules/apimapper/local-sources.d.ts +2 -2
- package/dist/modules/apimapper/local-sources.js +58 -30
- package/dist/modules/apimapper/local-sources.js.map +1 -1
- package/dist/modules/apimapper/misc.d.ts +30 -2
- package/dist/modules/apimapper/misc.js +129 -50
- package/dist/modules/apimapper/misc.js.map +1 -1
- package/dist/modules/apimapper/node-schema.d.ts +52 -0
- package/dist/modules/apimapper/node-schema.js +70 -2
- package/dist/modules/apimapper/node-schema.js.map +1 -1
- package/dist/modules/apimapper/normalizers.d.ts +1 -0
- package/dist/modules/apimapper/normalizers.js +51 -0
- package/dist/modules/apimapper/normalizers.js.map +1 -1
- package/dist/modules/apimapper/onboarding.d.ts +48 -2
- package/dist/modules/apimapper/onboarding.js +324 -17
- package/dist/modules/apimapper/onboarding.js.map +1 -1
- package/dist/modules/apimapper/read-cache.d.ts +31 -2
- package/dist/modules/apimapper/read-cache.js +20 -6
- package/dist/modules/apimapper/read-cache.js.map +1 -1
- package/dist/modules/apimapper/render/_shared.d.ts +24 -0
- package/dist/modules/apimapper/render/_shared.js +84 -0
- package/dist/modules/apimapper/render/_shared.js.map +1 -0
- package/dist/modules/apimapper/render/dag.d.ts +18 -0
- package/dist/modules/apimapper/render/dag.js +70 -0
- package/dist/modules/apimapper/render/dag.js.map +1 -0
- package/dist/modules/apimapper/render/index.d.ts +2 -0
- package/dist/modules/apimapper/render/index.js +112 -0
- package/dist/modules/apimapper/render/index.js.map +1 -0
- package/dist/modules/apimapper/render/renderers/chart-bar.d.ts +2 -0
- package/dist/modules/apimapper/render/renderers/chart-bar.js +70 -0
- package/dist/modules/apimapper/render/renderers/chart-bar.js.map +1 -0
- package/dist/modules/apimapper/render/renderers/chart-line.d.ts +2 -0
- package/dist/modules/apimapper/render/renderers/chart-line.js +71 -0
- package/dist/modules/apimapper/render/renderers/chart-line.js.map +1 -0
- package/dist/modules/apimapper/render/renderers/diff.d.ts +2 -0
- package/dist/modules/apimapper/render/renderers/diff.js +154 -0
- package/dist/modules/apimapper/render/renderers/diff.js.map +1 -0
- package/dist/modules/apimapper/render/renderers/flow-diagram.d.ts +1 -0
- package/dist/modules/apimapper/render/renderers/flow-diagram.js +180 -0
- package/dist/modules/apimapper/render/renderers/flow-diagram.js.map +1 -0
- package/dist/modules/apimapper/render/renderers/json-tree.d.ts +2 -0
- package/dist/modules/apimapper/render/renderers/json-tree.js +87 -0
- package/dist/modules/apimapper/render/renderers/json-tree.js.map +1 -0
- package/dist/modules/apimapper/render/renderers/schema-diagram.d.ts +2 -0
- package/dist/modules/apimapper/render/renderers/schema-diagram.js +83 -0
- package/dist/modules/apimapper/render/renderers/schema-diagram.js.map +1 -0
- package/dist/modules/apimapper/render/renderers/table.d.ts +2 -0
- package/dist/modules/apimapper/render/renderers/table.js +75 -0
- package/dist/modules/apimapper/render/renderers/table.js.map +1 -0
- package/dist/modules/apimapper/render/schemas.d.ts +23 -0
- package/dist/modules/apimapper/render/schemas.js +56 -0
- package/dist/modules/apimapper/render/schemas.js.map +1 -0
- package/dist/modules/apimapper/render/secret-masking.d.ts +5 -0
- package/dist/modules/apimapper/render/secret-masking.js +51 -0
- package/dist/modules/apimapper/render/secret-masking.js.map +1 -0
- package/dist/modules/apimapper/render/sidecar.d.ts +21 -0
- package/dist/modules/apimapper/render/sidecar.js +66 -0
- package/dist/modules/apimapper/render/sidecar.js.map +1 -0
- package/dist/modules/apimapper/render/token-cap.d.ts +21 -0
- package/dist/modules/apimapper/render/token-cap.js +57 -0
- package/dist/modules/apimapper/render/token-cap.js.map +1 -0
- package/dist/modules/apimapper/schema.d.ts +2 -2
- package/dist/modules/apimapper/schema.js +100 -32
- package/dist/modules/apimapper/schema.js.map +1 -1
- package/dist/modules/apimapper/settings-format.d.ts +23 -0
- package/dist/modules/apimapper/settings-format.js +135 -0
- package/dist/modules/apimapper/settings-format.js.map +1 -0
- package/dist/modules/apimapper/settings.d.ts +2 -2
- package/dist/modules/apimapper/settings.js +101 -40
- package/dist/modules/apimapper/settings.js.map +1 -1
- package/dist/modules/apimapper/skill-resources.d.ts +2 -2
- package/dist/modules/apimapper/skill-resources.js.map +1 -1
- package/dist/modules/apimapper/token-baseline.harness.d.ts +91 -0
- package/dist/modules/apimapper/token-baseline.harness.js +291 -0
- package/dist/modules/apimapper/token-baseline.harness.js.map +1 -0
- package/dist/modules/apimapper/toolslist-size.d.ts +55 -0
- package/dist/modules/apimapper/toolslist-size.js +190 -0
- package/dist/modules/apimapper/toolslist-size.js.map +1 -0
- package/dist/modules/apimapper/types.d.ts +23 -8
- package/dist/modules/apimapper/types.js +26 -1
- package/dist/modules/apimapper/types.js.map +1 -1
- package/dist/modules/apimapper/use-profile.d.ts +21 -0
- package/dist/modules/apimapper/use-profile.js +56 -2
- package/dist/modules/apimapper/use-profile.js.map +1 -1
- package/dist/modules/apimapper/workflows.d.ts +2 -2
- package/dist/modules/apimapper/workflows.js +143 -16
- package/dist/modules/apimapper/workflows.js.map +1 -1
- package/dist/platform/index.js +44 -5
- package/dist/platform/index.js.map +1 -1
- package/dist/setup-cli.d.ts +53 -0
- package/dist/setup-cli.js +126 -4
- package/dist/setup-cli.js.map +1 -1
- package/docs/architecture.md +1 -1
- package/docs/tools.md +1 -1
- package/manifest.json +12 -3
- package/package.json +9 -4
- package/skills/apimapper/SKILL.md +1 -1
- package/skills/apimapper/reference/render.md +132 -0
- package/skills/apimapper/reference/troubleshooting.md +1 -1
- package/skills/apimapper/reference/yootheme.md +1 -1
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// src/modules/apimapper/connections-trim.ts — pure trim + shape-detect helpers.
|
|
2
|
+
//
|
|
3
|
+
// W3 Stage-2 hardening (rc.13 Welle 3) — extracted verbatim from
|
|
4
|
+
// connections.ts (which had grown to 945 lines, above the ~650-line
|
|
5
|
+
// module-size guideline). `applyTrim` + `extractResourceList` are
|
|
6
|
+
// pre-existing pure functions (F-01/F-38 nested-shape trim and the
|
|
7
|
+
// connection_resources wire-shape normaliser) — no behaviour change, this
|
|
8
|
+
// is a mechanical move so connections.ts stays a lean tool-registration
|
|
9
|
+
// surface. The existing connections.test.ts pins prove equivalence.
|
|
10
|
+
//
|
|
11
|
+
// MODULE-SIZE GUIDELINE — POST-W3 STANCE (F-1.5, Pass-1 consolidation)
|
|
12
|
+
// ====================================================================
|
|
13
|
+
// The original ~600/650-line ceiling was the pre-W3 target for any single
|
|
14
|
+
// MCP tool-registration module. Post-W3 the practical ceiling for a
|
|
15
|
+
// tool-registration module is ~900 lines once handler bodies stay co-located
|
|
16
|
+
// with the registration site. The 5 *-format.ts siblings
|
|
17
|
+
// (connections-format.ts, credentials-format.ts, flows-format.ts,
|
|
18
|
+
// license-format.ts, settings-format.ts) hold the per-tool result builders;
|
|
19
|
+
// pure helpers (this file's applyTrim/extractResourceList, the credential
|
|
20
|
+
// sanitiser, node-schema, envelope, etc.) have been peeled off separately.
|
|
21
|
+
// Further extraction at this point would either:
|
|
22
|
+
//
|
|
23
|
+
// (a) split a handler from its `registerTool(...)` call-site, hurting
|
|
24
|
+
// readability for no measurable benefit, OR
|
|
25
|
+
// (b) duplicate the tool-registration concerns across files (every
|
|
26
|
+
// extracted handler would still have to thread the same `request`,
|
|
27
|
+
// `hintFor`, elicitation capability, format helpers, and capturing
|
|
28
|
+
// server — collapsing the module without simplifying it).
|
|
29
|
+
//
|
|
30
|
+
// Therefore: connections.ts (881), flows.ts (794), library.ts (658),
|
|
31
|
+
// onboarding.ts (603) exceeding the ~600/650 guideline is a documented
|
|
32
|
+
// trade-off, not a backlog item. New tool registrations belong with their
|
|
33
|
+
// domain peers; new pure helpers go into a sibling file. This is the
|
|
34
|
+
// canonical decision-record location — referenced from the post-W3 audit
|
|
35
|
+
// log (Stage 1 / Finding F-1.5).
|
|
36
|
+
//
|
|
37
|
+
// Both functions are re-exported from connections.ts so the public surface
|
|
38
|
+
// (`import { applyTrim, extractResourceList } from "./connections.js"`)
|
|
39
|
+
// is unchanged for existing callers and tests.
|
|
40
|
+
/**
|
|
41
|
+
* Pure trim + shape-detect for connection_data payloads.
|
|
42
|
+
*
|
|
43
|
+
* Extracted from the connection_data handler (W1.2 polish-2) so the
|
|
44
|
+
* shallow-clone contract for nested-items envelopes can be unit-tested
|
|
45
|
+
* directly, without going through the wire-roundtrip handler layer
|
|
46
|
+
* (where stubFetch's JSON.stringify masks reference identity).
|
|
47
|
+
*
|
|
48
|
+
* Detection rules (BEFORE trim):
|
|
49
|
+
* - `array`: `inner` is an Array — slice it directly when trim args are
|
|
50
|
+
* present; otherwise returned as-is.
|
|
51
|
+
* - `nested_items`: `inner` is an object whose `items` field is an Array
|
|
52
|
+
* — shallow-clone the envelope and slice the cloned items array. The
|
|
53
|
+
* shallow-clone is load-bearing: if a caller passes a cached envelope
|
|
54
|
+
* reference, mutating `.items` in place would corrupt the cache for
|
|
55
|
+
* subsequent reads.
|
|
56
|
+
* - `other`: neither of the above — return as-is, `itemCount` undefined.
|
|
57
|
+
*
|
|
58
|
+
* Strict-trim contract: `trimmed: true` and `totalBeforeTrim` are only
|
|
59
|
+
* surfaced when the slice actually cut content (`sliced.length !==
|
|
60
|
+
* source.length`). `limit > length` returns `trimmed: undefined`
|
|
61
|
+
* (truth-in-advertising — no false-positive pagination signals).
|
|
62
|
+
*
|
|
63
|
+
* Defense-in-depth: negative AND non-finite (NaN, ±Infinity) `limit`/
|
|
64
|
+
* `offset` are clamped to 0 at the function boundary.
|
|
65
|
+
* `Number.isFinite()` returns false for NaN/Infinity/-Infinity —
|
|
66
|
+
* providing a clean "is this a usable trim integer?" guard. Combined
|
|
67
|
+
* with the `>= 0` check, any invalid input (negative, NaN, Infinity)
|
|
68
|
+
* deterministically maps to 0 = "trim to empty". `applyTrim` is an
|
|
69
|
+
* exported public surface, so the caller is not guaranteed to be the
|
|
70
|
+
* Zod-validated handler.
|
|
71
|
+
*
|
|
72
|
+
* Schema-vs-contract asymmetry: this function-level contract treats
|
|
73
|
+
* `limit=0` as a valid "explicit empty payload" signal. The MCP tool
|
|
74
|
+
* surface (Zod schema) enforces `.min(1).max(500)` and therefore
|
|
75
|
+
* rejects `limit=0` before it reaches `applyTrim`. The permissive
|
|
76
|
+
* function contract is intentionally broader than the wire contract;
|
|
77
|
+
* `limit=0` is only reachable by direct programmatic callers (e.g.
|
|
78
|
+
* unit tests, internal pipeline composers), not by AI clients hitting
|
|
79
|
+
* the MCP tool.
|
|
80
|
+
*
|
|
81
|
+
* @param inner - REST inner payload (post-envelope-unwrap, untyped)
|
|
82
|
+
* @param limit - Max items to return after offset; `undefined` = no trim,
|
|
83
|
+
* `0` = explicit empty payload, negative/non-finite values clamp to 0.
|
|
84
|
+
* NOTE: the MCP tool's Zod schema (`.min(1).max(500)`) rejects `0` at
|
|
85
|
+
* the wire boundary — `limit=0` is only reachable via direct
|
|
86
|
+
* programmatic callers, not AI clients.
|
|
87
|
+
* @param offset - Skip items before slice; `undefined` = 0,
|
|
88
|
+
* negative/non-finite values clamp to 0
|
|
89
|
+
* @returns Trim result with `detectedShape`, `payload` (potentially
|
|
90
|
+
* sliced), `itemCount`, `totalBeforeTrim`, and `trimmed` metadata
|
|
91
|
+
*/
|
|
92
|
+
export function applyTrim(inner, limit, offset) {
|
|
93
|
+
// Defense-in-depth: clamp negative AND non-finite (NaN, ±Infinity)
|
|
94
|
+
// limit/offset to 0. Number.isFinite() returns false for NaN/Infinity/
|
|
95
|
+
// -Infinity — providing a clean "is this a usable trim integer?"
|
|
96
|
+
// guard. Combined with the >= 0 check, any invalid input (negative,
|
|
97
|
+
// NaN, Infinity) deterministically maps to 0 = "trim to empty".
|
|
98
|
+
// Rationale: NaN < 0 evaluates to false (regular comparison rules),
|
|
99
|
+
// so a naive `< 0` check would let NaN fall through to Array.slice
|
|
100
|
+
// (which coerces NaN → 0 and returns []) — coincidentally safe but
|
|
101
|
+
// misleading because `trimmed: true` would still surface. Same for
|
|
102
|
+
// Infinity, which slice would treat as "no upper bound" (returning
|
|
103
|
+
// the full array but marking trimmed=false-by-accident). Treating
|
|
104
|
+
// both as "invalid → 0" yields a single consistent contract.
|
|
105
|
+
const safeLimit = limit === undefined
|
|
106
|
+
? undefined
|
|
107
|
+
: Number.isFinite(limit) && limit >= 0
|
|
108
|
+
? limit
|
|
109
|
+
: 0;
|
|
110
|
+
const safeOffset = offset === undefined
|
|
111
|
+
? undefined
|
|
112
|
+
: Number.isFinite(offset) && offset >= 0
|
|
113
|
+
? offset
|
|
114
|
+
: 0;
|
|
115
|
+
const hasTrimArgs = safeLimit !== undefined || safeOffset !== undefined;
|
|
116
|
+
if (Array.isArray(inner)) {
|
|
117
|
+
const arr = inner;
|
|
118
|
+
if (hasTrimArgs) {
|
|
119
|
+
const start = safeOffset ?? 0;
|
|
120
|
+
const end = safeLimit !== undefined ? start + safeLimit : undefined;
|
|
121
|
+
const sliced = arr.slice(start, end);
|
|
122
|
+
if (sliced.length !== arr.length) {
|
|
123
|
+
return {
|
|
124
|
+
payload: sliced,
|
|
125
|
+
detectedShape: "array",
|
|
126
|
+
itemCount: sliced.length,
|
|
127
|
+
totalBeforeTrim: arr.length,
|
|
128
|
+
trimmed: true,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
return {
|
|
132
|
+
payload: sliced,
|
|
133
|
+
detectedShape: "array",
|
|
134
|
+
itemCount: sliced.length,
|
|
135
|
+
totalBeforeTrim: undefined,
|
|
136
|
+
trimmed: undefined,
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
payload: arr,
|
|
141
|
+
detectedShape: "array",
|
|
142
|
+
itemCount: arr.length,
|
|
143
|
+
totalBeforeTrim: undefined,
|
|
144
|
+
trimmed: undefined,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
if (inner !== null &&
|
|
148
|
+
typeof inner === "object" &&
|
|
149
|
+
Array.isArray(inner.items)) {
|
|
150
|
+
const innerObj = inner;
|
|
151
|
+
const nestedItems = innerObj.items;
|
|
152
|
+
if (hasTrimArgs) {
|
|
153
|
+
const start = safeOffset ?? 0;
|
|
154
|
+
const end = safeLimit !== undefined ? start + safeLimit : undefined;
|
|
155
|
+
const sliced = nestedItems.slice(start, end);
|
|
156
|
+
// Shallow-clone — never mutate the caller's envelope object.
|
|
157
|
+
const cloned = { ...innerObj, items: sliced };
|
|
158
|
+
if (sliced.length !== nestedItems.length) {
|
|
159
|
+
return {
|
|
160
|
+
payload: cloned,
|
|
161
|
+
detectedShape: "nested_items",
|
|
162
|
+
itemCount: sliced.length,
|
|
163
|
+
totalBeforeTrim: nestedItems.length,
|
|
164
|
+
trimmed: true,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
payload: cloned,
|
|
169
|
+
detectedShape: "nested_items",
|
|
170
|
+
itemCount: sliced.length,
|
|
171
|
+
totalBeforeTrim: undefined,
|
|
172
|
+
trimmed: undefined,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return {
|
|
176
|
+
payload: innerObj,
|
|
177
|
+
detectedShape: "nested_items",
|
|
178
|
+
itemCount: nestedItems.length,
|
|
179
|
+
totalBeforeTrim: undefined,
|
|
180
|
+
trimmed: undefined,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
payload: inner,
|
|
185
|
+
detectedShape: "other",
|
|
186
|
+
itemCount: undefined,
|
|
187
|
+
totalBeforeTrim: undefined,
|
|
188
|
+
trimmed: undefined,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* A1-P3-1: pure helper that normalises the three wire-shapes the
|
|
193
|
+
* `apimapper_connection_resources` REST endpoint can return:
|
|
194
|
+
*
|
|
195
|
+
* 1. bare array — `[{...}, {...}]`
|
|
196
|
+
* 2. `{ resources: [...] }` envelope (canonical post-Wave-1B)
|
|
197
|
+
* 3. `{ items: [...] }` envelope (legacy / library-style)
|
|
198
|
+
*
|
|
199
|
+
* Anything else (null, primitive, foreign-shaped object) resolves to
|
|
200
|
+
* `[]` rather than throwing — the handler then renders `resource_count:
|
|
201
|
+
* 0` and the AI client knows the picker is empty. Throwing here would
|
|
202
|
+
* leak an opaque type-error out of the tool surface.
|
|
203
|
+
*
|
|
204
|
+
* Precedence is `bare-array > resources > items`. The `resources`-over-
|
|
205
|
+
* `items` order is pinned in connections.test.ts because callers like
|
|
206
|
+
* the ResourcePicker rely on the canonical field winning when servers
|
|
207
|
+
* accidentally emit both (defensive against backend drift).
|
|
208
|
+
*
|
|
209
|
+
* Exported so the test suite can pin each branch atomically without
|
|
210
|
+
* going through the wire-roundtrip handler layer.
|
|
211
|
+
*/
|
|
212
|
+
export function extractResourceList(data) {
|
|
213
|
+
if (Array.isArray(data))
|
|
214
|
+
return data;
|
|
215
|
+
if (data !== null && typeof data === "object") {
|
|
216
|
+
const obj = data;
|
|
217
|
+
if (Array.isArray(obj.resources))
|
|
218
|
+
return obj.resources;
|
|
219
|
+
if (Array.isArray(obj.items))
|
|
220
|
+
return obj.items;
|
|
221
|
+
}
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=connections-trim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connections-trim.js","sourceRoot":"","sources":["../../../src/modules/apimapper/connections-trim.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,EAAE;AACF,iEAAiE;AACjE,oEAAoE;AACpE,kEAAkE;AAClE,mEAAmE;AACnE,0EAA0E;AAC1E,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,uEAAuE;AACvE,uEAAuE;AACvE,0EAA0E;AAC1E,oEAAoE;AACpE,6EAA6E;AAC7E,yDAAyD;AACzD,kEAAkE;AAClE,4EAA4E;AAC5E,0EAA0E;AAC1E,2EAA2E;AAC3E,iDAAiD;AACjD,EAAE;AACF,wEAAwE;AACxE,kDAAkD;AAClD,qEAAqE;AACrE,yEAAyE;AACzE,yEAAyE;AACzE,gEAAgE;AAChE,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,0EAA0E;AAC1E,qEAAqE;AACrE,yEAAyE;AACzE,iCAAiC;AACjC,EAAE;AAC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-server.js";
|
|
2
|
+
import { type McpServerWithElicitation } from "./elicitation.js";
|
|
3
|
+
import { applyTrim, extractResourceList, type ApplyTrimResult } from "./connections-trim.js";
|
|
4
|
+
export { applyTrim, extractResourceList, type ApplyTrimResult };
|
|
5
|
+
/**
|
|
6
|
+
* Register the connection CRUD + probe + sample + pipeline tools.
|
|
7
|
+
*
|
|
8
|
+
* @param server the tool registrar (essentials forward, rest captured).
|
|
9
|
+
* @param elicitation optional elicitation capability (the real McpServer, or
|
|
10
|
+
* any `{ server: { elicitInput } }`). Supplied only by the host wiring in
|
|
11
|
+
* index.ts. When omitted, `connection_create` falls back to a structured
|
|
12
|
+
* error on genuine credential ambiguity instead of prompting.
|
|
13
|
+
*/
|
|
14
|
+
export declare function registerConnectionTools(server: ToolRegistrar, elicitation?: McpServerWithElicitation): void;
|