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