@dsh-mobile/mobile-remote 3.3.0 → 3.4.0
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/FAQ.md +2 -2
- package/LICENSE +0 -0
- package/README.md +13 -8
- package/docs/PRIVACY-POLICY.en.md +26 -18
- package/docs/PRIVACY-POLICY.md +26 -18
- package/docs/SUPPORT.md +1 -1
- package/docs/TERMS-OF-SERVICE.en.md +5 -3
- package/docs/TERMS-OF-SERVICE.md +5 -3
- package/docs/USER-GUIDE.zh-CN.md +7 -6
- package/lib/account-usage-query.js +60 -60
- package/lib/account-usage.js +10 -10
- package/lib/api-helpers.js +114 -110
- package/lib/assistant-prefs.js +119 -76
- package/lib/auto-config.js +65 -65
- package/lib/backup.js +159 -123
- package/lib/break-reminder.js +45 -45
- package/lib/client.js +336 -138
- package/lib/config.js +234 -218
- package/lib/git-read-bundled-provider.js +27 -7
- package/lib/git-read-service.js +5 -5
- package/lib/host-compat.js +84 -84
- package/lib/http-util.js +17 -17
- package/lib/index.js +1670 -1511
- package/lib/memory/context.js +45 -40
- package/lib/memory/decay.js +93 -93
- package/lib/memory/extract.js +77 -77
- package/lib/memory/routes.js +33 -33
- package/lib/memory/store.js +239 -192
- package/lib/notify-copy.js +93 -93
- package/lib/permission-guide.js +86 -86
- package/lib/persona-cards.js +73 -61
- package/lib/phone-action-args.js +175 -0
- package/lib/phone-actions.js +227 -0
- package/lib/phone-announce.js +58 -0
- package/lib/proactive-material.js +42 -42
- package/lib/proactive.js +122 -119
- package/lib/protected-paths.js +205 -45
- package/lib/protocol.js +62 -23
- package/lib/push.js +29 -29
- package/lib/rate-limit.js +16 -16
- package/lib/relay/connector.js +334 -81
- package/lib/relay/crypto.js +15 -15
- package/lib/relay/devices.js +64 -32
- package/lib/relay/fingerprint.js +34 -34
- package/lib/relay/identity.js +26 -26
- package/lib/relay/mux.js +60 -46
- package/lib/relay/noise.js +40 -40
- package/lib/relay/on-demand.js +36 -31
- package/lib/relay/p2p.js +239 -0
- package/lib/relay/pairing.js +54 -15
- package/lib/relay/phone.js +63 -39
- package/lib/relay/serve.js +21 -21
- package/lib/relay/signal.js +69 -0
- package/lib/relay/ws-server.js +245 -0
- package/lib/reminders.js +15 -15
- package/lib/rpc-adapter.js +43 -43
- package/lib/session-list.js +31 -31
- package/lib/session-rotation.js +95 -95
- package/lib/session-title-cache.js +35 -35
- package/lib/session-title-refresh.js +51 -51
- package/lib/timeline.js +140 -140
- package/lib/turn-outline.js +104 -104
- package/package.json +11 -18
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
export const DEFAULT_TITLE_REFRESH_BUDGET_MS = 1500;
|
|
2
2
|
export const DEFAULT_TITLE_REFRESH_CONCURRENCY = 4;
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
30
|
export const createSessionTitleRefresher = ({
|
|
31
31
|
readRevision,
|
|
32
32
|
readTitles,
|
|
@@ -39,8 +39,8 @@ export const createSessionTitleRefresher = ({
|
|
|
39
39
|
if (!Number.isSafeInteger(concurrency) || concurrency < 1) throw new RangeError("concurrency must be a positive safe integer");
|
|
40
40
|
let currentRun = null;
|
|
41
41
|
let disposed = false;
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
|
|
44
44
|
let foldTail = Promise.resolve();
|
|
45
45
|
|
|
46
46
|
const foldAll = (ids, signal) => {
|
|
@@ -69,10 +69,10 @@ export const createSessionTitleRefresher = ({
|
|
|
69
69
|
run.resolve();
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
76
|
const armRunDeadline = (run) => {
|
|
77
77
|
if (!Number.isFinite(run.deadlineAt) || run.deadlineTimer) return;
|
|
78
78
|
const remaining = Math.max(0, run.deadlineAt - performance.now());
|
|
@@ -89,8 +89,8 @@ export const createSessionTitleRefresher = ({
|
|
|
89
89
|
const { signal } = run.controller;
|
|
90
90
|
try {
|
|
91
91
|
while (!disposed && !signal.aborted && run.queue.length > 0) {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
|
|
93
|
+
|
|
94
94
|
const pending = run.queue.splice(0, run.queue.length);
|
|
95
95
|
const misses = [];
|
|
96
96
|
let cursor = 0;
|
|
@@ -121,8 +121,8 @@ export const createSessionTitleRefresher = ({
|
|
|
121
121
|
() => scanRevisions(),
|
|
122
122
|
));
|
|
123
123
|
if (disposed || signal.aborted) break;
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
|
|
125
|
+
|
|
126
126
|
misses.sort((a, b) => a.index - b.index);
|
|
127
127
|
|
|
128
128
|
if (misses.length > 0) {
|
|
@@ -145,7 +145,7 @@ export const createSessionTitleRefresher = ({
|
|
|
145
145
|
onCacheChange();
|
|
146
146
|
}
|
|
147
147
|
} catch {
|
|
148
|
-
|
|
148
|
+
|
|
149
149
|
} finally {
|
|
150
150
|
finishRun(run);
|
|
151
151
|
}
|
|
@@ -187,22 +187,22 @@ export const createSessionTitleRefresher = ({
|
|
|
187
187
|
if (uniqueIds.length === 0) return new Map();
|
|
188
188
|
if (!Number.isFinite(budgetMs) || budgetMs < 0) throw new RangeError("budgetMs must be a non-negative finite number");
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
194
|
let run = currentRun;
|
|
195
195
|
if (!run || run.done || run.controller.signal.aborted) run = createRun(uniqueIds);
|
|
196
196
|
else addIds(run, uniqueIds);
|
|
197
|
-
|
|
198
|
-
|
|
197
|
+
|
|
198
|
+
|
|
199
199
|
if (Number.isFinite(runDeadlineMs) && runDeadlineMs >= 0) {
|
|
200
200
|
const nextAt = performance.now() + runDeadlineMs;
|
|
201
|
-
|
|
201
|
+
|
|
202
202
|
if (nextAt < run.deadlineAt) {
|
|
203
203
|
run.deadlineAt = nextAt;
|
|
204
|
-
|
|
205
|
-
|
|
204
|
+
|
|
205
|
+
|
|
206
206
|
if (run.deadlineTimer) {
|
|
207
207
|
clearTimeout(run.deadlineTimer);
|
|
208
208
|
run.deadlineTimer = null;
|
|
@@ -237,10 +237,10 @@ export const createSessionTitleRefresher = ({
|
|
|
237
237
|
clearTimeout(timer);
|
|
238
238
|
if (signal && abortHandler) signal.removeEventListener("abort", abortHandler);
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
|
|
244
244
|
if (outcome === "budget" && backgroundOnBudget && !signal?.aborted && !run.done) run.background = true;
|
|
245
245
|
const aborted = signal?.aborted === true;
|
|
246
246
|
release();
|
|
@@ -253,7 +253,7 @@ export const createSessionTitleRefresher = ({
|
|
|
253
253
|
disposed = true;
|
|
254
254
|
currentRun?.controller.abort(new Error("session-title refresher disposed"));
|
|
255
255
|
},
|
|
256
|
-
|
|
256
|
+
|
|
257
257
|
whenIdle() {
|
|
258
258
|
return currentRun?.promise ?? Promise.resolve();
|
|
259
259
|
},
|
package/lib/timeline.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
5
|
import { clampText } from "./api-helpers.js";
|
|
6
6
|
|
|
7
7
|
export const EVENT_TIMELINE_CAPABILITIES = {
|
|
@@ -13,24 +13,24 @@ export const EVENT_TIMELINE_CAPABILITIES = {
|
|
|
13
13
|
callCorrelation: true,
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
34
|
const REPLAY_IGNORED_TYPES = new Set([
|
|
35
35
|
"assistant/chunk",
|
|
36
36
|
"assistant/live-chunk",
|
|
@@ -48,11 +48,11 @@ const REPLAY_IGNORED_TYPES = new Set([
|
|
|
48
48
|
"compaction/end",
|
|
49
49
|
]);
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
56
|
const LLM_REQUEST_TYPE_PATTERN = /(?:^|[/-])llm-request$/;
|
|
57
57
|
|
|
58
58
|
export const isTimelineRecord = (event) => Boolean(
|
|
@@ -62,30 +62,30 @@ export const isTimelineRecord = (event) => Boolean(
|
|
|
62
62
|
&& !LLM_REQUEST_TYPE_PATTERN.test(event.type)
|
|
63
63
|
);
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
|
|
66
|
+
|
|
67
67
|
const LIVE_ONLY_TYPES = new Set(["assistant/chunk", "assistant/live-chunk"]);
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
|
|
70
|
+
|
|
71
71
|
const LIVE_CONTROL_TYPES = new Set(["compaction/end"]);
|
|
72
72
|
|
|
73
73
|
export const isLiveTimelineRecord = (event) => Boolean(
|
|
74
74
|
event && typeof event.type === "string" && (isTimelineRecord(event) || LIVE_ONLY_TYPES.has(event.type) || LIVE_CONTROL_TYPES.has(event.type))
|
|
75
75
|
);
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
89
|
const DETAIL_VISIBLE_TYPES = new Set([
|
|
90
90
|
"user/message",
|
|
91
91
|
"assistant/message",
|
|
@@ -96,47 +96,47 @@ const DETAIL_VISIBLE_TYPES = new Set([
|
|
|
96
96
|
"turn/end",
|
|
97
97
|
]);
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
export const isDetailVisibleType = (type) => typeof type === "string" && DETAIL_VISIBLE_TYPES.has(type);
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
107
|
export const MESSAGE_EVENT_TYPES = new Set(["user/message", "assistant/message"]);
|
|
108
108
|
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
export const isMessageEventType = (type) => typeof type === "string" && MESSAGE_EVENT_TYPES.has(type);
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
124
|
export const isVisibleConversationMessage = (event) => {
|
|
125
125
|
const type = event?.type;
|
|
126
126
|
if (!isMessageEventType(type)) return false;
|
|
127
127
|
if (type === "assistant/message") {
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
|
|
129
|
+
|
|
130
130
|
const message = event?.data?.message;
|
|
131
131
|
if (!message || typeof message !== "object") return false;
|
|
132
132
|
return blocksToText(message.content).trim() !== "";
|
|
133
133
|
}
|
|
134
|
-
|
|
134
|
+
|
|
135
135
|
const kind = event?.data?.source?.kind;
|
|
136
136
|
return kind === undefined || kind === null || kind === "user";
|
|
137
137
|
};
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
|
|
140
140
|
export function blocksToText(blocks, { includeToolCalls = false, imagePlaceholder = true } = {}) {
|
|
141
141
|
let out = "";
|
|
142
142
|
for (const block of blocks ?? []) {
|
|
@@ -147,14 +147,14 @@ export function blocksToText(blocks, { includeToolCalls = false, imagePlaceholde
|
|
|
147
147
|
return out;
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
function reasoningChars(blocks) {
|
|
152
152
|
let n = 0;
|
|
153
153
|
for (const block of blocks ?? []) if (block?.type === "reasoning") n += block.text.length;
|
|
154
154
|
return n;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
|
|
157
|
+
|
|
158
158
|
function reasoningText(blocks) {
|
|
159
159
|
let out = "";
|
|
160
160
|
for (const block of blocks ?? []) {
|
|
@@ -163,11 +163,11 @@ function reasoningText(blocks) {
|
|
|
163
163
|
return out;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
166
|
+
|
|
167
167
|
function imageMetaOf(ref) {
|
|
168
168
|
if (!ref || typeof ref !== "object") return null;
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
|
|
170
|
+
|
|
171
171
|
const attachment = ref.attachment && typeof ref.attachment === "object" ? ref.attachment : ref;
|
|
172
172
|
const id = attachment.attachmentId ?? attachment.id;
|
|
173
173
|
if (id === undefined || id === null || String(id) === "") return null;
|
|
@@ -187,12 +187,12 @@ function imageMetaOf(ref) {
|
|
|
187
187
|
};
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
function imagesOf(blocks) {
|
|
192
192
|
const out = [];
|
|
193
193
|
for (const block of blocks ?? []) {
|
|
194
194
|
if (!block || typeof block !== "object") continue;
|
|
195
|
-
|
|
195
|
+
|
|
196
196
|
if (block.type === "image") {
|
|
197
197
|
const meta = imageMetaOf(block.attachment ?? block);
|
|
198
198
|
if (meta) out.push(meta);
|
|
@@ -201,18 +201,18 @@ function imagesOf(blocks) {
|
|
|
201
201
|
return out;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
209
|
function imagesOfNested(blocks) {
|
|
210
210
|
const out = [];
|
|
211
211
|
const walk = (list) => {
|
|
212
212
|
for (const block of list ?? []) {
|
|
213
213
|
if (!block || typeof block !== "object") continue;
|
|
214
214
|
if (block.type === "image") {
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
const meta = imageMetaOf(block.attachment ?? block);
|
|
217
217
|
if (meta) out.push(meta);
|
|
218
218
|
} else if (block.type === "tool-result" && Array.isArray(block.content)) {
|
|
@@ -224,7 +224,7 @@ function imagesOfNested(blocks) {
|
|
|
224
224
|
return out;
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
|
|
228
228
|
function fileMetaOf(ref) {
|
|
229
229
|
if (!ref || typeof ref !== "object") return null;
|
|
230
230
|
const mediaType = typeof ref.mediaType === "string" ? ref.mediaType : typeof ref.mimeType === "string" ? ref.mimeType : "";
|
|
@@ -242,7 +242,7 @@ function fileMetaOf(ref) {
|
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
|
|
246
246
|
function filesOfNested(blocks, explicit = false) {
|
|
247
247
|
const out = [];
|
|
248
248
|
const seen = new Set();
|
|
@@ -269,12 +269,12 @@ function filesOfNested(blocks, explicit = false) {
|
|
|
269
269
|
return out;
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
|
|
278
278
|
export function sniffImageType(data) {
|
|
279
279
|
if (typeof data !== "string" || data.length === 0) return null;
|
|
280
280
|
const head = Buffer.from(data.slice(0, 40), "base64");
|
|
@@ -284,20 +284,20 @@ export function sniffImageType(data) {
|
|
|
284
284
|
if (bytes(0, 3) === "ffd8ff") return "image/jpeg";
|
|
285
285
|
if (bytes(0, 4) === "47494638") return "image/gif";
|
|
286
286
|
if (bytes(0, 4) === "52494646" && bytes(8, 4) === "57454250") return "image/webp";
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
|
|
288
|
+
|
|
289
289
|
const containerBrand = bytes(4, 4) === "66747970" ? bytes(8, 4) : "";
|
|
290
290
|
if (["68656963", "68656978", "68657663", "6d696631"].includes(containerBrand)) return "image/heic";
|
|
291
291
|
return null;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
298
|
function summarizeEventCore(event) {
|
|
299
299
|
const { seq, type, data } = event;
|
|
300
|
-
|
|
300
|
+
|
|
301
301
|
if (data === undefined) return { seq, type };
|
|
302
302
|
switch (type) {
|
|
303
303
|
case "user/message": {
|
|
@@ -309,13 +309,13 @@ function summarizeEventCore(event) {
|
|
|
309
309
|
type,
|
|
310
310
|
data: {
|
|
311
311
|
messageId: message.id,
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
|
|
313
|
+
|
|
314
314
|
text: clampText(blocksToText(message.content, { imagePlaceholder: false }), 2000),
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
319
|
...(typeof message.source?.kind === "string" && message.source.kind !== ""
|
|
320
320
|
? { sourceKind: message.source.kind }
|
|
321
321
|
: {}),
|
|
@@ -326,13 +326,13 @@ function summarizeEventCore(event) {
|
|
|
326
326
|
}
|
|
327
327
|
case "assistant/message": {
|
|
328
328
|
const message = data.message;
|
|
329
|
-
|
|
329
|
+
|
|
330
330
|
if (!message || typeof message !== "object") return { seq, type };
|
|
331
|
-
|
|
331
|
+
|
|
332
332
|
const images = imagesOfNested(message.content);
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
|
|
336
336
|
const reasoning = reasoningText(message.content);
|
|
337
337
|
return {
|
|
338
338
|
seq,
|
|
@@ -340,7 +340,7 @@ function summarizeEventCore(event) {
|
|
|
340
340
|
data: {
|
|
341
341
|
turn: data.turn,
|
|
342
342
|
step: data.step,
|
|
343
|
-
|
|
343
|
+
|
|
344
344
|
messageId: message.id,
|
|
345
345
|
text: clampText(blocksToText(message.content), 20000),
|
|
346
346
|
reasoningChars: reasoningChars(message.content),
|
|
@@ -367,7 +367,7 @@ function summarizeEventCore(event) {
|
|
|
367
367
|
argumentsDelta: clampText(String(chunk.argumentsDelta ?? ""), 2000),
|
|
368
368
|
},
|
|
369
369
|
};
|
|
370
|
-
return { seq, type, data: null };
|
|
370
|
+
return { seq, type, data: null };
|
|
371
371
|
}
|
|
372
372
|
case "tool/call": {
|
|
373
373
|
let argumentsText = data.arguments;
|
|
@@ -377,18 +377,18 @@ function summarizeEventCore(event) {
|
|
|
377
377
|
return { seq, type, data: { turn: data.turn, step: data.step, callId: data.callId, name: data.name, arguments: clampText(argumentsText, 2000) } };
|
|
378
378
|
}
|
|
379
379
|
case "tool/result": {
|
|
380
|
-
|
|
381
|
-
|
|
380
|
+
|
|
381
|
+
|
|
382
382
|
const message = data.message;
|
|
383
383
|
const blocks = Array.isArray(message?.content) ? message.content : [];
|
|
384
|
-
|
|
384
|
+
|
|
385
385
|
let callId = typeof data.callId === "string" ? data.callId : typeof data.toolCallId === "string" ? data.toolCallId : "";
|
|
386
386
|
let isError = data.error !== undefined || data.isError === true;
|
|
387
387
|
let text = typeof data.text === "string" ? data.text : "";
|
|
388
388
|
const images = Array.isArray(data.images)
|
|
389
389
|
? data.images.map(imageMetaOf).filter(Boolean).slice(0, 20)
|
|
390
390
|
: [];
|
|
391
|
-
|
|
391
|
+
|
|
392
392
|
for (const b of blocks) {
|
|
393
393
|
if (!b || typeof b !== "object") continue;
|
|
394
394
|
const inner = Array.isArray(b.content) ? b.content : [b];
|
|
@@ -399,10 +399,10 @@ function summarizeEventCore(event) {
|
|
|
399
399
|
}
|
|
400
400
|
const errName = typeof data.error?.name === "string" && data.error?.name !== "" ? data.error.name : "";
|
|
401
401
|
const directName = typeof data.name === "string" && data.name !== "" ? data.name : "";
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
|
|
406
406
|
const resultName = directName || errName;
|
|
407
407
|
return {
|
|
408
408
|
seq,
|
|
@@ -419,9 +419,9 @@ function summarizeEventCore(event) {
|
|
|
419
419
|
};
|
|
420
420
|
}
|
|
421
421
|
case "todo/write": {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
425
|
const list = Array.isArray(data.todos) ? data.todos : [];
|
|
426
426
|
return {
|
|
427
427
|
seq,
|
|
@@ -443,11 +443,11 @@ function summarizeEventCore(event) {
|
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
451
451
|
function detailTextCharsHint(event) {
|
|
452
452
|
if (event?.type !== "assistant/message") return {};
|
|
453
453
|
const content = event?.data?.message?.content;
|
|
@@ -455,16 +455,16 @@ function detailTextCharsHint(event) {
|
|
|
455
455
|
return { textChars: blocksToText(content).length };
|
|
456
456
|
}
|
|
457
457
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
|
|
468
468
|
export function detailEventFor(event) {
|
|
469
469
|
const detailEvent = { ...event };
|
|
470
470
|
if (event?.type === "assistant/message" && event.data && typeof event.data === "object") {
|
|
@@ -474,16 +474,16 @@ export function detailEventFor(event) {
|
|
|
474
474
|
return detailEvent;
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
481
|
export function summarizeEvent(event) {
|
|
482
482
|
const summary = summarizeEventCore(event);
|
|
483
483
|
if (event?.seq === undefined || event?.seq === null) return summary;
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
484
|
+
|
|
485
|
+
|
|
486
|
+
|
|
487
487
|
if (!isTimelineRecord(event) || !isDetailVisibleType(event.type)) return summary;
|
|
488
488
|
return {
|
|
489
489
|
...summary,
|