cursor-buddy 0.0.1 → 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.
- package/dist/client-CPQnk2_x.d.mts +285 -0
- package/dist/client-CPQnk2_x.d.mts.map +1 -0
- package/dist/client-DAa4L2fE.mjs +1404 -0
- package/dist/client-DAa4L2fE.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -1
- package/dist/{client → react}/index.d.mts +29 -53
- package/dist/react/index.d.mts.map +1 -0
- package/dist/react/index.mjs +358 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/server/adapters/next.d.mts +1 -1
- package/dist/server/index.d.mts +2 -2
- package/dist/server/index.mjs +24 -11
- package/dist/server/index.mjs.map +1 -1
- package/dist/{types-B2GUdTzP.d.mts → types-L97cq8UK.d.mts} +1 -1
- package/dist/{types-B2GUdTzP.d.mts.map → types-L97cq8UK.d.mts.map} +1 -1
- package/package.json +11 -10
- package/README.md +0 -314
- package/dist/client/index.d.mts.map +0 -1
- package/dist/client/index.mjs +0 -1123
- package/dist/client/index.mjs.map +0 -1
- package/dist/types-b2KrNyuu.d.mts +0 -59
- package/dist/types-b2KrNyuu.d.mts.map +0 -1
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
//#region src/core/utils/elements.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Element discovery for annotated screenshots.
|
|
4
|
+
* Finds visible interactive elements and assigns marker IDs.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Element marker with reference to actual DOM element.
|
|
8
|
+
*/
|
|
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;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Map of marker ID to element marker.
|
|
21
|
+
*/
|
|
22
|
+
type MarkerMap = Map<number, ElementMarker>;
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/core/types.d.ts
|
|
25
|
+
/**
|
|
26
|
+
* Voice state machine states
|
|
27
|
+
*/
|
|
28
|
+
type VoiceState = "idle" | "listening" | "processing" | "responding";
|
|
29
|
+
/**
|
|
30
|
+
* Events for the voice state machine
|
|
31
|
+
*/
|
|
32
|
+
type VoiceEvent = {
|
|
33
|
+
type: "HOTKEY_PRESSED";
|
|
34
|
+
} | {
|
|
35
|
+
type: "HOTKEY_RELEASED";
|
|
36
|
+
} | {
|
|
37
|
+
type: "TRANSCRIPTION_COMPLETE";
|
|
38
|
+
transcript: string;
|
|
39
|
+
} | {
|
|
40
|
+
type: "AI_RESPONSE_COMPLETE";
|
|
41
|
+
response: string;
|
|
42
|
+
} | {
|
|
43
|
+
type: "TTS_COMPLETE";
|
|
44
|
+
} | {
|
|
45
|
+
type: "ERROR";
|
|
46
|
+
error: Error;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
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
|
|
53
|
+
*/
|
|
54
|
+
interface PointingTarget {
|
|
55
|
+
/** X coordinate in viewport pixels (top-left origin) */
|
|
56
|
+
x: number;
|
|
57
|
+
/** Y coordinate in viewport pixels (top-left origin) */
|
|
58
|
+
y: number;
|
|
59
|
+
/** Label to display in speech bubble */
|
|
60
|
+
label: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 2D point
|
|
64
|
+
*/
|
|
65
|
+
interface Point {
|
|
66
|
+
x: number;
|
|
67
|
+
y: number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Screenshot capture result
|
|
71
|
+
*/
|
|
72
|
+
interface ScreenshotResult {
|
|
73
|
+
/** Base64-encoded image data URL */
|
|
74
|
+
imageData: string;
|
|
75
|
+
/** Screenshot image width in pixels (after any downscaling) */
|
|
76
|
+
width: number;
|
|
77
|
+
/** Screenshot image height in pixels (after any downscaling) */
|
|
78
|
+
height: number;
|
|
79
|
+
/** Live browser viewport width in CSS pixels */
|
|
80
|
+
viewportWidth: number;
|
|
81
|
+
/** Live browser viewport height in CSS pixels */
|
|
82
|
+
viewportHeight: number;
|
|
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
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Cursor render props passed to custom cursor components
|
|
137
|
+
*/
|
|
138
|
+
interface CursorRenderProps {
|
|
139
|
+
/** Current voice state */
|
|
140
|
+
state: VoiceState;
|
|
141
|
+
/** Whether cursor is currently engaged with a pointing target */
|
|
142
|
+
isPointing: boolean;
|
|
143
|
+
/** Rotation in radians (direction of travel during pointing) */
|
|
144
|
+
rotation: number;
|
|
145
|
+
/** Scale factor (1.0 normal, up to 1.3 during flight) */
|
|
146
|
+
scale: number;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Speech bubble render props
|
|
150
|
+
*/
|
|
151
|
+
interface SpeechBubbleRenderProps {
|
|
152
|
+
/** Text to display */
|
|
153
|
+
text: string;
|
|
154
|
+
/** Whether bubble is visible */
|
|
155
|
+
isVisible: boolean;
|
|
156
|
+
/** Called when the bubble should be dismissed */
|
|
157
|
+
onClick?: () => void;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Waveform render props
|
|
161
|
+
*/
|
|
162
|
+
interface WaveformRenderProps {
|
|
163
|
+
/** Current audio level (0-1) */
|
|
164
|
+
audioLevel: number;
|
|
165
|
+
/** Whether currently listening */
|
|
166
|
+
isListening: boolean;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Configuration options for CursorBuddyClient
|
|
170
|
+
*/
|
|
171
|
+
interface CursorBuddyClientOptions {
|
|
172
|
+
/** Callback when transcript is ready */
|
|
173
|
+
onTranscript?: (text: string) => void;
|
|
174
|
+
/** Callback when AI responds */
|
|
175
|
+
onResponse?: (text: string) => void;
|
|
176
|
+
/** Callback when pointing at element */
|
|
177
|
+
onPoint?: (target: PointingTarget) => void;
|
|
178
|
+
/** Callback when state changes */
|
|
179
|
+
onStateChange?: (state: VoiceState) => void;
|
|
180
|
+
/** Callback when error occurs */
|
|
181
|
+
onError?: (error: Error) => void;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Client snapshot for React's useSyncExternalStore
|
|
185
|
+
*/
|
|
186
|
+
interface CursorBuddySnapshot {
|
|
187
|
+
/** Current voice state */
|
|
188
|
+
state: VoiceState;
|
|
189
|
+
/** Latest transcribed user speech */
|
|
190
|
+
transcript: string;
|
|
191
|
+
/** Latest AI response (stripped of POINT tags) */
|
|
192
|
+
response: string;
|
|
193
|
+
/** Current error (null if none) */
|
|
194
|
+
error: Error | null;
|
|
195
|
+
/** Whether currently engaged with a pointing target */
|
|
196
|
+
isPointing: boolean;
|
|
197
|
+
/** Whether the buddy is enabled */
|
|
198
|
+
isEnabled: boolean;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/core/client.d.ts
|
|
202
|
+
/**
|
|
203
|
+
* Framework-agnostic client for cursor buddy voice interactions.
|
|
204
|
+
*
|
|
205
|
+
* Manages the complete voice interaction flow:
|
|
206
|
+
* idle -> listening -> processing -> responding -> idle
|
|
207
|
+
*
|
|
208
|
+
* Supports interruption: pressing hotkey during any state aborts
|
|
209
|
+
* in-flight work and immediately transitions to listening.
|
|
210
|
+
*/
|
|
211
|
+
declare class CursorBuddyClient {
|
|
212
|
+
private endpoint;
|
|
213
|
+
private options;
|
|
214
|
+
private voiceCapture;
|
|
215
|
+
private audioPlayback;
|
|
216
|
+
private screenCapture;
|
|
217
|
+
private pointerController;
|
|
218
|
+
private stateMachine;
|
|
219
|
+
private transcript;
|
|
220
|
+
private response;
|
|
221
|
+
private error;
|
|
222
|
+
private abortController;
|
|
223
|
+
private historyCommittedForTurn;
|
|
224
|
+
private cachedSnapshot;
|
|
225
|
+
private listeners;
|
|
226
|
+
constructor(endpoint: string, options?: CursorBuddyClientOptions, services?: CursorBuddyServices);
|
|
227
|
+
/**
|
|
228
|
+
* Start listening for voice input.
|
|
229
|
+
* Aborts any in-flight work from previous session.
|
|
230
|
+
*/
|
|
231
|
+
startListening(): void;
|
|
232
|
+
/**
|
|
233
|
+
* Stop listening and process the voice input.
|
|
234
|
+
*/
|
|
235
|
+
stopListening(): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Enable or disable the buddy.
|
|
238
|
+
*/
|
|
239
|
+
setEnabled(enabled: boolean): void;
|
|
240
|
+
/**
|
|
241
|
+
* Manually point at coordinates.
|
|
242
|
+
*/
|
|
243
|
+
pointAt(x: number, y: number, label: string): void;
|
|
244
|
+
/**
|
|
245
|
+
* Dismiss the current pointing target.
|
|
246
|
+
*/
|
|
247
|
+
dismissPointing(): void;
|
|
248
|
+
/**
|
|
249
|
+
* Reset to idle state and stop any in-progress work.
|
|
250
|
+
*/
|
|
251
|
+
reset(): void;
|
|
252
|
+
/**
|
|
253
|
+
* Update buddy position to follow cursor.
|
|
254
|
+
* Call this on cursor position changes.
|
|
255
|
+
*/
|
|
256
|
+
updateCursorPosition(): void;
|
|
257
|
+
/**
|
|
258
|
+
* Subscribe to state changes.
|
|
259
|
+
*/
|
|
260
|
+
subscribe(listener: () => void): () => void;
|
|
261
|
+
/**
|
|
262
|
+
* Get current state snapshot for React's useSyncExternalStore.
|
|
263
|
+
* Returns a cached object to ensure referential stability.
|
|
264
|
+
*/
|
|
265
|
+
getSnapshot(): CursorBuddySnapshot;
|
|
266
|
+
/**
|
|
267
|
+
* Build a new snapshot object.
|
|
268
|
+
*/
|
|
269
|
+
private buildSnapshot;
|
|
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;
|
|
277
|
+
private transcribe;
|
|
278
|
+
private chat;
|
|
279
|
+
private speak;
|
|
280
|
+
private handleError;
|
|
281
|
+
private notify;
|
|
282
|
+
}
|
|
283
|
+
//#endregion
|
|
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 };
|
|
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;;;UAciB,cAAA;EAbX;EAeJ,CAAA;EAbI;EAeJ,CAAA;EAdI;EAgBJ,KAAA;AAAA;;AAaF;;UAAiB,KAAA;EACf,CAAA;EACA,CAAA;AAAA;;;;UAMe,gBAAA;EAIf;EAFA,SAAA;EAMA;EAJA,KAAA;EAMc;EAJd,MAAA;EAae;EAXf,aAAA;;EAEA,cAAA;AAAA;;;;UASe,yBAAA,SAAkC,gBAAA;EAk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