@vgai/fal 0.1.3 → 0.1.4

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/tool-error.ts +17 -1
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vgai/fal",
3
3
  "author": "Volter AI, Inc.",
4
4
  "license": "Apache-2.0",
5
- "version": "0.1.3",
5
+ "version": "0.1.4",
6
6
  "type": "module",
7
7
  "description": "Optional registered Fal provider boundary for VGAI projects: quote, submit, poll and accept behind guarded pricing and credentials.",
8
8
  "homepage": "https://github.com/volter-ai/vgai-engine#readme",
package/src/tool-error.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { ApiError } from '@fal-ai/client';
1
2
  import { type ToolContext, ToolError } from '@vgai/sdk/tools';
2
3
 
3
4
  export const falToolErrors = [
@@ -23,7 +24,22 @@ export function falTool<TInput, TResult>(
23
24
  throw cause;
24
25
  }
25
26
  const message = cause instanceof Error ? cause.message : String(cause);
26
- throw new ToolError('PROVIDER_ERROR', message, { provider: 'fal', message });
27
+ const detail = cause instanceof ApiError ? cause.body?.detail : undefined;
28
+ throw new ToolError('PROVIDER_ERROR', message, {
29
+ provider: 'fal',
30
+ message,
31
+ ...(cause instanceof ApiError
32
+ ? { status: cause.status, requestId: cause.requestId }
33
+ : {}),
34
+ ...(typeof detail === 'string' ? { detail } : {}),
35
+ ...(Array.isArray(detail)
36
+ ? {
37
+ detail: detail
38
+ .filter((item) => item !== null && typeof item === 'object')
39
+ .map(({ loc, msg, type }) => ({ loc, msg, type })),
40
+ }
41
+ : {}),
42
+ });
27
43
  }
28
44
  };
29
45
  }