castle-web-cli 0.4.225 → 0.4.227

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.
@@ -9,6 +9,8 @@ export interface PromptTask {
9
9
  status: string;
10
10
  progress: number;
11
11
  notes: string;
12
+ model?: string;
13
+ effort?: string;
12
14
  item?: string;
13
15
  error?: string;
14
16
  interrupted?: string;
@@ -56,6 +58,7 @@ export declare const PLAYTEST_ON_FENCE_RULE = "- The user turned playtest checks
56
58
  export declare const TASK_FENCE_PROMPT_EXAMPLE = "Then a SHORT self-contained prompt -- one tight paragraph (aim under 100\nwords): what to build or fix and what \"done\" looks like. Task agents read\nthe deck's own docs for framework/API detail, so never restate recipes,\nfile layouts, or implementation steps.";
57
59
  export declare const PLAYTEST_TASK_UNDRIVEN_RULE = "- The playtest tool is a headless preview, not the user's device. If you could not make the behavior in question happen there, or checking it needs something the preview did not give you (a microphone, a camera, a second player, a native app command, the phone's on-screen keyboard), your result says exactly that -- \"I could not drive X in the headless preview because Y; unverified\" -- instead of reporting what the code implies. Never write \"verified\" for something you did not observe, and when you did observe it, say it was verified in the headless preview.";
58
60
  export declare const STOP_RULE_STEER = "- When a new message is about work a task is still running or waiting to run -- it corrects it, adds to it, narrows it, or answers a question you asked about it -- `castle-send` it to that task instead of stopping it: the task keeps what it has done and adjusts. Stop a running or waiting task only when the user said to stop or drop it, or took back what it is building so completely that nothing it has done would survive. When that change comes with new work, stop it in the SAME reply that spawns the replacement. When the new ask is about something else, leave the task running and spawn the new work as its own task: in parallel, or with `after:` naming it only when the new work needs that task's actual output. Never stop a task because a new one restates it or covers it more broadly.";
61
+ export declare const STEER_MODEL_CLAUSE = ", as a new task even when it changes a running one: a castle-send keeps that task's model.";
59
62
  export declare const SEND_FENCE_RULES = "\n\nTo hand a message to a task that is running or waiting to run:\n\n```castle-send\nthe task's title or id, alone on the first line\nthe user's message for it -- their own words, quoted, plus only what from this conversation the task needs to act on them\n```\n\n- `castle-send` reaches a RUNNING or WAITING task: it reads the message at its next step and folds it into the work it is doing, without starting over. One fence per task. It is the ONLY thing that reaches a running task -- a reply that says a task will pick something up, without this fence, sends nothing. The board row shows each message you sent and whether the task has read it.\n- It cannot reach a finished task. For those, spawn a new task (see the one-and-done rule below).";
60
63
  export declare const PROBE_CLAUSE_STEER = "But NEVER spawn work a pending probe could invalidate outright: castle-send can pass the answer to a running task, but it cannot undo work the answer throws away.";
61
64
  export declare function truncateToBytes(line: string, budget: number): string;
@@ -91,6 +94,8 @@ export declare function applyPlanOps(fileText: string, ops: PlanOp[], sources?:
91
94
  export declare function renderPlanDigest(plan: RouterPlanOpts, tasks: PromptTask[]): string;
92
95
  export declare function planOpenQuestionLines(fileText: string): string[];
93
96
  export declare function renderTaskPlanSlice(fileText: string, item: string | undefined, finishedWork?: PlanFinishedWork[]): string;
97
+ export type FreeModelCheck = (model: string) => boolean;
98
+ export declare function modelLabel(model: string, isFreeModel: FreeModelCheck): string;
94
99
  export declare const NO_DECK_DOCS = "This deck has no CLAUDE.md / AGENTS.md quick reference. There is no documentation to read -- do not search for one (CLAUDE.md, README, **/*.md, etc.).";
95
100
  export declare const STOPPED_TASKS_HEADER = "Tasks you stopped with castle-stop. They started and you cancelled them; none finished. What the user saw: the task appeared on their board and then vanished. So if the user says a task never started, or asks where it went, say plainly that you stopped it (not that it never started), then re-send it if they still want it";
96
101
  export declare const BAD_TASK_ENDINGS_HEADER = "Tasks that ended badly since your last reply. Tell the user about these at the start of your reply, plainly. Do not talk as if they are still running";
@@ -110,9 +115,17 @@ export interface RouterPromptOpts {
110
115
  plan?: RouterPlanOpts;
111
116
  playtest?: boolean;
112
117
  playtestPref?: 'on' | 'off';
113
- askCalls?: boolean;
114
118
  steer?: boolean;
115
119
  unsentSends?: string[];
120
+ routerModel?: {
121
+ model: string;
122
+ effort: string;
123
+ };
124
+ taskModel?: {
125
+ model: string;
126
+ effort: string;
127
+ };
128
+ isFreeModel?: FreeModelCheck;
116
129
  editorTabs?: string[];
117
130
  kits?: string[];
118
131
  paramsWrites?: string[];
@@ -128,11 +141,16 @@ export interface PromptRef {
128
141
  field?: string;
129
142
  fragment?: string;
130
143
  }
144
+ export interface FlattenedAttachment {
145
+ view: string;
146
+ original: string;
147
+ }
131
148
  export declare function userTurnInstruction(opts: {
132
149
  messages: string[];
133
150
  interruptedDraft?: string;
134
151
  attachments?: string[];
135
152
  marked?: string[];
153
+ flattened?: FlattenedAttachment[];
136
154
  refs?: PromptRef[];
137
155
  }): string;
138
156
  export declare function buildTaskPrompt(opts: {
@@ -35,6 +35,9 @@ file layouts, or implementation steps.`;
35
35
  export const PLAYTEST_TASK_UNDRIVEN_RULE = '- The playtest tool is a headless preview, not the user\'s device. If you could not make the behavior in question happen there, or checking it needs something the preview did not give you (a microphone, a camera, a second player, a native app command, the phone\'s on-screen keyboard), your result says exactly that -- "I could not drive X in the headless preview because Y; unverified" -- instead of reporting what the code implies. Never write "verified" for something you did not observe, and when you did observe it, say it was verified in the headless preview.';
36
36
  const STOP_RULE_NO_STEER = `- Stop a running or waiting task only when the new message makes its work unwanted: the user said to stop or drop it, took back or reversed what it is building, or corrected it -- it has the wrong idea, or they picked a different option than the one it is building -- so its result would have to be undone. When that change comes with new work, stop it in the SAME reply that spawns the replacement. When the new ask adds to a running task, extends it, or is about something else, leave it running and spawn the new work as its own task: in parallel, or with \`after:\` naming it only when the new work needs that task's actual output. Nothing reaches a running task, so leaving it running never covers the new ask by itself. Never stop a task because a new one restates it or covers it more broadly.`;
37
37
  export const STOP_RULE_STEER = `- When a new message is about work a task is still running or waiting to run -- it corrects it, adds to it, narrows it, or answers a question you asked about it -- \`castle-send\` it to that task instead of stopping it: the task keeps what it has done and adjusts. Stop a running or waiting task only when the user said to stop or drop it, or took back what it is building so completely that nothing it has done would survive. When that change comes with new work, stop it in the SAME reply that spawns the replacement. When the new ask is about something else, leave the task running and spawn the new work as its own task: in parallel, or with \`after:\` naming it only when the new work needs that task's actual output. Never stop a task because a new one restates it or covers it more broadly.`;
38
+ // A castle-send keeps the running task's recorded model, so a change the user
39
+ // wants on another model cannot ride it.
40
+ export const STEER_MODEL_CLAUSE = ", as a new task even when it changes a running one: a castle-send keeps that task's model.";
38
41
  export const SEND_FENCE_RULES = `
39
42
 
40
43
  To hand a message to a task that is running or waiting to run:
@@ -46,7 +49,7 @@ the user's message for it -- their own words, quoted, plus only what from this c
46
49
 
47
50
  - \`castle-send\` reaches a RUNNING or WAITING task: it reads the message at its next step and folds it into the work it is doing, without starting over. One fence per task. It is the ONLY thing that reaches a running task -- a reply that says a task will pick something up, without this fence, sends nothing. The board row shows each message you sent and whether the task has read it.
48
51
  - It cannot reach a finished task. For those, spawn a new task (see the one-and-done rule below).`;
49
- function baseRouterRules(playtest, askCalls, playtestPref, steer = false) {
52
+ function baseRouterRules(playtest, playtestPref, steer = false) {
50
53
  const runningTaskRules = steer ? STOP_RULE_STEER : STOP_RULE_NO_STEER;
51
54
  const sendFenceRules = steer ? SEND_FENCE_RULES : '';
52
55
  const playtestRules = playtestPref === 'off'
@@ -56,6 +59,7 @@ function baseRouterRules(playtest, askCalls, playtestPref, steer = false) {
56
59
  : playtest
57
60
  ? `\n${PLAYTEST_ROUTER_RULE}`
58
61
  : '';
62
+ const modelsRule = `\n- You cannot change which models run. Both are set in the model chip under the message box (Agent & model settings): Operator model and Operator effort set the model you, this chat, run on; Task model and Task effort set the model new tasks run on. A change applies to what starts after it, not to anything already running. When the user asks which model you or their tasks run on, asks to switch to or use a model or effort, or says they have switched: answer from == models == (and, when relevant, the model on the rows they mean), which always shows the current settings; trust it over anything said earlier in this chat, which may be wrong. The tool you run inside calls itself Claude Code; that names the tool, not you. Your model is the one == models == names for this chat: answer whether you are Claude, or any model, from it. When it names a model that is not Claude (${CLAUDE_FAMILY} are Claude), you are not Claude: say so plainly. If it does not show what they say they picked, tell them that setting has not changed yet. Point them to the matching row; never say you switched it or that it has changed when == models == does not show it. If the same message asks for work they want done on a model or effort == models == does not show yet, do not spawn that work yet: tell them to change the setting and send the request again. When == models == already shows it, spawn the work as usual${steer ? STEER_MODEL_CLAUSE : '.'} Apart from a usage-limit failure (above), do not bring up models when the user did not.`;
59
63
  return `You are Castle's create assistant: the fast conversational router for a game-making session. The deck (game project) lives in the current directory and runs live in a pane right next to this chat.
60
64
 
61
65
  What a deck is: a normal web project served by vite -- index.html plus plain JS/JSX modules, with real npm dependencies (more can be installed), the castle-web-sdk package, and usually a kit framework whose engine, behaviors, scenes, editors, and drawings are ordinary files in this directory. The web platform is fully available (DOM, canvas, npm libraries like react, three, etc.). The deck's Quick reference and file list below describe its setup; the full CLAUDE.md / AGENTS.md has deeper detail. NEVER claim something is impossible or unsupported on the platform without checking that context (or, for specifics it doesn't cover, the deck's files) first.
@@ -81,7 +85,8 @@ Hard rules:
81
85
  \`\`\`castle-task
82
86
  short imperative title on the first line
83
87
  after: comma-separated titles or ids this task must wait for (optional line)
84
- ${askCalls ? 'hold: answer (optional line -- only on the task a probe in this same reply decides)\n' : ''}${TASK_FENCE_PROMPT_EXAMPLE}
88
+ hold: answer (optional line -- only on the task a probe in this same reply decides)
89
+ ${TASK_FENCE_PROMPT_EXAMPLE}
85
90
  \`\`\`
86
91
 
87
92
  - Use \`after:\` only for the fallback case above -- a task that genuinely needs another's produced output (it may reference tasks spawned in this same reply, by title). Never for file-contention; independent tasks must NOT wait on each other.
@@ -100,7 +105,7 @@ comma-separated active-task titles or ids, or \`all\`
100
105
  - When you spawn a task that fixes or redoes a FINISHED one, \`castle-done\` the earlier row in the SAME reply. Keep the board meaning "what to look at right now".
101
106
  ${runningTaskRules}
102
107
  - A \`failed\` row carries an \`error:\` line -- why it failed. A \`blocked\` row waited on a dep that failed or was stopped, so its output never arrived and it will never start on its own -- \`blocked by:\` names that dep. When you see one, decide for the user: usually spawn a replacement task (or pipeline) that redoes the failed work, and in the SAME reply \`castle-stop\` the blocked row and \`castle-done\` the failed one, so the board stays clean.
103
- - A failed row whose error is a usage limit -- the free-model daily allowance, credits, or a spending limit -- will fail the same way if respawned. Do not respawn it. Tell the user what ran out, when it resets if the row says, and that they can pick another model in settings (or get credits) to keep going. You cannot choose the model tasks run on.
108
+ - A failed row whose error is a usage limit -- the free-model daily allowance, credits, or a spending limit -- will fail the same way if respawned. Do not respawn it. Tell the user what ran out, when it resets if the row says, and that they can pick another model in settings (or get credits) to keep going. Point them to the Task model setting described below; you cannot change it.${modelsRule}
104
109
  - An interrupted row with an \`interrupted:\` platform reason was cut off, not stopped by you. Tell the user, and redo it only if they want it (their message may already ask); part of its work may already be on disk.
105
110
  - Do not mark a task done to imply YOU verified its quality -- the user playtests and confirms that. But DO keep the board tidy: clear finished work the user blessed, and remove anything clearly obsolete. When genuinely unsure, leave the row.
106
111
  - Never claim the board is cleared without actually emitting the fence.
@@ -129,14 +134,8 @@ Conversation style:
129
134
  - Spawning a task does NOT apply the change -- tasks run for minutes and finish on the board. Talk about spawned work in future tense ("this will dial the shake back"), and NEVER ask how a change feels right after spawning it -- the user cannot have tried it yet. Save "how is it?" for things whose task already finished.
130
135
  - The user playtests in the pane beside this chat; finished work shows up there after a reload.`;
131
136
  }
132
- const SPEC_RULE = `- CLEAR SPEC (mechanics named, a reference given, "like X but Y"): the gaps are closed. Build what they said; never probe taste they already expressed.`;
133
- const PROBE_CAP_RULE = `- At most ONE probe open at a time; none on spec, delegation, or conversation turns; never re-probe something answered. Probe feel and identity -- what the player DOES, how it should feel, the goal shape, the tone -- never implementation.`;
134
- // The q-a2 router arm (prompt-evals t1-router-ladder arms/q-a2.ts), for the
135
- // decks that opted in (`agent.askCalls` / CASTLE_AGENT_ASK_CALLS -- see
136
- // askCallsEnabled in agent.ts). Off for everyone by default, so the plan rules
137
- // stay byte-identical to a prompt built before it existed.
138
- const ASK_CALLS_SPEC_RULE = `- CLEAR SPEC (mechanics named, a reference given, "like X but Y"): build what they said; never probe taste they already expressed.`;
139
- const ASK_CALLS_PROBE_CAP_RULE = `- At most ONE probe open at a time; none on delegation or conversation turns; never re-probe something answered. Before you close a task fence, find the one thing that task will have to settle on its own: a word of theirs that reads two ways, or a case their ask never mentions. Quote the word and ask which, as a probe, your reading as the first chip and the other as the second. Then split the work by that answer. Tasks the answer cannot change spawn now. The task it decides gets a \`hold: answer\` line: it waits on the board and starts with their reply appended, whichever chip they tap or whatever they type. When the answer decides everything they asked for, the probe and that held task are the whole reply -- a held task is still building. Before you close each unheld task fence, reread its brief: if it names or assumes any option of your probe -- even in passing, like a control scheme, a count, or which screen -- that task decides it too. Give it the \`hold: answer\` line, or move that choice out of it into the held task and write the rest so it works with either answer. When they tap a chip, the task you held for it starts on its own with their answer -- the board shows it running with that answer. Acknowledge it in one line; never spawn it again or stop it. A row still held means they typed instead: if their message answers the probe, castle-stop the held row and spawn it again with their answer; otherwise leave it held.`;
137
+ const SPEC_RULE = `- CLEAR SPEC (mechanics named, a reference given, "like X but Y"): build what they said; never probe taste they already expressed.`;
138
+ const PROBE_CAP_RULE = `- At most ONE probe open at a time; none on delegation or conversation turns; never re-probe something answered. Before you close a task fence, find the one thing that task will have to settle on its own: a word of theirs that reads two ways, or a case their ask never mentions. Quote the word and ask which, as a probe, your reading as the first chip and the other as the second. Then split the work by that answer. Tasks the answer cannot change spawn now. The task it decides gets a \`hold: answer\` line: it waits on the board and starts with their reply appended, whichever chip they tap or whatever they type. When the answer decides everything they asked for, the probe and that held task are the whole reply -- a held task is still building. Before you close each unheld task fence, reread its brief: if it names or assumes any option of your probe -- even in passing, like a control scheme, a count, or which screen -- that task decides it too. Give it the \`hold: answer\` line, or move that choice out of it into the held task and write the rest so it works with either answer. When they tap a chip, the task you held for it starts on its own with their answer -- the board shows it running with that answer. Acknowledge it in one line; never spawn it again or stop it. A row still held means they typed instead: if their message answers the probe, castle-stop the held row and spawn it again with their answer; otherwise leave it held.`;
140
139
  // Appended to the rules above for a deck with the plan doc on -- see
141
140
  // planSession in agent.ts for which decks those are. One self-contained block,
142
141
  // so a deck without it gets the pre-plan prompt byte for byte.
@@ -147,10 +146,10 @@ const ASK_CALLS_PROBE_CAP_RULE = `- At most ONE probe open at a time; none on de
147
146
  // so out loud rather than quietly contradicting them.
148
147
  const PROBE_CLAUSE_NO_STEER = 'But NEVER spawn work a pending probe could invalidate: there is no telling a running task anything.';
149
148
  export const PROBE_CLAUSE_STEER = 'But NEVER spawn work a pending probe could invalidate outright: castle-send can pass the answer to a running task, but it cannot undo work the answer throws away.';
150
- function planRules(askCalls, steer = false) {
149
+ function planRules(steer = false) {
151
150
  const probeRunningTaskClause = steer ? PROBE_CLAUSE_STEER : PROBE_CLAUSE_NO_STEER;
152
151
  return `Reading the user, fresh from EACH message -- the same user hands you a spec, then a fragment, then delegates:
153
- ${askCalls ? ASK_CALLS_SPEC_RULE : SPEC_RULE}
152
+ ${SPEC_RULE}
154
153
  - FRAGMENT ("something with ants", "a cozy game about tea?"): gaps they cannot name yet. Draw their taste out on the few dimensions that decide whether this feels like THEIRS -- while building, never instead of building.
155
154
  - A fragment is not only a whole-game ask. "how about some obstacles?", "make it feel brighter" name a slice and leave its taste open: build the part they named, and probe the ONE dimension you were about to settle for them. Deciding it silently is how a deck becomes yours instead of theirs.
156
155
  - A build turn that was going to carry NO question at all is where a feel question belongs, and on a deck already underway most turns are that: they name a change, you make it, nothing is asked, and the feel of it was yours by default. If what you are about to build has a feel they have not named -- how hard it should be, how fast it should move, how it should land -- ask that one thing in the same reply as the work. This never replaces a question you were already going to ask: still one at a time, and if you already had one, keep it.
@@ -164,7 +163,7 @@ Probing while you build. A probe is one short plain question plus 2-4 tappable o
164
163
 
165
164
  - Tapping one sends its text as the user's next message; they can ignore it and type anything else, and the build continues either way. Never phrase a probe as if an answer were required.
166
165
  - Spawn the work the answer cannot invalidate AND attach the probe in the same reply -- this supersedes the rules above against pairing a question with task directives. ${probeRunningTaskClause}
167
- ${askCalls ? ASK_CALLS_PROBE_CAP_RULE : PROBE_CAP_RULE}
166
+ ${PROBE_CAP_RULE}
168
167
  - Chips NEVER stand on their own: a probe's question is the line right before them, and a probe is the only thing they are for. Alone they read as answers to a question nobody asked.
169
168
  - Praise is where the pull to offer something is strongest and most wrong: "oh nice, that works great" gets one plain sentence and nothing else. Vary it -- a compliment that always gets the same reply stops reading as one.
170
169
 
@@ -190,7 +189,7 @@ now- food-hauling
190
189
  - THE USER SHAPING THE GAME IS AN INFLECTION POINT. A mechanic, a rule, an entity, a mood, a difficulty they ask for is taste, not a chore: it goes in with \`decide+\` quoting the words they used, in the same reply that spawns the work. Early on nearly every ask is one of these, and a plan that holds only what is in flight has kept nothing.
191
190
  - A bare number, a knob setting, or a bug they want gone is not taste -- just do the tweak. The REASON they give for one is: "make the islands bigger, it's already pretty hard" is a \`decide+\` about the difficulty they want, not about island size. A line about a value someone tuned names the intent and the knob, never the number: \`decide+ gentle-start: the first wave should feel easy -- spawnRate ("go easy at the start" -- user)\`, not \`... spawnRate at 0.4\`. A number inside the quote stays, since the quote is their words verbatim; your own sentence never carries one. The number lives in one place, the \`PARAMS\` object of the file that uses it, and a plan line repeating it becomes a second answer the moment anyone moves the slider.
192
191
  - Put the fence AFTER your task fences: tasks spawn the moment their fence closes.
193
- - NOTHING in \`## Open questions\` may be answered by anything else in the same reply, fence or task: asking and deciding are different acts. A probe IS the top open question, asked in its own words.
192
+ - NOTHING in \`## Open questions\` may be answered by anything else in the same reply, fence or task: asking and deciding are different acts.
194
193
  - An open question you have asked outright twice, and the user passed over both times, is TABLED: \`open- <label>\` it in that reply's fence and stop asking it. Passing over it twice is their answer about the question. It comes back only if they bring it up.
195
194
  - An ask that goes against a \`## Decisions\` line: say what was decided and why in one sentence BEFORE you build it. They may well have changed their mind -- that is theirs to say, and the line is yours to raise.
196
195
  - No plan.md yet and the deck is getting work? Open one here with the ops the moment supports: an \`identity:\` line, the \`## Now\` items you are spawning, an \`open+\` for what you are guessing at. SPARSE AND TRUE, and never in place of their actual ask.
@@ -199,9 +198,9 @@ Promotion. Finished tasks leave notes worth keeping, listed above with the id of
199
198
 
200
199
  If the user asks you to ease off the questions or the plan upkeep, record that with a \`decide+\` quoting the ask, and honor it -- keep \`## Now\` current, quietly.`;
201
200
  }
202
- function routerRules(plan, playtest, askCalls, playtestPref, steer = false) {
203
- const base = baseRouterRules(playtest, askCalls, playtestPref, steer);
204
- return plan ? `${base}\n\n${planRules(askCalls, steer)}` : base;
201
+ function routerRules(plan, playtest, playtestPref, steer = false) {
202
+ const base = baseRouterRules(playtest, playtestPref, steer);
203
+ return plan ? `${base}\n\n${planRules(steer)}` : base;
205
204
  }
206
205
  function renderTranscriptLine(m) {
207
206
  if (m.role === "user")
@@ -831,10 +830,6 @@ export function renderPlanDigest(plan, tasks) {
831
830
  }
832
831
  return parts.join("\n\n");
833
832
  }
834
- // The non-empty lines of `## Open questions`, for the runtime's agenda nudge
835
- // (agent.ts): a standing question the router keeps not asking gets named in a
836
- // notice, since five wordings of a prompt rule for the same behavior all
837
- // measured 0 (26-08-18) while the notice-shaped close rule measured real.
838
833
  export function planOpenQuestionLines(fileText) {
839
834
  const section = parsePlanSections(fileText).find((s) => s.key === "open questions");
840
835
  return (section?.lines ?? []).map((l) => l.trim()).filter(Boolean);
@@ -883,12 +878,30 @@ export function renderTaskPlanSlice(fileText, item, finishedWork) {
883
878
  // deck that opted out -- which is both meaningless there (nothing tells that
884
879
  // router what an item is) and a break in the byte-identity the opt-out
885
880
  // promises.
886
- function renderTasks(tasks, showItems) {
881
+ // The names the composer's model chip shows (formatRoleSettings in
882
+ // shell/operator.tsx), so the router's answer matches what the user sees in
883
+ // settings rather than a provider slug. "Muse" is the chip's name for a model
884
+ // Castle pays for, which only the budget's free prefixes decide.
885
+ const CLAUDE_MODEL_LABELS = { sonnet: "Sonnet", opus: "Opus", fable: "Fable" };
886
+ const CLAUDE_FAMILY = Object.values(CLAUDE_MODEL_LABELS).join(", ").replace(/, ([^,]*)$/, " and $1");
887
+ const noFreeModels = () => false;
888
+ export function modelLabel(model, isFreeModel) {
889
+ const trimmed = model.trim();
890
+ if (CLAUDE_MODEL_LABELS[trimmed])
891
+ return CLAUDE_MODEL_LABELS[trimmed];
892
+ if (isFreeModel(trimmed))
893
+ return "Muse";
894
+ return trimmed.slice(trimmed.lastIndexOf("/") + 1);
895
+ }
896
+ function renderTasks(tasks, showItems, isFreeModel) {
887
897
  if (tasks.length === 0)
888
898
  return "(none yet)";
889
899
  return tasks
890
900
  .map((t) => {
891
901
  const item = showItems && t.item ? ` -- item: ${t.item}` : "";
902
+ const model = t.model || t.effort
903
+ ? ` -- model: ${[t.model && modelLabel(t.model, isFreeModel), t.effort].filter(Boolean).join(" ")}`
904
+ : "";
892
905
  const notes = t.notes.trim() ? ` -- notes: ${t.notes.trim()}` : "";
893
906
  const error = t.error ? ` -- error: ${t.error}` : "";
894
907
  const interrupted = t.interrupted ? ` -- interrupted: ${t.interrupted}` : "";
@@ -896,7 +909,7 @@ function renderTasks(tasks, showItems) {
896
909
  ? ` -- blocked by: ${t.blockedBy.join(", ")}`
897
910
  : "";
898
911
  const sent = t.sent ? ` -- messages you sent it: ${t.sent}` : "";
899
- const row = `- [${t.status} ${t.progress}%] ${t.title} (${t.id})${item}${notes}${error}${interrupted}${blockedBy}${sent}`;
912
+ const row = `- [${t.status} ${t.progress}%] ${t.title} (${t.id})${item}${model}${notes}${error}${interrupted}${blockedBy}${sent}`;
900
913
  const held = t.status === "held" && t.heldQuestion !== undefined
901
914
  ? `\n held -- waiting on the answer to: ${t.heldQuestion}`
902
915
  : "";
@@ -950,6 +963,18 @@ export function buildRouterPromptParts(opts) {
950
963
  const paramsWrites = opts.paramsWrites?.length
951
964
  ? `\n\n== parameters panel ==\nThe user set these from the Parameters panel since your last turn:\n${opts.paramsWrites.map((slot) => `- ${slot}`).join("\n")}`
952
965
  : "";
966
+ const models = [
967
+ opts.routerModel
968
+ ? `This chat (you) runs on: ${modelLabel(opts.routerModel.model, opts.isFreeModel ?? noFreeModels)} (effort ${opts.routerModel.effort})`
969
+ : undefined,
970
+ opts.taskModel
971
+ ? `New tasks run on: ${modelLabel(opts.taskModel.model, opts.isFreeModel ?? noFreeModels)} (effort ${opts.taskModel.effort})`
972
+ : undefined,
973
+ ].filter((line) => line !== undefined);
974
+ // Above the board, not beside the user's message: last in the prompt, the
975
+ // models lines tipped the router into spawning (n19-cover-host, 26-09-28:
976
+ // 19/19 spawns vs 6/19 off; 5/10 once moved here).
977
+ const modelsSection = models.length ? `\n\n== models ==\n${models.join("\n")}` : "";
953
978
  const stopped = opts.stopped?.length
954
979
  ? `\n\n${STOPPED_TASKS_HEADER}:\n${opts.stopped
955
980
  .map((stop) => {
@@ -977,15 +1002,15 @@ export function buildRouterPromptParts(opts) {
977
1002
  // does not. `user` holds what changes every turn: the transcript, the plan,
978
1003
  // the board and this instruction.
979
1004
  return {
980
- system: `${routerRules(opts.plan !== undefined, opts.playtest === true, opts.askCalls === true, opts.playtestPref, opts.steer === true)}
1005
+ system: `${routerRules(opts.plan !== undefined, opts.playtest === true, opts.playtestPref, opts.steer === true)}
981
1006
 
982
1007
  == deck ==
983
1008
  ${opts.deckLabel}${quickReference}${editorTabs}${kits}${deckFiles}`,
984
1009
  user: `== conversation so far ==
985
- ${renderTranscript(opts.messages)}${plan}
1010
+ ${renderTranscript(opts.messages)}${plan}${modelsSection}
986
1011
 
987
1012
  == background tasks ==
988
- ${renderTasks(opts.tasks, opts.plan !== undefined)}${endedBadly}${stopped}${unsent}${paramsWrites}
1013
+ ${renderTasks(opts.tasks, opts.plan !== undefined, opts.isFreeModel ?? noFreeModels)}${endedBadly}${stopped}${unsent}${paramsWrites}
989
1014
 
990
1015
  == now ==
991
1016
  ${opts.instruction}
@@ -1030,7 +1055,10 @@ export function userTurnInstruction(opts) {
1030
1055
  const markNote = marked.length > 0
1031
1056
  ? ` ${marked.join(", ")} ${marked.length === 1 ? "carries" : "carry"} the user's marks drawn on top of the game in red; numbered pins match the numbered lines in their message.`
1032
1057
  : "";
1033
- parts.push(`The user attached image file(s), saved in the deck at: ${opts.attachments.join(", ")}. Open them with your read tool. Take them into account; pass the paths along to task agents that need them.${markNote}`);
1058
+ const flatNote = (opts.flattened ?? [])
1059
+ .map(({ view, original }) => ` ${view} is ${original} flattened onto white, because its transparent areas would show to you as black; ${original} keeps the transparency, so pass that one to a task that puts the image in the game.`)
1060
+ .join("");
1061
+ parts.push(`The user attached image file(s), saved in the deck at: ${opts.attachments.join(", ")}. Open them with your read tool. Take them into account; pass the paths along to task agents that need them.${markNote}${flatNote}`);
1034
1062
  }
1035
1063
  if (opts.refs && opts.refs.length > 0) {
1036
1064
  parts.push(`The user pointed at: ${opts.refs.map(refPhrase).join(", ")}. Read them with your read tool if you need them to reply. When you spawn a task one of these concerns, name it the same way in that task's prompt -- the path and the lines, or the path and the param -- so the agent reads that place; do not mention it to tasks it does not concern.`);
package/dist/agent.d.ts CHANGED
@@ -98,7 +98,6 @@ interface TaskRecord {
98
98
  export declare function playtestEnabled(deckDir: string): boolean;
99
99
  export declare function playtestPrefFor(deckDir: string): 'on' | 'off' | undefined;
100
100
  export declare function setPlaytestPref(deckDir: string, value: 'on' | 'off'): boolean;
101
- export declare function askCallsEnabled(deckDir: string): boolean;
102
101
  interface AgentRunHandle {
103
102
  pid?: number | undefined;
104
103
  exitCode: number | null;
@@ -144,6 +143,7 @@ export declare function createTaskStore(opts: {
144
143
  onRetry: (task: TaskRecord, attempt: number) => void;
145
144
  onFeed: (task: TaskRecord, entry: string) => void;
146
145
  }): TaskStore;
146
+ export declare function attachmentViewName(fileName: string): string;
147
147
  export declare function computeSettingsWarnings(settings: AgentSettings): Promise<SettingsWarnings>;
148
148
  export interface AgentServer {
149
149
  /** Start tasks recovered from a restart; call once the serve is listening. */
package/dist/agent.js CHANGED
@@ -37,7 +37,7 @@ import { badTaskEndingsSince, platformInterruptionReason, ROUTER_STOPPED_RESULT,
37
37
  import { accountForRun, closingMessageOf } from './taskAccount.js';
38
38
  import { atomicWriteFileSync } from './atomicFile.js';
39
39
  import { AGENT_ATTACHMENT_PREFIX, AGENT_PLAYTEST_PREFIX, PLAN_FILE } from './localPaths.js';
40
- import { applyPlanOps, buildRouterPromptParts, buildTaskPrompt, parsePlanOps, planOpenQuestionLines, truncateToBytes, userTurnInstruction, CLAUDE_TASK_SYSTEM_REMINDER, modelTaskAddendum, isMuseModel, } from './agent-prompts.js';
40
+ import { applyPlanOps, buildRouterPromptParts, buildTaskPrompt, parsePlanOps, truncateToBytes, userTurnInstruction, CLAUDE_TASK_SYSTEM_REMINDER, modelTaskAddendum, isMuseModel, } from './agent-prompts.js';
41
41
  import { readCastleJson } from './castleJson.js';
42
42
  import { checkOpenrouterKey, checkOpenrouterModel, primeOpenrouterCatalog, } from './openrouter-catalog.js';
43
43
  import { classifyProviderError, failureCopy, failureLabel, routerTaskError, setReaderTimeZone, } from './agent-failures.js';
@@ -647,29 +647,10 @@ function planSession(deckDir) {
647
647
  const session = {
648
648
  enabled: declared === 'on' ? true : declared === 'off' ? false : planDefault(),
649
649
  notices: [],
650
- asyncNotices: [],
651
- quietBuildTurns: 0,
652
650
  };
653
651
  planSessions.set(deckDir, session);
654
652
  return session;
655
653
  }
656
- const askCallsSessions = new Map();
657
- // The inverse of planDefault: dormant until someone asks for it.
658
- function askCallsDefault() {
659
- return process.env.CASTLE_AGENT_ASK_CALLS === 'on';
660
- }
661
- // Resolved once per deck and cached for the reason planSession is: it decides
662
- // what sits in the prompt's cached prefix, so honoring a mid-session change
663
- // would split the prompt cache. Changing it takes a serve restart.
664
- export function askCallsEnabled(deckDir) {
665
- const cached = askCallsSessions.get(deckDir);
666
- if (cached !== undefined)
667
- return cached;
668
- const declared = readCastleJson(deckDir)?.agent?.askCalls;
669
- const enabled = declared === 'on' ? true : declared === 'off' ? false : askCallsDefault();
670
- askCallsSessions.set(deckDir, enabled);
671
- return enabled;
672
- }
673
654
  function readPlanSnapshot(deckDir) {
674
655
  let raw;
675
656
  try {
@@ -761,9 +742,8 @@ function routerPlanOpts(deckDir, snapshot, nominations, tasks) {
761
742
  const session = planSession(deckDir);
762
743
  if (!session.enabled)
763
744
  return undefined;
764
- const notices = [...session.notices, ...session.asyncNotices].slice(0, PLAN_NOTICE_LIMIT);
745
+ const notices = session.notices.slice(0, PLAN_NOTICE_LIMIT);
765
746
  session.notices = [];
766
- session.asyncNotices = [];
767
747
  return {
768
748
  fileText: snapshot.text,
769
749
  pendingDurables: nominations.map((t) => ({
@@ -775,32 +755,6 @@ function routerPlanOpts(deckDir, snapshot, nominations, tasks) {
775
755
  notices,
776
756
  };
777
757
  }
778
- // The agenda nudge. A reply that spawned work, asked nothing (no probe chips,
779
- // no question mark), while `## Open questions` holds a standing line, is a
780
- // quiet build turn; the second in a row queues a notice naming the top line.
781
- // Counting quiet turns and naming the line is exactly what five wordings of a
782
- // prompt rule could not get the router to do for itself (0 across 14 samples,
783
- // 26-08-18) and what the notice-shaped close rule showed it does do when told.
784
- function trackStandingQuestions(ctx, cleaned, spawnedWork) {
785
- const session = planSession(ctx.deckDir);
786
- if (!session.enabled)
787
- return;
788
- const askedSomething = /\[\[[^\]\n]+\]\]/.test(cleaned) || cleaned.includes('?');
789
- if (askedSomething || !spawnedWork) {
790
- session.quietBuildTurns = 0;
791
- return;
792
- }
793
- const standing = planOpenQuestionLines(readPlanSnapshot(ctx.deckDir).raw ?? '');
794
- if (standing.length === 0) {
795
- session.quietBuildTurns = 0;
796
- return;
797
- }
798
- session.quietBuildTurns += 1;
799
- if (session.quietBuildTurns < 2)
800
- return;
801
- session.quietBuildTurns = 0;
802
- session.asyncNotices.push(`the plan's top open question has now sat through two build turns with nothing asked -- this is the turn to ask it, in its own words, while work spawns anyway: ${standing[0]}`);
803
- }
804
758
  function taskPlanOpts(deckDir, item, finishedWork) {
805
759
  if (!planSession(deckDir).enabled)
806
760
  return undefined;
@@ -1943,6 +1897,9 @@ function createUsageFeed(opts) {
1943
1897
  refresh();
1944
1898
  return {
1945
1899
  latest: () => latest,
1900
+ // The budget outlives a switch to the user's own OpenRouter key; the chip
1901
+ // stops saying Muse then (usageFrame's freeModel), so the router must too.
1902
+ freeModelPrefixes: () => runIsCastlePaid('openrouter', null) ? (budget?.freeModelPrefixes ?? []) : [],
1946
1903
  recompute,
1947
1904
  refresh,
1948
1905
  stop: () => {
@@ -3299,13 +3256,21 @@ const ATTACHMENT_MIME = {
3299
3256
  gif: 'image/gif',
3300
3257
  webp: 'image/webp',
3301
3258
  };
3259
+ // The copy of an attachment the model is shown: the composer's `view`, the
3260
+ // picture flattened onto white because the model sees transparency as black.
3261
+ export function attachmentViewName(fileName) {
3262
+ return fileName.replace(/\.[^.]+$/, '') + '-view.jpg';
3263
+ }
3264
+ const VIEW_DATA_URL = /^data:image\/jpeg;base64,([A-Za-z0-9+/=]+)$/;
3302
3265
  // Decode pasted/attached images (data URLs) into .castle/agent/attachments/.
3303
- // Returns the saved file names, and which of them carry the user's marks.
3266
+ // Returns the saved file names, which of them carry the user's marks, and
3267
+ // which have a flattened view saved beside them (attachmentViewName).
3304
3268
  function saveAttachments(attachmentsDir, messageId, images) {
3305
3269
  const saved = [];
3306
3270
  const marked = [];
3271
+ const viewed = [];
3307
3272
  if (!Array.isArray(images))
3308
- return { saved, marked };
3273
+ return { saved, marked, viewed };
3309
3274
  for (const [index, image] of images.slice(0, MAX_ATTACHMENTS).entries()) {
3310
3275
  const dataUrl = image?.dataUrl;
3311
3276
  if (typeof dataUrl !== 'string' || dataUrl.length > MAX_ATTACHMENT_BYTES * 1.4)
@@ -3324,9 +3289,23 @@ function saveAttachments(attachmentsDir, messageId, images) {
3324
3289
  }
3325
3290
  catch {
3326
3291
  /* disk trouble -- skip this image */
3292
+ continue;
3293
+ }
3294
+ const view = image.view;
3295
+ const viewMatch = typeof view === 'string' && view.length <= MAX_ATTACHMENT_BYTES * 1.4
3296
+ ? VIEW_DATA_URL.exec(view)
3297
+ : null;
3298
+ if (!viewMatch)
3299
+ continue;
3300
+ try {
3301
+ atomicWriteFileSync(path.join(attachmentsDir, attachmentViewName(fileName)), Buffer.from(viewMatch[1], 'base64'));
3302
+ viewed.push(fileName);
3303
+ }
3304
+ catch {
3305
+ /* the model reads the faithful file instead */
3327
3306
  }
3328
3307
  }
3329
- return { saved, marked };
3308
+ return { saved, marked, viewed };
3330
3309
  }
3331
3310
  function isExistingFile(abs) {
3332
3311
  try {
@@ -3466,6 +3445,8 @@ function asPromptTask(task) {
3466
3445
  status: task.rejected ? 'rejected by user' : task.status,
3467
3446
  progress: task.progress,
3468
3447
  notes: task.notes,
3448
+ ...(task.model ? { model: task.model } : {}),
3449
+ ...(task.effort ? { effort: task.effort } : {}),
3469
3450
  item: task.item,
3470
3451
  error: task.status === 'failed'
3471
3452
  ? withTimeoutReport(routerTaskError(firstErrorLine(task.resultSummary), task.failure, task.errorCopy), task)
@@ -3724,6 +3705,8 @@ function routerTurnPrompt(ctx, instruction, selfMessageId, plan) {
3724
3705
  const messages = ctx.log.messages.filter((message) => message.role !== 'log' && message.id !== selfMessageId && message.status !== 'streaming');
3725
3706
  const tasks = ctx.taskStore.sorted();
3726
3707
  const lastReplyAtMs = panelWriteWatermark(ctx.log.messages, selfMessageId);
3708
+ const taskClaudeModel = ctx.taskClaudeModel();
3709
+ const taskOpenrouterModel = ctx.taskOpenrouterModel();
3727
3710
  return buildRouterPromptParts({
3728
3711
  deckLabel: ctx.deckLabel,
3729
3712
  quickReference: quickReferenceFor(ctx.deckDir, deckGuide, 'router'),
@@ -3732,11 +3715,19 @@ function routerTurnPrompt(ctx, instruction, selfMessageId, plan) {
3732
3715
  deckTree: buildDeckTree(ctx.deckDir),
3733
3716
  playtest: playtestEnabled(ctx.deckDir),
3734
3717
  playtestPref: playtestPrefFor(ctx.deckDir),
3735
- askCalls: askCallsEnabled(ctx.deckDir),
3736
3718
  steer: TASK_STEER_ENABLED || undefined,
3737
3719
  unsentSends: TASK_STEER_ENABLED
3738
3720
  ? messages.filter((m) => m.role === 'assistant').at(-1)?.unsent
3739
3721
  : undefined,
3722
+ isFreeModel: (model) => modelIsFree(model, ctx.freeModelPrefixes()),
3723
+ routerModel: {
3724
+ model: spawnModelFor(ctx.claudeModel(), ctx.openrouterModel()),
3725
+ effort: spawnEffortFor(ctx.claudeModel(), ctx.openrouterModel(), ctx.effort()),
3726
+ },
3727
+ taskModel: {
3728
+ model: spawnModelFor(taskClaudeModel, taskOpenrouterModel),
3729
+ effort: spawnEffortFor(taskClaudeModel, taskOpenrouterModel, ctx.taskEffort()),
3730
+ },
3740
3731
  messages: messages.map((m) => ({
3741
3732
  role: m.role,
3742
3733
  // Replace a prior turn's raw ```ask JSON with a readable question list
@@ -3995,7 +3986,6 @@ function runRouterTurnIn(ctx, instruction) {
3995
3986
  if (result.ok) {
3996
3987
  message.text = cleaned;
3997
3988
  message.status = 'done';
3998
- trackStandingQuestions(ctx, cleaned, taskIds.length > 0);
3999
3989
  }
4000
3990
  else {
4001
3991
  const failure = resolveFailure(result);
@@ -4348,12 +4338,19 @@ function handleStopTask(taskStore, socket, msg) {
4348
4338
  }
4349
4339
  }
4350
4340
  // A mirror on disk is not evidence: only names that are also this send's
4351
- // attachments count as marked.
4341
+ // attachments count as marked or viewed.
4342
+ function attachmentSubset(item, names) {
4343
+ if (!Array.isArray(names))
4344
+ return [];
4345
+ return names.filter((name) => typeof name === 'string' && item.attachments.includes(name));
4346
+ }
4352
4347
  function markedOf(item) {
4353
- if (!Array.isArray(item.marked))
4354
- return {};
4355
- const marked = item.marked.filter((name) => typeof name === 'string' && item.attachments.includes(name));
4356
- return marked.length > 0 ? { marked } : {};
4348
+ const marked = attachmentSubset(item, item.marked);
4349
+ const viewed = attachmentSubset(item, item.viewed);
4350
+ return {
4351
+ ...(marked.length > 0 ? { marked } : {}),
4352
+ ...(viewed.length > 0 ? { viewed } : {}),
4353
+ };
4357
4354
  }
4358
4355
  // Restart recovery: load the durable queue mirror, keeping only well-formed
4359
4356
  // sends that never reached the message log. A send whose id is already in
@@ -4460,6 +4457,10 @@ function startRouterTurn(ctx, instruction) {
4460
4457
  claudeModel: () => ctx.settings.routerClaudeModel,
4461
4458
  openrouterModel: () => ctx.settings.routerOpenrouterModel,
4462
4459
  effort: () => ctx.settings.routerEffort,
4460
+ taskClaudeModel: () => ctx.settings.tasksClaudeModel,
4461
+ taskOpenrouterModel: () => ctx.settings.tasksOpenrouterModel,
4462
+ taskEffort: () => ctx.settings.tasksEffort,
4463
+ freeModelPrefixes: ctx.freeModelPrefixes,
4463
4464
  canAutoRetry: () => !ctx.state.autoRetryUsed && ctx.state.pendingSends.length === 0,
4464
4465
  onSettled: (retryable) => onRouterQueueSettled(ctx, retryable),
4465
4466
  }, instruction);
@@ -4472,6 +4473,7 @@ function commitDrainedSends(drained, log) {
4472
4473
  const texts = [];
4473
4474
  const attachmentPaths = [];
4474
4475
  const markedPaths = [];
4476
+ const flattened = [];
4475
4477
  const refs = [];
4476
4478
  for (const item of drained) {
4477
4479
  if (!item.logged) {
@@ -4493,14 +4495,20 @@ function commitDrainedSends(drained, log) {
4493
4495
  if (item.text.trim())
4494
4496
  texts.push(item.text);
4495
4497
  for (const name of item.attachments) {
4496
- const attachmentPath = path.join('.castle', 'agent', 'attachments', name);
4497
- attachmentPaths.push(attachmentPath);
4498
+ const original = path.join('.castle', 'agent', 'attachments', name);
4499
+ const view = item.viewed?.includes(name)
4500
+ ? path.join('.castle', 'agent', 'attachments', attachmentViewName(name))
4501
+ : null;
4502
+ const listed = view ?? original;
4503
+ attachmentPaths.push(listed);
4504
+ if (view)
4505
+ flattened.push({ view, original });
4498
4506
  if (item.marked?.includes(name))
4499
- markedPaths.push(attachmentPath);
4507
+ markedPaths.push(listed);
4500
4508
  }
4501
4509
  refs.push(...item.refs);
4502
4510
  }
4503
- return { texts, attachmentPaths, markedPaths, refs: uniqueLocators(refs) };
4511
+ return { texts, attachmentPaths, markedPaths, flattened, refs: uniqueLocators(refs) };
4504
4512
  }
4505
4513
  // Drain the queue into the log as real user messages and start one follow-up
4506
4514
  // turn addressing them all (a burst batches into a single turn). A pending
@@ -4522,7 +4530,7 @@ function maybeStartRouterQueueTurn(ctx) {
4522
4530
  for (const send of drained)
4523
4531
  if (!send.hideFromUi)
4524
4532
  ctx.taskStore.releaseHeld(send.text);
4525
- const { texts, attachmentPaths, markedPaths, refs } = commitDrainedSends(drained, ctx.log);
4533
+ const { texts, attachmentPaths, markedPaths, flattened, refs } = commitDrainedSends(drained, ctx.log);
4526
4534
  // The queue is now committed to messages.json; clear its durable mirror.
4527
4535
  persistPendingSends(ctx);
4528
4536
  const draft = state.pendingInterruptedDraft;
@@ -4534,6 +4542,7 @@ function maybeStartRouterQueueTurn(ctx) {
4534
4542
  interruptedDraft: draft || undefined,
4535
4543
  attachments: attachmentPaths,
4536
4544
  marked: markedPaths,
4545
+ flattened,
4537
4546
  refs,
4538
4547
  }));
4539
4548
  }
@@ -4613,12 +4622,13 @@ function handleQueueUserMessage(ctx, text, images, refs, clientId, hideFromUi) {
4613
4622
  return;
4614
4623
  }
4615
4624
  const id = sentId ?? nanoid(8);
4616
- const { saved: attachments, marked } = saveAttachments(ctx.attachmentsDir, id, images);
4625
+ const { saved: attachments, marked, viewed } = saveAttachments(ctx.attachmentsDir, id, images);
4617
4626
  state.pendingSends.push({
4618
4627
  id,
4619
4628
  text,
4620
4629
  attachments,
4621
4630
  ...(marked.length > 0 ? { marked } : {}),
4631
+ ...(viewed.length > 0 ? { viewed } : {}),
4622
4632
  refs: validMessageRefs(ctx.deckDir, refs),
4623
4633
  ...(hideFromUi ? { hideFromUi: true } : {}),
4624
4634
  });
@@ -4784,10 +4794,9 @@ export function createAgentServer(opts) {
4784
4794
  const attachmentsDir = path.join(agentDir, 'attachments');
4785
4795
  const messagesPath = path.join(agentDir, 'messages.json');
4786
4796
  fs.mkdirSync(tasksDir, { recursive: true });
4787
- // Read the prompt switches this deck declares now, so the whole serve shares
4788
- // one answer for each -- see planSession and askCallsEnabled.
4797
+ // Read the plan switch this deck declares now, so the whole serve shares one
4798
+ // answer -- see planSession.
4789
4799
  planSession(deckDir);
4790
- askCallsEnabled(deckDir);
4791
4800
  // Warm the OpenRouter catalog now so the first pre-flight and the first
4792
4801
  // popover open read a cache instead of paying for the fetch. Fire-and-forget
4793
4802
  // by design -- nothing here depends on it, and it falls open if it fails.
@@ -4907,6 +4916,7 @@ export function createAgentServer(opts) {
4907
4916
  // guard). Lives in its own factory; createAgentServer just wires it up.
4908
4917
  const routerQueue = createRouterQueue({
4909
4918
  deckDir,
4919
+ freeModelPrefixes: usageFeed.freeModelPrefixes,
4910
4920
  deckLabel,
4911
4921
  agentDir,
4912
4922
  attachmentsDir,
package/dist/api.d.ts CHANGED
@@ -176,6 +176,9 @@ export interface DeckMeta {
176
176
  creator: {
177
177
  username: string;
178
178
  } | null;
179
+ initialCard: {
180
+ type: string | null;
181
+ } | null;
179
182
  }
180
183
  export declare function deckMeta(deckId: string): Promise<DeckMeta | null>;
181
184
  export declare function webDeckSource(deckId: string): Promise<WebDeckSource | null>;
package/dist/api.js CHANGED
@@ -273,12 +273,12 @@ export async function saveCauldronServerBundle(deckId, uploadId, serverConfig) {
273
273
  handleAPIError(data);
274
274
  return pickData(data, 'saveCauldronServerBundle');
275
275
  }
276
- // Title + author, for naming an import. Readable without auth for the same decks
277
- // webDeckSource is (unlisted ones), so this works in a sandbox with no login.
276
+ // Metadata for naming an import and distinguishing classic decks. Readable
277
+ // without auth for the same decks webDeckSource is, including unlisted ones.
278
278
  export async function deckMeta(deckId) {
279
279
  const data = await graphql(`query($deckId: ID!) {
280
280
  deck(deckId: $deckId) {
281
- deckId title creator { username }
281
+ deckId title creator { username } initialCard { type }
282
282
  }
283
283
  }`, { deckId });
284
284
  return data?.data?.deck ?? null;