@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.
- package/CHANGELOG.md +58 -0
- package/dist/actions.cjs +374 -0
- package/dist/actions.cjs.map +1 -0
- package/dist/actions.d.cts +773 -0
- package/dist/actions.d.ts +773 -0
- package/dist/actions.js +351 -0
- package/dist/actions.js.map +1 -0
- package/dist/checks.cjs +31 -2
- package/dist/checks.cjs.map +1 -1
- package/dist/checks.d.cts +24 -1
- package/dist/checks.d.ts +24 -1
- package/dist/checks.js +31 -2
- package/dist/checks.js.map +1 -1
- package/dist/core.cjs +1757 -2
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +595 -1
- package/dist/core.d.ts +595 -1
- package/dist/core.js +1749 -2
- package/dist/core.js.map +1 -1
- package/dist/declare.cjs +12 -10
- package/dist/declare.cjs.map +1 -1
- package/dist/declare.d.cts +18 -2
- package/dist/declare.d.ts +18 -2
- package/dist/declare.js +12 -10
- package/dist/declare.js.map +1 -1
- package/dist/index.cjs +1757 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +595 -1
- package/dist/index.d.ts +595 -1
- package/dist/index.js +1749 -2
- package/dist/index.js.map +1 -1
- package/dist/menu.cjs +436 -0
- package/dist/menu.cjs.map +1 -0
- package/dist/menu.d.cts +834 -0
- package/dist/menu.d.ts +834 -0
- package/dist/menu.js +413 -0
- package/dist/menu.js.map +1 -0
- package/dist/operate-document.cjs +163 -0
- package/dist/operate-document.cjs.map +1 -0
- package/dist/operate-document.d.cts +132 -0
- package/dist/operate-document.d.ts +132 -0
- package/dist/operate-document.js +130 -0
- package/dist/operate-document.js.map +1 -0
- package/dist/operate-rich-html.cjs +129 -0
- package/dist/operate-rich-html.cjs.map +1 -0
- package/dist/operate-rich-html.d.cts +136 -0
- package/dist/operate-rich-html.d.ts +136 -0
- package/dist/operate-rich-html.js +96 -0
- package/dist/operate-rich-html.js.map +1 -0
- package/dist/operate-server.cjs +157 -0
- package/dist/operate-server.cjs.map +1 -0
- package/dist/operate-server.d.cts +183 -0
- package/dist/operate-server.d.ts +183 -0
- package/dist/operate-server.js +134 -0
- package/dist/operate-server.js.map +1 -0
- package/dist/operate-xlsx.cjs +248 -0
- package/dist/operate-xlsx.cjs.map +1 -0
- package/dist/operate-xlsx.d.cts +129 -0
- package/dist/operate-xlsx.d.ts +129 -0
- package/dist/operate-xlsx.js +215 -0
- package/dist/operate-xlsx.js.map +1 -0
- package/dist/operate.cjs +1774 -0
- package/dist/operate.cjs.map +1 -0
- package/dist/operate.d.cts +595 -0
- package/dist/operate.d.ts +595 -0
- package/dist/operate.js +1750 -0
- package/dist/operate.js.map +1 -0
- package/dist/ports.cjs.map +1 -1
- package/dist/ports.d.cts +361 -3
- package/dist/ports.d.ts +361 -3
- package/dist/react-bar.cjs +686 -0
- package/dist/react-bar.cjs.map +1 -0
- package/dist/react-bar.d.cts +379 -0
- package/dist/react-bar.d.ts +379 -0
- package/dist/react-bar.js +665 -0
- package/dist/react-bar.js.map +1 -0
- package/dist/react-host.cjs +301 -0
- package/dist/react-host.cjs.map +1 -0
- package/dist/react-host.d.cts +820 -0
- package/dist/react-host.d.ts +820 -0
- package/dist/react-host.js +269 -0
- package/dist/react-host.js.map +1 -0
- package/dist/react-menu.cjs +735 -0
- package/dist/react-menu.cjs.map +1 -0
- package/dist/react-menu.d.cts +370 -0
- package/dist/react-menu.d.ts +370 -0
- package/dist/react-menu.js +722 -0
- package/dist/react-menu.js.map +1 -0
- package/dist/react-overflow.cjs +592 -0
- package/dist/react-overflow.cjs.map +1 -0
- package/dist/react-overflow.d.cts +817 -0
- package/dist/react-overflow.d.ts +817 -0
- package/dist/react-overflow.js +571 -0
- package/dist/react-overflow.js.map +1 -0
- package/dist/react-palette.cjs +489 -0
- package/dist/react-palette.cjs.map +1 -0
- package/dist/react-palette.d.cts +359 -0
- package/dist/react-palette.d.ts +359 -0
- package/dist/react-palette.js +457 -0
- package/dist/react-palette.js.map +1 -0
- package/dist/react-selection.cjs +617 -0
- package/dist/react-selection.cjs.map +1 -0
- package/dist/react-selection.d.cts +357 -0
- package/dist/react-selection.d.ts +357 -0
- package/dist/react-selection.js +596 -0
- package/dist/react-selection.js.map +1 -0
- package/dist/react-sheet.cjs +616 -0
- package/dist/react-sheet.cjs.map +1 -0
- package/dist/react-sheet.d.cts +361 -0
- package/dist/react-sheet.d.ts +361 -0
- package/dist/react-sheet.js +595 -0
- package/dist/react-sheet.js.map +1 -0
- package/package.json +148 -5
package/dist/index.d.cts
CHANGED
|
@@ -1 +1,595 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Framework-neutral transfer contracts (Alchemy Operate, CONTRACT §2.3). All data crossing this boundary is JSON.
|
|
3
|
+
* Moved from `@ai-matrx/kit/content-transfer` in ALC-16; the format-adapter contract lives in `./contract`.
|
|
4
|
+
*/
|
|
5
|
+
type Json = null | boolean | number | string | Json[] | {
|
|
6
|
+
[key: string]: Json;
|
|
7
|
+
};
|
|
8
|
+
type Payload =
|
|
9
|
+
/** A text payload may name its language (code blocks): downloads take its extension, Markdown fences it. */
|
|
10
|
+
{
|
|
11
|
+
kind: "text";
|
|
12
|
+
text: string;
|
|
13
|
+
language?: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "markdown";
|
|
16
|
+
text: string;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "json";
|
|
19
|
+
value: Json;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "rows";
|
|
22
|
+
rows: Record<string, Json>[];
|
|
23
|
+
columns: Column[];
|
|
24
|
+
} | {
|
|
25
|
+
kind: "registered";
|
|
26
|
+
format: string;
|
|
27
|
+
value: Json;
|
|
28
|
+
};
|
|
29
|
+
type Column = {
|
|
30
|
+
id: string;
|
|
31
|
+
label: string;
|
|
32
|
+
path: string;
|
|
33
|
+
visible: boolean;
|
|
34
|
+
exportable?: boolean;
|
|
35
|
+
classification?: "ordinary" | "secret" | "credential";
|
|
36
|
+
/** Declared field shape suitable for a projected table-schema export. */
|
|
37
|
+
schema?: {
|
|
38
|
+
dataType?: string;
|
|
39
|
+
order?: number;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
defaultValue?: Json;
|
|
42
|
+
validation?: Json;
|
|
43
|
+
metadata?: Json;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
type ExportProjection = {
|
|
47
|
+
rules: {
|
|
48
|
+
target: "payload" | "row";
|
|
49
|
+
path: string;
|
|
50
|
+
exportable: boolean;
|
|
51
|
+
classification: "ordinary" | "secret" | "credential";
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
54
|
+
type TransferScope = "target" | "row" | "selected" | "view" | "loaded" | "all-matching";
|
|
55
|
+
type Section = {
|
|
56
|
+
id: string;
|
|
57
|
+
label: string;
|
|
58
|
+
path: string;
|
|
59
|
+
includedByDefault: boolean;
|
|
60
|
+
};
|
|
61
|
+
type Coverage = {
|
|
62
|
+
status: "complete" | "loaded" | "partial" | "unknown";
|
|
63
|
+
included: number;
|
|
64
|
+
total: number | null;
|
|
65
|
+
reason?: string;
|
|
66
|
+
};
|
|
67
|
+
type Omission = {
|
|
68
|
+
path: string;
|
|
69
|
+
reason: "excluded" | "filtered" | "truncated" | "unsupported" | "escaped" | "duplicate";
|
|
70
|
+
count?: number;
|
|
71
|
+
};
|
|
72
|
+
type RawSnapshot = {
|
|
73
|
+
id: string;
|
|
74
|
+
sourceId: string;
|
|
75
|
+
revision: string;
|
|
76
|
+
capturedAt: string;
|
|
77
|
+
label: string;
|
|
78
|
+
payload: Payload;
|
|
79
|
+
coverage: Coverage;
|
|
80
|
+
unsavedChanges: boolean;
|
|
81
|
+
omissions: Omission[];
|
|
82
|
+
sections: Section[];
|
|
83
|
+
limits?: TransferLimits;
|
|
84
|
+
};
|
|
85
|
+
declare const projected: unique symbol;
|
|
86
|
+
type Snapshot = RawSnapshot & {
|
|
87
|
+
readonly [projected]: true;
|
|
88
|
+
};
|
|
89
|
+
type QuerySnapshot = {
|
|
90
|
+
sourceId: string;
|
|
91
|
+
revision: string;
|
|
92
|
+
query: Json;
|
|
93
|
+
order: {
|
|
94
|
+
field: string;
|
|
95
|
+
direction: "asc" | "desc";
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
type ExportPage = {
|
|
99
|
+
rows: Record<string, Json>[];
|
|
100
|
+
nextCursor: string | null;
|
|
101
|
+
coverage: Coverage;
|
|
102
|
+
consistencyToken: string | null;
|
|
103
|
+
};
|
|
104
|
+
type CapturedAllMatching = {
|
|
105
|
+
query: QuerySnapshot;
|
|
106
|
+
getRowId(row: Record<string, Json>): string;
|
|
107
|
+
page(request: {
|
|
108
|
+
query: QuerySnapshot;
|
|
109
|
+
cursor: string | null;
|
|
110
|
+
consistencyToken: string | null;
|
|
111
|
+
signal: AbortSignal;
|
|
112
|
+
}): Promise<ExportPage>;
|
|
113
|
+
stableSnapshot?: boolean;
|
|
114
|
+
};
|
|
115
|
+
type CapturedSource = {
|
|
116
|
+
snapshot: RawSnapshot;
|
|
117
|
+
projection: ExportProjection;
|
|
118
|
+
allMatching?: CapturedAllMatching;
|
|
119
|
+
};
|
|
120
|
+
type Source = {
|
|
121
|
+
id: string;
|
|
122
|
+
label: string;
|
|
123
|
+
capture(request: {
|
|
124
|
+
scope: TransferScope;
|
|
125
|
+
signal: AbortSignal;
|
|
126
|
+
}): Promise<CapturedSource>;
|
|
127
|
+
};
|
|
128
|
+
type Draft = {
|
|
129
|
+
snapshotId: string;
|
|
130
|
+
sourceId: string;
|
|
131
|
+
sourceRevision: string;
|
|
132
|
+
revision: number;
|
|
133
|
+
payload: Payload;
|
|
134
|
+
omissions: Omission[];
|
|
135
|
+
manuallyEdited: boolean;
|
|
136
|
+
provenance: {
|
|
137
|
+
kind: "original" | "deterministic" | "manual" | "ai";
|
|
138
|
+
operationId?: string;
|
|
139
|
+
description: string;
|
|
140
|
+
}[];
|
|
141
|
+
/** Frozen prior states, with history omitted to avoid recursive duplication. */
|
|
142
|
+
history?: readonly Omit<Draft, "history">[];
|
|
143
|
+
};
|
|
144
|
+
type Transform = {
|
|
145
|
+
id: string;
|
|
146
|
+
apply(draft: Draft, options: Json, signal: AbortSignal): Promise<Draft>;
|
|
147
|
+
};
|
|
148
|
+
type Artifact = {
|
|
149
|
+
snapshotId: string;
|
|
150
|
+
draftRevision: number;
|
|
151
|
+
format: string;
|
|
152
|
+
plainText: string;
|
|
153
|
+
html?: string;
|
|
154
|
+
file?: {
|
|
155
|
+
filename: string;
|
|
156
|
+
mime: string;
|
|
157
|
+
bytes: Uint8Array;
|
|
158
|
+
};
|
|
159
|
+
omissions: Omission[];
|
|
160
|
+
};
|
|
161
|
+
/** A concrete destination receipt; opening an editor is not a persisted save. */
|
|
162
|
+
type TransferTarget = {
|
|
163
|
+
kind: string;
|
|
164
|
+
id: string;
|
|
165
|
+
label: string;
|
|
166
|
+
href?: string;
|
|
167
|
+
};
|
|
168
|
+
type TransferOutcome = {
|
|
169
|
+
status: "success";
|
|
170
|
+
delivered: "clipboard" | "download-started" | "action";
|
|
171
|
+
mimeTypes: string[];
|
|
172
|
+
/** Host-provided completion text for an explicit page action. */
|
|
173
|
+
message?: string;
|
|
174
|
+
target?: TransferTarget;
|
|
175
|
+
} | {
|
|
176
|
+
status: "degraded";
|
|
177
|
+
delivered: "plain-text";
|
|
178
|
+
reason: string;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Accepted for review; NOTHING was written and NOTHING failed.
|
|
182
|
+
*
|
|
183
|
+
* A destination whose organization reviews this kind of change first answers
|
|
184
|
+
* "filed, waiting for a person" — a queued write is neither a delivery nor a
|
|
185
|
+
* failure, and reporting it as either lies in one of two directions: claiming
|
|
186
|
+
* a record that does not exist, or telling someone their work was lost while
|
|
187
|
+
* it sits in a queue with their name on it.
|
|
188
|
+
*
|
|
189
|
+
* It carries the same sentence/remedy pair the other members carry, both
|
|
190
|
+
* REQUIRED: `message` is what happened in the host's own words, `remedy` is
|
|
191
|
+
* the half that sentence never states — what has NOT happened yet and what
|
|
192
|
+
* the person does next. `target`, when the host can name it, is the pending
|
|
193
|
+
* request itself (the approval row, which exists and opens) and NEVER the
|
|
194
|
+
* destination record, which does not exist yet.
|
|
195
|
+
*/
|
|
196
|
+
| {
|
|
197
|
+
status: "queued";
|
|
198
|
+
message: string;
|
|
199
|
+
remedy: string;
|
|
200
|
+
target?: TransferTarget;
|
|
201
|
+
} | {
|
|
202
|
+
status: "cancelled";
|
|
203
|
+
} | {
|
|
204
|
+
status: "error";
|
|
205
|
+
code: string;
|
|
206
|
+
message: string;
|
|
207
|
+
retryable: boolean;
|
|
208
|
+
target?: TransferTarget;
|
|
209
|
+
};
|
|
210
|
+
type Transport = {
|
|
211
|
+
copy(artifact: Artifact, signal: AbortSignal): Promise<TransferOutcome>;
|
|
212
|
+
download(artifact: Artifact, signal: AbortSignal): Promise<TransferOutcome>;
|
|
213
|
+
};
|
|
214
|
+
type SurfaceHandle = {
|
|
215
|
+
instanceId: string;
|
|
216
|
+
surfaceName: string;
|
|
217
|
+
isMounted(): boolean;
|
|
218
|
+
capture(signal: AbortSignal): Promise<CapturedSource>;
|
|
219
|
+
};
|
|
220
|
+
type AiPreparation = {
|
|
221
|
+
supports(snapshot: Snapshot): boolean;
|
|
222
|
+
run(request: {
|
|
223
|
+
snapshot: Snapshot;
|
|
224
|
+
draft: Draft;
|
|
225
|
+
instruction: string;
|
|
226
|
+
signal: AbortSignal;
|
|
227
|
+
}): Promise<Draft>;
|
|
228
|
+
/** Create an isolated adapter session for one preparation workspace. */
|
|
229
|
+
fork?(): AiPreparation;
|
|
230
|
+
/** Cancel the retained provider request; closing a host UI does not imply this. */
|
|
231
|
+
cancel?(): Promise<void>;
|
|
232
|
+
/** Revalidate the frozen source and recover a previously saved provider result. */
|
|
233
|
+
recover?(input: {
|
|
234
|
+
snapshot: Snapshot;
|
|
235
|
+
draft: Draft;
|
|
236
|
+
signal: AbortSignal;
|
|
237
|
+
}): Promise<Draft>;
|
|
238
|
+
};
|
|
239
|
+
type TransferLimits = {
|
|
240
|
+
maxRows: number | null;
|
|
241
|
+
maxStringChars: number | null;
|
|
242
|
+
maxDepth: number | null;
|
|
243
|
+
maxArrayItems?: number | null;
|
|
244
|
+
targetTokens: number | null;
|
|
245
|
+
};
|
|
246
|
+
type TransferPreferences = {
|
|
247
|
+
initialFormat: string;
|
|
248
|
+
initialPreset: "full" | "compact" | "brief";
|
|
249
|
+
limits: TransferLimits;
|
|
250
|
+
};
|
|
251
|
+
type PageAction = {
|
|
252
|
+
/** Alternate click-time source, captured through the same projection and limits before run. */
|
|
253
|
+
source?: Source;
|
|
254
|
+
id: string;
|
|
255
|
+
label: string;
|
|
256
|
+
supports(snapshot: Snapshot, draft?: Draft): boolean;
|
|
257
|
+
run(request: {
|
|
258
|
+
snapshot: Snapshot;
|
|
259
|
+
draft: Draft;
|
|
260
|
+
signal: AbortSignal;
|
|
261
|
+
}): Promise<TransferOutcome>;
|
|
262
|
+
};
|
|
263
|
+
|
|
264
|
+
/** Matrx's portable, source-labelled envelope for external AI tools. */
|
|
265
|
+
interface AgentPayloadInput {
|
|
266
|
+
kind: string;
|
|
267
|
+
location: string;
|
|
268
|
+
description: string;
|
|
269
|
+
data: unknown;
|
|
270
|
+
summary?: string;
|
|
271
|
+
attributes?: Record<string, string | number | boolean | null | undefined>;
|
|
272
|
+
context?: Record<string, string | number | boolean | null | undefined>;
|
|
273
|
+
}
|
|
274
|
+
interface AgentPayloadEnvironment {
|
|
275
|
+
url?: string;
|
|
276
|
+
route?: string;
|
|
277
|
+
capturedAt?: string;
|
|
278
|
+
}
|
|
279
|
+
/** A fence longer than any content fence prevents accidental Markdown closure. */
|
|
280
|
+
declare function fenceJsonBlock(json: string): string;
|
|
281
|
+
/** Capture location at invocation; environment injection makes non-browser use explicit. */
|
|
282
|
+
declare function buildAgentPayload(input: AgentPayloadInput, environment?: AgentPayloadEnvironment): string;
|
|
283
|
+
|
|
284
|
+
declare class ContentTransferError extends Error {
|
|
285
|
+
readonly code: string;
|
|
286
|
+
readonly path: string | undefined;
|
|
287
|
+
constructor(code: string, message: string, path?: string);
|
|
288
|
+
/**
|
|
289
|
+
* One error class across every loaded copy: while `@ai-matrx/kit/content-transfer`
|
|
290
|
+
* still bundles this module for its not-yet-repointed consumers (ALC-16), an
|
|
291
|
+
* error raised by one copy is `instanceof` the other.
|
|
292
|
+
*/
|
|
293
|
+
static [Symbol.hasInstance](value: unknown): boolean;
|
|
294
|
+
}
|
|
295
|
+
/** A realm-wide brand (Symbol.for), so a binding made by one loaded copy is recognised by another. */
|
|
296
|
+
declare const bound: unique symbol;
|
|
297
|
+
type BoundAllMatching = {
|
|
298
|
+
readonly [bound]: true;
|
|
299
|
+
readonly source: CapturedAllMatching;
|
|
300
|
+
readonly projection: ExportProjection;
|
|
301
|
+
readonly columns: readonly Column[];
|
|
302
|
+
readonly limits?: TransferLimits;
|
|
303
|
+
};
|
|
304
|
+
type NormalizeTransferJsonOptions = {
|
|
305
|
+
omitUndefinedObjectProperties?: boolean;
|
|
306
|
+
};
|
|
307
|
+
declare function normalizeTransferJson(value: unknown, options?: NormalizeTransferJsonOptions): Json;
|
|
308
|
+
/** Column ids are identities, never an alternative data address. */
|
|
309
|
+
declare function readTransferCell(row: Record<string, Json>, column: Column): Json | undefined;
|
|
310
|
+
declare function projectSnapshot(raw: RawSnapshot, projection: ExportProjection): Snapshot;
|
|
311
|
+
declare function directSource(payload: Payload, options?: Partial<Pick<RawSnapshot, "id" | "sourceId" | "revision" | "label" | "coverage" | "unsavedChanges" | "sections" | "limits"> & {
|
|
312
|
+
projection: ExportProjection;
|
|
313
|
+
}>): CapturedSource;
|
|
314
|
+
declare function capture(source: Source | Payload, signal: AbortSignal, scope?: TransferScope): Promise<{
|
|
315
|
+
snapshot: Snapshot;
|
|
316
|
+
allMatching?: BoundAllMatching;
|
|
317
|
+
}>;
|
|
318
|
+
declare function createDraft(s: Snapshot): Draft;
|
|
319
|
+
declare const editDraft: (d: Draft, p: Payload) => Draft;
|
|
320
|
+
declare const resetDraft: (s: Snapshot) => Draft;
|
|
321
|
+
declare const sourceChanged: (d: Draft, s: Snapshot) => boolean;
|
|
322
|
+
declare function undoDraft(d: Draft): Draft;
|
|
323
|
+
/** Keep and regenerate are explicit choices; observing fresh data never overwrites edits. */
|
|
324
|
+
declare function refreshDraft(draft: Draft, snapshot: Snapshot, choice: "keep" | "regenerate"): Draft;
|
|
325
|
+
declare function applySectionSelection(d: Draft, s: Snapshot, ids: readonly string[]): Draft;
|
|
326
|
+
declare function transformRows(d: Draft, o: {
|
|
327
|
+
search?: string;
|
|
328
|
+
sort?: {
|
|
329
|
+
column: string;
|
|
330
|
+
direction: "asc" | "desc";
|
|
331
|
+
};
|
|
332
|
+
filters?: Readonly<Record<string, string>>;
|
|
333
|
+
/** Positions in this call's input draft rows; unlike ids, no guessed key is used. */
|
|
334
|
+
selectedIndices?: readonly number[];
|
|
335
|
+
selectedIds?: readonly string[];
|
|
336
|
+
idColumn?: string;
|
|
337
|
+
visibleColumns?: readonly string[];
|
|
338
|
+
structuredProjection?: "full" | "visible";
|
|
339
|
+
top?: number | null;
|
|
340
|
+
}): Draft;
|
|
341
|
+
declare function reduceJson(draft: Draft, options: {
|
|
342
|
+
exclude?: readonly string[];
|
|
343
|
+
maxDepth?: number | null;
|
|
344
|
+
maxStringChars?: number | null;
|
|
345
|
+
maxArrayItems?: number | null;
|
|
346
|
+
}): Draft;
|
|
347
|
+
declare function collectAllMatching(c: BoundAllMatching, signal: AbortSignal): Promise<{
|
|
348
|
+
rows: Record<string, Json>[];
|
|
349
|
+
coverage: RawSnapshot["coverage"];
|
|
350
|
+
omissions: Omission[];
|
|
351
|
+
error?: ContentTransferError;
|
|
352
|
+
}>;
|
|
353
|
+
/** Preserve artifact-byte identity even if a consumer mutates a returned view. */
|
|
354
|
+
declare function sealTransferArtifact(artifact: Artifact): Artifact;
|
|
355
|
+
declare function serialize(draft: Draft, format: "plain" | "markdown" | "json" | "compact-json" | "csv" | "tsv" | "html", options?: {
|
|
356
|
+
spreadsheetSafe?: boolean;
|
|
357
|
+
filename?: string;
|
|
358
|
+
}): Artifact;
|
|
359
|
+
declare function createBrowserTransport(): Transport;
|
|
360
|
+
type TransferPreferenceOverrides = Partial<Omit<TransferPreferences, "limits">> & {
|
|
361
|
+
limits?: Partial<TransferLimits>;
|
|
362
|
+
};
|
|
363
|
+
/** Restrictions intersect: neither a menu nor a provider can relax a source limit. */
|
|
364
|
+
declare function resolveTransferPreferences(provider?: TransferPreferenceOverrides, menu?: TransferPreferenceOverrides, sourceLimits?: Partial<TransferLimits>): TransferPreferences;
|
|
365
|
+
/** One stable id per registered format or action; ambiguous overrides fail loudly. */
|
|
366
|
+
declare function resolveTransferRegistry<T extends {
|
|
367
|
+
id: string;
|
|
368
|
+
}>(...groups: readonly (readonly T[])[]): readonly T[];
|
|
369
|
+
type TransferSurfaceDeclaration = {
|
|
370
|
+
surfaceName: string;
|
|
371
|
+
label?: string;
|
|
372
|
+
values: readonly {
|
|
373
|
+
name: string;
|
|
374
|
+
label: string;
|
|
375
|
+
exportable?: boolean;
|
|
376
|
+
classification?: "ordinary" | "secret" | "credential";
|
|
377
|
+
includedByDefault?: boolean;
|
|
378
|
+
}[];
|
|
379
|
+
};
|
|
380
|
+
/** A structural adapter to the actual mounted surface, never a global name lookup. */
|
|
381
|
+
declare function createSurfaceTransferHandle(options: {
|
|
382
|
+
instanceId: string;
|
|
383
|
+
manifest: TransferSurfaceDeclaration;
|
|
384
|
+
isMounted(): boolean;
|
|
385
|
+
getScope(): Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
386
|
+
getRevision?(): string;
|
|
387
|
+
unsavedChanges?(): boolean;
|
|
388
|
+
projection?: ExportProjection;
|
|
389
|
+
limits?: TransferLimits;
|
|
390
|
+
}): SurfaceHandle;
|
|
391
|
+
/** Applies explicit preparation/source limits with exact omissions; token target is advisory. */
|
|
392
|
+
declare function applyTransferLimits(draft: Draft, limits: Partial<TransferLimits>): Draft;
|
|
393
|
+
|
|
394
|
+
interface AssetResolverPort {
|
|
395
|
+
resolve(url: string, signal: AbortSignal): Promise<{
|
|
396
|
+
url: string;
|
|
397
|
+
} | null>;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
* Operate — the format and delivery contract (Matrx Alchemy CONTRACT §2.3, ALC-16).
|
|
402
|
+
*
|
|
403
|
+
* A format is an ADAPTER: `supports` is synchronous and loads nothing; `load` dynamically
|
|
404
|
+
* imports the engine the first time the format is chosen (print for rich-html/html/pdf/docx/
|
|
405
|
+
* epub, SheetJS for xlsx). Delivery accepts only a SEALED artifact, so the bytes previewed are
|
|
406
|
+
* the bytes copied, downloaded or sent.
|
|
407
|
+
*/
|
|
408
|
+
|
|
409
|
+
type Notice = {
|
|
410
|
+
code: string;
|
|
411
|
+
sentence: string;
|
|
412
|
+
remedy: string;
|
|
413
|
+
};
|
|
414
|
+
/** A reference to a declared write target (the write door arrives in ALC-17). */
|
|
415
|
+
interface WriteTargetRef {
|
|
416
|
+
surfaceName?: string;
|
|
417
|
+
target: string;
|
|
418
|
+
item?: {
|
|
419
|
+
itemType: string;
|
|
420
|
+
identity: Record<string, string>;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
/** What a person or agent asks Operate to do with a source. */
|
|
424
|
+
type TransferOperation = {
|
|
425
|
+
kind: "copy";
|
|
426
|
+
format: string;
|
|
427
|
+
} | {
|
|
428
|
+
kind: "download";
|
|
429
|
+
format: string;
|
|
430
|
+
} | {
|
|
431
|
+
kind: "transform";
|
|
432
|
+
transform: string;
|
|
433
|
+
options?: Json;
|
|
434
|
+
} | {
|
|
435
|
+
kind: "prepare-for-ai";
|
|
436
|
+
instruction?: string;
|
|
437
|
+
} | {
|
|
438
|
+
kind: "send";
|
|
439
|
+
destination: WriteTargetRef;
|
|
440
|
+
};
|
|
441
|
+
/** The stable format ids. A registered row format adds its own id. */
|
|
442
|
+
type BuiltInFormatId = "plain" | "markdown" | "rich-html" | "html" | "json" | "compact-json" | "csv" | "tsv" | "xlsx" | "pdf" | "docx" | "epub";
|
|
443
|
+
interface FormatOptions {
|
|
444
|
+
filename?: string;
|
|
445
|
+
spreadsheetSafe?: boolean;
|
|
446
|
+
/** Markdown→HTML skin: the two page looks plus "inline" for the rich clipboard (styles on elements). */
|
|
447
|
+
skin?: "document" | "article" | "inline";
|
|
448
|
+
/** Rich clipboard destination profile (1.9a). A profile is its own action only when its bytes differ. */
|
|
449
|
+
profile?: "generic" | "google-docs" | "word";
|
|
450
|
+
/** Private or signed images → share-safe URLs before HTML is sealed (the host's `assets` port). */
|
|
451
|
+
assets?: AssetResolverPort;
|
|
452
|
+
/** Opt-in lazy code highlighting (default off; no highlighter is chosen yet — CONTRACT R19). */
|
|
453
|
+
highlightCode?: boolean;
|
|
454
|
+
onNotice?(notice: Notice): void;
|
|
455
|
+
}
|
|
456
|
+
interface FormatEngine {
|
|
457
|
+
build(draft: Draft, options: FormatOptions, signal: AbortSignal): Promise<Artifact>;
|
|
458
|
+
}
|
|
459
|
+
interface FormatAdapter {
|
|
460
|
+
id: BuiltInFormatId | (string & {});
|
|
461
|
+
label: string;
|
|
462
|
+
extension: string;
|
|
463
|
+
mime: string;
|
|
464
|
+
modes: readonly ("copy" | "download")[];
|
|
465
|
+
runsOn: "client";
|
|
466
|
+
supports(payload: Payload): boolean;
|
|
467
|
+
load(): Promise<FormatEngine>;
|
|
468
|
+
}
|
|
469
|
+
/** Work the client cannot do (Office generation/conversion, server PDF letters). */
|
|
470
|
+
interface ServerOperation {
|
|
471
|
+
id: string;
|
|
472
|
+
label: string;
|
|
473
|
+
runsOn: "server";
|
|
474
|
+
/** Shown in the menu: the person is told this leaves the device. */
|
|
475
|
+
statement: string;
|
|
476
|
+
supports(payload: Payload): boolean;
|
|
477
|
+
/** Projected draft only; sensitivity already applied. */
|
|
478
|
+
toInput(draft: Draft): Json;
|
|
479
|
+
}
|
|
480
|
+
/** Delivery results: `copy` and `download` only ever deliver, degrade, cancel or fail (CONTRACT R16). */
|
|
481
|
+
type DeliveryOutcome = Extract<TransferOutcome, {
|
|
482
|
+
status: "success" | "degraded" | "cancelled" | "error";
|
|
483
|
+
}>;
|
|
484
|
+
declare const sealed: unique symbol;
|
|
485
|
+
/** Only `seal` (a preparation session or `sealArtifact`) produces one; delivery accepts nothing else. */
|
|
486
|
+
type SealedArtifact = Artifact & {
|
|
487
|
+
readonly [sealed]: true;
|
|
488
|
+
};
|
|
489
|
+
/** Every send returns one (the write door's receipt shape, CONTRACT §2.3; the door itself is ALC-17). */
|
|
490
|
+
type Receipt = {
|
|
491
|
+
status: "applied";
|
|
492
|
+
to: WriteTargetRef;
|
|
493
|
+
sentence: string;
|
|
494
|
+
} | {
|
|
495
|
+
status: "queued";
|
|
496
|
+
to: WriteTargetRef;
|
|
497
|
+
sentence: string;
|
|
498
|
+
remedy: string;
|
|
499
|
+
} | {
|
|
500
|
+
status: "refused";
|
|
501
|
+
to: WriteTargetRef;
|
|
502
|
+
reason: string;
|
|
503
|
+
sentence: string;
|
|
504
|
+
remedy: string;
|
|
505
|
+
};
|
|
506
|
+
interface Delivery {
|
|
507
|
+
copy(artifact: SealedArtifact, signal: AbortSignal): Promise<DeliveryOutcome>;
|
|
508
|
+
/**
|
|
509
|
+
* Safari: call SYNCHRONOUSLY inside the click. Writes a promise-valued ClipboardItem at once and
|
|
510
|
+
* resolves it with the sealed artifact's bytes when `seal` finishes — the same bytes as `copy`,
|
|
511
|
+
* never a rebuild. `html` says whether the format carries rich HTML (decided before sealing).
|
|
512
|
+
*/
|
|
513
|
+
copyPending(artifact: Promise<SealedArtifact>, signal: AbortSignal, options?: {
|
|
514
|
+
html?: boolean;
|
|
515
|
+
}): Promise<DeliveryOutcome>;
|
|
516
|
+
download(artifact: SealedArtifact, signal: AbortSignal): Promise<DeliveryOutcome>;
|
|
517
|
+
/** Sends the sealed bytes through the write door (ALC-17). Without a door: refused, with a remedy. */
|
|
518
|
+
send(artifact: SealedArtifact, to: WriteTargetRef, via: "destination"): Promise<Receipt>;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Operate formats — one adapter per format, stable ids, synchronous eligibility, lazy engines
|
|
523
|
+
* (Matrx Alchemy CONTRACT §1.9 / §2.3, ALC-16).
|
|
524
|
+
*
|
|
525
|
+
* Built in (no heavy dependency): plain, markdown, json, compact-json, csv, tsv, rows→html.
|
|
526
|
+
* Loaded on first use: rich-html, html (documents), pdf, docx, epub (print's one Markdown→HTML
|
|
527
|
+
* engine and document writers) and xlsx (SheetJS). The heavy libraries are only ever reached
|
|
528
|
+
* through `import()`, so choosing plain text never downloads a PDF writer.
|
|
529
|
+
*/
|
|
530
|
+
|
|
531
|
+
declare function extensionForLanguage(language: string | undefined): string;
|
|
532
|
+
/** THE format adapters. Order is menu order. Ids are stable; labels are what a person reads. */
|
|
533
|
+
declare const FORMAT_ADAPTERS: readonly FormatAdapter[];
|
|
534
|
+
/**
|
|
535
|
+
* The adapters for a payload, in menu order: built-ins first, then registered formats (a
|
|
536
|
+
* duplicate id is refused — a registered format can never shadow a built-in).
|
|
537
|
+
*/
|
|
538
|
+
declare function eligibleFormats(payload: Payload, registered?: readonly FormatAdapter[], mode?: "copy" | "download"): FormatAdapter[];
|
|
539
|
+
/** Find an adapter by id (built-in or registered); an unknown id is an error with a remedy. */
|
|
540
|
+
declare function formatAdapter(id: string, registered?: readonly FormatAdapter[]): FormatAdapter;
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* The preparation workspace and delivery (CONTRACT §2.3, "exact bytes: preview = copy = download = send").
|
|
544
|
+
*
|
|
545
|
+
* capture → draft edits → SEAL → copy / download / send, and delivery takes the sealed artifact as-is.
|
|
546
|
+
*
|
|
547
|
+
* `seal` builds once per (draft revision, format, options) and brands the result; `copy`,
|
|
548
|
+
* `copyPending`, `download` and `send` accept only a branded artifact and never rebuild, so the
|
|
549
|
+
* bytes a person previewed are the bytes that reach the clipboard, the file or the destination.
|
|
550
|
+
*/
|
|
551
|
+
|
|
552
|
+
/** Freeze an artifact's bytes and brand it; the only way to make a `SealedArtifact`. */
|
|
553
|
+
declare function sealArtifact(artifact: Artifact): SealedArtifact;
|
|
554
|
+
/** True only for an artifact `sealArtifact` (or a preparation session's `seal`) produced. */
|
|
555
|
+
declare function isSealed(artifact: unknown): artifact is SealedArtifact;
|
|
556
|
+
interface PreparationSession {
|
|
557
|
+
readonly snapshot: Snapshot;
|
|
558
|
+
readonly draft: Draft;
|
|
559
|
+
/** Deterministic transform, AI preparation or any registered transform — bumps draft.revision. */
|
|
560
|
+
transform(id: string, options: Json, signal: AbortSignal): Promise<Draft>;
|
|
561
|
+
/** A manual edit. */
|
|
562
|
+
edit(payload: Payload): Draft;
|
|
563
|
+
/** Keep only these sections (ids from the snapshot). */
|
|
564
|
+
selectSections(ids: readonly string[]): Draft;
|
|
565
|
+
undo(): Draft;
|
|
566
|
+
/** Build once and seal; cached per (draft revision, format, options). */
|
|
567
|
+
seal(format: string, options: FormatOptions, signal: AbortSignal): Promise<SealedArtifact>;
|
|
568
|
+
}
|
|
569
|
+
interface PreparationOptions {
|
|
570
|
+
/** Transforms this session may run, by id (a duplicate id is refused). */
|
|
571
|
+
transforms?: readonly Transform[];
|
|
572
|
+
/** Registered row formats beside the built-ins (a duplicate id is refused). */
|
|
573
|
+
formats?: readonly FormatAdapter[];
|
|
574
|
+
}
|
|
575
|
+
declare function openPreparation(source: Source | Payload, scope: TransferScope, signal: AbortSignal, options?: PreparationOptions): Promise<PreparationSession>;
|
|
576
|
+
/** Seal a draft directly (hosts without a workspace, e.g. a one-click "Copy as CSV"). */
|
|
577
|
+
declare function sealDraft(draft: Draft, format: string, options: FormatOptions, signal: AbortSignal, formats?: readonly FormatAdapter[]): Promise<SealedArtifact>;
|
|
578
|
+
/**
|
|
579
|
+
* The one delivery. `transport` defaults to the browser (clipboard + download link); a non-browser
|
|
580
|
+
* host binds its own (`TransportPort`). `send` needs the write door (ALC-17): without one it is
|
|
581
|
+
* refused with a remedy, never faked.
|
|
582
|
+
*/
|
|
583
|
+
declare function createDelivery(ports?: {
|
|
584
|
+
transport?: Transport;
|
|
585
|
+
door?: {
|
|
586
|
+
apply(request: {
|
|
587
|
+
to: WriteTargetRef;
|
|
588
|
+
value: unknown;
|
|
589
|
+
origin: "user";
|
|
590
|
+
via: "destination";
|
|
591
|
+
}): Promise<Receipt>;
|
|
592
|
+
};
|
|
593
|
+
}): Delivery;
|
|
594
|
+
|
|
595
|
+
export { type AgentPayloadEnvironment, type AgentPayloadInput, type AiPreparation, type Artifact, type BoundAllMatching, type BuiltInFormatId, type CapturedAllMatching, type CapturedSource, type Column, ContentTransferError, type Coverage, type Delivery, type DeliveryOutcome, type Draft, type ExportPage, type ExportProjection, FORMAT_ADAPTERS, type FormatAdapter, type FormatEngine, type FormatOptions, type Json, type NormalizeTransferJsonOptions, type Notice, type Omission, type PageAction, type Payload, type PreparationOptions, type PreparationSession, type QuerySnapshot, type RawSnapshot, type Receipt, type SealedArtifact, type Section, type ServerOperation, type Snapshot, type Source, type SurfaceHandle, type TransferLimits, type TransferOperation, type TransferOutcome, type TransferPreferenceOverrides, type TransferPreferences, type TransferScope, type TransferSurfaceDeclaration, type TransferTarget, type Transform, type Transport, type WriteTargetRef, applySectionSelection, applyTransferLimits, buildAgentPayload, capture, collectAllMatching, createBrowserTransport, createDelivery, createDraft, createSurfaceTransferHandle, directSource, editDraft, eligibleFormats, extensionForLanguage, fenceJsonBlock, formatAdapter, isSealed, normalizeTransferJson, openPreparation, projectSnapshot, readTransferCell, reduceJson, refreshDraft, resetDraft, resolveTransferPreferences, resolveTransferRegistry, sealArtifact, sealDraft, sealTransferArtifact, serialize, sourceChanged, transformRows, undoDraft };
|