@arcforge/types 2.0.163 → 2.0.165
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 +26 -0
- package/package.json +22 -2
- package/src/agent-handle.ts +163 -0
- package/src/blueprint.ts +38 -0
- package/src/capsule-config.ts +13 -6
- package/src/engine.ts +3 -3
- package/src/error.ts +5 -0
- package/src/handle.ts +16 -10
- package/src/http.ts +2 -2
- package/src/index.ts +7 -0
- package/src/policy-build.ts +28 -6
- package/src/policy-normalize.ts +266 -33
- package/src/policy-resolve.ts +14 -2
- package/src/policy-shell.ts +189 -0
- package/src/policy.ts +329 -21
- package/src/prompts.ts +32 -0
- package/src/report.ts +2 -2
- package/src/scope.ts +4 -4
- package/src/session/events/capsule.ts +3 -3
- package/src/supervisor.ts +28 -1
- package/src/tools.ts +0 -6
- package/src/tui-contract.ts +1 -1
- package/src/tui.ts +31 -12
package/src/policy.ts
CHANGED
|
@@ -22,6 +22,35 @@ export type PolicyRule =
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* One entry in the `tools` map: a verdict for the whole name, or a bag of
|
|
27
|
+
* per-member verdicts one level deep.
|
|
28
|
+
*
|
|
29
|
+
* The bag branch is written as an index signature rather than
|
|
30
|
+
* `Record<string, PolicyRule>` so a literal like `{ read: true }` is not
|
|
31
|
+
* excess-property-checked against the glob branch (`{ allow?, deny? }`) and
|
|
32
|
+
* rejected — TypeScript picks the first union member a literal could match,
|
|
33
|
+
* and a bag shares no keys with a glob rule.
|
|
34
|
+
*/
|
|
35
|
+
export type ToolRule = PolicyRule | ToolMemberBag
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Per-member verdicts for one tool bag (`fs: { read: true, remove: false }`).
|
|
39
|
+
*
|
|
40
|
+
* The `allow`/`deny`/`escalate` keys are excluded because those make an
|
|
41
|
+
* object a GLOB RULE, not a bag — the same test `isMemberBag` applies at
|
|
42
|
+
* runtime. Encoding it here means TypeScript picks the right union branch
|
|
43
|
+
* for an object literal instead of excess-property-checking a bag against
|
|
44
|
+
* the glob shape and rejecting every member name.
|
|
45
|
+
*/
|
|
46
|
+
export type ToolMemberBag = {
|
|
47
|
+
[member: string]: PolicyRule
|
|
48
|
+
} & {
|
|
49
|
+
allow?: never
|
|
50
|
+
deny?: never
|
|
51
|
+
escalate?: never
|
|
52
|
+
}
|
|
53
|
+
|
|
25
54
|
/**
|
|
26
55
|
* A whole enforcement surface's policy — one rule for everything in it, or a
|
|
27
56
|
* rule per key.
|
|
@@ -52,20 +81,45 @@ export type PolicyRule =
|
|
|
52
81
|
export type PolicyBucket = PolicyRule | Record<string, PolicyRule>
|
|
53
82
|
|
|
54
83
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
84
|
+
* The `tools` bucket as an author writes it — a bare verdict for everything,
|
|
85
|
+
* or a map whose entries may themselves be per-member bags.
|
|
57
86
|
*
|
|
58
|
-
*
|
|
87
|
+
* Separate from `PolicyBucket` because only `tools` has the second level:
|
|
88
|
+
* `network` keys hosts and `process` has two fixed verbs, neither of which
|
|
89
|
+
* has members to address.
|
|
90
|
+
*/
|
|
91
|
+
export type ToolBucket = PolicyRule | Record<string, ToolRule>
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The wire type every enforcement layer reads. Passed to the agent on boot or
|
|
95
|
+
* via `update()`.
|
|
96
|
+
*
|
|
97
|
+
* ── Two layers with different expressive power ──────────────────────────────
|
|
98
|
+
*
|
|
99
|
+
* OS CONFINEMENT (Linux) is the WALL. `fs` becomes mount-namespace bind
|
|
100
|
+
* mounts, `net` becomes a network namespace with an nft default-drop
|
|
101
|
+
* ruleset, `limits` becomes cgroup caps, `env` becomes an explicit
|
|
102
|
+
* environment built from nothing. A path not granted does not exist; a host
|
|
103
|
+
* not allowed is unroutable. No process inside can argue with any of it.
|
|
104
|
+
*
|
|
105
|
+
* The MEDIATOR (everywhere) is the SOFT layer: it gates tool calls and
|
|
106
|
+
* program execution by glob, returns typed denials the model can reason
|
|
107
|
+
* about, raises escalations a human answers, and emits a span per decision.
|
|
59
108
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* mounts, `network` becomes a net-namespace + nft allowlist, `limits`
|
|
65
|
-
* becomes cgroup caps. Where the two overlap (network), the OS layer is
|
|
66
|
-
* the truth and the mediator is only the polite error in front of it.
|
|
109
|
+
* Where they overlap the OS layer is the truth and the mediator is the polite
|
|
110
|
+
* error in front of it. Off Linux only the mediator runs, which is a real
|
|
111
|
+
* reduction and is stated as one: `fs`, `net`, `limits` and `env` have no OS
|
|
112
|
+
* enforcement there.
|
|
67
113
|
*
|
|
68
|
-
*
|
|
114
|
+
* ── The shape follows what can be enforced ──────────────────────────────────
|
|
115
|
+
*
|
|
116
|
+
* Each surface is written to match its enforcement mechanism rather than to be
|
|
117
|
+
* uniform with its neighbours. `net` is an allow/deny list with no escalation
|
|
118
|
+
* because nftables filters packets and cannot ask a question. `shell` names
|
|
119
|
+
* binaries rather than command lines because a string matcher cannot survive
|
|
120
|
+
* four spellings of the same command. Uniformity that lets a user express what
|
|
121
|
+
* the kernel will not do is worse than an irregular API, and every place this
|
|
122
|
+
* type is irregular, that is why.
|
|
69
123
|
*/
|
|
70
124
|
export type CapsulePolicy = {
|
|
71
125
|
/**
|
|
@@ -134,17 +188,150 @@ export type CapsulePolicy = {
|
|
|
134
188
|
}
|
|
135
189
|
|
|
136
190
|
/**
|
|
137
|
-
* Network destinations
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
191
|
+
* Network destinations the box may reach.
|
|
192
|
+
*
|
|
193
|
+
* ── Why this is a LIST, not a glob map ──────────────────────────────────
|
|
194
|
+
*
|
|
195
|
+
* This was `Record<host, PolicyRule>`, which let a host carry `"escalate"`
|
|
196
|
+
* or a glob. Neither survives contact with the enforcement layer: nftables
|
|
197
|
+
* matches packets on ADDRESS and PORT, and it cannot pause to ask a human
|
|
198
|
+
* mid-connect. A shape that can express what the kernel cannot enforce is
|
|
199
|
+
* how `{ "*": false }` came to mean "unrestricted internet" — the rule read
|
|
200
|
+
* as a denial and compiled to nothing.
|
|
201
|
+
*
|
|
202
|
+
* So the shape is deliberately narrower than the rest of the policy: an
|
|
203
|
+
* allowlist and a denylist of `host` or `host:port`, and no escalation.
|
|
204
|
+
* What it says is what the kernel does.
|
|
205
|
+
*
|
|
206
|
+
* ── Enforcement ────────────────────────────────────────────────────────
|
|
207
|
+
*
|
|
208
|
+
* Under `isolation: "auto"` the box gets its own network namespace, gains
|
|
209
|
+
* connectivity through a userspace stack (slirp4netns), and carries an nft
|
|
210
|
+
* ruleset whose default policy is DROP. Rootless — no privilege, no helper.
|
|
211
|
+
* A raw socket cannot bypass it because the filter is the namespace's own
|
|
212
|
+
* egress hook, not a library call.
|
|
213
|
+
*
|
|
214
|
+
* Absent = no network at all (`--unshare-net`, no stack whatsoever).
|
|
215
|
+
* Present = default-drop plus exactly what is listed here.
|
|
216
|
+
*
|
|
217
|
+
* ── Hostnames are PINNED, not resolved per connection ──────────────────
|
|
218
|
+
*
|
|
219
|
+
* nft filters addresses, so each hostname is resolved when the box is built
|
|
220
|
+
* and its addresses become rules. The consequence is real and stated rather
|
|
221
|
+
* than hidden: a host whose DNS rotates mid-run (a CDN, a load balancer)
|
|
222
|
+
* may drop out from under a long-lived agent. `dns: "allowlist"` is what
|
|
223
|
+
* keeps that honest — see below.
|
|
142
224
|
*/
|
|
143
|
-
|
|
225
|
+
net?: {
|
|
226
|
+
/**
|
|
227
|
+
* Destinations the box may reach: `"api.github.com"` (any port) or
|
|
228
|
+
* `"api.github.com:443"` (that port only). An IP or CIDR is taken
|
|
229
|
+
* literally and never resolved.
|
|
230
|
+
*/
|
|
231
|
+
allow?: string[]
|
|
232
|
+
/**
|
|
233
|
+
* Destinations refused even when an `allow` entry would admit them.
|
|
234
|
+
* Deny beats allow, matching every other surface.
|
|
235
|
+
*/
|
|
236
|
+
deny?: string[]
|
|
237
|
+
/**
|
|
238
|
+
* How DNS is handled inside the box.
|
|
239
|
+
*
|
|
240
|
+
* - `"allowlist"` (default when `allow` is set) — a resolver that
|
|
241
|
+
* answers only for allowlisted names. Without this, an agent can
|
|
242
|
+
* resolve any name it likes and reach an allowlisted IP that happens
|
|
243
|
+
* to be shared hosting, or use DNS itself as an exfiltration channel.
|
|
244
|
+
* - `"open"` — port 53 to the host resolver, unfiltered. The pragmatic
|
|
245
|
+
* choice while a name is resolvable but its addresses churn.
|
|
246
|
+
* - `"off"` — no DNS. Only literal addresses in `allow` are reachable.
|
|
247
|
+
*/
|
|
248
|
+
dns?: "allowlist" | "open" | "off"
|
|
249
|
+
}
|
|
144
250
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
251
|
+
/**
|
|
252
|
+
* Shell access — running programs.
|
|
253
|
+
*
|
|
254
|
+
* ── Why the BINARY is the unit, not the command line ───────────────────
|
|
255
|
+
*
|
|
256
|
+
* This was `process: { run, spawn }`, matching a glob against the whole
|
|
257
|
+
* command string. That is not enforceable against an adversary: the same
|
|
258
|
+
* command reaches the same binary as `git push --force`, `git push
|
|
259
|
+
* --force`, `env git push --force`, or `sh -c "git push --force"`, and a
|
|
260
|
+
* string matcher catches one of the four. An allowlist that four spellings
|
|
261
|
+
* defeat is a linter, not a control.
|
|
262
|
+
*
|
|
263
|
+
* So `allow`/`deny` name PROGRAMS — resolved to a binary before matching —
|
|
264
|
+
* and argument patterns are a separate, explicitly advisory layer.
|
|
265
|
+
*/
|
|
266
|
+
shell?: {
|
|
267
|
+
/** Programs the agent may execute, by name (`"git"`) or absolute path. */
|
|
268
|
+
allow?: string[]
|
|
269
|
+
/** Programs refused outright. Deny beats allow. */
|
|
270
|
+
deny?: string[]
|
|
271
|
+
/**
|
|
272
|
+
* Argument patterns per program, matched against the argv tail.
|
|
273
|
+
*
|
|
274
|
+
* ADVISORY — mediator-only, and honest about it. A program that is
|
|
275
|
+
* allowed to run can generally be driven to the same effect by another
|
|
276
|
+
* spelling, so this catches mistakes and model misfires, not a
|
|
277
|
+
* determined bypass. The durable statement is which binaries exist at
|
|
278
|
+
* all (`allow`) and whether a shell is one of them (`raw`).
|
|
279
|
+
*/
|
|
280
|
+
args?: Record<string, PolicyRule>
|
|
281
|
+
/**
|
|
282
|
+
* Whether the agent may invoke a shell — `sh -c`, `bash -c`, and
|
|
283
|
+
* friends.
|
|
284
|
+
*
|
|
285
|
+
* Its own switch because it is the bypass for everything above: a
|
|
286
|
+
* shell turns one allowed program into arbitrary execution, so a user
|
|
287
|
+
* reading `allow: ["git"]` must not have to infer that `sh` was in
|
|
288
|
+
* scope. Defaults to false whenever any `shell` rule is declared.
|
|
289
|
+
*/
|
|
290
|
+
raw?: boolean
|
|
291
|
+
/** Long-lived child processes — a different privilege from running one. */
|
|
292
|
+
spawn?: PolicyRule | {
|
|
293
|
+
/** Rule governing which programs may be spawned. */
|
|
294
|
+
rule?: PolicyRule
|
|
295
|
+
/** Concurrent long-lived children the agent may hold. */
|
|
296
|
+
max?: number
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Environment variables the agent's process receives.
|
|
302
|
+
*
|
|
303
|
+
* ── The box starts EMPTY ───────────────────────────────────────────────
|
|
304
|
+
*
|
|
305
|
+
* The environment used to be `{ ...process.env }` — every variable in the
|
|
306
|
+
* invoking shell, handed to model code. An `fs` policy would carefully deny
|
|
307
|
+
* reading `.env` from disk and then the same secrets arrived as
|
|
308
|
+
* environment. Now the box is built with `--clearenv` and receives exactly
|
|
309
|
+
* three things:
|
|
310
|
+
*
|
|
311
|
+
* 1. the RUNTIME FLOOR — HOME, PATH, TZ, LANG and Axon's own plumbing.
|
|
312
|
+
* Not a grant; the box cannot start without it, and it never appears
|
|
313
|
+
* in `axon policy` as though the user had asked for it.
|
|
314
|
+
* 2. the agent's own `.env`, beside its code and already gitignored.
|
|
315
|
+
* This is where an agent's credentials belong, and it is why
|
|
316
|
+
* deny-by-default costs nothing: the common case needs no rule here.
|
|
317
|
+
* 3. whatever this block names.
|
|
318
|
+
*
|
|
319
|
+
* Inference credentials are in NONE of those, deliberately: the provider
|
|
320
|
+
* key is held by the supervisor and the agent asks for a ROLE, so no engine
|
|
321
|
+
* key exists inside the box to leak.
|
|
322
|
+
*
|
|
323
|
+
* ── What this block is for ─────────────────────────────────────────────
|
|
324
|
+
*
|
|
325
|
+
* The escape hatch: a variable the agent should read from the HOST rather
|
|
326
|
+
* than from its own `.env` — a shared token, something CI injects. Rare by
|
|
327
|
+
* design. A name listed here that is unset on the host is not an error; a
|
|
328
|
+
* name that is set but NOT listed produces a denial that names the variable
|
|
329
|
+
* and the fix, because a missing credential surfacing as a downstream 401
|
|
330
|
+
* is the failure mode that makes people turn policy off.
|
|
331
|
+
*/
|
|
332
|
+
env?: {
|
|
333
|
+
/** Host variables passed into the box. Absent = none. */
|
|
334
|
+
allow?: string[]
|
|
148
335
|
}
|
|
149
336
|
|
|
150
337
|
/**
|
|
@@ -159,9 +346,57 @@ export type CapsulePolicy = {
|
|
|
159
346
|
cpu?: string
|
|
160
347
|
/** Max processes/threads in the tree (fork-bomb cap). */
|
|
161
348
|
pids?: number
|
|
349
|
+
/**
|
|
350
|
+
* Writable-space cap, applied as the size of the box's tmpfs.
|
|
351
|
+
*
|
|
352
|
+
* Not a cgroup control — cgroup v2 has no disk-space knob — so it
|
|
353
|
+
* bounds what the box can write to its OWN scratch space, not what it
|
|
354
|
+
* can write into a granted `fs.write` path. Stated plainly because the
|
|
355
|
+
* difference matters: a policy granting `write: ["./output"]` on a real
|
|
356
|
+
* filesystem can still fill that filesystem.
|
|
357
|
+
*/
|
|
358
|
+
disk?: string
|
|
359
|
+
/**
|
|
360
|
+
* Wall-clock ceiling on one agent run (e.g. "30m"). The tree is killed
|
|
361
|
+
* on breach. The cheapest guard against a loop that burns tokens
|
|
362
|
+
* forever, and the one limit that is about cost rather than safety.
|
|
363
|
+
*/
|
|
364
|
+
wall?: string
|
|
162
365
|
}
|
|
163
366
|
|
|
164
|
-
|
|
367
|
+
/**
|
|
368
|
+
* Tool permissions, addressed exactly as the agent's code addresses them.
|
|
369
|
+
*
|
|
370
|
+
* The key IS the global. Every export from `src/tools/*.ts` lands in the
|
|
371
|
+
* agent's scope under its own name, and this map mirrors that scope
|
|
372
|
+
* one-for-one — so a rule and a call site are the same address:
|
|
373
|
+
*
|
|
374
|
+
* ```ts
|
|
375
|
+
* tools: {
|
|
376
|
+
* "*": "escalate", // anything not named below
|
|
377
|
+
* fs: { read: true, remove: false }, // one bag, per-member rules
|
|
378
|
+
* tavily: false, // the whole bag
|
|
379
|
+
* read: false, // a bare `read()` global — NOT fs.read
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
382
|
+
*
|
|
383
|
+
* Resolution walks the address from most specific to least:
|
|
384
|
+
* `fs.remove` → `fs` → `*`. A bare `read()` tries `read` → `*`.
|
|
385
|
+
*
|
|
386
|
+
* ONE LEVEL of nesting, because that is what the scope has: a global is
|
|
387
|
+
* either a function or a bag of functions, never deeper.
|
|
388
|
+
*
|
|
389
|
+
* `fs.read` and a bare `read` are INDEPENDENT rules, deliberately — they
|
|
390
|
+
* are two different globals, and the flat scope guarantees there is only
|
|
391
|
+
* ever one of each (a second export claiming a taken name fails at
|
|
392
|
+
* install, so an address here is never ambiguous).
|
|
393
|
+
*
|
|
394
|
+
* This is the high-granularity escape hatch, not the primary control:
|
|
395
|
+
* locking the filesystem or the network itself is the durable statement,
|
|
396
|
+
* since those hold however the tool surface changes. These rules are
|
|
397
|
+
* specific to the tools an agent happens to have installed.
|
|
398
|
+
*/
|
|
399
|
+
tools?: Record<string, ToolRule>
|
|
165
400
|
}
|
|
166
401
|
|
|
167
402
|
|
|
@@ -180,6 +415,79 @@ export type CapsulePolicy = {
|
|
|
180
415
|
*/
|
|
181
416
|
export type PolicyLayer = "profile" | "agent" | "grant"
|
|
182
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Two layers' rules for one capability, kept SEPARATE so both can be evaluated.
|
|
420
|
+
*
|
|
421
|
+
* ── Why a pair and not a merged rule ────────────────────────────────────────
|
|
422
|
+
*
|
|
423
|
+
* The ceiling used to collapse at the normalisation seam: when both layers were
|
|
424
|
+
* glob-shaped, `pairRule` returned the agent's and dropped the profile's. So a
|
|
425
|
+
* profile allowing `["git status"]` under an agent allowing `["git push
|
|
426
|
+
* --force"]` resolved to the agent's rule alone, and the force-push ran — the
|
|
427
|
+
* exact widening the ceiling exists to make impossible.
|
|
428
|
+
*
|
|
429
|
+
* Merging the two rules instead is worse, and is why this type exists rather
|
|
430
|
+
* than a smarter merge: unioning two allowlists permits everything either layer
|
|
431
|
+
* allowed, and intersecting two glob patterns is not something globs can
|
|
432
|
+
* express. Carrying both and evaluating each against the subject at call time
|
|
433
|
+
* is the only form that cannot widen, and it is what lets a denial name the
|
|
434
|
+
* layer that produced it.
|
|
435
|
+
*
|
|
436
|
+
* Only constructed where BOTH layers declared a glob rule. Every collapsible
|
|
437
|
+
* case (a bare verdict on either side) still collapses at the seam, so the hot
|
|
438
|
+
* path stays a plain rule.
|
|
439
|
+
*/
|
|
440
|
+
export type PolicyRulePair = {
|
|
441
|
+
profile: PolicyRule
|
|
442
|
+
agent: PolicyRule
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** A rule as the enforcer receives it: one layer's, or both carried together. */
|
|
446
|
+
export type EffectiveRule = PolicyRule | PolicyRulePair
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* A policy after the ceiling has run — the shape the ENFORCER reads.
|
|
450
|
+
*
|
|
451
|
+
* Identical to `CapsulePolicy` except that every slot holding a verdict may
|
|
452
|
+
* hold a carried pair instead. Kept as a distinct type rather than widening
|
|
453
|
+
* `CapsulePolicy` so the AUTHORED surface stays exactly what a user can write:
|
|
454
|
+
* nobody hand-writes a `{ profile, agent }` pair, and a config type that
|
|
455
|
+
* accepted one would document a shape with no authoring meaning.
|
|
456
|
+
*/
|
|
457
|
+
export type ResolvedCapsulePolicy = Omit<CapsulePolicy, "tools" | "shell"> & {
|
|
458
|
+
tools?: Record<string, ResolvedToolEntry>
|
|
459
|
+
shell?: Omit<NonNullable<CapsulePolicy["shell"]>, "args" | "spawn"> & {
|
|
460
|
+
args?: Record<string, EffectiveRule>
|
|
461
|
+
spawn?: EffectiveRule | { rule?: EffectiveRule; max?: number }
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* One resolved `tools` entry: a verdict for the whole name (possibly a carried
|
|
467
|
+
* pair), or a bag of per-member verdicts one level deep.
|
|
468
|
+
*
|
|
469
|
+
* The bag branch is a Record of EffectiveRule and NOT of ResolvedToolEntry:
|
|
470
|
+
* nesting stops at one level because the scope does — a global is a function or
|
|
471
|
+
* a bag of functions, never deeper.
|
|
472
|
+
*/
|
|
473
|
+
export type ResolvedToolEntry = EffectiveRule | ResolvedToolBag
|
|
474
|
+
|
|
475
|
+
/** Per-member verdicts for one resolved tool bag. */
|
|
476
|
+
export type ResolvedToolBag = {
|
|
477
|
+
[member: string]: EffectiveRule
|
|
478
|
+
} & { profile?: never; agent?: never; allow?: never; deny?: never; escalate?: never }
|
|
479
|
+
|
|
480
|
+
/** Distinguishes a carried pair from an ordinary rule. */
|
|
481
|
+
export function isRulePair(rule: EffectiveRule | undefined): rule is PolicyRulePair {
|
|
482
|
+
return (
|
|
483
|
+
typeof rule === "object"
|
|
484
|
+
&& rule !== null
|
|
485
|
+
&& !Array.isArray(rule)
|
|
486
|
+
&& "profile" in rule
|
|
487
|
+
&& "agent" in rule
|
|
488
|
+
)
|
|
489
|
+
}
|
|
490
|
+
|
|
183
491
|
/**
|
|
184
492
|
* Why an operation was denied or escalated — structured, never a string.
|
|
185
493
|
*
|
package/src/prompts.ts
CHANGED
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
|
|
2
|
+
/**
|
|
3
|
+
* Every prompt this agent declares, as name → its props.
|
|
4
|
+
*
|
|
5
|
+
* EMPTY HERE ON PURPOSE. `axon prepare` writes
|
|
6
|
+
* `.agent/types/prompts.d.ts`, which augments this interface with one entry
|
|
7
|
+
* per discovered prompt — so `axon.prompt("propose")` is checked against
|
|
8
|
+
* what the agent actually has, and a typo is a compile error rather than a
|
|
9
|
+
* PROMPT_NOT_FOUND at runtime.
|
|
10
|
+
*
|
|
11
|
+
* The declaration has to live here for the augmentation to attach to
|
|
12
|
+
* anything: a `declare module` block targeting an interface that was never
|
|
13
|
+
* declared silently creates nothing, which is exactly what happened while
|
|
14
|
+
* the generator wrote entries no signature ever read.
|
|
15
|
+
*
|
|
16
|
+
* An agent with no generated frame falls back to `string` (see
|
|
17
|
+
* `AxonPromptName`), so hand-written and pre-prepare code still compiles.
|
|
18
|
+
*/
|
|
19
|
+
export interface AxonPromptMap {}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A prompt name: constrained to the generated map when there is one, and
|
|
23
|
+
* any string when there is not.
|
|
24
|
+
*
|
|
25
|
+
* The fallback is what keeps this usable before `axon prepare` has run and
|
|
26
|
+
* in code written against no particular agent — narrowing to `never` there
|
|
27
|
+
* would make every call an error for the wrong reason.
|
|
28
|
+
*/
|
|
29
|
+
export type AxonPromptName = keyof AxonPromptMap extends never ? string : keyof AxonPromptMap
|
|
30
|
+
|
|
31
|
+
/** The props one prompt takes, from the generated map. */
|
|
32
|
+
export type AxonPromptProps<K> = K extends keyof AxonPromptMap ? AxonPromptMap[K] : Record<string, unknown>
|
|
33
|
+
|
|
2
34
|
/** Prompt template discovered from an agent or module. */
|
|
3
35
|
export type AxonPrompt = {
|
|
4
36
|
/** Prompt name used with `axon.prompt(name)`. */
|
package/src/report.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* One payload shape, posted by every side of the platform to
|
|
5
5
|
* POST /api/reports. Lives here because three independent packages
|
|
6
|
-
* construct it — @
|
|
6
|
+
* construct it — @arcforge/cloud (HTTP failures), @axon/err (runtime
|
|
7
7
|
* failures), and the backend's own 5xx handler — and a contract owned by
|
|
8
8
|
* any one of them would make the other two depend on a transport.
|
|
9
9
|
*
|
|
@@ -59,7 +59,7 @@ export type ErrorReport = {
|
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
61
|
* Caller-supplied detail. SCRUBBED BEFORE SENDING — see scrubContext()
|
|
62
|
-
* in @
|
|
62
|
+
* in @arcforge/cloud. This is the one field that can carry user data
|
|
63
63
|
* (paths, prompt text, agent names), so it is the one field that must
|
|
64
64
|
* never be forwarded raw.
|
|
65
65
|
*/
|
package/src/scope.ts
CHANGED
|
@@ -11,15 +11,15 @@ export type AxonScopeMember = {
|
|
|
11
11
|
/**
|
|
12
12
|
* A related group of globals in the capsule's executable TypeScript scope.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* emitted before members so every
|
|
14
|
+
* Every member installs directly on globalThis under its own export name —
|
|
15
|
+
* a module's `name` groups it for rendering and diagnostics, it does not
|
|
16
|
+
* namespace it. `ambientTypes` are emitted before members so every
|
|
17
|
+
* referenced type is resolvable.
|
|
17
18
|
*/
|
|
18
19
|
export type AxonScopeModule = {
|
|
19
20
|
name: string
|
|
20
21
|
description?: string
|
|
21
22
|
members: readonly AxonScopeMember[]
|
|
22
|
-
flat?: boolean
|
|
23
23
|
ambientTypes?: readonly string[]
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* own vocabulary (its subprocess bus serializes these over stdout as JSONL;
|
|
4
4
|
* the host wire validates and re-emits them), registered HERE because every
|
|
5
5
|
* event type that can reach a session log lives in this package's registry
|
|
6
|
-
* — @
|
|
6
|
+
* — @arcforge/capsule re-exports it (types/events.ts), it does not own it.
|
|
7
7
|
*
|
|
8
8
|
* Naming: start/complete/failed verb suffixes throughout, matching the
|
|
9
9
|
* kernel/cognet conventions — capsule spans (cmd, fn, proc) pair up in a
|
|
@@ -43,9 +43,9 @@ import type { CapsuleScope } from "../../capsule-scope"
|
|
|
43
43
|
/**
|
|
44
44
|
* Who asked for a capsule command to run — see the capsule:cmd span below.
|
|
45
45
|
*
|
|
46
|
-
* Declared here rather than in @
|
|
46
|
+
* Declared here rather than in @arcforge/capsule for the same reason the event
|
|
47
47
|
* map is: every type that can reach a session log lives in this package's
|
|
48
|
-
* registry, and @
|
|
48
|
+
* registry, and @arcforge/capsule re-exports from here rather than owning it.
|
|
49
49
|
*/
|
|
50
50
|
export type CapsuleCommandOrigin = "cognet" | "host"
|
|
51
51
|
|
package/src/supervisor.ts
CHANGED
|
@@ -114,6 +114,27 @@ export type SupervisorToAgent = {
|
|
|
114
114
|
*/
|
|
115
115
|
request(entry: AxonStimulusEntry): Promise<{ ok: boolean; interrupted?: boolean }>
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Bind the agent's HTTP surface, inside the box, and report the port.
|
|
119
|
+
*
|
|
120
|
+
* The AGENT owns its server: routes, middleware and plugins are agent
|
|
121
|
+
* code, and the handler they compose lives in the agent's heap. A
|
|
122
|
+
* supervisor-side proxy would have to re-implement HTTP semantics over
|
|
123
|
+
* this channel — streaming responses most of all — to serve routes it
|
|
124
|
+
* cannot see.
|
|
125
|
+
*
|
|
126
|
+
* Constrained the way any HTTP service is: by the auth middleware in
|
|
127
|
+
* front of it, not by the absence of a socket.
|
|
128
|
+
*
|
|
129
|
+
* Walks forward from `port` when it is taken (Nuxt/Vite behaviour), so
|
|
130
|
+
* the bound port comes BACK rather than being assumed — a caller
|
|
131
|
+
* printing a URL must print the one that answers.
|
|
132
|
+
*
|
|
133
|
+
* Idempotent: serving an already-served agent returns the live port
|
|
134
|
+
* rather than binding a second socket.
|
|
135
|
+
*/
|
|
136
|
+
serve(port: number): Promise<{ port: number }>
|
|
137
|
+
|
|
117
138
|
/**
|
|
118
139
|
* Execute code in the agent's scope — the console/devtools eval.
|
|
119
140
|
*
|
|
@@ -143,7 +164,13 @@ export type SupervisorToAgent = {
|
|
|
143
164
|
/** What a caller wants from the agent's prompt surface. */
|
|
144
165
|
export type PromptRequest =
|
|
145
166
|
| { action: "list" }
|
|
146
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Render a declared prompt. `props` are the prompt's own parameters —
|
|
169
|
+
* a `.vue` prompt's `defineProps`, or a static one's (ignored) — carried
|
|
170
|
+
* because a prompt WITH props is unrenderable without them, and the
|
|
171
|
+
* caller that has them is on this side of the link.
|
|
172
|
+
*/
|
|
173
|
+
| { action: "get"; name: string; props?: Record<string, unknown> }
|
|
147
174
|
| { action: "render"; entry: unknown }
|
|
148
175
|
|
|
149
176
|
// ── agent → supervisor ───────────────────────────────────────────────────────
|
package/src/tools.ts
CHANGED
|
@@ -22,12 +22,6 @@ export type AxonTool = {
|
|
|
22
22
|
* one callable.
|
|
23
23
|
*/
|
|
24
24
|
origin: "src" | "module" | "workspace"
|
|
25
|
-
/**
|
|
26
|
-
* When true, each fn is a top-level named export — not grouped under the tool name as a namespace.
|
|
27
|
-
* Helios renders flat tools as `declare const hello: ...` instead of `declare namespace another { hello }`.
|
|
28
|
-
* Set for src/tools/ files where the filename is just a grouping mechanism, not a user-facing namespace.
|
|
29
|
-
*/
|
|
30
|
-
flat?: boolean
|
|
31
25
|
/** Absolute path to the module root — present when origin is "module" or a workspace module. */
|
|
32
26
|
modulePath?: string
|
|
33
27
|
/**
|