stitchkit 0.90.3 → 0.90.4
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 +74 -0
- package/dist/agent-runtime-coding-tools.js +3 -3
- package/dist/agent-runtime-harness.js +4 -4
- package/dist/agent-runtime-sandbox.js +3 -3
- package/dist/agent-runtime.js +7 -7
- package/dist/cli.d.ts +14 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +359 -11
- package/dist/{index-gbqjt8jz.js → index-19ryv24q.js} +3 -3
- package/dist/{index-2hrfpw2c.js → index-32vjke6q.js} +2 -2
- package/dist/{index-f475yj00.js → index-6atvfjc1.js} +1 -1
- package/dist/{index-79hb1wyh.js → index-7t0wq6j5.js} +3 -3
- package/dist/{index-j7q0xj6d.js → index-8crm1srv.js} +1 -1
- package/dist/{index-kc6h6hg0.js → index-8z9we758.js} +1 -1
- package/dist/{index-r159gjwy.js → index-fenaekmk.js} +94 -8
- package/dist/{index-wb15909q.js → index-kzxpsf8y.js} +3 -3
- package/dist/{index-44ht2790.js → index-vcnfwrtr.js} +1 -1
- package/dist/{index-1923shw9.js → index-y47z614h.js} +214 -7
- package/dist/testing.js +1 -1
- package/dist/tool-invoker.js +4 -4
- package/dist/tools/cli-args.d.ts +22 -0
- package/dist/tools/cli-args.d.ts.map +1 -1
- package/dist/tools/cli-installer.d.ts +29 -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 +37 -10
- 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 +8 -8
- package/llms-full.txt +203 -3
- package/package.json +1 -1
|
@@ -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,MAAM,WAAW,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO;IAC9D,kEAAkE;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,MAAM,EAAE,OAAO,CAAC;IAChB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IACpD,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,kBAAkB,CAAC,MAAM;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,eAAe,CAAC,MAAM;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9B,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,sEAAsE;IACtE,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5C,8EAA8E;IAC9E,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,kBAAkB,CAAC,MAAM,CAAC,CAAC;CAC/D;AAWD,mEAAmE;AACnE,wBAAgB,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,OAAO,EAC7D,MAAM,EAAE,qBAAqB,CAAC,OAAO,CAAC,GACrC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAqFpC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type CliBuildAsset, type CliBuildManifest, type CliBuildTarget } from './cli-manifest.js';
|
|
2
|
+
export interface CliUpdateCheckConfig {
|
|
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;AAuH7F,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;AAShE,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;
|
|
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;AAShE,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,KAA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KAAK,IAAI,CAAC;IAC9B,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACtC;AAsXD,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,CA8c7D"}
|
|
@@ -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,7 +1,10 @@
|
|
|
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";
|
|
6
9
|
import {
|
|
7
10
|
isRecord
|
|
@@ -527,14 +530,35 @@ async function withConnectionToken(params, body) {
|
|
|
527
530
|
function zodObjectFromJsonSchema(schema) {
|
|
528
531
|
if (!schema || Object.keys(schema).length === 0)
|
|
529
532
|
return z.looseObject({});
|
|
530
|
-
const parsed = z.fromJSONSchema(schema);
|
|
533
|
+
const parsed = z.fromJSONSchema(reconcileDefinitionKeyword(schema));
|
|
531
534
|
if (parsed instanceof z.ZodObject)
|
|
532
535
|
return parsed;
|
|
533
536
|
return z.looseObject({});
|
|
534
537
|
}
|
|
538
|
+
function reconcileDefinitionKeyword(schema) {
|
|
539
|
+
return declaresDraft07(schema.$schema) ? schema : withDefsDialect(schema);
|
|
540
|
+
}
|
|
535
541
|
function sanitizeToolName(value) {
|
|
536
542
|
return value.replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "operation";
|
|
537
543
|
}
|
|
544
|
+
function reportSkippedConnectionTool(skipped) {
|
|
545
|
+
console.warn(`[stitchkit] connection "${skipped.connection}": tool "${skipped.tool}" not mounted — ${skipped.reason}`);
|
|
546
|
+
}
|
|
547
|
+
function mountToolsTolerantly(entries, connection, nameOf, build, onSkipped) {
|
|
548
|
+
const mounted = [];
|
|
549
|
+
for (const entry of entries) {
|
|
550
|
+
try {
|
|
551
|
+
mounted.push(build(entry));
|
|
552
|
+
} catch (error) {
|
|
553
|
+
onSkipped({
|
|
554
|
+
connection,
|
|
555
|
+
tool: nameOf(entry),
|
|
556
|
+
reason: error instanceof Error ? error.message : String(error)
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return mounted;
|
|
561
|
+
}
|
|
538
562
|
|
|
539
563
|
// src/tools/connections/schema-budget.ts
|
|
540
564
|
var schemaBytes = new WeakMap;
|
|
@@ -551,7 +575,7 @@ function jsonSchemaBytes(schema) {
|
|
|
551
575
|
}
|
|
552
576
|
|
|
553
577
|
// src/tools/connections/mcp.ts
|
|
554
|
-
async function mountMcpConnection(connection, instanceId) {
|
|
578
|
+
async function mountMcpConnection(connection, instanceId, onSkipped) {
|
|
555
579
|
const url = assertConnectionUrl(connection.transport.url, connection.name);
|
|
556
580
|
const allowedHosts = connectionAllowedHosts(url, connection.allowHosts);
|
|
557
581
|
assertAllowedHost(url, allowedHosts, connection.name);
|
|
@@ -568,7 +592,7 @@ async function mountMcpConnection(connection, instanceId) {
|
|
|
568
592
|
}).finally(() => discovery.teardown());
|
|
569
593
|
const discovered = readDiscoveredTools(listed, connection.name);
|
|
570
594
|
const filtered = filterMcpTools(discovered, connection.tools);
|
|
571
|
-
return filtered.
|
|
595
|
+
return mountToolsTolerantly(filtered, connection.name, (tool) => tool.name, (tool) => {
|
|
572
596
|
const name = tool.name;
|
|
573
597
|
const description = tool.description ?? `External MCP tool "${name}"`;
|
|
574
598
|
const input = zodObjectFromJsonSchema(tool.inputSchema);
|
|
@@ -576,6 +600,7 @@ async function mountMcpConnection(connection, instanceId) {
|
|
|
576
600
|
name,
|
|
577
601
|
description,
|
|
578
602
|
identity: { serviceName: connection.name, action: name, method: "POST" },
|
|
603
|
+
...connection.transports && { transports: connection.transports },
|
|
579
604
|
input,
|
|
580
605
|
output: z2.unknown(),
|
|
581
606
|
handler: (context) => {
|
|
@@ -592,7 +617,7 @@ async function mountMcpConnection(connection, instanceId) {
|
|
|
592
617
|
});
|
|
593
618
|
recordForeignSchemaBytes(definition, jsonSchemaBytes(tool.inputSchema));
|
|
594
619
|
return definition;
|
|
595
|
-
});
|
|
620
|
+
}, onSkipped);
|
|
596
621
|
}
|
|
597
622
|
function readDiscoveredTools(listed, connectionName) {
|
|
598
623
|
if (!isRecord(listed) || !Array.isArray(listed.tools)) {
|
|
@@ -684,7 +709,7 @@ function assertOpenApiOperation(document, operation, pathItem) {
|
|
|
684
709
|
}
|
|
685
710
|
|
|
686
711
|
// src/tools/connections/openapi.ts
|
|
687
|
-
async function mountOpenApiConnection(connection, instanceId) {
|
|
712
|
+
async function mountOpenApiConnection(connection, instanceId, onSkipped) {
|
|
688
713
|
const timeoutMs = connectionTimeoutMs(connection.timeoutMs);
|
|
689
714
|
const maxResponseBytes = connectionMaxResponseBytes(connection.maxResponseBytes);
|
|
690
715
|
const loaded = await loadOpenApiDocument(connection, timeoutMs, maxResponseBytes);
|
|
@@ -695,7 +720,7 @@ async function mountOpenApiConnection(connection, instanceId) {
|
|
|
695
720
|
assertAllowedHost(new URL(baseUrl), allowedHosts, connection.name);
|
|
696
721
|
const operations = collectOperations(document);
|
|
697
722
|
const names = new Set;
|
|
698
|
-
return operations.
|
|
723
|
+
return mountToolsTolerantly(operations, connection.name, operationKey, (entry) => {
|
|
699
724
|
assertOpenApiOperation(document, entry.operation, entry.pathItem);
|
|
700
725
|
const rawName = operationKey(entry);
|
|
701
726
|
const name = uniqueToolName(connection.name, rawName, names);
|
|
@@ -711,6 +736,7 @@ async function mountOpenApiConnection(connection, instanceId) {
|
|
|
711
736
|
action: rawName,
|
|
712
737
|
method: entry.method
|
|
713
738
|
},
|
|
739
|
+
...connection.transports && { transports: connection.transports },
|
|
714
740
|
input,
|
|
715
741
|
output: z3.unknown(),
|
|
716
742
|
handler: (context) => withConnectionToken({ instanceId, provider: connection.token, context }, async (token) => {
|
|
@@ -753,7 +779,7 @@ async function mountOpenApiConnection(connection, instanceId) {
|
|
|
753
779
|
});
|
|
754
780
|
recordForeignSchemaBytes(definition, jsonSchemaBytes(schema));
|
|
755
781
|
return definition;
|
|
756
|
-
});
|
|
782
|
+
}, onSkipped);
|
|
757
783
|
}
|
|
758
784
|
async function loadOpenApiDocument(connection, timeoutMs, maxResponseBytes) {
|
|
759
785
|
if (typeof connection.spec === "object" && connection.spec !== null) {
|
|
@@ -1005,9 +1031,10 @@ function asRecord(value) {
|
|
|
1005
1031
|
// src/tools/connections/mount.ts
|
|
1006
1032
|
async function mountConnections(connections, options = {}) {
|
|
1007
1033
|
const tools = [];
|
|
1034
|
+
const onSkipped = options.onSkippedTool ?? reportSkippedConnectionTool;
|
|
1008
1035
|
for (const connection of connections) {
|
|
1009
1036
|
const instanceId = instanceIdOf(connection);
|
|
1010
|
-
const mounted = connection.kind === "mcp" ? await mountMcpConnection(connection, instanceId) : await mountOpenApiConnection(connection, instanceId);
|
|
1037
|
+
const mounted = connection.kind === "mcp" ? await mountMcpConnection(connection, instanceId, onSkipped) : await mountOpenApiConnection(connection, instanceId, onSkipped);
|
|
1011
1038
|
tools.push(...mounted);
|
|
1012
1039
|
}
|
|
1013
1040
|
const limit = options.budget?.maxTools;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RuntimeToolDefinition } from '../runtime-tool.js';
|
|
2
|
+
import { type ConnectionToolSkipReporter } from './runtime.js';
|
|
2
3
|
import type { McpClientConnection } from './types.js';
|
|
3
4
|
/** Discover and mount every tool one MCP connection exposes. */
|
|
4
|
-
export declare function mountMcpConnection(connection: McpClientConnection, instanceId: string): Promise<RuntimeToolDefinition[]>;
|
|
5
|
+
export declare function mountMcpConnection(connection: McpClientConnection, instanceId: string, onSkipped: ConnectionToolSkipReporter): Promise<RuntimeToolDefinition[]>;
|
|
5
6
|
//# sourceMappingURL=mcp.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/mcp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/mcp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGhF,OAAO,EACL,KAAK,0BAA0B,EAIhC,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,mBAAmB,EAAiB,MAAM,SAAS,CAAC;AAQlE,gEAAgE;AAChE,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,mBAAmB,EAC/B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,0BAA0B,GACpC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAgElC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/mount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAO7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE5E;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,SAAS,oBAAoB,EAAE,EAC5C,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,SAAS,qBAAqB,EAAE,CAAC,CAuB3C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type RuntimeToolDefinition } from '../runtime-tool.js';
|
|
2
|
+
import { type ConnectionToolSkipReporter } from './runtime.js';
|
|
2
3
|
import type { OpenApiConnection } from './types.js';
|
|
3
4
|
/** Load and mount every operation of one OpenAPI document. */
|
|
4
|
-
export declare function mountOpenApiConnection(connection: OpenApiConnection, instanceId: string): Promise<RuntimeToolDefinition[]>;
|
|
5
|
+
export declare function mountOpenApiConnection(connection: OpenApiConnection, instanceId: string, onSkipped: ConnectionToolSkipReporter): Promise<RuntimeToolDefinition[]>;
|
|
5
6
|
//# sourceMappingURL=openapi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/openapi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/openapi.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqB,KAAK,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAWhF,OAAO,EACL,KAAK,0BAA0B,EAKhC,MAAM,WAAW,CAAC;AAGnB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAgBjD,8DAA8D;AAC9D,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,iBAAiB,EAC7B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,0BAA0B,GACpC,OAAO,CAAC,qBAAqB,EAAE,CAAC,CA4GlC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ZodObject } from 'zod';
|
|
2
2
|
import type { RuntimeContext } from '../../contract/index.js';
|
|
3
|
+
import type { RuntimeToolDefinition } from '../runtime-tool.js';
|
|
3
4
|
/** A connection's optional principal-scoped credential resolver. */
|
|
4
5
|
export type ConnectionTokenProvider = (context?: RuntimeContext) => string | undefined | Promise<string | undefined>;
|
|
5
6
|
interface TeardownTarget {
|
|
@@ -25,5 +26,21 @@ export declare function withConnectionToken<T>(params: {
|
|
|
25
26
|
export declare function zodObjectFromJsonSchema(schema: Record<string, unknown> | undefined): ZodObject;
|
|
26
27
|
/** Normalise a tool name into the characters every provider accepts. */
|
|
27
28
|
export declare function sanitizeToolName(value: string): string;
|
|
29
|
+
/** One discovered tool the mount could not turn into a definition. */
|
|
30
|
+
export interface SkippedConnectionTool {
|
|
31
|
+
connection: string;
|
|
32
|
+
tool: string;
|
|
33
|
+
reason: string;
|
|
34
|
+
}
|
|
35
|
+
export type ConnectionToolSkipReporter = (skipped: SkippedConnectionTool) => void;
|
|
36
|
+
/** Default report: name the tool and the reason, and keep the connection. */
|
|
37
|
+
export declare function reportSkippedConnectionTool(skipped: SkippedConnectionTool): void;
|
|
38
|
+
/**
|
|
39
|
+
* Build one definition per discovered entry, surviving the ones that cannot be
|
|
40
|
+
* built. A mount is all-or-nothing only if it is written that way, and a foreign
|
|
41
|
+
* surface of two hundred tools should not be lost to one unconvertible schema —
|
|
42
|
+
* the refusal is reported and named, which is what a caller can act on.
|
|
43
|
+
*/
|
|
44
|
+
export declare function mountToolsTolerantly<TEntry>(entries: readonly TEntry[], connection: string, nameOf: (entry: TEntry) => string, build: (entry: TEntry) => RuntimeToolDefinition, onSkipped: ConnectionToolSkipReporter): RuntimeToolDefinition[];
|
|
28
45
|
export {};
|
|
29
46
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAK,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAK,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAG7D,oEAAoE;AACpE,MAAM,MAAM,uBAAuB,GAAG,CACpC,OAAO,CAAC,EAAE,cAAc,KACrB,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAEtD,UAAU,cAAc;IACtB,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,OAAO,CAAC,EAAE,cAAc,CAAC;CAC1B,EACD,IAAI,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,CAAC,CAAC,GAC9C,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAC1C,SAAS,CAKX;AAcD,wEAAwE;AACxE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEtD;AAED,sEAAsE;AACtE,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;AAElF,6EAA6E;AAC7E,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAIhF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EACzC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EACjC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,qBAAqB,EAC/C,SAAS,EAAE,0BAA0B,GACpC,qBAAqB,EAAE,CAczB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RuntimeToolTransport } from '../runtime-tool.js';
|
|
2
|
+
import type { ConnectionTokenProvider, ConnectionToolSkipReporter } from './runtime.js';
|
|
2
3
|
/** Where one external MCP server lives, plus static request headers. */
|
|
3
4
|
export interface McpConnectionTransport {
|
|
4
5
|
url: string;
|
|
@@ -23,6 +24,14 @@ export interface McpClientConnectionConfig {
|
|
|
23
24
|
timeoutMs?: number;
|
|
24
25
|
/** Response body ceiling in bytes; defaults to 1 MiB. */
|
|
25
26
|
maxResponseBytes?: number;
|
|
27
|
+
/**
|
|
28
|
+
* Which surfaces this server's discovered tools appear on; default MCP and
|
|
29
|
+
* AGENT. Naming `['CLI']` is how a whole server becomes a set of commands,
|
|
30
|
+
* without the consumer rebuilding each discovered definition — and a
|
|
31
|
+
* connection without it contributes nothing to the CLI, because CLI exposure
|
|
32
|
+
* is explicit everywhere else in the framework too.
|
|
33
|
+
*/
|
|
34
|
+
transports?: readonly RuntimeToolTransport[];
|
|
26
35
|
}
|
|
27
36
|
/** A defined MCP connection. */
|
|
28
37
|
export interface McpClientConnection extends McpClientConnectionConfig {
|
|
@@ -40,6 +49,8 @@ export interface OpenApiConnectionConfig {
|
|
|
40
49
|
timeoutMs?: number;
|
|
41
50
|
/** Response body ceiling in bytes; defaults to 1 MiB. */
|
|
42
51
|
maxResponseBytes?: number;
|
|
52
|
+
/** Which surfaces every mounted operation appears on; default MCP and AGENT. */
|
|
53
|
+
transports?: readonly RuntimeToolTransport[];
|
|
43
54
|
}
|
|
44
55
|
/** A defined OpenAPI connection. */
|
|
45
56
|
export interface OpenApiConnection extends OpenApiConnectionConfig {
|
|
@@ -56,5 +67,11 @@ export interface ConnectionBudget {
|
|
|
56
67
|
/** Shared mount policy for every connection in one call. */
|
|
57
68
|
export interface ConnectionMountOptions {
|
|
58
69
|
budget?: ConnectionBudget;
|
|
70
|
+
/**
|
|
71
|
+
* Called for each discovered tool that could not be mounted. Defaults to a
|
|
72
|
+
* stderr line naming the connection, the tool and the reason; the rest of the
|
|
73
|
+
* surface is mounted either way.
|
|
74
|
+
*/
|
|
75
|
+
onSkippedTool?: ConnectionToolSkipReporter;
|
|
59
76
|
}
|
|
60
77
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tools/connections/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,0BA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C,EAAE,MAAM,CAAC;IAC1B,gFAAgF;IAChF,UAAU,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;CAC9C;AAED,oCAAoC;AACpC,MAAM,WAAW,iBAAkB,SAAQ,uBAAuB;IAChE,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,mEAAmE;AACnE,MAAM,MAAM,oBAAoB,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAE3E,wEAAwE;AACxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,6EAA6E;IAC7E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,4DAA4D;AAC5D,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;OAIG;IACH,aAAa,CAAC,EAAE,0BAA0B,CAAC;CAC5C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** True when a document says, in its own `$schema`, that it is draft-07. */
|
|
2
|
+
export declare function declaresDraft07(dialect: unknown): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Move a document's top-level `definitions` to `$defs`, carrying its pointers.
|
|
5
|
+
*
|
|
6
|
+
* A JSON Schema document that names one dialect and uses another's keyword is
|
|
7
|
+
* not a style question: a reader registers reusable subschemas from the keyword
|
|
8
|
+
* the dialect declares and then cannot resolve `#/definitions/x` at all. Both
|
|
9
|
+
* halves of this framework met that document — the MCP SDK stamps 2020-12 onto
|
|
10
|
+
* the metadata it is handed, and our own MCP client obeyed the stamp.
|
|
11
|
+
*
|
|
12
|
+
* Only the top level moves. A `definitions` deeper in the document may be a
|
|
13
|
+
* property literally called "definitions", and guessing which is worse than
|
|
14
|
+
* leaving it where the author put it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withDefsDialect(schema: Record<string, unknown>): Record<string, unknown>;
|
|
17
|
+
//# sourceMappingURL=json-schema-dialect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-schema-dialect.d.ts","sourceRoot":"","sources":["../../src/tools/json-schema-dialect.ts"],"names":[],"mappings":"AAQA,4EAA4E;AAC5E,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEzD;AAeD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUxF"}
|
|
@@ -10,6 +10,13 @@ export interface ToolPresentationConfig {
|
|
|
10
10
|
/** Build the one model-facing document shared by MCP, agents and manifests. */
|
|
11
11
|
export declare function buildToolPresentationSchema(config: ToolPresentationConfig): ToolPresentationSchema;
|
|
12
12
|
export declare function isObjectPresentationSchema(schema: ToolPresentationSchema): boolean;
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Metadata passed to the Zod identity carrier.
|
|
15
|
+
*
|
|
16
|
+
* The SDK supplies its own dialect and it is 2020-12, so the document has to
|
|
17
|
+
* speak 2020-12: a draft-07 `definitions` block under a 2020-12 `$schema` is a
|
|
18
|
+
* document that says one thing and does another, and a client that believes the
|
|
19
|
+
* stamp cannot resolve a single `#/definitions/...` pointer in it.
|
|
20
|
+
*/
|
|
14
21
|
export declare function presentationMetadata(schema: ToolPresentationSchema): ToolPresentationSchema;
|
|
15
22
|
//# sourceMappingURL=presentation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../src/tools/presentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"presentation.d.ts","sourceRoot":"","sources":["../../src/tools/presentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAGL,KAAK,sBAAsB,EAC5B,MAAM,WAAW,CAAC;AAInB,MAAM,WAAW,sBAAsB;IACrC,YAAY,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;IACzC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;CACnC;AA+KD,+EAA+E;AAC/E,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,sBAAsB,GAC7B,sBAAsB,CAgDxB;AAED,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAElF;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,sBAAsB,GAAG,sBAAsB,CAE3F"}
|
package/dist/tools.js
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
buildToolManifest,
|
|
22
22
|
describeToolCatalog,
|
|
23
23
|
mountAgent
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-19ryv24q.js";
|
|
25
25
|
import"./index-7rkhw9ec.js";
|
|
26
26
|
import {
|
|
27
27
|
argumentsDigest
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
} from "./index-4fpa9dy2.js";
|
|
38
38
|
import {
|
|
39
39
|
createToolInvoker
|
|
40
|
-
} from "./index-
|
|
40
|
+
} from "./index-7t0wq6j5.js";
|
|
41
41
|
import {
|
|
42
42
|
WaitTimeoutError,
|
|
43
43
|
createCli,
|
|
@@ -46,22 +46,22 @@ import {
|
|
|
46
46
|
fetchPinnedDocument,
|
|
47
47
|
readCapped,
|
|
48
48
|
runWaitOperation
|
|
49
|
-
} from "./index-
|
|
49
|
+
} from "./index-y47z614h.js";
|
|
50
50
|
import"./index-sbdmyz75.js";
|
|
51
51
|
import {
|
|
52
52
|
collectToolSurface
|
|
53
|
-
} from "./index-
|
|
53
|
+
} from "./index-kzxpsf8y.js";
|
|
54
54
|
import {
|
|
55
55
|
collectTools,
|
|
56
56
|
createToolRunner,
|
|
57
57
|
formatToolError
|
|
58
|
-
} from "./index-
|
|
58
|
+
} from "./index-32vjke6q.js";
|
|
59
59
|
import {
|
|
60
60
|
ToolExecutionControlError,
|
|
61
61
|
executeToolMethod,
|
|
62
62
|
isToolExecutionControlError,
|
|
63
63
|
toolResultFromError
|
|
64
|
-
} from "./index-
|
|
64
|
+
} from "./index-vcnfwrtr.js";
|
|
65
65
|
import {
|
|
66
66
|
getRequestContext,
|
|
67
67
|
getTraceId,
|
|
@@ -92,7 +92,7 @@ import"./index-kzfs85xp.js";
|
|
|
92
92
|
import {
|
|
93
93
|
createRuntimeToolFactory,
|
|
94
94
|
defineRuntimeTool
|
|
95
|
-
} from "./index-
|
|
95
|
+
} from "./index-8z9we758.js";
|
|
96
96
|
import {
|
|
97
97
|
PORTABLE_JSON_SCHEMA_FORMATS,
|
|
98
98
|
assertToolName,
|
|
@@ -103,7 +103,7 @@ import {
|
|
|
103
103
|
prepareProjectedMcpTools,
|
|
104
104
|
presentationMetadata,
|
|
105
105
|
validateMcpRoundPolicy
|
|
106
|
-
} from "./index-
|
|
106
|
+
} from "./index-fenaekmk.js";
|
|
107
107
|
import"./index-cby4ar3v.js";
|
|
108
108
|
import {
|
|
109
109
|
isRecord
|