@inupedia/spotlight-vue 0.5.16 → 0.5.17

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,474 +1,460 @@
1
- import { serializeSkillsForRemote as M } from "@inupedia/spotlight-client";
2
- import { useAgentSessionStore as R } from "../session/agentSession.js";
3
- import { useSpotlightMemoryPreferenceStore as $ } from "../store/memoryPreferenceStore.js";
4
- import { useSpotlightRuntimeStore as L } from "../store/runtimeStore.js";
5
- import { SPOTLIGHT_PIPELINE_STEP_IDS as s } from "../store/pipeline/constants.js";
6
- import { isLoopPlanningChunk as H, splitIntentStepContent as O, splitToolStepContent as q, composeToolStepContent as D } from "../store/pipeline/displayText.js";
7
- import { getSpotlightConfig as b } from "../plugin.js";
8
- import { getSkillsPoolForRun as J } from "../skills/index.js";
9
- import { executeRemoteHostTool as F, ensureHostToolsManifest as N } from "./hostToolRunner.js";
10
- import { getSpotlightServerBase as C, buildSpotlightJsonHeaders as y, getSpotlightProjectId as j } from "./httpConfig.js";
11
- import { ensureSpotlightMeta as W } from "./meta.js";
12
- const T = /* @__PURE__ */ new WeakMap();
13
- function z(e) {
14
- return e.type !== "host_action_request" && e.type !== "run_completed" && e.type !== "run_error" && e.type !== "ping" && e.type !== "memory_decision";
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";
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";
15
16
  }
16
- function c(e, t, o) {
17
- const n = e.getSteps().find((l) => l.id === t);
18
- if (n) return n;
19
- const r = { id: t, label: o, status: "pending" };
20
- return e.setSteps([...e.getSteps(), r]), r;
17
+ function d(t, e, o) {
18
+ const s = t.getSteps().find((a) => a.id === e);
19
+ if (s) return s;
20
+ const n = { id: e, label: o, status: "pending" };
21
+ return t.setSteps([...t.getSteps(), n]), n;
21
22
  }
22
- function P() {
23
- return new Promise((e) => {
24
- requestAnimationFrame(() => e());
23
+ function L() {
24
+ return new Promise((t) => {
25
+ requestAnimationFrame(() => t());
25
26
  });
26
27
  }
27
- function B(e) {
28
- const t = e.summary?.trim();
29
- if (t && t.length > 48 && !t.startsWith("{") && !t.startsWith("["))
30
- return t;
31
- if (e.output != null && typeof e.output == "object")
28
+ function Y(t) {
29
+ const e = t.summary?.trim();
30
+ if (e && e.length > 48 && !e.startsWith("{") && !e.startsWith("["))
31
+ return e;
32
+ if (t.output != null && typeof t.output == "object")
32
33
  try {
33
- const o = JSON.stringify(e.output, null, 2);
34
+ const o = JSON.stringify(t.output, null, 2);
34
35
  if (o && o !== "{}") return o;
35
36
  } catch {
36
37
  }
37
- return t || "";
38
+ return e || "";
38
39
  }
39
- function G(e) {
40
- const t = B(e.result);
40
+ function K(t) {
41
+ const e = Y(t.result);
41
42
  return {
42
- id: e.result.call.id,
43
- name: e.result.call.name,
44
- displayName: e.result.call.displayName,
45
- argsText: JSON.stringify(e.result.call.input ?? {}, null, 2),
46
- resultText: t,
47
- summary: e.result.summary,
48
- errorCode: e.result.errorCode,
49
- trace: e.result.trace,
50
- status: e.result.success ? "done" : "error"
43
+ id: t.result.call.id,
44
+ name: t.result.call.name,
45
+ displayName: t.result.call.displayName,
46
+ argsText: JSON.stringify(t.result.call.input ?? {}, null, 2),
47
+ resultText: e,
48
+ summary: t.result.summary,
49
+ errorCode: t.result.errorCode,
50
+ trace: t.result.trace,
51
+ status: t.result.success ? "done" : "error"
51
52
  };
52
53
  }
53
- function U(e) {
54
+ function Q(t) {
54
55
  return {
55
- id: e.call.id,
56
- name: e.call.name,
57
- displayName: e.call.displayName,
58
- argsText: JSON.stringify(e.call.input ?? {}, null, 2),
56
+ id: t.call.id,
57
+ name: t.call.name,
58
+ displayName: t.call.displayName,
59
+ argsText: JSON.stringify(t.call.input ?? {}, null, 2),
59
60
  status: "running"
60
61
  };
61
62
  }
62
- function V(e, t) {
63
- const o = t.success ? "前端操作已执行。" : t.error || "前端操作执行失败。";
63
+ function X(t, e) {
64
+ const o = e.success ? "前端操作已执行。" : e.error || "前端操作执行失败。";
64
65
  return {
65
- id: e.id,
66
- name: e.name,
67
- displayName: e.displayName,
68
- argsText: JSON.stringify(e.input ?? {}, null, 2),
66
+ id: t.id,
67
+ name: t.name,
68
+ displayName: t.displayName,
69
+ argsText: JSON.stringify(t.input ?? {}, null, 2),
69
70
  resultText: o,
70
71
  summary: o,
71
- errorCode: t.errorCode,
72
- trace: t.trace,
73
- status: t.success ? "done" : "error"
72
+ errorCode: e.errorCode,
73
+ trace: e.trace,
74
+ status: e.success ? "done" : "error"
74
75
  };
75
76
  }
76
- function Y(e, t) {
77
- c(e, s.tool, "执行工具与回答"), d(e, s.tool), e.appendToolCallsToStep(s.tool, [
77
+ function Z(t, e) {
78
+ return j(t, e?.sideEffectByName?.get(t));
79
+ }
80
+ function c(t, e, o) {
81
+ const s = t.getSteps().find((n) => n.id === e);
82
+ !s || s.status === "done" || s.status === "error" || t.setStep(e, "done", s.content ?? o);
83
+ }
84
+ function C(t, e) {
85
+ c(t, r.understand);
86
+ const o = E(e), s = B(e);
87
+ d(t, o, s);
88
+ const n = t.getSteps().find((a) => a.id === o);
89
+ !n || n.status === "active" || n.status === "done" || t.setStep(o, "active", n.content);
90
+ }
91
+ function f(t, e, o) {
92
+ const s = Z(e, o);
93
+ return C(t, s), E(s);
94
+ }
95
+ function v(t, e, o) {
96
+ const s = f(t, e.name, o);
97
+ t.appendToolCallsToStep(s, [
78
98
  {
79
- id: t.id,
80
- name: t.name,
81
- displayName: t.displayName,
82
- argsText: JSON.stringify(t.input ?? {}, null, 2),
99
+ id: e.id,
100
+ name: e.name,
101
+ displayName: e.displayName,
102
+ argsText: JSON.stringify(e.input ?? {}, null, 2),
83
103
  status: "running"
84
104
  }
85
105
  ]);
86
106
  }
87
- function K(e, t, o) {
88
- c(e, s.tool, "执行工具与回答"), d(e, s.tool), e.appendToolCallsToStep(s.tool, [
89
- V(t, o)
90
- ]);
91
- }
92
- function Q(e) {
93
- const t = e.getSteps().find(
94
- (o) => o.id === s.agent && o.label === "选择工具" && o.status === "active"
95
- );
96
- t && e.setStep(
97
- s.agent,
98
- "done",
99
- t.content ?? "工具选择与调用已完成。"
100
- );
101
- }
102
- function d(e, t) {
103
- if (t !== s.tool) return;
104
- Q(e);
105
- const o = e.getSteps().find((n) => n.id === t);
106
- !o || o.status === "active" || o.status === "done" || e.setStep(t, "active", o.content);
107
+ function tt(t, e, o, s) {
108
+ const n = f(t, e.name, s);
109
+ t.appendToolCallsToStep(n, [X(e, o)]);
107
110
  }
108
- function k(e, t) {
109
- return t || (e === s.tool ? "执行工具与回答" : e);
111
+ function N(t, e) {
112
+ return e || (t === r.gather ? "获取信息" : t === r.act ? "操作页面" : t === r.answer ? "回答" : t === r.understand ? "理解问题" : t === r.tool ? "获取信息" : t);
110
113
  }
111
- function X(e) {
112
- const t = e.getSteps().find((o) => o.id === s.agent);
113
- return t?.label === "检索知识" ? "知识问答" : t?.label === "选择工具" ? "执行工具与回答" : "生成回答";
114
+ function m(t, e, o, s, n) {
115
+ d(t, e, o), t.setStep(e, s, n);
114
116
  }
115
- function u(e, t, o, n, r) {
116
- c(e, t, o), e.setStep(t, n, r);
117
- }
118
- function Z(e, t) {
119
- const o = t.summary?.trim();
120
- switch (t.phase) {
117
+ function et(t, e) {
118
+ const o = e.summary?.trim();
119
+ switch (e.phase) {
121
120
  case "routing":
122
121
  case "analyzing":
123
- u(
124
- e,
125
- s.intent,
126
- "分析意图",
122
+ m(
123
+ t,
124
+ r.understand,
125
+ "理解问题",
127
126
  "active",
128
127
  o ?? "正在分析用户意图。"
129
128
  );
130
129
  return;
131
130
  case "router_done":
132
- u(
133
- e,
134
- s.intent,
135
- "分析意图",
131
+ m(
132
+ t,
133
+ r.understand,
134
+ "理解问题",
136
135
  "done",
137
136
  o ?? "意图分析已完成。"
138
137
  );
139
138
  return;
140
139
  case "knowledge_agent_start":
141
- u(
142
- e,
143
- s.agent,
144
- "检索知识",
140
+ c(t, r.understand), m(
141
+ t,
142
+ r.gather,
143
+ "获取信息",
145
144
  "active",
146
- o ?? "正在检索项目知识。"
145
+ o ?? "正在检索资料。"
147
146
  );
148
147
  return;
149
148
  case "knowledge_agent_done":
150
- u(
151
- e,
152
- s.agent,
153
- "检索知识",
154
- "done",
155
- o ?? "项目知识检索已完成。"
149
+ c(
150
+ t,
151
+ r.gather,
152
+ o ?? "资料已就绪。"
156
153
  );
157
154
  return;
158
155
  case "action_agent_start":
159
- u(
160
- e,
161
- s.agent,
162
- "选择工具",
163
- "active",
164
- o ?? "正在从已注册工具中选择操作。"
165
- );
156
+ c(t, r.understand);
166
157
  return;
167
158
  case "action_agent_done":
168
- u(
169
- e,
170
- s.agent,
171
- "选择工具",
172
- "done",
173
- o ?? "工具选择与调用已完成。"
159
+ c(t, r.gather), c(
160
+ t,
161
+ r.act,
162
+ o ?? "页面操作已完成。"
174
163
  );
175
164
  return;
176
165
  case "memory_replay":
177
- u(
178
- e,
179
- s.breakdown,
180
- "问题拆解",
166
+ m(
167
+ t,
168
+ r.understand,
169
+ "理解问题",
181
170
  "done",
182
- o ?? "Memory 缓存命中,跳过 LLM 规划。"
171
+ o ?? "已复用项目记忆,跳过本轮检索。"
183
172
  );
184
173
  return;
185
174
  default:
186
175
  return;
187
176
  }
188
177
  }
189
- async function v(e, t) {
190
- if (t.type !== "ping") {
191
- if (t.type === "step_sync")
192
- e.setSteps(
193
- t.steps.map((o) => ({
194
- id: o.id,
195
- label: o.label,
196
- status: o.status,
197
- content: e.getSteps().find((n) => n.id === o.id)?.content
178
+ async function st(t, e, o) {
179
+ if (e.type !== "ping") {
180
+ if (e.type === "step_sync")
181
+ t.setSteps(
182
+ e.steps.map((s) => ({
183
+ id: s.id,
184
+ label: s.label,
185
+ status: s.status,
186
+ content: t.getSteps().find((n) => n.id === s.id)?.content
198
187
  }))
199
188
  );
200
- else if (t.type === "step_status")
201
- c(e, t.stepId, t.label ?? t.stepId), e.setStep(t.stepId, t.status, t.content);
202
- else if (t.type === "step_content") {
203
- let o = t.stepId, n = t.content;
204
- if (o === s.intent && H(n))
205
- o = s.tool;
206
- else if (o === s.intent && t.mode === "replace") {
207
- const { intent: r, misplacedPlanning: l } = O(n);
208
- n = r, l.trim() && (c(e, s.tool, "执行工具与回答"), e.appendChunkToStep(
209
- s.tool,
210
- l
189
+ else if (e.type === "step_status")
190
+ d(t, e.stepId, e.label ?? e.stepId), t.setStep(e.stepId, e.status, e.content);
191
+ else if (e.type === "step_content") {
192
+ let s = e.stepId, n = e.content;
193
+ if ((s === r.intent || s === r.understand) && F(n))
194
+ s = r.gather;
195
+ 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(
198
+ r.gather,
199
+ i
211
200
  ));
212
201
  }
213
- c(e, o, k(o, t.label)), t.mode === "replace" ? e.setStep(
214
- o,
215
- e.getSteps().find((r) => r.id === o)?.status ?? "active",
216
- n
217
- ) : (d(e, o), e.appendChunkToStep(o, n), await P());
218
- } else if (t.type === "step_artifact")
219
- c(e, t.stepId, k(t.stepId, t.label)), d(e, t.stepId), t.artifact === "tool_calls" && t.toolCalls?.length ? e.appendToolCallsToStep(t.stepId, t.toolCalls) : t.artifact === "attachments" && t.attachments?.length ? e.appendAttachmentsToStep(t.stepId, t.attachments) : t.artifact === "files" && t.files?.length ? e.appendFilesToStep(t.stepId, t.files) : t.artifact === "artifacts" && t.artifacts?.length ? e.appendArtifactsToStep(t.stepId, t.artifacts) : t.artifact === "chat_items" && t.chatItems?.length && e.appendChatItemsToStep(t.stepId, t.chatItems);
220
- else if (t.type === "tool_start")
221
- c(e, s.tool, "执行工具与回答"), d(e, s.tool), e.appendToolCallsToStep(s.tool, [
222
- U(t)
223
- ]);
224
- else if (t.type === "tool_progress")
225
- c(e, s.tool, "执行工具与回答"), d(e, s.tool), e.appendToolCallsToStep(s.tool, [
202
+ if (d(t, s, N(s, e.label)), e.mode === "replace")
203
+ t.setStep(
204
+ s,
205
+ t.getSteps().find((a) => a.id === s)?.status ?? "active",
206
+ n
207
+ );
208
+ else {
209
+ if (s === r.tool || s === r.gather || s === r.act) {
210
+ const a = s === r.act ? "act" : "gather";
211
+ C(t, a);
212
+ }
213
+ t.appendChunkToStep(s, n), await L();
214
+ }
215
+ } else if (e.type === "step_artifact") {
216
+ 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(
218
+ t,
219
+ s === r.act ? "act" : "gather"
220
+ ), 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
+ } else if (e.type === "tool_start") {
222
+ const s = f(t, e.call.name, o);
223
+ t.appendToolCallsToStep(s, [Q(e)]);
224
+ } else if (e.type === "tool_progress") {
225
+ const s = f(t, e.call.name, o);
226
+ t.appendToolCallsToStep(s, [
226
227
  {
227
- id: t.call.id,
228
- name: t.call.name,
229
- displayName: t.call.displayName,
230
- argsText: JSON.stringify(t.call.input ?? {}, null, 2),
231
- summary: t.summary,
228
+ id: e.call.id,
229
+ name: e.call.name,
230
+ displayName: e.call.displayName,
231
+ argsText: JSON.stringify(e.call.input ?? {}, null, 2),
232
+ summary: e.summary,
232
233
  status: "running"
233
234
  }
234
235
  ]);
235
- else if (t.type === "tool_result")
236
- c(e, s.tool, "执行工具与回答"), d(e, s.tool), e.appendToolCallsToStep(s.tool, [
237
- G(t)
238
- ]), t.result.attachments?.length && e.appendAttachmentsToStep(
239
- s.tool,
240
- t.result.attachments
241
- ), t.result.files?.length && e.appendFilesToStep(
242
- s.tool,
243
- t.result.files
244
- ), t.result.toolCalls?.length && e.appendToolCallsToStep(
245
- s.tool,
246
- t.result.toolCalls
247
- );
248
- else if (t.type === "skill_permission_request") {
249
- const { useSpotlightStore: o } = await import("../store/spotlightStore.js");
250
- o().setPendingSkillPermission({
251
- skillName: t.skillName,
252
- displayName: t.displayName,
253
- reason: t.reason,
254
- source: t.source,
255
- at: t.at
236
+ } 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);
239
+ } else if (e.type === "skill_permission_request") {
240
+ const { useSpotlightStore: s } = await import("../store/spotlightStore.js");
241
+ s().setPendingSkillPermission({
242
+ skillName: e.skillName,
243
+ displayName: e.displayName,
244
+ reason: e.reason,
245
+ source: e.source,
246
+ at: e.at
256
247
  });
257
- } else if (t.type === "fork_progress")
258
- c(e, s.tool, "执行工具与回答"), e.appendChunkToStep(
259
- s.tool,
248
+ } else if (e.type === "fork_progress") {
249
+ const s = r.gather;
250
+ d(t, s, "获取信息"), t.appendChunkToStep(
251
+ s,
260
252
  `
261
- [fork ${t.agentId}] 第 ${t.iteration} 轮 · ${t.phase}:${t.summary}
253
+ [fork ${e.agentId}] 第 ${e.iteration} 轮 · ${e.phase}:${e.summary}
262
254
  `
263
255
  );
264
- else if (t.type === "turn_transition")
265
- Z(e, t);
266
- else if (t.type === "memory_decision") {
267
- c(e, s.breakdown, "问题拆解");
268
- const o = {
256
+ } else if (e.type === "turn_transition")
257
+ et(t, e);
258
+ else if (e.type === "memory_decision") {
259
+ const s = {
269
260
  reuse: "已复用项目记忆",
270
261
  augment: "正在结合历史项目结论",
271
262
  refresh: "资料可能变化,正在重新验证",
272
263
  ignore: "未发现可直接使用的项目记忆"
273
- };
274
- e.setStep(
275
- s.breakdown,
276
- t.decision.action === "reuse" ? "done" : "active",
277
- o[t.decision.action]
278
- );
279
- } else if (t.type === "assistant_response") {
280
- c(
281
- e,
282
- s.tool,
283
- X(e)
264
+ }, n = t.getSteps().find((i) => i.id === r.understand), a = e.decision.action === "reuse" || n?.status === "done" ? "done" : "active";
265
+ m(
266
+ t,
267
+ r.understand,
268
+ "理解问题",
269
+ a,
270
+ s[e.decision.action]
284
271
  );
285
- const o = e.getSteps().find((S) => S.id === s.tool), { planning: n, answer: r } = q(o?.content ?? ""), l = t.content.trim(), i = r.trim();
286
- i && l && (i === l || l.startsWith(
287
- i.slice(0, Math.min(i.length, 80))
288
- )) ? e.setStep(s.tool, "done") : e.setStep(
289
- s.tool,
290
- "done",
291
- D(n, l)
292
- );
293
- }
294
- z(t) && e.appendExecutionEvent?.(t);
272
+ } else e.type === "assistant_response" && (c(t, r.understand), c(t, r.gather), c(t, r.act), d(t, r.answer, "回答"), t.setStep(
273
+ r.answer,
274
+ "done",
275
+ e.content.trim()
276
+ ));
277
+ V(e) && t.appendExecutionEvent?.(e);
295
278
  }
296
279
  }
297
- async function tt(e) {
280
+ async function ot(t) {
298
281
  await fetch(
299
- `${C()}/v1/runs/${encodeURIComponent(e.runId)}/host-results`,
282
+ `${_()}/v1/runs/${encodeURIComponent(t.runId)}/host-results`,
300
283
  {
301
284
  method: "POST",
302
- headers: y(),
285
+ headers: S(),
303
286
  body: JSON.stringify({
304
- correlationId: e.correlationId,
305
- success: e.result.success,
306
- output: e.result.data,
307
- error: e.result.error,
308
- errorCode: e.result.errorCode,
309
- trace: e.result.trace
287
+ correlationId: t.correlationId,
288
+ success: t.result.success,
289
+ output: t.result.data,
290
+ error: t.result.error,
291
+ errorCode: t.result.errorCode,
292
+ trace: t.result.trace
310
293
  }),
311
- signal: e.signal
294
+ signal: t.signal
312
295
  }
313
296
  );
314
297
  }
315
- function et(e) {
316
- const t = e.split(/\n\n/u), o = t.pop() ?? "";
317
- return { events: t.flatMap((r) => {
318
- const l = r.split(/\n/u).find((i) => i.startsWith("data: "));
319
- if (!l) return [];
298
+ function nt(t) {
299
+ const e = t.split(/\n\n/u), o = e.pop() ?? "";
300
+ return { events: e.flatMap((n) => {
301
+ const a = n.split(/\n/u).find((i) => i.startsWith("data: "));
302
+ if (!a) return [];
320
303
  try {
321
- return [JSON.parse(l.slice(6))];
304
+ return [JSON.parse(a.slice(6))];
322
305
  } catch {
323
306
  return [];
324
307
  }
325
308
  }), rest: o };
326
309
  }
327
- async function ft(e) {
310
+ async function ht(t) {
328
311
  await Promise.allSettled([
329
- N(),
330
- W(e)
312
+ x(),
313
+ U(t)
331
314
  ]);
332
315
  }
333
- async function ot(e, t, o) {
334
- const n = R(), r = L(), l = $(), i = await N();
316
+ async function rt(t, e, o) {
317
+ const s = P(), n = D(), a = q(), i = await x();
335
318
  return {
336
319
  hostManifest: i,
337
320
  payload: {
338
- projectId: j(),
339
- sessionId: n.sessionId,
340
- memorySubjectId: b().getMemorySubjectId?.() ?? void 0,
341
- userQuestion: e,
321
+ projectId: G(),
322
+ sessionId: s.sessionId,
323
+ memorySubjectId: k().getMemorySubjectId?.() ?? void 0,
324
+ userQuestion: t,
342
325
  memoryRefreshRequested: o?.forceMemoryRefresh === !0,
343
- uiContext: b().getUiContext?.() ?? {},
326
+ uiContext: k().getUiContext?.() ?? {},
344
327
  sessionState: {
345
- sessionId: n.sessionId,
346
- activeTaskId: n.activeTaskId,
347
- activeTopic: n.activeTopic,
348
- pendingTask: n.pendingTask,
349
- conversationSummary: n.conversationSummary,
350
- summarizedTurnCount: n.summarizedTurnCount,
351
- conversationHistory: n.conversationHistory,
352
- lastAssistantReply: n.getLastAssistantContent(),
353
- invokedSkills: n.invokedSkills,
354
- skillPermissionGrants: n.skillPermissionGrants,
355
- memoryEnabled: l.enabled,
356
- memoryReadEnabled: l.enabled,
328
+ sessionId: s.sessionId,
329
+ activeTaskId: s.activeTaskId,
330
+ activeTopic: s.activeTopic,
331
+ pendingTask: s.pendingTask,
332
+ conversationSummary: s.conversationSummary,
333
+ summarizedTurnCount: s.summarizedTurnCount,
334
+ conversationHistory: s.conversationHistory,
335
+ lastAssistantReply: s.getLastAssistantContent(),
336
+ invokedSkills: s.invokedSkills,
337
+ skillPermissionGrants: s.skillPermissionGrants,
338
+ memoryEnabled: a.enabled,
339
+ memoryReadEnabled: a.enabled,
357
340
  memoryWriteEnabled: !0
358
341
  },
359
342
  runtimeState: {
360
- activeDomain: r.activeDomain,
361
- activeTarget: r.activeTarget,
362
- activeAction: r.activeAction,
363
- resumableAction: r.resumableAction,
364
- lastResolvedTarget: r.lastResolvedTarget
343
+ activeDomain: n.activeDomain,
344
+ activeTarget: n.activeTarget,
345
+ activeAction: n.activeAction,
346
+ resumableAction: n.resumableAction,
347
+ lastResolvedTarget: n.lastResolvedTarget
365
348
  },
366
349
  clientToolsManifestVersion: i.manifestDigest,
367
350
  clientToolManifest: i,
368
- skills: M(J()),
351
+ skills: O(W()),
369
352
  frontendBuildId: i.frontendBuildId,
370
353
  manifestDigest: i.manifestDigest
371
354
  }
372
355
  };
373
356
  }
374
- async function gt(e, t, o) {
375
- const n = C(), r = t.getSignal(), { payload: l, hostManifest: i } = await ot(
376
- e,
377
- r,
357
+ async function Tt(t, e, o) {
358
+ const s = _(), n = e.getSignal(), { payload: a, hostManifest: i } = await rt(
359
+ t,
360
+ n,
378
361
  o
379
- ), S = new Set(i.tools.map((m) => m.name)), p = await fetch(`${n}/v1/runs`, {
362
+ ), A = new Set(i.tools.map((u) => u.name)), h = {
363
+ sideEffectByName: new Map(
364
+ i.tools.map((u) => [u.name, u.sideEffect])
365
+ )
366
+ }, p = await fetch(`${s}/v1/runs`, {
380
367
  method: "POST",
381
- headers: y(),
382
- body: JSON.stringify(l),
383
- signal: r
368
+ headers: S(),
369
+ body: JSON.stringify(a),
370
+ signal: n
384
371
  });
385
372
  if (!p.ok) {
386
- const m = await p.text().catch(() => "");
373
+ const u = await p.text().catch(() => "");
387
374
  throw new Error(
388
- `Spotlight 后端创建 run 失败:${p.status} ${m}`
375
+ `Spotlight 后端创建 run 失败:${p.status} ${u}`
389
376
  );
390
377
  }
391
- const { runId: f } = await p.json();
392
- r && (T.set(r, f), r.addEventListener(
378
+ const { runId: g } = await p.json();
379
+ n && (I.set(n, g), n.addEventListener(
393
380
  "abort",
394
381
  () => {
395
- x(f);
382
+ $(g);
396
383
  },
397
384
  { once: !0 }
398
385
  ));
399
- const g = await fetch(
400
- `${n}/v1/runs/${encodeURIComponent(f)}/events`,
386
+ const y = await fetch(
387
+ `${s}/v1/runs/${encodeURIComponent(g)}/events`,
401
388
  {
402
- headers: y(),
403
- signal: r
389
+ headers: S(),
390
+ signal: n
404
391
  }
405
392
  );
406
- if (!g.ok || !g.body)
407
- throw new Error(`Spotlight 后端事件流连接失败:${g.status}`);
408
- const I = g.body.getReader(), E = new TextDecoder();
409
- let h = "";
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 = "";
410
397
  try {
411
398
  for (; ; ) {
412
- const { done: m, value: A } = await I.read();
413
- if (m) break;
414
- h += E.decode(A, { stream: !0 });
415
- const w = et(h);
416
- h = w.rest;
417
- for (const a of w.events) {
418
- if (a.type === "host_action_request") {
419
- Y(t, a.request.call);
420
- const _ = await F(a.request.call, t, {
421
- allowedHostNames: S,
422
- hostEffect: a.request.hostEffect
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
423
410
  });
424
- K(t, a.request.call, _), await tt({
425
- runId: f,
426
- correlationId: a.request.correlationId,
427
- result: _,
428
- signal: r
411
+ tt(e, l.request.call, b, h), await ot({
412
+ runId: g,
413
+ correlationId: l.request.correlationId,
414
+ result: b,
415
+ signal: n
429
416
  });
430
417
  continue;
431
418
  }
432
- if (a.type === "run_error")
433
- throw new Error(a.error);
434
- if (await v(t, a), await P(), a.type === "run_completed")
435
- return a.sessionPatch && R().applySessionPatch(a.sessionPatch), {
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), {
436
423
  command: null,
437
- memoryReplay: a.memoryReplay ?? null,
438
- memoryDecision: a.memoryDecision ?? null,
439
- assistantReply: a.assistantReply
424
+ memoryReplay: l.memoryReplay ?? null,
425
+ memoryDecision: l.memoryDecision ?? null,
426
+ assistantReply: l.assistantReply
440
427
  };
441
428
  }
442
429
  }
443
430
  } finally {
444
- I.releaseLock();
431
+ w.releaseLock();
445
432
  }
446
433
  return {
447
434
  command: null
448
435
  };
449
436
  }
450
- async function x(e) {
437
+ async function $(t) {
451
438
  await fetch(
452
- `${C()}/v1/runs/${encodeURIComponent(e)}`,
439
+ `${_()}/v1/runs/${encodeURIComponent(t)}`,
453
440
  {
454
441
  method: "DELETE",
455
- headers: y()
442
+ headers: S()
456
443
  }
457
444
  );
458
445
  }
459
- function yt(e) {
460
- if (!e) return;
461
- const t = T.get(e);
462
- t && (T.delete(e), x(t));
446
+ function It(t) {
447
+ if (!t) return;
448
+ const e = I.get(t);
449
+ e && (I.delete(t), $(e));
463
450
  }
464
451
  export {
465
- Z as applyLangGraphTransition,
466
- v as applyRemoteEvent,
467
- Y as beginHostToolCall,
468
- x as cancelRemoteSpotlightRun,
469
- yt as cancelRemoteSpotlightRunForSignal,
470
- X as responseStepLabel,
471
- gt as runRemoteSpotlightPipeline,
472
- K as settleHostToolCall,
473
- ft as warmupSpotlightRemoteContext
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
474
460
  };