@mindstudio-ai/remy 0.1.139 → 0.1.140
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/dist/headless.js +24 -1
- package/dist/index.js +24 -1
- package/dist/prompt/compiled/methods.md +40 -6
- package/dist/prompt/static/coding.md +2 -0
- package/package.json +1 -1
package/dist/headless.js
CHANGED
|
@@ -2352,7 +2352,30 @@ var listDirTool = {
|
|
|
2352
2352
|
const capped = children.slice(0, MAX_CHILDREN);
|
|
2353
2353
|
for (const child of capped) {
|
|
2354
2354
|
if (child.isDirectory()) {
|
|
2355
|
-
|
|
2355
|
+
const [childDisplay, childFinalPath] = await collapsePath(
|
|
2356
|
+
finalPath,
|
|
2357
|
+
child.name
|
|
2358
|
+
);
|
|
2359
|
+
lines.push(` ${childDisplay}/`);
|
|
2360
|
+
try {
|
|
2361
|
+
const grandchildren = await readAndSort(childFinalPath);
|
|
2362
|
+
const gcCapped = grandchildren.slice(0, MAX_CHILDREN);
|
|
2363
|
+
for (const gc of gcCapped) {
|
|
2364
|
+
if (gc.isDirectory()) {
|
|
2365
|
+
lines.push(` ${gc.name}/`);
|
|
2366
|
+
} else {
|
|
2367
|
+
lines.push(
|
|
2368
|
+
await formatFile(childFinalPath, gc.name, " ")
|
|
2369
|
+
);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
if (grandchildren.length > MAX_CHILDREN) {
|
|
2373
|
+
lines.push(
|
|
2374
|
+
` ... and ${grandchildren.length - MAX_CHILDREN} more`
|
|
2375
|
+
);
|
|
2376
|
+
}
|
|
2377
|
+
} catch {
|
|
2378
|
+
}
|
|
2356
2379
|
} else {
|
|
2357
2380
|
lines.push(await formatFile(finalPath, child.name, " "));
|
|
2358
2381
|
}
|
package/dist/index.js
CHANGED
|
@@ -2660,7 +2660,30 @@ var init_listDir = __esm({
|
|
|
2660
2660
|
const capped = children.slice(0, MAX_CHILDREN);
|
|
2661
2661
|
for (const child of capped) {
|
|
2662
2662
|
if (child.isDirectory()) {
|
|
2663
|
-
|
|
2663
|
+
const [childDisplay, childFinalPath] = await collapsePath(
|
|
2664
|
+
finalPath,
|
|
2665
|
+
child.name
|
|
2666
|
+
);
|
|
2667
|
+
lines.push(` ${childDisplay}/`);
|
|
2668
|
+
try {
|
|
2669
|
+
const grandchildren = await readAndSort(childFinalPath);
|
|
2670
|
+
const gcCapped = grandchildren.slice(0, MAX_CHILDREN);
|
|
2671
|
+
for (const gc of gcCapped) {
|
|
2672
|
+
if (gc.isDirectory()) {
|
|
2673
|
+
lines.push(` ${gc.name}/`);
|
|
2674
|
+
} else {
|
|
2675
|
+
lines.push(
|
|
2676
|
+
await formatFile(childFinalPath, gc.name, " ")
|
|
2677
|
+
);
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
if (grandchildren.length > MAX_CHILDREN) {
|
|
2681
|
+
lines.push(
|
|
2682
|
+
` ... and ${grandchildren.length - MAX_CHILDREN} more`
|
|
2683
|
+
);
|
|
2684
|
+
}
|
|
2685
|
+
} catch {
|
|
2686
|
+
}
|
|
2664
2687
|
} else {
|
|
2665
2688
|
lines.push(await formatFile(finalPath, child.name, " "));
|
|
2666
2689
|
}
|
|
@@ -245,20 +245,54 @@ export function getApprovalState(approvals: Approval[]) {
|
|
|
245
245
|
|
|
246
246
|
## Streaming
|
|
247
247
|
|
|
248
|
-
Methods can
|
|
248
|
+
Methods can push real-time updates to the frontend using `stream()`. This is the standard pattern for any method that takes more than a few seconds.
|
|
249
249
|
|
|
250
250
|
```typescript
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
import { mindstudio, stream } from '@mindstudio-ai/agent';
|
|
252
|
+
|
|
253
|
+
export async function enrichProfile(input: { name: string }) {
|
|
254
|
+
await stream('Researching...');
|
|
255
|
+
|
|
256
|
+
const { content } = await mindstudio.generateText(
|
|
257
|
+
{ message: `Find background info on ${input.name}` },
|
|
258
|
+
{ onLog: (event) => stream({ status: event.value }) },
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
await stream({ status: 'generating_image', progress: 0.5 });
|
|
262
|
+
|
|
263
|
+
const { imageUrl } = await mindstudio.generateImage(
|
|
264
|
+
{ prompt: `Professional portrait illustration of ${input.name}` },
|
|
265
|
+
{ onLog: (event) => stream({ status: event.value }) },
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
return { bio: content, imageUrl };
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Two data types:
|
|
273
|
+
- `stream('text')` sends a text token (like LLM streaming output)
|
|
274
|
+
- `stream({ ... })` sends structured data (progress, status, intermediate results)
|
|
275
|
+
|
|
276
|
+
Every SDK action accepts an `onLog` callback that emits execution progress. Pipe it through `stream()` so the frontend sees what's happening inside each action in real time. Use `stream()` directly for your own status messages between actions.
|
|
277
|
+
|
|
278
|
+
When there's no active stream (method not called with `stream: true`, CLI execution, background jobs), `stream()` is a silent no-op. Always safe to include unconditionally.
|
|
279
|
+
|
|
280
|
+
### Frontend
|
|
281
|
+
|
|
282
|
+
The frontend calls the method with `stream: true` and receives updates via `onToken`. The `text` value is accumulated (not a delta), so replace your display content each time.
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
const result = await api.enrichProfile(
|
|
286
|
+
{ name: 'Alice' },
|
|
254
287
|
{
|
|
255
288
|
stream: true,
|
|
256
|
-
onToken: (text) =>
|
|
289
|
+
onToken: (text) => setResponseText(text),
|
|
257
290
|
},
|
|
258
291
|
);
|
|
292
|
+
// result is the same final output you'd get without streaming
|
|
259
293
|
```
|
|
260
294
|
|
|
261
|
-
|
|
295
|
+
Use `onStreamError` for transient error handling. The method's promise still resolves with the final return value once execution completes.
|
|
262
296
|
|
|
263
297
|
## Raw Request Context (API Interface)
|
|
264
298
|
|
|
@@ -30,6 +30,8 @@ For any work involving AI models, external actions (web scraping, email, SMS), o
|
|
|
30
30
|
|
|
31
31
|
For multi-step tasks with branching logic (research, enrichment, content pipelines), use `runTask()` instead of manually chaining SDK actions. It runs an autonomous agent loop that composes actions, retries on failure, and returns structured JSON. See the task agents reference for details.
|
|
32
32
|
|
|
33
|
+
For methods that take more than a few seconds, use `stream()` from `@mindstudio-ai/agent` to push real-time progress to the frontend. Pipe `onLog` from SDK actions through `stream()` so users see what's happening. The frontend calls the method with `stream: true` and gets updates via `onToken`. See the methods reference for the full pattern.
|
|
34
|
+
|
|
33
35
|
### Auth
|
|
34
36
|
- Not every app needs auth, and even for apps that do need auth, not every screen needs auth. Think intentionally about places where auth is required. Don't make auth be the first thing a user sees - that's jarring. Only show auth at intuitive and natural moments in the user's journey - be thoughtful about how to implement auth in the UI.
|
|
35
37
|
- Frontend interfaces are always untrusted. Always enforce auth in backend methods. Use frontend auth and role information as a hint to conditionally show/hide UI to make the experience pleasant and seamless for users depending on their state, but remember to always use backend methods for gating data that is conditional on auth.
|