@inupedia/spotlight-vue 0.3.6 → 0.4.1

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.
Files changed (87) hide show
  1. package/README.md +7 -89
  2. package/dist/assets/spotlight-vue.css +1 -1
  3. package/dist/components/SpotlightCommandPanel.vue.d.ts.map +1 -1
  4. package/dist/components/SpotlightCommandPanel.vue.js +1 -1
  5. package/dist/components/SpotlightCommandPanel2.vue.js +88 -85
  6. package/dist/components/SpotlightRoot.vue.d.ts.map +1 -1
  7. package/dist/components/SpotlightRoot.vue.js +21 -19
  8. package/dist/components/SpotlightThinking.vue.d.ts +3 -0
  9. package/dist/components/SpotlightThinking.vue.d.ts.map +1 -1
  10. package/dist/components/SpotlightThinking.vue.js +1 -1
  11. package/dist/components/SpotlightThinking2.vue.js +459 -398
  12. package/dist/composables/useSpotlightPanelUi.d.ts +3 -1
  13. package/dist/composables/useSpotlightPanelUi.d.ts.map +1 -1
  14. package/dist/composables/useSpotlightPanelUi.js +8 -3
  15. package/dist/config.d.ts +9 -18
  16. package/dist/config.d.ts.map +1 -1
  17. package/dist/config.js +9 -10
  18. package/dist/env.d.ts +11 -0
  19. package/dist/env.d.ts.map +1 -0
  20. package/dist/env.js +14 -0
  21. package/dist/index.d.ts +3 -14
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +92 -126
  24. package/dist/plugin.d.ts +6 -5
  25. package/dist/plugin.d.ts.map +1 -1
  26. package/dist/plugin.js +35 -35
  27. package/dist/remote/hostToolRunner.d.ts +1 -1
  28. package/dist/remote/hostToolRunner.d.ts.map +1 -1
  29. package/dist/remote/hostToolRunner.js +38 -20
  30. package/dist/remote/runPipeline.d.ts +3 -12
  31. package/dist/remote/runPipeline.d.ts.map +1 -1
  32. package/dist/remote/runPipeline.js +165 -181
  33. package/dist/remote/types.d.ts +2 -0
  34. package/dist/remote/types.d.ts.map +1 -1
  35. package/dist/skills/skillPaths.js +5 -18
  36. package/dist/store/memoryPreferenceCopy.d.ts +6 -0
  37. package/dist/store/memoryPreferenceCopy.d.ts.map +1 -0
  38. package/dist/store/memoryPreferenceCopy.js +14 -0
  39. package/dist/store/memoryResultCopy.d.ts +6 -0
  40. package/dist/store/memoryResultCopy.d.ts.map +1 -0
  41. package/dist/store/memoryResultCopy.js +12 -0
  42. package/dist/store/spotlightStore.d.ts +78 -12
  43. package/dist/store/spotlightStore.d.ts.map +1 -1
  44. package/dist/store/spotlightStore.js +130 -124
  45. package/package.json +4 -8
  46. package/dist/composables/useSpotlightHostCore.d.ts +0 -8
  47. package/dist/composables/useSpotlightHostCore.d.ts.map +0 -1
  48. package/dist/composables/useSpotlightHostCore.js +0 -24
  49. package/dist/createSpotlight.d.ts +0 -38
  50. package/dist/createSpotlight.d.ts.map +0 -1
  51. package/dist/createSpotlight.js +0 -79
  52. package/dist/host/capabilityHost.d.ts +0 -38
  53. package/dist/host/capabilityHost.d.ts.map +0 -1
  54. package/dist/host/capabilityHost.js +0 -81
  55. package/dist/host/defineApp.d.ts +0 -16
  56. package/dist/host/defineApp.d.ts.map +0 -1
  57. package/dist/host/defineApp.js +0 -26
  58. package/dist/host/defineHost.d.ts +0 -55
  59. package/dist/host/defineHost.d.ts.map +0 -1
  60. package/dist/host/defineHost.js +0 -54
  61. package/dist/host/normalizeSkills.d.ts +0 -4
  62. package/dist/host/normalizeSkills.d.ts.map +0 -1
  63. package/dist/host/normalizeSkills.js +0 -10
  64. package/dist/host/skillExecution.d.ts +0 -9
  65. package/dist/host/skillExecution.d.ts.map +0 -1
  66. package/dist/host/skillExecution.js +0 -13
  67. package/dist/resolveConfig.d.ts +0 -21
  68. package/dist/resolveConfig.d.ts.map +0 -1
  69. package/dist/resolveConfig.js +0 -13
  70. package/dist/workflow/createOperateDefinition.d.ts +0 -22
  71. package/dist/workflow/createOperateDefinition.d.ts.map +0 -1
  72. package/dist/workflow/createOperateDefinition.js +0 -31
  73. package/dist/workflow/index.d.ts +0 -6
  74. package/dist/workflow/index.d.ts.map +0 -1
  75. package/dist/workflow/index.js +0 -20
  76. package/dist/workflow/operate.d.ts +0 -23
  77. package/dist/workflow/operate.d.ts.map +0 -1
  78. package/dist/workflow/operate.js +0 -95
  79. package/dist/workflow/runHostTool.d.ts +0 -4
  80. package/dist/workflow/runHostTool.d.ts.map +0 -1
  81. package/dist/workflow/runHostTool.js +0 -12
  82. package/dist/workflow/sessionControl.d.ts +0 -30
  83. package/dist/workflow/sessionControl.d.ts.map +0 -1
  84. package/dist/workflow/sessionControl.js +0 -112
  85. package/dist/workflow/shared.d.ts +0 -6
  86. package/dist/workflow/shared.d.ts.map +0 -1
  87. package/dist/workflow/shared.js +0 -14
@@ -1,34 +1,34 @@
1
- import { defineStore as S } from "pinia";
2
- import { getSpotlightConfig as f } from "../plugin.js";
3
- import { runRemoteSpotlightPipeline as g, warmupSpotlightRemoteContext as u, cancelRemoteSpotlightRunForSignal as y } from "../remote/runPipeline.js";
4
- import { ensureSpotlightMeta as T } from "../remote/meta.js";
5
- import { devWarn as E } from "../utils/devConsole.js";
6
- import { useAgentSessionStore as a } from "../session/agentSession.js";
7
- import { useSpotlightRuntimeStore as I } from "./runtimeStore.js";
8
- import { applyPipelineError as _ } from "./pipeline/errors.js";
9
- import { SPOTLIGHT_PIPELINE_STEP_LABELS as P, SPOTLIGHT_PIPELINE_STEP_IDS as x } from "./pipeline/constants.js";
10
- import { setStepState as R } from "./pipeline/steps.js";
11
- import { typewriterAppendToStepContent as A, typewriterToStepContent as b } from "./pipeline/typing.js";
12
- import { addRecentQuestionToList as v, persistRecentQuestions as Q, loadRecentQuestions as L } from "./recent.js";
13
- import { getSuggestedQuestions as C } from "./capabilities.js";
14
- import { buildSpotlightStoreSink as N } from "./storeSink.js";
15
- import { INVESTMENT_SUB_INTENT_LABELS as ee, InvestmentSubIntent as te, PROGRESS_SUB_INTENT_LABELS as ie, ProgressSubIntent as ne, QUALITY_SUB_INTENT_LABELS as se, QualitySubIntent as re, SAFETY_SUB_INTENT_LABELS as oe, SPOTLIGHT_INTENT_LABELS as le, SUB_INTENT_CONFIG as ue, SafetySubIntent as ae, SpotlightIntent as pe } from "./types.js";
16
- const c = "spotlight-telemetry-snapshots", l = 20;
17
- function p(e) {
1
+ import { defineStore as f } from "pinia";
2
+ import { getSpotlightConfig as g } from "../plugin.js";
3
+ import { runRemoteSpotlightPipeline as y, warmupSpotlightRemoteContext as a, cancelRemoteSpotlightRunForSignal as T } from "../remote/runPipeline.js";
4
+ import { ensureSpotlightMeta as E } from "../remote/meta.js";
5
+ import { devWarn as I } from "../utils/devConsole.js";
6
+ import { useAgentSessionStore as p } from "../session/agentSession.js";
7
+ import { useSpotlightRuntimeStore as _ } from "./runtimeStore.js";
8
+ import { applyPipelineError as P } from "./pipeline/errors.js";
9
+ import { SPOTLIGHT_PIPELINE_STEP_LABELS as R, SPOTLIGHT_PIPELINE_STEP_IDS as b } from "./pipeline/constants.js";
10
+ import { setStepState as x } from "./pipeline/steps.js";
11
+ import { typewriterAppendToStepContent as A, typewriterToStepContent as v } from "./pipeline/typing.js";
12
+ import { addRecentQuestionToList as Q, persistRecentQuestions as L, loadRecentQuestions as C } from "./recent.js";
13
+ import { getSuggestedQuestions as N } from "./capabilities.js";
14
+ import { buildSpotlightStoreSink as w } from "./storeSink.js";
15
+ import { INVESTMENT_SUB_INTENT_LABELS as te, InvestmentSubIntent as ie, PROGRESS_SUB_INTENT_LABELS as se, ProgressSubIntent as ne, QUALITY_SUB_INTENT_LABELS as re, QualitySubIntent as oe, SAFETY_SUB_INTENT_LABELS as le, SPOTLIGHT_INTENT_LABELS as ue, SUB_INTENT_CONFIG as ae, SafetySubIntent as pe, SpotlightIntent as he } from "./types.js";
16
+ const m = "spotlight-telemetry-snapshots", l = 20;
17
+ function h(e) {
18
18
  return e instanceof DOMException && e.name === "AbortError" ? !0 : e instanceof Error && e.name === "AbortError";
19
19
  }
20
20
  function k() {
21
21
  try {
22
- const e = localStorage.getItem(c), i = e ? JSON.parse(e) : [];
22
+ const e = localStorage.getItem(m), i = e ? JSON.parse(e) : [];
23
23
  return Array.isArray(i) ? i.slice(0, l) : [];
24
24
  } catch {
25
25
  return [];
26
26
  }
27
27
  }
28
- function h(e) {
28
+ function c(e) {
29
29
  try {
30
30
  localStorage.setItem(
31
- c,
31
+ m,
32
32
  JSON.stringify(e.slice(0, l))
33
33
  );
34
34
  } catch {
@@ -37,57 +37,57 @@ function h(e) {
37
37
  function o(e) {
38
38
  return e.type === "step_sync" || e.type === "step_status" || e.type === "step_content" || e.type === "step_artifact";
39
39
  }
40
- function w(e) {
40
+ function B(e) {
41
41
  return e.failureClass === "tool" ? e.budgetUsage.failedToolCalls > 0 ? "tool_runtime" : "tool_failure_unrecoverable" : e.failureClass === "runtime" ? "runtime_error" : e.failureClass === "cancel" ? "cancelled" : e.stopReason === "max_turns_exhausted" ? "max_turns_exhausted" : e.stopReason === "tool_failure_unrecoverable" ? "tool_failure_unrecoverable" : "completed";
42
42
  }
43
- function m(e) {
43
+ function d(e) {
44
44
  const i = /* @__PURE__ */ new Map();
45
- let n = null;
45
+ let s = null;
46
46
  for (const t of e) {
47
- (t.type === "turn_transition" || t.type === "turn_completed") && (n = t.turnId);
48
- const s = "turnId" in t ? t.turnId : n;
49
- if (!s || o(t)) continue;
50
- const r = i.get(s) ?? [];
47
+ (t.type === "turn_transition" || t.type === "turn_completed") && (s = t.turnId);
48
+ const n = "turnId" in t ? t.turnId : s;
49
+ if (!n || o(t)) continue;
50
+ const r = i.get(n) ?? [];
51
51
  r.push({
52
- turnId: s,
52
+ turnId: n,
53
53
  at: t.at,
54
54
  kind: t.type,
55
55
  iteration: "iteration" in t ? t.iteration : void 0,
56
56
  summary: t.type === "plan" || t.type === "turn_transition" ? t.summary : t.type === "assistant_response" ? t.content : t.type === "tool_result" ? t.result.summary : void 0,
57
57
  raw: t
58
- }), i.set(s, r);
58
+ }), i.set(n, r);
59
59
  }
60
60
  return Array.from(i.values()).sort(
61
- (t, s) => s[0].at - t[0].at
61
+ (t, n) => n[0].at - t[0].at
62
62
  );
63
63
  }
64
- function d(e, i) {
65
- const n = [...e].reverse().find(
66
- (s) => s.type === "turn_completed" && s.turnId === i
64
+ function S(e, i) {
65
+ const s = [...e].reverse().find(
66
+ (n) => n.type === "turn_completed" && n.turnId === i
67
67
  );
68
- if (!n) return null;
68
+ if (!s) return null;
69
69
  const t = e.filter(
70
- (s) => s.type === "tool_result" && s.result.success === !1 && !!s.result.error
71
- ).map((s) => s.result.error).slice(-5);
70
+ (n) => n.type === "tool_result" && n.result.success === !1 && !!n.result.error
71
+ ).map((n) => n.result.error).slice(-5);
72
72
  return {
73
- turnId: n.turnId,
74
- stopReason: n.stopReason,
75
- failureClass: n.failureClass,
76
- category: w(n),
77
- elapsedMs: n.elapsedMs,
73
+ turnId: s.turnId,
74
+ stopReason: s.stopReason,
75
+ failureClass: s.failureClass,
76
+ category: B(s),
77
+ elapsedMs: s.elapsedMs,
78
78
  toolErrors: t
79
79
  };
80
80
  }
81
- function B(e) {
81
+ function M(e) {
82
82
  const i = [...e].reverse().find(
83
- (n) => n.type === "turn_completed"
83
+ (s) => s.type === "turn_completed"
84
84
  );
85
- return i ? d(e, i.turnId) : null;
85
+ return i ? S(e, i.turnId) : null;
86
86
  }
87
- function M(e, i) {
88
- return m(e).find((n) => n[0]?.turnId === i) ?? [];
87
+ function O(e, i) {
88
+ return d(e).find((s) => s[0]?.turnId === i) ?? [];
89
89
  }
90
- const z = S("spotlight", {
90
+ const Z = f("spotlight", {
91
91
  state: () => ({
92
92
  visible: !1,
93
93
  prompt: "",
@@ -105,6 +105,8 @@ const z = S("spotlight", {
105
105
  pipelineRunId: 0,
106
106
  pipelineAbortController: null,
107
107
  lastMemoryReplay: null,
108
+ lastMemoryDecision: null,
109
+ lastSubmittedQuestion: "",
108
110
  telemetrySnapshots: k()
109
111
  }),
110
112
  getters: {
@@ -117,13 +119,13 @@ const z = S("spotlight", {
117
119
  );
118
120
  },
119
121
  turnTimelines(e) {
120
- return m(e.executionEvents);
122
+ return d(e.executionEvents);
121
123
  },
122
124
  latestTurnTimeline() {
123
125
  return this.turnTimelines[0] ?? [];
124
126
  },
125
127
  latestFailureSummary(e) {
126
- return B(e.executionEvents);
128
+ return M(e.executionEvents);
127
129
  },
128
130
  latestTelemetrySnapshot(e) {
129
131
  return e.telemetrySnapshots[0] ?? null;
@@ -131,24 +133,24 @@ const z = S("spotlight", {
131
133
  },
132
134
  actions: {
133
135
  persistTurnTelemetrySnapshot(e) {
134
- const i = M(this.executionEvents, e);
136
+ const i = O(this.executionEvents, e);
135
137
  if (!i.length) return;
136
- const n = {
138
+ const s = {
137
139
  turnId: e,
138
140
  recordedAt: Date.now(),
139
141
  timeline: i,
140
- failureSummary: d(
142
+ failureSummary: S(
141
143
  this.executionEvents,
142
144
  e
143
145
  )
144
146
  };
145
147
  this.telemetrySnapshots = [
146
- n,
148
+ s,
147
149
  ...this.telemetrySnapshots.filter((t) => t.turnId !== e)
148
- ].slice(0, l), h(this.telemetrySnapshots);
150
+ ].slice(0, l), c(this.telemetrySnapshots);
149
151
  },
150
152
  exportTurnTelemetrySnapshot(e) {
151
- const i = this.telemetrySnapshots.find((n) => n.turnId === e) ?? null;
153
+ const i = this.telemetrySnapshots.find((s) => s.turnId === e) ?? null;
152
154
  return i ? JSON.stringify(i, null, 2) : null;
153
155
  },
154
156
  exportLatestTelemetrySnapshot() {
@@ -156,65 +158,65 @@ const z = S("spotlight", {
156
158
  return e ? JSON.stringify(e, null, 2) : null;
157
159
  },
158
160
  clearTelemetrySnapshots() {
159
- this.telemetrySnapshots = [], h([]);
161
+ this.telemetrySnapshots = [], c([]);
160
162
  },
161
163
  isPipelineRunActive(e) {
162
164
  return this.pipelineRunId === e && this.pipelinePhase === "running";
163
165
  },
164
166
  cancelPipeline() {
165
- this.pipelineAbortController && (y(this.pipelineAbortController.signal), this.pipelineAbortController.abort(), this.pipelineAbortController = null), this.loading && (this.loading = !1), this.pipelinePhase === "running" && (this.pipelinePhase = "cancelled");
167
+ this.pipelineAbortController && (T(this.pipelineAbortController.signal), this.pipelineAbortController.abort(), this.pipelineAbortController = null), this.loading && (this.loading = !1), this.pipelinePhase === "running" && (this.pipelinePhase = "cancelled");
166
168
  },
167
- setStep(e, i, n) {
168
- R(this.agentSteps, e, i, n);
169
+ setStep(e, i, s) {
170
+ x(this.agentSteps, e, i, s);
169
171
  },
170
172
  recordExecutionEvent(e) {
171
173
  this.executionEvents.push(e), this.executionEvents.length > 500 && this.executionEvents.splice(0, this.executionEvents.length - 500), e.type === "turn_completed" && this.persistTurnTelemetrySnapshot(e.turnId);
172
174
  },
173
- async typewriterToStep(e, i, n = 24, t) {
174
- return b(
175
+ async typewriterToStep(e, i, s = 24, t) {
176
+ return v(
175
177
  this.agentSteps,
176
178
  e,
177
179
  i,
178
- n,
180
+ s,
179
181
  t
180
182
  );
181
183
  },
182
- async typewriterAppendToStep(e, i, n = 24, t) {
184
+ async typewriterAppendToStep(e, i, s = 24, t) {
183
185
  return A(
184
186
  this.agentSteps,
185
187
  e,
186
188
  i,
187
- n,
189
+ s,
188
190
  t
189
191
  );
190
192
  },
191
193
  open() {
192
- this.visible = !0, this.loadRecentQuestions(), this.refreshSuggestedQuestions(), u(), this.selectedIndex = -1, this.prompt = "", this.error = "";
194
+ this.visible = !0, this.loadRecentQuestions(), this.refreshSuggestedQuestions(), a(), this.selectedIndex = -1, this.prompt = "", this.error = "";
193
195
  },
194
196
  /**
195
197
  * ⌘/Ctrl+L 显示数字人时:与 open() 同步推荐问法、历史与输入壳状态,但不打开面板(visible 不变)。
196
198
  * 用于「语音等同 Spotlight 文字输入」通道,Thinking 仍走 submit(),布局与 ⌘K 一致。
197
199
  */
198
200
  prepareLive2dVoiceChannel() {
199
- this.loadRecentQuestions(), this.refreshSuggestedQuestions(), u(), this.selectedIndex = -1, this.prompt = "", this.error = "";
201
+ this.loadRecentQuestions(), this.refreshSuggestedQuestions(), a(), this.selectedIndex = -1, this.prompt = "", this.error = "";
200
202
  },
201
203
  loadRecentQuestions() {
202
- this.recentQuestions = L();
204
+ this.recentQuestions = C();
203
205
  },
204
206
  addRecentQuestion(e) {
205
- this.recentQuestions = v(
207
+ this.recentQuestions = Q(
206
208
  this.recentQuestions,
207
209
  e
208
- ), Q(this.recentQuestions);
210
+ ), L(this.recentQuestions);
209
211
  },
210
212
  async refreshSuggestedQuestions() {
211
- await T();
212
- const e = f(), i = e.getUiContext?.() ?? {}, n = I(), t = {
213
+ await E();
214
+ const e = g(), i = e.getUiContext?.() ?? {}, s = _(), t = {
213
215
  sceneLevel: i.sceneLevel ?? null,
214
216
  smallTab: i.smallTab ?? null,
215
- activeTarget: n.activeTarget
217
+ activeTarget: s.activeTarget
216
218
  };
217
- this.suggestedQuestions = e.getSuggestedQuestions?.(t) ?? C(t);
219
+ this.suggestedQuestions = e.getSuggestedQuestions?.(t) ?? N(t);
218
220
  },
219
221
  getSelectionQuestions() {
220
222
  return [...this.suggestedQuestions, ...this.recentQuestions];
@@ -235,7 +237,7 @@ const z = S("spotlight", {
235
237
  this.visible = !1, this.showThinkingBar = !0;
236
238
  },
237
239
  closeThinking() {
238
- this.cancelPipeline(), this.showThinkingBar = !1, this.agentSteps = [], this.executionEvents = [], this.pendingSkillPermission = null, this.error = "", this.result = null, this.lastMemoryReplay = null, this.pipelinePhase = "idle";
240
+ this.cancelPipeline(), this.showThinkingBar = !1, this.agentSteps = [], this.executionEvents = [], this.pendingSkillPermission = null, this.error = "", this.result = null, this.lastMemoryReplay = null, this.lastMemoryDecision = null, this.pipelinePhase = "idle";
239
241
  },
240
242
  setPendingSkillPermission(e) {
241
243
  this.pendingSkillPermission = e;
@@ -245,32 +247,32 @@ const z = S("spotlight", {
245
247
  },
246
248
  approvePendingSkillPermission() {
247
249
  const e = this.pendingSkillPermission;
248
- e && (a().grantSkillPermission(e.skillName), this.pendingSkillPermission = null);
250
+ e && (p().grantSkillPermission(e.skillName), this.pendingSkillPermission = null);
249
251
  },
250
252
  /** 供 pipeline handlers 使用,不直接依赖 pinia 的 api 封装 */
251
253
  buildHandlerApi(e, i) {
252
- const n = () => this.isPipelineRunActive(e);
253
- return N({
254
+ const s = () => this.isPipelineRunActive(e);
255
+ return w({
254
256
  signal: i,
255
- isCurrentRun: n,
257
+ isCurrentRun: s,
256
258
  getSteps: () => this.agentSteps,
257
259
  replaceSteps: (t) => {
258
260
  this.agentSteps = t;
259
261
  },
260
- setStep: (t, s, r) => {
261
- this.setStep(t, s, r);
262
+ setStep: (t, n, r) => {
263
+ this.setStep(t, n, r);
262
264
  },
263
- typewriterToStep: (t, s, r) => this.typewriterToStep(
265
+ typewriterToStep: (t, n, r) => this.typewriterToStep(
264
266
  t,
265
- s,
267
+ n,
266
268
  r,
267
- n
269
+ s
268
270
  ),
269
- typewriterAppendToStep: (t, s, r) => this.typewriterAppendToStep(
271
+ typewriterAppendToStep: (t, n, r) => this.typewriterAppendToStep(
270
272
  t,
271
- s,
273
+ n,
272
274
  r,
273
- n
275
+ s
274
276
  ),
275
277
  setError: (t) => {
276
278
  this.error = t;
@@ -293,52 +295,56 @@ const z = S("spotlight", {
293
295
  const e = this.getSelectionQuestions().length;
294
296
  e && (this.selectedIndex = this.selectedIndex < 0 ? e - 1 : (this.selectedIndex - 1 + e) % e);
295
297
  },
296
- async submit() {
298
+ async submit(e) {
297
299
  if (!this.prompt.trim() || this.loading) return;
298
- const e = this.pipelineRunId + 1;
299
- this.pipelineRunId = e;
300
- const i = new AbortController();
301
- this.pipelineAbortController = i, this.pipelinePhase = "running", this.loading = !0, this.error = "", this.result = null, this.lastMemoryReplay = null, this.executionEvents = [];
302
- const n = this.prompt.trim();
303
- this.addRecentQuestion(n), this.agentSteps = [], this.openThinkingBar();
300
+ const i = this.pipelineRunId + 1;
301
+ this.pipelineRunId = i;
302
+ const s = new AbortController();
303
+ this.pipelineAbortController = s, this.pipelinePhase = "running", this.loading = !0, this.error = "", this.result = null, this.lastMemoryReplay = null, this.lastMemoryDecision = null, this.executionEvents = [];
304
+ const t = this.prompt.trim();
305
+ this.lastSubmittedQuestion = t, this.addRecentQuestion(t), this.agentSteps = [], this.openThinkingBar();
304
306
  try {
305
- const t = this.buildHandlerApi(e, i.signal);
307
+ const n = this.buildHandlerApi(i, s.signal);
306
308
  try {
307
- const s = await g(
309
+ const r = await y(
310
+ t,
308
311
  n,
309
- t
312
+ e
310
313
  );
311
- s.memoryReplay && (this.lastMemoryReplay = s.memoryReplay);
312
- const r = a();
313
- r.pushTurn("user", n, "main_task"), s.assistantReply?.trim() && r.pushTurn("assistant", s.assistantReply, "main_task");
314
- } catch (s) {
315
- if (!this.isPipelineRunActive(e)) return;
316
- if (p(s)) {
314
+ r.memoryReplay && (this.lastMemoryReplay = r.memoryReplay), r.memoryDecision && (this.lastMemoryDecision = r.memoryDecision);
315
+ const u = p();
316
+ u.pushTurn("user", t, "main_task"), r.assistantReply?.trim() && u.pushTurn("assistant", r.assistantReply, "main_task");
317
+ } catch (r) {
318
+ if (!this.isPipelineRunActive(i)) return;
319
+ if (h(r)) {
317
320
  this.pipelinePhase = "cancelled";
318
321
  return;
319
322
  }
320
- throw E("Spotlight", "远程流水线异常(将向上抛出)", s), s;
323
+ throw I("Spotlight", "远程流水线异常(将向上抛出)", r), r;
321
324
  }
322
- } catch (t) {
323
- if (!this.isPipelineRunActive(e)) return;
324
- if (p(t)) {
325
+ } catch (n) {
326
+ if (!this.isPipelineRunActive(i)) return;
327
+ if (h(n)) {
325
328
  this.pipelinePhase = "cancelled";
326
329
  return;
327
330
  }
328
- const s = t instanceof Error ? t.message : "解析失败";
331
+ const r = n instanceof Error ? n.message : "解析失败";
329
332
  this.agentSteps.length === 0 && (this.agentSteps = [
330
333
  {
331
- id: x.intent,
332
- label: P.intent,
334
+ id: b.intent,
335
+ label: R.intent,
333
336
  status: "error",
334
- content: s
337
+ content: r
335
338
  }
336
- ]), _(this.buildHandlerApi(e, i.signal), s), this.pipelinePhase = "error";
339
+ ]), P(this.buildHandlerApi(i, s.signal), r), this.pipelinePhase = "error";
337
340
  } finally {
338
- const t = this.pipelinePhase;
339
- (this.isPipelineRunActive(e) || t === "done") && (this.loading = !1, this.pipelineAbortController = null, t === "running" && (this.pipelinePhase = "done"));
341
+ const n = this.pipelinePhase;
342
+ (this.isPipelineRunActive(i) || n === "done") && (this.loading = !1, this.pipelineAbortController = null, n === "running" && (this.pipelinePhase = "done"));
340
343
  }
341
344
  },
345
+ async forceRefreshLastAnswer() {
346
+ this.loading || !this.lastSubmittedQuestion.trim() || (this.prompt = this.lastSubmittedQuestion, await this.submit({ forceMemoryRefresh: !0 }));
347
+ },
342
348
  handleEnter() {
343
349
  if (!this.loading) {
344
350
  if (!this.prompt.trim()) {
@@ -351,16 +357,16 @@ const z = S("spotlight", {
351
357
  }
352
358
  });
353
359
  export {
354
- ee as INVESTMENT_SUB_INTENT_LABELS,
355
- te as InvestmentSubIntent,
356
- ie as PROGRESS_SUB_INTENT_LABELS,
360
+ te as INVESTMENT_SUB_INTENT_LABELS,
361
+ ie as InvestmentSubIntent,
362
+ se as PROGRESS_SUB_INTENT_LABELS,
357
363
  ne as ProgressSubIntent,
358
- se as QUALITY_SUB_INTENT_LABELS,
359
- re as QualitySubIntent,
360
- oe as SAFETY_SUB_INTENT_LABELS,
361
- le as SPOTLIGHT_INTENT_LABELS,
362
- ue as SUB_INTENT_CONFIG,
363
- ae as SafetySubIntent,
364
- pe as SpotlightIntent,
365
- z as useSpotlightStore
364
+ re as QUALITY_SUB_INTENT_LABELS,
365
+ oe as QualitySubIntent,
366
+ le as SAFETY_SUB_INTENT_LABELS,
367
+ ue as SPOTLIGHT_INTENT_LABELS,
368
+ ae as SUB_INTENT_CONFIG,
369
+ pe as SafetySubIntent,
370
+ he as SpotlightIntent,
371
+ Z as useSpotlightStore
366
372
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inupedia/spotlight-vue",
3
- "version": "0.3.6",
4
- "description": "Vue plugin and config entry for Inupedia Spotlight (monorepo workspace package)",
3
+ "version": "0.4.1",
4
+ "description": "Thin Vue runtime for Inupedia Spotlight Client Tools",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "inupedia",
@@ -26,10 +26,6 @@
26
26
  "types": "./dist/store/index.d.ts",
27
27
  "import": "./dist/store/index.js"
28
28
  },
29
- "./workflow": {
30
- "types": "./dist/workflow/index.d.ts",
31
- "import": "./dist/workflow/index.js"
32
- },
33
29
  "./testing": {
34
30
  "types": "./dist/testing/index.d.ts",
35
31
  "import": "./dist/testing/index.js"
@@ -95,8 +91,8 @@
95
91
  "dependencies": {
96
92
  "prettier": "^3.8.1",
97
93
  "yaml": "^2.8.4",
98
- "@inupedia/spotlight-client": "0.3.6",
99
- "@inupedia/spotlight-protocol": "0.3.6"
94
+ "@inupedia/spotlight-client": "0.4.1",
95
+ "@inupedia/spotlight-protocol": "0.4.1"
100
96
  },
101
97
  "peerDependencies": {
102
98
  "@inspira-ui/plugins": "^0.0.2",
@@ -1,8 +0,0 @@
1
- import { type SpotlightFrontendAction, type SpotlightHostCore, type SpotlightReadableContext } from "@inupedia/spotlight-client";
2
- export type UseSpotlightHostCoreOptions = {
3
- core?: SpotlightHostCore;
4
- };
5
- export declare function useSpotlightReadable(readable: SpotlightReadableContext, options?: UseSpotlightHostCoreOptions): void;
6
- export declare function useSpotlightAction<TInput extends Record<string, unknown> = Record<string, unknown>>(action: SpotlightFrontendAction<TInput>, options?: UseSpotlightHostCoreOptions): void;
7
- export declare function getDefaultSpotlightHostCore(): SpotlightHostCore;
8
- //# sourceMappingURL=useSpotlightHostCore.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSpotlightHostCore.d.ts","sourceRoot":"","sources":["../../src/composables/useSpotlightHostCore.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,EAC9B,MAAM,4BAA4B,CAAC;AAIpC,MAAM,MAAM,2BAA2B,GAAG;IACxC,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B,CAAC;AAQF,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,wBAAwB,EAClC,OAAO,GAAE,2BAAgC,GACxC,IAAI,CAGN;AAED,wBAAgB,kBAAkB,CAChC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAEhE,MAAM,EAAE,uBAAuB,CAAC,MAAM,CAAC,EACvC,OAAO,GAAE,2BAAgC,GACxC,IAAI,CAKN;AAED,wBAAgB,2BAA2B,IAAI,iBAAiB,CAE/D"}
@@ -1,24 +0,0 @@
1
- import { getCurrentScope as n, onScopeDispose as c } from "vue";
2
- import { createSpotlightHostCore as s } from "@inupedia/spotlight-client";
3
- const r = s();
4
- function i(e) {
5
- n() && c(e);
6
- }
7
- function p(e, t = {}) {
8
- const o = (t.core ?? r).registerReadable(e);
9
- i(o);
10
- }
11
- function f(e, t = {}) {
12
- const o = (t.core ?? r).registerAction(
13
- e
14
- );
15
- i(o);
16
- }
17
- function l() {
18
- return r;
19
- }
20
- export {
21
- l as getDefaultSpotlightHostCore,
22
- f as useSpotlightAction,
23
- p as useSpotlightReadable
24
- };
@@ -1,38 +0,0 @@
1
- import type { InjectionKey, Plugin } from "vue";
2
- import { type CapabilityConnectInputV1, type CapabilityConnectResultV1, type SpotlightClientConfig, type SpotlightProjectV1 } from "@inupedia/spotlight-client";
3
- import type { CapabilityBuildInfoV1 } from "@inupedia/spotlight-client/vite";
4
- export interface SpotlightCapabilityRuntimeV1 {
5
- readonly project: SpotlightProjectV1;
6
- connect(input: CapabilityConnectInputV1): Promise<CapabilityConnectResultV1>;
7
- disconnect(sessionId: string): void;
8
- dispose(): void;
9
- pendingBuild(): Readonly<CapabilityBuildInfoV1> | undefined;
10
- notifyBuild(buildInfo: Readonly<CapabilityBuildInfoV1>): void;
11
- }
12
- export declare const SPOTLIGHT_CAPABILITY_RUNTIME_KEY: InjectionKey<SpotlightCapabilityRuntimeV1>;
13
- export declare function getSpotlightCapabilityRuntime(): SpotlightCapabilityRuntimeV1 | undefined;
14
- export interface CreateSpotlightOptionsV1 {
15
- /** Reuse the same config as SpotlightVue so endpoint and auth cannot drift. */
16
- config?: Pick<SpotlightClientConfig, "serverUrl" | "apiKey">;
17
- /** @deprecated Prefer config.serverUrl. */
18
- endpoint?: string;
19
- /** @deprecated Prefer config.apiKey. */
20
- apiKey?: string;
21
- project: SpotlightProjectV1;
22
- capabilities?: {
23
- capabilityBuildInfo: Readonly<CapabilityBuildInfoV1>;
24
- openUploadStream: NonNullable<CreateSpotlightOptionsV1["openUploadStream"]>;
25
- };
26
- capabilityBuildInfo?: Readonly<CapabilityBuildInfoV1>;
27
- openUploadStream?: () => Promise<{
28
- digest: string;
29
- byteLength: number;
30
- contentType: "application/gzip";
31
- stream: ReadableStream<Uint8Array>;
32
- }>;
33
- fetch?: typeof globalThis.fetch;
34
- createWebSocket?: (url: string) => WebSocket;
35
- }
36
- export type SpotlightPluginV1 = Plugin & SpotlightCapabilityRuntimeV1;
37
- export declare function createSpotlight(options: CreateSpotlightOptionsV1): SpotlightPluginV1;
38
- //# sourceMappingURL=createSpotlight.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createSpotlight.d.ts","sourceRoot":"","sources":["../src/createSpotlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,OAAO,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IAC7E,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,IAAI,IAAI,CAAC;IAChB,YAAY,IAAI,QAAQ,CAAC,qBAAqB,CAAC,GAAG,SAAS,CAAC;IAC5D,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,IAAI,CAAC;CAC/D;AAED,eAAO,MAAM,gCAAgC,EAAE,YAAY,CAAC,4BAA4B,CAChD,CAAC;AAGzC,wBAAgB,6BAA6B,IAAI,4BAA4B,GAAG,SAAS,CAExF;AAED,MAAM,WAAW,wBAAwB;IACvC,+EAA+E;IAC/E,MAAM,CAAC,EAAE,IAAI,CAAC,qBAAqB,EAAE,WAAW,GAAG,QAAQ,CAAC,CAAC;IAC7D,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,YAAY,CAAC,EAAE;QACb,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;QACrD,gBAAgB,EAAE,WAAW,CAAC,wBAAwB,CAAC,kBAAkB,CAAC,CAAC,CAAC;KAC7E,CAAC;IACF,mBAAmB,CAAC,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IACtD,gBAAgB,CAAC,EAAE,MAAM,OAAO,CAAC;QAC/B,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,kBAAkB,CAAC;QAChC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;KACpC,CAAC,CAAC;IACH,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;CAC9C;AAED,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,4BAA4B,CAAC;AAEtE,wBAAgB,eAAe,CAAC,OAAO,EAAE,wBAAwB,GAAG,iBAAiB,CA8FpF"}
@@ -1,79 +0,0 @@
1
- import { createFrontendToolRegistry as S, subscribeCapabilityRuntimeV1 as j, createCapabilityClient as B, waitForCapabilityRuntimeV1 as C } from "@inupedia/spotlight-client";
2
- const E = /* @__PURE__ */ Symbol("spotlight-capability-runtime");
3
- let b;
4
- function U() {
5
- return b;
6
- }
7
- function O(t) {
8
- const g = t.config?.serverUrl?.trim() || t.endpoint?.trim();
9
- if (!g) throw new Error("createSpotlight: config.serverUrl or endpoint is required");
10
- const I = t.config?.apiKey?.trim() || t.apiKey?.trim() || void 0, v = S(t.project), i = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
11
- let u, c, l, s;
12
- const h = (e) => c || (t.capabilities ? c = Promise.resolve(t.capabilities) : t.capabilityBuildInfo && t.openUploadStream ? c = Promise.resolve({ capabilityBuildInfo: t.capabilityBuildInfo, openUploadStream: t.openUploadStream }) : C(t.project.projectId, e)), a = Object.assign(
13
- {
14
- project: t.project,
15
- async connect(e) {
16
- const d = n.get(e.sessionId);
17
- if (d) return d.promise;
18
- const o = new AbortController(), y = () => o.abort(e.signal?.reason);
19
- e.signal?.aborted ? o.abort(e.signal.reason) : e.signal?.addEventListener("abort", y, { once: !0 });
20
- const w = () => e.signal?.removeEventListener("abort", y), f = (async () => {
21
- const r = i.get(e.sessionId);
22
- if (r) {
23
- if (!r.channel) return r;
24
- try {
25
- return await r.channel.renew(), r;
26
- } catch {
27
- i.get(e.sessionId) === r && (r.channel.close(), i.delete(e.sessionId), l = void 0);
28
- }
29
- }
30
- const m = await h(o.signal);
31
- l ??= B({
32
- endpoint: g,
33
- apiKey: I,
34
- project: t.project,
35
- registry: v,
36
- buildInfo: m.capabilityBuildInfo,
37
- openUploadStream: m.openUploadStream,
38
- fetch: t.fetch,
39
- createWebSocket: t.createWebSocket
40
- });
41
- const p = await l.connect({ ...e, signal: o.signal });
42
- if (o.signal.aborted)
43
- throw p.channel?.close(), new DOMException("Capability connect aborted.", "AbortError");
44
- return i.set(e.sessionId, p), p;
45
- })();
46
- n.set(e.sessionId, { promise: f, controller: o, cleanup: w });
47
- try {
48
- return await f;
49
- } finally {
50
- const r = n.get(e.sessionId);
51
- r?.promise === f && (r.cleanup(), n.delete(e.sessionId));
52
- }
53
- },
54
- disconnect(e) {
55
- n.get(e)?.controller.abort(new DOMException("Capability connect disconnected.", "AbortError")), i.get(e)?.channel?.close(), i.delete(e);
56
- },
57
- dispose() {
58
- for (const e of i.values()) e.channel?.close();
59
- i.clear();
60
- for (const e of n.values())
61
- e.controller.abort(new DOMException("Spotlight disposed.", "AbortError")), e.cleanup();
62
- n.clear(), s?.(), s = void 0, b === a && (b = void 0);
63
- },
64
- pendingBuild: () => u,
65
- notifyBuild(e) {
66
- i.size > 0 || e.artifactDigest !== t.capabilityBuildInfo?.artifactDigest ? u = Object.freeze({ ...e }) : (c = void 0, l = void 0);
67
- },
68
- install(e) {
69
- b = a, s?.(), s = j(t.project.projectId, (d) => a.notifyBuild(d)), e.provide(E, a);
70
- }
71
- }
72
- );
73
- return Object.freeze(a), a;
74
- }
75
- export {
76
- E as SPOTLIGHT_CAPABILITY_RUNTIME_KEY,
77
- O as createSpotlight,
78
- U as getSpotlightCapabilityRuntime
79
- };