@unieai/rabi-session-reference 0.2.1-rc.3 → 0.2.2-rc.5
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/lib/index.js +12 -22
- package/lib/typert.host.js +37 -13
- package/lib/typert.remote-client.js +1 -1
- package/lib/types/index.d.ts +5 -4
- package/lib/types/index.js +12 -21
- package/locale/de.json +6 -0
- package/locale/es.json +6 -0
- package/locale/fr.json +6 -0
- package/locale/ja.json +6 -0
- package/locale/pt.json +6 -0
- package/locale/ru.json +6 -0
- package/package.json +23 -19
- package/src/config.ts +43 -0
- package/src/index.ts +483 -0
- package/src/projection.ts +180 -0
- package/src/serialization.ts +12 -0
- package/src/spill.ts +81 -0
- package/src/types.ts +88 -0
- package/src/uri.ts +103 -0
package/lib/index.js
CHANGED
|
@@ -437,7 +437,6 @@ let SessionReferenceResolver = (() => {
|
|
|
437
437
|
referenceContextFraction: z.number().min(0).max(1).default(DEFAULT_REFERENCE_CONTEXT_FRACTION)
|
|
438
438
|
});
|
|
439
439
|
config = __runInitializers(this, _instanceExtraInitializers);
|
|
440
|
-
assembledRoutes = /* @__PURE__ */ new WeakMap();
|
|
441
440
|
constructor(ctx, config = {}) {
|
|
442
441
|
super(ctx, "sessionReferenceResolver");
|
|
443
442
|
this.config = {
|
|
@@ -456,23 +455,12 @@ let SessionReferenceResolver = (() => {
|
|
|
456
455
|
}
|
|
457
456
|
if (this.config.maxReferences > 3) throw new SessionReferenceError(`session-reference: maxReferences must not exceed 3`, "SESSION_REFERENCE_INVALID_CONFIG");
|
|
458
457
|
if (!(this.config.referenceContextFraction >= 0 && this.config.referenceContextFraction <= 1)) throw new SessionReferenceError("session-reference: referenceContextFraction must be between zero and one", "SESSION_REFERENCE_INVALID_CONFIG");
|
|
459
|
-
ctx.on("
|
|
460
|
-
const assembly = await next();
|
|
461
|
-
if (context.agent !== void 0) {
|
|
462
|
-
const { provider, model } = assembly.variables;
|
|
463
|
-
this.assembledRoutes.set(context.agent, {
|
|
464
|
-
provider,
|
|
465
|
-
model
|
|
466
|
-
});
|
|
467
|
-
}
|
|
468
|
-
return assembly;
|
|
469
|
-
}, { prepend: true });
|
|
470
|
-
ctx.on("agent/pre-step", async ({ agent, signal }, next) => {
|
|
458
|
+
ctx.on("agent/pre-step", async ({ agent, signal, modelSelection }, next) => {
|
|
471
459
|
const decision = await next();
|
|
472
460
|
if (decision.kind === "reject") return decision;
|
|
473
461
|
return {
|
|
474
462
|
...decision,
|
|
475
|
-
messages: await this.prepareDirectMessages(agent, decision.messages, signal)
|
|
463
|
+
messages: await this.prepareDirectMessages(agent, decision.messages, modelSelection, signal)
|
|
476
464
|
};
|
|
477
465
|
}, { prepend: true });
|
|
478
466
|
}
|
|
@@ -481,10 +469,11 @@ let SessionReferenceResolver = (() => {
|
|
|
481
469
|
* snapshot immediately after the message that cited it.
|
|
482
470
|
* @param agent - agent entering the model step.
|
|
483
471
|
* @param messages - messages accepted by downstream pre-step listeners.
|
|
472
|
+
* @param route - provider and model fixed for the step.
|
|
484
473
|
* @param signal - active turn cancellation.
|
|
485
474
|
* @returns direct messages followed by their session-reference context in citation order.
|
|
486
475
|
*/
|
|
487
|
-
async prepareDirectMessages(agent, messages, signal) {
|
|
476
|
+
async prepareDirectMessages(agent, messages, route, signal) {
|
|
488
477
|
return (await Promise.all(messages.map(async (message) => {
|
|
489
478
|
if (message.source.kind !== "user") return [message];
|
|
490
479
|
const references = [];
|
|
@@ -498,7 +487,7 @@ let SessionReferenceResolver = (() => {
|
|
|
498
487
|
};
|
|
499
488
|
});
|
|
500
489
|
if (references.length === 0) return [message];
|
|
501
|
-
const resolved = await this.prepare(agent, content, references, signal);
|
|
490
|
+
const resolved = await this.prepare(agent, content, references, route, signal);
|
|
502
491
|
const direct = freezeMessage({
|
|
503
492
|
...message,
|
|
504
493
|
content: resolved.content
|
|
@@ -602,22 +591,23 @@ let SessionReferenceResolver = (() => {
|
|
|
602
591
|
}
|
|
603
592
|
/**
|
|
604
593
|
* Snapshot all references for one accepted direct message and return one aggregated durable context.
|
|
605
|
-
* Automatic budgets use the
|
|
594
|
+
* Automatic budgets use the context capacity of `route`.
|
|
606
595
|
* Missing model capacity or adapter uses 64 KiB; other metadata lookup failures and cancellation reject preparation.
|
|
607
596
|
* Truncated previews include omission facts and a full-snapshot spill locator, or an explicit unavailable notice.
|
|
608
597
|
* Cancellation prevents context publication, including when storage completes after cancellation.
|
|
609
598
|
* @param agent - target agent; references to it are rejected.
|
|
610
599
|
* @param content - already host-normalized readable message content.
|
|
611
600
|
* @param references - structured source sessions in mention order.
|
|
601
|
+
* @param route - provider and model whose context capacity sizes the previews.
|
|
612
602
|
* @param signal - optional cancellation boundary for the active turn.
|
|
613
603
|
* @returns detached content and optional referenced-session context.
|
|
614
604
|
*/
|
|
615
|
-
async prepare(agent, content, references, signal) {
|
|
605
|
+
async prepare(agent, content, references, route, signal) {
|
|
616
606
|
const acceptedContent = structuredClone(content);
|
|
617
607
|
const inputs = normalizeReferences(agent.id, references, this.config.maxReferences);
|
|
618
608
|
if (inputs.length === 0) return { content: acceptedContent };
|
|
619
609
|
assertNotCancelled(signal);
|
|
620
|
-
const maxReferenceBytes = await this.referenceBudget(
|
|
610
|
+
const maxReferenceBytes = await this.referenceBudget(route, signal);
|
|
621
611
|
assertNotCancelled(signal);
|
|
622
612
|
let prepared;
|
|
623
613
|
try {
|
|
@@ -658,11 +648,11 @@ let SessionReferenceResolver = (() => {
|
|
|
658
648
|
})
|
|
659
649
|
};
|
|
660
650
|
}
|
|
661
|
-
async referenceBudget(
|
|
651
|
+
async referenceBudget(route, signal) {
|
|
662
652
|
if (this.config.maxReferenceBytes !== void 0) return this.config.maxReferenceBytes;
|
|
663
|
-
const { provider, model } =
|
|
653
|
+
const { provider, model } = route;
|
|
664
654
|
const llm = this.ctx.get("llm");
|
|
665
|
-
if (
|
|
655
|
+
if (llm === void 0) return DEFAULT_MAX_REFERENCE_BYTES;
|
|
666
656
|
let info;
|
|
667
657
|
try {
|
|
668
658
|
info = await settleWithCancellation(llm.resolveModelInfo(provider, model, signal), signal);
|
package/lib/typert.host.js
CHANGED
|
@@ -80,7 +80,7 @@ const $remote = createTypertRemoteInfo({
|
|
|
80
80
|
description: 'mention-carrying candidates in rank order.',
|
|
81
81
|
jsonSchema: {"type":"array","items":{"type":"object","properties":{"mention":{"type":"string","description":"Canonical `@[label](rabi-session:…)` mention serialized into the prompt draft."},"sessionId":{"type":"string","description":"Opaque source session identity."},"label":{"type":"string","description":"Latest log-backed title, falling back to the opaque session id."},"displayTitle":{"type":"string","description":"Display and canonical-mention text, preferring a subagent's durable creation label over {@link label}."},"cwd":{"type":"string","description":"Source session working directory, when recorded."},"sameWorkspace":{"type":"boolean","description":"True when {@link SessionReferenceCandidate.cwd} is recorded and equals the requesting agent's. Hosts that only surface a distinguishing location read this instead of comparing paths they never received."},"createdAt":{"type":"number","description":"Source session creation time in Unix epoch milliseconds."}},"required":["mention","sessionId","label","sameWorkspace","createdAt"],"additionalProperties":true}},
|
|
82
82
|
},
|
|
83
|
-
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":
|
|
83
|
+
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":282,"column":9},
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
}, z)
|
|
@@ -118,9 +118,9 @@ export const TYPERT = {
|
|
|
118
118
|
{
|
|
119
119
|
"kind": "method",
|
|
120
120
|
"name": "prepare",
|
|
121
|
-
"signature": "async prepare( agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], signal?: AbortSignal, ): Promise<PreparedReferencedMessage>",
|
|
121
|
+
"signature": "async prepare( agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], route: Readonly<Pick<LlmCallConfig, 'provider' | 'model'>>, signal?: AbortSignal, ): Promise<PreparedReferencedMessage>",
|
|
122
122
|
"summary": "Snapshot all references for one accepted direct message and return one aggregated durable context.",
|
|
123
|
-
"jsDoc": "/**\n * Snapshot all references for one accepted direct message and return one aggregated durable context.\n * Automatic budgets use the
|
|
123
|
+
"jsDoc": "/**\n * Snapshot all references for one accepted direct message and return one aggregated durable context.\n * Automatic budgets use the context capacity of `route`.\n * Missing model capacity or adapter uses 64 KiB; other metadata lookup failures and cancellation reject preparation.\n * Truncated previews include omission facts and a full-snapshot spill locator, or an explicit unavailable notice.\n * Cancellation prevents context publication, including when storage completes after cancellation.\n * @param agent - target agent; references to it are rejected.\n * @param content - already host-normalized readable message content.\n * @param references - structured source sessions in mention order.\n * @param route - provider and model whose context capacity sizes the previews.\n * @param signal - optional cancellation boundary for the active turn.\n * @returns detached content and optional referenced-session context.\n */"
|
|
124
124
|
}
|
|
125
125
|
],
|
|
126
126
|
"types": [
|
|
@@ -130,7 +130,7 @@ export const TYPERT = {
|
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
"name": "Agent",
|
|
133
|
-
"declaration": "export interface Agent {\n readonly id: SessionId;\n readonly options: AgentOptions;\n readonly session: Session;\n readonly inbox: Inbox;\n readonly status: AgentStatus;\n readonly ctx: Context;\n cancel(cause: AgentCancelCause, options?: CancelOptions): void;\n whenIdle(): Promise<void>;\n runMaintenance<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>;\n send(message: UserMessage, target: InboxTarget, wakeup: boolean): void;\n followup(message: UserMessage): void;\n steer(message: UserMessage): void;\n inject(message: UserMessage): void;\n}"
|
|
133
|
+
"declaration": "export interface Agent {\n readonly id: SessionId;\n readonly options: AgentOptions;\n readonly session: Session;\n readonly model: Model;\n readonly inbox: Inbox;\n readonly status: AgentStatus;\n readonly ctx: Context;\n cancel(cause: AgentCancelCause, options?: CancelOptions): void;\n whenIdle(): Promise<void>;\n runMaintenance<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>;\n send(message: UserMessage, target: InboxTarget, wakeup: boolean): void;\n followup(message: UserMessage): void;\n steer(message: UserMessage): void;\n inject(message: UserMessage): void;\n}"
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
136
|
"name": "AgentCancelCause",
|
|
@@ -142,7 +142,7 @@ export const TYPERT = {
|
|
|
142
142
|
},
|
|
143
143
|
{
|
|
144
144
|
"name": "AgentOptions",
|
|
145
|
-
"declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n reasoningEffort?: ReasoningEffortId;\n maxTokens?: number;\n subagentDepth?: number;\n}"
|
|
145
|
+
"declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n reasoningEffort?: ReasoningEffortId | undefined;\n maxTokens?: number;\n subagentDepth?: number;\n}"
|
|
146
146
|
},
|
|
147
147
|
{
|
|
148
148
|
"name": "AgentStatus",
|
|
@@ -458,7 +458,11 @@ export const TYPERT = {
|
|
|
458
458
|
},
|
|
459
459
|
{
|
|
460
460
|
"name": "MessageSourceMap",
|
|
461
|
-
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'runtime-context': { kind: 'runtime-context'; } & ContextFormed;\n 'working-directory': { kind: 'working-directory'; };\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n '
|
|
461
|
+
"declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'tool-registry': { kind: 'tool-registry'; };\n 'action-cards': { kind: 'action-cards'; through: SessionSeq; } & ContextFormed;\n 'runtime-context': { kind: 'runtime-context'; } & ContextFormed;\n 'team-message': TeamMessageSource;\n 'working-directory': { kind: 'working-directory'; };\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; principal?: Principal; };\n 'retry-rpc': { kind: 'retry'; rpcId: SessionRequestId; clientTimeZone?: string; principal?: Principal; };\n 'skill-invocation': SkillInvocationSource;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'compact-checkpoint': CompactionCheckpointSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n 'user-question-reply': { kind: 'user-question-reply'; callId: ToolCallId; outcome: 'answered'; };\n goal: GoalMessageSource;\n 'plan-mode': { kind: 'plan-mode'; } & ContextFormed;\n schedule: { kind: 'schedule'; } & ContextFormed;\n 'session-reference': SessionReferenceSource;\n webhook: { readonly kind: 'webhook'; readonly provider: string; readonly source: WebhookSourceId; readonly deliveryId: WebhookDeliveryId; readonly ruleId: WebhookRuleId; readonly form: 'notice'; readonly summary: string; };\n}"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
"name": "Model",
|
|
465
|
+
"declaration": "export interface Model {\n current(): Readonly<ModelSelection> | undefined;\n select(selection: Readonly<ModelSelection>): void;\n}"
|
|
462
466
|
},
|
|
463
467
|
{
|
|
464
468
|
"name": "ModelMessageSource",
|
|
@@ -466,7 +470,7 @@ export const TYPERT = {
|
|
|
466
470
|
},
|
|
467
471
|
{
|
|
468
472
|
"name": "ModelSelection",
|
|
469
|
-
"declaration": "export interface ModelSelection {\n
|
|
473
|
+
"declaration": "export interface ModelSelection {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n}"
|
|
470
474
|
},
|
|
471
475
|
{
|
|
472
476
|
"name": "OneShotScheduleDispatchChange",
|
|
@@ -490,7 +494,7 @@ export const TYPERT = {
|
|
|
490
494
|
},
|
|
491
495
|
{
|
|
492
496
|
"name": "PrincipalMap",
|
|
493
|
-
"declaration": "export interface PrincipalMap {\n owner: { readonly kind: 'owner'; };\n}"
|
|
497
|
+
"declaration": "export interface PrincipalMap {\n owner: { readonly kind: 'owner'; };\n 'share-viewer': ShareViewerPrincipal;\n}"
|
|
494
498
|
},
|
|
495
499
|
{
|
|
496
500
|
"name": "ProviderRequestId",
|
|
@@ -554,15 +558,19 @@ export const TYPERT = {
|
|
|
554
558
|
},
|
|
555
559
|
{
|
|
556
560
|
"name": "Session",
|
|
557
|
-
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
561
|
+
"declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n get currentBatchPublication(): SessionEvent | undefined;\n append(inputs: readonly SessionEventInput[]): readonly SessionEvent[];\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
|
|
558
562
|
},
|
|
559
563
|
{
|
|
560
564
|
"name": "SessionEvent",
|
|
561
565
|
"declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq: SessionSeq; time: number; data: SessionEventMap[K]; ignorable?: true; } & (K extends SurfaceEventType ? SurfaceIntent<K> : { surfaceOp?: never; sourceEventSeqs?: never; }) }[T];"
|
|
562
566
|
},
|
|
567
|
+
{
|
|
568
|
+
"name": "SessionEventInput",
|
|
569
|
+
"declaration": "export type SessionEventInput = { [K in SessionEventType]: readonly [type: K, data: SessionEventMap[K], ...opts: K extends SurfaceEventType ? [opts: SurfaceIntent<K>] : []] }[SessionEventType];"
|
|
570
|
+
},
|
|
563
571
|
{
|
|
564
572
|
"name": "SessionEventMap",
|
|
565
|
-
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n '
|
|
573
|
+
"declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'model/selection': ModelSelection;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'agent-preset/selected': { agentPreset: string; };\n 'team/mode': { enabled: boolean; };\n 'team/member': { version: 2; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 2; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 2; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 2; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'working-directory/change': { cwd: string; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@unieai/rabi-session/types').SessionSeq; };\n 'permission/preset': { preset: string; };\n 'subagent/descriptor': SubagentDescriptorData;\n 'subagent/catalog': SubagentCatalogEvent;\n 'job/registered': JobRegisteredData;\n 'job/settled': JobSettledData;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'feedback/record': FeedbackRecord;\n 'llm/retry': LlmRetryEventData;\n 'llm/retry-started': LlmRetryStartedEventData;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'plan/mode': { active: boolean; };\n 'schedule/change': ScheduleChange;\n 'session-log-deepseek/delivery-accepted': { sessionId: import('@unieai/rabi-session/types').SessionId; sessionFormatVersion?: number; throughSeq: import('@unieai/rabi-session/types').SessionSeq; };\n 'subagent/model-selection-policy': { allowedModels: AllowedModelRoute[]; };\n 'workspace/changes': { turn: number; };\n}"
|
|
566
574
|
},
|
|
567
575
|
{
|
|
568
576
|
"name": "SessionEventType",
|
|
@@ -624,6 +632,10 @@ export const TYPERT = {
|
|
|
624
632
|
"name": "SessionTitleSource",
|
|
625
633
|
"declaration": "export type SessionTitleSource = { readonly kind: 'fallback'; } | { readonly kind: 'provider'; readonly provider: SessionTitleProviderId; readonly model?: SessionTitleModelIdentity; } | { readonly kind: 'user'; };"
|
|
626
634
|
},
|
|
635
|
+
{
|
|
636
|
+
"name": "ShareViewerPrincipal",
|
|
637
|
+
"declaration": "export interface ShareViewerPrincipal {\n readonly kind: 'share-viewer';\n readonly shareId: string;\n readonly actor: { readonly providerId: string; readonly tenantId: string; readonly subjectId: string; readonly displayName?: string; };\n}"
|
|
638
|
+
},
|
|
627
639
|
{
|
|
628
640
|
"name": "SkillInvocationSource",
|
|
629
641
|
"declaration": "export interface SkillInvocationSource {\n readonly kind: 'skill-invocation';\n readonly name: string;\n readonly form: 'instructions';\n}"
|
|
@@ -634,7 +646,7 @@ export const TYPERT = {
|
|
|
634
646
|
},
|
|
635
647
|
{
|
|
636
648
|
"name": "SubagentCatalogEvent",
|
|
637
|
-
"declaration": "export type SubagentCatalogEvent = { readonly childId: SessionId; readonly childCreatedAt: number; } & (({ readonly version: 0; } & KnownCatalogMode) | ({ readonly version: 1; } & (KnownCatalogMode | { readonly mode: 'unknown'; readonly label?: string; })) | { readonly version: 2; readonly mode: 'external'; readonly label?: string; });"
|
|
649
|
+
"declaration": "export type SubagentCatalogEvent = { readonly childId: SessionId; readonly childCreatedAt: number; } & (({ readonly version: 0; } & KnownCatalogMode) | ({ readonly version: 1; } & (KnownCatalogMode | { readonly mode: 'unknown'; readonly label?: string; })) | { readonly version: 2; readonly mode: 'external'; readonly label?: string; } | ({ readonly version: 3; readonly name: string; } & ({ readonly mode: 'continuable'; readonly label: string; } | { readonly mode: 'external'; readonly label?: string; })));"
|
|
638
650
|
},
|
|
639
651
|
{
|
|
640
652
|
"name": "SubagentDescriptorBase",
|
|
@@ -644,9 +656,21 @@ export const TYPERT = {
|
|
|
644
656
|
"name": "SubagentDescriptorData",
|
|
645
657
|
"declaration": "export type SubagentDescriptorData = OneShotSubagentDescriptorData | ContinuableSubagentDescriptorData;"
|
|
646
658
|
},
|
|
659
|
+
{
|
|
660
|
+
"name": "SubagentResult",
|
|
661
|
+
"declaration": "export interface SubagentResult {\n readonly output: readonly ContentBlock[];\n readonly structured?: unknown;\n readonly diagnostic?: string;\n readonly stopReason: SubagentStopReason;\n}"
|
|
662
|
+
},
|
|
647
663
|
{
|
|
648
664
|
"name": "SubagentSettledMessageSource",
|
|
649
|
-
"declaration": "export interface SubagentSettledMessageSource {\n readonly kind: 'subagent-settled';\n readonly form: 'notice';\n readonly summary: string;\n readonly senderSessionId: SessionId;\n}"
|
|
665
|
+
"declaration": "export interface SubagentSettledMessageSource {\n readonly kind: 'subagent-settled';\n readonly form: 'notice';\n readonly summary: string;\n readonly stopReason?: SubagentResult['stopReason'];\n readonly senderSessionId: SessionId;\n}"
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
"name": "SubagentStopReason",
|
|
669
|
+
"declaration": "export type SubagentStopReason = SubagentStopReasonMap[keyof SubagentStopReasonMap];"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
"name": "SubagentStopReasonMap",
|
|
673
|
+
"declaration": "export interface SubagentStopReasonMap {\n completed: 'completed';\n aborted: 'aborted';\n error: 'error';\n 'max-tokens': 'max-tokens';\n refusal: 'refusal';\n}"
|
|
650
674
|
},
|
|
651
675
|
{
|
|
652
676
|
"name": "SurfaceEventType",
|
|
@@ -702,7 +726,7 @@ export const TYPERT = {
|
|
|
702
726
|
},
|
|
703
727
|
{
|
|
704
728
|
"name": "TeamTaskSnapshot",
|
|
705
|
-
"declaration": "export interface TeamTaskSnapshot {\n readonly id: TeamTaskId;\n readonly revision: number;\n readonly subject: string;\n readonly description: string;\n readonly status: TeamTaskStatus;\n readonly ownerId?: SessionId;\n readonly blockedBy: TeamTaskId[];\n readonly writeScopes: string[];\n}"
|
|
729
|
+
"declaration": "export interface TeamTaskSnapshot {\n readonly id: TeamTaskId;\n readonly revision: number;\n readonly subject: string;\n readonly description: string;\n readonly status: TeamTaskStatus;\n readonly ownerId?: SessionId;\n readonly ownerName?: string;\n readonly blockedBy: TeamTaskId[];\n readonly writeScopes: string[];\n}"
|
|
706
730
|
},
|
|
707
731
|
{
|
|
708
732
|
"name": "TeamTaskStatus",
|
|
@@ -80,7 +80,7 @@ export const TYPERT_REMOTE = createTypertRemoteInfo({
|
|
|
80
80
|
description: 'mention-carrying candidates in rank order.',
|
|
81
81
|
jsonSchema: {"type":"array","items":{"type":"object","properties":{"mention":{"type":"string","description":"Canonical `@[label](rabi-session:…)` mention serialized into the prompt draft."},"sessionId":{"type":"string","description":"Opaque source session identity."},"label":{"type":"string","description":"Latest log-backed title, falling back to the opaque session id."},"displayTitle":{"type":"string","description":"Display and canonical-mention text, preferring a subagent's durable creation label over {@link label}."},"cwd":{"type":"string","description":"Source session working directory, when recorded."},"sameWorkspace":{"type":"boolean","description":"True when {@link SessionReferenceCandidate.cwd} is recorded and equals the requesting agent's. Hosts that only surface a distinguishing location read this instead of comparing paths they never received."},"createdAt":{"type":"number","description":"Source session creation time in Unix epoch milliseconds."}},"required":["mention","sessionId","label","sameWorkspace","createdAt"],"additionalProperties":true}},
|
|
82
82
|
},
|
|
83
|
-
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":
|
|
83
|
+
sourceLocation: {"file":"packages/context/session-reference/src/index.ts","line":282,"column":9},
|
|
84
84
|
},
|
|
85
85
|
},
|
|
86
86
|
}, z)
|
package/lib/types/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { Context } from '@unieai/cordis';
|
|
|
8
8
|
import z from '@unieai/schemastery';
|
|
9
9
|
import type { Agent } from '@unieai/rabi-agent';
|
|
10
10
|
import { TypertRemoteService } from '@unieai/rabi-typert-protocol';
|
|
11
|
-
import type { ContentBlock } from '@unieai/rabi-llm';
|
|
11
|
+
import type { ContentBlock, LlmCallConfig } from '@unieai/rabi-llm';
|
|
12
12
|
import { type Config } from './config.ts';
|
|
13
13
|
import type { PreparedReferencedMessage, SessionReferenceCandidate, SessionReferenceInput, SessionReferenceMentionCandidate } from './types.ts';
|
|
14
14
|
export type * from './types.ts';
|
|
@@ -25,13 +25,13 @@ export declare class SessionReferenceResolver extends TypertRemoteService {
|
|
|
25
25
|
static inject: string[];
|
|
26
26
|
static Config: z<Config>;
|
|
27
27
|
private readonly config;
|
|
28
|
-
private readonly assembledRoutes;
|
|
29
28
|
constructor(ctx: Context, config?: Config);
|
|
30
29
|
/**
|
|
31
30
|
* Replace canonical mentions in direct user messages and place each prepared
|
|
32
31
|
* snapshot immediately after the message that cited it.
|
|
33
32
|
* @param agent - agent entering the model step.
|
|
34
33
|
* @param messages - messages accepted by downstream pre-step listeners.
|
|
34
|
+
* @param route - provider and model fixed for the step.
|
|
35
35
|
* @param signal - active turn cancellation.
|
|
36
36
|
* @returns direct messages followed by their session-reference context in citation order.
|
|
37
37
|
*/
|
|
@@ -85,17 +85,18 @@ export declare class SessionReferenceResolver extends TypertRemoteService {
|
|
|
85
85
|
remoteExportCandidates(agent: Agent, query: string, signal: AbortSignal): Promise<SessionReferenceMentionCandidate[]>;
|
|
86
86
|
/**
|
|
87
87
|
* Snapshot all references for one accepted direct message and return one aggregated durable context.
|
|
88
|
-
* Automatic budgets use the
|
|
88
|
+
* Automatic budgets use the context capacity of `route`.
|
|
89
89
|
* Missing model capacity or adapter uses 64 KiB; other metadata lookup failures and cancellation reject preparation.
|
|
90
90
|
* Truncated previews include omission facts and a full-snapshot spill locator, or an explicit unavailable notice.
|
|
91
91
|
* Cancellation prevents context publication, including when storage completes after cancellation.
|
|
92
92
|
* @param agent - target agent; references to it are rejected.
|
|
93
93
|
* @param content - already host-normalized readable message content.
|
|
94
94
|
* @param references - structured source sessions in mention order.
|
|
95
|
+
* @param route - provider and model whose context capacity sizes the previews.
|
|
95
96
|
* @param signal - optional cancellation boundary for the active turn.
|
|
96
97
|
* @returns detached content and optional referenced-session context.
|
|
97
98
|
*/
|
|
98
|
-
prepare(agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], signal?: AbortSignal): Promise<PreparedReferencedMessage>;
|
|
99
|
+
prepare(agent: Agent, content: ContentBlock[], references: SessionReferenceInput[], route: Readonly<Pick<LlmCallConfig, 'provider' | 'model'>>, signal?: AbortSignal): Promise<PreparedReferencedMessage>;
|
|
99
100
|
private referenceBudget;
|
|
100
101
|
private renderSources;
|
|
101
102
|
}
|
package/lib/types/index.js
CHANGED
|
@@ -79,7 +79,6 @@ let SessionReferenceResolver = (() => {
|
|
|
79
79
|
referenceContextFraction: z.number().min(0).max(1).default(DEFAULT_REFERENCE_CONTEXT_FRACTION),
|
|
80
80
|
});
|
|
81
81
|
config = __runInitializers(this, _instanceExtraInitializers);
|
|
82
|
-
assembledRoutes = new WeakMap();
|
|
83
82
|
constructor(ctx, config = {}) {
|
|
84
83
|
super(ctx, 'sessionReferenceResolver');
|
|
85
84
|
this.config = {
|
|
@@ -100,22 +99,13 @@ let SessionReferenceResolver = (() => {
|
|
|
100
99
|
if (!(this.config.referenceContextFraction >= 0 && this.config.referenceContextFraction <= 1)) {
|
|
101
100
|
throw new SessionReferenceError('session-reference: referenceContextFraction must be between zero and one', 'SESSION_REFERENCE_INVALID_CONFIG');
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
ctx.on('system-prompt/assemble', async (_assembly, context, next) => {
|
|
105
|
-
const assembly = await next();
|
|
106
|
-
if (context.agent !== undefined) {
|
|
107
|
-
const { provider, model } = assembly.variables;
|
|
108
|
-
this.assembledRoutes.set(context.agent, { provider, model });
|
|
109
|
-
}
|
|
110
|
-
return assembly;
|
|
111
|
-
}, { prepend: true });
|
|
112
|
-
ctx.on('agent/pre-step', async ({ agent, signal }, next) => {
|
|
102
|
+
ctx.on('agent/pre-step', async ({ agent, signal, modelSelection }, next) => {
|
|
113
103
|
const decision = await next();
|
|
114
104
|
if (decision.kind === 'reject')
|
|
115
105
|
return decision;
|
|
116
106
|
return {
|
|
117
107
|
...decision,
|
|
118
|
-
messages: await this.prepareDirectMessages(agent, decision.messages, signal),
|
|
108
|
+
messages: await this.prepareDirectMessages(agent, decision.messages, modelSelection, signal),
|
|
119
109
|
};
|
|
120
110
|
}, { prepend: true });
|
|
121
111
|
}
|
|
@@ -124,10 +114,11 @@ let SessionReferenceResolver = (() => {
|
|
|
124
114
|
* snapshot immediately after the message that cited it.
|
|
125
115
|
* @param agent - agent entering the model step.
|
|
126
116
|
* @param messages - messages accepted by downstream pre-step listeners.
|
|
117
|
+
* @param route - provider and model fixed for the step.
|
|
127
118
|
* @param signal - active turn cancellation.
|
|
128
119
|
* @returns direct messages followed by their session-reference context in citation order.
|
|
129
120
|
*/
|
|
130
|
-
async prepareDirectMessages(agent, messages, signal) {
|
|
121
|
+
async prepareDirectMessages(agent, messages, route, signal) {
|
|
131
122
|
const prepared = await Promise.all(messages.map(async (message) => {
|
|
132
123
|
if (message.source.kind !== 'user')
|
|
133
124
|
return [message];
|
|
@@ -141,7 +132,7 @@ let SessionReferenceResolver = (() => {
|
|
|
141
132
|
});
|
|
142
133
|
if (references.length === 0)
|
|
143
134
|
return [message];
|
|
144
|
-
const resolved = await this.prepare(agent, content, references, signal);
|
|
135
|
+
const resolved = await this.prepare(agent, content, references, route, signal);
|
|
145
136
|
const direct = freezeMessage({ ...message, content: resolved.content });
|
|
146
137
|
/* v8 ignore if -- a parsed canonical mention always leaves one normalized reference */
|
|
147
138
|
if (resolved.additionalContext === undefined) {
|
|
@@ -262,23 +253,24 @@ let SessionReferenceResolver = (() => {
|
|
|
262
253
|
}
|
|
263
254
|
/**
|
|
264
255
|
* Snapshot all references for one accepted direct message and return one aggregated durable context.
|
|
265
|
-
* Automatic budgets use the
|
|
256
|
+
* Automatic budgets use the context capacity of `route`.
|
|
266
257
|
* Missing model capacity or adapter uses 64 KiB; other metadata lookup failures and cancellation reject preparation.
|
|
267
258
|
* Truncated previews include omission facts and a full-snapshot spill locator, or an explicit unavailable notice.
|
|
268
259
|
* Cancellation prevents context publication, including when storage completes after cancellation.
|
|
269
260
|
* @param agent - target agent; references to it are rejected.
|
|
270
261
|
* @param content - already host-normalized readable message content.
|
|
271
262
|
* @param references - structured source sessions in mention order.
|
|
263
|
+
* @param route - provider and model whose context capacity sizes the previews.
|
|
272
264
|
* @param signal - optional cancellation boundary for the active turn.
|
|
273
265
|
* @returns detached content and optional referenced-session context.
|
|
274
266
|
*/
|
|
275
|
-
async prepare(agent, content, references, signal) {
|
|
267
|
+
async prepare(agent, content, references, route, signal) {
|
|
276
268
|
const acceptedContent = structuredClone(content);
|
|
277
269
|
const inputs = normalizeReferences(agent.id, references, this.config.maxReferences);
|
|
278
270
|
if (inputs.length === 0)
|
|
279
271
|
return { content: acceptedContent };
|
|
280
272
|
assertNotCancelled(signal);
|
|
281
|
-
const maxReferenceBytes = await this.referenceBudget(
|
|
273
|
+
const maxReferenceBytes = await this.referenceBudget(route, signal);
|
|
282
274
|
assertNotCancelled(signal);
|
|
283
275
|
let prepared;
|
|
284
276
|
try {
|
|
@@ -320,13 +312,12 @@ let SessionReferenceResolver = (() => {
|
|
|
320
312
|
});
|
|
321
313
|
return { content: acceptedContent, additionalContext };
|
|
322
314
|
}
|
|
323
|
-
async referenceBudget(
|
|
315
|
+
async referenceBudget(route, signal) {
|
|
324
316
|
if (this.config.maxReferenceBytes !== undefined)
|
|
325
317
|
return this.config.maxReferenceBytes;
|
|
326
|
-
|
|
327
|
-
const { provider, model } = this.assembledRoutes.get(agent) ?? agent.options;
|
|
318
|
+
const { provider, model } = route;
|
|
328
319
|
const llm = this.ctx.get('llm');
|
|
329
|
-
if (
|
|
320
|
+
if (llm === undefined)
|
|
330
321
|
return DEFAULT_MAX_REFERENCE_BYTES;
|
|
331
322
|
let info;
|
|
332
323
|
try {
|
package/locale/de.json
ADDED
package/locale/es.json
ADDED
package/locale/fr.json
ADDED
package/locale/ja.json
ADDED
package/locale/pt.json
ADDED
package/locale/ru.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unieai/rabi-session-reference",
|
|
3
3
|
"description": "Cross-session snapshot references and durable untrusted model context (ctx.sessionReferenceResolver)",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2-rc.5",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -34,34 +34,38 @@
|
|
|
34
34
|
"lib/index.js",
|
|
35
35
|
"lib/types/**/*.js",
|
|
36
36
|
"lib/types/**/*.d.ts",
|
|
37
|
+
"lib/types/**/*.d.ts.map",
|
|
38
|
+
"lib/**/*.js.map",
|
|
37
39
|
"lib/typert.host.js",
|
|
38
40
|
"lib/typert.host.d.ts",
|
|
39
41
|
"lib/typert.remote-client.js",
|
|
40
42
|
"lib/typert.remote-client.d.ts",
|
|
43
|
+
"lib/typert.remote-client.d.ts.map",
|
|
44
|
+
"src",
|
|
41
45
|
"README.md"
|
|
42
46
|
],
|
|
43
47
|
"license": "MIT",
|
|
44
48
|
"dependencies": {
|
|
45
|
-
"@unieai/rabi-brand": "0.2.
|
|
46
|
-
"@unieai/rabi-util-values": "0.2.
|
|
47
|
-
"@unieai/schemastery": "3.
|
|
48
|
-
"zod": "4.
|
|
49
|
+
"@unieai/rabi-brand": "0.2.2-rc.5",
|
|
50
|
+
"@unieai/rabi-util-values": "0.2.2-rc.5",
|
|
51
|
+
"@unieai/schemastery": "3.19.0",
|
|
52
|
+
"zod": "4.6.6"
|
|
49
53
|
},
|
|
50
54
|
"peerDependencies": {
|
|
51
|
-
"@unieai/cordis": "4.0
|
|
52
|
-
"@unieai/rabi-agent": "0.2.
|
|
53
|
-
"@unieai/rabi-compaction": "0.2.
|
|
54
|
-
"@unieai/rabi-llm": "0.2.
|
|
55
|
-
"@unieai/rabi-output-retention": "0.2.
|
|
56
|
-
"@unieai/rabi-session": "0.2.
|
|
57
|
-
"@unieai/rabi-session-projection": "0.2.
|
|
58
|
-
"@unieai/rabi-session-projection-cache": "0.2.
|
|
59
|
-
"@unieai/rabi-session-query": "0.2.
|
|
60
|
-
"@unieai/rabi-session-title": "0.2.
|
|
61
|
-
"@unieai/rabi-spill": "0.2.
|
|
62
|
-
"@unieai/rabi-subagent": "0.2.
|
|
63
|
-
"@unieai/rabi-system-prompt": "0.2.
|
|
64
|
-
"@unieai/rabi-typert-protocol": "0.2.
|
|
55
|
+
"@unieai/cordis": "4.1.0",
|
|
56
|
+
"@unieai/rabi-agent": "0.2.2-rc.5",
|
|
57
|
+
"@unieai/rabi-compaction": "0.2.2-rc.5",
|
|
58
|
+
"@unieai/rabi-llm": "0.2.2-rc.5",
|
|
59
|
+
"@unieai/rabi-output-retention": "0.2.2-rc.5",
|
|
60
|
+
"@unieai/rabi-session": "0.2.2-rc.5",
|
|
61
|
+
"@unieai/rabi-session-projection": "0.2.2-rc.5",
|
|
62
|
+
"@unieai/rabi-session-projection-cache": "0.2.2-rc.5",
|
|
63
|
+
"@unieai/rabi-session-query": "0.2.2-rc.5",
|
|
64
|
+
"@unieai/rabi-session-title": "0.2.2-rc.5",
|
|
65
|
+
"@unieai/rabi-spill": "0.2.2-rc.5",
|
|
66
|
+
"@unieai/rabi-subagent": "0.2.2-rc.5",
|
|
67
|
+
"@unieai/rabi-system-prompt": "0.2.2-rc.5",
|
|
68
|
+
"@unieai/rabi-typert-protocol": "0.2.2-rc.5"
|
|
65
69
|
},
|
|
66
70
|
"peerDependenciesMeta": {
|
|
67
71
|
"@unieai/rabi-spill": {
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Configuration and stable diagnostics for session references. */
|
|
2
|
+
|
|
3
|
+
/** Hard maximum references accepted by one message. */
|
|
4
|
+
export const MAX_REFERENCES = 3
|
|
5
|
+
/** Default number of discovery candidates returned to a host. */
|
|
6
|
+
export const DEFAULT_CANDIDATE_LIMIT = 50
|
|
7
|
+
/** Minimum automatic UTF-8 budget for one rendered reference JSON object. */
|
|
8
|
+
export const DEFAULT_MAX_REFERENCE_BYTES = 65_536
|
|
9
|
+
|
|
10
|
+
/** Session-reference service configuration. */
|
|
11
|
+
export interface Config {
|
|
12
|
+
/** Maximum distinct source sessions referenced by one message, from one to three. */
|
|
13
|
+
maxReferences?: number
|
|
14
|
+
/** Default host candidate-list limit. */
|
|
15
|
+
candidateLimit?: number
|
|
16
|
+
/** Explicit maximum rendered UTF-8 bytes per source; absent uses the model-relative budget with a 64 KiB floor. */
|
|
17
|
+
maxReferenceBytes?: number
|
|
18
|
+
/** Fraction of the model context window per source, estimated at four bytes per token; between zero and one. */
|
|
19
|
+
referenceContextFraction?: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Stable failure codes exposed to host adapters. */
|
|
23
|
+
export type SessionReferenceErrorCode =
|
|
24
|
+
| 'SESSION_REFERENCE_INVALID_CONFIG'
|
|
25
|
+
| 'SESSION_REFERENCE_INVALID_REFERENCE'
|
|
26
|
+
| 'SESSION_REFERENCE_SELF_REFERENCE'
|
|
27
|
+
| 'SESSION_REFERENCE_TOO_MANY'
|
|
28
|
+
| 'SESSION_REFERENCE_READ_FAILED'
|
|
29
|
+
| 'SESSION_REFERENCE_BUDGET_EXCEEDED'
|
|
30
|
+
| 'SESSION_REFERENCE_CANCELLED'
|
|
31
|
+
|
|
32
|
+
/** Typed session-reference failure suitable for host protocol error mapping. */
|
|
33
|
+
export class SessionReferenceError extends Error {
|
|
34
|
+
/** @param message Human-readable diagnosis. @param code Stable routing code. @param options Optional cause. */
|
|
35
|
+
constructor(
|
|
36
|
+
message: string,
|
|
37
|
+
readonly code: SessionReferenceErrorCode,
|
|
38
|
+
options?: ErrorOptions,
|
|
39
|
+
) {
|
|
40
|
+
super(message, options)
|
|
41
|
+
this.name = 'SessionReferenceError'
|
|
42
|
+
}
|
|
43
|
+
}
|