thinkpool-pair 0.7.85 → 0.7.86

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/bridge.mjs CHANGED
@@ -976,11 +976,12 @@ function openStructured({ id, model, resume, log, commands, mode }) {
976
976
  // recursively spawn/post onward — the fork-bomb breaker (mirrors Tier C).
977
977
  tool(
978
978
  'spawn_terminal',
979
- 'Open a NEW agent terminal (a fresh Claude lane) in this ThinkPool Code room — YOUR lane to use, not a sibling that is already working. Use it to fan work out: give it an initial `task` and it runs in parallel in its own lane; collect its result later with read_terminal, and close it with close_terminal when done. ALWAYS prefer spawning a fresh lane over post_to_terminal into one that is already busy. Bounded by the room terminal cap and a per-turn limit.',
979
+ 'Open a NEW agent terminal (a fresh Claude lane) in this ThinkPool Code room — YOUR lane to use, not a sibling that is already working. Use it to fan work out: give it an initial `task` and it runs in parallel in its own lane; collect its result later with read_terminal, and close it with close_terminal when done. By default the new lane INHERITS your current permission mode — so if you are in bypass, it runs autonomously with no per-action clicking; pass `mode` to override. ALWAYS prefer spawning a fresh lane over post_to_terminal into one that is already busy. Bounded by the room terminal cap and a per-turn limit.',
980
980
  {
981
981
  name: z.string().max(80).optional().describe('a short label for the new lane so the room (and you) can find it, e.g. "Research: topologies"'),
982
982
  task: z.string().optional().describe('an initial task to hand the new lane immediately; omit to open it idle'),
983
983
  model: z.string().optional().describe('optional model for the lane, e.g. opus / sonnet / haiku'),
984
+ mode: z.enum(['default', 'acceptEdits', 'bypassPermissions', 'plan']).optional().describe('permission mode for the new lane; defaults to inheriting YOUR current mode. Raising a lane to bypassPermissions from a non-bypass lane asks the room to confirm once.'),
984
985
  },
985
986
  async (args) => {
986
987
  const okText = (t) => ({ content: [{ type: 'text', text: t }] })
@@ -992,7 +993,11 @@ function openStructured({ id, model, resume, log, commands, mode }) {
992
993
  const fromRef = String(id).slice(0, 8)
993
994
  // Name BEFORE opening so openStructured's own announce already carries the label.
994
995
  if (args?.name) { termNames[newId] = String(args.name).slice(0, 80); saveNames(room, termNames) }
995
- openStructured({ id: newId, model: args?.model })
996
+ // Inherit the spawner's permission mode by default (so a bypass orchestrator's
997
+ // lanes run autonomously); an explicit `mode` overrides. The PreToolUse gate
998
+ // already confirmed any bypass-escalation from a non-bypass lane before we got here.
999
+ const childMode = args?.mode || entry.mode
1000
+ openStructured({ id: newId, model: args?.model, mode: childMode })
996
1001
  const ne = sessions.get(newId)
997
1002
  if (!ne) { if (args?.name) { delete termNames[newId]; saveNames(room, termNames) } return okText('Could not open a new lane — the terminal cap may have just been reached. Close one and retry.') }
998
1003
  ne.spawnedBy = id // ownership: only the spawner may close_terminal it
@@ -253,15 +253,31 @@ export function startClaudeSession({ cwd, model, resume, env, mode: initialMode
253
253
  if (toolName === 'mcp__thinkpool__read_terminal') {
254
254
  return { continue: true, hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow', permissionDecisionReason: 'Auto-approved (read-only ThinkPool cross-terminal read).' } }
255
255
  }
256
- // ThinkPool cross-terminal SPAWN / CLOSE (Tier C+) — lane management the agent
257
- // OWNS. Unlike post_to_terminal (which WRITES into someone else's working lane,
258
- // so it's human-gated every time), these only ever open a FRESH lane or close a
259
- // lane the agent itself spawned — they never touch a sibling's work. Auto-allow
260
- // (surfaced as a card for visibility); the bridge-side handler enforces the real
261
- // bounds (hop-0-only, per-turn cap, the 8-terminal cap, TP_SPAWN_OFF) and can
262
- // only close self-spawned lanes. This is the "you open them yourself" path.
263
- if (toolName === 'mcp__thinkpool__spawn_terminal' || toolName === 'mcp__thinkpool__close_terminal') {
264
- return { continue: true, hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow', permissionDecisionReason: 'Auto-approved (ThinkPool cross-terminal lane management — bounded by the room caps; closes only self-spawned lanes).' } }
256
+ // ThinkPool cross-terminal CLOSE (Tier C+) — closes only a lane the agent itself
257
+ // spawned (bridge-side spawnedBy check), never a sibling's work nor the host
258
+ // terminal. Low-risk lane management → auto-allow (surfaced as a card for visibility).
259
+ if (toolName === 'mcp__thinkpool__close_terminal') {
260
+ return { continue: true, hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow', permissionDecisionReason: 'Auto-approved (ThinkPool cross-terminal close — only self-spawned lanes).' } }
261
+ }
262
+ // ThinkPool cross-terminal SPAWN (Tier C+) — opens a FRESH lane the agent owns
263
+ // (never touches a sibling). A spawned lane INHERITS the spawner's permission mode
264
+ // (`mode` here is THIS lane's current mode) unless an explicit `mode` overrides it.
265
+ // The only thing worth a human card is an ESCALATION: raising a child to
266
+ // bypassPermissions from a non-bypass lane (full unattended access the operator
267
+ // hasn't already opted into). If the spawner is already in bypass, children inherit
268
+ // bypass with NO prompt (you opted in once); a non-bypass child gates itself per
269
+ // action anyway, so no spawn prompt there either. Bridge-side spawnDecision still
270
+ // enforces hop-0-only / per-turn cap / 8-terminal cap / TP_SPAWN_OFF regardless.
271
+ if (toolName === 'mcp__thinkpool__spawn_terminal') {
272
+ const childMode = toolInput?.mode || mode // inherit this lane's mode by default
273
+ const escalating = childMode === 'bypassPermissions' && mode !== 'bypassPermissions'
274
+ if (!escalating) {
275
+ return { continue: true, hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: 'allow', permissionDecisionReason: `Auto-approved (spawn a fresh lane in ${childMode} mode — inherited, no escalation; bounded by the room caps).` } }
276
+ }
277
+ let decision = 'deny'
278
+ try { decision = await requestPermission?.({ id: randomUUID(), toolName, input: { ...toolInput, mode: childMode }, risk: 'high' }) ?? 'deny' } catch { decision = 'deny' }
279
+ const allowed = decision === 'allow'
280
+ return { continue: true, hookSpecificOutput: { hookEventName: 'PreToolUse', permissionDecision: allowed ? 'allow' : 'deny', permissionDecisionReason: allowed ? 'Bypass spawn approved in the ThinkPool room — the new lane runs autonomously.' : 'Bypass spawn denied in the room — do not retry as bypass; re-spawn without mode:bypassPermissions to get a gated lane, or ask what to do.' } }
265
281
  }
266
282
  // ThinkPool cross-terminal POST (Tier C) WRITES into a sibling agent's lane —
267
283
  // human-gated EVERY time, never remembered. First a bridge-side precheck
@@ -396,7 +412,7 @@ export function startClaudeSession({ cwd, model, resume, env, mode: initialMode
396
412
  'RUN IT, DO NOT ASK: verify your own work before calling it done. Actually run or serve what you changed, observe that it behaves correctly, and show the evidence in the room — a screenshot of the running result, the passing test output, or the real response — rather than telling the user "this should work, go test it." If you could not verify something, say exactly what is unverified. This room follows verify-before-claiming: runtime evidence you produced, not assertion.',
397
413
  'CROSS-TERMINAL AWARENESS: this room may have other terminals open alongside yours — other agents working, or shells the people are driving. You have a READ-ONLY tool, read_terminal: call it with no arguments to list the other open terminals, or with a terminal ref/id/command to read that terminal\'s recent activity. Reach for it when your work depends on what another terminal is doing (e.g. someone says "see what the other terminal hit", or you need to coordinate with a sibling agent before acting). It only ever reads — it never changes another terminal. Identify a terminal by its NAME or its ref/id from the roster, never by an on-screen number like "Terminal 2" — those positional labels renumber when a terminal is closed, so they do not reliably point at a lane.',
398
414
  'CROSS-TERMINAL HAND-OFF: you also have post_to_terminal(terminal, text) to send a message or task to ANOTHER AGENT terminal in this room (not a plain shell). Use it sparingly and only when the people clearly want the lanes to coordinate — e.g. "tell the backend terminal the API is ready", or to hand a sibling agent a concrete task. Every post requires a person in the room to approve a card before it is delivered, and an agent that was itself reached via a cross-post cannot post onward — so do not rely on it for chit-chat or loops. Prefer read_terminal to understand a sibling before you ever post to it.',
399
- 'CROSS-TERMINAL SPAWN: when a person asks you to fan work out across multiple agents — research lanes, parallel sub-tasks, a swarm — open YOUR OWN fresh lanes with spawn_terminal(name?, task?, model?); do NOT dump the work into siblings that are already busy (a sibling is mid-task unless read_terminal shows it idle, and hijacking it derails their work). spawn_terminal opens a brand-new Claude lane and, if you pass `task`, hands it that task immediately; it appears as a new terminal in the room. Collect each lane\'s result later with read_terminal (a spawned lane cannot post back to you), and tidy up with close_terminal once you have what you need — you may only close lanes you spawned yourself. You are bounded: at most a few new lanes per turn and 8 terminals total in the room, and a lane you were spawned/cross-posted into cannot itself spawn (so no runaway). This is how you "open the terminals yourself" instead of asking a person to.',
415
+ 'CROSS-TERMINAL SPAWN: when a person asks you to fan work out across multiple agents — research lanes, parallel sub-tasks, a swarm — open YOUR OWN fresh lanes with spawn_terminal(name?, task?, model?); do NOT dump the work into siblings that are already busy (a sibling is mid-task unless read_terminal shows it idle, and hijacking it derails their work). spawn_terminal opens a brand-new Claude lane and, if you pass `task`, hands it that task immediately; it appears as a new terminal in the room. A spawned lane INHERITS your current permission mode by default — so if you are in bypass, your lanes run autonomously with no per-action clicking; pass `mode` only to override. Raising a lane to bypass from a non-bypass lane asks the room to confirm once (everything else spawns without a prompt). Collect each lane\'s result later with read_terminal (a spawned lane cannot post back to you), and tidy up with close_terminal once you have what you need — you may only close lanes you spawned yourself. You are bounded: at most a few new lanes per turn and 8 terminals total in the room, and a lane you were spawned/cross-posted into cannot itself spawn (so no runaway). This is how you "open the terminals yourself" instead of asking a person to.',
400
416
  'WRITE PLANS INTO THE CHAT: whenever you form or revise a plan — because the room is in Plan mode, or because someone asked you to plan, design, or think it through first — write the actual plan out as a normal message in the room as you develop it: the approach, the concrete steps, the files you will touch, the open questions. The room does NOT surface plan files at all, and the plan-approval card does not reliably carry the plan text, so a plan that lives only in a plan file or only inside ExitPlanMode is INVISIBLE to the people you are working with — they just see "plan ready" with no content. The chat is the canonical place your plan lives; put it there so the room can read and react to it before you proceed.',
401
417
  ].join(' '),
402
418
  // Needed for live thinking-token progress (SDKThinkingTokensMessage) to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkpool-pair",
3
- "version": "0.7.85",
3
+ "version": "0.7.86",
4
4
  "description": "Share a local coding-agent CLI (Claude Code, Codex, Gemini, Aider, …) into a ThinkPool Code room, live.",
5
5
  "type": "module",
6
6
  "bin": {