sylas-opencode-runner 0.2.21
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/OpenCodeRunner.d.ts +88 -0
- package/dist/OpenCodeRunner.d.ts.map +1 -0
- package/dist/OpenCodeRunner.js +394 -0
- package/dist/OpenCodeRunner.js.map +1 -0
- package/dist/adapters.d.ts +245 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +544 -0
- package/dist/adapters.js.map +1 -0
- package/dist/formatter.d.ts +28 -0
- package/dist/formatter.d.ts.map +1 -0
- package/dist/formatter.js +251 -0
- package/dist/formatter.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/portAllocator.d.ts +117 -0
- package/dist/portAllocator.d.ts.map +1 -0
- package/dist/portAllocator.js +146 -0
- package/dist/portAllocator.js.map +1 -0
- package/dist/types.d.ts +346 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +48 -0
- package/dist/types.js.map +1 -0
- package/package.json +30 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Runner Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the OpenCode SDK integration with Sylas.
|
|
5
|
+
* OpenCode is an SDK-based AI coding agent that provides:
|
|
6
|
+
* - Managed server lifecycle via createOpencode()
|
|
7
|
+
* - SSE event streaming
|
|
8
|
+
* - True streaming input support
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { AgentRunnerConfig, AgentSessionInfo } from "sylas-core";
|
|
13
|
+
/**
|
|
14
|
+
* Configuration options for the OpenCode SDK server.
|
|
15
|
+
* These are passed to the createOpencode() function.
|
|
16
|
+
*/
|
|
17
|
+
export interface OpenCodeServerConfig {
|
|
18
|
+
/**
|
|
19
|
+
* Port number for the OpenCode server.
|
|
20
|
+
* If not specified, a random available port will be allocated.
|
|
21
|
+
*/
|
|
22
|
+
port?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Base URL for the OpenCode server.
|
|
25
|
+
* Defaults to http://localhost:{port}
|
|
26
|
+
*/
|
|
27
|
+
baseURL?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Request timeout in milliseconds.
|
|
30
|
+
* @default 60000
|
|
31
|
+
*/
|
|
32
|
+
timeout?: number;
|
|
33
|
+
/**
|
|
34
|
+
* Maximum number of automatic retry attempts for transient failures.
|
|
35
|
+
* @default 2
|
|
36
|
+
*/
|
|
37
|
+
maxRetries?: number;
|
|
38
|
+
/**
|
|
39
|
+
* Log level for the SDK client.
|
|
40
|
+
*/
|
|
41
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Configuration for the OpenCode Runner.
|
|
45
|
+
* Extends the base AgentRunnerConfig with OpenCode-specific options.
|
|
46
|
+
*/
|
|
47
|
+
export interface OpenCodeRunnerConfig extends AgentRunnerConfig {
|
|
48
|
+
/**
|
|
49
|
+
* OpenCode server configuration options.
|
|
50
|
+
*/
|
|
51
|
+
serverConfig?: OpenCodeServerConfig;
|
|
52
|
+
/**
|
|
53
|
+
* Enable debug logging for the runner.
|
|
54
|
+
* @default false
|
|
55
|
+
*/
|
|
56
|
+
debug?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Auto-approve all tool executions.
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
autoApprove?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Provider ID for the AI model.
|
|
64
|
+
* OpenCode supports multiple AI providers.
|
|
65
|
+
*/
|
|
66
|
+
providerId?: string;
|
|
67
|
+
opencodeAgent?: string;
|
|
68
|
+
opencodeReportedModel?: string;
|
|
69
|
+
opencodePlugins?: string[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Session information for an OpenCode session.
|
|
73
|
+
* Extends the base AgentSessionInfo with OpenCode-specific fields.
|
|
74
|
+
*/
|
|
75
|
+
export interface OpenCodeSessionInfo extends AgentSessionInfo {
|
|
76
|
+
/**
|
|
77
|
+
* The session ID assigned by OpenCode.
|
|
78
|
+
* This is different from the Sylas session ID.
|
|
79
|
+
*/
|
|
80
|
+
openCodeSessionId: string | null;
|
|
81
|
+
/**
|
|
82
|
+
* The port the OpenCode server is running on.
|
|
83
|
+
*/
|
|
84
|
+
serverPort: number | null;
|
|
85
|
+
/**
|
|
86
|
+
* Session title (if set).
|
|
87
|
+
*/
|
|
88
|
+
title?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Version identifier for the session.
|
|
91
|
+
*/
|
|
92
|
+
version?: string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* OpenCode message part types.
|
|
96
|
+
* Messages in OpenCode are composed of multiple parts.
|
|
97
|
+
*/
|
|
98
|
+
export type OpenCodeMessagePartType = "text" | "file" | "tool" | "snapshot" | "patch";
|
|
99
|
+
/**
|
|
100
|
+
* Base interface for message parts.
|
|
101
|
+
*/
|
|
102
|
+
export interface OpenCodeMessagePartBase {
|
|
103
|
+
type: OpenCodeMessagePartType;
|
|
104
|
+
timing?: {
|
|
105
|
+
start: number;
|
|
106
|
+
end: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Text content part.
|
|
111
|
+
*/
|
|
112
|
+
export interface OpenCodeTextPart extends OpenCodeMessagePartBase {
|
|
113
|
+
type: "text";
|
|
114
|
+
content: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* File reference part.
|
|
118
|
+
*/
|
|
119
|
+
export interface OpenCodeFilePart extends OpenCodeMessagePartBase {
|
|
120
|
+
type: "file";
|
|
121
|
+
path: string;
|
|
122
|
+
sourceLocation?: {
|
|
123
|
+
file: string;
|
|
124
|
+
line: number;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Tool execution part.
|
|
129
|
+
*/
|
|
130
|
+
export interface OpenCodeToolPart extends OpenCodeMessagePartBase {
|
|
131
|
+
type: "tool";
|
|
132
|
+
name: string;
|
|
133
|
+
state: OpenCodeToolState;
|
|
134
|
+
input?: Record<string, unknown>;
|
|
135
|
+
output?: unknown;
|
|
136
|
+
error?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Tool execution states.
|
|
140
|
+
*/
|
|
141
|
+
export type OpenCodeToolState = "pending" | "running" | "completed" | "error";
|
|
142
|
+
/**
|
|
143
|
+
* Snapshot part for application state capture.
|
|
144
|
+
*/
|
|
145
|
+
export interface OpenCodeSnapshotPart extends OpenCodeMessagePartBase {
|
|
146
|
+
type: "snapshot";
|
|
147
|
+
data?: Record<string, unknown>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Patch part for code modifications.
|
|
151
|
+
*/
|
|
152
|
+
export interface OpenCodePatchPart extends OpenCodeMessagePartBase {
|
|
153
|
+
type: "patch";
|
|
154
|
+
path?: string;
|
|
155
|
+
content?: string;
|
|
156
|
+
hash?: string;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Union type for all message part types.
|
|
160
|
+
*/
|
|
161
|
+
export type OpenCodeMessagePart = OpenCodeTextPart | OpenCodeFilePart | OpenCodeToolPart | OpenCodeSnapshotPart | OpenCodePatchPart;
|
|
162
|
+
/**
|
|
163
|
+
* User message from OpenCode.
|
|
164
|
+
*/
|
|
165
|
+
export interface OpenCodeUserMessage {
|
|
166
|
+
type: "user";
|
|
167
|
+
timestamp?: Date;
|
|
168
|
+
content: string;
|
|
169
|
+
parts?: OpenCodeMessagePart[];
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Assistant message from OpenCode.
|
|
173
|
+
*/
|
|
174
|
+
export interface OpenCodeAssistantMessage {
|
|
175
|
+
type: "assistant";
|
|
176
|
+
content: string;
|
|
177
|
+
parts?: OpenCodeMessagePart[];
|
|
178
|
+
tokenMetrics?: {
|
|
179
|
+
inputTokens: number;
|
|
180
|
+
outputTokens: number;
|
|
181
|
+
};
|
|
182
|
+
error?: OpenCodeMessageError;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Message error information.
|
|
186
|
+
*/
|
|
187
|
+
export interface OpenCodeMessageError {
|
|
188
|
+
type: string;
|
|
189
|
+
message: string;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Union type for OpenCode messages.
|
|
193
|
+
*/
|
|
194
|
+
export type OpenCodeMessage = OpenCodeUserMessage | OpenCodeAssistantMessage;
|
|
195
|
+
/**
|
|
196
|
+
* OpenCode event types for SSE streaming.
|
|
197
|
+
*/
|
|
198
|
+
export type OpenCodeEventType = "installation" | "ide_installation" | "diagnostics" | "message_update" | "message_remove" | "message_part_update" | "session_update" | "session_delete" | "session_idle" | "session_error" | "file_edit" | "file_watcher" | "storage_write" | "permission_update";
|
|
199
|
+
/**
|
|
200
|
+
* Base interface for OpenCode events.
|
|
201
|
+
*/
|
|
202
|
+
export interface OpenCodeEventBase {
|
|
203
|
+
type: OpenCodeEventType;
|
|
204
|
+
timestamp?: Date;
|
|
205
|
+
properties: Record<string, unknown>;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Session update event.
|
|
209
|
+
*/
|
|
210
|
+
export interface OpenCodeSessionUpdateEvent extends OpenCodeEventBase {
|
|
211
|
+
type: "session_update";
|
|
212
|
+
properties: {
|
|
213
|
+
sessionId: string;
|
|
214
|
+
[key: string]: unknown;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Message update event.
|
|
219
|
+
*/
|
|
220
|
+
export interface OpenCodeMessageUpdateEvent extends OpenCodeEventBase {
|
|
221
|
+
type: "message_update";
|
|
222
|
+
properties: {
|
|
223
|
+
sessionId: string;
|
|
224
|
+
messageId: string;
|
|
225
|
+
[key: string]: unknown;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Session error event.
|
|
230
|
+
*/
|
|
231
|
+
export interface OpenCodeSessionErrorEvent extends OpenCodeEventBase {
|
|
232
|
+
type: "session_error";
|
|
233
|
+
properties: {
|
|
234
|
+
sessionId: string;
|
|
235
|
+
error: {
|
|
236
|
+
name: string;
|
|
237
|
+
message: string;
|
|
238
|
+
data?: unknown;
|
|
239
|
+
};
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Union type for OpenCode events.
|
|
245
|
+
*/
|
|
246
|
+
export type OpenCodeEvent = OpenCodeSessionUpdateEvent | OpenCodeMessageUpdateEvent | OpenCodeSessionErrorEvent | OpenCodeEventBase;
|
|
247
|
+
/**
|
|
248
|
+
* OpenCode error types.
|
|
249
|
+
*/
|
|
250
|
+
export type OpenCodeErrorType = "MessageAbortedError" | "ProviderAuthError" | "UnknownError" | "BadRequestError" | "AuthenticationError" | "PermissionDeniedError" | "NotFoundError" | "ConflictError" | "UnprocessableEntityError" | "RateLimitError" | "InternalServerError" | "ConnectionError" | "TimeoutError";
|
|
251
|
+
/**
|
|
252
|
+
* OpenCode error information.
|
|
253
|
+
*/
|
|
254
|
+
export interface OpenCodeError {
|
|
255
|
+
name: OpenCodeErrorType;
|
|
256
|
+
message: string;
|
|
257
|
+
data?: unknown;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Events emitted by the OpenCode Runner.
|
|
261
|
+
*/
|
|
262
|
+
export interface OpenCodeRunnerEvents {
|
|
263
|
+
/**
|
|
264
|
+
* Emitted when a message is received.
|
|
265
|
+
*/
|
|
266
|
+
message: (message: OpenCodeMessage) => void;
|
|
267
|
+
/**
|
|
268
|
+
* Emitted when an error occurs.
|
|
269
|
+
*/
|
|
270
|
+
error: (error: Error) => void;
|
|
271
|
+
/**
|
|
272
|
+
* Emitted when the session completes.
|
|
273
|
+
*/
|
|
274
|
+
complete: (messages: OpenCodeMessage[]) => void;
|
|
275
|
+
/**
|
|
276
|
+
* Emitted when an SSE event is received from the server.
|
|
277
|
+
*/
|
|
278
|
+
streamEvent: (event: OpenCodeEvent) => void;
|
|
279
|
+
/**
|
|
280
|
+
* Emitted when the server starts.
|
|
281
|
+
*/
|
|
282
|
+
serverStart: (port: number) => void;
|
|
283
|
+
/**
|
|
284
|
+
* Emitted when the server stops.
|
|
285
|
+
*/
|
|
286
|
+
serverStop: () => void;
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Options for creating an OpenCode client.
|
|
290
|
+
* Based on the @opencode-ai/sdk ClientOptions.
|
|
291
|
+
*/
|
|
292
|
+
export interface OpenCodeClientOptions {
|
|
293
|
+
baseURL?: string;
|
|
294
|
+
timeout?: number;
|
|
295
|
+
maxRetries?: number;
|
|
296
|
+
fetch?: (request: RequestInit) => Promise<Response>;
|
|
297
|
+
defaultHeaders?: Record<string, string>;
|
|
298
|
+
defaultQuery?: Record<string, string>;
|
|
299
|
+
logLevel?: "debug" | "info" | "warn" | "error";
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* OpenCode session from the SDK.
|
|
303
|
+
*/
|
|
304
|
+
export interface OpenCodeSession {
|
|
305
|
+
id: string;
|
|
306
|
+
createdAt: Date;
|
|
307
|
+
updatedAt: Date;
|
|
308
|
+
title?: string;
|
|
309
|
+
version?: string;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Chat request body for the session.chat() method.
|
|
313
|
+
*/
|
|
314
|
+
export interface OpenCodeChatRequest {
|
|
315
|
+
content: string;
|
|
316
|
+
attachments?: Array<{
|
|
317
|
+
type: string;
|
|
318
|
+
path?: string;
|
|
319
|
+
content?: string;
|
|
320
|
+
}>;
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Type guard to check if a message is a user message.
|
|
324
|
+
*/
|
|
325
|
+
export declare function isOpenCodeUserMessage(message: OpenCodeMessage): message is OpenCodeUserMessage;
|
|
326
|
+
/**
|
|
327
|
+
* Type guard to check if a message is an assistant message.
|
|
328
|
+
*/
|
|
329
|
+
export declare function isOpenCodeAssistantMessage(message: OpenCodeMessage): message is OpenCodeAssistantMessage;
|
|
330
|
+
/**
|
|
331
|
+
* Type guard to check if a message part is a tool part.
|
|
332
|
+
*/
|
|
333
|
+
export declare function isOpenCodeToolPart(part: OpenCodeMessagePart): part is OpenCodeToolPart;
|
|
334
|
+
/**
|
|
335
|
+
* Type guard to check if a message part is a text part.
|
|
336
|
+
*/
|
|
337
|
+
export declare function isOpenCodeTextPart(part: OpenCodeMessagePart): part is OpenCodeTextPart;
|
|
338
|
+
/**
|
|
339
|
+
* Type guard to check if a tool part has completed.
|
|
340
|
+
*/
|
|
341
|
+
export declare function isToolCompleted(part: OpenCodeToolPart): boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Type guard to check if a tool part has errored.
|
|
344
|
+
*/
|
|
345
|
+
export declare function isToolErrored(part: OpenCodeToolPart): boolean;
|
|
346
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAMtE;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC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/dist/types.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenCode Runner Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the OpenCode SDK integration with Sylas.
|
|
5
|
+
* OpenCode is an SDK-based AI coding agent that provides:
|
|
6
|
+
* - Managed server lifecycle via createOpencode()
|
|
7
|
+
* - SSE event streaming
|
|
8
|
+
* - True streaming input support
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Type guard to check if a message is a user message.
|
|
14
|
+
*/
|
|
15
|
+
export function isOpenCodeUserMessage(message) {
|
|
16
|
+
return message.type === "user";
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Type guard to check if a message is an assistant message.
|
|
20
|
+
*/
|
|
21
|
+
export function isOpenCodeAssistantMessage(message) {
|
|
22
|
+
return message.type === "assistant";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Type guard to check if a message part is a tool part.
|
|
26
|
+
*/
|
|
27
|
+
export function isOpenCodeToolPart(part) {
|
|
28
|
+
return part.type === "tool";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Type guard to check if a message part is a text part.
|
|
32
|
+
*/
|
|
33
|
+
export function isOpenCodeTextPart(part) {
|
|
34
|
+
return part.type === "text";
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Type guard to check if a tool part has completed.
|
|
38
|
+
*/
|
|
39
|
+
export function isToolCompleted(part) {
|
|
40
|
+
return part.state === "completed";
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Type guard to check if a tool part has errored.
|
|
44
|
+
*/
|
|
45
|
+
export function isToolErrored(part) {
|
|
46
|
+
return part.state === "error";
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAyaH;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACpC,OAAwB;IAExB,OAAO,OAAO,CAAC,IAAI,KAAK,MAAM,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACzC,OAAwB;IAExB,OAAO,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAyB;IAEzB,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CACjC,IAAyB;IAEzB,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAsB;IACrD,OAAO,IAAI,CAAC,KAAK,KAAK,WAAW,CAAC;AACnC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,IAAsB;IACnD,OAAO,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC;AAC/B,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sylas-opencode-runner",
|
|
3
|
+
"version": "0.2.21",
|
|
4
|
+
"description": "OpenCode SDK integration and management for Sylas",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@opencode-ai/sdk": "1.0.167",
|
|
13
|
+
"zod": "^3.23.0",
|
|
14
|
+
"sylas-core": "0.2.21"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@types/node": "^20.0.0",
|
|
18
|
+
"typescript": "^5.3.3"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc",
|
|
25
|
+
"dev": "tsc --watch",
|
|
26
|
+
"test": "bun test",
|
|
27
|
+
"test:run": "bun test",
|
|
28
|
+
"typecheck": "tsc --noEmit"
|
|
29
|
+
}
|
|
30
|
+
}
|