@orkestrel/agent 0.0.31 → 0.0.33
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/src/core/index.cjs +298 -209
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +119 -76
- package/dist/src/core/index.d.ts +119 -76
- package/dist/src/core/index.js +297 -210
- package/dist/src/core/index.js.map +1 -1
- package/package.json +28 -27
package/dist/src/core/index.d.ts
CHANGED
|
@@ -691,7 +691,7 @@ export declare interface AgentInterface {
|
|
|
691
691
|
*/
|
|
692
692
|
export declare class AgentJobError extends Error {
|
|
693
693
|
/** Names the machine-readable condition — `'PARTIAL'`: a job that ended partial under a disallowing policy. */
|
|
694
|
-
readonly code:
|
|
694
|
+
readonly code: 'PARTIAL';
|
|
695
695
|
/** Holds the partial {@link AgentResult} the cancelled job produced. */
|
|
696
696
|
readonly partial: AgentResult;
|
|
697
697
|
constructor(message: string, partial: AgentResult);
|
|
@@ -1543,7 +1543,7 @@ export declare interface AgentTurn {
|
|
|
1543
1543
|
readonly usage: TokenUsage | undefined;
|
|
1544
1544
|
readonly spent: TokenUsage | undefined;
|
|
1545
1545
|
readonly messages: readonly Message[];
|
|
1546
|
-
readonly
|
|
1546
|
+
readonly outcome: 'answer' | 'tools' | 'cancel';
|
|
1547
1547
|
readonly partial: boolean;
|
|
1548
1548
|
readonly futile: boolean;
|
|
1549
1549
|
readonly estimate: number | undefined;
|
|
@@ -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
|
|
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',
|
|
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,
|
|
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
|
-
*
|
|
1914
|
-
* that is itself
|
|
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
|
|
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: [],
|
|
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.
|
|
@@ -4604,7 +4616,7 @@ export declare interface GaugeInterface extends LedgerGauge {
|
|
|
4604
4616
|
* `'CAPACITY'` otherwise. `replay` names the thinking the next request carries. Default: `'none'`.
|
|
4605
4617
|
* Measured use is `prompt + completion - (thinking ?? 0)` for `'none'`, and `prompt + completion`
|
|
4606
4618
|
* otherwise; absent completion counts as 0. Without prompt usage, use is `overhead + scale * estimate`.
|
|
4607
|
-
* Capacity left is `max(0, capacity - used)`. The reply reserve adds recall
|
|
4619
|
+
* Capacity left is `max(0, capacity - used)`. The reply reserve adds recall uniform at the marginal
|
|
4608
4620
|
* rate to the largest observed reply's `completion - (thinking ?? 0)` for every policy.
|
|
4609
4621
|
* Without a positive reply observation, it prices the longest reply text at that rate. Recall room is
|
|
4610
4622
|
* `max(0, (remainder - predict - reserve) / 2 / rate)`; recall closes at `remainder - predict < 2 * reserve`.
|
|
@@ -4996,7 +5008,7 @@ export declare function intersectKeys(parent: readonly string[] | undefined, chi
|
|
|
4996
5008
|
export declare const INVALID_RELAY_STATUS = 400;
|
|
4997
5009
|
|
|
4998
5010
|
/**
|
|
4999
|
-
* Narrows an unknown caught value to an {@link AgentError} through
|
|
5011
|
+
* Narrows an unknown caught value to an {@link AgentError} through its identity brand and declared members, so a `catch`
|
|
5000
5012
|
* can branch on its `code`.
|
|
5001
5013
|
*
|
|
5002
5014
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5014,7 +5026,7 @@ export declare const INVALID_RELAY_STATUS = 400;
|
|
|
5014
5026
|
export declare function isAgentError(value: unknown): value is AgentError;
|
|
5015
5027
|
|
|
5016
5028
|
/**
|
|
5017
|
-
* Narrows an unknown caught value to an {@link AgentJobError} through
|
|
5029
|
+
* Narrows an unknown caught value to an {@link AgentJobError} through its identity brand and declared members, so a
|
|
5018
5030
|
* `catch` can recover its `partial` result.
|
|
5019
5031
|
*
|
|
5020
5032
|
* @param value - The value to test (typically a `catch` binding or a rejected enqueue)
|
|
@@ -5032,7 +5044,7 @@ export declare function isAgentError(value: unknown): value is AgentError;
|
|
|
5032
5044
|
export declare function isAgentJobError(value: unknown): value is AgentJobError;
|
|
5033
5045
|
|
|
5034
5046
|
/**
|
|
5035
|
-
* Narrows an unknown caught value to a {@link ConversationError} through
|
|
5047
|
+
* Narrows an unknown caught value to a {@link ConversationError} through its identity brand and declared members, so a
|
|
5036
5048
|
* `catch` can branch on its `code`.
|
|
5037
5049
|
*
|
|
5038
5050
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5094,7 +5106,7 @@ export declare function isConversationSnapshot(value: unknown): value is Convers
|
|
|
5094
5106
|
export declare function isFraction(value: unknown): value is number;
|
|
5095
5107
|
|
|
5096
5108
|
/**
|
|
5097
|
-
* Narrows a caught value to a {@link JudgeAbortError} through
|
|
5109
|
+
* Narrows a caught value to a {@link JudgeAbortError} through its identity brand and declared members, so a `catch` can
|
|
5098
5110
|
* recover its `partial` result.
|
|
5099
5111
|
*
|
|
5100
5112
|
* @param value - The caught value
|
|
@@ -5126,7 +5138,7 @@ export declare function isJudgeAbortError(value: unknown): value is JudgeAbortEr
|
|
|
5126
5138
|
export declare function isJudgeEntry(value: unknown): value is JudgeEntry;
|
|
5127
5139
|
|
|
5128
5140
|
/**
|
|
5129
|
-
* Narrows a caught value to the judge failure class through
|
|
5141
|
+
* Narrows a caught value to the judge failure class through its identity brand and declared members.
|
|
5130
5142
|
*
|
|
5131
5143
|
* @param value - The caught value
|
|
5132
5144
|
* @returns True if the value is a {@link JudgeError}; false otherwise
|
|
@@ -5179,7 +5191,7 @@ export declare function isJudgeQuestion(value: unknown): value is JudgeQuestion;
|
|
|
5179
5191
|
export declare function isJudgment(value: unknown): value is Judgment;
|
|
5180
5192
|
|
|
5181
5193
|
/**
|
|
5182
|
-
* Narrows an unknown caught value to a {@link LedgerError} through
|
|
5194
|
+
* Narrows an unknown caught value to a {@link LedgerError} through its identity brand and declared members, so a `catch` can
|
|
5183
5195
|
* branch on its `code`.
|
|
5184
5196
|
*
|
|
5185
5197
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5246,7 +5258,7 @@ export declare function isNonNegativeSafeInteger(value: unknown): value is numbe
|
|
|
5246
5258
|
export declare function isPositiveSafeInteger(value: unknown): value is number;
|
|
5247
5259
|
|
|
5248
5260
|
/**
|
|
5249
|
-
* Narrows an unknown caught value to a {@link ProviderAbortError} through
|
|
5261
|
+
* Narrows an unknown caught value to a {@link ProviderAbortError} through its identity brand and declared members, so a
|
|
5250
5262
|
* `catch` can recover its `partial` result.
|
|
5251
5263
|
*
|
|
5252
5264
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5264,7 +5276,7 @@ export declare function isPositiveSafeInteger(value: unknown): value is number;
|
|
|
5264
5276
|
export declare function isProviderAbortError(value: unknown): value is ProviderAbortError;
|
|
5265
5277
|
|
|
5266
5278
|
/**
|
|
5267
|
-
* Narrows a caught value to the provider failure class through
|
|
5279
|
+
* Narrows a caught value to the provider failure class through its identity brand and declared members.
|
|
5268
5280
|
*
|
|
5269
5281
|
* @param value - The caught value
|
|
5270
5282
|
* @returns True if the value is a provider failure; false otherwise
|
|
@@ -5376,7 +5388,7 @@ export declare function joinThinking(running: string | undefined, next: string):
|
|
|
5376
5388
|
*/
|
|
5377
5389
|
export declare class JudgeAbortError extends Error {
|
|
5378
5390
|
/** Names the machine-readable condition — `'ABORT'`: a judge call cancelled mid-flight. */
|
|
5379
|
-
readonly code:
|
|
5391
|
+
readonly code: 'ABORT';
|
|
5380
5392
|
readonly partial: JudgeResult;
|
|
5381
5393
|
constructor(partial: JudgeResult, options?: ErrorOptions);
|
|
5382
5394
|
}
|
|
@@ -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.
|
|
@@ -5950,15 +5970,15 @@ export declare interface LedgerOwner {
|
|
|
5950
5970
|
}
|
|
5951
5971
|
|
|
5952
5972
|
/** Names a briefing source's planning group: a topic match, an off-topic rule or correction, or a name match. */
|
|
5953
|
-
export declare type
|
|
5973
|
+
export declare type LedgerPlanGroup = 1 | 2 | 3;
|
|
5954
5974
|
|
|
5955
5975
|
/**
|
|
5956
|
-
* Carries the records projected from a conversation,
|
|
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
|
|
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.
|
|
6030
|
-
* in
|
|
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
|
*
|
|
@@ -6432,7 +6457,7 @@ export declare const MAX_ERROR_BODY_LENGTH = 2048;
|
|
|
6432
6457
|
* @remarks
|
|
6433
6458
|
* The result is a structural estimate, not a tokenizer allocation. `id` and `role` are joins back to
|
|
6434
6459
|
* the message, not token components, and a provider's template effects and the estimation error are
|
|
6435
|
-
* not individually attributed. `content` is `ceil(length / 4)`, `
|
|
6460
|
+
* not individually attributed. `content` is `ceil(length / 4)`, `uniform` is
|
|
6436
6461
|
* {@link import('./constants.js').MESSAGE_TOKEN_OVERHEAD}, `calls` is the estimate of the JSON-rendered
|
|
6437
6462
|
* calls (`0` when the message carries none, the framing overhead when they cannot be rendered),
|
|
6438
6463
|
* `thinking` is the estimate of the thinking (`0` when absent), and `images` is the attached image
|
|
@@ -6444,7 +6469,7 @@ export declare const MAX_ERROR_BODY_LENGTH = 2048;
|
|
|
6444
6469
|
* @example
|
|
6445
6470
|
* ```ts
|
|
6446
6471
|
* measureMessage({ id: '1', role: 'user', content: 'hello' })
|
|
6447
|
-
* // { id: '1', role: 'user', content: 2,
|
|
6472
|
+
* // { id: '1', role: 'user', content: 2, uniform: 4, calls: 0, thinking: 0, images: 0 }
|
|
6448
6473
|
* ```
|
|
6449
6474
|
*/
|
|
6450
6475
|
export declare function measureMessage(message: Message): MessageMeasure;
|
|
@@ -6468,7 +6493,7 @@ export declare function measureMessage(message: Message): MessageMeasure;
|
|
|
6468
6493
|
* @example
|
|
6469
6494
|
* ```ts
|
|
6470
6495
|
* measureRequest({ messages: [{ id: '1', role: 'user', content: 'hello' }] })
|
|
6471
|
-
* // { messages: [{ id: '1', role: 'user', content: 2,
|
|
6496
|
+
* // { messages: [{ id: '1', role: 'user', content: 2, uniform: 4, calls: 0, thinking: 0, images: 0 }], tools: 0, schema: 0 }
|
|
6472
6497
|
* ```
|
|
6473
6498
|
*/
|
|
6474
6499
|
export declare function measureRequest(request: ProviderRequest): RequestMeasure;
|
|
@@ -6595,7 +6620,7 @@ export declare const MESSAGE_TOKEN_OVERHEAD = 4;
|
|
|
6595
6620
|
/** Validates and projects conversation messages at a JSON wire boundary. */
|
|
6596
6621
|
export declare const messageContract: ContractInterface<Readonly<{
|
|
6597
6622
|
id: string;
|
|
6598
|
-
role: "
|
|
6623
|
+
role: "assistant" | "system" | "tool" | "user";
|
|
6599
6624
|
content: string;
|
|
6600
6625
|
} & {
|
|
6601
6626
|
calls?: readonly Readonly<{
|
|
@@ -6693,7 +6718,7 @@ export declare interface MessageManagerInterface {
|
|
|
6693
6718
|
*
|
|
6694
6719
|
* @remarks
|
|
6695
6720
|
* The structural estimate is not a tokenizer allocation. `id` and `role` are joins back to the
|
|
6696
|
-
* message, not token components. A message's estimate is the sum of `content`, `
|
|
6721
|
+
* message, not token components. A message's estimate is the sum of `content`, `uniform`, `calls`,
|
|
6697
6722
|
* `thinking`, and `images`; no total is stored. A provider's template effects and the estimation
|
|
6698
6723
|
* error are not individually attributed.
|
|
6699
6724
|
*/
|
|
@@ -6702,9 +6727,9 @@ export declare interface MessageMeasure {
|
|
|
6702
6727
|
readonly role: MessageRole;
|
|
6703
6728
|
/** Holds the `ceil(length / 4)` estimate of the message `content`. */
|
|
6704
6729
|
readonly content: number;
|
|
6705
|
-
/** Holds the fixed per-message
|
|
6706
|
-
readonly
|
|
6707
|
-
/** Holds the estimate of the JSON-rendered `calls`, or the
|
|
6730
|
+
/** Holds the fixed per-message uniform overhead. */
|
|
6731
|
+
readonly uniform: number;
|
|
6732
|
+
/** Holds the estimate of the JSON-rendered `calls`, or the uniform overhead when they cannot be rendered; `0` when the message carries none. */
|
|
6708
6733
|
readonly calls: number;
|
|
6709
6734
|
/** Holds the estimate of the message `thinking`; `0` when absent. */
|
|
6710
6735
|
readonly thinking: number;
|
|
@@ -6829,7 +6854,7 @@ export declare function placeMember(input: LedgerProjectionInput, links: Readonl
|
|
|
6829
6854
|
*/
|
|
6830
6855
|
export declare class ProviderAbortError extends Error {
|
|
6831
6856
|
/** Names the machine-readable condition — `'ABORT'`: a stream cancelled mid-flight. */
|
|
6832
|
-
readonly code:
|
|
6857
|
+
readonly code: 'ABORT';
|
|
6833
6858
|
readonly partial: ProviderResult;
|
|
6834
6859
|
constructor(partial: ProviderResult, options?: ErrorOptions);
|
|
6835
6860
|
}
|
|
@@ -6990,7 +7015,7 @@ export declare interface ProviderRequest {
|
|
|
6990
7015
|
export declare const providerRequestContract: ContractInterface<Readonly<{
|
|
6991
7016
|
messages: readonly Readonly<{
|
|
6992
7017
|
id: string;
|
|
6993
|
-
role: "
|
|
7018
|
+
role: "assistant" | "system" | "tool" | "user";
|
|
6994
7019
|
content: string;
|
|
6995
7020
|
} & {
|
|
6996
7021
|
calls?: readonly Readonly<{
|
|
@@ -7205,7 +7230,7 @@ export declare function raceSignal<T>(promise: Promise<T>, signal: AbortSignal |
|
|
|
7205
7230
|
* rankLedgerCut(2, false, 'rule') // 3
|
|
7206
7231
|
* ```
|
|
7207
7232
|
*/
|
|
7208
|
-
export declare function rankLedgerCut(group:
|
|
7233
|
+
export declare function rankLedgerCut(group: LedgerPlanGroup, unsettled: boolean, category: LedgerCategory | undefined): number;
|
|
7209
7234
|
|
|
7210
7235
|
/**
|
|
7211
7236
|
* Decodes UTF-8 chunks with a final flush and releases the stream on every exit.
|
|
@@ -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'
|
|
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'
|
|
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
|
|
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
|