stitchkit 0.90.4 → 0.90.6
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 +102 -0
- package/README.md +2 -0
- package/dist/agent-runtime-coding-tools.js +5 -4
- package/dist/agent-runtime-harness.js +6 -5
- package/dist/agent-runtime-sandbox.js +5 -4
- package/dist/agent-runtime.js +9 -8
- package/dist/application/grammy.d.ts.map +1 -1
- package/dist/application-grammy.js +4 -1
- package/dist/cli.js +62 -18
- package/dist/contract/index.js +2 -1
- package/dist/google.d.ts +56 -0
- package/dist/google.d.ts.map +1 -0
- package/dist/google.js +175 -0
- package/dist/{index-32vjke6q.js → index-1bnkzq95.js} +1 -1
- package/dist/{index-db51n3xr.js → index-640tz39q.js} +5 -5
- package/dist/{index-19ryv24q.js → index-83fafqw8.js} +3 -3
- package/dist/{index-z78bjcxj.js → index-aj9geeez.js} +1 -1
- package/dist/{index-bg8ypxzn.js → index-bva395we.js} +6 -7
- package/dist/{index-y47z614h.js → index-fqg5mfk7.js} +145 -32
- package/dist/index-hr4tzbwq.js +11 -0
- package/dist/{index-kazec06k.js → index-nrqg8tks.js} +5 -19
- package/dist/index-rxfy4cq7.js +17 -0
- package/dist/{index-6atvfjc1.js → index-s208wab5.js} +1 -1
- package/dist/{index-7t0wq6j5.js → index-tgh3ksfh.js} +5 -5
- package/dist/{index-6q3zjwaz.js → index-vy2nxwg8.js} +1 -1
- package/dist/{index-kzxpsf8y.js → index-zsdgd1tz.js} +1 -1
- package/dist/index.js +10 -9
- package/dist/internal/pkce.d.ts +3 -0
- package/dist/internal/pkce.d.ts.map +1 -0
- package/dist/node.js +5 -4
- package/dist/oauth.d.ts +57 -0
- package/dist/oauth.d.ts.map +1 -0
- package/dist/oauth.js +170 -0
- package/dist/observability/index.js +3 -2
- package/dist/primitives.js +2 -1
- package/dist/remote.js +4 -3
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/index.js +14 -11
- package/dist/server/middleware/pkce.d.ts +1 -2
- package/dist/server/middleware/pkce.d.ts.map +1 -1
- package/dist/testing.js +5 -4
- package/dist/tool-invoker.js +7 -6
- package/dist/tools/cli-args.d.ts +10 -8
- package/dist/tools/cli-args.d.ts.map +1 -1
- package/dist/tools/cli-installer.d.ts +7 -2
- package/dist/tools/cli-installer.d.ts.map +1 -1
- package/dist/tools/cli-view.d.ts.map +1 -1
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools/connections/index.js +37 -4
- 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.map +1 -1
- package/dist/tools.js +16 -14
- package/dist/tracking.js +3 -2
- package/llms-full.txt +224 -8
- package/llms.txt +1 -0
- package/package.json +36 -22
- package/dist/{index-8crm1srv.js → index-3yqgj323.js} +3 -3
- package/dist/{index-vcnfwrtr.js → index-8pjqv3zh.js} +6 -6
package/dist/oauth.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-safe OAuth Authorization Code + PKCE mechanics.
|
|
3
|
+
*
|
|
4
|
+
* The application owns navigation, token exchange, identity, persistence,
|
|
5
|
+
* sessions, roles and account policy. This module owns one pending browser
|
|
6
|
+
* transaction and consumes it exactly once.
|
|
7
|
+
*/
|
|
8
|
+
import type { z } from 'zod';
|
|
9
|
+
export type AuthorizationCodeClientErrorCode = 'INVALID_CONFIGURATION' | 'RESERVED_PARAMETER' | 'INVALID_CONTEXT' | 'STORAGE_FAILURE' | 'MISSING_TRANSACTION' | 'MALFORMED_TRANSACTION' | 'UNSUPPORTED_TRANSACTION_VERSION' | 'STATE_MISMATCH';
|
|
10
|
+
export declare class AuthorizationCodeClientError extends Error {
|
|
11
|
+
readonly code: AuthorizationCodeClientErrorCode;
|
|
12
|
+
constructor(code: AuthorizationCodeClientErrorCode, options?: ErrorOptions);
|
|
13
|
+
}
|
|
14
|
+
export interface AuthorizationCodeStorage {
|
|
15
|
+
getItem(key: string): string | null;
|
|
16
|
+
setItem(key: string, value: string): void;
|
|
17
|
+
removeItem(key: string): void;
|
|
18
|
+
}
|
|
19
|
+
export interface AuthorizationCodeCrypto {
|
|
20
|
+
getRandomValues(bytes: Uint8Array): Uint8Array;
|
|
21
|
+
subtle: Pick<SubtleCrypto, 'digest'>;
|
|
22
|
+
}
|
|
23
|
+
export interface AuthorizationCodeClientConfig<TContext> {
|
|
24
|
+
authorizationEndpoint: string;
|
|
25
|
+
clientId: string;
|
|
26
|
+
redirectUri: string;
|
|
27
|
+
scopes: readonly string[];
|
|
28
|
+
storage: AuthorizationCodeStorage;
|
|
29
|
+
storageKey: string;
|
|
30
|
+
contextSchema: z.ZodType<TContext>;
|
|
31
|
+
authorizationParameters?: Readonly<Record<string, string>>;
|
|
32
|
+
/** Web Crypto seam for deterministic tests. Defaults at call time, never module load. */
|
|
33
|
+
crypto?: AuthorizationCodeCrypto;
|
|
34
|
+
}
|
|
35
|
+
export interface BeginAuthorizationCodeInput<TContext> {
|
|
36
|
+
context: TContext;
|
|
37
|
+
}
|
|
38
|
+
export interface BeginAuthorizationCodeResult {
|
|
39
|
+
authorizationUrl: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ConsumeAuthorizationCodeInput {
|
|
42
|
+
state: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ConsumedAuthorizationCode<TContext> {
|
|
45
|
+
codeVerifier: string;
|
|
46
|
+
nonce: string;
|
|
47
|
+
redirectUri: string;
|
|
48
|
+
context: TContext;
|
|
49
|
+
}
|
|
50
|
+
export interface AuthorizationCodeClient<TContext> {
|
|
51
|
+
begin(input: BeginAuthorizationCodeInput<TContext>): Promise<BeginAuthorizationCodeResult>;
|
|
52
|
+
consume(input: ConsumeAuthorizationCodeInput): ConsumedAuthorizationCode<TContext>;
|
|
53
|
+
}
|
|
54
|
+
export declare function createAuthorizationCodeClient<TContext>(config: AuthorizationCodeClientConfig<TContext>): AuthorizationCodeClient<TContext>;
|
|
55
|
+
/** Keep a return target on the current origin, or use the caller's trusted fallback. */
|
|
56
|
+
export declare function safeInternalReturnPath(candidate: string | null | undefined, fallback: string): string;
|
|
57
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../src/oauth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAgB7B,MAAM,MAAM,gCAAgC,GACxC,uBAAuB,GACvB,oBAAoB,GACpB,iBAAiB,GACjB,iBAAiB,GACjB,qBAAqB,GACrB,uBAAuB,GACvB,iCAAiC,GACjC,gBAAgB,CAAC;AAarB,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,QAAQ,CAAC,IAAI,EAAE,gCAAgC,CAAC;IAEhD,YAAY,IAAI,EAAE,gCAAgC,EAAE,OAAO,CAAC,EAAE,YAAY,EAIzE;CACF;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU,CAAC;IAC/C,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,6BAA6B,CAAC,QAAQ;IACrD,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,OAAO,EAAE,wBAAwB,CAAC;IAClC,UA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url
|
|
6
|
+
} from "./index-rxfy4cq7.js";
|
|
7
|
+
|
|
8
|
+
// src/oauth.ts
|
|
9
|
+
var TRANSACTION_VERSION = 1;
|
|
10
|
+
var RESERVED_PARAMETERS = new Set([
|
|
11
|
+
"response_type",
|
|
12
|
+
"client_id",
|
|
13
|
+
"redirect_uri",
|
|
14
|
+
"scope",
|
|
15
|
+
"state",
|
|
16
|
+
"nonce",
|
|
17
|
+
"code_challenge",
|
|
18
|
+
"code_challenge_method"
|
|
19
|
+
]);
|
|
20
|
+
var ERROR_MESSAGES = {
|
|
21
|
+
INVALID_CONFIGURATION: "The OAuth client configuration is invalid.",
|
|
22
|
+
RESERVED_PARAMETER: "A provider parameter conflicts with the OAuth protocol.",
|
|
23
|
+
INVALID_CONTEXT: "The OAuth transaction context is invalid.",
|
|
24
|
+
STORAGE_FAILURE: "The OAuth transaction store is unavailable.",
|
|
25
|
+
MISSING_TRANSACTION: "The OAuth transaction is missing or was already consumed.",
|
|
26
|
+
MALFORMED_TRANSACTION: "The OAuth transaction is malformed.",
|
|
27
|
+
UNSUPPORTED_TRANSACTION_VERSION: "The OAuth transaction version is unsupported.",
|
|
28
|
+
STATE_MISMATCH: "The OAuth response state does not match the pending transaction."
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
class AuthorizationCodeClientError extends Error {
|
|
32
|
+
code;
|
|
33
|
+
constructor(code, options) {
|
|
34
|
+
super(ERROR_MESSAGES[code], options);
|
|
35
|
+
this.name = "AuthorizationCodeClientError";
|
|
36
|
+
this.code = code;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function recordOf(value) {
|
|
40
|
+
return typeof value === "object" && value !== null && !Array.isArray(value) ? Object.fromEntries(Object.entries(value)) : null;
|
|
41
|
+
}
|
|
42
|
+
function randomToken(crypto) {
|
|
43
|
+
return bytesToBase64Url(crypto.getRandomValues(new Uint8Array(32)));
|
|
44
|
+
}
|
|
45
|
+
function runtimeCrypto() {
|
|
46
|
+
const runtime = globalThis.crypto;
|
|
47
|
+
if (!runtime?.subtle || typeof runtime.getRandomValues !== "function") {
|
|
48
|
+
throw new AuthorizationCodeClientError("INVALID_CONFIGURATION");
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
getRandomValues: (bytes) => runtime.getRandomValues(bytes),
|
|
52
|
+
subtle: runtime.subtle
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function parseTransaction(raw, contextSchema) {
|
|
56
|
+
let decoded;
|
|
57
|
+
try {
|
|
58
|
+
decoded = JSON.parse(raw);
|
|
59
|
+
} catch {
|
|
60
|
+
throw new AuthorizationCodeClientError("MALFORMED_TRANSACTION");
|
|
61
|
+
}
|
|
62
|
+
const record = recordOf(decoded);
|
|
63
|
+
if (!record)
|
|
64
|
+
throw new AuthorizationCodeClientError("MALFORMED_TRANSACTION");
|
|
65
|
+
if (record.version !== TRANSACTION_VERSION) {
|
|
66
|
+
throw new AuthorizationCodeClientError("UNSUPPORTED_TRANSACTION_VERSION");
|
|
67
|
+
}
|
|
68
|
+
const context = contextSchema.safeParse(record.context);
|
|
69
|
+
if (!context.success)
|
|
70
|
+
throw new AuthorizationCodeClientError("INVALID_CONTEXT");
|
|
71
|
+
if (typeof record.state !== "string" || typeof record.nonce !== "string" || typeof record.codeVerifier !== "string" || typeof record.redirectUri !== "string") {
|
|
72
|
+
throw new AuthorizationCodeClientError("MALFORMED_TRANSACTION");
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
version: TRANSACTION_VERSION,
|
|
76
|
+
state: record.state,
|
|
77
|
+
nonce: record.nonce,
|
|
78
|
+
codeVerifier: record.codeVerifier,
|
|
79
|
+
redirectUri: record.redirectUri,
|
|
80
|
+
context: context.data
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function createAuthorizationCodeClient(config) {
|
|
84
|
+
if (!config.authorizationEndpoint || !config.clientId || !config.redirectUri || !config.storageKey || config.scopes.length === 0 || config.scopes.some((scope) => !scope)) {
|
|
85
|
+
throw new AuthorizationCodeClientError("INVALID_CONFIGURATION");
|
|
86
|
+
}
|
|
87
|
+
for (const parameter of Object.keys(config.authorizationParameters ?? {})) {
|
|
88
|
+
if (RESERVED_PARAMETERS.has(parameter)) {
|
|
89
|
+
throw new AuthorizationCodeClientError("RESERVED_PARAMETER");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
async begin({ context }) {
|
|
94
|
+
const parsedContext = config.contextSchema.safeParse(context);
|
|
95
|
+
if (!parsedContext.success)
|
|
96
|
+
throw new AuthorizationCodeClientError("INVALID_CONTEXT");
|
|
97
|
+
const crypto = config.crypto ?? runtimeCrypto();
|
|
98
|
+
const state = randomToken(crypto);
|
|
99
|
+
const nonce = randomToken(crypto);
|
|
100
|
+
const codeVerifier = randomToken(crypto);
|
|
101
|
+
const codeChallenge = await deriveCodeChallenge(codeVerifier, crypto.subtle);
|
|
102
|
+
let url;
|
|
103
|
+
try {
|
|
104
|
+
url = new URL(config.authorizationEndpoint);
|
|
105
|
+
} catch {
|
|
106
|
+
throw new AuthorizationCodeClientError("INVALID_CONFIGURATION");
|
|
107
|
+
}
|
|
108
|
+
for (const [name, value] of Object.entries(config.authorizationParameters ?? {})) {
|
|
109
|
+
url.searchParams.set(name, value);
|
|
110
|
+
}
|
|
111
|
+
url.searchParams.set("response_type", "code");
|
|
112
|
+
url.searchParams.set("client_id", config.clientId);
|
|
113
|
+
url.searchParams.set("redirect_uri", config.redirectUri);
|
|
114
|
+
url.searchParams.set("scope", config.scopes.join(" "));
|
|
115
|
+
url.searchParams.set("state", state);
|
|
116
|
+
url.searchParams.set("nonce", nonce);
|
|
117
|
+
url.searchParams.set("code_challenge", codeChallenge);
|
|
118
|
+
url.searchParams.set("code_challenge_method", "S256");
|
|
119
|
+
const transaction = {
|
|
120
|
+
version: TRANSACTION_VERSION,
|
|
121
|
+
state,
|
|
122
|
+
nonce,
|
|
123
|
+
codeVerifier,
|
|
124
|
+
redirectUri: config.redirectUri,
|
|
125
|
+
context: parsedContext.data
|
|
126
|
+
};
|
|
127
|
+
try {
|
|
128
|
+
config.storage.setItem(config.storageKey, JSON.stringify(transaction));
|
|
129
|
+
} catch {
|
|
130
|
+
throw new AuthorizationCodeClientError("STORAGE_FAILURE");
|
|
131
|
+
}
|
|
132
|
+
return { authorizationUrl: url.toString() };
|
|
133
|
+
},
|
|
134
|
+
consume({ state }) {
|
|
135
|
+
let raw;
|
|
136
|
+
try {
|
|
137
|
+
raw = config.storage.getItem(config.storageKey);
|
|
138
|
+
config.storage.removeItem(config.storageKey);
|
|
139
|
+
} catch {
|
|
140
|
+
throw new AuthorizationCodeClientError("STORAGE_FAILURE");
|
|
141
|
+
}
|
|
142
|
+
if (raw === null)
|
|
143
|
+
throw new AuthorizationCodeClientError("MISSING_TRANSACTION");
|
|
144
|
+
const transaction = parseTransaction(raw, config.contextSchema);
|
|
145
|
+
if (transaction.state !== state)
|
|
146
|
+
throw new AuthorizationCodeClientError("STATE_MISMATCH");
|
|
147
|
+
return {
|
|
148
|
+
codeVerifier: transaction.codeVerifier,
|
|
149
|
+
nonce: transaction.nonce,
|
|
150
|
+
redirectUri: transaction.redirectUri,
|
|
151
|
+
context: transaction.context
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function safeInternalReturnPath(candidate, fallback) {
|
|
157
|
+
const hasAsciiControl = [...candidate ?? ""].some((character) => {
|
|
158
|
+
const code = character.charCodeAt(0);
|
|
159
|
+
return code <= 31 || code === 127;
|
|
160
|
+
});
|
|
161
|
+
if (!candidate?.startsWith("/") || candidate.startsWith("//") || candidate.includes("\\") || hasAsciiControl) {
|
|
162
|
+
return fallback;
|
|
163
|
+
}
|
|
164
|
+
return candidate;
|
|
165
|
+
}
|
|
166
|
+
export {
|
|
167
|
+
safeInternalReturnPath,
|
|
168
|
+
createAuthorizationCodeClient,
|
|
169
|
+
AuthorizationCodeClientError
|
|
170
|
+
};
|
|
@@ -28,9 +28,9 @@ import"../index-f9mb610r.js";
|
|
|
28
28
|
import {
|
|
29
29
|
recordedErrorMessage
|
|
30
30
|
} from "../index-2hryh65w.js";
|
|
31
|
-
import"../index-
|
|
31
|
+
import"../index-nrqg8tks.js";
|
|
32
|
+
import"../index-rxfy4cq7.js";
|
|
32
33
|
import"../index-6k1937bx.js";
|
|
33
|
-
import"../index-scs3f1eg.js";
|
|
34
34
|
import {
|
|
35
35
|
childSpan,
|
|
36
36
|
createTraceContext,
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
resolvePropagationContext,
|
|
40
40
|
resolveTraceContext
|
|
41
41
|
} from "../index-zcgf3gqf.js";
|
|
42
|
+
import"../index-scs3f1eg.js";
|
|
42
43
|
import"../index-kzfs85xp.js";
|
|
43
44
|
import {
|
|
44
45
|
isRecord
|
package/dist/primitives.js
CHANGED
package/dist/remote.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createClient
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-vy2nxwg8.js";
|
|
4
4
|
import"./index-1txvygak.js";
|
|
5
5
|
import {
|
|
6
6
|
ApiError
|
|
@@ -9,12 +9,13 @@ import"./index-2hryh65w.js";
|
|
|
9
9
|
import {
|
|
10
10
|
mergeMeta,
|
|
11
11
|
resolveRouteParamsSchema
|
|
12
|
-
} from "./index-
|
|
12
|
+
} from "./index-nrqg8tks.js";
|
|
13
|
+
import"./index-rxfy4cq7.js";
|
|
13
14
|
import"./index-6k1937bx.js";
|
|
15
|
+
import"./index-zcgf3gqf.js";
|
|
14
16
|
import {
|
|
15
17
|
AppError
|
|
16
18
|
} from "./index-scs3f1eg.js";
|
|
17
|
-
import"./index-zcgf3gqf.js";
|
|
18
19
|
import"./index-kzfs85xp.js";
|
|
19
20
|
import {
|
|
20
21
|
isRecord
|
package/dist/server/bun.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bun.d.ts","source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js";
|
|
17
17
|
import"../index-y91ry9h2.js";
|
|
18
18
|
import {
|
|
19
19
|
withDeadline
|
|
@@ -37,7 +37,6 @@ import {
|
|
|
37
37
|
createAuthHook,
|
|
38
38
|
createBearerResolver,
|
|
39
39
|
defineCookie,
|
|
40
|
-
deriveCodeChallenge,
|
|
41
40
|
extractToken,
|
|
42
41
|
parseCookieHeader,
|
|
43
42
|
parseCookies,
|
|
@@ -45,7 +44,10 @@ import {
|
|
|
45
44
|
signJwt,
|
|
46
45
|
verifyJwt,
|
|
47
46
|
verifyPkce
|
|
48
|
-
} from "../index-
|
|
47
|
+
} from "../index-bva395we.js";
|
|
48
|
+
import {
|
|
49
|
+
deriveCodeChallenge
|
|
50
|
+
} from "../index-hr4tzbwq.js";
|
|
49
51
|
import {
|
|
50
52
|
DEFAULT_CORS_ALLOW_HEADERS,
|
|
51
53
|
DEFAULT_CORS_EXPOSE_HEADERS,
|
|
@@ -59,7 +61,7 @@ import {
|
|
|
59
61
|
defineMultipartStream,
|
|
60
62
|
implement,
|
|
61
63
|
implementRegistry
|
|
62
|
-
} from "../index-
|
|
64
|
+
} from "../index-aj9geeez.js";
|
|
63
65
|
import {
|
|
64
66
|
isWithinDir,
|
|
65
67
|
realPathWithinDir
|
|
@@ -85,8 +87,14 @@ import {
|
|
|
85
87
|
DEFAULT_CONTRACT_STREAM_FRAME_BYTES,
|
|
86
88
|
joinRoutePath,
|
|
87
89
|
parseTrailingWildcard
|
|
88
|
-
} from "../index-
|
|
90
|
+
} from "../index-nrqg8tks.js";
|
|
91
|
+
import"../index-rxfy4cq7.js";
|
|
89
92
|
import"../index-6k1937bx.js";
|
|
93
|
+
import"../index-zcgf3gqf.js";
|
|
94
|
+
import {
|
|
95
|
+
jsonSchemaFields,
|
|
96
|
+
toJsonSchema
|
|
97
|
+
} from "../index-cby4ar3v.js";
|
|
90
98
|
import {
|
|
91
99
|
AppError,
|
|
92
100
|
STITCH_ERROR_STATUS,
|
|
@@ -99,12 +107,7 @@ import {
|
|
|
99
107
|
rateLimited,
|
|
100
108
|
unauthorized
|
|
101
109
|
} from "../index-scs3f1eg.js";
|
|
102
|
-
import"../index-zcgf3gqf.js";
|
|
103
110
|
import"../index-kzfs85xp.js";
|
|
104
|
-
import {
|
|
105
|
-
jsonSchemaFields,
|
|
106
|
-
toJsonSchema
|
|
107
|
-
} from "../index-cby4ar3v.js";
|
|
108
111
|
import {
|
|
109
112
|
isRecord
|
|
110
113
|
} from "../index-77fekveh.js";
|
|
@@ -491,7 +494,7 @@ function createServer(config) {
|
|
|
491
494
|
};
|
|
492
495
|
if (unixPath !== undefined) {
|
|
493
496
|
reclaimStaleUnixSocket(unixPath);
|
|
494
|
-
const { reusePort, ipv6Only, http3, http1, idleTimeout, ...unixExtra } = bunExtra ?? {};
|
|
497
|
+
const { reusePort, ipv6Only, http3, http2, http1, idleTimeout, ...unixExtra } = bunExtra ?? {};
|
|
495
498
|
runtime = trackedWebSocket ? Bun.serve({
|
|
496
499
|
...unixExtra,
|
|
497
500
|
...development && { development },
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
+
export { deriveCodeChallenge } from '../../internal/pkce.js';
|
|
1
2
|
/** The only PKCE method OAuth 2.1 permits for public clients. */
|
|
2
3
|
export type PkceMethod = 'S256';
|
|
3
|
-
/** Derive the S256 `code_challenge` from a `code_verifier`. */
|
|
4
|
-
export declare function deriveCodeChallenge(verifier: string): Promise<string>;
|
|
5
4
|
/**
|
|
6
5
|
* Verify a `code_verifier` against the stored S256 `code_challenge`. S256 is the
|
|
7
6
|
* only method OAuth 2.1 permits for public clients — `plain` is intentionally
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../../src/server/middleware/pkce.ts"],"names":[],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"pkce.d.ts","sourceRoot":"","sources":["../../../src/server/middleware/pkce.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,iEAAiE;AACjE,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC;AAEhC;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAItF"}
|
package/dist/testing.js
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
import {
|
|
29
29
|
createClient,
|
|
30
30
|
createClients
|
|
31
|
-
} from "./index-
|
|
31
|
+
} from "./index-vy2nxwg8.js";
|
|
32
32
|
import {
|
|
33
33
|
RealtimeRequestDisconnectedError,
|
|
34
34
|
RealtimeRequestInvalidAcknowledgementError,
|
|
@@ -39,11 +39,10 @@ import"./index-3xwxfj4z.js";
|
|
|
39
39
|
import"./index-2hryh65w.js";
|
|
40
40
|
import {
|
|
41
41
|
joinRoutePath
|
|
42
|
-
} from "./index-
|
|
42
|
+
} from "./index-nrqg8tks.js";
|
|
43
|
+
import"./index-rxfy4cq7.js";
|
|
43
44
|
import"./index-6k1937bx.js";
|
|
44
|
-
import"./index-scs3f1eg.js";
|
|
45
45
|
import"./index-zcgf3gqf.js";
|
|
46
|
-
import"./index-kzfs85xp.js";
|
|
47
46
|
import {
|
|
48
47
|
mcpProjectionCandidate,
|
|
49
48
|
prepareProjectedMcpTools,
|
|
@@ -52,6 +51,8 @@ import {
|
|
|
52
51
|
import {
|
|
53
52
|
toJsonSchema
|
|
54
53
|
} from "./index-cby4ar3v.js";
|
|
54
|
+
import"./index-scs3f1eg.js";
|
|
55
|
+
import"./index-kzfs85xp.js";
|
|
55
56
|
import {
|
|
56
57
|
isRecord
|
|
57
58
|
} from "./index-77fekveh.js";
|
package/dist/tool-invoker.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
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
|
-
import"./index-
|
|
9
|
+
import"./index-nrqg8tks.js";
|
|
10
|
+
import"./index-rxfy4cq7.js";
|
|
10
11
|
import"./index-6k1937bx.js";
|
|
11
|
-
import"./index-scs3f1eg.js";
|
|
12
12
|
import"./index-zcgf3gqf.js";
|
|
13
13
|
import"./index-7zbps32p.js";
|
|
14
|
-
import"./index-kzfs85xp.js";
|
|
15
14
|
import"./index-fenaekmk.js";
|
|
16
15
|
import"./index-cby4ar3v.js";
|
|
16
|
+
import"./index-scs3f1eg.js";
|
|
17
|
+
import"./index-kzfs85xp.js";
|
|
17
18
|
import"./index-77fekveh.js";
|
|
18
19
|
export {
|
|
19
20
|
createToolInvoker
|
package/dist/tools/cli-args.d.ts
CHANGED
|
@@ -35,8 +35,11 @@ export type CliResultView = {
|
|
|
35
35
|
by?: string;
|
|
36
36
|
top?: number;
|
|
37
37
|
} | {
|
|
38
|
-
kind: '
|
|
39
|
-
|
|
38
|
+
kind: 'records';
|
|
39
|
+
sort?: string;
|
|
40
|
+
ascending?: boolean;
|
|
41
|
+
top?: number;
|
|
42
|
+
table?: readonly string[];
|
|
40
43
|
};
|
|
41
44
|
/** CLI-behaviour flags, parsed out of argv before the tool arguments. */
|
|
42
45
|
export interface CliRunOptions {
|
|
@@ -68,6 +71,8 @@ export interface CliArgvRoute {
|
|
|
68
71
|
commandArgv: string[];
|
|
69
72
|
topLevelHelp: boolean;
|
|
70
73
|
version: boolean;
|
|
74
|
+
/** `--help <substring>` — narrow the command list instead of printing it whole. */
|
|
75
|
+
helpFilter?: string;
|
|
71
76
|
error?: string;
|
|
72
77
|
}
|
|
73
78
|
type FieldKind = 'boolean' | 'number' | 'bigint' | 'date' | 'string' | 'enum' | 'array' | 'object' | 'other';
|
|
@@ -77,12 +82,6 @@ interface FieldInfo {
|
|
|
77
82
|
elementKind?: FieldKind;
|
|
78
83
|
}
|
|
79
84
|
export declare const RESERVED_CLI_OPTIONS: Set<string>;
|
|
80
|
-
/**
|
|
81
|
-
* Select a command without duplicating the framework-global option grammar.
|
|
82
|
-
* With no default configured this returns the historical first-token routing
|
|
83
|
-
* byte-for-byte. With a default, recognised leading globals may precede an
|
|
84
|
-
* explicit command; a remaining option token belongs to the default command.
|
|
85
|
-
*/
|
|
86
85
|
export declare function routeCliArgv(argv: string[], defaultCommand?: string): CliArgvRoute;
|
|
87
86
|
export declare class CliArgumentError extends Error {
|
|
88
87
|
name: string;
|
|
@@ -94,6 +93,9 @@ export declare class CliArgumentError extends Error {
|
|
|
94
93
|
* scalar schema yields an empty map and every value is left as a string.
|
|
95
94
|
*/
|
|
96
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;
|
|
97
99
|
/**
|
|
98
100
|
* Parse a command's argv slice (everything after the command name) against its
|
|
99
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;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GACrB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAC9C;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE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C,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,GACL,aAAa,CAwOf;AAED,iFAAiF;AACjF,MAAM,WAAW,qBAAqB;IACpC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,wEAAwE;IACxE,OAAO,EAAE,MAAM,CAAC,MAAM,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"}
|
|
@@ -10,8 +10,13 @@
|
|
|
10
10
|
import type { CliBuildAsset, CliBuildManifest } from './cli-manifest.js';
|
|
11
11
|
export interface CliInstallerConfig {
|
|
12
12
|
manifest: CliBuildManifest;
|
|
13
|
-
/**
|
|
14
|
-
|
|
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;
|
|
15
20
|
/** The name the binary takes on the PATH; defaults to the manifest name. */
|
|
16
21
|
binaryName?: string;
|
|
17
22
|
/** Default install directory; overridable by `INSTALL_DIR` at run time. */
|
|
@@ -1 +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
|
|
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"}
|
|
@@ -1 +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;
|
|
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,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,EAAE,GACjB,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,SAAS,KAAK,SAAS,MAAM,EAAE,CAAC,CAAC;AAE9D,MAAM,WAAW,SAAS,CACxB,KAAK,GAAG,OAAO,EACf,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,QAAQ,SAA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4ar3v.js";
|
|
9
|
+
import {
|
|
10
|
+
AppError
|
|
11
|
+
} from "../../index-scs3f1eg.js";
|
|
12
|
+
import {
|
|
13
|
+
safeJsonParse
|
|
14
|
+
} from "../../index-kzfs85xp.js";
|
|
9
15
|
import {
|
|
10
16
|
isRecord
|
|
11
17
|
} from "../../index-77fekveh.js";
|
|
@@ -514,6 +520,34 @@ class McpHttpClient {
|
|
|
514
520
|
}
|
|
515
521
|
}
|
|
516
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
|
+
|
|
517
551
|
// src/tools/connections/runtime.ts
|
|
518
552
|
import { z } from "zod";
|
|
519
553
|
async function withConnectionToken(params, body) {
|
|
@@ -608,10 +642,9 @@ async function mountMcpConnection(connection, instanceId, onSkipped) {
|
|
|
608
642
|
return withConnectionToken({ instanceId, provider: connection.token, client, context }, async (token) => {
|
|
609
643
|
await client.initialize(token, context.signal);
|
|
610
644
|
const result = await client.request("tools/call", { name, arguments: context.input }, token, context.signal);
|
|
611
|
-
if (isRecord(result) && result.isError === true)
|
|
612
|
-
throw
|
|
613
|
-
|
|
614
|
-
return result;
|
|
645
|
+
if (isRecord(result) && result.isError === true)
|
|
646
|
+
throw mcpToolFailure(name, result);
|
|
647
|
+
return context.source === "cli" ? unwrapMcpResult(result) : result;
|
|
615
648
|
}).finally(() => client.teardown());
|
|
616
649
|
}
|
|
617
650
|
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a discovered MCP tool's answer is, per transport.
|
|
3
|
+
*
|
|
4
|
+
* `tools/call` returns an envelope — `{ content: [...], structuredContent? }` —
|
|
5
|
+
* and an agent mount needs exactly that: the parts are what a model is shown.
|
|
6
|
+
* The CLI transport is different in kind, because the handler's value is what
|
|
7
|
+
* gets printed, piped and aggregated. Handed the envelope, `--count-by status`
|
|
8
|
+
* groups the *parts* and answers `no record carries the field "status" —
|
|
9
|
+
* available: text, type`, and `--json` emits the answer as a JSON string nested
|
|
10
|
+
* inside `content[0].text`, so every consumer unwraps before anything works.
|
|
11
|
+
*
|
|
12
|
+
* So the CLI unwraps, and only the CLI. The order is the server's own order of
|
|
13
|
+
* preference: `structuredContent` is the answer when the server sent one; a lone
|
|
14
|
+
* text part is the answer when it parses as JSON, and its text when it does not.
|
|
15
|
+
* Anything else — several parts, an image, audio — is passed through whole,
|
|
16
|
+
* because picking one part out of many would be inventing an answer.
|
|
17
|
+
*/
|
|
18
|
+
import { AppError } from '../../contract/errors.js';
|
|
19
|
+
export declare function unwrapMcpResult(result: unknown): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* The class a relayed failure carries when the server sent no structured body.
|
|
22
|
+
*
|
|
23
|
+
* Not `INTERNAL_SERVER_ERROR`: nothing of ours broke. The honest statement is
|
|
24
|
+
* that the call failed upstream and we cannot say more than the server did.
|
|
25
|
+
*/
|
|
26
|
+
export declare const UPSTREAM_TOOL_ERROR = "UPSTREAM_TOOL_ERROR";
|
|
27
|
+
/**
|
|
28
|
+
* Turn a failed `CallToolResult` into the error the caller can act on.
|
|
29
|
+
*
|
|
30
|
+
* The line this replaces threw a one-sentence `Error` and discarded the result,
|
|
31
|
+
* which cost three things at once: the code (so `exitCodes` had nothing to map
|
|
32
|
+
* and every remote failure exited `1`), the message the operator needed, and the
|
|
33
|
+
* error's own class — a plain `Error` is an *unexpected* error to the runner, so
|
|
34
|
+
* it printed a code frame of the framework bundle before the JSON failure and
|
|
35
|
+
* was then scrubbed to a bare `INTERNAL_SERVER_ERROR`.
|
|
36
|
+
*
|
|
37
|
+
* A structured `{ error, details }` body is the remote contract's own refusal
|
|
38
|
+
* and is relayed as one. Anything else keeps the framework's sentence and
|
|
39
|
+
* carries what the server did send — reporting less than we have is not caution.
|
|
40
|
+
* The status is 502 either way: whatever the code says, the failure happened
|
|
41
|
+
* upstream, and a consumer re-serving it over HTTP should say so.
|
|
42
|
+
*/
|
|
43
|
+
export declare function mcpToolFailure(toolName: string, result: unknown): AppError;
|
|
44
|
+
//# sourceMappingURL=mcp-envelope.d.ts.map
|