@inupedia/spotlight-vue 0.1.10 → 0.2.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.
@@ -1 +1 @@
1
- {"version":3,"file":"runPipeline.d.ts","sourceRoot":"","sources":["../../src/remote/runPipeline.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAc7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAub9D,wBAAsB,4BAA4B,CAChD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;AAwCD,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,2BAA2B,CAAC,CAgGtC;AAED,wBAAsB,wBAAwB,CAAC,KAAK,EAAE,MAAM,iBAQ3D;AAED,wBAAgB,iCAAiC,CAAC,MAAM,CAAC,EAAE,WAAW,QAMrE"}
1
+ {"version":3,"file":"runPipeline.d.ts","sourceRoot":"","sources":["../../src/remote/runPipeline.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAc7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,YAAY,CAAC;AAmb9D,wBAAsB,4BAA4B,CAChD,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAKf;AAwCD,wBAAsB,0BAA0B,CAC9C,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,UAAU,GACd,OAAO,CAAC,2BAA2B,CAAC,CA+FtC;AAED,wBAAsB,wBAAwB,CAAC,KAAK,EAAE,MAAM,iBAQ3D;AAED,wBAAgB,iCAAiC,CAAC,MAAM,CAAC,EAAE,WAAW,QAMrE"}
@@ -7,17 +7,17 @@ import { SPOTLIGHT_PIPELINE_STEP_IDS as r } from "../store/pipeline/constants.js
7
7
  import { isLoopPlanningChunk as $, splitIntentStepContent as O, splitToolStepContent as H, composeToolStepContent as M } from "../store/pipeline/displayText.js";
8
8
  import { getSpotlightConfig as F } from "../plugin.js";
9
9
  import { executeRemoteHostTool as q, ensureHostToolsManifest as _ } from "./hostToolRunner.js";
10
- import { getSpotlightServerBase as h, buildSpotlightJsonHeaders as y, getSpotlightProjectId as J } from "./httpConfig.js";
10
+ import { getSpotlightServerBase as g, buildSpotlightJsonHeaders as y, getSpotlightProjectId as J } from "./httpConfig.js";
11
11
  import { ensureSpotlightMeta as W } from "./meta.js";
12
- const g = /* @__PURE__ */ new WeakMap();
12
+ const h = /* @__PURE__ */ new WeakMap();
13
13
  function D(e) {
14
14
  return e.type !== "host_action_request" && e.type !== "run_completed" && e.type !== "run_error" && e.type !== "ping";
15
15
  }
16
- function a(e, t, o) {
16
+ function i(e, t, o) {
17
17
  const s = e.getSteps().find((n) => n.id === t);
18
18
  if (s) return s;
19
- const l = { id: t, label: o, status: "pending" };
20
- return e.setSteps([...e.getSteps(), l]), l;
19
+ const a = { id: t, label: o, status: "pending" };
20
+ return e.setSteps([...e.getSteps(), a]), a;
21
21
  }
22
22
  function j() {
23
23
  return new Promise((e) => {
@@ -78,7 +78,7 @@ function Q(e) {
78
78
  }
79
79
  function V(e, t, o) {
80
80
  if (!Q(t.request.call.name)) return;
81
- a(e, r.tool, "执行工具与回答");
81
+ i(e, r.tool, "执行工具与回答");
82
82
  const s = B(t.request.call, o);
83
83
  e.appendToolCallsToStep(r.tool, [s]), e.setStep(
84
84
  r.tool,
@@ -86,7 +86,7 @@ function V(e, t, o) {
86
86
  s.resultText
87
87
  );
88
88
  }
89
- function p(e, t) {
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);
@@ -106,31 +106,31 @@ async function Y(e, t) {
106
106
  }))
107
107
  );
108
108
  else if (t.type === "step_status")
109
- a(e, t.stepId, t.label ?? t.stepId), e.setStep(t.stepId, t.status, t.content);
109
+ i(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
112
  if (o === r.intent && $(s))
113
113
  o = r.tool;
114
114
  else if (o === r.intent && t.mode === "replace") {
115
- const { intent: l, misplacedPlanning: n } = O(s);
116
- s = l, n.trim() && (a(e, r.tool, "执行工具与回答"), e.appendChunkToStep(
115
+ const { intent: a, misplacedPlanning: n } = O(s);
116
+ s = a, n.trim() && (i(e, r.tool, "执行工具与回答"), e.appendChunkToStep(
117
117
  r.tool,
118
118
  n
119
119
  ));
120
120
  }
121
- a(e, o, w(o, t.label)), t.mode === "replace" ? e.setStep(
121
+ i(e, o, w(o, t.label)), t.mode === "replace" ? e.setStep(
122
122
  o,
123
- e.getSteps().find((l) => l.id === o)?.status ?? "active",
123
+ e.getSteps().find((a) => a.id === o)?.status ?? "active",
124
124
  s
125
- ) : (p(e, o), e.appendChunkToStep(o, s), await j());
125
+ ) : (d(e, o), e.appendChunkToStep(o, s), await j());
126
126
  } else if (t.type === "step_artifact")
127
- a(e, t.stepId, w(t.stepId, t.label)), p(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);
127
+ i(e, t.stepId, w(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
- a(e, r.tool, "执行工具与回答"), p(e, r.tool), e.appendToolCallsToStep(r.tool, [
129
+ i(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
130
130
  G(t)
131
131
  ]);
132
132
  else if (t.type === "tool_progress")
133
- a(e, r.tool, "执行工具与回答"), p(e, r.tool), e.appendToolCallsToStep(r.tool, [
133
+ i(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,7 +141,7 @@ async function Y(e, t) {
141
141
  }
142
142
  ]);
143
143
  else if (t.type === "tool_result")
144
- a(e, r.tool, "执行工具与回答"), p(e, r.tool), e.appendToolCallsToStep(r.tool, [
144
+ i(e, r.tool, "执行工具与回答"), d(e, r.tool), e.appendToolCallsToStep(r.tool, [
145
145
  z(t)
146
146
  ]), t.result.attachments?.length && e.appendAttachmentsToStep(
147
147
  r.tool,
@@ -163,21 +163,21 @@ async function Y(e, t) {
163
163
  at: t.at
164
164
  });
165
165
  } else if (t.type === "fork_progress")
166
- a(e, r.tool, "执行工具与回答"), e.appendChunkToStep(
166
+ i(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" && (a(e, r.breakdown, "问题拆解"), e.setStep(
173
+ t.phase === "memory_replay" && (i(e, r.breakdown, "问题拆解"), e.setStep(
174
174
  r.breakdown,
175
175
  "done",
176
176
  t.summary ?? "Memory 缓存命中,跳过 LLM 规划。"
177
177
  ));
178
178
  else if (t.type === "assistant_response") {
179
- a(e, r.tool, "执行工具与回答");
180
- const o = e.getSteps().find((u) => u.id === r.tool), { planning: s, answer: l } = H(o?.content ?? ""), n = t.content.trim(), c = l.trim();
179
+ i(e, r.tool, "执行工具与回答");
180
+ const o = e.getSteps().find((u) => u.id === r.tool), { planning: s, answer: a } = H(o?.content ?? ""), n = t.content.trim(), c = a.trim();
181
181
  c && n && (c === n || n.startsWith(
182
182
  c.slice(0, Math.min(c.length, 80))
183
183
  )) ? e.setStep(r.tool, "done") : e.setStep(
@@ -191,7 +191,7 @@ async function Y(e, t) {
191
191
  }
192
192
  async function K(e) {
193
193
  await fetch(
194
- `${h()}/v1/runs/${encodeURIComponent(e.runId)}/host-results`,
194
+ `${g()}/v1/runs/${encodeURIComponent(e.runId)}/host-results`,
195
195
  {
196
196
  method: "POST",
197
197
  headers: y(),
@@ -209,8 +209,8 @@ async function K(e) {
209
209
  }
210
210
  function X(e) {
211
211
  const t = e.split(/\n\n/u), o = t.pop() ?? "";
212
- return { events: t.flatMap((l) => {
213
- const n = l.split(/\n/u).find((c) => c.startsWith("data: "));
212
+ return { events: t.flatMap((a) => {
213
+ const n = a.split(/\n/u).find((c) => c.startsWith("data: "));
214
214
  if (!n) return [];
215
215
  try {
216
216
  return [JSON.parse(n.slice(6))];
@@ -226,7 +226,7 @@ async function ut(e) {
226
226
  ]);
227
227
  }
228
228
  async function Z(e, t) {
229
- const o = R(), s = L(), l = A(), n = await _(t);
229
+ const o = R(), s = L(), a = A(), n = await _(t);
230
230
  return {
231
231
  hostManifest: n,
232
232
  payload: {
@@ -245,7 +245,7 @@ async function Z(e, t) {
245
245
  lastAssistantReply: o.getLastAssistantContent(),
246
246
  invokedSkills: o.invokedSkills,
247
247
  skillPermissionGrants: o.skillPermissionGrants,
248
- memoryEnabled: l.memoryEnabled
248
+ memoryEnabled: a.enabled
249
249
  },
250
250
  runtimeState: {
251
251
  activeDomain: s.activeDomain,
@@ -259,24 +259,24 @@ async function Z(e, t) {
259
259
  }
260
260
  };
261
261
  }
262
- async function dt(e, t) {
263
- const o = h(), s = t.getSignal(), { payload: l, hostManifest: n } = await Z(
262
+ async function pt(e, t) {
263
+ const o = g(), s = t.getSignal(), { payload: a, hostManifest: n } = await Z(
264
264
  e,
265
265
  s
266
- ), c = new Set(n.tools.map((d) => d.name)), u = await fetch(`${o}/v1/runs`, {
266
+ ), c = new Set(n.tools.map((p) => p.name)), u = await fetch(`${o}/v1/runs`, {
267
267
  method: "POST",
268
268
  headers: y(),
269
- body: JSON.stringify(l),
269
+ body: JSON.stringify(a),
270
270
  signal: s
271
271
  });
272
272
  if (!u.ok) {
273
- const d = await u.text().catch(() => "");
273
+ const p = await u.text().catch(() => "");
274
274
  throw new Error(
275
- `Spotlight 后端创建 run 失败:${u.status} ${d}`
275
+ `Spotlight 后端创建 run 失败:${u.status} ${p}`
276
276
  );
277
277
  }
278
278
  const { runId: m } = await u.json();
279
- s && (g.set(s, m), s.addEventListener(
279
+ s && (h.set(s, m), s.addEventListener(
280
280
  "abort",
281
281
  () => {
282
282
  b(m);
@@ -293,37 +293,36 @@ async function dt(e, t) {
293
293
  if (!f.ok || !f.body)
294
294
  throw new Error(`Spotlight 后端事件流连接失败:${f.status}`);
295
295
  const T = f.body.getReader(), P = new TextDecoder();
296
- let S = "", k = null;
296
+ let S = "", C = null;
297
297
  try {
298
298
  for (; ; ) {
299
- const { done: d, value: N } = await T.read();
300
- if (d) break;
299
+ const { done: p, value: N } = await T.read();
300
+ if (p) break;
301
301
  S += P.decode(N, { stream: !0 });
302
- const C = X(S);
303
- S = C.rest;
304
- for (const i of C.events) {
305
- if (i.type === "host_action_request") {
306
- const I = await q(i.request.call, t, {
302
+ const I = X(S);
303
+ S = I.rest;
304
+ for (const l of I.events) {
305
+ if (l.type === "host_action_request") {
306
+ const k = await q(l.request.call, t, {
307
307
  allowedHostNames: c,
308
- hostEffect: i.request.hostEffect
308
+ hostEffect: l.request.hostEffect
309
309
  });
310
- V(t, i, I), await K({
310
+ V(t, l, k), await K({
311
311
  runId: m,
312
- correlationId: i.request.correlationId,
313
- result: I,
312
+ correlationId: l.request.correlationId,
313
+ result: k,
314
314
  signal: s
315
315
  });
316
316
  continue;
317
317
  }
318
- if (i.type === "run_error")
319
- throw new Error(i.error);
320
- if (await Y(t, i), i.type === "run_completed")
321
- return i.sessionPatch?.invokedSkills && R().setInvokedSkills(
322
- i.sessionPatch.invokedSkills
323
- ), k = i, {
318
+ if (l.type === "run_error")
319
+ throw new Error(l.error);
320
+ if (await Y(t, l), l.type === "run_completed")
321
+ return l.sessionPatch && R().applySessionPatch(l.sessionPatch), C = l, {
324
322
  command: null,
325
- usedLegacyFallback: i.usedQueryLoop,
326
- memoryReplay: i.memoryReplay ?? null
323
+ usedLegacyFallback: l.usedQueryLoop,
324
+ memoryReplay: l.memoryReplay ?? null,
325
+ assistantReply: l.assistantReply
327
326
  };
328
327
  }
329
328
  }
@@ -332,26 +331,26 @@ async function dt(e, t) {
332
331
  }
333
332
  return {
334
333
  command: null,
335
- usedLegacyFallback: k?.usedQueryLoop ?? !0
334
+ usedLegacyFallback: C?.usedQueryLoop ?? !0
336
335
  };
337
336
  }
338
337
  async function b(e) {
339
338
  await fetch(
340
- `${h()}/v1/runs/${encodeURIComponent(e)}`,
339
+ `${g()}/v1/runs/${encodeURIComponent(e)}`,
341
340
  {
342
341
  method: "DELETE",
343
342
  headers: y()
344
343
  }
345
344
  );
346
345
  }
347
- function pt(e) {
346
+ function dt(e) {
348
347
  if (!e) return;
349
- const t = g.get(e);
350
- t && (g.delete(e), b(t));
348
+ const t = h.get(e);
349
+ t && (h.delete(e), b(t));
351
350
  }
352
351
  export {
353
352
  b as cancelRemoteSpotlightRun,
354
- pt as cancelRemoteSpotlightRunForSignal,
355
- dt as runRemoteSpotlightPipeline,
353
+ dt as cancelRemoteSpotlightRunForSignal,
354
+ pt as runRemoteSpotlightPipeline,
356
355
  ut as warmupSpotlightRemoteContext
357
356
  };
@@ -2,6 +2,7 @@ import type { SpotlightCommand } from "../store/types.js";
2
2
  export type SpotlightPipelineRunOutcome = {
3
3
  command: SpotlightCommand | null;
4
4
  usedLegacyFallback: boolean;
5
+ assistantReply?: string | null;
5
6
  memoryReplay?: {
6
7
  source: "exact" | "semantic" | "session";
7
8
  entryId: string;
@@ -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,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;CACV,CAAC"}
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;CACV,CAAC"}
@@ -42,5 +42,19 @@ export declare const useAgentSessionStore: import("pinia").StoreDefinition<"agen
42
42
  }): string;
43
43
  /** 最后一条助手回复(用于 repeat_last_answer) */
44
44
  getLastAssistantContent(): string | null;
45
+ applySessionPatch(patch: {
46
+ sessionId?: string;
47
+ activeTaskId?: string | null;
48
+ activeTopic?: string | null;
49
+ pendingTask?: PendingTask | null;
50
+ conversationSummary?: string;
51
+ summarizedTurnCount?: number;
52
+ conversationHistory?: ConversationTurn[];
53
+ lastAssistantReply?: string | null;
54
+ invokedSkills?: SpotlightSessionInvokedSkill[];
55
+ skillPermissionGrants?: string[];
56
+ memoryEnabled?: boolean;
57
+ tenantId?: string;
58
+ }): void;
45
59
  }>;
46
60
  //# sourceMappingURL=agentSession.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agentSession.d.ts","sourceRoot":"","sources":["../../src/session/agentSession.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AA2FjF,eAAO,MAAM,oBAAoB;;kBAGP,MAAM,GAAG,IAAI;iBACd,MAAM,GAAG,IAAI;iBACb,WAAW,GAAG,IAAI;;;yBAGZ,gBAAgB,EAAE;mBACxB,4BAA4B,EAAE;2BACtB,MAAM,EAAE;;uCAGF,MAAM;;sBAsBvB,MAAM,GAAG,IAAI;6BAGN,4BAA4B,EAAE;oCAGvB,MAAM;0BAIhB,MAAM,GAAG,IAAI;IAGnC,qBAAqB;yBACA,WAAW,GAAG,IAAI;IAGvC,2BAA2B;;mBAKnB,gBAAgB,CAAC,MAAM,CAAC,WACrB,MAAM,YACL,gBAAgB,CAAC,SAAS,CAAC;IAUvC,wBAAwB;sBACN,MAAM,GAAG,gBAAgB,EAAE;wCAGT,MAAM,GAAG,gBAAgB,EAAE;;sCAa7B;QAChC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC;;;;;qCAoBgC;QAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC;IAGD,sCAAsC;+BACX,MAAM,GAAG,IAAI;EAS1C,CAAC"}
1
+ {"version":3,"file":"agentSession.d.ts","sourceRoot":"","sources":["../../src/session/agentSession.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,gBAAgB,EAChB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AA8GjF,eAAO,MAAM,oBAAoB;;;;;;;;;;;uCAgBM,MAAM;;sBAwBvB,MAAM,GAAG,IAAI;6BAIN,4BAA4B,EAAE;oCAIvB,MAAM;0BAKhB,MAAM,GAAG,IAAI;IAInC,qBAAqB;yBACA,WAAW,GAAG,IAAI;IAIvC,2BAA2B;;mBAMnB,gBAAgB,CAAC,MAAM,CAAC,WACrB,MAAM,YACL,gBAAgB,CAAC,SAAS,CAAC;IAWvC,wBAAwB;sBACN,MAAM,GAAG,gBAAgB,EAAE;wCAGT,MAAM,GAAG,gBAAgB,EAAE;;sCAa7B;QAChC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC;;;;;qCAoBgC;QAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;KAClC;IAGD,sCAAsC;+BACX,MAAM,GAAG,IAAI;6BAQf;QACvB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,WAAW,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;QACjC,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,mBAAmB,CAAC,EAAE,gBAAgB,EAAE,CAAC;QACzC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QACnC,aAAa,CAAC,EAAE,4BAA4B,EAAE,CAAC;QAC/C,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;QACjC,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB;EAuBH,CAAC"}
@@ -1,45 +1,46 @@
1
- import { defineStore as m } from "pinia";
2
- const a = 8, T = 4, v = 700, g = 700;
3
- function u() {
1
+ import { defineStore as T } from "pinia";
2
+ import { readPersistedAgentSession as v, writePersistedAgentSession as d, snapshotAgentSession as g } from "./agentSessionPersistence.js";
3
+ const u = 8, k = 4, S = 700, f = 700;
4
+ function l() {
4
5
  return `session_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
5
6
  }
6
7
  function c(t) {
7
8
  return t.replace(/\s+/g, " ").trim();
8
9
  }
9
- function l(t, n) {
10
+ function m(t, n) {
10
11
  const s = c(t);
11
12
  return n <= 0 || !s ? "" : s.length <= n ? s : n <= 3 ? s.slice(0, n) : `${s.slice(0, n - 3)}...`;
12
13
  }
13
14
  function h(t) {
14
- const n = t.role === "user" ? "用户" : t.role === "assistant" ? "助手" : "工具", s = t.purpose ? `/${t.purpose}` : "", e = c(t.content), i = e.length > 48 ? `${e.slice(0, 48).trim()}...` : e;
15
- return `${n}${s}:${i || "(空)"}`;
15
+ const n = t.role === "user" ? "用户" : t.role === "assistant" ? "助手" : "工具", s = t.purpose ? `/${t.purpose}` : "", i = c(t.content), e = i.length > 48 ? `${i.slice(0, 48).trim()}...` : i;
16
+ return `${n}${s}:${e || "(空)"}`;
16
17
  }
17
- function p(t, n) {
18
+ function y(t, n) {
18
19
  const s = t.split(`
19
- `).map((i) => i.trim()).filter(Boolean), e = n.map(h);
20
- return [...s, ...e].slice(-12).join(`
20
+ `).map((e) => e.trim()).filter(Boolean), i = n.map(h);
21
+ return [...s, ...i].slice(-12).join(`
21
22
  `);
22
23
  }
23
- function d(t, n) {
24
+ function p(t, n) {
24
25
  if (n <= 0 || !t.length) return [];
25
26
  const s = [];
26
- let e = 0;
27
- for (let i = t.length - 1; i >= 0; i--) {
28
- const o = t[i], r = c(o.content).length;
29
- if (s.length > 0 && e + r > n)
27
+ let i = 0;
28
+ for (let e = t.length - 1; e >= 0; e--) {
29
+ const r = t[e], a = c(r.content).length;
30
+ if (s.length > 0 && i + a > n)
30
31
  break;
31
- if (s.length === 0 && r > n) {
32
+ if (s.length === 0 && a > n) {
32
33
  s.unshift({
33
- ...o,
34
- content: l(o.content, n)
34
+ ...r,
35
+ content: m(r.content, n)
35
36
  });
36
37
  break;
37
38
  }
38
- s.unshift(o), e += r;
39
+ s.unshift(r), i += a;
39
40
  }
40
41
  return s;
41
42
  }
42
- function S(t) {
43
+ function C(t) {
43
44
  const n = [];
44
45
  return t.conversationSummary && n.push(
45
46
  `历史摘要(已压缩 ${t.summarizedTurnCount} 条):
@@ -52,49 +53,55 @@ ${t.recentTurns.map(h).join(`
52
53
 
53
54
  `);
54
55
  }
55
- const f = m("agentSession", {
56
- state: () => ({
57
- sessionId: u(),
58
- activeTaskId: null,
59
- activeTopic: null,
60
- pendingTask: null,
61
- conversationSummary: "",
62
- summarizedTurnCount: 0,
63
- conversationHistory: [],
64
- invokedSkills: [],
65
- skillPermissionGrants: []
66
- }),
56
+ function o(t) {
57
+ d(g(t));
58
+ }
59
+ const I = T("agentSession", {
60
+ state: () => {
61
+ const t = v();
62
+ return {
63
+ sessionId: t?.sessionId ?? l(),
64
+ activeTaskId: t?.activeTaskId ?? null,
65
+ activeTopic: t?.activeTopic ?? null,
66
+ pendingTask: t?.pendingTask ?? null,
67
+ conversationSummary: t?.conversationSummary ?? "",
68
+ summarizedTurnCount: t?.summarizedTurnCount ?? 0,
69
+ conversationHistory: t?.conversationHistory ?? [],
70
+ invokedSkills: t?.invokedSkills ?? [],
71
+ skillPermissionGrants: t?.skillPermissionGrants ?? []
72
+ };
73
+ },
67
74
  actions: {
68
75
  compactTurnsIntoSummary(t) {
69
76
  if (t <= 0) return;
70
77
  const n = this.conversationHistory.slice(0, t);
71
- n.length && (this.conversationSummary = p(
78
+ n.length && (this.conversationSummary = y(
72
79
  this.conversationSummary,
73
80
  n
74
- ), this.summarizedTurnCount += n.length, this.conversationHistory = this.conversationHistory.slice(t));
81
+ ), this.summarizedTurnCount += n.length, this.conversationHistory = this.conversationHistory.slice(t), o(this.$state));
75
82
  },
76
83
  resetSession() {
77
- this.sessionId = u(), this.activeTaskId = null, this.activeTopic = null, this.pendingTask = null, this.conversationSummary = "", this.summarizedTurnCount = 0, this.conversationHistory = [], this.invokedSkills = [], this.skillPermissionGrants = [];
84
+ this.sessionId = l(), this.activeTaskId = null, this.activeTopic = null, this.pendingTask = null, this.conversationSummary = "", this.summarizedTurnCount = 0, this.conversationHistory = [], this.invokedSkills = [], this.skillPermissionGrants = [], o(this.$state);
78
85
  },
79
86
  setActiveTask(t) {
80
- this.activeTaskId = t;
87
+ this.activeTaskId = t, o(this.$state);
81
88
  },
82
89
  setInvokedSkills(t) {
83
- this.invokedSkills = t;
90
+ this.invokedSkills = t, o(this.$state);
84
91
  },
85
92
  grantSkillPermission(t) {
86
- this.skillPermissionGrants.includes(t) || this.skillPermissionGrants.push(t);
93
+ this.skillPermissionGrants.includes(t) || (this.skillPermissionGrants.push(t), o(this.$state));
87
94
  },
88
95
  setActiveTopic(t) {
89
- this.activeTopic = t;
96
+ this.activeTopic = t, o(this.$state);
90
97
  },
91
98
  /** 挂起当前任务,用于用户插问时 */
92
99
  setPendingTask(t) {
93
- this.pendingTask = t;
100
+ this.pendingTask = t, o(this.$state);
94
101
  },
95
102
  /** 清除挂起任务(用户选择不继续或导览结束) */
96
103
  clearPendingTask() {
97
- this.pendingTask = null;
104
+ this.pendingTask = null, o(this.$state);
98
105
  },
99
106
  pushTurn(t, n, s) {
100
107
  this.conversationHistory.push({
@@ -102,32 +109,32 @@ const f = m("agentSession", {
102
109
  content: n,
103
110
  timestamp: Date.now(),
104
111
  purpose: s
105
- }), this.compactConversationHistory();
112
+ }), this.compactConversationHistory(), o(this.$state);
106
113
  },
107
114
  /** 最近 N 轮对话(用于上下文压缩) */
108
115
  getRecentTurns(t) {
109
116
  return this.conversationHistory.slice(-t);
110
117
  },
111
118
  getRecentTurnsWithinChars(t) {
112
- return d(this.conversationHistory, t);
119
+ return p(this.conversationHistory, t);
113
120
  },
114
121
  compactConversationHistory() {
115
- if (this.conversationHistory.length <= a + T)
122
+ if (this.conversationHistory.length <= u + k)
116
123
  return;
117
- const t = this.conversationHistory.length - a;
124
+ const t = this.conversationHistory.length - u;
118
125
  this.compactTurnsIntoSummary(t);
119
126
  },
120
127
  getConversationSnapshot(t) {
121
- const n = t?.summaryChars ?? v, s = t?.recentTurnChars ?? g, e = this.getRecentTurnsWithinChars(s), i = l(
128
+ const n = t?.summaryChars ?? S, s = t?.recentTurnChars ?? f, i = this.getRecentTurnsWithinChars(s), e = m(
122
129
  this.conversationSummary,
123
130
  n
124
131
  );
125
132
  return {
126
- conversationSummary: i,
127
- recentTurns: e,
128
- contextText: S({
129
- conversationSummary: i,
130
- recentTurns: e,
133
+ conversationSummary: e,
134
+ recentTurns: i,
135
+ contextText: C({
136
+ conversationSummary: e,
137
+ recentTurns: i,
131
138
  summarizedTurnCount: this.summarizedTurnCount
132
139
  })
133
140
  };
@@ -141,9 +148,12 @@ const f = m("agentSession", {
141
148
  if (this.conversationHistory[t].role === "assistant")
142
149
  return this.conversationHistory[t].content;
143
150
  return null;
151
+ },
152
+ applySessionPatch(t) {
153
+ t.sessionId && (this.sessionId = t.sessionId), t.activeTaskId !== void 0 && (this.activeTaskId = t.activeTaskId), t.activeTopic !== void 0 && (this.activeTopic = t.activeTopic), t.pendingTask !== void 0 && (this.pendingTask = t.pendingTask), t.conversationSummary !== void 0 && (this.conversationSummary = t.conversationSummary), t.summarizedTurnCount !== void 0 && (this.summarizedTurnCount = t.summarizedTurnCount), t.conversationHistory?.length && (this.conversationHistory = t.conversationHistory), t.invokedSkills?.length && (this.invokedSkills = t.invokedSkills), t.skillPermissionGrants?.length && (this.skillPermissionGrants = t.skillPermissionGrants), o(this.$state);
144
154
  }
145
155
  }
146
156
  });
147
157
  export {
148
- f as useAgentSessionStore
158
+ I as useAgentSessionStore
149
159
  };
@@ -0,0 +1,18 @@
1
+ import type { ConversationTurn, PendingTask } from "../types/session.js";
2
+ import type { SpotlightSessionInvokedSkill } from "@inupedia/spotlight-protocol";
3
+ export declare const AGENT_SESSION_STORAGE_KEY = "spotlight-agent-session";
4
+ export type PersistedAgentSession = {
5
+ sessionId: string;
6
+ activeTaskId: string | null;
7
+ activeTopic: string | null;
8
+ pendingTask: PendingTask | null;
9
+ conversationSummary: string;
10
+ summarizedTurnCount: number;
11
+ conversationHistory: ConversationTurn[];
12
+ invokedSkills: SpotlightSessionInvokedSkill[];
13
+ skillPermissionGrants: string[];
14
+ };
15
+ export declare function readPersistedAgentSession(): Partial<PersistedAgentSession> | null;
16
+ export declare function writePersistedAgentSession(state: PersistedAgentSession): void;
17
+ export declare function snapshotAgentSession(state: PersistedAgentSession): PersistedAgentSession;
18
+ //# sourceMappingURL=agentSessionPersistence.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agentSessionPersistence.d.ts","sourceRoot":"","sources":["../../src/session/agentSessionPersistence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAEjF,eAAO,MAAM,yBAAyB,4BAA4B,CAAC;AAEnE,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,gBAAgB,EAAE,CAAC;IACxC,aAAa,EAAE,4BAA4B,EAAE,CAAC;IAC9C,qBAAqB,EAAE,MAAM,EAAE,CAAC;CACjC,CAAC;AAEF,wBAAgB,yBAAyB,IAAI,OAAO,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAQjF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI,CAM7E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,qBAAqB,GAAG,qBAAqB,CAYxF"}
@@ -0,0 +1,34 @@
1
+ const i = "spotlight-agent-session";
2
+ function s() {
3
+ try {
4
+ const n = localStorage.getItem(i);
5
+ return n ? JSON.parse(n) : null;
6
+ } catch {
7
+ return null;
8
+ }
9
+ }
10
+ function e(n) {
11
+ try {
12
+ localStorage.setItem(i, JSON.stringify(n));
13
+ } catch {
14
+ }
15
+ }
16
+ function o(n) {
17
+ return {
18
+ sessionId: n.sessionId,
19
+ activeTaskId: n.activeTaskId,
20
+ activeTopic: n.activeTopic,
21
+ pendingTask: n.pendingTask,
22
+ conversationSummary: n.conversationSummary,
23
+ summarizedTurnCount: n.summarizedTurnCount,
24
+ conversationHistory: n.conversationHistory,
25
+ invokedSkills: n.invokedSkills,
26
+ skillPermissionGrants: n.skillPermissionGrants
27
+ };
28
+ }
29
+ export {
30
+ i as AGENT_SESSION_STORAGE_KEY,
31
+ s as readPersistedAgentSession,
32
+ o as snapshotAgentSession,
33
+ e as writePersistedAgentSession
34
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"memoryPreferenceStore.d.ts","sourceRoot":"","sources":["../../src/store/memoryPreferenceStore.ts"],"names":[],"mappings":"AAeA,mDAAmD;AACnD,eAAO,MAAM,iCAAiC;;;sBAoBtB,OAAO;;;;;sBAAP,OAAO;;;;;sBAAP,OAAO;;4BAQ9B,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD"}
1
+ {"version":3,"file":"memoryPreferenceStore.d.ts","sourceRoot":"","sources":["../../src/store/memoryPreferenceStore.ts"],"names":[],"mappings":"AAmBA,mDAAmD;AACnD,eAAO,MAAM,iCAAiC;;;sBAoBtB,OAAO;;;;;sBAAP,OAAO;;;;;sBAAP,OAAO;;4BAQ9B,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD"}
@@ -1,19 +1,23 @@
1
- import { defineStore as a } from "pinia";
2
- import { ref as l, watch as n, computed as u } from "vue";
1
+ import { defineStore as n } from "pinia";
2
+ import { ref as a, watch as l, computed as u } from "vue";
3
3
  const r = "spotlight-memory-enabled";
4
4
  function o() {
5
5
  try {
6
6
  const e = localStorage.getItem(r);
7
- return e == null ? !0 : e !== "false";
7
+ if (e == null) return !0;
8
+ if (e === "false") return !1;
9
+ if (e === "true") return !0;
10
+ const t = JSON.parse(e);
11
+ return typeof t.enabled == "boolean" ? t.enabled : !0;
8
12
  } catch {
9
13
  return !0;
10
14
  }
11
15
  }
12
- const i = a(
16
+ const f = n(
13
17
  "spotlightMemoryPreference",
14
18
  () => {
15
- const e = l(o());
16
- return n(
19
+ const e = a(o());
20
+ return l(
17
21
  e,
18
22
  (t) => {
19
23
  try {
@@ -34,10 +38,10 @@ const i = a(
34
38
  };
35
39
  }
36
40
  );
37
- function d() {
41
+ function m() {
38
42
  return o();
39
43
  }
40
44
  export {
41
- d as readSpotlightMemoryEnabled,
42
- i as useSpotlightMemoryPreferenceStore
45
+ m as readSpotlightMemoryEnabled,
46
+ f as useSpotlightMemoryPreferenceStore
43
47
  };