@ai-matrx/alchemy 0.9.1 → 0.10.1
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 +33 -0
- package/README.md +1 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +166 -2
- package/dist/actions.d.ts +166 -2
- package/dist/actions.js +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +143 -14
- package/dist/core.d.ts +143 -14
- package/dist/core.js +2 -2
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +143 -14
- package/dist/index.d.ts +143 -14
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/menu.d.cts +153 -1
- package/dist/menu.d.ts +153 -1
- package/dist/operate-server.d.cts +5 -1
- package/dist/operate-server.d.ts +5 -1
- package/dist/operate.cjs +1 -1
- package/dist/operate.cjs.map +1 -1
- package/dist/operate.d.cts +143 -14
- package/dist/operate.d.ts +143 -14
- package/dist/operate.js +2 -2
- package/dist/operate.js.map +1 -1
- package/dist/ports.cjs.map +1 -1
- package/dist/ports.d.cts +154 -2
- package/dist/ports.d.ts +154 -2
- package/dist/react-host.d.cts +153 -1
- package/dist/react-host.d.ts +153 -1
- package/dist/react-overflow.d.cts +153 -1
- package/dist/react-overflow.d.ts +153 -1
- package/package.json +1 -1
package/dist/react-host.d.ts
CHANGED
|
@@ -251,6 +251,148 @@ interface ClickTarget {
|
|
|
251
251
|
host?: unknown;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Operate — the format and delivery contract (Matrx Alchemy CONTRACT §2.3, ALC-16).
|
|
256
|
+
*
|
|
257
|
+
* A format is an ADAPTER: `supports` is synchronous and loads nothing; `load` dynamically
|
|
258
|
+
* imports the engine the first time the format is chosen (print for rich-html/html/pdf/docx/
|
|
259
|
+
* epub, SheetJS for xlsx). Delivery accepts only a SEALED artifact, so the bytes previewed are
|
|
260
|
+
* the bytes copied, downloaded or sent.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/** A reference to a declared write target (resolved by the one write door, ALC-17). */
|
|
264
|
+
interface WriteTargetRef {
|
|
265
|
+
surfaceName?: string;
|
|
266
|
+
target: string;
|
|
267
|
+
item?: {
|
|
268
|
+
itemType: string;
|
|
269
|
+
identity: Record<string, string>;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Every write returns one (CONTRACT §2.3; the door is `createWriteDoor`, ALC-17). An applied
|
|
274
|
+
* receipt may carry a `warning` with its `fix` (rule 10: a person's kind mismatch warns, never refuses).
|
|
275
|
+
* A refusal's `reason` is a `WriteRefusalReason` (`./door`).
|
|
276
|
+
*/
|
|
277
|
+
type Receipt = {
|
|
278
|
+
status: "applied";
|
|
279
|
+
to: WriteTargetRef;
|
|
280
|
+
sentence: string;
|
|
281
|
+
warning?: string;
|
|
282
|
+
fix?: string;
|
|
283
|
+
} | {
|
|
284
|
+
status: "queued";
|
|
285
|
+
to: WriteTargetRef;
|
|
286
|
+
sentence: string;
|
|
287
|
+
remedy: string;
|
|
288
|
+
} | {
|
|
289
|
+
status: "refused";
|
|
290
|
+
to: WriteTargetRef;
|
|
291
|
+
reason: string;
|
|
292
|
+
sentence: string;
|
|
293
|
+
remedy: string;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* THE ONE WRITE DOOR (Matrx Alchemy ALC-17; Applets CONTRACTS §6 "receipts through the one write door").
|
|
298
|
+
*
|
|
299
|
+
* Every write — a person's edit, a menu row, a destination send, an agent, an applet, an automation,
|
|
300
|
+
* an Action projected from a write target — lands through `door.write`. The door:
|
|
301
|
+
*
|
|
302
|
+
* 1. resolves the DECLARED write target (the surface's own, then its ancestors'); an undeclared
|
|
303
|
+
* target is refused by name;
|
|
304
|
+
* 2. enforces the mode: `stream` takes ops from the target's `streamOps`; ops on any other target
|
|
305
|
+
* need `patchable` (+ `updatesValue`); a value on a `stream` target is refused;
|
|
306
|
+
* 3. checks the kind (rule 10): a person's mismatch WARNS (the receipt is still applied, with a
|
|
307
|
+
* `warning` and a `fix`); an agent's, applet's or automation's malformed write is REFUSED;
|
|
308
|
+
* 4. applies the policy: manual → a person only; ask → a person's own act is the approval, anyone
|
|
309
|
+
* else asks through `approvals`; queued → filed through `review`; auto → applies;
|
|
310
|
+
* 5. applies through the handler: the mounted page's LIVE handler wins over the HEADLESS one;
|
|
311
|
+
* neither → refused `unapplicable` ("open <surface> to apply it");
|
|
312
|
+
* 6. turns stale / missing record / broken protected span into "cannot apply" with a one-click
|
|
313
|
+
* remedy (rule 11).
|
|
314
|
+
*
|
|
315
|
+
* Every outcome is a `Receipt` carrying the system's own sentence. `write` never throws.
|
|
316
|
+
*
|
|
317
|
+
* Who counts as a person: `person`, `menu` and `destination` (a destination send is a person's own
|
|
318
|
+
* click on "Send to …"). `agent`, `applet` and `automation` are not.
|
|
319
|
+
*
|
|
320
|
+
* Open-risk ruling — stream ops into an entity target: an entity write is ONE atomic save. Ops reach
|
|
321
|
+
* an entity target only when it is declared `patchable` (the ops are handed to the handler in one
|
|
322
|
+
* call and commit as one save); a non-patchable entity target refuses ops with the remedy "stream
|
|
323
|
+
* into the editor, then save". Op-by-op persistence into a record does not exist.
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
/** Who is writing. `menu` and `destination` are a person's own act. */
|
|
327
|
+
type WriteCaller = "person" | "agent" | "applet" | "automation" | "destination" | "menu";
|
|
328
|
+
/** One text op for a `stream` (or `patchable`) target — the WidgetHandle op set. */
|
|
329
|
+
interface WriteOp {
|
|
330
|
+
op: StreamOp;
|
|
331
|
+
/** The text the op inserts or replaces with. */
|
|
332
|
+
text?: string;
|
|
333
|
+
/** What `replace` / `insert_before` / `insert_after` / `patch` anchor on. */
|
|
334
|
+
find?: string;
|
|
335
|
+
}
|
|
336
|
+
interface WriteRequest {
|
|
337
|
+
surfaceName: string;
|
|
338
|
+
/** A write target name; `"<itemType>.<name>"` names an item's target. */
|
|
339
|
+
target: string;
|
|
340
|
+
itemType?: string;
|
|
341
|
+
/** Which item, by its declared identity values. Required for an item target. */
|
|
342
|
+
itemIdentity?: Record<string, string>;
|
|
343
|
+
/** A whole value. Exactly one of `value` / `ops`. */
|
|
344
|
+
value?: unknown;
|
|
345
|
+
/** Text ops (stream / patchable targets). */
|
|
346
|
+
ops?: readonly WriteOp[];
|
|
347
|
+
by: WriteCaller;
|
|
348
|
+
runId?: string;
|
|
349
|
+
}
|
|
350
|
+
/** What a handler receives: the request plus the declared target it resolved to. */
|
|
351
|
+
interface WriteApplyRequest {
|
|
352
|
+
surfaceName: string;
|
|
353
|
+
/** The surface that declares the target (an ancestor when inherited). */
|
|
354
|
+
declaredOn: string;
|
|
355
|
+
target: WriteTarget;
|
|
356
|
+
item?: {
|
|
357
|
+
itemType: string;
|
|
358
|
+
identity: Record<string, string>;
|
|
359
|
+
};
|
|
360
|
+
value?: unknown;
|
|
361
|
+
ops?: readonly WriteOp[];
|
|
362
|
+
by: WriteCaller;
|
|
363
|
+
runId?: string;
|
|
364
|
+
}
|
|
365
|
+
/** Rule 11: the three "cannot apply" signals. */
|
|
366
|
+
type CannotApply = "stale" | "missing-record" | "broken-span";
|
|
367
|
+
/**
|
|
368
|
+
* A handler applies the write. Return nothing (or `{ status: "applied" }`) when it landed, or a
|
|
369
|
+
* `cannotApply` signal; THROWING an error whose `code` is a `CannotApply` signal means the same.
|
|
370
|
+
*/
|
|
371
|
+
type WriteHandlerResult = void | {
|
|
372
|
+
status: "applied";
|
|
373
|
+
sentence?: string;
|
|
374
|
+
} | {
|
|
375
|
+
status: "cannot-apply";
|
|
376
|
+
cannotApply: CannotApply;
|
|
377
|
+
sentence?: string;
|
|
378
|
+
remedy?: string;
|
|
379
|
+
};
|
|
380
|
+
type WriteHandler = (request: WriteApplyRequest, signal: AbortSignal) => WriteHandlerResult | Promise<WriteHandlerResult>;
|
|
381
|
+
/** Files a `queued` write for an organization's review. */
|
|
382
|
+
interface WriteReviewPort {
|
|
383
|
+
file(request: WriteApplyRequest): Promise<{
|
|
384
|
+
sentence?: string;
|
|
385
|
+
remedy?: string;
|
|
386
|
+
} | void>;
|
|
387
|
+
}
|
|
388
|
+
interface WriteDoor {
|
|
389
|
+
write(request: WriteRequest, signal?: AbortSignal): Promise<Receipt>;
|
|
390
|
+
/** A feature's write handler that works with no page mounted. Refuses a second one for the same target. */
|
|
391
|
+
registerHeadless(surfaceName: string, targetName: string, handler: WriteHandler): () => void;
|
|
392
|
+
/** A mounted page's handler; wins over the headless one while registered. Returns unregister. */
|
|
393
|
+
registerLive(surfaceName: string, targetName: string, handler: WriteHandler): () => void;
|
|
394
|
+
}
|
|
395
|
+
|
|
254
396
|
/**
|
|
255
397
|
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
256
398
|
*
|
|
@@ -282,6 +424,8 @@ interface ActionError {
|
|
|
282
424
|
message: string;
|
|
283
425
|
retryable: boolean;
|
|
284
426
|
diagnostic?: string;
|
|
427
|
+
/** Superset: the one-click remedy a write door refusal names. */
|
|
428
|
+
remedy?: string;
|
|
285
429
|
}
|
|
286
430
|
/** CONTRACTS §0 `Result<T>`. */
|
|
287
431
|
type ActionResult<T = unknown> = {
|
|
@@ -338,7 +482,7 @@ type MandateRunRequest = ({
|
|
|
338
482
|
* PP-01a `window` (host-rendered windows for a live preparation session)
|
|
339
483
|
* PP-13a `transferKnobs` (organization default recipes)
|
|
340
484
|
*
|
|
341
|
-
*
|
|
485
|
+
* ALC-17 `door` (the one write door), `review` (queued writes)
|
|
342
486
|
*
|
|
343
487
|
* ── Absent-port semantics ───────────────────────────────────────────────────
|
|
344
488
|
*
|
|
@@ -374,6 +518,10 @@ type MandateRunRequest = ({
|
|
|
374
518
|
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
375
519
|
* ("needs a person's approval"); a person's own click is the approval
|
|
376
520
|
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
521
|
+
* door absent → write-target Actions dispatch to `pageActions` as before, and
|
|
522
|
+
* `Delivery.send` is refused with a remedy; bound → every such write goes
|
|
523
|
+
* through it and returns its receipt
|
|
524
|
+
* review absent → a write to a `queued` target is refused ("review isn't available here")
|
|
377
525
|
*
|
|
378
526
|
* Types only: this entry has no runtime code.
|
|
379
527
|
*/
|
|
@@ -527,6 +675,10 @@ interface AlchemyHostPorts {
|
|
|
527
675
|
pageActions?: PageActionPort;
|
|
528
676
|
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
529
677
|
approvals?: ApprovalPort;
|
|
678
|
+
/** `createWriteDoor(...)`: every write to a declared target lands here and returns a receipt. */
|
|
679
|
+
door?: WriteDoor;
|
|
680
|
+
/** Files a write to a `queued` target for an organization's review. */
|
|
681
|
+
review?: WriteReviewPort;
|
|
530
682
|
}
|
|
531
683
|
interface ServerActionPort {
|
|
532
684
|
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
|
@@ -251,6 +251,148 @@ interface ClickTarget {
|
|
|
251
251
|
host?: unknown;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Operate — the format and delivery contract (Matrx Alchemy CONTRACT §2.3, ALC-16).
|
|
256
|
+
*
|
|
257
|
+
* A format is an ADAPTER: `supports` is synchronous and loads nothing; `load` dynamically
|
|
258
|
+
* imports the engine the first time the format is chosen (print for rich-html/html/pdf/docx/
|
|
259
|
+
* epub, SheetJS for xlsx). Delivery accepts only a SEALED artifact, so the bytes previewed are
|
|
260
|
+
* the bytes copied, downloaded or sent.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/** A reference to a declared write target (resolved by the one write door, ALC-17). */
|
|
264
|
+
interface WriteTargetRef {
|
|
265
|
+
surfaceName?: string;
|
|
266
|
+
target: string;
|
|
267
|
+
item?: {
|
|
268
|
+
itemType: string;
|
|
269
|
+
identity: Record<string, string>;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Every write returns one (CONTRACT §2.3; the door is `createWriteDoor`, ALC-17). An applied
|
|
274
|
+
* receipt may carry a `warning` with its `fix` (rule 10: a person's kind mismatch warns, never refuses).
|
|
275
|
+
* A refusal's `reason` is a `WriteRefusalReason` (`./door`).
|
|
276
|
+
*/
|
|
277
|
+
type Receipt = {
|
|
278
|
+
status: "applied";
|
|
279
|
+
to: WriteTargetRef;
|
|
280
|
+
sentence: string;
|
|
281
|
+
warning?: string;
|
|
282
|
+
fix?: string;
|
|
283
|
+
} | {
|
|
284
|
+
status: "queued";
|
|
285
|
+
to: WriteTargetRef;
|
|
286
|
+
sentence: string;
|
|
287
|
+
remedy: string;
|
|
288
|
+
} | {
|
|
289
|
+
status: "refused";
|
|
290
|
+
to: WriteTargetRef;
|
|
291
|
+
reason: string;
|
|
292
|
+
sentence: string;
|
|
293
|
+
remedy: string;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* THE ONE WRITE DOOR (Matrx Alchemy ALC-17; Applets CONTRACTS §6 "receipts through the one write door").
|
|
298
|
+
*
|
|
299
|
+
* Every write — a person's edit, a menu row, a destination send, an agent, an applet, an automation,
|
|
300
|
+
* an Action projected from a write target — lands through `door.write`. The door:
|
|
301
|
+
*
|
|
302
|
+
* 1. resolves the DECLARED write target (the surface's own, then its ancestors'); an undeclared
|
|
303
|
+
* target is refused by name;
|
|
304
|
+
* 2. enforces the mode: `stream` takes ops from the target's `streamOps`; ops on any other target
|
|
305
|
+
* need `patchable` (+ `updatesValue`); a value on a `stream` target is refused;
|
|
306
|
+
* 3. checks the kind (rule 10): a person's mismatch WARNS (the receipt is still applied, with a
|
|
307
|
+
* `warning` and a `fix`); an agent's, applet's or automation's malformed write is REFUSED;
|
|
308
|
+
* 4. applies the policy: manual → a person only; ask → a person's own act is the approval, anyone
|
|
309
|
+
* else asks through `approvals`; queued → filed through `review`; auto → applies;
|
|
310
|
+
* 5. applies through the handler: the mounted page's LIVE handler wins over the HEADLESS one;
|
|
311
|
+
* neither → refused `unapplicable` ("open <surface> to apply it");
|
|
312
|
+
* 6. turns stale / missing record / broken protected span into "cannot apply" with a one-click
|
|
313
|
+
* remedy (rule 11).
|
|
314
|
+
*
|
|
315
|
+
* Every outcome is a `Receipt` carrying the system's own sentence. `write` never throws.
|
|
316
|
+
*
|
|
317
|
+
* Who counts as a person: `person`, `menu` and `destination` (a destination send is a person's own
|
|
318
|
+
* click on "Send to …"). `agent`, `applet` and `automation` are not.
|
|
319
|
+
*
|
|
320
|
+
* Open-risk ruling — stream ops into an entity target: an entity write is ONE atomic save. Ops reach
|
|
321
|
+
* an entity target only when it is declared `patchable` (the ops are handed to the handler in one
|
|
322
|
+
* call and commit as one save); a non-patchable entity target refuses ops with the remedy "stream
|
|
323
|
+
* into the editor, then save". Op-by-op persistence into a record does not exist.
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
/** Who is writing. `menu` and `destination` are a person's own act. */
|
|
327
|
+
type WriteCaller = "person" | "agent" | "applet" | "automation" | "destination" | "menu";
|
|
328
|
+
/** One text op for a `stream` (or `patchable`) target — the WidgetHandle op set. */
|
|
329
|
+
interface WriteOp {
|
|
330
|
+
op: StreamOp;
|
|
331
|
+
/** The text the op inserts or replaces with. */
|
|
332
|
+
text?: string;
|
|
333
|
+
/** What `replace` / `insert_before` / `insert_after` / `patch` anchor on. */
|
|
334
|
+
find?: string;
|
|
335
|
+
}
|
|
336
|
+
interface WriteRequest {
|
|
337
|
+
surfaceName: string;
|
|
338
|
+
/** A write target name; `"<itemType>.<name>"` names an item's target. */
|
|
339
|
+
target: string;
|
|
340
|
+
itemType?: string;
|
|
341
|
+
/** Which item, by its declared identity values. Required for an item target. */
|
|
342
|
+
itemIdentity?: Record<string, string>;
|
|
343
|
+
/** A whole value. Exactly one of `value` / `ops`. */
|
|
344
|
+
value?: unknown;
|
|
345
|
+
/** Text ops (stream / patchable targets). */
|
|
346
|
+
ops?: readonly WriteOp[];
|
|
347
|
+
by: WriteCaller;
|
|
348
|
+
runId?: string;
|
|
349
|
+
}
|
|
350
|
+
/** What a handler receives: the request plus the declared target it resolved to. */
|
|
351
|
+
interface WriteApplyRequest {
|
|
352
|
+
surfaceName: string;
|
|
353
|
+
/** The surface that declares the target (an ancestor when inherited). */
|
|
354
|
+
declaredOn: string;
|
|
355
|
+
target: WriteTarget;
|
|
356
|
+
item?: {
|
|
357
|
+
itemType: string;
|
|
358
|
+
identity: Record<string, string>;
|
|
359
|
+
};
|
|
360
|
+
value?: unknown;
|
|
361
|
+
ops?: readonly WriteOp[];
|
|
362
|
+
by: WriteCaller;
|
|
363
|
+
runId?: string;
|
|
364
|
+
}
|
|
365
|
+
/** Rule 11: the three "cannot apply" signals. */
|
|
366
|
+
type CannotApply = "stale" | "missing-record" | "broken-span";
|
|
367
|
+
/**
|
|
368
|
+
* A handler applies the write. Return nothing (or `{ status: "applied" }`) when it landed, or a
|
|
369
|
+
* `cannotApply` signal; THROWING an error whose `code` is a `CannotApply` signal means the same.
|
|
370
|
+
*/
|
|
371
|
+
type WriteHandlerResult = void | {
|
|
372
|
+
status: "applied";
|
|
373
|
+
sentence?: string;
|
|
374
|
+
} | {
|
|
375
|
+
status: "cannot-apply";
|
|
376
|
+
cannotApply: CannotApply;
|
|
377
|
+
sentence?: string;
|
|
378
|
+
remedy?: string;
|
|
379
|
+
};
|
|
380
|
+
type WriteHandler = (request: WriteApplyRequest, signal: AbortSignal) => WriteHandlerResult | Promise<WriteHandlerResult>;
|
|
381
|
+
/** Files a `queued` write for an organization's review. */
|
|
382
|
+
interface WriteReviewPort {
|
|
383
|
+
file(request: WriteApplyRequest): Promise<{
|
|
384
|
+
sentence?: string;
|
|
385
|
+
remedy?: string;
|
|
386
|
+
} | void>;
|
|
387
|
+
}
|
|
388
|
+
interface WriteDoor {
|
|
389
|
+
write(request: WriteRequest, signal?: AbortSignal): Promise<Receipt>;
|
|
390
|
+
/** A feature's write handler that works with no page mounted. Refuses a second one for the same target. */
|
|
391
|
+
registerHeadless(surfaceName: string, targetName: string, handler: WriteHandler): () => void;
|
|
392
|
+
/** A mounted page's handler; wins over the headless one while registered. Returns unregister. */
|
|
393
|
+
registerLive(surfaceName: string, targetName: string, handler: WriteHandler): () => void;
|
|
394
|
+
}
|
|
395
|
+
|
|
254
396
|
/**
|
|
255
397
|
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
256
398
|
*
|
|
@@ -282,6 +424,8 @@ interface ActionError {
|
|
|
282
424
|
message: string;
|
|
283
425
|
retryable: boolean;
|
|
284
426
|
diagnostic?: string;
|
|
427
|
+
/** Superset: the one-click remedy a write door refusal names. */
|
|
428
|
+
remedy?: string;
|
|
285
429
|
}
|
|
286
430
|
/** CONTRACTS §0 `Result<T>`. */
|
|
287
431
|
type ActionResult<T = unknown> = {
|
|
@@ -338,7 +482,7 @@ type MandateRunRequest = ({
|
|
|
338
482
|
* PP-01a `window` (host-rendered windows for a live preparation session)
|
|
339
483
|
* PP-13a `transferKnobs` (organization default recipes)
|
|
340
484
|
*
|
|
341
|
-
*
|
|
485
|
+
* ALC-17 `door` (the one write door), `review` (queued writes)
|
|
342
486
|
*
|
|
343
487
|
* ── Absent-port semantics ───────────────────────────────────────────────────
|
|
344
488
|
*
|
|
@@ -374,6 +518,10 @@ type MandateRunRequest = ({
|
|
|
374
518
|
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
375
519
|
* ("needs a person's approval"); a person's own click is the approval
|
|
376
520
|
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
521
|
+
* door absent → write-target Actions dispatch to `pageActions` as before, and
|
|
522
|
+
* `Delivery.send` is refused with a remedy; bound → every such write goes
|
|
523
|
+
* through it and returns its receipt
|
|
524
|
+
* review absent → a write to a `queued` target is refused ("review isn't available here")
|
|
377
525
|
*
|
|
378
526
|
* Types only: this entry has no runtime code.
|
|
379
527
|
*/
|
|
@@ -527,6 +675,10 @@ interface AlchemyHostPorts {
|
|
|
527
675
|
pageActions?: PageActionPort;
|
|
528
676
|
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
529
677
|
approvals?: ApprovalPort;
|
|
678
|
+
/** `createWriteDoor(...)`: every write to a declared target lands here and returns a receipt. */
|
|
679
|
+
door?: WriteDoor;
|
|
680
|
+
/** Files a write to a `queued` target for an organization's review. */
|
|
681
|
+
review?: WriteReviewPort;
|
|
530
682
|
}
|
|
531
683
|
interface ServerActionPort {
|
|
532
684
|
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
package/dist/react-overflow.d.ts
CHANGED
|
@@ -251,6 +251,148 @@ interface ClickTarget {
|
|
|
251
251
|
host?: unknown;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Operate — the format and delivery contract (Matrx Alchemy CONTRACT §2.3, ALC-16).
|
|
256
|
+
*
|
|
257
|
+
* A format is an ADAPTER: `supports` is synchronous and loads nothing; `load` dynamically
|
|
258
|
+
* imports the engine the first time the format is chosen (print for rich-html/html/pdf/docx/
|
|
259
|
+
* epub, SheetJS for xlsx). Delivery accepts only a SEALED artifact, so the bytes previewed are
|
|
260
|
+
* the bytes copied, downloaded or sent.
|
|
261
|
+
*/
|
|
262
|
+
|
|
263
|
+
/** A reference to a declared write target (resolved by the one write door, ALC-17). */
|
|
264
|
+
interface WriteTargetRef {
|
|
265
|
+
surfaceName?: string;
|
|
266
|
+
target: string;
|
|
267
|
+
item?: {
|
|
268
|
+
itemType: string;
|
|
269
|
+
identity: Record<string, string>;
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Every write returns one (CONTRACT §2.3; the door is `createWriteDoor`, ALC-17). An applied
|
|
274
|
+
* receipt may carry a `warning` with its `fix` (rule 10: a person's kind mismatch warns, never refuses).
|
|
275
|
+
* A refusal's `reason` is a `WriteRefusalReason` (`./door`).
|
|
276
|
+
*/
|
|
277
|
+
type Receipt = {
|
|
278
|
+
status: "applied";
|
|
279
|
+
to: WriteTargetRef;
|
|
280
|
+
sentence: string;
|
|
281
|
+
warning?: string;
|
|
282
|
+
fix?: string;
|
|
283
|
+
} | {
|
|
284
|
+
status: "queued";
|
|
285
|
+
to: WriteTargetRef;
|
|
286
|
+
sentence: string;
|
|
287
|
+
remedy: string;
|
|
288
|
+
} | {
|
|
289
|
+
status: "refused";
|
|
290
|
+
to: WriteTargetRef;
|
|
291
|
+
reason: string;
|
|
292
|
+
sentence: string;
|
|
293
|
+
remedy: string;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* THE ONE WRITE DOOR (Matrx Alchemy ALC-17; Applets CONTRACTS §6 "receipts through the one write door").
|
|
298
|
+
*
|
|
299
|
+
* Every write — a person's edit, a menu row, a destination send, an agent, an applet, an automation,
|
|
300
|
+
* an Action projected from a write target — lands through `door.write`. The door:
|
|
301
|
+
*
|
|
302
|
+
* 1. resolves the DECLARED write target (the surface's own, then its ancestors'); an undeclared
|
|
303
|
+
* target is refused by name;
|
|
304
|
+
* 2. enforces the mode: `stream` takes ops from the target's `streamOps`; ops on any other target
|
|
305
|
+
* need `patchable` (+ `updatesValue`); a value on a `stream` target is refused;
|
|
306
|
+
* 3. checks the kind (rule 10): a person's mismatch WARNS (the receipt is still applied, with a
|
|
307
|
+
* `warning` and a `fix`); an agent's, applet's or automation's malformed write is REFUSED;
|
|
308
|
+
* 4. applies the policy: manual → a person only; ask → a person's own act is the approval, anyone
|
|
309
|
+
* else asks through `approvals`; queued → filed through `review`; auto → applies;
|
|
310
|
+
* 5. applies through the handler: the mounted page's LIVE handler wins over the HEADLESS one;
|
|
311
|
+
* neither → refused `unapplicable` ("open <surface> to apply it");
|
|
312
|
+
* 6. turns stale / missing record / broken protected span into "cannot apply" with a one-click
|
|
313
|
+
* remedy (rule 11).
|
|
314
|
+
*
|
|
315
|
+
* Every outcome is a `Receipt` carrying the system's own sentence. `write` never throws.
|
|
316
|
+
*
|
|
317
|
+
* Who counts as a person: `person`, `menu` and `destination` (a destination send is a person's own
|
|
318
|
+
* click on "Send to …"). `agent`, `applet` and `automation` are not.
|
|
319
|
+
*
|
|
320
|
+
* Open-risk ruling — stream ops into an entity target: an entity write is ONE atomic save. Ops reach
|
|
321
|
+
* an entity target only when it is declared `patchable` (the ops are handed to the handler in one
|
|
322
|
+
* call and commit as one save); a non-patchable entity target refuses ops with the remedy "stream
|
|
323
|
+
* into the editor, then save". Op-by-op persistence into a record does not exist.
|
|
324
|
+
*/
|
|
325
|
+
|
|
326
|
+
/** Who is writing. `menu` and `destination` are a person's own act. */
|
|
327
|
+
type WriteCaller = "person" | "agent" | "applet" | "automation" | "destination" | "menu";
|
|
328
|
+
/** One text op for a `stream` (or `patchable`) target — the WidgetHandle op set. */
|
|
329
|
+
interface WriteOp {
|
|
330
|
+
op: StreamOp;
|
|
331
|
+
/** The text the op inserts or replaces with. */
|
|
332
|
+
text?: string;
|
|
333
|
+
/** What `replace` / `insert_before` / `insert_after` / `patch` anchor on. */
|
|
334
|
+
find?: string;
|
|
335
|
+
}
|
|
336
|
+
interface WriteRequest {
|
|
337
|
+
surfaceName: string;
|
|
338
|
+
/** A write target name; `"<itemType>.<name>"` names an item's target. */
|
|
339
|
+
target: string;
|
|
340
|
+
itemType?: string;
|
|
341
|
+
/** Which item, by its declared identity values. Required for an item target. */
|
|
342
|
+
itemIdentity?: Record<string, string>;
|
|
343
|
+
/** A whole value. Exactly one of `value` / `ops`. */
|
|
344
|
+
value?: unknown;
|
|
345
|
+
/** Text ops (stream / patchable targets). */
|
|
346
|
+
ops?: readonly WriteOp[];
|
|
347
|
+
by: WriteCaller;
|
|
348
|
+
runId?: string;
|
|
349
|
+
}
|
|
350
|
+
/** What a handler receives: the request plus the declared target it resolved to. */
|
|
351
|
+
interface WriteApplyRequest {
|
|
352
|
+
surfaceName: string;
|
|
353
|
+
/** The surface that declares the target (an ancestor when inherited). */
|
|
354
|
+
declaredOn: string;
|
|
355
|
+
target: WriteTarget;
|
|
356
|
+
item?: {
|
|
357
|
+
itemType: string;
|
|
358
|
+
identity: Record<string, string>;
|
|
359
|
+
};
|
|
360
|
+
value?: unknown;
|
|
361
|
+
ops?: readonly WriteOp[];
|
|
362
|
+
by: WriteCaller;
|
|
363
|
+
runId?: string;
|
|
364
|
+
}
|
|
365
|
+
/** Rule 11: the three "cannot apply" signals. */
|
|
366
|
+
type CannotApply = "stale" | "missing-record" | "broken-span";
|
|
367
|
+
/**
|
|
368
|
+
* A handler applies the write. Return nothing (or `{ status: "applied" }`) when it landed, or a
|
|
369
|
+
* `cannotApply` signal; THROWING an error whose `code` is a `CannotApply` signal means the same.
|
|
370
|
+
*/
|
|
371
|
+
type WriteHandlerResult = void | {
|
|
372
|
+
status: "applied";
|
|
373
|
+
sentence?: string;
|
|
374
|
+
} | {
|
|
375
|
+
status: "cannot-apply";
|
|
376
|
+
cannotApply: CannotApply;
|
|
377
|
+
sentence?: string;
|
|
378
|
+
remedy?: string;
|
|
379
|
+
};
|
|
380
|
+
type WriteHandler = (request: WriteApplyRequest, signal: AbortSignal) => WriteHandlerResult | Promise<WriteHandlerResult>;
|
|
381
|
+
/** Files a `queued` write for an organization's review. */
|
|
382
|
+
interface WriteReviewPort {
|
|
383
|
+
file(request: WriteApplyRequest): Promise<{
|
|
384
|
+
sentence?: string;
|
|
385
|
+
remedy?: string;
|
|
386
|
+
} | void>;
|
|
387
|
+
}
|
|
388
|
+
interface WriteDoor {
|
|
389
|
+
write(request: WriteRequest, signal?: AbortSignal): Promise<Receipt>;
|
|
390
|
+
/** A feature's write handler that works with no page mounted. Refuses a second one for the same target. */
|
|
391
|
+
registerHeadless(surfaceName: string, targetName: string, handler: WriteHandler): () => void;
|
|
392
|
+
/** A mounted page's handler; wins over the headless one while registered. Returns unregister. */
|
|
393
|
+
registerLive(surfaceName: string, targetName: string, handler: WriteHandler): () => void;
|
|
394
|
+
}
|
|
395
|
+
|
|
254
396
|
/**
|
|
255
397
|
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
256
398
|
*
|
|
@@ -282,6 +424,8 @@ interface ActionError {
|
|
|
282
424
|
message: string;
|
|
283
425
|
retryable: boolean;
|
|
284
426
|
diagnostic?: string;
|
|
427
|
+
/** Superset: the one-click remedy a write door refusal names. */
|
|
428
|
+
remedy?: string;
|
|
285
429
|
}
|
|
286
430
|
/** CONTRACTS §0 `Result<T>`. */
|
|
287
431
|
type ActionResult<T = unknown> = {
|
|
@@ -338,7 +482,7 @@ type MandateRunRequest = ({
|
|
|
338
482
|
* PP-01a `window` (host-rendered windows for a live preparation session)
|
|
339
483
|
* PP-13a `transferKnobs` (organization default recipes)
|
|
340
484
|
*
|
|
341
|
-
*
|
|
485
|
+
* ALC-17 `door` (the one write door), `review` (queued writes)
|
|
342
486
|
*
|
|
343
487
|
* ── Absent-port semantics ───────────────────────────────────────────────────
|
|
344
488
|
*
|
|
@@ -374,6 +518,10 @@ type MandateRunRequest = ({
|
|
|
374
518
|
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
375
519
|
* ("needs a person's approval"); a person's own click is the approval
|
|
376
520
|
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
521
|
+
* door absent → write-target Actions dispatch to `pageActions` as before, and
|
|
522
|
+
* `Delivery.send` is refused with a remedy; bound → every such write goes
|
|
523
|
+
* through it and returns its receipt
|
|
524
|
+
* review absent → a write to a `queued` target is refused ("review isn't available here")
|
|
377
525
|
*
|
|
378
526
|
* Types only: this entry has no runtime code.
|
|
379
527
|
*/
|
|
@@ -527,6 +675,10 @@ interface AlchemyHostPorts {
|
|
|
527
675
|
pageActions?: PageActionPort;
|
|
528
676
|
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
529
677
|
approvals?: ApprovalPort;
|
|
678
|
+
/** `createWriteDoor(...)`: every write to a declared target lands here and returns a receipt. */
|
|
679
|
+
door?: WriteDoor;
|
|
680
|
+
/** Files a write to a `queued` target for an organization's review. */
|
|
681
|
+
review?: WriteReviewPort;
|
|
530
682
|
}
|
|
531
683
|
interface ServerActionPort {
|
|
532
684
|
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/alchemy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Matrx Alchemy: the complete Matrx copy, prepare-for-AI, and export experience, with framework-neutral core, React menu, glyph and styles; Declare (what a screen holds: types, registry, validation, JSON schema) and the one surface sync; Actions (the one action registry: eligibility, duplicate refusal, projected reads) and the one menu engine (model + bar, overflow, context, selection, sheet and palette layouts as per-layout React subpaths).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|