veryfront 0.1.643 → 0.1.645

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.643",
3
+ "version": "0.1.645",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "workspace": [
@@ -1 +1 @@
1
- {"version":3,"file":"browser-encoder.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/ag-ui/browser-encoder.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,8CAA8C;AAC9C,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhF,mEAAmE;AACnE,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,uCAAuC;AACvC,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,8BAA8B,CAAC;CAC1C;AAED,+CAA+C;AA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I,CAAC;IAClC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,QAAQ,EAAE,8BAA8B,CAAC;CAC1C;AAED,+CAA+C;AAC/C,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,8CAA8C;AAC9C,wBAAgB,6BAA6B,IAAI,uBAAuB,CAYvE;AA6FD,yDAAyD;AACzD,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,8BAA8B,GACvC,aAAa,GAAG,IAAI,CA6BtB;AA4HD,wDAAwD;AACxD,wBAAgB,wCAAwC,CACtD,KAAK,EAAE,uBAAuB,EAC9B,KAAK,EAAE,sBAAsB,GAC5B,uBAAuB,EAAE,CAkN3B;AAED,4CAA4C;AAC5C,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,uBAAuB,EAC9B,QAAQ,EAAE,aAAa,GAAG,IAAI,GAC7B,uBAAuB,EAAE,CA8B3B"}
@@ -296,11 +296,15 @@ export function mapRuntimeStreamEventToAgUiBrowserEvents(state, event) {
296
296
  ];
297
297
  case "tool-input-available": {
298
298
  state.sawVisibleOutput = true;
299
- return [
299
+ const events = [
300
300
  ...closeOpenTextEvent(state),
301
301
  ...closeOpenReasoningEvent(state),
302
302
  ...completeToolInput(state, event),
303
303
  ];
304
+ if (event.providerExecuted === true) {
305
+ events.push(createToolResultEvent(event.toolCallId, null));
306
+ }
307
+ return events;
304
308
  }
305
309
  case "tool-input-error": {
306
310
  state.sawVisibleOutput = true;
@@ -15,7 +15,7 @@ export type NormalizedHostedChatRequest = {
15
15
  parentMessageId: string | undefined;
16
16
  };
17
17
  /** Options accepted by prepare hosted chat runtime messages. */
18
- export type PrepareHostedChatRuntimeMessagesOptions = Pick<PrepareAgentRuntimeMessagesFromUiMessagesOptions, "emptyConversationPrompt"> & {
18
+ export type PrepareHostedChatRuntimeMessagesOptions = Pick<PrepareAgentRuntimeMessagesFromUiMessagesOptions, "emptyConversationPrompt" | "providerOwnedToolNames"> & {
19
19
  authToken?: string;
20
20
  apiUrl?: string | URL;
21
21
  projectId?: string | null;
@@ -47,6 +47,7 @@ export type HostedChatRuntimeCreationPreparationInput<TRuntimeAgentDefinition> =
47
47
  model?: string;
48
48
  thinking?: RuntimeAgentThinkingConfig;
49
49
  maxSteps?: number;
50
+ allowedRemoteTools?: unknown;
50
51
  };
51
52
  projectId: string | null;
52
53
  authToken: string;
@@ -79,6 +80,7 @@ export type HostedChatExecutionPreparationInput<TRuntimeAgentDefinition extends
79
80
  model?: string;
80
81
  thinking?: RuntimeAgentThinkingConfig;
81
82
  maxSteps?: number;
83
+ allowedRemoteTools?: unknown;
82
84
  }, TRuntimeResult extends HostedChatRuntimeCreationResult> = {
83
85
  request: ParsedHostedChatRequest;
84
86
  agentConfig: TRuntimeAgentDefinition;
@@ -113,6 +115,7 @@ export declare function prepareHostedChatExecution<TRuntimeAgentDefinition exten
113
115
  model?: string;
114
116
  thinking?: RuntimeAgentThinkingConfig;
115
117
  maxSteps?: number;
118
+ allowedRemoteTools?: unknown;
116
119
  }, TRuntimeResult extends HostedChatRuntimeCreationResult>(input: HostedChatExecutionPreparationInput<TRuntimeAgentDefinition, TRuntimeResult>): Promise<HostedChatExecutionPreparationResult<TRuntimeAgentDefinition, TRuntimeResult>>;
117
120
  /** Prepare hosted chat runtime messages. */
118
121
  export declare function prepareHostedChatRuntimeMessages(messages: readonly ChatUiMessage[], options?: PrepareHostedChatRuntimeMessagesOptions): Promise<AgentRuntimeMessage[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-preparation.ts"],"names":[],"mappings":"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ACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,EACD,cAAc,SAAS,+BAA+B,EAEtD,KAAK,EAAE,mCAAmC,CACxC,uBAAuB,EACvB,cAAc,CACf,GACA,OAAO,CACR,oCAAoC,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAC9E,CAmDA;AAED,4CAA4C;AAC5C,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,OAAO,GAAE,uCAA4C,GACpD,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAqBhC"}
1
+ {"version":3,"file":"chat-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/hosted/chat-preparation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,KAAK,EACV,gCAAgC,EAChC,+BAA+B,EAEhC,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EACL,KAAK,gCAAgC,EAErC,KAAK,4CAA4C,EAClD,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEL,KAAK,gDAAgD,EACtD,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACL,KAAK,kCAAkC,EAExC,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAE3E,kDAAkD;AAClD,MAAM,MAAM,2BAA2B,GAAG;IACxC,iBAAiB,EAAE,aAAa,EAAE,CAAC;IACnC,yBAAyB,EAAE,kBAAkB,CAAC;IAC9C,eAAe,EAAE,M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IACrC,QAAQ,EAAE,0CAA0C,CAClD,uBAAuB,CACxB,CAAC,UAAU,CAAC,CAAC;IACd,aAAa,EAAE,kCAAkC,CAAC;CACnD,CAAC;AAEF,wDAAwD;AACxD,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,uBAAuB,GAC/B,2BAA2B,CAgB7B;AAgBD,gEAAgE;AAChE,wBAAsB,uCAAuC,CAC3D,uBAAuB,EAEvB,KAAK,EAAE,yCAAyC,CAAC,uBAAuB,CAAC,GACxE,OAAO,CAAC,0CAA0C,CAAC,uBAAuB,CAAC,CAAC,CA+D9E;AAED,qCAAqC;AACrC,wBAAsB,0BAA0B,CAC9C,uBAAuB,SAAS;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,EACD,cAAc,SAAS,+BAA+B,EAEtD,KAAK,EAAE,mCAAmC,CACxC,uBAAuB,EACvB,cAAc,CACf,GACA,OAAO,CACR,oCAAoC,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAC9E,CAoDA;AAED,4CAA4C;AAC5C,wBAAsB,gCAAgC,CACpD,QAAQ,EAAE,SAAS,aAAa,EAAE,EAClC,OAAO,GAAE,uCAA4C,GACpD,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAuBhC"}
@@ -2,6 +2,11 @@ import { prepareHostedConversationRootRunContext, } from "../conversation/root-r
2
2
  import { prepareAgentRuntimeMessagesFromUiMessages, } from "../runtime/message-preparation.js";
3
3
  import { resolveHostedRuntimeRequestConfig, } from "./runtime-request-config.js";
4
4
  import { getRuntimeUploadUrl } from "../runtime/upload-url-client.js";
5
+ function getAllowedRemoteToolNames(agentConfig) {
6
+ return Array.isArray(agentConfig.allowedRemoteTools)
7
+ ? agentConfig.allowedRemoteTools.filter((toolName) => typeof toolName === "string" && toolName.length > 0)
8
+ : [];
9
+ }
5
10
  /** Request payload for normalize parsed hosted chat. */
6
11
  export function normalizeParsedHostedChatRequest(request) {
7
12
  const effectiveMessages = request.messages;
@@ -127,6 +132,7 @@ export async function prepareHostedChatExecution(input) {
127
132
  authToken: input.request.authToken,
128
133
  apiUrl: input.apiUrl,
129
134
  projectId: input.request.projectId,
135
+ providerOwnedToolNames: getAllowedRemoteToolNames(input.agentConfig),
130
136
  });
131
137
  return {
132
138
  ...normalized,
@@ -143,6 +149,7 @@ export async function prepareHostedChatRuntimeMessages(messages, options = {}) {
143
149
  return await prepareAgentRuntimeMessagesFromUiMessages({
144
150
  messages,
145
151
  emptyConversationPrompt: options.emptyConversationPrompt,
152
+ providerOwnedToolNames: options.providerOwnedToolNames,
146
153
  });
147
154
  }
148
155
  const authToken = options.authToken;
@@ -150,6 +157,7 @@ export async function prepareHostedChatRuntimeMessages(messages, options = {}) {
150
157
  return await prepareAgentRuntimeMessagesFromUiMessages({
151
158
  messages,
152
159
  emptyConversationPrompt: options.emptyConversationPrompt,
160
+ providerOwnedToolNames: options.providerOwnedToolNames,
153
161
  resolveFileUrl: ({ uploadId }) => getRuntimeUploadUrl({
154
162
  apiUrl,
155
163
  authToken,
@@ -6,6 +6,7 @@ export type PrepareAgentRuntimeMessagesFromUiMessagesOptions = {
6
6
  messages: readonly ChatUiMessage[];
7
7
  emptyConversationPrompt?: string;
8
8
  resolveFileUrl?: RuntimeFileUrlResolver;
9
+ providerOwnedToolNames?: readonly string[];
9
10
  };
10
11
  /** Prepare agent runtime messages from UI messages. */
11
12
  export declare function prepareAgentRuntimeMessagesFromUiMessages(options: PrepareAgentRuntimeMessagesFromUiMessagesOptions): Promise<AgentRuntimeMessage[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"message-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/message-preparation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,2EAA2E;AAC3E,MAAM,MAAM,gDAAgD,GAAG;IAC7D,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC,CAAC;AAEF,uDAAuD;AACvD,wBAAsB,yCAAyC,CAC7D,OAAO,EAAE,gDAAgD,GACxD,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAiBhC"}
1
+ {"version":3,"file":"message-preparation.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/message-preparation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,+BAA+B,CAAC;AAKvC,2EAA2E;AAC3E,MAAM,MAAM,gDAAgD,GAAG;IAC7D,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAC;IACnC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,sBAAsB,CAAC;IACxC,sBAAsB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5C,CAAC;AAEF,uDAAuD;AACvD,wBAAsB,yCAAyC,CAC7D,OAAO,EAAE,gDAAgD,GACxD,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAmBhC"}
@@ -15,7 +15,9 @@ export async function prepareAgentRuntimeMessagesFromUiMessages(options) {
15
15
  const refreshedMessages = options.resolveFileUrl
16
16
  ? await resolveRuntimeMessageFileUrls(options.messages, options.resolveFileUrl)
17
17
  : [...options.messages];
18
- return convertProviderMessagesToAgentRuntimeMessages(prepareProviderModelMessagesFromUiMessages(refreshedMessages));
18
+ return convertProviderMessagesToAgentRuntimeMessages(prepareProviderModelMessagesFromUiMessages(refreshedMessages, {
19
+ providerOwnedToolNames: options.providerOwnedToolNames,
20
+ }));
19
21
  }
20
22
  function isEmptyConversation(messages) {
21
23
  if (messages.length === 0)
@@ -1,4 +1,8 @@
1
1
  import { type ChatUiMessage, type ProviderModelMessage } from "./types.js";
2
+ /** Options accepted by prepare provider model messages from UI messages. */
3
+ export interface PrepareProviderModelMessagesFromUiMessagesOptions {
4
+ providerOwnedToolNames?: readonly string[];
5
+ }
2
6
  /** Estimate tokens. */
3
7
  export declare function estimateTokens(value: unknown): number;
4
8
  /** Compress turn. */
@@ -16,7 +20,7 @@ export declare function stripPendingToolParts(messages: ChatUiMessage[]): ChatUi
16
20
  /** Sanitize provider model messages. */
17
21
  export declare function sanitizeProviderModelMessages(messages: ProviderModelMessage[]): ProviderModelMessage[];
18
22
  /** Prepare provider model messages from UI messages. */
19
- export declare function prepareProviderModelMessagesFromUiMessages(messages: ChatUiMessage[]): ProviderModelMessage[];
23
+ export declare function prepareProviderModelMessagesFromUiMessages(messages: ChatUiMessage[], options?: PrepareProviderModelMessagesFromUiMessagesOptions): ProviderModelMessage[];
20
24
  /** Mask old tool outputs. */
21
25
  export declare function maskOldToolOutputs(messages: ProviderModelMessage[]): ProviderModelMessage[];
22
26
  /** Repair tool pairs. */
@@ -1 +1 @@
1
- {"version":3,"file":"message-prep.d.ts","sourceRoot":"","sources":["../../../src/src/chat/message-prep.ts"],"names":[],"mappings":"AAAA,OAAO,yBAAyB,CAAC;AAQjC,OAAO,EAKL,KAAK,aAAa,EAGlB,KAAK,oBAAoB,EAE1B,MAAM,YAAY,CAAC;AAMpB,uBAAuB;AACvB,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAErD;AAOD,qBAAqB;AACrB,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,oBAAoB,EAAE,EAChC,QAAQ,EAAE,MA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mDjB;AAyCD,gCAAgC;AAChC,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE,CAiBhF;AAsFD,wCAAwC;AACxC,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,oBAAoB,EAAE,GAC/B,oBAAoB,EAAE,CAwBxB;AA4ED,wDAAwD;AACxD,wBAAgB,0CAA0C,CACxD,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,GAAE,iDAAsD,GAC9D,oBAAoB,EAAE,CAqBxB;AA2OD,6BAA6B;AAC7B,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CA4E3F;AAWD,yBAAyB;AACzB,wBAAgB,eAAe,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CA4IxF;AAED,yBAAyB;AACzB,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGjF;AAED,sCAAsC;AACtC,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CA4B7F;AAED,wBAAwB;AACxB,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,oBAAoB,EAAE,EAChC,QAAQ,GAAE,MAAU,GACnB,oBAAoB,EAAE,CAexB;AAED,2BAA2B;AAC3B,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,oBAAoB,EAAE,CA0D1F;AAED,4BAA4B;AAC5B,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,oBAAoB,EAAE,EAChC,MAAM,GAAE,MAA6B,EACrC,QAAQ,GAAE,MAAU,GACnB,oBAAoB,EAAE,CAMxB"}
@@ -387,11 +387,64 @@ function filterValidMessages(messages) {
387
387
  return true;
388
388
  });
389
389
  }
390
+ function getMessagePartToolCallId(part) {
391
+ if (!part || typeof part !== "object" || Array.isArray(part))
392
+ return undefined;
393
+ return getStringField(part, "toolCallId", "") ||
394
+ getStringField(part, "tool_call_id", "") ||
395
+ getStringField(part, "id", "") ||
396
+ undefined;
397
+ }
398
+ function getMessagePartToolName(part) {
399
+ if (!part || typeof part !== "object" || Array.isArray(part))
400
+ return undefined;
401
+ const record = part;
402
+ const explicitToolName = getStringField(part, "toolName", "") ||
403
+ getStringField(part, "tool_name", "") ||
404
+ getStringField(part, "name", "") ||
405
+ undefined;
406
+ if (explicitToolName)
407
+ return explicitToolName;
408
+ const type = typeof record.type === "string" ? record.type : undefined;
409
+ return type?.startsWith("tool-") && type !== "tool-call" && type !== "tool-result"
410
+ ? type.replace(/^tool-/, "")
411
+ : undefined;
412
+ }
413
+ function stripProviderOwnedToolParts(messages, providerOwnedToolNames) {
414
+ if (!providerOwnedToolNames || providerOwnedToolNames.length === 0) {
415
+ return messages;
416
+ }
417
+ const providerOwnedNames = new Set(providerOwnedToolNames);
418
+ const providerOwnedToolCallIds = new Set();
419
+ return messages.map((message) => {
420
+ if (message.role === "user" || message.role === "system") {
421
+ providerOwnedToolCallIds.clear();
422
+ return message;
423
+ }
424
+ let mutated = false;
425
+ const parts = message.parts.filter((part) => {
426
+ const toolName = getMessagePartToolName(part);
427
+ const toolCallId = getMessagePartToolCallId(part);
428
+ const ownedByName = toolName ? providerOwnedNames.has(toolName) : false;
429
+ const ownedByCallId = toolCallId ? providerOwnedToolCallIds.has(toolCallId) : false;
430
+ if (!ownedByName && !ownedByCallId) {
431
+ return true;
432
+ }
433
+ if (toolCallId) {
434
+ providerOwnedToolCallIds.add(toolCallId);
435
+ }
436
+ mutated = true;
437
+ return false;
438
+ });
439
+ return mutated ? { ...message, parts } : message;
440
+ });
441
+ }
390
442
  /** Prepare provider model messages from UI messages. */
391
- export function prepareProviderModelMessagesFromUiMessages(messages) {
443
+ export function prepareProviderModelMessagesFromUiMessages(messages, options = {}) {
392
444
  const validMessages = messages.filter((message) => message && typeof message === "object" && "role" in message);
393
445
  const normalizedMessages = normalizeMessageFilePartMediaTypes(validMessages);
394
- const strippedPendingToolMessages = stripPendingToolParts(normalizedMessages);
446
+ const strippedProviderOwnedToolMessages = stripProviderOwnedToolParts(normalizedMessages, options.providerOwnedToolNames);
447
+ const strippedPendingToolMessages = stripPendingToolParts(strippedProviderOwnedToolMessages);
395
448
  const strippedSupersededToolMessages = stripSupersededToolErrorParts(strippedPendingToolMessages);
396
449
  const rewrittenMessages = rewriteUnsupportedFilePartsAsAnnotations(strippedSupersededToolMessages);
397
450
  const providerModelMessages = convertUiMessagesToProviderModelMessages(rewrittenMessages);
@@ -21,6 +21,13 @@ export interface ModuleLoaderConfig {
21
21
  /** React version for transforms (from project config) */
22
22
  reactVersion?: string;
23
23
  }
24
+ /**
25
+ * Detect a dynamic `import()` failure caused by a module file that is missing on
26
+ * disk (e.g. a stale/evicted cached page module). Matches Node/Deno's
27
+ * `ERR_MODULE_NOT_FOUND` as well as the "Cannot find module" / "Module not found"
28
+ * message variants the runtimes surface for a missing `import()` target.
29
+ */
30
+ export declare function isMissingModuleError(error: unknown): boolean;
24
31
  /**
25
32
  * Load a module by path, transforming it and its dependencies.
26
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/orchestrator/module-loader/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AA2BzE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAkJpE,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,cAAc,EAC5B,MAAM,EAAE,kBAAkB,EAC1B,eAAe,UAAQ,GACtB,OAAO,CAAC,MAAM,CAAC,CAsSjB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAyBD;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAqClC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/src/rendering/orchestrator/module-loader/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AA4BzE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAkJpE,wBAAsB,uBAAuB,CAC3C,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,cAAc,EAC5B,MAAM,EAAE,kBAAkB,EAC1B,eAAe,UAAQ,GACtB,OAAO,CAAC,MAAM,CAAC,CAsSjB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;IACxB,IAAI,EAAE,aAAa,GAAG,YAAY,CAAC;IACnC,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,yDAAyD;IACzD,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAyBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAI5D;AAED;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA6DlC"}
@@ -18,7 +18,7 @@ import { validateCachedBundlesByManifestOrCode } from "../../../transforms/esm/c
18
18
  import { getHttpBundleCacheDir, getMdxEsmCacheDir } from "../../../utils/cache-dir.js";
19
19
  import { dirname, join, normalize } from "../../../platform/compat/path/index.js";
20
20
  import { hashCodeHex } from "../../../utils/hash-utils.js";
21
- import { getModulePathCache, lookupMdxEsmCache, saveModulePathCache, } from "../../../transforms/mdx/esm-module-loader/cache/index.js";
21
+ import { getModulePathCache, invalidateMdxEsmModule, lookupMdxEsmCache, saveModulePathCache, } from "../../../transforms/mdx/esm-module-loader/cache/index.js";
22
22
  import { buildMdxEsmPathCacheKey } from "../../../transforms/mdx/esm-module-loader/cache-format.js";
23
23
  const logger = rendererLogger.component("module-loader");
24
24
  // Re-export utilities
@@ -363,6 +363,19 @@ async function getModuleCacheDir(config) {
363
363
  }
364
364
  return getProjectTmpDir(projectId ?? projectDir);
365
365
  }
366
+ /**
367
+ * Detect a dynamic `import()` failure caused by a module file that is missing on
368
+ * disk (e.g. a stale/evicted cached page module). Matches Node/Deno's
369
+ * `ERR_MODULE_NOT_FOUND` as well as the "Cannot find module" / "Module not found"
370
+ * message variants the runtimes surface for a missing `import()` target.
371
+ */
372
+ export function isMissingModuleError(error) {
373
+ if (!(error instanceof Error))
374
+ return false;
375
+ if (error.code === "ERR_MODULE_NOT_FOUND")
376
+ return true;
377
+ return /cannot find module|module not found/i.test(error.message);
378
+ }
366
379
  /**
367
380
  * Load a module by path, transforming it and its dependencies.
368
381
  *
@@ -395,6 +408,25 @@ export async function loadModule(filePath, config) {
395
408
  return await import(`file://${tempFilePath}?t=${Date.now()}&retry=1`);
396
409
  }
397
410
  }
411
+ // Self-heal: the cached module artifact resolved to a path that no longer
412
+ // exists on disk (evicted, or rebuilt under a different content hash by a
413
+ // racing write). Rather than hard-failing the whole page render (#2077),
414
+ // treat it as a cache miss: drop the stale cache pointers so we don't get
415
+ // handed the same dead path, rebuild the module from source, and retry the
416
+ // import once. Skip HTTP-bundle misses, which have dedicated recovery above.
417
+ if (!bundleMatch && isMissingModuleError(error)) {
418
+ logger.warn("Cached module missing on disk, rebuilding and retrying import", {
419
+ filePath,
420
+ tempFilePath,
421
+ });
422
+ config.moduleCache.delete(getModuleCacheKey(filePath, config.projectId, config.projectDir, config.contentSourceId));
423
+ // tmpDir is the exact cache dir this module was registered under, so the
424
+ // invalidation stays scoped to this tenant (the path-cache key is not
425
+ // project-scoped — see invalidateMdxEsmModule).
426
+ invalidateMdxEsmModule(tmpDir, filePath, config.projectDir, config.reactVersion);
427
+ const rebuiltPath = await transformModuleWithDeps(filePath, tmpDir, localAdapter, config);
428
+ return await import(`file://${rebuiltPath}?t=${Date.now()}&rebuilt=1`);
429
+ }
398
430
  logger.error("Failed to import module:", {
399
431
  filePath,
400
432
  tempFilePath,
@@ -24,6 +24,29 @@ export declare function clearModulePathCache(): void;
24
24
  /** Await any in-flight disk cleanup (for testing only). */
25
25
  export declare function waitForDiskCleanup(): Promise<void>;
26
26
  export declare function invalidateModulePaths(changedPaths: string[]): void;
27
+ /**
28
+ * Invalidate the cached module path for a single source file in a single cache dir.
29
+ *
30
+ * Unlike {@link invalidateModulePaths} (driven by the file watcher on source
31
+ * edits, which also deletes the stale `.mjs` from disk), this is a targeted,
32
+ * synchronous self-heal for the case where a cached module artifact has already
33
+ * gone missing on disk — evicted, or rebuilt under a different content hash by a
34
+ * racing write — while the in-memory path cache and its verified-deps fast-path
35
+ * still point at the stale path. Clearing both forces the next
36
+ * {@link lookupMdxEsmCache} to report a miss so the module is rebuilt instead of
37
+ * handing back a path whose `import()` fails with ERR_MODULE_NOT_FOUND (#2077).
38
+ *
39
+ * `cacheDir` MUST be the dir that produced the missing path. The path-cache key
40
+ * is scoped only by React version + relative module path (not project/source),
41
+ * so two tenants that both have e.g. `app/page.tsx` share the same key in their
42
+ * separate cache dirs — scanning every dir would evict another tenant's valid
43
+ * entry, so the invalidation is confined to the failing dir.
44
+ *
45
+ * The deletion is also persisted to `_index.json` (fire-and-forget, chained onto
46
+ * the shared disk-cleanup queue like {@link invalidateModulePaths}) so the stale
47
+ * pointer does not resurrect from disk on the next process start.
48
+ */
49
+ export declare function invalidateMdxEsmModule(cacheDir: string, filePath: string, projectDir?: string, reactVersion?: string): void;
27
50
  export declare function clearESMDiskCache(): Promise<void>;
28
51
  export declare function clearHttpBundleCache(): Promise<void>;
29
52
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/src/transforms/mdx/esm-module-loader/cache/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAI5D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,MAAM,iBAAiB,GACzB;IAAE,MAAM,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAClB;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAI9D,eAAO,MAAM,kBAAkB,wBAE7B,CAAC;AA2HH,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAA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  return _pendingDiskCleanup;
186
186
  }
187
+ /**
188
+ * Persist the given cache dirs' `_index.json` fire-and-forget, chained onto the
189
+ * shared disk-cleanup queue so concurrent invalidations don't clobber each
190
+ * other. Used after an in-memory eviction so the stale pointer does not
191
+ * resurrect from disk on the next process start — callers that drop an entry
192
+ * (e.g. an SSR-only path) may never re-register and re-save it themselves.
193
+ */
194
+ function queueIndexPersist(cacheDirs) {
195
+ if (cacheDirs.length === 0)
196
+ return;
197
+ const cleanup = async () => {
198
+ for (const cacheDir of cacheDirs) {
199
+ await saveModulePathCache(cacheDir);
200
+ }
201
+ };
202
+ _pendingDiskCleanup = _pendingDiskCleanup.then(cleanup, cleanup).catch((error) => {
203
+ logger.warn(`${LOG_PREFIX_MDX_LOADER} Failed to persist _index.json`, {
204
+ error: error instanceof Error ? error.message : String(error),
205
+ });
206
+ });
207
+ }
187
208
  export function invalidateModulePaths(changedPaths) {
188
209
  if (modulePathCaches.size === 0)
189
210
  return;
@@ -250,6 +271,44 @@ export function invalidateModulePaths(changedPaths) {
250
271
  });
251
272
  });
252
273
  }
274
+ /**
275
+ * Invalidate the cached module path for a single source file in a single cache dir.
276
+ *
277
+ * Unlike {@link invalidateModulePaths} (driven by the file watcher on source
278
+ * edits, which also deletes the stale `.mjs` from disk), this is a targeted,
279
+ * synchronous self-heal for the case where a cached module artifact has already
280
+ * gone missing on disk — evicted, or rebuilt under a different content hash by a
281
+ * racing write — while the in-memory path cache and its verified-deps fast-path
282
+ * still point at the stale path. Clearing both forces the next
283
+ * {@link lookupMdxEsmCache} to report a miss so the module is rebuilt instead of
284
+ * handing back a path whose `import()` fails with ERR_MODULE_NOT_FOUND (#2077).
285
+ *
286
+ * `cacheDir` MUST be the dir that produced the missing path. The path-cache key
287
+ * is scoped only by React version + relative module path (not project/source),
288
+ * so two tenants that both have e.g. `app/page.tsx` share the same key in their
289
+ * separate cache dirs — scanning every dir would evict another tenant's valid
290
+ * entry, so the invalidation is confined to the failing dir.
291
+ *
292
+ * The deletion is also persisted to `_index.json` (fire-and-forget, chained onto
293
+ * the shared disk-cleanup queue like {@link invalidateModulePaths}) so the stale
294
+ * pointer does not resurrect from disk on the next process start.
295
+ */
296
+ export function invalidateMdxEsmModule(cacheDir, filePath, projectDir, reactVersion = REACT_DEFAULT_VERSION) {
297
+ const cache = modulePathCaches.get(cacheDir);
298
+ if (!cache)
299
+ return;
300
+ const cacheKey = toMdxEsmCacheKey(filePath, projectDir, reactVersion);
301
+ const cachedPath = cache.get(cacheKey);
302
+ if (cachedPath === undefined)
303
+ return;
304
+ cache.delete(cacheKey);
305
+ verifiedModuleDeps.delete(`${cachedPath}:${cacheKey}`);
306
+ logger.debug(`${LOG_PREFIX_MDX_LOADER} Self-heal invalidated missing module`, {
307
+ filePath,
308
+ cachedPath,
309
+ });
310
+ queueIndexPersist([cacheDir]);
311
+ }
253
312
  function extractNormalizedCachedModulePath(cachedKey) {
254
313
  const normalizedPath = cachedKey.match(/(?:^|:)(_vf_modules\/[^:]+)$/)?.[1] ?? cachedKey;
255
314
  return normalizedPath.replace(/^_vf_modules\//, "").replace(/\.js$/, "");
@@ -312,8 +371,32 @@ recoveryOptions, reactVersion = REACT_DEFAULT_VERSION) {
312
371
  return { status: "miss" };
313
372
  const verifyKey = `${cachedPath}:${cacheKey}`;
314
373
  if (verifiedModuleDeps.get(verifyKey)) {
315
- logger.debug(`${LOG_PREFIX_MDX_LOADER} SSR reusing MDX-ESM cache (verified): ${filePath} -> ${cachedPath}`);
316
- return { status: "hit", path: cachedPath };
374
+ // Fast-path: skip the expensive read + content scans for already-verified
375
+ // modules, but still confirm the artifact is present on disk. A cached module
376
+ // can be evicted or rebuilt under a different content hash out from under us
377
+ // (disk-cache eviction, or a racing rebuild) without going through
378
+ // invalidateModulePaths — which is the only thing that clears this marker.
379
+ // Returning the stale path here makes the SSR loader import() a file that no
380
+ // longer exists and hard-fail the whole page render (#2077), so a single stat
381
+ // (far cheaper than the read + regex scans below) guards correctness.
382
+ try {
383
+ const stat = await getLocalFs().stat(cachedPath);
384
+ if (stat?.isFile) {
385
+ logger.debug(`${LOG_PREFIX_MDX_LOADER} SSR reusing MDX-ESM cache (verified): ${filePath} -> ${cachedPath}`);
386
+ return { status: "hit", path: cachedPath };
387
+ }
388
+ }
389
+ catch (_) {
390
+ /* expected: verified artifact was evicted/rebuilt; fall through to invalidate */
391
+ }
392
+ // Artifact is gone — drop the stale markers so the caller rebuilds it, and
393
+ // persist the deletion so it can't resurrect from _index.json on restart
394
+ // (an SSR-only caller may never re-register and re-save this entry itself).
395
+ logger.debug(`${LOG_PREFIX_MDX_LOADER} Verified MDX-ESM artifact missing on disk, invalidating`, { filePath, cachedPath });
396
+ verifiedModuleDeps.delete(verifyKey);
397
+ cache.delete(cacheKey);
398
+ queueIndexPersist([cacheDir]);
399
+ return { status: "miss" };
317
400
  }
318
401
  try {
319
402
  const stat = await getLocalFs().stat(cachedPath);
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.643";
2
+ export declare const VERSION = "0.1.645";
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.643";
4
+ export const VERSION = "0.1.645";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfront",
3
- "version": "0.1.643",
3
+ "version": "0.1.645",
4
4
  "description": "The simplest way to build AI-powered apps",
5
5
  "keywords": [
6
6
  "react",