@a3s-lab/code 2.2.0 → 2.4.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 +139 -3
- package/index.d.ts +215 -42
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -17,7 +17,9 @@ async function main() {
|
|
|
17
17
|
const agent = await Agent.create('agent.acl')
|
|
18
18
|
const session = agent.session('/my-project')
|
|
19
19
|
|
|
20
|
-
const result = await session.send(
|
|
20
|
+
const result = await session.send({
|
|
21
|
+
prompt: 'What files handle authentication?',
|
|
22
|
+
})
|
|
21
23
|
console.log(result.text)
|
|
22
24
|
}
|
|
23
25
|
|
|
@@ -68,18 +70,35 @@ When streaming, `task_updated` is the authoritative task-list snapshot for UI
|
|
|
68
70
|
rendering. `planning_end` contains the initial plan, while `step_start` and
|
|
69
71
|
`step_end` are fine-grained progress events.
|
|
70
72
|
|
|
73
|
+
## Durable Request Shape
|
|
74
|
+
|
|
75
|
+
`send(...)` and `stream(...)` accept either a prompt string or an object-shaped
|
|
76
|
+
request. Use the object shape when the call needs history, attachments, or
|
|
77
|
+
future request options:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
const result = await session.send({
|
|
81
|
+
prompt: 'Explain the auth module',
|
|
82
|
+
history: previousMessages,
|
|
83
|
+
attachments: [{ data: imageBuffer, mediaType: 'image/png' }],
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
`sendRequest(...)`, `streamRequest(...)`, and attachment-specific positional
|
|
88
|
+
overloads remain for compatibility.
|
|
89
|
+
|
|
71
90
|
## Delegation And Tool Introspection
|
|
72
91
|
|
|
73
92
|
The SDK exposes the core `task` / `parallel_task` tools as direct helpers:
|
|
74
93
|
|
|
75
94
|
```js
|
|
76
|
-
await session.
|
|
95
|
+
await session.task({
|
|
77
96
|
agent: 'explore',
|
|
78
97
|
description: 'Find auth entry points',
|
|
79
98
|
prompt: 'Inspect the repository and summarize the auth-related files.',
|
|
80
99
|
})
|
|
81
100
|
|
|
82
|
-
await session.
|
|
101
|
+
await session.tasks([
|
|
83
102
|
{ agent: 'explore', description: 'Find tests', prompt: 'Locate auth tests.' },
|
|
84
103
|
{ agent: 'verification', description: 'Check risk', prompt: 'Review auth edge cases.' },
|
|
85
104
|
])
|
|
@@ -88,6 +107,122 @@ await session.parallelTask([
|
|
|
88
107
|
Use `session.toolNames()` for names and `session.toolDefinitions()` when a UI
|
|
89
108
|
needs the full model-visible schemas.
|
|
90
109
|
|
|
110
|
+
## Object-Shaped Direct Tools
|
|
111
|
+
|
|
112
|
+
New direct helpers use option objects when the command can grow over time:
|
|
113
|
+
|
|
114
|
+
```js
|
|
115
|
+
await session.git({ command: 'status' })
|
|
116
|
+
await session.git({ command: 'worktree', subcommand: 'list' })
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The older positional `git(...)` overload and `gitCommand(...)` remain for
|
|
120
|
+
compatibility.
|
|
121
|
+
|
|
122
|
+
## Disposable Worker Agents
|
|
123
|
+
|
|
124
|
+
A3S Code treats subagents as cattle, not pets: define reproducible worker specs
|
|
125
|
+
in code, register them on a session, and delegate by name through the existing
|
|
126
|
+
`task` tool.
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
const session = agent.session('/my-project', {
|
|
130
|
+
workerAgents: [
|
|
131
|
+
{
|
|
132
|
+
name: 'frontend-cow',
|
|
133
|
+
description: 'Small verified frontend fixes',
|
|
134
|
+
kind: 'implementer',
|
|
135
|
+
model: 'openai/gpt-4o',
|
|
136
|
+
maxSteps: 24,
|
|
137
|
+
prompt: 'Keep patches focused and run the narrowest relevant check.',
|
|
138
|
+
},
|
|
139
|
+
{ name: 'review-cow', description: 'Adversarial review', kind: 'reviewer' },
|
|
140
|
+
],
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
await session.task({
|
|
144
|
+
agent: 'frontend-cow',
|
|
145
|
+
description: 'Fix admin chat loading state',
|
|
146
|
+
prompt: 'Find and fix the loading-state regression, then summarize verification.',
|
|
147
|
+
})
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
You can also register workers after the session is running:
|
|
151
|
+
|
|
152
|
+
```js
|
|
153
|
+
session.registerWorkerAgent({
|
|
154
|
+
name: 'verify-cow',
|
|
155
|
+
description: 'Run focused checks without editing files',
|
|
156
|
+
kind: 'verifier',
|
|
157
|
+
})
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
For a worker as the top-level actor, use `agent.sessionForWorker(workspace, spec)`.
|
|
161
|
+
|
|
162
|
+
## AHP-Supervised Advice
|
|
163
|
+
|
|
164
|
+
Background advice belongs in the host or AHP harness. A3S Code forwards hooks,
|
|
165
|
+
run lifecycle events, task updates, verification summaries, confirmations, idle
|
|
166
|
+
signals, and errors; the harness decides when to surface suggestions, add host
|
|
167
|
+
context, or propose PTC scripts.
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
const session = agent.session('/my-project', {
|
|
171
|
+
ahpTransport: new HttpTransport('http://localhost:8080/ahp'),
|
|
172
|
+
})
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
PTC scripts proposed by an AHP harness are not executed automatically. Run them
|
|
176
|
+
explicitly through `session.program(...)` so existing permission, confirmation,
|
|
177
|
+
and trace policies stay in force.
|
|
178
|
+
|
|
179
|
+
## Live MCP Servers
|
|
180
|
+
|
|
181
|
+
Prefer the object-shaped MCP API for new code. It keeps transport-specific
|
|
182
|
+
fields grouped and leaves room for OAuth/env/timeout extensions:
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
await session.addMcp({
|
|
186
|
+
name: 'github',
|
|
187
|
+
transport: {
|
|
188
|
+
type: 'stdio',
|
|
189
|
+
command: 'npx',
|
|
190
|
+
args: ['-y', '@modelcontextprotocol/server-github'],
|
|
191
|
+
},
|
|
192
|
+
env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN ?? '' },
|
|
193
|
+
timeoutMs: 30000,
|
|
194
|
+
})
|
|
195
|
+
|
|
196
|
+
console.log(await session.mcps())
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
The positional `addMcpServer(...)` overload and longer
|
|
200
|
+
`addMcpServerConfig(...)` alias remain for compatibility.
|
|
201
|
+
|
|
202
|
+
## HITL Confirmations
|
|
203
|
+
|
|
204
|
+
Use `permissionPolicy` to decide which tools ask, then `confirmationPolicy` to
|
|
205
|
+
control confirmation runtime behavior such as timeout and YOLO lanes.
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
const session = agent.session('.', {
|
|
209
|
+
permissionPolicy: { ask: ['bash*'], defaultDecision: 'allow' },
|
|
210
|
+
confirmationPolicy: {
|
|
211
|
+
enabled: true,
|
|
212
|
+
defaultTimeoutMs: 30000,
|
|
213
|
+
timeoutAction: 'reject',
|
|
214
|
+
yoloLanes: ['query'],
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
for (const pending of await session.pendingConfirmations()) {
|
|
219
|
+
await session.confirmToolUse(pending.toolId, true, 'Reviewed')
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
For the streaming event-driven loop used by UIs, see
|
|
224
|
+
`examples/streaming/hitl_confirmation_loop.ts`.
|
|
225
|
+
|
|
91
226
|
## Run Replay
|
|
92
227
|
|
|
93
228
|
Each `send(...)` or `stream(...)` call records a run snapshot and replayable
|
|
@@ -99,6 +234,7 @@ await session.send('Fix the failing test')
|
|
|
99
234
|
const [run] = await session.runs()
|
|
100
235
|
console.log(run.id, run.status)
|
|
101
236
|
console.log(await session.runEvents(run.id))
|
|
237
|
+
console.log(await session.activeTools())
|
|
102
238
|
```
|
|
103
239
|
|
|
104
240
|
Use `session.currentRun()` while a stream is active to inspect the current run.
|
package/index.d.ts
CHANGED
|
@@ -56,21 +56,6 @@ export interface AgentResult {
|
|
|
56
56
|
verificationSummaryText: string
|
|
57
57
|
}
|
|
58
58
|
export declare function formatVerificationSummary(summary: any): string
|
|
59
|
-
/**
|
|
60
|
-
* Result of a `/btw` ephemeral side question.
|
|
61
|
-
*
|
|
62
|
-
* The answer is never added to conversation history.
|
|
63
|
-
*/
|
|
64
|
-
export interface BtwResult {
|
|
65
|
-
/** The original question. */
|
|
66
|
-
question: string
|
|
67
|
-
/** The LLM's answer. */
|
|
68
|
-
answer: string
|
|
69
|
-
/** Token usage for this ephemeral call. */
|
|
70
|
-
promptTokens: number
|
|
71
|
-
completionTokens: number
|
|
72
|
-
totalTokens: number
|
|
73
|
-
}
|
|
74
59
|
export interface AgentEvent {
|
|
75
60
|
type: string
|
|
76
61
|
text?: string
|
|
@@ -84,10 +69,6 @@ export interface AgentEvent {
|
|
|
84
69
|
totalTokens?: number
|
|
85
70
|
verificationSummaryJson?: string
|
|
86
71
|
verificationSummaryText?: string
|
|
87
|
-
/** For btw_answer event: the original question */
|
|
88
|
-
question?: string
|
|
89
|
-
/** For btw_answer event: the LLM's answer */
|
|
90
|
-
answer?: string
|
|
91
72
|
/** Extra data for events that don't map to standard fields (JSON-encoded) */
|
|
92
73
|
data?: string
|
|
93
74
|
}
|
|
@@ -130,6 +111,27 @@ export interface DelegateTaskOptions {
|
|
|
130
111
|
background?: boolean
|
|
131
112
|
maxSteps?: number
|
|
132
113
|
}
|
|
114
|
+
/** Object-shaped request for `Session.sendRequest` and `Session.streamRequest`. */
|
|
115
|
+
export interface SessionRequestOptions {
|
|
116
|
+
prompt: string
|
|
117
|
+
history?: Array<MessageObject>
|
|
118
|
+
attachments?: Array<AttachmentObject>
|
|
119
|
+
}
|
|
120
|
+
export interface GitCommandOptions {
|
|
121
|
+
command: string
|
|
122
|
+
subcommand?: string
|
|
123
|
+
name?: string
|
|
124
|
+
path?: string
|
|
125
|
+
newBranch?: boolean
|
|
126
|
+
base?: string
|
|
127
|
+
force?: boolean
|
|
128
|
+
maxCount?: number
|
|
129
|
+
message?: string
|
|
130
|
+
includeUntracked?: boolean
|
|
131
|
+
target?: string
|
|
132
|
+
ref?: string
|
|
133
|
+
reference?: string
|
|
134
|
+
}
|
|
133
135
|
/** Parameters for the web_search tool. */
|
|
134
136
|
export interface JsWebSearchParams {
|
|
135
137
|
/** The search query. */
|
|
@@ -199,6 +201,67 @@ export interface PermissionPolicy {
|
|
|
199
201
|
/** Whether this policy is enabled. Defaults to true. */
|
|
200
202
|
enabled?: boolean
|
|
201
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Reproducible recipe for a disposable worker/subagent.
|
|
206
|
+
*
|
|
207
|
+
* This is the Node.js cattle-mode interface: define workers in data, pass them
|
|
208
|
+
* to SessionOptions.workerAgents, Agent.sessionForWorker(), or
|
|
209
|
+
* Session.registerWorkerAgent(). The Rust core compiles each spec into the
|
|
210
|
+
* normal delegated-agent runtime definition.
|
|
211
|
+
*/
|
|
212
|
+
export interface WorkerAgentSpec {
|
|
213
|
+
/** Stable worker name used by task delegation. */
|
|
214
|
+
name: string
|
|
215
|
+
/** Human-readable worker purpose. */
|
|
216
|
+
description: string
|
|
217
|
+
/** Preset role: "read_only", "planner", "implementer", "verifier", "reviewer", or "custom". */
|
|
218
|
+
kind?: string
|
|
219
|
+
/** Hide from UI lists while allowing explicit delegation. */
|
|
220
|
+
hidden?: boolean
|
|
221
|
+
/** Optional permission policy override. */
|
|
222
|
+
permissions?: PermissionPolicy
|
|
223
|
+
/** Optional model override in "provider/model" format. */
|
|
224
|
+
model?: string
|
|
225
|
+
/** Optional worker-specific prompt. */
|
|
226
|
+
prompt?: string
|
|
227
|
+
/** Maximum execution steps/tool rounds. */
|
|
228
|
+
maxSteps?: number
|
|
229
|
+
}
|
|
230
|
+
export interface AgentDefinition {
|
|
231
|
+
name: string
|
|
232
|
+
description: string
|
|
233
|
+
native: boolean
|
|
234
|
+
hidden: boolean
|
|
235
|
+
model?: string
|
|
236
|
+
prompt?: string
|
|
237
|
+
maxSteps?: number
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* HITL confirmation policy configuration.
|
|
241
|
+
*
|
|
242
|
+
* Controls the runtime behavior of Human-in-the-Loop confirmation flow.
|
|
243
|
+
*/
|
|
244
|
+
export interface ConfirmationPolicy {
|
|
245
|
+
/** Whether HITL is enabled (default: false, all tools auto-approved). */
|
|
246
|
+
enabled?: boolean
|
|
247
|
+
/** Default timeout in milliseconds (default: 30000 = 30s). */
|
|
248
|
+
defaultTimeoutMs?: number
|
|
249
|
+
/** Action to take on timeout: "reject" or "auto_approve" (default: "reject"). */
|
|
250
|
+
timeoutAction?: string
|
|
251
|
+
/** Lanes that should auto-approve without confirmation: "control", "query", "execute", or "generate". */
|
|
252
|
+
yoloLanes?: Array<string>
|
|
253
|
+
}
|
|
254
|
+
/** Snapshot of a pending HITL tool confirmation. */
|
|
255
|
+
export interface PendingConfirmation {
|
|
256
|
+
/** Tool call ID to pass to `confirmToolUse`. */
|
|
257
|
+
toolId: string
|
|
258
|
+
/** Tool name awaiting confirmation. */
|
|
259
|
+
toolName: string
|
|
260
|
+
/** Tool arguments for display in a confirmation UI. */
|
|
261
|
+
args: any
|
|
262
|
+
/** Milliseconds remaining before the confirmation times out. */
|
|
263
|
+
remainingMs: number
|
|
264
|
+
}
|
|
202
265
|
export interface SessionOptions {
|
|
203
266
|
/** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */
|
|
204
267
|
model?: string
|
|
@@ -208,6 +271,8 @@ export interface SessionOptions {
|
|
|
208
271
|
skillDirs?: Array<string>
|
|
209
272
|
/** Extra directories to scan for agent files. */
|
|
210
273
|
agentDirs?: Array<string>
|
|
274
|
+
/** Reproducible disposable workers to register for task delegation. */
|
|
275
|
+
workerAgents?: Array<WorkerAgentSpec>
|
|
211
276
|
/**
|
|
212
277
|
* Optional advanced queue configuration for explicit external/hybrid lane dispatch.
|
|
213
278
|
*
|
|
@@ -342,6 +407,37 @@ export interface SessionOptions {
|
|
|
342
407
|
* ```
|
|
343
408
|
*/
|
|
344
409
|
ahpTransport?: JsAhpTransport
|
|
410
|
+
/**
|
|
411
|
+
* HITL confirmation policy configuration.
|
|
412
|
+
*
|
|
413
|
+
* Pass a confirmation policy to enable Human-in-the-Loop confirmation for tool execution.
|
|
414
|
+
* When enabled, tools that require confirmation will emit ConfirmationRequired events
|
|
415
|
+
* and wait for user approval before executing.
|
|
416
|
+
*
|
|
417
|
+
* ```js
|
|
418
|
+
* agent.session('.', {
|
|
419
|
+
* confirmationPolicy: {
|
|
420
|
+
* enabled: true,
|
|
421
|
+
* defaultTimeoutMs: 30000,
|
|
422
|
+
* timeoutAction: 'reject'
|
|
423
|
+
* }
|
|
424
|
+
* });
|
|
425
|
+
* ```
|
|
426
|
+
*/
|
|
427
|
+
confirmationPolicy?: ConfirmationPolicy
|
|
428
|
+
/**
|
|
429
|
+
* Maximum execution time in milliseconds.
|
|
430
|
+
*
|
|
431
|
+
* When set, the execution loop will abort if it exceeds this duration.
|
|
432
|
+
* This prevents runaway executions and excessive API costs.
|
|
433
|
+
*
|
|
434
|
+
* ```js
|
|
435
|
+
* agent.session('.', {
|
|
436
|
+
* maxExecutionTimeMs: 300000 // 5 minutes
|
|
437
|
+
* });
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
maxExecutionTimeMs?: number
|
|
345
441
|
}
|
|
346
442
|
/** A single message in conversation history. */
|
|
347
443
|
export interface MessageObject {
|
|
@@ -733,40 +829,45 @@ export declare class Agent {
|
|
|
733
829
|
* @param options - Optional session overrides layered on top of the agent definition
|
|
734
830
|
*/
|
|
735
831
|
sessionForAgent(workspace: string, agentName: string, agentDirs?: Array<string> | undefined | null, options?: SessionOptions | undefined | null): Session
|
|
736
|
-
}
|
|
737
|
-
/** Workspace-bound session. All LLM and tool operations happen here. */
|
|
738
|
-
export declare class Session {
|
|
739
832
|
/**
|
|
740
|
-
*
|
|
833
|
+
* Create a session pre-configured from a disposable worker spec.
|
|
741
834
|
*
|
|
742
|
-
*
|
|
743
|
-
*
|
|
835
|
+
* This avoids writing temporary agent files for one-off cattle workers.
|
|
836
|
+
*
|
|
837
|
+
* @param workspace - Path to the workspace directory
|
|
838
|
+
* @param worker - Worker spec to compile into an agent definition
|
|
839
|
+
* @param options - Optional session overrides layered on top of the worker definition
|
|
744
840
|
*/
|
|
745
|
-
|
|
841
|
+
sessionForWorker(workspace: string, worker: WorkerAgentSpec, options?: SessionOptions | undefined | null): Session
|
|
842
|
+
}
|
|
843
|
+
/** Workspace-bound session. All LLM and tool operations happen here. */
|
|
844
|
+
export declare class Session {
|
|
746
845
|
/**
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
* Takes a read-only snapshot of the current history, makes a separate LLM
|
|
750
|
-
* call with no tools, and returns the answer. History is never modified.
|
|
751
|
-
*
|
|
752
|
-
* Safe to call concurrently with an ongoing `send()` — the snapshot only
|
|
753
|
-
* acquires a read lock on the internal history.
|
|
846
|
+
* Send a prompt or request and wait for the complete response.
|
|
754
847
|
*
|
|
755
|
-
*
|
|
756
|
-
*
|
|
848
|
+
* `send("prompt")` is the compact prompt-first form. `send({ prompt,
|
|
849
|
+
* history, attachments })` is the compact object-shaped form for growth.
|
|
757
850
|
*/
|
|
758
|
-
|
|
851
|
+
send(request: string | SessionRequestOptions, history?: Array<MessageObject> | null): Promise<AgentResult>
|
|
852
|
+
/** Alias for `send(...)` with a name that matches run/replay terminology. */
|
|
853
|
+
run(request: string | SessionRequestOptions, history?: Array<MessageObject> | null): Promise<AgentResult>
|
|
759
854
|
/**
|
|
760
|
-
* Send a prompt and get a streaming event iterator.
|
|
855
|
+
* Send a prompt or request and get a streaming event iterator.
|
|
761
856
|
*
|
|
762
857
|
* Returns an `EventStream`. Use `for await (const event of stream)` or call `.next()` manually.
|
|
763
858
|
* When `history` is omitted, the session history and verification evidence are
|
|
764
859
|
* updated after the stream completes. Supplying `history` keeps the stream isolated.
|
|
860
|
+
*/
|
|
861
|
+
stream(request: string | SessionRequestOptions, history?: Array<MessageObject> | null): Promise<EventStream>
|
|
862
|
+
/**
|
|
863
|
+
* Send a request using the long-lived object-shaped API.
|
|
765
864
|
*
|
|
766
|
-
*
|
|
767
|
-
*
|
|
865
|
+
* Prefer this for new integrations when the call may need history,
|
|
866
|
+
* attachments, or future request options.
|
|
768
867
|
*/
|
|
769
|
-
|
|
868
|
+
sendRequest(request: SessionRequestOptions): Promise<AgentResult>
|
|
869
|
+
/** Stream a request using the long-lived object-shaped API. */
|
|
870
|
+
streamRequest(request: SessionRequestOptions): Promise<EventStream>
|
|
770
871
|
/**
|
|
771
872
|
* Send a prompt with image attachments and wait for the complete response.
|
|
772
873
|
*
|
|
@@ -796,13 +897,19 @@ export declare class Session {
|
|
|
796
897
|
runEvents(runId: string): Promise<any>
|
|
797
898
|
/** Return the currently running operation, or null when idle. */
|
|
798
899
|
currentRun(): Promise<any>
|
|
900
|
+
/** Return active tool calls observed for the currently running operation. */
|
|
901
|
+
activeTools(): Promise<any>
|
|
799
902
|
/** Cancel a specific run only if it is still the active run. */
|
|
800
903
|
cancelRun(runId: string): Promise<boolean>
|
|
801
904
|
/** Execute a tool by name, bypassing the LLM. */
|
|
802
905
|
tool(name: string, args: any): Promise<ToolResult>
|
|
803
906
|
/** Delegate a bounded task to a child agent through the built-in `task` tool. */
|
|
907
|
+
task(options: DelegateTaskOptions): Promise<ToolResult>
|
|
908
|
+
/** Delegate a bounded task to a child agent through the built-in `task` tool. */
|
|
804
909
|
delegateTask(options: DelegateTaskOptions): Promise<ToolResult>
|
|
805
910
|
/** Execute several delegated child-agent tasks concurrently through `parallel_task`. */
|
|
911
|
+
tasks(tasks: DelegateTaskOptions[]): Promise<ToolResult>
|
|
912
|
+
/** Execute several delegated child-agent tasks concurrently through `parallel_task`. */
|
|
806
913
|
parallelTask(tasks: DelegateTaskOptions[]): Promise<ToolResult>
|
|
807
914
|
/** Run a bounded JavaScript script through the embedded QuickJS `program` tool. */
|
|
808
915
|
program(options: ProgramScriptOptions): Promise<ToolResult>
|
|
@@ -816,8 +923,24 @@ export declare class Session {
|
|
|
816
923
|
grep(pattern: string): Promise<string>
|
|
817
924
|
/** Search the web using multiple search engines. */
|
|
818
925
|
webSearch(params: JsWebSearchParams): Promise<ToolResult>
|
|
819
|
-
/**
|
|
820
|
-
|
|
926
|
+
/**
|
|
927
|
+
* Execute a git command.
|
|
928
|
+
*
|
|
929
|
+
* Prefer `git({ command: "status" })`; positional arguments remain for
|
|
930
|
+
* compatibility.
|
|
931
|
+
*/
|
|
932
|
+
git(command: string | GitCommandOptions, subcommand?: string | null, name?: string | null, path?: string | null, newBranch?: boolean | null, base?: string | null, force?: boolean | null, maxCount?: number | null, message?: string | null, includeUntracked?: boolean | null, target?: string | null, reference?: string | null): Promise<ToolResult>
|
|
933
|
+
/**
|
|
934
|
+
* Execute a git command with an object-shaped API.
|
|
935
|
+
*
|
|
936
|
+
* Preferred over the positional `git(...)` overload for new callers.
|
|
937
|
+
*
|
|
938
|
+
* ```js
|
|
939
|
+
* await session.gitCommand({ command: 'status' })
|
|
940
|
+
* await session.gitCommand({ command: 'worktree', subcommand: 'list' })
|
|
941
|
+
* ```
|
|
942
|
+
*/
|
|
943
|
+
gitCommand(args: GitCommandOptions): Promise<ToolResult>
|
|
821
944
|
/** Check if this session has an advanced lane queue configured. */
|
|
822
945
|
hasQueue(): boolean
|
|
823
946
|
/**
|
|
@@ -837,6 +960,19 @@ export declare class Session {
|
|
|
837
960
|
completeExternalTask(taskId: string, result: ExternalTaskResult): Promise<boolean>
|
|
838
961
|
/** Get pending external queue tasks. */
|
|
839
962
|
pendingExternalTasks(): Promise<any>
|
|
963
|
+
/** Return pending HITL tool confirmations for this session. */
|
|
964
|
+
pendingConfirmations(): Promise<Array<PendingConfirmation>>
|
|
965
|
+
/**
|
|
966
|
+
* Resolve a pending HITL tool confirmation.
|
|
967
|
+
*
|
|
968
|
+
* @param toolId - Tool call ID from a `confirmation_required` event.
|
|
969
|
+
* @param approved - Whether the tool execution should proceed.
|
|
970
|
+
* @param reason - Optional human-readable reason for audit/UI display.
|
|
971
|
+
* @returns true if a pending confirmation was found and completed.
|
|
972
|
+
*/
|
|
973
|
+
confirmToolUse(toolId: string, approved: boolean, reason?: string | undefined | null): Promise<boolean>
|
|
974
|
+
/** Cancel all pending HITL confirmations for this session. */
|
|
975
|
+
cancelConfirmations(): Promise<number>
|
|
840
976
|
/** Get optional queue statistics. */
|
|
841
977
|
queueStats(): Promise<QueueStats>
|
|
842
978
|
/** Return compact execution trace events recorded for this session. */
|
|
@@ -878,6 +1014,23 @@ export declare class Session {
|
|
|
878
1014
|
* @returns Number of tools registered from the server
|
|
879
1015
|
*/
|
|
880
1016
|
addMcpServer(name: string, transport?: 'stdio' | 'http' | 'streamable-http', command?: string | undefined | null, args?: Array<string> | undefined | null, url?: string | undefined | null, headers?: Record<string, string> | undefined | null, env?: Record<string, string> | undefined | null, timeoutMs?: number | undefined | null): Promise<number>
|
|
1017
|
+
/**
|
|
1018
|
+
* Add an MCP server with a typed object config.
|
|
1019
|
+
*
|
|
1020
|
+
* Preferred over the positional overload for new SDK callers.
|
|
1021
|
+
*
|
|
1022
|
+
* ```js
|
|
1023
|
+
* await session.addMcpServerConfig({
|
|
1024
|
+
* name: 'github',
|
|
1025
|
+
* transport: { type: 'stdio', command: 'npx', args: ['-y', '@modelcontextprotocol/server-github'] },
|
|
1026
|
+
* env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN },
|
|
1027
|
+
* timeoutMs: 30000,
|
|
1028
|
+
* })
|
|
1029
|
+
* ```
|
|
1030
|
+
*/
|
|
1031
|
+
addMcpServerConfig(config: McpServerConfig): Promise<number>
|
|
1032
|
+
/** Add an MCP server with the compact object-shaped API. */
|
|
1033
|
+
addMcp(config: McpServerConfig): Promise<number>
|
|
881
1034
|
/**
|
|
882
1035
|
* Dynamically register agent definitions from a directory into the live session.
|
|
883
1036
|
*
|
|
@@ -890,18 +1043,38 @@ export declare class Session {
|
|
|
890
1043
|
* @returns Number of agents successfully loaded
|
|
891
1044
|
*/
|
|
892
1045
|
registerAgentDir(path: string): number
|
|
1046
|
+
/**
|
|
1047
|
+
* Register a disposable worker agent into the live session.
|
|
1048
|
+
*
|
|
1049
|
+
* The worker is immediately callable through the model-visible `task` tool.
|
|
1050
|
+
*
|
|
1051
|
+
* @param worker - Worker spec to register
|
|
1052
|
+
* @returns Compiled agent definition
|
|
1053
|
+
*/
|
|
1054
|
+
registerWorkerAgent(worker: WorkerAgentSpec): AgentDefinition
|
|
1055
|
+
/**
|
|
1056
|
+
* Register many disposable workers into the live session.
|
|
1057
|
+
*
|
|
1058
|
+
* @param workers - Worker specs to register
|
|
1059
|
+
* @returns Compiled agent definitions
|
|
1060
|
+
*/
|
|
1061
|
+
registerWorkerAgents(workers: Array<WorkerAgentSpec>): Array<AgentDefinition>
|
|
893
1062
|
/**
|
|
894
1063
|
* Disconnect and unregister an MCP server, removing its tools from the session.
|
|
895
1064
|
*
|
|
896
1065
|
* @param name - Server name (must match the name used in addMcpServer)
|
|
897
1066
|
*/
|
|
898
1067
|
removeMcpServer(name: string): Promise<void>
|
|
1068
|
+
/** Remove an MCP server with the compact API. */
|
|
1069
|
+
removeMcp(name: string): Promise<void>
|
|
899
1070
|
/**
|
|
900
1071
|
* Return connection status for all MCP servers registered on this session.
|
|
901
1072
|
*
|
|
902
1073
|
* @returns Array of `{ name, connected, toolCount }` entries
|
|
903
1074
|
*/
|
|
904
1075
|
mcpStatus(): Promise<Array<McpServerStatusEntry>>
|
|
1076
|
+
/** Return MCP server status with the compact API. */
|
|
1077
|
+
mcps(): Promise<Array<McpServerStatusEntry>>
|
|
905
1078
|
/**
|
|
906
1079
|
* Return the names of all tools currently registered on this session.
|
|
907
1080
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a3s-lab/code",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A3S Code - Native Node.js bindings for the coding-agent runtime",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"test:helpers": "node test-helpers.mjs"
|
|
41
41
|
},
|
|
42
42
|
"optionalDependencies": {
|
|
43
|
-
"@a3s-lab/code-darwin-arm64": "2.
|
|
44
|
-
"@a3s-lab/code-linux-x64-gnu": "2.
|
|
45
|
-
"@a3s-lab/code-linux-x64-musl": "2.
|
|
46
|
-
"@a3s-lab/code-linux-arm64-gnu": "2.
|
|
47
|
-
"@a3s-lab/code-linux-arm64-musl": "2.
|
|
48
|
-
"@a3s-lab/code-win32-x64-msvc": "2.
|
|
43
|
+
"@a3s-lab/code-darwin-arm64": "2.4.0",
|
|
44
|
+
"@a3s-lab/code-linux-x64-gnu": "2.4.0",
|
|
45
|
+
"@a3s-lab/code-linux-x64-musl": "2.4.0",
|
|
46
|
+
"@a3s-lab/code-linux-arm64-gnu": "2.4.0",
|
|
47
|
+
"@a3s-lab/code-linux-arm64-musl": "2.4.0",
|
|
48
|
+
"@a3s-lab/code-win32-x64-msvc": "2.4.0"
|
|
49
49
|
}
|
|
50
50
|
}
|