@abaigram/abai-stub 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/audit.d.ts +35 -3
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +32 -2
- package/dist/audit.js.map +1 -1
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/endpoint.js +15 -0
- package/dist/endpoint.js.map +1 -1
- package/dist/entry.d.ts +1 -1
- package/dist/entry.d.ts.map +1 -1
- package/dist/entry.js +2 -2
- package/dist/entry.js.map +1 -1
- package/dist/harness-binding.d.ts +14 -2
- package/dist/harness-binding.d.ts.map +1 -1
- package/dist/harness-binding.js +30 -1
- package/dist/harness-binding.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/manifest/manifest.d.ts +5 -0
- package/dist/manifest/manifest.d.ts.map +1 -1
- package/dist/manifest/manifest.js +9 -0
- package/dist/manifest/manifest.js.map +1 -1
- package/dist/program.d.ts +7 -2
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +27 -6
- package/dist/program.js.map +1 -1
- package/dist/region.d.ts.map +1 -1
- package/dist/region.js +3 -2
- package/dist/region.js.map +1 -1
- package/dist/registry.d.ts +3 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +4 -0
- package/dist/registry.js.map +1 -1
- package/dist/wire/protocol.d.ts +4 -2
- package/dist/wire/protocol.d.ts.map +1 -1
- package/dist/wire/protocol.js +4 -2
- package/dist/wire/protocol.js.map +1 -1
- package/package.json +1 -1
package/dist/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,2EAA2E;AAC3E,sEAAsE;AACtE,uEAAuE;AACvE,mEAAmE;AACnE,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C,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,QAAQ,CAAC;AAAA,CAChB","sourcesContent":["// Declarations in code become the manifest (abaigrammar section 7). The\n// program hands `createAbaigram` keyed records; this module turns them into\n// the manifest's lists in insertion order, fills the grammar's defaults so\n// the rendered abaigram.yaml is explicit and byte-stable, appends the\n// deviations this TypeScript instantiation declares, and validates. An\n// invalid declaration throws at startup: declared, not discovered.\nimport {\n\tABAIGRAMMAR_VERSION,\n\ttype CapabilityDecl,\n\ttype CellDecl,\n\ttype DecisionDecl,\n\ttype EventDecl,\n\ttype Manifest,\n\ttype Mode,\n\ttype Policy,\n\ttype TurnDecl,\n\tvalidateManifest,\n} from \"./manifest/manifest.ts\";\n\n/** A capability's handler: parameters in, a result out; a throw is an error result. */\nexport type CapabilityHandler = (params: Record<string, unknown>) => unknown | Promise<unknown>;\n/** A sized knob's handler: the delivered value, at a safepoint, on the thread that reached it. */\nexport type KnobHandler = (value: unknown) => void;\n/** The stop handler, run at a safepoint on a graceful stop (section 5.5). */\nexport type StopHandler = () => void | Promise<void>;\n\nexport type CellOptions = Omit<CellDecl, \"name\"> & { onChange?: KnobHandler };\nexport type EventOptions = Omit<EventDecl, \"name\">;\nexport type CapabilityOptions = Omit<CapabilityDecl, \"name\" | \"dispatch\" | \"policy\" | \"timeout\"> & {\n\tdispatch?: CapabilityDecl[\"dispatch\"];\n\tpolicy?: Policy;\n\ttimeout?: string;\n\thandler?: CapabilityHandler;\n};\nexport type DecisionOptions = Omit<DecisionDecl, \"name\" | \"policy\"> & { policy?: Policy };\nexport type TurnOptions = Omit<TurnDecl, \"name\">;\n\nexport interface AbaigramOptions {\n\tname: string;\n\t/** Default `<name> abai`. */\n\tentry?: string;\n\tmodes: Mode[];\n\t/** Paths relative to the program's root; `identity` defaults to `abai/identity.md`. */\n\tcontent?: Partial<Manifest[\"content\"]>;\n\t/** Default `~/.abai/audit/<name>.jsonl`. */\n\taudit?: Manifest[\"audit\"];\n\tharness?: Manifest[\"harness\"];\n\tmodel?: Manifest[\"model\"];\n\tcheck?: Manifest[\"check\"];\n\tlifecycle?: Omit<NonNullable<Manifest[\"lifecycle\"]>, \"stop\"> & {\n\t\tstop?: { graceful: string; handler: StopHandler };\n\t};\n\tattention?: Manifest[\"attention\"];\n\tpolicy?: Manifest[\"policy\"];\n\t/** The program's own deviations; the instantiation's are appended. */\n\tdeviations?: string[];\n\tcells?: Record<string, CellOptions>;\n\tevents?: Record<string, EventOptions>;\n\tcapabilities?: Record<string, CapabilityOptions>;\n\tdecisions?: Record<string, DecisionOptions>;\n\tturns?: Record<string, TurnOptions>;\n}\n\n/** Where this TypeScript instantiation departs from the grammar, in every manifest it renders. */\nexport const INSTANTIATION_DEVIATIONS: readonly string[] = [\n\t\"Touchpoints are awaited promises: Node cannot block its only thread while the agent loop runs on it, so the program's logic pauses at the await while its own timers and I/O callbacks keep running (section 4.3).\",\n\t\"Sized cell writes and event payload copies allocate: JavaScript has no copy into a preallocated byte slot; scalar rows meet section 11.2, sized rows are measured and reported.\",\n\t\"A cooperative pause holds the program at its next touchpoint, not inside safepoint(): a safepoint cannot block, since the resume arrives on the same event loop that would be blocked. The flag is still one load at a safepoint, and os pause (the launcher's signal) holds the program anywhere (section 5.5).\",\n\t\"Under launch the child is attached as soon as its endpoint is accepted, a moment after its first statement rather than before it: Node cannot listen in a constructor. A program that wants the agent present from its first line awaits attach() (section 6.3).\",\n];\nexport const SIDECAR_DEVIATION =\n\t\"In sidecar mode the region is not shared memory: cells are read by request and events cross the socket, so observation costs the program one serialization per connected harness (section 11.3). Under ABAI_HARNESS=null or exercise the null harness stays in the program's process and no endpoint opens, so a check run's measured overhead leaves that serialization out.\";\n\nexport const DEFAULT_CAPABILITY_TIMEOUT = \"30s\";\nexport const DEFAULT_KNOB_TIMEOUT = \"30s\";\n\nfunction isSized(type: CellDecl[\"type\"]): boolean {\n\treturn type === \"string\" || type === \"object\" || type === \"list\";\n}\n\n/** Build the explicit, validated manifest from the program's declarations. Throws on a violation. */\nexport function buildManifest(options: AbaigramOptions): Manifest {\n\tconst cells: CellDecl[] = [];\n\tfor (const [name, cell] of Object.entries(options.cells ?? {})) {\n\t\tconst { onChange: _onChange, ...decl } = cell;\n\t\tconst full: CellDecl = { name, ...decl };\n\t\tif (full.access === \"readwrite\") {\n\t\t\tfull.policy ??= \"auto\";\n\t\t\tif (isSized(full.type)) full.timeout ??= DEFAULT_KNOB_TIMEOUT;\n\t\t}\n\t\tcells.push(full);\n\t}\n\tconst events: EventDecl[] = [];\n\tfor (const [name, event] of Object.entries(options.events ?? {})) {\n\t\tconst full: EventDecl = { name, ...event };\n\t\tfull.wakes ??= \"never\";\n\t\tevents.push(full);\n\t}\n\tconst capabilities: CapabilityDecl[] = [];\n\tfor (const [name, capability] of Object.entries(options.capabilities ?? {})) {\n\t\tconst { handler: _handler, ...decl } = capability;\n\t\tcapabilities.push({\n\t\t\tname,\n\t\t\t...decl,\n\t\t\tdispatch: decl.dispatch ?? \"safepoint\",\n\t\t\ttimeout: decl.timeout ?? DEFAULT_CAPABILITY_TIMEOUT,\n\t\t\tpolicy: decl.policy ?? (decl.effect === \"mutate\" ? \"confirm\" : \"auto\"),\n\t\t});\n\t}\n\tconst decisions: DecisionDecl[] = [];\n\tfor (const [name, decision] of Object.entries(options.decisions ?? {})) {\n\t\tdecisions.push({ name, ...decision, policy: decision.policy ?? \"auto\" });\n\t}\n\tconst turns: TurnDecl[] = [];\n\tfor (const [name, turn] of Object.entries(options.turns ?? {})) {\n\t\tif (options.decisions?.[name] !== undefined) {\n\t\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${name} is both a decision and a turn`);\n\t\t}\n\t\tturns.push({ name, ...turn });\n\t}\n\tconst deviations = [...(options.deviations ?? []), ...INSTANTIATION_DEVIATIONS];\n\tif (options.modes.includes(\"sidecar\")) deviations.push(SIDECAR_DEVIATION);\n\n\tconst manifest: Manifest = {\n\t\tabaigrammar: ABAIGRAMMAR_VERSION,\n\t\tname: options.name,\n\t\tentry: options.entry ?? `${options.name} abai`,\n\t\tmodes: [...options.modes],\n\t\t...(options.harness === undefined ? {} : { harness: options.harness }),\n\t\t...(options.model === undefined ? {} : { model: options.model }),\n\t\t...(options.check === undefined ? {} : { check: options.check }),\n\t\tcontent: { identity: \"abai/identity.md\", ...(options.content ?? {}) },\n\t\taudit: options.audit ?? { path: `~/.abai/audit/${options.name}.jsonl` },\n\t\t...(options.lifecycle === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tlifecycle: {\n\t\t\t\t\t\tpause: options.lifecycle.pause,\n\t\t\t\t\t\t...(options.lifecycle.stop === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { stop: { graceful: options.lifecycle.stop.graceful, handler: \"stop\" } }),\n\t\t\t\t\t\t...(options.lifecycle.policy === undefined ? {} : { policy: options.lifecycle.policy }),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t...(options.attention === undefined ? {} : { attention: options.attention }),\n\t\t...(options.policy === undefined ? {} : { policy: options.policy }),\n\t\tdeviations,\n\t\tcells,\n\t\tevents,\n\t\tcapabilities,\n\t\tdecisions,\n\t\tturns,\n\t};\n\tconst violations = validateManifest(manifest);\n\tif (violations.length > 0) {\n\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${violations.join(\"; \")}`);\n\t}\n\treturn manifest;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,4EAA4E;AAC5E,2EAA2E;AAC3E,sEAAsE;AACtE,uEAAuE;AACvE,mEAAmE;AACnE,OAAO,EACN,mBAAmB,EASnB,gBAAgB,GAChB,MAAM,wBAAwB,CAAC;AAgDhC,kGAAkG;AAClG,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IAC1D,oNAAoN;IACpN,iLAAiL;IACjL,kTAAkT;IAClT,kQAAkQ;CAClQ,CAAC;AACF,MAAM,CA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,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,uBAAuB,OAAO,CAAC,IAAI,qBAAqB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClG,CAAC;IACD,OAAO,QAAQ,CAAC;AAAA,CAChB","sourcesContent":["// Declarations in code become the manifest (abaigrammar section 7). The\n// program hands `createAbaigram` keyed records; this module turns them into\n// the manifest's lists in insertion order, fills the grammar's defaults so\n// the rendered abaigram.yaml is explicit and byte-stable, appends the\n// deviations this TypeScript instantiation declares, and validates. An\n// invalid declaration throws at startup: declared, not discovered.\nimport {\n\tABAIGRAMMAR_VERSION,\n\ttype CapabilityDecl,\n\ttype CellDecl,\n\ttype DecisionDecl,\n\ttype EventDecl,\n\ttype Manifest,\n\ttype Mode,\n\ttype Policy,\n\ttype TurnDecl,\n\tvalidateManifest,\n} from \"./manifest/manifest.ts\";\n\n/** A capability's handler: parameters in, a result out; a throw is an error result. */\nexport type CapabilityHandler = (params: Record<string, unknown>) => unknown | Promise<unknown>;\n/** A sized knob's handler: the delivered value, at a safepoint, on the thread that reached it. */\nexport type KnobHandler = (value: unknown) => void;\n/** The stop handler, run at a safepoint on a graceful stop (section 5.5). */\nexport type StopHandler = () => void | Promise<void>;\n\nexport type CellOptions = Omit<CellDecl, \"name\"> & { onChange?: KnobHandler };\nexport type EventOptions = Omit<EventDecl, \"name\">;\nexport type CapabilityOptions = Omit<CapabilityDecl, \"name\" | \"dispatch\" | \"policy\" | \"timeout\"> & {\n\tdispatch?: CapabilityDecl[\"dispatch\"];\n\tpolicy?: Policy;\n\ttimeout?: string;\n\thandler?: CapabilityHandler;\n};\nexport type DecisionOptions = Omit<DecisionDecl, \"name\" | \"policy\"> & { policy?: Policy };\nexport type TurnOptions = Omit<TurnDecl, \"name\">;\n\nexport interface AbaigramOptions {\n\tname: string;\n\t/** Default `<name> abai`. */\n\tentry?: string;\n\tmodes: Mode[];\n\t/** Paths relative to the program's root; `identity` defaults to `abai/identity.md`. */\n\tcontent?: Partial<Manifest[\"content\"]>;\n\t/** Default `~/.abai/audit/<name>.jsonl`. */\n\taudit?: Manifest[\"audit\"];\n\tharness?: Manifest[\"harness\"];\n\tmodel?: Manifest[\"model\"];\n\tcheck?: Manifest[\"check\"];\n\tlifecycle?: Omit<NonNullable<Manifest[\"lifecycle\"]>, \"stop\"> & {\n\t\tstop?: { graceful: string; handler: StopHandler };\n\t};\n\tattention?: Manifest[\"attention\"];\n\tpolicy?: Manifest[\"policy\"];\n\t/** The agent may be a member of an agent network; `doc` says how its members relate to this program's names. */\n\tnetwork?: Manifest[\"network\"];\n\t/** The program's own deviations; the instantiation's are appended. */\n\tdeviations?: string[];\n\tcells?: Record<string, CellOptions>;\n\tevents?: Record<string, EventOptions>;\n\tcapabilities?: Record<string, CapabilityOptions>;\n\tdecisions?: Record<string, DecisionOptions>;\n\tturns?: Record<string, TurnOptions>;\n}\n\n/** Where this TypeScript instantiation departs from the grammar, in every manifest it renders. */\nexport const INSTANTIATION_DEVIATIONS: readonly string[] = [\n\t\"Touchpoints are awaited promises: Node cannot block its only thread while the agent loop runs on it, so the program's logic pauses at the await while its own timers and I/O callbacks keep running (section 4.3).\",\n\t\"Sized cell writes and event payload copies allocate: JavaScript has no copy into a preallocated byte slot; scalar rows meet section 11.2, sized rows are measured and reported.\",\n\t\"A cooperative pause holds the program at its next touchpoint, not inside safepoint(): a safepoint cannot block, since the resume arrives on the same event loop that would be blocked. The flag is still one load at a safepoint, and os pause (the launcher's signal) holds the program anywhere (section 5.5).\",\n\t\"Under launch the child is attached as soon as its endpoint is accepted, a moment after its first statement rather than before it: Node cannot listen in a constructor. A program that wants the agent present from its first line awaits attach() (section 6.3).\",\n];\nexport const THREAD_DEVIATION =\n\t\"In thread mode the harness has no thread of its own: Node runs one event loop, so the harness runs on the program's loop between the program's callbacks, live, and a long synchronous step on either side delays the other. Isolation is what one loop allows: a harness listener that throws while the program emits, decides or gives a turn is caught at the binding, a failed agent run ends that run alone, and a model unreachable at first contact detaches the harness, so the program goes on as itself; an exception or rejection the harness lets escape to the process is a process fault, as for any library on the same loop (section 6.2).\";\nexport const SIDECAR_DEVIATION =\n\t\"In sidecar mode the region is not shared memory: cells are read by request and events cross the socket, so observation costs the program one serialization per connected harness (section 11.3). Under ABAI_HARNESS=null or exercise the null harness stays in the program's process and no endpoint opens, so a check run's measured overhead leaves that serialization out.\";\n\nexport const DEFAULT_CAPABILITY_TIMEOUT = \"30s\";\nexport const DEFAULT_KNOB_TIMEOUT = \"30s\";\n\nfunction isSized(type: CellDecl[\"type\"]): boolean {\n\treturn type === \"string\" || type === \"object\" || type === \"list\";\n}\n\n/** Build the explicit, validated manifest from the program's declarations. Throws on a violation. */\nexport function buildManifest(options: AbaigramOptions): Manifest {\n\tconst cells: CellDecl[] = [];\n\tfor (const [name, cell] of Object.entries(options.cells ?? {})) {\n\t\tconst { onChange: _onChange, ...decl } = cell;\n\t\tconst full: CellDecl = { name, ...decl };\n\t\tif (full.access === \"readwrite\") {\n\t\t\tfull.policy ??= \"auto\";\n\t\t\tif (isSized(full.type)) full.timeout ??= DEFAULT_KNOB_TIMEOUT;\n\t\t}\n\t\tcells.push(full);\n\t}\n\tconst events: EventDecl[] = [];\n\tfor (const [name, event] of Object.entries(options.events ?? {})) {\n\t\tconst full: EventDecl = { name, ...event };\n\t\tfull.wakes ??= \"never\";\n\t\tevents.push(full);\n\t}\n\tconst capabilities: CapabilityDecl[] = [];\n\tfor (const [name, capability] of Object.entries(options.capabilities ?? {})) {\n\t\tconst { handler: _handler, ...decl } = capability;\n\t\tcapabilities.push({\n\t\t\tname,\n\t\t\t...decl,\n\t\t\tdispatch: decl.dispatch ?? \"safepoint\",\n\t\t\ttimeout: decl.timeout ?? DEFAULT_CAPABILITY_TIMEOUT,\n\t\t\tpolicy: decl.policy ?? (decl.effect === \"mutate\" ? \"confirm\" : \"auto\"),\n\t\t});\n\t}\n\tconst decisions: DecisionDecl[] = [];\n\tfor (const [name, decision] of Object.entries(options.decisions ?? {})) {\n\t\tdecisions.push({ name, ...decision, policy: decision.policy ?? \"auto\" });\n\t}\n\tconst turns: TurnDecl[] = [];\n\tfor (const [name, turn] of Object.entries(options.turns ?? {})) {\n\t\tif (options.decisions?.[name] !== undefined) {\n\t\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${name} is both a decision and a turn`);\n\t\t}\n\t\tturns.push({ name, ...turn });\n\t}\n\tconst deviations = [...(options.deviations ?? []), ...INSTANTIATION_DEVIATIONS];\n\tif (options.modes.includes(\"thread\")) deviations.push(THREAD_DEVIATION);\n\tif (options.modes.includes(\"sidecar\")) deviations.push(SIDECAR_DEVIATION);\n\n\tconst manifest: Manifest = {\n\t\tabaigrammar: ABAIGRAMMAR_VERSION,\n\t\tname: options.name,\n\t\tentry: options.entry ?? `${options.name} abai`,\n\t\tmodes: [...options.modes],\n\t\t...(options.harness === undefined ? {} : { harness: options.harness }),\n\t\t...(options.model === undefined ? {} : { model: options.model }),\n\t\t...(options.check === undefined ? {} : { check: options.check }),\n\t\tcontent: { identity: \"abai/identity.md\", ...(options.content ?? {}) },\n\t\taudit: options.audit ?? { path: `~/.abai/audit/${options.name}.jsonl` },\n\t\t...(options.lifecycle === undefined\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\tlifecycle: {\n\t\t\t\t\t\tpause: options.lifecycle.pause,\n\t\t\t\t\t\t...(options.lifecycle.stop === undefined\n\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t: { stop: { graceful: options.lifecycle.stop.graceful, handler: \"stop\" } }),\n\t\t\t\t\t\t...(options.lifecycle.policy === undefined ? {} : { policy: options.lifecycle.policy }),\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t...(options.attention === undefined ? {} : { attention: options.attention }),\n\t\t...(options.policy === undefined ? {} : { policy: options.policy }),\n\t\t...(options.network === undefined ? {} : { network: options.network }),\n\t\tdeviations,\n\t\tcells,\n\t\tevents,\n\t\tcapabilities,\n\t\tdecisions,\n\t\tturns,\n\t};\n\tconst violations = validateManifest(manifest);\n\tif (violations.length > 0) {\n\t\tthrow new Error(`the declarations of ${options.name} do not validate: ${violations.join(\"; \")}`);\n\t}\n\treturn manifest;\n}\n"]}
|
package/dist/wire/protocol.d.ts
CHANGED
|
@@ -10,9 +10,11 @@ export declare const PROTOCOL_VERSION = 1;
|
|
|
10
10
|
* apply the decision's default, audited as a default; a v1-core host has no
|
|
11
11
|
* such answer, so the client sends it the manifest default instead),
|
|
12
12
|
* `lifecycle` (the `lifecycle {op}` command of section 5.5 and a cause on
|
|
13
|
-
* `turn_end`)
|
|
13
|
+
* `turn_end`), `messages` (the `record_message` command: the harness hands
|
|
14
|
+
* the stub one message sent or received over the run's network for the
|
|
15
|
+
* audit log, section 10).
|
|
14
16
|
*/
|
|
15
|
-
export declare const EXTENSIONS: readonly ["consent", "content", "turns", "call_codes", "defaults", "lifecycle"];
|
|
17
|
+
export declare const EXTENSIONS: readonly ["consent", "content", "turns", "call_codes", "defaults", "lifecycle", "messages"];
|
|
16
18
|
export type Extension = (typeof EXTENSIONS)[number];
|
|
17
19
|
/** Why a request failed, in the capability error vocabulary (the `call_codes` extension). */
|
|
18
20
|
export type WireErrorCode = "unknown" | "forbidden" | "denied" | "invalid" | "timeout" | "error";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/wire/protocol.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,iFAAkF,CAAC;AAC1G,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpD,6FAA6F;AAC7F,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS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GAAG,cAAc,GAAG,oBAAoB,CAAC;AAMzG,0GAA0G;AAC1G,MAAM,WAAW,YAAY;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,0EAA0E;AAC1E,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CACf;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC/B,QAAQ,EAAE,QAAQ,CAAC;CACnB;AAED,sHAAsH;AACtH,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,0EAA0E;AAC1E,MAAM,WAAW,mBAAmB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,+FAA+F;IAC/F,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAC;CACnB","sourcesContent":["// abai wire protocol v1 (abaigrammar section 6.3): LF-framed JSON lines over a\n// local socket. The core is the generic part of arx-06's supervisor protocol,\n// unchanged, so a running arx-06 is a sidecar target; extensions are\n// advertised in hello.abai.extensions.\nimport type { Manifest } from \"../manifest/manifest.ts\";\n\nexport const PROTOCOL_VERSION = 1;\n\n/**\n * The extensions a TypeScript stub speaks beyond the v1 core, named in\n * `hello.abai.extensions` so a client speaks each only when it is offered:\n * `consent` (consent stated on a request or hook answer), `content` (the\n * install, use and turn slots on `get_content`), `turns` (turns and\n * touchpoints as messages), `call_codes` (a code beside every error),\n * `defaults` (a `hook_response` whose `result` is null asks the program to\n * apply the decision's default, audited as a default; a v1-core host has no\n * such answer, so the client sends it the manifest default instead),\n * `lifecycle` (the `lifecycle {op}` command of section 5.5 and a cause on\n * `turn_end`).\n */\nexport const EXTENSIONS = [\"consent\", \"content\", \"turns\", \"call_codes\", \"defaults\", \"lifecycle\"] as const;\nexport type Extension = (typeof EXTENSIONS)[number];\n\n/** Why a request failed, in the capability error vocabulary (the `call_codes` extension). */\nexport type WireErrorCode = \"unknown\" | \"forbidden\" | \"denied\" | \"invalid\" | \"timeout\" | \"error\";\n\n// ---------------------------------------------------------------------------\n// Server -> client\n// ---------------------------------------------------------------------------\n\n/** The abai identity of the program, in `hello`. */\nexport interface HelloAbai {\n\tname: string;\n\tabaigrammar: string;\n\tmodes: string[];\n\taudit: { path: string; failed: string | null };\n\t/** Wire extensions beyond the v1 core; absent means none. */\n\textensions?: string[];\n}\n\nexport interface HelloMessage {\n\ttype: \"hello\";\n\tprotocol: number;\n\tpid: number;\n\t/** The program's own version string, when it has one. */\n\tversion?: string;\n\tcwd: string;\n\t/** A directory the program calls its own (arx-06's agent dir); absent for most programs. */\n\tagentDir?: string;\n\tmode: string;\n\t/** What this host offers: hooks and commands policy does not forbid. */\n\tcapabilities: { hooks: string[]; commands: string[] };\n\t/** Sequence number of the last event the host counted. */\n\tlastSeq: number;\n\t/** This connection's id (`k1`, `k2`, ...), as the audit log names it. */\n\tconnection: string;\n\tabai: HelloAbai;\n}\n\nexport type WireEvent = { type: string } & Record<string, unknown>;\n\nexport interface EventMessage {\n\ttype: \"event\";\n\tseq: number;\n\tts: number;\n\tevent: WireEvent;\n\t/** A sized field was cut to its declared max. An additive field; a v1-core client ignores it. */\n\ttruncated?: boolean;\n}\n\n/** A `snapshot` message some hosts send; parsed, its shape is the host's. */\nexport type LooseSnapshotMessage = { type: \"snapshot\" } & Record<string, unknown>;\n\n/** An event that could not be serialized was dropped; the program continues. */\nexport interface SerializeErrorMessage {\n\ttype: \"serialize_error\";\n\tseq: number;\n\tts: number;\n\teventType: string;\n\terror: string;\n}\n\nexport type WireResponse =\n\t| { type: \"response\"; id?: string; command: string; success: true; data?: unknown }\n\t| { type: \"response\"; id?: string; command: string; success: false; error: string; code?: WireErrorCode };\n\n/** Extension `turns`: the program gives the harness a turn; `turn_end` hands control back. */\nexport interface TurnMessage {\n\ttype: \"turn\";\n\tid: string;\n\tname: string;\n\t/** How long the program waits before the turn ends on its own. */\n\ttimeoutMs: number;\n\tcontent?: string;\n}\n\n/** Extension `turns`: a program-initiated `install` or `session`; `touchpoint_end` returns it. */\nexport interface TouchpointMessage {\n\ttype: \"touchpoint\";\n\tid: string;\n\tkind: \"install\" | \"session\";\n\tcontent?: string;\n}\n\n/** Interceptable hook round trip. Only sent to the connection holding the hook. */\nexport interface HookMessage {\n\ttype: \"hook\";\n\tid: string;\n\thook: string;\n\ttimeoutMs: number;\n\tpayload: unknown;\n}\n\nexport interface HookTimeoutMessage {\n\ttype: \"hook_timeout\";\n\thook: string;\n\tid: string;\n}\n\n/** The claimant's claims were dropped by the host (three consecutive timeouts). */\nexport interface HookClaimsReleasedMessage {\n\ttype: \"hook_claims_released\";\n\treason: string;\n\thooks: string[];\n}\n\n/**\n * A hook could not be served: the payload was not serializable (no `hook`\n * message was sent for this id) or the claimant's result failed validation.\n * The run continued as if the hook were unclaimed.\n */\nexport interface HookRejectedMessage {\n\ttype: \"hook_rejected\";\n\tid: string;\n\thook: string;\n\terror: string;\n}\n\nexport type ServerMessage =\n\t| HelloMessage\n\t| EventMessage\n\t| LooseSnapshotMessage\n\t| SerializeErrorMessage\n\t| WireResponse\n\t| HookMessage\n\t| HookTimeoutMessage\n\t| HookClaimsReleasedMessage\n\t| HookRejectedMessage\n\t| TurnMessage\n\t| TouchpointMessage;\n\n// ---------------------------------------------------------------------------\n// Client -> server\n// ---------------------------------------------------------------------------\n\n/**\n * Per-connection event filter. `include` restricts the stream to the listed\n * event types; `exclude` drops the listed types. A `subscribe` request\n * replaces the whole filter, so an omitted `exclude` means no exclusions.\n */\nexport interface SubscriptionFilter {\n\tinclude?: string[];\n\texclude?: string[];\n}\n\n/** The library's commands: the connection's own, the stub's, and the cells channel. */\nexport type LibraryCommand =\n\t// connection\n\t| { type: \"ping\" }\n\t| ({ type: \"subscribe\" } & SubscriptionFilter)\n\t| { type: \"claim_hooks\"; hooks: string[]; timeoutMs?: number }\n\t| { type: \"release_hooks\"; hooks?: string[] }\n\t// library\n\t| { type: \"get_manifest\" }\n\t| { type: \"get_content\" }\n\t| { type: \"get_audit\"; limit?: number }\n\t// cells (abaigrammar section 5.2)\n\t| { type: \"get_cells\" }\n\t| { type: \"set_cell\"; name: string; value: unknown }\n\t// lifecycle (abaigrammar section 5.5), the `lifecycle` extension: status always, pause and resume for a\n\t// cooperative pause, stop for the declared stop handler; start and restart are the launcher's own\n\t| { type: \"lifecycle\"; op: string };\n\n/**\n * Every command a client can send: the library commands, plus any capability\n * call sent as `{ type: <capability name>, ...params }`. The advertised list\n * is the host's (`hello.capabilities.commands`).\n */\nexport type WireCommand = LibraryCommand | ({ type: string } & Record<string, unknown>);\n\n/** Consent stated for an act whose policy is `confirm` (abaigrammar section 10); the `consent` extension. */\nexport type WireConsent = \"approved\" | \"auto\" | \"denied\";\n\nexport interface RequestMessage {\n\ttype: \"request\";\n\tid: string;\n\tcommand: WireCommand;\n\t/** The agent's stated reason for an act of control; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\nexport interface HookResponseMessage {\n\ttype: \"hook_response\";\n\tid: string;\n\tresult: unknown;\n\t/** The agent's stated reason for its answer; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\n/** Extension `turns`: the harness is done with a turn. `cause` says why the agent did nothing with it (`budget`). */\nexport interface TurnEndMessage {\n\ttype: \"turn_end\";\n\tid: string;\n\tcause?: string;\n}\n\n/** Extension `turns`: the harness is done with a touchpoint. */\nexport interface TouchpointEndMessage {\n\ttype: \"touchpoint_end\";\n\tid: string;\n}\n\nexport type ClientMessage = RequestMessage | HookResponseMessage | TurnEndMessage | TouchpointEndMessage;\n\n// ---------------------------------------------------------------------------\n// Response data of the library commands\n// ---------------------------------------------------------------------------\n\n/** `get_cells`: every cell's value (sized ones cut to their max) and the host's event sequence number. */\nexport interface GetCellsData {\n\tseq: number;\n\tcells: Record<string, unknown>;\n}\n\n/** `set_cell`: the knob and the value that landed (it may be clamped). */\nexport interface SetCellData {\n\tname: string;\n\tvalue: unknown;\n}\n\n/** `get_manifest`: the effective manifest of this running host. */\nexport interface GetManifestData {\n\tmanifest: Manifest;\n}\n\n/** `get_content`: the content slots the stub embeds (abaigrammar section 8). A v1-core host sends `identity` only. */\nexport interface GetContentData {\n\tidentity: string;\n\tinstall?: string;\n\tuse?: string;\n\tturns?: Record<string, string>;\n}\n\n/** `lifecycle {op: \"status\"}`: what the stub knows of its own process. */\nexport interface LifecycleStatusData {\n\tpid: number;\n\tname: string;\n\tmode: string;\n\tcwd: string;\n\tstartedAt: string;\n\tconnections: number;\n\tpaused: boolean;\n\t/** A launcher handed this program its connection, so the full lifecycle is available to it. */\n\tlaunched: boolean;\n}\n\n/** `get_audit`: the log's location and state, and its last records. */\nexport interface GetAuditData {\n\tpath: string;\n\tfailed: string | null;\n\trecords: unknown[];\n\t/** More records exist than were returned. */\n\ttruncated: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/wire/protocol.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAy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MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,6CAA6C;IAC7C,SAAS,EAAE,OAAO,CAAC;CACnB","sourcesContent":["// abai wire protocol v1 (abaigrammar section 6.3): LF-framed JSON lines over a\n// local socket. The core is the generic part of arx-06's supervisor protocol,\n// unchanged, so a running arx-06 is a sidecar target; extensions are\n// advertised in hello.abai.extensions.\nimport type { Manifest } from \"../manifest/manifest.ts\";\n\nexport const PROTOCOL_VERSION = 1;\n\n/**\n * The extensions a TypeScript stub speaks beyond the v1 core, named in\n * `hello.abai.extensions` so a client speaks each only when it is offered:\n * `consent` (consent stated on a request or hook answer), `content` (the\n * install, use and turn slots on `get_content`), `turns` (turns and\n * touchpoints as messages), `call_codes` (a code beside every error),\n * `defaults` (a `hook_response` whose `result` is null asks the program to\n * apply the decision's default, audited as a default; a v1-core host has no\n * such answer, so the client sends it the manifest default instead),\n * `lifecycle` (the `lifecycle {op}` command of section 5.5 and a cause on\n * `turn_end`), `messages` (the `record_message` command: the harness hands\n * the stub one message sent or received over the run's network for the\n * audit log, section 10).\n */\nexport const EXTENSIONS = [\"consent\", \"content\", \"turns\", \"call_codes\", \"defaults\", \"lifecycle\", \"messages\"] as const;\nexport type Extension = (typeof EXTENSIONS)[number];\n\n/** Why a request failed, in the capability error vocabulary (the `call_codes` extension). */\nexport type WireErrorCode = \"unknown\" | \"forbidden\" | \"denied\" | \"invalid\" | \"timeout\" | \"error\";\n\n// ---------------------------------------------------------------------------\n// Server -> client\n// ---------------------------------------------------------------------------\n\n/** The abai identity of the program, in `hello`. */\nexport interface HelloAbai {\n\tname: string;\n\tabaigrammar: string;\n\tmodes: string[];\n\taudit: { path: string; failed: string | null };\n\t/** Wire extensions beyond the v1 core; absent means none. */\n\textensions?: string[];\n}\n\nexport interface HelloMessage {\n\ttype: \"hello\";\n\tprotocol: number;\n\tpid: number;\n\t/** The program's own version string, when it has one. */\n\tversion?: string;\n\tcwd: string;\n\t/** A directory the program calls its own (arx-06's agent dir); absent for most programs. */\n\tagentDir?: string;\n\tmode: string;\n\t/** What this host offers: hooks and commands policy does not forbid. */\n\tcapabilities: { hooks: string[]; commands: string[] };\n\t/** Sequence number of the last event the host counted. */\n\tlastSeq: number;\n\t/** This connection's id (`k1`, `k2`, ...), as the audit log names it. */\n\tconnection: string;\n\tabai: HelloAbai;\n}\n\nexport type WireEvent = { type: string } & Record<string, unknown>;\n\nexport interface EventMessage {\n\ttype: \"event\";\n\tseq: number;\n\tts: number;\n\tevent: WireEvent;\n\t/** A sized field was cut to its declared max. An additive field; a v1-core client ignores it. */\n\ttruncated?: boolean;\n}\n\n/** A `snapshot` message some hosts send; parsed, its shape is the host's. */\nexport type LooseSnapshotMessage = { type: \"snapshot\" } & Record<string, unknown>;\n\n/** An event that could not be serialized was dropped; the program continues. */\nexport interface SerializeErrorMessage {\n\ttype: \"serialize_error\";\n\tseq: number;\n\tts: number;\n\teventType: string;\n\terror: string;\n}\n\nexport type WireResponse =\n\t| { type: \"response\"; id?: string; command: string; success: true; data?: unknown }\n\t| { type: \"response\"; id?: string; command: string; success: false; error: string; code?: WireErrorCode };\n\n/** Extension `turns`: the program gives the harness a turn; `turn_end` hands control back. */\nexport interface TurnMessage {\n\ttype: \"turn\";\n\tid: string;\n\tname: string;\n\t/** How long the program waits before the turn ends on its own. */\n\ttimeoutMs: number;\n\tcontent?: string;\n}\n\n/** Extension `turns`: a program-initiated `install` or `session`; `touchpoint_end` returns it. */\nexport interface TouchpointMessage {\n\ttype: \"touchpoint\";\n\tid: string;\n\tkind: \"install\" | \"session\";\n\tcontent?: string;\n}\n\n/** Interceptable hook round trip. Only sent to the connection holding the hook. */\nexport interface HookMessage {\n\ttype: \"hook\";\n\tid: string;\n\thook: string;\n\ttimeoutMs: number;\n\tpayload: unknown;\n}\n\nexport interface HookTimeoutMessage {\n\ttype: \"hook_timeout\";\n\thook: string;\n\tid: string;\n}\n\n/** The claimant's claims were dropped by the host (three consecutive timeouts). */\nexport interface HookClaimsReleasedMessage {\n\ttype: \"hook_claims_released\";\n\treason: string;\n\thooks: string[];\n}\n\n/**\n * A hook could not be served: the payload was not serializable (no `hook`\n * message was sent for this id) or the claimant's result failed validation.\n * The run continued as if the hook were unclaimed.\n */\nexport interface HookRejectedMessage {\n\ttype: \"hook_rejected\";\n\tid: string;\n\thook: string;\n\terror: string;\n}\n\nexport type ServerMessage =\n\t| HelloMessage\n\t| EventMessage\n\t| LooseSnapshotMessage\n\t| SerializeErrorMessage\n\t| WireResponse\n\t| HookMessage\n\t| HookTimeoutMessage\n\t| HookClaimsReleasedMessage\n\t| HookRejectedMessage\n\t| TurnMessage\n\t| TouchpointMessage;\n\n// ---------------------------------------------------------------------------\n// Client -> server\n// ---------------------------------------------------------------------------\n\n/**\n * Per-connection event filter. `include` restricts the stream to the listed\n * event types; `exclude` drops the listed types. A `subscribe` request\n * replaces the whole filter, so an omitted `exclude` means no exclusions.\n */\nexport interface SubscriptionFilter {\n\tinclude?: string[];\n\texclude?: string[];\n}\n\n/** The library's commands: the connection's own, the stub's, and the cells channel. */\nexport type LibraryCommand =\n\t// connection\n\t| { type: \"ping\" }\n\t| ({ type: \"subscribe\" } & SubscriptionFilter)\n\t| { type: \"claim_hooks\"; hooks: string[]; timeoutMs?: number }\n\t| { type: \"release_hooks\"; hooks?: string[] }\n\t// library\n\t| { type: \"get_manifest\" }\n\t| { type: \"get_content\" }\n\t| { type: \"get_audit\"; limit?: number }\n\t// cells (abaigrammar section 5.2)\n\t| { type: \"get_cells\" }\n\t| { type: \"set_cell\"; name: string; value: unknown }\n\t// lifecycle (abaigrammar section 5.5), the `lifecycle` extension: status always, pause and resume for a\n\t// cooperative pause, stop for the declared stop handler; start and restart are the launcher's own\n\t| { type: \"lifecycle\"; op: string };\n\n/**\n * Every command a client can send: the library commands, plus any capability\n * call sent as `{ type: <capability name>, ...params }`. The advertised list\n * is the host's (`hello.capabilities.commands`).\n */\nexport type WireCommand = LibraryCommand | ({ type: string } & Record<string, unknown>);\n\n/** Consent stated for an act whose policy is `confirm` (abaigrammar section 10); the `consent` extension. */\nexport type WireConsent = \"approved\" | \"auto\" | \"denied\";\n\nexport interface RequestMessage {\n\ttype: \"request\";\n\tid: string;\n\tcommand: WireCommand;\n\t/** The agent's stated reason for an act of control; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\nexport interface HookResponseMessage {\n\ttype: \"hook_response\";\n\tid: string;\n\tresult: unknown;\n\t/** The agent's stated reason for its answer; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\n/** Extension `turns`: the harness is done with a turn. `cause` says why the agent did nothing with it (`budget`). */\nexport interface TurnEndMessage {\n\ttype: \"turn_end\";\n\tid: string;\n\tcause?: string;\n}\n\n/** Extension `turns`: the harness is done with a touchpoint. */\nexport interface TouchpointEndMessage {\n\ttype: \"touchpoint_end\";\n\tid: string;\n}\n\nexport type ClientMessage = RequestMessage | HookResponseMessage | TurnEndMessage | TouchpointEndMessage;\n\n// ---------------------------------------------------------------------------\n// Response data of the library commands\n// ---------------------------------------------------------------------------\n\n/** `get_cells`: every cell's value (sized ones cut to their max) and the host's event sequence number. */\nexport interface GetCellsData {\n\tseq: number;\n\tcells: Record<string, unknown>;\n}\n\n/** `set_cell`: the knob and the value that landed (it may be clamped). */\nexport interface SetCellData {\n\tname: string;\n\tvalue: unknown;\n}\n\n/** `get_manifest`: the effective manifest of this running host. */\nexport interface GetManifestData {\n\tmanifest: Manifest;\n}\n\n/** `get_content`: the content slots the stub embeds (abaigrammar section 8). A v1-core host sends `identity` only. */\nexport interface GetContentData {\n\tidentity: string;\n\tinstall?: string;\n\tuse?: string;\n\tturns?: Record<string, string>;\n}\n\n/** `lifecycle {op: \"status\"}`: what the stub knows of its own process. */\nexport interface LifecycleStatusData {\n\tpid: number;\n\tname: string;\n\tmode: string;\n\tcwd: string;\n\tstartedAt: string;\n\tconnections: number;\n\tpaused: boolean;\n\t/** A launcher handed this program its connection, so the full lifecycle is available to it. */\n\tlaunched: boolean;\n}\n\n/** `get_audit`: the log's location and state, and its last records. */\nexport interface GetAuditData {\n\tpath: string;\n\tfailed: string | null;\n\trecords: unknown[];\n\t/** More records exist than were returned. */\n\ttruncated: boolean;\n}\n"]}
|
package/dist/wire/protocol.js
CHANGED
|
@@ -9,7 +9,9 @@ export const PROTOCOL_VERSION = 1;
|
|
|
9
9
|
* apply the decision's default, audited as a default; a v1-core host has no
|
|
10
10
|
* such answer, so the client sends it the manifest default instead),
|
|
11
11
|
* `lifecycle` (the `lifecycle {op}` command of section 5.5 and a cause on
|
|
12
|
-
* `turn_end`)
|
|
12
|
+
* `turn_end`), `messages` (the `record_message` command: the harness hands
|
|
13
|
+
* the stub one message sent or received over the run's network for the
|
|
14
|
+
* audit log, section 10).
|
|
13
15
|
*/
|
|
14
|
-
export const EXTENSIONS = ["consent", "content", "turns", "call_codes", "defaults", "lifecycle"];
|
|
16
|
+
export const EXTENSIONS = ["consent", "content", "turns", "call_codes", "defaults", "lifecycle", "messages"];
|
|
15
17
|
//# sourceMappingURL=protocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/wire/protocol.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,CAAU,CAAC","sourcesContent":["// abai wire protocol v1 (abaigrammar section 6.3): LF-framed JSON lines over a\n// local socket. The core is the generic part of arx-06's supervisor protocol,\n// unchanged, so a running arx-06 is a sidecar target; extensions are\n// advertised in hello.abai.extensions.\nimport type { Manifest } from \"../manifest/manifest.ts\";\n\nexport const PROTOCOL_VERSION = 1;\n\n/**\n * The extensions a TypeScript stub speaks beyond the v1 core, named in\n * `hello.abai.extensions` so a client speaks each only when it is offered:\n * `consent` (consent stated on a request or hook answer), `content` (the\n * install, use and turn slots on `get_content`), `turns` (turns and\n * touchpoints as messages), `call_codes` (a code beside every error),\n * `defaults` (a `hook_response` whose `result` is null asks the program to\n * apply the decision's default, audited as a default; a v1-core host has no\n * such answer, so the client sends it the manifest default instead),\n * `lifecycle` (the `lifecycle {op}` command of section 5.5 and a cause on\n * `turn_end`).\n */\nexport const EXTENSIONS = [\"consent\", \"content\", \"turns\", \"call_codes\", \"defaults\", \"lifecycle\"] as const;\nexport type Extension = (typeof EXTENSIONS)[number];\n\n/** Why a request failed, in the capability error vocabulary (the `call_codes` extension). */\nexport type WireErrorCode = \"unknown\" | \"forbidden\" | \"denied\" | \"invalid\" | \"timeout\" | \"error\";\n\n// ---------------------------------------------------------------------------\n// Server -> client\n// ---------------------------------------------------------------------------\n\n/** The abai identity of the program, in `hello`. */\nexport interface HelloAbai {\n\tname: string;\n\tabaigrammar: string;\n\tmodes: string[];\n\taudit: { path: string; failed: string | null };\n\t/** Wire extensions beyond the v1 core; absent means none. */\n\textensions?: string[];\n}\n\nexport interface HelloMessage {\n\ttype: \"hello\";\n\tprotocol: number;\n\tpid: number;\n\t/** The program's own version string, when it has one. */\n\tversion?: string;\n\tcwd: string;\n\t/** A directory the program calls its own (arx-06's agent dir); absent for most programs. */\n\tagentDir?: string;\n\tmode: string;\n\t/** What this host offers: hooks and commands policy does not forbid. */\n\tcapabilities: { hooks: string[]; commands: string[] };\n\t/** Sequence number of the last event the host counted. */\n\tlastSeq: number;\n\t/** This connection's id (`k1`, `k2`, ...), as the audit log names it. */\n\tconnection: string;\n\tabai: HelloAbai;\n}\n\nexport type WireEvent = { type: string } & Record<string, unknown>;\n\nexport interface EventMessage {\n\ttype: \"event\";\n\tseq: number;\n\tts: number;\n\tevent: WireEvent;\n\t/** A sized field was cut to its declared max. An additive field; a v1-core client ignores it. */\n\ttruncated?: boolean;\n}\n\n/** A `snapshot` message some hosts send; parsed, its shape is the host's. */\nexport type LooseSnapshotMessage = { type: \"snapshot\" } & Record<string, unknown>;\n\n/** An event that could not be serialized was dropped; the program continues. */\nexport interface SerializeErrorMessage {\n\ttype: \"serialize_error\";\n\tseq: number;\n\tts: number;\n\teventType: string;\n\terror: string;\n}\n\nexport type WireResponse =\n\t| { type: \"response\"; id?: string; command: string; success: true; data?: unknown }\n\t| { type: \"response\"; id?: string; command: string; success: false; error: string; code?: WireErrorCode };\n\n/** Extension `turns`: the program gives the harness a turn; `turn_end` hands control back. */\nexport interface TurnMessage {\n\ttype: \"turn\";\n\tid: string;\n\tname: string;\n\t/** How long the program waits before the turn ends on its own. */\n\ttimeoutMs: number;\n\tcontent?: string;\n}\n\n/** Extension `turns`: a program-initiated `install` or `session`; `touchpoint_end` returns it. */\nexport interface TouchpointMessage {\n\ttype: \"touchpoint\";\n\tid: string;\n\tkind: \"install\" | \"session\";\n\tcontent?: string;\n}\n\n/** Interceptable hook round trip. Only sent to the connection holding the hook. */\nexport interface HookMessage {\n\ttype: \"hook\";\n\tid: string;\n\thook: string;\n\ttimeoutMs: number;\n\tpayload: unknown;\n}\n\nexport interface HookTimeoutMessage {\n\ttype: \"hook_timeout\";\n\thook: string;\n\tid: string;\n}\n\n/** The claimant's claims were dropped by the host (three consecutive timeouts). */\nexport interface HookClaimsReleasedMessage {\n\ttype: \"hook_claims_released\";\n\treason: string;\n\thooks: string[];\n}\n\n/**\n * A hook could not be served: the payload was not serializable (no `hook`\n * message was sent for this id) or the claimant's result failed validation.\n * The run continued as if the hook were unclaimed.\n */\nexport interface HookRejectedMessage {\n\ttype: \"hook_rejected\";\n\tid: string;\n\thook: string;\n\terror: string;\n}\n\nexport type ServerMessage =\n\t| HelloMessage\n\t| EventMessage\n\t| LooseSnapshotMessage\n\t| SerializeErrorMessage\n\t| WireResponse\n\t| HookMessage\n\t| HookTimeoutMessage\n\t| HookClaimsReleasedMessage\n\t| HookRejectedMessage\n\t| TurnMessage\n\t| TouchpointMessage;\n\n// ---------------------------------------------------------------------------\n// Client -> server\n// ---------------------------------------------------------------------------\n\n/**\n * Per-connection event filter. `include` restricts the stream to the listed\n * event types; `exclude` drops the listed types. A `subscribe` request\n * replaces the whole filter, so an omitted `exclude` means no exclusions.\n */\nexport interface SubscriptionFilter {\n\tinclude?: string[];\n\texclude?: string[];\n}\n\n/** The library's commands: the connection's own, the stub's, and the cells channel. */\nexport type LibraryCommand =\n\t// connection\n\t| { type: \"ping\" }\n\t| ({ type: \"subscribe\" } & SubscriptionFilter)\n\t| { type: \"claim_hooks\"; hooks: string[]; timeoutMs?: number }\n\t| { type: \"release_hooks\"; hooks?: string[] }\n\t// library\n\t| { type: \"get_manifest\" }\n\t| { type: \"get_content\" }\n\t| { type: \"get_audit\"; limit?: number }\n\t// cells (abaigrammar section 5.2)\n\t| { type: \"get_cells\" }\n\t| { type: \"set_cell\"; name: string; value: unknown }\n\t// lifecycle (abaigrammar section 5.5), the `lifecycle` extension: status always, pause and resume for a\n\t// cooperative pause, stop for the declared stop handler; start and restart are the launcher's own\n\t| { type: \"lifecycle\"; op: string };\n\n/**\n * Every command a client can send: the library commands, plus any capability\n * call sent as `{ type: <capability name>, ...params }`. The advertised list\n * is the host's (`hello.capabilities.commands`).\n */\nexport type WireCommand = LibraryCommand | ({ type: string } & Record<string, unknown>);\n\n/** Consent stated for an act whose policy is `confirm` (abaigrammar section 10); the `consent` extension. */\nexport type WireConsent = \"approved\" | \"auto\" | \"denied\";\n\nexport interface RequestMessage {\n\ttype: \"request\";\n\tid: string;\n\tcommand: WireCommand;\n\t/** The agent's stated reason for an act of control; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\nexport interface HookResponseMessage {\n\ttype: \"hook_response\";\n\tid: string;\n\tresult: unknown;\n\t/** The agent's stated reason for its answer; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\n/** Extension `turns`: the harness is done with a turn. `cause` says why the agent did nothing with it (`budget`). */\nexport interface TurnEndMessage {\n\ttype: \"turn_end\";\n\tid: string;\n\tcause?: string;\n}\n\n/** Extension `turns`: the harness is done with a touchpoint. */\nexport interface TouchpointEndMessage {\n\ttype: \"touchpoint_end\";\n\tid: string;\n}\n\nexport type ClientMessage = RequestMessage | HookResponseMessage | TurnEndMessage | TouchpointEndMessage;\n\n// ---------------------------------------------------------------------------\n// Response data of the library commands\n// ---------------------------------------------------------------------------\n\n/** `get_cells`: every cell's value (sized ones cut to their max) and the host's event sequence number. */\nexport interface GetCellsData {\n\tseq: number;\n\tcells: Record<string, unknown>;\n}\n\n/** `set_cell`: the knob and the value that landed (it may be clamped). */\nexport interface SetCellData {\n\tname: string;\n\tvalue: unknown;\n}\n\n/** `get_manifest`: the effective manifest of this running host. */\nexport interface GetManifestData {\n\tmanifest: Manifest;\n}\n\n/** `get_content`: the content slots the stub embeds (abaigrammar section 8). A v1-core host sends `identity` only. */\nexport interface GetContentData {\n\tidentity: string;\n\tinstall?: string;\n\tuse?: string;\n\tturns?: Record<string, string>;\n}\n\n/** `lifecycle {op: \"status\"}`: what the stub knows of its own process. */\nexport interface LifecycleStatusData {\n\tpid: number;\n\tname: string;\n\tmode: string;\n\tcwd: string;\n\tstartedAt: string;\n\tconnections: number;\n\tpaused: boolean;\n\t/** A launcher handed this program its connection, so the full lifecycle is available to it. */\n\tlaunched: boolean;\n}\n\n/** `get_audit`: the log's location and state, and its last records. */\nexport interface GetAuditData {\n\tpath: string;\n\tfailed: string | null;\n\trecords: unknown[];\n\t/** More records exist than were returned. */\n\ttruncated: boolean;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../src/wire/protocol.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAElC;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,CAAU,CAAC","sourcesContent":["// abai wire protocol v1 (abaigrammar section 6.3): LF-framed JSON lines over a\n// local socket. The core is the generic part of arx-06's supervisor protocol,\n// unchanged, so a running arx-06 is a sidecar target; extensions are\n// advertised in hello.abai.extensions.\nimport type { Manifest } from \"../manifest/manifest.ts\";\n\nexport const PROTOCOL_VERSION = 1;\n\n/**\n * The extensions a TypeScript stub speaks beyond the v1 core, named in\n * `hello.abai.extensions` so a client speaks each only when it is offered:\n * `consent` (consent stated on a request or hook answer), `content` (the\n * install, use and turn slots on `get_content`), `turns` (turns and\n * touchpoints as messages), `call_codes` (a code beside every error),\n * `defaults` (a `hook_response` whose `result` is null asks the program to\n * apply the decision's default, audited as a default; a v1-core host has no\n * such answer, so the client sends it the manifest default instead),\n * `lifecycle` (the `lifecycle {op}` command of section 5.5 and a cause on\n * `turn_end`), `messages` (the `record_message` command: the harness hands\n * the stub one message sent or received over the run's network for the\n * audit log, section 10).\n */\nexport const EXTENSIONS = [\"consent\", \"content\", \"turns\", \"call_codes\", \"defaults\", \"lifecycle\", \"messages\"] as const;\nexport type Extension = (typeof EXTENSIONS)[number];\n\n/** Why a request failed, in the capability error vocabulary (the `call_codes` extension). */\nexport type WireErrorCode = \"unknown\" | \"forbidden\" | \"denied\" | \"invalid\" | \"timeout\" | \"error\";\n\n// ---------------------------------------------------------------------------\n// Server -> client\n// ---------------------------------------------------------------------------\n\n/** The abai identity of the program, in `hello`. */\nexport interface HelloAbai {\n\tname: string;\n\tabaigrammar: string;\n\tmodes: string[];\n\taudit: { path: string; failed: string | null };\n\t/** Wire extensions beyond the v1 core; absent means none. */\n\textensions?: string[];\n}\n\nexport interface HelloMessage {\n\ttype: \"hello\";\n\tprotocol: number;\n\tpid: number;\n\t/** The program's own version string, when it has one. */\n\tversion?: string;\n\tcwd: string;\n\t/** A directory the program calls its own (arx-06's agent dir); absent for most programs. */\n\tagentDir?: string;\n\tmode: string;\n\t/** What this host offers: hooks and commands policy does not forbid. */\n\tcapabilities: { hooks: string[]; commands: string[] };\n\t/** Sequence number of the last event the host counted. */\n\tlastSeq: number;\n\t/** This connection's id (`k1`, `k2`, ...), as the audit log names it. */\n\tconnection: string;\n\tabai: HelloAbai;\n}\n\nexport type WireEvent = { type: string } & Record<string, unknown>;\n\nexport interface EventMessage {\n\ttype: \"event\";\n\tseq: number;\n\tts: number;\n\tevent: WireEvent;\n\t/** A sized field was cut to its declared max. An additive field; a v1-core client ignores it. */\n\ttruncated?: boolean;\n}\n\n/** A `snapshot` message some hosts send; parsed, its shape is the host's. */\nexport type LooseSnapshotMessage = { type: \"snapshot\" } & Record<string, unknown>;\n\n/** An event that could not be serialized was dropped; the program continues. */\nexport interface SerializeErrorMessage {\n\ttype: \"serialize_error\";\n\tseq: number;\n\tts: number;\n\teventType: string;\n\terror: string;\n}\n\nexport type WireResponse =\n\t| { type: \"response\"; id?: string; command: string; success: true; data?: unknown }\n\t| { type: \"response\"; id?: string; command: string; success: false; error: string; code?: WireErrorCode };\n\n/** Extension `turns`: the program gives the harness a turn; `turn_end` hands control back. */\nexport interface TurnMessage {\n\ttype: \"turn\";\n\tid: string;\n\tname: string;\n\t/** How long the program waits before the turn ends on its own. */\n\ttimeoutMs: number;\n\tcontent?: string;\n}\n\n/** Extension `turns`: a program-initiated `install` or `session`; `touchpoint_end` returns it. */\nexport interface TouchpointMessage {\n\ttype: \"touchpoint\";\n\tid: string;\n\tkind: \"install\" | \"session\";\n\tcontent?: string;\n}\n\n/** Interceptable hook round trip. Only sent to the connection holding the hook. */\nexport interface HookMessage {\n\ttype: \"hook\";\n\tid: string;\n\thook: string;\n\ttimeoutMs: number;\n\tpayload: unknown;\n}\n\nexport interface HookTimeoutMessage {\n\ttype: \"hook_timeout\";\n\thook: string;\n\tid: string;\n}\n\n/** The claimant's claims were dropped by the host (three consecutive timeouts). */\nexport interface HookClaimsReleasedMessage {\n\ttype: \"hook_claims_released\";\n\treason: string;\n\thooks: string[];\n}\n\n/**\n * A hook could not be served: the payload was not serializable (no `hook`\n * message was sent for this id) or the claimant's result failed validation.\n * The run continued as if the hook were unclaimed.\n */\nexport interface HookRejectedMessage {\n\ttype: \"hook_rejected\";\n\tid: string;\n\thook: string;\n\terror: string;\n}\n\nexport type ServerMessage =\n\t| HelloMessage\n\t| EventMessage\n\t| LooseSnapshotMessage\n\t| SerializeErrorMessage\n\t| WireResponse\n\t| HookMessage\n\t| HookTimeoutMessage\n\t| HookClaimsReleasedMessage\n\t| HookRejectedMessage\n\t| TurnMessage\n\t| TouchpointMessage;\n\n// ---------------------------------------------------------------------------\n// Client -> server\n// ---------------------------------------------------------------------------\n\n/**\n * Per-connection event filter. `include` restricts the stream to the listed\n * event types; `exclude` drops the listed types. A `subscribe` request\n * replaces the whole filter, so an omitted `exclude` means no exclusions.\n */\nexport interface SubscriptionFilter {\n\tinclude?: string[];\n\texclude?: string[];\n}\n\n/** The library's commands: the connection's own, the stub's, and the cells channel. */\nexport type LibraryCommand =\n\t// connection\n\t| { type: \"ping\" }\n\t| ({ type: \"subscribe\" } & SubscriptionFilter)\n\t| { type: \"claim_hooks\"; hooks: string[]; timeoutMs?: number }\n\t| { type: \"release_hooks\"; hooks?: string[] }\n\t// library\n\t| { type: \"get_manifest\" }\n\t| { type: \"get_content\" }\n\t| { type: \"get_audit\"; limit?: number }\n\t// cells (abaigrammar section 5.2)\n\t| { type: \"get_cells\" }\n\t| { type: \"set_cell\"; name: string; value: unknown }\n\t// lifecycle (abaigrammar section 5.5), the `lifecycle` extension: status always, pause and resume for a\n\t// cooperative pause, stop for the declared stop handler; start and restart are the launcher's own\n\t| { type: \"lifecycle\"; op: string };\n\n/**\n * Every command a client can send: the library commands, plus any capability\n * call sent as `{ type: <capability name>, ...params }`. The advertised list\n * is the host's (`hello.capabilities.commands`).\n */\nexport type WireCommand = LibraryCommand | ({ type: string } & Record<string, unknown>);\n\n/** Consent stated for an act whose policy is `confirm` (abaigrammar section 10); the `consent` extension. */\nexport type WireConsent = \"approved\" | \"auto\" | \"denied\";\n\nexport interface RequestMessage {\n\ttype: \"request\";\n\tid: string;\n\tcommand: WireCommand;\n\t/** The agent's stated reason for an act of control; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\nexport interface HookResponseMessage {\n\ttype: \"hook_response\";\n\tid: string;\n\tresult: unknown;\n\t/** The agent's stated reason for its answer; written to the audit log. */\n\treason?: string;\n\t/** Extension `consent`: ignored by a v1-core host. */\n\tconsent?: WireConsent;\n}\n\n/** Extension `turns`: the harness is done with a turn. `cause` says why the agent did nothing with it (`budget`). */\nexport interface TurnEndMessage {\n\ttype: \"turn_end\";\n\tid: string;\n\tcause?: string;\n}\n\n/** Extension `turns`: the harness is done with a touchpoint. */\nexport interface TouchpointEndMessage {\n\ttype: \"touchpoint_end\";\n\tid: string;\n}\n\nexport type ClientMessage = RequestMessage | HookResponseMessage | TurnEndMessage | TouchpointEndMessage;\n\n// ---------------------------------------------------------------------------\n// Response data of the library commands\n// ---------------------------------------------------------------------------\n\n/** `get_cells`: every cell's value (sized ones cut to their max) and the host's event sequence number. */\nexport interface GetCellsData {\n\tseq: number;\n\tcells: Record<string, unknown>;\n}\n\n/** `set_cell`: the knob and the value that landed (it may be clamped). */\nexport interface SetCellData {\n\tname: string;\n\tvalue: unknown;\n}\n\n/** `get_manifest`: the effective manifest of this running host. */\nexport interface GetManifestData {\n\tmanifest: Manifest;\n}\n\n/** `get_content`: the content slots the stub embeds (abaigrammar section 8). A v1-core host sends `identity` only. */\nexport interface GetContentData {\n\tidentity: string;\n\tinstall?: string;\n\tuse?: string;\n\tturns?: Record<string, string>;\n}\n\n/** `lifecycle {op: \"status\"}`: what the stub knows of its own process. */\nexport interface LifecycleStatusData {\n\tpid: number;\n\tname: string;\n\tmode: string;\n\tcwd: string;\n\tstartedAt: string;\n\tconnections: number;\n\tpaused: boolean;\n\t/** A launcher handed this program its connection, so the full lifecycle is available to it. */\n\tlaunched: boolean;\n}\n\n/** `get_audit`: the log's location and state, and its last records. */\nexport interface GetAuditData {\n\tpath: string;\n\tfailed: string | null;\n\trecords: unknown[];\n\t/** More records exist than were returned. */\n\ttruncated: boolean;\n}\n"]}
|