@fias/arche-sdk 2.11.0 → 2.13.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.
Files changed (42) hide show
  1. package/dist/bridge.d.ts +27 -1
  2. package/dist/bridge.d.ts.map +1 -1
  3. package/dist/bridge.js +58 -0
  4. package/dist/bridge.js.map +1 -1
  5. package/dist/bridge.test.js +97 -4
  6. package/dist/bridge.test.js.map +1 -1
  7. package/dist/entity-ops.d.ts +24 -2
  8. package/dist/entity-ops.d.ts.map +1 -1
  9. package/dist/entity-ops.js +21 -1
  10. package/dist/entity-ops.js.map +1 -1
  11. package/dist/fias.d.ts +9 -4
  12. package/dist/fias.d.ts.map +1 -1
  13. package/dist/fias.js +15 -8
  14. package/dist/fias.js.map +1 -1
  15. package/dist/generated/permissions.d.ts +1 -1
  16. package/dist/generated/permissions.d.ts.map +1 -1
  17. package/dist/generated/permissions.js +6 -0
  18. package/dist/generated/permissions.js.map +1 -1
  19. package/dist/hooks.d.ts +58 -1
  20. package/dist/hooks.d.ts.map +1 -1
  21. package/dist/hooks.js +263 -3
  22. package/dist/hooks.js.map +1 -1
  23. package/dist/hooks.test.js +67 -0
  24. package/dist/hooks.test.js.map +1 -1
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +29 -1
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +719 -19
  30. package/dist/panels.d.ts +213 -0
  31. package/dist/panels.d.ts.map +1 -0
  32. package/dist/panels.js +422 -0
  33. package/dist/panels.js.map +1 -0
  34. package/dist/panels.test.d.ts +2 -0
  35. package/dist/panels.test.d.ts.map +1 -0
  36. package/dist/panels.test.js +127 -0
  37. package/dist/panels.test.js.map +1 -0
  38. package/dist/types.d.ts +311 -4
  39. package/dist/types.d.ts.map +1 -1
  40. package/package.json +1 -1
  41. package/templates/default/AGENTS.md +186 -1
  42. package/templates/default/CLAUDE.md +186 -1
@@ -0,0 +1 @@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AK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACpC,MAAM,IAAI,GAAG,kBAAkB,KAAK,GAAG,CAAC;QACxC,MAAM,MAAM,GAAG,uBAAuB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,EAAE;YAAE,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9C,IAAI,QAAQ,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;YACpD,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBAAE,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,4BAA4B,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC;YACpF,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAChF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=panels.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panels.test.d.ts","sourceRoot":"","sources":["../src/panels.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const panels_1 = require("./panels");
4
+ const panel = {
5
+ id: 'reward-default',
6
+ title: 'Game over',
7
+ elements: [
8
+ { kind: 'text', text: 'Score: {score}' },
9
+ { kind: 'conditionalText', text: 'New high score!', showIf: 'isRecord' },
10
+ { kind: 'text', text: 'Base Reward:', joinNext: true },
11
+ { kind: 'slottedItems', slot: 'base' },
12
+ { kind: 'button', label: 'Play again', action: 'emit:restart' },
13
+ ],
14
+ };
15
+ describe('validatePanelCatalog', () => {
16
+ it('accepts a well-formed catalog with a theme', () => {
17
+ const result = (0, panels_1.validatePanelCatalog)({
18
+ theme: { bg: '#F6EAD2', font: "'YoungSerif', Georgia, serif", amountFormat: '×{n}' },
19
+ panels: [panel],
20
+ });
21
+ expect(result).toEqual({ ok: true, issues: [] });
22
+ });
23
+ it('reports every problem at once, each with its path', () => {
24
+ // A validator that stops at the first issue turns one authoring pass into
25
+ // several — the caller is usually showing these in a form.
26
+ const result = (0, panels_1.validatePanelCatalog)({
27
+ panels: [
28
+ { ...panel, id: 'Reward Default' },
29
+ { ...panel, elements: [{ kind: 'confetti' }] },
30
+ ],
31
+ });
32
+ expect(result.ok).toBe(false);
33
+ expect(result.issues).toHaveLength(2);
34
+ expect(result.issues[0]).toContain('catalog.panels[0].id');
35
+ expect(result.issues[1]).toContain('catalog.panels[1].elements[0].kind');
36
+ expect(result.issues[1]).toContain('confetti');
37
+ });
38
+ it('rejects duplicate panel ids — they key dedupe, telemetry and render output', () => {
39
+ const result = (0, panels_1.validatePanelCatalog)({ panels: [panel, { ...panel }] });
40
+ expect(result.ok).toBe(false);
41
+ expect(result.issues[0]).toContain('duplicate panel id "reward-default"');
42
+ });
43
+ it('rejects unknown top-level fields rather than dropping them silently', () => {
44
+ const result = (0, panels_1.validatePanelCatalog)({ panels: [panel], schemaVersion: 1 });
45
+ expect(result.ok).toBe(false);
46
+ expect(result.issues[0]).toContain('unknown field "schemaVersion"');
47
+ });
48
+ it('rejects a non-object and a missing panels array with a usable message', () => {
49
+ expect((0, panels_1.validatePanelCatalog)(null).issues[0]).toContain('expected an object');
50
+ expect((0, panels_1.validatePanelCatalog)({ panels: 'nope' }).issues[0]).toContain('expected an array');
51
+ });
52
+ });
53
+ describe('validatePanelDefinition', () => {
54
+ it('caps the element list', () => {
55
+ const elements = Array.from({ length: panels_1.PANEL_MAX_ELEMENTS + 1 }, () => ({
56
+ kind: 'text',
57
+ text: 'x',
58
+ }));
59
+ const result = (0, panels_1.validatePanelDefinition)({ ...panel, elements });
60
+ expect(result.ok).toBe(false);
61
+ expect(result.issues[0]).toContain(`more than ${panels_1.PANEL_MAX_ELEMENTS} elements`);
62
+ });
63
+ it('requires at least one element', () => {
64
+ expect((0, panels_1.validatePanelDefinition)({ ...panel, elements: [] }).ok).toBe(false);
65
+ });
66
+ it('rejects an unknown field on a known element kind', () => {
67
+ // Mass-assignment's cosmetic cousin: a field nobody reads looks like it works.
68
+ const result = (0, panels_1.validatePanelDefinition)({
69
+ ...panel,
70
+ elements: [{ kind: 'text', text: 'x', color: 'red' }],
71
+ });
72
+ expect(result.ok).toBe(false);
73
+ expect(result.issues[0]).toContain('unknown field "color"');
74
+ });
75
+ it.each([
76
+ ['open_url:javascript:alert(1)', 'a javascript: URL'],
77
+ ['open_url:http://insecure.example', 'plain http'],
78
+ ['open_url://protocol-relative.example', 'protocol-relative'],
79
+ ['open_arche:arc_short', 'a malformed arche id'],
80
+ ['exfiltrate', 'a form outside the namespace'],
81
+ ])('rejects button action %p (%s)', (action, _why) => {
82
+ const result = (0, panels_1.validatePanelDefinition)({
83
+ ...panel,
84
+ elements: [{ kind: 'button', label: 'Go', action }],
85
+ });
86
+ expect(result.ok).toBe(false);
87
+ });
88
+ it('rejects an image key outside the presignable roots', () => {
89
+ // Not pedantry: the platform only presigns these roots, so any other key is a
90
+ // permanently broken image rather than an unusual one.
91
+ const result = (0, panels_1.validatePanelDefinition)({
92
+ ...panel,
93
+ elements: [{ kind: 'image', imageKey: 'https://cdn.example/x.png' }],
94
+ });
95
+ expect(result.ok).toBe(false);
96
+ expect(result.issues[0]).toContain('dfe-icons');
97
+ });
98
+ it.each(['score > 100', '!isRecord', 'a && b', 'is-record'])('rejects showIf %p — a value NAME, never an expression', (showIf) => {
99
+ const result = (0, panels_1.validatePanelDefinition)({
100
+ ...panel,
101
+ elements: [{ kind: 'conditionalText', text: 'x', showIf }],
102
+ });
103
+ expect(result.ok).toBe(false);
104
+ });
105
+ });
106
+ describe('validatePanelTheme', () => {
107
+ it('accepts a partial theme', () => {
108
+ expect((0, panels_1.validatePanelTheme)({ accent: '#D8B24A' })).toEqual({ ok: true, issues: [] });
109
+ });
110
+ it.each([
111
+ ['url(https://evil.example/p.png)', 'an outbound request from every panel you draw'],
112
+ ['var(--host-bg)', 'reaching into the host’s variables'],
113
+ ['#fff; position: fixed', 'escaping the declaration'],
114
+ ])('rejects colour %p (%s)', (bg, _why) => {
115
+ expect((0, panels_1.validatePanelTheme)({ bg }).ok).toBe(false);
116
+ });
117
+ it('requires {n} in amountFormat — otherwise every quantity silently vanishes', () => {
118
+ expect((0, panels_1.validatePanelTheme)({ amountFormat: '×' }).ok).toBe(false);
119
+ expect((0, panels_1.validatePanelTheme)({ amountFormat: '×{n}' }).ok).toBe(true);
120
+ });
121
+ it('names the offending field, since a theme is a flat bag of look-alike strings', () => {
122
+ const result = (0, panels_1.validatePanelTheme)({ radius: '100vw' });
123
+ expect(result.issues[0]).toContain('theme.radius');
124
+ expect(result.issues[0]).toContain('px, rem or em');
125
+ });
126
+ });
127
+ //# sourceMappingURL=panels.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"panels.test.js","sourceRoot":"","sources":["../src/panels.test.ts"],"names":[],"mappings":";;AAAA,qCAKkB;AAElB,MAAM,KAAK,GAAG;IACZ,EAAE,EAAE,gBAAgB;IACpB,KAAK,EAAE,WAAW;IAClB,QAAQ,EAAE;QACR,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE;QACxC,EAAE,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,UAAU,EAAE;QACxE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,IAAI,EAAE;QACtD,EAAE,IAAI,EAAE,cAAc,EAAE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AE,CAAC,8EAA8E,EAAE,GAAG,EAAE;QACtF,MAAM,MAAM,GAAG,IAAA,2BAAkB,EAAC,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;QACvD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QACnD,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/types.d.ts CHANGED
@@ -826,10 +826,183 @@ export interface ArcheAssetsApi {
826
826
  /** Refresh the signed URL for a single asset. */
827
827
  getUrl: (assetId: string) => Promise<ArcheAsset>;
828
828
  }
829
+ /** Where an asset sits in the moderation lifecycle, from the author's view. */
830
+ export type CommunityAssetStatus =
831
+ /** Awaiting a verdict. Nobody else can see it yet. */
832
+ 'pending_moderation'
833
+ /** Live — every user of this arche can see it. */
834
+ | 'published'
835
+ /** Moderation said no. Terminal; `moderationReason` says roughly why. */
836
+ | 'rejected'
837
+ /** Held for a human moderator. */
838
+ | 'needs_review'
839
+ /** The author removed it. */
840
+ | 'unpublished'
841
+ /** An admin removed it. */
842
+ | 'taken_down';
843
+ export interface CommunityAsset {
844
+ assetId: string;
845
+ archeId: string;
846
+ title: string | null;
847
+ caption: string | null;
848
+ tags: string[];
849
+ /** Opt-in display credit chosen by the publisher; null when anonymous. */
850
+ attributionName: string | null;
851
+ /** Always `image/png` — publishing normalizes to a canonical PNG. */
852
+ contentType: string;
853
+ sizeBytes: number;
854
+ /** ISO timestamp, or null while it is not published. */
855
+ publishedAt: string | null;
856
+ /** Present only on YOUR OWN assets (`listMine`, and `get` when you published it). */
857
+ status?: CommunityAssetStatus;
858
+ /** Coarse reason a rejected asset was refused. Own assets only. */
859
+ moderationReason?: string | null;
860
+ /** Whatever `clientRef` you passed at publish time. Own assets only. */
861
+ clientRef?: string | null;
862
+ createdAt?: string;
863
+ }
864
+ /** A short-lived signed URL for one published asset. Render with `<img src>`. */
865
+ export interface CommunityAssetUrl {
866
+ assetId: string;
867
+ url: string;
868
+ /**
869
+ * Epoch MILLISECONDS (the Vault convention — note `ArcheAsset.expiresAt`
870
+ * above is unix SECONDS). URLs last ~5 minutes; the hook refreshes them for
871
+ * you, so prefer calling `getUrls` again over caching this yourself.
872
+ */
873
+ expiresAt: number;
874
+ }
875
+ export interface CommunityAssetPublishInput {
876
+ /**
877
+ * The `fileId` from a `useImageGeneration()` result — the image must be one
878
+ * YOU created or uploaded, in your own Fias files.
879
+ *
880
+ * Required here, while `ImageGenerationResult.fileId` is OPTIONAL (it is
881
+ * absent if the generated image was never written to the user's files). That
882
+ * mismatch is deliberate: TypeScript makes you handle the missing case rather
883
+ * than forwarding `undefined` and discovering it as a runtime
884
+ * `FILE_NOT_FOUND`. Guard before publishing:
885
+ *
886
+ * ```ts
887
+ * const image = await generate({ prompt });
888
+ * if (!image.fileId) return; // nothing saved — nothing to publish
889
+ * await publish({ fileId: image.fileId });
890
+ * ```
891
+ */
892
+ fileId: string;
893
+ title?: string | null;
894
+ caption?: string | null;
895
+ /** Up to 16, each ≤64 chars. The only filterable dimension in `listCommunity`. */
896
+ tags?: string[];
897
+ /** Your own correlation handle (e.g. `"page-3"`), echoed back per item. */
898
+ clientRef?: string | null;
899
+ /** Opt-in display credit. Screened like every other author-supplied string. */
900
+ attributionName?: string | null;
901
+ }
902
+ /**
903
+ * One item's outcome from `publishMany`. Items succeed or fail INDEPENDENTLY —
904
+ * a single rejected page must not sink a whole book — and retrying only the
905
+ * failures is safe: publishing the same bytes twice returns the first result
906
+ * rather than creating a duplicate.
907
+ */
908
+ export type CommunityAssetPublishResult = {
909
+ clientRef: string | null;
910
+ asset: CommunityAsset;
911
+ error?: undefined;
912
+ } | {
913
+ clientRef: string | null;
914
+ asset?: undefined;
915
+ error: {
916
+ code: string;
917
+ message: string;
918
+ };
919
+ };
920
+ export interface CommunityAssetListOptions {
921
+ /** 1..100. Default 30. */
922
+ limit?: number;
923
+ /** `nextCursor` from the previous page. */
924
+ cursor?: string | null;
925
+ /** Return only assets carrying this tag. `listCommunity` only. */
926
+ tag?: string | null;
927
+ }
928
+ export interface CommunityAssetListResult {
929
+ assets: CommunityAsset[];
930
+ /** Null when there are no more pages. */
931
+ nextCursor: string | null;
932
+ }
933
+ export type CommunityAssetReportReason = 'sexual' | 'violence' | 'hate' | 'illegal' | 'copyright' | 'spam' | 'other';
934
+ export interface CommunityAssetsApi {
935
+ /**
936
+ * Publish one image you created so other users of this arche can see it.
937
+ * Free. It becomes visible only after moderation — expect
938
+ * `status: 'pending_moderation'` back, not `'published'`.
939
+ */
940
+ publish: (input: CommunityAssetPublishInput) => Promise<CommunityAsset>;
941
+ /** Publish up to 20 at once; each item succeeds or fails on its own. */
942
+ publishMany: (items: CommunityAssetPublishInput[]) => Promise<CommunityAssetPublishResult[]>;
943
+ /** Remove one of YOUR published assets. */
944
+ unpublish: (assetId: string) => Promise<CommunityAsset>;
945
+ /** Your own publications here, including moderation status. */
946
+ listMine: (options?: CommunityAssetListOptions) => Promise<CommunityAssetListResult>;
947
+ /** Browse what this arche's community has published. */
948
+ listCommunity: (options?: CommunityAssetListOptions) => Promise<CommunityAssetListResult>;
949
+ /** Metadata for one asset. */
950
+ get: (assetId: string) => Promise<CommunityAsset>;
951
+ /** A signed URL for one asset. Cached and auto-refreshed by the hook. */
952
+ getUrl: (assetId: string) => Promise<CommunityAssetUrl>;
953
+ /**
954
+ * Signed URLs for up to 50 assets in ONE call. Use this for a gallery or a
955
+ * multi-page book — 13 separate `getUrl` calls against a 5-minute TTL is the
956
+ * shape this exists to avoid. Ids that are gone or not yet published are
957
+ * simply omitted from the result rather than throwing.
958
+ */
959
+ getUrls: (assetIds: string[]) => Promise<CommunityAssetUrl[]>;
960
+ /** Report a published asset for moderator review. */
961
+ report: (assetId: string, reason: CommunityAssetReportReason, details?: string) => Promise<{
962
+ reportId: string;
963
+ status: string;
964
+ }>;
965
+ }
829
966
  /**
830
967
  * Message types sent from the plugin iframe to the parent frame.
831
968
  */
832
- export type PluginToHostMessageType = 'ready' | 'resize' | 'toast' | 'get_user' | 'get_theme' | 'storage_read' | 'storage_write' | 'storage_list' | 'storage_delete' | 'entity_invoke' | 'client_entity_invoke' | 'image_generate' | 'entities_list_image' | 'audio_generate' | 'surface_invoke' | 'navigate' | 'open_arche' | 'data_create_collection' | 'data_list_collections' | 'data_delete_collection' | 'data_put' | 'data_get' | 'data_query' | 'data_delete' | 'data_batch' | 'data_search' | 'workspace_create' | 'workspace_list' | 'workspace_get' | 'workspace_archive' | 'workspace_list_members' | 'workspace_add_member' | 'workspace_update_member' | 'workspace_remove_member' | '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_read_many' | 'vault_documents_download_url' | 'vault_documents_get_urls' | 'vault_documents_search' | 'vault_documents_write' | 'vault_documents_update' | 'vault_documents_delete' | 'vault_documents_attach' | 'vault_documents_detach' | 'vault_documents_upload_init' | 'vault_documents_upload_finalize' | 'vault_documents_upload' | 'vault_documents_pick' | 'arche_assets_list' | 'arche_assets_index' | 'arche_assets_get_url' | 'preview_state' | 'subscription_unsubscribe';
969
+ export type PluginToHostMessageType = 'ready' | 'resize' | 'toast' | 'get_user' | 'get_theme' | 'storage_read' | 'storage_write' | 'storage_list' | 'storage_delete' | 'entity_invoke' | 'client_entity_invoke' | 'image_generate' | 'entities_list_image' | 'audio_generate' | 'surface_invoke' | 'navigate' | 'open_arche' | 'data_create_collection' | 'data_list_collections' | 'data_delete_collection' | 'data_put' | 'data_get' | 'data_query' | 'data_delete' | 'data_batch' | 'data_search' | 'workspace_create' | 'workspace_list' | 'workspace_get' | 'workspace_archive' | 'workspace_list_members' | 'workspace_add_member' | 'workspace_update_member' | 'workspace_remove_member' | '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_read_many' | 'vault_documents_download_url' | 'vault_documents_get_urls' | 'vault_documents_search' | 'vault_documents_write' | 'vault_documents_update' | 'vault_documents_delete' | 'vault_documents_attach' | 'vault_documents_detach' | 'vault_documents_upload_init' | 'vault_documents_upload_finalize' | 'vault_documents_upload' | 'vault_documents_pick' | 'arche_assets_list' | 'arche_assets_index' | 'arche_assets_get_url' | 'preview_state' | 'subscription_unsubscribe' | 'ai_actions_declare' | 'ai_state' | 'ai_action_result';
970
+ /**
971
+ * One Fias AI action a plugin declares — what the platform assistant may do
972
+ * in this plugin's UI while it is open. Mirrors the platform's
973
+ * `PluginManifestAiAction` (@fias/db-types): the manifest `fiasAI` block
974
+ * declares actions statically (fixed at publish, reviewable); this same shape
975
+ * declares them at runtime via `useFiasAIActions` (TRUSTED arches only).
976
+ */
977
+ export interface FiasAIActionDescriptor {
978
+ /** Lowercase snake_case, ≤100 chars — becomes the assistant's `ui__<id>` tool name. */
979
+ id: string;
980
+ /** Written FOR the model: when to use it, what it does. ≤1000 chars. */
981
+ description: string;
982
+ /** JSON Schema for the action's params ({"type":"object","properties":{}} for none). */
983
+ parameterSchema: Record<string, unknown>;
984
+ /** Escalate to an explicit in-app approval before the action runs. Escalate-only — there is no way to skip a confirmation the platform requires. */
985
+ requiresConfirmation?: boolean;
986
+ category?: string;
987
+ /**
988
+ * Host-side visibility precondition: the action is offered to the assistant
989
+ * only while every named key of the last `state` snapshot equals the given
990
+ * value (e.g. `{ documentOpen: true }`). Equality over booleans/strings
991
+ * only. Filtering is presentation, not enforcement — the `onAction` handler
992
+ * must still re-check its own preconditions and throw when unmet.
993
+ */
994
+ availableWhen?: Record<string, boolean | string>;
995
+ }
996
+ /** A runtime Fias AI declaration (`useFiasAIActions`). */
997
+ export interface FiasAIActionsDeclaration {
998
+ /**
999
+ * Capability summary the assistant always sees while the plugin is open —
1000
+ * cover availableWhen-hidden actions too ("once a document is open, …") so
1001
+ * a filtered-out verb reads as a precondition, not a missing capability.
1002
+ */
1003
+ description: string;
1004
+ actions: FiasAIActionDescriptor[];
1005
+ }
833
1006
  /**
834
1007
  * Why a realtime subscription ended (ADR-012 Phase M4). Closed union so
835
1008
  * hooks can distinguish terminal endings (`authorization_revoked`,
@@ -870,7 +1043,7 @@ export interface StepNavigationOptions {
870
1043
  /**
871
1044
  * Message types sent from the parent frame to the plugin iframe.
872
1045
  */
873
- export type HostToPluginMessageType = 'init' | 'response' | 'theme_update' | 'navigate_update' | 'step_navigate' | 'stream_token' | 'preview_state_capture' | 'preview_state_restore' | 'subscription_event' | 'subscription_ended';
1046
+ export type HostToPluginMessageType = 'init' | 'response' | 'theme_update' | 'navigate_update' | 'step_navigate' | 'stream_token' | 'preview_state_capture' | 'preview_state_restore' | 'subscription_event' | 'subscription_ended' | 'ai_action_dispatch';
874
1047
  /**
875
1048
  * Base message structure for all bridge communication.
876
1049
  */
@@ -986,6 +1159,11 @@ export interface DataStoreCollection {
986
1159
  readMinRole?: WorkspaceRole | null;
987
1160
  /** Who may write (shared-scoped only): see {@link DataStoreWritePolicy}. */
988
1161
  writePolicy?: DataStoreWritePolicy;
1162
+ /**
1163
+ * Server-enforced constraints (ADR-014); null/absent = none. Returned so a
1164
+ * plugin can VERIFY its declared constraints took effect.
1165
+ */
1166
+ constraints?: DataStoreCollectionConstraints | null;
989
1167
  createdAt: string;
990
1168
  }
991
1169
  /**
@@ -1006,6 +1184,109 @@ export interface DataStoreCollection {
1006
1184
  * loosening is refused.
1007
1185
  */
1008
1186
  export type DataStoreWritePolicy = 'any' | 'author' | 'collaborators';
1187
+ /** Numeric comparison operator used by constraints and preconditions. */
1188
+ export type DataStoreBoundOp = 'eq' | 'ne' | 'lt' | 'lte' | 'gt' | 'gte';
1189
+ /**
1190
+ * One declared numeric bound on a written document: `field <op> bound`, where
1191
+ * the bound is a constant (`value`) or a sibling numeric field on the SAME
1192
+ * document (`valueField`) — exactly one of the two. Skipped when `field` is
1193
+ * absent; fails closed when the bound cannot be evaluated.
1194
+ */
1195
+ export interface DataStoreFieldBound {
1196
+ /** Dot-notation path into the document data. */
1197
+ field: string;
1198
+ op: DataStoreBoundOp;
1199
+ /** Constant bound. Exactly one of `value` / `valueField`. */
1200
+ value?: number;
1201
+ /** Sibling field on the same document to compare against. */
1202
+ valueField?: string;
1203
+ }
1204
+ /**
1205
+ * Server-enforced per-collection constraints, declared at collection creation
1206
+ * (or in the manifest `collections` block) and checked by the platform on
1207
+ * EVERY write — a client cannot bypass them. Tighten-only after creation:
1208
+ * entries can be added (by a collaborator), never removed or changed.
1209
+ *
1210
+ * - `appendOnly` — the collection is a ledger: no overwrites, no deletes.
1211
+ * - `nonNegative` — named numeric fields must be ≥ 0 when present.
1212
+ * - `fieldBounds` — numeric bounds, e.g. `issued lte authorized`.
1213
+ * - `immutableFields` — set-once fields an overwrite must carry unchanged.
1214
+ *
1215
+ * Violations reject the write with code `CONSTRAINT_VIOLATION`.
1216
+ */
1217
+ export interface DataStoreCollectionConstraints {
1218
+ appendOnly?: true;
1219
+ nonNegative?: string[];
1220
+ fieldBounds?: DataStoreFieldBound[];
1221
+ immutableFields?: string[];
1222
+ }
1223
+ /**
1224
+ * One precondition on an atomic {@link FiasDataStoreApi.batch}: evaluated by
1225
+ * the server against current committed state, inside the batch transaction,
1226
+ * BEFORE any operation applies. Any failure rejects the entire batch —
1227
+ * `version` failures with code `VERSION_CONFLICT`, the rest with
1228
+ * `PRECONDITION_FAILED`. May reference documents the batch does not write.
1229
+ *
1230
+ * - `version` — compare-and-swap: the document must exist at exactly this
1231
+ * version (see {@link DataStoreDocument.version}). THE tool for
1232
+ * read-compute-write flows: assert the versions of every document the
1233
+ * client math depended on, and a concurrent writer can no longer race you.
1234
+ * - `absent` — create-once / uniqueness.
1235
+ * - `exists` — referential integrity.
1236
+ * - `field_bound` — numeric guard on current state, e.g. `status eq 0`.
1237
+ */
1238
+ export type DataStoreBatchPrecondition = {
1239
+ kind: 'version';
1240
+ collection: string;
1241
+ key: string;
1242
+ workspaceId?: string;
1243
+ version: number;
1244
+ } | {
1245
+ kind: 'absent';
1246
+ collection: string;
1247
+ key: string;
1248
+ workspaceId?: string;
1249
+ } | {
1250
+ kind: 'exists';
1251
+ collection: string;
1252
+ key: string;
1253
+ workspaceId?: string;
1254
+ } | {
1255
+ kind: 'field_bound';
1256
+ collection: string;
1257
+ key: string;
1258
+ workspaceId?: string;
1259
+ field: string;
1260
+ op: DataStoreBoundOp;
1261
+ value: number;
1262
+ };
1263
+ /** Options for {@link FiasDataStoreApi.batch}. */
1264
+ export interface DataStoreBatchOptions {
1265
+ /** ADR-014 preconditions, all-or-nothing with the batch (max 10). */
1266
+ preconditions?: DataStoreBatchPrecondition[];
1267
+ }
1268
+ /**
1269
+ * Result of {@link FiasDataStoreApi.batch}. `written` aligns 1:1 with the
1270
+ * batch's `put` operations in operation order, carrying each document's
1271
+ * post-write {@link DataStoreDocument.version} — assert these in the next
1272
+ * batch's `version` preconditions to chain race-free writes without a
1273
+ * read-back. Absent on platforms without conditional-write support.
1274
+ */
1275
+ export interface DataStoreBatchResult {
1276
+ written?: {
1277
+ key: string;
1278
+ version?: number;
1279
+ }[];
1280
+ }
1281
+ /**
1282
+ * Result of {@link FiasDataStoreApi.put}, carrying the document's post-write
1283
+ * {@link DataStoreDocument.version} — assert it in the next batch's `version`
1284
+ * precondition to chain race-free writes without a read-back. Absent on
1285
+ * platforms without conditional-write support.
1286
+ */
1287
+ export interface DataStorePutResult {
1288
+ version?: number;
1289
+ }
1009
1290
  /**
1010
1291
  * A document returned from the data store.
1011
1292
  */
@@ -1013,6 +1294,14 @@ export interface DataStoreDocument<T = Record<string, unknown>> {
1013
1294
  key: string;
1014
1295
  data: T;
1015
1296
  updatedAt: string;
1297
+ /**
1298
+ * Server-owned optimistic-concurrency counter (ADR-014): 1 on create,
1299
+ * incremented on every successful put, never client-writable. Assert it in
1300
+ * a batch `version` precondition to make read-compute-write race-free.
1301
+ * Requires a platform version with conditional-write support; absent
1302
+ * otherwise.
1303
+ */
1304
+ version?: number;
1016
1305
  /**
1017
1306
  * Present on SHARED-scope documents only: whether the document's last writer
1018
1307
  * is an active arche collaborator (owner/publisher). The trust signal for
@@ -1077,6 +1366,13 @@ export interface DataStoreSearchMatch<T = Record<string, unknown>> {
1077
1366
  data: T;
1078
1367
  /** Cosine similarity in [0, 1]; higher is closer. */
1079
1368
  similarity: number;
1369
+ /**
1370
+ * Post-write CAS counter (ADR-014) — see {@link DataStoreDocument.version}.
1371
+ * Carried on matches so a document located by search can be asserted in a
1372
+ * follow-up `version` precondition without a second read. Absent on
1373
+ * platforms without conditional-write support.
1374
+ */
1375
+ version?: number;
1080
1376
  /** Present on shared-scope matches: see {@link DataStoreDocument.authoredByCollaborator}. */
1081
1377
  authoredByCollaborator?: boolean;
1082
1378
  }
@@ -1108,6 +1404,8 @@ export interface FiasDataStoreApi {
1108
1404
  readMinRole?: WorkspaceRole;
1109
1405
  /** Shared-scoped only: who may write. See {@link DataStoreWritePolicy}. */
1110
1406
  writePolicy?: DataStoreWritePolicy;
1407
+ /** Server-enforced constraints (ADR-014). Tighten-only after creation. */
1408
+ constraints?: DataStoreCollectionConstraints;
1111
1409
  }) => Promise<DataStoreCollection>;
1112
1410
  /** List all collections for this arche. */
1113
1411
  listCollections: () => Promise<DataStoreCollection[]>;
@@ -1117,8 +1415,11 @@ export interface FiasDataStoreApi {
1117
1415
  * Write (upsert) a document by key. For a `workspace`-scoped collection pass
1118
1416
  * `{ workspaceId }`; the caller must be an active member with write access
1119
1417
  * (owner/admin/member). See {@link FiasWorkspacesApi}.
1418
+ *
1419
+ * Resolves with the document's post-write `version` (ADR-014) so a follow-up
1420
+ * conditional batch can assert it without a read-back.
1120
1421
  */
1121
- put: <T extends Record<string, unknown> = Record<string, unknown>>(collection: string, key: string, data: T, options?: DataStoreScopeOptions) => Promise<void>;
1422
+ put: <T extends Record<string, unknown> = Record<string, unknown>>(collection: string, key: string, data: T, options?: DataStoreScopeOptions) => Promise<DataStorePutResult>;
1122
1423
  /** Get a document by key. Returns null if not found. Pass `{ workspaceId }`
1123
1424
  * for a workspace-scoped collection. */
1124
1425
  get: <T extends Record<string, unknown> = Record<string, unknown>>(collection: string, key: string, options?: DataStoreScopeOptions) => Promise<T | null>;
@@ -1150,8 +1451,14 @@ export interface FiasDataStoreApi {
1150
1451
  * updating a running total together) where a sequence of separate calls could
1151
1452
  * leave a half-applied state. A batch may span collections and scopes; any
1152
1453
  * failure (bad key, role denial, quota) rolls the whole batch back.
1454
+ *
1455
+ * Pass `options.preconditions` (ADR-014) to make the batch CONDITIONAL:
1456
+ * every precondition is evaluated server-side against committed state before
1457
+ * any op applies — assert the `version` of each document your computation
1458
+ * read, and a concurrent writer can no longer race you. The result carries
1459
+ * each put's post-write version (see {@link DataStoreBatchResult}).
1153
1460
  */
1154
- batch: (operations: DataStoreBatchOp[]) => Promise<void>;
1461
+ batch: (operations: DataStoreBatchOp[], options?: DataStoreBatchOptions) => Promise<DataStoreBatchResult>;
1155
1462
  }
1156
1463
  /** Per-call scope options for workspace-scoped Data Store documents. */
1157
1464
  export interface DataStoreScopeOptions {