dispach 0.2.0-pilot.2 → 0.2.0-pilot.4
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/APEv2Parser-v1059sdf.js +5 -0
- package/dist/{APEv2Parser-e7k9bv13.js.map → APEv2Parser-v1059sdf.js.map} +1 -1
- package/dist/{AiffParser-btgza62h.js → AiffParser-d63xfxy7.js} +2 -2
- package/dist/App-7vmwg2rx.js +11 -0
- package/dist/{App-pg0dr8an.js.map → App-7vmwg2rx.js.map} +1 -1
- package/dist/{AsfParser-rxeats6m.js → AsfParser-e9qw1zww.js} +3 -3
- package/dist/{AsfParser-rxeats6m.js.map → AsfParser-e9qw1zww.js.map} +1 -1
- package/dist/{ConfigEditor-9qa0sktq.js → ConfigEditor-63sykb3e.js} +4 -4
- package/dist/{ConfigEditor-9qa0sktq.js.map → ConfigEditor-63sykb3e.js.map} +1 -1
- package/dist/{DsdiffParser-kv863bc1.js → DsdiffParser-g4e89wz9.js} +3 -3
- package/dist/{DsdiffParser-kv863bc1.js.map → DsdiffParser-g4e89wz9.js.map} +1 -1
- package/dist/{DsfParser-hjwbg1q5.js → DsfParser-qa5yh5p1.js} +3 -3
- package/dist/{DsfParser-hjwbg1q5.js.map → DsfParser-qa5yh5p1.js.map} +1 -1
- package/dist/FlacParser-nyx65j1q.js +5 -0
- package/dist/{KeyProbe-1ps2524b.js → KeyProbe-n5p1w903.js} +3 -3
- package/dist/{KeyProbe-1ps2524b.js.map → KeyProbe-n5p1w903.js.map} +1 -1
- package/dist/{MP4Parser-3che75e1.js → MP4Parser-4at4dbvx.js} +3 -3
- package/dist/{MP4Parser-3che75e1.js.map → MP4Parser-4at4dbvx.js.map} +1 -1
- package/dist/{MatroskaParser-8hmdtx8q.js → MatroskaParser-gg2gtj81.js} +3 -3
- package/dist/{MatroskaParser-8hmdtx8q.js.map → MatroskaParser-gg2gtj81.js.map} +1 -1
- package/dist/{MpegParser-71aj1y8y.js → MpegParser-5h5c2yvc.js} +2 -2
- package/dist/{MusepackParser-87r0dynk.js → MusepackParser-9qew0gyx.js} +3 -3
- package/dist/{MusepackParser-87r0dynk.js.map → MusepackParser-9qew0gyx.js.map} +1 -1
- package/dist/{OggParser-w42xrxch.js → OggParser-t2z5byqa.js} +3 -3
- package/dist/{OggParser-w42xrxch.js.map → OggParser-t2z5byqa.js.map} +1 -1
- package/dist/{Picker-vj5ynnq2.js → Picker-32jwxayd.js} +3 -3
- package/dist/{Picker-vj5ynnq2.js.map → Picker-32jwxayd.js.map} +1 -1
- package/dist/{SessionPicker-hfbpherr.js → SessionPicker-yjbqbstr.js} +3 -3
- package/dist/{SessionPicker-hfbpherr.js.map → SessionPicker-yjbqbstr.js.map} +1 -1
- package/dist/{SkillBrowser-1d1fm1xj.js → SkillBrowser-ry8bvw8y.js} +3 -3
- package/dist/{SkillBrowser-1d1fm1xj.js.map → SkillBrowser-ry8bvw8y.js.map} +1 -1
- package/dist/{WavPackParser-87x24j40.js → WavPackParser-p843j2sp.js} +3 -3
- package/dist/{WavPackParser-87x24j40.js.map → WavPackParser-p843j2sp.js.map} +1 -1
- package/dist/{WaveParser-dgrykdpk.js → WaveParser-fx5fb7kt.js} +2 -2
- package/dist/{WizardApp-b4q48t4z.js → WizardApp-f2rfq172.js} +3 -3
- package/dist/{WizardApp-b4q48t4z.js.map → WizardApp-f2rfq172.js.map} +1 -1
- package/dist/{channels-d4xkxfar.js → channels-yshcsfap.js} +5 -5
- package/dist/{channels-d4xkxfar.js.map → channels-yshcsfap.js.map} +1 -1
- package/dist/client.d.ts +1937 -18
- package/dist/{config-p97t4qmk.js → config-29kq9vdx.js} +12 -12
- package/dist/{config-p97t4qmk.js.map → config-29kq9vdx.js.map} +1 -1
- package/dist/{credential-pq5ckfn8.js → credential-3d0edjdj.js} +5 -5
- package/dist/{credential-pq5ckfn8.js.map → credential-3d0edjdj.js.map} +1 -1
- package/dist/{index-kqdrdn38.js → index-0za0pzfc.js} +6 -6
- package/dist/{index-kqdrdn38.js.map → index-0za0pzfc.js.map} +1 -1
- package/dist/{index-pckx0hsw.js → index-1744qpr9.js} +5 -5
- package/dist/{index-pckx0hsw.js.map → index-1744qpr9.js.map} +1 -1
- package/dist/{index-v9mmd35e.js → index-22wv6mv5.js} +4 -4
- package/dist/{index-v9mmd35e.js.map → index-22wv6mv5.js.map} +1 -1
- package/dist/{index-tn16vrgz.js → index-242qsp5x.js} +7 -7
- package/dist/{index-tn16vrgz.js.map → index-242qsp5x.js.map} +1 -1
- package/dist/{index-ry1zw01x.js → index-2c264w09.js} +11 -11
- package/dist/index-2c264w09.js.map +13 -0
- package/dist/{index-szet76ct.js → index-3et72809.js} +26 -26
- package/dist/{index-szet76ct.js.map → index-3et72809.js.map} +2 -2
- package/dist/{index-vkh83ncj.js → index-438j3bwz.js} +3 -3
- package/dist/{index-vkh83ncj.js.map → index-438j3bwz.js.map} +1 -1
- package/dist/{index-e36yxmj2.js → index-55w9ttsc.js} +15 -15
- package/dist/{index-e36yxmj2.js.map → index-55w9ttsc.js.map} +2 -2
- package/dist/index-5gb3jt0d.js +6 -0
- package/dist/{index-4kgtfze8.js.map → index-5gb3jt0d.js.map} +1 -1
- package/dist/{index-f1vcncyr.js → index-653bpmm7.js} +2 -2
- package/dist/{index-5sjysvn1.js → index-6xymgmbr.js} +4 -4
- package/dist/{index-5sjysvn1.js.map → index-6xymgmbr.js.map} +1 -1
- package/dist/{index-999yf0d2.js → index-7ccn530n.js} +169 -169
- package/dist/{index-999yf0d2.js.map → index-7ccn530n.js.map} +11 -11
- package/dist/{index-gp4z9cn5.js → index-81982mhh.js} +7 -7
- package/dist/{index-gp4z9cn5.js.map → index-81982mhh.js.map} +1 -1
- package/dist/index-8j2chqz9.js +6 -0
- package/dist/{index-p0wjy7d6.js.map → index-8j2chqz9.js.map} +1 -1
- package/dist/{index-pyajzr2x.js → index-8v9e6sg4.js} +7 -7
- package/dist/{index-pyajzr2x.js.map → index-8v9e6sg4.js.map} +1 -1
- package/dist/index-93x98xe2.js +5 -0
- package/dist/{index-7gcqnh4j.js.map → index-93x98xe2.js.map} +2 -2
- package/dist/{index-xm9pw8zm.js → index-a2xv0d12.js} +4 -4
- package/dist/{index-xm9pw8zm.js.map → index-a2xv0d12.js.map} +1 -1
- package/dist/{index-552k3p6x.js → index-afzr95s2.js} +4 -4
- package/dist/{index-552k3p6x.js.map → index-afzr95s2.js.map} +1 -1
- package/dist/{index-87hc4xtp.js → index-ah3edkkd.js} +5 -5
- package/dist/{index-87hc4xtp.js.map → index-ah3edkkd.js.map} +1 -1
- package/dist/index-b2cwz1p4.js +70 -0
- package/dist/index-b2cwz1p4.js.map +12 -0
- package/dist/{index-r9yr9z01.js → index-c20594s9.js} +10 -10
- package/dist/{index-r9yr9z01.js.map → index-c20594s9.js.map} +1 -1
- package/dist/index-c7k0tr9z.js +6 -0
- package/dist/{index-3wzageha.js.map → index-c7k0tr9z.js.map} +2 -2
- package/dist/{index-akyngwhg.js → index-d4ap27z8.js} +4 -4
- package/dist/{index-akyngwhg.js.map → index-d4ap27z8.js.map} +1 -1
- package/dist/index-dm2ydvh7.js +6 -0
- package/dist/{index-99arhztm.js.map → index-dm2ydvh7.js.map} +1 -1
- package/dist/{index-jq292533.js → index-dr4bmkvw.js} +4 -4
- package/dist/{index-jq292533.js.map → index-dr4bmkvw.js.map} +1 -1
- package/dist/{index-p82s92n0.js → index-ftqdrptv.js} +4 -4
- package/dist/{index-p82s92n0.js.map → index-ftqdrptv.js.map} +1 -1
- package/dist/{index-d05kzgz3.js → index-fzq4awfm.js} +6 -6
- package/dist/{index-d05kzgz3.js.map → index-fzq4awfm.js.map} +1 -1
- package/dist/index-gbz3n3zp.js +6 -0
- package/dist/{index-gznvv86v.js.map → index-gbz3n3zp.js.map} +1 -1
- package/dist/{index-mjxqf1s1.js → index-gq51j1v4.js} +2 -2
- package/dist/{index-5v2ynsw9.js → index-gqad9zr3.js} +6 -6
- package/dist/{index-5v2ynsw9.js.map → index-gqad9zr3.js.map} +1 -1
- package/dist/{index-7tws4a98.js → index-gta69aw8.js} +38 -38
- package/dist/{index-7tws4a98.js.map → index-gta69aw8.js.map} +5 -5
- package/dist/{index-mdhrmj2j.js → index-hgbpwf9n.js} +3 -3
- package/dist/{index-mdhrmj2j.js.map → index-hgbpwf9n.js.map} +1 -1
- package/dist/{index-7xefn7m0.js → index-jaw3fzhk.js} +4 -4
- package/dist/{index-7xefn7m0.js.map → index-jaw3fzhk.js.map} +1 -1
- package/dist/{index-q9gwzp5j.js → index-mhncbgvg.js} +4 -4
- package/dist/{index-q9gwzp5j.js.map → index-mhncbgvg.js.map} +1 -1
- package/dist/{index-96cf3zz4.js → index-n9hvdky5.js} +4 -4
- package/dist/{index-96cf3zz4.js.map → index-n9hvdky5.js.map} +1 -1
- package/dist/{index-1c7kcyfq.js → index-p2yxw774.js} +4 -4
- package/dist/{index-1c7kcyfq.js.map → index-p2yxw774.js.map} +1 -1
- package/dist/{index-tqrx302v.js → index-pnz56nvf.js} +5 -5
- package/dist/{index-tqrx302v.js.map → index-pnz56nvf.js.map} +1 -1
- package/dist/{index-0a07ca51.js → index-ppafg4wv.js} +22 -22
- package/dist/{index-0a07ca51.js.map → index-ppafg4wv.js.map} +2 -2
- package/dist/{index-rsc5p35w.js → index-r6rpt940.js} +6 -6
- package/dist/{index-rsc5p35w.js.map → index-r6rpt940.js.map} +1 -1
- package/dist/{index-kmaq9hx4.js → index-r8cpr3za.js} +4 -4
- package/dist/{index-kmaq9hx4.js.map → index-r8cpr3za.js.map} +1 -1
- package/dist/{index-7zrpcfhj.js → index-rgdredf1.js} +4 -4
- package/dist/{index-7zrpcfhj.js.map → index-rgdredf1.js.map} +1 -1
- package/dist/{index-b8d2y1cb.js → index-ryw27wwe.js} +4 -4
- package/dist/{index-b8d2y1cb.js.map → index-ryw27wwe.js.map} +1 -1
- package/dist/{index-7e78cat9.js → index-sa3y3qk9.js} +4 -4
- package/dist/{index-7e78cat9.js.map → index-sa3y3qk9.js.map} +1 -1
- package/dist/{index-8wd4ymdg.js → index-svkzkfn0.js} +3 -3
- package/dist/{index-8wd4ymdg.js.map → index-svkzkfn0.js.map} +1 -1
- package/dist/index-v700serf.js +5 -0
- package/dist/{index-8wqf1n2y.js.map → index-v700serf.js.map} +2 -2
- package/dist/{index-rhsrphzb.js → index-v7jvv9ng.js} +4 -4
- package/dist/{index-rhsrphzb.js.map → index-v7jvv9ng.js.map} +1 -1
- package/dist/{index-pk385zk4.js → index-vbr1kf2g.js} +2 -2
- package/dist/index-wzk2npdh.js +8 -0
- package/dist/{index-dpa6r43h.js.map → index-wzk2npdh.js.map} +2 -2
- package/dist/{index-k99avg4y.js → index-y3cmd2g8.js} +4 -4
- package/dist/{index-k99avg4y.js.map → index-y3cmd2g8.js.map} +1 -1
- package/dist/index.js +128 -128
- package/dist/index.js.map +4 -4
- package/dist/serve.d.ts +7 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/{web-t6d2vbx0.js → web-10856pm1.js} +4 -4
- package/dist/{web-t6d2vbx0.js.map → web-10856pm1.js.map} +1 -1
- package/dist/wire.d.ts +923 -7
- package/dist/wrapper-rgk1asmr.js +5 -0
- package/dist/{wrapper-8x4hpa5z.js.map → wrapper-rgk1asmr.js.map} +1 -1
- package/package.json +6 -5
- package/dist/APEv2Parser-e7k9bv13.js +0 -5
- package/dist/App-pg0dr8an.js +0 -11
- package/dist/FlacParser-7tvpty5w.js +0 -5
- package/dist/index-3wzageha.js +0 -6
- package/dist/index-4kgtfze8.js +0 -6
- package/dist/index-4t6mjaz9.js +0 -70
- package/dist/index-4t6mjaz9.js.map +0 -12
- package/dist/index-7gcqnh4j.js +0 -5
- package/dist/index-8wqf1n2y.js +0 -5
- package/dist/index-99arhztm.js +0 -6
- package/dist/index-dpa6r43h.js +0 -8
- package/dist/index-gznvv86v.js +0 -6
- package/dist/index-p0wjy7d6.js +0 -6
- package/dist/index-ry1zw01x.js.map +0 -13
- package/dist/wrapper-8x4hpa5z.js +0 -5
- /package/dist/{AiffParser-btgza62h.js.map → AiffParser-d63xfxy7.js.map} +0 -0
- /package/dist/{FlacParser-7tvpty5w.js.map → FlacParser-nyx65j1q.js.map} +0 -0
- /package/dist/{MpegParser-71aj1y8y.js.map → MpegParser-5h5c2yvc.js.map} +0 -0
- /package/dist/{WaveParser-dgrykdpk.js.map → WaveParser-fx5fb7kt.js.map} +0 -0
- /package/dist/{index-f1vcncyr.js.map → index-653bpmm7.js.map} +0 -0
- /package/dist/{index-mjxqf1s1.js.map → index-gq51j1v4.js.map} +0 -0
- /package/dist/{index-pk385zk4.js.map → index-vbr1kf2g.js.map} +0 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,25 +1,1944 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
export interface ErrorDetail {
|
|
4
|
+
/** Stable, machine-readable. Snake case. */
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
/** What to do about it. Never empty. */
|
|
8
|
+
readonly hint: string;
|
|
9
|
+
/** Dotted path into the manifest, where applicable: `tools.pinned[2]`. */
|
|
10
|
+
readonly field?: string;
|
|
11
|
+
}
|
|
1
12
|
/**
|
|
2
|
-
*
|
|
13
|
+
* A channel's last reported state.
|
|
3
14
|
*
|
|
4
|
-
*
|
|
15
|
+
* `needs_input` is the one that is not about the network: the transport is running and cannot
|
|
16
|
+
* finish connecting until a *person* does something — WhatsApp's link-device QR is the first
|
|
17
|
+
* instance and a re-auth after a session expires is the second. It exists before either ships
|
|
18
|
+
* because a client that has learned to read four states will not grow a fifth quietly, and
|
|
19
|
+
* without it "live but waiting for somebody" is indistinguishable from a hang.
|
|
5
20
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
21
|
+
* Deliberately not a discriminated object. The states that carry nothing would gain a wrapper
|
|
22
|
+
* they do not need, and `status` is a string on the wire (`agent.channel.status`) where changing
|
|
23
|
+
* a field's type inside `v: 1` breaks every consumer that already reads it. The structured half
|
|
24
|
+
* travels beside it as `ChannelInput`.
|
|
25
|
+
*/
|
|
26
|
+
export type ChannelStatus = "starting" | "connected" | "disconnected" | "error" | "needs_input";
|
|
27
|
+
/**
|
|
28
|
+
* What a person has to supply, when a channel reports `needs_input`.
|
|
29
|
+
*
|
|
30
|
+
* `kind` has one member on purpose. A second with no producer is the dead-vocabulary shape this
|
|
31
|
+
* runtime keeps finding (`kv`, `eviction: oldest`, `declined`) — and a reader needs a fallback
|
|
32
|
+
* branch for an unknown kind regardless, since the set can always grow, so growing it later
|
|
33
|
+
* costs a consumer nothing.
|
|
34
|
+
*/
|
|
35
|
+
export interface ChannelInput {
|
|
36
|
+
/**
|
|
37
|
+
* How to present `payload`.
|
|
38
|
+
*
|
|
39
|
+
* `qr` — render it as a 2D barcode. `pairing_code` — show it as text to be typed in, which is
|
|
40
|
+
* WhatsApp's alternative to scanning and the only route that works on a surface that cannot
|
|
41
|
+
* draw a barcode.
|
|
42
|
+
*
|
|
43
|
+
* The set grows inside `v: 1` because this is a **string on the wire**; a client that has never
|
|
44
|
+
* heard of a kind must still show the payload rather than an empty box, which is why every
|
|
45
|
+
* renderer here has an unknown-kind branch.
|
|
46
|
+
*/
|
|
47
|
+
readonly kind: "qr" | "pairing_code";
|
|
48
|
+
/** The bytes to render or display, verbatim. Never a sentence — that is `detail`. */
|
|
49
|
+
readonly payload: string;
|
|
50
|
+
/**
|
|
51
|
+
* When it stops working, if the transport knows. RFC 3339.
|
|
52
|
+
*
|
|
53
|
+
* WhatsApp rotates its QR roughly every 20 seconds, so a stored payload goes stale fast and a
|
|
54
|
+
* code nobody can tell is expired is worse than none — it reads as a broken scanner rather
|
|
55
|
+
* than an old picture. Absent means the transport does not know, never "it does not expire".
|
|
56
|
+
*/
|
|
57
|
+
readonly expiresAt?: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A `ChannelInput` as a reader gets it: stamped with when the runtime recorded it.
|
|
61
|
+
*
|
|
62
|
+
* The stamp is the runtime's rather than the transport's so one clock decides it, and it is
|
|
63
|
+
* required rather than optional because a payload whose age is unknown cannot be shown safely.
|
|
64
|
+
*/
|
|
65
|
+
export type IssuedChannelInput = ChannelInput & {
|
|
66
|
+
readonly issuedAt: string;
|
|
67
|
+
};
|
|
68
|
+
/** Where a schedule row came from, and therefore who is allowed to remove it. */
|
|
69
|
+
export type ScheduleOrigin = "manifest" | "api";
|
|
70
|
+
/** How the last run ended. `skipped` covers a fire the overlap policy deferred and then dropped. */
|
|
71
|
+
export type ScheduleRunStatus = "ok" | "error" | "skipped";
|
|
72
|
+
export interface ScheduleRecord {
|
|
73
|
+
readonly agentId: string;
|
|
74
|
+
readonly id: string;
|
|
75
|
+
readonly kind: "cron" | "every" | "at";
|
|
76
|
+
readonly expr: string;
|
|
77
|
+
/** Absent means the host zone, resolved at parse time. */
|
|
78
|
+
readonly timezone: string | undefined;
|
|
79
|
+
readonly task: string;
|
|
80
|
+
/** Absent together means `deliver: "none"` — the reply reaches the event stream only. */
|
|
81
|
+
readonly deliverChannel: string | undefined;
|
|
82
|
+
readonly deliverTo: string | undefined;
|
|
83
|
+
/** `isolated`, or `shared:<key>`. */
|
|
84
|
+
readonly sessionMode: string;
|
|
85
|
+
/** Model role override. Absent is `main`. */
|
|
86
|
+
readonly role: string | undefined;
|
|
87
|
+
readonly enabled: boolean;
|
|
88
|
+
readonly origin: ScheduleOrigin;
|
|
89
|
+
/**
|
|
90
|
+
* The un-jittered boundary that **`nextRunAt` belongs to** — the occurrence that has not
|
|
91
|
+
* happened yet, never the one before it.
|
|
92
|
+
*
|
|
93
|
+
* Two things depend on getting this right, and both were bugs first.
|
|
94
|
+
*
|
|
95
|
+
* Jitter must not compound: anchoring the following run on a *jittered* instant adds the offset
|
|
96
|
+
* once per fire, measured at 16m19s between fires of a 15-minute schedule.
|
|
97
|
+
*
|
|
98
|
+
* And it must name the **pending** occurrence rather than the last one. Treating it as
|
|
99
|
+
* already-fired makes the boot recompute ask for the occurrence *after* the pending one, which
|
|
100
|
+
* skips one per restart — measured live, a daily brief went from "in 4h" to "in 28h" and a
|
|
101
|
+
* leap-year schedule from 2028 to 2032. Whether that pending occurrence has been consumed is
|
|
102
|
+
* therefore not inferable from the anchor, and `decideDue` takes it as an argument.
|
|
103
|
+
*/
|
|
104
|
+
readonly anchorAt: string;
|
|
105
|
+
/** When it fires next, jitter included. `undefined` means never again — a spent one-shot. */
|
|
106
|
+
readonly nextRunAt: string | undefined;
|
|
107
|
+
readonly lastFiredAt: string | undefined;
|
|
108
|
+
readonly lastStatus: ScheduleRunStatus | undefined;
|
|
109
|
+
readonly lastError: string | undefined;
|
|
110
|
+
/**
|
|
111
|
+
* The run whose outcome `lastStatus` describes, so a late report can tell whether it still does.
|
|
112
|
+
*
|
|
113
|
+
* A delivery failure surfaces after the turn has finished — `hub.deliver` enqueues and the
|
|
114
|
+
* outbox sends on a later tick — so by the time it arrives the schedule may have fired again.
|
|
115
|
+
* Matching on the id is what stops that report landing on the wrong run.
|
|
116
|
+
*/
|
|
117
|
+
readonly lastRunId: string | undefined;
|
|
118
|
+
readonly runs: number;
|
|
119
|
+
/**
|
|
120
|
+
* The manifest that wrote this row, or `''` for unknown provenance.
|
|
121
|
+
*
|
|
122
|
+
* Rows are keyed by agent `id`, which two directories may share; this is what stops one
|
|
123
|
+
* manifest's reconciliation deleting the other's schedules. See migration 9.
|
|
124
|
+
*/
|
|
125
|
+
readonly sourcePath: string;
|
|
126
|
+
readonly createdAt: string;
|
|
127
|
+
readonly updatedAt: string;
|
|
128
|
+
}
|
|
129
|
+
/** Where a tool's output came from. */
|
|
130
|
+
export type Trust = "trusted" | "untrusted";
|
|
131
|
+
/** What `tools.untrusted.onMutate` may say. `confirm` needs an approver to be reachable. */
|
|
132
|
+
export type OnMutate = "refuse" | "confirm" | "allow";
|
|
133
|
+
declare const SENDER_KINDS: readonly [
|
|
134
|
+
"user",
|
|
135
|
+
"agent"
|
|
136
|
+
];
|
|
137
|
+
export type SenderKind = (typeof SENDER_KINDS)[number];
|
|
138
|
+
/** Who sent this turn's input, when it was not the operator holding the API token. */
|
|
139
|
+
export interface TurnSender {
|
|
140
|
+
/**
|
|
141
|
+
* Stable identity in the caller's own namespace: `agent:ops-bot`, `user:018f…`, an email.
|
|
142
|
+
*
|
|
143
|
+
* Opaque to this runtime, which never parses it — it is carried onto the turn row and the
|
|
144
|
+
* `turn.start` event so an audit can answer "who asked for this" after the process is gone.
|
|
145
|
+
*/
|
|
146
|
+
readonly id: string;
|
|
147
|
+
/** A human-facing name, for the prompt's frame and for a listing. Decoration, not identity. */
|
|
148
|
+
readonly name?: string;
|
|
149
|
+
readonly kind: SenderKind;
|
|
150
|
+
/**
|
|
151
|
+
* The conversation this was said in, when it was a room (Phase 27). Stamped by the runtime, never
|
|
152
|
+
* accepted from a client — the wire schema strips it. Room text is **untrusted** to every agent
|
|
153
|
+
* that reads it, a human's included: a room is several people's text, and the write gate is what
|
|
154
|
+
* holds. A mutating call from a room therefore needs a `policy.allow` rule or an approval.
|
|
155
|
+
*/
|
|
156
|
+
readonly room?: string;
|
|
157
|
+
}
|
|
158
|
+
export interface EventEnvelope<TType extends string = string, TData = unknown> {
|
|
159
|
+
readonly v: 1;
|
|
160
|
+
/** RFC 3339 UTC. */
|
|
161
|
+
readonly ts: string;
|
|
162
|
+
readonly runtimeId: string;
|
|
163
|
+
readonly agentId?: string;
|
|
164
|
+
readonly sessionKey?: string;
|
|
165
|
+
readonly turnId?: string;
|
|
166
|
+
readonly stepId?: string;
|
|
167
|
+
readonly type: TType;
|
|
168
|
+
readonly data: TData;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Why a turn stopped. Everything that is not `final` is reported honestly, never as `final`.
|
|
172
|
+
*
|
|
173
|
+
* `max_steps` used to be applied only when the last step left work pending or produced no text, so a
|
|
174
|
+
* turn that exhausted its budget while narrating was recorded as a clean completion. There is no
|
|
175
|
+
* reading under which reaching the cap is `final`, and the condition is gone.
|
|
176
|
+
*
|
|
177
|
+
* `truncated` and `no_progress` are separate reasons rather than shades of the other two because each
|
|
178
|
+
* needs a different sentence: a truncated reply names an output limit and whose it was, and a stalled
|
|
179
|
+
* one names the call that repeated. Collapsing either into `max_steps` would put the wrong remedy in
|
|
180
|
+
* front of whoever reads it.
|
|
181
|
+
*/
|
|
182
|
+
export type TurnEndReason = "final" | "max_steps" | "no_progress" | "truncated" | "stopped" | "timeout" | "error";
|
|
183
|
+
export interface ContextSlotReport {
|
|
184
|
+
readonly slot: number;
|
|
185
|
+
/**
|
|
186
|
+
* Human-facing name for the slot, from the first block in it.
|
|
187
|
+
*
|
|
188
|
+
* Declared because it is *sent*: `slotReport` has always included it and the interface has always
|
|
189
|
+
* omitted it, which type-checks because a function return is not excess-property-checked. So every
|
|
190
|
+
* reader saw `undefined` where the wire carried a name, and `04-SPEC-WIRE.md` documented a field
|
|
191
|
+
* the type said did not exist.
|
|
192
|
+
*/
|
|
193
|
+
readonly label: string;
|
|
194
|
+
readonly tokens: number;
|
|
195
|
+
readonly pinned: boolean;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Event type → shape of its `data`. Phase 1 covers boot, turn, and model events; tool events
|
|
199
|
+
* arrived in Phase 3 and channel and delivery events in Phase 4. Skill, compaction, and schedule
|
|
200
|
+
* events arrive with their subsystems.
|
|
201
|
+
*/
|
|
202
|
+
export interface EventDataMap {
|
|
203
|
+
"runtime.ready": {
|
|
204
|
+
/** Time inside `Runtime.create`. */
|
|
205
|
+
bootMs: number;
|
|
206
|
+
/** Time since process start — the number the sub-second boot claim refers to. */
|
|
207
|
+
processMs: number;
|
|
208
|
+
phases: Record<string, number>;
|
|
209
|
+
agents: number;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* The store is open and migrated. Fires before `runtime.ready`, because nothing can serve a
|
|
213
|
+
* turn until it does.
|
|
214
|
+
*
|
|
215
|
+
* `reaped` names turns a previous process left `running`. It is reported rather than fixed
|
|
216
|
+
* quietly: a non-empty list means that process died mid-generation, which is worth seeing.
|
|
217
|
+
*/
|
|
218
|
+
"store.ready": {
|
|
219
|
+
location: string;
|
|
220
|
+
driver: "bun" | "node";
|
|
221
|
+
/** Schema version before migrating. 0 for a fresh database. */
|
|
222
|
+
from: number;
|
|
223
|
+
to: number;
|
|
224
|
+
applied: string[];
|
|
225
|
+
reaped: string[];
|
|
226
|
+
};
|
|
227
|
+
"runtime.stopping": {
|
|
228
|
+
reason: string;
|
|
229
|
+
};
|
|
230
|
+
"agent.loaded": {
|
|
231
|
+
tools: number;
|
|
232
|
+
skills: number;
|
|
233
|
+
schedules: number;
|
|
234
|
+
model: string;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* One agent stopped being hosted by this process, while the process kept running.
|
|
238
|
+
*
|
|
239
|
+
* The other half of `agent.loaded`, and it only became possible to emit when `Runtime.dispose`
|
|
240
|
+
* did: before that an agent left only by the process exiting, which `runtime.stopping` already
|
|
241
|
+
* reports. A client holding a list of agents needs both — an always-on server whose agent set
|
|
242
|
+
* changes under it, with nothing on the stream saying so, is a UI that shows a chat for an
|
|
243
|
+
* agent that has gone.
|
|
244
|
+
*
|
|
245
|
+
* `reason` rather than a boolean because the three cases read differently to whoever is
|
|
246
|
+
* watching: `requested` is an operator, `replaced` is the same agent coming back a moment
|
|
247
|
+
* later, `stopped` is 16.3's durable off switch.
|
|
248
|
+
*/
|
|
249
|
+
"agent.disposed": {
|
|
250
|
+
reason: "requested" | "replaced" | "stopped";
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* A reload has finished (`Runtime.reload`) — at once when the agent was idle (`waitedMs: 0`), or
|
|
254
|
+
* after the running turns when it was not. `held` is how many new
|
|
255
|
+
* turns waited for it rather than running on the old configuration. `ok: false` means the new
|
|
256
|
+
* manifest did not load: `error` says why, and the old instance is still serving unless
|
|
257
|
+
* `disposed` says otherwise.
|
|
258
|
+
*/
|
|
259
|
+
"agent.reloaded": {
|
|
260
|
+
ok: boolean;
|
|
261
|
+
adopted: string[];
|
|
262
|
+
waitedMs: number;
|
|
263
|
+
held: number;
|
|
264
|
+
disposed: boolean;
|
|
265
|
+
error?: ErrorDetail;
|
|
266
|
+
};
|
|
267
|
+
"agent.warning": ErrorDetail;
|
|
268
|
+
/**
|
|
269
|
+
* One plugin registered, with what it cost and what it declared.
|
|
270
|
+
*
|
|
271
|
+
* `permissions` carries the *kinds* rather than the full entries: the event's job is to make
|
|
272
|
+
* visible that a plugin asked for network and env access at all, and the detail belongs in
|
|
273
|
+
* `plugins` output where somebody is actually reading it. Advisory in v1 either way (7.5).
|
|
274
|
+
*/
|
|
275
|
+
"plugin.loaded": {
|
|
276
|
+
name: string;
|
|
277
|
+
version: string;
|
|
278
|
+
setupMs: number;
|
|
279
|
+
permissions: string[];
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* A `setup` over its budget.
|
|
283
|
+
*
|
|
284
|
+
* Reported, never refused. `setup` registers capabilities and does no work, so a slow one is
|
|
285
|
+
* usually doing work that belonged in a factory — and naming it is what makes that visible,
|
|
286
|
+
* where a refusal would turn a performance smell into an agent that will not start.
|
|
287
|
+
*/
|
|
288
|
+
"plugin.slow": {
|
|
289
|
+
name: string;
|
|
290
|
+
setupMs: number;
|
|
291
|
+
};
|
|
292
|
+
/**
|
|
293
|
+
* `trust` and `from` are additive within `v: 1` and both are always meaningful.
|
|
294
|
+
*
|
|
295
|
+
* `trust` is present on every turn — `"trusted"` for the operator, the REPL, a schedule and a
|
|
296
|
+
* channel turn alike — rather than only when it is `"untrusted"`. A field that appears only in
|
|
297
|
+
* the interesting case makes its absence ambiguous between "this turn was trusted" and "this
|
|
298
|
+
* server predates the field", and an observability surface has to be able to tell those apart.
|
|
299
|
+
* `from` *is* omitted when there was no sender, because an absent sender is a real third state
|
|
300
|
+
* and synthesising one would put the operator's own turn behind a fake identity.
|
|
301
|
+
*/
|
|
302
|
+
/**
|
|
303
|
+
* A call is waiting on a person, and the runtime emitted this **before** asking.
|
|
304
|
+
*
|
|
305
|
+
* Core emits it, not the front end, and that placement is the whole reason every surface gets
|
|
306
|
+
* approvals for free. The plan had the approver emitting its own event, which makes the request
|
|
307
|
+
* visible only to whichever front end implements it — so a second observer of a REPL session,
|
|
308
|
+
* or an audit log, or the firehose, would see a turn simply stop. Core already holds the
|
|
309
|
+
* `EventContext` (agent, session, turn) that a client needs to correlate the prompt with what it
|
|
310
|
+
* is showing, and an `ApprovalRequest` deliberately does not carry any of it.
|
|
311
|
+
*
|
|
312
|
+
* Paired with exactly one `approval.resolved`. A request with no resolution is a bug, not a
|
|
313
|
+
* state — the same reasoning that keeps `tool.gated` from emitting a `tool.call` it will never
|
|
314
|
+
* follow with a `tool.result`.
|
|
315
|
+
*/
|
|
316
|
+
"approval.requested": {
|
|
317
|
+
approvalId: string;
|
|
318
|
+
slug: string;
|
|
319
|
+
callId: string;
|
|
320
|
+
/** The command or path a rule would match. Terminal escapes already stripped. */
|
|
321
|
+
match?: string;
|
|
322
|
+
mutating: boolean;
|
|
323
|
+
reason: string;
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* How it ended, including the ways nobody chose.
|
|
327
|
+
*
|
|
328
|
+
* `by` matters more than `granted` to a client with a prompt on screen: `"abandoned"` means
|
|
329
|
+
* take it down because the turn is gone, `"error"` means the approver itself is broken and the
|
|
330
|
+
* denial says nothing about what a person wanted. Collapsing all three into `granted: false`
|
|
331
|
+
* would make a crashed approver indistinguishable from a considered no.
|
|
332
|
+
*/
|
|
333
|
+
"approval.resolved": {
|
|
334
|
+
approvalId: string;
|
|
335
|
+
slug: string;
|
|
336
|
+
granted: boolean;
|
|
337
|
+
by: "approver" | "error" | "abandoned";
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* A delegation began. Emitted on the **supervisor's** context, so the envelope's `turnId` is
|
|
341
|
+
* the turn that is waiting rather than the member's.
|
|
342
|
+
*
|
|
343
|
+
* `sessionKey` is the member's fresh session, which is the answer to "what did it actually
|
|
344
|
+
* say" — the artifact is all that reaches the supervisor's prompt, deliberately, so without
|
|
345
|
+
* this a `no_artifact` would be unexplainable from the outside.
|
|
346
|
+
*/
|
|
347
|
+
"handoff.start": {
|
|
348
|
+
member: string;
|
|
349
|
+
task: string;
|
|
350
|
+
sessionKey: string;
|
|
351
|
+
};
|
|
352
|
+
/**
|
|
353
|
+
* How it ended. `outcome` rather than a boolean, and that is the same reasoning
|
|
354
|
+
* `approval.resolved.by` carries: four outcomes collapse badly into `ok: false`.
|
|
355
|
+
*
|
|
356
|
+
* `no_artifact` is the member declining or failing to fit the schema — its own prose says which.
|
|
357
|
+
* `budget` is its `limits` stopping it, which is a task-too-large signal rather than a fault.
|
|
358
|
+
* `error` is a fault. Reporting the first two as failure would send a reader debugging the
|
|
359
|
+
* member when the thing to change is the task.
|
|
360
|
+
*/
|
|
361
|
+
"handoff.result": {
|
|
362
|
+
member: string;
|
|
363
|
+
sessionKey: string;
|
|
364
|
+
outcome: "ok" | "no_artifact" | "budget" | "error";
|
|
365
|
+
steps: number;
|
|
366
|
+
tokens: {
|
|
367
|
+
prompt: number;
|
|
368
|
+
output: number;
|
|
369
|
+
};
|
|
370
|
+
errorCode?: string;
|
|
371
|
+
};
|
|
372
|
+
"turn.start": {
|
|
373
|
+
source: string;
|
|
374
|
+
inputTokens: number;
|
|
375
|
+
trust: Trust;
|
|
376
|
+
from?: {
|
|
377
|
+
id: string;
|
|
378
|
+
kind: SenderKind;
|
|
379
|
+
};
|
|
380
|
+
};
|
|
381
|
+
"context.assembled": {
|
|
382
|
+
slots: ContextSlotReport[];
|
|
383
|
+
total: number;
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* History that did not fit the prompt budget and was left out by `assembleContext`.
|
|
387
|
+
*
|
|
388
|
+
* This is the blunt trim, not the ladder: it runs after compaction has done what it can and drops
|
|
389
|
+
* whole messages newest-budget-first. `AssembledContext.droppedMessages` was documented as
|
|
390
|
+
* "Reported, never silent" and had no reader anywhere, so a prompt could lose the oldest half of a
|
|
391
|
+
* conversation with nothing saying so on any surface.
|
|
392
|
+
*
|
|
393
|
+
* Distinct from `compaction.stage` on purpose: a stage is a decision the ladder made and can
|
|
394
|
+
* explain, and this is the budget running out anyway.
|
|
395
|
+
*/
|
|
396
|
+
"context.dropped": {
|
|
397
|
+
messages: number;
|
|
398
|
+
budget: number;
|
|
399
|
+
keptTokens: number;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* How full the prompt that was sent is. Emitted once per step, after any compaction.
|
|
403
|
+
*
|
|
404
|
+
* `fraction` describes the prompt that went to the endpoint, not the one the ladder was handed —
|
|
405
|
+
* and that distinction was a real defect, caught in a pty capture. Reporting the pre-compaction
|
|
406
|
+
* figure put **`ctx 128%`** on the status line of a session that compaction had handled correctly:
|
|
407
|
+
* true of a prompt nobody sent, and indistinguishable from a runtime that had just overflowed its
|
|
408
|
+
* window. `peak` carries the figure the ladder actually ran on, and is present only when it differs.
|
|
409
|
+
*
|
|
410
|
+
* `source` is here because a fraction alone cannot be acted on: `estimated` means no endpoint has
|
|
411
|
+
* reported `prompt_tokens` yet and the figure carries the estimator's raw bias, which is measured
|
|
412
|
+
* at 16–20% *low* on observation-heavy prompts. Reading a bare number without knowing which of the
|
|
413
|
+
* three it is invites tuning thresholds against the wrong quantity.
|
|
414
|
+
*/
|
|
415
|
+
"context.pressure": {
|
|
416
|
+
fraction: number;
|
|
417
|
+
tokens: number;
|
|
418
|
+
budget: number;
|
|
419
|
+
source: "reported" | "corrected" | "estimated";
|
|
420
|
+
/** What the ladder faced, when compaction changed it. Absent on an ordinary turn. */
|
|
421
|
+
peak?: number;
|
|
422
|
+
};
|
|
423
|
+
/**
|
|
424
|
+
* One compaction stage that ran. Emitted per stage, in the order they ran.
|
|
425
|
+
*
|
|
426
|
+
* `changed: false` is not noise — it is why the next stage ran, and a ladder that only reported its
|
|
427
|
+
* successes would look like it skipped rungs. `digest` names where the text came from, because "the
|
|
428
|
+
* digest is thin" and "the compactor is unreachable" need different fixes.
|
|
429
|
+
*/
|
|
430
|
+
"compaction.stage": {
|
|
431
|
+
stage: "trim" | "snip" | "micro" | "collapse" | "reset";
|
|
432
|
+
before: number;
|
|
433
|
+
after: number;
|
|
434
|
+
changed: boolean;
|
|
435
|
+
digest?: "model" | "mechanical";
|
|
436
|
+
};
|
|
437
|
+
/**
|
|
438
|
+
* The last rung fired: history was replaced by a digest.
|
|
439
|
+
*
|
|
440
|
+
* `count` is per session, and a second firing is a misconfiguration rather than a busy day —
|
|
441
|
+
* `warning` carries the sentence saying so.
|
|
442
|
+
*/
|
|
443
|
+
"context.reset": {
|
|
444
|
+
count: number;
|
|
445
|
+
warning?: string;
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* The session moved to another phase, and the visible catalogue changed with it.
|
|
449
|
+
*
|
|
450
|
+
* `tools` is the count now visible, because that is the fact a reader wants: the phase name alone
|
|
451
|
+
* does not say whether the move did anything. Emitted from inside the step that called `phase_set`,
|
|
452
|
+
* so the ordering shows which reply the change applies to.
|
|
453
|
+
*/
|
|
454
|
+
"phase.changed": {
|
|
455
|
+
to: string;
|
|
456
|
+
tools: number;
|
|
457
|
+
};
|
|
458
|
+
"model.call": {
|
|
459
|
+
role: "main" | "selector" | "compactor";
|
|
460
|
+
model: string;
|
|
461
|
+
promptTokens: number;
|
|
462
|
+
/** Always false: whether a call hits a cache is known only from its usage, on `model.result`. */
|
|
463
|
+
cached: boolean;
|
|
464
|
+
attempt: number;
|
|
465
|
+
/** This model call's id, the same one its `model.result` and usage row carry (not a tool call's). */
|
|
466
|
+
callId: string;
|
|
467
|
+
};
|
|
468
|
+
/** Suppressed unless a subscriber opted in — this is per-token and high volume. */
|
|
469
|
+
"model.chunk": {
|
|
470
|
+
delta: string;
|
|
471
|
+
kind: "text" | "reasoning";
|
|
472
|
+
};
|
|
473
|
+
"model.retry": {
|
|
474
|
+
status: number;
|
|
475
|
+
attempt: number;
|
|
476
|
+
delayMs: number;
|
|
477
|
+
};
|
|
478
|
+
/**
|
|
479
|
+
* A call moved from a failing model to the next in its role's `fallbacks`, before any output.
|
|
480
|
+
* `reason` is the error code or status (`model_unreachable`, `HTTP 503`).
|
|
481
|
+
*/
|
|
482
|
+
"model.fallback": {
|
|
483
|
+
from: string;
|
|
484
|
+
to: string;
|
|
485
|
+
reason: string;
|
|
486
|
+
};
|
|
487
|
+
"model.result": {
|
|
488
|
+
outputTokens: number;
|
|
489
|
+
promptTokens: number;
|
|
490
|
+
/**
|
|
491
|
+
* Whether `promptTokens` came from the endpoint or from `estimateTokens`.
|
|
492
|
+
*
|
|
493
|
+
* The event carried the number and not whether it was measured, so every consumer summing
|
|
494
|
+
* it was mixing the two silently — and the estimator runs **16-20% low** on exactly the
|
|
495
|
+
* observation-heavy prompts worth summing (`evals/budget`). `StepResult` has carried this
|
|
496
|
+
* flag since Phase 7A for the compaction ladder, which refuses to calibrate without it; a
|
|
497
|
+
* ladder that would not trust the figure while an observability surface reported it as fact
|
|
498
|
+
* is the same asymmetry `cachedPromptTokens`' three states exist to prevent.
|
|
499
|
+
*
|
|
500
|
+
* Added by 10B's eval, which needs to compare two token figures and must refuse to print a
|
|
501
|
+
* ratio of two estimates.
|
|
502
|
+
*/
|
|
503
|
+
promptTokensReported: boolean;
|
|
504
|
+
finishReason: string;
|
|
505
|
+
latencyMs: number;
|
|
506
|
+
/**
|
|
507
|
+
* Milliseconds from the request to the first streamed output — text, reasoning or a tool
|
|
508
|
+
* call. The latency a person feels, which `latencyMs` (the whole call) hides on a long reply.
|
|
509
|
+
* Absent when nothing streamed: an error before the first chunk, or an empty reply.
|
|
510
|
+
*/
|
|
511
|
+
firstTokenMs?: number;
|
|
512
|
+
/**
|
|
513
|
+
* The model call's id — minted once, before retries and fallbacks, so one call is one id
|
|
514
|
+
* however many requests it took. The idempotency key a ledger debits on: a redelivered
|
|
515
|
+
* webhook carries the same one. Not a tool call's `callId`.
|
|
516
|
+
*/
|
|
517
|
+
callId: string;
|
|
518
|
+
/** The model that answered: the requested one, or the fallback that stood in for it. */
|
|
519
|
+
model: string;
|
|
520
|
+
/** The manifest role that made the call: `main`, `compactor`, or a named one. */
|
|
521
|
+
role: string;
|
|
522
|
+
/** Prompt tokens served from cache, when reported. Absent is "not reported", not zero. */
|
|
523
|
+
cachedPromptTokens?: number;
|
|
524
|
+
/** Prompt tokens written to cache, when reported. */
|
|
525
|
+
cacheWriteTokens?: number;
|
|
526
|
+
/** Who sent the turn this call belongs to, when it was not the operator. */
|
|
527
|
+
sender?: string;
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* A tool is about to run. `argsHash` rather than the arguments themselves: arguments carry
|
|
531
|
+
* whatever the conversation carried, and an event stream is the wrong place to copy it to.
|
|
532
|
+
*/
|
|
533
|
+
/**
|
|
534
|
+
* A billable media call: a voice note transcribed or an image generated.
|
|
535
|
+
*
|
|
536
|
+
* Its own event rather than a `model.result`, because every consumer of that one reads token
|
|
537
|
+
* figures and a media call has none; `callId` is the same kind of ledger key and the row lands in
|
|
538
|
+
* `model_calls` beside the token rows, so `/v1/usage` sums both.
|
|
539
|
+
*/
|
|
540
|
+
"media.result": {
|
|
541
|
+
callId: string;
|
|
542
|
+
kind: "transcription" | "image";
|
|
543
|
+
provider: string;
|
|
544
|
+
model: string;
|
|
545
|
+
latencyMs: number;
|
|
546
|
+
/** Present on an image call. */
|
|
547
|
+
images?: number;
|
|
548
|
+
/** Present on a transcription whose duration the provider or the channel reported. */
|
|
549
|
+
audioSeconds?: number;
|
|
550
|
+
sender?: string;
|
|
551
|
+
};
|
|
552
|
+
"tool.call": {
|
|
553
|
+
slug: string;
|
|
554
|
+
callId: string;
|
|
555
|
+
argsHash: string;
|
|
556
|
+
mutating: boolean;
|
|
557
|
+
};
|
|
558
|
+
"tool.result": {
|
|
559
|
+
slug: string;
|
|
560
|
+
callId: string;
|
|
561
|
+
ok: boolean;
|
|
562
|
+
latencyMs: number;
|
|
563
|
+
/** Of the observation before any truncation, so a cut is visible as a size, not a guess. */
|
|
564
|
+
bytes: number;
|
|
565
|
+
truncated: boolean;
|
|
566
|
+
/** Whether this output may contain text a stranger wrote. */
|
|
567
|
+
trust: Trust;
|
|
568
|
+
};
|
|
569
|
+
/**
|
|
570
|
+
* A call was blocked before it ran — by the trust gate, or by a `tools.policy` rule.
|
|
571
|
+
*
|
|
572
|
+
* **Not an error.** The model is told and the turn continues. `reason` says which of the two
|
|
573
|
+
* decided and why; `policy` carries the `tools.untrusted.onMutate` setting, so a surprised
|
|
574
|
+
* operator can see whether they were on the default.
|
|
575
|
+
*
|
|
576
|
+
* A blocked call emits this and nothing else — no `tool.call`, no `tool.result` — because
|
|
577
|
+
* nothing ran, and a consumer pairing call with result would otherwise hold an orphan.
|
|
578
|
+
*/
|
|
579
|
+
"tool.gated": {
|
|
580
|
+
slug: string;
|
|
581
|
+
callId: string;
|
|
582
|
+
reason: string;
|
|
583
|
+
policy: OnMutate;
|
|
584
|
+
};
|
|
585
|
+
/**
|
|
586
|
+
* A step's tool calls could not be used as written. The first occurrence is followed by one
|
|
587
|
+
* correction request; a second in a row ends the turn with `tool_repair_failed` rather than
|
|
588
|
+
* asking again. Two of these back to back is the signal that a catalogue needs work.
|
|
589
|
+
*/
|
|
590
|
+
"tool.repair": {
|
|
591
|
+
slugs: string[];
|
|
592
|
+
errors: string[];
|
|
593
|
+
};
|
|
594
|
+
/**
|
|
595
|
+
* A remote tool provider caught its cached catalogue up, **after** `runtime.ready`.
|
|
596
|
+
*
|
|
597
|
+
* The only observable evidence that the refresh happened, since it is deliberately fire-and-forget:
|
|
598
|
+
* the boot path resolves from disk so that nothing touches the network before readiness, which
|
|
599
|
+
* means the network call has to live somewhere with no caller waiting on it. `ok: false` carries
|
|
600
|
+
* the reason and is not a turn failure — the agent keeps serving the cached catalogue.
|
|
601
|
+
*
|
|
602
|
+
* `changed` is the field worth watching. A slug whose schema moved under a running agent is a
|
|
603
|
+
* catalogue the model has already been told about in the current session's cached prefix.
|
|
604
|
+
*/
|
|
605
|
+
"tools.refreshed": {
|
|
606
|
+
provider: string;
|
|
607
|
+
ok: boolean;
|
|
608
|
+
fetched: number;
|
|
609
|
+
changed: string[];
|
|
610
|
+
missing: string[];
|
|
611
|
+
latencyMs: number;
|
|
612
|
+
/** Present when `ok` is false. */
|
|
613
|
+
error?: string;
|
|
614
|
+
};
|
|
615
|
+
/**
|
|
616
|
+
* A channel's state changed.
|
|
617
|
+
*
|
|
618
|
+
* Never blocks readiness. A channel that cannot connect says so here and keeps trying, because
|
|
619
|
+
* a runtime that refused to boot during a Telegram outage would also be unable to serve its
|
|
620
|
+
* HTTP API during one. `needs_input` is the same rule applied to a person rather than a
|
|
621
|
+
* network: the transport is up and cannot finish without somebody acting.
|
|
622
|
+
*
|
|
623
|
+
* `status` is imported rather than restated. It was a second literal copy of `ChannelStatus`
|
|
624
|
+
* for four phases — right when written and silently wrong at the next member, which is the
|
|
625
|
+
* hand-kept-list shape this runtime has paid for repeatedly (`NO_MANIFEST`, `THRESHOLD_ORDER`,
|
|
626
|
+
* the wire doc's six phantom event rows).
|
|
627
|
+
*
|
|
628
|
+
* `input` accompanies `needs_input` and nothing else: the structured thing a person has to act
|
|
629
|
+
* on, where `detail` is the sentence explaining it. A consumer must tolerate an unknown
|
|
630
|
+
* `kind`, because that set can grow inside `v: 1` while this field's type cannot.
|
|
631
|
+
*/
|
|
632
|
+
"agent.channel.status": {
|
|
633
|
+
channelId: string;
|
|
634
|
+
channelType: string;
|
|
635
|
+
status: ChannelStatus;
|
|
636
|
+
detail?: string;
|
|
637
|
+
input?: IssuedChannelInput;
|
|
638
|
+
};
|
|
639
|
+
/** A channel failure that did not stop the channel. A bad token lands here, not on `error`. */
|
|
640
|
+
"agent.channel.error": ErrorDetail & {
|
|
641
|
+
channelId: string;
|
|
642
|
+
};
|
|
643
|
+
/**
|
|
644
|
+
* An inbound message was not turned into a turn.
|
|
645
|
+
*
|
|
646
|
+
* `duplicate` is routine — a provider replaying an unacknowledged update. `denied` is an
|
|
647
|
+
* `allowFrom` refusal, and is reported rather than dropped silently: an allowlist that quietly
|
|
648
|
+
* discards a message is indistinguishable from a channel that is not receiving at all, which is
|
|
649
|
+
* a support conversation nobody enjoys.
|
|
650
|
+
*/
|
|
651
|
+
"agent.channel.rejected": {
|
|
652
|
+
channelId: string;
|
|
653
|
+
reason: "duplicate" | "denied";
|
|
654
|
+
/** Handle where the provider exposes one, peer id otherwise. Never the message body. */
|
|
655
|
+
sender: string;
|
|
656
|
+
detail: string;
|
|
657
|
+
};
|
|
658
|
+
/**
|
|
659
|
+
* One chunk reached the provider.
|
|
660
|
+
*
|
|
661
|
+
* `uncertain` means this row was recovered from a dead process and may be a second copy — see
|
|
662
|
+
* `delivery.uncertain`. It is on the success event on purpose: that is where a reader
|
|
663
|
+
* investigating a duplicate will actually be looking.
|
|
664
|
+
*/
|
|
665
|
+
"delivery.sent": {
|
|
666
|
+
channelId: string;
|
|
667
|
+
providerMessageId?: string;
|
|
668
|
+
chunkIndex: number;
|
|
669
|
+
chunkTotal: number;
|
|
670
|
+
attempts: number;
|
|
671
|
+
uncertain: boolean;
|
|
672
|
+
};
|
|
673
|
+
/** A retryable send failed and will be tried again after `delayMs`. */
|
|
674
|
+
"delivery.retry": {
|
|
675
|
+
channelId: string;
|
|
676
|
+
chunkIndex: number;
|
|
677
|
+
attempts: number;
|
|
678
|
+
delayMs: number;
|
|
679
|
+
error: ErrorDetail;
|
|
680
|
+
};
|
|
681
|
+
/**
|
|
682
|
+
* A chunk was abandoned. `exhausted` distinguishes "gave up after N tries" from "the provider
|
|
683
|
+
* said no and meant it", which want different responses from whoever is reading.
|
|
684
|
+
*
|
|
685
|
+
* `abandoned` counts the later chunks of the same reply dropped as a consequence. Half a
|
|
686
|
+
* message is worse than none, so they are not sent on their own — and they are reported as one
|
|
687
|
+
* number rather than as N more failure events, because there was one fault.
|
|
688
|
+
*/
|
|
689
|
+
"delivery.failed": {
|
|
690
|
+
channelId: string;
|
|
691
|
+
chunkIndex: number;
|
|
692
|
+
chunkTotal: number;
|
|
693
|
+
attempts: number;
|
|
694
|
+
exhausted: boolean;
|
|
695
|
+
abandoned: number;
|
|
696
|
+
error: ErrorDetail;
|
|
697
|
+
};
|
|
698
|
+
/**
|
|
699
|
+
* A delivery was found in flight at boot and re-queued, and may therefore be sent twice.
|
|
700
|
+
*
|
|
701
|
+
* The window is between the bytes leaving the process and the provider's acknowledgement
|
|
702
|
+
* arriving back, and it cannot be closed from this side — only by a provider that deduplicates
|
|
703
|
+
* on a key we supply. `idempotentSend` reports whether this channel is one of those, so the
|
|
704
|
+
* event says how much doubt there actually is rather than implying a fixed amount.
|
|
705
|
+
*/
|
|
706
|
+
"delivery.uncertain": {
|
|
707
|
+
channelId: string;
|
|
708
|
+
chunkIndex: number;
|
|
709
|
+
chunkTotal: number;
|
|
710
|
+
attempts: number;
|
|
711
|
+
idempotentSend: boolean;
|
|
712
|
+
};
|
|
713
|
+
/**
|
|
714
|
+
* A tool provider let go of something outside this process during shutdown.
|
|
715
|
+
*
|
|
716
|
+
* Emitted rather than logged because the thing being released is, by definition, something that
|
|
717
|
+
* would otherwise outlive the runtime unnoticed — which is exactly what happened: `exec`
|
|
718
|
+
* backgrounded commands that nothing ever reaped, and thirty-three of them took the machine to a
|
|
719
|
+
* load average of 351 and made `runtime.ready` take 132 seconds.
|
|
720
|
+
*/
|
|
721
|
+
"runtime.released": {
|
|
722
|
+
provider: string;
|
|
723
|
+
released: string[];
|
|
724
|
+
};
|
|
725
|
+
/** Manifest schedules brought in line with the store at load. API-created rows are untouched. */
|
|
726
|
+
"schedules.reconciled": {
|
|
727
|
+
created: number;
|
|
728
|
+
updated: number;
|
|
729
|
+
removed: number;
|
|
730
|
+
total: number;
|
|
731
|
+
};
|
|
732
|
+
/**
|
|
733
|
+
* A schedule came due and a turn started.
|
|
734
|
+
*
|
|
735
|
+
* `driftMs` is measured against the row's own `nextRunAt`, so it reports the **scheduler's**
|
|
736
|
+
* lateness and not the jitter — jitter is a deliberate, reproducible displacement and folding it
|
|
737
|
+
* into drift would make a healthy schedule look permanently late by its own offset.
|
|
738
|
+
*/
|
|
739
|
+
"schedule.fired": {
|
|
740
|
+
scheduleId: string;
|
|
741
|
+
kind: "cron" | "every" | "at";
|
|
742
|
+
driftMs: number;
|
|
743
|
+
/** A one-shot firing after its moment, because nothing was running when it came due. */
|
|
744
|
+
late: boolean;
|
|
745
|
+
};
|
|
746
|
+
/**
|
|
747
|
+
* Occurrences that came due with nothing running, and were not replayed.
|
|
748
|
+
*
|
|
749
|
+
* A recurring schedule skips to the next occurrence after downtime rather than firing the whole
|
|
750
|
+
* backlog. Emitted so the skip is visible: a schedule that silently drops fires is
|
|
751
|
+
* indistinguishable from one that is working, which is the failure this event exists to prevent.
|
|
752
|
+
*/
|
|
753
|
+
"schedule.skipped": {
|
|
754
|
+
scheduleId: string;
|
|
755
|
+
kind: "cron" | "every" | "at";
|
|
756
|
+
reason: "downtime";
|
|
757
|
+
missed: number;
|
|
758
|
+
/** The count hit its cap and the real figure is higher. */
|
|
759
|
+
missedAtLeast: boolean;
|
|
760
|
+
};
|
|
761
|
+
/** A fire arrived while the previous run of the same schedule was still going. */
|
|
762
|
+
"schedule.deferred": {
|
|
763
|
+
scheduleId: string;
|
|
764
|
+
kind: "cron" | "every" | "at";
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* A schedule could not be read, or the turn it started failed.
|
|
768
|
+
*
|
|
769
|
+
* Never thrown, on purpose: one unreadable expression must not stop the timer for every other
|
|
770
|
+
* schedule in the process.
|
|
771
|
+
*/
|
|
772
|
+
"schedule.error": {
|
|
773
|
+
scheduleId: string;
|
|
774
|
+
code: string;
|
|
775
|
+
message: string;
|
|
776
|
+
hint: string;
|
|
777
|
+
};
|
|
778
|
+
/** A message in a room or DM, a human's or an agent's (Phase 27). The room as the embedder shows it. */
|
|
779
|
+
"conversation.message": {
|
|
780
|
+
conversationId: string;
|
|
781
|
+
messageId: string;
|
|
782
|
+
authorId: string;
|
|
783
|
+
origin: "human" | "agent";
|
|
784
|
+
text: string;
|
|
785
|
+
mentions: string[];
|
|
786
|
+
hop: number;
|
|
787
|
+
turnId?: string;
|
|
788
|
+
};
|
|
789
|
+
/**
|
|
790
|
+
* An agent a message addressed did not answer it: the hop ceiling (`limits.maxHops`) was reached,
|
|
791
|
+
* the governor refused the turn, or the turn failed. `detail` is the sentence.
|
|
792
|
+
*/
|
|
793
|
+
"conversation.skipped": {
|
|
794
|
+
conversationId: string;
|
|
795
|
+
messageId: string;
|
|
796
|
+
reason: "hop_limit" | "refused" | "failed";
|
|
797
|
+
detail: string;
|
|
798
|
+
hop: number;
|
|
799
|
+
ceiling: number;
|
|
800
|
+
};
|
|
801
|
+
/**
|
|
802
|
+
* A stand-in wanted to make a mutating call and queued it for its absent owner instead (Phase 28).
|
|
803
|
+
* Nothing ran. `POST /v1/actions/:actionId` is how the owner answers.
|
|
804
|
+
*/
|
|
805
|
+
"action.deferred": {
|
|
806
|
+
actionId: string;
|
|
807
|
+
conversationId: string;
|
|
808
|
+
ownerId: string;
|
|
809
|
+
requestedBy: string;
|
|
810
|
+
slug: string;
|
|
811
|
+
};
|
|
812
|
+
/** The owner answered a queued action: `done` or `failed` once it ran, `denied` if they declined. */
|
|
813
|
+
"action.decided": {
|
|
814
|
+
actionId: string;
|
|
815
|
+
conversationId: string;
|
|
816
|
+
status: "done" | "failed" | "denied";
|
|
817
|
+
};
|
|
818
|
+
/** An admin recorded who an agent works for. */
|
|
819
|
+
"agent.assigned": {
|
|
820
|
+
participantId: string;
|
|
821
|
+
assignedBy?: string;
|
|
822
|
+
};
|
|
823
|
+
/**
|
|
824
|
+
* A turn recalled passages from someone's owner scope for somebody other than that person
|
|
825
|
+
* (Phase 29). The same record lands in the audit the owner can list.
|
|
826
|
+
*/
|
|
827
|
+
"memory.read": {
|
|
828
|
+
scope: string;
|
|
829
|
+
reader: string;
|
|
830
|
+
sources: readonly string[];
|
|
831
|
+
requestedBy?: string;
|
|
832
|
+
onBehalfOf?: string;
|
|
833
|
+
};
|
|
834
|
+
"turn.end": {
|
|
835
|
+
reason: TurnEndReason;
|
|
836
|
+
steps: number;
|
|
837
|
+
tokens: {
|
|
838
|
+
prompt: number;
|
|
839
|
+
output: number;
|
|
840
|
+
};
|
|
841
|
+
durationMs: number;
|
|
842
|
+
/** Files this turn produced for the reply, relative to the agent's directory. */
|
|
843
|
+
attachments?: readonly {
|
|
844
|
+
path: string;
|
|
845
|
+
mimeType: string;
|
|
846
|
+
}[];
|
|
847
|
+
};
|
|
848
|
+
error: ErrorDetail & {
|
|
849
|
+
stack?: string;
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
export type EventType = keyof EventDataMap & string;
|
|
853
|
+
export type AnyEvent = {
|
|
854
|
+
[K in EventType]: EventEnvelope<K, EventDataMap[K]>;
|
|
855
|
+
}[EventType];
|
|
856
|
+
/**
|
|
857
|
+
* One error type, carrying what the wire carries.
|
|
858
|
+
*
|
|
859
|
+
* `04-SPEC-WIRE.md` guarantees every failure arrives as `{ error: { code, message, hint, field? } }`
|
|
860
|
+
* and that `code` is stable and machine-readable — so a client that threw `Error("HTTP 409")` would
|
|
861
|
+
* be discarding the only part a caller can branch on, and the hint, which is the part a person
|
|
862
|
+
* reads. `spec.test.ts` now asserts both ends of that promise: every code the server can return is
|
|
863
|
+
* documented, and every reachable failure carries a non-empty hint.
|
|
864
|
+
*
|
|
865
|
+
* A single class rather than one per code. The codes are data — a new one ships whenever the server
|
|
866
|
+
* grows a refusal — and a subclass per code would mean this package needing a release to let a
|
|
867
|
+
* caller catch something the server already sends. Branch on `code`.
|
|
868
|
+
*/
|
|
869
|
+
/** The shape the server sends. Mirrors `ErrorDetail` in core without importing it. */
|
|
870
|
+
export interface WireError {
|
|
871
|
+
readonly code: string;
|
|
872
|
+
readonly message: string;
|
|
873
|
+
readonly hint?: string;
|
|
874
|
+
/** The manifest path or request field at fault, when the server can name one. */
|
|
875
|
+
readonly field?: string;
|
|
876
|
+
}
|
|
877
|
+
export declare class DispachError extends Error {
|
|
878
|
+
/** Stable and machine-readable. Branch on this, never on `message`. */
|
|
879
|
+
readonly code: string;
|
|
880
|
+
/** What to do about it. Empty only if the server sent none, which `spec.test.ts` forbids. */
|
|
881
|
+
readonly hint: string;
|
|
882
|
+
readonly field: string | undefined;
|
|
883
|
+
/** HTTP status, or `undefined` for a failure that never reached a response. */
|
|
884
|
+
readonly status: number | undefined;
|
|
885
|
+
/** The request that produced it, so a caught error is traceable without a log. */
|
|
886
|
+
readonly request: {
|
|
887
|
+
readonly method: string;
|
|
888
|
+
readonly path: string;
|
|
889
|
+
} | undefined;
|
|
890
|
+
constructor(detail: WireError, context?: {
|
|
891
|
+
readonly status?: number;
|
|
892
|
+
readonly method?: string;
|
|
893
|
+
readonly path?: string;
|
|
894
|
+
readonly cause?: unknown;
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
/** What a replay says about itself, from the `stream.replay` preamble. */
|
|
898
|
+
export interface ReplayReport {
|
|
899
|
+
/** Whether the turn was still running when the buffer was snapshotted. */
|
|
900
|
+
readonly state: "running" | "ended";
|
|
901
|
+
/** How many events the replay carries. */
|
|
902
|
+
readonly events: number;
|
|
903
|
+
/** The buffer discarded its oldest events to stay under its cap. */
|
|
904
|
+
readonly truncated: boolean;
|
|
905
|
+
/** How many were discarded. Zero unless `truncated`. */
|
|
906
|
+
readonly dropped: number;
|
|
907
|
+
/**
|
|
908
|
+
* Whether token history is complete in the replay.
|
|
909
|
+
*
|
|
910
|
+
* `"start"` from the first token, `"partial"` from somewhere in the middle, `"none"` at all.
|
|
911
|
+
* A reattaching client reconstructing text needs this: `"partial"` and `"none"` mean the
|
|
912
|
+
* replay's tokens are not the whole reply even when `truncated` is false, because chunk
|
|
913
|
+
* interest is taken when somebody asks and the turn may have been running before that.
|
|
914
|
+
*/
|
|
915
|
+
readonly chunks: "start" | "partial" | "none";
|
|
916
|
+
}
|
|
917
|
+
export type TurnStreamItem =
|
|
918
|
+
/** The first frame on an inline stream: the same object a non-streaming POST returns. */
|
|
919
|
+
{
|
|
920
|
+
readonly kind: "accepted";
|
|
921
|
+
readonly turnId: string;
|
|
922
|
+
readonly sessionKey: string;
|
|
923
|
+
}
|
|
924
|
+
/** Always before any replayed event, so a hole is known before text is assembled. */
|
|
925
|
+
| {
|
|
926
|
+
readonly kind: "replay";
|
|
927
|
+
readonly report: ReplayReport;
|
|
928
|
+
}
|
|
929
|
+
/** A runtime event, enveloped and typed. */
|
|
930
|
+
| {
|
|
931
|
+
readonly kind: "event";
|
|
932
|
+
readonly event: AnyEvent;
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* The turn finished before you attached and its buffer has been evicted.
|
|
936
|
+
*
|
|
937
|
+
* Not an error: the turn happened and its answer exists. `status` is the stored outcome and
|
|
938
|
+
* the full text is one `GET /v1/agents/:id/turns/:turnId` away.
|
|
939
|
+
*/
|
|
940
|
+
| {
|
|
941
|
+
readonly kind: "ended";
|
|
942
|
+
readonly turnId: string;
|
|
943
|
+
readonly status: string;
|
|
944
|
+
readonly steps: number | undefined;
|
|
945
|
+
readonly errorCode: string | undefined;
|
|
946
|
+
}
|
|
947
|
+
/**
|
|
948
|
+
* Recorded as running, and not observable from the process you asked.
|
|
949
|
+
*
|
|
950
|
+
* One store is shared by every process under a sandbox root, so a served process can hold a
|
|
951
|
+
* `running` row for a turn another process is executing. Distinct from `ended` because
|
|
952
|
+
* treating it as finished would send a reader after a final text that does not exist yet.
|
|
953
|
+
*/
|
|
954
|
+
| {
|
|
955
|
+
readonly kind: "unavailable";
|
|
956
|
+
readonly turnId: string;
|
|
957
|
+
readonly reason: string;
|
|
958
|
+
};
|
|
959
|
+
/** The `stream.subscribed` preamble on the firehose, reporting the filter the server resolved. */
|
|
960
|
+
export interface SubscribedReport {
|
|
961
|
+
readonly agentId: string | null;
|
|
962
|
+
readonly types: readonly string[] | null;
|
|
963
|
+
readonly chunks: boolean;
|
|
964
|
+
/** Present when `chunks` is on because `types` named `model.chunk`. */
|
|
965
|
+
readonly implied: string | undefined;
|
|
966
|
+
}
|
|
967
|
+
export type EventStreamItem = {
|
|
968
|
+
readonly kind: "subscribed";
|
|
969
|
+
readonly report: SubscribedReport;
|
|
970
|
+
} | {
|
|
971
|
+
readonly kind: "event";
|
|
972
|
+
readonly event: AnyEvent;
|
|
973
|
+
};
|
|
974
|
+
export interface ClientOptions {
|
|
975
|
+
/** `http://host:port`, with or without a trailing slash. `/v1` is added by this client. */
|
|
976
|
+
readonly baseUrl: string;
|
|
977
|
+
/**
|
|
978
|
+
* The bearer token. Optional because a loopback server may be configured without one — and
|
|
979
|
+
* omitting it against a server that wants one produces a `401 unauthorized`, which is the
|
|
980
|
+
* correct and legible failure rather than something this client should guess about.
|
|
981
|
+
*/
|
|
982
|
+
readonly token?: string;
|
|
983
|
+
/** Injectable for tests and for a runtime with its own instrumented `fetch`. */
|
|
984
|
+
readonly fetch?: typeof fetch;
|
|
985
|
+
}
|
|
986
|
+
/** What `POST /messages` returns, and the handle for everything you can then do with it. */
|
|
987
|
+
export interface TurnHandle {
|
|
988
|
+
readonly turnId: string;
|
|
989
|
+
readonly sessionKey: string;
|
|
990
|
+
/**
|
|
991
|
+
* This send was an idempotent **replay**: nothing ran, and this is the original turn.
|
|
992
|
+
*
|
|
993
|
+
* `false` on every handle that is not one, including a reattach handle from `agent.turn(id)`,
|
|
994
|
+
* so a caller never has to distinguish absent from false. Worth branching on when the send is
|
|
995
|
+
* the trigger for something else — enqueueing a notification twice because a retry looked like
|
|
996
|
+
* a fresh turn is the failure the key exists to prevent, and it is only avoidable if the caller
|
|
997
|
+
* can see that it happened.
|
|
998
|
+
*/
|
|
999
|
+
readonly replayed: boolean;
|
|
1000
|
+
/**
|
|
1001
|
+
* Every frame, as a discriminated union: the replay report, the events, and whichever of the
|
|
1002
|
+
* three endings applies. The honest view, and the one to use when assembling anything.
|
|
1003
|
+
*/
|
|
1004
|
+
stream(options?: StreamOptions): AsyncGenerator<TurnStreamItem>;
|
|
1005
|
+
/**
|
|
1006
|
+
* The reply's text deltas. Throws `replay_truncated` rather than yielding a fragment whose
|
|
1007
|
+
* front is missing — pass `{ allowTruncated: true }` to accept one knowingly.
|
|
1008
|
+
*/
|
|
1009
|
+
tokens(options?: StreamOptions & {
|
|
1010
|
+
readonly allowTruncated?: boolean;
|
|
1011
|
+
}): AsyncGenerator<string>;
|
|
1012
|
+
/** Wait for the turn to finish and return its stored text. */
|
|
1013
|
+
text(): Promise<string>;
|
|
1014
|
+
/** The stored row, once the turn has finished. */
|
|
1015
|
+
get(): Promise<TurnRecordLike>;
|
|
1016
|
+
/** Cooperative cancel. Partial content is persisted on this path and never on a disconnect. */
|
|
1017
|
+
stop(): Promise<void>;
|
|
1018
|
+
}
|
|
1019
|
+
export interface StreamOptions {
|
|
1020
|
+
/**
|
|
1021
|
+
* Per-token `model.chunk` frames. **Default off, and the reader decides.**
|
|
1022
|
+
*
|
|
1023
|
+
* Not caution: a token event is one envelope and one ISO timestamp per token, and most clients
|
|
1024
|
+
* are watching a turn's progress rather than animating its text. Asking for a stream and
|
|
1025
|
+
* asking for the tokens in it are two requests.
|
|
1026
|
+
*/
|
|
1027
|
+
readonly chunks?: boolean;
|
|
1028
|
+
/** Aborts the HTTP request. **Does not cancel the turn** — `stop()` does. */
|
|
1029
|
+
readonly signal?: AbortSignal;
|
|
1030
|
+
}
|
|
1031
|
+
/** The turn row, kept structural so this package does not re-declare core's store types. */
|
|
1032
|
+
export interface TurnRecordLike {
|
|
1033
|
+
readonly turnId: string;
|
|
1034
|
+
readonly sessionKey: string;
|
|
1035
|
+
readonly status: string;
|
|
1036
|
+
/** What was sent, raw. Always on the wire; declared late, which is why a list needed it. */
|
|
1037
|
+
readonly input: string;
|
|
1038
|
+
readonly text: string;
|
|
1039
|
+
readonly steps: number;
|
|
1040
|
+
/**
|
|
1041
|
+
* The prompt the turn **ended** at, the last step's: a context-size figure, not what the turn
|
|
1042
|
+
* was billed. `usage()` sums every call.
|
|
1043
|
+
*/
|
|
1044
|
+
readonly promptTokens: number;
|
|
1045
|
+
readonly outputTokens: number;
|
|
1046
|
+
readonly errorCode?: string;
|
|
1047
|
+
/** Who sent the input. Absent means the token-holder — not "unknown". */
|
|
1048
|
+
readonly sender?: string;
|
|
1049
|
+
readonly senderName?: string;
|
|
1050
|
+
readonly senderKind?: "user" | "agent";
|
|
1051
|
+
}
|
|
1052
|
+
export interface SendOptions {
|
|
1053
|
+
readonly sessionKey?: string;
|
|
1054
|
+
/** `"none"`, a channel id, or `{ channel, to }`. See the spec — a bare id needs a recipient. */
|
|
1055
|
+
readonly deliver?: string | {
|
|
1056
|
+
readonly channel: string;
|
|
1057
|
+
readonly to: string;
|
|
1058
|
+
};
|
|
1059
|
+
/**
|
|
1060
|
+
* Who sent this, when it was not you.
|
|
1061
|
+
*
|
|
1062
|
+
* `kind: "agent"` is a declaration with teeth: the server fences the text as data and blocks
|
|
1063
|
+
* mutating tools for the whole turn. There is no separate `trust` field here for the same
|
|
1064
|
+
* reason there is none on the wire — the pair could then disagree, and the dangerous half is
|
|
1065
|
+
* the one that would win quietly.
|
|
1066
|
+
*/
|
|
1067
|
+
readonly from?: TurnSender;
|
|
1068
|
+
/**
|
|
1069
|
+
* Makes this send safe to retry.
|
|
1070
|
+
*
|
|
1071
|
+
* Sent as the `Idempotency-Key` header. A second send with the same key and the same text
|
|
1072
|
+
* returns the **first** turn's handle with `replayed` set, having run nothing; the same key
|
|
1073
|
+
* with different text is a `DispachError` (`idempotency_key_reused`) rather than a silent
|
|
1074
|
+
* replay of a message you did not send. Remembered by the server for 24 hours.
|
|
1075
|
+
*/
|
|
1076
|
+
readonly idempotencyKey?: string;
|
|
1077
|
+
readonly signal?: AbortSignal;
|
|
1078
|
+
}
|
|
1079
|
+
export interface AgentClient {
|
|
1080
|
+
readonly id: string;
|
|
1081
|
+
/** Start a turn. Returns once accepted; the turn runs detached. */
|
|
1082
|
+
send(text: string, options?: SendOptions): Promise<TurnHandle>;
|
|
1083
|
+
/** A handle for a turn id you already hold — the reattach path. */
|
|
1084
|
+
turn(turnId: string): TurnHandle;
|
|
1085
|
+
describe(): Promise<AgentDescriptionLike>;
|
|
1086
|
+
tools(): Promise<readonly ToolSummary[]>;
|
|
1087
|
+
skills(): Promise<SkillsReport>;
|
|
1088
|
+
sessions(): Promise<readonly SessionSummary[]>;
|
|
1089
|
+
/**
|
|
1090
|
+
* A page of one conversation, newest first.
|
|
1091
|
+
*
|
|
1092
|
+
* Needed by anything that *resumes* rather than watches: an attached terminal or a browser tab
|
|
1093
|
+
* opening onto a conversation has to paint what is already there, and the event stream only
|
|
1094
|
+
* carries what happens next. Without this a resumed session shows a blank screen above a live
|
|
1095
|
+
* prompt, which is the failure `seedHistory` was written for on the embedded path.
|
|
1096
|
+
*/
|
|
1097
|
+
messages(sessionKey: string, options?: MessagesOptions): Promise<MessagePageLike>;
|
|
1098
|
+
/**
|
|
1099
|
+
* Clear a conversation's history. Memory files on disk are untouched, and the server says so.
|
|
1100
|
+
*
|
|
1101
|
+
* Deliberately not called `delete`: the session key keeps working and the next message starts
|
|
1102
|
+
* it again, so this empties rather than removes. A name implying removal would invite a caller
|
|
1103
|
+
* to treat a cleared key as unusable.
|
|
1104
|
+
*/
|
|
1105
|
+
clearSession(sessionKey: string): Promise<{
|
|
1106
|
+
readonly memoryFilesKept: boolean;
|
|
1107
|
+
}>;
|
|
1108
|
+
/**
|
|
1109
|
+
* Re-read the manifest by **replacing** the agent — a new instance, not a mutated one.
|
|
1110
|
+
*
|
|
1111
|
+
* `adopted` lists everything that came back, which is more than one agent when the target is a
|
|
1112
|
+
* supervisor: a team loads from one manifest as one unit. While a turn is running the reload is
|
|
1113
|
+
* `pending` (202): the running turns finish on the old settings and the swap follows, announced
|
|
1114
|
+
* by `agent.reloaded`; `adopted` is then empty.
|
|
1115
|
+
*/
|
|
1116
|
+
reload(): Promise<{
|
|
1117
|
+
readonly id: string;
|
|
1118
|
+
readonly adopted: readonly string[];
|
|
1119
|
+
readonly status?: "loaded" | "pending";
|
|
1120
|
+
readonly running?: number;
|
|
1121
|
+
readonly holdAfterMs?: number;
|
|
1122
|
+
}>;
|
|
1123
|
+
/** What this agent cost, from the per-call meter. */
|
|
1124
|
+
usage(options?: UsageOptions): Promise<UsageReportLike & {
|
|
1125
|
+
readonly id: string;
|
|
1126
|
+
}>;
|
|
1127
|
+
/**
|
|
1128
|
+
* Every turn this agent has taken, newest first, across sessions. Pass the previous page's
|
|
1129
|
+
* `nextBefore` as `before`.
|
|
1130
|
+
*/
|
|
1131
|
+
turns(options?: {
|
|
1132
|
+
readonly limit?: number;
|
|
1133
|
+
readonly before?: number;
|
|
1134
|
+
}): Promise<{
|
|
1135
|
+
readonly turns: readonly TurnRecordLike[];
|
|
1136
|
+
readonly nextBefore?: number;
|
|
1137
|
+
}>;
|
|
1138
|
+
/** The variables this agent's manifest reads, and whether each is set. Never a value. */
|
|
1139
|
+
secrets(): Promise<readonly SecretStatusLike[]>;
|
|
1140
|
+
/**
|
|
1141
|
+
* Write credentials into the agent's `.env` and apply them: reloaded if hosted, adopted if it was
|
|
1142
|
+
* not running. Only names the manifest reads are accepted, all or nothing.
|
|
1143
|
+
*/
|
|
1144
|
+
setSecrets(values: Readonly<Record<string, string>>): Promise<SecretsWrittenLike>;
|
|
1145
|
+
schedules(): Promise<readonly ScheduleRecord[]>;
|
|
1146
|
+
/**
|
|
1147
|
+
* Arm a schedule. The server validates the expression and the delivery target.
|
|
1148
|
+
*
|
|
1149
|
+
* Deliberately untyped beyond `Record`: the accepted shape is `prepareScheduleWrite`'s, in
|
|
1150
|
+
* core, and a second declaration of it here is a second definition of what a valid schedule is
|
|
1151
|
+
* — right when written and wrong at the next field.
|
|
1152
|
+
*/
|
|
1153
|
+
createSchedule(schedule: Readonly<Record<string, unknown>>): Promise<ScheduleRecord>;
|
|
1154
|
+
updateSchedule(scheduleId: string, patch: Readonly<Record<string, unknown>>): Promise<ScheduleRecord>;
|
|
1155
|
+
deleteSchedule(scheduleId: string): Promise<void>;
|
|
1156
|
+
/** Fire one now, out of band. Does **not** move its next scheduled run. */
|
|
1157
|
+
runSchedule(scheduleId: string): Promise<{
|
|
1158
|
+
readonly scheduleId: string;
|
|
1159
|
+
readonly turnId: string;
|
|
1160
|
+
readonly sessionKey: string;
|
|
1161
|
+
}>;
|
|
1162
|
+
/**
|
|
1163
|
+
* Every manifest field a person may set here, what it does, and its current value.
|
|
1164
|
+
*
|
|
1165
|
+
* The values are the manifest's **source** text, unexpanded — `${MODEL_ID}` comes back as
|
|
1166
|
+
* `${MODEL_ID}`. A caller that showed the loaded value and wrote it back would bake the
|
|
1167
|
+
* expansion in, turning a manifest that follows its environment into one that does not.
|
|
1168
|
+
*/
|
|
1169
|
+
config(): Promise<AgentConfig>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Set one field, then let the server replace the agent so it takes effect.
|
|
1172
|
+
*
|
|
1173
|
+
* `value` is **text**, exactly as it is typed at a terminal, and core's `parseSettingValue`
|
|
1174
|
+
* reads it — a list is `["a", "b"]`, a map is `{k: v}`, a number is `40`. Not a JSON value,
|
|
1175
|
+
* deliberately: one parser serves both of the person's editors, and two would eventually
|
|
1176
|
+
* disagree about whether `["a", "b"]` is a list of two strings.
|
|
1177
|
+
*
|
|
1178
|
+
* Read `applied` rather than assuming it. The file is written before the agent is replaced and
|
|
1179
|
+
* `dispose` refuses while a turn is in flight, so a successful write can legitimately arrive
|
|
1180
|
+
* with `applied: false` and the reason under `pending` — the edit then takes effect at the next
|
|
1181
|
+
* start. Two fields need `confirm: true`; `config()` says which by carrying a `confirm`
|
|
1182
|
+
* sentence on the row.
|
|
1183
|
+
*/
|
|
1184
|
+
setConfig(path: string, value: string, options?: {
|
|
1185
|
+
readonly confirm?: boolean;
|
|
1186
|
+
}): Promise<ConfigWriteResult>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Connect or disconnect a channel, and set its credential.
|
|
1189
|
+
*
|
|
1190
|
+
* One call for three things, because they are one decision — is this channel working — and a
|
|
1191
|
+
* client holding three call sites for one panel is how two of them come to disagree. The
|
|
1192
|
+
* credential is **write-only**: nothing reads one back, which is why there is no getter for it
|
|
1193
|
+
* and why `channels[]` on the agent resource reports only whether it is set.
|
|
1194
|
+
*/
|
|
1195
|
+
setChannel(channelId: string, changes: {
|
|
1196
|
+
readonly enabled?: boolean;
|
|
1197
|
+
readonly credential?: string;
|
|
1198
|
+
}): Promise<ChannelWriteResult>;
|
|
1199
|
+
/** Forget a channel's stored pairing, so the next start offers a new code to scan. */
|
|
1200
|
+
unpairChannel(channelId: string): Promise<{
|
|
1201
|
+
readonly channelId: string;
|
|
1202
|
+
readonly note: string;
|
|
1203
|
+
}>;
|
|
1204
|
+
/** One conversation's summary. `sessions()` is the listing. */
|
|
1205
|
+
session(sessionKey: string): Promise<SessionSummary>;
|
|
1206
|
+
/** Move a conversation into a phase the manifest declares. */
|
|
1207
|
+
setPhase(sessionKey: string, phase: string): Promise<{
|
|
1208
|
+
readonly sessionKey: string;
|
|
1209
|
+
readonly phase: string;
|
|
1210
|
+
}>;
|
|
1211
|
+
context(options?: {
|
|
1212
|
+
readonly sessionKey?: string;
|
|
1213
|
+
readonly input?: string;
|
|
1214
|
+
}): Promise<unknown>;
|
|
1215
|
+
/**
|
|
1216
|
+
* What is waiting on a person right now, oldest first.
|
|
1217
|
+
*
|
|
1218
|
+
* The recovery path. `approval.requested` on the stream is how a live client learns about a
|
|
1219
|
+
* question; this is how one that missed it — opened late, refreshed, a second operator —
|
|
1220
|
+
* discovers why a turn has visibly stopped. A UI that only listens will lose prompts to a page
|
|
1221
|
+
* reload, which is the same failure turn reattach exists to prevent.
|
|
1222
|
+
*/
|
|
1223
|
+
approvals(): Promise<readonly PendingApproval[]>;
|
|
1224
|
+
/**
|
|
1225
|
+
* Answer one. Throws `approval_not_found` when it is no longer waiting.
|
|
1226
|
+
*
|
|
1227
|
+
* That covers answered-already and abandoned-with-its-turn alike, deliberately: nothing about a
|
|
1228
|
+
* settled approval is kept, so there is no state to tell them apart with. Watch
|
|
1229
|
+
* `approval.resolved` for `by: "abandoned"` if you need to take a prompt down for the right
|
|
1230
|
+
* reason.
|
|
1231
|
+
*/
|
|
1232
|
+
approve(approvalId: string, granted: boolean): Promise<void>;
|
|
1233
|
+
/**
|
|
1234
|
+
* Switch this agent off — durably, and out of the host now.
|
|
1235
|
+
*
|
|
1236
|
+
* Two effects in one call and both are needed: the store row survives a restart, and the host
|
|
1237
|
+
* drops the agent immediately. It is not a signal — since one process hosts several agents,
|
|
1238
|
+
* signalling the process would take the others with it.
|
|
1239
|
+
*
|
|
1240
|
+
* Throws `agent_turn_in_flight` (409) while a turn is running. The row is written first either
|
|
1241
|
+
* way, so the agent is off at the next start even when the teardown is refused.
|
|
1242
|
+
*/
|
|
1243
|
+
stop(reason?: string): Promise<AgentLifecycleState>;
|
|
1244
|
+
/**
|
|
1245
|
+
* Switch it back on, and have the host adopt it now.
|
|
1246
|
+
*
|
|
1247
|
+
* Throws `start_not_supported` (501) on a server with no way to look up a manifest for an agent
|
|
1248
|
+
* it is not hosting — an embedder over its own agent store, or the container image, which
|
|
1249
|
+
* passes none on purpose.
|
|
1250
|
+
*/
|
|
1251
|
+
start(): Promise<AgentLifecycleState>;
|
|
1252
|
+
/** Record which member this agent works for. An admin participant's act (Phase 27). */
|
|
1253
|
+
assign(participantId: string): Promise<AssignmentLike>;
|
|
1254
|
+
unassign(): Promise<{
|
|
1255
|
+
readonly id: string;
|
|
1256
|
+
readonly unassigned: boolean;
|
|
1257
|
+
}>;
|
|
1258
|
+
/** A slice of this agent — its carried memory, archive and knowledge — as a bundle (R11). */
|
|
1259
|
+
exportBundle(paths?: readonly ("MEMORY.md" | "memory/" | "knowledge/")[]): Promise<AgentBundleLike>;
|
|
1260
|
+
/** Merge a bundle into this agent. Memory note by note; knowledge kept (`skip`) or `overwrite`n. */
|
|
1261
|
+
importBundle(bundle: AgentBundleLike, mode?: "skip" | "overwrite"): Promise<ImportReportLike>;
|
|
1262
|
+
}
|
|
1263
|
+
/** What `stop` and `start` report back. */
|
|
1264
|
+
export interface AgentLifecycleState {
|
|
1265
|
+
readonly id: string;
|
|
1266
|
+
readonly status: "loaded" | "disabled";
|
|
1267
|
+
/**
|
|
1268
|
+
* When it was last switched off, and why — **kept through a later start**, as the record of
|
|
1269
|
+
* what happened. So a started agent legitimately carries both, and a reader has to look at
|
|
1270
|
+
* `status` rather than at their presence.
|
|
1271
|
+
*/
|
|
1272
|
+
readonly disabledAt?: string;
|
|
1273
|
+
readonly reason?: string;
|
|
1274
|
+
/** Which agents the host took on. A supervisor brings its team, so this can be several. */
|
|
1275
|
+
readonly adopted?: readonly string[];
|
|
1276
|
+
}
|
|
1277
|
+
/** A question waiting on somebody. */
|
|
1278
|
+
export interface PendingApproval {
|
|
1279
|
+
readonly approvalId: string;
|
|
1280
|
+
/** Which agent is asking. Always the agent in the path — a listing never crosses agents. */
|
|
1281
|
+
readonly agentId: string;
|
|
1282
|
+
readonly slug: string;
|
|
1283
|
+
readonly callId: string;
|
|
1284
|
+
/** The command or path a rule would match — what the person actually needs to read. */
|
|
1285
|
+
readonly match?: string;
|
|
1286
|
+
readonly mutating: boolean;
|
|
1287
|
+
readonly reason: string;
|
|
1288
|
+
readonly requestedAt: string;
|
|
1289
|
+
}
|
|
1290
|
+
/**
|
|
1291
|
+
* An agent in the listing, or at the head of its own resource.
|
|
1292
|
+
*
|
|
1293
|
+
* **Most fields are optional because a stopped agent is listed too.** `GET /v1/agents` carries a
|
|
1294
|
+
* thin `{ id, name, status: "disabled", reason? }` row for one — it is not loaded, so there is no
|
|
1295
|
+
* manifest in memory to report a model or a window from, and loading one to fill the row in would
|
|
1296
|
+
* make a listing depend on the agent's credentials being present, which is the defect
|
|
1297
|
+
* `readManifestHeader` exists to avoid. Read `status` first: `"disabled"` means the rest is absent
|
|
1298
|
+
* by design rather than missing by accident.
|
|
1299
|
+
*/
|
|
1300
|
+
export interface AgentDescriptionLike {
|
|
1301
|
+
readonly id: string;
|
|
1302
|
+
readonly name: string;
|
|
1303
|
+
readonly status: string;
|
|
1304
|
+
readonly model?: string;
|
|
1305
|
+
readonly dialect?: string;
|
|
1306
|
+
readonly window?: number;
|
|
1307
|
+
readonly tools?: number;
|
|
1308
|
+
/** What the catalogue costs per turn. A tool *count* says nothing about the bill. */
|
|
1309
|
+
readonly catalogueTokens?: number;
|
|
1310
|
+
readonly skills?: number;
|
|
1311
|
+
readonly schedules?: number;
|
|
1312
|
+
readonly entryPhase?: string | null;
|
|
1313
|
+
readonly phases?: readonly string[];
|
|
1314
|
+
/**
|
|
1315
|
+
* Each channel's last reported state. `unknown[]` until 16.6, which is why the web UI cast.
|
|
1316
|
+
*
|
|
1317
|
+
* `status` is deliberately a plain `string` and not `ChannelStatus`: the set can grow inside
|
|
1318
|
+
* `v: 1`, and a closed union here would make a server one member ahead of this package a type
|
|
1319
|
+
* error rather than a state a client renders generically. `input` is present only with
|
|
1320
|
+
* `needs_input` and its `kind` is `string` for the same reason.
|
|
1321
|
+
*/
|
|
1322
|
+
readonly channels?: readonly {
|
|
1323
|
+
readonly id: string;
|
|
1324
|
+
readonly type: string;
|
|
1325
|
+
readonly status: string;
|
|
1326
|
+
readonly detail?: string;
|
|
1327
|
+
readonly input?: {
|
|
1328
|
+
readonly kind: string;
|
|
1329
|
+
readonly payload: string;
|
|
1330
|
+
readonly issuedAt: string;
|
|
1331
|
+
readonly expiresAt?: string;
|
|
1332
|
+
};
|
|
1333
|
+
}[];
|
|
1334
|
+
readonly warnings?: readonly WireError[];
|
|
1335
|
+
/** Set on a `disabled` row: when it was switched off, and why if anybody said. */
|
|
1336
|
+
readonly disabledAt?: string;
|
|
1337
|
+
readonly reason?: string;
|
|
1338
|
+
}
|
|
1339
|
+
export interface ToolSummary {
|
|
1340
|
+
readonly slug: string;
|
|
1341
|
+
readonly summary: string;
|
|
1342
|
+
readonly mutating: boolean;
|
|
1343
|
+
readonly trust: string;
|
|
1344
|
+
/** Why a tool declares itself trusted when a provider tool defaults to untrusted. */
|
|
1345
|
+
readonly trustReason?: string;
|
|
1346
|
+
readonly provider: string;
|
|
1347
|
+
readonly tags: readonly string[];
|
|
1348
|
+
/** Absent on an unphased agent — which is not the same as "visible in no phase". */
|
|
1349
|
+
readonly phases?: readonly string[];
|
|
1350
|
+
}
|
|
1351
|
+
/** One editable manifest field, as `GET /v1/agents/:id/config` reports it. */
|
|
1352
|
+
export interface ConfigSetting {
|
|
1353
|
+
/** Dotted, exactly as it appears in the file. */
|
|
1354
|
+
readonly path: string;
|
|
1355
|
+
/** What it does, addressed to a person reading a list. */
|
|
1356
|
+
readonly means: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* Why a person is asked to confirm, when they are.
|
|
1359
|
+
*
|
|
1360
|
+
* Present on exactly two fields — the ones whose only purpose is to stop a check running. A
|
|
1361
|
+
* client must show this sentence and send `confirm: true` only after somebody has read it.
|
|
1362
|
+
*/
|
|
1363
|
+
readonly confirm?: string;
|
|
1364
|
+
/**
|
|
1365
|
+
* The current value, unexpanded. **Absent when the file does not set the field**, which is not
|
|
1366
|
+
* the same as set to nothing — it is what lets a control distinguish "unset" from "empty".
|
|
1367
|
+
*/
|
|
1368
|
+
readonly value?: unknown;
|
|
1369
|
+
}
|
|
1370
|
+
export interface AgentConfig {
|
|
1371
|
+
/**
|
|
1372
|
+
* `false` for an agent loaded from an object rather than a file.
|
|
1373
|
+
*
|
|
1374
|
+
* Named rather than implied by an empty list: an embedder's programmatic manifest has no file
|
|
1375
|
+
* behind it, and a client that could not tell would offer a form whose save can only fail.
|
|
1376
|
+
*/
|
|
1377
|
+
readonly editable: boolean;
|
|
1378
|
+
/** Absolute path of the manifest, when there is one. */
|
|
1379
|
+
readonly file?: string;
|
|
1380
|
+
readonly settings: readonly ConfigSetting[];
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* What a channel write reports.
|
|
1384
|
+
*
|
|
1385
|
+
* `notes` is a list because one request may do two things — set the credential and connect it — and
|
|
1386
|
+
* collapsing them into one sentence would lose whichever half somebody is checking. `applied`
|
|
1387
|
+
* separates the *write* from the agent picking it up: the manifest is written before the agent is
|
|
1388
|
+
* replaced, and `dispose` refuses while a turn is in flight, so `applied: false` with a reason is a
|
|
1389
|
+
* real and correct outcome rather than a failure.
|
|
1390
|
+
*/
|
|
1391
|
+
export interface ChannelWriteResult {
|
|
1392
|
+
readonly channelId: string;
|
|
1393
|
+
readonly notes: readonly string[];
|
|
1394
|
+
readonly applied: boolean;
|
|
1395
|
+
readonly pending?: WireError;
|
|
1396
|
+
}
|
|
1397
|
+
export interface ConfigWriteResult {
|
|
1398
|
+
readonly path: string;
|
|
1399
|
+
/** What was there. `undefined` when the field was not set. */
|
|
1400
|
+
readonly before: unknown;
|
|
1401
|
+
readonly after: unknown;
|
|
1402
|
+
/**
|
|
1403
|
+
* The source editor could not place the path, so the file was re-serialised.
|
|
1404
|
+
*
|
|
1405
|
+
* Worth surfacing rather than swallowing: a reflowed manifest is correct and its comments have
|
|
1406
|
+
* moved, which a person should hear from the thing that did it rather than from `git diff`.
|
|
1407
|
+
*/
|
|
1408
|
+
readonly reflowed: boolean;
|
|
1409
|
+
/** Whether the running agent was replaced, so the change is in force now. */
|
|
1410
|
+
readonly applied: boolean;
|
|
1411
|
+
/** Why it is not, when `applied` is false. The write already happened either way. */
|
|
1412
|
+
readonly pending?: {
|
|
1413
|
+
readonly code: string;
|
|
1414
|
+
readonly message: string;
|
|
1415
|
+
readonly hint: string;
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
export interface SkillsReport {
|
|
1419
|
+
/** `false` when the agent declares no `skills:` block at all. */
|
|
1420
|
+
readonly configured: boolean;
|
|
1421
|
+
readonly maxActive?: number;
|
|
1422
|
+
readonly threshold?: number;
|
|
1423
|
+
readonly cached?: boolean;
|
|
1424
|
+
readonly skills: readonly {
|
|
1425
|
+
readonly name: string;
|
|
1426
|
+
readonly description: string;
|
|
1427
|
+
readonly tokens: number;
|
|
1428
|
+
readonly whenNotToUse?: string;
|
|
1429
|
+
readonly scripts: readonly string[];
|
|
1430
|
+
}[];
|
|
1431
|
+
}
|
|
1432
|
+
/**
|
|
1433
|
+
* One stored message, as a page returns it.
|
|
11
1434
|
*
|
|
12
|
-
*
|
|
1435
|
+
* `origin` is what a resuming client filters on and the field most easily got wrong: it is set
|
|
1436
|
+
* only when the *harness* wrote the row (`observation`, `call`, `repair`, `digest`), and absent for
|
|
1437
|
+
* a person's message and the model's prose. So a transcript is built from an **allowlist of
|
|
1438
|
+
* absent-or-prose**, never a blocklist — `lib/resume.ts` in the CLI owns that rule for the same
|
|
1439
|
+
* reason `endNote` is shared: it has been written wrong twice.
|
|
1440
|
+
*/
|
|
1441
|
+
export interface StoredMessageLike {
|
|
1442
|
+
/** Monotonic within a store, and the ordering key. Never sort by timestamp, which can tie. */
|
|
1443
|
+
readonly id: number;
|
|
1444
|
+
readonly role: string;
|
|
1445
|
+
readonly content: string;
|
|
1446
|
+
readonly turnId?: string;
|
|
1447
|
+
readonly origin?: string;
|
|
1448
|
+
readonly createdAt?: string;
|
|
1449
|
+
}
|
|
1450
|
+
export interface MessagePageLike {
|
|
1451
|
+
readonly messages: readonly StoredMessageLike[];
|
|
1452
|
+
/** Feed back as `before` for the previous page. Absent once the first message is included. */
|
|
1453
|
+
readonly nextBefore?: number;
|
|
1454
|
+
}
|
|
1455
|
+
/**
|
|
1456
|
+
* One conversation, as `GET /v1/agents/:id/sessions` returns it.
|
|
1457
|
+
*
|
|
1458
|
+
* This declared four fields while the route sent the store's whole `SessionSummary` — `messages`
|
|
1459
|
+
* and `phase` among them. Under-declaring is not harmless: a session picker cannot show how long a
|
|
1460
|
+
* conversation is, and the field is *there*, so the only way to find out is to read the server. The
|
|
1461
|
+
* same shape as `channels` being `readonly unknown[]` until 16.6.
|
|
1462
|
+
*/
|
|
1463
|
+
export interface SessionSummary {
|
|
1464
|
+
readonly sessionKey: string;
|
|
1465
|
+
readonly channel: string;
|
|
1466
|
+
readonly peerId: string;
|
|
1467
|
+
readonly turns: number;
|
|
1468
|
+
readonly messages: number;
|
|
1469
|
+
readonly lastActivityAt: string;
|
|
1470
|
+
readonly createdAt: string;
|
|
1471
|
+
readonly updatedAt: string;
|
|
1472
|
+
readonly thread?: string;
|
|
1473
|
+
/** Phase-scoped tool visibility, persisted per session. Absent on an unphased agent. */
|
|
1474
|
+
readonly phase?: string;
|
|
1475
|
+
}
|
|
1476
|
+
export interface MessagesOptions {
|
|
1477
|
+
/** The cursor from a previous page's `nextBefore`. Absent starts at the newest. */
|
|
1478
|
+
readonly before?: number;
|
|
1479
|
+
readonly limit?: number;
|
|
1480
|
+
}
|
|
1481
|
+
export interface EventStreamOptions {
|
|
1482
|
+
readonly agentId?: string;
|
|
1483
|
+
/**
|
|
1484
|
+
* Event types to receive. An unknown type is **refused** with `unknown_event_type` naming the
|
|
1485
|
+
* nearest real one, rather than opening a stream that matches nothing — so a typo here is an
|
|
1486
|
+
* error at the call rather than a silence forever.
|
|
1487
|
+
*
|
|
1488
|
+
* Naming `model.chunk` turns `chunks` on by itself; the `subscribed` report says so.
|
|
1489
|
+
*/
|
|
1490
|
+
readonly types?: readonly EventType[];
|
|
1491
|
+
readonly chunks?: boolean;
|
|
1492
|
+
readonly signal?: AbortSignal;
|
|
1493
|
+
}
|
|
1494
|
+
/**
|
|
1495
|
+
* One provisioning question, as `GET /v1/provision` serves it.
|
|
13
1496
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1497
|
+
* Structural rather than imported from `@dispach/server`: the client talks to a wire, and a type
|
|
1498
|
+
* dependency on the server package would make a browser bundle pull Zod in for a form.
|
|
1499
|
+
*/
|
|
1500
|
+
export interface ProvisionStepLike {
|
|
1501
|
+
readonly step: string;
|
|
1502
|
+
readonly prompt: string;
|
|
1503
|
+
/** The default, already a value that may be sent back — never a menu index. */
|
|
1504
|
+
readonly fallback: string;
|
|
1505
|
+
readonly optional: boolean;
|
|
1506
|
+
/** Mask it. Written once into the agent's `.env` at `0600`; no route reads it back. */
|
|
1507
|
+
readonly secret: boolean;
|
|
1508
|
+
/**
|
|
1509
|
+
* What opens this step, absent when it is always asked.
|
|
1510
|
+
*
|
|
1511
|
+
* Evaluate **transitively**: askable when the requirement is met *and* the step it names is
|
|
1512
|
+
* itself askable. `lib/provision-form.ts` in `@dispach/web` is the reference implementation.
|
|
1513
|
+
*/
|
|
1514
|
+
readonly requires?: {
|
|
1515
|
+
readonly step: string;
|
|
1516
|
+
readonly value: string;
|
|
1517
|
+
};
|
|
1518
|
+
readonly choices?: readonly {
|
|
1519
|
+
readonly value: string;
|
|
1520
|
+
readonly label: string;
|
|
1521
|
+
readonly hint?: string;
|
|
1522
|
+
}[];
|
|
1523
|
+
}
|
|
1524
|
+
/** What this server will ask, and whether it can create an agent at all. */
|
|
1525
|
+
export interface ProvisionOfferLike {
|
|
1526
|
+
/** A provisioner was injected. `false` means `POST /v1/agents` answers `501`. */
|
|
1527
|
+
readonly available: boolean;
|
|
1528
|
+
/** This handler is on a loopback bind. A fact about the server, not about you. */
|
|
1529
|
+
readonly local: boolean;
|
|
1530
|
+
/**
|
|
1531
|
+
* May *this caller* provision, which is the field to branch on.
|
|
1532
|
+
*
|
|
1533
|
+
* `local` describes the bind; this describes the request. They differ on exactly the
|
|
1534
|
+
* deployment that ships the onboarding page — an authenticated container — where branching on
|
|
1535
|
+
* `local` told an admin they were not allowed to do what they were allowed to do.
|
|
1536
|
+
*/
|
|
1537
|
+
readonly allowed: boolean;
|
|
1538
|
+
readonly steps: readonly ProvisionStepLike[];
|
|
1539
|
+
}
|
|
1540
|
+
/**
|
|
1541
|
+
* What `POST /v1/agents` answers, `201` either way.
|
|
1542
|
+
*
|
|
1543
|
+
* `adopted` is the part worth reading: the agent is on disk whichever way this went, so a failed
|
|
1544
|
+
* adoption is not a failed creation — telling somebody their request failed while a complete agent
|
|
1545
|
+
* sits in the sandbox would send them to create a second one. An empty `adopted` with an `error` is
|
|
1546
|
+
* "it exists and is not running", which is a different sentence and needs a different one shown.
|
|
1547
|
+
*/
|
|
1548
|
+
export interface ProvisionedAgentLike {
|
|
1549
|
+
readonly id: string;
|
|
1550
|
+
readonly dir: string;
|
|
1551
|
+
/** Relative paths written, so a caller can report what it made without re-reading the disk. */
|
|
1552
|
+
readonly files: readonly string[];
|
|
1553
|
+
readonly adopted: readonly string[];
|
|
1554
|
+
readonly error?: WireError;
|
|
1555
|
+
}
|
|
1556
|
+
/** One template, as `GET /v1/templates` lists it. A broken one carries `problem` and no variables. */
|
|
1557
|
+
export interface TemplateLike {
|
|
1558
|
+
readonly name: string;
|
|
1559
|
+
readonly description?: string;
|
|
1560
|
+
readonly vars: readonly {
|
|
1561
|
+
readonly name: string;
|
|
1562
|
+
readonly description?: string;
|
|
1563
|
+
readonly required: boolean;
|
|
1564
|
+
readonly default?: string;
|
|
1565
|
+
/** Written to the agent's `.env`, never into a file, and never returned by any route. */
|
|
1566
|
+
readonly secret: boolean;
|
|
1567
|
+
}[];
|
|
1568
|
+
readonly problem?: WireError;
|
|
1569
|
+
}
|
|
1570
|
+
/** One variable an agent's manifest reads. Whether it is set, never what it is. */
|
|
1571
|
+
export interface SecretStatusLike {
|
|
1572
|
+
readonly name: string;
|
|
1573
|
+
readonly set: boolean;
|
|
1574
|
+
/** The manifest fields that read it. */
|
|
1575
|
+
readonly usedBy: readonly string[];
|
|
1576
|
+
}
|
|
1577
|
+
/**
|
|
1578
|
+
* What `PUT /v1/agents/:id/secrets` answers, `200` whenever the values were written.
|
|
19
1579
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
1580
|
+
* `applied` is the part to read: `reloaded` for a hosted agent, `adopted` for one that was not
|
|
1581
|
+
* running (usually because this key was the thing missing), `none` for a stopped agent or when
|
|
1582
|
+
* applying failed, in which case `error` says why. `shadowed` names values written and overridden
|
|
1583
|
+
* by the server's own environment, which wins by design.
|
|
23
1584
|
*/
|
|
24
|
-
export
|
|
25
|
-
|
|
1585
|
+
export interface SecretsWrittenLike {
|
|
1586
|
+
readonly id: string;
|
|
1587
|
+
readonly written: readonly string[];
|
|
1588
|
+
readonly shadowed: readonly string[];
|
|
1589
|
+
readonly applied: "reloaded" | "adopted" | "none";
|
|
1590
|
+
readonly adopted: readonly string[];
|
|
1591
|
+
readonly stopped?: boolean;
|
|
1592
|
+
readonly error?: WireError;
|
|
1593
|
+
}
|
|
1594
|
+
/** What a delivery queue still owes. `nextAttemptAt` may be in the past: due now. */
|
|
1595
|
+
export interface DeliveryBacklogLike {
|
|
1596
|
+
readonly pending: number;
|
|
1597
|
+
readonly inflight: number;
|
|
1598
|
+
readonly nextAttemptAt?: string;
|
|
1599
|
+
}
|
|
1600
|
+
/** `GET /v1/activity`: whether the process may be suspended, and when to wake it. */
|
|
1601
|
+
export interface ActivityLike {
|
|
1602
|
+
readonly idle: boolean;
|
|
1603
|
+
readonly turnsRunning: number;
|
|
1604
|
+
readonly deliveries: {
|
|
1605
|
+
readonly outbox: DeliveryBacklogLike;
|
|
1606
|
+
readonly webhooks: DeliveryBacklogLike;
|
|
1607
|
+
};
|
|
1608
|
+
readonly nextWakeAt?: string;
|
|
1609
|
+
}
|
|
1610
|
+
/** A human the embedder registered (Phase 27). Agents are participants too, as `agent:<id>`. */
|
|
1611
|
+
export interface ParticipantLike {
|
|
1612
|
+
readonly id: string;
|
|
1613
|
+
readonly kind: "human";
|
|
1614
|
+
readonly name?: string;
|
|
1615
|
+
readonly role: "admin" | "member";
|
|
1616
|
+
readonly createdAt: string;
|
|
1617
|
+
/** Pushed by the embedder; absent reads as online. */
|
|
1618
|
+
readonly presence?: "online" | "offline";
|
|
1619
|
+
readonly presenceAt?: string;
|
|
1620
|
+
}
|
|
1621
|
+
/** A slice of one agent: the carried memory file, the memory archive and knowledge (R11). */
|
|
1622
|
+
export interface AgentBundleLike {
|
|
1623
|
+
readonly version: 1;
|
|
1624
|
+
readonly agentId: string;
|
|
1625
|
+
readonly exportedAt: string;
|
|
1626
|
+
readonly files: readonly {
|
|
1627
|
+
readonly path: string;
|
|
1628
|
+
readonly content: string;
|
|
1629
|
+
}[];
|
|
1630
|
+
}
|
|
1631
|
+
export interface ImportReportLike {
|
|
1632
|
+
readonly id: string;
|
|
1633
|
+
readonly added: readonly string[];
|
|
1634
|
+
readonly merged: readonly {
|
|
1635
|
+
readonly path: string;
|
|
1636
|
+
readonly notes: number;
|
|
1637
|
+
}[];
|
|
1638
|
+
readonly skipped: readonly string[];
|
|
1639
|
+
readonly overwritten: readonly string[];
|
|
1640
|
+
readonly evicted: number;
|
|
1641
|
+
readonly reload: "none" | "loaded" | "pending";
|
|
1642
|
+
}
|
|
1643
|
+
/** A note in a shared memory scope (Phase 29): `space`, `owner:<participantId>` or `project:<id>`. */
|
|
1644
|
+
export interface MemoryNoteLike {
|
|
1645
|
+
readonly id: string;
|
|
1646
|
+
readonly scope: string;
|
|
1647
|
+
readonly text: string;
|
|
1648
|
+
readonly writtenBy: string;
|
|
1649
|
+
readonly createdAt: string;
|
|
1650
|
+
}
|
|
1651
|
+
/** One recall of someone's owner scope made for somebody else. */
|
|
1652
|
+
export interface MemoryReadLike {
|
|
1653
|
+
readonly scope: string;
|
|
1654
|
+
readonly reader: string;
|
|
1655
|
+
readonly turnId: string;
|
|
1656
|
+
readonly sessionKey: string;
|
|
1657
|
+
readonly requestedBy?: string;
|
|
1658
|
+
readonly onBehalfOf?: string;
|
|
1659
|
+
readonly sources: readonly string[];
|
|
1660
|
+
readonly at: string;
|
|
1661
|
+
}
|
|
1662
|
+
export interface ProjectLike {
|
|
1663
|
+
readonly id: string;
|
|
1664
|
+
readonly name?: string;
|
|
1665
|
+
readonly agents: readonly string[];
|
|
1666
|
+
readonly createdAt: string;
|
|
1667
|
+
}
|
|
1668
|
+
export interface ConversationLike {
|
|
1669
|
+
readonly id: string;
|
|
1670
|
+
readonly kind: "room" | "dm";
|
|
1671
|
+
readonly title?: string;
|
|
1672
|
+
readonly members: readonly string[];
|
|
1673
|
+
readonly createdAt: string;
|
|
1674
|
+
}
|
|
1675
|
+
export interface ConversationMessageLike {
|
|
1676
|
+
readonly id: string;
|
|
1677
|
+
readonly conversationId: string;
|
|
1678
|
+
readonly authorId: string;
|
|
1679
|
+
readonly origin: "human" | "agent";
|
|
1680
|
+
readonly text: string;
|
|
1681
|
+
readonly mentions: readonly string[];
|
|
1682
|
+
readonly hop: number;
|
|
1683
|
+
readonly turnId?: string;
|
|
1684
|
+
/** The absent owner a stand-in answered for. */
|
|
1685
|
+
readonly onBehalfOf?: string;
|
|
1686
|
+
readonly seq: number;
|
|
1687
|
+
readonly createdAt: string;
|
|
1688
|
+
}
|
|
1689
|
+
/** A mutating call a stand-in queued for its absent owner (Phase 28). */
|
|
1690
|
+
export interface DeferredActionLike {
|
|
1691
|
+
readonly id: string;
|
|
1692
|
+
readonly agentId: string;
|
|
1693
|
+
readonly conversationId: string;
|
|
1694
|
+
readonly ownerId: string;
|
|
1695
|
+
readonly requestedBy: string;
|
|
1696
|
+
readonly slug: string;
|
|
1697
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
1698
|
+
readonly status: "pending" | "done" | "failed" | "denied";
|
|
1699
|
+
readonly result?: string;
|
|
1700
|
+
readonly createdAt: string;
|
|
1701
|
+
readonly decidedAt?: string;
|
|
1702
|
+
}
|
|
1703
|
+
export interface AssignmentLike {
|
|
1704
|
+
readonly agentId: string;
|
|
1705
|
+
readonly participantId: string;
|
|
1706
|
+
readonly assignedBy?: string;
|
|
1707
|
+
readonly assignedAt: string;
|
|
1708
|
+
}
|
|
1709
|
+
/** A webhook subscription as the server reports it. Never the secret. */
|
|
1710
|
+
export interface WebhookLike {
|
|
1711
|
+
readonly subscriptionId: string;
|
|
1712
|
+
readonly url: string;
|
|
1713
|
+
readonly types: readonly string[];
|
|
1714
|
+
readonly scope?: {
|
|
1715
|
+
readonly agents?: readonly string[];
|
|
1716
|
+
readonly sessionPrefix?: string;
|
|
1717
|
+
};
|
|
1718
|
+
readonly createdAt: string;
|
|
1719
|
+
/** True while the last attempt failed. `lastError` says why. */
|
|
1720
|
+
readonly failing: boolean;
|
|
1721
|
+
readonly consecutiveFailures: number;
|
|
1722
|
+
readonly lastError?: string;
|
|
1723
|
+
readonly lastSuccessAt?: string;
|
|
1724
|
+
readonly lastFailureAt?: string;
|
|
1725
|
+
readonly pending: number;
|
|
1726
|
+
}
|
|
1727
|
+
/** How to slice usage. `by` defaults to `["agent", "model"]` on the server; `[]` is one total. */
|
|
1728
|
+
export interface UsageOptions {
|
|
1729
|
+
readonly by?: readonly ("agent" | "model" | "day" | "sender")[];
|
|
1730
|
+
/** Inclusive, ISO-8601. */
|
|
1731
|
+
readonly from?: string;
|
|
1732
|
+
/** Exclusive, ISO-8601. */
|
|
1733
|
+
readonly to?: string;
|
|
1734
|
+
}
|
|
1735
|
+
/** One group's totals. A grouping field is present exactly when it was asked for. */
|
|
1736
|
+
export interface UsageBucketLike {
|
|
1737
|
+
readonly agentId?: string;
|
|
1738
|
+
readonly model?: string;
|
|
1739
|
+
readonly day?: string;
|
|
1740
|
+
/** Absent within a `sender` grouping means the operator's own calls. */
|
|
1741
|
+
readonly sender?: string;
|
|
1742
|
+
readonly calls: number;
|
|
1743
|
+
readonly promptTokens: number;
|
|
1744
|
+
readonly cachedPromptTokens: number;
|
|
1745
|
+
/** Prompt tokens written to a cache (Bedrock, Anthropic). Zero where nothing reports it. */
|
|
1746
|
+
readonly cacheWriteTokens: number;
|
|
1747
|
+
readonly outputTokens: number;
|
|
1748
|
+
/** Calls where either figure was an estimate. Non-zero means the totals are partly a guess. */
|
|
1749
|
+
readonly estimatedCalls: number;
|
|
1750
|
+
}
|
|
1751
|
+
export interface UsageReportLike {
|
|
1752
|
+
readonly buckets: readonly UsageBucketLike[];
|
|
1753
|
+
/** The earliest metered call. Absent when there are none. Earlier turns are not included. */
|
|
1754
|
+
readonly meteredSince?: string;
|
|
1755
|
+
}
|
|
1756
|
+
/** How far one credential reaches. Absent fields mean "everything". See `04-SPEC-WIRE.md`. */
|
|
1757
|
+
export interface KeyScopeLike {
|
|
1758
|
+
readonly agents?: readonly string[];
|
|
1759
|
+
/** A session-key prefix; a trailing `*` is accepted and ignored. */
|
|
1760
|
+
readonly sessions?: string;
|
|
1761
|
+
readonly can?: readonly ("read" | "chat" | "write" | "admin")[];
|
|
1762
|
+
/** The one participant this key speaks for: every turn it starts acts for them. */
|
|
1763
|
+
readonly participant?: string;
|
|
1764
|
+
}
|
|
1765
|
+
/** A credential as a listing shows it. Never the secret — no route returns one twice. */
|
|
1766
|
+
export interface OperatorKeyLike {
|
|
1767
|
+
readonly keyId: string;
|
|
1768
|
+
readonly label: string;
|
|
1769
|
+
readonly createdAt: string;
|
|
1770
|
+
readonly lastUsedAt?: string;
|
|
1771
|
+
readonly revokedAt?: string;
|
|
1772
|
+
/** Absent means unscoped: every agent, every session, all four capabilities. */
|
|
1773
|
+
readonly scope?: KeyScopeLike;
|
|
1774
|
+
readonly expiresAt?: string;
|
|
1775
|
+
}
|
|
1776
|
+
export interface DispachClient {
|
|
1777
|
+
agent(id: string): AgentClient;
|
|
1778
|
+
/** Every agent this runtime hosts. */
|
|
1779
|
+
agents(): Promise<readonly AgentDescriptionLike[]>;
|
|
1780
|
+
health(): Promise<{
|
|
1781
|
+
status: string;
|
|
1782
|
+
version: string;
|
|
1783
|
+
uptimeMs: number;
|
|
1784
|
+
agents: number;
|
|
1785
|
+
}>;
|
|
1786
|
+
/** `true` once the runtime can serve a turn. Needs no token. */
|
|
1787
|
+
ready(): Promise<boolean>;
|
|
1788
|
+
/** The firehose. Every event, optionally narrowed. */
|
|
1789
|
+
events(options?: EventStreamOptions): AsyncGenerator<EventStreamItem>;
|
|
1790
|
+
/**
|
|
1791
|
+
* What this server will ask to create an agent.
|
|
1792
|
+
*
|
|
1793
|
+
* Answers even when provisioning is unavailable or remote — an empty list beside
|
|
1794
|
+
* `available: false` says *why* a form cannot be offered, where a `501` would only say that one
|
|
1795
|
+
* cannot.
|
|
1796
|
+
*/
|
|
1797
|
+
provision(): Promise<ProvisionOfferLike>;
|
|
1798
|
+
/**
|
|
1799
|
+
* Create an agent and adopt it into this host.
|
|
1800
|
+
*
|
|
1801
|
+
* Send a subset: anything left out takes its default, exactly as `init --yes` does with flags.
|
|
1802
|
+
* A bad answer comes back as a `400` whose `field` names the step to fix.
|
|
1803
|
+
*/
|
|
1804
|
+
createAgent(answers: Readonly<Record<string, string>>): Promise<ProvisionedAgentLike>;
|
|
1805
|
+
/** What every agent this credential reaches cost, from the per-call meter. */
|
|
1806
|
+
usage(options?: UsageOptions): Promise<UsageReportLike>;
|
|
1807
|
+
/**
|
|
1808
|
+
* Whether the server is idle and when it must next be woken — for whatever suspends it. Needs
|
|
1809
|
+
* the server token or an unscoped operator key.
|
|
1810
|
+
*/
|
|
1811
|
+
activity(): Promise<ActivityLike>;
|
|
1812
|
+
/** Registered human participants. */
|
|
1813
|
+
participants(): Promise<readonly ParticipantLike[]>;
|
|
1814
|
+
registerParticipant(input: {
|
|
1815
|
+
readonly id: string;
|
|
1816
|
+
readonly name?: string;
|
|
1817
|
+
readonly role?: "admin" | "member";
|
|
1818
|
+
}): Promise<ParticipantLike>;
|
|
1819
|
+
/** The rooms and DMs this credential can see. */
|
|
1820
|
+
conversations(): Promise<readonly ConversationLike[]>;
|
|
1821
|
+
createConversation(input: {
|
|
1822
|
+
readonly kind: "room" | "dm";
|
|
1823
|
+
readonly members: readonly string[];
|
|
1824
|
+
readonly title?: string;
|
|
1825
|
+
}): Promise<ConversationLike>;
|
|
1826
|
+
conversation(conversationId: string): Promise<ConversationLike>;
|
|
1827
|
+
setMembers(conversationId: string, change: {
|
|
1828
|
+
readonly add?: readonly string[];
|
|
1829
|
+
readonly remove?: readonly string[];
|
|
1830
|
+
}): Promise<ConversationLike>;
|
|
1831
|
+
/**
|
|
1832
|
+
* Post a human member's message. In a room only the mentioned agents answer; their replies come
|
|
1833
|
+
* back as `conversation.message` events and in `conversationMessages`.
|
|
1834
|
+
*/
|
|
1835
|
+
postMessage(conversationId: string, message: {
|
|
1836
|
+
readonly text: string;
|
|
1837
|
+
readonly mentions?: readonly string[];
|
|
1838
|
+
readonly authorId?: string;
|
|
1839
|
+
}): Promise<ConversationMessageLike>;
|
|
1840
|
+
conversationMessages(conversationId: string, options?: {
|
|
1841
|
+
readonly after?: number;
|
|
1842
|
+
readonly limit?: number;
|
|
1843
|
+
}): Promise<{
|
|
1844
|
+
readonly messages: readonly ConversationMessageLike[];
|
|
1845
|
+
readonly nextAfter?: number;
|
|
1846
|
+
}>;
|
|
1847
|
+
/** Push whether a person is there. An offline person's agent stands in for them in a DM. */
|
|
1848
|
+
setPresence(participantId: string, presence: "online" | "offline"): Promise<ParticipantLike>;
|
|
1849
|
+
/** Actions stand-ins queued for their owners. A member-bound key sees its own. */
|
|
1850
|
+
actions(options?: {
|
|
1851
|
+
readonly status?: DeferredActionLike["status"];
|
|
1852
|
+
}): Promise<readonly DeferredActionLike[]>;
|
|
1853
|
+
/** Approve (runs the exact call) or decline a queued action. The owner's to decide. */
|
|
1854
|
+
decideAction(actionId: string, approve: boolean): Promise<DeferredActionLike>;
|
|
1855
|
+
/** Add a note to a shared memory scope. Who may write which scope is the server's to decide. */
|
|
1856
|
+
addNote(input: {
|
|
1857
|
+
readonly scope: string;
|
|
1858
|
+
readonly text: string;
|
|
1859
|
+
}): Promise<MemoryNoteLike>;
|
|
1860
|
+
notes(scope: string): Promise<readonly MemoryNoteLike[]>;
|
|
1861
|
+
deleteNote(noteId: string): Promise<{
|
|
1862
|
+
readonly id: string;
|
|
1863
|
+
readonly deleted: boolean;
|
|
1864
|
+
}>;
|
|
1865
|
+
/** A person's audit of reads of their owner scope. Theirs, or an admin's. */
|
|
1866
|
+
memoryReads(participantId: string): Promise<readonly MemoryReadLike[]>;
|
|
1867
|
+
projects(): Promise<readonly ProjectLike[]>;
|
|
1868
|
+
/** Define a project; `agents`, when given, replaces its membership. */
|
|
1869
|
+
putProject(projectId: string, input: {
|
|
1870
|
+
readonly name?: string;
|
|
1871
|
+
readonly agents?: readonly string[];
|
|
1872
|
+
}): Promise<ProjectLike>;
|
|
1873
|
+
deleteProject(projectId: string): Promise<{
|
|
1874
|
+
readonly id: string;
|
|
1875
|
+
readonly deleted: boolean;
|
|
1876
|
+
}>;
|
|
1877
|
+
/** Name the space's one non-admin writer: a participant, or `agent:<id>`. */
|
|
1878
|
+
setSpaceWriter(writer: string): Promise<{
|
|
1879
|
+
readonly writer: string;
|
|
1880
|
+
}>;
|
|
1881
|
+
/** The webhook subscriptions this credential can see. */
|
|
1882
|
+
webhooks(): Promise<readonly WebhookLike[]>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Subscribe a URL. **The secret comes back exactly once**: store it where the receiver can read
|
|
1885
|
+
* it, and verify deliveries with any Standard Webhooks library.
|
|
1886
|
+
*/
|
|
1887
|
+
createWebhook(input: {
|
|
1888
|
+
readonly url: string;
|
|
1889
|
+
readonly types: readonly string[];
|
|
1890
|
+
readonly agents?: readonly string[];
|
|
1891
|
+
}): Promise<WebhookLike & {
|
|
1892
|
+
readonly secret: string;
|
|
1893
|
+
}>;
|
|
1894
|
+
deleteWebhook(subscriptionId: string): Promise<{
|
|
1895
|
+
readonly id: string;
|
|
1896
|
+
readonly deleted: boolean;
|
|
1897
|
+
}>;
|
|
1898
|
+
/** Every template this server can create an agent from, with the variables each declares. */
|
|
1899
|
+
templates(): Promise<readonly TemplateLike[]>;
|
|
1900
|
+
/**
|
|
1901
|
+
* Create an agent from a template and adopt it. The id is derived from `name`. A secret
|
|
1902
|
+
* variable's value goes to the new agent's `.env` and is never returned.
|
|
1903
|
+
*/
|
|
1904
|
+
createAgentFromTemplate(input: {
|
|
1905
|
+
readonly template: string;
|
|
1906
|
+
readonly name: string;
|
|
1907
|
+
readonly vars?: Readonly<Record<string, string>>;
|
|
1908
|
+
}): Promise<ProvisionedAgentLike>;
|
|
1909
|
+
/**
|
|
1910
|
+
* Every credential, live and revoked, with the sentence this server says about scope.
|
|
1911
|
+
*
|
|
1912
|
+
* Revoked ones are **shown**: the row is the only record a credential ever existed, and hiding
|
|
1913
|
+
* it makes a revocation unverifiable.
|
|
1914
|
+
*/
|
|
1915
|
+
keys(): Promise<{
|
|
1916
|
+
readonly keys: readonly OperatorKeyLike[];
|
|
1917
|
+
readonly scope: string;
|
|
1918
|
+
}>;
|
|
1919
|
+
/**
|
|
1920
|
+
* Mint one. **The secret comes back exactly once** and is stored only as a fingerprint.
|
|
1921
|
+
*
|
|
1922
|
+
* `expiresIn` is seconds from now; the response carries the absolute `expiresAt` this server
|
|
1923
|
+
* computed. Relative going in, because an absolute instant would assert agreement with a clock
|
|
1924
|
+
* the caller does not share.
|
|
1925
|
+
*/
|
|
1926
|
+
createKey(input: {
|
|
1927
|
+
readonly label: string;
|
|
1928
|
+
readonly scope?: KeyScopeLike & {
|
|
1929
|
+
readonly expiresIn?: number;
|
|
1930
|
+
};
|
|
1931
|
+
}): Promise<OperatorKeyLike & {
|
|
1932
|
+
readonly secret: string;
|
|
1933
|
+
}>;
|
|
1934
|
+
/** Permanent. A revoked secret can never be re-presented. */
|
|
1935
|
+
revokeKey(keyId: string): Promise<OperatorKeyLike>;
|
|
1936
|
+
}
|
|
1937
|
+
/** Narrow an event by type, so a `switch` over a stream keeps its `data` typed. */
|
|
1938
|
+
export declare function isEvent<K extends EventType>(event: AnyEvent, type: K): event is AnyEvent & {
|
|
1939
|
+
type: K;
|
|
1940
|
+
data: EventDataMap[K];
|
|
1941
|
+
};
|
|
1942
|
+
export declare function createClient(options: ClientOptions): DispachClient;
|
|
1943
|
+
|
|
1944
|
+
export {};
|