@ai-matrx/alchemy 0.8.59 → 0.9.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 +36 -0
- package/README.md +2 -0
- package/dist/actions.cjs +1 -1
- package/dist/actions.cjs.map +1 -1
- package/dist/actions.d.cts +300 -3
- package/dist/actions.d.ts +300 -3
- package/dist/actions.js +1 -1
- package/dist/actions.js.map +1 -1
- package/dist/checks.cjs +1 -1
- package/dist/checks.cjs.map +1 -1
- package/dist/checks.d.cts +22 -1
- package/dist/checks.d.ts +22 -1
- package/dist/checks.js +2 -2
- package/dist/checks.js.map +1 -1
- package/dist/core.d.cts +141 -26
- package/dist/core.d.ts +141 -26
- package/dist/declare.cjs +1 -1
- package/dist/declare.cjs.map +1 -1
- package/dist/declare.d.cts +12 -4
- package/dist/declare.d.ts +12 -4
- package/dist/declare.js +1 -1
- package/dist/declare.js.map +1 -1
- package/dist/index.d.cts +141 -26
- package/dist/index.d.ts +141 -26
- package/dist/menu.cjs +1 -1
- package/dist/menu.cjs.map +1 -1
- package/dist/menu.d.cts +109 -2
- package/dist/menu.d.ts +109 -2
- package/dist/menu.js +1 -1
- package/dist/menu.js.map +1 -1
- package/dist/operate-server.d.cts +6 -0
- package/dist/operate-server.d.ts +6 -0
- package/dist/operate.d.cts +141 -26
- package/dist/operate.d.ts +141 -26
- package/dist/ports.cjs.map +1 -1
- package/dist/ports.d.cts +116 -1
- package/dist/ports.d.ts +116 -1
- package/dist/react-bar.cjs +2 -2
- package/dist/react-bar.cjs.map +1 -1
- package/dist/react-bar.d.cts +4 -2
- package/dist/react-bar.d.ts +4 -2
- package/dist/react-bar.js +2 -2
- package/dist/react-bar.js.map +1 -1
- package/dist/react-host.d.cts +124 -3
- package/dist/react-host.d.ts +124 -3
- package/dist/react-menu.cjs +2 -2
- package/dist/react-menu.cjs.map +1 -1
- package/dist/react-menu.d.cts +20 -4
- package/dist/react-menu.d.ts +20 -4
- package/dist/react-menu.js +2 -2
- package/dist/react-menu.js.map +1 -1
- package/dist/react-overflow.cjs +2 -2
- package/dist/react-overflow.cjs.map +1 -1
- package/dist/react-overflow.d.cts +109 -2
- package/dist/react-overflow.d.ts +109 -2
- package/dist/react-overflow.js +2 -2
- package/dist/react-overflow.js.map +1 -1
- package/dist/react-palette.cjs +1 -1
- package/dist/react-palette.cjs.map +1 -1
- package/dist/react-palette.d.cts +4 -2
- package/dist/react-palette.d.ts +4 -2
- package/dist/react-palette.js +1 -1
- package/dist/react-palette.js.map +1 -1
- package/dist/react-selection.cjs +2 -2
- package/dist/react-selection.cjs.map +1 -1
- package/dist/react-selection.d.cts +4 -2
- package/dist/react-selection.d.ts +4 -2
- package/dist/react-selection.js +2 -2
- package/dist/react-selection.js.map +1 -1
- package/dist/react-sheet.cjs +2 -2
- package/dist/react-sheet.cjs.map +1 -1
- package/dist/react-sheet.d.cts +4 -2
- package/dist/react-sheet.d.ts +4 -2
- package/dist/react-sheet.js +2 -2
- package/dist/react-sheet.js.map +1 -1
- package/package.json +3 -3
package/dist/operate.d.cts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Framework-neutral transfer contracts (Alchemy Operate, CONTRACT §2.3). All data crossing this boundary is JSON.
|
|
3
3
|
* Moved from `@ai-matrx/kit/content-transfer` in ALC-16; the format-adapter contract lives in `./contract`.
|
|
4
4
|
*/
|
|
5
|
-
type Json$
|
|
6
|
-
[key: string]: Json$
|
|
5
|
+
type Json$2 = null | boolean | number | string | Json$2[] | {
|
|
6
|
+
[key: string]: Json$2;
|
|
7
7
|
};
|
|
8
8
|
type Payload =
|
|
9
9
|
/** A text payload may name its language (code blocks): downloads take its extension, Markdown fences it. */
|
|
@@ -16,15 +16,15 @@ type Payload =
|
|
|
16
16
|
text: string;
|
|
17
17
|
} | {
|
|
18
18
|
kind: "json";
|
|
19
|
-
value: Json$
|
|
19
|
+
value: Json$2;
|
|
20
20
|
} | {
|
|
21
21
|
kind: "rows";
|
|
22
|
-
rows: Record<string, Json$
|
|
22
|
+
rows: Record<string, Json$2>[];
|
|
23
23
|
columns: Column[];
|
|
24
24
|
} | {
|
|
25
25
|
kind: "registered";
|
|
26
26
|
format: string;
|
|
27
|
-
value: Json$
|
|
27
|
+
value: Json$2;
|
|
28
28
|
};
|
|
29
29
|
type Column = {
|
|
30
30
|
id: string;
|
|
@@ -38,9 +38,9 @@ type Column = {
|
|
|
38
38
|
dataType?: string;
|
|
39
39
|
order?: number;
|
|
40
40
|
required?: boolean;
|
|
41
|
-
defaultValue?: Json$
|
|
42
|
-
validation?: Json$
|
|
43
|
-
metadata?: Json$
|
|
41
|
+
defaultValue?: Json$2;
|
|
42
|
+
validation?: Json$2;
|
|
43
|
+
metadata?: Json$2;
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
type ExportProjection = {
|
|
@@ -93,21 +93,21 @@ type Snapshot = RawSnapshot & {
|
|
|
93
93
|
type QuerySnapshot = {
|
|
94
94
|
sourceId: string;
|
|
95
95
|
revision: string;
|
|
96
|
-
query: Json$
|
|
96
|
+
query: Json$2;
|
|
97
97
|
order: {
|
|
98
98
|
field: string;
|
|
99
99
|
direction: "asc" | "desc";
|
|
100
100
|
}[];
|
|
101
101
|
};
|
|
102
102
|
type ExportPage = {
|
|
103
|
-
rows: Record<string, Json$
|
|
103
|
+
rows: Record<string, Json$2>[];
|
|
104
104
|
nextCursor: string | null;
|
|
105
105
|
coverage: Coverage;
|
|
106
106
|
consistencyToken: string | null;
|
|
107
107
|
};
|
|
108
108
|
type CapturedAllMatching = {
|
|
109
109
|
query: QuerySnapshot;
|
|
110
|
-
getRowId(row: Record<string, Json$
|
|
110
|
+
getRowId(row: Record<string, Json$2>): string;
|
|
111
111
|
page(request: {
|
|
112
112
|
query: QuerySnapshot;
|
|
113
113
|
cursor: string | null;
|
|
@@ -147,7 +147,7 @@ type Draft = {
|
|
|
147
147
|
};
|
|
148
148
|
type Transform = {
|
|
149
149
|
id: string;
|
|
150
|
-
apply(draft: Draft, options: Json$
|
|
150
|
+
apply(draft: Draft, options: Json$2, signal: AbortSignal): Promise<Draft>;
|
|
151
151
|
};
|
|
152
152
|
type Artifact = {
|
|
153
153
|
snapshotId: string;
|
|
@@ -338,9 +338,9 @@ type BoundAllMatching = {
|
|
|
338
338
|
type NormalizeTransferJsonOptions = {
|
|
339
339
|
omitUndefinedObjectProperties?: boolean;
|
|
340
340
|
};
|
|
341
|
-
declare function normalizeTransferJson(value: unknown, options?: NormalizeTransferJsonOptions): Json$
|
|
341
|
+
declare function normalizeTransferJson(value: unknown, options?: NormalizeTransferJsonOptions): Json$2;
|
|
342
342
|
/** Column ids are identities, never an alternative data address. */
|
|
343
|
-
declare function readTransferCell(row: Record<string, Json$
|
|
343
|
+
declare function readTransferCell(row: Record<string, Json$2>, column: Column): Json$2 | undefined;
|
|
344
344
|
declare function projectSnapshot(raw: RawSnapshot, projection: ExportProjection): Snapshot;
|
|
345
345
|
declare function directSource(payload: Payload, options?: Partial<Pick<RawSnapshot, "id" | "sourceId" | "revision" | "label" | "coverage" | "unsavedChanges" | "sections" | "limits"> & {
|
|
346
346
|
projection: ExportProjection;
|
|
@@ -385,7 +385,7 @@ declare function reduceJson(draft: Draft, options: {
|
|
|
385
385
|
maxArrayItems?: number | null;
|
|
386
386
|
}): Draft;
|
|
387
387
|
declare function collectAllMatching(c: BoundAllMatching, signal: AbortSignal): Promise<{
|
|
388
|
-
rows: Record<string, Json$
|
|
388
|
+
rows: Record<string, Json$2>[];
|
|
389
389
|
coverage: RawSnapshot["coverage"];
|
|
390
390
|
omissions: Omission[];
|
|
391
391
|
error?: ContentTransferError;
|
|
@@ -433,6 +433,16 @@ declare function createSurfaceTransferHandle(options: {
|
|
|
433
433
|
/** Applies explicit preparation/source limits with exact omissions; token target is advisory. */
|
|
434
434
|
declare function applyTransferLimits(draft: Draft, limits: Partial<TransferLimits>): Draft;
|
|
435
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Matrx Alchemy — Declare types (CONTRACT §2.1).
|
|
438
|
+
*
|
|
439
|
+
* A declaration is plain JSON data (chair ruling N2): no functions, no classes,
|
|
440
|
+
* no React. Runtime behaviour lives in `MountedSurface` (`/declare/host`) and in
|
|
441
|
+
* handler registrations, never here. Zero React, zero `@ai-matrx/agents`.
|
|
442
|
+
*/
|
|
443
|
+
type Json$1 = null | boolean | number | string | Json$1[] | {
|
|
444
|
+
[key: string]: Json$1;
|
|
445
|
+
};
|
|
436
446
|
/** Unchanged from `ui_surface_value_type_chk`. */
|
|
437
447
|
type ValueType = "string" | "number" | "boolean" | "object" | "array" | "document";
|
|
438
448
|
type Classification = "ordinary" | "secret" | "credential";
|
|
@@ -639,6 +649,75 @@ interface ClickTarget {
|
|
|
639
649
|
host?: unknown;
|
|
640
650
|
}
|
|
641
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
654
|
+
*
|
|
655
|
+
* An Action is one thing a surface can have done to it, by a person, an agent,
|
|
656
|
+
* an applet or an automation: a write target, a client tool, a Kind Action or a
|
|
657
|
+
* row in `ui.ui_surface_action`. All of them project onto `ActionDeclaration`
|
|
658
|
+
* (`./declarations.ts`) and run through ONE runner (`./surface-run.ts`). There is
|
|
659
|
+
* never a second registry: `name` IS the alchemy action id, and `category`
|
|
660
|
+
* defaults to "applet" in alchemy's closed `ActionCategory` union.
|
|
661
|
+
*
|
|
662
|
+
* Types only — no runtime code, no React, no `@ai-matrx/agents`. `/ports`
|
|
663
|
+
* imports from here, so this file imports nothing but local types.
|
|
664
|
+
*/
|
|
665
|
+
|
|
666
|
+
/** Who started a run. */
|
|
667
|
+
type ActionCaller = "person" | "agent" | "applet" | "automation";
|
|
668
|
+
/** Who may run it without a click: "manual" = only a person; "ask" = proposed first; "auto" = runs. */
|
|
669
|
+
type ActionPolicy = "ask" | "auto" | "manual";
|
|
670
|
+
interface ActionContext {
|
|
671
|
+
runId: string;
|
|
672
|
+
by: ActionCaller;
|
|
673
|
+
viewerId: string | null;
|
|
674
|
+
surfaceName?: string;
|
|
675
|
+
policy?: ActionPolicy;
|
|
676
|
+
}
|
|
677
|
+
/** The system's own sentence, never thrown into a UI. Superset of RecordsError (CONTRACTS §0 `AppletError`). */
|
|
678
|
+
interface ActionError {
|
|
679
|
+
code: string;
|
|
680
|
+
message: string;
|
|
681
|
+
retryable: boolean;
|
|
682
|
+
diagnostic?: string;
|
|
683
|
+
}
|
|
684
|
+
/** CONTRACTS §0 `Result<T>`. */
|
|
685
|
+
type ActionResult<T = unknown> = {
|
|
686
|
+
ok: true;
|
|
687
|
+
data: T;
|
|
688
|
+
} | {
|
|
689
|
+
ok: false;
|
|
690
|
+
error: ActionError;
|
|
691
|
+
};
|
|
692
|
+
/** `POST /actions/run` (aidream) — the request. */
|
|
693
|
+
interface ServerActionRunRequest {
|
|
694
|
+
name: string;
|
|
695
|
+
input: Json$1;
|
|
696
|
+
by: ActionCaller;
|
|
697
|
+
surface_name?: string;
|
|
698
|
+
policy?: ActionPolicy;
|
|
699
|
+
}
|
|
700
|
+
/** `POST /actions/run` (aidream) — the response. */
|
|
701
|
+
interface ServerActionRunResponse {
|
|
702
|
+
status: "applied" | "proposed" | "refused";
|
|
703
|
+
message: string;
|
|
704
|
+
receipts: Json$1[];
|
|
705
|
+
proposal?: Json$1;
|
|
706
|
+
}
|
|
707
|
+
/** A mandate run request: by alias (an Action's `target`) or by key. */
|
|
708
|
+
type MandateRunRequest = ({
|
|
709
|
+
alias: string;
|
|
710
|
+
key?: never;
|
|
711
|
+
} | {
|
|
712
|
+
key: string;
|
|
713
|
+
alias?: never;
|
|
714
|
+
}) & {
|
|
715
|
+
variables: Record<string, Json$1>;
|
|
716
|
+
userInput?: string;
|
|
717
|
+
by: ActionCaller;
|
|
718
|
+
policy: ActionPolicy;
|
|
719
|
+
};
|
|
720
|
+
|
|
642
721
|
/**
|
|
643
722
|
* `@ai-matrx/alchemy/ports` — the host ports (Matrx Alchemy CONTRACT §2.2).
|
|
644
723
|
*
|
|
@@ -687,6 +766,12 @@ interface ClickTarget {
|
|
|
687
766
|
* to an overlay carrying the session as data)
|
|
688
767
|
* transferKnobs absent → no organization default recipe; a person's own
|
|
689
768
|
* default (persistence) or the package's Full applies
|
|
769
|
+
* serverActions absent → `runs: "server"` Actions refuse with "not available here"
|
|
770
|
+
* mandates absent → `runs: "mandate"` Actions refuse the same way
|
|
771
|
+
* pageActions absent → `runs: "page"` Actions refuse the same way
|
|
772
|
+
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
773
|
+
* ("needs a person's approval"); a person's own click is the approval
|
|
774
|
+
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
690
775
|
*
|
|
691
776
|
* Types only: this entry has no runtime code.
|
|
692
777
|
*/
|
|
@@ -832,6 +917,36 @@ interface AlchemyHostPorts {
|
|
|
832
917
|
window?: WindowPort;
|
|
833
918
|
/** Organization default recipes, resolved by the host's Feature Knob ladder (platform → organization). */
|
|
834
919
|
transferKnobs?: TransferKnobsPort;
|
|
920
|
+
/** aidream `POST /actions/run`: a registered server action by name, as the caller, under the apply-policy cascade. */
|
|
921
|
+
serverActions?: ServerActionPort;
|
|
922
|
+
/** Runs a mandate by alias or key (the host binds `@ai-matrx/agents`; alchemy never imports it). */
|
|
923
|
+
mandates?: MandatePort;
|
|
924
|
+
/** The page's own handlers for `runs: "page"` Actions (in an applet frame: routed as `{ action, input, runId }`). */
|
|
925
|
+
pageActions?: PageActionPort;
|
|
926
|
+
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
927
|
+
approvals?: ApprovalPort;
|
|
928
|
+
}
|
|
929
|
+
interface ServerActionPort {
|
|
930
|
+
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
|
931
|
+
}
|
|
932
|
+
interface MandatePort {
|
|
933
|
+
/** Resolves with the run's result (a kind envelope or JSON); rejects with the system's sentence. */
|
|
934
|
+
run(request: MandateRunRequest): Promise<unknown>;
|
|
935
|
+
}
|
|
936
|
+
interface ApprovalRequest {
|
|
937
|
+
action: string;
|
|
938
|
+
label: string;
|
|
939
|
+
description: string;
|
|
940
|
+
input: Json;
|
|
941
|
+
by: "agent" | "applet" | "automation";
|
|
942
|
+
surfaceName: string;
|
|
943
|
+
}
|
|
944
|
+
interface ApprovalPort {
|
|
945
|
+
/** Resolves true when the person approves; false when they decline or dismiss. */
|
|
946
|
+
ask(request: ApprovalRequest): Promise<boolean>;
|
|
947
|
+
}
|
|
948
|
+
interface PageActionPort {
|
|
949
|
+
dispatch(name: string, input: unknown, context: ActionContext): Promise<ActionResult<unknown>>;
|
|
835
950
|
}
|
|
836
951
|
/**
|
|
837
952
|
* Why a port and not `OverlayHostPort`: an overlay's `data` is `Json`, and a live preparation
|
|
@@ -983,7 +1098,7 @@ type TransferOperation = {
|
|
|
983
1098
|
} | {
|
|
984
1099
|
kind: "transform";
|
|
985
1100
|
transform: string;
|
|
986
|
-
options?: Json$
|
|
1101
|
+
options?: Json$2;
|
|
987
1102
|
} | {
|
|
988
1103
|
kind: "prepare-for-ai";
|
|
989
1104
|
instruction?: string;
|
|
@@ -1028,7 +1143,7 @@ interface ServerOperation {
|
|
|
1028
1143
|
statement: string;
|
|
1029
1144
|
supports(payload: Payload): boolean;
|
|
1030
1145
|
/** Projected draft only; sensitivity already applied. */
|
|
1031
|
-
toInput(draft: Draft): Json$
|
|
1146
|
+
toInput(draft: Draft): Json$2;
|
|
1032
1147
|
}
|
|
1033
1148
|
/** Delivery results: `copy` and `download` only ever deliver, degrade, cancel or fail (CONTRACT R16). */
|
|
1034
1149
|
type DeliveryOutcome = Extract<TransferOutcome, {
|
|
@@ -1110,7 +1225,7 @@ interface PreparationSession {
|
|
|
1110
1225
|
readonly snapshot: Snapshot;
|
|
1111
1226
|
readonly draft: Draft;
|
|
1112
1227
|
/** Deterministic transform, AI preparation or any registered transform — bumps draft.revision. */
|
|
1113
|
-
transform(id: string, options: Json$
|
|
1228
|
+
transform(id: string, options: Json$2, signal: AbortSignal): Promise<Draft>;
|
|
1114
1229
|
/** A manual edit. */
|
|
1115
1230
|
edit(payload: Payload): Draft;
|
|
1116
1231
|
/** Keep only these sections (ids from the snapshot). */
|
|
@@ -1228,19 +1343,19 @@ declare function patternBelow(pattern: string, pointer: string): boolean;
|
|
|
1228
1343
|
/** The path a person reads and copies: `/messages/*\/metadata` → `data.messages[*].metadata`. */
|
|
1229
1344
|
declare function displayPath(pointer: string, root?: string): string;
|
|
1230
1345
|
/** Exactly `JSON.stringify(value).length`, computed once per object (large sources stay cheap). */
|
|
1231
|
-
declare function jsonSize(value: Json$
|
|
1346
|
+
declare function jsonSize(value: Json$2): number;
|
|
1232
1347
|
/** The size a person expects for a node: a string's own length, else its JSON. */
|
|
1233
|
-
declare function nodeChars(value: Json$
|
|
1348
|
+
declare function nodeChars(value: Json$2): number;
|
|
1234
1349
|
/**
|
|
1235
1350
|
* The one-line stub that stands in for a node: its header (a string's first line, an object's
|
|
1236
1351
|
* short scalar members) and its original size.
|
|
1237
1352
|
*/
|
|
1238
|
-
declare function stubText(value: Json$
|
|
1353
|
+
declare function stubText(value: Json$2): string;
|
|
1239
1354
|
/** Every concrete pointer in `value` a pattern names (for counts, diffs and highlights). */
|
|
1240
|
-
declare function concretePointers(value: Json$
|
|
1355
|
+
declare function concretePointers(value: Json$2, pattern: string): string[];
|
|
1241
1356
|
/** Apply exclusions and per-node limits to a JSON value; returns the new value and what changed. */
|
|
1242
|
-
declare function applyStructureToJson(value: Json$
|
|
1243
|
-
value: Json$
|
|
1357
|
+
declare function applyStructureToJson(value: Json$2, recipe: StructureRecipe, labels?: Readonly<Record<string, string>>): {
|
|
1358
|
+
value: Json$2;
|
|
1244
1359
|
omissions: Omission[];
|
|
1245
1360
|
};
|
|
1246
1361
|
/** A JSON (or registered) draft with the person's structure choices applied. */
|
|
@@ -1250,7 +1365,7 @@ declare function applyJsonStructure(draft: Draft, recipe: StructureRecipe, label
|
|
|
1250
1365
|
* earlier sibling is excluded). Null when the node is excluded or cut; a stubbed ancestor answers
|
|
1251
1366
|
* with the stub's own pointer.
|
|
1252
1367
|
*/
|
|
1253
|
-
declare function outputPointer(value: Json$
|
|
1368
|
+
declare function outputPointer(value: Json$2, recipe: StructureRecipe, pointer: string): string | null;
|
|
1254
1369
|
declare function isProseSection(section: Section): boolean;
|
|
1255
1370
|
interface SectionLayout {
|
|
1256
1371
|
text: string;
|
|
@@ -1321,4 +1436,4 @@ declare function setPersonDefaultRecipe(ports: Pick<AlchemyHostPorts, "persisten
|
|
|
1321
1436
|
[key: string]: Json;
|
|
1322
1437
|
} | null): Promise<void>;
|
|
1323
1438
|
|
|
1324
|
-
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, EMPTY_STRUCTURE, type ExportPage, type ExportProjection, FORMAT_ADAPTERS, type FormatAdapter, type FormatEngine, type FormatOptions, type Json$
|
|
1439
|
+
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, EMPTY_STRUCTURE, type ExportPage, type ExportProjection, FORMAT_ADAPTERS, type FormatAdapter, type FormatEngine, type FormatOptions, type Json$2 as Json, type NodeLimit, type NormalizeTransferJsonOptions, type Notice, type Omission, type OutputSpan, type PageAction, type Payload, type PreparationOptions, type PreparationSession, type QuerySnapshot, type RawSnapshot, type Receipt, type RecipeOrigin, type ResolvedRecipe, type SealedArtifact, type Section, type SectionLayout, type ServerOperation, type Snapshot, type Source, type SpanMap, type StructureRecipe, type SurfaceHandle, TRANSFER_DEFAULT_RECIPE_SETTING, type TransferLimits, type TransferOperation, type TransferOutcome, type TransferPreferenceOverrides, type TransferPreferences, type TransferScope, type TransferSurfaceDeclaration, type TransferTarget, type Transform, type Transport, type WriteTargetRef, agentPayloadWithSpans, applyJsonStructure, applySectionSelection, applySectionStructure, applyStructureToJson, applyTransferLimits, assembleAgentPayload, buildAgentPayload, capture, collectAllMatching, concretePointers, createBrowserTransport, createDelivery, createDraft, createSurfaceTransferHandle, deriveDraft, directSource, displayPath, editDraft, eligibleFormats, exportedColumns, extensionForLanguage, fenceJsonBlock, formatAdapter, isProseSection, isSealed, joinPointer, jsonSize, jsonTextSpans, nodeChars, normalizeTransferJson, offsetSpans, openPreparation, outputPointer, patternBelow, patternCovers, patternMatches, pointerSegments, projectSnapshot, readTransferCell, recipeKey, reduceJson, refreshDraft, resetDraft, resolveDefaultRecipe, resolveTransferPreferences, resolveTransferRegistry, sealArtifact, sealDraft, sealTransferArtifact, sectionLayout, serialize, setPersonDefaultRecipe, sourceChanged, spanMap, stubText, transformRows, undoDraft };
|
package/dist/operate.d.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Framework-neutral transfer contracts (Alchemy Operate, CONTRACT §2.3). All data crossing this boundary is JSON.
|
|
3
3
|
* Moved from `@ai-matrx/kit/content-transfer` in ALC-16; the format-adapter contract lives in `./contract`.
|
|
4
4
|
*/
|
|
5
|
-
type Json$
|
|
6
|
-
[key: string]: Json$
|
|
5
|
+
type Json$2 = null | boolean | number | string | Json$2[] | {
|
|
6
|
+
[key: string]: Json$2;
|
|
7
7
|
};
|
|
8
8
|
type Payload =
|
|
9
9
|
/** A text payload may name its language (code blocks): downloads take its extension, Markdown fences it. */
|
|
@@ -16,15 +16,15 @@ type Payload =
|
|
|
16
16
|
text: string;
|
|
17
17
|
} | {
|
|
18
18
|
kind: "json";
|
|
19
|
-
value: Json$
|
|
19
|
+
value: Json$2;
|
|
20
20
|
} | {
|
|
21
21
|
kind: "rows";
|
|
22
|
-
rows: Record<string, Json$
|
|
22
|
+
rows: Record<string, Json$2>[];
|
|
23
23
|
columns: Column[];
|
|
24
24
|
} | {
|
|
25
25
|
kind: "registered";
|
|
26
26
|
format: string;
|
|
27
|
-
value: Json$
|
|
27
|
+
value: Json$2;
|
|
28
28
|
};
|
|
29
29
|
type Column = {
|
|
30
30
|
id: string;
|
|
@@ -38,9 +38,9 @@ type Column = {
|
|
|
38
38
|
dataType?: string;
|
|
39
39
|
order?: number;
|
|
40
40
|
required?: boolean;
|
|
41
|
-
defaultValue?: Json$
|
|
42
|
-
validation?: Json$
|
|
43
|
-
metadata?: Json$
|
|
41
|
+
defaultValue?: Json$2;
|
|
42
|
+
validation?: Json$2;
|
|
43
|
+
metadata?: Json$2;
|
|
44
44
|
};
|
|
45
45
|
};
|
|
46
46
|
type ExportProjection = {
|
|
@@ -93,21 +93,21 @@ type Snapshot = RawSnapshot & {
|
|
|
93
93
|
type QuerySnapshot = {
|
|
94
94
|
sourceId: string;
|
|
95
95
|
revision: string;
|
|
96
|
-
query: Json$
|
|
96
|
+
query: Json$2;
|
|
97
97
|
order: {
|
|
98
98
|
field: string;
|
|
99
99
|
direction: "asc" | "desc";
|
|
100
100
|
}[];
|
|
101
101
|
};
|
|
102
102
|
type ExportPage = {
|
|
103
|
-
rows: Record<string, Json$
|
|
103
|
+
rows: Record<string, Json$2>[];
|
|
104
104
|
nextCursor: string | null;
|
|
105
105
|
coverage: Coverage;
|
|
106
106
|
consistencyToken: string | null;
|
|
107
107
|
};
|
|
108
108
|
type CapturedAllMatching = {
|
|
109
109
|
query: QuerySnapshot;
|
|
110
|
-
getRowId(row: Record<string, Json$
|
|
110
|
+
getRowId(row: Record<string, Json$2>): string;
|
|
111
111
|
page(request: {
|
|
112
112
|
query: QuerySnapshot;
|
|
113
113
|
cursor: string | null;
|
|
@@ -147,7 +147,7 @@ type Draft = {
|
|
|
147
147
|
};
|
|
148
148
|
type Transform = {
|
|
149
149
|
id: string;
|
|
150
|
-
apply(draft: Draft, options: Json$
|
|
150
|
+
apply(draft: Draft, options: Json$2, signal: AbortSignal): Promise<Draft>;
|
|
151
151
|
};
|
|
152
152
|
type Artifact = {
|
|
153
153
|
snapshotId: string;
|
|
@@ -338,9 +338,9 @@ type BoundAllMatching = {
|
|
|
338
338
|
type NormalizeTransferJsonOptions = {
|
|
339
339
|
omitUndefinedObjectProperties?: boolean;
|
|
340
340
|
};
|
|
341
|
-
declare function normalizeTransferJson(value: unknown, options?: NormalizeTransferJsonOptions): Json$
|
|
341
|
+
declare function normalizeTransferJson(value: unknown, options?: NormalizeTransferJsonOptions): Json$2;
|
|
342
342
|
/** Column ids are identities, never an alternative data address. */
|
|
343
|
-
declare function readTransferCell(row: Record<string, Json$
|
|
343
|
+
declare function readTransferCell(row: Record<string, Json$2>, column: Column): Json$2 | undefined;
|
|
344
344
|
declare function projectSnapshot(raw: RawSnapshot, projection: ExportProjection): Snapshot;
|
|
345
345
|
declare function directSource(payload: Payload, options?: Partial<Pick<RawSnapshot, "id" | "sourceId" | "revision" | "label" | "coverage" | "unsavedChanges" | "sections" | "limits"> & {
|
|
346
346
|
projection: ExportProjection;
|
|
@@ -385,7 +385,7 @@ declare function reduceJson(draft: Draft, options: {
|
|
|
385
385
|
maxArrayItems?: number | null;
|
|
386
386
|
}): Draft;
|
|
387
387
|
declare function collectAllMatching(c: BoundAllMatching, signal: AbortSignal): Promise<{
|
|
388
|
-
rows: Record<string, Json$
|
|
388
|
+
rows: Record<string, Json$2>[];
|
|
389
389
|
coverage: RawSnapshot["coverage"];
|
|
390
390
|
omissions: Omission[];
|
|
391
391
|
error?: ContentTransferError;
|
|
@@ -433,6 +433,16 @@ declare function createSurfaceTransferHandle(options: {
|
|
|
433
433
|
/** Applies explicit preparation/source limits with exact omissions; token target is advisory. */
|
|
434
434
|
declare function applyTransferLimits(draft: Draft, limits: Partial<TransferLimits>): Draft;
|
|
435
435
|
|
|
436
|
+
/**
|
|
437
|
+
* Matrx Alchemy — Declare types (CONTRACT §2.1).
|
|
438
|
+
*
|
|
439
|
+
* A declaration is plain JSON data (chair ruling N2): no functions, no classes,
|
|
440
|
+
* no React. Runtime behaviour lives in `MountedSurface` (`/declare/host`) and in
|
|
441
|
+
* handler registrations, never here. Zero React, zero `@ai-matrx/agents`.
|
|
442
|
+
*/
|
|
443
|
+
type Json$1 = null | boolean | number | string | Json$1[] | {
|
|
444
|
+
[key: string]: Json$1;
|
|
445
|
+
};
|
|
436
446
|
/** Unchanged from `ui_surface_value_type_chk`. */
|
|
437
447
|
type ValueType = "string" | "number" | "boolean" | "object" | "array" | "document";
|
|
438
448
|
type Classification = "ordinary" | "secret" | "credential";
|
|
@@ -639,6 +649,75 @@ interface ClickTarget {
|
|
|
639
649
|
host?: unknown;
|
|
640
650
|
}
|
|
641
651
|
|
|
652
|
+
/**
|
|
653
|
+
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
654
|
+
*
|
|
655
|
+
* An Action is one thing a surface can have done to it, by a person, an agent,
|
|
656
|
+
* an applet or an automation: a write target, a client tool, a Kind Action or a
|
|
657
|
+
* row in `ui.ui_surface_action`. All of them project onto `ActionDeclaration`
|
|
658
|
+
* (`./declarations.ts`) and run through ONE runner (`./surface-run.ts`). There is
|
|
659
|
+
* never a second registry: `name` IS the alchemy action id, and `category`
|
|
660
|
+
* defaults to "applet" in alchemy's closed `ActionCategory` union.
|
|
661
|
+
*
|
|
662
|
+
* Types only — no runtime code, no React, no `@ai-matrx/agents`. `/ports`
|
|
663
|
+
* imports from here, so this file imports nothing but local types.
|
|
664
|
+
*/
|
|
665
|
+
|
|
666
|
+
/** Who started a run. */
|
|
667
|
+
type ActionCaller = "person" | "agent" | "applet" | "automation";
|
|
668
|
+
/** Who may run it without a click: "manual" = only a person; "ask" = proposed first; "auto" = runs. */
|
|
669
|
+
type ActionPolicy = "ask" | "auto" | "manual";
|
|
670
|
+
interface ActionContext {
|
|
671
|
+
runId: string;
|
|
672
|
+
by: ActionCaller;
|
|
673
|
+
viewerId: string | null;
|
|
674
|
+
surfaceName?: string;
|
|
675
|
+
policy?: ActionPolicy;
|
|
676
|
+
}
|
|
677
|
+
/** The system's own sentence, never thrown into a UI. Superset of RecordsError (CONTRACTS §0 `AppletError`). */
|
|
678
|
+
interface ActionError {
|
|
679
|
+
code: string;
|
|
680
|
+
message: string;
|
|
681
|
+
retryable: boolean;
|
|
682
|
+
diagnostic?: string;
|
|
683
|
+
}
|
|
684
|
+
/** CONTRACTS §0 `Result<T>`. */
|
|
685
|
+
type ActionResult<T = unknown> = {
|
|
686
|
+
ok: true;
|
|
687
|
+
data: T;
|
|
688
|
+
} | {
|
|
689
|
+
ok: false;
|
|
690
|
+
error: ActionError;
|
|
691
|
+
};
|
|
692
|
+
/** `POST /actions/run` (aidream) — the request. */
|
|
693
|
+
interface ServerActionRunRequest {
|
|
694
|
+
name: string;
|
|
695
|
+
input: Json$1;
|
|
696
|
+
by: ActionCaller;
|
|
697
|
+
surface_name?: string;
|
|
698
|
+
policy?: ActionPolicy;
|
|
699
|
+
}
|
|
700
|
+
/** `POST /actions/run` (aidream) — the response. */
|
|
701
|
+
interface ServerActionRunResponse {
|
|
702
|
+
status: "applied" | "proposed" | "refused";
|
|
703
|
+
message: string;
|
|
704
|
+
receipts: Json$1[];
|
|
705
|
+
proposal?: Json$1;
|
|
706
|
+
}
|
|
707
|
+
/** A mandate run request: by alias (an Action's `target`) or by key. */
|
|
708
|
+
type MandateRunRequest = ({
|
|
709
|
+
alias: string;
|
|
710
|
+
key?: never;
|
|
711
|
+
} | {
|
|
712
|
+
key: string;
|
|
713
|
+
alias?: never;
|
|
714
|
+
}) & {
|
|
715
|
+
variables: Record<string, Json$1>;
|
|
716
|
+
userInput?: string;
|
|
717
|
+
by: ActionCaller;
|
|
718
|
+
policy: ActionPolicy;
|
|
719
|
+
};
|
|
720
|
+
|
|
642
721
|
/**
|
|
643
722
|
* `@ai-matrx/alchemy/ports` — the host ports (Matrx Alchemy CONTRACT §2.2).
|
|
644
723
|
*
|
|
@@ -687,6 +766,12 @@ interface ClickTarget {
|
|
|
687
766
|
* to an overlay carrying the session as data)
|
|
688
767
|
* transferKnobs absent → no organization default recipe; a person's own
|
|
689
768
|
* default (persistence) or the package's Full applies
|
|
769
|
+
* serverActions absent → `runs: "server"` Actions refuse with "not available here"
|
|
770
|
+
* mandates absent → `runs: "mandate"` Actions refuse the same way
|
|
771
|
+
* pageActions absent → `runs: "page"` Actions refuse the same way
|
|
772
|
+
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
773
|
+
* ("needs a person's approval"); a person's own click is the approval
|
|
774
|
+
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
690
775
|
*
|
|
691
776
|
* Types only: this entry has no runtime code.
|
|
692
777
|
*/
|
|
@@ -832,6 +917,36 @@ interface AlchemyHostPorts {
|
|
|
832
917
|
window?: WindowPort;
|
|
833
918
|
/** Organization default recipes, resolved by the host's Feature Knob ladder (platform → organization). */
|
|
834
919
|
transferKnobs?: TransferKnobsPort;
|
|
920
|
+
/** aidream `POST /actions/run`: a registered server action by name, as the caller, under the apply-policy cascade. */
|
|
921
|
+
serverActions?: ServerActionPort;
|
|
922
|
+
/** Runs a mandate by alias or key (the host binds `@ai-matrx/agents`; alchemy never imports it). */
|
|
923
|
+
mandates?: MandatePort;
|
|
924
|
+
/** The page's own handlers for `runs: "page"` Actions (in an applet frame: routed as `{ action, input, runId }`). */
|
|
925
|
+
pageActions?: PageActionPort;
|
|
926
|
+
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
927
|
+
approvals?: ApprovalPort;
|
|
928
|
+
}
|
|
929
|
+
interface ServerActionPort {
|
|
930
|
+
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
|
931
|
+
}
|
|
932
|
+
interface MandatePort {
|
|
933
|
+
/** Resolves with the run's result (a kind envelope or JSON); rejects with the system's sentence. */
|
|
934
|
+
run(request: MandateRunRequest): Promise<unknown>;
|
|
935
|
+
}
|
|
936
|
+
interface ApprovalRequest {
|
|
937
|
+
action: string;
|
|
938
|
+
label: string;
|
|
939
|
+
description: string;
|
|
940
|
+
input: Json;
|
|
941
|
+
by: "agent" | "applet" | "automation";
|
|
942
|
+
surfaceName: string;
|
|
943
|
+
}
|
|
944
|
+
interface ApprovalPort {
|
|
945
|
+
/** Resolves true when the person approves; false when they decline or dismiss. */
|
|
946
|
+
ask(request: ApprovalRequest): Promise<boolean>;
|
|
947
|
+
}
|
|
948
|
+
interface PageActionPort {
|
|
949
|
+
dispatch(name: string, input: unknown, context: ActionContext): Promise<ActionResult<unknown>>;
|
|
835
950
|
}
|
|
836
951
|
/**
|
|
837
952
|
* Why a port and not `OverlayHostPort`: an overlay's `data` is `Json`, and a live preparation
|
|
@@ -983,7 +1098,7 @@ type TransferOperation = {
|
|
|
983
1098
|
} | {
|
|
984
1099
|
kind: "transform";
|
|
985
1100
|
transform: string;
|
|
986
|
-
options?: Json$
|
|
1101
|
+
options?: Json$2;
|
|
987
1102
|
} | {
|
|
988
1103
|
kind: "prepare-for-ai";
|
|
989
1104
|
instruction?: string;
|
|
@@ -1028,7 +1143,7 @@ interface ServerOperation {
|
|
|
1028
1143
|
statement: string;
|
|
1029
1144
|
supports(payload: Payload): boolean;
|
|
1030
1145
|
/** Projected draft only; sensitivity already applied. */
|
|
1031
|
-
toInput(draft: Draft): Json$
|
|
1146
|
+
toInput(draft: Draft): Json$2;
|
|
1032
1147
|
}
|
|
1033
1148
|
/** Delivery results: `copy` and `download` only ever deliver, degrade, cancel or fail (CONTRACT R16). */
|
|
1034
1149
|
type DeliveryOutcome = Extract<TransferOutcome, {
|
|
@@ -1110,7 +1225,7 @@ interface PreparationSession {
|
|
|
1110
1225
|
readonly snapshot: Snapshot;
|
|
1111
1226
|
readonly draft: Draft;
|
|
1112
1227
|
/** Deterministic transform, AI preparation or any registered transform — bumps draft.revision. */
|
|
1113
|
-
transform(id: string, options: Json$
|
|
1228
|
+
transform(id: string, options: Json$2, signal: AbortSignal): Promise<Draft>;
|
|
1114
1229
|
/** A manual edit. */
|
|
1115
1230
|
edit(payload: Payload): Draft;
|
|
1116
1231
|
/** Keep only these sections (ids from the snapshot). */
|
|
@@ -1228,19 +1343,19 @@ declare function patternBelow(pattern: string, pointer: string): boolean;
|
|
|
1228
1343
|
/** The path a person reads and copies: `/messages/*\/metadata` → `data.messages[*].metadata`. */
|
|
1229
1344
|
declare function displayPath(pointer: string, root?: string): string;
|
|
1230
1345
|
/** Exactly `JSON.stringify(value).length`, computed once per object (large sources stay cheap). */
|
|
1231
|
-
declare function jsonSize(value: Json$
|
|
1346
|
+
declare function jsonSize(value: Json$2): number;
|
|
1232
1347
|
/** The size a person expects for a node: a string's own length, else its JSON. */
|
|
1233
|
-
declare function nodeChars(value: Json$
|
|
1348
|
+
declare function nodeChars(value: Json$2): number;
|
|
1234
1349
|
/**
|
|
1235
1350
|
* The one-line stub that stands in for a node: its header (a string's first line, an object's
|
|
1236
1351
|
* short scalar members) and its original size.
|
|
1237
1352
|
*/
|
|
1238
|
-
declare function stubText(value: Json$
|
|
1353
|
+
declare function stubText(value: Json$2): string;
|
|
1239
1354
|
/** Every concrete pointer in `value` a pattern names (for counts, diffs and highlights). */
|
|
1240
|
-
declare function concretePointers(value: Json$
|
|
1355
|
+
declare function concretePointers(value: Json$2, pattern: string): string[];
|
|
1241
1356
|
/** Apply exclusions and per-node limits to a JSON value; returns the new value and what changed. */
|
|
1242
|
-
declare function applyStructureToJson(value: Json$
|
|
1243
|
-
value: Json$
|
|
1357
|
+
declare function applyStructureToJson(value: Json$2, recipe: StructureRecipe, labels?: Readonly<Record<string, string>>): {
|
|
1358
|
+
value: Json$2;
|
|
1244
1359
|
omissions: Omission[];
|
|
1245
1360
|
};
|
|
1246
1361
|
/** A JSON (or registered) draft with the person's structure choices applied. */
|
|
@@ -1250,7 +1365,7 @@ declare function applyJsonStructure(draft: Draft, recipe: StructureRecipe, label
|
|
|
1250
1365
|
* earlier sibling is excluded). Null when the node is excluded or cut; a stubbed ancestor answers
|
|
1251
1366
|
* with the stub's own pointer.
|
|
1252
1367
|
*/
|
|
1253
|
-
declare function outputPointer(value: Json$
|
|
1368
|
+
declare function outputPointer(value: Json$2, recipe: StructureRecipe, pointer: string): string | null;
|
|
1254
1369
|
declare function isProseSection(section: Section): boolean;
|
|
1255
1370
|
interface SectionLayout {
|
|
1256
1371
|
text: string;
|
|
@@ -1321,4 +1436,4 @@ declare function setPersonDefaultRecipe(ports: Pick<AlchemyHostPorts, "persisten
|
|
|
1321
1436
|
[key: string]: Json;
|
|
1322
1437
|
} | null): Promise<void>;
|
|
1323
1438
|
|
|
1324
|
-
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, EMPTY_STRUCTURE, type ExportPage, type ExportProjection, FORMAT_ADAPTERS, type FormatAdapter, type FormatEngine, type FormatOptions, type Json$
|
|
1439
|
+
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, EMPTY_STRUCTURE, type ExportPage, type ExportProjection, FORMAT_ADAPTERS, type FormatAdapter, type FormatEngine, type FormatOptions, type Json$2 as Json, type NodeLimit, type NormalizeTransferJsonOptions, type Notice, type Omission, type OutputSpan, type PageAction, type Payload, type PreparationOptions, type PreparationSession, type QuerySnapshot, type RawSnapshot, type Receipt, type RecipeOrigin, type ResolvedRecipe, type SealedArtifact, type Section, type SectionLayout, type ServerOperation, type Snapshot, type Source, type SpanMap, type StructureRecipe, type SurfaceHandle, TRANSFER_DEFAULT_RECIPE_SETTING, type TransferLimits, type TransferOperation, type TransferOutcome, type TransferPreferenceOverrides, type TransferPreferences, type TransferScope, type TransferSurfaceDeclaration, type TransferTarget, type Transform, type Transport, type WriteTargetRef, agentPayloadWithSpans, applyJsonStructure, applySectionSelection, applySectionStructure, applyStructureToJson, applyTransferLimits, assembleAgentPayload, buildAgentPayload, capture, collectAllMatching, concretePointers, createBrowserTransport, createDelivery, createDraft, createSurfaceTransferHandle, deriveDraft, directSource, displayPath, editDraft, eligibleFormats, exportedColumns, extensionForLanguage, fenceJsonBlock, formatAdapter, isProseSection, isSealed, joinPointer, jsonSize, jsonTextSpans, nodeChars, normalizeTransferJson, offsetSpans, openPreparation, outputPointer, patternBelow, patternCovers, patternMatches, pointerSegments, projectSnapshot, readTransferCell, recipeKey, reduceJson, refreshDraft, resetDraft, resolveDefaultRecipe, resolveTransferPreferences, resolveTransferRegistry, sealArtifact, sealDraft, sealTransferArtifact, sectionLayout, serialize, setPersonDefaultRecipe, sourceChanged, spanMap, stubText, transformRows, undoDraft };
|