@vgai/fal 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # @vgai/fal
2
2
 
3
- Optional Project Tools and editor UI for Fal. The package registers
3
+ The **provider boundary** for Fal: pricing, spend routing and credentials,
4
+ behind guarded tools. This package registers NOTHING and contains no editor UI.
5
+
6
+ Add the capability to a project instead — `vgai add fal` — which copies the tool
7
+ DECLARATIONS and the generation documents into your `src/tools/` as ordinary,
8
+ editable source. They import this package for the parts that must not be
9
+ editable, and nothing else.
10
+
11
+ Two kinds of code exist in VGAI. This is the dependency side: the machinery that
12
+ makes the system work, which an agent is not meant to read or change. Anything
13
+ that hooks into the editor is on the lib side, so it is visible project source.
14
+
15
+ The guarded surface this package exports backs these tools:
4
16
  `project.fal.quote`, `project.fal.submit`, `project.fal.poll`, and
5
17
  `project.fal.cancel`, and `project.fal.accept`. Quote reads current
6
18
  account-specific pricing without inspecting provider wallet balance; submission
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.0",
5
+ "version": "0.1.2",
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",
@@ -20,25 +20,19 @@
20
20
  ],
21
21
  "exports": {
22
22
  "./accept": "./src/accept.ts",
23
+ "./cancel": "./src/cancel.ts",
23
24
  "./contracts": "./src/contracts.ts",
24
25
  "./package.json": "./package.json",
25
26
  "./poll": "./src/poll.ts",
26
27
  "./pricing": "./src/pricing.ts",
27
- "./submit": "./src/submit.ts"
28
- },
29
- "vgai": {
30
- "tools": [
31
- "./src/submit.tool.ts",
32
- "./src/quote.tool.ts",
33
- "./src/cancel.tool.ts",
34
- "./src/poll.tool.ts",
35
- "./src/accept.tool.ts"
36
- ]
28
+ "./provider": "./src/provider.ts",
29
+ "./submit": "./src/submit.ts",
30
+ "./tool-error": "./src/tool-error.ts"
37
31
  },
38
32
  "dependencies": {
39
33
  "@fal-ai/client": "1.10.1",
40
34
  "@vgai/fal-client-compat": "0.1.0",
41
- "@vgai/sdk": "0.5.0",
35
+ "@vgai/sdk": "^0.5.1",
42
36
  "fflate": "^0.8.2",
43
37
  "three": "^0.180.0",
44
38
  "zod": "^4.3.6"
@@ -47,7 +41,7 @@
47
41
  "@types/node": "^25.3.0",
48
42
  "@types/react": "^19.2.14",
49
43
  "@types/three": "^0.180.0",
50
- "@vgai/editor-sdk": "0.5.0",
44
+ "@vgai/editor-sdk": "^0.5.1",
51
45
  "react": "^19.2.4"
52
46
  }
53
47
  }
@@ -1,49 +0,0 @@
1
- import type { GenerationToolContribution } from '@vgai/sdk/generations';
2
- import { defineTool } from '@vgai/sdk/tools';
3
- import { acceptFal } from './accept.js';
4
- import { AcceptInputSchema, AcceptResultSchema } from './contracts.js';
5
- import { falTool, falToolErrors } from './tool-error.js';
6
- export const tool = defineTool({
7
- name: 'project.fal.accept',
8
- summary: 'Accept a completed Fal request',
9
- description:
10
- 'Downloads and validates a completed Fal result, then atomically commits ordinary files and provenance.',
11
- input: AcceptInputSchema,
12
- result: AcceptResultSchema,
13
- errors: falToolErrors,
14
- requires: { project: true },
15
- host: 'node',
16
- mutates: true,
17
- supportsDryRun: false,
18
- longRunning: true,
19
- permission: { risk: 'write', summary: 'Writes one accepted Fal output batch under public/.' },
20
- impl: falTool(acceptFal),
21
- });
22
-
23
- export const generation = {
24
- role: 'accept',
25
- provider: 'fal',
26
- toUpdate(inputValue, resultValue) {
27
- const input = AcceptInputSchema.parse(inputValue);
28
- const result = AcceptResultSchema.parse(resultValue);
29
- return {
30
- provider: 'fal',
31
- externalId: input.requestId,
32
- ...(input.mode === 'direct' && result.settledAmount !== undefined
33
- ? {
34
- billing: {
35
- route: 'byok' as const,
36
- currency: 'USD' as const,
37
- settledAmount: result.settledAmount,
38
- },
39
- }
40
- : input.mode === 'managed' && result.settledCredits !== undefined
41
- ? { billing: { route: 'managed' as const, settledCredits: result.settledCredits } }
42
- : {}),
43
- accepted: {
44
- provenanceOperationId: result.provenanceOperationId,
45
- outputPaths: result.files.map((file) => file.path),
46
- },
47
- };
48
- },
49
- } satisfies GenerationToolContribution;
@@ -1,36 +0,0 @@
1
- import type { GenerationToolContribution } from '@vgai/sdk/generations';
2
- import { defineTool } from '@vgai/sdk/tools';
3
- import { cancelFal } from './cancel.js';
4
- import { CancelInputSchema, CancelResultSchema } from './contracts.js';
5
- import { falTool, falToolErrors } from './tool-error.js';
6
-
7
- export const tool = defineTool({
8
- name: 'project.fal.cancel',
9
- summary: 'Cancel a Fal request',
10
- description: 'Cancels one queued or running Fal request without writing generated project files.',
11
- input: CancelInputSchema,
12
- result: CancelResultSchema,
13
- errors: falToolErrors,
14
- requires: { project: true },
15
- host: 'node',
16
- mutates: false,
17
- supportsDryRun: false,
18
- longRunning: false,
19
- permission: { risk: 'write', summary: 'Cancels one external Fal request.' },
20
- impl: falTool(cancelFal),
21
- });
22
-
23
- export const generation = {
24
- role: 'cancel',
25
- provider: 'fal',
26
- toUpdate(inputValue, resultValue) {
27
- const input = CancelInputSchema.parse(inputValue);
28
- CancelResultSchema.parse(resultValue);
29
- return {
30
- provider: 'fal',
31
- externalId: input.requestId,
32
- status: 'cancelled' as const,
33
- message: 'Cancelled at the provider.',
34
- };
35
- },
36
- } satisfies GenerationToolContribution;
package/src/poll.tool.ts DELETED
@@ -1,70 +0,0 @@
1
- import type { GenerationToolContribution } from '@vgai/sdk/generations';
2
- import { defineTool } from '@vgai/sdk/tools';
3
- import { PollInputSchema, PollResultSchema } from './contracts.js';
4
- import { pollFal } from './poll.js';
5
- import { falTool, falToolErrors } from './tool-error.js';
6
- export const tool = defineTool({
7
- name: 'project.fal.poll',
8
- summary: 'Inspect a Fal request',
9
- description: 'Reads one native Fal queue request without writing project files.',
10
- input: PollInputSchema,
11
- result: PollResultSchema,
12
- errors: falToolErrors,
13
- requires: { project: true },
14
- host: 'node',
15
- mutates: false,
16
- supportsDryRun: false,
17
- longRunning: false,
18
- permission: { risk: 'read', summary: 'Reads one Fal request.' },
19
- impl: falTool(pollFal),
20
- });
21
-
22
- export const generation = {
23
- role: 'poll',
24
- provider: 'fal',
25
- toUpdate(inputValue, resultValue) {
26
- const input = PollInputSchema.parse(inputValue);
27
- const result = PollResultSchema.parse(resultValue);
28
- return {
29
- provider: 'fal',
30
- externalId: input.requestId,
31
- status: result.error
32
- ? 'failed'
33
- : result.status === 'COMPLETED'
34
- ? 'succeeded'
35
- : result.status === 'IN_PROGRESS'
36
- ? 'running'
37
- : 'queued',
38
- providerStatus: result.status,
39
- ...(result.queuePosition === undefined ? {} : { queuePosition: result.queuePosition }),
40
- ...(result.error ? { message: result.error.message } : {}),
41
- ...(result.cancelUrl
42
- ? {
43
- cancel: {
44
- tool: 'project.fal.cancel',
45
- input: {
46
- mode: input.mode,
47
- endpoint: input.endpoint,
48
- requestId: input.requestId,
49
- cancelUrl: result.cancelUrl,
50
- },
51
- },
52
- }
53
- : {}),
54
- ...(input.mode === 'managed' &&
55
- (result.estimatedCredits !== undefined || result.settledCredits !== undefined)
56
- ? {
57
- billing: {
58
- route: 'managed' as const,
59
- ...(result.estimatedCredits === undefined
60
- ? {}
61
- : { estimatedCredits: result.estimatedCredits }),
62
- ...(result.settledCredits === undefined
63
- ? {}
64
- : { settledCredits: result.settledCredits }),
65
- },
66
- }
67
- : {}),
68
- };
69
- },
70
- } satisfies GenerationToolContribution;
package/src/quote.tool.ts DELETED
@@ -1,20 +0,0 @@
1
- import { defineTool } from '@vgai/sdk/tools';
2
- import { QuoteInputSchema, QuoteResultSchema } from './contracts.js';
3
- import { quoteFalPrice } from './pricing.js';
4
- import { falTool, falToolErrors } from './tool-error.js';
5
-
6
- export const tool = defineTool({
7
- name: 'project.fal.quote',
8
- summary: 'Quote a Fal request',
9
- description: 'Reads Fal current account pricing for one provider-native request.',
10
- input: QuoteInputSchema,
11
- result: QuoteResultSchema,
12
- errors: falToolErrors,
13
- requires: { project: true },
14
- host: 'node',
15
- mutates: false,
16
- supportsDryRun: false,
17
- longRunning: false,
18
- permission: { risk: 'read', summary: 'Reads current Fal account pricing.' },
19
- impl: falTool(quoteFalPrice),
20
- });
@@ -1,101 +0,0 @@
1
- import type { GenerationToolContribution } from '@vgai/sdk/generations';
2
- import { defineTool } from '@vgai/sdk/tools';
3
- import {
4
- SEEDANCE_2_REFERENCE_TO_VIDEO_ENDPOINT,
5
- SubmissionSchema,
6
- SubmitResultSchema,
7
- } from './contracts.js';
8
- import { submitFal } from './submit.js';
9
- import { falTool, falToolErrors } from './tool-error.js';
10
-
11
- const ENDPOINT_LABELS: Record<string, string> = {
12
- 'fal-ai/nano-banana-2': 'Generated image',
13
- 'fal-ai/nano-banana-2/edit': 'Edited image',
14
- 'fal-ai/gemini-3.1-flash-image-preview': 'Generated image',
15
- 'fal-ai/nano-banana': 'Generated image',
16
- 'fal-ai/nano-banana/edit': 'Edited image',
17
- 'fal-ai/stable-audio': 'Generated audio',
18
- 'fal-ai/sam-3/3d-objects': 'Reconstructed object',
19
- 'fal-ai/minimax/hailuo-02/standard/text-to-video': 'Generated video',
20
- [SEEDANCE_2_REFERENCE_TO_VIDEO_ENDPOINT]: 'Seedance video treatment',
21
- 'fal-ai/hunyuan_world': 'Generated panorama',
22
- 'fal-ai/hunyuan_world/image-to-world': 'Generated layered world',
23
- };
24
-
25
- function jobLabel(endpoint: string, input: Record<string, unknown>): string {
26
- const prompt = input['prompt'];
27
- if (typeof prompt === 'string' && prompt.trim()) {
28
- return prompt.trim().length > 64 ? `${prompt.trim().slice(0, 61)}…` : prompt.trim();
29
- }
30
- return ENDPOINT_LABELS[endpoint] ?? endpoint;
31
- }
32
- export const tool = defineTool({
33
- name: 'project.fal.submit',
34
- summary: 'Submit a Fal request',
35
- description:
36
- 'Submits one provider-native Fal queue request. No project files are written until project.fal.accept.',
37
- input: SubmissionSchema,
38
- result: SubmitResultSchema,
39
- errors: falToolErrors,
40
- requires: { project: true },
41
- host: 'node',
42
- mutates: false,
43
- supportsDryRun: false,
44
- longRunning: false,
45
- permission: {
46
- risk: 'write',
47
- summary: 'Creates an external Fal request that may incur provider charges.',
48
- },
49
- impl: falTool(submitFal),
50
- });
51
-
52
- export const generation = {
53
- role: 'submit',
54
- provider: 'fal',
55
- toJob(inputValue, resultValue) {
56
- const input = SubmissionSchema.parse(inputValue);
57
- const result = SubmitResultSchema.parse(resultValue);
58
- return {
59
- provider: 'fal',
60
- externalId: result.requestId,
61
- label: jobLabel(input.endpoint, input.input),
62
- operation: input.endpoint,
63
- mode: input.mode,
64
- status: 'queued',
65
- billing:
66
- input.mode === 'mock'
67
- ? { route: 'mock' }
68
- : input.mode === 'managed'
69
- ? {
70
- route: 'managed',
71
- ...(result.estimatedCredits === undefined
72
- ? {}
73
- : { estimatedCredits: result.estimatedCredits }),
74
- }
75
- : {
76
- route: 'byok',
77
- currency: 'USD',
78
- ...(result.quote?.estimatedAmount === undefined
79
- ? {}
80
- : { estimatedAmount: result.quote.estimatedAmount }),
81
- },
82
- poll: {
83
- tool: 'project.fal.poll',
84
- input: { mode: input.mode, endpoint: input.endpoint, requestId: result.requestId },
85
- },
86
- cancel: {
87
- tool: 'project.fal.cancel',
88
- input: {
89
- mode: input.mode,
90
- endpoint: input.endpoint,
91
- requestId: result.requestId,
92
- cancelUrl: result.cancelUrl,
93
- },
94
- },
95
- accept: {
96
- tool: 'project.fal.accept',
97
- input: { ...input, requestId: result.requestId },
98
- },
99
- };
100
- },
101
- } satisfies GenerationToolContribution;