@agentdocumentformat/cli 0.7.2

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 (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -0
  3. package/dist/adf.mjs +162 -0
  4. package/dist/chunks/APEv2Parser-2CNNHMXV.mjs +22 -0
  5. package/dist/chunks/AiffParser-7BR4RL6G.mjs +162 -0
  6. package/dist/chunks/App-L5L37JI5.mjs +16747 -0
  7. package/dist/chunks/AsfParser-VVRSLFOM.mjs +538 -0
  8. package/dist/chunks/DsdiffParser-CMD4AX7A.mjs +156 -0
  9. package/dist/chunks/DsfParser-UOGZDS2M.mjs +94 -0
  10. package/dist/chunks/FlacParser-HB3T3CD4.mjs +23 -0
  11. package/dist/chunks/MP4Parser-66HBRUSX.mjs +973 -0
  12. package/dist/chunks/MatroskaParser-J3HUIMEW.mjs +579 -0
  13. package/dist/chunks/MpegParser-YW6LIUEW.mjs +442 -0
  14. package/dist/chunks/MusepackParser-PAUSXP7D.mjs +252 -0
  15. package/dist/chunks/OggParser-NUBV3GWC.mjs +359 -0
  16. package/dist/chunks/WavPackParser-WQAGT7TC.mjs +171 -0
  17. package/dist/chunks/WaveParser-EWLQVDX4.mjs +238 -0
  18. package/dist/chunks/adf-schema-JRU2BTOG.mjs +62 -0
  19. package/dist/chunks/build-QF5W473T.mjs +60 -0
  20. package/dist/chunks/chatgpt-subscription-BQGWYZXE.mjs +23 -0
  21. package/dist/chunks/chunk-2DIECGFL.mjs +6 -0
  22. package/dist/chunks/chunk-2NAP2ZF7.mjs +60 -0
  23. package/dist/chunks/chunk-3AT7IIP7.mjs +25696 -0
  24. package/dist/chunks/chunk-3GNIDM53.mjs +35 -0
  25. package/dist/chunks/chunk-3M4ZPOA3.mjs +1477 -0
  26. package/dist/chunks/chunk-4MQPTCXY.mjs +510 -0
  27. package/dist/chunks/chunk-5PO5PKRV.mjs +366 -0
  28. package/dist/chunks/chunk-5QU5VY7N.mjs +52 -0
  29. package/dist/chunks/chunk-5W7KES6P.mjs +436 -0
  30. package/dist/chunks/chunk-62NE4LG4.mjs +61 -0
  31. package/dist/chunks/chunk-64OKE4X3.mjs +45 -0
  32. package/dist/chunks/chunk-6GJ4QHRI.mjs +1278 -0
  33. package/dist/chunks/chunk-6VQEXLE2.mjs +144 -0
  34. package/dist/chunks/chunk-6XUV6EK6.mjs +41 -0
  35. package/dist/chunks/chunk-776TSXEP.mjs +43 -0
  36. package/dist/chunks/chunk-7CV2SA3H.mjs +285 -0
  37. package/dist/chunks/chunk-7MTRVW2U.mjs +3103 -0
  38. package/dist/chunks/chunk-7N2R2VCG.mjs +1434 -0
  39. package/dist/chunks/chunk-7T2YMTWL.mjs +374 -0
  40. package/dist/chunks/chunk-7XYNI52E.mjs +149 -0
  41. package/dist/chunks/chunk-APHX6HSV.mjs +7731 -0
  42. package/dist/chunks/chunk-APRU6PHC.mjs +40 -0
  43. package/dist/chunks/chunk-AUYKRQPJ.mjs +499 -0
  44. package/dist/chunks/chunk-DXWDD5XJ.mjs +136 -0
  45. package/dist/chunks/chunk-EWL5FG4I.mjs +39 -0
  46. package/dist/chunks/chunk-EYX2YLJW.mjs +117 -0
  47. package/dist/chunks/chunk-F5ELW46V.mjs +27 -0
  48. package/dist/chunks/chunk-G426FACA.mjs +49 -0
  49. package/dist/chunks/chunk-GEKSJHIV.mjs +2472 -0
  50. package/dist/chunks/chunk-HBUENVQL.mjs +570 -0
  51. package/dist/chunks/chunk-HPVFJYXR.mjs +112 -0
  52. package/dist/chunks/chunk-HWLWPXQ7.mjs +721 -0
  53. package/dist/chunks/chunk-I2HJYHFT.mjs +665 -0
  54. package/dist/chunks/chunk-I3UYSITV.mjs +68 -0
  55. package/dist/chunks/chunk-IC4JDZCI.mjs +3864 -0
  56. package/dist/chunks/chunk-IHDDCZBS.mjs +112 -0
  57. package/dist/chunks/chunk-IIGMZHQQ.mjs +10416 -0
  58. package/dist/chunks/chunk-KWFOS5WC.mjs +41 -0
  59. package/dist/chunks/chunk-LAZIXV2F.mjs +5290 -0
  60. package/dist/chunks/chunk-LFMB4PAA.mjs +10814 -0
  61. package/dist/chunks/chunk-M2RX3S2T.mjs +49 -0
  62. package/dist/chunks/chunk-M3WPIJYM.mjs +65 -0
  63. package/dist/chunks/chunk-NBTUWMGP.mjs +263 -0
  64. package/dist/chunks/chunk-NGK6PVSF.mjs +2676 -0
  65. package/dist/chunks/chunk-NZ7JTHEO.mjs +85 -0
  66. package/dist/chunks/chunk-OQN33RGQ.mjs +52 -0
  67. package/dist/chunks/chunk-RIX34QHC.mjs +2935 -0
  68. package/dist/chunks/chunk-SGUTYISF.mjs +16 -0
  69. package/dist/chunks/chunk-SLJ5L7PY.mjs +1473 -0
  70. package/dist/chunks/chunk-SLUKGXKH.mjs +68 -0
  71. package/dist/chunks/chunk-TMT32MXT.mjs +419 -0
  72. package/dist/chunks/chunk-UYY5M2PB.mjs +151 -0
  73. package/dist/chunks/chunk-VAUOM3IN.mjs +298 -0
  74. package/dist/chunks/chunk-VMHTYDH4.mjs +172 -0
  75. package/dist/chunks/chunk-VZS54AA5.mjs +200 -0
  76. package/dist/chunks/chunk-WFQUVXML.mjs +295 -0
  77. package/dist/chunks/chunk-X34PDRUH.mjs +809 -0
  78. package/dist/chunks/chunk-XNPZBLYL.mjs +33 -0
  79. package/dist/chunks/chunk-XX7OSWTO.mjs +157 -0
  80. package/dist/chunks/chunk-XYTWGHFS.mjs +600 -0
  81. package/dist/chunks/chunk-XYV3VCIX.mjs +336 -0
  82. package/dist/chunks/chunk-Y5ZLKFLE.mjs +1469 -0
  83. package/dist/chunks/chunk-ZJKXHM4Q.mjs +230 -0
  84. package/dist/chunks/cli-TCMBNZF6.mjs +1030 -0
  85. package/dist/chunks/commands-DTEKM4ZL.mjs +20 -0
  86. package/dist/chunks/daemon-ZC3FZ2P4.mjs +112449 -0
  87. package/dist/chunks/daemon-control-WDX7PMTC.mjs +300 -0
  88. package/dist/chunks/daemon-token-WRSULP7G.mjs +23 -0
  89. package/dist/chunks/devtools-H7CI2ZVG.mjs +85 -0
  90. package/dist/chunks/discord-IWDQJA7A.mjs +70588 -0
  91. package/dist/chunks/dist-C57KYFS2.mjs +4952 -0
  92. package/dist/chunks/dist-I3XBAGDL.mjs +11 -0
  93. package/dist/chunks/email-V4Q4VJON.mjs +58679 -0
  94. package/dist/chunks/environment-NX277MQG.mjs +15 -0
  95. package/dist/chunks/grok-subscription-4PYX7TBF.mjs +19 -0
  96. package/dist/chunks/layout-EPJQNFAI.mjs +22 -0
  97. package/dist/chunks/lib-N7FCZWKH.mjs +4038 -0
  98. package/dist/chunks/open-OTQDGDH5.mjs +36 -0
  99. package/dist/chunks/parser-JVY2PWSM.mjs +19 -0
  100. package/dist/chunks/pipeline-executor-BHBSJX2K.mjs +19 -0
  101. package/dist/chunks/react-IUIDQ5LX.mjs +11 -0
  102. package/dist/chunks/screen-54BUTYCW.mjs +27 -0
  103. package/dist/chunks/slack-3L5QTDZX.mjs +8113 -0
  104. package/dist/chunks/store-WR7TZJZS.mjs +32 -0
  105. package/dist/chunks/telegram-5ISVFBV3.mjs +14918 -0
  106. package/dist/chunks/terminal-O5WO7C5U.mjs +48 -0
  107. package/dist/chunks/theme-NORU4J74.mjs +20 -0
  108. package/dist/chunks/themes-F2FKU7CP.mjs +23 -0
  109. package/dist/chunks/token-6G3HCMNX.mjs +54 -0
  110. package/dist/chunks/token-util-UXYSDQIW.mjs +12 -0
  111. package/dist/chunks/tui-ODVYUIMT.mjs +197 -0
  112. package/dist/chunks/welcome-XHXFV7SH.mjs +32 -0
  113. package/dist/chunks/whatsapp-XSAMNGPJ.mjs +85412 -0
  114. package/dist/chunks/xterm-headless-YF53XWXE.mjs +3353 -0
  115. package/package.json +53 -0
  116. package/resources/wasm/coreutils.LICENSE +18 -0
  117. package/resources/wasm/coreutils.wasm +0 -0
@@ -0,0 +1,366 @@
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
+ import {
8
+ __export
9
+ } from "./chunk-M2RX3S2T.mjs";
10
+
11
+ // src/shared/utils/loop-parser.ts
12
+ var loop_parser_exports = {};
13
+ __export(loop_parser_exports, {
14
+ TURN_ERROR_MARKER: () => TURN_ERROR_MARKER,
15
+ findToolResult: () => findToolResult,
16
+ getLoopSummary: () => getLoopSummary,
17
+ isContextEntry: () => isContextEntry,
18
+ loopToLLMMessages: () => loopToLLMMessages,
19
+ parseLoopSendStamp: () => parseLoopSendStamp,
20
+ parseLoopToDisplay: () => parseLoopToDisplay,
21
+ parseLoopWithToolPairs: () => parseLoopWithToolPairs,
22
+ parseTurnErrorMarker: () => parseTurnErrorMarker
23
+ });
24
+ function isContextEntry(text) {
25
+ let match = text.match(/^\[Context: ([^\]]+)\]/);
26
+ return match ? match[1] : null;
27
+ }
28
+ function parseLoopSendStamp(text) {
29
+ let match = text.match(/^\[from loop:([a-z0-9][a-z0-9_-]{0,31})\] ([\s\S]*)$/);
30
+ return match ? { fromLoop: match[1], body: match[2] } : null;
31
+ }
32
+ var TURN_ERROR_MARKER = "[Turn error] ";
33
+ function parseTurnErrorMarker(text) {
34
+ return text.startsWith(TURN_ERROR_MARKER) ? text.slice(TURN_ERROR_MARKER.length) : null;
35
+ }
36
+ function extractImageUrl(content) {
37
+ let match = content.match(/\[image: ([^\s]+) \(/);
38
+ return match ? `adf-file://${match[1]}` : null;
39
+ }
40
+ function collectImageUrls(blocks) {
41
+ return blocks.filter((b) => b.type === "image_url" && b.image_url?.url).map((b) => b.image_url.url);
42
+ }
43
+ 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;
45
+ }
46
+ function summarizeReasoning(details) {
47
+ return !Array.isArray(details) || details.length === 0 ? { preserved: !1, encrypted: !1 } : { preserved: !0, encrypted: details.some((d) => d?.type === "reasoning.encrypted") };
48
+ }
49
+ function parseLoopToDisplay(entries) {
50
+ let displayEntries = [], toolIdToName = /* @__PURE__ */ new Map();
51
+ for (let entry of entries) {
52
+ let blocks = entry.content_json, timestamp = entry.created_at || 0;
53
+ if (entry.role === "user") {
54
+ let imagePreviewUrls = collectImageUrls(blocks);
55
+ for (let bi = 0; bi < blocks.length; bi++) {
56
+ let block = blocks[bi];
57
+ if (block.type === "text" && block.text) {
58
+ if (block.text.startsWith("[Loop Compacted")) {
59
+ let audited = block.text.startsWith("[Loop Compacted, audited]"), content = block.text.replace("[Loop Compacted, audited] ", "").replace("[Loop Compacted] ", "");
60
+ displayEntries.push({
61
+ id: `loop-${entry.seq}-${bi}`,
62
+ type: "compaction",
63
+ content,
64
+ timestamp,
65
+ // model/tokens carry the compaction LLM call's usage
66
+ metadata: { seq: entry.seq, audited, model: entry.model, tokens: entry.tokens }
67
+ });
68
+ continue;
69
+ }
70
+ let turnError = parseTurnErrorMarker(block.text);
71
+ if (turnError !== null) {
72
+ displayEntries.push({
73
+ id: `loop-${entry.seq}-${bi}`,
74
+ type: "error",
75
+ content: turnError,
76
+ timestamp,
77
+ metadata: { seq: entry.seq }
78
+ });
79
+ continue;
80
+ }
81
+ let contextCategory = isContextEntry(block.text);
82
+ if (contextCategory) {
83
+ let content = block.text.replace(/^\[Context: [^\]]+\] /, "");
84
+ displayEntries.push({
85
+ id: `loop-${entry.seq}-${bi}`,
86
+ type: "context",
87
+ content,
88
+ timestamp,
89
+ metadata: { seq: entry.seq, category: contextCategory }
90
+ });
91
+ continue;
92
+ }
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;
106
+ displayEntries.push({
107
+ id: `loop-${entry.seq}-${bi}`,
108
+ type: triggerType && triggerType !== "manual_invoke" ? "trigger" : "user",
109
+ content: block.text,
110
+ timestamp,
111
+ metadata: {
112
+ seq: entry.seq,
113
+ ...triggerType ? { triggerType } : {},
114
+ ...!triggerType && imagePreviewUrls.length > 0 ? { imagePreviewUrls } : {}
115
+ }
116
+ });
117
+ } else if (block.type === "tool_result") {
118
+ let toolName = toolIdToName.get(block.tool_use_id ?? "") ?? "unknown", imageUrl = extractImageUrl(block.content ?? "");
119
+ displayEntries.push({
120
+ id: `loop-${entry.seq}-${bi}`,
121
+ type: "tool_result",
122
+ content: block.content ?? "",
123
+ timestamp,
124
+ metadata: {
125
+ seq: entry.seq,
126
+ tool_use_id: block.tool_use_id,
127
+ name: toolName,
128
+ isError: block.is_error,
129
+ ...imageUrl ? { imageUrl } : {}
130
+ }
131
+ });
132
+ }
133
+ }
134
+ } else if (entry.role === "assistant") {
135
+ let firstEntryOfRow = displayEntries.length, reasoningTokens = typeof entry.tokens?.reasoning == "number" ? entry.tokens.reasoning : void 0;
136
+ for (let bi = 0; bi < blocks.length; bi++) {
137
+ let block = blocks[bi];
138
+ if (block.type === "text" && block.text && block.text.trim())
139
+ displayEntries.push({
140
+ id: `loop-${entry.seq}-${bi}`,
141
+ type: "text",
142
+ content: block.text,
143
+ timestamp,
144
+ metadata: { seq: entry.seq, model: entry.model }
145
+ });
146
+ else if (block.type === "tool_use")
147
+ block.id && block.name && toolIdToName.set(block.id, block.name), displayEntries.push({
148
+ id: `loop-${entry.seq}-${bi}`,
149
+ type: "tool_call",
150
+ content: formatToolCall(block),
151
+ timestamp,
152
+ metadata: {
153
+ seq: entry.seq,
154
+ tool_id: block.id,
155
+ name: block.name,
156
+ input: block.input
157
+ }
158
+ });
159
+ else if (block.type === "thinking" && (block.thinking || Array.isArray(block.reasoning_details) && block.reasoning_details.length > 0)) {
160
+ let { preserved, encrypted } = summarizeReasoning(block.reasoning_details);
161
+ displayEntries.push({
162
+ id: `loop-${entry.seq}-${bi}`,
163
+ type: "thinking",
164
+ content: block.thinking ?? "",
165
+ timestamp,
166
+ metadata: {
167
+ seq: entry.seq,
168
+ model: entry.model,
169
+ ...reasoningTokens !== void 0 ? { reasoningTokens } : {},
170
+ ...preserved ? { preservedReasoning: !0 } : {},
171
+ ...encrypted ? { encryptedReasoning: !0 } : {}
172
+ }
173
+ });
174
+ }
175
+ }
176
+ stampRowTokens(displayEntries, firstEntryOfRow, entry.tokens);
177
+ }
178
+ }
179
+ return displayEntries;
180
+ }
181
+ function stampRowTokens(displayEntries, firstEntryOfRow, tokens) {
182
+ if (!tokens || displayEntries.length <= firstEntryOfRow) return;
183
+ let last = displayEntries[displayEntries.length - 1];
184
+ last.metadata = { ...last.metadata, tokens };
185
+ }
186
+ function formatToolCall(block) {
187
+ let name = block.name ?? "unknown", input = block.input;
188
+ if (!input || typeof input != "object")
189
+ return `${name}()`;
190
+ try {
191
+ let inputStr = JSON.stringify(input, null, 2);
192
+ return inputStr.length > 200 ? `${name}(${inputStr.substring(0, 200)}...)` : `${name}(${inputStr})`;
193
+ } catch {
194
+ return `${name}(...)`;
195
+ }
196
+ }
197
+ function findToolResult(entries, toolUseId) {
198
+ for (let entry of entries)
199
+ if (entry.role === "user") {
200
+ for (let block of entry.content_json)
201
+ if (block.type === "tool_result" && block.tool_use_id === toolUseId)
202
+ return block;
203
+ }
204
+ return null;
205
+ }
206
+ function parseLoopWithToolPairs(entries) {
207
+ let displayEntries = [], pendingToolCalls = /* @__PURE__ */ new Map();
208
+ for (let entry of entries) {
209
+ let blocks = entry.content_json, timestamp = entry.created_at || 0;
210
+ if (entry.role === "user") {
211
+ let imagePreviewUrls = collectImageUrls(blocks);
212
+ for (let bi = 0; bi < blocks.length; bi++) {
213
+ let block = blocks[bi];
214
+ if (block.type === "text" && block.text) {
215
+ if (block.text.startsWith("[Loop Compacted")) {
216
+ let audited = block.text.startsWith("[Loop Compacted, audited]"), content = block.text.replace("[Loop Compacted, audited] ", "").replace("[Loop Compacted] ", "");
217
+ displayEntries.push({
218
+ id: `loop-${entry.seq}-${bi}`,
219
+ type: "compaction",
220
+ content,
221
+ timestamp,
222
+ // model/tokens carry the compaction LLM call's usage
223
+ metadata: { seq: entry.seq, audited, model: entry.model, tokens: entry.tokens }
224
+ });
225
+ continue;
226
+ }
227
+ let turnError = parseTurnErrorMarker(block.text);
228
+ if (turnError !== null) {
229
+ displayEntries.push({
230
+ id: `loop-${entry.seq}-${bi}`,
231
+ type: "error",
232
+ content: turnError,
233
+ timestamp,
234
+ metadata: { seq: entry.seq }
235
+ });
236
+ continue;
237
+ }
238
+ let contextCategory = isContextEntry(block.text);
239
+ if (contextCategory) {
240
+ let content = block.text.replace(/^\[Context: [^\]]+\] /, "");
241
+ displayEntries.push({
242
+ id: `loop-${entry.seq}-${bi}`,
243
+ type: "context",
244
+ content,
245
+ timestamp,
246
+ metadata: { seq: entry.seq, category: contextCategory }
247
+ });
248
+ continue;
249
+ }
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;
263
+ displayEntries.push({
264
+ id: `loop-${entry.seq}-${bi}`,
265
+ type: triggerType && triggerType !== "manual_invoke" ? "trigger" : "user",
266
+ content: block.text,
267
+ timestamp,
268
+ metadata: {
269
+ seq: entry.seq,
270
+ ...triggerType ? { triggerType } : {},
271
+ ...!triggerType && imagePreviewUrls.length > 0 ? { imagePreviewUrls } : {}
272
+ }
273
+ });
274
+ } 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 = {
277
+ ...pending.entry.metadata,
278
+ result: block.content,
279
+ isError: block.is_error,
280
+ ...imageUrl ? { imageUrl } : {}
281
+ }, pendingToolCalls.delete(block.tool_use_id)), displayEntries.push({
282
+ id: `loop-${entry.seq}-${bi}`,
283
+ type: "tool_result",
284
+ content: block.content ?? "",
285
+ timestamp,
286
+ metadata: {
287
+ seq: entry.seq,
288
+ tool_use_id: block.tool_use_id,
289
+ isError: block.is_error,
290
+ ...imageUrl ? { imageUrl } : {}
291
+ }
292
+ });
293
+ }
294
+ }
295
+ } else if (entry.role === "assistant") {
296
+ let firstEntryOfRow = displayEntries.length, reasoningTokens = typeof entry.tokens?.reasoning == "number" ? entry.tokens.reasoning : void 0;
297
+ for (let bi = 0; bi < blocks.length; bi++) {
298
+ let block = blocks[bi];
299
+ if (block.type === "text" && block.text && block.text.trim())
300
+ displayEntries.push({
301
+ id: `loop-${entry.seq}-${bi}`,
302
+ type: "text",
303
+ content: block.text,
304
+ timestamp,
305
+ metadata: { seq: entry.seq, model: entry.model }
306
+ });
307
+ else if (block.type === "tool_use" && block.id) {
308
+ let toolEntry = {
309
+ id: `loop-${entry.seq}-${bi}`,
310
+ type: "tool_call",
311
+ content: formatToolCall(block),
312
+ timestamp,
313
+ metadata: {
314
+ seq: entry.seq,
315
+ tool_id: block.id,
316
+ name: block.name,
317
+ input: block.input
318
+ }
319
+ };
320
+ displayEntries.push(toolEntry), pendingToolCalls.set(block.id, { entry: toolEntry, seq: entry.seq });
321
+ } else if (block.type === "thinking" && (block.thinking || Array.isArray(block.reasoning_details) && block.reasoning_details.length > 0)) {
322
+ let { preserved, encrypted } = summarizeReasoning(block.reasoning_details);
323
+ displayEntries.push({
324
+ id: `loop-${entry.seq}-${bi}`,
325
+ type: "thinking",
326
+ content: block.thinking ?? "",
327
+ timestamp,
328
+ metadata: {
329
+ seq: entry.seq,
330
+ model: entry.model,
331
+ ...reasoningTokens !== void 0 ? { reasoningTokens } : {},
332
+ ...preserved ? { preservedReasoning: !0 } : {},
333
+ ...encrypted ? { encryptedReasoning: !0 } : {}
334
+ }
335
+ });
336
+ }
337
+ }
338
+ stampRowTokens(displayEntries, firstEntryOfRow, entry.tokens);
339
+ }
340
+ }
341
+ return displayEntries;
342
+ }
343
+ function getLoopSummary(entries) {
344
+ let userMessages = 0, assistantMessages = 0, toolCalls = 0, thinkingBlocks = 0;
345
+ for (let entry of entries)
346
+ entry.role === "user" ? entry.content_json.some((b) => b.type === "text") && userMessages++ : entry.role === "assistant" && (entry.content_json.some((b) => b.type === "text") && assistantMessages++, toolCalls += entry.content_json.filter((b) => b.type === "tool_use").length, thinkingBlocks += entry.content_json.filter((b) => b.type === "thinking").length);
347
+ return {
348
+ totalMessages: entries.length,
349
+ userMessages,
350
+ assistantMessages,
351
+ toolCalls,
352
+ thinkingBlocks
353
+ };
354
+ }
355
+ function loopToLLMMessages(entries) {
356
+ return entries.map((entry) => ({
357
+ role: entry.role,
358
+ content: entry.content_json
359
+ }));
360
+ }
361
+
362
+ export {
363
+ TURN_ERROR_MARKER,
364
+ parseLoopToDisplay,
365
+ loop_parser_exports
366
+ };
@@ -0,0 +1,52 @@
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/main/tui/app/prefs.ts
9
+ import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
10
+ import { homedir } from "node:os";
11
+ import { dirname, join } from "node:path";
12
+ var file = null, prefs = {};
13
+ function defaultPrefsPath(env = process.env, platform = process.platform) {
14
+ let override = env.ADF_TUI_PREFS;
15
+ if (override !== void 0) return override === "" || override === "off" ? null : override;
16
+ let base = platform === "darwin" ? join(homedir(), "Library", "Application Support") : platform === "win32" ? env.APPDATA ?? join(homedir(), "AppData", "Roaming") : env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
17
+ return join(base, "adf-studio", "tui-prefs.json");
18
+ }
19
+ function loadPrefs(path) {
20
+ if (file = path, prefs = {}, !path || !existsSync(path)) return prefs;
21
+ try {
22
+ let parsed = JSON.parse(readFileSync(path, "utf8"));
23
+ parsed && typeof parsed == "object" && !Array.isArray(parsed) && (prefs = parsed);
24
+ } catch {
25
+ }
26
+ return prefs;
27
+ }
28
+ function getPrefs() {
29
+ return prefs;
30
+ }
31
+ function savePrefs(patch) {
32
+ if (prefs = {
33
+ ...prefs,
34
+ ...patch,
35
+ ...patch.tips ? { tips: { ...prefs.tips, ...patch.tips } } : {},
36
+ ...patch.welcome ? { welcome: { ...prefs.welcome, ...patch.welcome } } : {}
37
+ }, !!file)
38
+ try {
39
+ mkdirSync(dirname(file), { recursive: !0 });
40
+ let tmp = `${file}.${process.pid}.tmp`;
41
+ writeFileSync(tmp, `${JSON.stringify(prefs, null, 2)}
42
+ `, "utf8"), renameSync(tmp, file);
43
+ } catch {
44
+ }
45
+ }
46
+
47
+ export {
48
+ defaultPrefsPath,
49
+ loadPrefs,
50
+ getPrefs,
51
+ savePrefs
52
+ };