codeassembly-agent-logic 0.9.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.
- package/.meta/changelog.json +57 -0
- package/CHANGELOG.md +14 -0
- package/README.md +34 -21
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/react/canvas/CanvasKey.d.ts +38 -0
- package/dist/esm/react/canvas/CanvasKey.js +33 -0
- package/dist/esm/react/hooks/document-types.d.ts +72 -0
- package/dist/esm/react/hooks/document-types.js +3 -0
- package/dist/esm/react/hooks/file-location.d.ts +10 -0
- package/dist/esm/react/hooks/file-location.js +19 -0
- package/dist/esm/react/hooks/label-source.js +2 -1
- package/dist/esm/react/hooks/load-messages.d.ts +2 -0
- package/dist/esm/react/hooks/load-messages.js +3 -0
- package/dist/esm/react/hooks/read-document.d.ts +48 -0
- package/dist/esm/react/hooks/read-document.js +88 -0
- package/dist/esm/react/hooks/stored-base.d.ts +7 -0
- package/dist/esm/react/hooks/stored-base.js +8 -0
- package/dist/esm/react/hooks/stored-upload.d.ts +9 -0
- package/dist/esm/react/hooks/stored-upload.js +16 -0
- package/dist/esm/react/hooks/useDocumentState.d.ts +57 -0
- package/dist/esm/react/hooks/useDocumentState.js +151 -0
- package/dist/esm/react/index.d.ts +18 -1
- package/dist/esm/react/index.js +13 -0
- package/dist/esm/react/inspector/Inspector.d.ts +13 -0
- package/dist/esm/react/inspector/Inspector.js +58 -0
- package/dist/esm/react/messages/FindingList.d.ts +18 -0
- package/dist/esm/react/messages/FindingList.js +15 -0
- package/dist/esm/react/messages/GapList.d.ts +14 -0
- package/dist/esm/react/messages/GapList.js +18 -0
- package/dist/esm/react/messages/Messages.d.ts +29 -0
- package/dist/esm/react/messages/Messages.js +19 -0
- package/dist/esm/react/messages/SectionMessage.d.ts +10 -0
- package/dist/esm/react/messages/SectionMessage.js +8 -0
- package/dist/esm/react/messages/UnconvertedPassages.d.ts +15 -0
- package/dist/esm/react/messages/UnconvertedPassages.js +15 -0
- package/dist/esm/react/messages/abbreviate.d.ts +2 -0
- package/dist/esm/react/messages/abbreviate.js +5 -0
- package/dist/esm/react/messages/icons.d.ts +9 -0
- package/dist/esm/react/messages/icons.js +10 -0
- package/dist/esm/react/slots.d.ts +28 -0
- package/dist/esm/react/slots.js +1 -0
- package/dist/esm/react/source/SourceLine.d.ts +13 -0
- package/dist/esm/react/source/SourceLine.js +49 -0
- package/dist/esm/react/source/Workspace.d.ts +32 -0
- package/dist/esm/react/source/Workspace.js +22 -0
- package/dist/esm/react/source/build-connector.d.ts +39 -0
- package/dist/esm/react/source/build-connector.js +23 -0
- package/dist/esm/react/styles.css +445 -6
- package/dist/esm/schema/agent-logic-file-name.d.ts +4 -0
- package/dist/esm/schema/agent-logic-file-name.js +4 -0
- package/package.json +3 -2
package/.meta/changelog.json
CHANGED
|
@@ -1,4 +1,61 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"date": "2026-11-22",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "🎉 Features",
|
|
8
|
+
"audience": "all",
|
|
9
|
+
"items": [
|
|
10
|
+
{
|
|
11
|
+
"description": "Adds `Workspace` to `codeassembly-agent-logic/react`, which lays the statechart canvas beside a source pane that stacks the inspector above the `PromptPane`, and which takes the app's `LinkButton` component for the inspector's links. (#2309)",
|
|
12
|
+
"hash": "86210e280a54cc7f1c68379c4a65fdb51469dba5",
|
|
13
|
+
"entry": 1
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"description": "Adds `Inspector`, a panel that describes the selected state, transition, or ambient instruction and renders each state and transition that it names through the app's `LinkButton` component. (#2309)",
|
|
17
|
+
"hash": "86210e280a54cc7f1c68379c4a65fdb51469dba5",
|
|
18
|
+
"entry": 2
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"description": "Adds `SourceLine`, which draws a line from the selected chart element to its passage in the prompt pane while both are in view, in the color that the new `--agent-logic-source-line` property sets. (#2309)",
|
|
22
|
+
"hash": "86210e280a54cc7f1c68379c4a65fdb51469dba5",
|
|
23
|
+
"entry": 3
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"description": "Adds `CanvasKey`, which lists each kind of mark that the chart draws with its gloss, followed by a checkbox that shows and hides the ambient instructions and a toggle that opens the messages panel. (#2310)",
|
|
27
|
+
"hash": "e333e2505c483b8be0c048b16bd0974e5e5b8b1c",
|
|
28
|
+
"entry": 1
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"description": "Adds the `Messages` panel, which lists a converted document's gaps, the converter's findings, and its unconverted passages, together with `countMessages` and `hasMessages`, which report how many messages a document has. (#2310)",
|
|
32
|
+
"hash": "e333e2505c483b8be0c048b16bd0974e5e5b8b1c",
|
|
33
|
+
"entry": 2
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"description": "Exports `ButtonProps` and `LinkButtonProps`, the props of the app's button and in-page link, with an `isHeading` flag that gives a button titling a section the heading's text size and an `isInline` flag that keeps a link's underline at rest inside a sentence. (#2310)",
|
|
37
|
+
"hash": "e333e2505c483b8be0c048b16bd0974e5e5b8b1c",
|
|
38
|
+
"entry": 3
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"description": "Styles the canvas key and the messages panel in `styles.css` from the existing seeds, and adds `--agent-logic-information-background` and `--agent-logic-warning-background` for overriding the backgrounds of the panel's information and warning sections. (#2310)",
|
|
42
|
+
"hash": "e333e2505c483b8be0c048b16bd0974e5e5b8b1c",
|
|
43
|
+
"entry": 4
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"description": "Adds to `codeassembly-agent-logic/react` the `useDocumentState` hook, which opens an example or a file stored in a `FileStore` of `@williamthorsen/toolbelt.text-file-store`, keeps the open document in step with the URL and the browser's history, and opens and stores a document of a kind that the app defines through its `otherKind` option and its returned `prepareLoad` and `storeAndOpen`. (#2311)",
|
|
47
|
+
"hash": "269736cb6615246ac7e3b36c140b2c2930aaac2e",
|
|
48
|
+
"entry": 1
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"description": "Adds `AGENT_LOGIC_SUFFIX` and `isAgentLogicFileName` to the root entry of `codeassembly-agent-logic`, which lets server code, such as a file-store plugin, recognize an agent-logic file name without importing the `./react` entry. (#2311)",
|
|
52
|
+
"hash": "269736cb6615246ac7e3b36c140b2c2930aaac2e",
|
|
53
|
+
"entry": 2
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
2
59
|
{
|
|
3
60
|
"version": "0.9.0",
|
|
4
61
|
"date": "2026-11-22",
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.10.0 — 2026-11-22
|
|
6
|
+
|
|
7
|
+
### 🎉 Features
|
|
8
|
+
|
|
9
|
+
- Adds `Workspace` to `codeassembly-agent-logic/react`, which lays the statechart canvas beside a source pane that stacks the inspector above the `PromptPane`, and which takes the app's `LinkButton` component for the inspector's links. (#2309)
|
|
10
|
+
- Adds `Inspector`, a panel that describes the selected state, transition, or ambient instruction and renders each state and transition that it names through the app's `LinkButton` component. (#2309)
|
|
11
|
+
- Adds `SourceLine`, which draws a line from the selected chart element to its passage in the prompt pane while both are in view, in the color that the new `--agent-logic-source-line` property sets. (#2309)
|
|
12
|
+
- Adds `CanvasKey`, which lists each kind of mark that the chart draws with its gloss, followed by a checkbox that shows and hides the ambient instructions and a toggle that opens the messages panel. (#2310)
|
|
13
|
+
- Adds the `Messages` panel, which lists a converted document's gaps, the converter's findings, and its unconverted passages, together with `countMessages` and `hasMessages`, which report how many messages a document has. (#2310)
|
|
14
|
+
- Exports `ButtonProps` and `LinkButtonProps`, the props of the app's button and in-page link, with an `isHeading` flag that gives a button titling a section the heading's text size and an `isInline` flag that keeps a link's underline at rest inside a sentence. (#2310)
|
|
15
|
+
- Styles the canvas key and the messages panel in `styles.css` from the existing seeds, and adds `--agent-logic-information-background` and `--agent-logic-warning-background` for overriding the backgrounds of the panel's information and warning sections. (#2310)
|
|
16
|
+
- Adds to `codeassembly-agent-logic/react` the `useDocumentState` hook, which opens an example or a file stored in a `FileStore` of `@williamthorsen/toolbelt.text-file-store`, keeps the open document in step with the URL and the browser's history, and opens and stores a document of a kind that the app defines through its `otherKind` option and its returned `prepareLoad` and `storeAndOpen`. (#2311)
|
|
17
|
+
- Adds `AGENT_LOGIC_SUFFIX` and `isAgentLogicFileName` to the root entry of `codeassembly-agent-logic`, which lets server code, such as a file-store plugin, recognize an agent-logic file name without importing the `./react` entry. (#2311)
|
|
18
|
+
|
|
5
19
|
## 0.9.0 — 2026-11-22
|
|
6
20
|
|
|
7
21
|
### 🎉 Features
|
package/README.md
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
<!-- section:release-notes -->
|
|
2
|
-
## Release notes — v0.
|
|
2
|
+
## Release notes — v0.10.0 (2026-11-22)
|
|
3
3
|
|
|
4
4
|
### 🎉 Features
|
|
5
5
|
|
|
6
|
-
- Adds `
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
6
|
+
- Adds `Workspace` to `codeassembly-agent-logic/react`, which lays the statechart canvas beside a source pane that stacks the inspector above the `PromptPane`, and which takes the app's `LinkButton` component for the inspector's links. (#2309)
|
|
7
|
+
- Adds `Inspector`, a panel that describes the selected state, transition, or ambient instruction and renders each state and transition that it names through the app's `LinkButton` component. (#2309)
|
|
8
|
+
- Adds `SourceLine`, which draws a line from the selected chart element to its passage in the prompt pane while both are in view, in the color that the new `--agent-logic-source-line` property sets. (#2309)
|
|
9
|
+
- Adds `CanvasKey`, which lists each kind of mark that the chart draws with its gloss, followed by a checkbox that shows and hides the ambient instructions and a toggle that opens the messages panel. (#2310)
|
|
10
|
+
- Adds the `Messages` panel, which lists a converted document's gaps, the converter's findings, and its unconverted passages, together with `countMessages` and `hasMessages`, which report how many messages a document has. (#2310)
|
|
11
|
+
- Exports `ButtonProps` and `LinkButtonProps`, the props of the app's button and in-page link, with an `isHeading` flag that gives a button titling a section the heading's text size and an `isInline` flag that keeps a link's underline at rest inside a sentence. (#2310)
|
|
12
|
+
- Styles the canvas key and the messages panel in `styles.css` from the existing seeds, and adds `--agent-logic-information-background` and `--agent-logic-warning-background` for overriding the backgrounds of the panel's information and warning sections. (#2310)
|
|
13
|
+
- Adds to `codeassembly-agent-logic/react` the `useDocumentState` hook, which opens an example or a file stored in a `FileStore` of `@williamthorsen/toolbelt.text-file-store`, keeps the open document in step with the URL and the browser's history, and opens and stores a document of a kind that the app defines through its `otherKind` option and its returned `prepareLoad` and `storeAndOpen`. (#2311)
|
|
14
|
+
- Adds `AGENT_LOGIC_SUFFIX` and `isAgentLogicFileName` to the root entry of `codeassembly-agent-logic`, which lets server code, such as a file-store plugin, recognize an agent-logic file name without importing the `./react` entry. (#2311)
|
|
11
15
|
<!-- /section:release-notes -->
|
|
12
16
|
|
|
13
17
|
<!-- readme-type: library -->
|
|
@@ -34,16 +38,16 @@ if (result.ok) {
|
|
|
34
38
|
|
|
35
39
|
## Entries
|
|
36
40
|
|
|
37
|
-
| Entry | Exports
|
|
38
|
-
| -------------------------------------------------- |
|
|
39
|
-
| `codeassembly-agent-logic` | The config schema and its validation, the converter and coverage check, the chart description, its ELK graph (`buildElkGraph`), its layout, source marking, and the bundled examples.
|
|
40
|
-
| `codeassembly-agent-logic/agent` | `convertWithAgent`, which converts a prompt by directing an ACP agent through the conversion.
|
|
41
|
-
| `codeassembly-agent-logic/react` | `StatechartCanvas`, the key's entries as data (`CANVAS_KEY_ENTRIES` and the mark glyphs), `PromptPane` and its `PromptKey`, and the hooks of a page that presents a chart.
|
|
42
|
-
| `codeassembly-agent-logic/react/styles.css` | The stylesheet of the canvas and the prompt pane.
|
|
43
|
-
| `codeassembly-agent-logic/server` | `createConversionHandler`, which serves conversions on an ACP agent, and its stores.
|
|
44
|
-
| `codeassembly-agent-logic/client` | `createConversionClient`, the browser client of the routes that `createConversionHandler` serves.
|
|
45
|
-
| `codeassembly-agent-logic/job` | `createConversionJob`, which converts a prompt as a job of `@williamthorsen/toolbelt.llm`, in a page or a function, and `createConversionJobFromInput`, which creates the job at an endpoint.
|
|
46
|
-
| `codeassembly-agent-logic/agent-logic.schema.json` | The config's JSON Schema.
|
|
41
|
+
| Entry | Exports |
|
|
42
|
+
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
43
|
+
| `codeassembly-agent-logic` | The config schema, its file-name suffix (`AGENT_LOGIC_SUFFIX`, `isAgentLogicFileName`), and its validation, the converter and coverage check, the chart description, its ELK graph (`buildElkGraph`), its layout, source marking, and the bundled examples. |
|
|
44
|
+
| `codeassembly-agent-logic/agent` | `convertWithAgent`, which converts a prompt by directing an ACP agent through the conversion. |
|
|
45
|
+
| `codeassembly-agent-logic/react` | `StatechartCanvas` and its `CanvasKey`, the key's entries as data (`CANVAS_KEY_ENTRIES` and the mark glyphs), `PromptPane` and its `PromptKey`, `Inspector`, `SourceLine`, the `Workspace` that composes them, the `Messages` panel, the props of the app's button and link, the hooks of a page that presents a chart, and `useDocumentState`, which opens an example or a stored file. |
|
|
46
|
+
| `codeassembly-agent-logic/react/styles.css` | The stylesheet of the canvas and its key, the prompt pane, the inspector, the source line, the workspace, and the messages panel. |
|
|
47
|
+
| `codeassembly-agent-logic/server` | `createConversionHandler`, which serves conversions on an ACP agent, and its stores. |
|
|
48
|
+
| `codeassembly-agent-logic/client` | `createConversionClient`, the browser client of the routes that `createConversionHandler` serves. |
|
|
49
|
+
| `codeassembly-agent-logic/job` | `createConversionJob`, which converts a prompt as a job of `@williamthorsen/toolbelt.llm`, in a page or a function, and `createConversionJobFromInput`, which creates the job at an endpoint. |
|
|
50
|
+
| `codeassembly-agent-logic/agent-logic.schema.json` | The config's JSON Schema. |
|
|
47
51
|
|
|
48
52
|
React 19 is a peer of `./react`, `@williamthorsen/toolbelt.acp` and `@modelcontextprotocol/server` peers of `./agent` and `./server`, and `@williamthorsen/toolbelt.llm` a peer of `./job`.
|
|
49
53
|
|
|
@@ -131,15 +135,21 @@ if (started.ok) {
|
|
|
131
135
|
|
|
132
136
|
## What the app supplies
|
|
133
137
|
|
|
134
|
-
The package draws the chart and the prompt; the page around them is the app's. The app renders the load controls
|
|
138
|
+
The package draws the chart and its key, the prompt, the inspector of the selected element, and the messages panel; the page around them is the app's. The app renders the load controls and the terminal in its own design system. `StatechartCanvas` passes the marks that the chart draws to its `renderKey` prop, into which the app renders `CanvasKey`; `CANVAS_KEY_ENTRIES` gives each mark's name, gloss, and drawing to an app that draws a key of its own.
|
|
139
|
+
|
|
140
|
+
`Workspace` lays the canvas beside the source pane, in which `Inspector` describes the selected element above the `PromptPane`, and `SourceLine` joins the selected element to its passage. It fills the height that its flex parent leaves, and the app sets its outer spacing. The app supplies its links as the required `LinkButton` component, whose props are `LinkButtonProps`: It renders a button styled as an in-page link with its own pointer, hover, and focus states, so that the links match the app's design system, and keeps the underline at rest when `isInline` is set, for a link inside a sentence. `Workspace` also takes an optional `Canvas` component in place of `StatechartCanvas`, through which an app's tests replace React Flow. Each component's doc comment states its props.
|
|
141
|
+
|
|
142
|
+
`CanvasKey` lists the marks that the chart draws, each with its gloss, followed by the optional toggles of the ambient instructions and of the messages panel. `Messages` lists the document's gaps, the converter's findings, and its unconverted passages, and stays hidden until its toggle opens it; the app renders it into `Workspace`'s `messages` prop. `countMessages` returns the counts that the toggle states, and `hasMessages` whether the panel has anything to list. Both components take the app's button as the required `Button` component, whose props are `ButtonProps`: It renders a button that looks like a button at rest, with its own pointer, hover, and focus states, and forwards the ARIA attributes that it receives. A button in a line of text or in the key takes the app's compact size, and one with `isHeading` set, the disclosure that titles a section, takes the heading's text size. `Messages` also takes `LinkButton`.
|
|
143
|
+
|
|
144
|
+
`PromptPane` shows the whole prompt with its key, marking the text that the chart does not use and leaving used text unmarked. It sets each Markdown heading by its level, with its `#` muted, and leaves Markdown structure, such as heading lines and list markers, unmarked. The app supplies its segments, from `buildPromptSegments`, the selected element, the passages to show, and the handler that receives a clicked passage's path. `SourceLine` finds the pane's text by `data-prompt-text` and the passage by `data-passage-for`, whose value is the element's path; `PromptPane`'s doc comment lists its other attributes. `PromptKey` renders the key alone, for an app that places it outside the pane. The app also supplies the URL of the conversions resource to `./client`'s `createConversionClient`.
|
|
135
145
|
|
|
136
|
-
`
|
|
146
|
+
`useDocumentState` owns what the document region shows, the start page, the Visualizations table, or one document, and keeps it in step with the URL and the browser's history. The app supplies the `FileStore` of `@williamthorsen/toolbelt.text-file-store` (its `./proposed` entry) from which a stored file is read and into which the Upload card's text is written, and the `announce` function of its status region; it renders the region and sets the tab title from the state that the hook returns. An app that stores a document of its own kind, such as an unconverted prompt, reads it through the `otherKind` option and writes it through the returned `prepareLoad` and `storeAndOpen`. The hook's doc comment states its options and fields.
|
|
137
147
|
|
|
138
148
|
## Styling and theming
|
|
139
149
|
|
|
140
150
|
Import `codeassembly-agent-logic/react/styles.css` once, through a bundler: It imports React Flow's base styles from this package's own dependency. Its defaults form a finished light theme, which applies under any `color-scheme`.
|
|
141
151
|
|
|
142
|
-
The colours come in two tiers of custom properties. The seeds are a few base colours, and every other colour derives from them, so an app sets the seeds alone to retheme the canvas
|
|
152
|
+
The colours come in two tiers of custom properties. The seeds are a few base colours, and every other colour derives from them, so an app sets the seeds alone to retheme the canvas, its key, the pane, the workspace, and the messages panel, for example to map them to its design tokens or to make a dark theme:
|
|
143
153
|
|
|
144
154
|
```css
|
|
145
155
|
:root {
|
|
@@ -149,7 +159,7 @@ The colours come in two tiers of custom properties. The seeds are a few base col
|
|
|
149
159
|
}
|
|
150
160
|
```
|
|
151
161
|
|
|
152
|
-
Set the properties on `:root`, or on an ancestor of the
|
|
162
|
+
Set the properties on `:root`, or on an ancestor of the components and of any key that the app renders outside them. The seeds, whose defaults [`styles.css`](src/react/styles.css) declares:
|
|
153
163
|
|
|
154
164
|
- `--agent-logic-surface`: the background of a state and of a label
|
|
155
165
|
- `--agent-logic-text`: the text
|
|
@@ -159,14 +169,17 @@ Set the properties on `:root`, or on an ancestor of the canvas, the pane, and an
|
|
|
159
169
|
The component properties, which an app sets to override one part; `styles.css` states each derivation:
|
|
160
170
|
|
|
161
171
|
- `--agent-logic-ambient-background`, `--agent-logic-compound-background`, `--agent-logic-hover-background`: backgrounds, from `text` (and `surface` for a compound state)
|
|
172
|
+
- `--agent-logic-danger-text`: the message of a failed layout, from `warning` and `text`
|
|
173
|
+
- `--agent-logic-information-background`, `--agent-logic-warning-background`: the information and warning sections of the messages panel, from `accent` and `warning` with `surface`
|
|
162
174
|
- `--agent-logic-node-background`, `--agent-logic-tooltip-text`: from `surface`
|
|
163
175
|
- `--agent-logic-selected-background`, `--agent-logic-passage-background`: from `accent` and `surface`; the second fills the pane's selected and shown passages
|
|
164
176
|
- `--agent-logic-text-subtle`, `--agent-logic-text-subtlest`, `--agent-logic-border`, `--agent-logic-border-strong`: from `text` and `surface`; the pane sets unused text in the first and comments in the second
|
|
165
177
|
- `--agent-logic-unconverted`: the wavy line under unconverted text, from `warning` and `text`
|
|
166
178
|
- `--agent-logic-tooltip-background`: from `text`
|
|
167
179
|
- `--agent-logic-focus-ring`, `--agent-logic-selected`: from `accent`
|
|
180
|
+
- `--agent-logic-source-line`: the source line, from `selected`
|
|
168
181
|
|
|
169
|
-
The canvas's ground and its dots also derive from the seeds; React Flow's `--xy-background-color` and `--xy-background-pattern-color` replace them. `--agent-logic-font-code` sets the code font, and `--agent-logic-font-prose` the face in which the pane
|
|
182
|
+
The canvas's ground and its dots also derive from the seeds; React Flow's `--xy-background-color` and `--xy-background-pattern-color` replace them. `--agent-logic-font-code` sets the code font, and `--agent-logic-font-prose` the face in which the pane, a flow's preamble, and the messages panel quote the prompt.
|
|
170
183
|
|
|
171
184
|
## The bin
|
|
172
185
|
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Root entry of `codeassembly-agent-logic`: the agent-logic schema, its file name, validation, coverage, layout, source
|
|
3
|
+
* marking, and examples.
|
|
4
|
+
*/
|
|
2
5
|
export * from './convert/convert-prompt.js';
|
|
3
6
|
export * from './convert/draft-schema.js';
|
|
4
7
|
export * from './coverage-map/check-coverage.js';
|
|
@@ -8,6 +11,7 @@ export { buildElkGraph, type ElkGraphOptions } from './layout/build-elk-graph.js
|
|
|
8
11
|
export * from './layout/describe-config.js';
|
|
9
12
|
export * from './layout/layout-config.js';
|
|
10
13
|
export * from './layout/to-flow-elements.js';
|
|
14
|
+
export * from './schema/agent-logic-file-name.js';
|
|
11
15
|
export * from './schema/agent-logic-schema.js';
|
|
12
16
|
export * from './schema/config-traversal.js';
|
|
13
17
|
export * from './schema/validate-config.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export { buildElkGraph } from "./layout/build-elk-graph.js";
|
|
|
7
7
|
export * from "./layout/describe-config.js";
|
|
8
8
|
export * from "./layout/layout-config.js";
|
|
9
9
|
export * from "./layout/to-flow-elements.js";
|
|
10
|
+
export * from "./schema/agent-logic-file-name.js";
|
|
10
11
|
export * from "./schema/agent-logic-schema.js";
|
|
11
12
|
export * from "./schema/config-traversal.js";
|
|
12
13
|
export * from "./schema/validate-config.js";
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ComponentType, type ReactElement } from 'react';
|
|
2
|
+
import type { ButtonProps } from '../slots.js';
|
|
3
|
+
import type { ChartMark } from './list-chart-marks.js';
|
|
4
|
+
/** The state of the control that shows and hides every flow's preamble of ambient instructions. */
|
|
5
|
+
export interface AmbientToggle {
|
|
6
|
+
/** The number of ambient instructions in the chart, which the control's label states. */
|
|
7
|
+
count: number;
|
|
8
|
+
isShown: boolean;
|
|
9
|
+
onChange: (isShown: boolean) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface CanvasKeyProps {
|
|
12
|
+
/** The marks that the chart draws; the key names only these. */
|
|
13
|
+
marks: ReadonlySet<ChartMark>;
|
|
14
|
+
ambientToggle?: AmbientToggle | undefined;
|
|
15
|
+
messagesToggle?: MessagesToggle | undefined;
|
|
16
|
+
/** The app's button, which the key renders as the toggle of the messages panel. */
|
|
17
|
+
Button: ComponentType<ButtonProps>;
|
|
18
|
+
}
|
|
19
|
+
/** The numbers of each kind of message that a document has. */
|
|
20
|
+
export interface MessageCounts {
|
|
21
|
+
gaps: number;
|
|
22
|
+
findings: number;
|
|
23
|
+
unconverted: number;
|
|
24
|
+
}
|
|
25
|
+
/** The state of the control that opens and closes the messages panel below the canvas. */
|
|
26
|
+
export interface MessagesToggle {
|
|
27
|
+
counts: MessageCounts;
|
|
28
|
+
isOpen: boolean;
|
|
29
|
+
onToggle: () => void;
|
|
30
|
+
/** The id of the panel that the control opens. */
|
|
31
|
+
panelId: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The canvas's key, a strip below the chart: each kind of element that the chart marks, drawn as on the chart, with its
|
|
35
|
+
* gloss on hover and focus, then the control that shows and hides the preambles when the chart has ambient
|
|
36
|
+
* instructions, and the toggle of the messages panel when the document has messages.
|
|
37
|
+
*/
|
|
38
|
+
export declare function CanvasKey({ marks, ambientToggle, messagesToggle, Button }: CanvasKeyProps): ReactElement | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { ChevronIcon } from "../messages/icons.js";
|
|
4
|
+
import { CANVAS_KEY_ENTRIES } from "./canvas-key-entries.js";
|
|
5
|
+
export function CanvasKey({ marks, ambientToggle, messagesToggle, Button }) {
|
|
6
|
+
const entries = CANVAS_KEY_ENTRIES.filter(({ id }) => marks.has(id));
|
|
7
|
+
if (entries.length === 0 && ambientToggle === undefined && messagesToggle === undefined)
|
|
8
|
+
return undefined;
|
|
9
|
+
return (_jsxs("div", { className: "canvas-key", children: [_jsx("ul", { "aria-label": "Key", className: "canvas-key__entries", children: entries.map((entry) => (_jsx(KeyEntry, { entry: entry }, entry.id))) }), _jsxs("div", { className: "canvas-key__controls", children: [ambientToggle === undefined ? undefined : _jsx(AmbientToggleControl, { ...ambientToggle }), messagesToggle === undefined ? undefined : _jsx(MessagesToggleControl, { ...messagesToggle, Button: Button })] })] }));
|
|
10
|
+
}
|
|
11
|
+
function AmbientToggleControl({ count, isShown, onChange }) {
|
|
12
|
+
const inputId = useId();
|
|
13
|
+
return (_jsxs("div", { className: "canvas-key__ambient", children: [_jsx("input", { id: inputId, type: "checkbox", checked: isShown, onChange: (event) => onChange(event.currentTarget.checked) }), _jsxs("label", { htmlFor: inputId, className: "prompt-key__sample--ambient", children: ["Ambient instructions (", count, ")"] })] }));
|
|
14
|
+
}
|
|
15
|
+
function formatCounts({ gaps, findings, unconverted }) {
|
|
16
|
+
const kinds = [
|
|
17
|
+
[gaps, 'gap', 'gaps'],
|
|
18
|
+
[findings, 'finding', 'findings'],
|
|
19
|
+
[unconverted, 'unconverted', 'unconverted'],
|
|
20
|
+
];
|
|
21
|
+
return kinds
|
|
22
|
+
.filter(([count]) => count !== 0)
|
|
23
|
+
.map(([count, singular, plural]) => `${count} ${count === 1 ? singular : plural}`)
|
|
24
|
+
.join(' · ');
|
|
25
|
+
}
|
|
26
|
+
function KeyEntry({ entry: { name, gloss, mark } }) {
|
|
27
|
+
const glossId = useId();
|
|
28
|
+
return (_jsxs("li", { className: "canvas-key__entry", children: [_jsxs("span", { tabIndex: 0, "aria-describedby": glossId, className: "canvas-key__entry-label", children: [mark, name] }), _jsx("span", { id: glossId, role: "tooltip", className: "canvas-key__tooltip", children: gloss })] }));
|
|
29
|
+
}
|
|
30
|
+
function MessagesToggleControl({ counts, isOpen, onToggle, panelId, Button, }) {
|
|
31
|
+
const countsId = useId();
|
|
32
|
+
return (_jsxs("div", { className: "canvas-key__messages", children: [_jsxs(Button, { "aria-expanded": isOpen, "aria-controls": panelId, "aria-describedby": countsId, onClick: onToggle, children: [_jsx(ChevronIcon, { isOpen: isOpen }), "Messages"] }), _jsx("span", { id: countsId, className: "canvas-key__counts", children: formatCounts(counts) })] }));
|
|
33
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { AgentLogicConfig } from '../../schema/agent-logic-schema.js';
|
|
2
|
+
import type { Problem } from '../../schema/validate-config.js';
|
|
3
|
+
import type { SourceLabel } from './label-source.js';
|
|
4
|
+
/** A config that validated, shown as the document's chart. */
|
|
5
|
+
export interface ChartDocument extends SourceLabel {
|
|
6
|
+
kind: 'chart';
|
|
7
|
+
/** Changes with every load, so that the canvas of one load never shows another's chart. */
|
|
8
|
+
key: number;
|
|
9
|
+
/** The example's name or the stored file's name. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Where the document came from, as a word for the app bar. */
|
|
12
|
+
origin: 'Example' | 'File';
|
|
13
|
+
/** The example's slug, which the sidebar marks as current; absent for any other document. */
|
|
14
|
+
slug?: string | undefined;
|
|
15
|
+
/** The stored file's name, which the sidebar marks as current; absent for an example. */
|
|
16
|
+
fileName?: string | undefined;
|
|
17
|
+
config: AgentLogicConfig;
|
|
18
|
+
}
|
|
19
|
+
/** An example or a stored file that the page could not open, reported on the start page under its title. */
|
|
20
|
+
export interface DocumentReport {
|
|
21
|
+
title: string;
|
|
22
|
+
/** The line that names the document's source, when the page read the document but could not load it. */
|
|
23
|
+
source?: string | undefined;
|
|
24
|
+
/** Why the page could not read the document. */
|
|
25
|
+
message?: string | undefined;
|
|
26
|
+
problems: Problem[];
|
|
27
|
+
}
|
|
28
|
+
/** Where uploaded text came from: a dropped or picked file, or typed or pasted text. */
|
|
29
|
+
export type InputOrigin = {
|
|
30
|
+
kind: 'file';
|
|
31
|
+
fileName: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'paste';
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Why text from a card did not load: text that is not of the card's kind, a stored file that already has the text's
|
|
37
|
+
* name, or a write that the store refused or did not receive.
|
|
38
|
+
*/
|
|
39
|
+
export type LoadFailure = {
|
|
40
|
+
kind: 'invalid' | 'not-json' | 'other-kind' | 'store' | 'syntax';
|
|
41
|
+
problems: Problem[];
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'conflict';
|
|
44
|
+
name: string;
|
|
45
|
+
problems: Problem[];
|
|
46
|
+
};
|
|
47
|
+
/** How a card's text is loaded; `replace` overwrites a stored file that has the text's name. */
|
|
48
|
+
export interface LoadOptions {
|
|
49
|
+
replace?: boolean | undefined;
|
|
50
|
+
}
|
|
51
|
+
/** The document that the document region shows: a chart, or a stored document of a kind that the app defines. */
|
|
52
|
+
export type OpenDocument<TOther extends OtherDocument = never> = ChartDocument | TOther;
|
|
53
|
+
/**
|
|
54
|
+
* A stored document of a kind that the app defines, such as an unconverted prompt. Its `kind` must not be `'chart'`,
|
|
55
|
+
* which `isChartDocument` reads as a chart.
|
|
56
|
+
*/
|
|
57
|
+
export interface OtherDocument {
|
|
58
|
+
kind: string;
|
|
59
|
+
/** Changes with every load, so that the view of one load never keeps another's state. */
|
|
60
|
+
key: number;
|
|
61
|
+
name: string;
|
|
62
|
+
fileName: string;
|
|
63
|
+
}
|
|
64
|
+
/** How a page opens and announces stored text of a kind that the app defines. */
|
|
65
|
+
export interface OtherKindHandlers<TOther extends OtherDocument> {
|
|
66
|
+
/** Returns the document of a stored file of this kind, or `undefined` for a file to open as a chart. */
|
|
67
|
+
read: (name: string, text: string, key: number) => TOther | undefined;
|
|
68
|
+
/** Returns the announcement of an opened document of this kind. */
|
|
69
|
+
describe: (document: TOther) => string;
|
|
70
|
+
}
|
|
71
|
+
/** Reports whether the open document is a chart rather than a document of a kind that the app defines. */
|
|
72
|
+
export declare function isChartDocument<TOther extends OtherDocument>(document: OpenDocument<TOther>): document is ChartDocument;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Returns the URL search string that names a stored file, and nothing else, so that a link to it can be shared. */
|
|
2
|
+
export declare function buildFileSearch(name: string): string;
|
|
3
|
+
/** Returns the URL of the start page: the page's path without a search string. */
|
|
4
|
+
export declare function buildStartLocation(): string;
|
|
5
|
+
/** Returns the URL search string that names the Visualizations table. */
|
|
6
|
+
export declare function buildVisualizationsSearch(): string;
|
|
7
|
+
/** Returns the stored file that a URL search string names, or `undefined` when it names none. */
|
|
8
|
+
export declare function findFileInSearch(search: string): string | undefined;
|
|
9
|
+
/** Reports whether a URL search string names the Visualizations table. */
|
|
10
|
+
export declare function isVisualizationsSearch(search: string): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function buildFileSearch(name) {
|
|
2
|
+
return `?${new URLSearchParams({ [FILE_PARAMETER]: name }).toString()}`;
|
|
3
|
+
}
|
|
4
|
+
export function buildStartLocation() {
|
|
5
|
+
return globalThis.location.pathname;
|
|
6
|
+
}
|
|
7
|
+
export function buildVisualizationsSearch() {
|
|
8
|
+
return `?${new URLSearchParams({ [VIEW_PARAMETER]: VISUALIZATIONS_VIEW }).toString()}`;
|
|
9
|
+
}
|
|
10
|
+
export function findFileInSearch(search) {
|
|
11
|
+
const name = new URLSearchParams(search).get(FILE_PARAMETER);
|
|
12
|
+
return name === null || name === '' ? undefined : name;
|
|
13
|
+
}
|
|
14
|
+
export function isVisualizationsSearch(search) {
|
|
15
|
+
return new URLSearchParams(search).get(VIEW_PARAMETER) === VISUALIZATIONS_VIEW;
|
|
16
|
+
}
|
|
17
|
+
const FILE_PARAMETER = 'file';
|
|
18
|
+
const VIEW_PARAMETER = 'view';
|
|
19
|
+
const VISUALIZATIONS_VIEW = 'visualizations';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { sanitizeName } from "../../convert/sanitize-name.js";
|
|
2
|
+
import { AGENT_LOGIC_SUFFIX } from "../../schema/agent-logic-file-name.js";
|
|
2
3
|
export function labelSource(origin) {
|
|
3
4
|
const [source, base] = describe(origin);
|
|
4
|
-
return { source, downloadName: `${base}
|
|
5
|
+
return { source, downloadName: `${base}${AGENT_LOGIC_SUFFIX}` };
|
|
5
6
|
}
|
|
6
7
|
function describe(origin) {
|
|
7
8
|
switch (origin.kind) {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { StoredFileRead } from '@williamthorsen/toolbelt.text-file-store/proposed';
|
|
2
|
+
import type { Example } from '../../examples/examples.js';
|
|
3
|
+
import type { AgentLogicConfig } from '../../schema/agent-logic-schema.js';
|
|
4
|
+
import { type ChartDocument, type DocumentReport, type LoadFailure, type OpenDocument, type OtherDocument, type OtherKindHandlers } from './document-types.js';
|
|
5
|
+
import { type TextOrigin } from './parse-config-text.js';
|
|
6
|
+
/** Returns the document of a stored agent-logic file. */
|
|
7
|
+
export declare function buildChartDocument(fileName: string, config: AgentLogicConfig, key: number): ChartDocument;
|
|
8
|
+
/** Returns the announcement of a document that opened: a chart's description, or that of the app's own kind. */
|
|
9
|
+
export declare function describeDocument<TOther extends OtherDocument = never>(document: OpenDocument<TOther>, otherKind?: OtherKindHandlers<TOther>): string;
|
|
10
|
+
/** Returns the announcement of a report: its problems when the page read the document, or its message. */
|
|
11
|
+
export declare function describeReport(report: DocumentReport): string;
|
|
12
|
+
/** Returns the announcement of what the document region now shows, or `undefined` for the start page. */
|
|
13
|
+
export declare function describeShown<TOther extends OtherDocument = never>({ document, report, view }: Shown<TOther>, otherKind?: OtherKindHandlers<TOther>): string | undefined;
|
|
14
|
+
/** Reports whether nothing is shown, which is the start page. */
|
|
15
|
+
export declare function isStartPageShown<TOther extends OtherDocument>({ document, report, opening, view, }: Shown<TOther>): boolean;
|
|
16
|
+
/** Returns the config that the text parses and validates to, with its parsed value, or why it did not load. */
|
|
17
|
+
export declare function readConfigText(text: string, origin: TextOrigin): {
|
|
18
|
+
ok: true;
|
|
19
|
+
config: AgentLogicConfig;
|
|
20
|
+
value: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
failure: LoadFailure;
|
|
24
|
+
};
|
|
25
|
+
/** Returns what the page shows for an example, or the start page when there is none. */
|
|
26
|
+
export declare function readExample(example: Example | undefined, key: number): Shown;
|
|
27
|
+
/**
|
|
28
|
+
* Returns what the page shows first for its URL: the Visualizations table, a stored file to read, an example, or the
|
|
29
|
+
* start page.
|
|
30
|
+
*/
|
|
31
|
+
export declare function readLocation(key: number): Shown;
|
|
32
|
+
/**
|
|
33
|
+
* Returns what the page shows for a stored file's read: its document, as the app's own kind when `otherKind` reads it
|
|
34
|
+
* as one and as a chart otherwise, or a report on why it did not open.
|
|
35
|
+
*/
|
|
36
|
+
export declare function readStoredFile<TOther extends OtherDocument = never>(name: string, read: StoredFileRead, key: number, otherKind?: OtherKindHandlers<TOther>): Shown<TOther>;
|
|
37
|
+
/**
|
|
38
|
+
* What the document region shows: a document, a report on a document that did not open, the stored file being read,
|
|
39
|
+
* the Visualizations table, or none of them, which is the start page.
|
|
40
|
+
*/
|
|
41
|
+
export interface Shown<TOther extends OtherDocument = never> {
|
|
42
|
+
document?: OpenDocument<TOther> | undefined;
|
|
43
|
+
report?: DocumentReport | undefined;
|
|
44
|
+
opening?: string | undefined;
|
|
45
|
+
view?: 'visualizations' | undefined;
|
|
46
|
+
}
|
|
47
|
+
/** The heading of the Visualizations table, which also names it in the tab title and the announcement. */
|
|
48
|
+
export declare const VISUALIZATIONS_TITLE = "All visualizations";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { validateConfig } from "../../schema/validate-config.js";
|
|
2
|
+
import { describeLoaded, describeNotLoaded } from "./describe-load-outcome.js";
|
|
3
|
+
import { isChartDocument, } from "./document-types.js";
|
|
4
|
+
import { findExampleInSearch } from "./example-location.js";
|
|
5
|
+
import { findFileInSearch, isVisualizationsSearch } from "./file-location.js";
|
|
6
|
+
import { labelSource } from "./label-source.js";
|
|
7
|
+
import { parseConfigText } from "./parse-config-text.js";
|
|
8
|
+
export function buildChartDocument(fileName, config, key) {
|
|
9
|
+
const label = labelSource({ kind: 'file', fileName });
|
|
10
|
+
return { ...label, kind: 'chart', key, name: fileName, origin: 'File', fileName, config };
|
|
11
|
+
}
|
|
12
|
+
export function describeDocument(document, otherKind) {
|
|
13
|
+
if (isChartDocument(document))
|
|
14
|
+
return describeLoaded(document.source, document.config);
|
|
15
|
+
return otherKind === undefined ? `Opened ${document.name}.` : otherKind.describe(document);
|
|
16
|
+
}
|
|
17
|
+
export function describeReport(report) {
|
|
18
|
+
return report.source === undefined
|
|
19
|
+
? `${report.title}: ${report.message ?? ''}`
|
|
20
|
+
: describeNotLoaded(report.source, report.problems);
|
|
21
|
+
}
|
|
22
|
+
export function describeShown({ document, report, view }, otherKind) {
|
|
23
|
+
if (view !== undefined)
|
|
24
|
+
return `Opened ${VISUALIZATIONS_TITLE}.`;
|
|
25
|
+
return document === undefined ? report && describeReport(report) : describeDocument(document, otherKind);
|
|
26
|
+
}
|
|
27
|
+
export function isStartPageShown({ document, report, opening, view, }) {
|
|
28
|
+
return document === undefined && report === undefined && opening === undefined && view === undefined;
|
|
29
|
+
}
|
|
30
|
+
export function readConfigText(text, origin) {
|
|
31
|
+
const read = parseConfigText(text, origin);
|
|
32
|
+
if (!read.ok)
|
|
33
|
+
return { ok: false, failure: { kind: read.isNotJson ? 'not-json' : 'syntax', problems: read.problems } };
|
|
34
|
+
const result = validateConfig(read.value);
|
|
35
|
+
return result.ok
|
|
36
|
+
? { ok: true, config: result.config, value: read.value }
|
|
37
|
+
: { ok: false, failure: { kind: 'invalid', problems: result.problems } };
|
|
38
|
+
}
|
|
39
|
+
export function readExample(example, key) {
|
|
40
|
+
if (example === undefined)
|
|
41
|
+
return {};
|
|
42
|
+
const origin = { kind: 'example', name: example.name, slug: example.slug };
|
|
43
|
+
const label = labelSource(origin);
|
|
44
|
+
const result = validateConfig(example.value);
|
|
45
|
+
return result.ok
|
|
46
|
+
? {
|
|
47
|
+
document: {
|
|
48
|
+
...label,
|
|
49
|
+
kind: 'chart',
|
|
50
|
+
key,
|
|
51
|
+
name: example.name,
|
|
52
|
+
origin: 'Example',
|
|
53
|
+
slug: example.slug,
|
|
54
|
+
config: result.config,
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
: { report: { title: 'Example not loaded', source: label.source, problems: result.problems } };
|
|
58
|
+
}
|
|
59
|
+
export function readLocation(key) {
|
|
60
|
+
if (isVisualizationsSearch(globalThis.location.search))
|
|
61
|
+
return { view: 'visualizations' };
|
|
62
|
+
const fileName = findFileInSearch(globalThis.location.search);
|
|
63
|
+
return fileName === undefined
|
|
64
|
+
? readExample(findExampleInSearch(globalThis.location.search), key)
|
|
65
|
+
: { opening: fileName };
|
|
66
|
+
}
|
|
67
|
+
export function readStoredFile(name, read, key, otherKind) {
|
|
68
|
+
if (!read.ok) {
|
|
69
|
+
return {
|
|
70
|
+
report: read.reason === 'missing'
|
|
71
|
+
? {
|
|
72
|
+
title: 'File not found',
|
|
73
|
+
message: `The store does not hold ${name}. Choose a file under Recents.`,
|
|
74
|
+
problems: [],
|
|
75
|
+
}
|
|
76
|
+
: { title: 'File not opened', message: read.message, problems: [] },
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const other = otherKind?.read(name, read.text, key);
|
|
80
|
+
if (other !== undefined)
|
|
81
|
+
return { document: other };
|
|
82
|
+
const parsed = readConfigText(read.text, 'file');
|
|
83
|
+
if (parsed.ok)
|
|
84
|
+
return { document: buildChartDocument(name, parsed.config, key) };
|
|
85
|
+
const { source } = labelSource({ kind: 'file', fileName: name });
|
|
86
|
+
return { report: { title: 'File not loaded', source, problems: parsed.failure.problems } };
|
|
87
|
+
}
|
|
88
|
+
export const VISUALIZATIONS_TITLE = 'All visualizations';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Returns a file name without its last extension when a base precedes it, or the name itself. */
|
|
2
|
+
export declare function dropLastExtension(fileName: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* Replaces each run of characters that a stored name does not take with `-`, and trims leading dots and dashes; a base
|
|
5
|
+
* of which none of its characters remains becomes the fallback.
|
|
6
|
+
*/
|
|
7
|
+
export declare function sanitizeStoredBase(base: string, fallback: string): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function dropLastExtension(fileName) {
|
|
2
|
+
const dot = fileName.lastIndexOf('.');
|
|
3
|
+
return dot > 0 ? fileName.slice(0, dot) : fileName;
|
|
4
|
+
}
|
|
5
|
+
export function sanitizeStoredBase(base, fallback) {
|
|
6
|
+
const sanitized = base.replaceAll(/[^\w.-]+/g, '-').replace(/^[.-]+/, '');
|
|
7
|
+
return sanitized === '' ? fallback : sanitized;
|
|
8
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AgentLogicConfig } from '../../schema/agent-logic-schema.js';
|
|
2
|
+
import type { InputOrigin } from './document-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the name under which an upload is stored: a dropped or picked file's name, with `.agent-logic.json` in place
|
|
5
|
+
* of its last extension, or a pasted config's `id`, each with its base sanitized into a name that the store accepts.
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildStoredUploadName(origin: InputOrigin, config: AgentLogicConfig): string;
|
|
8
|
+
/** Returns the text that is stored for an upload: its parsed JSON, re-serialized without any Markdown code fence. */
|
|
9
|
+
export declare function buildStoredUploadText(value: unknown): string;
|