@mindstudio-ai/remy 0.1.120 → 0.1.121
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.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Methods
|
|
2
2
|
|
|
3
|
-
A method is a named async function that runs on the platform. It's the universal unit of backend logic — every interface (web, API, Discord, cron, webhook) invokes methods.
|
|
3
|
+
A method is a named async function that runs on the platform. It's the universal unit of backend logic — every interface (web, API, Discord, cron, webhook) invokes methods. One file per method, one named export.
|
|
4
4
|
|
|
5
5
|
## Writing a Method
|
|
6
6
|
|
|
@@ -192,6 +192,37 @@ export async function createPurchaseOrder(input: {
|
|
|
192
192
|
}
|
|
193
193
|
```
|
|
194
194
|
|
|
195
|
+
## Fire-and-Forget Background Tasks
|
|
196
|
+
|
|
197
|
+
A method can return immediately while kicking off slow work (like `runTask()`) that continues in the background. Don't await the slow call — use `.then()` / `.catch()` to update the record when it completes, and return an early result to the caller. The frontend polls the record's status to track progress.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
export async function enrichRestaurant(input: { id: string; name: string }) {
|
|
201
|
+
await Restaurants.update(input.id, { status: 'enriching' });
|
|
202
|
+
|
|
203
|
+
// Fire — don't await
|
|
204
|
+
agent.runTask<RestaurantData>({
|
|
205
|
+
prompt: '...',
|
|
206
|
+
input: { name: input.name },
|
|
207
|
+
tools: ['searchGoogle', 'fetchUrl', 'generateImage'],
|
|
208
|
+
structuredOutputExample: { /* ... */ },
|
|
209
|
+
model: 'claude-4-6-sonnet',
|
|
210
|
+
}).then(async (result) => {
|
|
211
|
+
if (result.parsedSuccessfully) {
|
|
212
|
+
await Restaurants.update(input.id, { ...result.output, status: 'complete' });
|
|
213
|
+
} else {
|
|
214
|
+
await Restaurants.update(input.id, { status: 'failed' });
|
|
215
|
+
}
|
|
216
|
+
}).catch(async () => {
|
|
217
|
+
await Restaurants.update(input.id, { status: 'failed' });
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return { status: 'enriching' };
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
This works because the execution environment persists between requests. The un-awaited promise continues after the method returns. DB, auth, and SDK all work normally in the background chain. For critical workflows, write a "pending" record before firing so incomplete tasks can be detected and retried.
|
|
225
|
+
|
|
195
226
|
## Shared Helpers
|
|
196
227
|
|
|
197
228
|
Code shared between methods goes in `dist/methods/src/common/`. Helpers are not listed in the manifest — they're internal, imported by methods but not directly invocable.
|
|
@@ -94,7 +94,7 @@ const { vendor } = await api.approveVendor({ vendorId: '...' });
|
|
|
94
94
|
- **Managed databases.** SQLite with typed schemas. Push a schema change and the platform diffs, migrates, and promotes atomically.
|
|
95
95
|
- **Built-in auth.** Opt-in via manifest. Developer builds login UI, platform handles verification codes (email/SMS), cookie sessions, and role enforcement. Backend methods use `auth.requireRole('admin')` for access control.
|
|
96
96
|
- **Multiple interfaces, one codebase.** Web, API, Discord, Telegram, Cron, Webhook, Email, MCP — all invoke the same methods. Methods don't know which interface called them.
|
|
97
|
-
- **Sandboxed execution.**
|
|
97
|
+
- **Sandboxed execution.** Each method invocation runs in its own isolated execution context with npm packages pre-installed.
|
|
98
98
|
- **Git-native deployment.** Push to default branch to deploy. Push to feature branch for preview. Rollback is a git revert.
|
|
99
99
|
|
|
100
100
|
## Minimum Viable App
|