@tangle-network/agent-app 1.0.8 → 1.0.9

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.
Files changed (30) hide show
  1. package/dist/agent-profiles/d1.js +3 -3
  2. package/dist/agent-profiles/index.js +3 -3
  3. package/dist/app-auth/index.js +1 -1
  4. package/dist/chat-routes/dispatch-parts.d.ts +1 -1
  5. package/dist/chat-routes/index.js +5 -5
  6. package/dist/{chunk-7JUQQEQY.js → chunk-532GILWC.js} +2 -2
  7. package/dist/{chunk-3KJAPMZB.js → chunk-C3JXGK3R.js} +2 -2
  8. package/dist/{chunk-UOZ4JCFJ.js → chunk-GJMKHY5U.js} +3 -25
  9. package/dist/chunk-GJMKHY5U.js.map +1 -0
  10. package/dist/{chunk-7MVMNCRP.js → chunk-IDRATMRZ.js} +5 -5
  11. package/dist/{chunk-7MVMNCRP.js.map → chunk-IDRATMRZ.js.map} +1 -1
  12. package/dist/{chunk-2CRRXINH.js → chunk-OJI2H3EZ.js} +13 -27
  13. package/dist/{chunk-2CRRXINH.js.map → chunk-OJI2H3EZ.js.map} +1 -1
  14. package/dist/{chunk-UCXB3ZZ3.js → chunk-TJA5ERCP.js} +3 -3
  15. package/dist/{chunk-VHDBKP3G.js → chunk-WQZCX4IJ.js} +2 -2
  16. package/dist/email/index.js +1 -1
  17. package/dist/email/palette.d.ts +23 -30
  18. package/dist/preset-cloudflare/index.js +2 -2
  19. package/dist/public-consultation/index.d.ts +1 -1
  20. package/dist/public-consultation/index.js +5 -5
  21. package/dist/sandbox/index.js +4 -4
  22. package/dist/theme/tokens.css +3 -3
  23. package/dist/tools/index.js +4 -4
  24. package/dist/work-product/index.js +2 -2
  25. package/package.json +5 -5
  26. package/dist/chunk-UOZ4JCFJ.js.map +0 -1
  27. /package/dist/{chunk-7JUQQEQY.js.map → chunk-532GILWC.js.map} +0 -0
  28. /package/dist/{chunk-3KJAPMZB.js.map → chunk-C3JXGK3R.js.map} +0 -0
  29. /package/dist/{chunk-UCXB3ZZ3.js.map → chunk-TJA5ERCP.js.map} +0 -0
  30. /package/dist/{chunk-VHDBKP3G.js.map → chunk-WQZCX4IJ.js.map} +0 -0
@@ -242,6 +242,7 @@ function createUploadRoute(options) {
242
242
  }
243
243
 
244
244
  // src/chat-routes/dispatch-parts.ts
245
+ import { partitionBySpeaker } from "@tangle-network/agent-interface/speaker";
245
246
  import { pathToFileURL } from "url";
246
247
  function byteLen(value) {
247
248
  return new TextEncoder().encode(value).length;
@@ -320,41 +321,26 @@ function projectDispatchHistory(messages, view = {}) {
320
321
  out.push({ role: "user", content: textOf(message) });
321
322
  continue;
322
323
  }
323
- const slices = speakerSlices(message);
324
- if (slices.length === 0) {
325
- const owner = view.owner;
324
+ const sections = partitionBySpeaker(message.parts ?? []);
325
+ const grouped = sections.some((section) => section.speaker !== null);
326
+ for (const { speaker, parts } of sections) {
327
+ const text = textOf(grouped ? {
328
+ role: "assistant",
329
+ parts,
330
+ content: parts.filter((part) => part.type === "text" && typeof part.text === "string").map((part) => part.text).join("")
331
+ } : message);
332
+ if (grouped && !speaker && !text) continue;
333
+ const owner = speaker ?? view.owner;
326
334
  const foreign = view.pov !== void 0 && owner !== void 0 && owner.id !== view.pov;
327
335
  out.push({
328
336
  role: foreign ? "user" : "assistant",
329
- content: foreign ? tagged(owner.name, textOf(message)) : textOf(message)
337
+ content: owner && (foreign || speaker && view.pov === void 0) ? tagged(owner.name, text) : text
330
338
  });
331
- continue;
332
- }
333
- for (const slice of slices) {
334
- const text = textOf({ role: "assistant", content: slice.text, parts: slice.parts });
335
- if (view.pov === void 0) out.push({ role: "assistant", content: tagged(slice.name, text) });
336
- else if (slice.id === view.pov) out.push({ role: "assistant", content: text });
337
- else out.push({ role: "user", content: tagged(slice.name, text) });
338
339
  }
339
340
  }
340
341
  return out;
341
342
  }
342
343
  var tagged = (name, text) => `[${name}] ${text}`;
343
- function speakerSlices(message) {
344
- const parts = message.parts ?? [];
345
- const slices = [];
346
- let current = null;
347
- for (const part of parts) {
348
- if (part.type === "speaker" && typeof part.id === "string" && typeof part.name === "string") {
349
- current = { id: part.id, name: part.name, text: "", parts: [] };
350
- slices.push(current);
351
- } else if (current) {
352
- current.parts.push(part);
353
- if (part.type === "text" && typeof part.text === "string") current.text += part.text;
354
- }
355
- }
356
- return slices;
357
- }
358
344
  function readResultToBase64(read) {
359
345
  if (typeof read.base64 === "string") return read.base64;
360
346
  if (read.bytes) return bytesToBase64(read.bytes);
@@ -4167,4 +4153,4 @@ export {
4167
4153
  createChatTurnRoutes,
4168
4154
  streamChatRouteAsSandboxEvents
4169
4155
  };
4170
- //# sourceMappingURL=chunk-2CRRXINH.js.map
4156
+ //# sourceMappingURL=chunk-OJI2H3EZ.js.map