@a3s-lab/code 1.11.0 → 2.0.1

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 +27 -1
  2. package/index.d.ts +104 -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?')
@@ -28,6 +28,32 @@ main().catch(console.error)
28
28
 
29
29
  `session.tool(...)` returns a `ToolResult` enriched with parsed metadata helpers.
30
30
 
31
+ ## Programmatic Tool Calling
32
+
33
+ `session.program(...)` runs a bounded JavaScript script in the embedded QuickJS
34
+ runtime. It is the SDK-friendly wrapper around the core `program` tool.
35
+
36
+ ```js
37
+ const result = await session.program({
38
+ source: `
39
+ export default async function run(ctx, inputs) {
40
+ const hits = await ctx.grep(inputs.query, { glob: '*.ts' })
41
+ const files = await ctx.glob('src/**/*.ts')
42
+ return { hits, files: files.slice(0, 10) }
43
+ }
44
+ `,
45
+ inputs: { query: 'PermissionPolicy' },
46
+ allowedTools: ['grep', 'glob'],
47
+ limits: { timeoutMs: 30000, maxToolCalls: 20, maxOutputBytes: 65536 },
48
+ })
49
+
50
+ console.log(result.output)
51
+ ```
52
+
53
+ Omit `allowedTools` to allow every registered session tool except `program`.
54
+ Scripts can also be loaded from workspace-relative `.js` or `.mjs` files with
55
+ `{ path: 'scripts/ptc/search.js' }`.
56
+
31
57
  ### Agentic Parse LLM Blocks
32
58
 
33
59
  When `agentic_parse` runs with a query, the SDK exposes the exact structured
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
@@ -191,6 +108,26 @@ export interface ToolResult {
191
108
  /** Convenience JSON view of `metadata.document_runtime` when present. */
192
109
  documentRuntimeJson?: string
193
110
  }
111
+ export interface ProgramScriptLimits {
112
+ /** Wall-clock timeout for the embedded QuickJS script. */
113
+ timeoutMs?: number
114
+ /** Maximum number of ctx tool calls the script may perform. */
115
+ maxToolCalls?: number
116
+ /** Maximum bytes returned in the program result output. */
117
+ maxOutputBytes?: number
118
+ }
119
+ export interface ProgramScriptOptions {
120
+ /** Inline JavaScript source. Define `async function run(ctx, inputs)` or export it as default. */
121
+ source?: string
122
+ /** Workspace-relative `.js` or `.mjs` script path. */
123
+ path?: string
124
+ /** JSON-serializable inputs passed to `run(ctx, inputs)`. */
125
+ inputs?: any
126
+ /** Optional tool allow-list. Defaults to every registered tool except `program`. */
127
+ allowedTools?: Array<string>
128
+ /** Execution limits for the script. */
129
+ limits?: ProgramScriptLimits
130
+ }
194
131
  /** Parameters for the web_search tool. */
195
132
  export interface JsWebSearchParams {
196
133
  /** The search query. */
@@ -262,6 +199,18 @@ export interface JsAhpTransport {
262
199
  authToken?: string
263
200
  path?: string
264
201
  }
202
+ export interface PermissionPolicy {
203
+ /** Tool invocation patterns that are always denied first. */
204
+ deny?: Array<string>
205
+ /** Tool invocation patterns that are auto-approved. */
206
+ allow?: Array<string>
207
+ /** Tool invocation patterns that always require confirmation. */
208
+ ask?: Array<string>
209
+ /** Default decision when no rule matches: "allow", "deny", or "ask". */
210
+ defaultDecision?: string
211
+ /** Whether this policy is enabled. Defaults to true. */
212
+ enabled?: boolean
213
+ }
265
214
  export interface SessionOptions {
266
215
  /** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */
267
216
  model?: string
@@ -271,10 +220,14 @@ export interface SessionOptions {
271
220
  skillDirs?: Array<string>
272
221
  /** Extra directories to scan for agent files. */
273
222
  agentDirs?: Array<string>
274
- /** Optional queue configuration for lane-based tool execution. */
223
+ /**
224
+ * Optional advanced queue configuration for explicit external/hybrid lane dispatch.
225
+ *
226
+ * Ordinary sessions are queue-free unless this is provided.
227
+ */
275
228
  queueConfig?: SessionQueueConfig
276
- /** Allow all tools without HITL confirmation (default: false). */
277
- permissive?: boolean
229
+ /** Explicit permission policy for tool execution. */
230
+ permissionPolicy?: PermissionPolicy
278
231
  /** Enable planning mode (default: false). */
279
232
  planning?: boolean
280
233
  /** Enable goal tracking (default: false). */
@@ -431,7 +384,12 @@ export interface AttachmentObject {
431
384
  /** MIME type (e.g., "image/jpeg", "image/png"). */
432
385
  mediaType: string
433
386
  }
434
- /** Configuration for the session lane queue. */
387
+ /**
388
+ * Configuration for the optional advanced session lane queue.
389
+ *
390
+ * Ordinary sessions do not initialize queue infrastructure. Use this only for
391
+ * explicit external/hybrid dispatch, priority experiments, or operational integrations.
392
+ */
435
393
  export interface SessionQueueConfig {
436
394
  /** Max concurrency for Query lane (default: 4). */
437
395
  queryConcurrency?: number
@@ -510,28 +468,13 @@ export interface CommandContext {
510
468
  }
511
469
  /** Metadata about a registered slash command. */
512
470
  export interface CommandInfo {
513
- /** Command name without the leading `/` (e.g., `"loop"`, `"help"`) */
471
+ /** Command name without the leading `/` (e.g., `"help"`, `"model"`) */
514
472
  name: string
515
473
  /** Short description shown in `/help` */
516
474
  description: string
517
- /** Optional usage hint (e.g., `"/loop [interval] <prompt> [every <interval>]"`) */
475
+ /** Optional usage hint (e.g., `"/model <provider/model>"`) */
518
476
  usage?: string
519
477
  }
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
478
  /** Matcher for filtering which events trigger a hook. */
536
479
  export interface HookMatcherObject {
537
480
  /** Match specific tool name (exact match) */
@@ -569,118 +512,6 @@ export interface SkillInfo {
569
512
  * Each entry has `name`, `description`, and `kind` (instruction, tool, or agent).
570
513
  */
571
514
  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
515
  /** Configuration for a search engine. */
685
516
  export interface SearchEngineConfig {
686
517
  enabled: boolean
@@ -700,6 +531,7 @@ export interface HeadlessConfig {
700
531
  browserPath?: string
701
532
  maxTabs?: number
702
533
  launchArgs?: Array<string>
534
+ proxyUrl?: string
703
535
  }
704
536
  /** Health monitor configuration for search engines. */
705
537
  export interface SearchHealthConfig {
@@ -713,7 +545,7 @@ export interface SearchConfig {
713
545
  engines: Record<string, SearchEngineConfig>
714
546
  headless?: HeadlessConfig
715
547
  }
716
- /** SubAgent configuration for orchestrator. */
548
+ /** SubAgent configuration for the advanced orchestrator control plane. */
717
549
  export interface SubAgentConfig {
718
550
  /** Agent type (general, explore, plan, etc.) */
719
551
  agentType: string
@@ -721,10 +553,6 @@ export interface SubAgentConfig {
721
553
  description: string
722
554
  /** Execution prompt */
723
555
  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
556
  /** Maximum execution steps */
729
557
  maxSteps?: number
730
558
  /** Execution timeout (milliseconds) */
@@ -737,45 +565,6 @@ export interface SubAgentConfig {
737
565
  agentDirs?: Array<string>
738
566
  /** Extra directories to scan for skill definition files */
739
567
  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
568
  }
780
569
  /** SubAgent activity type */
781
570
  export interface SubAgentActivity {
@@ -805,17 +594,6 @@ export interface SubAgentStateEntry {
805
594
  id: string
806
595
  state: string
807
596
  }
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
597
  /** Streaming event iterator. Use `for await (const event of stream)` or call `.next()` manually. */
820
598
  export declare class EventStream {
821
599
  /**
@@ -994,10 +772,10 @@ export declare class Agent {
994
772
  /**
995
773
  * Create an Agent from a config file path or inline config string.
996
774
  *
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.
775
+ * Accepts ACL-compatible config files (.acl) or inline config strings.
776
+ * JSON config is not supported.
999
777
  *
1000
- * @param configSource - Path to a config file (.hcl/.json/.acl), or inline config string
778
+ * @param configSource - Path to a config file (.acl), or inline config string
1001
779
  */
1002
780
  static create(configSource: string): Promise<Agent>
1003
781
  /**
@@ -1071,6 +849,8 @@ export declare class Session {
1071
849
  * Send a prompt and get a streaming event iterator.
1072
850
  *
1073
851
  * Returns an `EventStream`. Use `for await (const event of stream)` or call `.next()` manually.
852
+ * When `history` is omitted, the session history and verification evidence are
853
+ * updated after the stream completes. Supplying `history` keeps the stream isolated.
1074
854
  *
1075
855
  * @param prompt - The prompt to send
1076
856
  * @param history - Optional conversation history
@@ -1087,6 +867,9 @@ export declare class Session {
1087
867
  /**
1088
868
  * Stream a prompt with image attachments.
1089
869
  *
870
+ * When `history` is omitted, the session history and verification evidence are
871
+ * updated after the stream completes. Supplying `history` keeps the stream isolated.
872
+ *
1090
873
  * @param prompt - The prompt to send
1091
874
  * @param attachments - Array of `{ data: Buffer, mediaType: string }`
1092
875
  * @param history - Optional conversation history
@@ -1096,19 +879,8 @@ export declare class Session {
1096
879
  history(): Array<MessageObject>
1097
880
  /** Execute a tool by name, bypassing the LLM. */
1098
881
  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>
882
+ /** Run a bounded JavaScript script through the embedded QuickJS `program` tool. */
883
+ program(options: ProgramScriptOptions): Promise<ToolResult>
1112
884
  /** Read a file from the workspace. */
1113
885
  readFile(path: string): Promise<string>
1114
886
  /** Execute a bash command in the workspace. */
@@ -1121,48 +893,40 @@ export declare class Session {
1121
893
  webSearch(params: JsWebSearchParams): Promise<ToolResult>
1122
894
  /** Execute a git command (status, log, branch, checkout, diff, stash, remote, worktree). */
1123
895
  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. */
896
+ /** Check if this session has an advanced lane queue configured. */
1125
897
  hasQueue(): boolean
1126
898
  /**
1127
- * Configure a lane's handler mode.
899
+ * Configure a lane's handler mode for explicit external/hybrid dispatch.
1128
900
  *
1129
901
  * @param lane - "control", "query", "execute", or "generate"
1130
902
  * @param config - { mode: "internal"|"external"|"hybrid", timeoutMs?: number }
1131
903
  */
1132
904
  setLaneHandler(lane: string, config: LaneHandlerConfig): Promise<void>
1133
905
  /**
1134
- * Complete an external task by ID.
906
+ * Complete an external queue task by ID.
1135
907
  *
1136
908
  * @param taskId - The task identifier
1137
909
  * @param result - { success: boolean, result?: any, error?: string }
1138
910
  * @returns true if found, false if not found
1139
911
  */
1140
912
  completeExternalTask(taskId: string, result: ExternalTaskResult): Promise<boolean>
1141
- /** Get pending external tasks. */
913
+ /** Get pending external queue tasks. */
1142
914
  pendingExternalTasks(): Promise<any>
1143
- /** Get queue statistics. */
915
+ /** Get optional queue statistics. */
1144
916
  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. */
917
+ /** Return compact execution trace events recorded for this session. */
918
+ traceEvents(): any
919
+ /** Return structured verification reports recorded for this session. */
920
+ verificationReports(): any
921
+ /** Return a structured verification summary for this session. */
922
+ verificationSummary(): any
923
+ /** Return a concise human-readable verification summary for this session. */
924
+ verificationSummaryText(): string
925
+ /** Run verification commands and return a structured verification report. */
926
+ verifyCommands(subject: string, commands: Array<VerificationCommand>): Promise<any>
927
+ /** Return project-aware verification command presets for this workspace. */
928
+ verificationPresets(): any
929
+ /** Get dead letters from the optional queue's DLQ. */
1166
930
  deadLetters(): Promise<any>
1167
931
  /**
1168
932
  * Get a detailed metrics snapshot from the queue.
@@ -1362,30 +1126,6 @@ export declare class Session {
1362
1126
  * @returns Array of CommandInfo objects sorted by name
1363
1127
  */
1364
1128
  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
1129
  /**
1390
1130
  * Cancel the current ongoing operation (send/stream).
1391
1131
  *
@@ -1396,200 +1136,13 @@ export declare class Session {
1396
1136
  */
1397
1137
  cancel(): boolean
1398
1138
  /**
1399
- * Close the session and stop background tasks such as the cron ticker.
1139
+ * Close the session and cancel any active operation.
1400
1140
  *
1401
1141
  * Call this when the session will no longer be used so Node.js can exit
1402
1142
  * cleanly without waiting on session-scoped background workers.
1403
1143
  */
1404
1144
  close(): void
1405
1145
  }
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
1146
  /** SubAgent handle for control and monitoring. */
1594
1147
  export declare class SubAgentHandle {
1595
1148
  /** Get SubAgent ID */
@@ -1614,36 +1167,21 @@ export declare class SubAgentEventStream {
1614
1167
  /** Receive the next sub-agent event, or `null` on timeout / end-of-stream. */
1615
1168
  recv(timeoutMs?: number | undefined | null): Promise<any | null>
1616
1169
  }
1617
- /** Agent Orchestrator for main-sub agent coordination. */
1170
+ /**
1171
+ * Advanced orchestrator for explicit SubAgent lifecycle control.
1172
+ *
1173
+ * Routine multi-agent work should use `task` / `parallelTask` delegation; this
1174
+ * API is for monitoring and controlling long-running SubAgents directly.
1175
+ */
1618
1176
  export declare class Orchestrator {
1619
1177
  /**
1620
1178
  * Create a new orchestrator.
1621
1179
  *
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.
1180
+ * @param agent - `Agent` instance used to execute spawned SubAgents.
1625
1181
  */
1626
- static create(agent?: Agent | undefined | null): Orchestrator
1182
+ static create(agent: Agent): Orchestrator
1627
1183
  /** Spawn a new SubAgent */
1628
1184
  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
1185
  /** Get active SubAgent count */
1648
1186
  activeCount(): number
1649
1187
  /** Get all SubAgent information list */
@@ -1662,17 +1200,4 @@ export declare class Orchestrator {
1662
1200
  cancelSubagent(id: string): void
1663
1201
  /** Wait for all SubAgents to complete */
1664
1202
  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
1203
  }
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.1",
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.1",
47
+ "@a3s-lab/code-linux-x64-gnu": "2.0.1",
48
+ "@a3s-lab/code-linux-x64-musl": "2.0.1",
49
+ "@a3s-lab/code-linux-arm64-gnu": "2.0.1",
50
+ "@a3s-lab/code-linux-arm64-musl": "2.0.1",
51
+ "@a3s-lab/code-win32-x64-msvc": "2.0.1"
53
52
  }
54
- }
53
+ }