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.
- package/.meta/changelog.json +85 -0
- package/CHANGELOG.md +24 -0
- package/README.md +47 -18
- package/dist/esm/agent/convert-with-agent.d.ts +3 -3
- package/dist/esm/agent/convert-with-agent.js +2 -1
- package/dist/esm/conversion-session/format-conversion-input.d.ts +9 -0
- package/dist/esm/conversion-session/format-conversion-input.js +11 -1
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/job/create-conversion-job.d.ts +10 -1
- package/dist/esm/job/create-conversion-job.js +6 -2
- package/dist/esm/job/index.d.ts +1 -1
- package/dist/esm/job/index.js +1 -1
- 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 +4 -3
package/.meta/changelog.json
CHANGED
|
@@ -1,4 +1,89 @@
|
|
|
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
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"version": "0.9.0",
|
|
61
|
+
"date": "2026-11-22",
|
|
62
|
+
"sections": [
|
|
63
|
+
{
|
|
64
|
+
"title": "๐ Features",
|
|
65
|
+
"audience": "all",
|
|
66
|
+
"items": [
|
|
67
|
+
{
|
|
68
|
+
"description": "Adds `createConversionJobFromInput` to `codeassembly-agent-logic/job`, which recreates the job that `createConversionJob` created from the input that `runJob` posts, for use as the `createJob` option of `createJobHandler` at an operator's endpoint. (#2305)",
|
|
69
|
+
"hash": "1e507c103d73bfdd750a7c17c09ac4c06dfdeddf",
|
|
70
|
+
"entry": 1
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"title": "๐ Bug fixes",
|
|
76
|
+
"audience": "all",
|
|
77
|
+
"items": [
|
|
78
|
+
{
|
|
79
|
+
"description": "Fixes the issue that `createConversionJob` and `convertWithAgent` accepted a prompt file name containing a newline and sent part of the name to the model as the prompt; both now throw for such a name before the conversion starts. (#2305)",
|
|
80
|
+
"hash": "1e507c103d73bfdd750a7c17c09ac4c06dfdeddf",
|
|
81
|
+
"entry": 2
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
},
|
|
2
87
|
{
|
|
3
88
|
"version": "0.8.0",
|
|
4
89
|
"date": "2026-11-21",
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,30 @@
|
|
|
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
|
+
|
|
19
|
+
## 0.9.0 โ 2026-11-22
|
|
20
|
+
|
|
21
|
+
### ๐ Features
|
|
22
|
+
|
|
23
|
+
- Adds `createConversionJobFromInput` to `codeassembly-agent-logic/job`, which recreates the job that `createConversionJob` created from the input that `runJob` posts, for use as the `createJob` option of `createJobHandler` at an operator's endpoint. (#2305)
|
|
24
|
+
|
|
25
|
+
### ๐ Bug fixes
|
|
26
|
+
|
|
27
|
+
- Fixes the issue that `createConversionJob` and `convertWithAgent` accepted a prompt file name containing a newline and sent part of the name to the model as the prompt; both now throw for such a name before the conversion starts. (#2305)
|
|
28
|
+
|
|
5
29
|
## 0.8.0 โ 2026-11-21
|
|
6
30
|
|
|
7
31
|
### ๐ Features
|
package/README.md
CHANGED
|
@@ -1,10 +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
|
-
-
|
|
7
|
-
-
|
|
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)
|
|
8
15
|
<!-- /section:release-notes -->
|
|
9
16
|
|
|
10
17
|
<!-- readme-type: library -->
|
|
@@ -31,16 +38,16 @@ if (result.ok) {
|
|
|
31
38
|
|
|
32
39
|
## Entries
|
|
33
40
|
|
|
34
|
-
| Entry | Exports
|
|
35
|
-
| -------------------------------------------------- |
|
|
36
|
-
| `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.
|
|
37
|
-
| `codeassembly-agent-logic/agent` | `convertWithAgent`, which converts a prompt by directing an ACP agent through the conversion.
|
|
38
|
-
| `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.
|
|
39
|
-
| `codeassembly-agent-logic/react/styles.css` | The stylesheet of the canvas and the prompt pane.
|
|
40
|
-
| `codeassembly-agent-logic/server` | `createConversionHandler`, which serves conversions on an ACP agent, and its stores.
|
|
41
|
-
| `codeassembly-agent-logic/client` | `createConversionClient`, the browser client of the routes that `createConversionHandler` serves.
|
|
42
|
-
| `codeassembly-agent-logic/job` | `createConversionJob`, which converts a prompt as a job of `@williamthorsen/toolbelt.llm`, in a page or a function.
|
|
43
|
-
| `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. |
|
|
44
51
|
|
|
45
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`.
|
|
46
53
|
|
|
@@ -81,6 +88,19 @@ if (outcome.status === 'completed') console.log(outcome.result);
|
|
|
81
88
|
|
|
82
89
|
`createConversionJob` returns a job for [`@williamthorsen/toolbelt.llm`](https://github.com/williamthorsen/toolbelt/tree/main/packages/llm#readme), which runs it in the page on a user's connection or at an operator's endpoint, without a harness. The job sends the instructions and the message that `convertWithAgent` sends, offers the same two tools with the same caps, and makes at most `MAX_ROUNDS` model requests. Its result is a `ConvertResult`, available once the conversion is finished: the config accepted, the prompt recorded out of scope, or the last of the 5 submissions rejected. A run that the model ends earlier is `unfinished`. Create a job for each run.
|
|
83
90
|
|
|
91
|
+
When the page runs the job at an operator's endpoint, `runJob` posts only the job's input, and the endpoint's `createJobHandler` creates the job from it. `createConversionJobFromInput` creates the job that `createConversionJob` created for that input, and throws for input that `createConversionJob` does not create:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
import { createConversionJobFromInput } from 'codeassembly-agent-logic/job';
|
|
95
|
+
import { createJobHandler } from '@williamthorsen/toolbelt.llm/proposed';
|
|
96
|
+
|
|
97
|
+
export const POST = createJobHandler({
|
|
98
|
+
createJob: createConversionJobFromInput,
|
|
99
|
+
connection: { provider: 'anthropic', model: 'claude-sonnet-5-5', apiKey: operatorKey },
|
|
100
|
+
maxInputLength: 100_000,
|
|
101
|
+
});
|
|
102
|
+
```
|
|
103
|
+
|
|
84
104
|
## Serving conversions
|
|
85
105
|
|
|
86
106
|
```ts
|
|
@@ -115,15 +135,21 @@ if (started.ok) {
|
|
|
115
135
|
|
|
116
136
|
## What the app supplies
|
|
117
137
|
|
|
118
|
-
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`.
|
|
119
145
|
|
|
120
|
-
`
|
|
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.
|
|
121
147
|
|
|
122
148
|
## Styling and theming
|
|
123
149
|
|
|
124
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`.
|
|
125
151
|
|
|
126
|
-
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:
|
|
127
153
|
|
|
128
154
|
```css
|
|
129
155
|
:root {
|
|
@@ -133,7 +159,7 @@ The colours come in two tiers of custom properties. The seeds are a few base col
|
|
|
133
159
|
}
|
|
134
160
|
```
|
|
135
161
|
|
|
136
|
-
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:
|
|
137
163
|
|
|
138
164
|
- `--agent-logic-surface`: the background of a state and of a label
|
|
139
165
|
- `--agent-logic-text`: the text
|
|
@@ -143,14 +169,17 @@ Set the properties on `:root`, or on an ancestor of the canvas, the pane, and an
|
|
|
143
169
|
The component properties, which an app sets to override one part; `styles.css` states each derivation:
|
|
144
170
|
|
|
145
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`
|
|
146
174
|
- `--agent-logic-node-background`, `--agent-logic-tooltip-text`: from `surface`
|
|
147
175
|
- `--agent-logic-selected-background`, `--agent-logic-passage-background`: from `accent` and `surface`; the second fills the pane's selected and shown passages
|
|
148
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
|
|
149
177
|
- `--agent-logic-unconverted`: the wavy line under unconverted text, from `warning` and `text`
|
|
150
178
|
- `--agent-logic-tooltip-background`: from `text`
|
|
151
179
|
- `--agent-logic-focus-ring`, `--agent-logic-selected`: from `accent`
|
|
180
|
+
- `--agent-logic-source-line`: the source line, from `selected`
|
|
152
181
|
|
|
153
|
-
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.
|
|
154
183
|
|
|
155
184
|
## The bin
|
|
156
185
|
|
|
@@ -41,9 +41,9 @@ export type ConversionEvent = SessionEvent | {
|
|
|
41
41
|
* and submission, then a `result` event that contains the outcome of the last submission.
|
|
42
42
|
*
|
|
43
43
|
* Rejects before the agent starts when the profile cannot identify calls of the conversion's tools, which
|
|
44
|
-
* `codexProfile` cannot; when the agent ends its turn without submitting a draft;
|
|
45
|
-
* signal aborts; and, when the agent fails, with an error that names the cause, such
|
|
46
|
-
* in.
|
|
44
|
+
* `codexProfile` cannot, or when the name contains a newline; when the agent ends its turn without submitting a draft;
|
|
45
|
+
* with the signal's reason when the signal aborts; and, when the agent fails, with an error that names the cause, such
|
|
46
|
+
* as a harness that is not signed in.
|
|
47
47
|
*
|
|
48
48
|
* @stage proposed
|
|
49
49
|
* @experimental
|
|
@@ -17,6 +17,7 @@ export function createConvertWithAgent(runPromptImpl) {
|
|
|
17
17
|
if (agent.isToolServerCall === undefined) {
|
|
18
18
|
throw new Error(`The agent \`${agent.command}\` cannot convert a prompt: Its profile cannot identify calls of the conversion's tools, so they would be refused.`);
|
|
19
19
|
}
|
|
20
|
+
const input = formatConversionInput(prompt, name);
|
|
20
21
|
signal?.throwIfAborted();
|
|
21
22
|
const pending = [];
|
|
22
23
|
const session = createConversionSession({
|
|
@@ -34,7 +35,7 @@ export function createConvertWithAgent(runPromptImpl) {
|
|
|
34
35
|
agent,
|
|
35
36
|
cwd,
|
|
36
37
|
instructions: CONVERSION_INSTRUCTIONS,
|
|
37
|
-
prompt:
|
|
38
|
+
prompt: input,
|
|
38
39
|
tools: {
|
|
39
40
|
name: CONVERSION_SERVER_NAME,
|
|
40
41
|
createServer: () => createConversionServer(session),
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns the message that starts a conversion: a header line naming the prompt's file, a blank line, and the prompt.
|
|
3
|
+
* Throws for a name that contains a newline, which the header line cannot hold.
|
|
3
4
|
*/
|
|
4
5
|
export declare function formatConversionInput(prompt: string, name: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Returns the prompt and the file name from which `formatConversionInput` formatted `input`. Throws when `input` is not
|
|
8
|
+
* in that format.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseConversionInput(input: string): {
|
|
11
|
+
prompt: string;
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
const HEADER_PREFIX = 'Prompt file: ';
|
|
1
2
|
export function formatConversionInput(prompt, name) {
|
|
2
|
-
|
|
3
|
+
if (name.includes('\n'))
|
|
4
|
+
throw new Error(`The prompt's file name cannot contain a newline: ${JSON.stringify(name)}.`);
|
|
5
|
+
return `${HEADER_PREFIX}${name}\n\n${prompt}`;
|
|
6
|
+
}
|
|
7
|
+
export function parseConversionInput(input) {
|
|
8
|
+
const headerEnd = input.indexOf('\n');
|
|
9
|
+
if (!input.startsWith(HEADER_PREFIX) || headerEnd === -1 || input[headerEnd + 1] !== '\n') {
|
|
10
|
+
throw new Error('Conversion input must start with a `' + HEADER_PREFIX + '{name}` line followed by a blank line.');
|
|
11
|
+
}
|
|
12
|
+
return { prompt: input.slice(headerEnd + 2), name: input.slice(HEADER_PREFIX.length, headerEnd) };
|
|
3
13
|
}
|
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";
|
|
@@ -20,9 +20,18 @@ export interface ConversionJobOptions {
|
|
|
20
20
|
* instructions and message as `convertWithAgent`, checks its coverage map through `check_coverage`, and submits each
|
|
21
21
|
* draft through `submit_draft`, with the same caps. The job's result is the outcome of the submission that finished
|
|
22
22
|
* the conversion: an accepted config, an out-of-scope verdict, or the problems of the last submission accepted. A run
|
|
23
|
-
* that the model ends before then is unfinished. Create a job for each run.
|
|
23
|
+
* that the model ends before then is unfinished. Create a job for each run. Throws for a name that contains a newline.
|
|
24
24
|
*
|
|
25
25
|
* @stage proposed
|
|
26
26
|
* @experimental
|
|
27
27
|
*/
|
|
28
28
|
export declare function createConversionJob({ prompt, name }: ConversionJobOptions): Job<ConvertResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Creates the job that `createConversionJob` creates for a prompt, from that job's `input`: the string that `runJob`
|
|
31
|
+
* posts to an operator's endpoint, for the `createJob` of `createJobHandler`. Throws when `input` is not one that
|
|
32
|
+
* `createConversionJob` creates.
|
|
33
|
+
*
|
|
34
|
+
* @stage proposed
|
|
35
|
+
* @experimental
|
|
36
|
+
*/
|
|
37
|
+
export declare function createConversionJobFromInput(input: string): Job<ConvertResult>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { CHECK_COVERAGE_DESCRIPTION, SUBMIT_DRAFT_DESCRIPTION } from "../conversion-session/conversion-tools.js";
|
|
3
3
|
import { createConversionSession, MAX_COVERAGE_CHECKS, MAX_SUBMISSIONS, } from "../conversion-session/create-conversion-session.js";
|
|
4
|
-
import { formatConversionInput } from "../conversion-session/format-conversion-input.js";
|
|
4
|
+
import { formatConversionInput, parseConversionInput } from "../conversion-session/format-conversion-input.js";
|
|
5
5
|
import { coverageMapSchema } from "../coverage-map/coverage-map-schema.js";
|
|
6
6
|
import { CONVERSION_INSTRUCTIONS } from "../instructions/conversion-instructions.js";
|
|
7
7
|
export const MAX_ROUNDS = MAX_COVERAGE_CHECKS + MAX_SUBMISSIONS + 2;
|
|
8
8
|
export function createConversionJob({ prompt, name }) {
|
|
9
|
+
const input = formatConversionInput(prompt, name);
|
|
9
10
|
const session = createConversionSession({ prompt, name, onEvent: () => { } });
|
|
10
11
|
let finished;
|
|
11
12
|
const checkCoverage = {
|
|
@@ -25,9 +26,12 @@ export function createConversionJob({ prompt, name }) {
|
|
|
25
26
|
};
|
|
26
27
|
return {
|
|
27
28
|
instructions: CONVERSION_INSTRUCTIONS,
|
|
28
|
-
input
|
|
29
|
+
input,
|
|
29
30
|
tools: { check_coverage: checkCoverage, submit_draft: submitDraft },
|
|
30
31
|
maxRounds: MAX_ROUNDS,
|
|
31
32
|
readResult: () => finished,
|
|
32
33
|
};
|
|
33
34
|
}
|
|
35
|
+
export function createConversionJobFromInput(input) {
|
|
36
|
+
return createConversionJob(parseConversionInput(input));
|
|
37
|
+
}
|
package/dist/esm/job/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** `./job` entry: converts a prompt as a job of `@williamthorsen/toolbelt.llm`, in a page or a function. */
|
|
2
2
|
export { MAX_COVERAGE_CHECKS, MAX_SUBMISSIONS } from '../conversion-session/create-conversion-session.js';
|
|
3
3
|
export type { ConvertResult } from '../convert/convert-prompt.js';
|
|
4
|
-
export { type ConversionJobOptions, createConversionJob, MAX_ROUNDS } from './create-conversion-job.js';
|
|
4
|
+
export { type ConversionJobOptions, createConversionJob, createConversionJobFromInput, MAX_ROUNDS, } from './create-conversion-job.js';
|
package/dist/esm/job/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { MAX_COVERAGE_CHECKS, MAX_SUBMISSIONS } from "../conversion-session/create-conversion-session.js";
|
|
2
|
-
export { createConversionJob, MAX_ROUNDS } from "./create-conversion-job.js";
|
|
2
|
+
export { createConversionJob, createConversionJobFromInput, MAX_ROUNDS, } from "./create-conversion-job.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) {
|