feat(web): declare the remaining context forms on every shipped producer
Four values complete the vocabulary, so the opaque body is reached only by producers that genuinely promise no shape. `snapshot` — current state a later snapshot supersedes. system-prompt now exposes `renderContextSections()`, the named contributions `renderContextSnapshot()` already joins for the model, so the body attributes each part to the subsystem that produced it instead of re-splitting joined prose. The runtime snapshot, time-context, and tmux-context declare it. `notice` — a one-off account of what just happened, declared by tool-tasks, goal state changes, tool-goal wrap-up, plan-mode switches, and repeat-tool-guard. Its `summary` rides the COLLAPSED row: these five are the majority of shipped producers and none of them needs expanding to be read. The task summary bounds itself because its inputs are unbounded caller text. `relay` — a message another agent addressed to this one; both subagent sources declare it and the body names the sender above what it said. `recall` — material lifted from another session's log. session-reference needed no new field: its references already record retained and omitted counts and the truncation flag, which the body shows first, because recalled context is bounded on the way in. `ContextFormed` is now discriminated by `form`, so a producer cannot declare a shape without the facts that shape is presented from — a notice without its summary, or a snapshot without its sections, fails to compile. Only the two hook bridges stay opaque, by design: their content is whatever an external program printed, so no shape can be promised for it. Unknown kinds and unreadable records land there too.
This commit is contained in:
@@ -114,6 +114,26 @@ function fitWithSuffix(
|
||||
return `${retainTail(content, maxBytes - fixedBytes)}${fixed}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Bound for the durable one-line account. A notice summary rides a collapsed
|
||||
* transcript row, and both the task label and its status detail are caller
|
||||
* text with no length of their own, so the summary caps itself rather than
|
||||
* committing unbounded prose to the log.
|
||||
*/
|
||||
const SUMMARY_MAX_CHARS = 120
|
||||
|
||||
/**
|
||||
* One-line account of a settled task for the `notice` form's collapsed row.
|
||||
* @param snapshot - the settled task.
|
||||
* @returns its kind, label, and status, bounded to {@link SUMMARY_MAX_CHARS}.
|
||||
*/
|
||||
function completionSummary(snapshot: TaskSnapshot): string {
|
||||
const summary = `${snapshot.kind} ${snapshot.label} ${statusLine(snapshot)}`
|
||||
return summary.length <= SUMMARY_MAX_CHARS
|
||||
? summary
|
||||
: `${summary.slice(0, SUMMARY_MAX_CHARS - 1)}…`
|
||||
}
|
||||
|
||||
function fitCompletionNotice(snapshot: TaskSnapshot): string {
|
||||
const prefix = `background task ${snapshot.id}`
|
||||
const detail = ` (${snapshot.kind}: ${snapshot.label}) finished ${statusLine(snapshot)}`
|
||||
@@ -230,7 +250,12 @@ export function apply(ctx: Context, config: Config): void {
|
||||
type: 'text',
|
||||
text: fitCompletionNotice(snapshot),
|
||||
}],
|
||||
source: { kind: 'plugin', plugin: 'tool-tasks' },
|
||||
source: {
|
||||
kind: 'plugin',
|
||||
plugin: 'tool-tasks',
|
||||
form: 'notice',
|
||||
summary: completionSummary(snapshot),
|
||||
},
|
||||
}))
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user