@fias/arche-sdk 1.9.0 → 1.12.0
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 +1 -1
- package/dist/cli/create-plugin.js +0 -0
- package/dist/coverage-fills.test.d.ts +8 -0
- package/dist/coverage-fills.test.d.ts.map +1 -0
- package/dist/coverage-fills.test.js +302 -0
- package/dist/coverage-fills.test.js.map +1 -0
- package/dist/generated/permissions.d.ts +15 -0
- package/dist/generated/permissions.d.ts.map +1 -0
- package/dist/generated/permissions.js +32 -0
- package/dist/generated/permissions.js.map +1 -0
- package/dist/generated/surfaces.d.ts +267 -0
- package/dist/generated/surfaces.d.ts.map +1 -0
- package/dist/generated/surfaces.js +87 -0
- package/dist/generated/surfaces.js.map +1 -0
- package/dist/hooks.d.ts +81 -18
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +288 -50
- package/dist/hooks.js.map +1 -1
- package/dist/hooks.test.js +827 -0
- package/dist/hooks.test.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +295 -32
- package/dist/types.d.ts +339 -56
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -1
- package/package.json +16 -16
- package/templates/default/AGENTS.md +104 -3
- package/templates/default/CLAUDE.md +104 -3
|
@@ -220,10 +220,10 @@ function ImageMaker() {
|
|
|
220
220
|
<button
|
|
221
221
|
onClick={() =>
|
|
222
222
|
generate({
|
|
223
|
-
entityId: '
|
|
223
|
+
entityId: 'ent_modeldef_gpt_image_1_5',
|
|
224
224
|
prompt: 'A serene mountain landscape at sunset',
|
|
225
225
|
size: '1024x1024',
|
|
226
|
-
quality: '
|
|
226
|
+
quality: 'high',
|
|
227
227
|
})
|
|
228
228
|
}
|
|
229
229
|
disabled={isLoading}
|
|
@@ -237,6 +237,56 @@ function ImageMaker() {
|
|
|
237
237
|
}
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
+
### `useFiasFiles()` — User-files filesystem (SDK ≥ 1.9.0)
|
|
241
|
+
|
|
242
|
+
**Permissions:** `files:read` for `list`/`read`/`getDownloadUrl`; add `files:write` for `write`/`update`/`delete`
|
|
243
|
+
**Returns:** `FiasFilesApi`
|
|
244
|
+
|
|
245
|
+
Access the user's Fias filesystem, scoped to files this arche owns. Files written through this hook (and images created via `useImageGeneration()`) appear in MyData under `/My-Fias/{ArcheName}/`. Listing is by ownership — moving a file in MyData doesn't hide it from the arche.
|
|
246
|
+
|
|
247
|
+
The most common use is `getDownloadUrl(fileId)` to refresh the presigned URL on a generated image after the original (~1h) expires:
|
|
248
|
+
|
|
249
|
+
```tsx
|
|
250
|
+
import { useFiasFiles, useImageGeneration } from '@fias/arche-sdk';
|
|
251
|
+
|
|
252
|
+
function PortraitGallery({ savedFileId }: { savedFileId: string }) {
|
|
253
|
+
const { getDownloadUrl } = useFiasFiles();
|
|
254
|
+
const [url, setUrl] = useState<string | null>(null);
|
|
255
|
+
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
let cancelled = false;
|
|
258
|
+
getDownloadUrl(savedFileId).then((r) => {
|
|
259
|
+
if (!cancelled) setUrl(r.url);
|
|
260
|
+
});
|
|
261
|
+
return () => {
|
|
262
|
+
cancelled = true;
|
|
263
|
+
};
|
|
264
|
+
}, [savedFileId, getDownloadUrl]);
|
|
265
|
+
|
|
266
|
+
return url ? <img src={url} alt="" /> : null;
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Store the `fileId`, not the `imageUrl`.** Image-generation results include both, but `imageUrl` is a short-lived presigned link. Persist `fileId` in your data store and resolve to a fresh URL on render via `getDownloadUrl`.
|
|
271
|
+
|
|
272
|
+
**Same-name writes overwrite.** Calling `write({ name: 'save.json', content })` twice with the same name reuses the existing `fileId` and replaces the content — useful for periodic snapshots.
|
|
273
|
+
|
|
274
|
+
**`read()` is text-only.** It rejects binary content types with HTTP 415. Use `getDownloadUrl(fileId)` and pass the URL to `<img>`, `fetch`, etc. for binaries.
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
const files = useFiasFiles();
|
|
278
|
+
|
|
279
|
+
await files.write({
|
|
280
|
+
name: 'save.json',
|
|
281
|
+
content: JSON.stringify(state),
|
|
282
|
+
contentType: 'application/json',
|
|
283
|
+
});
|
|
284
|
+
const { content } = await files.read(fileId);
|
|
285
|
+
const { files: page, nextCursor } = await files.list({ limit: 20 });
|
|
286
|
+
await files.update(fileId, { tags: ['draft'] });
|
|
287
|
+
await files.delete(fileId);
|
|
288
|
+
```
|
|
289
|
+
|
|
240
290
|
### `useFiasNavigation()` — In-plugin routing
|
|
241
291
|
|
|
242
292
|
**Permission:** None required
|
|
@@ -337,6 +387,12 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' |
|
|
|
337
387
|
|
|
338
388
|
These are hard limits enforced by the platform. Code that violates these will fail review or be blocked at runtime.
|
|
339
389
|
|
|
390
|
+
### Hitting a limit? Tell the user about Entity requests
|
|
391
|
+
|
|
392
|
+
Don't just say "can't do that" when the user asks for something blocked by these rules — most often a direct external API call, a third-party service, or a capability the platform hasn't surfaced yet. The Fias team adds new **Entities** on request: platform-managed wrappers that hold credentials, handle auth, and expose the capability to plugins through `useEntityInvocation()` (or `useImageGeneration()` for image models). The plugin never bypasses the sandbox — it invokes the new Entity like any other model.
|
|
393
|
+
|
|
394
|
+
When you hit a constraint, say so AND tell the user: file an Entity request on the Customer Support arche at `https://platform.fias.io/a/arche_customer_support`. Describe the service, endpoints, and auth method needed; once the Entity ships, the plugin can call it via `useEntityInvocation` with no sandbox change. Then propose a fallback that works inside the current sandbox (mock data, a simpler path, deferring the call) so the build keeps moving while the request is in flight.
|
|
395
|
+
|
|
340
396
|
### Sandboxing
|
|
341
397
|
|
|
342
398
|
- Plugins run in an iframe with `sandbox="allow-scripts allow-forms allow-same-origin allow-downloads"`
|
|
@@ -390,6 +446,18 @@ If newer package versions are available, tell the user and ask if they want to u
|
|
|
390
446
|
|
|
391
447
|
If `sync --dry-run` shows pending changes, tell the user and offer to run `npx fias-dev sync` to update AI instruction files and config from the latest SDK templates. This never touches source code or project-specific files (`package.json`, `fias-plugin.json`, `src/`).
|
|
392
448
|
|
|
449
|
+
#### UI cache after a harness upgrade
|
|
450
|
+
|
|
451
|
+
The harness pulls its host-page UI (toolbar, mode toggle, sign-in modal) from a CDN and caches it in `~/.fias/harness-cache/`. The cached UI takes priority over the bundled copy that ships in the npm package.
|
|
452
|
+
|
|
453
|
+
When you upgrade `@fias/plugin-dev-harness` but the CDN hasn't been redeployed yet, the cached UI can be older than the CLI. fias-dev now detects this case automatically and falls back to the bundled UI — look for this line in the startup log:
|
|
454
|
+
|
|
455
|
+
```
|
|
456
|
+
ℹ Cached harness UI v1.14.3 is older than CLI v1.18.0 — using bundled UI.
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
That message means everything is fine; the bundled UI exactly matches your CLI version. If you ever see stale behavior persist across an upgrade (and the line above didn't appear), delete `~/.fias/harness-cache/` and restart.
|
|
460
|
+
|
|
393
461
|
### Starting Development
|
|
394
462
|
|
|
395
463
|
```bash
|
|
@@ -423,9 +491,42 @@ npx fias-dev login --env production # Authenticate with production
|
|
|
423
491
|
npx fias-dev entities # List all
|
|
424
492
|
npx fias-dev entities --search "image" # Search by keyword
|
|
425
493
|
npx fias-dev entities --type "model-definition" # Filter by type
|
|
426
|
-
npx fias-dev entities --detail
|
|
494
|
+
npx fias-dev entities --detail ent_modeldef_gpt_image_1_5 # Full entity details (capabilities, sizes, pricing)
|
|
427
495
|
```
|
|
428
496
|
|
|
497
|
+
### Debugging — Read the Browser's View Directly
|
|
498
|
+
|
|
499
|
+
The harness mirrors every browser-side event to a per-port log file at `/tmp/fias-dev-<port>.log` (so usually `/tmp/fias-dev-3200.log`). The file path is also printed at startup:
|
|
500
|
+
|
|
501
|
+
```
|
|
502
|
+
Browser dev-log mirror: /tmp/fias-dev-3200.log
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
What's captured:
|
|
506
|
+
|
|
507
|
+
- Every Dev Console entry (`send` / `recv` / `info` / `error` / `toast` / `cost` / `nav`)
|
|
508
|
+
- Every uncaught JS error (`window.error`)
|
|
509
|
+
- Every unhandled promise rejection (`unhandledrejection`)
|
|
510
|
+
- Bridge requests + responses with payload previews
|
|
511
|
+
|
|
512
|
+
Format is one line per event:
|
|
513
|
+
|
|
514
|
+
```
|
|
515
|
+
2026-05-24T07:14:33.123Z [ERROR] window.error {"message":"...","file":"...","line":42}
|
|
516
|
+
2026-05-24T07:14:35.456Z [SEND] image_generate {"entityId":"ent_modeldef_..."}
|
|
517
|
+
2026-05-24T07:14:36.789Z [RECV] response {...}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
**For AI agents pair-debugging with a developer:** tail this file instead of asking the developer to open DevTools and copy-paste output. Reproduce the failing action in the browser, then read the file — you'll see exactly what the iframe and harness exchanged.
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
tail -f /tmp/fias-dev-3200.log
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
The file is truncated on every `fias-dev` start, so it always reflects the current session.
|
|
527
|
+
|
|
528
|
+
The mirror uses `navigator.sendBeacon` (with a `fetch` fallback) so there's a sub-second delay before the most recent events land in the file. If you're chasing a race, give it a beat before reading.
|
|
529
|
+
|
|
429
530
|
### Validating the Manifest
|
|
430
531
|
|
|
431
532
|
```bash
|
|
@@ -220,10 +220,10 @@ function ImageMaker() {
|
|
|
220
220
|
<button
|
|
221
221
|
onClick={() =>
|
|
222
222
|
generate({
|
|
223
|
-
entityId: '
|
|
223
|
+
entityId: 'ent_modeldef_gpt_image_1_5',
|
|
224
224
|
prompt: 'A serene mountain landscape at sunset',
|
|
225
225
|
size: '1024x1024',
|
|
226
|
-
quality: '
|
|
226
|
+
quality: 'high',
|
|
227
227
|
})
|
|
228
228
|
}
|
|
229
229
|
disabled={isLoading}
|
|
@@ -237,6 +237,56 @@ function ImageMaker() {
|
|
|
237
237
|
}
|
|
238
238
|
```
|
|
239
239
|
|
|
240
|
+
### `useFiasFiles()` — User-files filesystem (SDK ≥ 1.9.0)
|
|
241
|
+
|
|
242
|
+
**Permissions:** `files:read` for `list`/`read`/`getDownloadUrl`; add `files:write` for `write`/`update`/`delete`
|
|
243
|
+
**Returns:** `FiasFilesApi`
|
|
244
|
+
|
|
245
|
+
Access the user's Fias filesystem, scoped to files this arche owns. Files written through this hook (and images created via `useImageGeneration()`) appear in MyData under `/My-Fias/{ArcheName}/`. Listing is by ownership — moving a file in MyData doesn't hide it from the arche.
|
|
246
|
+
|
|
247
|
+
The most common use is `getDownloadUrl(fileId)` to refresh the presigned URL on a generated image after the original (~1h) expires:
|
|
248
|
+
|
|
249
|
+
```tsx
|
|
250
|
+
import { useFiasFiles, useImageGeneration } from '@fias/arche-sdk';
|
|
251
|
+
|
|
252
|
+
function PortraitGallery({ savedFileId }: { savedFileId: string }) {
|
|
253
|
+
const { getDownloadUrl } = useFiasFiles();
|
|
254
|
+
const [url, setUrl] = useState<string | null>(null);
|
|
255
|
+
|
|
256
|
+
useEffect(() => {
|
|
257
|
+
let cancelled = false;
|
|
258
|
+
getDownloadUrl(savedFileId).then((r) => {
|
|
259
|
+
if (!cancelled) setUrl(r.url);
|
|
260
|
+
});
|
|
261
|
+
return () => {
|
|
262
|
+
cancelled = true;
|
|
263
|
+
};
|
|
264
|
+
}, [savedFileId, getDownloadUrl]);
|
|
265
|
+
|
|
266
|
+
return url ? <img src={url} alt="" /> : null;
|
|
267
|
+
}
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Store the `fileId`, not the `imageUrl`.** Image-generation results include both, but `imageUrl` is a short-lived presigned link. Persist `fileId` in your data store and resolve to a fresh URL on render via `getDownloadUrl`.
|
|
271
|
+
|
|
272
|
+
**Same-name writes overwrite.** Calling `write({ name: 'save.json', content })` twice with the same name reuses the existing `fileId` and replaces the content — useful for periodic snapshots.
|
|
273
|
+
|
|
274
|
+
**`read()` is text-only.** It rejects binary content types with HTTP 415. Use `getDownloadUrl(fileId)` and pass the URL to `<img>`, `fetch`, etc. for binaries.
|
|
275
|
+
|
|
276
|
+
```tsx
|
|
277
|
+
const files = useFiasFiles();
|
|
278
|
+
|
|
279
|
+
await files.write({
|
|
280
|
+
name: 'save.json',
|
|
281
|
+
content: JSON.stringify(state),
|
|
282
|
+
contentType: 'application/json',
|
|
283
|
+
});
|
|
284
|
+
const { content } = await files.read(fileId);
|
|
285
|
+
const { files: page, nextCursor } = await files.list({ limit: 20 });
|
|
286
|
+
await files.update(fileId, { tags: ['draft'] });
|
|
287
|
+
await files.delete(fileId);
|
|
288
|
+
```
|
|
289
|
+
|
|
240
290
|
### `useFiasNavigation()` — In-plugin routing
|
|
241
291
|
|
|
242
292
|
**Permission:** None required
|
|
@@ -337,6 +387,12 @@ fias.showToast('Saved!', 'success'); // Toast: 'info' | 'success' | 'warning' |
|
|
|
337
387
|
|
|
338
388
|
These are hard limits enforced by the platform. Code that violates these will fail review or be blocked at runtime.
|
|
339
389
|
|
|
390
|
+
### Hitting a limit? Tell the user about Entity requests
|
|
391
|
+
|
|
392
|
+
Don't just say "can't do that" when the user asks for something blocked by these rules — most often a direct external API call, a third-party service, or a capability the platform hasn't surfaced yet. The Fias team adds new **Entities** on request: platform-managed wrappers that hold credentials, handle auth, and expose the capability to plugins through `useEntityInvocation()` (or `useImageGeneration()` for image models). The plugin never bypasses the sandbox — it invokes the new Entity like any other model.
|
|
393
|
+
|
|
394
|
+
When you hit a constraint, say so AND tell the user: file an Entity request on the Customer Support arche at `https://platform.fias.io/a/arche_customer_support`. Describe the service, endpoints, and auth method needed; once the Entity ships, the plugin can call it via `useEntityInvocation` with no sandbox change. Then propose a fallback that works inside the current sandbox (mock data, a simpler path, deferring the call) so the build keeps moving while the request is in flight.
|
|
395
|
+
|
|
340
396
|
### Sandboxing
|
|
341
397
|
|
|
342
398
|
- Plugins run in an iframe with `sandbox="allow-scripts allow-forms allow-same-origin allow-downloads"`
|
|
@@ -390,6 +446,18 @@ If newer package versions are available, tell the user and ask if they want to u
|
|
|
390
446
|
|
|
391
447
|
If `sync --dry-run` shows pending changes, tell the user and offer to run `npx fias-dev sync` to update AI instruction files and config from the latest SDK templates. This never touches source code or project-specific files (`package.json`, `fias-plugin.json`, `src/`).
|
|
392
448
|
|
|
449
|
+
#### UI cache after a harness upgrade
|
|
450
|
+
|
|
451
|
+
The harness pulls its host-page UI (toolbar, mode toggle, sign-in modal) from a CDN and caches it in `~/.fias/harness-cache/`. The cached UI takes priority over the bundled copy that ships in the npm package.
|
|
452
|
+
|
|
453
|
+
When you upgrade `@fias/plugin-dev-harness` but the CDN hasn't been redeployed yet, the cached UI can be older than the CLI. fias-dev now detects this case automatically and falls back to the bundled UI — look for this line in the startup log:
|
|
454
|
+
|
|
455
|
+
```
|
|
456
|
+
ℹ Cached harness UI v1.14.3 is older than CLI v1.18.0 — using bundled UI.
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
That message means everything is fine; the bundled UI exactly matches your CLI version. If you ever see stale behavior persist across an upgrade (and the line above didn't appear), delete `~/.fias/harness-cache/` and restart.
|
|
460
|
+
|
|
393
461
|
### Starting Development
|
|
394
462
|
|
|
395
463
|
```bash
|
|
@@ -423,9 +491,42 @@ npx fias-dev login --env production # Authenticate with production
|
|
|
423
491
|
npx fias-dev entities # List all
|
|
424
492
|
npx fias-dev entities --search "image" # Search by keyword
|
|
425
493
|
npx fias-dev entities --type "model-definition" # Filter by type
|
|
426
|
-
npx fias-dev entities --detail
|
|
494
|
+
npx fias-dev entities --detail ent_modeldef_gpt_image_1_5 # Full entity details (capabilities, sizes, pricing)
|
|
427
495
|
```
|
|
428
496
|
|
|
497
|
+
### Debugging — Read the Browser's View Directly
|
|
498
|
+
|
|
499
|
+
The harness mirrors every browser-side event to a per-port log file at `/tmp/fias-dev-<port>.log` (so usually `/tmp/fias-dev-3200.log`). The file path is also printed at startup:
|
|
500
|
+
|
|
501
|
+
```
|
|
502
|
+
Browser dev-log mirror: /tmp/fias-dev-3200.log
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
What's captured:
|
|
506
|
+
|
|
507
|
+
- Every Dev Console entry (`send` / `recv` / `info` / `error` / `toast` / `cost` / `nav`)
|
|
508
|
+
- Every uncaught JS error (`window.error`)
|
|
509
|
+
- Every unhandled promise rejection (`unhandledrejection`)
|
|
510
|
+
- Bridge requests + responses with payload previews
|
|
511
|
+
|
|
512
|
+
Format is one line per event:
|
|
513
|
+
|
|
514
|
+
```
|
|
515
|
+
2026-05-24T07:14:33.123Z [ERROR] window.error {"message":"...","file":"...","line":42}
|
|
516
|
+
2026-05-24T07:14:35.456Z [SEND] image_generate {"entityId":"ent_modeldef_..."}
|
|
517
|
+
2026-05-24T07:14:36.789Z [RECV] response {...}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
**For AI agents pair-debugging with a developer:** tail this file instead of asking the developer to open DevTools and copy-paste output. Reproduce the failing action in the browser, then read the file — you'll see exactly what the iframe and harness exchanged.
|
|
521
|
+
|
|
522
|
+
```bash
|
|
523
|
+
tail -f /tmp/fias-dev-3200.log
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
The file is truncated on every `fias-dev` start, so it always reflects the current session.
|
|
527
|
+
|
|
528
|
+
The mirror uses `navigator.sendBeacon` (with a `fetch` fallback) so there's a sub-second delay before the most recent events land in the file. If you're chasing a race, give it a beat before reading.
|
|
529
|
+
|
|
429
530
|
### Validating the Manifest
|
|
430
531
|
|
|
431
532
|
```bash
|