codeassembly-agent-logic 0.8.0 → 0.9.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 +28 -0
- package/CHANGELOG.md +10 -0
- package/README.md +29 -13
- 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/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/package.json +2 -2
package/.meta/changelog.json
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.9.0",
|
|
4
|
+
"date": "2026-11-22",
|
|
5
|
+
"sections": [
|
|
6
|
+
{
|
|
7
|
+
"title": "🎉 Features",
|
|
8
|
+
"audience": "all",
|
|
9
|
+
"items": [
|
|
10
|
+
{
|
|
11
|
+
"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)",
|
|
12
|
+
"hash": "1e507c103d73bfdd750a7c17c09ac4c06dfdeddf",
|
|
13
|
+
"entry": 1
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"title": "🐛 Bug fixes",
|
|
19
|
+
"audience": "all",
|
|
20
|
+
"items": [
|
|
21
|
+
{
|
|
22
|
+
"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)",
|
|
23
|
+
"hash": "1e507c103d73bfdd750a7c17c09ac4c06dfdeddf",
|
|
24
|
+
"entry": 2
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
2
30
|
{
|
|
3
31
|
"version": "0.8.0",
|
|
4
32
|
"date": "2026-11-21",
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## 0.9.0 — 2026-11-22
|
|
6
|
+
|
|
7
|
+
### 🎉 Features
|
|
8
|
+
|
|
9
|
+
- 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)
|
|
10
|
+
|
|
11
|
+
### 🐛 Bug fixes
|
|
12
|
+
|
|
13
|
+
- 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)
|
|
14
|
+
|
|
5
15
|
## 0.8.0 — 2026-11-21
|
|
6
16
|
|
|
7
17
|
### 🎉 Features
|
package/README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
<!-- section:release-notes -->
|
|
2
|
-
## Release notes — v0.
|
|
2
|
+
## Release notes — v0.9.0 (2026-11-22)
|
|
3
3
|
|
|
4
4
|
### 🎉 Features
|
|
5
5
|
|
|
6
|
-
-
|
|
7
|
-
|
|
6
|
+
- 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)
|
|
7
|
+
|
|
8
|
+
### 🐛 Bug fixes
|
|
9
|
+
|
|
10
|
+
- 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)
|
|
8
11
|
<!-- /section:release-notes -->
|
|
9
12
|
|
|
10
13
|
<!-- readme-type: library -->
|
|
@@ -31,16 +34,16 @@ if (result.ok) {
|
|
|
31
34
|
|
|
32
35
|
## Entries
|
|
33
36
|
|
|
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.
|
|
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. |
|
|
44
47
|
|
|
45
48
|
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
49
|
|
|
@@ -81,6 +84,19 @@ if (outcome.status === 'completed') console.log(outcome.result);
|
|
|
81
84
|
|
|
82
85
|
`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
86
|
|
|
87
|
+
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:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { createConversionJobFromInput } from 'codeassembly-agent-logic/job';
|
|
91
|
+
import { createJobHandler } from '@williamthorsen/toolbelt.llm/proposed';
|
|
92
|
+
|
|
93
|
+
export const POST = createJobHandler({
|
|
94
|
+
createJob: createConversionJobFromInput,
|
|
95
|
+
connection: { provider: 'anthropic', model: 'claude-sonnet-5-5', apiKey: operatorKey },
|
|
96
|
+
maxInputLength: 100_000,
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
84
100
|
## Serving conversions
|
|
85
101
|
|
|
86
102
|
```ts
|
|
@@ -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
|
}
|
|
@@ -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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeassembly-agent-logic",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Model of an agent prompt's states and transitions, with React and server entries for the apps that present it",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@types/react": "19.3.0",
|
|
81
81
|
"@types/react-dom": "19.3.0",
|
|
82
82
|
"@vitejs/plugin-react": "6.3.0",
|
|
83
|
-
"@williamthorsen/nmr": "2.3.
|
|
83
|
+
"@williamthorsen/nmr": "2.3.1",
|
|
84
84
|
"@williamthorsen/toolbelt.acp": "0.3.3",
|
|
85
85
|
"@williamthorsen/toolbelt.llm": "0.2.1",
|
|
86
86
|
"eslint": "10.15.0",
|