@inupedia/spotlight-vue 0.5.18 → 0.6.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.
@@ -1,44 +1,58 @@
1
- import { serializeSkillsForRemote as O } from "@inupedia/spotlight-client";
2
- import { useAgentSessionStore as P } from "../session/agentSession.js";
3
- import { useSpotlightMemoryPreferenceStore as q } from "../store/memoryPreferenceStore.js";
4
- import { useSpotlightRuntimeStore as D } from "../store/runtimeStore.js";
1
+ import { serializeSkillsForRemote as F } from "@inupedia/spotlight-client";
2
+ import { useAgentSessionStore as L } from "../session/agentSession.js";
3
+ import { useSpotlightMemoryPreferenceStore as J } from "../store/memoryPreferenceStore.js";
4
+ import { useSpotlightRuntimeStore as j } from "../store/runtimeStore.js";
5
5
  import { SPOTLIGHT_PIPELINE_STEP_IDS as r } from "../store/pipeline/constants.js";
6
- import { isLoopPlanningChunk as F, splitIntentStepContent as J } from "../store/pipeline/displayText.js";
7
- import { toolLaneStepId as E, resolveToolLane as j, toolLaneStepLabel as B } from "../store/pipeline/toolLane.js";
8
- import { getSpotlightConfig as k } from "../plugin.js";
9
- import { getSkillsPoolForRun as W } from "../skills/index.js";
10
- import { executeRemoteHostTool as z, ensureHostToolsManifest as x } from "./hostToolRunner.js";
11
- import { getSpotlightServerBase as _, buildSpotlightJsonHeaders as S, getSpotlightProjectId as G } from "./httpConfig.js";
12
- import { ensureSpotlightMeta as U } from "./meta.js";
13
- const I = /* @__PURE__ */ new WeakMap();
14
- function V(t) {
15
- return t.type !== "host_action_request" && t.type !== "run_completed" && t.type !== "run_error" && t.type !== "ping" && t.type !== "memory_decision";
6
+ import { isLoopPlanningChunk as B, splitIntentStepContent as W } from "../store/pipeline/displayText.js";
7
+ import { toolLaneStepId as M, resolveToolLane as U, toolLaneStepLabel as z } from "../store/pipeline/toolLane.js";
8
+ import { getSpotlightConfig as E } from "../plugin.js";
9
+ import { getSkillsPoolForRun as G } from "../skills/index.js";
10
+ import { executeRemoteHostTool as V, ensureHostToolsManifest as A } from "./hostToolRunner.js";
11
+ import { getSpotlightServerBase as T, buildSpotlightJsonHeaders as w, getSpotlightProjectId as Y } from "./httpConfig.js";
12
+ import { ensureSpotlightMeta as K } from "./meta.js";
13
+ const N = /* @__PURE__ */ new WeakMap();
14
+ function Q(t) {
15
+ return t.type !== "host_action_request" && t.type !== "run_completed" && t.type !== "run_error" && t.type !== "run_status" && t.type !== "ping" && t.type !== "memory_decision";
16
16
  }
17
- function d(t, e, o) {
17
+ function u(t, e, o) {
18
18
  const s = t.getSteps().find((a) => a.id === e);
19
19
  if (s) return s;
20
20
  const n = { id: e, label: o, status: "pending" };
21
21
  return t.setSteps([...t.getSteps(), n]), n;
22
22
  }
23
- function L() {
23
+ function O() {
24
24
  return new Promise((t) => {
25
25
  requestAnimationFrame(() => t());
26
26
  });
27
27
  }
28
- function Y(t) {
29
- const e = t.summary?.trim();
30
- if (e && e.length > 48 && !e.startsWith("{") && !e.startsWith("["))
31
- return e;
28
+ function X(t) {
29
+ return Array.isArray(t) ? t.flatMap((o, s) => {
30
+ if (!o || typeof o != "object") return [];
31
+ const n = o, a = typeof n.content == "string" ? n.content.trim() : "";
32
+ if (!a) return [];
33
+ const i = typeof n.title == "string" && n.title.trim() || typeof n.url == "string" && n.url.trim() || `资料 ${s + 1}`, f = typeof n.url == "string" ? n.url.trim() : "";
34
+ return [[i, f && f !== i ? f : "", a].filter(Boolean).join(`
35
+ `)];
36
+ }).join(`
37
+
38
+ `) : "";
39
+ }
40
+ function Z(t) {
41
+ const e = X(t.output);
42
+ if (e) return e;
43
+ const o = t.summary?.trim();
44
+ if (o && o.length > 48 && !o.startsWith("{") && !o.startsWith("["))
45
+ return o;
32
46
  if (t.output != null && typeof t.output == "object")
33
47
  try {
34
- const o = JSON.stringify(t.output, null, 2);
35
- if (o && o !== "{}") return o;
48
+ const s = JSON.stringify(t.output, null, 2);
49
+ if (s && s !== "{}") return s;
36
50
  } catch {
37
51
  }
38
- return e || "";
52
+ return o || "";
39
53
  }
40
- function K(t) {
41
- const e = Y(t.result);
54
+ function v(t) {
55
+ const e = Z(t.result);
42
56
  return {
43
57
  id: t.result.call.id,
44
58
  name: t.result.call.name,
@@ -51,7 +65,7 @@ function K(t) {
51
65
  status: t.result.success ? "done" : "error"
52
66
  };
53
67
  }
54
- function Q(t) {
68
+ function tt(t) {
55
69
  return {
56
70
  id: t.call.id,
57
71
  name: t.call.name,
@@ -60,7 +74,7 @@ function Q(t) {
60
74
  status: "running"
61
75
  };
62
76
  }
63
- function X(t, e) {
77
+ function et(t, e) {
64
78
  const o = e.success ? "前端操作已执行。" : e.error || "前端操作执行失败。";
65
79
  return {
66
80
  id: t.id,
@@ -74,26 +88,26 @@ function X(t, e) {
74
88
  status: e.success ? "done" : "error"
75
89
  };
76
90
  }
77
- function Z(t, e) {
78
- return j(t, e?.sideEffectByName?.get(t));
91
+ function st(t, e) {
92
+ return U(t, e?.sideEffectByName?.get(t));
79
93
  }
80
- function c(t, e, o) {
94
+ function d(t, e, o) {
81
95
  const s = t.getSteps().find((n) => n.id === e);
82
96
  !s || s.status === "done" || s.status === "error" || t.setStep(e, "done", s.content ?? o);
83
97
  }
84
- function C(t, e) {
85
- c(t, r.understand);
86
- const o = E(e), s = B(e);
87
- d(t, o, s);
98
+ function R(t, e) {
99
+ d(t, r.understand);
100
+ const o = M(e), s = z(e);
101
+ u(t, o, s);
88
102
  const n = t.getSteps().find((a) => a.id === o);
89
103
  !n || n.status === "active" || n.status === "done" || t.setStep(o, "active", n.content);
90
104
  }
91
- function f(t, e, o) {
92
- const s = Z(e, o);
93
- return C(t, s), E(s);
105
+ function S(t, e, o) {
106
+ const s = st(e, o);
107
+ return R(t, s), M(s);
94
108
  }
95
- function v(t, e, o) {
96
- const s = f(t, e.name, o);
109
+ function nt(t, e, o) {
110
+ const s = S(t, e.name, o);
97
111
  t.appendToolCallsToStep(s, [
98
112
  {
99
113
  id: e.id,
@@ -104,22 +118,22 @@ function v(t, e, o) {
104
118
  }
105
119
  ]);
106
120
  }
107
- function tt(t, e, o, s) {
108
- const n = f(t, e.name, s);
109
- t.appendToolCallsToStep(n, [X(e, o)]);
121
+ function ot(t, e, o, s) {
122
+ const n = S(t, e.name, s);
123
+ t.appendToolCallsToStep(n, [et(e, o)]);
110
124
  }
111
- function N(t, e) {
125
+ function b(t, e) {
112
126
  return e || (t === r.gather ? "获取信息" : t === r.act ? "操作页面" : t === r.answer ? "回答" : t === r.understand ? "理解问题" : t === r.tool ? "获取信息" : t);
113
127
  }
114
- function m(t, e, o, s, n) {
115
- d(t, e, o), t.setStep(e, s, n);
128
+ function y(t, e, o, s, n) {
129
+ u(t, e, o), t.setStep(e, s, n);
116
130
  }
117
- function et(t, e) {
131
+ function rt(t, e) {
118
132
  const o = e.summary?.trim();
119
133
  switch (e.phase) {
120
134
  case "routing":
121
135
  case "analyzing":
122
- m(
136
+ y(
123
137
  t,
124
138
  r.understand,
125
139
  "理解问题",
@@ -128,7 +142,7 @@ function et(t, e) {
128
142
  );
129
143
  return;
130
144
  case "router_done":
131
- m(
145
+ y(
132
146
  t,
133
147
  r.understand,
134
148
  "理解问题",
@@ -137,7 +151,7 @@ function et(t, e) {
137
151
  );
138
152
  return;
139
153
  case "knowledge_agent_start":
140
- c(t, r.understand), m(
154
+ d(t, r.understand), y(
141
155
  t,
142
156
  r.gather,
143
157
  "获取信息",
@@ -146,24 +160,24 @@ function et(t, e) {
146
160
  );
147
161
  return;
148
162
  case "knowledge_agent_done":
149
- c(
163
+ d(
150
164
  t,
151
165
  r.gather,
152
166
  o ?? "资料已就绪。"
153
167
  );
154
168
  return;
155
169
  case "action_agent_start":
156
- c(t, r.understand);
170
+ d(t, r.understand);
157
171
  return;
158
172
  case "action_agent_done":
159
- c(t, r.gather), c(
173
+ d(t, r.gather), d(
160
174
  t,
161
175
  r.act,
162
176
  o ?? "页面操作已完成。"
163
177
  );
164
178
  return;
165
179
  case "memory_replay":
166
- m(
180
+ y(
167
181
  t,
168
182
  r.understand,
169
183
  "理解问题",
@@ -175,7 +189,7 @@ function et(t, e) {
175
189
  return;
176
190
  }
177
191
  }
178
- async function st(t, e, o) {
192
+ async function at(t, e, o) {
179
193
  if (e.type !== "ping") {
180
194
  if (e.type === "step_sync")
181
195
  t.setSteps(
@@ -187,19 +201,19 @@ async function st(t, e, o) {
187
201
  }))
188
202
  );
189
203
  else if (e.type === "step_status")
190
- d(t, e.stepId, e.label ?? e.stepId), t.setStep(e.stepId, e.status, e.content);
204
+ u(t, e.stepId, e.label ?? e.stepId), t.setStep(e.stepId, e.status, e.content);
191
205
  else if (e.type === "step_content") {
192
206
  let s = e.stepId, n = e.content;
193
- if ((s === r.intent || s === r.understand) && F(n))
207
+ if ((s === r.intent || s === r.understand) && B(n))
194
208
  s = r.gather;
195
209
  else if ((s === r.intent || s === r.understand) && e.mode === "replace") {
196
- const { intent: a, misplacedPlanning: i } = J(n);
197
- n = a, i.trim() && (d(t, r.gather, "获取信息"), t.appendChunkToStep(
210
+ const { intent: a, misplacedPlanning: i } = W(n);
211
+ n = a, i.trim() && (u(t, r.gather, "获取信息"), t.appendChunkToStep(
198
212
  r.gather,
199
213
  i
200
214
  ));
201
215
  }
202
- if (d(t, s, N(s, e.label)), e.mode === "replace")
216
+ if (u(t, s, b(s, e.label)), e.mode === "replace")
203
217
  t.setStep(
204
218
  s,
205
219
  t.getSteps().find((a) => a.id === s)?.status ?? "active",
@@ -208,21 +222,21 @@ async function st(t, e, o) {
208
222
  else {
209
223
  if (s === r.tool || s === r.gather || s === r.act) {
210
224
  const a = s === r.act ? "act" : "gather";
211
- C(t, a);
225
+ R(t, a);
212
226
  }
213
- t.appendChunkToStep(s, n), await L();
227
+ t.appendChunkToStep(s, n), await O();
214
228
  }
215
229
  } else if (e.type === "step_artifact") {
216
230
  const s = e.stepId === r.tool ? r.gather : e.stepId;
217
- d(t, s, N(s, e.label)), (s === r.gather || s === r.act) && C(
231
+ u(t, s, b(s, e.label)), (s === r.gather || s === r.act) && R(
218
232
  t,
219
233
  s === r.act ? "act" : "gather"
220
234
  ), e.artifact === "tool_calls" && e.toolCalls?.length ? t.appendToolCallsToStep(s, e.toolCalls) : e.artifact === "attachments" && e.attachments?.length ? t.appendAttachmentsToStep(s, e.attachments) : e.artifact === "files" && e.files?.length ? t.appendFilesToStep(s, e.files) : e.artifact === "artifacts" && e.artifacts?.length ? t.appendArtifactsToStep(s, e.artifacts) : e.artifact === "chat_items" && e.chatItems?.length && t.appendChatItemsToStep(s, e.chatItems);
221
235
  } else if (e.type === "tool_start") {
222
- const s = f(t, e.call.name, o);
223
- t.appendToolCallsToStep(s, [Q(e)]);
236
+ const s = S(t, e.call.name, o);
237
+ t.appendToolCallsToStep(s, [tt(e)]);
224
238
  } else if (e.type === "tool_progress") {
225
- const s = f(t, e.call.name, o);
239
+ const s = S(t, e.call.name, o);
226
240
  t.appendToolCallsToStep(s, [
227
241
  {
228
242
  id: e.call.id,
@@ -234,8 +248,8 @@ async function st(t, e, o) {
234
248
  }
235
249
  ]);
236
250
  } else if (e.type === "tool_result") {
237
- const s = f(t, e.result.call.name, o);
238
- t.appendToolCallsToStep(s, [K(e)]), e.result.attachments?.length && t.appendAttachmentsToStep(s, e.result.attachments), e.result.files?.length && t.appendFilesToStep(s, e.result.files), e.result.toolCalls?.length && t.appendToolCallsToStep(s, e.result.toolCalls);
251
+ const s = S(t, e.result.call.name, o);
252
+ t.appendToolCallsToStep(s, [v(e)]), e.result.attachments?.length && t.appendAttachmentsToStep(s, e.result.attachments), e.result.files?.length && t.appendFilesToStep(s, e.result.files), e.result.toolCalls?.length && t.appendToolCallsToStep(s, e.result.toolCalls);
239
253
  } else if (e.type === "skill_permission_request") {
240
254
  const { useSpotlightStore: s } = await import("../store/spotlightStore.js");
241
255
  s().setPendingSkillPermission({
@@ -247,14 +261,14 @@ async function st(t, e, o) {
247
261
  });
248
262
  } else if (e.type === "fork_progress") {
249
263
  const s = r.gather;
250
- d(t, s, "获取信息"), t.appendChunkToStep(
264
+ u(t, s, "获取信息"), t.appendChunkToStep(
251
265
  s,
252
266
  `
253
267
  [fork ${e.agentId}] 第 ${e.iteration} 轮 · ${e.phase}:${e.summary}
254
268
  `
255
269
  );
256
270
  } else if (e.type === "turn_transition")
257
- et(t, e);
271
+ rt(t, e);
258
272
  else if (e.type === "memory_decision") {
259
273
  const s = {
260
274
  reuse: "已复用项目记忆",
@@ -262,68 +276,99 @@ async function st(t, e, o) {
262
276
  refresh: "资料可能变化,正在重新验证",
263
277
  ignore: "未发现可直接使用的项目记忆"
264
278
  }, n = t.getSteps().find((i) => i.id === r.understand), a = e.decision.action === "reuse" || n?.status === "done" ? "done" : "active";
265
- m(
279
+ y(
266
280
  t,
267
281
  r.understand,
268
282
  "理解问题",
269
283
  a,
270
284
  s[e.decision.action]
271
285
  );
272
- } else e.type === "assistant_response" && (c(t, r.understand), c(t, r.gather), c(t, r.act), d(t, r.answer, "回答"), t.setStep(
286
+ } else if (e.type === "run_status") {
287
+ const s = e.detail?.trim();
288
+ if (s) {
289
+ const n = t.getSteps().find((a) => a.id === r.act) ? r.act : r.gather;
290
+ u(t, n, b(n, null)), t.appendChunkToStep(n, `
291
+ ${s}
292
+ `);
293
+ }
294
+ } else e.type === "assistant_response" && (d(t, r.understand), d(t, r.gather), d(t, r.act), u(t, r.answer, "回答"), t.setStep(
273
295
  r.answer,
274
296
  "done",
275
297
  e.content.trim()
276
298
  ));
277
- V(e) && t.appendExecutionEvent?.(e);
299
+ Q(e) && t.appendExecutionEvent?.(e);
278
300
  }
279
301
  }
280
- async function ot(t) {
302
+ async function it(t) {
281
303
  await fetch(
282
- `${_()}/v1/runs/${encodeURIComponent(t.runId)}/host-results`,
304
+ `${T()}/v1/runs/${encodeURIComponent(t.runId)}/host-results`,
283
305
  {
284
306
  method: "POST",
285
- headers: S(),
307
+ headers: w(),
286
308
  body: JSON.stringify({
287
309
  correlationId: t.correlationId,
288
310
  success: t.result.success,
289
311
  output: t.result.data,
290
312
  error: t.result.error,
291
313
  errorCode: t.result.errorCode,
292
- trace: t.result.trace
314
+ trace: t.result.trace,
315
+ // Free observation: the page just changed, so tell the agent what it
316
+ // looks like now instead of making it plan against the pre-call state.
317
+ uiContext: E().getUiContext?.() ?? void 0
293
318
  }),
294
319
  signal: t.signal
295
320
  }
296
321
  );
297
322
  }
298
- function nt(t) {
323
+ function lt(t) {
299
324
  const e = t.split(/\n\n/u), o = e.pop() ?? "";
300
325
  return { events: e.flatMap((n) => {
301
- const a = n.split(/\n/u).find((i) => i.startsWith("data: "));
302
- if (!a) return [];
326
+ const a = n.split(/\n/u), i = a.find((c) => c.startsWith("data: "));
327
+ if (!i) return [];
328
+ const f = a.find((c) => c.startsWith("id: ")), p = f ? Number.parseInt(f.slice(4), 10) : Number.NaN;
303
329
  try {
304
- return [JSON.parse(a.slice(6))];
330
+ const c = JSON.parse(i.slice(6));
331
+ return [Number.isFinite(p) ? { ...c, seq: p } : c];
305
332
  } catch {
306
333
  return [];
307
334
  }
308
335
  }), rest: o };
309
336
  }
310
- async function ht(t) {
337
+ const ct = 6, ut = 400;
338
+ async function dt(t, e, o) {
339
+ const s = e > 0 ? `?lastEventId=${e}` : "", n = await fetch(
340
+ `${T()}/v1/runs/${encodeURIComponent(t)}/events${s}`,
341
+ { headers: w(), signal: o }
342
+ );
343
+ if (n.status === 410)
344
+ throw new Error("Spotlight 后端已不再保留这次运行的记录,请重新提问。");
345
+ if (!n.ok || !n.body)
346
+ throw new Error(`Spotlight 后端事件流连接失败:${n.status}`);
347
+ return n;
348
+ }
349
+ function ft(t) {
350
+ return Math.min(ut * 2 ** t, 5e3);
351
+ }
352
+ function mt(t) {
353
+ return new Promise((e) => setTimeout(e, t));
354
+ }
355
+ async function kt(t) {
311
356
  await Promise.allSettled([
312
- x(),
313
- U(t)
357
+ A(),
358
+ K(t)
314
359
  ]);
315
360
  }
316
- async function rt(t, e, o) {
317
- const s = P(), n = D(), a = q(), i = await x();
361
+ async function pt(t, e, o) {
362
+ const s = L(), n = j(), a = J(), i = await A();
318
363
  return {
319
364
  hostManifest: i,
320
365
  payload: {
321
- projectId: G(),
366
+ projectId: Y(),
322
367
  sessionId: s.sessionId,
323
- memorySubjectId: k().getMemorySubjectId?.() ?? void 0,
368
+ memorySubjectId: E().getMemorySubjectId?.() ?? void 0,
324
369
  userQuestion: t,
325
370
  memoryRefreshRequested: o?.forceMemoryRefresh === !0,
326
- uiContext: k().getUiContext?.() ?? {},
371
+ uiContext: E().getUiContext?.() ?? {},
327
372
  sessionState: {
328
373
  sessionId: s.sessionId,
329
374
  activeTaskId: s.activeTaskId,
@@ -348,113 +393,117 @@ async function rt(t, e, o) {
348
393
  },
349
394
  clientToolsManifestVersion: i.manifestDigest,
350
395
  clientToolManifest: i,
351
- skills: O(W()),
396
+ skills: F(G()),
352
397
  frontendBuildId: i.frontendBuildId,
353
398
  manifestDigest: i.manifestDigest
354
399
  }
355
400
  };
356
401
  }
357
- async function Tt(t, e, o) {
358
- const s = _(), n = e.getSignal(), { payload: a, hostManifest: i } = await rt(
402
+ async function Pt(t, e, o) {
403
+ const s = T(), n = e.getSignal(), { payload: a, hostManifest: i } = await pt(
359
404
  t,
360
405
  n,
361
406
  o
362
- ), A = new Set(i.tools.map((u) => u.name)), h = {
407
+ ), f = new Set(i.tools.map((m) => m.name)), p = {
363
408
  sideEffectByName: new Map(
364
- i.tools.map((u) => [u.name, u.sideEffect])
409
+ i.tools.map((m) => [m.name, m.sideEffect])
365
410
  )
366
- }, p = await fetch(`${s}/v1/runs`, {
411
+ }, c = await fetch(`${s}/v1/runs`, {
367
412
  method: "POST",
368
- headers: S(),
413
+ headers: w(),
369
414
  body: JSON.stringify(a),
370
415
  signal: n
371
416
  });
372
- if (!p.ok) {
373
- const u = await p.text().catch(() => "");
417
+ if (!c.ok) {
418
+ const m = await c.text().catch(() => "");
374
419
  throw new Error(
375
- `Spotlight 后端创建 run 失败:${p.status} ${u}`
420
+ `Spotlight 后端创建 run 失败:${c.status} ${m}`
376
421
  );
377
422
  }
378
- const { runId: g } = await p.json();
379
- n && (I.set(n, g), n.addEventListener(
423
+ const { runId: h } = await c.json();
424
+ n && (N.set(n, h), n.addEventListener(
380
425
  "abort",
381
426
  () => {
382
- $(g);
427
+ q(h);
383
428
  },
384
429
  { once: !0 }
385
430
  ));
386
- const y = await fetch(
387
- `${s}/v1/runs/${encodeURIComponent(g)}/events`,
388
- {
389
- headers: S(),
390
- signal: n
391
- }
392
- );
393
- if (!y.ok || !y.body)
394
- throw new Error(`Spotlight 后端事件流连接失败:${y.status}`);
395
- const w = y.body.getReader(), H = new TextDecoder();
396
- let T = "";
397
- try {
398
- for (; ; ) {
399
- const { done: u, value: M } = await w.read();
400
- if (u) break;
401
- T += H.decode(M, { stream: !0 });
402
- const R = nt(T);
403
- T = R.rest;
404
- for (const l of R.events) {
405
- if (l.type === "host_action_request") {
406
- v(e, l.request.call, h);
407
- const b = await z(l.request.call, e, {
408
- allowedHostNames: A,
409
- hostEffect: l.request.hostEffect
410
- });
411
- tt(e, l.request.call, b, h), await ot({
412
- runId: g,
413
- correlationId: l.request.correlationId,
414
- result: b,
415
- signal: n
416
- });
417
- continue;
431
+ let k = 0, C = 0;
432
+ for (; ; ) {
433
+ const P = (await dt(h, k, n)).body.getReader(), D = new TextDecoder();
434
+ let I = "", _ = !1;
435
+ try {
436
+ for (; ; ) {
437
+ const { done: g, value: H } = await P.read();
438
+ if (g) {
439
+ _ = !0;
440
+ break;
441
+ }
442
+ I += D.decode(H, { stream: !0 });
443
+ const x = lt(I);
444
+ I = x.rest;
445
+ for (const l of x.events) {
446
+ if (typeof l.seq == "number" && (k = l.seq), l.type === "host_action_request") {
447
+ nt(e, l.request.call, p);
448
+ const $ = await V(l.request.call, e, {
449
+ allowedHostNames: f,
450
+ hostEffect: l.request.hostEffect
451
+ });
452
+ ot(e, l.request.call, $, p), await it({
453
+ runId: h,
454
+ correlationId: l.request.correlationId,
455
+ result: $,
456
+ signal: n
457
+ });
458
+ continue;
459
+ }
460
+ if (l.type === "run_error")
461
+ throw new Error(l.error);
462
+ if (await at(e, l, p), await O(), l.type === "run_completed")
463
+ return l.sessionPatch && L().applySessionPatch(l.sessionPatch), {
464
+ command: null,
465
+ memoryReplay: l.memoryReplay ?? null,
466
+ memoryDecision: l.memoryDecision ?? null,
467
+ assistantReply: l.assistantReply
468
+ };
418
469
  }
419
- if (l.type === "run_error")
420
- throw new Error(l.error);
421
- if (await st(e, l, h), await L(), l.type === "run_completed")
422
- return l.sessionPatch && P().applySessionPatch(l.sessionPatch), {
423
- command: null,
424
- memoryReplay: l.memoryReplay ?? null,
425
- memoryDecision: l.memoryDecision ?? null,
426
- assistantReply: l.assistantReply
427
- };
428
470
  }
471
+ } catch (g) {
472
+ if (n?.aborted || !gt(g)) throw g;
473
+ _ = !0;
474
+ } finally {
475
+ P.releaseLock();
429
476
  }
430
- } finally {
431
- w.releaseLock();
477
+ if (!_ || n?.aborted) return { command: null };
478
+ if (C += 1, C > ct)
479
+ throw new Error("Spotlight 后端事件流多次重连失败,请重试。");
480
+ await mt(ft(C - 1));
432
481
  }
433
- return {
434
- command: null
435
- };
436
482
  }
437
- async function $(t) {
483
+ function gt(t) {
484
+ return t instanceof TypeError || t instanceof DOMException;
485
+ }
486
+ async function q(t) {
438
487
  await fetch(
439
- `${_()}/v1/runs/${encodeURIComponent(t)}`,
488
+ `${T()}/v1/runs/${encodeURIComponent(t)}`,
440
489
  {
441
490
  method: "DELETE",
442
- headers: S()
491
+ headers: w()
443
492
  }
444
493
  );
445
494
  }
446
- function It(t) {
495
+ function xt(t) {
447
496
  if (!t) return;
448
- const e = I.get(t);
449
- e && (I.delete(t), $(e));
497
+ const e = N.get(t);
498
+ e && (N.delete(t), q(e));
450
499
  }
451
500
  export {
452
- et as applyLangGraphTransition,
453
- st as applyRemoteEvent,
454
- v as beginHostToolCall,
455
- $ as cancelRemoteSpotlightRun,
456
- It as cancelRemoteSpotlightRunForSignal,
457
- Tt as runRemoteSpotlightPipeline,
458
- tt as settleHostToolCall,
459
- ht as warmupSpotlightRemoteContext
501
+ rt as applyLangGraphTransition,
502
+ at as applyRemoteEvent,
503
+ nt as beginHostToolCall,
504
+ q as cancelRemoteSpotlightRun,
505
+ xt as cancelRemoteSpotlightRunForSignal,
506
+ Pt as runRemoteSpotlightPipeline,
507
+ ot as settleHostToolCall,
508
+ kt as warmupSpotlightRemoteContext
460
509
  };
@@ -14,6 +14,11 @@ export declare function composeToolStepContent(planning: string, answer: string)
14
14
  * 最终回答和流式回答都必须经过这里,避免中途把内部材料渲染给用户。
15
15
  */
16
16
  export declare function sanitizeToolStepAnswerText(content: string): string;
17
+ /**
18
+ * Strip vendor evidence labels from displayed text.
19
+ * Never wipe the whole answer just because a label appears inside it.
20
+ */
21
+ export declare function stripInternalEvidenceAnswer(text: string): string;
17
22
  export interface GatherProcessDisplay {
18
23
  headline: string;
19
24
  items: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"displayText.d.ts","sourceRoot":"","sources":["../../../src/store/pipeline/displayText.ts"],"names":[],"mappings":"AAeA,kEAAkE;AAClE,eAAO,MAAM,0BAA0B,qCAAqC,CAAC;AAE7E,8CAA8C;AAC9C,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAOpE;AAoCD,yCAAyC;AACzC,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG;IACrD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,CAeA;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAelE;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAMD;;;GAGG;AACH,wBAAgB,yBAAyB,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