@ai-matrx/alchemy 0.6.2 → 0.8.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.
Files changed (113) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/actions.cjs +374 -0
  3. package/dist/actions.cjs.map +1 -0
  4. package/dist/actions.d.cts +773 -0
  5. package/dist/actions.d.ts +773 -0
  6. package/dist/actions.js +351 -0
  7. package/dist/actions.js.map +1 -0
  8. package/dist/checks.cjs +31 -2
  9. package/dist/checks.cjs.map +1 -1
  10. package/dist/checks.d.cts +24 -1
  11. package/dist/checks.d.ts +24 -1
  12. package/dist/checks.js +31 -2
  13. package/dist/checks.js.map +1 -1
  14. package/dist/core.cjs +1757 -2
  15. package/dist/core.cjs.map +1 -1
  16. package/dist/core.d.cts +595 -1
  17. package/dist/core.d.ts +595 -1
  18. package/dist/core.js +1749 -2
  19. package/dist/core.js.map +1 -1
  20. package/dist/declare.cjs +12 -10
  21. package/dist/declare.cjs.map +1 -1
  22. package/dist/declare.d.cts +18 -2
  23. package/dist/declare.d.ts +18 -2
  24. package/dist/declare.js +12 -10
  25. package/dist/declare.js.map +1 -1
  26. package/dist/index.cjs +1757 -2
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +595 -1
  29. package/dist/index.d.ts +595 -1
  30. package/dist/index.js +1749 -2
  31. package/dist/index.js.map +1 -1
  32. package/dist/menu.cjs +436 -0
  33. package/dist/menu.cjs.map +1 -0
  34. package/dist/menu.d.cts +834 -0
  35. package/dist/menu.d.ts +834 -0
  36. package/dist/menu.js +413 -0
  37. package/dist/menu.js.map +1 -0
  38. package/dist/operate-document.cjs +163 -0
  39. package/dist/operate-document.cjs.map +1 -0
  40. package/dist/operate-document.d.cts +132 -0
  41. package/dist/operate-document.d.ts +132 -0
  42. package/dist/operate-document.js +130 -0
  43. package/dist/operate-document.js.map +1 -0
  44. package/dist/operate-rich-html.cjs +129 -0
  45. package/dist/operate-rich-html.cjs.map +1 -0
  46. package/dist/operate-rich-html.d.cts +136 -0
  47. package/dist/operate-rich-html.d.ts +136 -0
  48. package/dist/operate-rich-html.js +96 -0
  49. package/dist/operate-rich-html.js.map +1 -0
  50. package/dist/operate-server.cjs +157 -0
  51. package/dist/operate-server.cjs.map +1 -0
  52. package/dist/operate-server.d.cts +183 -0
  53. package/dist/operate-server.d.ts +183 -0
  54. package/dist/operate-server.js +134 -0
  55. package/dist/operate-server.js.map +1 -0
  56. package/dist/operate-xlsx.cjs +248 -0
  57. package/dist/operate-xlsx.cjs.map +1 -0
  58. package/dist/operate-xlsx.d.cts +129 -0
  59. package/dist/operate-xlsx.d.ts +129 -0
  60. package/dist/operate-xlsx.js +215 -0
  61. package/dist/operate-xlsx.js.map +1 -0
  62. package/dist/operate.cjs +1774 -0
  63. package/dist/operate.cjs.map +1 -0
  64. package/dist/operate.d.cts +595 -0
  65. package/dist/operate.d.ts +595 -0
  66. package/dist/operate.js +1750 -0
  67. package/dist/operate.js.map +1 -0
  68. package/dist/ports.cjs.map +1 -1
  69. package/dist/ports.d.cts +361 -3
  70. package/dist/ports.d.ts +361 -3
  71. package/dist/react-bar.cjs +686 -0
  72. package/dist/react-bar.cjs.map +1 -0
  73. package/dist/react-bar.d.cts +379 -0
  74. package/dist/react-bar.d.ts +379 -0
  75. package/dist/react-bar.js +665 -0
  76. package/dist/react-bar.js.map +1 -0
  77. package/dist/react-host.cjs +301 -0
  78. package/dist/react-host.cjs.map +1 -0
  79. package/dist/react-host.d.cts +820 -0
  80. package/dist/react-host.d.ts +820 -0
  81. package/dist/react-host.js +269 -0
  82. package/dist/react-host.js.map +1 -0
  83. package/dist/react-menu.cjs +735 -0
  84. package/dist/react-menu.cjs.map +1 -0
  85. package/dist/react-menu.d.cts +370 -0
  86. package/dist/react-menu.d.ts +370 -0
  87. package/dist/react-menu.js +722 -0
  88. package/dist/react-menu.js.map +1 -0
  89. package/dist/react-overflow.cjs +592 -0
  90. package/dist/react-overflow.cjs.map +1 -0
  91. package/dist/react-overflow.d.cts +817 -0
  92. package/dist/react-overflow.d.ts +817 -0
  93. package/dist/react-overflow.js +571 -0
  94. package/dist/react-overflow.js.map +1 -0
  95. package/dist/react-palette.cjs +489 -0
  96. package/dist/react-palette.cjs.map +1 -0
  97. package/dist/react-palette.d.cts +359 -0
  98. package/dist/react-palette.d.ts +359 -0
  99. package/dist/react-palette.js +457 -0
  100. package/dist/react-palette.js.map +1 -0
  101. package/dist/react-selection.cjs +617 -0
  102. package/dist/react-selection.cjs.map +1 -0
  103. package/dist/react-selection.d.cts +357 -0
  104. package/dist/react-selection.d.ts +357 -0
  105. package/dist/react-selection.js +596 -0
  106. package/dist/react-selection.js.map +1 -0
  107. package/dist/react-sheet.cjs +616 -0
  108. package/dist/react-sheet.cjs.map +1 -0
  109. package/dist/react-sheet.d.cts +361 -0
  110. package/dist/react-sheet.d.ts +361 -0
  111. package/dist/react-sheet.js +595 -0
  112. package/dist/react-sheet.js.map +1 -0
  113. package/package.json +148 -5
package/dist/ports.d.cts CHANGED
@@ -1,3 +1,209 @@
1
+ /** Unchanged from `ui_surface_value_type_chk`. */
2
+ type ValueType = "string" | "number" | "boolean" | "object" | "array" | "document";
3
+ type Classification = "ordinary" | "secret" | "credential";
4
+ /** Persisted (CONTRACT §2.7). Projection enforces it before any value leaves. */
5
+ interface Sensitivity {
6
+ /** false = never leaves through Operate. Default true. */
7
+ exportable: boolean;
8
+ /** secret/credential are always excluded; no caller can relax this. Default "ordinary". */
9
+ classification: Classification;
10
+ /** Pre-checked in the preparation workspace. Default true. */
11
+ includedByDefault: boolean;
12
+ }
13
+ interface ValueGroup {
14
+ key: string;
15
+ label: string;
16
+ sortOrder: number;
17
+ description?: string;
18
+ }
19
+ /** The four runtime slots a capture fills (absorbs page-capture). */
20
+ type LiveSlot = "selection" | "on-demand" | "errors" | "requests";
21
+ interface DeclaredValue {
22
+ name: string;
23
+ label: string;
24
+ description: string;
25
+ valueType: ValueType;
26
+ /** Registered content-ir kind key (DB: kind_key). */
27
+ valueKind?: string;
28
+ alwaysAvailable: boolean;
29
+ typicalCharCount: number;
30
+ autoContext?: boolean;
31
+ group?: string;
32
+ sortOrder?: number;
33
+ sensitivity?: Partial<Sensitivity>;
34
+ /** Filled at capture time from a live slot instead of the scope. */
35
+ liveSlot?: LiveSlot;
36
+ /** "request" values drop out of "Only the data". Default "data". */
37
+ role?: "data" | "request";
38
+ }
39
+ /** Where a write lands. "stream" = applied live, op by op, into an editable text. */
40
+ type WriteMode = "draft" | "entity" | "ui" | "stream";
41
+ /** Who may apply WITHOUT a click. "queued" = filed for an organization's review. */
42
+ type ApplyPolicy = "manual" | "ask" | "auto" | "queued";
43
+ /** The WidgetHandle text op set, unchanged in meaning. */
44
+ type StreamOp = "replace" | "insert_before" | "insert_after" | "prepend" | "append" | "patch";
45
+ interface WriteTarget {
46
+ name: string;
47
+ label: string;
48
+ description: string;
49
+ valueType: ValueType;
50
+ valueKind?: string;
51
+ /** Read twin (evidence loop). Required when patchable or mode === "stream". */
52
+ updatesValue?: string;
53
+ patchable?: boolean;
54
+ approvalComparison?: "text-replacement";
55
+ mode: WriteMode;
56
+ /** Required iff mode === "stream". */
57
+ streamOps?: readonly StreamOp[];
58
+ /** Default "manual". Binding overrides may only tighten. */
59
+ applyPolicy?: ApplyPolicy;
60
+ destination?: boolean;
61
+ /** Present when the target writes into an item rather than the screen. */
62
+ itemType?: string;
63
+ group?: string;
64
+ sortOrder?: number;
65
+ }
66
+ /** One kind of thing inside a screen (a row, a message, a code block, a card). */
67
+ interface ItemType {
68
+ name: string;
69
+ label: string;
70
+ description: string;
71
+ /** Value names that together identify one item. */
72
+ identity: readonly string[];
73
+ levels?: readonly string[];
74
+ entityType?: string;
75
+ values: readonly DeclaredValue[];
76
+ writeTargets?: readonly WriteTarget[];
77
+ }
78
+ type Readiness = "verified" | "partial" | "stub";
79
+ /** `ui_surface_execution_mode_check`, unchanged. */
80
+ type ExecutionMode = "python-stream" | "nextjs-stream" | "browser-realtime" | "local-runtime";
81
+ interface ConfigNamespaceDeclaration {
82
+ namespace: string;
83
+ label: string;
84
+ description: string;
85
+ }
86
+ interface EvidenceSourceDeclaration {
87
+ kind: "processed_document";
88
+ idValue: string;
89
+ fileIdValue?: string;
90
+ labelValue?: string;
91
+ representation?: "clean" | "raw";
92
+ }
93
+ /**
94
+ * One screen's declaration. Owning packages add fields (agent roles, client
95
+ * tools) as EXTENSION SLOTS — by interface extension or declaration merging —
96
+ * and register a `DeclarationExtension` so validation and the sync cover them.
97
+ */
98
+ interface SurfaceDeclaration {
99
+ surfaceName: string;
100
+ /** REQUIRED. `ui_surface.client_name`; must equal the surfaceName prefix. */
101
+ client: string;
102
+ /** REQUIRED. `ui_surface.execution_mode`. */
103
+ executionMode: ExecutionMode;
104
+ /** REQUIRED. `ui_surface.description` ("" only where the live row is empty). */
105
+ description: string;
106
+ label: string;
107
+ readiness: Readiness;
108
+ readinessNote?: string;
109
+ urlPattern?: string;
110
+ inheritsFrom?: string;
111
+ intro?: string;
112
+ overlayId?: string;
113
+ values: readonly DeclaredValue[];
114
+ groups?: readonly ValueGroup[];
115
+ writeTargets?: readonly WriteTarget[];
116
+ itemTypes?: readonly ItemType[];
117
+ liveSlots?: readonly LiveSlot[];
118
+ configNamespaces?: readonly ConfigNamespaceDeclaration[];
119
+ evidenceSources?: readonly EvidenceSourceDeclaration[];
120
+ skipBaselineValues?: boolean;
121
+ }
122
+ type ValueProvenance = {
123
+ kind: "own";
124
+ } | {
125
+ kind: "inherited";
126
+ from: string;
127
+ } | {
128
+ kind: "baseline";
129
+ };
130
+ type ResolvedValue = DeclaredValue & {
131
+ provenance: ValueProvenance;
132
+ groupKey: string;
133
+ /** Defaults filled. */
134
+ resolvedSensitivity: Sensitivity;
135
+ };
136
+ interface ResolvedSurfaceDeclaration extends SurfaceDeclaration {
137
+ contentHash: string;
138
+ values: readonly ResolvedValue[];
139
+ groups: readonly ValueGroup[];
140
+ }
141
+ /**
142
+ * ITEM KEYS. A value or write target is identified by (surfaceName, itemType ?? "", name).
143
+ * The qualified key "<itemType>.<name>" names an item value; a bare name is a screen value.
144
+ */
145
+ type QualifiedValueKey = string;
146
+ /** RAW-FREE. What leaves the package about a clicked item. */
147
+ interface ResolvedItem {
148
+ itemType: string;
149
+ identity: Record<string, string>;
150
+ level?: string;
151
+ readOnly: boolean;
152
+ }
153
+
154
+ /**
155
+ * The click target (CONTRACT §2.4) in its own module: `/ports` references it,
156
+ * and `/ports` must stay free of every other package (types only).
157
+ */
158
+
159
+ /** The transfer Payload's kinds (`actions/types.ts` asserts equality at compile time). */
160
+ type PayloadKind = "text" | "markdown" | "json" | "rows" | "registered";
161
+ /** What eligibility is computed from: everything declared at the click target. */
162
+ interface ClickTarget {
163
+ surface: {
164
+ instanceId: string;
165
+ surfaceName: string;
166
+ } | null;
167
+ /** The resolved declaration (inheritance applied). Eligibility decides by KEY existence over it. */
168
+ declaration: ResolvedSurfaceDeclaration | null;
169
+ /** Declared value keys with a read path here (screen names + qualified item keys). Key existence, not population. */
170
+ valueKeys: ReadonlySet<QualifiedValueKey>;
171
+ /** Scope chain, most general first: ["global", "<domain>", "<surfaceName>"]. */
172
+ scopeChain: readonly string[];
173
+ /** The surface's explicit exclusions (the one override). */
174
+ excludedActionIds: ReadonlySet<string>;
175
+ item: ResolvedItem | null;
176
+ level: string | null;
177
+ /** Offsets + the live range handle, editable or not. */
178
+ selection: {
179
+ text: string;
180
+ type: "editable" | "non-editable";
181
+ start: number;
182
+ end: number;
183
+ /** Opaque host handle (DOM Range / element) used to restore or stream into the selection. */
184
+ handle?: unknown;
185
+ } | null;
186
+ /** Payload kinds a capture of this target would produce (from declared value types/kinds). */
187
+ payloadKinds: readonly PayloadKind[];
188
+ /** Declared targets writable on this target right now. */
189
+ writable: readonly WriteTarget[];
190
+ readOnly: boolean;
191
+ /** True when any declared value here is secret/credential or non-exportable. */
192
+ restricted: boolean;
193
+ organizationId: string | null;
194
+ auth: {
195
+ authenticated: boolean;
196
+ admin: boolean;
197
+ creator: boolean;
198
+ };
199
+ /**
200
+ * Host-owned context a provider reads to act (the rich-document source, the
201
+ * editable field's callbacks). Opaque to the package; never crosses into the
202
+ * model. Providers that need it narrow it themselves.
203
+ */
204
+ host?: unknown;
205
+ }
206
+
1
207
  /**
2
208
  * `@ai-matrx/alchemy/ports` — the host ports (Matrx Alchemy CONTRACT §2.2).
3
209
  *
@@ -10,9 +216,11 @@
10
216
  *
11
217
  * ALC-13 `kinds` (content-ir's validator, injected), `diagnostics` (required)
12
218
  * ALC-14 `identity`, `persistence`
219
+ * ALC-15 `store`, `notify`, `overlay`, `icons`, `knobs`, `i18n`, `auth`, `dialogs`
13
220
  *
14
- * Later waves add store/notify/overlay/icons/knobs/i18n/auth/dialogs (ALC-15),
15
- * transport/assets/server (ALC-16) and approvals/bodies/receipts (ALC-17).
221
+ * ALC-16 `transport`, `assets`, `server`
222
+ *
223
+ * ALC-17 adds approvals/bodies/receipts.
16
224
  *
17
225
  * ── Absent-port semantics ───────────────────────────────────────────────────
18
226
  *
@@ -27,6 +235,16 @@
27
235
  * identity absent → organization-scoped declarations are absent
28
236
  * persistence absent → per-person settings are absent (organization and
29
237
  * platform defaults apply)
238
+ * store absent → actions that read named host state or run named
239
+ * host commands are absent
240
+ * notify absent → outcomes are not announced (diagnostics still captures)
241
+ * overlay absent → actions that open an overlay or navigate are absent
242
+ * icons absent → rows render label-only (a key is never shown as text)
243
+ * knobs absent → the platform default layout/density applies
244
+ * i18n absent → labels as written
245
+ * auth absent → a signed-out person does not see requiresAuth actions
246
+ * (sign-in-then-resume is the capability that is missing)
247
+ * dialogs absent → actions that need a host dialog are absent
30
248
  *
31
249
  * Types only: this entry has no runtime code.
32
250
  */
@@ -55,6 +273,7 @@ interface KindValidatorPort {
55
273
  unverifiable?: true;
56
274
  }>;
57
275
  }
276
+
58
277
  /** Where contract breaks are captured. Required: nothing fails silently. */
59
278
  interface DiagnosticsPort {
60
279
  capture(error: unknown, context: {
@@ -79,6 +298,72 @@ interface PersistencePort {
79
298
  readSetting<T extends Json>(key: string): Promise<T | null>;
80
299
  writeSetting(key: string, value: Json): Promise<void>;
81
300
  }
301
+ /** Neutral state access: named reads and named commands. No Redux type or dispatch crosses this line. */
302
+ interface StorePort {
303
+ /** A named, typed read the host registered ("activeConversationId", "organizationName"). */
304
+ read<T extends Json>(key: string): T | null;
305
+ /** A named command the host registered ("tasks.setPendingSource"); resolves with its result. */
306
+ command(name: string, input: Json): Promise<Json | void>;
307
+ subscribe(key: string, listener: () => void): () => void;
308
+ }
309
+ interface NotifyPort {
310
+ success(sentence: string): void;
311
+ info(sentence: string): void;
312
+ /** Every failure names its remedy. */
313
+ error(sentence: string, remedy: string): void;
314
+ }
315
+ /** Overlays are dispatched through the host; the menu never renders a modal. */
316
+ interface OverlayHostPort {
317
+ open(overlayId: string, data: Json, instanceId?: string): void;
318
+ close(overlayId: string, instanceId?: string): void;
319
+ navigate(href: string): void;
320
+ }
321
+ /** Icon key → the host's icon component. The model only ever holds keys. */
322
+ interface IconResolverPort {
323
+ resolve(key: string): unknown | null;
324
+ }
325
+ type ContextArrangementKnob = "classic" | "tiered" | "command";
326
+ type DensityKnob = "comfortable" | "compact";
327
+ /** ORGANIZATION defaults only; every method takes the organization. */
328
+ interface MenuKnobsPort {
329
+ /** Replaces the constant PLACEMENT_LABEL_OVERRIDE. */
330
+ placementLabel(placement: string, organizationId: string | null): string | null;
331
+ /** Replaces the constant DEFAULT_PLACEMENT_MODE. */
332
+ placementMode(placement: string, organizationId: string | null): "show" | "hide";
333
+ /** The organization's default layout and density (platform default when null: command / comfortable). */
334
+ layout(organizationId: string | null): {
335
+ context: ContextArrangementKnob;
336
+ density: DensityKnob;
337
+ } | null;
338
+ }
339
+ /** Label translation. Absent = labels as written. */
340
+ interface I18nPort {
341
+ t(key: string, fallback: string): string;
342
+ }
343
+ /** Sign in, then resume the action the person picked. */
344
+ interface AuthResumePort {
345
+ isSignedIn(): boolean;
346
+ /** Stash {actionId, target fingerprint} and open sign-in; after sign-in the next matching menu host resumes it. */
347
+ signInThenResume(pending: {
348
+ actionId: string;
349
+ contentFingerprint: string;
350
+ }): void;
351
+ takePending(contentFingerprint: string): {
352
+ actionId: string;
353
+ } | null;
354
+ }
355
+ /** Per-instance host dialogs (today's RichDocumentActionContextCallbacks). */
356
+ interface HostDialogsPort {
357
+ requestDelete?(target: ClickTarget): void;
358
+ requestConvert?(target: ClickTarget): void;
359
+ requestEditHistory?(target: ClickTarget): void;
360
+ requestFullPrint?(target: ClickTarget): void;
361
+ requestSaveTable?(table: {
362
+ headers: string[];
363
+ rows: string[][];
364
+ }): void;
365
+ requestFlashcard?(answer: string): void;
366
+ }
82
367
  /** The ports a host binds. Optional = absent capability when unbound (see above). */
83
368
  interface AlchemyHostPorts {
84
369
  kinds?: KindValidatorPort;
@@ -86,6 +371,79 @@ interface AlchemyHostPorts {
86
371
  diagnostics: DiagnosticsPort;
87
372
  identity?: IdentityPort;
88
373
  persistence?: PersistencePort;
374
+ store?: StorePort;
375
+ notify?: NotifyPort;
376
+ overlay?: OverlayHostPort;
377
+ icons?: IconResolverPort;
378
+ /** Organization defaults for menu knobs; a person's own choice is layered over them via persistence (N9). */
379
+ knobs?: MenuKnobsPort;
380
+ i18n?: I18nPort;
381
+ auth?: AuthResumePort;
382
+ dialogs?: HostDialogsPort;
383
+ /** Clipboard and download for this runtime (the browser default ships in /operate). */
384
+ transport?: TransportPort;
385
+ /** Private or signed images → share-safe URLs before HTML is sealed. Absent = images keep their URL. */
386
+ assets?: AssetResolverPort;
387
+ /** Present when the host can reach aidream server operations; absent = server formats are not offered. */
388
+ server?: ServerPort;
389
+ }
390
+ /** A transferable artifact as the transport sees it (structurally `@ai-matrx/alchemy/operate`'s Artifact). */
391
+ interface TransportArtifact {
392
+ format: string;
393
+ plainText: string;
394
+ html?: string;
395
+ file?: {
396
+ filename: string;
397
+ mime: string;
398
+ bytes: Uint8Array;
399
+ };
400
+ }
401
+ type TransportOutcome = {
402
+ status: "success";
403
+ delivered: "clipboard" | "download-started";
404
+ mimeTypes: string[];
405
+ } | {
406
+ status: "degraded";
407
+ delivered: "plain-text";
408
+ reason: string;
409
+ } | {
410
+ status: "cancelled";
411
+ } | {
412
+ status: "error";
413
+ code: string;
414
+ message: string;
415
+ retryable: boolean;
416
+ };
417
+ /** Clipboard and download for a non-browser runtime (MV3 service worker, Tauri — CONTRACT R8). */
418
+ interface TransportPort {
419
+ copy(artifact: TransportArtifact, signal: AbortSignal): Promise<TransportOutcome>;
420
+ download(artifact: TransportArtifact, signal: AbortSignal): Promise<TransportOutcome>;
421
+ }
422
+ interface AssetResolverPort {
423
+ resolve(url: string, signal: AbortSignal): Promise<{
424
+ url: string;
425
+ } | null>;
426
+ }
427
+ type ServerResult = {
428
+ status: "bytes";
429
+ filename: string;
430
+ mime: string;
431
+ bytes: Uint8Array;
432
+ notices: readonly {
433
+ code: string;
434
+ sentence: string;
435
+ remedy: string;
436
+ }[];
437
+ } | {
438
+ status: "receipt";
439
+ receipt: {
440
+ status: string;
441
+ sentence: string;
442
+ remedy?: string;
443
+ };
444
+ };
445
+ interface ServerPort {
446
+ call(operationId: string, input: Json, signal: AbortSignal): Promise<ServerResult>;
89
447
  }
90
448
 
91
- export type { AlchemyHostPorts, DiagnosticsPort, IdentityPort, Json, KindValidatorPort, PersistencePort };
449
+ export type { AlchemyHostPorts, AssetResolverPort, AuthResumePort, ContextArrangementKnob, DensityKnob, DiagnosticsPort, HostDialogsPort, I18nPort, IconResolverPort, IdentityPort, Json, KindValidatorPort, MenuKnobsPort, NotifyPort, OverlayHostPort, PersistencePort, ServerPort, ServerResult, StorePort, TransportArtifact, TransportOutcome, TransportPort };