repoburg 1.3.305 → 1.3.307

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.
@@ -41237,6 +41237,12 @@ CREATE INDEX IF NOT EXISTS idx_workspaces_path ON workspaces(path);
41237
41237
  if (!turnColumns.some((c) => c.name === "stream_cursor")) {
41238
41238
  database.exec("ALTER TABLE turns ADD COLUMN stream_cursor TEXT");
41239
41239
  }
41240
+ if (!turnColumns.some((c) => c.name === "origin")) {
41241
+ database.exec("ALTER TABLE turns ADD COLUMN origin TEXT");
41242
+ }
41243
+ if (!turnColumns.some((c) => c.name === "origin_name")) {
41244
+ database.exec("ALTER TABLE turns ADD COLUMN origin_name TEXT");
41245
+ }
41240
41246
  const processColumns = database.prepare("PRAGMA table_info(cli_processes)").all();
41241
41247
  if (!processColumns.some((c) => c.name === "runtime")) {
41242
41248
  database.exec("ALTER TABLE cli_processes ADD COLUMN runtime TEXT NOT NULL DEFAULT 'claude'");
@@ -42370,8 +42376,8 @@ async function registerSessionRoutes(fastify) {
42370
42376
  for (const turn of turnRows) {
42371
42377
  const newTurnId = v4_default();
42372
42378
  db2.prepare(
42373
- `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, attachments, created_at, updated_at)
42374
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
42379
+ `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status, error, attachments, origin, origin_name, created_at, updated_at)
42380
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
42375
42381
  ).run(
42376
42382
  newTurnId,
42377
42383
  newSessionId,
@@ -42383,6 +42389,8 @@ async function registerSessionRoutes(fastify) {
42383
42389
  turn.status,
42384
42390
  turn.error,
42385
42391
  turn.attachments,
42392
+ turn.origin ?? null,
42393
+ turn.origin_name ?? null,
42386
42394
  turn.created_at,
42387
42395
  turn.updated_at
42388
42396
  );
@@ -116786,6 +116794,12 @@ function parseTranscript(text2) {
116786
116794
  link.origin = raw.origin ?? null;
116787
116795
  link.message = raw.message ?? null;
116788
116796
  link.toolUseResult = raw.toolUseResult;
116797
+ } else if (raw.type === "attachment") {
116798
+ const attachment = raw.attachment;
116799
+ if (attachment?.type === "queued_command" && attachment.origin?.kind === "peer") {
116800
+ link.origin = attachment.origin;
116801
+ link.queuedPrompt = typeof attachment.prompt === "string" ? attachment.prompt : "";
116802
+ }
116789
116803
  }
116790
116804
  entries.push(link);
116791
116805
  }
@@ -116859,6 +116873,21 @@ function classifyUserInput(entry) {
116859
116873
  const imageNote = images > 0 && !trimmed.includes("[Image") ? Array(images).fill("[Image]").join(" ") : "";
116860
116874
  return { kind: "prompt", text: [trimmed, imageNote].filter(Boolean).join("\n") };
116861
116875
  }
116876
+ function hasToolResult(content) {
116877
+ return Array.isArray(content) && content.some((b) => b?.type === "tool_result");
116878
+ }
116879
+ var PEER_ENVELOPE = /<cross-session-message\b[^>]*>([\s\S]*?)<\/cross-session-message>/;
116880
+ function peerMessageData(origin, content) {
116881
+ let body = typeof origin.body === "string" ? origin.body.trim() : "";
116882
+ if (!body) {
116883
+ const text2 = typeof content === "string" ? content : Array.isArray(content) ? content.map(
116884
+ (b) => b && typeof b === "object" && b.type === "text" ? String(b.text ?? "") : ""
116885
+ ).join("\n") : "";
116886
+ const enveloped = PEER_ENVELOPE.exec(text2);
116887
+ body = (enveloped ? enveloped[1] : text2).trim();
116888
+ }
116889
+ return { name: origin.name?.trim() || null, from: origin.from ?? null, body };
116890
+ }
116862
116891
  function syntheticText(content) {
116863
116892
  if (typeof content === "string") return content;
116864
116893
  if (!Array.isArray(content)) return "";
@@ -116879,6 +116908,8 @@ function buildTurns(chain) {
116879
116908
  const at = stamp(entry);
116880
116909
  const turn = {
116881
116910
  userPrompt: prompt,
116911
+ origin: null,
116912
+ originName: null,
116882
116913
  status: "completed",
116883
116914
  agentResponse: null,
116884
116915
  thoughts: null,
@@ -116911,7 +116942,25 @@ function buildTurns(chain) {
116911
116942
  }
116912
116943
  continue;
116913
116944
  }
116945
+ if (entry.type === "attachment") {
116946
+ if (entry.origin?.kind === "peer" && current) {
116947
+ addItem(current, entry, {
116948
+ type: "peer_message",
116949
+ externalId: `peer-${entry.uuid}`,
116950
+ data: peerMessageData(entry.origin, entry.queuedPrompt ?? ""),
116951
+ status: "completed"
116952
+ });
116953
+ }
116954
+ continue;
116955
+ }
116914
116956
  if (entry.type === "user") {
116957
+ if (entry.origin?.kind === "peer" && !hasToolResult(entry.message?.content)) {
116958
+ const data = peerMessageData(entry.origin, entry.message?.content);
116959
+ current = openTurn(data.body, entry);
116960
+ current.origin = "peer";
116961
+ current.originName = data.name;
116962
+ continue;
116963
+ }
116915
116964
  if (entry.isMeta || entry.isCompactSummary) continue;
116916
116965
  const content = entry.message?.content;
116917
116966
  if (Array.isArray(content) && content.some((b) => b?.type === "tool_result")) {
@@ -117124,8 +117173,8 @@ async function importClaudeSession(db2, claudeSessionId, workspacePath) {
117124
117173
  );
117125
117174
  const insertTurn = db2.prepare(
117126
117175
  `INSERT INTO turns (id, session_id, user_prompt, agent_response, thoughts, token_usage, external_turn_id, status,
117127
- error, created_at, updated_at)
117128
- VALUES (?, ?, ?, ?, ?, NULL, ?, ?, NULL, ?, ?)`
117176
+ error, origin, origin_name, created_at, updated_at)
117177
+ VALUES (?, ?, ?, ?, ?, NULL, ?, ?, NULL, ?, ?, ?, ?)`
117129
117178
  );
117130
117179
  const insertItem2 = db2.prepare(
117131
117180
  `INSERT INTO items (id, turn_id, external_item_id, type, data, status, created_at, updated_at)
@@ -117155,6 +117204,8 @@ async function importClaudeSession(db2, claudeSessionId, workspacePath) {
117155
117204
  turn.thoughts,
117156
117205
  turn.externalTurnId,
117157
117206
  turn.status,
117207
+ turn.origin ?? null,
117208
+ turn.originName ?? null,
117158
117209
  turn.createdAt,
117159
117210
  turn.updatedAt
117160
117211
  );
@@ -118141,6 +118192,9 @@ function setStartupGate(started) {
118141
118192
  if (startupGate === gate) startupPending = false;
118142
118193
  });
118143
118194
  }
118195
+ function noteAdoptedTurn(turnId) {
118196
+ if (startupPending) lastResult.turnIds.add(turnId);
118197
+ }
118144
118198
  function lastAdoption() {
118145
118199
  return lastResult;
118146
118200
  }
@@ -121184,7 +121238,11 @@ function rescueWaitMs() {
121184
121238
  }
121185
121239
  var RESCUE_ENV = ["CLAUDE_CODE_RESUME_INTERRUPTED_TURN", "CLAUDE_CODE_RESUME_REASON"];
121186
121240
  function spawnEnv(sessionId, resume) {
121187
- const env = { ...process.env, AGENT_PANE_SESSION_ID: sessionId };
121241
+ const env = {
121242
+ ...process.env,
121243
+ AGENT_PANE_SESSION_ID: sessionId,
121244
+ CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: "1"
121245
+ };
121188
121246
  for (const k of RESCUE_ENV) delete env[k];
121189
121247
  if (resume) {
121190
121248
  env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN = "1";
@@ -121367,6 +121425,9 @@ async function ensureSessionStarted(session, mapKey, resumeSessionId, resume, ad
121367
121425
  permissionMode: "bypassPermissions",
121368
121426
  allowDangerouslySkipPermissions: true,
121369
121427
  includePartialMessages: true,
121428
+ // Echo user messages: a message from another Claude session (SendMessage)
121429
+ // reaches the pane only this way, with its sender in `origin` (MUH-102).
121430
+ extraArgs: { "replay-user-messages": null },
121370
121431
  // Inline visuals: the model's show_widget calls render in the chat.
121371
121432
  mcpServers: { [WIDGET_SERVER_NAME]: createWidgetMcpServer() },
121372
121433
  ...CLI_OVERRIDE,
@@ -121474,12 +121535,26 @@ async function dispatchFrame(entry, sessionId, message, db2, opts = {}) {
121474
121535
  entry.rateLimit = message.rate_limit_info;
121475
121536
  return;
121476
121537
  }
121538
+ const state = sessionStateOf(message);
121539
+ if (state) {
121540
+ handleSessionState(entry, state, db2);
121541
+ return;
121542
+ }
121543
+ const peer = peerOriginOf(message);
121544
+ if (peer) {
121545
+ handlePeerMessage(entry, sessionId, message, peer, db2);
121546
+ return;
121547
+ }
121548
+ if (entry.selfStarted && isModelFrame(message)) reopenForFollowUp(entry, sessionId, db2);
121477
121549
  const currentTurnId = entry.turnId;
121478
121550
  if (!currentTurnId) {
121479
121551
  handleTaskFrame(message, sessionId, entry, db2);
121480
121552
  return;
121481
121553
  }
121482
121554
  if (entry.resume && !trackResumeFrame(entry, message, db2)) return;
121555
+ if (message.type === "result" && !message.parent_tool_use_id) {
121556
+ entry.resultTurnId = currentTurnId;
121557
+ }
121483
121558
  if (opts.awaitResult && message.type === "result") {
121484
121559
  await handleResultMessage(message, sessionId, currentTurnId, entry, db2);
121485
121560
  return;
@@ -121490,6 +121565,119 @@ function isTurnLive2(db2, turnId) {
121490
121565
  const row = db2.prepare("SELECT status FROM turns WHERE id = ?").get(turnId);
121491
121566
  return row?.status === "pending" || row?.status === "running";
121492
121567
  }
121568
+ function sessionStateOf(message) {
121569
+ if (message.type !== "system") return null;
121570
+ const m = message;
121571
+ if (m.subtype !== "session_state_changed") return null;
121572
+ return m.state === "idle" || m.state === "running" || m.state === "requires_action" ? m.state : null;
121573
+ }
121574
+ function peerOriginOf(message) {
121575
+ if (message.type !== "user") return null;
121576
+ if (message.parent_tool_use_id) return null;
121577
+ const origin = message.origin;
121578
+ return origin?.kind === "peer" ? origin : null;
121579
+ }
121580
+ var PEER_ENVELOPE2 = /<cross-session-message\b[^>]*>([\s\S]*?)<\/cross-session-message>/;
121581
+ function peerMessageBody(content, origin) {
121582
+ if (typeof origin.body === "string" && origin.body.trim()) return origin.body.trim();
121583
+ let text2 = "";
121584
+ if (typeof content === "string") text2 = content;
121585
+ else if (Array.isArray(content)) {
121586
+ text2 = content.map((b) => b && typeof b === "object" && b.type === "text" ? String(b.text ?? "") : "").join("\n");
121587
+ }
121588
+ const enveloped = PEER_ENVELOPE2.exec(text2);
121589
+ return (enveloped ? enveloped[1] : text2).trim();
121590
+ }
121591
+ function turnInProgress(entry, db2) {
121592
+ return !!entry.turnId && entry.resultTurnId !== entry.turnId && isTurnLive2(db2, entry.turnId);
121593
+ }
121594
+ function handleSessionState(entry, state, db2) {
121595
+ if (state === "running") {
121596
+ entry.selfStarted = !entry.resume && !turnInProgress(entry, db2);
121597
+ } else if (state === "idle") {
121598
+ entry.selfStarted = false;
121599
+ }
121600
+ }
121601
+ function handlePeerMessage(entry, sessionId, message, origin, db2) {
121602
+ const uuid3 = message.uuid ?? null;
121603
+ const body = peerMessageBody(message.message?.content, origin);
121604
+ const name = origin.name?.trim() || null;
121605
+ entry.selfStarted = false;
121606
+ if (uuid3) {
121607
+ const known = db2.prepare("SELECT id FROM turns WHERE session_id = ? AND runtime_input_ids = ?").get(sessionId, JSON.stringify([uuid3]));
121608
+ if (known) {
121609
+ entry.turnId = known.id;
121610
+ return;
121611
+ }
121612
+ }
121613
+ if (entry.turnId && turnInProgress(entry, db2)) {
121614
+ upsertItem(
121615
+ db2,
121616
+ { type: "peer_message", data: { name, from: origin.from ?? null, body }, externalId: `peer-${uuid3 ?? v4_default()}` },
121617
+ sessionId,
121618
+ entry.turnId,
121619
+ "completed",
121620
+ "item:completed"
121621
+ );
121622
+ return;
121623
+ }
121624
+ openPeerTurn(entry, sessionId, { body, name, uuid: uuid3 }, db2);
121625
+ }
121626
+ function openPeerTurn(entry, sessionId, peer, db2) {
121627
+ const previous = entry.turnId;
121628
+ if (previous && previous !== entry.resultTurnId && isTurnLive2(db2, previous)) {
121629
+ const prev = db2.prepare("SELECT token_usage FROM turns WHERE id = ?").get(previous);
121630
+ completeTurn2(db2, sessionId, previous, prev?.token_usage ? JSON.parse(prev.token_usage) : null);
121631
+ }
121632
+ if (previous) streamingMessageIds.delete(previous);
121633
+ const threadId = entry.threadId ?? null;
121634
+ const turnId = v4_default();
121635
+ const now = (/* @__PURE__ */ new Date()).toISOString();
121636
+ const inputIds = peer.uuid ? JSON.stringify([peer.uuid]) : null;
121637
+ db2.prepare(
121638
+ `INSERT INTO turns (id, session_id, user_prompt, status, thread_id, runtime_input_ids, origin, origin_name, created_at, updated_at)
121639
+ VALUES (?, ?, ?, 'running', ?, ?, 'peer', ?, ?, ?)`
121640
+ ).run(turnId, sessionId, peer.body, threadId, inputIds, peer.name, now, now);
121641
+ entry.turnId = turnId;
121642
+ entry.lastApiError = null;
121643
+ entry.reopenedTurnId = null;
121644
+ bindHostTurn2(entry, turnId);
121645
+ setSessionStatus2(db2, sessionId, 1, "running", now);
121646
+ const row = db2.prepare("SELECT * FROM turns WHERE id = ?").get(turnId);
121647
+ const turn = {
121648
+ ...row,
121649
+ token_usage: null,
121650
+ attachments: null,
121651
+ runtime_input_ids: peer.uuid ? [peer.uuid] : null,
121652
+ items: []
121653
+ };
121654
+ if (threadId) {
121655
+ db2.prepare("UPDATE discussion_threads SET updated_at = ? WHERE id = ?").run(now, threadId);
121656
+ broadcast("thread:followup", { sessionId, threadId, turn });
121657
+ } else {
121658
+ broadcast("turn:created", { sessionId, turn });
121659
+ }
121660
+ broadcast("turn:started", { sessionId, turnId });
121661
+ }
121662
+ function reopenForFollowUp(entry, sessionId, db2) {
121663
+ entry.selfStarted = false;
121664
+ const turnId = entry.turnId;
121665
+ if (!turnId) return;
121666
+ entry.reopenedTurnId = turnId;
121667
+ const reopen = () => {
121668
+ if (entry.turnId !== turnId || entry.reopenedTurnId !== turnId || entry.closeReason) return;
121669
+ const row = db2.prepare("SELECT status FROM turns WHERE id = ?").get(turnId);
121670
+ if (row?.status !== "completed") return;
121671
+ const now = (/* @__PURE__ */ new Date()).toISOString();
121672
+ db2.prepare("UPDATE turns SET status = 'running', updated_at = ? WHERE id = ?").run(now, turnId);
121673
+ if (entry.resultTurnId === turnId) entry.resultTurnId = null;
121674
+ bindHostTurn2(entry, turnId);
121675
+ setSessionStatus2(db2, sessionId, 1, "running", now);
121676
+ broadcast("turn:started", { sessionId, turnId });
121677
+ };
121678
+ if (entry.settling) void entry.settling.then(reopen, reopen);
121679
+ else reopen();
121680
+ }
121493
121681
  async function startTurn3(session, turn) {
121494
121682
  if (isAdoptionPending()) await waitForAdoption();
121495
121683
  const db2 = getDb();
@@ -121530,6 +121718,9 @@ async function startTurn3(session, turn) {
121530
121718
  }
121531
121719
  entry.turnId = turn.id;
121532
121720
  entry.lastApiError = null;
121721
+ entry.reopenedTurnId = null;
121722
+ entry.resultTurnId = null;
121723
+ entry.selfStarted = false;
121533
121724
  clearResume(entry);
121534
121725
  bindHostTurn2(entry, turn.id);
121535
121726
  db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("running", now, turn.id);
@@ -121997,14 +122188,25 @@ function handleBackgroundTasksChanged(message, sessionId, entry) {
121997
122188
  async function handleResultMessage(message, sessionId, turnId, entry, db2) {
121998
122189
  const parentToolUseId = message.parent_tool_use_id ?? null;
121999
122190
  if (parentToolUseId) return;
122191
+ const followUp = entry.reopenedTurnId === turnId;
122192
+ const settling = settleResult(message, sessionId, turnId, entry, db2, followUp);
122193
+ const tracked = settling.then(
122194
+ () => {
122195
+ },
122196
+ () => {
122197
+ }
122198
+ );
122199
+ entry.settling = tracked;
122000
122200
  try {
122001
- await settleResult(message, sessionId, turnId, entry, db2);
122201
+ await settling;
122002
122202
  } finally {
122203
+ if (followUp && entry.reopenedTurnId === turnId) entry.reopenedTurnId = null;
122204
+ if (entry.settling === tracked) entry.settling = null;
122003
122205
  settleHostTurn2(entry);
122004
122206
  maybeRetire2(entry);
122005
122207
  }
122006
122208
  }
122007
- async function settleResult(message, sessionId, turnId, entry, db2) {
122209
+ async function settleResult(message, sessionId, turnId, entry, db2, followUp = false) {
122008
122210
  if (message.subtype === "success") {
122009
122211
  const usage = mapUsage(message.usage);
122010
122212
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -122015,6 +122217,10 @@ async function settleResult(message, sessionId, turnId, entry, db2) {
122015
122217
  if (message.is_error) {
122016
122218
  const row = db2.prepare("SELECT status, resume_state FROM turns WHERE id = ?").get(turnId);
122017
122219
  if (!row || row.status === "pending" && row.resume_state === "waiting") return;
122220
+ if (followUp && row.status === "running") {
122221
+ completeTurn2(db2, sessionId, turnId, null);
122222
+ row.status = "completed";
122223
+ }
122018
122224
  const text2 = (message.result || apiError?.text || "Claude API error").trim();
122019
122225
  const kind = classifyApiError({
122020
122226
  error: apiError?.error,
@@ -122563,6 +122769,7 @@ function bindHostTurn2(entry, turnId) {
122563
122769
  const host = entry.host;
122564
122770
  const proc = host?.proc;
122565
122771
  if (!host || !proc?.hosted) return;
122772
+ noteAdoptedTurn(turnId);
122566
122773
  const offset = proc.consumedLineEnd;
122567
122774
  try {
122568
122775
  setHostTurn(getDb(), host.id, turnId, offset);
@@ -1,4 +1,4 @@
1
- var en=Object.defineProperty;var tn=(e,t,i)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ye=(e,t,i)=>tn(e,typeof t!="symbol"?t+"":t,i);import{c as sn,b as rn,u as gi,r as lt,j as Ee,R as nn,X as on}from"./index-BhyGOapD.js";/**
1
+ var en=Object.defineProperty;var tn=(e,t,i)=>t in e?en(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var Ye=(e,t,i)=>tn(e,typeof t!="symbol"?t+"":t,i);import{c as sn,b as rn,u as gi,r as lt,j as Ee,R as nn,X as on}from"./index-Cko45vc_.js";/**
2
2
  * @license lucide-react v0.469.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.