@inupedia/spotlight-vue 0.5.11 → 0.5.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/spotlight-vue.css +1 -1
- package/dist/components/SpotlightThinking.vue.d.ts.map +1 -1
- package/dist/components/SpotlightThinking.vue.js +2 -2
- package/dist/components/SpotlightThinking2.vue.js +187 -191
- package/dist/constants/toolNames.d.ts +1 -0
- package/dist/constants/toolNames.d.ts.map +1 -1
- package/dist/constants/toolNames.js +2 -1
- package/dist/remote/runPipeline.d.ts +83 -0
- package/dist/remote/runPipeline.d.ts.map +1 -1
- package/dist/remote/runPipeline.js +230 -222
- package/dist/store/pipeline/toolDisplay.d.ts.map +1 -1
- package/dist/store/pipeline/toolDisplay.js +33 -29
- package/package.json +3 -3
|
@@ -1,113 +1,116 @@
|
|
|
1
1
|
import { serializeSkillsForRemote as A } from "@inupedia/spotlight-client";
|
|
2
|
-
import { useAgentSessionStore as
|
|
2
|
+
import { useAgentSessionStore as R } 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
|
|
7
|
-
import { getSpotlightConfig as
|
|
6
|
+
import { isLoopPlanningChunk as L, splitIntentStepContent as H, splitToolStepContent as O, composeToolStepContent as q } from "../store/pipeline/displayText.js";
|
|
7
|
+
import { getSpotlightConfig as b } from "../plugin.js";
|
|
8
8
|
import { getSkillsPoolForRun as D } from "../skills/index.js";
|
|
9
|
-
import { executeRemoteHostTool as J, ensureHostToolsManifest as
|
|
10
|
-
import { getSpotlightServerBase as
|
|
11
|
-
import { ensureSpotlightMeta as
|
|
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
|
|
14
|
-
return
|
|
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(
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
return
|
|
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((
|
|
24
|
-
requestAnimationFrame(() =>
|
|
23
|
+
return new Promise((e) => {
|
|
24
|
+
requestAnimationFrame(() => e());
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
function B(
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
31
|
-
if (
|
|
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(
|
|
33
|
+
const o = JSON.stringify(e.output, null, 2);
|
|
34
34
|
if (o && o !== "{}") return o;
|
|
35
35
|
} catch {
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return t || "";
|
|
38
38
|
}
|
|
39
|
-
function G(
|
|
40
|
-
const
|
|
39
|
+
function G(e) {
|
|
40
|
+
const t = B(e.result);
|
|
41
41
|
return {
|
|
42
|
-
id:
|
|
43
|
-
name:
|
|
44
|
-
displayName:
|
|
45
|
-
argsText: JSON.stringify(
|
|
46
|
-
resultText:
|
|
47
|
-
summary:
|
|
48
|
-
errorCode:
|
|
49
|
-
trace:
|
|
50
|
-
status:
|
|
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(
|
|
53
|
+
function U(e) {
|
|
54
54
|
return {
|
|
55
|
-
id:
|
|
56
|
-
name:
|
|
57
|
-
displayName:
|
|
58
|
-
argsText: JSON.stringify(
|
|
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(
|
|
63
|
-
const o =
|
|
62
|
+
function V(e, t) {
|
|
63
|
+
const o = t.success ? "前端操作已执行。" : t.error || "前端操作执行失败。";
|
|
64
64
|
return {
|
|
65
|
-
id:
|
|
66
|
-
name:
|
|
67
|
-
displayName:
|
|
68
|
-
argsText: JSON.stringify(
|
|
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:
|
|
72
|
-
trace:
|
|
73
|
-
status:
|
|
71
|
+
errorCode: t.errorCode,
|
|
72
|
+
trace: t.trace,
|
|
73
|
+
status: t.success ? "done" : "error"
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function Y(t) {
|
|
77
|
-
|
|
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(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
90
|
-
if (
|
|
91
|
-
const o =
|
|
92
|
-
!o || o.status === "active" || o.status === "done" ||
|
|
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
|
|
95
|
-
return
|
|
97
|
+
function k(e, t) {
|
|
98
|
+
return t || (e === s.tool ? "执行工具与回答" : e);
|
|
96
99
|
}
|
|
97
|
-
function Q(
|
|
98
|
-
const
|
|
99
|
-
return
|
|
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(
|
|
102
|
-
c(
|
|
104
|
+
function u(e, t, o, n, r) {
|
|
105
|
+
c(e, t, o), e.setStep(t, n, r);
|
|
103
106
|
}
|
|
104
|
-
function X(
|
|
105
|
-
const o =
|
|
106
|
-
switch (
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
167
|
+
e,
|
|
165
168
|
s.breakdown,
|
|
166
169
|
"问题拆解",
|
|
167
170
|
"done",
|
|
@@ -172,181 +175,182 @@ function X(t, e) {
|
|
|
172
175
|
return;
|
|
173
176
|
}
|
|
174
177
|
}
|
|
175
|
-
async function Z(
|
|
176
|
-
if (
|
|
177
|
-
if (
|
|
178
|
-
|
|
179
|
-
|
|
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:
|
|
186
|
+
content: e.getSteps().find((n) => n.id === o.id)?.content
|
|
184
187
|
}))
|
|
185
188
|
);
|
|
186
|
-
else if (
|
|
187
|
-
c(
|
|
188
|
-
else if (
|
|
189
|
-
let o =
|
|
190
|
-
if (o === s.intent && L(
|
|
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 &&
|
|
193
|
-
const { intent:
|
|
194
|
-
|
|
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
|
-
|
|
199
|
+
l
|
|
197
200
|
));
|
|
198
201
|
}
|
|
199
|
-
c(
|
|
202
|
+
c(e, o, k(o, t.label)), t.mode === "replace" ? e.setStep(
|
|
200
203
|
o,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
) : (
|
|
204
|
-
} else if (
|
|
205
|
-
c(
|
|
206
|
-
else if (
|
|
207
|
-
c(
|
|
208
|
-
U(
|
|
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, 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);
|
|
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 (
|
|
211
|
-
c(
|
|
213
|
+
else if (t.type === "tool_progress")
|
|
214
|
+
c(e, s.tool, "执行工具与回答"), d(e, s.tool), e.appendToolCallsToStep(s.tool, [
|
|
212
215
|
{
|
|
213
|
-
id:
|
|
214
|
-
name:
|
|
215
|
-
displayName:
|
|
216
|
-
argsText: JSON.stringify(
|
|
217
|
-
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 (
|
|
222
|
-
c(
|
|
223
|
-
G(
|
|
224
|
-
]),
|
|
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
|
-
|
|
227
|
-
),
|
|
229
|
+
t.result.attachments
|
|
230
|
+
), t.result.files?.length && e.appendFilesToStep(
|
|
228
231
|
s.tool,
|
|
229
|
-
|
|
230
|
-
),
|
|
232
|
+
t.result.files
|
|
233
|
+
), t.result.toolCalls?.length && e.appendToolCallsToStep(
|
|
231
234
|
s.tool,
|
|
232
|
-
|
|
235
|
+
t.result.toolCalls
|
|
233
236
|
);
|
|
234
|
-
else if (
|
|
237
|
+
else if (t.type === "skill_permission_request") {
|
|
235
238
|
const { useSpotlightStore: o } = await import("../store/spotlightStore.js");
|
|
236
239
|
o().setPendingSkillPermission({
|
|
237
|
-
skillName:
|
|
238
|
-
displayName:
|
|
239
|
-
reason:
|
|
240
|
-
source:
|
|
241
|
-
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 (
|
|
244
|
-
c(
|
|
246
|
+
} else if (t.type === "fork_progress")
|
|
247
|
+
c(e, s.tool, "执行工具与回答"), e.appendChunkToStep(
|
|
245
248
|
s.tool,
|
|
246
249
|
`
|
|
247
|
-
[fork ${
|
|
250
|
+
[fork ${t.agentId}] 第 ${t.iteration} 轮 · ${t.phase}:${t.summary}
|
|
248
251
|
`
|
|
249
252
|
);
|
|
250
|
-
else if (
|
|
251
|
-
X(
|
|
252
|
-
else if (
|
|
253
|
-
c(
|
|
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
|
-
|
|
263
|
+
e.setStep(
|
|
261
264
|
s.breakdown,
|
|
262
|
-
|
|
263
|
-
o[
|
|
265
|
+
t.decision.action === "reuse" ? "done" : "active",
|
|
266
|
+
o[t.decision.action]
|
|
264
267
|
);
|
|
265
|
-
} else if (
|
|
268
|
+
} else if (t.type === "assistant_response") {
|
|
266
269
|
c(
|
|
267
|
-
|
|
270
|
+
e,
|
|
268
271
|
s.tool,
|
|
269
|
-
Q(
|
|
272
|
+
Q(e)
|
|
270
273
|
);
|
|
271
|
-
const o =
|
|
272
|
-
i &&
|
|
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
|
-
)) ?
|
|
277
|
+
)) ? e.setStep(s.tool, "done") : e.setStep(
|
|
275
278
|
s.tool,
|
|
276
279
|
"done",
|
|
277
|
-
q(
|
|
280
|
+
q(n, l)
|
|
278
281
|
);
|
|
279
282
|
}
|
|
280
|
-
|
|
283
|
+
W(t) && e.appendExecutionEvent?.(t);
|
|
281
284
|
}
|
|
282
285
|
}
|
|
283
|
-
async function v(
|
|
286
|
+
async function v(e) {
|
|
284
287
|
await fetch(
|
|
285
|
-
`${
|
|
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:
|
|
291
|
-
success:
|
|
292
|
-
output:
|
|
293
|
-
error:
|
|
294
|
-
errorCode:
|
|
295
|
-
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:
|
|
300
|
+
signal: e.signal
|
|
298
301
|
}
|
|
299
302
|
);
|
|
300
303
|
}
|
|
301
|
-
function tt(
|
|
302
|
-
const
|
|
303
|
-
return { events:
|
|
304
|
-
const
|
|
305
|
-
if (!
|
|
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(
|
|
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(
|
|
316
|
+
async function pt(e) {
|
|
314
317
|
await Promise.allSettled([
|
|
315
|
-
|
|
316
|
-
|
|
318
|
+
N(),
|
|
319
|
+
j(e)
|
|
317
320
|
]);
|
|
318
321
|
}
|
|
319
|
-
async function et(
|
|
320
|
-
const
|
|
322
|
+
async function et(e, t, o) {
|
|
323
|
+
const n = R(), r = $(), l = M(), i = await N();
|
|
321
324
|
return {
|
|
322
325
|
hostManifest: i,
|
|
323
326
|
payload: {
|
|
324
|
-
projectId:
|
|
325
|
-
sessionId:
|
|
326
|
-
memorySubjectId:
|
|
327
|
-
userQuestion:
|
|
327
|
+
projectId: F(),
|
|
328
|
+
sessionId: n.sessionId,
|
|
329
|
+
memorySubjectId: b().getMemorySubjectId?.() ?? void 0,
|
|
330
|
+
userQuestion: e,
|
|
328
331
|
memoryRefreshRequested: o?.forceMemoryRefresh === !0,
|
|
329
|
-
uiContext:
|
|
332
|
+
uiContext: b().getUiContext?.() ?? {},
|
|
330
333
|
sessionState: {
|
|
331
|
-
sessionId:
|
|
332
|
-
activeTaskId:
|
|
333
|
-
activeTopic:
|
|
334
|
-
pendingTask:
|
|
335
|
-
conversationSummary:
|
|
336
|
-
summarizedTurnCount:
|
|
337
|
-
conversationHistory:
|
|
338
|
-
lastAssistantReply:
|
|
339
|
-
invokedSkills:
|
|
340
|
-
skillPermissionGrants:
|
|
341
|
-
|
|
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
|
+
memoryEnabled: l.enabled,
|
|
345
|
+
memoryReadEnabled: l.enabled,
|
|
342
346
|
memoryWriteEnabled: !0
|
|
343
347
|
},
|
|
344
348
|
runtimeState: {
|
|
345
|
-
activeDomain:
|
|
346
|
-
activeTarget:
|
|
347
|
-
activeAction:
|
|
348
|
-
resumableAction:
|
|
349
|
-
lastResolvedTarget:
|
|
349
|
+
activeDomain: r.activeDomain,
|
|
350
|
+
activeTarget: r.activeTarget,
|
|
351
|
+
activeAction: r.activeAction,
|
|
352
|
+
resumableAction: r.resumableAction,
|
|
353
|
+
lastResolvedTarget: r.lastResolvedTarget
|
|
350
354
|
},
|
|
351
355
|
clientToolsManifestVersion: i.manifestDigest,
|
|
352
356
|
clientToolManifest: i,
|
|
@@ -356,100 +360,104 @@ async function et(t, e, o) {
|
|
|
356
360
|
}
|
|
357
361
|
};
|
|
358
362
|
}
|
|
359
|
-
async function ft(
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
async function ft(e, t, o) {
|
|
364
|
+
const n = C(), r = t.getSignal(), { payload: l, hostManifest: i } = await et(
|
|
365
|
+
e,
|
|
366
|
+
r,
|
|
363
367
|
o
|
|
364
|
-
), S = new Set(i.tools.map((
|
|
368
|
+
), S = new Set(i.tools.map((m) => m.name)), p = await fetch(`${n}/v1/runs`, {
|
|
365
369
|
method: "POST",
|
|
366
370
|
headers: g(),
|
|
367
|
-
body: JSON.stringify(
|
|
368
|
-
signal:
|
|
371
|
+
body: JSON.stringify(l),
|
|
372
|
+
signal: r
|
|
369
373
|
});
|
|
370
374
|
if (!p.ok) {
|
|
371
|
-
const
|
|
375
|
+
const m = await p.text().catch(() => "");
|
|
372
376
|
throw new Error(
|
|
373
|
-
`Spotlight 后端创建 run 失败:${p.status} ${
|
|
377
|
+
`Spotlight 后端创建 run 失败:${p.status} ${m}`
|
|
374
378
|
);
|
|
375
379
|
}
|
|
376
380
|
const { runId: f } = await p.json();
|
|
377
|
-
|
|
381
|
+
r && (T.set(r, f), r.addEventListener(
|
|
378
382
|
"abort",
|
|
379
383
|
() => {
|
|
380
|
-
|
|
384
|
+
P(f);
|
|
381
385
|
},
|
|
382
386
|
{ once: !0 }
|
|
383
387
|
));
|
|
384
388
|
const y = await fetch(
|
|
385
|
-
`${
|
|
389
|
+
`${n}/v1/runs/${encodeURIComponent(f)}/events`,
|
|
386
390
|
{
|
|
387
391
|
headers: g(),
|
|
388
|
-
signal:
|
|
392
|
+
signal: r
|
|
389
393
|
}
|
|
390
394
|
);
|
|
391
395
|
if (!y.ok || !y.body)
|
|
392
396
|
throw new Error(`Spotlight 后端事件流连接失败:${y.status}`);
|
|
393
|
-
const
|
|
397
|
+
const I = y.body.getReader(), x = new TextDecoder();
|
|
394
398
|
let h = "";
|
|
395
399
|
try {
|
|
396
400
|
for (; ; ) {
|
|
397
|
-
const { done:
|
|
398
|
-
if (
|
|
401
|
+
const { done: m, value: E } = await I.read();
|
|
402
|
+
if (m) break;
|
|
399
403
|
h += x.decode(E, { stream: !0 });
|
|
400
404
|
const w = tt(h);
|
|
401
405
|
h = w.rest;
|
|
402
|
-
for (const
|
|
403
|
-
if (
|
|
404
|
-
|
|
406
|
+
for (const a of w.events) {
|
|
407
|
+
if (a.type === "host_action_request") {
|
|
408
|
+
Y(t, a.request.call);
|
|
409
|
+
const _ = await J(a.request.call, t, {
|
|
405
410
|
allowedHostNames: S,
|
|
406
|
-
hostEffect:
|
|
411
|
+
hostEffect: a.request.hostEffect
|
|
407
412
|
});
|
|
408
|
-
K(
|
|
413
|
+
K(t, a.request.call, _), await v({
|
|
409
414
|
runId: f,
|
|
410
|
-
correlationId:
|
|
415
|
+
correlationId: a.request.correlationId,
|
|
411
416
|
result: _,
|
|
412
|
-
signal:
|
|
417
|
+
signal: r
|
|
413
418
|
});
|
|
414
419
|
continue;
|
|
415
420
|
}
|
|
416
|
-
if (
|
|
417
|
-
throw new Error(
|
|
418
|
-
if (await Z(
|
|
419
|
-
return
|
|
421
|
+
if (a.type === "run_error")
|
|
422
|
+
throw new Error(a.error);
|
|
423
|
+
if (await Z(t, a), a.type === "run_completed")
|
|
424
|
+
return a.sessionPatch && R().applySessionPatch(a.sessionPatch), {
|
|
420
425
|
command: null,
|
|
421
|
-
memoryReplay:
|
|
422
|
-
memoryDecision:
|
|
423
|
-
assistantReply:
|
|
426
|
+
memoryReplay: a.memoryReplay ?? null,
|
|
427
|
+
memoryDecision: a.memoryDecision ?? null,
|
|
428
|
+
assistantReply: a.assistantReply
|
|
424
429
|
};
|
|
425
430
|
}
|
|
426
431
|
}
|
|
427
432
|
} finally {
|
|
428
|
-
|
|
433
|
+
I.releaseLock();
|
|
429
434
|
}
|
|
430
435
|
return {
|
|
431
436
|
command: null
|
|
432
437
|
};
|
|
433
438
|
}
|
|
434
|
-
async function
|
|
439
|
+
async function P(e) {
|
|
435
440
|
await fetch(
|
|
436
|
-
`${
|
|
441
|
+
`${C()}/v1/runs/${encodeURIComponent(e)}`,
|
|
437
442
|
{
|
|
438
443
|
method: "DELETE",
|
|
439
444
|
headers: g()
|
|
440
445
|
}
|
|
441
446
|
);
|
|
442
447
|
}
|
|
443
|
-
function yt(
|
|
444
|
-
if (!
|
|
445
|
-
const
|
|
446
|
-
|
|
448
|
+
function yt(e) {
|
|
449
|
+
if (!e) return;
|
|
450
|
+
const t = T.get(e);
|
|
451
|
+
t && (T.delete(e), P(t));
|
|
447
452
|
}
|
|
448
453
|
export {
|
|
449
454
|
X as applyLangGraphTransition,
|
|
450
|
-
|
|
455
|
+
Z as applyRemoteEvent,
|
|
456
|
+
Y as beginHostToolCall,
|
|
457
|
+
P as cancelRemoteSpotlightRun,
|
|
451
458
|
yt as cancelRemoteSpotlightRunForSignal,
|
|
452
459
|
Q as responseStepLabel,
|
|
453
460
|
ft as runRemoteSpotlightPipeline,
|
|
461
|
+
K as settleHostToolCall,
|
|
454
462
|
pt as warmupSpotlightRemoteContext
|
|
455
463
|
};
|