@a3s-lab/code 1.11.0 → 2.0.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.
Files changed (4) hide show
  1. package/README.md +1 -1
  2. package/index.d.ts +82 -579
  3. package/index.js +2 -6
  4. package/package.json +12 -13
package/README.md CHANGED
@@ -14,7 +14,7 @@ npm install @a3s-lab/code
14
14
  const { Agent } = require('@a3s-lab/code')
15
15
 
16
16
  async function main() {
17
- const agent = await Agent.create('agent.hcl')
17
+ const agent = await Agent.create('agent.acl')
18
18
  const session = agent.session('/my-project')
19
19
 
20
20
  const result = await session.send('What files handle authentication?')
package/index.d.ts CHANGED
@@ -3,106 +3,6 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- /** Unique task identifier (UUID string in JavaScript). */
7
- export interface TaskId {
8
- /** The task ID as a string */
9
- id: string
10
- }
11
- /** Task execution status. */
12
- export interface TaskStatus {
13
- /** Status string: "pending", "running", "completed", "failed", "killed" */
14
- status: string
15
- }
16
- /** Task type variants. */
17
- export interface TaskType {
18
- /** Type string: "tool", "agent", "remote_agent", "in_process_teammate", "workflow", "coordinator", "monitor_mcp", "idle" */
19
- type: string
20
- /** JSON-encoded data for the variant */
21
- data?: string
22
- }
23
- /** Base task with lifecycle management. */
24
- export interface Task {
25
- id: string
26
- kind: TaskType
27
- status: TaskStatus
28
- description: string
29
- toolUseId?: string
30
- parentId?: string
31
- childIds: Array<string>
32
- error?: string
33
- }
34
- /** Result of a completed task. */
35
- export interface TaskResult {
36
- taskId: string
37
- output?: string
38
- durationMs: number
39
- }
40
- /** Token usage statistics for a task. */
41
- export interface TaskTokenUsage {
42
- inputTokens: number
43
- outputTokens: number
44
- cacheReadTokens: number
45
- cacheWriteTokens: number
46
- }
47
- /** Record of a single tool activity. */
48
- export interface ToolActivity {
49
- toolName: string
50
- timestamp: string
51
- argsSummary: string
52
- success: boolean
53
- }
54
- /** Snapshot of agent execution progress. */
55
- export interface AgentProgress {
56
- toolCounts: Record<string, number>
57
- totalToolCalls: number
58
- tokenUsage: TaskTokenUsage
59
- recentActivities: Array<ToolActivity>
60
- elapsedMs: number
61
- running: boolean
62
- }
63
- /** Phase of an idle task. */
64
- export interface IdlePhase {
65
- /** Phase string: "starting", "consolidating", "updating", "completed" */
66
- phase: string
67
- }
68
- /** Tool call recorded during an idle turn. */
69
- export interface IdleToolCall {
70
- name: string
71
- argsSummary: string
72
- success: boolean
73
- }
74
- /** A single turn in idle execution. */
75
- export interface IdleTurn {
76
- text: string
77
- toolCalls: Array<IdleToolCall>
78
- touchedFiles: Array<string>
79
- inputTokens: number
80
- outputTokens: number
81
- }
82
- /** Memory update produced by idle completion. */
83
- export interface MemoryUpdate {
84
- semanticFacts: Array<string>
85
- episodicEntries: Array<EpisodicEntry>
86
- proceduralUpdates: Array<string>
87
- totalTokens: number
88
- durationMs: number
89
- }
90
- /** Episodic memory entry from idle. */
91
- export interface EpisodicEntry {
92
- timestamp: string
93
- description: string
94
- relatedFiles: Array<string>
95
- importance: number
96
- }
97
- /** Idle (memory consolidation) task state. */
98
- export interface IdleTask {
99
- id: string
100
- phase: IdlePhase
101
- reason: string
102
- turns: Array<IdleTurn>
103
- touchedFiles: Array<string>
104
- error?: string
105
- }
106
6
  /** AHP event type. */
107
7
  export interface AhpEventType {
108
8
  /** Event type string: "handshake", "pre_action", "post_action", "pre_prompt", "post_response", "session_start", "session_end", "error", "query", "heartbeat", "idle" */
@@ -148,7 +48,14 @@ export interface AgentResult {
148
48
  promptTokens: number
149
49
  completionTokens: number
150
50
  totalTokens: number
151
- }
51
+ verificationStatus: string
52
+ pendingVerificationCount: number
53
+ failedVerificationCount: number
54
+ verificationReportCount: number
55
+ verificationSummaryJson: string
56
+ verificationSummaryText: string
57
+ }
58
+ export declare function formatVerificationSummary(summary: any): string
152
59
  /**
153
60
  * Result of a `/btw` ephemeral side question.
154
61
  *
@@ -175,6 +82,8 @@ export interface AgentEvent {
175
82
  prompt?: string
176
83
  error?: string
177
84
  totalTokens?: number
85
+ verificationSummaryJson?: string
86
+ verificationSummaryText?: string
178
87
  /** For btw_answer event: the original question */
179
88
  question?: string
180
89
  /** For btw_answer event: the LLM's answer */
@@ -182,6 +91,14 @@ export interface AgentEvent {
182
91
  /** Extra data for events that don't map to standard fields (JSON-encoded) */
183
92
  data?: string
184
93
  }
94
+ export interface VerificationCommand {
95
+ id: string
96
+ kind: string
97
+ description: string
98
+ command: string
99
+ required?: boolean
100
+ timeoutMs?: number
101
+ }
185
102
  export interface ToolResult {
186
103
  name: string
187
104
  output: string
@@ -262,6 +179,18 @@ export interface JsAhpTransport {
262
179
  authToken?: string
263
180
  path?: string
264
181
  }
182
+ export interface PermissionPolicy {
183
+ /** Tool invocation patterns that are always denied first. */
184
+ deny?: Array<string>
185
+ /** Tool invocation patterns that are auto-approved. */
186
+ allow?: Array<string>
187
+ /** Tool invocation patterns that always require confirmation. */
188
+ ask?: Array<string>
189
+ /** Default decision when no rule matches: "allow", "deny", or "ask". */
190
+ defaultDecision?: string
191
+ /** Whether this policy is enabled. Defaults to true. */
192
+ enabled?: boolean
193
+ }
265
194
  export interface SessionOptions {
266
195
  /** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */
267
196
  model?: string
@@ -271,10 +200,14 @@ export interface SessionOptions {
271
200
  skillDirs?: Array<string>
272
201
  /** Extra directories to scan for agent files. */
273
202
  agentDirs?: Array<string>
274
- /** Optional queue configuration for lane-based tool execution. */
203
+ /**
204
+ * Optional advanced queue configuration for explicit external/hybrid lane dispatch.
205
+ *
206
+ * Ordinary sessions are queue-free unless this is provided.
207
+ */
275
208
  queueConfig?: SessionQueueConfig
276
- /** Allow all tools without HITL confirmation (default: false). */
277
- permissive?: boolean
209
+ /** Explicit permission policy for tool execution. */
210
+ permissionPolicy?: PermissionPolicy
278
211
  /** Enable planning mode (default: false). */
279
212
  planning?: boolean
280
213
  /** Enable goal tracking (default: false). */
@@ -431,7 +364,12 @@ export interface AttachmentObject {
431
364
  /** MIME type (e.g., "image/jpeg", "image/png"). */
432
365
  mediaType: string
433
366
  }
434
- /** Configuration for the session lane queue. */
367
+ /**
368
+ * Configuration for the optional advanced session lane queue.
369
+ *
370
+ * Ordinary sessions do not initialize queue infrastructure. Use this only for
371
+ * explicit external/hybrid dispatch, priority experiments, or operational integrations.
372
+ */
435
373
  export interface SessionQueueConfig {
436
374
  /** Max concurrency for Query lane (default: 4). */
437
375
  queryConcurrency?: number
@@ -510,28 +448,13 @@ export interface CommandContext {
510
448
  }
511
449
  /** Metadata about a registered slash command. */
512
450
  export interface CommandInfo {
513
- /** Command name without the leading `/` (e.g., `"loop"`, `"help"`) */
451
+ /** Command name without the leading `/` (e.g., `"help"`, `"model"`) */
514
452
  name: string
515
453
  /** Short description shown in `/help` */
516
454
  description: string
517
- /** Optional usage hint (e.g., `"/loop [interval] <prompt> [every <interval>]"`) */
455
+ /** Optional usage hint (e.g., `"/model <provider/model>"`) */
518
456
  usage?: string
519
457
  }
520
- /** Info about an active scheduled task. */
521
- export interface ScheduledTaskInfo {
522
- /** 8-char hex task ID */
523
- id: string
524
- /** The prompt sent at each interval */
525
- prompt: string
526
- /** Interval between fires in seconds */
527
- intervalSecs: number
528
- /** Whether the task repeats (always `true` for tasks created via `/loop`) */
529
- recurring: boolean
530
- /** Number of times this task has fired so far */
531
- fireCount: number
532
- /** Seconds until the next fire (0 if overdue) */
533
- nextFireInSecs: number
534
- }
535
458
  /** Matcher for filtering which events trigger a hook. */
536
459
  export interface HookMatcherObject {
537
460
  /** Match specific tool name (exact match) */
@@ -569,118 +492,6 @@ export interface SkillInfo {
569
492
  * Each entry has `name`, `description`, and `kind` (instruction, tool, or agent).
570
493
  */
571
494
  export declare function builtinSkills(): Array<SkillInfo>
572
- /** Role of a team member. */
573
- export const enum TeamRole {
574
- /** Decomposes goals into tasks, assigns work. */
575
- Lead = 0,
576
- /** Executes assigned tasks. */
577
- Worker = 1,
578
- /** Reviews completed work, provides feedback. */
579
- Reviewer = 2
580
- }
581
- /** Task status on the team task board. */
582
- export const enum TeamTaskStatus {
583
- /** Waiting to be claimed. */
584
- Open = 0,
585
- /** Claimed by a worker. */
586
- InProgress = 1,
587
- /** Work done, awaiting review. */
588
- InReview = 2,
589
- /** Approved by reviewer. */
590
- Done = 3,
591
- /** Rejected, needs rework. */
592
- Rejected = 4
593
- }
594
- /** Team configuration. */
595
- export interface TeamConfig {
596
- /** Maximum concurrent tasks on the board (default: 50). */
597
- maxTasks?: number
598
- /** Message channel buffer size (default: 128). */
599
- channelBuffer?: number
600
- /** Maximum coordinator rounds before `runUntilDone` exits (default: 10). */
601
- maxRounds?: number
602
- /** Worker/Reviewer polling interval in milliseconds (default: 200). */
603
- pollIntervalMs?: number
604
- }
605
- /** A task snapshot from the team board (read-only). */
606
- export interface TeamTask {
607
- id: string
608
- description: string
609
- postedBy: string
610
- assignedTo?: string
611
- /** Task status. */
612
- status: string
613
- result?: string
614
- createdAt: number
615
- updatedAt: number
616
- }
617
- /** Result returned by `TeamRunner.runUntilDone()`. */
618
- export interface TeamRunResult {
619
- doneTasks: Array<TeamTask>
620
- rejectedTasks: Array<TeamTask>
621
- rounds: number
622
- }
623
- /**
624
- * Per-member overrides for `TeamRunner.addLead`, `addWorker`, and `addReviewer`.
625
- *
626
- * All fields are optional. Unset fields inherit from the agent definition
627
- * file (role-level config) and ultimately from the `Agent` base config:
628
- *
629
- * ```
630
- * TeamMemberOptions → AgentDefinition (.yaml/.md) → Agent (config.hcl)
631
- * ```
632
- *
633
- * Specifically:
634
- * - `model`: unset → inherits agent definition model → inherits Agent default model
635
- * - `extra`: unset → inherits agent definition `prompt` field
636
- * - `role`, `guidelines`, `responseStyle`: unset → empty (no definition-level equivalent)
637
- * - `workspace`: unset → inherits the workspace passed to `TeamRunner.create`
638
- * - `maxToolRounds`: unset → inherits agent definition `max_steps` → inherits Agent config
639
- */
640
- export interface TeamMemberOptions {
641
- /**
642
- * Override the workspace for this member.
643
- *
644
- * Set this to an isolated git worktree path so concurrent workers do not
645
- * conflict with each other on the filesystem.
646
- * Falls back to the workspace supplied to `TeamRunner.create`.
647
- */
648
- workspace?: string
649
- /**
650
- * Model override. Format: `"provider/model"` (e.g. `"openai/gpt-4o"`).
651
- * Falls back to the agent definition model, then the Agent default model.
652
- */
653
- model?: string
654
- /**
655
- * Custom role/identity prepended before the core agentic prompt.
656
- *
657
- * Example: `"You are a senior Python developer specializing in FastAPI."`
658
- * No definition-level default — omit to use the standard agent identity.
659
- */
660
- role?: string
661
- /**
662
- * Custom coding guidelines appended after the core prompt.
663
- *
664
- * Example: `"Always write unit tests. Follow PEP 8."`
665
- * No definition-level default — omit to use no extra guidelines.
666
- */
667
- guidelines?: string
668
- /**
669
- * Custom response style (replaces the default Response Format section).
670
- * No definition-level default — omit to use the standard response format.
671
- */
672
- responseStyle?: string
673
- /**
674
- * Freeform extra instructions appended at the very end of the system prompt.
675
- * Falls back to the agent definition `prompt` field when unset.
676
- */
677
- extra?: string
678
- /**
679
- * Override maximum number of tool-call rounds for this member's session.
680
- * Falls back to the agent definition `max_steps`, then the Agent config.
681
- */
682
- maxToolRounds?: number
683
- }
684
495
  /** Configuration for a search engine. */
685
496
  export interface SearchEngineConfig {
686
497
  enabled: boolean
@@ -700,6 +511,7 @@ export interface HeadlessConfig {
700
511
  browserPath?: string
701
512
  maxTabs?: number
702
513
  launchArgs?: Array<string>
514
+ proxyUrl?: string
703
515
  }
704
516
  /** Health monitor configuration for search engines. */
705
517
  export interface SearchHealthConfig {
@@ -713,7 +525,7 @@ export interface SearchConfig {
713
525
  engines: Record<string, SearchEngineConfig>
714
526
  headless?: HeadlessConfig
715
527
  }
716
- /** SubAgent configuration for orchestrator. */
528
+ /** SubAgent configuration for the advanced orchestrator control plane. */
717
529
  export interface SubAgentConfig {
718
530
  /** Agent type (general, explore, plan, etc.) */
719
531
  agentType: string
@@ -721,10 +533,6 @@ export interface SubAgentConfig {
721
533
  description: string
722
534
  /** Execution prompt */
723
535
  prompt: string
724
- /** Enable permissive mode (bypass HITL) */
725
- permissive: boolean
726
- /** Deny rules to enforce even in permissive mode (e.g., ["mcp__longvt__*"]) */
727
- permissiveDeny?: Array<string>
728
536
  /** Maximum execution steps */
729
537
  maxSteps?: number
730
538
  /** Execution timeout (milliseconds) */
@@ -737,45 +545,6 @@ export interface SubAgentConfig {
737
545
  agentDirs?: Array<string>
738
546
  /** Extra directories to scan for skill definition files */
739
547
  skillDirs?: Array<string>
740
- /**
741
- * Lane queue config for External/Hybrid tool dispatch.
742
- * When set, tools in the specified lanes are routed to external workers.
743
- */
744
- laneConfig?: SessionQueueConfig
745
- }
746
- /**
747
- * Unified agent slot — used for both standalone subagents and team members.
748
- *
749
- * When `role` is `undefined` the slot describes a standalone subagent.
750
- * Valid role values: `"lead"`, `"worker"`, `"reviewer"`.
751
- */
752
- export interface AgentSlot {
753
- /** Agent type (general, explore, plan, etc.) */
754
- agentType: string
755
- /** Team role: "lead", "worker", or "reviewer". Omit for standalone. */
756
- role?: string
757
- /** Task description */
758
- description: string
759
- /** Execution prompt */
760
- prompt: string
761
- /** Enable permissive mode (bypass HITL) */
762
- permissive: boolean
763
- /** Deny rules to enforce even in permissive mode (e.g., ["mcp__longvt__*"]) */
764
- permissiveDeny?: Array<string>
765
- /** Maximum execution steps */
766
- maxSteps?: number
767
- /** Execution timeout (milliseconds) */
768
- timeoutMs?: number
769
- /** Parent SubAgent ID (for nesting) */
770
- parentId?: string
771
- /** Workspace directory (defaults to ".") */
772
- workspace?: string
773
- /** Extra directories to scan for agent definition files */
774
- agentDirs?: Array<string>
775
- /** Extra directories to scan for skill definition files */
776
- skillDirs?: Array<string>
777
- /** Lane queue config for External/Hybrid tool dispatch */
778
- laneConfig?: SessionQueueConfig
779
548
  }
780
549
  /** SubAgent activity type */
781
550
  export interface SubAgentActivity {
@@ -805,17 +574,6 @@ export interface SubAgentStateEntry {
805
574
  id: string
806
575
  state: string
807
576
  }
808
- /** A pending external task waiting for a remote worker to process. */
809
- export interface PendingExternalTask {
810
- /** Unique task identifier — pass this to `completeExternalTask()` */
811
- taskId: string
812
- /** Tool type: "bash", "write", "edit", etc. */
813
- commandType: string
814
- /** JSON-encoded tool arguments */
815
- payload: string
816
- /** Lane name: "Execute", "Query", etc. */
817
- lane: string
818
- }
819
577
  /** Streaming event iterator. Use `for await (const event of stream)` or call `.next()` manually. */
820
578
  export declare class EventStream {
821
579
  /**
@@ -994,10 +752,10 @@ export declare class Agent {
994
752
  /**
995
753
  * Create an Agent from a config file path or inline config string.
996
754
  *
997
- * Accepts HCL (.hcl), JSON (.json), ACL (.acl), or inline config strings.
998
- * For inline strings: JSON starts with '{', ACL starts with 'providers "', otherwise HCL.
755
+ * Accepts ACL-compatible config files (.acl) or inline config strings.
756
+ * JSON config is not supported.
999
757
  *
1000
- * @param configSource - Path to a config file (.hcl/.json/.acl), or inline config string
758
+ * @param configSource - Path to a config file (.acl), or inline config string
1001
759
  */
1002
760
  static create(configSource: string): Promise<Agent>
1003
761
  /**
@@ -1071,6 +829,8 @@ export declare class Session {
1071
829
  * Send a prompt and get a streaming event iterator.
1072
830
  *
1073
831
  * Returns an `EventStream`. Use `for await (const event of stream)` or call `.next()` manually.
832
+ * When `history` is omitted, the session history and verification evidence are
833
+ * updated after the stream completes. Supplying `history` keeps the stream isolated.
1074
834
  *
1075
835
  * @param prompt - The prompt to send
1076
836
  * @param history - Optional conversation history
@@ -1087,6 +847,9 @@ export declare class Session {
1087
847
  /**
1088
848
  * Stream a prompt with image attachments.
1089
849
  *
850
+ * When `history` is omitted, the session history and verification evidence are
851
+ * updated after the stream completes. Supplying `history` keeps the stream isolated.
852
+ *
1090
853
  * @param prompt - The prompt to send
1091
854
  * @param attachments - Array of `{ data: Buffer, mediaType: string }`
1092
855
  * @param history - Optional conversation history
@@ -1096,19 +859,6 @@ export declare class Session {
1096
859
  history(): Array<MessageObject>
1097
860
  /** Execute a tool by name, bypassing the LLM. */
1098
861
  tool(name: string, args: any): Promise<ToolResult>
1099
- /**
1100
- * Run a goal through the built-in `run_team` tool.
1101
- *
1102
- * Spawns a Lead → Worker → Reviewer team as child subagents: the Lead
1103
- * decomposes `goal` into tasks, Workers execute them concurrently, and the
1104
- * Reviewer approves or rejects each result (rejected tasks are retried).
1105
- *
1106
- * This is a typed convenience wrapper over `session.tool("run_team", {...})`.
1107
- * All agent-type arguments default to `"general"` when omitted.
1108
- *
1109
- * @returns `ToolResult` whose `output` contains the formatted team run summary.
1110
- */
1111
- runTeam(goal: string, leadAgent?: string | undefined | null, workerAgent?: string | undefined | null, reviewerAgent?: string | undefined | null, maxSteps?: number | undefined | null): Promise<ToolResult>
1112
862
  /** Read a file from the workspace. */
1113
863
  readFile(path: string): Promise<string>
1114
864
  /** Execute a bash command in the workspace. */
@@ -1121,48 +871,40 @@ export declare class Session {
1121
871
  webSearch(params: JsWebSearchParams): Promise<ToolResult>
1122
872
  /** Execute a git command (status, log, branch, checkout, diff, stash, remote, worktree). */
1123
873
  git(command: string, subcommand?: string | undefined | null, name?: string | undefined | null, path?: string | undefined | null, newBranch?: boolean | undefined | null, base?: string | undefined | null, force?: boolean | undefined | null, maxCount?: number | undefined | null, message?: string | undefined | null, includeUntracked?: boolean | undefined | null, target?: string | undefined | null, reference?: string | undefined | null): Promise<ToolResult>
1124
- /** Check if this session has a lane queue configured. */
874
+ /** Check if this session has an advanced lane queue configured. */
1125
875
  hasQueue(): boolean
1126
876
  /**
1127
- * Configure a lane's handler mode.
877
+ * Configure a lane's handler mode for explicit external/hybrid dispatch.
1128
878
  *
1129
879
  * @param lane - "control", "query", "execute", or "generate"
1130
880
  * @param config - { mode: "internal"|"external"|"hybrid", timeoutMs?: number }
1131
881
  */
1132
882
  setLaneHandler(lane: string, config: LaneHandlerConfig): Promise<void>
1133
883
  /**
1134
- * Complete an external task by ID.
884
+ * Complete an external queue task by ID.
1135
885
  *
1136
886
  * @param taskId - The task identifier
1137
887
  * @param result - { success: boolean, result?: any, error?: string }
1138
888
  * @returns true if found, false if not found
1139
889
  */
1140
890
  completeExternalTask(taskId: string, result: ExternalTaskResult): Promise<boolean>
1141
- /** Get pending external tasks. */
891
+ /** Get pending external queue tasks. */
1142
892
  pendingExternalTasks(): Promise<any>
1143
- /** Get queue statistics. */
893
+ /** Get optional queue statistics. */
1144
894
  queueStats(): Promise<QueueStats>
1145
- /**
1146
- * Submit a JSON payload as a command to the session's lane queue.
1147
- *
1148
- * The payload is stored and returned as-is when the queue schedules the
1149
- * command. Returns a Promise that resolves to the payload value.
1150
- *
1151
- * @param lane - "control", "query", "execute", or "generate"
1152
- * @param payload - Any JSON-serializable value
1153
- */
1154
- submit(lane: string, payload: any): Promise<any>
1155
- /**
1156
- * Submit multiple JSON payloads as a batch to the session's lane queue.
1157
- *
1158
- * More efficient than calling `submit()` in a loop. Returns a Promise that
1159
- * resolves to an array of results in the same order as the input payloads.
1160
- *
1161
- * @param lane - "control", "query", "execute", or "generate"
1162
- * @param payloads - Array of JSON-serializable values
1163
- */
1164
- submitBatch(lane: string, payloads: Array<any>): Promise<Array<any>>
1165
- /** Get dead letters from the DLQ. */
895
+ /** Return compact execution trace events recorded for this session. */
896
+ traceEvents(): any
897
+ /** Return structured verification reports recorded for this session. */
898
+ verificationReports(): any
899
+ /** Return a structured verification summary for this session. */
900
+ verificationSummary(): any
901
+ /** Return a concise human-readable verification summary for this session. */
902
+ verificationSummaryText(): string
903
+ /** Run verification commands and return a structured verification report. */
904
+ verifyCommands(subject: string, commands: Array<VerificationCommand>): Promise<any>
905
+ /** Return project-aware verification command presets for this workspace. */
906
+ verificationPresets(): any
907
+ /** Get dead letters from the optional queue's DLQ. */
1166
908
  deadLetters(): Promise<any>
1167
909
  /**
1168
910
  * Get a detailed metrics snapshot from the queue.
@@ -1362,30 +1104,6 @@ export declare class Session {
1362
1104
  * @returns Array of CommandInfo objects sorted by name
1363
1105
  */
1364
1106
  listCommands(): Array<CommandInfo>
1365
- /**
1366
- * Schedule a recurring prompt to fire at a given interval.
1367
- *
1368
- * This is the programmatic equivalent of `/loop <interval>s <prompt>`.
1369
- * The scheduled prompt runs automatically after each `send()` call when it is due.
1370
- *
1371
- * @param prompt - The prompt to send at each interval
1372
- * @param intervalSecs - Interval in seconds (minimum: 1)
1373
- * @returns 8-char hex task ID (use with `cancelScheduledTask`)
1374
- */
1375
- scheduleTask(prompt: string, intervalSecs: number): string
1376
- /**
1377
- * List all active scheduled tasks for this session.
1378
- *
1379
- * @returns Array of ScheduledTaskInfo objects sorted by task ID
1380
- */
1381
- listScheduledTasks(): Array<ScheduledTaskInfo>
1382
- /**
1383
- * Cancel a scheduled task by ID.
1384
- *
1385
- * @param id - Task ID returned by `scheduleTask` or listed by `listScheduledTasks`
1386
- * @returns `true` if the task was found and cancelled
1387
- */
1388
- cancelScheduledTask(id: string): boolean
1389
1107
  /**
1390
1108
  * Cancel the current ongoing operation (send/stream).
1391
1109
  *
@@ -1396,200 +1114,13 @@ export declare class Session {
1396
1114
  */
1397
1115
  cancel(): boolean
1398
1116
  /**
1399
- * Close the session and stop background tasks such as the cron ticker.
1117
+ * Close the session and cancel any active operation.
1400
1118
  *
1401
1119
  * Call this when the session will no longer be used so Node.js can exit
1402
1120
  * cleanly without waiting on session-scoped background workers.
1403
1121
  */
1404
1122
  close(): void
1405
1123
  }
1406
- /**
1407
- * Shared task board for team coordination.
1408
- *
1409
- * Use `Team.taskBoard()` or `TeamRunner.taskBoard()` to access the board.
1410
- */
1411
- export declare class TeamTaskBoard {
1412
- /**
1413
- * Post a new task. Returns the task ID, or null if the board is full.
1414
- *
1415
- * @param description - Task description
1416
- * @param postedBy - Member ID posting the task
1417
- * @param assignTo - Optional member ID to pre-assign the task to
1418
- */
1419
- post(description: string, postedBy: string, assignTo?: string | undefined | null): string | null
1420
- /** Claim the next open or rejected task for a member. */
1421
- claim(memberId: string): TeamTask | null
1422
- /** Mark a task as complete with a result. Returns true if found. */
1423
- complete(taskId: string, result: string): boolean
1424
- /** Approve a task (reviewer action). Returns true if the task was in InReview state. */
1425
- approve(taskId: string): boolean
1426
- /** Reject a task back to open (reviewer action). Returns true if found. */
1427
- reject(taskId: string): boolean
1428
- /** Get a task by ID. */
1429
- get(taskId: string): TeamTask | null
1430
- /** Get all tasks with the given status. */
1431
- byStatus(status: TeamTaskStatus): Array<TeamTask>
1432
- /** Get all tasks assigned to a member. */
1433
- byAssignee(memberId: string): Array<TeamTask>
1434
- /** Summary stats as `{ open, inProgress, inReview, done, rejected }`. */
1435
- stats(): any
1436
- /** Total number of tasks on the board. */
1437
- get len(): number
1438
- /** True if the board has no tasks. */
1439
- get isEmpty(): boolean
1440
- }
1441
- /**
1442
- * Multi-agent team coordinator.
1443
- *
1444
- * Create the team, add members, then pass it to `TeamRunner` to execute.
1445
- *
1446
- * @example
1447
- * ```js
1448
- * const team = new Team("refactor-auth");
1449
- * team.addMember("lead", TeamRole.Lead);
1450
- * team.addMember("worker-1", TeamRole.Worker);
1451
- * team.addMember("reviewer", TeamRole.Reviewer);
1452
- * const runner = new TeamRunner(team);
1453
- * runner.bindSession("lead", leadSession);
1454
- * const result = await runner.runUntilDone("Refactor the auth module");
1455
- * ```
1456
- */
1457
- export declare class Team {
1458
- /**
1459
- * Create a new team.
1460
- *
1461
- * @param name - Team name
1462
- * @param config - Optional `TeamConfig` (uses defaults if omitted)
1463
- */
1464
- constructor(name: string, config?: TeamConfig | undefined | null)
1465
- /**
1466
- * Add a member to the team.
1467
- *
1468
- * @param memberId - Unique member identifier
1469
- * @param role - TeamRole: Lead, Worker, or Reviewer
1470
- */
1471
- addMember(memberId: string, role: TeamRole): void
1472
- /** Remove a member. Returns true if the member was found. */
1473
- removeMember(memberId: string): boolean
1474
- /** Number of registered members. */
1475
- get memberCount(): number
1476
- /** Get the shared task board for inspection. */
1477
- taskBoard(): TeamTaskBoard
1478
- }
1479
- /**
1480
- * Binds an agent team to real `Session` executors and runs the workflow.
1481
- *
1482
- * The team object is consumed on construction.
1483
- *
1484
- * @example
1485
- * ```js
1486
- * const runner = new TeamRunner(team);
1487
- * runner.bindSession("lead", leadSession);
1488
- * runner.bindSession("worker-1", workerSession);
1489
- * runner.bindSession("reviewer", reviewerSession);
1490
- * const result = await runner.runUntilDone("Build the feature");
1491
- * for (const task of result.doneTasks) {
1492
- * console.log(task.id, task.result);
1493
- * }
1494
- * ```
1495
- */
1496
- export declare class TeamRunner {
1497
- /**
1498
- * Create a runner from a team.
1499
- *
1500
- * The team is consumed: further calls on the original `Team` object will throw.
1501
- */
1502
- constructor(team: Team)
1503
- /**
1504
- * Create a runner with a default agent context.
1505
- *
1506
- * Stores the agent, workspace, and agent directories once so that
1507
- * subsequent calls to `addLead`, `addWorker`, and `addReviewer` do not
1508
- * need to repeat them.
1509
- *
1510
- * @param agent - The `Agent` to create sessions from
1511
- * @param workspace - Path to the workspace directory shared by all members
1512
- * @param agentDirs - Directories to scan for agent definition files
1513
- */
1514
- static create(agent: Agent, workspace: string, agentDirs?: Array<string> | undefined | null): TeamRunner
1515
- /**
1516
- * Add a Lead member bound to the named agent definition.
1517
- *
1518
- * Requires the runner to have been created with `TeamRunner.create(...)`.
1519
- * The member ID is fixed to `"lead"`.
1520
- *
1521
- * Unset fields in `opts` inherit from the agent definition, then from the
1522
- * `Agent` base config (see `TeamMemberOptions` for the full inheritance chain).
1523
- *
1524
- * @param agentName - Name of the agent definition (e.g. `"orchestrator"`)
1525
- * @param opts - Optional per-member overrides; omit to use agent definition defaults
1526
- */
1527
- addLead(agentName: string, opts?: TeamMemberOptions | undefined | null): void
1528
- /**
1529
- * Add a Worker member bound to the named agent definition.
1530
- *
1531
- * Requires the runner to have been created with `TeamRunner.create(...)`.
1532
- * Member IDs are auto-generated as `"worker-1"`, `"worker-2"`, etc.
1533
- * Call this multiple times to add concurrent workers.
1534
- *
1535
- * Set `opts.workspace` to a git worktree path to give each worker an
1536
- * isolated filesystem so concurrent writes do not conflict.
1537
- * Unset fields inherit from the agent definition, then from the `Agent`
1538
- * base config (see `TeamMemberOptions` for the full inheritance chain).
1539
- *
1540
- * @param agentName - Name of the agent definition (e.g. `"general"`)
1541
- * @param opts - Optional per-member overrides; omit to use agent definition defaults
1542
- */
1543
- addWorker(agentName: string, opts?: TeamMemberOptions | undefined | null): void
1544
- /**
1545
- * Add a Reviewer member bound to the named agent definition.
1546
- *
1547
- * Requires the runner to have been created with `TeamRunner.create(...)`.
1548
- * The member ID is fixed to `"reviewer"`.
1549
- *
1550
- * Unset fields in `opts` inherit from the agent definition, then from the
1551
- * `Agent` base config (see `TeamMemberOptions` for the full inheritance chain).
1552
- *
1553
- * @param agentName - Name of the agent definition (e.g. `"reviewer"`)
1554
- * @param opts - Optional per-member overrides; omit to use agent definition defaults
1555
- */
1556
- addReviewer(agentName: string, opts?: TeamMemberOptions | undefined | null): void
1557
- /**
1558
- * Bind a `Session` to a team member.
1559
- *
1560
- * @param memberId - The member ID (must match a member added to the team)
1561
- * @param session - A `Session` object from `Agent.session()`
1562
- */
1563
- bindSession(memberId: string, session: Session): void
1564
- /**
1565
- * Bind a team member to a named agent definition.
1566
- *
1567
- * Loads the agent by name from built-in agents and optionally from
1568
- * additional directories, then creates and binds a session with the
1569
- * agent's permissions, system prompt, model, and step limit applied.
1570
- *
1571
- * @param memberId - The member ID (must match a member added to the team)
1572
- * @param agent - The `Agent` to create the session from
1573
- * @param workspace - Path to the workspace directory
1574
- * @param agentName - Name of the agent to load (e.g. "explore", "general")
1575
- * @param agentDirs - Optional directories to scan for agent files
1576
- */
1577
- bindAgent(memberId: string, agent: Agent, workspace: string, agentName: string, agentDirs?: Array<string> | undefined | null): void
1578
- /** Get the shared task board for inspection. */
1579
- taskBoard(): TeamTaskBoard
1580
- /**
1581
- * Run the Lead → Worker → Reviewer workflow until all tasks are done.
1582
- *
1583
- * 1. The Lead member decomposes `goal` into tasks via JSON response.
1584
- * 2. Worker members concurrently claim and execute tasks.
1585
- * 3. The Reviewer member approves or rejects completed tasks.
1586
- * 4. Rejected tasks re-enter the work queue for retry.
1587
- *
1588
- * @param goal - High-level goal to decompose and execute
1589
- * @returns `TeamRunResult` with `doneTasks`, `rejectedTasks`, and `rounds`
1590
- */
1591
- runUntilDone(goal: string): Promise<TeamRunResult>
1592
- }
1593
1124
  /** SubAgent handle for control and monitoring. */
1594
1125
  export declare class SubAgentHandle {
1595
1126
  /** Get SubAgent ID */
@@ -1614,36 +1145,21 @@ export declare class SubAgentEventStream {
1614
1145
  /** Receive the next sub-agent event, or `null` on timeout / end-of-stream. */
1615
1146
  recv(timeoutMs?: number | undefined | null): Promise<any | null>
1616
1147
  }
1617
- /** Agent Orchestrator for main-sub agent coordination. */
1148
+ /**
1149
+ * Advanced orchestrator for explicit SubAgent lifecycle control.
1150
+ *
1151
+ * Routine multi-agent work should use `task` / `parallelTask` delegation; this
1152
+ * API is for monitoring and controlling long-running SubAgents directly.
1153
+ */
1618
1154
  export declare class Orchestrator {
1619
1155
  /**
1620
1156
  * Create a new orchestrator.
1621
1157
  *
1622
- * @param agent - Optional `Agent` instance. When provided, spawned SubAgents
1623
- * execute real LLM calls using the agent's configuration.
1624
- * When omitted, SubAgents run in placeholder mode.
1158
+ * @param agent - `Agent` instance used to execute spawned SubAgents.
1625
1159
  */
1626
- static create(agent?: Agent | undefined | null): Orchestrator
1160
+ static create(agent: Agent): Orchestrator
1627
1161
  /** Spawn a new SubAgent */
1628
1162
  spawnSubagent(config: SubAgentConfig): SubAgentHandle
1629
- /**
1630
- * Spawn a subagent from a unified `AgentSlot` declaration.
1631
- *
1632
- * Convenience wrapper over `spawnSubagent` that accepts the unified slot
1633
- * type. The `role` field is ignored for standalone spawning — use
1634
- * `runTeam` for team-based workflows.
1635
- */
1636
- spawn(slot: AgentSlot): SubAgentHandle
1637
- /**
1638
- * Run a goal through a Lead → Worker → Reviewer team built from AgentSlots.
1639
- *
1640
- * Requires `Orchestrator.create(agent)` mode — returns an error if no backing
1641
- * Agent is configured. Each slot's `role` field determines its position in the
1642
- * team; slots without a role default to Worker.
1643
- *
1644
- * @returns `TeamRunResult` with `doneTasks`, `rejectedTasks`, and `rounds`.
1645
- */
1646
- runTeam(goal: string, workspace: string, slots: Array<AgentSlot>): Promise<TeamRunResult>
1647
1163
  /** Get active SubAgent count */
1648
1164
  activeCount(): number
1649
1165
  /** Get all SubAgent information list */
@@ -1662,17 +1178,4 @@ export declare class Orchestrator {
1662
1178
  cancelSubagent(id: string): void
1663
1179
  /** Wait for all SubAgents to complete */
1664
1180
  waitAll(): void
1665
- /**
1666
- * Return any external tasks currently waiting for the given SubAgent.
1667
- *
1668
- * Returns an empty array when no tasks are pending or the SubAgent is not found.
1669
- */
1670
- pendingExternalTasksFor(subagentId: string): Array<PendingExternalTask>
1671
- /**
1672
- * Complete an external task dispatched to a remote worker.
1673
- *
1674
- * Returns `true` if the task was found and completed, `false` if no
1675
- * session with the given `subagent_id` is currently registered.
1676
- */
1677
- completeExternalTask(subagentId: string, taskId: string, result: ExternalTaskResult): boolean
1678
1181
  }
package/index.js CHANGED
@@ -310,8 +310,9 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { EventStream, FileMemoryStore, FileSessionStore, MemorySessionStore, DefaultSecurityProvider, SkillPlugin, StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport, Agent, Session, builtinSkills, TeamRole, TeamTaskStatus, TeamTaskBoard, Team, TeamRunner, BrowserBackend, SubAgentHandle, SubAgentEventStream, Orchestrator } = nativeBinding
313
+ const { formatVerificationSummary, EventStream, FileMemoryStore, FileSessionStore, MemorySessionStore, DefaultSecurityProvider, SkillPlugin, StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport, Agent, Session, builtinSkills, BrowserBackend, SubAgentHandle, SubAgentEventStream, Orchestrator } = nativeBinding
314
314
 
315
+ module.exports.formatVerificationSummary = formatVerificationSummary
315
316
  module.exports.EventStream = EventStream
316
317
  module.exports.FileMemoryStore = FileMemoryStore
317
318
  module.exports.FileSessionStore = FileSessionStore
@@ -325,11 +326,6 @@ module.exports.UnixSocketTransport = UnixSocketTransport
325
326
  module.exports.Agent = Agent
326
327
  module.exports.Session = Session
327
328
  module.exports.builtinSkills = builtinSkills
328
- module.exports.TeamRole = TeamRole
329
- module.exports.TeamTaskStatus = TeamTaskStatus
330
- module.exports.TeamTaskBoard = TeamTaskBoard
331
- module.exports.Team = Team
332
- module.exports.TeamRunner = TeamRunner
333
329
  module.exports.BrowserBackend = BrowserBackend
334
330
  module.exports.SubAgentHandle = SubAgentHandle
335
331
  module.exports.SubAgentEventStream = SubAgentEventStream
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@a3s-lab/code",
3
- "version": "1.11.0",
4
- "description": "A3S Code - Native AI coding agent library for Node.js",
3
+ "version": "2.0.0",
4
+ "description": "A3S Code - Native Node.js bindings for the coding-agent runtime",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "napi": {
@@ -38,17 +38,16 @@
38
38
  "prepublishOnly": "napi prepublish -t npm",
39
39
  "test": "node test.mjs",
40
40
  "test:helpers": "node test-helpers.mjs",
41
- "test:agentic-search-locators": "node examples/test-agentic-search-locators.js",
42
- "test:agentic-search-sampled-lines": "node examples/test-agentic-search-sampled-lines.js",
43
- "test:agentic-parse-llm-blocks": "node examples/test-agentic-parse-llm-blocks.js",
44
- "test:loop": "tsx --tsconfig examples/tsconfig.json examples/test_loop_commands.ts"
41
+ "test:agentic-search-locators": "node examples/search/test-agentic-search-locators.js",
42
+ "test:agentic-search-sampled-lines": "node examples/search/test-agentic-search-sampled-lines.js",
43
+ "test:agentic-parse-llm-blocks": "node examples/search/test-agentic-parse-llm-blocks.js"
45
44
  },
46
45
  "optionalDependencies": {
47
- "@a3s-lab/code-darwin-arm64": "1.11.0",
48
- "@a3s-lab/code-linux-x64-gnu": "1.11.0",
49
- "@a3s-lab/code-linux-x64-musl": "1.11.0",
50
- "@a3s-lab/code-linux-arm64-gnu": "1.11.0",
51
- "@a3s-lab/code-linux-arm64-musl": "1.11.0",
52
- "@a3s-lab/code-win32-x64-msvc": "1.11.0"
46
+ "@a3s-lab/code-darwin-arm64": "2.0.0",
47
+ "@a3s-lab/code-linux-x64-gnu": "2.0.0",
48
+ "@a3s-lab/code-linux-x64-musl": "2.0.0",
49
+ "@a3s-lab/code-linux-arm64-gnu": "2.0.0",
50
+ "@a3s-lab/code-linux-arm64-musl": "2.0.0",
51
+ "@a3s-lab/code-win32-x64-msvc": "2.0.0"
53
52
  }
54
- }
53
+ }