@wootsup/mcp 0.1.0-rc.9 → 0.3.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/CHANGELOG.md +148 -83
- package/README.md +36 -32
- package/SECURITY.md +15 -6
- package/dist/auth/keychain.d.ts +27 -1
- package/dist/auth/keychain.js +48 -2
- package/dist/auth/keychain.js.map +1 -1
- package/dist/cli-hint.d.ts +22 -0
- package/dist/cli-hint.js +55 -0
- package/dist/cli-hint.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +163 -22
- package/dist/index.js.map +1 -1
- package/dist/install-skill.js +1 -1
- package/dist/modules/apimapper/cache.d.ts +2 -2
- package/dist/modules/apimapper/cache.js +119 -29
- package/dist/modules/apimapper/cache.js.map +1 -1
- package/dist/modules/apimapper/client.d.ts +102 -1
- package/dist/modules/apimapper/client.js +631 -297
- 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 +612 -153
- package/dist/modules/apimapper/connections.js.map +1 -1
- package/dist/modules/apimapper/credential-sanitizer.d.ts +5 -0
- package/dist/modules/apimapper/credential-sanitizer.js +60 -1
- package/dist/modules/apimapper/credential-sanitizer.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 +226 -73
- package/dist/modules/apimapper/credentials.js.map +1 -1
- package/dist/modules/apimapper/diagnose.d.ts +54 -2
- package/dist/modules/apimapper/diagnose.js +213 -12
- 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 +312 -122
- 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 +265 -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 +35 -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 +47 -7
- 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 +170 -35
- package/dist/modules/apimapper/graph.js.map +1 -1
- package/dist/modules/apimapper/index.d.ts +17 -1
- package/dist/modules/apimapper/index.js +68 -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 +665 -80
- 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 +62 -38
- 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 +44 -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 +114 -49
- 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 +78 -3
- package/dist/modules/apimapper/onboarding.js +428 -26
- 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 +92 -33
- 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 +100 -42
- package/dist/modules/apimapper/settings.js.map +1 -1
- package/dist/modules/apimapper/sites-tools.d.ts +29 -0
- package/dist/modules/apimapper/sites-tools.js +165 -0
- package/dist/modules/apimapper/sites-tools.js.map +1 -0
- 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/tool-result.d.ts +46 -0
- package/dist/modules/apimapper/tool-result.js +63 -0
- package/dist/modules/apimapper/tool-result.js.map +1 -0
- package/dist/modules/apimapper/toolslist-size.d.ts +56 -0
- package/dist/modules/apimapper/toolslist-size.js +192 -0
- package/dist/modules/apimapper/toolslist-size.js.map +1 -0
- package/dist/modules/apimapper/types.d.ts +44 -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/whitelist-drift.d.ts +85 -0
- package/dist/modules/apimapper/whitelist-drift.js +360 -0
- package/dist/modules/apimapper/whitelist-drift.js.map +1 -0
- package/dist/modules/apimapper/workflows.d.ts +2 -2
- package/dist/modules/apimapper/workflows.js +202 -20
- package/dist/modules/apimapper/workflows.js.map +1 -1
- package/dist/modules/apimapper/yootheme-binding.d.ts +35 -0
- package/dist/modules/apimapper/yootheme-binding.js +186 -0
- package/dist/modules/apimapper/yootheme-binding.js.map +1 -0
- package/dist/platform/index.d.ts +56 -0
- package/dist/platform/index.js +195 -7
- package/dist/platform/index.js.map +1 -1
- package/dist/setup/detect-clients.d.ts +40 -1
- package/dist/setup/detect-clients.js +148 -1
- package/dist/setup/detect-clients.js.map +1 -1
- package/dist/setup/probe-handshake.js +40 -7
- package/dist/setup/probe-handshake.js.map +1 -1
- package/dist/setup/remove-config.d.ts +8 -0
- package/dist/setup/remove-config.js +145 -0
- package/dist/setup/remove-config.js.map +1 -0
- package/dist/setup/uninstall.d.ts +34 -0
- package/dist/setup/uninstall.js +147 -0
- package/dist/setup/uninstall.js.map +1 -0
- package/dist/setup-cli.d.ts +60 -0
- package/dist/setup-cli.js +155 -5
- package/dist/setup-cli.js.map +1 -1
- package/dist/sites/loader.d.ts +41 -0
- package/dist/sites/loader.js +119 -0
- package/dist/sites/loader.js.map +1 -0
- package/dist/sites/schema.d.ts +69 -0
- package/dist/sites/schema.js +71 -0
- package/dist/sites/schema.js.map +1 -0
- package/dist/sites/secret-resolver.d.ts +47 -0
- package/dist/sites/secret-resolver.js +150 -0
- package/dist/sites/secret-resolver.js.map +1 -0
- package/dist/skill-instructions.d.ts +1 -1
- package/dist/skill-instructions.js +5 -0
- package/dist/skill-instructions.js.map +1 -1
- package/dist/transports/stdio.js +4 -4
- package/dist/transports/stdio.js.map +1 -1
- package/dist/uninstall-skill.d.ts +27 -0
- package/dist/uninstall-skill.js +89 -0
- package/dist/uninstall-skill.js.map +1 -0
- package/docs/architecture.md +22 -22
- package/docs/customgraph-internal-migration.md +4 -4
- package/docs/security.md +2 -21
- package/docs/tools.md +40 -12
- package/manifest.json +77 -70
- package/package.json +68 -60
- package/skills/apimapper/SKILL.md +53 -7
- package/skills/apimapper/reference/conditional-style-multi-items.md +114 -0
- package/skills/apimapper/reference/jmespath-pitfalls.md +108 -0
- package/skills/apimapper/reference/joomla.md +1 -1
- package/skills/apimapper/reference/library-template-discovery.md +65 -0
- package/skills/apimapper/reference/merge-two-sources-on-key.md +99 -0
- package/skills/apimapper/reference/render.md +132 -0
- package/skills/apimapper/reference/troubleshooting.md +21 -1
- package/skills/apimapper/reference/yootheme.md +1 -1
- package/dist/auth/oauth-provider.d.ts +0 -68
- package/dist/auth/oauth-provider.js +0 -232
- package/dist/auth/oauth-provider.js.map +0 -1
- package/dist/server-http.d.ts +0 -22
- package/dist/server-http.js +0 -159
- package/dist/server-http.js.map +0 -1
- package/dist/transports/http.d.ts +0 -29
- package/dist/transports/http.js +0 -267
- package/dist/transports/http.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sites-tools.js","sourceRoot":"","sources":["../../../src/modules/apimapper/sites-tools.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,EAAE;AACF,+EAA+E;AAC/E,iFAAiF;AACjF,mFAAmF;AACnF,4EAA4E;AAC5E,6EAA6E;AAC7E,4EAA4E;AAC5E,EAAE;AACF,iFAAiF;AACjF,8EAA8E;AAC9E,gFAAgF;AAChF,wBAAwB;AAGxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAGvE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAmCtC,MAAM,UAAU,6BAA6B,CAC3C,MAAiC,EACjC,IAA2B;IAE3B,MAAM,SAAS,GAAG,MAAuB,CAAC;IAE1C,SAAS,CAAC,YAAY,CACpB,yBAAyB,EACzB;QACE,KAAK,EAAE,0BAA0B;QACjC,WAAW,EACT,sEAAsE;YACtE,2DAA2D;YAC3D,oDAAoD;YACpD,8DAA8D;YAC9D,mDAAmD;YACnD,wCAAwC;YACxC,uBAAuB;YACvB,yFAAyF;QAC3F,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,QAAQ,CAAC,EAAE,KAAK,EAAE,0BA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AY;YACpB,QAAQ,EAAE;gBACR,cAAc,EAAE,QAAQ,CAAC,cAAc;gBACvC,WAAW,EAAE,QAAQ,CAAC,WAAW;gBACjC,YAAY,EAAE,QAAQ,CAAC,YAAY;gBACnC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;aAC5B;SACF,EACD,KAAK,EACL,EAAE,QAAQ,EAAE,IAAI,EAAE,CACnB,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ToolRegistrar } from "./gateway/capturing-server.js";
|
|
2
2
|
export declare const SKILL_RESOURCE_URIS: readonly ["skill://apimapper/getting-started", "skill://apimapper/oauth", "skill://apimapper/yootheme", "skill://apimapper/joomla", "skill://apimapper/troubleshooting"];
|
|
3
3
|
export type SkillResourceUri = (typeof SKILL_RESOURCE_URIS)[number];
|
|
4
|
-
export declare function registerSkillResources(server:
|
|
4
|
+
export declare function registerSkillResources(server: ToolRegistrar, rootDir?: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skill-resources.js","sourceRoot":"","sources":["../../../src/modules/apimapper/skill-resources.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,EAAE;AACF,sEAAsE;AACtE,4EAA4E;AAC5E,6DAA6D;AAC7D,EAAE;AACF,6EAA6E;AAC7E,uEAAuE;AACvE,0EAA0E;AAC1E,EAAE;AACF,4CAA4C;AAC5C,8EAA8E;AAC9E,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,uCAAuC;AACvC,qFAAqF;AAGrF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,mCAAmC;IACnC,yBAAyB;IACzB,4BAA4B;IAC5B,0BAA0B;IAC1B,mCAAmC;CAC3B,CAAC;AAYX,MAAM,SAAS,GAAwB;IACrC;QACE,GAAG,EAAE,mCAAmC;QACxC,IAAI,EAAE,2BAA2B;QACjC,KAAK,EAAE,8BAA8B;QACrC,WAAW,EACT,gGAAgG;QAClG,QAAQ,EAAE,UAAU;KACrB;IACD;QACE,GAAG,EAAE,yBAAyB;QAC9B,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,4BAA4B;QACnC,WAAW,EACT,+FAA+F;QACjG,QAAQ,EAAE,oBAAoB;KAC/B;IACD;QACE,GAAG,EAAE,4BAA4B;QACjC,IAAI,EAAE,oBAAoB;QAC1B,KAAK,EAAE,uCAAuC;QAC9C,WAAW,EACT,iGAAiG;QACnG,QAAQ,EAAE,uBAAuB;KAClC;IACD;QACE,GAAG,EAAE,0BAA0B;QAC/B,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,2BAA2B;QAClC,WAAW,EAAE,2FAA2F;QACxG,QAAQ,EAAE,qBAAqB;KAChC;IACD;QACE,GAAG,EAAE,mCAAmC;QACxC,IAAI,EAAE,2BAA2B;QACjC,KAAK,EAAE,8BAA8B;QACrC,WAAW,EACT,mGAAmG;QACrG,QAAQ,EAAE,8BAA8B;KACzC;CACF,CAAC;AAEF,SAAS,iBAAiB;IACxB,2EAA2E;IAC3E,sEAAsE;IACtE,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"skill-resources.js","sourceRoot":"","sources":["../../../src/modules/apimapper/skill-resources.ts"],"names":[],"mappings":"AAAA,wDAAw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,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A canned REST body — either a raw string sent as-is, or a JSON-serializable
|
|
3
|
+
* object/array that the harness stringifies. Narrowing to these three shapes
|
|
4
|
+
* keeps the `JSON.stringify` branch type-safe without falling back to `unknown`.
|
|
5
|
+
*/
|
|
6
|
+
export type CannedBody = string | Record<string, unknown> | unknown[];
|
|
7
|
+
/** A single fetch result the responder hands back for one upstream URL. */
|
|
8
|
+
export interface CannedResponse {
|
|
9
|
+
/** HTTP status. Defaults to 200 when omitted. */
|
|
10
|
+
status?: number;
|
|
11
|
+
/** Response body — an object/array is JSON-stringified; a string is sent as-is. */
|
|
12
|
+
body: CannedBody;
|
|
13
|
+
}
|
|
14
|
+
/** Maps an upstream request (URL + init) to a canned REST response. */
|
|
15
|
+
export type FetchResponder = (url: string, init?: RequestInit) => CannedResponse;
|
|
16
|
+
/** The shape every apimapper tool handler resolves to (MCP CallToolResult). */
|
|
17
|
+
interface ToolCallResult {
|
|
18
|
+
content?: Array<{
|
|
19
|
+
type: string;
|
|
20
|
+
text?: string;
|
|
21
|
+
}>;
|
|
22
|
+
isError?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A registered tool: its handler is what the harness invokes. */
|
|
25
|
+
export interface RegisteredHarnessTool {
|
|
26
|
+
handler: (args: Record<string, unknown>, extra?: unknown) => Promise<ToolCallResult> | ToolCallResult;
|
|
27
|
+
}
|
|
28
|
+
/** Per-tool byte tally for one replayed call. */
|
|
29
|
+
export interface SequenceEntry {
|
|
30
|
+
tool: string;
|
|
31
|
+
/**
|
|
32
|
+
* Total UTF-8 bytes of the result's `content[].text` blocks — the raw
|
|
33
|
+
* payload an MCP client receives. This is the historical token-baseline
|
|
34
|
+
* metric and the field the ≥40% goal is measured against.
|
|
35
|
+
*/
|
|
36
|
+
bytes: number;
|
|
37
|
+
/**
|
|
38
|
+
* `bytes` minus the toolkit's embedded `<!-- structured-meta:… -->` base64
|
|
39
|
+
* marker(s). Some MCP hosts (the WootsUp Chat UI) strip this marker before
|
|
40
|
+
* the LLM sees the text; generic hosts (Claude Desktop / Cursor) do not.
|
|
41
|
+
* Reporting both keeps the post-W3 measurement honest about which figure a
|
|
42
|
+
* given host actually pays.
|
|
43
|
+
*/
|
|
44
|
+
visibleBytes: number;
|
|
45
|
+
}
|
|
46
|
+
/** The full harness measurement. */
|
|
47
|
+
export interface TokenBaselineResult {
|
|
48
|
+
sequence: SequenceEntry[];
|
|
49
|
+
/** Sum of `bytes` (raw text incl. structured-meta marker) across the run. */
|
|
50
|
+
totalBytes: number;
|
|
51
|
+
/** Sum of `visibleBytes` (marker stripped) across the run. */
|
|
52
|
+
totalVisibleBytes: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One step of the canonical sequence — the tool to invoke and the canned
|
|
56
|
+
* real-shape arguments to invoke it with.
|
|
57
|
+
*/
|
|
58
|
+
interface SequenceStep {
|
|
59
|
+
tool: string;
|
|
60
|
+
args: Record<string, unknown>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The canonical 8-call walkthrough (the Maria mixed-feed flow): a fresh user
|
|
64
|
+
* discovers the install, activates a library template, inspects a connection,
|
|
65
|
+
* builds and validates a flow, then compiles it. Inputs are real-shape and
|
|
66
|
+
* fixed so the measurement is reproducible.
|
|
67
|
+
*/
|
|
68
|
+
export declare const CANONICAL_SEQUENCE: readonly SequenceStep[];
|
|
69
|
+
/** The tool names the canonical sequence exercises, in call order. */
|
|
70
|
+
export declare const CANONICAL_TOOLS: readonly string[];
|
|
71
|
+
/**
|
|
72
|
+
* Canonical fetch responder — routes an upstream URL to its real-shape
|
|
73
|
+
* fixture. Anything unmatched returns an empty-success envelope, which is the
|
|
74
|
+
* benign default for the optional sub-calls inside `apimapper_onboarding`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function canonicalFetchResponder(url: string): CannedResponse;
|
|
77
|
+
/**
|
|
78
|
+
* Strip every embedded structured-meta marker from a text block. What remains
|
|
79
|
+
* is the human/LLM-readable text a marker-aware host (the WootsUp Chat UI)
|
|
80
|
+
* presents after extracting the marker into a Rich Card.
|
|
81
|
+
*/
|
|
82
|
+
export declare function stripStructuredMeta(text: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* Replay the canonical sequence and measure total token output.
|
|
85
|
+
*
|
|
86
|
+
* @param tools the registered apimapper tools map (name → tool)
|
|
87
|
+
* @param fetchResponder maps each upstream URL to a canned REST response
|
|
88
|
+
* @returns per-tool byte tally + `totalBytes` across the whole sequence
|
|
89
|
+
*/
|
|
90
|
+
export declare function runTokenBaseline(tools: Record<string, RegisteredHarnessTool>, fetchResponder: FetchResponder): Promise<TokenBaselineResult>;
|
|
91
|
+
export {};
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
// token-baseline.harness.ts — W3.0.C
|
|
2
|
+
//
|
|
3
|
+
// Deterministic, offline token-output measurement for the canonical API
|
|
4
|
+
// Mapper tool-call sequence. The SAME harness is re-run after Welle 3 ships;
|
|
5
|
+
// the before/after delta is what proves the ≥40% token-reduction goal, so
|
|
6
|
+
// consistency between runs matters more than the absolute number.
|
|
7
|
+
//
|
|
8
|
+
// How it works:
|
|
9
|
+
// 1. The caller passes the registered apimapper tools map (the live
|
|
10
|
+
// `registerTool` config + handler for every tool) and a `fetchResponder`
|
|
11
|
+
// that maps an upstream URL to a canned real-shape REST response.
|
|
12
|
+
// 2. `runTokenBaseline` installs the responder as `globalThis.fetch`,
|
|
13
|
+
// replays the 8-call canonical sequence against the real tool handlers
|
|
14
|
+
// with canned real-shape inputs, sums the UTF-8 byte length of every
|
|
15
|
+
// result's `content[].text` block, and restores `globalThis.fetch`.
|
|
16
|
+
// 3. It returns `{ sequence: [{ tool, bytes }], totalBytes }`.
|
|
17
|
+
//
|
|
18
|
+
// No network, no child process — the tool handlers run in-process and the
|
|
19
|
+
// REST layer is the supplied responder. Given the same tools map and the
|
|
20
|
+
// same responder, the result is byte-for-byte identical (determinism is
|
|
21
|
+
// pinned by token-baseline.test.ts).
|
|
22
|
+
/**
|
|
23
|
+
* The canonical 8-call walkthrough (the Maria mixed-feed flow): a fresh user
|
|
24
|
+
* discovers the install, activates a library template, inspects a connection,
|
|
25
|
+
* builds and validates a flow, then compiles it. Inputs are real-shape and
|
|
26
|
+
* fixed so the measurement is reproducible.
|
|
27
|
+
*/
|
|
28
|
+
export const CANONICAL_SEQUENCE = [
|
|
29
|
+
{ tool: "apimapper_onboarding", args: {} },
|
|
30
|
+
{ tool: "apimapper_library_list", args: { limit: 25 } },
|
|
31
|
+
{
|
|
32
|
+
tool: "apimapper_library_activate",
|
|
33
|
+
args: { id: "pexels", extra_fields: { api_key: "demo-key" } },
|
|
34
|
+
},
|
|
35
|
+
{ tool: "apimapper_connection_list", args: {} },
|
|
36
|
+
{ tool: "apimapper_connection_data", args: { id: "con_pexels", limit: 10 } },
|
|
37
|
+
{
|
|
38
|
+
tool: "apimapper_flow_create",
|
|
39
|
+
args: {
|
|
40
|
+
name: "Maria Mixed Feed",
|
|
41
|
+
nodes: [
|
|
42
|
+
{
|
|
43
|
+
id: "src1",
|
|
44
|
+
type: "source",
|
|
45
|
+
position: { x: 0, y: 0 },
|
|
46
|
+
data: { connectionId: "con_pexels" },
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "out1",
|
|
50
|
+
type: "output-yootheme",
|
|
51
|
+
position: { x: 300, y: 0 },
|
|
52
|
+
data: { name: "Mixed Feed" },
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
edges: [{ id: "e1", source: "src1", target: "out1" }],
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
tool: "apimapper_graph_validate",
|
|
60
|
+
args: {
|
|
61
|
+
nodes: [
|
|
62
|
+
{
|
|
63
|
+
id: "src1",
|
|
64
|
+
type: "source",
|
|
65
|
+
position: { x: 0, y: 0 },
|
|
66
|
+
data: { connectionId: "con_pexels" },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "out1",
|
|
70
|
+
type: "output-yootheme",
|
|
71
|
+
position: { x: 300, y: 0 },
|
|
72
|
+
data: { name: "Mixed Feed" },
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
edges: [{ id: "e1", source: "src1", target: "out1" }],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
{ tool: "apimapper_flow_compile", args: { id: "flow_maria01" } },
|
|
79
|
+
];
|
|
80
|
+
/** The tool names the canonical sequence exercises, in call order. */
|
|
81
|
+
export const CANONICAL_TOOLS = CANONICAL_SEQUENCE.map((s) => s.tool);
|
|
82
|
+
// ── Canonical real-shape REST fixtures ──────────────────────────────────
|
|
83
|
+
//
|
|
84
|
+
// One fixture per upstream endpoint the canonical sequence touches. Shapes
|
|
85
|
+
// mirror the actual PHP wire responses (the same shapes the per-module test
|
|
86
|
+
// files assert against). Keeping them here — alongside the sequence — means
|
|
87
|
+
// the determinism test and the scripts/token-baseline.mjs runner measure the
|
|
88
|
+
// exact same byte budget; the responder is a single source of truth.
|
|
89
|
+
// `provider` mirrors the real library.test.ts fixtures — the library_list
|
|
90
|
+
// handler reads it for the client-side provider filter, so shipping it keeps
|
|
91
|
+
// the measured shape faithful to the live PHP wire response.
|
|
92
|
+
const LIBRARY_ITEMS = [
|
|
93
|
+
{
|
|
94
|
+
id: "pexels",
|
|
95
|
+
name: "Pexels",
|
|
96
|
+
provider: "pexels",
|
|
97
|
+
category: "media",
|
|
98
|
+
description: "Free stock photos and videos via the Pexels REST API.",
|
|
99
|
+
auth_type: "apikey",
|
|
100
|
+
popular: true,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: "google-sheets",
|
|
104
|
+
name: "Google Sheets",
|
|
105
|
+
provider: "google",
|
|
106
|
+
category: "productivity",
|
|
107
|
+
description: "Read rows from a Google Sheets spreadsheet.",
|
|
108
|
+
auth_type: "oauth2_authcode",
|
|
109
|
+
popular: true,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
id: "instagram",
|
|
113
|
+
name: "Instagram Graph",
|
|
114
|
+
provider: "instagram",
|
|
115
|
+
category: "social",
|
|
116
|
+
description: "Fetch media from an Instagram Business account.",
|
|
117
|
+
auth_type: "oauth2_authcode",
|
|
118
|
+
popular: false,
|
|
119
|
+
},
|
|
120
|
+
];
|
|
121
|
+
const CONNECTIONS = [
|
|
122
|
+
{
|
|
123
|
+
id: "con_pexels",
|
|
124
|
+
name: "Pexels — Curated",
|
|
125
|
+
source_type: "pexels",
|
|
126
|
+
status: "active",
|
|
127
|
+
credential_id: "cred_pexels1",
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
const PEXELS_ROWS = Array.from({ length: 10 }, (_, i) => ({
|
|
131
|
+
id: 1000 + i,
|
|
132
|
+
title: `Curated photo ${i + 1}`,
|
|
133
|
+
photographer: `Photographer ${i + 1}`,
|
|
134
|
+
image: { url: `https://images.pexels.com/photos/${1000 + i}/photo.jpg` },
|
|
135
|
+
width: 1920,
|
|
136
|
+
height: 1280,
|
|
137
|
+
}));
|
|
138
|
+
const FLOW_OBJECT = {
|
|
139
|
+
id: "flow_maria01",
|
|
140
|
+
name: "Maria Mixed Feed",
|
|
141
|
+
node_count: 2,
|
|
142
|
+
is_compiled: false,
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Canonical fetch responder — routes an upstream URL to its real-shape
|
|
146
|
+
* fixture. Anything unmatched returns an empty-success envelope, which is the
|
|
147
|
+
* benign default for the optional sub-calls inside `apimapper_onboarding`.
|
|
148
|
+
*/
|
|
149
|
+
export function canonicalFetchResponder(url) {
|
|
150
|
+
if (url.includes("/library/popular")) {
|
|
151
|
+
return { body: { connections: LIBRARY_ITEMS.filter((i) => i.popular) } };
|
|
152
|
+
}
|
|
153
|
+
if (url.includes("/library/featured")) {
|
|
154
|
+
return { body: { connections: LIBRARY_ITEMS.slice(0, 2) } };
|
|
155
|
+
}
|
|
156
|
+
if (url.includes("/library/categories")) {
|
|
157
|
+
return {
|
|
158
|
+
body: {
|
|
159
|
+
categories: [
|
|
160
|
+
{ id: "media", name: "Media", count: 4 },
|
|
161
|
+
{ id: "social", name: "Social", count: 3 },
|
|
162
|
+
],
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
if (url.includes("/library/pexels/activate")) {
|
|
167
|
+
return {
|
|
168
|
+
body: {
|
|
169
|
+
success: true,
|
|
170
|
+
connection: { id: "con_pexels", name: "Pexels", source_type: "pexels" },
|
|
171
|
+
reused: false,
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
if (url.includes("/library")) {
|
|
176
|
+
return { body: { connections: LIBRARY_ITEMS, total: LIBRARY_ITEMS.length } };
|
|
177
|
+
}
|
|
178
|
+
if (url.includes("/connections/con_pexels/data")) {
|
|
179
|
+
// Real backend returns the connection as an OBJECT, not a bare id —
|
|
180
|
+
// mirrors the {data, connection:{…}} envelope the connections.test.ts
|
|
181
|
+
// fixtures assert against, so the byte measurement stays realistic.
|
|
182
|
+
return {
|
|
183
|
+
body: {
|
|
184
|
+
data: PEXELS_ROWS,
|
|
185
|
+
connection: {
|
|
186
|
+
id: "con_pexels",
|
|
187
|
+
name: "Pexels — Curated",
|
|
188
|
+
source_type: "pexels",
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (url.includes("/connections")) {
|
|
194
|
+
return { body: { connections: CONNECTIONS } };
|
|
195
|
+
}
|
|
196
|
+
if (url.includes("/flows/flow_maria01/compile")) {
|
|
197
|
+
return { body: { compiled: {}, flowId: "flow_maria01" } };
|
|
198
|
+
}
|
|
199
|
+
if (url.includes("/flows")) {
|
|
200
|
+
return { body: { success: true, flow: FLOW_OBJECT } };
|
|
201
|
+
}
|
|
202
|
+
if (url.includes("/graph/validate")) {
|
|
203
|
+
return {
|
|
204
|
+
body: { valid: true, warnings: [], nodeCount: 2, edgeCount: 1 },
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
if (url.includes("/health")) {
|
|
208
|
+
return {
|
|
209
|
+
body: { plugin_version: "2.0.7", api_version: "v1", status: "ok" },
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
if (url.includes("/license")) {
|
|
213
|
+
return { body: { tier: "pro", status: "active" } };
|
|
214
|
+
}
|
|
215
|
+
// Benign default for any onboarding sub-call without a dedicated fixture.
|
|
216
|
+
return { body: {} };
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Matches the toolkit's embedded structured-meta marker — a trailing
|
|
220
|
+
* `\n\n<!-- structured-meta:<base64> -->` block appended by the
|
|
221
|
+
* `tableResult` / `detailResult` / … builders so `_meta.ui` survives
|
|
222
|
+
* `@ai-sdk/mcp`'s conversion (see @getimo/mcp-toolkit `embedStructuredMeta`).
|
|
223
|
+
* The `[A-Za-z0-9+/=]*` body is base64; `g` strips every occurrence.
|
|
224
|
+
*/
|
|
225
|
+
const STRUCTURED_META_MARKER = /\n\n<!-- structured-meta:[A-Za-z0-9+/=]*? -->/g;
|
|
226
|
+
/**
|
|
227
|
+
* Strip every embedded structured-meta marker from a text block. What remains
|
|
228
|
+
* is the human/LLM-readable text a marker-aware host (the WootsUp Chat UI)
|
|
229
|
+
* presents after extracting the marker into a Rich Card.
|
|
230
|
+
*/
|
|
231
|
+
export function stripStructuredMeta(text) {
|
|
232
|
+
return text.replace(STRUCTURED_META_MARKER, "");
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Sum the UTF-8 byte length of every text block in a tool result — both the
|
|
236
|
+
* raw bytes (`bytes`) and the marker-stripped, LLM-visible bytes
|
|
237
|
+
* (`visibleBytes`). The raw figure is the token-baseline metric; the visible
|
|
238
|
+
* figure is what a marker-stripping host actually feeds the model.
|
|
239
|
+
*/
|
|
240
|
+
function resultBytes(result) {
|
|
241
|
+
const blocks = Array.isArray(result.content) ? result.content : [];
|
|
242
|
+
let bytes = 0;
|
|
243
|
+
let visibleBytes = 0;
|
|
244
|
+
for (const block of blocks) {
|
|
245
|
+
if (typeof block.text === "string") {
|
|
246
|
+
bytes += Buffer.byteLength(block.text, "utf8");
|
|
247
|
+
visibleBytes += Buffer.byteLength(stripStructuredMeta(block.text), "utf8");
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return { bytes, visibleBytes };
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Replay the canonical sequence and measure total token output.
|
|
254
|
+
*
|
|
255
|
+
* @param tools the registered apimapper tools map (name → tool)
|
|
256
|
+
* @param fetchResponder maps each upstream URL to a canned REST response
|
|
257
|
+
* @returns per-tool byte tally + `totalBytes` across the whole sequence
|
|
258
|
+
*/
|
|
259
|
+
export async function runTokenBaseline(tools, fetchResponder) {
|
|
260
|
+
const originalFetch = globalThis.fetch;
|
|
261
|
+
globalThis.fetch = (async (input, init) => {
|
|
262
|
+
const url = String(input);
|
|
263
|
+
const canned = fetchResponder(url, init);
|
|
264
|
+
const body = typeof canned.body === "string"
|
|
265
|
+
? canned.body
|
|
266
|
+
: JSON.stringify(canned.body);
|
|
267
|
+
return new Response(body, {
|
|
268
|
+
status: canned.status ?? 200,
|
|
269
|
+
headers: { "Content-Type": "application/json" },
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
try {
|
|
273
|
+
const sequence = [];
|
|
274
|
+
for (const step of CANONICAL_SEQUENCE) {
|
|
275
|
+
const tool = tools[step.tool];
|
|
276
|
+
if (!tool) {
|
|
277
|
+
throw new Error(`token-baseline: tool "${step.tool}" is not registered`);
|
|
278
|
+
}
|
|
279
|
+
const result = await tool.handler(step.args);
|
|
280
|
+
const { bytes, visibleBytes } = resultBytes(result);
|
|
281
|
+
sequence.push({ tool: step.tool, bytes, visibleBytes });
|
|
282
|
+
}
|
|
283
|
+
const totalBytes = sequence.reduce((sum, e) => sum + e.bytes, 0);
|
|
284
|
+
const totalVisibleBytes = sequence.reduce((sum, e) => sum + e.visibleBytes, 0);
|
|
285
|
+
return { sequence, totalBytes, totalVisibleBytes };
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
globalThis.fetch = originalFetch;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
//# sourceMappingURL=token-baseline.harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-baseline.harness.js","sourceRoot":"","sources":["../../../src/modules/apimapper/token-baseline.harness.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,EAAE;AACF,wEAAwE;AACxE,6EAA6E;AAC7E,0EAA0E;AAC1E,kEAAkE;AAClE,EAAE;AACF,gBAAgB;AAChB,sEAAsE;AACtE,8EAA8E;AAC9E,uEAAuE;AACvE,wEAAwE;AACxE,4EAA4E;AAC5E,0EAA0E;AAC1E,yEAAyE;AACzE,iEAAiE;AACjE,EAAE;AACF,0EAA0E;AAC1E,yEAAyE;AACzE,wEAAwE;AACxE,qCAAqC;AA0ErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA4B;IACzD,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAE,EAAE,EAAE;IAC1C,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;IACvD;QACE,IAAI,EAAE,4BAA4B;QAClC,IAAI,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;KAC9D;IACD,EAAE,IAAI,EAAE,2BAA2B,EAAE,IAAI,EAAE,EAAE,EAAE;IAC/C,EAAE,IAAI,EAAE,2BAA2B,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;IAC5E;QACE,IAAI,EAAE,uBAAuB;QAC7B,IAAI,EAAE;YACJ,IAAI,EAAE,kBAAkB;YACxB,KAAK,EAAE;gBACL;oBACE,EAAE,EAAE,MAAM;oBACV,IAAI,EAAE,QA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AI,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QACjE,MAAM,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CACvC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,YAAY,EAChC,CAAC,CACF,CAAC;QACF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC;IACrD,CAAC;YAAS,CAAC;QACT,UAAU,CAAC,KAAK,GAAG,aAAa,CAAC;IACnC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { StructuredCallToolResult } from "@getimo/mcp-toolkit";
|
|
2
|
+
import { type ApiErrorCode } from "./client.js";
|
|
3
|
+
/**
|
|
4
|
+
* The minimal slice of a response this helper reads. `ExtApiResponse` (the
|
|
5
|
+
* shared client return type) is a structural superset, and the graph
|
|
6
|
+
* hydration object `{ error, status?, errorCode? }` also satisfies it, so
|
|
7
|
+
* both can flow through `restErrorResult` without a cast.
|
|
8
|
+
*/
|
|
9
|
+
export interface RestErrorLike {
|
|
10
|
+
/** Human-readable error from the upstream response, if any. */
|
|
11
|
+
error?: string;
|
|
12
|
+
/** Coarse error classification used for the recovery hint + code fallback. */
|
|
13
|
+
errorCode?: ApiErrorCode | string;
|
|
14
|
+
/** HTTP status, used as the `code` fallback when `errorCode` is absent. */
|
|
15
|
+
status?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Per-site overrides for the canonical REST-error mapping. */
|
|
18
|
+
export interface RestErrorOpts {
|
|
19
|
+
/**
|
|
20
|
+
* Fallback message when `response.error` is absent. Mirrors the per-tool
|
|
21
|
+
* `r.error ?? "<fallback>"` string each site used inline.
|
|
22
|
+
*/
|
|
23
|
+
message?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Bespoke suggestion that overrides the default `hintFor(response.errorCode)`.
|
|
26
|
+
* Use only where a site intentionally pinned a tool-specific recovery hint.
|
|
27
|
+
*/
|
|
28
|
+
suggestion?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Bespoke `code` fallback that overrides the default `String(status)` when
|
|
31
|
+
* `response.errorCode` is absent. Use only where a site pinned a domain code.
|
|
32
|
+
*/
|
|
33
|
+
code?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Build the canonical structured error result for a failed REST request.
|
|
37
|
+
*
|
|
38
|
+
* Behaviour-preserving replacement for the 67× inline
|
|
39
|
+
* `errorResult({ message: r.error ?? …, code: …, suggestion: hintFor(…), details })`
|
|
40
|
+
* block. See the file header for the exact mapping and the opts contract.
|
|
41
|
+
*
|
|
42
|
+
* @param response the failed response (`!response.success` already checked by the caller)
|
|
43
|
+
* @param details the structured `details` payload (typically the echoed input params)
|
|
44
|
+
* @param opts per-site overrides — see {@link RestErrorOpts}
|
|
45
|
+
*/
|
|
46
|
+
export declare function restErrorResult(response: RestErrorLike, details?: Record<string, unknown>, opts?: RestErrorOpts): StructuredCallToolResult;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// src/modules/apimapper/tool-result.ts — shared REST-error result builder.
|
|
2
|
+
//
|
|
3
|
+
// A1 (Wave-B audit, 2026-06-03): ~67 tool handlers across the apimapper
|
|
4
|
+
// modules hand-wrote the IDENTICAL post-request error block:
|
|
5
|
+
//
|
|
6
|
+
// if (!r.success) {
|
|
7
|
+
// return errorResult({
|
|
8
|
+
// message: r.error ?? "<per-tool fallback>",
|
|
9
|
+
// code: r.errorCode ?? (r.status ? String(r.status) : undefined),
|
|
10
|
+
// suggestion: hintFor(r.errorCode),
|
|
11
|
+
// details: { ...inputParams },
|
|
12
|
+
// });
|
|
13
|
+
// }
|
|
14
|
+
//
|
|
15
|
+
// `restErrorResult(r, details?, opts?)` collapses that block to a single
|
|
16
|
+
// call while preserving the output BYTE-FOR-BYTE. The mapping is:
|
|
17
|
+
//
|
|
18
|
+
// message → r.error ?? opts.message ?? "request failed"
|
|
19
|
+
// code → r.errorCode ?? (r.status ? String(r.status) : undefined)
|
|
20
|
+
// suggestion → opts.suggestion ?? hintFor(r.errorCode)
|
|
21
|
+
// details → details (passed through verbatim; computed by the caller)
|
|
22
|
+
//
|
|
23
|
+
// Per-site nuance is preserved through `opts`:
|
|
24
|
+
// - opts.message : the per-tool fallback string when `r.error` is absent.
|
|
25
|
+
// - opts.suggestion : a bespoke suggestion that overrides hintFor() (used by
|
|
26
|
+
// the few sites that want a tool-specific recovery hint
|
|
27
|
+
// regardless of the error code).
|
|
28
|
+
// - opts.code : a bespoke `code` fallback that overrides the
|
|
29
|
+
// `r.status`-derived default when `r.errorCode` is absent
|
|
30
|
+
// (used by sites that pin a domain code like
|
|
31
|
+
// "credential_lookup_failed").
|
|
32
|
+
//
|
|
33
|
+
// Sites whose error is NOT a `!response.success` REST failure (e.g. a
|
|
34
|
+
// post-success "entity not found" semantic check, or a `bad_request`
|
|
35
|
+
// validation guard with a hardcoded message/code/suggestion) deliberately
|
|
36
|
+
// stay on the raw `errorResult({...})` form — they are documented per-site
|
|
37
|
+
// and must NOT be funnelled through this helper, because their message/code
|
|
38
|
+
// do not derive from the response shape.
|
|
39
|
+
import { errorResult } from "@getimo/mcp-toolkit";
|
|
40
|
+
import { hintFor } from "./client.js";
|
|
41
|
+
/**
|
|
42
|
+
* Build the canonical structured error result for a failed REST request.
|
|
43
|
+
*
|
|
44
|
+
* Behaviour-preserving replacement for the 67× inline
|
|
45
|
+
* `errorResult({ message: r.error ?? …, code: …, suggestion: hintFor(…), details })`
|
|
46
|
+
* block. See the file header for the exact mapping and the opts contract.
|
|
47
|
+
*
|
|
48
|
+
* @param response the failed response (`!response.success` already checked by the caller)
|
|
49
|
+
* @param details the structured `details` payload (typically the echoed input params)
|
|
50
|
+
* @param opts per-site overrides — see {@link RestErrorOpts}
|
|
51
|
+
*/
|
|
52
|
+
export function restErrorResult(response, details, opts = {}) {
|
|
53
|
+
const errorCode = response.errorCode;
|
|
54
|
+
return errorResult({
|
|
55
|
+
message: response.error ?? opts.message ?? "request failed",
|
|
56
|
+
code: errorCode !== undefined && errorCode !== ""
|
|
57
|
+
? String(errorCode)
|
|
58
|
+
: opts.code ?? (response.status ? String(response.status) : undefined),
|
|
59
|
+
suggestion: opts.suggestion ?? hintFor(errorCode),
|
|
60
|
+
...(details !== undefined ? { details } : {}),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=tool-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-result.js","sourceRoot":"","sources":["../../../src/modules/apimapper/tool-result.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,EAAE;AACF,wEAAwE;AACxE,6DAA6D;AAC7D,EAAE;AACF,sBAAsB;AACtB,2BAA2B;AAC3B,mDAAmD;AACnD,wEAAwE;AACxE,0CAA0C;AAC1C,qCAAqC;AACrC,UAAU;AACV,MAAM;AACN,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,EAAE;AACF,6DAA6D;AAC7D,0EAA0E;AAC1E,yDAAyD;AACzD,2EAA2E;AAC3E,EAAE;AACF,+CAA+C;AAC/C,+EAA+E;AAC/E,+EAA+E;AAC/E,8EAA8E;AAC9E,uDAAuD;AACvD,qEAAqE;AACrE,gFAAgF;AAChF,mEAAmE;AACnE,qDAAqD;AACrD,EAAE;AACF,sEAAsE;AACtE,qEAAqE;AACrE,0EAA0E;AAC1E,2EAA2E;AAC3E,4EAA4E;AAC5E,yCAAyC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAqB,MAAM,aAAa,CAAC;AAoCzD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,QAAuB,EACvB,OAAiC,EACjC,OAAsB,EAAE;IAExB,MAAM,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC;IACrC,OAAO,WAAW,CAAC;QACjB,OAAO,EAAE,QAAQ,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,gBAAgB;QAC3D,IAAI,EACF,SAAS,KAAK,SAAS,IAAI,SAAS,KAAK,EAAE;YACzC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC;YACnB,CAAC,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC1E,UAAU,EACR,IAAI,CAAC,UAAU,IAAI,OAAO,CAAC,SAAqC,CAAC;QACnE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type CollectedTool } from "./gateway/test-support.js";
|
|
2
|
+
/**
|
|
3
|
+
* The minimal `tools/list`-relevant slice of a registered tool: the fields the
|
|
4
|
+
* MCP client receives and the LLM reads as part of the static catalog.
|
|
5
|
+
*/
|
|
6
|
+
export interface ToolCatalogEntry {
|
|
7
|
+
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
inputSchema?: unknown;
|
|
10
|
+
annotations?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
/** One side of the measurement: its tool count and total serialized bytes. */
|
|
13
|
+
export interface ToolsListMeasurement {
|
|
14
|
+
/** Number of tools in this `tools/list` surface. */
|
|
15
|
+
toolCount: number;
|
|
16
|
+
/** Sum of `Buffer.byteLength(JSON.stringify(entry))` across all tools. */
|
|
17
|
+
totalBytes: number;
|
|
18
|
+
/** Per-tool byte tally, sorted by name, for the breakdown table. */
|
|
19
|
+
perTool: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
bytes: number;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
/** The full Task-B result: the post-W3 and pre-W3-equivalent surfaces. */
|
|
25
|
+
export interface ToolsListComparison {
|
|
26
|
+
/** Post-W3 `tools/list` — the 19 surface tools the server exposes today. */
|
|
27
|
+
postW3: ToolsListMeasurement;
|
|
28
|
+
/** Pre-W3-equivalent `tools/list` — all 78 tools exposed flat (no gateway). */
|
|
29
|
+
preW3Flat: ToolsListMeasurement;
|
|
30
|
+
/** Absolute byte reduction (preW3Flat.totalBytes − postW3.totalBytes). */
|
|
31
|
+
bytesSaved: number;
|
|
32
|
+
/** Reduction as a fraction of the pre-W3-equivalent total (0..1). */
|
|
33
|
+
fractionSaved: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Projects one tool to its `tools/list` JSON-Schema-bearing catalog entry.
|
|
37
|
+
* The `inputSchema` is JSON-Schema-projected the same way the SDK and the
|
|
38
|
+
* gateway's discovery mode do, so the byte count reflects the real wire shape.
|
|
39
|
+
*/
|
|
40
|
+
export declare function toCatalogEntry(name: string, tool: Pick<CollectedTool, "description" | "inputSchema" | "annotations">): ToolCatalogEntry;
|
|
41
|
+
/**
|
|
42
|
+
* Builds the full 79-tool catalog from the current build and measures the
|
|
43
|
+
* post-W3 vs pre-W3-equivalent `tools/list` payload sizes.
|
|
44
|
+
*
|
|
45
|
+
* Surface composition (verified against `gateway/essentials.ts` + `src/index.ts`,
|
|
46
|
+
* pinned live in `gateway/gateway.test.ts` — A2):
|
|
47
|
+
* - module tools : 15 essentials + `apimapper_advanced` = 16 (on the real
|
|
48
|
+
* McpServer) + 60 advanced (gateway registry) = 76
|
|
49
|
+
* - top-level tools: rest_modules_status + use_profile + list_profiles = 3
|
|
50
|
+
* total = 79
|
|
51
|
+
*
|
|
52
|
+
* POST-W3 `tools/list` = the 16 module-real tools + the 3 top-level tools = 19.
|
|
53
|
+
* PRE-W3 flat `tools/list` = the 18 non-gateway surface tools + the 60 advanced
|
|
54
|
+
* tools = 78 (the `apimapper_advanced` gateway did not exist pre-W3).
|
|
55
|
+
*/
|
|
56
|
+
export declare function measureToolsList(): Promise<ToolsListComparison>;
|