teapot-coding-agent 0.29.30 → 0.29.31

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/master.js CHANGED
@@ -1915,49 +1915,80 @@ When this task is done (or truly blocked), call finish() with a summary for @${p
1915
1915
  * (the files survived, but nothing in the UI could reach them again).
1916
1916
  */
1917
1917
  async archiveAgent(id) {
1918
- const ac = this.config.agents.find((a) => a.id === id);
1919
- if (!ac)
1918
+ const root = this.config.agents.find((a) => a.id === id);
1919
+ if (!root)
1920
1920
  throw new Error(`no such agent: ${id}`);
1921
- const live = this.agents.get(id);
1922
- if (live) {
1923
- this.agents.delete(id);
1924
- await live.dispose();
1921
+ // The whole SUBTREE goes with it. A sub-agent whose parent is archived can never
1922
+ // run again — its parent is what spawns and messages it — so leaving it un-archived
1923
+ // put orphans in the list that look usable and are not. The descendants are found
1924
+ // from the config (not the live map), so sub-agents that are already stopped or
1925
+ // suspended are included.
1926
+ const ids = [id, ...this.subtreeOf(id).map((s) => s.id)];
1927
+ const now = Date.now();
1928
+ for (const one of ids) {
1929
+ const live = this.agents.get(one);
1930
+ if (live) {
1931
+ this.agents.delete(one);
1932
+ await live.dispose();
1933
+ }
1934
+ const ac = this.config.agents.find((a) => a.id === one);
1935
+ if (!ac)
1936
+ continue;
1937
+ ac.archived = true;
1938
+ ac.archivedAt = now;
1925
1939
  }
1926
- ac.archived = true;
1927
- ac.archivedAt = Date.now();
1928
1940
  this.saveConfig();
1929
- return { archived: true };
1941
+ return { archived: true, ids };
1930
1942
  }
1931
- /** Bring an archived agent back. Its session pointer was never touched. */
1943
+ /**
1944
+ * Bring an archived agent back. Its session pointer was never touched.
1945
+ *
1946
+ * Restores the SUBTREE too, because archiving took it: a parent restored without its
1947
+ * children would come back unable to reach the work it delegated, and the children
1948
+ * would sit invisibly in the archive with no way to know why.
1949
+ */
1932
1950
  async restoreAgent(id) {
1933
1951
  const ac = this.config.agents.find((a) => a.id === id);
1934
1952
  if (!ac)
1935
1953
  throw new Error(`no such agent: ${id}`);
1936
- delete ac.archived;
1937
- delete ac.archivedAt;
1954
+ const ids = [id, ...this.subtreeOf(id).map((s) => s.id)];
1955
+ for (const one of ids) {
1956
+ const e = this.config.agents.find((a) => a.id === one);
1957
+ if (!e)
1958
+ continue;
1959
+ delete e.archived;
1960
+ delete e.archivedAt;
1961
+ }
1938
1962
  this.saveConfig();
1939
1963
  // start it again unless it was never configured to run (it is in the list, so it
1940
1964
  // was) — a restore is the operator asking for it back, so it comes back LIVE
1941
1965
  try {
1942
1966
  await this.addAgent(ac);
1943
- return { restored: true, live: true };
1967
+ return { restored: true, live: true, ids };
1944
1968
  }
1945
1969
  catch (err) {
1946
1970
  // the entry is restored either way; starting it can fail on a provider/auth
1947
1971
  // problem, and reporting that is more useful than undoing the restore
1948
1972
  console.error(`[teapot] restored "${id}" but could not start it: ${err.message}`);
1949
- return { restored: true, live: false };
1973
+ return { restored: true, live: false, ids };
1950
1974
  }
1951
1975
  }
1952
1976
  /** Archived entries, newest first — what the settings panel lists. */
1953
1977
  archivedAgents() {
1954
- return this.config.agents
1955
- .filter((a) => a.archived)
1978
+ const archived = this.config.agents.filter((a) => a.archived);
1979
+ const ids = new Set(archived.map((a) => a.id));
1980
+ return archived
1956
1981
  .map((a) => ({
1957
1982
  id: a.id,
1958
1983
  workspace: a.workspace,
1959
1984
  ...(a.archivedAt !== undefined ? { archivedAt: a.archivedAt } : {}),
1960
1985
  sessions: this.sessionsOf(a.id).length,
1986
+ // A sub-agent is listed under its parent rather than as an equal entry: the
1987
+ // operator archived ONE thing, and a flat list of every descendant makes it
1988
+ // look like they did several. Only an ARCHIVED parent counts — otherwise a
1989
+ // live parent would hide a genuinely standalone entry.
1990
+ ...(a.parent && ids.has(a.parent) ? { parent: a.parent } : {}),
1991
+ subs: this.subtreeOf(a.id).filter((s) => ids.has(s.id)).length,
1961
1992
  }))
1962
1993
  .sort((a, b) => (b.archivedAt ?? 0) - (a.archivedAt ?? 0));
1963
1994
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teapot-coding-agent",
3
- "version": "0.29.30",
3
+ "version": "0.29.31",
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",