@soft-boy/agentschema 0.3.12 → 0.5.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.
Files changed (94) hide show
  1. package/README.md +13 -9
  2. package/dist/bin/agentschema.d.ts +2 -0
  3. package/dist/bin/agentschema.js +333 -0
  4. package/dist/lib/channels.d.ts +65 -0
  5. package/dist/lib/channels.js +339 -0
  6. package/dist/lib/check.d.ts +10 -0
  7. package/dist/lib/check.js +411 -0
  8. package/dist/lib/files.d.ts +7 -0
  9. package/{lib → dist/lib}/files.js +10 -14
  10. package/dist/lib/index.d.ts +24 -0
  11. package/{lib → dist/lib}/index.js +3 -10
  12. package/dist/lib/instance.d.ts +41 -0
  13. package/dist/lib/instance.js +74 -0
  14. package/dist/lib/markdown.d.ts +11 -0
  15. package/dist/lib/markdown.js +38 -0
  16. package/dist/lib/scaffold.d.ts +15 -0
  17. package/dist/lib/scaffold.js +46 -0
  18. package/dist/lib/scheduled.d.ts +56 -0
  19. package/dist/lib/scheduled.js +185 -0
  20. package/dist/lib/skills.d.ts +28 -0
  21. package/dist/lib/skills.js +55 -0
  22. package/dist/lib/stream.d.ts +30 -0
  23. package/dist/lib/stream.js +56 -0
  24. package/dist/lib/system-prompt.d.ts +16 -0
  25. package/{lib → dist/lib}/system-prompt.js +14 -15
  26. package/dist/lib/tools.d.ts +105 -0
  27. package/dist/lib/tools.js +353 -0
  28. package/dist/lib/vaults.d.ts +55 -0
  29. package/dist/lib/vaults.js +143 -0
  30. package/dist/src/chat.d.ts +15 -0
  31. package/dist/src/chat.js +159 -0
  32. package/dist/src/check.d.ts +2 -0
  33. package/dist/src/check.js +14 -0
  34. package/dist/src/cred-menu.d.ts +17 -0
  35. package/dist/src/cred-menu.js +193 -0
  36. package/dist/src/cred.d.ts +54 -0
  37. package/dist/src/cred.js +252 -0
  38. package/dist/src/custom-tools.d.ts +3 -0
  39. package/dist/src/custom-tools.js +18 -0
  40. package/dist/src/delete.d.ts +9 -0
  41. package/dist/src/delete.js +27 -0
  42. package/dist/src/deploy.d.ts +62 -0
  43. package/dist/src/deploy.js +442 -0
  44. package/dist/src/dotenv.d.ts +7 -0
  45. package/dist/src/dotenv.js +54 -0
  46. package/dist/src/folder.d.ts +5 -0
  47. package/dist/src/folder.js +57 -0
  48. package/dist/src/init.d.ts +11 -0
  49. package/dist/src/init.js +51 -0
  50. package/dist/src/list.d.ts +3 -0
  51. package/dist/src/list.js +46 -0
  52. package/dist/src/lock.d.ts +10 -0
  53. package/dist/src/lock.js +37 -0
  54. package/dist/src/mcp.d.ts +11 -0
  55. package/dist/src/mcp.js +79 -0
  56. package/dist/src/node.d.ts +14 -0
  57. package/dist/src/oauth.d.ts +64 -0
  58. package/dist/src/oauth.js +208 -0
  59. package/dist/src/prompts.d.ts +18 -0
  60. package/dist/src/prompts.js +166 -0
  61. package/dist/src/session.d.ts +58 -0
  62. package/dist/src/session.js +200 -0
  63. package/dist/src/tools-menu.d.ts +8 -0
  64. package/dist/src/tools-menu.js +173 -0
  65. package/package.json +21 -9
  66. package/bin/agentschema.js +0 -326
  67. package/lib/channels.js +0 -338
  68. package/lib/check.js +0 -388
  69. package/lib/instance.js +0 -48
  70. package/lib/markdown.js +0 -42
  71. package/lib/scaffold.js +0 -51
  72. package/lib/scheduled.js +0 -175
  73. package/lib/skills.js +0 -58
  74. package/lib/stream.js +0 -50
  75. package/lib/tools.js +0 -327
  76. package/lib/vaults.js +0 -142
  77. package/src/chat.js +0 -156
  78. package/src/check.js +0 -14
  79. package/src/cred-menu.js +0 -197
  80. package/src/cred.js +0 -263
  81. package/src/custom-tools.js +0 -17
  82. package/src/delete.js +0 -25
  83. package/src/deploy.js +0 -441
  84. package/src/dotenv.js +0 -50
  85. package/src/folder.js +0 -55
  86. package/src/init.js +0 -54
  87. package/src/list.js +0 -49
  88. package/src/lock.js +0 -40
  89. package/src/mcp.js +0 -76
  90. package/src/oauth.js +0 -215
  91. package/src/prompts.js +0 -159
  92. package/src/session.js +0 -194
  93. package/src/tools-menu.js +0 -163
  94. /package/{src → dist/src}/node.js +0 -0
package/README.md CHANGED
@@ -10,7 +10,7 @@ Define an AI-Agent as a folder of Markdown files.
10
10
  ```
11
11
  my-agent/
12
12
  ├── agent.md # the agent
13
- ├── env.md # the environment it runs in
13
+ ├── computer.md # the computer it runs on
14
14
  ├── system_prompt/
15
15
  │ └── rules.md # more of the system prompt
16
16
  ├── tools/
@@ -28,8 +28,6 @@ my-agent/
28
28
  └── good-morning.md # a task it runs on a timetable
29
29
  ```
30
30
 
31
- **Status:** v0.2 draft. v0.2 breaks from the Claude Managed Agents schema: tools move out of `agent.md` and into `tools/`.
32
-
33
31
  ## Table of contents
34
32
 
35
33
  - [Philosophy](#philosophy)
@@ -39,7 +37,7 @@ my-agent/
39
37
  - [Specification](#specification)
40
38
  - [`agent.md`](#agentmd)
41
39
  - [`system_prompt/`](#system_prompt)
42
- - [`env.md`](#envmd)
40
+ - [`computer.md`](#computermd)
43
41
  - [`tools/`](#tools)
44
42
  - [`skills/`](#skills)
45
43
  - [`vaults/`](#vaults)
@@ -84,7 +82,7 @@ agentschema run my-agent
84
82
 
85
83
  ## Specification
86
84
 
87
- `agent.md` and `env.md` are required; everything else is optional. `agentschema check` validates a folder without calling the API. This is the short version, and the full specification is in [docs/](docs/README.md).
85
+ `agent.md` and `computer.md` are required; everything else is optional. `agentschema check` validates a folder without calling the API. This is the short version, and the full specification is in [docs/](docs/README.md).
88
86
 
89
87
  ### `agent.md`
90
88
 
@@ -94,9 +92,9 @@ The frontmatter uses the fields of a [Managed Agents agent](https://platform.cla
94
92
 
95
93
  A long system prompt can be split into files here, at any depth. They're added after `agent.md`'s body, in the order `tree` lists them, with a blank line between each one, so number them to keep them in order, like `01-role.md` and `02-rules.md`. Each file is taken as written. See [System prompt](docs/system_prompt.md).
96
94
 
97
- ### `env.md`
95
+ ### `computer.md`
98
96
 
99
- The frontmatter uses the fields of a [Managed Agents environment](https://platform.claude.com/docs/en/managed-agents/environments). The body is a note for people, and isn't sent anywhere.
97
+ The computer the agent runs on. The frontmatter uses the fields of a [Managed Agents environment](https://platform.claude.com/docs/en/managed-agents/environments), and the body is a note for people, and isn't sent anywhere. It used to be called `env.md`, which still works, with a warning to rename it.
100
98
 
101
99
  ### `tools/`
102
100
 
@@ -232,12 +230,18 @@ const { errors, warnings } = checkFiles(files);
232
230
  const { plan, lock } = await deployFiles({ files, lock: savedLock, client, saveLock });
233
231
  ```
234
232
 
233
+ Both entry points ship with TypeScript declarations, including types for the shapes they take and return (`FileMap`, `CheckResult`, `Instance`, `DeployResult`, …).
234
+
235
235
  ## Development
236
236
 
237
+ The source is TypeScript, in `bin/`, `lib/` and `src/`. Node 22.18 or later runs it as it is, so `node bin/agentschema.ts` works without a build; the published package is compiled to JavaScript and type declarations in `dist/`, and runs on Node 18.
238
+
237
239
  ```sh
238
240
  npm install
239
- npm test # unit tests; deploy runs against a fake API client
240
- npm link # makes `agentschema` available globally from this checkout
241
+ npm run typecheck # tsc, without writing files
242
+ npm run build # compiles to dist/
243
+ npm test # builds, then runs the unit tests; deploy runs against a fake API client
244
+ npm link # makes `agentschema` available globally from this checkout (run npm run build first)
241
245
  ```
242
246
 
243
247
  ## License
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,333 @@
1
+ #!/usr/bin/env node
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { createInterface } from "node:readline/promises";
4
+ import { parseArgs } from "node:util";
5
+ import Anthropic from "@anthropic-ai/sdk";
6
+ import { chat } from "../src/chat.js";
7
+ import { spawn } from "node:child_process";
8
+ import { credCreate, credDeploy } from "../src/cred-menu.js";
9
+ import { credDelete, credLogin } from "../src/cred.js";
10
+ import { check } from "../src/check.js";
11
+ import { DeleteError, deleteAgent, deleteSession } from "../src/delete.js";
12
+ import { DeployError, deploy } from "../src/deploy.js";
13
+ import { loadEnvFile } from "../src/dotenv.js";
14
+ import { InitError, init } from "../src/init.js";
15
+ import { listAgents, listSessions } from "../src/list.js";
16
+ import { prompts } from "../src/prompts.js";
17
+ import { SessionError, openSession } from "../src/session.js";
18
+ import { toolsCreate } from "../src/tools-menu.js";
19
+ const FOOTER = `ags is a short name for agentschema. dir defaults to the current directory. Every command
20
+ but init, check and tools create authenticates with ANTHROPIC_API_KEY, or with a profile from \`ant auth login\`.`;
21
+ const USAGE = `Usage: agentschema <command> [dir] [options]
22
+
23
+ Commands:
24
+ init <name> Scaffold a new agent folder, asking a few questions
25
+ check [dir] Validate the folder's files, without calling the API
26
+ deploy [dir] Create or update the skills, agent, environment, vaults and scheduled tasks, and write claude-lock.json
27
+ run [dir] Chat with the deployed agent in a new session, loading dir/.env for your tools
28
+ list List the agents in your workspace
29
+ delete <agent_id> Archive an agent (agents can't be deleted outright)
30
+ tools <command> Add pre-built tools, custom tools and MCP servers (agentschema tools -h)
31
+ sessions <command> List and delete sessions (agentschema sessions -h)
32
+ cred <command> Create and manage the credentials in vaults/ (agentschema cred -h)
33
+
34
+ Options:
35
+ -y, --yes (init) Skip the questions and use the defaults
36
+ (delete) Don't ask for confirmation
37
+ --dry-run (deploy) Show what would be created or updated, change nothing
38
+ --force (deploy) Update the agent even if it was changed outside this folder
39
+ --resume <id> (run) Resume an existing session (sesn_...) instead of starting one
40
+ -h, --help Show this help
41
+ -v, --version Show the version
42
+
43
+ ${FOOTER}`;
44
+ const TOOLS_USAGE = `Usage: agentschema tools <command> [options]
45
+
46
+ Each tool is a file in tools/. The pre-built tools share one file, each custom tool has its own,
47
+ and so does each MCP server.
48
+
49
+ Commands:
50
+ create [dir] Add a tool: asks whether it's the pre-built tools, a custom tool or an
51
+ MCP server, then writes its file
52
+
53
+ Options:
54
+ -h, --help Show this help
55
+
56
+ dir defaults to the current directory.`;
57
+ const SESSIONS_USAGE = `Usage: agentschema sessions <command> [options]
58
+
59
+ Commands:
60
+ list List the sessions in your workspace, newest first
61
+ delete <id> Delete a session and its history
62
+
63
+ Options:
64
+ -y, --yes (delete) Don't ask for confirmation
65
+ -h, --help Show this help
66
+
67
+ Resume a session with agentschema run --resume <id>.`;
68
+ const CRED_USAGE = `Usage: agentschema cred <command> [options]
69
+
70
+ Each credential is a file in vaults/<vault>/<name>.md, without its secrets, which go straight
71
+ to Anthropic.
72
+
73
+ Commands:
74
+ create [dir] Add a credential: asks which vault it goes in and whether it's for an MCP
75
+ server or an environment variable, writes its file, then signs you in or
76
+ asks for its secrets, and creates it in Anthropic
77
+ deploy <file> Create the credential a file describes in Anthropic, by signing in or
78
+ pasting its secrets
79
+ login <file> Sign in to the credential's MCP server in the browser, and store the tokens,
80
+ creating the credential or replacing the tokens of the existing one
81
+ delete <file> Delete the credential a file describes from Anthropic; the file stays
82
+
83
+ Options:
84
+ --port <port> (create, deploy, login) Port for the sign-in redirect (default: any free port)
85
+ -y, --yes (delete) Don't ask for confirmation
86
+ -h, --help Show this help
87
+
88
+ dir defaults to the current directory.`;
89
+ // The commands that group subcommands, and their help.
90
+ const GROUPS = { tools: TOOLS_USAGE, sessions: SESSIONS_USAGE, cred: CRED_USAGE };
91
+ const OPTIONS = {
92
+ yes: { type: "boolean", short: "y" },
93
+ "dry-run": { type: "boolean" },
94
+ force: { type: "boolean" },
95
+ resume: { type: "string" },
96
+ port: { type: "string" },
97
+ help: { type: "boolean", short: "h" },
98
+ version: { type: "boolean", short: "v" },
99
+ };
100
+ const COMMANDS = {
101
+ init: { args: [1, 1], options: ["yes"] },
102
+ check: { args: [0, 1], options: [] },
103
+ deploy: { args: [0, 1], options: ["dry-run", "force"] },
104
+ run: { args: [0, 1], options: ["resume"] },
105
+ list: { args: [0, 0], options: [] },
106
+ delete: { args: [1, 1], options: ["yes"] },
107
+ "tools create": { args: [0, 1], options: [] },
108
+ "sessions list": { args: [0, 0], options: [] },
109
+ "sessions delete": { args: [1, 1], options: ["yes"] },
110
+ "cred create": { args: [0, 1], options: ["port"] },
111
+ "cred deploy": { args: [1, 1], options: ["port"] },
112
+ "cred login": { args: [1, 1], options: ["port"] },
113
+ "cred delete": { args: [1, 1], options: ["yes"] },
114
+ };
115
+ // The exit code; undefined only if a command in COMMANDS has no branch below, which none lacks.
116
+ async function main(argv) {
117
+ let parsed;
118
+ try {
119
+ parsed = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true });
120
+ }
121
+ catch (err) {
122
+ // parseArgs throws only its own TypeErrors, for unknown or malformed options.
123
+ console.error(`agentschema: ${err.message}\n\n${GROUPS[argv[0]] ?? USAGE}`);
124
+ return 1;
125
+ }
126
+ const { values, positionals } = parsed;
127
+ let [command, ...args] = positionals;
128
+ const group = command in GROUPS ? command : null;
129
+ if (group)
130
+ command = `${group} ${args.shift() ?? ""}`.trim();
131
+ const usage = group ? GROUPS[group] : USAGE;
132
+ if (values.version) {
133
+ // This file is bin/agentschema.ts in a checkout, and dist/bin/agentschema.js once built.
134
+ const pkgFile = ["../package.json", "../../package.json"].map((p) => new URL(p, import.meta.url)).find(existsSync);
135
+ const pkg = JSON.parse(readFileSync(pkgFile, "utf8"));
136
+ console.log(pkg.version);
137
+ return 0;
138
+ }
139
+ if (values.help) {
140
+ console.log(usage);
141
+ return 0;
142
+ }
143
+ if (!command) {
144
+ console.log(USAGE);
145
+ return 1;
146
+ }
147
+ if (group && command === group) {
148
+ console.error(usage);
149
+ return 1;
150
+ }
151
+ if (!(command in COMMANDS)) {
152
+ console.error(`agentschema: unknown command "${command}"\n\n${usage}`);
153
+ return 1;
154
+ }
155
+ const spec = COMMANDS[command];
156
+ // Object.keys loses the keys' type; they're option names, as parseArgs rejects any others.
157
+ const misplaced = Object.keys(values).filter((k) => !spec.options.includes(k));
158
+ if (args.length > spec.args[1] || misplaced.length > 0) {
159
+ const arg = args[spec.args[1]] ?? `--${misplaced[0]}`;
160
+ console.error(`agentschema: unexpected argument ${arg} for ${command}\n\n${usage}`);
161
+ return 1;
162
+ }
163
+ if (args.length < spec.args[0]) {
164
+ const examples = { init: "init my-agent", delete: "delete agent_…", "sessions delete": "sessions delete sesn_…", "cred deploy": "cred deploy my-agent/vaults/Ops/Slack.md", "cred login": "cred login my-agent/vaults/Ops/Slack.md", "cred delete": "cred delete my-agent/vaults/Ops/Slack.md" };
165
+ const example = examples[command];
166
+ console.error(`agentschema: ${command} needs an argument, e.g. agentschema ${example}`);
167
+ return 1;
168
+ }
169
+ const dir = args[0] ?? ".";
170
+ if (command === "init") {
171
+ try {
172
+ await init(dir, { yes: values.yes ?? false });
173
+ return 0;
174
+ }
175
+ catch (err) {
176
+ if (!(err instanceof InitError))
177
+ throw err;
178
+ console.error(`error: ${err.message}`);
179
+ return 1;
180
+ }
181
+ }
182
+ if (command === "check") {
183
+ const { errors, warnings } = check(dir);
184
+ for (const w of warnings)
185
+ console.warn(`warning: ${w}`);
186
+ for (const e of errors)
187
+ console.error(`error: ${e}`);
188
+ if (errors.length > 0)
189
+ return 1;
190
+ console.log(`${dir}: ok`);
191
+ return 0;
192
+ }
193
+ try {
194
+ if (command === "deploy") {
195
+ for (const w of check(dir).warnings)
196
+ console.warn(`warning: ${w}`);
197
+ const dryRun = values["dry-run"] ?? false;
198
+ await deploy(dir, {
199
+ client: makeClient(dryRun),
200
+ dryRun,
201
+ force: values.force ?? false,
202
+ log: (line) => console.log(line),
203
+ });
204
+ return 0;
205
+ }
206
+ if (command === "list" || command === "sessions list") {
207
+ const lines = command === "list" ? await listAgents(makeClient(false)) : await listSessions(makeClient(false));
208
+ for (const line of lines)
209
+ console.log(line);
210
+ return 0;
211
+ }
212
+ if (command === "delete" || command === "sessions delete") {
213
+ const remove = command === "delete" ? deleteAgent : deleteSession;
214
+ await remove(makeClient(false), args[0], {
215
+ confirm: values.yes ? async () => true : confirm,
216
+ log: (line) => console.log(line),
217
+ });
218
+ return 0;
219
+ }
220
+ if (command === "tools create") {
221
+ const io = prompts(process.stdin, process.stdout, { cancelled: () => new DeployError("cancelled") });
222
+ try {
223
+ await toolsCreate(args[0] ?? ".", { io, log: (line) => console.log(line) });
224
+ }
225
+ finally {
226
+ io.close();
227
+ }
228
+ return 0;
229
+ }
230
+ if (["cred create", "cred deploy", "cred login"].includes(command)) {
231
+ if (values.port !== undefined && !/^\d+$/.test(values.port))
232
+ throw new DeployError(`--port must be a number, not "${values.port}"`);
233
+ const io = prompts(process.stdin, process.stdout, { cancelled: () => new DeployError("cancelled") });
234
+ const options = { client: makeClient(false), openBrowser, port: values.port ?? 0, log: (line) => console.log(line) };
235
+ try {
236
+ if (command === "cred create")
237
+ await credCreate(args[0] ?? ".", { ...options, io });
238
+ else if (command === "cred deploy")
239
+ await credDeploy(args[0], { ...options, io });
240
+ else
241
+ await credLogin(args[0], { ...options, ask: (q, { secret }) => (secret ? io.secret(q.trim()) : io.text(q.trim())) });
242
+ }
243
+ finally {
244
+ io.close();
245
+ }
246
+ return 0;
247
+ }
248
+ if (command === "cred delete") {
249
+ await credDelete(args[0], {
250
+ client: makeClient(false),
251
+ confirm: values.yes ? async () => true : confirm,
252
+ log: (line) => console.log(line),
253
+ });
254
+ return 0;
255
+ }
256
+ if (command === "run") {
257
+ // Made first, so .env only reaches your tools: Anthropic credentials still come from the
258
+ // shell, the same as for every other command.
259
+ const client = makeClient(false);
260
+ for (const warning of loadEnvFile(dir))
261
+ console.warn(`warning: ${warning}`);
262
+ const { session, notes } = await openSession(dir, {
263
+ client,
264
+ sessionId: values.resume,
265
+ });
266
+ for (const note of notes)
267
+ console.warn(`warning: ${note}`);
268
+ await chat(client, session, { agentName: session.agent?.name ?? "agent", tools: customTools(dir) });
269
+ return 0;
270
+ }
271
+ }
272
+ catch (err) {
273
+ if (err instanceof Anthropic.APIError) {
274
+ console.error(`error: ${err.status ?? "network error"}: ${err.error?.error?.message ?? err.message}`);
275
+ return 1;
276
+ }
277
+ if (err instanceof DeployError || err instanceof DeleteError || err instanceof SessionError || err instanceof Anthropic.AnthropicError) {
278
+ console.error(`error: ${err.message}`);
279
+ return 1;
280
+ }
281
+ throw err;
282
+ }
283
+ }
284
+ // Asks a yes/no question in the terminal; without one, there's no one to ask.
285
+ async function confirm(question) {
286
+ if (!process.stdin.isTTY)
287
+ throw new DeleteError("not a terminal, so can't ask for confirmation; pass --yes");
288
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
289
+ try {
290
+ return /^(y|yes)$/i.test((await rl.question(`${question} [y/N] `)).trim());
291
+ }
292
+ finally {
293
+ rl.close();
294
+ }
295
+ }
296
+ // Opens a URL in the default browser; the URL is also printed, in case this fails.
297
+ function openBrowser(url) {
298
+ const [cmd, args] = process.platform === "darwin" ? ["open", [url]]
299
+ : process.platform === "win32" ? ["cmd", ["/c", "start", "", url]]
300
+ : ["xdg-open", [url]];
301
+ try {
302
+ spawn(cmd, args, { stdio: "ignore", detached: true }).on("error", () => { }).unref();
303
+ }
304
+ catch {
305
+ // The URL was printed; the user can open it.
306
+ }
307
+ }
308
+ // The folder's custom tools, by name, for run to execute. A folder that doesn't pass check
309
+ // runs none of them; run asks you for each result instead.
310
+ function customTools(dir) {
311
+ const { instance, errors } = check(dir);
312
+ const customs = instance?.tools.filter((t) => t.data.type === "custom") ?? [];
313
+ if (customs.length === 0)
314
+ return {};
315
+ if (errors.length > 0) {
316
+ console.warn(`warning: ${dir} doesn't pass check, so its custom tools won't run; you'll be asked for each result`);
317
+ return {};
318
+ }
319
+ return Object.fromEntries(customs.map((t) => [t.name, t]));
320
+ }
321
+ // A dry run makes no API calls, so it works without credentials.
322
+ function makeClient(dryRun) {
323
+ try {
324
+ return new Anthropic();
325
+ }
326
+ catch (err) {
327
+ if (!dryRun)
328
+ throw err;
329
+ // Stands in for the client in a dry run, which reads nothing else from it.
330
+ return { baseURL: process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com" };
331
+ }
332
+ }
333
+ process.exitCode = await main(process.argv.slice(2));
@@ -0,0 +1,65 @@
1
+ import { type FileMap } from "./files.ts";
2
+ import { type SystemPromptPart } from "./system-prompt.ts";
3
+ import { type Frontmatter, type MarkdownFile } from "./markdown.ts";
4
+ import { type AgentbookCatalog, type Tool } from "./tools.ts";
5
+ export declare const CHANNELS_DIR = "channels";
6
+ export declare const ANYONE = "*";
7
+ export interface Channel extends MarkdownFile {
8
+ file: string;
9
+ name: string;
10
+ }
11
+ type Check = (value: unknown) => string | null;
12
+ export interface ChannelField {
13
+ required?: boolean;
14
+ check: Check;
15
+ }
16
+ export interface ChannelType {
17
+ secrets: string[];
18
+ scopes: string[];
19
+ approvals: string[];
20
+ hasGroups: boolean;
21
+ expiresAfter?: string;
22
+ allow: Check;
23
+ fields: Record<string, ChannelField>;
24
+ identity?: (data: Frontmatter) => string | null;
25
+ }
26
+ export interface ChannelSettings {
27
+ type: string;
28
+ enabled: boolean;
29
+ allow: typeof ANYONE | string[];
30
+ respondTo: string[];
31
+ dedicatedChannels: string[];
32
+ sendTo: string[];
33
+ scope: string;
34
+ expiresAfterMs: number | null;
35
+ approvals: string;
36
+ limits: Record<string, number>;
37
+ greeting: string | null;
38
+ }
39
+ export interface ReadChannelsResult {
40
+ channels: Channel[];
41
+ errors: string[];
42
+ }
43
+ export interface CheckChannelsOptions {
44
+ agent?: Pick<MarkdownFile, "body">;
45
+ systemPrompt?: SystemPromptPart[];
46
+ tools?: Tool[];
47
+ toolsets?: AgentbookCatalog;
48
+ }
49
+ export type ChannelSystemSource = {
50
+ agent: Pick<MarkdownFile, "body">;
51
+ systemPrompt?: SystemPromptPart[];
52
+ } | {
53
+ agent?: undefined;
54
+ body: string;
55
+ };
56
+ export declare const CHANNEL_TYPES: Record<string, ChannelType>;
57
+ export declare function readChannels(files: FileMap): ReadChannelsResult;
58
+ export declare function checkChannels(channels: Channel[], { agent, systemPrompt, tools, toolsets }?: CheckChannelsOptions, errors?: string[], warnings?: string[]): {
59
+ errors: string[];
60
+ warnings: string[];
61
+ };
62
+ export declare function durationMs(value: unknown): number | null;
63
+ export declare function channelSettings({ data }: Pick<Channel, "data">): ChannelSettings;
64
+ export declare const channelSystem: (instance: ChannelSystemSource, channel: Pick<Channel, "body">) => string;
65
+ export {};