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.
@@ -1,6 +1,6 @@
1
1
  import { Transport } from "@modelcontextprotocol/server";
2
+ import { Option } from "functype";
2
3
  import { Hono } from "hono";
3
- //#region src/types/core.d.ts
4
4
  type SessionAuth = Record<string, unknown> | undefined;
5
5
  /**
6
6
  * Structural type compatible with StandardSchemaV1 (zod, valibot, etc.)
@@ -170,8 +170,6 @@ type ServerStatus = "error" | "running" | "stopped";
170
170
  declare class UserError extends Error {
171
171
  constructor(message: string);
172
172
  }
173
- //#endregion
174
- //#region src/types/server.d.ts
175
173
  type Logger = {
176
174
  debug: (...args: unknown[]) => void;
177
175
  error: (...args: unknown[]) => void;
@@ -180,7 +178,17 @@ type Logger = {
180
178
  warn: (...args: unknown[]) => void;
181
179
  };
182
180
  type ServerConfig<T extends SessionAuth = SessionAuth> = {
183
- authenticate?: (request: unknown) => Promise<T>;
181
+ /**
182
+ * Authenticate a request; resolve to the session that tools see as `context.session`.
183
+ * Rejecting, throwing, or resolving to `undefined`/`null` fails it with a 401. On the
184
+ * MCP endpoint, reject with a `Response` to send that instead; protected artifacts and
185
+ * routes answer with their `onUnauthorized`, or 401.
186
+ *
187
+ * Receives the web `Request` for MCP calls and for protected artifacts and routes, on
188
+ * every runtime. On stdio there is no request: it is called once with `undefined`, and
189
+ * a failure serves without a session. Read headers with `getRequestHeader`.
190
+ */
191
+ authenticate?: (request: Request | undefined) => Promise<T>;
184
192
  instructions?: string;
185
193
  logger?: Logger;
186
194
  name: string;
@@ -189,44 +197,35 @@ type ServerConfig<T extends SessionAuth = SessionAuth> = {
189
197
  * balancer does not close the connection as idle while a long-running tool produces no
190
198
  * output — a large document read, say.
191
199
  *
192
- * This is the only keepalive that survives `httpStream.stateless`. A transport-level ping
193
- * needs the standing server-to-client stream, and stateless has none; these travel on the
194
- * request's own stream instead. If you set `stateless` and have anything with an idle
195
- * timeout in front of you, you want this too.
200
+ * They are SSE comment frames on the request's own stream, so they work although the
201
+ * server keeps no sessions. With this on, every response streams as SSE, because a JSON
202
+ * response cannot carry them.
196
203
  *
197
- * Set at construction rather than on `httpStream`, because the backend builds its server
204
+ * Set at construction rather than on `httpStream`, because the backend builds its handler
198
205
  * before `start()` ever sees the transport config.
199
- *
200
- * Honoured by the fastmcp backend. The edge backend ignores it — Workers and Deno Deploy
201
- * terminate the connection themselves, so there is nothing for somamcp to keep alive.
202
206
  */
203
207
  streamKeepalive?: {
204
208
  /** Whether to write keepalives. Opt-in. */
205
209
  enabled?: boolean;
206
210
  /**
207
211
  * Gap between keepalives. Keep it comfortably under the shortest idle timeout on the
208
- * path — an AWS ALB defaults to 60s. Defaults to 20s in the fastmcp backend.
212
+ * path — an AWS ALB defaults to 60s. Defaults to 20s.
209
213
  */
210
214
  intervalMs?: number;
211
- /**
212
- * Level reported on the keepalive notification. Defaults to `debug` in the fastmcp
213
- * backend, which is usually what you want — these fire every interval, for the whole
214
- * length of every long call.
215
- */
216
- logLevel?: "alert" | "critical" | "debug" | "emergency" | "error" | "info" | "notice" | "warning";
217
215
  };
218
216
  version: `${number}.${number}.${number}`;
219
217
  };
220
218
  /**
221
- * httpStream transport options. All fields are passed through to the underlying
222
- * MCP backend unchanged; `port` is the only one required.
219
+ * Options for listening on a port, which needs `somamcp/node`. `port` is the only
220
+ * required field.
223
221
  *
224
- * - `cors` — `true` for permissive defaults, or a config object forwarded to the
225
- * backend's CORS implementation. Only relevant for browser-facing servers.
226
- * - `stateless` — treat each request independently (no session state). Useful
227
- * for horizontally-scaled or Lambda-style deployments.
228
- * - `eventStore` — pluggable store enabling resumable event streams; the
229
- * backend's `EventStore` interface, opaque to somamcp.
222
+ * - `cors` — `true` for permissive defaults, or options for Hono's `cors()`. Only
223
+ * relevant for browser-facing servers.
224
+ * - `enableJsonResponse` — answer `2026-07-28` requests with JSON instead of SSE.
225
+ * It turns `streamKeepalive` off, since JSON cannot carry keepalive frames.
226
+ * - `endpoint` — the MCP path. Defaults to `/mcp`.
227
+ * - `host` — the address to bind. Defaults to `localhost`; set `0.0.0.0` in a container.
228
+ * - `stateless` — serving is always stateless; `false` logs a warning and is ignored.
230
229
  * - `sslCert` / `sslKey` / `sslCa` — inline PEM strings enabling TLS termination
231
230
  * at the server. Omit for plain HTTP behind a proxy.
232
231
  */
@@ -234,7 +233,6 @@ type HttpStreamConfig = {
234
233
  cors?: boolean | Record<string, unknown>;
235
234
  enableJsonResponse?: boolean;
236
235
  endpoint?: `/${string}`;
237
- eventStore?: unknown;
238
236
  host?: string;
239
237
  port: number;
240
238
  sslCa?: string;
@@ -248,8 +246,6 @@ type TransportConfig = {
248
246
  httpStream: HttpStreamConfig;
249
247
  transportType: "httpStream";
250
248
  };
251
- //#endregion
252
- //#region src/backend/adapter.d.ts
253
249
  type BackendSession<T extends SessionAuth = SessionAuth> = {
254
250
  sessionId?: string;
255
251
  auth?: T;
@@ -267,12 +263,11 @@ type BackendAdapter<T extends SessionAuth = SessionAuth> = {
267
263
  readonly sessions: ReadonlyArray<BackendSession<T>>;
268
264
  addPrompt: <Args extends PromptArgument<T>[]>(prompt: Prompt<T, Args>) => void;
269
265
  addResource: (resource: Resource<T>) => void;
270
- addResourceTemplate: (...args: ReadonlyArray<unknown>) => void;
266
+ addResourceTemplate: (template: ResourceTemplate<T>) => void;
271
267
  addTool: <P extends SchemaParams>(tool: Tool<T, P>) => void;
272
268
  /**
273
269
  * Handle a web-standard Request. Optional: when absent, callers fall back to
274
- * `getApp().fetch`. Edge backends implement this as their primary entry point;
275
- * Node backends provide it for parity so `SomaServerInstance.fetch` always works.
270
+ * `getApp().fetch`. The SDK backend implements it as its primary entry point.
276
271
  */
277
272
  fetch?: (request: Request) => Promise<Response>;
278
273
  getApp: () => Hono;
@@ -281,9 +276,8 @@ type BackendAdapter<T extends SessionAuth = SessionAuth> = {
281
276
  * Whether `removeTool` / `removeResource` / `removePrompt` actually take
282
277
  * effect. Defaults to true when absent.
283
278
  *
284
- * The edge backend sets this false: EdgeFastMCP exposes no removal API, so its
285
- * `remove*` calls only warn. Capability counts must not shrink for a tool that
286
- * is still being served.
279
+ * A backend that cannot remove sets this false, so capability counts do not
280
+ * shrink for a tool that is still being served.
287
281
  */
288
282
  readonly supportsRemoval?: boolean;
289
283
  removePrompt: (name: string) => void;
@@ -293,16 +287,11 @@ type BackendAdapter<T extends SessionAuth = SessionAuth> = {
293
287
  stop: () => Promise<void>;
294
288
  };
295
289
  type BackendFactory<T extends SessionAuth = SessionAuth> = (config: ServerConfig<T>, backendOptions?: Record<string, unknown>) => BackendAdapter<T>;
296
- //#endregion
297
- //#region src/backend/fastmcp.d.ts
298
- declare const createFastMCPBackend: <T extends SessionAuth = SessionAuth>(config: ServerConfig<T>, backendOptions?: Record<string, unknown>) => BackendAdapter<T>;
299
- //#endregion
300
- //#region src/backend/sdk/index.d.ts
301
290
  type SdkBackendOptions = {
302
291
  /** MCP endpoint path when serving through `fetch`. `start({ httpStream: { endpoint } })` overrides it. Defaults to "/mcp". */
303
292
  mcpPath?: string;
304
293
  /**
305
- * Transport for `start({ transportType: "stdio" })` in place of the process's
294
+ * Node only (`somamcp/node`): transport for `start({ transportType: "stdio" })` in place of the process's
306
295
  * stdin/stdout, e.g. a `StdioServerTransport` over a Unix socket.
307
296
  */
308
297
  stdioTransport?: Transport;
@@ -316,9 +305,9 @@ type SdkBackendOptions = {
316
305
  * so there are no sessions, `connect`/`disconnect` never fire, and a 2025 client's
317
306
  * GET or DELETE is answered `405`.
318
307
  *
319
- * `start()` serves a port (`httpStream`) or stdio on Node; `fetch()` serves any
320
- * runtime with web-standard `Request`/`Response`.
308
+ * This is the WinterTC build: it serves through `fetch()` on any runtime with
309
+ * web-standard `Request`/`Response`, and `start()` with a transport rejects. For a
310
+ * port or stdio, use `createNodeBackend` from `somamcp/node`.
321
311
  */
322
312
  declare const createSdkBackend: <T extends SessionAuth = SessionAuth>(config: ServerConfig<T>, backendOptions?: Record<string, unknown>) => BackendAdapter<T>;
323
- //#endregion
324
- export { ServerStatus as A, Resource as C, ResourceTemplate as D, ResourceResult as E, UserError as F, TextContent as M, Tool as N, ResourceTemplateArgument as O, ToolAnnotations as P, PromptResult as S, ResourceLink as T, ImageContent as _, BackendEvents as a, Prompt as b, HttpStreamConfig as c, TransportConfig as d, AudioContent as f, Context$1 as g, ContentResult as h, BackendAdapter as i, SessionAuth as j, SchemaParams as k, Logger as l, Content as m, createSdkBackend as n, BackendFactory as o, Completion as p, createFastMCPBackend as r, BackendSession as s, SdkBackendOptions as t, ServerConfig as u, InferSchemaOutput as v, ResourceContent as w, PromptArgument as x, Progress as y };
313
+ export { SessionAuth as A, ResourceContent as C, ResourceTemplateArgument as D, ResourceTemplate as E, Tool as M, ToolAnnotations as N, SchemaParams as O, UserError as P, Resource as S, ResourceResult as T, InferSchemaOutput as _, BackendFactory as a, PromptArgument as b, Logger as c, AudioContent as d, Completion as f, ImageContent as g, Context$1 as h, BackendEvents as i, TextContent as j, ServerStatus as k, ServerConfig as l, ContentResult as m, createSdkBackend as n, BackendSession as o, Content as p, BackendAdapter as r, HttpStreamConfig as s, SdkBackendOptions as t, TransportConfig as u, Progress as v, ResourceLink as w, PromptResult as x, Prompt as y };
package/dist/index.d.ts CHANGED
@@ -1,474 +1,3 @@
1
- import { A as ServerStatus, C as Resource, D as ResourceTemplate, E as ResourceResult, F as UserError, M as TextContent, N as Tool, O as ResourceTemplateArgument, P as ToolAnnotations, S as PromptResult, T as ResourceLink, _ as ImageContent, b as Prompt, c as HttpStreamConfig, d as TransportConfig, f as AudioContent, g as Context, h as ContentResult, i as BackendAdapter, j as SessionAuth, k as SchemaParams, l as Logger, m as Content, o as BackendFactory, p as Completion, r as createFastMCPBackend, s as BackendSession, u as ServerConfig, v as InferSchemaOutput, w as ResourceContent, x as PromptArgument, y as Progress } from "./index-C2wa9nmp.js";
2
- import { Option } from "functype";
3
- import { Context as Context$1, Hono, MiddlewareHandler } from "hono";
4
- import { DirectLogger, DirectLogger as DirectLogger$1 } from "functype-log";
5
- import { z } from "zod";
6
- import { Tool as Tool$1 } from "@modelcontextprotocol/sdk/types.js";
7
- //#region src/artifacts/types.d.ts
8
- type ArtifactCommon = {
9
- protected?: boolean;
10
- };
11
- type StaticArtifact = ArtifactCommon & {
12
- contentType: string;
13
- content: string;
14
- path: string;
15
- type: "static";
16
- };
17
- type DynamicArtifact = ArtifactCommon & {
18
- handler: (c: Context$1) => Response | Promise<Response>;
19
- path: string;
20
- type: "dynamic";
21
- };
22
- type DirectoryArtifact = ArtifactCommon & {
23
- directory: string;
24
- path: string;
25
- type: "directory";
26
- };
27
- type ArtifactConfig = DirectoryArtifact | DynamicArtifact | StaticArtifact;
28
- type ArtifactAuthenticate = (request: unknown) => Promise<unknown>;
29
- //#endregion
30
- //#region src/buildInfo.d.ts
31
- type BuildInfo = {
32
- branch?: string;
33
- commit?: string;
34
- date?: string;
35
- environment?: string;
36
- };
37
- type RuntimeInfo = {
38
- arch: string;
39
- nodeVersion: string;
40
- platform: string;
41
- /** Which runtime family reported the fields above. Absent on pre-1.2 builds. */
42
- runtime?: "edge" | "node";
43
- };
44
- declare const readBuildInfoFromEnv: () => BuildInfo;
45
- declare const resolveBuildInfo: (override?: BuildInfo) => BuildInfo;
46
- declare const getRuntimeInfo: () => RuntimeInfo;
47
- //#endregion
48
- //#region src/gateway/types.d.ts
49
- type GatewayConfig = {
50
- id: string;
51
- name?: string;
52
- proxyTools?: boolean;
53
- reconnect?: boolean;
54
- reconnectIntervalMs?: number;
55
- toolPrefix?: string;
56
- url: string;
57
- };
58
- type GatewayStatus = "connected" | "connecting" | "disconnected" | "error";
59
- type GatewayInfo = {
60
- id: string;
61
- name: string;
62
- remoteTools: ReadonlyArray<{
63
- description?: string;
64
- name: string;
65
- }>;
66
- status: GatewayStatus;
67
- url: string;
68
- };
69
- type GatewayInstance = {
70
- readonly config: GatewayConfig;
71
- readonly info: GatewayInfo;
72
- readonly name: string;
73
- readonly status: GatewayStatus;
74
- readonly tools: ReadonlyArray<Tool$1>;
75
- callTool: (name: string, args?: Record<string, unknown>) => Promise<unknown>;
76
- connect: () => Promise<void>;
77
- disconnect: () => Promise<void>;
78
- };
79
- type GatewayManagerInstance = {
80
- readonly connectedCount: number;
81
- readonly totalCount: number;
82
- add: (config: GatewayConfig) => GatewayInstance;
83
- connectAll: () => Promise<void>;
84
- disconnectAll: () => Promise<void>;
85
- get: (id: string) => Option<GatewayInstance>;
86
- getAll: () => ReadonlyArray<GatewayInstance>;
87
- getInfoAll: () => ReadonlyArray<GatewayInfo>;
88
- };
89
- //#endregion
90
- //#region src/telemetry/TelemetryCollector.d.ts
91
- 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";
92
- type ErrorCategory = "validation" | "timeout" | "gateway" | "internal" | "auth" | "not_found";
93
- type CaptureLevel = "full" | "metadata" | "none";
94
- type ToolCaptureConfig = {
95
- captureLevel?: CaptureLevel;
96
- maxOutputSize?: number;
97
- redactInputFields?: ReadonlyArray<string>;
98
- };
99
- type TelemetryEvent = {
100
- data?: Record<string, unknown>;
101
- durationMs?: number;
102
- error?: string;
103
- errorCategory?: ErrorCategory;
104
- errorStack?: string;
105
- input?: Record<string, unknown>;
106
- name: string;
107
- output?: unknown;
108
- requestId?: string;
109
- sessionId?: string;
110
- timestamp: number;
111
- type: TelemetryEventType;
112
- };
113
- type TelemetryCollector = {
114
- flush?: () => Promise<void>;
115
- recordEvent: (event: TelemetryEvent) => void;
116
- };
117
- //#endregion
118
- //#region src/auth/middleware.d.ts
119
- /**
120
- * Callback invoked to authenticate an incoming request. Receives either a Hono
121
- * `Request` (custom routes / protected artifacts) or an `http.IncomingMessage`
122
- * (MCP transport). Use `getRequestHeader` to hide the shape difference.
123
- */
124
- type Authenticate = (request: unknown) => Promise<unknown>;
125
- /** Response builder invoked when auth is missing or fails. Defaults to `401 { error: "Unauthorized" }`. */
126
- type OnUnauthorized = (c: Context$1) => Response | Promise<Response>;
127
- type AuthMiddlewareConfig = {
128
- authenticate?: Authenticate;
129
- onUnauthorized?: OnUnauthorized;
130
- };
131
- declare const createAuthMiddleware: ({ authenticate, onUnauthorized }: AuthMiddlewareConfig) => MiddlewareHandler;
132
- //#endregion
133
- //#region src/auth/request.d.ts
134
- /**
135
- * Extract a header from either shape somamcp's `authenticate` callback may receive:
136
- *
137
- * - **Hono `Request`** (`c.req.raw`) — used on protected artifact and custom routes.
138
- * Headers implement the WHATWG `Headers` interface (`.get(name)`).
139
- * - **`http.IncomingMessage`** — used on the MCP transport path (FastMCP).
140
- * Headers are a plain lowercased object; values may be `string | string[]`.
141
- *
142
- * Case-insensitive on the header name. Returns `undefined` when the header is
143
- * absent or the request shape is not recognized — matches the `Headers.get`
144
- * shape callers already write against.
145
- */
146
- declare const getRequestHeader: (request: unknown, name: string) => string | undefined;
147
- //#endregion
148
- //#region src/types/routes.d.ts
149
- type RouteMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
150
- /**
151
- * Config for a custom HTTP route registered on the server's Hono app via
152
- * `SomaServerInstance.addRoute`.
153
- *
154
- * When `protected: true`, the server's `authenticate` callback runs first — a
155
- * throw or rejection short-circuits to `onUnauthorized` (default `401`).
156
- *
157
- * ### Route ordering
158
- *
159
- * Hono dispatches by registration order. `addRoute` registers immediately, so
160
- * routes added **before** `start()` land alongside artifacts and introspection
161
- * routes in call order. For concrete non-overlapping paths this doesn't matter;
162
- * for wildcards or overlapping prefixes, register earlier to take precedence.
163
- */
164
- type RouteConfig = {
165
- method: RouteMethod | ReadonlyArray<RouteMethod>;
166
- path: `/${string}`;
167
- protected?: boolean;
168
- handler: (c: Context$1) => Response | Promise<Response>;
169
- onUnauthorized?: OnUnauthorized;
170
- };
171
- //#endregion
172
- //#region src/types.d.ts
173
- type SomaServerOptions<T extends SessionAuth = SessionAuth> = ServerConfig<T> & {
174
- artifacts?: ArtifactConfig[];
175
- /**
176
- * Backend implementation. Defaults to `createFastMCPBackend` (Node).
177
- * Pass `createEdgeBackend` from `somamcp/edge` to target Cloudflare Workers,
178
- * Deno Deploy, or Bun.
179
- */
180
- backend?: BackendFactory<T>;
181
- backendOptions?: Record<string, unknown>;
182
- build?: BuildInfo;
183
- enableDashboard?: boolean;
184
- enableHealthEndpoint?: boolean;
185
- enableInfoEndpoint?: boolean;
186
- enableIntrospection?: boolean;
187
- gateways?: GatewayConfig[];
188
- healthDetailPath?: string;
189
- healthPath?: string;
190
- infoPath?: string;
191
- introspectionPrefix?: string;
192
- logLayer?: DirectLogger$1;
193
- telemetry?: TelemetryCollector;
194
- };
195
- type ServerHealth = {
196
- activeSessions: number;
197
- gateways: {
198
- connected: number;
199
- total: number;
200
- };
201
- name: string;
202
- startedAt: number;
203
- status: ServerStatus;
204
- uptime: number;
205
- };
206
- type ServerCapabilities = {
207
- prompts: ReadonlyArray<{
208
- description?: string;
209
- name: string;
210
- }>;
211
- resources: ReadonlyArray<{
212
- description?: string;
213
- name: string;
214
- uri: string;
215
- }>;
216
- tools: ReadonlyArray<{
217
- description?: string;
218
- name: string;
219
- }>;
220
- };
221
- type CapabilitiesSummary = {
222
- prompts: number;
223
- resources: number;
224
- tools: number;
225
- };
226
- type ServerInfo = {
227
- build: BuildInfo;
228
- capabilities: CapabilitiesSummary;
229
- name: string;
230
- runtime: RuntimeInfo;
231
- version: string;
232
- };
233
- type ToolOptions<T extends SessionAuth = SessionAuth, P extends SchemaParams = SchemaParams> = Tool<T, P> & {
234
- captureConfig?: ToolCaptureConfig;
235
- };
236
- type SomaServerInstance<T extends SessionAuth = SessionAuth> = {
237
- readonly name: string;
238
- readonly serverState: ServerStatus;
239
- readonly sessions: ReadonlyArray<BackendSession<T>>;
240
- addPrompt: <Args extends PromptArgument<T>[]>(prompt: Prompt<T, Args>) => void;
241
- addPrompts: <Args extends PromptArgument<T>[]>(prompts: Prompt<T, Args>[]) => void;
242
- addResource: (resource: Resource<T>) => void;
243
- addResources: (resources: Resource<T>[]) => void;
244
- addResourceTemplate: (...args: ReadonlyArray<unknown>) => void;
245
- addRoute: (route: RouteConfig) => void;
246
- addTool: <P extends SchemaParams>(tool: Tool<T, P>) => void;
247
- addTools: <P extends SchemaParams>(tools: Tool<T, P>[]) => void;
248
- /**
249
- * Web-standard request handler covering both MCP calls and registered
250
- * artifacts/routes. This is the entry point for edge runtimes:
251
- * `export default { fetch: (req) => server.fetch(req) }`.
252
- */
253
- fetch: (request: Request) => Promise<Response>;
254
- getApp: () => Hono;
255
- getCapabilities: () => ServerCapabilities;
256
- getGatewayManager: () => GatewayManagerInstance;
257
- getHealth: () => ServerHealth;
258
- getInfo: () => ServerInfo;
259
- removePrompt: (name: string) => void;
260
- removeResource: (name: string) => void;
261
- removeTool: (name: string) => void;
262
- start: (options?: TransportConfig) => Promise<void>;
263
- stop: () => Promise<void>;
264
- };
265
- //#endregion
266
- //#region src/Server.d.ts
267
- /**
268
- * Backend-agnostic server core.
269
- *
270
- * `backend` is required here on purpose. Defaulting it would mean a static import
271
- * of the Node FastMCP backend, which lands in every bundle that reaches this
272
- * module — including `somamcp/edge`. The entry barrels supply the default instead:
273
- * `somamcp` binds createFastMCPBackend, `somamcp/edge` binds createEdgeBackend.
274
- */
275
- declare const createServerCore: <T extends SessionAuth = SessionAuth>(options: SomaServerOptions<T> & {
276
- backend: BackendFactory<T>;
277
- }) => SomaServerInstance<T>;
278
- //#endregion
279
- //#region src/content/helpers.d.ts
280
- type ContentInput = {
281
- buffer: Buffer;
282
- } | {
283
- path: string;
284
- } | {
285
- url: string;
286
- };
287
- declare const imageContent: (input: ContentInput) => Promise<ImageContent>;
288
- declare const audioContent: (input: ContentInput) => Promise<AudioContent>;
289
- //#endregion
290
- //#region src/telemetry/CompositeTelemetry.d.ts
291
- declare const createCompositeTelemetry: (collectors: ReadonlyArray<TelemetryCollector>) => TelemetryCollector;
292
- //#endregion
293
- //#region src/telemetry/ConsoleTelemetry.d.ts
294
- declare const createConsoleTelemetry: (prefix?: string) => TelemetryCollector;
295
- //#endregion
296
- //#region src/telemetry/EnrichedError.d.ts
297
- type EnrichedErrorResponse = {
298
- errorCategory: ErrorCategory;
299
- message: string;
300
- relatedState?: Record<string, unknown>;
301
- suggestions?: ReadonlyArray<string>;
302
- };
303
- declare const classifyError: (error: unknown) => ErrorCategory;
304
- declare const createEnrichedError: (error: unknown, context?: {
305
- gatewayStatus?: string;
306
- toolName?: string;
307
- }) => EnrichedErrorResponse;
308
- //#endregion
309
- //#region src/telemetry/JsonFileTelemetry.d.ts
310
- type JsonFileTelemetryOptions = {
311
- filePath: string;
312
- flushIntervalMs?: number;
313
- };
314
- declare const createJsonFileTelemetry: (options: JsonFileTelemetryOptions) => TelemetryCollector;
315
- //#endregion
316
- //#region src/telemetry/LogLayerTelemetry.d.ts
317
- declare const createLogLayerTelemetry: (logger: DirectLogger$1) => TelemetryCollector;
318
- //#endregion
319
- //#region src/telemetry/NoopTelemetry.d.ts
320
- declare const NoopTelemetry: TelemetryCollector;
321
- //#endregion
322
- //#region src/telemetry/telemetryWrapper.d.ts
323
- /**
324
- * Wrap a tool's `execute` in telemetry + error enrichment.
325
- *
326
- * The success path returns the tool's return value **unchanged**, so any of the
327
- * supported shapes reach the backend intact: a plain string, a `ContentResult`
328
- * (`{ content: [...], isError? }`), or a content-array with multimodal parts
329
- * (`{ type: "image", data, mimeType }`, `audio`, `resource`, etc.). Use the
330
- * exported `imageContent` / `audioContent` helpers to build parts without
331
- * reaching into the backend.
332
- *
333
- * The failure path converts an error to a `ContentResult` with `isError: true`
334
- * and the enriched error payload as the text content.
335
- */
336
- declare const wrapTool: <T extends SessionAuth, P extends SchemaParams>(tool: Tool<T, P>, telemetry: TelemetryCollector, captureConfig?: ToolCaptureConfig) => Tool<T, P>;
337
- declare const wrapResource: <T extends SessionAuth>(resource: Resource<T>, telemetry: TelemetryCollector) => Resource<T>;
338
- declare const wrapPrompt: <T extends SessionAuth, Args extends PromptArgument<T>[] = PromptArgument<T>[]>(prompt: Prompt<T, Args>, telemetry: TelemetryCollector) => Prompt<T, Args>;
339
- //#endregion
340
- //#region src/logging.d.ts
341
- declare const createDefaultLogger: (name: string) => DirectLogger$1;
342
- //#endregion
343
- //#region src/artifacts/ArtifactManager.d.ts
344
- declare const registerArtifacts: (app: Hono, artifacts: ReadonlyArray<ArtifactConfig>, authenticate?: ArtifactAuthenticate) => void;
345
- //#endregion
346
- //#region src/artifacts/DashboardArtifact.d.ts
347
- declare const createDashboardArtifact: (getHealth: () => ServerHealth, getCapabilities: () => ServerCapabilities, getConnections: () => ReadonlyArray<GatewayInfo>) => ArtifactConfig;
348
- //#endregion
349
- //#region src/artifacts/HealthArtifact.d.ts
350
- declare const DEFAULT_HEALTH_PATH = "/health";
351
- declare const DEFAULT_HEALTH_DETAIL_PATH = "/health/detail";
352
- declare const createHealthArtifact: (getHealth: () => ServerHealth, path?: string) => ArtifactConfig;
353
- declare const createHealthDetailArtifact: (getHealth: () => ServerHealth, path?: string) => ArtifactConfig;
354
- //#endregion
355
- //#region src/artifacts/InfoArtifact.d.ts
356
- declare const DEFAULT_INFO_PATH = "/info";
357
- declare const createInfoArtifact: (getInfo: () => ServerInfo, path?: string) => ArtifactConfig;
358
- //#endregion
359
- //#region src/introspection/capabilitiesTool.d.ts
360
- declare const createCapabilitiesTool: <T extends SessionAuth>(getCapabilities: () => ServerCapabilities) => Tool<T>;
361
- //#endregion
362
- //#region src/introspection/connectionsTool.d.ts
363
- declare const createConnectionsTool: <T extends SessionAuth>(getConnections: () => ReadonlyArray<GatewayInfo>) => Tool<T>;
364
- //#endregion
365
- //#region src/introspection/healthTool.d.ts
366
- declare const createHealthTool: <T extends SessionAuth>(getHealth: () => ServerHealth) => Tool<T>;
367
- //#endregion
368
- //#region src/introspection/infoTool.d.ts
369
- declare const createInfoTool: <T extends SessionAuth>(getInfo: () => ServerInfo, name?: string) => Tool<T>;
370
- //#endregion
371
- //#region src/feedback/redaction.d.ts
372
- type RedactionPattern = {
373
- description: string;
374
- name: string;
375
- pattern: RegExp;
376
- replacement?: string;
377
- };
378
- type RedactionResult = {
379
- matches: ReadonlyArray<{
380
- name: string;
381
- count: number;
382
- }>;
383
- redacted: boolean;
384
- text: string;
385
- };
386
- declare const DEFAULT_REDACTION_PATTERNS: ReadonlyArray<RedactionPattern>;
387
- declare const redact: (input: string, patterns?: ReadonlyArray<RedactionPattern>) => RedactionResult;
388
- //#endregion
389
- //#region src/feedback/types.d.ts
390
- type FeedbackType = "bug" | "feature" | "feedback" | "question";
391
- type FeedbackSeverity = "high" | "low" | "medium";
392
- type NormalizedFeedback = {
393
- body: string;
394
- labels: ReadonlyArray<string>;
395
- title: string;
396
- };
397
- type FeedbackSubmitSuccess = {
398
- id?: string;
399
- success: true;
400
- url?: string;
401
- };
402
- type FeedbackSubmitFailure = {
403
- error: string;
404
- success: false;
405
- };
406
- type FeedbackSubmitResult = FeedbackSubmitFailure | FeedbackSubmitSuccess;
407
- type FeedbackProvider = {
408
- readonly name: string;
409
- submit: (payload: NormalizedFeedback) => Promise<FeedbackSubmitResult>;
410
- };
411
- //#endregion
412
- //#region src/feedback/feedbackTool.d.ts
413
- type FeedbackEnrichmentContext = {
414
- type: FeedbackType;
415
- severity?: FeedbackSeverity;
416
- };
417
- type FeedbackToolOptions = {
418
- description?: string;
419
- enrichment?: (ctx: FeedbackEnrichmentContext) => Promise<Record<string, unknown>> | Record<string, unknown>;
420
- extraLabels?: ReadonlyArray<string>;
421
- name?: string;
422
- provider: FeedbackProvider;
423
- redactionPatterns?: ReadonlyArray<RedactionPattern>;
424
- };
425
- declare const PARAMETERS: z.ZodObject<{
426
- description: z.ZodString;
427
- severity: z.ZodOptional<z.ZodEnum<{
428
- low: "low";
429
- medium: "medium";
430
- high: "high";
431
- }>>;
432
- title: z.ZodString;
433
- type: z.ZodDefault<z.ZodEnum<{
434
- bug: "bug";
435
- feature: "feature";
436
- feedback: "feedback";
437
- question: "question";
438
- }>>;
439
- }, z.core.$strip>;
440
- declare const createFeedbackTool: <T extends SessionAuth>(options: FeedbackToolOptions) => Tool<T, typeof PARAMETERS>;
441
- //#endregion
442
- //#region src/feedback/providers/github.d.ts
443
- type GithubFeedbackOptions = {
444
- baseUrl?: string;
445
- defaultLabels?: ReadonlyArray<string>;
446
- fetchImpl?: typeof fetch;
447
- getToken: () => Option<string>;
448
- repo: `${string}/${string}`;
449
- };
450
- declare const createGithubFeedback: (options: GithubFeedbackOptions) => FeedbackProvider;
451
- //#endregion
452
- //#region src/feedback/providers/webhook.d.ts
453
- type WebhookFeedbackOptions = {
454
- fetchImpl?: typeof fetch;
455
- headers?: Record<string, string>;
456
- transform?: (payload: NormalizedFeedback) => unknown;
457
- url: string;
458
- };
459
- declare const createWebhookFeedback: (options: WebhookFeedbackOptions) => FeedbackProvider;
460
- //#endregion
461
- //#region src/gateway/Gateway.d.ts
462
- declare const createGateway: (config: GatewayConfig, telemetry: TelemetryCollector) => GatewayInstance;
463
- //#endregion
464
- //#region src/gateway/GatewayManager.d.ts
465
- declare const createGatewayManager: (telemetry: TelemetryCollector) => GatewayManagerInstance;
466
- //#endregion
467
- //#region src/gateway/toolProxy.d.ts
468
- declare const createProxiedTools: <T extends SessionAuth>(gateway: GatewayInstance, telemetry?: TelemetryCollector) => ReadonlyArray<Tool<T>>;
469
- //#endregion
470
- //#region src/index.d.ts
471
- /** Create a server backed by FastMCP (Node). For edge runtimes, use `somamcp/edge`. */
472
- declare const createServer: <T extends SessionAuth = SessionAuth>(options: SomaServerOptions<T>) => SomaServerInstance<T>;
473
- //#endregion
474
- 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 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 JsonFileTelemetryOptions, 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, audioContent, classifyError, createAuthMiddleware, createCapabilitiesTool, createCompositeTelemetry, createConnectionsTool, createConsoleTelemetry, createDashboardArtifact, createDefaultLogger, createEnrichedError, createFastMCPBackend, createFeedbackTool, createGateway, createGatewayManager, createGithubFeedback, createHealthArtifact, createHealthDetailArtifact, createHealthTool, createInfoArtifact, createInfoTool, createJsonFileTelemetry, createLogLayerTelemetry, createProxiedTools, createServer, createServerCore, createWebhookFeedback, getRequestHeader, getRuntimeInfo, imageContent, 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 };