@agentdocumentformat/cli 0.7.8 → 0.8.1

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 (103) hide show
  1. package/README.md +1 -1
  2. package/dist/adf.mjs +59 -8
  3. package/dist/chunks/{APEv2Parser-2CNNHMXV.mjs → APEv2Parser-WIXRJLHB.mjs} +2 -2
  4. package/dist/chunks/{AiffParser-7BR4RL6G.mjs → AiffParser-ZC4QFOVJ.mjs} +5 -5
  5. package/dist/chunks/{App-7RIIOHJJ.mjs → App-4AZZJNN2.mjs} +917 -826
  6. package/dist/chunks/{DsdiffParser-CMD4AX7A.mjs → DsdiffParser-UAPAJHFX.mjs} +5 -5
  7. package/dist/chunks/{DsfParser-UOGZDS2M.mjs → DsfParser-NNYZK2QX.mjs} +6 -6
  8. package/dist/chunks/{FlacParser-HB3T3CD4.mjs → FlacParser-MW2W4LO3.mjs} +6 -6
  9. package/dist/chunks/{MP4Parser-66HBRUSX.mjs → MP4Parser-Z57SYOOQ.mjs} +4 -4
  10. package/dist/chunks/{MpegParser-YW6LIUEW.mjs → MpegParser-XIIPAZVM.mjs} +7 -7
  11. package/dist/chunks/{MusepackParser-PAUSXP7D.mjs → MusepackParser-QWNDEYHJ.mjs} +6 -6
  12. package/dist/chunks/{OggParser-NUBV3GWC.mjs → OggParser-WRX53F77.mjs} +9 -9
  13. package/dist/chunks/{WavPackParser-WQAGT7TC.mjs → WavPackParser-MJ7WCSJ5.mjs} +2 -2
  14. package/dist/chunks/{WaveParser-EWLQVDX4.mjs → WaveParser-RAVLHZ5S.mjs} +7 -7
  15. package/dist/chunks/{adf-schema-US4NFHMR.mjs → adf-schema-AIPBQTR2.mjs} +9 -3
  16. package/dist/chunks/auth-manager-AJ32FZWS.mjs +19 -0
  17. package/dist/chunks/auth-manager-C5OBEQK2.mjs +18 -0
  18. package/dist/chunks/auth-manager-TBNKCJ45.mjs +17 -0
  19. package/dist/chunks/{chatgpt-subscription-E4MXTIAT.mjs → chatgpt-subscription-MMGNW5KJ.mjs} +5 -2
  20. package/dist/chunks/chunk-2Z7X3UUR.mjs +678 -0
  21. package/dist/chunks/chunk-3UGZFWIF.mjs +26 -0
  22. package/dist/chunks/{chunk-XNPZBLYL.mjs → chunk-75DC5EWN.mjs} +13 -2
  23. package/dist/chunks/{chunk-5PO5PKRV.mjs → chunk-7JZXMDDF.mjs} +158 -67
  24. package/dist/chunks/chunk-AEAJDCVK.mjs +517 -0
  25. package/dist/chunks/{chunk-6VQEXLE2.mjs → chunk-BHY7QDCM.mjs} +41 -3
  26. package/dist/chunks/{chunk-CD3ATSXE.mjs → chunk-BR3AD5QZ.mjs} +8 -2
  27. package/dist/chunks/chunk-BS3USVEA.mjs +301 -0
  28. package/dist/chunks/chunk-C2S64Y6F.mjs +203 -0
  29. package/dist/chunks/chunk-D7A77SNL.mjs +976 -0
  30. package/dist/chunks/chunk-DDTTSKGG.mjs +2443 -0
  31. package/dist/chunks/{chunk-VAUOM3IN.mjs → chunk-DLWCKKIO.mjs} +1 -1
  32. package/dist/chunks/{chunk-G6PH7RPW.mjs → chunk-E7LC6SHP.mjs} +3 -3
  33. package/dist/chunks/{chunk-ZESQMP66.mjs → chunk-F3WSCAJD.mjs} +3 -3
  34. package/dist/chunks/{chunk-KXEF4F4E.mjs → chunk-GAZO6UMI.mjs} +1 -1
  35. package/dist/chunks/{chunk-XYTWGHFS.mjs → chunk-H3XLRWVE.mjs} +1 -1
  36. package/dist/chunks/{chunk-7T2YMTWL.mjs → chunk-H4C65MTP.mjs} +4 -4
  37. package/dist/chunks/chunk-HBOFZRUS.mjs +738 -0
  38. package/dist/chunks/{chunk-VN7UH7I5.mjs → chunk-IMVMSU3A.mjs} +251 -68
  39. package/dist/chunks/{chunk-XYV3VCIX.mjs → chunk-JZFONJSL.mjs} +79 -20
  40. package/dist/chunks/chunk-KCIRFUZH.mjs +12799 -0
  41. package/dist/chunks/chunk-KDDVQKCG.mjs +65 -0
  42. package/dist/chunks/chunk-KRPKWOMB.mjs +290 -0
  43. package/dist/chunks/chunk-LKFHERRV.mjs +145 -0
  44. package/dist/chunks/chunk-LTX74NU6.mjs +29 -0
  45. package/dist/chunks/{chunk-HSBV6YFU.mjs → chunk-LVF2DRBR.mjs} +634 -99
  46. package/dist/chunks/chunk-M2F7C2UJ.mjs +425 -0
  47. package/dist/chunks/{chunk-62NE4LG4.mjs → chunk-MQAMI5BF.mjs} +5 -5
  48. package/dist/chunks/chunk-MZRXFWPQ.mjs +278 -0
  49. package/dist/chunks/{chunk-PRMGZZM5.mjs → chunk-NZLEPJ5M.mjs} +2 -0
  50. package/dist/chunks/{chunk-I3UYSITV.mjs → chunk-O7XKQ6CH.mjs} +1 -1
  51. package/dist/chunks/chunk-P3RG5LQA.mjs +244 -0
  52. package/dist/chunks/chunk-PAK5JCO2.mjs +48 -0
  53. package/dist/chunks/chunk-PC63YFB7.mjs +34 -0
  54. package/dist/chunks/{daemon-control-HKFVSQTQ.mjs → chunk-RHBGCOS3.mjs} +67 -26
  55. package/dist/chunks/{chunk-J74STFKE.mjs → chunk-RJDOVMM4.mjs} +362 -58
  56. package/dist/chunks/{chunk-QPLEAE6V.mjs → chunk-SOSPQPEN.mjs} +167 -650
  57. package/dist/chunks/{chunk-LFMB4PAA.mjs → chunk-TKXIH27X.mjs} +974 -113
  58. package/dist/chunks/{chunk-5W7KES6P.mjs → chunk-UZPDETEU.mjs} +1 -1
  59. package/dist/chunks/chunk-V3MM6PCH.mjs +366 -0
  60. package/dist/chunks/chunk-VENQBMOA.mjs +62 -0
  61. package/dist/chunks/chunk-WJGPNHGX.mjs +67 -0
  62. package/dist/chunks/{chunk-Y5ZLKFLE.mjs → chunk-XNNJQCZP.mjs} +196 -165
  63. package/dist/chunks/{chunk-HDBPBORT.mjs → chunk-YRBFIDLB.mjs} +46 -10
  64. package/dist/chunks/{chunk-BNXUAOO4.mjs → chunk-ZGXUOAWZ.mjs} +3186 -959
  65. package/dist/chunks/chunk-ZPB3HYM7.mjs +45 -0
  66. package/dist/chunks/claude-subscription-EB4LAAVV.mjs +29 -0
  67. package/dist/chunks/{cli-NMFIAR7Z.mjs → cli-PCVFB6B4.mjs} +797 -56
  68. package/dist/chunks/{commands-KPJWFRUE.mjs → commands-KOMPXJZS.mjs} +4 -3
  69. package/dist/chunks/{daemon-YDIK3AAM.mjs → daemon-BVDB565V.mjs} +83142 -64424
  70. package/dist/chunks/daemon-control-MKN7G5M3.mjs +59 -0
  71. package/dist/chunks/{daemon-token-WRSULP7G.mjs → daemon-token-L5QKTHU5.mjs} +3 -1
  72. package/dist/chunks/{discord-DSP4HUWI.mjs → discord-IR62565M.mjs} +3 -52
  73. package/dist/chunks/{email-BRG7KUO2.mjs → email-KHHTJBDW.mjs} +4 -2
  74. package/dist/chunks/{grok-subscription-4PYX7TBF.mjs → grok-subscription-E74FS5EG.mjs} +5 -2
  75. package/dist/chunks/{layout-EPJQNFAI.mjs → layout-ECWGJF6M.mjs} +2 -2
  76. package/dist/chunks/{lib-N7FCZWKH.mjs → lib-L27L5PXM.mjs} +22 -22
  77. package/dist/chunks/{open-VAU7PXT6.mjs → open-3OR6WT4T.mjs} +6 -6
  78. package/dist/chunks/{parser-JVY2PWSM.mjs → parser-7GARNT5L.mjs} +1 -1
  79. package/dist/chunks/{pipeline-executor-O77NTGLP.mjs → pipeline-executor-DRYEEFDR.mjs} +6 -5
  80. package/dist/chunks/prompt-RRHZX4YT.mjs +13 -0
  81. package/dist/chunks/remote-access-cli-GLEEP7DI.mjs +268 -0
  82. package/dist/chunks/remote-hello-UFWUBDQI.mjs +37 -0
  83. package/dist/chunks/sdk-OJOAF4DP.mjs +30014 -0
  84. package/dist/chunks/{slack-OCNNF4DX.mjs → slack-IYC5RAB5.mjs} +3 -4
  85. package/dist/chunks/{store-HUVDJPYN.mjs → store-55CQSAOX.mjs} +7 -3
  86. package/dist/chunks/tailscale-WLJATFMB.mjs +25 -0
  87. package/dist/chunks/{theme-SFE3JMA2.mjs → theme-HLBDTF6F.mjs} +1 -1
  88. package/dist/chunks/{themes-YLXLOIJF.mjs → themes-BQ72P446.mjs} +2 -2
  89. package/dist/chunks/{token-6G3HCMNX.mjs → token-6D22WECM.mjs} +20 -16
  90. package/dist/chunks/{token-util-UXYSDQIW.mjs → token-util-YF3ZWBZ4.mjs} +1 -2
  91. package/dist/chunks/{tui-UQJLK7XI.mjs → tui-RAUVFOYY.mjs} +21 -18
  92. package/dist/chunks/{welcome-XHXFV7SH.mjs → welcome-J5JZZAM5.mjs} +1 -1
  93. package/dist/chunks/{whatsapp-AJMRQBT7.mjs → whatsapp-YJFFVN4Q.mjs} +9 -9
  94. package/package.json +1 -1
  95. package/dist/chunks/chunk-GKKCMXIZ.mjs +0 -94
  96. package/dist/chunks/chunk-IHDDCZBS.mjs +0 -112
  97. package/dist/chunks/chunk-KWFOS5WC.mjs +0 -41
  98. package/dist/chunks/chunk-UEZR2CNS.mjs +0 -65
  99. package/dist/chunks/chunk-VMHTYDH4.mjs +0 -172
  100. package/dist/chunks/chunk-Y2QA53AN.mjs +0 -259
  101. package/dist/chunks/{chunk-NBTUWMGP.mjs → chunk-2MTE22CR.mjs} +3 -3
  102. package/dist/chunks/{chunk-APRU6PHC.mjs → chunk-JZ7AQNPM.mjs} +3 -3
  103. package/dist/chunks/{telegram-2EFGKIVK.mjs → telegram-JYY2VDTI.mjs} +5 -5
@@ -0,0 +1,26 @@
1
+ import { createRequire as __adfCreateRequire } from 'node:module';
2
+ import { fileURLToPath as __adfFileURLToPath } from 'node:url';
3
+ import { dirname as __adfDirname } from 'node:path';
4
+ const require = __adfCreateRequire(import.meta.url);
5
+ const __filename = __adfFileURLToPath(import.meta.url);
6
+ const __dirname = __adfDirname(__filename);
7
+
8
+ // src/shared/utils/network-consent-text.ts
9
+ var PUBLIC_WARNING = "Public network. The token is sent unencrypted.";
10
+ var NETWORK_PROBLEM_TEXT = {
11
+ route_read: "It cannot read the route table.",
12
+ no_gateway: "It cannot find the router address.",
13
+ arp_read: "It cannot read the address table.",
14
+ no_answer: "The router does not answer.",
15
+ no_subnet: "It cannot find the subnet."
16
+ };
17
+ function unidentifiedText(problem, who = "Studio") {
18
+ let head = `${who} cannot identify this network.`;
19
+ return problem ? `${head} ${NETWORK_PROBLEM_TEXT[problem.step]}` : head;
20
+ }
21
+
22
+ export {
23
+ PUBLIC_WARNING,
24
+ NETWORK_PROBLEM_TEXT,
25
+ unidentifiedText
26
+ };
@@ -4,8 +4,18 @@ import { dirname as __adfDirname } from 'node:path';
4
4
  const require = __adfCreateRequire(import.meta.url);
5
5
  const __filename = __adfFileURLToPath(import.meta.url);
6
6
  const __dirname = __adfDirname(__filename);
7
+ import {
8
+ __export
9
+ } from "./chunk-M2RX3S2T.mjs";
7
10
 
8
- // src/main/tui/api/types.ts
11
+ // src/shared/daemon-client/types.ts
12
+ var types_exports = {};
13
+ __export(types_exports, {
14
+ DaemonError: () => DaemonError,
15
+ MAIN_LOOP: () => MAIN_LOOP,
16
+ SUPPORTED_CLIENT_API_VERSION: () => SUPPORTED_CLIENT_API_VERSION,
17
+ isCredentialsLocked: () => isCredentialsLocked
18
+ });
9
19
  var MAIN_LOOP = "main", DaemonError = class extends Error {
10
20
  constructor(message, status, body = null) {
11
21
  super(message);
@@ -25,9 +35,10 @@ function isCredentialsLocked(err) {
25
35
  let body = err.body;
26
36
  return !!body && typeof body == "object" && body.code === "credentials_locked";
27
37
  }
38
+ var SUPPORTED_CLIENT_API_VERSION = 2;
28
39
 
29
40
  export {
30
41
  MAIN_LOOP,
31
42
  DaemonError,
32
- isCredentialsLocked
43
+ types_exports
33
44
  };
@@ -4,34 +4,119 @@ import { dirname as __adfDirname } from 'node:path';
4
4
  const require = __adfCreateRequire(import.meta.url);
5
5
  const __filename = __adfFileURLToPath(import.meta.url);
6
6
  const __dirname = __adfDirname(__filename);
7
+ import {
8
+ attachmentsOf,
9
+ displayAttachment,
10
+ isFileRefBlock,
11
+ splitLegacyUploads
12
+ } from "./chunk-LKFHERRV.mjs";
7
13
  import {
8
14
  __export
9
15
  } from "./chunk-M2RX3S2T.mjs";
10
16
 
17
+ // src/shared/utils/owner-command-row.ts
18
+ var owner_command_row_exports = {};
19
+ __export(owner_command_row_exports, {
20
+ OWNER_COMMAND_MARKER: () => OWNER_COMMAND_MARKER,
21
+ formatOwnerCommandRow: () => formatOwnerCommandRow,
22
+ isOwnerCommandRow: () => isOwnerCommandRow,
23
+ parseOwnerCommandRow: () => parseOwnerCommandRow
24
+ });
25
+ var OWNER_COMMAND_MARKER = "[Owner command] ";
26
+ function formatOwnerCommandRow(header, body) {
27
+ return `${OWNER_COMMAND_MARKER}${JSON.stringify(header)}
28
+ ${body}`;
29
+ }
30
+ function parseOwnerCommandRow(text) {
31
+ if (!text.startsWith(OWNER_COMMAND_MARKER)) return null;
32
+ let newline = text.indexOf(`
33
+ `);
34
+ try {
35
+ let header = JSON.parse(text.slice(OWNER_COMMAND_MARKER.length, newline < 0 ? void 0 : newline));
36
+ return !header || header.v !== 1 || typeof header.id != "string" || typeof header.command != "string" || typeof header.lambda != "string" || typeof header.authorized != "boolean" || typeof header.duration_ms != "number" || !Number.isFinite(header.duration_ms) || header.duration_ms < 0 || !["ok", "error", "denied"].includes(header.status) ? null : { header, body: newline < 0 ? "" : text.slice(newline + 1) };
37
+ } catch {
38
+ return null;
39
+ }
40
+ }
41
+ function isOwnerCommandRow(text) {
42
+ return parseOwnerCommandRow(text) !== null;
43
+ }
44
+
11
45
  // src/shared/utils/loop-parser.ts
12
46
  var loop_parser_exports = {};
13
47
  __export(loop_parser_exports, {
48
+ RUNTIME_NOTICE_PREFIXES: () => RUNTIME_NOTICE_PREFIXES,
49
+ TURN_ERROR_DETAILS_MARKER: () => TURN_ERROR_DETAILS_MARKER,
14
50
  TURN_ERROR_MARKER: () => TURN_ERROR_MARKER,
51
+ classifyInjectedText: () => classifyInjectedText,
52
+ detectTriggerType: () => detectTriggerType,
15
53
  findToolResult: () => findToolResult,
54
+ formatTurnErrorRow: () => formatTurnErrorRow,
16
55
  getLoopSummary: () => getLoopSummary,
17
- isContextEntry: () => isContextEntry,
56
+ isNoticeCategory: () => isNoticeCategory,
57
+ isRuntimeNotice: () => isRuntimeNotice,
18
58
  loopToLLMMessages: () => loopToLLMMessages,
19
59
  parseLoopSendStamp: () => parseLoopSendStamp,
20
60
  parseLoopToDisplay: () => parseLoopToDisplay,
21
61
  parseLoopWithToolPairs: () => parseLoopWithToolPairs,
22
- parseTurnErrorMarker: () => parseTurnErrorMarker
62
+ parseTurnErrorMarker: () => parseTurnErrorMarker,
63
+ parseTurnErrorRow: () => parseTurnErrorRow,
64
+ providerContextCategory: () => providerContextCategory
23
65
  });
24
- function isContextEntry(text) {
25
- let match = text.match(/^\[Context: ([^\]]+)\]/);
26
- return match ? match[1] : null;
27
- }
28
66
  function parseLoopSendStamp(text) {
29
67
  let match = text.match(/^\[from loop:([a-z0-9][a-z0-9_-]{0,31})\] ([\s\S]*)$/);
30
68
  return match ? { fromLoop: match[1], body: match[2] } : null;
31
69
  }
32
- var TURN_ERROR_MARKER = "[Turn error] ";
70
+ var TURN_ERROR_MARKER = "[Turn error] ", TURN_ERROR_DETAILS_MARKER = `
71
+
72
+ [Error details] `;
73
+ function formatTurnErrorRow(message, details) {
74
+ return `${TURN_ERROR_MARKER}${message}${details ? `${TURN_ERROR_DETAILS_MARKER}${details}` : ""}`;
75
+ }
76
+ function parseTurnErrorRow(text) {
77
+ if (!text.startsWith(TURN_ERROR_MARKER)) return null;
78
+ let body = text.slice(TURN_ERROR_MARKER.length), at = body.lastIndexOf(TURN_ERROR_DETAILS_MARKER);
79
+ return at < 0 ? { message: body } : { message: body.slice(0, at), details: body.slice(at + TURN_ERROR_DETAILS_MARKER.length) };
80
+ }
33
81
  function parseTurnErrorMarker(text) {
34
- return text.startsWith(TURN_ERROR_MARKER) ? text.slice(TURN_ERROR_MARKER.length) : null;
82
+ return parseTurnErrorRow(text)?.message ?? null;
83
+ }
84
+ var RUNTIME_NOTICE_PREFIXES = [
85
+ "[System]",
86
+ "[System notice:",
87
+ "[Provider unavailable (",
88
+ "[Provider error (",
89
+ "[Turn error (",
90
+ "[Continue working autonomously",
91
+ "[You have responded ",
92
+ "Context is about to be compacted."
93
+ ];
94
+ function isRuntimeNotice(text) {
95
+ return RUNTIME_NOTICE_PREFIXES.some((prefix) => text.startsWith(prefix));
96
+ }
97
+ function isNoticeCategory(category) {
98
+ return category === "owner_command" || category === "runtime" || category === "status";
99
+ }
100
+ function providerContextCategory(addedBy) {
101
+ return `provider_context | from=${addedBy.replace(/[\]|\n]/g, " ")}`;
102
+ }
103
+ function classifyInjectedText(text) {
104
+ let ownerCommand = parseOwnerCommandRow(text);
105
+ if (ownerCommand) return { content: ownerCommand.body, metadata: { category: "owner_command", ownerCommand: ownerCommand.header } };
106
+ let context = text.match(/^\[Context: ([^\]]+)\] ?([\s\S]*)$/);
107
+ if (context) {
108
+ let [name, ...fields] = context[1].split(" | "), field = (key) => fields.find((f) => f.startsWith(`${key}=`))?.slice(key.length + 1), content = context[2];
109
+ if (fields.includes("loop_inject=v2"))
110
+ return { content, metadata: { category: "injected", injectCategory: name, origin: field("origin") ?? "system:unknown" } };
111
+ if (name === "System" || name === "status") return { content, metadata: { category: "status" } };
112
+ if (name === "provider_context") {
113
+ let addedBy = field("from");
114
+ return { content, metadata: { category: "provider_context", ...addedBy ? { addedBy } : {} } };
115
+ }
116
+ return { content, metadata: { category: name } };
117
+ }
118
+ let loopSend = parseLoopSendStamp(text);
119
+ return loopSend ? { content: loopSend.body, metadata: { category: "loop", fromLoop: loopSend.fromLoop } } : isRuntimeNotice(text) ? { content: text, metadata: { category: "runtime" } } : null;
35
120
  }
36
121
  function extractImageUrl(content) {
37
122
  let match = content.match(/\[image: ([^\s]+) \(/);
@@ -40,8 +125,22 @@ function extractImageUrl(content) {
40
125
  function collectImageUrls(blocks) {
41
126
  return blocks.filter((b) => b.type === "image_url" && b.image_url?.url).map((b) => b.image_url.url);
42
127
  }
128
+ function toolResultAttachments(blocks, index) {
129
+ let out = [];
130
+ for (let i = index + 1; i < blocks.length; i++) {
131
+ let b = blocks[i];
132
+ if (b.type === "tool_result") break;
133
+ isFileRefBlock(b) && out.push(displayAttachment(b.file_ref));
134
+ }
135
+ return out;
136
+ }
137
+ function withToolAttachments(meta, attachments) {
138
+ if (attachments.length === 0) return meta;
139
+ let next = { ...meta, attachments };
140
+ return attachments.some((a) => a.deleted && a.kind === "image") && delete next.imageUrl, next;
141
+ }
43
142
  function detectTriggerType(text) {
44
- return text.startsWith("The user has edited the document.") ? "document_edit" : text.startsWith("You received a message from agent") ? "message_received" : text.startsWith("A scheduled timer has fired") ? "schedule" : text.startsWith("[Inbox notification]") ? "inbox_notification" : text === "Go." ? "autonomous_start" : text === "The user has manually triggered you. Review the document and respond." ? "manual_invoke" : text.startsWith("[Continue working autonomously") ? "autonomous_continue" : text.startsWith("A file has been ") ? "file_change" : text.startsWith("An outbound message was sent") ? "outbox" : text.startsWith("A tool call was intercepted") ? "tool_call" : text.startsWith("A task has completed") ? "task_complete" : null;
143
+ return text.startsWith("The user has edited the document.") ? "document_edit" : text.startsWith("You received a message from agent") ? "message_received" : text.startsWith("A scheduled timer has fired") ? "timer" : text.startsWith("[Inbox notification]") ? "inbox" : text === "Go." ? "autonomous_start" : text === "The user has manually triggered you. Review the document and respond." ? "manual_invoke" : text.startsWith("Agent started. Review your mind") ? "startup" : text.startsWith("A batch of ") && text.includes(" events fired: ") ? "batch" : text.startsWith("A file has been ") ? "file_change" : text.startsWith("An outbound message was sent") ? "outbox" : text.startsWith("A tool call has been intercepted") || text.startsWith("A tool call was intercepted") ? "tool_call" : text.startsWith("A task has been created.") ? "task_create" : text.startsWith("A task has completed") ? "task_complete" : text.startsWith("A log entry has been recorded.") ? "log_entry" : text.startsWith("An LLM call completed.") ? "llm_call" : text.startsWith("You have been triggered. Review the current state") ? "unknown" : null;
45
144
  }
46
145
  function summarizeReasoning(details) {
47
146
  return !Array.isArray(details) || details.length === 0 ? { preserved: !1, encrypted: !1 } : { preserved: !0, encrypted: details.some((d) => d?.type === "reasoning.encrypted") };
@@ -51,7 +150,7 @@ function parseLoopToDisplay(entries) {
51
150
  for (let entry of entries) {
52
151
  let blocks = entry.content_json, timestamp = entry.created_at || 0;
53
152
  if (entry.role === "user") {
54
- let imagePreviewUrls = collectImageUrls(blocks);
153
+ let imagePreviewUrls = collectImageUrls(blocks), attachments = blocks.some((b) => b.type === "tool_result") ? [] : attachmentsOf(blocks), firstEntryOfRow = displayEntries.length;
55
154
  for (let bi = 0; bi < blocks.length; bi++) {
56
155
  let block = blocks[bi];
57
156
  if (block.type === "text" && block.text) {
@@ -67,51 +166,39 @@ function parseLoopToDisplay(entries) {
67
166
  });
68
167
  continue;
69
168
  }
70
- let turnError = parseTurnErrorMarker(block.text);
169
+ let turnError = parseTurnErrorRow(block.text);
71
170
  if (turnError !== null) {
72
171
  displayEntries.push({
73
172
  id: `loop-${entry.seq}-${bi}`,
74
173
  type: "error",
75
- content: turnError,
174
+ content: turnError.message,
76
175
  timestamp,
77
- metadata: { seq: entry.seq }
176
+ metadata: turnError.details ? { seq: entry.seq, details: turnError.details } : { seq: entry.seq }
78
177
  });
79
178
  continue;
80
179
  }
81
- let contextCategory = isContextEntry(block.text);
82
- if (contextCategory) {
83
- let content = block.text.replace(/^\[Context: [^\]]+\] /, "");
180
+ let injected = classifyInjectedText(block.text);
181
+ if (injected) {
84
182
  displayEntries.push({
85
183
  id: `loop-${entry.seq}-${bi}`,
86
184
  type: "context",
87
- content,
185
+ content: injected.content,
88
186
  timestamp,
89
- metadata: { seq: entry.seq, category: contextCategory }
187
+ metadata: { seq: entry.seq, ...injected.metadata }
90
188
  });
91
189
  continue;
92
190
  }
93
- let loopSend = parseLoopSendStamp(block.text);
94
- if (loopSend) {
95
- displayEntries.push({
96
- id: `loop-${entry.seq}-${bi}`,
97
- type: "context",
98
- content: loopSend.body,
99
- timestamp,
100
- metadata: { seq: entry.seq, category: "loop", fromLoop: loopSend.fromLoop }
101
- });
102
- continue;
103
- }
104
- let triggerType = detectTriggerType(block.text);
105
- if (triggerType === "autonomous_continue") continue;
191
+ let triggerType = detectTriggerType(block.text), legacy = triggerType ? { text: block.text, attachments: [] } : splitLegacyUploads(block.text), shown = [...attachments, ...legacy.attachments];
106
192
  displayEntries.push({
107
193
  id: `loop-${entry.seq}-${bi}`,
108
194
  type: triggerType && triggerType !== "manual_invoke" ? "trigger" : "user",
109
- content: block.text,
195
+ content: legacy.text,
110
196
  timestamp,
111
197
  metadata: {
112
198
  seq: entry.seq,
113
199
  ...triggerType ? { triggerType } : {},
114
- ...!triggerType && imagePreviewUrls.length > 0 ? { imagePreviewUrls } : {}
200
+ ...!triggerType && imagePreviewUrls.length > 0 ? { imagePreviewUrls } : {},
201
+ ...!triggerType && shown.length > 0 ? { attachments: shown } : {}
115
202
  }
116
203
  });
117
204
  } else if (block.type === "tool_result") {
@@ -121,16 +208,17 @@ function parseLoopToDisplay(entries) {
121
208
  type: "tool_result",
122
209
  content: block.content ?? "",
123
210
  timestamp,
124
- metadata: {
211
+ metadata: withToolAttachments({
125
212
  seq: entry.seq,
126
213
  tool_use_id: block.tool_use_id,
127
214
  name: toolName,
128
215
  isError: block.is_error,
129
216
  ...imageUrl ? { imageUrl } : {}
130
- }
217
+ }, toolResultAttachments(blocks, bi))
131
218
  });
132
219
  }
133
220
  }
221
+ pushAttachmentOnlyEntry(displayEntries, firstEntryOfRow, entry, attachments, imagePreviewUrls);
134
222
  } else if (entry.role === "assistant") {
135
223
  let firstEntryOfRow = displayEntries.length, reasoningTokens = typeof entry.tokens?.reasoning == "number" ? entry.tokens.reasoning : void 0;
136
224
  for (let bi = 0; bi < blocks.length; bi++) {
@@ -141,7 +229,7 @@ function parseLoopToDisplay(entries) {
141
229
  type: "text",
142
230
  content: block.text,
143
231
  timestamp,
144
- metadata: { seq: entry.seq, model: entry.model }
232
+ metadata: { seq: entry.seq, model: entry.model, ...block.interrupted ? { interrupted: !0 } : {} }
145
233
  });
146
234
  else if (block.type === "tool_use")
147
235
  block.id && block.name && toolIdToName.set(block.id, block.name), displayEntries.push({
@@ -165,6 +253,7 @@ function parseLoopToDisplay(entries) {
165
253
  timestamp,
166
254
  metadata: {
167
255
  seq: entry.seq,
256
+ ...block.interrupted ? { interrupted: !0 } : {},
168
257
  model: entry.model,
169
258
  ...reasoningTokens !== void 0 ? { reasoningTokens } : {},
170
259
  ...preserved ? { preservedReasoning: !0 } : {},
@@ -178,6 +267,15 @@ function parseLoopToDisplay(entries) {
178
267
  }
179
268
  return displayEntries;
180
269
  }
270
+ function pushAttachmentOnlyEntry(displayEntries, firstEntryOfRow, entry, attachments, imagePreviewUrls) {
271
+ attachments.length === 0 || displayEntries.length > firstEntryOfRow || displayEntries.push({
272
+ id: `loop-${entry.seq}-attachments`,
273
+ type: "user",
274
+ content: "",
275
+ timestamp: entry.created_at || 0,
276
+ metadata: { seq: entry.seq, attachments, ...imagePreviewUrls.length > 0 ? { imagePreviewUrls } : {} }
277
+ });
278
+ }
181
279
  function stampRowTokens(displayEntries, firstEntryOfRow, tokens) {
182
280
  if (!tokens || displayEntries.length <= firstEntryOfRow) return;
183
281
  let last = displayEntries[displayEntries.length - 1];
@@ -208,7 +306,7 @@ function parseLoopWithToolPairs(entries) {
208
306
  for (let entry of entries) {
209
307
  let blocks = entry.content_json, timestamp = entry.created_at || 0;
210
308
  if (entry.role === "user") {
211
- let imagePreviewUrls = collectImageUrls(blocks);
309
+ let imagePreviewUrls = collectImageUrls(blocks), attachments = blocks.some((b) => b.type === "tool_result") ? [] : attachmentsOf(blocks), firstEntryOfRow = displayEntries.length;
212
310
  for (let bi = 0; bi < blocks.length; bi++) {
213
311
  let block = blocks[bi];
214
312
  if (block.type === "text" && block.text) {
@@ -224,74 +322,63 @@ function parseLoopWithToolPairs(entries) {
224
322
  });
225
323
  continue;
226
324
  }
227
- let turnError = parseTurnErrorMarker(block.text);
325
+ let turnError = parseTurnErrorRow(block.text);
228
326
  if (turnError !== null) {
229
327
  displayEntries.push({
230
328
  id: `loop-${entry.seq}-${bi}`,
231
329
  type: "error",
232
- content: turnError,
330
+ content: turnError.message,
233
331
  timestamp,
234
- metadata: { seq: entry.seq }
332
+ metadata: turnError.details ? { seq: entry.seq, details: turnError.details } : { seq: entry.seq }
235
333
  });
236
334
  continue;
237
335
  }
238
- let contextCategory = isContextEntry(block.text);
239
- if (contextCategory) {
240
- let content = block.text.replace(/^\[Context: [^\]]+\] /, "");
336
+ let injected = classifyInjectedText(block.text);
337
+ if (injected) {
241
338
  displayEntries.push({
242
339
  id: `loop-${entry.seq}-${bi}`,
243
340
  type: "context",
244
- content,
341
+ content: injected.content,
245
342
  timestamp,
246
- metadata: { seq: entry.seq, category: contextCategory }
343
+ metadata: { seq: entry.seq, ...injected.metadata }
247
344
  });
248
345
  continue;
249
346
  }
250
- let loopSend = parseLoopSendStamp(block.text);
251
- if (loopSend) {
252
- displayEntries.push({
253
- id: `loop-${entry.seq}-${bi}`,
254
- type: "context",
255
- content: loopSend.body,
256
- timestamp,
257
- metadata: { seq: entry.seq, category: "loop", fromLoop: loopSend.fromLoop }
258
- });
259
- continue;
260
- }
261
- let triggerType = detectTriggerType(block.text);
262
- if (triggerType === "autonomous_continue") continue;
347
+ let triggerType = detectTriggerType(block.text), legacy = triggerType ? { text: block.text, attachments: [] } : splitLegacyUploads(block.text), shown = [...attachments, ...legacy.attachments];
263
348
  displayEntries.push({
264
349
  id: `loop-${entry.seq}-${bi}`,
265
350
  type: triggerType && triggerType !== "manual_invoke" ? "trigger" : "user",
266
- content: block.text,
351
+ content: legacy.text,
267
352
  timestamp,
268
353
  metadata: {
269
354
  seq: entry.seq,
270
355
  ...triggerType ? { triggerType } : {},
271
- ...!triggerType && imagePreviewUrls.length > 0 ? { imagePreviewUrls } : {}
356
+ ...!triggerType && imagePreviewUrls.length > 0 ? { imagePreviewUrls } : {},
357
+ ...!triggerType && shown.length > 0 ? { attachments: shown } : {}
272
358
  }
273
359
  });
274
360
  } else if (block.type === "tool_result" && block.tool_use_id) {
275
- let pending = pendingToolCalls.get(block.tool_use_id), imageUrl = extractImageUrl(block.content ?? "");
276
- pending && (pending.entry.metadata = {
361
+ let pending = pendingToolCalls.get(block.tool_use_id), imageUrl = extractImageUrl(block.content ?? ""), resultAttachments = toolResultAttachments(blocks, bi);
362
+ pending && (pending.entry.metadata = withToolAttachments({
277
363
  ...pending.entry.metadata,
278
364
  result: block.content,
279
365
  isError: block.is_error,
280
366
  ...imageUrl ? { imageUrl } : {}
281
- }, pendingToolCalls.delete(block.tool_use_id)), displayEntries.push({
367
+ }, resultAttachments), pendingToolCalls.delete(block.tool_use_id)), displayEntries.push({
282
368
  id: `loop-${entry.seq}-${bi}`,
283
369
  type: "tool_result",
284
370
  content: block.content ?? "",
285
371
  timestamp,
286
- metadata: {
372
+ metadata: withToolAttachments({
287
373
  seq: entry.seq,
288
374
  tool_use_id: block.tool_use_id,
289
375
  isError: block.is_error,
290
376
  ...imageUrl ? { imageUrl } : {}
291
- }
377
+ }, resultAttachments)
292
378
  });
293
379
  }
294
380
  }
381
+ pushAttachmentOnlyEntry(displayEntries, firstEntryOfRow, entry, attachments, imagePreviewUrls);
295
382
  } else if (entry.role === "assistant") {
296
383
  let firstEntryOfRow = displayEntries.length, reasoningTokens = typeof entry.tokens?.reasoning == "number" ? entry.tokens.reasoning : void 0;
297
384
  for (let bi = 0; bi < blocks.length; bi++) {
@@ -302,7 +389,7 @@ function parseLoopWithToolPairs(entries) {
302
389
  type: "text",
303
390
  content: block.text,
304
391
  timestamp,
305
- metadata: { seq: entry.seq, model: entry.model }
392
+ metadata: { seq: entry.seq, model: entry.model, ...block.interrupted ? { interrupted: !0 } : {} }
306
393
  });
307
394
  else if (block.type === "tool_use" && block.id) {
308
395
  let toolEntry = {
@@ -327,6 +414,7 @@ function parseLoopWithToolPairs(entries) {
327
414
  timestamp,
328
415
  metadata: {
329
416
  seq: entry.seq,
417
+ ...block.interrupted ? { interrupted: !0 } : {},
330
418
  model: entry.model,
331
419
  ...reasoningTokens !== void 0 ? { reasoningTokens } : {},
332
420
  ...preserved ? { preservedReasoning: !0 } : {},
@@ -360,7 +448,10 @@ function loopToLLMMessages(entries) {
360
448
  }
361
449
 
362
450
  export {
363
- TURN_ERROR_MARKER,
451
+ formatOwnerCommandRow,
452
+ owner_command_row_exports,
453
+ formatTurnErrorRow,
454
+ providerContextCategory,
364
455
  parseLoopToDisplay,
365
456
  loop_parser_exports
366
457
  };