@orkestrel/agent 0.0.32 → 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 +122 -30
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +24 -24
- package/dist/src/core/index.d.ts +24 -24
- package/dist/src/core/index.js +123 -31
- package/dist/src/core/index.js.map +1 -1
- package/package.json +22 -22
|
@@ -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;
|
|
@@ -4616,7 +4616,7 @@ export declare interface GaugeInterface extends LedgerGauge {
|
|
|
4616
4616
|
* `'CAPACITY'` otherwise. `replay` names the thinking the next request carries. Default: `'none'`.
|
|
4617
4617
|
* Measured use is `prompt + completion - (thinking ?? 0)` for `'none'`, and `prompt + completion`
|
|
4618
4618
|
* otherwise; absent completion counts as 0. Without prompt usage, use is `overhead + scale * estimate`.
|
|
4619
|
-
* 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
|
|
4620
4620
|
* rate to the largest observed reply's `completion - (thinking ?? 0)` for every policy.
|
|
4621
4621
|
* Without a positive reply observation, it prices the longest reply text at that rate. Recall room is
|
|
4622
4622
|
* `max(0, (remainder - predict - reserve) / 2 / rate)`; recall closes at `remainder - predict < 2 * reserve`.
|
|
@@ -5008,7 +5008,7 @@ export declare function intersectKeys(parent: readonly string[] | undefined, chi
|
|
|
5008
5008
|
export declare const INVALID_RELAY_STATUS = 400;
|
|
5009
5009
|
|
|
5010
5010
|
/**
|
|
5011
|
-
* 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`
|
|
5012
5012
|
* can branch on its `code`.
|
|
5013
5013
|
*
|
|
5014
5014
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5026,7 +5026,7 @@ export declare const INVALID_RELAY_STATUS = 400;
|
|
|
5026
5026
|
export declare function isAgentError(value: unknown): value is AgentError;
|
|
5027
5027
|
|
|
5028
5028
|
/**
|
|
5029
|
-
* 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
|
|
5030
5030
|
* `catch` can recover its `partial` result.
|
|
5031
5031
|
*
|
|
5032
5032
|
* @param value - The value to test (typically a `catch` binding or a rejected enqueue)
|
|
@@ -5044,7 +5044,7 @@ export declare function isAgentError(value: unknown): value is AgentError;
|
|
|
5044
5044
|
export declare function isAgentJobError(value: unknown): value is AgentJobError;
|
|
5045
5045
|
|
|
5046
5046
|
/**
|
|
5047
|
-
* 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
|
|
5048
5048
|
* `catch` can branch on its `code`.
|
|
5049
5049
|
*
|
|
5050
5050
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5106,7 +5106,7 @@ export declare function isConversationSnapshot(value: unknown): value is Convers
|
|
|
5106
5106
|
export declare function isFraction(value: unknown): value is number;
|
|
5107
5107
|
|
|
5108
5108
|
/**
|
|
5109
|
-
* 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
|
|
5110
5110
|
* recover its `partial` result.
|
|
5111
5111
|
*
|
|
5112
5112
|
* @param value - The caught value
|
|
@@ -5138,7 +5138,7 @@ export declare function isJudgeAbortError(value: unknown): value is JudgeAbortEr
|
|
|
5138
5138
|
export declare function isJudgeEntry(value: unknown): value is JudgeEntry;
|
|
5139
5139
|
|
|
5140
5140
|
/**
|
|
5141
|
-
* 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.
|
|
5142
5142
|
*
|
|
5143
5143
|
* @param value - The caught value
|
|
5144
5144
|
* @returns True if the value is a {@link JudgeError}; false otherwise
|
|
@@ -5191,7 +5191,7 @@ export declare function isJudgeQuestion(value: unknown): value is JudgeQuestion;
|
|
|
5191
5191
|
export declare function isJudgment(value: unknown): value is Judgment;
|
|
5192
5192
|
|
|
5193
5193
|
/**
|
|
5194
|
-
* 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
|
|
5195
5195
|
* branch on its `code`.
|
|
5196
5196
|
*
|
|
5197
5197
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5258,7 +5258,7 @@ export declare function isNonNegativeSafeInteger(value: unknown): value is numbe
|
|
|
5258
5258
|
export declare function isPositiveSafeInteger(value: unknown): value is number;
|
|
5259
5259
|
|
|
5260
5260
|
/**
|
|
5261
|
-
* 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
|
|
5262
5262
|
* `catch` can recover its `partial` result.
|
|
5263
5263
|
*
|
|
5264
5264
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5276,7 +5276,7 @@ export declare function isPositiveSafeInteger(value: unknown): value is number;
|
|
|
5276
5276
|
export declare function isProviderAbortError(value: unknown): value is ProviderAbortError;
|
|
5277
5277
|
|
|
5278
5278
|
/**
|
|
5279
|
-
* 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.
|
|
5280
5280
|
*
|
|
5281
5281
|
* @param value - The caught value
|
|
5282
5282
|
* @returns True if the value is a provider failure; false otherwise
|
|
@@ -5388,7 +5388,7 @@ export declare function joinThinking(running: string | undefined, next: string):
|
|
|
5388
5388
|
*/
|
|
5389
5389
|
export declare class JudgeAbortError extends Error {
|
|
5390
5390
|
/** Names the machine-readable condition — `'ABORT'`: a judge call cancelled mid-flight. */
|
|
5391
|
-
readonly code:
|
|
5391
|
+
readonly code: 'ABORT';
|
|
5392
5392
|
readonly partial: JudgeResult;
|
|
5393
5393
|
constructor(partial: JudgeResult, options?: ErrorOptions);
|
|
5394
5394
|
}
|
|
@@ -5970,7 +5970,7 @@ export declare interface LedgerOwner {
|
|
|
5970
5970
|
}
|
|
5971
5971
|
|
|
5972
5972
|
/** Names a briefing source's planning group: a topic match, an off-topic rule or correction, or a name match. */
|
|
5973
|
-
export declare type
|
|
5973
|
+
export declare type LedgerPlanGroup = 1 | 2 | 3;
|
|
5974
5974
|
|
|
5975
5975
|
/**
|
|
5976
5976
|
* Carries the records projected from a conversation, accepted amendments, and the live messages no
|
|
@@ -6457,7 +6457,7 @@ export declare const MAX_ERROR_BODY_LENGTH = 2048;
|
|
|
6457
6457
|
* @remarks
|
|
6458
6458
|
* The result is a structural estimate, not a tokenizer allocation. `id` and `role` are joins back to
|
|
6459
6459
|
* the message, not token components, and a provider's template effects and the estimation error are
|
|
6460
|
-
* not individually attributed. `content` is `ceil(length / 4)`, `
|
|
6460
|
+
* not individually attributed. `content` is `ceil(length / 4)`, `uniform` is
|
|
6461
6461
|
* {@link import('./constants.js').MESSAGE_TOKEN_OVERHEAD}, `calls` is the estimate of the JSON-rendered
|
|
6462
6462
|
* calls (`0` when the message carries none, the framing overhead when they cannot be rendered),
|
|
6463
6463
|
* `thinking` is the estimate of the thinking (`0` when absent), and `images` is the attached image
|
|
@@ -6469,7 +6469,7 @@ export declare const MAX_ERROR_BODY_LENGTH = 2048;
|
|
|
6469
6469
|
* @example
|
|
6470
6470
|
* ```ts
|
|
6471
6471
|
* measureMessage({ id: '1', role: 'user', content: 'hello' })
|
|
6472
|
-
* // { id: '1', role: 'user', content: 2,
|
|
6472
|
+
* // { id: '1', role: 'user', content: 2, uniform: 4, calls: 0, thinking: 0, images: 0 }
|
|
6473
6473
|
* ```
|
|
6474
6474
|
*/
|
|
6475
6475
|
export declare function measureMessage(message: Message): MessageMeasure;
|
|
@@ -6493,7 +6493,7 @@ export declare function measureMessage(message: Message): MessageMeasure;
|
|
|
6493
6493
|
* @example
|
|
6494
6494
|
* ```ts
|
|
6495
6495
|
* measureRequest({ messages: [{ id: '1', role: 'user', content: 'hello' }] })
|
|
6496
|
-
* // { 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 }
|
|
6497
6497
|
* ```
|
|
6498
6498
|
*/
|
|
6499
6499
|
export declare function measureRequest(request: ProviderRequest): RequestMeasure;
|
|
@@ -6620,7 +6620,7 @@ export declare const MESSAGE_TOKEN_OVERHEAD = 4;
|
|
|
6620
6620
|
/** Validates and projects conversation messages at a JSON wire boundary. */
|
|
6621
6621
|
export declare const messageContract: ContractInterface<Readonly<{
|
|
6622
6622
|
id: string;
|
|
6623
|
-
role: "
|
|
6623
|
+
role: "assistant" | "system" | "tool" | "user";
|
|
6624
6624
|
content: string;
|
|
6625
6625
|
} & {
|
|
6626
6626
|
calls?: readonly Readonly<{
|
|
@@ -6718,7 +6718,7 @@ export declare interface MessageManagerInterface {
|
|
|
6718
6718
|
*
|
|
6719
6719
|
* @remarks
|
|
6720
6720
|
* The structural estimate is not a tokenizer allocation. `id` and `role` are joins back to the
|
|
6721
|
-
* 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`,
|
|
6722
6722
|
* `thinking`, and `images`; no total is stored. A provider's template effects and the estimation
|
|
6723
6723
|
* error are not individually attributed.
|
|
6724
6724
|
*/
|
|
@@ -6727,9 +6727,9 @@ export declare interface MessageMeasure {
|
|
|
6727
6727
|
readonly role: MessageRole;
|
|
6728
6728
|
/** Holds the `ceil(length / 4)` estimate of the message `content`. */
|
|
6729
6729
|
readonly content: number;
|
|
6730
|
-
/** Holds the fixed per-message
|
|
6731
|
-
readonly
|
|
6732
|
-
/** 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. */
|
|
6733
6733
|
readonly calls: number;
|
|
6734
6734
|
/** Holds the estimate of the message `thinking`; `0` when absent. */
|
|
6735
6735
|
readonly thinking: number;
|
|
@@ -6854,7 +6854,7 @@ export declare function placeMember(input: LedgerProjectionInput, links: Readonl
|
|
|
6854
6854
|
*/
|
|
6855
6855
|
export declare class ProviderAbortError extends Error {
|
|
6856
6856
|
/** Names the machine-readable condition — `'ABORT'`: a stream cancelled mid-flight. */
|
|
6857
|
-
readonly code:
|
|
6857
|
+
readonly code: 'ABORT';
|
|
6858
6858
|
readonly partial: ProviderResult;
|
|
6859
6859
|
constructor(partial: ProviderResult, options?: ErrorOptions);
|
|
6860
6860
|
}
|
|
@@ -7015,7 +7015,7 @@ export declare interface ProviderRequest {
|
|
|
7015
7015
|
export declare const providerRequestContract: ContractInterface<Readonly<{
|
|
7016
7016
|
messages: readonly Readonly<{
|
|
7017
7017
|
id: string;
|
|
7018
|
-
role: "
|
|
7018
|
+
role: "assistant" | "system" | "tool" | "user";
|
|
7019
7019
|
content: string;
|
|
7020
7020
|
} & {
|
|
7021
7021
|
calls?: readonly Readonly<{
|
|
@@ -7230,7 +7230,7 @@ export declare function raceSignal<T>(promise: Promise<T>, signal: AbortSignal |
|
|
|
7230
7230
|
* rankLedgerCut(2, false, 'rule') // 3
|
|
7231
7231
|
* ```
|
|
7232
7232
|
*/
|
|
7233
|
-
export declare function rankLedgerCut(group:
|
|
7233
|
+
export declare function rankLedgerCut(group: LedgerPlanGroup, unsettled: boolean, category: LedgerCategory | undefined): number;
|
|
7234
7234
|
|
|
7235
7235
|
/**
|
|
7236
7236
|
* Decodes UTF-8 chunks with a final flush and releases the stream on every exit.
|
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;
|
|
@@ -4616,7 +4616,7 @@ export declare interface GaugeInterface extends LedgerGauge {
|
|
|
4616
4616
|
* `'CAPACITY'` otherwise. `replay` names the thinking the next request carries. Default: `'none'`.
|
|
4617
4617
|
* Measured use is `prompt + completion - (thinking ?? 0)` for `'none'`, and `prompt + completion`
|
|
4618
4618
|
* otherwise; absent completion counts as 0. Without prompt usage, use is `overhead + scale * estimate`.
|
|
4619
|
-
* 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
|
|
4620
4620
|
* rate to the largest observed reply's `completion - (thinking ?? 0)` for every policy.
|
|
4621
4621
|
* Without a positive reply observation, it prices the longest reply text at that rate. Recall room is
|
|
4622
4622
|
* `max(0, (remainder - predict - reserve) / 2 / rate)`; recall closes at `remainder - predict < 2 * reserve`.
|
|
@@ -5008,7 +5008,7 @@ export declare function intersectKeys(parent: readonly string[] | undefined, chi
|
|
|
5008
5008
|
export declare const INVALID_RELAY_STATUS = 400;
|
|
5009
5009
|
|
|
5010
5010
|
/**
|
|
5011
|
-
* 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`
|
|
5012
5012
|
* can branch on its `code`.
|
|
5013
5013
|
*
|
|
5014
5014
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5026,7 +5026,7 @@ export declare const INVALID_RELAY_STATUS = 400;
|
|
|
5026
5026
|
export declare function isAgentError(value: unknown): value is AgentError;
|
|
5027
5027
|
|
|
5028
5028
|
/**
|
|
5029
|
-
* 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
|
|
5030
5030
|
* `catch` can recover its `partial` result.
|
|
5031
5031
|
*
|
|
5032
5032
|
* @param value - The value to test (typically a `catch` binding or a rejected enqueue)
|
|
@@ -5044,7 +5044,7 @@ export declare function isAgentError(value: unknown): value is AgentError;
|
|
|
5044
5044
|
export declare function isAgentJobError(value: unknown): value is AgentJobError;
|
|
5045
5045
|
|
|
5046
5046
|
/**
|
|
5047
|
-
* 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
|
|
5048
5048
|
* `catch` can branch on its `code`.
|
|
5049
5049
|
*
|
|
5050
5050
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5106,7 +5106,7 @@ export declare function isConversationSnapshot(value: unknown): value is Convers
|
|
|
5106
5106
|
export declare function isFraction(value: unknown): value is number;
|
|
5107
5107
|
|
|
5108
5108
|
/**
|
|
5109
|
-
* 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
|
|
5110
5110
|
* recover its `partial` result.
|
|
5111
5111
|
*
|
|
5112
5112
|
* @param value - The caught value
|
|
@@ -5138,7 +5138,7 @@ export declare function isJudgeAbortError(value: unknown): value is JudgeAbortEr
|
|
|
5138
5138
|
export declare function isJudgeEntry(value: unknown): value is JudgeEntry;
|
|
5139
5139
|
|
|
5140
5140
|
/**
|
|
5141
|
-
* 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.
|
|
5142
5142
|
*
|
|
5143
5143
|
* @param value - The caught value
|
|
5144
5144
|
* @returns True if the value is a {@link JudgeError}; false otherwise
|
|
@@ -5191,7 +5191,7 @@ export declare function isJudgeQuestion(value: unknown): value is JudgeQuestion;
|
|
|
5191
5191
|
export declare function isJudgment(value: unknown): value is Judgment;
|
|
5192
5192
|
|
|
5193
5193
|
/**
|
|
5194
|
-
* 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
|
|
5195
5195
|
* branch on its `code`.
|
|
5196
5196
|
*
|
|
5197
5197
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5258,7 +5258,7 @@ export declare function isNonNegativeSafeInteger(value: unknown): value is numbe
|
|
|
5258
5258
|
export declare function isPositiveSafeInteger(value: unknown): value is number;
|
|
5259
5259
|
|
|
5260
5260
|
/**
|
|
5261
|
-
* 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
|
|
5262
5262
|
* `catch` can recover its `partial` result.
|
|
5263
5263
|
*
|
|
5264
5264
|
* @param value - The value to test (typically a `catch` binding)
|
|
@@ -5276,7 +5276,7 @@ export declare function isPositiveSafeInteger(value: unknown): value is number;
|
|
|
5276
5276
|
export declare function isProviderAbortError(value: unknown): value is ProviderAbortError;
|
|
5277
5277
|
|
|
5278
5278
|
/**
|
|
5279
|
-
* 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.
|
|
5280
5280
|
*
|
|
5281
5281
|
* @param value - The caught value
|
|
5282
5282
|
* @returns True if the value is a provider failure; false otherwise
|
|
@@ -5388,7 +5388,7 @@ export declare function joinThinking(running: string | undefined, next: string):
|
|
|
5388
5388
|
*/
|
|
5389
5389
|
export declare class JudgeAbortError extends Error {
|
|
5390
5390
|
/** Names the machine-readable condition — `'ABORT'`: a judge call cancelled mid-flight. */
|
|
5391
|
-
readonly code:
|
|
5391
|
+
readonly code: 'ABORT';
|
|
5392
5392
|
readonly partial: JudgeResult;
|
|
5393
5393
|
constructor(partial: JudgeResult, options?: ErrorOptions);
|
|
5394
5394
|
}
|
|
@@ -5970,7 +5970,7 @@ export declare interface LedgerOwner {
|
|
|
5970
5970
|
}
|
|
5971
5971
|
|
|
5972
5972
|
/** Names a briefing source's planning group: a topic match, an off-topic rule or correction, or a name match. */
|
|
5973
|
-
export declare type
|
|
5973
|
+
export declare type LedgerPlanGroup = 1 | 2 | 3;
|
|
5974
5974
|
|
|
5975
5975
|
/**
|
|
5976
5976
|
* Carries the records projected from a conversation, accepted amendments, and the live messages no
|
|
@@ -6457,7 +6457,7 @@ export declare const MAX_ERROR_BODY_LENGTH = 2048;
|
|
|
6457
6457
|
* @remarks
|
|
6458
6458
|
* The result is a structural estimate, not a tokenizer allocation. `id` and `role` are joins back to
|
|
6459
6459
|
* the message, not token components, and a provider's template effects and the estimation error are
|
|
6460
|
-
* not individually attributed. `content` is `ceil(length / 4)`, `
|
|
6460
|
+
* not individually attributed. `content` is `ceil(length / 4)`, `uniform` is
|
|
6461
6461
|
* {@link import('./constants.js').MESSAGE_TOKEN_OVERHEAD}, `calls` is the estimate of the JSON-rendered
|
|
6462
6462
|
* calls (`0` when the message carries none, the framing overhead when they cannot be rendered),
|
|
6463
6463
|
* `thinking` is the estimate of the thinking (`0` when absent), and `images` is the attached image
|
|
@@ -6469,7 +6469,7 @@ export declare const MAX_ERROR_BODY_LENGTH = 2048;
|
|
|
6469
6469
|
* @example
|
|
6470
6470
|
* ```ts
|
|
6471
6471
|
* measureMessage({ id: '1', role: 'user', content: 'hello' })
|
|
6472
|
-
* // { id: '1', role: 'user', content: 2,
|
|
6472
|
+
* // { id: '1', role: 'user', content: 2, uniform: 4, calls: 0, thinking: 0, images: 0 }
|
|
6473
6473
|
* ```
|
|
6474
6474
|
*/
|
|
6475
6475
|
export declare function measureMessage(message: Message): MessageMeasure;
|
|
@@ -6493,7 +6493,7 @@ export declare function measureMessage(message: Message): MessageMeasure;
|
|
|
6493
6493
|
* @example
|
|
6494
6494
|
* ```ts
|
|
6495
6495
|
* measureRequest({ messages: [{ id: '1', role: 'user', content: 'hello' }] })
|
|
6496
|
-
* // { 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 }
|
|
6497
6497
|
* ```
|
|
6498
6498
|
*/
|
|
6499
6499
|
export declare function measureRequest(request: ProviderRequest): RequestMeasure;
|
|
@@ -6620,7 +6620,7 @@ export declare const MESSAGE_TOKEN_OVERHEAD = 4;
|
|
|
6620
6620
|
/** Validates and projects conversation messages at a JSON wire boundary. */
|
|
6621
6621
|
export declare const messageContract: ContractInterface<Readonly<{
|
|
6622
6622
|
id: string;
|
|
6623
|
-
role: "
|
|
6623
|
+
role: "assistant" | "system" | "tool" | "user";
|
|
6624
6624
|
content: string;
|
|
6625
6625
|
} & {
|
|
6626
6626
|
calls?: readonly Readonly<{
|
|
@@ -6718,7 +6718,7 @@ export declare interface MessageManagerInterface {
|
|
|
6718
6718
|
*
|
|
6719
6719
|
* @remarks
|
|
6720
6720
|
* The structural estimate is not a tokenizer allocation. `id` and `role` are joins back to the
|
|
6721
|
-
* 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`,
|
|
6722
6722
|
* `thinking`, and `images`; no total is stored. A provider's template effects and the estimation
|
|
6723
6723
|
* error are not individually attributed.
|
|
6724
6724
|
*/
|
|
@@ -6727,9 +6727,9 @@ export declare interface MessageMeasure {
|
|
|
6727
6727
|
readonly role: MessageRole;
|
|
6728
6728
|
/** Holds the `ceil(length / 4)` estimate of the message `content`. */
|
|
6729
6729
|
readonly content: number;
|
|
6730
|
-
/** Holds the fixed per-message
|
|
6731
|
-
readonly
|
|
6732
|
-
/** 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. */
|
|
6733
6733
|
readonly calls: number;
|
|
6734
6734
|
/** Holds the estimate of the message `thinking`; `0` when absent. */
|
|
6735
6735
|
readonly thinking: number;
|
|
@@ -6854,7 +6854,7 @@ export declare function placeMember(input: LedgerProjectionInput, links: Readonl
|
|
|
6854
6854
|
*/
|
|
6855
6855
|
export declare class ProviderAbortError extends Error {
|
|
6856
6856
|
/** Names the machine-readable condition — `'ABORT'`: a stream cancelled mid-flight. */
|
|
6857
|
-
readonly code:
|
|
6857
|
+
readonly code: 'ABORT';
|
|
6858
6858
|
readonly partial: ProviderResult;
|
|
6859
6859
|
constructor(partial: ProviderResult, options?: ErrorOptions);
|
|
6860
6860
|
}
|
|
@@ -7015,7 +7015,7 @@ export declare interface ProviderRequest {
|
|
|
7015
7015
|
export declare const providerRequestContract: ContractInterface<Readonly<{
|
|
7016
7016
|
messages: readonly Readonly<{
|
|
7017
7017
|
id: string;
|
|
7018
|
-
role: "
|
|
7018
|
+
role: "assistant" | "system" | "tool" | "user";
|
|
7019
7019
|
content: string;
|
|
7020
7020
|
} & {
|
|
7021
7021
|
calls?: readonly Readonly<{
|
|
@@ -7230,7 +7230,7 @@ export declare function raceSignal<T>(promise: Promise<T>, signal: AbortSignal |
|
|
|
7230
7230
|
* rankLedgerCut(2, false, 'rule') // 3
|
|
7231
7231
|
* ```
|
|
7232
7232
|
*/
|
|
7233
|
-
export declare function rankLedgerCut(group:
|
|
7233
|
+
export declare function rankLedgerCut(group: LedgerPlanGroup, unsettled: boolean, category: LedgerCategory | undefined): number;
|
|
7234
7234
|
|
|
7235
7235
|
/**
|
|
7236
7236
|
* Decodes UTF-8 chunks with a final flush and releases the stream on every exit.
|