@fitzzero/quickdraw-core 5.1.2 → 5.1.3
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/README.md +793 -57
- package/dist/{admin-DWWrT1h6.d.ts → admin-CS7JB_UH.d.ts} +2 -2
- package/dist/{adminSchemas-D4bFKsrb.d.ts → adminSchemas-29cGgrg5.d.ts} +1 -1
- package/dist/{auth-DXiSJZaf.d.ts → auth-DtdYjrZ9.d.ts} +11 -7
- package/dist/{caller-BT-Mv4bD.d.ts → caller-BTwGl7vm.d.ts} +183 -15
- package/dist/chunk-2FDSKLBO.js +82 -0
- package/dist/chunk-2FDSKLBO.js.map +1 -0
- package/dist/{chunk-GSIPUNJL.js → chunk-64I6MYBC.js} +139 -792
- package/dist/chunk-64I6MYBC.js.map +1 -0
- package/dist/chunk-7473HK24.js +17 -0
- package/dist/chunk-7473HK24.js.map +1 -0
- package/dist/chunk-7Y5ROPXL.js +33 -0
- package/dist/chunk-7Y5ROPXL.js.map +1 -0
- package/dist/chunk-A2RBQD66.js +7 -0
- package/dist/chunk-A2RBQD66.js.map +1 -0
- package/dist/chunk-ASAMUGHG.js +651 -0
- package/dist/chunk-ASAMUGHG.js.map +1 -0
- package/dist/{chunk-B2P7AZ25.js → chunk-CYE4UBOB.js} +6 -4
- package/dist/chunk-CYE4UBOB.js.map +1 -0
- package/dist/chunk-DNP65TD5.js +832 -0
- package/dist/chunk-DNP65TD5.js.map +1 -0
- package/dist/{chunk-5CGO426C.js → chunk-GYLWEJHW.js} +5 -1
- package/dist/chunk-GYLWEJHW.js.map +1 -0
- package/dist/{chunk-AONAFOYU.js → chunk-I3JCFS7H.js} +25 -13
- package/dist/chunk-I3JCFS7H.js.map +1 -0
- package/dist/{chunk-X5CWPX7H.js → chunk-IIQ3WMJK.js} +13 -2
- package/dist/chunk-IIQ3WMJK.js.map +1 -0
- package/dist/{chunk-6K5BY47X.js → chunk-JVTONQFI.js} +1277 -277
- package/dist/chunk-JVTONQFI.js.map +1 -0
- package/dist/{chunk-RL4VKLBX.js → chunk-KKQANRLG.js} +2 -2
- package/dist/{chunk-RL4VKLBX.js.map → chunk-KKQANRLG.js.map} +1 -1
- package/dist/{chunk-GKH3LJ7N.js → chunk-MPQAT55F.js} +38 -205
- package/dist/chunk-MPQAT55F.js.map +1 -0
- package/dist/chunk-NX2V6SIL.js +202 -0
- package/dist/chunk-NX2V6SIL.js.map +1 -0
- package/dist/{chunk-7QCUX4TK.js → chunk-NZHA4TZD.js} +72 -175
- package/dist/chunk-NZHA4TZD.js.map +1 -0
- package/dist/{chunk-MBH6IDSM.js → chunk-OCZJ4EYV.js} +40 -17
- package/dist/chunk-OCZJ4EYV.js.map +1 -0
- package/dist/{chunk-RJ5I2VO3.js → chunk-PHCURHC7.js} +6 -6
- package/dist/chunk-PHCURHC7.js.map +1 -0
- package/dist/{chunk-4YO5H5ON.js → chunk-Q4OGQM5I.js} +4 -10
- package/dist/chunk-Q4OGQM5I.js.map +1 -0
- package/dist/chunk-QSU47XEX.js +13 -0
- package/dist/chunk-QSU47XEX.js.map +1 -0
- package/dist/{chunk-LCC7HNFP.js → chunk-RZXJTDH5.js} +2 -2
- package/dist/{chunk-Z2LZ7IZ7.js → chunk-SN3OZVEQ.js} +5 -31
- package/dist/chunk-SN3OZVEQ.js.map +1 -0
- package/dist/{chunk-Z5ILULF2.js → chunk-SQ5VUG77.js} +4 -3
- package/dist/{chunk-Z5ILULF2.js.map → chunk-SQ5VUG77.js.map} +1 -1
- package/dist/chunk-STH5DLQP.js +1192 -0
- package/dist/chunk-STH5DLQP.js.map +1 -0
- package/dist/{chunk-NMXYENH4.js → chunk-VZFJTKIW.js} +6 -6
- package/dist/{chunk-753VJIUP.js → chunk-X4ZU4QH5.js} +43 -9
- package/dist/chunk-X4ZU4QH5.js.map +1 -0
- package/dist/chunk-XD7SRDUY.js +188 -0
- package/dist/chunk-XD7SRDUY.js.map +1 -0
- package/dist/chunk-Z7I6SONO.js +825 -0
- package/dist/chunk-Z7I6SONO.js.map +1 -0
- package/dist/cli/quickdraw-docs.js +131 -113
- package/dist/cli/quickdraw-docs.js.map +1 -1
- package/dist/client/core.d.ts +387 -0
- package/dist/client/core.js +109 -0
- package/dist/client/core.js.map +1 -0
- package/dist/client/index.d.ts +30 -193
- package/dist/client/index.js +56 -217
- package/dist/client/index.js.map +1 -1
- package/dist/{clientTypes-hWcPUVS9.d.ts → clientTypes-CUUNJwWs.d.ts} +3 -3
- package/dist/{connection-CgijdGpT.d.ts → connection-2EeQ_Et0.d.ts} +16 -9
- package/dist/{createServer-Cp-Wk500.d.ts → createServer-Bx5HOcYK.d.ts} +37 -9
- package/dist/{createTestApp-BB_PkqQ7.d.ts → createTestApp-DAMANT79.d.ts} +36 -9
- package/dist/{envelope-DzWyIXjj.d.ts → envelope-BMBaxppV.d.ts} +200 -8
- package/dist/{http-DotQ5bj8.d.ts → http-YzLAar3w.d.ts} +15 -50
- package/dist/index.d.ts +7 -6
- package/dist/index.js +61 -28
- package/dist/index.js.map +1 -1
- package/dist/{infer-BmoZsL9a.d.ts → infer-Br62cnyW.d.ts} +39 -1
- package/dist/{metrics-DW80Exve.d.ts → metrics-CTVpw0gu.d.ts} +2 -2
- package/dist/parser.js +2 -1
- package/dist/prisma/index.d.ts +13 -6
- package/dist/prisma/index.js +155 -9
- package/dist/prisma/index.js.map +1 -1
- package/dist/remote-N7OUAGOW.js +15 -0
- package/dist/remote-N7OUAGOW.js.map +1 -0
- package/dist/server/auth/index.d.ts +3 -3
- package/dist/server/auth/index.js +5 -3
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/index.d.ts +140 -36
- package/dist/server/index.js +162 -55
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp/index.d.ts +34 -18
- package/dist/server/mcp/index.js +29 -12
- package/dist/server/mcp/index.js.map +1 -1
- package/dist/server/otel.d.ts +3 -3
- package/dist/{sharing-UDLn1049.d.ts → sharing-BrsmlDv_.d.ts} +3 -3
- package/dist/testing/client.d.ts +13 -13
- package/dist/testing/client.js +17 -10
- package/dist/testing/client.js.map +1 -1
- package/dist/testing/index.d.ts +49 -12
- package/dist/testing/index.js +102 -19
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/mock.d.ts +5 -5
- package/dist/testing/mock.js +15 -9
- package/dist/tracked-BR5b2O-U.d.ts +43 -0
- package/dist/{types-CYliTP65.d.ts → types-CLRCQGnO.d.ts} +4 -3
- package/dist/types-tMagHbjy.d.ts +151 -0
- package/dist/utils/index.d.ts +16 -4
- package/dist/utils/index.js +6 -3
- package/package.json +5 -1
- package/dist/chunk-4YO5H5ON.js.map +0 -1
- package/dist/chunk-5CGO426C.js.map +0 -1
- package/dist/chunk-6K5BY47X.js.map +0 -1
- package/dist/chunk-753VJIUP.js.map +0 -1
- package/dist/chunk-7QCUX4TK.js.map +0 -1
- package/dist/chunk-AONAFOYU.js.map +0 -1
- package/dist/chunk-B2P7AZ25.js.map +0 -1
- package/dist/chunk-GKH3LJ7N.js.map +0 -1
- package/dist/chunk-GSIPUNJL.js.map +0 -1
- package/dist/chunk-MBH6IDSM.js.map +0 -1
- package/dist/chunk-RJ5I2VO3.js.map +0 -1
- package/dist/chunk-X5CWPX7H.js.map +0 -1
- package/dist/chunk-Z2LZ7IZ7.js.map +0 -1
- /package/dist/{chunk-LCC7HNFP.js.map → chunk-RZXJTDH5.js.map} +0 -0
- /package/dist/{chunk-NMXYENH4.js.map → chunk-VZFJTKIW.js.map} +0 -0
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { A as AnyService, d as Caller } from '../../caller-
|
|
1
|
+
import { A as AnyService, d as Caller } from '../../caller-BTwGl7vm.js';
|
|
2
2
|
import { IncomingHttpHeaders, IncomingMessage } from 'node:http';
|
|
3
|
-
import { ap as MethodName, d as StandardSchemaV1, c as InferOutput } from '../../infer-
|
|
3
|
+
import { ap as MethodName, d as StandardSchemaV1, c as InferOutput } from '../../infer-Br62cnyW.js';
|
|
4
4
|
import { Q as QuickdrawError, a as ErrorCode } from '../../errors-S-bxEIBC.js';
|
|
5
|
-
import { P as PrincipalOfServices, C as ContractOfServices, D as Dispatcher, H as HttpRouter } from '../../http-
|
|
6
|
-
import {
|
|
5
|
+
import { P as PrincipalOfServices, M as McpContextOfServices, C as ContractOfServices, D as Dispatcher, H as HttpRouter } from '../../http-YzLAar3w.js';
|
|
6
|
+
import { M as MaybePromise, P as Principal } from '../../types-CLRCQGnO.js';
|
|
7
7
|
import { L as Logger } from '../../logger-Yz93KzdV.js';
|
|
8
|
-
import { A as AuthenticateResult } from '../../auth-
|
|
8
|
+
import { A as AuthenticateResult } from '../../auth-DtdYjrZ9.js';
|
|
9
9
|
import { Readable, Writable } from 'node:stream';
|
|
10
10
|
import { A as AllowedOrigin } from '../../origins-kvpxnVcW.js';
|
|
11
|
-
import '../../envelope-
|
|
12
|
-
import '../../metrics-
|
|
11
|
+
import '../../envelope-BMBaxppV.js';
|
|
12
|
+
import '../../metrics-CTVpw0gu.js';
|
|
13
13
|
import 'socket.io';
|
|
14
14
|
|
|
15
15
|
/** The JSON Schema of a tool's arguments. MCP requires an object schema. */
|
|
@@ -72,8 +72,7 @@ interface McpHttpRequest {
|
|
|
72
72
|
}
|
|
73
73
|
/** The session or request a tool call arrives on, as the registry's `principal` and `context` see it. */
|
|
74
74
|
type McpRequest = McpStdioRequest | McpHttpRequest;
|
|
75
|
-
|
|
76
|
-
type McpContextOfServices<S extends readonly AnyService[]> = [S[number]] extends [never] ? McpContext : McpContextOf<NonNullable<S[number]["~types"]>>;
|
|
75
|
+
|
|
77
76
|
/** How a tool call ended: what the tool returned, or why it failed. */
|
|
78
77
|
type McpCallResult = {
|
|
79
78
|
readonly ok: true;
|
|
@@ -99,6 +98,18 @@ interface McpToolResult {
|
|
|
99
98
|
interface McpCallOptions {
|
|
100
99
|
/** The session or request the call arrived on. */
|
|
101
100
|
readonly request: McpRequest;
|
|
101
|
+
/**
|
|
102
|
+
* Who the call acts for, when the app signed the caller in itself (its own
|
|
103
|
+
* MCP transport over `callMethod`, an in-process assistant): the
|
|
104
|
+
* registry's `principal` hook is not asked. `null` calls anonymously, and
|
|
105
|
+
* so does `undefined`: the hook is asked only when the key is absent. The
|
|
106
|
+
* `context` hook, bound arguments and the call's concurrency lane see this
|
|
107
|
+
* principal. One that carries no `serviceAccess` gets the grants the
|
|
108
|
+
* server's `auth.loadServiceAccess` loads, at each call, as `qd.caller`
|
|
109
|
+
* gives them; one that carries grants (`{}` included) keeps them. An
|
|
110
|
+
* in-process option: the HTTP routes never read it from a request.
|
|
111
|
+
*/
|
|
112
|
+
readonly principal?: Principal | null;
|
|
102
113
|
/** Cancels the call. Only queries stop early; a mutation runs to its end. */
|
|
103
114
|
readonly signal?: AbortSignal;
|
|
104
115
|
/**
|
|
@@ -125,8 +136,9 @@ interface McpToolCall<S extends readonly AnyService[] = readonly AnyService[], A
|
|
|
125
136
|
*/
|
|
126
137
|
readonly arguments: Args;
|
|
127
138
|
/**
|
|
128
|
-
* Who the call acts for, from the registry's `principal
|
|
129
|
-
* an anonymous caller of a
|
|
139
|
+
* Who the call acts for, from the registry's `principal` hook or the
|
|
140
|
+
* call's own `principal` option. `null` only for an anonymous caller of a
|
|
141
|
+
* tool with `access: "public"`.
|
|
130
142
|
*/
|
|
131
143
|
readonly principal: PrincipalOfServices<S> | null;
|
|
132
144
|
/** The fields the registry's `context` produced for the call, if any. */
|
|
@@ -239,7 +251,9 @@ interface McpRegistryOptions<S extends readonly AnyService[], Tools extends read
|
|
|
239
251
|
* Without it every call is anonymous. An HTTP request's queries share the
|
|
240
252
|
* lane of its bearer token: a hook that authenticates by anything else (a
|
|
241
253
|
* cookie, an API key header) must refuse a request whose bearer token it
|
|
242
|
-
* does not verify, or a caller makes a lane per made-up token.
|
|
254
|
+
* does not verify, or a caller makes a lane per made-up token. A call
|
|
255
|
+
* whose options give `principal` (an app that signed the caller in
|
|
256
|
+
* itself) is not asked about.
|
|
243
257
|
*/
|
|
244
258
|
readonly principal?: (request: McpRequest) => MaybePromise<AuthenticateResult<PrincipalOfServices<S>>>;
|
|
245
259
|
/**
|
|
@@ -289,16 +303,18 @@ interface McpRegistry {
|
|
|
289
303
|
has(name: string): boolean;
|
|
290
304
|
/**
|
|
291
305
|
* Calls the tool `name` with the client's `args` in the session of
|
|
292
|
-
* `options.request
|
|
293
|
-
* unknown name is `NOT_FOUND`),
|
|
294
|
-
* Never rejects.
|
|
306
|
+
* `options.request`, as `options.principal` when it is given. Resolves
|
|
307
|
+
* with the tool's value or its failure (an unknown name is `NOT_FOUND`),
|
|
308
|
+
* after `options.respond` was given it. Never rejects.
|
|
295
309
|
*/
|
|
296
310
|
call(name: string, args: unknown, options: McpCallOptions): Promise<McpCallResult>;
|
|
297
311
|
/**
|
|
298
312
|
* Calls a method's tool by its service and method name with the method's
|
|
299
313
|
* `input` as it is, without the tool's argument mapping: the shape 4.1's
|
|
300
|
-
* HTTP route took. Bound arguments are filled as for `call
|
|
301
|
-
*
|
|
314
|
+
* HTTP route took. Bound arguments are filled as for `call`, and
|
|
315
|
+
* `options.principal` says who calls as for `call`: an app's own MCP
|
|
316
|
+
* transport over it passes the caller it signed in. A method that is not
|
|
317
|
+
* a tool is `NOT_FOUND`.
|
|
302
318
|
*/
|
|
303
319
|
callMethod(service: string, method: string, input: unknown, options: McpCallOptions): Promise<McpCallResult>;
|
|
304
320
|
}
|
|
@@ -452,4 +468,4 @@ type McpHttpReply = {
|
|
|
452
468
|
*/
|
|
453
469
|
declare function createMcpHttpRouter(options: McpHttpRouterOptions): HttpRouter;
|
|
454
470
|
|
|
455
|
-
export { type DescribeToolsOptions, MCP_PROTOCOL_VERSION, type McpBindCall, type McpBinder, type McpCallOptions, type McpCallResult,
|
|
471
|
+
export { type DescribeToolsOptions, MCP_PROTOCOL_VERSION, type McpBindCall, type McpBinder, type McpCallOptions, type McpCallResult, McpContextOfServices, type McpCustomTool, type McpHttpReply, type McpHttpRequest, type McpHttpRouterOptions, type McpInputSchema, type McpMethodRef, type McpRegistry, type McpRegistryOptions, type McpRequest, type McpStdioRequest, type McpStdioServer, type McpStdioServerOptions, type McpTextContent, type McpTool, type McpToolAccess, type McpToolAnnotations, type McpToolArguments, type McpToolCall, type McpToolInputSchema, type McpToolResult, bootstrapMcpServer, createMcpHttpRouter, createMcpRegistry, createMcpStdioServer, describeTools, toToolResult };
|
package/dist/server/mcp/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
} from "../../chunk-XNLWBZIG.js";
|
|
4
4
|
import {
|
|
5
5
|
NEVER_ABORTED,
|
|
6
|
+
callerGrantsOf,
|
|
6
7
|
checkKind,
|
|
7
8
|
inputKeys,
|
|
8
9
|
lazyMembers,
|
|
@@ -11,38 +12,42 @@ import {
|
|
|
11
12
|
pointerToken,
|
|
12
13
|
referenced,
|
|
13
14
|
runtimeOf,
|
|
14
|
-
toQuickdrawError
|
|
15
|
-
|
|
15
|
+
toQuickdrawError,
|
|
16
|
+
withCallerGrants
|
|
17
|
+
} from "../../chunk-OCZJ4EYV.js";
|
|
16
18
|
import {
|
|
17
19
|
describeError
|
|
18
|
-
} from "../../chunk-
|
|
20
|
+
} from "../../chunk-RZXJTDH5.js";
|
|
19
21
|
import {
|
|
20
22
|
originAllowlist
|
|
21
23
|
} from "../../chunk-NO4M6PO5.js";
|
|
22
24
|
import {
|
|
23
25
|
isForbiddenCredential,
|
|
24
26
|
isJsonRequest,
|
|
27
|
+
isPrincipal,
|
|
25
28
|
isRefusal,
|
|
26
29
|
readJsonInput,
|
|
27
30
|
toPrincipal,
|
|
28
31
|
unreadable
|
|
29
|
-
} from "../../chunk-
|
|
32
|
+
} from "../../chunk-PHCURHC7.js";
|
|
30
33
|
import "../../chunk-DUBU3BB3.js";
|
|
31
34
|
import "../../chunk-AK23XSWD.js";
|
|
35
|
+
import {
|
|
36
|
+
consoleLogger
|
|
37
|
+
} from "../../chunk-DKE6QO26.js";
|
|
32
38
|
import {
|
|
33
39
|
hasJsonSchema,
|
|
34
40
|
isStandardSchema
|
|
35
41
|
} from "../../chunk-47AEXVDM.js";
|
|
36
|
-
import "../../chunk-
|
|
37
|
-
import
|
|
38
|
-
consoleLogger
|
|
39
|
-
} from "../../chunk-DKE6QO26.js";
|
|
42
|
+
import "../../chunk-SN3OZVEQ.js";
|
|
43
|
+
import "../../chunk-7Y5ROPXL.js";
|
|
40
44
|
import {
|
|
41
45
|
INTERNAL_MESSAGE,
|
|
42
46
|
QuickdrawError,
|
|
43
47
|
httpStatus,
|
|
44
48
|
toWire
|
|
45
|
-
} from "../../chunk-
|
|
49
|
+
} from "../../chunk-Q4OGQM5I.js";
|
|
50
|
+
import "../../chunk-QSU47XEX.js";
|
|
46
51
|
|
|
47
52
|
// src/server/mcp/tools.ts
|
|
48
53
|
var JSON_SCHEMA_TARGET = "draft-07";
|
|
@@ -347,8 +352,20 @@ async function contextOf(settings, request, principal) {
|
|
|
347
352
|
}
|
|
348
353
|
return fields;
|
|
349
354
|
}
|
|
350
|
-
|
|
351
|
-
|
|
355
|
+
function givenPrincipal(principal) {
|
|
356
|
+
if (principal === null || principal === void 0) {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
if (!isPrincipal(principal)) {
|
|
360
|
+
throw new TypeError(
|
|
361
|
+
"An MCP call's principal must be a principal with a non-empty string userId, or null"
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
return principal;
|
|
365
|
+
}
|
|
366
|
+
async function openSession(settings, options) {
|
|
367
|
+
const { request } = options;
|
|
368
|
+
const principal = Object.hasOwn(options, "principal") ? await withCallerGrants(givenPrincipal(options.principal), callerGrantsOf(settings.dispatcher)) : await principalOf(settings, request);
|
|
352
369
|
const mcp = await contextOf(settings, request, principal);
|
|
353
370
|
return { principal, mcp, connectionId: laneOf(request, principal) };
|
|
354
371
|
}
|
|
@@ -617,7 +634,7 @@ function resolveRegistry(options) {
|
|
|
617
634
|
async function inSession(settings, name, options, run) {
|
|
618
635
|
let session;
|
|
619
636
|
try {
|
|
620
|
-
session = await openSession(settings, options
|
|
637
|
+
session = await openSession(settings, options);
|
|
621
638
|
} catch (error) {
|
|
622
639
|
return settle(settings, options, failure(settings, error, name));
|
|
623
640
|
}
|