@inupedia/spotlight-vue 0.5.16 → 0.5.18
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/avatar/speech/live2dStreamSpeech.d.ts +2 -2
- package/dist/avatar/speech/live2dStreamSpeech.d.ts.map +1 -1
- package/dist/avatar/speech/live2dStreamSpeech.js +1 -1
- package/dist/components/SpotlightShell.vue.d.ts.map +1 -1
- package/dist/components/SpotlightShell2.vue.js +53 -53
- package/dist/components/SpotlightThinking.vue.d.ts.map +1 -1
- package/dist/components/SpotlightThinking.vue.js +2 -2
- package/dist/components/SpotlightThinking2.vue.js +386 -365
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -59
- package/dist/remote/runPipeline.d.ts +8 -5
- package/dist/remote/runPipeline.d.ts.map +1 -1
- package/dist/remote/runPipeline.js +308 -322
- package/dist/store/pipeline/constants.d.ts +13 -4
- package/dist/store/pipeline/constants.d.ts.map +1 -1
- package/dist/store/pipeline/constants.js +17 -8
- package/dist/store/pipeline/displayText.d.ts +12 -0
- package/dist/store/pipeline/displayText.d.ts.map +1 -1
- package/dist/store/pipeline/displayText.js +75 -45
- package/dist/store/pipeline/errors.d.ts.map +1 -1
- package/dist/store/pipeline/errors.js +10 -10
- package/dist/store/pipeline/toolLane.d.ts +10 -0
- package/dist/store/pipeline/toolLane.d.ts.map +1 -0
- package/dist/store/pipeline/toolLane.js +24 -0
- package/dist/store/spotlightStore.js +2 -2
- package/package.json +3 -3
|
@@ -1,474 +1,460 @@
|
|
|
1
|
-
import { serializeSkillsForRemote as
|
|
2
|
-
import { useAgentSessionStore as
|
|
3
|
-
import { useSpotlightMemoryPreferenceStore as
|
|
4
|
-
import { useSpotlightRuntimeStore as
|
|
5
|
-
import { SPOTLIGHT_PIPELINE_STEP_IDS as
|
|
6
|
-
import { isLoopPlanningChunk as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
return
|
|
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
|
|
23
|
-
return new Promise((
|
|
24
|
-
requestAnimationFrame(() =>
|
|
23
|
+
function L() {
|
|
24
|
+
return new Promise((t) => {
|
|
25
|
+
requestAnimationFrame(() => t());
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
return
|
|
31
|
-
if (
|
|
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(
|
|
34
|
+
const o = JSON.stringify(t.output, null, 2);
|
|
34
35
|
if (o && o !== "{}") return o;
|
|
35
36
|
} catch {
|
|
36
37
|
}
|
|
37
|
-
return
|
|
38
|
+
return e || "";
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
40
|
+
function K(t) {
|
|
41
|
+
const e = Y(t.result);
|
|
41
42
|
return {
|
|
42
|
-
id:
|
|
43
|
-
name:
|
|
44
|
-
displayName:
|
|
45
|
-
argsText: JSON.stringify(
|
|
46
|
-
resultText:
|
|
47
|
-
summary:
|
|
48
|
-
errorCode:
|
|
49
|
-
trace:
|
|
50
|
-
status:
|
|
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
|
|
54
|
+
function Q(t) {
|
|
54
55
|
return {
|
|
55
|
-
id:
|
|
56
|
-
name:
|
|
57
|
-
displayName:
|
|
58
|
-
argsText: JSON.stringify(
|
|
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
|
|
63
|
-
const o =
|
|
63
|
+
function X(t, e) {
|
|
64
|
+
const o = e.success ? "前端操作已执行。" : e.error || "前端操作执行失败。";
|
|
64
65
|
return {
|
|
65
|
-
id:
|
|
66
|
-
name:
|
|
67
|
-
displayName:
|
|
68
|
-
argsText: JSON.stringify(
|
|
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:
|
|
72
|
-
trace:
|
|
73
|
-
status:
|
|
72
|
+
errorCode: e.errorCode,
|
|
73
|
+
trace: e.trace,
|
|
74
|
+
status: e.success ? "done" : "error"
|
|
74
75
|
};
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
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:
|
|
80
|
-
name:
|
|
81
|
-
displayName:
|
|
82
|
-
argsText: JSON.stringify(
|
|
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
|
|
88
|
-
|
|
89
|
-
|
|
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
|
|
109
|
-
return
|
|
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
|
|
112
|
-
|
|
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
|
|
116
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
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
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
"
|
|
166
|
+
m(
|
|
167
|
+
t,
|
|
168
|
+
r.understand,
|
|
169
|
+
"理解问题",
|
|
181
170
|
"done",
|
|
182
|
-
o ?? "
|
|
171
|
+
o ?? "已复用项目记忆,跳过本轮检索。"
|
|
183
172
|
);
|
|
184
173
|
return;
|
|
185
174
|
default:
|
|
186
175
|
return;
|
|
187
176
|
}
|
|
188
177
|
}
|
|
189
|
-
async function
|
|
190
|
-
if (
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
id:
|
|
195
|
-
label:
|
|
196
|
-
status:
|
|
197
|
-
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 (
|
|
201
|
-
|
|
202
|
-
else if (
|
|
203
|
-
let
|
|
204
|
-
if (
|
|
205
|
-
|
|
206
|
-
else if (
|
|
207
|
-
const { intent:
|
|
208
|
-
n =
|
|
209
|
-
|
|
210
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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:
|
|
228
|
-
name:
|
|
229
|
-
displayName:
|
|
230
|
-
argsText: JSON.stringify(
|
|
231
|
-
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 (
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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 (
|
|
258
|
-
|
|
259
|
-
|
|
248
|
+
} else if (e.type === "fork_progress") {
|
|
249
|
+
const s = r.gather;
|
|
250
|
+
d(t, s, "获取信息"), t.appendChunkToStep(
|
|
251
|
+
s,
|
|
260
252
|
`
|
|
261
|
-
[fork ${
|
|
253
|
+
[fork ${e.agentId}] 第 ${e.iteration} 轮 · ${e.phase}:${e.summary}
|
|
262
254
|
`
|
|
263
255
|
);
|
|
264
|
-
else if (
|
|
265
|
-
|
|
266
|
-
else if (
|
|
267
|
-
|
|
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
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
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
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
|
280
|
+
async function ot(t) {
|
|
298
281
|
await fetch(
|
|
299
|
-
`${
|
|
282
|
+
`${_()}/v1/runs/${encodeURIComponent(t.runId)}/host-results`,
|
|
300
283
|
{
|
|
301
284
|
method: "POST",
|
|
302
|
-
headers:
|
|
285
|
+
headers: S(),
|
|
303
286
|
body: JSON.stringify({
|
|
304
|
-
correlationId:
|
|
305
|
-
success:
|
|
306
|
-
output:
|
|
307
|
-
error:
|
|
308
|
-
errorCode:
|
|
309
|
-
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:
|
|
294
|
+
signal: t.signal
|
|
312
295
|
}
|
|
313
296
|
);
|
|
314
297
|
}
|
|
315
|
-
function
|
|
316
|
-
const
|
|
317
|
-
return { events:
|
|
318
|
-
const
|
|
319
|
-
if (!
|
|
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(
|
|
304
|
+
return [JSON.parse(a.slice(6))];
|
|
322
305
|
} catch {
|
|
323
306
|
return [];
|
|
324
307
|
}
|
|
325
308
|
}), rest: o };
|
|
326
309
|
}
|
|
327
|
-
async function
|
|
310
|
+
async function ht(t) {
|
|
328
311
|
await Promise.allSettled([
|
|
329
|
-
|
|
330
|
-
|
|
312
|
+
x(),
|
|
313
|
+
U(t)
|
|
331
314
|
]);
|
|
332
315
|
}
|
|
333
|
-
async function
|
|
334
|
-
const
|
|
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:
|
|
339
|
-
sessionId:
|
|
340
|
-
memorySubjectId:
|
|
341
|
-
userQuestion:
|
|
321
|
+
projectId: G(),
|
|
322
|
+
sessionId: s.sessionId,
|
|
323
|
+
memorySubjectId: k().getMemorySubjectId?.() ?? void 0,
|
|
324
|
+
userQuestion: t,
|
|
342
325
|
memoryRefreshRequested: o?.forceMemoryRefresh === !0,
|
|
343
|
-
uiContext:
|
|
326
|
+
uiContext: k().getUiContext?.() ?? {},
|
|
344
327
|
sessionState: {
|
|
345
|
-
sessionId:
|
|
346
|
-
activeTaskId:
|
|
347
|
-
activeTopic:
|
|
348
|
-
pendingTask:
|
|
349
|
-
conversationSummary:
|
|
350
|
-
summarizedTurnCount:
|
|
351
|
-
conversationHistory:
|
|
352
|
-
lastAssistantReply:
|
|
353
|
-
invokedSkills:
|
|
354
|
-
skillPermissionGrants:
|
|
355
|
-
memoryEnabled:
|
|
356
|
-
memoryReadEnabled:
|
|
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:
|
|
361
|
-
activeTarget:
|
|
362
|
-
activeAction:
|
|
363
|
-
resumableAction:
|
|
364
|
-
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:
|
|
351
|
+
skills: O(W()),
|
|
369
352
|
frontendBuildId: i.frontendBuildId,
|
|
370
353
|
manifestDigest: i.manifestDigest
|
|
371
354
|
}
|
|
372
355
|
};
|
|
373
356
|
}
|
|
374
|
-
async function
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
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
|
-
),
|
|
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:
|
|
382
|
-
body: JSON.stringify(
|
|
383
|
-
signal:
|
|
368
|
+
headers: S(),
|
|
369
|
+
body: JSON.stringify(a),
|
|
370
|
+
signal: n
|
|
384
371
|
});
|
|
385
372
|
if (!p.ok) {
|
|
386
|
-
const
|
|
373
|
+
const u = await p.text().catch(() => "");
|
|
387
374
|
throw new Error(
|
|
388
|
-
`Spotlight 后端创建 run 失败:${p.status} ${
|
|
375
|
+
`Spotlight 后端创建 run 失败:${p.status} ${u}`
|
|
389
376
|
);
|
|
390
377
|
}
|
|
391
|
-
const { runId:
|
|
392
|
-
|
|
378
|
+
const { runId: g } = await p.json();
|
|
379
|
+
n && (I.set(n, g), n.addEventListener(
|
|
393
380
|
"abort",
|
|
394
381
|
() => {
|
|
395
|
-
|
|
382
|
+
$(g);
|
|
396
383
|
},
|
|
397
384
|
{ once: !0 }
|
|
398
385
|
));
|
|
399
|
-
const
|
|
400
|
-
`${
|
|
386
|
+
const y = await fetch(
|
|
387
|
+
`${s}/v1/runs/${encodeURIComponent(g)}/events`,
|
|
401
388
|
{
|
|
402
|
-
headers:
|
|
403
|
-
signal:
|
|
389
|
+
headers: S(),
|
|
390
|
+
signal: n
|
|
404
391
|
}
|
|
405
392
|
);
|
|
406
|
-
if (!
|
|
407
|
-
throw new Error(`Spotlight 后端事件流连接失败:${
|
|
408
|
-
const
|
|
409
|
-
let
|
|
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:
|
|
413
|
-
if (
|
|
414
|
-
|
|
415
|
-
const
|
|
416
|
-
|
|
417
|
-
for (const
|
|
418
|
-
if (
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
allowedHostNames:
|
|
422
|
-
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
|
-
|
|
425
|
-
runId:
|
|
426
|
-
correlationId:
|
|
427
|
-
result:
|
|
428
|
-
signal:
|
|
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 (
|
|
433
|
-
throw new Error(
|
|
434
|
-
if (await
|
|
435
|
-
return
|
|
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:
|
|
438
|
-
memoryDecision:
|
|
439
|
-
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
|
-
|
|
431
|
+
w.releaseLock();
|
|
445
432
|
}
|
|
446
433
|
return {
|
|
447
434
|
command: null
|
|
448
435
|
};
|
|
449
436
|
}
|
|
450
|
-
async function
|
|
437
|
+
async function $(t) {
|
|
451
438
|
await fetch(
|
|
452
|
-
`${
|
|
439
|
+
`${_()}/v1/runs/${encodeURIComponent(t)}`,
|
|
453
440
|
{
|
|
454
441
|
method: "DELETE",
|
|
455
|
-
headers:
|
|
442
|
+
headers: S()
|
|
456
443
|
}
|
|
457
444
|
);
|
|
458
445
|
}
|
|
459
|
-
function
|
|
460
|
-
if (!
|
|
461
|
-
const
|
|
462
|
-
|
|
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
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
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
|
};
|