@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/menu.d.cts
CHANGED
|
@@ -378,6 +378,75 @@ interface ClickTarget {
|
|
|
378
378
|
host?: unknown;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
/**
|
|
382
|
+
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
383
|
+
*
|
|
384
|
+
* An Action is one thing a surface can have done to it, by a person, an agent,
|
|
385
|
+
* an applet or an automation: a write target, a client tool, a Kind Action or a
|
|
386
|
+
* row in `ui.ui_surface_action`. All of them project onto `ActionDeclaration`
|
|
387
|
+
* (`./declarations.ts`) and run through ONE runner (`./surface-run.ts`). There is
|
|
388
|
+
* never a second registry: `name` IS the alchemy action id, and `category`
|
|
389
|
+
* defaults to "applet" in alchemy's closed `ActionCategory` union.
|
|
390
|
+
*
|
|
391
|
+
* Types only — no runtime code, no React, no `@ai-matrx/agents`. `/ports`
|
|
392
|
+
* imports from here, so this file imports nothing but local types.
|
|
393
|
+
*/
|
|
394
|
+
|
|
395
|
+
/** Who started a run. */
|
|
396
|
+
type ActionCaller = "person" | "agent" | "applet" | "automation";
|
|
397
|
+
/** Who may run it without a click: "manual" = only a person; "ask" = proposed first; "auto" = runs. */
|
|
398
|
+
type ActionPolicy = "ask" | "auto" | "manual";
|
|
399
|
+
interface ActionContext {
|
|
400
|
+
runId: string;
|
|
401
|
+
by: ActionCaller;
|
|
402
|
+
viewerId: string | null;
|
|
403
|
+
surfaceName?: string;
|
|
404
|
+
policy?: ActionPolicy;
|
|
405
|
+
}
|
|
406
|
+
/** The system's own sentence, never thrown into a UI. Superset of RecordsError (CONTRACTS §0 `AppletError`). */
|
|
407
|
+
interface ActionError {
|
|
408
|
+
code: string;
|
|
409
|
+
message: string;
|
|
410
|
+
retryable: boolean;
|
|
411
|
+
diagnostic?: string;
|
|
412
|
+
}
|
|
413
|
+
/** CONTRACTS §0 `Result<T>`. */
|
|
414
|
+
type ActionResult<T = unknown> = {
|
|
415
|
+
ok: true;
|
|
416
|
+
data: T;
|
|
417
|
+
} | {
|
|
418
|
+
ok: false;
|
|
419
|
+
error: ActionError;
|
|
420
|
+
};
|
|
421
|
+
/** `POST /actions/run` (aidream) — the request. */
|
|
422
|
+
interface ServerActionRunRequest {
|
|
423
|
+
name: string;
|
|
424
|
+
input: Json$1;
|
|
425
|
+
by: ActionCaller;
|
|
426
|
+
surface_name?: string;
|
|
427
|
+
policy?: ActionPolicy;
|
|
428
|
+
}
|
|
429
|
+
/** `POST /actions/run` (aidream) — the response. */
|
|
430
|
+
interface ServerActionRunResponse {
|
|
431
|
+
status: "applied" | "proposed" | "refused";
|
|
432
|
+
message: string;
|
|
433
|
+
receipts: Json$1[];
|
|
434
|
+
proposal?: Json$1;
|
|
435
|
+
}
|
|
436
|
+
/** A mandate run request: by alias (an Action's `target`) or by key. */
|
|
437
|
+
type MandateRunRequest = ({
|
|
438
|
+
alias: string;
|
|
439
|
+
key?: never;
|
|
440
|
+
} | {
|
|
441
|
+
key: string;
|
|
442
|
+
alias?: never;
|
|
443
|
+
}) & {
|
|
444
|
+
variables: Record<string, Json$1>;
|
|
445
|
+
userInput?: string;
|
|
446
|
+
by: ActionCaller;
|
|
447
|
+
policy: ActionPolicy;
|
|
448
|
+
};
|
|
449
|
+
|
|
381
450
|
/**
|
|
382
451
|
* `@ai-matrx/alchemy/ports` — the host ports (Matrx Alchemy CONTRACT §2.2).
|
|
383
452
|
*
|
|
@@ -426,6 +495,12 @@ interface ClickTarget {
|
|
|
426
495
|
* to an overlay carrying the session as data)
|
|
427
496
|
* transferKnobs absent → no organization default recipe; a person's own
|
|
428
497
|
* default (persistence) or the package's Full applies
|
|
498
|
+
* serverActions absent → `runs: "server"` Actions refuse with "not available here"
|
|
499
|
+
* mandates absent → `runs: "mandate"` Actions refuse the same way
|
|
500
|
+
* pageActions absent → `runs: "page"` Actions refuse the same way
|
|
501
|
+
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
502
|
+
* ("needs a person's approval"); a person's own click is the approval
|
|
503
|
+
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
429
504
|
*
|
|
430
505
|
* Types only: this entry has no runtime code.
|
|
431
506
|
*/
|
|
@@ -571,6 +646,36 @@ interface AlchemyHostPorts {
|
|
|
571
646
|
window?: WindowPort;
|
|
572
647
|
/** Organization default recipes, resolved by the host's Feature Knob ladder (platform → organization). */
|
|
573
648
|
transferKnobs?: TransferKnobsPort;
|
|
649
|
+
/** aidream `POST /actions/run`: a registered server action by name, as the caller, under the apply-policy cascade. */
|
|
650
|
+
serverActions?: ServerActionPort;
|
|
651
|
+
/** Runs a mandate by alias or key (the host binds `@ai-matrx/agents`; alchemy never imports it). */
|
|
652
|
+
mandates?: MandatePort;
|
|
653
|
+
/** The page's own handlers for `runs: "page"` Actions (in an applet frame: routed as `{ action, input, runId }`). */
|
|
654
|
+
pageActions?: PageActionPort;
|
|
655
|
+
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
656
|
+
approvals?: ApprovalPort;
|
|
657
|
+
}
|
|
658
|
+
interface ServerActionPort {
|
|
659
|
+
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
|
660
|
+
}
|
|
661
|
+
interface MandatePort {
|
|
662
|
+
/** Resolves with the run's result (a kind envelope or JSON); rejects with the system's sentence. */
|
|
663
|
+
run(request: MandateRunRequest): Promise<unknown>;
|
|
664
|
+
}
|
|
665
|
+
interface ApprovalRequest {
|
|
666
|
+
action: string;
|
|
667
|
+
label: string;
|
|
668
|
+
description: string;
|
|
669
|
+
input: Json;
|
|
670
|
+
by: "agent" | "applet" | "automation";
|
|
671
|
+
surfaceName: string;
|
|
672
|
+
}
|
|
673
|
+
interface ApprovalPort {
|
|
674
|
+
/** Resolves true when the person approves; false when they decline or dismiss. */
|
|
675
|
+
ask(request: ApprovalRequest): Promise<boolean>;
|
|
676
|
+
}
|
|
677
|
+
interface PageActionPort {
|
|
678
|
+
dispatch(name: string, input: unknown, context: ActionContext): Promise<ActionResult<unknown>>;
|
|
574
679
|
}
|
|
575
680
|
/**
|
|
576
681
|
* Why a port and not `OverlayHostPort`: an overlay's `data` is `Json`, and a live preparation
|
|
@@ -724,8 +829,10 @@ type Eligibility = {
|
|
|
724
829
|
status: "unavailable";
|
|
725
830
|
sentence: string;
|
|
726
831
|
};
|
|
727
|
-
/** rich-document's ActionCategory, unchanged, plus the three the context menu groups by. */
|
|
728
|
-
type ActionCategory = "feedback" | "copy" | "export" | "save" | "edit" | "share" | "creator" | "app" | "listen" | "study" | "ask" | "ai" | "admin" | "clipboard" | "history" | "surface-info"
|
|
832
|
+
/** rich-document's ActionCategory, unchanged, plus the three the context menu groups by, plus "applet" (surface Actions). */
|
|
833
|
+
type ActionCategory = "feedback" | "copy" | "export" | "save" | "edit" | "share" | "creator" | "app" | "listen" | "study" | "ask" | "ai" | "admin" | "clipboard" | "history" | "surface-info"
|
|
834
|
+
/** Surface Actions (Applets CONTRACTS §6): the default category of an `ActionDeclaration`. */
|
|
835
|
+
| "applet";
|
|
729
836
|
/**
|
|
730
837
|
* An optional named section inside the action's group (a grid's cell / row /
|
|
731
838
|
* column). `primary` marks the thing the person clicked: every layout renders
|
package/dist/menu.d.ts
CHANGED
|
@@ -378,6 +378,75 @@ interface ClickTarget {
|
|
|
378
378
|
host?: unknown;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
+
/**
|
|
382
|
+
* Surface Actions — the shapes (Applets CONTRACTS §6, FROZEN; exported here as a superset).
|
|
383
|
+
*
|
|
384
|
+
* An Action is one thing a surface can have done to it, by a person, an agent,
|
|
385
|
+
* an applet or an automation: a write target, a client tool, a Kind Action or a
|
|
386
|
+
* row in `ui.ui_surface_action`. All of them project onto `ActionDeclaration`
|
|
387
|
+
* (`./declarations.ts`) and run through ONE runner (`./surface-run.ts`). There is
|
|
388
|
+
* never a second registry: `name` IS the alchemy action id, and `category`
|
|
389
|
+
* defaults to "applet" in alchemy's closed `ActionCategory` union.
|
|
390
|
+
*
|
|
391
|
+
* Types only — no runtime code, no React, no `@ai-matrx/agents`. `/ports`
|
|
392
|
+
* imports from here, so this file imports nothing but local types.
|
|
393
|
+
*/
|
|
394
|
+
|
|
395
|
+
/** Who started a run. */
|
|
396
|
+
type ActionCaller = "person" | "agent" | "applet" | "automation";
|
|
397
|
+
/** Who may run it without a click: "manual" = only a person; "ask" = proposed first; "auto" = runs. */
|
|
398
|
+
type ActionPolicy = "ask" | "auto" | "manual";
|
|
399
|
+
interface ActionContext {
|
|
400
|
+
runId: string;
|
|
401
|
+
by: ActionCaller;
|
|
402
|
+
viewerId: string | null;
|
|
403
|
+
surfaceName?: string;
|
|
404
|
+
policy?: ActionPolicy;
|
|
405
|
+
}
|
|
406
|
+
/** The system's own sentence, never thrown into a UI. Superset of RecordsError (CONTRACTS §0 `AppletError`). */
|
|
407
|
+
interface ActionError {
|
|
408
|
+
code: string;
|
|
409
|
+
message: string;
|
|
410
|
+
retryable: boolean;
|
|
411
|
+
diagnostic?: string;
|
|
412
|
+
}
|
|
413
|
+
/** CONTRACTS §0 `Result<T>`. */
|
|
414
|
+
type ActionResult<T = unknown> = {
|
|
415
|
+
ok: true;
|
|
416
|
+
data: T;
|
|
417
|
+
} | {
|
|
418
|
+
ok: false;
|
|
419
|
+
error: ActionError;
|
|
420
|
+
};
|
|
421
|
+
/** `POST /actions/run` (aidream) — the request. */
|
|
422
|
+
interface ServerActionRunRequest {
|
|
423
|
+
name: string;
|
|
424
|
+
input: Json$1;
|
|
425
|
+
by: ActionCaller;
|
|
426
|
+
surface_name?: string;
|
|
427
|
+
policy?: ActionPolicy;
|
|
428
|
+
}
|
|
429
|
+
/** `POST /actions/run` (aidream) — the response. */
|
|
430
|
+
interface ServerActionRunResponse {
|
|
431
|
+
status: "applied" | "proposed" | "refused";
|
|
432
|
+
message: string;
|
|
433
|
+
receipts: Json$1[];
|
|
434
|
+
proposal?: Json$1;
|
|
435
|
+
}
|
|
436
|
+
/** A mandate run request: by alias (an Action's `target`) or by key. */
|
|
437
|
+
type MandateRunRequest = ({
|
|
438
|
+
alias: string;
|
|
439
|
+
key?: never;
|
|
440
|
+
} | {
|
|
441
|
+
key: string;
|
|
442
|
+
alias?: never;
|
|
443
|
+
}) & {
|
|
444
|
+
variables: Record<string, Json$1>;
|
|
445
|
+
userInput?: string;
|
|
446
|
+
by: ActionCaller;
|
|
447
|
+
policy: ActionPolicy;
|
|
448
|
+
};
|
|
449
|
+
|
|
381
450
|
/**
|
|
382
451
|
* `@ai-matrx/alchemy/ports` — the host ports (Matrx Alchemy CONTRACT §2.2).
|
|
383
452
|
*
|
|
@@ -426,6 +495,12 @@ interface ClickTarget {
|
|
|
426
495
|
* to an overlay carrying the session as data)
|
|
427
496
|
* transferKnobs absent → no organization default recipe; a person's own
|
|
428
497
|
* default (persistence) or the package's Full applies
|
|
498
|
+
* serverActions absent → `runs: "server"` Actions refuse with "not available here"
|
|
499
|
+
* mandates absent → `runs: "mandate"` Actions refuse the same way
|
|
500
|
+
* pageActions absent → `runs: "page"` Actions refuse the same way
|
|
501
|
+
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
502
|
+
* ("needs a person's approval"); a person's own click is the approval
|
|
503
|
+
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
429
504
|
*
|
|
430
505
|
* Types only: this entry has no runtime code.
|
|
431
506
|
*/
|
|
@@ -571,6 +646,36 @@ interface AlchemyHostPorts {
|
|
|
571
646
|
window?: WindowPort;
|
|
572
647
|
/** Organization default recipes, resolved by the host's Feature Knob ladder (platform → organization). */
|
|
573
648
|
transferKnobs?: TransferKnobsPort;
|
|
649
|
+
/** aidream `POST /actions/run`: a registered server action by name, as the caller, under the apply-policy cascade. */
|
|
650
|
+
serverActions?: ServerActionPort;
|
|
651
|
+
/** Runs a mandate by alias or key (the host binds `@ai-matrx/agents`; alchemy never imports it). */
|
|
652
|
+
mandates?: MandatePort;
|
|
653
|
+
/** The page's own handlers for `runs: "page"` Actions (in an applet frame: routed as `{ action, input, runId }`). */
|
|
654
|
+
pageActions?: PageActionPort;
|
|
655
|
+
/** Asks a person, in place, to approve an `ask` Action that an agent, applet or automation started. */
|
|
656
|
+
approvals?: ApprovalPort;
|
|
657
|
+
}
|
|
658
|
+
interface ServerActionPort {
|
|
659
|
+
run(request: ServerActionRunRequest): Promise<ServerActionRunResponse>;
|
|
660
|
+
}
|
|
661
|
+
interface MandatePort {
|
|
662
|
+
/** Resolves with the run's result (a kind envelope or JSON); rejects with the system's sentence. */
|
|
663
|
+
run(request: MandateRunRequest): Promise<unknown>;
|
|
664
|
+
}
|
|
665
|
+
interface ApprovalRequest {
|
|
666
|
+
action: string;
|
|
667
|
+
label: string;
|
|
668
|
+
description: string;
|
|
669
|
+
input: Json;
|
|
670
|
+
by: "agent" | "applet" | "automation";
|
|
671
|
+
surfaceName: string;
|
|
672
|
+
}
|
|
673
|
+
interface ApprovalPort {
|
|
674
|
+
/** Resolves true when the person approves; false when they decline or dismiss. */
|
|
675
|
+
ask(request: ApprovalRequest): Promise<boolean>;
|
|
676
|
+
}
|
|
677
|
+
interface PageActionPort {
|
|
678
|
+
dispatch(name: string, input: unknown, context: ActionContext): Promise<ActionResult<unknown>>;
|
|
574
679
|
}
|
|
575
680
|
/**
|
|
576
681
|
* Why a port and not `OverlayHostPort`: an overlay's `data` is `Json`, and a live preparation
|
|
@@ -724,8 +829,10 @@ type Eligibility = {
|
|
|
724
829
|
status: "unavailable";
|
|
725
830
|
sentence: string;
|
|
726
831
|
};
|
|
727
|
-
/** rich-document's ActionCategory, unchanged, plus the three the context menu groups by. */
|
|
728
|
-
type ActionCategory = "feedback" | "copy" | "export" | "save" | "edit" | "share" | "creator" | "app" | "listen" | "study" | "ask" | "ai" | "admin" | "clipboard" | "history" | "surface-info"
|
|
832
|
+
/** rich-document's ActionCategory, unchanged, plus the three the context menu groups by, plus "applet" (surface Actions). */
|
|
833
|
+
type ActionCategory = "feedback" | "copy" | "export" | "save" | "edit" | "share" | "creator" | "app" | "listen" | "study" | "ask" | "ai" | "admin" | "clipboard" | "history" | "surface-info"
|
|
834
|
+
/** Surface Actions (Applets CONTRACTS §6): the default category of an `ActionDeclaration`. */
|
|
835
|
+
| "applet";
|
|
729
836
|
/**
|
|
730
837
|
* An optional named section inside the action's group (a grid's cell / row /
|
|
731
838
|
* column). `primary` marks the thing the person clicked: every layout renders
|
package/dist/menu.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var APPROVED_HEADINGS=new Set(["Save","Copy as","Export","Edit","Creator tools","Admin","App","Compare","History"]),CONTAINER_WORD=/^(more|more…|more\.\.\.|other|others|misc|miscellaneous|additional|extra|extras|actions|options|advanced|stuff|everything else)$/i,TARGET_SHAPE=/^(Cell|Row|Column|Table|Range|Selection|Record) · .+$/;function isContainerWord(label){return CONTAINER_WORD.test(label.trim())}function isApprovedHeading(label,kind="group",approved=APPROVED_HEADINGS){let l=label.trim();return!l||isContainerWord(l)?!1:approved.has(l)?!0:kind==="target"||TARGET_SHAPE.test(l)}function defaultHeadingPolicy(){return globalThis.process?.env?.NODE_ENV==="production"?"inline":"throw"}var UnapprovedHeadingError=class extends Error{heading;constructor(heading,where){super(`Menu heading "${heading}" (${where}) is not an approved heading. Remedy: show these rows inline \u2014 declare no section (or kind "target" for the clicked thing's own label) \u2014 or ask Arman to add the name to APPROVED_HEADINGS in @ai-matrx/alchemy/menu. A generic container word ("More\u2026", "Other") is never approved.`),this.name="UnapprovedHeadingError",this.heading=heading}};function menuHeadings(model){let out=[],walk=nodes=>{for(let n of nodes)n.kind==="submenu"&&(out.push(n.label),walk(n.children))};for(let s of model.sections)s.label&&out.push(s.label),walk(s.nodes);return[...new Set(out)]}function unapprovedHeadings(model,approved=APPROVED_HEADINGS){let out=new Set;for(let s of model.sections){s.label&&!isApprovedHeading(s.label,s.primary||s.target?"target":"group",approved)&&out.add(s.label);let walk=nodes=>{for(let n of nodes)n.kind==="submenu"&&(isContainerWord(n.label)&&out.add(n.label),walk(n.children))};walk(s.nodes)}return[...out]}var CATEGORY_GROUP={clipboard:"clipboard",copy:"transfer",export:"transfer",save:"document",share:"document",edit:"editable",history:"history",ai:"ai",ask:"ai",listen:"tools",study:"tools",app:"tools",feedback:"quick",creator:"admin",admin:"admin","surface-info":"surface-info"},GROUP_ORDER=["clipboard","editable","transfer","document","history","ai","tools","quick","surface","admin","surface-info"],CATEGORY_ORDER=["clipboard","edit","copy","export","save","share","history","ask","ai","listen","study","app","feedback","creator","admin","surface-info"];function translate(i18n,key,fallback){if(!i18n)return fallback;try{return i18n.t(key,fallback)}catch{return fallback}}function actionToNode(resolved,target,options={}){let{action,eligibility}=resolved,rawLabel=typeof action.label=="function"?action.label(target):action.label,label=translate(options.i18n,action.labelKey??action.id,rawLabel),base={id:action.id,actionId:action.id,...action.icon!==void 0?{icon:action.icon}:{},...action.placement!==void 0?{placement:action.placement}:{}};if(action.expand)return{...base,kind:"submenu",label,lazy:!0,loading:!1,...action.pending?.(target)?{pending:!0}:{},children:[],...action.emptyLabel!==void 0?{emptyLabel:action.emptyLabel}:{}};if(action.href!==void 0){let href=typeof action.href=="function"?action.href(target):action.href;return{...base,kind:"link",label,href}}if(action.toggle)return{...base,kind:"checkbox",label,checked:action.pressed?.(target)??!1,...action.description!==void 0?{description:action.description}:{}};let state=action.stateIcon?.(target)??null,pressed=action.pressed?.(target),hint=action.hint!==void 0?translate(options.i18n,action.hintKey??`${action.id}.hint`,action.hint):void 0;return{...base,kind:"item",label,...action.iconTone!==void 0?{iconTone:action.iconTone}:{},...state?{stateIcon:state}:{},...action.description!==void 0?{description:action.description}:{},...hint!==void 0?{hint}:{},...pressed!==void 0?{pressed}:{},...action.destructive?{destructive:!0}:{},...action.preserveSelection?{preserveSelection:!0}:{},...action.keepsMenuOpen?{keepsMenuOpen:!0}:{},...eligibility.status==="unavailable-verb"||eligibility.status==="unavailable"?{unavailable:{sentence:eligibility.sentence}}:{}}}function buildMenuModel(target,resolved,options={}){let policy=options.headingPolicy??defaultHeadingPolicy();resolved=resolved.map(r=>{let sec=r.action.section;if(r.action.expand&&isContainerWord(typeof r.action.label=="string"?r.action.label:"")&&policy==="throw")throw new UnapprovedHeadingError(r.action.label,`submenu of ${r.action.id}`);if(!sec)return r;let kind=sec.kind??(sec.primary?"target":"group");if(isApprovedHeading(sec.label,kind))return r;if(policy==="throw")throw new UnapprovedHeadingError(sec.label,`section of ${r.action.id}`);let{section:_dropped,...rest}=r.action;return{...r,action:rest}});let ordered=resolved.map((r,index)=>({r,index})).sort((a,b)=>{let ca=CATEGORY_ORDER.indexOf(a.r.action.category),cb=CATEGORY_ORDER.indexOf(b.r.action.category);if(ca!==cb)return ca-cb;let oa=a.r.action.order??0,ob=b.r.action.order??0;return oa!==ob?oa-ob:a.index-b.index}).map(x=>x.r),sections=new Map,roles={},explicit=new Map;resolved.forEach((r,index)=>{let sec=r.action.section;if(!sec)return;let entry=explicit.get(sec.id)??{group:CATEGORY_GROUP[r.action.category],rows:[]};entry.rows.push({r,index}),explicit.set(sec.id,entry)});let placed=new Set;for(let r of ordered){let sec=r.action.section;if(sec&&placed.has(sec.id))continue;let group=sec?explicit.get(sec.id)?.group??CATEGORY_GROUP[r.action.category]:CATEGORY_GROUP[r.action.category],sectionId=sec?`section:${sec.id}`:group,section=sections.get(sectionId);section||(section={id:sectionId,group,nodes:[],...sec?{label:translate(options.i18n,sec.labelKey??`section.${sec.id}`,sec.label)}:{},...sec?.icon!==void 0?{icon:sec.icon}:{},...sec?.primary?{primary:!0}:{},...sec&&(sec.kind??(sec.primary?"target":"group"))==="target"?{target:!0}:{}},sections.set(sectionId,section));let rows=sec?(explicit.get(sec.id)?.rows??[]).sort((x,y)=>(x.r.action.order??0)-(y.r.action.order??0)||x.index-y.index).map(x=>x.r):[r];sec&&placed.add(sec.id);for(let row of rows)row.action.startsGroup&§ion.nodes.length>0&§ion.nodes.push({kind:"separator",id:`${row.action.id}:group`}),section.nodes.push(actionToNode(row,target,options)),row.action.verb&&(roles[row.action.verb]=row.action.id)}let list=[...sections.values()].sort((a,b)=>!!a.primary!=!!b.primary?a.primary?-1:1:GROUP_ORDER.indexOf(a.group)-GROUP_ORDER.indexOf(b.group)),selected=target.selection?.text?.trim(),content=options.content?.trim(),fieldName=options.contentLabel?.trim();return{header:selected?{label:"Selected",text:target.selection?.text??""}:fieldName?{label:fieldName,text:options.content??""}:content?{label:"Content",text:options.content??""}:null,sections:list,roles}}function withExpandedChildren(model,nodeId,children){let visit=nodes=>nodes.map(n=>n.kind!=="submenu"?n:n.id===nodeId?children==="loading"?{...n,loading:!0}:{...n,lazy:!1,loading:!1,pending:!1,children}:{...n,children:visit(n.children)});return{...model,sections:model.sections.map(s=>({...s,nodes:visit(s.nodes)}))}}function findNode(nodes,id){for(let n of nodes){if(n.id===id)return n;if(n.kind==="submenu"){let hit=findNode(n.children,id);if(hit)return hit}}return null}var INLINE_SECTION_MAX=3;function sectionLabel(section){return section.label??null}function isLeaf(node){return node.kind==="item"||node.kind==="checkbox"||node.kind==="link"}function collect(nodes,out){for(let n of nodes)isLeaf(n)?out.push(n.id):n.kind==="submenu"&&(n.lazy?out.push(n.id):collect(n.children,out))}function leafIds(arranged){let out=[];if(Array.isArray(arranged))for(let s of arranged)collect(s.nodes,out);else if("leaves"in arranged)for(let l of arranged.leaves)out.push(l.node.id);else if("primary"in arranged&&"overflow"in arranged){collect(arranged.primary,out);for(let s of arranged.overflow)collect(s.nodes,out)}else if("root"in arranged)collect(arranged.strip,out),collect(arranged.root,out);else if("more"in arranged){collect(arranged.strip,out);for(let s of arranged.more)collect(s.nodes,out)}else if("filterable"in arranged){collect(arranged.strip,out);for(let s of arranged.sections)collect(s.nodes,out)}else for(let s of arranged.sections)collect(s.nodes,out);return[...new Set(out)].sort()}function fold(section){return{kind:"submenu",id:`${section.id}:fold`,label:section.label,...section.icon!==void 0?{icon:section.icon}:{},children:section.nodes}}function rowCount(nodes){return nodes.filter(n=>n.kind!=="separator"&&n.kind!=="label").length}function stripOf(model){let clipboard=model.sections.find(s=>s.group==="clipboard"&&!s.primary);return clipboard?clipboard.nodes.filter(isLeaf):[]}function clipboardRest(model){let clipboard=model.sections.find(s=>s.group==="clipboard"&&!s.primary);return clipboard?clipboard.nodes.filter(n=>!isLeaf(n)&&n.kind==="submenu"):[]}function placementOf(node){return"placement"in node&&node.placement?node.placement:"overflow"}function classic(model){return{strip:[],sections:model.sections,filterable:!1}}function tiered(model,filterable){let strip=stripOf(model),sections=[],rest=clipboardRest(model);for(let s of model.sections){if(s.group==="clipboard"&&!s.primary){rest.length&§ions.push({...s,nodes:rest});continue}if(s.primary){sections.push(s);continue}if(!s.label||s.group==="surface-info"||rowCount(s.nodes)<=3){sections.push(s);continue}sections.push({id:s.id,group:s.group,nodes:[fold({...s,label:s.label})]})}return{strip,sections,filterable}}function context(model,arrangement){return arrangement==="classic"?classic(model):tiered(model,arrangement==="command")}function foldUnderSubject(arranged,subject){let label=subject.trim(),primary=arranged.sections.filter(s=>s.primary),rest=arranged.sections.filter(s=>!s.primary);if(!label||primary.length===0||rest.length===0&&arranged.strip.length===0)return arranged;let children=[];arranged.strip.length&&children.push(...arranged.strip);for(let s of rest)rowCount(s.nodes)!==0&&(children.length&&children.push({kind:"separator",id:`${s.id}:subject-sep`}),s.label&&children.push({kind:"label",id:`${s.id}:subject-label`,label:s.label}),children.push(...s.nodes));return rowCount(children)===0?{...arranged,strip:[]}:{strip:[],filterable:!1,sections:[...primary,{id:"subject",group:rest[0]?.group??primary[0].group,nodes:[{kind:"submenu",id:"subject:fold",label,children}]}]}}function foldNamed(sections){return sections.map(s=>s.label&&!s.primary&&rowCount(s.nodes)>3?{id:s.id,group:s.group,nodes:[fold({...s,label:s.label})]}:s)}function overflow(model){return foldNamed(model.sections)}function bar(model,_options={}){let primary=[],overflowSections=[];for(let s of model.sections){let rest=[];for(let n of s.nodes){if(n.kind==="separator"||n.kind==="label"){rest.push(n);continue}let p=placementOf(n);(p==="primary"||p==="both")&&primary.push(n),(p==="overflow"||p==="both")&&rest.push(n)}rowCount(rest)>0&&overflowSections.push({...s,nodes:rest})}return{primary,overflow:foldNamed(overflowSections)}}function selectionToolbar(model){let strip=[],more=[];for(let s of model.sections){let rest=[];for(let n of s.nodes)s.group==="clipboard"&&!s.primary&&isLeaf(n)||placementOf(n)!=="overflow"?strip.push(n):rest.push(n);rowCount(rest)>0&&more.push({...s,nodes:rest})}return{strip,more}}function sheet(model){let strip=stripOf(model),root=[],rest=clipboardRest(model);for(let s of model.sections){let nodes=s.group==="clipboard"&&!s.primary?rest:s.nodes;rowCount(nodes)!==0&&(root.length&&root.push({kind:"separator",id:`${s.id}:sep`}),s.primary||!s.label||rowCount(nodes)<=3?(s.label&&root.push({kind:"label",id:`${s.id}:label`,label:s.label}),root.push(...nodes)):root.push(fold({...s,label:s.label,nodes})))}return{strip,root}}function palette(model){let leaves=[],walk=(nodes,trail)=>{for(let n of nodes)isLeaf(n)?leaves.push({node:n,breadcrumb:trail}):n.kind==="submenu"&&(n.lazy?leaves.push({node:n,breadcrumb:trail}):walk(n.children,[...trail,n.label]))};for(let s of model.sections)walk(s.nodes,s.label?[s.label]:[]);return{leaves}}function filterPalette(arranged,query){let words=query.toLowerCase().split(/\s+/).filter(Boolean);return words.length?{leaves:arranged.leaves.filter(l=>{let hay=`${l.node.label} ${l.breadcrumb.join(" ")}`.toLowerCase();return words.every(w=>hay.includes(w))})}:arranged}var layouts={bar,overflow,context,selectionToolbar,sheet,palette};var PLATFORM_MENU_LAYOUT={context:"command",density:"comfortable"},MENU_LAYOUT_SETTING="alchemy.menu.layout",ARRANGEMENTS=new Set(["classic","tiered","command"]),DENSITIES=new Set(["comfortable","compact"]);async function resolveMenuLayout(ports,organizationId){let org=ports.knobs?.layout(organizationId)??null,base={...PLATFORM_MENU_LAYOUT,...org??{}},own=null;try{own=await ports.persistence?.readSetting(MENU_LAYOUT_SETTING)??null}catch{own=null}if(own&&typeof own=="object"&&!Array.isArray(own)){let o=own;return{context:typeof o.context=="string"&&ARRANGEMENTS.has(o.context)?o.context:base.context,density:typeof o.density=="string"&&DENSITIES.has(o.density)?o.density:base.density}}return base}export{APPROVED_HEADINGS,CATEGORY_GROUP,GROUP_ORDER,INLINE_SECTION_MAX,MENU_LAYOUT_SETTING,PLATFORM_MENU_LAYOUT,UnapprovedHeadingError,actionToNode,bar,buildMenuModel,context,defaultHeadingPolicy,filterPalette,findNode,foldUnderSubject,isApprovedHeading,isContainerWord,layouts,leafIds,menuHeadings,overflow,palette,resolveMenuLayout,sectionLabel,selectionToolbar,sheet,unapprovedHeadings,withExpandedChildren};
|
|
1
|
+
var APPROVED_HEADINGS=new Set(["Save","Copy as","Export","Edit","Creator tools","Admin","App","Compare","History"]),CONTAINER_WORD=/^(more|more…|more\.\.\.|other|others|misc|miscellaneous|additional|extra|extras|actions|options|advanced|stuff|everything else)$/i,TARGET_SHAPE=/^(Cell|Row|Column|Table|Range|Selection|Record) · .+$/;function isContainerWord(label){return CONTAINER_WORD.test(label.trim())}function isApprovedHeading(label,kind="group",approved=APPROVED_HEADINGS){let l=label.trim();return!l||isContainerWord(l)?!1:approved.has(l)?!0:kind==="target"||TARGET_SHAPE.test(l)}function defaultHeadingPolicy(){return globalThis.process?.env?.NODE_ENV==="production"?"inline":"throw"}var UnapprovedHeadingError=class extends Error{heading;constructor(heading,where){super(`Menu heading "${heading}" (${where}) is not an approved heading. Remedy: show these rows inline \u2014 declare no section (or kind "target" for the clicked thing's own label) \u2014 or ask Arman to add the name to APPROVED_HEADINGS in @ai-matrx/alchemy/menu. A generic container word ("More\u2026", "Other") is never approved.`),this.name="UnapprovedHeadingError",this.heading=heading}};function menuHeadings(model){let out=[],walk=nodes=>{for(let n of nodes)n.kind==="submenu"&&(out.push(n.label),walk(n.children))};for(let s of model.sections)s.label&&out.push(s.label),walk(s.nodes);return[...new Set(out)]}function unapprovedHeadings(model,approved=APPROVED_HEADINGS){let out=new Set;for(let s of model.sections){s.label&&!isApprovedHeading(s.label,s.primary||s.target?"target":"group",approved)&&out.add(s.label);let walk=nodes=>{for(let n of nodes)n.kind==="submenu"&&(isContainerWord(n.label)&&out.add(n.label),walk(n.children))};walk(s.nodes)}return[...out]}var CATEGORY_GROUP={clipboard:"clipboard",copy:"transfer",export:"transfer",save:"document",share:"document",edit:"editable",history:"history",ai:"ai",ask:"ai",listen:"tools",study:"tools",app:"tools",applet:"tools",feedback:"quick",creator:"admin",admin:"admin","surface-info":"surface-info"},GROUP_ORDER=["clipboard","editable","transfer","document","history","ai","tools","quick","surface","admin","surface-info"],CATEGORY_ORDER=["clipboard","edit","copy","export","save","share","history","ask","ai","listen","study","app","applet","feedback","creator","admin","surface-info"];function translate(i18n,key,fallback){if(!i18n)return fallback;try{return i18n.t(key,fallback)}catch{return fallback}}function actionToNode(resolved,target,options={}){let{action,eligibility}=resolved,rawLabel=typeof action.label=="function"?action.label(target):action.label,label=translate(options.i18n,action.labelKey??action.id,rawLabel),base={id:action.id,actionId:action.id,...action.icon!==void 0?{icon:action.icon}:{},...action.placement!==void 0?{placement:action.placement}:{}};if(action.expand)return{...base,kind:"submenu",label,lazy:!0,loading:!1,...action.pending?.(target)?{pending:!0}:{},children:[],...action.emptyLabel!==void 0?{emptyLabel:action.emptyLabel}:{}};if(action.href!==void 0){let href=typeof action.href=="function"?action.href(target):action.href;return{...base,kind:"link",label,href}}if(action.toggle)return{...base,kind:"checkbox",label,checked:action.pressed?.(target)??!1,...action.description!==void 0?{description:action.description}:{}};let state=action.stateIcon?.(target)??null,pressed=action.pressed?.(target),hint=action.hint!==void 0?translate(options.i18n,action.hintKey??`${action.id}.hint`,action.hint):void 0;return{...base,kind:"item",label,...action.iconTone!==void 0?{iconTone:action.iconTone}:{},...state?{stateIcon:state}:{},...action.description!==void 0?{description:action.description}:{},...hint!==void 0?{hint}:{},...pressed!==void 0?{pressed}:{},...action.destructive?{destructive:!0}:{},...action.preserveSelection?{preserveSelection:!0}:{},...action.keepsMenuOpen?{keepsMenuOpen:!0}:{},...eligibility.status==="unavailable-verb"||eligibility.status==="unavailable"?{unavailable:{sentence:eligibility.sentence}}:{}}}function buildMenuModel(target,resolved,options={}){let policy=options.headingPolicy??defaultHeadingPolicy();resolved=resolved.map(r=>{let sec=r.action.section;if(r.action.expand&&isContainerWord(typeof r.action.label=="string"?r.action.label:"")&&policy==="throw")throw new UnapprovedHeadingError(r.action.label,`submenu of ${r.action.id}`);if(!sec)return r;let kind=sec.kind??(sec.primary?"target":"group");if(isApprovedHeading(sec.label,kind))return r;if(policy==="throw")throw new UnapprovedHeadingError(sec.label,`section of ${r.action.id}`);let{section:_dropped,...rest}=r.action;return{...r,action:rest}});let ordered=resolved.map((r,index)=>({r,index})).sort((a,b)=>{let ca=CATEGORY_ORDER.indexOf(a.r.action.category),cb=CATEGORY_ORDER.indexOf(b.r.action.category);if(ca!==cb)return ca-cb;let oa=a.r.action.order??0,ob=b.r.action.order??0;return oa!==ob?oa-ob:a.index-b.index}).map(x=>x.r),sections=new Map,roles={},explicit=new Map;resolved.forEach((r,index)=>{let sec=r.action.section;if(!sec)return;let entry=explicit.get(sec.id)??{group:CATEGORY_GROUP[r.action.category],rows:[]};entry.rows.push({r,index}),explicit.set(sec.id,entry)});let placed=new Set;for(let r of ordered){let sec=r.action.section;if(sec&&placed.has(sec.id))continue;let group=sec?explicit.get(sec.id)?.group??CATEGORY_GROUP[r.action.category]:CATEGORY_GROUP[r.action.category],sectionId=sec?`section:${sec.id}`:group,section=sections.get(sectionId);section||(section={id:sectionId,group,nodes:[],...sec?{label:translate(options.i18n,sec.labelKey??`section.${sec.id}`,sec.label)}:{},...sec?.icon!==void 0?{icon:sec.icon}:{},...sec?.primary?{primary:!0}:{},...sec&&(sec.kind??(sec.primary?"target":"group"))==="target"?{target:!0}:{}},sections.set(sectionId,section));let rows=sec?(explicit.get(sec.id)?.rows??[]).sort((x,y)=>(x.r.action.order??0)-(y.r.action.order??0)||x.index-y.index).map(x=>x.r):[r];sec&&placed.add(sec.id);for(let row of rows)row.action.startsGroup&§ion.nodes.length>0&§ion.nodes.push({kind:"separator",id:`${row.action.id}:group`}),section.nodes.push(actionToNode(row,target,options)),row.action.verb&&(roles[row.action.verb]=row.action.id)}let list=[...sections.values()].sort((a,b)=>!!a.primary!=!!b.primary?a.primary?-1:1:GROUP_ORDER.indexOf(a.group)-GROUP_ORDER.indexOf(b.group)),selected=target.selection?.text?.trim(),content=options.content?.trim(),fieldName=options.contentLabel?.trim();return{header:selected?{label:"Selected",text:target.selection?.text??""}:fieldName?{label:fieldName,text:options.content??""}:content?{label:"Content",text:options.content??""}:null,sections:list,roles}}function withExpandedChildren(model,nodeId,children){let visit=nodes=>nodes.map(n=>n.kind!=="submenu"?n:n.id===nodeId?children==="loading"?{...n,loading:!0}:{...n,lazy:!1,loading:!1,pending:!1,children}:{...n,children:visit(n.children)});return{...model,sections:model.sections.map(s=>({...s,nodes:visit(s.nodes)}))}}function findNode(nodes,id){for(let n of nodes){if(n.id===id)return n;if(n.kind==="submenu"){let hit=findNode(n.children,id);if(hit)return hit}}return null}var INLINE_SECTION_MAX=3;function sectionLabel(section){return section.label??null}function isLeaf(node){return node.kind==="item"||node.kind==="checkbox"||node.kind==="link"}function collect(nodes,out){for(let n of nodes)isLeaf(n)?out.push(n.id):n.kind==="submenu"&&(n.lazy?out.push(n.id):collect(n.children,out))}function leafIds(arranged){let out=[];if(Array.isArray(arranged))for(let s of arranged)collect(s.nodes,out);else if("leaves"in arranged)for(let l of arranged.leaves)out.push(l.node.id);else if("primary"in arranged&&"overflow"in arranged){collect(arranged.primary,out);for(let s of arranged.overflow)collect(s.nodes,out)}else if("root"in arranged)collect(arranged.strip,out),collect(arranged.root,out);else if("more"in arranged){collect(arranged.strip,out);for(let s of arranged.more)collect(s.nodes,out)}else if("filterable"in arranged){collect(arranged.strip,out);for(let s of arranged.sections)collect(s.nodes,out)}else for(let s of arranged.sections)collect(s.nodes,out);return[...new Set(out)].sort()}function fold(section){return{kind:"submenu",id:`${section.id}:fold`,label:section.label,...section.icon!==void 0?{icon:section.icon}:{},children:section.nodes}}function rowCount(nodes){return nodes.filter(n=>n.kind!=="separator"&&n.kind!=="label").length}function stripOf(model){let clipboard=model.sections.find(s=>s.group==="clipboard"&&!s.primary);return clipboard?clipboard.nodes.filter(isLeaf):[]}function clipboardRest(model){let clipboard=model.sections.find(s=>s.group==="clipboard"&&!s.primary);return clipboard?clipboard.nodes.filter(n=>!isLeaf(n)&&n.kind==="submenu"):[]}function placementOf(node){return"placement"in node&&node.placement?node.placement:"overflow"}function classic(model){return{strip:[],sections:model.sections,filterable:!1}}function tiered(model,filterable){let strip=stripOf(model),sections=[],rest=clipboardRest(model);for(let s of model.sections){if(s.group==="clipboard"&&!s.primary){rest.length&§ions.push({...s,nodes:rest});continue}if(s.primary){sections.push(s);continue}if(!s.label||s.group==="surface-info"||rowCount(s.nodes)<=3){sections.push(s);continue}sections.push({id:s.id,group:s.group,nodes:[fold({...s,label:s.label})]})}return{strip,sections,filterable}}function context(model,arrangement){return arrangement==="classic"?classic(model):tiered(model,arrangement==="command")}function foldUnderSubject(arranged,subject){let label=subject.trim(),primary=arranged.sections.filter(s=>s.primary),rest=arranged.sections.filter(s=>!s.primary);if(!label||primary.length===0||rest.length===0&&arranged.strip.length===0)return arranged;let children=[];arranged.strip.length&&children.push(...arranged.strip);for(let s of rest)rowCount(s.nodes)!==0&&(children.length&&children.push({kind:"separator",id:`${s.id}:subject-sep`}),s.label&&children.push({kind:"label",id:`${s.id}:subject-label`,label:s.label}),children.push(...s.nodes));return rowCount(children)===0?{...arranged,strip:[]}:{strip:[],filterable:!1,sections:[...primary,{id:"subject",group:rest[0]?.group??primary[0].group,nodes:[{kind:"submenu",id:"subject:fold",label,children}]}]}}function foldNamed(sections){return sections.map(s=>s.label&&!s.primary&&rowCount(s.nodes)>3?{id:s.id,group:s.group,nodes:[fold({...s,label:s.label})]}:s)}function overflow(model){return foldNamed(model.sections)}function bar(model,_options={}){let primary=[],overflowSections=[];for(let s of model.sections){let rest=[];for(let n of s.nodes){if(n.kind==="separator"||n.kind==="label"){rest.push(n);continue}let p=placementOf(n);(p==="primary"||p==="both")&&primary.push(n),(p==="overflow"||p==="both")&&rest.push(n)}rowCount(rest)>0&&overflowSections.push({...s,nodes:rest})}return{primary,overflow:foldNamed(overflowSections)}}function selectionToolbar(model){let strip=[],more=[];for(let s of model.sections){let rest=[];for(let n of s.nodes)s.group==="clipboard"&&!s.primary&&isLeaf(n)||placementOf(n)!=="overflow"?strip.push(n):rest.push(n);rowCount(rest)>0&&more.push({...s,nodes:rest})}return{strip,more}}function sheet(model){let strip=stripOf(model),root=[],rest=clipboardRest(model);for(let s of model.sections){let nodes=s.group==="clipboard"&&!s.primary?rest:s.nodes;rowCount(nodes)!==0&&(root.length&&root.push({kind:"separator",id:`${s.id}:sep`}),s.primary||!s.label||rowCount(nodes)<=3?(s.label&&root.push({kind:"label",id:`${s.id}:label`,label:s.label}),root.push(...nodes)):root.push(fold({...s,label:s.label,nodes})))}return{strip,root}}function palette(model){let leaves=[],walk=(nodes,trail)=>{for(let n of nodes)isLeaf(n)?leaves.push({node:n,breadcrumb:trail}):n.kind==="submenu"&&(n.lazy?leaves.push({node:n,breadcrumb:trail}):walk(n.children,[...trail,n.label]))};for(let s of model.sections)walk(s.nodes,s.label?[s.label]:[]);return{leaves}}function filterPalette(arranged,query){let words=query.toLowerCase().split(/\s+/).filter(Boolean);return words.length?{leaves:arranged.leaves.filter(l=>{let hay=`${l.node.label} ${l.breadcrumb.join(" ")}`.toLowerCase();return words.every(w=>hay.includes(w))})}:arranged}var layouts={bar,overflow,context,selectionToolbar,sheet,palette};var PLATFORM_MENU_LAYOUT={context:"command",density:"comfortable"},MENU_LAYOUT_SETTING="alchemy.menu.layout",ARRANGEMENTS=new Set(["classic","tiered","command"]),DENSITIES=new Set(["comfortable","compact"]);async function resolveMenuLayout(ports,organizationId){let org=ports.knobs?.layout(organizationId)??null,base={...PLATFORM_MENU_LAYOUT,...org??{}},own=null;try{own=await ports.persistence?.readSetting(MENU_LAYOUT_SETTING)??null}catch{own=null}if(own&&typeof own=="object"&&!Array.isArray(own)){let o=own;return{context:typeof o.context=="string"&&ARRANGEMENTS.has(o.context)?o.context:base.context,density:typeof o.density=="string"&&DENSITIES.has(o.density)?o.density:base.density}}return base}export{APPROVED_HEADINGS,CATEGORY_GROUP,GROUP_ORDER,INLINE_SECTION_MAX,MENU_LAYOUT_SETTING,PLATFORM_MENU_LAYOUT,UnapprovedHeadingError,actionToNode,bar,buildMenuModel,context,defaultHeadingPolicy,filterPalette,findNode,foldUnderSubject,isApprovedHeading,isContainerWord,layouts,leafIds,menuHeadings,overflow,palette,resolveMenuLayout,sectionLabel,selectionToolbar,sheet,unapprovedHeadings,withExpandedChildren};
|
|
2
2
|
//# sourceMappingURL=menu.js.map
|
package/dist/menu.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/menu/headings.ts","../src/menu/model.ts","../src/menu/layouts.ts","../src/menu/knobs.ts"],"sourcesContent":["/**\n * THE ONE APPROVED-HEADING LIST (ALC-15, chair rulings 7 and D1; the Lossless\n * Law and the vocabulary law). A heading a person sees above or around rows\n * must be a name the classic menus used before agents started coining names.\n *\n * 🚨 ADDING A HEADING TO THIS LIST IS ARMAN'S CALL — never an agent's.\n *\n * Two kinds of section heading exist:\n * - a GROUP heading (\"Copy as\", \"History\"): must be in APPROVED_HEADINGS;\n * - a TARGET label, the thing the person clicked, supplied by the surface at\n * run time (\"Cell · Visit date\", \"Row · Widget A\", \"This finding\", the\n * surface's own label): allowed as declared (`section.kind: \"target\"`, or\n * the \"<Target> · <name>\" shape), except a generic container word.\n * A generic container word (\"More…\", \"Other\", \"Actions\") is never a heading.\n * An unapproved heading renders its rows INLINE in production; in development\n * and tests `buildMenuModel` throws with the remedy.\n */\nimport type { MenuModel, MenuNode } from \"./types\";\n\n/** Names with their provenance (the commit where each classic menu used them). */\nexport const APPROVED_HEADINGS: ReadonlySet<string> = new Set([\n \"Save\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Copy as\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Export\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Edit\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Creator tools\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Admin\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"App\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Compare\", // rich-document menuStructure, 2e3a8a9fdf (2026-06-11)\n \"History\", // context-menu-v3 tiered layout — the one grouping Arman approved, 2026-08-22\n]);\n\n// Ruling (chair, 2026-09-26, per R26): \"Conversation\" is a TARGET label (`kind: \"target\"`) — it names the thing its rows act on (the whole conversation), like \"Cell · …\" and \"Table · …\"; it is not a group heading and is not added above.\n\nconst CONTAINER_WORD =\n /^(more|more…|more\\.\\.\\.|other|others|misc|miscellaneous|additional|extra|extras|actions|options|advanced|stuff|everything else)$/i;\n\n/** \"Cell · Visit date\", \"Row · Widget A\", \"Column · Price\", \"Table · Route sheet\". */\nconst TARGET_SHAPE = /^(Cell|Row|Column|Table|Range|Selection|Record) · .+$/;\n\nexport function isContainerWord(label: string): boolean {\n return CONTAINER_WORD.test(label.trim());\n}\n\nexport type HeadingKind = \"group\" | \"target\";\n\n/** Is this heading allowed? */\nexport function isApprovedHeading(label: string, kind: HeadingKind = \"group\", approved: ReadonlySet<string> = APPROVED_HEADINGS): boolean {\n const l = label.trim();\n if (!l || isContainerWord(l)) return false;\n if (approved.has(l)) return true;\n return kind === \"target\" || TARGET_SHAPE.test(l);\n}\n\nexport type HeadingPolicy = \"throw\" | \"inline\";\n\n/** Development and tests throw; production shows the rows inline. */\nexport function defaultHeadingPolicy(): HeadingPolicy {\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.NODE_ENV;\n return env === \"production\" ? \"inline\" : \"throw\";\n}\n\nexport class UnapprovedHeadingError extends Error {\n readonly heading: string;\n constructor(heading: string, where: string) {\n super(\n `Menu heading \"${heading}\" (${where}) is not an approved heading. Remedy: show these rows inline — declare no section ` +\n `(or kind \"target\" for the clicked thing's own label) — or ask Arman to add the name to APPROVED_HEADINGS in ` +\n `@ai-matrx/alchemy/menu. A generic container word (\"More…\", \"Other\") is never approved.`,\n );\n this.name = \"UnapprovedHeadingError\";\n this.heading = heading;\n }\n}\n\n/** Every heading in a model: section labels, folds, and submenu rows at any depth. */\nexport function menuHeadings(model: Pick<MenuModel, \"sections\">): string[] {\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind === \"submenu\") {\n out.push(n.label);\n walk(n.children);\n }\n }\n };\n for (const s of model.sections) {\n if (s.label) out.push(s.label);\n walk(s.nodes);\n }\n return [...new Set(out)];\n}\n\n/** Section headings not in the approved set (container words are never approved). */\nexport function unapprovedHeadings(model: Pick<MenuModel, \"sections\">, approved: ReadonlySet<string> = APPROVED_HEADINGS): string[] {\n const out = new Set<string>();\n for (const s of model.sections) {\n if (s.label && !isApprovedHeading(s.label, s.primary || s.target ? \"target\" : \"group\", approved)) out.add(s.label);\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) if (n.kind === \"submenu\") {\n if (isContainerWord(n.label)) out.add(n.label);\n walk(n.children);\n }\n };\n walk(s.nodes);\n }\n return [...out];\n}\n","/**\n * buildMenuModel — WHAT exists at a click target, as one framework-neutral\n * tree (CONTRACT §2.5). Categories GROUP, never gate: eligibility already ran\n * in the registry; this only arranges the resolved set into sections.\n */\nimport type { Action, ActionCategory, ClickTarget, ResolvedAction } from \"../actions/types\";\nimport type { I18nPort } from \"../ports\";\nimport type { MenuGroup, MenuModel, MenuNode, MenuSection, MenuSubmenuNode } from \"./types\";\nimport { UnapprovedHeadingError, defaultHeadingPolicy, isApprovedHeading, isContainerWord, type HeadingPolicy } from \"./headings\";\n\n/** THE category → menu group table (CONTRACT §2.5). */\nexport const CATEGORY_GROUP: Readonly<Record<ActionCategory, MenuGroup>> = {\n clipboard: \"clipboard\",\n copy: \"transfer\",\n export: \"transfer\",\n save: \"document\",\n share: \"document\",\n edit: \"editable\",\n history: \"history\",\n ai: \"ai\",\n ask: \"ai\",\n listen: \"tools\",\n study: \"tools\",\n app: \"tools\",\n feedback: \"quick\",\n creator: \"admin\",\n admin: \"admin\",\n \"surface-info\": \"surface-info\",\n};\n\n/** Classic order of the groups. `surface-info` is engine-built and always last. */\nexport const GROUP_ORDER: readonly MenuGroup[] = [\n \"clipboard\",\n \"editable\",\n \"transfer\",\n \"document\",\n \"history\",\n \"ai\",\n \"tools\",\n \"quick\",\n \"surface\",\n \"admin\",\n \"surface-info\",\n];\n\nconst CATEGORY_ORDER: readonly ActionCategory[] = [\n \"clipboard\",\n \"edit\",\n \"copy\",\n \"export\",\n \"save\",\n \"share\",\n \"history\",\n \"ask\",\n \"ai\",\n \"listen\",\n \"study\",\n \"app\",\n \"feedback\",\n \"creator\",\n \"admin\",\n \"surface-info\",\n];\n\nexport interface BuildMenuModelOptions {\n /** What an unapproved heading does: \"throw\" (development/tests) or \"inline\" (production). */\n headingPolicy?: HeadingPolicy;\n i18n?: I18nPort;\n /** Content the menu acts on when nothing is selected. */\n content?: string | null;\n /**\n * The name of the field the content is (a text box's label, \"Body\"). The\n * header then names the field — never \"Content: {{reply.body}}\", its raw text.\n */\n contentLabel?: string | null;\n}\n\nfunction translate(i18n: I18nPort | undefined, key: string, fallback: string): string {\n if (!i18n) return fallback;\n try {\n return i18n.t(key, fallback);\n } catch {\n return fallback;\n }\n}\n\n/** One resolved action → one model node (item, checkbox, link or lazy submenu). */\nexport function actionToNode(\n resolved: ResolvedAction,\n target: ClickTarget,\n options: BuildMenuModelOptions = {},\n): MenuNode {\n const { action, eligibility } = resolved;\n const rawLabel = typeof action.label === \"function\" ? action.label(target) : action.label;\n const label = translate(options.i18n, action.labelKey ?? action.id, rawLabel);\n const base = {\n id: action.id,\n actionId: action.id,\n ...(action.icon !== undefined ? { icon: action.icon } : {}),\n ...(action.placement !== undefined ? { placement: action.placement } : {}),\n };\n if (action.expand) {\n const node: MenuSubmenuNode = {\n ...base,\n kind: \"submenu\",\n label,\n lazy: true,\n loading: false,\n ...(action.pending?.(target) ? { pending: true } : {}),\n children: [],\n ...(action.emptyLabel !== undefined ? { emptyLabel: action.emptyLabel } : {}),\n };\n return node;\n }\n if (action.href !== undefined) {\n const href = typeof action.href === \"function\" ? action.href(target) : action.href;\n return { ...base, kind: \"link\", label, href };\n }\n if (action.toggle) {\n return {\n ...base,\n kind: \"checkbox\",\n label,\n checked: action.pressed?.(target) ?? false,\n ...(action.description !== undefined ? { description: action.description } : {}),\n };\n }\n const state = action.stateIcon?.(target) ?? null;\n const pressed = action.pressed?.(target);\n const hint = action.hint !== undefined ? translate(options.i18n, action.hintKey ?? `${action.id}.hint`, action.hint) : undefined;\n return {\n ...base,\n kind: \"item\",\n label,\n ...(action.iconTone !== undefined ? { iconTone: action.iconTone } : {}),\n ...(state ? { stateIcon: state } : {}),\n ...(action.description !== undefined ? { description: action.description } : {}),\n ...(hint !== undefined ? { hint } : {}),\n ...(pressed !== undefined ? { pressed } : {}),\n ...(action.destructive ? { destructive: true } : {}),\n ...(action.preserveSelection ? { preserveSelection: true } : {}),\n ...(action.keepsMenuOpen ? { keepsMenuOpen: true } : {}),\n ...(eligibility.status === \"unavailable-verb\" || eligibility.status === \"unavailable\"\n ? { unavailable: { sentence: eligibility.sentence } }\n : {}),\n };\n}\n\nexport function buildMenuModel(\n target: ClickTarget,\n resolved: readonly ResolvedAction[],\n options: BuildMenuModelOptions = {},\n): MenuModel {\n // THE ONE HEADING CHECK, for every host: an unapproved heading's rows go\n // inline (production) or the build throws with the remedy (dev/tests).\n const policy = options.headingPolicy ?? defaultHeadingPolicy();\n resolved = resolved.map((r) => {\n const sec = r.action.section;\n if (r.action.expand && isContainerWord(typeof r.action.label === \"string\" ? r.action.label : \"\") && policy === \"throw\") {\n throw new UnapprovedHeadingError(r.action.label as string, `submenu of ${r.action.id}`);\n }\n if (!sec) return r;\n const kind = sec.kind ?? (sec.primary ? \"target\" : \"group\");\n if (isApprovedHeading(sec.label, kind)) return r;\n if (policy === \"throw\") throw new UnapprovedHeadingError(sec.label, `section of ${r.action.id}`);\n const { section: _dropped, ...rest } = r.action;\n return { ...r, action: rest };\n });\n const ordered = resolved\n .map((r, index) => ({ r, index }))\n .sort((a, b) => {\n const ca = CATEGORY_ORDER.indexOf(a.r.action.category);\n const cb = CATEGORY_ORDER.indexOf(b.r.action.category);\n if (ca !== cb) return ca - cb;\n const oa = a.r.action.order ?? 0;\n const ob = b.r.action.order ?? 0;\n if (oa !== ob) return oa - ob;\n return a.index - b.index;\n })\n .map((x) => x.r);\n\n const sections = new Map<string, MenuSection>();\n const roles: Record<string, string> = {};\n // An explicit section sits in the group of its first-registered action and\n // keeps its own row order (order, then registration) across categories.\n const explicit = new Map<string, { group: MenuGroup; rows: { r: ResolvedAction; index: number }[] }>();\n resolved.forEach((r, index) => {\n const sec = r.action.section;\n if (!sec) return;\n const entry = explicit.get(sec.id) ?? { group: CATEGORY_GROUP[r.action.category], rows: [] };\n entry.rows.push({ r, index });\n explicit.set(sec.id, entry);\n });\n const placed = new Set<string>();\n for (const r of ordered) {\n const sec = r.action.section;\n if (sec && placed.has(sec.id)) continue;\n const group = sec ? (explicit.get(sec.id)?.group ?? CATEGORY_GROUP[r.action.category]) : CATEGORY_GROUP[r.action.category];\n const sectionId = sec ? `section:${sec.id}` : group;\n let section = sections.get(sectionId);\n if (!section) {\n section = {\n id: sectionId,\n group,\n nodes: [],\n ...(sec ? { label: translate(options.i18n, sec.labelKey ?? `section.${sec.id}`, sec.label) } : {}),\n ...(sec?.icon !== undefined ? { icon: sec.icon } : {}),\n ...(sec?.primary ? { primary: true } : {}),\n ...(sec && (sec.kind ?? (sec.primary ? \"target\" : \"group\")) === \"target\" ? { target: true } : {}),\n };\n sections.set(sectionId, section);\n }\n const rows = sec\n ? (explicit.get(sec.id)?.rows ?? [])\n .sort((x, y) => (x.r.action.order ?? 0) - (y.r.action.order ?? 0) || x.index - y.index)\n .map((x) => x.r)\n : [r];\n if (sec) placed.add(sec.id);\n for (const row of rows) {\n if (row.action.startsGroup && section.nodes.length > 0) {\n section.nodes.push({ kind: \"separator\", id: `${row.action.id}:group` });\n }\n section.nodes.push(actionToNode(row, target, options));\n if (row.action.verb) roles[row.action.verb] = row.action.id;\n }\n }\n\n const list = [...sections.values()].sort((a, b) => {\n if (Boolean(a.primary) !== Boolean(b.primary)) return a.primary ? -1 : 1;\n return GROUP_ORDER.indexOf(a.group) - GROUP_ORDER.indexOf(b.group);\n });\n\n const selected = target.selection?.text?.trim();\n const content = options.content?.trim();\n const fieldName = options.contentLabel?.trim();\n const header = selected\n ? { label: \"Selected\", text: target.selection?.text ?? \"\" }\n : fieldName\n ? { label: fieldName, text: options.content ?? \"\" }\n : content\n ? { label: \"Content\", text: options.content ?? \"\" }\n : null;\n\n return { header, sections: list, roles };\n}\n\n/** Fill a lazy submenu's rows once they load (pure: returns a new model). */\n/**\n * AN EXPANDED SUBMENU KEEPS ITS GROUPS (DATA-V2-BASICS-2, 2026-09-28). A provider's rows arrive flat,\n * so a submenu drew \"Highlight row\" and \"Delete row…\" as neighbours with no divider, while the same\n * rows in a top-level menu sit in their sections. A divider now goes wherever the rows' `section`\n * changes — a row with no section and a row with one are different groups too.\n */\nexport function withGroupDividers(children: readonly Action[], nodes: readonly MenuNode[]): MenuNode[] {\n const out: MenuNode[] = [];\n children.forEach((child, i) => {\n const node = nodes[i];\n if (!node) return;\n if (i > 0 && (child.startsGroup || (children[i - 1]!.section?.id ?? null) !== (child.section?.id ?? null))) {\n out.push({ kind: \"separator\", id: `${child.id}:group` });\n }\n out.push(node);\n });\n return out;\n}\n\nexport function withExpandedChildren(model: MenuModel, nodeId: string, children: MenuNode[] | \"loading\"): MenuModel {\n const visit = (nodes: MenuNode[]): MenuNode[] =>\n nodes.map((n) => {\n if (n.kind !== \"submenu\") return n;\n if (n.id === nodeId) {\n return children === \"loading\" ? { ...n, loading: true } : { ...n, lazy: false, loading: false, pending: false, children };\n }\n return { ...n, children: visit(n.children) };\n });\n return { ...model, sections: model.sections.map((s) => ({ ...s, nodes: visit(s.nodes) })) };\n}\n\n/** Find a node anywhere in a tree. */\nexport function findNode(nodes: readonly MenuNode[], id: string): MenuNode | null {\n for (const n of nodes) {\n if (n.id === id) return n;\n if (n.kind === \"submenu\") {\n const hit = findNode(n.children, id);\n if (hit) return hit;\n }\n }\n return null;\n}\n","/**\n * Layouts — pure arrangements of one MenuModel (CONTRACT §2.5).\n *\n * Every layout is a function over the SAME model: it decides which nodes sit\n * at the top level, which fold under a named submenu and which go into a\n * strip. None adds, drops or renames a leaf — `leafIds(arranged)` equals\n * `leafIds(model)` for every layout (THE LOSSLESS LAW, proven by test).\n *\n * The clipboard group IS the universal verb strip: in the strip layouts it is\n * drawn icon-only; elsewhere its rows are drawn in place. Unavailable verbs\n * (the only greyed nodes, R1 c) appear in every layout identically.\n */\nimport type {\n ArrangedBar,\n ArrangedContext,\n ArrangedPalette,\n ArrangedSelectionToolbar,\n ArrangedSheet,\n ContextArrangement,\n MenuLeafNode,\n MenuModel,\n MenuNode,\n MenuSection,\n MenuSubmenuNode,\n} from \"./types\";\n\n/** A section with more rows than this folds under its label in tiered/command/sheet. */\nexport const INLINE_SECTION_MAX = 3;\n\n/**\n * A section's heading is ONLY the name its actions declare (an approved\n * heading the classic menu already uses: \"Save as\", \"Copy as\", \"History\").\n * A group with no declared name has no heading and is never folded — its rows\n * show inline. The package never coins a heading (chair ruling, ALC-15).\n */\nexport function sectionLabel(section: MenuSection): string | null {\n return section.label ?? null;\n}\n\nfunction isLeaf(node: MenuNode): node is MenuLeafNode {\n return node.kind === \"item\" || node.kind === \"checkbox\" || node.kind === \"link\";\n}\n\n/** Every actionable id in a node list, depth-first. A lazy submenu counts as one leaf. */\nfunction collect(nodes: readonly MenuNode[], out: string[]): void {\n for (const n of nodes) {\n if (isLeaf(n)) out.push(n.id);\n else if (n.kind === \"submenu\") {\n if (n.lazy) out.push(n.id);\n else collect(n.children, out);\n }\n }\n}\n\ntype Arranged =\n | MenuModel\n | ArrangedBar\n | ArrangedContext\n | ArrangedSheet\n | ArrangedPalette\n | ArrangedSelectionToolbar\n | MenuSection[];\n\n/** Proof obligation for every layout: its leaf set equals the model's (sorted, de-duplicated). */\nexport function leafIds(arranged: Arranged): readonly string[] {\n const out: string[] = [];\n if (Array.isArray(arranged)) {\n for (const s of arranged) collect(s.nodes, out);\n } else if (\"leaves\" in arranged) {\n for (const l of arranged.leaves) out.push(l.node.id);\n } else if (\"primary\" in arranged && \"overflow\" in arranged) {\n collect(arranged.primary, out);\n for (const s of arranged.overflow) collect(s.nodes, out);\n } else if (\"root\" in arranged) {\n collect(arranged.strip, out);\n collect(arranged.root, out);\n } else if (\"more\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.more) collect(s.nodes, out);\n } else if (\"filterable\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.sections) collect(s.nodes, out);\n } else {\n for (const s of arranged.sections) collect(s.nodes, out);\n }\n return [...new Set(out)].sort();\n}\n\n/** Only a NAMED section folds; callers check `section.label` first. */\nfunction fold(section: MenuSection & { label: string }): MenuSubmenuNode {\n return {\n kind: \"submenu\",\n id: `${section.id}:fold`,\n label: section.label,\n ...(section.icon !== undefined ? { icon: section.icon } : {}),\n children: section.nodes,\n };\n}\n\nfunction rowCount(nodes: readonly MenuNode[]): number {\n return nodes.filter((n) => n.kind !== \"separator\" && n.kind !== \"label\").length;\n}\n\nfunction stripOf(model: MenuModel): MenuLeafNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter(isLeaf) : [];\n}\n\nfunction clipboardRest(model: MenuModel): MenuNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter((n) => !isLeaf(n) && n.kind === \"submenu\") : [];\n}\n\nfunction placementOf(node: MenuNode): \"primary\" | \"overflow\" | \"both\" {\n return \"placement\" in node && node.placement ? node.placement : \"overflow\";\n}\n\n/** The historical flat column: every section top-level. */\nfunction classic(model: MenuModel): ArrangedContext {\n return { strip: [], sections: model.sections, filterable: false };\n}\n\n/**\n * Tiered / command: the universal verbs as an icon strip; every other row by\n * its own name; the clicked target's (primary) section first, inline, heading\n * kept; a long non-primary section folds under ITS OWN label (never a coined\n * heading); History is the one approved grouping and already a group.\n */\nfunction tiered(model: MenuModel, filterable: boolean): ArrangedContext {\n const strip = stripOf(model);\n const sections: MenuSection[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n if (s.group === \"clipboard\" && !s.primary) {\n if (rest.length) sections.push({ ...s, nodes: rest });\n continue;\n }\n if (s.primary) {\n sections.push(s);\n continue;\n }\n if (!s.label || s.group === \"surface-info\" || rowCount(s.nodes) <= INLINE_SECTION_MAX) {\n // A section keeps its declared heading in EVERY layout (the Lossless\n // Law covers headings: ⋯, the bar's ⋯ and the phone sheet show it too).\n sections.push(s);\n continue;\n }\n sections.push({ id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] });\n }\n return { strip, sections, filterable };\n}\n\nexport function context(model: MenuModel, arrangement: ContextArrangement): ArrangedContext {\n if (arrangement === \"classic\") return classic(model);\n return tiered(model, arrangement === \"command\");\n}\n\n/**\n * FOLD UNDER THE SUBJECT — a control that belongs to a CONTAINER of the thing\n * (a tab's \"…\" over the note it shows) draws the container's own rows (the\n * primary sections) on top, and EVERY other row — the verb strip included —\n * under ONE submenu named for the subject (\"Note ▸\"). The label is the\n * subject's name the host supplies (the menu header's label), never a coined\n * group heading. Lossless: rows move, none is dropped or renamed. With no\n * primary section there is nothing to put first, so the arrangement is left\n * as it was. (page-pass /notes, 2026-09-28, Arman's ruling for the tab \"…\".)\n */\nexport function foldUnderSubject(arranged: ArrangedContext, subject: string): ArrangedContext {\n const label = subject.trim();\n const primary = arranged.sections.filter((s) => s.primary);\n const rest = arranged.sections.filter((s) => !s.primary);\n if (!label || primary.length === 0 || (rest.length === 0 && arranged.strip.length === 0)) return arranged;\n const children: MenuNode[] = [];\n if (arranged.strip.length) children.push(...arranged.strip);\n for (const s of rest) {\n if (rowCount(s.nodes) === 0) continue;\n if (children.length) children.push({ kind: \"separator\", id: `${s.id}:subject-sep` });\n if (s.label) children.push({ kind: \"label\", id: `${s.id}:subject-label`, label: s.label });\n children.push(...s.nodes);\n }\n if (rowCount(children) === 0) return { ...arranged, strip: [] };\n return {\n strip: [],\n filterable: false,\n sections: [\n ...primary,\n { id: \"subject\", group: rest[0]?.group ?? primary[0]!.group, nodes: [{ kind: \"submenu\", id: \"subject:fold\", label, children }] },\n ],\n };\n}\n\n/**\n * A long NAMED section folds under its own name (\"Save as ▸\", \"Copy as ▸\");\n * primary sections and unnamed groups stay inline. Folding moves rows, never\n * renames or drops them, and never under a coined heading.\n */\nfunction foldNamed(sections: readonly MenuSection[]): MenuSection[] {\n return sections.map((s) =>\n s.label && !s.primary && rowCount(s.nodes) > INLINE_SECTION_MAX ? { id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] } : s,\n );\n}\n\n/** ⋯ overflow: every section in classic order; long named sections fold under their own name. */\nexport function overflow(model: MenuModel): MenuSection[] {\n return foldNamed(model.sections);\n}\n\n/**\n * The action bar: primary buttons inline, EVERYTHING else under ⋯. A \"both\"\n * action is mirrored in both halves (the leaf set is still the model's).\n * `mini` changes presentation only (icon-only primaries), never membership.\n */\nexport function bar(model: MenuModel, _options: { mini?: boolean } = {}): ArrangedBar {\n const primary: MenuNode[] = [];\n const overflowSections: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n if (n.kind === \"separator\" || n.kind === \"label\") {\n rest.push(n);\n continue;\n }\n const p = placementOf(n);\n if (p === \"primary\" || p === \"both\") primary.push(n);\n if (p === \"overflow\" || p === \"both\") rest.push(n);\n }\n if (rowCount(rest) > 0) overflowSections.push({ ...s, nodes: rest });\n }\n return { primary, overflow: foldNamed(overflowSections) };\n}\n\n/** Selection toolbar: the verbs plus primary actions as a strip; the rest under More. */\nexport function selectionToolbar(model: MenuModel): ArrangedSelectionToolbar {\n const strip: MenuNode[] = [];\n const more: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n const inStrip = (s.group === \"clipboard\" && !s.primary && isLeaf(n)) || placementOf(n) !== \"overflow\";\n if (inStrip) strip.push(n);\n else rest.push(n);\n }\n if (rowCount(rest) > 0) more.push({ ...s, nodes: rest });\n }\n return { strip, more };\n}\n\n/**\n * Mobile bottom sheet: the verb strip on top; primary and short sections\n * inline; longer sections become one drill-down row named by the section.\n * Consumes the model directly, so it can never drift from desktop.\n */\nexport function sheet(model: MenuModel): ArrangedSheet {\n const strip = stripOf(model);\n const root: MenuNode[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n const nodes = s.group === \"clipboard\" && !s.primary ? rest : s.nodes;\n if (rowCount(nodes) === 0) continue;\n if (root.length) root.push({ kind: \"separator\", id: `${s.id}:sep` });\n if (s.primary || !s.label || rowCount(nodes) <= INLINE_SECTION_MAX) {\n if (s.label) root.push({ kind: \"label\", id: `${s.id}:label`, label: s.label });\n root.push(...nodes);\n } else {\n root.push(fold({ ...s, label: s.label, nodes }));\n }\n }\n return { strip, root };\n}\n\n/** Command palette: every leaf flattened with its breadcrumb (Linear). */\nexport function palette(model: MenuModel): ArrangedPalette {\n const leaves: ArrangedPalette[\"leaves\"] = [];\n const walk = (nodes: readonly MenuNode[], trail: string[]) => {\n for (const n of nodes) {\n if (isLeaf(n)) leaves.push({ node: n, breadcrumb: trail });\n else if (n.kind === \"submenu\") {\n if (n.lazy) leaves.push({ node: n, breadcrumb: trail });\n else walk(n.children, [...trail, n.label]);\n }\n }\n };\n for (const s of model.sections) walk(s.nodes, s.label ? [s.label] : []);\n return { leaves };\n}\n\n/**\n * A SEARCH REACHES EVERY ROW (clone 2026-10-01: \"Patient\" found nothing while\n * \"Patient reminder card\" sat under AI Actions ▸ My Personal). `palette` lists a\n * lazy submenu as ONE leaf — its label only — because its rows load on open.\n * A layout that searches opens every lazy submenu it can see: these are the\n * ones still to open (not already loading).\n */\nexport function lazySubmenuIds(model: MenuModel | null): string[] {\n if (!model) return [];\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind !== \"submenu\") continue;\n if (n.lazy) {\n if (!n.loading) out.push(n.id);\n } else walk(n.children);\n }\n };\n for (const s of model.sections) walk(s.nodes);\n return out;\n}\n\n/** True while some submenu's rows are not in the model yet (a search could still find more). */\nexport function paletteStillOpening(model: MenuModel | null): boolean {\n if (!model) return true;\n const walk = (nodes: readonly MenuNode[]): boolean =>\n nodes.some((n) => n.kind === \"submenu\" && (n.lazy || n.loading || n.pending || walk(n.children)));\n return model.sections.some((s) => walk(s.nodes));\n}\n\n/** Filter the palette by a query (every word must match label or breadcrumb). */\nexport function filterPalette(arranged: ArrangedPalette, query: string): ArrangedPalette {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (!words.length) return arranged;\n return {\n leaves: arranged.leaves.filter((l) => {\n const hay = `${l.node.label} ${l.breadcrumb.join(\" \")}`.toLowerCase();\n return words.every((w) => hay.includes(w));\n }),\n };\n}\n\nexport const layouts = { bar, overflow, context, selectionToolbar, sheet, palette };\n","/**\n * N9: layout and density are a PERSON's choice layered over the organization\n * default: persistence (\"alchemy.menu.layout\") → knobs.layout(org) → platform\n * default (command / comfortable, Arman 2026-08-22).\n */\nimport type { AlchemyHostPorts, ContextArrangementKnob, DensityKnob } from \"../ports\";\n\nexport const PLATFORM_MENU_LAYOUT: { context: ContextArrangementKnob; density: DensityKnob } = {\n context: \"command\",\n density: \"comfortable\",\n};\n\nexport const MENU_LAYOUT_SETTING = \"alchemy.menu.layout\";\n\nconst ARRANGEMENTS = new Set<string>([\"classic\", \"tiered\", \"command\"]);\nconst DENSITIES = new Set<string>([\"comfortable\", \"compact\"]);\n\nexport async function resolveMenuLayout(\n ports: Pick<AlchemyHostPorts, \"persistence\" | \"knobs\">,\n organizationId: string | null,\n): Promise<{ context: ContextArrangementKnob; density: DensityKnob }> {\n const org = ports.knobs?.layout(organizationId) ?? null;\n const base = { ...PLATFORM_MENU_LAYOUT, ...(org ?? {}) };\n let own: unknown = null;\n try {\n own = (await ports.persistence?.readSetting(MENU_LAYOUT_SETTING)) ?? null;\n } catch {\n own = null;\n }\n if (own && typeof own === \"object\" && !Array.isArray(own)) {\n const o = own as { context?: unknown; density?: unknown };\n return {\n context: typeof o.context === \"string\" && ARRANGEMENTS.has(o.context) ? (o.context as ContextArrangementKnob) : base.context,\n density: typeof o.density === \"string\" && DENSITIES.has(o.density) ? (o.density as DensityKnob) : base.density,\n };\n }\n return base;\n}\n"],"mappings":"AAoBO,IAAM,kBAAyC,IAAI,IAAI,CAC5D,OACA,UACA,SACA,OACA,gBACA,QACA,MACA,UACA,SACF,CAAC,EAIK,eACJ,oIAGI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AM,GAAG,EAAE,KAAK,KAAK,IAAI,EAAE,WAAW,KAAK,GAAG,CAAC,GAAG,YAAY,EACpE,OAAO,MAAM,MAAO,GAAM,IAAI,SAAS,CAAC,CAAC,CAC3C,CAAC,CACH,EAN0B,QAO5B,CAEO,IAAM,QAAU,CAAE,IAAK,SAAU,QAAS,iBAAkB,MAAO,OAAQ,ECjU3E,IAAM,qBAAkF,CAC7F,QAAS,UACT,QAAS,aACX,EAEa,oBAAsB,sBAE7B,aAAe,IAAI,IAAY,CAAC,UAAW,SAAU,SAAS,CAAC,EAC/D,UAAY,IAAI,IAAY,CAAC,cAAe,SAAS,CAAC,EAE5D,eAAsB,kBACpB,MACA,eACoE,CACpE,IAAM,IAAM,MAAM,OAAO,OAAO,cAAc,GAAK,KAC7C,KAAO,CAAE,GAAG,qBAAsB,GAAI,KAAO,CAAC,CAAG,EACnD,IAAe,KACnB,GAAI,CACF,IAAO,MAAM,MAAM,aAAa,YAAY,mBAAmB,GAAM,IACvE,MAAQ,CACN,IAAM,IACR,CACA,GAAI,KAAO,OAAO,KAAQ,UAAY,CAAC,MAAM,QAAQ,GAAG,EAAG,CACzD,IAAM,EAAI,IACV,MAAO,CACL,QAAS,OAAO,EAAE,SAAY,UAAY,aAAa,IAAI,EAAE,OAAO,EAAK,EAAE,QAAqC,KAAK,QACrH,QAAS,OAAO,EAAE,SAAY,UAAY,UAAU,IAAI,EAAE,OAAO,EAAK,EAAE,QAA0B,KAAK,OACzG,CACF,CACA,OAAO,IACT","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/menu/headings.ts","../src/menu/model.ts","../src/menu/layouts.ts","../src/menu/knobs.ts"],"sourcesContent":["/**\n * THE ONE APPROVED-HEADING LIST (ALC-15, chair rulings 7 and D1; the Lossless\n * Law and the vocabulary law). A heading a person sees above or around rows\n * must be a name the classic menus used before agents started coining names.\n *\n * 🚨 ADDING A HEADING TO THIS LIST IS ARMAN'S CALL — never an agent's.\n *\n * Two kinds of section heading exist:\n * - a GROUP heading (\"Copy as\", \"History\"): must be in APPROVED_HEADINGS;\n * - a TARGET label, the thing the person clicked, supplied by the surface at\n * run time (\"Cell · Visit date\", \"Row · Widget A\", \"This finding\", the\n * surface's own label): allowed as declared (`section.kind: \"target\"`, or\n * the \"<Target> · <name>\" shape), except a generic container word.\n * A generic container word (\"More…\", \"Other\", \"Actions\") is never a heading.\n * An unapproved heading renders its rows INLINE in production; in development\n * and tests `buildMenuModel` throws with the remedy.\n */\nimport type { MenuModel, MenuNode } from \"./types\";\n\n/** Names with their provenance (the commit where each classic menu used them). */\nexport const APPROVED_HEADINGS: ReadonlySet<string> = new Set([\n \"Save\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Copy as\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Export\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Edit\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Creator tools\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Admin\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"App\", // rich-document menuStructure, e5b8d01229 (2026-05-19)\n \"Compare\", // rich-document menuStructure, 2e3a8a9fdf (2026-06-11)\n \"History\", // context-menu-v3 tiered layout — the one grouping Arman approved, 2026-08-22\n]);\n\n// Ruling (chair, 2026-09-26, per R26): \"Conversation\" is a TARGET label (`kind: \"target\"`) — it names the thing its rows act on (the whole conversation), like \"Cell · …\" and \"Table · …\"; it is not a group heading and is not added above.\n\nconst CONTAINER_WORD =\n /^(more|more…|more\\.\\.\\.|other|others|misc|miscellaneous|additional|extra|extras|actions|options|advanced|stuff|everything else)$/i;\n\n/** \"Cell · Visit date\", \"Row · Widget A\", \"Column · Price\", \"Table · Route sheet\". */\nconst TARGET_SHAPE = /^(Cell|Row|Column|Table|Range|Selection|Record) · .+$/;\n\nexport function isContainerWord(label: string): boolean {\n return CONTAINER_WORD.test(label.trim());\n}\n\nexport type HeadingKind = \"group\" | \"target\";\n\n/** Is this heading allowed? */\nexport function isApprovedHeading(label: string, kind: HeadingKind = \"group\", approved: ReadonlySet<string> = APPROVED_HEADINGS): boolean {\n const l = label.trim();\n if (!l || isContainerWord(l)) return false;\n if (approved.has(l)) return true;\n return kind === \"target\" || TARGET_SHAPE.test(l);\n}\n\nexport type HeadingPolicy = \"throw\" | \"inline\";\n\n/** Development and tests throw; production shows the rows inline. */\nexport function defaultHeadingPolicy(): HeadingPolicy {\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.NODE_ENV;\n return env === \"production\" ? \"inline\" : \"throw\";\n}\n\nexport class UnapprovedHeadingError extends Error {\n readonly heading: string;\n constructor(heading: string, where: string) {\n super(\n `Menu heading \"${heading}\" (${where}) is not an approved heading. Remedy: show these rows inline — declare no section ` +\n `(or kind \"target\" for the clicked thing's own label) — or ask Arman to add the name to APPROVED_HEADINGS in ` +\n `@ai-matrx/alchemy/menu. A generic container word (\"More…\", \"Other\") is never approved.`,\n );\n this.name = \"UnapprovedHeadingError\";\n this.heading = heading;\n }\n}\n\n/** Every heading in a model: section labels, folds, and submenu rows at any depth. */\nexport function menuHeadings(model: Pick<MenuModel, \"sections\">): string[] {\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind === \"submenu\") {\n out.push(n.label);\n walk(n.children);\n }\n }\n };\n for (const s of model.sections) {\n if (s.label) out.push(s.label);\n walk(s.nodes);\n }\n return [...new Set(out)];\n}\n\n/** Section headings not in the approved set (container words are never approved). */\nexport function unapprovedHeadings(model: Pick<MenuModel, \"sections\">, approved: ReadonlySet<string> = APPROVED_HEADINGS): string[] {\n const out = new Set<string>();\n for (const s of model.sections) {\n if (s.label && !isApprovedHeading(s.label, s.primary || s.target ? \"target\" : \"group\", approved)) out.add(s.label);\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) if (n.kind === \"submenu\") {\n if (isContainerWord(n.label)) out.add(n.label);\n walk(n.children);\n }\n };\n walk(s.nodes);\n }\n return [...out];\n}\n","/**\n * buildMenuModel — WHAT exists at a click target, as one framework-neutral\n * tree (CONTRACT §2.5). Categories GROUP, never gate: eligibility already ran\n * in the registry; this only arranges the resolved set into sections.\n */\nimport type { Action, ActionCategory, ClickTarget, ResolvedAction } from \"../actions/types\";\nimport type { I18nPort } from \"../ports\";\nimport type { MenuGroup, MenuModel, MenuNode, MenuSection, MenuSubmenuNode } from \"./types\";\nimport { UnapprovedHeadingError, defaultHeadingPolicy, isApprovedHeading, isContainerWord, type HeadingPolicy } from \"./headings\";\n\n/** THE category → menu group table (CONTRACT §2.5). */\nexport const CATEGORY_GROUP: Readonly<Record<ActionCategory, MenuGroup>> = {\n clipboard: \"clipboard\",\n copy: \"transfer\",\n export: \"transfer\",\n save: \"document\",\n share: \"document\",\n edit: \"editable\",\n history: \"history\",\n ai: \"ai\",\n ask: \"ai\",\n listen: \"tools\",\n study: \"tools\",\n app: \"tools\",\n applet: \"tools\",\n feedback: \"quick\",\n creator: \"admin\",\n admin: \"admin\",\n \"surface-info\": \"surface-info\",\n};\n\n/** Classic order of the groups. `surface-info` is engine-built and always last. */\nexport const GROUP_ORDER: readonly MenuGroup[] = [\n \"clipboard\",\n \"editable\",\n \"transfer\",\n \"document\",\n \"history\",\n \"ai\",\n \"tools\",\n \"quick\",\n \"surface\",\n \"admin\",\n \"surface-info\",\n];\n\nconst CATEGORY_ORDER: readonly ActionCategory[] = [\n \"clipboard\",\n \"edit\",\n \"copy\",\n \"export\",\n \"save\",\n \"share\",\n \"history\",\n \"ask\",\n \"ai\",\n \"listen\",\n \"study\",\n \"app\",\n \"applet\",\n \"feedback\",\n \"creator\",\n \"admin\",\n \"surface-info\",\n];\n\nexport interface BuildMenuModelOptions {\n /** What an unapproved heading does: \"throw\" (development/tests) or \"inline\" (production). */\n headingPolicy?: HeadingPolicy;\n i18n?: I18nPort;\n /** Content the menu acts on when nothing is selected. */\n content?: string | null;\n /**\n * The name of the field the content is (a text box's label, \"Body\"). The\n * header then names the field — never \"Content: {{reply.body}}\", its raw text.\n */\n contentLabel?: string | null;\n}\n\nfunction translate(i18n: I18nPort | undefined, key: string, fallback: string): string {\n if (!i18n) return fallback;\n try {\n return i18n.t(key, fallback);\n } catch {\n return fallback;\n }\n}\n\n/** One resolved action → one model node (item, checkbox, link or lazy submenu). */\nexport function actionToNode(\n resolved: ResolvedAction,\n target: ClickTarget,\n options: BuildMenuModelOptions = {},\n): MenuNode {\n const { action, eligibility } = resolved;\n const rawLabel = typeof action.label === \"function\" ? action.label(target) : action.label;\n const label = translate(options.i18n, action.labelKey ?? action.id, rawLabel);\n const base = {\n id: action.id,\n actionId: action.id,\n ...(action.icon !== undefined ? { icon: action.icon } : {}),\n ...(action.placement !== undefined ? { placement: action.placement } : {}),\n };\n if (action.expand) {\n const node: MenuSubmenuNode = {\n ...base,\n kind: \"submenu\",\n label,\n lazy: true,\n loading: false,\n ...(action.pending?.(target) ? { pending: true } : {}),\n children: [],\n ...(action.emptyLabel !== undefined ? { emptyLabel: action.emptyLabel } : {}),\n };\n return node;\n }\n if (action.href !== undefined) {\n const href = typeof action.href === \"function\" ? action.href(target) : action.href;\n return { ...base, kind: \"link\", label, href };\n }\n if (action.toggle) {\n return {\n ...base,\n kind: \"checkbox\",\n label,\n checked: action.pressed?.(target) ?? false,\n ...(action.description !== undefined ? { description: action.description } : {}),\n };\n }\n const state = action.stateIcon?.(target) ?? null;\n const pressed = action.pressed?.(target);\n const hint = action.hint !== undefined ? translate(options.i18n, action.hintKey ?? `${action.id}.hint`, action.hint) : undefined;\n return {\n ...base,\n kind: \"item\",\n label,\n ...(action.iconTone !== undefined ? { iconTone: action.iconTone } : {}),\n ...(state ? { stateIcon: state } : {}),\n ...(action.description !== undefined ? { description: action.description } : {}),\n ...(hint !== undefined ? { hint } : {}),\n ...(pressed !== undefined ? { pressed } : {}),\n ...(action.destructive ? { destructive: true } : {}),\n ...(action.preserveSelection ? { preserveSelection: true } : {}),\n ...(action.keepsMenuOpen ? { keepsMenuOpen: true } : {}),\n ...(eligibility.status === \"unavailable-verb\" || eligibility.status === \"unavailable\"\n ? { unavailable: { sentence: eligibility.sentence } }\n : {}),\n };\n}\n\nexport function buildMenuModel(\n target: ClickTarget,\n resolved: readonly ResolvedAction[],\n options: BuildMenuModelOptions = {},\n): MenuModel {\n // THE ONE HEADING CHECK, for every host: an unapproved heading's rows go\n // inline (production) or the build throws with the remedy (dev/tests).\n const policy = options.headingPolicy ?? defaultHeadingPolicy();\n resolved = resolved.map((r) => {\n const sec = r.action.section;\n if (r.action.expand && isContainerWord(typeof r.action.label === \"string\" ? r.action.label : \"\") && policy === \"throw\") {\n throw new UnapprovedHeadingError(r.action.label as string, `submenu of ${r.action.id}`);\n }\n if (!sec) return r;\n const kind = sec.kind ?? (sec.primary ? \"target\" : \"group\");\n if (isApprovedHeading(sec.label, kind)) return r;\n if (policy === \"throw\") throw new UnapprovedHeadingError(sec.label, `section of ${r.action.id}`);\n const { section: _dropped, ...rest } = r.action;\n return { ...r, action: rest };\n });\n const ordered = resolved\n .map((r, index) => ({ r, index }))\n .sort((a, b) => {\n const ca = CATEGORY_ORDER.indexOf(a.r.action.category);\n const cb = CATEGORY_ORDER.indexOf(b.r.action.category);\n if (ca !== cb) return ca - cb;\n const oa = a.r.action.order ?? 0;\n const ob = b.r.action.order ?? 0;\n if (oa !== ob) return oa - ob;\n return a.index - b.index;\n })\n .map((x) => x.r);\n\n const sections = new Map<string, MenuSection>();\n const roles: Record<string, string> = {};\n // An explicit section sits in the group of its first-registered action and\n // keeps its own row order (order, then registration) across categories.\n const explicit = new Map<string, { group: MenuGroup; rows: { r: ResolvedAction; index: number }[] }>();\n resolved.forEach((r, index) => {\n const sec = r.action.section;\n if (!sec) return;\n const entry = explicit.get(sec.id) ?? { group: CATEGORY_GROUP[r.action.category], rows: [] };\n entry.rows.push({ r, index });\n explicit.set(sec.id, entry);\n });\n const placed = new Set<string>();\n for (const r of ordered) {\n const sec = r.action.section;\n if (sec && placed.has(sec.id)) continue;\n const group = sec ? (explicit.get(sec.id)?.group ?? CATEGORY_GROUP[r.action.category]) : CATEGORY_GROUP[r.action.category];\n const sectionId = sec ? `section:${sec.id}` : group;\n let section = sections.get(sectionId);\n if (!section) {\n section = {\n id: sectionId,\n group,\n nodes: [],\n ...(sec ? { label: translate(options.i18n, sec.labelKey ?? `section.${sec.id}`, sec.label) } : {}),\n ...(sec?.icon !== undefined ? { icon: sec.icon } : {}),\n ...(sec?.primary ? { primary: true } : {}),\n ...(sec && (sec.kind ?? (sec.primary ? \"target\" : \"group\")) === \"target\" ? { target: true } : {}),\n };\n sections.set(sectionId, section);\n }\n const rows = sec\n ? (explicit.get(sec.id)?.rows ?? [])\n .sort((x, y) => (x.r.action.order ?? 0) - (y.r.action.order ?? 0) || x.index - y.index)\n .map((x) => x.r)\n : [r];\n if (sec) placed.add(sec.id);\n for (const row of rows) {\n if (row.action.startsGroup && section.nodes.length > 0) {\n section.nodes.push({ kind: \"separator\", id: `${row.action.id}:group` });\n }\n section.nodes.push(actionToNode(row, target, options));\n if (row.action.verb) roles[row.action.verb] = row.action.id;\n }\n }\n\n const list = [...sections.values()].sort((a, b) => {\n if (Boolean(a.primary) !== Boolean(b.primary)) return a.primary ? -1 : 1;\n return GROUP_ORDER.indexOf(a.group) - GROUP_ORDER.indexOf(b.group);\n });\n\n const selected = target.selection?.text?.trim();\n const content = options.content?.trim();\n const fieldName = options.contentLabel?.trim();\n const header = selected\n ? { label: \"Selected\", text: target.selection?.text ?? \"\" }\n : fieldName\n ? { label: fieldName, text: options.content ?? \"\" }\n : content\n ? { label: \"Content\", text: options.content ?? \"\" }\n : null;\n\n return { header, sections: list, roles };\n}\n\n/** Fill a lazy submenu's rows once they load (pure: returns a new model). */\n/**\n * AN EXPANDED SUBMENU KEEPS ITS GROUPS (DATA-V2-BASICS-2, 2026-09-28). A provider's rows arrive flat,\n * so a submenu drew \"Highlight row\" and \"Delete row…\" as neighbours with no divider, while the same\n * rows in a top-level menu sit in their sections. A divider now goes wherever the rows' `section`\n * changes — a row with no section and a row with one are different groups too.\n */\nexport function withGroupDividers(children: readonly Action[], nodes: readonly MenuNode[]): MenuNode[] {\n const out: MenuNode[] = [];\n children.forEach((child, i) => {\n const node = nodes[i];\n if (!node) return;\n if (i > 0 && (child.startsGroup || (children[i - 1]!.section?.id ?? null) !== (child.section?.id ?? null))) {\n out.push({ kind: \"separator\", id: `${child.id}:group` });\n }\n out.push(node);\n });\n return out;\n}\n\nexport function withExpandedChildren(model: MenuModel, nodeId: string, children: MenuNode[] | \"loading\"): MenuModel {\n const visit = (nodes: MenuNode[]): MenuNode[] =>\n nodes.map((n) => {\n if (n.kind !== \"submenu\") return n;\n if (n.id === nodeId) {\n return children === \"loading\" ? { ...n, loading: true } : { ...n, lazy: false, loading: false, pending: false, children };\n }\n return { ...n, children: visit(n.children) };\n });\n return { ...model, sections: model.sections.map((s) => ({ ...s, nodes: visit(s.nodes) })) };\n}\n\n/** Find a node anywhere in a tree. */\nexport function findNode(nodes: readonly MenuNode[], id: string): MenuNode | null {\n for (const n of nodes) {\n if (n.id === id) return n;\n if (n.kind === \"submenu\") {\n const hit = findNode(n.children, id);\n if (hit) return hit;\n }\n }\n return null;\n}\n","/**\n * Layouts — pure arrangements of one MenuModel (CONTRACT §2.5).\n *\n * Every layout is a function over the SAME model: it decides which nodes sit\n * at the top level, which fold under a named submenu and which go into a\n * strip. None adds, drops or renames a leaf — `leafIds(arranged)` equals\n * `leafIds(model)` for every layout (THE LOSSLESS LAW, proven by test).\n *\n * The clipboard group IS the universal verb strip: in the strip layouts it is\n * drawn icon-only; elsewhere its rows are drawn in place. Unavailable verbs\n * (the only greyed nodes, R1 c) appear in every layout identically.\n */\nimport type {\n ArrangedBar,\n ArrangedContext,\n ArrangedPalette,\n ArrangedSelectionToolbar,\n ArrangedSheet,\n ContextArrangement,\n MenuLeafNode,\n MenuModel,\n MenuNode,\n MenuSection,\n MenuSubmenuNode,\n} from \"./types\";\n\n/** A section with more rows than this folds under its label in tiered/command/sheet. */\nexport const INLINE_SECTION_MAX = 3;\n\n/**\n * A section's heading is ONLY the name its actions declare (an approved\n * heading the classic menu already uses: \"Save as\", \"Copy as\", \"History\").\n * A group with no declared name has no heading and is never folded — its rows\n * show inline. The package never coins a heading (chair ruling, ALC-15).\n */\nexport function sectionLabel(section: MenuSection): string | null {\n return section.label ?? null;\n}\n\nfunction isLeaf(node: MenuNode): node is MenuLeafNode {\n return node.kind === \"item\" || node.kind === \"checkbox\" || node.kind === \"link\";\n}\n\n/** Every actionable id in a node list, depth-first. A lazy submenu counts as one leaf. */\nfunction collect(nodes: readonly MenuNode[], out: string[]): void {\n for (const n of nodes) {\n if (isLeaf(n)) out.push(n.id);\n else if (n.kind === \"submenu\") {\n if (n.lazy) out.push(n.id);\n else collect(n.children, out);\n }\n }\n}\n\ntype Arranged =\n | MenuModel\n | ArrangedBar\n | ArrangedContext\n | ArrangedSheet\n | ArrangedPalette\n | ArrangedSelectionToolbar\n | MenuSection[];\n\n/** Proof obligation for every layout: its leaf set equals the model's (sorted, de-duplicated). */\nexport function leafIds(arranged: Arranged): readonly string[] {\n const out: string[] = [];\n if (Array.isArray(arranged)) {\n for (const s of arranged) collect(s.nodes, out);\n } else if (\"leaves\" in arranged) {\n for (const l of arranged.leaves) out.push(l.node.id);\n } else if (\"primary\" in arranged && \"overflow\" in arranged) {\n collect(arranged.primary, out);\n for (const s of arranged.overflow) collect(s.nodes, out);\n } else if (\"root\" in arranged) {\n collect(arranged.strip, out);\n collect(arranged.root, out);\n } else if (\"more\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.more) collect(s.nodes, out);\n } else if (\"filterable\" in arranged) {\n collect(arranged.strip, out);\n for (const s of arranged.sections) collect(s.nodes, out);\n } else {\n for (const s of arranged.sections) collect(s.nodes, out);\n }\n return [...new Set(out)].sort();\n}\n\n/** Only a NAMED section folds; callers check `section.label` first. */\nfunction fold(section: MenuSection & { label: string }): MenuSubmenuNode {\n return {\n kind: \"submenu\",\n id: `${section.id}:fold`,\n label: section.label,\n ...(section.icon !== undefined ? { icon: section.icon } : {}),\n children: section.nodes,\n };\n}\n\nfunction rowCount(nodes: readonly MenuNode[]): number {\n return nodes.filter((n) => n.kind !== \"separator\" && n.kind !== \"label\").length;\n}\n\nfunction stripOf(model: MenuModel): MenuLeafNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter(isLeaf) : [];\n}\n\nfunction clipboardRest(model: MenuModel): MenuNode[] {\n const clipboard = model.sections.find((s) => s.group === \"clipboard\" && !s.primary);\n return clipboard ? clipboard.nodes.filter((n) => !isLeaf(n) && n.kind === \"submenu\") : [];\n}\n\nfunction placementOf(node: MenuNode): \"primary\" | \"overflow\" | \"both\" {\n return \"placement\" in node && node.placement ? node.placement : \"overflow\";\n}\n\n/** The historical flat column: every section top-level. */\nfunction classic(model: MenuModel): ArrangedContext {\n return { strip: [], sections: model.sections, filterable: false };\n}\n\n/**\n * Tiered / command: the universal verbs as an icon strip; every other row by\n * its own name; the clicked target's (primary) section first, inline, heading\n * kept; a long non-primary section folds under ITS OWN label (never a coined\n * heading); History is the one approved grouping and already a group.\n */\nfunction tiered(model: MenuModel, filterable: boolean): ArrangedContext {\n const strip = stripOf(model);\n const sections: MenuSection[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n if (s.group === \"clipboard\" && !s.primary) {\n if (rest.length) sections.push({ ...s, nodes: rest });\n continue;\n }\n if (s.primary) {\n sections.push(s);\n continue;\n }\n if (!s.label || s.group === \"surface-info\" || rowCount(s.nodes) <= INLINE_SECTION_MAX) {\n // A section keeps its declared heading in EVERY layout (the Lossless\n // Law covers headings: ⋯, the bar's ⋯ and the phone sheet show it too).\n sections.push(s);\n continue;\n }\n sections.push({ id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] });\n }\n return { strip, sections, filterable };\n}\n\nexport function context(model: MenuModel, arrangement: ContextArrangement): ArrangedContext {\n if (arrangement === \"classic\") return classic(model);\n return tiered(model, arrangement === \"command\");\n}\n\n/**\n * FOLD UNDER THE SUBJECT — a control that belongs to a CONTAINER of the thing\n * (a tab's \"…\" over the note it shows) draws the container's own rows (the\n * primary sections) on top, and EVERY other row — the verb strip included —\n * under ONE submenu named for the subject (\"Note ▸\"). The label is the\n * subject's name the host supplies (the menu header's label), never a coined\n * group heading. Lossless: rows move, none is dropped or renamed. With no\n * primary section there is nothing to put first, so the arrangement is left\n * as it was. (page-pass /notes, 2026-09-28, Arman's ruling for the tab \"…\".)\n */\nexport function foldUnderSubject(arranged: ArrangedContext, subject: string): ArrangedContext {\n const label = subject.trim();\n const primary = arranged.sections.filter((s) => s.primary);\n const rest = arranged.sections.filter((s) => !s.primary);\n if (!label || primary.length === 0 || (rest.length === 0 && arranged.strip.length === 0)) return arranged;\n const children: MenuNode[] = [];\n if (arranged.strip.length) children.push(...arranged.strip);\n for (const s of rest) {\n if (rowCount(s.nodes) === 0) continue;\n if (children.length) children.push({ kind: \"separator\", id: `${s.id}:subject-sep` });\n if (s.label) children.push({ kind: \"label\", id: `${s.id}:subject-label`, label: s.label });\n children.push(...s.nodes);\n }\n if (rowCount(children) === 0) return { ...arranged, strip: [] };\n return {\n strip: [],\n filterable: false,\n sections: [\n ...primary,\n { id: \"subject\", group: rest[0]?.group ?? primary[0]!.group, nodes: [{ kind: \"submenu\", id: \"subject:fold\", label, children }] },\n ],\n };\n}\n\n/**\n * A long NAMED section folds under its own name (\"Save as ▸\", \"Copy as ▸\");\n * primary sections and unnamed groups stay inline. Folding moves rows, never\n * renames or drops them, and never under a coined heading.\n */\nfunction foldNamed(sections: readonly MenuSection[]): MenuSection[] {\n return sections.map((s) =>\n s.label && !s.primary && rowCount(s.nodes) > INLINE_SECTION_MAX ? { id: s.id, group: s.group, nodes: [fold({ ...s, label: s.label })] } : s,\n );\n}\n\n/** ⋯ overflow: every section in classic order; long named sections fold under their own name. */\nexport function overflow(model: MenuModel): MenuSection[] {\n return foldNamed(model.sections);\n}\n\n/**\n * The action bar: primary buttons inline, EVERYTHING else under ⋯. A \"both\"\n * action is mirrored in both halves (the leaf set is still the model's).\n * `mini` changes presentation only (icon-only primaries), never membership.\n */\nexport function bar(model: MenuModel, _options: { mini?: boolean } = {}): ArrangedBar {\n const primary: MenuNode[] = [];\n const overflowSections: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n if (n.kind === \"separator\" || n.kind === \"label\") {\n rest.push(n);\n continue;\n }\n const p = placementOf(n);\n if (p === \"primary\" || p === \"both\") primary.push(n);\n if (p === \"overflow\" || p === \"both\") rest.push(n);\n }\n if (rowCount(rest) > 0) overflowSections.push({ ...s, nodes: rest });\n }\n return { primary, overflow: foldNamed(overflowSections) };\n}\n\n/** Selection toolbar: the verbs plus primary actions as a strip; the rest under More. */\nexport function selectionToolbar(model: MenuModel): ArrangedSelectionToolbar {\n const strip: MenuNode[] = [];\n const more: MenuSection[] = [];\n for (const s of model.sections) {\n const rest: MenuNode[] = [];\n for (const n of s.nodes) {\n const inStrip = (s.group === \"clipboard\" && !s.primary && isLeaf(n)) || placementOf(n) !== \"overflow\";\n if (inStrip) strip.push(n);\n else rest.push(n);\n }\n if (rowCount(rest) > 0) more.push({ ...s, nodes: rest });\n }\n return { strip, more };\n}\n\n/**\n * Mobile bottom sheet: the verb strip on top; primary and short sections\n * inline; longer sections become one drill-down row named by the section.\n * Consumes the model directly, so it can never drift from desktop.\n */\nexport function sheet(model: MenuModel): ArrangedSheet {\n const strip = stripOf(model);\n const root: MenuNode[] = [];\n const rest = clipboardRest(model);\n for (const s of model.sections) {\n const nodes = s.group === \"clipboard\" && !s.primary ? rest : s.nodes;\n if (rowCount(nodes) === 0) continue;\n if (root.length) root.push({ kind: \"separator\", id: `${s.id}:sep` });\n if (s.primary || !s.label || rowCount(nodes) <= INLINE_SECTION_MAX) {\n if (s.label) root.push({ kind: \"label\", id: `${s.id}:label`, label: s.label });\n root.push(...nodes);\n } else {\n root.push(fold({ ...s, label: s.label, nodes }));\n }\n }\n return { strip, root };\n}\n\n/** Command palette: every leaf flattened with its breadcrumb (Linear). */\nexport function palette(model: MenuModel): ArrangedPalette {\n const leaves: ArrangedPalette[\"leaves\"] = [];\n const walk = (nodes: readonly MenuNode[], trail: string[]) => {\n for (const n of nodes) {\n if (isLeaf(n)) leaves.push({ node: n, breadcrumb: trail });\n else if (n.kind === \"submenu\") {\n if (n.lazy) leaves.push({ node: n, breadcrumb: trail });\n else walk(n.children, [...trail, n.label]);\n }\n }\n };\n for (const s of model.sections) walk(s.nodes, s.label ? [s.label] : []);\n return { leaves };\n}\n\n/**\n * A SEARCH REACHES EVERY ROW (clone 2026-10-01: \"Patient\" found nothing while\n * \"Patient reminder card\" sat under AI Actions ▸ My Personal). `palette` lists a\n * lazy submenu as ONE leaf — its label only — because its rows load on open.\n * A layout that searches opens every lazy submenu it can see: these are the\n * ones still to open (not already loading).\n */\nexport function lazySubmenuIds(model: MenuModel | null): string[] {\n if (!model) return [];\n const out: string[] = [];\n const walk = (nodes: readonly MenuNode[]) => {\n for (const n of nodes) {\n if (n.kind !== \"submenu\") continue;\n if (n.lazy) {\n if (!n.loading) out.push(n.id);\n } else walk(n.children);\n }\n };\n for (const s of model.sections) walk(s.nodes);\n return out;\n}\n\n/** True while some submenu's rows are not in the model yet (a search could still find more). */\nexport function paletteStillOpening(model: MenuModel | null): boolean {\n if (!model) return true;\n const walk = (nodes: readonly MenuNode[]): boolean =>\n nodes.some((n) => n.kind === \"submenu\" && (n.lazy || n.loading || n.pending || walk(n.children)));\n return model.sections.some((s) => walk(s.nodes));\n}\n\n/** Filter the palette by a query (every word must match label or breadcrumb). */\nexport function filterPalette(arranged: ArrangedPalette, query: string): ArrangedPalette {\n const words = query.toLowerCase().split(/\\s+/).filter(Boolean);\n if (!words.length) return arranged;\n return {\n leaves: arranged.leaves.filter((l) => {\n const hay = `${l.node.label} ${l.breadcrumb.join(\" \")}`.toLowerCase();\n return words.every((w) => hay.includes(w));\n }),\n };\n}\n\nexport const layouts = { bar, overflow, context, selectionToolbar, sheet, palette };\n","/**\n * N9: layout and density are a PERSON's choice layered over the organization\n * default: persistence (\"alchemy.menu.layout\") → knobs.layout(org) → platform\n * default (command / comfortable, Arman 2026-08-22).\n */\nimport type { AlchemyHostPorts, ContextArrangementKnob, DensityKnob } from \"../ports\";\n\nexport const PLATFORM_MENU_LAYOUT: { context: ContextArrangementKnob; density: DensityKnob } = {\n context: \"command\",\n density: \"comfortable\",\n};\n\nexport const MENU_LAYOUT_SETTING = \"alchemy.menu.layout\";\n\nconst ARRANGEMENTS = new Set<string>([\"classic\", \"tiered\", \"command\"]);\nconst DENSITIES = new Set<string>([\"comfortable\", \"compact\"]);\n\nexport async function resolveMenuLayout(\n ports: Pick<AlchemyHostPorts, \"persistence\" | \"knobs\">,\n organizationId: string | null,\n): Promise<{ context: ContextArrangementKnob; density: DensityKnob }> {\n const org = ports.knobs?.layout(organizationId) ?? null;\n const base = { ...PLATFORM_MENU_LAYOUT, ...(org ?? {}) };\n let own: unknown = null;\n try {\n own = (await ports.persistence?.readSetting(MENU_LAYOUT_SETTING)) ?? null;\n } catch {\n own = null;\n }\n if (own && typeof own === \"object\" && !Array.isArray(own)) {\n const o = own as { context?: unknown; density?: unknown };\n return {\n context: typeof o.context === \"string\" && ARRANGEMENTS.has(o.context) ? (o.context as ContextArrangementKnob) : base.context,\n density: typeof o.density === \"string\" && DENSITIES.has(o.density) ? (o.density as DensityKnob) : base.density,\n };\n }\n return base;\n}\n"],"mappings":"AAoBO,IAAM,kBAAyC,IAAI,IAAI,CAC5D,OACA,UACA,SACA,OACA,gBACA,QACA,MACA,UACA,SACF,CAAC,EAIK,eACJ,oIAGI,aAAe,wDAEd,SAAS,gBAAgB,MAAwB,CACtD,OAAO,eAAe,KAAK,MAAM,KAAK,CAAC,CACzC,CAKO,SAAS,kBAAkB,MAAe,KAAoB,QAAS,SAAgC,kBAA4B,CACxI,IAAM,EAAI,MAAM,KAAK,EAC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QAO5B,CAEO,IAAM,QAAU,CAAE,IAAK,SAAU,QAAS,iBAAkB,MAAO,OAAQ,ECjU3E,IAAM,qBAAkF,CAC7F,QAAS,UACT,QAAS,aACX,EAEa,oBAAsB,sBAE7B,aAAe,IAAI,IAAY,CAAC,UAAW,SAAU,SAAS,CAAC,EAC/D,UAAY,IAAI,IAAY,CAAC,cAAe,SAAS,CAAC,EAE5D,eAAsB,kBACpB,MACA,eACoE,CACpE,IAAM,IAAM,MAAM,OAAO,OAAO,cAAc,GAAK,KAC7C,KAAO,CAAE,GAAG,qBAAsB,GAAI,KAAO,CAAC,CAAG,EACnD,IAAe,KACnB,GAAI,CACF,IAAO,MAAM,MAAM,aAAa,YAAY,mBAAmB,GAAM,IACvE,MAAQ,CACN,IAAM,IACR,CACA,GAAI,KAAO,OAAO,KAAQ,UAAY,CAAC,MAAM,QAAQ,GAAG,EAAG,CACzD,IAAM,EAAI,IACV,MAAO,CACL,QAAS,OAAO,EAAE,SAAY,UAAY,aAAa,IAAI,EAAE,OAAO,EAAK,EAAE,QAAqC,KAAK,QACrH,QAAS,OAAO,EAAE,SAAY,UAAY,UAAU,IAAI,EAAE,OAAO,EAAK,EAAE,QAA0B,KAAK,OACzG,CACF,CACA,OAAO,IACT","names":[]}
|
|
@@ -46,6 +46,12 @@
|
|
|
46
46
|
* to an overlay carrying the session as data)
|
|
47
47
|
* transferKnobs absent → no organization default recipe; a person's own
|
|
48
48
|
* default (persistence) or the package's Full applies
|
|
49
|
+
* serverActions absent → `runs: "server"` Actions refuse with "not available here"
|
|
50
|
+
* mandates absent → `runs: "mandate"` Actions refuse the same way
|
|
51
|
+
* pageActions absent → `runs: "page"` Actions refuse the same way
|
|
52
|
+
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
53
|
+
* ("needs a person's approval"); a person's own click is the approval
|
|
54
|
+
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
49
55
|
*
|
|
50
56
|
* Types only: this entry has no runtime code.
|
|
51
57
|
*/
|
package/dist/operate-server.d.ts
CHANGED
|
@@ -46,6 +46,12 @@
|
|
|
46
46
|
* to an overlay carrying the session as data)
|
|
47
47
|
* transferKnobs absent → no organization default recipe; a person's own
|
|
48
48
|
* default (persistence) or the package's Full applies
|
|
49
|
+
* serverActions absent → `runs: "server"` Actions refuse with "not available here"
|
|
50
|
+
* mandates absent → `runs: "mandate"` Actions refuse the same way
|
|
51
|
+
* pageActions absent → `runs: "page"` Actions refuse the same way
|
|
52
|
+
* approvals absent → a policy "ask" Action started by an agent, applet or automation is refused
|
|
53
|
+
* ("needs a person's approval"); a person's own click is the approval
|
|
54
|
+
* (`runs: "navigate"` goes through `overlay.navigate`; overlay absent → refused)
|
|
49
55
|
*
|
|
50
56
|
* Types only: this entry has no runtime code.
|
|
51
57
|
*/
|