@orkestrel/scaffold 0.0.130 → 0.0.131
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/bin/main.js +39 -36
- package/dist/bin/main.js.map +1 -1
- package/dist/host/agents/platforms/windows.md +1 -0
- package/dist/host/agents/skills/orkestrel-polish/SKILL.md +1 -0
- package/dist/host/claude/agents/orkestrel.md +5 -5
- package/dist/host/claude/rules/patterns.md +2 -0
- package/dist/host/guides/agent.md +228 -152
- package/dist/host/guides/scaffold.md +13 -6
- package/dist/host/manifest.json +7 -7
- package/dist/src/core/index.cjs +14 -7
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +5 -2
- package/dist/src/core/index.d.ts +5 -2
- package/dist/src/core/index.js +14 -7
- package/dist/src/core/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -614,13 +614,14 @@ Run the ledger's agent only through the `respond` method: the ledger's agent ser
|
|
|
614
614
|
The method has the following pieces, each named by its export:
|
|
615
615
|
|
|
616
616
|
- **The filing.** The `Classifier` class files each message through the judge the `judge` option injects. A user message carrying an id or a number, as read by `extractLiterals`, stays non-quiet regardless of its recorded weights. If its winning category is quiet, `category` returns `undefined`; this floor supplies no fact, rule, or correction judgment. Shape assignments keep their categories. Hydrating recorded judgments applies the same floor, and the next filing asks the topic questions those messages previously skipped. The ledger files a tool result, its own notes, an assistant call, and an assistant reply after the first request by their shape, and asks the judge about the rest: the `LEDGER_QUESTIONS` category question about each remaining non-request message, and the topic question, for each desk topic, about each non-quiet statement and each request unless that topic has `requested: false`; and the `amends` question about a later user message whose `correction` probability reaches the `correction` cutoff and an earlier message that isn't quiet and shares an id, an owner, or a desk topic with it, followed by the `supersedes` question about the same pair when the `amends` answer reaches its cutoff. The `narrow` member of the `correction` option keeps only the eligible earlier messages that also share a registry entity with the correction or an id or a number in their content, so a desk topic alone admits no pair, and a correction with no id, owner, or desk topic still asks no pair. On a scripted support-desk conversation recorded on 2026-11-03 with the Mica v0.1 4B judge on Ollama 0.40.14, `narrow` took 24 judge calls and 45 s against 68 and 136 s at a correction in 199 messages of 285889 characters (median 577, 95th percentile 5111, maximum 10059), and 26 judge calls and 45 s against 109 and 196 s at a correction in 290 messages of 539538 characters (median 583, 95th percentile 5906, maximum 32883). Those calls include the category and topic questions `narrow` leaves in place. Filings were equal at those two corrections, on 5 pairs and 1 supersession. A third correction, forecast from recorded answers and not run, lost 0 of 8 pairs. The 173 pairs `narrow` drops across the three, 196 questions, filed 0 on recorded answers, on text whose corrections repeat a literal by construction, and the registry-entity path admitted no pair on this recording. A true supersession outside that set is never asked, and no run on any model measures how often one occurs. Set `narrow` when a correction's wait costs more than a missed supersession and your corrections repeat the id, number, or looked-up entity they correct. Leave it off for a host with no lookups or with free-text values. Every answer lands in the conversation's `judgments` store, so a later request asks only what no earlier one asked. Under the default `strict`, a judge failure rejects the `respond` call it belongs to, after the `fault` event, and holds nothing, so the next request asks the judge again about every question still unanswered. A failure that repeats rejects that request too, so a question the judge always refuses stops each request until you remove its message or set `strict: false`. Under `strict: false`, a judge failure leaves its question unanswered, and the next request asks it again, except for two failures that hold the question so that no later request asks it: a refused question, which the judge reports as a `JudgeError` with code `'QUESTION'`, and the deterministic logprob failure the `DETERMINISTIC_JUDGE_ERROR` constant matches. The `LedgerClassification` value ignores amendment and supersession marks whose later message is quiet and reads the remaining filing back at the cutoffs: an `amends` answer at its cutoff marks a pair amended only when the two messages share an id or a number, and a `supersedes` answer at its cutoff marks the pair superseded and amended whatever they share. Each `classify` call also returns one `ClassifierAttempt` value per logical filing question it attempted, in asking order, and observes the filing without changing it. An attempt names the question's key and its `ClassifierPhase` value, and its `ClassifierOutcome` value says whether the conversation already held the judgment (`cached`), the classifier held the question after a deterministic failure or because a message it names left the conversation (`skipped`), or the judgment manager's `resolve` call fulfilled (`resolved`), rejected under a live signal (`failed`), or was cut short by an abort (`aborted`). A `resolved`, `failed`, or `aborted` attempt carries the monotonic milliseconds the classifier waited on that call as `duration`, and a `cached` or `skipped` attempt carries none. A question that a caller abort preceded has no attempt, because it never began. The attempts count logical questions and resolve requests, never the physical wire calls a judge makes for them, and they record no join of pending requests. The `attempts` member of the `LedgerResult` value holds the attempts of the filing selections of that `respond` call alone; the `Selection` values the ledger emits carry none. A page passes `agent: { scheduler: createBrowserScheduler() }` from `@orkestrel/workflow/browser`, so the classifier hands the host a turn each time the `LEDGER_SLICE` constant's milliseconds have run while it files, and the plan after the filing still runs as one task; a page that omits the option also runs each stretch of cached filing as one task, and the host gets a turn only while the classifier waits on the judge. A direct `agent.context.select` for the same request during a paced filing's yield rejects with `AgentError` `'CONCURRENCY'`, and one for a message the call does not own returns a selection whose `fault` is `LedgerError` `'REQUEST'`. A `classify` call reads each message's quiet flag and near set at most once while it pairs corrections, so a judgment or message written during a pair-phase await reads at the next `classify` call, and `LedgerLookup.read` runs one time per tool message for each plan, each `recall` call, and each filing pass. The **What a cancel waits for.** bullet under [Production behaviors of automatic compaction](#production-behaviors-of-automatic-compaction) applies to this filing: what it names holds the run, and on a ledger its held scan, until it returns.
|
|
617
|
-
- **The records.** The `buildRecords` helper projects the filing into one `LedgerRecord` value per owner a lookup result names, plus one rules record for the rules and corrections no owner claims. Each line is a sentence of a live message, verbatim except that a sentence that opens with a pronoun opens with its party and a colon. A message filed quiet or superseded isn't live. Accepted message-level amendments preserve every original indexed sentence of live earlier sources; the projection lists distinct accepted edges in its `amendments` member. Sentence scope remains unresolved. The `recall` tool and the answer note keep the stored content of each message they carry. The seed tail keeps stored content except for lookup results, which the plan replaces with stubs.
|
|
617
|
+
- **The records.** The `buildRecords` helper projects the filing into one `LedgerRecord` value per owner a lookup result names, plus one rules record for the rules and corrections no owner claims. Each line is a sentence of a live message, verbatim except that a sentence that opens with a pronoun opens with its party and a colon. A message filed quiet or superseded isn't live. Accepted message-level amendments preserve every original indexed sentence of live earlier sources; the projection lists distinct accepted edges in its `amendments` member. Sentence scope remains unresolved. The `recall` tool and the answer note keep the stored content of each message they carry. The seed tail keeps stored content except for lookup results, which the plan replaces with stubs. A write files its result as a finding, as a lookup does, and the finding supersedes every earlier finding whose ids or owner ids meet its `targets`, and every such finding without targets in its own tool group, which the `collectWriteSupersessions` helper reads and the `mergeSupersessions` helper merges into the filing. So the reads a write made stale leave the records, its own lines join their owner record, and a write that names no owner joins the owner record of the read it retired.
|
|
618
618
|
- **Amendment scope.** The first retained occurrence of an amended source opens with its `[N]` reference and a note on its later changes. Distinct retained sources receive decimal references starting at 1 in first-occurrence emission order, after deduplication. References are local to one rendering of the records and are recomputed after each trim; omitted sources do not shift them. A copy that follows a window numbers its sources after the ones the window holds, so one reference names one source across the window and that copy. Repeated occurrences share one reference. Recall and storage retain original source IDs. Authored content is unchanged. A fully included later source opens with its own [M] reference, and the earlier source's note reads “Changed later by [M].” If any effective correction is absent or partial, the note reads “A later change is not shown.” The omission note exposes no omitted identity, text, owner, or count. Completeness uses every original sentence identity after source deduplication and each trim; annotations count against the existing room. An edge whose amender a newer message superseded points at that amender's newest live successor, followed through accepted supersessions alone, so a change fully received by the records is not called not shown. With no live successor, the edge keeps its endpoint, which reads as absent. Neither restores the superseded text. An amendment of an amender infers no edge to the earlier message. Earlier text can conflict with its correction; downstream correction application and semantic sentence withdrawal remain unproved.
|
|
619
|
-
- **The plan.** For each request, the ledger selects the records the request names through the `selectRecords` helper and fits the built head (the system message and the context message), the tail, and the copy of the request turn that carries the records inside a token budget: the `capacity` option less the `predict` option, times the `prompt` share, less the overhead cost of the gauge and held back by the `LEDGER_SCALE_DRIFT` constant, of which the seed tail takes at most the `tail` share. The `tail` share bounds only the seed. Owner records with the same member ids in the same order render once, under their titles joined with `; `; before trimming, the view keeps the first requested record's key, members, and lines. The projection and held sources stay unchanged. The plan budget bounds the records, the tail, and the window of a request's first call: it prices the built head, the tail, the window, and the copy with its records and images. Runtime recall and recovery fit their result groups separately. A request, a lookup result, or a faulted selection's whole view can still exceed the budget. The plan prices each lookup stub in the tail at the longer of its `shown` and `hidden` forms, so a tail that fits the plan still fits after the window and the copy decide which results they show. The `share` option sets both shares, and the `DEFAULT_LEDGER_SHARE` constant holds the defaults. Until the records fit, the ledger drops the rules off the request's topics, then the sources outside the selected records, then the rules on its topics, then the owner lines. Inside an owner record, it drops the lines whose source isn't a rule or a correction first, oldest first, then the lines of rules and corrections, oldest first. The `Gauge` class prices the prompt; without the `gauge` option, the ledger calibrates before its first pass, and the `calibrate` method measures the price on demand. A lookup in the tail reaches the model as the stub the `renderStub` helper writes, which reads `shown` when the window and the copy together hold its whole result or the whole result of a finding with the same canonical lookup identity and text. The plan reaches the agent as a `Selection` value whose `messages` member is the tail, then each exchange in the window, then the copy of the request turn that the `buildRequestMessage` helper writes: the record lines the window doesn't hold, a blank line, a `## Request` heading, and the request. A copy with no line to add is the request itself. The answer pass carries the same copy, and the stored request keeps its own content.
|
|
619
|
+
- **The plan.** For each request, the ledger selects the records the request names through the `selectRecords` helper and fits the built head (the system message and the context message), the tail, and the copy of the request turn that carries the records inside a token budget: the `capacity` option less the `predict` option, times the `prompt` share, less the overhead cost of the gauge and held back by the `LEDGER_SCALE_DRIFT` constant, of which the seed tail takes at most the `tail` share. The `tail` share bounds only the seed. Owner records with the same member ids in the same order render once, under their titles joined with `; `; before trimming, the view keeps the first requested record's key, members, and lines. The projection and held sources stay unchanged. The plan budget bounds the records, the tail, and the window of a request's first call: it prices the built head, the tail, the window, and the copy with its records and images. Runtime recall and recovery fit their result groups separately. A request, a lookup result, or a faulted selection's whole view can still exceed the budget. The plan prices each lookup stub in the tail at the longer of its `shown` and `hidden` forms, so a tail that fits the plan still fits after the window and the copy decide which results they show. The `share` option sets both shares, and the `DEFAULT_LEDGER_SHARE` constant holds the defaults. Until the records fit, the ledger drops the rules off the request's topics, then the sources outside the selected records, then the rules on its topics, then the owner lines. Inside an owner record, it drops the lines whose source isn't a rule or a correction first, oldest first, then the lines of rules and corrections, oldest first. The `Gauge` class prices the prompt; without the `gauge` option or a snapshot gauge priced on the same tool definitions, the ledger calibrates before its first pass, and the `calibrate` method measures the price on demand and records the digest of the definitions it priced. A lookup in the tail reaches the model as the stub the `renderStub` helper writes, which reads `shown` when the window and the copy together hold its whole result or the whole result of a finding with the same canonical lookup identity and text. The plan reaches the agent as a `Selection` value whose `messages` member is the tail, then each exchange in the window, then the copy of the request turn that the `buildRequestMessage` helper writes: the record lines the window doesn't hold, a blank line, a `## Request` heading, and the request. A copy with no line to add is the request itself. The answer pass carries the same copy, and the stored request keeps its own content.
|
|
620
620
|
- **The window.** The ledger holds one `LedgerExchange` value per completed exchange: the request as it was sent, its final reply, and the record lines that copy rendered. Each prompt sends those exchanges in order, so a prompt extends the one before it, within the limits the **A follow-up can read the reply again.** bullet names. A copy holds only the record lines the window doesn't hold, matched by identity and never by text, so identical words under another source render with their own attribution. A titled record's line is held by record, source, and sentence, so a source under another owner's record renders again for its attribution. A line of a source outside the selected records, which renders under no title, is held by source and sentence under any placement, so it doesn't repeat what an earlier copy printed under a title. A line the window holds stays held whether or not a later request selects its record. The seed and the records are planned without the window, so the window spends only the spare room of the plan's total and never displaces a record line or a seed message. The plan prices the following rungs in order and sends the first whose prompt fits the total and, if that rung offers `recall`, leaves an open recall open: the whole window with a copy of the lines it doesn't hold, then the newest exchange with its request plain and a copy of every selected line, then no exchange and a copy of every selected line. When no rung meets both tests, the plan sends no exchange. A recall already closed with no exchange at all doesn't prevent admission. A fall to a lower rung is silent, with no note, and an answered request leaves the window as what it sent plus its own exchange, so the exchanges a fall left out don't return. An admitted window can reduce recall listing room without closing recall. Admission retains its reserve forecast. Runtime recall reads reported usage when available, including completion and replayed thinking, and fits its result without that reserve veto. The window empties when a message it holds changes or leaves the conversation, when a source it holds leaves the records, when the accepted amendments touching a message it holds change, when a request no longer pairs with the reply held for it, or when this request's lines would change an amendment note or reference an earlier copy printed. A source missing from this request's selected records empties nothing. An empty window derives the newest request and its final reply from the conversation, with the request plain, or nothing when the newest request holds no valid reply. A window a change empties keeps its last exchange, with the request plain, when the derive gives nothing because a later request failed and that exchange's reply still stands, so a stopped request doesn't lose the reply a person read. It never carries a removed reply, and it never falls back to an exchange older than that. A derived pair seats before the request is sent. A request that rejects or ends with no reply leaves the window as it stands, a seated derived pair included, so the next prompt holds the last good exchange. A request answered through the whole view under `strict: false` joins with its stored request plain and no lines. Tool calls, tool results, and ledger notes never enter the window, so a request that called a tool joins as its copy and its final reply.
|
|
621
|
-
- **The `recall` tool.** The tool requires a nonempty topic string; an empty topic fails argument admission. The ledger registers a `recall` tool beside the application's lookups and offers it only on a request with something to find: a user statement, including a quiet one, a lookup finding with a result, an earlier request, or a nonblank call-free reply that the seed tail, the window, and the copy together don't hold whole. A lookup stub doesn't hold its result, but a fully received finding with the same canonical lookup identity and text holds an identical finding's result too. A partly shown message counts as hidden, and a finding with no result never opens the offer. A ledger note and the current request's own turns never open the offer. The `collectRecallMessages` and `hasHiddenRecall` helpers read this per request from the conversation, so a hydrated ledger offers what the uninterrupted one offers. When nothing is hidden, the ledger narrows the agent's scope to the other tools for that request, keeping a host's allow-lists and selector, and the `respond` method restores the host's own scope when it settles, a rejection or an abort included, only while the plan's scope is still active. A scope the host applied in the meantime stays active. The tool's description reads that it finds something said earlier that isn't in the messages the model can see. It lists matching statements and lookup findings first, newest first, each source followed by the amenders the topic doesn't match itself; an amender the topic matches lists as its own newer item. It then lists earlier requests and call-free, non-empty assistant replies, newest first, under `Earlier request:` and `Earlier reply:`. A conversation match contains every word of at least one part of the topic, including when that part also names an owner. This conversation route excludes the current request and its turns, ledger notes, and messages already listed. It keeps the stored text, with each run of line breaks written as a line break and two spaces so that only a label opens a line, and it admits a partial reply the conversation stored before an abort. A hidden quiet statement can open the offer by itself, and a word match can list it. A cut landing mid-stream stores no reply and carries nothing. On the statement and lookup route, only lines opening with `Earlier request:` or `Earlier reply:` gain the same two-space indent; every other byte, including stored line breaks, stays unchanged. A label names the message's role, so a host-added assistant message in the seed reads as a reply too. These listings do not promote replies or requests into records. A search that finds nothing returns `nothing earlier on "TOPIC"; answer from the messages you can see`, where `TOPIC` is the searched topic, and that result enters no answer note. A blank topic still returns its guidance as a failure. The route reads the conversation and not the prompt, so it can list a request or a reply the window already carries. The tool fits whole items, including each source's amenders, into what the measured request leaves below capacity less predict, and names how many items it left out. An oversized item is omitted, and a later fitting item can still be returned. The result and its omission line share the allowance, with tool-message framing counted. When no item fits, the line reads `N older items didn't fit in this request; answer from the messages you can see`, using `item` for one and `more` for conversation matches. A partial listing keeps `N older items not shown; name a narrower topic to narrow the recall`. A gauged direct run fits its listing to the same allowance; with no gauge, the first whole item remains unconditional. The cut line uses `more` when an omitted item precedes a kept one in listing order, or when conversation matches are listed; otherwise it uses `older`. This rule applies to both omission forms. Statements and lookup findings take priority over conversation matches. A request can call it as many times as the `limit` member of the `recall` option allows, the `DEFAULT_RECALL_LIMIT` constant by default; after that it returns the `closure` note. Lack of room never closes recall: a distinct later call is fitted independently. The prefix uses the last call's reported prompt and completion, adjusted for replay by `Gauge.remainder`; missing usage uses an estimate. Additions use the larger of `Gauge.rate` and the latest reported call's prompt less known overhead divided by its estimate, with `LEDGER_SCALE_DRIFT` headroom. As in `Gauge.observe`, a partly spared call keeps the marginal rate instead of guessing an overhead share. Calls without reported usage use the marginal rate alone. Sibling recall results share the room. A listing within the `LEDGER_SCALE_DRIFT` margin of the room can be left out, with the omission line stating that it did not fit this request.
|
|
622
|
-
- **The repeat stop.** A lookup or `recall` call that repeats an earlier call of the same request, compared by tool name and canonical arguments, returns the `repeat` note as its failure, and the ledger aborts the pass. For a lookup, the repeat stop's identity compares string arguments as written. The projection's lookup identity, which the `identifyLookup` helper writes, trims and uppercases each top-level string argument and decides which finding replaces an earlier one. So `lookup_order` calls for `bw-5512` and `BW-5512` both run in one request, and the second finding replaces the first in the records when its text differs. A finding with different text or an empty result replaces the earlier one, a finding with the same text replaces nothing, so the first unsuperseded finding of the final same-text run stays live, and a thrown call files no finding, leaving the earlier result live.
|
|
623
|
-
- **The
|
|
621
|
+
- **The `recall` tool.** The tool requires a nonempty topic string; an empty topic fails argument admission. The ledger registers a `recall` tool beside the application's lookups and offers it only on a request with something to find: a user statement, including a quiet one, a lookup finding with a result, an earlier request, or a nonblank call-free reply that the seed tail, the window, and the copy together don't hold whole. A lookup stub doesn't hold its result, but a fully received finding with the same canonical lookup identity and text holds an identical finding's result too. A partly shown message counts as hidden, and a finding with no result never opens the offer. A retired finding never opens the offer either: one a write superseded through its `targets`, or one a later finding of the same canonical lookup identity replaced with different text or an empty result, as the `collectRetiredFindings` helper reads them. A live hidden finding still opens it. A ledger note and the current request's own turns never open the offer. The `collectRecallMessages` and `hasHiddenRecall` helpers read this per request from the conversation, so a hydrated ledger offers what the uninterrupted one offers. When nothing is hidden, the ledger narrows the agent's scope to the other tools for that request, keeping a host's allow-lists and selector, and the `respond` method restores the host's own scope when it settles, a rejection or an abort included, only while the plan's scope is still active. A scope the host applied in the meantime stays active. The tool's description reads that it finds something said earlier that isn't in the messages the model can see. It lists matching statements and lookup findings first, newest first, each source followed by the amenders the topic doesn't match itself; an amender the topic matches lists as its own newer item. It then lists earlier requests and call-free, non-empty assistant replies, newest first, under `Earlier request:` and `Earlier reply:`. A conversation match contains every word of at least one part of the topic, including when that part also names an owner. This conversation route excludes the current request and its turns, ledger notes, and messages already listed, and neither route lists a retired finding, as its own item or as an amender. It keeps the stored text, with each run of line breaks written as a line break and two spaces so that only a label opens a line, and it admits a partial reply the conversation stored before an abort. A hidden quiet statement can open the offer by itself, and a word match can list it. A cut landing mid-stream stores no reply and carries nothing. On the statement and lookup route, only lines opening with `Earlier request:` or `Earlier reply:` gain the same two-space indent; every other byte, including stored line breaks, stays unchanged. A label names the message's role, so a host-added assistant message in the seed reads as a reply too. These listings do not promote replies or requests into records. A search that finds nothing returns `nothing earlier on "TOPIC"; answer from the messages you can see`, where `TOPIC` is the searched topic, and that result enters no answer note. A blank topic still returns its guidance as a failure. The route reads the conversation and not the prompt, so it can list a request or a reply the window already carries. The tool fits whole items, including each source's amenders, into what the measured request leaves below capacity less predict, and names how many items it left out. An oversized item is omitted, and a later fitting item can still be returned. The result and its omission line share the allowance, with tool-message framing counted. When no item fits, the line reads `N older items didn't fit in this request; answer from the messages you can see`, using `item` for one and `more` for conversation matches. A partial listing keeps `N older items not shown; name a narrower topic to narrow the recall`. A gauged direct run fits its listing to the same allowance; with no gauge, the first whole item remains unconditional. The cut line uses `more` when an omitted item precedes a kept one in listing order, or when conversation matches are listed; otherwise it uses `older`. This rule applies to both omission forms. Statements and lookup findings take priority over conversation matches. A request can call it as many times as the `limit` member of the `recall` option allows, the `DEFAULT_RECALL_LIMIT` constant by default; after that it returns the `closure` note. Lack of room never closes recall: a distinct later call is fitted independently. The prefix uses the last call's reported prompt and completion, adjusted for replay by `Gauge.remainder`; missing usage uses an estimate. Additions use the larger of `Gauge.rate` and the latest reported call's prompt less known overhead divided by its estimate, with `LEDGER_SCALE_DRIFT` headroom. As in `Gauge.observe`, a partly spared call keeps the marginal rate instead of guessing an overhead share. Calls without reported usage use the marginal rate alone. Sibling recall results share the room. A listing within the `LEDGER_SCALE_DRIFT` margin of the room can be left out, with the omission line stating that it did not fit this request.
|
|
622
|
+
- **The repeat stop.** A lookup, write, or `recall` call that repeats an earlier call of the same request, compared by tool name and canonical arguments, returns the `repeat` note as its failure, and the ledger aborts the pass. For a lookup, the repeat stop's identity compares string arguments as written. The projection's lookup identity, which the `identifyLookup` helper writes, trims and uppercases each top-level string argument and decides which finding replaces an earlier one. So `lookup_order` calls for `bw-5512` and `BW-5512` both run in one request, and the second finding replaces the first in the records when its text differs. A finding with different text or an empty result replaces the earlier one, a finding with the same text replaces nothing, so the first unsuperseded finding of the final same-text run stays live, and a thrown call files no finding, leaving the earlier result live. A write that runs admits again each lookup call whose finding it retired, so a read in a later turn that checks the write runs, and a second identical read with no write between is still a repeat. A lookup or write call its tool refuses for its arguments is never a run: when the tool's `execute` throws, or returns a promise that rejects with, an error `isToolError` admits whose code is `'ARGUMENTS'`, from the tool's own door or its handler, the request releases the call, so the identical call runs again, the model can repair it, and the agent's `limit` bounds a model that keeps sending it. The release lands when the refusal does, so an identical twin in the same batch that starts while a promise's refusal is still pending reads as a repeat. Every other failure of a call that reached its tool counts as a run: another thrown or rejected error, a `ToolError` of another code, and a refusal the host raises inside the handler, such as a declined confirm. A host registry's `execute` answers a refusal as a failure with no code, so a handler that routes through one and rethrows that failure turns an argument refusal into a run; call `tools.tool(name)` and its `execute` to keep the code. A call the agent's scope or authority refuses, or its approver declines or leaves unanswered, never reaches its tool. When the authority's `evaluate` method denies a lookup or write call, or its ask is declined or left unanswered, the request records the call as denied, and its identical retry in a later turn of the same request is denied with the `repeat` note as its reason before the authority's `evaluate` method reads it and with no ask, so the ledger aborts the pass and the person is asked once. Every call of a batch is evaluated before the first ask, so the identical twin in one batch of a call whose ask was declined or left unanswered reaches the ledger's `ask`, which refuses it without entering the host's approver: the agent reports the twin's `ask` event, then its `deny` event, the twin reads the `refused` note, and its pass goes on. The twin of a call the `evaluate` method denied stops as a repeat. A later request asks again, and a call with other arguments is evaluated and asked as before. A denial that the agent's `deny` event reports with no decision records nothing: a scope miss, a throwing `evaluate` method or an invalid decision, and a cleared call whose tool changed before dispatch. An asked call whose tool changed before its approval returned is denied as unanswered with its decision, so the request records it.
|
|
623
|
+
- **The stray stop.** A call the model makes in a turn that advertises no tools runs nothing, in the first pass and the answer pass alike: the agent refuses it once, as its `deny` and `tool` events and the stream's `tool` chunk report, and the ledger then ends that pass, which the agent's `abort` event reports with the reason `'stray'`. So a pass whose scope advertises no tools makes at most one model generation, whatever the agent's `limit`. A first pass advertises no tools when the ledger registers no lookup and no write and nothing is hidden, because the plan then leaves `recall` out too, and the guide's example ledger is one. When every call of that turn failed, the ledger stores the reply again without its calls and their refusals, as a call-free turn stores it, so the call files no finding, retires nothing, and leaves the records, the window, the snapshot, and the `recall` tool as a call-free pass leaves them. A reply that carries text beside the call ends the pass with that text and `partial: false`. A reply with no text ends it partial with empty content, so after a first pass the ledger runs the answer pass, as it does after an empty first pass. A turn that advertises any tool keeps the pass running: a call to a name it doesn't advertise is refused and the pass runs on, up to the agent's `limit`.
|
|
624
|
+
- **The answer pass.** When the first pass ends partial or without final text and the caller didn't abort, the ledger adds an answer note when the pass's lookups or recalls returned anything, carrying what they returned without their call text, then the `cue` note, and runs one answer pass that advertises no tools and always turns thinking off. A call the model makes there anyway ends the pass after its one generation, whatever the agent's `limit`, as **The stray stop.** states, and a reply with no text makes the `respond` method resolve partial with empty content. A scope a host applies during the pass decides what it advertises, and a pass whose scope advertises a tool runs on to the agent's `limit`. Before that pass, the ledger prices the rebuilt prompt at the same request-local rate. If it exceeds capacity less predict, it leaves a call-free partial assistant reply out of the prompt while keeping it stored, then fits the union of result groups to the remaining room. Source and amendment groups stay whole. Only the omission line the ledger appended is excluded from the digest; a literal line inside an accepted source group is preserved, even when its text matches an omission line; groups already represented by earlier groups enter no second copy. The `passes` member of the `LedgerResult` value holds both passes, and its `content` member is the last pass's. A rejected first pass counts as unfinished. When the answer pass rejects as well, the `respond` method rejects with that pass's error, and the ledger stays free for a later request.
|
|
624
625
|
- **The thinking budget.** The `predict` option reserves the generation room that thinking and the reply share, taking it out of the plan budget, the runtime recall room, and the answer prompt allowance. The plan's reserve-based admission rule stays unchanged. The gauge counts only the thinking the next request carries: under the provider's default `replay` of `'none'`, it leaves a call's thinking out of the capacity that call used, and the `computeThinking` helper apportions that thinking from the completion by character share. Under every policy, the reply reserve reads the reply without its thinking. The `think` option requests or suppresses thinking for the first pass, and omission leaves the provider's default; the answer pass always runs with thinking off. With replay `'none'`, a ledger at a `capacity` of `W + P` with a `predict` of `P`, where `W` is a context window and `P` a generation cap, budgets like a ledger at `W` without thinking.
|
|
625
626
|
|
|
626
627
|
Display references identify sources within the rendered records while the line keeps the stored identity:
|
|
@@ -647,10 +648,12 @@ The application supplies the following through `LedgerOptions`:
|
|
|
647
648
|
- the question wording, through the `questions` option, where the `LEDGER_QUESTIONS` constant is the wording, and its own cutoffs through the `thresholds` option, which has no default because a cutoff holds only for the wording and the judge it was fitted on;
|
|
648
649
|
- the desk topics, through the `topics` option;
|
|
649
650
|
- the lookups, through the `lookups` option, each a tool the model calls and a reading handler that names the ids and the owners in its result;
|
|
651
|
+
- the writes, through the `writes` option, each a tool annotated `consequential` and a reading handler that names the ids, the owners, and the `targets` in its result, the ids whose state the call changed or removed;
|
|
652
|
+
- the agent options, through the `agent` option, whose `authority` member gates every lookup and write and is required with writes;
|
|
650
653
|
- the capacity, through the `capacity` option, the model's context window in tokens;
|
|
651
654
|
- the generation cap, through the `predict` option, in tokens with thinking included, 0 by default and less than `capacity`;
|
|
652
655
|
- the thinking of the first pass, through the boolean `think` option; the answer pass always runs with thinking off;
|
|
653
|
-
- the state to hydrate from, through the `snapshot` option, which takes what a ledger's `snapshot` method returned: the conversation with its judgments, the marked request, note, and failed tool result ids, the gauge, which a `gauge` option overrides, and the window while it holds an exchange.
|
|
656
|
+
- the state to hydrate from, through the `snapshot` option, which takes what a ledger's `snapshot` method returned: the conversation with its judgments, the marked request, note, and failed tool result ids, the gauge, which a `gauge` option overrides and which holds only for the tool definitions it priced, and the window while it holds an exchange.
|
|
654
657
|
|
|
655
658
|
The method has the following documented limits:
|
|
656
659
|
|
|
@@ -664,18 +667,25 @@ The method has the following documented limits:
|
|
|
664
667
|
- **An abort during calibration rejects.** When the caller's signal aborts while the ledger calibrates, the `respond` method rejects with the abort reason instead of resolving a partial result; after calibration, an abort ends the request partial and skips the answer pass.
|
|
665
668
|
- **A foreign signal rejects before anything is appended.** A `signal` that isn't a native `AbortSignal` rejects the `respond` method with a `ContractError` before the request is appended, and the ledger stays free for a later request.
|
|
666
669
|
- **The seed selection stays fixed.** Only the messages added before the first request form the seed tail. Each completed exchange follows it in the window: a request as it was sent and its last call-free assistant reply, excluding notes, calls, and tool messages. A blank or missing last call-free reply carries nothing. A committed partial reply means one the conversation stored; it remains eligible after an abort, but a cut landing mid-stream stores no reply and carries nothing. A host statement reaches the prompt through records or recall, and neither that statement nor a host lookup after the reply erases the exchange. Two non-empty call-free assistants without a ledger note between them make the pairing ambiguous, so it carries nothing; answer-pass notes establish the separation between a partial first reply and the final answer. A host that removes a request must remove every turn of it too, because nothing stored links a reply to its request: a surviving reply can read as the earlier request's when that request has no reply of its own, or when the removed request's answer pass left its note behind. The seed messages and the selected record lines stay the same on every rung of the window, and only a seed stub's `shown` or `hidden` state follows the rung.
|
|
667
|
-
- **Records don't retire.** No age or request count retires a message: it leaves the records only when a later message supersedes it, a later finding of the same lookup with different text or an empty result replaces it, or a later answer files it quiet. Only the plan decides which of its lines a request copy shows, and a line an earlier copy showed stays in the prompt until the window empties or falls past that copy.
|
|
670
|
+
- **Records don't retire.** No age or request count retires a message: it leaves the records only when a later message supersedes it, a later finding of the same lookup with different text or an empty result replaces it, a write names it among its `targets`, or a later answer files it quiet. Only the plan decides which of its lines a request copy shows, and a line an earlier copy showed stays in the prompt until the window empties or falls past that copy.
|
|
668
671
|
- **The ledger refuses no over-window prompt.** A request, a lookup result, or the whole view a faulted selection builds from can exceed the room the `capacity` option leaves. Recall results and recovery digests are fitted, but unbounded mandatory content can still reach the provider, and the provider's own context limit decides what happens to it. A provider that refuses an over-long prompt fails the pass, so lower `capacity`, or set `AgentOptions.window` on an agent you drive yourself, to fold the conversation first.
|
|
669
672
|
- **A host edit after fitting enters unpriced.** A memo written during a request's first pass enters the rebuilt answer context and consumes its fitting allowance. A later host edit, after fitting, remains unpriced. The context can change while the selected seed and request stay the same.
|
|
670
673
|
- **A heading inside a record line reads as one.** A record line and the request copy render a message's or a lookup's text verbatim, so text holding a `## Rules` or `## Request` heading reads as one inside the user turn's copy; it changes no filing and never reaches `system`, and no delimiter marks such text.
|
|
671
|
-
- **
|
|
674
|
+
- **Lookups read, writes change; both answer to `agent.authority`.** A tool whose call changes a record is a write, never a lookup. The ledger passes its agent one authority, which denies every name the ledger doesn't advertise, allows `recall`, and hands every lookup and write to the `authority` member of the `agent` option, whose `ask` answers each asked call. Without that member, the ledger allows each lookup itself and holds no approver, so a `consequential` lookup meets the floor and is denied as unanswered at every call. A tool a host adds later reads `the ledger advertises no such tool` under either.
|
|
675
|
+
- **A repeated write asks before it stops.** The repeat stop runs when a call executes, after its approval, so a write that repeats an earlier call of the same request that ran asks the approver and then returns the `repeat` note. A write that repeats a call the authority denied, declined, or left unanswered in the same request is denied as a repeat before the ask instead.
|
|
672
676
|
- **A snapshot's judgments are frozen records.** `LedgerInterface.snapshot().conversation` carries the stored deep-frozen judgments, so a write to one throws `TypeError` in strict-mode code, and a host copies a record through `copyJSON` before it migrates or redacts it. A host that migrates or redacts a snapshot can delete its `window` member as the clean path, because the stored copies repeat conversation text: the hydrated ledger derives the newest pair plain, and no stored copy keeps the old text in the snapshot's bytes or can send it.
|
|
673
|
-
- **A
|
|
677
|
+
- **A stored gauge holds for the tool definitions it priced.** The `gauge` member of a snapshot, a `LedgerGaugeSnapshot` value, holds the scale, the overhead cost, and a required `digest` member, which the `digestLedgerTools` helper computes over the tool definitions the calibration request carried, or over the ledger's definitions at construction when the `gauge` option supplied the price. A ledger hydrated with definitions of another digest, because an application added, removed, or edited a lookup or a write, or changed the topics the `recall` definition names, drops the stored gauge, reads `undefined` from its `gauge` member, and calibrates before its first pass, so a hydrated ledger never plans with an overhead priced on other definitions. The comparison reads the definitions at construction, so a tool a host adds to the agent's tools afterward isn't compared. A reordered list changes the digest too and costs one calibration. With the same definitions, the hydrated ledger reuses the gauge and makes no calibration call. The `isLedgerSnapshot` guard refuses a gauge with no `digest` member, and construction refuses that snapshot with `LedgerError` code `'SNAPSHOT'`. The `snapshot` method omits the gauge when JSON can't render its definitions. A `gauge` option is the application's own price and is never compared.
|
|
678
|
+
- **A snapshot carries no gauge observations.** The `gauge` member of a snapshot holds the price and its digest alone. A hydrated ledger has observed no reply and no earlier request, so its window admission starts with the longest stored reply as its reserve forecast. Runtime recall uses the current request's measurements; lost marginal-rate history can still change the fit, so live and hydrated calls can list different numbers of items. The window's rungs retain their reserve rule. A hydrated ledger sends what the uninterrupted one would when the live and hydrated reserves admit the same rung. A rung that lies between the two reserves can differ, which moves the prefix and never the record coverage.
|
|
674
679
|
- **A hydrated ledger asks a held question again.** A snapshot doesn't carry the questions a `strict: false` classifier held after a refused question or a deterministic judge failure, so a ledger hydrated from it asks each of them again in its next request.
|
|
675
680
|
- **A snapshot carries the window.** The `window` member of a `LedgerSnapshot` value is optional and present only while the window holds an exchange, so the snapshot of an empty window reads as one with no such member. A 0.0.36 snapshot holds none, reads as it did, and derives the newest pair plain. The `snapshot` method omits a window its conversation can't support, as after a host removes a held message, so a removal doesn't leave a snapshot that hydrating refuses. The `isLedgerSnapshot` guard reads a stored window's exact shape alone, so it refuses a malformed window or one with no `digest` member, and construction refuses that snapshot with `LedgerError` code `'SNAPSHOT'`. It reads no reference or sentence range, so a well-shaped window that names a removed message or sentence passes the guard, and hydrating discards it, because its digest disagrees or can't be computed.
|
|
676
681
|
- **A stored window carries a digest.** The `window` member of a snapshot holds a required `digest` member, a checksum the `digestLedgerWindow` helper computes over the canonical form of its held messages, each request, reply, and record line's source, every lookup result and every message holding a call, because an owner heading can print a lookup no line holds, its stored copies, and its sentence receipts. An edit to any of those, by a host migrating or redacting, makes the digest disagree: hydrating discards the whole window and the ledger derives the newest pair from the edited conversation, so old held text doesn't reach a provider. A digest that can't be computed discards the window the same way. The digest detects an edit, can collide, and makes no security claim. The canonical form sorts keys, so a store that reorders them doesn't make the digest disagree. A held message the canonical form can't render, such as one with an `undefined` tool argument, makes the `snapshot` method omit the window. A held lookup's call arguments count too, through the assistant message that made the call.
|
|
677
682
|
- **A follow-up can read the reply again.** A model server that keeps a prompt cache reuses a prompt that extends the last. On a model whose generation prefix differs from how it renders a reply in history, the server reads the reply itself again, so a follow-up costs the reply plus the text the last prompt didn't hold: small with short replies, and larger with long ones. After a request that called a tool, the prompt shares its prefix only through that request's copy, because tool calls and results stay out of the window, so that reply is read again on any model. Anything ahead of the window moves the prefix too: a system or instruction edit, a memo or workspace change in the context message, a seed stub whose `shown` or `hidden` state flips, and a seed exchange whose cut moves when the gauge rescales. So do an emptied window, a fall to a lower rung, a workspace image, which attaches to the last user message, and a reply whose thinking the `replay` policy leaves out.
|
|
678
683
|
- **A changed lookup empties the window.** A later finding of the same lookup with different text or an empty result retires the source the window holds, and that empties the window. That prompt holds the derived newest pair and a copy of every selected line, so it doesn't extend the prompt before it. A lookup repeated with the same text retires nothing, so the prompt extends the one before it.
|
|
684
|
+
- **A write empties the window when it retires a held line.** A write that retires a source the window holds empties the window, as a changed lookup does, so that prompt doesn't extend the prompt before it.
|
|
685
|
+
- **A write retires whole findings.** A write retires every earlier finding that names a target, so a list read loses its untouched rows too and the model reads again. A user statement about the record never retires through `targets`; the judge's supersession files that.
|
|
686
|
+
- **A partial request can hold a completed write.** A write stores its result before the next turn, so an abort or a failure later in the request leaves the write in the conversation, retiring the reads it made stale. A host that discards a partial request's snapshot loses that write while its store keeps the change, so it must save the snapshot after any request that ran a write.
|
|
687
|
+
- **A write's handler must be total.** A handler that throws marks the write failed, so a write that changed the store files nothing and leaves the stale read live, and a handler that misses a target leaves that target's earlier reads live. Pass the same `writes` on every hydrate: the ledger reads the targets again from the conversation, so a changed list brings retired reads back live.
|
|
688
|
+
- **A write that changed nothing stubs as such.** A seed write whose handler reads no change stubs as `changed nothing`, where an empty lookup stubs as `no record`.
|
|
679
689
|
- **A cut stream stores nothing.** A stream cut before its reply is stored leaves the window standing, so a follow-up that refers to the cut text reads against the last completed reply.
|
|
680
690
|
- **Recall fitting depends on its measured price.** Runtime recall and recovery allow the `LEDGER_SCALE_DRIFT` margin over the larger of the gauge's marginal rate and this request's measured rate. A provider whose new text costs more than that bound is outside the capacity guarantee. Missing usage remains estimated; no exact tokenizer preflight is available. A long earlier reply still affects window admission, but never vetoes a runtime recall that fits.
|
|
681
691
|
- **A replaced seed lookup keeps its stub.** When a later finding of the same lookup with different text replaces a seed lookup, the seed stub reads `result not shown` while a later copy can print the replacing result, unless the window and the copy fully receive a finding with the same canonical lookup identity and text as the seed finding. That full receipt makes a duplicate stub read `shown`, even when its own source is retired.
|
|
@@ -1580,63 +1590,67 @@ The `ledgers` module serves a conversation through event-sourced records: the `L
|
|
|
1580
1590
|
|
|
1581
1591
|
The following table lists the types the ledger declares, each with its shape:
|
|
1582
1592
|
|
|
1583
|
-
| Name | Kind | Signature
|
|
1584
|
-
| ------------------------- | --------- |
|
|
1585
|
-
| `LedgerCategory` | type | `(typeof LEDGER_CATEGORIES)[number]`
|
|
1586
|
-
| `LedgerQuestion` | interface | `{ category, topic, amends, supersedes }`
|
|
1587
|
-
| `LedgerThreshold` | interface | `{ category, topic, amends, supersedes, correction }`
|
|
1588
|
-
| `LedgerTopic` | interface | `{ name, criterion, requested? }`
|
|
1589
|
-
| `LedgerShare` | interface | `{ prompt, tail }`
|
|
1590
|
-
| `LedgerNote` | interface | `{ cue, results, repeat, closure }`
|
|
1591
|
-
| `LedgerRecallOptions` | interface | `{ limit? }`
|
|
1592
|
-
| `LedgerCorrectionOptions` | interface | `{ narrow? }`
|
|
1593
|
-
| `LedgerOwner` | interface | `{ id, names }`
|
|
1594
|
-
| `LedgerLookupResult` | interface | `{ ids, owners }`
|
|
1595
|
-
| `LedgerLookupHandler` | type | `(args: Readonly<Record<string, unknown>>, text: string) => LedgerLookupResult \| undefined`
|
|
1596
|
-
| `LedgerLookup` | interface | `{ tool, read }`
|
|
1597
|
-
| `
|
|
1598
|
-
| `
|
|
1599
|
-
| `
|
|
1600
|
-
| `
|
|
1601
|
-
| `
|
|
1602
|
-
| `
|
|
1603
|
-
| `
|
|
1604
|
-
| `
|
|
1605
|
-
| `
|
|
1606
|
-
| `
|
|
1607
|
-
| `
|
|
1608
|
-
| `
|
|
1609
|
-
| `
|
|
1610
|
-
| `
|
|
1611
|
-
| `
|
|
1612
|
-
| `
|
|
1613
|
-
| `
|
|
1614
|
-
| `
|
|
1615
|
-
| `
|
|
1616
|
-
| `
|
|
1617
|
-
| `
|
|
1618
|
-
| `
|
|
1619
|
-
| `
|
|
1620
|
-
| `
|
|
1621
|
-
| `
|
|
1622
|
-
| `
|
|
1623
|
-
| `
|
|
1624
|
-
| `
|
|
1625
|
-
| `
|
|
1626
|
-
| `
|
|
1627
|
-
| `
|
|
1628
|
-
| `
|
|
1629
|
-
| `
|
|
1630
|
-
| `
|
|
1631
|
-
| `
|
|
1632
|
-
| `
|
|
1633
|
-
| `
|
|
1634
|
-
| `
|
|
1635
|
-
| `
|
|
1636
|
-
| `
|
|
1637
|
-
| `
|
|
1638
|
-
| `
|
|
1639
|
-
| `
|
|
1593
|
+
| Name | Kind | Signature | Summary |
|
|
1594
|
+
| ------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1595
|
+
| `LedgerCategory` | type | `(typeof LEDGER_CATEGORIES)[number]` | Names the category the ledger files a message under, one of `LEDGER_CATEGORIES`. |
|
|
1596
|
+
| `LedgerQuestion` | interface | `{ category, topic, amends, supersedes }` | Carries the wording of every question the ledger asks its judge. |
|
|
1597
|
+
| `LedgerThreshold` | interface | `{ category, topic, amends, supersedes, correction }` | Carries the probability cutoff of each reading the ledger takes from its judge. |
|
|
1598
|
+
| `LedgerTopic` | interface | `{ name, criterion, requested? }` | Carries one desk topic: the subject the ledger asks its judge about for statements and, when enabled, requests. |
|
|
1599
|
+
| `LedgerShare` | interface | `{ prompt, tail }` | Carries the share of the context capacity the prompt can take and the share of that budget the tail can take. |
|
|
1600
|
+
| `LedgerNote` | interface | `{ cue, results, repeat, closure }` | Carries the text of each note the ledger writes into its conversation or returns to the model. |
|
|
1601
|
+
| `LedgerRecallOptions` | interface | `{ limit? }` | Configures the ledger's `recall` tool. |
|
|
1602
|
+
| `LedgerCorrectionOptions` | interface | `{ narrow? }` | Narrows the pair questions the ledger asks about each correction. |
|
|
1603
|
+
| `LedgerOwner` | interface | `{ id, names }` | Carries one owner a lookup result names: its id and the names it goes by. |
|
|
1604
|
+
| `LedgerLookupResult` | interface | `{ ids, owners }` | Carries what a lookup handler read from one lookup result: the ids it names and the owners among them. |
|
|
1605
|
+
| `LedgerLookupHandler` | type | `(args: Readonly<Record<string, unknown>>, text: string) => LedgerLookupResult \| undefined` | Reads one successful lookup result into the ids and owners it names. |
|
|
1606
|
+
| `LedgerLookup` | interface | `{ tool, read }` | Carries one application lookup: the tool the model calls and the handler that reads its results. |
|
|
1607
|
+
| `LedgerWriteResult` | interface | `{ targets }` | Carries what a write handler read from one write result: the ids and owners it names, and the ids whose state the call changed or removed. |
|
|
1608
|
+
| `LedgerWriteHandler` | type | `(args: Readonly<Record<string, unknown>>, text: string) => LedgerWriteResult \| undefined` | Reads one successful write result into the ids and owners it names and the ids whose state it changed. |
|
|
1609
|
+
| `LedgerWrite` | interface | `{ tool, read }` | Carries one application write: the `consequential` tool the model calls and the handler that reads its results. |
|
|
1610
|
+
| `LedgerLookupFinding` | interface | `{ id, name, arguments, text, result, targets? }` | Carries one successful lookup result as the ledger read it. |
|
|
1611
|
+
| `LedgerLookupState` | type | `'failed' \| 'empty' \| 'shown' \| 'hidden'` | Names what became of a lookup of an earlier request, as the tail stub of its result reports it. |
|
|
1612
|
+
| `LedgerRegistry` | interface | `{ ids, owners }` | Carries the ids the ledger's lookups named and the owners among them. |
|
|
1613
|
+
| `LedgerIndex` | interface | `{ ids, aliases, carriers, names, words, keys, ranks }` | Carries a registry prepared for matching: its ids, each owner name's owners, and the compiled needles. |
|
|
1614
|
+
| `LedgerGauge` | interface | `{ scale, overhead }` | Carries the price of a prompt in tokens, measured against the model the ledger serves. |
|
|
1615
|
+
| `LedgerGaugeSnapshot` | interface | `{ digest }` | Carries a stored gauge: its price and the digest of the tool definitions that price measured. |
|
|
1616
|
+
| `LedgerAgentOptions` | type | `Pick<AgentOptions, 'limit' \| 'timeout' \| 'on' \| 'scheduler' \| 'instructions' \| 'skills' \| 'memos' \| 'workspaces' \| 'strict' \| 'authority'>` | Selects the agent bounds, hooks, scheduler, and context libraries a ledger passes through to the agent it builds. |
|
|
1617
|
+
| `LedgerOptions` | interface | `{ judge, system, topics, questions, thresholds, capacity, predict?, think?, gauge?, lookups?, writes?, share?, recall?, correction?, agent?, snapshot? }` | Configures a ledger: its judge and the wording and cutoffs it files with, the desk topics, the context capacity, and the optional first-pass thinking, lookups, writes, gauge, shares, snapshot, recall limit, correction filter, and agent options. |
|
|
1618
|
+
| `LedgerSnapshot` | interface | `{ conversation, requests, notes, failures, gauge?, window? }` | Holds the JSON-serializable state a ledger hydrates from: its conversation and the message ids it marked. |
|
|
1619
|
+
| `LedgerExchangeSnapshot` | interface | `{ request, copy?, reply, lines }` | Carries the sent request text, stored pair ids, and sentence placements of one exchange. |
|
|
1620
|
+
| `LedgerWindowSnapshot` | interface | `{ digest, exchanges, amendments }` | Carries a nonempty exchange window, its message, copy, and receipt checksum, and its accepted edges. |
|
|
1621
|
+
| `LedgerResult` | interface | `{ passes, attempts }` | Carries the outcome of one request a ledger served: the agent result of its reply and every pass it took. |
|
|
1622
|
+
| `LedgerInterface` | interface | `{ agent, conversation, gauge, respond(), calibrate(), snapshot() }` | Serves the requests of one conversation through an agent whose prompt the ledger projects from what the judge filed. |
|
|
1623
|
+
| `LedgerListing` | interface | `{ result, lines, groups, turn }` | Carries a recall result, its accepted whole groups, lookup line translations, and provider-turn position. |
|
|
1624
|
+
| `LedgerRecovery` | interface | `{ digest, omitted }` | Carries the answer note and the partial messages omitted from its prompt. |
|
|
1625
|
+
| `LedgerRequestInterface` | interface | `{ scope, apply(), sent, fault(), faulted(), message, plan, selection, boundary, usage, calls, attempts, signal, aborted, abort(), enter(), open(), adopt(), observe(), spend(), think(), file(), admit(), release(), deny(), denied(), recall(), close(), list(), listings, lines() }` | Holds what one `respond` call of a ledger keeps while it serves its request: the request message, the filing attempts and the plan its selections produced, the gauge calls of its passes, and its repeat and recall stops. |
|
|
1626
|
+
| `LedgerWordSet` | interface | `{ words, names }` | Carries the lowercase words and non-opening capitalized names of a message. |
|
|
1627
|
+
| `LedgerClassification` | interface | `{ quiet, categories, topics, amendments, supersessions }` | Carries the ledger's filing of its conversation's messages, keyed by message id. |
|
|
1628
|
+
| `LedgerLine` | interface | `{ text, source, sentence, party?, topics, role }` | Carries one record line: a sentence of a live message, verbatim except that a sentence that opens with a pronoun opens with its party and a colon. |
|
|
1629
|
+
| `LedgerReceipt` | interface | `{ key, title, source, sentence }` | Identifies an original sentence at one record placement. |
|
|
1630
|
+
| `LedgerOccurrence` | interface | `{}` | Carries a rendered sentence with its record placement. |
|
|
1631
|
+
| `LedgerExchange` | interface | `{ request, reply, lines }` | Carries a completed request copy, its stored reply, and the sentences the copy rendered. |
|
|
1632
|
+
| `LedgerDraft` | interface | `{ copy, lines, evidence, window }` | Carries a planned copy and its validity evidence to request settlement. |
|
|
1633
|
+
| `LedgerEvidence` | interface | `{ messages, amendments }` | Captures held message identities and the accepted edges used to validate their copies. |
|
|
1634
|
+
| `LedgerRenderResult` | interface | `{ text, lines }` | Carries rendered record text and its sentences in emission order. |
|
|
1635
|
+
| `LedgerRecord` | interface | `{ key, title, members, lines }` | Carries one record: the live messages placed on one owner or on the rules, as lines. |
|
|
1636
|
+
| `LedgerAmendment` | interface | `{ earlier, later }` | Identifies an accepted direct message amendment whose sentence scope remains unresolved. |
|
|
1637
|
+
| `LedgerRenderContext` | interface | `{ amendments, complete, first, references }` | Supplies accepted amendments and completely included sources for one rendering of the records. |
|
|
1638
|
+
| `LedgerProjection` | interface | `{ records, amendments, orphans }` | Carries the records projected from a conversation, accepted amendments, and the live messages no record placed. |
|
|
1639
|
+
| `LedgerProjectionInput` | interface | `{ system, exclusions, owners, messages, findings, entities, classification }` | Carries what a projection reads. |
|
|
1640
|
+
| `LedgerProjectionRequest` | interface | `{ owners, topics }` | Carries the owners and the desk topics one request names, which select its records. |
|
|
1641
|
+
| `LedgerCategoryHandler` | type | `(message: Message) => LedgerCategory \| undefined` | Reads a message's category from its shape, or returns undefined to leave it to the judge. |
|
|
1642
|
+
| `LedgerEntityHandler` | type | `(text: string, partial: boolean) => ReadonlySet<string>` | Lists the registry ids and owner ids a text names. |
|
|
1643
|
+
| `ClassifierOptions` | interface | `{ strict?, conversation, judge, questions, topics, thresholds, assign, entities, correction?, scheduler? }` | Configures a classifier: the conversation it files, the judge and the wording it asks with, the desk topics, the cutoffs, the ledger's handlers, and the optional correction filter and scheduler. |
|
|
1644
|
+
| `ClassifierPhase` | type | `'category' \| 'topic' \| 'amends' \| 'supersedes'` | Names the filing question a classifier asked: a message's category, a message's topic, or an earlier and later message's amendment or supersession. |
|
|
1645
|
+
| `ClassifierOutcome` | type | `'cached' \| 'skipped' \| 'resolved' \| 'failed' \| 'aborted'` | Names what became of one filing question. |
|
|
1646
|
+
| `ClassifierAttempt` | interface | `{ key, phase, outcome, duration? }` | Carries what became of one filing question: its judgment key, its phase, its outcome, and the time spent resolving it. |
|
|
1647
|
+
| `ClassifierResult` | interface | `{ judgments, usage?, attempts, fault?, failure? }` | Carries the judgment keys one classification rests on and the judge usage it spent. |
|
|
1648
|
+
| `ClassifierInterface` | interface | `{ classify(), category(), quiet(), decisive(), topics(), classification() }` | Files a conversation's messages through a judge and reads the filing. |
|
|
1649
|
+
| `GaugeCall` | interface | `{ estimate, spared?, prompt?, completion?, thinking?, tools }` | Carries one agent call as the gauge reads it. |
|
|
1650
|
+
| `GaugeOptions` | interface | `{ capacity, predict?, replay? }` | Configures a gauge: its starting price of a prompt and the context capacity it measures against. |
|
|
1651
|
+
| `GaugeInterface` | interface | `{ rate(), remainder(), reserve(), room(), observe() }` | Prices prompts in tokens and measures the room a request has left. |
|
|
1652
|
+
| `LedgerPlanGroup` | type | `1 \| 2 \| 3` | Names the planning group of a source the records render: a topic match, an off-topic rule or correction, or a name match. |
|
|
1653
|
+
| `LedgerErrorCode` | type | `'REQUEST' \| 'THRESHOLD' \| 'SHARE' \| 'CAPACITY' \| 'LIMIT' \| 'TOPIC' \| 'LOOKUP' \| 'GAUGE' \| 'REFERENCE' \| 'SNAPSHOT' \| 'QUESTION' \| 'WRITE'` | Names the machine-readable conditions a `LedgerError` error reports. |
|
|
1640
1654
|
|
|
1641
1655
|
#### Constants
|
|
1642
1656
|
|
|
@@ -1693,72 +1707,77 @@ The following table lists the classes that serve, file, and price a conversation
|
|
|
1693
1707
|
|
|
1694
1708
|
The following guards validate ledger fractions, capacity, and snapshots:
|
|
1695
1709
|
|
|
1696
|
-
| Name | Kind | Signature | Summary |
|
|
1697
|
-
| ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1698
|
-
| `isFraction` | function | `(value: unknown) => value is number` | Checks whether a value is finite and lies in the interval (0, 1\]. |
|
|
1699
|
-
| `isLedgerQuestion` | function | `(value: unknown) => value is LedgerQuestion` | Checks whether a value holds the wording a ledger files with: a choice `category` question whose criteria describe every category, a non-empty `topic` string, and noul `amends` and `supersedes` questions. |
|
|
1700
|
-
| `ledgerWindowShape` | const | `import("@orkestrel/contract").ObjectShape<{ digest: import("@orkestrel/contract").StringShape; exchanges: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ request: import("@orkestrel/contract").StringShape; copy: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; reply: import("@orkestrel/contract").StringShape; lines: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ key: import("@orkestrel/contract").StringShape; title: import("@orkestrel/contract").StringShape; source: import("@orkestrel/contract").StringShape; sentence: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; amendments: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ earlier: import("@orkestrel/contract").StringShape; later: import("@orkestrel/contract").StringShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>` | Describes the minimal serialized evidence of a nonempty exchange window. |
|
|
1701
|
-
| `ledgerWindowContract` | const | `import("@orkestrel/contract").ContractInterface<Readonly<{ digest: string; exchanges: readonly Readonly<{ request: string; reply: string; lines: readonly Readonly<{ key: string; title: string; source: string; sentence: number; } & {}>[]; } & { copy?: string; }>[]; amendments: readonly Readonly<{ earlier: string; later: string; } & {}>[]; } & {}>>` | Reads structural faults of a serialized exchange window. |
|
|
1702
|
-
| `ledgerSnapshotShape` | const | `import("@orkestrel/contract").ObjectShape<{ conversation: import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; sections: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; summary: import("@orkestrel/contract").StringShape; messages: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; role: import("@orkestrel/contract").LiteralShape<readonly ["system", "user", "assistant", "tool"]>; content: import("@orkestrel/contract").StringShape; calls: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; name: import("@orkestrel/contract").StringShape; arguments: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>; }, boolean \| ContractShape>>>; call: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; images: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>>; thinking: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; messages: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; role: import("@orkestrel/contract").LiteralShape<readonly ["system", "user", "assistant", "tool"]>; content: import("@orkestrel/contract").StringShape; calls: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; name: import("@orkestrel/contract").StringShape; arguments: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>; }, boolean \| ContractShape>>>; call: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; images: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>>; thinking: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; }, boolean \| ContractShape>>; judgments: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; question: import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["choice"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["score"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["noul"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ true: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; false: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>]>; model: import("@orkestrel/contract").StringShape; sources: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; state: import("@orkestrel/contract").StringShape; time: import("@orkestrel/contract").NumberShape; usage: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ prompt: import("@orkestrel/contract").NumberShape; completion: import("@orkestrel/contract").NumberShape; total: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; answer: import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["choice"]>; probabilities: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").NumberShape>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["score"]>; probabilities: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").NumberShape>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["noul"]>; noul: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>]>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; question: import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["choice"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["score"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["noul"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ true: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; false: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>]>; model: import("@orkestrel/contract").StringShape; sources: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; state: import("@orkestrel/contract").StringShape; time: import("@orkestrel/contract").NumberShape; usage: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ prompt: import("@orkestrel/contract").NumberShape; completion: import("@orkestrel/contract").NumberShape; total: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; refusal: import("@orkestrel/contract").ObjectShape<{ missing: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; }, boolean \| ContractShape>; }, boolean \| ContractShape>]>>>; }, boolean \| ContractShape>; requests: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; notes: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; failures: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; gauge: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ scale: import("@orkestrel/contract").NumberShape; overhead: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; window: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ digest: import("@orkestrel/contract").StringShape; exchanges: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ request: import("@orkestrel/contract").StringShape; copy: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; reply: import("@orkestrel/contract").StringShape; lines: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ key: import("@orkestrel/contract").StringShape; title: import("@orkestrel/contract").StringShape; source: import("@orkestrel/contract").StringShape; sentence: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; amendments: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ earlier: import("@orkestrel/contract").StringShape; later: import("@orkestrel/contract").StringShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>` | Describes a ledger snapshot exactly: an unknown key refuses, so a key a later version adds never reads as absent. |
|
|
1703
|
-
| `ledgerSnapshotContract` | const | `import("@orkestrel/contract").ContractInterface<Readonly<{ conversation: Readonly<{ id: string; sections: readonly Readonly<{ id: string; summary: string; messages: readonly Readonly<{ id: string; role: "assistant" \| "system" \| "tool" \| "user"; content: string; } & { calls?: readonly Readonly<{ id: string; name: string; arguments: { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; } & {}>[]; call?: string; images?: readonly string[]; thinking?: string; }>[]; } & {}>[]; messages: readonly Readonly<{ id: string; role: "assistant" \| "system" \| "tool" \| "user"; content: string; } & { calls?: readonly Readonly<{ id: string; name: string; arguments: { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; } & {}>[]; call?: string; images?: readonly string[]; thinking?: string; }>[]; } & { judgments?: readonly (Readonly<{ id: string; question: Readonly<{ form: "choice"; criteria: { readonly [k: string]: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null; }; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "score"; criteria: readonly (string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null)[]; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "noul"; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; criteria?: Readonly<{} & { true?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; false?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }>; }>; model: string; sources: readonly string[]; state: string; time: number; answer: Readonly<{ form: "choice"; probabilities: { readonly [k: string]: number; }; } & {}> \| Readonly<{ form: "score"; probabilities: readonly number[]; } & {}> \| Readonly<{ form: "noul"; noul: number; } & {}>; } & { usage?: Readonly<{ prompt: number; completion: number; total: number; } & {}>; }> \| Readonly<{ id: string; question: Readonly<{ form: "choice"; criteria: { readonly [k: string]: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null; }; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "score"; criteria: readonly (string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null)[]; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "noul"; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; criteria?: Readonly<{} & { true?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; false?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }>; }>; model: string; sources: readonly string[]; state: string; time: number; refusal: Readonly<{ missing: readonly string[]; } & {}>; } & { usage?: Readonly<{ prompt: number; completion: number; total: number; } & {}>; }>)[]; }>; requests: readonly string[]; notes: readonly string[]; failures: readonly string[]; } & { gauge?: Readonly<{ scale: number; overhead: number; } & {}>; window?: Readonly<{ digest: string; exchanges: readonly Readonly<{ request: string; reply: string; lines: readonly Readonly<{ key: string; title: string; source: string; sentence: number; } & {}>[]; } & { copy?: string; }>[]; amendments: readonly Readonly<{ earlier: string; later: string; } & {}>[]; } & {}>; }>>` | Reads structural faults of a ledger snapshot, including its optional held exchange window. |
|
|
1704
|
-
| `isPositiveSafeInteger` | function | `(value: unknown) => value is number` | Checks whether a value is a positive safe integer. |
|
|
1705
|
-
| `isLedgerWindowSnapshot` | function | `(value: unknown) => value is LedgerWindowSnapshot` | Checks whether a value has the exact shape of a nonempty exchange window. |
|
|
1706
|
-
| `isLedgerSnapshot` | function | `(value: unknown) => value is LedgerSnapshot` | Checks whether a value is a ledger snapshot whose marked ids name messages of its own conversation. |
|
|
1710
|
+
| Name | Kind | Signature | Summary |
|
|
1711
|
+
| ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1712
|
+
| `isFraction` | function | `(value: unknown) => value is number` | Checks whether a value is finite and lies in the interval (0, 1\]. |
|
|
1713
|
+
| `isLedgerQuestion` | function | `(value: unknown) => value is LedgerQuestion` | Checks whether a value holds the wording a ledger files with: a choice `category` question whose criteria describe every category, a non-empty `topic` string, and noul `amends` and `supersedes` questions. |
|
|
1714
|
+
| `ledgerWindowShape` | const | `import("@orkestrel/contract").ObjectShape<{ digest: import("@orkestrel/contract").StringShape; exchanges: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ request: import("@orkestrel/contract").StringShape; copy: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; reply: import("@orkestrel/contract").StringShape; lines: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ key: import("@orkestrel/contract").StringShape; title: import("@orkestrel/contract").StringShape; source: import("@orkestrel/contract").StringShape; sentence: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; amendments: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ earlier: import("@orkestrel/contract").StringShape; later: import("@orkestrel/contract").StringShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>` | Describes the minimal serialized evidence of a nonempty exchange window. |
|
|
1715
|
+
| `ledgerWindowContract` | const | `import("@orkestrel/contract").ContractInterface<Readonly<{ digest: string; exchanges: readonly Readonly<{ request: string; reply: string; lines: readonly Readonly<{ key: string; title: string; source: string; sentence: number; } & {}>[]; } & { copy?: string; }>[]; amendments: readonly Readonly<{ earlier: string; later: string; } & {}>[]; } & {}>>` | Reads structural faults of a serialized exchange window. |
|
|
1716
|
+
| `ledgerSnapshotShape` | const | `import("@orkestrel/contract").ObjectShape<{ conversation: import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; sections: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; summary: import("@orkestrel/contract").StringShape; messages: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; role: import("@orkestrel/contract").LiteralShape<readonly ["system", "user", "assistant", "tool"]>; content: import("@orkestrel/contract").StringShape; calls: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; name: import("@orkestrel/contract").StringShape; arguments: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>; }, boolean \| ContractShape>>>; call: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; images: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>>; thinking: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; messages: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; role: import("@orkestrel/contract").LiteralShape<readonly ["system", "user", "assistant", "tool"]>; content: import("@orkestrel/contract").StringShape; calls: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; name: import("@orkestrel/contract").StringShape; arguments: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>; }, boolean \| ContractShape>>>; call: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; images: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>>; thinking: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; }, boolean \| ContractShape>>; judgments: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; question: import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["choice"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["score"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["noul"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ true: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; false: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>]>; model: import("@orkestrel/contract").StringShape; sources: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; state: import("@orkestrel/contract").StringShape; time: import("@orkestrel/contract").NumberShape; usage: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ prompt: import("@orkestrel/contract").NumberShape; completion: import("@orkestrel/contract").NumberShape; total: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; answer: import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["choice"]>; probabilities: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").NumberShape>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["score"]>; probabilities: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").NumberShape>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["noul"]>; noul: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>]>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ id: import("@orkestrel/contract").StringShape; question: import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["choice"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["score"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").NullableShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>>; }, boolean \| ContractShape>, import("@orkestrel/contract").ObjectShape<{ form: import("@orkestrel/contract").LiteralShape<readonly ["noul"]>; instructions: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; criteria: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ true: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; false: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").UnionShape<readonly [import("@orkestrel/contract").StringShape, import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").JSONShape>, import("@orkestrel/contract").ObjectShape<Record<never, never>, import("@orkestrel/contract").JSONShape>]>>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>]>; model: import("@orkestrel/contract").StringShape; sources: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; state: import("@orkestrel/contract").StringShape; time: import("@orkestrel/contract").NumberShape; usage: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ prompt: import("@orkestrel/contract").NumberShape; completion: import("@orkestrel/contract").NumberShape; total: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; refusal: import("@orkestrel/contract").ObjectShape<{ missing: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; }, boolean \| ContractShape>; }, boolean \| ContractShape>]>>>; }, boolean \| ContractShape>; requests: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; notes: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; failures: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").StringShape>; gauge: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ scale: import("@orkestrel/contract").NumberShape; overhead: import("@orkestrel/contract").NumberShape; digest: import("@orkestrel/contract").StringShape; }, boolean \| ContractShape>>; window: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").ObjectShape<{ digest: import("@orkestrel/contract").StringShape; exchanges: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ request: import("@orkestrel/contract").StringShape; copy: import("@orkestrel/contract").OptionalShape<import("@orkestrel/contract").StringShape>; reply: import("@orkestrel/contract").StringShape; lines: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ key: import("@orkestrel/contract").StringShape; title: import("@orkestrel/contract").StringShape; source: import("@orkestrel/contract").StringShape; sentence: import("@orkestrel/contract").NumberShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; amendments: import("@orkestrel/contract").ArrayShape<import("@orkestrel/contract").ObjectShape<{ earlier: import("@orkestrel/contract").StringShape; later: import("@orkestrel/contract").StringShape; }, boolean \| ContractShape>>; }, boolean \| ContractShape>>; }, boolean \| ContractShape>` | Describes a ledger snapshot exactly: an unknown key refuses, so a key a later version adds never reads as absent. |
|
|
1717
|
+
| `ledgerSnapshotContract` | const | `import("@orkestrel/contract").ContractInterface<Readonly<{ conversation: Readonly<{ id: string; sections: readonly Readonly<{ id: string; summary: string; messages: readonly Readonly<{ id: string; role: "assistant" \| "system" \| "tool" \| "user"; content: string; } & { calls?: readonly Readonly<{ id: string; name: string; arguments: { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; } & {}>[]; call?: string; images?: readonly string[]; thinking?: string; }>[]; } & {}>[]; messages: readonly Readonly<{ id: string; role: "assistant" \| "system" \| "tool" \| "user"; content: string; } & { calls?: readonly Readonly<{ id: string; name: string; arguments: { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; } & {}>[]; call?: string; images?: readonly string[]; thinking?: string; }>[]; } & { judgments?: readonly (Readonly<{ id: string; question: Readonly<{ form: "choice"; criteria: { readonly [k: string]: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null; }; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "score"; criteria: readonly (string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null)[]; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "noul"; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; criteria?: Readonly<{} & { true?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; false?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }>; }>; model: string; sources: readonly string[]; state: string; time: number; answer: Readonly<{ form: "choice"; probabilities: { readonly [k: string]: number; }; } & {}> \| Readonly<{ form: "score"; probabilities: readonly number[]; } & {}> \| Readonly<{ form: "noul"; noul: number; } & {}>; } & { usage?: Readonly<{ prompt: number; completion: number; total: number; } & {}>; }> \| Readonly<{ id: string; question: Readonly<{ form: "choice"; criteria: { readonly [k: string]: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null; }; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "score"; criteria: readonly (string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; } \| null)[]; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }> \| Readonly<{ form: "noul"; } & { instructions?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; criteria?: Readonly<{} & { true?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; false?: string \| readonly import("@orkestrel/contract").JSONValue[] \| { readonly [k: string]: import("@orkestrel/contract").JSONValue; }; }>; }>; model: string; sources: readonly string[]; state: string; time: number; refusal: Readonly<{ missing: readonly string[]; } & {}>; } & { usage?: Readonly<{ prompt: number; completion: number; total: number; } & {}>; }>)[]; }>; requests: readonly string[]; notes: readonly string[]; failures: readonly string[]; } & { gauge?: Readonly<{ scale: number; overhead: number; digest: string; } & {}>; window?: Readonly<{ digest: string; exchanges: readonly Readonly<{ request: string; reply: string; lines: readonly Readonly<{ key: string; title: string; source: string; sentence: number; } & {}>[]; } & { copy?: string; }>[]; amendments: readonly Readonly<{ earlier: string; later: string; } & {}>[]; } & {}>; }>>` | Reads structural faults of a ledger snapshot, including its optional held exchange window. |
|
|
1718
|
+
| `isPositiveSafeInteger` | function | `(value: unknown) => value is number` | Checks whether a value is a positive safe integer. |
|
|
1719
|
+
| `isLedgerWindowSnapshot` | function | `(value: unknown) => value is LedgerWindowSnapshot` | Checks whether a value has the exact shape of a nonempty exchange window. |
|
|
1720
|
+
| `isLedgerSnapshot` | function | `(value: unknown) => value is LedgerSnapshot` | Checks whether a value is a ledger snapshot whose marked ids name messages of its own conversation. |
|
|
1707
1721
|
|
|
1708
1722
|
#### Helpers
|
|
1709
1723
|
|
|
1710
1724
|
The following table lists the pure helpers that read text, project and select records, render the records, fit a price, and hold the window:
|
|
1711
1725
|
|
|
1712
|
-
| Name
|
|
1713
|
-
|
|
|
1714
|
-
| `splitSentences`
|
|
1715
|
-
| `collectNames`
|
|
1716
|
-
| `identifyLookup`
|
|
1717
|
-
| `linkOwners`
|
|
1718
|
-
| `collectRegistry`
|
|
1719
|
-
| `buildLedgerIndex`
|
|
1720
|
-
| `matchEntities`
|
|
1721
|
-
| `normalizeWord`
|
|
1722
|
-
| `buildRecords`
|
|
1723
|
-
| `selectRecords`
|
|
1724
|
-
| `findLedgerCall`
|
|
1725
|
-
| `collectProjectionIds`
|
|
1726
|
-
| `scanAmendments`
|
|
1727
|
-
| `buildRecallMessage`
|
|
1728
|
-
| `buildRequestMessage`
|
|
1729
|
-
| `renderTopicNames`
|
|
1730
|
-
| `renderCauseChain`
|
|
1731
|
-
| `extractWords`
|
|
1732
|
-
| `splitWords`
|
|
1733
|
-
| `rankLedgerCut`
|
|
1734
|
-
| `findLedgerCut`
|
|
1735
|
-
| `buildLedgerCut`
|
|
1736
|
-
| `renderLedgerRecord`
|
|
1737
|
-
| `renderLedgerPinned`
|
|
1738
|
-
| `splitTopic`
|
|
1739
|
-
| `cutListing`
|
|
1740
|
-
| `matchesCutLine`
|
|
1741
|
-
| `normalizeArgument`
|
|
1742
|
-
| `splitResultLines`
|
|
1743
|
-
| `renderLookupCall`
|
|
1744
|
-
| `renderStub`
|
|
1745
|
-
| `computeThinking`
|
|
1746
|
-
| `resolvePredict`
|
|
1747
|
-
| `fitSlope`
|
|
1748
|
-
| `
|
|
1749
|
-
| `
|
|
1750
|
-
| `
|
|
1751
|
-
| `
|
|
1752
|
-
| `
|
|
1753
|
-
| `
|
|
1754
|
-
| `
|
|
1755
|
-
| `
|
|
1756
|
-
| `
|
|
1757
|
-
| `
|
|
1758
|
-
| `
|
|
1759
|
-
| `
|
|
1760
|
-
| `
|
|
1761
|
-
| `
|
|
1726
|
+
| Name | Kind | Signature | Summary |
|
|
1727
|
+
| --------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1728
|
+
| `splitSentences` | function | `(text: string) => readonly string[]` | Splits a message into its sentences. |
|
|
1729
|
+
| `collectNames` | function | `(text: string) => readonly string[]` | Collects the capitalized name runs of a text, leaving out the run that opens each sentence. |
|
|
1730
|
+
| `identifyLookup` | function | `(name: string, args: Readonly<Record<string, unknown>>) => string \| undefined` | Identifies a lookup finding for projection by its tool name and normalized arguments. |
|
|
1731
|
+
| `linkOwners` | function | `(findings: readonly LedgerLookupFinding[], owners: ReadonlyMap<string, readonly string[]>) => ReadonlyMap<string, string>` | Links each id-shaped lookup argument to its owner. |
|
|
1732
|
+
| `collectRegistry` | function | `(findings: readonly LedgerLookupFinding[]) => LedgerRegistry` | Collects the ids and the owner names the lookup findings named. |
|
|
1733
|
+
| `buildLedgerIndex` | function | `(registry: LedgerRegistry) => LedgerIndex` | Builds a registry's matching index: each name's owners, each word's carriers, the needles, keys, and ranks. |
|
|
1734
|
+
| `matchEntities` | function | `(index: LedgerIndex, text: string, partial: boolean) => ReadonlySet<string>` | Matches the registry ids and owners a text names. |
|
|
1735
|
+
| `normalizeWord` | function | `(word: string) => string` | Normalizes a run of letters and digits to the one form each of its cases folds to. |
|
|
1736
|
+
| `buildRecords` | function | `(input: LedgerProjectionInput) => LedgerProjection` | Projects the owner records and the rules record from a conversation's messages. |
|
|
1737
|
+
| `selectRecords` | function | `(projection: LedgerProjection, request: LedgerProjectionRequest) => readonly LedgerRecord[]` | Selects a request's records, collapsing owners with equal ordered member ids under titles joined with `; `. |
|
|
1738
|
+
| `findLedgerCall` | function | `(group: readonly Message[], message: Message) => ToolCall \| undefined` | Finds the call that owns a tool message within a collected tool group. |
|
|
1739
|
+
| `collectProjectionIds` | function | `(projection: LedgerProjection) => ReadonlySet<string>` | Collects the live message ids placed in records or left without a record. |
|
|
1740
|
+
| `scanAmendments` | function | `(amendments: ReadonlyMap<string, readonly string[]>, start: string, admit: (id: string) => boolean) => readonly string[]` | Scans admitted amendments in breadth-first order without revisiting a message. |
|
|
1741
|
+
| `buildRecallMessage` | function | `(topic: string) => Message` | Builds the placeholder assistant recall call used to price recall framing. |
|
|
1742
|
+
| `buildRequestMessage` | function | `(request: Message, records: string) => Message` | Builds the copy of a request turn that carries the rendered records ahead of the request. |
|
|
1743
|
+
| `renderTopicNames` | function | `(topics: readonly LedgerTopic[]) => string` | Renders topic names as a comma-separated list in their supplied order. |
|
|
1744
|
+
| `renderCauseChain` | function | `(error: unknown) => string` | Renders an error and its causes, stopping after 4 entries. |
|
|
1745
|
+
| `extractWords` | function | `(message: Message) => LedgerWordSet` | Extracts lowercase words and capitalized names that do not open a sentence. |
|
|
1746
|
+
| `splitWords` | function | `(part: string) => readonly string[]` | Splits a topic part into lowercase words with surrounding punctuation removed. |
|
|
1747
|
+
| `rankLedgerCut` | function | `(group: LedgerPlanGroup, unsettled: boolean, category: LedgerCategory \| undefined) => number` | Ranks a source the records render for removal before the next prompt. |
|
|
1748
|
+
| `findLedgerCut` | function | `<T>(low: number, high: number, probe: (cut: number) => T \| undefined, found?: T) => T \| undefined` | Finds the first cut in a range whose probe returns a value, by bisection. |
|
|
1749
|
+
| `buildLedgerCut` | function | `(steps: ReadonlyArray<LedgerLine \| string>, records: readonly LedgerRecord[], included: ReadonlySet<string>) => { readonly records: readonly LedgerRecord[]; readonly included: ReadonlySet<string>; }` | Builds the cut the given steps leave: each step drops the line it is, by identity, or the source it names. |
|
|
1750
|
+
| `renderLedgerRecord` | function | `(record: Pick<LedgerRecord, 'title' \| 'lines'>, context?: LedgerRenderContext) => string` | Renders one record as a heading and one list item per line. |
|
|
1751
|
+
| `renderLedgerPinned` | function | `(record: Pick<LedgerRecord, 'title' \| 'lines'>, context?: LedgerRenderContext) => string` | Renders one owner record under a `###` heading, which the records nest under their one `## Records` heading. |
|
|
1752
|
+
| `splitTopic` | function | `(topic: string) => readonly string[]` | Splits a recall topic at its joints. |
|
|
1753
|
+
| `cutListing` | function | `(entries: readonly string[], room: number, kind?: 'older' \| 'more', first?: boolean) => string` | Cuts entries to a room and names how many it left out. |
|
|
1754
|
+
| `matchesCutLine` | function | `(line: string) => boolean` | Checks whether a line is the cut line `cutListing` writes. |
|
|
1755
|
+
| `normalizeArgument` | function | `(value: string) => string` | Normalizes a lookup argument string to the spelling that lookup identity and owner linking compare. |
|
|
1756
|
+
| `splitResultLines` | function | `(text: string) => readonly string[]` | Splits a tool result into its lines at each line feed, with or without a carriage return before it. |
|
|
1757
|
+
| `renderLookupCall` | function | `(name: string, args: Readonly<Record<string, unknown>>) => string` | Renders a lookup call as its tool name and its JSON arguments. |
|
|
1758
|
+
| `renderStub` | function | `(name: string, args: Readonly<Record<string, unknown>>, state: LedgerLookupState, write?: boolean) => string` | Renders the tail stub of a lookup result from an earlier request. |
|
|
1759
|
+
| `computeThinking` | function | `(message: Pick<Message, 'thinking' \| 'content' \| 'calls'>, completion: number) => number` | Computes the completion tokens attributable to a message's thinking. |
|
|
1760
|
+
| `resolvePredict` | function | `(predict: number \| undefined, capacity: number) => number` | Resolves the generation cap and checks it against the context capacity. |
|
|
1761
|
+
| `fitSlope` | function | `(groups: ReadonlyArray<readonly GaugeCall[]>) => number \| undefined` | Fits the marginal tokens one estimate unit adds within a request. |
|
|
1762
|
+
| `collectWriteSupersessions` | function | `(messages: readonly Message[], findings: readonly LedgerLookupFinding[]) => ReadonlyMap<string, readonly string[]>` | Collects each finding a write made stale, mapped to the writes that supersede it. |
|
|
1763
|
+
| `collectRetiredFindings` | function | `(messages: readonly Message[], findings: readonly LedgerLookupFinding[]) => ReadonlySet<string>` | Collects the findings a write superseded or a later finding of the same lookup replaced. |
|
|
1764
|
+
| `mergeSupersessions` | function | `(classification: LedgerClassification, edges: ReadonlyMap<string, readonly string[]>, messages: readonly Message[]) => LedgerClassification` | Merges supersession edges into a classification, adding each edge to both its supersessions and its amendments. |
|
|
1765
|
+
| `collectLive` | function | `(input: LedgerProjectionInput) => readonly string[]` | Collects the ids of the live messages in conversation order. |
|
|
1766
|
+
| `placeMember` | function | `(input: LedgerProjectionInput, links: ReadonlyMap<string, string>, amended: ReadonlyMap<string, readonly string[]>, id: string, seen: ReadonlySet<string>, settled?: Map<string, ReadonlySet<string>>) => ReadonlySet<string>` | Places a message on the record keys it joins. |
|
|
1767
|
+
| `buildLedgerRenderContext` | function | `(messages: readonly Message[], lines: readonly LedgerLine[], amendments: readonly LedgerAmendment[]) => LedgerRenderContext` | Derives complete source identities, first occurrences, and local references from the actual lines of the records. |
|
|
1768
|
+
| `renderLedgerAnnotation` | function | `(line: LedgerLine, context: LedgerRenderContext) => string` | Renders a source's reference and its later changes at the source's first retained line. |
|
|
1769
|
+
| `collectAmendments` | function | `(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, live: readonly string[]) => readonly LedgerAmendment[]` | Collects accepted amendments of live messages, following superseded amenders to live successors. |
|
|
1770
|
+
| `buildLines` | function | `(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, id: string, holders: readonly string[], system: readonly string[]) => readonly LedgerLine[]` | Builds the record lines of one message. |
|
|
1771
|
+
| `collectRecallMessages` | function | `(input: LedgerProjectionInput, requests: ReadonlySet<string>, notes: ReadonlySet<string>) => readonly Message[]` | Collects stored messages eligible to open the recall offer. |
|
|
1772
|
+
| `hasHiddenRecall` | function | `(input: LedgerProjectionInput, request: string, requests: ReadonlySet<string>, notes: ReadonlySet<string>, messages: readonly Message[], lines: readonly LedgerReceipt[]) => boolean` | Checks whether an eligible earlier message is absent from the prompt or incompletely covered. A successful finding is held when a finding with the same canonical identity and text is fully received. |
|
|
1773
|
+
| `matchesLookup` | function | `(left: LedgerLookupFinding, right: LedgerLookupFinding) => boolean` | Checks whether two successful findings carry the same text for the same canonical lookup. |
|
|
1774
|
+
| `digestLedgerWindow` | function | `(exchanges: readonly LedgerExchangeSnapshot[], messages: readonly Message[]) => string \| undefined` | Digests held messages, lookup call context, stored copies, and sentence receipts using canonical text. This non-cryptographic checksum detects host edits and makes no security claim. |
|
|
1775
|
+
| `digestLedgerTools` | function | `(definitions: readonly ToolDefinition[]) => string \| undefined` | Digests tool definitions as the JSON a provider request carries them, in order. |
|
|
1776
|
+
| `computeLedgerChecksum` | function | `(text: string) => string` | Computes a checksum of text: two 32-bit FNV-1a lanes over its code points, as 16 hexadecimal digits. |
|
|
1777
|
+
| `buildLedgerLineKey` | function | `(line: Pick<LedgerOccurrence, 'key' \| 'title' \| 'source' \| 'sentence'>) => string` | Encodes a sentence's record placement without comparing rendered text. |
|
|
1778
|
+
| `collectLedgerLines` | function | `(record: LedgerRecord, held: ReadonlySet<string>) => readonly LedgerOccurrence[]` | Collects the record's sentence receipts not already held by a window. |
|
|
1779
|
+
| `collectLedgerReplies` | function | `(messages: readonly Message[], requests: ReadonlySet<string>, notes: ReadonlySet<string>) => ReadonlyMap<string, Message>` | Selects each marked request's unambiguous final call-free reply. |
|
|
1780
|
+
| `collectLedgerEvidence` | function | `(messages: readonly Message[], sources: ReadonlySet<string>, amendments: readonly LedgerAmendment[]) => LedgerEvidence` | Captures source bytes and direct amendment edges for a held window. |
|
|
1762
1781
|
|
|
1763
1782
|
The `Classifier` and `Gauge` classes the ledger composes are public, so a harness can file a conversation or price a prompt without a ledger. The following classifier files one rule, and the following gauge prices the calls of one request:
|
|
1764
1783
|
|
|
@@ -2194,27 +2213,31 @@ The conversation ledger. The `respond` method serves one request through to its
|
|
|
2194
2213
|
|
|
2195
2214
|
#### `LedgerRequestInterface`
|
|
2196
2215
|
|
|
2197
|
-
The state of one `respond` call. The ledger creates one request per call and drops it when the call settles, so no request state reaches a later call or a run no call owns. Each agent run the call makes is a pass: the `open` method starts one, and the `selection`, `boundary`, and `usage` data members read the current pass. The `scope`, `sent`, `message`, `plan`, `selection`, `boundary`, `usage`, `calls`, and `
|
|
2198
|
-
|
|
2199
|
-
| Method | Returns | Summary
|
|
2200
|
-
| --------- | ------------------------------------------ |
|
|
2201
|
-
| `enter` | `Message` | Appends the request's content to a conversation as a user message, once, and holds it as `message`.
|
|
2202
|
-
| `open` | `void` | Opens a pass, which becomes the current pass.
|
|
2203
|
-
| `apply` | `void` | Records the scope applied by the ledger's plan for conditional restoration at settle.
|
|
2204
|
-
| `fault` | `void` | Records an error the request's run reported through its `fault` event.
|
|
2205
|
-
| `faulted` | `boolean` | Reports whether the request's run reported this error through its `fault` event.
|
|
2206
|
-
| `adopt` | `void` | Records the selection the current pass's run adopted and adds the usage it spent.
|
|
2207
|
-
| `observe` | `void` | Starts a gauge call in the current pass, making that pass's call in flight final.
|
|
2208
|
-
| `spend` | `void` | Adds one call's reported usage to the current pass and records it on the call in flight.
|
|
2209
|
-
| `think` | `void` | Records the thinking share of the call in flight, read from the first assistant message after the call's position.
|
|
2210
|
-
| `file` | `void` | Appends the attempts of one planning selection and holds its plan when planning succeeded.
|
|
2211
|
-
| `admit` | `void` | Admits one tool call of the request, compared by tool name and canonical arguments.
|
|
2212
|
-
| `
|
|
2213
|
-
| `
|
|
2214
|
-
| `
|
|
2215
|
-
| `
|
|
2216
|
-
|
|
2217
|
-
|
|
2216
|
+
The state of one `respond` call. The ledger creates one request per call and drops it when the call settles, so no request state reaches a later call or a run no call owns. Each agent run the call makes is a pass: the `open` method starts one, and the `selection`, `boundary`, and `usage` data members read the current pass. The `signal` and `aborted` data members read the current pass too, and `aborted` reads `signal`. The `scope`, `sent`, `message`, `plan`, `selection`, `boundary`, `usage`, `calls`, `attempts`, `signal`, and `aborted` data members stay Surface rows. The `apply(scope)` method records the scope applied by the plan for conditional restoration when the call settles.
|
|
2217
|
+
|
|
2218
|
+
| Method | Returns | Summary |
|
|
2219
|
+
| --------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
2220
|
+
| `enter` | `Message` | Appends the request's content to a conversation as a user message, once, and holds it as `message`. |
|
|
2221
|
+
| `open` | `void` | Opens a pass, which becomes the current pass. |
|
|
2222
|
+
| `apply` | `void` | Records the scope applied by the ledger's plan for conditional restoration at settle. |
|
|
2223
|
+
| `fault` | `void` | Records an error the request's run reported through its `fault` event. |
|
|
2224
|
+
| `faulted` | `boolean` | Reports whether the request's run reported this error through its `fault` event. |
|
|
2225
|
+
| `adopt` | `void` | Records the selection the current pass's run adopted and adds the usage it spent. |
|
|
2226
|
+
| `observe` | `void` | Starts a gauge call in the current pass, making that pass's call in flight final. |
|
|
2227
|
+
| `spend` | `void` | Adds one call's reported usage to the current pass and records it on the call in flight. |
|
|
2228
|
+
| `think` | `void` | Records the thinking share of the call in flight, read from the first assistant message after the call's position. |
|
|
2229
|
+
| `file` | `void` | Appends the attempts of one planning selection and holds its plan when planning succeeded. |
|
|
2230
|
+
| `admit` | `void` | Admits one tool call of the request, compared by tool name and canonical arguments. |
|
|
2231
|
+
| `release` | `void` | Releases one tool call the request admitted, so a later `admit` of the same call passes. |
|
|
2232
|
+
| `deny` | `void` | Records one tool call the authority denied, declined, or left unanswered, so `denied` reports it for the rest of the request. |
|
|
2233
|
+
| `denied` | `boolean` | Reports whether the request recorded this tool call as denied. |
|
|
2234
|
+
| `recall` | `void` | Counts one `recall` call, closing the request's recall tool when its recalls reach the limit. |
|
|
2235
|
+
| `close` | `void` | Closes the request's recall tool, so every later `recall` call throws the closure note. |
|
|
2236
|
+
| `abort` | `void` | Aborts the current pass's run through `signal`, with the reason `'stray'`, so the run ends after its turn. |
|
|
2237
|
+
| `list` | `void` | Holds the stored first line of each lookup a recall result listed, keyed by its listed line. |
|
|
2238
|
+
| `lines` | `ReadonlyMap<string, string> \| undefined` | Returns the stored first lines a recall result listed. |
|
|
2239
|
+
|
|
2240
|
+
The ledger drives each request through these methods, and a harness can drive one directly to check its stops. The following request serves one pass, then refuses a repeated lookup, admits it again after a release, records a denied write, and refuses a recall past its limit:
|
|
2218
2241
|
|
|
2219
2242
|
```ts
|
|
2220
2243
|
import type { Selection } from '@orkestrel/agent'
|
|
@@ -2243,6 +2266,11 @@ request.calls // [{ estimate: 40, tools: 2, prompt: 52, completion: 8 }] — the
|
|
|
2243
2266
|
|
|
2244
2267
|
request.admit('lookup_order', { id: 'BW-5512' })
|
|
2245
2268
|
request.admit('lookup_order', { id: 'BW-5512' }) // throws Error(LEDGER_NOTES.repeat)
|
|
2269
|
+
request.release('lookup_order', { id: 'BW-5512' }) // as a write that retired its finding does
|
|
2270
|
+
request.admit('lookup_order', { id: 'BW-5512' }) // passes once more
|
|
2271
|
+
request.deny('refund_order', { id: 'BW-5512' }) // as the agent's `deny` event with a decision does
|
|
2272
|
+
request.denied('refund_order', { id: 'BW-5512' }) // true — the ledger denies its identical retry as a repeat
|
|
2273
|
+
request.denied('refund_order', { id: 'BW-5513' }) // false — other arguments are another call
|
|
2246
2274
|
request.recall()
|
|
2247
2275
|
request.recall() // throws Error(LEDGER_NOTES.closure) — the 1 recall call is spent
|
|
2248
2276
|
|
|
@@ -3402,7 +3430,55 @@ copies[1]
|
|
|
3402
3430
|
|
|
3403
3431
|
The second request names Brightwater Studio, so its copy carries that owner's record, built from the first request's lookup result. It leaves out the rule, because the first request's copy, which follows the seed tail in the window with its final reply, holds it. The system message holds the `system` option alone. The executed transcription runs this fence with its own cutoffs and reads the prompts the provider received; see [the `tests/guides.test.ts` parity test](../tests/guides.test.ts).
|
|
3404
3432
|
|
|
3405
|
-
|
|
3433
|
+
Register a tool whose call changes a record as a write, through the `writes` option, and gate it through the `authority` member of the `agent` option, which a ledger with writes requires. The write's tool carries the `consequential` annotation, so the floor raises the authority's `allow` to an `ask` and its `ask` handler approves each call. Its `read` handler returns what a lookup's handler returns plus `targets`, the ids whose state the call changed or removed. The ledger files the write's result as a finding, and the targets retire every earlier finding that names one, so the next copy holds the new value:
|
|
3434
|
+
|
|
3435
|
+
```ts
|
|
3436
|
+
import type { LedgerLookup, LedgerOptions, LedgerWrite, ProviderInterface } from '@orkestrel/agent'
|
|
3437
|
+
import { createAuthority, createLedger } from '@orkestrel/agent'
|
|
3438
|
+
|
|
3439
|
+
declare const provider: ProviderInterface // replies with a `lookup_contact` call, an `update_contact` call, 'Updated.', then 'She is on 555-0102.'
|
|
3440
|
+
declare const options: LedgerOptions // the judge, system, topics, questions, thresholds, and capacity above, with a stored gauge
|
|
3441
|
+
declare const lookup: LedgerLookup // `lookup_contact`, which reads 'Contact C-12: Mara Quill. Phone 555-0101.'
|
|
3442
|
+
declare function confirm(name: string): Promise<boolean> // asks the person, who approves
|
|
3443
|
+
|
|
3444
|
+
const write: LedgerWrite = {
|
|
3445
|
+
tool: {
|
|
3446
|
+
name: 'update_contact',
|
|
3447
|
+
description: "Set a contact's phone.",
|
|
3448
|
+
parameters: {
|
|
3449
|
+
type: 'object',
|
|
3450
|
+
properties: { id: { type: 'string' }, phone: { type: 'string' } },
|
|
3451
|
+
required: ['id', 'phone'],
|
|
3452
|
+
},
|
|
3453
|
+
annotations: { consequential: true },
|
|
3454
|
+
execute: (args) => `Contact ${String(args.id)}: Mara Quill. Phone ${String(args.phone)}.`,
|
|
3455
|
+
},
|
|
3456
|
+
read: (args) => ({
|
|
3457
|
+
ids: [String(args.id)],
|
|
3458
|
+
owners: [{ id: String(args.id), names: ['Mara Quill'] }],
|
|
3459
|
+
targets: [String(args.id)], // the contact whose earlier reads this call made stale
|
|
3460
|
+
}),
|
|
3461
|
+
}
|
|
3462
|
+
const ledger = createLedger(provider, {
|
|
3463
|
+
...options,
|
|
3464
|
+
lookups: [lookup],
|
|
3465
|
+
writes: [write],
|
|
3466
|
+
agent: {
|
|
3467
|
+
authority: createAuthority({
|
|
3468
|
+
fallback: { zone: 'desk', verdict: 'allow' },
|
|
3469
|
+
ask: (context) => confirm(context.call.name),
|
|
3470
|
+
}),
|
|
3471
|
+
},
|
|
3472
|
+
})
|
|
3473
|
+
const copies: Array<string | undefined> = []
|
|
3474
|
+
ledger.agent.emitter.on('select', (selection) => copies.push(selection.messages.at(-1)?.content))
|
|
3475
|
+
await ledger.respond("Change Mara Quill's phone to 555-0102.")
|
|
3476
|
+
await ledger.respond("What is Mara Quill's phone?")
|
|
3477
|
+
copies[1]
|
|
3478
|
+
// "## Records\n### Mara Quill (C-12)\n- Contact C-12: Mara Quill.\n- Phone 555-0102.\n\n## Request\nWhat is Mara Quill's phone?" — the write retired the read of 555-0101
|
|
3479
|
+
```
|
|
3480
|
+
|
|
3481
|
+
To carry a ledger across a restart, store what its `snapshot` method returns and pass it back as the `snapshot` option of a later `createLedger` call. The snapshot is plain JSON: the conversation with its judgments, the ids of the requests, notes, and failed tool results the ledger marked, the gauge with the digest of the tool definitions it priced, and the window while it holds an exchange. Narrow a parsed snapshot with the `isLedgerSnapshot` guard first, because construction refuses a snapshot the guard refuses with `LedgerError` code `'SNAPSHOT'`. The hydrated ledger makes no calibration call when the options carry a gauge or the snapshot carries one priced on the same tool definitions; with any other definitions, it calibrates before its first pass. It asks its judge no question the stored judgments answer. The following example continues the preceding ledger in a second ledger, and the second ledger sends the prompt the first would send for the same request. The window holds every line this request selects, so its copy is the request itself:
|
|
3406
3482
|
|
|
3407
3483
|
```ts
|
|
3408
3484
|
import type { LedgerInterface, LedgerOptions, ProviderInterface } from '@orkestrel/agent'
|
|
@@ -3691,12 +3767,12 @@ The following test files back this guide:
|
|
|
3691
3767
|
- [`tests/src/core/agents/contracts.test.ts`](../tests/src/core/agents/contracts.test.ts) — the frame, prompt, and answer contracts over every frame arm and every refused wire row, a throwing `Proxy`, and seeded values that agree with `parse`.
|
|
3692
3768
|
- [`tests/src/core/agents/validators.test.ts`](../tests/src/core/agents/validators.test.ts) — `isAuthorityDecision` over each verdict with and without `reason`, and its refusal of a `{ zone, allowed }` decision, an unknown verdict, a non-string `zone` or `reason`, a non-object, a throwing getter, a revoked `Proxy`, and a `Proxy` whose `get` trap throws.
|
|
3693
3769
|
- [`tests/src/core/agents/AgentFanout.test.ts`](../tests/src/core/agents/AgentFanout.test.ts) — `AgentFanout` through a real runner: one fan-out per unit across a retried attempt, every distinct unit's children, and the partial policy.
|
|
3694
|
-
- [`tests/src/core/ledgers/Ledger.test.ts`](../tests/src/core/ledgers/Ledger.test.ts) — the ledger over a scripted provider: owner records, seed stubs paired with their calls by call id and priced at their longer form, and the seed tail, the `'REQUEST'` fault of a run no active `respond` call owns, a run on another conversation, and the refused direct run during a request, the runs that stay on the ledger's conversation under a switch, the repeat stop, the answer pass and the abort that skips it, calibration with its replay at the next user boundary and its refusals, the filing of notes and failed lookups, the `recall` tool's listing, limit, room, and per-request offer with a host's scope kept and restored, the answer note's lines, the generation cap and thinking per pass, and retained amended sentences with unresolved scope while `recall`, the answer note, and the seed tail keep stored content, the window's extending copies, rungs, emptying, derived pair, rejected request, answered fallback, and stub state, and the snapshot and hydrate: selections and judge keys equal to the uninterrupted ledger's with each emptied mark list as a control, provider prompts equal through five JSON round trips, the `window` member's omission, refusals, and digest checked at hydrate, the JSON round trip, the `'CONCURRENCY'` refusal, the flush before capture, judgments kept across a judge abort, the `'SNAPSHOT'` refusals, the `'ROLE'` refusal of a hydrated `system` message, the gauge precedence, the fork, a recorded correction fixture replayed through a hydrated ledger, the replay from a sorted snapshot, each lookup result read once per selection, a message removed during a judge await kept out of that selection's plan, the forwarding of the `narrow` member to the classifier, head pricing and the built-head calibration, and the host turns: each entry refused during one, another thread's refused run and its recall, an append and a removal that fault the selection with no question about a gone message, a judgment removed during one asked again, an abort and a scheduler fault that leave the ledger free, the same bytes when paced, and the agent's turn between its own turns.
|
|
3695
|
-
- [`tests/src/core/ledgers/LedgerRequest.test.ts`](../tests/src/core/ledgers/LedgerRequest.test.ts) — the request's recall-limit refusal, its single `enter`, its passes with their selections, usage, calls, and thinking, its filing attempts and plan, the draft its last provider turn adopted as the `sent` member, the repeat stop, the recall limit and `close`, and the listings of a recall result.
|
|
3770
|
+
- [`tests/src/core/ledgers/Ledger.test.ts`](../tests/src/core/ledgers/Ledger.test.ts) — the ledger over a scripted provider: owner records, seed stubs paired with their calls by call id and priced at their longer form, and the seed tail, the `'REQUEST'` fault of a run no active `respond` call owns, a run on another conversation, and the refused direct run during a request, the runs that stay on the ledger's conversation under a switch, the repeat stop and the stop of the identical retry of a call the authority denied, the answer pass and the abort that skips it, calibration with its replay at the next user boundary and its refusals, the filing of notes and failed lookups, the `recall` tool's listing, limit, room, and per-request offer with a host's scope kept and restored, the answer note's lines, the generation cap and thinking per pass, and retained amended sentences with unresolved scope while `recall`, the answer note, and the seed tail keep stored content, the window's extending copies, rungs, emptying, derived pair, rejected request, answered fallback, and stub state, and the snapshot and hydrate: selections and judge keys equal to the uninterrupted ledger's with each emptied mark list as a control, provider prompts equal through five JSON round trips, the `window` member's omission, refusals, and digest checked at hydrate, the JSON round trip, the `'CONCURRENCY'` refusal, the flush before capture, judgments kept across a judge abort, the `'SNAPSHOT'` refusals, the `'ROLE'` refusal of a hydrated `system` message, the gauge precedence, the fork, a recorded correction fixture replayed through a hydrated ledger, the replay from a sorted snapshot, each lookup result read once per selection, a message removed during a judge await kept out of that selection's plan, the forwarding of the `narrow` member to the classifier, head pricing and the built-head calibration, and the host turns: each entry refused during one, another thread's refused run and its recall, an append and a removal that fault the selection with no question about a gone message, a judgment removed during one asked again, an abort and a scheduler fault that leave the ledger free, the same bytes when paced, and the agent's turn between its own turns.
|
|
3771
|
+
- [`tests/src/core/ledgers/LedgerRequest.test.ts`](../tests/src/core/ledgers/LedgerRequest.test.ts) — the request's recall-limit refusal, its single `enter`, its passes with their selections, usage, calls, and thinking, its filing attempts and plan, the draft its last provider turn adopted as the `sent` member, the repeat stop and its release, the denied calls, the recall limit and `close`, the abort of the current pass, and the listings of a recall result.
|
|
3696
3772
|
- [`tests/src/core/ledgers/Classifier.test.ts`](../tests/src/core/ledgers/Classifier.test.ts) — the measured question bytes and asking order, judgment reuse and usage, exact cutoffs, the category tie in `LEDGER_CATEGORIES` order, pair questions, deterministic and transient judge failures, abort faults that keep the completed judgments, the cached, skipped, resolved, failed, and aborted attempts each of those paths records, each message's quiet flag and near set read once per classification, with a change to the conversation or the judge's model read at the next call, the pairs of every eligible earlier message asked in conversation order and the narrower set of the `narrow` member, and the host turns: a yield after a slice elapses on a recording and a real scheduler, none in a live slice or with no scheduler, the same questions when paced, the asks a removed source skips, an abort during a turn, and a scheduler fault.
|
|
3697
3773
|
- [`tests/src/core/ledgers/Gauge.test.ts`](../tests/src/core/ledgers/Gauge.test.ts) — the gauge's construction refusals and its `observe`, `rate`, `remainder`, `reserve`, and `room` methods, under the generation cap and each replay policy.
|
|
3698
3774
|
- [`tests/src/core/ledgers/factories.test.ts`](../tests/src/core/ledgers/factories.test.ts) — `createLedger` and its `LedgerError` refusals for thresholds, shares, capacity, limits, topics, lookups, and a supplied gauge, the keys of the `LedgerAgentOptions` type, and the barrel exports of the ledger module.
|
|
3699
|
-
- [`tests/src/core/ledgers/helpers.test.ts`](../tests/src/core/ledgers/helpers.test.ts) — the projection helpers from `splitSentences` through `buildRecords` and `selectRecords`, the `normalizeWord` fold, the alias index the `buildLedgerIndex` function builds for the `matchEntities` function, the record renderers, `findLedgerCall`, `rankLedgerCut`, `findLedgerCut`, `buildLedgerCut`, `splitTopic`, `cutListing` and `matchesCutLine`, `renderStub`, `buildRequestMessage`, `normalizeArgument`, `splitResultLines`, `renderLookupCall`, `computeThinking`, `resolvePredict`, `fitSlope`, `digestLedgerWindow`, `collectRecallMessages`, `hasHiddenRecall`, `buildLedgerLineKey`, `collectLedgerLines`, `collectLedgerReplies`, and `collectLedgerEvidence`.
|
|
3775
|
+
- [`tests/src/core/ledgers/helpers.test.ts`](../tests/src/core/ledgers/helpers.test.ts) — the projection helpers from `splitSentences` through `buildRecords` and `selectRecords`, the `normalizeWord` fold, the alias index the `buildLedgerIndex` function builds for the `matchEntities` function, the record renderers, `findLedgerCall`, `rankLedgerCut`, `findLedgerCut`, `buildLedgerCut`, `splitTopic`, `cutListing` and `matchesCutLine`, `renderStub`, `buildRequestMessage`, `normalizeArgument`, `splitResultLines`, `renderLookupCall`, `computeThinking`, `resolvePredict`, `fitSlope`, `digestLedgerWindow`, `collectRecallMessages`, `collectRetiredFindings`, `hasHiddenRecall`, `buildLedgerLineKey`, `collectLedgerLines`, `collectLedgerReplies`, and `collectLedgerEvidence`.
|
|
3700
3776
|
- [`tests/src/core/ledgers/validators.test.ts`](../tests/src/core/ledgers/validators.test.ts) — `isFraction`, `isPositiveSafeInteger`, `isLedgerSnapshot`, which refuses every malformed snapshot, an unknown or mis-roled id, a throwing getter, and a revoked proxy, and accepts a snapshot a ledger returned, and `isLedgerWindowSnapshot`, which agrees with the `ledgerWindowContract` constant on a valid window and its malformed neighbors.
|
|
3701
3777
|
|
|
3702
3778
|
### Placement proofs
|