somamcp 1.5.0 → 2.0.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/edge.d.ts CHANGED
@@ -1,767 +1,3 @@
1
- import { Option } from "functype";
2
- import { Context as Context$1, Hono, MiddlewareHandler } from "hono";
3
- import { DirectLogger } from "functype-log";
4
- import { z } from "zod";
5
- import { Tool as Tool$1 } from "@modelcontextprotocol/sdk/types.js";
6
- //#region src/artifacts/types.d.ts
7
- type ArtifactCommon = {
8
- protected?: boolean;
9
- };
10
- type StaticArtifact = ArtifactCommon & {
11
- contentType: string;
12
- content: string;
13
- path: string;
14
- type: "static";
15
- };
16
- type DynamicArtifact = ArtifactCommon & {
17
- handler: (c: Context$1) => Response | Promise<Response>;
18
- path: string;
19
- type: "dynamic";
20
- };
21
- type DirectoryArtifact = ArtifactCommon & {
22
- directory: string;
23
- path: string;
24
- type: "directory";
25
- };
26
- type ArtifactConfig = DirectoryArtifact | DynamicArtifact | StaticArtifact;
27
- type ArtifactAuthenticate = (request: unknown) => Promise<unknown>;
28
- //#endregion
29
- //#region src/types/core.d.ts
30
- type SessionAuth = Record<string, unknown> | undefined;
31
- /**
32
- * Structural type compatible with StandardSchemaV1 (zod, valibot, etc.)
33
- * We define this structurally to avoid a direct dependency on @standard-schema/spec.
34
- */
35
- type SchemaParams = {
36
- readonly "~standard": {
37
- readonly version: 1;
38
- readonly vendor: string;
39
- readonly types?: {
40
- readonly input: unknown;
41
- readonly output: unknown;
42
- } | undefined;
43
- readonly validate: (value: unknown) => {
44
- value: unknown;
45
- } | {
46
- issues: ReadonlyArray<{
47
- message: string;
48
- }>;
49
- } | Promise<{
50
- value: unknown;
51
- } | {
52
- issues: ReadonlyArray<{
53
- message: string;
54
- }>;
55
- }>;
56
- };
57
- };
58
- type InferSchemaOutput<P extends SchemaParams> = NonNullable<P["~standard"]["types"]>["output"] extends (infer O) ? [O] extends [never] ? unknown : O : unknown;
59
- type TextContent = {
60
- text: string;
61
- type: "text";
62
- };
63
- type ImageContent = {
64
- data: string;
65
- mimeType: string;
66
- type: "image";
67
- };
68
- type AudioContent = {
69
- data: string;
70
- mimeType: string;
71
- type: "audio";
72
- };
73
- type ResourceContent = {
74
- resource: {
75
- blob?: string;
76
- mimeType?: string;
77
- text?: string;
78
- uri: string;
79
- };
80
- type: "resource";
81
- };
82
- type ResourceLink = {
83
- mimeType?: string;
84
- name?: string;
85
- type: "resource_link";
86
- uri: string;
87
- };
88
- type Content = AudioContent | ImageContent | ResourceContent | ResourceLink | TextContent;
89
- type ContentResult = {
90
- content: Content[];
91
- isError?: boolean;
92
- };
93
- type Progress = {
94
- progress: number;
95
- total?: number;
96
- };
97
- type Context<T extends SessionAuth = SessionAuth> = {
98
- client: {
99
- version: unknown;
100
- };
101
- log: {
102
- debug: (message: string, data?: unknown) => void;
103
- error: (message: string, data?: unknown) => void;
104
- info: (message: string, data?: unknown) => void;
105
- warn: (message: string, data?: unknown) => void;
106
- };
107
- reportProgress: (progress: Progress) => Promise<void>;
108
- requestId?: string;
109
- session: T | undefined;
110
- sessionId?: string;
111
- streamContent: (content: Content | Content[]) => Promise<void>;
112
- };
113
- type ToolAnnotations = {
114
- destructiveHint?: boolean;
115
- idempotentHint?: boolean;
116
- openWorldHint?: boolean;
117
- readOnlyHint?: boolean;
118
- streamingHint?: boolean;
119
- title?: string;
120
- };
121
- type Tool<T extends SessionAuth = SessionAuth, P extends SchemaParams = SchemaParams> = {
122
- _meta?: {
123
- [key: string]: unknown;
124
- ui?: {
125
- resourceUri?: string;
126
- };
127
- };
128
- annotations?: ToolAnnotations;
129
- canAccess?: (auth: T) => boolean;
130
- description?: string;
131
- execute: (args: InferSchemaOutput<P>, context: Context<T>) => Promise<Content | ContentResult | string | void>;
132
- name: string;
133
- outputSchema?: SchemaParams;
134
- parameters?: P;
135
- timeoutMs?: number;
136
- };
137
- type Completion = {
138
- hasMore?: boolean;
139
- total?: number;
140
- values: string[];
141
- };
142
- type ResourceResult = {
143
- blob: string;
144
- mimeType?: string;
145
- uri?: string;
146
- } | {
147
- mimeType?: string;
148
- text: string;
149
- uri?: string;
150
- };
151
- type Resource<T extends SessionAuth = SessionAuth> = {
152
- complete?: (name: string, value: string, auth?: T) => Promise<Completion>;
153
- description?: string;
154
- load: (auth?: T) => Promise<ResourceResult | ResourceResult[]>;
155
- mimeType?: string;
156
- name: string;
157
- uri: string;
158
- };
159
- type ResourceTemplateArgument<T extends SessionAuth = SessionAuth> = Readonly<{
160
- complete?: (value: string, auth?: T) => Promise<Completion>;
161
- description?: string;
162
- name: string;
163
- required?: boolean;
164
- }>;
165
- /**
166
- * A family of resources addressed by an RFC 6570 URI template, e.g. `docs://{path}`.
167
- * `load` receives the variables matched from the requested URI.
168
- */
169
- type ResourceTemplate<T extends SessionAuth = SessionAuth> = {
170
- arguments: ResourceTemplateArgument<T>[];
171
- complete?: (name: string, value: string, auth?: T) => Promise<Completion>;
172
- description?: string;
173
- load: (args: Record<string, string>, auth?: T) => Promise<ResourceResult | ResourceResult[]>;
174
- mimeType?: string;
175
- name: string;
176
- uriTemplate: string;
177
- };
178
- type PromptArgument<T extends SessionAuth = SessionAuth> = Readonly<{
179
- complete?: (value: string, auth?: T) => Promise<Completion>;
180
- description?: string;
181
- enum?: string[];
182
- name: string;
183
- required?: boolean;
184
- }>;
185
- type PromptResult = {
186
- messages: unknown[];
187
- } | string;
188
- type Prompt<T extends SessionAuth = SessionAuth, Args extends PromptArgument<T>[] = PromptArgument<T>[]> = {
189
- arguments?: Args;
190
- complete?: (name: string, value: string, auth?: T) => Promise<Completion>;
191
- description?: string;
192
- load: (args: Record<string, string | undefined>, auth?: T) => Promise<PromptResult>;
193
- name: string;
194
- };
195
- type ServerStatus = "error" | "running" | "stopped";
196
- declare class UserError extends Error {
197
- constructor(message: string);
198
- }
199
- //#endregion
200
- //#region src/types/server.d.ts
201
- type Logger = {
202
- debug: (...args: unknown[]) => void;
203
- error: (...args: unknown[]) => void;
204
- info: (...args: unknown[]) => void;
205
- log: (...args: unknown[]) => void;
206
- warn: (...args: unknown[]) => void;
207
- };
208
- type ServerConfig<T extends SessionAuth = SessionAuth> = {
209
- authenticate?: (request: unknown) => Promise<T>;
210
- instructions?: string;
211
- logger?: Logger;
212
- name: string;
213
- /**
214
- * Periodic writes onto an in-flight tool call's own response stream, so a proxy or load
215
- * balancer does not close the connection as idle while a long-running tool produces no
216
- * output — a large document read, say.
217
- *
218
- * This is the only keepalive that survives `httpStream.stateless`. A transport-level ping
219
- * needs the standing server-to-client stream, and stateless has none; these travel on the
220
- * request's own stream instead. If you set `stateless` and have anything with an idle
221
- * timeout in front of you, you want this too.
222
- *
223
- * Set at construction rather than on `httpStream`, because the backend builds its server
224
- * before `start()` ever sees the transport config.
225
- *
226
- * Honoured by the fastmcp backend. The edge backend ignores it — Workers and Deno Deploy
227
- * terminate the connection themselves, so there is nothing for somamcp to keep alive.
228
- */
229
- streamKeepalive?: {
230
- /** Whether to write keepalives. Opt-in. */
231
- enabled?: boolean;
232
- /**
233
- * Gap between keepalives. Keep it comfortably under the shortest idle timeout on the
234
- * path — an AWS ALB defaults to 60s. Defaults to 20s in the fastmcp backend.
235
- */
236
- intervalMs?: number;
237
- /**
238
- * Level reported on the keepalive notification. Defaults to `debug` in the fastmcp
239
- * backend, which is usually what you want — these fire every interval, for the whole
240
- * length of every long call.
241
- */
242
- logLevel?: "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning";
243
- };
244
- version: `${number}.${number}.${number}`;
245
- };
246
- /**
247
- * httpStream transport options. All fields are passed through to the underlying
248
- * MCP backend unchanged; `port` is the only one required.
249
- *
250
- * - `cors` — `true` for permissive defaults, or a config object forwarded to the
251
- * backend's CORS implementation. Only relevant for browser-facing servers.
252
- * - `stateless` — treat each request independently (no session state). Useful
253
- * for horizontally-scaled or Lambda-style deployments.
254
- * - `eventStore` — pluggable store enabling resumable event streams; the
255
- * backend's `EventStore` interface, opaque to somamcp.
256
- * - `sslCert` / `sslKey` / `sslCa` — inline PEM strings enabling TLS termination
257
- * at the server. Omit for plain HTTP behind a proxy.
258
- */
259
- type HttpStreamConfig = {
260
- cors?: boolean | Record<string, unknown>;
261
- enableJsonResponse?: boolean;
262
- endpoint?: `/${string}`;
263
- eventStore?: unknown;
264
- host?: string;
265
- port: number;
266
- sslCa?: string;
267
- sslCert?: string;
268
- sslKey?: string;
269
- stateless?: boolean;
270
- };
271
- type TransportConfig = {
272
- transportType: "stdio";
273
- } | {
274
- httpStream: HttpStreamConfig;
275
- transportType: "httpStream";
276
- };
277
- //#endregion
278
- //#region src/backend/adapter.d.ts
279
- type BackendSession<T extends SessionAuth = SessionAuth> = {
280
- sessionId?: string;
281
- auth?: T;
282
- };
283
- type BackendEvents<T extends SessionAuth> = {
284
- connect: (event: {
285
- session: BackendSession<T>;
286
- }) => void;
287
- disconnect: (event: {
288
- session: BackendSession<T>;
289
- }) => void;
290
- };
291
- type BackendAdapter<T extends SessionAuth = SessionAuth> = {
292
- readonly serverState: ServerStatus;
293
- readonly sessions: ReadonlyArray<BackendSession<T>>;
294
- addPrompt: <Args extends PromptArgument<T>[]>(prompt: Prompt<T, Args>) => void;
295
- addResource: (resource: Resource<T>) => void;
296
- addResourceTemplate: (...args: ReadonlyArray<unknown>) => void;
297
- addTool: <P extends SchemaParams>(tool: Tool<T, P>) => void;
298
- /**
299
- * Handle a web-standard Request. Optional: when absent, callers fall back to
300
- * `getApp().fetch`. Edge backends implement this as their primary entry point;
301
- * Node backends provide it for parity so `SomaServerInstance.fetch` always works.
302
- */
303
- fetch?: (request: Request) => Promise<Response>;
304
- getApp: () => Hono;
305
- on: <E extends keyof BackendEvents<T>>(event: E, handler: BackendEvents<T>[E]) => void;
306
- /**
307
- * Whether `removeTool` / `removeResource` / `removePrompt` actually take
308
- * effect. Defaults to true when absent.
309
- *
310
- * The edge backend sets this false: EdgeFastMCP exposes no removal API, so its
311
- * `remove*` calls only warn. Capability counts must not shrink for a tool that
312
- * is still being served.
313
- */
314
- readonly supportsRemoval?: boolean;
315
- removePrompt: (name: string) => void;
316
- removeResource: (name: string) => void;
317
- removeTool: (name: string) => void;
318
- start: (transport?: TransportConfig) => Promise<void>;
319
- stop: () => Promise<void>;
320
- };
321
- type BackendFactory<T extends SessionAuth = SessionAuth> = (config: ServerConfig<T>, backendOptions?: Record<string, unknown>) => BackendAdapter<T>;
322
- //#endregion
323
- //#region src/buildInfo.d.ts
324
- type BuildInfo = {
325
- branch?: string;
326
- commit?: string;
327
- date?: string;
328
- environment?: string;
329
- };
330
- type RuntimeInfo = {
331
- arch: string;
332
- nodeVersion: string;
333
- platform: string;
334
- /** Which runtime family reported the fields above. Absent on pre-1.2 builds. */
335
- runtime?: "edge" | "node";
336
- };
337
- declare const readBuildInfoFromEnv: () => BuildInfo;
338
- declare const resolveBuildInfo: (override?: BuildInfo) => BuildInfo;
339
- declare const getRuntimeInfo: () => RuntimeInfo;
340
- //#endregion
341
- //#region src/gateway/types.d.ts
342
- type GatewayConfig = {
343
- id: string;
344
- name?: string;
345
- proxyTools?: boolean;
346
- reconnect?: boolean;
347
- reconnectIntervalMs?: number;
348
- toolPrefix?: string;
349
- url: string;
350
- };
351
- type GatewayStatus = "connected" | "connecting" | "disconnected" | "error";
352
- type GatewayInfo = {
353
- id: string;
354
- name: string;
355
- remoteTools: ReadonlyArray<{
356
- description?: string;
357
- name: string;
358
- }>;
359
- status: GatewayStatus;
360
- url: string;
361
- };
362
- type GatewayInstance = {
363
- readonly config: GatewayConfig;
364
- readonly info: GatewayInfo;
365
- readonly name: string;
366
- readonly status: GatewayStatus;
367
- readonly tools: ReadonlyArray<Tool$1>;
368
- callTool: (name: string, args?: Record<string, unknown>) => Promise<unknown>;
369
- connect: () => Promise<void>;
370
- disconnect: () => Promise<void>;
371
- };
372
- type GatewayManagerInstance = {
373
- readonly connectedCount: number;
374
- readonly totalCount: number;
375
- add: (config: GatewayConfig) => GatewayInstance;
376
- connectAll: () => Promise<void>;
377
- disconnectAll: () => Promise<void>;
378
- get: (id: string) => Option<GatewayInstance>;
379
- getAll: () => ReadonlyArray<GatewayInstance>;
380
- getInfoAll: () => ReadonlyArray<GatewayInfo>;
381
- };
382
- //#endregion
383
- //#region src/telemetry/TelemetryCollector.d.ts
384
- type TelemetryEventType = "server.start" | "server.stop" | "tool.execute" | "tool.error" | "resource.load" | "resource.error" | "prompt.load" | "prompt.error" | "gateway.connect" | "gateway.disconnect" | "gateway.error" | "session.connect" | "session.disconnect";
385
- type ErrorCategory = "validation" | "timeout" | "gateway" | "internal" | "auth" | "not_found";
386
- type CaptureLevel = "full" | "metadata" | "none";
387
- type ToolCaptureConfig = {
388
- captureLevel?: CaptureLevel;
389
- maxOutputSize?: number;
390
- redactInputFields?: ReadonlyArray<string>;
391
- };
392
- type TelemetryEvent = {
393
- data?: Record<string, unknown>;
394
- durationMs?: number;
395
- error?: string;
396
- errorCategory?: ErrorCategory;
397
- errorStack?: string;
398
- input?: Record<string, unknown>;
399
- name: string;
400
- output?: unknown;
401
- requestId?: string;
402
- sessionId?: string;
403
- timestamp: number;
404
- type: TelemetryEventType;
405
- };
406
- type TelemetryCollector = {
407
- flush?: () => Promise<void>;
408
- recordEvent: (event: TelemetryEvent) => void;
409
- };
410
- //#endregion
411
- //#region src/auth/middleware.d.ts
412
- /**
413
- * Callback invoked to authenticate an incoming request. Receives either a Hono
414
- * `Request` (custom routes / protected artifacts) or an `http.IncomingMessage`
415
- * (MCP transport). Use `getRequestHeader` to hide the shape difference.
416
- */
417
- type Authenticate = (request: unknown) => Promise<unknown>;
418
- /** Response builder invoked when auth is missing or fails. Defaults to `401 { error: "Unauthorized" }`. */
419
- type OnUnauthorized = (c: Context$1) => Response | Promise<Response>;
420
- type AuthMiddlewareConfig = {
421
- authenticate?: Authenticate;
422
- onUnauthorized?: OnUnauthorized;
423
- };
424
- declare const createAuthMiddleware: ({ authenticate, onUnauthorized }: AuthMiddlewareConfig) => MiddlewareHandler;
425
- //#endregion
426
- //#region src/auth/request.d.ts
427
- /**
428
- * Extract a header from either shape somamcp's `authenticate` callback may receive:
429
- *
430
- * - **Hono `Request`** (`c.req.raw`) — used on protected artifact and custom routes.
431
- * Headers implement the WHATWG `Headers` interface (`.get(name)`).
432
- * - **`http.IncomingMessage`** — used on the MCP transport path (FastMCP).
433
- * Headers are a plain lowercased object; values may be `string | string[]`.
434
- *
435
- * Case-insensitive on the header name. Returns `undefined` when the header is
436
- * absent or the request shape is not recognized — matches the `Headers.get`
437
- * shape callers already write against.
438
- */
439
- declare const getRequestHeader: (request: unknown, name: string) => string | undefined;
440
- //#endregion
441
- //#region src/types/routes.d.ts
442
- type RouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
443
- /**
444
- * Config for a custom HTTP route registered on the server's Hono app via
445
- * `SomaServerInstance.addRoute`.
446
- *
447
- * When `protected: true`, the server's `authenticate` callback runs first — a
448
- * throw or rejection short-circuits to `onUnauthorized` (default `401`).
449
- *
450
- * ### Route ordering
451
- *
452
- * Hono dispatches by registration order. `addRoute` registers immediately, so
453
- * routes added **before** `start()` land alongside artifacts and introspection
454
- * routes in call order. For concrete non-overlapping paths this doesn't matter;
455
- * for wildcards or overlapping prefixes, register earlier to take precedence.
456
- */
457
- type RouteConfig = {
458
- method: RouteMethod | ReadonlyArray<RouteMethod>;
459
- path: `/${string}`;
460
- protected?: boolean;
461
- handler: (c: Context$1) => Response | Promise<Response>;
462
- onUnauthorized?: OnUnauthorized;
463
- };
464
- //#endregion
465
- //#region src/types.d.ts
466
- type SomaServerOptions<T extends SessionAuth = SessionAuth> = ServerConfig<T> & {
467
- artifacts?: ArtifactConfig[];
468
- /**
469
- * Backend implementation. Defaults to `createFastMCPBackend` (Node).
470
- * Pass `createEdgeBackend` from `somamcp/edge` to target Cloudflare Workers,
471
- * Deno Deploy, or Bun.
472
- */
473
- backend?: BackendFactory<T>;
474
- backendOptions?: Record<string, unknown>;
475
- build?: BuildInfo;
476
- enableDashboard?: boolean;
477
- enableHealthEndpoint?: boolean;
478
- enableInfoEndpoint?: boolean;
479
- enableIntrospection?: boolean;
480
- gateways?: GatewayConfig[];
481
- healthDetailPath?: string;
482
- healthPath?: string;
483
- infoPath?: string;
484
- introspectionPrefix?: string;
485
- logLayer?: DirectLogger;
486
- telemetry?: TelemetryCollector;
487
- };
488
- type ServerHealth = {
489
- activeSessions: number;
490
- gateways: {
491
- connected: number;
492
- total: number;
493
- };
494
- name: string;
495
- startedAt: number;
496
- status: ServerStatus;
497
- uptime: number;
498
- };
499
- type ServerCapabilities = {
500
- prompts: ReadonlyArray<{
501
- description?: string;
502
- name: string;
503
- }>;
504
- resources: ReadonlyArray<{
505
- description?: string;
506
- name: string;
507
- uri: string;
508
- }>;
509
- tools: ReadonlyArray<{
510
- description?: string;
511
- name: string;
512
- }>;
513
- };
514
- type CapabilitiesSummary = {
515
- prompts: number;
516
- resources: number;
517
- tools: number;
518
- };
519
- type ServerInfo = {
520
- build: BuildInfo;
521
- capabilities: CapabilitiesSummary;
522
- name: string;
523
- runtime: RuntimeInfo;
524
- version: string;
525
- };
526
- type ToolOptions<T extends SessionAuth = SessionAuth, P extends SchemaParams = SchemaParams> = Tool<T, P> & {
527
- captureConfig?: ToolCaptureConfig;
528
- };
529
- type SomaServerInstance<T extends SessionAuth = SessionAuth> = {
530
- readonly name: string;
531
- readonly serverState: ServerStatus;
532
- readonly sessions: ReadonlyArray<BackendSession<T>>;
533
- addPrompt: <Args extends PromptArgument<T>[]>(prompt: Prompt<T, Args>) => void;
534
- addPrompts: <Args extends PromptArgument<T>[]>(prompts: Prompt<T, Args>[]) => void;
535
- addResource: (resource: Resource<T>) => void;
536
- addResources: (resources: Resource<T>[]) => void;
537
- addResourceTemplate: (...args: ReadonlyArray<unknown>) => void;
538
- addRoute: (route: RouteConfig) => void;
539
- addTool: <P extends SchemaParams>(tool: Tool<T, P>) => void;
540
- addTools: <P extends SchemaParams>(tools: Tool<T, P>[]) => void;
541
- /**
542
- * Web-standard request handler covering both MCP calls and registered
543
- * artifacts/routes. This is the entry point for edge runtimes:
544
- * `export default { fetch: (req) => server.fetch(req) }`.
545
- */
546
- fetch: (request: Request) => Promise<Response>;
547
- getApp: () => Hono;
548
- getCapabilities: () => ServerCapabilities;
549
- getGatewayManager: () => GatewayManagerInstance;
550
- getHealth: () => ServerHealth;
551
- getInfo: () => ServerInfo;
552
- removePrompt: (name: string) => void;
553
- removeResource: (name: string) => void;
554
- removeTool: (name: string) => void;
555
- start: (options?: TransportConfig) => Promise<void>;
556
- stop: () => Promise<void>;
557
- };
558
- //#endregion
559
- //#region src/Server.d.ts
560
- /**
561
- * Backend-agnostic server core.
562
- *
563
- * `backend` is required here on purpose. Defaulting it would mean a static import
564
- * of the Node FastMCP backend, which lands in every bundle that reaches this
565
- * module — including `somamcp/edge`. The entry barrels supply the default instead:
566
- * `somamcp` binds createFastMCPBackend, `somamcp/edge` binds createEdgeBackend.
567
- */
568
- declare const createServerCore: <T extends SessionAuth = SessionAuth>(options: SomaServerOptions<T> & {
569
- backend: BackendFactory<T>;
570
- }) => SomaServerInstance<T>;
571
- //#endregion
572
- //#region src/backend/edge.d.ts
573
- type EdgeBackendOptions = {
574
- /** Base path for the MCP endpoint. Defaults to "/mcp". */
575
- mcpPath?: string;
576
- };
577
- /**
578
- * Edge-runtime backend for Cloudflare Workers, Deno Deploy, and Bun.
579
- *
580
- * Routing: somamcp owns the outer Hono app so artifacts and routes registered
581
- * via `createServer` take precedence. Anything unmatched falls through to
582
- * EdgeFastMCP, which serves the MCP endpoint. This ordering matters — EdgeFastMCP
583
- * registers its own `/health` at construction, and Hono is first-match-wins, so
584
- * mounting it first would shadow somamcp's health artifact.
585
- */
586
- declare const createEdgeBackend: <T extends SessionAuth = SessionAuth>(config: ServerConfig<T>, backendOptions?: Record<string, unknown>) => BackendAdapter<T>;
587
- //#endregion
588
- //#region src/telemetry/CompositeTelemetry.d.ts
589
- declare const createCompositeTelemetry: (collectors: ReadonlyArray<TelemetryCollector>) => TelemetryCollector;
590
- //#endregion
591
- //#region src/telemetry/ConsoleTelemetry.d.ts
592
- declare const createConsoleTelemetry: (prefix?: string) => TelemetryCollector;
593
- //#endregion
594
- //#region src/telemetry/EnrichedError.d.ts
595
- type EnrichedErrorResponse = {
596
- errorCategory: ErrorCategory;
597
- message: string;
598
- relatedState?: Record<string, unknown>;
599
- suggestions?: ReadonlyArray<string>;
600
- };
601
- declare const classifyError: (error: unknown) => ErrorCategory;
602
- declare const createEnrichedError: (error: unknown, context?: {
603
- gatewayStatus?: string;
604
- toolName?: string;
605
- }) => EnrichedErrorResponse;
606
- //#endregion
607
- //#region src/telemetry/NoopTelemetry.d.ts
608
- declare const NoopTelemetry: TelemetryCollector;
609
- //#endregion
610
- //#region src/telemetry/telemetryWrapper.d.ts
611
- /**
612
- * Wrap a tool's `execute` in telemetry + error enrichment.
613
- *
614
- * The success path returns the tool's return value **unchanged**, so any of the
615
- * supported shapes reach the backend intact: a plain string, a `ContentResult`
616
- * (`{ content: [...], isError? }`), or a content-array with multimodal parts
617
- * (`{ type: "image", data, mimeType }`, `audio`, `resource`, etc.). Use the
618
- * exported `imageContent` / `audioContent` helpers to build parts without
619
- * reaching into the backend.
620
- *
621
- * The failure path converts an error to a `ContentResult` with `isError: true`
622
- * and the enriched error payload as the text content.
623
- */
624
- declare const wrapTool: <T extends SessionAuth, P extends SchemaParams>(tool: Tool<T, P>, telemetry: TelemetryCollector, captureConfig?: ToolCaptureConfig) => Tool<T, P>;
625
- declare const wrapResource: <T extends SessionAuth>(resource: Resource<T>, telemetry: TelemetryCollector) => Resource<T>;
626
- declare const wrapPrompt: <T extends SessionAuth, Args extends PromptArgument<T>[] = PromptArgument<T>[]>(prompt: Prompt<T, Args>, telemetry: TelemetryCollector) => Prompt<T, Args>;
627
- //#endregion
628
- //#region src/artifacts/ArtifactManager.d.ts
629
- declare const registerArtifacts: (app: Hono, artifacts: ReadonlyArray<ArtifactConfig>, authenticate?: ArtifactAuthenticate) => void;
630
- //#endregion
631
- //#region src/artifacts/DashboardArtifact.d.ts
632
- declare const createDashboardArtifact: (getHealth: () => ServerHealth, getCapabilities: () => ServerCapabilities, getConnections: () => ReadonlyArray<GatewayInfo>) => ArtifactConfig;
633
- //#endregion
634
- //#region src/artifacts/HealthArtifact.d.ts
635
- declare const DEFAULT_HEALTH_PATH = "/health";
636
- declare const DEFAULT_HEALTH_DETAIL_PATH = "/health/detail";
637
- declare const createHealthArtifact: (getHealth: () => ServerHealth, path?: string) => ArtifactConfig;
638
- declare const createHealthDetailArtifact: (getHealth: () => ServerHealth, path?: string) => ArtifactConfig;
639
- //#endregion
640
- //#region src/artifacts/InfoArtifact.d.ts
641
- declare const DEFAULT_INFO_PATH = "/info";
642
- declare const createInfoArtifact: (getInfo: () => ServerInfo, path?: string) => ArtifactConfig;
643
- //#endregion
644
- //#region src/introspection/capabilitiesTool.d.ts
645
- declare const createCapabilitiesTool: <T extends SessionAuth>(getCapabilities: () => ServerCapabilities) => Tool<T>;
646
- //#endregion
647
- //#region src/introspection/connectionsTool.d.ts
648
- declare const createConnectionsTool: <T extends SessionAuth>(getConnections: () => ReadonlyArray<GatewayInfo>) => Tool<T>;
649
- //#endregion
650
- //#region src/introspection/healthTool.d.ts
651
- declare const createHealthTool: <T extends SessionAuth>(getHealth: () => ServerHealth) => Tool<T>;
652
- //#endregion
653
- //#region src/introspection/infoTool.d.ts
654
- declare const createInfoTool: <T extends SessionAuth>(getInfo: () => ServerInfo, name?: string) => Tool<T>;
655
- //#endregion
656
- //#region src/feedback/redaction.d.ts
657
- type RedactionPattern = {
658
- description: string;
659
- name: string;
660
- pattern: RegExp;
661
- replacement?: string;
662
- };
663
- type RedactionResult = {
664
- matches: ReadonlyArray<{
665
- name: string;
666
- count: number;
667
- }>;
668
- redacted: boolean;
669
- text: string;
670
- };
671
- declare const DEFAULT_REDACTION_PATTERNS: ReadonlyArray<RedactionPattern>;
672
- declare const redact: (input: string, patterns?: ReadonlyArray<RedactionPattern>) => RedactionResult;
673
- //#endregion
674
- //#region src/feedback/types.d.ts
675
- type FeedbackType = "bug" | "feature" | "feedback" | "question";
676
- type FeedbackSeverity = "high" | "low" | "medium";
677
- type NormalizedFeedback = {
678
- body: string;
679
- labels: ReadonlyArray<string>;
680
- title: string;
681
- };
682
- type FeedbackSubmitSuccess = {
683
- id?: string;
684
- success: true;
685
- url?: string;
686
- };
687
- type FeedbackSubmitFailure = {
688
- error: string;
689
- success: false;
690
- };
691
- type FeedbackSubmitResult = FeedbackSubmitFailure | FeedbackSubmitSuccess;
692
- type FeedbackProvider = {
693
- readonly name: string;
694
- submit: (payload: NormalizedFeedback) => Promise<FeedbackSubmitResult>;
695
- };
696
- //#endregion
697
- //#region src/feedback/feedbackTool.d.ts
698
- type FeedbackEnrichmentContext = {
699
- type: FeedbackType;
700
- severity?: FeedbackSeverity;
701
- };
702
- type FeedbackToolOptions = {
703
- description?: string;
704
- enrichment?: (ctx: FeedbackEnrichmentContext) => Promise<Record<string, unknown>> | Record<string, unknown>;
705
- extraLabels?: ReadonlyArray<string>;
706
- name?: string;
707
- provider: FeedbackProvider;
708
- redactionPatterns?: ReadonlyArray<RedactionPattern>;
709
- };
710
- declare const PARAMETERS: z.ZodObject<{
711
- description: z.ZodString;
712
- severity: z.ZodOptional<z.ZodEnum<{
713
- low: "low";
714
- medium: "medium";
715
- high: "high";
716
- }>>;
717
- title: z.ZodString;
718
- type: z.ZodDefault<z.ZodEnum<{
719
- bug: "bug";
720
- feature: "feature";
721
- feedback: "feedback";
722
- question: "question";
723
- }>>;
724
- }, z.core.$strip>;
725
- declare const createFeedbackTool: <T extends SessionAuth>(options: FeedbackToolOptions) => Tool<T, typeof PARAMETERS>;
726
- //#endregion
727
- //#region src/feedback/providers/github.d.ts
728
- type GithubFeedbackOptions = {
729
- baseUrl?: string;
730
- defaultLabels?: ReadonlyArray<string>;
731
- fetchImpl?: typeof fetch;
732
- getToken: () => Option<string>;
733
- repo: `${string}/${string}`;
734
- };
735
- declare const createGithubFeedback: (options: GithubFeedbackOptions) => FeedbackProvider;
736
- //#endregion
737
- //#region src/feedback/providers/webhook.d.ts
738
- type WebhookFeedbackOptions = {
739
- fetchImpl?: typeof fetch;
740
- headers?: Record<string, string>;
741
- transform?: (payload: NormalizedFeedback) => unknown;
742
- url: string;
743
- };
744
- declare const createWebhookFeedback: (options: WebhookFeedbackOptions) => FeedbackProvider;
745
- //#endregion
746
- //#region src/gateway/Gateway.d.ts
747
- declare const createGateway: (config: GatewayConfig, telemetry: TelemetryCollector) => GatewayInstance;
748
- //#endregion
749
- //#region src/gateway/GatewayManager.d.ts
750
- declare const createGatewayManager: (telemetry: TelemetryCollector) => GatewayManagerInstance;
751
- //#endregion
752
- //#region src/gateway/toolProxy.d.ts
753
- declare const createProxiedTools: <T extends SessionAuth>(gateway: GatewayInstance, telemetry?: TelemetryCollector) => ReadonlyArray<Tool<T>>;
754
- //#endregion
755
- //#region src/edge.d.ts
756
- /**
757
- * Create a server backed by the edge runtime adapter. Identical to the `somamcp`
758
- * `createServer` except that `backend` defaults to `createEdgeBackend`.
759
- *
760
- * ```ts
761
- * const server = createServer({ name: "my-server", version: "1.0.0" })
762
- * export default { fetch: (req: Request) => server.fetch(req) }
763
- * ```
764
- */
765
- declare const createServer: <T extends SessionAuth = SessionAuth>(options: SomaServerOptions<T>) => SomaServerInstance<T>;
766
- //#endregion
767
- export { type ArtifactAuthenticate, type ArtifactConfig, type AudioContent, type AuthMiddlewareConfig, type Authenticate, type BackendAdapter, type BackendFactory, type BackendSession, type BuildInfo, type CapabilitiesSummary, type CaptureLevel, type Completion, type Content, type ContentResult, type Context, DEFAULT_HEALTH_DETAIL_PATH, DEFAULT_HEALTH_PATH, DEFAULT_INFO_PATH, DEFAULT_REDACTION_PATTERNS, type DirectoryArtifact, type DynamicArtifact, type EdgeBackendOptions, type EnrichedErrorResponse, type ErrorCategory, type FeedbackEnrichmentContext, type FeedbackProvider, type FeedbackSeverity, type FeedbackSubmitFailure, type FeedbackSubmitResult, type FeedbackSubmitSuccess, type FeedbackToolOptions, type FeedbackType, type GatewayConfig, type GatewayInfo, type GatewayInstance, type GatewayManagerInstance, type GatewayStatus, type GithubFeedbackOptions, type HttpStreamConfig, type ImageContent, type InferSchemaOutput, type Logger, NoopTelemetry, type NormalizedFeedback, type OnUnauthorized, type Progress, type Prompt, type PromptArgument, type PromptResult, type RedactionPattern, type RedactionResult, type Resource, type ResourceContent, type ResourceLink, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteConfig, type RouteMethod, type RuntimeInfo, type SchemaParams, type ServerCapabilities, type ServerConfig, type ServerHealth, type ServerInfo, type ServerStatus, type SessionAuth, type SomaServerInstance, type SomaServerOptions, type StaticArtifact, type TelemetryCollector, type TelemetryEvent, type TelemetryEventType, type TextContent, type Tool, type ToolAnnotations, type ToolCaptureConfig, type ToolOptions, type TransportConfig, UserError, type WebhookFeedbackOptions, classifyError, createAuthMiddleware, createCapabilitiesTool, createCompositeTelemetry, createConnectionsTool, createConsoleTelemetry, createDashboardArtifact, createEdgeBackend, createEnrichedError, createFeedbackTool, createGateway, createGatewayManager, createGithubFeedback, createHealthArtifact, createHealthDetailArtifact, createHealthTool, createInfoArtifact, createInfoTool, createProxiedTools, createServer, createServerCore, createWebhookFeedback, getRequestHeader, getRuntimeInfo, readBuildInfoFromEnv, redact, registerArtifacts, resolveBuildInfo, wrapPrompt, wrapResource, wrapTool };
1
+ import { A as SessionAuth, C as ResourceContent, D as ResourceTemplateArgument, E as ResourceTemplate, M as Tool, N as ToolAnnotations, O as SchemaParams, P as UserError, S as Resource, T as ResourceResult, _ as InferSchemaOutput, a as BackendFactory, b as PromptArgument, c as Logger, d as AudioContent, f as Completion, g as ImageContent, h as Context, j as TextContent, k as ServerStatus, l as ServerConfig, m as ContentResult, n as createSdkBackend, o as BackendSession, p as Content, r as BackendAdapter, s as HttpStreamConfig, t as SdkBackendOptions, u as TransportConfig, v as Progress, w as ResourceLink, x as PromptResult, y as Prompt } from "./index-ololl9dI.js";
2
+ import { $ as ServerHealth, A as DEFAULT_HEALTH_DETAIL_PATH, At as DynamicArtifact, B as NoopTelemetry, C as redact, Ct as RuntimeInfo, D as createCapabilitiesTool, Dt as ArtifactAuthenticate, E as createConnectionsTool, Et as resolveBuildInfo, F as registerArtifacts, G as createConsoleTelemetry, H as EnrichedErrorResponse, I as createDefaultLogger, J as audioContent, K as createCompositeTelemetry, L as wrapPrompt, M as createHealthArtifact, N as createHealthDetailArtifact, O as DEFAULT_INFO_PATH, Ot as ArtifactConfig, P as createDashboardArtifact, Q as ServerCapabilities, R as wrapResource, S as RedactionResult, St as BuildInfo, T as createHealthTool, Tt as readBuildInfoFromEnv, U as classifyError, V as createLogLayerTelemetry, W as createEnrichedError, X as createServerCore, Y as imageContent, Z as CapabilitiesSummary, _ as FeedbackSubmitSuccess, _t as GatewayConfig, a as createGateway, at as RouteMethod, b as DEFAULT_REDACTION_PATTERNS, bt as GatewayManagerInstance, c as GithubFeedbackOptions, ct as Authenticate, d as FeedbackToolOptions, dt as CaptureLevel, et as ServerInfo, f as createFeedbackTool, ft as ErrorCategory, g as FeedbackSubmitResult, gt as ToolCaptureConfig, h as FeedbackSubmitFailure, ht as TelemetryEventType, i as createGatewayManager, it as RouteConfig, j as DEFAULT_HEALTH_PATH, jt as StaticArtifact, k as createInfoArtifact, kt as DirectoryArtifact, l as createGithubFeedback, lt as OnUnauthorized, m as FeedbackSeverity, mt as TelemetryEvent, n as createServer, nt as SomaServerOptions, o as WebhookFeedbackOptions, ot as getRequestHeader, p as FeedbackProvider, pt as TelemetryCollector, q as ContentInput, r as createProxiedTools, rt as ToolOptions, s as createWebhookFeedback, st as AuthMiddlewareConfig, t as DirectLogger, tt as SomaServerInstance, u as FeedbackEnrichmentContext, ut as createAuthMiddleware, v as FeedbackType, vt as GatewayInfo, w as createInfoTool, wt as getRuntimeInfo, x as RedactionPattern, xt as GatewayStatus, y as NormalizedFeedback, yt as GatewayInstance, z as wrapTool } from "./index-aVpYZPUq.js";
3
+ export { type ArtifactAuthenticate, type ArtifactConfig, type AudioContent, type AuthMiddlewareConfig, type Authenticate, type BackendAdapter, type BackendFactory, type BackendSession, type BuildInfo, type CapabilitiesSummary, type CaptureLevel, type Completion, type Content, type ContentInput, type ContentResult, type Context, DEFAULT_HEALTH_DETAIL_PATH, DEFAULT_HEALTH_PATH, DEFAULT_INFO_PATH, DEFAULT_REDACTION_PATTERNS, type DirectLogger, type DirectoryArtifact, type DynamicArtifact, type EnrichedErrorResponse, type ErrorCategory, type FeedbackEnrichmentContext, type FeedbackProvider, type FeedbackSeverity, type FeedbackSubmitFailure, type FeedbackSubmitResult, type FeedbackSubmitSuccess, type FeedbackToolOptions, type FeedbackType, type GatewayConfig, type GatewayInfo, type GatewayInstance, type GatewayManagerInstance, type GatewayStatus, type GithubFeedbackOptions, type HttpStreamConfig, type ImageContent, type InferSchemaOutput, type Logger, NoopTelemetry, type NormalizedFeedback, type OnUnauthorized, type Progress, type Prompt, type PromptArgument, type PromptResult, type RedactionPattern, type RedactionResult, type Resource, type ResourceContent, type ResourceLink, type ResourceResult, type ResourceTemplate, type ResourceTemplateArgument, type RouteConfig, type RouteMethod, type RuntimeInfo, type SchemaParams, type SdkBackendOptions, type ServerCapabilities, type ServerConfig, type ServerHealth, type ServerInfo, type ServerStatus, type SessionAuth, type SomaServerInstance, type SomaServerOptions, type StaticArtifact, type TelemetryCollector, type TelemetryEvent, type TelemetryEventType, type TextContent, type Tool, type ToolAnnotations, type ToolCaptureConfig, type ToolOptions, type TransportConfig, UserError, type WebhookFeedbackOptions, audioContent, classifyError, createAuthMiddleware, createCapabilitiesTool, createCompositeTelemetry, createConnectionsTool, createConsoleTelemetry, createDashboardArtifact, createDefaultLogger, createEnrichedError, createFeedbackTool, createGateway, createGatewayManager, createGithubFeedback, createHealthArtifact, createHealthDetailArtifact, createHealthTool, createInfoArtifact, createInfoTool, createLogLayerTelemetry, createProxiedTools, createSdkBackend, createServer, createServerCore, createWebhookFeedback, getRequestHeader, getRuntimeInfo, imageContent, readBuildInfoFromEnv, redact, registerArtifacts, resolveBuildInfo, wrapPrompt, wrapResource, wrapTool };