@a3s-lab/code 0.7.1 → 0.7.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/index.d.ts +0 -87
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.js +205 -16
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-arm64-musl.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.linux-x64-musl.node +0 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/* auto-generated by napi-rs */
|
|
3
|
-
|
|
4
|
-
export interface AgentOptions {
|
|
5
|
-
/** LLM model identifier (e.g., "claude-sonnet-4-20250514", "gpt-4o") */
|
|
6
|
-
model: string
|
|
7
|
-
/** API key for the LLM provider */
|
|
8
|
-
apiKey: string
|
|
9
|
-
/** Path to the workspace directory (sandbox root) */
|
|
10
|
-
workspace?: string
|
|
11
|
-
/** System prompt for the agent */
|
|
12
|
-
systemPrompt?: string
|
|
13
|
-
/** Base URL override for the LLM API */
|
|
14
|
-
baseUrl?: string
|
|
15
|
-
/** Maximum tool execution rounds per turn */
|
|
16
|
-
maxToolRounds?: number
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface AgentResult {
|
|
20
|
-
/** The final text response from the agent */
|
|
21
|
-
text: string
|
|
22
|
-
/** Number of tool calls made during execution */
|
|
23
|
-
toolCallsCount: number
|
|
24
|
-
/** Total prompt tokens used */
|
|
25
|
-
promptTokens: number
|
|
26
|
-
/** Total completion tokens used */
|
|
27
|
-
completionTokens: number
|
|
28
|
-
/** Total tokens used */
|
|
29
|
-
totalTokens: number
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface AgentEvent {
|
|
33
|
-
/** Event type: "start", "text_delta", "tool_start", "tool_end", "turn_start", "turn_end", "end", "error" */
|
|
34
|
-
type: string
|
|
35
|
-
/** Text content (for text_delta and end events) */
|
|
36
|
-
text?: string
|
|
37
|
-
/** Tool name (for tool_start and tool_end events) */
|
|
38
|
-
toolName?: string
|
|
39
|
-
/** Tool ID (for tool_start and tool_end events) */
|
|
40
|
-
toolId?: string
|
|
41
|
-
/** Tool output (for tool_end events) */
|
|
42
|
-
toolOutput?: string
|
|
43
|
-
/** Exit code (for tool_end events) */
|
|
44
|
-
exitCode?: number
|
|
45
|
-
/** Turn number (for turn_start and turn_end events) */
|
|
46
|
-
turn?: number
|
|
47
|
-
/** Prompt text (for start events) */
|
|
48
|
-
prompt?: string
|
|
49
|
-
/** Error message (for error events) */
|
|
50
|
-
error?: string
|
|
51
|
-
/** Token usage (for turn_end and end events) */
|
|
52
|
-
totalTokens?: number
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface ToolResult {
|
|
56
|
-
/** Tool name */
|
|
57
|
-
name: string
|
|
58
|
-
/** Tool output text */
|
|
59
|
-
output: string
|
|
60
|
-
/** Exit code (0 = success) */
|
|
61
|
-
exitCode: number
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* AI coding agent with tool execution capabilities.
|
|
66
|
-
*
|
|
67
|
-
* Create an Agent by providing a model name, API key, and workspace path.
|
|
68
|
-
* The agent auto-detects whether to use the Anthropic or OpenAI API based
|
|
69
|
-
* on the model name.
|
|
70
|
-
*/
|
|
71
|
-
export class Agent {
|
|
72
|
-
constructor(options: AgentOptions)
|
|
73
|
-
/** Send a prompt and wait for the complete response */
|
|
74
|
-
send(prompt: string): Promise<AgentResult>
|
|
75
|
-
/** Send a prompt and get all streaming events as an array */
|
|
76
|
-
stream(prompt: string): Promise<AgentEvent[]>
|
|
77
|
-
/** Execute a tool by name, bypassing the LLM */
|
|
78
|
-
tool(name: string, args: Record<string, unknown>): Promise<ToolResult>
|
|
79
|
-
/** Read a file from the workspace */
|
|
80
|
-
readFile(path: string): Promise<string>
|
|
81
|
-
/** Execute a bash command in the workspace */
|
|
82
|
-
bash(command: string): Promise<string>
|
|
83
|
-
/** Search for files matching a glob pattern */
|
|
84
|
-
glob(pattern: string): Promise<string[]>
|
|
85
|
-
/** Search file contents with a regex pattern */
|
|
86
|
-
grep(pattern: string): Promise<string>
|
|
87
|
-
}
|
package/index.darwin-arm64.node
CHANGED
|
Binary file
|
package/index.darwin-x64.node
CHANGED
|
Binary file
|
package/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
1
2
|
/* eslint-disable */
|
|
2
|
-
/*
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
3
6
|
|
|
4
7
|
const { existsSync, readFileSync } = require('fs')
|
|
5
8
|
const { join } = require('path')
|
|
@@ -11,12 +14,12 @@ let localFileExisted = false
|
|
|
11
14
|
let loadError = null
|
|
12
15
|
|
|
13
16
|
function isMusl() {
|
|
14
|
-
// For Node
|
|
17
|
+
// For Node 10
|
|
15
18
|
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
16
19
|
try {
|
|
17
20
|
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
18
21
|
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
19
|
-
} catch {
|
|
22
|
+
} catch (e) {
|
|
20
23
|
return true
|
|
21
24
|
}
|
|
22
25
|
} else {
|
|
@@ -26,13 +29,100 @@ function isMusl() {
|
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'index.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./index.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('@a3s-lab/code-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'index.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./index.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('@a3s-lab/code-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'index.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./index.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('@a3s-lab/code-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'index.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./index.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('@a3s-lab/code-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'index.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./index.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('@a3s-lab/code-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
29
110
|
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'index.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./index.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('@a3s-lab/code-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
30
120
|
switch (arch) {
|
|
31
121
|
case 'x64':
|
|
32
|
-
localFileExisted = existsSync(join(__dirname, '
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'index.darwin-x64.node'))
|
|
33
123
|
try {
|
|
34
124
|
if (localFileExisted) {
|
|
35
|
-
nativeBinding = require('./
|
|
125
|
+
nativeBinding = require('./index.darwin-x64.node')
|
|
36
126
|
} else {
|
|
37
127
|
nativeBinding = require('@a3s-lab/code-darwin-x64')
|
|
38
128
|
}
|
|
@@ -41,10 +131,12 @@ switch (platform) {
|
|
|
41
131
|
}
|
|
42
132
|
break
|
|
43
133
|
case 'arm64':
|
|
44
|
-
localFileExisted = existsSync(
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'index.darwin-arm64.node')
|
|
136
|
+
)
|
|
45
137
|
try {
|
|
46
138
|
if (localFileExisted) {
|
|
47
|
-
nativeBinding = require('./
|
|
139
|
+
nativeBinding = require('./index.darwin-arm64.node')
|
|
48
140
|
} else {
|
|
49
141
|
nativeBinding = require('@a3s-lab/code-darwin-arm64')
|
|
50
142
|
}
|
|
@@ -56,14 +148,31 @@ switch (platform) {
|
|
|
56
148
|
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
57
149
|
}
|
|
58
150
|
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'index.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./index.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('@a3s-lab/code-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
59
166
|
case 'linux':
|
|
60
167
|
switch (arch) {
|
|
61
168
|
case 'x64':
|
|
62
169
|
if (isMusl()) {
|
|
63
|
-
localFileExisted = existsSync(
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'index.linux-x64-musl.node')
|
|
172
|
+
)
|
|
64
173
|
try {
|
|
65
174
|
if (localFileExisted) {
|
|
66
|
-
nativeBinding = require('./
|
|
175
|
+
nativeBinding = require('./index.linux-x64-musl.node')
|
|
67
176
|
} else {
|
|
68
177
|
nativeBinding = require('@a3s-lab/code-linux-x64-musl')
|
|
69
178
|
}
|
|
@@ -71,10 +180,12 @@ switch (platform) {
|
|
|
71
180
|
loadError = e
|
|
72
181
|
}
|
|
73
182
|
} else {
|
|
74
|
-
localFileExisted = existsSync(
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'index.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
75
186
|
try {
|
|
76
187
|
if (localFileExisted) {
|
|
77
|
-
nativeBinding = require('./
|
|
188
|
+
nativeBinding = require('./index.linux-x64-gnu.node')
|
|
78
189
|
} else {
|
|
79
190
|
nativeBinding = require('@a3s-lab/code-linux-x64-gnu')
|
|
80
191
|
}
|
|
@@ -85,10 +196,12 @@ switch (platform) {
|
|
|
85
196
|
break
|
|
86
197
|
case 'arm64':
|
|
87
198
|
if (isMusl()) {
|
|
88
|
-
localFileExisted = existsSync(
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'index.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
89
202
|
try {
|
|
90
203
|
if (localFileExisted) {
|
|
91
|
-
nativeBinding = require('./
|
|
204
|
+
nativeBinding = require('./index.linux-arm64-musl.node')
|
|
92
205
|
} else {
|
|
93
206
|
nativeBinding = require('@a3s-lab/code-linux-arm64-musl')
|
|
94
207
|
}
|
|
@@ -96,10 +209,12 @@ switch (platform) {
|
|
|
96
209
|
loadError = e
|
|
97
210
|
}
|
|
98
211
|
} else {
|
|
99
|
-
localFileExisted = existsSync(
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'index.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
100
215
|
try {
|
|
101
216
|
if (localFileExisted) {
|
|
102
|
-
nativeBinding = require('./
|
|
217
|
+
nativeBinding = require('./index.linux-arm64-gnu.node')
|
|
103
218
|
} else {
|
|
104
219
|
nativeBinding = require('@a3s-lab/code-linux-arm64-gnu')
|
|
105
220
|
}
|
|
@@ -108,6 +223,78 @@ switch (platform) {
|
|
|
108
223
|
}
|
|
109
224
|
}
|
|
110
225
|
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
if (isMusl()) {
|
|
228
|
+
localFileExisted = existsSync(
|
|
229
|
+
join(__dirname, 'index.linux-arm-musleabihf.node')
|
|
230
|
+
)
|
|
231
|
+
try {
|
|
232
|
+
if (localFileExisted) {
|
|
233
|
+
nativeBinding = require('./index.linux-arm-musleabihf.node')
|
|
234
|
+
} else {
|
|
235
|
+
nativeBinding = require('@a3s-lab/code-linux-arm-musleabihf')
|
|
236
|
+
}
|
|
237
|
+
} catch (e) {
|
|
238
|
+
loadError = e
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
localFileExisted = existsSync(
|
|
242
|
+
join(__dirname, 'index.linux-arm-gnueabihf.node')
|
|
243
|
+
)
|
|
244
|
+
try {
|
|
245
|
+
if (localFileExisted) {
|
|
246
|
+
nativeBinding = require('./index.linux-arm-gnueabihf.node')
|
|
247
|
+
} else {
|
|
248
|
+
nativeBinding = require('@a3s-lab/code-linux-arm-gnueabihf')
|
|
249
|
+
}
|
|
250
|
+
} catch (e) {
|
|
251
|
+
loadError = e
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
break
|
|
255
|
+
case 'riscv64':
|
|
256
|
+
if (isMusl()) {
|
|
257
|
+
localFileExisted = existsSync(
|
|
258
|
+
join(__dirname, 'index.linux-riscv64-musl.node')
|
|
259
|
+
)
|
|
260
|
+
try {
|
|
261
|
+
if (localFileExisted) {
|
|
262
|
+
nativeBinding = require('./index.linux-riscv64-musl.node')
|
|
263
|
+
} else {
|
|
264
|
+
nativeBinding = require('@a3s-lab/code-linux-riscv64-musl')
|
|
265
|
+
}
|
|
266
|
+
} catch (e) {
|
|
267
|
+
loadError = e
|
|
268
|
+
}
|
|
269
|
+
} else {
|
|
270
|
+
localFileExisted = existsSync(
|
|
271
|
+
join(__dirname, 'index.linux-riscv64-gnu.node')
|
|
272
|
+
)
|
|
273
|
+
try {
|
|
274
|
+
if (localFileExisted) {
|
|
275
|
+
nativeBinding = require('./index.linux-riscv64-gnu.node')
|
|
276
|
+
} else {
|
|
277
|
+
nativeBinding = require('@a3s-lab/code-linux-riscv64-gnu')
|
|
278
|
+
}
|
|
279
|
+
} catch (e) {
|
|
280
|
+
loadError = e
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
break
|
|
284
|
+
case 's390x':
|
|
285
|
+
localFileExisted = existsSync(
|
|
286
|
+
join(__dirname, 'index.linux-s390x-gnu.node')
|
|
287
|
+
)
|
|
288
|
+
try {
|
|
289
|
+
if (localFileExisted) {
|
|
290
|
+
nativeBinding = require('./index.linux-s390x-gnu.node')
|
|
291
|
+
} else {
|
|
292
|
+
nativeBinding = require('@a3s-lab/code-linux-s390x-gnu')
|
|
293
|
+
}
|
|
294
|
+
} catch (e) {
|
|
295
|
+
loadError = e
|
|
296
|
+
}
|
|
297
|
+
break
|
|
111
298
|
default:
|
|
112
299
|
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
113
300
|
}
|
|
@@ -123,6 +310,8 @@ if (!nativeBinding) {
|
|
|
123
310
|
throw new Error(`Failed to load native binding`)
|
|
124
311
|
}
|
|
125
312
|
|
|
126
|
-
const { Agent } = nativeBinding
|
|
313
|
+
const { Agent, Session, builtinSkills } = nativeBinding
|
|
127
314
|
|
|
128
315
|
module.exports.Agent = Agent
|
|
316
|
+
module.exports.Session = Session
|
|
317
|
+
module.exports.builtinSkills = builtinSkills
|
|
Binary file
|
|
Binary file
|
package/index.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|