veryfront 0.1.1010 → 0.1.1011

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.1010",
3
+ "version": "0.1.1011",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -1 +1 @@
1
- {"version":3,"file":"run-event-normalization.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/conversation/run-event-normalization.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wCAAwC,QAAa,CAAC;AAQnE,KAAK,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAS7E,sDAAsD;AACtD,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM5E;AAED,oDAAoD;AACpD,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,0BAA0B,GAChC,0BAA0B,EAAE,CAQ9B;AAgDD,0CAA0C;AAC1C,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,0BAA0B,EAAE,GACnC,0BAA0B,EAAE,CAE9B"}
1
+ {"version":3,"file":"run-event-normalization.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/conversation/run-event-normalization.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wCAAwC,QAAa,CAAC;AASnE,KAAK,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAS7E,sDAAsD;AACtD,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAM5E;AAED,oDAAoD;AACpD,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,0BAA0B,GAChC,0BAA0B,EAAE,CAQ9B;AA0CD,0CAA0C;AAC1C,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,0BAA0B,EAAE,GACnC,0BAA0B,EAAE,CAE9B"}
@@ -1,4 +1,5 @@
1
1
  export const MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES = 240 * 1024;
2
+ const OMITTED_CONVERSATION_RUN_EVENT_TYPE = "CUSTOM";
2
3
  const MAX_SUMMARY_DEPTH = 4;
3
4
  const MAX_SUMMARY_ARRAY_ITEMS = 8;
4
5
  const MAX_SUMMARY_OBJECT_KEYS = 24;
@@ -55,13 +56,7 @@ function enforceEventSizeLimit(event) {
55
56
  }
56
57
  }
57
58
  }
58
- return {
59
- type: event.type,
60
- ...(typeof event.messageId === "string" ? { messageId: event.messageId } : {}),
61
- ...(typeof event.toolCallId === "string" ? { toolCallId: event.toolCallId } : {}),
62
- truncated: true,
63
- note: "Conversation-run event payload exceeded the size limit and was omitted.",
64
- };
59
+ return buildOmittedEvent(event);
65
60
  }
66
61
  /** Normalizes conversation run events. */
67
62
  export function normalizeConversationRunEvents(events) {
@@ -139,6 +134,36 @@ function truncateEventStringFieldToLimit(event, field, suffix) {
139
134
  }
140
135
  return buildCandidate(best);
141
136
  }
137
+ function addStringFieldWithinLimit(event, field, value) {
138
+ const candidate = { ...event, [field]: value };
139
+ if (getConversationRunEventJsonByteLength(candidate) <= MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES) {
140
+ return candidate;
141
+ }
142
+ return truncateEventStringFieldToLimit(candidate, field, " [truncated]") ?? event;
143
+ }
144
+ function buildOmittedEvent(event) {
145
+ let omitted = {
146
+ type: OMITTED_CONVERSATION_RUN_EVENT_TYPE,
147
+ name: "conversation-run-event-omitted",
148
+ truncated: true,
149
+ note: "Conversation-run event payload exceeded the size limit and was omitted.",
150
+ };
151
+ omitted = addStringFieldWithinLimit(omitted, "originalType", event.type);
152
+ if (typeof event.messageId === "string") {
153
+ omitted = addStringFieldWithinLimit(omitted, "originalMessageId", event.messageId);
154
+ }
155
+ if (typeof event.toolCallId === "string") {
156
+ omitted = addStringFieldWithinLimit(omitted, "originalToolCallId", event.toolCallId);
157
+ }
158
+ if (getConversationRunEventJsonByteLength(omitted) <= MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES) {
159
+ return omitted;
160
+ }
161
+ return {
162
+ type: OMITTED_CONVERSATION_RUN_EVENT_TYPE,
163
+ name: "conversation-run-event-omitted",
164
+ truncated: true,
165
+ };
166
+ }
142
167
  function summarizeGenericEvent(event) {
143
168
  const { type, ...rest } = event;
144
169
  return {
@@ -149,17 +174,38 @@ function summarizeGenericEvent(event) {
149
174
  };
150
175
  }
151
176
  function splitStringFieldEvent(event, field) {
152
- const maxBytes = getStringFieldBudget(event, field);
153
- const parts = splitUtf8String(event[field], maxBytes);
154
- return parts.map((part) => ({ ...event, [field]: part }));
155
- }
156
- function getStringFieldBudget(event, field) {
157
- const eventWithEmptyField = {
158
- ...event,
159
- [field]: "",
160
- };
161
- return Math.max(1, MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES -
162
- getConversationRunEventJsonByteLength(eventWithEmptyField));
177
+ const value = event[field];
178
+ const buildPart = (slice) => ({ ...event, [field]: slice });
179
+ const parts = [];
180
+ let startIndex = 0;
181
+ while (startIndex < value.length) {
182
+ // Largest prefix whose WHOLE serialized event fits the byte limit. Measuring the
183
+ // event (not the raw slice) keeps the split correct for escape-heavy content that
184
+ // expands under JSON.stringify — the same unit the API enforces — so every part
185
+ // fits without the size-limit backstop having to truncate (drop) any data.
186
+ let low = startIndex + 1;
187
+ let high = value.length;
188
+ let bestEndIndex = -1;
189
+ while (low <= high) {
190
+ const mid = Math.floor((low + high) / 2);
191
+ if (getConversationRunEventJsonByteLength(buildPart(value.slice(startIndex, mid))) <=
192
+ MAX_CONVERSATION_RUN_EVENT_PAYLOAD_BYTES) {
193
+ bestEndIndex = mid;
194
+ low = mid + 1;
195
+ }
196
+ else {
197
+ high = mid - 1;
198
+ }
199
+ }
200
+ if (bestEndIndex <= startIndex) {
201
+ // Even a single character overflows the envelope; hand off to the size-limit
202
+ // backstop rather than loop forever emitting zero-progress parts.
203
+ return [event];
204
+ }
205
+ parts.push(buildPart(value.slice(startIndex, bestEndIndex)));
206
+ startIndex = bestEndIndex;
207
+ }
208
+ return parts.length > 0 ? parts : [event];
163
209
  }
164
210
  function splitUtf8String(value, maxBytes) {
165
211
  if (encoder.encode(value).byteLength <= maxBytes) {
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.1010";
2
+ export declare const VERSION = "0.1.1011";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.1010";
4
+ export const VERSION = "0.1.1011";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.1010",
3
+ "version": "0.1.1011",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",