repoburg 1.3.279 → 1.3.280

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.
@@ -41840,6 +41840,10 @@ function isSessionBusy(db2, session, opts) {
41840
41840
  );
41841
41841
  return false;
41842
41842
  }
41843
+ function turnResponse(db2, turnId) {
41844
+ const row = db2.prepare("SELECT agent_response FROM turns WHERE id = ?").get(turnId);
41845
+ return row?.agent_response || null;
41846
+ }
41843
41847
  function recomputeSessionRunning(db2, sessionId, idleStatus = "active", hasUnreviewed = false) {
41844
41848
  const live = db2.prepare(
41845
41849
  `SELECT COUNT(*) AS c,
@@ -98487,10 +98491,15 @@ viewer; it refreshes via AgentPane.onStateChanged(cb).
98487
98491
 
98488
98492
  Headless contract for apps that declare tools:
98489
98493
  - register AgentPane.onToolCall(handler) synchronously at startup
98494
+ - the handler gets one payload, handler({ callId, name, tool, args }), the
98495
+ same as in the tab; a handler declaring two parameters still gets the
98496
+ older headless form ('tool_call', payload)
98490
98497
  - tool handlers must not depend on the DOM or the live UI
98491
- - headless state is the instance of the CALLING session's workspace
98492
- ('' = global when the caller has no known workspace); open tabs
98493
- sync via onStateChanged
98498
+ - headless state is the instance of the CALLING session's workspace; open
98499
+ tabs sync via onStateChanged. A session in a subfolder uses the workspace
98500
+ above it; one in an app folder, or with no workspace, uses the global
98501
+ instance. A path the pane does not know (unregistered, deleted) fails the
98502
+ call with "Unknown workspace", and no state is read or written
98494
98503
  - createSession/submitTurn/openSession/openUrl are not available in the
98495
98504
  headless runtime
98496
98505
  - stored files are: getFile(ref)/fileUrl(ref)/uploadFile({ name, type, data })
@@ -98499,7 +98508,8 @@ Headless contract for apps that declare tools:
98499
98508
 
98500
98509
  If the app cannot load headless (broken app.js, no handler), the pane
98501
98510
  falls back to relaying calls into the OPEN app iframe \u2014 the app must be
98502
- open in AgentPane for a tool call to succeed in that case.
98511
+ open in AgentPane, on the calling session's workspace, for a tool call to
98512
+ succeed in that case.
98503
98513
 
98504
98514
  ## Result contract
98505
98515
 
@@ -99263,7 +99273,8 @@ function getHeadlessToolHandler(appId, workspace = "") {
99263
99273
  return Promise.resolve(next);
99264
99274
  },
99265
99275
  onToolCall: (cb) => {
99266
- if (typeof cb === "function") handler = cb;
99276
+ if (typeof cb !== "function") return;
99277
+ handler = cb.length >= 2 ? (payload) => cb("tool_call", payload) : (payload) => cb(payload);
99267
99278
  },
99268
99279
  resolveToolCall: (callId, result) => {
99269
99280
  resolveHeadlessToolCall(String(callId), result);
@@ -99347,7 +99358,7 @@ function dispatchHeadlessToolCall(handler, tool, args) {
99347
99358
  pendingCalls.set(callId, { resolve, reject, timer: timer2 });
99348
99359
  });
99349
99360
  try {
99350
- handler("tool_call", { callId, tool, name: tool, args: args ?? {} });
99361
+ handler({ callId, tool, name: tool, args: args ?? {} });
99351
99362
  } catch (err) {
99352
99363
  const pending = pendingCalls.get(callId);
99353
99364
  if (pending) {
@@ -99426,12 +99437,12 @@ function dispatchAppTool(toolName, args, workspace = "") {
99426
99437
  pendingCalls2.delete(callId);
99427
99438
  reject(
99428
99439
  new Error(
99429
- `Mini app '${appId}' did not answer tool '${localName}' within ${TOOL_CALL_TIMEOUT_MS / 1e3}s \u2014 open the app in AgentPane or fix its headless load.`
99440
+ `Mini app '${appId}' did not answer tool '${localName}' within ${TOOL_CALL_TIMEOUT_MS / 1e3}s \u2014 open the app in AgentPane (${workspace ? `workspace ${workspace}` : "global instance"}) or fix its headless load.`
99430
99441
  )
99431
99442
  );
99432
99443
  }, TOOL_CALL_TIMEOUT_MS);
99433
99444
  pendingCalls2.set(callId, { resolve, reject, timer: timer2, appId });
99434
- broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {} });
99445
+ broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {}, workspace });
99435
99446
  });
99436
99447
  return { callId, result };
99437
99448
  }
@@ -99456,8 +99467,14 @@ var FILE_UPLOAD_BODY_LIMIT = Math.ceil(APP_FILE_MAX_BYTES * 4 / 3) + 64 * 1024;
99456
99467
  var IMPORT_FILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
99457
99468
  function resolveToolWorkspace(workspace) {
99458
99469
  if (!workspace) return "";
99459
- const row = getDb().prepare("SELECT 1 FROM workspaces WHERE path = ? AND deleted = 0").get(workspace);
99460
- return row ? workspace : "";
99470
+ const rows = getDb().prepare("SELECT path, deleted FROM workspaces").all();
99471
+ const active = rows.filter((w) => !w.deleted).map((w) => w.path);
99472
+ if (active.includes(workspace)) return workspace;
99473
+ const cwd = path7.isAbsolute(workspace) ? path7.resolve(workspace) : "";
99474
+ if (isInAppFolder(cwd)) return "";
99475
+ const covering = rows.filter((w) => cwd === w.path || cwd.startsWith(w.path + path7.sep)).sort((a, b) => b.path.length - a.path.length)[0];
99476
+ if (covering && !covering.deleted) return covering.path;
99477
+ throw new Error(`Unknown workspace: ${workspace}. Known workspaces: ${active.join(", ") || "none"}`);
99461
99478
  }
99462
99479
  var IMPORT_MAX_FILES = 50;
99463
99480
  var IMPORT_MAX_FILE_BYTES = 512 * 1024;
@@ -101323,6 +101340,7 @@ async function startTurn(session, turn) {
101323
101340
  broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
101324
101341
  return;
101325
101342
  }
101343
+ const response = turnResponse(db3, turn.id);
101326
101344
  if (p.usage !== void 0) {
101327
101345
  db3.prepare("UPDATE turns SET status = ?, token_usage = ?, updated_at = ? WHERE id = ?").run(
101328
101346
  "completed",
@@ -101330,10 +101348,10 @@ async function startTurn(session, turn) {
101330
101348
  now2,
101331
101349
  turn.id
101332
101350
  );
101333
- broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, usage: p.usage, hasUnreviewed: true });
101351
+ broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, usage: p.usage, hasUnreviewed: true, response });
101334
101352
  } else {
101335
101353
  db3.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now2, turn.id);
101336
- broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, hasUnreviewed: true });
101354
+ broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, hasUnreviewed: true, response });
101337
101355
  }
101338
101356
  recomputeSessionRunning(db3, session.id, "active", true);
101339
101357
  syncThreadTitle(session.id);
@@ -102652,6 +102670,7 @@ async function handleResultMessage(message, sessionId, turnId, entry, db2) {
102652
102670
  function completeTurn(db2, sessionId, turnId, usage) {
102653
102671
  markTurnResumed(db2, turnId, { settle: true });
102654
102672
  const now = (/* @__PURE__ */ new Date()).toISOString();
102673
+ const response = turnResponse(db2, turnId);
102655
102674
  if (usage) {
102656
102675
  db2.prepare("UPDATE turns SET status = ?, token_usage = ?, updated_at = ? WHERE id = ?").run(
102657
102676
  "completed",
@@ -102659,10 +102678,10 @@ function completeTurn(db2, sessionId, turnId, usage) {
102659
102678
  now,
102660
102679
  turnId
102661
102680
  );
102662
- broadcast("turn:completed", { sessionId, turnId, usage, hasUnreviewed: true });
102681
+ broadcast("turn:completed", { sessionId, turnId, usage, hasUnreviewed: true, response });
102663
102682
  } else {
102664
102683
  db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now, turnId);
102665
- broadcast("turn:completed", { sessionId, turnId, hasUnreviewed: true });
102684
+ broadcast("turn:completed", { sessionId, turnId, hasUnreviewed: true, response });
102666
102685
  }
102667
102686
  recomputeSessionRunning(db2, sessionId, "active", true);
102668
102687
  syncThreadTitle2(sessionId);
@@ -41371,6 +41371,10 @@ function isSessionBusy(db2, session, opts) {
41371
41371
  );
41372
41372
  return false;
41373
41373
  }
41374
+ function turnResponse(db2, turnId) {
41375
+ const row = db2.prepare("SELECT agent_response FROM turns WHERE id = ?").get(turnId);
41376
+ return row?.agent_response || null;
41377
+ }
41374
41378
  function recomputeSessionRunning(db2, sessionId, idleStatus = "active", hasUnreviewed = false) {
41375
41379
  const live = db2.prepare(
41376
41380
  `SELECT COUNT(*) AS c,
@@ -98474,10 +98478,15 @@ viewer; it refreshes via AgentPane.onStateChanged(cb).
98474
98478
 
98475
98479
  Headless contract for apps that declare tools:
98476
98480
  - register AgentPane.onToolCall(handler) synchronously at startup
98481
+ - the handler gets one payload, handler({ callId, name, tool, args }), the
98482
+ same as in the tab; a handler declaring two parameters still gets the
98483
+ older headless form ('tool_call', payload)
98477
98484
  - tool handlers must not depend on the DOM or the live UI
98478
- - headless state is the instance of the CALLING session's workspace
98479
- ('' = global when the caller has no known workspace); open tabs
98480
- sync via onStateChanged
98485
+ - headless state is the instance of the CALLING session's workspace; open
98486
+ tabs sync via onStateChanged. A session in a subfolder uses the workspace
98487
+ above it; one in an app folder, or with no workspace, uses the global
98488
+ instance. A path the pane does not know (unregistered, deleted) fails the
98489
+ call with "Unknown workspace", and no state is read or written
98481
98490
  - createSession/submitTurn/openSession/openUrl are not available in the
98482
98491
  headless runtime
98483
98492
  - stored files are: getFile(ref)/fileUrl(ref)/uploadFile({ name, type, data })
@@ -98486,7 +98495,8 @@ Headless contract for apps that declare tools:
98486
98495
 
98487
98496
  If the app cannot load headless (broken app.js, no handler), the pane
98488
98497
  falls back to relaying calls into the OPEN app iframe \u2014 the app must be
98489
- open in AgentPane for a tool call to succeed in that case.
98498
+ open in AgentPane, on the calling session's workspace, for a tool call to
98499
+ succeed in that case.
98490
98500
 
98491
98501
  ## Result contract
98492
98502
 
@@ -99250,7 +99260,8 @@ function getHeadlessToolHandler(appId, workspace = "") {
99250
99260
  return Promise.resolve(next);
99251
99261
  },
99252
99262
  onToolCall: (cb) => {
99253
- if (typeof cb === "function") handler = cb;
99263
+ if (typeof cb !== "function") return;
99264
+ handler = cb.length >= 2 ? (payload) => cb("tool_call", payload) : (payload) => cb(payload);
99254
99265
  },
99255
99266
  resolveToolCall: (callId, result) => {
99256
99267
  resolveHeadlessToolCall(String(callId), result);
@@ -99334,7 +99345,7 @@ function dispatchHeadlessToolCall(handler, tool, args) {
99334
99345
  pendingCalls.set(callId, { resolve, reject, timer: timer2 });
99335
99346
  });
99336
99347
  try {
99337
- handler("tool_call", { callId, tool, name: tool, args: args ?? {} });
99348
+ handler({ callId, tool, name: tool, args: args ?? {} });
99338
99349
  } catch (err) {
99339
99350
  const pending = pendingCalls.get(callId);
99340
99351
  if (pending) {
@@ -99413,12 +99424,12 @@ function dispatchAppTool(toolName, args, workspace = "") {
99413
99424
  pendingCalls2.delete(callId);
99414
99425
  reject(
99415
99426
  new Error(
99416
- `Mini app '${appId}' did not answer tool '${localName}' within ${TOOL_CALL_TIMEOUT_MS / 1e3}s \u2014 open the app in AgentPane or fix its headless load.`
99427
+ `Mini app '${appId}' did not answer tool '${localName}' within ${TOOL_CALL_TIMEOUT_MS / 1e3}s \u2014 open the app in AgentPane (${workspace ? `workspace ${workspace}` : "global instance"}) or fix its headless load.`
99417
99428
  )
99418
99429
  );
99419
99430
  }, TOOL_CALL_TIMEOUT_MS);
99420
99431
  pendingCalls2.set(callId, { resolve, reject, timer: timer2, appId });
99421
- broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {} });
99432
+ broadcast("app:tool_call", { appId, callId, tool: localName, args: args ?? {}, workspace });
99422
99433
  });
99423
99434
  return { callId, result };
99424
99435
  }
@@ -99443,8 +99454,14 @@ var FILE_UPLOAD_BODY_LIMIT = Math.ceil(APP_FILE_MAX_BYTES * 4 / 3) + 64 * 1024;
99443
99454
  var IMPORT_FILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
99444
99455
  function resolveToolWorkspace(workspace) {
99445
99456
  if (!workspace) return "";
99446
- const row = getDb().prepare("SELECT 1 FROM workspaces WHERE path = ? AND deleted = 0").get(workspace);
99447
- return row ? workspace : "";
99457
+ const rows = getDb().prepare("SELECT path, deleted FROM workspaces").all();
99458
+ const active = rows.filter((w) => !w.deleted).map((w) => w.path);
99459
+ if (active.includes(workspace)) return workspace;
99460
+ const cwd = path7.isAbsolute(workspace) ? path7.resolve(workspace) : "";
99461
+ if (isInAppFolder(cwd)) return "";
99462
+ const covering = rows.filter((w) => cwd === w.path || cwd.startsWith(w.path + path7.sep)).sort((a, b) => b.path.length - a.path.length)[0];
99463
+ if (covering && !covering.deleted) return covering.path;
99464
+ throw new Error(`Unknown workspace: ${workspace}. Known workspaces: ${active.join(", ") || "none"}`);
99448
99465
  }
99449
99466
  var IMPORT_MAX_FILES = 50;
99450
99467
  var IMPORT_MAX_FILE_BYTES = 512 * 1024;
@@ -101310,6 +101327,7 @@ async function startTurn(session, turn) {
101310
101327
  broadcast("turn:failed", { sessionId: session.id, turnId: turn.id, error: errMsg });
101311
101328
  return;
101312
101329
  }
101330
+ const response = turnResponse(db3, turn.id);
101313
101331
  if (p.usage !== void 0) {
101314
101332
  db3.prepare("UPDATE turns SET status = ?, token_usage = ?, updated_at = ? WHERE id = ?").run(
101315
101333
  "completed",
@@ -101317,10 +101335,10 @@ async function startTurn(session, turn) {
101317
101335
  now2,
101318
101336
  turn.id
101319
101337
  );
101320
- broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, usage: p.usage, hasUnreviewed: true });
101338
+ broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, usage: p.usage, hasUnreviewed: true, response });
101321
101339
  } else {
101322
101340
  db3.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now2, turn.id);
101323
- broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, hasUnreviewed: true });
101341
+ broadcast("turn:completed", { sessionId: session.id, turnId: turn.id, hasUnreviewed: true, response });
101324
101342
  }
101325
101343
  recomputeSessionRunning(db3, session.id, "active", true);
101326
101344
  syncThreadTitle(session.id);
@@ -102639,6 +102657,7 @@ async function handleResultMessage(message, sessionId, turnId, entry, db2) {
102639
102657
  function completeTurn(db2, sessionId, turnId, usage) {
102640
102658
  markTurnResumed(db2, turnId, { settle: true });
102641
102659
  const now = (/* @__PURE__ */ new Date()).toISOString();
102660
+ const response = turnResponse(db2, turnId);
102642
102661
  if (usage) {
102643
102662
  db2.prepare("UPDATE turns SET status = ?, token_usage = ?, updated_at = ? WHERE id = ?").run(
102644
102663
  "completed",
@@ -102646,10 +102665,10 @@ function completeTurn(db2, sessionId, turnId, usage) {
102646
102665
  now,
102647
102666
  turnId
102648
102667
  );
102649
- broadcast("turn:completed", { sessionId, turnId, usage, hasUnreviewed: true });
102668
+ broadcast("turn:completed", { sessionId, turnId, usage, hasUnreviewed: true, response });
102650
102669
  } else {
102651
102670
  db2.prepare("UPDATE turns SET status = ?, updated_at = ? WHERE id = ?").run("completed", now, turnId);
102652
- broadcast("turn:completed", { sessionId, turnId, hasUnreviewed: true });
102671
+ broadcast("turn:completed", { sessionId, turnId, hasUnreviewed: true, response });
102653
102672
  }
102654
102673
  recomputeSessionRunning(db2, sessionId, "active", true);
102655
102674
  syncThreadTitle2(sessionId);