@ai-ecoverse/slicc-agent 7.32.0 → 7.33.0

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/spectrum/messages.ts"],
4
- "sourcesContent": ["import type {\n AssistantMessage,\n AssistantStatus,\n ErrorAction,\n LickMessage,\n Message,\n MessagePart,\n SystemMessage,\n ToolCall,\n ToolStatus,\n Usage,\n UserMessage,\n} from '@ai-ecoverse/slicc-spectrum/ui';\nimport type { ConversationView, EntryRecord } from '@earendil-works/pi-durable';\nimport { splitUser } from '../attachments.ts';\nimport {\n ASKED_KIND,\n askedLine,\n GATED_KIND,\n type GatedCall,\n GUEST_INPUT_KIND,\n type GuestAsked,\n type GuestInput,\n type GuestOutcome,\n type GuestReviewed,\n guestText,\n REVIEWED_KIND,\n TAINTED_KIND,\n} from '../guests/attribution.ts';\nimport { withoutIntent } from '../intent/said.ts';\nimport { type Lick, parseLick } from '../licks/lick.ts';\nimport { entryLick, LICK_TOOLS, type LickDecision, lickDecisions } from '../licks/state.ts';\nimport { FROM_KIND, type From } from '../scoops/from.ts';\nimport type { SecretName } from '../secrets/names.ts';\nimport { listedLine, SECRETS_KIND } from '../secrets/view.ts';\nimport type { Delivered } from '../services.ts';\nimport { SPRINKLE_KIND } from '../sprinkles/kind.ts';\nimport { warn } from './attempt.ts';\nimport { toolTitle } from './tool-title.ts';\n\ntype Json = Record<string, unknown>;\n\ninterface Block {\n type: string;\n text?: string;\n thinking?: string;\n id?: string;\n name?: string;\n arguments?: Json;\n}\n\ninterface ModelMessage {\n role: string;\n content?: string | Block[];\n timestamp?: number;\n stopReason?: string;\n errorMessage?: string;\n provider?: string;\n model?: string;\n usage?: {\n input?: number;\n output?: number;\n cacheRead?: number;\n cacheWrite?: number;\n cost?: { total?: number };\n };\n toolCallId?: string;\n isError?: boolean;\n details?: { patch?: unknown };\n}\n\ninterface Slot {\n callId: string;\n status: string;\n output?: string;\n}\n\ninterface Live {\n run?: unknown;\n generation?: { message?: ModelMessage; retry?: { at: number; error: string } };\n tools?: Slot[];\n compactions?: { taskId: number; reason: string }[];\n}\n\nexport function textOf(content: ModelMessage['content']): string {\n if (typeof content === 'string') return content;\n return (content ?? []).map((block) => (block.type === 'text' ? (block.text ?? '') : '')).join('');\n}\n\nconst paths = (args: Json | undefined): string[] =>\n typeof args?.path === 'string' ? [args.path] : [];\n\ninterface Replacement {\n oldText?: string;\n newText?: string;\n}\n\nconst GAP = '\u2026';\n\nfunction seconds(value: unknown): string | undefined {\n return typeof value === 'number' ? `timeout ${value}s` : undefined;\n}\n\nfunction lines(args: Json): string | undefined {\n const { offset, limit } = args as { offset?: number; limit?: number };\n if (typeof offset === 'number' && typeof limit === 'number')\n return `lines ${offset}\u2013${offset + limit - 1}`;\n if (typeof offset === 'number') return `from line ${offset}`;\n return typeof limit === 'number' ? `first ${limit} lines` : undefined;\n}\n\nfunction edits(args: Json): ToolCall['diff'] {\n const list = Array.isArray(args.edits) ? (args.edits as Replacement[]) : [];\n if (list.length === 0) return undefined;\n return {\n before: list.map((edit) => edit.oldText ?? '').join(`\\n${GAP}\\n`),\n after: list.map((edit) => edit.newText ?? '').join(`\\n${GAP}\\n`),\n };\n}\n\nexport function fromPatch(patch: string): ToolCall['diff'] {\n const before: string[] = [];\n const after: string[] = [];\n let hunks = 0;\n for (const line of patch.split('\\n')) {\n if (line.startsWith('@@')) {\n if (hunks++ > 0) {\n before.push(GAP);\n after.push(GAP);\n }\n continue;\n }\n if (hunks === 0 || line === '' || line.startsWith('\\\\')) continue;\n const text = line.slice(1);\n if (line.startsWith('-')) before.push(text);\n else if (line.startsWith('+')) after.push(text);\n else {\n before.push(text);\n after.push(text);\n }\n }\n return hunks ? { before: before.join('\\n'), after: after.join('\\n') } : undefined;\n}\n\nfunction shape(name: string, args: Json): Pick<ToolCall, 'input' | 'meta' | 'diff'> {\n const path = typeof args.path === 'string' ? args.path : '';\n const meta = name === 'bash' ? seconds(args.timeout) : name === 'read' ? lines(args) : undefined;\n const base = meta ? { meta } : {};\n if (name === 'bash' && typeof args.command === 'string') return { input: args.command, ...base };\n if (name === 'read' || name === 'write') return { input: path, ...base };\n if (name === 'edit') {\n const diff = edits(args);\n return { input: path, ...(diff ? { diff } : {}) };\n }\n return { input: JSON.stringify(withoutIntent(name, args), null, 2) };\n}\n\ntype Trust = (callId: string) => boolean;\n\nconst NEVER: Trust = () => false;\n\nfunction toolCall(block: Block, trust: Trust): ToolCall {\n const args = block.arguments ?? {};\n const name = block.name ?? 'tool';\n const id = block.id ?? '';\n return {\n id,\n name,\n title: toolTitle(name, args, trust(id)),\n ...shape(name, args),\n output: '',\n status: 'running',\n paths: paths(block.arguments),\n };\n}\n\nfunction part(block: Block, trust: Trust): MessagePart | undefined {\n if (block.type === 'text') return { type: 'text', text: block.text ?? '' };\n if (block.type === 'thinking') return { type: 'thinking', text: block.thinking ?? '' };\n if (block.type === 'toolCall') return { type: 'tool', tool: toolCall(block, trust) };\n return undefined;\n}\n\nfunction usage(message: ModelMessage): Usage | undefined {\n const used = message.usage;\n if (!used) return undefined;\n return {\n input: used.input ?? 0,\n output: used.output ?? 0,\n cost: used.cost?.total ?? 0,\n cacheRead: used.cacheRead ?? 0,\n cacheWrite: used.cacheWrite ?? 0,\n };\n}\n\nconst statuses: Record<string, AssistantStatus> = { error: 'error', aborted: 'stopped' };\n\nconst credentials =\n /security token|unrecognizedclient|not authori[sz]ed|unauthori[sz]ed|forbidden|\\b40[13]\\b|api key|credential|bearer/i;\nconst models = /model/i;\nconst unavailable =\n /access|invalid|not found|identifier|unsupported|not supported|isn['\u2019]t supported|not available|isn['\u2019]t available/i;\n\nconst providerNames: Record<string, string> = { 'amazon-bedrock': 'Bedrock', adobe: 'Adobe' };\nconst filtered =\n /Provider (?:stopped with|finish_reason): (?:content_filter(?:ed)?|guardrail_intervened|sensitive)|content[_ ]filter(?:ed|ing)?\\b|guardrail[_ ]intervened/i;\nconst refused =\n /refused to complete the request|Provider (?:stopped with|finish_reason): refusal|\\bstop_?reason\\W+refusal\\b/i;\nconst unconnected = /no api key|not configured|no credentials/i;\nconst missing = /missing/i;\nconst adobeAuth =\n /\\b401\\b|authenticat|unauthori[sz]ed|expired|invalid[_ ]?(?:token|credentials?|api[_ ]key)|token verification/i;\n\nfunction proxyRefusal(error: string): { message: string; detail: string } {\n try {\n const body = JSON.parse(error.match(/\\{.*\\}/s)?.[0] ?? '') as {\n error?: { type?: unknown; message?: unknown };\n };\n const { type, message } = body.error ?? {};\n const status = error.match(/^\\s*(\\d{3})\\b/)?.[1];\n return {\n message: typeof message === 'string' ? message : error,\n detail: typeof type === 'string' ? [status, type].filter(Boolean).join(' ') : error,\n };\n } catch {\n return { message: error, detail: error };\n }\n}\n\nexport const CONNECT_IT = 'Connect it in Settings \u203A Accounts.';\nexport const LOG_IN_AGAIN = 'Log in again to continue.';\n\nconst logged = new Set<string>();\n\nfunction logOnce(error: string): void {\n if (logged.has(error)) return;\n logged.add(error);\n warn(`slicc-agent: the Adobe session expired: ${error}`);\n}\n\nexport function providerName(provider: string | undefined, fallback = 'The provider'): string {\n return providerNames[provider ?? ''] ?? fallback;\n}\n\nexport function errorPart(error: string, provider?: string): MessagePart {\n const action = errorAction(error);\n if (action === 'drop-turn') {\n return {\n type: 'error',\n message: filtered.test(error)\n ? \"The model's content filter stopped this reply.\"\n : 'The model refused to answer this turn.',\n detail: error,\n action,\n };\n }\n const name = providerName(provider);\n const account = provider ? { account: provider } : {};\n if (unconnected.test(error))\n return {\n type: 'error',\n message: `${name} isn't connected.`,\n detail: CONNECT_IT,\n action: 'settings',\n ...account,\n };\n if (action === 'settings' && provider === 'adobe') {\n if (!adobeAuth.test(error)) return { type: 'error', ...proxyRefusal(error), action: 'retry' };\n logOnce(error);\n return {\n type: 'error',\n message: 'Your Adobe session has expired.',\n detail: LOG_IN_AGAIN,\n action: 'login',\n ...account,\n };\n }\n if (action === 'settings') {\n const lead = missing.test(error)\n ? `${name} needs an API key.`\n : `${name} rejected the API key.`;\n return { type: 'error', message: lead, detail: error, action, ...account };\n }\n return action === 'change-model'\n ? {\n type: 'error',\n message: \"This model isn't available with the current account.\",\n detail: error,\n action,\n }\n : { type: 'error', message: error, action };\n}\n\nexport function errorAction(message: string): ErrorAction {\n if (filtered.test(message) || refused.test(message)) return 'drop-turn';\n if (credentials.test(message)) return 'settings';\n if (models.test(message) && unavailable.test(message)) return 'change-model';\n return 'retry';\n}\n\nfunction sprinkleMessage(id: string, entry: EntryRecord): AssistantMessage {\n const data = (entry.data ?? {}) as { sprinkle?: unknown; at?: unknown };\n return {\n id,\n role: 'assistant',\n parts: [{ type: 'sprinkle', sprinkle: String(data.sprinkle ?? '') }],\n status: 'done',\n createdAt: typeof data.at === 'number' ? data.at : 0,\n };\n}\n\nexport function assistant(\n id: string,\n message: ModelMessage,\n status?: AssistantStatus,\n trust: Trust = NEVER\n): AssistantMessage {\n const blocks = Array.isArray(message.content) ? message.content : [];\n const parts = blocks\n .map((block) => part(block, trust))\n .filter((item): item is MessagePart => item !== undefined);\n if (message.errorMessage) parts.push(errorPart(message.errorMessage, message.provider));\n const used = usage(message);\n return {\n id,\n role: 'assistant',\n parts,\n status: status ?? statuses[message.stopReason ?? ''] ?? 'done',\n createdAt: message.timestamp ?? 0,\n ...(message.provider && message.model ? { model: `${message.provider}/${message.model}` } : {}),\n ...(used ? { usage: used } : {}),\n };\n}\n\nfunction user(\n id: string,\n message: ModelMessage,\n delivered: Delivered | undefined,\n from: From | undefined\n): UserMessage {\n return {\n id,\n role: 'user',\n ...shownUser(message.content, `ref:${id.slice(1)}:0`),\n createdAt: message.timestamp ?? 0,\n ...(delivered ? { delivered } : {}),\n ...(from ? { from: from.from } : {}),\n ...(from?.agent ? { origin: 'agent' as const } : {}),\n };\n}\n\nfunction guestUser(\n id: string,\n message: ModelMessage,\n delivered: Delivered | undefined,\n data: unknown\n): UserMessage {\n const input = data as Partial<GuestInput> | undefined;\n const name = String(input?.name ?? '');\n const shown = shownUser(message.content, `ref:${id.slice(1)}:0`);\n return {\n id,\n role: 'user',\n ...shown,\n text: guestText(shown.text, name),\n createdAt: message.timestamp ?? 0,\n ...(delivered ? { delivered } : {}),\n from: name,\n origin: 'guest',\n ...(typeof input?.seat === 'string' ? { seat: input.seat } : {}),\n };\n}\n\nexport function origins(entries: readonly EntryRecord[]): Map<number, From> {\n const out = new Map<number, From>();\n for (const entry of entries)\n if (entry.kind === FROM_KIND) {\n const note = entry.data as From;\n out.set(note.entry, note);\n }\n return out;\n}\n\nexport function shownChannel(channel: Lick['channel']): LickMessage['channel'] {\n return channel === 'cone-message' ? 'bash' : channel;\n}\n\nfunction lickMessage(\n id: string,\n entry: EntryRecord,\n decisions: ReadonlyMap<string, LickDecision>\n): LickMessage | undefined {\n const lick = entryLick(entry);\n if (!lick) return undefined;\n const state = lick.actions?.length ? (decisions.get(lick.id) ?? 'pending') : undefined;\n return {\n id,\n role: 'lick',\n channel: shownChannel(lick.channel),\n title: lick.title,\n text: lick.text,\n createdAt: lick.at,\n ...(lick.body ? { body: lick.body } : {}),\n ...(lick.count > 1 ? { count: lick.count } : {}),\n ...(state ? { state } : {}),\n ...(lick.severity ? { severity: lick.severity } : {}),\n ...(lick.summary ? { summary: lick.summary } : {}),\n ...(lick.report ? { report: lick.report } : {}),\n ...(lick.channel === 'sudo-run' && lick.source ? { approval: lick.source } : {}),\n };\n}\n\nfunction withoutLickTools(message: AssistantMessage): AssistantMessage {\n const parts = message.parts.filter((item) => item.type !== 'tool' || !LICK_TOOLS[item.tool.name]);\n return parts.length === message.parts.length ? message : { ...message, parts };\n}\n\nfunction system(id: string, entry: EntryRecord, text: string): SystemMessage {\n const reason = (entry.data as Json | undefined)?.reason as SystemMessage['trigger'] | undefined;\n return {\n id,\n role: 'system',\n kind: 'compaction',\n text,\n createdAt: 0,\n state: 'summarized',\n ...(reason ? { trigger: reason } : {}),\n };\n}\n\nfunction tools(messages: Message[]): Map<string, ToolCall> {\n const found = new Map<string, ToolCall>();\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const item of message.parts) if (item.type === 'tool') found.set(item.tool.id, item.tool);\n }\n return found;\n}\n\ninterface Diagnostic {\n severity: string;\n message: string;\n}\n\ninterface Note {\n severity: 'error' | 'warn' | 'info';\n text: string;\n}\n\ntype Card = ToolCall & { notes?: Note[] };\n\nconst RANK: Note['severity'][] = ['error', 'warn', 'info'];\n\nconst LINE = /^\\[(error|warn|info)\\] (.*)$/;\n\nfunction rendered(diagnostics: readonly Diagnostic[]): string {\n return `<harness>\\n${diagnostics.map((item) => `[${item.severity}] ${item.message}`).join('\\n')}\\n</harness>`;\n}\n\nfunction parsed(text: string): Diagnostic[] | undefined {\n const body = /^<harness>\\n([\\s\\S]*)\\n<\\/harness>$/.exec(text)?.[1];\n if (body === undefined) return undefined;\n const found = body.split('\\n').map((line) => LINE.exec(line));\n if (!found.every((match): match is RegExpExecArray => match !== null)) return undefined;\n return found.map(([, severity, message]) => ({ severity, message }) as Diagnostic);\n}\n\nfunction harness(\n content: ModelMessage['content'],\n data: unknown\n): { content: ModelMessage['content']; diagnostics: Diagnostic[] } {\n const last = Array.isArray(content) ? content.at(-1) : undefined;\n const stored = (data as { diagnostics?: unknown } | undefined)?.diagnostics;\n const listed = Array.isArray(stored) ? (stored as Diagnostic[]) : parsed(last?.text ?? '');\n if (!listed?.length || last?.type !== 'text' || last.text !== rendered(listed))\n return { content, diagnostics: [] };\n return { content: (content as Block[]).slice(0, -1), diagnostics: listed };\n}\n\nconst count = (value: string | undefined): string => Number(value).toLocaleString('en');\n\nconst ends: Record<string, string> = { end: ' from the start', beginning: ' from the end' };\n\nconst phrasings: [RegExp, (match: RegExpExecArray) => string][] = [\n [/^Command exited with code (-?\\d+)$/, (match) => `Exited with code ${match[1]}`],\n [/^Command timed out after (.+)$/, (match) => `Timed out after ${match[1]}`],\n [/^Command aborted$/, () => 'Aborted'],\n [/^Full output: (.+)$/, (match) => `Full output in ${match[1]}`],\n [\n /^Output truncated(?: to its (beginning|end))?: (\\d+) lines, (\\d+) bytes dropped$/,\n (match) =>\n `Output truncated: ${count(match[2])} lines and ${count(match[3])} bytes dropped${ends[match[1] ?? ''] ?? ''}`,\n ],\n];\n\nfunction phrased(message: string): string {\n const line = message\n .replace(/\\n[\\s\\S]*$/, '')\n .trim()\n .replace(/\\.$/, '');\n for (const [pattern, phrase] of phrasings) {\n const match = pattern.exec(line);\n if (match) return phrase(match);\n }\n return line;\n}\n\nfunction note(diagnostic: Diagnostic): Note {\n return { severity: diagnostic.severity as Note['severity'], text: phrased(diagnostic.message) };\n}\n\nfunction settle(calls: Map<string, ToolCall>, result: ModelMessage, data?: unknown): void {\n const call = calls.get(result.toolCallId ?? '') as Card | undefined;\n if (!call) return;\n const split = harness(result.content, data);\n call.output = textOf(split.content);\n if (split.diagnostics.length)\n call.notes = split.diagnostics\n .map(note)\n .sort((a, b) => RANK.indexOf(a.severity) - RANK.indexOf(b.severity));\n call.status = result.isError ? 'error' : 'done';\n const image = Array.isArray(result.content)\n ? (result.content as { type: string; data?: string; mimeType?: string }[]).find(\n (part) => part.type === 'image' && part.data && part.mimeType\n )\n : undefined;\n if (image) call.image = `data:${image.mimeType};base64,${image.data}`;\n const patch = result.details?.patch;\n const diff = typeof patch === 'string' ? fromPatch(patch) : undefined;\n if (diff) call.diff = diff;\n else if (result.isError) delete call.diff;\n}\n\nfunction rewound(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as { stopped?: string[]; restored?: string[]; files?: boolean };\n const notes = [\n 'Its prompt is back in the composer.',\n ...(data.stopped?.length\n ? [`Stopped ${data.stopped.map((name) => `scoop ${name}`).join(', ')}.`]\n : []),\n ...(data.restored?.length\n ? [`Restored ${data.restored.map((name) => `scoop ${name}`).join(', ')}.`]\n : []),\n ...(data.files ? ['Changed files stay; use Changes or git to revert them.'] : []),\n ];\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: 'Rewound 1 turn',\n text: notes.join(' '),\n createdAt: 0,\n };\n}\n\nfunction thawed(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as { name?: string; kind?: string; v6?: boolean };\n const what = data.v6 ? 'SLICC 6' : data.kind === 'agent' ? 'agent run' : 'scoop';\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: `Thawed from ${what} ${data.name ?? ''}`.trim(),\n text: textOf(entry.model?.[0]?.content ?? ''),\n createdAt: entry.model?.[0]?.timestamp ?? 0,\n };\n}\n\nexport function reviewed(entries: readonly EntryRecord[]): Map<string, GuestOutcome> {\n const out = new Map<string, GuestOutcome>();\n for (const entry of entries) {\n if (entry.kind !== REVIEWED_KIND) continue;\n const data = (entry.data ?? {}) as Partial<GuestReviewed>;\n if (typeof data.review === 'string' && data.outcome) out.set(data.review, data.outcome);\n }\n return out;\n}\n\nfunction asked(\n id: string,\n entry: EntryRecord,\n outcomes: ReadonlyMap<string, GuestOutcome>\n): SystemMessage {\n const data = (entry.data ?? {}) as Partial<GuestAsked>;\n return {\n id,\n role: 'system',\n kind: 'notice',\n text: askedLine(\n String(data.name ?? ''),\n String(data.text ?? ''),\n outcomes.get(String(data.review))\n ),\n createdAt: typeof data.at === 'number' ? data.at : 0,\n };\n}\n\nfunction secrets(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as {\n names?: SecretName[];\n error?: string | null;\n exposed?: string[];\n };\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: data.error ? 'Secrets unavailable' : 'Secrets listed',\n text: listedLine({\n names: data.names ?? [],\n error: data.error ?? null,\n exposed: data.exposed ?? [],\n }),\n createdAt: entry.model?.[0]?.timestamp ?? 0,\n };\n}\n\nconst V6_KINDS: Record<string, string> = {\n user: 'pi.user',\n assistant: 'pi.assistant',\n toolResult: 'pi.tool-result',\n};\n\nfunction entryMessage(\n entry: EntryRecord,\n out: Message[],\n calls: Map<string, ToolCall>,\n delivered: Delivered | undefined,\n notes: {\n decisions: ReadonlyMap<string, LickDecision>;\n origins: ReadonlyMap<number, From>;\n outcomes: ReadonlyMap<string, GuestOutcome>;\n trust: { tainted: boolean; intents: boolean; gated: ReadonlySet<string> };\n }\n): void {\n const id = `e${entry.id}`;\n const model = entry.model?.[0] as ModelMessage | undefined;\n if (entry.kind === 'slicc.v6' && model) {\n const kind = V6_KINDS[model.role as string];\n if (kind) entryMessage({ ...entry, kind }, out, calls, delivered, notes);\n return;\n }\n if (entry.kind === TAINTED_KIND) notes.trust.tainted = true;\n if (entry.kind === 'slicc.rewound') out.push(rewound(id, entry));\n if (entry.kind === 'slicc.thawed') out.push(thawed(id, entry));\n else if (entry.kind === SECRETS_KIND) out.push(secrets(id, entry));\n else if (entry.kind === ASKED_KIND) out.push(asked(id, entry, notes.outcomes));\n else if (entry.kind === SPRINKLE_KIND) out.push(sprinkleMessage(id, entry));\n else if (entry.kind === 'pi.user' && model)\n out.push(\n lickMessage(id, entry, notes.decisions) ??\n user(id, model, delivered, notes.origins.get(entry.id))\n );\n else if (entry.kind === GUEST_INPUT_KIND && model)\n out.push(guestUser(id, model, delivered, entry.data));\n else if (entry.kind === 'pi.assistant' && model) {\n const message = assistant(id, model, undefined, trusted(notes.trust));\n notes.trust.tainted = false;\n out.push(withoutLickTools(message));\n for (const [key, value] of tools([message])) calls.set(key, value);\n } else if (entry.kind === 'pi.tool-result' && model) settle(calls, model, entry.data);\n else if (entry.kind === 'pi.compaction') out.push(system(id, entry, textOf(model?.content)));\n}\n\nconst slotStatus: Record<string, ToolStatus> = {\n pending: 'running',\n running: 'running',\n done: 'done',\n};\n\nfunction trusted(trust: { tainted: boolean; intents: boolean; gated: ReadonlySet<string> }) {\n if (!trust.intents || trust.tainted) return NEVER;\n return (callId: string) => !trust.gated.has(callId);\n}\n\nfunction gatedCalls(entries: readonly EntryRecord[]): Set<string> {\n const found = new Set<string>();\n for (const entry of entries)\n if (entry.kind === GATED_KIND) found.add(String((entry.data as Partial<GatedCall>)?.callId));\n return found;\n}\n\nfunction live(\n view: ConversationView,\n out: Message[],\n calls: Map<string, ToolCall>,\n trust: Trust\n): void {\n const state = view.docs['pi.live'] as Live | undefined;\n for (const slot of state?.tools ?? []) {\n const call = calls.get(slot.callId);\n if (call && call.status === 'running') {\n call.status = slotStatus[slot.status] ?? 'running';\n call.output = slot.output ?? call.output;\n }\n }\n const partial = state?.generation?.message;\n if (partial) out.push(assistant('live', partial, 'streaming', trust));\n for (const compaction of state?.compactions ?? []) {\n out.push({\n id: `compaction-${compaction.taskId}`,\n role: 'system',\n kind: 'compaction',\n text: '',\n createdAt: 0,\n state: 'summarizing',\n trigger: compaction.reason as SystemMessage['trigger'],\n });\n }\n const retry = state?.generation?.retry;\n if (retry)\n out.push({\n id: 'retry',\n role: 'system',\n kind: 'notice',\n text: retry.error,\n createdAt: retry.at,\n });\n}\n\nexport function toMessages(\n view: ConversationView | undefined,\n deliveries: Readonly<Record<string, Delivered>> = {},\n intents = false\n): Message[] {\n const out: Message[] = [];\n if (!view) return out;\n const calls = new Map<string, ToolCall>();\n const notes = {\n decisions: lickDecisions(view.entries),\n origins: origins(view.entries),\n outcomes: reviewed(view.entries),\n trust: { tainted: view.before !== undefined, intents, gated: gatedCalls(view.entries) },\n };\n let previous: EntryRecord | undefined;\n for (const entry of view.entries) {\n const steered = previous?.kind === 'pi.tool-result' ? 'steer' : undefined;\n entryMessage(entry, out, calls, deliveries[String(entry.id)] ?? steered, notes);\n previous = entry;\n }\n live(view, out, calls, trusted(notes.trust));\n return out;\n}\n\nfunction shownUser(\n content: ModelMessage['content'],\n prefix?: string\n): Pick<UserMessage, 'text' | 'attachments'> {\n const { text, attachments } = splitUser(content, prefix);\n return attachments.length ? { text, attachments } : { text };\n}\n\nexport function isBusy(view: ConversationView | undefined): boolean {\n return Boolean((view?.docs['pi.live'] as Live | undefined)?.run);\n}\n\nexport function queued(\n view: ConversationView | undefined,\n at: (id: string) => number = () => 0\n): UserMessage[] {\n const items = ((view?.docs['pi.inbox'] as { items?: Json[] } | undefined)?.items ?? []) as {\n id: number;\n mode: string;\n content?: ModelMessage['content'];\n entry?: { kind?: string; data?: Partial<GuestInput> };\n }[];\n return items\n .filter((item) => item.mode !== 'write' && !parseLick(textOf(item.content)))\n .map((item) => {\n const shown = shownUser(item.content);\n const data = item.entry?.data;\n const guest = item.entry?.kind === GUEST_INPUT_KIND ? String(data?.name ?? '') : null;\n const seat = typeof data?.seat === 'string' ? { seat: data.seat } : {};\n return {\n id: `q${item.id}`,\n role: 'user' as const,\n ...shown,\n ...(guest === null\n ? {}\n : {\n text: guestText(shown.text, guest),\n from: guest,\n origin: 'guest' as const,\n ...seat,\n }),\n createdAt: at(`q${item.id}`),\n queued: true,\n mode: item.mode === 'steer' ? 'steer' : 'queue',\n };\n });\n}\n"],
5
- "mappings": "AAcA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAKA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAC9B,SAAoB,iBAAiB;AACrC,SAAS,WAAW,YAA+B,qBAAqB;AACxE,SAAS,iBAA4B;AAErC,SAAS,YAAY,oBAAoB;AAEzC,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AACrB,SAAS,iBAAiB;AA8CnB,SAAS,OAAO,SAA0C;AAC/D,MAAI,OAAO,YAAY,SAAU,QAAO;AACxC,UAAQ,WAAW,CAAC,GAAG,IAAI,CAAC,UAAW,MAAM,SAAS,SAAU,MAAM,QAAQ,KAAM,EAAG,EAAE,KAAK,EAAE;AAClG;AAEA,MAAM,QAAQ,CAAC,SACb,OAAO,MAAM,SAAS,WAAW,CAAC,KAAK,IAAI,IAAI,CAAC;AAOlD,MAAM,MAAM;AAEZ,SAAS,QAAQ,OAAoC;AACnD,SAAO,OAAO,UAAU,WAAW,WAAW,KAAK,MAAM;AAC3D;AAEA,SAAS,MAAM,MAAgC;AAC7C,QAAM,EAAE,QAAQ,MAAM,IAAI;AAC1B,MAAI,OAAO,WAAW,Y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AAU,MAAM,MAAM,KAAK;AAAA,QACjC,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,GAAG;AAAA,MACL;AAAA,MACJ,WAAW,GAAG,IAAI,KAAK,EAAE,EAAE;AAAA,MAC3B,QAAQ;AAAA,MACR,MAAM,KAAK,SAAS,UAAU,UAAU;AAAA,IAC1C;AAAA,EACF,CAAC;AACL;",
6
- "names": ["note", "part"]
4
+ "sourcesContent": ["import type {\n AssistantMessage,\n AssistantStatus,\n ErrorAction,\n LickMessage,\n Message,\n MessagePart,\n SystemMessage,\n ToolCall,\n ToolStatus,\n Usage,\n UserMessage,\n} from '@ai-ecoverse/slicc-spectrum/ui';\nimport type { ConversationView, EntryRecord } from '@earendil-works/pi-durable';\nimport { splitUser } from '../attachments.ts';\nimport {\n ASKED_KIND,\n askedLine,\n GATED_KIND,\n type GatedCall,\n GUEST_INPUT_KIND,\n type GuestAsked,\n type GuestInput,\n type GuestOutcome,\n type GuestReviewed,\n guestText,\n REVIEWED_KIND,\n TAINTED_KIND,\n} from '../guests/attribution.ts';\nimport { intentOf, withoutIntent } from '../intent/said.ts';\nimport type { Ran } from '../kernel/trace.ts';\nimport { type Lick, parseLick } from '../licks/lick.ts';\nimport { entryLick, LICK_TOOLS, type LickDecision, lickDecisions } from '../licks/state.ts';\nimport { ranFailures, ranMeta, ranOf, ranTitle, saidIntent } from '../ran/shown.ts';\nimport { FROM_KIND, type From } from '../scoops/from.ts';\nimport type { SecretName } from '../secrets/names.ts';\nimport { listedLine, SECRETS_KIND } from '../secrets/view.ts';\nimport type { Delivered } from '../services.ts';\nimport { SPRINKLE_KIND } from '../sprinkles/kind.ts';\nimport { warn } from './attempt.ts';\nimport { shownTitle, toolTitle } from './tool-title.ts';\n\ntype Json = Record<string, unknown>;\n\ninterface Block {\n type: string;\n text?: string;\n thinking?: string;\n id?: string;\n name?: string;\n arguments?: Json;\n}\n\ninterface ModelMessage {\n role: string;\n content?: string | Block[];\n timestamp?: number;\n stopReason?: string;\n errorMessage?: string;\n provider?: string;\n model?: string;\n usage?: {\n input?: number;\n output?: number;\n cacheRead?: number;\n cacheWrite?: number;\n cost?: { total?: number };\n };\n toolCallId?: string;\n isError?: boolean;\n details?: { patch?: unknown; ran?: unknown };\n}\n\ninterface Slot {\n callId: string;\n status: string;\n output?: string;\n}\n\ninterface Live {\n run?: unknown;\n generation?: { message?: ModelMessage; retry?: { at: number; error: string } };\n tools?: Slot[];\n compactions?: { taskId: number; reason: string }[];\n}\n\nexport function textOf(content: ModelMessage['content']): string {\n if (typeof content === 'string') return content;\n return (content ?? []).map((block) => (block.type === 'text' ? (block.text ?? '') : '')).join('');\n}\n\nconst paths = (args: Json | undefined): string[] =>\n typeof args?.path === 'string' ? [args.path] : [];\n\ninterface Replacement {\n oldText?: string;\n newText?: string;\n}\n\nconst GAP = '\u2026';\n\nfunction seconds(value: unknown): string | undefined {\n return typeof value === 'number' ? `timeout ${value}s` : undefined;\n}\n\nfunction lines(args: Json): string | undefined {\n const { offset, limit } = args as { offset?: number; limit?: number };\n if (typeof offset === 'number' && typeof limit === 'number')\n return `lines ${offset}\u2013${offset + limit - 1}`;\n if (typeof offset === 'number') return `from line ${offset}`;\n return typeof limit === 'number' ? `first ${limit} lines` : undefined;\n}\n\nfunction edits(args: Json): ToolCall['diff'] {\n const list = Array.isArray(args.edits) ? (args.edits as Replacement[]) : [];\n if (list.length === 0) return undefined;\n return {\n before: list.map((edit) => edit.oldText ?? '').join(`\\n${GAP}\\n`),\n after: list.map((edit) => edit.newText ?? '').join(`\\n${GAP}\\n`),\n };\n}\n\nexport function fromPatch(patch: string): ToolCall['diff'] {\n const before: string[] = [];\n const after: string[] = [];\n let hunks = 0;\n for (const line of patch.split('\\n')) {\n if (line.startsWith('@@')) {\n if (hunks++ > 0) {\n before.push(GAP);\n after.push(GAP);\n }\n continue;\n }\n if (hunks === 0 || line === '' || line.startsWith('\\\\')) continue;\n const text = line.slice(1);\n if (line.startsWith('-')) before.push(text);\n else if (line.startsWith('+')) after.push(text);\n else {\n before.push(text);\n after.push(text);\n }\n }\n return hunks ? { before: before.join('\\n'), after: after.join('\\n') } : undefined;\n}\n\nfunction shape(name: string, args: Json): Pick<ToolCall, 'input' | 'meta' | 'diff'> {\n const path = typeof args.path === 'string' ? args.path : '';\n const meta = name === 'bash' ? seconds(args.timeout) : name === 'read' ? lines(args) : undefined;\n const base = meta ? { meta } : {};\n if (name === 'bash' && typeof args.command === 'string') return { input: args.command, ...base };\n if (name === 'read' || name === 'write') return { input: path, ...base };\n if (name === 'edit') {\n const diff = edits(args);\n return { input: path, ...(diff ? { diff } : {}) };\n }\n return { input: JSON.stringify(withoutIntent(name, args), null, 2) };\n}\n\ntype Trust = (callId: string) => boolean;\n\nconst NEVER: Trust = () => false;\n\nfunction toolCall(block: Block, trust: Trust): ToolCall {\n const args = block.arguments ?? {};\n const name = block.name ?? 'tool';\n const id = block.id ?? '';\n return {\n id,\n name,\n title: toolTitle(name, args, trust(id)),\n ...shape(name, args),\n output: '',\n status: 'running',\n paths: paths(block.arguments),\n };\n}\n\nfunction part(block: Block, trust: Trust): MessagePart | undefined {\n if (block.type === 'text') return { type: 'text', text: block.text ?? '' };\n if (block.type === 'thinking') return { type: 'thinking', text: block.thinking ?? '' };\n if (block.type === 'toolCall') return { type: 'tool', tool: toolCall(block, trust) };\n return undefined;\n}\n\nfunction usage(message: ModelMessage): Usage | undefined {\n const used = message.usage;\n if (!used) return undefined;\n return {\n input: used.input ?? 0,\n output: used.output ?? 0,\n cost: used.cost?.total ?? 0,\n cacheRead: used.cacheRead ?? 0,\n cacheWrite: used.cacheWrite ?? 0,\n };\n}\n\nconst statuses: Record<string, AssistantStatus> = { error: 'error', aborted: 'stopped' };\n\nconst credentials =\n /security token|unrecognizedclient|not authori[sz]ed|unauthori[sz]ed|forbidden|\\b40[13]\\b|api key|credential|bearer/i;\nconst models = /model/i;\nconst unavailable =\n /access|invalid|not found|identifier|unsupported|not supported|isn['\u2019]t supported|not available|isn['\u2019]t available/i;\n\nconst providerNames: Record<string, string> = { 'amazon-bedrock': 'Bedrock', adobe: 'Adobe' };\nconst filtered =\n /Provider (?:stopped with|finish_reason): (?:content_filter(?:ed)?|guardrail_intervened|sensitive)|content[_ ]filter(?:ed|ing)?\\b|guardrail[_ ]intervened/i;\nconst refused =\n /refused to complete the request|Provider (?:stopped with|finish_reason): refusal|\\bstop_?reason\\W+refusal\\b/i;\nconst unconnected = /no api key|not configured|no credentials/i;\nconst missing = /missing/i;\nconst adobeAuth =\n /\\b401\\b|authenticat|unauthori[sz]ed|expired|invalid[_ ]?(?:token|credentials?|api[_ ]key)|token verification/i;\n\nfunction proxyRefusal(error: string): { message: string; detail: string } {\n try {\n const body = JSON.parse(error.match(/\\{.*\\}/s)?.[0] ?? '') as {\n error?: { type?: unknown; message?: unknown };\n };\n const { type, message } = body.error ?? {};\n const status = error.match(/^\\s*(\\d{3})\\b/)?.[1];\n return {\n message: typeof message === 'string' ? message : error,\n detail: typeof type === 'string' ? [status, type].filter(Boolean).join(' ') : error,\n };\n } catch {\n return { message: error, detail: error };\n }\n}\n\nexport const CONNECT_IT = 'Connect it in Settings \u203A Accounts.';\nexport const LOG_IN_AGAIN = 'Log in again to continue.';\n\nconst logged = new Set<string>();\n\nfunction logOnce(error: string): void {\n if (logged.has(error)) return;\n logged.add(error);\n warn(`slicc-agent: the Adobe session expired: ${error}`);\n}\n\nexport function providerName(provider: string | undefined, fallback = 'The provider'): string {\n return providerNames[provider ?? ''] ?? fallback;\n}\n\nexport function errorPart(error: string, provider?: string): MessagePart {\n const action = errorAction(error);\n if (action === 'drop-turn') {\n return {\n type: 'error',\n message: filtered.test(error)\n ? \"The model's content filter stopped this reply.\"\n : 'The model refused to answer this turn.',\n detail: error,\n action,\n };\n }\n const name = providerName(provider);\n const account = provider ? { account: provider } : {};\n if (unconnected.test(error))\n return {\n type: 'error',\n message: `${name} isn't connected.`,\n detail: CONNECT_IT,\n action: 'settings',\n ...account,\n };\n if (action === 'settings' && provider === 'adobe') {\n if (!adobeAuth.test(error)) return { type: 'error', ...proxyRefusal(error), action: 'retry' };\n logOnce(error);\n return {\n type: 'error',\n message: 'Your Adobe session has expired.',\n detail: LOG_IN_AGAIN,\n action: 'login',\n ...account,\n };\n }\n if (action === 'settings') {\n const lead = missing.test(error)\n ? `${name} needs an API key.`\n : `${name} rejected the API key.`;\n return { type: 'error', message: lead, detail: error, action, ...account };\n }\n return action === 'change-model'\n ? {\n type: 'error',\n message: \"This model isn't available with the current account.\",\n detail: error,\n action,\n }\n : { type: 'error', message: error, action };\n}\n\nexport function errorAction(message: string): ErrorAction {\n if (filtered.test(message) || refused.test(message)) return 'drop-turn';\n if (credentials.test(message)) return 'settings';\n if (models.test(message) && unavailable.test(message)) return 'change-model';\n return 'retry';\n}\n\nfunction sprinkleMessage(id: string, entry: EntryRecord): AssistantMessage {\n const data = (entry.data ?? {}) as { sprinkle?: unknown; at?: unknown };\n return {\n id,\n role: 'assistant',\n parts: [{ type: 'sprinkle', sprinkle: String(data.sprinkle ?? '') }],\n status: 'done',\n createdAt: typeof data.at === 'number' ? data.at : 0,\n };\n}\n\nexport function assistant(\n id: string,\n message: ModelMessage,\n status?: AssistantStatus,\n trust: Trust = NEVER\n): AssistantMessage {\n const blocks = Array.isArray(message.content) ? message.content : [];\n const parts = blocks\n .map((block) => part(block, trust))\n .filter((item): item is MessagePart => item !== undefined);\n if (message.errorMessage) parts.push(errorPart(message.errorMessage, message.provider));\n const used = usage(message);\n return {\n id,\n role: 'assistant',\n parts,\n status: status ?? statuses[message.stopReason ?? ''] ?? 'done',\n createdAt: message.timestamp ?? 0,\n ...(message.provider && message.model ? { model: `${message.provider}/${message.model}` } : {}),\n ...(used ? { usage: used } : {}),\n };\n}\n\nfunction user(\n id: string,\n message: ModelMessage,\n delivered: Delivered | undefined,\n from: From | undefined\n): UserMessage {\n return {\n id,\n role: 'user',\n ...shownUser(message.content, `ref:${id.slice(1)}:0`),\n createdAt: message.timestamp ?? 0,\n ...(delivered ? { delivered } : {}),\n ...(from ? { from: from.from } : {}),\n ...(from?.agent ? { origin: 'agent' as const } : {}),\n };\n}\n\nfunction guestUser(\n id: string,\n message: ModelMessage,\n delivered: Delivered | undefined,\n data: unknown\n): UserMessage {\n const input = data as Partial<GuestInput> | undefined;\n const name = String(input?.name ?? '');\n const shown = shownUser(message.content, `ref:${id.slice(1)}:0`);\n return {\n id,\n role: 'user',\n ...shown,\n text: guestText(shown.text, name),\n createdAt: message.timestamp ?? 0,\n ...(delivered ? { delivered } : {}),\n from: name,\n origin: 'guest',\n ...(typeof input?.seat === 'string' ? { seat: input.seat } : {}),\n };\n}\n\nexport function origins(entries: readonly EntryRecord[]): Map<number, From> {\n const out = new Map<number, From>();\n for (const entry of entries)\n if (entry.kind === FROM_KIND) {\n const note = entry.data as From;\n out.set(note.entry, note);\n }\n return out;\n}\n\nexport function shownChannel(channel: Lick['channel']): LickMessage['channel'] {\n return channel === 'cone-message' ? 'bash' : channel;\n}\n\nfunction lickMessage(\n id: string,\n entry: EntryRecord,\n decisions: ReadonlyMap<string, LickDecision>\n): LickMessage | undefined {\n const lick = entryLick(entry);\n if (!lick) return undefined;\n const state = lick.actions?.length ? (decisions.get(lick.id) ?? 'pending') : undefined;\n return {\n id,\n role: 'lick',\n channel: shownChannel(lick.channel),\n title: lick.title,\n text: lick.text,\n createdAt: lick.at,\n ...(lick.body ? { body: lick.body } : {}),\n ...(lick.count > 1 ? { count: lick.count } : {}),\n ...(state ? { state } : {}),\n ...(lick.severity ? { severity: lick.severity } : {}),\n ...(lick.summary ? { summary: lick.summary } : {}),\n ...(lick.report ? { report: lick.report } : {}),\n ...(lick.channel === 'sudo-run' && lick.source ? { approval: lick.source } : {}),\n };\n}\n\nfunction withoutLickTools(message: AssistantMessage): AssistantMessage {\n const parts = message.parts.filter((item) => item.type !== 'tool' || !LICK_TOOLS[item.tool.name]);\n return parts.length === message.parts.length ? message : { ...message, parts };\n}\n\nfunction system(id: string, entry: EntryRecord, text: string): SystemMessage {\n const reason = (entry.data as Json | undefined)?.reason as SystemMessage['trigger'] | undefined;\n return {\n id,\n role: 'system',\n kind: 'compaction',\n text,\n createdAt: 0,\n state: 'summarized',\n ...(reason ? { trigger: reason } : {}),\n };\n}\n\nfunction tools(messages: Message[]): Map<string, ToolCall> {\n const found = new Map<string, ToolCall>();\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const item of message.parts) if (item.type === 'tool') found.set(item.tool.id, item.tool);\n }\n return found;\n}\n\ninterface Diagnostic {\n severity: string;\n message: string;\n}\n\ninterface Note {\n severity: 'error' | 'warn' | 'info';\n text: string;\n}\n\ntype Card = ToolCall & { notes?: Note[] };\n\nconst RANK: Note['severity'][] = ['error', 'warn', 'info'];\n\nconst LINE = /^\\[(error|warn|info)\\] (.*)$/;\n\nfunction rendered(diagnostics: readonly Diagnostic[]): string {\n return `<harness>\\n${diagnostics.map((item) => `[${item.severity}] ${item.message}`).join('\\n')}\\n</harness>`;\n}\n\nfunction parsed(text: string): Diagnostic[] | undefined {\n const body = /^<harness>\\n([\\s\\S]*)\\n<\\/harness>$/.exec(text)?.[1];\n if (body === undefined) return undefined;\n const found = body.split('\\n').map((line) => LINE.exec(line));\n if (!found.every((match): match is RegExpExecArray => match !== null)) return undefined;\n return found.map(([, severity, message]) => ({ severity, message }) as Diagnostic);\n}\n\nfunction harness(\n content: ModelMessage['content'],\n data: unknown\n): { content: ModelMessage['content']; diagnostics: Diagnostic[] } {\n const last = Array.isArray(content) ? content.at(-1) : undefined;\n const stored = (data as { diagnostics?: unknown } | undefined)?.diagnostics;\n const listed = Array.isArray(stored) ? (stored as Diagnostic[]) : parsed(last?.text ?? '');\n if (!listed?.length || last?.type !== 'text' || last.text !== rendered(listed))\n return { content, diagnostics: [] };\n return { content: (content as Block[]).slice(0, -1), diagnostics: listed };\n}\n\nconst count = (value: string | undefined): string => Number(value).toLocaleString('en');\n\nconst ends: Record<string, string> = { end: ' from the start', beginning: ' from the end' };\n\nconst phrasings: [RegExp, (match: RegExpExecArray) => string][] = [\n [/^Command exited with code (-?\\d+)$/, (match) => `Exited with code ${match[1]}`],\n [/^Command timed out after (.+)$/, (match) => `Timed out after ${match[1]}`],\n [/^Command aborted$/, () => 'Aborted'],\n [/^Full output: (.+)$/, (match) => `Full output in ${match[1]}`],\n [\n /^Output truncated(?: to its (beginning|end))?: (\\d+) lines, (\\d+) bytes dropped$/,\n (match) =>\n `Output truncated: ${count(match[2])} lines and ${count(match[3])} bytes dropped${ends[match[1] ?? ''] ?? ''}`,\n ],\n];\n\nfunction phrased(message: string): string {\n const line = message\n .replace(/\\n[\\s\\S]*$/, '')\n .trim()\n .replace(/\\.$/, '');\n for (const [pattern, phrase] of phrasings) {\n const match = pattern.exec(line);\n if (match) return phrase(match);\n }\n return line;\n}\n\nfunction note(diagnostic: Diagnostic): Note {\n return { severity: diagnostic.severity as Note['severity'], text: phrased(diagnostic.message) };\n}\n\ntype Said = { trusted: boolean; intent: boolean };\n\nconst ranked = (notes: Note[]) =>\n notes.sort((a, b) => RANK.indexOf(a.severity) - RANK.indexOf(b.severity));\n\nfunction traced(call: Card, ran: Ran, said: Said | undefined): void {\n const known = new Set((call.notes ?? []).map((item) => item.text));\n const failures = ranFailures(ran)\n .filter((text) => !known.has(text))\n .map((text): Note => ({ severity: 'error', text }));\n if (failures.length) call.notes = ranked([...(call.notes ?? []), ...failures]);\n call.meta = [ranMeta(ran), call.meta].filter(Boolean).join(' \u00B7 ');\n if (said?.intent) return;\n const intent = said?.trusted ? saidIntent(ran.intent) : '';\n const title = intent || ranTitle(ran);\n if (title) call.title = shownTitle(title);\n}\n\nfunction settle(\n calls: Map<string, ToolCall>,\n result: ModelMessage,\n data?: unknown,\n said?: ReadonlyMap<string, Said>\n): void {\n const call = calls.get(result.toolCallId ?? '') as Card | undefined;\n if (!call) return;\n const split = harness(result.content, data);\n call.output = textOf(split.content);\n if (split.diagnostics.length) call.notes = ranked(split.diagnostics.map(note));\n const ran = call.name === 'bash' ? ranOf(result.details) : undefined;\n if (ran) traced(call, ran, said?.get(call.id));\n call.status = result.isError ? 'error' : 'done';\n const image = Array.isArray(result.content)\n ? (result.content as { type: string; data?: string; mimeType?: string }[]).find(\n (part) => part.type === 'image' && part.data && part.mimeType\n )\n : undefined;\n if (image) call.image = `data:${image.mimeType};base64,${image.data}`;\n const patch = result.details?.patch;\n const diff = typeof patch === 'string' ? fromPatch(patch) : undefined;\n if (diff) call.diff = diff;\n else if (result.isError) delete call.diff;\n}\n\nfunction rewound(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as { stopped?: string[]; restored?: string[]; files?: boolean };\n const notes = [\n 'Its prompt is back in the composer.',\n ...(data.stopped?.length\n ? [`Stopped ${data.stopped.map((name) => `scoop ${name}`).join(', ')}.`]\n : []),\n ...(data.restored?.length\n ? [`Restored ${data.restored.map((name) => `scoop ${name}`).join(', ')}.`]\n : []),\n ...(data.files ? ['Changed files stay; use Changes or git to revert them.'] : []),\n ];\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: 'Rewound 1 turn',\n text: notes.join(' '),\n createdAt: 0,\n };\n}\n\nfunction thawed(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as { name?: string; kind?: string; v6?: boolean };\n const what = data.v6 ? 'SLICC 6' : data.kind === 'agent' ? 'agent run' : 'scoop';\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: `Thawed from ${what} ${data.name ?? ''}`.trim(),\n text: textOf(entry.model?.[0]?.content ?? ''),\n createdAt: entry.model?.[0]?.timestamp ?? 0,\n };\n}\n\nexport function reviewed(entries: readonly EntryRecord[]): Map<string, GuestOutcome> {\n const out = new Map<string, GuestOutcome>();\n for (const entry of entries) {\n if (entry.kind !== REVIEWED_KIND) continue;\n const data = (entry.data ?? {}) as Partial<GuestReviewed>;\n if (typeof data.review === 'string' && data.outcome) out.set(data.review, data.outcome);\n }\n return out;\n}\n\nfunction asked(\n id: string,\n entry: EntryRecord,\n outcomes: ReadonlyMap<string, GuestOutcome>\n): SystemMessage {\n const data = (entry.data ?? {}) as Partial<GuestAsked>;\n return {\n id,\n role: 'system',\n kind: 'notice',\n text: askedLine(\n String(data.name ?? ''),\n String(data.text ?? ''),\n outcomes.get(String(data.review))\n ),\n createdAt: typeof data.at === 'number' ? data.at : 0,\n };\n}\n\nfunction secrets(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as {\n names?: SecretName[];\n error?: string | null;\n exposed?: string[];\n };\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: data.error ? 'Secrets unavailable' : 'Secrets listed',\n text: listedLine({\n names: data.names ?? [],\n error: data.error ?? null,\n exposed: data.exposed ?? [],\n }),\n createdAt: entry.model?.[0]?.timestamp ?? 0,\n };\n}\n\nconst V6_KINDS: Record<string, string> = {\n user: 'pi.user',\n assistant: 'pi.assistant',\n toolResult: 'pi.tool-result',\n};\n\nfunction entryMessage(\n entry: EntryRecord,\n out: Message[],\n calls: Map<string, ToolCall>,\n delivered: Delivered | undefined,\n notes: {\n decisions: ReadonlyMap<string, LickDecision>;\n origins: ReadonlyMap<number, From>;\n outcomes: ReadonlyMap<string, GuestOutcome>;\n trust: { tainted: boolean; intents: boolean; gated: ReadonlySet<string> };\n said: Map<string, Said>;\n }\n): void {\n const id = `e${entry.id}`;\n const model = entry.model?.[0] as ModelMessage | undefined;\n if (entry.kind === 'slicc.v6' && model) {\n const kind = V6_KINDS[model.role as string];\n if (kind) entryMessage({ ...entry, kind }, out, calls, delivered, notes);\n return;\n }\n if (entry.kind === TAINTED_KIND) notes.trust.tainted = true;\n if (entry.kind === 'slicc.rewound') out.push(rewound(id, entry));\n if (entry.kind === 'slicc.thawed') out.push(thawed(id, entry));\n else if (entry.kind === SECRETS_KIND) out.push(secrets(id, entry));\n else if (entry.kind === ASKED_KIND) out.push(asked(id, entry, notes.outcomes));\n else if (entry.kind === SPRINKLE_KIND) out.push(sprinkleMessage(id, entry));\n else if (entry.kind === 'pi.user' && model)\n out.push(\n lickMessage(id, entry, notes.decisions) ??\n user(id, model, delivered, notes.origins.get(entry.id))\n );\n else if (entry.kind === GUEST_INPUT_KIND && model)\n out.push(guestUser(id, model, delivered, entry.data));\n else if (entry.kind === 'pi.assistant' && model) {\n const trust = trusted(notes.trust);\n const message = assistant(id, model, undefined, trust);\n remember(model, trust, notes.said);\n notes.trust.tainted = false;\n out.push(withoutLickTools(message));\n for (const [key, value] of tools([message])) calls.set(key, value);\n } else if (entry.kind === 'pi.tool-result' && model) settle(calls, model, entry.data, notes.said);\n else if (entry.kind === 'pi.compaction') out.push(system(id, entry, textOf(model?.content)));\n}\n\nfunction remember(message: ModelMessage, trust: Trust, said: Map<string, Said>): void {\n for (const block of Array.isArray(message.content) ? message.content : [])\n if (block.type === 'toolCall' && block.id) {\n const trusted = trust(block.id);\n said.set(block.id, {\n trusted,\n intent: trusted && intentOf(String(block.name), block.arguments) !== '',\n });\n }\n}\n\nconst slotStatus: Record<string, ToolStatus> = {\n pending: 'running',\n running: 'running',\n done: 'done',\n};\n\nfunction trusted(trust: { tainted: boolean; intents: boolean; gated: ReadonlySet<string> }) {\n if (!trust.intents || trust.tainted) return NEVER;\n return (callId: string) => !trust.gated.has(callId);\n}\n\nfunction gatedCalls(entries: readonly EntryRecord[]): Set<string> {\n const found = new Set<string>();\n for (const entry of entries)\n if (entry.kind === GATED_KIND) found.add(String((entry.data as Partial<GatedCall>)?.callId));\n return found;\n}\n\nfunction live(\n view: ConversationView,\n out: Message[],\n calls: Map<string, ToolCall>,\n trust: Trust\n): void {\n const state = view.docs['pi.live'] as Live | undefined;\n for (const slot of state?.tools ?? []) {\n const call = calls.get(slot.callId);\n if (call && call.status === 'running') {\n call.status = slotStatus[slot.status] ?? 'running';\n call.output = slot.output ?? call.output;\n }\n }\n const partial = state?.generation?.message;\n if (partial) out.push(assistant('live', partial, 'streaming', trust));\n for (const compaction of state?.compactions ?? []) {\n out.push({\n id: `compaction-${compaction.taskId}`,\n role: 'system',\n kind: 'compaction',\n text: '',\n createdAt: 0,\n state: 'summarizing',\n trigger: compaction.reason as SystemMessage['trigger'],\n });\n }\n const retry = state?.generation?.retry;\n if (retry)\n out.push({\n id: 'retry',\n role: 'system',\n kind: 'notice',\n text: retry.error,\n createdAt: retry.at,\n });\n}\n\nexport function toMessages(\n view: ConversationView | undefined,\n deliveries: Readonly<Record<string, Delivered>> = {},\n intents = false\n): Message[] {\n const out: Message[] = [];\n if (!view) return out;\n const calls = new Map<string, ToolCall>();\n const notes = {\n decisions: lickDecisions(view.entries),\n origins: origins(view.entries),\n outcomes: reviewed(view.entries),\n trust: { tainted: view.before !== undefined, intents, gated: gatedCalls(view.entries) },\n said: new Map<string, Said>(),\n };\n let previous: EntryRecord | undefined;\n for (const entry of view.entries) {\n const steered = previous?.kind === 'pi.tool-result' ? 'steer' : undefined;\n entryMessage(entry, out, calls, deliveries[String(entry.id)] ?? steered, notes);\n previous = entry;\n }\n live(view, out, calls, trusted(notes.trust));\n return out;\n}\n\nfunction shownUser(\n content: ModelMessage['content'],\n prefix?: string\n): Pick<UserMessage, 'text' | 'attachments'> {\n const { text, attachments } = splitUser(content, prefix);\n return attachments.length ? { text, attachments } : { text };\n}\n\nexport function isBusy(view: ConversationView | undefined): boolean {\n return Boolean((view?.docs['pi.live'] as Live | undefined)?.run);\n}\n\nexport function queued(\n view: ConversationView | undefined,\n at: (id: string) => number = () => 0\n): UserMessage[] {\n const items = ((view?.docs['pi.inbox'] as { items?: Json[] } | undefined)?.items ?? []) as {\n id: number;\n mode: string;\n content?: ModelMessage['content'];\n entry?: { kind?: string; data?: Partial<GuestInput> };\n }[];\n return items\n .filter((item) => item.mode !== 'write' && !parseLick(textOf(item.content)))\n .map((item) => {\n const shown = shownUser(item.content);\n const data = item.entry?.data;\n const guest = item.entry?.kind === GUEST_INPUT_KIND ? String(data?.name ?? '') : null;\n const seat = typeof data?.seat === 'string' ? { seat: data.seat } : {};\n return {\n id: `q${item.id}`,\n role: 'user' as const,\n ...shown,\n ...(guest === null\n ? {}\n : {\n text: guestText(shown.text, guest),\n from: guest,\n origin: 'guest' as const,\n ...seat,\n }),\n createdAt: at(`q${item.id}`),\n queued: true,\n mode: item.mode === 'steer' ? 'steer' : 'queue',\n };\n });\n}\n"],
5
+ "mappings": "AAcA,SAAS,iBAAiB;AAC1B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EAKA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,qBAAqB;AAExC,SAAoB,iBAAiB;AACrC,SAAS,WAAW,YAA+B,qBAAqB;AACxE,SAAS,aAAa,SAAS,OAAO,UAAU,kBAAkB;AAClE,SAAS,iBAA4B;AAErC,SAAS,YAAY,oBAAoB;AAEzC,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AACrB,SAAS,YAAY,iBAAiB;AA8C/B,SAAS,OAAO,SAA0C;AAC/D,MAAI,OAAO,YAAY,SAAU,QAAO;AACxC,UAAQ,WAAW,CAAC,GAAG,IAAI,CAAC,UAAW,MAAM,SAAS,SAAU,MAAM,QAAQ,KAAM,EAAG,EAAE,KAAK,EAAE;AAClG;AAEA,MAAM,QAAQ,CAAC,SACb,OAAO,MAAM,SAAS,WAAW,CAAC,KAAK,IAAI,IAAI,CAAC;AAOlD,MAAM,MAAM;AAEZ,SAAS,QAAQ,OAAoC;AACnD,SAAO,OAAO,UAAU,WAAW,WAAW,KAAK,MAAM;AAC3D;AAEA,SAAS,MAAM,MAAgC;AAC7C,QAAM,EAAE,QAAQ,MAAM,IAAI;AAC1B,MAAI,OAAO,WAAW,YAAY,OAAO,UAAU;AACjD,WAAO,SAAS,MAAM,SAAI,SAAS,QAAQ,CAAC;AAC9C,MAAI,OAAO,WAAW,SAAU,QAAO,aAAa,MAAM;AAC1D,SAAO,OAAO,UAAU,WAAW,SAAS,KAAK,WAAW;AAC9D;AAEA,SAAS,MAAM,MAA8B;AAC3C,QAAM,OAAO,MAAM,QAAQ,KAAK,KAAK,IAAK,KAAK,QAA0B,CAAC;AAC1E,M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  }
@@ -1,17 +1,18 @@
1
1
  import { intentOf } from "../intent/said.js";
2
2
  import { mcpLabel } from "../mcp/label.js";
3
3
  import { redactSecrets } from "../memory/format.js";
4
+ import { listed } from "../ran/shown.js";
4
5
  const TITLE_LENGTH = 60;
5
6
  function leaf(path) {
6
7
  return path.replace(/\\/g, "/").split("/").filter(Boolean).at(-1) ?? "";
7
8
  }
8
- function shown(text) {
9
+ function shownTitle(text) {
9
10
  const flat = redactSecrets(text).text.replace(/\s+/g, " ").trim();
10
11
  return flat.length > TITLE_LENGTH ? `${flat.slice(0, TITLE_LENGTH - 1)}\u2026` : flat;
11
12
  }
12
13
  function file(verb, path) {
13
14
  const name = leaf(path);
14
- return shown(name ? `${verb} ${name}` : verb);
15
+ return shownTitle(name ? `${verb} ${name}` : verb);
15
16
  }
16
17
  const PROGRAMS_SHOWN = 3;
17
18
  function program(segment) {
@@ -20,10 +21,6 @@ function program(segment) {
20
21
  const name = leaf(word ?? "");
21
22
  return /^[\w.+-]+$/.test(name) ? name : void 0;
22
23
  }
23
- function listed(names) {
24
- if (names.length < 2) return names.join("");
25
- return `${names.slice(0, -1).join(", ")} and ${names.at(-1)}`;
26
- }
27
24
  function commandTitle(command) {
28
25
  const head = command.replace(/<<[\s\S]*/, "");
29
26
  const names = [
@@ -32,31 +29,32 @@ function commandTitle(command) {
32
29
  )
33
30
  ];
34
31
  if (!names.length) return "Running a command";
35
- const shown2 = names.slice(0, PROGRAMS_SHOWN);
36
- const more = names.length > PROGRAMS_SHOWN ? [...shown2, "more"] : shown2;
32
+ const shown = names.slice(0, PROGRAMS_SHOWN);
33
+ const more = names.length > PROGRAMS_SHOWN ? [...shown, "more"] : shown;
37
34
  return `Running ${listed(more)}`;
38
35
  }
39
36
  function toolTitle(name, args, trusted = false) {
40
37
  const said = trusted ? intentOf(name, args) : "";
41
- if (said) return shown(said);
38
+ if (said) return shownTitle(said);
42
39
  const labeled = mcpLabel(name);
43
40
  if (labeled) return `Calling ${labeled}`;
44
41
  const path = typeof args?.path === "string" ? args.path : "";
45
42
  const command = typeof args?.command === "string" ? args.command : "";
46
- if (name === "bash") return shown(commandTitle(command));
43
+ if (name === "bash") return shownTitle(commandTitle(command));
47
44
  if (name === "read") return file("Reading", path);
48
45
  if (name === "write") return file("Writing", path);
49
46
  if (name === "edit") return file("Editing", path);
50
47
  if (name === "codemode") return "Running code";
51
48
  if (path) {
52
49
  const fileName = leaf(path);
53
- return shown(fileName ? `${name} ${fileName}` : name);
50
+ return shownTitle(fileName ? `${name} ${fileName}` : name);
54
51
  }
55
- if (command) return shown(command) || name;
52
+ if (command) return shownTitle(command) || name;
56
53
  return name;
57
54
  }
58
55
  export {
59
56
  commandTitle,
57
+ shownTitle,
60
58
  toolTitle
61
59
  };
62
60
  //# sourceMappingURL=tool-title.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/spectrum/tool-title.ts"],
4
- "sourcesContent": ["import { intentOf } from '../intent/said.ts';\nimport { mcpLabel } from '../mcp/label.ts';\nimport { redactSecrets } from '../memory/format.ts';\n\ntype Json = Record<string, unknown>;\n\nconst TITLE_LENGTH = 60;\n\nfunction leaf(path: string): string {\n return path.replace(/\\\\/g, '/').split('/').filter(Boolean).at(-1) ?? '';\n}\n\nfunction shown(text: string): string {\n const flat = redactSecrets(text).text.replace(/\\s+/g, ' ').trim();\n return flat.length > TITLE_LENGTH ? `${flat.slice(0, TITLE_LENGTH - 1)}\u2026` : flat;\n}\n\nfunction file(verb: string, path: string): string {\n const name = leaf(path);\n return shown(name ? `${verb} ${name}` : verb);\n}\n\nconst PROGRAMS_SHOWN = 3;\n\nfunction program(segment: string): string | undefined {\n const words = segment.trim().split(/\\s+/);\n const word = words.find((each) => !/^\\w+=/.test(each) && each !== 'sudo' && each !== 'env');\n const name = leaf(word ?? '');\n return /^[\\w.+-]+$/.test(name) ? name : undefined;\n}\n\nfunction listed(names: readonly string[]): string {\n if (names.length < 2) return names.join('');\n return `${names.slice(0, -1).join(', ')} and ${names.at(-1)}`;\n}\n\nexport function commandTitle(command: string): string {\n const head = command.replace(/<<[\\s\\S]*/, '');\n const names = [\n ...new Set(\n head\n .split(/&&|\\|\\||[;|&\\n()]/)\n .map(program)\n .filter((name) => name !== undefined)\n ),\n ];\n if (!names.length) return 'Running a command';\n const shown = names.slice(0, PROGRAMS_SHOWN);\n const more = names.length > PROGRAMS_SHOWN ? [...shown, 'more'] : shown;\n return `Running ${listed(more)}`;\n}\n\nexport function toolTitle(name: string, args: Json | undefined, trusted = false): string {\n const said = trusted ? intentOf(name, args) : '';\n if (said) return shown(said);\n const labeled = mcpLabel(name);\n if (labeled) return `Calling ${labeled}`;\n const path = typeof args?.path === 'string' ? args.path : '';\n const command = typeof args?.command === 'string' ? args.command : '';\n if (name === 'bash') return shown(commandTitle(command));\n if (name === 'read') return file('Reading', path);\n if (name === 'write') return file('Writing', path);\n if (name === 'edit') return file('Editing', path);\n if (name === 'codemode') return 'Running code';\n if (path) {\n const fileName = leaf(path);\n return shown(fileName ? `${name} ${fileName}` : name);\n }\n if (command) return shown(command) || name;\n return name;\n}\n"],
5
- "mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAI9B,MAAM,eAAe;AAErB,SAAS,KAAK,MAAsB;AAClC,SAAO,KAAK,QAAQ,OAAO,GAAG,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,GAAG,EAAE,KAAK;AACvE;AAEA,SAAS,MAAM,MAAsB;AACnC,QAAM,OAAO,cAAc,IAAI,EAAE,KAAK,QAAQ,QAAQ,GAAG,EAAE,KAAK;AAChE,SAAO,KAAK,SAAS,eAAe,GAAG,KAAK,MAAM,GAAG,eAAe,CAAC,CAAC,WAAM;AAC9E;AAEA,SAAS,KAAK,MAAc,MAAsB;AAChD,QAAM,OAAO,KAAK,IAAI;AACtB,SAAO,MAAM,OAAO,GAAG,IAAI,IAAI,IAAI,KAAK,IAAI;AAC9C;AAE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,OAAO,CAAC;AACvD,MAAI,SAAS,OAAQ,QAAO,KAAK,WAAW,IAAI;AAChD,MAAI,SAAS,QAAS,QAAO,KAAK,WAAW,IAAI;AACjD,MAAI,SAAS,OAAQ,QAAO,KAAK,WAAW,IAAI;AAChD,MAAI,SAAS,WAAY,QAAO;AAChC,MAAI,MAAM;AACR,UAAM,WAAW,KAAK,IAAI;AAC1B,WAAO,MAAM,WAAW,GAAG,IAAI,IAAI,QAAQ,KAAK,IAAI;AAAA,EACtD;AACA,MAAI,QAAS,QAAO,MAAM,OAAO,KAAK;AACtC,SAAO;AACT;",
6
- "names": ["shown"]
4
+ "sourcesContent": ["import { intentOf } from '../intent/said.ts';\nimport { mcpLabel } from '../mcp/label.ts';\nimport { redactSecrets } from '../memory/format.ts';\nimport { listed } from '../ran/shown.ts';\n\ntype Json = Record<string, unknown>;\n\nconst TITLE_LENGTH = 60;\n\nfunction leaf(path: string): string {\n return path.replace(/\\\\/g, '/').split('/').filter(Boolean).at(-1) ?? '';\n}\n\nexport function shownTitle(text: string): string {\n const flat = redactSecrets(text).text.replace(/\\s+/g, ' ').trim();\n return flat.length > TITLE_LENGTH ? `${flat.slice(0, TITLE_LENGTH - 1)}\u2026` : flat;\n}\n\nfunction file(verb: string, path: string): string {\n const name = leaf(path);\n return shownTitle(name ? `${verb} ${name}` : verb);\n}\n\nconst PROGRAMS_SHOWN = 3;\n\nfunction program(segment: string): string | undefined {\n const words = segment.trim().split(/\\s+/);\n const word = words.find((each) => !/^\\w+=/.test(each) && each !== 'sudo' && each !== 'env');\n const name = leaf(word ?? '');\n return /^[\\w.+-]+$/.test(name) ? name : undefined;\n}\n\nexport function commandTitle(command: string): string {\n const head = command.replace(/<<[\\s\\S]*/, '');\n const names = [\n ...new Set(\n head\n .split(/&&|\\|\\||[;|&\\n()]/)\n .map(program)\n .filter((name) => name !== undefined)\n ),\n ];\n if (!names.length) return 'Running a command';\n const shown = names.slice(0, PROGRAMS_SHOWN);\n const more = names.length > PROGRAMS_SHOWN ? [...shown, 'more'] : shown;\n return `Running ${listed(more)}`;\n}\n\nexport function toolTitle(name: string, args: Json | undefined, trusted = false): string {\n const said = trusted ? intentOf(name, args) : '';\n if (said) return shownTitle(said);\n const labeled = mcpLabel(name);\n if (labeled) return `Calling ${labeled}`;\n const path = typeof args?.path === 'string' ? args.path : '';\n const command = typeof args?.command === 'string' ? args.command : '';\n if (name === 'bash') return shownTitle(commandTitle(command));\n if (name === 'read') return file('Reading', path);\n if (name === 'write') return file('Writing', path);\n if (name === 'edit') return file('Editing', path);\n if (name === 'codemode') return 'Running code';\n if (path) {\n const fileName = leaf(path);\n return shownTitle(fileName ? `${name} ${fileName}` : name);\n }\n if (command) return shownTitle(command) || name;\n return name;\n}\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAC9B,SAAS,cAAc;AAIvB,MAAM,eAAe;AAErB,SAAS,KAAK,MAAsB;AAClC,SAAO,KAAK,QAAQ,OAAO,GAAG,EAAE,MAAM,GAAG,EAAE,OAAO,OAAO,EAAE,GAAG,EAAE,KAAK;AACvE;AAEO,SAAS,WAAW,MAAsB;AAC/C,QAAM,OAAO,cAAc,IAAI,EAAE,KAAK,QAAQ,QAAQ,GAAG,EAAE,KAAK;AAChE,SAAO,KAAK,SAAS,eAAe,GAAG,KAAK,MAAM,GAAG,eAAe,CAAC,CAAC,WAAM;AAC9E;AAEA,SAAS,KAAK,MAAc,MAAsB;AAChD,QAAM,OAAO,KAAK,IAAI;AACtB,SAAO,WAAW,OAAO,GAAG,IAAI,IAAI,IAAI,KAAK,IAAI;AACnD;AAEA,MAAM,iBAAiB;AAEvB,SAAS,QAAQ,SAAqC;AACpD,QAAM,QAAQ,QAAQ,KAAK,EAAE,MAAM,KAAK;AACxC,QAAM,OAAO,MAAM,KAAK,CAAC,SAAS,CAAC,QAAQ,KAAK,IAAI,KAAK,SAAS,UAAU,SAAS,KAAK;AAC1F,QAAM,OAAO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,5 +1,6 @@
1
1
  import { answerText } from "../agent.js";
2
2
  import { intentOf, withoutIntent } from "../intent/said.js";
3
+ import { ranLine, ranOf, saidIntent } from "../ran/shown.js";
3
4
  const OUTPUT_LENGTH = 600;
4
5
  function blocks(entry) {
5
6
  const content = entry.model?.[0]?.content;
@@ -35,8 +36,15 @@ function clusterOf(entries, callIds) {
35
36
  at: said?.timestamp ?? 0
36
37
  });
37
38
  }
38
- if (entry.kind === "pi.tool-result" && said?.toolCallId)
39
- results.set(said.toolCallId, { output: answerText(said.content), index });
39
+ if (entry.kind === "pi.tool-result" && said?.toolCallId) {
40
+ const ran = ranOf(said.details);
41
+ results.set(said.toolCallId, {
42
+ output: answerText(said.content),
43
+ index,
44
+ ran: ranLine(ran),
45
+ intent: saidIntent(ran?.intent)
46
+ });
47
+ }
40
48
  });
41
49
  const runs = [];
42
50
  let at = 0;
@@ -50,7 +58,8 @@ function clusterOf(entries, callIds) {
50
58
  input: call.input,
51
59
  output: result?.output ?? "",
52
60
  done: !!result,
53
- intent: call.intent
61
+ intent: call.intent || (call.name === "bash" ? result?.intent ?? "" : ""),
62
+ ran: call.name === "bash" ? result?.ran ?? "" : ""
54
63
  });
55
64
  at = Math.max(at, call.at);
56
65
  last = Math.max(last, result?.index ?? Number.POSITIVE_INFINITY);
@@ -59,11 +68,12 @@ function clusterOf(entries, callIds) {
59
68
  return { runs, at, settled };
60
69
  }
61
70
  function describeStep(run) {
62
- return `${run.name}: ${run.input}`;
71
+ return run.ran ? `${run.name}: ${run.input}
72
+ ${run.ran}` : `${run.name}: ${run.input}`;
63
73
  }
64
74
  function describe(runs) {
65
75
  return runs.map(
66
- (run) => `${run.name}: ${run.input}
76
+ (run) => `${describeStep(run)}
67
77
  => ${run.done ? run.output.slice(0, OUTPUT_LENGTH) : "(running)"}`
68
78
  ).join("\n\n");
69
79
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/titles/cluster.ts"],
4
- "sourcesContent": ["import type { ConversationView, EntryRecord } from '@earendil-works/pi-durable';\nimport { answerText } from '../agent.ts';\nimport { intentOf, withoutIntent } from '../intent/said.ts';\n\nconst OUTPUT_LENGTH = 600;\n\nexport type Run = { name: string; input: string; output: string; done: boolean; intent: string };\n\nexport type Cluster = { runs: Run[]; at: number; settled: boolean };\n\ntype Block = { type?: string; id?: string; name?: string; arguments?: unknown; text?: string };\n\ntype Said = {\n content?: unknown;\n toolCallId?: string;\n timestamp?: number;\n stopReason?: string;\n};\n\nfunction blocks(entry: EntryRecord): Block[] {\n const content = (entry.model?.[0] as Said | undefined)?.content;\n return entry.kind === 'pi.assistant' && Array.isArray(content) ? (content as Block[]) : [];\n}\n\nexport function callIdsOf(views: readonly ConversationView[]): Set<string> {\n const ids = new Set<string>();\n for (const view of views)\n for (const entry of view.entries)\n for (const block of blocks(entry))\n if (block.type === 'toolCall' && block.id) ids.add(block.id);\n return ids;\n}\n\nfunction movedOn(entry: EntryRecord): boolean {\n if (entry.kind === 'pi.user') return true;\n if (entry.kind !== 'pi.assistant') return false;\n const said = entry.model?.[0] as Said | undefined;\n return (\n said?.stopReason !== 'toolUse' ||\n blocks(entry).some((block) => block.type === 'text' && block.text?.trim())\n );\n}\n\nexport function clusterOf(\n entries: readonly EntryRecord[],\n callIds: readonly string[]\n): Cluster | undefined {\n const calls = new Map<string, Pick<Run, 'name' | 'input' | 'intent'> & { at: number }>();\n const results = new Map<string, { output: string; index: number }>();\n entries.forEach((entry, index) => {\n const said = entry.model?.[0] as Said | undefined;\n for (const block of blocks(entry))\n if (block.type === 'toolCall' && block.id) {\n const name = block.name ?? 'tool';\n const args = (block.arguments ?? {}) as object;\n calls.set(block.id, {\n name,\n input: JSON.stringify(withoutIntent(name, args)),\n intent: intentOf(name, args),\n at: said?.timestamp ?? 0,\n });\n }\n if (entry.kind === 'pi.tool-result' && said?.toolCallId)\n results.set(said.toolCallId, { output: answerText(said.content), index });\n });\n const runs: Run[] = [];\n let at = 0;\n let last = -1;\n for (const id of callIds) {\n const call = calls.get(id);\n if (!call) return undefined;\n const result = results.get(id);\n runs.push({\n name: call.name,\n input: call.input,\n output: result?.output ?? '',\n done: !!result,\n intent: call.intent,\n });\n at = Math.max(at, call.at);\n last = Math.max(last, result?.index ?? Number.POSITIVE_INFINITY);\n }\n const settled = entries.slice(last + 1).some(movedOn);\n return { runs, at, settled };\n}\n\nexport function describeStep(run: Run): string {\n return `${run.name}: ${run.input}`;\n}\n\nexport function describe(runs: readonly Run[]): string {\n return runs\n .map(\n (run) =>\n `${run.name}: ${run.input}\\n=> ${run.done ? run.output.slice(0, OUTPUT_LENGTH) : '(running)'}`\n )\n .join('\\n\\n');\n}\n"],
5
- "mappings": "AACA,SAAS,kBAAkB;AAC3B,SAAS,UAAU,qBAAqB;AAExC,MAAM,gBAAgB;AAetB,SAAS,OAAO,OAA6B;AAC3C,QAAM,UAAW,MAAM,QAAQ,CAAC,GAAwB;AACxD,SAAO,MAAM,SAAS,kBAAkB,MAAM,QAAQ,OAAO,IAAK,UAAsB,CAAC;AAC3F;AAEO,SAAS,UAAU,OAAiD;AACzE,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,QAAQ;AACjB,eAAW,SAAS,KAAK;AACvB,iBAAW,SAAS,OAAO,KAAK;AAC9B,YAAI,MAAM,SAAS,cAAc,MAAM,GAAI,KAAI,IAAI,MAAM,EAAE;AACjE,SAAO;AACT;AAEA,SAAS,QAAQ,OAA6B;AAC5C,MAAI,MAAM,SAAS,UAAW,QAAO;AACrC,MAAI,MAAM,SAAS,eAAgB,QAAO;AAC1C,QAAM,OAAO,MAAM,QAAQ,CAAC;AAC5B,SACE,MAAM,eAAe,aACrB,OAAO,KAAK,EAAE,KAAK,CAAC,UAAU,MAAM,SAAS,UAAU,MAAM,MAAM,KAAK,CAAC;AAE7E;AAEO,SAAS,UACd,SACA,SACqB;AACrB,QAAM,QAAQ,oBAAI,IAAqE;AACvF,QAAM,UAAU,oBAAI,IAA+C;AACnE,UAAQ,Q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AAA,IACC,CAAC,QACC,GAAG,IAAI,IAAI,KAAK,IAAI,KAAK;AAAA,KAAQ,IAAI,OAAO,IAAI,OAAO,MAAM,GAAG,aAAa,IAAI,WAAW;AAAA,EAChG,EACC,KAAK,MAAM;AAChB;",
4
+ "sourcesContent": ["import type { ConversationView, EntryRecord } from '@earendil-works/pi-durable';\nimport { answerText } from '../agent.ts';\nimport { intentOf, withoutIntent } from '../intent/said.ts';\nimport { ranLine, ranOf, saidIntent } from '../ran/shown.ts';\n\nconst OUTPUT_LENGTH = 600;\n\nexport type Run = {\n name: string;\n input: string;\n output: string;\n done: boolean;\n intent: string;\n ran: string;\n};\n\nexport type Cluster = { runs: Run[]; at: number; settled: boolean };\n\ntype Block = { type?: string; id?: string; name?: string; arguments?: unknown; text?: string };\n\ntype Said = {\n content?: unknown;\n toolCallId?: string;\n details?: unknown;\n timestamp?: number;\n stopReason?: string;\n};\n\nfunction blocks(entry: EntryRecord): Block[] {\n const content = (entry.model?.[0] as Said | undefined)?.content;\n return entry.kind === 'pi.assistant' && Array.isArray(content) ? (content as Block[]) : [];\n}\n\nexport function callIdsOf(views: readonly ConversationView[]): Set<string> {\n const ids = new Set<string>();\n for (const view of views)\n for (const entry of view.entries)\n for (const block of blocks(entry))\n if (block.type === 'toolCall' && block.id) ids.add(block.id);\n return ids;\n}\n\nfunction movedOn(entry: EntryRecord): boolean {\n if (entry.kind === 'pi.user') return true;\n if (entry.kind !== 'pi.assistant') return false;\n const said = entry.model?.[0] as Said | undefined;\n return (\n said?.stopReason !== 'toolUse' ||\n blocks(entry).some((block) => block.type === 'text' && block.text?.trim())\n );\n}\n\nexport function clusterOf(\n entries: readonly EntryRecord[],\n callIds: readonly string[]\n): Cluster | undefined {\n const calls = new Map<string, Pick<Run, 'name' | 'input' | 'intent'> & { at: number }>();\n const results = new Map<string, { output: string; index: number; ran: string; intent: string }>();\n entries.forEach((entry, index) => {\n const said = entry.model?.[0] as Said | undefined;\n for (const block of blocks(entry))\n if (block.type === 'toolCall' && block.id) {\n const name = block.name ?? 'tool';\n const args = (block.arguments ?? {}) as object;\n calls.set(block.id, {\n name,\n input: JSON.stringify(withoutIntent(name, args)),\n intent: intentOf(name, args),\n at: said?.timestamp ?? 0,\n });\n }\n if (entry.kind === 'pi.tool-result' && said?.toolCallId) {\n const ran = ranOf(said.details);\n results.set(said.toolCallId, {\n output: answerText(said.content),\n index,\n ran: ranLine(ran),\n intent: saidIntent(ran?.intent),\n });\n }\n });\n const runs: Run[] = [];\n let at = 0;\n let last = -1;\n for (const id of callIds) {\n const call = calls.get(id);\n if (!call) return undefined;\n const result = results.get(id);\n runs.push({\n name: call.name,\n input: call.input,\n output: result?.output ?? '',\n done: !!result,\n intent: call.intent || (call.name === 'bash' ? (result?.intent ?? '') : ''),\n ran: call.name === 'bash' ? (result?.ran ?? '') : '',\n });\n at = Math.max(at, call.at);\n last = Math.max(last, result?.index ?? Number.POSITIVE_INFINITY);\n }\n const settled = entries.slice(last + 1).some(movedOn);\n return { runs, at, settled };\n}\n\nexport function describeStep(run: Run): string {\n return run.ran ? `${run.name}: ${run.input}\\n${run.ran}` : `${run.name}: ${run.input}`;\n}\n\nexport function describe(runs: readonly Run[]): string {\n return runs\n .map(\n (run) =>\n `${describeStep(run)}\\n=> ${run.done ? run.output.slice(0, OUTPUT_LENGTH) : '(running)'}`\n )\n .join('\\n\\n');\n}\n"],
5
+ "mappings": "AACA,SAAS,kBAAkB;AAC3B,SAAS,UAAU,qBAAqB;AACxC,SAAS,SAAS,OAAO,kBAAkB;AAE3C,MAAM,gBAAgB;AAuBtB,SAAS,OAAO,OAA6B;AAC3C,QAAM,UAAW,MAAM,QAAQ,CAAC,GAAwB;AACxD,SAAO,MAAM,SAAS,kBAAkB,MAAM,QAAQ,OAAO,IAAK,UAAsB,CAAC;AAC3F;AAEO,SAAS,UAAU,OAAiD;AACzE,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,QAAQ;AACjB,eAAW,SAAS,KAAK;AACvB,iBAA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AAM,OAAO,MAAM,IAAI,EAAE;AACzB,QAAI,CAAC,KAAM,QAAO;AAClB,UAAM,SAAS,QAAQ,IAAI,EAAE;AAC7B,SAAK,KAAK;AAAA,MACR,MAAM,KAAK;AAAA,MACX,OAAO,KAAK;AAAA,MACZ,QAAQ,QAAQ,UAAU;AAAA,MAC1B,MAAM,CAAC,CAAC;AAAA,MACR,QAAQ,KAAK,WAAW,KAAK,SAAS,SAAU,QAAQ,UAAU,KAAM;AAAA,MACxE,KAAK,KAAK,SAAS,SAAU,QAAQ,OAAO,KAAM;AAAA,IACpD,CAAC;AACD,SAAK,KAAK,IAAI,IAAI,KAAK,EAAE;AACzB,WAAO,KAAK,IAAI,MAAM,QAAQ,SAAS,OAAO,iBAAiB;AAAA,EACjE;AACA,QAAM,UAAU,QAAQ,MAAM,OAAO,CAAC,EAAE,KAAK,OAAO;AACpD,SAAO,EAAE,MAAM,IAAI,QAAQ;AAC7B;AAEO,SAAS,aAAa,KAAkB;AAC7C,SAAO,IAAI,MAAM,GAAG,IAAI,IAAI,KAAK,IAAI,KAAK;AAAA,EAAK,IAAI,GAAG,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,KAAK;AACtF;AAEO,SAAS,SAAS,MAA8B;AACrD,SAAO,KACJ;AAAA,IACC,CAAC,QACC,GAAG,aAAa,GAAG,CAAC;AAAA,KAAQ,IAAI,OAAO,IAAI,OAAO,MAAM,GAAG,aAAa,IAAI,WAAW;AAAA,EAC3F,EACC,KAAK,MAAM;AAChB;",
6
6
  "names": []
7
7
  }
@@ -43,22 +43,36 @@ export interface SpawnOptions {
43
43
  user?: string | number;
44
44
  env?: Record<string, string>;
45
45
  pgid?: number;
46
- tag?: string;
46
+ tag?: string | readonly string[];
47
47
  stdin?: Uint8Array;
48
48
  onStdout?(bytes: Uint8Array): void;
49
49
  onStderr?(bytes: Uint8Array): void;
50
50
  }
51
51
  export interface TraceExit {
52
52
  type: 'exit';
53
+ seq?: number;
53
54
  pid: number;
54
55
  status: number;
55
56
  signal?: string;
57
+ utime?: number;
58
+ stime?: number;
56
59
  at?: number;
57
60
  }
58
- export type TraceEvent = TraceExit | {
61
+ export type TraceEvent = {
59
62
  type: 'exec' | 'fork';
63
+ seq: number;
60
64
  pid: number;
61
- };
65
+ ppid: number;
66
+ pgid?: number;
67
+ argv: readonly string[];
68
+ exe?: string;
69
+ at?: number;
70
+ replaced?: boolean;
71
+ } | TraceExit;
72
+ export interface TraceBatch {
73
+ events: readonly TraceEvent[];
74
+ dropped: number;
75
+ }
62
76
  export interface SudoRunOptions {
63
77
  stdout?: string;
64
78
  stderr?: string;
@@ -76,10 +90,7 @@ export interface KernelClient {
76
90
  fs: KernelFs;
77
91
  protocol?: readonly number[];
78
92
  sudoRun?(request: object, options: SudoRunOptions): Promise<SudoRunning>;
79
- trace?(tag: string, onEvents: (batch: {
80
- events: TraceEvent[];
81
- dropped: number;
82
- }) => void | Promise<unknown>, options?: {
93
+ trace?(tag: string, onEvents: (batch: TraceBatch) => void | Promise<unknown>, options?: {
83
94
  limit?: number;
84
95
  }): Promise<{
85
96
  close(): void;
@@ -2,10 +2,14 @@ import type { Context } from '@earendil-works/chord';
2
2
  import { ExecutionError, type Result, type ShellExecOptions, type ShellExecResult } from '@earendil-works/pi-durable/env';
3
3
  import type { ScrubStream } from '../secrets/scrub.ts';
4
4
  import type { KernelClient, KernelProcess } from './client.ts';
5
+ import { type CallTrace } from './trace.ts';
5
6
  export declare const SHELL: readonly ['bash', '-c'];
6
7
  export declare const HELD_LIMIT: number;
7
8
  export declare const HELD = "output held: waiting for the vault";
8
9
  export declare const GONE = "the kernel went away mid-run, so the command may have partly run";
10
+ export type TracedExecOptions = ShellExecOptions & {
11
+ trace?: CallTrace;
12
+ };
9
13
  export interface ExecHooks {
10
14
  scrub?: () => ScrubStream;
11
15
  spawn?: (argv: readonly string[]) => readonly string[];
@@ -0,0 +1,45 @@
1
+ import type { KernelClient, TraceBatch } from './client.ts';
2
+ export declare const CALL_TAG = "call:";
3
+ export declare const PROGRAMS_KEPT = 16;
4
+ export declare const NAMES_HELD = 64;
5
+ export declare const PIDS_HELD = 1024;
6
+ export declare const QUEUE_HELD = 4096;
7
+ export declare const LINGER_MS = 2000;
8
+ export declare const TRACE_LIMIT = 4096;
9
+ export declare const INTENT_HELD = 1000;
10
+ export interface RanProgram {
11
+ name: string;
12
+ status?: number;
13
+ signal?: string;
14
+ quiet?: true;
15
+ }
16
+ export interface Ran {
17
+ programs: RanProgram[];
18
+ ms: number;
19
+ more?: number;
20
+ dropped?: number;
21
+ intent?: string;
22
+ }
23
+ export interface CallTrace {
24
+ tag: string;
25
+ report(ran: Ran): void;
26
+ }
27
+ export declare function programOf(argv: readonly string[], exe?: string): {
28
+ name: string;
29
+ args: readonly string[];
30
+ } | undefined;
31
+ export declare function argvIntent(args: readonly string[]): string | undefined;
32
+ export declare class Collector {
33
+ #private;
34
+ constructor(argv: readonly string[], launchers: number);
35
+ feed(batch: TraceBatch): void;
36
+ begin(pid: number): void;
37
+ get done(): boolean;
38
+ settled(ms: number): Promise<void>;
39
+ facts(ms: number, killed: boolean): Ran;
40
+ }
41
+ export interface Tracer {
42
+ collector: Collector;
43
+ close(): void;
44
+ }
45
+ export declare function follow(client: KernelClient, tag: string, argv: readonly string[], launchers: number): Promise<Tracer | undefined>;
@@ -0,0 +1,3 @@
1
+ import { type Extension, type ToolRegistration } from '@earendil-works/pi-durable';
2
+ export declare const RAN = "slicc-ran";
3
+ export declare function ranExtension(tools: readonly ToolRegistration[]): Extension;
@@ -0,0 +1,12 @@
1
+ import type { Ran, RanProgram } from '../kernel/trace.ts';
2
+ export declare const RAN_KEY = "ran";
3
+ export declare const META_PROGRAMS = 8;
4
+ export declare function ranOf(details: unknown): Ran | undefined;
5
+ export declare function saidIntent(raw: string | undefined): string;
6
+ export declare function listed(names: readonly string[]): string;
7
+ export declare function ranTitle(ran: Ran): string | undefined;
8
+ export declare function seconds(ms: number): string;
9
+ export declare function ranMeta(ran: Ran): string;
10
+ export declare function failed(program: RanProgram): string | undefined;
11
+ export declare function ranFailures(ran: Ran): string[];
12
+ export declare function ranLine(ran: Ran | undefined): string;
@@ -34,6 +34,7 @@ interface ModelMessage {
34
34
  isError?: boolean;
35
35
  details?: {
36
36
  patch?: unknown;
37
+ ran?: unknown;
37
38
  };
38
39
  }
39
40
  export declare function textOf(content: ModelMessage['content']): string;
@@ -1,4 +1,5 @@
1
1
  type Json = Record<string, unknown>;
2
+ export declare function shownTitle(text: string): string;
2
3
  export declare function commandTitle(command: string): string;
3
4
  export declare function toolTitle(name: string, args: Json | undefined, trusted?: boolean): string;
4
5
  export {};
@@ -5,6 +5,7 @@ export type Run = {
5
5
  output: string;
6
6
  done: boolean;
7
7
  intent: string;
8
+ ran: string;
8
9
  };
9
10
  export type Cluster = {
10
11
  runs: Run[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-agent",
3
- "version": "7.32.0",
3
+ "version": "7.33.0",
4
4
  "description": "SLICC's agent core on pi durable: an agent worker, session storage, remoting and pi extensions",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -87,7 +87,7 @@
87
87
  "fake-indexeddb": "6.2.7",
88
88
  "lefthook": "2.2.2",
89
89
  "monocart-coverage-reports": "3.2.0",
90
- "playwright-core": "1.64.1",
90
+ "playwright-core": "1.65.0",
91
91
  "semantic-release": "25.0.9",
92
92
  "slicc-agent-5": "npm:@ai-ecoverse/slicc-agent@5.10.1",
93
93
  "typescript": "7.0.2"