veryfront 0.1.252 → 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.252",
3
+ "version": "0.1.254",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -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
+ }
@@ -94,6 +94,8 @@ export { type ConversationRootRunContext, type ConversationRootRunDescriptor, cr
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
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";
97
99
  export { type ConversationRunMirror, type ConversationRunMirrorRetryScheduledState, type ConversationRunMirrorSnapshot, type ConversationRunMirrorStoppedState, createConversationRunMirror, } from "./conversation-run-mirror.js";
98
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";
99
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,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,O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ACvB,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"}
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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BAAiB,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"}
@@ -93,6 +93,8 @@ export { createConversationRootRunContext, createConversationRootRunStartAdapter
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
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";
96
98
  export { createConversationRunMirror, } from "./conversation-run-mirror.js";
97
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";
98
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.252";
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.252";
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.252",
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.252",
3
+ "version": "0.1.254",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -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
+ }
@@ -216,6 +216,18 @@ export {
216
216
  normalizeConversationRunEvent,
217
217
  normalizeConversationRunEvents,
218
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";
219
231
  export {
220
232
  type ConversationRunMirror,
221
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.252";
3
+ export const VERSION = "0.1.254";