@a3s-lab/code 2.4.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 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
@@ -135,6 +157,7 @@ const session = agent.session('/my-project', {
135
157
  model: 'openai/gpt-4o',
136
158
  maxSteps: 24,
137
159
  prompt: 'Keep patches focused and run the narrowest relevant check.',
160
+ confirmationInheritance: 'auto_approve', // child runs auto-approve Ask decisions
138
161
  },
139
162
  { name: 'review-cow', description: 'Adversarial review', kind: 'reviewer' },
140
163
  ],
@@ -159,6 +182,27 @@ session.registerWorkerAgent({
159
182
 
160
183
  For a worker as the top-level actor, use `agent.sessionForWorker(workspace, spec)`.
161
184
 
185
+ ### Confirmation Inheritance
186
+
187
+ Control how child runs resolve Ask decisions with `confirmationInheritance`:
188
+
189
+ - `'auto_approve'` (default): Child runs auto-approve all Ask decisions
190
+ - `'deny_on_ask'`: Child runs fail immediately when encountering an Ask
191
+ - `'inherit_parent'`: Child runs inherit the parent's confirmation policy
192
+
193
+ ```js
194
+ const session = agent.session('/my-project', {
195
+ workerAgents: [
196
+ {
197
+ name: 'restricted-writer',
198
+ description: 'Write files with parent confirmation',
199
+ kind: 'implementer',
200
+ confirmationInheritance: 'inherit_parent', // requires parent approval
201
+ },
202
+ ],
203
+ })
204
+ ```
205
+
162
206
  ## AHP-Supervised Advice
163
207
 
164
208
  Background advice belongs in the host or AHP harness. A3S Code forwards hooks,
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.
@@ -226,6 +262,8 @@ export interface WorkerAgentSpec {
226
262
  prompt?: string
227
263
  /** Maximum execution steps/tool rounds. */
228
264
  maxSteps?: number
265
+ /** How child runs resolve Ask decisions: "auto_approve" (default), "deny_on_ask", or "inherit_parent". */
266
+ confirmationInheritance?: string
229
267
  }
230
268
  export interface AgentDefinition {
231
269
  name: string
@@ -235,6 +273,8 @@ export interface AgentDefinition {
235
273
  model?: string
236
274
  prompt?: string
237
275
  maxSteps?: number
276
+ /** How child runs resolve Ask decisions: "auto_approve", "deny_on_ask", or "inherit_parent". */
277
+ confirmationInheritance?: string
238
278
  }
239
279
  /**
240
280
  * HITL confirmation policy configuration.
@@ -335,6 +375,17 @@ export interface SessionOptions {
335
375
  * ```
336
376
  */
337
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
338
389
  /**
339
390
  * Custom role/identity prepended before the core agentic prompt.
340
391
  * Example: "You are a senior Python developer specializing in FastAPI."
@@ -694,6 +745,52 @@ export declare class DefaultSecurityProvider {
694
745
  kind: string
695
746
  constructor()
696
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
+ }
697
794
  /**
698
795
  * Stdio transport for AHP (Agent Harness Protocol).
699
796
  *
@@ -915,6 +1012,14 @@ export declare class Session {
915
1012
  program(options: ProgramScriptOptions): Promise<ToolResult>
916
1013
  /** Read a file from the workspace. */
917
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>
918
1023
  /** Execute a bash command in the workspace. */
919
1024
  bash(command: string): Promise<string>
920
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.4.0",
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.4.0",
44
- "@a3s-lab/code-linux-x64-gnu": "2.4.0",
45
- "@a3s-lab/code-linux-x64-musl": "2.4.0",
46
- "@a3s-lab/code-linux-arm64-gnu": "2.4.0",
47
- "@a3s-lab/code-linux-arm64-musl": "2.4.0",
48
- "@a3s-lab/code-win32-x64-msvc": "2.4.0"
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
  }