@inupedia/spotlight-vue 0.3.6 → 0.4.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 +7 -89
- 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 +88 -85
- 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 +1 -1
- package/dist/components/SpotlightThinking2.vue.js +459 -398
- 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/config.d.ts +9 -18
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +9 -10
- package/dist/env.d.ts +11 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +14 -0
- package/dist/index.d.ts +3 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +92 -126
- package/dist/plugin.d.ts +6 -5
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +35 -35
- package/dist/remote/hostToolRunner.d.ts +1 -1
- package/dist/remote/hostToolRunner.d.ts.map +1 -1
- package/dist/remote/hostToolRunner.js +38 -20
- package/dist/remote/runPipeline.d.ts +3 -12
- package/dist/remote/runPipeline.d.ts.map +1 -1
- package/dist/remote/runPipeline.js +165 -181
- package/dist/remote/types.d.ts +2 -0
- package/dist/remote/types.d.ts.map +1 -1
- package/dist/skills/skillPaths.js +5 -18
- package/dist/store/memoryPreferenceCopy.d.ts +6 -0
- package/dist/store/memoryPreferenceCopy.d.ts.map +1 -0
- package/dist/store/memoryPreferenceCopy.js +14 -0
- package/dist/store/memoryResultCopy.d.ts +6 -0
- package/dist/store/memoryResultCopy.d.ts.map +1 -0
- package/dist/store/memoryResultCopy.js +12 -0
- package/dist/store/spotlightStore.d.ts +78 -12
- package/dist/store/spotlightStore.d.ts.map +1 -1
- package/dist/store/spotlightStore.js +130 -124
- package/package.json +4 -8
- package/dist/composables/useSpotlightHostCore.d.ts +0 -8
- package/dist/composables/useSpotlightHostCore.d.ts.map +0 -1
- package/dist/composables/useSpotlightHostCore.js +0 -24
- package/dist/createSpotlight.d.ts +0 -38
- package/dist/createSpotlight.d.ts.map +0 -1
- package/dist/createSpotlight.js +0 -79
- package/dist/host/capabilityHost.d.ts +0 -38
- package/dist/host/capabilityHost.d.ts.map +0 -1
- package/dist/host/capabilityHost.js +0 -81
- package/dist/host/defineApp.d.ts +0 -16
- package/dist/host/defineApp.d.ts.map +0 -1
- package/dist/host/defineApp.js +0 -26
- package/dist/host/defineHost.d.ts +0 -55
- package/dist/host/defineHost.d.ts.map +0 -1
- package/dist/host/defineHost.js +0 -54
- package/dist/host/normalizeSkills.d.ts +0 -4
- package/dist/host/normalizeSkills.d.ts.map +0 -1
- package/dist/host/normalizeSkills.js +0 -10
- package/dist/host/skillExecution.d.ts +0 -9
- package/dist/host/skillExecution.d.ts.map +0 -1
- package/dist/host/skillExecution.js +0 -13
- package/dist/resolveConfig.d.ts +0 -21
- package/dist/resolveConfig.d.ts.map +0 -1
- package/dist/resolveConfig.js +0 -13
- package/dist/workflow/createOperateDefinition.d.ts +0 -22
- package/dist/workflow/createOperateDefinition.d.ts.map +0 -1
- package/dist/workflow/createOperateDefinition.js +0 -31
- package/dist/workflow/index.d.ts +0 -6
- package/dist/workflow/index.d.ts.map +0 -1
- package/dist/workflow/index.js +0 -20
- package/dist/workflow/operate.d.ts +0 -23
- package/dist/workflow/operate.d.ts.map +0 -1
- package/dist/workflow/operate.js +0 -95
- package/dist/workflow/runHostTool.d.ts +0 -4
- package/dist/workflow/runHostTool.d.ts.map +0 -1
- package/dist/workflow/runHostTool.js +0 -12
- package/dist/workflow/sessionControl.d.ts +0 -30
- package/dist/workflow/sessionControl.d.ts.map +0 -1
- package/dist/workflow/sessionControl.js +0 -112
- package/dist/workflow/shared.d.ts +0 -6
- package/dist/workflow/shared.d.ts.map +0 -1
- package/dist/workflow/shared.js +0 -14
|
@@ -1,24 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
sessionToolHandler: c
|
|
1
|
+
import { createClientToolManifest as s } from "@inupedia/spotlight-client";
|
|
2
|
+
import { getSpotlightConfig as i, getSpotlightClientTools as a } from "../plugin.js";
|
|
3
|
+
const c = {};
|
|
4
|
+
async function m(t) {
|
|
5
|
+
const e = i(), n = c, r = e.frontendBuildId?.trim() || n?.VITE_BUILD_SHA?.trim() || "development";
|
|
6
|
+
return await s({
|
|
7
|
+
projectId: e.projectId,
|
|
8
|
+
frontendBuildId: r,
|
|
9
|
+
tools: typeof e.tools == "function" ? e.tools() : e.tools
|
|
11
10
|
});
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
}
|
|
12
|
+
async function d(t, e, n) {
|
|
13
|
+
const r = a();
|
|
14
|
+
if (!n.allowedHostNames.has(t.name) || !r.has(t.name))
|
|
15
|
+
return {
|
|
16
|
+
success: !1,
|
|
17
|
+
error: `Client tool is not registered: ${t.name}`,
|
|
18
|
+
errorCode: "UNKNOWN_TOOL",
|
|
19
|
+
trace: [],
|
|
20
|
+
executionTarget: "host"
|
|
21
|
+
};
|
|
22
|
+
try {
|
|
23
|
+
return {
|
|
24
|
+
success: !0,
|
|
25
|
+
data: await r.execute(t.name, t.input),
|
|
26
|
+
trace: [],
|
|
27
|
+
executionTarget: "host"
|
|
28
|
+
};
|
|
29
|
+
} catch (o) {
|
|
30
|
+
return {
|
|
31
|
+
success: !1,
|
|
32
|
+
error: o instanceof Error ? o.message : String(o),
|
|
33
|
+
errorCode: "TOOL_RUN_FAILED",
|
|
34
|
+
trace: [],
|
|
35
|
+
executionTarget: "host"
|
|
36
|
+
};
|
|
37
|
+
}
|
|
20
38
|
}
|
|
21
39
|
export {
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
m as ensureHostToolsManifest,
|
|
41
|
+
d as executeRemoteHostTool
|
|
24
42
|
};
|
|
@@ -1,18 +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
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}): Omit<T, "skills"> & {
|
|
8
|
-
capabilitySnapshotId?: string;
|
|
9
|
-
sessionBindingVersion?: number;
|
|
10
|
-
};
|
|
11
|
-
export declare function bindRunSessionIdentity<T>(readSessionId: () => string, connect?: (sessionId: string) => Promise<T>): Promise<{
|
|
12
|
-
sessionId: string;
|
|
13
|
-
capability?: T;
|
|
14
|
-
}>;
|
|
15
|
-
export declare function runRemoteSpotlightPipeline(userQuestion: string, api: HandlerApi): Promise<SpotlightPipelineRunOutcome>;
|
|
4
|
+
export declare function runRemoteSpotlightPipeline(userQuestion: string, api: HandlerApi, options?: {
|
|
5
|
+
forceMemoryRefresh?: boolean;
|
|
6
|
+
}): Promise<SpotlightPipelineRunOutcome>;
|
|
16
7
|
export declare function cancelRemoteSpotlightRun(runId: string): Promise<void>;
|
|
17
8
|
export declare function cancelRemoteSpotlightRunForSignal(signal?: AbortSignal): void;
|
|
18
9
|
//# sourceMappingURL=runPipeline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAiDD,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,31 +1,30 @@
|
|
|
1
|
-
import { serializeSkillsForRemote as E
|
|
2
|
-
import { getSkillsPoolForRun as
|
|
3
|
-
import { useAgentSessionStore as
|
|
4
|
-
import { useSpotlightMemoryPreferenceStore as
|
|
5
|
-
import { useSpotlightRuntimeStore as
|
|
6
|
-
import { SPOTLIGHT_PIPELINE_STEP_IDS as
|
|
7
|
-
import { isLoopPlanningChunk as
|
|
8
|
-
import { getSpotlightConfig as
|
|
9
|
-
import { executeRemoteHostTool as
|
|
10
|
-
import { getSpotlightServerBase as T, buildSpotlightJsonHeaders as
|
|
11
|
-
import { ensureSpotlightMeta as
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return e.type !== "host_action_request" && e.type !== "run_completed" && e.type !== "run_error" && e.type !== "ping";
|
|
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
|
+
import { SPOTLIGHT_PIPELINE_STEP_IDS as r } from "../store/pipeline/constants.js";
|
|
7
|
+
import { isLoopPlanningChunk as M, splitIntentStepContent as O, splitToolStepContent as H, composeToolStepContent as q } from "../store/pipeline/displayText.js";
|
|
8
|
+
import { getSpotlightConfig as D } from "../plugin.js";
|
|
9
|
+
import { executeRemoteHostTool as F, ensureHostToolsManifest as _ } from "./hostToolRunner.js";
|
|
10
|
+
import { getSpotlightServerBase as T, buildSpotlightJsonHeaders as y, getSpotlightProjectId as J } from "./httpConfig.js";
|
|
11
|
+
import { ensureSpotlightMeta as W } from "./meta.js";
|
|
12
|
+
const h = /* @__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";
|
|
16
15
|
}
|
|
17
16
|
function c(e, t, o) {
|
|
18
|
-
const s = e.getSteps().find((
|
|
17
|
+
const s = e.getSteps().find((l) => l.id === t);
|
|
19
18
|
if (s) return s;
|
|
20
|
-
const
|
|
21
|
-
return e.setSteps([...e.getSteps(),
|
|
19
|
+
const n = { id: t, label: o, status: "pending" };
|
|
20
|
+
return e.setSteps([...e.getSteps(), n]), n;
|
|
22
21
|
}
|
|
23
|
-
function
|
|
22
|
+
function B() {
|
|
24
23
|
return new Promise((e) => {
|
|
25
24
|
requestAnimationFrame(() => e());
|
|
26
25
|
});
|
|
27
26
|
}
|
|
28
|
-
function
|
|
27
|
+
function U(e) {
|
|
29
28
|
const t = e.summary?.trim();
|
|
30
29
|
if (t && t.length > 48 && !t.startsWith("{") && !t.startsWith("["))
|
|
31
30
|
return t;
|
|
@@ -37,8 +36,8 @@ function G(e) {
|
|
|
37
36
|
}
|
|
38
37
|
return t || "";
|
|
39
38
|
}
|
|
40
|
-
function
|
|
41
|
-
const t =
|
|
39
|
+
function z(e) {
|
|
40
|
+
const t = U(e.result);
|
|
42
41
|
return {
|
|
43
42
|
id: e.result.call.id,
|
|
44
43
|
name: e.result.call.name,
|
|
@@ -51,7 +50,7 @@ function V(e) {
|
|
|
51
50
|
status: e.result.success ? "done" : "error"
|
|
52
51
|
};
|
|
53
52
|
}
|
|
54
|
-
function
|
|
53
|
+
function G(e) {
|
|
55
54
|
return {
|
|
56
55
|
id: e.call.id,
|
|
57
56
|
name: e.call.name,
|
|
@@ -60,7 +59,7 @@ function Q(e) {
|
|
|
60
59
|
status: "running"
|
|
61
60
|
};
|
|
62
61
|
}
|
|
63
|
-
function
|
|
62
|
+
function Q(e, t) {
|
|
64
63
|
const o = t.success ? "前端操作已执行。" : t.error || "前端操作执行失败。";
|
|
65
64
|
return {
|
|
66
65
|
id: e.id,
|
|
@@ -74,28 +73,28 @@ function Y(e, t) {
|
|
|
74
73
|
status: t.success ? "done" : "error"
|
|
75
74
|
};
|
|
76
75
|
}
|
|
77
|
-
function
|
|
76
|
+
function V(e) {
|
|
78
77
|
return e.startsWith("panel.") || e.startsWith("navigate.") || e.startsWith("session.");
|
|
79
78
|
}
|
|
80
|
-
function
|
|
81
|
-
if (!
|
|
82
|
-
c(e,
|
|
83
|
-
const s =
|
|
84
|
-
e.appendToolCallsToStep(
|
|
85
|
-
|
|
79
|
+
function Y(e, t, o) {
|
|
80
|
+
if (!V(t.request.call.name)) return;
|
|
81
|
+
c(e, r.tool, "执行工具与回答");
|
|
82
|
+
const s = Q(t.request.call, o);
|
|
83
|
+
e.appendToolCallsToStep(r.tool, [s]), e.setStep(
|
|
84
|
+
r.tool,
|
|
86
85
|
o.success ? "done" : "error",
|
|
87
86
|
s.resultText
|
|
88
87
|
);
|
|
89
88
|
}
|
|
90
|
-
function
|
|
91
|
-
if (t !==
|
|
89
|
+
function d(e, t) {
|
|
90
|
+
if (t !== r.tool) return;
|
|
92
91
|
const o = e.getSteps().find((s) => s.id === t);
|
|
93
92
|
!o || o.status === "active" || o.status === "done" || e.setStep(t, "active", o.content);
|
|
94
93
|
}
|
|
95
|
-
function
|
|
96
|
-
return t || (e ===
|
|
94
|
+
function R(e, t) {
|
|
95
|
+
return t || (e === r.tool ? "执行工具与回答" : e);
|
|
97
96
|
}
|
|
98
|
-
async function
|
|
97
|
+
async function K(e, t) {
|
|
99
98
|
if (t.type !== "ping") {
|
|
100
99
|
if (t.type === "step_sync")
|
|
101
100
|
e.setSteps(
|
|
@@ -110,28 +109,28 @@ async function Z(e, t) {
|
|
|
110
109
|
c(e, t.stepId, t.label ?? t.stepId), e.setStep(t.stepId, t.status, t.content);
|
|
111
110
|
else if (t.type === "step_content") {
|
|
112
111
|
let o = t.stepId, s = t.content;
|
|
113
|
-
if (o ===
|
|
114
|
-
o =
|
|
115
|
-
else if (o ===
|
|
116
|
-
const { intent:
|
|
117
|
-
s =
|
|
118
|
-
|
|
119
|
-
|
|
112
|
+
if (o === r.intent && M(s))
|
|
113
|
+
o = r.tool;
|
|
114
|
+
else if (o === r.intent && t.mode === "replace") {
|
|
115
|
+
const { intent: n, misplacedPlanning: l } = O(s);
|
|
116
|
+
s = n, l.trim() && (c(e, r.tool, "执行工具与回答"), e.appendChunkToStep(
|
|
117
|
+
r.tool,
|
|
118
|
+
l
|
|
120
119
|
));
|
|
121
120
|
}
|
|
122
|
-
c(e, o,
|
|
121
|
+
c(e, o, R(o, t.label)), t.mode === "replace" ? e.setStep(
|
|
123
122
|
o,
|
|
124
|
-
e.getSteps().find((
|
|
123
|
+
e.getSteps().find((n) => n.id === o)?.status ?? "active",
|
|
125
124
|
s
|
|
126
|
-
) : (
|
|
125
|
+
) : (d(e, o), e.appendChunkToStep(o, s), await B());
|
|
127
126
|
} else if (t.type === "step_artifact")
|
|
128
|
-
c(e, t.stepId,
|
|
127
|
+
c(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);
|
|
129
128
|
else if (t.type === "tool_start")
|
|
130
|
-
c(e,
|
|
131
|
-
|
|
129
|
+
c(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
|
|
130
|
+
G(t)
|
|
132
131
|
]);
|
|
133
132
|
else if (t.type === "tool_progress")
|
|
134
|
-
c(e,
|
|
133
|
+
c(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
|
|
135
134
|
{
|
|
136
135
|
id: t.call.id,
|
|
137
136
|
name: t.call.name,
|
|
@@ -142,16 +141,16 @@ async function Z(e, t) {
|
|
|
142
141
|
}
|
|
143
142
|
]);
|
|
144
143
|
else if (t.type === "tool_result")
|
|
145
|
-
c(e,
|
|
146
|
-
|
|
144
|
+
c(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
|
|
145
|
+
z(t)
|
|
147
146
|
]), t.result.attachments?.length && e.appendAttachmentsToStep(
|
|
148
|
-
|
|
147
|
+
r.tool,
|
|
149
148
|
t.result.attachments
|
|
150
149
|
), t.result.files?.length && e.appendFilesToStep(
|
|
151
|
-
|
|
150
|
+
r.tool,
|
|
152
151
|
t.result.files
|
|
153
152
|
), t.result.toolCalls?.length && e.appendToolCallsToStep(
|
|
154
|
-
|
|
153
|
+
r.tool,
|
|
155
154
|
t.result.toolCalls
|
|
156
155
|
);
|
|
157
156
|
else if (t.type === "skill_permission_request") {
|
|
@@ -164,38 +163,51 @@ async function Z(e, t) {
|
|
|
164
163
|
at: t.at
|
|
165
164
|
});
|
|
166
165
|
} else if (t.type === "fork_progress")
|
|
167
|
-
c(e,
|
|
168
|
-
|
|
166
|
+
c(e, r.tool, "执行工具与回答"), e.appendChunkToStep(
|
|
167
|
+
r.tool,
|
|
169
168
|
`
|
|
170
169
|
[fork ${t.agentId}] 第 ${t.iteration} 轮 · ${t.phase}:${t.summary}
|
|
171
170
|
`
|
|
172
171
|
);
|
|
173
172
|
else if (t.type === "turn_transition")
|
|
174
|
-
t.phase === "memory_replay" && (c(e,
|
|
175
|
-
|
|
173
|
+
t.phase === "memory_replay" && (c(e, r.breakdown, "问题拆解"), e.setStep(
|
|
174
|
+
r.breakdown,
|
|
176
175
|
"done",
|
|
177
176
|
t.summary ?? "Memory 缓存命中,跳过 LLM 规划。"
|
|
178
177
|
));
|
|
179
|
-
else if (t.type === "
|
|
180
|
-
c(e,
|
|
181
|
-
const o =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
else if (t.type === "memory_decision") {
|
|
179
|
+
c(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
|
+
c(e, r.tool, "执行工具与回答");
|
|
193
|
+
const o = e.getSteps().find((S) => S.id === r.tool), { planning: s, answer: n } = H(o?.content ?? ""), l = t.content.trim(), a = n.trim();
|
|
194
|
+
a && l && (a === l || l.startsWith(
|
|
195
|
+
a.slice(0, Math.min(a.length, 80))
|
|
196
|
+
)) ? e.setStep(r.tool, "done") : e.setStep(
|
|
197
|
+
r.tool,
|
|
186
198
|
"done",
|
|
187
|
-
q(s,
|
|
199
|
+
q(s, l)
|
|
188
200
|
);
|
|
189
201
|
}
|
|
190
|
-
|
|
202
|
+
j(t) && e.appendExecutionEvent?.(t);
|
|
191
203
|
}
|
|
192
204
|
}
|
|
193
|
-
async function
|
|
205
|
+
async function X(e) {
|
|
194
206
|
await fetch(
|
|
195
207
|
`${T()}/v1/runs/${encodeURIComponent(e.runId)}/host-results`,
|
|
196
208
|
{
|
|
197
209
|
method: "POST",
|
|
198
|
-
headers:
|
|
210
|
+
headers: y(),
|
|
199
211
|
body: JSON.stringify({
|
|
200
212
|
correlationId: e.correlationId,
|
|
201
213
|
success: e.result.success,
|
|
@@ -208,160 +220,134 @@ async function v(e) {
|
|
|
208
220
|
}
|
|
209
221
|
);
|
|
210
222
|
}
|
|
211
|
-
function
|
|
223
|
+
function Z(e) {
|
|
212
224
|
const t = e.split(/\n\n/u), o = t.pop() ?? "";
|
|
213
|
-
return { events: t.flatMap((
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
225
|
+
return { events: t.flatMap((n) => {
|
|
226
|
+
const l = n.split(/\n/u).find((a) => a.startsWith("data: "));
|
|
227
|
+
if (!l) return [];
|
|
216
228
|
try {
|
|
217
|
-
return [JSON.parse(
|
|
229
|
+
return [JSON.parse(l.slice(6))];
|
|
218
230
|
} catch {
|
|
219
231
|
return [];
|
|
220
232
|
}
|
|
221
233
|
}), rest: o };
|
|
222
234
|
}
|
|
223
|
-
async function
|
|
235
|
+
async function dt(e) {
|
|
224
236
|
await Promise.allSettled([
|
|
225
|
-
_(
|
|
226
|
-
|
|
237
|
+
_(),
|
|
238
|
+
W(e)
|
|
227
239
|
]);
|
|
228
240
|
}
|
|
229
|
-
function
|
|
230
|
-
|
|
231
|
-
const { skills: o, ...s } = e;
|
|
232
|
-
return { ...s, ...t };
|
|
233
|
-
}
|
|
234
|
-
async function ot(e, t) {
|
|
235
|
-
const o = e(), s = t ? await t(o) : void 0;
|
|
236
|
-
return { sessionId: o, ...s ? { capability: s } : {} };
|
|
237
|
-
}
|
|
238
|
-
async function st(e, t) {
|
|
239
|
-
const o = k(), s = O(), a = $(), r = await _(t), l = B(), u = await ot(
|
|
240
|
-
() => o.sessionId,
|
|
241
|
-
l ? (y) => l.connect({
|
|
242
|
-
sessionId: y,
|
|
243
|
-
browserInstanceId: R(
|
|
244
|
-
"spotlight.browser-instance",
|
|
245
|
-
localStorage
|
|
246
|
-
),
|
|
247
|
-
tabInstanceId: R(
|
|
248
|
-
"spotlight.tab-instance",
|
|
249
|
-
sessionStorage
|
|
250
|
-
),
|
|
251
|
-
signal: t
|
|
252
|
-
}) : void 0
|
|
253
|
-
), d = u.capability, p = u.sessionId;
|
|
241
|
+
async function v(e, t, o) {
|
|
242
|
+
const s = b(), n = $(), l = L(), a = await _();
|
|
254
243
|
return {
|
|
255
|
-
hostManifest:
|
|
256
|
-
payload:
|
|
257
|
-
projectId:
|
|
258
|
-
sessionId:
|
|
244
|
+
hostManifest: a,
|
|
245
|
+
payload: {
|
|
246
|
+
projectId: J(),
|
|
247
|
+
sessionId: s.sessionId,
|
|
259
248
|
userQuestion: e,
|
|
260
|
-
|
|
249
|
+
memoryRefreshRequested: o?.forceMemoryRefresh === !0,
|
|
250
|
+
uiContext: D().getUiContext?.() ?? {},
|
|
261
251
|
sessionState: {
|
|
262
|
-
sessionId:
|
|
263
|
-
activeTaskId:
|
|
264
|
-
activeTopic:
|
|
265
|
-
pendingTask:
|
|
266
|
-
conversationSummary:
|
|
267
|
-
summarizedTurnCount:
|
|
268
|
-
conversationHistory:
|
|
269
|
-
lastAssistantReply:
|
|
270
|
-
invokedSkills:
|
|
271
|
-
skillPermissionGrants:
|
|
272
|
-
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,
|
|
273
263
|
memoryWriteEnabled: !0
|
|
274
264
|
},
|
|
275
265
|
runtimeState: {
|
|
276
|
-
activeDomain:
|
|
277
|
-
activeTarget:
|
|
278
|
-
activeAction:
|
|
279
|
-
resumableAction:
|
|
280
|
-
lastResolvedTarget:
|
|
266
|
+
activeDomain: n.activeDomain,
|
|
267
|
+
activeTarget: n.activeTarget,
|
|
268
|
+
activeAction: n.activeAction,
|
|
269
|
+
resumableAction: n.resumableAction,
|
|
270
|
+
lastResolvedTarget: n.lastResolvedTarget
|
|
281
271
|
},
|
|
282
|
-
clientToolsManifestVersion:
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
}
|
|
272
|
+
clientToolsManifestVersion: a.manifestDigest,
|
|
273
|
+
clientToolManifest: a,
|
|
274
|
+
frontendBuildId: a.frontendBuildId,
|
|
275
|
+
manifestDigest: a.manifestDigest,
|
|
276
|
+
skills: E(A())
|
|
277
|
+
}
|
|
288
278
|
};
|
|
289
279
|
}
|
|
290
|
-
function
|
|
291
|
-
const
|
|
292
|
-
if (o) return o;
|
|
293
|
-
const s = A();
|
|
294
|
-
return t.setItem(e, s), s;
|
|
295
|
-
}
|
|
296
|
-
async function ht(e, t) {
|
|
297
|
-
const o = T(), s = t.getSignal(), { payload: a, hostManifest: r } = await st(
|
|
280
|
+
async function mt(e, t, o) {
|
|
281
|
+
const s = T(), n = t.getSignal(), { payload: l, hostManifest: a } = await v(
|
|
298
282
|
e,
|
|
299
|
-
|
|
300
|
-
|
|
283
|
+
n,
|
|
284
|
+
o
|
|
285
|
+
), S = new Set(a.tools.map((u) => u.name)), m = await fetch(`${s}/v1/runs`, {
|
|
301
286
|
method: "POST",
|
|
302
|
-
headers:
|
|
303
|
-
body: JSON.stringify(
|
|
304
|
-
signal:
|
|
287
|
+
headers: y(),
|
|
288
|
+
body: JSON.stringify(l),
|
|
289
|
+
signal: n
|
|
305
290
|
});
|
|
306
|
-
if (!
|
|
307
|
-
const
|
|
291
|
+
if (!m.ok) {
|
|
292
|
+
const u = await m.text().catch(() => "");
|
|
308
293
|
throw new Error(
|
|
309
|
-
`Spotlight 后端创建 run 失败:${
|
|
294
|
+
`Spotlight 后端创建 run 失败:${m.status} ${u}`
|
|
310
295
|
);
|
|
311
296
|
}
|
|
312
|
-
const { runId:
|
|
313
|
-
|
|
297
|
+
const { runId: p } = await m.json();
|
|
298
|
+
n && (h.set(n, p), n.addEventListener(
|
|
314
299
|
"abort",
|
|
315
300
|
() => {
|
|
316
|
-
P(
|
|
301
|
+
P(p);
|
|
317
302
|
},
|
|
318
303
|
{ once: !0 }
|
|
319
304
|
));
|
|
320
|
-
const
|
|
321
|
-
`${
|
|
305
|
+
const f = await fetch(
|
|
306
|
+
`${s}/v1/runs/${encodeURIComponent(p)}/events`,
|
|
322
307
|
{
|
|
323
|
-
headers:
|
|
324
|
-
signal:
|
|
308
|
+
headers: y(),
|
|
309
|
+
signal: n
|
|
325
310
|
}
|
|
326
311
|
);
|
|
327
|
-
if (!
|
|
328
|
-
throw new Error(`Spotlight 后端事件流连接失败:${
|
|
329
|
-
const
|
|
330
|
-
let
|
|
312
|
+
if (!f.ok || !f.body)
|
|
313
|
+
throw new Error(`Spotlight 后端事件流连接失败:${f.status}`);
|
|
314
|
+
const C = f.body.getReader(), N = new TextDecoder();
|
|
315
|
+
let g = "", I = null;
|
|
331
316
|
try {
|
|
332
317
|
for (; ; ) {
|
|
333
|
-
const { done:
|
|
334
|
-
if (
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
for (const i of
|
|
318
|
+
const { done: u, value: x } = await C.read();
|
|
319
|
+
if (u) break;
|
|
320
|
+
g += N.decode(x, { stream: !0 });
|
|
321
|
+
const k = Z(g);
|
|
322
|
+
g = k.rest;
|
|
323
|
+
for (const i of k.events) {
|
|
339
324
|
if (i.type === "host_action_request") {
|
|
340
|
-
const
|
|
341
|
-
allowedHostNames:
|
|
325
|
+
const w = await F(i.request.call, t, {
|
|
326
|
+
allowedHostNames: S,
|
|
342
327
|
hostEffect: i.request.hostEffect
|
|
343
328
|
});
|
|
344
|
-
|
|
345
|
-
runId:
|
|
329
|
+
Y(t, i, w), await X({
|
|
330
|
+
runId: p,
|
|
346
331
|
correlationId: i.request.correlationId,
|
|
347
|
-
result:
|
|
348
|
-
signal:
|
|
332
|
+
result: w,
|
|
333
|
+
signal: n
|
|
349
334
|
});
|
|
350
335
|
continue;
|
|
351
336
|
}
|
|
352
337
|
if (i.type === "run_error")
|
|
353
338
|
throw new Error(i.error);
|
|
354
|
-
if (await
|
|
355
|
-
return i.sessionPatch &&
|
|
339
|
+
if (await K(t, i), i.type === "run_completed")
|
|
340
|
+
return i.sessionPatch && b().applySessionPatch(i.sessionPatch), I = i, {
|
|
356
341
|
command: null,
|
|
357
342
|
usedLegacyFallback: i.usedQueryLoop,
|
|
358
343
|
memoryReplay: i.memoryReplay ?? null,
|
|
344
|
+
memoryDecision: i.memoryDecision ?? null,
|
|
359
345
|
assistantReply: i.assistantReply
|
|
360
346
|
};
|
|
361
347
|
}
|
|
362
348
|
}
|
|
363
349
|
} finally {
|
|
364
|
-
|
|
350
|
+
C.releaseLock();
|
|
365
351
|
}
|
|
366
352
|
return {
|
|
367
353
|
command: null,
|
|
@@ -373,20 +359,18 @@ async function P(e) {
|
|
|
373
359
|
`${T()}/v1/runs/${encodeURIComponent(e)}`,
|
|
374
360
|
{
|
|
375
361
|
method: "DELETE",
|
|
376
|
-
headers:
|
|
362
|
+
headers: y()
|
|
377
363
|
}
|
|
378
364
|
);
|
|
379
365
|
}
|
|
380
|
-
function
|
|
366
|
+
function pt(e) {
|
|
381
367
|
if (!e) return;
|
|
382
|
-
const t =
|
|
383
|
-
t && (
|
|
368
|
+
const t = h.get(e);
|
|
369
|
+
t && (h.delete(e), P(t));
|
|
384
370
|
}
|
|
385
371
|
export {
|
|
386
|
-
ot as bindRunSessionIdentity,
|
|
387
372
|
P as cancelRemoteSpotlightRun,
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
St as warmupSpotlightRemoteContext
|
|
373
|
+
pt as cancelRemoteSpotlightRunForSignal,
|
|
374
|
+
mt as runRemoteSpotlightPipeline,
|
|
375
|
+
dt as warmupSpotlightRemoteContext
|
|
392
376
|
};
|
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"}
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
if (
|
|
4
|
-
return
|
|
5
|
-
}
|
|
6
|
-
function n(r, o, i) {
|
|
7
|
-
const t = o.find((e) => e.name === r);
|
|
8
|
-
if (t) {
|
|
9
|
-
if (t.skillRoot)
|
|
10
|
-
return t.skillRoot.startsWith("/") ? t.skillRoot : `${i.replace(/\/$/, "")}/${t.skillRoot.replace(/^\.\//, "")}`;
|
|
11
|
-
if (t.sourcePath) {
|
|
12
|
-
const e = l(t.sourcePath);
|
|
13
|
-
if (e)
|
|
14
|
-
return e.startsWith("/") ? e : `${i.replace(/\/$/, "")}/${e.replace(/^\.\//, "")}`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
function n(r) {
|
|
2
|
+
const e = r.replace(/\\/g, "/");
|
|
3
|
+
if (e.endsWith("/SKILL.md"))
|
|
4
|
+
return e.slice(0, -9);
|
|
17
5
|
}
|
|
18
6
|
export {
|
|
19
|
-
|
|
20
|
-
n as resolveSkillRoot
|
|
7
|
+
n as inferSkillRootFromSourcePath
|
|
21
8
|
};
|