@a3s-lab/code 3.6.2 → 4.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 CHANGED
@@ -320,6 +320,25 @@ console.log(await session.mcps())
320
320
  The positional `addMcpServer(...)` overload and longer
321
321
  `addMcpServerConfig(...)` alias remain for compatibility.
322
322
 
323
+ ## Filesystem-First Agents
324
+
325
+ Define a durable agent as a **directory** — `instructions.md` (required) plus
326
+ optional `agent.acl`, `skills/`, `schedules/` (cron), and `tools/` (`kind: mcp` or
327
+ `kind: script` sandboxed QuickJS) — and serve its schedules. Each fire is a full
328
+ harness turn (context, tool visibility, safety gate, verification). Returns a
329
+ handle you must keep and stop explicitly.
330
+
331
+ ```js
332
+ const handle = await agent.serveAgentDir('./my-agent', './workspace', {
333
+ // Optional: pass a sessionStore so each schedule resumes its accumulated
334
+ // context across daemon restarts.
335
+ sessionStore: new FileSessionStore('./sessions'),
336
+ })
337
+ // ... runs in the background until:
338
+ await handle.stop()
339
+ console.log(handle.isStopped()) // true
340
+ ```
341
+
323
342
  ## HITL Confirmations
324
343
 
325
344
  Use `permissionPolicy` to decide which tools ask, then `confirmationPolicy` to
package/generated.d.ts CHANGED
@@ -413,6 +413,13 @@ export interface SessionOptions {
413
413
  builtinSkills?: boolean
414
414
  /** Extra directories to scan for skill files (.md with YAML frontmatter). */
415
415
  skillDirs?: Array<string>
416
+ /**
417
+ * Whether active skill allowed-tools restrict ordinary session tool calls.
418
+ *
419
+ * Defaults to false. Set true to restore the legacy global active-skill
420
+ * restriction before permission policy, hooks, HITL, or AHP run.
421
+ */
422
+ enforceActiveSkillToolRestrictions?: boolean
416
423
  /** Extra directories to scan for agent files. */
417
424
  agentDirs?: Array<string>
418
425
  /** Reproducible disposable workers to register for task delegation. */
@@ -1234,6 +1241,51 @@ export declare class Agent {
1234
1241
  * deployments.
1235
1242
  */
1236
1243
  disconnectIdleMcp(idleThresholdMs: number): Promise<Array<string>>
1244
+ /**
1245
+ * Serve a filesystem-first agent directory's cron schedules until stopped.
1246
+ *
1247
+ * Loads the directory by convention: `instructions.md` (required), optional
1248
+ * `agent.acl`, `skills/`, `schedules/*.md` (cron jobs), and `tools/*.md`
1249
+ * (`kind: mcp` servers or `kind: script` sandboxed QuickJS tools). It starts
1250
+ * one durable session per enabled schedule (stable id `schedule:<name>`) with
1251
+ * the agent dir's tools installed; each schedule fires as a FULL harness turn
1252
+ * (context, tool visibility, safety gate, verification), never a raw model call.
1253
+ *
1254
+ * Returns immediately with a {@link ServeHandle}; the daemon runs in the
1255
+ * background until `handle.stop()` is called. The handle MUST be kept and
1256
+ * stopped explicitly — dropping it does NOT cancel the daemon.
1257
+ *
1258
+ * ```js
1259
+ * const handle = await agent.serveAgentDir('./my-agent', '/my-project');
1260
+ * // ... later ...
1261
+ * await handle.stop();
1262
+ * ```
1263
+ *
1264
+ * @param dir - Path to the agent directory (prompt/skills/schedules/tools)
1265
+ * @param workspace - Workspace directory each scheduled turn operates in
1266
+ * @param options - Optional session overrides merged into every schedule session
1267
+ * (model, llmClient, sessionStore, …); `promptSlots`/`sessionId` set here are
1268
+ * NOT overridden so a host can pin them per schedule
1269
+ */
1270
+ serveAgentDir(dir: string, workspace: string, options?: SessionOptions | undefined | null): Promise<ServeHandle>
1271
+ }
1272
+ /**
1273
+ * Lifetime handle for a running serve daemon (see {@link Agent.serveAgentDir}).
1274
+ *
1275
+ * The daemon keeps running until `stop()` is called. Dropping the handle does
1276
+ * NOT cancel the daemon — call `stop()` explicitly for graceful shutdown.
1277
+ */
1278
+ export declare class ServeHandle {
1279
+ /**
1280
+ * Request graceful shutdown of the serve daemon.
1281
+ *
1282
+ * Signals every per-schedule job to stop after its current fire. Idempotent:
1283
+ * calling `stop()` more than once is a no-op. Resolves once the cancellation
1284
+ * has been signalled.
1285
+ */
1286
+ stop(): Promise<void>
1287
+ /** Whether `stop()` has been called on this handle. */
1288
+ isStopped(): boolean
1237
1289
  }
1238
1290
  /** Workspace-bound session. All LLM and tool operations happen here. */
1239
1291
  export declare class Session {
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, LocalWorkspaceBackend, S3WorkspaceBackend, StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport, Agent, Session, builtinSkills, BrowserBackend } = nativeBinding
313
+ const { formatVerificationSummary, EventStream, FileMemoryStore, FileSessionStore, MemorySessionStore, DefaultSecurityProvider, LocalWorkspaceBackend, S3WorkspaceBackend, StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport, Agent, ServeHandle, Session, builtinSkills, BrowserBackend } = nativeBinding
314
314
 
315
315
  module.exports.formatVerificationSummary = formatVerificationSummary
316
316
  module.exports.EventStream = EventStream
@@ -325,6 +325,7 @@ module.exports.HttpTransport = HttpTransport
325
325
  module.exports.WebSocketTransport = WebSocketTransport
326
326
  module.exports.UnixSocketTransport = UnixSocketTransport
327
327
  module.exports.Agent = Agent
328
+ module.exports.ServeHandle = ServeHandle
328
329
  module.exports.Session = Session
329
330
  module.exports.builtinSkills = builtinSkills
330
331
  module.exports.BrowserBackend = BrowserBackend
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a3s-lab/code",
3
- "version": "3.6.2",
3
+ "version": "4.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",
@@ -38,16 +38,16 @@
38
38
  "build": "napi build --platform --release --js index.js --dts generated.d.ts",
39
39
  "build:debug": "napi build --platform --js index.js --dts generated.d.ts",
40
40
  "prepublishOnly": "napi prepublish -t npm",
41
- "test": "node test.mjs",
41
+ "test": "node test.mjs && node test_serve.mjs",
42
42
  "test:types": "tsc --noEmit --module nodenext --moduleResolution nodenext --target es2022 --strict --skipLibCheck test-types.ts",
43
43
  "test:helpers": "node test-helpers.mjs"
44
44
  },
45
45
  "optionalDependencies": {
46
- "@a3s-lab/code-darwin-arm64": "3.6.2",
47
- "@a3s-lab/code-linux-x64-gnu": "3.6.2",
48
- "@a3s-lab/code-linux-x64-musl": "3.6.2",
49
- "@a3s-lab/code-linux-arm64-gnu": "3.6.2",
50
- "@a3s-lab/code-linux-arm64-musl": "3.6.2",
51
- "@a3s-lab/code-win32-x64-msvc": "3.6.2"
46
+ "@a3s-lab/code-darwin-arm64": "4.1.0",
47
+ "@a3s-lab/code-linux-x64-gnu": "4.1.0",
48
+ "@a3s-lab/code-linux-x64-musl": "4.1.0",
49
+ "@a3s-lab/code-linux-arm64-gnu": "4.1.0",
50
+ "@a3s-lab/code-linux-arm64-musl": "4.1.0",
51
+ "@a3s-lab/code-win32-x64-msvc": "4.1.0"
52
52
  }
53
53
  }