codeassembly-agent-logic 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.meta/changelog.json +85 -0
  2. package/CHANGELOG.md +24 -0
  3. package/README.md +47 -18
  4. package/dist/esm/agent/convert-with-agent.d.ts +3 -3
  5. package/dist/esm/agent/convert-with-agent.js +2 -1
  6. package/dist/esm/conversion-session/format-conversion-input.d.ts +9 -0
  7. package/dist/esm/conversion-session/format-conversion-input.js +11 -1
  8. package/dist/esm/index.d.ts +5 -1
  9. package/dist/esm/index.js +1 -0
  10. package/dist/esm/job/create-conversion-job.d.ts +10 -1
  11. package/dist/esm/job/create-conversion-job.js +6 -2
  12. package/dist/esm/job/index.d.ts +1 -1
  13. package/dist/esm/job/index.js +1 -1
  14. package/dist/esm/react/canvas/CanvasKey.d.ts +38 -0
  15. package/dist/esm/react/canvas/CanvasKey.js +33 -0
  16. package/dist/esm/react/hooks/document-types.d.ts +72 -0
  17. package/dist/esm/react/hooks/document-types.js +3 -0
  18. package/dist/esm/react/hooks/file-location.d.ts +10 -0
  19. package/dist/esm/react/hooks/file-location.js +19 -0
  20. package/dist/esm/react/hooks/label-source.js +2 -1
  21. package/dist/esm/react/hooks/load-messages.d.ts +2 -0
  22. package/dist/esm/react/hooks/load-messages.js +3 -0
  23. package/dist/esm/react/hooks/read-document.d.ts +48 -0
  24. package/dist/esm/react/hooks/read-document.js +88 -0
  25. package/dist/esm/react/hooks/stored-base.d.ts +7 -0
  26. package/dist/esm/react/hooks/stored-base.js +8 -0
  27. package/dist/esm/react/hooks/stored-upload.d.ts +9 -0
  28. package/dist/esm/react/hooks/stored-upload.js +16 -0
  29. package/dist/esm/react/hooks/useDocumentState.d.ts +57 -0
  30. package/dist/esm/react/hooks/useDocumentState.js +151 -0
  31. package/dist/esm/react/index.d.ts +18 -1
  32. package/dist/esm/react/index.js +13 -0
  33. package/dist/esm/react/inspector/Inspector.d.ts +13 -0
  34. package/dist/esm/react/inspector/Inspector.js +58 -0
  35. package/dist/esm/react/messages/FindingList.d.ts +18 -0
  36. package/dist/esm/react/messages/FindingList.js +15 -0
  37. package/dist/esm/react/messages/GapList.d.ts +14 -0
  38. package/dist/esm/react/messages/GapList.js +18 -0
  39. package/dist/esm/react/messages/Messages.d.ts +29 -0
  40. package/dist/esm/react/messages/Messages.js +19 -0
  41. package/dist/esm/react/messages/SectionMessage.d.ts +10 -0
  42. package/dist/esm/react/messages/SectionMessage.js +8 -0
  43. package/dist/esm/react/messages/UnconvertedPassages.d.ts +15 -0
  44. package/dist/esm/react/messages/UnconvertedPassages.js +15 -0
  45. package/dist/esm/react/messages/abbreviate.d.ts +2 -0
  46. package/dist/esm/react/messages/abbreviate.js +5 -0
  47. package/dist/esm/react/messages/icons.d.ts +9 -0
  48. package/dist/esm/react/messages/icons.js +10 -0
  49. package/dist/esm/react/slots.d.ts +28 -0
  50. package/dist/esm/react/slots.js +1 -0
  51. package/dist/esm/react/source/SourceLine.d.ts +13 -0
  52. package/dist/esm/react/source/SourceLine.js +49 -0
  53. package/dist/esm/react/source/Workspace.d.ts +32 -0
  54. package/dist/esm/react/source/Workspace.js +22 -0
  55. package/dist/esm/react/source/build-connector.d.ts +39 -0
  56. package/dist/esm/react/source/build-connector.js +23 -0
  57. package/dist/esm/react/styles.css +445 -6
  58. package/dist/esm/schema/agent-logic-file-name.d.ts +4 -0
  59. package/dist/esm/schema/agent-logic-file-name.js +4 -0
  60. package/package.json +4 -3
@@ -1,7 +1,8 @@
1
1
  /*
2
- * Styles for the statechart canvas, the prompt pane, and the marks of their keys. The colours come in two tiers of
3
- * custom properties: the seeds, declared on :root, and the component properties, each of which derives its default from
4
- * the seeds. A consumer sets either tier on :root or on an ancestor of the components that it renders.
2
+ * Styles for the statechart canvas, its key, the prompt pane, the marks of their keys, the inspector, the source line,
3
+ * the workspace, and the messages panel. The colours come in two tiers of custom properties: the seeds, declared on
4
+ * :root, and the component properties, each of which derives its default from the seeds. A consumer sets either tier on
5
+ * :root or on an ancestor of the components that it renders.
5
6
  */
6
7
 
7
8
  @import '@xyflow/react/style.css';
@@ -19,16 +20,22 @@
19
20
 
20
21
  /*
21
22
  * Each component property resolves here, on the elements that read it, rather than on :root, so that seeds set on any
22
- * ancestor of the canvas, the pane, or a key entry reach the derivation. Every rule below reads the private property.
23
+ * ancestor of the canvas, the pane, a key, the inspector, the source line, the workspace, or the messages panel reach
24
+ * the derivation. Every rule below reads the private property.
23
25
  */
24
26
  :where(
25
27
  .statechart-canvas,
26
28
  .arrowhead-defs,
29
+ .canvas-key,
27
30
  .canvas-key__swatch,
28
31
  .canvas-key__word,
29
32
  .mark-glyph,
30
33
  .prompt-pane,
31
- .prompt-key
34
+ .prompt-key,
35
+ .statechart-inspector,
36
+ .statechart-messages,
37
+ .statechart-source-line,
38
+ .statechart-workspace
32
39
  ) {
33
40
  --_agent-logic-ambient-background: var(
34
41
  --agent-logic-ambient-background,
@@ -46,11 +53,19 @@
46
53
  --agent-logic-compound-background,
47
54
  color-mix(in srgb, var(--agent-logic-text) 5%, var(--agent-logic-surface))
48
55
  );
56
+ --_agent-logic-danger-text: var(
57
+ --agent-logic-danger-text,
58
+ color-mix(in srgb, var(--agent-logic-warning) 70%, var(--agent-logic-text))
59
+ );
49
60
  --_agent-logic-focus-ring: var(--agent-logic-focus-ring, var(--agent-logic-accent));
50
61
  --_agent-logic-hover-background: var(
51
62
  --agent-logic-hover-background,
52
63
  color-mix(in srgb, var(--agent-logic-text) 12.5%, transparent)
53
64
  );
65
+ --_agent-logic-information-background: var(
66
+ --agent-logic-information-background,
67
+ color-mix(in srgb, var(--agent-logic-accent) 9%, var(--agent-logic-surface))
68
+ );
54
69
  --_agent-logic-node-background: var(--agent-logic-node-background, var(--agent-logic-surface));
55
70
  --_agent-logic-passage-background: var(
56
71
  --agent-logic-passage-background,
@@ -61,6 +76,7 @@
61
76
  --agent-logic-selected-background,
62
77
  color-mix(in srgb, var(--agent-logic-accent) 13%, var(--agent-logic-surface))
63
78
  );
79
+ --_agent-logic-source-line: var(--agent-logic-source-line, var(--_agent-logic-selected));
64
80
  --_agent-logic-text-subtle: var(
65
81
  --agent-logic-text-subtle,
66
82
  color-mix(in srgb, var(--agent-logic-text) 78%, var(--agent-logic-surface))
@@ -75,6 +91,10 @@
75
91
  --agent-logic-unconverted,
76
92
  color-mix(in srgb, var(--agent-logic-warning) 70%, var(--agent-logic-text))
77
93
  );
94
+ --_agent-logic-warning-background: var(
95
+ --agent-logic-warning-background,
96
+ color-mix(in srgb, var(--agent-logic-warning) 11%, var(--agent-logic-surface))
97
+ );
78
98
  }
79
99
 
80
100
  .statechart-canvas {
@@ -528,7 +548,142 @@
528
548
  line-height: 18px;
529
549
  }
530
550
 
531
- /* -- Key -- */
551
+ /* -- Key: a strip below the canvas, with the marks that the chart draws and the canvas's toggles -- */
552
+
553
+ .canvas-key {
554
+ display: flex;
555
+ flex: none;
556
+ align-items: center;
557
+ border-block-start: 1px solid var(--_agent-logic-border);
558
+ background: var(--agent-logic-surface);
559
+ color: var(--agent-logic-text);
560
+ }
561
+
562
+ .canvas-key__entries {
563
+ display: flex;
564
+ flex-wrap: wrap;
565
+ gap: 4px 12px;
566
+ margin: 0;
567
+ padding: 6px 10px;
568
+ font-size: 12px;
569
+ line-height: 16px;
570
+ list-style: none;
571
+ }
572
+
573
+ .canvas-key__entry {
574
+ position: relative;
575
+ margin: 0;
576
+ }
577
+
578
+ /* An entry takes focus only so that a keyboard user reaches its gloss; it does not act on a click. */
579
+ .canvas-key__entry-label {
580
+ display: inline-flex;
581
+ align-items: center;
582
+ gap: 5px;
583
+ padding: 2px 4px;
584
+ border-radius: 3px;
585
+ white-space: nowrap;
586
+ cursor: help;
587
+ }
588
+
589
+ .canvas-key__entry-label:hover {
590
+ background: var(--_agent-logic-hover-background);
591
+ }
592
+
593
+ .canvas-key__entry-label:focus-visible {
594
+ outline: 2px solid var(--_agent-logic-focus-ring);
595
+ outline-offset: 1px;
596
+ }
597
+
598
+ .canvas-key__tooltip {
599
+ position: absolute;
600
+ inset-block-end: 100%;
601
+ inset-inline-start: 0;
602
+ z-index: 10;
603
+ display: none;
604
+ inline-size: max-content;
605
+ max-inline-size: 256px;
606
+ margin-block-end: 4px;
607
+ padding: 4px 8px;
608
+ border-radius: 2px;
609
+ background: var(--_agent-logic-tooltip-background);
610
+ color: var(--_agent-logic-tooltip-text);
611
+ font-size: 12px;
612
+ line-height: 16px;
613
+ pointer-events: none;
614
+ }
615
+
616
+ .canvas-key__entry:hover .canvas-key__tooltip,
617
+ .canvas-key__entry:focus-within .canvas-key__tooltip {
618
+ display: block;
619
+ }
620
+
621
+ .canvas-key__controls {
622
+ display: flex;
623
+ flex: none;
624
+ align-items: center;
625
+ gap: 8px;
626
+ margin-inline: auto 4px;
627
+ font-size: 14px;
628
+ line-height: 20px;
629
+ }
630
+
631
+ .canvas-key__ambient {
632
+ display: flex;
633
+ align-items: center;
634
+ gap: 6px;
635
+ padding: 2px 6px;
636
+ border-radius: 2px;
637
+ white-space: nowrap;
638
+ }
639
+
640
+ .canvas-key__ambient:hover {
641
+ background: var(--_agent-logic-hover-background);
642
+ }
643
+
644
+ .canvas-key__ambient > input,
645
+ .canvas-key__ambient > label {
646
+ cursor: pointer;
647
+ }
648
+
649
+ .canvas-key__ambient > input {
650
+ inline-size: 16px;
651
+ block-size: 16px;
652
+ margin: 0;
653
+ accent-color: var(--agent-logic-accent);
654
+ }
655
+
656
+ .canvas-key__messages {
657
+ display: flex;
658
+ align-items: center;
659
+ gap: 8px;
660
+ white-space: nowrap;
661
+ }
662
+
663
+ .canvas-key__counts {
664
+ color: var(--_agent-logic-text-subtle);
665
+ font-size: 12px;
666
+ }
667
+
668
+ /* The chevron of a disclosure, inside the app's button: right while closed, down while open. */
669
+ .statechart-chevron {
670
+ flex: none;
671
+ inline-size: 16px;
672
+ block-size: 16px;
673
+ transition: transform 150ms ease-out;
674
+ }
675
+
676
+ .statechart-chevron--open {
677
+ transform: rotate(90deg);
678
+ }
679
+
680
+ @media (prefers-reduced-motion: reduce) {
681
+ .statechart-chevron {
682
+ transition: none;
683
+ }
684
+ }
685
+
686
+ /* -- Marks of the key -- */
532
687
 
533
688
  .canvas-key__swatch {
534
689
  display: inline-block;
@@ -702,3 +857,287 @@
702
857
  .prompt-key__sample {
703
858
  font-family: var(--agent-logic-font-prose);
704
859
  }
860
+
861
+ /* -- Inspector: the selected element's facts, above the prompt -- */
862
+
863
+ .statechart-inspector {
864
+ flex: none;
865
+ max-height: 50%;
866
+ overflow-y: auto;
867
+ padding: 16px 20px;
868
+ border-bottom: 1px solid var(--_agent-logic-border);
869
+ background: var(--agent-logic-surface);
870
+ color: var(--agent-logic-text);
871
+ }
872
+
873
+ .statechart-inspector__empty {
874
+ margin: 0;
875
+ color: var(--_agent-logic-text-subtle);
876
+ }
877
+
878
+ .statechart-inspector__details {
879
+ display: flex;
880
+ flex-direction: column;
881
+ gap: 12px;
882
+ }
883
+
884
+ .statechart-inspector__heading {
885
+ margin: 0;
886
+ font-size: 16px;
887
+ font-weight: 600;
888
+ line-height: 20px;
889
+ overflow-wrap: anywhere;
890
+ }
891
+
892
+ .statechart-inspector__fact {
893
+ display: flex;
894
+ flex-direction: column;
895
+ gap: 4px;
896
+ }
897
+
898
+ /* Labels and the connecting words between links: secondary text. */
899
+ .statechart-inspector__aside {
900
+ color: var(--_agent-logic-text-subtle);
901
+ font-size: 12px;
902
+ line-height: 16px;
903
+ }
904
+
905
+ .statechart-inspector__none {
906
+ color: var(--_agent-logic-text-subtle);
907
+ }
908
+
909
+ .statechart-inspector__actions {
910
+ margin: 0;
911
+ padding-inline-start: 16px;
912
+ list-style: disc;
913
+ }
914
+
915
+ .statechart-inspector__actions > li + li,
916
+ .statechart-inspector__transitions > li + li {
917
+ margin-top: 4px;
918
+ }
919
+
920
+ .statechart-inspector__kinds {
921
+ display: flex;
922
+ flex-wrap: wrap;
923
+ gap: 4px;
924
+ margin: 0;
925
+ padding: 0;
926
+ list-style: none;
927
+ }
928
+
929
+ .statechart-inspector__kind {
930
+ padding: 0 8px;
931
+ border: 1px solid var(--_agent-logic-border-strong);
932
+ border-radius: 9999px;
933
+ font-size: 12px;
934
+ line-height: 20px;
935
+ }
936
+
937
+ .statechart-inspector__quote {
938
+ margin: 0;
939
+ font-family: var(--agent-logic-font-prose);
940
+ font-size: 16px;
941
+ line-height: 24px;
942
+ white-space: pre-wrap;
943
+ }
944
+
945
+ .statechart-inspector__row {
946
+ display: flex;
947
+ flex-wrap: wrap;
948
+ align-items: baseline;
949
+ gap: 6px;
950
+ }
951
+
952
+ .statechart-inspector__transitions {
953
+ margin: 0;
954
+ padding: 0;
955
+ list-style: none;
956
+ }
957
+
958
+ .statechart-inspector__code {
959
+ font-family: var(--agent-logic-font-code);
960
+ }
961
+
962
+ .statechart-inspector__unnamed {
963
+ font-size: 12px;
964
+ }
965
+
966
+ /* -- Messages panel: the gaps, the converter's findings, and the unconverted passages, below the canvas -- */
967
+
968
+ .statechart-messages {
969
+ display: flex;
970
+ flex: none;
971
+ flex-direction: column;
972
+ gap: 6px;
973
+ block-size: 40%;
974
+ box-sizing: border-box;
975
+ overflow-y: auto;
976
+ padding: 8px;
977
+ border-block-start: 1px solid var(--_agent-logic-border);
978
+ background: var(--agent-logic-surface);
979
+ color: var(--agent-logic-text);
980
+ font-size: 14px;
981
+ line-height: 20px;
982
+ }
983
+
984
+ /* A display set here would otherwise show a panel or a list that its `hidden` attribute hides. */
985
+ .statechart-messages[hidden],
986
+ .statechart-messages__details[hidden] {
987
+ display: none;
988
+ }
989
+
990
+ .statechart-messages__section {
991
+ display: flex;
992
+ gap: 10px;
993
+ padding: 14px 16px;
994
+ border-radius: 6px;
995
+ }
996
+
997
+ .statechart-messages__section--information {
998
+ background: var(--_agent-logic-information-background);
999
+ }
1000
+
1001
+ .statechart-messages__section--information > .statechart-messages__icon {
1002
+ color: var(--agent-logic-accent);
1003
+ }
1004
+
1005
+ .statechart-messages__section--warning {
1006
+ background: var(--_agent-logic-warning-background);
1007
+ }
1008
+
1009
+ .statechart-messages__section--warning > .statechart-messages__icon {
1010
+ color: var(--agent-logic-warning);
1011
+ }
1012
+
1013
+ .statechart-messages__icon {
1014
+ flex: none;
1015
+ inline-size: 20px;
1016
+ block-size: 20px;
1017
+ margin-block-start: 2px;
1018
+ }
1019
+
1020
+ .statechart-messages__icon-stroke {
1021
+ stroke: var(--agent-logic-surface);
1022
+ }
1023
+
1024
+ .statechart-messages__icon-fill {
1025
+ fill: var(--agent-logic-surface);
1026
+ }
1027
+
1028
+ .statechart-messages__section-body {
1029
+ display: flex;
1030
+ flex: 1;
1031
+ flex-direction: column;
1032
+ gap: 6px;
1033
+ min-inline-size: 0;
1034
+ }
1035
+
1036
+ .statechart-messages__section-title {
1037
+ margin: 0;
1038
+ font-size: 16px;
1039
+ font-weight: 600;
1040
+ line-height: 24px;
1041
+ }
1042
+
1043
+ .statechart-messages__section-body p {
1044
+ margin: 0;
1045
+ }
1046
+
1047
+ .statechart-messages__list {
1048
+ display: flex;
1049
+ flex-direction: column;
1050
+ gap: 4px;
1051
+ margin: 0;
1052
+ padding-inline-start: 20px;
1053
+ list-style: disc;
1054
+ }
1055
+
1056
+ .statechart-messages__details,
1057
+ .statechart-messages__passages {
1058
+ display: flex;
1059
+ flex-direction: column;
1060
+ gap: 6px;
1061
+ }
1062
+
1063
+ .statechart-messages__passages {
1064
+ margin: 0;
1065
+ padding: 0;
1066
+ list-style: none;
1067
+ }
1068
+
1069
+ /* A finding's kind classifies it, so it reads as a tag. */
1070
+ .statechart-messages__kind {
1071
+ display: inline-block;
1072
+ margin-inline-end: 6px;
1073
+ padding: 0 5px;
1074
+ border: 1px solid var(--_agent-logic-border);
1075
+ border-radius: 3px;
1076
+ color: var(--_agent-logic-text-subtle);
1077
+ font-size: 12px;
1078
+ font-weight: 600;
1079
+ line-height: 16px;
1080
+ white-space: nowrap;
1081
+ }
1082
+
1083
+ .statechart-messages__quote {
1084
+ font-family: var(--agent-logic-font-prose);
1085
+ }
1086
+
1087
+ /* -- Source line: drawn over the workspace from the selected element to its passage -- */
1088
+
1089
+ .statechart-source-line {
1090
+ position: absolute;
1091
+ inset: 0;
1092
+ z-index: 4;
1093
+ width: 100%;
1094
+ height: 100%;
1095
+ overflow: visible;
1096
+ pointer-events: none;
1097
+ fill: var(--_agent-logic-source-line);
1098
+ stroke: var(--_agent-logic-source-line);
1099
+ }
1100
+
1101
+ /* -- Workspace: the canvas beside the source pane, which holds the inspector above the prompt -- */
1102
+
1103
+ .statechart-workspace {
1104
+ position: relative;
1105
+ display: grid;
1106
+ flex: 1;
1107
+ grid-template-columns: minmax(0, 1fr) clamp(392px, 35vw, 500px);
1108
+ min-height: 0;
1109
+ overflow: hidden;
1110
+ border: 1px solid var(--_agent-logic-border);
1111
+ border-radius: 4px;
1112
+ }
1113
+
1114
+ .statechart-workspace__chart {
1115
+ display: flex;
1116
+ flex-direction: column;
1117
+ min-height: 0;
1118
+ }
1119
+
1120
+ .statechart-workspace__canvas {
1121
+ position: relative;
1122
+ flex: 1;
1123
+ min-height: 0;
1124
+ }
1125
+
1126
+ .statechart-workspace__error {
1127
+ margin: 0;
1128
+ padding: 16px;
1129
+ color: var(--_agent-logic-danger-text);
1130
+ }
1131
+
1132
+ .statechart-workspace__source {
1133
+ display: flex;
1134
+ flex-direction: column;
1135
+ min-height: 0;
1136
+ border-left: 1px solid var(--_agent-logic-border);
1137
+ background: var(--agent-logic-surface);
1138
+ }
1139
+
1140
+ .statechart-workspace__prompt {
1141
+ flex: 1;
1142
+ min-height: 0;
1143
+ }
@@ -0,0 +1,4 @@
1
+ /** The suffix that names an agent-logic file in a store and in a download. */
2
+ export declare const AGENT_LOGIC_SUFFIX = ".agent-logic.json";
3
+ /** Reports whether the name ends in `.agent-logic.json` after a non-empty base. */
4
+ export declare function isAgentLogicFileName(name: string): boolean;
@@ -0,0 +1,4 @@
1
+ export const AGENT_LOGIC_SUFFIX = '.agent-logic.json';
2
+ export function isAgentLogicFileName(name) {
3
+ return name.length > AGENT_LOGIC_SUFFIX.length && name.endsWith(AGENT_LOGIC_SUFFIX);
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeassembly-agent-logic",
3
- "version": "0.8.0",
3
+ "version": "0.10.0",
4
4
  "description": "Model of an agent prompt's states and transitions, with React and server entries for the apps that present it",
5
5
  "keywords": [
6
6
  "agents",
@@ -65,6 +65,7 @@
65
65
  ],
66
66
  "dependencies": {
67
67
  "@williamthorsen/toolbelt.errors": "0.11.4",
68
+ "@williamthorsen/toolbelt.text-file-store": "0.2.0",
68
69
  "@xyflow/react": "13.0.2",
69
70
  "elkjs": "0.12.1",
70
71
  "zod": "4.6.7"
@@ -80,9 +81,9 @@
80
81
  "@types/react": "19.3.0",
81
82
  "@types/react-dom": "19.3.0",
82
83
  "@vitejs/plugin-react": "6.3.0",
83
- "@williamthorsen/nmr": "2.3.0",
84
+ "@williamthorsen/nmr": "2.3.1",
84
85
  "@williamthorsen/toolbelt.acp": "0.3.3",
85
- "@williamthorsen/toolbelt.llm": "0.2.1",
86
+ "@williamthorsen/toolbelt.llm": "0.3.0",
86
87
  "eslint": "10.15.0",
87
88
  "eslint-plugin-jest-dom": "5.11.0",
88
89
  "eslint-plugin-react": "7.37.5",