@runtypelabs/persona-proxy 1.36.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 +106 -0
- package/dist/index.cjs +621 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +120 -0
- package/dist/index.d.ts +120 -0
- package/dist/index.js +589 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
- package/src/flows/components.ts +58 -0
- package/src/flows/conversational.ts +26 -0
- package/src/flows/index.ts +11 -0
- package/src/flows/scheduling.ts +64 -0
- package/src/flows/shopping-assistant.ts +171 -0
- package/src/index.ts +331 -0
- package/src/utils/index.ts +10 -0
- package/src/utils/stripe.ts +115 -0
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
## Vanilla Agent Proxy
|
|
2
|
+
|
|
3
|
+
Proxy server library for `@runtypelabs/persona` widget. Handles flow configuration and forwards requests to Travrse or other AI backends.
|
|
4
|
+
|
|
5
|
+
### Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @runtypelabs/persona-proxy
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
### Usage
|
|
12
|
+
|
|
13
|
+
The proxy server handles flow configuration and forwards requests to Travrse. You can configure it in three ways:
|
|
14
|
+
|
|
15
|
+
**Option 1: Use default flow (recommended for getting started)**
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
// api/chat.ts
|
|
19
|
+
import { createChatProxyApp } from '@runtypelabs/persona-proxy';
|
|
20
|
+
|
|
21
|
+
export default createChatProxyApp({
|
|
22
|
+
path: '/api/chat/dispatch',
|
|
23
|
+
allowedOrigins: ['https://www.example.com']
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Option 2: Reference a Travrse flow ID**
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { createChatProxyApp } from '@runtypelabs/persona-proxy';
|
|
31
|
+
|
|
32
|
+
export default createChatProxyApp({
|
|
33
|
+
path: '/api/chat/dispatch',
|
|
34
|
+
allowedOrigins: ['https://www.example.com'],
|
|
35
|
+
flowId: 'flow_abc123' // Flow created in Travrse dashboard or API
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**Option 3: Define a custom flow**
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createChatProxyApp } from '@runtypelabs/persona-proxy';
|
|
43
|
+
|
|
44
|
+
export default createChatProxyApp({
|
|
45
|
+
path: '/api/chat/dispatch',
|
|
46
|
+
allowedOrigins: ['https://www.example.com'],
|
|
47
|
+
flowConfig: {
|
|
48
|
+
name: "Custom Chat Flow",
|
|
49
|
+
description: "Specialized assistant flow",
|
|
50
|
+
steps: [
|
|
51
|
+
{
|
|
52
|
+
id: "custom_prompt",
|
|
53
|
+
name: "Custom Prompt",
|
|
54
|
+
type: "prompt",
|
|
55
|
+
enabled: true,
|
|
56
|
+
config: {
|
|
57
|
+
model: "meta/llama3.1-8b-instruct-free",
|
|
58
|
+
responseFormat: "markdown",
|
|
59
|
+
outputVariable: "prompt_result",
|
|
60
|
+
userPrompt: "{{user_message}}",
|
|
61
|
+
systemPrompt: "you are a helpful assistant, chatting with a user",
|
|
62
|
+
previousMessages: "{{messages}}"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Hosting on Vercel:**
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { createVercelHandler } from '@runtypelabs/persona-proxy';
|
|
74
|
+
|
|
75
|
+
export default createVercelHandler({
|
|
76
|
+
allowedOrigins: ['https://www.example.com'],
|
|
77
|
+
flowId: 'flow_abc123' // Optional
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Configuration Options
|
|
82
|
+
|
|
83
|
+
| Option | Type | Description |
|
|
84
|
+
| --- | --- | --- |
|
|
85
|
+
| `upstreamUrl` | `string` | Travrse API endpoint (defaults to `https://api.travrse.ai/v1/dispatch`) |
|
|
86
|
+
| `apiKey` | `string` | Travrse API key (defaults to `TRAVRSE_API_KEY` environment variable) |
|
|
87
|
+
| `path` | `string` | Proxy endpoint path (defaults to `/api/chat/dispatch`) |
|
|
88
|
+
| `allowedOrigins` | `string[]` | CORS allowed origins |
|
|
89
|
+
| `flowId` | `string` | Travrse flow ID to use |
|
|
90
|
+
| `flowConfig` | `TravrseFlowConfig` | Custom flow configuration |
|
|
91
|
+
|
|
92
|
+
### Environment Setup
|
|
93
|
+
|
|
94
|
+
Add `TRAVRSE_API_KEY` to your environment. The proxy constructs the Travrse payload (including flow configuration) and streams the response back to the client.
|
|
95
|
+
|
|
96
|
+
### Building
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pnpm build
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
This generates:
|
|
103
|
+
- `dist/index.js` (ESM)
|
|
104
|
+
- `dist/index.cjs` (CJS)
|
|
105
|
+
- Type definitions in `dist/index.d.ts`
|
|
106
|
+
|