@a3s-lab/code 0.7.0 → 0.7.2
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 +72 -56
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.js +204 -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 +1,103 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
1
2
|
/* eslint-disable */
|
|
2
|
-
/* auto-generated by napi-rs */
|
|
3
3
|
|
|
4
|
-
|
|
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
|
-
}
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
18
5
|
|
|
19
6
|
export interface AgentResult {
|
|
20
|
-
/** The final text response from the agent */
|
|
21
7
|
text: string
|
|
22
|
-
/** Number of tool calls made during execution */
|
|
23
8
|
toolCallsCount: number
|
|
24
|
-
/** Total prompt tokens used */
|
|
25
9
|
promptTokens: number
|
|
26
|
-
/** Total completion tokens used */
|
|
27
10
|
completionTokens: number
|
|
28
|
-
/** Total tokens used */
|
|
29
11
|
totalTokens: number
|
|
30
12
|
}
|
|
31
|
-
|
|
32
13
|
export interface AgentEvent {
|
|
33
|
-
/** Event type: "start", "text_delta", "tool_start", "tool_end", "turn_start", "turn_end", "end", "error" */
|
|
34
14
|
type: string
|
|
35
|
-
/** Text content (for text_delta and end events) */
|
|
36
15
|
text?: string
|
|
37
|
-
/** Tool name (for tool_start and tool_end events) */
|
|
38
16
|
toolName?: string
|
|
39
|
-
/** Tool ID (for tool_start and tool_end events) */
|
|
40
17
|
toolId?: string
|
|
41
|
-
/** Tool output (for tool_end events) */
|
|
42
18
|
toolOutput?: string
|
|
43
|
-
/** Exit code (for tool_end events) */
|
|
44
19
|
exitCode?: number
|
|
45
|
-
/** Turn number (for turn_start and turn_end events) */
|
|
46
20
|
turn?: number
|
|
47
|
-
/** Prompt text (for start events) */
|
|
48
21
|
prompt?: string
|
|
49
|
-
/** Error message (for error events) */
|
|
50
22
|
error?: string
|
|
51
|
-
/** Token usage (for turn_end and end events) */
|
|
52
23
|
totalTokens?: number
|
|
53
24
|
}
|
|
54
|
-
|
|
55
25
|
export interface ToolResult {
|
|
56
|
-
/** Tool name */
|
|
57
26
|
name: string
|
|
58
|
-
/** Tool output text */
|
|
59
27
|
output: string
|
|
60
|
-
/** Exit code (0 = success) */
|
|
61
28
|
exitCode: number
|
|
62
29
|
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
/**
|
|
30
|
+
export interface SessionOptions {
|
|
31
|
+
/** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */
|
|
32
|
+
model?: string
|
|
33
|
+
/** Extra directories to scan for skill files (.md with YAML frontmatter). */
|
|
34
|
+
skillDirs?: Array<string>
|
|
35
|
+
/** Extra directories to scan for agent files. */
|
|
36
|
+
agentDirs?: Array<string>
|
|
37
|
+
}
|
|
38
|
+
export interface MessageObject {
|
|
39
|
+
role: string
|
|
40
|
+
content: Array<ContentBlockObject>
|
|
41
|
+
}
|
|
42
|
+
export interface ContentBlockObject {
|
|
43
|
+
type: string
|
|
44
|
+
/** Text content (for "text" blocks). */
|
|
45
|
+
text?: string
|
|
46
|
+
/** Tool use ID (for "tool_use" blocks). */
|
|
47
|
+
id?: string
|
|
48
|
+
/** Tool name (for "tool_use" blocks). */
|
|
49
|
+
name?: string
|
|
50
|
+
/** Tool input (for "tool_use" blocks). */
|
|
51
|
+
input?: any
|
|
52
|
+
/** Tool use ID reference (for "tool_result" blocks). */
|
|
53
|
+
toolUseId?: string
|
|
54
|
+
/** Tool result content (for "tool_result" blocks). */
|
|
55
|
+
resultContent?: string
|
|
56
|
+
/** Whether this is an error result (for "tool_result" blocks). */
|
|
57
|
+
isError?: boolean
|
|
58
|
+
}
|
|
59
|
+
/** AI coding agent. Create with `Agent.create()`, then call `agent.session()`. */
|
|
60
|
+
export declare class Agent {
|
|
61
|
+
/**
|
|
62
|
+
* Create an Agent from a config file path or inline config string.
|
|
63
|
+
*
|
|
64
|
+
* @param configSource - Path to .hcl/.json file, or inline JSON/HCL string
|
|
65
|
+
*/
|
|
66
|
+
static create(configSource: string): Promise<Agent>
|
|
67
|
+
/**
|
|
68
|
+
* Bind to a workspace directory, returning a Session.
|
|
69
|
+
*
|
|
70
|
+
* @param workspace - Path to the workspace directory
|
|
71
|
+
* @param options - Optional session overrides (model, skillDirs, agentDirs)
|
|
72
|
+
*/
|
|
73
|
+
session(workspace: string, options?: SessionOptions | undefined | null): Session
|
|
74
|
+
}
|
|
75
|
+
/** Workspace-bound session. All LLM and tool operations happen here. */
|
|
76
|
+
export declare class Session {
|
|
77
|
+
/**
|
|
78
|
+
* Send a prompt and wait for the complete response.
|
|
79
|
+
*
|
|
80
|
+
* @param prompt - The prompt to send
|
|
81
|
+
* @param history - Optional conversation history
|
|
82
|
+
*/
|
|
83
|
+
send(prompt: string, history?: Array<MessageObject> | undefined | null): Promise<AgentResult>
|
|
84
|
+
/**
|
|
85
|
+
* Send a prompt and get a stream of events.
|
|
86
|
+
*
|
|
87
|
+
* @param prompt - The prompt to send
|
|
88
|
+
* @param history - Optional conversation history
|
|
89
|
+
*/
|
|
90
|
+
stream(prompt: string, history?: Array<MessageObject> | undefined | null): Promise<Array<AgentEvent>>
|
|
91
|
+
/** Return the session's conversation history. */
|
|
92
|
+
history(): Array<MessageObject>
|
|
93
|
+
/** Execute a tool by name, bypassing the LLM. */
|
|
94
|
+
tool(name: string, args: any): Promise<ToolResult>
|
|
95
|
+
/** Read a file from the workspace. */
|
|
80
96
|
readFile(path: string): Promise<string>
|
|
81
|
-
/** Execute a bash command in the workspace */
|
|
97
|
+
/** Execute a bash command in the workspace. */
|
|
82
98
|
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 */
|
|
99
|
+
/** Search for files matching a glob pattern. */
|
|
100
|
+
glob(pattern: string): Promise<Array<string>>
|
|
101
|
+
/** Search file contents with a regex pattern. */
|
|
86
102
|
grep(pattern: string): Promise<string>
|
|
87
103
|
}
|
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,7 @@ if (!nativeBinding) {
|
|
|
123
310
|
throw new Error(`Failed to load native binding`)
|
|
124
311
|
}
|
|
125
312
|
|
|
126
|
-
const { Agent } = nativeBinding
|
|
313
|
+
const { Agent, Session } = nativeBinding
|
|
127
314
|
|
|
128
315
|
module.exports.Agent = Agent
|
|
316
|
+
module.exports.Session = Session
|
|
Binary file
|
|
Binary file
|
package/index.linux-x64-gnu.node
CHANGED
|
Binary file
|
|
Binary file
|