@zackbart/connecta 0.4.0 → 0.4.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.
- package/CHANGELOG.md +83 -0
- package/README.md +34 -14
- package/SECURITY.md +1 -1
- package/dist/connectors/api.d.ts +10 -0
- package/dist/connectors/api.d.ts.map +1 -1
- package/dist/connectors/api.js +11 -1
- package/dist/connectors/api.js.map +1 -1
- package/dist/connectors/remote-mcp.d.ts +14 -1
- package/dist/connectors/remote-mcp.d.ts.map +1 -1
- package/dist/connectors/remote-mcp.js +29 -0
- package/dist/connectors/remote-mcp.js.map +1 -1
- package/dist/credentials.d.ts +2 -1
- package/dist/credentials.d.ts.map +1 -1
- package/dist/credentials.js +4 -2
- package/dist/credentials.js.map +1 -1
- package/dist/executors/quickjs.d.ts.map +1 -1
- package/dist/executors/quickjs.js +32 -4
- package/dist/executors/quickjs.js.map +1 -1
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -1
- package/dist/index.js.map +1 -1
- package/dist/meta-tools.d.ts +3 -0
- package/dist/meta-tools.d.ts.map +1 -1
- package/dist/meta-tools.js +47 -6
- package/dist/meta-tools.js.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +29 -5
- package/dist/server.js.map +1 -1
- package/dist/storage/file.d.ts.map +1 -1
- package/dist/storage/file.js +19 -3
- package/dist/storage/file.js.map +1 -1
- package/dist/ui.d.ts +1 -1
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +13 -9
- package/dist/ui.js.map +1 -1
- package/dist/validate.d.ts +33 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +32 -2
- package/dist/validate.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/connectors/api.ts +21 -1
- package/src/connectors/remote-mcp.ts +52 -0
- package/src/credentials.ts +6 -3
- package/src/executors/quickjs.ts +32 -4
- package/src/index.ts +72 -1
- package/src/meta-tools.ts +90 -16
- package/src/server.ts +32 -5
- package/src/storage/file.ts +18 -2
- package/src/ui.ts +13 -8
- package/src/validate.ts +60 -2
- package/src/version.ts +1 -1
package/dist/storage/file.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file.js","sourceRoot":"","sources":["../../src/storage/file.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,IAAY,EACZ,OAA2B,EAAE;IAE7B,MAAM,MAAM,GAAW,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC;IAC9C,IAAI,IAAI,GAA0B,EAAE,CAAC;IACrC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,IAAI,CAAC;YACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAA0B,CAAC;QACzE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,uEAAuE;YACvE,sEAAsE;YACtE,oEAAoE;YACpE,wEAAwE;YACxE,kDAAkD;YAClD,MAAM,UAAU,GAAG,GAAG,IAAI,YAAY,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACnD,IAAI,CAAC;gBACH,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;YAC/B,CAAC;YAAC,OAAO,WAAW,EAAE,CAAC;gBACrB,MAAM,IAAI,KAAK,CACb,yBAAyB,IAAI,sCAAsC;oBACjE,gBAAgB,MAAM,CAAC,WAAW,CAAC,8BAA8B;oBACjE,2DAA2D,CAC9D,CAAC;YACJ,CAAC;YACD,MAAM,CAAC,KAAK,CACV,yBAAyB,IAAI,qBAAqB;g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AC,GAAW,EAAgB,EAAE;QAC1C,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,CAAC;YAAE,OAAO,IAAI,CAAC;QACpB,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC,CAAC;IACF,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,GAAG;YACX,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,IAAI,IAAI,CAAC;QACnC,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI;YACxB,IAAI,CAAC,GAAG,CAAC,GAAG;gBACV,KAAK;gBACL,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC,CAAC,SAAS;aACxE,CAAC;YACF,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,KAAK,CAAC,MAAM,CAAC,GAAG;YACd,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,OAAO,EAAE,CAAC;QACZ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/ui.d.ts
CHANGED
|
@@ -92,6 +92,6 @@ export declare function buildUiData(registry: Registry, baseUrl: string, serverI
|
|
|
92
92
|
* normal sign-in flow and a short-lived session token; bearer-only deployments
|
|
93
93
|
* retain the manual-token fallback.
|
|
94
94
|
*/
|
|
95
|
-
export declare function renderUiHtml(uiAuth?: UiAuthConfig, mcpUrl?: string, branding?: ConnectaBranding): string;
|
|
95
|
+
export declare function renderUiHtml(uiAuth?: UiAuthConfig, mcpUrl?: string, branding?: ConnectaBranding, nonce?: string): string;
|
|
96
96
|
export {};
|
|
97
97
|
//# sourceMappingURL=ui.d.ts.map
|
package/dist/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjE,8CAA8C;AAC9C,eAAO,MAAM,oBAAoB,gRAM1B,CAAC;AAER,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,eAAe,CAC7B,QAAQ,CAAC,EAAE,gBAAgB,GAC1B,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEjE,8CAA8C;AAC9C,eAAO,MAAM,oBAAoB,gRAM1B,CAAC;AAER,UAAU,gBAAgB;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;I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
10
10
|
const productName = branding?.productName?.trim() || "Connecta";
|
|
11
11
|
const ownerName = branding?.ownerName?.trim();
|
|
12
|
+
// Operator branding URLs become masthead/callback hrefs, so a non-http(s)
|
|
13
|
+
// scheme (javascript:, data:) is dropped the same as an unset URL — the
|
|
14
|
+
// callers already render a <span> instead of an <a> when it is absent.
|
|
15
|
+
const productUrl = branding?.productUrl?.trim();
|
|
16
|
+
const ownerUrl = branding?.ownerUrl?.trim();
|
|
12
17
|
return {
|
|
13
18
|
productName,
|
|
14
|
-
...(
|
|
15
|
-
? { productUrl: branding.productUrl.trim() }
|
|
16
|
-
: {}),
|
|
19
|
+
...(productUrl && isSafeHttpUrl(productUrl) ? { productUrl } : {}),
|
|
17
20
|
...(ownerName ? { ownerName } : {}),
|
|
18
|
-
...(
|
|
19
|
-
? { ownerUrl: branding.ownerUrl.trim() }
|
|
20
|
-
: {}),
|
|
21
|
+
...(ownerUrl && isSafeHttpUrl(ownerUrl) ? { ownerUrl } : {}),
|
|
21
22
|
description: branding?.description?.trim() ||
|
|
22
23
|
`Manage the services this ${productName} instance makes available to agents.`,
|
|
23
24
|
pageTitle: branding?.pageTitle?.trim() ||
|
|
@@ -205,10 +206,13 @@ function jsonForInlineScript(value) {
|
|
|
205
206
|
* normal sign-in flow and a short-lived session token; bearer-only deployments
|
|
206
207
|
* retain the manual-token fallback.
|
|
207
208
|
*/
|
|
208
|
-
export function renderUiHtml(uiAuth, mcpUrl = "/mcp", branding) {
|
|
209
|
+
export function renderUiHtml(uiAuth, mcpUrl = "/mcp", branding, nonce) {
|
|
209
210
|
const auth = uiAuth ?? { kind: "bearer" };
|
|
210
211
|
const brand = resolveBranding(branding);
|
|
211
212
|
const title = brand.pageTitle;
|
|
213
|
+
// When the /ui response ships a nonce-based CSP, every <script> it emits must
|
|
214
|
+
// carry that nonce to run; without a nonce the markup is unchanged.
|
|
215
|
+
const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
|
|
212
216
|
// Top-left corner. With an owner set it reads "<owner> <product>"; without
|
|
213
217
|
// one the product label stands alone. Either half links out when the
|
|
214
218
|
// matching URL is configured.
|
|
@@ -225,7 +229,7 @@ export function renderUiHtml(uiAuth, mcpUrl = "/mcp", branding) {
|
|
|
225
229
|
: `<span class="product">${escapeHtmlAttr(brand.productName)}</span>`
|
|
226
230
|
: "";
|
|
227
231
|
const clerkScript = uiAuth?.kind === "clerk"
|
|
228
|
-
? `<script defer crossorigin="anonymous" data-clerk-publishable-key="${escapeHtmlAttr(uiAuth.publishableKey)}" src="${escapeHtmlAttr(uiAuth.frontendApiUrl)}/npm/@clerk/clerk-js@6/dist/clerk.browser.js"></script>`
|
|
232
|
+
? `<script${nonceAttr} defer crossorigin="anonymous" data-clerk-publishable-key="${escapeHtmlAttr(uiAuth.publishableKey)}" src="${escapeHtmlAttr(uiAuth.frontendApiUrl)}/npm/@clerk/clerk-js@6/dist/clerk.browser.js"></script>`
|
|
229
233
|
: "";
|
|
230
234
|
return `<!doctype html>
|
|
231
235
|
<html lang="en">
|
|
@@ -584,7 +588,7 @@ ${clerkScript}
|
|
|
584
588
|
</section>
|
|
585
589
|
</main>
|
|
586
590
|
|
|
587
|
-
<script>
|
|
591
|
+
<script${nonceAttr}>
|
|
588
592
|
const AUTH = ${jsonForInlineScript(auth)};
|
|
589
593
|
const MCP_URL = ${jsonForInlineScript(mcpUrl)};
|
|
590
594
|
const filterUiConnectors = ${filterUiConnectors.toString()};
|
package/dist/ui.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAIA,8CAA8C;AAC9C,MAAM,CAAC,MAAM,oBAAoB,GAAG;;;;;;OAM7B,CAAC;AAeR,MAAM,UAAU,eAAe,CAC7B,QAA2B;IAE3B,MAAM,WAAW,GAAG,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,UAAU,CAAC;IAChE,MAAM,SAAS,GAAG,QAAQ,EAAE,SAA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;;;;;yCA4BH,cAAc,CAAC,KAAK,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAkCjE,SAAS;eACH,mBAAmB,CAAC,IAAI,CAAC;kBACtB,mBAAmB,CAAC,MAAM,CAAC;6BAChB,kBAAkB,CAAC,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8CAwFZ,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoX3E,CAAC;AACT,CAAC"}
|
package/dist/validate.d.ts
CHANGED
|
@@ -11,6 +11,27 @@ export interface ValidateToolInputOptions {
|
|
|
11
11
|
* unusable. Default console.
|
|
12
12
|
*/
|
|
13
13
|
logger?: Logger;
|
|
14
|
+
/**
|
|
15
|
+
* Fail-closed on a schema the validator cannot evaluate (default false =
|
|
16
|
+
* today's fail-open behavior). When true, a schema that cannot be compiled —
|
|
17
|
+
* or that only fails on first use, e.g. an unresolvable `$ref` — yields a
|
|
18
|
+
* non-retryable `invalid_args` error instead of passing the raw arguments
|
|
19
|
+
* through, so unvalidated input is never silently admitted. The happy path
|
|
20
|
+
* (a schema that compiles and validates) is unaffected.
|
|
21
|
+
*/
|
|
22
|
+
failClosed?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface PrecompileValidatorOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Tool address used in the warning text, conventionally
|
|
27
|
+
* `"connectorId.toolName"`.
|
|
28
|
+
*/
|
|
29
|
+
address: string;
|
|
30
|
+
/**
|
|
31
|
+
* Destination for the warning emitted when the schema cannot be compiled.
|
|
32
|
+
* Default console.
|
|
33
|
+
*/
|
|
34
|
+
logger?: Logger;
|
|
14
35
|
}
|
|
15
36
|
/**
|
|
16
37
|
* Validate call arguments against a tool's JSON Schema.
|
|
@@ -24,7 +45,9 @@ export interface ValidateToolInputOptions {
|
|
|
24
45
|
*
|
|
25
46
|
* A schema the validator cannot compile (or that only fails on first use, e.g.
|
|
26
47
|
* an unresolvable `$ref`) is warned about once and then passed through — a
|
|
27
|
-
* broken schema should not break an otherwise working tool.
|
|
48
|
+
* broken schema should not break an otherwise working tool. Pass
|
|
49
|
+
* `failClosed: true` to instead reject such calls with `invalid_args`, for
|
|
50
|
+
* callers that would rather refuse a call than forward unvalidated arguments.
|
|
28
51
|
*
|
|
29
52
|
* The compiled validator is cached by **schema object identity**, so pass a
|
|
30
53
|
* stable object: hold the parsed manifest and hand the same schema back on
|
|
@@ -36,4 +59,13 @@ export interface ValidateToolInputOptions {
|
|
|
36
59
|
* the `Connector` interface directly.
|
|
37
60
|
*/
|
|
38
61
|
export declare function validateToolInput(schema: JsonSchema, args: unknown, opts: ValidateToolInputOptions): ConnectorCallError | null;
|
|
62
|
+
/**
|
|
63
|
+
* Eagerly compile and cache a tool's inputSchema so a schema the validator
|
|
64
|
+
* cannot use surfaces once at connector construction rather than silently on
|
|
65
|
+
* the first call. Reuses the same module-level cache `validateToolInput` reads,
|
|
66
|
+
* so the runtime path hits the cache. Warning-only: it never throws and never
|
|
67
|
+
* changes call behavior. A schema that only fails on first `validate()` (e.g.
|
|
68
|
+
* an unresolvable `$ref`) still slips through here and is caught at call time.
|
|
69
|
+
*/
|
|
70
|
+
export declare function precompileValidator(schema: JsonSchema, opts: PrecompileValidatorOptions): void;
|
|
39
71
|
//# sourceMappingURL=validate.d.ts.map
|
package/dist/validate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAErD,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,0BAA0B;IACzC;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AA6BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,wBAAwB,GAC7B,kBAAkB,GAAG,IAAI,CAqC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,0BAA0B,GAC/B,IAAI,CAQN"}
|
package/dist/validate.js
CHANGED
|
@@ -5,6 +5,9 @@ import { ConnectorCallError } from "./errors.js";
|
|
|
5
5
|
// breaking a working tool). A WeakMap so schemas belonging to a discarded
|
|
6
6
|
// connector are collectable, the same pattern compactSchema uses.
|
|
7
7
|
const validators = new WeakMap();
|
|
8
|
+
function unevaluableSchema(address) {
|
|
9
|
+
return new ConnectorCallError("invalid_args", `Cannot validate arguments for "${address}": its inputSchema could not be evaluated`);
|
|
10
|
+
}
|
|
8
11
|
function disableValidation(schema, address, logger, err) {
|
|
9
12
|
validators.set(schema, null);
|
|
10
13
|
logger.warn(`[connecta] tool "${address}" has an inputSchema the validator cannot use (${err instanceof Error ? err.message : String(err)}) — arguments are not validated`);
|
|
@@ -21,7 +24,9 @@ function disableValidation(schema, address, logger, err) {
|
|
|
21
24
|
*
|
|
22
25
|
* A schema the validator cannot compile (or that only fails on first use, e.g.
|
|
23
26
|
* an unresolvable `$ref`) is warned about once and then passed through — a
|
|
24
|
-
* broken schema should not break an otherwise working tool.
|
|
27
|
+
* broken schema should not break an otherwise working tool. Pass
|
|
28
|
+
* `failClosed: true` to instead reject such calls with `invalid_args`, for
|
|
29
|
+
* callers that would rather refuse a call than forward unvalidated arguments.
|
|
25
30
|
*
|
|
26
31
|
* The compiled validator is cached by **schema object identity**, so pass a
|
|
27
32
|
* stable object: hold the parsed manifest and hand the same schema back on
|
|
@@ -45,13 +50,19 @@ export function validateToolInput(schema, args, opts) {
|
|
|
45
50
|
validator = null;
|
|
46
51
|
}
|
|
47
52
|
}
|
|
53
|
+
// A schema the validator could not compile (or that a prior call disabled):
|
|
54
|
+
// pass through by default, refuse when the caller opted into fail-closed.
|
|
55
|
+
if (validator === null) {
|
|
56
|
+
return opts.failClosed ? unevaluableSchema(opts.address) : null;
|
|
57
|
+
}
|
|
48
58
|
let result;
|
|
49
59
|
try {
|
|
50
|
-
result = validator
|
|
60
|
+
result = validator.validate(args);
|
|
51
61
|
}
|
|
52
62
|
catch (err) {
|
|
53
63
|
// e.g. an unresolvable $ref — surfaces on first validate, not compile.
|
|
54
64
|
disableValidation(schema, opts.address, logger, err);
|
|
65
|
+
return opts.failClosed ? unevaluableSchema(opts.address) : null;
|
|
55
66
|
}
|
|
56
67
|
if (result && !result.valid) {
|
|
57
68
|
const units = result.errors.filter((u) => u.instanceLocation !== "#");
|
|
@@ -63,4 +74,23 @@ export function validateToolInput(schema, args, opts) {
|
|
|
63
74
|
}
|
|
64
75
|
return null;
|
|
65
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Eagerly compile and cache a tool's inputSchema so a schema the validator
|
|
79
|
+
* cannot use surfaces once at connector construction rather than silently on
|
|
80
|
+
* the first call. Reuses the same module-level cache `validateToolInput` reads,
|
|
81
|
+
* so the runtime path hits the cache. Warning-only: it never throws and never
|
|
82
|
+
* changes call behavior. A schema that only fails on first `validate()` (e.g.
|
|
83
|
+
* an unresolvable `$ref`) still slips through here and is caught at call time.
|
|
84
|
+
*/
|
|
85
|
+
export function precompileValidator(schema, opts) {
|
|
86
|
+
if (validators.has(schema))
|
|
87
|
+
return;
|
|
88
|
+
const logger = opts.logger ?? console;
|
|
89
|
+
try {
|
|
90
|
+
validators.set(schema, new Validator(schema, "2020-12", false));
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
disableValidation(schema, opts.address, logger, err);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
66
96
|
//# sourceMappingURL=validate.js.map
|
package/dist/validate.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,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AAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAkB,EAClB,IAAgC;IAEhC,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC;QAAE,OAAO;IACnC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC;IACtC,IAAI,CAAC;QACH,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,SAAS,CAAC,MAAe,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3E,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,iBAAiB,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
* a bump that forgets this file fails the build rather than shipping a stale
|
|
5
5
|
* version to `/health` and to downstream MCP handshakes.
|
|
6
6
|
*/
|
|
7
|
-
export declare const CONNECTA_VERSION = "0.4.
|
|
7
|
+
export declare const CONNECTA_VERSION = "0.4.1";
|
|
8
8
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
package/src/connectors/api.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validateToolInput } from "../validate.js";
|
|
1
|
+
import { precompileValidator, validateToolInput } from "../validate.js";
|
|
2
2
|
import type {
|
|
3
3
|
Connector,
|
|
4
4
|
ConnectorCredentialConfig,
|
|
@@ -49,6 +49,16 @@ export interface ApiOptions {
|
|
|
49
49
|
* on loose coercion.
|
|
50
50
|
*/
|
|
51
51
|
validateArgs?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Fail-closed on a tool whose `inputSchema` the validator cannot evaluate
|
|
54
|
+
* (default false). The default surfaces such a schema as a one-time warning
|
|
55
|
+
* and then passes the raw arguments through, so a broken schema never breaks
|
|
56
|
+
* an otherwise working tool. Set true to instead reject those calls with a
|
|
57
|
+
* non-retryable `invalid_args` ConnectorCallError, so a schema that cannot be
|
|
58
|
+
* enforced never silently admits unvalidated input. Only consulted when
|
|
59
|
+
* `validateArgs` is not false.
|
|
60
|
+
*/
|
|
61
|
+
strictValidation?: boolean;
|
|
52
62
|
tools: ApiTool[];
|
|
53
63
|
}
|
|
54
64
|
|
|
@@ -73,6 +83,15 @@ export function api(id: string, opts: ApiOptions): Connector {
|
|
|
73
83
|
}));
|
|
74
84
|
const byName = new Map(opts.tools.map((t) => [t.name, t]));
|
|
75
85
|
const validateArgs = opts.validateArgs ?? true;
|
|
86
|
+
const strictValidation = opts.strictValidation ?? false;
|
|
87
|
+
if (validateArgs) {
|
|
88
|
+
// Compile each schema now so a validator-hostile inputSchema surfaces once
|
|
89
|
+
// here rather than silently on its first call. Warning-only; never throws.
|
|
90
|
+
for (const t of opts.tools) {
|
|
91
|
+
if (t.inputSchema)
|
|
92
|
+
precompileValidator(t.inputSchema, { address: `${id}.${t.name}` });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
76
95
|
return {
|
|
77
96
|
id,
|
|
78
97
|
title: opts.title,
|
|
@@ -95,6 +114,7 @@ export function api(id: string, opts: ApiOptions): Connector {
|
|
|
95
114
|
const invalid = validateToolInput(tool.inputSchema, input, {
|
|
96
115
|
address: `${id}.${name}`,
|
|
97
116
|
logger: ctx.logger,
|
|
117
|
+
failClosed: strictValidation,
|
|
98
118
|
});
|
|
99
119
|
if (invalid) throw invalid;
|
|
100
120
|
}
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
Connector,
|
|
11
11
|
ConnectorContext,
|
|
12
12
|
ConnectorStatus,
|
|
13
|
+
Logger,
|
|
13
14
|
ToolDef,
|
|
14
15
|
} from "../types.js";
|
|
15
16
|
|
|
@@ -23,6 +24,19 @@ export interface RemoteMcpOptions {
|
|
|
23
24
|
title?: string;
|
|
24
25
|
description?: string;
|
|
25
26
|
auth?: RemoteMcpAuth;
|
|
27
|
+
/**
|
|
28
|
+
* Refuse to connect to a non-`https://` `url` at construction (default
|
|
29
|
+
* false). Loopback hosts (`localhost`, `127.0.0.1`, `[::1]`) are always
|
|
30
|
+
* allowed for local development. Off by default, static `headers` credentials
|
|
31
|
+
* over a cleartext connection are warned about but permitted; set this true
|
|
32
|
+
* to make that misconfiguration a hard error instead.
|
|
33
|
+
*/
|
|
34
|
+
requireHttps?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Destination for the cleartext-credential warning emitted at construction.
|
|
37
|
+
* Default console.
|
|
38
|
+
*/
|
|
39
|
+
logger?: Logger;
|
|
26
40
|
/**
|
|
27
41
|
* @internal Testing seam. When set, this transport is used instead of the
|
|
28
42
|
* HTTP transport, letting tests point the connector at an in-process MCP
|
|
@@ -35,6 +49,15 @@ function msg(err: unknown): string {
|
|
|
35
49
|
return err instanceof Error ? err.message : String(err);
|
|
36
50
|
}
|
|
37
51
|
|
|
52
|
+
function isLoopbackHost(hostname: string): boolean {
|
|
53
|
+
return (
|
|
54
|
+
hostname === "localhost" ||
|
|
55
|
+
hostname === "127.0.0.1" ||
|
|
56
|
+
hostname === "[::1]" ||
|
|
57
|
+
hostname === "::1"
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
38
61
|
interface ConnectionState {
|
|
39
62
|
client: Client | null;
|
|
40
63
|
transport: Transport | null;
|
|
@@ -60,6 +83,27 @@ export function remoteMcp(id: string, opts: RemoteMcpOptions): Connector {
|
|
|
60
83
|
// from the isolate singleton. Those are request-bound in Cloudflare Workers.
|
|
61
84
|
const states = new WeakMap<object, ConnectionState>();
|
|
62
85
|
const isOauth = opts.auth?.type === "oauth";
|
|
86
|
+
const logger = opts.logger ?? console;
|
|
87
|
+
|
|
88
|
+
// Check the destination scheme once at construction: buildTransport (and the
|
|
89
|
+
// SDK's fetch) attach any static credentials to every request, so an http://
|
|
90
|
+
// endpoint sends bearer tokens / API keys in cleartext. Loopback is exempt
|
|
91
|
+
// for local development.
|
|
92
|
+
const destination = new URL(opts.url);
|
|
93
|
+
const insecureDestination =
|
|
94
|
+
destination.protocol !== "https:" && !isLoopbackHost(destination.hostname);
|
|
95
|
+
if (insecureDestination) {
|
|
96
|
+
if (opts.requireHttps) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`[connecta] connector "${id}" url ${opts.url} is not https:// (and not loopback) — refusing to connect (requireHttps).`,
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
if (opts.auth?.type === "headers") {
|
|
102
|
+
logger.warn(
|
|
103
|
+
`[connecta] connector "${id}" sends static credentials to ${opts.url} over a non-https:// connection — those tokens will be transmitted in cleartext.`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
63
107
|
|
|
64
108
|
/** Typed per-call auth signal; the SDK's UnauthorizedError stays as cause. */
|
|
65
109
|
const authRequiredError = (cause: unknown) =>
|
|
@@ -98,6 +142,14 @@ export function remoteMcp(id: string, opts: RemoteMcpOptions): Connector {
|
|
|
98
142
|
return state.provider;
|
|
99
143
|
};
|
|
100
144
|
|
|
145
|
+
// NOTE: StreamableHTTPClientTransport speaks over fetch, which transparently
|
|
146
|
+
// follows 3xx redirects. A malicious or compromised downstream MCP could
|
|
147
|
+
// redirect to an internal address (e.g. http://169.254.169.254/…) and fetch
|
|
148
|
+
// would re-issue the request — potentially carrying static auth headers. The
|
|
149
|
+
// scheme check above only guards the first hop; a fully robust guard (manual
|
|
150
|
+
// redirect handling + per-hop re-validation + stripping auth headers cross-
|
|
151
|
+
// origin) lives in the SDK transport and is deferred to a future non-patch
|
|
152
|
+
// release rather than reimplemented here.
|
|
101
153
|
const buildTransport = (
|
|
102
154
|
ctx: ConnectorContext,
|
|
103
155
|
state: ConnectionState,
|
package/src/credentials.ts
CHANGED
|
@@ -21,7 +21,8 @@ interface CredentialPlaintext {
|
|
|
21
21
|
|
|
22
22
|
export interface CredentialFieldMetadata {
|
|
23
23
|
configured: true;
|
|
24
|
-
|
|
24
|
+
/** Only emitted when the value is long enough that four chars don't leak much. */
|
|
25
|
+
lastFour?: string;
|
|
25
26
|
updatedAt: string;
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -200,7 +201,9 @@ export class CredentialVault {
|
|
|
200
201
|
field,
|
|
201
202
|
{
|
|
202
203
|
configured: true as const,
|
|
203
|
-
|
|
204
|
+
// Only reveal the tail on values comfortably longer than four chars;
|
|
205
|
+
// for a short secret those four would be half of it.
|
|
206
|
+
...(value.length >= 12 ? { lastFour: value.slice(-4) } : {}),
|
|
204
207
|
updatedAt: credential.updatedAt,
|
|
205
208
|
},
|
|
206
209
|
]),
|
|
@@ -208,7 +211,7 @@ export class CredentialVault {
|
|
|
208
211
|
const single = fields.value;
|
|
209
212
|
return {
|
|
210
213
|
configured: true,
|
|
211
|
-
...(single ? { lastFour: single.lastFour } : {}),
|
|
214
|
+
...(single?.lastFour ? { lastFour: single.lastFour } : {}),
|
|
212
215
|
updatedAt: credential.updatedAt,
|
|
213
216
|
fields,
|
|
214
217
|
};
|
package/src/executors/quickjs.ts
CHANGED
|
@@ -32,6 +32,14 @@ export interface QuickJsExecutorOptions {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const MAX_LOG_ENTRIES = 200;
|
|
35
|
+
// Cap each entry AND the cumulative buffer at capture time so untrusted guest
|
|
36
|
+
// code can't retain unbounded host memory: a single `console.log("x".repeat(N))`
|
|
37
|
+
// otherwise copies the whole N-char guest string into a host array we hold for
|
|
38
|
+
// the entire execution. 8k chars/entry is generous for glue-code logging (the
|
|
39
|
+
// join in execute.ts trims the assembled log to 4k anyway), and 256k total
|
|
40
|
+
// keeps the worst case — 200 maxed-out entries — bounded well under a MiB.
|
|
41
|
+
const MAX_LOG_ENTRY_CHARS = 8_000;
|
|
42
|
+
const MAX_LOG_TOTAL_CHARS = 256_000;
|
|
35
43
|
|
|
36
44
|
function msg(err: unknown): string {
|
|
37
45
|
return err instanceof Error ? err.message : String(err);
|
|
@@ -123,12 +131,32 @@ function installBridge(
|
|
|
123
131
|
};
|
|
124
132
|
armWake(bridge);
|
|
125
133
|
|
|
134
|
+
// Running total of chars actually retained in `logs`; once the cumulative
|
|
135
|
+
// budget is spent we push one marker and drop the rest, so a flood of large
|
|
136
|
+
// entries can't grow the host array without bound.
|
|
137
|
+
let logTotalChars = 0;
|
|
138
|
+
let logBudgetSpent = false;
|
|
126
139
|
const logFn = ctx.newFunction("__log", (h) => {
|
|
127
|
-
if (logs.length
|
|
128
|
-
logs.
|
|
129
|
-
|
|
130
|
-
|
|
140
|
+
if (logs.length >= MAX_LOG_ENTRIES) {
|
|
141
|
+
if (logs.length === MAX_LOG_ENTRIES) {
|
|
142
|
+
logs.push(`[log truncated after ${MAX_LOG_ENTRIES} entries]`);
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (logBudgetSpent) return;
|
|
147
|
+
// Cap the entry before retaining it: `getString` yields a transient copy,
|
|
148
|
+
// but slicing here keeps only a bounded string alive in `logs`.
|
|
149
|
+
let entry = ctx.getString(h);
|
|
150
|
+
if (entry.length > MAX_LOG_ENTRY_CHARS) {
|
|
151
|
+
entry = `${entry.slice(0, MAX_LOG_ENTRY_CHARS)}…[entry truncated]`;
|
|
152
|
+
}
|
|
153
|
+
if (logTotalChars + entry.length > MAX_LOG_TOTAL_CHARS) {
|
|
154
|
+
logs.push("[log truncated: size budget exceeded]");
|
|
155
|
+
logBudgetSpent = true;
|
|
156
|
+
return;
|
|
131
157
|
}
|
|
158
|
+
logs.push(entry);
|
|
159
|
+
logTotalChars += entry.length;
|
|
132
160
|
});
|
|
133
161
|
ctx.setProp(ctx.global, "__log", logFn);
|
|
134
162
|
logFn.dispose();
|
package/src/index.ts
CHANGED
|
@@ -77,6 +77,22 @@ export interface ConnectaConfig {
|
|
|
77
77
|
* not explicitly ask to retry.
|
|
78
78
|
*/
|
|
79
79
|
defaultToolTimeoutMs?: number;
|
|
80
|
+
/**
|
|
81
|
+
* Deadline (ms) applied to each individual downstream probe/catalog call that
|
|
82
|
+
* the discovery meta-tools fan out — `list_connectors` (with `probe`),
|
|
83
|
+
* `search_tools`, and `describe_tools` — so a single hung connector can no
|
|
84
|
+
* longer stall the whole meta-tool call. **Defaults to a generous 30_000**,
|
|
85
|
+
* chosen to trip only on a pathological hang, not on a realistically slow
|
|
86
|
+
* probe, so having it on by default will not break existing deployments.
|
|
87
|
+
* Bounds one downstream call, not the whole fan-out: a connector that outruns
|
|
88
|
+
* it degrades to an unavailable/errored entry while the rest are unaffected.
|
|
89
|
+
*
|
|
90
|
+
* Does NOT apply to `call_tool`/`batch_call` — those carry their own budget
|
|
91
|
+
* via `defaultToolTimeoutMs` or a per-call `timeoutMs`. Note this bounds the
|
|
92
|
+
* caller-facing wait only; the underlying fetch is not currently aborted, so
|
|
93
|
+
* real cancellation of the downstream request is a deferred follow-up.
|
|
94
|
+
*/
|
|
95
|
+
probeTimeoutMs?: number;
|
|
80
96
|
serverInfo?: {
|
|
81
97
|
name?: string;
|
|
82
98
|
version?: string;
|
|
@@ -122,6 +138,58 @@ function normalizeAuth(auth: ConnectaConfig["auth"]): InboundAuth[] {
|
|
|
122
138
|
});
|
|
123
139
|
}
|
|
124
140
|
|
|
141
|
+
/**
|
|
142
|
+
* One-time construction warnings for deployment shapes that run fine but are
|
|
143
|
+
* usually unintended. Warning-only — never throws and never changes behavior;
|
|
144
|
+
* each condition emits at most one `logger.warn`. Iterates connectors once.
|
|
145
|
+
*/
|
|
146
|
+
function warnInsecureConfig(
|
|
147
|
+
config: ConnectaConfig,
|
|
148
|
+
inboundAuth: InboundAuth[],
|
|
149
|
+
logger: Logger,
|
|
150
|
+
): void {
|
|
151
|
+
const oauthConnectors = config.connectors.filter((c) => c.finishAuth);
|
|
152
|
+
const hasCredentialConnector = config.connectors.some((c) => c.credential);
|
|
153
|
+
|
|
154
|
+
// Open mode (no inbound auth) with connectors that expose credentials or
|
|
155
|
+
// downstream OAuth: any caller reaches everything, including the vault.
|
|
156
|
+
if (
|
|
157
|
+
inboundAuth.length === 0 &&
|
|
158
|
+
(hasCredentialConnector || oauthConnectors.length > 0)
|
|
159
|
+
) {
|
|
160
|
+
logger.warn(
|
|
161
|
+
"[connecta] running with no inbound authentication: any caller can " +
|
|
162
|
+
"invoke every connector and read or overwrite stored credentials. " +
|
|
163
|
+
"Configure `auth` (for example bearerToken(...) or Clerk) to gate access.",
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Unset publicUrl with OAuth connectors: the downstream redirect_uri is
|
|
168
|
+
// derived per-request from the attacker-influenced inbound Host header.
|
|
169
|
+
if (oauthConnectors.length > 0 && !config.publicUrl) {
|
|
170
|
+
logger.warn(
|
|
171
|
+
"[connecta] publicUrl is unset while OAuth connectors are configured: " +
|
|
172
|
+
"the downstream OAuth redirect_uri is derived per-request from the " +
|
|
173
|
+
"inbound Host header, so an attacker who controls that header can point " +
|
|
174
|
+
"it at their own host and capture the authorization code. Set " +
|
|
175
|
+
"`publicUrl` to a fixed https origin.",
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// OAuth connectors whose callback performs no state/CSRF check: the public
|
|
180
|
+
// /oauth/callback/<id> route would exchange any delivered code.
|
|
181
|
+
for (const connector of oauthConnectors) {
|
|
182
|
+
if (!connector.verifyState) {
|
|
183
|
+
logger.warn(
|
|
184
|
+
`[connecta] connector "${connector.id}" has an OAuth callback with no ` +
|
|
185
|
+
`state/CSRF check: /oauth/callback/${connector.id} will exchange any ` +
|
|
186
|
+
"delivered code. Implement `verifyState` (the shipped remoteMcp " +
|
|
187
|
+
"connector already does).",
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
125
193
|
export function createConnecta(config: ConnectaConfig): Connecta {
|
|
126
194
|
const storage = config.storage ?? memoryStorage();
|
|
127
195
|
const logger = config.logger ?? defaultLogger();
|
|
@@ -143,9 +211,11 @@ export function createConnecta(config: ConnectaConfig): Connecta {
|
|
|
143
211
|
toolCatalogStaleSeconds: config.toolCatalogStaleSeconds,
|
|
144
212
|
maxResultBytes: config.maxResultBytes,
|
|
145
213
|
});
|
|
214
|
+
const inboundAuth = normalizeAuth(config.auth);
|
|
215
|
+
warnInsecureConfig(config, inboundAuth, logger);
|
|
146
216
|
const handler = createFetchHandler({
|
|
147
217
|
registry,
|
|
148
|
-
auth:
|
|
218
|
+
auth: inboundAuth,
|
|
149
219
|
publicUrl: config.publicUrl,
|
|
150
220
|
serverInfo: {
|
|
151
221
|
...config.serverInfo,
|
|
@@ -158,6 +228,7 @@ export function createConnecta(config: ConnectaConfig): Connecta {
|
|
|
158
228
|
activityDeploymentId: config.activityDeploymentId,
|
|
159
229
|
executor: config.executor,
|
|
160
230
|
defaultToolTimeoutMs: config.defaultToolTimeoutMs,
|
|
231
|
+
probeTimeoutMs: config.probeTimeoutMs,
|
|
161
232
|
credentialVault,
|
|
162
233
|
deploymentInfo: config.deploymentInfo,
|
|
163
234
|
branding: config.branding,
|