@stjbrown/agent-knowledge 0.1.0-beta.3 → 0.1.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1 -1
- package/dist/{tui-GCLV5CZQ.js → tui-6LNJ6LCX.js} +12 -2
- package/dist/tui-6LNJ6LCX.js.map +1 -0
- package/package.json +1 -1
- package/skills/kb/SKILL.md +5 -0
- package/skills/kb/example-bundle/spec/types.md +3 -2
- package/skills/kb-ingest/SKILL.md +21 -3
- package/skills/kb-init/SKILL.md +16 -5
- package/skills/kb-lint/SKILL.md +6 -1
- package/dist/tui-GCLV5CZQ.js.map +0 -1
package/dist/main.js
CHANGED
|
@@ -309,7 +309,7 @@ async function main(argv) {
|
|
|
309
309
|
const sub = parsed.subcommand;
|
|
310
310
|
if (!sub) {
|
|
311
311
|
if (!headless) {
|
|
312
|
-
const { runTui } = await import("./tui-
|
|
312
|
+
const { runTui } = await import("./tui-6LNJ6LCX.js");
|
|
313
313
|
if (modelId && !process.env["JANET_MODEL"]) process.env["JANET_MODEL"] = modelId;
|
|
314
314
|
return runTui({ dir, bundle: bundleOverride, threadId });
|
|
315
315
|
}
|
|
@@ -61,6 +61,16 @@ function toolActivityLabel(toolName) {
|
|
|
61
61
|
}
|
|
62
62
|
return "Janet is working\u2026";
|
|
63
63
|
}
|
|
64
|
+
function toolErrorLabel(result) {
|
|
65
|
+
const detail = String(result);
|
|
66
|
+
const readRequired = detail.match(
|
|
67
|
+
/File "([^"]+)" (?:has not been read|was modified since last read)/
|
|
68
|
+
);
|
|
69
|
+
if (readRequired) {
|
|
70
|
+
return `Update paused: Janet needs to re-read "${readRequired[1]}" first.`;
|
|
71
|
+
}
|
|
72
|
+
return `Tool error: ${detail.slice(0, 140)}`;
|
|
73
|
+
}
|
|
64
74
|
|
|
65
75
|
// src/tui/theme.ts
|
|
66
76
|
import chalk from "chalk";
|
|
@@ -257,7 +267,7 @@ async function runTui(opts) {
|
|
|
257
267
|
);
|
|
258
268
|
if (event.isError) {
|
|
259
269
|
closeSegment();
|
|
260
|
-
addLine(c.warn(`
|
|
270
|
+
addLine(c.warn(` ${toolErrorLabel(event.result)}`));
|
|
261
271
|
}
|
|
262
272
|
break;
|
|
263
273
|
case "tool_suspended": {
|
|
@@ -566,4 +576,4 @@ Ask me anything in the bundle, or say what to ingest. /help for commands.`
|
|
|
566
576
|
export {
|
|
567
577
|
runTui
|
|
568
578
|
};
|
|
569
|
-
//# sourceMappingURL=tui-
|
|
579
|
+
//# sourceMappingURL=tui-6LNJ6LCX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/tui/index.ts","../src/tui/activity.ts","../src/tui/theme.ts"],"sourcesContent":["/**\n * Janet's interactive TUI — a minimal pi-tui chat.\n *\n * The transcript renders in strict chronological order: each run of assistant\n * text becomes its own markdown block, and a tool line / question / approval\n * \"closes\" the current block so the next text appears BELOW it (rather than the\n * whole answer streaming at the top while tools pile up underneath).\n *\n * Approvals are governed by the controller's tool-category policy: reads,\n * skills, task bookkeeping, ask_user, and bundle edits never prompt. Execution,\n * MCP, and unknown future tools ask — and the prompt offers \"always allow\" for\n * the session. Questions with options render as an arrow-key SelectList.\n */\nimport {\n Container,\n Editor,\n Loader,\n Markdown,\n ProcessTerminal,\n SelectList,\n Spacer,\n TUI,\n Text,\n} from \"@earendil-works/pi-tui\";\nimport type { Component, SelectItem } from \"@earendil-works/pi-tui\";\nimport type { AgentControllerEvent } from \"@mastra/core/agent-controller\";\nimport { bootJanet, type BootOptions } from \"../agent/controller.js\";\nimport { messageText } from \"../headless/format.js\";\nimport { GREETING } from \"../agent/persona.js\";\nimport { getAuthStorage } from \"../gateways/oauth/claude-max.js\";\nimport { loadSettings, completeOnboarding, rememberModel } from \"../onboarding/settings.js\";\nimport { availableModels, normalizeModelSelection } from \"../onboarding/providers.js\";\nimport { toolActivityLabel, toolErrorLabel } from \"./activity.js\";\nimport { c, editorTheme, markdownTheme } from \"./theme.js\";\n\n/** OAuth providers janet can log in to. */\nconst OAUTH_PROVIDERS = [\"anthropic\", \"openai-codex\"] as const;\n\n/** Editor with a Ctrl+C hook (raw-mode terminals deliver it as input \\x03). */\nclass JanetEditor extends Editor {\n onCtrlC?: () => void;\n override handleInput(data: string): void {\n if (data === \"\\x03\") {\n this.onCtrlC?.();\n return;\n }\n super.handleInput(data);\n }\n}\n\nconst HELP_TEXT = `Commands:\n /models Pick a model from a list (arrow keys)\n /model [provider/id] Open the picker, or switch directly by id\n /login <provider> [mode]\n Log in; OpenAI mode is browser or device\n /logout <provider> Remove stored credentials for a provider\n /auth Show which providers are authenticated\n /help This help\n /quit Exit (double Ctrl+C also works)\n\nAnything else is a message to Janet.`;\n\ninterface PendingApproval {\n toolCallId: string;\n toolName: string;\n}\n\ninterface QuestionOption {\n label: string;\n description?: string;\n}\n\ninterface PendingQuestion {\n toolCallId: string;\n options?: QuestionOption[];\n multi: boolean;\n}\n\n/** The assistant text block currently being streamed (one segment between tools). */\ninterface ActiveMessage {\n id: string;\n committedLen: number;\n comp: Markdown | null;\n lastText: string;\n}\n\n/** Map a typed answer to ask_user resume data (free-text or multi-select). */\nfunction resolveAnswer(q: PendingQuestion, text: string): string | string[] | undefined {\n if (!q.options?.length) return text;\n const opts = q.options;\n const pick = (token: string): string | undefined => {\n const t = token.trim();\n if (!t) return undefined;\n const n = Number(t);\n if (Number.isInteger(n) && n >= 1 && n <= opts.length) return opts[n - 1]!.label;\n const exact = opts.find((o) => o.label.toLowerCase() === t.toLowerCase());\n if (exact) return exact.label;\n return opts.find((o) => o.label.toLowerCase().startsWith(t.toLowerCase()))?.label;\n };\n if (q.multi) {\n const picks = text.split(\",\").map(pick);\n return picks.some((p) => p === undefined) ? undefined : (picks as string[]);\n }\n return pick(text);\n}\n\nexport async function runTui(opts: Omit<BootOptions, \"interactive\">): Promise<number> {\n const { controller, session, paths, herdrDetach } = await bootJanet({ ...opts, interactive: true });\n\n // The interactive approval policy is set deterministically in the controller's\n // initialState (reads/edits/meta never prompt; only execute asks, with an\n // \"always allow\" option) — see INTERACTIVE_RULES in controller.ts.\n\n // Model precedence: an already-persisted per-thread selection, else\n // JANET_MODEL, else the global onboarding default. If none, the first-run\n // wizard runs after the UI is up.\n const persistedModel = process.env[\"JANET_MODEL\"] || loadSettings().defaultModelId;\n const presetModel = persistedModel\n ? normalizeModelSelection(persistedModel, availableModels())\n : undefined;\n if (!session.model.hasSelection() && presetModel) {\n await session.model.switch({ modelId: presetModel });\n }\n\n const terminal = new ProcessTerminal();\n const ui = new TUI(terminal);\n const chat = new Container();\n const status = new Text(\"\", 1, 0);\n const editor = new JanetEditor(ui, editorTheme);\n const loader = new Loader(ui, c.accent, c.dim, \"Janet is thinking…\");\n\n ui.addChild(chat);\n ui.addChild(new Spacer(1));\n ui.addChild(editor);\n ui.addChild(status);\n\n let running = false;\n let loaderMounted = false;\n let pendingApproval: PendingApproval | null = null;\n let pendingQuestion: PendingQuestion | null = null;\n let pendingInput: ((text: string) => void) | null = null;\n let activeSelect: SelectList | null = null;\n let active: ActiveMessage | null = null;\n const activeTools = new Map<string, string>();\n\n const updateStatus = (): void => {\n const model = session.model.hasSelection() ? session.model.get() : \"no model — /model <id>\";\n const state =\n pendingInput\n ? \"enter the requested value\"\n : pendingQuestion || activeSelect\n ? \"answer Janet's question\"\n : pendingApproval\n ? \"awaiting approval\"\n : running\n ? \"working\"\n : \"idle\";\n status.setText(c.dim(`${paths.projectPath} · `) + c.accent(model) + c.dim(` · ${state}`));\n ui.requestRender();\n };\n\n // Keep the spinner (and any focused select) visually last by inserting new\n // content before them.\n const appendToChat = (comp: Component): void => {\n if (loaderMounted) chat.removeChild(loader);\n if (activeSelect) chat.removeChild(activeSelect);\n chat.addChild(comp);\n if (activeSelect) chat.addChild(activeSelect);\n if (loaderMounted) chat.addChild(loader);\n ui.requestRender();\n };\n\n const addLine = (text: string): void => appendToChat(new Text(text, 1, 0));\n\n const setLoader = (on: boolean): void => {\n if (on && !loaderMounted) {\n chat.addChild(loader);\n loader.start();\n loaderMounted = true;\n } else if (!on && loaderMounted) {\n loader.stop();\n chat.removeChild(loader);\n loaderMounted = false;\n }\n ui.requestRender();\n };\n\n // Freeze the current text segment so the next assistant text starts a new\n // block below whatever we're about to insert (a tool line, question, etc.).\n const closeSegment = (): void => {\n if (active) {\n active.committedLen = active.lastText.length;\n active.comp = null;\n }\n };\n\n const answerQuestion = (resumeData: string | string[], echo: string): void => {\n if (activeSelect) {\n chat.removeChild(activeSelect);\n activeSelect = null;\n }\n const q = pendingQuestion;\n pendingQuestion = null;\n ui.setFocus(editor);\n addLine(c.user(`❯ ${echo}`));\n setLoader(true);\n updateStatus();\n if (q) void session.respondToToolSuspension({ toolCallId: q.toolCallId, resumeData });\n };\n\n const onEvent = (event: AgentControllerEvent): void => {\n switch (event.type) {\n case \"agent_start\":\n running = true;\n active = null;\n activeTools.clear();\n loader.setMessage(\"Janet is thinking…\");\n setLoader(true);\n updateStatus();\n break;\n case \"message_update\":\n case \"message_end\": {\n if (event.message.role !== \"assistant\") break;\n const text = messageText(event.message);\n if (!text) break;\n if (!active || active.id !== event.message.id) {\n active = { id: event.message.id, committedLen: 0, comp: null, lastText: \"\" };\n }\n active.lastText = text;\n const tail = text.slice(active.committedLen);\n if (!tail) break;\n if (!active.comp) {\n active.comp = new Markdown(tail, 1, 0, markdownTheme);\n appendToChat(active.comp);\n } else {\n active.comp.setText(tail);\n ui.requestRender();\n }\n break;\n }\n case \"tool_start\":\n closeSegment();\n if (event.toolName !== \"ask_user\") {\n activeTools.set(event.toolCallId, event.toolName);\n loader.setMessage(toolActivityLabel(event.toolName));\n }\n break;\n case \"tool_end\":\n activeTools.delete(event.toolCallId);\n loader.setMessage(\n activeTools.size\n ? toolActivityLabel(Array.from(activeTools.values()).at(-1)!)\n : \"Janet is thinking…\",\n );\n if (event.isError) {\n closeSegment();\n addLine(c.warn(` ${toolErrorLabel(event.result)}`));\n }\n break;\n case \"tool_suspended\": {\n closeSegment();\n activeTools.delete(event.toolCallId);\n setLoader(false);\n const payload = event.suspendPayload as {\n question?: string;\n options?: QuestionOption[];\n selectionMode?: string;\n };\n const question = payload?.question ?? `Janet needs input for ${event.toolName}.`;\n const options = payload?.options;\n const multi = payload?.selectionMode === \"multi_select\";\n addLine(c.accentBold(` Janet asks: ${question}`));\n\n if (options?.length && !multi) {\n // Arrow-key selection (↑/↓, enter), like a native picker.\n const items: SelectItem[] = options.map((o) => ({\n value: o.label,\n label: o.label,\n ...(o.description ? { description: o.description } : {}),\n }));\n const select = new SelectList(items, Math.min(items.length, 8), editorTheme.selectList);\n select.onSelect = (item: SelectItem) => answerQuestion(item.value, item.label);\n activeSelect = select;\n pendingQuestion = { toolCallId: event.toolCallId, options, multi: false };\n chat.addChild(select);\n addLine(c.dim(\" Use ↑/↓ and Enter.\"));\n ui.setFocus(select);\n } else {\n pendingQuestion = { toolCallId: event.toolCallId, options, multi };\n if (options?.length) {\n options.forEach((o, i) =>\n addLine(c.accent(` ${i + 1}. `) + o.label + (o.description ? c.dim(` — ${o.description}`) : \"\")),\n );\n addLine(c.dim(\" Reply with numbers or labels, then press Enter.\"));\n } else {\n addLine(c.dim(\" Type your answer, then press Enter.\"));\n }\n }\n updateStatus();\n break;\n }\n case \"tool_approval_required\":\n closeSegment();\n activeTools.delete(event.toolCallId);\n pendingApproval = { toolCallId: event.toolCallId, toolName: event.toolName };\n addLine(\n c.warn(` Janet wants to run ${c.bold(event.toolName)}.`) +\n c.dim(\" y = yes · n = no · a = always allow this kind\"),\n );\n updateStatus();\n break;\n case \"error\": {\n closeSegment();\n const err = event.error as Error & { responseBody?: string };\n addLine(\n c.error(` Error: ${err?.message || \"unknown\"}${err?.responseBody ? ` — ${err.responseBody.slice(0, 200)}` : \"\"}`),\n );\n break;\n }\n case \"model_changed\":\n updateStatus();\n break;\n case \"agent_end\":\n running = false;\n activeTools.clear();\n loader.setMessage(\"Janet is thinking…\");\n if (event.reason !== \"suspended\") pendingQuestion = null;\n setLoader(false);\n updateStatus();\n break;\n }\n };\n const unsubscribe = session.subscribe(onEvent);\n\n const shutdown = async (code: number): Promise<never> => {\n unsubscribe();\n herdrDetach();\n ui.stop();\n await controller.destroy().catch(() => {});\n process.exit(code);\n };\n\n // Ask the user for one value; the next editor submit resolves it. Used by the\n // OAuth login flow (paste-code / prompts).\n const promptInput = (message: string, placeholder?: string): Promise<string> => {\n addLine(c.accentBold(` ${message}`));\n if (placeholder) addLine(c.dim(` (${placeholder})`));\n updateStatus();\n return new Promise((resolve) => {\n pendingInput = resolve;\n });\n };\n\n // Interactive model picker: an arrow-key list of models from the providers\n // reachable right now. Selecting one switches the session and persists it as\n // the default. Shared by /models, /model (no arg), and first-run onboarding.\n const showModelPicker = (intro?: string): void => {\n const choices = availableModels();\n if (intro) addLine(c.accentBold(intro));\n if (!choices.length) {\n addLine(c.dim(\" No providers are configured yet. Set one up, then try again:\"));\n addLine(c.dim(\" • Vertex AI: gcloud auth application-default login (+ GOOGLE_VERTEX_PROJECT)\"));\n addLine(c.dim(\" • Anthropic: set ANTHROPIC_API_KEY, or /login anthropic\"));\n addLine(c.dim(\" • OpenAI: set OPENAI_API_KEY, or /login openai-codex\"));\n addLine(c.dim(\" • Bedrock: configure AWS credentials\"));\n updateStatus();\n return;\n }\n const current = session.model.hasSelection() ? session.model.get() : null;\n addLine(c.dim(\" ↑/↓ to move, enter to choose:\"));\n const select = new SelectList(\n choices.map((ch) => ({\n value: ch.id,\n label: ch.id === current ? `${ch.label} (current)` : ch.label,\n description: ch.via,\n })),\n Math.min(choices.length, 10),\n editorTheme.selectList,\n );\n select.onSelect = (item: SelectItem) => {\n chat.removeChild(select);\n activeSelect = null;\n ui.setFocus(editor);\n void session.model.switch({ modelId: item.value });\n completeOnboarding(item.value, new Date().toISOString());\n addLine(c.accentBold(` ✓ Using ${item.value}.`) + c.dim(\" (saved as your default)\"));\n updateStatus();\n };\n activeSelect = select;\n chat.addChild(select);\n ui.setFocus(select);\n updateStatus();\n };\n\n const handleCommand = async (text: string): Promise<void> => {\n const [cmd, ...rest] = text.slice(1).split(/\\s+/);\n switch (cmd) {\n case \"quit\":\n case \"exit\":\n await shutdown(0);\n break;\n case \"help\":\n addLine(c.dim(HELP_TEXT));\n break;\n case \"login\": {\n const providerId = (rest[0] || \"anthropic\").trim();\n if (!(OAUTH_PROVIDERS as readonly string[]).includes(providerId)) {\n addLine(c.dim(`Usage: /login <${OAUTH_PROVIDERS.join(\" | \")}>`));\n break;\n }\n const authMode = rest[1]?.trim();\n if (\n authMode &&\n (providerId !== \"openai-codex\" || ![\"browser\", \"device\"].includes(authMode))\n ) {\n addLine(c.dim(\"Usage: /login openai-codex [browser | device]\"));\n break;\n }\n addLine(c.dim(`Starting ${providerId} login…`));\n try {\n await getAuthStorage().login(providerId, {\n onAuth: (info) => {\n addLine(c.accent(\" Open this URL in your browser to authorize:\"));\n addLine(\" \" + info.url);\n if (info.instructions) addLine(c.dim(\" \" + info.instructions));\n },\n onProgress: (m) => addLine(c.dim(\" \" + m)),\n onManualCodeInput: () => promptInput(\"Paste the code shown after you authorize:\"),\n onPrompt: (p) => promptInput(p.message, p.placeholder),\n ...(authMode ? { authMode } : {}),\n });\n addLine(c.accentBold(` ✓ Logged in to ${providerId}.`));\n updateStatus();\n } catch (err) {\n addLine(c.error(` Login failed: ${(err as Error).message}`));\n } finally {\n // A successful browser callback can win the race with the manual-code\n // prompt. Disarm that abandoned prompt so it cannot consume the next\n // chat message after login completes.\n pendingInput = null;\n updateStatus();\n }\n break;\n }\n case \"logout\": {\n const providerId = rest[0]?.trim();\n if (!providerId) {\n addLine(c.dim(`Usage: /logout <${OAUTH_PROVIDERS.join(\" | \")}>`));\n break;\n }\n const storage = getAuthStorage();\n storage.logout(providerId); // OAuth credential\n storage.remove(`apikey:${providerId}`); // stored API key slot, if any\n addLine(c.dim(`Logged out of ${providerId}.`));\n break;\n }\n case \"auth\": {\n const storage = getAuthStorage();\n storage.reload();\n const providers = storage.list();\n if (!providers.length) {\n addLine(c.dim(\"No stored credentials. Use /login <provider>, or set an API key env var\"));\n addLine(c.dim(\"(ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_VERTEX_PROJECT, AWS_*).\"));\n } else {\n for (const p of providers) {\n const cred = storage.get(p);\n addLine(c.dim(` ${p}: `) + (cred?.type === \"oauth\" ? c.accent(\"OAuth (subscription)\") : \"API key\"));\n }\n }\n break;\n }\n case \"model\": {\n const inputId = rest.join(\" \").trim();\n // No id → open the picker; an explicit id still works for power users.\n if (!inputId) {\n showModelPicker();\n break;\n }\n const id = normalizeModelSelection(inputId, availableModels());\n await session.model.switch({ modelId: id });\n completeOnboarding(id, new Date().toISOString());\n rememberModel(id); // so a hand-typed model shows up in the picker next time\n addLine(c.dim(`Model set to ${id}.`));\n updateStatus();\n break;\n }\n case \"models\":\n showModelPicker();\n break;\n default:\n addLine(c.dim(`Unknown command /${cmd}. Try /help.`));\n }\n };\n\n editor.onSubmit = (raw: string) => {\n const text = raw.trim();\n editor.setText(\"\");\n if (!text) return;\n\n // Feed normal prompt input (messages + slash commands) into the editor's\n // built-in up/down history. Skip transient responses — approvals, question\n // answers, and paste-codes shouldn't clutter recall.\n if (!pendingInput && !pendingApproval && !pendingQuestion) {\n editor.addToHistory(text);\n }\n\n // A requested value (e.g. an OAuth paste-code) consumes the next submit.\n // Don't echo it verbatim — it may be a credential.\n if (pendingInput) {\n const resolve = pendingInput;\n pendingInput = null;\n addLine(c.dim(\" ❯ (value entered)\"));\n updateStatus();\n resolve(text);\n return;\n }\n\n // A typed question (free-text or multi-select) consumes the next submit.\n if (pendingQuestion && !activeSelect) {\n const resumeData = resolveAnswer(pendingQuestion, text);\n if (resumeData === undefined) {\n addLine(c.dim(\" Didn't match an option — reply with a number or an exact label.\"));\n return;\n }\n answerQuestion(resumeData, Array.isArray(resumeData) ? resumeData.join(\", \") : resumeData);\n return;\n }\n\n // Pending tool approval: y / n / a (always allow this category).\n if (pendingApproval) {\n const approve = /^y(es)?$/i.test(text);\n const decline = /^n(o)?$/i.test(text);\n const always = /^a(lways)?$/i.test(text);\n if (approve || decline || always) {\n const { toolCallId } = pendingApproval;\n pendingApproval = null;\n addLine(c.dim(always ? \" ✓ always allowed\" : approve ? \" ✓ approved\" : \" ✗ declined\"));\n updateStatus();\n void session.respondToToolApproval({\n decision: always ? \"always_allow_category\" : approve ? \"approve\" : \"decline\",\n toolCallId,\n });\n return;\n }\n addLine(c.dim(\" Answer y (yes), n (no), or a (always allow) first.\"));\n return;\n }\n\n if (text.startsWith(\"/\")) {\n void handleCommand(text);\n return;\n }\n\n addLine(c.user(`❯ ${text}`));\n if (!session.model.hasSelection()) {\n showModelPicker(\" Pick a model first:\");\n return;\n }\n void session.sendMessage({ content: text }).catch((err: Error) => {\n running = false;\n setLoader(false);\n addLine(c.error(` ✗ ${err.message}`));\n updateStatus();\n });\n };\n\n // Double Ctrl+C exits; single clears input or aborts a running turn.\n let lastCtrlC = 0;\n editor.onCtrlC = () => {\n const now = Date.now();\n if (now - lastCtrlC < 800) {\n void shutdown(0);\n return;\n }\n lastCtrlC = now;\n if (running) {\n void session.abort();\n addLine(c.dim(\" (aborted — Ctrl+C again to quit)\"));\n } else if (editor.getText()) {\n editor.setText(\"\");\n ui.requestRender();\n } else {\n addLine(c.dim(\" (Ctrl+C again to quit)\"));\n }\n };\n\n addLine(c.accentBold(GREETING));\n addLine(\n c.dim(\n `Knowledge bundle: ${paths.bundlePath}\\n` +\n `Ask me anything in the bundle, or say what to ingest. /help for commands.`,\n ),\n );\n updateStatus();\n ui.start();\n ui.setFocus(editor);\n ui.requestRender();\n\n // First run (no model configured): open the picker to get set up.\n if (!session.model.hasSelection()) showModelPicker(\" Let's pick a model to get you started.\");\n\n // The TUI owns the process from here; exit happens via shutdown().\n return await new Promise<number>(() => {});\n}\n","const WORKSPACE_READ = new Set([\n \"mastra_workspace_file_stat\",\n \"mastra_workspace_grep\",\n \"mastra_workspace_lsp_inspect\",\n \"mastra_workspace_list_files\",\n \"mastra_workspace_read_file\",\n \"mastra_workspace_search\",\n]);\n\nconst WORKSPACE_WRITE = new Set([\n \"mastra_workspace_ast_edit\",\n \"mastra_workspace_delete\",\n \"mastra_workspace_edit_file\",\n \"mastra_workspace_index\",\n \"mastra_workspace_mkdir\",\n \"mastra_workspace_write_file\",\n]);\n\nconst WORKSPACE_EXECUTE = new Set([\n \"mastra_workspace_execute_command\",\n \"mastra_workspace_get_process_output\",\n \"mastra_workspace_kill_process\",\n]);\n\n/** Friendly transient status for routine tool work. */\nexport function toolActivityLabel(toolName: string): string {\n if (toolName === \"skill\" || toolName === \"skill_read\" || toolName === \"skill_search\") {\n return \"Janet is reading the playbook…\";\n }\n if (WORKSPACE_READ.has(toolName)) return \"Janet is checking the workspace…\";\n if (WORKSPACE_WRITE.has(toolName)) return \"Janet is updating the bundle…\";\n if (WORKSPACE_EXECUTE.has(toolName) || toolName.includes(\"shell\")) {\n return \"Janet is running a check…\";\n }\n return \"Janet is working…\";\n}\n\n/** Turn recoverable workspace guard failures into useful user-facing status. */\nexport function toolErrorLabel(result: unknown): string {\n const detail = String(result);\n const readRequired = detail.match(\n /File \"([^\"]+)\" (?:has not been read|was modified since last read)/,\n );\n if (readRequired) {\n return `Update paused: Janet needs to re-read \"${readRequired[1]}\" first.`;\n }\n return `Tool error: ${detail.slice(0, 140)}`;\n}\n","import chalk from \"chalk\";\nimport type { EditorTheme } from \"@earendil-works/pi-tui\";\n\n/**\n * Janet's minimal terminal theme. Good Place warm: cyan accents, soft dims.\n * Kept tiny on purpose — no gradients, no branding machinery.\n */\nexport const c = {\n accent: chalk.cyan,\n accentBold: chalk.cyan.bold,\n dim: chalk.dim,\n user: chalk.green,\n error: chalk.red,\n warn: chalk.yellow,\n bold: chalk.bold,\n italic: chalk.italic,\n};\n\nexport const editorTheme: EditorTheme = {\n borderColor: (s: string) => chalk.cyan(s),\n selectList: {\n selectedPrefix: (s: string) => chalk.cyan(s),\n selectedText: (s: string) => chalk.cyan.bold(s),\n description: (s: string) => chalk.dim(s),\n scrollInfo: (s: string) => chalk.dim(s),\n noMatch: (s: string) => chalk.dim(s),\n },\n};\n\nexport const markdownTheme = {\n heading: (s: string) => chalk.cyan.bold(s),\n link: (s: string) => chalk.cyan.underline(s),\n linkUrl: (s: string) => chalk.dim(s),\n code: (s: string) => chalk.yellow(s),\n codeBlock: (s: string) => chalk.yellow(s),\n codeBlockBorder: (s: string) => chalk.dim(s),\n quote: (s: string) => chalk.italic(s),\n quoteBorder: (s: string) => chalk.dim(s),\n hr: (s: string) => chalk.dim(s),\n listBullet: (s: string) => chalk.cyan(s),\n bold: (s: string) => chalk.bold(s),\n italic: (s: string) => chalk.italic(s),\n strikethrough: (s: string) => chalk.strikethrough(s),\n underline: (s: string) => chalk.underline(s),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACvBP,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,oBAAoB,oBAAI,IAAI;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,SAAS,kBAAkB,UAA0B;AAC1D,MAAI,aAAa,WAAW,aAAa,gBAAgB,aAAa,gBAAgB;AACpF,WAAO;AAAA,EACT;AACA,MAAI,eAAe,IAAI,QAAQ,EAAG,QAAO;AACzC,MAAI,gBAAgB,IAAI,QAAQ,EAAG,QAAO;AAC1C,MAAI,kBAAkB,IAAI,QAAQ,KAAK,SAAS,SAAS,OAAO,GAAG;AACjE,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAGO,SAAS,eAAe,QA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A,IACf,CAAC;AAAA,EACH;AAGA,MAAI,YAAY;AAChB,SAAO,UAAU,MAAM;AACrB,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,MAAM,YAAY,KAAK;AACzB,WAAK,SAAS,CAAC;AACf;AAAA,IACF;AACA,gBAAY;AACZ,QAAI,SAAS;AACX,WAAK,QAAQ,MAAM;AACnB,cAAQ,EAAE,IAAI,yCAAoC,CAAC;AAAA,IACrD,WAAW,OAAO,QAAQ,GAAG;AAC3B,aAAO,QAAQ,EAAE;AACjB,SAAG,cAAc;AAAA,IACnB,OAAO;AACL,cAAQ,EAAE,IAAI,0BAA0B,CAAC;AAAA,IAC3C;AAAA,EACF;AAEA,UAAQ,EAAE,WAAW,QAAQ,CAAC;AAC9B;AAAA,IACE,EAAE;AAAA,MACA,qBAAqB,MAAM,UAAU;AAAA;AAAA,IAEvC;AAAA,EACF;AACA,eAAa;AACb,KAAG,MAAM;AACT,KAAG,SAAS,MAAM;AAClB,KAAG,cAAc;AAGjB,MAAI,CAAC,QAAQ,MAAM,aAAa,EAAG,iBAAgB,0CAA0C;AAG7F,SAAO,MAAM,IAAI,QAAgB,MAAM;AAAA,EAAC,CAAC;AAC3C;","names":[]}
|
package/package.json
CHANGED
package/skills/kb/SKILL.md
CHANGED
|
@@ -28,6 +28,11 @@ non-empty `type`. Everything else is soft guidance — consumers MUST tolerate m
|
|
|
28
28
|
unknown types, and broken links. Never reject a bundle over them. Full rules:
|
|
29
29
|
[references/SPEC.md](references/SPEC.md) §9.
|
|
30
30
|
|
|
31
|
+
The domain portion of `spec/types.md` is a living, producer-chosen vocabulary, not a validation
|
|
32
|
+
enum. Keep the workflow conventions `Reference` and `Spec Section`; start the domain types small
|
|
33
|
+
and evolve them through [`kb-ingest`](../kb-ingest/SKILL.md) when the domain reveals a durable new
|
|
34
|
+
kind of entity. Use [`kb-lint`](../kb-lint/SKILL.md) to detect schema drift.
|
|
35
|
+
|
|
31
36
|
## Route to the right skill
|
|
32
37
|
|
|
33
38
|
| The user wants to… | Use |
|
|
@@ -19,5 +19,6 @@ grows.
|
|
|
19
19
|
| `order` | A purchase made by a customer. | `concepts/` |
|
|
20
20
|
| `Reference` | A mirror of external source material (points at it via `resource`). | `references/` |
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
`chapter`)
|
|
22
|
+
Keep the workflow types `Spec Section` and `Reference`. Replace `customer` and `order` with a small,
|
|
23
|
+
provisional set of domain entities (e.g. `person`, `deal`, `metric`, `character`, `chapter`) and
|
|
24
|
+
extend that set as the domain becomes clearer.
|
|
@@ -63,8 +63,26 @@ Before writing anything, draft a plan — the discovery-before-synthesis guard.
|
|
|
63
63
|
Keep the plan in scratch (or a temporary `_ingest_plan.md` you delete before finishing). A rich
|
|
64
64
|
source may touch 10–15 concepts.
|
|
65
65
|
|
|
66
|
+
### Schema-fit check
|
|
67
|
+
|
|
68
|
+
Treat `spec/types.md` as a living vocabulary, not a closed enum. Before routing, check whether the
|
|
69
|
+
source reveals a recurring, materially distinct kind of entity that the current types cannot
|
|
70
|
+
describe cleanly. Do not force-fit it or create an undocumented type.
|
|
71
|
+
|
|
72
|
+
- **Safe additive change:** when the new type and its route are unambiguous and do not reclassify
|
|
73
|
+
existing concepts, add it to `spec/types.md`, update `spec/conventions.md` if routing changes, and
|
|
74
|
+
include the schema change in this ingest's log entry.
|
|
75
|
+
- **Judgment or migration change:** ask the user once before renaming, splitting, merging, or
|
|
76
|
+
deprecating types; changing a type's meaning; moving existing concepts; or choosing among
|
|
77
|
+
plausible schemas. Present the proposed change and affected concepts together.
|
|
78
|
+
- Prefer a useful broader type for a one-off signal. Add a type when it is likely to recur or its
|
|
79
|
+
distinction materially improves routing and retrieval.
|
|
80
|
+
- Preserve old type values as deprecated until any approved migration is complete. Update affected
|
|
81
|
+
concepts and indexes together; never leave two undocumented vocabularies in parallel.
|
|
82
|
+
|
|
66
83
|
**Completion criterion:** a written plan exists listing every entity, its route (create/update), the
|
|
67
|
-
Reference for the source,
|
|
84
|
+
Reference for the source, any supersede/conflict flags, and any schema addition or proposed
|
|
85
|
+
migration.
|
|
68
86
|
|
|
69
87
|
## 4. Store the source as a Reference (provenance)
|
|
70
88
|
|
|
@@ -84,8 +102,8 @@ mechanics of create / **supersede** / **conflict** / additive-event. Write new c
|
|
|
84
102
|
both directions** (a person named in a deal links to their concept and back), with relative links.
|
|
85
103
|
|
|
86
104
|
**Completion criterion:** every entity in the plan has its concept created or updated with a
|
|
87
|
-
non-empty `type`, citing the Reference; planned supersede/conflict actions
|
|
88
|
-
model — no meaning rewritten in place.
|
|
105
|
+
non-empty, documented `type`, citing the Reference; planned schema and supersede/conflict actions
|
|
106
|
+
are applied per the schema layer and trust model — no meaning rewritten in place.
|
|
89
107
|
|
|
90
108
|
## 6. Re-synthesize overviews
|
|
91
109
|
|
package/skills/kb-init/SKILL.md
CHANGED
|
@@ -39,8 +39,10 @@ user only what you still can't infer:
|
|
|
39
39
|
`type` vocabulary (e.g. `person`, `deal`, `metric`; or `character`, `chapter`, `theme`).
|
|
40
40
|
- What raw **sources** will be ingested, and how should they route to those entities?
|
|
41
41
|
|
|
42
|
-
Keep it short — a few types and a one-line routing rule is enough to start
|
|
43
|
-
co-evolves
|
|
42
|
+
Keep it short — a few **provisional** types and a one-line routing rule is enough to start. This is
|
|
43
|
+
an initial vocabulary, not a closed enum; the schema layer co-evolves as ingest reveals the domain.
|
|
44
|
+
`Reference` (captured source material) and `Spec Section` (the bundle's own schema documents) are
|
|
45
|
+
workflow types supplied by the seed, not domain choices the user needs to design.
|
|
44
46
|
|
|
45
47
|
Interaction contract:
|
|
46
48
|
|
|
@@ -48,19 +50,28 @@ Interaction contract:
|
|
|
48
50
|
- Ask one concise, free-text question for everything that remains unknown.
|
|
49
51
|
- Do not use canned multiple-choice options for this domain-specific input.
|
|
50
52
|
- After the user answers, continue from this loaded procedure. Do not load `kb-init` again.
|
|
53
|
+
- If you propose a schema for confirmation, accept the user's answer once. After approval, scaffold
|
|
54
|
+
without restating or replanning it.
|
|
51
55
|
|
|
52
56
|
**Completion criterion:** you can name the bundle's initial `type` values, its raw sources, and a
|
|
53
57
|
one-line ingest routing rule.
|
|
54
58
|
|
|
55
|
-
## 3.
|
|
59
|
+
## 3. Write the adapted seed and schema layer
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
Read [../kb/example-bundle/](../kb/example-bundle/) as the source scaffold, then write its adapted
|
|
62
|
+
artifacts into the target. Do not first write an unmodified copy and then overwrite it: create the
|
|
63
|
+
directories and write each target file once with its final, domain-specific content. Work quietly
|
|
64
|
+
after the user's approval; do not narrate each read or write.
|
|
65
|
+
|
|
66
|
+
If a prior attempt already created a target file, it is no longer new: read that file immediately
|
|
67
|
+
before editing it, preserve valid work, and resume from the incomplete step. Never retry a
|
|
68
|
+
read-before-write failure blindly or dismiss it as a false alarm.
|
|
58
69
|
|
|
59
70
|
| Artifact | Action |
|
|
60
71
|
|---|---|
|
|
61
72
|
| `index.md` | Keep `okf_version: "0.1"` frontmatter; replace the body with this bundle's title and section list. |
|
|
62
73
|
| `log.md` | Start fresh with a single dated `**Creation**` entry. |
|
|
63
|
-
| `spec/types.md` |
|
|
74
|
+
| `spec/types.md` | Keep `Spec Section` and `Reference`; replace only the example domain types with the provisional vocabulary from step 2. |
|
|
64
75
|
| `spec/conventions.md` | Replace with folder taxonomy, naming, ingest routing rule, and a trust-model pointer. |
|
|
65
76
|
| `concepts/*` | Remove example entities (`customers`, `orders`); leave `concepts/` empty or create domain starter folders. |
|
|
66
77
|
| `knowledge/index.md` | If multi-bundle (step 1): create or update the catalog entry for this bundle. |
|
package/skills/kb-lint/SKILL.md
CHANGED
|
@@ -44,6 +44,9 @@ the legwork that makes lint worth running. Cover every check:
|
|
|
44
44
|
- **Coverage gaps** — entities named repeatedly across concepts but lacking their own concept; data
|
|
45
45
|
gaps a source or web search could fill.
|
|
46
46
|
- **Provenance gaps** — concepts making external claims with no `# Citations` / Reference.
|
|
47
|
+
- **Schema drift** — types used but absent from `spec/types.md`; documented types that no longer
|
|
48
|
+
describe their concepts; spelling/case variants; or one overloaded type hiding several recurring,
|
|
49
|
+
materially distinct entity kinds. Treat unused documented types as Info, not an error.
|
|
47
50
|
|
|
48
51
|
**Completion criterion:** every check above has been run across the whole bundle and its findings
|
|
49
52
|
recorded — not a sample.
|
|
@@ -71,7 +74,9 @@ vs. what needs a human:
|
|
|
71
74
|
log dates, broken links with an obvious target, index entries out of sync with files.
|
|
72
75
|
- **Never auto-fix:** anything that changes a claim's meaning. A contradiction or a stale *claim* is
|
|
73
76
|
resolved by [ingest](../kb-ingest/SKILL.md) under the [trust model](../kb/references/trust-model.md)
|
|
74
|
-
(**supersede**/**conflict**) — never by editing meaning in place here.
|
|
77
|
+
(**supersede**/**conflict**) — never by editing meaning in place here. Type renames, merges,
|
|
78
|
+
splits, deprecations, and migrations also require user confirmation; report the proposed schema
|
|
79
|
+
change and affected concepts together.
|
|
75
80
|
|
|
76
81
|
**Completion criterion:** every safe issue is fixed and every meaning-level issue is flagged (not
|
|
77
82
|
touched); the re-report distinguishes the two.
|
package/dist/tui-GCLV5CZQ.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tui/index.ts","../src/tui/activity.ts","../src/tui/theme.ts"],"sourcesContent":["/**\n * Janet's interactive TUI — a minimal pi-tui chat.\n *\n * The transcript renders in strict chronological order: each run of assistant\n * text becomes its own markdown block, and a tool line / question / approval\n * \"closes\" the current block so the next text appears BELOW it (rather than the\n * whole answer streaming at the top while tools pile up underneath).\n *\n * Approvals are governed by the controller's tool-category policy: reads,\n * skills, task bookkeeping, ask_user, and bundle edits never prompt. Execution,\n * MCP, and unknown future tools ask — and the prompt offers \"always allow\" for\n * the session. Questions with options render as an arrow-key SelectList.\n */\nimport {\n Container,\n Editor,\n Loader,\n Markdown,\n ProcessTerminal,\n SelectList,\n Spacer,\n TUI,\n Text,\n} from \"@earendil-works/pi-tui\";\nimport type { Component, SelectItem } from \"@earendil-works/pi-tui\";\nimport type { AgentControllerEvent } from \"@mastra/core/agent-controller\";\nimport { bootJanet, type BootOptions } from \"../agent/controller.js\";\nimport { messageText } from \"../headless/format.js\";\nimport { GREETING } from \"../agent/persona.js\";\nimport { getAuthStorage } from \"../gateways/oauth/claude-max.js\";\nimport { loadSettings, completeOnboarding, rememberModel } from \"../onboarding/settings.js\";\nimport { availableModels, normalizeModelSelection } from \"../onboarding/providers.js\";\nimport { toolActivityLabel } from \"./activity.js\";\nimport { c, editorTheme, markdownTheme } from \"./theme.js\";\n\n/** OAuth providers janet can log in to. */\nconst OAUTH_PROVIDERS = [\"anthropic\", \"openai-codex\"] as const;\n\n/** Editor with a Ctrl+C hook (raw-mode terminals deliver it as input \\x03). */\nclass JanetEditor extends Editor {\n onCtrlC?: () => void;\n override handleInput(data: string): void {\n if (data === \"\\x03\") {\n this.onCtrlC?.();\n return;\n }\n super.handleInput(data);\n }\n}\n\nconst HELP_TEXT = `Commands:\n /models Pick a model from a list (arrow keys)\n /model [provider/id] Open the picker, or switch directly by id\n /login <provider> [mode]\n Log in; OpenAI mode is browser or device\n /logout <provider> Remove stored credentials for a provider\n /auth Show which providers are authenticated\n /help This help\n /quit Exit (double Ctrl+C also works)\n\nAnything else is a message to Janet.`;\n\ninterface PendingApproval {\n toolCallId: string;\n toolName: string;\n}\n\ninterface QuestionOption {\n label: string;\n description?: string;\n}\n\ninterface PendingQuestion {\n toolCallId: string;\n options?: QuestionOption[];\n multi: boolean;\n}\n\n/** The assistant text block currently being streamed (one segment between tools). */\ninterface ActiveMessage {\n id: string;\n committedLen: number;\n comp: Markdown | null;\n lastText: string;\n}\n\n/** Map a typed answer to ask_user resume data (free-text or multi-select). */\nfunction resolveAnswer(q: PendingQuestion, text: string): string | string[] | undefined {\n if (!q.options?.length) return text;\n const opts = q.options;\n const pick = (token: string): string | undefined => {\n const t = token.trim();\n if (!t) return undefined;\n const n = Number(t);\n if (Number.isInteger(n) && n >= 1 && n <= opts.length) return opts[n - 1]!.label;\n const exact = opts.find((o) => o.label.toLowerCase() === t.toLowerCase());\n if (exact) return exact.label;\n return opts.find((o) => o.label.toLowerCase().startsWith(t.toLowerCase()))?.label;\n };\n if (q.multi) {\n const picks = text.split(\",\").map(pick);\n return picks.some((p) => p === undefined) ? undefined : (picks as string[]);\n }\n return pick(text);\n}\n\nexport async function runTui(opts: Omit<BootOptions, \"interactive\">): Promise<number> {\n const { controller, session, paths, herdrDetach } = await bootJanet({ ...opts, interactive: true });\n\n // The interactive approval policy is set deterministically in the controller's\n // initialState (reads/edits/meta never prompt; only execute asks, with an\n // \"always allow\" option) — see INTERACTIVE_RULES in controller.ts.\n\n // Model precedence: an already-persisted per-thread selection, else\n // JANET_MODEL, else the global onboarding default. If none, the first-run\n // wizard runs after the UI is up.\n const persistedModel = process.env[\"JANET_MODEL\"] || loadSettings().defaultModelId;\n const presetModel = persistedModel\n ? normalizeModelSelection(persistedModel, availableModels())\n : undefined;\n if (!session.model.hasSelection() && presetModel) {\n await session.model.switch({ modelId: presetModel });\n }\n\n const terminal = new ProcessTerminal();\n const ui = new TUI(terminal);\n const chat = new Container();\n const status = new Text(\"\", 1, 0);\n const editor = new JanetEditor(ui, editorTheme);\n const loader = new Loader(ui, c.accent, c.dim, \"Janet is thinking…\");\n\n ui.addChild(chat);\n ui.addChild(new Spacer(1));\n ui.addChild(editor);\n ui.addChild(status);\n\n let running = false;\n let loaderMounted = false;\n let pendingApproval: PendingApproval | null = null;\n let pendingQuestion: PendingQuestion | null = null;\n let pendingInput: ((text: string) => void) | null = null;\n let activeSelect: SelectList | null = null;\n let active: ActiveMessage | null = null;\n const activeTools = new Map<string, string>();\n\n const updateStatus = (): void => {\n const model = session.model.hasSelection() ? session.model.get() : \"no model — /model <id>\";\n const state =\n pendingInput\n ? \"enter the requested value\"\n : pendingQuestion || activeSelect\n ? \"answer Janet's question\"\n : pendingApproval\n ? \"awaiting approval\"\n : running\n ? \"working\"\n : \"idle\";\n status.setText(c.dim(`${paths.projectPath} · `) + c.accent(model) + c.dim(` · ${state}`));\n ui.requestRender();\n };\n\n // Keep the spinner (and any focused select) visually last by inserting new\n // content before them.\n const appendToChat = (comp: Component): void => {\n if (loaderMounted) chat.removeChild(loader);\n if (activeSelect) chat.removeChild(activeSelect);\n chat.addChild(comp);\n if (activeSelect) chat.addChild(activeSelect);\n if (loaderMounted) chat.addChild(loader);\n ui.requestRender();\n };\n\n const addLine = (text: string): void => appendToChat(new Text(text, 1, 0));\n\n const setLoader = (on: boolean): void => {\n if (on && !loaderMounted) {\n chat.addChild(loader);\n loader.start();\n loaderMounted = true;\n } else if (!on && loaderMounted) {\n loader.stop();\n chat.removeChild(loader);\n loaderMounted = false;\n }\n ui.requestRender();\n };\n\n // Freeze the current text segment so the next assistant text starts a new\n // block below whatever we're about to insert (a tool line, question, etc.).\n const closeSegment = (): void => {\n if (active) {\n active.committedLen = active.lastText.length;\n active.comp = null;\n }\n };\n\n const answerQuestion = (resumeData: string | string[], echo: string): void => {\n if (activeSelect) {\n chat.removeChild(activeSelect);\n activeSelect = null;\n }\n const q = pendingQuestion;\n pendingQuestion = null;\n ui.setFocus(editor);\n addLine(c.user(`❯ ${echo}`));\n setLoader(true);\n updateStatus();\n if (q) void session.respondToToolSuspension({ toolCallId: q.toolCallId, resumeData });\n };\n\n const onEvent = (event: AgentControllerEvent): void => {\n switch (event.type) {\n case \"agent_start\":\n running = true;\n active = null;\n activeTools.clear();\n loader.setMessage(\"Janet is thinking…\");\n setLoader(true);\n updateStatus();\n break;\n case \"message_update\":\n case \"message_end\": {\n if (event.message.role !== \"assistant\") break;\n const text = messageText(event.message);\n if (!text) break;\n if (!active || active.id !== event.message.id) {\n active = { id: event.message.id, committedLen: 0, comp: null, lastText: \"\" };\n }\n active.lastText = text;\n const tail = text.slice(active.committedLen);\n if (!tail) break;\n if (!active.comp) {\n active.comp = new Markdown(tail, 1, 0, markdownTheme);\n appendToChat(active.comp);\n } else {\n active.comp.setText(tail);\n ui.requestRender();\n }\n break;\n }\n case \"tool_start\":\n closeSegment();\n if (event.toolName !== \"ask_user\") {\n activeTools.set(event.toolCallId, event.toolName);\n loader.setMessage(toolActivityLabel(event.toolName));\n }\n break;\n case \"tool_end\":\n activeTools.delete(event.toolCallId);\n loader.setMessage(\n activeTools.size\n ? toolActivityLabel(Array.from(activeTools.values()).at(-1)!)\n : \"Janet is thinking…\",\n );\n if (event.isError) {\n closeSegment();\n addLine(c.warn(` Tool error: ${String(event.result).slice(0, 140)}`));\n }\n break;\n case \"tool_suspended\": {\n closeSegment();\n activeTools.delete(event.toolCallId);\n setLoader(false);\n const payload = event.suspendPayload as {\n question?: string;\n options?: QuestionOption[];\n selectionMode?: string;\n };\n const question = payload?.question ?? `Janet needs input for ${event.toolName}.`;\n const options = payload?.options;\n const multi = payload?.selectionMode === \"multi_select\";\n addLine(c.accentBold(` Janet asks: ${question}`));\n\n if (options?.length && !multi) {\n // Arrow-key selection (↑/↓, enter), like a native picker.\n const items: SelectItem[] = options.map((o) => ({\n value: o.label,\n label: o.label,\n ...(o.description ? { description: o.description } : {}),\n }));\n const select = new SelectList(items, Math.min(items.length, 8), editorTheme.selectList);\n select.onSelect = (item: SelectItem) => answerQuestion(item.value, item.label);\n activeSelect = select;\n pendingQuestion = { toolCallId: event.toolCallId, options, multi: false };\n chat.addChild(select);\n addLine(c.dim(\" Use ↑/↓ and Enter.\"));\n ui.setFocus(select);\n } else {\n pendingQuestion = { toolCallId: event.toolCallId, options, multi };\n if (options?.length) {\n options.forEach((o, i) =>\n addLine(c.accent(` ${i + 1}. `) + o.label + (o.description ? c.dim(` — ${o.description}`) : \"\")),\n );\n addLine(c.dim(\" Reply with numbers or labels, then press Enter.\"));\n } else {\n addLine(c.dim(\" Type your answer, then press Enter.\"));\n }\n }\n updateStatus();\n break;\n }\n case \"tool_approval_required\":\n closeSegment();\n activeTools.delete(event.toolCallId);\n pendingApproval = { toolCallId: event.toolCallId, toolName: event.toolName };\n addLine(\n c.warn(` Janet wants to run ${c.bold(event.toolName)}.`) +\n c.dim(\" y = yes · n = no · a = always allow this kind\"),\n );\n updateStatus();\n break;\n case \"error\": {\n closeSegment();\n const err = event.error as Error & { responseBody?: string };\n addLine(\n c.error(` Error: ${err?.message || \"unknown\"}${err?.responseBody ? ` — ${err.responseBody.slice(0, 200)}` : \"\"}`),\n );\n break;\n }\n case \"model_changed\":\n updateStatus();\n break;\n case \"agent_end\":\n running = false;\n activeTools.clear();\n loader.setMessage(\"Janet is thinking…\");\n if (event.reason !== \"suspended\") pendingQuestion = null;\n setLoader(false);\n updateStatus();\n break;\n }\n };\n const unsubscribe = session.subscribe(onEvent);\n\n const shutdown = async (code: number): Promise<never> => {\n unsubscribe();\n herdrDetach();\n ui.stop();\n await controller.destroy().catch(() => {});\n process.exit(code);\n };\n\n // Ask the user for one value; the next editor submit resolves it. Used by the\n // OAuth login flow (paste-code / prompts).\n const promptInput = (message: string, placeholder?: string): Promise<string> => {\n addLine(c.accentBold(` ${message}`));\n if (placeholder) addLine(c.dim(` (${placeholder})`));\n updateStatus();\n return new Promise((resolve) => {\n pendingInput = resolve;\n });\n };\n\n // Interactive model picker: an arrow-key list of models from the providers\n // reachable right now. Selecting one switches the session and persists it as\n // the default. Shared by /models, /model (no arg), and first-run onboarding.\n const showModelPicker = (intro?: string): void => {\n const choices = availableModels();\n if (intro) addLine(c.accentBold(intro));\n if (!choices.length) {\n addLine(c.dim(\" No providers are configured yet. Set one up, then try again:\"));\n addLine(c.dim(\" • Vertex AI: gcloud auth application-default login (+ GOOGLE_VERTEX_PROJECT)\"));\n addLine(c.dim(\" • Anthropic: set ANTHROPIC_API_KEY, or /login anthropic\"));\n addLine(c.dim(\" • OpenAI: set OPENAI_API_KEY, or /login openai-codex\"));\n addLine(c.dim(\" • Bedrock: configure AWS credentials\"));\n updateStatus();\n return;\n }\n const current = session.model.hasSelection() ? session.model.get() : null;\n addLine(c.dim(\" ↑/↓ to move, enter to choose:\"));\n const select = new SelectList(\n choices.map((ch) => ({\n value: ch.id,\n label: ch.id === current ? `${ch.label} (current)` : ch.label,\n description: ch.via,\n })),\n Math.min(choices.length, 10),\n editorTheme.selectList,\n );\n select.onSelect = (item: SelectItem) => {\n chat.removeChild(select);\n activeSelect = null;\n ui.setFocus(editor);\n void session.model.switch({ modelId: item.value });\n completeOnboarding(item.value, new Date().toISOString());\n addLine(c.accentBold(` ✓ Using ${item.value}.`) + c.dim(\" (saved as your default)\"));\n updateStatus();\n };\n activeSelect = select;\n chat.addChild(select);\n ui.setFocus(select);\n updateStatus();\n };\n\n const handleCommand = async (text: string): Promise<void> => {\n const [cmd, ...rest] = text.slice(1).split(/\\s+/);\n switch (cmd) {\n case \"quit\":\n case \"exit\":\n await shutdown(0);\n break;\n case \"help\":\n addLine(c.dim(HELP_TEXT));\n break;\n case \"login\": {\n const providerId = (rest[0] || \"anthropic\").trim();\n if (!(OAUTH_PROVIDERS as readonly string[]).includes(providerId)) {\n addLine(c.dim(`Usage: /login <${OAUTH_PROVIDERS.join(\" | \")}>`));\n break;\n }\n const authMode = rest[1]?.trim();\n if (\n authMode &&\n (providerId !== \"openai-codex\" || ![\"browser\", \"device\"].includes(authMode))\n ) {\n addLine(c.dim(\"Usage: /login openai-codex [browser | device]\"));\n break;\n }\n addLine(c.dim(`Starting ${providerId} login…`));\n try {\n await getAuthStorage().login(providerId, {\n onAuth: (info) => {\n addLine(c.accent(\" Open this URL in your browser to authorize:\"));\n addLine(\" \" + info.url);\n if (info.instructions) addLine(c.dim(\" \" + info.instructions));\n },\n onProgress: (m) => addLine(c.dim(\" \" + m)),\n onManualCodeInput: () => promptInput(\"Paste the code shown after you authorize:\"),\n onPrompt: (p) => promptInput(p.message, p.placeholder),\n ...(authMode ? { authMode } : {}),\n });\n addLine(c.accentBold(` ✓ Logged in to ${providerId}.`));\n updateStatus();\n } catch (err) {\n addLine(c.error(` Login failed: ${(err as Error).message}`));\n } finally {\n // A successful browser callback can win the race with the manual-code\n // prompt. Disarm that abandoned prompt so it cannot consume the next\n // chat message after login completes.\n pendingInput = null;\n updateStatus();\n }\n break;\n }\n case \"logout\": {\n const providerId = rest[0]?.trim();\n if (!providerId) {\n addLine(c.dim(`Usage: /logout <${OAUTH_PROVIDERS.join(\" | \")}>`));\n break;\n }\n const storage = getAuthStorage();\n storage.logout(providerId); // OAuth credential\n storage.remove(`apikey:${providerId}`); // stored API key slot, if any\n addLine(c.dim(`Logged out of ${providerId}.`));\n break;\n }\n case \"auth\": {\n const storage = getAuthStorage();\n storage.reload();\n const providers = storage.list();\n if (!providers.length) {\n addLine(c.dim(\"No stored credentials. Use /login <provider>, or set an API key env var\"));\n addLine(c.dim(\"(ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_VERTEX_PROJECT, AWS_*).\"));\n } else {\n for (const p of providers) {\n const cred = storage.get(p);\n addLine(c.dim(` ${p}: `) + (cred?.type === \"oauth\" ? c.accent(\"OAuth (subscription)\") : \"API key\"));\n }\n }\n break;\n }\n case \"model\": {\n const inputId = rest.join(\" \").trim();\n // No id → open the picker; an explicit id still works for power users.\n if (!inputId) {\n showModelPicker();\n break;\n }\n const id = normalizeModelSelection(inputId, availableModels());\n await session.model.switch({ modelId: id });\n completeOnboarding(id, new Date().toISOString());\n rememberModel(id); // so a hand-typed model shows up in the picker next time\n addLine(c.dim(`Model set to ${id}.`));\n updateStatus();\n break;\n }\n case \"models\":\n showModelPicker();\n break;\n default:\n addLine(c.dim(`Unknown command /${cmd}. Try /help.`));\n }\n };\n\n editor.onSubmit = (raw: string) => {\n const text = raw.trim();\n editor.setText(\"\");\n if (!text) return;\n\n // Feed normal prompt input (messages + slash commands) into the editor's\n // built-in up/down history. Skip transient responses — approvals, question\n // answers, and paste-codes shouldn't clutter recall.\n if (!pendingInput && !pendingApproval && !pendingQuestion) {\n editor.addToHistory(text);\n }\n\n // A requested value (e.g. an OAuth paste-code) consumes the next submit.\n // Don't echo it verbatim — it may be a credential.\n if (pendingInput) {\n const resolve = pendingInput;\n pendingInput = null;\n addLine(c.dim(\" ❯ (value entered)\"));\n updateStatus();\n resolve(text);\n return;\n }\n\n // A typed question (free-text or multi-select) consumes the next submit.\n if (pendingQuestion && !activeSelect) {\n const resumeData = resolveAnswer(pendingQuestion, text);\n if (resumeData === undefined) {\n addLine(c.dim(\" Didn't match an option — reply with a number or an exact label.\"));\n return;\n }\n answerQuestion(resumeData, Array.isArray(resumeData) ? resumeData.join(\", \") : resumeData);\n return;\n }\n\n // Pending tool approval: y / n / a (always allow this category).\n if (pendingApproval) {\n const approve = /^y(es)?$/i.test(text);\n const decline = /^n(o)?$/i.test(text);\n const always = /^a(lways)?$/i.test(text);\n if (approve || decline || always) {\n const { toolCallId } = pendingApproval;\n pendingApproval = null;\n addLine(c.dim(always ? \" ✓ always allowed\" : approve ? \" ✓ approved\" : \" ✗ declined\"));\n updateStatus();\n void session.respondToToolApproval({\n decision: always ? \"always_allow_category\" : approve ? \"approve\" : \"decline\",\n toolCallId,\n });\n return;\n }\n addLine(c.dim(\" Answer y (yes), n (no), or a (always allow) first.\"));\n return;\n }\n\n if (text.startsWith(\"/\")) {\n void handleCommand(text);\n return;\n }\n\n addLine(c.user(`❯ ${text}`));\n if (!session.model.hasSelection()) {\n showModelPicker(\" Pick a model first:\");\n return;\n }\n void session.sendMessage({ content: text }).catch((err: Error) => {\n running = false;\n setLoader(false);\n addLine(c.error(` ✗ ${err.message}`));\n updateStatus();\n });\n };\n\n // Double Ctrl+C exits; single clears input or aborts a running turn.\n let lastCtrlC = 0;\n editor.onCtrlC = () => {\n const now = Date.now();\n if (now - lastCtrlC < 800) {\n void shutdown(0);\n return;\n }\n lastCtrlC = now;\n if (running) {\n void session.abort();\n addLine(c.dim(\" (aborted — Ctrl+C again to quit)\"));\n } else if (editor.getText()) {\n editor.setText(\"\");\n ui.requestRender();\n } else {\n addLine(c.dim(\" (Ctrl+C again to quit)\"));\n }\n };\n\n addLine(c.accentBold(GREETING));\n addLine(\n c.dim(\n `Knowledge bundle: ${paths.bundlePath}\\n` +\n `Ask me anything in the bundle, or say what to ingest. /help for commands.`,\n ),\n );\n updateStatus();\n ui.start();\n ui.setFocus(editor);\n ui.requestRender();\n\n // First run (no model configured): open the picker to get set up.\n if (!session.model.hasSelection()) showModelPicker(\" Let's pick a model to get you started.\");\n\n // The TUI owns the process from here; exit happens via shutdown().\n return await new Promise<number>(() => {});\n}\n","const WORKSPACE_READ = new Set([\n \"mastra_workspace_file_stat\",\n \"mastra_workspace_grep\",\n \"mastra_workspace_lsp_inspect\",\n \"mastra_workspace_list_files\",\n \"mastra_workspace_read_file\",\n \"mastra_workspace_search\",\n]);\n\nconst WORKSPACE_WRITE = new Set([\n \"mastra_workspace_ast_edit\",\n \"mastra_workspace_delete\",\n \"mastra_workspace_edit_file\",\n \"mastra_workspace_index\",\n \"mastra_workspace_mkdir\",\n \"mastra_workspace_write_file\",\n]);\n\nconst WORKSPACE_EXECUTE = new Set([\n \"mastra_workspace_execute_command\",\n \"mastra_workspace_get_process_output\",\n \"mastra_workspace_kill_process\",\n]);\n\n/** Friendly transient status for routine tool work. */\nexport function toolActivityLabel(toolName: string): string {\n if (toolName === \"skill\" || toolName === \"skill_read\" || toolName === \"skill_search\") {\n return \"Janet is reading the playbook…\";\n }\n if (WORKSPACE_READ.has(toolName)) return \"Janet is checking the workspace…\";\n if (WORKSPACE_WRITE.has(toolName)) return \"Janet is updating the bundle…\";\n if (WORKSPACE_EXECUTE.has(toolName) || toolName.includes(\"shell\")) {\n return \"Janet is running a check…\";\n }\n return \"Janet is working…\";\n}\n","import chalk from \"chalk\";\nimport type { EditorTheme } from \"@earendil-works/pi-tui\";\n\n/**\n * Janet's minimal terminal theme. Good Place warm: cyan accents, soft dims.\n * Kept tiny on purpose — no gradients, no branding machinery.\n */\nexport const c = {\n accent: chalk.cyan,\n accentBold: chalk.cyan.bold,\n dim: chalk.dim,\n user: chalk.green,\n error: chalk.red,\n warn: chalk.yellow,\n bold: chalk.bold,\n italic: chalk.italic,\n};\n\nexport const editorTheme: EditorTheme = {\n borderColor: (s: string) => chalk.cyan(s),\n selectList: {\n selectedPrefix: (s: string) => chalk.cyan(s),\n selectedText: (s: string) => chalk.cyan.bold(s),\n description: (s: string) => chalk.dim(s),\n scrollInfo: (s: string) => chalk.dim(s),\n noMatch: (s: string) => chalk.dim(s),\n },\n};\n\nexport const markdownTheme = {\n heading: (s: string) => chalk.cyan.bold(s),\n link: (s: string) => chalk.cyan.underline(s),\n linkUrl: (s: string) => chalk.dim(s),\n code: (s: string) => chalk.yellow(s),\n codeBlock: (s: string) => chalk.yellow(s),\n codeBlockBorder: (s: string) => chalk.dim(s),\n quote: (s: string) => chalk.italic(s),\n quoteBorder: (s: string) => chalk.dim(s),\n hr: (s: string) => chalk.dim(s),\n listBullet: (s: string) => chalk.cyan(s),\n bold: (s: string) => chalk.bold(s),\n italic: (s: string) => chalk.italic(s),\n strikethrough: (s: string) => chalk.strikethrough(s),\n underline: (s: string) => chalk.underline(s),\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAaA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACvBP,IAAM,iBAAiB,oBAAI,IAAI;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,kBAAkB,oBAAI,IAAI;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,IAAM,oBAAoB,oBAAI,IAAI;AAAA,EAChC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,SAAS,kBAAkB,UAA0B;AAC1D,MAAI,aAAa,WAAW,aAAa,gBAAgB,aAAa,gBAAgB;AACpF,WAAO;AAAA,EACT;AACA,MAAI,eAAe,IAAI,QAAQ,EAAG,QAAO;AACzC,MAAI,gBAAgB,IAAI,QAAQ,EAAG,QAAO;AAC1C,MAAI,kBAAkB,IAAI,QAAQ,KAAK,SA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