@praudent/dagma 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin-ui/assets/index-CHJ8lsZp.js +120 -0
- package/dist/admin-ui/assets/index-XyqtD-IA.css +1 -0
- package/dist/admin-ui/index.html +12 -0
- package/dist/blueprint/agent.d.ts +148 -0
- package/dist/blueprint/agent.js +1 -0
- package/dist/blueprint/declaration-site.d.ts +7 -0
- package/dist/blueprint/declaration-site.js +8 -0
- package/dist/blueprint/declared-structure.d.ts +145 -0
- package/dist/blueprint/declared-structure.js +213 -0
- package/dist/blueprint/define-run-state.d.ts +79 -0
- package/dist/blueprint/define-run-state.js +89 -0
- package/dist/blueprint/load-blueprint.d.ts +28 -0
- package/dist/blueprint/load-blueprint.js +85 -0
- package/dist/blueprint/outcomes.d.ts +76 -0
- package/dist/blueprint/outcomes.js +10 -0
- package/dist/blueprint/phase.d.ts +153 -0
- package/dist/blueprint/phase.js +1 -0
- package/dist/blueprint/places.d.ts +26 -0
- package/dist/blueprint/places.js +37 -0
- package/dist/blueprint/prompt-file.d.ts +81 -0
- package/dist/blueprint/prompt-file.js +131 -0
- package/dist/blueprint/reply-reader.d.ts +36 -0
- package/dist/blueprint/reply-reader.js +38 -0
- package/dist/blueprint/run-settings.d.ts +38 -0
- package/dist/blueprint/run-settings.js +1 -0
- package/dist/blueprint/serializer.d.ts +14 -0
- package/dist/blueprint/serializer.js +4 -0
- package/dist/blueprint/write-scope.d.ts +39 -0
- package/dist/blueprint/write-scope.js +106 -0
- package/dist/command.d.ts +2 -0
- package/dist/command.js +148 -0
- package/dist/commands/calls-answering.d.ts +16 -0
- package/dist/commands/calls-answering.js +63 -0
- package/dist/commands/json-file.d.ts +6 -0
- package/dist/commands/json-file.js +19 -0
- package/dist/commands/run-command.d.ts +23 -0
- package/dist/commands/run-command.js +172 -0
- package/dist/commands/typed-answers.d.ts +10 -0
- package/dist/commands/typed-answers.js +43 -0
- package/dist/config.d.ts +27 -0
- package/dist/config.js +20 -0
- package/dist/devtool-server/app-pages.d.ts +12 -0
- package/dist/devtool-server/app-pages.js +68 -0
- package/dist/devtool-server/blueprint-description.d.ts +21 -0
- package/dist/devtool-server/blueprint-description.js +27 -0
- package/dist/devtool-server/connected-runs.d.ts +36 -0
- package/dist/devtool-server/connected-runs.js +201 -0
- package/dist/devtool-server/devtool-server.d.ts +17 -0
- package/dist/devtool-server/devtool-server.js +294 -0
- package/dist/devtool-server/devtool-shapes.d.ts +312 -0
- package/dist/devtool-server/devtool-shapes.js +24 -0
- package/dist/devtool-server/listed-runs.d.ts +17 -0
- package/dist/devtool-server/listed-runs.js +42 -0
- package/dist/devtool-server/print-blueprint.d.ts +1 -0
- package/dist/devtool-server/print-blueprint.js +36 -0
- package/dist/example/added-species.d.ts +21 -0
- package/dist/example/added-species.js +19 -0
- package/dist/example/cover.d.ts +21 -0
- package/dist/example/cover.js +67 -0
- package/dist/example/cross-references.d.ts +21 -0
- package/dist/example/cross-references.js +77 -0
- package/dist/example/entry-drafts.d.ts +21 -0
- package/dist/example/entry-drafts.js +63 -0
- package/dist/example/entry-merge.d.ts +108 -0
- package/dist/example/entry-merge.js +284 -0
- package/dist/example/field-guide.d.ts +26 -0
- package/dist/example/field-guide.js +40 -0
- package/dist/example/guide-page.d.ts +21 -0
- package/dist/example/guide-page.js +15 -0
- package/dist/example/missing-species.d.ts +21 -0
- package/dist/example/missing-species.js +59 -0
- package/dist/example/run-state.d.ts +803 -0
- package/dist/example/run-state.js +58 -0
- package/dist/example/serializers.d.ts +32 -0
- package/dist/example/serializers.js +42 -0
- package/dist/example/species-list.d.ts +47 -0
- package/dist/example/species-list.js +93 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +25 -0
- package/dist/inference/anthropic-api.d.ts +37 -0
- package/dist/inference/anthropic-api.js +197 -0
- package/dist/inference/anthropic-prices.d.ts +18 -0
- package/dist/inference/anthropic-prices.js +61 -0
- package/dist/inference/anthropic-request.d.ts +51 -0
- package/dist/inference/anthropic-request.js +208 -0
- package/dist/inference/bedrock-api.d.ts +45 -0
- package/dist/inference/bedrock-api.js +242 -0
- package/dist/inference/bedrock-prices.d.ts +22 -0
- package/dist/inference/bedrock-prices.js +79 -0
- package/dist/inference/bedrock-request.d.ts +27 -0
- package/dist/inference/bedrock-request.js +193 -0
- package/dist/inference/call-queue-shapes.d.ts +273 -0
- package/dist/inference/call-queue-shapes.js +82 -0
- package/dist/inference/call-queue.d.ts +109 -0
- package/dist/inference/call-queue.js +408 -0
- package/dist/inference/gemini-api.d.ts +44 -0
- package/dist/inference/gemini-api.js +191 -0
- package/dist/inference/gemini-prices.d.ts +19 -0
- package/dist/inference/gemini-prices.js +33 -0
- package/dist/inference/gemini-request.d.ts +25 -0
- package/dist/inference/gemini-request.js +126 -0
- package/dist/inference/inference.d.ts +84 -0
- package/dist/inference/inference.js +9 -0
- package/dist/inference/openai-api.d.ts +29 -0
- package/dist/inference/openai-api.js +138 -0
- package/dist/inference/openai-prices.d.ts +12 -0
- package/dist/inference/openai-prices.js +25 -0
- package/dist/inference/openai-request.d.ts +50 -0
- package/dist/inference/openai-request.js +100 -0
- package/dist/inference/own-worker.d.ts +6 -0
- package/dist/inference/own-worker.js +16 -0
- package/dist/inference/scripted.d.ts +146 -0
- package/dist/inference/scripted.js +67 -0
- package/dist/run/assignments/agent-call.d.ts +32 -0
- package/dist/run/assignments/agent-call.js +218 -0
- package/dist/run/assignments/agent-phase.d.ts +14 -0
- package/dist/run/assignments/agent-phase.js +243 -0
- package/dist/run/assignments/assignment-memory.d.ts +42 -0
- package/dist/run/assignments/assignment-memory.js +52 -0
- package/dist/run/assignments/assignment.d.ts +17 -0
- package/dist/run/assignments/assignment.js +252 -0
- package/dist/run/assignments/model-settings.d.ts +39 -0
- package/dist/run/assignments/model-settings.js +57 -0
- package/dist/run/assignments/prepared-call.d.ts +28 -0
- package/dist/run/assignments/prepared-call.js +115 -0
- package/dist/run/assignments/tool-call.d.ts +26 -0
- package/dist/run/assignments/tool-call.js +108 -0
- package/dist/run/blueprint-mistake.d.ts +8 -0
- package/dist/run/blueprint-mistake.js +14 -0
- package/dist/run/code-phase.d.ts +11 -0
- package/dist/run/code-phase.js +59 -0
- package/dist/run/create-run.d.ts +36 -0
- package/dist/run/create-run.js +119 -0
- package/dist/run/execute-run.d.ts +7 -0
- package/dist/run/execute-run.js +158 -0
- package/dist/run/record/apply-event.d.ts +13 -0
- package/dist/run/record/apply-event.js +256 -0
- package/dist/run/record/events.d.ts +187 -0
- package/dist/run/record/events.js +1 -0
- package/dist/run/record/postgres-run-store.d.ts +13 -0
- package/dist/run/record/postgres-run-store.js +189 -0
- package/dist/run/record/progress-projection.d.ts +83 -0
- package/dist/run/record/progress-projection.js +167 -0
- package/dist/run/record/progress.d.ts +207 -0
- package/dist/run/record/progress.js +63 -0
- package/dist/run/record/run-store.d.ts +74 -0
- package/dist/run/record/run-store.js +1 -0
- package/dist/run/record/run-summary.d.ts +8 -0
- package/dist/run/record/run-summary.js +19 -0
- package/dist/run/record/run-types.d.ts +95 -0
- package/dist/run/record/run-types.js +1 -0
- package/dist/run/record/state-changes.d.ts +42 -0
- package/dist/run/record/state-changes.js +157 -0
- package/dist/run/resume-run.d.ts +25 -0
- package/dist/run/resume-run.js +99 -0
- package/dist/run/run-endings.d.ts +20 -0
- package/dist/run/run-endings.js +20 -0
- package/dist/run/run-option-shapes.d.ts +176 -0
- package/dist/run/run-option-shapes.js +47 -0
- package/dist/run/run-session.d.ts +144 -0
- package/dist/run/run-session.js +278 -0
- package/dist/worker/answer-queued-call.d.ts +19 -0
- package/dist/worker/answer-queued-call.js +100 -0
- package/dist/worker/launchers/claude-code.d.ts +7 -0
- package/dist/worker/launchers/claude-code.js +156 -0
- package/dist/worker/launchers/codex.d.ts +6 -0
- package/dist/worker/launchers/codex.js +141 -0
- package/dist/worker/launchers/launch.d.ts +31 -0
- package/dist/worker/launchers/launch.js +6 -0
- package/dist/worker/launchers/program-run.d.ts +30 -0
- package/dist/worker/launchers/program-run.js +92 -0
- package/dist/worker/launchers/tool-server.d.ts +26 -0
- package/dist/worker/launchers/tool-server.js +90 -0
- package/dist/worker/worker.d.ts +13 -0
- package/dist/worker/worker.js +170 -0
- package/package.json +43 -4
- package/README.md +0 -3
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { jsonReply } from '../index.js';
|
|
3
|
+
import { accept, defineAgent, defineAgentPhase, defineLane, defineTool, draftsOf, speciesNamed, SpeciesSchema, speciesWithoutEntry, withEntry, } from './run-state.js';
|
|
4
|
+
import { correctionText, draftsText, entriesText, jsonReplyCorrection, namesText, speciesText, } from './serializers.js';
|
|
5
|
+
// Shows: two lanes; a correction ("Every required section is present"); both mergers place the
|
|
6
|
+
// template entrySections; the tool find_species; a species with subspecies adds them as species,
|
|
7
|
+
// each with a draft the merger wrote, which become new assignments of the other lane; medium
|
|
8
|
+
// effort.
|
|
9
|
+
const findSpecies = defineTool({
|
|
10
|
+
name: 'find_species',
|
|
11
|
+
description: 'Returns the species on the list whose name contains the text.',
|
|
12
|
+
input: z.object({ nameContains: z.string() }).strict(),
|
|
13
|
+
annotations: { readOnlyHint: true },
|
|
14
|
+
handle: ({ args, state }) => ({
|
|
15
|
+
result: state.species.filter((species) => species.name.includes(args.nameContains)),
|
|
16
|
+
}),
|
|
17
|
+
});
|
|
18
|
+
const REQUIRED_SECTIONS = ['Identification', 'Habitat'];
|
|
19
|
+
function missingSections({ reply }) {
|
|
20
|
+
return REQUIRED_SECTIONS.filter((section) => !reply.text.includes(section));
|
|
21
|
+
}
|
|
22
|
+
function missingSectionsText({ reply }) {
|
|
23
|
+
return `Add these sections: ${missingSections({ reply }).join(', ')}.`;
|
|
24
|
+
}
|
|
25
|
+
const EntryReply = z.object({ text: z.string(), mentions: z.string().array() }).strict();
|
|
26
|
+
export const entryMerger = defineAgent({
|
|
27
|
+
name: 'entry-merger',
|
|
28
|
+
description: 'Writes one entry from the drafts of its species.',
|
|
29
|
+
subject: SpeciesSchema,
|
|
30
|
+
prompt: 'entry-merger.md',
|
|
31
|
+
inputs: {
|
|
32
|
+
species: {
|
|
33
|
+
description: 'The species this entry is for.',
|
|
34
|
+
serializer: speciesText,
|
|
35
|
+
from: ({ subject }) => ({ species: subject }),
|
|
36
|
+
},
|
|
37
|
+
drafts: {
|
|
38
|
+
description: 'Every draft written for this species.',
|
|
39
|
+
serializer: draftsText,
|
|
40
|
+
from: ({ state, subject }) => ({ drafts: draftsOf({ state, species: subject }) }),
|
|
41
|
+
},
|
|
42
|
+
correction: {
|
|
43
|
+
description: 'The reply that was sent back and why, on a call after one.',
|
|
44
|
+
serializer: correctionText,
|
|
45
|
+
from: ({ correction }) => ({ correction }),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
replyReader: jsonReply({ schema: EntryReply, correctionFor: jsonReplyCorrection }),
|
|
49
|
+
checks: [
|
|
50
|
+
{
|
|
51
|
+
name: 'required-sections',
|
|
52
|
+
description: 'Every required section (Identification, Habitat) is present in the entry text.',
|
|
53
|
+
check: ({ reply }) => (missingSections({ reply }).length ? [missingSectionsText({ reply })] : []),
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
mayChange: [
|
|
57
|
+
{
|
|
58
|
+
path: 'entries',
|
|
59
|
+
description: 'Creates or updates only this species entry.',
|
|
60
|
+
records: {
|
|
61
|
+
idField: 'speciesId',
|
|
62
|
+
actions: ['create', 'update'],
|
|
63
|
+
onlyIds: ({ subject }) => [subject.id],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
path: 'species',
|
|
68
|
+
description: 'Adds newly mentioned species to the list.',
|
|
69
|
+
records: { actions: ['create'] },
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
replyOutcome: {
|
|
73
|
+
description: 'Saves this species entry, and adds to the list each species the entry mentions that the guide does not list yet.',
|
|
74
|
+
decide: ({ reply, subject }) => accept({
|
|
75
|
+
change: (current) => {
|
|
76
|
+
const unlisted = reply.mentions.filter((name) => !current.species.some((species) => species.name === name));
|
|
77
|
+
// A species added here has no drafts yet: the side line added-species, beside this
|
|
78
|
+
// phase, writes its entry before the phase finishes.
|
|
79
|
+
return {
|
|
80
|
+
...withEntry({ state: current, species: subject, entry: reply }),
|
|
81
|
+
species: [
|
|
82
|
+
...current.species,
|
|
83
|
+
...unlisted.map((name) => speciesNamed({ name, subspecies: [] })),
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
maxCorrections: 3,
|
|
90
|
+
tools: [findSpecies],
|
|
91
|
+
modelSettings: { effort: 'medium' },
|
|
92
|
+
});
|
|
93
|
+
const SubspeciesEntryReply = z
|
|
94
|
+
.object({
|
|
95
|
+
text: z.string(),
|
|
96
|
+
mentions: z.string().array(),
|
|
97
|
+
/** One draft per subspecies, so that its own assignment in this phase has a draft to merge. */
|
|
98
|
+
subspeciesDrafts: z.object({ name: z.string(), text: z.string() }).strict().array(),
|
|
99
|
+
})
|
|
100
|
+
.strict();
|
|
101
|
+
export const subspeciesMerger = defineAgent({
|
|
102
|
+
name: 'subspecies-merger',
|
|
103
|
+
description: 'Writes the entry of a species with subspecies and a first draft of each subspecies.',
|
|
104
|
+
subject: SpeciesSchema,
|
|
105
|
+
prompt: 'subspecies-merger.md',
|
|
106
|
+
inputs: {
|
|
107
|
+
species: {
|
|
108
|
+
description: 'The species this entry is for, with its subspecies.',
|
|
109
|
+
serializer: speciesText,
|
|
110
|
+
from: ({ subject }) => ({ species: subject }),
|
|
111
|
+
},
|
|
112
|
+
drafts: {
|
|
113
|
+
description: 'Every draft written for this species.',
|
|
114
|
+
serializer: draftsText,
|
|
115
|
+
from: ({ state, subject }) => ({ drafts: draftsOf({ state, species: subject }) }),
|
|
116
|
+
},
|
|
117
|
+
correction: {
|
|
118
|
+
description: 'The reply that was sent back and why, on a call after one.',
|
|
119
|
+
serializer: correctionText,
|
|
120
|
+
from: ({ correction }) => ({ correction }),
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
replyReader: jsonReply({ schema: SubspeciesEntryReply, correctionFor: jsonReplyCorrection }),
|
|
124
|
+
checks: [
|
|
125
|
+
{
|
|
126
|
+
name: 'required-sections',
|
|
127
|
+
description: 'Every required section (Identification, Habitat) is present in the entry text.',
|
|
128
|
+
check: ({ reply }) => (missingSections({ reply }).length ? [missingSectionsText({ reply })] : []),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'subspecies-drafts',
|
|
132
|
+
description: 'Every listed subspecies has a first draft.',
|
|
133
|
+
check: ({ reply, subject }) => {
|
|
134
|
+
const undrafted = subject.subspecies.filter((name) => !reply.subspeciesDrafts.some((draft) => draft.name === name));
|
|
135
|
+
return undrafted.length ? [`Draft these subspecies: ${undrafted.join(', ')}.`] : [];
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
mayChange: [
|
|
140
|
+
{
|
|
141
|
+
path: 'entries',
|
|
142
|
+
description: 'Creates or updates only this species entry.',
|
|
143
|
+
records: {
|
|
144
|
+
idField: 'speciesId',
|
|
145
|
+
actions: ['create', 'update'],
|
|
146
|
+
onlyIds: ({ subject }) => [subject.id],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
path: 'species',
|
|
151
|
+
description: 'Adds each subspecies to the species list.',
|
|
152
|
+
records: { actions: ['create'] },
|
|
153
|
+
},
|
|
154
|
+
{ path: 'drafts', description: 'Adds the first drafts for the new subspecies.' },
|
|
155
|
+
],
|
|
156
|
+
replyOutcome: {
|
|
157
|
+
description: 'Saves this species entry and adds its subspecies as species, each with its draft.',
|
|
158
|
+
decide: ({ reply, subject }) => {
|
|
159
|
+
const added = subject.subspecies.map((name) => speciesNamed({ name, subspecies: [] }));
|
|
160
|
+
return accept({
|
|
161
|
+
change: (current) => ({
|
|
162
|
+
...withEntry({ state: current, species: subject, entry: reply }),
|
|
163
|
+
// Each added species is a new key of the other lane's `subjects`, so it becomes an
|
|
164
|
+
// assignment of that lane.
|
|
165
|
+
species: [...current.species, ...added],
|
|
166
|
+
drafts: [
|
|
167
|
+
...current.drafts,
|
|
168
|
+
...added.map((species) => ({
|
|
169
|
+
speciesId: species.id,
|
|
170
|
+
text: reply.subspeciesDrafts.find((draft) => draft.name === species.name).text,
|
|
171
|
+
})),
|
|
172
|
+
],
|
|
173
|
+
}),
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
maxCorrections: 3,
|
|
178
|
+
tools: [findSpecies],
|
|
179
|
+
modelSettings: { effort: 'medium' },
|
|
180
|
+
});
|
|
181
|
+
export const entryReviewer = defineAgent({
|
|
182
|
+
name: 'entry-reviewer',
|
|
183
|
+
description: 'Corrects the merged entry of its species.',
|
|
184
|
+
subject: SpeciesSchema,
|
|
185
|
+
prompt: 'entry-reviewer.md',
|
|
186
|
+
inputs: {
|
|
187
|
+
entry: {
|
|
188
|
+
description: 'The entry the merger before it wrote.',
|
|
189
|
+
serializer: entriesText,
|
|
190
|
+
from: ({ state, subject }) => ({
|
|
191
|
+
entries: state.entries.filter((entry) => entry.speciesId === subject.id),
|
|
192
|
+
}),
|
|
193
|
+
},
|
|
194
|
+
mentions: {
|
|
195
|
+
description: 'The species the merger said the entry mentions.',
|
|
196
|
+
serializer: namesText,
|
|
197
|
+
// The reviewer stands in two chains, so it names whichever merger ran before it.
|
|
198
|
+
from: ({ earlier, subject }) => ({
|
|
199
|
+
names: earlier({ agent: subject.subspecies.length ? subspeciesMerger : entryMerger }).reply
|
|
200
|
+
.mentions,
|
|
201
|
+
}),
|
|
202
|
+
},
|
|
203
|
+
correction: {
|
|
204
|
+
description: 'The reply that was sent back and why, on a call after one.',
|
|
205
|
+
serializer: correctionText,
|
|
206
|
+
from: ({ correction }) => ({ correction }),
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
replyReader: jsonReply({
|
|
210
|
+
/** The corrected text, or null when the entry stands. */
|
|
211
|
+
schema: z.object({ correctedText: z.string().nullable() }).strict(),
|
|
212
|
+
correctionFor: jsonReplyCorrection,
|
|
213
|
+
}),
|
|
214
|
+
checks: [
|
|
215
|
+
{
|
|
216
|
+
name: 'required-sections',
|
|
217
|
+
description: 'A corrected text keeps every required section (Identification, Habitat).',
|
|
218
|
+
check: ({ reply }) => reply.correctedText !== null && missingSections({ reply: { text: reply.correctedText } }).length
|
|
219
|
+
? [missingSectionsText({ reply: { text: reply.correctedText } })]
|
|
220
|
+
: [],
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
mayChange: [
|
|
224
|
+
{
|
|
225
|
+
path: 'entries',
|
|
226
|
+
description: 'Updates only the text of this species entry.',
|
|
227
|
+
records: {
|
|
228
|
+
idField: 'speciesId',
|
|
229
|
+
actions: ['update'],
|
|
230
|
+
fields: ['text'],
|
|
231
|
+
onlyIds: ({ subject }) => [subject.id],
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
],
|
|
235
|
+
replyOutcome: {
|
|
236
|
+
description: 'Replaces this species entry text when corrected.',
|
|
237
|
+
decide: ({ reply, subject }) => {
|
|
238
|
+
const correctedText = reply.correctedText;
|
|
239
|
+
if (correctedText === null)
|
|
240
|
+
return accept();
|
|
241
|
+
return accept({
|
|
242
|
+
change: (current) => ({
|
|
243
|
+
...current,
|
|
244
|
+
entries: current.entries.map((entry) => entry.speciesId === subject.id ? { ...entry, text: correctedText } : entry),
|
|
245
|
+
}),
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
maxCorrections: 2,
|
|
250
|
+
});
|
|
251
|
+
export const entryMerge = defineAgentPhase({
|
|
252
|
+
name: 'entry-merge',
|
|
253
|
+
description: 'Merges the drafts of each species into one entry.',
|
|
254
|
+
lanes: [
|
|
255
|
+
defineLane({
|
|
256
|
+
name: 'plain',
|
|
257
|
+
assignments: {
|
|
258
|
+
forEach: {
|
|
259
|
+
description: 'One per species without subspecies that has drafts and no merged entry.',
|
|
260
|
+
subjectName: 'species',
|
|
261
|
+
subjects: ({ state }) => speciesWithoutEntry({ state })
|
|
262
|
+
.filter((species) => !species.subspecies.length && draftsOf({ state, species }).length > 0)
|
|
263
|
+
.map((species) => ({ key: species.id, label: species.name, subject: species })),
|
|
264
|
+
},
|
|
265
|
+
concurrency: 8,
|
|
266
|
+
},
|
|
267
|
+
chain: [entryMerger, entryReviewer],
|
|
268
|
+
}),
|
|
269
|
+
defineLane({
|
|
270
|
+
name: 'with-subspecies',
|
|
271
|
+
assignments: {
|
|
272
|
+
forEach: {
|
|
273
|
+
description: 'One per species with subspecies and without a merged entry.',
|
|
274
|
+
subjectName: 'species',
|
|
275
|
+
subjects: ({ state }) => speciesWithoutEntry({ state })
|
|
276
|
+
.filter((species) => species.subspecies.length)
|
|
277
|
+
.map((species) => ({ key: species.id, label: species.name, subject: species })),
|
|
278
|
+
},
|
|
279
|
+
concurrency: 2,
|
|
280
|
+
},
|
|
281
|
+
chain: [subspeciesMerger, entryReviewer],
|
|
282
|
+
}),
|
|
283
|
+
],
|
|
284
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The example blueprint: a field guide written from a topic. It uses every part of a blueprint
|
|
2
|
+
* that the spec's example table names. */
|
|
3
|
+
declare const _default: import("../index.js").Blueprint<{
|
|
4
|
+
entries: {
|
|
5
|
+
name: string;
|
|
6
|
+
text: string;
|
|
7
|
+
speciesId: string;
|
|
8
|
+
mentions: string[];
|
|
9
|
+
seeAlso: string[] | null;
|
|
10
|
+
}[];
|
|
11
|
+
topic: string;
|
|
12
|
+
species: {
|
|
13
|
+
name: string;
|
|
14
|
+
id: string;
|
|
15
|
+
subspecies: string[];
|
|
16
|
+
}[];
|
|
17
|
+
drafts: {
|
|
18
|
+
text: string;
|
|
19
|
+
speciesId: string;
|
|
20
|
+
}[];
|
|
21
|
+
missingSpecies: string[];
|
|
22
|
+
title: string | null;
|
|
23
|
+
}, {
|
|
24
|
+
topic: string;
|
|
25
|
+
}, unknown>;
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { addedSpecies } from './added-species.js';
|
|
3
|
+
import { cover } from './cover.js';
|
|
4
|
+
import { crossReferences } from './cross-references.js';
|
|
5
|
+
import { entryDrafts } from './entry-drafts.js';
|
|
6
|
+
import { entryMerge } from './entry-merge.js';
|
|
7
|
+
import { guidePage } from './guide-page.js';
|
|
8
|
+
import { missingSpecies } from './missing-species.js';
|
|
9
|
+
import { defineBlueprint } from './run-state.js';
|
|
10
|
+
import { speciesList } from './species-list.js';
|
|
11
|
+
/** The example blueprint: a field guide written from a topic. It uses every part of a blueprint
|
|
12
|
+
* that the spec's example table names. */
|
|
13
|
+
export default defineBlueprint({
|
|
14
|
+
name: 'field-guide',
|
|
15
|
+
description: 'Writes a field guide to the species of one topic.',
|
|
16
|
+
input: z.object({ topic: z.string() }).strict(),
|
|
17
|
+
startingState: {
|
|
18
|
+
description: 'An empty guide on the topic.',
|
|
19
|
+
from: ({ input }) => ({
|
|
20
|
+
topic: input.topic,
|
|
21
|
+
species: [],
|
|
22
|
+
drafts: [],
|
|
23
|
+
entries: [],
|
|
24
|
+
missingSpecies: [],
|
|
25
|
+
title: null,
|
|
26
|
+
}),
|
|
27
|
+
},
|
|
28
|
+
promptFolder: './prompts',
|
|
29
|
+
templates: { entrySections: 'templates/entry-sections.md' },
|
|
30
|
+
modelSettings: {
|
|
31
|
+
effort: 'low',
|
|
32
|
+
model: {
|
|
33
|
+
codex: 'gpt-6.1-terra',
|
|
34
|
+
'claude-code': 'claude-fable-5-2',
|
|
35
|
+
'openai-api': 'gpt-6.1-terra',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
trunk: [speciesList, entryDrafts, entryMerge, missingSpecies, crossReferences, cover, guidePage],
|
|
39
|
+
sideLines: [addedSpecies],
|
|
40
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const guidePage: import("../index.js").Phase<{
|
|
2
|
+
entries: {
|
|
3
|
+
name: string;
|
|
4
|
+
text: string;
|
|
5
|
+
speciesId: string;
|
|
6
|
+
mentions: string[];
|
|
7
|
+
seeAlso: string[] | null;
|
|
8
|
+
}[];
|
|
9
|
+
topic: string;
|
|
10
|
+
species: {
|
|
11
|
+
name: string;
|
|
12
|
+
id: string;
|
|
13
|
+
subspecies: string[];
|
|
14
|
+
}[];
|
|
15
|
+
drafts: {
|
|
16
|
+
text: string;
|
|
17
|
+
speciesId: string;
|
|
18
|
+
}[];
|
|
19
|
+
missingSpecies: string[];
|
|
20
|
+
title: string | null;
|
|
21
|
+
}, unknown>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { accept, defineCodePhase } from './run-state.js';
|
|
2
|
+
// guide-page: code phase. Shows: writes the guide as an HTML artifact.
|
|
3
|
+
export const guidePage = defineCodePhase({
|
|
4
|
+
name: 'guide-page',
|
|
5
|
+
description: 'Writes the finished guide as one HTML page.',
|
|
6
|
+
run: ({ state }) => accept({
|
|
7
|
+
artifacts: [
|
|
8
|
+
{
|
|
9
|
+
name: 'guide.html',
|
|
10
|
+
mediaType: 'text/html',
|
|
11
|
+
bytes: new TextEncoder().encode(`<h1>${state.title}</h1>${state.entries.map((entry) => `<h2>${entry.name}</h2><p>${entry.text}</p>`).join('')}`),
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const missingSpecies: import("../index.js").Phase<{
|
|
2
|
+
entries: {
|
|
3
|
+
name: string;
|
|
4
|
+
text: string;
|
|
5
|
+
speciesId: string;
|
|
6
|
+
mentions: string[];
|
|
7
|
+
seeAlso: string[] | null;
|
|
8
|
+
}[];
|
|
9
|
+
topic: string;
|
|
10
|
+
species: {
|
|
11
|
+
name: string;
|
|
12
|
+
id: string;
|
|
13
|
+
subspecies: string[];
|
|
14
|
+
}[];
|
|
15
|
+
drafts: {
|
|
16
|
+
text: string;
|
|
17
|
+
speciesId: string;
|
|
18
|
+
}[];
|
|
19
|
+
missingSpecies: string[];
|
|
20
|
+
title: string | null;
|
|
21
|
+
}, unknown>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { jsonReply, sendBack } from '../index.js';
|
|
3
|
+
import { accept, defineAgent, defineAgentPhase, speciesNamed } from './run-state.js';
|
|
4
|
+
import { correctionText, entriesText, jsonReplyCorrection, topicText } from './serializers.js';
|
|
5
|
+
// missing-species: once; gap-finder.
|
|
6
|
+
// Shows: work found late. The gap finder adds the species it names to the list, and the side
|
|
7
|
+
// line added-species, beside this phase, writes their entries before the phase finishes. The
|
|
8
|
+
// cross-references follow on the trunk, once every entry is written.
|
|
9
|
+
const gapFinder = defineAgent({
|
|
10
|
+
name: 'gap-finder',
|
|
11
|
+
description: 'Names species the finished entries show the guide lacks and adds them to the list.',
|
|
12
|
+
prompt: 'gap-finder.md',
|
|
13
|
+
inputs: {
|
|
14
|
+
topic: {
|
|
15
|
+
description: 'The topic the person gave.',
|
|
16
|
+
serializer: topicText,
|
|
17
|
+
from: ({ state }) => ({ topic: state.topic }),
|
|
18
|
+
},
|
|
19
|
+
entries: {
|
|
20
|
+
description: 'Every entry of the guide.',
|
|
21
|
+
serializer: entriesText,
|
|
22
|
+
from: ({ state }) => ({ entries: state.entries }),
|
|
23
|
+
},
|
|
24
|
+
correction: {
|
|
25
|
+
description: 'The reply that was sent back and why, on a call after one.',
|
|
26
|
+
serializer: correctionText,
|
|
27
|
+
from: ({ correction }) => ({ correction }),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
replyReader: jsonReply({
|
|
31
|
+
schema: z.object({ missing: z.string().array() }).strict(),
|
|
32
|
+
correctionFor: jsonReplyCorrection,
|
|
33
|
+
}),
|
|
34
|
+
replyOutcome: {
|
|
35
|
+
description: 'Names no species already on the list. Adds each species it names to the list.',
|
|
36
|
+
decide: ({ reply, state }) => {
|
|
37
|
+
const listed = reply.missing.filter((name) => state.species.some((species) => species.name === name));
|
|
38
|
+
if (listed.length)
|
|
39
|
+
return sendBack({ correction: `Already listed: ${listed.join(', ')}.` });
|
|
40
|
+
return accept({
|
|
41
|
+
change: (current) => ({
|
|
42
|
+
...current,
|
|
43
|
+
species: [
|
|
44
|
+
...current.species,
|
|
45
|
+
...reply.missing.map((name) => speciesNamed({ name, subspecies: [] })),
|
|
46
|
+
],
|
|
47
|
+
missingSpecies: reply.missing,
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
maxCorrections: 1,
|
|
53
|
+
});
|
|
54
|
+
export const missingSpecies = defineAgentPhase({
|
|
55
|
+
name: 'missing-species',
|
|
56
|
+
description: 'Looks for species the finished entries show the guide lacks.',
|
|
57
|
+
assignments: 'once',
|
|
58
|
+
chain: [gapFinder],
|
|
59
|
+
});
|