stitchkit 0.90.2 → 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 +129 -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-8dph3pw6.js → index-y47z614h.js} +405 -35
- package/dist/testing.js +1 -1
- package/dist/tool-invoker.js +4 -4
- package/dist/tools/cli-args.d.ts +49 -0
- package/dist/tools/cli-args.d.ts.map +1 -1
- package/dist/tools/cli-command.d.ts +8 -1
- package/dist/tools/cli-command.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-policy.d.ts +6 -1
- package/dist/tools/cli-policy.d.ts.map +1 -1
- 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 +20 -5
- 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 +293 -7
- package/package.json +1 -1
package/dist/tool-invoker.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToolInvoker
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
3
|
+
} from "./index-7t0wq6j5.js";
|
|
4
|
+
import"./index-32vjke6q.js";
|
|
5
|
+
import"./index-vcnfwrtr.js";
|
|
6
6
|
import"./index-vsbzgd7b.js";
|
|
7
7
|
import"./index-f9mb610r.js";
|
|
8
8
|
import"./index-2hryh65w.js";
|
|
@@ -12,7 +12,7 @@ import"./index-scs3f1eg.js";
|
|
|
12
12
|
import"./index-zcgf3gqf.js";
|
|
13
13
|
import"./index-7zbps32p.js";
|
|
14
14
|
import"./index-kzfs85xp.js";
|
|
15
|
-
import"./index-
|
|
15
|
+
import"./index-fenaekmk.js";
|
|
16
16
|
import"./index-cby4ar3v.js";
|
|
17
17
|
import"./index-77fekveh.js";
|
|
18
18
|
export {
|
package/dist/tools/cli-args.d.ts
CHANGED
|
@@ -18,6 +18,26 @@
|
|
|
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: 'table';
|
|
39
|
+
fields: readonly string[];
|
|
40
|
+
};
|
|
21
41
|
/** CLI-behaviour flags, parsed out of argv before the tool arguments. */
|
|
22
42
|
export interface CliRunOptions {
|
|
23
43
|
/** `--json` — emit compact success/error JSON records for scripts. */
|
|
@@ -34,6 +54,8 @@ export interface CliRunOptions {
|
|
|
34
54
|
dryRun: boolean;
|
|
35
55
|
/** `--help` / `-h` — print usage for the command. */
|
|
36
56
|
help: boolean;
|
|
57
|
+
/** `--count-by` / `--sum` / `--top` / `--table` — aggregate instead of the collection. */
|
|
58
|
+
view?: CliResultView;
|
|
37
59
|
}
|
|
38
60
|
export interface ParsedCliArgs {
|
|
39
61
|
/** The flat tool-argument object handed to `executeToolMethod`. */
|
|
@@ -88,5 +110,32 @@ export declare function parseCliArgs(argv: string[], schema: z.ZodType | undefin
|
|
|
88
110
|
optionAliases?: ReadonlyMap<string, string>;
|
|
89
111
|
positionals?: readonly string[];
|
|
90
112
|
}): ParsedCliArgs;
|
|
113
|
+
/** The application's own global options, lifted out of one invocation's argv. */
|
|
114
|
+
export interface CliGlobalOptionsParse {
|
|
115
|
+
/** argv with the application-global tokens removed, ready for routing. */
|
|
116
|
+
argv: string[];
|
|
117
|
+
/** The validated values, as the application's own schema types them. */
|
|
118
|
+
globals: Record<string, unknown>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Lift the APPLICATION's global options out of argv, wherever they stand.
|
|
122
|
+
*
|
|
123
|
+
* These are not arguments of any operation: which identity key to use, which
|
|
124
|
+
* checkout a call speaks for, which profile. They belong to the invocation, so
|
|
125
|
+
* they may precede the command name as easily as follow it — and a command's
|
|
126
|
+
* own parser must never see them, or an app-global would read as an unknown
|
|
127
|
+
* flag on every operation that does not declare it.
|
|
128
|
+
*
|
|
129
|
+
* Stripping them BEFORE routing is what keeps this one grammar rather than two:
|
|
130
|
+
* `routeCliArgv` then sees a command where a command is, `parseCliArgs` sees
|
|
131
|
+
* only operation arguments, and `passthrough` cannot swallow an app-global into
|
|
132
|
+
* a freeform bag. The token shape is the same `classifyLongOptionToken` the
|
|
133
|
+
* framework's own globals use, so `--root /x`, `--root=/x` and a bare boolean
|
|
134
|
+
* `--verbose` all behave as they do everywhere else.
|
|
135
|
+
*
|
|
136
|
+
* `--` ends the sweep: past it every token is a literal value, so a positional
|
|
137
|
+
* that happens to read as `--root` survives intact.
|
|
138
|
+
*/
|
|
139
|
+
export declare function extractCliGlobalOptions(argv: readonly string[], schema: z.ZodObject | undefined): CliGlobalOptionsParse;
|
|
91
140
|
export {};
|
|
92
141
|
//# sourceMappingURL=cli-args.d.ts.map
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"cli-args.d.ts","sourceRoot":"","sources":["../../src/tools/cli-args.ts"],"names":[],"mappings":"AAAA;;;;;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AAS,GAAG,SAAS,GAC9B,qBAAqB,CA8CvB"}
|
|
@@ -5,6 +5,13 @@ import { type ToolResult } from './execute.js';
|
|
|
5
5
|
export interface CliCommandContext<TInput extends ZodObject> extends CliWriters {
|
|
6
6
|
input: z.output<TInput>;
|
|
7
7
|
options: Readonly<CliRunOptions>;
|
|
8
|
+
/**
|
|
9
|
+
* The application's own global options for this invocation, already validated
|
|
10
|
+
* against `CliConfig.globalOptions`. Empty when the CLI declares none. Typed
|
|
11
|
+
* loosely because a command is defined independently of the CLI it is mounted
|
|
12
|
+
* on — read it through the same schema the application declared.
|
|
13
|
+
*/
|
|
14
|
+
globals: Readonly<Record<string, unknown>>;
|
|
8
15
|
}
|
|
9
16
|
export interface CliCommandDefinitionBase<TInput extends ZodObject> {
|
|
10
17
|
name: string;
|
|
@@ -41,5 +48,5 @@ export interface PreparedCliCommandEmission {
|
|
|
41
48
|
export declare function prepareCliCommandEmission(definition: CliCommandDefinition, result: ToolResult, options: Readonly<CliRunOptions>): PreparedCliCommandEmission;
|
|
42
49
|
export declare function cliCommandPresentationSchema(definition: CliCommandDefinition): Record<string, unknown>;
|
|
43
50
|
/** Execute a CLI-only definition without inventing a tool operation identity. */
|
|
44
|
-
export declare function executeCliCommand(definition: CliCommandDefinition, rawArgs: Record<string, unknown>, options: CliRunOptions, writers: CliWriters, coerceJson: boolean): Promise<ToolResult>;
|
|
51
|
+
export declare function executeCliCommand(definition: CliCommandDefinition, rawArgs: Record<string, unknown>, options: CliRunOptions, writers: CliWriters, coerceJson: boolean, globals?: Readonly<Record<string, unknown>>): Promise<ToolResult>;
|
|
45
52
|
//# sourceMappingURL=cli-command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-command.d.ts","sourceRoot":"","sources":["../../src/tools/cli-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEjD,OAAO,KAAK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7C,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,UAAU,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,+EAA+E;AAC/E,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,oBAAoB,EAChC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,GAC/B,0BAA0B,CAwB5B;AAED,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,oBAAoB,GAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKzB;AAED,iFAAiF;AACjF,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,oBAAoB,EAChC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,OAAO,EACnB,OAAO,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,GAC9C,OAAO,CAAC,UAAU,CAAC,CAoCrB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
/** The asset this script installs — one script per target. */
|
|
14
|
+
asset: CliBuildAsset;
|
|
15
|
+
/** The name the binary takes on the PATH; defaults to the manifest name. */
|
|
16
|
+
binaryName?: string;
|
|
17
|
+
/** Default install directory; overridable by `INSTALL_DIR` at run time. */
|
|
18
|
+
installDir?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Render the installer for one asset.
|
|
22
|
+
*
|
|
23
|
+
* The three properties that matter, in the script rather than in a comment:
|
|
24
|
+
* no JSON parsing, the digest is checked against the **decompressed** bytes, and
|
|
25
|
+
* the final step is a rename — an interrupted download leaves a temporary file,
|
|
26
|
+
* never a half-written executable on someone's PATH.
|
|
27
|
+
*/
|
|
28
|
+
export declare function renderCliInstaller(config: CliInstallerConfig): string;
|
|
29
|
+
//# 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,8DAA8D;IAC9D,KAAK,EAAE,aAAa,CAAC;IACrB,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,CAuErE"}
|
|
@@ -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"}
|
|
@@ -13,7 +13,12 @@ export interface CliCommandPresentation {
|
|
|
13
13
|
presentationSchema: Record<string, unknown>;
|
|
14
14
|
/** Canonical field name → one short alias. */
|
|
15
15
|
aliases: ReadonlyMap<string, string>;
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* `undefined` retains automatic non-boolean schema order. A trailing ARRAY
|
|
18
|
+
* field is variadic — it takes every remaining token. An array declared
|
|
19
|
+
* anywhere else keeps taking exactly one (a JSON-array token), and command
|
|
20
|
+
* help says which is which: only the variadic tail renders as `<name...>`.
|
|
21
|
+
*/
|
|
17
22
|
positionals?: readonly string[];
|
|
18
23
|
}
|
|
19
24
|
export declare function applyCliPresentationPolicy(command: string, descriptor: Omit<CliCommandPresentation, 'aliases' | 'positionals'>, config: CliPresentationPolicyConfig): CliCommandPresentation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-policy.d.ts","sourceRoot":"","sources":["../../src/tools/cli-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,WAAW,2BAA2B;IAC1C,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,6FAA6F;IAC7F,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,8CAA8C;IAC9C,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC
|
|
1
|
+
{"version":3,"file":"cli-policy.d.ts","sourceRoot":"","sources":["../../src/tools/cli-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAGlD,MAAM,WAAW,2BAA2B;IAC1C,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3E,6FAA6F;IAC7F,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,8CAA8C;IAC9C,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACrC;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAkFD,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,IAAI,CAAC,sBAAsB,EAAE,SAAS,GAAG,aAAa,CAAC,EACnE,MAAM,EAAE,2BAA2B,GAClC,sBAAsB,CAexB;AAED,wFAAwF;AACxF,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAAC,EACrD,MAAM,EAAE,2BAA2B,GAClC,IAAI,CAWN"}
|
|
@@ -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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E,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,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
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
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ZodObject, z } from 'zod';
|
|
1
2
|
import type { ServiceDef, StitchLogger } from '../server/types.js';
|
|
2
3
|
import { type CliCommandDefinition } from './cli-command.js';
|
|
3
4
|
import { type ExitCodeMap } from './cli-format.js';
|
|
@@ -6,7 +7,7 @@ import { type CliWaitConfig } from './cli-wait.js';
|
|
|
6
7
|
import { type ErrorHintFn, type ToolCallHooks, type ToolLifecycle } from './execute.js';
|
|
7
8
|
import type { RuntimeToolDefinition } from './runtime-tool.js';
|
|
8
9
|
export type CliSurfaceSource<TAuth, TValue> = readonly TValue[] | ((auth: Awaited<TAuth> | undefined) => readonly TValue[]);
|
|
9
|
-
export interface CliConfig<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown
|
|
10
|
+
export interface CliConfig<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>, TGlobals extends ZodObject = ZodObject> extends CliPresentationPolicyConfig {
|
|
10
11
|
/** Program name — shown in help and unknown-command messages. */
|
|
11
12
|
name: string;
|
|
12
13
|
/** Program version — printed by `--version`. */
|
|
@@ -23,13 +24,27 @@ export interface CliConfig<TAuth = unknown, TContext extends Record<string, unkn
|
|
|
23
24
|
* promise of one.
|
|
24
25
|
*/
|
|
25
26
|
auth?: TAuth | Promise<TAuth>;
|
|
26
|
-
/**
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Lazily resolve identity only when a managed command/surface actually needs
|
|
29
|
+
* it. Receives the application's global options, so `--caller <key>` can
|
|
30
|
+
* select WHICH identity this invocation speaks as.
|
|
31
|
+
*/
|
|
32
|
+
resolveAuth?: (globals: z.output<TGlobals>) => TAuth | Promise<TAuth>;
|
|
33
|
+
/**
|
|
34
|
+
* The application's OWN global options — invocation context that belongs to
|
|
35
|
+
* no single operation: which identity key, which checkout, which profile.
|
|
36
|
+
* Declared as a Zod object of optional fields; `createCli` lifts these flags
|
|
37
|
+
* out of argv wherever they stand (before or after the command name),
|
|
38
|
+
* validates them against this schema and keeps them out of every operation's
|
|
39
|
+
* arguments. A name that collides with a framework option or with a field of
|
|
40
|
+
* any command is a startup error, never silent shadowing.
|
|
41
|
+
*/
|
|
42
|
+
globalOptions?: TGlobals;
|
|
28
43
|
/**
|
|
29
44
|
* Context merged into every handler. Typed against the app's context shape
|
|
30
45
|
* when the CLI is built via `createToolkit<AppContext>()`.
|
|
31
46
|
*/
|
|
32
|
-
context?: (auth: Awaited<TAuth> | undefined) => TContext;
|
|
47
|
+
context?: (auth: Awaited<TAuth> | undefined, globals: z.output<TGlobals>) => TContext;
|
|
33
48
|
/** Explicit cancellation for this invocation; applications may bind SIGINT to it. */
|
|
34
49
|
signal?: AbortSignal;
|
|
35
50
|
/** Tool-call observability hooks — `afterToolCall` fires for every result,
|
|
@@ -87,5 +102,5 @@ export interface CliConfig<TAuth = unknown, TContext extends Record<string, unkn
|
|
|
87
102
|
stdin?: () => Promise<string | null>;
|
|
88
103
|
}
|
|
89
104
|
/** Build and run one mixed contract/runtime/native CLI surface, then exit. */
|
|
90
|
-
export declare function createCli<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown
|
|
105
|
+
export declare function createCli<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>, TGlobals extends ZodObject = ZodObject>(config: CliConfig<TAuth, TContext, TGlobals>): Promise<void>;
|
|
91
106
|
//# sourceMappingURL=cli.d.ts.map
|
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":"
|
|
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,KAAK,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC/D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAInB,MAAM,WAAW,CAAC;AAKnB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAI5D,MAAM,MAAM,gBAAgB,CAAC,KAAK,EAAE,MAAM,IACtC,SAAS,MAAM,E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AAE,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;
|