@inupedia/spotlight-vue 0.5.19 → 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,4 +1,4 @@
1
- import type { HostToolEffect, SpotlightMemoryDecision, ToolSideEffectV1 } from "@inupedia/spotlight-protocol";
1
+ import type { HostToolEffect, SpotlightMemoryDecision, SpotlightRunStatus, SpotlightRunSummary, ToolSideEffectV1 } from "@inupedia/spotlight-protocol";
2
2
  import type { HandlerApi } from "../store/pipeline/types.js";
3
3
  import type { SpotlightExecutionEvent } from "../store/runtime/types.js";
4
4
  import { executeRemoteHostTool } from "./hostToolRunner.js";
@@ -16,7 +16,15 @@ type RemoteRunEvent = SpotlightExecutionEvent | {
16
16
  displayName: string;
17
17
  };
18
18
  hostEffect?: HostToolEffect;
19
+ /** >1 means the server is re-sending this call after a lost connection. */
20
+ dispatch?: number;
19
21
  };
22
+ } | {
23
+ type: "run_status";
24
+ at: number;
25
+ runId: string;
26
+ status: SpotlightRunStatus;
27
+ detail?: string;
20
28
  } | {
21
29
  type: "run_completed";
22
30
  at: number;
@@ -27,6 +35,7 @@ type RemoteRunEvent = SpotlightExecutionEvent | {
27
35
  stopReason: string;
28
36
  failureClass: string | null;
29
37
  elapsedMs: number;
38
+ summary?: SpotlightRunSummary;
30
39
  memoryReplay?: {
31
40
  source: "exact" | "semantic" | "session";
32
41
  entryId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"runPipeline.d.ts","sourceRoot":"","sources":["../../src/remote/runPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAetC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGzE,OAAO,EAEL,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AAO7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AA0B,CAC9C,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GACzC,OAAO,CAAC,2BAA2B,CAAC,CA0GtC;AAOD,wBAAsB,wBAAwB,CAAC,KAAK,EAAE,MAAM,iBAQ3D;AAED,wBAAgB,iCAAiC,CAAC,MAAM,CAAC,EAAE,WAAW,QAMrE"}
@@ -1,58 +1,58 @@
1
- import { serializeSkillsForRemote as H } from "@inupedia/spotlight-client";
2
- import { useAgentSessionStore as E } 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 x, resolveToolLane as j, toolLaneStepLabel as B } from "../store/pipeline/toolLane.js";
8
- import { getSpotlightConfig as N } from "../plugin.js";
9
- import { getSkillsPoolForRun as W } from "../skills/index.js";
10
- import { executeRemoteHostTool as z, ensureHostToolsManifest as L } from "./hostToolRunner.js";
11
- import { getSpotlightServerBase as w, buildSpotlightJsonHeaders as h, getSpotlightProjectId as G } from "./httpConfig.js";
12
- import { ensureSpotlightMeta as U } from "./meta.js";
13
- const C = /* @__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, n) {
17
+ function u(t, e, o) {
18
18
  const s = t.getSteps().find((a) => a.id === e);
19
19
  if (s) return s;
20
- const o = { id: e, label: n, status: "pending" };
21
- return t.setSteps([...t.getSteps(), o]), o;
20
+ const n = { id: e, label: o, status: "pending" };
21
+ return t.setSteps([...t.getSteps(), n]), n;
22
22
  }
23
- function $() {
23
+ function O() {
24
24
  return new Promise((t) => {
25
25
  requestAnimationFrame(() => t());
26
26
  });
27
27
  }
28
- function Y(t) {
29
- return Array.isArray(t) ? t.flatMap((n, s) => {
30
- if (!n || typeof n != "object") return [];
31
- const o = n, a = typeof o.content == "string" ? o.content.trim() : "";
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
32
  if (!a) return [];
33
- const i = typeof o.title == "string" && o.title.trim() || typeof o.url == "string" && o.url.trim() || `资料 ${s + 1}`, m = typeof o.url == "string" ? o.url.trim() : "";
34
- return [[i, m && m !== i ? m : "", a].filter(Boolean).join(`
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
35
  `)];
36
36
  }).join(`
37
37
 
38
38
  `) : "";
39
39
  }
40
- function K(t) {
41
- const e = Y(t.output);
40
+ function Z(t) {
41
+ const e = X(t.output);
42
42
  if (e) return e;
43
- const n = t.summary?.trim();
44
- if (n && n.length > 48 && !n.startsWith("{") && !n.startsWith("["))
45
- return n;
43
+ const o = t.summary?.trim();
44
+ if (o && o.length > 48 && !o.startsWith("{") && !o.startsWith("["))
45
+ return o;
46
46
  if (t.output != null && typeof t.output == "object")
47
47
  try {
48
48
  const s = JSON.stringify(t.output, null, 2);
49
49
  if (s && s !== "{}") return s;
50
50
  } catch {
51
51
  }
52
- return n || "";
52
+ return o || "";
53
53
  }
54
- function Q(t) {
55
- const e = K(t.result);
54
+ function v(t) {
55
+ const e = Z(t.result);
56
56
  return {
57
57
  id: t.result.call.id,
58
58
  name: t.result.call.name,
@@ -65,7 +65,7 @@ function Q(t) {
65
65
  status: t.result.success ? "done" : "error"
66
66
  };
67
67
  }
68
- function X(t) {
68
+ function tt(t) {
69
69
  return {
70
70
  id: t.call.id,
71
71
  name: t.call.name,
@@ -74,40 +74,40 @@ function X(t) {
74
74
  status: "running"
75
75
  };
76
76
  }
77
- function Z(t, e) {
78
- const n = e.success ? "前端操作已执行。" : e.error || "前端操作执行失败。";
77
+ function et(t, e) {
78
+ const o = e.success ? "前端操作已执行。" : e.error || "前端操作执行失败。";
79
79
  return {
80
80
  id: t.id,
81
81
  name: t.name,
82
82
  displayName: t.displayName,
83
83
  argsText: JSON.stringify(t.input ?? {}, null, 2),
84
- resultText: n,
85
- summary: n,
84
+ resultText: o,
85
+ summary: o,
86
86
  errorCode: e.errorCode,
87
87
  trace: e.trace,
88
88
  status: e.success ? "done" : "error"
89
89
  };
90
90
  }
91
- function v(t, e) {
92
- return j(t, e?.sideEffectByName?.get(t));
91
+ function st(t, e) {
92
+ return U(t, e?.sideEffectByName?.get(t));
93
93
  }
94
- function c(t, e, n) {
95
- const s = t.getSteps().find((o) => o.id === e);
96
- !s || s.status === "done" || s.status === "error" || t.setStep(e, "done", s.content ?? n);
94
+ function d(t, e, o) {
95
+ const s = t.getSteps().find((n) => n.id === e);
96
+ !s || s.status === "done" || s.status === "error" || t.setStep(e, "done", s.content ?? o);
97
97
  }
98
- function _(t, e) {
99
- c(t, r.understand);
100
- const n = x(e), s = B(e);
101
- d(t, n, s);
102
- const o = t.getSteps().find((a) => a.id === n);
103
- !o || o.status === "active" || o.status === "done" || t.setStep(n, "active", o.content);
98
+ function R(t, e) {
99
+ d(t, r.understand);
100
+ const o = M(e), s = z(e);
101
+ u(t, o, s);
102
+ const n = t.getSteps().find((a) => a.id === o);
103
+ !n || n.status === "active" || n.status === "done" || t.setStep(o, "active", n.content);
104
104
  }
105
- function p(t, e, n) {
106
- const s = v(e, n);
107
- return _(t, s), x(s);
105
+ function S(t, e, o) {
106
+ const s = st(e, o);
107
+ return R(t, s), M(s);
108
108
  }
109
- function tt(t, e, n) {
110
- const s = p(t, e.name, n);
109
+ function nt(t, e, o) {
110
+ const s = S(t, e.name, o);
111
111
  t.appendToolCallsToStep(s, [
112
112
  {
113
113
  id: e.id,
@@ -118,78 +118,78 @@ function tt(t, e, n) {
118
118
  }
119
119
  ]);
120
120
  }
121
- function et(t, e, n, s) {
122
- const o = p(t, e.name, s);
123
- t.appendToolCallsToStep(o, [Z(e, n)]);
121
+ function ot(t, e, o, s) {
122
+ const n = S(t, e.name, s);
123
+ t.appendToolCallsToStep(n, [et(e, o)]);
124
124
  }
125
- function P(t, e) {
125
+ function b(t, e) {
126
126
  return e || (t === r.gather ? "获取信息" : t === r.act ? "操作页面" : t === r.answer ? "回答" : t === r.understand ? "理解问题" : t === r.tool ? "获取信息" : t);
127
127
  }
128
- function f(t, e, n, s, o) {
129
- d(t, e, n), t.setStep(e, s, o);
128
+ function y(t, e, o, s, n) {
129
+ u(t, e, o), t.setStep(e, s, n);
130
130
  }
131
- function st(t, e) {
132
- const n = e.summary?.trim();
131
+ function rt(t, e) {
132
+ const o = e.summary?.trim();
133
133
  switch (e.phase) {
134
134
  case "routing":
135
135
  case "analyzing":
136
- f(
136
+ y(
137
137
  t,
138
138
  r.understand,
139
139
  "理解问题",
140
140
  "active",
141
- n ?? "正在分析用户意图。"
141
+ o ?? "正在分析用户意图。"
142
142
  );
143
143
  return;
144
144
  case "router_done":
145
- f(
145
+ y(
146
146
  t,
147
147
  r.understand,
148
148
  "理解问题",
149
149
  "done",
150
- n ?? "意图分析已完成。"
150
+ o ?? "意图分析已完成。"
151
151
  );
152
152
  return;
153
153
  case "knowledge_agent_start":
154
- c(t, r.understand), f(
154
+ d(t, r.understand), y(
155
155
  t,
156
156
  r.gather,
157
157
  "获取信息",
158
158
  "active",
159
- n ?? "正在检索资料。"
159
+ o ?? "正在检索资料。"
160
160
  );
161
161
  return;
162
162
  case "knowledge_agent_done":
163
- c(
163
+ d(
164
164
  t,
165
165
  r.gather,
166
- n ?? "资料已就绪。"
166
+ o ?? "资料已就绪。"
167
167
  );
168
168
  return;
169
169
  case "action_agent_start":
170
- c(t, r.understand);
170
+ d(t, r.understand);
171
171
  return;
172
172
  case "action_agent_done":
173
- c(t, r.gather), c(
173
+ d(t, r.gather), d(
174
174
  t,
175
175
  r.act,
176
- n ?? "页面操作已完成。"
176
+ o ?? "页面操作已完成。"
177
177
  );
178
178
  return;
179
179
  case "memory_replay":
180
- f(
180
+ y(
181
181
  t,
182
182
  r.understand,
183
183
  "理解问题",
184
184
  "done",
185
- n ?? "已复用项目记忆,跳过本轮检索。"
185
+ o ?? "已复用项目记忆,跳过本轮检索。"
186
186
  );
187
187
  return;
188
188
  default:
189
189
  return;
190
190
  }
191
191
  }
192
- async function ot(t, e, n) {
192
+ async function at(t, e, o) {
193
193
  if (e.type !== "ping") {
194
194
  if (e.type === "step_sync")
195
195
  t.setSteps(
@@ -197,46 +197,46 @@ async function ot(t, e, n) {
197
197
  id: s.id,
198
198
  label: s.label,
199
199
  status: s.status,
200
- content: t.getSteps().find((o) => o.id === s.id)?.content
200
+ content: t.getSteps().find((n) => n.id === s.id)?.content
201
201
  }))
202
202
  );
203
203
  else if (e.type === "step_status")
204
- 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);
205
205
  else if (e.type === "step_content") {
206
- let s = e.stepId, o = e.content;
207
- if ((s === r.intent || s === r.understand) && F(o))
206
+ let s = e.stepId, n = e.content;
207
+ if ((s === r.intent || s === r.understand) && B(n))
208
208
  s = r.gather;
209
209
  else if ((s === r.intent || s === r.understand) && e.mode === "replace") {
210
- const { intent: a, misplacedPlanning: i } = J(o);
211
- o = 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(
212
212
  r.gather,
213
213
  i
214
214
  ));
215
215
  }
216
- if (d(t, s, P(s, e.label)), e.mode === "replace")
216
+ if (u(t, s, b(s, e.label)), e.mode === "replace")
217
217
  t.setStep(
218
218
  s,
219
219
  t.getSteps().find((a) => a.id === s)?.status ?? "active",
220
- o
220
+ n
221
221
  );
222
222
  else {
223
223
  if (s === r.tool || s === r.gather || s === r.act) {
224
224
  const a = s === r.act ? "act" : "gather";
225
- _(t, a);
225
+ R(t, a);
226
226
  }
227
- t.appendChunkToStep(s, o), await $();
227
+ t.appendChunkToStep(s, n), await O();
228
228
  }
229
229
  } else if (e.type === "step_artifact") {
230
230
  const s = e.stepId === r.tool ? r.gather : e.stepId;
231
- d(t, s, P(s, e.label)), (s === r.gather || s === r.act) && _(
231
+ u(t, s, b(s, e.label)), (s === r.gather || s === r.act) && R(
232
232
  t,
233
233
  s === r.act ? "act" : "gather"
234
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);
235
235
  } else if (e.type === "tool_start") {
236
- const s = p(t, e.call.name, n);
237
- t.appendToolCallsToStep(s, [X(e)]);
236
+ const s = S(t, e.call.name, o);
237
+ t.appendToolCallsToStep(s, [tt(e)]);
238
238
  } else if (e.type === "tool_progress") {
239
- const s = p(t, e.call.name, n);
239
+ const s = S(t, e.call.name, o);
240
240
  t.appendToolCallsToStep(s, [
241
241
  {
242
242
  id: e.call.id,
@@ -248,8 +248,8 @@ async function ot(t, e, n) {
248
248
  }
249
249
  ]);
250
250
  } else if (e.type === "tool_result") {
251
- const s = p(t, e.result.call.name, n);
252
- t.appendToolCallsToStep(s, [Q(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);
253
253
  } else if (e.type === "skill_permission_request") {
254
254
  const { useSpotlightStore: s } = await import("../store/spotlightStore.js");
255
255
  s().setPendingSkillPermission({
@@ -261,83 +261,114 @@ async function ot(t, e, n) {
261
261
  });
262
262
  } else if (e.type === "fork_progress") {
263
263
  const s = r.gather;
264
- d(t, s, "获取信息"), t.appendChunkToStep(
264
+ u(t, s, "获取信息"), t.appendChunkToStep(
265
265
  s,
266
266
  `
267
267
  [fork ${e.agentId}] 第 ${e.iteration} 轮 · ${e.phase}:${e.summary}
268
268
  `
269
269
  );
270
270
  } else if (e.type === "turn_transition")
271
- st(t, e);
271
+ rt(t, e);
272
272
  else if (e.type === "memory_decision") {
273
273
  const s = {
274
274
  reuse: "已复用项目记忆",
275
275
  augment: "正在结合历史项目结论",
276
276
  refresh: "资料可能变化,正在重新验证",
277
277
  ignore: "未发现可直接使用的项目记忆"
278
- }, o = t.getSteps().find((i) => i.id === r.understand), a = e.decision.action === "reuse" || o?.status === "done" ? "done" : "active";
279
- f(
278
+ }, n = t.getSteps().find((i) => i.id === r.understand), a = e.decision.action === "reuse" || n?.status === "done" ? "done" : "active";
279
+ y(
280
280
  t,
281
281
  r.understand,
282
282
  "理解问题",
283
283
  a,
284
284
  s[e.decision.action]
285
285
  );
286
- } 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(
287
295
  r.answer,
288
296
  "done",
289
297
  e.content.trim()
290
298
  ));
291
- V(e) && t.appendExecutionEvent?.(e);
299
+ Q(e) && t.appendExecutionEvent?.(e);
292
300
  }
293
301
  }
294
- async function nt(t) {
302
+ async function it(t) {
295
303
  await fetch(
296
- `${w()}/v1/runs/${encodeURIComponent(t.runId)}/host-results`,
304
+ `${T()}/v1/runs/${encodeURIComponent(t.runId)}/host-results`,
297
305
  {
298
306
  method: "POST",
299
- headers: h(),
307
+ headers: w(),
300
308
  body: JSON.stringify({
301
309
  correlationId: t.correlationId,
302
310
  success: t.result.success,
303
311
  output: t.result.data,
304
312
  error: t.result.error,
305
313
  errorCode: t.result.errorCode,
306
- 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
307
318
  }),
308
319
  signal: t.signal
309
320
  }
310
321
  );
311
322
  }
312
- function rt(t) {
313
- const e = t.split(/\n\n/u), n = e.pop() ?? "";
314
- return { events: e.flatMap((o) => {
315
- const a = o.split(/\n/u).find((i) => i.startsWith("data: "));
316
- if (!a) return [];
323
+ function lt(t) {
324
+ const e = t.split(/\n\n/u), o = e.pop() ?? "";
325
+ return { events: e.flatMap((n) => {
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;
317
329
  try {
318
- return [JSON.parse(a.slice(6))];
330
+ const c = JSON.parse(i.slice(6));
331
+ return [Number.isFinite(p) ? { ...c, seq: p } : c];
319
332
  } catch {
320
333
  return [];
321
334
  }
322
- }), rest: n };
335
+ }), rest: o };
336
+ }
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;
323
348
  }
324
- async function Tt(t) {
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) {
325
356
  await Promise.allSettled([
326
- L(),
327
- U(t)
357
+ A(),
358
+ K(t)
328
359
  ]);
329
360
  }
330
- async function at(t, e, n) {
331
- const s = E(), o = D(), a = q(), i = await L();
361
+ async function pt(t, e, o) {
362
+ const s = L(), n = j(), a = J(), i = await A();
332
363
  return {
333
364
  hostManifest: i,
334
365
  payload: {
335
- projectId: G(),
366
+ projectId: Y(),
336
367
  sessionId: s.sessionId,
337
- memorySubjectId: N().getMemorySubjectId?.() ?? void 0,
368
+ memorySubjectId: E().getMemorySubjectId?.() ?? void 0,
338
369
  userQuestion: t,
339
- memoryRefreshRequested: n?.forceMemoryRefresh === !0,
340
- uiContext: N().getUiContext?.() ?? {},
370
+ memoryRefreshRequested: o?.forceMemoryRefresh === !0,
371
+ uiContext: E().getUiContext?.() ?? {},
341
372
  sessionState: {
342
373
  sessionId: s.sessionId,
343
374
  activeTaskId: s.activeTaskId,
@@ -354,121 +385,125 @@ async function at(t, e, n) {
354
385
  memoryWriteEnabled: !0
355
386
  },
356
387
  runtimeState: {
357
- activeDomain: o.activeDomain,
358
- activeTarget: o.activeTarget,
359
- activeAction: o.activeAction,
360
- resumableAction: o.resumableAction,
361
- lastResolvedTarget: o.lastResolvedTarget
388
+ activeDomain: n.activeDomain,
389
+ activeTarget: n.activeTarget,
390
+ activeAction: n.activeAction,
391
+ resumableAction: n.resumableAction,
392
+ lastResolvedTarget: n.lastResolvedTarget
362
393
  },
363
394
  clientToolsManifestVersion: i.manifestDigest,
364
395
  clientToolManifest: i,
365
- skills: H(W()),
396
+ skills: F(G()),
366
397
  frontendBuildId: i.frontendBuildId,
367
398
  manifestDigest: i.manifestDigest
368
399
  }
369
400
  };
370
401
  }
371
- async function It(t, e, n) {
372
- const s = w(), o = e.getSignal(), { payload: a, hostManifest: i } = await at(
402
+ async function Pt(t, e, o) {
403
+ const s = T(), n = e.getSignal(), { payload: a, hostManifest: i } = await pt(
373
404
  t,
374
- o,
375
- n
376
- ), m = new Set(i.tools.map((u) => u.name)), T = {
405
+ n,
406
+ o
407
+ ), f = new Set(i.tools.map((m) => m.name)), p = {
377
408
  sideEffectByName: new Map(
378
- i.tools.map((u) => [u.name, u.sideEffect])
409
+ i.tools.map((m) => [m.name, m.sideEffect])
379
410
  )
380
- }, g = await fetch(`${s}/v1/runs`, {
411
+ }, c = await fetch(`${s}/v1/runs`, {
381
412
  method: "POST",
382
- headers: h(),
413
+ headers: w(),
383
414
  body: JSON.stringify(a),
384
- signal: o
415
+ signal: n
385
416
  });
386
- if (!g.ok) {
387
- const u = await g.text().catch(() => "");
417
+ if (!c.ok) {
418
+ const m = await c.text().catch(() => "");
388
419
  throw new Error(
389
- `Spotlight 后端创建 run 失败:${g.status} ${u}`
420
+ `Spotlight 后端创建 run 失败:${c.status} ${m}`
390
421
  );
391
422
  }
392
- const { runId: y } = await g.json();
393
- o && (C.set(o, y), o.addEventListener(
423
+ const { runId: h } = await c.json();
424
+ n && (N.set(n, h), n.addEventListener(
394
425
  "abort",
395
426
  () => {
396
- A(y);
427
+ q(h);
397
428
  },
398
429
  { once: !0 }
399
430
  ));
400
- const S = await fetch(
401
- `${s}/v1/runs/${encodeURIComponent(y)}/events`,
402
- {
403
- headers: h(),
404
- signal: o
405
- }
406
- );
407
- if (!S.ok || !S.body)
408
- throw new Error(`Spotlight 后端事件流连接失败:${S.status}`);
409
- const R = S.body.getReader(), M = new TextDecoder();
410
- let I = "";
411
- try {
412
- for (; ; ) {
413
- const { done: u, value: O } = await R.read();
414
- if (u) break;
415
- I += M.decode(O, { stream: !0 });
416
- const b = rt(I);
417
- I = b.rest;
418
- for (const l of b.events) {
419
- if (l.type === "host_action_request") {
420
- tt(e, l.request.call, T);
421
- const k = await z(l.request.call, e, {
422
- allowedHostNames: m,
423
- hostEffect: l.request.hostEffect
424
- });
425
- et(e, l.request.call, k, T), await nt({
426
- runId: y,
427
- correlationId: l.request.correlationId,
428
- result: k,
429
- signal: o
430
- });
431
- 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
+ };
432
469
  }
433
- if (l.type === "run_error")
434
- throw new Error(l.error);
435
- if (await ot(e, l, T), await $(), l.type === "run_completed")
436
- return l.sessionPatch && E().applySessionPatch(l.sessionPatch), {
437
- command: null,
438
- memoryReplay: l.memoryReplay ?? null,
439
- memoryDecision: l.memoryDecision ?? null,
440
- assistantReply: l.assistantReply
441
- };
442
470
  }
471
+ } catch (g) {
472
+ if (n?.aborted || !gt(g)) throw g;
473
+ _ = !0;
474
+ } finally {
475
+ P.releaseLock();
443
476
  }
444
- } finally {
445
- R.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));
446
481
  }
447
- return {
448
- command: null
449
- };
450
482
  }
451
- async function A(t) {
483
+ function gt(t) {
484
+ return t instanceof TypeError || t instanceof DOMException;
485
+ }
486
+ async function q(t) {
452
487
  await fetch(
453
- `${w()}/v1/runs/${encodeURIComponent(t)}`,
488
+ `${T()}/v1/runs/${encodeURIComponent(t)}`,
454
489
  {
455
490
  method: "DELETE",
456
- headers: h()
491
+ headers: w()
457
492
  }
458
493
  );
459
494
  }
460
- function Ct(t) {
495
+ function xt(t) {
461
496
  if (!t) return;
462
- const e = C.get(t);
463
- e && (C.delete(t), A(e));
497
+ const e = N.get(t);
498
+ e && (N.delete(t), q(e));
464
499
  }
465
500
  export {
466
- st as applyLangGraphTransition,
467
- ot as applyRemoteEvent,
468
- tt as beginHostToolCall,
469
- A as cancelRemoteSpotlightRun,
470
- Ct as cancelRemoteSpotlightRunForSignal,
471
- It as runRemoteSpotlightPipeline,
472
- et as settleHostToolCall,
473
- Tt 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
474
509
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inupedia/spotlight-vue",
3
- "version": "0.5.19",
3
+ "version": "0.6.0",
4
4
  "description": "Thin Vue runtime for Inupedia Spotlight Client Tools",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -91,8 +91,8 @@
91
91
  "dependencies": {
92
92
  "prettier": "^3.8.1",
93
93
  "yaml": "^2.8.4",
94
- "@inupedia/spotlight-protocol": "0.5.19",
95
- "@inupedia/spotlight-client": "0.5.19"
94
+ "@inupedia/spotlight-protocol": "0.6.0",
95
+ "@inupedia/spotlight-client": "0.6.0"
96
96
  },
97
97
  "peerDependencies": {
98
98
  "@inspira-ui/plugins": "^0.0.2",