@ai-ecoverse/slicc-agent 5.2.0 → 5.3.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.
- package/README.md +16 -2
- package/dist/agent.js +6 -1
- package/dist/agent.js.map +2 -2
- package/dist/client.js +3 -0
- package/dist/client.js.map +2 -2
- package/dist/control.js +10 -4
- package/dist/control.js.map +2 -2
- package/dist/guests/attribution.js +22 -0
- package/dist/guests/attribution.js.map +7 -0
- package/dist/guests/client.js +150 -0
- package/dist/guests/client.js.map +7 -0
- package/dist/guests/guard.js +38 -0
- package/dist/guests/guard.js.map +7 -0
- package/dist/guests/index.js +282 -0
- package/dist/guests/index.js.map +7 -0
- package/dist/guests/seats.js +49 -0
- package/dist/guests/seats.js.map +7 -0
- package/dist/guests/serve.js +72 -0
- package/dist/guests/serve.js.map +7 -0
- package/dist/guests/view.js +40 -0
- package/dist/guests/view.js.map +7 -0
- package/dist/host.js +91 -3
- package/dist/host.js.map +2 -2
- package/dist/index.js +8 -0
- package/dist/index.js.map +2 -2
- package/dist/owner.js +2 -1
- package/dist/owner.js.map +2 -2
- package/dist/page.js +8 -0
- package/dist/page.js.map +2 -2
- package/dist/secrets/extension.js +4 -1
- package/dist/secrets/extension.js.map +2 -2
- package/dist/services.js +12 -0
- package/dist/services.js.map +2 -2
- package/dist/serving.js +7 -0
- package/dist/serving.js.map +2 -2
- package/dist/spectrum/agent-port.js +14 -1
- package/dist/spectrum/agent-port.js.map +2 -2
- package/dist/spectrum/guest-port.js +57 -0
- package/dist/spectrum/guest-port.js.map +7 -0
- package/dist/spectrum/index.js +19 -0
- package/dist/spectrum/index.js.map +3 -3
- package/dist/spectrum/messages.js +30 -8
- package/dist/spectrum/messages.js.map +2 -2
- package/dist/spectrum/proposals.js +56 -0
- package/dist/spectrum/proposals.js.map +7 -0
- package/dist/types/client.d.ts +7 -1
- package/dist/types/control.d.ts +2 -1
- package/dist/types/guests/attribution.d.ts +9 -0
- package/dist/types/guests/client.d.ts +12 -0
- package/dist/types/guests/guard.d.ts +5 -0
- package/dist/types/guests/index.d.ts +54 -0
- package/dist/types/guests/seats.d.ts +39 -0
- package/dist/types/guests/serve.d.ts +17 -0
- package/dist/types/guests/view.d.ts +3 -0
- package/dist/types/host.d.ts +19 -2
- package/dist/types/index.d.ts +3 -0
- package/dist/types/owner.d.ts +4 -0
- package/dist/types/page.d.ts +1 -0
- package/dist/types/services.d.ts +34 -2
- package/dist/types/serving.d.ts +8 -1
- package/dist/types/spectrum/guest-port.d.ts +26 -0
- package/dist/types/spectrum/index.d.ts +13 -0
- package/dist/types/spectrum/proposals.d.ts +8 -0
- package/dist/worker.js +2 -1
- package/dist/worker.js.map +2 -2
- package/package.json +5 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { splitUser } from "../attachments.js";
|
|
2
|
+
import { GUEST_INPUT_KIND, guestText } from "../guests/attribution.js";
|
|
2
3
|
import { parseLick } from "../licks/lick.js";
|
|
3
4
|
import { entryLick, LICK_TOOLS, lickDecisions } from "../licks/state.js";
|
|
4
5
|
import { mcpLabel } from "../mcp/label.js";
|
|
@@ -199,6 +200,20 @@ function user(id, message, delivered, from) {
|
|
|
199
200
|
...from?.agent ? { origin: "agent" } : {}
|
|
200
201
|
};
|
|
201
202
|
}
|
|
203
|
+
function guestUser(id, message, delivered, data) {
|
|
204
|
+
const name = String(data?.name ?? "");
|
|
205
|
+
const shown = shownUser(message.content, `ref:${id.slice(1)}:0`);
|
|
206
|
+
return {
|
|
207
|
+
id,
|
|
208
|
+
role: "user",
|
|
209
|
+
...shown,
|
|
210
|
+
text: guestText(shown.text, name),
|
|
211
|
+
createdAt: message.timestamp ?? 0,
|
|
212
|
+
...delivered ? { delivered } : {},
|
|
213
|
+
from: name,
|
|
214
|
+
origin: "guest"
|
|
215
|
+
};
|
|
216
|
+
}
|
|
202
217
|
function origins(entries) {
|
|
203
218
|
const out = /* @__PURE__ */ new Map();
|
|
204
219
|
for (const entry of entries)
|
|
@@ -362,6 +377,8 @@ function entryMessage(entry, out, calls, delivered, notes) {
|
|
|
362
377
|
out.push(
|
|
363
378
|
lickMessage(id, entry, notes.decisions) ?? user(id, model, delivered, notes.origins.get(entry.id))
|
|
364
379
|
);
|
|
380
|
+
else if (entry.kind === GUEST_INPUT_KIND && model)
|
|
381
|
+
out.push(guestUser(id, model, delivered, entry.data));
|
|
365
382
|
else if (entry.kind === "pi.assistant" && model) {
|
|
366
383
|
const message = assistant(id, model);
|
|
367
384
|
out.push(withoutLickTools(message));
|
|
@@ -429,14 +446,19 @@ function isBusy(view) {
|
|
|
429
446
|
}
|
|
430
447
|
function queued(view, at = () => 0) {
|
|
431
448
|
const items = view?.docs["pi.inbox"]?.items ?? [];
|
|
432
|
-
return items.filter((item) => item.mode !== "write" && !parseLick(textOf(item.content))).map((item) =>
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
449
|
+
return items.filter((item) => item.mode !== "write" && !parseLick(textOf(item.content))).map((item) => {
|
|
450
|
+
const shown = shownUser(item.content);
|
|
451
|
+
const guest = item.entry?.kind === GUEST_INPUT_KIND ? String(item.entry.data?.name ?? "") : null;
|
|
452
|
+
return {
|
|
453
|
+
id: `q${item.id}`,
|
|
454
|
+
role: "user",
|
|
455
|
+
...shown,
|
|
456
|
+
...guest === null ? {} : { text: guestText(shown.text, guest), from: guest, origin: "guest" },
|
|
457
|
+
createdAt: at(`q${item.id}`),
|
|
458
|
+
queued: true,
|
|
459
|
+
mode: item.mode === "steer" ? "steer" : "queue"
|
|
460
|
+
};
|
|
461
|
+
});
|
|
440
462
|
}
|
|
441
463
|
export {
|
|
442
464
|
CONNECT_IT,
|
|
@@ -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 { parseLick } from '../licks/lick.ts';\nimport { entryLick, LICK_TOOLS, type LickDecision, lickDecisions } from '../licks/state.ts';\nimport { mcpLabel } from '../mcp/label.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';\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\nfunction title(args: Json | undefined): string {\n const subject = args?.command ?? args?.path;\n return typeof subject === 'string' ? subject : '';\n}\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(args, null, 2) };\n}\n\nfunction toolCall(block: Block): ToolCall {\n const args = block.arguments ?? {};\n return {\n id: block.id ?? '',\n name: block.name ?? 'tool',\n title: mcpLabel(block.name ?? '') ?? title(block.arguments),\n ...shape(block.name ?? 'tool', args),\n output: '',\n status: 'running',\n paths: paths(block.arguments),\n };\n}\n\nfunction part(block: Block): 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) };\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.';\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 if (unconnected.test(error))\n return {\n type: 'error',\n message: `${name} isn't connected.`,\n detail: CONNECT_IT,\n action: 'settings',\n };\n if (action === 'settings' && provider === 'adobe') {\n return adobeAuth.test(error)\n ? {\n type: 'error',\n message: 'Your Adobe session has expired.',\n detail: error,\n action: 'login',\n }\n : { type: 'error', ...proxyRefusal(error), action: 'retry' };\n }\n const lead =\n action === 'settings'\n ? missing.test(error)\n ? `${name} needs an API key.`\n : `${name} rejected the API key.`\n : action === 'change-model'\n ? \"This model isn't available with the current account.\"\n : null;\n return lead\n ? { type: 'error', message: lead, detail: error, action }\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): AssistantMessage {\n const blocks = Array.isArray(message.content) ? message.content : [];\n const parts = blocks.map(part).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\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\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: 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 };\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 };\n const what = 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\nfunction secrets(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as { names?: SecretName[] };\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: 'Secrets listed',\n text: listedLine(data.names ?? []),\n createdAt: entry.model?.[0]?.timestamp ?? 0,\n };\n}\n\nfunction entryMessage(\n entry: EntryRecord,\n out: Message[],\n calls: Map<string, ToolCall>,\n delivered: Delivered | undefined,\n notes: { decisions: ReadonlyMap<string, LickDecision>; origins: ReadonlyMap<number, From> }\n): void {\n const id = `e${entry.id}`;\n const model = entry.model?.[0] as ModelMessage | undefined;\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 === 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 === 'pi.assistant' && model) {\n const message = assistant(id, model);\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 live(view: ConversationView, out: Message[], calls: Map<string, ToolCall>): 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'));\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): Message[] {\n const out: Message[] = [];\n if (!view) return out;\n const calls = new Map<string, ToolCall>();\n const notes = { decisions: lickDecisions(view.entries), origins: origins(view.entries) };\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);\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 }[];\n return items\n .filter((item) => item.mode !== 'write' && !parseLick(textOf(item.content)))\n .map((item) => ({\n id: `q${item.id}`,\n role: 'user' as const,\n ...shownUser(item.content),\n createdAt: at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AAK,EAAE,EAAE;AAAA,IAC3B,QAAQ;AAAA,IACR,MAAM,KAAK,SAAS,UAAU,UAAU;AAAA,EAC1C,EAAE;AACN;",
|
|
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 { GUEST_INPUT_KIND, type GuestInput, guestText } from '../guests/attribution.ts';\nimport { parseLick } from '../licks/lick.ts';\nimport { entryLick, LICK_TOOLS, type LickDecision, lickDecisions } from '../licks/state.ts';\nimport { mcpLabel } from '../mcp/label.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';\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\nfunction title(args: Json | undefined): string {\n const subject = args?.command ?? args?.path;\n return typeof subject === 'string' ? subject : '';\n}\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(args, null, 2) };\n}\n\nfunction toolCall(block: Block): ToolCall {\n const args = block.arguments ?? {};\n return {\n id: block.id ?? '',\n name: block.name ?? 'tool',\n title: mcpLabel(block.name ?? '') ?? title(block.arguments),\n ...shape(block.name ?? 'tool', args),\n output: '',\n status: 'running',\n paths: paths(block.arguments),\n };\n}\n\nfunction part(block: Block): 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) };\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.';\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 if (unconnected.test(error))\n return {\n type: 'error',\n message: `${name} isn't connected.`,\n detail: CONNECT_IT,\n action: 'settings',\n };\n if (action === 'settings' && provider === 'adobe') {\n return adobeAuth.test(error)\n ? {\n type: 'error',\n message: 'Your Adobe session has expired.',\n detail: error,\n action: 'login',\n }\n : { type: 'error', ...proxyRefusal(error), action: 'retry' };\n }\n const lead =\n action === 'settings'\n ? missing.test(error)\n ? `${name} needs an API key.`\n : `${name} rejected the API key.`\n : action === 'change-model'\n ? \"This model isn't available with the current account.\"\n : null;\n return lead\n ? { type: 'error', message: lead, detail: error, action }\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): AssistantMessage {\n const blocks = Array.isArray(message.content) ? message.content : [];\n const parts = blocks.map(part).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 name = String((data as Partial<GuestInput> | undefined)?.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 };\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\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: 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 };\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 };\n const what = 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\nfunction secrets(id: string, entry: EntryRecord): SystemMessage {\n const data = (entry.data ?? {}) as { names?: SecretName[] };\n return {\n id,\n role: 'system',\n kind: 'notice',\n title: 'Secrets listed',\n text: listedLine(data.names ?? []),\n createdAt: entry.model?.[0]?.timestamp ?? 0,\n };\n}\n\nfunction entryMessage(\n entry: EntryRecord,\n out: Message[],\n calls: Map<string, ToolCall>,\n delivered: Delivered | undefined,\n notes: { decisions: ReadonlyMap<string, LickDecision>; origins: ReadonlyMap<number, From> }\n): void {\n const id = `e${entry.id}`;\n const model = entry.model?.[0] as ModelMessage | undefined;\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 === 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);\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 live(view: ConversationView, out: Message[], calls: Map<string, ToolCall>): 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'));\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): Message[] {\n const out: Message[] = [];\n if (!view) return out;\n const calls = new Map<string, ToolCall>();\n const notes = { decisions: lickDecisions(view.entries), origins: origins(view.entries) };\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);\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 guest =\n item.entry?.kind === GUEST_INPUT_KIND ? String(item.entry.data?.name ?? '') : null;\n return {\n id: `q${item.id}`,\n role: 'user' as const,\n ...shown,\n ...(guest === null\n ? {}\n : { text: guestText(shown.text, guest), from: guest, origin: 'guest' as const }),\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,SAAS,kBAAmC,iBAAiB;AAC7D,SAAS,iBAAiB;AAC1B,SAAS,WAAW,YAA+B,qBAAqB;AACxE,SAAS,gBAAgB;AACzB,SAAS,iBAA4B;AAErC,SAAS,YAAY,oBAAoB;AAEzC,SAAS,qBAAqB;AA8CvB,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,C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,WAAO;AAAA,MACL,IAAI,IAAI,KAAK,EAAE;AAAA,MACf,MAAM;AAAA,MACN,GAAG;AAAA,MACH,GAAI,UAAU,OACV,CAAC,IACD,EAAE,MAAM,UAAU,MAAM,MAAM,KAAK,GAAG,MAAM,OAAO,QAAQ,QAAiB;AAAA,MAChF,WAAW,GAAG,IAAI,KAAK,EAAE,EAAE;AAAA,MAC3B,QAAQ;AAAA,MACR,MAAM,KAAK,SAAS,UAAU,UAAU;AAAA,IAC1C;AAAA,EACF,CAAC;AACL;",
|
|
6
6
|
"names": ["note", "part"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const UNANSWERED = "Nobody approved this in time.";
|
|
2
|
+
const DECLINED = "It was declined.";
|
|
3
|
+
const WITHDRAWN = "It was withdrawn.";
|
|
4
|
+
const ENDED = {
|
|
5
|
+
unanswered: UNANSWERED,
|
|
6
|
+
rejected: DECLINED,
|
|
7
|
+
withdrawn: WITHDRAWN
|
|
8
|
+
};
|
|
9
|
+
function proposalQueue(proposals, label) {
|
|
10
|
+
return (proposals ?? []).filter((proposal) => proposal.state === "pending").map((proposal) => ({
|
|
11
|
+
id: `g${proposal.id}`,
|
|
12
|
+
role: "user",
|
|
13
|
+
text: proposal.text,
|
|
14
|
+
createdAt: proposal.createdAt,
|
|
15
|
+
queued: true,
|
|
16
|
+
mode: "queue",
|
|
17
|
+
from: label,
|
|
18
|
+
origin: "guest"
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
function proposalNotices(proposals) {
|
|
22
|
+
return (proposals ?? []).flatMap((proposal) => {
|
|
23
|
+
const title = ENDED[proposal.state];
|
|
24
|
+
if (!title) return [];
|
|
25
|
+
return [
|
|
26
|
+
{
|
|
27
|
+
id: `g${proposal.id}`,
|
|
28
|
+
role: "system",
|
|
29
|
+
kind: "notice",
|
|
30
|
+
title,
|
|
31
|
+
text: proposal.text,
|
|
32
|
+
createdAt: proposal.decidedAt ?? proposal.createdAt
|
|
33
|
+
}
|
|
34
|
+
];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function merged(messages, notices) {
|
|
38
|
+
if (!notices.length) return [...messages];
|
|
39
|
+
const out = [];
|
|
40
|
+
const left = [...notices].sort((a, b) => a.createdAt - b.createdAt);
|
|
41
|
+
for (const message of messages) {
|
|
42
|
+
while (left.length && left[0].createdAt < message.createdAt)
|
|
43
|
+
out.push(left.shift());
|
|
44
|
+
out.push(message);
|
|
45
|
+
}
|
|
46
|
+
return [...out, ...left];
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
DECLINED,
|
|
50
|
+
UNANSWERED,
|
|
51
|
+
WITHDRAWN,
|
|
52
|
+
merged,
|
|
53
|
+
proposalNotices,
|
|
54
|
+
proposalQueue
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=proposals.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/spectrum/proposals.ts"],
|
|
4
|
+
"sourcesContent": ["import type { Message, SystemMessage, UserMessage } from '@ai-ecoverse/slicc-spectrum/ui';\nimport type { GuestProposal } from '../services.ts';\n\nexport const UNANSWERED = 'Nobody approved this in time.';\nexport const DECLINED = 'It was declined.';\nexport const WITHDRAWN = 'It was withdrawn.';\n\nconst ENDED: Record<string, string> = {\n unanswered: UNANSWERED,\n rejected: DECLINED,\n withdrawn: WITHDRAWN,\n};\n\nexport function proposalQueue(\n proposals: readonly GuestProposal[] | undefined,\n label: string\n): UserMessage[] {\n return (proposals ?? [])\n .filter((proposal) => proposal.state === 'pending')\n .map((proposal) => ({\n id: `g${proposal.id}`,\n role: 'user',\n text: proposal.text,\n createdAt: proposal.createdAt,\n queued: true,\n mode: 'queue',\n from: label,\n origin: 'guest',\n }));\n}\n\nexport function proposalNotices(proposals: readonly GuestProposal[] | undefined): SystemMessage[] {\n return (proposals ?? []).flatMap((proposal) => {\n const title = ENDED[proposal.state];\n if (!title) return [];\n return [\n {\n id: `g${proposal.id}`,\n role: 'system',\n kind: 'notice',\n title,\n text: proposal.text,\n createdAt: proposal.decidedAt ?? proposal.createdAt,\n },\n ];\n });\n}\n\nexport function merged(messages: readonly Message[], notices: readonly SystemMessage[]): Message[] {\n if (!notices.length) return [...messages];\n const out: Message[] = [];\n const left = [...notices].sort((a, b) => a.createdAt - b.createdAt);\n for (const message of messages) {\n while (left.length && (left[0] as SystemMessage).createdAt < message.createdAt)\n out.push(left.shift() as SystemMessage);\n out.push(message);\n }\n return [...out, ...left];\n}\n"],
|
|
5
|
+
"mappings": "AAGO,MAAM,aAAa;AACnB,MAAM,WAAW;AACjB,MAAM,YAAY;AAEzB,MAAM,QAAgC;AAAA,EACpC,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,WAAW;AACb;AAEO,SAAS,cACd,WACA,OACe;AACf,UAAQ,aAAa,CAAC,GACnB,OAAO,CAAC,aAAa,SAAS,UAAU,SAAS,EACjD,IAAI,CAAC,cAAc;AAAA,IAClB,IAAI,IAAI,SAAS,EAAE;AAAA,IACnB,MAAM;AAAA,IACN,MAAM,SAAS;AAAA,IACf,WAAW,SAAS;AAAA,IACpB,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,EACV,EAAE;AACN;AAEO,SAAS,gBAAgB,WAAkE;AAChG,UAAQ,aAAa,CAAC,GAAG,QAAQ,CAAC,aAAa;AAC7C,UAAM,QAAQ,MAAM,SAAS,KAAK;AAClC,QAAI,CAAC,MAAO,QAAO,CAAC;AACpB,WAAO;AAAA,MACL;AAAA,QACE,IAAI,IAAI,SAAS,EAAE;AAAA,QACnB,MAAM;AAAA,QACN,MAAM;AAAA,QACN;AAAA,QACA,MAAM,SAAS;AAAA,QACf,WAAW,SAAS,aAAa,SAAS;AAAA,MAC5C;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,SAAS,OAAO,UAA8B,SAA8C;AACjG,MAAI,CAAC,QAAQ,OAAQ,QAAO,CAAC,GAAG,QAAQ;AACxC,QAAM,MAAiB,CAAC;AACxB,QAAM,OAAO,CAAC,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,YAAY,EAAE,SAAS;AAClE,aAAW,WAAW,UAAU;AAC9B,WAAO,KAAK,UAAW,KAAK,CAAC,EAAoB,YAAY,QAAQ;AACnE,UAAI,KAAK,KAAK,MAAM,CAAkB;AACxC,QAAI,KAAK,OAAO;AAAA,EAClB;AACA,SAAO,CAAC,GAAG,KAAK,GAAG,IAAI;AACzB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -3,11 +3,12 @@ import type { ConversationView } from '@earendil-works/pi-durable';
|
|
|
3
3
|
import type { Approval } from './approvals/record.ts';
|
|
4
4
|
import type { ChangesView } from './changes/git.ts';
|
|
5
5
|
import type { FrozenCone } from './freezer/index.ts';
|
|
6
|
+
import type { GuestSeat } from './guests/seats.ts';
|
|
6
7
|
import type { MemoryEntry, MemoryScope } from './memory/format.ts';
|
|
7
8
|
import type { AgentRemote } from './remote/host.ts';
|
|
8
9
|
import type { AgentPages } from './remote/pages.ts';
|
|
9
10
|
import type { VaultState } from './secrets/vault.ts';
|
|
10
|
-
import { AgentControl, AgentSettings, type AgentsSummary, type Command, type Delivered, type MonitorFeed, type PrivateRevision, type SendMode } from './services.ts';
|
|
11
|
+
import { AgentControl, AgentSettings, type AgentsSummary, type Command, type Delivered, type GuestProposal, type GuestShown, type MonitorFeed, type PrivateRevision, type SendMode } from './services.ts';
|
|
11
12
|
import type { Sprinkle } from './sprinkles/kind.ts';
|
|
12
13
|
import { type PortEndpoint } from './wire.ts';
|
|
13
14
|
export interface AgentConnection {
|
|
@@ -27,6 +28,11 @@ export interface AgentConnection {
|
|
|
27
28
|
readonly monitor?: ReplicatedState<MonitorFeed>;
|
|
28
29
|
readonly vault?: ReplicatedState<VaultState>;
|
|
29
30
|
readonly labels?: ReplicatedState<Record<string, string>>;
|
|
31
|
+
readonly guests?: ReplicatedState<GuestSeat[]>;
|
|
32
|
+
readonly viewOnly?: boolean;
|
|
33
|
+
readonly guest?: GuestShown;
|
|
34
|
+
readonly proposals?: ReplicatedState<GuestProposal[]>;
|
|
35
|
+
readonly owner?: boolean;
|
|
30
36
|
readonly approvals?: ReplicatedState<Approval[]>;
|
|
31
37
|
readonly settings: AgentSettings;
|
|
32
38
|
readonly remote?: AgentRemote;
|
package/dist/types/control.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ChangesRuntime } from './changes/index.ts';
|
|
|
3
3
|
import type { Cones } from './cone.ts';
|
|
4
4
|
import type { Deliveries } from './deliveries.ts';
|
|
5
5
|
import type { FreezerRuntime } from './freezer/index.ts';
|
|
6
|
+
import type { Guests } from './guests/index.ts';
|
|
6
7
|
import type { LickSources, Licks } from './licks/index.ts';
|
|
7
8
|
import type { MemoryRuntime } from './memory/index.ts';
|
|
8
9
|
import type { Monitor } from './monitor/index.ts';
|
|
@@ -23,4 +24,4 @@ export interface HostScoops {
|
|
|
23
24
|
}
|
|
24
25
|
export declare function readable(out: string): string;
|
|
25
26
|
export declare function submissionId(value: string): SubmissionId | undefined;
|
|
26
|
-
export declare function createAgentControl(harness: Harness, target: Conversation | Cones, deliveries?: Deliveries, licks?: HostLicks, scoops?: HostScoops, skills?: Pick<SkillsRuntime, 'expand' | 'commandsFor'>, sprinkles?: Pick<SprinklesRuntime, 'send' | 'call'>, memory?: Pick<MemoryRuntime, 'save' | 'remove'>, freezer?: Pick<FreezerRuntime, 'freeze' | 'newChat' | 'thaw' | 'discard'>, changes?: Pick<ChangesRuntime, 'open' | 'accept' | 'revert'>, monitor?: Pick<Monitor, 'open' | 'close'>, secrets?: () => readonly SecretName[], uploads?: Uploads, labels?: Pick<LabelsRuntime, 'label'>): AgentControl;
|
|
27
|
+
export declare function createAgentControl(harness: Harness, target: Conversation | Cones, deliveries?: Deliveries, licks?: HostLicks, scoops?: HostScoops, skills?: Pick<SkillsRuntime, 'expand' | 'commandsFor'>, sprinkles?: Pick<SprinklesRuntime, 'send' | 'call'>, memory?: Pick<MemoryRuntime, 'save' | 'remove'>, freezer?: Pick<FreezerRuntime, 'freeze' | 'newChat' | 'thaw' | 'discard'>, changes?: Pick<ChangesRuntime, 'open' | 'accept' | 'revert'>, monitor?: Pick<Monitor, 'open' | 'close'>, secrets?: () => readonly SecretName[], uploads?: Uploads, labels?: Pick<LabelsRuntime, 'label'>, guests?: Pick<Guests, 'open' | 'revoke'>): AgentControl;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const GUEST_INPUT_KIND = "slicc.guest-input";
|
|
2
|
+
export type GuestInput = {
|
|
3
|
+
seat: string;
|
|
4
|
+
name: string;
|
|
5
|
+
approval: string | null;
|
|
6
|
+
};
|
|
7
|
+
export declare function guestContent(name: string, text: string): string;
|
|
8
|
+
export declare function guestHeader(name: string): string;
|
|
9
|
+
export declare function guestText(text: string, name: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type AgentConnection } from '../client.ts';
|
|
2
|
+
import { type GuestShown } from '../services.ts';
|
|
3
|
+
import { type PortEndpoint } from '../wire.ts';
|
|
4
|
+
import type { Proposed, ProposeRequest } from './index.ts';
|
|
5
|
+
export declare const GUEST_ONLY = "a guest can only watch and send messages";
|
|
6
|
+
export declare const SEAT_REFUSED = "This guest link isn't valid any more.";
|
|
7
|
+
export declare const proposedSentence: (reason: string) => string;
|
|
8
|
+
export interface GuestConnection extends AgentConnection {
|
|
9
|
+
readonly guest: GuestShown;
|
|
10
|
+
propose(request: ProposeRequest): Promise<Proposed>;
|
|
11
|
+
}
|
|
12
|
+
export declare function connectGuest(endpoint: PortEndpoint): Promise<GuestConnection | AgentConnection>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type Extension, type Harness } from '@earendil-works/pi-durable';
|
|
2
|
+
export declare const GUEST_GUARD = "slicc-guest-guard";
|
|
3
|
+
export declare const GUEST_REQUEST = "guest:";
|
|
4
|
+
export declare const GUEST_TOOLS_BLOCKED = "Tool calls in a run a guest started need a review, which this agent can't do yet.";
|
|
5
|
+
export declare function guestGuard(harness: () => Pick<Harness, 'submission'> | undefined): Extension;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type Context, type ReplicatedState } from '@earendil-works/chord';
|
|
2
|
+
import { type Harness } from '@earendil-works/pi-durable';
|
|
3
|
+
import type { Agents } from '../agents.ts';
|
|
4
|
+
import type { Approvals } from '../approvals/index.ts';
|
|
5
|
+
import type { GuestPrincipal } from '../serving.ts';
|
|
6
|
+
import { type GuestDraft, type GuestSeat, type SeatRecord } from './seats.ts';
|
|
7
|
+
export type GuestOpened = {
|
|
8
|
+
seat: GuestSeat;
|
|
9
|
+
error: null;
|
|
10
|
+
} | {
|
|
11
|
+
seat: null;
|
|
12
|
+
error: string;
|
|
13
|
+
};
|
|
14
|
+
export type Proposed = {
|
|
15
|
+
state: 'submitted';
|
|
16
|
+
submissionId: string;
|
|
17
|
+
reason: null;
|
|
18
|
+
} | {
|
|
19
|
+
state: 'pending';
|
|
20
|
+
submissionId: null;
|
|
21
|
+
approval: string;
|
|
22
|
+
reason: null;
|
|
23
|
+
} | {
|
|
24
|
+
state: 'unanswered';
|
|
25
|
+
submissionId: null;
|
|
26
|
+
reason: string;
|
|
27
|
+
};
|
|
28
|
+
export interface ProposeRequest {
|
|
29
|
+
text: string;
|
|
30
|
+
requestId: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface Guests {
|
|
33
|
+
readonly seats: ReplicatedState<GuestSeat[]>;
|
|
34
|
+
open(draft: GuestDraft, context: Context): Promise<GuestOpened>;
|
|
35
|
+
revoke(id: string, context: Context): Promise<{
|
|
36
|
+
revoked: boolean;
|
|
37
|
+
}>;
|
|
38
|
+
admit(id: string, label: string): GuestPrincipal | null;
|
|
39
|
+
record(id: string): SeatRecord | undefined;
|
|
40
|
+
current(guest: GuestPrincipal): SeatRecord | undefined;
|
|
41
|
+
joined(id: string): () => void;
|
|
42
|
+
onEnd(listener: (id: string) => void): () => void;
|
|
43
|
+
propose(guest: GuestPrincipal, request: ProposeRequest, context: Context): Promise<Proposed>;
|
|
44
|
+
dispose(): void;
|
|
45
|
+
}
|
|
46
|
+
export interface GuestsOptions {
|
|
47
|
+
harness: Pick<Harness, 'commit' | 'abortSubmission'>;
|
|
48
|
+
agents: Pick<Agents, 'state' | 'conversation'>;
|
|
49
|
+
approvals?: Pick<Approvals, 'state' | 'request' | 'withdrawSeat'>;
|
|
50
|
+
now?: () => number;
|
|
51
|
+
context?: Context;
|
|
52
|
+
}
|
|
53
|
+
export declare const MAX_PROPOSAL = 32000;
|
|
54
|
+
export declare function createGuests(options: GuestsOptions): Promise<Guests>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ApprovalTier } from '../approvals/record.ts';
|
|
2
|
+
export type GuestGate = ApprovalTier | 'off';
|
|
3
|
+
export type GuestGates = {
|
|
4
|
+
messages: GuestGate;
|
|
5
|
+
tools: GuestGate;
|
|
6
|
+
};
|
|
7
|
+
export type GuestDraft = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
agentId: string;
|
|
11
|
+
expiresAt: number | null;
|
|
12
|
+
gates: GuestGates;
|
|
13
|
+
};
|
|
14
|
+
export type SeatRecord = GuestDraft & {
|
|
15
|
+
createdAt: number;
|
|
16
|
+
epoch: number;
|
|
17
|
+
revoked: number | null;
|
|
18
|
+
delivered?: string[];
|
|
19
|
+
};
|
|
20
|
+
export interface GuestSeat {
|
|
21
|
+
id: string;
|
|
22
|
+
label: string;
|
|
23
|
+
agentId: string;
|
|
24
|
+
createdAt: number;
|
|
25
|
+
expiresAt: number | null;
|
|
26
|
+
gates: GuestGates;
|
|
27
|
+
connected: boolean;
|
|
28
|
+
pending: number;
|
|
29
|
+
}
|
|
30
|
+
export type GuestsState = {
|
|
31
|
+
seats: Record<string, SeatRecord>;
|
|
32
|
+
};
|
|
33
|
+
export declare const GuestsDoc: import("@earendil-works/pi-durable").SessionDocToken<GuestsState>;
|
|
34
|
+
export declare const MAX_SEAT_MS: number;
|
|
35
|
+
export declare const MAX_LABEL = 64;
|
|
36
|
+
export declare function cleanLabel(raw: unknown): string;
|
|
37
|
+
export declare function isGate(value: unknown): value is GuestGate;
|
|
38
|
+
export declare function checkDraft(draft: GuestDraft, now: number): string | null;
|
|
39
|
+
export declare function liveSeat(seat: SeatRecord | undefined, now: number): boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Context, Host, ReplicatedState } from '@earendil-works/chord';
|
|
2
|
+
import type { ConversationView } from '@earendil-works/pi-durable';
|
|
3
|
+
import type { Agents } from '../agents.ts';
|
|
4
|
+
import type { Approval } from '../approvals/index.ts';
|
|
5
|
+
import type { AgentGuest, GuestProposal } from '../services.ts';
|
|
6
|
+
import type { GuestPrincipal } from '../serving.ts';
|
|
7
|
+
import { type PortEndpoint } from '../wire.ts';
|
|
8
|
+
import type { Guests } from './index.ts';
|
|
9
|
+
export declare function proposalsOf(items: readonly Approval[] | undefined, seat: string): GuestProposal[];
|
|
10
|
+
export declare function guestOpener(guests: Guests, agents: Pick<Agents, 'state'>, views: ReplicatedState<Record<string, ConversationView>>, context: Context, approvals?: ReplicatedState<Approval[]>): (principal: GuestPrincipal) => {
|
|
11
|
+
value: AgentGuest;
|
|
12
|
+
dispose(): void;
|
|
13
|
+
} | undefined;
|
|
14
|
+
export declare function admitGuest(guests: Guests, endpoint: PortEndpoint, asked: {
|
|
15
|
+
id: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}, serverId: string, link: number, host: Pick<Host, 'accept'>): void;
|
package/dist/types/host.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { type Context, type Host, type ReplicatedState } from '@earendil-works/chord';
|
|
1
|
+
import { type Context, type Host, type Readable, type ReplicatedState } from '@earendil-works/chord';
|
|
2
2
|
import type { Agent } from './agent.ts';
|
|
3
3
|
import { type ApprovalJudge, type Approvals, type DecidedBy } from './approvals/index.ts';
|
|
4
4
|
import type { ChangesRuntime } from './changes/index.ts';
|
|
5
5
|
import { type HostLicks, type HostScoops } from './control.ts';
|
|
6
6
|
import type { FreezerRuntime } from './freezer/index.ts';
|
|
7
|
+
import { type Guests } from './guests/index.ts';
|
|
7
8
|
import type { UserClients } from './kernel/users.ts';
|
|
8
9
|
import type { McpRuntime } from './mcp/index.ts';
|
|
9
10
|
import type { MemoryRuntime } from './memory/index.ts';
|
|
@@ -12,7 +13,8 @@ import { type AgentRemote } from './remote/host.ts';
|
|
|
12
13
|
import { type Pages } from './remote/pages.ts';
|
|
13
14
|
import type { SecretName } from './secrets/names.ts';
|
|
14
15
|
import type { VaultState } from './secrets/vault.ts';
|
|
15
|
-
import { AgentControl, AgentSettings, AgentTranscript } from './services.ts';
|
|
16
|
+
import { AgentControl, type AgentGuest, AgentSettings, AgentTranscript } from './services.ts';
|
|
17
|
+
import { type GuestPrincipal, type Seat } from './serving.ts';
|
|
16
18
|
import type { SkillsRuntime } from './skills/index.ts';
|
|
17
19
|
import type { SprinklesRuntime } from './sprinkles/index.ts';
|
|
18
20
|
import { type Thumbnail } from './thumbs.ts';
|
|
@@ -22,12 +24,17 @@ import { type PortEndpoint } from './wire.ts';
|
|
|
22
24
|
export interface ConnectOptions {
|
|
23
25
|
readOnly?: boolean;
|
|
24
26
|
pages?: boolean;
|
|
27
|
+
guest?: {
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
};
|
|
25
31
|
}
|
|
26
32
|
export interface AgentHost {
|
|
27
33
|
readonly serverId: string;
|
|
28
34
|
readonly agent: Agent;
|
|
29
35
|
readonly users?: UserClients;
|
|
30
36
|
readonly pages: Pages;
|
|
37
|
+
readonly guests: Guests;
|
|
31
38
|
readonly approvals: Approvals;
|
|
32
39
|
connect(endpoint: PortEndpoint, options?: ConnectOptions): void;
|
|
33
40
|
close(): Promise<void>;
|
|
@@ -67,7 +74,17 @@ interface Served {
|
|
|
67
74
|
settings: AgentSettings;
|
|
68
75
|
remote: AgentRemote;
|
|
69
76
|
pages: Pages;
|
|
77
|
+
guest?: (principal: GuestPrincipal) => {
|
|
78
|
+
value: AgentGuest;
|
|
79
|
+
dispose(): void;
|
|
80
|
+
} | undefined;
|
|
70
81
|
decide: (by: DecidedBy) => AgentControl['decide'];
|
|
71
82
|
}
|
|
83
|
+
export declare const CLOSED_TO_GUESTS = "a guest seat has only its transcript and propose";
|
|
84
|
+
export declare const openToGuests: <F extends object>(factory: F) => F;
|
|
85
|
+
export declare function closedToGuests(host: Host): Host;
|
|
86
|
+
export declare function lazily<T>(state: () => ReplicatedState<T>): Readable<T>;
|
|
87
|
+
export declare const GUEST_MANAGERS: ReadonlySet<Seat>;
|
|
88
|
+
export declare const OWNER_GUESTS = "only the owner can invite or revoke guests";
|
|
72
89
|
export declare function serveAgent(serving: Served): Host;
|
|
73
90
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ export { APPROVAL_MS, type Approval, type ApprovalAnswer, type ApprovalDecided,
|
|
|
4
4
|
export { FILE_LIMIT, IMAGE_LIMIT, type SendAttachment, type ShownAttachment, splitUser, TOTAL_LIMIT, userParts, } from './attachments.ts';
|
|
5
5
|
export { type AgentConnection, connectAgent } from './client.ts';
|
|
6
6
|
export { createAgentControl } from './control.ts';
|
|
7
|
+
export { connectGuest, GUEST_ONLY, type GuestConnection, SEAT_REFUSED, } from './guests/client.ts';
|
|
8
|
+
export type { GuestOpened, Proposed, ProposeRequest } from './guests/index.ts';
|
|
9
|
+
export type { GuestDraft, GuestGate, GuestGates, GuestSeat } from './guests/seats.ts';
|
|
7
10
|
export { type AgentHost, type ConnectOptions, hostAgent } from './host.ts';
|
|
8
11
|
export type { KernelClient, KernelFs, KernelProcess, KernelStat, SpawnOptions, } from './kernel/client.ts';
|
|
9
12
|
export { HOME, type KernelEnvOptions, kernelEnvironment, SliccKernelEnv } from './kernel/env.ts';
|
package/dist/types/owner.d.ts
CHANGED
package/dist/types/page.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { type AgentConnection, connectAgent } from './client.ts';
|
|
2
|
+
export { connectGuest, GUEST_ONLY, type GuestConnection, SEAT_REFUSED, } from './guests/client.ts';
|
|
2
3
|
export { type ByteSink, bridgePort, encodeFrame, FrameReader, type LinkEnd, linkEndpoint, MAX_FRAME, } from './link.ts';
|
|
3
4
|
export { AGENT_LOCK, type AgentOwner, type AgentWorker, type KernelSource, type OwnerOptions, type PortOptions, startAgent, } from './owner.ts';
|
|
4
5
|
export { type RemoteControl, type RemoteEvent, type RemoteOptions, remoteControl, } from './remote/client.ts';
|