stitchkit 0.90.3 → 0.90.5
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 +142 -0
- package/dist/agent-runtime-coding-tools.js +4 -4
- package/dist/agent-runtime-harness.js +6 -6
- package/dist/agent-runtime-sandbox.js +4 -4
- package/dist/agent-runtime.js +9 -9
- package/dist/cli.d.ts +14 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +402 -11
- package/dist/{index-2hrfpw2c.js → index-1bnkzq95.js} +2 -2
- package/dist/{index-j7q0xj6d.js → index-3yqgj323.js} +3 -3
- package/dist/{index-gbqjt8jz.js → index-83fafqw8.js} +3 -3
- package/dist/{index-44ht2790.js → index-8pjqv3zh.js} +6 -6
- package/dist/{index-kc6h6hg0.js → index-8z9we758.js} +1 -1
- package/dist/{index-r159gjwy.js → index-fenaekmk.js} +94 -8
- package/dist/{index-1923shw9.js → index-fqg5mfk7.js} +339 -19
- package/dist/{index-f475yj00.js → index-s208wab5.js} +1 -1
- package/dist/{index-79hb1wyh.js → index-tgh3ksfh.js} +5 -5
- package/dist/{index-wb15909q.js → index-zsdgd1tz.js} +3 -3
- package/dist/index.js +7 -7
- package/dist/node.js +2 -2
- package/dist/observability/index.js +1 -1
- package/dist/remote.js +1 -1
- package/dist/server/index.js +6 -6
- package/dist/testing.js +3 -3
- package/dist/tool-invoker.js +6 -6
- package/dist/tools/cli-args.d.ts +30 -6
- package/dist/tools/cli-args.d.ts.map +1 -1
- package/dist/tools/cli-installer.d.ts +34 -0
- package/dist/tools/cli-installer.d.ts.map +1 -0
- package/dist/tools/cli-manifest.d.ts +83 -0
- package/dist/tools/cli-manifest.d.ts.map +1 -0
- package/dist/tools/cli-profile.d.ts +40 -0
- package/dist/tools/cli-profile.d.ts.map +1 -0
- package/dist/tools/cli-update.d.ts +64 -0
- package/dist/tools/cli-update.d.ts.map +1 -0
- package/dist/tools/cli-view.d.ts +12 -0
- package/dist/tools/cli-view.d.ts.map +1 -0
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools/connections/index.d.ts +2 -1
- package/dist/tools/connections/index.d.ts.map +1 -1
- package/dist/tools/connections/index.js +74 -14
- package/dist/tools/connections/mcp-envelope.d.ts +44 -0
- package/dist/tools/connections/mcp-envelope.d.ts.map +1 -0
- package/dist/tools/connections/mcp.d.ts +2 -1
- package/dist/tools/connections/mcp.d.ts.map +1 -1
- package/dist/tools/connections/mount.d.ts.map +1 -1
- package/dist/tools/connections/openapi.d.ts +2 -1
- package/dist/tools/connections/openapi.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +17 -0
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +18 -1
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/json-schema-dialect.d.ts +17 -0
- package/dist/tools/json-schema-dialect.d.ts.map +1 -0
- package/dist/tools/presentation.d.ts +8 -1
- package/dist/tools/presentation.d.ts.map +1 -1
- package/dist/tools.js +13 -13
- package/dist/tracking.js +1 -1
- package/llms-full.txt +273 -3
- package/package.json +1 -1
- package/dist/{index-db51n3xr.js → index-ra6txecz.js} +3 -3
package/dist/testing.js
CHANGED
|
@@ -41,17 +41,17 @@ import {
|
|
|
41
41
|
joinRoutePath
|
|
42
42
|
} from "./index-kazec06k.js";
|
|
43
43
|
import"./index-6k1937bx.js";
|
|
44
|
-
import"./index-scs3f1eg.js";
|
|
45
44
|
import"./index-zcgf3gqf.js";
|
|
46
|
-
import"./index-kzfs85xp.js";
|
|
47
45
|
import {
|
|
48
46
|
mcpProjectionCandidate,
|
|
49
47
|
prepareProjectedMcpTools,
|
|
50
48
|
projectToolSurface
|
|
51
|
-
} from "./index-
|
|
49
|
+
} from "./index-fenaekmk.js";
|
|
52
50
|
import {
|
|
53
51
|
toJsonSchema
|
|
54
52
|
} from "./index-cby4ar3v.js";
|
|
53
|
+
import"./index-scs3f1eg.js";
|
|
54
|
+
import"./index-kzfs85xp.js";
|
|
55
55
|
import {
|
|
56
56
|
isRecord
|
|
57
57
|
} from "./index-77fekveh.js";
|
package/dist/tool-invoker.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToolInvoker
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-tgh3ksfh.js";
|
|
4
|
+
import"./index-1bnkzq95.js";
|
|
5
|
+
import"./index-8pjqv3zh.js";
|
|
6
6
|
import"./index-vsbzgd7b.js";
|
|
7
7
|
import"./index-f9mb610r.js";
|
|
8
8
|
import"./index-2hryh65w.js";
|
|
9
9
|
import"./index-kazec06k.js";
|
|
10
10
|
import"./index-6k1937bx.js";
|
|
11
|
-
import"./index-scs3f1eg.js";
|
|
12
11
|
import"./index-zcgf3gqf.js";
|
|
13
12
|
import"./index-7zbps32p.js";
|
|
14
|
-
import"./index-
|
|
15
|
-
import"./index-r159gjwy.js";
|
|
13
|
+
import"./index-fenaekmk.js";
|
|
16
14
|
import"./index-cby4ar3v.js";
|
|
15
|
+
import"./index-scs3f1eg.js";
|
|
16
|
+
import"./index-kzfs85xp.js";
|
|
17
17
|
import"./index-77fekveh.js";
|
|
18
18
|
export {
|
|
19
19
|
createToolInvoker
|
package/dist/tools/cli-args.d.ts
CHANGED
|
@@ -18,6 +18,29 @@
|
|
|
18
18
|
* call does (ADR 0014 parity).
|
|
19
19
|
*/
|
|
20
20
|
import { z } from 'zod';
|
|
21
|
+
/**
|
|
22
|
+
* A requested aggregate view over the result.
|
|
23
|
+
*
|
|
24
|
+
* `--by` always names the grouping field, in every form it appears in, so the
|
|
25
|
+
* grammar has one meaning rather than two: `--top 5 --by status` is the five
|
|
26
|
+
* largest groups of `status`, exactly as `--count-by status --top 5` is.
|
|
27
|
+
*/
|
|
28
|
+
export type CliResultView = {
|
|
29
|
+
kind: 'count';
|
|
30
|
+
field: string;
|
|
31
|
+
top?: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'sum';
|
|
34
|
+
field: string;
|
|
35
|
+
by?: string;
|
|
36
|
+
top?: number;
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'records';
|
|
39
|
+
sort?: string;
|
|
40
|
+
ascending?: boolean;
|
|
41
|
+
top?: number;
|
|
42
|
+
table?: readonly string[];
|
|
43
|
+
};
|
|
21
44
|
/** CLI-behaviour flags, parsed out of argv before the tool arguments. */
|
|
22
45
|
export interface CliRunOptions {
|
|
23
46
|
/** `--json` — emit compact success/error JSON records for scripts. */
|
|
@@ -34,6 +57,8 @@ export interface CliRunOptions {
|
|
|
34
57
|
dryRun: boolean;
|
|
35
58
|
/** `--help` / `-h` — print usage for the command. */
|
|
36
59
|
help: boolean;
|
|
60
|
+
/** `--count-by` / `--sum` / `--top` / `--table` — aggregate instead of the collection. */
|
|
61
|
+
view?: CliResultView;
|
|
37
62
|
}
|
|
38
63
|
export interface ParsedCliArgs {
|
|
39
64
|
/** The flat tool-argument object handed to `executeToolMethod`. */
|
|
@@ -46,6 +71,8 @@ export interface CliArgvRoute {
|
|
|
46
71
|
commandArgv: string[];
|
|
47
72
|
topLevelHelp: boolean;
|
|
48
73
|
version: boolean;
|
|
74
|
+
/** `--help <substring>` — narrow the command list instead of printing it whole. */
|
|
75
|
+
helpFilter?: string;
|
|
49
76
|
error?: string;
|
|
50
77
|
}
|
|
51
78
|
type FieldKind = 'boolean' | 'number' | 'bigint' | 'date' | 'string' | 'enum' | 'array' | 'object' | 'other';
|
|
@@ -55,12 +82,6 @@ interface FieldInfo {
|
|
|
55
82
|
elementKind?: FieldKind;
|
|
56
83
|
}
|
|
57
84
|
export declare const RESERVED_CLI_OPTIONS: Set<string>;
|
|
58
|
-
/**
|
|
59
|
-
* Select a command without duplicating the framework-global option grammar.
|
|
60
|
-
* With no default configured this returns the historical first-token routing
|
|
61
|
-
* byte-for-byte. With a default, recognised leading globals may precede an
|
|
62
|
-
* explicit command; a remaining option token belongs to the default command.
|
|
63
|
-
*/
|
|
64
85
|
export declare function routeCliArgv(argv: string[], defaultCommand?: string): CliArgvRoute;
|
|
65
86
|
export declare class CliArgumentError extends Error {
|
|
66
87
|
name: string;
|
|
@@ -72,6 +93,9 @@ export declare class CliArgumentError extends Error {
|
|
|
72
93
|
* scalar schema yields an empty map and every value is left as a string.
|
|
73
94
|
*/
|
|
74
95
|
export declare function describeSchemaFields(schema: z.ZodType | undefined): Map<string, FieldInfo>;
|
|
96
|
+
/** Strict boolean for a RESERVED option — an unrecognised value is a usage error, never a silent `true`. */
|
|
97
|
+
/** True for a value the reserved-boolean grammar already claims. */
|
|
98
|
+
export declare function isReservedBoolWord(value: string): boolean;
|
|
75
99
|
/**
|
|
76
100
|
* Parse a command's argv slice (everything after the command name) against its
|
|
77
101
|
* merged tool schema.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/tools/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,yEAAyE;AACzE,MAAM,WAAW,aAAa;IAC5B,sEAAsE;IACtE,IAAI,EAAE,OAAO,CAAC;IACd,iEAAiE;IACjE,IAAI,EAAE,OAAO,CAAC;IACd,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,KAAK,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,MAAM,EAAE,OAAO,CAAC;IAChB,qDAAqD;IACrD,IAAI,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/tools/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB;;;;;;GAMG;A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EAAE,OAAO,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,uBAAuB,CACrC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,MAAM,EAAE,CAAC,CAAC,SAAS,GAAG,SAAS,GAC9B,qBAAqB,CA8CvB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate the one-line installer, from the manifest, on the server.
|
|
3
|
+
*
|
|
4
|
+
* A `curl … | sh` runs on a machine where nothing is installed yet — including
|
|
5
|
+
* `jq`. An installer that fetches the manifest and parses it therefore fails on
|
|
6
|
+
* exactly the machines it exists for. Generating the script *from* the manifest,
|
|
7
|
+
* with the URL and the digest already substituted, removes the dependency: the
|
|
8
|
+
* script downloads one file, checks one digest and renames it into place.
|
|
9
|
+
*/
|
|
10
|
+
import type { CliBuildAsset, CliBuildManifest } from './cli-manifest.js';
|
|
11
|
+
export interface CliInstallerConfig {
|
|
12
|
+
manifest: CliBuildManifest;
|
|
13
|
+
/**
|
|
14
|
+
* The asset this script installs. Omit it to render one script covering every
|
|
15
|
+
* asset in the manifest, selected by `uname` at run time — otherwise the
|
|
16
|
+
* dispatch is the one hand-written piece left in the install path, and every
|
|
17
|
+
* publisher writes the same `uname -s`/`uname -m` mapping from memory.
|
|
18
|
+
*/
|
|
19
|
+
asset?: CliBuildAsset;
|
|
20
|
+
/** The name the binary takes on the PATH; defaults to the manifest name. */
|
|
21
|
+
binaryName?: string;
|
|
22
|
+
/** Default install directory; overridable by `INSTALL_DIR` at run time. */
|
|
23
|
+
installDir?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Render the installer for one asset.
|
|
27
|
+
*
|
|
28
|
+
* The three properties that matter, in the script rather than in a comment:
|
|
29
|
+
* no JSON parsing, the digest is checked against the **decompressed** bytes, and
|
|
30
|
+
* the final step is a rename — an interrupted download leaves a temporary file,
|
|
31
|
+
* never a half-written executable on someone's PATH.
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderCliInstaller(config: CliInstallerConfig): string;
|
|
34
|
+
//# sourceMappingURL=cli-installer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-installer.d.ts","sourceRoot":"","sources":["../../src/tools/cli-installer.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEtE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAOD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CA+ErE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The build manifest a CLI is distributed by — one schema, so the publisher,
|
|
3
|
+
* the server and the installed binary cannot disagree about it.
|
|
4
|
+
*
|
|
5
|
+
* Everything here is Zod and arithmetic: no filesystem, no network. The half
|
|
6
|
+
* that downloads lives in `cli-update.ts`, the half that writes shell in
|
|
7
|
+
* `cli-installer.ts`, and both read these shapes.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
/** What a build runs on. The values are Node's own, so a CLI can name its own. */
|
|
11
|
+
export declare const CliBuildTargetSchema: z.ZodObject<{
|
|
12
|
+
platform: z.ZodString;
|
|
13
|
+
arch: z.ZodString;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export type CliBuildTarget = z.infer<typeof CliBuildTargetSchema>;
|
|
16
|
+
/**
|
|
17
|
+
* One downloadable build.
|
|
18
|
+
*
|
|
19
|
+
* `size` and `sha256` describe the **decompressed** bytes — what will actually
|
|
20
|
+
* be executed. A digest over the transferred archive proves the transfer and
|
|
21
|
+
* says nothing about the file that ends up on the PATH, which is the one the
|
|
22
|
+
* user runs.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CliBuildAssetSchema: z.ZodObject<{
|
|
25
|
+
platform: z.ZodString;
|
|
26
|
+
arch: z.ZodString;
|
|
27
|
+
url: z.ZodURL;
|
|
28
|
+
compression: z.ZodDefault<z.ZodEnum<{
|
|
29
|
+
gzip: "gzip";
|
|
30
|
+
none: "none";
|
|
31
|
+
}>>;
|
|
32
|
+
size: z.ZodInt;
|
|
33
|
+
sha256: z.ZodString;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export type CliBuildAsset = z.infer<typeof CliBuildAssetSchema>;
|
|
36
|
+
/**
|
|
37
|
+
* The document a CLI's distribution endpoint serves.
|
|
38
|
+
*
|
|
39
|
+
* `commit` and `builtAt` are here, not only inside the binary, because the
|
|
40
|
+
* question "is what I am running the build this version means" is asked from
|
|
41
|
+
* both sides.
|
|
42
|
+
*/
|
|
43
|
+
export declare const CliBuildManifestSchema: z.ZodObject<{
|
|
44
|
+
name: z.ZodString;
|
|
45
|
+
version: z.ZodString;
|
|
46
|
+
commit: z.ZodString;
|
|
47
|
+
builtAt: z.ZodISODateTime;
|
|
48
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
49
|
+
platform: z.ZodString;
|
|
50
|
+
arch: z.ZodString;
|
|
51
|
+
url: z.ZodURL;
|
|
52
|
+
compression: z.ZodDefault<z.ZodEnum<{
|
|
53
|
+
gzip: "gzip";
|
|
54
|
+
none: "none";
|
|
55
|
+
}>>;
|
|
56
|
+
size: z.ZodInt;
|
|
57
|
+
sha256: z.ZodString;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export type CliBuildManifest = z.infer<typeof CliBuildManifestSchema>;
|
|
61
|
+
/** The stamp a build carries inside itself, so the tool can say what it is. */
|
|
62
|
+
export declare const CliBuildStampSchema: z.ZodObject<{
|
|
63
|
+
version: z.ZodString;
|
|
64
|
+
commit: z.ZodString;
|
|
65
|
+
builtAt: z.ZodISODateTime;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
export type CliBuildStamp = z.infer<typeof CliBuildStampSchema>;
|
|
68
|
+
/** One line a `--version` can print: what it is, not what the reader infers. */
|
|
69
|
+
export declare function formatCliBuildStamp(stamp: CliBuildStamp, name?: string): string;
|
|
70
|
+
/** The target the running process is on, in the manifest's own vocabulary. */
|
|
71
|
+
export declare function currentCliBuildTarget(): CliBuildTarget;
|
|
72
|
+
/** The asset for one target, or `undefined` when this build was not published. */
|
|
73
|
+
export declare function selectCliBuildAsset(manifest: CliBuildManifest, target?: CliBuildTarget): CliBuildAsset | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Refuse republishing a version from a different commit.
|
|
76
|
+
*
|
|
77
|
+
* A version is a promise about contents. Publishing `1.4.2` twice from two trees
|
|
78
|
+
* means everyone who already installed `1.4.2` is told they are current and
|
|
79
|
+
* never receives the fix — and nothing about their machine looks wrong. The
|
|
80
|
+
* check is one comparison and belongs in the publisher, before the upload.
|
|
81
|
+
*/
|
|
82
|
+
export declare function assertCliPublishable(previous: CliBuildManifest | undefined, next: CliBuildManifest): void;
|
|
83
|
+
//# sourceMappingURL=cli-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-manifest.d.ts","sourceRoot":"","sources":["../../src/tools/cli-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,kFAAkF;AAClF,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAK9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;iBAMjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAG/E;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,IAAI,cAAc,CAEtD;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,GAAE,cAAwC,GAC/C,aAAa,GAAG,SAAS,CAI3B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,EACtC,IAAI,EAAE,gBAAgB,GACrB,IAAI,CAQN"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import { AppError } from '../contract/errors.js';
|
|
3
|
+
/** A refusal a CLI can report as an ordinary error result. */
|
|
4
|
+
export declare class CliProfileError extends AppError {
|
|
5
|
+
constructor(message: string, code?: 'NOT_FOUND' | 'BAD_REQUEST' | 'FORBIDDEN');
|
|
6
|
+
}
|
|
7
|
+
export interface CliProfileStoreConfig<TSchema extends z.ZodType> {
|
|
8
|
+
/** Directory holding one `<name>.json` per profile, mode 0700. */
|
|
9
|
+
directory: string;
|
|
10
|
+
/** What one profile file must contain — an address and a credential, typically. */
|
|
11
|
+
schema: TSchema;
|
|
12
|
+
/**
|
|
13
|
+
* How to create a missing profile, in the application's own words. It is
|
|
14
|
+
* printed with the refusal, because "profile not found" without the command
|
|
15
|
+
* that creates it leaves the reader to guess the file format.
|
|
16
|
+
*/
|
|
17
|
+
createHint?: (name: string, path: string) => string;
|
|
18
|
+
/** Where the substitution notice goes; default stderr. */
|
|
19
|
+
announce?: (line: string) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface ResolvedCliProfile<TValue> {
|
|
22
|
+
name: string;
|
|
23
|
+
path: string;
|
|
24
|
+
value: TValue;
|
|
25
|
+
/** True when no name was asked for and the only configured profile was taken. */
|
|
26
|
+
substituted: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface CliProfileStore<TValue> {
|
|
29
|
+
directory: string;
|
|
30
|
+
pathFor(name: string): string;
|
|
31
|
+
list(): string[];
|
|
32
|
+
read(name: string): TValue;
|
|
33
|
+
/** Write a profile, creating the directory 0700 and the file 0600. */
|
|
34
|
+
write(name: string, value: unknown): string;
|
|
35
|
+
/** The rule this module exists for. `undefined` means "no name was given". */
|
|
36
|
+
resolve(name: string | undefined): ResolvedCliProfile<TValue>;
|
|
37
|
+
}
|
|
38
|
+
/** Build a profile store over a directory of `0600` JSON files. */
|
|
39
|
+
export declare function createCliProfileStore<TSchema extends z.ZodType>(config: CliProfileStoreConfig<TSchema>): CliProfileStore<z.output<TSchema>>;
|
|
40
|
+
//# sourceMappingURL=cli-profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-profile.d.ts","sourceRoot":"","sources":["../../src/tools/cli-profile.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAO9C,8DAA8D;AAC9D,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,WAAW,GAAG,aAAa,GAAG,WAAyB,EAGzF;CACF;AAED,M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ateCheckConfig {
|
|
3
|
+
manifestUrl: string;
|
|
4
|
+
currentVersion: string;
|
|
5
|
+
/** At most one network check per interval; default 24 h. */
|
|
6
|
+
intervalMs?: number;
|
|
7
|
+
/** When the last check happened, from the application's own state. */
|
|
8
|
+
lastCheckedAt?: number;
|
|
9
|
+
now?: number;
|
|
10
|
+
/** Header+body deadline for the check; default 2 s. */
|
|
11
|
+
timeoutMs?: number;
|
|
12
|
+
target?: CliBuildTarget;
|
|
13
|
+
allowPrivateHosts?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Four answers, never three. "Could not ask" is not "up to date": collapsing
|
|
17
|
+
* them is how a tool goes quiet about its own staleness for months.
|
|
18
|
+
*/
|
|
19
|
+
export type CliUpdateCheck = {
|
|
20
|
+
status: 'skipped';
|
|
21
|
+
nextCheckAt: number;
|
|
22
|
+
} | {
|
|
23
|
+
status: 'current';
|
|
24
|
+
version: string;
|
|
25
|
+
} | {
|
|
26
|
+
status: 'outdated';
|
|
27
|
+
version: string;
|
|
28
|
+
manifest: CliBuildManifest;
|
|
29
|
+
asset?: CliBuildAsset;
|
|
30
|
+
} | {
|
|
31
|
+
status: 'unknown';
|
|
32
|
+
reason: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Compare two versions, or refuse to. `undefined` means "these are not
|
|
36
|
+
* comparable", which the caller reports as unknown rather than guessing an
|
|
37
|
+
* order — an update prompt derived from a guess is worse than no prompt.
|
|
38
|
+
*/
|
|
39
|
+
export declare function compareCliVersions(left: string, right: string): number | undefined;
|
|
40
|
+
/** Ask whether a newer build exists. Never throws; never blocks for long. */
|
|
41
|
+
export declare function checkCliUpdate(config: CliUpdateCheckConfig): Promise<CliUpdateCheck>;
|
|
42
|
+
export interface CliUpdateApplyConfig {
|
|
43
|
+
asset: CliBuildAsset;
|
|
44
|
+
/** The file to replace; defaults to the running executable. */
|
|
45
|
+
targetPath?: string;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
maxBytes?: number;
|
|
48
|
+
allowPrivateHosts?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface AppliedCliUpdate {
|
|
51
|
+
path: string;
|
|
52
|
+
bytes: number;
|
|
53
|
+
sha256: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Download, verify and replace the binary.
|
|
57
|
+
*
|
|
58
|
+
* The digest is taken over the decompressed bytes — the file that will be
|
|
59
|
+
* executed — and the last step is a rename inside the target's own directory,
|
|
60
|
+
* so the executable on the PATH is either the old one or the new one and never
|
|
61
|
+
* a partial write.
|
|
62
|
+
*/
|
|
63
|
+
export declare function applyCliUpdate(config: CliUpdateApplyConfig): Promise<AppliedCliUpdate>;
|
|
64
|
+
//# sourceMappingURL=cli-update.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-update.d.ts","sourceRoot":"","sources":["../../src/tools/cli-update.ts"],"names":[],"mappings":"AAeA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,gBAAgB,EAErB,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AASxB,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,sEAAsE;IACtE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uDAAuD;IACvD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GACtB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,gBAAgB,CAAC;IAAC,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,GAC1F;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAe1C;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAalF;AAED,6EAA6E;AAC7E,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,cAAc,CAAC,CA2C1F;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,aAAa,CAAC;IACrB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAmC5F"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type CliResultView } from './cli-args.js';
|
|
2
|
+
/** What a view produces: a JSON value, or the one human-facing shape. */
|
|
3
|
+
export type CliViewOutput = {
|
|
4
|
+
kind: 'json';
|
|
5
|
+
data: unknown;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'text';
|
|
8
|
+
text: string;
|
|
9
|
+
};
|
|
10
|
+
/** Compute the requested view, or refuse it with a message naming the field. */
|
|
11
|
+
export declare function renderCliView(data: unknown, view: CliResultView): CliViewOutput;
|
|
12
|
+
//# sourceMappingURL=cli-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-view.d.ts","sourceRoot":"","sources":["../../src/tools/cli-view.ts"],"names":[],"mappings":"AAeA,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAElE,yEAAyE;AACzE,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAwK7F,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,GAAG,aAAa,CA+B/E"}
|
package/dist/tools/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/tools/cli.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/tools/cli.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAUhE,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAsB,KAAK,WAAW,EAAc,MAAM,cAAc,CAAC;AAChF,OAAO,EAIL,KAAK,2BAA2B,EACjC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,KAAK,WAAW,EA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AAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACtC;AA2ZD,8EAA8E;AAC9E,wBAAsB,SAAS,CAC7B,KAAK,GAAG,OAAO,EACf,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,QAAQ,SAAS,SAAS,GAAG,SAAS,EACtC,MAAM,EAAE,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAme7D"}
|
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
* outbound request is checked against the connection's own host (plus any
|
|
12
12
|
* explicit `allowHosts`), and credentials are resolved separately for each call.
|
|
13
13
|
*/
|
|
14
|
+
export type { RuntimeToolTransport } from '../runtime-tool.js';
|
|
14
15
|
export { defineMcpClientConnection, defineOpenApiConnection } from './define.js';
|
|
15
16
|
export { ConnectionAuthorizationRequiredError, ConnectionBudgetExceededError, ConnectionRequestError, ConnectionUrlError, } from './errors.js';
|
|
16
17
|
export { mountConnections } from './mount.js';
|
|
17
|
-
export type { ConnectionTokenProvider } from './runtime.js';
|
|
18
|
+
export type { ConnectionTokenProvider, ConnectionToolSkipReporter, SkippedConnectionTool, } from './runtime.js';
|
|
18
19
|
export type { ConnectionBudget, ConnectionDefinition, ConnectionMountOptions, McpClientConnection, McpClientConnectionConfig, McpConnectionTransport, McpToolFilter, OpenApiConnection, OpenApiConnectionConfig, } from './types.js';
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC7B,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAC9E,OAAO,EACL,oCAAoC,EACpC,6BAA6B,EAC7B,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,YAAY,EACV,uBAAuB,EACvB,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,SAAS,CAAC"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineRuntimeTool
|
|
3
|
-
} from "../../index-
|
|
4
|
-
import
|
|
3
|
+
} from "../../index-8z9we758.js";
|
|
4
|
+
import {
|
|
5
|
+
declaresDraft07,
|
|
6
|
+
withDefsDialect
|
|
7
|
+
} from "../../index-fenaekmk.js";
|
|
5
8
|
import"../../index-cby4ar3v.js";
|
|
9
|
+
import {
|
|
10
|
+
AppError
|
|
11
|
+
} from "../../index-scs3f1eg.js";
|
|
12
|
+
import {
|
|
13
|
+
safeJsonParse
|
|
14
|
+
} from "../../index-kzfs85xp.js";
|
|
6
15
|
import {
|
|
7
16
|
isRecord
|
|
8
17
|
} from "../../index-77fekveh.js";
|
|
@@ -511,6 +520,34 @@ class McpHttpClient {
|
|
|
511
520
|
}
|
|
512
521
|
}
|
|
513
522
|
|
|
523
|
+
// src/tools/connections/mcp-envelope.ts
|
|
524
|
+
function unwrapMcpResult(result) {
|
|
525
|
+
if (!isRecord(result))
|
|
526
|
+
return result;
|
|
527
|
+
if (result.structuredContent !== undefined)
|
|
528
|
+
return result.structuredContent;
|
|
529
|
+
if (!Array.isArray(result.content))
|
|
530
|
+
return result;
|
|
531
|
+
const only = result.content.length === 1 ? result.content[0] : undefined;
|
|
532
|
+
if (!isRecord(only) || only.type !== "text" || typeof only.text !== "string")
|
|
533
|
+
return result;
|
|
534
|
+
try {
|
|
535
|
+
return safeJsonParse(only.text);
|
|
536
|
+
} catch {
|
|
537
|
+
return only.text;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
var UPSTREAM_TOOL_ERROR = "UPSTREAM_TOOL_ERROR";
|
|
541
|
+
function mcpToolFailure(toolName, result) {
|
|
542
|
+
const payload = unwrapMcpResult(result);
|
|
543
|
+
if (isRecord(payload) && typeof payload.error === "string") {
|
|
544
|
+
const details = isRecord(payload.details) ? payload.details : undefined;
|
|
545
|
+
const message = typeof details?.message === "string" ? details.message : payload.error;
|
|
546
|
+
return new AppError(payload.error, message, 502, details);
|
|
547
|
+
}
|
|
548
|
+
return new AppError(UPSTREAM_TOOL_ERROR, `External MCP tool "${toolName}" returned an error`, 502, payload === undefined ? undefined : { upstream: payload });
|
|
549
|
+
}
|
|
550
|
+
|
|
514
551
|
// src/tools/connections/runtime.ts
|
|
515
552
|
import { z } from "zod";
|
|
516
553
|
async function withConnectionToken(params, body) {
|
|
@@ -527,14 +564,35 @@ async function withConnectionToken(params, body) {
|
|
|
527
564
|
function zodObjectFromJsonSchema(schema) {
|
|
528
565
|
if (!schema || Object.keys(schema).length === 0)
|
|
529
566
|
return z.looseObject({});
|
|
530
|
-
const parsed = z.fromJSONSchema(schema);
|
|
567
|
+
const parsed = z.fromJSONSchema(reconcileDefinitionKeyword(schema));
|
|
531
568
|
if (parsed instanceof z.ZodObject)
|
|
532
569
|
return parsed;
|
|
533
570
|
return z.looseObject({});
|
|
534
571
|
}
|
|
572
|
+
function reconcileDefinitionKeyword(schema) {
|
|
573
|
+
return declaresDraft07(schema.$schema) ? schema : withDefsDialect(schema);
|
|
574
|
+
}
|
|
535
575
|
function sanitizeToolName(value) {
|
|
536
576
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "operation";
|
|
537
577
|
}
|
|
578
|
+
function reportSkippedConnectionTool(skipped) {
|
|
579
|
+
console.warn(`[stitchkit] connection "${skipped.connection}": tool "${skipped.tool}" not mounted — ${skipped.reason}`);
|
|
580
|
+
}
|
|
581
|
+
function mountToolsTolerantly(entries, connection, nameOf, build, onSkipped) {
|
|
582
|
+
const mounted = [];
|
|
583
|
+
for (const entry of entries) {
|
|
584
|
+
try {
|
|
585
|
+
mounted.push(build(entry));
|
|
586
|
+
} catch (error) {
|
|
587
|
+
onSkipped({
|
|
588
|
+
connection,
|
|
589
|
+
tool: nameOf(entry),
|
|
590
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return mounted;
|
|
595
|
+
}
|
|
538
596
|
|
|
539
597
|
// src/tools/connections/schema-budget.ts
|
|
540
598
|
var schemaBytes = new WeakMap;
|
|
@@ -551,7 +609,7 @@ function jsonSchemaBytes(schema) {
|
|
|
551
609
|
}
|
|
552
610
|
|
|
553
611
|
// src/tools/connections/mcp.ts
|
|
554
|
-
async function mountMcpConnection(connection, instanceId) {
|
|
612
|
+
async function mountMcpConnection(connection, instanceId, onSkipped) {
|
|
555
613
|
const url = assertConnectionUrl(connection.transport.url, connection.name);
|
|
556
614
|
const allowedHosts = connectionAllowedHosts(url, connection.allowHosts);
|
|
557
615
|
assertAllowedHost(url, allowedHosts, connection.name);
|
|
@@ -568,7 +626,7 @@ async function mountMcpConnection(connection, instanceId) {
|
|
|
568
626
|
}).finally(() => discovery.teardown());
|
|
569
627
|
const discovered = readDiscoveredTools(listed, connection.name);
|
|
570
628
|
const filtered = filterMcpTools(discovered, connection.tools);
|
|
571
|
-
return filtered.
|
|
629
|
+
return mountToolsTolerantly(filtered, connection.name, (tool) => tool.name, (tool) => {
|
|
572
630
|
const name = tool.name;
|
|
573
631
|
const description = tool.description ?? `External MCP tool "${name}"`;
|
|
574
632
|
const input = zodObjectFromJsonSchema(tool.inputSchema);
|
|
@@ -576,6 +634,7 @@ async function mountMcpConnection(connection, instanceId) {
|
|
|
576
634
|
name,
|
|
577
635
|
description,
|
|
578
636
|
identity: { serviceName: connection.name, action: name, method: "POST" },
|
|
637
|
+
...connection.transports && { transports: connection.transports },
|
|
579
638
|
input,
|
|
580
639
|
output: z2.unknown(),
|
|
581
640
|
handler: (context) => {
|
|
@@ -583,16 +642,15 @@ async function mountMcpConnection(connection, instanceId) {
|
|
|
583
642
|
return withConnectionToken({ instanceId, provider: connection.token, client, context }, async (token) => {
|
|
584
643
|
await client.initialize(token, context.signal);
|
|
585
644
|
const result = await client.request("tools/call", { name, arguments: context.input }, token, context.signal);
|
|
586
|
-
if (isRecord(result) && result.isError === true)
|
|
587
|
-
throw
|
|
588
|
-
|
|
589
|
-
return result;
|
|
645
|
+
if (isRecord(result) && result.isError === true)
|
|
646
|
+
throw mcpToolFailure(name, result);
|
|
647
|
+
return context.source === "cli" ? unwrapMcpResult(result) : result;
|
|
590
648
|
}).finally(() => client.teardown());
|
|
591
649
|
}
|
|
592
650
|
});
|
|
593
651
|
recordForeignSchemaBytes(definition, jsonSchemaBytes(tool.inputSchema));
|
|
594
652
|
return definition;
|
|
595
|
-
});
|
|
653
|
+
}, onSkipped);
|
|
596
654
|
}
|
|
597
655
|
function readDiscoveredTools(listed, connectionName) {
|
|
598
656
|
if (!isRecord(listed) || !Array.isArray(listed.tools)) {
|
|
@@ -684,7 +742,7 @@ function assertOpenApiOperation(document, operation, pathItem) {
|
|
|
684
742
|
}
|
|
685
743
|
|
|
686
744
|
// src/tools/connections/openapi.ts
|
|
687
|
-
async function mountOpenApiConnection(connection, instanceId) {
|
|
745
|
+
async function mountOpenApiConnection(connection, instanceId, onSkipped) {
|
|
688
746
|
const timeoutMs = connectionTimeoutMs(connection.timeoutMs);
|
|
689
747
|
const maxResponseBytes = connectionMaxResponseBytes(connection.maxResponseBytes);
|
|
690
748
|
const loaded = await loadOpenApiDocument(connection, timeoutMs, maxResponseBytes);
|
|
@@ -695,7 +753,7 @@ async function mountOpenApiConnection(connection, instanceId) {
|
|
|
695
753
|
assertAllowedHost(new URL(baseUrl), allowedHosts, connection.name);
|
|
696
754
|
const operations = collectOperations(document);
|
|
697
755
|
const names = new Set;
|
|
698
|
-
return operations.
|
|
756
|
+
return mountToolsTolerantly(operations, connection.name, operationKey, (entry) => {
|
|
699
757
|
assertOpenApiOperation(document, entry.operation, entry.pathItem);
|
|
700
758
|
const rawName = operationKey(entry);
|
|
701
759
|
const name = uniqueToolName(connection.name, rawName, names);
|
|
@@ -711,6 +769,7 @@ async function mountOpenApiConnection(connection, instanceId) {
|
|
|
711
769
|
action: rawName,
|
|
712
770
|
method: entry.method
|
|
713
771
|
},
|
|
772
|
+
...connection.transports && { transports: connection.transports },
|
|
714
773
|
input,
|
|
715
774
|
output: z3.unknown(),
|
|
716
775
|
handler: (context) => withConnectionToken({ instanceId, provider: connection.token, context }, async (token) => {
|
|
@@ -753,7 +812,7 @@ async function mountOpenApiConnection(connection, instanceId) {
|
|
|
753
812
|
});
|
|
754
813
|
recordForeignSchemaBytes(definition, jsonSchemaBytes(schema));
|
|
755
814
|
return definition;
|
|
756
|
-
});
|
|
815
|
+
}, onSkipped);
|
|
757
816
|
}
|
|
758
817
|
async function loadOpenApiDocument(connection, timeoutMs, maxResponseBytes) {
|
|
759
818
|
if (typeof connection.spec === "object" && connection.spec !== null) {
|
|
@@ -1005,9 +1064,10 @@ function asRecord(value) {
|
|
|
1005
1064
|
// src/tools/connections/mount.ts
|
|
1006
1065
|
async function mountConnections(connections, options = {}) {
|
|
1007
1066
|
const tools = [];
|
|
1067
|
+
const onSkipped = options.onSkippedTool ?? reportSkippedConnectionTool;
|
|
1008
1068
|
for (const connection of connections) {
|
|
1009
1069
|
const instanceId = instanceIdOf(connection);
|
|
1010
|
-
const mounted = connection.kind === "mcp" ? await mountMcpConnection(connection, instanceId) : await mountOpenApiConnection(connection, instanceId);
|
|
1070
|
+
const mounted = connection.kind === "mcp" ? await mountMcpConnection(connection, instanceId, onSkipped) : await mountOpenApiConnection(connection, instanceId, onSkipped);
|
|
1011
1071
|
tools.push(...mounted);
|
|
1012
1072
|
}
|
|
1013
1073
|
const limit = options.budget?.maxTools;
|