@silkweave/core 3.2.1 → 4.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/build/index.d.mts +20 -5
- package/build/index.d.mts.map +1 -1
- package/build/index.mjs.map +1 -1
- package/package.json +1 -4
package/build/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import z$1, { z } from "zod/v4";
|
|
2
|
-
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
2
|
|
|
4
3
|
//#region src/util/context.d.ts
|
|
5
4
|
interface SilkweaveContext {
|
|
@@ -13,6 +12,22 @@ interface SilkweaveContext {
|
|
|
13
12
|
declare function createContext(store?: Record<string, unknown>): SilkweaveContext;
|
|
14
13
|
//#endregion
|
|
15
14
|
//#region src/util/action.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* The shape an action's `toolResult` hook returns - a structural, dependency-free
|
|
17
|
+
* mirror of the MCP SDK's `CallToolResult`. Kept in core (rather than importing
|
|
18
|
+
* `@modelcontextprotocol/sdk`) so a CLI/Fastify/tRPC-only install never pulls the
|
|
19
|
+
* entire MCP HTTP server stack for a single type. An SDK `CallToolResult` is
|
|
20
|
+
* assignable to this; the MCP adapters narrow it back at the SDK boundary.
|
|
21
|
+
*/
|
|
22
|
+
interface ToolResult {
|
|
23
|
+
content: Array<{
|
|
24
|
+
type: string;
|
|
25
|
+
} & Record<string, unknown>>;
|
|
26
|
+
structuredContent?: Record<string, unknown>;
|
|
27
|
+
isError?: boolean;
|
|
28
|
+
_meta?: Record<string, unknown>;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
16
31
|
type ActionKind = 'query' | 'mutation';
|
|
17
32
|
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
18
33
|
/**
|
|
@@ -102,7 +117,7 @@ interface Action<I extends object = any, O extends object = any, N extends strin
|
|
|
102
117
|
tags?: string[];
|
|
103
118
|
isEnabled?: (context: SilkweaveContext) => boolean;
|
|
104
119
|
run: ActionRun<I, O> | ActionStreamRun<I, C>;
|
|
105
|
-
toolResult?: (response: O, context: SilkweaveContext) =>
|
|
120
|
+
toolResult?: (response: O, context: SilkweaveContext) => ToolResult | undefined;
|
|
106
121
|
}
|
|
107
122
|
interface NonStreamingActionInput<I extends object, O extends object, N extends string, K extends ActionKind> {
|
|
108
123
|
name: N;
|
|
@@ -123,7 +138,7 @@ interface NonStreamingActionInput<I extends object, O extends object, N extends
|
|
|
123
138
|
tags?: string[];
|
|
124
139
|
isEnabled?: (context: SilkweaveContext) => boolean;
|
|
125
140
|
run: ActionRun<I, O>;
|
|
126
|
-
toolResult?: (response: O, context: SilkweaveContext) =>
|
|
141
|
+
toolResult?: (response: O, context: SilkweaveContext) => ToolResult | undefined;
|
|
127
142
|
}
|
|
128
143
|
interface StreamingActionInput<I extends object, C, N extends string, K extends ActionKind> {
|
|
129
144
|
name: N;
|
|
@@ -142,7 +157,7 @@ interface StreamingActionInput<I extends object, C, N extends string, K extends
|
|
|
142
157
|
tags?: string[];
|
|
143
158
|
isEnabled?: (context: SilkweaveContext) => boolean;
|
|
144
159
|
run: ActionStreamRun<I, C>;
|
|
145
|
-
toolResult?: (response: C[], context: SilkweaveContext) =>
|
|
160
|
+
toolResult?: (response: C[], context: SilkweaveContext) => ToolResult | undefined;
|
|
146
161
|
}
|
|
147
162
|
declare function createAction<I extends object, C, N extends string, K extends ActionKind = 'mutation'>(action: StreamingActionInput<I, C, N, K>): StreamingActionInput<I, C, N, K>;
|
|
148
163
|
declare function createAction<I extends object, O extends object, N extends string, K extends ActionKind = 'mutation'>(action: NonStreamingActionInput<I, O, N, K>): NonStreamingActionInput<I, O, N, K>;
|
|
@@ -366,5 +381,5 @@ interface UnwrapResult {
|
|
|
366
381
|
}
|
|
367
382
|
declare function unwrap(type: z.ZodTypeAny, result?: UnwrapResult): [z.ZodTypeAny, UnwrapResult];
|
|
368
383
|
//#endregion
|
|
369
|
-
export { Action, ActionInputSources, ActionKind, ActionLintCode, ActionLintWarning, ActionRun, ActionStreamRun, Adapter, AdapterFactory, AdapterGenerator, CreateLoggerOptions, HttpMethod, LogFn, LogLevel, LogLevels, Logger, MessageOptions, NonStreamingActionInput, OnToolCall, ProgressOptions, Silkweave, SilkweaveContext, SilkweaveError, type SilkweaveOptions, StreamingActionInput, ToolAnnotations, ToolCallEvent, UnwrapResult, actionMethod, badRequest, buildLogLevels, createAction, createConsoleLogger, createContext, createLogger, emitToolCall, forbidden, internal, isStreamingAction, lintActions, methodHasBody, notFound, pathParamNames, reportActionLint, resolveActionInput, runStreamingAction, silkweave, unwrap, validateActionDisposition, validateActionRouting };
|
|
384
|
+
export { Action, ActionInputSources, ActionKind, ActionLintCode, ActionLintWarning, ActionRun, ActionStreamRun, Adapter, AdapterFactory, AdapterGenerator, CreateLoggerOptions, HttpMethod, LogFn, LogLevel, LogLevels, Logger, MessageOptions, NonStreamingActionInput, OnToolCall, ProgressOptions, Silkweave, SilkweaveContext, SilkweaveError, type SilkweaveOptions, StreamingActionInput, ToolAnnotations, ToolCallEvent, ToolResult, UnwrapResult, actionMethod, badRequest, buildLogLevels, createAction, createConsoleLogger, createContext, createLogger, emitToolCall, forbidden, internal, isStreamingAction, lintActions, methodHasBody, notFound, pathParamNames, reportActionLint, resolveActionInput, runStreamingAction, silkweave, unwrap, validateActionDisposition, validateActionRouting };
|
|
370
385
|
//# sourceMappingURL=index.d.mts.map
|
package/build/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/util/context.ts","../src/util/action.ts","../src/util/adapter.ts","../src/lib/silkweave.ts","../src/util/error.ts","../src/util/http.ts","../src/util/lint.ts","../src/util/logger.ts","../src/util/streaming.ts","../src/util/telemetry.ts","../src/util/zod.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/util/context.ts","../src/util/action.ts","../src/util/adapter.ts","../src/lib/silkweave.ts","../src/util/error.ts","../src/util/http.ts","../src/util/lint.ts","../src/util/logger.ts","../src/util/streaming.ts","../src/util/telemetry.ts","../src/util/zod.ts"],"mappings":";;;UAAiB,gBAAA;EACf,IAAA;EACA,GAAA,GAAM,GAAA;EACN,GAAA,MAAS,GAAA,aAAgB,CAAA;EACzB,WAAA,MAAiB,GAAA,aAAgB,CAAA;EACjC,GAAA,MAAS,GAAA,UAAa,KAAA,EAAO,CAAA;EAC7B,IAAA,GAAO,KAAA,GAAQ,MAAA,sBAA4B,gBAAA;AAAA;AAAA,iBAG7B,aAAA,CAAc,KAAA,GAAO,MAAA,oBAA+B,gBAAA;;;;AATpE;;;;;;UCYiB,UAAA;EACf,OAAA,EAAS,KAAA;IAAQ,IAAA;EAAA,IAAiB,MAAA;EAClC,iBAAA,GAAoB,MAAA;EACpB,OAAA;EACA,KAAA,GAAQ,MAAA;EAAA,CACP,GAAA;AAAA;AAAA,KAGS,UAAA;AAAA,KAEA,UAAA;;;;;;;;UASK,eAAA;ED1BO;EC4BtB,KAAA;ED3Be;EC6Bf,YAAA;ED7B2C;EC+B3C,eAAA;ED/B2D;ECiC3D,cAAA;ED9B2B;ECgC3B,aAAA;AAAA;AAAA,KAGU,SAAA,UAAmB,KAAA,EAAO,CAAA,EAAG,OAAA,EAAS,gBAAA,KAAqB,OAAA,CAAQ,CAAA;AAAA,KACnE,eAAA,UAAyB,KAAA,EAAO,CAAA,EAAG,OAAA,EAAS,gBAAA,KAAqB,cAAA,CAAe,CAAA;AAAA,UAE3E,MAAA,sFAIL,UAAA,GAAa,UAAA;EAGvB,IAAA,EAAM,CAAA;EACN,WAAA;EACA,KAAA,EAAO,GAAA,CAAE,OAAA,CAAQ,CAAA;IAAO,KAAA,EAAO,MAAA,SAAe,GAAA,CAAE,UAAA;EAAA;EAChD,MAAA,GAAS,GAAA,CAAE,OAAA,CAAQ,CAAA;IAAO,KAAA,EAAO,MAAA,SAAe,GAAA,CAAE,UAAA;EAAA;EA5ChB;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ESmBN,EAAA;EACA,SAAA;EACA,YAAA;ETnBiC;ESqBjC,WAAA;ETpBM;ESsBN,UAAA;ETtB6B;ESwB7B,OAAA,EAAS,gBAAA;AAAA;;;;;;KAQC,UAAA,IAAc,KAAA,EAAO,aAAA,YAAyB,OAAA;;;;;iBAM1C,YAAA,CAAa,IAAA,EAAM,UAAA,cAAwB,KAAA,EAAO,aAAA;;;UCxCjD,YAAA;EACf,YAAA;EACA,UAAA;EACA,UAAA;EACA,UAAA;AAAA;AAAA,iBAGc,MAAA,CACd,IAAA,EAAM,CAAA,CAAE,UAAA,EACR,MAAA,GAAQ,YAAA,IACN,CAAA,CAAE,UAAA,EAAY,YAAA"}
|
package/build/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/util/context.ts","../src/util/zod.ts","../src/util/lint.ts","../src/lib/silkweave.ts","../src/util/error.ts","../src/util/action.ts","../src/util/http.ts","../src/util/logger.ts","../src/util/streaming.ts","../src/util/telemetry.ts"],"sourcesContent":["export interface SilkweaveContext {\n keys: () => string[]\n has: (key: string) => boolean\n get: <T>(key: string) => T\n getOptional: <T>(key: string) => T | undefined\n set: <T>(key: string, value: T) => void\n fork: (store?: Record<string, unknown>) => SilkweaveContext\n}\n\nexport function createContext(store: Record<string, unknown> = {}): SilkweaveContext {\n return {\n keys: () => {\n return Object.keys(store)\n },\n has: (key: string): boolean => {\n return store[key] != null\n },\n get: <T>(key: string): T => {\n const value = store[key]\n if (value == null) { throw new Error(`Invalid context key: ${key}`) }\n return value as T\n },\n getOptional: <T>(key: string): T | undefined => {\n return store[key] as T | undefined\n },\n set: <T>(key: string, value: T) => {\n store[key] = value\n },\n fork: (value?: Record<string, unknown>) => {\n return createContext({ ...store, ...value })\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from 'zod/v4'\n\nexport interface UnwrapResult {\n defaultValue?: any\n isOptional?: boolean\n isNullable?: boolean\n isReadOnly?: boolean\n}\n\nexport function unwrap(\n type: z.ZodTypeAny,\n result: UnwrapResult = {}\n): [z.ZodTypeAny, UnwrapResult] {\n if (type instanceof z.ZodOptional) {\n result.isOptional = true\n return unwrap(type.unwrap() as z.ZodTypeAny, result)\n } else if (type instanceof z.ZodNullable) {\n result.isNullable = true\n return unwrap(type.unwrap() as z.ZodTypeAny, result)\n } else if (type instanceof z.ZodReadonly) {\n result.isReadOnly = true\n return unwrap(type.def.innerType as z.ZodTypeAny, result)\n } else if (type instanceof z.ZodDefault) {\n result.defaultValue = typeof type.def.defaultValue === 'function'\n ? type.def.defaultValue()\n : type.def.defaultValue\n return unwrap(type.unwrap() as z.ZodTypeAny, result)\n } else {\n return [type, result]\n }\n}\n","import { z } from 'zod/v4'\nimport { Action } from './action.js'\nimport { unwrap } from './zod.js'\n\nexport type ActionLintCode =\n | 'missing-description'\n | 'short-description'\n | 'undescribed-params'\n | 'some-undescribed-params'\n\nexport interface ActionLintWarning {\n action: string\n code: ActionLintCode\n message: string\n}\n\n/** A description shorter than this reads as a placeholder to an agent picking a tool. */\nconst MIN_DESCRIPTION_LENGTH = 12\n\n/** A field's `.describe()` text, looking through optional/default/nullable/readonly wrappers. */\nfunction describedText(field: z.ZodTypeAny): string | undefined {\n if (field.description) { return field.description }\n const [base] = unwrap(field)\n return base.description\n}\n\n/**\n * Static checks for agent-hostile action definitions - the cheap mistakes that\n * quietly degrade tool-use: a missing or throwaway description (the model reads\n * it to decide when to call the tool) and undescribed input parameters (the\n * model guesses what to pass). Pure + side-effect-free; `reportActionLint` wires\n * it to a warn sink, and `silkweave().start()` runs it automatically.\n */\nexport function lintActions(actions: Action[]): ActionLintWarning[] {\n const warnings: ActionLintWarning[] = []\n for (const action of actions) {\n const description = action.description?.trim() ?? ''\n if (!description) {\n warnings.push({\n action: action.name,\n code: 'missing-description',\n message: `Action \"${action.name}\" has no description - MCP clients show it to the model to decide when to call the tool. Add a clear, specific sentence.`\n })\n } else if (description.length < MIN_DESCRIPTION_LENGTH) {\n warnings.push({\n action: action.name,\n code: 'short-description',\n message: `Action \"${action.name}\" description is very short (\"${description}\"). A fuller sentence helps agents choose the right tool.`\n })\n }\n\n const shape = action.input?.shape ?? {}\n const params = Object.keys(shape)\n const undescribed = params.filter((name) => !describedText(shape[name]))\n if (params.length > 0 && undescribed.length === params.length) {\n warnings.push({\n action: action.name,\n code: 'undescribed-params',\n message: `Action \"${action.name}\" has no described input parameters (${params.join(', ')}). Add .describe() to each field so agents pass correct values.`\n })\n } else if (undescribed.length > 0) {\n warnings.push({\n action: action.name,\n code: 'some-undescribed-params',\n message: `Action \"${action.name}\" input fields lack descriptions: ${undescribed.join(', ')}. Add .describe() for better agent tool-use.`\n })\n }\n }\n return warnings\n}\n\n/**\n * Run `lintActions` and emit each warning through `warn` (default `console.warn`,\n * which goes to stderr - safe even for the stdio MCP transport). Returns the\n * warnings so callers can also inspect or suppress them.\n */\nexport function reportActionLint(\n actions: Action[],\n warn: (message: string) => void = (message) => { console.warn(message) }\n): ActionLintWarning[] {\n const warnings = lintActions(actions)\n for (const warning of warnings) {\n warn(`[silkweave] ${warning.message}`)\n }\n return warnings\n}\n","import { Action } from '../util/action.js'\nimport { Adapter, AdapterGenerator, SilkweaveOptions } from '../util/adapter.js'\nimport { createContext } from '../util/context.js'\nimport { reportActionLint } from '../util/lint.js'\n\nexport type { SilkweaveOptions } from '../util/adapter.js'\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface Silkweave<Actions extends Record<string, Action> = {}> {\n set: <T>(key: string, value: T) => Silkweave<Actions>\n adapter: (generator: AdapterGenerator) => Silkweave<Actions>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n action: <A extends Action<any, any, string, any>>(\n action: A\n ) => Silkweave<Actions & Record<A['name'], A>>\n actions: <Arr extends readonly Action[]>(\n actions: Arr\n ) => Silkweave<Actions & { [K in Arr[number] as K['name']]: K }>\n start: () => Promise<Silkweave<Actions>>\n}\n\nexport function silkweave(options: SilkweaveOptions): Silkweave {\n const adapters: Adapter[] = []\n const actions: Action[] = []\n const context = createContext()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const builder: Silkweave<any> = {\n set: (key, value) => {\n context.set(key, value)\n return builder\n },\n adapter: (generator) => {\n adapters.push(generator(options, context))\n return builder\n },\n action: (value) => {\n actions.push(value)\n return builder\n },\n actions: (values) => {\n actions.push(...values)\n return builder\n },\n start: async () => {\n if (options.lint !== false) { reportActionLint(actions) }\n await Promise.all(adapters.map((adapter) => {\n const filtered = adapter.allActions\n ? actions\n : actions.filter((action) => {\n if (!action.isEnabled) { return true }\n return action.isEnabled(adapter.context)\n })\n return adapter.start(filtered)\n }))\n return builder\n }\n }\n return builder\n}\n","export class SilkweaveError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly statusCode = 500\n ) {\n super(message)\n this.name = 'SilkweaveError'\n }\n}\n\nexport function notFound(message = 'Not found') {\n return new SilkweaveError(message, 'not_found', 404)\n}\n\nexport function badRequest(message = 'Bad request') {\n return new SilkweaveError(message, 'bad_request', 400)\n}\n\nexport function forbidden(message = 'Forbidden') {\n return new SilkweaveError(message, 'forbidden', 403)\n}\n\nexport function internal(message = 'Internal error') {\n return new SilkweaveError(message, 'internal', 500)\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { type CallToolResult } from '@modelcontextprotocol/sdk/types.js'\nimport z from 'zod/v4'\nimport { SilkweaveContext } from './context.js'\nimport { SilkweaveError } from './error.js'\n\nexport type ActionKind = 'query' | 'mutation'\n\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * MCP tool annotations (spec `ToolAnnotations`) - client-facing hints about a\n * tool's behavior, used by MCP hosts to group and permission-gate tools. All\n * hints are advisory. Structurally compatible with the MCP SDK's\n * `ToolAnnotations`, defined here so non-MCP packages can set them without a\n * type dependency on the SDK.\n */\nexport interface ToolAnnotations {\n /** Human-readable title override for the tool. */\n title?: string\n /** The tool does not modify its environment. */\n readOnlyHint?: boolean\n /** The tool may perform destructive updates (only meaningful when not read-only). */\n destructiveHint?: boolean\n /** Repeated calls with the same arguments have no additional effect. */\n idempotentHint?: boolean\n /** The tool may interact with an open world of external entities. */\n openWorldHint?: boolean\n}\n\nexport type ActionRun<I, O> = (input: I, context: SilkweaveContext) => Promise<O>\nexport type ActionStreamRun<I, C> = (input: I, context: SilkweaveContext) => AsyncGenerator<C, void, void>\n\nexport interface Action<\n I extends object = any,\n O extends object = any,\n N extends string = string,\n K extends ActionKind = ActionKind,\n C = any\n> {\n name: N\n description: string\n input: z.ZodType<I> & { shape: Record<string, z.ZodTypeAny> }\n output?: z.ZodType<O> & { shape: Record<string, z.ZodTypeAny> }\n /**\n * Schema for individual chunks yielded by a streaming `run`. Required when\n * `run` is an async generator; adapters detect streaming actions by checking\n * `isStreamingAction(action)` at runtime, but type-aware tooling (inferRouter,\n * typegen) uses the presence of this field.\n */\n chunk?: z.ZodType<C>\n kind?: K\n /**\n * HTTP verb for REST-style adapters (fastify, nestjs `rest`). Defaults to\n * `POST`, or `GET` when `kind` is `'query'`. An explicit `method` always wins.\n */\n method?: HttpMethod\n /**\n * Route path for REST-style adapters. May contain `:param` placeholders\n * (e.g. `'spaces/:spaceId/users'`); each placeholder must be a key of the\n * input schema and is resolved from the URL path at runtime. When unset, the\n * adapter derives the path from `name`.\n */\n path?: string\n /**\n * Input fields sourced from the URL query string instead of the request body\n * (e.g. `['offset', 'limit']`). Each must be a key of the input schema; their\n * required/optional status is validated by the input schema as usual.\n */\n queryParams?: (keyof I)[]\n args?: (keyof I)[]\n /**\n * MCP result disposition for this action. `'json'` (the default when unset)\n * formats the response with `jsonToolResult` (compact JSON text); `'smart'`\n * uses `smartToolResult` (inlines small payloads, offloads large ones to an\n * embedded resource); `'structured'` declares the `output` schema as an MCP\n * `outputSchema` contract - the result is parsed through `output` (stripping\n * extra fields) and shipped as `structuredContent` alongside a JSON text\n * mirror. `'json'`/`'smart'` are only defaults a client's `_meta.disposition`\n * can override; a `'structured'` action ignores `_meta.disposition`, since\n * its schema contract is fixed at `tools/list` time. `'structured'` requires\n * a non-streaming action with an `output` schema (validated at registration\n * via `validateActionDisposition()`). Ignored by non-MCP adapters.\n */\n disposition?: 'json' | 'smart' | 'structured'\n /**\n * MCP tool annotations forwarded to `tools/list`. When unset, MCP adapters\n * derive `readOnlyHint` from `kind` (`'query'` ⇒ read-only); explicit\n * annotations are merged over the derived base, so setting e.g. only\n * `destructiveHint` keeps the derived `readOnlyHint`. Ignored by non-MCP\n * adapters.\n */\n annotations?: ToolAnnotations\n /**\n * Free-form grouping labels (e.g. `['leads', 'write']`). Carried on the\n * action for per-request filtering (`filterActions` in the MCP adapters) and\n * other consumers; no behavior in core itself.\n */\n tags?: string[]\n isEnabled?: (context: SilkweaveContext) => boolean\n run: ActionRun<I, O> | ActionStreamRun<I, C>\n toolResult?: (response: O, context: SilkweaveContext) => CallToolResult | undefined\n}\n\nexport interface NonStreamingActionInput<I extends object, O extends object, N extends string, K extends ActionKind> {\n name: N\n description: string\n input: z.ZodType<I> & { shape: Record<string, z.ZodTypeAny> }\n output?: z.ZodType<O> & { shape: Record<string, z.ZodTypeAny> }\n kind?: K\n method?: HttpMethod\n path?: string\n queryParams?: (keyof I)[]\n args?: (keyof I)[]\n disposition?: 'json' | 'smart' | 'structured'\n annotations?: ToolAnnotations\n tags?: string[]\n isEnabled?: (context: SilkweaveContext) => boolean\n run: ActionRun<I, O>\n toolResult?: (response: O, context: SilkweaveContext) => CallToolResult | undefined\n}\n\nexport interface StreamingActionInput<I extends object, C, N extends string, K extends ActionKind> {\n name: N\n description: string\n input: z.ZodType<I> & { shape: Record<string, z.ZodTypeAny> }\n chunk: z.ZodType<C>\n kind?: K\n method?: HttpMethod\n path?: string\n queryParams?: (keyof I)[]\n args?: (keyof I)[]\n disposition?: 'json' | 'smart'\n annotations?: ToolAnnotations\n tags?: string[]\n isEnabled?: (context: SilkweaveContext) => boolean\n run: ActionStreamRun<I, C>\n toolResult?: (response: C[], context: SilkweaveContext) => CallToolResult | undefined\n}\n\nexport function createAction<\n I extends object,\n C,\n N extends string,\n K extends ActionKind = 'mutation'\n>(action: StreamingActionInput<I, C, N, K>): StreamingActionInput<I, C, N, K>\nexport function createAction<\n I extends object,\n O extends object,\n N extends string,\n K extends ActionKind = 'mutation'\n>(action: NonStreamingActionInput<I, O, N, K>): NonStreamingActionInput<I, O, N, K>\nexport function createAction(action: Action): Action {\n return action\n}\n\n/**\n * Returns `true` when `action.run` is an async generator function (declared\n * with `async function*`). Adapters use this to switch between buffered\n * request/response and streaming chunk delivery.\n */\nexport function isStreamingAction(action: Action): boolean {\n return action.run?.constructor?.name === 'AsyncGeneratorFunction'\n}\n\n/**\n * Validate an action's MCP `disposition` at registration time. `'structured'`\n * declares the `output` schema as a hard MCP `outputSchema` contract, so it\n * requires a non-streaming action with an `output` schema - anything else is a\n * misconfiguration surfaced at boot rather than a per-call protocol error.\n * MCP adapters call this from `start()` (or, for per-request transports, when\n * the handler is built).\n */\nexport function validateActionDisposition(action: Action): void {\n if (action.disposition !== 'structured') { return }\n if (isStreamingAction(action) || action.chunk) {\n throw new SilkweaveError(\n `Action '${action.name}': disposition 'structured' is not supported on a streaming action - there is no single result to validate against an output schema`,\n 'invalid_action'\n )\n }\n if (!action.output) {\n throw new SilkweaveError(\n `Action '${action.name}': disposition 'structured' requires an 'output' schema - it becomes the tool's MCP outputSchema contract`,\n 'invalid_action'\n )\n }\n if (action.toolResult) {\n // A `toolResult` hook returns a CallToolResult that would bypass the\n // schema-parsed `structuredContent`, so the SDK's outputSchema validation\n // would reject every call. The two are mutually exclusive by construction.\n throw new SilkweaveError(\n `Action '${action.name}': a 'toolResult' hook cannot be combined with disposition 'structured' - the hook would bypass the structuredContent the outputSchema contract requires`,\n 'invalid_action'\n )\n }\n}\n","import type z from 'zod/v4'\nimport { type Action, type HttpMethod } from './action.js'\nimport { SilkweaveError } from './error.js'\nimport { unwrap } from './zod.js'\n\nconst PATH_PARAM_RE = /:([A-Za-z0-9_]+)/g\n\n/**\n * Resolve the HTTP verb for an action. An explicit `method` always wins;\n * otherwise `kind: 'query'` maps to `GET` and everything else to `POST`.\n */\nexport function actionMethod(action: Pick<Action, 'method' | 'kind'>): HttpMethod {\n if (action.method) { return action.method }\n return action.kind === 'query' ? 'GET' : 'POST'\n}\n\n/** Whether a request with this method carries a body (everything except GET). */\nexport function methodHasBody(method: HttpMethod): boolean {\n return method !== 'GET'\n}\n\n/** Extract the `:param` placeholder names from a route path template. */\nexport function pathParamNames(path: string | undefined): string[] {\n if (!path) { return [] }\n return [...path.matchAll(PATH_PARAM_RE)].map((match) => match[1])\n}\n\n/**\n * Assert that every `:param` in `action.path` and every `queryParams` entry is a\n * field of the input schema. Throws a `SilkweaveError` at registration time so\n * misconfigured routing fails fast instead of silently dropping values.\n */\nexport function validateActionRouting(action: Action): void {\n const shape = action.input.shape\n for (const param of pathParamNames(action.path)) {\n if (!(param in shape)) {\n throw new SilkweaveError(\n `Action \"${action.name}\" path \"${action.path}\" references \":${param}\" but the input schema has no \"${param}\" field`,\n 'invalid_action_routing'\n )\n }\n }\n for (const key of action.queryParams ?? []) {\n if (!(String(key) in shape)) {\n throw new SilkweaveError(\n `Action \"${action.name}\" lists query param \"${String(key)}\" but the input schema has no such field`,\n 'invalid_action_routing'\n )\n }\n }\n}\n\n/**\n * Coerce a raw string (from the URL path or query string) to the primitive the\n * field's schema expects. Non-string values pass through untouched (REST\n * frameworks like Fastify may have already coerced via JSON Schema), and a\n * failed coercion returns the original value so Zod surfaces a proper error.\n */\nfunction coerceScalar(field: z.ZodTypeAny | undefined, value: unknown): unknown {\n if (!field || typeof value !== 'string') { return value }\n const [base] = unwrap(field)\n const type = (base as { def?: { type?: string } }).def?.type\n if (type === 'number') {\n const num = Number(value)\n return value.trim() === '' || Number.isNaN(num) ? value : num\n }\n if (type === 'boolean') {\n if (value === 'true') { return true }\n if (value === 'false') { return false }\n return value\n }\n if (type === 'bigint') {\n try { return BigInt(value) } catch { return value }\n }\n return value\n}\n\nexport interface ActionInputSources {\n /** Path parameters keyed by `:param` name (e.g. Express/Fastify `req.params`). */\n params?: Record<string, string | undefined>\n /** Parsed query string (string values, or arrays/coerced values from a framework). */\n query?: Record<string, unknown>\n /** Parsed request body (already-typed JSON for body methods). */\n body?: unknown\n}\n\n/**\n * Merge an action's path params, query params, and body into a single input\n * object honouring its `method`/`path`/`queryParams` routing config:\n *\n * - body fields form the base layer (only for body-carrying methods),\n * - declared query params override (on bodyless GET requests every input field\n * that is not a path param is read from the query string),\n * - path params override last.\n *\n * String values from the path/query are coerced to the primitive their schema\n * expects. The result is not validated here - callers pass it to\n * `action.input.parse()` (or let a framework validate it).\n */\nexport function resolveActionInput(action: Action, sources: ActionInputSources): Record<string, unknown> {\n const shape = action.input.shape\n const method = actionMethod(action)\n const hasBody = methodHasBody(method)\n const params = sources.params ?? {}\n const query = sources.query ?? {}\n const pathParams = new Set(pathParamNames(action.path))\n const queryKeys = new Set((action.queryParams ?? []).map(String))\n\n const merged: Record<string, unknown> = {}\n\n if (hasBody && sources.body && typeof sources.body === 'object') {\n Object.assign(merged, sources.body as Record<string, unknown>)\n }\n\n for (const [key, raw] of Object.entries(query)) {\n if (raw === undefined) { continue }\n const declared = hasBody ? queryKeys.has(key) : (key in shape && !pathParams.has(key))\n if (!declared) { continue }\n merged[key] = Array.isArray(raw) ? raw : coerceScalar(shape[key], raw)\n }\n\n for (const key of pathParams) {\n const raw = params[key]\n if (raw === undefined) { continue }\n merged[key] = coerceScalar(shape[key], raw)\n }\n\n return merged\n}\n","export interface MessageOptions {\n message: string\n}\n\nexport interface ProgressOptions {\n progress: number\n total?: number\n message?: string\n}\n\nconst LogLevels = ['error', 'debug', 'info', 'notice', 'warning', 'critical', 'alert', 'emergency'] as const\n\nexport type LogLevel = typeof LogLevels[number]\n\nexport type LogFn = (data: unknown) => void\n\nexport interface Logger extends Record<LogLevel, LogFn> {\n progress: (options: ProgressOptions) => void\n}\n\nexport { LogLevels }\n\n// Severity ordering (lowest number = most verbose) used to gate writes by the\n// configured `level` threshold. Mirrors syslog-style precedence so a `level` of\n// e.g. `'warning'` suppresses `info`/`notice`/`debug`.\nconst LEVEL_SEVERITY: Record<LogLevel, number> = {\n debug: 10,\n info: 20,\n notice: 30,\n warning: 40,\n error: 50,\n critical: 60,\n alert: 70,\n emergency: 80\n}\n\nexport interface CreateLoggerOptions {\n name?: string\n /** Minimum severity to write to `stream`. Defaults to `'debug'` (everything). */\n level?: LogLevel\n /**\n * Destination stream for structured log lines, or `false` to discard them.\n * Defaults to `process.stdout`. The `onLog` callback always fires regardless\n * of this setting - the stream is just the diagnostic sink.\n */\n stream?: NodeJS.WritableStream | false\n onLog?: (level: LogLevel, data: unknown) => void\n onProgress?: (options: ProgressOptions) => void\n}\n\nexport function createLogger(options: CreateLoggerOptions = {}): Logger {\n const { name, level = 'debug', stream, onLog, onProgress } = options\n\n const target = stream === false ? undefined : stream ?? process.stdout\n const threshold = LEVEL_SEVERITY[level] ?? LEVEL_SEVERITY.debug\n\n const write = (logLevel: LogLevel, data: unknown) => {\n if (target && LEVEL_SEVERITY[logLevel] >= threshold) {\n const line = typeof data === 'object' && data !== null\n ? { level: logLevel, time: Date.now(), name, ...data }\n : { level: logLevel, time: Date.now(), name, msg: data }\n target.write(`${JSON.stringify(line)}\\n`)\n }\n }\n\n const logLevels = Object.fromEntries(LogLevels.map((logLevel) => {\n return [logLevel, (data: unknown) => {\n write(logLevel, data)\n onLog?.(logLevel, data)\n }]\n })) as Record<LogLevel, LogFn>\n\n return {\n ...logLevels,\n progress: (progressOptions) => {\n if (onProgress) {\n onProgress(progressOptions)\n } else {\n write('info', { ...progressOptions })\n }\n }\n }\n}\n\nexport function buildLogLevels(fn: (level: LogLevel, data: unknown) => void): Record<LogLevel, LogFn> {\n return Object.fromEntries(LogLevels.map((level) => [level, (data: unknown) => { fn(level, data) }])) as Record<LogLevel, LogFn>\n}\n\n// Maps each syslog level onto a `console` method for a human-readable terminal\n// logger. Used by the `cli` adapter and the MCP `cliProxy` client - a\n// zero-dependency replacement for a terminal-UI logging library.\nconst CONSOLE_LEVEL_MAP: Record<LogLevel, 'log' | 'info' | 'warn' | 'error'> = {\n debug: 'log',\n info: 'info',\n notice: 'info',\n warning: 'warn',\n error: 'error',\n critical: 'error',\n alert: 'error',\n emergency: 'error'\n}\n\n/**\n * Human-readable `console`-backed logger for terminal contexts. Strings are\n * written verbatim; objects are JSON-stringified. Zero dependencies.\n */\nexport function createConsoleLogger(): Logger {\n const toString = (value: unknown) => typeof value === 'string' ? value : JSON.stringify(value)\n return {\n ...buildLogLevels((level, data) => {\n console[CONSOLE_LEVEL_MAP[level]](toString(data))\n }),\n progress: ({ progress, total, message }) => {\n console.info(toString({ progress, total, message }))\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Action, ActionStreamRun, isStreamingAction } from './action.js'\nimport { SilkweaveContext } from './context.js'\n\n/**\n * Drive a streaming action's async generator. Calls `onChunk` once per yielded\n * value and awaits it before pulling the next value from the generator - this\n * is what wires transport-level backpressure (SSE drain, stdout flush, tRPC\n * subscription consumer) back to the action.\n *\n * Returns the buffered array of all chunks. Use this for non-streaming\n * adapters or when a client has opted out of streaming (e.g. no MCP\n * `progressToken`). Pass `onChunk` to also emit each chunk on the wire.\n */\nexport async function runStreamingAction<C>(\n action: Action<any, any, string, any, C>,\n input: object,\n context: SilkweaveContext,\n onChunk?: (chunk: C, index: number) => void | Promise<void>\n): Promise<C[]> {\n if (!isStreamingAction(action)) {\n throw new Error(`Action ${action.name} is not a streaming action`)\n }\n const run = action.run as ActionStreamRun<object, C>\n const iter = run(input, context)\n const chunks: C[] = []\n let index = 0\n for await (const chunk of iter) {\n chunks.push(chunk)\n if (onChunk) { await onChunk(chunk, index) }\n index += 1\n }\n return chunks\n}\n","import { SilkweaveContext } from './context.js'\n\n/**\n * One tool/procedure invocation, as reported to an `OnToolCall` hook. MCP\n * adapters emit these from the tool registrar (where result formatting\n * happens, so `resultBytes`/`sideloaded` are known); other transports emit\n * from their own invocation seam and omit the MCP-only fields.\n */\nexport interface ToolCallEvent {\n /** Action name (e.g. `'leads.bulkUpdate'`). */\n action: string\n /** Wire name the client called (e.g. `'LeadsBulkUpdate'` over MCP, `'leadsBulkUpdate'` over tRPC). */\n tool: string\n transport: 'mcp' | 'trpc' | 'rest' | 'cli'\n /** Wall-clock duration; for streaming actions this spans full generator consumption. */\n durationMs: number\n /**\n * `false` when the action threw or the formatted result is an MCP\n * `isError` tool result. `errorCode`/`errorMessage` are set for thrown\n * errors (a `SilkweaveError`'s `code`, else the error's `name`).\n */\n ok: boolean\n errorCode?: string\n errorMessage?: string\n /** Serialized (JSON) size of the raw result - MCP-layer events only. */\n resultBytes?: number\n /** Whether `smartToolResult` offloaded the payload to an embedded resource - MCP-layer events only. */\n sideloaded?: boolean\n /** The per-call action context (access to `auth`/`request` for spaceId, apiKeyId, ...). */\n context: SilkweaveContext\n}\n\n/**\n * Telemetry hook invoked once per tool call, fire-and-forget: adapters never\n * await it on the result path and swallow (log) its errors, so the hook can\n * never fail, slow, or reorder a call.\n */\nexport type OnToolCall = (event: ToolCallEvent) => void | Promise<void>\n\n/**\n * Invoke an `OnToolCall` hook with fire-and-forget semantics - sync throws and\n * async rejections are logged to stderr and never propagate to the call path.\n */\nexport function emitToolCall(hook: OnToolCall | undefined, event: ToolCallEvent): void {\n if (!hook) { return }\n try {\n void Promise.resolve(hook(event)).catch((error: unknown) => { console.error('onToolCall hook error:', error) })\n } catch (error) {\n console.error('onToolCall hook error:', error)\n }\n}\n"],"mappings":";;AASA,SAAgB,cAAc,QAAiC,EAAE,EAAoB;AACnF,QAAO;EACL,YAAY;AACV,UAAO,OAAO,KAAK,MAAM;;EAE3B,MAAM,QAAyB;AAC7B,UAAO,MAAM,QAAQ;;EAEvB,MAAS,QAAmB;GAC1B,MAAM,QAAQ,MAAM;AACpB,OAAI,SAAS,KAAQ,OAAM,IAAI,MAAM,wBAAwB,MAAM;AACnE,UAA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A4B;AACrF,KAAI,CAAC,KAAQ;AACb,KAAI;AACG,UAAQ,QAAQ,KAAK,MAAM,CAAC,CAAC,OAAO,UAAmB;AAAE,WAAQ,MAAM,0BAA0B,MAAM;IAAG;UACxG,OAAO;AACd,UAAQ,MAAM,0BAA0B,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/util/context.ts","../src/util/zod.ts","../src/util/lint.ts","../src/lib/silkweave.ts","../src/util/error.ts","../src/util/action.ts","../src/util/http.ts","../src/util/logger.ts","../src/util/streaming.ts","../src/util/telemetry.ts"],"sourcesContent":["export interface SilkweaveContext {\n keys: () => string[]\n has: (key: string) => boolean\n get: <T>(key: string) => T\n getOptional: <T>(key: string) => T | undefined\n set: <T>(key: string, value: T) => void\n fork: (store?: Record<string, unknown>) => SilkweaveContext\n}\n\nexport function createContext(store: Record<string, unknown> = {}): SilkweaveContext {\n return {\n keys: () => {\n return Object.keys(store)\n },\n has: (key: string): boolean => {\n return store[key] != null\n },\n get: <T>(key: string): T => {\n const value = store[key]\n if (value == null) { throw new Error(`Invalid context key: ${key}`) }\n return value as T\n },\n getOptional: <T>(key: string): T | undefined => {\n return store[key] as T | undefined\n },\n set: <T>(key: string, value: T) => {\n store[key] = value\n },\n fork: (value?: Record<string, unknown>) => {\n return createContext({ ...store, ...value })\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from 'zod/v4'\n\nexport interface UnwrapResult {\n defaultValue?: any\n isOptional?: boolean\n isNullable?: boolean\n isReadOnly?: boolean\n}\n\nexport function unwrap(\n type: z.ZodTypeAny,\n result: UnwrapResult = {}\n): [z.ZodTypeAny, UnwrapResult] {\n if (type instanceof z.ZodOptional) {\n result.isOptional = true\n return unwrap(type.unwrap() as z.ZodTypeAny, result)\n } else if (type instanceof z.ZodNullable) {\n result.isNullable = true\n return unwrap(type.unwrap() as z.ZodTypeAny, result)\n } else if (type instanceof z.ZodReadonly) {\n result.isReadOnly = true\n return unwrap(type.def.innerType as z.ZodTypeAny, result)\n } else if (type instanceof z.ZodDefault) {\n result.defaultValue = typeof type.def.defaultValue === 'function'\n ? type.def.defaultValue()\n : type.def.defaultValue\n return unwrap(type.unwrap() as z.ZodTypeAny, result)\n } else {\n return [type, result]\n }\n}\n","import { z } from 'zod/v4'\nimport { Action } from './action.js'\nimport { unwrap } from './zod.js'\n\nexport type ActionLintCode =\n | 'missing-description'\n | 'short-description'\n | 'undescribed-params'\n | 'some-undescribed-params'\n\nexport interface ActionLintWarning {\n action: string\n code: ActionLintCode\n message: string\n}\n\n/** A description shorter than this reads as a placeholder to an agent picking a tool. */\nconst MIN_DESCRIPTION_LENGTH = 12\n\n/** A field's `.describe()` text, looking through optional/default/nullable/readonly wrappers. */\nfunction describedText(field: z.ZodTypeAny): string | undefined {\n if (field.description) { return field.description }\n const [base] = unwrap(field)\n return base.description\n}\n\n/**\n * Static checks for agent-hostile action definitions - the cheap mistakes that\n * quietly degrade tool-use: a missing or throwaway description (the model reads\n * it to decide when to call the tool) and undescribed input parameters (the\n * model guesses what to pass). Pure + side-effect-free; `reportActionLint` wires\n * it to a warn sink, and `silkweave().start()` runs it automatically.\n */\nexport function lintActions(actions: Action[]): ActionLintWarning[] {\n const warnings: ActionLintWarning[] = []\n for (const action of actions) {\n const description = action.description?.trim() ?? ''\n if (!description) {\n warnings.push({\n action: action.name,\n code: 'missing-description',\n message: `Action \"${action.name}\" has no description - MCP clients show it to the model to decide when to call the tool. Add a clear, specific sentence.`\n })\n } else if (description.length < MIN_DESCRIPTION_LENGTH) {\n warnings.push({\n action: action.name,\n code: 'short-description',\n message: `Action \"${action.name}\" description is very short (\"${description}\"). A fuller sentence helps agents choose the right tool.`\n })\n }\n\n const shape = action.input?.shape ?? {}\n const params = Object.keys(shape)\n const undescribed = params.filter((name) => !describedText(shape[name]))\n if (params.length > 0 && undescribed.length === params.length) {\n warnings.push({\n action: action.name,\n code: 'undescribed-params',\n message: `Action \"${action.name}\" has no described input parameters (${params.join(', ')}). Add .describe() to each field so agents pass correct values.`\n })\n } else if (undescribed.length > 0) {\n warnings.push({\n action: action.name,\n code: 'some-undescribed-params',\n message: `Action \"${action.name}\" input fields lack descriptions: ${undescribed.join(', ')}. Add .describe() for better agent tool-use.`\n })\n }\n }\n return warnings\n}\n\n/**\n * Run `lintActions` and emit each warning through `warn` (default `console.warn`,\n * which goes to stderr - safe even for the stdio MCP transport). Returns the\n * warnings so callers can also inspect or suppress them.\n */\nexport function reportActionLint(\n actions: Action[],\n warn: (message: string) => void = (message) => { console.warn(message) }\n): ActionLintWarning[] {\n const warnings = lintActions(actions)\n for (const warning of warnings) {\n warn(`[silkweave] ${warning.message}`)\n }\n return warnings\n}\n","import { Action } from '../util/action.js'\nimport { Adapter, AdapterGenerator, SilkweaveOptions } from '../util/adapter.js'\nimport { createContext } from '../util/context.js'\nimport { reportActionLint } from '../util/lint.js'\n\nexport type { SilkweaveOptions } from '../util/adapter.js'\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface Silkweave<Actions extends Record<string, Action> = {}> {\n set: <T>(key: string, value: T) => Silkweave<Actions>\n adapter: (generator: AdapterGenerator) => Silkweave<Actions>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n action: <A extends Action<any, any, string, any>>(\n action: A\n ) => Silkweave<Actions & Record<A['name'], A>>\n actions: <Arr extends readonly Action[]>(\n actions: Arr\n ) => Silkweave<Actions & { [K in Arr[number] as K['name']]: K }>\n start: () => Promise<Silkweave<Actions>>\n}\n\nexport function silkweave(options: SilkweaveOptions): Silkweave {\n const adapters: Adapter[] = []\n const actions: Action[] = []\n const context = createContext()\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const builder: Silkweave<any> = {\n set: (key, value) => {\n context.set(key, value)\n return builder\n },\n adapter: (generator) => {\n adapters.push(generator(options, context))\n return builder\n },\n action: (value) => {\n actions.push(value)\n return builder\n },\n actions: (values) => {\n actions.push(...values)\n return builder\n },\n start: async () => {\n if (options.lint !== false) { reportActionLint(actions) }\n await Promise.all(adapters.map((adapter) => {\n const filtered = adapter.allActions\n ? actions\n : actions.filter((action) => {\n if (!action.isEnabled) { return true }\n return action.isEnabled(adapter.context)\n })\n return adapter.start(filtered)\n }))\n return builder\n }\n }\n return builder\n}\n","export class SilkweaveError extends Error {\n constructor(\n message: string,\n public readonly code: string,\n public readonly statusCode = 500\n ) {\n super(message)\n this.name = 'SilkweaveError'\n }\n}\n\nexport function notFound(message = 'Not found') {\n return new SilkweaveError(message, 'not_found', 404)\n}\n\nexport function badRequest(message = 'Bad request') {\n return new SilkweaveError(message, 'bad_request', 400)\n}\n\nexport function forbidden(message = 'Forbidden') {\n return new SilkweaveError(message, 'forbidden', 403)\n}\n\nexport function internal(message = 'Internal error') {\n return new SilkweaveError(message, 'internal', 500)\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport z from 'zod/v4'\nimport { SilkweaveContext } from './context.js'\nimport { SilkweaveError } from './error.js'\n\n/**\n * The shape an action's `toolResult` hook returns - a structural, dependency-free\n * mirror of the MCP SDK's `CallToolResult`. Kept in core (rather than importing\n * `@modelcontextprotocol/sdk`) so a CLI/Fastify/tRPC-only install never pulls the\n * entire MCP HTTP server stack for a single type. An SDK `CallToolResult` is\n * assignable to this; the MCP adapters narrow it back at the SDK boundary.\n */\nexport interface ToolResult {\n content: Array<{ type: string } & Record<string, unknown>>\n structuredContent?: Record<string, unknown>\n isError?: boolean\n _meta?: Record<string, unknown>\n [key: string]: unknown\n}\n\nexport type ActionKind = 'query' | 'mutation'\n\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'\n\n/**\n * MCP tool annotations (spec `ToolAnnotations`) - client-facing hints about a\n * tool's behavior, used by MCP hosts to group and permission-gate tools. All\n * hints are advisory. Structurally compatible with the MCP SDK's\n * `ToolAnnotations`, defined here so non-MCP packages can set them without a\n * type dependency on the SDK.\n */\nexport interface ToolAnnotations {\n /** Human-readable title override for the tool. */\n title?: string\n /** The tool does not modify its environment. */\n readOnlyHint?: boolean\n /** The tool may perform destructive updates (only meaningful when not read-only). */\n destructiveHint?: boolean\n /** Repeated calls with the same arguments have no additional effect. */\n idempotentHint?: boolean\n /** The tool may interact with an open world of external entities. */\n openWorldHint?: boolean\n}\n\nexport type ActionRun<I, O> = (input: I, context: SilkweaveContext) => Promise<O>\nexport type ActionStreamRun<I, C> = (input: I, context: SilkweaveContext) => AsyncGenerator<C, void, void>\n\nexport interface Action<\n I extends object = any,\n O extends object = any,\n N extends string = string,\n K extends ActionKind = ActionKind,\n C = any\n> {\n name: N\n description: string\n input: z.ZodType<I> & { shape: Record<string, z.ZodTypeAny> }\n output?: z.ZodType<O> & { shape: Record<string, z.ZodTypeAny> }\n /**\n * Schema for individual chunks yielded by a streaming `run`. Required when\n * `run` is an async generator; adapters detect streaming actions by checking\n * `isStreamingAction(action)` at runtime, but type-aware tooling (inferRouter,\n * typegen) uses the presence of this field.\n */\n chunk?: z.ZodType<C>\n kind?: K\n /**\n * HTTP verb for REST-style adapters (fastify, nestjs `rest`). Defaults to\n * `POST`, or `GET` when `kind` is `'query'`. An explicit `method` always wins.\n */\n method?: HttpMethod\n /**\n * Route path for REST-style adapters. May contain `:param` placeholders\n * (e.g. `'spaces/:spaceId/users'`); each placeholder must be a key of the\n * input schema and is resolved from the URL path at runtime. When unset, the\n * adapter derives the path from `name`.\n */\n path?: string\n /**\n * Input fields sourced from the URL query string instead of the request body\n * (e.g. `['offset', 'limit']`). Each must be a key of the input schema; their\n * required/optional status is validated by the input schema as usual.\n */\n queryParams?: (keyof I)[]\n args?: (keyof I)[]\n /**\n * MCP result disposition for this action. `'json'` (the default when unset)\n * formats the response with `jsonToolResult` (compact JSON text); `'smart'`\n * uses `smartToolResult` (inlines small payloads, offloads large ones to an\n * embedded resource); `'structured'` declares the `output` schema as an MCP\n * `outputSchema` contract - the result is parsed through `output` (stripping\n * extra fields) and shipped as `structuredContent` alongside a JSON text\n * mirror. `'json'`/`'smart'` are only defaults a client's `_meta.disposition`\n * can override; a `'structured'` action ignores `_meta.disposition`, since\n * its schema contract is fixed at `tools/list` time. `'structured'` requires\n * a non-streaming action with an `output` schema (validated at registration\n * via `validateActionDisposition()`). Ignored by non-MCP adapters.\n */\n disposition?: 'json' | 'smart' | 'structured'\n /**\n * MCP tool annotations forwarded to `tools/list`. When unset, MCP adapters\n * derive `readOnlyHint` from `kind` (`'query'` ⇒ read-only); explicit\n * annotations are merged over the derived base, so setting e.g. only\n * `destructiveHint` keeps the derived `readOnlyHint`. Ignored by non-MCP\n * adapters.\n */\n annotations?: ToolAnnotations\n /**\n * Free-form grouping labels (e.g. `['leads', 'write']`). Carried on the\n * action for per-request filtering (`filterActions` in the MCP adapters) and\n * other consumers; no behavior in core itself.\n */\n tags?: string[]\n isEnabled?: (context: SilkweaveContext) => boolean\n run: ActionRun<I, O> | ActionStreamRun<I, C>\n toolResult?: (response: O, context: SilkweaveContext) => ToolResult | undefined\n}\n\nexport interface NonStreamingActionInput<I extends object, O extends object, N extends string, K extends ActionKind> {\n name: N\n description: string\n input: z.ZodType<I> & { shape: Record<string, z.ZodTypeAny> }\n output?: z.ZodType<O> & { shape: Record<string, z.ZodTypeAny> }\n kind?: K\n method?: HttpMethod\n path?: string\n queryParams?: (keyof I)[]\n args?: (keyof I)[]\n disposition?: 'json' | 'smart' | 'structured'\n annotations?: ToolAnnotations\n tags?: string[]\n isEnabled?: (context: SilkweaveContext) => boolean\n run: ActionRun<I, O>\n toolResult?: (response: O, context: SilkweaveContext) => ToolResult | undefined\n}\n\nexport interface StreamingActionInput<I extends object, C, N extends string, K extends ActionKind> {\n name: N\n description: string\n input: z.ZodType<I> & { shape: Record<string, z.ZodTypeAny> }\n chunk: z.ZodType<C>\n kind?: K\n method?: HttpMethod\n path?: string\n queryParams?: (keyof I)[]\n args?: (keyof I)[]\n disposition?: 'json' | 'smart'\n annotations?: ToolAnnotations\n tags?: string[]\n isEnabled?: (context: SilkweaveContext) => boolean\n run: ActionStreamRun<I, C>\n toolResult?: (response: C[], context: SilkweaveContext) => ToolResult | undefined\n}\n\nexport function createAction<\n I extends object,\n C,\n N extends string,\n K extends ActionKind = 'mutation'\n>(action: StreamingActionInput<I, C, N, K>): StreamingActionInput<I, C, N, K>\nexport function createAction<\n I extends object,\n O extends object,\n N extends string,\n K extends ActionKind = 'mutation'\n>(action: NonStreamingActionInput<I, O, N, K>): NonStreamingActionInput<I, O, N, K>\nexport function createAction(action: Action): Action {\n return action\n}\n\n/**\n * Returns `true` when `action.run` is an async generator function (declared\n * with `async function*`). Adapters use this to switch between buffered\n * request/response and streaming chunk delivery.\n */\nexport function isStreamingAction(action: Action): boolean {\n return action.run?.constructor?.name === 'AsyncGeneratorFunction'\n}\n\n/**\n * Validate an action's MCP `disposition` at registration time. `'structured'`\n * declares the `output` schema as a hard MCP `outputSchema` contract, so it\n * requires a non-streaming action with an `output` schema - anything else is a\n * misconfiguration surfaced at boot rather than a per-call protocol error.\n * MCP adapters call this from `start()` (or, for per-request transports, when\n * the handler is built).\n */\nexport function validateActionDisposition(action: Action): void {\n if (action.disposition !== 'structured') { return }\n if (isStreamingAction(action) || action.chunk) {\n throw new SilkweaveError(\n `Action '${action.name}': disposition 'structured' is not supported on a streaming action - there is no single result to validate against an output schema`,\n 'invalid_action'\n )\n }\n if (!action.output) {\n throw new SilkweaveError(\n `Action '${action.name}': disposition 'structured' requires an 'output' schema - it becomes the tool's MCP outputSchema contract`,\n 'invalid_action'\n )\n }\n if (action.toolResult) {\n // A `toolResult` hook returns a ToolResult that would bypass the\n // schema-parsed `structuredContent`, so the SDK's outputSchema validation\n // would reject every call. The two are mutually exclusive by construction.\n throw new SilkweaveError(\n `Action '${action.name}': a 'toolResult' hook cannot be combined with disposition 'structured' - the hook would bypass the structuredContent the outputSchema contract requires`,\n 'invalid_action'\n )\n }\n}\n","import type z from 'zod/v4'\nimport { type Action, type HttpMethod } from './action.js'\nimport { SilkweaveError } from './error.js'\nimport { unwrap } from './zod.js'\n\nconst PATH_PARAM_RE = /:([A-Za-z0-9_]+)/g\n\n/**\n * Resolve the HTTP verb for an action. An explicit `method` always wins;\n * otherwise `kind: 'query'` maps to `GET` and everything else to `POST`.\n */\nexport function actionMethod(action: Pick<Action, 'method' | 'kind'>): HttpMethod {\n if (action.method) { return action.method }\n return action.kind === 'query' ? 'GET' : 'POST'\n}\n\n/** Whether a request with this method carries a body (everything except GET). */\nexport function methodHasBody(method: HttpMethod): boolean {\n return method !== 'GET'\n}\n\n/** Extract the `:param` placeholder names from a route path template. */\nexport function pathParamNames(path: string | undefined): string[] {\n if (!path) { return [] }\n return [...path.matchAll(PATH_PARAM_RE)].map((match) => match[1])\n}\n\n/**\n * Assert that every `:param` in `action.path` and every `queryParams` entry is a\n * field of the input schema. Throws a `SilkweaveError` at registration time so\n * misconfigured routing fails fast instead of silently dropping values.\n */\nexport function validateActionRouting(action: Action): void {\n const shape = action.input.shape\n for (const param of pathParamNames(action.path)) {\n if (!(param in shape)) {\n throw new SilkweaveError(\n `Action \"${action.name}\" path \"${action.path}\" references \":${param}\" but the input schema has no \"${param}\" field`,\n 'invalid_action_routing'\n )\n }\n }\n for (const key of action.queryParams ?? []) {\n if (!(String(key) in shape)) {\n throw new SilkweaveError(\n `Action \"${action.name}\" lists query param \"${String(key)}\" but the input schema has no such field`,\n 'invalid_action_routing'\n )\n }\n }\n}\n\n/**\n * Coerce a raw string (from the URL path or query string) to the primitive the\n * field's schema expects. Non-string values pass through untouched (REST\n * frameworks like Fastify may have already coerced via JSON Schema), and a\n * failed coercion returns the original value so Zod surfaces a proper error.\n */\nfunction coerceScalar(field: z.ZodTypeAny | undefined, value: unknown): unknown {\n if (!field || typeof value !== 'string') { return value }\n const [base] = unwrap(field)\n const type = (base as { def?: { type?: string } }).def?.type\n if (type === 'number') {\n const num = Number(value)\n return value.trim() === '' || Number.isNaN(num) ? value : num\n }\n if (type === 'boolean') {\n if (value === 'true') { return true }\n if (value === 'false') { return false }\n return value\n }\n if (type === 'bigint') {\n try { return BigInt(value) } catch { return value }\n }\n return value\n}\n\nexport interface ActionInputSources {\n /** Path parameters keyed by `:param` name (e.g. Express/Fastify `req.params`). */\n params?: Record<string, string | undefined>\n /** Parsed query string (string values, or arrays/coerced values from a framework). */\n query?: Record<string, unknown>\n /** Parsed request body (already-typed JSON for body methods). */\n body?: unknown\n}\n\n/**\n * Merge an action's path params, query params, and body into a single input\n * object honouring its `method`/`path`/`queryParams` routing config:\n *\n * - body fields form the base layer (only for body-carrying methods),\n * - declared query params override (on bodyless GET requests every input field\n * that is not a path param is read from the query string),\n * - path params override last.\n *\n * String values from the path/query are coerced to the primitive their schema\n * expects. The result is not validated here - callers pass it to\n * `action.input.parse()` (or let a framework validate it).\n */\nexport function resolveActionInput(action: Action, sources: ActionInputSources): Record<string, unknown> {\n const shape = action.input.shape\n const method = actionMethod(action)\n const hasBody = methodHasBody(method)\n const params = sources.params ?? {}\n const query = sources.query ?? {}\n const pathParams = new Set(pathParamNames(action.path))\n const queryKeys = new Set((action.queryParams ?? []).map(String))\n\n const merged: Record<string, unknown> = {}\n\n if (hasBody && sources.body && typeof sources.body === 'object') {\n Object.assign(merged, sources.body as Record<string, unknown>)\n }\n\n for (const [key, raw] of Object.entries(query)) {\n if (raw === undefined) { continue }\n const declared = hasBody ? queryKeys.has(key) : (key in shape && !pathParams.has(key))\n if (!declared) { continue }\n merged[key] = Array.isArray(raw) ? raw : coerceScalar(shape[key], raw)\n }\n\n for (const key of pathParams) {\n const raw = params[key]\n if (raw === undefined) { continue }\n merged[key] = coerceScalar(shape[key], raw)\n }\n\n return merged\n}\n","export interface MessageOptions {\n message: string\n}\n\nexport interface ProgressOptions {\n progress: number\n total?: number\n message?: string\n}\n\nconst LogLevels = ['error', 'debug', 'info', 'notice', 'warning', 'critical', 'alert', 'emergency'] as const\n\nexport type LogLevel = typeof LogLevels[number]\n\nexport type LogFn = (data: unknown) => void\n\nexport interface Logger extends Record<LogLevel, LogFn> {\n progress: (options: ProgressOptions) => void\n}\n\nexport { LogLevels }\n\n// Severity ordering (lowest number = most verbose) used to gate writes by the\n// configured `level` threshold. Mirrors syslog-style precedence so a `level` of\n// e.g. `'warning'` suppresses `info`/`notice`/`debug`.\nconst LEVEL_SEVERITY: Record<LogLevel, number> = {\n debug: 10,\n info: 20,\n notice: 30,\n warning: 40,\n error: 50,\n critical: 60,\n alert: 70,\n emergency: 80\n}\n\nexport interface CreateLoggerOptions {\n name?: string\n /** Minimum severity to write to `stream`. Defaults to `'debug'` (everything). */\n level?: LogLevel\n /**\n * Destination stream for structured log lines, or `false` to discard them.\n * Defaults to `process.stdout`. The `onLog` callback always fires regardless\n * of this setting - the stream is just the diagnostic sink.\n */\n stream?: NodeJS.WritableStream | false\n onLog?: (level: LogLevel, data: unknown) => void\n onProgress?: (options: ProgressOptions) => void\n}\n\nexport function createLogger(options: CreateLoggerOptions = {}): Logger {\n const { name, level = 'debug', stream, onLog, onProgress } = options\n\n const target = stream === false ? undefined : stream ?? process.stdout\n const threshold = LEVEL_SEVERITY[level] ?? LEVEL_SEVERITY.debug\n\n const write = (logLevel: LogLevel, data: unknown) => {\n if (target && LEVEL_SEVERITY[logLevel] >= threshold) {\n const line = typeof data === 'object' && data !== null\n ? { level: logLevel, time: Date.now(), name, ...data }\n : { level: logLevel, time: Date.now(), name, msg: data }\n target.write(`${JSON.stringify(line)}\\n`)\n }\n }\n\n const logLevels = Object.fromEntries(LogLevels.map((logLevel) => {\n return [logLevel, (data: unknown) => {\n write(logLevel, data)\n onLog?.(logLevel, data)\n }]\n })) as Record<LogLevel, LogFn>\n\n return {\n ...logLevels,\n progress: (progressOptions) => {\n if (onProgress) {\n onProgress(progressOptions)\n } else {\n write('info', { ...progressOptions })\n }\n }\n }\n}\n\nexport function buildLogLevels(fn: (level: LogLevel, data: unknown) => void): Record<LogLevel, LogFn> {\n return Object.fromEntries(LogLevels.map((level) => [level, (data: unknown) => { fn(level, data) }])) as Record<LogLevel, LogFn>\n}\n\n// Maps each syslog level onto a `console` method for a human-readable terminal\n// logger. Used by the `cli` adapter and the MCP `cliProxy` client - a\n// zero-dependency replacement for a terminal-UI logging library.\nconst CONSOLE_LEVEL_MAP: Record<LogLevel, 'log' | 'info' | 'warn' | 'error'> = {\n debug: 'log',\n info: 'info',\n notice: 'info',\n warning: 'warn',\n error: 'error',\n critical: 'error',\n alert: 'error',\n emergency: 'error'\n}\n\n/**\n * Human-readable `console`-backed logger for terminal contexts. Strings are\n * written verbatim; objects are JSON-stringified. Zero dependencies.\n */\nexport function createConsoleLogger(): Logger {\n const toString = (value: unknown) => typeof value === 'string' ? value : JSON.stringify(value)\n return {\n ...buildLogLevels((level, data) => {\n console[CONSOLE_LEVEL_MAP[level]](toString(data))\n }),\n progress: ({ progress, total, message }) => {\n console.info(toString({ progress, total, message }))\n }\n }\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { Action, ActionStreamRun, isStreamingAction } from './action.js'\nimport { SilkweaveContext } from './context.js'\n\n/**\n * Drive a streaming action's async generator. Calls `onChunk` once per yielded\n * value and awaits it before pulling the next value from the generator - this\n * is what wires transport-level backpressure (SSE drain, stdout flush, tRPC\n * subscription consumer) back to the action.\n *\n * Returns the buffered array of all chunks. Use this for non-streaming\n * adapters or when a client has opted out of streaming (e.g. no MCP\n * `progressToken`). Pass `onChunk` to also emit each chunk on the wire.\n */\nexport async function runStreamingAction<C>(\n action: Action<any, any, string, any, C>,\n input: object,\n context: SilkweaveContext,\n onChunk?: (chunk: C, index: number) => void | Promise<void>\n): Promise<C[]> {\n if (!isStreamingAction(action)) {\n throw new Error(`Action ${action.name} is not a streaming action`)\n }\n const run = action.run as ActionStreamRun<object, C>\n const iter = run(input, context)\n const chunks: C[] = []\n let index = 0\n for await (const chunk of iter) {\n chunks.push(chunk)\n if (onChunk) { await onChunk(chunk, index) }\n index += 1\n }\n return chunks\n}\n","import { SilkweaveContext } from './context.js'\n\n/**\n * One tool/procedure invocation, as reported to an `OnToolCall` hook. MCP\n * adapters emit these from the tool registrar (where result formatting\n * happens, so `resultBytes`/`sideloaded` are known); other transports emit\n * from their own invocation seam and omit the MCP-only fields.\n */\nexport interface ToolCallEvent {\n /** Action name (e.g. `'leads.bulkUpdate'`). */\n action: string\n /** Wire name the client called (e.g. `'LeadsBulkUpdate'` over MCP, `'leadsBulkUpdate'` over tRPC). */\n tool: string\n transport: 'mcp' | 'trpc' | 'rest' | 'cli'\n /** Wall-clock duration; for streaming actions this spans full generator consumption. */\n durationMs: number\n /**\n * `false` when the action threw or the formatted result is an MCP\n * `isError` tool result. `errorCode`/`errorMessage` are set for thrown\n * errors (a `SilkweaveError`'s `code`, else the error's `name`).\n */\n ok: boolean\n errorCode?: string\n errorMessage?: string\n /** Serialized (JSON) size of the raw result - MCP-layer events only. */\n resultBytes?: number\n /** Whether `smartToolResult` offloaded the payload to an embedded resource - MCP-layer events only. */\n sideloaded?: boolean\n /** The per-call action context (access to `auth`/`request` for spaceId, apiKeyId, ...). */\n context: SilkweaveContext\n}\n\n/**\n * Telemetry hook invoked once per tool call, fire-and-forget: adapters never\n * await it on the result path and swallow (log) its errors, so the hook can\n * never fail, slow, or reorder a call.\n */\nexport type OnToolCall = (event: ToolCallEvent) => void | Promise<void>\n\n/**\n * Invoke an `OnToolCall` hook with fire-and-forget semantics - sync throws and\n * async rejections are logged to stderr and never propagate to the call path.\n */\nexport function emitToolCall(hook: OnToolCall | undefined, event: ToolCallEvent): void {\n if (!hook) { return }\n try {\n void Promise.resolve(hook(event)).catch((error: unknown) => { console.error('onToolCall hook error:', error) })\n } catch (error) {\n console.error('onToolCall hook error:', error)\n }\n}\n"],"mappings":";;AASA,SAAgB,cAAc,QAAiC,EAAE,EAAoB;AACnF,QAAO;EACL,YAAY;AACV,UAAO,OAAO,KAAK,MAAM;;EAE3B,MAAM,QAAyB;AAC7B,UAAO,MAAM,QAAQ;;EAEvB,MAAS,QAAmB;GAC1B,MAAM,QAAQ,MAAM;AACpB,OAAI,SAAS,KAAQ,OAAM,IAAI,MAAM,wBAAwB,MAAM;AACnE,UAAO;;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;AACrF,KAAI,CAAC,KAAQ;AACb,KAAI;AACG,UAAQ,QAAQ,KAAK,MAAM,CAAC,CAAC,OAAO,UAAmB;AAAE,WAAQ,MAAM,0BAA0B,MAAM;IAAG;UACxG,OAAO;AACd,UAAQ,MAAM,0BAA0B,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@silkweave/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Silkweave Core",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.silkweave.dev",
|
|
@@ -25,9 +25,6 @@
|
|
|
25
25
|
"default": "./build/index.mjs"
|
|
26
26
|
}
|
|
27
27
|
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@modelcontextprotocol/sdk": "^1.29.0"
|
|
30
|
-
},
|
|
31
28
|
"peerDependencies": {
|
|
32
29
|
"zod": "^3.25.0"
|
|
33
30
|
},
|