codmir 0.3.2 → 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/LICENSE +55 -0
- package/README.md +219 -14
- package/dist/analyze-LULBI4ZC.mjs +7 -0
- package/dist/chunk-ASGAT3Z5.mjs +756 -0
- package/dist/chunk-EBO3CZXG.mjs +15 -0
- package/dist/{chunk-7HVQNURM.mjs → chunk-GU32P57R.mjs} +70 -0
- package/dist/cli/index.js +2018 -146
- package/dist/cli/index.mjs +1166 -139
- package/dist/index.d.mts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +70 -0
- package/dist/index.mjs +2 -1
- package/dist/voice-agent/index.d.mts +134 -0
- package/dist/voice-agent/index.d.ts +134 -0
- package/dist/voice-agent/index.js +220 -0
- package/dist/voice-agent/index.mjs +187 -0
- package/dist/voice-daemon/index.d.mts +354 -0
- package/dist/voice-daemon/index.d.ts +354 -0
- package/dist/voice-daemon/index.js +1089 -0
- package/dist/voice-daemon/index.mjs +1046 -0
- package/package.json +49 -12
package/dist/index.d.mts
CHANGED
|
@@ -88,6 +88,51 @@ interface CreateTestCaseInput {
|
|
|
88
88
|
interface UpdateTestCaseInput extends Partial<CreateTestCaseInput> {
|
|
89
89
|
status?: TestCaseStatus;
|
|
90
90
|
}
|
|
91
|
+
interface TestRunArtifact {
|
|
92
|
+
label?: string;
|
|
93
|
+
type?: string;
|
|
94
|
+
url: string;
|
|
95
|
+
}
|
|
96
|
+
interface TestRunSummaryInput {
|
|
97
|
+
projectId: string;
|
|
98
|
+
sprintId?: string;
|
|
99
|
+
suite: string;
|
|
100
|
+
framework?: string;
|
|
101
|
+
passCount: number;
|
|
102
|
+
failCount: number;
|
|
103
|
+
flakyCount?: number;
|
|
104
|
+
durationMs?: number;
|
|
105
|
+
commitSha?: string;
|
|
106
|
+
releaseTrainId?: string;
|
|
107
|
+
artifacts?: TestRunArtifact[];
|
|
108
|
+
}
|
|
109
|
+
interface TestRunRecord extends TestRunSummaryInput {
|
|
110
|
+
id: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
}
|
|
113
|
+
interface CoverageFeatureBreakdown {
|
|
114
|
+
name: string;
|
|
115
|
+
coverage: number;
|
|
116
|
+
risk?: string;
|
|
117
|
+
}
|
|
118
|
+
interface CoverageInsightRequest {
|
|
119
|
+
projectId: string;
|
|
120
|
+
sprintId?: string;
|
|
121
|
+
linesPct: number;
|
|
122
|
+
branchesPct?: number;
|
|
123
|
+
statementsPct?: number;
|
|
124
|
+
functionsPct?: number;
|
|
125
|
+
features?: CoverageFeatureBreakdown[];
|
|
126
|
+
}
|
|
127
|
+
interface CoverageSuggestedTest {
|
|
128
|
+
title: string;
|
|
129
|
+
reason?: string;
|
|
130
|
+
}
|
|
131
|
+
interface CoverageInsight extends CoverageInsightRequest {
|
|
132
|
+
id: string;
|
|
133
|
+
createdAt: string;
|
|
134
|
+
suggestedTests?: CoverageSuggestedTest[] | null;
|
|
135
|
+
}
|
|
91
136
|
interface ApiResponse<T> {
|
|
92
137
|
data?: T;
|
|
93
138
|
error?: string;
|
|
@@ -132,6 +177,7 @@ declare class CodmirClient {
|
|
|
132
177
|
private readonly config;
|
|
133
178
|
readonly tickets: TicketsAPI;
|
|
134
179
|
readonly testCases: TestCasesAPI;
|
|
180
|
+
readonly testing: TestingAPI;
|
|
135
181
|
constructor(config: CodmirClientConfig);
|
|
136
182
|
/**
|
|
137
183
|
* Make an HTTP request to the codmir API
|
|
@@ -216,5 +262,34 @@ declare class TestCasesAPI {
|
|
|
216
262
|
*/
|
|
217
263
|
delete(projectId: string, testCaseId: string | number): Promise<void>;
|
|
218
264
|
}
|
|
265
|
+
declare class TestingAPI {
|
|
266
|
+
private config;
|
|
267
|
+
constructor(config: Required<CodmirClientConfig>);
|
|
268
|
+
private request;
|
|
269
|
+
submitTestRun(payload: TestRunSummaryInput): Promise<{
|
|
270
|
+
run: TestRunRecord;
|
|
271
|
+
summary: {
|
|
272
|
+
framework: string;
|
|
273
|
+
passRate: number;
|
|
274
|
+
totalDurationMs: number;
|
|
275
|
+
};
|
|
276
|
+
}>;
|
|
277
|
+
listTestRuns(projectId: string, options?: {
|
|
278
|
+
limit?: number;
|
|
279
|
+
suite?: string;
|
|
280
|
+
}): Promise<TestRunRecord[]>;
|
|
281
|
+
requestCoverageInsight(payload: CoverageInsightRequest): Promise<{
|
|
282
|
+
report: CoverageInsight;
|
|
283
|
+
insights: {
|
|
284
|
+
coverageGauge: number;
|
|
285
|
+
featureBreakdown?: CoverageInsightRequest['features'];
|
|
286
|
+
suggestedTests: {
|
|
287
|
+
title: string;
|
|
288
|
+
reason?: string;
|
|
289
|
+
}[];
|
|
290
|
+
};
|
|
291
|
+
}>;
|
|
292
|
+
listCoverageInsights(projectId: string, limit?: number): Promise<CoverageInsight[]>;
|
|
293
|
+
}
|
|
219
294
|
|
|
220
|
-
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
|
295
|
+
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CoverageFeatureBreakdown, type CoverageInsight, type CoverageInsightRequest, type CoverageSuggestedTest, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type TestRunArtifact, type TestRunRecord, type TestRunSummaryInput, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
package/dist/index.d.ts
CHANGED
|
@@ -88,6 +88,51 @@ interface CreateTestCaseInput {
|
|
|
88
88
|
interface UpdateTestCaseInput extends Partial<CreateTestCaseInput> {
|
|
89
89
|
status?: TestCaseStatus;
|
|
90
90
|
}
|
|
91
|
+
interface TestRunArtifact {
|
|
92
|
+
label?: string;
|
|
93
|
+
type?: string;
|
|
94
|
+
url: string;
|
|
95
|
+
}
|
|
96
|
+
interface TestRunSummaryInput {
|
|
97
|
+
projectId: string;
|
|
98
|
+
sprintId?: string;
|
|
99
|
+
suite: string;
|
|
100
|
+
framework?: string;
|
|
101
|
+
passCount: number;
|
|
102
|
+
failCount: number;
|
|
103
|
+
flakyCount?: number;
|
|
104
|
+
durationMs?: number;
|
|
105
|
+
commitSha?: string;
|
|
106
|
+
releaseTrainId?: string;
|
|
107
|
+
artifacts?: TestRunArtifact[];
|
|
108
|
+
}
|
|
109
|
+
interface TestRunRecord extends TestRunSummaryInput {
|
|
110
|
+
id: string;
|
|
111
|
+
createdAt: string;
|
|
112
|
+
}
|
|
113
|
+
interface CoverageFeatureBreakdown {
|
|
114
|
+
name: string;
|
|
115
|
+
coverage: number;
|
|
116
|
+
risk?: string;
|
|
117
|
+
}
|
|
118
|
+
interface CoverageInsightRequest {
|
|
119
|
+
projectId: string;
|
|
120
|
+
sprintId?: string;
|
|
121
|
+
linesPct: number;
|
|
122
|
+
branchesPct?: number;
|
|
123
|
+
statementsPct?: number;
|
|
124
|
+
functionsPct?: number;
|
|
125
|
+
features?: CoverageFeatureBreakdown[];
|
|
126
|
+
}
|
|
127
|
+
interface CoverageSuggestedTest {
|
|
128
|
+
title: string;
|
|
129
|
+
reason?: string;
|
|
130
|
+
}
|
|
131
|
+
interface CoverageInsight extends CoverageInsightRequest {
|
|
132
|
+
id: string;
|
|
133
|
+
createdAt: string;
|
|
134
|
+
suggestedTests?: CoverageSuggestedTest[] | null;
|
|
135
|
+
}
|
|
91
136
|
interface ApiResponse<T> {
|
|
92
137
|
data?: T;
|
|
93
138
|
error?: string;
|
|
@@ -132,6 +177,7 @@ declare class CodmirClient {
|
|
|
132
177
|
private readonly config;
|
|
133
178
|
readonly tickets: TicketsAPI;
|
|
134
179
|
readonly testCases: TestCasesAPI;
|
|
180
|
+
readonly testing: TestingAPI;
|
|
135
181
|
constructor(config: CodmirClientConfig);
|
|
136
182
|
/**
|
|
137
183
|
* Make an HTTP request to the codmir API
|
|
@@ -216,5 +262,34 @@ declare class TestCasesAPI {
|
|
|
216
262
|
*/
|
|
217
263
|
delete(projectId: string, testCaseId: string | number): Promise<void>;
|
|
218
264
|
}
|
|
265
|
+
declare class TestingAPI {
|
|
266
|
+
private config;
|
|
267
|
+
constructor(config: Required<CodmirClientConfig>);
|
|
268
|
+
private request;
|
|
269
|
+
submitTestRun(payload: TestRunSummaryInput): Promise<{
|
|
270
|
+
run: TestRunRecord;
|
|
271
|
+
summary: {
|
|
272
|
+
framework: string;
|
|
273
|
+
passRate: number;
|
|
274
|
+
totalDurationMs: number;
|
|
275
|
+
};
|
|
276
|
+
}>;
|
|
277
|
+
listTestRuns(projectId: string, options?: {
|
|
278
|
+
limit?: number;
|
|
279
|
+
suite?: string;
|
|
280
|
+
}): Promise<TestRunRecord[]>;
|
|
281
|
+
requestCoverageInsight(payload: CoverageInsightRequest): Promise<{
|
|
282
|
+
report: CoverageInsight;
|
|
283
|
+
insights: {
|
|
284
|
+
coverageGauge: number;
|
|
285
|
+
featureBreakdown?: CoverageInsightRequest['features'];
|
|
286
|
+
suggestedTests: {
|
|
287
|
+
title: string;
|
|
288
|
+
reason?: string;
|
|
289
|
+
}[];
|
|
290
|
+
};
|
|
291
|
+
}>;
|
|
292
|
+
listCoverageInsights(projectId: string, limit?: number): Promise<CoverageInsight[]>;
|
|
293
|
+
}
|
|
219
294
|
|
|
220
|
-
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
|
295
|
+
export { type ApiResponse, CodmirClient, type CodmirClientConfig, CodmirError, type CoverageFeatureBreakdown, type CoverageInsight, type CoverageInsightRequest, type CoverageSuggestedTest, type CreateTestCaseInput, type CreateTicketInput, type PaginatedResponse, type TestCase, type TestCasePriority, type TestCaseStatus, type TestCaseStep, type TestCaseTemplate, type TestRunArtifact, type TestRunRecord, type TestRunSummaryInput, type Ticket, type TicketPriority, type TicketStatus, type TicketType, type UpdateTestCaseInput, type UpdateTicketInput, type User };
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,7 @@ var CodmirClient = class {
|
|
|
35
35
|
};
|
|
36
36
|
this.tickets = new TicketsAPI(this.config);
|
|
37
37
|
this.testCases = new TestCasesAPI(this.config);
|
|
38
|
+
this.testing = new TestingAPI(this.config);
|
|
38
39
|
}
|
|
39
40
|
/**
|
|
40
41
|
* Make an HTTP request to the codmir API
|
|
@@ -293,6 +294,75 @@ var TestCasesAPI = class {
|
|
|
293
294
|
);
|
|
294
295
|
}
|
|
295
296
|
};
|
|
297
|
+
var TestingAPI = class {
|
|
298
|
+
constructor(config) {
|
|
299
|
+
this.config = config;
|
|
300
|
+
}
|
|
301
|
+
async request(method, path, body) {
|
|
302
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
303
|
+
const headers = {
|
|
304
|
+
"Content-Type": "application/json",
|
|
305
|
+
...this.config.headers
|
|
306
|
+
};
|
|
307
|
+
if (this.config.apiKey) {
|
|
308
|
+
headers["X-API-Key"] = this.config.apiKey;
|
|
309
|
+
}
|
|
310
|
+
const controller = new AbortController();
|
|
311
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
312
|
+
try {
|
|
313
|
+
const response = await fetch(url, {
|
|
314
|
+
method,
|
|
315
|
+
headers,
|
|
316
|
+
body: body ? JSON.stringify(body) : void 0,
|
|
317
|
+
signal: controller.signal
|
|
318
|
+
});
|
|
319
|
+
clearTimeout(timeoutId);
|
|
320
|
+
if (!response.ok) {
|
|
321
|
+
const errorData = await response.json().catch(() => ({}));
|
|
322
|
+
const error = new Error(errorData.error || `HTTP ${response.status}`);
|
|
323
|
+
error.statusCode = response.status;
|
|
324
|
+
error.response = errorData;
|
|
325
|
+
throw error;
|
|
326
|
+
}
|
|
327
|
+
if (response.status === 204) {
|
|
328
|
+
return {};
|
|
329
|
+
}
|
|
330
|
+
return await response.json();
|
|
331
|
+
} catch (error) {
|
|
332
|
+
clearTimeout(timeoutId);
|
|
333
|
+
if (error.name === "AbortError") {
|
|
334
|
+
const timeoutError = new Error("Request timeout");
|
|
335
|
+
timeoutError.statusCode = 408;
|
|
336
|
+
throw timeoutError;
|
|
337
|
+
}
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
async submitTestRun(payload) {
|
|
342
|
+
return this.request("POST", "/api/testing/test-runs", payload);
|
|
343
|
+
}
|
|
344
|
+
async listTestRuns(projectId, options) {
|
|
345
|
+
const params = new URLSearchParams({ projectId });
|
|
346
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
347
|
+
if (options?.suite) params.set("suite", options.suite);
|
|
348
|
+
const response = await this.request(
|
|
349
|
+
"GET",
|
|
350
|
+
`/api/testing/test-runs?${params.toString()}`
|
|
351
|
+
);
|
|
352
|
+
return response.runs || [];
|
|
353
|
+
}
|
|
354
|
+
async requestCoverageInsight(payload) {
|
|
355
|
+
return this.request("POST", "/api/testing/coverage-insight", payload);
|
|
356
|
+
}
|
|
357
|
+
async listCoverageInsights(projectId, limit = 5) {
|
|
358
|
+
const params = new URLSearchParams({ projectId, limit: String(limit) });
|
|
359
|
+
const response = await this.request(
|
|
360
|
+
"GET",
|
|
361
|
+
`/api/testing/coverage-insight?${params.toString()}`
|
|
362
|
+
);
|
|
363
|
+
return response.reports || [];
|
|
364
|
+
}
|
|
365
|
+
};
|
|
296
366
|
// Annotate the CommonJS export names for ESM import in node:
|
|
297
367
|
0 && (module.exports = {
|
|
298
368
|
CodmirClient
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voice assistant states.
|
|
3
|
+
*/
|
|
4
|
+
type AssistantState = "idle" | "listening" | "thinking" | "speaking" | "error";
|
|
5
|
+
/**
|
|
6
|
+
* Command types that can be executed by the voice daemon.
|
|
7
|
+
*/
|
|
8
|
+
type CodmirCommand = {
|
|
9
|
+
type: "open_app";
|
|
10
|
+
name: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "open_url";
|
|
13
|
+
url: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "focus_window";
|
|
16
|
+
titleContains: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "type_text";
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "press_key";
|
|
22
|
+
key: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "click";
|
|
25
|
+
button?: number;
|
|
26
|
+
} | {
|
|
27
|
+
type: "scroll";
|
|
28
|
+
direction: "up" | "down";
|
|
29
|
+
amount?: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: "speak";
|
|
32
|
+
text: string;
|
|
33
|
+
voice?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Events emitted by the voice agent.
|
|
37
|
+
*/
|
|
38
|
+
interface VoiceAgentEvents {
|
|
39
|
+
connected: () => void;
|
|
40
|
+
disconnected: () => void;
|
|
41
|
+
wake: (wakeword: string) => void;
|
|
42
|
+
stateChange: (state: AssistantState, previousState: AssistantState) => void;
|
|
43
|
+
transcript: (text: string, isFinal: boolean) => void;
|
|
44
|
+
response: (text: string, commands?: CodmirCommand[]) => void;
|
|
45
|
+
commandExecuted: (command: CodmirCommand, success: boolean, error?: string) => void;
|
|
46
|
+
error: (message: string, code?: string) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration options for the voice agent.
|
|
50
|
+
*/
|
|
51
|
+
interface VoiceAgentOptions {
|
|
52
|
+
/** WebSocket URL of the voice daemon. Default: ws://127.0.0.1:9410 */
|
|
53
|
+
url?: string;
|
|
54
|
+
/** Client ID for identification. */
|
|
55
|
+
clientId?: string;
|
|
56
|
+
/** Client type for identification. */
|
|
57
|
+
clientType?: "overlay" | "cli" | "ide" | "web" | "other";
|
|
58
|
+
/** Automatically reconnect on disconnect. Default: true */
|
|
59
|
+
autoReconnect?: boolean;
|
|
60
|
+
/** Reconnect delay in milliseconds. Default: 2000 */
|
|
61
|
+
reconnectDelay?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Client SDK for connecting to the codmir voice daemon.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { VoiceAgent } from '@codmir/voice-agent';
|
|
70
|
+
*
|
|
71
|
+
* const agent = new VoiceAgent({ clientId: 'my-app', clientType: 'web' });
|
|
72
|
+
*
|
|
73
|
+
* agent.on('wake', (wakeword) => {
|
|
74
|
+
* console.log('Wake word detected:', wakeword);
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* agent.on('stateChange', (state, prev) => {
|
|
78
|
+
* console.log('State changed:', prev, '->', state);
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* await agent.connect();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare class VoiceAgent {
|
|
85
|
+
private readonly options;
|
|
86
|
+
private ws;
|
|
87
|
+
private connected;
|
|
88
|
+
private reconnecting;
|
|
89
|
+
private listeners;
|
|
90
|
+
constructor(options?: VoiceAgentOptions);
|
|
91
|
+
/**
|
|
92
|
+
* Connect to the voice daemon.
|
|
93
|
+
*/
|
|
94
|
+
connect(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Disconnect from the voice daemon.
|
|
97
|
+
*/
|
|
98
|
+
disconnect(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Check if connected to the daemon.
|
|
101
|
+
*/
|
|
102
|
+
isConnected(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Register an event listener.
|
|
105
|
+
*/
|
|
106
|
+
on<K extends keyof VoiceAgentEvents>(event: K, callback: VoiceAgentEvents[K]): () => void;
|
|
107
|
+
/**
|
|
108
|
+
* Execute a command on the daemon.
|
|
109
|
+
*/
|
|
110
|
+
executeCommand(command: CodmirCommand): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Mute the voice assistant.
|
|
113
|
+
*/
|
|
114
|
+
mute(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Unmute the voice assistant.
|
|
117
|
+
*/
|
|
118
|
+
unmute(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Ping the daemon.
|
|
121
|
+
*/
|
|
122
|
+
ping(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Simulate a wake word detection (for testing).
|
|
125
|
+
*/
|
|
126
|
+
simulateWake(wakeword?: string): void;
|
|
127
|
+
private sendIdentify;
|
|
128
|
+
private send;
|
|
129
|
+
private handleMessage;
|
|
130
|
+
private emit;
|
|
131
|
+
private scheduleReconnect;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { type AssistantState, type CodmirCommand, VoiceAgent, type VoiceAgentEvents, type VoiceAgentOptions, VoiceAgent as default };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Voice assistant states.
|
|
3
|
+
*/
|
|
4
|
+
type AssistantState = "idle" | "listening" | "thinking" | "speaking" | "error";
|
|
5
|
+
/**
|
|
6
|
+
* Command types that can be executed by the voice daemon.
|
|
7
|
+
*/
|
|
8
|
+
type CodmirCommand = {
|
|
9
|
+
type: "open_app";
|
|
10
|
+
name: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "open_url";
|
|
13
|
+
url: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "focus_window";
|
|
16
|
+
titleContains: string;
|
|
17
|
+
} | {
|
|
18
|
+
type: "type_text";
|
|
19
|
+
text: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "press_key";
|
|
22
|
+
key: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "click";
|
|
25
|
+
button?: number;
|
|
26
|
+
} | {
|
|
27
|
+
type: "scroll";
|
|
28
|
+
direction: "up" | "down";
|
|
29
|
+
amount?: number;
|
|
30
|
+
} | {
|
|
31
|
+
type: "speak";
|
|
32
|
+
text: string;
|
|
33
|
+
voice?: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Events emitted by the voice agent.
|
|
37
|
+
*/
|
|
38
|
+
interface VoiceAgentEvents {
|
|
39
|
+
connected: () => void;
|
|
40
|
+
disconnected: () => void;
|
|
41
|
+
wake: (wakeword: string) => void;
|
|
42
|
+
stateChange: (state: AssistantState, previousState: AssistantState) => void;
|
|
43
|
+
transcript: (text: string, isFinal: boolean) => void;
|
|
44
|
+
response: (text: string, commands?: CodmirCommand[]) => void;
|
|
45
|
+
commandExecuted: (command: CodmirCommand, success: boolean, error?: string) => void;
|
|
46
|
+
error: (message: string, code?: string) => void;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Configuration options for the voice agent.
|
|
50
|
+
*/
|
|
51
|
+
interface VoiceAgentOptions {
|
|
52
|
+
/** WebSocket URL of the voice daemon. Default: ws://127.0.0.1:9410 */
|
|
53
|
+
url?: string;
|
|
54
|
+
/** Client ID for identification. */
|
|
55
|
+
clientId?: string;
|
|
56
|
+
/** Client type for identification. */
|
|
57
|
+
clientType?: "overlay" | "cli" | "ide" | "web" | "other";
|
|
58
|
+
/** Automatically reconnect on disconnect. Default: true */
|
|
59
|
+
autoReconnect?: boolean;
|
|
60
|
+
/** Reconnect delay in milliseconds. Default: 2000 */
|
|
61
|
+
reconnectDelay?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Client SDK for connecting to the codmir voice daemon.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import { VoiceAgent } from '@codmir/voice-agent';
|
|
70
|
+
*
|
|
71
|
+
* const agent = new VoiceAgent({ clientId: 'my-app', clientType: 'web' });
|
|
72
|
+
*
|
|
73
|
+
* agent.on('wake', (wakeword) => {
|
|
74
|
+
* console.log('Wake word detected:', wakeword);
|
|
75
|
+
* });
|
|
76
|
+
*
|
|
77
|
+
* agent.on('stateChange', (state, prev) => {
|
|
78
|
+
* console.log('State changed:', prev, '->', state);
|
|
79
|
+
* });
|
|
80
|
+
*
|
|
81
|
+
* await agent.connect();
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
declare class VoiceAgent {
|
|
85
|
+
private readonly options;
|
|
86
|
+
private ws;
|
|
87
|
+
private connected;
|
|
88
|
+
private reconnecting;
|
|
89
|
+
private listeners;
|
|
90
|
+
constructor(options?: VoiceAgentOptions);
|
|
91
|
+
/**
|
|
92
|
+
* Connect to the voice daemon.
|
|
93
|
+
*/
|
|
94
|
+
connect(): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Disconnect from the voice daemon.
|
|
97
|
+
*/
|
|
98
|
+
disconnect(): void;
|
|
99
|
+
/**
|
|
100
|
+
* Check if connected to the daemon.
|
|
101
|
+
*/
|
|
102
|
+
isConnected(): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Register an event listener.
|
|
105
|
+
*/
|
|
106
|
+
on<K extends keyof VoiceAgentEvents>(event: K, callback: VoiceAgentEvents[K]): () => void;
|
|
107
|
+
/**
|
|
108
|
+
* Execute a command on the daemon.
|
|
109
|
+
*/
|
|
110
|
+
executeCommand(command: CodmirCommand): Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Mute the voice assistant.
|
|
113
|
+
*/
|
|
114
|
+
mute(): void;
|
|
115
|
+
/**
|
|
116
|
+
* Unmute the voice assistant.
|
|
117
|
+
*/
|
|
118
|
+
unmute(): void;
|
|
119
|
+
/**
|
|
120
|
+
* Ping the daemon.
|
|
121
|
+
*/
|
|
122
|
+
ping(): void;
|
|
123
|
+
/**
|
|
124
|
+
* Simulate a wake word detection (for testing).
|
|
125
|
+
*/
|
|
126
|
+
simulateWake(wakeword?: string): void;
|
|
127
|
+
private sendIdentify;
|
|
128
|
+
private send;
|
|
129
|
+
private handleMessage;
|
|
130
|
+
private emit;
|
|
131
|
+
private scheduleReconnect;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export { type AssistantState, type CodmirCommand, VoiceAgent, type VoiceAgentEvents, type VoiceAgentOptions, VoiceAgent as default };
|