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