@inupedia/spotlight-vue 0.5.10 → 0.5.12

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