@a3s-lab/code 2.6.0 → 3.1.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/README.md +80 -3
- package/index.d.ts +183 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -55,9 +55,8 @@ Scripts can also be loaded from workspace-relative `.js` or `.mjs` files with
|
|
|
55
55
|
## Workspace Backends And Direct Files
|
|
56
56
|
|
|
57
57
|
The default workspace backend is the local filesystem rooted at the session
|
|
58
|
-
workspace. SDK callers can pass
|
|
59
|
-
option surface
|
|
60
|
-
use:
|
|
58
|
+
workspace. SDK callers can pass an explicit typed backend through the same
|
|
59
|
+
option surface used by remote, browser, DFS, and container-backed workspaces:
|
|
61
60
|
|
|
62
61
|
```js
|
|
63
62
|
const { Agent, LocalWorkspaceBackend } = require('@a3s-lab/code')
|
|
@@ -74,6 +73,39 @@ await session.editFile('notes.txt', 'one', 'uno')
|
|
|
74
73
|
await session.patchFile('notes.txt', '@@ -1,2 +1,2 @@\n uno\n-two\n+dos')
|
|
75
74
|
```
|
|
76
75
|
|
|
76
|
+
### S3-compatible object storage
|
|
77
|
+
|
|
78
|
+
`S3WorkspaceBackend` lets built-in file tools (`read`, `write`, `edit`,
|
|
79
|
+
`patch`, `ls`) target any S3-compatible endpoint — AWS S3, MinIO, RustFS,
|
|
80
|
+
Cloudflare R2, Backblaze B2, etc. `bash`, `git`, `grep`, and `glob` are
|
|
81
|
+
automatically hidden from the model because object storage cannot service
|
|
82
|
+
them.
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
const { Agent, S3WorkspaceBackend } = require('@a3s-lab/code')
|
|
86
|
+
|
|
87
|
+
const agent = await Agent.create('agent.acl')
|
|
88
|
+
const session = agent.session('s3://workspace/users/u1/sessions/s1', {
|
|
89
|
+
workspaceBackend: new S3WorkspaceBackend({
|
|
90
|
+
endpoint: 'https://minio.local:9000', // omit for AWS S3
|
|
91
|
+
region: 'us-east-1',
|
|
92
|
+
accessKeyId: 'AKIA...',
|
|
93
|
+
secretAccessKey: '...',
|
|
94
|
+
bucket: 'workspace',
|
|
95
|
+
prefix: 'users/u1/sessions/s1',
|
|
96
|
+
forcePathStyle: true, // true for MinIO/RustFS/R2
|
|
97
|
+
}),
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
await session.writeFile('notes/hello.txt', 'one\ntwo\n')
|
|
101
|
+
await session.readFile('notes/hello.txt')
|
|
102
|
+
await session.ls('notes')
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
S3 has no atomic read-modify-write, so concurrent writers to the same key
|
|
106
|
+
overwrite each other (last-writer-wins). Partition workspaces per session or
|
|
107
|
+
user via the `prefix` field when running multi-tenant.
|
|
108
|
+
|
|
77
109
|
## Planning Events
|
|
78
110
|
|
|
79
111
|
Planning is automatic by default. Prefer the explicit tri-state
|
|
@@ -126,9 +158,54 @@ await session.tasks([
|
|
|
126
158
|
])
|
|
127
159
|
```
|
|
128
160
|
|
|
161
|
+
For automatic subagent delegation, `autoParallel: false` disables automatic
|
|
162
|
+
parallel fan-out while keeping manual `parallel_task` / `session.tasks(...)`
|
|
163
|
+
available:
|
|
164
|
+
|
|
165
|
+
```js
|
|
166
|
+
const session = agent.session('/my-project', {
|
|
167
|
+
autoDelegation: { enabled: true, maxTasks: 4 },
|
|
168
|
+
maxParallelTasks: 8,
|
|
169
|
+
autoParallel: false,
|
|
170
|
+
})
|
|
171
|
+
```
|
|
172
|
+
|
|
129
173
|
Use `session.toolNames()` for names and `session.toolDefinitions()` when a UI
|
|
130
174
|
needs the full model-visible schemas.
|
|
131
175
|
|
|
176
|
+
## Evidence And Artifacts
|
|
177
|
+
|
|
178
|
+
Tool outputs that exceed the inline display budget are retained as session
|
|
179
|
+
artifacts. Use `artifactStoreLimits` to tune retention and `getArtifact(...)`
|
|
180
|
+
to retrieve retained content by URI:
|
|
181
|
+
|
|
182
|
+
```js
|
|
183
|
+
const session = agent.session('/my-project', {
|
|
184
|
+
artifactStoreLimits: { maxArtifacts: 64, maxBytes: 8 * 1024 * 1024 },
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
const artifact = session.getArtifact('a3s://tool-output/read/abc123')
|
|
188
|
+
if (artifact) console.log(artifact.content)
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
External verification systems can attach their reports to the same session
|
|
192
|
+
evidence stream:
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
session.recordVerificationReports([{
|
|
196
|
+
schema: 'a3s.verification_report.v1',
|
|
197
|
+
subject: 'sdk:tests',
|
|
198
|
+
status: 'passed',
|
|
199
|
+
checks: [{
|
|
200
|
+
id: 'check:sdk',
|
|
201
|
+
kind: 'test',
|
|
202
|
+
description: 'Run SDK tests',
|
|
203
|
+
status: 'passed',
|
|
204
|
+
required: true,
|
|
205
|
+
}],
|
|
206
|
+
}])
|
|
207
|
+
```
|
|
208
|
+
|
|
132
209
|
## Object-Shaped Direct Tools
|
|
133
210
|
|
|
134
211
|
New direct helpers use option objects when the command can grow over time:
|
package/index.d.ts
CHANGED
|
@@ -71,6 +71,14 @@ export interface AgentEvent {
|
|
|
71
71
|
verificationSummaryText?: string
|
|
72
72
|
/** Extra data for events that don't map to standard fields (JSON-encoded) */
|
|
73
73
|
data?: string
|
|
74
|
+
/**
|
|
75
|
+
* Structured discriminant for tool failures on `tool_end` events
|
|
76
|
+
* (JSON-encoded with a `type` field on the top level, e.g.
|
|
77
|
+
* `{"type":"version_conflict","path":"doc.md","expected":"etag-1","actual":"etag-2"}`).
|
|
78
|
+
* Undefined on success or untyped failure. Streaming consumers parse
|
|
79
|
+
* this to branch on the failure kind without scanning `toolOutput`.
|
|
80
|
+
*/
|
|
81
|
+
errorKindJson?: string
|
|
74
82
|
}
|
|
75
83
|
export interface VerificationCommand {
|
|
76
84
|
id: string
|
|
@@ -80,6 +88,32 @@ export interface VerificationCommand {
|
|
|
80
88
|
required?: boolean
|
|
81
89
|
timeoutMs?: number
|
|
82
90
|
}
|
|
91
|
+
export type VerificationStatus = 'passed' | 'failed' | 'needs_review' | 'skipped'
|
|
92
|
+
export interface VerificationCheck {
|
|
93
|
+
id: string
|
|
94
|
+
kind: string
|
|
95
|
+
description: string
|
|
96
|
+
status: VerificationStatus
|
|
97
|
+
required?: boolean
|
|
98
|
+
suggested_tools?: Array<string>
|
|
99
|
+
evidence_uris?: Array<string>
|
|
100
|
+
residual_risk?: string
|
|
101
|
+
}
|
|
102
|
+
export interface VerificationReport {
|
|
103
|
+
schema: string
|
|
104
|
+
subject: string
|
|
105
|
+
status: VerificationStatus
|
|
106
|
+
checks: Array<VerificationCheck>
|
|
107
|
+
residual_risks?: Array<string>
|
|
108
|
+
}
|
|
109
|
+
export interface ToolArtifact {
|
|
110
|
+
artifact_id: string
|
|
111
|
+
artifact_uri: string
|
|
112
|
+
tool_name: string
|
|
113
|
+
content: string
|
|
114
|
+
original_bytes: number
|
|
115
|
+
shown_bytes: number
|
|
116
|
+
}
|
|
83
117
|
export interface ToolResult {
|
|
84
118
|
name: string
|
|
85
119
|
output: string
|
|
@@ -88,7 +122,32 @@ export interface ToolResult {
|
|
|
88
122
|
metadataJson?: string
|
|
89
123
|
/** Convenience JSON view of `metadata.document_runtime` when present. */
|
|
90
124
|
documentRuntimeJson?: string
|
|
125
|
+
/**
|
|
126
|
+
* Structured discriminant for tool failures, JSON-encoded with a
|
|
127
|
+
* `type` field on the top level — e.g.
|
|
128
|
+
* `{"type":"version_conflict","path":"doc.md","expected":"etag-1","actual":"etag-2"}`.
|
|
129
|
+
* Undefined on success or untyped failure. SDK callers parse it to
|
|
130
|
+
* branch on the failure kind without scanning the `output` string.
|
|
131
|
+
*/
|
|
132
|
+
errorKindJson?: string
|
|
91
133
|
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Parsed shape of `ToolResult.errorKindJson` / `AgentEvent.errorKindJson`.
|
|
137
|
+
*
|
|
138
|
+
* Use a discriminated union on the `type` field; new variants may be
|
|
139
|
+
* added in future minor releases — callers should match exhaustively on
|
|
140
|
+
* the kinds they care about and fall through to a default branch for
|
|
141
|
+
* unknown ones.
|
|
142
|
+
*/
|
|
143
|
+
export type ToolErrorKind =
|
|
144
|
+
| { type: 'version_conflict'; path: string; expected: string; actual: string | null }
|
|
145
|
+
| { type: 'remote_git_conflict'; code: string; message: string }
|
|
146
|
+
| { type: 'not_found'; path: string }
|
|
147
|
+
| { type: 'invalid_argument'; message: string }
|
|
148
|
+
| { type: 'unsupported'; message: string }
|
|
149
|
+
| { type: 'timeout'; op: string; duration_ms: number }
|
|
150
|
+
|
|
92
151
|
/** Execution limits for `Session.program`. */
|
|
93
152
|
export interface ProgramScriptLimits {
|
|
94
153
|
timeoutMs?: number
|
|
@@ -166,6 +225,16 @@ export interface InlineSkill {
|
|
|
166
225
|
/** Markdown content for the skill. */
|
|
167
226
|
content: string
|
|
168
227
|
}
|
|
228
|
+
export interface AutoDelegationOptions {
|
|
229
|
+
/** Enable runtime-driven automatic child-agent delegation. */
|
|
230
|
+
enabled?: boolean
|
|
231
|
+
/** Allow automatic delegation to launch multiple child agents in parallel. */
|
|
232
|
+
autoParallel?: boolean
|
|
233
|
+
/** Minimum local confidence required to auto-delegate a child task. */
|
|
234
|
+
minConfidence?: number
|
|
235
|
+
/** Maximum number of automatic child tasks per user request. */
|
|
236
|
+
maxTasks?: number
|
|
237
|
+
}
|
|
169
238
|
export interface JsMemoryStore {
|
|
170
239
|
backend: string
|
|
171
240
|
dir?: string
|
|
@@ -212,6 +281,79 @@ export interface JsS3BackendConfig {
|
|
|
212
281
|
prefix: string
|
|
213
282
|
/** `true` for MinIO / RustFS / most non-AWS endpoints; `false` for AWS S3. */
|
|
214
283
|
forcePathStyle?: boolean
|
|
284
|
+
/**
|
|
285
|
+
* Maximum bytes a single `read` may return. The backend rejects any
|
|
286
|
+
* response with `Content-Length` greater than this without buffering
|
|
287
|
+
* the body. Defaults to 10 MiB on the Rust side when omitted.
|
|
288
|
+
*/
|
|
289
|
+
maxReadBytes?: number
|
|
290
|
+
/**
|
|
291
|
+
* Enable degraded `grep` / `glob` against this S3 backend. Off by
|
|
292
|
+
* default — object storage has no native search, so the only viable
|
|
293
|
+
* strategy is `LIST` + `GET` + regex, which can be slow and expensive.
|
|
294
|
+
*/
|
|
295
|
+
searchEnabled?: boolean
|
|
296
|
+
/**
|
|
297
|
+
* Upper bound on objects considered per `grep` / `glob` call. Defaults
|
|
298
|
+
* to 500 on the Rust side. Ignored when `searchEnabled` is `false`.
|
|
299
|
+
*/
|
|
300
|
+
maxObjectsScanned?: number
|
|
301
|
+
/**
|
|
302
|
+
* Per-object body-size ceiling for `grep` downloads. Larger objects are
|
|
303
|
+
* skipped (debug-traced). Defaults to 1 MiB on the Rust side. Ignored
|
|
304
|
+
* when `searchEnabled` is `false`.
|
|
305
|
+
*/
|
|
306
|
+
maxGrepBytesPerObject?: number
|
|
307
|
+
/**
|
|
308
|
+
* Concurrent object downloads during `grep`. Defaults to 8 on the Rust
|
|
309
|
+
* side. Set lower when the gitserver / S3 endpoint rate-limits
|
|
310
|
+
* aggressively; set higher when latency dominates. Ignored when
|
|
311
|
+
* `searchEnabled` is `false`.
|
|
312
|
+
*/
|
|
313
|
+
searchConcurrency?: number
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Configuration for a `RemoteGitBackend` — an HTTP/JSON client that
|
|
317
|
+
* brings the `git` tool to non-local workspaces (S3, future container /
|
|
318
|
+
* DFS).
|
|
319
|
+
*
|
|
320
|
+
* Pass alongside `workspaceBackend` on a session to attach remote git
|
|
321
|
+
* on top of any filesystem backend.
|
|
322
|
+
*/
|
|
323
|
+
export interface JsRemoteGitBackendConfig {
|
|
324
|
+
/**
|
|
325
|
+
* Base URL of the gitserver, no trailing slash. The client builds
|
|
326
|
+
* `{baseUrl}/v1/repos/{repoId}/git/{op}` per the RFC.
|
|
327
|
+
*/
|
|
328
|
+
baseUrl: string
|
|
329
|
+
/**
|
|
330
|
+
* Opaque repository identifier, URL-safe. Negotiated out of band
|
|
331
|
+
* with the gitserver operator.
|
|
332
|
+
*/
|
|
333
|
+
repoId: string
|
|
334
|
+
/**
|
|
335
|
+
* Bearer token sent as `Authorization: Bearer <token>`. Required in
|
|
336
|
+
* production; omitting it emits a server-side warning and is only safe
|
|
337
|
+
* on a trusted localhost gitserver.
|
|
338
|
+
*/
|
|
339
|
+
bearerToken?: string
|
|
340
|
+
/**
|
|
341
|
+
* mTLS client certificate path (PEM). When set together with `clientKeyPem`,
|
|
342
|
+
* the backend reads both files at construction and configures mTLS on the
|
|
343
|
+
* HTTP client. Setting only one of the pair errors at construction.
|
|
344
|
+
*/
|
|
345
|
+
clientCertPem?: string
|
|
346
|
+
/**
|
|
347
|
+
* mTLS client private key path (PEM). PKCS#8 format expected for the
|
|
348
|
+
* `rustls-tls` backend. See `clientCertPem`.
|
|
349
|
+
*/
|
|
350
|
+
clientKeyPem?: string
|
|
351
|
+
/** Per-call HTTP timeout in milliseconds. Defaults to 30 000. */
|
|
352
|
+
requestTimeoutMs?: number
|
|
353
|
+
/** Client-side cap on `diff` response bytes. Defaults to 1 MiB. */
|
|
354
|
+
maxDiffBytes?: number
|
|
355
|
+
/** Client-side cap on `log` `max_count`. Defaults to 200. */
|
|
356
|
+
maxLogEntries?: number
|
|
215
357
|
}
|
|
216
358
|
/**
|
|
217
359
|
* Union type for AHP transport configuration.
|
|
@@ -302,6 +444,13 @@ export interface PendingConfirmation {
|
|
|
302
444
|
/** Milliseconds remaining before the confirmation times out. */
|
|
303
445
|
remainingMs: number
|
|
304
446
|
}
|
|
447
|
+
/** Retention limits for large tool/program artifacts. */
|
|
448
|
+
export interface ArtifactStoreLimits {
|
|
449
|
+
/** Maximum number of artifacts retained by a session. */
|
|
450
|
+
maxArtifacts?: number
|
|
451
|
+
/** Maximum total artifact content bytes retained by a session. */
|
|
452
|
+
maxBytes?: number
|
|
453
|
+
}
|
|
305
454
|
export interface SessionOptions {
|
|
306
455
|
/** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */
|
|
307
456
|
model?: string
|
|
@@ -342,6 +491,8 @@ export interface SessionOptions {
|
|
|
342
491
|
autoCompact?: boolean
|
|
343
492
|
/** Context usage threshold (0.0–1.0) to trigger auto-compaction (default: 0.8). */
|
|
344
493
|
autoCompactThreshold?: number
|
|
494
|
+
/** Retention limits for large tool/program artifacts. */
|
|
495
|
+
artifactStoreLimits?: ArtifactStoreLimits
|
|
345
496
|
/**
|
|
346
497
|
* Long-term memory store backend.
|
|
347
498
|
*
|
|
@@ -386,6 +537,23 @@ export interface SessionOptions {
|
|
|
386
537
|
* ```
|
|
387
538
|
*/
|
|
388
539
|
workspaceBackend?: JsWorkspaceBackend
|
|
540
|
+
/**
|
|
541
|
+
* Optional remote git provider. When set, the resulting session attaches
|
|
542
|
+
* a `RemoteGitBackend` on top of `workspaceBackend` so the built-in
|
|
543
|
+
* `git` tool is available even on object-storage workspaces.
|
|
544
|
+
*
|
|
545
|
+
* ```js
|
|
546
|
+
* agent.session('s3://workspace/u1/s1', {
|
|
547
|
+
* workspaceBackend: new S3WorkspaceBackend({ ... }),
|
|
548
|
+
* remoteGit: {
|
|
549
|
+
* baseUrl: 'https://gitserver.internal',
|
|
550
|
+
* repoId: 'u1/s1',
|
|
551
|
+
* bearerToken: token,
|
|
552
|
+
* },
|
|
553
|
+
* });
|
|
554
|
+
* ```
|
|
555
|
+
*/
|
|
556
|
+
remoteGit?: JsRemoteGitBackendConfig
|
|
389
557
|
/**
|
|
390
558
|
* Custom role/identity prepended before the core agentic prompt.
|
|
391
559
|
* Example: "You are a senior Python developer specializing in FastAPI."
|
|
@@ -407,6 +575,16 @@ export interface SessionOptions {
|
|
|
407
575
|
inlineSkills?: Array<InlineSkill>
|
|
408
576
|
/** Override maximum number of tool-call rounds for this session. */
|
|
409
577
|
maxToolRounds?: number
|
|
578
|
+
/** Override maximum sibling parallel branches for this session. */
|
|
579
|
+
maxParallelTasks?: number
|
|
580
|
+
/** Override automatic child-agent delegation for this session. */
|
|
581
|
+
autoDelegation?: AutoDelegationOptions
|
|
582
|
+
/**
|
|
583
|
+
* Global session-level kill switch for automatic parallel child-agent fan-out.
|
|
584
|
+
*
|
|
585
|
+
* Manual `parallel_task` calls remain available when this is false.
|
|
586
|
+
*/
|
|
587
|
+
autoParallel?: boolean
|
|
410
588
|
/**
|
|
411
589
|
* Sampling temperature (0.0–1.0). Overrides the provider default.
|
|
412
590
|
* Only applied when `model` is also set.
|
|
@@ -1083,7 +1261,9 @@ export declare class Session {
|
|
|
1083
1261
|
/** Return compact execution trace events recorded for this session. */
|
|
1084
1262
|
traceEvents(): any
|
|
1085
1263
|
/** Return structured verification reports recorded for this session. */
|
|
1086
|
-
verificationReports():
|
|
1264
|
+
verificationReports(): Array<VerificationReport>
|
|
1265
|
+
/** Add externally produced verification reports to this session. */
|
|
1266
|
+
recordVerificationReports(reports: Array<VerificationReport> | VerificationReport): void
|
|
1087
1267
|
/** Return a structured verification summary for this session. */
|
|
1088
1268
|
verificationSummary(): any
|
|
1089
1269
|
/** Return a concise human-readable verification summary for this session. */
|
|
@@ -1188,6 +1368,8 @@ export declare class Session {
|
|
|
1188
1368
|
toolNames(): Array<string>
|
|
1189
1369
|
/** Return full model-visible tool definitions currently registered on this session. */
|
|
1190
1370
|
toolDefinitions(): any
|
|
1371
|
+
/** Return a stored tool artifact by URI, or null if it is not retained. */
|
|
1372
|
+
getArtifact(artifactUri: string): ToolArtifact | null
|
|
1191
1373
|
/**
|
|
1192
1374
|
* Register a hook for lifecycle event interception.
|
|
1193
1375
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a3s-lab/code",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "A3S Code - Native Node.js bindings for the coding-agent runtime",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"test:helpers": "node test-helpers.mjs"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@a3s-lab/code-darwin-arm64": "
|
|
44
|
-
"@a3s-lab/code-linux-x64-gnu": "
|
|
45
|
-
"@a3s-lab/code-linux-x64-musl": "
|
|
46
|
-
"@a3s-lab/code-linux-arm64-gnu": "
|
|
47
|
-
"@a3s-lab/code-linux-arm64-musl": "
|
|
48
|
-
"@a3s-lab/code-win32-x64-msvc": "
|
|
43
|
+
"@a3s-lab/code-darwin-arm64": "3.1.0",
|
|
44
|
+
"@a3s-lab/code-linux-x64-gnu": "3.1.0",
|
|
45
|
+
"@a3s-lab/code-linux-x64-musl": "3.1.0",
|
|
46
|
+
"@a3s-lab/code-linux-arm64-gnu": "3.1.0",
|
|
47
|
+
"@a3s-lab/code-linux-arm64-musl": "3.1.0",
|
|
48
|
+
"@a3s-lab/code-win32-x64-msvc": "3.1.0"
|
|
49
49
|
}
|
|
50
50
|
}
|