silkweave 2.6.1 → 3.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/README.md +19 -19
- 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/package.json +16 -12
- package/build/vercel.d.mts +0 -1
- package/build/vercel.mjs +0 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ 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
19
|
│ │ │ + Swagger │ │ │ + clack │ │ MCP │
|
|
20
20
|
└─────────────┘ └───────────┘ │ └────────────┘ └──────────┘
|
|
@@ -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)
|
|
@@ -76,7 +76,7 @@ Silkweave is organized as a monorepo with modular packages. Install only what yo
|
|
|
76
76
|
| `@silkweave/mcp` | [](https://www.npmjs.com/package/@silkweave/mcp) | MCP adapters - stdio, streamable HTTP, CLI proxy |
|
|
77
77
|
| `@silkweave/cli` | [](https://www.npmjs.com/package/@silkweave/cli) | CLI adapter - commander + clack terminal UI |
|
|
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
81
|
| `@silkweave/logger` | [](https://www.npmjs.com/package/@silkweave/logger) | Logging utilities - pino, clack, and MCP notification support |
|
|
82
82
|
|
|
@@ -93,13 +93,13 @@ pnpm add @silkweave/core @silkweave/fastify
|
|
|
93
93
|
pnpm add @silkweave/core @silkweave/cli
|
|
94
94
|
|
|
95
95
|
# Vercel serverless MCP
|
|
96
|
-
pnpm add @silkweave/core @silkweave/
|
|
96
|
+
pnpm add @silkweave/core @silkweave/edge
|
|
97
97
|
|
|
98
98
|
# Vercel AI SDK chat (useChat over tRPC subscriptions)
|
|
99
99
|
pnpm add @silkweave/core @silkweave/trpc @silkweave/ai ai @ai-sdk/anthropic
|
|
100
100
|
|
|
101
101
|
# All of the above
|
|
102
|
-
pnpm add @silkweave/core @silkweave/mcp @silkweave/cli @silkweave/fastify @silkweave/
|
|
102
|
+
pnpm add @silkweave/core @silkweave/mcp @silkweave/cli @silkweave/fastify @silkweave/edge @silkweave/ai
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
---
|
|
@@ -407,17 +407,17 @@ $ mytool greet --name "World" --enthusiastic
|
|
|
407
407
|
ℹ HELLO, WORLD!!!
|
|
408
408
|
```
|
|
409
409
|
|
|
410
|
-
###
|
|
410
|
+
### Edge Adapter
|
|
411
411
|
|
|
412
412
|
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
413
|
|
|
414
414
|
```typescript
|
|
415
|
-
// api/mcp.ts (
|
|
415
|
+
// api/mcp.ts (edge / serverless function)
|
|
416
416
|
import { silkweave } from '@silkweave/core'
|
|
417
|
-
import {
|
|
417
|
+
import { edge } from '@silkweave/edge'
|
|
418
418
|
import { SearchAction } from '../actions/search.js'
|
|
419
419
|
|
|
420
|
-
const { adapter, handler } =
|
|
420
|
+
const { adapter, handler } = edge()
|
|
421
421
|
|
|
422
422
|
await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
423
423
|
.adapter(adapter)
|
|
@@ -427,12 +427,12 @@ await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
|
427
427
|
export default { fetch: handler }
|
|
428
428
|
```
|
|
429
429
|
|
|
430
|
-
The `
|
|
430
|
+
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
431
|
|
|
432
432
|
**For Next.js App Router** (`app/api/mcp/route.ts`):
|
|
433
433
|
|
|
434
434
|
```typescript
|
|
435
|
-
const { adapter, GET, POST, DELETE } =
|
|
435
|
+
const { adapter, GET, POST, DELETE } = edge()
|
|
436
436
|
|
|
437
437
|
await silkweave({ name: 'my-tools', description: 'My Tools', version: '1.0.0' })
|
|
438
438
|
.adapter(adapter)
|
|
@@ -449,7 +449,7 @@ export { GET, POST, DELETE }
|
|
|
449
449
|
- Logging goes to `process.stderr` (Vercel log drain) and MCP client notifications
|
|
450
450
|
- No CORS handling - use Next.js middleware or `vercel.json` headers
|
|
451
451
|
|
|
452
|
-
**`
|
|
452
|
+
**`EdgeAdapterOptions`:**
|
|
453
453
|
|
|
454
454
|
| Option | Type | Default | Description |
|
|
455
455
|
|--------|------|---------|-------------|
|
|
@@ -534,7 +534,7 @@ Adapters detect streaming actions via `isStreamingAction()` at registration time
|
|
|
534
534
|
|---------|-------------|---------------------|-------------------|
|
|
535
535
|
| **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
536
|
| **MCP HTTP** (`@silkweave/mcp`) | Same - `notifications/progress` carried on the session's SSE stream | Same - `_meta.progressToken` | Same |
|
|
537
|
-
| **MCP
|
|
537
|
+
| **MCP Edge** (`@silkweave/edge`) | Same - `notifications/progress` over Streamable HTTP | Same | Same |
|
|
538
538
|
| **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
539
|
| **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
540
|
| **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 +624,7 @@ See [`examples/ai/`](../../examples/ai) in the repo for a complete Vite + React
|
|
|
624
624
|
|
|
625
625
|
## Smart Tool Results
|
|
626
626
|
|
|
627
|
-
MCP adapters (stdio, HTTP, and
|
|
627
|
+
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
628
|
|
|
629
629
|
- **Small responses** (≤ 4096 chars): returned as inline `TextContent` JSON
|
|
630
630
|
- **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
|
|
@@ -927,13 +927,13 @@ interface FastifyAdapterOptions {
|
|
|
927
927
|
import { cli } from '@silkweave/cli'
|
|
928
928
|
function cli(): AdapterFactory
|
|
929
929
|
|
|
930
|
-
//
|
|
931
|
-
import {
|
|
932
|
-
function
|
|
933
|
-
interface
|
|
930
|
+
// Edge / serverless - from @silkweave/edge
|
|
931
|
+
import { edge } from '@silkweave/edge'
|
|
932
|
+
function edge(options?: EdgeAdapterOptions): EdgeAdapter
|
|
933
|
+
interface EdgeAdapterOptions {
|
|
934
934
|
enableJsonResponse?: boolean
|
|
935
935
|
}
|
|
936
|
-
interface
|
|
936
|
+
interface EdgeAdapter {
|
|
937
937
|
adapter: AdapterGenerator // Pass to silkweave().adapter()
|
|
938
938
|
handler: (req: Request) => Promise<Response>
|
|
939
939
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "silkweave",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.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,20 @@
|
|
|
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/mcp": "
|
|
64
|
-
"@silkweave/
|
|
65
|
-
"@silkweave/
|
|
62
|
+
"@silkweave/auth": "3.0.0",
|
|
63
|
+
"@silkweave/cli": "3.0.0",
|
|
64
|
+
"@silkweave/core": "3.0.0",
|
|
65
|
+
"@silkweave/fastify": "3.0.0",
|
|
66
|
+
"@silkweave/logger": "3.0.0",
|
|
67
|
+
"@silkweave/mcp": "3.0.0",
|
|
68
|
+
"@silkweave/typegen": "3.0.0",
|
|
69
|
+
"@silkweave/edge": "3.0.0"
|
|
66
70
|
},
|
|
67
71
|
"devDependencies": {
|
|
68
72
|
"@eslint/js": "^10.0.1",
|
package/build/vercel.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@silkweave/vercel";
|
package/build/vercel.mjs
DELETED