@waniwani/sdk 0.9.9 → 0.9.11
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/LICENSE +661 -21
- package/README.md +39 -32
- package/dist/chat/index.js +7 -7
- package/dist/chat/index.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.js +5 -5
- package/dist/mcp/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,26 +3,28 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/@waniwani/sdk)
|
|
4
4
|
[](./LICENSE)
|
|
5
5
|
|
|
6
|
-
> The official SDK for [WaniWani](https://waniwani.ai)
|
|
6
|
+
> The official SDK for [WaniWani](https://waniwani.ai). Build, ship, and measure conversational MCP apps.
|
|
7
7
|
|
|
8
|
-
`@waniwani/sdk` is the developer-facing library
|
|
8
|
+
`@waniwani/sdk` is the developer-facing library for your MCP (Model Context Protocol) server. It provides **event tracking** and **multi-step conversational flows**.
|
|
9
9
|
|
|
10
|
-
- **Zero runtime dependencies
|
|
11
|
-
- **Works with any MCP runtime
|
|
12
|
-
- **Fully typed
|
|
13
|
-
- **Automatic tool tracking
|
|
14
|
-
- **LangGraph-inspired flows
|
|
10
|
+
- **Zero runtime dependencies.** Sub-5KB core bundle, safe for serverless and edge runtimes.
|
|
11
|
+
- **Works with any MCP runtime.** [`@modelcontextprotocol/sdk`](https://www.npmjs.com/package/@modelcontextprotocol/sdk), [Skybridge](https://github.com/alpic-ai/skybridge), [`@vercel/mcp-handler`](https://www.npmjs.com/package/@vercel/mcp-handler).
|
|
12
|
+
- **Fully typed.** Zod state schemas, inferred node contexts, typed event properties.
|
|
13
|
+
- **Automatic tool tracking.** One call to `withWaniwani(server)` and every tool invocation is tracked.
|
|
14
|
+
- **LangGraph-inspired flows.** Compile a state graph into a single MCP tool that drives multi-turn conversations.
|
|
15
15
|
|
|
16
|
-
> **Status:** pre-alpha. APIs and
|
|
16
|
+
> **Status:** pre-alpha. APIs and behavior may change between releases. Pin versions in production.
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
|
|
21
|
+
bun add @waniwani/sdk
|
|
22
22
|
# or
|
|
23
23
|
pnpm add @waniwani/sdk
|
|
24
24
|
# or
|
|
25
|
-
|
|
25
|
+
npm install @waniwani/sdk
|
|
26
|
+
# or
|
|
27
|
+
yarn add @waniwani/sdk
|
|
26
28
|
```
|
|
27
29
|
|
|
28
30
|
Requires Node 18.17+ and an MCP server runtime.
|
|
@@ -31,35 +33,40 @@ Requires Node 18.17+ and an MCP server runtime.
|
|
|
31
33
|
|
|
32
34
|
### 1. Get an API key
|
|
33
35
|
|
|
34
|
-
Sign in to [app.waniwani.ai](https://app.waniwani.ai), create an MCP environment, and copy its API key. Expose it to your server as `WANIWANI_API_KEY`:
|
|
36
|
+
Sign in to [app.waniwani.ai](https://app.waniwani.ai), create an MCP environment, and copy its API key. Keys are prefixed with `wwk_` and shown in full only once. Expose it to your server as `WANIWANI_API_KEY`:
|
|
35
37
|
|
|
36
38
|
```bash
|
|
37
39
|
# .env
|
|
38
|
-
WANIWANI_API_KEY=
|
|
40
|
+
WANIWANI_API_KEY=wwk_...
|
|
39
41
|
```
|
|
40
42
|
|
|
41
43
|
### 2. Wrap your MCP server
|
|
42
44
|
|
|
43
45
|
```ts
|
|
44
|
-
import
|
|
46
|
+
import express from "express";
|
|
45
47
|
import { withWaniwani } from "@waniwani/sdk/mcp";
|
|
46
|
-
import { McpServer } from "
|
|
48
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
49
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
47
50
|
import "dotenv/config";
|
|
48
51
|
|
|
49
|
-
const server = new McpServer(
|
|
50
|
-
{ name: "my-mcp-app", version: "0.0.1" },
|
|
51
|
-
{ capabilities: {} },
|
|
52
|
-
);
|
|
52
|
+
const server = new McpServer({ name: "my-mcp-app", version: "0.0.1" });
|
|
53
53
|
|
|
54
54
|
server.registerTool(/* ... your tools ... */);
|
|
55
55
|
|
|
56
|
-
// One
|
|
57
|
-
withWaniwani(server
|
|
56
|
+
// One call. Every registered tool is now tracked automatically.
|
|
57
|
+
withWaniwani(server);
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
// Connect the Streamable HTTP transport
|
|
60
|
+
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined });
|
|
61
|
+
await server.connect(transport);
|
|
62
|
+
|
|
63
|
+
const app = express();
|
|
64
|
+
app.use(express.json());
|
|
65
|
+
app.post("/mcp", (req, res) => transport.handleRequest(req, res, req.body));
|
|
66
|
+
app.listen(3000);
|
|
60
67
|
```
|
|
61
68
|
|
|
62
|
-
Every tool call produces a `tool.called` event with duration, status, input/output, and session correlation
|
|
69
|
+
Every tool call produces a `tool.called` event with duration, status, input/output, and session correlation, all visible in your WaniWani dashboard within seconds.
|
|
63
70
|
|
|
64
71
|
### 3. Track custom events
|
|
65
72
|
|
|
@@ -111,11 +118,11 @@ export const onboardingFlow = createFlow({
|
|
|
111
118
|
await onboardingFlow.register(server);
|
|
112
119
|
```
|
|
113
120
|
|
|
114
|
-
The engine handles state persistence, resumption, branching, and validation. The model
|
|
121
|
+
The engine handles state persistence, resumption, branching, and validation. The model calls one tool and the rest is managed server-side.
|
|
115
122
|
|
|
116
123
|
## Documentation
|
|
117
124
|
|
|
118
|
-
Full product documentation lives at **[docs.waniwani.ai](https://docs.waniwani.ai)
|
|
125
|
+
Full product documentation lives at **[docs.waniwani.ai](https://docs.waniwani.ai)**:
|
|
119
126
|
|
|
120
127
|
- [Introduction](https://docs.waniwani.ai/introduction)
|
|
121
128
|
- [Quickstart](https://docs.waniwani.ai/quickstart)
|
|
@@ -132,22 +139,22 @@ The same docs are also available in this repository under [`docs/`](./docs).
|
|
|
132
139
|
| `@waniwani/sdk` | `waniwani()` client: event tracking, identify, flush, shutdown. |
|
|
133
140
|
| `@waniwani/sdk/mcp` | `withWaniwani`, `createFlow`, `createTool`, `createResource`, flow primitives. |
|
|
134
141
|
| `@waniwani/sdk/mcp/react` | React hooks for WaniWani-powered widgets. |
|
|
135
|
-
| `@waniwani/sdk/chat` | Chat UI components for embedding conversations. |
|
|
136
|
-
| `@waniwani/sdk/kb` | Knowledge base client. |
|
|
137
142
|
|
|
138
143
|
Most users only need `@waniwani/sdk` and `@waniwani/sdk/mcp`.
|
|
139
144
|
|
|
140
145
|
## Examples
|
|
141
146
|
|
|
142
|
-
- **[Alpic x WaniWani demo](https://github.com/
|
|
147
|
+
- **[Alpic x WaniWani demo](https://github.com/WaniWani-AI/alpic-x-waniwani-demo)**: a Skybridge MCP server with a full `createFlow` booking journey.
|
|
143
148
|
|
|
144
149
|
## Links
|
|
145
150
|
|
|
146
|
-
- **Website
|
|
147
|
-
- **Dashboard
|
|
148
|
-
- **Docs
|
|
149
|
-
- **Issues
|
|
151
|
+
- **Website**: [waniwani.ai](https://waniwani.ai)
|
|
152
|
+
- **Dashboard**: [app.waniwani.ai](https://app.waniwani.ai)
|
|
153
|
+
- **Docs**: [docs.waniwani.ai](https://docs.waniwani.ai)
|
|
154
|
+
- **Issues**: [github.com/WaniWani-AI/sdk/issues](https://github.com/WaniWani-AI/sdk/issues)
|
|
150
155
|
|
|
151
156
|
## License
|
|
152
157
|
|
|
153
|
-
[
|
|
158
|
+
[AGPL-3.0-or-later](./LICENSE) © WaniWani
|
|
159
|
+
|
|
160
|
+
"WaniWani" is a trademark of WaniWani. The license covers the code, not the name.
|