veryfront 0.1.251 → 0.1.254

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/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.251",
3
+ "version": "0.1.254",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -0,0 +1,8 @@
1
+ type ConversationRunEventRecord = Record<string, unknown> & {
2
+ type: string;
3
+ };
4
+ export declare function getConversationRunEventJsonByteLength(value: unknown): number;
5
+ export declare function normalizeConversationRunEvent(event: ConversationRunEventRecord): ConversationRunEventRecord[];
6
+ export declare function normalizeConversationRunEvents(events: ConversationRunEventRecord[]): ConversationRunEventRecord[];
7
+ export {};
8
+ //# sourceMappingURL=conversation-run-event-normalization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-run-event-normalization.d.ts","sourceRoot":"","sources":["../../../src/src/agent/conversation-run-event-normalization.ts"],"names":[],"mappings":"AAQA,KAAK,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAS7E,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM5E;AAED,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,0BAA0B,GAChC,0BAA0B,EAAE,CAkB9B;AAED,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,0BAA0B,EAAE,GACnC,0BAA0B,EAAE,CAE9B"}
@@ -0,0 +1,167 @@
1
+ const MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES = 240 * 1024;
2
+ const MAX_SUMMARY_DEPTH = 4;
3
+ const MAX_SUMMARY_ARRAY_ITEMS = 8;
4
+ const MAX_SUMMARY_OBJECT_KEYS = 24;
5
+ const MAX_SUMMARY_STRING_BYTES = 8 * 1024;
6
+ const encoder = new TextEncoder();
7
+ function hasStringField(event, field) {
8
+ return typeof event[field] === "string";
9
+ }
10
+ export function getConversationRunEventJsonByteLength(value) {
11
+ try {
12
+ return encoder.encode(JSON.stringify(value)).byteLength;
13
+ }
14
+ catch {
15
+ return Number.POSITIVE_INFINITY;
16
+ }
17
+ }
18
+ export function normalizeConversationRunEvent(event) {
19
+ if (getConversationRunEventJsonByteLength(event) <= MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES) {
20
+ return [event];
21
+ }
22
+ switch (event.type) {
23
+ case "TEXT_MESSAGE_CONTENT":
24
+ case "REASONING_CONTENT":
25
+ case "REASONING_MESSAGE_CONTENT":
26
+ case "TOOL_CALL_ARGS":
27
+ return hasStringField(event, "delta") ? splitStringFieldEvent(event, "delta") : [event];
28
+ case "TOOL_CALL_RESULT":
29
+ return [summarizeToolResultEvent(event)];
30
+ default:
31
+ return [summarizeGenericEvent(event)];
32
+ }
33
+ }
34
+ export function normalizeConversationRunEvents(events) {
35
+ return events.flatMap(normalizeConversationRunEvent);
36
+ }
37
+ function summarizeToolResultEvent(event) {
38
+ if (event.type !== "TOOL_CALL_RESULT") {
39
+ return event;
40
+ }
41
+ if (typeof event.content === "string") {
42
+ const maxResultBytes = getStringFieldBudget(event, "content");
43
+ return {
44
+ ...event,
45
+ content: truncateUtf8String(event.content, maxResultBytes, " [tool result truncated in conversation-run event]"),
46
+ };
47
+ }
48
+ const summarizedEvent = {
49
+ ...event,
50
+ content: summarizeValue(event.content),
51
+ };
52
+ if (getConversationRunEventJsonByteLength(summarizedEvent) <=
53
+ MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES) {
54
+ return summarizedEvent;
55
+ }
56
+ return {
57
+ ...event,
58
+ content: {
59
+ truncated: true,
60
+ originalType: describeValueType(event.content),
61
+ note: "Tool result omitted from the conversation-run event because it exceeded the payload size limit.",
62
+ },
63
+ };
64
+ }
65
+ function summarizeGenericEvent(event) {
66
+ return {
67
+ ...event,
68
+ truncated: true,
69
+ note: "Conversation-run event payload was summarized to stay within storage limits.",
70
+ };
71
+ }
72
+ function splitStringFieldEvent(event, field) {
73
+ const maxBytes = getStringFieldBudget(event, field);
74
+ const parts = splitUtf8String(event[field], maxBytes);
75
+ return parts.map((part) => ({ ...event, [field]: part }));
76
+ }
77
+ function getStringFieldBudget(event, field) {
78
+ const eventWithEmptyField = {
79
+ ...event,
80
+ [field]: "",
81
+ };
82
+ return Math.max(1, MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES -
83
+ getConversationRunEventJsonByteLength(eventWithEmptyField));
84
+ }
85
+ function splitUtf8String(value, maxBytes) {
86
+ if (encoder.encode(value).byteLength <= maxBytes) {
87
+ return [value];
88
+ }
89
+ const parts = [];
90
+ let startIndex = 0;
91
+ while (startIndex < value.length) {
92
+ let low = startIndex + 1;
93
+ let high = value.length;
94
+ let bestEndIndex = startIndex + 1;
95
+ while (low <= high) {
96
+ const mid = Math.floor((low + high) / 2);
97
+ const slice = value.slice(startIndex, mid);
98
+ if (encoder.encode(slice).byteLength <= maxBytes) {
99
+ bestEndIndex = mid;
100
+ low = mid + 1;
101
+ }
102
+ else {
103
+ high = mid - 1;
104
+ }
105
+ }
106
+ parts.push(value.slice(startIndex, bestEndIndex));
107
+ startIndex = bestEndIndex;
108
+ }
109
+ return parts;
110
+ }
111
+ function truncateUtf8String(value, maxBytes, suffix) {
112
+ if (encoder.encode(value).byteLength <= maxBytes) {
113
+ return value;
114
+ }
115
+ const suffixBytes = encoder.encode(suffix).byteLength;
116
+ if (suffixBytes >= maxBytes) {
117
+ return suffix.slice(0, Math.max(1, maxBytes));
118
+ }
119
+ const prefixBudget = maxBytes - suffixBytes;
120
+ const [prefix] = splitUtf8String(value, prefixBudget);
121
+ return `${prefix}${suffix}`;
122
+ }
123
+ function summarizeValue(value, depth = 0, seen = new WeakSet()) {
124
+ if (typeof value === "string") {
125
+ return truncateUtf8String(value, MAX_SUMMARY_STRING_BYTES, "… [truncated]");
126
+ }
127
+ if (value === null || typeof value !== "object") {
128
+ return value;
129
+ }
130
+ if (seen.has(value)) {
131
+ return "[circular]";
132
+ }
133
+ if (depth >= MAX_SUMMARY_DEPTH) {
134
+ return "[truncated nested data]";
135
+ }
136
+ seen.add(value);
137
+ if (Array.isArray(value)) {
138
+ const items = value
139
+ .slice(0, MAX_SUMMARY_ARRAY_ITEMS)
140
+ .map((item) => summarizeValue(item, depth + 1, seen));
141
+ if (value.length > MAX_SUMMARY_ARRAY_ITEMS) {
142
+ items.push(`[truncated ${value.length - MAX_SUMMARY_ARRAY_ITEMS} more items]`);
143
+ }
144
+ return items;
145
+ }
146
+ const entries = Object.entries(value);
147
+ const summarizedEntries = entries
148
+ .slice(0, MAX_SUMMARY_OBJECT_KEYS)
149
+ .map(([key, entryValue]) => [key, summarizeValue(entryValue, depth + 1, seen)]);
150
+ const summarizedObject = Object.fromEntries(summarizedEntries);
151
+ if (entries.length > MAX_SUMMARY_OBJECT_KEYS) {
152
+ return {
153
+ ...summarizedObject,
154
+ _truncatedKeys: entries.length - MAX_SUMMARY_OBJECT_KEYS,
155
+ };
156
+ }
157
+ return summarizedObject;
158
+ }
159
+ function describeValueType(value) {
160
+ if (Array.isArray(value)) {
161
+ return "array";
162
+ }
163
+ if (value === null) {
164
+ return "null";
165
+ }
166
+ return typeof value;
167
+ }
@@ -0,0 +1,5 @@
1
+ import { type ChatStreamEvent } from "../chat/protocol.js";
2
+ import { type ConversationRunEvent, ConversationRunEventEncoder } from "./conversation-run-events.js";
3
+ export declare function prepareConversationRunStreamEvents(events: ChatStreamEvent[], encoder?: ConversationRunEventEncoder): ConversationRunEvent[];
4
+ export declare function prepareConversationRunExternalEvents(events: ConversationRunEvent[]): ConversationRunEvent[];
5
+ //# sourceMappingURL=conversation-run-event-preparation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-run-event-preparation.d.ts","sourceRoot":"","sources":["../../../src/src/agent/conversation-run-event-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EACL,KAAK,oBAAoB,EACzB,2BAA2B,EAE5B,MAAM,8BAA8B,CAAC;AAGtC,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,8BAAoC,GAC1C,oBAAoB,EAAE,CAExB;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,oBAAoB,EAAE,GAC7B,oBAAoB,EAAE,CAExB"}
@@ -0,0 +1,8 @@
1
+ import { ConversationRunEventEncoder, encodeConversationRunEvents, } from "./conversation-run-events.js";
2
+ import { normalizeConversationRunEvents } from "./conversation-run-event-normalization.js";
3
+ export function prepareConversationRunStreamEvents(events, encoder = new ConversationRunEventEncoder()) {
4
+ return normalizeConversationRunEvents(encodeConversationRunEvents(events, encoder));
5
+ }
6
+ export function prepareConversationRunExternalEvents(events) {
7
+ return normalizeConversationRunEvents(events);
8
+ }
@@ -0,0 +1,30 @@
1
+ import { z } from "zod";
2
+ import { type ChatStreamEvent } from "../chat/protocol.js";
3
+ export declare const conversationRunEventTypes: {
4
+ readonly custom: "CUSTOM";
5
+ readonly textMessageStart: "TEXT_MESSAGE_START";
6
+ readonly textMessageContent: "TEXT_MESSAGE_CONTENT";
7
+ readonly textMessageEnd: "TEXT_MESSAGE_END";
8
+ readonly reasoningMessageStart: "REASONING_MESSAGE_START";
9
+ readonly reasoningMessageContent: "REASONING_MESSAGE_CONTENT";
10
+ readonly reasoningMessageEnd: "REASONING_MESSAGE_END";
11
+ readonly toolCallStart: "TOOL_CALL_START";
12
+ readonly toolCallArgs: "TOOL_CALL_ARGS";
13
+ readonly toolCallEnd: "TOOL_CALL_END";
14
+ readonly toolCallResult: "TOOL_CALL_RESULT";
15
+ };
16
+ export declare const ConversationRunEventSchema: z.ZodObject<{
17
+ type: z.ZodString;
18
+ }, z.core.$loose>;
19
+ export type ConversationRunEvent = z.infer<typeof ConversationRunEventSchema>;
20
+ export declare class ConversationRunEventEncoder {
21
+ private readonly streamedToolInputs;
22
+ private readonly toolInputs;
23
+ private activeMessageId;
24
+ private getToolResultMessageId;
25
+ private serializeToolResultContent;
26
+ encode(chunk: ChatStreamEvent): ConversationRunEvent[];
27
+ }
28
+ export declare function encodeConversationRunEvents(events: ChatStreamEvent[], encoder?: ConversationRunEventEncoder): ConversationRunEvent[];
29
+ export declare function normalizeEncodedConversationRunEvents(events: ChatStreamEvent[], encoder?: ConversationRunEventEncoder): ConversationRunEvent[];
30
+ //# sourceMappingURL=conversation-run-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-run-events.d.ts","sourceRoot":"","sources":["../../../src/src/agent/conversation-run-events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG3D,eAAO,MAAM,yBAAyB;;;;;;;;;;;;CAY5B,CAAC;AAEX,eAAO,MAAM,0BAA0B;;iBAEvB,CAAC;AAEjB,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAyB9E,qBAAa,2BAA2B;IACtC,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAqB;IACxD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA8B;IACzD,OAAO,CAAC,eAAe,CAAuB;IAE9C,OAAO,CAAC,sBAAsB;IAM9B,OAAO,CAAC,0BAA0B;IAYlC,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,oBAAoB,EAAE;CAqJvD;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,8BAAoC,GAC1C,oBAAoB,EAAE,CAExB;AAED,wBAAgB,qCAAqC,CACnD,MAAM,EAAE,eAAe,EAAE,EACzB,OAAO,8BAAoC,GAC1C,oBAAoB,EAAE,CAExB"}
@@ -0,0 +1,198 @@
1
+ import { z } from "zod";
2
+ import { normalizeConversationRunEvents } from "./conversation-run-event-normalization.js";
3
+ export const conversationRunEventTypes = {
4
+ custom: "CUSTOM",
5
+ textMessageStart: "TEXT_MESSAGE_START",
6
+ textMessageContent: "TEXT_MESSAGE_CONTENT",
7
+ textMessageEnd: "TEXT_MESSAGE_END",
8
+ reasoningMessageStart: "REASONING_MESSAGE_START",
9
+ reasoningMessageContent: "REASONING_MESSAGE_CONTENT",
10
+ reasoningMessageEnd: "REASONING_MESSAGE_END",
11
+ toolCallStart: "TOOL_CALL_START",
12
+ toolCallArgs: "TOOL_CALL_ARGS",
13
+ toolCallEnd: "TOOL_CALL_END",
14
+ toolCallResult: "TOOL_CALL_RESULT",
15
+ };
16
+ export const ConversationRunEventSchema = z.object({
17
+ type: z.string().min(1),
18
+ }).passthrough();
19
+ function serializeToolInput(input) {
20
+ try {
21
+ return JSON.stringify(input ?? {});
22
+ }
23
+ catch {
24
+ return "{}";
25
+ }
26
+ }
27
+ function encodeCustomDataEvent(chunk) {
28
+ const name = chunk.type.slice("data-".length);
29
+ if (name.length === 0) {
30
+ return [];
31
+ }
32
+ return [{
33
+ type: conversationRunEventTypes.custom,
34
+ name,
35
+ value: chunk.data,
36
+ }];
37
+ }
38
+ export class ConversationRunEventEncoder {
39
+ streamedToolInputs = new Set();
40
+ toolInputs = new Map();
41
+ activeMessageId = null;
42
+ getToolResultMessageId(toolCallId) {
43
+ return this.activeMessageId
44
+ ? `${this.activeMessageId}:tool:${toolCallId}`
45
+ : `tool:${toolCallId}`;
46
+ }
47
+ serializeToolResultContent(value) {
48
+ if (typeof value === "string") {
49
+ return value;
50
+ }
51
+ try {
52
+ return JSON.stringify(value ?? null);
53
+ }
54
+ catch {
55
+ return String(value);
56
+ }
57
+ }
58
+ encode(chunk) {
59
+ switch (chunk.type) {
60
+ case "start":
61
+ this.activeMessageId = chunk.messageId ?? null;
62
+ return [];
63
+ case "text-start":
64
+ return [{
65
+ type: conversationRunEventTypes.textMessageStart,
66
+ messageId: chunk.id,
67
+ role: "assistant",
68
+ }];
69
+ case "text-delta":
70
+ return [{
71
+ type: conversationRunEventTypes.textMessageContent,
72
+ messageId: chunk.id,
73
+ delta: chunk.delta,
74
+ }];
75
+ case "text-end":
76
+ return [{ type: conversationRunEventTypes.textMessageEnd, messageId: chunk.id }];
77
+ case "reasoning-start":
78
+ return [{
79
+ type: conversationRunEventTypes.reasoningMessageStart,
80
+ messageId: chunk.id,
81
+ role: "assistant",
82
+ }];
83
+ case "reasoning-delta":
84
+ return [{
85
+ type: conversationRunEventTypes.reasoningMessageContent,
86
+ messageId: chunk.id,
87
+ delta: chunk.delta,
88
+ }];
89
+ case "reasoning-end":
90
+ return [{ type: conversationRunEventTypes.reasoningMessageEnd, messageId: chunk.id }];
91
+ case "tool-input-start":
92
+ return [{
93
+ type: conversationRunEventTypes.toolCallStart,
94
+ toolCallId: chunk.toolCallId,
95
+ toolCallName: chunk.toolName,
96
+ }];
97
+ case "tool-input-delta":
98
+ this.streamedToolInputs.add(chunk.toolCallId);
99
+ return [{
100
+ type: conversationRunEventTypes.toolCallArgs,
101
+ toolCallId: chunk.toolCallId,
102
+ delta: chunk.inputTextDelta,
103
+ }];
104
+ case "tool-input-available": {
105
+ this.toolInputs.set(chunk.toolCallId, chunk.input);
106
+ const events = [];
107
+ if (!this.streamedToolInputs.has(chunk.toolCallId)) {
108
+ events.push({
109
+ type: conversationRunEventTypes.toolCallArgs,
110
+ toolCallId: chunk.toolCallId,
111
+ delta: serializeToolInput(chunk.input),
112
+ });
113
+ }
114
+ events.push({ type: conversationRunEventTypes.toolCallEnd, toolCallId: chunk.toolCallId });
115
+ return events;
116
+ }
117
+ case "tool-input-error": {
118
+ this.toolInputs.set(chunk.toolCallId, chunk.input);
119
+ const events = [];
120
+ if (!this.streamedToolInputs.has(chunk.toolCallId)) {
121
+ events.push({
122
+ type: conversationRunEventTypes.toolCallArgs,
123
+ toolCallId: chunk.toolCallId,
124
+ delta: serializeToolInput(chunk.input),
125
+ });
126
+ }
127
+ events.push({ type: conversationRunEventTypes.toolCallEnd, toolCallId: chunk.toolCallId });
128
+ events.push({
129
+ type: conversationRunEventTypes.toolCallResult,
130
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
131
+ toolCallId: chunk.toolCallId,
132
+ content: this.serializeToolResultContent(chunk.errorText),
133
+ role: "tool",
134
+ ...(this.toolInputs.has(chunk.toolCallId)
135
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
136
+ : {}),
137
+ isError: true,
138
+ });
139
+ this.toolInputs.delete(chunk.toolCallId);
140
+ return events;
141
+ }
142
+ case "tool-output-available":
143
+ return [{
144
+ type: conversationRunEventTypes.toolCallResult,
145
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
146
+ toolCallId: chunk.toolCallId,
147
+ content: this.serializeToolResultContent(chunk.output),
148
+ role: "tool",
149
+ ...(this.toolInputs.has(chunk.toolCallId)
150
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
151
+ : {}),
152
+ }];
153
+ case "tool-output-error":
154
+ return [{
155
+ type: conversationRunEventTypes.toolCallResult,
156
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
157
+ toolCallId: chunk.toolCallId,
158
+ content: this.serializeToolResultContent(chunk.errorText),
159
+ role: "tool",
160
+ ...(this.toolInputs.has(chunk.toolCallId)
161
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
162
+ : {}),
163
+ isError: true,
164
+ }];
165
+ case "tool-output-denied":
166
+ return [{
167
+ type: conversationRunEventTypes.toolCallResult,
168
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
169
+ toolCallId: chunk.toolCallId,
170
+ content: "Tool output denied",
171
+ role: "tool",
172
+ ...(this.toolInputs.has(chunk.toolCallId)
173
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
174
+ : {}),
175
+ isError: true,
176
+ }];
177
+ case "error":
178
+ case "finish":
179
+ case "abort":
180
+ case "message-metadata":
181
+ case "source-url":
182
+ case "source-document":
183
+ case "file":
184
+ case "tool-approval-request":
185
+ case "start-step":
186
+ case "finish-step":
187
+ return [];
188
+ default:
189
+ return chunk.type.startsWith("data-") ? encodeCustomDataEvent(chunk) : [];
190
+ }
191
+ }
192
+ }
193
+ export function encodeConversationRunEvents(events, encoder = new ConversationRunEventEncoder()) {
194
+ return events.flatMap((event) => encoder.encode(event));
195
+ }
196
+ export function normalizeEncodedConversationRunEvents(events, encoder = new ConversationRunEventEncoder()) {
197
+ return normalizeConversationRunEvents(encodeConversationRunEvents(events, encoder));
198
+ }
@@ -93,6 +93,9 @@ export { type ConversationRunContext, createConversationRunContext, } from "./co
93
93
  export { type ConversationRootRunContext, type ConversationRootRunDescriptor, createConversationRootRunContext, createConversationRootRunStartAdapter, prepareConversationRootRunContext, startConversationRootRun, } from "./conversation-root-run-context.js";
94
94
  export { bootstrapConversationAgentRun, type BootstrapConversationAgentRunResult, type ConversationMessageRecord, ConversationMessageRecordSchema, type ConversationRecord, ConversationRecordSchema, createConversationMessage, createConversationRecord, ensureConversationProjectLink, fetchConversationRecord, } from "./conversation-bootstrap.js";
95
95
  export { type ConversationChildLifecycleContext, type ConversationHostedLifecycleFinalizeInput, createConversationChildLifecycleAdapter, createConversationHostedLifecycleAdapter, type CreateConversationHostedLifecycleAdapterOptions, } from "./conversation-hosted-lifecycle.js";
96
+ export { getConversationRunEventJsonByteLength, normalizeConversationRunEvent, normalizeConversationRunEvents, } from "./conversation-run-event-normalization.js";
97
+ export { type ConversationRunEvent, ConversationRunEventEncoder, ConversationRunEventSchema, conversationRunEventTypes, encodeConversationRunEvents, normalizeEncodedConversationRunEvents, } from "./conversation-run-events.js";
98
+ export { prepareConversationRunExternalEvents, prepareConversationRunStreamEvents, } from "./conversation-run-event-preparation.js";
96
99
  export { type ConversationRunMirror, type ConversationRunMirrorRetryScheduledState, type ConversationRunMirrorSnapshot, type ConversationRunMirrorStoppedState, createConversationRunMirror, } from "./conversation-run-mirror.js";
97
100
  export { type ActiveConversationRunStatus, appendConversationRunEvents, AppendConversationRunEventsError, type AppendConversationRunEventsResponse, AppendConversationRunEventsResponseSchema, CompleteConversationRunResponseSchema, type ConversationAgentRunUsage, type ConversationRunAppendCursorResyncResult, type ConversationRunAppendExecutionOutcome, type ConversationRunAppendFailureOutcome, type ConversationRunAppendRecoveryOutcome, type ConversationRunBatchFlushOutcome, type ConversationRunEventQueueController, type ConversationRunProjection, ConversationRunProjectionSchema, type ConversationRunQueueFlushOutcome, ConversationRunStatusSchema, type ConversationRunTargets, ConversationRunTargetsSchema, ConversationRunTerminalStateError, createConversationAgentRun, createConversationRunEventQueueController, finalizeConversationAgentRun, flushConversationRunEventBatches, flushConversationRunEventQueue, getConversationRun, isActiveConversationRunStatus, isAppendableConversationRunProjection, isCursorMismatchConversationRunAppendError, isIgnorableConversationRunAppendError, monitorConversationRunStatus, parseAppendConversationRunEventsErrorBody, recoverConversationRunAppendExecution, recoverConversationRunAppendFailure, recoverConversationRunCursorMismatch, resolveConversationRunTargets, resyncConversationRunAppendCursor, type TerminalConversationRunStatus, } from "./durable.js";
98
101
  export { buildInvokeAgentChildRunLifecycleCustomEvent, buildInvokeAgentChildRunProgressEvents, buildInvokeAgentChildRunStateDelta, type InvokeAgentChildRunLifecycleCustomEvent, InvokeAgentChildRunLifecycleCustomEventSchema, type InvokeAgentChildRunLifecycleValue, InvokeAgentChildRunLifecycleValueSchema, type InvokeAgentChildRunProgressEvent, type InvokeAgentChildRunProgressInput, type InvokeAgentChildRunStateDelta, InvokeAgentChildRunStateDeltaSchema, publishInvokeAgentChildRunProgress, } from "./invoke-agent-child-runs.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,KAAK,EACL,WAAW,EAC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jB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/agent/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+EG;AACH,OAAO,yBAAyB,CAAC;AAGjC,YAAY,EACV,KAAK,EACL,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,YAAY,EACZ,OAAO,IAAI,YAAY,EACvB,WAAW,EACX,aAAa,EACb,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,iBAAiB,EACtB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,WAAW,EACX,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,GAClB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,KA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,EAC/B,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,wBAAwB,EAC7B,8BAA8B,EAC9B,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAC3B,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,4BAA4B,EAC5B,iBAAiB,EACjB,KAAK,wBAAwB,GAC9B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,KAAK,uBAAuB,EAC5B,KAAK,8BAA8B,EACnC,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAC7B,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC"}
@@ -92,6 +92,9 @@ export { createConversationRunContext, } from "./conversation-run-context.js";
92
92
  export { createConversationRootRunContext, createConversationRootRunStartAdapter, prepareConversationRootRunContext, startConversationRootRun, } from "./conversation-root-run-context.js";
93
93
  export { bootstrapConversationAgentRun, ConversationMessageRecordSchema, ConversationRecordSchema, createConversationMessage, createConversationRecord, ensureConversationProjectLink, fetchConversationRecord, } from "./conversation-bootstrap.js";
94
94
  export { createConversationChildLifecycleAdapter, createConversationHostedLifecycleAdapter, } from "./conversation-hosted-lifecycle.js";
95
+ export { getConversationRunEventJsonByteLength, normalizeConversationRunEvent, normalizeConversationRunEvents, } from "./conversation-run-event-normalization.js";
96
+ export { ConversationRunEventEncoder, ConversationRunEventSchema, conversationRunEventTypes, encodeConversationRunEvents, normalizeEncodedConversationRunEvents, } from "./conversation-run-events.js";
97
+ export { prepareConversationRunExternalEvents, prepareConversationRunStreamEvents, } from "./conversation-run-event-preparation.js";
95
98
  export { createConversationRunMirror, } from "./conversation-run-mirror.js";
96
99
  export { appendConversationRunEvents, AppendConversationRunEventsError, AppendConversationRunEventsResponseSchema, CompleteConversationRunResponseSchema, ConversationRunProjectionSchema, ConversationRunStatusSchema, ConversationRunTargetsSchema, ConversationRunTerminalStateError, createConversationAgentRun, createConversationRunEventQueueController, finalizeConversationAgentRun, flushConversationRunEventBatches, flushConversationRunEventQueue, getConversationRun, isActiveConversationRunStatus, isAppendableConversationRunProjection, isCursorMismatchConversationRunAppendError, isIgnorableConversationRunAppendError, monitorConversationRunStatus, parseAppendConversationRunEventsErrorBody, recoverConversationRunAppendExecution, recoverConversationRunAppendFailure, recoverConversationRunCursorMismatch, resolveConversationRunTargets, resyncConversationRunAppendCursor, } from "./durable.js";
97
100
  export { buildInvokeAgentChildRunLifecycleCustomEvent, buildInvokeAgentChildRunProgressEvents, buildInvokeAgentChildRunStateDelta, InvokeAgentChildRunLifecycleCustomEventSchema, InvokeAgentChildRunLifecycleValueSchema, InvokeAgentChildRunStateDeltaSchema, publishInvokeAgentChildRunProgress, } from "./invoke-agent-child-runs.js";
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.1.251";
1
+ export declare const VERSION = "0.1.254";
2
2
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.251";
3
+ export const VERSION = "0.1.254";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.251",
3
+ "version": "0.1.254",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",
package/src/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.251",
3
+ "version": "0.1.254",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -0,0 +1,228 @@
1
+ const MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES = 240 * 1024;
2
+ const MAX_SUMMARY_DEPTH = 4;
3
+ const MAX_SUMMARY_ARRAY_ITEMS = 8;
4
+ const MAX_SUMMARY_OBJECT_KEYS = 24;
5
+ const MAX_SUMMARY_STRING_BYTES = 8 * 1024;
6
+
7
+ const encoder = new TextEncoder();
8
+
9
+ type ConversationRunEventRecord = Record<string, unknown> & { type: string };
10
+
11
+ function hasStringField<TField extends "delta" | "content">(
12
+ event: ConversationRunEventRecord,
13
+ field: TField,
14
+ ): event is ConversationRunEventRecord & Record<TField, string> {
15
+ return typeof event[field] === "string";
16
+ }
17
+
18
+ export function getConversationRunEventJsonByteLength(value: unknown): number {
19
+ try {
20
+ return encoder.encode(JSON.stringify(value)).byteLength;
21
+ } catch {
22
+ return Number.POSITIVE_INFINITY;
23
+ }
24
+ }
25
+
26
+ export function normalizeConversationRunEvent(
27
+ event: ConversationRunEventRecord,
28
+ ): ConversationRunEventRecord[] {
29
+ if (getConversationRunEventJsonByteLength(event) <= MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES) {
30
+ return [event];
31
+ }
32
+
33
+ switch (event.type) {
34
+ case "TEXT_MESSAGE_CONTENT":
35
+ case "REASONING_CONTENT":
36
+ case "REASONING_MESSAGE_CONTENT":
37
+ case "TOOL_CALL_ARGS":
38
+ return hasStringField(event, "delta") ? splitStringFieldEvent(event, "delta") : [event];
39
+
40
+ case "TOOL_CALL_RESULT":
41
+ return [summarizeToolResultEvent(event)];
42
+
43
+ default:
44
+ return [summarizeGenericEvent(event)];
45
+ }
46
+ }
47
+
48
+ export function normalizeConversationRunEvents(
49
+ events: ConversationRunEventRecord[],
50
+ ): ConversationRunEventRecord[] {
51
+ return events.flatMap(normalizeConversationRunEvent);
52
+ }
53
+
54
+ function summarizeToolResultEvent(event: ConversationRunEventRecord): ConversationRunEventRecord {
55
+ if (event.type !== "TOOL_CALL_RESULT") {
56
+ return event;
57
+ }
58
+
59
+ if (typeof event.content === "string") {
60
+ const maxResultBytes = getStringFieldBudget(event, "content");
61
+ return {
62
+ ...event,
63
+ content: truncateUtf8String(
64
+ event.content,
65
+ maxResultBytes,
66
+ " [tool result truncated in conversation-run event]",
67
+ ),
68
+ };
69
+ }
70
+
71
+ const summarizedEvent = {
72
+ ...event,
73
+ content: summarizeValue(event.content),
74
+ } satisfies ConversationRunEventRecord;
75
+
76
+ if (
77
+ getConversationRunEventJsonByteLength(summarizedEvent) <=
78
+ MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES
79
+ ) {
80
+ return summarizedEvent;
81
+ }
82
+
83
+ return {
84
+ ...event,
85
+ content: {
86
+ truncated: true,
87
+ originalType: describeValueType(event.content),
88
+ note:
89
+ "Tool result omitted from the conversation-run event because it exceeded the payload size limit.",
90
+ },
91
+ };
92
+ }
93
+
94
+ function summarizeGenericEvent(event: ConversationRunEventRecord): ConversationRunEventRecord {
95
+ return {
96
+ ...event,
97
+ truncated: true,
98
+ note: "Conversation-run event payload was summarized to stay within storage limits.",
99
+ };
100
+ }
101
+
102
+ function splitStringFieldEvent<TField extends "delta" | "content">(
103
+ event: ConversationRunEventRecord & Record<TField, string>,
104
+ field: TField,
105
+ ): ConversationRunEventRecord[] {
106
+ const maxBytes = getStringFieldBudget(event, field);
107
+ const parts = splitUtf8String(event[field], maxBytes);
108
+ return parts.map((part) => ({ ...event, [field]: part }));
109
+ }
110
+
111
+ function getStringFieldBudget(
112
+ event: ConversationRunEventRecord,
113
+ field: "delta" | "content",
114
+ ): number {
115
+ const eventWithEmptyField = {
116
+ ...event,
117
+ [field]: "",
118
+ };
119
+
120
+ return Math.max(
121
+ 1,
122
+ MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES -
123
+ getConversationRunEventJsonByteLength(eventWithEmptyField),
124
+ );
125
+ }
126
+
127
+ function splitUtf8String(value: string, maxBytes: number): string[] {
128
+ if (encoder.encode(value).byteLength <= maxBytes) {
129
+ return [value];
130
+ }
131
+
132
+ const parts: string[] = [];
133
+ let startIndex = 0;
134
+
135
+ while (startIndex < value.length) {
136
+ let low = startIndex + 1;
137
+ let high = value.length;
138
+ let bestEndIndex = startIndex + 1;
139
+
140
+ while (low <= high) {
141
+ const mid = Math.floor((low + high) / 2);
142
+ const slice = value.slice(startIndex, mid);
143
+ if (encoder.encode(slice).byteLength <= maxBytes) {
144
+ bestEndIndex = mid;
145
+ low = mid + 1;
146
+ } else {
147
+ high = mid - 1;
148
+ }
149
+ }
150
+
151
+ parts.push(value.slice(startIndex, bestEndIndex));
152
+ startIndex = bestEndIndex;
153
+ }
154
+
155
+ return parts;
156
+ }
157
+
158
+ function truncateUtf8String(value: string, maxBytes: number, suffix: string): string {
159
+ if (encoder.encode(value).byteLength <= maxBytes) {
160
+ return value;
161
+ }
162
+
163
+ const suffixBytes = encoder.encode(suffix).byteLength;
164
+ if (suffixBytes >= maxBytes) {
165
+ return suffix.slice(0, Math.max(1, maxBytes));
166
+ }
167
+
168
+ const prefixBudget = maxBytes - suffixBytes;
169
+ const [prefix] = splitUtf8String(value, prefixBudget);
170
+ return `${prefix}${suffix}`;
171
+ }
172
+
173
+ function summarizeValue(value: unknown, depth = 0, seen: WeakSet<object> = new WeakSet()): unknown {
174
+ if (typeof value === "string") {
175
+ return truncateUtf8String(value, MAX_SUMMARY_STRING_BYTES, "… [truncated]");
176
+ }
177
+
178
+ if (value === null || typeof value !== "object") {
179
+ return value;
180
+ }
181
+
182
+ if (seen.has(value)) {
183
+ return "[circular]";
184
+ }
185
+
186
+ if (depth >= MAX_SUMMARY_DEPTH) {
187
+ return "[truncated nested data]";
188
+ }
189
+
190
+ seen.add(value);
191
+
192
+ if (Array.isArray(value)) {
193
+ const items = value
194
+ .slice(0, MAX_SUMMARY_ARRAY_ITEMS)
195
+ .map((item) => summarizeValue(item, depth + 1, seen));
196
+ if (value.length > MAX_SUMMARY_ARRAY_ITEMS) {
197
+ items.push(`[truncated ${value.length - MAX_SUMMARY_ARRAY_ITEMS} more items]`);
198
+ }
199
+ return items;
200
+ }
201
+
202
+ const entries = Object.entries(value);
203
+ const summarizedEntries = entries
204
+ .slice(0, MAX_SUMMARY_OBJECT_KEYS)
205
+ .map(([key, entryValue]) => [key, summarizeValue(entryValue, depth + 1, seen)] as const);
206
+ const summarizedObject = Object.fromEntries(summarizedEntries);
207
+
208
+ if (entries.length > MAX_SUMMARY_OBJECT_KEYS) {
209
+ return {
210
+ ...summarizedObject,
211
+ _truncatedKeys: entries.length - MAX_SUMMARY_OBJECT_KEYS,
212
+ };
213
+ }
214
+
215
+ return summarizedObject;
216
+ }
217
+
218
+ function describeValueType(value: unknown): string {
219
+ if (Array.isArray(value)) {
220
+ return "array";
221
+ }
222
+
223
+ if (value === null) {
224
+ return "null";
225
+ }
226
+
227
+ return typeof value;
228
+ }
@@ -0,0 +1,20 @@
1
+ import { type ChatStreamEvent } from "../chat/protocol.js";
2
+ import {
3
+ type ConversationRunEvent,
4
+ ConversationRunEventEncoder,
5
+ encodeConversationRunEvents,
6
+ } from "./conversation-run-events.js";
7
+ import { normalizeConversationRunEvents } from "./conversation-run-event-normalization.js";
8
+
9
+ export function prepareConversationRunStreamEvents(
10
+ events: ChatStreamEvent[],
11
+ encoder = new ConversationRunEventEncoder(),
12
+ ): ConversationRunEvent[] {
13
+ return normalizeConversationRunEvents(encodeConversationRunEvents(events, encoder));
14
+ }
15
+
16
+ export function prepareConversationRunExternalEvents(
17
+ events: ConversationRunEvent[],
18
+ ): ConversationRunEvent[] {
19
+ return normalizeConversationRunEvents(events);
20
+ }
@@ -0,0 +1,234 @@
1
+ import { z } from "zod";
2
+ import { type ChatStreamEvent } from "../chat/protocol.js";
3
+ import { normalizeConversationRunEvents } from "./conversation-run-event-normalization.js";
4
+
5
+ export const conversationRunEventTypes = {
6
+ custom: "CUSTOM",
7
+ textMessageStart: "TEXT_MESSAGE_START",
8
+ textMessageContent: "TEXT_MESSAGE_CONTENT",
9
+ textMessageEnd: "TEXT_MESSAGE_END",
10
+ reasoningMessageStart: "REASONING_MESSAGE_START",
11
+ reasoningMessageContent: "REASONING_MESSAGE_CONTENT",
12
+ reasoningMessageEnd: "REASONING_MESSAGE_END",
13
+ toolCallStart: "TOOL_CALL_START",
14
+ toolCallArgs: "TOOL_CALL_ARGS",
15
+ toolCallEnd: "TOOL_CALL_END",
16
+ toolCallResult: "TOOL_CALL_RESULT",
17
+ } as const;
18
+
19
+ export const ConversationRunEventSchema = z.object({
20
+ type: z.string().min(1),
21
+ }).passthrough();
22
+
23
+ export type ConversationRunEvent = z.infer<typeof ConversationRunEventSchema>;
24
+
25
+ function serializeToolInput(input: unknown): string {
26
+ try {
27
+ return JSON.stringify(input ?? {});
28
+ } catch {
29
+ return "{}";
30
+ }
31
+ }
32
+
33
+ function encodeCustomDataEvent(
34
+ chunk: Extract<ChatStreamEvent, { type: `data-${string}` }>,
35
+ ): ConversationRunEvent[] {
36
+ const name = chunk.type.slice("data-".length);
37
+ if (name.length === 0) {
38
+ return [];
39
+ }
40
+
41
+ return [{
42
+ type: conversationRunEventTypes.custom,
43
+ name,
44
+ value: chunk.data,
45
+ }];
46
+ }
47
+
48
+ export class ConversationRunEventEncoder {
49
+ private readonly streamedToolInputs = new Set<string>();
50
+ private readonly toolInputs = new Map<string, unknown>();
51
+ private activeMessageId: string | null = null;
52
+
53
+ private getToolResultMessageId(toolCallId: string) {
54
+ return this.activeMessageId
55
+ ? `${this.activeMessageId}:tool:${toolCallId}`
56
+ : `tool:${toolCallId}`;
57
+ }
58
+
59
+ private serializeToolResultContent(value: unknown): string {
60
+ if (typeof value === "string") {
61
+ return value;
62
+ }
63
+
64
+ try {
65
+ return JSON.stringify(value ?? null);
66
+ } catch {
67
+ return String(value);
68
+ }
69
+ }
70
+
71
+ encode(chunk: ChatStreamEvent): ConversationRunEvent[] {
72
+ switch (chunk.type) {
73
+ case "start":
74
+ this.activeMessageId = chunk.messageId ?? null;
75
+ return [];
76
+
77
+ case "text-start":
78
+ return [{
79
+ type: conversationRunEventTypes.textMessageStart,
80
+ messageId: chunk.id,
81
+ role: "assistant",
82
+ }];
83
+
84
+ case "text-delta":
85
+ return [{
86
+ type: conversationRunEventTypes.textMessageContent,
87
+ messageId: chunk.id,
88
+ delta: chunk.delta,
89
+ }];
90
+
91
+ case "text-end":
92
+ return [{ type: conversationRunEventTypes.textMessageEnd, messageId: chunk.id }];
93
+
94
+ case "reasoning-start":
95
+ return [{
96
+ type: conversationRunEventTypes.reasoningMessageStart,
97
+ messageId: chunk.id,
98
+ role: "assistant",
99
+ }];
100
+
101
+ case "reasoning-delta":
102
+ return [{
103
+ type: conversationRunEventTypes.reasoningMessageContent,
104
+ messageId: chunk.id,
105
+ delta: chunk.delta,
106
+ }];
107
+
108
+ case "reasoning-end":
109
+ return [{ type: conversationRunEventTypes.reasoningMessageEnd, messageId: chunk.id }];
110
+
111
+ case "tool-input-start":
112
+ return [{
113
+ type: conversationRunEventTypes.toolCallStart,
114
+ toolCallId: chunk.toolCallId,
115
+ toolCallName: chunk.toolName,
116
+ }];
117
+
118
+ case "tool-input-delta":
119
+ this.streamedToolInputs.add(chunk.toolCallId);
120
+ return [{
121
+ type: conversationRunEventTypes.toolCallArgs,
122
+ toolCallId: chunk.toolCallId,
123
+ delta: chunk.inputTextDelta,
124
+ }];
125
+
126
+ case "tool-input-available": {
127
+ this.toolInputs.set(chunk.toolCallId, chunk.input);
128
+ const events: ConversationRunEvent[] = [];
129
+ if (!this.streamedToolInputs.has(chunk.toolCallId)) {
130
+ events.push({
131
+ type: conversationRunEventTypes.toolCallArgs,
132
+ toolCallId: chunk.toolCallId,
133
+ delta: serializeToolInput(chunk.input),
134
+ });
135
+ }
136
+ events.push({ type: conversationRunEventTypes.toolCallEnd, toolCallId: chunk.toolCallId });
137
+ return events;
138
+ }
139
+
140
+ case "tool-input-error": {
141
+ this.toolInputs.set(chunk.toolCallId, chunk.input);
142
+ const events: ConversationRunEvent[] = [];
143
+ if (!this.streamedToolInputs.has(chunk.toolCallId)) {
144
+ events.push({
145
+ type: conversationRunEventTypes.toolCallArgs,
146
+ toolCallId: chunk.toolCallId,
147
+ delta: serializeToolInput(chunk.input),
148
+ });
149
+ }
150
+ events.push({ type: conversationRunEventTypes.toolCallEnd, toolCallId: chunk.toolCallId });
151
+ events.push({
152
+ type: conversationRunEventTypes.toolCallResult,
153
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
154
+ toolCallId: chunk.toolCallId,
155
+ content: this.serializeToolResultContent(chunk.errorText),
156
+ role: "tool",
157
+ ...(this.toolInputs.has(chunk.toolCallId)
158
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
159
+ : {}),
160
+ isError: true,
161
+ });
162
+ this.toolInputs.delete(chunk.toolCallId);
163
+ return events;
164
+ }
165
+
166
+ case "tool-output-available":
167
+ return [{
168
+ type: conversationRunEventTypes.toolCallResult,
169
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
170
+ toolCallId: chunk.toolCallId,
171
+ content: this.serializeToolResultContent(chunk.output),
172
+ role: "tool",
173
+ ...(this.toolInputs.has(chunk.toolCallId)
174
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
175
+ : {}),
176
+ }];
177
+
178
+ case "tool-output-error":
179
+ return [{
180
+ type: conversationRunEventTypes.toolCallResult,
181
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
182
+ toolCallId: chunk.toolCallId,
183
+ content: this.serializeToolResultContent(chunk.errorText),
184
+ role: "tool",
185
+ ...(this.toolInputs.has(chunk.toolCallId)
186
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
187
+ : {}),
188
+ isError: true,
189
+ }];
190
+
191
+ case "tool-output-denied":
192
+ return [{
193
+ type: conversationRunEventTypes.toolCallResult,
194
+ messageId: this.getToolResultMessageId(chunk.toolCallId),
195
+ toolCallId: chunk.toolCallId,
196
+ content: "Tool output denied",
197
+ role: "tool",
198
+ ...(this.toolInputs.has(chunk.toolCallId)
199
+ ? { input: this.toolInputs.get(chunk.toolCallId) }
200
+ : {}),
201
+ isError: true,
202
+ }];
203
+
204
+ case "error":
205
+ case "finish":
206
+ case "abort":
207
+ case "message-metadata":
208
+ case "source-url":
209
+ case "source-document":
210
+ case "file":
211
+ case "tool-approval-request":
212
+ case "start-step":
213
+ case "finish-step":
214
+ return [];
215
+
216
+ default:
217
+ return chunk.type.startsWith("data-") ? encodeCustomDataEvent(chunk) : [];
218
+ }
219
+ }
220
+ }
221
+
222
+ export function encodeConversationRunEvents(
223
+ events: ChatStreamEvent[],
224
+ encoder = new ConversationRunEventEncoder(),
225
+ ): ConversationRunEvent[] {
226
+ return events.flatMap((event) => encoder.encode(event));
227
+ }
228
+
229
+ export function normalizeEncodedConversationRunEvents(
230
+ events: ChatStreamEvent[],
231
+ encoder = new ConversationRunEventEncoder(),
232
+ ): ConversationRunEvent[] {
233
+ return normalizeConversationRunEvents(encodeConversationRunEvents(events, encoder));
234
+ }
@@ -211,6 +211,23 @@ export {
211
211
  createConversationHostedLifecycleAdapter,
212
212
  type CreateConversationHostedLifecycleAdapterOptions,
213
213
  } from "./conversation-hosted-lifecycle.js";
214
+ export {
215
+ getConversationRunEventJsonByteLength,
216
+ normalizeConversationRunEvent,
217
+ normalizeConversationRunEvents,
218
+ } from "./conversation-run-event-normalization.js";
219
+ export {
220
+ type ConversationRunEvent,
221
+ ConversationRunEventEncoder,
222
+ ConversationRunEventSchema,
223
+ conversationRunEventTypes,
224
+ encodeConversationRunEvents,
225
+ normalizeEncodedConversationRunEvents,
226
+ } from "./conversation-run-events.js";
227
+ export {
228
+ prepareConversationRunExternalEvents,
229
+ prepareConversationRunStreamEvents,
230
+ } from "./conversation-run-event-preparation.js";
214
231
  export {
215
232
  type ConversationRunMirror,
216
233
  type ConversationRunMirrorRetryScheduledState,
@@ -1,3 +1,3 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
- export const VERSION = "0.1.251";
3
+ export const VERSION = "0.1.254";