teapot-coding-agent 0.29.28 → 0.29.30

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.
@@ -53,6 +53,8 @@ async function listModels(baseUrl, apiKey) {
53
53
  import path from "node:path";
54
54
  import { bus } from "../bus.js";
55
55
  import { readEvents, readEventsTail, filterByBranch } from "../log/events.js";
56
+ import { mcp } from "../agent/mcp-registry.js";
57
+ import { connectMcp } from "../agent/mcp.js";
56
58
  /** media categories the file tree can preview inline */
57
59
  const IMAGE_EXT = new Set(["png", "jpg", "jpeg", "gif", "webp", "svg", "bmp", "ico", "avif"]);
58
60
  const VIDEO_EXT = new Set(["mp4", "webm", "mov", "mkv", "avi", "m4v"]);
@@ -355,11 +357,9 @@ export function buildApp(master) {
355
357
  : spawn(shell, [], { cwd: agent.workspace, env: { ...env, TERM: "dumb" } });
356
358
  console.log(`[teapot] ⌨ terminal open: ${agentId} @ ${agent.workspace} (${hasScript ? "pty" : "pipe"})`);
357
359
  child.stdout?.on("data", (b) => {
358
- termSizes.markBusy(child);
359
360
  send({ kind: "data", data: b.toString("utf8") });
360
361
  });
361
362
  child.stderr?.on("data", (b) => {
362
- termSizes.markBusy(child);
363
363
  send({ kind: "data", data: b.toString("utf8") });
364
364
  });
365
365
  child.on("close", (code) => {
@@ -826,14 +826,90 @@ export function buildApp(master) {
826
826
  onError: patch.onError,
827
827
  retryDelayMs: patch.retryDelayMs,
828
828
  maxSpawnDepth: patch.maxSpawnDepth,
829
+ shortContext: patch.shortContext,
829
830
  tasks: patch.tasks,
831
+ mcpServers: patch.mcpServers,
830
832
  });
833
+ // #67: apply the new server list to the live registry and connect in the
834
+ // background — an added server's tools must appear on the next turn without a
835
+ // restart, and a removed one's connection must be closed now.
836
+ if (patch.mcpServers) {
837
+ mcp.apply(patch.mcpServers);
838
+ void mcp.connectAll();
839
+ }
831
840
  return c.json({ ok: true });
832
841
  }
833
842
  catch (err) {
834
843
  return c.json({ error: err.message }, 400);
835
844
  }
836
845
  });
846
+ // ---- MCP servers (#67) ----
847
+ //
848
+ // `test` is the endpoint the settings panel uses to answer "does this work?" before
849
+ // saving: it connects, lists tools, and reports the count or the exact failure. Doing
850
+ // that through `PUT /api/config` would mean saving a broken server first, and the
851
+ // failure would then surface on an agent's turn instead of in the panel that caused it.
852
+ app.get("/api/mcp", (c) => c.json({
853
+ servers: master.config.mcpServers ?? [],
854
+ states: mcp.states().map((s) => ({
855
+ name: s.config.name,
856
+ status: s.status,
857
+ tools: s.tools.length,
858
+ ...(s.lastError ? { lastError: s.lastError } : {}),
859
+ ...(s.lastChecked ? { lastChecked: s.lastChecked } : {}),
860
+ })),
861
+ }));
862
+ // Agent Plugins (#162): what was loaded, and where from. Read-only on purpose —
863
+ // installing a plugin is a filesystem act, and a web endpoint that unpacks an
864
+ // archive is a much larger surface than this feature is worth.
865
+ app.get("/api/plugins", (c) => c.json({
866
+ pluginsDir: master.config.pluginsDir === false
867
+ ? null
868
+ : (master.config.pluginsDir ?? null),
869
+ plugins: master.plugins.map((p) => ({
870
+ name: p.name,
871
+ ...(p.version ? { version: p.version } : {}),
872
+ ...(p.description ? { description: p.description } : {}),
873
+ root: p.root,
874
+ skills: p.skills,
875
+ mcpServers: p.mcpServers.map((s) => s.name),
876
+ warnings: p.warnings,
877
+ })),
878
+ }));
879
+ app.post("/api/mcp/test", async (c) => {
880
+ const body = await c.req.json().catch(() => null);
881
+ if (!body?.name)
882
+ return c.json({ error: "a server needs a name" }, 400);
883
+ try {
884
+ const conn = await connectMcp({ ...body, enabled: true });
885
+ try {
886
+ const tools = await conn.tools();
887
+ return c.json({
888
+ ok: true,
889
+ tools: tools.map((t) => ({ name: t.name, description: t.description })),
890
+ });
891
+ }
892
+ finally {
893
+ await conn.close();
894
+ }
895
+ }
896
+ catch (err) {
897
+ const e = err;
898
+ return c.json({ ok: false, error: e.message, authRequired: Boolean(e.authRequired) }, 200);
899
+ }
900
+ });
901
+ app.post("/api/mcp/connect", async (c) => {
902
+ const body = await c.req.json().catch(() => null);
903
+ if (!body?.name)
904
+ return c.json({ error: "missing name" }, 400);
905
+ try {
906
+ const st = await mcp.connect(body.name);
907
+ return c.json({ ok: true, status: st.status, tools: st.tools.length });
908
+ }
909
+ catch (err) {
910
+ return c.json({ ok: false, error: err.message }, 200);
911
+ }
912
+ });
837
913
  app.get("/api/agents/:id", (c) => {
838
914
  const a = master.agents.get(c.req.param("id"));
839
915
  return a ? c.json(a.snapshot()) : notFound(c, "agent", c.req.param("id"));
@@ -69,8 +69,6 @@ function ptySlaveOf(pid) {
69
69
  }
70
70
  /** debounce window: long enough to collapse a drag, short enough to feel instant */
71
71
  export const TERM_RESIZE_DEBOUNCE_MS = 250;
72
- /** how long after output a terminal counts as "a program is running" */
73
- export const TERM_BUSY_MS = 400;
74
72
  export class TermSizeTracker {
75
73
  states = new Map();
76
74
  /**
@@ -78,7 +76,7 @@ export class TermSizeTracker {
78
76
  * debounce.
79
77
  */
80
78
  request(child, rows, cols, write) {
81
- const st = this.states.get(child) ?? { rows: 0, cols: 0, timer: null, busyUntil: 0 };
79
+ const st = this.states.get(child) ?? { rows: 0, cols: 0, timer: null };
82
80
  this.states.set(child, st);
83
81
  if (st.timer) {
84
82
  clearTimeout(st.timer);
@@ -87,7 +85,6 @@ export class TermSizeTracker {
87
85
  // already the applied size → nothing a shell could act on
88
86
  if (st.rows === rows && st.cols === cols)
89
87
  return;
90
- const wait = Math.max(0, st.busyUntil - Date.now());
91
88
  const apply = () => {
92
89
  st.timer = null;
93
90
  st.rows = rows;
@@ -99,26 +96,7 @@ export class TermSizeTracker {
99
96
  /* child exited mid-debounce */
100
97
  }
101
98
  };
102
- st.timer = setTimeout(() => {
103
- // output may have CONTINUED past the deadline this timer was computed
104
- // from (markBusy only extends busyUntil — it cannot reach an already
105
- // pending timer). Writing now would type stty into a running program,
106
- // so defer to whatever busy window remains.
107
- const remain = st.busyUntil - Date.now();
108
- if (remain > 0) {
109
- st.timer = setTimeout(apply, remain);
110
- return;
111
- }
112
- apply();
113
- }, wait > 0 ? wait : TERM_RESIZE_DEBOUNCE_MS);
114
- }
115
- /** a child produced output — defer resizes so we never type into it */
116
- markBusy(child, ms = TERM_BUSY_MS) {
117
- // create the entry if absent: output usually arrives long before the first
118
- // resize, and dropping the signal then let the resize land in the program
119
- const st = this.states.get(child) ?? { rows: 0, cols: 0, timer: null, busyUntil: 0 };
120
- this.states.set(child, st);
121
- st.busyUntil = Date.now() + ms;
99
+ st.timer = setTimeout(apply, TERM_RESIZE_DEBOUNCE_MS);
122
100
  }
123
101
  /** forget a child; cancels its pending resize so we can't write to a corpse */
124
102
  forget(child) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.29.28",
3
+ "version": "0.29.30",
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",