@a3s-lab/code 2.5.0 → 2.6.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 +22 -0
- package/index.d.ts +101 -0
- package/index.js +3 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -52,6 +52,28 @@ Omit `allowedTools` to allow every registered session tool except `program`.
|
|
|
52
52
|
Scripts can also be loaded from workspace-relative `.js` or `.mjs` files with
|
|
53
53
|
`{ path: 'scripts/ptc/search.js' }`.
|
|
54
54
|
|
|
55
|
+
## Workspace Backends And Direct Files
|
|
56
|
+
|
|
57
|
+
The default workspace backend is the local filesystem rooted at the session
|
|
58
|
+
workspace. SDK callers can pass the explicit typed backend now, using the same
|
|
59
|
+
option surface that remote, browser, DFS, and container-backed workspaces will
|
|
60
|
+
use:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const { Agent, LocalWorkspaceBackend } = require('@a3s-lab/code')
|
|
64
|
+
|
|
65
|
+
const agent = await Agent.create('agent.acl')
|
|
66
|
+
const session = agent.session('/repo', {
|
|
67
|
+
workspaceBackend: new LocalWorkspaceBackend('/repo'),
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
await session.writeFile('notes.txt', 'one\ntwo\n')
|
|
71
|
+
await session.readFile('notes.txt')
|
|
72
|
+
await session.ls()
|
|
73
|
+
await session.editFile('notes.txt', 'one', 'uno')
|
|
74
|
+
await session.patchFile('notes.txt', '@@ -1,2 +1,2 @@\n uno\n-two\n+dos')
|
|
75
|
+
```
|
|
76
|
+
|
|
55
77
|
## Planning Events
|
|
56
78
|
|
|
57
79
|
Planning is automatic by default. Prefer the explicit tri-state
|
package/index.d.ts
CHANGED
|
@@ -177,6 +177,42 @@ export interface JsSessionStore {
|
|
|
177
177
|
export interface JsSecurityProvider {
|
|
178
178
|
kind: string
|
|
179
179
|
}
|
|
180
|
+
export interface JsWorkspaceBackend {
|
|
181
|
+
kind: string
|
|
182
|
+
root?: string
|
|
183
|
+
s3?: JsS3BackendConfig
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Configuration for an S3-compatible workspace backend.
|
|
187
|
+
*
|
|
188
|
+
* Use this with [`S3WorkspaceBackend`] to point a session's built-in file
|
|
189
|
+
* tools at any S3-compatible endpoint (AWS S3, MinIO, RustFS, R2, etc.).
|
|
190
|
+
* `endpoint` is optional — omit it to use the AWS default. `prefix` is
|
|
191
|
+
* the logical workspace root inside the bucket; every workspace path
|
|
192
|
+
* becomes `<prefix>/<path>` when sent to S3.
|
|
193
|
+
*/
|
|
194
|
+
export interface JsS3BackendConfig {
|
|
195
|
+
/**
|
|
196
|
+
* Optional S3 endpoint URL. Omit for AWS S3 (the SDK will compute it
|
|
197
|
+
* from `region`). Set to `https://...` for MinIO / RustFS / R2 / etc.
|
|
198
|
+
*/
|
|
199
|
+
endpoint?: string
|
|
200
|
+
/** AWS region. Defaults to `us-east-1` when omitted. */
|
|
201
|
+
region?: string
|
|
202
|
+
/** Static access key. Use `sessionToken` together when STS-issued. */
|
|
203
|
+
accessKeyId: string
|
|
204
|
+
secretAccessKey: string
|
|
205
|
+
sessionToken?: string
|
|
206
|
+
/** Bucket name. */
|
|
207
|
+
bucket: string
|
|
208
|
+
/**
|
|
209
|
+
* Logical workspace prefix inside the bucket (without leading/trailing
|
|
210
|
+
* slashes). Use `""` to make the bucket root the workspace.
|
|
211
|
+
*/
|
|
212
|
+
prefix: string
|
|
213
|
+
/** `true` for MinIO / RustFS / most non-AWS endpoints; `false` for AWS S3. */
|
|
214
|
+
forcePathStyle?: boolean
|
|
215
|
+
}
|
|
180
216
|
/**
|
|
181
217
|
* Union type for AHP transport configuration.
|
|
182
218
|
* Accepts any of: StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport.
|
|
@@ -339,6 +375,17 @@ export interface SessionOptions {
|
|
|
339
375
|
* ```
|
|
340
376
|
*/
|
|
341
377
|
securityProvider?: JsSecurityProvider
|
|
378
|
+
/**
|
|
379
|
+
* Workspace backend used by built-in tools.
|
|
380
|
+
*
|
|
381
|
+
* Pass `new LocalWorkspaceBackend("/repo")` to explicitly use the local
|
|
382
|
+
* filesystem backend. This option is the SDK surface for future remote,
|
|
383
|
+
* browser, DFS, and container-backed workspace implementations.
|
|
384
|
+
* ```js
|
|
385
|
+
* agent.session('/repo', { workspaceBackend: new LocalWorkspaceBackend('/repo') });
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
workspaceBackend?: JsWorkspaceBackend
|
|
342
389
|
/**
|
|
343
390
|
* Custom role/identity prepended before the core agentic prompt.
|
|
344
391
|
* Example: "You are a senior Python developer specializing in FastAPI."
|
|
@@ -698,6 +745,52 @@ export declare class DefaultSecurityProvider {
|
|
|
698
745
|
kind: string
|
|
699
746
|
constructor()
|
|
700
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Local filesystem workspace backend.
|
|
750
|
+
*
|
|
751
|
+
* This is the explicit typed form of the default local workspace behavior.
|
|
752
|
+
* It is useful when callers want to pass workspace backends through the same
|
|
753
|
+
* option surface that remote/browser backends will use.
|
|
754
|
+
*
|
|
755
|
+
* ```js
|
|
756
|
+
* agent.session('/repo', { workspaceBackend: new LocalWorkspaceBackend('/repo') });
|
|
757
|
+
* ```
|
|
758
|
+
*/
|
|
759
|
+
export declare class LocalWorkspaceBackend {
|
|
760
|
+
kind: string
|
|
761
|
+
root: string
|
|
762
|
+
/** Create a local filesystem workspace backend rooted at `root`. */
|
|
763
|
+
constructor(root: string)
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* S3-compatible object-storage workspace backend.
|
|
767
|
+
*
|
|
768
|
+
* Points built-in file tools (`read`, `write`, `edit`, `patch`, `ls`) at an
|
|
769
|
+
* S3-compatible bucket. Works with AWS S3, MinIO, RustFS, Cloudflare R2,
|
|
770
|
+
* Backblaze B2, and other S3-API-compatible services.
|
|
771
|
+
*
|
|
772
|
+
* `bash`, `git`, `grep`, and `glob` are intentionally **not** registered
|
|
773
|
+
* when this backend is in use — object storage cannot service them.
|
|
774
|
+
*
|
|
775
|
+
* ```js
|
|
776
|
+
* const backend = new S3WorkspaceBackend({
|
|
777
|
+
* endpoint: 'https://minio.local:9000',
|
|
778
|
+
* region: 'us-east-1',
|
|
779
|
+
* accessKeyId: 'AKIA...',
|
|
780
|
+
* secretAccessKey: '...',
|
|
781
|
+
* bucket: 'workspace',
|
|
782
|
+
* prefix: 'users/u1/sessions/s1',
|
|
783
|
+
* forcePathStyle: true,
|
|
784
|
+
* });
|
|
785
|
+
* agent.session('s3://workspace/users/u1/sessions/s1', { workspaceBackend: backend });
|
|
786
|
+
* ```
|
|
787
|
+
*/
|
|
788
|
+
export declare class S3WorkspaceBackend {
|
|
789
|
+
kind: string
|
|
790
|
+
s3: JsS3BackendConfig
|
|
791
|
+
/** Create an S3-compatible workspace backend. */
|
|
792
|
+
constructor(config: JsS3BackendConfig)
|
|
793
|
+
}
|
|
701
794
|
/**
|
|
702
795
|
* Stdio transport for AHP (Agent Harness Protocol).
|
|
703
796
|
*
|
|
@@ -919,6 +1012,14 @@ export declare class Session {
|
|
|
919
1012
|
program(options: ProgramScriptOptions): Promise<ToolResult>
|
|
920
1013
|
/** Read a file from the workspace. */
|
|
921
1014
|
readFile(path: string): Promise<string>
|
|
1015
|
+
/** Write a file in the workspace. */
|
|
1016
|
+
writeFile(path: string, content: string): Promise<ToolResult>
|
|
1017
|
+
/** List a directory in the workspace. */
|
|
1018
|
+
ls(path?: string | undefined | null): Promise<ToolResult>
|
|
1019
|
+
/** Edit a file by replacing text in the workspace. */
|
|
1020
|
+
editFile(path: string, oldString: string, newString: string, replaceAll?: boolean | undefined | null): Promise<ToolResult>
|
|
1021
|
+
/** Apply a unified diff patch to a workspace file. */
|
|
1022
|
+
patchFile(path: string, diff: string): Promise<ToolResult>
|
|
922
1023
|
/** Execute a bash command in the workspace. */
|
|
923
1024
|
bash(command: string): Promise<string>
|
|
924
1025
|
/** Search for files matching a glob pattern. */
|
package/index.js
CHANGED
|
@@ -310,7 +310,7 @@ if (!nativeBinding) {
|
|
|
310
310
|
throw new Error(`Failed to load native binding`)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
const { formatVerificationSummary, EventStream, FileMemoryStore, FileSessionStore, MemorySessionStore, DefaultSecurityProvider, StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport, Agent, Session, builtinSkills, BrowserBackend } = nativeBinding
|
|
313
|
+
const { formatVerificationSummary, EventStream, FileMemoryStore, FileSessionStore, MemorySessionStore, DefaultSecurityProvider, LocalWorkspaceBackend, S3WorkspaceBackend, StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport, Agent, Session, builtinSkills, BrowserBackend } = nativeBinding
|
|
314
314
|
|
|
315
315
|
module.exports.formatVerificationSummary = formatVerificationSummary
|
|
316
316
|
module.exports.EventStream = EventStream
|
|
@@ -318,6 +318,8 @@ module.exports.FileMemoryStore = FileMemoryStore
|
|
|
318
318
|
module.exports.FileSessionStore = FileSessionStore
|
|
319
319
|
module.exports.MemorySessionStore = MemorySessionStore
|
|
320
320
|
module.exports.DefaultSecurityProvider = DefaultSecurityProvider
|
|
321
|
+
module.exports.LocalWorkspaceBackend = LocalWorkspaceBackend
|
|
322
|
+
module.exports.S3WorkspaceBackend = S3WorkspaceBackend
|
|
321
323
|
module.exports.StdioTransport = StdioTransport
|
|
322
324
|
module.exports.HttpTransport = HttpTransport
|
|
323
325
|
module.exports.WebSocketTransport = WebSocketTransport
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a3s-lab/code",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.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": "2.
|
|
44
|
-
"@a3s-lab/code-linux-x64-gnu": "2.
|
|
45
|
-
"@a3s-lab/code-linux-x64-musl": "2.
|
|
46
|
-
"@a3s-lab/code-linux-arm64-gnu": "2.
|
|
47
|
-
"@a3s-lab/code-linux-arm64-musl": "2.
|
|
48
|
-
"@a3s-lab/code-win32-x64-msvc": "2.
|
|
43
|
+
"@a3s-lab/code-darwin-arm64": "2.6.0",
|
|
44
|
+
"@a3s-lab/code-linux-x64-gnu": "2.6.0",
|
|
45
|
+
"@a3s-lab/code-linux-x64-musl": "2.6.0",
|
|
46
|
+
"@a3s-lab/code-linux-arm64-gnu": "2.6.0",
|
|
47
|
+
"@a3s-lab/code-linux-arm64-musl": "2.6.0",
|
|
48
|
+
"@a3s-lab/code-win32-x64-msvc": "2.6.0"
|
|
49
49
|
}
|
|
50
50
|
}
|