cursor-buddy 0.0.2 → 0.0.3

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,53 +1,25 @@
1
- //#region src/core/services/voice-capture.d.ts
1
+ //#region src/core/utils/elements.d.ts
2
2
  /**
3
- * Framework-agnostic service for voice capture using AudioWorkletNode.
3
+ * Element discovery for annotated screenshots.
4
+ * Finds visible interactive elements and assigns marker IDs.
4
5
  */
5
- declare class VoiceCaptureService {
6
- private audioContext;
7
- private workletNode;
8
- private stream;
9
- private chunks;
10
- private levelCallback;
11
- /**
12
- * Register a callback to receive audio level updates (0-1).
13
- * Called at ~60fps during recording for waveform visualization.
14
- */
15
- onLevel(callback: (level: number) => void): void;
16
- /**
17
- * Start recording audio from the microphone.
18
- * @throws Error if microphone access is denied
19
- */
20
- start(): Promise<void>;
21
- /**
22
- * Stop recording and return the captured audio as a WAV blob.
23
- */
24
- stop(): Promise<Blob>;
25
- /**
26
- * Clean up all resources.
27
- */
28
- dispose(): void;
29
- }
30
- //#endregion
31
- //#region src/core/services/audio-playback.d.ts
32
6
  /**
33
- * Framework-agnostic service for audio playback with abort support.
7
+ * Element marker with reference to actual DOM element.
34
8
  */
35
- declare class AudioPlaybackService {
36
- private audio;
37
- private currentUrl;
38
- /**
39
- * Play audio from a blob. Stops any currently playing audio first.
40
- * @param blob - Audio blob to play
41
- * @param signal - Optional AbortSignal to cancel playback
42
- * @returns Promise that resolves when playback completes
43
- */
44
- play(blob: Blob, signal?: AbortSignal): Promise<void>;
45
- /**
46
- * Stop any currently playing audio.
47
- */
48
- stop(): void;
49
- private cleanup;
9
+ interface ElementMarker {
10
+ /** Sequential marker ID (1, 2, 3...) */
11
+ id: number;
12
+ /** Reference to the actual DOM element */
13
+ element: Element;
14
+ /** Bounding rect at time of capture */
15
+ rect: DOMRect;
16
+ /** Brief description for AI context */
17
+ description: string;
50
18
  }
19
+ /**
20
+ * Map of marker ID to element marker.
21
+ */
22
+ type MarkerMap = Map<number, ElementMarker>;
51
23
  //#endregion
52
24
  //#region src/core/types.d.ts
53
25
  /**
@@ -74,7 +46,10 @@ type VoiceEvent = {
74
46
  error: Error;
75
47
  };
76
48
  /**
77
- * Point coordinates parsed from AI response [POINT:x,y:label]
49
+ * Point coordinates parsed from AI response.
50
+ * Supports two formats:
51
+ * - Marker-based: [POINT:5:label] - references a numbered marker
52
+ * - Coordinate-based: [POINT:640,360:label] - raw pixel coordinates
78
53
  */
79
54
  interface PointingTarget {
80
55
  /** X coordinate in viewport pixels (top-left origin) */
@@ -106,6 +81,57 @@ interface ScreenshotResult {
106
81
  /** Live browser viewport height in CSS pixels */
107
82
  viewportHeight: number;
108
83
  }
84
+ /**
85
+ * Annotated screenshot result with marker map.
86
+ */
87
+ interface AnnotatedScreenshotResult extends ScreenshotResult {
88
+ /** Map of marker ID to element reference */
89
+ markerMap: MarkerMap;
90
+ /** Text description of markers for AI context */
91
+ markerContext: string;
92
+ }
93
+ /**
94
+ * Public contract for voice capture used by the core client.
95
+ */
96
+ interface VoiceCapturePort {
97
+ start(): Promise<void>;
98
+ stop(): Promise<Blob>;
99
+ onLevel(callback: (level: number) => void): void;
100
+ dispose(): void;
101
+ }
102
+ /**
103
+ * Public contract for audio playback used by the core client.
104
+ */
105
+ interface AudioPlaybackPort {
106
+ play(blob: Blob, signal?: AbortSignal): Promise<void>;
107
+ stop(): void;
108
+ }
109
+ /**
110
+ * Public contract for screenshot capture used by the core client.
111
+ */
112
+ interface ScreenCapturePort {
113
+ capture(): Promise<ScreenshotResult>;
114
+ captureAnnotated(): Promise<AnnotatedScreenshotResult>;
115
+ }
116
+ /**
117
+ * Public contract for pointer control used by the core client.
118
+ */
119
+ interface PointerControllerPort {
120
+ pointAt(target: PointingTarget): void;
121
+ release(): void;
122
+ isPointing(): boolean;
123
+ subscribe(listener: () => void): () => void;
124
+ updateFollowPosition(): void;
125
+ }
126
+ /**
127
+ * Internal services interface for dependency injection.
128
+ */
129
+ interface CursorBuddyServices {
130
+ voiceCapture?: VoiceCapturePort;
131
+ audioPlayback?: AudioPlaybackPort;
132
+ screenCapture?: ScreenCapturePort;
133
+ pointerController?: PointerControllerPort;
134
+ }
109
135
  /**
110
136
  * Cursor render props passed to custom cursor components
111
137
  */
@@ -172,69 +198,7 @@ interface CursorBuddySnapshot {
172
198
  isEnabled: boolean;
173
199
  }
174
200
  //#endregion
175
- //#region src/core/services/screen-capture.d.ts
176
- /**
177
- * Framework-agnostic service for capturing viewport screenshots.
178
- */
179
- declare class ScreenCaptureService {
180
- /**
181
- * Capture a screenshot of the current viewport.
182
- * @returns Screenshot result with image data and dimensions
183
- */
184
- capture(): Promise<ScreenshotResult>;
185
- }
186
- //#endregion
187
- //#region src/core/services/pointer-controller.d.ts
188
- type PointerMode = "follow" | "flying" | "anchored";
189
- /**
190
- * Controller for cursor pointing behavior.
191
- * Manages the pointer state machine (follow -> flying -> anchored -> follow)
192
- * and cursor animation.
193
- */
194
- declare class PointerController {
195
- private mode;
196
- private cancelAnimation;
197
- private releaseTimeout;
198
- private listeners;
199
- /**
200
- * Animate cursor to point at a target.
201
- */
202
- pointAt(target: PointingTarget): void;
203
- /**
204
- * Release the cursor from pointing mode back to follow mode.
205
- */
206
- release(): void;
207
- /**
208
- * Check if cursor is currently pointing (flying or anchored).
209
- */
210
- isPointing(): boolean;
211
- /**
212
- * Get current pointer mode.
213
- */
214
- getMode(): PointerMode;
215
- /**
216
- * Subscribe to pointer state changes.
217
- */
218
- subscribe(listener: () => void): () => void;
219
- /**
220
- * Update buddy position to follow cursor when in follow mode.
221
- * Call this on cursor position changes.
222
- */
223
- updateFollowPosition(): void;
224
- private scheduleRelease;
225
- private notify;
226
- }
227
- //#endregion
228
201
  //#region src/core/client.d.ts
229
- /**
230
- * Internal services interface for dependency injection (testing).
231
- */
232
- interface CursorBuddyServices {
233
- voiceCapture?: VoiceCaptureService;
234
- audioPlayback?: AudioPlaybackService;
235
- screenCapture?: ScreenCaptureService;
236
- pointerController?: PointerController;
237
- }
238
202
  /**
239
203
  * Framework-agnostic client for cursor buddy voice interactions.
240
204
  *
@@ -256,6 +220,7 @@ declare class CursorBuddyClient {
256
220
  private response;
257
221
  private error;
258
222
  private abortController;
223
+ private historyCommittedForTurn;
259
224
  private cachedSnapshot;
260
225
  private listeners;
261
226
  constructor(endpoint: string, options?: CursorBuddyClientOptions, services?: CursorBuddyServices);
@@ -303,6 +268,12 @@ declare class CursorBuddyClient {
303
268
  */
304
269
  private buildSnapshot;
305
270
  private abort;
271
+ /**
272
+ * Commit partial turn to history when interrupted.
273
+ * Only commits if we have both transcript and response,
274
+ * and haven't already committed for this turn.
275
+ */
276
+ private commitPartialHistory;
306
277
  private transcribe;
307
278
  private chat;
308
279
  private speak;
@@ -311,4 +282,4 @@ declare class CursorBuddyClient {
311
282
  }
312
283
  //#endregion
313
284
  export { Point as a, VoiceEvent as c, CursorRenderProps as i, VoiceState as l, CursorBuddyClientOptions as n, PointingTarget as o, CursorBuddySnapshot as r, SpeechBubbleRenderProps as s, CursorBuddyClient as t, WaveformRenderProps as u };
314
- //# sourceMappingURL=client-DKZY5bI1.d.mts.map
285
+ //# sourceMappingURL=client-CPQnk2_x.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-CPQnk2_x.d.mts","names":[],"sources":["../src/core/utils/elements.ts","../src/core/types.ts","../src/core/client.ts"],"mappings":";;AAgEA;;;;;;UAAiB,aAAA;EAMf;EAJA,EAAA;EAMA;EAJA,OAAA,EAAS,OAAA;EAIE;EAFX,IAAA,EAAM,OAAA;EAQa;EANnB,WAAA;AAAA;;;;KAMU,SAAA,GAAY,GAAA,SAAY,aAAA;;;;AAdpC;;KC7DY,UAAA;;;;KAKA,UAAA;EACN,IAAA;AAAA;EACA,IAAA;AAAA;EACA,IAAA;EAAgC,UAAA;AAAA;EAChC,IAAA;EAA8B,QAAA;AAAA;EAC9B,IAAA;AAAA;EACA,IAAA;EAAe,KAAA,EAAO,KAAA;AAAA;;;;AAN5B;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