teapot-coding-agent 0.37.209 → 0.37.211

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,9 +49,7 @@ you) — no hand-editing required.
49
49
  ```
50
50
 
51
51
  Save it at `~/.config/teapot-coding-agent/config.json` (or pass a path as
52
- the first CLI arg / `$TEAPOT_CONFIG`). A full template lives in
53
- [`teapot.config.example.json`](teapot.config.example.json). With a config
54
- present the wizard is skipped and your agents start immediately.
52
+ the first CLI arg / `$TEAPOT_CONFIG`).
55
53
 
56
54
  </details>
57
55
 
@@ -81,7 +81,6 @@ export function updateForEvent(e, opts) {
81
81
  };
82
82
  }
83
83
  case "tool_result": {
84
- const _name = String(d.name ?? "tool");
85
84
  return {
86
85
  sessionUpdate: "tool_call_update",
87
86
  toolCallId: String(d.callId ?? e.type),
@@ -5,7 +5,7 @@ import { storeImage, resolveImages } from "../log/image-store.js";
5
5
  import { chat, chatStream } from "./llm.js";
6
6
  import { auditPrompt, parseAuditVerdict } from "./goal-audit.js";
7
7
  import { createCatalog } from "./tool-catalog.js";
8
- import { resetToolCatalog, executeTool, toolSpecs, currentSkills, safeJoin, isContextOverflow, isRequestNodeLimit, hasRunningBgShellsFor, killBgShells, runningBgShellCount } from "./tools.js";
8
+ import { resetToolCatalog, executeTool, toolSpecs, currentSkills, safeJoin, isContextOverflow, isRequestNodeLimit, hasRunningBgShellsFor, killBgShells, runningBgShellCount, listBgShells } from "./tools.js";
9
9
  import { effortChoosable } from "./llm.js";
10
10
  import { turnAnchor } from "./timing.js";
11
11
  import { isBareAcknowledgement } from "./ack.js";
@@ -1416,6 +1416,12 @@ export class Agent {
1416
1416
  workspaceMissing: this.isGhost,
1417
1417
  // live count for the header badge — see runningBgShellCount (#197)
1418
1418
  bgRunning: runningBgShellCount(this.workspace),
1419
+ /**
1420
+ * The bg-jobs PANEL reads this, so its rows come over the same `agent-update` frame as the count in the header badge.
1421
+ * A second REST poll could disagree with the badge by one frame — which is exactly how a running job's row and its
1422
+ * "N running" badge drifted apart (#290).
1423
+ */
1424
+ bgJobs: listBgShells(this.workspace, this.opts.sessionDir),
1419
1425
  session: this.currentSession,
1420
1426
  ...(title ? { sessionTitle: title } : {}),
1421
1427
  branch: this.currentBranch,
@@ -1561,6 +1567,8 @@ export class Agent {
1561
1567
  if (i === -1)
1562
1568
  return null;
1563
1569
  const [p] = this.pendingPrompts.splice(i, 1);
1570
+ if (!p)
1571
+ return null;
1564
1572
  void this.log
1565
1573
  .append("system_note", this.currentSession, this.currentBranch, {
1566
1574
  event: "prompt-cancelled",
@@ -2169,13 +2177,13 @@ export class Agent {
2169
2177
  await this.answerUnansweredToolCalls(m);
2170
2178
  return "end";
2171
2179
  },
2172
- report_progress: async (call, m) => {
2180
+ report_progress: async (call, _m) => {
2173
2181
  await this.recordProgress(call.function.arguments);
2174
2182
  this.reportedThisRound = true;
2175
2183
  await this.answerMeta(call, "progress recorded");
2176
2184
  return "next";
2177
2185
  },
2178
- set_goal: async (call, m) => {
2186
+ set_goal: async (call, _m) => {
2179
2187
  const a = safeParse(call.function.arguments);
2180
2188
  const text = String(a.text ?? "").trim();
2181
2189
  if (text)
@@ -2185,7 +2193,7 @@ export class Agent {
2185
2193
  await this.answerMeta(call, text ? "goal updated" : "empty goal rejected");
2186
2194
  return "next";
2187
2195
  },
2188
- get_goal: async (call, m) => {
2196
+ get_goal: async (call, _m) => {
2189
2197
  await this.answerMeta(call, JSON.stringify({
2190
2198
  goal: this.goal.text || "(none set)",
2191
2199
  status: this.goal.status,
@@ -2227,11 +2235,11 @@ export class Agent {
2227
2235
  await this.answerUnansweredToolCalls(m);
2228
2236
  throw Object.assign(new Error("waiting for user"), { name: "WaitForUser" });
2229
2237
  },
2230
- get_todo: async (call, m) => {
2238
+ get_todo: async (call, _m) => {
2231
2239
  await this.answerMeta(call, this.todo.trim() || "(todo.md is empty — no task list yet)");
2232
2240
  return "next";
2233
2241
  },
2234
- set_todo: async (call, m) => {
2242
+ set_todo: async (call, _m) => {
2235
2243
  const a = safeParse(call.function.arguments);
2236
2244
  const ACTIONS = new Set(["done", "reopen", "add", "remove"]);
2237
2245
  const updates = Array.isArray(a.updates)
@@ -2265,7 +2273,7 @@ export class Agent {
2265
2273
  await this.answerMeta(call, "task list replaced (visible to the operator)");
2266
2274
  return "next";
2267
2275
  },
2268
- get_feedback: async (call, m) => {
2276
+ get_feedback: async (call, _m) => {
2269
2277
  const fb = await fs.readFile(this.feedbackFile, "utf8").catch(() => "");
2270
2278
  this.messages.push({
2271
2279
  role: "tool",
@@ -2274,7 +2282,7 @@ export class Agent {
2274
2282
  });
2275
2283
  return "next";
2276
2284
  },
2277
- add_feedback: async (call, m) => {
2285
+ add_feedback: async (call, _m) => {
2278
2286
  const a = safeParse(call.function.arguments);
2279
2287
  const rule = String(a.rule ?? "").trim().slice(0, 500);
2280
2288
  if (!rule) {
@@ -2285,9 +2293,10 @@ export class Agent {
2285
2293
  const lines = existing.split("\n");
2286
2294
  const idx = lines.findIndex((l) => l.includes(rule.slice(0, 60)));
2287
2295
  if (idx !== -1 && /^\s*- /.test(lines[idx])) {
2288
- const m = lines[idx].match(/\[x(\d+)\]/);
2296
+ const current = lines[idx] ?? "";
2297
+ const m = current.match(/\[x(\d+)\]/);
2289
2298
  const count = m ? Number(m[1]) + 1 : 2;
2290
- lines[idx] = lines[idx].replace(/\[x\d+\]\s*/, "").replace(/- /, `- [x${count}] `);
2299
+ lines[idx] = current.replace(/\[x\d+\]\s*/, "").replace(/- /, `- [x${count}] `);
2291
2300
  await fs.writeFile(this.feedbackFile, lines.join("\n"), "utf8");
2292
2301
  this.messages.push({
2293
2302
  role: "tool",
@@ -2302,7 +2311,7 @@ export class Agent {
2302
2311
  }
2303
2312
  return "next";
2304
2313
  },
2305
- record_decision: async (call, m) => {
2314
+ record_decision: async (call, _m) => {
2306
2315
  const a = safeParse(call.function.arguments);
2307
2316
  const decision = String(a.decision ?? "").trim().slice(0, 500);
2308
2317
  const rationale = String(a.rationale ?? "").trim().slice(0, 2000);
@@ -2326,7 +2335,7 @@ export class Agent {
2326
2335
  await this.answerMeta(call, "decision recorded to decisions.md");
2327
2336
  return "next";
2328
2337
  },
2329
- get_decisions: async (call, m) => {
2338
+ get_decisions: async (call, _m) => {
2330
2339
  const dec = await fs.readFile(this.decisionsFile, "utf8").catch(() => "");
2331
2340
  this.messages.push({
2332
2341
  role: "tool",
@@ -2335,7 +2344,7 @@ export class Agent {
2335
2344
  });
2336
2345
  return "next";
2337
2346
  },
2338
- read_memory: async (call, m) => {
2347
+ read_memory: async (call, _m) => {
2339
2348
  const a = safeParse(call.function.arguments);
2340
2349
  const query = String(a.query ?? "").trim();
2341
2350
  const mem = await fs.readFile(this.memoryFile, "utf8").catch(() => "");
@@ -2388,7 +2397,7 @@ export class Agent {
2388
2397
  : `(no line in memory.md matches ${JSON.stringify(query)} — ${mem.split(/\r?\n/).length} lines searched; call read_memory with no query to see all of it)`);
2389
2398
  return "next";
2390
2399
  },
2391
- list_skills: async (call, m) => {
2400
+ list_skills: async (call, _m) => {
2392
2401
  await this.refreshSkills();
2393
2402
  const list = this.skillsCache.length
2394
2403
  ? this.skillsCache.map((s) => `- ${s.name}: ${s.description || "(no description)"}`).join("\n")
@@ -2396,14 +2405,14 @@ export class Agent {
2396
2405
  await this.answerMeta(call, list);
2397
2406
  return "next";
2398
2407
  },
2399
- set_memory: async (call, m) => {
2408
+ set_memory: async (call, _m) => {
2400
2409
  const a = safeParse(call.function.arguments);
2401
2410
  const content = String(a.content ?? "").slice(0, 32_000);
2402
2411
  await fs.writeFile(this.memoryFile, content, "utf8");
2403
2412
  await this.answerMeta(call, `memory.md REPLACED (${content.length} bytes). It is not in your prompt — call read_memory when you need it.`);
2404
2413
  return "next";
2405
2414
  },
2406
- forget_memory: async (call, m) => {
2415
+ forget_memory: async (call, _m) => {
2407
2416
  const a = safeParse(call.function.arguments);
2408
2417
  const query = String(a.query ?? "").trim();
2409
2418
  if (!query) {
@@ -2434,7 +2443,7 @@ export class Agent {
2434
2443
  `(memory.md is now ${next.length} bytes — re-add with add_memory if that was wrong)`);
2435
2444
  return "next";
2436
2445
  },
2437
- add_memory: async (call, m) => {
2446
+ add_memory: async (call, _m) => {
2438
2447
  const a = safeParse(call.function.arguments);
2439
2448
  const text = String(a.text ?? "").trim().slice(0, 8_000);
2440
2449
  if (!text) {
@@ -2741,7 +2750,7 @@ export class Agent {
2741
2750
  : {}),
2742
2751
  });
2743
2752
  this.consecutiveToolErrors = result.ok ? 0 : this.consecutiveToolErrors + 1;
2744
- if (this.consecutiveToolErrors >= this.opts.maxConsecutiveToolErrors) {
2753
+ if (this.consecutiveToolErrors >= (this.opts.maxConsecutiveToolErrors ?? 0)) {
2745
2754
  await this.log.append("system_note", this.currentSession, this.currentBranch, {
2746
2755
  event: "runaway-detected",
2747
2756
  failures: this.consecutiveToolErrors,
@@ -3211,9 +3220,9 @@ export class Agent {
3211
3220
  });
3212
3221
  }
3213
3222
  async maybeRequestProgress() {
3214
- const elapsedOk = Date.now() - this.lastProgressAt >= this.opts.progressIntervalMs;
3215
- const activityOk = this.activityChars >= this.opts.progressMinChars ||
3216
- this.turnsSinceProgress >= this.opts.progressMaxQuietTurns;
3223
+ const elapsedOk = Date.now() - this.lastProgressAt >= (this.opts.progressIntervalMs ?? 0);
3224
+ const activityOk = this.activityChars >= (this.opts.progressMinChars ?? 0) ||
3225
+ this.turnsSinceProgress >= (this.opts.progressMaxQuietTurns ?? 0);
3217
3226
  if (!elapsedOk || !activityOk)
3218
3227
  return;
3219
3228
  if (this.nudgedAtTurn === this.stats.turns)
@@ -3394,12 +3403,12 @@ export class Agent {
3394
3403
  const before = this.contextSizeForBudgeting();
3395
3404
  if (this.opts.shortContext)
3396
3405
  await this.maybePrune();
3397
- if (!force && before < this.opts.contextTokenBudget)
3406
+ if (!force && before < (this.opts.contextTokenBudget ?? 0))
3398
3407
  return;
3399
3408
  if (!force && this.opts.autoCompact === false)
3400
3409
  return;
3401
3410
  const pruned = await this.maybePrune(true);
3402
- if (pruned > 0 && !force && this.contextSizeForBudgeting() < this.opts.contextTokenBudget) {
3411
+ if (pruned > 0 && !force && this.contextSizeForBudgeting() < (this.opts.contextTokenBudget ?? 0)) {
3403
3412
  await this.log.append("system_note", this.currentSession, this.currentBranch, {
3404
3413
  event: "context-pruned-enough",
3405
3414
  outputs: pruned,
@@ -3433,10 +3442,10 @@ export class Agent {
3433
3442
  });
3434
3443
  return;
3435
3444
  }
3436
- this.lastUsage = undefined;
3445
+ delete this.lastUsage;
3437
3446
  const keepTokens = keepFraction !== undefined
3438
- ? Math.max(1, Math.floor(this.opts.contextTokenBudget * keepFraction))
3439
- : Math.min(KEEP_RECENT_TOKENS, Math.max(1, Math.floor(this.opts.contextTokenBudget / 4)));
3447
+ ? Math.max(1, Math.floor((this.opts.contextTokenBudget ?? 0) * keepFraction))
3448
+ : Math.min(KEEP_RECENT_TOKENS, Math.max(1, Math.floor((this.opts.contextTokenBudget ?? 0) / 4)));
3440
3449
  let cut = -1;
3441
3450
  for (let i = this.messages.length - 1; i >= 1; i--) {
3442
3451
  if (this.estimateTokens(this.messages.slice(i)) > keepTokens)
@@ -3458,7 +3467,7 @@ export class Agent {
3458
3467
  let summarizedCount = oldCount;
3459
3468
  let droppedCount = 0;
3460
3469
  const oldTokens = Math.max(this.estimateTokens(old), oldShareOfBefore);
3461
- const summarizeBar = Math.max(SUMMARIZE_MIN_TOKENS, this.opts.contextTokenBudget * SUMMARIZE_MIN_SHARE);
3470
+ const summarizeBar = Math.max(SUMMARIZE_MIN_TOKENS, (this.opts.contextTokenBudget ?? 0) * SUMMARIZE_MIN_SHARE);
3462
3471
  const worthSummarizing = force || oldTokens >= summarizeBar;
3463
3472
  const previousSummary = this.lastCompactSummary;
3464
3473
  /**
@@ -3817,7 +3826,7 @@ export class Agent {
3817
3826
  const timer = setTimeout(() => {
3818
3827
  this.wake = null;
3819
3828
  resolve();
3820
- }, ms);
3829
+ }, ms ?? 0);
3821
3830
  this.wake = () => {
3822
3831
  clearTimeout(timer);
3823
3832
  this.wake = null;
@@ -129,18 +129,18 @@ export function usageLine(used, budget, window) {
129
129
  * When the window is unknown the budget is the only denominator there is, and the line says so rather than pretending.
130
130
  */
131
131
  const full = Number.isFinite(window) && (window ?? 0) > 0 ? window : 0;
132
- const hasBudget = Number.isFinite(budget) && budget > 0;
132
+ const hasBudget = Number.isFinite(budget ?? 0) && (budget ?? 0) > 0;
133
133
  const denom = full || (hasBudget ? budget : 0);
134
134
  if (!denom)
135
135
  return `context ${fmt(used)} tokens used`;
136
136
  const pct = Math.max(0, Math.min(100, Math.round((used / denom) * 100)));
137
137
  const size = full
138
138
  ? `${fmt(used)}/${fmt(full)} tokens`
139
- : `${fmt(used)}/${fmt(budget)} tokens — the compaction threshold; full window unknown`;
139
+ : `${fmt(used)}/${fmt(budget ?? 0)} tokens — the compaction threshold; full window unknown`;
140
140
  if (!hasBudget)
141
141
  return `context ${pct}% used (${size})`;
142
- const until = Math.max(0, budget - used);
143
- const threshold = full ? ` · auto-compacts at ${fmt(budget)}` : "";
142
+ const until = Math.max(0, (budget ?? 0) - used);
143
+ const threshold = full ? ` · auto-compacts at ${fmt(budget ?? 0)}` : "";
144
144
  return `context ${pct}% used (${size})${threshold} · ${fmt(until)} until auto-compaction`;
145
145
  }
146
146
  /**
@@ -3,7 +3,6 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import path from "node:path";
4
4
  export const FLOW_TIMEOUT_MS = 5 * 60_000;
5
5
  export class ServerAuth {
6
- authUrl;
7
6
  verifier;
8
7
  flow = { phase: "idle" };
9
8
  lastError;
@@ -115,7 +114,6 @@ export class ServerAuth {
115
114
  await this.persist(this.server, this.store);
116
115
  }
117
116
  redirectToAuthorization(url) {
118
- this.authUrl = url;
119
117
  this.flow = { phase: "authorizing", url: url.toString(), startedAt: Date.now() };
120
118
  }
121
119
  async saveCodeVerifier(verifier) {
@@ -155,7 +153,6 @@ export class ServerAuth {
155
153
  async clear() {
156
154
  this.store = {};
157
155
  this.verifier = undefined;
158
- this.authUrl = undefined;
159
156
  this.flow = { phase: "idle" };
160
157
  this.lastError = undefined;
161
158
  await this.persist(this.server, this.store);
@@ -217,7 +217,7 @@ export class McpRegistry {
217
217
  else
218
218
  this.servers.set(cfg.name, { config: cfg, status: "disconnected", tools: [] });
219
219
  }
220
- async startOAuth(name, opts = {}) {
220
+ async startOAuth(name, _opts = {}) {
221
221
  const st = this.servers.get(name);
222
222
  if (!st)
223
223
  throw new Error(`no such MCP server: ${name}`);
@@ -51,7 +51,7 @@ export function parseSkillMd(text) {
51
51
  const m = text.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
52
52
  if (!m)
53
53
  return { meta: {}, body: text.trim() };
54
- const lines = m[1].split(/\r?\n/);
54
+ const lines = (m[1] ?? "").split(/\r?\n/);
55
55
  const meta = {};
56
56
  for (let i = 0; i < lines.length; i++) {
57
57
  const kv = lines[i].match(/^([A-Za-z0-9_-]+)\s*:\s*(.*)$/);
@@ -82,7 +82,7 @@ export function parseSkillMd(text) {
82
82
  continue;
83
83
  meta[key] = unquote(raw);
84
84
  }
85
- return { meta, body: m[2].trim() };
85
+ return { meta, body: (m[2] ?? "").trim() };
86
86
  }
87
87
  function unquote(v) {
88
88
  const s = v.trim();
@@ -649,10 +649,6 @@ ${body}` : body;
649
649
  ` : ""}${body}
650
650
  … [truncated at ${end} of ${s.length} chars — call again with offset=${end}]`;
651
651
  }
652
- function clipText(s, max) {
653
- const n = Math.max(1000, Math.min(max, 80_000));
654
- return s.length <= n ? s : `${s.slice(0, n)}\n… [truncated, ${s.length} chars total]`;
655
- }
656
652
  const BACKTRACKING_PATTERNS = [
657
653
  { re: /\([^()]*[+*}][^()]*\)\s*[+*{]/, why: "a quantifier nested inside another quantifier" },
658
654
  { re: /\(([^()|]*)\|\1\)\s*[+*{]/, why: "an alternation with identical branches inside a quantifier" },
@@ -741,25 +737,26 @@ function parsePatch(patch) {
741
737
  i++;
742
738
  while (i < lines.length && lines[i].startsWith("+"))
743
739
  body.push(lines[i++].slice(1));
740
+ const addPath = (m[1] ?? "").trim();
744
741
  if (body.length === 0)
745
- return `invalid patch: Add File hunk for '${m[1].trim()}' has no + lines`;
746
- ops.push({ kind: "add", path: m[1].trim(), contents: body.join("\n") + "\n" });
742
+ return `invalid patch: Add File hunk for '${addPath}' has no + lines`;
743
+ ops.push({ kind: "add", path: addPath, contents: body.join("\n") + "\n" });
747
744
  continue;
748
745
  }
749
746
  m = t.match(/^\*\*\* Delete File: (.+)$/);
750
747
  if (m) {
751
- ops.push({ kind: "delete", path: m[1].trim() });
748
+ ops.push({ kind: "delete", path: (m[1] ?? "").trim() });
752
749
  i++;
753
750
  continue;
754
751
  }
755
752
  m = t.match(/^\*\*\* Update File: (.+)$/);
756
753
  if (m) {
757
- const filePath = m[1].trim();
754
+ const filePath = (m[1] ?? "").trim();
758
755
  let movePath = null;
759
756
  i++;
760
757
  const mv = lines[i]?.trim().match(/^\*\*\* Move to: (.+)$/);
761
758
  if (mv) {
762
- movePath = mv[1].trim();
759
+ movePath = (mv[1] ?? "").trim();
763
760
  i++;
764
761
  }
765
762
  const chunks = [];
@@ -1010,7 +1007,7 @@ export function parseAnchor(anchor) {
1010
1007
  const m = /^\s*(\d+):([0-9a-z]{4,8}| {4})\s*$/.exec(anchor);
1011
1008
  if (!m)
1012
1009
  return null;
1013
- return { line: Number(m[1]), hash: m[2] };
1010
+ return { line: Number(m[1]), hash: m[2] ?? "" };
1014
1011
  }
1015
1012
  export function resolveAnchor(lines, anchor) {
1016
1013
  const hits = [];
@@ -1921,6 +1918,8 @@ export const TOOLS = [
1921
1918
  if (!content.trim())
1922
1919
  return { ok: false, result: "content required" };
1923
1920
  const globalRoot = roots.find((r) => r.source === "global") ?? roots[0];
1921
+ if (!globalRoot)
1922
+ return { ok: false, result: "no writable skill root" };
1924
1923
  const filePath = await saveSkill(globalRoot.dir, name, description, content.slice(0, 64_000));
1925
1924
  let note = "";
1926
1925
  for (const r of roots) {
@@ -1,4 +1,4 @@
1
- import { createWriteStream } from "node:fs";
1
+ import { createWriteStream, WriteStream } from "node:fs";
2
2
  import { mkdirSync } from "node:fs";
3
3
  import path from "node:path";
4
4
  const IDLE_CLOSE_MS = 15_000;
package/dist/master.js CHANGED
@@ -899,7 +899,8 @@ export class Master {
899
899
  let n = 2;
900
900
  while (this.agents.has(id) || this.config.agents.some((a) => a.id === id))
901
901
  id = `${base.slice(0, 56)}-${n++}`;
902
- const directive = persona ? `${SUB_PERSONAS[persona].label}\n${SUB_PERSONAS[persona].directive}\n\n` : "";
902
+ const personaDef = persona ? SUB_PERSONAS[persona] : undefined;
903
+ const directive = personaDef ? `${personaDef.label}\n${personaDef.directive}\n\n` : "";
903
904
  const pcfg = this.config.agents.find((a) => a.id === parentId);
904
905
  let forkTip;
905
906
  let forkBranch;
@@ -1139,12 +1140,6 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
1139
1140
  }
1140
1141
  }
1141
1142
  }
1142
- titleFor(agentId, sessionId) {
1143
- const a = this.config.agents.find((x) => x.id === agentId);
1144
- if (!a || a.session !== sessionId)
1145
- return undefined;
1146
- return this.readSessionTitle(sessionId) ?? undefined;
1147
- }
1148
1143
  /** The session's own name, from its manifest. One place, so it cannot go stale in another. */
1149
1144
  readSessionTitle(sessionId) {
1150
1145
  if (!sessionId)
@@ -1679,7 +1674,7 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
1679
1674
  // a session that has been read into memory: this is the count that makes "messagesInMemory" interpretable
1680
1675
  loadedSessions: [...this.agents.values()].filter((a) => a.conversation.length > 0).length,
1681
1676
  cpuMsTotal: Math.round((cu.user + cu.system) / 1000),
1682
- loadavg1: +(os.loadavg()[0]).toFixed(2),
1677
+ loadavg1: +(os.loadavg()[0] ?? 0).toFixed(2),
1683
1678
  agents: [...this.agents.values()].map((a) => ({
1684
1679
  id: a.opts_id(),
1685
1680
  turns: a.stats.turns,
@@ -1,4 +1,3 @@
1
- import { closeSync, openSync, readSync } from "node:fs";
2
1
  export const sessionTitles = {
3
2
  order: 30,
4
3
  id: "agents-session-title",
@@ -60,62 +59,3 @@ export const sessionTitles = {
60
59
  return changed;
61
60
  },
62
61
  };
63
- let scanBuffer;
64
- function firstUserPromptText(file) {
65
- let fd;
66
- try {
67
- fd = openSync(file, "r");
68
- const CHUNK = 16 * 1024;
69
- const CAP = 256 * 1024;
70
- scanBuffer ??= Buffer.alloc(CHUNK);
71
- const buf = scanBuffer;
72
- let offset = 0;
73
- let carry = "";
74
- while (offset < CAP) {
75
- const n = readSync(fd, buf, 0, CHUNK, offset);
76
- if (n <= 0)
77
- break;
78
- offset += n;
79
- const lines = (carry + buf.subarray(0, n).toString("utf8")).split("\n");
80
- carry = lines.pop() ?? "";
81
- for (const l of lines) {
82
- if (!l)
83
- continue;
84
- let e;
85
- try {
86
- e = JSON.parse(l);
87
- }
88
- catch {
89
- continue;
90
- }
91
- if (e.type !== "prompt")
92
- continue;
93
- if (e.data?.source !== "user")
94
- return null;
95
- return titleOf(typeof e.data.text === "string" ? e.data.text : null);
96
- }
97
- }
98
- return null;
99
- }
100
- catch {
101
- return null;
102
- }
103
- finally {
104
- if (fd !== undefined) {
105
- try {
106
- closeSync(fd);
107
- }
108
- catch {
109
- }
110
- }
111
- }
112
- }
113
- function titleOf(text) {
114
- const line = (text ?? "")
115
- .split("\n")
116
- .map((l) => l.trim())
117
- .find((l) => l.length > 0);
118
- if (!line)
119
- return null;
120
- return line.length > 80 ? `${line.slice(0, 79)}…` : line;
121
- }
@@ -13,14 +13,16 @@ function parseField(part, min, max) {
13
13
  return v;
14
14
  };
15
15
  for (const piece of part.split(",")) {
16
- const [range, stepStr] = piece.split("/");
16
+ const [range = "", stepStr] = piece.split("/");
17
17
  const step = Math.max(1, Number(stepStr ?? 1) || 1);
18
18
  if (range === "*" || range === "*/" + step) {
19
19
  for (let i = min; i <= max; i += step)
20
20
  out.add(i);
21
21
  }
22
22
  else if (range.includes("-")) {
23
- const [a, b] = range.split("-").map(Number);
23
+ const [aRaw, bRaw] = range.split("-").map(Number);
24
+ const a = aRaw ?? min;
25
+ const b = bRaw ?? max;
24
26
  clampOrThrow(a);
25
27
  clampOrThrow(b);
26
28
  if (a > b)
@@ -46,7 +48,7 @@ export function parseSchedule(spec) {
46
48
  let effective = spec.trim();
47
49
  if (every) {
48
50
  const n = Number(every[1]);
49
- const unit = every[2].toLowerCase();
51
+ const unit = (every[2] ?? "").toLowerCase();
50
52
  if (unit === "s") {
51
53
  const m = Math.max(1, Math.round(n / 60));
52
54
  effective = `*/${m} * * * *`;
@@ -63,14 +65,23 @@ export function parseSchedule(spec) {
63
65
  throw new Error(`bad schedule: ${spec}`);
64
66
  return {
65
67
  raw: spec,
66
- fields: parts.map((p, i) => parseField(p, BOUNDS[i][0], BOUNDS[i][1])),
68
+ fields: parts.map((p, i) => {
69
+ const bounds = BOUNDS[i];
70
+ if (!bounds)
71
+ throw new Error(`bad schedule: ${spec}`);
72
+ return parseField(p, bounds[0], bounds[1]);
73
+ }),
67
74
  };
68
75
  }
69
76
  export function matches(schedule, d) {
70
77
  const values = [d.getMinutes(), d.getHours(), d.getDate(), d.getMonth() + 1, d.getDay()];
71
78
  for (let i = 0; i < 5; i++) {
72
- if (!schedule.fields[i].has(values[i])) {
73
- if (i === 4 && values[i] === 0 && schedule.fields[i].has(7))
79
+ const field = schedule.fields[i];
80
+ const value = values[i];
81
+ if (!field || value === undefined)
82
+ return false;
83
+ if (!field.has(value)) {
84
+ if (i === 4 && value === 0 && field.has(7))
74
85
  continue;
75
86
  return false;
76
87
  }
@@ -6,6 +6,7 @@ import { createHash } from "node:crypto";
6
6
  import { currentSkills } from "../agent/tools.js";
7
7
  import { readSkillFile } from "../agent/skills.js";
8
8
  import { detectImageTools, downscaleImage, widthName, MAX_EDGE } from "./image-resize.js";
9
+ import {} from "node:child_process";
9
10
  import { promises as fs } from "node:fs";
10
11
  import { fileURLToPath } from "node:url";
11
12
  import { parseSchedule } from "../scheduler/cron.js";
@@ -35,6 +36,7 @@ import path from "node:path";
35
36
  import { bus } from "../bus.js";
36
37
  import { branchCounts, readEvents, readEventsTail, readEventsWindow, filterByBranch } from "../log/events.js";
37
38
  import { mcp } from "../agent/mcp-registry.js";
39
+ import {} from "../agent/mcp.js";
38
40
  const IMAGE_EXT = new Set(["png", "jpg", "jpeg", "gif", "webp", "svg", "bmp", "ico", "avif"]);
39
41
  const VIDEO_EXT = new Set(["mp4", "webm", "mov", "mkv", "avi", "m4v"]);
40
42
  const AUDIO_EXT = new Set(["mp3", "wav", "ogg", "m4a", "flac", "aac", "opus"]);
@@ -710,7 +712,8 @@ export function buildApp(master) {
710
712
  shortContext: patch.shortContext,
711
713
  tasks: patch.tasks,
712
714
  mcpServers: patch.mcpServers,
713
- ...(patch.password !== undefined ? { password: patch.password } : {}),
715
+ pluginsDir: master.config.pluginsDir,
716
+ password: patch.password,
714
717
  });
715
718
  if (patch.mcpServers) {
716
719
  mcp.apply(patch.mcpServers);
@@ -1557,7 +1560,12 @@ export function dualStackHost(host) {
1557
1560
  export function serveApp(app, port, host) {
1558
1561
  const wss = new WebSocketServer({ noServer: true });
1559
1562
  const bindHost = dualStackHost(host);
1560
- const server = serve({ fetch: app.fetch, port, hostname: bindHost, websocket: { server: wss } }, (info) => {
1563
+ const server = serve({
1564
+ fetch: app.fetch,
1565
+ port,
1566
+ hostname: bindHost,
1567
+ websocket: { server: wss },
1568
+ }, (info) => {
1561
1569
  const shown = host && host !== "0.0.0.0" && host !== "::"
1562
1570
  ? `http://${host}:${info.port}`
1563
1571
  : `http://localhost:${info.port} (all interfaces, IPv4 + IPv6)`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.37.209",
3
+ "version": "0.37.211",
4
4
  "description": "A lightweight, always-on multi-agent harness for AI coding agents",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-or-later",
@@ -30,12 +30,13 @@
30
30
  "README.md"
31
31
  ],
32
32
  "scripts": {
33
- "build": "tsc -p tsconfig.json && tsc -p tsconfig.frontend.json && vite build",
33
+ "build": "tsc && pnpm typecheck:web && vite build",
34
34
  "build-server": "tsc -p tsconfig.json",
35
35
  "build-web": "vite build",
36
- "typecheck": "tsc -p tsconfig.json --noEmit",
37
- "typecheck-web": "tsc -p tsconfig.frontend.json",
38
- "typecheck:scripts": "tsc -p tsconfig.scripts.json",
36
+ "typecheck:server": "tsc -p tsconfig.json --noEmit",
37
+ "typecheck:web": "cd frontend && tsc",
38
+ "typecheck:scripts": "cd scripts && tsc",
39
+ "typecheck:test": "cd test && tsc",
39
40
  "lint": "oxlint src frontend test scripts",
40
41
  "lint:comments": "node scripts/find-stacked-comments.ts",
41
42
  "lint:comments:strict": "node scripts/find-stacked-comments.ts --strict",
@@ -47,12 +48,14 @@
47
48
  "test:clean": "node scripts/clean-test-tmp.ts --apply",
48
49
  "test:tmp": "node scripts/clean-test-tmp.ts",
49
50
  "release:wait": "node scripts/wait-npm-version.ts",
50
- "pre-release": "pnpm typecheck && pnpm typecheck-web && pnpm typecheck:scripts && pnpm lint && pnpm build && pnpm test && pnpm test:portable && node scripts/smoke-web.ts"
51
+ "pre-release": "pnpm typecheck:server && pnpm typecheck:web && pnpm typecheck:scripts && pnpm typecheck:test && pnpm lint && pnpm build && pnpm test && pnpm test:portable && node scripts/smoke-web.ts"
51
52
  },
52
53
  "dependencies": {
53
54
  "@hono/node-server": "^2.1.4",
54
55
  "@modelcontextprotocol/client": "^2.3.1",
55
56
  "@mozilla/readability": "^0.6.0",
57
+ "@solidjs/vite-plugin": "^3.0.1",
58
+ "@solidjs/web": "^2.0.3",
56
59
  "happy-dom": "^20.14.5",
57
60
  "hono": "^4.13.13",
58
61
  "openai": "^7.30.1",
@@ -66,9 +69,8 @@
66
69
  "@xterm/xterm": "^6.0.0",
67
70
  "oxlint": "^1.87.0",
68
71
  "shiki": "^4.5.0",
69
- "solid-js": "^1.9.17",
72
+ "solid-js": "^2.0.3",
70
73
  "typescript": "^7.0.2",
71
- "vite": "^8.3.4",
72
- "vite-plugin-solid": "^2.11.14"
74
+ "vite": "^8.3.4"
73
75
  }
74
76
  }