veryfront 0.1.152 → 0.1.155

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.
Files changed (34) hide show
  1. package/esm/deno.js +1 -1
  2. package/esm/src/agent/ag-ui-handler.d.ts +6 -0
  3. package/esm/src/agent/ag-ui-handler.d.ts.map +1 -1
  4. package/esm/src/agent/ag-ui-handler.js +115 -19
  5. package/esm/src/agent/ag-ui-run-control.d.ts +33 -0
  6. package/esm/src/agent/ag-ui-run-control.d.ts.map +1 -0
  7. package/esm/src/agent/ag-ui-run-control.js +102 -0
  8. package/esm/src/agent/index.d.ts +1 -0
  9. package/esm/src/agent/index.d.ts.map +1 -1
  10. package/esm/src/agent/index.js +1 -0
  11. package/esm/src/agent/runtime/chat-stream-handler.d.ts.map +1 -1
  12. package/esm/src/agent/runtime/chat-stream-handler.js +1 -25
  13. package/esm/src/agent/runtime/error-utils.d.ts +4 -0
  14. package/esm/src/agent/runtime/error-utils.d.ts.map +1 -0
  15. package/esm/src/agent/runtime/error-utils.js +25 -0
  16. package/esm/src/agent/runtime/index.d.ts.map +1 -1
  17. package/esm/src/agent/runtime/index.js +1 -25
  18. package/esm/src/observability/error-collector.d.ts +1 -0
  19. package/esm/src/observability/error-collector.d.ts.map +1 -1
  20. package/esm/src/observability/error-collector.js +6 -3
  21. package/esm/src/routing/api/module-loader/loader.js +26 -28
  22. package/esm/src/utils/version-constant.d.ts +1 -1
  23. package/esm/src/utils/version-constant.js +1 -1
  24. package/package.json +1 -1
  25. package/src/deno.js +1 -1
  26. package/src/src/agent/ag-ui-handler.ts +187 -27
  27. package/src/src/agent/ag-ui-run-control.ts +161 -0
  28. package/src/src/agent/index.ts +8 -0
  29. package/src/src/agent/runtime/chat-stream-handler.ts +1 -33
  30. package/src/src/agent/runtime/error-utils.ts +32 -0
  31. package/src/src/agent/runtime/index.ts +1 -33
  32. package/src/src/observability/error-collector.ts +13 -3
  33. package/src/src/routing/api/module-loader/loader.ts +37 -38
  34. package/src/src/utils/version-constant.ts +1 -1
@@ -100,6 +100,7 @@ import {
100
100
  } from "../../skill/allowed-tools.js";
101
101
  import { resolveConfiguredAgentModel, resolveRuntimeModel } from "./model-resolution.js";
102
102
  import type { RuntimeGenerateToolResult } from "./runtime-tool-types.js";
103
+ import { stringifyToolError, throwIfAborted } from "./error-utils.js";
103
104
 
104
105
  const logger = serverLogger.component("agent");
105
106
  const LOAD_SKILL_TOOL_ID = "load-skill";
@@ -108,23 +109,6 @@ type RuntimeToolFilterConfig = AgentConfig & {
108
109
  __vfAllowedRemoteTools?: string[];
109
110
  };
110
111
 
111
- function createAbortError(reason?: unknown): Error {
112
- if (reason instanceof Error) {
113
- return reason;
114
- }
115
-
116
- return new DOMException(
117
- typeof reason === "string" && reason.length > 0 ? reason : "The operation was aborted",
118
- "AbortError",
119
- );
120
- }
121
-
122
- function throwIfAborted(abortSignal?: AbortSignal): void {
123
- if (abortSignal?.aborted) {
124
- throw createAbortError(abortSignal.reason);
125
- }
126
- }
127
-
128
112
  function isAbortError(error: unknown, abortSignal?: AbortSignal): boolean {
129
113
  if (abortSignal?.aborted && error === abortSignal.reason) {
130
114
  return true;
@@ -133,22 +117,6 @@ function isAbortError(error: unknown, abortSignal?: AbortSignal): boolean {
133
117
  return error instanceof DOMException && error.name === "AbortError";
134
118
  }
135
119
 
136
- function stringifyToolError(error: unknown): string {
137
- if (typeof error === "string" && error.length > 0) {
138
- return error;
139
- }
140
-
141
- if (error instanceof Error && typeof error.message === "string" && error.message.length > 0) {
142
- return error.message;
143
- }
144
-
145
- try {
146
- return JSON.stringify(error);
147
- } catch {
148
- return String(error);
149
- }
150
- }
151
-
152
120
  function getToolResultError(result: unknown): string | undefined {
153
121
  if (!result || typeof result !== "object" || !("error" in result)) {
154
122
  return undefined;
@@ -150,6 +150,16 @@ export class ErrorCollector {
150
150
  return this.addTypedError("runtime", message, { stack, context, slug });
151
151
  }
152
152
 
153
+ private addFileContextError(
154
+ type: "bundle" | "hmr" | "module",
155
+ message: string,
156
+ file?: string,
157
+ context?: Record<string, unknown>,
158
+ slug?: string,
159
+ ): DevError {
160
+ return this.addTypedError(type, message, { file, context, slug });
161
+ }
162
+
153
163
  /**
154
164
  * Add a bundle error
155
165
  * @param message Error message
@@ -163,7 +173,7 @@ export class ErrorCollector {
163
173
  context?: Record<string, unknown>,
164
174
  slug?: string,
165
175
  ): DevError {
166
- return this.addTypedError("bundle", message, { file, context, slug });
176
+ return this.addFileContextError("bundle", message, file, context, slug);
167
177
  }
168
178
 
169
179
  /**
@@ -179,7 +189,7 @@ export class ErrorCollector {
179
189
  context?: Record<string, unknown>,
180
190
  slug?: string,
181
191
  ): DevError {
182
- return this.addTypedError("hmr", message, { file, context, slug });
192
+ return this.addFileContextError("hmr", message, file, context, slug);
183
193
  }
184
194
 
185
195
  /**
@@ -195,7 +205,7 @@ export class ErrorCollector {
195
205
  context?: Record<string, unknown>,
196
206
  slug?: string,
197
207
  ): DevError {
198
- return this.addTypedError("module", message, { file, context, slug });
208
+ return this.addFileContextError("module", message, file, context, slug);
199
209
  }
200
210
 
201
211
  getAll(filter?: ErrorFilter): DevError[] {
@@ -355,31 +355,45 @@ function createImportMapPlugin(
355
355
 
356
356
  build.onLoad(
357
357
  { filter: /.*/, namespace: "import-map" },
358
- wrapWithCurrentContext(async (args) => {
359
- try {
360
- const { filePath, contents } = await readFileWithExtensions(
361
- adapter,
362
- args.path,
363
- FILE_EXTENSIONS,
364
- projectDir,
365
- );
366
-
367
- return {
368
- contents,
369
- loader: getLoaderForFile(filePath),
370
- resolveDir: pathHelper.dirname(filePath),
371
- };
372
- } catch (error) {
373
- const msg = error instanceof Error ? error.message : String(error);
374
- logger.error(`Failed to load file via import map: ${args.path}`, error);
375
- return { errors: [{ text: `Failed to load: ${msg}` }] };
376
- }
358
+ createNamespaceOnLoadHandler({
359
+ adapter,
360
+ projectDir,
361
+ errorLabel: "file via import map",
377
362
  }),
378
363
  );
379
364
  },
380
365
  };
381
366
  }
382
367
 
368
+ function createNamespaceOnLoadHandler(options: {
369
+ adapter: RuntimeAdapter;
370
+ projectDir: string;
371
+ errorLabel: string;
372
+ }) {
373
+ const { adapter, projectDir, errorLabel } = options;
374
+
375
+ return wrapWithCurrentContext(async (args: { path: string }) => {
376
+ try {
377
+ const { filePath, contents } = await readFileWithExtensions(
378
+ adapter,
379
+ args.path,
380
+ FILE_EXTENSIONS,
381
+ projectDir,
382
+ );
383
+
384
+ return {
385
+ contents,
386
+ loader: getLoaderForFile(filePath),
387
+ resolveDir: pathHelper.dirname(filePath),
388
+ };
389
+ } catch (error) {
390
+ const msg = error instanceof Error ? error.message : String(error);
391
+ logger.error(`Failed to load ${errorLabel}: ${args.path}`, error);
392
+ return { errors: [{ text: `Failed to load: ${msg}` }] };
393
+ }
394
+ });
395
+ }
396
+
383
397
  /** Resolves relative imports through the adapter's virtual FS for remote projects. */
384
398
  function createAdapterResolvePlugin(
385
399
  adapter: RuntimeAdapter,
@@ -420,25 +434,10 @@ function createAdapterResolvePlugin(
420
434
  // cannot resolve the per-project adapter and all file reads fail silently.
421
435
  build.onLoad(
422
436
  { filter: /.*/, namespace: "vf-adapter" },
423
- wrapWithCurrentContext(async (args) => {
424
- try {
425
- const { filePath, contents } = await readFileWithExtensions(
426
- adapter,
427
- args.path,
428
- FILE_EXTENSIONS,
429
- projectDir,
430
- );
431
-
432
- return {
433
- contents,
434
- loader: getLoaderForFile(filePath),
435
- resolveDir: pathHelper.dirname(filePath),
436
- };
437
- } catch (error) {
438
- const msg = error instanceof Error ? error.message : String(error);
439
- logger.error(`Failed to load via adapter: ${args.path}`, error);
440
- return { errors: [{ text: `Failed to load: ${msg}` }] };
441
- }
437
+ createNamespaceOnLoadHandler({
438
+ adapter,
439
+ projectDir,
440
+ errorLabel: "via adapter",
442
441
  }),
443
442
  );
444
443
  },
@@ -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.152";
3
+ export const VERSION = "0.1.155";