@picassohq/cli 1.0.8 → 1.0.9
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/README.md +4 -0
- package/dist/build-info.json +1 -1
- package/dist/index.js +1662 -1475
- package/package.json +1 -1
- package/runtime/dsh/picasso-providers.patch.yml +49 -61
- package/runtime/dsh/picasso-runtime.cordis.yml +49 -61
- package/runtime/engine-manifest.json +6 -6
- package/runtime/packages/picasso-browser/cordis.patch.yml +4 -0
- package/runtime/packages/picasso-browser/index.js +915 -0
- package/runtime/packages/picasso-browser/package.json +29 -0
- package/runtime/packages/picasso-commands/index.js +51 -1
- package/runtime/packages/picasso-lean-context/index.js +37 -7
- package/runtime/packages/picasso-model-router/connections.js +1 -1
- package/runtime/packages/picasso-progress-reports/index.js +121 -3
- package/runtime/packages/picasso-sdk-server/browser-host.js +94 -0
- package/runtime/packages/picasso-sdk-server/index.js +23 -3
- package/runtime/plugins/picasso-browser/index.js +319 -22
- package/runtime/plugins/picasso-browser/package.json +1 -1
- package/runtime/plugins/picasso-commands/index.js +51 -1
- package/runtime/plugins/picasso-lean-context/index.js +37 -7
- package/runtime/plugins/picasso-model-router/connections.js +1 -1
- package/runtime/plugins/picasso-progress-reports/index.js +121 -3
- package/runtime/relay/main.mjs +2374 -1107
- package/runtime/relay/versions-routes.mjs +38 -36
|
@@ -148,6 +148,16 @@ function freshState() {
|
|
|
148
148
|
reportPercentSincePlan: undefined,
|
|
149
149
|
/** A plan-drift nudge is in history since the last `todo/write`. */
|
|
150
150
|
driftNudged: false,
|
|
151
|
+
/** When the last `todo/write` landed (the engine's clock), undefined before any. */
|
|
152
|
+
planWrittenAt: undefined,
|
|
153
|
+
/** Turns a person opened (not goal rounds, mail or schedules) since the last `todo/write`, the current one included. */
|
|
154
|
+
personTurnsSincePlan: 0,
|
|
155
|
+
/** A progress report was written after the last `todo/write`. */
|
|
156
|
+
reportSincePlan: false,
|
|
157
|
+
/** The current turn was opened by a person's prompt that is not a continuation ("continue", "go on", …). */
|
|
158
|
+
turnIsNewTask: false,
|
|
159
|
+
/** An earlier-task nudge is in history since the last `todo/write`. */
|
|
160
|
+
earlierTaskNudged: false,
|
|
151
161
|
};
|
|
152
162
|
}
|
|
153
163
|
|
|
@@ -156,6 +166,35 @@ function todosFrom(data) {
|
|
|
156
166
|
return list.filter(isRecord).map((todo) => ({ status: typeof todo.status === 'string' ? todo.status : 'pending' }));
|
|
157
167
|
}
|
|
158
168
|
|
|
169
|
+
/** A prompt a person typed (not a goal round, mail, a schedule or a harness reminder). */
|
|
170
|
+
export function isPersonPrompt(message) {
|
|
171
|
+
if (message?.role !== undefined && message.role !== 'user') return false;
|
|
172
|
+
const kind = message?.source?.kind;
|
|
173
|
+
return kind === undefined || kind === 'user';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** Phrases that carry on the work in hand whatever follows them ("continue where you left off, why did you stop?"). */
|
|
177
|
+
const CONTINUATION_PROMPT = /^(?:continue|keep going|keep at it|go on|go ahead|carry on|proceed|resume|pick up where|finish (?:it|up)|retry|try again)\b/iu;
|
|
178
|
+
/** Words that carry on only as the whole prompt ("go", "ok do it"): "GO. Fix ONLY the digests" is a new instruction. */
|
|
179
|
+
const BARE_CONTINUATION = /^(?:go|next|ok(?:ay)?|yes|yep|sure|do it|finish)\b/iu;
|
|
180
|
+
const BARE_CONTINUATION_MAX_WORDS = 3;
|
|
181
|
+
/** Longest prompt still read as "carry on" rather than a new task. */
|
|
182
|
+
export const CONTINUATION_MAX_CHARS = 160;
|
|
183
|
+
|
|
184
|
+
/** Whether a person's prompt continues the work in hand ("continue where you left off", "go on") instead of starting a task. */
|
|
185
|
+
export function isContinuationPrompt(text) {
|
|
186
|
+
const flat = String(text ?? '').replace(/\s+/gu, ' ').trim();
|
|
187
|
+
if (flat.length === 0 || flat.length > CONTINUATION_MAX_CHARS) return false;
|
|
188
|
+
if (CONTINUATION_PROMPT.test(flat)) return true;
|
|
189
|
+
return BARE_CONTINUATION.test(flat) && flat.split(' ').length <= BARE_CONTINUATION_MAX_WORDS;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** What a turn's opening message says about the task: whether a person opened it, and whether as a new task. */
|
|
193
|
+
function openerFacts(message) {
|
|
194
|
+
const person = isPersonPrompt(message);
|
|
195
|
+
return { person, newTask: person && !isContinuationPrompt(textOf(message)) };
|
|
196
|
+
}
|
|
197
|
+
|
|
159
198
|
/** Fold one durable session event into the timing state. */
|
|
160
199
|
export function foldEvent(state, event) {
|
|
161
200
|
if (!isRecord(event)) return state;
|
|
@@ -164,6 +203,7 @@ export function foldEvent(state, event) {
|
|
|
164
203
|
case 'turn/start':
|
|
165
204
|
state.turnStart = time;
|
|
166
205
|
state.openerSeen = false;
|
|
206
|
+
state.turnIsNewTask = false;
|
|
167
207
|
// A new turn is a new prompt (or goal round): no follow-up carries over into it.
|
|
168
208
|
state.awaitingAnswer = false;
|
|
169
209
|
state.followUpDue = false;
|
|
@@ -174,6 +214,9 @@ export function foldEvent(state, event) {
|
|
|
174
214
|
state.openerSeen = true;
|
|
175
215
|
// A goal round continues the run it belongs to; anything else (a prompt, mail, a schedule) starts one.
|
|
176
216
|
if (!isGoalRound(message) || state.runStart === undefined) state.runStart = state.turnStart ?? time;
|
|
217
|
+
const opener = openerFacts(message);
|
|
218
|
+
if (opener.person) state.personTurnsSincePlan += 1;
|
|
219
|
+
state.turnIsNewTask = opener.newTask;
|
|
177
220
|
}
|
|
178
221
|
if (message?.source?.kind === SOURCE_KIND && time !== undefined) {
|
|
179
222
|
state.lastReminder = time;
|
|
@@ -183,16 +226,22 @@ export function foldEvent(state, event) {
|
|
|
183
226
|
state.followUpDue = false;
|
|
184
227
|
}
|
|
185
228
|
if (message?.source?.kind === DRIFT_SOURCE_KIND) state.driftNudged = true;
|
|
229
|
+
if (message?.source?.kind === EARLIER_TASK_SOURCE_KIND) state.earlierTaskNudged = true;
|
|
186
230
|
break;
|
|
187
231
|
}
|
|
188
232
|
case 'todo/write':
|
|
189
233
|
state.todos = todosFrom(event.data);
|
|
190
234
|
state.reportPercentSincePlan = undefined;
|
|
191
235
|
state.driftNudged = false;
|
|
236
|
+
state.planWrittenAt = time;
|
|
237
|
+
state.personTurnsSincePlan = 0;
|
|
238
|
+
state.reportSincePlan = false;
|
|
239
|
+
state.earlierTaskNudged = false;
|
|
192
240
|
break;
|
|
193
241
|
case 'assistant/message': {
|
|
194
242
|
const report = parseProgressReport(textOf(event.data?.message));
|
|
195
243
|
if (report !== undefined && report.percent !== undefined) state.reportPercentSincePlan = report.percent;
|
|
244
|
+
if (report !== undefined) state.reportSincePlan = true;
|
|
196
245
|
if (time !== undefined && report !== undefined) {
|
|
197
246
|
state.lastReport = time;
|
|
198
247
|
if (!state.reminderPending) state.selfReporting = true;
|
|
@@ -370,7 +419,7 @@ export function renderPlanDrift(reported, todos) {
|
|
|
370
419
|
const list = Array.isArray(todos) ? todos : [];
|
|
371
420
|
const done = list.filter((todo) => todo?.status === 'completed').length;
|
|
372
421
|
const plan = Math.round(planCompletion(list));
|
|
373
|
-
return `<system-reminder>\nYour latest progress report says ${reported}% done, but your todo list shows ${plan}% (${done} of ${list.length} step${list.length === 1 ? '' : 's'} completed). Update it with todo_write so the plan matches the work,
|
|
422
|
+
return `<system-reminder>\nYour latest progress report says ${reported}% done, but your todo list shows ${plan}% (${done} of ${list.length} step${list.length === 1 ? '' : 's'} completed). Update it with todo_write so the plan matches the work; if it no longer matches what you are working on now, replace it for the current work, or clear it with todo_write and an empty list (todos: []). Then keep going.\n</system-reminder>`;
|
|
374
423
|
}
|
|
375
424
|
|
|
376
425
|
/** A frozen sourced user-role reminder carrying the plan-drift nudge. */
|
|
@@ -383,6 +432,67 @@ export function planDriftMessage(reported, todos) {
|
|
|
383
432
|
});
|
|
384
433
|
}
|
|
385
434
|
|
|
435
|
+
// ── Plan from an earlier task (Tier 2) ────────────────────────────────────────────────────────────────────────
|
|
436
|
+
//
|
|
437
|
+
// Owner 2026-11-18 (session m0-d03430f0): a 6/10 plan for the Kimi deploy (last todo_write 05:01Z) stayed in every panel
|
|
438
|
+
// through the Mythos hierarchy deploy, which the progress reports took to 100%. The person had started new tasks; the
|
|
439
|
+
// models (Fable, Gemini, DeepSeek) never touched a checklist that no longer matched their work, and nothing told them it
|
|
440
|
+
// belonged to an earlier task. So when a person starts a new task (a turn whose prompt is not a continuation) and the
|
|
441
|
+
// plan, still open, has gone untouched for more than PLAN_EARLIER_TASK_TURNS of their turns while progress reports moved
|
|
442
|
+
// on past it, that turn gets ONE sourced `<system-reminder>` at the tail: rewrite the plan for this task or clear it.
|
|
443
|
+
// Once per `todo/write`; top-level agents only; the text depends only on history (the write's time, its counts and the
|
|
444
|
+
// turn count), so identical history yields identical bytes. Tier 1 is never touched.
|
|
445
|
+
|
|
446
|
+
export const EARLIER_TASK_SOURCE_KIND = 'picasso-plan-earlier-task';
|
|
447
|
+
/** A plan untouched for MORE than this many person turns (and older than the newest report) is from an earlier task. */
|
|
448
|
+
export const PLAN_EARLIER_TASK_TURNS = 3;
|
|
449
|
+
|
|
450
|
+
const TODO_DONE = new Set(['completed', 'cancelled', 'canceled', 'done', 'skipped']);
|
|
451
|
+
const hasOpenTodos = (todos) => Array.isArray(todos) && todos.some((todo) => !TODO_DONE.has(String(todo?.status ?? 'pending')));
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* `{ writtenAt, turns }` when the earlier-task nudge is due, else undefined: an open plan, a person's new-task prompt
|
|
455
|
+
* opening this turn (`proposed` holds it on the turn's first step), more than PLAN_EARLIER_TASK_TURNS person turns since
|
|
456
|
+
* the plan's last write, a progress report since it, and no nudge yet for this write.
|
|
457
|
+
*/
|
|
458
|
+
export function planEarlierTaskDue(state, proposed = []) {
|
|
459
|
+
if (!isRecord(state) || state.earlierTaskNudged === true || !hasOpenTodos(state.todos)) return undefined;
|
|
460
|
+
let turns = state.personTurnsSincePlan;
|
|
461
|
+
let newTask = state.turnIsNewTask === true;
|
|
462
|
+
if (!state.openerSeen) {
|
|
463
|
+
const opener = (Array.isArray(proposed) ? proposed : []).find((message) => message?.role === 'user');
|
|
464
|
+
const facts = opener === undefined ? { person: false, newTask: false } : openerFacts(opener);
|
|
465
|
+
if (facts.person) turns += 1;
|
|
466
|
+
newTask = facts.newTask;
|
|
467
|
+
}
|
|
468
|
+
if (!newTask || turns <= PLAN_EARLIER_TASK_TURNS || state.reportSincePlan !== true) return undefined;
|
|
469
|
+
return { ...(state.planWrittenAt === undefined ? {} : { writtenAt: state.planWrittenAt }), turns };
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/** `2026-11-18 05:01 UTC`: UTC, so the same history gives the same bytes on every machine. */
|
|
473
|
+
function utcMinute(time) {
|
|
474
|
+
const iso = new Date(time).toISOString();
|
|
475
|
+
return `${iso.slice(0, 10)} ${iso.slice(11, 16)} UTC`;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/** The nudge text: when the plan was last written, its counts and how many turns it sat untouched. */
|
|
479
|
+
export function renderPlanEarlierTask({ writtenAt, turns } = {}, todos = []) {
|
|
480
|
+
const list = Array.isArray(todos) ? todos : [];
|
|
481
|
+
const done = list.filter((todo) => todo?.status === 'completed').length;
|
|
482
|
+
const when = Number.isFinite(writtenAt) ? `last updated ${utcMinute(writtenAt)}` : 'last updated in an earlier turn';
|
|
483
|
+
return `<system-reminder>\nYour plan is from an earlier task (${when}, ${done} of ${list.length} done, untouched for ${turns} turns while your progress reports moved on): rewrite it for this task with todo_write, or clear it with todo_write and an empty list (todos: []) if this task needs no plan.\n</system-reminder>`;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/** A frozen sourced user-role reminder carrying the earlier-task nudge. */
|
|
487
|
+
export function planEarlierTaskMessage(due, todos) {
|
|
488
|
+
return Object.freeze({
|
|
489
|
+
role: 'user',
|
|
490
|
+
content: Object.freeze([Object.freeze({ type: 'text', text: renderPlanEarlierTask(due, todos) })]),
|
|
491
|
+
source: Object.freeze({ kind: EARLIER_TASK_SOURCE_KIND, form: 'reminder' }),
|
|
492
|
+
id: randomUUID(),
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
|
|
386
496
|
export function apply(ctx, config = {}, deps = {}) {
|
|
387
497
|
const readSettings = deps.settings ?? settingsReader(config, deps.env ?? process.env);
|
|
388
498
|
const clock = deps.now ?? Date.now;
|
|
@@ -396,9 +506,17 @@ export function apply(ctx, config = {}, deps = {}) {
|
|
|
396
506
|
const session = agent?.session;
|
|
397
507
|
if (!session || typeof session.eventAt !== 'function' || isChildAgent(agent)) return decision;
|
|
398
508
|
const state = scanSession(states, session);
|
|
399
|
-
// The plan
|
|
400
|
-
const drift = decision.messages.some((message) => message?.source?.kind === DRIFT_SOURCE_KIND) ? undefined : planDriftDue(state, decision.messages);
|
|
509
|
+
// The plan nudges read only history; they are not the timed report reminder, so that setting does not gate them.
|
|
401
510
|
const extra = [];
|
|
511
|
+
const earlier = decision.messages.some((message) => message?.source?.kind === EARLIER_TASK_SOURCE_KIND) ? undefined : planEarlierTaskDue(state, decision.messages);
|
|
512
|
+
if (earlier !== undefined) {
|
|
513
|
+
// Recorded now so a step that is rejected downstream cannot send it twice before its event lands. It says more
|
|
514
|
+
// than the percent drift nudge would about this plan, so that one is spent for this write too.
|
|
515
|
+
state.earlierTaskNudged = true;
|
|
516
|
+
state.driftNudged = true;
|
|
517
|
+
extra.push(planEarlierTaskMessage(earlier, state.todos));
|
|
518
|
+
}
|
|
519
|
+
const drift = earlier !== undefined || decision.messages.some((message) => message?.source?.kind === DRIFT_SOURCE_KIND) ? undefined : planDriftDue(state, decision.messages);
|
|
402
520
|
if (drift !== undefined) {
|
|
403
521
|
// Recorded now so a step that is rejected downstream cannot send it twice before its event lands.
|
|
404
522
|
state.driftNudged = true;
|