broods 0.2.1 → 0.4.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 +89 -0
- package/dist/account.d.ts +802 -0
- package/dist/account.js +290 -0
- package/dist/cli/index.js +414 -157
- package/dist/index.d.ts +530 -80
- package/dist/index.js +419 -25
- package/package.json +12 -8
package/README.md
CHANGED
|
@@ -38,6 +38,95 @@ Runtime calls use an environment runtime API key. After `broods deploy`, the CLI
|
|
|
38
38
|
writes `BROODS_API_KEY` to `.env.local`; the SDK also accepts `apiKey`,
|
|
39
39
|
`BROODS_API_KEY`, `baseUrl`, and `BROODS_BASE_URL`.
|
|
40
40
|
|
|
41
|
+
## Two ways to configure agents
|
|
42
|
+
|
|
43
|
+
**Config-first (`broods dev` / `broods deploy`).** Resources declared in your
|
|
44
|
+
`broods/` folder with `defineAgent`, `defineWorkspace`, etc. are _predefined
|
|
45
|
+
configs_: the CLI syncs them to your project on deploy and codegen gives you
|
|
46
|
+
typed references. Use this when the set of agents is fixed and versioned with
|
|
47
|
+
your code.
|
|
48
|
+
|
|
49
|
+
**Dynamic config at runtime (`BroodsAccountClient`).** When your app needs to
|
|
50
|
+
create or mutate config while it runs — for example a multi-tenant product that
|
|
51
|
+
provisions one agent per customer — use the account config client with your
|
|
52
|
+
account secret. It is the complete typed client for the account config plane:
|
|
53
|
+
agents, sandboxes (config + suspend/resume/terminate/snapshot/terminal),
|
|
54
|
+
workspaces (config + file upload/rename/delete/download), tools, policies,
|
|
55
|
+
skills, crons (+ run history), and the account itself (metadata, secret
|
|
56
|
+
rotation, deletion). It is a separate, dependency-free entry point
|
|
57
|
+
(`broods/account`) built on plain `fetch`, so it also works in edge runtimes
|
|
58
|
+
such as Convex actions and Cloudflare Workers where the main SDK entry (which
|
|
59
|
+
reads `.env` files from disk) cannot load:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
import { BroodsAccountClient, envPlaceholder } from "broods/account";
|
|
63
|
+
|
|
64
|
+
// baseUrl defaults to https://gateway.broods.app (override with BROODS_BASE_URL);
|
|
65
|
+
// the secret falls back to BROODS_ACCOUNT_SECRET from the runtime's environment.
|
|
66
|
+
const account = new BroodsAccountClient({
|
|
67
|
+
accountSecret: process.env.BROODS_ACCOUNT_SECRET,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Provision a tenant agent (config is deep-merged on update; null deletes keys).
|
|
71
|
+
const created = await account.createAgent({
|
|
72
|
+
name: `tenant-agent-${customerId}`,
|
|
73
|
+
config: {
|
|
74
|
+
model: { provider: "custom", modelId: "Qwen3.6-27B" },
|
|
75
|
+
agent: { system: "You are the tenant's sales assistant." },
|
|
76
|
+
publicAccess: true,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Store an account secret once, then reference it from any dynamic agent.
|
|
81
|
+
// Reads list only names/timestamps; secret values are never returned.
|
|
82
|
+
await account.setEnvVar("OVH_API_KEY", process.env.OVH_API_KEY!);
|
|
83
|
+
await account.updateAgent(created.agentId, {
|
|
84
|
+
config: { provider: { custom: { apiKey: envPlaceholder("OVH_API_KEY") } } },
|
|
85
|
+
});
|
|
86
|
+
await account.updateAgent(created.agentId, {
|
|
87
|
+
config: { channels: { slack: { id: "conn-1", botToken: "xoxb-…" } } },
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Schedule it, browse its workspace, surface its webhook URL.
|
|
91
|
+
await account.createCron({
|
|
92
|
+
name: "daily-digest",
|
|
93
|
+
agentId: created.agentId,
|
|
94
|
+
input: "Summarize yesterday's conversations.",
|
|
95
|
+
scheduleExpression: "cron(0 8 * * ? *)",
|
|
96
|
+
});
|
|
97
|
+
const { accountId } = await account.getAccount();
|
|
98
|
+
const url = account.webhookUrl(accountId, created.agentId, "slack");
|
|
99
|
+
|
|
100
|
+
// The same client covers the rest of the config plane: standalone sandboxes and
|
|
101
|
+
// workspaces, uploaded tools, reusable policies, skills, and cron run history.
|
|
102
|
+
const sandbox = await account.createSandbox({
|
|
103
|
+
name: "reserved",
|
|
104
|
+
config: { provider: "lambda", persistent: true, permissionMode: "ask" },
|
|
105
|
+
});
|
|
106
|
+
await account.uploadWorkspaceFile("ws_1", {
|
|
107
|
+
path: "memory/seed.md",
|
|
108
|
+
contentBase64: "IyBTZWVk",
|
|
109
|
+
});
|
|
110
|
+
await account.createSkill({
|
|
111
|
+
source: "json",
|
|
112
|
+
name: "triage",
|
|
113
|
+
description: "Triage flow",
|
|
114
|
+
content: "# Triage",
|
|
115
|
+
});
|
|
116
|
+
const runs = await account.listCronRuns("cron_1", { limit: 20 });
|
|
117
|
+
|
|
118
|
+
// Persistent sandbox lifecycle is driven by reservationKey.
|
|
119
|
+
await account.suspendSandbox(sandbox.sandboxId, "ws-namespace");
|
|
120
|
+
|
|
121
|
+
// Rotate the account secret when needed (the returned secret is shown once).
|
|
122
|
+
const { secret } = await account.rotateSecret();
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`get`/`update` methods return `null` (and `delete` returns `false`) when the
|
|
126
|
+
resource does not exist, so upsert flows need no try/catch; other API errors
|
|
127
|
+
throw `BroodsAccountApiError` with the HTTP status. Secrets inside configs are
|
|
128
|
+
encrypted at rest and come back redacted on reads.
|
|
129
|
+
|
|
41
130
|
## License
|
|
42
131
|
|
|
43
132
|
The `broods` npm package, including the CLI and TypeScript client SDK, is MIT
|