stitchkit 0.26.0 → 0.28.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/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +7 -1
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/contract/define.d.ts +60 -3
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/index.js +1 -1
- package/dist/{index-bkccbx64.js → index-17jpjnhd.js} +196 -44
- package/dist/{index-q5w3cvvp.js → index-4whcb3c3.js} +3 -1
- package/dist/{index-dzx781tm.js → index-9g9d6r1h.js} +40 -4
- package/dist/{index-tje0q6gp.js → index-czmqks7r.js} +6 -1
- package/dist/{index-p6fge9a5.js → index-jvescqgr.js} +1 -1
- package/dist/{index-h4y2wg3n.js → index-pmftwk2a.js} +18 -0
- package/dist/index.js +20 -8
- package/dist/node.d.ts +1 -1
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +7 -7
- package/dist/observability/context.d.ts +8 -4
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/index.js +6 -8
- package/dist/server/create.d.ts +2 -2
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/index.d.ts +3 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +19 -7
- package/dist/server/logger.d.ts +36 -4
- package/dist/server/logger.d.ts.map +1 -1
- package/dist/server/logging.d.ts +20 -0
- package/dist/server/logging.d.ts.map +1 -0
- package/dist/server/middleware/cors.d.ts +25 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/node.d.ts +2 -2
- package/dist/server/node.d.ts.map +1 -1
- package/dist/server/openapi.d.ts.map +1 -1
- package/dist/server/router.d.ts +27 -0
- package/dist/server/router.d.ts.map +1 -1
- package/dist/server/types.d.ts +116 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +2 -1
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/tool-logger.d.ts +7 -0
- package/dist/tools/tool-logger.d.ts.map +1 -1
- package/dist/tools.js +29 -14
- package/llms-full.txt +234 -14
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/dist/index-khwedj16.js +0 -40
- /package/dist/{index-0d0rb85d.js → index-zza375qp.js} +0 -0
package/dist/server/types.d.ts
CHANGED
|
@@ -5,11 +5,33 @@ type Prop<T, K extends string> = K extends keyof T ? T[K] : undefined;
|
|
|
5
5
|
type InferParams<E> = Prop<E, 'params'> extends ZodType<infer P> ? P : undefined;
|
|
6
6
|
type InferInput<E> = Prop<E, 'input'> extends ZodType<infer I> ? I : undefined;
|
|
7
7
|
type InferOutput<E> = Prop<E, 'output'> extends ZodType<infer O> ? O : never;
|
|
8
|
+
/**
|
|
9
|
+
* What an endpoint's handler must return: the `Response` itself for a `raw`
|
|
10
|
+
* endpoint, the output type when there is an output schema, nothing otherwise.
|
|
11
|
+
* Enforced in both directions — a raw handler returning data and a normal
|
|
12
|
+
* handler returning a `Response` are both compile errors (the latter used to
|
|
13
|
+
* be accepted and silently serialized to `{}`).
|
|
14
|
+
*/
|
|
15
|
+
type HandlerReturn<E> = E extends {
|
|
16
|
+
rawResponse: true;
|
|
17
|
+
} ? Response | Promise<Response> : Prop<E, 'output'> extends ZodType ? Promise<InferOutput<E>> | InferOutput<E> : void | Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* `ctx.req` is optional in general — a tool call has no `Request`. A raw
|
|
20
|
+
* endpoint is HTTP-only by declaration, and its handler needs the request
|
|
21
|
+
* (`serveFile(ctx.req, …)` reads `Range` / `If-None-Match`), so it is narrowed
|
|
22
|
+
* to a guaranteed `Request` there rather than making every raw handler write
|
|
23
|
+
* a non-null assertion. → ADR 0038.
|
|
24
|
+
*/
|
|
25
|
+
type RequiredRequest<E> = E extends {
|
|
26
|
+
rawResponse: true;
|
|
27
|
+
} ? {
|
|
28
|
+
req: Request;
|
|
29
|
+
} : unknown;
|
|
8
30
|
export type Handlers<C extends Record<string, EndpointDef>, TCtx extends RuntimeContext = HandlerContext> = {
|
|
9
31
|
[K in keyof C]: (ctx: TCtx & {
|
|
10
32
|
params: InferParams<C[K]>;
|
|
11
33
|
input: InferInput<C[K]>;
|
|
12
|
-
}
|
|
34
|
+
} & RequiredRequest<C[K]>) => HandlerReturn<C[K]>;
|
|
13
35
|
};
|
|
14
36
|
export interface MethodDef<TParams = unknown, TInput = unknown, TOutput = unknown> {
|
|
15
37
|
method: HttpMethod;
|
|
@@ -54,6 +76,14 @@ export interface MethodDef<TParams = unknown, TInput = unknown, TOutput = unknow
|
|
|
54
76
|
* the consumer narrows the type. Never serialized to OpenAPI. → ADR 0021.
|
|
55
77
|
*/
|
|
56
78
|
meta?: Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* The handler returns the `Response` itself — from `EndpointDef.rawResponse`. Routed
|
|
81
|
+
* and gated like any endpoint, but never serialized, never validated against
|
|
82
|
+
* an output schema and never mounted as a tool. → ADR 0038.
|
|
83
|
+
*/
|
|
84
|
+
rawResponse?: true;
|
|
85
|
+
/** Documented response media type of a raw-response endpoint — OpenAPI only. */
|
|
86
|
+
contentType?: string;
|
|
57
87
|
handler: (ctx: RuntimeContext) => Promise<TOutput> | TOutput;
|
|
58
88
|
}
|
|
59
89
|
export interface ServiceDef {
|
|
@@ -124,6 +154,63 @@ export interface StitchLogger {
|
|
|
124
154
|
error(msg: string, data?: Record<string, unknown>): void;
|
|
125
155
|
debug(msg: string, data?: Record<string, unknown>): void;
|
|
126
156
|
}
|
|
157
|
+
/** How a request finished — what `LoggingConfig.enrich` gets to react to. */
|
|
158
|
+
export interface LogOutcome {
|
|
159
|
+
status: number;
|
|
160
|
+
durationMs: number;
|
|
161
|
+
errorCode?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Request-logging configuration. `logging: true` is shorthand for `logging: {}`
|
|
165
|
+
* — **any** object turns request logging on; `logger` replaces the built-in
|
|
166
|
+
* sink, and `skip` / `enrich` apply to whichever sink is active.
|
|
167
|
+
*/
|
|
168
|
+
export interface LoggingConfig {
|
|
169
|
+
/** Send lines here instead of to the built-in formatter. */
|
|
170
|
+
logger?: StitchLogger;
|
|
171
|
+
/**
|
|
172
|
+
* Silence a request. Consulted *after* the built-in noise filter (framework
|
|
173
|
+
* assets, `favicon`, preflights), so it can only quieten more, never restore
|
|
174
|
+
* a line the framework drops — `/_bun/` assets are served by the runtime
|
|
175
|
+
* before `fetch` sees them, so un-skipping would be a promise the router
|
|
176
|
+
* cannot keep. A throw is swallowed and treated as "do not skip".
|
|
177
|
+
*
|
|
178
|
+
* The case this exists for: a monitoring probe on a path that 404s every
|
|
179
|
+
* cycle, and Socket.IO's polling transport, which logs a line per poll.
|
|
180
|
+
*/
|
|
181
|
+
skip?: (req: Request, url: URL) => boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Extra fields for the completion line. Runs once per request, at close —
|
|
184
|
+
* not on the development `→` breadcrumb — and its keys are merged **under**
|
|
185
|
+
* the framework's own, which always win: `traceId`, `method`, `path`,
|
|
186
|
+
* `status`, `durationMs`, `errorCode` and `ip` in both sinks, plus `ts`,
|
|
187
|
+
* `level` and `msg` on the built-in production line.
|
|
188
|
+
*
|
|
189
|
+
* Four things to know:
|
|
190
|
+
* - It reaches the structured output only: the production JSON line and a
|
|
191
|
+
* custom logger's `data`. The development `←` line stays as it is — it is a
|
|
192
|
+
* human-readable line, not a record — so **enriched fields are invisible in
|
|
193
|
+
* development**, which is exactly where they get written.
|
|
194
|
+
* - Values must survive `JSON.stringify` on the built-in line. One that does
|
|
195
|
+
* not (a cycle, a `BigInt`) costs the extra fields for that line; the
|
|
196
|
+
* framework's own are re-emitted alone rather than losing the record.
|
|
197
|
+
* - It is synchronous and the request body is **already consumed** by the
|
|
198
|
+
* time it runs. Anything body-derived belongs in `createAuditHook`, which
|
|
199
|
+
* clones the request before the handler.
|
|
200
|
+
* - Its values reach the sink as given. A header echoed straight into a
|
|
201
|
+
* text-based logger can inject line breaks — sanitise anything
|
|
202
|
+
* caller-controlled, as the framework does for the request path.
|
|
203
|
+
*
|
|
204
|
+
* A throw is swallowed; the line is still written without the extra fields.
|
|
205
|
+
*/
|
|
206
|
+
enrich?: (req: Request, url: URL, outcome: LogOutcome) => Record<string, unknown> | undefined;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A fetch handler — what `createHandler` returns and what the servers hand to
|
|
210
|
+
* the runtime. The optional second argument is the runtime's server handle:
|
|
211
|
+
* Bun passes one (raw routes need it for upgrades), Node adapters never do.
|
|
212
|
+
*/
|
|
213
|
+
export type FetchHandler = (req: Request, server?: BunServer) => Promise<Response>;
|
|
127
214
|
/**
|
|
128
215
|
* Runtime-neutral handler config — everything `createHandler` needs.
|
|
129
216
|
* No Bun globals, no Bun types. This is the portability seam.
|
|
@@ -151,7 +238,7 @@ export interface HandlerConfig {
|
|
|
151
238
|
maxUploadBytes?: number;
|
|
152
239
|
cors?: CorsConfig;
|
|
153
240
|
hooks?: LifecycleHooks;
|
|
154
|
-
logging?: boolean |
|
|
241
|
+
logging?: boolean | LoggingConfig;
|
|
155
242
|
/**
|
|
156
243
|
* Report handler-output keys the contract schema removed, as dot-paths, through
|
|
157
244
|
* the configured logger. **Off by default** — the strip itself is correct (the
|
|
@@ -165,7 +252,14 @@ export interface HandlerConfig {
|
|
|
165
252
|
* → ADR 0037.
|
|
166
253
|
*/
|
|
167
254
|
warnOnOutputStrip?: boolean;
|
|
168
|
-
|
|
255
|
+
/**
|
|
256
|
+
* Resolve the trace id for a request. Returning `undefined` falls back to
|
|
257
|
+
* {@link resolveTraceId} (a trusted inbound `x-request-id` / `x-trace-id`,
|
|
258
|
+
* else a fresh id) — which is what makes `traceId: getTraceId` work: outside
|
|
259
|
+
* an active observability context it yields `undefined`, and the framework
|
|
260
|
+
* mints one instead of stamping the string `"undefined"`.
|
|
261
|
+
*/
|
|
262
|
+
traceId?: (req: Request) => string | undefined;
|
|
169
263
|
/**
|
|
170
264
|
* Trust the `x-forwarded-for` / `x-real-ip` headers for the client IP.
|
|
171
265
|
* These are client-controllable — enable only when the server runs behind a
|
|
@@ -185,11 +279,29 @@ type BunDevelopmentOptions = BunServeOptions extends {
|
|
|
185
279
|
development?: infer T;
|
|
186
280
|
} ? T : never;
|
|
187
281
|
export type ServerPassthrough = Omit<BunServeOptions, 'fetch' | 'port' | 'hostname' | 'unix' | 'routes' | 'websocket' | 'development'>;
|
|
282
|
+
/**
|
|
283
|
+
* The composition seam shared by the servers that own their own `fetch`.
|
|
284
|
+
*
|
|
285
|
+
* `wrapInRequestContext` and `createAuditHook` must sit **outside** the
|
|
286
|
+
* handler, which used to mean building the server by hand — `createServer` and
|
|
287
|
+
* `serveNode` construct `fetch` internally, so neither could reach the
|
|
288
|
+
* observability layer at all. `wrapFetch` is where those wrappers go.
|
|
289
|
+
*
|
|
290
|
+
* Order is the consumer's, and it matters: `wrapInRequestContext` outermost,
|
|
291
|
+
* the audit wrapper inside it, because the audit hook reads that context.
|
|
292
|
+
*
|
|
293
|
+
* ```ts
|
|
294
|
+
* createServer({ services, wrapFetch: (h) => wrapInRequestContext(audit.http(h)) })
|
|
295
|
+
* ```
|
|
296
|
+
*/
|
|
297
|
+
export interface FetchComposition {
|
|
298
|
+
wrapFetch?: (fetch: FetchHandler) => FetchHandler;
|
|
299
|
+
}
|
|
188
300
|
/**
|
|
189
301
|
* Full config for `createServer` — extends `HandlerConfig` with Bun-specific
|
|
190
302
|
* options (`Bun.serve` routes, websocket, development, passthrough).
|
|
191
303
|
*/
|
|
192
|
-
export interface BunServerConfig extends HandlerConfig {
|
|
304
|
+
export interface BunServerConfig extends HandlerConfig, FetchComposition {
|
|
193
305
|
port?: number;
|
|
194
306
|
hostname?: string;
|
|
195
307
|
routes?: BunRoutes;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EACV,WAAW,EACX,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACtE,KAAK,WAAW,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;AACjF,KAAK,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC;AAC/E,KAAK,WAAW,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAE7E,MAAM,MAAM,QAAQ,CAClB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,IAAI,SAAS,cAAc,GAAG,cAAc,IAC1C;KACD,CAAC,IAAI,MAAM,CAAC,GAAG,CACd,GAAG,EAAE,IAAI,GAAG;QAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names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CAAC,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACvD,KAAK,oBAAoB,GAAG,eAAe,SAAS;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AACxF,KAAK,SAAS,GAAG,eAAe,SAAS;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAC1E,KAAK,qBAAqB,GAAG,eAAe,SAAS;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,CAAC,GAAG,KAAK,CAAC;AAE3F,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,eAAe,EACf,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,aAAa,CAChF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,YAAY,CAAC;CACnD;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,aAAa,EAAE,gBAAgB;IACtE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,oBAAoB,CAAC;IACjC,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,GAAG,CAAC,EAAE,iBAAiB,CAAC;CACzB"}
|
|
@@ -25,7 +25,8 @@ export interface ToolNameEntry {
|
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Resolve every tool name the given services expose, sorted by name (then
|
|
28
|
-
* service) — a stable shape to snapshot. Multipart
|
|
28
|
+
* service) — a stable shape to snapshot. Multipart and raw-response endpoints
|
|
29
|
+
* are absent
|
|
29
30
|
* (never mounted as tools) and CLI appears only where `expose` opts in,
|
|
30
31
|
* mirroring the real mounts.
|
|
31
32
|
*/
|
|
@@ -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,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,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
|
|
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,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAGlD,qDAAqD;AACrD,MAAM,WAAW,aAAa;IAC5B,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,QAAQ,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE,CA2BrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/tools/mount.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC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AAC,EAAE,MAAM,EACjB,SAAS,CAAC,EAAE,WAAW,GACtB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAazB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/tools/remote.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../../src/tools/remote.ts"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,WAAW,EAEjB,MAAM,aAAa,CAAC;AAGrB,OAAO,KAAK,EAAa,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAiB7D,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,aAAa,CAAC,EAAE,CACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACnE,QAAQ,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,EAChC,IAAI,EAAE,UAAU,EAChB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,UAAU,CAgFZ"}
|
|
@@ -15,6 +15,13 @@ export interface ToolCallRecord {
|
|
|
15
15
|
durationMs: number;
|
|
16
16
|
/** Transport tag the call came in on (`ctx.source`). */
|
|
17
17
|
source: string;
|
|
18
|
+
/**
|
|
19
|
+
* The active trace id, when an observability context is running — the key
|
|
20
|
+
* that joins this line to the HTTP request that triggered the tool call.
|
|
21
|
+
* Absent when nothing established a context (`wrapInRequestContext`, or a
|
|
22
|
+
* server's `wrapFetch`).
|
|
23
|
+
*/
|
|
24
|
+
traceId?: string;
|
|
18
25
|
}
|
|
19
26
|
/** Config for `createToolLogger`. */
|
|
20
27
|
export interface ToolLoggerConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-logger.d.ts","sourceRoot":"","sources":["../../src/tools/tool-logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tool-logger.d.ts","sourceRoot":"","sources":["../../src/tools/tool-logger.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,kFAAkF;AAClF,MAAM,WAAW,cAAc;IAC7B,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,EAAE,EAAE,OAAO,CAAC;IACZ,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,UAAU,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qCAAqC;AACrC,MAAM,WAAW,gBAAgB;IAC/B,2DAA2D;IAC3D,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAE,gBAAqB,GAAG,aAAa,CAqB7E"}
|
package/dist/tools.js
CHANGED
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
inputIsQuery,
|
|
3
3
|
signJwt,
|
|
4
4
|
verifyPkce
|
|
5
|
-
} from "./index-
|
|
5
|
+
} from "./index-jvescqgr.js";
|
|
6
6
|
import {
|
|
7
7
|
DEFAULT_CORS_ALLOW_HEADERS
|
|
8
|
-
} from "./index-
|
|
8
|
+
} from "./index-czmqks7r.js";
|
|
9
9
|
import {
|
|
10
10
|
assertToolName,
|
|
11
11
|
assertUniqueToolName,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
readCapped,
|
|
22
22
|
toolResultFromError,
|
|
23
23
|
writeDownload
|
|
24
|
-
} from "./index-
|
|
24
|
+
} from "./index-4whcb3c3.js";
|
|
25
25
|
import {
|
|
26
26
|
toJsonSchema
|
|
27
27
|
} from "./index-0ed3bx43.js";
|
|
@@ -29,8 +29,10 @@ import {
|
|
|
29
29
|
AppError,
|
|
30
30
|
isWithinDir,
|
|
31
31
|
mergeMeta
|
|
32
|
-
} from "./index-
|
|
33
|
-
import
|
|
32
|
+
} from "./index-zza375qp.js";
|
|
33
|
+
import {
|
|
34
|
+
getTraceId
|
|
35
|
+
} from "./index-9g9d6r1h.js";
|
|
34
36
|
import {
|
|
35
37
|
isRecord,
|
|
36
38
|
typedEntries
|
|
@@ -929,10 +931,15 @@ function parseApiErrorBody(body) {
|
|
|
929
931
|
}
|
|
930
932
|
|
|
931
933
|
// src/browser/client.ts
|
|
932
|
-
function withTimeout(options,
|
|
933
|
-
|
|
934
|
+
function withTimeout(options, endpoint) {
|
|
935
|
+
const responseType = endpoint.rawResponse ? "response" : undefined;
|
|
936
|
+
if (endpoint.timeout === undefined && responseType === undefined)
|
|
934
937
|
return options;
|
|
935
|
-
return {
|
|
938
|
+
return {
|
|
939
|
+
...options,
|
|
940
|
+
...endpoint.timeout !== undefined && { timeout: endpoint.timeout },
|
|
941
|
+
...responseType && { responseType }
|
|
942
|
+
};
|
|
936
943
|
}
|
|
937
944
|
function withOutput(endpoint, result) {
|
|
938
945
|
const schema = endpoint.output;
|
|
@@ -1009,15 +1016,15 @@ function createHttpMethod(endpoint, prefix, client, config) {
|
|
|
1009
1016
|
const formData = new FormData;
|
|
1010
1017
|
appendMultipartFile(formData, endpoint.multipart, file);
|
|
1011
1018
|
appendFormFields(formData, firstArg, new Set([...prefixKeys, endpoint.multipart]));
|
|
1012
|
-
return withOutput(endpoint, client[httpMethod](url, formData, withTimeout(undefined, endpoint
|
|
1019
|
+
return withOutput(endpoint, client[httpMethod](url, formData, withTimeout(undefined, endpoint)));
|
|
1013
1020
|
}
|
|
1014
1021
|
if (isGet) {
|
|
1015
1022
|
const params = collectQueryParams(firstArg, prefixKeys, endpoint);
|
|
1016
|
-
return withOutput(endpoint, client.get(url, withTimeout(params ? { params } : undefined, endpoint
|
|
1023
|
+
return withOutput(endpoint, client.get(url, withTimeout(params ? { params } : undefined, endpoint)));
|
|
1017
1024
|
}
|
|
1018
1025
|
if (httpMethod === "delete") {
|
|
1019
1026
|
const params = collectQueryParams(firstArg, prefixKeys, endpoint);
|
|
1020
|
-
return withOutput(endpoint, client.delete(url, withTimeout(params ? { params } : undefined, endpoint
|
|
1027
|
+
return withOutput(endpoint, client.delete(url, withTimeout(params ? { params } : undefined, endpoint)));
|
|
1021
1028
|
}
|
|
1022
1029
|
const payload = {};
|
|
1023
1030
|
for (const [key, value] of Object.entries(firstArg)) {
|
|
@@ -1025,7 +1032,7 @@ function createHttpMethod(endpoint, prefix, client, config) {
|
|
|
1025
1032
|
payload[key] = value;
|
|
1026
1033
|
}
|
|
1027
1034
|
}
|
|
1028
|
-
return withOutput(endpoint, client[httpMethod](url, Object.keys(payload).length > 0 ? payload : undefined, withTimeout(undefined, endpoint
|
|
1035
|
+
return withOutput(endpoint, client[httpMethod](url, Object.keys(payload).length > 0 ? payload : undefined, withTimeout(undefined, endpoint)));
|
|
1029
1036
|
};
|
|
1030
1037
|
}
|
|
1031
1038
|
function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
@@ -1081,6 +1088,8 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
|
1081
1088
|
if (!res2.ok) {
|
|
1082
1089
|
await throwForErrorResponse(res2, config, null);
|
|
1083
1090
|
}
|
|
1091
|
+
if (endpoint.rawResponse)
|
|
1092
|
+
return res2;
|
|
1084
1093
|
if (res2.status === 204)
|
|
1085
1094
|
return;
|
|
1086
1095
|
const json3 = await res2.json();
|
|
@@ -1098,6 +1107,8 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
|
1098
1107
|
if (!res.ok) {
|
|
1099
1108
|
await throwForErrorResponse(res, config, { error: res.statusText });
|
|
1100
1109
|
}
|
|
1110
|
+
if (endpoint.rawResponse)
|
|
1111
|
+
return res;
|
|
1101
1112
|
if (res.status === 204)
|
|
1102
1113
|
return;
|
|
1103
1114
|
const json2 = await res.json();
|
|
@@ -1145,6 +1156,7 @@ function stripParams(args, path, extra) {
|
|
|
1145
1156
|
}
|
|
1146
1157
|
|
|
1147
1158
|
// src/tools/remote.ts
|
|
1159
|
+
var HTTP_ONLY = Object.freeze(["HTTP"]);
|
|
1148
1160
|
function toArgs(ctx) {
|
|
1149
1161
|
const { params, input } = ctx;
|
|
1150
1162
|
return {
|
|
@@ -1164,7 +1176,7 @@ function implementRemote(contract, http, options) {
|
|
|
1164
1176
|
serviceName: contract.meta.prefix,
|
|
1165
1177
|
key,
|
|
1166
1178
|
toolName: "toolName" in endpoint ? endpoint.toolName : undefined,
|
|
1167
|
-
expose: endpoint.expose,
|
|
1179
|
+
expose: endpoint.rawResponse ? HTTP_ONLY : endpoint.expose,
|
|
1168
1180
|
ui: "ui" in endpoint ? endpoint.ui : undefined,
|
|
1169
1181
|
annotations: "annotations" in endpoint ? endpoint.annotations : undefined,
|
|
1170
1182
|
meta: mergeMeta(contract.meta.meta, endpoint.meta),
|
|
@@ -1174,6 +1186,8 @@ function implementRemote(contract, http, options) {
|
|
|
1174
1186
|
outputSchema: endpoint.output,
|
|
1175
1187
|
multipart: endpoint.multipart,
|
|
1176
1188
|
idempotent: endpoint.idempotent,
|
|
1189
|
+
rawResponse: endpoint.rawResponse,
|
|
1190
|
+
contentType: "contentType" in endpoint ? endpoint.contentType : undefined,
|
|
1177
1191
|
handler: async (ctx) => {
|
|
1178
1192
|
const call = client[key];
|
|
1179
1193
|
if (!call) {
|
|
@@ -1211,7 +1225,8 @@ function createToolLogger(config = {}) {
|
|
|
1211
1225
|
ok: result.ok,
|
|
1212
1226
|
code: result.ok ? undefined : result.code,
|
|
1213
1227
|
durationMs: Math.round(durationMs),
|
|
1214
|
-
source: String(context.source)
|
|
1228
|
+
source: String(context.source),
|
|
1229
|
+
traceId: getTraceId()
|
|
1215
1230
|
};
|
|
1216
1231
|
const codePart = result.ok ? "" : ` ${result.code}`;
|
|
1217
1232
|
log(`[tool] ${result.ok ? "ok" : "warn"} ${toolName} (${endpoint.serviceName}.${endpoint.key})${codePart} ${record.durationMs}ms`);
|