stitchkit 0.41.0 → 0.42.0
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/dist/cli.js +2 -2
- package/dist/contract/errors-factory.d.ts +88 -15
- package/dist/contract/errors-factory.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -4
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +2 -2
- package/dist/{index-xax049k6.js → index-11x5dts2.js} +44 -13
- package/dist/{index-4e1c0hsw.js → index-181aebw8.js} +1 -1
- package/dist/{index-dnkefke9.js → index-310bfer5.js} +1 -1
- package/dist/{index-sc67e454.js → index-gex6gxhe.js} +7 -4
- package/dist/{index-ncqqn1bc.js → index-p9vkwns1.js} +2 -2
- package/dist/{index-809wc1tt.js → index-s4qsmgwe.js} +4 -1
- package/dist/index.js +2 -2
- package/dist/internal/typed.d.ts +8 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/node.js +2 -2
- package/dist/observability/index.js +1 -1
- package/dist/react.js +1 -1
- package/dist/server/error-hook.d.ts +8 -4
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/index.js +7 -6
- package/dist/tools/agent.d.ts +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +8 -6
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +13 -5
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp-handler.d.ts +5 -4
- package/dist/tools/mcp-handler.d.ts.map +1 -1
- package/dist/tools/mcp-stdio.d.ts +3 -2
- package/dist/tools/mcp-stdio.d.ts.map +1 -1
- package/dist/tools/mcp.d.ts +49 -9
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/native-mcp.d.ts +4 -18
- package/dist/tools/native-mcp.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +1 -1
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/surface.d.ts +37 -0
- package/dist/tools/surface.d.ts.map +1 -0
- package/dist/tools/toolkit.d.ts +4 -4
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transports.d.ts +11 -9
- package/dist/tools/transports.d.ts.map +1 -1
- package/dist/tools/view-file.d.ts +3 -3
- package/dist/tools.d.ts +5 -5
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +292 -155
- package/llms-full.txt +264 -47
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
emitResult,
|
|
5
5
|
parseCliArgs,
|
|
6
6
|
pollUntilDone
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-p9vkwns1.js";
|
|
8
8
|
import"./index-frfyw9fa.js";
|
|
9
9
|
import"./index-x3fcszf8.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-gex6gxhe.js";
|
|
11
11
|
export {
|
|
12
12
|
pollUntilDone,
|
|
13
13
|
parseCliArgs,
|
|
@@ -1,18 +1,91 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Declare an application's domain errors once. Each definition owns its HTTP
|
|
3
|
+
* status and optional Zod schema for structured details; generated factories
|
|
4
|
+
* construct (but do not throw) branded `AppError` instances.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* export const appErrors = defineErrors({
|
|
8
|
+
* SESSION_NOT_FOUND: { status: 404 },
|
|
9
|
+
* QUOTA_EXCEEDED: {
|
|
10
|
+
* status: 429,
|
|
11
|
+
* details: z.object({ retryAfterSeconds: z.number().int().positive() }),
|
|
12
|
+
* },
|
|
13
|
+
* })
|
|
14
|
+
*
|
|
15
|
+
* throw appErrors.errors.SESSION_NOT_FOUND({ message: 'No such session' })
|
|
16
|
+
* throw appErrors.errors.QUOTA_EXCEEDED({
|
|
17
|
+
* details: { retryAfterSeconds: 30 },
|
|
18
|
+
* hint: 'Wait for the current window to expire',
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
import { AppError } from './errors';
|
|
24
|
+
/** Supported structured-details schemas: a required or optional Zod object. */
|
|
25
|
+
export type ErrorDetailsSchema = z.ZodObject | z.ZodOptional<z.ZodObject>;
|
|
26
|
+
/** One domain error definition. Omitting `details` forbids structured details. */
|
|
27
|
+
export type ErrorDefinition = {
|
|
28
|
+
readonly status: number;
|
|
29
|
+
readonly details?: never;
|
|
30
|
+
} | {
|
|
31
|
+
readonly status: number;
|
|
32
|
+
readonly details: ErrorDetailsSchema;
|
|
33
|
+
};
|
|
34
|
+
export type ErrorDefinitions = Record<string, ErrorDefinition>;
|
|
35
|
+
/** Parsed details retained by the constructed `AppError`. */
|
|
36
|
+
export type ErrorDetailsOutput<TDefinition extends ErrorDefinition> = TDefinition extends {
|
|
37
|
+
details: infer TSchema extends ErrorDetailsSchema;
|
|
38
|
+
} ? Extract<z.output<TSchema>, Record<string, unknown> | undefined> : undefined;
|
|
39
|
+
/** AppError instance with required details refined when its schema is required. */
|
|
40
|
+
export type DefinedAppError<TCode extends string, TDefinition extends ErrorDefinition> = AppError<TCode, ErrorDetailsOutput<TDefinition>> & (TDefinition extends {
|
|
41
|
+
details: infer TSchema extends ErrorDetailsSchema;
|
|
42
|
+
} ? undefined extends z.output<TSchema> ? object : {
|
|
43
|
+
readonly details: ErrorDetailsOutput<TDefinition>;
|
|
44
|
+
} : object);
|
|
45
|
+
/**
|
|
46
|
+
* Factory arguments inferred from the definition: details are forbidden,
|
|
47
|
+
* required or optional according to the declared schema.
|
|
48
|
+
*/
|
|
49
|
+
export type ErrorFactoryArguments<TDefinition extends ErrorDefinition> = TDefinition extends {
|
|
50
|
+
details: infer TSchema extends ErrorDetailsSchema;
|
|
51
|
+
} ? undefined extends z.input<TSchema> ? [
|
|
52
|
+
options?: {
|
|
53
|
+
message?: string;
|
|
54
|
+
details?: Exclude<z.input<TSchema>, undefined>;
|
|
55
|
+
hint?: string;
|
|
56
|
+
}
|
|
57
|
+
] : [
|
|
58
|
+
options: {
|
|
59
|
+
message?: string;
|
|
60
|
+
details: z.input<TSchema>;
|
|
61
|
+
hint?: string;
|
|
62
|
+
}
|
|
63
|
+
] : [options?: {
|
|
64
|
+
message?: string;
|
|
65
|
+
details?: never;
|
|
66
|
+
hint?: string;
|
|
67
|
+
}];
|
|
68
|
+
/** Typed constructor for one declared domain error code. */
|
|
69
|
+
export type ErrorFactory<TCode extends string, TDefinition extends ErrorDefinition> = (...args: ErrorFactoryArguments<TDefinition>) => DefinedAppError<TCode, TDefinition>;
|
|
70
|
+
export type ErrorFactories<TDefinitions extends ErrorDefinitions> = {
|
|
71
|
+
readonly [TCode in keyof TDefinitions]: ErrorFactory<TCode & string, TDefinitions[TCode]>;
|
|
72
|
+
};
|
|
73
|
+
export type FrozenErrorDefinitions<TDefinitions extends ErrorDefinitions> = {
|
|
74
|
+
readonly [TCode in keyof TDefinitions]: Readonly<TDefinitions[TCode]>;
|
|
75
|
+
};
|
|
76
|
+
/** The immutable handle returned by `defineErrors`. */
|
|
77
|
+
export interface DefinedErrors<TDefinitions extends ErrorDefinitions> {
|
|
78
|
+
/** One typed `AppError` constructor per code. The caller chooses when to throw. */
|
|
79
|
+
readonly errors: ErrorFactories<TDefinitions>;
|
|
80
|
+
/** Code literals for client-side matching without magic strings. */
|
|
81
|
+
readonly codes: {
|
|
82
|
+
readonly [TCode in keyof TDefinitions]: TCode & string;
|
|
8
83
|
};
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** Type guard — is `code` one of this app's declared codes? */
|
|
14
|
-
isCode: (code: string) => code is keyof TDef & string;
|
|
84
|
+
/** Read-only definitions; status and details schemas remain one source of truth. */
|
|
85
|
+
readonly definitions: FrozenErrorDefinitions<TDefinitions>;
|
|
86
|
+
/** Type guard — is `code` one of this application's declared codes? */
|
|
87
|
+
readonly isCode: (code: string) => code is Extract<keyof TDefinitions, string>;
|
|
15
88
|
}
|
|
16
|
-
/** Declare
|
|
17
|
-
export declare function defineErrors<const
|
|
89
|
+
/** Declare an immutable, Zod-first domain error vocabulary. */
|
|
90
|
+
export declare function defineErrors<const TDefinitions extends ErrorDefinitions>(source: TDefinitions): DefinedErrors<TDefinitions>;
|
|
18
91
|
//# sourceMappingURL=errors-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-factory.d.ts","sourceRoot":"","sources":["../../src/contract/errors-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors-factory.d.ts","sourceRoot":"","sources":["../../src/contract/errors-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAE1E,kFAAkF;AAClF,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE/D,6DAA6D;AAC7D,MAAM,MAAM,kBAAkB,CAAC,WAAW,SAAS,eAAe,IAAI,WAAW,SAAS;IACxF,OAA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"}
|
|
@@ -21,12 +21,12 @@ export interface ErrorEnvelope {
|
|
|
21
21
|
* structured `details` and a `hint`. `toJSON()` renders the public error
|
|
22
22
|
* envelope. Throw it directly, or via the typed helpers below.
|
|
23
23
|
*/
|
|
24
|
-
export declare class AppError extends Error {
|
|
25
|
-
readonly code:
|
|
24
|
+
export declare class AppError<TCode extends string = string, TDetails extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> extends Error {
|
|
25
|
+
readonly code: TCode;
|
|
26
26
|
readonly status: number;
|
|
27
|
-
readonly details?:
|
|
27
|
+
readonly details?: TDetails | undefined;
|
|
28
28
|
readonly hint?: string | undefined;
|
|
29
|
-
constructor(code:
|
|
29
|
+
constructor(code: TCode, message?: string, status?: number, details?: TDetails | undefined, hint?: string | undefined);
|
|
30
30
|
static is(err: unknown): err is AppError;
|
|
31
31
|
toJSON(): ErrorEnvelope;
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/contract/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,8BAA8B;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gCAAgC;QAChC,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,0BAA0B;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAcD;;;;GAIG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/contract/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,8BAA8B;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gCAAgC;QAChC,OAAO,CAAC,EA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AAK,CAEhE;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;CAUE,CAAC;AAEnC,mFAAmF;AACnF,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAE/D,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAEvE;AAED,+FAA+F;AAC/F,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,KAAK,CAOP"}
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ALL_TRANSPORTS, type BodyHttpSuccessStatus, type ContractDef, type ContractMeta, defineContract, type EndpointDef, type EndpointFn, type EndpointResponseMeta, type EndpointToolAnnotations, type EndpointUiMeta, type FileDescriptor, type HandlerContext, type HeadEndpointDef, type HttpMethod, type HttpSuccessStatus, type MultipartFile, type ResponseMetadata, type RuntimeContext, type ScopedEndpointFn, type ScopedHttpClient, type ScopedUrlBuilder, type ScopedUrlFn, type Transport, type TransportSource, type TypedClient, type TypedHttpClient, type TypedUrlBuilder, } from './define';
|
|
2
2
|
export { AppError, appError, badRequest, conflict, type ErrorEnvelope, forbidden, isStitchErrorCode, notFound, rateLimited, STITCH_ERROR_STATUS, type StitchErrorCode, unauthorized, } from './errors';
|
|
3
|
-
export { type DefinedErrors, defineErrors, type
|
|
3
|
+
export { type DefinedAppError, type DefinedErrors, defineErrors, type ErrorDefinition, type ErrorDefinitions, type ErrorDetailsOutput, type ErrorDetailsSchema, type ErrorFactories, type ErrorFactory, type ErrorFactoryArguments, type FrozenErrorDefinitions, } from './errors-factory';
|
|
4
4
|
export { createContractFactory, type ScopedDefineContract } from './factory';
|
|
5
5
|
export { decodeCursor, encodeCursor, type Paginated, paginatedSchema, } from './pagination';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,KAAK,aAAa,EAClB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,KAAK,aAAa,EAClB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAE7E,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,SAAS,EACd,eAAe,GAChB,MAAM,cAAc,CAAC"}
|
package/dist/contract/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
2
|
+
mapObjectTypeBoundary
|
|
3
|
+
} from "./index-s4qsmgwe.js";
|
|
4
4
|
|
|
5
5
|
// src/contract/define.ts
|
|
6
6
|
import { z } from "zod";
|
|
@@ -237,17 +237,48 @@ function appError(code, message, details) {
|
|
|
237
237
|
throw new AppError(code, message, isStitchErrorCode(code) ? STITCH_ERROR_STATUS[code] : 500, details);
|
|
238
238
|
}
|
|
239
239
|
// src/contract/errors-factory.ts
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
import { z as z2 } from "zod";
|
|
241
|
+
function isErrorDetailsSchema(value) {
|
|
242
|
+
return value instanceof z2.ZodObject || value instanceof z2.ZodOptional && value.unwrap() instanceof z2.ZodObject;
|
|
243
|
+
}
|
|
244
|
+
function validateDefinition(code, definition) {
|
|
245
|
+
if (!Number.isInteger(definition.status) || definition.status < 400 || definition.status > 599) {
|
|
246
|
+
throw new Error(`[stitchkit] Error "${code}" must declare an integer HTTP status from 400 to 599`);
|
|
247
|
+
}
|
|
248
|
+
if (definition.details !== undefined && !isErrorDetailsSchema(definition.details)) {
|
|
249
|
+
throw new Error(`[stitchkit] Error "${code}" details must be a Zod object or optional Zod object`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function defineErrors(source) {
|
|
253
|
+
const definitions = mapObjectTypeBoundary(source, (code, definition) => {
|
|
254
|
+
const name = String(code);
|
|
255
|
+
validateDefinition(name, definition);
|
|
256
|
+
return Object.freeze({ ...definition });
|
|
243
257
|
});
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
258
|
+
Object.freeze(definitions);
|
|
259
|
+
const errors = mapObjectTypeBoundary(definitions, (code, definition) => {
|
|
260
|
+
const name = String(code);
|
|
261
|
+
return (options = {}) => {
|
|
262
|
+
if (definition.details === undefined) {
|
|
263
|
+
if ("details" in options) {
|
|
264
|
+
throw new Error(`[stitchkit] Error "${name}" does not declare details`);
|
|
265
|
+
}
|
|
266
|
+
return new AppError(name, options.message, definition.status, undefined, options.hint);
|
|
267
|
+
}
|
|
268
|
+
const details = definition.details.parse(options.details);
|
|
269
|
+
return new AppError(name, options.message, definition.status, details, options.hint);
|
|
270
|
+
};
|
|
271
|
+
});
|
|
272
|
+
Object.freeze(errors);
|
|
273
|
+
const codes = mapObjectTypeBoundary(definitions, (code) => String(code));
|
|
274
|
+
Object.freeze(codes);
|
|
275
|
+
const known = new Set(Object.keys(definitions));
|
|
276
|
+
return Object.freeze({
|
|
247
277
|
errors,
|
|
248
278
|
codes,
|
|
279
|
+
definitions,
|
|
249
280
|
isCode: (code) => known.has(code)
|
|
250
|
-
};
|
|
281
|
+
});
|
|
251
282
|
}
|
|
252
283
|
// src/contract/factory.ts
|
|
253
284
|
function createContractFactory() {
|
|
@@ -262,7 +293,7 @@ function createContractFactory() {
|
|
|
262
293
|
};
|
|
263
294
|
}
|
|
264
295
|
// src/contract/pagination.ts
|
|
265
|
-
import { z as
|
|
296
|
+
import { z as z3 } from "zod";
|
|
266
297
|
|
|
267
298
|
// src/internal/base64url.ts
|
|
268
299
|
function bytesToBase64Url(bytes) {
|
|
@@ -282,9 +313,9 @@ function base64UrlToBytes(segment) {
|
|
|
282
313
|
|
|
283
314
|
// src/contract/pagination.ts
|
|
284
315
|
function paginatedSchema(itemSchema) {
|
|
285
|
-
return
|
|
286
|
-
items:
|
|
287
|
-
nextCursor:
|
|
316
|
+
return z3.object({
|
|
317
|
+
items: z3.array(itemSchema),
|
|
318
|
+
nextCursor: z3.string().nullable()
|
|
288
319
|
});
|
|
289
320
|
}
|
|
290
321
|
function toBase64Url(str) {
|
|
@@ -121,6 +121,9 @@ function mergeMeta(contractMeta, endpointMeta) {
|
|
|
121
121
|
return { ...contractMeta };
|
|
122
122
|
return { ...contractMeta, ...endpointMeta };
|
|
123
123
|
}
|
|
124
|
+
// src/contract/errors-factory.ts
|
|
125
|
+
import { z as z2 } from "zod";
|
|
126
|
+
|
|
124
127
|
// src/internal/typed.ts
|
|
125
128
|
function typedEntries(value) {
|
|
126
129
|
return Object.entries(value);
|
|
@@ -129,7 +132,7 @@ function isRecord(value) {
|
|
|
129
132
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
130
133
|
}
|
|
131
134
|
// src/contract/pagination.ts
|
|
132
|
-
import { z as
|
|
135
|
+
import { z as z3 } from "zod";
|
|
133
136
|
|
|
134
137
|
// src/internal/base64url.ts
|
|
135
138
|
function bytesToBase64Url(bytes) {
|
|
@@ -147,7 +150,7 @@ function base64UrlToBytes(segment) {
|
|
|
147
150
|
return Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
|
|
148
151
|
}
|
|
149
152
|
// src/internal/errors.ts
|
|
150
|
-
import { z as
|
|
153
|
+
import { z as z4 } from "zod";
|
|
151
154
|
function issuePath(path) {
|
|
152
155
|
return path.length > 0 ? path.map(String).join(".") : "(root)";
|
|
153
156
|
}
|
|
@@ -170,7 +173,7 @@ var MAX_DETAIL_ISSUES = 20;
|
|
|
170
173
|
function errorCode(err) {
|
|
171
174
|
if (AppError.is(err))
|
|
172
175
|
return err.code;
|
|
173
|
-
if (err instanceof
|
|
176
|
+
if (err instanceof z4.ZodError)
|
|
174
177
|
return "VALIDATION_ERROR";
|
|
175
178
|
return;
|
|
176
179
|
}
|
|
@@ -186,7 +189,7 @@ function recordedErrorMessage(code, envelopeMessage, thrown) {
|
|
|
186
189
|
function normalizeError(err) {
|
|
187
190
|
if (AppError.is(err))
|
|
188
191
|
return err;
|
|
189
|
-
if (err instanceof
|
|
192
|
+
if (err instanceof z4.ZodError) {
|
|
190
193
|
return new AppError("VALIDATION_ERROR", formatZodError(err), 400, {
|
|
191
194
|
issues: zodIssues(err).slice(0, MAX_DETAIL_ISSUES)
|
|
192
195
|
});
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
runWithRequestContext,
|
|
18
18
|
safeJsonParse,
|
|
19
19
|
validateDeclaredOutput
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-gex6gxhe.js";
|
|
21
21
|
|
|
22
22
|
// src/tools/coerce.ts
|
|
23
23
|
import { z } from "zod";
|
|
@@ -717,7 +717,7 @@ function toToolName(serviceName, methodName) {
|
|
|
717
717
|
}
|
|
718
718
|
function assertUniqueToolName(name, taken, surface) {
|
|
719
719
|
if (taken) {
|
|
720
|
-
throw new Error(`Duplicate ${surface} "${name}" across mounted
|
|
720
|
+
throw new Error(`Duplicate ${surface} "${name}" across mounted operations`);
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
723
|
|
|
@@ -14,5 +14,8 @@ function mapObject(source, mapper) {
|
|
|
14
14
|
}
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
|
+
function mapObjectTypeBoundary(source, mapper) {
|
|
18
|
+
return mapObject(source, (key, value) => mapper(key, value));
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
export { typedEntries, isRecord, mapObject };
|
|
21
|
+
export { typedEntries, isRecord, mapObject, mapObjectTypeBoundary };
|
package/dist/index.js
CHANGED
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
parseTrailingWildcard,
|
|
18
18
|
rateLimited,
|
|
19
19
|
unauthorized
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-11x5dts2.js";
|
|
21
21
|
import {
|
|
22
22
|
isRecord,
|
|
23
23
|
mapObject,
|
|
24
24
|
typedEntries
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-s4qsmgwe.js";
|
|
26
26
|
|
|
27
27
|
// src/browser/client-multipart.ts
|
|
28
28
|
function isFileDescriptor(value) {
|
package/dist/internal/typed.d.ts
CHANGED
|
@@ -6,4 +6,12 @@ export declare function isRecord(value: unknown): value is Record<string, unknow
|
|
|
6
6
|
export declare function mapObject<TSource extends object, TResult extends {
|
|
7
7
|
[K in keyof TSource]?: unknown;
|
|
8
8
|
}>(source: TSource, mapper: <K extends keyof TSource>(key: K, value: TSource[K]) => TResult[K] | undefined): TResult;
|
|
9
|
+
/**
|
|
10
|
+
* Dynamic key-wise factory bridge. Use when runtime construction preserves a
|
|
11
|
+
* mapped type's key/value relation but TypeScript cannot express the dependent
|
|
12
|
+
* callback return. The assertion is intentionally isolated at this boundary.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mapObjectTypeBoundary<TSource extends object, TResult extends {
|
|
15
|
+
[K in keyof TSource]?: unknown;
|
|
16
|
+
}>(source: TSource, mapper: (key: keyof TSource, value: TSource[keyof TSource]) => unknown): TResult;
|
|
9
17
|
//# sourceMappingURL=typed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/internal/typed.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,KAAK,EAAE,CAAC,GACP,KAAK,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAE/C;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,SAAS,CACvB,OAAO,SAAS,MAAM,EACtB,OAAO,SAAS;KAAG,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,EAAE,OAAO;CAAE,EAElD,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,GACrF,OAAO,CAOT"}
|
|
1
|
+
{"version":3,"file":"typed.d.ts","sourceRoot":"","sources":["../../src/internal/typed.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAC3C,KAAK,EAAE,CAAC,GACP,KAAK,CAAC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAE/C;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED,wBAAgB,SAAS,CACvB,OAAO,SAAS,MAAM,EACtB,OAAO,SAAS;KAAG,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,EAAE,OAAO;CAAE,EAElD,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,SAAS,GACrF,OAAO,CAOT;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,SAAS,MAAM,EACtB,OAAO,SAAS;KAAG,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,EAAE,OAAO;CAAE,EAElD,MAAM,EAAE,OAAO,EACf,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,OAAO,CAAC,KAAK,OAAO,GACrE,OAAO,CAKT"}
|
package/dist/node.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
createImplement,
|
|
4
4
|
createSocketIOServer,
|
|
5
5
|
implement
|
|
6
|
-
} from "./index-
|
|
6
|
+
} from "./index-181aebw8.js";
|
|
7
7
|
import"./index-6jypn22c.js";
|
|
8
8
|
import"./index-x3fcszf8.js";
|
|
9
9
|
import {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
notFound,
|
|
16
16
|
rateLimited,
|
|
17
17
|
unauthorized
|
|
18
|
-
} from "./index-
|
|
18
|
+
} from "./index-gex6gxhe.js";
|
|
19
19
|
// src/server/node.ts
|
|
20
20
|
import { serve } from "srvx";
|
|
21
21
|
async function serveNode(config) {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
setRequestError,
|
|
17
17
|
setRequestUser,
|
|
18
18
|
wrapInRequestContext
|
|
19
|
-
} from "../index-
|
|
19
|
+
} from "../index-gex6gxhe.js";
|
|
20
20
|
|
|
21
21
|
// src/observability/sanitize.ts
|
|
22
22
|
var DEFAULT_SENSITIVE_KEYS = /(password|passwd|pwd|secret|token|apikey|api[-_ ]?key|auth|authorization|bearer|session|cookie|init[-_ ]?data|credential|private[-_ ]?key)/i;
|
package/dist/react.js
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import type { RuntimeContext } from '../contract';
|
|
35
35
|
import { type StitchErrorCode } from '../contract';
|
|
36
|
-
import type { LifecycleHooks } from './types';
|
|
36
|
+
import type { LifecycleHooks, MethodDef } from './types';
|
|
37
37
|
/** The normalised error handed to `render` — code already remapped. */
|
|
38
38
|
export interface ResolvedError {
|
|
39
39
|
/** Wire code — the app code from `codeMap` for a stitch error, else the thrown code. */
|
|
@@ -62,9 +62,13 @@ export interface ErrorHookConfig<TWireCode extends string = string> {
|
|
|
62
62
|
* in the envelope, which is the ordinary reason to have one. Declaring the
|
|
63
63
|
* parameter is optional: a one-argument `render` stays assignable.
|
|
64
64
|
*/
|
|
65
|
-
render: (info: ResolvedError, ctx: RuntimeContext) => unknown
|
|
66
|
-
/**
|
|
67
|
-
|
|
65
|
+
render: (info: ResolvedError, ctx: RuntimeContext, endpoint?: MethodDef) => unknown | Promise<unknown>;
|
|
66
|
+
/**
|
|
67
|
+
* Observe the raw thrown value before rendering — logging, metrics or
|
|
68
|
+
* asynchronous request attribution. The matched endpoint is absent for
|
|
69
|
+
* failures that happen before the router resolves an operation.
|
|
70
|
+
*/
|
|
71
|
+
onError?: (error: unknown, info: ResolvedError, ctx: RuntimeContext, endpoint?: MethodDef) => unknown | Promise<unknown>;
|
|
68
72
|
}
|
|
69
73
|
/** Build an `onError` hook from a code map + envelope renderer. */
|
|
70
74
|
export declare function createErrorHook<TWireCode extends string = string>(config: ErrorHookConfig<TWireCode>): NonNullable<LifecycleHooks['onError']>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-hook.d.ts","sourceRoot":"","sources":["../../src/server/error-hook.ts"],"names":[],"mappings":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d,IAAI,EAAE,aAAa,EACnB,GAAG,EAAE,cAAc,EACnB,QAAQ,CAAC,EAAE,SAAS,KACjB,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC;AAED,mEAAmE;AACnE,wBAAgB,eAAe,CAAC,SAAS,SAAS,MAAM,GAAG,MAAM,EAC/D,MAAM,EAAE,eAAe,CAAC,SAAS,CAAC,GACjC,WAAW,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,CA0BxC"}
|
package/dist/server/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
socketIoLane,
|
|
10
10
|
staticRoute,
|
|
11
11
|
webSocketLane
|
|
12
|
-
} from "../index-
|
|
12
|
+
} from "../index-181aebw8.js";
|
|
13
13
|
import {
|
|
14
14
|
createAuthHook,
|
|
15
15
|
createBearerResolver,
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
signJwt,
|
|
23
23
|
verifyJwt,
|
|
24
24
|
verifyPkce
|
|
25
|
-
} from "../index-
|
|
25
|
+
} from "../index-310bfer5.js";
|
|
26
26
|
import {
|
|
27
27
|
DEFAULT_CORS_ALLOW_HEADERS,
|
|
28
28
|
DEFAULT_CORS_EXPOSE_HEADERS,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
resolveTraceId,
|
|
60
60
|
unauthorized,
|
|
61
61
|
zodIssues
|
|
62
|
-
} from "../index-
|
|
62
|
+
} from "../index-gex6gxhe.js";
|
|
63
63
|
// src/server/bun.ts
|
|
64
64
|
function createServer(config) {
|
|
65
65
|
const { routes, websocket, development, bun: bunExtra, port = 3000, hostname } = config;
|
|
@@ -140,7 +140,7 @@ function cacheHeaders(maxAge, scope = "public") {
|
|
|
140
140
|
}
|
|
141
141
|
// src/server/error-hook.ts
|
|
142
142
|
function createErrorHook(config) {
|
|
143
|
-
return (ctx, error) => {
|
|
143
|
+
return async (ctx, error, endpoint) => {
|
|
144
144
|
const appErr = normalizeError(error);
|
|
145
145
|
const code = config.codeMap && isStitchErrorCode(appErr.code) ? config.codeMap[appErr.code] : appErr.code;
|
|
146
146
|
const info = {
|
|
@@ -150,8 +150,9 @@ function createErrorHook(config) {
|
|
|
150
150
|
details: appErr.details,
|
|
151
151
|
hint: appErr.hint
|
|
152
152
|
};
|
|
153
|
-
config.onError?.(error, info, ctx);
|
|
154
|
-
|
|
153
|
+
await config.onError?.(error, info, ctx, endpoint);
|
|
154
|
+
const body = await config.render(info, ctx, endpoint);
|
|
155
|
+
return new Response(JSON.stringify(body), {
|
|
155
156
|
status: info.status,
|
|
156
157
|
headers: { "content-type": "application/json" }
|
|
157
158
|
});
|
package/dist/tools/agent.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ToolSet } from 'ai';
|
|
|
2
2
|
import type { ServiceDef } from '../server/types';
|
|
3
3
|
import { type ErrorHintFn, type ToolCallHooks, type ToolLifecycle } from './execute';
|
|
4
4
|
import { type ToolExtend } from './mount';
|
|
5
|
-
import {
|
|
5
|
+
import type { RuntimeToolDefinition } from './runtime-tool';
|
|
6
6
|
export interface AgentContext {
|
|
7
7
|
[key: string]: unknown;
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAGlC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,WAAW,CAAC;AACnB,OAAO,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/tools/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAGlC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAG5D,MAAM,WAAW,YAAY;IAC3B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,qCAAqC;IACrC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;OAIG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mEAAmE;IACnE,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC5D,+EAA+E;IAC/E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,gEAAgE;IAChE,SAAS,CAAC,EAAE,WAAW,CAAC;IACxB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACjD;AAED,wBAAgB,UAAU,CACxB,QAAQ,EAAE,UAAU,GAAG,UAAU,EAAE,EACnC,MAAM,GAAE,gBAAqB,GAC5B,OAAO,CAwET"}
|
|
@@ -7,13 +7,15 @@
|
|
|
7
7
|
* consumer's build instead. Also the mechanical "what changed" diff when
|
|
8
8
|
* migrating a service between contract shapes.
|
|
9
9
|
*
|
|
10
|
-
* Built on
|
|
11
|
-
*
|
|
10
|
+
* Built on the mixed-surface collector used by the mounts — the listing cannot
|
|
11
|
+
* drift when pathless runtime tools sit beside contract operations.
|
|
12
12
|
*/
|
|
13
13
|
import type { Transport } from '../contract';
|
|
14
|
-
import type
|
|
14
|
+
import { type ToolSurfaceDefinition } from './surface';
|
|
15
15
|
/** One mounted tool name and where it comes from. */
|
|
16
16
|
export interface ToolNameEntry {
|
|
17
|
+
/** Whether the operation comes from a contract or a pathless runtime definition. */
|
|
18
|
+
kind: 'contract' | 'runtime';
|
|
17
19
|
/** Final tool name — the `toolName` override, else derived from service + method. */
|
|
18
20
|
name: string;
|
|
19
21
|
/** Owning service (`ServiceDef.name` — the contract's prefix). */
|
|
@@ -24,11 +26,11 @@ export interface ToolNameEntry {
|
|
|
24
26
|
transports: Transport[];
|
|
25
27
|
}
|
|
26
28
|
/**
|
|
27
|
-
* Resolve every tool name the
|
|
28
|
-
*
|
|
29
|
+
* Resolve every tool name the surface exposes, sorted by name (then service) —
|
|
30
|
+
* a stable shape to snapshot. Multipart and raw-response endpoints
|
|
29
31
|
* are absent
|
|
30
32
|
* (never mounted as tools) and CLI appears only where `expose` opts in,
|
|
31
33
|
* mirroring the real mounts.
|
|
32
34
|
*/
|
|
33
|
-
export declare function listToolNames(
|
|
35
|
+
export declare function listToolNames(surface: ToolSurfaceDefinition): ToolNameEntry[];
|
|
34
36
|
//# sourceMappingURL=list-names.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-names.d.ts","sourceRoot":"","sources":["../../src/tools/list-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"list-names.d.ts","sourceRoot":"","sources":["../../src/tools/list-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAEL,KAAK,qBAAqB,EAE3B,MAAM,WAAW,CAAC;AAEnB,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,oFAAoF;IACpF,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,MAAM,EAAE,MAAM,CAAC;IACf,6EAA6E;IAC7E,UAAU,EAAE,SAAS,EAAE,CAAC;CACzB;AAID;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,qBAAqB,GAAG,aAAa,EAAE,CA6B7E"}
|
package/dist/tools/manifest.d.ts
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CollectToolsConfig } from './mount';
|
|
2
|
+
import type { RuntimeToolTransport } from './runtime-tool';
|
|
3
|
+
import { type ToolSurfaceDefinition } from './surface';
|
|
2
4
|
export interface ToolManifestEntry {
|
|
3
5
|
name: string;
|
|
4
6
|
description: string;
|
|
5
7
|
inputSchema: Record<string, unknown>;
|
|
6
8
|
}
|
|
9
|
+
export interface ToolManifestConfig extends ToolSurfaceDefinition {
|
|
10
|
+
/** Model-facing surface whose exposure rules the manifest must mirror. */
|
|
11
|
+
transport: RuntimeToolTransport;
|
|
12
|
+
extend?: CollectToolsConfig['extend'];
|
|
13
|
+
flattenUnionInput?: boolean;
|
|
14
|
+
}
|
|
7
15
|
/**
|
|
8
|
-
* Build a searchable manifest from
|
|
9
|
-
* JSON Schema for each. Use it to power a `tool_search`
|
|
10
|
-
* decides the search algorithm and the unlock mechanism.
|
|
16
|
+
* Build a searchable manifest from the complete contract/runtime surface —
|
|
17
|
+
* name, description and JSON Schema for each. Use it to power a `tool_search`
|
|
18
|
+
* tool: the app decides the search algorithm and the unlock mechanism.
|
|
11
19
|
*
|
|
12
20
|
* A tool whose schema cannot be represented as JSON Schema still appears —
|
|
13
21
|
* with an empty `inputSchema` — so it stays discoverable by name / description
|
|
14
22
|
* rather than crashing the whole manifest.
|
|
15
23
|
*/
|
|
16
|
-
export declare function buildToolManifest(
|
|
24
|
+
export declare function buildToolManifest(config: ToolManifestConfig): ToolManifestEntry[];
|
|
17
25
|
//# sourceMappingURL=manifest.d.ts.map
|