@fias/arche-sdk 1.9.0 → 1.11.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/dist/index.mjs CHANGED
@@ -497,6 +497,60 @@ function useImageGeneration() {
497
497
  );
498
498
  return { generate, isLoading, result, error };
499
499
  }
500
+ function useAudioGeneration() {
501
+ const bridge = useBridge();
502
+ const [isLoading, setIsLoading] = useState2(false);
503
+ const [result, setResult] = useState2(null);
504
+ const [error, setError] = useState2(null);
505
+ const generate = useCallback(
506
+ async (params) => {
507
+ setIsLoading(true);
508
+ setError(null);
509
+ try {
510
+ const res = await bridge.request("audio_generate", params, 18e4);
511
+ setResult(res);
512
+ return res;
513
+ } catch (err) {
514
+ const e = err instanceof Error ? err : new Error(String(err));
515
+ setError(e);
516
+ throw e;
517
+ } finally {
518
+ setIsLoading(false);
519
+ }
520
+ },
521
+ [bridge]
522
+ );
523
+ return { generate, isLoading, result, error };
524
+ }
525
+ function useSurface(surfaceKey, timeoutMs = 18e4) {
526
+ const bridge = useBridge();
527
+ const [isLoading, setIsLoading] = useState2(false);
528
+ const [result, setResult] = useState2(null);
529
+ const [error, setError] = useState2(null);
530
+ const invoke = useCallback(
531
+ async (params) => {
532
+ setIsLoading(true);
533
+ setError(null);
534
+ try {
535
+ const res = await bridge.request(
536
+ "surface_invoke",
537
+ { surfaceKey, params },
538
+ timeoutMs
539
+ );
540
+ setResult(res);
541
+ return res;
542
+ } catch (err) {
543
+ const e = err instanceof Error ? err : new Error(String(err));
544
+ setError(e);
545
+ throw e;
546
+ } finally {
547
+ setIsLoading(false);
548
+ }
549
+ },
550
+ [bridge, surfaceKey, timeoutMs]
551
+ );
552
+ return { invoke, isLoading, result, error };
553
+ }
500
554
  function useFiasNavigation() {
501
555
  const bridge = useBridge();
502
556
  const [currentPath, setCurrentPath] = useState2(bridge.getCurrentPath());
@@ -760,32 +814,44 @@ function useFiasStore() {
760
814
  ]
761
815
  );
762
816
  }
763
- var FILES_DOWNLOAD_URL_REFRESH_BUFFER_MS = 6e4;
817
+ var DOWNLOAD_URL_REFRESH_BUFFER_MS = 6e4;
764
818
  var downloadUrlCache = /* @__PURE__ */ new Map();
765
819
  var downloadUrlInflight = /* @__PURE__ */ new Map();
766
- async function fetchFileDownloadUrl(fileId) {
820
+ async function fetchVaultDocumentDownloadUrl(documentId) {
767
821
  const now = Date.now();
768
- const cached = downloadUrlCache.get(fileId);
769
- if (cached && now < cached.expiresAt - FILES_DOWNLOAD_URL_REFRESH_BUFFER_MS) {
770
- return { url: cached.url, expiresAt: cached.expiresAt };
822
+ const cached = downloadUrlCache.get(documentId);
823
+ if (cached && now < cached.expiresAt - DOWNLOAD_URL_REFRESH_BUFFER_MS) {
824
+ return { url: cached.url, expiresAt: cached.expiresAt, contentType: cached.contentType };
771
825
  }
772
- const inflight = downloadUrlInflight.get(fileId);
826
+ const inflight = downloadUrlInflight.get(documentId);
773
827
  if (inflight) return inflight;
774
828
  const bridge = getBridge();
775
- const promise = bridge.request("files_download_url", { fileId }).then((result) => {
776
- downloadUrlCache.set(fileId, { url: result.url, expiresAt: result.expiresAt });
777
- return result;
829
+ const promise = bridge.request(
830
+ "vault_documents_download_url",
831
+ { documentId }
832
+ ).then((result) => {
833
+ const normalized = {
834
+ url: result.url,
835
+ expiresAt: new Date(result.expiresAt).getTime(),
836
+ contentType: result.contentType
837
+ };
838
+ downloadUrlCache.set(documentId, {
839
+ url: normalized.url,
840
+ expiresAt: normalized.expiresAt,
841
+ contentType: normalized.contentType
842
+ });
843
+ return normalized;
778
844
  }).finally(() => {
779
- downloadUrlInflight.delete(fileId);
845
+ downloadUrlInflight.delete(documentId);
780
846
  });
781
- downloadUrlInflight.set(fileId, promise);
847
+ downloadUrlInflight.set(documentId, promise);
782
848
  return promise;
783
849
  }
784
- function useFiasFiles() {
850
+ function useVaultDocuments() {
785
851
  const bridge = useBridge();
786
852
  const list = useCallback(
787
853
  async (options) => {
788
- return bridge.request("files_list", {
854
+ return bridge.request("vault_documents_list", {
789
855
  search: options?.search,
790
856
  limit: options?.limit,
791
857
  cursor: options?.cursor
@@ -794,13 +860,15 @@ function useFiasFiles() {
794
860
  [bridge]
795
861
  );
796
862
  const read = useCallback(
797
- async (fileId) => {
798
- return bridge.request("files_read", { fileId });
863
+ async (documentId) => {
864
+ return bridge.request("vault_documents_read", {
865
+ documentId
866
+ });
799
867
  },
800
868
  [bridge]
801
869
  );
802
870
  const getDownloadUrl = useCallback(
803
- (fileId) => fetchFileDownloadUrl(fileId),
871
+ (documentId) => fetchVaultDocumentDownloadUrl(documentId),
804
872
  // The hook closes over the React context's bridge, but the resolver
805
873
  // uses the singleton — they are the same instance in practice. Keeping
806
874
  // `bridge` in the deps for symmetry with other hooks that do go through
@@ -809,7 +877,7 @@ function useFiasFiles() {
809
877
  );
810
878
  const write = useCallback(
811
879
  async (params) => {
812
- return bridge.request("files_write", {
880
+ return bridge.request("vault_documents_write", {
813
881
  name: params.name,
814
882
  content: params.content,
815
883
  contentType: params.contentType,
@@ -819,21 +887,21 @@ function useFiasFiles() {
819
887
  [bridge]
820
888
  );
821
889
  const update = useCallback(
822
- async (fileId, params) => {
823
- await bridge.request("files_update", {
824
- fileId,
890
+ async (documentId, params) => {
891
+ await bridge.request("vault_documents_update", {
892
+ documentId,
825
893
  name: params.name,
826
894
  tags: params.tags
827
895
  });
828
- downloadUrlCache.delete(fileId);
896
+ downloadUrlCache.delete(documentId);
829
897
  },
830
898
  [bridge]
831
899
  );
832
- const deleteFile = useCallback(
833
- async (fileId) => {
834
- await bridge.request("files_delete", { fileId });
835
- downloadUrlCache.delete(fileId);
836
- downloadUrlInflight.delete(fileId);
900
+ const deleteDocument = useCallback(
901
+ async (documentId) => {
902
+ await bridge.request("vault_documents_delete", { documentId });
903
+ downloadUrlCache.delete(documentId);
904
+ downloadUrlInflight.delete(documentId);
837
905
  },
838
906
  [bridge]
839
907
  );
@@ -844,11 +912,76 @@ function useFiasFiles() {
844
912
  getDownloadUrl,
845
913
  write,
846
914
  update,
847
- delete: deleteFile
915
+ delete: deleteDocument
848
916
  }),
849
- [list, read, getDownloadUrl, write, update, deleteFile]
917
+ [list, read, getDownloadUrl, write, update, deleteDocument]
850
918
  );
851
919
  }
920
+ function useArcheAssets() {
921
+ const bridge = useBridge();
922
+ const list = useCallback(
923
+ async (options) => {
924
+ return bridge.request("arche_assets_list", {
925
+ cursor: options?.cursor,
926
+ limit: options?.limit
927
+ });
928
+ },
929
+ [bridge]
930
+ );
931
+ const getUrl = useCallback(
932
+ async (assetId) => {
933
+ return bridge.request("arche_assets_get_url", { assetId });
934
+ },
935
+ [bridge]
936
+ );
937
+ return useMemo2(() => ({ list, getUrl }), [list, getUrl]);
938
+ }
939
+
940
+ // src/generated/surfaces.ts
941
+ var AUDIO_AUDIO_ISOLATION_SURFACE_KEY = "audio.audio-isolation";
942
+ var useElevenLabsAudioIsolation = () => useSurface(
943
+ AUDIO_AUDIO_ISOLATION_SURFACE_KEY
944
+ );
945
+ var AUDIO_FORCED_ALIGNMENT_SURFACE_KEY = "audio.forced-alignment";
946
+ var useElevenLabsForcedAlignment = () => useSurface(
947
+ AUDIO_FORCED_ALIGNMENT_SURFACE_KEY
948
+ );
949
+ var AUDIO_LYRIA_MUSIC_SURFACE_KEY = "audio.lyria-music";
950
+ var useLyriaMusic = () => useSurface(AUDIO_LYRIA_MUSIC_SURFACE_KEY);
951
+ var AUDIO_MUSIC_SURFACE_KEY = "audio.music";
952
+ var useElevenLabsMusic = () => useSurface(AUDIO_MUSIC_SURFACE_KEY);
953
+ var AUDIO_SOUND_EFFECTS_SURFACE_KEY = "audio.sound-effects";
954
+ var useElevenLabsSfx = () => useSurface(AUDIO_SOUND_EFFECTS_SURFACE_KEY);
955
+ var AUDIO_SPEECH_TO_TEXT_SURFACE_KEY = "audio.speech-to-text";
956
+ var useElevenLabsStt = () => useSurface(AUDIO_SPEECH_TO_TEXT_SURFACE_KEY);
957
+ var AUDIO_TTS_SURFACE_KEY = "audio.tts";
958
+ var useElevenLabsTts = () => useSurface(AUDIO_TTS_SURFACE_KEY);
959
+ var AUDIO_VOICE_CHANGER_SURFACE_KEY = "audio.voice-changer";
960
+ var useElevenLabsVoiceChanger = () => useSurface(
961
+ AUDIO_VOICE_CHANGER_SURFACE_KEY
962
+ );
963
+ var AUDIO_VOICE_DESIGN_SURFACE_KEY = "audio.voice-design";
964
+ var useElevenLabsVoiceDesign = () => useSurface(
965
+ AUDIO_VOICE_DESIGN_SURFACE_KEY
966
+ );
967
+
968
+ // src/generated/permissions.ts
969
+ var VALID_PLUGIN_PERMISSIONS = [
970
+ "assets:read",
971
+ "data:store",
972
+ "entities:audio_generate",
973
+ "entities:image_generate",
974
+ "entities:invoke",
975
+ "storage:sandbox",
976
+ "store:purchase",
977
+ "theme:read",
978
+ "user:profile:read",
979
+ "vault:documents:read",
980
+ "vault:documents:write"
981
+ ];
982
+ function isValidPluginPermission(perm) {
983
+ return VALID_PLUGIN_PERMISSIONS.includes(perm);
984
+ }
852
985
 
853
986
  // src/fias.ts
854
987
  var fias = {
@@ -2703,28 +2836,51 @@ function getFontPairingById(id) {
2703
2836
  return FONT_PAIRINGS.find((f) => f.id === id) ?? FONT_PAIRINGS[0];
2704
2837
  }
2705
2838
  export {
2839
+ AUDIO_AUDIO_ISOLATION_SURFACE_KEY,
2840
+ AUDIO_FORCED_ALIGNMENT_SURFACE_KEY,
2841
+ AUDIO_LYRIA_MUSIC_SURFACE_KEY,
2842
+ AUDIO_MUSIC_SURFACE_KEY,
2843
+ AUDIO_SOUND_EFFECTS_SURFACE_KEY,
2844
+ AUDIO_SPEECH_TO_TEXT_SURFACE_KEY,
2845
+ AUDIO_TTS_SURFACE_KEY,
2846
+ AUDIO_VOICE_CHANGER_SURFACE_KEY,
2847
+ AUDIO_VOICE_DESIGN_SURFACE_KEY,
2706
2848
  DARK_THEME,
2707
2849
  FONT_PAIRINGS,
2708
2850
  FiasBridge,
2709
2851
  FiasProvider,
2710
2852
  LIGHT_THEME,
2711
2853
  THEME_CATALOG,
2712
- fetchFileDownloadUrl,
2854
+ VALID_PLUGIN_PERMISSIONS,
2855
+ fetchVaultDocumentDownloadUrl,
2713
2856
  fias,
2714
2857
  getBridge,
2715
2858
  getDefaultTheme,
2716
2859
  getFontPairingById,
2717
2860
  getThemeById,
2861
+ isValidPluginPermission,
2718
2862
  resetBridge,
2863
+ useArcheAssets,
2864
+ useAudioGeneration,
2865
+ useElevenLabsAudioIsolation,
2866
+ useElevenLabsForcedAlignment,
2867
+ useElevenLabsMusic,
2868
+ useElevenLabsSfx,
2869
+ useElevenLabsStt,
2870
+ useElevenLabsTts,
2871
+ useElevenLabsVoiceChanger,
2872
+ useElevenLabsVoiceDesign,
2719
2873
  useEntityInvocation,
2720
2874
  useFiasDataStore,
2721
- useFiasFiles,
2722
2875
  useFiasNavigation,
2723
2876
  useFiasStorage,
2724
2877
  useFiasStore,
2725
2878
  useFiasTheme,
2726
2879
  useFiasUser,
2727
2880
  useImageGeneration,
2881
+ useLyriaMusic,
2728
2882
  usePersistentState,
2729
- useStepNavigation
2883
+ useStepNavigation,
2884
+ useSurface,
2885
+ useVaultDocuments
2730
2886
  };
package/dist/types.d.ts CHANGED
@@ -1,7 +1,14 @@
1
1
  /**
2
2
  * Permission scopes that plugins can request in their manifest.
3
+ *
4
+ * Re-exported from `./generated/permissions`, which is produced by
5
+ * `pnpm generate:sdk-types` from `@fias/db-types`'s canonical list. The
6
+ * `sdk-permissions-match-db-types.test.ts` architecture trip-wire ensures
7
+ * the generated file stays in lockstep.
3
8
  */
4
- export type PluginPermission = 'user:profile:read' | 'entities:invoke' | 'entities:image_generate' | 'storage:sandbox' | 'theme:read' | 'data:store' | 'store:purchase' | 'files:read' | 'files:write';
9
+ import type { PluginPermission } from './generated/permissions';
10
+ export type { PluginPermission };
11
+ export { VALID_PLUGIN_PERMISSIONS, isValidPluginPermission } from './generated/permissions';
5
12
  /**
6
13
  * User profile data available via useFiasUser() hook.
7
14
  */
@@ -99,18 +106,49 @@ export interface EntityInvocationParams {
99
106
  * Image generation parameters for useImageGeneration() hook.
100
107
  */
101
108
  export interface ImageGenerationParams {
102
- /** Entity ID of an image model (e.g., ent_modeldef_dalle3) */
109
+ /** Entity ID of an image model (e.g., ent_modeldef_gpt_image_1_5) */
103
110
  entityId: string;
104
111
  /** Text prompt describing the image to generate */
105
112
  prompt: string;
106
113
  /** Image size/aspect ratio (model-specific, e.g., '1024x1024', '16:9') */
107
114
  size?: string;
108
- /** Quality level (model-specific, e.g., 'standard', 'hd') */
115
+ /** Quality level (model-specific, e.g., 'low', 'medium', 'high') */
109
116
  quality?: string;
110
- /** Artistic style (model-specific, e.g., 'vivid', 'natural') */
117
+ /** Artistic style (model-specific, e.g., 'realistic_image', 'digital_illustration') */
111
118
  style?: string;
112
119
  /** Additional provider-specific parameters */
113
120
  providerParams?: Record<string, unknown>;
121
+ /**
122
+ * Optional reference image for image-to-image generation. Provide ONE of:
123
+ *
124
+ * - `{ archeAssetId }` — a published asset from this arche's library
125
+ * (uses the `assets:read` permission scope to read bytes server-side).
126
+ * - `{ fileId }` — a Vault Document this arche owns (uses
127
+ * `vault:documents:read` to read bytes server-side). For images
128
+ * previously generated via `useImageGeneration`, pass `result.fileId`.
129
+ * - `{ dataUrl }` — a `data:` URL with base64-encoded PNG/JPEG/WEBP
130
+ * bytes. Use only when the source isn't already in the asset library
131
+ * or vault; subject to a payload-size cap (~8 MB).
132
+ *
133
+ * The selected image model must support reference images (e.g. the
134
+ * Stability AI entities `ent_modeldef_stable_img_core`,
135
+ * `ent_modeldef_stable_img_ultra`, `ent_modeldef_sd3_large`). Models
136
+ * that don't support it return INVALID_PARAMS rather than silently
137
+ * ignoring the reference.
138
+ */
139
+ referenceImage?: {
140
+ archeAssetId: string;
141
+ } | {
142
+ fileId: string;
143
+ } | {
144
+ dataUrl: string;
145
+ };
146
+ /**
147
+ * How closely the output should follow the reference image. 0 = ignore
148
+ * the reference, 1 = copy it almost exactly. Default 0.5 when a
149
+ * `referenceImage` is provided.
150
+ */
151
+ referenceStrength?: number;
114
152
  }
115
153
  /**
116
154
  * Image generation result.
@@ -138,6 +176,73 @@ export interface ImageGenerationApi {
138
176
  result: ImageGenerationResult | null;
139
177
  error: Error | null;
140
178
  }
179
+ /**
180
+ * Audio sub-type discriminator. v1 ships music only; future entries
181
+ * (`'speech'`, `'sfx'`, ...) extend the unions on `AudioGenerationParams`,
182
+ * `AudioGenerationResult`, and the bridge dispatch in lockstep.
183
+ */
184
+ export type AudioType = 'music';
185
+ /**
186
+ * Audio generation parameters for useAudioGeneration() hook.
187
+ *
188
+ * Discriminated union by `audioType` so future sub-types can carry their
189
+ * own parameter shape (e.g., speech adds voice/style, SFX adds duration
190
+ * range) without breaking music callers.
191
+ */
192
+ export type AudioGenerationParams = MusicAudioGenerationParams;
193
+ /** Parameters for music audio generation (Lyria today). */
194
+ export interface MusicAudioGenerationParams {
195
+ audioType: 'music';
196
+ /** Entity ID of a music model (e.g., ent_modeldef_lyria2) OR a PluginAudioConfig configId. */
197
+ entityId: string;
198
+ /** Text prompt describing the music to generate. */
199
+ prompt: string;
200
+ /** Optional negative prompt — sounds or styles to avoid. */
201
+ negativePrompt?: string;
202
+ /** Optional seed for deterministic regeneration. */
203
+ seed?: number;
204
+ /** Number of clips to generate (1–4 for Lyria 2). */
205
+ sampleCount?: number;
206
+ /** Requested duration in seconds (Lyria 2 emits a fixed 30 s clip). */
207
+ durationSeconds?: number;
208
+ }
209
+ /**
210
+ * Audio generation result. Always returns an array of clips so multi-clip
211
+ * generations (sampleCount > 1) and single-clip generations share one shape.
212
+ */
213
+ export interface AudioGenerationResult {
214
+ /** Audio sub-type discriminator matching the request. */
215
+ audioType: AudioType;
216
+ /** Generated audio clips. */
217
+ clips: Array<{
218
+ /** Same-origin signed proxy URL for `<audio src>`. Expires after ~1 hour. */
219
+ audioUrl: string;
220
+ /** S3 reference for the clip (use for persistent storage / re-signing). */
221
+ audioRef: string;
222
+ /** User-file record id (best-effort; undefined if the write failed). */
223
+ fileId?: string;
224
+ /** MIME type — `audio/wav` today. */
225
+ mimeType: string;
226
+ sampleRate: number;
227
+ durationSeconds: number;
228
+ sizeBytes: number;
229
+ }>;
230
+ /** Sum of `clips[].durationSeconds`. */
231
+ totalDurationSeconds: number;
232
+ /** Provider that generated the audio. */
233
+ provider: string;
234
+ /** Provider-side model name. */
235
+ model: string;
236
+ }
237
+ /**
238
+ * Audio generation API available via useAudioGeneration() hook.
239
+ */
240
+ export interface AudioGenerationApi {
241
+ generate: (params: AudioGenerationParams) => Promise<AudioGenerationResult>;
242
+ isLoading: boolean;
243
+ result: AudioGenerationResult | null;
244
+ error: Error | null;
245
+ }
141
246
  /**
142
247
  * Navigation API available via useFiasNavigation() hook.
143
248
  */
@@ -146,16 +251,17 @@ export interface FiasNavigationApi {
146
251
  currentPath: string;
147
252
  }
148
253
  /**
149
- * A file owned by the calling arche in the user's Fias file system.
254
+ * A document owned by the calling arche in the user's Vault.
150
255
  *
151
- * Files written via useFiasFiles() (or generated via useImageGeneration())
152
- * are scoped by `source_arche_id`. Listing only returns files the calling
153
- * arche created — files from other arches are never visible.
154
- */
155
- export interface FiasFile {
156
- fileId: string;
157
- fileName: string;
158
- contentType: string;
256
+ * Documents written via useVaultDocuments() (or generated via
257
+ * useImageGeneration()) are scoped by `source_arche_id`. Listing only
258
+ * returns documents the calling arche created — documents from other
259
+ * arches are never visible.
260
+ */
261
+ export interface VaultDocumentSummary {
262
+ documentId: string;
263
+ name: string;
264
+ mimeType: string;
159
265
  sizeBytes: number;
160
266
  /** ISO 8601 timestamp. */
161
267
  createdAt: string;
@@ -164,31 +270,34 @@ export interface FiasFile {
164
270
  /** Free-form tags, set by the arche on write/update. */
165
271
  tags: string[];
166
272
  /**
167
- * Folder path within the user's file tree. The platform places arche-owned
168
- * files in `/My-Fias/{ArcheName}/` by default; users can move them via
169
- * the MyData UI without breaking arche access (listing is scoped by
170
- * source_arche_id, not folder).
273
+ * Folder the document lives in. The platform places arche-owned
274
+ * writes into `/My-Fias/Arches/<archeId>/` by default; users can move
275
+ * them via the My Data UI without breaking arche access (listing is
276
+ * scoped by `source_arche_id`, not folder).
171
277
  */
172
- folderPath: string | null;
278
+ folderId: string | null;
173
279
  }
174
- export interface FiasFilesListOptions {
280
+ export interface VaultDocumentsListOptions {
175
281
  search?: string;
176
282
  limit?: number;
177
283
  cursor?: string;
178
284
  }
179
- export interface FiasFilesListResult {
180
- files: FiasFile[];
285
+ export interface VaultDocumentsListResult {
286
+ documents: VaultDocumentSummary[];
181
287
  nextCursor: string | null;
182
288
  }
183
- export interface FiasFilesDownloadUrl {
289
+ export interface VaultDocumentDownloadUrl {
184
290
  url: string;
185
291
  /** Epoch milliseconds when the presigned URL expires. */
186
292
  expiresAt: number;
293
+ /** MIME type of the document, or null when unset on the row. */
294
+ contentType: string | null;
187
295
  }
188
- export interface FiasFilesWriteParams {
296
+ export interface VaultDocumentWriteParams {
189
297
  /**
190
- * File name (no leading slash). Must be unique per arche per user; same-name
191
- * writes overwrite the existing file's content but keep the same fileId.
298
+ * Document name (no leading slash). Must be unique per arche per
299
+ * user; same-name writes create a new row with the same name (no
300
+ * implicit overwrite — call `delete` first if that's what you want).
192
301
  */
193
302
  name: string;
194
303
  /** UTF-8 string content. Use for JSON, text, or base64-encoded binaries. */
@@ -198,54 +307,103 @@ export interface FiasFilesWriteParams {
198
307
  /** Free-form tags. */
199
308
  tags?: string[];
200
309
  }
201
- export interface FiasFilesUpdateParams {
202
- /** New file name. */
310
+ export interface VaultDocumentUpdateParams {
311
+ /** New document name. */
203
312
  name?: string;
204
313
  /** Replaces the tag list. */
205
314
  tags?: string[];
206
315
  }
207
316
  /**
208
- * Files API available via useFiasFiles() hook.
317
+ * Vault Documents API available via useVaultDocuments() hook.
209
318
  *
210
- * Provides access to the user's Fias file system, scoped to files this arche
211
- * owns (via `source_arche_id`). Files are visible to the user in MyData under
212
- * `/My-Fias/{ArcheName}/`, but the SDK lists by ownership — moving a file in
213
- * MyData does not hide it from the arche.
319
+ * Provides access to the user's Vault Documents, scoped to documents
320
+ * this arche owns (via `source_arche_id`). Documents are visible to
321
+ * the user in My Data under `/My-Fias/Arches/<archeId>/`, but the SDK
322
+ * lists by ownership — moving a document in My Data does not hide it
323
+ * from the arche.
214
324
  *
215
325
  * Permissions:
216
- * - `files:read` — list, read, getDownloadUrl
217
- * - `files:write` — write, update, delete
326
+ * - `vault:documents:read` — list, read, getDownloadUrl
327
+ * - `vault:documents:write` — write, update, delete
218
328
  *
219
- * Note: images returned from useImageGeneration() are auto-saved into the
220
- * arche's folder and the result includes a `fileId`. Pass that fileId here
221
- * to refresh the presigned URL after the original ~1h TTL expires.
222
- */
223
- export interface FiasFilesApi {
224
- /** List files owned by this arche. Paginated. */
225
- list: (options?: FiasFilesListOptions) => Promise<FiasFilesListResult>;
226
- /** Read the UTF-8 content of a file. */
227
- read: (fileId: string) => Promise<{
329
+ * Note: images returned from useImageGeneration() are auto-saved into
330
+ * the arche's folder and the result includes a `documentId`. Pass that
331
+ * documentId here to refresh the presigned URL after the original ~1h
332
+ * TTL expires.
333
+ */
334
+ export interface VaultDocumentsApi {
335
+ /** List documents owned by this arche. Paginated. */
336
+ list: (options?: VaultDocumentsListOptions) => Promise<VaultDocumentsListResult>;
337
+ /** Read the UTF-8 content of a document. */
338
+ read: (documentId: string) => Promise<{
228
339
  content: string;
229
340
  contentType: string;
230
341
  }>;
231
342
  /**
232
- * Get a fresh presigned download URL for a fileId. The result is cached
233
- * client-side and refreshed automatically before expiry.
343
+ * Get a fresh presigned download URL for a documentId. The result is
344
+ * cached client-side and refreshed automatically before expiry.
234
345
  */
235
- getDownloadUrl: (fileId: string) => Promise<FiasFilesDownloadUrl>;
236
- /** Create or overwrite a file. Returns the fileId. */
237
- write: (params: FiasFilesWriteParams) => Promise<{
238
- fileId: string;
346
+ getDownloadUrl: (documentId: string) => Promise<VaultDocumentDownloadUrl>;
347
+ /** Create a document. Returns the documentId. */
348
+ write: (params: VaultDocumentWriteParams) => Promise<{
349
+ documentId: string;
239
350
  }>;
240
- /** Rename or retag a file. */
241
- update: (fileId: string, params: FiasFilesUpdateParams) => Promise<void>;
242
- /** Soft-delete a file (recoverable from the Trash in MyData for 7 days). */
243
- delete: (fileId: string) => Promise<void>;
351
+ /** Rename or retag a document. */
352
+ update: (documentId: string, params: VaultDocumentUpdateParams) => Promise<void>;
353
+ /** Soft-delete a document (recoverable from Trash in My Data). */
354
+ delete: (documentId: string) => Promise<void>;
355
+ }
356
+ /**
357
+ * One entry from the arche's published asset manifest. Surfaced to
358
+ * plugins via `useArcheAssets().list()`.
359
+ *
360
+ * `signedUrl` is a short-lived (~5 min default) URL that loads through
361
+ * api.fias.ai's signed proxy. Plugins should use `getUrl(assetId)` to
362
+ * refresh after expiry rather than caching URLs across sessions.
363
+ */
364
+ export interface ArcheAsset {
365
+ assetId: string;
366
+ signedUrl: string;
367
+ /** Unix-seconds expiry of `signedUrl`. */
368
+ expiresAt: number;
369
+ contentType: 'image/png' | 'image/jpeg' | 'image/webp';
370
+ width: number;
371
+ height: number;
372
+ sizeBytes: number;
373
+ /** Display name set by the contributor. May be null if not provided. */
374
+ name: string | null;
375
+ /** Alt text — recommended for accessibility-aware rendering. */
376
+ altText: string | null;
377
+ /** Tags set by the contributor for filtering. Empty array if none. */
378
+ tags: string[];
379
+ }
380
+ export interface ArcheAssetsListOptions {
381
+ cursor?: string;
382
+ /** 1..100. Default 50. */
383
+ limit?: number;
384
+ }
385
+ export interface ArcheAssetsListResult {
386
+ entries: ArcheAsset[];
387
+ nextCursor: string | null;
388
+ }
389
+ /**
390
+ * Asset library API. Permission: `assets:read`.
391
+ *
392
+ * The library is a contributor-curated set of images pinned to this
393
+ * arche's published version — once the contributor publishes, the set
394
+ * is immutable for that version's runtime. New uploads on the
395
+ * contributor's side affect future published versions only.
396
+ */
397
+ export interface ArcheAssetsApi {
398
+ /** Page through the published asset manifest. */
399
+ list: (options?: ArcheAssetsListOptions) => Promise<ArcheAssetsListResult>;
400
+ /** Refresh the signed URL for a single asset. */
401
+ getUrl: (assetId: string) => Promise<ArcheAsset>;
244
402
  }
245
403
  /**
246
404
  * Message types sent from the plugin iframe to the parent frame.
247
405
  */
248
- export type PluginToHostMessageType = 'ready' | 'resize' | 'toast' | 'get_user' | 'get_theme' | 'storage_read' | 'storage_write' | 'storage_list' | 'storage_delete' | 'entity_invoke' | 'image_generate' | 'navigate' | 'data_create_collection' | 'data_list_collections' | 'data_delete_collection' | 'data_put' | 'data_get' | 'data_query' | 'data_delete' | 'store_get_products' | 'store_purchase' | 'store_get_entitlements' | 'store_get_purchase_history' | 'store_restore' | 'store_cancel_subscription' | 'files_list' | 'files_read' | 'files_download_url' | 'files_write' | 'files_update' | 'files_delete';
406
+ export type PluginToHostMessageType = 'ready' | 'resize' | 'toast' | 'get_user' | 'get_theme' | 'storage_read' | 'storage_write' | 'storage_list' | 'storage_delete' | 'entity_invoke' | 'image_generate' | 'audio_generate' | 'surface_invoke' | 'navigate' | 'data_create_collection' | 'data_list_collections' | 'data_delete_collection' | 'data_put' | 'data_get' | 'data_query' | 'data_delete' | 'store_get_products' | 'store_purchase' | 'store_get_entitlements' | 'store_get_purchase_history' | 'store_restore' | 'store_cancel_subscription' | 'vault_documents_list' | 'vault_documents_read' | 'vault_documents_download_url' | 'vault_documents_write' | 'vault_documents_update' | 'vault_documents_delete' | 'arche_assets_list' | 'arche_assets_get_url';
249
407
  /**
250
408
  * Step navigation API available via useStepNavigation() hook.
251
409
  */