@orkestrel/agent 0.0.39 → 0.0.41

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.
@@ -1744,8 +1744,8 @@ export declare interface AgentResult {
1744
1744
  readonly usage?: TokenUsage;
1745
1745
  /**
1746
1746
  * Reports cancellation or a turn limit reached with unresolved tool intent.
1747
- * A reply to a turn advertising no tools is a complete answer (`false`), even if it
1748
- * contains calls: those calls are dropped and observed through the `deny` event.
1747
+ * A call in a reply to a turn advertising no tools is denied like any scoped-out call and the
1748
+ * loop runs another turn, so a run whose last allowed turn still carried a call is partial (`true`).
1749
1749
  */
1750
1750
  readonly partial: boolean;
1751
1751
  /**
@@ -3126,7 +3126,8 @@ export declare function collectLedgerReplies(messages: readonly Message[], reque
3126
3126
  * or superseded. When the whole run is superseded, its first finding reaches that final filter.
3127
3127
  * Different text or an undefined result replaces the earlier run, so an empty lookup leaves the
3128
3128
  * earlier result out of every record. A thrown lookup leaves the earlier result live. A finding
3129
- * with no canonical identity participates in no replacement.
3129
+ * with no canonical identity participates in no replacement. A finding a write retired is
3130
+ * superseded once {@link mergeSupersessions} merges the write's edges into the classification.
3130
3131
  *
3131
3132
  * @param input - The messages, findings, and classification to read
3132
3133
  * @returns The live message ids
@@ -3169,12 +3170,13 @@ export declare function collectProjectionIds(projection: LedgerProjection): Read
3169
3170
  /**
3170
3171
  * Collects stored messages eligible to open the recall offer.
3171
3172
  * @remarks
3172
- * Notes and findings without a result do not open the offer. User statements, including quiet
3173
- * statements available through recall's word route, can open it; this helper does not filter results.
3173
+ * Notes, findings without a result, and findings {@link collectRetiredFindings} names do not open
3174
+ * the offer. User statements, including quiet statements available through recall's word route,
3175
+ * can open it; this helper does not filter results.
3174
3176
  * @param input - The messages, findings, and classification
3175
3177
  * @param requests - The marked request ids
3176
3178
  * @param notes - The annotation ids to exclude
3177
- * @returns User statements, lookup findings with results, marked requests, and nonblank call-free replies
3179
+ * @returns User statements, lookup findings with results that no write superseded and no later finding replaced, marked requests, and nonblank call-free replies
3178
3180
  * @example
3179
3181
  * ```ts
3180
3182
  * collectRecallMessages(input, new Set(), new Set()) // eligible stored messages
@@ -3202,6 +3204,27 @@ export declare function collectRecallMessages(input: LedgerProjectionInput, requ
3202
3204
  */
3203
3205
  export declare function collectRegistry(findings: readonly LedgerLookupFinding[]): LedgerRegistry;
3204
3206
 
3207
+ /**
3208
+ * Collects the findings a write superseded or a later finding of the same lookup replaced.
3209
+ *
3210
+ * @remarks
3211
+ * A write supersedes the findings {@link collectWriteSupersessions} maps. A later finding of the
3212
+ * same canonical lookup identity, as {@link identifyLookup} writes it, replaces an earlier one when
3213
+ * its text differs or it holds no result, and a later finding with the same text replaces nothing.
3214
+ * A finding with no canonical identity is never replaced, and a finding the messages don't hold
3215
+ * takes no part. A supersession the judge files is not read here.
3216
+ *
3217
+ * @param messages - The conversation's messages, which fix each finding's position
3218
+ * @param findings - The lookup and write findings of those messages
3219
+ * @returns The ids of the superseded and replaced findings
3220
+ *
3221
+ * @example
3222
+ * ```ts
3223
+ * collectRetiredFindings(messages, findings) // Set { 'tool-1' } when tool-2 wrote what tool-1 read
3224
+ * ```
3225
+ */
3226
+ export declare function collectRetiredFindings(messages: readonly Message[], findings: readonly LedgerLookupFinding[]): ReadonlySet<string>;
3227
+
3205
3228
  /**
3206
3229
  * Collects each assistant message that carries calls together with the tool messages that answer
3207
3230
  * it, then each run of tool messages that no assistant message owns.
@@ -3225,6 +3248,29 @@ export declare function collectRegistry(findings: readonly LedgerLookupFinding[]
3225
3248
  */
3226
3249
  export declare function collectToolGroups(messages: readonly Message[]): ReadonlyArray<readonly Message[]>;
3227
3250
 
3251
+ /**
3252
+ * Collects each finding a write made stale, mapped to the writes that supersede it.
3253
+ *
3254
+ * @remarks
3255
+ * A write is a finding with `targets`. It supersedes another finding whose names meet its targets
3256
+ * when that finding comes before it in conversation order, or sits in its own tool group and
3257
+ * carries no targets, because one batch dispatches its calls at once. So the later of two writes in
3258
+ * one group supersedes the earlier, and never the reverse. A finding's names are its result's `ids`
3259
+ * and owner ids, or, for an empty finding, the ids its string arguments name, as `extractLiterals`
3260
+ * reads them. Names and targets compare exactly. A write never supersedes itself, a finding with
3261
+ * empty `targets` supersedes nothing, and a finding the messages don't hold takes no part.
3262
+ *
3263
+ * @param messages - The conversation's messages, which fix each finding's position and tool group
3264
+ * @param findings - The lookup and write findings of those messages
3265
+ * @returns Each superseded finding's id, in conversation order, mapped to the ids of the writes that supersede it, in conversation order
3266
+ *
3267
+ * @example
3268
+ * ```ts
3269
+ * collectWriteSupersessions(messages, findings) // Map { 'tool-1' => ['tool-2'] } when tool-2 wrote what tool-1 read
3270
+ * ```
3271
+ */
3272
+ export declare function collectWriteSupersessions(messages: readonly Message[], findings: readonly LedgerLookupFinding[]): ReadonlyMap<string, readonly string[]>;
3273
+
3228
3274
  /**
3229
3275
  * Configures one {@link ConversationInterface.compact} call — the retained-tail size, the
3230
3276
  * `sections` cap, or both, overridden for one fold.
@@ -3254,6 +3300,22 @@ export declare interface CompactOptions {
3254
3300
  readonly signal?: AbortSignal;
3255
3301
  }
3256
3302
 
3303
+ /**
3304
+ * Computes a checksum of text: two 32-bit FNV-1a lanes over its code points, as 16 hexadecimal digits.
3305
+ *
3306
+ * @remarks
3307
+ * The checksum detects an edit, can collide, and makes no security claim. Over ASCII text, the first
3308
+ * lane is the standard 32-bit FNV-1a hash.
3309
+ *
3310
+ * @param text - The text to checksum
3311
+ * @returns The 16-digit lowercase hexadecimal checksum
3312
+ * @example
3313
+ * ```ts
3314
+ * computeLedgerChecksum('a') // 'e40c292ce457465e'
3315
+ * ```
3316
+ */
3317
+ export declare function computeLedgerChecksum(text: string): string;
3318
+
3257
3319
  /**
3258
3320
  * Computes the completion tokens attributable to a message's thinking.
3259
3321
  *
@@ -5682,6 +5744,23 @@ export declare function describeSnapshotRefusal(noun: string, id: unknown, fault
5682
5744
  /** Matches the logprob decoding failure `invalid or duplicate top logprob token`, which the ledger holds for the ledger's life. */
5683
5745
  export declare const DETERMINISTIC_JUDGE_ERROR: RegExp;
5684
5746
 
5747
+ /**
5748
+ * Digests tool definitions as the JSON a provider request carries them, in order.
5749
+ *
5750
+ * @remarks
5751
+ * A ledger stores this digest with its gauge, so a hydrate reuses the gauge only for the same
5752
+ * definitions: an added, removed, reordered, or edited definition changes the digest. The digest is
5753
+ * a {@link computeLedgerChecksum} checksum and makes no security claim.
5754
+ *
5755
+ * @param definitions - The tool definitions, as a tool manager's `definitions` method returns them
5756
+ * @returns The 16-digit hexadecimal digest, or undefined when JSON cannot render the definitions
5757
+ * @example
5758
+ * ```ts
5759
+ * digestLedgerTools([{ name: 'lookup_order', description: 'Read an order by its id.' }]) // '1eff754a69b7128c'
5760
+ * ```
5761
+ */
5762
+ export declare function digestLedgerTools(definitions: readonly ToolDefinition[]): string | undefined;
5763
+
5685
5764
  /**
5686
5765
  * Digests held messages, lookup call context, stored copies, and sentence receipts using canonical text.
5687
5766
  * This non-cryptographic checksum detects host edits and makes no security claim.
@@ -6830,8 +6909,8 @@ export declare function isLedgerQuestion(value: unknown): value is LedgerQuestio
6830
6909
  * `conversation` must pass `isConversationSnapshot`, and `requests`, `notes`, and `failures` must be
6831
6910
  * dense arrays of strings. Each request and note id must name a `user` message of
6832
6911
  * `conversation.messages` and each failure id a `tool` message, so an id only a section original
6833
- * holds is refused. A `gauge`, when present, must hold a finite `scale` greater than 0 and a finite
6834
- * `overhead` of at least 0. The guard is exact: an unknown member and an own `undefined` `gauge` return
6912
+ * holds is refused. A `gauge`, when present, must hold a finite `scale` greater than 0, a finite
6913
+ * `overhead` of at least 0, and a string `digest`. The guard is exact: an unknown member and an own `undefined` `gauge` return
6835
6914
  * false, at the snapshot and in its `gauge`. Unreadable members and untrusted inputs return false. The
6836
6915
  * guard is structural: it admits a conversation holding a stored `system` role
6837
6916
  * or a repeated id, which `requireConversationSnapshot` and the `Conversation` constructor then
@@ -7641,6 +7720,7 @@ export declare class Ledger implements LedgerInterface {
7641
7720
  * @param provider - The provider that serves the conversation
7642
7721
  * @param options - The filing policy, capacity, and request bounds
7643
7722
  * @throws {LedgerError} Thrown when a threshold, share, capacity, limit, topic, lookup, or gauge is invalid
7723
+ * @throws {LedgerError} Thrown when a write lacks the `consequential` annotation, writes come without `agent.authority`, or a write is named `recall` or shares a lookup's or another write's name (code `'WRITE'`)
7644
7724
  * @throws {LedgerError} Thrown when `predict` is not a nonnegative safe integer less than `capacity` (code `'CAPACITY'`)
7645
7725
  * @throws {LedgerError} Thrown when `questions` fails `isLedgerQuestion` (code `'QUESTION'`)
7646
7726
  * @throws {LedgerError} Thrown when `snapshot` is malformed or marks an id its conversation does not hold (code `'SNAPSHOT'`, its faults under `context.faults`)
@@ -7678,6 +7758,7 @@ export declare class Ledger implements LedgerInterface {
7678
7758
  snapshot(): LedgerSnapshot;
7679
7759
  /**
7680
7760
  * Appends a request and serves it, recovering an unfinished or rejected first pass with one answer pass.
7761
+ * In either pass, a call the model makes in a turn that advertises no tools runs nothing and ends the pass after that generation, whatever the agent's `limit`, and when every call of that turn failed, the ledger stores the reply without its calls: a reply with text ends the pass complete, and one without text ends it partial with empty content.
7681
7762
  * A calibration call that reports no prompt usage, or a prompt usage of 0 or less, rejects with `LedgerError` code `'GAUGE'`; a provider error during calibration rejects with that error.
7682
7763
  * When the answer pass rejects, `respond` rejects with that error, and under the default `strict` a judge failure or another selection failure rejects it too. A rejection belongs to its own call: the ledger stays free, and the next call asks the judge again about whatever is still unanswered.
7683
7764
  * @param content - The request text
@@ -7764,9 +7845,18 @@ export declare const LEDGER_WORD: RegExp;
7764
7845
  * that `respond` call after the `fault` event, and the next call asks the judge again about whatever is
7765
7846
  * still unanswered. With `strict: false` the request goes on with that question undecided, or from the
7766
7847
  * conversation's `view()`. A provider failure in the first pass is the one
7767
- * failure the answer pass recovers under either value.
7768
- */
7769
- export declare type LedgerAgentOptions = Pick<AgentOptions, 'limit' | 'timeout' | 'on' | 'scheduler' | 'instructions' | 'skills' | 'memos' | 'workspaces' | 'strict'>;
7848
+ * failure the answer pass recovers under either value. `authority` gates every lookup and write:
7849
+ * the ledger passes its agent one authority that denies a name the ledger doesn't advertise, allows
7850
+ * `recall`, and hands every other call to this authority's `evaluate`, and every asked call to its
7851
+ * `ask`. Without it, the ledger allows each lookup and holds no approver, so a `consequential`
7852
+ * lookup is denied as unanswered at every call. In one request, the ledger denies the identical
7853
+ * retry in a later turn of a lookup or write call the authority denied, declined, or left
7854
+ * unanswered as a repeat, before its `evaluate` method and with no ask, and its `ask` refuses the
7855
+ * identical twin in the same batch of a declined or unanswered ask without calling this authority's
7856
+ * `ask`, so a person is asked about such a call once per request. The agent still reports that
7857
+ * twin's `ask` event.
7858
+ */
7859
+ export declare type LedgerAgentOptions = Pick<AgentOptions, 'limit' | 'timeout' | 'on' | 'scheduler' | 'instructions' | 'skills' | 'memos' | 'workspaces' | 'strict' | 'authority'>;
7770
7860
 
7771
7861
  /** Identifies an accepted direct message amendment whose sentence scope remains unresolved. */
7772
7862
  export declare interface LedgerAmendment {
@@ -7836,7 +7926,7 @@ export declare type LedgerEntityHandler = (text: string, partial: boolean) => Re
7836
7926
  * carrying the machine-readable `code`.
7837
7927
  *
7838
7928
  * @remarks
7839
- * A threshold, share, capacity, limit, topic, lookup, question, or gauge outside its bounds is a
7929
+ * A threshold, share, capacity, limit, topic, lookup, write, question, or gauge outside its bounds is a
7840
7930
  * programmer error and throws this with the matching {@link LedgerErrorCode}. A calibration call that reports
7841
7931
  * no prompt usage throws this with `'GAUGE'`. A snapshot option that `isLedgerSnapshot` refuses
7842
7932
  * throws this with `'SNAPSHOT'`, its `context` holding the `faults`. Narrow a caught value with {@link isLedgerError} and
@@ -7882,7 +7972,9 @@ export declare type LedgerErrorCode =
7882
7972
  /** Reports a snapshot that is malformed or that marks an id its conversation does not hold. */
7883
7973
  | 'SNAPSHOT'
7884
7974
  /** Reports filing wording that `isLedgerQuestion` refuses. */
7885
- | 'QUESTION';
7975
+ | 'QUESTION'
7976
+ /** Reports a write without the `consequential` annotation, writes without `agent.authority`, or a write named `recall` or with a name a lookup or another write carries. */
7977
+ | 'WRITE';
7886
7978
 
7887
7979
  /** Captures held message identities and the accepted edges used to validate their copies. */
7888
7980
  export declare interface LedgerEvidence {
@@ -7918,6 +8010,18 @@ export declare interface LedgerGauge {
7918
8010
  readonly overhead: number;
7919
8011
  }
7920
8012
 
8013
+ /**
8014
+ * Carries a stored gauge: its price and the digest of the tool definitions that price measured.
8015
+ *
8016
+ * @remarks
8017
+ * `digest` is what the `digestLedgerTools` helper returns for the definitions the calibration request
8018
+ * carried, or for the ledger's definitions at construction when the options supplied the gauge. A
8019
+ * hydrate reuses the price only when the hydrated ledger's definitions have the same digest.
8020
+ */
8021
+ export declare interface LedgerGaugeSnapshot extends LedgerGauge {
8022
+ readonly digest: string;
8023
+ }
8024
+
7921
8025
  /**
7922
8026
  * Carries a registry prepared for matching: its ids, each owner name's owners, and the compiled needles.
7923
8027
  *
@@ -7963,7 +8067,7 @@ export declare interface LedgerInterface {
7963
8067
  readonly agent: AgentInterface;
7964
8068
  /** Holds the one conversation the ledger files and serves. */
7965
8069
  readonly conversation: ConversationInterface;
7966
- /** Holds the measured price of a prompt, or undefined until the ledger calibrates when the options supplied none. */
8070
+ /** Holds the measured price of a prompt, or undefined until the ledger calibrates when neither the options nor a snapshot priced on the same tool definitions supplied one. */
7967
8071
  readonly gauge: LedgerGauge | undefined;
7968
8072
  /**
7969
8073
  * Appends `content` as a user message and serves it through to its reply.
@@ -7971,7 +8075,11 @@ export declare interface LedgerInterface {
7971
8075
  * @remarks
7972
8076
  * The ledger calibrates first while `gauge` is undefined. When the first pass ends without final
7973
8077
  * text and the caller did not abort, the ledger adds the results and cue notes and makes one
7974
- * answer pass that advertises no tools. A rejected first pass counts as unfinished; when the
8078
+ * answer pass that advertises no tools. In either pass, a call the model makes in a turn that
8079
+ * advertises no tools runs nothing and ends the pass after that turn, so such a pass makes one
8080
+ * model generation, whatever the agent's `limit`; when every call of that turn failed, the ledger
8081
+ * stores the reply without its calls, as a call-free turn stores it. That pass ends with the
8082
+ * reply's text and `partial: false`, or partial with empty content when the reply carries no text. A rejected first pass counts as unfinished; when the
7975
8083
  * answer pass rejects as well, `respond` rejects with that pass's error. A `respond` or `calibrate` call while either is in flight
7976
8084
  * rejects with an `AgentError` whose `code` is `'CONCURRENCY'`. A calibration call that reports no prompt usage, or a prompt usage of 0 or less, rejects with
7977
8085
  * `LedgerError` code `'GAUGE'`; a provider error during calibration rejects with that error.
@@ -8001,7 +8109,8 @@ export declare interface LedgerInterface {
8001
8109
  * @remarks
8002
8110
  * The ledger sends the head its agent's context builds and its conversation's view to the provider twice, with
8003
8111
  * and without the tool definitions. The call without tools prices the messages and the
8004
- * difference between the calls is the overhead cost.
8112
+ * difference between the calls is the overhead cost. The ledger records the digest of the
8113
+ * definitions the call with tools carried, and its snapshot stores that digest with the gauge.
8005
8114
  * An abort during calibration rejects with the abort reason. A call during `respond` or `calibrate` rejects
8006
8115
  * with `AgentError` code `'CONCURRENCY'`.
8007
8116
  *
@@ -8018,9 +8127,10 @@ export declare interface LedgerInterface {
8018
8127
  * The ledger first files every tool result whose message is appended, so a failure a direct
8019
8128
  * agent run left is marked; a result whose tool message is not yet appended is not captured. A
8020
8129
  * call while a `respond` or `calibrate` call is in flight throws, because an entered, unanswered
8021
- * request would hydrate as a dangling request; a direct agent run is not refused.
8130
+ * request would hydrate as a dangling request; a direct agent run is not refused. The `gauge`
8131
+ * member carries the digest of the tool definitions the gauge priced.
8022
8132
  *
8023
- * @returns The snapshot, each id list in conversation order and `gauge` present after the ledger holds one
8133
+ * @returns The snapshot, each id list in conversation order and `gauge` present after the ledger holds one whose definitions JSON renders
8024
8134
  * @throws {AgentError} Thrown when a request or calibration is active (code `'CONCURRENCY'`)
8025
8135
  */
8026
8136
  snapshot(): LedgerSnapshot;
@@ -8057,8 +8167,18 @@ export declare interface LedgerListing {
8057
8167
  *
8058
8168
  * @remarks
8059
8169
  * The ledger registers the tool behind a repeat stop beside its own `recall` tool, so the tool must
8060
- * not be named `recall`, and no two lookups can share a tool name.
8170
+ * not be named `recall`, and no two lookups can share a tool name. A lookup is a read: a tool whose
8171
+ * call changes a record is a {@link LedgerWrite}.
8061
8172
  * The repeat stop compares the tool name and canonical arguments without normalizing strings.
8173
+ * A call the tool refuses for its arguments never counts as a run: when `execute` throws, or
8174
+ * returns a promise that rejects with, an error `isToolError` admits whose code is `'ARGUMENTS'`,
8175
+ * the request releases the call, so the identical call runs again. Every other failure counts.
8176
+ * A call the authority denies, or whose ask is declined or left unanswered, never runs, and the
8177
+ * request records it. Its identical retry in a later turn of the same request is denied with the
8178
+ * {@link LedgerNote} `repeat` text before the authority evaluates or asks it, and ends the pass as a
8179
+ * repeat does. Its identical twin in the same batch was evaluated with it: the twin of a denied call
8180
+ * is denied as that retry is, and the twin of a declined or unanswered ask is refused without
8181
+ * entering the host's approver, after the agent reports its `ask` event, and the pass goes on.
8062
8182
  * The projection uses {@link identifyLookup}, which trims and uppercases top-level string
8063
8183
  * arguments when deciding which finding replaces an earlier one.
8064
8184
  * A throwing `read` handler makes the lookup failed: it files as chatter and replaces no finding.
@@ -8079,7 +8199,9 @@ export declare interface LedgerLookup {
8079
8199
  * @remarks
8080
8200
  * `id` is the tool message's id, `name` and `arguments` come from the call it answers, and `text`
8081
8201
  * is the result text. `result` is what the lookup's handler read, undefined for a lookup that found
8082
- * nothing; an empty finding still replaces an earlier finding of the same call.
8202
+ * nothing; an empty finding still replaces an earlier finding of the same call. `targets` is present
8203
+ * on the finding of a write whose handler read a result: the ids whose state the call changed or
8204
+ * removed, which supersede the earlier findings that name them.
8083
8205
  */
8084
8206
  export declare interface LedgerLookupFinding {
8085
8207
  readonly id: string;
@@ -8087,6 +8209,7 @@ export declare interface LedgerLookupFinding {
8087
8209
  readonly arguments: Readonly<Record<string, unknown>>;
8088
8210
  readonly text: string;
8089
8211
  readonly result: LedgerLookupResult | undefined;
8212
+ readonly targets?: readonly string[];
8090
8213
  }
8091
8214
 
8092
8215
  /**
@@ -8122,8 +8245,9 @@ export declare type LedgerLookupState = 'failed' | 'empty' | 'shown' | 'hidden';
8122
8245
  * @remarks
8123
8246
  * `cue` is the last user message of an answer pass. `results` heads the note that carries what the
8124
8247
  * first pass's lookups and recalls returned. `repeat` is the failure a repeated tool call returns,
8125
- * and the ledger reads a failure with exactly this text as a repeat. `closure` is the failure a
8126
- * `recall` call returns after the request's recalls are spent, repeated, or out of room.
8248
+ * and the reason of the denial the ledger gives the identical retry of a call the authority denied;
8249
+ * the ledger reads a failure with exactly this text, or that denial, as a repeat. `closure` is the
8250
+ * failure a `recall` call returns after the request's recalls are spent, repeated, or out of room.
8127
8251
  */
8128
8252
  export declare interface LedgerNote {
8129
8253
  readonly cue: string;
@@ -8138,15 +8262,15 @@ export declare interface LedgerOccurrence extends LedgerLine, LedgerReceipt {
8138
8262
 
8139
8263
  /**
8140
8264
  * Configures a ledger: its judge and the wording and cutoffs it files with, the desk topics, the
8141
- * context capacity, and the optional first-pass thinking, lookups, gauge, shares, snapshot, recall
8142
- * limit, correction filter, and agent options.
8265
+ * context capacity, and the optional first-pass thinking, lookups, writes, gauge, shares, snapshot,
8266
+ * recall limit, correction filter, and agent options.
8143
8267
  *
8144
8268
  * @remarks
8145
8269
  * `judge` answers every filing question. `system` is the application's system text, a date
8146
8270
  * sentence included; it opens the system message, which also holds the instructions and the skills index the `agent` option supplies. The memos index and the workspace text go into the context message after it, and the records go into a copy of each request turn. `topics` lists the desk
8147
8271
  * topics. `questions` and `thresholds` are required with no default; pass the `LEDGER_QUESTIONS`
8148
8272
  * constant for the measured wording, and fit `thresholds` on the wording and the judge you pass. `capacity` is the model's context window in tokens and must be a positive safe
8149
- * integer. Without `gauge`, the ledger calibrates before its first pass. `share` defaults leaf by leaf to `DEFAULT_LEDGER_SHARE`. The ledger writes the `LEDGER_NOTES` text.
8273
+ * integer. Without `gauge`, or a `snapshot` gauge priced on the same tool definitions, the ledger calibrates before its first pass. `share` defaults leaf by leaf to `DEFAULT_LEDGER_SHARE`. The ledger writes the `LEDGER_NOTES` text.
8150
8274
  * `predict` is the generation cap in tokens, including thinking. Default: 0. It must be a
8151
8275
  * nonnegative safe integer less than `capacity`; construction throws `LedgerError` with code
8152
8276
  * `'CAPACITY'` otherwise. The plan budgets
@@ -8154,7 +8278,8 @@ export declare interface LedgerOccurrence extends LedgerLine, LedgerReceipt {
8154
8278
  * The plan retains its `remainder - predict < 2 * reserve` admission rule. Runtime recall fits whole
8155
8279
  * results to measured remaining capacity at the larger of the gauge rate and the request's measured
8156
8280
  * rate, allowing `LEDGER_SCALE_DRIFT` for new text. Lack of room omits results without closing recall.
8157
- * `snapshot` hydrates the conversation and
8281
+ * `writes` lists the {@link LedgerWrite} entries the model can call; a ledger with writes requires
8282
+ * `agent.authority`. `snapshot` hydrates the conversation and
8158
8283
  * the marked ids a ledger's `snapshot()` returned; construction throws `LedgerError` with code
8159
8284
  * `'SNAPSHOT'` when `isLedgerSnapshot` refuses it, and `ConversationError` with code `'ROLE'` or
8160
8285
  * `'SNAPSHOT'` when its conversation holds a `system` message or repeats an id.
@@ -8177,11 +8302,12 @@ export declare interface LedgerOptions {
8177
8302
  readonly think?: boolean;
8178
8303
  readonly gauge?: LedgerGauge;
8179
8304
  readonly lookups?: readonly LedgerLookup[];
8305
+ readonly writes?: readonly LedgerWrite[];
8180
8306
  readonly share?: Partial<LedgerShare>;
8181
8307
  readonly recall?: LedgerRecallOptions;
8182
8308
  readonly correction?: LedgerCorrectionOptions;
8183
8309
  readonly agent?: LedgerAgentOptions;
8184
- /** Hydrates from a snapshot: its conversation, its marked ids, and its gauge when these options supply none, because a `gauge` option wins over `snapshot.gauge`. */
8310
+ /** Hydrates from a snapshot: its conversation, its marked ids, and its gauge when these options supply none and the gauge priced the same tool definitions, because a `gauge` option wins over `snapshot.gauge`. */
8185
8311
  readonly snapshot?: LedgerSnapshot;
8186
8312
  }
8187
8313
 
@@ -8411,9 +8537,22 @@ export declare class LedgerRequest implements LedgerRequestInterface {
8411
8537
  * @returns The attempts in asking order
8412
8538
  */
8413
8539
  get attempts(): readonly ClassifierAttempt[];
8540
+ /**
8541
+ * Returns the signal `abort` aborts for the current pass's run.
8542
+ *
8543
+ * @returns The current pass's abort signal, or undefined before a pass
8544
+ */
8545
+ get signal(): AbortSignal | undefined;
8546
+ /**
8547
+ * Reports whether `abort` ended the current pass.
8548
+ *
8549
+ * @returns True if the current pass was aborted; false otherwise, and before a pass
8550
+ */
8551
+ get aborted(): boolean;
8414
8552
  enter(conversation: ConversationInterface): Message;
8415
8553
  open(boundary: number): void;
8416
8554
  adopt(selection: Selection, boundary: number): void;
8555
+ abort(): void;
8417
8556
  observe(call: GaugeCall, position: number): void;
8418
8557
  spend(usage: TokenUsage): void;
8419
8558
  think(messages: readonly Message[]): void;
@@ -8421,6 +8560,9 @@ export declare class LedgerRequest implements LedgerRequestInterface {
8421
8560
  faulted(error: unknown): boolean;
8422
8561
  file(attempts: readonly ClassifierAttempt[], plan?: Selection, draft?: LedgerDraft): void;
8423
8562
  admit(name: string, args: Readonly<Record<string, unknown>>): void;
8563
+ release(name: string, args: Readonly<Record<string, unknown>>): void;
8564
+ deny(name: string, args: Readonly<Record<string, unknown>>): void;
8565
+ denied(name: string, args: Readonly<Record<string, unknown>>): boolean;
8424
8566
  recall(): void;
8425
8567
  close(): void;
8426
8568
  list(result: string, lines: ReadonlyMap<string, string>, groups: readonly string[]): void;
@@ -8437,7 +8579,8 @@ export declare class LedgerRequest implements LedgerRequestInterface {
8437
8579
  * @remarks
8438
8580
  * A ledger creates one request per `respond` call and drops it when the call settles, so no request
8439
8581
  * state reaches a later call or a run no call owns. Each agent run the call makes is a pass: `open`
8440
- * starts one, and `selection`, `boundary`, and `usage` read the current pass, the last one opened.
8582
+ * starts one, and `selection`, `boundary`, `usage`, `signal`, and `aborted` read the current pass,
8583
+ * the last one opened.
8441
8584
  * `calls` lists the gauge calls of every pass in order. A call stays in flight, taking its usage and
8442
8585
  * thinking, until its pass observes the next call, and is final from then on.
8443
8586
  */
@@ -8471,6 +8614,18 @@ export declare interface LedgerRequestInterface {
8471
8614
  readonly calls: readonly GaugeCall[];
8472
8615
  /** Holds the filing attempts of every planning selection the request made, in asking order. */
8473
8616
  readonly attempts: readonly ClassifierAttempt[];
8617
+ /** Holds the signal `abort` aborts for the current pass's run, or undefined before a pass. */
8618
+ readonly signal: AbortSignal | undefined;
8619
+ /** Reports whether `abort` ended the current pass, read from `signal`; false before a pass. */
8620
+ readonly aborted: boolean;
8621
+ /**
8622
+ * Aborts the current pass's run through `signal`, with the reason `'stray'`, so the run ends after its turn.
8623
+ *
8624
+ * @remarks
8625
+ * The ledger calls it when a turn that advertised no tools made a call. A later call, and a call
8626
+ * before a pass opens, changes nothing.
8627
+ */
8628
+ abort(): void;
8474
8629
  /**
8475
8630
  * Appends the request's content to a conversation as a user message, once, and holds it as `message`.
8476
8631
  *
@@ -8532,6 +8687,37 @@ export declare interface LedgerRequestInterface {
8532
8687
  * @throws {Error} Thrown when the arguments have no canonical identity
8533
8688
  */
8534
8689
  admit(name: string, args: Readonly<Record<string, unknown>>): void;
8690
+ /**
8691
+ * Releases one tool call the request admitted, so a later `admit` of the same call passes.
8692
+ *
8693
+ * @remarks
8694
+ * The call is compared as `admit` compares it. A call the request never admitted, or one whose
8695
+ * arguments have no canonical identity, changes nothing.
8696
+ *
8697
+ * @param name - The tool name
8698
+ * @param args - The call's arguments
8699
+ */
8700
+ release(name: string, args: Readonly<Record<string, unknown>>): void;
8701
+ /**
8702
+ * Records one tool call the authority denied, declined, or left unanswered, so `denied` reports it for the rest of the request.
8703
+ *
8704
+ * @remarks
8705
+ * The call is compared as `admit` compares it, and a denial admits nothing. A call whose arguments
8706
+ * have no canonical identity changes nothing. The ledger records each lookup or write call the
8707
+ * agent's `deny` event reports with a decision.
8708
+ *
8709
+ * @param name - The tool name
8710
+ * @param args - The call's arguments
8711
+ */
8712
+ deny(name: string, args: Readonly<Record<string, unknown>>): void;
8713
+ /**
8714
+ * Reports whether the request recorded this tool call as denied.
8715
+ *
8716
+ * @param name - The tool name
8717
+ * @param args - The call's arguments
8718
+ * @returns True if `deny` recorded the same call, compared as `admit` compares it; false otherwise
8719
+ */
8720
+ denied(name: string, args: Readonly<Record<string, unknown>>): boolean;
8535
8721
  /**
8536
8722
  * Counts one `recall` call, closing the request's recall tool when its recalls reach the limit.
8537
8723
  *
@@ -8602,7 +8788,10 @@ export declare interface LedgerShare {
8602
8788
  * `respond` appended, `notes` the user messages carrying `LEDGER_NOTES` text, and `failures` the
8603
8789
  * tool messages whose call or reading failed, each in conversation order. Each id names a message
8604
8790
  * of `conversation.messages`: a request or note a `user` message and a failure a `tool` message.
8605
- * `gauge` carries the scale and overhead alone. The gauge's observations of earlier requests are
8791
+ * `gauge` carries the scale, the overhead, and the required `digest` of the tool definitions they
8792
+ * priced. A hydrated ledger whose definitions have another digest drops the gauge and calibrates
8793
+ * before its first pass; a gauge with no `digest` refuses the snapshot, and `snapshot()` omits a gauge
8794
+ * whose definitions JSON cannot render. The gauge's observations of earlier requests are
8606
8795
  * not carried, so a hydrated ledger sizes and closes `recall` from its fallback reserve until it
8607
8796
  * completes a request. A question a `strict: false` classifier held after a deterministic judge
8608
8797
  * failure is not carried, so a hydrated ledger asks it again. Hydrating a second ledger from one snapshot forks
@@ -8613,14 +8802,16 @@ export declare interface LedgerShare {
8613
8802
  * never the record coverage. A plain request omits `copy` because its content already lives in `conversation`.
8614
8803
  * The required window `digest` checks canonical held messages, lookup call context, copies, and receipts. A mismatch drains
8615
8804
  * the window and its evidence; a missing digest refuses the snapshot. An unencodable held message
8616
- * makes `snapshot()` omit the window. The checksum detects edits, not authenticity.
8805
+ * makes `snapshot()` omit the window. The checksum detects edits, not authenticity. A write's
8806
+ * retirements carry no member: the hydrated ledger reads each write's targets again from the
8807
+ * conversation and its failures, so a changed `writes` list brings retired reads back live.
8617
8808
  */
8618
8809
  export declare interface LedgerSnapshot {
8619
8810
  readonly conversation: ConversationSnapshot;
8620
8811
  readonly requests: readonly string[];
8621
8812
  readonly notes: readonly string[];
8622
8813
  readonly failures: readonly string[];
8623
- readonly gauge?: LedgerGauge;
8814
+ readonly gauge?: LedgerGaugeSnapshot;
8624
8815
  readonly window?: LedgerWindowSnapshot;
8625
8816
  }
8626
8817
 
@@ -8783,6 +8974,7 @@ failures: readonly string[];
8783
8974
  gauge?: Readonly<{
8784
8975
  scale: number;
8785
8976
  overhead: number;
8977
+ digest: string;
8786
8978
  } & {}>;
8787
8979
  window?: Readonly<{
8788
8980
  digest: string;
@@ -8922,6 +9114,7 @@ failures: ArrayShape<StringShape>;
8922
9114
  gauge: OptionalShape<ObjectShape< {
8923
9115
  scale: NumberShape;
8924
9116
  overhead: NumberShape;
9117
+ digest: StringShape;
8925
9118
  }, boolean | ContractShape>>;
8926
9119
  window: OptionalShape<ObjectShape< {
8927
9120
  digest: StringShape;
@@ -9034,6 +9227,59 @@ export declare interface LedgerWordSet {
9034
9227
  readonly names: ReadonlySet<string>;
9035
9228
  }
9036
9229
 
9230
+ /**
9231
+ * Carries one application write: the `consequential` tool the model calls and the handler that reads its results.
9232
+ *
9233
+ * @remarks
9234
+ * The ledger registers the tool beside its lookups and `recall`, behind the same repeat stop, which
9235
+ * releases a call the tool refuses for its arguments and refuses, without entering the host's
9236
+ * approver, the identical retry or batch twin of a call the authority denied, declined, or left
9237
+ * unanswered, as a lookup's does: a retry in a later turn, and the twin of a denied call, end the
9238
+ * pass as a repeat, and the twin of a declined or unanswered ask is refused after the agent reports
9239
+ * its `ask` event, and the pass goes on. The
9240
+ * tool must carry `annotations.consequential: true`, must not be named `recall`, and can share no
9241
+ * name with a lookup or another write, and a ledger with writes requires `agent.authority`;
9242
+ * construction throws `LedgerError` with code `'WRITE'` otherwise. A write runs through the agent's
9243
+ * scope, the host authority, the `consequential` floor, and the host's approver like any tool.
9244
+ * The ledger files a successful result as a finding, as it files a lookup's, adding the ids its
9245
+ * string arguments name to `ids` and never to `targets`. The finding supersedes every earlier
9246
+ * finding whose `ids` or owner ids meet its `targets`, and every such finding without targets in
9247
+ * its own tool group, as {@link collectWriteSupersessions} reads them. A handler that returns
9248
+ * undefined reads a call that changed nothing, which retires nothing. A refused, denied, aborted,
9249
+ * or thrown call, and a throwing handler, file nothing and retire nothing. The ledger reads the
9250
+ * targets again from the conversation on every scan, so pass the same writes on every hydrate.
9251
+ * When a write runs, the ledger also calls the handler on its result once, and the request admits
9252
+ * again each lookup call whose finding the write retired, so a later read that checks the write
9253
+ * passes the repeat stop; a second identical read with no write between is still a repeat.
9254
+ */
9255
+ export declare interface LedgerWrite {
9256
+ readonly tool: ToolInterface;
9257
+ readonly read: LedgerWriteHandler;
9258
+ }
9259
+
9260
+ /**
9261
+ * Reads one successful write result into the ids and owners it names and the ids whose state it changed.
9262
+ *
9263
+ * @param args - The arguments the model called the write with
9264
+ * @param text - The result text the tool returned
9265
+ * @returns The ids, owners, and targets the result names, or undefined when the call changed nothing
9266
+ *
9267
+ * @example
9268
+ * ```ts
9269
+ * const read: LedgerWriteHandler = (args, text) => {
9270
+ * if (text.startsWith('No change')) return undefined
9271
+ * const id = String(args.id ?? '').trim().toUpperCase()
9272
+ * return { ids: [id], owners: [{ id, names: [] }], targets: [id] }
9273
+ * }
9274
+ * ```
9275
+ */
9276
+ export declare type LedgerWriteHandler = (args: Readonly<Record<string, unknown>>, text: string) => LedgerWriteResult | undefined;
9277
+
9278
+ /** 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. */
9279
+ export declare interface LedgerWriteResult extends LedgerLookupResult {
9280
+ readonly targets: readonly string[];
9281
+ }
9282
+
9037
9283
  /**
9038
9284
  * Links each id-shaped lookup argument to its owner.
9039
9285
  *
@@ -9757,6 +10003,26 @@ export declare interface MemoStoreInterface {
9757
10003
  delete(id: string): Promise<void>;
9758
10004
  }
9759
10005
 
10006
+ /**
10007
+ * Merges supersession edges into a classification, adding each edge to both its supersessions and its amendments.
10008
+ *
10009
+ * @remarks
10010
+ * Each earlier message's later ids stay distinct and in conversation order, so every supersession
10011
+ * is still an amendment, as the classifier files one. An empty edge map returns the classification
10012
+ * itself.
10013
+ *
10014
+ * @param classification - The judged classification
10015
+ * @param edges - The later ids that supersede each earlier id, such as {@link collectWriteSupersessions} returns
10016
+ * @param messages - The conversation's messages, which order the later ids
10017
+ * @returns The classification with the edges merged
10018
+ *
10019
+ * @example
10020
+ * ```ts
10021
+ * mergeSupersessions(classification, new Map([['tool-1', ['tool-2']]]), messages).supersessions.get('tool-1') // ['tool-2']
10022
+ * ```
10023
+ */
10024
+ export declare function mergeSupersessions(classification: LedgerClassification, edges: ReadonlyMap<string, readonly string[]>, messages: readonly Message[]): LedgerClassification;
10025
+
9760
10026
  /**
9761
10027
  * Represents one conversation turn fed to a {@link ProviderInterface} — a stored, identified
9762
10028
  * message.
@@ -11181,6 +11447,7 @@ export declare function renderSection<T>(open: string, members: readonly T[], re
11181
11447
  * @param name - The lookup tool name
11182
11448
  * @param args - The arguments the call carried; arguments JSON cannot carry leave the call as its bare tool name, per {@link renderLookupCall}
11183
11449
  * @param state - What became of the result: `failed`, `empty`, `shown` in the records, or `hidden` from them
11450
+ * @param write - If `true`, the call is a write's, whose `empty` state reads `changed nothing`; if `false`, a lookup's, whose `empty` state reads `no record`. Default: `false`
11184
11451
  * @returns The stub text, which carries the call and its state
11185
11452
  *
11186
11453
  * @example
@@ -11189,7 +11456,7 @@ export declare function renderSection<T>(open: string, members: readonly T[], re
11189
11456
  * // 'lookup_order {"id":"BW-5512"}: result not shown; call recall with BW-5512'
11190
11457
  * ```
11191
11458
  */
11192
- export declare function renderStub(name: string, args: Readonly<Record<string, unknown>>, state: LedgerLookupState): string;
11459
+ export declare function renderStub(name: string, args: Readonly<Record<string, unknown>>, state: LedgerLookupState, write?: boolean): string;
11193
11460
 
11194
11461
  /**
11195
11462
  * Renders a tool's output as the string content of its tool message, or returns `undefined` when JSON