@inupedia/spotlight-vue 0.2.13 → 0.2.15
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/SpotlightCommandPanel.vue.d.ts.map +1 -1
- package/dist/components/SpotlightCommandPanel.vue.js +1 -1
- package/dist/components/SpotlightCommandPanel2.vue.js +41 -40
- package/dist/components/SpotlightRoot.vue.d.ts.map +1 -1
- package/dist/components/SpotlightRoot.vue.js +21 -19
- package/dist/components/SpotlightThinking.vue.d.ts +3 -0
- package/dist/components/SpotlightThinking.vue.d.ts.map +1 -1
- package/dist/components/SpotlightThinking.vue.js +2 -2
- package/dist/components/SpotlightThinking2.vue.js +126 -114
- package/dist/composables/useSpotlightPanelUi.d.ts +3 -1
- package/dist/composables/useSpotlightPanelUi.d.ts.map +1 -1
- package/dist/composables/useSpotlightPanelUi.js +8 -3
- package/dist/remote/runPipeline.d.ts +3 -1
- package/dist/remote/runPipeline.d.ts.map +1 -1
- package/dist/remote/runPipeline.js +149 -133
- package/dist/remote/types.d.ts +2 -0
- package/dist/remote/types.d.ts.map +1 -1
- package/dist/store/spotlightStore.d.ts +68 -2
- package/dist/store/spotlightStore.d.ts.map +1 -1
- package/dist/store/spotlightStore.js +130 -124
- package/package.json +3 -3
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { computed as u } from "vue";
|
|
2
|
-
function
|
|
3
|
-
const n = e.voiceKeyLabel ?? "`", r = u(() => e.pipelinePhase.value === "error" ? "error" : e.loading.value || e.pipelinePhase.value === "running" ? "running" : e.pipelinePhase.value === "done" ? "done" : "idle"), l = u(() => e.voiceHoldActive?.value ? `正在录音,松开 ${n} 结束并转写…` : e.speechPending?.value ? "语音识别中,请稍候…" : r.value === "running" ? "Agent 正在分析场景、路由工具和上下文…" : r.value === "done" ? "继续追问,或者换个角度继续盘它…" : r.value === "error" ? "刚才那轮跑岔了,换个问法再试试…" : "输入问题或从下方选择历史…"), a = u(() => e.voiceHoldActive?.value ? "语音录制中" : e.speechPending?.value ? "语音识别中" : r.value === "running" ? "Agent 执行中" : r.value === "done" ? e.
|
|
2
|
+
function v(e) {
|
|
3
|
+
const n = e.voiceKeyLabel ?? "`", r = u(() => e.pipelinePhase.value === "error" ? "error" : e.loading.value || e.pipelinePhase.value === "running" ? "running" : e.pipelinePhase.value === "done" ? "done" : "idle"), l = u(() => e.voiceHoldActive?.value ? `正在录音,松开 ${n} 结束并转写…` : e.speechPending?.value ? "语音识别中,请稍候…" : r.value === "running" ? "Agent 正在分析场景、路由工具和上下文…" : r.value === "done" ? "继续追问,或者换个角度继续盘它…" : r.value === "error" ? "刚才那轮跑岔了,换个问法再试试…" : "输入问题或从下方选择历史…"), a = u(() => e.voiceHoldActive?.value ? "语音录制中" : e.speechPending?.value ? "语音识别中" : r.value === "running" ? "Agent 执行中" : r.value === "done" ? e.memoryDecision?.value ? {
|
|
4
|
+
reuse: "已复用项目记忆",
|
|
5
|
+
augment: "已结合项目记忆",
|
|
6
|
+
refresh: "已重新验证资料",
|
|
7
|
+
ignore: "已完成"
|
|
8
|
+
}[e.memoryDecision.value.action] : e.memoryReplay?.value ? e.memoryReplay.value.source === "semantic" ? "语义缓存命中" : "Memory 缓存命中" : "已完成" : r.value === "error" ? "执行异常" : "等待提问");
|
|
4
9
|
return { uiState: r, placeholder: l, badgeLabel: a };
|
|
5
10
|
}
|
|
6
11
|
export {
|
|
7
|
-
|
|
12
|
+
v as useSpotlightPanelUi
|
|
8
13
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { HandlerApi } from "../store/pipeline/types.js";
|
|
2
2
|
import type { SpotlightPipelineRunOutcome } from "./types.js";
|
|
3
3
|
export declare function warmupSpotlightRemoteContext(signal?: AbortSignal): Promise<void>;
|
|
4
|
-
export declare function runRemoteSpotlightPipeline(userQuestion: string, api: HandlerApi
|
|
4
|
+
export declare function runRemoteSpotlightPipeline(userQuestion: string, api: HandlerApi, options?: {
|
|
5
|
+
forceMemoryRefresh?: boolean;
|
|
6
|
+
}): Promise<SpotlightPipelineRunOutcome>;
|
|
5
7
|
export declare function cancelRemoteSpotlightRun(runId: string): Promise<void>;
|
|
6
8
|
export declare function cancelRemoteSpotlightRunForSignal(signal?: AbortSignal): void;
|
|
7
9
|
//# sourceMappingURL=runPipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runPipeline.d.ts","sourceRoot":"","sources":["../../src/remote/runPipeline.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runPipeline.d.ts","sourceRoot":"","sources":["../../src/remote/runPipeline.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAc7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AA2c9D,wBAAsB,4BAA4B,CAChD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;AA8CD,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,UAAU,EACf,OAAO,CAAC,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GACzC,OAAO,CAAC,2BAA2B,CAAC,CAiGtC;AAED,wBAAsB,wBAAwB,CAAC,KAAK,EAAE,MAAM,iBAQ3D;AAED,wBAAgB,iCAAiC,CAAC,MAAM,CAAC,EAAE,WAAW,QAMrE"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { serializeSkillsForRemote as
|
|
2
|
-
import { getSkillsPoolForRun as
|
|
3
|
-
import { useAgentSessionStore as
|
|
4
|
-
import { useSpotlightMemoryPreferenceStore as
|
|
5
|
-
import { useSpotlightRuntimeStore as
|
|
1
|
+
import { serializeSkillsForRemote as E } from "@inupedia/spotlight-client";
|
|
2
|
+
import { getSkillsPoolForRun as A } from "../skills/index.js";
|
|
3
|
+
import { useAgentSessionStore as b } from "../session/agentSession.js";
|
|
4
|
+
import { useSpotlightMemoryPreferenceStore as L } from "../store/memoryPreferenceStore.js";
|
|
5
|
+
import { useSpotlightRuntimeStore as $ } from "../store/runtimeStore.js";
|
|
6
6
|
import { SPOTLIGHT_PIPELINE_STEP_IDS as r } from "../store/pipeline/constants.js";
|
|
7
|
-
import { isLoopPlanningChunk as
|
|
7
|
+
import { isLoopPlanningChunk as O, splitIntentStepContent as H, splitToolStepContent as M, composeToolStepContent as q } from "../store/pipeline/displayText.js";
|
|
8
8
|
import { getSpotlightConfig as F } from "../plugin.js";
|
|
9
|
-
import { executeRemoteHostTool as
|
|
10
|
-
import { getSpotlightServerBase as
|
|
11
|
-
import { ensureSpotlightMeta as
|
|
12
|
-
const
|
|
13
|
-
function
|
|
14
|
-
return e.type !== "host_action_request" && e.type !== "run_completed" && e.type !== "run_error" && e.type !== "ping";
|
|
9
|
+
import { executeRemoteHostTool as J, ensureHostToolsManifest as _ } from "./hostToolRunner.js";
|
|
10
|
+
import { getSpotlightServerBase as T, buildSpotlightJsonHeaders as y, getSpotlightProjectId as W } from "./httpConfig.js";
|
|
11
|
+
import { ensureSpotlightMeta as D } from "./meta.js";
|
|
12
|
+
const g = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
function j(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
|
|
17
|
-
const s = e.getSteps().find((
|
|
16
|
+
function a(e, t, o) {
|
|
17
|
+
const s = e.getSteps().find((l) => l.id === t);
|
|
18
18
|
if (s) return s;
|
|
19
|
-
const
|
|
20
|
-
return e.setSteps([...e.getSteps(),
|
|
19
|
+
const n = { id: t, label: o, status: "pending" };
|
|
20
|
+
return e.setSteps([...e.getSteps(), n]), n;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function U() {
|
|
23
23
|
return new Promise((e) => {
|
|
24
24
|
requestAnimationFrame(() => e());
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function z(e) {
|
|
28
28
|
const t = e.summary?.trim();
|
|
29
29
|
if (t && t.length > 48 && !t.startsWith("{") && !t.startsWith("["))
|
|
30
30
|
return t;
|
|
@@ -36,8 +36,8 @@ function U(e) {
|
|
|
36
36
|
}
|
|
37
37
|
return t || "";
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const t =
|
|
39
|
+
function G(e) {
|
|
40
|
+
const t = z(e.result);
|
|
41
41
|
return {
|
|
42
42
|
id: e.result.call.id,
|
|
43
43
|
name: e.result.call.name,
|
|
@@ -50,7 +50,7 @@ function z(e) {
|
|
|
50
50
|
status: e.result.success ? "done" : "error"
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function B(e) {
|
|
54
54
|
return {
|
|
55
55
|
id: e.call.id,
|
|
56
56
|
name: e.call.name,
|
|
@@ -59,7 +59,7 @@ function G(e) {
|
|
|
59
59
|
status: "running"
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function Q(e, t) {
|
|
63
63
|
const o = t.success ? "前端操作已执行。" : t.error || "前端操作执行失败。";
|
|
64
64
|
return {
|
|
65
65
|
id: e.id,
|
|
@@ -73,28 +73,28 @@ function B(e, t) {
|
|
|
73
73
|
status: t.success ? "done" : "error"
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
|
-
function
|
|
76
|
+
function V(e) {
|
|
77
77
|
return e.startsWith("panel.") || e.startsWith("navigate.") || e.startsWith("session.");
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
if (!
|
|
81
|
-
|
|
82
|
-
const s =
|
|
79
|
+
function Y(e, t, o) {
|
|
80
|
+
if (!V(t.request.call.name)) return;
|
|
81
|
+
a(e, r.tool, "执行工具与回答");
|
|
82
|
+
const s = Q(t.request.call, o);
|
|
83
83
|
e.appendToolCallsToStep(r.tool, [s]), e.setStep(
|
|
84
84
|
r.tool,
|
|
85
85
|
o.success ? "done" : "error",
|
|
86
86
|
s.resultText
|
|
87
87
|
);
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function d(e, t) {
|
|
90
90
|
if (t !== r.tool) return;
|
|
91
91
|
const o = e.getSteps().find((s) => s.id === t);
|
|
92
92
|
!o || o.status === "active" || o.status === "done" || e.setStep(t, "active", o.content);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function R(e, t) {
|
|
95
95
|
return t || (e === r.tool ? "执行工具与回答" : e);
|
|
96
96
|
}
|
|
97
|
-
async function
|
|
97
|
+
async function K(e, t) {
|
|
98
98
|
if (t.type !== "ping") {
|
|
99
99
|
if (t.type === "step_sync")
|
|
100
100
|
e.setSteps(
|
|
@@ -106,31 +106,31 @@ async function Y(e, t) {
|
|
|
106
106
|
}))
|
|
107
107
|
);
|
|
108
108
|
else if (t.type === "step_status")
|
|
109
|
-
|
|
109
|
+
a(e, t.stepId, t.label ?? t.stepId), e.setStep(t.stepId, t.status, t.content);
|
|
110
110
|
else if (t.type === "step_content") {
|
|
111
111
|
let o = t.stepId, s = t.content;
|
|
112
|
-
if (o === r.intent &&
|
|
112
|
+
if (o === r.intent && O(s))
|
|
113
113
|
o = r.tool;
|
|
114
114
|
else if (o === r.intent && t.mode === "replace") {
|
|
115
|
-
const { intent:
|
|
116
|
-
s =
|
|
115
|
+
const { intent: n, misplacedPlanning: l } = H(s);
|
|
116
|
+
s = n, l.trim() && (a(e, r.tool, "执行工具与回答"), e.appendChunkToStep(
|
|
117
117
|
r.tool,
|
|
118
|
-
|
|
118
|
+
l
|
|
119
119
|
));
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
a(e, o, R(o, t.label)), t.mode === "replace" ? e.setStep(
|
|
122
122
|
o,
|
|
123
|
-
e.getSteps().find((
|
|
123
|
+
e.getSteps().find((n) => n.id === o)?.status ?? "active",
|
|
124
124
|
s
|
|
125
|
-
) : (
|
|
125
|
+
) : (d(e, o), e.appendChunkToStep(o, s), await U());
|
|
126
126
|
} else if (t.type === "step_artifact")
|
|
127
|
-
|
|
127
|
+
a(e, t.stepId, R(t.stepId, t.label)), d(e, t.stepId), t.artifact === "tool_calls" && t.toolCalls?.length ? e.appendToolCallsToStep(t.stepId, t.toolCalls) : t.artifact === "attachments" && t.attachments?.length ? e.appendAttachmentsToStep(t.stepId, t.attachments) : t.artifact === "files" && t.files?.length ? e.appendFilesToStep(t.stepId, t.files) : t.artifact === "artifacts" && t.artifacts?.length ? e.appendArtifactsToStep(t.stepId, t.artifacts) : t.artifact === "chat_items" && t.chatItems?.length && e.appendChatItemsToStep(t.stepId, t.chatItems);
|
|
128
128
|
else if (t.type === "tool_start")
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
a(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
|
|
130
|
+
B(t)
|
|
131
131
|
]);
|
|
132
132
|
else if (t.type === "tool_progress")
|
|
133
|
-
|
|
133
|
+
a(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
|
|
134
134
|
{
|
|
135
135
|
id: t.call.id,
|
|
136
136
|
name: t.call.name,
|
|
@@ -141,8 +141,8 @@ async function Y(e, t) {
|
|
|
141
141
|
}
|
|
142
142
|
]);
|
|
143
143
|
else if (t.type === "tool_result")
|
|
144
|
-
|
|
145
|
-
|
|
144
|
+
a(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
|
|
145
|
+
G(t)
|
|
146
146
|
]), t.result.attachments?.length && e.appendAttachmentsToStep(
|
|
147
147
|
r.tool,
|
|
148
148
|
t.result.attachments
|
|
@@ -163,35 +163,48 @@ async function Y(e, t) {
|
|
|
163
163
|
at: t.at
|
|
164
164
|
});
|
|
165
165
|
} else if (t.type === "fork_progress")
|
|
166
|
-
|
|
166
|
+
a(e, r.tool, "执行工具与回答"), e.appendChunkToStep(
|
|
167
167
|
r.tool,
|
|
168
168
|
`
|
|
169
169
|
[fork ${t.agentId}] 第 ${t.iteration} 轮 · ${t.phase}:${t.summary}
|
|
170
170
|
`
|
|
171
171
|
);
|
|
172
172
|
else if (t.type === "turn_transition")
|
|
173
|
-
t.phase === "memory_replay" && (
|
|
173
|
+
t.phase === "memory_replay" && (a(e, r.breakdown, "问题拆解"), e.setStep(
|
|
174
174
|
r.breakdown,
|
|
175
175
|
"done",
|
|
176
176
|
t.summary ?? "Memory 缓存命中,跳过 LLM 规划。"
|
|
177
177
|
));
|
|
178
|
-
else if (t.type === "
|
|
179
|
-
|
|
180
|
-
const o =
|
|
181
|
-
|
|
178
|
+
else if (t.type === "memory_decision") {
|
|
179
|
+
a(e, r.breakdown, "问题拆解");
|
|
180
|
+
const o = {
|
|
181
|
+
reuse: "已复用项目记忆",
|
|
182
|
+
augment: "正在结合历史项目结论",
|
|
183
|
+
refresh: "资料可能变化,正在重新验证",
|
|
184
|
+
ignore: "未发现可直接使用的项目记忆"
|
|
185
|
+
};
|
|
186
|
+
e.setStep(
|
|
187
|
+
r.breakdown,
|
|
188
|
+
t.decision.action === "reuse" ? "done" : "active",
|
|
189
|
+
o[t.decision.action]
|
|
190
|
+
);
|
|
191
|
+
} else if (t.type === "assistant_response") {
|
|
192
|
+
a(e, r.tool, "执行工具与回答");
|
|
193
|
+
const o = e.getSteps().find((S) => S.id === r.tool), { planning: s, answer: n } = M(o?.content ?? ""), l = t.content.trim(), c = n.trim();
|
|
194
|
+
c && l && (c === l || l.startsWith(
|
|
182
195
|
c.slice(0, Math.min(c.length, 80))
|
|
183
196
|
)) ? e.setStep(r.tool, "done") : e.setStep(
|
|
184
197
|
r.tool,
|
|
185
198
|
"done",
|
|
186
|
-
|
|
199
|
+
q(s, l)
|
|
187
200
|
);
|
|
188
201
|
}
|
|
189
|
-
|
|
202
|
+
j(t) && e.appendExecutionEvent?.(t);
|
|
190
203
|
}
|
|
191
204
|
}
|
|
192
|
-
async function
|
|
205
|
+
async function X(e) {
|
|
193
206
|
await fetch(
|
|
194
|
-
`${
|
|
207
|
+
`${T()}/v1/runs/${encodeURIComponent(e.runId)}/host-results`,
|
|
195
208
|
{
|
|
196
209
|
method: "POST",
|
|
197
210
|
headers: y(),
|
|
@@ -207,151 +220,154 @@ async function K(e) {
|
|
|
207
220
|
}
|
|
208
221
|
);
|
|
209
222
|
}
|
|
210
|
-
function
|
|
223
|
+
function Z(e) {
|
|
211
224
|
const t = e.split(/\n\n/u), o = t.pop() ?? "";
|
|
212
|
-
return { events: t.flatMap((
|
|
213
|
-
const
|
|
214
|
-
if (!
|
|
225
|
+
return { events: t.flatMap((n) => {
|
|
226
|
+
const l = n.split(/\n/u).find((c) => c.startsWith("data: "));
|
|
227
|
+
if (!l) return [];
|
|
215
228
|
try {
|
|
216
|
-
return [JSON.parse(
|
|
229
|
+
return [JSON.parse(l.slice(6))];
|
|
217
230
|
} catch {
|
|
218
231
|
return [];
|
|
219
232
|
}
|
|
220
233
|
}), rest: o };
|
|
221
234
|
}
|
|
222
|
-
async function
|
|
235
|
+
async function dt(e) {
|
|
223
236
|
await Promise.allSettled([
|
|
224
|
-
|
|
225
|
-
|
|
237
|
+
_(e),
|
|
238
|
+
D(e)
|
|
226
239
|
]);
|
|
227
240
|
}
|
|
228
|
-
async function
|
|
229
|
-
const
|
|
241
|
+
async function v(e, t, o) {
|
|
242
|
+
const s = b(), n = $(), l = L(), c = await _(t);
|
|
230
243
|
return {
|
|
231
|
-
hostManifest:
|
|
244
|
+
hostManifest: c,
|
|
232
245
|
payload: {
|
|
233
|
-
projectId:
|
|
234
|
-
sessionId:
|
|
246
|
+
projectId: W(),
|
|
247
|
+
sessionId: s.sessionId,
|
|
235
248
|
userQuestion: e,
|
|
249
|
+
memoryRefreshRequested: o?.forceMemoryRefresh === !0,
|
|
236
250
|
uiContext: F().getUiContext?.() ?? {},
|
|
237
251
|
sessionState: {
|
|
238
|
-
sessionId:
|
|
239
|
-
activeTaskId:
|
|
240
|
-
activeTopic:
|
|
241
|
-
pendingTask:
|
|
242
|
-
conversationSummary:
|
|
243
|
-
summarizedTurnCount:
|
|
244
|
-
conversationHistory:
|
|
245
|
-
lastAssistantReply:
|
|
246
|
-
invokedSkills:
|
|
247
|
-
skillPermissionGrants:
|
|
248
|
-
memoryReadEnabled:
|
|
252
|
+
sessionId: s.sessionId,
|
|
253
|
+
activeTaskId: s.activeTaskId,
|
|
254
|
+
activeTopic: s.activeTopic,
|
|
255
|
+
pendingTask: s.pendingTask,
|
|
256
|
+
conversationSummary: s.conversationSummary,
|
|
257
|
+
summarizedTurnCount: s.summarizedTurnCount,
|
|
258
|
+
conversationHistory: s.conversationHistory,
|
|
259
|
+
lastAssistantReply: s.getLastAssistantContent(),
|
|
260
|
+
invokedSkills: s.invokedSkills,
|
|
261
|
+
skillPermissionGrants: s.skillPermissionGrants,
|
|
262
|
+
memoryReadEnabled: l.enabled,
|
|
249
263
|
memoryWriteEnabled: !0
|
|
250
264
|
},
|
|
251
265
|
runtimeState: {
|
|
252
|
-
activeDomain:
|
|
253
|
-
activeTarget:
|
|
254
|
-
activeAction:
|
|
255
|
-
resumableAction:
|
|
256
|
-
lastResolvedTarget:
|
|
266
|
+
activeDomain: n.activeDomain,
|
|
267
|
+
activeTarget: n.activeTarget,
|
|
268
|
+
activeAction: n.activeAction,
|
|
269
|
+
resumableAction: n.resumableAction,
|
|
270
|
+
lastResolvedTarget: n.lastResolvedTarget
|
|
257
271
|
},
|
|
258
|
-
clientToolsManifestVersion:
|
|
259
|
-
skills:
|
|
272
|
+
clientToolsManifestVersion: c.version,
|
|
273
|
+
skills: E(A())
|
|
260
274
|
}
|
|
261
275
|
};
|
|
262
276
|
}
|
|
263
|
-
async function
|
|
264
|
-
const
|
|
277
|
+
async function pt(e, t, o) {
|
|
278
|
+
const s = T(), n = t.getSignal(), { payload: l, hostManifest: c } = await v(
|
|
265
279
|
e,
|
|
266
|
-
|
|
267
|
-
|
|
280
|
+
n,
|
|
281
|
+
o
|
|
282
|
+
), S = new Set(c.tools.map((u) => u.name)), p = await fetch(`${s}/v1/runs`, {
|
|
268
283
|
method: "POST",
|
|
269
284
|
headers: y(),
|
|
270
|
-
body: JSON.stringify(
|
|
271
|
-
signal:
|
|
285
|
+
body: JSON.stringify(l),
|
|
286
|
+
signal: n
|
|
272
287
|
});
|
|
273
|
-
if (!
|
|
274
|
-
const
|
|
288
|
+
if (!p.ok) {
|
|
289
|
+
const u = await p.text().catch(() => "");
|
|
275
290
|
throw new Error(
|
|
276
|
-
`Spotlight 后端创建 run 失败:${
|
|
291
|
+
`Spotlight 后端创建 run 失败:${p.status} ${u}`
|
|
277
292
|
);
|
|
278
293
|
}
|
|
279
|
-
const { runId: m } = await
|
|
280
|
-
|
|
294
|
+
const { runId: m } = await p.json();
|
|
295
|
+
n && (g.set(n, m), n.addEventListener(
|
|
281
296
|
"abort",
|
|
282
297
|
() => {
|
|
283
|
-
|
|
298
|
+
P(m);
|
|
284
299
|
},
|
|
285
300
|
{ once: !0 }
|
|
286
301
|
));
|
|
287
302
|
const f = await fetch(
|
|
288
|
-
`${
|
|
303
|
+
`${s}/v1/runs/${encodeURIComponent(m)}/events`,
|
|
289
304
|
{
|
|
290
305
|
headers: y(),
|
|
291
|
-
signal:
|
|
306
|
+
signal: n
|
|
292
307
|
}
|
|
293
308
|
);
|
|
294
309
|
if (!f.ok || !f.body)
|
|
295
310
|
throw new Error(`Spotlight 后端事件流连接失败:${f.status}`);
|
|
296
|
-
const
|
|
297
|
-
let
|
|
311
|
+
const C = f.body.getReader(), N = new TextDecoder();
|
|
312
|
+
let h = "", I = null;
|
|
298
313
|
try {
|
|
299
314
|
for (; ; ) {
|
|
300
|
-
const { done:
|
|
301
|
-
if (
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
for (const
|
|
306
|
-
if (
|
|
307
|
-
const
|
|
308
|
-
allowedHostNames:
|
|
309
|
-
hostEffect:
|
|
315
|
+
const { done: u, value: x } = await C.read();
|
|
316
|
+
if (u) break;
|
|
317
|
+
h += N.decode(x, { stream: !0 });
|
|
318
|
+
const k = Z(h);
|
|
319
|
+
h = k.rest;
|
|
320
|
+
for (const i of k.events) {
|
|
321
|
+
if (i.type === "host_action_request") {
|
|
322
|
+
const w = await J(i.request.call, t, {
|
|
323
|
+
allowedHostNames: S,
|
|
324
|
+
hostEffect: i.request.hostEffect
|
|
310
325
|
});
|
|
311
|
-
|
|
326
|
+
Y(t, i, w), await X({
|
|
312
327
|
runId: m,
|
|
313
|
-
correlationId:
|
|
314
|
-
result:
|
|
315
|
-
signal:
|
|
328
|
+
correlationId: i.request.correlationId,
|
|
329
|
+
result: w,
|
|
330
|
+
signal: n
|
|
316
331
|
});
|
|
317
332
|
continue;
|
|
318
333
|
}
|
|
319
|
-
if (
|
|
320
|
-
throw new Error(
|
|
321
|
-
if (await
|
|
322
|
-
return
|
|
334
|
+
if (i.type === "run_error")
|
|
335
|
+
throw new Error(i.error);
|
|
336
|
+
if (await K(t, i), i.type === "run_completed")
|
|
337
|
+
return i.sessionPatch && b().applySessionPatch(i.sessionPatch), I = i, {
|
|
323
338
|
command: null,
|
|
324
|
-
usedLegacyFallback:
|
|
325
|
-
memoryReplay:
|
|
326
|
-
|
|
339
|
+
usedLegacyFallback: i.usedQueryLoop,
|
|
340
|
+
memoryReplay: i.memoryReplay ?? null,
|
|
341
|
+
memoryDecision: i.memoryDecision ?? null,
|
|
342
|
+
assistantReply: i.assistantReply
|
|
327
343
|
};
|
|
328
344
|
}
|
|
329
345
|
}
|
|
330
346
|
} finally {
|
|
331
|
-
|
|
347
|
+
C.releaseLock();
|
|
332
348
|
}
|
|
333
349
|
return {
|
|
334
350
|
command: null,
|
|
335
|
-
usedLegacyFallback:
|
|
351
|
+
usedLegacyFallback: I?.usedQueryLoop ?? !0
|
|
336
352
|
};
|
|
337
353
|
}
|
|
338
|
-
async function
|
|
354
|
+
async function P(e) {
|
|
339
355
|
await fetch(
|
|
340
|
-
`${
|
|
356
|
+
`${T()}/v1/runs/${encodeURIComponent(e)}`,
|
|
341
357
|
{
|
|
342
358
|
method: "DELETE",
|
|
343
359
|
headers: y()
|
|
344
360
|
}
|
|
345
361
|
);
|
|
346
362
|
}
|
|
347
|
-
function
|
|
363
|
+
function mt(e) {
|
|
348
364
|
if (!e) return;
|
|
349
|
-
const t =
|
|
350
|
-
t && (
|
|
365
|
+
const t = g.get(e);
|
|
366
|
+
t && (g.delete(e), P(t));
|
|
351
367
|
}
|
|
352
368
|
export {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
369
|
+
P as cancelRemoteSpotlightRun,
|
|
370
|
+
mt as cancelRemoteSpotlightRunForSignal,
|
|
371
|
+
pt as runRemoteSpotlightPipeline,
|
|
372
|
+
dt as warmupSpotlightRemoteContext
|
|
357
373
|
};
|
package/dist/remote/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SpotlightMemoryDecision } from "@inupedia/spotlight-protocol";
|
|
1
2
|
import type { SpotlightCommand } from "../store/types.js";
|
|
2
3
|
export type SpotlightPipelineRunOutcome = {
|
|
3
4
|
command: SpotlightCommand | null;
|
|
@@ -8,5 +9,6 @@ export type SpotlightPipelineRunOutcome = {
|
|
|
8
9
|
entryId: string;
|
|
9
10
|
kind: string;
|
|
10
11
|
} | null;
|
|
12
|
+
memoryDecision?: SpotlightMemoryDecision | null;
|
|
11
13
|
};
|
|
12
14
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/remote/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE;QACb,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;QACzC,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/remote/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,YAAY,CAAC,EAAE;QACb,MAAM,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;QACzC,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,IAAI,CAAC;IACT,cAAc,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACjD,CAAC"}
|