piroboros 0.1.0 → 0.2.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/dist/durable.js CHANGED
@@ -1,3 +1,6 @@
1
+ import { existsSync, renameSync, rmSync } from "node:fs";
2
+ import { DatabaseSync } from "node:sqlite";
3
+ import { dirname, join } from "node:path";
1
4
  import { BACKGROUND_CONTEXT, withCancel } from "@earendil-works/chord/context";
2
5
  import { AgentDoc, CompactionTask, configure, createRegistry, defineDoc, defineDocFamily, defineEntry, defineTask, defineTool, defineExtension, GenerationTask, Harness, hook, InboxDoc, LiveDoc, MemoryStorage, ROOT_CONVERSATION_ID, section, SessionFailed, ToolTask, watchEvents, wrapTool, } from "@earendil-works/pi-durable";
3
6
  import { NodeExecutionEnv } from "@earendil-works/pi-durable/env/node";
@@ -42,15 +45,76 @@ class ShellEnv extends NodeExecutionEnv {
42
45
  }
43
46
  }
44
47
  export async function openHarness(options) {
45
- const storage = options.storage ?? (options.path === undefined ? new MemoryStorage() : await openNodeSqliteStorage(options.path));
48
+ const storage = options.storage ?? (options.path === undefined ? new MemoryStorage() : (backupBeforeSchema2(options.path), await openNodeSqliteStorage(options.path)));
46
49
  return Harness.open(storage, {
47
50
  models: options.models,
51
+ ...(options.identity === undefined ? {} : { identity: options.identity }),
48
52
  registry: options.registry,
49
53
  settings: options.settings,
50
54
  env: (target) => (options.env ? options.env(target.cwd) : new ShellEnv({ cwd: target.cwd ?? process.cwd(), shellPath: findBash() })),
51
55
  onReport: options.onReport ?? (() => { }),
56
+ ...(options.telemetry === undefined ? {} : { telemetry: options.telemetry }),
52
57
  }, ctx);
53
58
  }
59
+ /** Copy a SQLite database through `<target>.tmp`, checked by quick_check, so a partial copy never has the final name. The caller rules out an existing target. */
60
+ export function backupDatabase(source, target) {
61
+ const tmp = `${target}.tmp`;
62
+ rmSync(tmp, { force: true });
63
+ try {
64
+ const db = new DatabaseSync(source);
65
+ try {
66
+ db.prepare("VACUUM INTO ?").run(tmp);
67
+ }
68
+ finally {
69
+ db.close();
70
+ }
71
+ const copy = new DatabaseSync(tmp, { readOnly: true });
72
+ try {
73
+ const rows = copy.prepare("PRAGMA quick_check").all();
74
+ if (rows.length !== 1 || rows[0].quick_check !== "ok")
75
+ throw new Error(`the copy failed quick_check: ${rows.map((r) => r.quick_check).join("; ")}`);
76
+ }
77
+ finally {
78
+ copy.close();
79
+ }
80
+ renameSync(tmp, target);
81
+ }
82
+ catch (error) {
83
+ rmSync(tmp, { force: true });
84
+ throw error;
85
+ }
86
+ }
87
+ /** ponytail: one-time guard for the schema 1 to 2 migration of pi-durable main, after which 0.1.0 cannot open the chat database. Delete after 0.3.0. */
88
+ function backupBeforeSchema2(path) {
89
+ const target = join(dirname(path), "chat.schema1.sqlite");
90
+ if (target === path)
91
+ throw new Error(`invariant: the chat database may not be named ${target}`);
92
+ if (!existsSync(path))
93
+ return;
94
+ const db = new DatabaseSync(path);
95
+ let version;
96
+ try {
97
+ const table = db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'durable_schema'").get();
98
+ version = table === undefined ? undefined : db.prepare("SELECT version FROM durable_schema WHERE singleton = 1").get()?.version;
99
+ }
100
+ finally {
101
+ db.close();
102
+ }
103
+ if (version !== 1)
104
+ return; // no table (new or empty file) or already schema 2: nothing to back up
105
+ if (existsSync(target))
106
+ throw new Error(`${target} is from an earlier upgrade and ${path} is schema 1 again; move ${target} somewhere else, then start piroboros again`);
107
+ try {
108
+ backupDatabase(path, target);
109
+ }
110
+ catch (error) {
111
+ throw new Error(`could not back up the chat database before its schema 2 migration (if the disk is full, free space): ${error instanceof Error ? error.message : String(error)}`);
112
+ }
113
+ }
114
+ /** Tasks the restart limit parked (pi-durable main). They stay parked across starts until aborted or retried. */
115
+ export async function parkedTasks(harness) {
116
+ return (await harness.inspect(ctx)).tasks.filter((t) => t.state.kind === "blocked" && t.state.reason === "restart_limit").map((t) => t.record);
117
+ }
54
118
  /* --- named behaviors ---------------------------------------------------------------------------------- */
55
119
  export const MARKER_KIND = "piroboros.turn";
56
120
  /** True when the root has no run in progress. */
@@ -88,7 +152,8 @@ export function submitInput(root, content, requestId) {
88
152
  export function submitSteer(root, content, requestId) {
89
153
  return root.submit({ type: "input", content, whenBusy: "steer", requestId }, ctx);
90
154
  }
91
- const LIVE_STATUSES = new Set(["pending", "running", "waiting", "completing"]);
155
+ /** Every status but "terminal" is live: pending, running, waiting, sleeping, completing. A status this code does not know, or a missing one, counts as live (fails closed). */
156
+ export const isLiveStatus = (status) => status !== "terminal";
92
157
  /**
93
158
  * Whether a task is live. Fails closed: a task that cannot be read, is absent, or reports a status this
94
159
  * code does not know counts as live.
@@ -99,7 +164,7 @@ export async function isTaskLive(harness, taskId) {
99
164
  if (record === undefined)
100
165
  return true;
101
166
  const status = record.state.status;
102
- return status === undefined || LIVE_STATUSES.has(status);
167
+ return isLiveStatus(status);
103
168
  }
104
169
  catch {
105
170
  return true;
package/dist/guard.js CHANGED
@@ -169,7 +169,7 @@ export function createGuard(deps) {
169
169
  if (harness === undefined)
170
170
  return "the guard is not bound to a harness, so a live Conclave pipeline cannot be ruled out";
171
171
  if (await isTaskLive(harness, state.taskId))
172
- return "a Conclave pipeline is running; use /conclave cancel to stop it before writing from the root";
172
+ return "a Conclave pipeline is running or paused; use /conclave cancel to stop it before writing from the root";
173
173
  }
174
174
  // F3: reports are untrusted data. A turn made only of reports may not write or run commands until the user sends something.
175
175
  try {
package/dist/main.js CHANGED
@@ -1,6 +1,5 @@
1
1
  import { createInterface } from "node:readline/promises";
2
- import { DatabaseSync } from "node:sqlite";
3
- import { existsSync, rmSync, writeSync } from "node:fs";
2
+ import { existsSync, writeSync } from "node:fs";
4
3
  import { basename, resolve } from "node:path";
5
4
  import { FileCredentialStore } from "./auth.js";
6
5
  import { checkIntegrity, ConfigError, describeIntegrity, ensureHome, getDeviceId, homeOutsideProfileWarning, homePaths, isModelRef, readSettings, recordIntegrity, recordUnrecorded, resolveHome, splitModelRef, } from "./config.js";
@@ -13,7 +12,7 @@ import { failureText } from "./chat/turn.js";
13
12
  import { sanitizeTerminal } from "./tui/sanitize.js";
14
13
  import { themeSequences } from "./tui/theme.js";
15
14
  import { SETUP_HINT, SetupError } from "./setup.js";
16
- import { recentEntries, SessionFailed } from "./durable.js";
15
+ import { backupDatabase, recentEntries, SessionFailed } from "./durable.js";
17
16
  // Command line entry. Exit codes: 0 success, 1 runtime failure or cancel, 2 missing requirement or no main
18
17
  // model, 3 another process holds the lock, 4 login required, 5 config files changed outside piroboros.
19
18
  export const EXIT = { ok: 0, failure: 1, requirement: 2, busy: EXIT_LOCK_BUSY, login: 4, tamper: 5, turnFailed: 6 };
@@ -162,18 +161,13 @@ export async function main(argv, deps = {}) {
162
161
  err(`piroboros: ${target} already exists; choose a new file name\n`);
163
162
  return EXIT.failure;
164
163
  }
165
- const db = new DatabaseSync(paths.chat);
166
164
  try {
167
- db.prepare("VACUUM INTO ?").run(target);
165
+ backupDatabase(paths.chat, target);
168
166
  }
169
167
  catch (error) {
170
- rmSync(target, { force: true });
171
168
  err(`piroboros: backup failed: ${error instanceof Error ? error.message : String(error)}\n`);
172
169
  return EXIT.failure;
173
170
  }
174
- finally {
175
- db.close();
176
- }
177
171
  out(`backup written to ${target}\n`);
178
172
  return EXIT.ok;
179
173
  }
package/dist/runtime.js CHANGED
@@ -2,7 +2,8 @@ import { readFileSync } from "node:fs";
2
2
  import { FileCredentialStore } from "./auth.js";
3
3
  import { createBase } from "./base.js";
4
4
  import { checkIntegrity, compactorStatus, describeIntegrity, ensureHome, getDeviceId, homePaths, isModelRef, profileDir, mergeSettings, readSettings, recordIntegrity, recordUnrecorded, reloadChanges, splitModelRef, unsetSettings, withDefaults, } from "./config.js";
5
- import { configure, createRegistry, ctx, defineExtension, onSessionFailed, openHarness, ROOT, SessionFailed } from "./durable.js";
5
+ import { configure, createRegistry, ctx, defineExtension, onSessionFailed, openHarness, parkedTasks, ROOT, SessionFailed } from "./durable.js";
6
+ import { openTelemetry } from "./telemetry.js";
6
7
  import { MemoryHost } from "./memory/host.js";
7
8
  import { createAkashicTool } from "./memory/akashic/tools.js";
8
9
  import { createMnemosiaTools } from "./memory/mnemosia/tools.js";
@@ -24,9 +25,12 @@ import { ThinkingState } from "./tui/thinking/state.js";
24
25
  /** The root stops when its run shows no output and no running tool for this long (the provider SDK stops its own timer once headers arrive). */
25
26
  export const ROOT_IDLE_TIMEOUT_MS = 600_000;
26
27
  export const idleStopText = (ms) => `stopped (idle): no output for ${Math.round(ms / 1000)} s.`;
27
- function reportMessage(error) {
28
- return error instanceof Error ? error.message : String(error);
28
+ function reportMessage(error, info) {
29
+ const text = error instanceof Error ? error.message : String(error);
30
+ const source = info === undefined ? undefined : "task" in info && info.task !== undefined ? info.task.kind : "extension" in info ? info.extension : undefined;
31
+ return source === undefined ? text : `${source}: ${text}`;
29
32
  }
33
+ const pausedText = (n) => `${n === 1 ? "1 task" : `${n} tasks`} stopped without finishing on several starts in a row and ${n === 1 ? "is" : "are"} paused: Esc stops a paused reply, /conclave cancel a paused pipeline`;
30
34
  export async function openRuntime(options) {
31
35
  const paths = homePaths(options.home);
32
36
  // A storage error fails the whole session (pi-durable 1.2.0). Reports once the session is closing are noise.
@@ -161,18 +165,32 @@ export async function openRuntime(options) {
161
165
  // The skills section is the last static section: after chat, before budget. It renders nothing without skills.
162
166
  const planningOn = withDefaults(settings).planning;
163
167
  const rootExtensions = [guard.extension, base, viewtools, ...(planningOn ? [planning] : []), memoryExtension, stuck, chat, skills.extension, budget];
168
+ // A failure to open the store turns telemetry off, visibly; the run goes on without it.
169
+ let telemetry;
170
+ if (withDefaults(settings).telemetry) {
171
+ try {
172
+ telemetry = await openTelemetry(paths.telemetry);
173
+ }
174
+ catch (error) {
175
+ report(`telemetry off: ${reportMessage(error)}`);
176
+ }
177
+ }
164
178
  const harness = await openHarness({
165
179
  path: options.persistent === false ? undefined : paths.chat,
166
180
  storage: options.storage,
181
+ telemetry: telemetry?.recorder,
167
182
  models,
183
+ identity: { attribution: null },
168
184
  registry,
169
185
  settings: {
170
186
  extensions: [guard.extension, base, viewtools, budget], steeringMode: "all", followUpMode: "all", compaction: { enabled: false, backgroundTokens: 0 },
171
187
  // A getter: pi-durable reads it at every request, so /reload applies a changed cacheRetention at the next turn.
172
188
  get stream() { return { cacheRetention: withDefaults(effective()).cacheRetention }; },
173
189
  },
174
- onReport: (error) => report(reportMessage(error)),
175
- }).catch((error) => {
190
+ onReport: (error, info) => { if (info.type !== "task_parked")
191
+ report(reportMessage(error, info)); },
192
+ }).catch(async (error) => {
193
+ await telemetry?.close().catch(() => undefined);
176
194
  memory.close();
177
195
  throw error;
178
196
  });
@@ -202,6 +220,7 @@ export async function openRuntime(options) {
202
220
  }
203
221
  catch (error) {
204
222
  await harness.close(ctx);
223
+ await telemetry?.close().catch(() => undefined);
205
224
  memory.close();
206
225
  throw error;
207
226
  }
@@ -225,6 +244,9 @@ export async function openRuntime(options) {
225
244
  });
226
245
  // pi-durable resumes a live pipeline by itself. Say so, and forget one that ended while piroboros was closed.
227
246
  await conclave.recover().catch((error) => report(reportMessage(error)));
247
+ const parked = await parkedTasks(harness);
248
+ if (parked.length > 0)
249
+ options.onStatus?.({ kind: "notice", message: pausedText(parked.length) });
228
250
  const compact = new CompactLoop({ harness, root, compactor, onAlarm: (text) => report(`alarm: ${text}`), onReport: (error) => report(reportMessage(error)) });
229
251
  const loop = new TurnLoop({
230
252
  harness,
@@ -321,6 +343,7 @@ export async function openRuntime(options) {
321
343
  throw error;
322
344
  }
323
345
  },
346
+ telemetry: async () => (telemetry === undefined ? "telemetry is off; /settings telemetry turns it on at the next start" : telemetry.summary()),
324
347
  fatal,
325
348
  async close() {
326
349
  // Every step runs even when an earlier one throws; the errors are reported together.
@@ -338,6 +361,7 @@ export async function openRuntime(options) {
338
361
  await step(() => compact.stop());
339
362
  await step(() => search.close());
340
363
  await step(() => harness.close(ctx));
364
+ await step(() => telemetry?.close());
341
365
  // Flush the briefing traces, then close the store. The tools can no longer run.
342
366
  await step(() => mnemosia.close());
343
367
  await step(() => memory.close());
@@ -0,0 +1,84 @@
1
+ import { openNodeSqliteDatabase } from "@earendil-works/chord/sqlite/node";
2
+ import { createSqliteTelemetry } from "@earendil-works/chord/telemetry-sqlite";
3
+ /**
4
+ * ponytail: error text (status.error.message of a span: a provider's reply, a thrown fault) can echo prompt text or
5
+ * paths, so a connection-local TEMP trigger removes it from every inserted span; the error name stays. secure_delete
6
+ * keeps the removed text out of the WAL. If upstream moves error text to another column this misses it: rerun the
7
+ * canary probe on every pi-durable, chord or pi-ai upgrade.
8
+ */
9
+ const DROP_ERROR_TEXT = `PRAGMA secure_delete = ON;
10
+ CREATE TEMP TRIGGER drop_error_text AFTER INSERT ON main.telemetry_spans
11
+ WHEN json_extract(NEW.status, '$.error.message') IS NOT NULL
12
+ BEGIN UPDATE telemetry_spans SET status = json_remove(NEW.status, '$.error.message') WHERE id = NEW.id; END;`;
13
+ export async function openTelemetry(path) {
14
+ const db = await openNodeSqliteDatabase(path);
15
+ let recorder;
16
+ try {
17
+ recorder = await createSqliteTelemetry(db);
18
+ await db.exec(DROP_ERROR_TEXT);
19
+ }
20
+ catch (error) {
21
+ await recorder?.close().catch(() => undefined);
22
+ await db.close().catch(() => undefined);
23
+ throw error;
24
+ }
25
+ const rec = recorder;
26
+ return {
27
+ recorder: rec,
28
+ async summary(now = Date.now()) {
29
+ let head = "";
30
+ try {
31
+ await rec.flush();
32
+ }
33
+ catch (error) {
34
+ head = `telemetry recording stopped: ${error instanceof Error ? error.message : String(error)} (the numbers below are up to then)\n`;
35
+ }
36
+ const startMin = now - 86_400_000;
37
+ const [duration, tokens, cost] = await Promise.all(["pi.ai.request.duration", "pi.ai.tokens", "pi.ai.cost"].map((name) => rec.findMetrics({ name, startMin })));
38
+ const rows = new Map();
39
+ const row = (m) => {
40
+ const key = `${m.attributes.provider}/${m.attributes.model}`;
41
+ if (!rows.has(key))
42
+ rows.set(key, { n: 0, failed: 0, ms: 0, input: 0, output: 0, cost: 0 });
43
+ return rows.get(key);
44
+ };
45
+ for (const m of duration) {
46
+ const r = row(m);
47
+ r.n += m.count;
48
+ r.ms += m.sum;
49
+ if (m.attributes.stop === "error")
50
+ r.failed += m.count;
51
+ }
52
+ for (const m of tokens) {
53
+ const r = row(m);
54
+ if (m.attributes.kind === "input")
55
+ r.input += m.sum;
56
+ else if (m.attributes.kind === "output")
57
+ r.output += m.sum;
58
+ }
59
+ for (const m of cost)
60
+ row(m).cost += m.sum;
61
+ const lines = [...rows].filter(([, r]) => r.n > 0).map(([model, r]) => `${model}: ${r.n} requests, ${r.failed} failed, ${(r.ms / r.n / 1000).toFixed(1)} s average, ${r.input} in / ${r.output} out tokens, $${r.cost.toFixed(4)}`);
62
+ return `${head}${lines.length === 0 ? "no model requests recorded in the last 24 hours" : `model requests, last 24 hours (the last 10 seconds may not show yet)\n${lines.join("\n")}`}`;
63
+ },
64
+ async close() {
65
+ const errors = [];
66
+ try {
67
+ await rec.close();
68
+ }
69
+ catch (error) {
70
+ errors.push(error);
71
+ }
72
+ try {
73
+ await db.close();
74
+ }
75
+ catch (error) {
76
+ errors.push(error);
77
+ }
78
+ if (errors.length === 1)
79
+ throw errors[0];
80
+ if (errors.length > 1)
81
+ throw new AggregateError(errors, "telemetry close failed in more than one step");
82
+ },
83
+ };
84
+ }
package/dist/tui/app.js CHANGED
@@ -501,6 +501,8 @@ export function runCommand(rt, text, ask, flow) {
501
501
  const started = sub === "approve" ? rt.conclave.approve() : rt.conclave.start(text.slice("/conclave".length));
502
502
  return started.then((result) => (result.ok ? result.message : `not started: ${result.error}`));
503
503
  }
504
+ if (name === "telemetry")
505
+ return rt.telemetry();
504
506
  if (name === "skills")
505
507
  return skillsReport(rt.skills.state(), COMMANDS.map((command) => command.name));
506
508
  if (name === "akashic")
@@ -11,6 +11,7 @@ export const COMMANDS = [
11
11
  { name: "akashic", description: "memory status, accept and vault", args: "[status | accept | vault ...]" },
12
12
  { name: "thinking-steps", description: "choose how thinking steps are shown", args: "[mode | global <mode | clear>]" },
13
13
  { name: "skills", description: "list the skills the chat can use" },
14
+ { name: "telemetry", description: "model requests, latency and cost of the last 24 hours" },
14
15
  ];
15
16
  /** The skills that are commands: a name that starts with a letter, and no built-in command of the same name (that one wins). */
16
17
  const commandSkills = (skills) => skills.filter((skill) => /^[a-z]/u.test(skill.name) && !COMMANDS.some((command) => command.name === skill.name));
@@ -0,0 +1,21 @@
1
+ # The Conclave
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ The Conclave is a team of eight agents defined in `agents/*.md` and `skills/conclave/SKILL.md`. `/conclave <task>` starts a review. Samaela plans, then Nytheria, Elaria, Raskreia, Avaritia, Vaelia and Astrelia review in that order. Each member runs alone, in its own child conversation, and sees the task and the reports posted so far. If any reviewer's verdict is `proceed with changes` or `send back`, Samaela runs once more as the final-plan seat (shown as "Samaela (final plan)" in the pane). She gets the task, her first plan and all the reviewer reports, and her report is the final plan; Vesperia is briefed with it in place of the first plan. When every verdict is `proceed`, this step is skipped. Each member's final message is posted as a report, but the reports are held while the pipeline runs: they reach the chat together, in one turn, when the review ends at `awaiting approve`, or when the execution finishes, fails or is cancelled. Messages you send meanwhile are answered as usual and do not bring the held reports in. A report over 4,000 characters keeps its first 2,400 and last 1,400 characters, and every report ends with a pointer to the member's whole chat. When the report's verdict line falls in the cut part, it is repeated after the cut marker, so the verdict still counts. `zoom("Name")` shows that member's latest run, 30,000 characters per page (`zoom` with `page`). Names are not case-sensitive; an unknown name and a member that has not run yet get different answers.
6
+
7
+ ## The pane
8
+
9
+ While a pipeline exists, the chat shows a Conclave pane. Each member is `waiting`, `running`, `done`, `partial`, `blocked`, `failed (reason)`, `not run` or, for Vesperia after a complete review, `awaiting approve`. The running member's last entries and its answer in progress appear under the list, at most 10 lines. A hint under the list says what to do next: `/conclave cancel stops it` while it runs, `/conclave approve runs Vesperia` when it waits, `/conclave approve runs Vesperia again` after a stopped execution, and `/conclave <task> starts a new review` after a failed review. When the terminal has too few rows, the pane drops rows in this order: the stream, the thinking steps, the member's name, members that wait, finished members, the hint, other members, the running member and the title. A pane under the chat is hidden when the chat would get fewer than 8 rows. In a terminal of 100 columns or more there is always a right column, 30% wide. It shows the Conclave pane while a pipeline is running, waiting for approval or stopped with a failed member, and a session panel otherwise: the main model, the thinking level, the chat view size against 128 KB, the compactor state, the memory status, web access, and the outcome of the last run (or the hint `/conclave <task>`). In a narrower terminal the pane goes under the chat at full width with 4 stream lines, and there is no idle panel. A pipeline that completed shows one line with its outcome, and a stopped one keeps the member list so the failed member and its reason stay visible.
10
+
11
+ ## Running and controlling a pipeline
12
+
13
+ - `/conclave approve` runs Vesperia, who executes the plan of the latest complete review. Only Vesperia can write files and run shell commands, and she can write only inside the working directory. The reviewers can read, search, `zoom` and `date`. They also have `mnemosia_brief`. They have no shell, because the shell is not confined to a directory, and they cannot write memory.
14
+ - `/conclave cancel` stops a running pipeline and posts a `FAILED (cancelled)` report. `/conclave status` shows the current member.
15
+ - `/conclave undo` restores the files of the last Vesperia run. It covers only what she changed with the `write` and `edit` tools. Changes made through `bash` are not covered; the list says how many shell commands she ran. Only the latest run is kept. Before the first change, the tools save the exact bytes of each file under `<home>/undo/<run>/`, so these copies can hold file contents, secrets included. They are not redacted and are deleted by the undo or when the next run starts. Files over 1 MB, or past 20 MB of copies per run, are listed as not restorable. The command shows what it would restore, delete and skip, and asks before it touches anything. A file that changed after the run is skipped. A file the run created is deleted only if it is unchanged since. It is refused while a pipeline runs. Her decision memory, if any, stays quarantined until you run `/akashic accept`; there is no reject command.
16
+ - After a run that ended `partial`, `blocked` or failed, `/conclave approve` starts a new Vesperia and gives her the earlier report as one more card, marked as evidence and not as instructions. Type your new instruction in the chat first. The brief says whether `/conclave undo` restored the files. The pane shows `partial` or `blocked` for Vesperia instead of `done`. A new review forgets the earlier report. After a run that ended `done`, `/conclave approve` is refused: start a new review with `/conclave <task>`. A run with no verdict line can be approved again.
17
+ - `/conclave` is refused while the chat is busy with a turn or while another pipeline runs. Esc in the chat does not stop a pipeline.
18
+ - A member that gives no report, makes too many model calls (`maxTurns`, 64, or 256 for Vesperia), produces no output for too long (`idleTimeoutMs`, 10 minutes, not counted while a tool runs) or repeats the same failing call is reported as `FAILED`, and the pipeline stops there. A member whose final answer is empty, aborted or errored is reported as `FAILED: no report produced`.
19
+ - Each member's model is `conclave.members.<name>.model`, then `conclave.defaultModel`, then `main`. The choice is made once when the pipeline starts. A member whose model has no credentials fails the start before any member runs. `model:` is not allowed in an agent file, because the model is your choice and belongs in `settings.json`. `thinking`, `maxTurns` and `idleTimeoutMs` can be set per member in `settings.json` as well. The thinking level defaults come from the agent files: Samaela `high`, Vesperia `medium`, Astrelia and Vaelia `low`, the other reviewers `medium`. To give Samaela one model and the others another, set `conclave.members.samaela.model` and `conclave.defaultModel`, as in `settings.json.example`; `/settings conclave.members.samaela` edits the same keys from the chat.
20
+ - While a pipeline runs, the root chat cannot write files or run commands. A chat turn that was started only by member reports cannot either, until you send a message. Reports are treated as untrusted data. Such a turn ends its input with one line from piroboros that tells the model this rule, so it summarizes the reports and points to `/conclave approve` or a reply from you instead of trying a tool that would be refused.
21
+ - If piroboros closes while a pipeline runs, it resumes the pipeline at the next start and says so.
@@ -0,0 +1,48 @@
1
+ # Configuration and commands
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ ## Files and data
6
+
7
+ Everything piroboros stores lives under `PIROBOROS_HOME` (default `~/.piroboros`): the chat database, `chat.schema1.sqlite` (the copy made before the schema 2 upgrade), `telemetry.sqlite`, `auth.json`, `settings.json`, `models.json`, the memory stores, the optional vault clone, your `skills` folder and `skills-trust.json`. Copy `settings.json.example` and `models.json.example` from this repository as a starting point; the examples use placeholder hosts.
8
+
9
+ `PIROBOROS_HOME/instructions.md` is an optional file of your own standing instructions. It is read again for every request, so an edit applies at the next turn and `/reload` is not needed. The text goes to the main model as an `instructions` section and is also appended to the compactor's system prompt, so the compactor follows it too. A line meant only for replies should say so, for example "Do not apply this to compaction lines."
10
+
11
+ ## Custom providers (`models.json`)
12
+
13
+ `models.json` adds providers that speak one of three wire formats: `openai-completions`, `openai-responses` or `anthropic-messages`. Each model needs `id`, `api`, `baseUrl`, `contextWindow` and `maxTokens`. See `models.json.example`.
14
+
15
+ - OpenAI formats take a base URL that ends in `/v1`. The Anthropic format takes the host root, because the client adds `/v1/messages` itself; a base URL ending in `/v1` is rejected.
16
+ - A provider id must not contain `/`, and must not be the id of a built-in provider.
17
+ - A model needs `contextWindow` minus `maxTokens` of at least 24,000 to load. The main model needs `contextWindow` minus `maxTokens` minus 2,000 to be at least 72,000, otherwise it is listed as disabled in the main-model picker.
18
+ - The API key comes from the variable `<ID>_API_KEY`: the id is upper-cased and every character outside A-Z and 0-9 becomes an underscore, so `my-llm.v2` reads `MY_LLM_V2_API_KEY`. A key stored through setup or `/login` takes precedence over the variable.
19
+ - A UTF-8 BOM at the start of the file is accepted.
20
+ - Two optional keys control reasoning. `thinkingLevelMap` maps piroboros thinking levels (`off`, `minimal`, `low`, `medium`, `high`, `xhigh`, `max`) to the value the provider accepts, or to `null` for a level the model does not support; it needs `"reasoning": true`. `compat` is passed to pi-ai unchanged and covers provider differences such as `supportsReasoningEffort` or `thinkingFormat`. Some models reason by default even when no level is sent, so mapping `off` to the provider's lowest value is how you cap them. For example, a model that accepts only `low` and `high`:
21
+
22
+ ```json
23
+ "reasoning": true,
24
+ "compat": { "supportsReasoningEffort": true },
25
+ "thinkingLevelMap": { "off": "low", "minimal": "low", "low": "low", "medium": "low", "high": "high", "xhigh": "high", "max": "high" }
26
+ ```
27
+ - An invalid file does not stop startup. piroboros starts without custom providers and shows the error, which names the field. `/reload` re-reads `models.json` and `settings.json` and keeps the previous configuration if either is invalid.
28
+
29
+ ## Command line
30
+
31
+ - `npm start` opens the chat. If no main model is set it runs setup first. To type `piroboros` in any terminal instead, run `npm link` once in this folder; `npm unlink -g piroboros` removes it. While the chat is open the window title reads `piroboros - <folder>`, the folder it was started in.
32
+ - `npm run setup` runs the guided setup. It needs the same exclusive access as the chat, so it exits with code 3 while the chat is open. If a config file was edited outside piroboros, setup shows the change and asks whether to accept it before it starts, the same as starting the chat does; answering no exits with code 5.
33
+ - `--print <message>` sends one message and prints the answer. `--model provider/model` uses another model for that run only, with `--print` and for the interactive start; an unknown model exits 2 and does not open setup. Exit codes: 2 when no main model is set, 4 when login is required, 5 when the config files were changed outside piroboros.
34
+ - `--backup <file>` writes a copy of the chat database.
35
+
36
+ ## Chat commands
37
+
38
+ `/model`, `/reload`, `/login`, `/settings`, `/status`, `/conclave`, `/akashic`, `/thinking-steps`, `/skills` and `/telemetry` are available in the chat, and so is one command for each skill you have installed (see [Skills](tools.md#skills)).
39
+
40
+ `/telemetry` prints the model requests of the last 24 hours, one line per model: requests, failures, average time, tokens and cost. The last 10 seconds may not show yet. It says so when telemetry is off.
41
+
42
+ `/login` signs in from the chat. `/login` alone lists the providers, with `[ready]` on the ones that already resolve, and the two web search keys. `/login <provider>` goes straight to one, and `/login web-tinyfish` or `/login web-exa` stores a search key. A provider that offers both an OAuth and an API key method asks which one you want, and a provider that is already signed in asks before it signs in again. What you type is masked in a box that replaces the chat, the credential goes to `auth.json`, and error text is scrubbed before it is shown. The sign-in address is shown on screen and opened with the platform's default handler. Esc cancels, and closing piroboros during a sign-in stops its local callback server. The next turn uses the new credential without a restart.
43
+
44
+ `/settings` changes `settings.json` from the chat. `/settings` lists 25 keys and the 8 Conclave members with their current values (a default is marked as such), and the list filters as you type. `/settings conclave.members.vaelia` lists that member's four keys, and `/settings <key>`, for example `/settings web.maxFetches`, goes straight to a key; an unknown key gets a hint. The editor depends on the key: a choice for words and on/off, a number box that starts at the current value and refuses a value outside the allowed range, the setup model pick for model keys (it signs in when the provider needs it), and for lists such as `guard.deny` a menu of the entries, where picking an entry removes it and "Add an entry" adds one. Every key can be reset to its default, which removes it from the file. The editor says when a change applies: at the next turn, right away, at the next Conclave run or at the next start. `cacheRetention` applies at the next turn: `"short"` keeps the prompt cache for about 5 minutes, and `"long"` keeps it for an hour and costs more per cache write.
45
+
46
+ A change to a security-relevant key shows the old and the new value and asks before it is saved. Those keys are `main`, `compactor.model`, `compactor.allowThirdParty`, `conclave.defaultModel`, the model of each Conclave member, `shellEnvAllow`, `shellTimeoutMs`, `guard.deny` and the `web` keys. `/model` asks the same way when it changes the main model, and asks nothing when the model is already the main one. A compactor model on a host that is not loopback also asks whether third-party use is allowed, as setup does, and setting `web.search.provider` with no stored key offers to enter the key. Every write goes through the same checked path as `/thinking-steps global`: if `settings.json` was edited outside piroboros, the write is refused until `/reload`. When piroboros was started with `--model`, `/settings` says so and explains that a change to `main` applies when it starts without the flag.
47
+
48
+ `/reload` shows the changed security-relevant settings (hosts, `allowThirdParty`, `shellEnvAllow`, `guard.deny`, the `web` keys) and asks before it accepts files that were edited outside piroboros. `/status` shows the messages saved, the summary view size and the cache use of recent responses. The compactor asks its model for lines of at most 400 bytes; 512 bytes stays the hard limit, and a line still over it after five tries is cut at a clause boundary. A provider reply of HTTP 429 or 503 counts as busy: the compactor waits longer and does not count it as an error, up to 20 times per node, and `/status` shows the retries made while the provider was busy. Until a compactor is configured, long messages show as "not summarized yet" lines and each request carries a window of at most 128 KB of the view.
@@ -0,0 +1,25 @@
1
+ # Development
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ This page applies to a source checkout. `src/tune` is not in the npm package.
6
+
7
+ ```
8
+ npm run typecheck
9
+ npm run build
10
+ ```
11
+
12
+ `npm run build` writes `dist/`, the step `npm pack` runs before packing. The launcher never runs a `dist/` found in a checkout. The repository has no test suite.
13
+
14
+ Versions follow semver. See `CHANGELOG.md`.
15
+
16
+ ## Compactor prompt tuning
17
+
18
+ `npm run tune:compactor` runs the real compaction prompts over 12 made-up coding chats (8 dev, 4 held-out, in `src/tune/corpus`) and scores each produced line against fixed probes: exact tokens that must survive, and corrected values that must replace the old one. A candidate in `src/tune/candidates` is kept only if its held-out mean beats the baseline by `--margin` (default 0.02), its dev mean does not drop, and no probe type drops on the held-out chats. The script prints a verdict and never edits `src`; apply a winning candidate to `src/chat/prompt.ts` yourself, then delete its file. A candidate is a JSON file `{ "name", "messageTaskSuffix"?, "mergeTaskSuffix"? }`. The first one, the "was X, now Y (replaced)" rule for merges, won over three repeats (held-out 0.671 to 0.814, corrections kept 4% to 58%) and is now part of the merge task.
19
+
20
+ ```
21
+ npm run tune:compactor -- --dry-run
22
+ npm run tune:compactor -- --yes
23
+ ```
24
+
25
+ It uses the compactor model from your `settings.json` (or `--model provider/id`) with your stored login. Other options: `--repeats N` (default 1) and `--out file.json`, which also holds a `meta` block with the date, model, thinking level, repeats, margin and each candidate's name and text. A real run needs `--yes` because it sends hundreds of requests to that provider and costs money: `--dry-run` prints the minimum call count first, and replies over 512 bytes add retries. The chats are invented and the corpus is not scrubbed or sent anywhere else.
@@ -0,0 +1,33 @@
1
+ # Interface
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ ## The command list and questions
6
+
7
+ Typing `/` as the first character opens a list of commands above the input, with a one-line description and the argument hint of each. Up and Down move, Tab completes the highlighted name, Enter runs a command that takes no argument or completes one that does, and Esc closes the list and keeps the text. After a space the list offers the choices for `/model`, `/conclave`, `/thinking-steps`, `/akashic`, `/login` (providers and the two web keys) and `/settings` (keys and members, matched anywhere in the name). Text that is not a command, such as `/srv/data`, goes to the chat. Questions that need an answer, such as the `/reload` confirmation, open an overlay that replaces the chat until it is answered; Esc cancels it, and a secret typed or pasted there is masked with a fixed-length mask.
8
+
9
+ ## Screen layout
10
+
11
+ The screen is never as tall as the window, because Ink clears the whole console on Windows when a frame is as tall as the window. The chat, the command list, replies, the pane and the notices share the rows, and the chat always keeps at least 3. From top to bottom the screen shows the header, the chat (with held messages under it), standing notices, replies, alerts, the status line, the command list and the input box. In a terminal under 16 rows or 60 columns there is no header and there are no boxes, and a row of key hints sits above the input; otherwise the keys show in the empty input. The chat shows the last 60 entries. PgUp and PgDn scroll it, also while the command list is open, and End returns to the newest line. A view you scrolled stays where it is while new lines arrive, until you press End or send a message. Narrowing the window wraps the text again, so the view position is not kept. Tool calls show their main argument, for example `▸ bash npm run build`, or `[tool bash: npm run build]` in a small terminal. Tool output is limited to 3 rows and ends with `(N more lines)`, and a tool error reads `✗ name message`, or `tool error (name): message` in a small terminal. Reports from Conclave members are labeled `◆ <member> report`, or `<member> report:` in a small terminal. After a failed turn the alert says that your message is back in the input and Enter sends it again, and the hint under the error names the next step for that kind of failure.
12
+
13
+ ## Look
14
+
15
+ From 60 columns and 16 rows the screen is drawn in a theme. A header row shows `◆ piroboros`, the version, the state of the app (`ready`, `working (Esc stops)`, `no model set`, `login required`, `ERROR <reason>`, `error` or `stopped`), the number of Conclave members, and `conclave D/N` while a pipeline is live. In a narrow terminal the version leaves the header first, then the member count, then the Conclave count. From 24 rows a rule runs under the header and the chat box starts with a title row: `◆ piroboros` and the main model. The chat sits in a bordered box. Your messages carry a `● You` label with a rule above it, and replies, tool calls and tool results carry a `◆ piroboros` label. A Conclave report carries a `◆ <Member> report` label that ends with a `done` or `failed` pill (Vesperia's follows her verdict: `done`, `partial`, `blocked` or `failed`) and, on the newest report of a member whose run has ended, the time the run took, such as `(2m 14s)`. While a turn or a pipeline runs, the bottom of the chat box shows a rule and one row: `piroboros is working`, or `Waiting for <member> (turn T of M)`; the rows are left out when the chat would be left with fewer than 4 rows. Below come a status row and the input in a bordered box. The input shows the keys while it is empty. When it fits, a strip at its right shows the token counts of the last reply: `IN`, `OUT`, `CACHE` (the share of the prompt read from the cache) and `CTX` (prompt and output against the model's context window). Otherwise the cache counts stay in the status row.
16
+
17
+ From 100 columns a second box sits beside the chat and has the same height. It is `◆ Conclave review` or `◆ Conclave execution` with a progress bar while a pipeline is on screen, and `◆ Session` with the session rows otherwise. Below that every member has a row with a state pill (`running`, `done`, `failed`, `partial`, `blocked`, `waiting`, `awaiting approve`, `not run` or `idle`; a box too narrow for the long words shows `approve` and `idle`). A muted row under it gives how long an ended member took, or the turn and the start time of the running one, and any detail such as the reason for a failure. The one-line description from the member's agent file follows, clipped to the box. After the members come the running member's thinking and stream, a hint, `◆ Recent Activity` (the starts and ends of the latest pipeline, newest first, each with the time and the verdict or reason, or `no conclave run yet` before a timed run) and `◆ Resource Usage` (the last reply of the main chat: input, output, cache read, the cache share, and the share of the context window with a bar). When the box is too short, rows leave in a fixed order: the descriptions and the activity first, then the thinking and the stream, the rules, the hint, the usage rows, the session rows and the progress bar, and the members and the title last. The strip at the right of the input row shows only while the Input row of Resource Usage is not on screen, and the cache counts stay out of the status row while the strip or the Read row shows them. Under 100 columns the Conclave pane sits under the chat, as described in [The Conclave](conclave.md) and the session panel is not shown.
18
+
19
+ The times come from the `conclave` document: each seat's start and end, in the clock of the harness, are stored from this version on and cleared by a new review (a re-approval clears Vesperia's entry). A run from an older version shows no durations and no activity. If piroboros closes while a seat is running, the seat's end is the time the run resumed, so its duration includes the time the program was closed. The pills and durations on report labels are drawn from these numbers when the screen is drawn; they are never written into a report or sent to a model.
20
+
21
+ The colors are a dark red accent, a lighter tint of it for text, grey for secondary text, and green, amber and red for states. At start piroboros sets the terminal's default background to #1A1A1A with OSC 11 and its default text color to white with OSC 10, and resets both with OSC 111 and OSC 110 when it ends, on SIGTERM, SIGHUP and SIGBREAK, and at process exit. Closing the console window delivers SIGHUP, and Windows ends the process shortly after. Ctrl+Break delivers SIGBREAK. SIGTERM arrives only from a program that sends it. Those handlers exit with code 1 without releasing the lock file, as a default kill does, and the operating system frees the file handle. A hard kill, for example from Task Manager, resets nothing, and the colors stay until the tab closes. `NO_COLOR` with a non-empty value, or `FORCE_COLOR=0` or `FORCE_COLOR=false`, turns the colors and the OSC writes off. The setup wizard that runs before the chat gets the palette colors but not the background.
22
+
23
+ The text cursor is the real terminal cursor, set to a blinking bar (DECSCUSR 5) when piroboros starts and reset (DECSCUSR 0) at the same points as the colors. It is set under `NO_COLOR` too, because only the colors are switched off. It sits after the typed text, at the start of the keys text while the input is empty, and is hidden while a question overlay owns the keys; the setup wizard has no cursor. The screen is redrawn with the cursor hidden and shown again each time, so the blink restarts on every redraw while an answer streams. A hard kill does not reset the shape.
24
+
25
+ ## Thinking steps
26
+
27
+ Above each assistant message the chat shows a panel built from the message's thinking blocks, and from the live partial while the answer is still being written. It is display only: thinking never reaches the index, the view, the compactor or the member briefs. There are three modes. `collapsed` is one line with the most relevant step. `summary` (the default) is up to five steps in order. `expanded` is every step with its text. Alt+T cycles the modes. Ctrl+T sets the main model's thinking level to the next of `off`, `minimal`, `low`, `medium`, `high`, `xhigh` and `max` (then `off` again), writes it to `settings.json` like `/settings thinking`, and it applies at the next turn. A model's `thinkingLevelMap` in `models.json` decides what each level sends. `/thinking-steps <mode>` sets the mode for this session. `/thinking-steps global <mode|clear>` writes `tui.thinkingSteps` in `settings.json` and also sets the session mode; `clear` removes the key and the session shows `summary`. A new session starts from the global value, then `summary`. The rows of the panel wrap to the width and keep the tree gutter. They count against the rows of the screen like any chat line, and a long panel scrolls with the chat.
28
+
29
+ The panel says `Waiting for thinking content` while a response has no thinking yet, `No thinking content supplied` when a finished message has none, and `Reasoning is hidden by the provider` for a redacted block. It is hidden when the thinking level is `off` or the main model has `reasoning` false. Steps are re-derived at most every 100 ms while streaming, from the last 32,000 characters; a finished message is parsed once. In the Conclave pane the running member's thinking steps appear under its name, within the same line limit, and only when the member produced thinking. An entry that holds only tool calls has no thinking line. Text from the model is sanitized, so a control character is shown as a symbol. A zero-width joiner between two emoji, as in a family, a flag or a skin tone, is shown as it is; anywhere else it is shown as a symbol.
30
+
31
+ ## Keys
32
+
33
+ - A message you send while a turn runs is added to that turn. Esc stops the turn and puts your unanswered messages back in the input box, in the order you sent them. Ctrl+C does the same while a turn runs, and a second press within 2 seconds exits. With no turn running, Ctrl+C clears text you typed or pasted, and exits when there is none. Text put back after a stop does not count as typed. While a turn runs, the status line starts with `working (Esc stops)`. Ctrl+T steps the main model's thinking level and Alt+T cycles the thinking steps view (see [Thinking steps](#thinking-steps)). Set `NO_COLOR` to turn colors off; an explicit `FORCE_COLOR` wins over it.
package/docs/memory.md ADDED
@@ -0,0 +1,11 @@
1
+ # Memory
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ Three tools give the model memory that outlives the chat. `akashic_memory` keeps durable facts in SQLite at `${PIROBOROS_HOME}/akashic/memory.sqlite`. The categories are decisions, people, project-state, open-loops, preferences and procedures, and the actions are remember, record, search, update, forget, recent and group. Text over 4,000 characters is split into parts that share a group id. Every write records its actor as `piroboros:<role>`. `mnemosia_brief` returns a ranked briefing from those memories within a token budget, and `mnemosia_submit_feedback` reports how a briefing did. Traces and feedback go under `${PIROBOROS_HOME}/mnemosia/`. The root chat and Vesperia have all three tools. The other Conclave members have `mnemosia_brief` only.
6
+
7
+ Before a turn, the top five memories for the working directory are written to the log as a note whenever they change. The view shows the note as `[akashic snapshot <hash>: ids <list>]`, and `zoom` on it shows the text, framed as untrusted data with `<` and `>` escaped.
8
+
9
+ One scanner checks every memory that is written, updated, imported or shown. It rejects hidden characters, text that overrides instructions, asks for the system prompt, sends secrets to an address, or runs downloaded code. A memory written in a turn that holds only member reports is quarantined: it stays out of the snapshot and out of search until you run `/akashic accept <id|all>`. The status line counts quarantined memories. Vesperia's records wait for `/akashic accept` the same way. After a retry that fixed what an earlier attempt got wrong, she may record a short lesson besides her decision memory; it waits for `/akashic accept` too, and you should read it before accepting, because `/akashic accept all` takes everything.
10
+
11
+ `/akashic vault init <repo-url> [--auto-push]` mirrors every memory to a Git clone at `${PIROBOROS_HOME}/akashic/vault/` as Markdown files, committed as `piroboros <piroboros@localhost>`. SQLite stays the source of truth. Nothing is pulled before a write, and a failed mirror never loses the write: the tool result says `saved locally` and names a code (`VAULT_GIT_MISSING`, `VAULT_GH_MISSING`, `VAULT_NOT_PRIVATE`, `VAULT_TRANSPORT`, `VAULT_DIRTY`, `VAULT_PUSH_REJECTED` or `VAULT_CONFLICT`), the status line shows `vault: sync pending`, and the next write or `/akashic vault sync` tries again. A clone that was edited by hand is not written into until you deal with the edit. Project paths are written as hashes. `/akashic vault import` reads the clone's files into the store as proposed memories. It never overwrites or deletes a stored memory, and proposed memories stay out of the snapshot until you run `/akashic vault accept <id|all>`. Records tagged `source=archive` or `source=compaction-extraction` are never mirrored on their own; `/akashic vault commit [message]` copies them into the clone and commits. `/akashic vault status`, `/akashic vault push` and `/akashic` (counts) complete the set.
@@ -0,0 +1,13 @@
1
+ # Privacy and limits
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ - Each provider you configure receives the prompts for the model you assign to it: the main model gets the chat view, the compactor gets the text it summarizes, and each Conclave member gets its own conversation. Everything sent to the compactor is scrubbed first: credential-shaped strings (keys, authorization headers, PEM blocks, JSON and environment-style labels, password phrases), every value in `auth.json`, and the value of every environment variable named `*_API_KEY`, `*_TOKEN` or `*_SECRET` that is 8 or more characters long. Your local log keeps the raw text. A compactor is a third party when its provider is not the one your main model or any Conclave member uses and its address is not loopback; sending the chat to a third party needs your explicit consent (`compactor.allowThirdParty: true`), and a third party also loses hex strings of 32 or more characters. Without consent the compactor shows as disabled with the reason and nothing is sent. This is checked again on every compactor request, so withdrawing consent and running `/reload` stops the next request. "Loopback" means the host is exactly `localhost`, is inside 127.0.0.0/8, or is `::1`, with no user name or password in the URL; piroboros treats it as user-declared local and cannot check that the address really is.
6
+ - Shell output beyond 30,000 characters is cut to its first 12,000 and last 18,000 characters, with a marker in between. The cut part is not saved to any file, so the model has to run the command again to see it.
7
+ - Memory-briefing traces (mnemosia) are written under `PIROBOROS_HOME`. A trace is kept while it is under 90 days old or among the 500 newest, and older ones are deleted at startup. The feedback log, `feedback.jsonl`, is capped at 2 MB; when it passes the cap, the oldest lines are dropped.
8
+ - The shell tool is not path-confined. The guard limits which agents may write. A shell command can reach any path your account can.
9
+ - Shell commands that kill processes (`kill`, `pkill`, `killall`, `taskkill`, `tskill`, `Stop-Process`, `spps`, or `wmic` deleting a process) are refused, because `taskkill /IM node.exe` would also end piroboros. This is a tripwire against accidents, not a sandbox: a command can be worded around it.
10
+ - piroboros records model request and task timings to `telemetry.sqlite` under `PIROBOROS_HOME` and sends them nowhere. It records provider and model names, tool names, token counts, cost, durations, stop reasons and error kinds, never message text, tool arguments, tool output or error messages. Records older than 7 days are deleted while piroboros runs. Telemetry is on by default; `"telemetry": false` stops it at the next start, and deleting the file removes what was recorded.
11
+ - piroboros sends no provider attribution headers. Requests still carry the User-Agent `pi/<version> (<platform>; node/<v>; <arch>)` set by pi-ai.
12
+ - The first start of this version copies `chat.sqlite` to `chat.schema1.sqlite` before upgrading it. The copy holds the whole chat, like `chat.sqlite` itself. Delete it once you no longer need to go back to 0.1.0.
13
+ - The memory vault mirrors to a private GitHub repository. Only GitHub remotes are tested.
package/docs/tools.md ADDED
@@ -0,0 +1,20 @@
1
+ # Tools and skills
2
+
3
+ [Back to the README](../README.md)
4
+
5
+ ## File search, plans and loops
6
+
7
+ - `find` and `grep` search the working directory. They use fff (`@ff-labs/fff-node`, an indexed finder) and fall back to ripgrep when fff cannot load or returns an error, or when `grep` is called with `exact: true`. Each result says which backend answered in `details.backend`. If neither fff nor `rg` works, the tools return a named error (`search_unavailable`). A ripgrep run that fails, for example on an invalid glob, returns `search_rg_failed` with its first error line instead of an empty result. The fff databases live in `${PIROBOROS_HOME}/fff/`. Results under protected locations (`PIROBOROS_HOME`, `~/.ssh`, `.env` files, `guard.deny`) are dropped, credential-shaped text is redacted, and output is capped at 20,000 characters.
8
+ - The `plan` tool keeps a short task list for the current request. The model sends the whole list each time, with exactly one item in progress. The list is shown to the model with every message of that request and is cleared when the next user message starts. Set `"planning": false` in `settings.json` to remove the tool; the change applies at the next start.
9
+ - If the model makes the same tool call five times in a row, it gets a reminder to change approach. If the same call fails eight times in a row, the turn ends and the status line says `stopped (stuck)`. Denied calls do not count. If the model's run produces no output and no tool is running for ten minutes, the turn ends and the status line says `stopped (idle)`. If one run makes 256 tool rounds without finishing, the turn ends and the status line says `stopped (round limit)`.
10
+
11
+ ## Skills
12
+
13
+ A skill is a folder with a `SKILL.md` file. The file starts with a block between two `---` lines that holds a `name` and a `description`, and the instructions follow. Skills are for the main chat. The Conclave members, the compactor and Vesperia do not get them.
14
+
15
+ - **Where they come from.** In this order, and the first skill with a name wins: `PIROBOROS_HOME/skills`, then the `skills` folder inside `.agents` in your user profile, then the project folders, which are the `skills` folder inside `.agents` and the one inside `.piroboros` in the working directory. A skill is a folder one level down, `<folder>/<skill>/SKILL.md`. A link to a folder is followed. A folder with no `SKILL.md` of its own is listed as skipped and is not searched further.
16
+ - **What is read.** Only `name` and `description`, as plain, quoted or block (`>` and `|`) values. Other keys, including nested ones, are ignored. A name is lowercase letters, digits and single hyphens, at most 64 characters, and it may differ from its folder name. A description is cut to 512 characters, and a `SKILL.md` over 256 KB is skipped. A bad file is skipped with a reason that `/skills` shows, and it never stops startup.
17
+ - **What the model sees.** One line per skill (name, description and folder) in a `skills` section of the system prompt, after the chat section. The text changes only when the list changes, or when a name, description or folder does, so prompt caching keeps working. It is capped at 20 KB, filled in the order above, and `/skills` lists what did not fit. The model opens a `SKILL.md` with the `read` tool when a task matches it, and the section says that a `SKILL.md` at a listed path is your instruction. With no skills installed there is no section. A skill deleted after the last scan gives a read error until `/reload`.
18
+ - **Project skills need a yes.** The first time a project skill is seen, and again whenever its `SKILL.md` changes, the chat asks one question for all of them, listing the names and paths. Yes loads them. No records each as declined, and it stays out until its file changes; typing `/name` for it says so. The answers are in `PIROBOROS_HOME/skills-trust.json`, which is checked like the other config files: an edit outside piroboros is shown at startup, and a missing, corrupt or edited file means every project skill is asked about again. The question opens when the chat screen opens. Until you answer, the index holds your own skills only, and a yes adds the project ones. With `--print` no question is possible, so project skills are left out, nothing is recorded and one line on stderr says how many. Only `SKILL.md` is pinned. Scripts and other files beside it can change without a new question, so say yes only to a folder you trust.
19
+ - **Commands.** `/skill-name some request` is sent to the chat exactly as typed, and the model reads the skill. Skills appear in the command list after the built-in commands, with their descriptions. A skill named like a built-in command, such as `conclave`, stays available to the model only, and so does a name that starts with a digit. A name with a digit in it is a command only when it is a loaded skill, so `/42 is the answer` and `/v2` stay ordinary text. `/skills` lists the loaded, shadowed, skipped, declined, waiting and over-budget skills. `/reload` rescans and asks about new project skills.
20
+ - **Reading inside `PIROBOROS_HOME`.** The `read` tool may open files under `PIROBOROS_HOME/skills`, so skills installed there work. Files named like secrets stay refused there: `.env` files, `*.pem`, `*.key`, `*.p12`, `*.pfx`, `*.kdbx`, `id_rsa*`, `id_ed25519*`, `id_ecdsa*`, `*.sqlite*`, `auth.json`, `.netrc` and `.npmrc`. Everything else in the home stays refused for every tool: credentials, settings, the chat database, memory, traces, undo copies and the trust file. Writing under `skills` is refused too, a link out of that folder to a protected place is refused, and a `SKILL.md` that is linked into a protected place is skipped. `find` and `grep` search the working directory only, so they never reach it. The guard is a tripwire for the file tools. It cannot tell a hard link from a file, and shell commands are not confined.