@slopus/happy-providers 0.0.0 → 0.0.4
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/EXAMPLES.md +39 -73
- package/README.md +165 -88
- package/dist/core/BaseSession.d.ts +1 -1
- package/dist/core/BaseSession.d.ts.map +1 -1
- package/dist/core/EmptyResponseError.d.ts +3 -3
- package/dist/core/EmptyResponseError.d.ts.map +1 -1
- package/dist/core/EmptyResponseError.js.map +1 -1
- package/dist/core/SessionAssistantMessageAccumulator.d.ts +17 -0
- package/dist/core/SessionAssistantMessageAccumulator.d.ts.map +1 -0
- package/dist/core/SessionAssistantMessageAccumulator.js +154 -0
- package/dist/core/SessionAssistantMessageAccumulator.js.map +1 -0
- package/dist/core/SessionCompaction.d.ts +4 -10
- package/dist/core/SessionCompaction.d.ts.map +1 -1
- package/dist/core/SessionContext.d.ts +35 -33
- package/dist/core/SessionContext.d.ts.map +1 -1
- package/dist/core/SessionEvent.d.ts +23 -8
- package/dist/core/SessionEvent.d.ts.map +1 -1
- package/dist/core/SessionEvent.js.map +1 -1
- package/dist/core/SessionRunRequest.d.ts +2 -4
- package/dist/core/SessionRunRequest.d.ts.map +1 -1
- package/dist/core/SessionTool.d.ts +1 -3
- package/dist/core/SessionTool.d.ts.map +1 -1
- package/dist/core/SessionUsage.d.ts +14 -0
- package/dist/core/SessionUsage.d.ts.map +1 -0
- package/dist/core/{SessionCacheUsage.js → SessionUsage.js} +2 -2
- package/dist/core/SessionUsage.js.map +1 -0
- package/dist/core/addSessionUsage.d.ts +3 -0
- package/dist/core/addSessionUsage.d.ts.map +1 -0
- package/dist/core/{addSessionCacheUsage.js → addSessionUsage.js} +3 -3
- package/dist/core/addSessionUsage.js.map +1 -0
- package/dist/core/emitToolCallResult.d.ts +1 -0
- package/dist/core/emitToolCallResult.d.ts.map +1 -1
- package/dist/core/emitToolCallResult.js +6 -2
- package/dist/core/emitToolCallResult.js.map +1 -1
- package/dist/core/toSessionReminderMessage.d.ts.map +1 -1
- package/dist/core/toSessionReminderMessage.js +6 -2
- package/dist/core/toSessionReminderMessage.js.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/protocol/anthropic/collectAnthropicCompaction.d.ts +2 -2
- package/dist/protocol/anthropic/collectAnthropicCompaction.d.ts.map +1 -1
- package/dist/protocol/anthropic/collectAnthropicCompaction.js +14 -9
- package/dist/protocol/anthropic/collectAnthropicCompaction.js.map +1 -1
- package/dist/protocol/anthropic/mapAnthropicStream.d.ts.map +1 -1
- package/dist/protocol/anthropic/mapAnthropicStream.js +52 -30
- package/dist/protocol/anthropic/mapAnthropicStream.js.map +1 -1
- package/dist/protocol/anthropic/toAnthropicMessages.d.ts +1 -2
- package/dist/protocol/anthropic/toAnthropicMessages.d.ts.map +1 -1
- package/dist/protocol/anthropic/toAnthropicMessages.js +46 -108
- package/dist/protocol/anthropic/toAnthropicMessages.js.map +1 -1
- package/dist/protocol/responses/ResponsesSession.d.ts +1 -1
- package/dist/protocol/responses/ResponsesSession.d.ts.map +1 -1
- package/dist/protocol/responses/ResponsesSession.js +13 -42
- package/dist/protocol/responses/ResponsesSession.js.map +1 -1
- package/dist/protocol/responses/mapOpenAIResponseStream.d.ts +9 -6
- package/dist/protocol/responses/mapOpenAIResponseStream.d.ts.map +1 -1
- package/dist/protocol/responses/mapOpenAIResponseStream.js +191 -59
- package/dist/protocol/responses/mapOpenAIResponseStream.js.map +1 -1
- package/dist/protocol/responses/toOpenAIInputContent.d.ts +2 -2
- package/dist/protocol/responses/toOpenAIInputContent.d.ts.map +1 -1
- package/dist/protocol/responses/toOpenAIInputContent.js +4 -4
- package/dist/protocol/responses/toOpenAIInputContent.js.map +1 -1
- package/dist/protocol/responses/toOpenAIResponseInput.d.ts.map +1 -1
- package/dist/protocol/responses/toOpenAIResponseInput.js +74 -68
- package/dist/protocol/responses/toOpenAIResponseInput.js.map +1 -1
- package/dist/protocol/responses/toSessionUsage.d.ts +4 -0
- package/dist/protocol/responses/toSessionUsage.d.ts.map +1 -0
- package/dist/protocol/responses/{toSessionCacheUsage.js → toSessionUsage.js} +4 -4
- package/dist/protocol/responses/toSessionUsage.js.map +1 -0
- package/dist/vendors/bedrock/AnthropicBedrockSession.d.ts +1 -1
- package/dist/vendors/bedrock/AnthropicBedrockSession.d.ts.map +1 -1
- package/dist/vendors/bedrock/AnthropicBedrockSession.js +23 -64
- package/dist/vendors/bedrock/AnthropicBedrockSession.js.map +1 -1
- package/dist/vendors/claude/ClaudeSession.d.ts +1 -1
- package/dist/vendors/claude/ClaudeSession.d.ts.map +1 -1
- package/dist/vendors/claude/ClaudeSession.js +168 -72
- package/dist/vendors/claude/ClaudeSession.js.map +1 -1
- package/dist/vendors/claude/impl/ClaudeToolBridge.js +1 -7
- package/dist/vendors/claude/impl/ClaudeToolBridge.js.map +1 -1
- package/dist/vendors/claude/impl/claudeMessageIdentity.d.ts +3 -4
- package/dist/vendors/claude/impl/claudeMessageIdentity.d.ts.map +1 -1
- package/dist/vendors/claude/impl/claudeMessageIdentity.js +9 -12
- package/dist/vendors/claude/impl/claudeMessageIdentity.js.map +1 -1
- package/dist/vendors/claude/impl/createClaudeSessionReplay.js +36 -30
- package/dist/vendors/claude/impl/createClaudeSessionReplay.js.map +1 -1
- package/dist/vendors/claude/impl/toClaudeSdkOptions.d.ts.map +1 -1
- package/dist/vendors/claude/impl/toClaudeSdkOptions.js +2 -2
- package/dist/vendors/claude/impl/toClaudeSdkOptions.js.map +1 -1
- package/dist/vendors/codex/CodexSession.d.ts +1 -1
- package/dist/vendors/codex/CodexSession.d.ts.map +1 -1
- package/dist/vendors/codex/CodexSession.js +30 -51
- package/dist/vendors/codex/CodexSession.js.map +1 -1
- package/dist/vendors/codex/CodexToolVendor.d.ts +2 -1
- package/dist/vendors/codex/CodexToolVendor.d.ts.map +1 -1
- package/dist/vendors/codex/impl/codexCompaction.d.ts +2 -2
- package/dist/vendors/codex/impl/codexCompaction.d.ts.map +1 -1
- package/dist/vendors/codex/impl/codexCompaction.js +15 -7
- package/dist/vendors/codex/impl/codexCompaction.js.map +1 -1
- package/dist/vendors/codex/impl/createCodexModelSwitchMessage.d.ts.map +1 -1
- package/dist/vendors/codex/impl/createCodexModelSwitchMessage.js +11 -8
- package/dist/vendors/codex/impl/createCodexModelSwitchMessage.js.map +1 -1
- package/dist/vendors/codex/impl/getCodexContextSuffix.js +13 -15
- package/dist/vendors/codex/impl/getCodexContextSuffix.js.map +1 -1
- package/dist/vendors/codex/impl/getCodexIncrementalInput.d.ts +2 -2
- package/dist/vendors/codex/impl/getCodexIncrementalInput.d.ts.map +1 -1
- package/dist/vendors/codex/impl/getCodexIncrementalInput.js +15 -4
- package/dist/vendors/codex/impl/getCodexIncrementalInput.js.map +1 -1
- package/dist/vendors/codex/impl/getCodexTurnKey.js +1 -1
- package/dist/vendors/codex/impl/getCodexTurnKey.js.map +1 -1
- package/dist/vendors/codex/impl/settleCodexToolSearch.d.ts +4 -3
- package/dist/vendors/codex/impl/settleCodexToolSearch.d.ts.map +1 -1
- package/dist/vendors/codex/impl/settleCodexToolSearch.js +14 -2
- package/dist/vendors/codex/impl/settleCodexToolSearch.js.map +1 -1
- package/dist/vendors/codex/impl/toCodexToolDefinitions.d.ts.map +1 -1
- package/dist/vendors/codex/impl/toCodexToolDefinitions.js +6 -27
- package/dist/vendors/codex/impl/toCodexToolDefinitions.js.map +1 -1
- package/dist/vendors/codex/impl/withCodexSkills.d.ts.map +1 -1
- package/dist/vendors/codex/impl/withCodexSkills.js +8 -12
- package/dist/vendors/codex/impl/withCodexSkills.js.map +1 -1
- package/dist/vendors/codex/tools/tool_search.d.ts +9 -5
- package/dist/vendors/codex/tools/tool_search.d.ts.map +1 -1
- package/dist/vendors/codex/tools/tool_search.js +8 -10
- package/dist/vendors/codex/tools/tool_search.js.map +1 -1
- package/dist/vendors/grok/GrokSession.d.ts +1 -1
- package/dist/vendors/grok/GrokSession.d.ts.map +1 -1
- package/dist/vendors/grok/GrokSession.js +21 -43
- package/dist/vendors/grok/GrokSession.js.map +1 -1
- package/dist/vendors/grok/impl/grokMessages.js +11 -5
- package/dist/vendors/grok/impl/grokMessages.js.map +1 -1
- package/dist/vendors/grok/impl/stripGrokContextImages.d.ts.map +1 -1
- package/dist/vendors/grok/impl/stripGrokContextImages.js +3 -3
- package/dist/vendors/grok/impl/stripGrokContextImages.js.map +1 -1
- package/dist/vendors/grok/impl/toGrokInputContent.d.ts +2 -2
- package/dist/vendors/grok/impl/toGrokInputContent.d.ts.map +1 -1
- package/dist/vendors/grok/impl/toGrokInputContent.js +4 -4
- package/dist/vendors/grok/impl/toGrokInputContent.js.map +1 -1
- package/dist/vendors/grok/impl/toGrokResponseInput.d.ts.map +1 -1
- package/dist/vendors/grok/impl/toGrokResponseInput.js +78 -70
- package/dist/vendors/grok/impl/toGrokResponseInput.js.map +1 -1
- package/package.json +74 -75
- package/dist/core/SessionCacheUsage.d.ts +0 -9
- package/dist/core/SessionCacheUsage.d.ts.map +0 -1
- package/dist/core/SessionCacheUsage.js.map +0 -1
- package/dist/core/addSessionCacheUsage.d.ts +0 -3
- package/dist/core/addSessionCacheUsage.d.ts.map +0 -1
- package/dist/core/addSessionCacheUsage.js.map +0 -1
- package/dist/protocol/responses/toSessionCacheUsage.d.ts +0 -4
- package/dist/protocol/responses/toSessionCacheUsage.d.ts.map +0 -1
- package/dist/protocol/responses/toSessionCacheUsage.js.map +0 -1
package/README.md
CHANGED
|
@@ -81,6 +81,8 @@ warm, but you own the transcript.
|
|
|
81
81
|
import {
|
|
82
82
|
CodexProvider,
|
|
83
83
|
CodexSessionCredential,
|
|
84
|
+
SessionAssistantMessageAccumulator,
|
|
85
|
+
type SessionAssistantMessage,
|
|
84
86
|
type SessionMessage,
|
|
85
87
|
} from "@slopus/happy-providers";
|
|
86
88
|
|
|
@@ -94,25 +96,30 @@ const provider = new CodexProvider({
|
|
|
94
96
|
model: "gpt-5.6-sol",
|
|
95
97
|
transport: "auto",
|
|
96
98
|
});
|
|
99
|
+
const instructions = "You are a concise coding assistant.";
|
|
97
100
|
const session = await provider.session("conversation-1", {
|
|
98
|
-
instructions
|
|
101
|
+
instructions,
|
|
99
102
|
tools: [],
|
|
100
103
|
});
|
|
101
104
|
|
|
102
105
|
const messages: SessionMessage[] = [];
|
|
103
106
|
|
|
104
107
|
async function ask(content: string): Promise<string> {
|
|
105
|
-
messages.push({ role: "user", content });
|
|
108
|
+
messages.push({ role: "user", content: [{ type: "text", text: content }] });
|
|
106
109
|
|
|
107
110
|
let response = "";
|
|
108
|
-
|
|
111
|
+
const assistant = new SessionAssistantMessageAccumulator();
|
|
112
|
+
for await (const event of session.run({ context: { instructions, messages } })) {
|
|
113
|
+
assistant.add(event);
|
|
109
114
|
if (event.type === "text_delta") response += event.delta;
|
|
110
115
|
if (event.type === "done" && event.state === "error") {
|
|
111
116
|
throw new Error(event.message);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
|
|
115
|
-
|
|
120
|
+
const message = assistant.message();
|
|
121
|
+
if (message === undefined) throw new Error("The provider returned no assistant message.");
|
|
122
|
+
messages.push(message);
|
|
116
123
|
return response;
|
|
117
124
|
}
|
|
118
125
|
|
|
@@ -124,8 +131,10 @@ try {
|
|
|
124
131
|
}
|
|
125
132
|
```
|
|
126
133
|
|
|
127
|
-
A production caller
|
|
128
|
-
|
|
134
|
+
A production caller reconstructs and persists the assistant message from the ordered block events.
|
|
135
|
+
`SessionAssistantMessageAccumulator` does that directly, including retry rewinds. Its result
|
|
136
|
+
contains the text, reasoning, tool calls, provider-owned tool results, and opaque replay metadata
|
|
137
|
+
needed for the next turn.
|
|
129
138
|
[EXAMPLES.md](EXAMPLES.md) walks through a complete event collector and a tool-call continuation.
|
|
130
139
|
|
|
131
140
|
## Providers and credentials
|
|
@@ -180,7 +189,7 @@ reasoning effort, priority service tier, structured output schema, and an abort
|
|
|
180
189
|
|
|
181
190
|
```ts
|
|
182
191
|
const stream = session.run({
|
|
183
|
-
context: { messages },
|
|
192
|
+
context: { instructions, messages },
|
|
184
193
|
model: "gpt-5.6-sol",
|
|
185
194
|
effort: "high",
|
|
186
195
|
abort: abortController.signal,
|
|
@@ -216,22 +225,23 @@ continuing the same conversation; mint a new one for a new conversation or an in
|
|
|
216
225
|
## Messages and events
|
|
217
226
|
|
|
218
227
|
`SessionMessage` covers user, assistant, tool-result, system-notice, agent, and compaction
|
|
219
|
-
messages.
|
|
228
|
+
messages. User, system, assistant, and tool-result content is always an ordered block array.
|
|
220
229
|
|
|
221
230
|
Some fields exist purely so the provider can continue a conversation faithfully, and their
|
|
222
231
|
contents are intentionally opaque. Whenever these appear, store them byte-for-byte and send them
|
|
223
232
|
back unchanged:
|
|
224
233
|
|
|
225
|
-
-
|
|
226
|
-
- tool-call and tool-result `vendor` metadata;
|
|
227
|
-
- signed reasoning blocks;
|
|
234
|
+
- reasoning block `reasoning` payloads;
|
|
235
|
+
- tool-call and tool-result block `vendor` metadata;
|
|
228
236
|
- compaction `encryptedContent` and `vendor` metadata.
|
|
229
237
|
|
|
230
238
|
`SessionStream` is an `AsyncIterable<SessionEvent>`. You'll see text and reasoning deltas,
|
|
231
239
|
tool-call boundaries, provider-owned tool results, token usage, retry notices, and block rollback
|
|
232
|
-
boundaries.
|
|
233
|
-
|
|
234
|
-
|
|
240
|
+
boundaries. Content-block start order is the exact order of `SessionAssistantMessage.content`;
|
|
241
|
+
indexes are neither exposed nor needed. Every started stream ends with exactly one `done` event.
|
|
242
|
+
Use `SessionAssistantMessageAccumulator` to build the message while streaming, or
|
|
243
|
+
`assistantMessageFromEvents()` after collecting a run. Both discard output invalidated by
|
|
244
|
+
`block_reset` correctly.
|
|
235
245
|
|
|
236
246
|
## Tools: you run them, not the library
|
|
237
247
|
|
|
@@ -277,8 +287,8 @@ behind your back:
|
|
|
277
287
|
|
|
278
288
|
```ts
|
|
279
289
|
const compacted = await session.compact({
|
|
280
|
-
context: { messages },
|
|
281
|
-
|
|
290
|
+
context: { instructions, messages },
|
|
291
|
+
instructions: "Preserve decisions, unfinished work, and exact identifiers.",
|
|
282
292
|
signal: abortController.signal,
|
|
283
293
|
});
|
|
284
294
|
|
|
@@ -290,6 +300,11 @@ if (compacted.status === "completed") {
|
|
|
290
300
|
On success, adopt and persist the complete returned `context` as your new transcript. On
|
|
291
301
|
cancellation or failure, keep the original — nothing was changed out from under you.
|
|
292
302
|
|
|
303
|
+
The `context` is the complete caller-selected input to compact: root instructions and messages
|
|
304
|
+
travel together exactly as they do for inference. The separate `instructions` field tells the
|
|
305
|
+
provider what the compacted replacement should retain. Compaction does not accept a caller token
|
|
306
|
+
count; providers report their own usage.
|
|
307
|
+
|
|
293
308
|
## The most important part: sessions are stateful and managed
|
|
294
309
|
|
|
295
310
|
Everything above is mechanics. This is the mental model.
|
|
@@ -346,11 +361,11 @@ next operation.
|
|
|
346
361
|
|
|
347
362
|
```ts
|
|
348
363
|
// Correct: turns on one session are sequential.
|
|
349
|
-
for await (const event of session.run({ context: { messages } })) {
|
|
364
|
+
for await (const event of session.run({ context: { instructions, messages } })) {
|
|
350
365
|
// Consume every event.
|
|
351
366
|
}
|
|
352
367
|
|
|
353
|
-
const compacted = await session.compact({ context: { messages } });
|
|
368
|
+
const compacted = await session.compact({ context: { instructions, messages } });
|
|
354
369
|
```
|
|
355
370
|
|
|
356
371
|
Independent sessions run concurrently just fine — use one session per conversation or branch:
|
|
@@ -360,12 +375,16 @@ const first = await provider.session("conversation-1", firstOptions);
|
|
|
360
375
|
const second = await provider.session("conversation-2", secondOptions);
|
|
361
376
|
|
|
362
377
|
const runFirst = async () => {
|
|
363
|
-
for await (const event of first.run({
|
|
378
|
+
for await (const event of first.run({
|
|
379
|
+
context: { instructions: firstInstructions, messages: firstMessages },
|
|
380
|
+
})) {
|
|
364
381
|
// Consume the first conversation's events.
|
|
365
382
|
}
|
|
366
383
|
};
|
|
367
384
|
const runSecond = async () => {
|
|
368
|
-
for await (const event of second.run({
|
|
385
|
+
for await (const event of second.run({
|
|
386
|
+
context: { instructions: secondInstructions, messages: secondMessages },
|
|
387
|
+
})) {
|
|
369
388
|
// Consume the second conversation's events.
|
|
370
389
|
}
|
|
371
390
|
};
|
|
@@ -384,7 +403,7 @@ the next inference begins.
|
|
|
384
403
|
or by creating two session objects with the same ID.
|
|
385
404
|
|
|
386
405
|
To branch today, copy your transcript and open a new session with its own ID. Include all opaque
|
|
387
|
-
reasoning,
|
|
406
|
+
reasoning, tool metadata, and compaction messages in the copy:
|
|
388
407
|
|
|
389
408
|
```ts
|
|
390
409
|
const branchMessages = structuredClone(messages);
|
|
@@ -395,7 +414,7 @@ const branch = await provider.session("conversation-1-branch-1", {
|
|
|
395
414
|
});
|
|
396
415
|
|
|
397
416
|
for await (const event of branch.run({
|
|
398
|
-
context: { messages: branchMessages },
|
|
417
|
+
context: { instructions, messages: branchMessages },
|
|
399
418
|
model,
|
|
400
419
|
effort,
|
|
401
420
|
})) {
|
|
@@ -450,7 +469,7 @@ out the rewound output:
|
|
|
450
469
|
import { committedSessionEvents, type SessionEvent } from "@slopus/happy-providers";
|
|
451
470
|
|
|
452
471
|
const streamed: SessionEvent[] = [];
|
|
453
|
-
for await (const event of session.run({ context: { messages } })) {
|
|
472
|
+
for await (const event of session.run({ context: { instructions, messages } })) {
|
|
454
473
|
streamed.push(event);
|
|
455
474
|
}
|
|
456
475
|
|
|
@@ -598,7 +617,7 @@ abstract class BaseSession {
|
|
|
598
617
|
readonly id: string;
|
|
599
618
|
|
|
600
619
|
abstract run(request: SessionRunRequest): SessionStream;
|
|
601
|
-
abstract compact(options
|
|
620
|
+
abstract compact(options: SessionCompactionOptions): Promise<SessionCompaction>;
|
|
602
621
|
abstract destroy(): void | Promise<void>;
|
|
603
622
|
}
|
|
604
623
|
```
|
|
@@ -635,10 +654,8 @@ What one `run()` takes:
|
|
|
635
654
|
|
|
636
655
|
```ts
|
|
637
656
|
interface SessionRunRequest {
|
|
638
|
-
/** Complete rebuilt conversation
|
|
639
|
-
context:
|
|
640
|
-
readonly messages: readonly SessionMessage[];
|
|
641
|
-
};
|
|
657
|
+
/** Complete rebuilt conversation context for this inference turn. */
|
|
658
|
+
context: SessionContext;
|
|
642
659
|
abort?: AbortSignal;
|
|
643
660
|
model?: string;
|
|
644
661
|
effort?: SessionReasoningEffort;
|
|
@@ -673,58 +690,54 @@ type SessionMessage =
|
|
|
673
690
|
| SessionCompactionMessage;
|
|
674
691
|
```
|
|
675
692
|
|
|
676
|
-
A user turn
|
|
693
|
+
A user turn contains ordered multimodal blocks:
|
|
677
694
|
|
|
678
695
|
```ts
|
|
679
696
|
interface SessionUserMessage {
|
|
680
697
|
readonly role: "user";
|
|
681
|
-
readonly content:
|
|
682
|
-
/** Background context that does not establish a provider turn boundary. */
|
|
683
|
-
readonly contextOnly?: true;
|
|
684
|
-
readonly input?: SessionInputContent;
|
|
698
|
+
readonly content: readonly SessionInputBlock[];
|
|
685
699
|
}
|
|
686
700
|
|
|
687
|
-
type
|
|
701
|
+
type SessionInputBlock = SessionTextBlock | SessionImageBlock;
|
|
688
702
|
|
|
689
|
-
interface
|
|
703
|
+
interface SessionTextBlock {
|
|
690
704
|
readonly type: "text";
|
|
691
705
|
readonly text: string;
|
|
692
706
|
}
|
|
693
707
|
|
|
694
|
-
interface
|
|
708
|
+
interface SessionImageBlock {
|
|
695
709
|
readonly type: "image";
|
|
696
710
|
readonly data: string;
|
|
697
711
|
readonly mimeType: string;
|
|
698
712
|
}
|
|
699
713
|
```
|
|
700
714
|
|
|
701
|
-
A model turn
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
them byte-for-byte:
|
|
715
|
+
A model turn is one ordered block array. Do not flatten or reorder it: provider replay state lives
|
|
716
|
+
on the block it belongs to, so text, reasoning, client tool calls, and provider-owned tool results
|
|
717
|
+
retain their original sequence:
|
|
705
718
|
|
|
706
719
|
```ts
|
|
707
720
|
interface SessionAssistantMessage {
|
|
708
721
|
readonly role: "assistant";
|
|
709
|
-
readonly content:
|
|
710
|
-
/** Opaque encrypted reasoning from a Responses-compatible backend. */
|
|
711
|
-
readonly encryptedReasoning?: string;
|
|
712
|
-
/** Ordered reasoning blocks retained as caller-owned history. */
|
|
713
|
-
readonly reasoning?: readonly SessionReasoning[];
|
|
714
|
-
/** Completed client tool calls emitted alongside this message. */
|
|
715
|
-
readonly toolCalls?: readonly SessionToolCall[];
|
|
716
|
-
/** Ordered, opaque Responses output items, replayed without flattening or reordering. */
|
|
717
|
-
readonly responseItems?: readonly string[];
|
|
722
|
+
readonly content: readonly SessionAssistantBlock[];
|
|
718
723
|
}
|
|
719
724
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
+
type SessionAssistantBlock =
|
|
726
|
+
| SessionTextBlock
|
|
727
|
+
| SessionReasoningBlock
|
|
728
|
+
| SessionToolCallBlock
|
|
729
|
+
| SessionToolResultBlock;
|
|
730
|
+
|
|
731
|
+
interface SessionReasoningBlock {
|
|
732
|
+
readonly type: "reasoning";
|
|
733
|
+
/** Human-readable reasoning, when exposed. */
|
|
734
|
+
readonly text?: string;
|
|
735
|
+
/** Opaque signed or encrypted replay state, when required. */
|
|
736
|
+
readonly reasoning?: string;
|
|
725
737
|
}
|
|
726
738
|
|
|
727
|
-
interface
|
|
739
|
+
interface SessionToolCallBlock {
|
|
740
|
+
readonly type: "tool_call";
|
|
728
741
|
readonly callId: string;
|
|
729
742
|
readonly name: string;
|
|
730
743
|
readonly namespace?: string;
|
|
@@ -743,11 +756,9 @@ Your answer to a tool call, tied back by `callId`:
|
|
|
743
756
|
interface SessionToolResultMessage {
|
|
744
757
|
readonly role: "tool";
|
|
745
758
|
readonly callId: string;
|
|
746
|
-
readonly content:
|
|
759
|
+
readonly content: readonly SessionOutputBlock[];
|
|
747
760
|
/** Whether the caller reported that the tool invocation failed. */
|
|
748
761
|
readonly isError?: boolean;
|
|
749
|
-
/** Ordered multimodal content. When present, providers use this instead of content. */
|
|
750
|
-
readonly input?: SessionInputContent;
|
|
751
762
|
/** The opaque metadata that arrived with the call, echoed back. */
|
|
752
763
|
readonly vendor?: any;
|
|
753
764
|
}
|
|
@@ -760,7 +771,7 @@ edit it):
|
|
|
760
771
|
```ts
|
|
761
772
|
interface SessionSystemMessage {
|
|
762
773
|
readonly role: "system";
|
|
763
|
-
readonly content:
|
|
774
|
+
readonly content: readonly SessionTextBlock[];
|
|
764
775
|
}
|
|
765
776
|
|
|
766
777
|
interface SessionAgentMessage {
|
|
@@ -784,6 +795,11 @@ interface SessionCompactionMessage {
|
|
|
784
795
|
}
|
|
785
796
|
```
|
|
786
797
|
|
|
798
|
+
`SessionAgentMessage` is specifically Codex cross-agent replay state. It represents encrypted
|
|
799
|
+
messages exchanged by Codex collaborators and preserves their author, recipient, display header,
|
|
800
|
+
and turn boundary. Persist and replay values emitted by Codex; do not construct it as a generic
|
|
801
|
+
application message. Non-Codex providers ignore it.
|
|
802
|
+
|
|
787
803
|
### `SessionTool`
|
|
788
804
|
|
|
789
805
|
A tool definition, as covered in the [Tools section](#tools-you-run-them-not-the-library):
|
|
@@ -802,9 +818,7 @@ interface SessionTool {
|
|
|
802
818
|
readonly description?: string;
|
|
803
819
|
readonly parameters?: TSchema; // a TypeBox schema
|
|
804
820
|
/** Provider-neutral request to expose this tool through native tool discovery. */
|
|
805
|
-
readonly
|
|
806
|
-
/** Opaque provider metadata persisted with this tool definition. */
|
|
807
|
-
readonly vendor?: any;
|
|
821
|
+
readonly defer?: boolean;
|
|
808
822
|
/** OpenAI-style Lark grammar; ignored by providers that do not support grammar tools. */
|
|
809
823
|
readonly grammar?: SessionToolLarkGrammar;
|
|
810
824
|
}
|
|
@@ -821,35 +835,62 @@ interface SessionToolLarkGrammar {
|
|
|
821
835
|
|
|
822
836
|
```ts
|
|
823
837
|
type SessionEvent =
|
|
824
|
-
//
|
|
838
|
+
// Attempt blocks bracket tentative output so provider-owned retries can rewind it.
|
|
825
839
|
| { type: "block_start" }
|
|
826
840
|
| { type: "block_stop" }
|
|
827
841
|
| { type: "block_reset" }
|
|
828
|
-
//
|
|
842
|
+
// Text and reasoning blocks are sequential. Start order is message-content order.
|
|
843
|
+
| { type: "text_start" }
|
|
829
844
|
| { type: "text_delta"; delta: string }
|
|
845
|
+
| { type: "text_end" }
|
|
846
|
+
| { type: "reasoning_start" }
|
|
830
847
|
| { type: "reasoning_delta"; delta: string }
|
|
831
|
-
| { type: "
|
|
832
|
-
| { type: "response_items"; items: readonly string[] }
|
|
848
|
+
| { type: "reasoning_end"; reasoning?: string }
|
|
833
849
|
// Tool calls. `server: true` marks a provider-owned call the client never executes.
|
|
834
|
-
| {
|
|
850
|
+
| {
|
|
851
|
+
type: "toolcall_start";
|
|
852
|
+
callId: string;
|
|
853
|
+
name: string;
|
|
854
|
+
namespace?: string;
|
|
855
|
+
server?: true;
|
|
856
|
+
vendor?: any;
|
|
857
|
+
}
|
|
835
858
|
| { type: "toolcall_delta"; callId: string; delta: string }
|
|
836
859
|
| { type: "toolcall_end"; callId: string; arguments: string; incomplete?: boolean }
|
|
837
860
|
// Server-tool results settle inside the same response, streamed beside the call.
|
|
838
|
-
| { type: "toolcall_result_start"; callId: string }
|
|
861
|
+
| { type: "toolcall_result_start"; callId: string; vendor?: any }
|
|
839
862
|
| { type: "toolcall_result_delta"; callId: string; delta: string }
|
|
840
|
-
| {
|
|
863
|
+
| {
|
|
864
|
+
type: "toolcall_result_end";
|
|
865
|
+
callId: string;
|
|
866
|
+
content: readonly SessionOutputBlock[];
|
|
867
|
+
isError?: boolean;
|
|
868
|
+
incomplete?: boolean;
|
|
869
|
+
}
|
|
841
870
|
// Progress.
|
|
842
871
|
| { type: "retrying"; attempt: number; reason: string }
|
|
843
|
-
| { type: "token_usage"; usage:
|
|
872
|
+
| { type: "token_usage"; usage: SessionUsage }
|
|
844
873
|
// Exactly one done event ends every started stream.
|
|
845
874
|
| { type: "done"; state: "cancelled" }
|
|
846
|
-
| { type: "done"; state: "normal"; endTurn?: boolean }
|
|
847
|
-
| { type: "done"; state: "tool_call" }
|
|
848
|
-
| { type: "done"; state: "length" }
|
|
849
|
-
| {
|
|
875
|
+
| { type: "done"; state: "normal"; tokens: SessionTokens; endTurn?: boolean }
|
|
876
|
+
| { type: "done"; state: "tool_call"; tokens: SessionTokens }
|
|
877
|
+
| { type: "done"; state: "length"; tokens: SessionTokens }
|
|
878
|
+
| {
|
|
879
|
+
type: "done";
|
|
880
|
+
state: "error";
|
|
881
|
+
kind: SessionErrorKind;
|
|
882
|
+
message: string;
|
|
883
|
+
providerError?: SessionProviderError;
|
|
884
|
+
};
|
|
850
885
|
|
|
851
886
|
type SessionErrorKind = "internal_error" | "context_overflow" | "billing_error" | "unknown";
|
|
852
887
|
|
|
888
|
+
interface SessionTokens {
|
|
889
|
+
/** Full input context size, including cached input. */
|
|
890
|
+
readonly input: number;
|
|
891
|
+
readonly output: number;
|
|
892
|
+
}
|
|
893
|
+
|
|
853
894
|
type SessionStream = AsyncIterable<SessionEvent>;
|
|
854
895
|
```
|
|
855
896
|
|
|
@@ -859,15 +900,37 @@ response hit a length limit, `"cancelled"` means the run was aborted, and `"erro
|
|
|
859
900
|
Ordinary tools never emit `toolcall_result_*` events — you answer those with a `role: "tool"`
|
|
860
901
|
message; only server tools stream their results here.
|
|
861
902
|
|
|
903
|
+
No content index is exposed. A `text_start`, `reasoning_start`, `toolcall_start`, or
|
|
904
|
+
`toolcall_result_start` appends that block to the assistant message. Text and reasoning are
|
|
905
|
+
sequential; parallel tool calls are updated by `callId`. The corresponding end event closes the
|
|
906
|
+
block and supplies final opaque state or normalized content when needed.
|
|
907
|
+
|
|
908
|
+
The exported accumulator implements those rules and the outer retry rollback boundaries:
|
|
909
|
+
|
|
910
|
+
```ts
|
|
911
|
+
const assistant = new SessionAssistantMessageAccumulator();
|
|
912
|
+
|
|
913
|
+
for await (const event of session.run({ context: { instructions, messages } })) {
|
|
914
|
+
assistant.add(event);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
const message = assistant.message();
|
|
918
|
+
if (message !== undefined) messages.push(message);
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
If you already collected the complete run, `assistantMessageFromEvents(events)` returns the same
|
|
922
|
+
result. There is no terminal `assistant_message` event and no provider-specific `response_items`
|
|
923
|
+
event; the ordered lifecycle is the message.
|
|
924
|
+
|
|
862
925
|
The helpers `isSessionDoneEvent()` and `isSessionErrorDone()` narrow events, and
|
|
863
926
|
`committedSessionEvents()` filters a collected stream down to what survived block rewinds.
|
|
864
927
|
|
|
865
|
-
### `
|
|
928
|
+
### `SessionUsage`
|
|
866
929
|
|
|
867
930
|
Token accounting for one attempt:
|
|
868
931
|
|
|
869
932
|
```ts
|
|
870
|
-
interface
|
|
933
|
+
interface SessionUsage {
|
|
871
934
|
readonly input: number;
|
|
872
935
|
readonly output: number;
|
|
873
936
|
readonly cacheRead: number;
|
|
@@ -876,8 +939,27 @@ interface SessionCacheUsage {
|
|
|
876
939
|
}
|
|
877
940
|
```
|
|
878
941
|
|
|
879
|
-
|
|
880
|
-
|
|
942
|
+
The fields are normalized the same way for every provider: `input` is the complete input context,
|
|
943
|
+
including cached tokens; `cacheRead` and `cacheWrite` describe subsets of that input; and
|
|
944
|
+
`totalTokens` is `input + output`. Cache reads are the payoff of prompt-cache continuity — a
|
|
945
|
+
healthy continuation shows much of its input also reported as `cacheRead`.
|
|
946
|
+
|
|
947
|
+
**Getting the last turn's context size.** The size of the context the model actually saw on a
|
|
948
|
+
turn is `input`; cache columns are already included:
|
|
949
|
+
|
|
950
|
+
```ts
|
|
951
|
+
let lastUsage: SessionUsage | undefined;
|
|
952
|
+
for await (const event of session.run({ context: { instructions, messages } })) {
|
|
953
|
+
if (event.type === "token_usage") lastUsage = event.usage;
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
const contextSize = lastUsage?.input ?? 0;
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
Keep the _last_ `token_usage` event of the run — a retried run reports usage per attempt, and the
|
|
960
|
+
final event describes the attempt that produced the committed response. This is the right value
|
|
961
|
+
for a context-window meter in your UI. Compaction itself does not accept a caller-supplied token
|
|
962
|
+
count; its returned usage comes from the provider.
|
|
881
963
|
|
|
882
964
|
### `SessionCompaction`
|
|
883
965
|
|
|
@@ -889,12 +971,8 @@ interface SessionCompactionOptions {
|
|
|
889
971
|
readonly model?: string;
|
|
890
972
|
/** Provider-native instructions describing what the compaction should retain. */
|
|
891
973
|
readonly instructions?: string;
|
|
892
|
-
/**
|
|
893
|
-
readonly context
|
|
894
|
-
readonly messages: readonly SessionMessage[];
|
|
895
|
-
};
|
|
896
|
-
/** Best available count of input tokens in the selected context. */
|
|
897
|
-
readonly inputTokens?: number;
|
|
974
|
+
/** Complete context to compact, including its root instructions and messages. */
|
|
975
|
+
readonly context: SessionContext;
|
|
898
976
|
readonly signal?: AbortSignal;
|
|
899
977
|
}
|
|
900
978
|
|
|
@@ -913,7 +991,7 @@ interface CompletedSessionCompaction {
|
|
|
913
991
|
readonly encryptedReasoning?: string;
|
|
914
992
|
/** Original messages intentionally retained alongside the summary. */
|
|
915
993
|
readonly preservedMessages: readonly SessionMessage[];
|
|
916
|
-
readonly usage:
|
|
994
|
+
readonly usage: SessionUsage;
|
|
917
995
|
/** Complete replacement context — adopt this as your new transcript. */
|
|
918
996
|
readonly context: SessionContext;
|
|
919
997
|
}
|
|
@@ -928,8 +1006,6 @@ interface FailedSessionCompaction {
|
|
|
928
1006
|
readonly status: "failed";
|
|
929
1007
|
readonly kind: "inference_error" | "invalid_summary" | "tool_call";
|
|
930
1008
|
readonly message: string;
|
|
931
|
-
/** Original context left active because compaction did not complete. */
|
|
932
|
-
readonly context: SessionContext;
|
|
933
1009
|
}
|
|
934
1010
|
|
|
935
1011
|
interface SessionContext {
|
|
@@ -938,7 +1014,8 @@ interface SessionContext {
|
|
|
938
1014
|
}
|
|
939
1015
|
```
|
|
940
1016
|
|
|
941
|
-
On `"cancelled"` and `"failed"` nothing changed
|
|
1017
|
+
On `"cancelled"` and `"failed"` nothing changed. Cancellation echoes the selected context;
|
|
1018
|
+
failure only describes the error because the caller already owns the unchanged input context.
|
|
942
1019
|
|
|
943
1020
|
### `SessionProviderError`
|
|
944
1021
|
|
|
@@ -6,7 +6,7 @@ export declare abstract class BaseSession {
|
|
|
6
6
|
readonly id: string;
|
|
7
7
|
protected constructor(id: string);
|
|
8
8
|
abstract run(request: SessionRunRequest): SessionStream;
|
|
9
|
-
abstract compact(options
|
|
9
|
+
abstract compact(options: SessionCompactionOptions): Promise<SessionCompaction>;
|
|
10
10
|
abstract destroy(): void | Promise<void>;
|
|
11
11
|
}
|
|
12
12
|
export type { SessionCompaction, SessionContext, SessionEvent, SessionRunRequest, SessionStream };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseSession.d.ts","sourceRoot":"","sources":["../../sources/core/BaseSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,8BAAsB,WAAW;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,SAAS,aAAa,EAAE,EAAE,MAAM,EAE/B;IAED,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAAC;IAExD,QAAQ,CAAC,OAAO,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"BaseSession.d.ts","sourceRoot":"","sources":["../../sources/core/BaseSession.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAErE,8BAAsB,WAAW;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,SAAS,aAAa,EAAE,EAAE,MAAM,EAE/B;IAED,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAAC;IAExD,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,wBAAwB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAEhF,QAAQ,CAAC,OAAO,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5C;AAED,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SessionUsage } from "../core/SessionUsage.js";
|
|
2
2
|
import type { SessionEvent } from "../core/SessionEvent.js";
|
|
3
3
|
type ErrorDoneEvent = Extract<SessionEvent, {
|
|
4
4
|
type: "done";
|
|
@@ -7,8 +7,8 @@ type ErrorDoneEvent = Extract<SessionEvent, {
|
|
|
7
7
|
export declare class EmptyResponseError extends Error {
|
|
8
8
|
readonly code = "empty_response";
|
|
9
9
|
readonly errorType = "empty_response";
|
|
10
|
-
readonly usage:
|
|
11
|
-
constructor(provider: string, usage?:
|
|
10
|
+
readonly usage: SessionUsage | undefined;
|
|
11
|
+
constructor(provider: string, usage?: SessionUsage);
|
|
12
12
|
}
|
|
13
13
|
export declare function isEmptyResponseError(error: unknown): error is EmptyResponseError;
|
|
14
14
|
export declare function emptyResponseDoneEvent(error: EmptyResponseError, attempts: number): ErrorDoneEvent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyResponseError.d.ts","sourceRoot":"","sources":["../../sources/core/EmptyResponseError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"EmptyResponseError.d.ts","sourceRoot":"","sources":["../../sources/core/EmptyResponseError.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAE3D,KAAK,cAAc,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAE9E,qBAAa,kBAAmB,SAAQ,KAAK;IACzC,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,SAAS,oBAAoB;IACtC,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CAAC;IAEzC,YAAY,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,YAAY,EAIjD;CACJ;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAED,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,MAAM,GACjB,cAAc,CAehB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyResponseError.js","sourceRoot":"","sources":["../../sources/core/EmptyResponseError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAM5F,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAChC,IAAI,GAAG,gBAAgB,CAAC;IACxB,SAAS,GAAG,gBAAgB,CAAC;IAC7B,KAAK,
|
|
1
|
+
{"version":3,"file":"EmptyResponseError.js","sourceRoot":"","sources":["../../sources/core/EmptyResponseError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAC;AAM5F,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAChC,IAAI,GAAG,gBAAgB,CAAC;IACxB,SAAS,GAAG,gBAAgB,CAAC;IAC7B,KAAK,CAA2B;IAEzC,YAAY,QAAgB,EAAE,KAAoB;QAC9C,KAAK,CAAC,GAAG,QAAQ,+CAA+C,CAAC,CAAC;QAClE,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAC/C,OAAO,KAAK,YAAY,kBAAkB,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAClC,KAAyB,EACzB,QAAgB;IAEhB,MAAM,WAAW,GAAG,+BAA+B,CAAC,KAAK,EAAE;QACvD,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC;QAC/B,eAAe,EAAE,KAAK,CAAC,OAAO;KACjC,CAAC,CAAC;IACH,OAAO;QACH,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,aAAa,EAAE;YACX,IAAI,EAAE,gBAAgB;YACtB,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;SACxD;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SessionAssistantMessage } from "../core/SessionContext.js";
|
|
2
|
+
import type { SessionEvent } from "../core/SessionEvent.js";
|
|
3
|
+
/** Reconstructs one ordered assistant message from a session run's block events. */
|
|
4
|
+
export declare class SessionAssistantMessageAccumulator {
|
|
5
|
+
private readonly content;
|
|
6
|
+
private checkpoint;
|
|
7
|
+
private text;
|
|
8
|
+
private reasoning;
|
|
9
|
+
private readonly toolCalls;
|
|
10
|
+
private readonly toolResults;
|
|
11
|
+
add(event: SessionEvent): void;
|
|
12
|
+
message(): SessionAssistantMessage | undefined;
|
|
13
|
+
private clearActiveBlocks;
|
|
14
|
+
}
|
|
15
|
+
/** Reconstructs one assistant message after consuming a complete run. */
|
|
16
|
+
export declare function assistantMessageFromEvents(events: readonly SessionEvent[]): SessionAssistantMessage | undefined;
|
|
17
|
+
//# sourceMappingURL=SessionAssistantMessageAccumulator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SessionAssistantMessageAccumulator.d.ts","sourceRoot":"","sources":["../../sources/core/SessionAssistantMessageAccumulator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAER,uBAAuB,EAE1B,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AA4B3D,oFAAoF;AACpF,qBAAa,kCAAkC;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA+B;IACvD,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,IAAI,CAA+B;IAC3C,OAAO,CAAC,SAAS,CAAoC;IACrD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA2C;IACrE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA6C;IAEzE,GAAG,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CA8G7B;IAED,OAAO,IAAI,uBAAuB,GAAG,SAAS,CAM7C;IAED,OAAO,CAAC,iBAAiB;CAM5B;AAED,yEAAyE;AACzE,wBAAgB,0BAA0B,CACtC,MAAM,EAAE,SAAS,YAAY,EAAE,GAChC,uBAAuB,GAAG,SAAS,CAIrC"}
|