UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

78 lines • 4.22 kB
"use strict"; /** * hosting/wireOps — the ONE list of operations a request body's `op` may name. * * A hosting request is ordinarily a MESSAGE. Some are not: since 9.23 a body * carrying `{ op: 'artifact-head' | 'artifact-get', ref }` redeems a claim * ticket, and since 9.26 one carrying `{ op: 'session-list' }` or * `{ op: 'session-transcript', sessionId }` asks the verified caller's own * conversation history. Two DOMAINS now share one field. (`answer-account` * belongs to the artifact domain: it names a claim ticket, and its reader is * `readArtifactWireOp`.) * * That is exactly the shape where a grammar quietly forks. Each domain has its * own reader (`readArtifactWireOp`, `readSessionWireOp`), each reader must * decline the other domain's ops without claiming them — and somebody has to * own "this is not an op anybody speaks", which is the refusal that keeps a * typo from becoming a conversation turn with a ref as its input. * * So the names live here, once, and both readers ask this module the two * questions they cannot answer alone: *is this somebody's op?* and *what do we * say when it is nobody's?* Either reader produces the same refusal, listing * the same operations, in the same words — so the answer never depends on which * dialect happened to call which reader first. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.refuseUnknownWireOp = exports.isWireOp = exports.ALL_WIRE_OPS = exports.WIRE_OPS = void 0; const errors_js_1 = require("./errors.js"); /** * Every operation this package's wire grammar knows, keyed by the name the code * uses for it. The VALUES are the wire spelling — a body says `op: * 'artifact-head'`, because a field named `op` has to say which domain it * belongs to. */ exports.WIRE_OPS = { /** The claim ticket's metadata — the render-by-ref decision (9.23.0). */ artifactHead: 'artifact-head', /** Metadata + the payload (9.23.0). */ artifactGet: 'artifact-get', /** * One answer's plain-words account, computed on the server from the * recording the ref names (explain-answer). Spoken only by a host that opted * in with `standingAgent({ answerAccounts })`. */ answerAccount: 'answer-account', /** The verified caller's own sessions (9.26.0). */ sessionList: 'session-list', /** One owned session's message history (9.26.0). */ sessionTranscript: 'session-transcript', /** The question currently outstanding on one session, without its checkpoint. */ sessionPending: 'session-pending', }; /** Every op name, in the order a refusal lists them. */ exports.ALL_WIRE_OPS = Object.values(exports.WIRE_OPS); /** Is this string an operation some reader in this package owns? */ function isWireOp(candidate) { return typeof candidate === 'string' && exports.ALL_WIRE_OPS.includes(candidate); } exports.isWireOp = isWireOp; /** * The ONE refusal for a body that named an operation nobody speaks. * * A caller who typo'd `'artifact-hed'` and silently got a conversation turn * (with the ref as garbage input) is the accepted-and-silently-wrong failure * this exists to prevent: a body that NAMES an op never falls through to a * model turn. `httpHost` answers it as that request's 400. */ function refuseUnknownWireOp(op) { throw new errors_js_1.InvalidWireOpError(`the wire operation '${String(op)}' is not one this host speaks. Known operations: ` + `'${exports.WIRE_OPS.artifactHead}' (a claim ticket's metadata) and '${exports.WIRE_OPS.artifactGet}' ` + `(metadata + payload), each taking { ref }; '${exports.WIRE_OPS.answerAccount}' (one answer's ` + `plain-words account, taking { ref }, on a host that opted in with ` + `standingAgent({ answerAccounts })); '${exports.WIRE_OPS.sessionList}' (the verified ` + `caller's own sessions) and '${exports.WIRE_OPS.sessionTranscript}' (one owned session's ` + `messages, taking { sessionId }); '${exports.WIRE_OPS.sessionPending}' (the current question, ` + `taking { sessionId }). A request without 'op' is an ordinary invoke.`); } exports.refuseUnknownWireOp = refuseUnknownWireOp; //# sourceMappingURL=wireOps.js.map