castle-web-cli 0.4.189 → 0.4.191
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/agent-prompts.d.ts +3 -0
- package/dist/agent-prompts.js +14 -2
- package/dist/agent.d.ts +3 -0
- package/dist/agent.js +114 -22
- package/dist/shell/assets/index-6eWEUoBA.js +449 -0
- package/dist/shell/assets/index-D6leLNUq.css +1 -0
- package/dist/shell/index.html +2 -2
- package/kits/physics-2d/castle.json +1 -1
- package/kits/physics-2d/editors/PxArtEditor.jsx +6 -28
- package/kits/physics-2d/editors/SceneEditor.jsx +16 -67
- package/kits/physics-2d/editors/editorHistory.js +27 -0
- package/kits/physics-2d/editors/pixelEditorChrome.jsx +7 -19
- package/kits/physics-2d/engine/icons.js +0 -2
- package/kits/physics-2d/eslint.config.js +1 -1
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/engine3d/PxModelEditor.jsx +2 -2
- package/kits/physics-3d/engine3d/Scene3DEditor.jsx +2 -2
- package/kits/physics-3d/engine3d/editorChrome.jsx +23 -51
- package/package.json +1 -1
- package/dist/shell/assets/index-BHS1yecn.js +0 -449
- package/dist/shell/assets/index-BaqrGZkv.css +0 -1
package/dist/agent-prompts.d.ts
CHANGED
|
@@ -121,3 +121,6 @@ export declare function buildTaskPrompt(opts: {
|
|
|
121
121
|
playtest?: boolean;
|
|
122
122
|
}): string;
|
|
123
123
|
export declare const CLAUDE_TASK_SYSTEM_REMINDER = "Castle background task agent: work autonomously to completion -- never pause to ask questions or wait for confirmation; finish the task end-to-end, then stop. Prefer the quickest viable change that fully does the job.";
|
|
124
|
+
export declare const MUSE_TASK_ADDENDUM = "Kit code rules for this deck. The kit guide documents every API you need; use exactly the names and signatures it gives and nothing else. Do not guess at APIs: no typeof checks on methods, no ?. or ?? fallbacks on documented objects, no try/catch around ordinary calls, no alternate spellings of a callback. One mechanism per feature, chosen for what the task asks (a tap on the actor is its onTap; a tap anywhere on the card is the pointer checked in update; a contact is onCollisionEnter): use that one and never also scan for the same event another way. Props come from defaultProps, so never repeat a default with ?? value. Find actors by the behavior or id the task names; never sniff ids like 'player' or 'ball' as fallbacks. Read the guide's gotchas for every API you use and follow them. Reference only files that exist in the deck tree or that you create in this task. Build everything the task names and only that: no extra input methods, actors, or polish it did not mention.";
|
|
125
|
+
export declare function isMuseModel(model: string): boolean;
|
|
126
|
+
export declare function modelTaskAddendum(model: string): string | undefined;
|
package/dist/agent-prompts.js
CHANGED
|
@@ -72,13 +72,15 @@ comma-separated active-task titles or ids, or \`all\`
|
|
|
72
72
|
- Task agents are capable coding agents working in this same deck directory, but they know nothing about this conversation beyond your prompt.
|
|
73
73
|
- The deck keeps its own version history, and you may READ it: \`castle-web list-versions\` shows the versions newest first, and \`castle-web show-version <id>\` shows what one changed, as diffs of just those files. Use them to answer "what changed" or to ground a claim about recent work. You NEVER run \`save-version\` -- you did not make the changes, so a version of yours would not correspond to a unit of work -- and you NEVER run \`restore-version\`: going back is the user's own decision, not something you do on their behalf.
|
|
74
74
|
|
|
75
|
-
Asking with options (the \`\`\`ask block). When you need the user to settle a few choices at once, emit ONE fenced block tagged \`ask\` containing JSON -- it renders inline in the chat as grouped options they tap and submit together (far better than stacking questions they can only half-answer). Reach for it to pin a direction fast when their ask is vague ("make me a game" -> ask what kind), NOT to interrogate.
|
|
75
|
+
Asking with options (the \`\`\`ask block). When you need the user to settle a few choices at once, emit ONE fenced block tagged \`ask\` containing JSON -- it renders inline in the chat as grouped options they tap and submit together (far better than stacking questions they can only half-answer). Reach for it to pin a direction fast when their ask is vague ("make me a game" -> ask what kind), NOT to interrogate.
|
|
76
76
|
|
|
77
77
|
\`\`\`ask
|
|
78
78
|
{ "questions": [ { "id": "kind", "q": "What kind of game?", "options": ["Arcade", "Puzzle", "Platformer"] }, { "id": "feel", "q": "What should it feel like?", "options": ["Cozy", "Frantic"], "multi": true } ] }
|
|
79
79
|
\`\`\`
|
|
80
80
|
|
|
81
|
-
- Per question: \`q\` (the text, required), \`options\` (
|
|
81
|
+
- Per question: \`q\` (the text, required), \`options\` (named choices, required), \`multi\` (optional -- false/omitted = pick one, true = pick any that apply), \`id\` (optional answer handle). Keep it to a few high-leverage questions.
|
|
82
|
+
- Skip and Other are always on the widget: Skip sits beside the question so they can pass on it, Other is a free-text field at the bottom of the list. Do NOT add "Other" or "Skip" to \`options\` -- they are already there. Named options only.
|
|
83
|
+
- A skipped question comes back as \`skipped\`. Other comes back as whatever they typed. Act on those the same as a named pick.
|
|
82
84
|
- The user's picks come back as their next message, which you then act on (usually by spawning the first build tasks). Don't pair an \`\`\`ask block with task directives in the same reply -- ask first, build once they answer. Don't use one when a single plain question would do, and never re-ask something already settled.
|
|
83
85
|
|
|
84
86
|
Conversation style:
|
|
@@ -999,3 +1001,13 @@ phase: wiring the paddle to touch
|
|
|
999
1001
|
// Appended to claude task agents' system prompt (portable replacement for the
|
|
1000
1002
|
// machine-specific /goal slash command): commit to autonomous completion.
|
|
1001
1003
|
export const CLAUDE_TASK_SYSTEM_REMINDER = "Castle background task agent: work autonomously to completion -- never pause to ask questions or wait for confirmation; finish the task end-to-end, then stop. Prefer the quickest viable change that fully does the job.";
|
|
1004
|
+
// Meta's muse models hedge on uncertain kit APIs with typeof probes, several
|
|
1005
|
+
// callback spellings, and per-frame scans beside callbacks. These rules apply to
|
|
1006
|
+
// muse task agents only; other models are untouched.
|
|
1007
|
+
export const MUSE_TASK_ADDENDUM = "Kit code rules for this deck. The kit guide documents every API you need; use exactly the names and signatures it gives and nothing else. Do not guess at APIs: no typeof checks on methods, no ?. or ?? fallbacks on documented objects, no try/catch around ordinary calls, no alternate spellings of a callback. One mechanism per feature, chosen for what the task asks (a tap on the actor is its onTap; a tap anywhere on the card is the pointer checked in update; a contact is onCollisionEnter): use that one and never also scan for the same event another way. Props come from defaultProps, so never repeat a default with ?? value. Find actors by the behavior or id the task names; never sniff ids like 'player' or 'ball' as fallbacks. Read the guide's gotchas for every API you use and follow them. Reference only files that exist in the deck tree or that you create in this task. Build everything the task names and only that: no extra input methods, actors, or polish it did not mention.";
|
|
1008
|
+
export function isMuseModel(model) {
|
|
1009
|
+
return /muse/i.test(model);
|
|
1010
|
+
}
|
|
1011
|
+
export function modelTaskAddendum(model) {
|
|
1012
|
+
return isMuseModel(model) ? MUSE_TASK_ADDENDUM : undefined;
|
|
1013
|
+
}
|
package/dist/agent.d.ts
CHANGED
|
@@ -3,11 +3,14 @@ import { Duplex } from 'stream';
|
|
|
3
3
|
import { type PlaytestToolResult } from './native/playtest.js';
|
|
4
4
|
export declare const AGENT_WS_PATH = "/__castle/agent";
|
|
5
5
|
export type ClaudeModel = 'sonnet' | 'opus' | 'fable' | 'openrouter';
|
|
6
|
+
export type EffortLevel = 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
6
7
|
interface AgentSettings {
|
|
7
8
|
routerClaudeModel: ClaudeModel;
|
|
8
9
|
tasksClaudeModel: ClaudeModel;
|
|
9
10
|
routerOpenrouterModel: string;
|
|
10
11
|
tasksOpenrouterModel: string;
|
|
12
|
+
routerEffort: EffortLevel;
|
|
13
|
+
tasksEffort: EffortLevel;
|
|
11
14
|
}
|
|
12
15
|
type OpenrouterSlugKey = 'routerOpenrouterModel' | 'tasksOpenrouterModel';
|
|
13
16
|
type SettingsWarnings = Partial<Record<OpenrouterSlugKey, {
|
package/dist/agent.js
CHANGED
|
@@ -27,7 +27,7 @@ import { WebSocketServer } from 'ws';
|
|
|
27
27
|
import { rawDataToString } from './rawData.js';
|
|
28
28
|
import { atomicWriteFileSync } from './atomicFile.js';
|
|
29
29
|
import { AGENT_ATTACHMENT_PREFIX, AGENT_PLAYTEST_PREFIX, PLAN_FILE } from './localPaths.js';
|
|
30
|
-
import { applyPlanOps, buildRouterPromptParts, buildTaskPrompt, parsePlanOps, planOpenQuestionLines, truncateToBytes, userTurnInstruction, CLAUDE_TASK_SYSTEM_REMINDER, } from './agent-prompts.js';
|
|
30
|
+
import { applyPlanOps, buildRouterPromptParts, buildTaskPrompt, parsePlanOps, planOpenQuestionLines, truncateToBytes, userTurnInstruction, CLAUDE_TASK_SYSTEM_REMINDER, modelTaskAddendum, isMuseModel, } from './agent-prompts.js';
|
|
31
31
|
import { readCastleJson } from './castleJson.js';
|
|
32
32
|
import { checkOpenrouterKey, checkOpenrouterModel, primeOpenrouterCatalog, } from './openrouter-catalog.js';
|
|
33
33
|
import { classifyProviderError, failureCopy, setReaderTimeZone, } from './agent-failures.js';
|
|
@@ -55,6 +55,8 @@ const DEFAULT_SETTINGS = {
|
|
|
55
55
|
// castleSpendRefusal. Picking any other slug puts that role back on credits.
|
|
56
56
|
routerOpenrouterModel: 'meta/muse-spark-1.3-contributor',
|
|
57
57
|
tasksOpenrouterModel: 'meta/muse-spark-1.3-contributor',
|
|
58
|
+
routerEffort: 'medium',
|
|
59
|
+
tasksEffort: 'medium',
|
|
58
60
|
};
|
|
59
61
|
// What the two claude-model defaults become once the user has an Anthropic
|
|
60
62
|
// credential of their own -- a key or a claude.ai login, which
|
|
@@ -70,10 +72,26 @@ const ANTHROPIC_DEFAULT_MODELS = {
|
|
|
70
72
|
// appears and disappears mid-session (the Accounts modal, `claude /login` in
|
|
71
73
|
// the terminal panel, a hand-edited user-keys.json), and
|
|
72
74
|
// refreshDefaultedSettings re-reads it when it does.
|
|
75
|
+
// The effort a role starts at for a given model. Tasks on a muse model start
|
|
76
|
+
// at low: castle-agent-evals/muse-tune measured medium as slower with more api
|
|
77
|
+
// guessing. The operator stays at medium on every model, and claude models
|
|
78
|
+
// stay at medium for both roles. A level the user picks is stored and stands.
|
|
79
|
+
function defaultEffortFor(role, claudeModel, openrouterModel) {
|
|
80
|
+
return role === 'tasks' && claudeModel === 'openrouter' && isMuseModel(openrouterModel) ? 'low' : 'medium';
|
|
81
|
+
}
|
|
82
|
+
const EFFORT_ROLES = [
|
|
83
|
+
{ role: 'router', label: 'operator', claude: 'routerClaudeModel', slug: 'routerOpenrouterModel', effort: 'routerEffort' },
|
|
84
|
+
{ role: 'tasks', label: 'tasks', claude: 'tasksClaudeModel', slug: 'tasksOpenrouterModel', effort: 'tasksEffort' },
|
|
85
|
+
];
|
|
73
86
|
function defaultSettings() {
|
|
74
|
-
|
|
87
|
+
const models = resolveAnthropicAuth().mode === 'proxy'
|
|
75
88
|
? { ...DEFAULT_SETTINGS }
|
|
76
89
|
: { ...DEFAULT_SETTINGS, ...ANTHROPIC_DEFAULT_MODELS };
|
|
90
|
+
return {
|
|
91
|
+
...models,
|
|
92
|
+
routerEffort: defaultEffortFor('router', models.routerClaudeModel, models.routerOpenrouterModel),
|
|
93
|
+
tasksEffort: defaultEffortFor('tasks', models.tasksClaudeModel, models.tasksOpenrouterModel),
|
|
94
|
+
};
|
|
77
95
|
}
|
|
78
96
|
// Bump to force every deck onto the current DEFAULT_SETTINGS once, discarding
|
|
79
97
|
// what users had chosen: a stored file below this epoch has ALL of its setting
|
|
@@ -120,6 +138,15 @@ function normalizeOpenrouterModel(value) {
|
|
|
120
138
|
const trimmed = value.trim();
|
|
121
139
|
return trimmed && trimmed.length <= OPENROUTER_MODEL_MAX_LEN ? trimmed : null;
|
|
122
140
|
}
|
|
141
|
+
function normalizeEffort(value) {
|
|
142
|
+
return value === 'low' ||
|
|
143
|
+
value === 'medium' ||
|
|
144
|
+
value === 'high' ||
|
|
145
|
+
value === 'xhigh' ||
|
|
146
|
+
value === 'max'
|
|
147
|
+
? value
|
|
148
|
+
: null;
|
|
149
|
+
}
|
|
123
150
|
// Every setting's validator, keyed the same as AgentSettings, so load and save
|
|
124
151
|
// iterate one list rather than repeating the field names per direction.
|
|
125
152
|
const SETTING_NORMALIZERS = {
|
|
@@ -127,6 +154,8 @@ const SETTING_NORMALIZERS = {
|
|
|
127
154
|
tasksClaudeModel: normalizeClaudeModel,
|
|
128
155
|
routerOpenrouterModel: normalizeOpenrouterModel,
|
|
129
156
|
tasksOpenrouterModel: normalizeOpenrouterModel,
|
|
157
|
+
routerEffort: normalizeEffort,
|
|
158
|
+
tasksEffort: normalizeEffort,
|
|
130
159
|
};
|
|
131
160
|
const SETTING_KEYS = Object.keys(SETTING_NORMALIZERS);
|
|
132
161
|
// Sparse ON PURPOSE: only fields that DIFFER from the current defaults are
|
|
@@ -150,6 +179,16 @@ function serializeAgentSettings(settings) {
|
|
|
150
179
|
if (settings[key] !== defaults[key])
|
|
151
180
|
out[key] = settings[key];
|
|
152
181
|
}
|
|
182
|
+
// Effort's default follows the role's stored model, not the default model.
|
|
183
|
+
for (const role of EFFORT_ROLES) {
|
|
184
|
+
const value = settings[role.effort];
|
|
185
|
+
if (value === defaultEffortFor(role.role, settings[role.claude], settings[role.slug])) {
|
|
186
|
+
delete out[role.effort];
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
out[role.effort] = value;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
153
192
|
return JSON.stringify(out, null, 2) + '\n';
|
|
154
193
|
}
|
|
155
194
|
function loadAgentSettings(settingsPath) {
|
|
@@ -170,7 +209,14 @@ function loadAgentSettings(settingsPath) {
|
|
|
170
209
|
if (value !== null)
|
|
171
210
|
overrides[key] = value;
|
|
172
211
|
}
|
|
173
|
-
|
|
212
|
+
const merged = { ...defaults, ...overrides };
|
|
213
|
+
for (const role of EFFORT_ROLES) {
|
|
214
|
+
if (role.effort in overrides) {
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
217
|
+
merged[role.effort] = defaultEffortFor(role.role, merged[role.claude], merged[role.slug]);
|
|
218
|
+
}
|
|
219
|
+
return merged;
|
|
174
220
|
}
|
|
175
221
|
// Re-resolve the defaults into the live settings object after a credential
|
|
176
222
|
// change, in place because every consumer (the router queue, the task store)
|
|
@@ -265,7 +311,7 @@ function openrouterApiKey() {
|
|
|
265
311
|
// Build the headless CLI invocation for a role. Hosted claude runs
|
|
266
312
|
// bypassPermissions for both roles because the container is already the
|
|
267
313
|
// permission boundary. Local claude stays on auto (NOT plan mode -- that makes it emit plan tool calls)
|
|
268
|
-
// at
|
|
314
|
+
// at the role's effort setting. claudeModel "openrouter" keeps the SAME claude binary and
|
|
269
315
|
// swaps only the model slug and env (see envForOpenrouterSpawn).
|
|
270
316
|
// claude CLI 2.1.198 SILENTLY resolves `--permission-mode auto` to "default"
|
|
271
317
|
// whenever --model is not in its built-in catalog -- which is every free-form
|
|
@@ -347,7 +393,7 @@ const ROUTER_CLAUDE_ENV = {
|
|
|
347
393
|
function buildAgentInvocation(role, prompt, claudeModel,
|
|
348
394
|
// Already resolved for this role by the caller (router turns pass
|
|
349
395
|
// settings.routerOpenrouterModel, task spawns settings.tasksOpenrouterModel).
|
|
350
|
-
openrouterModel,
|
|
396
|
+
openrouterModel, effort,
|
|
351
397
|
// This run's ledger identity, and the deck dir its castle.json is read from.
|
|
352
398
|
metering,
|
|
353
399
|
// The task this spawn belongs to, so its playtest frames land under
|
|
@@ -357,11 +403,12 @@ taskId,
|
|
|
357
403
|
// The stable part of a router prompt, passed as appended system text so the
|
|
358
404
|
// CLI's own cache breakpoints cover it.
|
|
359
405
|
systemPrompt) {
|
|
360
|
-
const
|
|
406
|
+
const viaOpenrouter = claudeModel === 'openrouter';
|
|
407
|
+
const spawnModel = viaOpenrouter ? openrouterModel : claudeModel;
|
|
408
|
+
const systemText = [systemPrompt, role === 'task' ? CLAUDE_TASK_SYSTEM_REMINDER : undefined, role === 'task' ? modelTaskAddendum(spawnModel) : undefined]
|
|
361
409
|
.filter((text) => Boolean(text))
|
|
362
410
|
.join('\n\n');
|
|
363
411
|
const hosted = Boolean(process.env.CASTLE_SANDBOX_ID);
|
|
364
|
-
const viaOpenrouter = claudeModel === 'openrouter';
|
|
365
412
|
const orAuth = viaOpenrouter ? resolveOpenrouterAuth() : null;
|
|
366
413
|
const anAuth = viaOpenrouter ? null : resolveAnthropicAuth();
|
|
367
414
|
// Direct = the user's own credential/login is in play, so this run bypasses
|
|
@@ -380,9 +427,9 @@ systemPrompt) {
|
|
|
380
427
|
hosted ? 'bypassPermissions' : 'auto',
|
|
381
428
|
...(!hosted && viaOpenrouter ? [openrouterAllowedToolsArg(role)] : []),
|
|
382
429
|
'--model',
|
|
383
|
-
|
|
430
|
+
spawnModel,
|
|
384
431
|
'--effort',
|
|
385
|
-
|
|
432
|
+
effort,
|
|
386
433
|
// Newer claude models default thinking display to "omitted" (empty
|
|
387
434
|
// thinking_delta text, signature only); "summarized" restores actual
|
|
388
435
|
// summary text so the shell's expandable thinking transcript has
|
|
@@ -804,16 +851,18 @@ function humanizeAskBlocks(text) {
|
|
|
804
851
|
return null;
|
|
805
852
|
const opts = q.options
|
|
806
853
|
.filter((o) => typeof o === 'string' && o.trim() !== '')
|
|
854
|
+
.filter((o) => {
|
|
855
|
+
const t = o.trim().toLowerCase();
|
|
856
|
+
return t !== 'other' && t !== 'skip';
|
|
857
|
+
})
|
|
807
858
|
.join(' / ');
|
|
808
|
-
if (!opts)
|
|
809
|
-
return null;
|
|
810
859
|
const mode = q.multi === true ? 'pick any' : 'pick one';
|
|
811
|
-
return `- ${q.q} (${mode}): ${opts}`;
|
|
860
|
+
return opts ? `- ${q.q} (${mode}): ${opts}` : `- ${q.q} (${mode})`;
|
|
812
861
|
})
|
|
813
862
|
.filter((l) => l !== null);
|
|
814
863
|
if (lines.length === 0)
|
|
815
864
|
return whole;
|
|
816
|
-
return `[You asked the user to choose:\n${lines.join('\n')}]`;
|
|
865
|
+
return `[You asked the user to choose. Skip and Other are always on the picker -- do not add them to options:\n${lines.join('\n')}]`;
|
|
817
866
|
}
|
|
818
867
|
catch {
|
|
819
868
|
return whole;
|
|
@@ -1661,7 +1710,7 @@ async function runAgentTurn(opts) {
|
|
|
1661
1710
|
// conversation -- nothing is resumed).
|
|
1662
1711
|
const sessionId = newAgentSessionId(opts.role);
|
|
1663
1712
|
const settled = (run) => run.finally(() => notifyAgentRunFinished());
|
|
1664
|
-
const invocation = buildAgentInvocation(opts.role, opts.prompt, opts.claudeModel, opts.openrouterModel, { sessionId, deckDir: opts.cwd }, opts.taskId, opts.systemPrompt);
|
|
1713
|
+
const invocation = buildAgentInvocation(opts.role, opts.prompt, opts.claudeModel, opts.openrouterModel, opts.effort, { sessionId, deckDir: opts.cwd }, opts.taskId, opts.systemPrompt);
|
|
1665
1714
|
const run = runAgentCli({
|
|
1666
1715
|
cwd: opts.cwd,
|
|
1667
1716
|
command: invocation.command,
|
|
@@ -2016,6 +2065,7 @@ async function runTaskAgentIn(ctx, task) {
|
|
|
2016
2065
|
prompt: taskPrompt,
|
|
2017
2066
|
claudeModel: ctx.claudeModel,
|
|
2018
2067
|
openrouterModel: ctx.openrouterModel,
|
|
2068
|
+
effort: ctx.effort,
|
|
2019
2069
|
cwd: ctx.deckDir,
|
|
2020
2070
|
timeoutMs: TASK_TIMEOUT_MS,
|
|
2021
2071
|
logPath: path.join(dir, 'log.jsonl'),
|
|
@@ -2072,6 +2122,7 @@ function startTask(ctx, task) {
|
|
|
2072
2122
|
children: ctx.children,
|
|
2073
2123
|
claudeModel: ctx.claudeModel(),
|
|
2074
2124
|
openrouterModel: ctx.openrouterModel(),
|
|
2125
|
+
effort: ctx.effort(),
|
|
2075
2126
|
stopRequested: ctx.stopRequested,
|
|
2076
2127
|
quickReference: ctx.quickReference,
|
|
2077
2128
|
playtest: ctx.playtest,
|
|
@@ -2279,6 +2330,7 @@ function createTaskStore(opts) {
|
|
|
2279
2330
|
quickReference: opts.quickReference,
|
|
2280
2331
|
claudeModel: opts.claudeModel,
|
|
2281
2332
|
openrouterModel: opts.openrouterModel,
|
|
2333
|
+
effort: opts.effort,
|
|
2282
2334
|
playtest: opts.playtest,
|
|
2283
2335
|
onStarted: opts.onStarted,
|
|
2284
2336
|
onFinished: opts.onFinished,
|
|
@@ -2684,6 +2736,8 @@ function createMessageLog(messagesPath, broadcast, welcomeMessage, forClient) {
|
|
|
2684
2736
|
function add(message) {
|
|
2685
2737
|
messages.push(message);
|
|
2686
2738
|
persist();
|
|
2739
|
+
if (message.hideFromUi)
|
|
2740
|
+
return;
|
|
2687
2741
|
broadcast({ type: 'message-add', message: forClient(message) });
|
|
2688
2742
|
}
|
|
2689
2743
|
function addLog(text) {
|
|
@@ -2904,6 +2958,7 @@ function runRouterTurnIn(ctx, instruction) {
|
|
|
2904
2958
|
systemPrompt: prompt.system,
|
|
2905
2959
|
claudeModel: ctx.claudeModel(),
|
|
2906
2960
|
openrouterModel: ctx.openrouterModel(),
|
|
2961
|
+
effort: ctx.effort(),
|
|
2907
2962
|
cwd: ctx.deckDir,
|
|
2908
2963
|
timeoutMs: ROUTER_TIMEOUT_MS,
|
|
2909
2964
|
logPath: path.join(ctx.agentDir, 'router-log.jsonl'),
|
|
@@ -3098,6 +3153,27 @@ function applyAgentSettings(incoming, ctx) {
|
|
|
3098
3153
|
changes.push(`${key === 'routerOpenrouterModel' ? 'operator' : 'tasks'} openrouter model -> ${value}`);
|
|
3099
3154
|
}
|
|
3100
3155
|
}
|
|
3156
|
+
for (const key of ['routerEffort', 'tasksEffort']) {
|
|
3157
|
+
const value = normalizeEffort(incoming[key]);
|
|
3158
|
+
if (value && value !== settings[key]) {
|
|
3159
|
+
settings[key] = value;
|
|
3160
|
+
changes.push(`${key === 'routerEffort' ? 'operator' : 'tasks'} effort -> ${value}`);
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
// A role whose model just changed takes that model's default effort, unless
|
|
3164
|
+
// this same message chose one. The reset is written and broadcast like any
|
|
3165
|
+
// other change, so the picker shows the level the next spawn will use.
|
|
3166
|
+
for (const role of EFFORT_ROLES) {
|
|
3167
|
+
const modelChanged = changes.some((c) => c.startsWith(`${role.label} claude model`) || c.startsWith(`${role.label} openrouter model`));
|
|
3168
|
+
if (!modelChanged || normalizeEffort(incoming[role.effort])) {
|
|
3169
|
+
continue;
|
|
3170
|
+
}
|
|
3171
|
+
const value = defaultEffortFor(role.role, settings[role.claude], settings[role.slug]);
|
|
3172
|
+
if (value !== settings[role.effort]) {
|
|
3173
|
+
settings[role.effort] = value;
|
|
3174
|
+
changes.push(`${role.label} effort -> ${value} (default for this model)`);
|
|
3175
|
+
}
|
|
3176
|
+
}
|
|
3101
3177
|
if (changes.length === 0)
|
|
3102
3178
|
return;
|
|
3103
3179
|
atomicWriteFileSync(ctx.settingsPath, serializeAgentSettings(settings));
|
|
@@ -3311,6 +3387,7 @@ function loadRecoverableSends(deckDir, pendingPath, committedIds) {
|
|
|
3311
3387
|
// predates @-mentions wrote none at all, which is a send worth
|
|
3312
3388
|
// recovering for its words, not a malformed one.
|
|
3313
3389
|
refs: validMessageRefs(deckDir, refsOrLegacyFiles(item)),
|
|
3390
|
+
...(item.hideFromUi === true ? { hideFromUi: true } : {}),
|
|
3314
3391
|
});
|
|
3315
3392
|
}
|
|
3316
3393
|
}
|
|
@@ -3345,7 +3422,10 @@ function persistPendingSends(ctx) {
|
|
|
3345
3422
|
atomicWriteFileSync(ctx.pendingPath, JSON.stringify(ctx.state.pendingSends, null, 2) + '\n');
|
|
3346
3423
|
}
|
|
3347
3424
|
function computeQueuedSnippets(pendingSends) {
|
|
3348
|
-
return pendingSends
|
|
3425
|
+
return pendingSends
|
|
3426
|
+
.filter((p) => !p.hideFromUi)
|
|
3427
|
+
.map((p) => p.text.trim())
|
|
3428
|
+
.filter(Boolean);
|
|
3349
3429
|
}
|
|
3350
3430
|
function broadcastQueueState(ctx) {
|
|
3351
3431
|
ctx.broadcast({
|
|
@@ -3386,6 +3466,7 @@ function startRouterTurn(ctx, instruction) {
|
|
|
3386
3466
|
currentEpoch: () => ctx.state.userEpoch,
|
|
3387
3467
|
claudeModel: () => ctx.settings.routerClaudeModel,
|
|
3388
3468
|
openrouterModel: () => ctx.settings.routerOpenrouterModel,
|
|
3469
|
+
effort: () => ctx.settings.routerEffort,
|
|
3389
3470
|
canAutoRetry: () => !ctx.state.autoRetryUsed && ctx.state.pendingSends.length === 0,
|
|
3390
3471
|
onSettled: (retryable) => onRouterQueueSettled(ctx, retryable),
|
|
3391
3472
|
}, instruction);
|
|
@@ -3411,6 +3492,8 @@ function commitDrainedSends(drained, log) {
|
|
|
3411
3492
|
message.attachments = item.attachments;
|
|
3412
3493
|
if (item.refs.length > 0)
|
|
3413
3494
|
message.refs = item.refs;
|
|
3495
|
+
if (item.hideFromUi)
|
|
3496
|
+
message.hideFromUi = true;
|
|
3414
3497
|
log.add(message);
|
|
3415
3498
|
}
|
|
3416
3499
|
if (item.text.trim())
|
|
@@ -3496,7 +3579,7 @@ function safeClientMessageId(clientId) {
|
|
|
3496
3579
|
return null;
|
|
3497
3580
|
return /^[A-Za-z0-9_-]{1,32}$/.test(clientId) ? clientId : null;
|
|
3498
3581
|
}
|
|
3499
|
-
function handleQueueUserMessage(ctx, text, images, refs, clientId) {
|
|
3582
|
+
function handleQueueUserMessage(ctx, text, images, refs, clientId, hideFromUi) {
|
|
3500
3583
|
const { state } = ctx;
|
|
3501
3584
|
// Mid-run: queue (don't interrupt). It shows as a queued row in the
|
|
3502
3585
|
// composer and flushes when the current turn settles. Idle: start now.
|
|
@@ -3524,6 +3607,7 @@ function handleQueueUserMessage(ctx, text, images, refs, clientId) {
|
|
|
3524
3607
|
text,
|
|
3525
3608
|
attachments,
|
|
3526
3609
|
refs: validMessageRefs(ctx.deckDir, refs),
|
|
3610
|
+
...(hideFromUi ? { hideFromUi: true } : {}),
|
|
3527
3611
|
});
|
|
3528
3612
|
persistPendingSends(ctx);
|
|
3529
3613
|
if (state.routerRunning) {
|
|
@@ -3574,9 +3658,13 @@ function interruptRouterQueue(ctx) {
|
|
|
3574
3658
|
}
|
|
3575
3659
|
function cancelQueuedSend(ctx, index) {
|
|
3576
3660
|
const { state } = ctx;
|
|
3577
|
-
|
|
3661
|
+
const visible = state.pendingSends.filter((p) => !p.hideFromUi);
|
|
3662
|
+
if (!Number.isInteger(index) || index < 0 || index >= visible.length)
|
|
3663
|
+
return;
|
|
3664
|
+
const real = state.pendingSends.indexOf(visible[index]);
|
|
3665
|
+
if (real < 0)
|
|
3578
3666
|
return;
|
|
3579
|
-
state.pendingSends.splice(
|
|
3667
|
+
state.pendingSends.splice(real, 1);
|
|
3580
3668
|
persistPendingSends(ctx);
|
|
3581
3669
|
broadcastQueueState(ctx);
|
|
3582
3670
|
}
|
|
@@ -3608,7 +3696,7 @@ function createRouterQueue(deps) {
|
|
|
3608
3696
|
persistPendingSends(ctx);
|
|
3609
3697
|
maybeStartRouterQueueTurn(ctx);
|
|
3610
3698
|
return {
|
|
3611
|
-
handleUserMessage: (text, images, refs, clientId) => handleQueueUserMessage(ctx, text, images, refs, clientId),
|
|
3699
|
+
handleUserMessage: (text, images, refs, clientId, hideFromUi) => handleQueueUserMessage(ctx, text, images, refs, clientId, hideFromUi),
|
|
3612
3700
|
interruptRouter: () => interruptRouterQueue(ctx),
|
|
3613
3701
|
cancelQueued: (index) => cancelQueuedSend(ctx, index),
|
|
3614
3702
|
isRunning: () => ctx.state.routerRunning,
|
|
@@ -3755,6 +3843,7 @@ export function createAgentServer(opts) {
|
|
|
3755
3843
|
quickReference,
|
|
3756
3844
|
openrouterModel: () => settings.tasksOpenrouterModel,
|
|
3757
3845
|
claudeModel: () => settings.tasksClaudeModel,
|
|
3846
|
+
effort: () => settings.tasksEffort,
|
|
3758
3847
|
playtest,
|
|
3759
3848
|
// Task lifecycle stays on the board only -- log lines for it were spam.
|
|
3760
3849
|
onUpdate: (task) => broadcast({ type: 'task-update', task: asClientTask(task, opts.signPath) }),
|
|
@@ -3790,8 +3879,9 @@ export function createAgentServer(opts) {
|
|
|
3790
3879
|
log.persist();
|
|
3791
3880
|
broadcast({ type: 'message-picker', id, pickerAnswers: msg.pickerAnswers });
|
|
3792
3881
|
}
|
|
3793
|
-
if (text.trim())
|
|
3794
|
-
routerQueue.handleUserMessage(text.trim(), undefined, undefined);
|
|
3882
|
+
if (text.trim()) {
|
|
3883
|
+
routerQueue.handleUserMessage(text.trim(), undefined, undefined, undefined, true);
|
|
3884
|
+
}
|
|
3795
3885
|
}
|
|
3796
3886
|
function handleTaskAck(id, rejected) {
|
|
3797
3887
|
taskStore.acknowledge(id, rejected);
|
|
@@ -3837,7 +3927,9 @@ export function createAgentServer(opts) {
|
|
|
3837
3927
|
clients.add(socket);
|
|
3838
3928
|
const hello = {
|
|
3839
3929
|
type: 'hello',
|
|
3840
|
-
messages: messages
|
|
3930
|
+
messages: messages
|
|
3931
|
+
.filter((message) => !message.hideFromUi)
|
|
3932
|
+
.map((message) => asClientMessage(message, opts.signPath)),
|
|
3841
3933
|
tasks: taskStore.sorted().map((task) => asClientTask(task, opts.signPath)),
|
|
3842
3934
|
settings,
|
|
3843
3935
|
feeds: Object.fromEntries(taskFeeds.map),
|