@orkestrel/agent 0.0.31 → 0.0.32

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.
@@ -1798,29 +1798,42 @@ export declare function buildJudgeResult(model: string, results: readonly JudgeR
1798
1798
  */
1799
1799
  export declare function buildJudgments(request: JudgeRequest, result: JudgeResult, sources: readonly string[], state: string, model: string): readonly JudgmentInput[];
1800
1800
 
1801
+ /**
1802
+ * Derives complete source identities, first occurrences, and local references from the actual briefing lines.
1803
+ * @param messages - Original messages whose indexed sentences establish completeness
1804
+ * @param lines - Retained lines in rendering order after deduplication and trimming
1805
+ * @param amendments - Accepted direct message amendment edges
1806
+ * @returns Immutable rendering facts for this retained population
1807
+ *
1808
+ * @example
1809
+ * ```ts
1810
+ * buildLedgerRenderContext([], [], []).complete.size // 0
1811
+ * ```
1812
+ */
1813
+ export declare function buildLedgerRenderContext(messages: readonly Message[], lines: readonly LedgerLine[], amendments: readonly LedgerAmendment[]): LedgerRenderContext;
1814
+
1801
1815
  /**
1802
1816
  * Builds the record lines of one message.
1803
1817
  *
1804
1818
  * @remarks
1805
- * Each sentence that is not stale becomes a line. A sentence that opens with a pronoun and follows
1819
+ * Each original indexed sentence becomes a line. A sentence that opens with a pronoun and follows
1806
1820
  * another sentence takes the last name of the sentence before it that is neither an owner name nor
1807
1821
  * a system name, and its line text opens with that party and a colon.
1808
1822
  *
1809
1823
  * @param input - The classification whose topics the lines carry
1810
1824
  * @param byId - The messages by id
1811
1825
  * @param id - The message id
1812
- * @param dead - The stale sentences as `SOURCE SENTENCE` keys
1813
1826
  * @param holders - The owner names, which never serve as a party
1814
1827
  * @param system - The system text's names, which never serve as a party
1815
1828
  * @returns The lines in sentence order; empty when the message is absent
1816
1829
  *
1817
1830
  * @example
1818
1831
  * ```ts
1819
- * buildLines(input, byId, 'user-1', new Set(), [], []).map((line) => line.text)
1832
+ * buildLines(input, byId, 'user-1', [], []).map((line) => line.text)
1820
1833
  * // ['Odile Marlow phoned about BW-5512.', 'Odile Marlow: She wants a refund.']
1821
1834
  * ```
1822
1835
  */
1823
- export declare function buildLines(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, id: string, dead: ReadonlySet<string>, holders: readonly string[], system: readonly string[]): readonly LedgerLine[];
1836
+ export declare function buildLines(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, id: string, holders: readonly string[], system: readonly string[]): readonly LedgerLine[];
1824
1837
 
1825
1838
  /**
1826
1839
  * Builds a request's JSON headers, awaiting the caller's header hook inside the call's
@@ -1910,8 +1923,8 @@ export declare function buildRecapMessage(section: Section): Message;
1910
1923
  * argument. A message that names no owner joins where its earlier side of an amendment pair joins,
1911
1924
  * or on the rules record when it is filed as a rule or a correction, and is an orphan otherwise.
1912
1925
  *
1913
- * A sentence an amending message made stale is left out and listed in `stale`. An amending message
1914
- * that is itself replaced keeps that effect, so the old value never revives.
1926
+ * Every live sentence is retained. Accepted direct edges are listed in `amendments`. An amending message
1927
+ * that is itself superseded retains its accepted edge without restoring its text.
1915
1928
  *
1916
1929
  * A sentence that opens with a pronoun takes the party named in the sentence before it. The reading
1917
1930
  * trusts capitals, so a capitalized word that is no person, such as a carrier named mid-sentence,
@@ -1919,7 +1932,7 @@ export declare function buildRecapMessage(section: Section): Message;
1919
1932
  * the follow-up facts the records exist for.
1920
1933
  *
1921
1934
  * @param input - The messages, readings, entities, and classification to project
1922
- * @returns The records with owner records ordered by their first member and the rules record last, the stale sentences, and the live message ids no record placed
1935
+ * @returns The records with owner records ordered by their first member and the rules record last, the accepted amendments, and the live message ids no record placed
1923
1936
  *
1924
1937
  * @example
1925
1938
  * ```ts
@@ -2268,6 +2281,26 @@ export declare interface CodedErrorOptions {
2268
2281
  readonly context?: Readonly<Record<string, unknown>>;
2269
2282
  }
2270
2283
 
2284
+ /**
2285
+ * Collects accepted direct amendments of live messages.
2286
+ *
2287
+ * @remarks
2288
+ * An accepted edge relates an earlier live message to an amender without claiming which sentences
2289
+ * changed. An amender takes effect while live and retains its edge after another message supersedes
2290
+ * it, without restoring the superseded text. An excluded or quiet user or tool message has no effect.
2291
+ *
2292
+ * @param input - The exclusions and classification to read
2293
+ * @param byId - The messages by id
2294
+ * @param live - The live message ids from {@link collectLive}
2295
+ * @returns The distinct accepted direct edges in conversation order
2296
+ *
2297
+ * @example
2298
+ * ```ts
2299
+ * collectAmendments(input, byId, ['user-1', 'user-3']) // [{ earlier: 'user-1', later: 'user-3' }]
2300
+ * ```
2301
+ */
2302
+ export declare function collectAmendments(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, live: readonly string[]): readonly LedgerAmendment[];
2303
+
2271
2304
  /**
2272
2305
  * Collects whole exchanges, joining every exchange spanned by a tool group.
2273
2306
  *
@@ -2350,7 +2383,7 @@ export declare function collectNames(text: string): readonly string[];
2350
2383
  * @returns The distinct live message ids
2351
2384
  * @example
2352
2385
  * ```ts
2353
- * collectProjectionIds({ records: [], stale: [], orphans: ['message-1'] }) // Set { 'message-1' }
2386
+ * collectProjectionIds({ records: [], amendments: [], orphans: ['message-1'] }) // Set { 'message-1' }
2354
2387
  * ```
2355
2388
  */
2356
2389
  export declare function collectProjectionIds(projection: LedgerProjection): ReadonlySet<string>;
@@ -2375,27 +2408,6 @@ export declare function collectProjectionIds(projection: LedgerProjection): Read
2375
2408
  */
2376
2409
  export declare function collectRegistry(readings: readonly LedgerLookupReading[]): LedgerRegistry;
2377
2410
 
2378
- /**
2379
- * Collects the sentences that live messages made stale.
2380
- *
2381
- * @remarks
2382
- * A sentence of a live message is stale when it shares an id or a number with a message that
2383
- * amends it. An amending message takes effect while it is live, and keeps its effect after another
2384
- * message supersedes it, so the value it replaced never revives. A user or tool message that the
2385
- * input excludes or files quiet never takes effect.
2386
- *
2387
- * @param input - The exclusions and classification to read
2388
- * @param byId - The messages by id
2389
- * @param live - The live message ids from {@link collectLive}
2390
- * @returns The stale sentences in conversation order, each with the tokens it shares
2391
- *
2392
- * @example
2393
- * ```ts
2394
- * collectStale(input, byId, ['user-1', 'user-3']) // [{ source: 'user-1', sentence: 1, tokens: ['ESC-2291'] }]
2395
- * ```
2396
- */
2397
- export declare function collectStale(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, live: readonly string[]): readonly LedgerStaleSentence[];
2398
-
2399
2411
  /**
2400
2412
  * Collects each assistant message that carries calls together with the tool messages that answer
2401
2413
  * it, then each run of tool messages that no assistant message owns.
@@ -5653,6 +5665,12 @@ export declare const LEDGER_SCALE_DRIFT = 0.06;
5653
5665
  */
5654
5666
  export declare type LedgerAgentOptions = Pick<AgentOptions, 'limit' | 'timeout' | 'on'>;
5655
5667
 
5668
+ /** Identifies an accepted direct message amendment whose sentence scope remains unresolved. */
5669
+ export declare interface LedgerAmendment {
5670
+ readonly earlier: string;
5671
+ readonly later: string;
5672
+ }
5673
+
5656
5674
  /** Names the category the ledger files a message under, one of {@link LEDGER_CATEGORIES}. */
5657
5675
  export declare type LedgerCategory = (typeof LEDGER_CATEGORIES)[number];
5658
5676
 
@@ -5729,7 +5747,9 @@ export declare type LedgerErrorCode =
5729
5747
  /** Reports a lookup tool named `recall` or a name another lookup tool carries. */
5730
5748
  | 'LOOKUP'
5731
5749
  /** Reports a supplied gauge outside its bounds, or a calibration call that reports no prompt usage, or a prompt usage of 0 or less. */
5732
- | 'GAUGE';
5750
+ | 'GAUGE'
5751
+ /** Reports a render context that holds no reference for a source it annotates. */
5752
+ | 'REFERENCE';
5733
5753
 
5734
5754
  /**
5735
5755
  * Carries the price of a prompt in tokens, measured against the model the ledger serves.
@@ -5953,12 +5973,12 @@ export declare interface LedgerOwner {
5953
5973
  export declare type LedgerPlanningGroup = 1 | 2 | 3;
5954
5974
 
5955
5975
  /**
5956
- * Carries the records projected from a conversation, the stale sentences, and the live messages no
5976
+ * Carries the records projected from a conversation, accepted amendments, and the live messages no
5957
5977
  * record placed.
5958
5978
  */
5959
5979
  export declare interface LedgerProjection {
5960
5980
  readonly records: readonly LedgerRecord[];
5961
- readonly stale: readonly LedgerStaleSentence[];
5981
+ readonly amendments: readonly LedgerAmendment[];
5962
5982
  readonly orphans: readonly string[];
5963
5983
  }
5964
5984
 
@@ -6026,8 +6046,9 @@ export declare interface LedgerRecallOptions {
6026
6046
  *
6027
6047
  * @remarks
6028
6048
  * `key` is `rules` for the rules record and `owner:` followed by the owner id for an owner record.
6029
- * `title` is `Rules`, or the owner's first name with its id. `members` lists the placed message ids
6030
- * in conversation order.
6049
+ * `title` is `Rules`, or the owner's first name with its id. In a request view, owner records with
6050
+ * the same member ids in the same order render once, under their titles joined with `; `.
6051
+ * `members` lists the placed message ids in conversation order.
6031
6052
  */
6032
6053
  export declare interface LedgerRecord {
6033
6054
  readonly key: string;
@@ -6049,6 +6070,24 @@ export declare interface LedgerRegistry {
6049
6070
  readonly owners: ReadonlyMap<string, readonly string[]>;
6050
6071
  }
6051
6072
 
6073
+ /**
6074
+ * Supplies accepted amendments and completely included sources for one briefing rendering.
6075
+ *
6076
+ * @remarks
6077
+ * `first` identifies each source's first retained line object in actual emission order. Build this
6078
+ * context from the same line objects passed to the renderers after deduplication and trimming;
6079
+ * recompute it when the retained population changes. `references` assigns each distinct retained
6080
+ * source its decimal display reference in first-occurrence order, starting at 1. These
6081
+ * briefing-local references can change after trimming; the projection, recall, and storage retain
6082
+ * original source IDs.
6083
+ */
6084
+ export declare interface LedgerRenderContext {
6085
+ readonly amendments: readonly LedgerAmendment[];
6086
+ readonly complete: ReadonlySet<string>;
6087
+ readonly first: ReadonlyMap<string, LedgerLine>;
6088
+ readonly references: ReadonlyMap<string, string>;
6089
+ }
6090
+
6052
6091
  /**
6053
6092
  * Holds what one ledger request keeps while it is served: its message, its filing readings and
6054
6093
  * plan, the gauge calls of its passes, and its repeat and recall stops.
@@ -6276,20 +6315,6 @@ export declare interface LedgerShare {
6276
6315
  readonly tail: number;
6277
6316
  }
6278
6317
 
6279
- /**
6280
- * Carries one sentence a later message made stale, with the tokens the two share.
6281
- *
6282
- * @remarks
6283
- * `source` is the earlier message's id and `sentence` the zero-based index of the sentence. The
6284
- * projection leaves a stale sentence out of the records and the briefing. Recall and answer notes
6285
- * keep the stored content. The seed tail replaces lookup results with status stubs.
6286
- */
6287
- export declare interface LedgerStaleSentence {
6288
- readonly source: string;
6289
- readonly sentence: number;
6290
- readonly tokens: readonly string[];
6291
- }
6292
-
6293
6318
  /**
6294
6319
  * Carries the probability cutoff of each reading the ledger takes from its judge.
6295
6320
  *
@@ -7643,10 +7668,25 @@ export declare function renderFencedFile(path: string, language: string, content
7643
7668
  */
7644
7669
  export declare function renderJSON(value: unknown): string | undefined;
7645
7670
 
7671
+ /**
7672
+ * Renders source framing and unresolved amendment scope at a source's first retained line.
7673
+ * @param line - The retained occurrence to annotate
7674
+ * @param context - Actual complete sources, first occurrences, local references, and accepted amendment edges
7675
+ * @returns Source framing and truthful inclusion notes, or empty text for an unrelated or repeated occurrence
7676
+ * @throws {LedgerError} Thrown when the context holds no reference for the annotated source or a fully included amender (code `'REQUEST'`)
7677
+ *
7678
+ * @example
7679
+ * ```ts
7680
+ * renderLedgerAnnotation({ text: 'Unchanged.', source: 'user-1', sentence: 0, topics: [], role: 'user' }, buildLedgerRenderContext([], [], [])) // ''
7681
+ * ```
7682
+ */
7683
+ export declare function renderLedgerAnnotation(line: LedgerLine, context: LedgerRenderContext): string;
7684
+
7646
7685
  /**
7647
7686
  * Renders one owner record under a `###` heading, which the briefing nests under its one `## Pinned` heading.
7648
7687
  *
7649
7688
  * @param record - An owner record or view with a `title` and `lines`
7689
+ * @param context - Rendering facts for optional accepted amendment annotations
7650
7690
  * @returns `### TITLE` followed by `- LINE` for each line
7651
7691
  *
7652
7692
  * @example
@@ -7654,7 +7694,7 @@ export declare function renderJSON(value: unknown): string | undefined;
7654
7694
  * renderLedgerPinned({ title: 'Odile Marlow (account OM-30418)', lines: [] }) // '### Odile Marlow (account OM-30418)'
7655
7695
  * ```
7656
7696
  */
7657
- export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' | 'lines'>): string;
7697
+ export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' | 'lines'>, context?: LedgerRenderContext): string;
7658
7698
 
7659
7699
  /**
7660
7700
  * Renders one record as a heading and one list item per line.
@@ -7663,6 +7703,7 @@ export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' |
7663
7703
  * The briefing joins rendered records with one blank line.
7664
7704
  *
7665
7705
  * @param record - A record or view with a `title` and `lines`
7706
+ * @param context - Rendering facts for optional accepted amendment annotations
7666
7707
  * @returns `## TITLE` followed by `- LINE` for each line
7667
7708
  *
7668
7709
  * @example
@@ -7671,7 +7712,7 @@ export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' |
7671
7712
  * // '## Rules\n- Refunds need a manager.'
7672
7713
  * ```
7673
7714
  */
7674
- export declare function renderLedgerRecord(record: Pick<LedgerRecord, 'title' | 'lines'>): string;
7715
+ export declare function renderLedgerRecord(record: Pick<LedgerRecord, 'title' | 'lines'>, context?: LedgerRenderContext): string;
7675
7716
 
7676
7717
  /**
7677
7718
  * Renders a lookup call as its tool name and its JSON arguments.
@@ -8336,12 +8377,14 @@ export declare interface Selection {
8336
8377
  export declare type SelectionHandler = (conversation: ConversationInterface, request: Message, signal: AbortSignal) => Promise<Selection>;
8337
8378
 
8338
8379
  /**
8339
- * Selects a request's view of the projected records.
8380
+ * Selects a request's records, collapsing owners with equal ordered member ids under titles joined with `; `.
8340
8381
  *
8341
8382
  * @remarks
8342
8383
  * The view holds the owner records the request names in the order it names them, then the rules
8343
8384
  * record with the lines whose topics meet the request's first, each group in position order. The
8344
- * returned records and lines are copies.
8385
+ * returned records and lines are copies. Owner records with the same member ids in the same order
8386
+ * collapse into the first requested record, keeping its key, members, and lines and joining their
8387
+ * titles with `; ` before trimming.
8345
8388
  *
8346
8389
  * @param projection - The output of {@link buildRecords}
8347
8390
  * @param request - The owners and the desk topics the request names
@@ -1798,29 +1798,42 @@ export declare function buildJudgeResult(model: string, results: readonly JudgeR
1798
1798
  */
1799
1799
  export declare function buildJudgments(request: JudgeRequest, result: JudgeResult, sources: readonly string[], state: string, model: string): readonly JudgmentInput[];
1800
1800
 
1801
+ /**
1802
+ * Derives complete source identities, first occurrences, and local references from the actual briefing lines.
1803
+ * @param messages - Original messages whose indexed sentences establish completeness
1804
+ * @param lines - Retained lines in rendering order after deduplication and trimming
1805
+ * @param amendments - Accepted direct message amendment edges
1806
+ * @returns Immutable rendering facts for this retained population
1807
+ *
1808
+ * @example
1809
+ * ```ts
1810
+ * buildLedgerRenderContext([], [], []).complete.size // 0
1811
+ * ```
1812
+ */
1813
+ export declare function buildLedgerRenderContext(messages: readonly Message[], lines: readonly LedgerLine[], amendments: readonly LedgerAmendment[]): LedgerRenderContext;
1814
+
1801
1815
  /**
1802
1816
  * Builds the record lines of one message.
1803
1817
  *
1804
1818
  * @remarks
1805
- * Each sentence that is not stale becomes a line. A sentence that opens with a pronoun and follows
1819
+ * Each original indexed sentence becomes a line. A sentence that opens with a pronoun and follows
1806
1820
  * another sentence takes the last name of the sentence before it that is neither an owner name nor
1807
1821
  * a system name, and its line text opens with that party and a colon.
1808
1822
  *
1809
1823
  * @param input - The classification whose topics the lines carry
1810
1824
  * @param byId - The messages by id
1811
1825
  * @param id - The message id
1812
- * @param dead - The stale sentences as `SOURCE SENTENCE` keys
1813
1826
  * @param holders - The owner names, which never serve as a party
1814
1827
  * @param system - The system text's names, which never serve as a party
1815
1828
  * @returns The lines in sentence order; empty when the message is absent
1816
1829
  *
1817
1830
  * @example
1818
1831
  * ```ts
1819
- * buildLines(input, byId, 'user-1', new Set(), [], []).map((line) => line.text)
1832
+ * buildLines(input, byId, 'user-1', [], []).map((line) => line.text)
1820
1833
  * // ['Odile Marlow phoned about BW-5512.', 'Odile Marlow: She wants a refund.']
1821
1834
  * ```
1822
1835
  */
1823
- export declare function buildLines(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, id: string, dead: ReadonlySet<string>, holders: readonly string[], system: readonly string[]): readonly LedgerLine[];
1836
+ export declare function buildLines(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, id: string, holders: readonly string[], system: readonly string[]): readonly LedgerLine[];
1824
1837
 
1825
1838
  /**
1826
1839
  * Builds a request's JSON headers, awaiting the caller's header hook inside the call's
@@ -1910,8 +1923,8 @@ export declare function buildRecapMessage(section: Section): Message;
1910
1923
  * argument. A message that names no owner joins where its earlier side of an amendment pair joins,
1911
1924
  * or on the rules record when it is filed as a rule or a correction, and is an orphan otherwise.
1912
1925
  *
1913
- * A sentence an amending message made stale is left out and listed in `stale`. An amending message
1914
- * that is itself replaced keeps that effect, so the old value never revives.
1926
+ * Every live sentence is retained. Accepted direct edges are listed in `amendments`. An amending message
1927
+ * that is itself superseded retains its accepted edge without restoring its text.
1915
1928
  *
1916
1929
  * A sentence that opens with a pronoun takes the party named in the sentence before it. The reading
1917
1930
  * trusts capitals, so a capitalized word that is no person, such as a carrier named mid-sentence,
@@ -1919,7 +1932,7 @@ export declare function buildRecapMessage(section: Section): Message;
1919
1932
  * the follow-up facts the records exist for.
1920
1933
  *
1921
1934
  * @param input - The messages, readings, entities, and classification to project
1922
- * @returns The records with owner records ordered by their first member and the rules record last, the stale sentences, and the live message ids no record placed
1935
+ * @returns The records with owner records ordered by their first member and the rules record last, the accepted amendments, and the live message ids no record placed
1923
1936
  *
1924
1937
  * @example
1925
1938
  * ```ts
@@ -2268,6 +2281,26 @@ export declare interface CodedErrorOptions {
2268
2281
  readonly context?: Readonly<Record<string, unknown>>;
2269
2282
  }
2270
2283
 
2284
+ /**
2285
+ * Collects accepted direct amendments of live messages.
2286
+ *
2287
+ * @remarks
2288
+ * An accepted edge relates an earlier live message to an amender without claiming which sentences
2289
+ * changed. An amender takes effect while live and retains its edge after another message supersedes
2290
+ * it, without restoring the superseded text. An excluded or quiet user or tool message has no effect.
2291
+ *
2292
+ * @param input - The exclusions and classification to read
2293
+ * @param byId - The messages by id
2294
+ * @param live - The live message ids from {@link collectLive}
2295
+ * @returns The distinct accepted direct edges in conversation order
2296
+ *
2297
+ * @example
2298
+ * ```ts
2299
+ * collectAmendments(input, byId, ['user-1', 'user-3']) // [{ earlier: 'user-1', later: 'user-3' }]
2300
+ * ```
2301
+ */
2302
+ export declare function collectAmendments(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, live: readonly string[]): readonly LedgerAmendment[];
2303
+
2271
2304
  /**
2272
2305
  * Collects whole exchanges, joining every exchange spanned by a tool group.
2273
2306
  *
@@ -2350,7 +2383,7 @@ export declare function collectNames(text: string): readonly string[];
2350
2383
  * @returns The distinct live message ids
2351
2384
  * @example
2352
2385
  * ```ts
2353
- * collectProjectionIds({ records: [], stale: [], orphans: ['message-1'] }) // Set { 'message-1' }
2386
+ * collectProjectionIds({ records: [], amendments: [], orphans: ['message-1'] }) // Set { 'message-1' }
2354
2387
  * ```
2355
2388
  */
2356
2389
  export declare function collectProjectionIds(projection: LedgerProjection): ReadonlySet<string>;
@@ -2375,27 +2408,6 @@ export declare function collectProjectionIds(projection: LedgerProjection): Read
2375
2408
  */
2376
2409
  export declare function collectRegistry(readings: readonly LedgerLookupReading[]): LedgerRegistry;
2377
2410
 
2378
- /**
2379
- * Collects the sentences that live messages made stale.
2380
- *
2381
- * @remarks
2382
- * A sentence of a live message is stale when it shares an id or a number with a message that
2383
- * amends it. An amending message takes effect while it is live, and keeps its effect after another
2384
- * message supersedes it, so the value it replaced never revives. A user or tool message that the
2385
- * input excludes or files quiet never takes effect.
2386
- *
2387
- * @param input - The exclusions and classification to read
2388
- * @param byId - The messages by id
2389
- * @param live - The live message ids from {@link collectLive}
2390
- * @returns The stale sentences in conversation order, each with the tokens it shares
2391
- *
2392
- * @example
2393
- * ```ts
2394
- * collectStale(input, byId, ['user-1', 'user-3']) // [{ source: 'user-1', sentence: 1, tokens: ['ESC-2291'] }]
2395
- * ```
2396
- */
2397
- export declare function collectStale(input: LedgerProjectionInput, byId: ReadonlyMap<string, Message>, live: readonly string[]): readonly LedgerStaleSentence[];
2398
-
2399
2411
  /**
2400
2412
  * Collects each assistant message that carries calls together with the tool messages that answer
2401
2413
  * it, then each run of tool messages that no assistant message owns.
@@ -5653,6 +5665,12 @@ export declare const LEDGER_SCALE_DRIFT = 0.06;
5653
5665
  */
5654
5666
  export declare type LedgerAgentOptions = Pick<AgentOptions, 'limit' | 'timeout' | 'on'>;
5655
5667
 
5668
+ /** Identifies an accepted direct message amendment whose sentence scope remains unresolved. */
5669
+ export declare interface LedgerAmendment {
5670
+ readonly earlier: string;
5671
+ readonly later: string;
5672
+ }
5673
+
5656
5674
  /** Names the category the ledger files a message under, one of {@link LEDGER_CATEGORIES}. */
5657
5675
  export declare type LedgerCategory = (typeof LEDGER_CATEGORIES)[number];
5658
5676
 
@@ -5729,7 +5747,9 @@ export declare type LedgerErrorCode =
5729
5747
  /** Reports a lookup tool named `recall` or a name another lookup tool carries. */
5730
5748
  | 'LOOKUP'
5731
5749
  /** Reports a supplied gauge outside its bounds, or a calibration call that reports no prompt usage, or a prompt usage of 0 or less. */
5732
- | 'GAUGE';
5750
+ | 'GAUGE'
5751
+ /** Reports a render context that holds no reference for a source it annotates. */
5752
+ | 'REFERENCE';
5733
5753
 
5734
5754
  /**
5735
5755
  * Carries the price of a prompt in tokens, measured against the model the ledger serves.
@@ -5953,12 +5973,12 @@ export declare interface LedgerOwner {
5953
5973
  export declare type LedgerPlanningGroup = 1 | 2 | 3;
5954
5974
 
5955
5975
  /**
5956
- * Carries the records projected from a conversation, the stale sentences, and the live messages no
5976
+ * Carries the records projected from a conversation, accepted amendments, and the live messages no
5957
5977
  * record placed.
5958
5978
  */
5959
5979
  export declare interface LedgerProjection {
5960
5980
  readonly records: readonly LedgerRecord[];
5961
- readonly stale: readonly LedgerStaleSentence[];
5981
+ readonly amendments: readonly LedgerAmendment[];
5962
5982
  readonly orphans: readonly string[];
5963
5983
  }
5964
5984
 
@@ -6026,8 +6046,9 @@ export declare interface LedgerRecallOptions {
6026
6046
  *
6027
6047
  * @remarks
6028
6048
  * `key` is `rules` for the rules record and `owner:` followed by the owner id for an owner record.
6029
- * `title` is `Rules`, or the owner's first name with its id. `members` lists the placed message ids
6030
- * in conversation order.
6049
+ * `title` is `Rules`, or the owner's first name with its id. In a request view, owner records with
6050
+ * the same member ids in the same order render once, under their titles joined with `; `.
6051
+ * `members` lists the placed message ids in conversation order.
6031
6052
  */
6032
6053
  export declare interface LedgerRecord {
6033
6054
  readonly key: string;
@@ -6049,6 +6070,24 @@ export declare interface LedgerRegistry {
6049
6070
  readonly owners: ReadonlyMap<string, readonly string[]>;
6050
6071
  }
6051
6072
 
6073
+ /**
6074
+ * Supplies accepted amendments and completely included sources for one briefing rendering.
6075
+ *
6076
+ * @remarks
6077
+ * `first` identifies each source's first retained line object in actual emission order. Build this
6078
+ * context from the same line objects passed to the renderers after deduplication and trimming;
6079
+ * recompute it when the retained population changes. `references` assigns each distinct retained
6080
+ * source its decimal display reference in first-occurrence order, starting at 1. These
6081
+ * briefing-local references can change after trimming; the projection, recall, and storage retain
6082
+ * original source IDs.
6083
+ */
6084
+ export declare interface LedgerRenderContext {
6085
+ readonly amendments: readonly LedgerAmendment[];
6086
+ readonly complete: ReadonlySet<string>;
6087
+ readonly first: ReadonlyMap<string, LedgerLine>;
6088
+ readonly references: ReadonlyMap<string, string>;
6089
+ }
6090
+
6052
6091
  /**
6053
6092
  * Holds what one ledger request keeps while it is served: its message, its filing readings and
6054
6093
  * plan, the gauge calls of its passes, and its repeat and recall stops.
@@ -6276,20 +6315,6 @@ export declare interface LedgerShare {
6276
6315
  readonly tail: number;
6277
6316
  }
6278
6317
 
6279
- /**
6280
- * Carries one sentence a later message made stale, with the tokens the two share.
6281
- *
6282
- * @remarks
6283
- * `source` is the earlier message's id and `sentence` the zero-based index of the sentence. The
6284
- * projection leaves a stale sentence out of the records and the briefing. Recall and answer notes
6285
- * keep the stored content. The seed tail replaces lookup results with status stubs.
6286
- */
6287
- export declare interface LedgerStaleSentence {
6288
- readonly source: string;
6289
- readonly sentence: number;
6290
- readonly tokens: readonly string[];
6291
- }
6292
-
6293
6318
  /**
6294
6319
  * Carries the probability cutoff of each reading the ledger takes from its judge.
6295
6320
  *
@@ -7643,10 +7668,25 @@ export declare function renderFencedFile(path: string, language: string, content
7643
7668
  */
7644
7669
  export declare function renderJSON(value: unknown): string | undefined;
7645
7670
 
7671
+ /**
7672
+ * Renders source framing and unresolved amendment scope at a source's first retained line.
7673
+ * @param line - The retained occurrence to annotate
7674
+ * @param context - Actual complete sources, first occurrences, local references, and accepted amendment edges
7675
+ * @returns Source framing and truthful inclusion notes, or empty text for an unrelated or repeated occurrence
7676
+ * @throws {LedgerError} Thrown when the context holds no reference for the annotated source or a fully included amender (code `'REQUEST'`)
7677
+ *
7678
+ * @example
7679
+ * ```ts
7680
+ * renderLedgerAnnotation({ text: 'Unchanged.', source: 'user-1', sentence: 0, topics: [], role: 'user' }, buildLedgerRenderContext([], [], [])) // ''
7681
+ * ```
7682
+ */
7683
+ export declare function renderLedgerAnnotation(line: LedgerLine, context: LedgerRenderContext): string;
7684
+
7646
7685
  /**
7647
7686
  * Renders one owner record under a `###` heading, which the briefing nests under its one `## Pinned` heading.
7648
7687
  *
7649
7688
  * @param record - An owner record or view with a `title` and `lines`
7689
+ * @param context - Rendering facts for optional accepted amendment annotations
7650
7690
  * @returns `### TITLE` followed by `- LINE` for each line
7651
7691
  *
7652
7692
  * @example
@@ -7654,7 +7694,7 @@ export declare function renderJSON(value: unknown): string | undefined;
7654
7694
  * renderLedgerPinned({ title: 'Odile Marlow (account OM-30418)', lines: [] }) // '### Odile Marlow (account OM-30418)'
7655
7695
  * ```
7656
7696
  */
7657
- export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' | 'lines'>): string;
7697
+ export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' | 'lines'>, context?: LedgerRenderContext): string;
7658
7698
 
7659
7699
  /**
7660
7700
  * Renders one record as a heading and one list item per line.
@@ -7663,6 +7703,7 @@ export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' |
7663
7703
  * The briefing joins rendered records with one blank line.
7664
7704
  *
7665
7705
  * @param record - A record or view with a `title` and `lines`
7706
+ * @param context - Rendering facts for optional accepted amendment annotations
7666
7707
  * @returns `## TITLE` followed by `- LINE` for each line
7667
7708
  *
7668
7709
  * @example
@@ -7671,7 +7712,7 @@ export declare function renderLedgerPinned(record: Pick<LedgerRecord, 'title' |
7671
7712
  * // '## Rules\n- Refunds need a manager.'
7672
7713
  * ```
7673
7714
  */
7674
- export declare function renderLedgerRecord(record: Pick<LedgerRecord, 'title' | 'lines'>): string;
7715
+ export declare function renderLedgerRecord(record: Pick<LedgerRecord, 'title' | 'lines'>, context?: LedgerRenderContext): string;
7675
7716
 
7676
7717
  /**
7677
7718
  * Renders a lookup call as its tool name and its JSON arguments.
@@ -8336,12 +8377,14 @@ export declare interface Selection {
8336
8377
  export declare type SelectionHandler = (conversation: ConversationInterface, request: Message, signal: AbortSignal) => Promise<Selection>;
8337
8378
 
8338
8379
  /**
8339
- * Selects a request's view of the projected records.
8380
+ * Selects a request's records, collapsing owners with equal ordered member ids under titles joined with `; `.
8340
8381
  *
8341
8382
  * @remarks
8342
8383
  * The view holds the owner records the request names in the order it names them, then the rules
8343
8384
  * record with the lines whose topics meet the request's first, each group in position order. The
8344
- * returned records and lines are copies.
8385
+ * returned records and lines are copies. Owner records with the same member ids in the same order
8386
+ * collapse into the first requested record, keeping its key, members, and lines and joining their
8387
+ * titles with `; ` before trimming.
8345
8388
  *
8346
8389
  * @param projection - The output of {@link buildRecords}
8347
8390
  * @param request - The owners and the desk topics the request names