eve-hub 0.6.34 → 0.6.35

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # eve-hub
2
2
 
3
+ ## 0.6.35
4
+
5
+ ### Patch Changes
6
+
7
+ - A bot's attach_image carries its images into its reply with their sizes; an oversized upload answers 413 naming both limits.
8
+
3
9
  ## 0.6.34
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve-hub",
3
- "version": "0.6.34",
3
+ "version": "0.6.35",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Bot-side code shared by every hub agent: registry tools, the roster hook, the eve channel, the host sandbox and browser, and model helpers.",
6
6
  "type": "module",
package/world.mjs CHANGED
@@ -670,6 +670,8 @@ var PENDING_REQUESTS_READ = s(`SELECT r.id, r.session_id, r.thread_id, r.bot, r.
670
670
  var LIVE_TURNS_READ = s(`SELECT thread_id,bot,started_at,reply_text,activity FROM turns WHERE status IN ${OPEN_TURN_STATUSES} ORDER BY started_at`);
671
671
 
672
672
  // ../../hosted-hub/src/store/attachments.ts
673
+ var MAX_ATTACHMENTS = 10;
674
+ var OPEN_TURN = `(SELECT id FROM turns WHERE session_id = ? AND status IN ${OPEN_TURN_STATUSES} ORDER BY started_at DESC LIMIT 1)`;
673
675
  var ATTACHMENTS_READ = s("SELECT message_id, upload_id, name FROM message_attachments ORDER BY message_id, position");
674
676
  var unseenBy = (bot, thread, mid) => {
675
677
  const end = `COALESCE((SELECT rowid FROM messages WHERE id = ${mid}), 9223372036854775807)`;
@@ -27156,6 +27158,7 @@ function fold(state, chunks, now = Date.now()) {
27156
27158
  reduceActivity(open3.activity, { type: "turn.cancelled" }, at, cutOff(open3, "turn.cancelled"));
27157
27159
  Object.assign(open3, { status: open3.status === "cancelling" ? "cancelled" : status, endedAt: at, error: error63 });
27158
27160
  touched.set(open3.id, open3);
27161
+ stmts.push(s("DELETE FROM turn_attachments WHERE turn_id = ?", open3.id));
27159
27162
  log("turn.status", { turnId: open3.id, status: open3.status });
27160
27163
  open3 = null;
27161
27164
  };
@@ -27229,6 +27232,10 @@ function fold(state, chunks, now = Date.now()) {
27229
27232
  break;
27230
27233
  }
27231
27234
  case "action.result": {
27235
+ const attachment = data.result?.output?.attachment;
27236
+ if (data.result?.toolName === "attach_image" && data.status === "completed" && typeof attachment?.id === "string" && typeof attachment.name === "string" && typeof attachment.size === "number")
27237
+ stmts.push(s(`INSERT OR IGNORE INTO turn_attachments (turn_id, position, upload_id, name, size)
27238
+ SELECT ?, n, ?, ?, ? FROM (SELECT count(*) AS n FROM turn_attachments WHERE turn_id = ?) WHERE n < ?`, open3.id, attachment.id, attachment.name, attachment.size, open3.id, MAX_ATTACHMENTS));
27232
27239
  const ls = open3.lastStep, callId = data.result?.callId;
27233
27240
  if (!ls || !callId || ls.calls[callId] !== null) break;
27234
27241
  const postOutput = data.result?.output;
@@ -27242,14 +27249,16 @@ function fold(state, chunks, now = Date.now()) {
27242
27249
  break;
27243
27250
  case "turn.completed": {
27244
27251
  flush();
27245
- const text = open3.text.trim();
27246
- if (open3.status !== "cancelling" && !lastActWasOwnPost(open3.lastStep)) {
27252
+ const text = lastActWasOwnPost(open3.lastStep) ? "" : open3.text.trim();
27253
+ if (open3.status !== "cancelling") {
27247
27254
  const messageId2 = derivedMessageId(open3.id);
27248
27255
  stmts.push(s(`INSERT OR IGNORE INTO messages (id, thread_id, author, author_kind, text, turn_id, created_at)
27249
- SELECT ?, ?, ?, 'agent', ?, ?, ? WHERE ? <> ''
27250
- AND EXISTS (SELECT 1 FROM turns WHERE id = ? AND status NOT IN ('cancelling','cancelled') AND NOT (${REVOKED_TURN}))`, messageId2, session.thread, session.bot, text, open3.id, at, text, open3.id));
27256
+ SELECT ?, ?, ?, 'agent', ?, ?, ? WHERE (? <> '' OR EXISTS (SELECT 1 FROM turn_attachments WHERE turn_id = ?))
27257
+ AND EXISTS (SELECT 1 FROM turns WHERE id = ? AND status NOT IN ('cancelling','cancelled') AND NOT (${REVOKED_TURN}))`, messageId2, session.thread, session.bot, text, open3.id, at, text, open3.id, open3.id));
27251
27258
  log("message.created", { messageId: messageId2, author: session.bot, authorKind: "agent" }, IF_INSERTED);
27252
27259
  stmts.push(...notificationFor(messageId2, "agent", text, state.notify ?? void 0));
27260
+ stmts.push(s(`INSERT OR IGNORE INTO message_attachments (message_id, position, upload_id, name, size)
27261
+ SELECT ?, position, upload_id, name, size FROM turn_attachments WHERE turn_id = ? AND EXISTS (SELECT 1 FROM messages WHERE id = ?) ORDER BY position`, messageId2, open3.id, messageId2));
27253
27262
  const to = recipients(state.roster, text, { name: session.bot, kind: "agent" }, session.thread, state.participants);
27254
27263
  stmts.push(...routingStatements(messageId2, session.thread, to, at, { by: session.bot, joins: true }));
27255
27264
  deliver.push(messageId2);