silkweave 2.6.1 → 3.1.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/README.md +24 -25
- package/build/auth-oauth.d.mts +1 -0
- package/build/auth-oauth.mjs +2 -0
- package/build/edge.d.mts +1 -0
- package/build/edge.mjs +2 -0
- package/build/logger.d.mts +2 -1
- package/build/logger.mjs +2 -2
- package/package.json +15 -12
- package/build/vercel.d.mts +0 -1
- package/build/vercel.mjs +0 -2
package/README.md
CHANGED
|
@@ -14,9 +14,9 @@ Silkweave is a TypeScript toolkit that lets you define application logic as port
|
|
|
14
14
|
┌──────────────┬───────┼───────┬──────────────┐
|
|
15
15
|
│ │ │ │ │
|
|
16
16
|
┌──────▼──────┐ ┌─────▼─────┐ │ ┌─────▼──────┐ ┌────▼─────┐
|
|
17
|
-
│ MCP (stdio) │ │ Fastify │ │ │ CLI │ │
|
|
17
|
+
│ MCP (stdio) │ │ Fastify │ │ │ CLI │ │ Edge │
|
|
18
18
|
│ MCP (http) │ │ REST API │ │ │ commander │ │serverless│
|
|
19
|
-
│ │ │ + Swagger │ │ │
|
|
19
|
+
│ │ │ + Swagger │ │ │ console │ │ MCP │
|
|
20
20
|
└─────────────┘ └───────────┘ │ └────────────┘ └──────────┘
|
|
21
21
|
│
|
|
22
22
|
```
|
|
@@ -37,7 +37,7 @@ Silkweave is a TypeScript toolkit that lets you define application logic as port
|
|
|
37
37
|
- [MCP Streamable HTTP](#mcp-streamable-http)
|
|
38
38
|
- [Fastify REST API](#fastify-rest-api)
|
|
39
39
|
- [CLI](#cli)
|
|
40
|
-
- [
|
|
40
|
+
- [Edge Adapter](#edge-adapter)
|
|
41
41
|
- [Logging and Progress](#logging-and-progress)
|
|
42
42
|
- [Streaming Actions](#streaming-actions)
|
|
43
43
|
- [Plug into Vercel AI SDK](#plug-into-vercel-ai-sdk)
|
|
@@ -60,7 +60,7 @@ Silkweave eliminates this duplication. You define an **Action** - a name, a Zod
|
|
|
60
60
|
|
|
61
61
|
- **MCP adapters** register your actions as MCP tools with proper notifications, progress reporting, and error handling
|
|
62
62
|
- **Fastify adapter** generates a REST API with full OpenAPI/Swagger documentation derived from your Zod schemas
|
|
63
|
-
- **CLI adapter** builds a complete command-line interface with argument parsing, option flags, and
|
|
63
|
+
- **CLI adapter** builds a complete command-line interface with argument parsing, option flags, and plain `console` output
|
|
64
64
|
|
|
65
65
|
Your action doesn't know or care which transport is running it.
|
|
66
66
|
|
|
@@ -74,11 +74,10 @@ Silkweave is organized as a monorepo with modular packages. Install only what yo
|
|
|
74
74
|
|---------|-----|-------------|
|
|
75
75
|
| `@silkweave/core` | [](https://www.npmjs.com/package/@silkweave/core) | Core library - actions, adapters, builder, context, logger, utilities |
|
|
76
76
|
| `@silkweave/mcp` | [](https://www.npmjs.com/package/@silkweave/mcp) | MCP adapters - stdio, streamable HTTP, CLI proxy |
|
|
77
|
-
| `@silkweave/cli` | [](https://www.npmjs.com/package/@silkweave/cli) | CLI adapter - commander +
|
|
77
|
+
| `@silkweave/cli` | [](https://www.npmjs.com/package/@silkweave/cli) | CLI adapter - commander + plain `console` output |
|
|
78
78
|
| `@silkweave/fastify` | [](https://www.npmjs.com/package/@silkweave/fastify) | Fastify REST adapter - auto-generated OpenAPI/Swagger docs |
|
|
79
|
-
| `@silkweave/
|
|
79
|
+
| `@silkweave/edge` | [](https://www.npmjs.com/package/@silkweave/edge) | Edge / serverless adapter - stateless MCP over Web Standard Streamable HTTP |
|
|
80
80
|
| `@silkweave/ai` | [](https://www.npmjs.com/package/@silkweave/ai) | Vercel AI SDK bridge - `createChatAction()` + `silkweaveTransport()` for `useChat` over tRPC subscriptions |
|
|
81
|
-
| `@silkweave/logger` | [](https://www.npmjs.com/package/@silkweave/logger) | Logging utilities - pino, clack, and MCP notification support |
|
|
82
81
|
|
|
83
82
|
**`@silkweave/core`** is always required. Then add the adapter packages for the transports you need:
|
|
84
83
|
|
|
@@ -93,13 +92,13 @@ pnpm add @silkweave/core @silkweave/fastify
|
|
|
93
92
|
pnpm add @silkweave/core @silkweave/cli
|
|
94
93
|
|
|
95
94
|
# Vercel serverless MCP
|
|
96
|
-
pnpm add @silkweave/core @silkweave/
|
|
95
|
+
pnpm add @silkweave/core @silkweave/edge
|
|
97
96
|
|
|
98
97
|
# Vercel AI SDK chat (useChat over tRPC subscriptions)
|
|
99
98
|
pnpm add @silkweave/core @silkweave/trpc @silkweave/ai ai @ai-sdk/anthropic
|
|
100
99
|
|
|
101
100
|
# All of the above
|
|
102
|
-
pnpm add @silkweave/core @silkweave/mcp @silkweave/cli @silkweave/fastify @silkweave/
|
|
101
|
+
pnpm add @silkweave/core @silkweave/mcp @silkweave/cli @silkweave/fastify @silkweave/edge @silkweave/ai
|
|
103
102
|
```
|
|
104
103
|
|
|
105
104
|
---
|
|
@@ -373,7 +372,7 @@ fastify({
|
|
|
373
372
|
|
|
374
373
|
### CLI
|
|
375
374
|
|
|
376
|
-
Transforms your actions into a complete command-line application with help text, option parsing, and
|
|
375
|
+
Transforms your actions into a complete command-line application with help text, option parsing, and plain `console` output.
|
|
377
376
|
|
|
378
377
|
```typescript
|
|
379
378
|
import { silkweave } from '@silkweave/core'
|
|
@@ -407,17 +406,17 @@ $ mytool greet --name "World" --enthusiastic
|
|
|
407
406
|
ℹ HELLO, WORLD!!!
|
|
408
407
|
```
|
|
409
408
|
|
|
410
|
-
###
|
|
409
|
+
### Edge Adapter
|
|
411
410
|
|
|
412
411
|
Deploy your actions as a stateless MCP server on Vercel. Each request creates a fresh server instance - no sessions, no persistent connections, fully compatible with serverless constraints.
|
|
413
412
|
|
|
414
413
|
```typescript
|
|
415
|
-
// api/mcp.ts (
|
|
414
|
+
// api/mcp.ts (edge / serverless function)
|
|
416
415
|
import { silkweave } from '@silkweave/core'
|
|
417
|
-
import {
|
|
416
|
+
import { edge } from '@silkweave/edge'
|
|
418
417
|
import { SearchAction } from '../actions/search.js'
|
|
419
418
|
|
|
420
|
-
const { adapter, handler } =
|
|
419
|
+
const { adapter, handler } = edge()
|
|
421
420
|
|
|
422
421
|
await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
423
422
|
.adapter(adapter)
|
|
@@ -427,12 +426,12 @@ await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
|
427
426
|
export default { fetch: handler }
|
|
428
427
|
```
|
|
429
428
|
|
|
430
|
-
The `
|
|
429
|
+
The `edge()` function returns a compound object - `adapter` wires into the Silkweave builder, while `handler`/`GET`/`POST`/`DELETE` are the request handler for your Vercel route.
|
|
431
430
|
|
|
432
431
|
**For Next.js App Router** (`app/api/mcp/route.ts`):
|
|
433
432
|
|
|
434
433
|
```typescript
|
|
435
|
-
const { adapter, GET, POST, DELETE } =
|
|
434
|
+
const { adapter, GET, POST, DELETE } = edge()
|
|
436
435
|
|
|
437
436
|
await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
438
437
|
.adapter(adapter)
|
|
@@ -449,7 +448,7 @@ export { GET, POST, DELETE }
|
|
|
449
448
|
- Logging goes to `process.stderr` (Vercel log drain) and MCP client notifications
|
|
450
449
|
- No CORS handling - use Next.js middleware or `vercel.json` headers
|
|
451
450
|
|
|
452
|
-
**`
|
|
451
|
+
**`EdgeAdapterOptions`:**
|
|
453
452
|
|
|
454
453
|
| Option | Type | Default | Description |
|
|
455
454
|
|--------|------|---------|-------------|
|
|
@@ -534,7 +533,7 @@ Adapters detect streaming actions via `isStreamingAction()` at registration time
|
|
|
534
533
|
|---------|-------------|---------------------|-------------------|
|
|
535
534
|
| **MCP stdio** (`@silkweave/mcp`) | `notifications/progress` - one notification per chunk, with the JSON-stringified chunk in the `message` field and a 1-based `progress` counter | Client sends `_meta.progressToken` in the tool call (MCP SDK does this automatically when the host subscribes) | Action runs to completion; chunks are buffered and returned as the final `CallToolResult` |
|
|
536
535
|
| **MCP HTTP** (`@silkweave/mcp`) | Same - `notifications/progress` carried on the session's SSE stream | Same - `_meta.progressToken` | Same |
|
|
537
|
-
| **MCP
|
|
536
|
+
| **MCP Edge** (`@silkweave/edge`) | Same - `notifications/progress` over Streamable HTTP | Same | Same |
|
|
538
537
|
| **Fastify REST** (`@silkweave/fastify`) | `text/event-stream` (SSE: `data: <json>\n\n`, terminated by `event: done`) **or** `application/x-ndjson` (one JSON chunk per line) | `Accept: text/event-stream` or `Accept: application/x-ndjson` | `200 OK` with the buffered chunk array as JSON |
|
|
539
538
|
| **tRPC** (`@silkweave/trpc`) | Action is registered as a tRPC **`.subscription()`** whose async generator yields chunks directly | Streaming action ⇒ always a subscription, regardless of `kind` | n/a - the consumer iterates the subscription |
|
|
540
539
|
| **CLI** (`@silkweave/cli`) | NDJSON on stdout (one JSON chunk per line, backpressure-aware via `stdout.write` + `drain`) | Streaming action ⇒ always streamed | n/a |
|
|
@@ -624,7 +623,7 @@ See [`examples/ai/`](../../examples/ai) in the repo for a complete Vite + React
|
|
|
624
623
|
|
|
625
624
|
## Smart Tool Results
|
|
626
625
|
|
|
627
|
-
MCP adapters (stdio, HTTP, and
|
|
626
|
+
MCP adapters (stdio, HTTP, and Edge) use `smartToolResult()` by default to format action return values. This is a server-side best practice for managing LLM context bloat:
|
|
628
627
|
|
|
629
628
|
- **Small responses** (≤ 4096 chars): returned as inline `TextContent` JSON
|
|
630
629
|
- **Large responses** (> 4096 chars): split into a short text summary + a base64 **embedded resource**, keeping the LLM's context window lean while preserving full data access
|
|
@@ -923,17 +922,17 @@ interface FastifyAdapterOptions {
|
|
|
923
922
|
// ...plus all FastifyHttpOptions (logger, connectionTimeout, etc.)
|
|
924
923
|
}
|
|
925
924
|
|
|
926
|
-
// CLI via commander
|
|
925
|
+
// CLI via commander - from @silkweave/cli
|
|
927
926
|
import { cli } from '@silkweave/cli'
|
|
928
927
|
function cli(): AdapterFactory
|
|
929
928
|
|
|
930
|
-
//
|
|
931
|
-
import {
|
|
932
|
-
function
|
|
933
|
-
interface
|
|
929
|
+
// Edge / serverless - from @silkweave/edge
|
|
930
|
+
import { edge } from '@silkweave/edge'
|
|
931
|
+
function edge(options?: EdgeAdapterOptions): EdgeAdapter
|
|
932
|
+
interface EdgeAdapterOptions {
|
|
934
933
|
enableJsonResponse?: boolean
|
|
935
934
|
}
|
|
936
|
-
interface
|
|
935
|
+
interface EdgeAdapter {
|
|
937
936
|
adapter: AdapterGenerator // Pass to silkweave().adapter()
|
|
938
937
|
handler: (req: Request) => Promise<Response>
|
|
939
938
|
GET: (req: Request) => Promise<Response>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@silkweave/auth/oauth";
|
package/build/edge.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@silkweave/edge";
|
package/build/edge.mjs
ADDED
package/build/logger.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { CreateLoggerOptions, LogFn, LogLevel, LogLevels, Logger, MessageOptions, ProgressOptions, buildLogLevels, createConsoleLogger, createLogger } from "@silkweave/core";
|
|
2
|
+
export { type CreateLoggerOptions, type LogFn, type LogLevel, LogLevels, type Logger, type MessageOptions, type ProgressOptions, buildLogLevels, createConsoleLogger, createLogger };
|
package/build/logger.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export {};
|
|
1
|
+
import { LogLevels, buildLogLevels, createConsoleLogger, createLogger } from "@silkweave/core";
|
|
2
|
+
export { LogLevels, buildLogLevels, createConsoleLogger, createLogger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silkweave",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Silkweave Umbrella Package",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.silkweave.dev",
|
|
@@ -21,6 +21,10 @@
|
|
|
21
21
|
"types": "./build/auth.d.mts",
|
|
22
22
|
"default": "./build/auth.mjs"
|
|
23
23
|
},
|
|
24
|
+
"./auth/oauth": {
|
|
25
|
+
"types": "./build/auth-oauth.d.mts",
|
|
26
|
+
"default": "./build/auth-oauth.mjs"
|
|
27
|
+
},
|
|
24
28
|
"./cli": {
|
|
25
29
|
"types": "./build/cli.d.mts",
|
|
26
30
|
"default": "./build/cli.mjs"
|
|
@@ -49,20 +53,19 @@
|
|
|
49
53
|
"types": "./build/typegen.d.mts",
|
|
50
54
|
"default": "./build/typegen.mjs"
|
|
51
55
|
},
|
|
52
|
-
"./
|
|
53
|
-
"types": "./build/
|
|
54
|
-
"default": "./build/
|
|
56
|
+
"./edge": {
|
|
57
|
+
"types": "./build/edge.d.mts",
|
|
58
|
+
"default": "./build/edge.mjs"
|
|
55
59
|
}
|
|
56
60
|
},
|
|
57
61
|
"dependencies": {
|
|
58
|
-
"@silkweave/auth": "
|
|
59
|
-
"@silkweave/cli": "
|
|
60
|
-
"@silkweave/
|
|
61
|
-
"@silkweave/
|
|
62
|
-
"@silkweave/
|
|
63
|
-
"@silkweave/
|
|
64
|
-
"@silkweave/
|
|
65
|
-
"@silkweave/typegen": "2.6.1"
|
|
62
|
+
"@silkweave/auth": "3.1.0",
|
|
63
|
+
"@silkweave/cli": "3.1.0",
|
|
64
|
+
"@silkweave/core": "3.1.0",
|
|
65
|
+
"@silkweave/fastify": "3.1.0",
|
|
66
|
+
"@silkweave/mcp": "3.1.0",
|
|
67
|
+
"@silkweave/edge": "3.1.0",
|
|
68
|
+
"@silkweave/typegen": "3.1.0"
|
|
66
69
|
},
|
|
67
70
|
"devDependencies": {
|
|
68
71
|
"@eslint/js": "^10.0.1",
|
package/build/vercel.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@silkweave/vercel";
|
package/build/vercel.mjs
DELETED