@positronic/template-new-project 0.0.73 → 0.0.75
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/index.js +4 -4
- package/package.json +1 -1
- package/template/CLAUDE.md +1 -1
- package/template/_env +1 -1
- package/template/brain.ts +1 -1
- package/template/brains/example.ts +4 -0
- package/template/docs/memory-guide.md +1 -1
- package/template/docs/positronic-guide.md +4 -4
- package/template/runner.ts +33 -1
package/index.js
CHANGED
|
@@ -53,10 +53,10 @@ module.exports = {
|
|
|
53
53
|
],
|
|
54
54
|
setup: async ctx => {
|
|
55
55
|
const devRootPath = process.env.POSITRONIC_LOCAL_PATH;
|
|
56
|
-
let coreVersion = '^0.0.
|
|
57
|
-
let cloudflareVersion = '^0.0.
|
|
58
|
-
let clientVercelVersion = '^0.0.
|
|
59
|
-
let genUIComponentsVersion = '^0.0.
|
|
56
|
+
let coreVersion = '^0.0.75';
|
|
57
|
+
let cloudflareVersion = '^0.0.75';
|
|
58
|
+
let clientVercelVersion = '^0.0.75';
|
|
59
|
+
let genUIComponentsVersion = '^0.0.75';
|
|
60
60
|
|
|
61
61
|
// Map backend selection to package names
|
|
62
62
|
const backendPackageMap = {
|
package/package.json
CHANGED
package/template/CLAUDE.md
CHANGED
|
@@ -126,7 +126,7 @@ The optional `timeout` parameter accepts durations like `'30m'`, `'1h'`, `'24h'`
|
|
|
126
126
|
If your brain generates a custom HTML page with a form that submits to a webhook, you must include a CSRF token. Without a token, the server will reject the submission.
|
|
127
127
|
|
|
128
128
|
1. Generate a token with `generateFormToken()` from `@positronic/core`
|
|
129
|
-
2. Add `<input type="hidden" name="__positronic_token" value="${token}">` to the form
|
|
129
|
+
2. Add `<input type="hidden" name="__positronic_token" value="<%= '${token}' %>">` to the form
|
|
130
130
|
3. Pass the token when creating the webhook registration: `myWebhook(identifier, token)`
|
|
131
131
|
|
|
132
132
|
The `.ui()` step handles this automatically. See `/docs/brain-dsl-guide.md` for full examples.
|
package/template/_env
CHANGED
package/template/brain.ts
CHANGED
|
@@ -81,7 +81,7 @@ import { components } from './components/index.js';
|
|
|
81
81
|
* const memoryTools = createMem0Tools();
|
|
82
82
|
* ```
|
|
83
83
|
*
|
|
84
|
-
* Memory is automatically scoped to the current user (via currentUser.
|
|
84
|
+
* Memory is automatically scoped to the current user (via currentUser.name)
|
|
85
85
|
* and the brain name. No need to pass userId manually.
|
|
86
86
|
*
|
|
87
87
|
* See docs/memory-guide.md for full details.
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { brain } from '../brain.js';
|
|
3
3
|
|
|
4
|
+
// This brain uses the AI client configured in runner.ts.
|
|
5
|
+
// By default it uses Google Gemini (requires GOOGLE_GENERATIVE_AI_API_KEY in .env).
|
|
6
|
+
// See runner.ts to switch to Anthropic, OpenAI, or any other Vercel AI SDK provider.
|
|
7
|
+
|
|
4
8
|
const exampleBrain = brain('example')
|
|
5
9
|
.step('Start', ({ state }) => ({
|
|
6
10
|
...state,
|
|
@@ -277,7 +277,7 @@ brain('sales-agent').withMemory(memory) // agentId = 'sales-agent'
|
|
|
277
277
|
|
|
278
278
|
### userId
|
|
279
279
|
|
|
280
|
-
Automatically set from `currentUser.
|
|
280
|
+
Automatically set from `currentUser.name` when the brain runs. All memory operations are automatically scoped to the current user — no need to pass userId manually:
|
|
281
281
|
|
|
282
282
|
```typescript
|
|
283
283
|
// userId is auto-bound from currentUser — just use memory directly
|
|
@@ -234,7 +234,7 @@ const api = {
|
|
|
234
234
|
|
|
235
235
|
## currentUser
|
|
236
236
|
|
|
237
|
-
Every brain run requires a `currentUser` — an object with at least
|
|
237
|
+
Every brain run requires a `currentUser` — an object with at least a `name` field that identifies who is running the brain. This identity is used to scope per-user data like memory and store fields.
|
|
238
238
|
|
|
239
239
|
### How currentUser Gets Set
|
|
240
240
|
|
|
@@ -251,7 +251,7 @@ import { runner } from './runner.js';
|
|
|
251
251
|
import myBrain from './brains/my-brain.js';
|
|
252
252
|
|
|
253
253
|
await runner.run(myBrain, {
|
|
254
|
-
currentUser: {
|
|
254
|
+
currentUser: { name: 'local-dev-user' },
|
|
255
255
|
});
|
|
256
256
|
```
|
|
257
257
|
|
|
@@ -261,7 +261,7 @@ await runner.run(myBrain, {
|
|
|
261
261
|
const events = await collectEvents(
|
|
262
262
|
testBrain.run({
|
|
263
263
|
client: mockClient,
|
|
264
|
-
currentUser: {
|
|
264
|
+
currentUser: { name: 'test-user' },
|
|
265
265
|
})
|
|
266
266
|
);
|
|
267
267
|
```
|
|
@@ -278,7 +278,7 @@ const events = await collectEvents(
|
|
|
278
278
|
```typescript
|
|
279
279
|
export default brain('greet')
|
|
280
280
|
.step('Hello', ({ currentUser }) => ({
|
|
281
|
-
greeting: 'Hello, user ' + currentUser.
|
|
281
|
+
greeting: 'Hello, user ' + currentUser.name,
|
|
282
282
|
}));
|
|
283
283
|
```
|
|
284
284
|
|
package/template/runner.ts
CHANGED
|
@@ -5,6 +5,39 @@ import { google } from '@ai-sdk/google';
|
|
|
5
5
|
/**
|
|
6
6
|
* The BrainRunner executes brains with the configured client and adapters.
|
|
7
7
|
*
|
|
8
|
+
* ## AI Provider Setup
|
|
9
|
+
*
|
|
10
|
+
* By default this uses Google Gemini. Set GOOGLE_GENERATIVE_AI_API_KEY in
|
|
11
|
+
* your .env file (get a key at https://aistudio.google.com/apikey).
|
|
12
|
+
*
|
|
13
|
+
* To switch to a different provider, install its Vercel AI SDK adapter
|
|
14
|
+
* and swap the model below:
|
|
15
|
+
*
|
|
16
|
+
* **Anthropic (Claude):**
|
|
17
|
+
* ```bash
|
|
18
|
+
* npm install @ai-sdk/anthropic
|
|
19
|
+
* ```
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { anthropic } from '@ai-sdk/anthropic';
|
|
22
|
+
* const client = new VercelClient(anthropic('claude-sonnet-4-5-20250929'));
|
|
23
|
+
* ```
|
|
24
|
+
* Then set ANTHROPIC_API_KEY in your .env file.
|
|
25
|
+
*
|
|
26
|
+
* **OpenAI:**
|
|
27
|
+
* ```bash
|
|
28
|
+
* npm install @ai-sdk/openai
|
|
29
|
+
* ```
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { openai } from '@ai-sdk/openai';
|
|
32
|
+
* const client = new VercelClient(openai('gpt-4o'));
|
|
33
|
+
* ```
|
|
34
|
+
* Then set OPENAI_API_KEY in your .env file.
|
|
35
|
+
*
|
|
36
|
+
* Any provider supported by the Vercel AI SDK works — just install the
|
|
37
|
+
* package and pass the model to VercelClient.
|
|
38
|
+
*
|
|
39
|
+
* ## Memory
|
|
40
|
+
*
|
|
8
41
|
* To add memory (automatic conversation indexing with Mem0):
|
|
9
42
|
*
|
|
10
43
|
* ```typescript
|
|
@@ -23,7 +56,6 @@ import { google } from '@ai-sdk/google';
|
|
|
23
56
|
* });
|
|
24
57
|
* ```
|
|
25
58
|
*
|
|
26
|
-
* The adapter automatically indexes all agent conversations to memory.
|
|
27
59
|
* See docs/memory-guide.md for more details.
|
|
28
60
|
*/
|
|
29
61
|
const client = new VercelClient(google('gemini-3-pro-preview'));
|