@a3s-lab/code 3.1.0 → 3.2.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/generated.d.ts ADDED
@@ -0,0 +1,1512 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ /** AHP event type. */
7
+ export interface AhpEventType {
8
+ /** Event type string: "handshake", "pre_action", "post_action", "pre_prompt", "post_response", "session_start", "session_end", "error", "query", "heartbeat", "idle" */
9
+ eventType: string
10
+ }
11
+ /** A factual memory item. */
12
+ export interface AhpFact {
13
+ content: string
14
+ source: string
15
+ confidence: number
16
+ }
17
+ /** Memory state summary. */
18
+ export interface AhpMemorySummary {
19
+ memoryType: string
20
+ totalItems: number
21
+ recentTopics: Array<string>
22
+ }
23
+ /** Session statistics. */
24
+ export interface AhpSessionStats {
25
+ totalActions: number
26
+ totalTokens: number
27
+ durationMs: number
28
+ errorCount: number
29
+ }
30
+ /** Decision from harness for idle events. */
31
+ export interface AhpIdleDecision {
32
+ /** Decision string: "allow" or "defer" */
33
+ decision: string
34
+ /** Reason if deferred */
35
+ reason?: string
36
+ }
37
+ /** Context passed with AHP events. */
38
+ export interface AhpEventContext {
39
+ recentFacts?: Array<AhpFact>
40
+ memorySummary?: AhpMemorySummary
41
+ sessionStats?: AhpSessionStats
42
+ currentTask?: string
43
+ capabilities?: Record<string, string>
44
+ }
45
+ export interface AgentResult {
46
+ text: string
47
+ toolCallsCount: number
48
+ promptTokens: number
49
+ completionTokens: number
50
+ totalTokens: number
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
59
+ export interface AgentEvent {
60
+ type: string
61
+ text?: string
62
+ toolName?: string
63
+ toolId?: string
64
+ toolOutput?: string
65
+ exitCode?: number
66
+ turn?: number
67
+ prompt?: string
68
+ error?: string
69
+ totalTokens?: number
70
+ verificationSummaryJson?: string
71
+ verificationSummaryText?: string
72
+ /** Extra data for events that don't map to standard fields (JSON-encoded) */
73
+ data?: string
74
+ /**
75
+ * Structured discriminant for tool failures on `tool_end` events
76
+ * (JSON-encoded with a `type` field). `None` on success or untyped
77
+ * failure. Lets streaming consumers branch on the failure kind
78
+ * without scanning `tool_output`.
79
+ */
80
+ errorKindJson?: string
81
+ }
82
+ export interface VerificationCommand {
83
+ id: string
84
+ kind: string
85
+ description: string
86
+ command: string
87
+ required?: boolean
88
+ timeoutMs?: number
89
+ }
90
+ export interface ToolResult {
91
+ name: string
92
+ output: string
93
+ exitCode: number
94
+ /** Raw JSON-encoded tool metadata returned by the Rust core API. */
95
+ metadataJson?: string
96
+ /** Convenience JSON view of `metadata.document_runtime` when present. */
97
+ documentRuntimeJson?: string
98
+ /**
99
+ * Structured discriminant for tool failures, JSON-encoded with a
100
+ * `type` field on the top level — e.g.
101
+ * `{"type":"version_conflict","path":"doc.md","expected":"etag-1","actual":"etag-2"}`.
102
+ * `None` on success or untyped failure. SDK callers parse it to
103
+ * branch on the failure kind without scanning the `output` string.
104
+ */
105
+ errorKindJson?: string
106
+ }
107
+ /** Execution limits for `Session.program`. */
108
+ export interface ProgramScriptLimits {
109
+ timeoutMs?: number
110
+ maxToolCalls?: number
111
+ maxOutputBytes?: number
112
+ }
113
+ /** Options for `Session.program`. */
114
+ export interface ProgramScriptOptions {
115
+ source?: string
116
+ path?: string
117
+ inputs?: any
118
+ allowedTools?: Array<string>
119
+ limits?: ProgramScriptLimits
120
+ }
121
+ /** Options for `Session.delegateTask`. */
122
+ export interface DelegateTaskOptions {
123
+ agent: string
124
+ description: string
125
+ prompt: string
126
+ background?: boolean
127
+ maxSteps?: number
128
+ }
129
+ /** Object-shaped request for `Session.sendRequest` and `Session.streamRequest`. */
130
+ export interface SessionRequestOptions {
131
+ prompt: string
132
+ history?: Array<MessageObject>
133
+ attachments?: Array<AttachmentObject>
134
+ }
135
+ export interface GitCommandOptions {
136
+ command: string
137
+ subcommand?: string
138
+ name?: string
139
+ path?: string
140
+ newBranch?: boolean
141
+ base?: string
142
+ force?: boolean
143
+ maxCount?: number
144
+ message?: string
145
+ includeUntracked?: boolean
146
+ target?: string
147
+ ref?: string
148
+ reference?: string
149
+ }
150
+ /** Parameters for the web_search tool. */
151
+ export interface JsWebSearchParams {
152
+ /** The search query. */
153
+ query: string
154
+ /** List of search engines to use. */
155
+ engines?: Array<string>
156
+ /** Maximum number of results to return (default: 10, max: 50). */
157
+ limit?: number
158
+ /** Search timeout in seconds (default: 10, max: 60). */
159
+ timeout?: number
160
+ /** Proxy URL (e.g., http://127.0.0.1:8080 or socks5://127.0.0.1:1080). */
161
+ proxy?: string
162
+ /** Output format: "text" or "json". */
163
+ format?: string
164
+ }
165
+ /** Result of a single `EventStream.next()` call. */
166
+ export interface NextResult {
167
+ value?: AgentEvent
168
+ done: boolean
169
+ }
170
+ /**
171
+ * An inline skill registered programmatically (no file required).
172
+ *
173
+ * Use `kind: "instruction"` for prompt injections or `kind: "persona"` to
174
+ * replace the default role section of the system prompt.
175
+ */
176
+ export interface InlineSkill {
177
+ /** Unique skill name (kebab-case recommended, e.g. "type-hints"). */
178
+ name: string
179
+ /** Skill kind: `"instruction"` or `"persona"`. */
180
+ kind: string
181
+ /** Markdown content for the skill. */
182
+ content: string
183
+ }
184
+ export interface JsMemoryStore {
185
+ backend: string
186
+ dir?: string
187
+ }
188
+ export interface JsSessionStore {
189
+ backend: string
190
+ dir?: string
191
+ }
192
+ export interface JsSecurityProvider {
193
+ kind: string
194
+ }
195
+ export interface JsWorkspaceBackend {
196
+ kind: string
197
+ root?: string
198
+ s3?: JsS3BackendConfig
199
+ }
200
+ /**
201
+ * Configuration for an S3-compatible workspace backend.
202
+ *
203
+ * Use this with [`S3WorkspaceBackend`] to point a session's built-in file
204
+ * tools at any S3-compatible endpoint (AWS S3, MinIO, RustFS, R2, etc.).
205
+ * `endpoint` is optional — omit it to use the AWS default. `prefix` is
206
+ * the logical workspace root inside the bucket; every workspace path
207
+ * becomes `<prefix>/<path>` when sent to S3.
208
+ */
209
+ export interface JsS3BackendConfig {
210
+ /**
211
+ * Optional S3 endpoint URL. Omit for AWS S3 (the SDK will compute it
212
+ * from `region`). Set to `https://...` for MinIO / RustFS / R2 / etc.
213
+ */
214
+ endpoint?: string
215
+ /** AWS region. Defaults to `us-east-1` when omitted. */
216
+ region?: string
217
+ /** Static access key. Use `sessionToken` together when STS-issued. */
218
+ accessKeyId: string
219
+ secretAccessKey: string
220
+ sessionToken?: string
221
+ /** Bucket name. */
222
+ bucket: string
223
+ /**
224
+ * Logical workspace prefix inside the bucket (without leading/trailing
225
+ * slashes). Use `""` to make the bucket root the workspace.
226
+ */
227
+ prefix: string
228
+ /** `true` for MinIO / RustFS / most non-AWS endpoints; `false` for AWS S3. */
229
+ forcePathStyle?: boolean
230
+ /**
231
+ * Maximum bytes a single `read` may return. The backend rejects any
232
+ * response with `Content-Length` greater than this without buffering
233
+ * the body. Defaults to 10 MiB on the Rust side when omitted.
234
+ */
235
+ maxReadBytes?: number
236
+ /**
237
+ * Enable degraded `grep` / `glob` against this S3 backend. Off by
238
+ * default — object storage has no native search, so the only viable
239
+ * strategy is `LIST` + `GET` + regex, which can be slow and expensive.
240
+ */
241
+ searchEnabled?: boolean
242
+ /**
243
+ * Upper bound on objects considered per `grep` / `glob` call. Defaults
244
+ * to 500 on the Rust side. Ignored when `searchEnabled` is `false`.
245
+ */
246
+ maxObjectsScanned?: number
247
+ /**
248
+ * Per-object body-size ceiling for `grep` downloads. Larger objects are
249
+ * skipped (debug-traced). Defaults to 1 MiB on the Rust side. Ignored
250
+ * when `searchEnabled` is `false`.
251
+ */
252
+ maxGrepBytesPerObject?: number
253
+ /**
254
+ * Concurrent object downloads during `grep`. Defaults to 8 on the
255
+ * Rust side. Set lower when the gitserver / S3 endpoint rate-limits
256
+ * aggressively; set higher when latency dominates. Ignored when
257
+ * `searchEnabled` is `false`.
258
+ */
259
+ searchConcurrency?: number
260
+ }
261
+ /**
262
+ * Configuration for a [`RemoteGitBackend`] — an HTTP/JSON client that
263
+ * brings the `git` tool to non-local workspaces (S3, future container /
264
+ * DFS).
265
+ *
266
+ * Pass alongside `workspaceBackend` on a session to attach remote git
267
+ * on top of any filesystem backend. The protocol is specified in the
268
+ * repository RFC `apps/docs/content/docs/en/code/rfcs/workspace-remote-git.mdx`.
269
+ */
270
+ export interface JsRemoteGitBackendConfig {
271
+ /**
272
+ * Base URL of the gitserver, no trailing slash. The client builds
273
+ * `{baseUrl}/v1/repos/{repoId}/git/{op}` per the RFC.
274
+ */
275
+ baseUrl: string
276
+ /**
277
+ * Opaque repository identifier, URL-safe. Negotiated out of band
278
+ * with the gitserver operator.
279
+ */
280
+ repoId: string
281
+ /**
282
+ * Bearer token sent as `Authorization: Bearer <token>`. Required in
283
+ * production; omitting it emits a `tracing::warn!` and is only safe
284
+ * on a trusted localhost gitserver.
285
+ */
286
+ bearerToken?: string
287
+ /**
288
+ * mTLS client certificate path (PEM). When set together with
289
+ * `clientKeyPem`, the backend reads both files at construction and
290
+ * configures mTLS on the HTTP client. Setting only one of the pair
291
+ * errors at construction.
292
+ */
293
+ clientCertPem?: string
294
+ /**
295
+ * mTLS client private key path (PEM). PKCS#8 format expected for the
296
+ * `rustls-tls` backend. See `clientCertPem`.
297
+ */
298
+ clientKeyPem?: string
299
+ /** Per-call HTTP timeout in milliseconds. Defaults to 30 000. */
300
+ requestTimeoutMs?: number
301
+ /** Client-side cap on `diff` response bytes. Defaults to 1 MiB. */
302
+ maxDiffBytes?: number
303
+ /** Client-side cap on `log` `max_count`. Defaults to 200. */
304
+ maxLogEntries?: number
305
+ }
306
+ /**
307
+ * Union type for AHP transport configuration.
308
+ * Accepts any of: StdioTransport, HttpTransport, WebSocketTransport, UnixSocketTransport.
309
+ */
310
+ export interface JsAhpTransport {
311
+ kind: string
312
+ program?: string
313
+ args?: Array<string>
314
+ url?: string
315
+ authToken?: string
316
+ path?: string
317
+ }
318
+ export interface PermissionPolicy {
319
+ /** Tool invocation patterns that are always denied first. */
320
+ deny?: Array<string>
321
+ /** Tool invocation patterns that are auto-approved. */
322
+ allow?: Array<string>
323
+ /** Tool invocation patterns that always require confirmation. */
324
+ ask?: Array<string>
325
+ /** Default decision when no rule matches: "allow", "deny", or "ask". */
326
+ defaultDecision?: string
327
+ /** Whether this policy is enabled. Defaults to true. */
328
+ enabled?: boolean
329
+ }
330
+ /**
331
+ * Reproducible recipe for a disposable worker/subagent.
332
+ *
333
+ * This is the Node.js cattle-mode interface: define workers in data, pass them
334
+ * to SessionOptions.workerAgents, Agent.sessionForWorker(), or
335
+ * Session.registerWorkerAgent(). The Rust core compiles each spec into the
336
+ * normal delegated-agent runtime definition.
337
+ */
338
+ export interface WorkerAgentSpec {
339
+ /** Stable worker name used by task delegation. */
340
+ name: string
341
+ /** Human-readable worker purpose. */
342
+ description: string
343
+ /** Preset role: "read_only", "planner", "implementer", "verifier", "reviewer", or "custom". */
344
+ kind?: string
345
+ /** Hide from UI lists while allowing explicit delegation. */
346
+ hidden?: boolean
347
+ /** Optional permission policy override. */
348
+ permissions?: PermissionPolicy
349
+ /** Optional model override in "provider/model" format. */
350
+ model?: string
351
+ /** Optional worker-specific prompt. */
352
+ prompt?: string
353
+ /** Maximum execution steps/tool rounds. */
354
+ maxSteps?: number
355
+ /** How child runs resolve Ask decisions: "auto_approve" (default), "deny_on_ask", or "inherit_parent". */
356
+ confirmationInheritance?: string
357
+ }
358
+ export interface AgentDefinition {
359
+ name: string
360
+ description: string
361
+ native: boolean
362
+ hidden: boolean
363
+ model?: string
364
+ prompt?: string
365
+ maxSteps?: number
366
+ /** How child runs resolve Ask decisions: "auto_approve", "deny_on_ask", or "inherit_parent". */
367
+ confirmationInheritance?: string
368
+ }
369
+ /**
370
+ * HITL confirmation policy configuration.
371
+ *
372
+ * Controls the runtime behavior of Human-in-the-Loop confirmation flow.
373
+ */
374
+ export interface ConfirmationPolicy {
375
+ /** Whether HITL is enabled (default: false, all tools auto-approved). */
376
+ enabled?: boolean
377
+ /** Default timeout in milliseconds (default: 30000 = 30s). */
378
+ defaultTimeoutMs?: number
379
+ /** Action to take on timeout: "reject" or "auto_approve" (default: "reject"). */
380
+ timeoutAction?: string
381
+ /** Lanes that should auto-approve without confirmation: "control", "query", "execute", or "generate". */
382
+ yoloLanes?: Array<string>
383
+ }
384
+ /** Snapshot of a pending HITL tool confirmation. */
385
+ export interface PendingConfirmation {
386
+ /** Tool call ID to pass to `confirmToolUse`. */
387
+ toolId: string
388
+ /** Tool name awaiting confirmation. */
389
+ toolName: string
390
+ /** Tool arguments for display in a confirmation UI. */
391
+ args: any
392
+ /** Milliseconds remaining before the confirmation times out. */
393
+ remainingMs: number
394
+ }
395
+ export interface AutoDelegationOptions {
396
+ /** Enable runtime-driven automatic child-agent delegation. */
397
+ enabled?: boolean
398
+ /**
399
+ * Allow automatic delegation to launch multiple child agents in parallel.
400
+ *
401
+ * Manual `parallel_task` calls remain available when this is false.
402
+ */
403
+ autoParallel?: boolean
404
+ /** Minimum local confidence required to auto-delegate a child task. */
405
+ minConfidence?: number
406
+ /** Maximum number of automatic child tasks per user request. */
407
+ maxTasks?: number
408
+ }
409
+ export interface SessionOptions {
410
+ /** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */
411
+ model?: string
412
+ /** Enable built-in skills (4 skills: code-search, code-review, explain-code, find-bugs). */
413
+ builtinSkills?: boolean
414
+ /** Extra directories to scan for skill files (.md with YAML frontmatter). */
415
+ skillDirs?: Array<string>
416
+ /** Extra directories to scan for agent files. */
417
+ agentDirs?: Array<string>
418
+ /** Reproducible disposable workers to register for task delegation. */
419
+ workerAgents?: Array<WorkerAgentSpec>
420
+ /**
421
+ * Optional advanced queue configuration for explicit external/hybrid lane dispatch.
422
+ *
423
+ * Ordinary sessions are queue-free unless this is provided.
424
+ */
425
+ queueConfig?: SessionQueueConfig
426
+ /** Explicit permission policy for tool execution. */
427
+ permissionPolicy?: PermissionPolicy
428
+ /**
429
+ * Explicit planning mode: "auto", "enabled", or "disabled".
430
+ *
431
+ * Prefer this over `planning` when the caller needs an unambiguous SDK contract.
432
+ * If both are set, `planningMode` wins.
433
+ */
434
+ planningMode?: string
435
+ /** Legacy planning shortcut. Omit for auto planning, true to force planning, false to disable. */
436
+ planning?: boolean
437
+ /** Enable goal tracking (default: false). */
438
+ goalTracking?: boolean
439
+ /** Max consecutive parse errors before abort. */
440
+ maxParseRetries?: number
441
+ /** Per-tool execution timeout in milliseconds. */
442
+ toolTimeoutMs?: number
443
+ /** Max LLM API failures before abort. */
444
+ circuitBreakerThreshold?: number
445
+ /** Enable auto-compaction when context window fills up (default: false). */
446
+ autoCompact?: boolean
447
+ /** Context usage threshold (0.0–1.0) to trigger auto-compaction (default: 0.8). */
448
+ autoCompactThreshold?: number
449
+ /** Retention limits for large tool/program artifacts. */
450
+ artifactStoreLimits?: ArtifactStoreLimits
451
+ /**
452
+ * Long-term memory store backend.
453
+ *
454
+ * Pass `new FileMemoryStore("./memory")` for file-based persistence.
455
+ * ```js
456
+ * agent.session('.', { memoryStore: new FileMemoryStore('./memory') });
457
+ * ```
458
+ */
459
+ memoryStore?: JsMemoryStore
460
+ /**
461
+ * Session persistence store backend.
462
+ *
463
+ * Pass `new FileSessionStore("./sessions")` to persist sessions to disk,
464
+ * or `new MemorySessionStore()` for an ephemeral in-process store.
465
+ * ```js
466
+ * agent.session('.', {
467
+ * sessionStore: new FileSessionStore('./sessions'),
468
+ * sessionId: 'my-session',
469
+ * autoSave: true,
470
+ * });
471
+ * ```
472
+ */
473
+ sessionStore?: JsSessionStore
474
+ /**
475
+ * Security provider.
476
+ *
477
+ * Pass `new DefaultSecurityProvider()` to enable input taint tracking and
478
+ * output sanitisation. Omit to disable security (default: no security).
479
+ * ```js
480
+ * agent.session('.', { securityProvider: new DefaultSecurityProvider() });
481
+ * ```
482
+ */
483
+ securityProvider?: JsSecurityProvider
484
+ /**
485
+ * Workspace backend used by built-in tools.
486
+ *
487
+ * Pass `new LocalWorkspaceBackend("/repo")` to explicitly use the local
488
+ * filesystem backend. This option is the SDK surface for future remote,
489
+ * browser, DFS, and container-backed workspace implementations.
490
+ * ```js
491
+ * agent.session('/repo', { workspaceBackend: new LocalWorkspaceBackend('/repo') });
492
+ * ```
493
+ */
494
+ workspaceBackend?: JsWorkspaceBackend
495
+ /**
496
+ * Optional remote git provider. When set, the resulting session attaches
497
+ * a `RemoteGitBackend` on top of `workspaceBackend` so the built-in
498
+ * `git` tool is available even on object-storage workspaces.
499
+ *
500
+ * ```js
501
+ * agent.session('s3://workspace/u1/s1', {
502
+ * workspaceBackend: new S3WorkspaceBackend({ ... }),
503
+ * remoteGit: {
504
+ * baseUrl: 'https://gitserver.internal',
505
+ * repoId: 'u1/s1',
506
+ * bearerToken: token,
507
+ * },
508
+ * });
509
+ * ```
510
+ */
511
+ remoteGit?: JsRemoteGitBackendConfig
512
+ /**
513
+ * Custom role/identity prepended before the core agentic prompt.
514
+ * Example: "You are a senior Python developer specializing in FastAPI."
515
+ */
516
+ role?: string
517
+ /**
518
+ * Custom coding guidelines appended after the core prompt.
519
+ * Example: "Always use type hints. Follow PEP 8."
520
+ */
521
+ guidelines?: string
522
+ /** Custom response style (replaces default Response Format section). */
523
+ responseStyle?: string
524
+ /** Freeform extra instructions appended at the end. */
525
+ extra?: string
526
+ /**
527
+ * Inline skills registered programmatically without needing skill files on disk.
528
+ * Each entry defines an instruction or persona skill injected into the system prompt.
529
+ */
530
+ inlineSkills?: Array<InlineSkill>
531
+ /** Override maximum number of tool-call rounds for this session. */
532
+ maxToolRounds?: number
533
+ /** Override maximum sibling parallel branches for this session. */
534
+ maxParallelTasks?: number
535
+ /** Override automatic child-agent delegation for this session. */
536
+ autoDelegation?: AutoDelegationOptions
537
+ /**
538
+ * Global session-level kill switch for automatic parallel child-agent fan-out.
539
+ *
540
+ * Manual `parallel_task` calls remain available when this is false.
541
+ */
542
+ autoParallel?: boolean
543
+ /**
544
+ * Sampling temperature (0.0–1.0). Overrides the provider default.
545
+ * Only applied when `model` is also set.
546
+ */
547
+ temperature?: number
548
+ /**
549
+ * Extended thinking token budget (e.g. 10_000). Enables chain-of-thought reasoning.
550
+ * Only applied when `model` is also set. Provider must support extended thinking.
551
+ */
552
+ thinkingBudget?: number
553
+ /**
554
+ * Enable continuation injection (default: true).
555
+ * When enabled, the loop injects a follow-up prompt when the LLM stops without completing.
556
+ */
557
+ continuationEnabled?: boolean
558
+ /** Maximum continuation injections per execution (default: 3). */
559
+ maxContinuationTurns?: number
560
+ /**
561
+ * Session ID (auto-generated if not set).
562
+ *
563
+ * Set a stable ID so the session can be saved and resumed later:
564
+ * ```js
565
+ * agent.session('.', { sessionId: 'my-session', sessionStore: new FileSessionStore('./sessions'), autoSave: true });
566
+ * // Later:
567
+ * agent.resumeSession('my-session', { sessionStore: new FileSessionStore('./sessions') });
568
+ * ```
569
+ */
570
+ sessionId?: string
571
+ /** Automatically save the session to the configured store after each turn (default: false). */
572
+ autoSave?: boolean
573
+ /**
574
+ * AHP transport configuration for external agent supervision.
575
+ *
576
+ * Pass an AHP transport instance to enable Agent Harness Protocol supervision.
577
+ * All agent lifecycle events will be forwarded to the harness server.
578
+ *
579
+ * ```js
580
+ * // Stdio transport (local child process)
581
+ * agent.session('.', { ahpTransport: new StdioTransport('python', ['ahp_server.py']) });
582
+ *
583
+ * // HTTP transport (remote server)
584
+ * agent.session('.', { ahpTransport: new HttpTransport('http://localhost:8080/ahp') });
585
+ *
586
+ * // WebSocket transport (bidirectional streaming)
587
+ * agent.session('.', { ahpTransport: new WebSocketTransport('ws://localhost:8080/ahp') });
588
+ *
589
+ * // Unix socket transport (local IPC)
590
+ * agent.session('.', { ahpTransport: new UnixSocketTransport('/tmp/ahp.sock') });
591
+ * ```
592
+ */
593
+ ahpTransport?: JsAhpTransport
594
+ /**
595
+ * HITL confirmation policy configuration.
596
+ *
597
+ * Pass a confirmation policy to enable Human-in-the-Loop confirmation for tool execution.
598
+ * When enabled, tools that require confirmation will emit ConfirmationRequired events
599
+ * and wait for user approval before executing.
600
+ *
601
+ * ```js
602
+ * agent.session('.', {
603
+ * confirmationPolicy: {
604
+ * enabled: true,
605
+ * defaultTimeoutMs: 30000,
606
+ * timeoutAction: 'reject'
607
+ * }
608
+ * });
609
+ * ```
610
+ */
611
+ confirmationPolicy?: ConfirmationPolicy
612
+ /**
613
+ * Maximum execution time in milliseconds.
614
+ *
615
+ * When set, the execution loop will abort if it exceeds this duration.
616
+ * This prevents runaway executions and excessive API costs.
617
+ *
618
+ * ```js
619
+ * agent.session('.', {
620
+ * maxExecutionTimeMs: 300000 // 5 minutes
621
+ * });
622
+ * ```
623
+ */
624
+ maxExecutionTimeMs?: number
625
+ }
626
+ /** Retention limits for large tool/program artifacts. */
627
+ export interface ArtifactStoreLimits {
628
+ /** Maximum number of artifacts retained by a session. */
629
+ maxArtifacts?: number
630
+ /** Maximum total artifact content bytes retained by a session. */
631
+ maxBytes?: number
632
+ }
633
+ /** A single message in conversation history. */
634
+ export interface MessageObject {
635
+ role: string
636
+ content: Array<ContentBlockObject>
637
+ }
638
+ /** A content block within a message. */
639
+ export interface ContentBlockObject {
640
+ type: string
641
+ /** Text content (for "text" blocks). */
642
+ text?: string
643
+ /** Tool use ID (for "tool_use" blocks). */
644
+ id?: string
645
+ /** Tool name (for "tool_use" blocks). */
646
+ name?: string
647
+ /** Tool input (for "tool_use" blocks). */
648
+ input?: any
649
+ /** Tool use ID reference (for "tool_result" blocks). */
650
+ toolUseId?: string
651
+ /** Tool result content (for "tool_result" blocks). */
652
+ resultContent?: string
653
+ /** Whether this is an error result (for "tool_result" blocks). */
654
+ isError?: boolean
655
+ }
656
+ /** An image attachment for multi-modal prompts. */
657
+ export interface AttachmentObject {
658
+ /** Raw image bytes. */
659
+ data: Buffer
660
+ /** MIME type (e.g., "image/jpeg", "image/png"). */
661
+ mediaType: string
662
+ }
663
+ /**
664
+ * Configuration for the optional advanced session lane queue.
665
+ *
666
+ * Ordinary sessions do not initialize queue infrastructure. Use this only for
667
+ * explicit external/hybrid dispatch, priority experiments, or operational integrations.
668
+ */
669
+ export interface SessionQueueConfig {
670
+ /** Max concurrency for Query lane (default: 4). */
671
+ queryConcurrency?: number
672
+ /** Max concurrency for Execute lane (default: 2). */
673
+ executeConcurrency?: number
674
+ /** Max concurrency for Generate lane (default: 1). */
675
+ generateConcurrency?: number
676
+ /** Enable dead letter queue. */
677
+ enableDlq?: boolean
678
+ /** Max DLQ size (default: 1000). */
679
+ dlqMaxSize?: number
680
+ /** Enable metrics collection. */
681
+ enableMetrics?: boolean
682
+ /** Enable queue alerts. */
683
+ enableAlerts?: boolean
684
+ /** Default command timeout (ms). */
685
+ timeoutMs?: number
686
+ /** Enable all features with sensible defaults. */
687
+ enableAllFeatures?: boolean
688
+ /**
689
+ * Per-lane handler config. Keys: "control", "query", "execute", "generate".
690
+ * Values: LaneHandlerConfig with mode ("internal"/"external"/"hybrid") and timeoutMs.
691
+ */
692
+ laneHandlers?: Record<string, LaneHandlerConfig>
693
+ }
694
+ /** Result of an external task completion. */
695
+ export interface ExternalTaskResult {
696
+ success: boolean
697
+ result?: any
698
+ error?: string
699
+ }
700
+ /** Lane handler configuration. */
701
+ export interface LaneHandlerConfig {
702
+ /** "internal", "external", or "hybrid" */
703
+ mode: string
704
+ /** Timeout for external processing (ms). */
705
+ timeoutMs?: number
706
+ }
707
+ /** Queue statistics. */
708
+ export interface QueueStats {
709
+ totalPending: number
710
+ totalActive: number
711
+ externalPending: number
712
+ }
713
+ export interface McpServerStatusEntry {
714
+ name: string
715
+ connected: boolean
716
+ toolCount: number
717
+ error?: string
718
+ }
719
+ /** MCP server metadata exposed to slash command handlers. */
720
+ export interface CommandMcpServerInfo {
721
+ /** MCP server name. */
722
+ name: string
723
+ /** Number of tools currently exposed by the server. */
724
+ toolCount: number
725
+ }
726
+ /** Context passed to custom slash command handlers. */
727
+ export interface CommandContext {
728
+ /** Current session ID. */
729
+ sessionId: string
730
+ /** Current workspace path. */
731
+ workspace: string
732
+ /** Current active model identifier. */
733
+ model: string
734
+ /** Number of messages in session history. */
735
+ historyLen: number
736
+ /** Total tokens used in this session so far. */
737
+ totalTokens: number
738
+ /** Estimated session cost in USD. */
739
+ totalCost: number
740
+ /** Registered tool names (builtin + MCP). */
741
+ toolNames: Array<string>
742
+ /** Connected MCP servers and their tool counts. */
743
+ mcpServers: Array<CommandMcpServerInfo>
744
+ }
745
+ /** Metadata about a registered slash command. */
746
+ export interface CommandInfo {
747
+ /** Command name without the leading `/` (e.g., `"help"`, `"model"`) */
748
+ name: string
749
+ /** Short description shown in `/help` */
750
+ description: string
751
+ /** Optional usage hint (e.g., `"/model <provider/model>"`) */
752
+ usage?: string
753
+ }
754
+ /** Matcher for filtering which events trigger a hook. */
755
+ export interface HookMatcherObject {
756
+ /** Match specific tool name (exact match) */
757
+ tool?: string
758
+ /** Match file path pattern (glob) */
759
+ pathPattern?: string
760
+ /** Match command pattern (regex for Bash commands) */
761
+ commandPattern?: string
762
+ /** Match session ID (exact match) */
763
+ sessionId?: string
764
+ /** Match skill name (supports glob patterns) */
765
+ skill?: string
766
+ }
767
+ /** Configuration for a hook. */
768
+ export interface HookConfigObject {
769
+ /** Priority (lower values = higher priority, default: 100) */
770
+ priority?: number
771
+ /** Timeout in milliseconds (default: 30000) */
772
+ timeoutMs?: number
773
+ /** Whether to execute asynchronously (fire-and-forget) */
774
+ asyncExecution?: boolean
775
+ /** Maximum retry attempts */
776
+ maxRetries?: number
777
+ }
778
+ /** Metadata about a built-in skill. */
779
+ export interface SkillInfo {
780
+ name: string
781
+ description: string
782
+ /** Skill kind: "instruction", "tool", or "agent". */
783
+ kind: string
784
+ }
785
+ /**
786
+ * Return a list of built-in skills compiled into the library.
787
+ *
788
+ * Each entry has `name`, `description`, and `kind` (instruction, tool, or agent).
789
+ */
790
+ export declare function builtinSkills(): Array<SkillInfo>
791
+ /** Configuration for a search engine. */
792
+ export interface SearchEngineConfig {
793
+ enabled: boolean
794
+ weight: number
795
+ timeout?: number
796
+ }
797
+ /** Browser backend for headless search. */
798
+ export const enum BrowserBackend {
799
+ /** Chrome/Chromium headless. */
800
+ Chrome = 0,
801
+ /** Lightpanda headless browser (Linux/macOS only). */
802
+ Lightpanda = 1
803
+ }
804
+ /** Headless browser configuration. */
805
+ export interface HeadlessConfig {
806
+ backend: BrowserBackend
807
+ browserPath?: string
808
+ maxTabs?: number
809
+ launchArgs?: Array<string>
810
+ proxyUrl?: string
811
+ }
812
+ /** Health monitor configuration for search engines. */
813
+ export interface SearchHealthConfig {
814
+ maxFailures: number
815
+ suspendSeconds: number
816
+ }
817
+ /** Search engine configuration (a3s-search integration). */
818
+ export interface SearchConfig {
819
+ timeout: number
820
+ health?: SearchHealthConfig
821
+ engines: Record<string, SearchEngineConfig>
822
+ headless?: HeadlessConfig
823
+ }
824
+ /** Streaming event iterator. Use `for await (const event of stream)` or call `.next()` manually. */
825
+ export declare class EventStream {
826
+ /**
827
+ * Get the next event from the stream.
828
+ *
829
+ * Returns `{ value: AgentEvent | null, done: boolean }`.
830
+ * When `done` is true, the stream is exhausted.
831
+ */
832
+ next(): Promise<NextResult>
833
+ }
834
+ /**
835
+ * File-backed long-term memory store.
836
+ *
837
+ * ```js
838
+ * agent.session('.', { memoryStore: new FileMemoryStore('./memory') });
839
+ * ```
840
+ */
841
+ export declare class FileMemoryStore {
842
+ backend: string
843
+ dir: string
844
+ /** Create a file-backed memory store at `dir`. */
845
+ constructor(dir: string)
846
+ }
847
+ /**
848
+ * File-backed session store (persists sessions to disk for later resumption).
849
+ *
850
+ * ```js
851
+ * agent.session('.', {
852
+ * sessionStore: new FileSessionStore('./sessions'),
853
+ * sessionId: 'my-session',
854
+ * autoSave: true,
855
+ * });
856
+ * ```
857
+ */
858
+ export declare class FileSessionStore {
859
+ backend: string
860
+ dir: string
861
+ /** Create a file-backed session store at `dir`. */
862
+ constructor(dir: string)
863
+ }
864
+ /**
865
+ * In-memory (non-persistent) session store.
866
+ *
867
+ * Useful for testing, ephemeral runs, and CI pipelines where no disk state is needed.
868
+ *
869
+ * ```js
870
+ * agent.session('.', { sessionStore: new MemorySessionStore() });
871
+ * ```
872
+ */
873
+ export declare class MemorySessionStore {
874
+ backend: string
875
+ constructor()
876
+ }
877
+ /**
878
+ * Default security provider: input taint tracking + output sanitisation.
879
+ *
880
+ * ```js
881
+ * agent.session('.', { securityProvider: new DefaultSecurityProvider() });
882
+ * ```
883
+ */
884
+ export declare class DefaultSecurityProvider {
885
+ kind: string
886
+ constructor()
887
+ }
888
+ /**
889
+ * Local filesystem workspace backend.
890
+ *
891
+ * This is the explicit typed form of the default local workspace behavior.
892
+ * It is useful when callers want to pass workspace backends through the same
893
+ * option surface that remote/browser backends will use.
894
+ *
895
+ * ```js
896
+ * agent.session('/repo', { workspaceBackend: new LocalWorkspaceBackend('/repo') });
897
+ * ```
898
+ */
899
+ export declare class LocalWorkspaceBackend {
900
+ kind: string
901
+ root: string
902
+ /** Create a local filesystem workspace backend rooted at `root`. */
903
+ constructor(root: string)
904
+ }
905
+ /**
906
+ * S3-compatible object-storage workspace backend.
907
+ *
908
+ * Points built-in file tools (`read`, `write`, `edit`, `patch`, `ls`) at an
909
+ * S3-compatible bucket. Works with AWS S3, MinIO, RustFS, Cloudflare R2,
910
+ * Backblaze B2, and other S3-API-compatible services.
911
+ *
912
+ * `bash`, `git`, `grep`, and `glob` are intentionally **not** registered
913
+ * when this backend is in use — object storage cannot service them.
914
+ *
915
+ * ```js
916
+ * const backend = new S3WorkspaceBackend({
917
+ * endpoint: 'https://minio.local:9000',
918
+ * region: 'us-east-1',
919
+ * accessKeyId: 'AKIA...',
920
+ * secretAccessKey: '...',
921
+ * bucket: 'workspace',
922
+ * prefix: 'users/u1/sessions/s1',
923
+ * forcePathStyle: true,
924
+ * });
925
+ * agent.session('s3://workspace/users/u1/sessions/s1', { workspaceBackend: backend });
926
+ * ```
927
+ */
928
+ export declare class S3WorkspaceBackend {
929
+ kind: string
930
+ s3: JsS3BackendConfig
931
+ /** Create an S3-compatible workspace backend. */
932
+ constructor(config: JsS3BackendConfig)
933
+ }
934
+ /**
935
+ * Stdio transport for AHP (Agent Harness Protocol).
936
+ *
937
+ * Launches a child process and communicates via stdin/stdout using JSON-RPC 2.0.
938
+ *
939
+ * ```js
940
+ * agent.session('.', {
941
+ * ahpTransport: new StdioTransport('python', ['ahp_server.py'])
942
+ * });
943
+ * ```
944
+ */
945
+ export declare class StdioTransport {
946
+ kind: string
947
+ program?: string
948
+ args?: Array<string>
949
+ url?: string
950
+ authToken?: string
951
+ path?: string
952
+ constructor(program: string, args: Array<string>)
953
+ }
954
+ /**
955
+ * HTTP transport for AHP (Agent Harness Protocol).
956
+ *
957
+ * Connects to a remote AHP harness server via HTTP.
958
+ *
959
+ * ```js
960
+ * agent.session('.', {
961
+ * ahpTransport: new HttpTransport('http://localhost:8080/ahp')
962
+ * });
963
+ * ```
964
+ */
965
+ export declare class HttpTransport {
966
+ kind: string
967
+ program?: string
968
+ args?: Array<string>
969
+ url?: string
970
+ authToken?: string
971
+ path?: string
972
+ constructor(url: string, authToken?: string | undefined | null)
973
+ }
974
+ /**
975
+ * WebSocket transport for AHP (Agent Harness Protocol).
976
+ *
977
+ * Connects to a remote AHP harness server via WebSocket for bidirectional streaming.
978
+ *
979
+ * ```js
980
+ * agent.session('.', {
981
+ * ahpTransport: new WebSocketTransport('ws://localhost:8080/ahp')
982
+ * });
983
+ * ```
984
+ */
985
+ export declare class WebSocketTransport {
986
+ kind: string
987
+ program?: string
988
+ args?: Array<string>
989
+ url?: string
990
+ authToken?: string
991
+ path?: string
992
+ constructor(url: string, authToken?: string | undefined | null)
993
+ }
994
+ /**
995
+ * Unix socket transport for AHP (Agent Harness Protocol).
996
+ *
997
+ * Connects to a local AHP harness server via Unix domain socket.
998
+ *
999
+ * ```js
1000
+ * agent.session('.', {
1001
+ * ahpTransport: new UnixSocketTransport('/tmp/ahp.sock')
1002
+ * });
1003
+ * ```
1004
+ */
1005
+ export declare class UnixSocketTransport {
1006
+ kind: string
1007
+ program?: string
1008
+ args?: Array<string>
1009
+ url?: string
1010
+ authToken?: string
1011
+ path?: string
1012
+ constructor(path: string)
1013
+ }
1014
+ /** AI coding agent. Create with `Agent.create()`, then call `agent.session()`. */
1015
+ export declare class Agent {
1016
+ /**
1017
+ * Create an Agent from a config file path or inline config string.
1018
+ *
1019
+ * Accepts ACL-compatible config files (.acl) or inline config strings.
1020
+ * JSON config is not supported.
1021
+ *
1022
+ * @param configSource - Path to a config file (.acl), or inline config string
1023
+ */
1024
+ static create(configSource: string): Promise<Agent>
1025
+ /**
1026
+ * Re-fetch tool definitions from all connected global MCP servers and
1027
+ * update the agent-level cache.
1028
+ *
1029
+ * New sessions created after this call will see the refreshed tool list.
1030
+ * Existing sessions are unaffected.
1031
+ */
1032
+ refreshMcpTools(): Promise<void>
1033
+ /**
1034
+ * Bind to a workspace directory, returning a Session.
1035
+ *
1036
+ * @param workspace - Path to the workspace directory
1037
+ * @param options - Optional session overrides
1038
+ */
1039
+ session(workspace: string, options?: SessionOptions | undefined | null): Session
1040
+ /**
1041
+ * Resume a previously saved session by ID.
1042
+ *
1043
+ * `options.sessionStore` must be set to a `FileSessionStore` (or `MemorySessionStore`)
1044
+ * that points to the directory where the session was originally saved.
1045
+ *
1046
+ * ```js
1047
+ * const session = agent.resumeSession('my-session', {
1048
+ * sessionStore: new FileSessionStore('./sessions'),
1049
+ * });
1050
+ * ```
1051
+ *
1052
+ * @param sessionId - The session ID to resume
1053
+ * @param options - Session options; `sessionStore` is required
1054
+ */
1055
+ resumeSession(sessionId: string, options: SessionOptions): Session
1056
+ /**
1057
+ * Create a session pre-configured from a named agent definition.
1058
+ *
1059
+ * Loads the agent by name from built-in agents and optionally from
1060
+ * additional directories, then creates a session with the agent's
1061
+ * permissions, system prompt, model, and step limit applied.
1062
+ *
1063
+ * @param workspace - Path to the workspace directory
1064
+ * @param agentName - Name of the agent to load (e.g. "explore", "general")
1065
+ * @param agentDirs - Optional directories to scan for agent files
1066
+ * @param options - Optional session overrides layered on top of the agent definition
1067
+ */
1068
+ sessionForAgent(workspace: string, agentName: string, agentDirs?: Array<string> | undefined | null, options?: SessionOptions | undefined | null): Session
1069
+ /**
1070
+ * Create a session pre-configured from a disposable worker spec.
1071
+ *
1072
+ * This avoids writing temporary agent files for one-off cattle workers.
1073
+ *
1074
+ * @param workspace - Path to the workspace directory
1075
+ * @param worker - Worker spec to compile into an agent definition
1076
+ * @param options - Optional session overrides layered on top of the worker definition
1077
+ */
1078
+ sessionForWorker(workspace: string, worker: WorkerAgentSpec, options?: SessionOptions | undefined | null): Session
1079
+ }
1080
+ /** Workspace-bound session. All LLM and tool operations happen here. */
1081
+ export declare class Session {
1082
+ /**
1083
+ * Send a prompt or request and wait for the complete response.
1084
+ *
1085
+ * `send("prompt")` is the compact prompt-first form. `send({ prompt,
1086
+ * history, attachments })` is the compact object-shaped form for growth.
1087
+ */
1088
+ send(request: string | SessionRequestOptions, history?: Array<MessageObject> | null): Promise<AgentResult>
1089
+ /** Alias for `send(...)` with a name that matches run/replay terminology. */
1090
+ run(request: string | SessionRequestOptions, history?: Array<MessageObject> | null): Promise<AgentResult>
1091
+ /**
1092
+ * Send a prompt or request and get a streaming event iterator.
1093
+ *
1094
+ * Returns an `EventStream`. Use `for await (const event of stream)` or call `.next()` manually.
1095
+ * When `history` is omitted, the session history and verification evidence are
1096
+ * updated after the stream completes. Supplying `history` keeps the stream isolated.
1097
+ */
1098
+ stream(request: string | SessionRequestOptions, history?: Array<MessageObject> | null): Promise<EventStream>
1099
+ /**
1100
+ * Send a request using the long-lived object-shaped API.
1101
+ *
1102
+ * Prefer this for new integrations when the call may need history,
1103
+ * attachments, or future request options.
1104
+ */
1105
+ sendRequest(request: SessionRequestOptions): Promise<AgentResult>
1106
+ /** Stream a request using the long-lived object-shaped API. */
1107
+ streamRequest(request: SessionRequestOptions): Promise<EventStream>
1108
+ /**
1109
+ * Send a prompt with image attachments and wait for the complete response.
1110
+ *
1111
+ * @param prompt - The prompt to send
1112
+ * @param attachments - Array of `{ data: Buffer, mediaType: string }`
1113
+ * @param history - Optional conversation history
1114
+ */
1115
+ sendWithAttachments(prompt: string, attachments: Array<AttachmentObject>, history?: Array<MessageObject> | undefined | null): Promise<AgentResult>
1116
+ /**
1117
+ * Stream a prompt with image attachments.
1118
+ *
1119
+ * When `history` is omitted, the session history and verification evidence are
1120
+ * updated after the stream completes. Supplying `history` keeps the stream isolated.
1121
+ *
1122
+ * @param prompt - The prompt to send
1123
+ * @param attachments - Array of `{ data: Buffer, mediaType: string }`
1124
+ * @param history - Optional conversation history
1125
+ */
1126
+ streamWithAttachments(prompt: string, attachments: Array<AttachmentObject>, history?: Array<MessageObject> | undefined | null): Promise<EventStream>
1127
+ /** Return the session's conversation history. */
1128
+ history(): Array<MessageObject>
1129
+ /** Return run snapshots recorded by this session. */
1130
+ runs(): Promise<any>
1131
+ /** Return a run snapshot by ID, or null when it is unknown. */
1132
+ runSnapshot(runId: string): Promise<any>
1133
+ /** Return recorded runtime events for a run. */
1134
+ runEvents(runId: string): Promise<any>
1135
+ /** Return the currently running operation, or null when idle. */
1136
+ currentRun(): Promise<any>
1137
+ /** Return active tool calls observed for the currently running operation. */
1138
+ activeTools(): Promise<any>
1139
+ /**
1140
+ * Look up a delegated subagent task by id. Resolves to `null` when no
1141
+ * such task has been observed in this session.
1142
+ */
1143
+ subagentTask(taskId: string): Promise<any>
1144
+ /**
1145
+ * Return snapshots of every delegated subagent task observed in this
1146
+ * session (including completed and failed ones), oldest first.
1147
+ */
1148
+ subagentTasks(): Promise<any>
1149
+ /** Return snapshots of subagent tasks still in `running` state. */
1150
+ pendingSubagentTasks(): Promise<any>
1151
+ /**
1152
+ * Cancel an in-flight subagent task by id. Resolves to `true` when a
1153
+ * cancellation token was found and fired, `false` when the task id
1154
+ * is unknown or the task already finished.
1155
+ */
1156
+ cancelSubagentTask(taskId: string): Promise<boolean>
1157
+ /** Cancel a specific run only if it is still the active run. */
1158
+ cancelRun(runId: string): Promise<boolean>
1159
+ /** Execute a tool by name, bypassing the LLM. */
1160
+ tool(name: string, args: any): Promise<ToolResult>
1161
+ /** Delegate a bounded task to a child agent through the built-in `task` tool. */
1162
+ task(options: DelegateTaskOptions): Promise<ToolResult>
1163
+ /** Delegate a bounded task to a child agent through the built-in `task` tool. */
1164
+ delegateTask(options: DelegateTaskOptions): Promise<ToolResult>
1165
+ /** Execute several delegated child-agent tasks concurrently through `parallel_task`. */
1166
+ tasks(tasks: DelegateTaskOptions[]): Promise<ToolResult>
1167
+ /** Execute several delegated child-agent tasks concurrently through `parallel_task`. */
1168
+ parallelTask(tasks: DelegateTaskOptions[]): Promise<ToolResult>
1169
+ /** Run a bounded JavaScript script through the embedded QuickJS `program` tool. */
1170
+ program(options: ProgramScriptOptions): Promise<ToolResult>
1171
+ /** Read a file from the workspace. */
1172
+ readFile(path: string): Promise<string>
1173
+ /** Write a file in the workspace. */
1174
+ writeFile(path: string, content: string): Promise<ToolResult>
1175
+ /** List a directory in the workspace. */
1176
+ ls(path?: string | undefined | null): Promise<ToolResult>
1177
+ /** Edit a file by replacing text in the workspace. */
1178
+ editFile(path: string, oldString: string, newString: string, replaceAll?: boolean | undefined | null): Promise<ToolResult>
1179
+ /** Apply a unified diff patch to a workspace file. */
1180
+ patchFile(path: string, diff: string): Promise<ToolResult>
1181
+ /** Execute a bash command in the workspace. */
1182
+ bash(command: string): Promise<string>
1183
+ /** Search for files matching a glob pattern. */
1184
+ glob(pattern: string): Promise<Array<string>>
1185
+ /** Search file contents with a regex pattern. */
1186
+ grep(pattern: string): Promise<string>
1187
+ /** Search the web using multiple search engines. */
1188
+ webSearch(params: JsWebSearchParams): Promise<ToolResult>
1189
+ /**
1190
+ * Execute a git command.
1191
+ *
1192
+ * Prefer `git({ command: "status" })`; positional arguments remain for
1193
+ * compatibility.
1194
+ */
1195
+ 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>
1196
+ /**
1197
+ * Execute a git command with an object-shaped API.
1198
+ *
1199
+ * Preferred over the positional `git(...)` overload for new callers.
1200
+ *
1201
+ * ```js
1202
+ * await session.gitCommand({ command: 'status' })
1203
+ * await session.gitCommand({ command: 'worktree', subcommand: 'list' })
1204
+ * ```
1205
+ */
1206
+ gitCommand(args: GitCommandOptions): Promise<ToolResult>
1207
+ /** Check if this session has an advanced lane queue configured. */
1208
+ hasQueue(): boolean
1209
+ /**
1210
+ * Configure a lane's handler mode for explicit external/hybrid dispatch.
1211
+ *
1212
+ * @param lane - "control", "query", "execute", or "generate"
1213
+ * @param config - { mode: "internal"|"external"|"hybrid", timeoutMs?: number }
1214
+ */
1215
+ setLaneHandler(lane: string, config: LaneHandlerConfig): Promise<void>
1216
+ /**
1217
+ * Complete an external queue task by ID.
1218
+ *
1219
+ * @param taskId - The task identifier
1220
+ * @param result - { success: boolean, result?: any, error?: string }
1221
+ * @returns true if found, false if not found
1222
+ */
1223
+ completeExternalTask(taskId: string, result: ExternalTaskResult): Promise<boolean>
1224
+ /** Get pending external queue tasks. */
1225
+ pendingExternalTasks(): Promise<any>
1226
+ /** Return pending HITL tool confirmations for this session. */
1227
+ pendingConfirmations(): Promise<Array<PendingConfirmation>>
1228
+ /**
1229
+ * Resolve a pending HITL tool confirmation.
1230
+ *
1231
+ * @param toolId - Tool call ID from a `confirmation_required` event.
1232
+ * @param approved - Whether the tool execution should proceed.
1233
+ * @param reason - Optional human-readable reason for audit/UI display.
1234
+ * @returns true if a pending confirmation was found and completed.
1235
+ */
1236
+ confirmToolUse(toolId: string, approved: boolean, reason?: string | undefined | null): Promise<boolean>
1237
+ /** Cancel all pending HITL confirmations for this session. */
1238
+ cancelConfirmations(): Promise<number>
1239
+ /** Get optional queue statistics. */
1240
+ queueStats(): Promise<QueueStats>
1241
+ /** Return compact execution trace events recorded for this session. */
1242
+ traceEvents(): any
1243
+ /** Return structured verification reports recorded for this session. */
1244
+ verificationReports(): any
1245
+ /** Add externally produced verification reports to this session. */
1246
+ recordVerificationReports(reports: any): void
1247
+ /** Return a structured verification summary for this session. */
1248
+ verificationSummary(): any
1249
+ /** Return a concise human-readable verification summary for this session. */
1250
+ verificationSummaryText(): string
1251
+ /** Run verification commands and return a structured verification report. */
1252
+ verifyCommands(subject: string, commands: Array<VerificationCommand>): Promise<any>
1253
+ /** Return project-aware verification command presets for this workspace. */
1254
+ verificationPresets(): any
1255
+ /** Get dead letters from the optional queue's DLQ. */
1256
+ deadLetters(): Promise<any>
1257
+ /**
1258
+ * Get a detailed metrics snapshot from the queue.
1259
+ *
1260
+ * Returns `null` if metrics are not enabled (queue not configured or
1261
+ * `enable_metrics` was not set in `SessionQueueConfig`).
1262
+ *
1263
+ * @returns Object with `counters`, `gauges`, and `histograms` maps, or null
1264
+ */
1265
+ queueMetrics(): Promise<any>
1266
+ /**
1267
+ * Add an MCP server to this live session.
1268
+ *
1269
+ * Connects the server and registers all its tools immediately so the agent
1270
+ * can call them. Tool names follow the convention `mcp__<name>__<tool>`.
1271
+ *
1272
+ * @param name - Server identifier (used as prefix in tool names)
1273
+ * @param transport - Transport type: `"stdio"` (default), `"http"`, or `"streamable-http"`
1274
+ * @param command - Executable to launch (stdio only, e.g. `"npx"`)
1275
+ * @param args - Arguments for the command (stdio only)
1276
+ * @param url - Server URL (http / streamable-http only)
1277
+ * @param headers - HTTP headers (http / streamable-http only)
1278
+ * @param env - Optional extra environment variables (stdio only)
1279
+ * @returns Number of tools registered from the server
1280
+ */
1281
+ 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>
1282
+ /**
1283
+ * Add an MCP server with a typed object config.
1284
+ *
1285
+ * Preferred over the positional overload for new SDK callers.
1286
+ *
1287
+ * ```js
1288
+ * await session.addMcpServerConfig({
1289
+ * name: 'github',
1290
+ * transport: { type: 'stdio', command: 'npx', args: ['-y', '@modelcontextprotocol/server-github'] },
1291
+ * env: { GITHUB_TOKEN: process.env.GITHUB_TOKEN },
1292
+ * timeoutMs: 30000,
1293
+ * })
1294
+ * ```
1295
+ */
1296
+ addMcpServerConfig(config: McpServerConfig): Promise<number>
1297
+ /** Add an MCP server with the compact object-shaped API. */
1298
+ addMcp(config: McpServerConfig): Promise<number>
1299
+ /**
1300
+ * Dynamically register agent definitions from a directory into the live session.
1301
+ *
1302
+ * Scans the directory for `*.yaml`, `*.yml`, and `*.md` agent definition files
1303
+ * and registers them into the shared AgentRegistry used by the `task` tool.
1304
+ * New agents are immediately callable via `task({ agent: "…", … })` without
1305
+ * restarting the session.
1306
+ *
1307
+ * @param path - Directory to scan for agent definition files
1308
+ * @returns Number of agents successfully loaded
1309
+ */
1310
+ registerAgentDir(path: string): number
1311
+ /**
1312
+ * Register a disposable worker agent into the live session.
1313
+ *
1314
+ * The worker is immediately callable through the model-visible `task` tool.
1315
+ *
1316
+ * @param worker - Worker spec to register
1317
+ * @returns Compiled agent definition
1318
+ */
1319
+ registerWorkerAgent(worker: WorkerAgentSpec): AgentDefinition
1320
+ /**
1321
+ * Register many disposable workers into the live session.
1322
+ *
1323
+ * @param workers - Worker specs to register
1324
+ * @returns Compiled agent definitions
1325
+ */
1326
+ registerWorkerAgents(workers: Array<WorkerAgentSpec>): Array<AgentDefinition>
1327
+ /**
1328
+ * Disconnect and unregister an MCP server, removing its tools from the session.
1329
+ *
1330
+ * @param name - Server name (must match the name used in addMcpServer)
1331
+ */
1332
+ removeMcpServer(name: string): Promise<void>
1333
+ /** Remove an MCP server with the compact API. */
1334
+ removeMcp(name: string): Promise<void>
1335
+ /**
1336
+ * Return connection status for all MCP servers registered on this session.
1337
+ *
1338
+ * @returns Array of `{ name, connected, toolCount }` entries
1339
+ */
1340
+ mcpStatus(): Promise<Array<McpServerStatusEntry>>
1341
+ /** Return MCP server status with the compact API. */
1342
+ mcps(): Promise<Array<McpServerStatusEntry>>
1343
+ /**
1344
+ * Return the names of all tools currently registered on this session.
1345
+ *
1346
+ * @returns Array of tool name strings
1347
+ */
1348
+ toolNames(): Array<string>
1349
+ /** Return full model-visible tool definitions currently registered on this session. */
1350
+ toolDefinitions(): any
1351
+ /** Return a stored tool artifact by URI, or null if it is not retained. */
1352
+ getArtifact(artifactUri: string): any
1353
+ /**
1354
+ * Register a hook for lifecycle event interception.
1355
+ *
1356
+ * Hooks registered on a session are automatically propagated to all sub-agents
1357
+ * spawned by the `task` tool, including grandchild agents at arbitrary depth.
1358
+ * This ensures security hooks (e.g. a sentinel) apply across the full agent tree
1359
+ * without requiring explicit registration on each sub-agent session.
1360
+ *
1361
+ * @param hookId - Unique hook identifier
1362
+ * @param eventType - Event type: "pre_tool_use", "post_tool_use", "generate_start",
1363
+ * "generate_end", "session_start", "session_end", "skill_load", "skill_unload",
1364
+ * "pre_prompt", "post_response", "on_error"
1365
+ * @param matcher - Optional matcher: { tool?, pathPattern?, commandPattern?, sessionId?, skill? }
1366
+ * @param config - Optional config: { priority?, timeoutMs?, asyncExecution?, maxRetries? }
1367
+ * @param handler - Optional callback `(event: any) => { action: 'continue' | 'block' | 'skip',
1368
+ * reason?: string } | null`. When provided, the function is called for every matching event
1369
+ * and its return value controls execution. Return `{ action: 'block', reason: '...' }` to
1370
+ * cancel the operation, `{ action: 'skip' }` to skip remaining hooks, or `null`/`undefined`
1371
+ * for continue. Hooks with no handler still fire (observable via stream events) but always
1372
+ * continue.
1373
+ */
1374
+ registerHook(hookId: string, eventType: string, matcher?: HookMatcherObject | undefined | null, config?: HookConfigObject | undefined | null, handler?: ((event: Record<string, unknown>) => { action: string; reason?: string } | null | undefined) | null | undefined): void
1375
+ /**
1376
+ * Unregister a hook by ID.
1377
+ *
1378
+ * @param hookId - The hook identifier to remove
1379
+ * @returns true if the hook was found and removed
1380
+ */
1381
+ unregisterHook(hookId: string): boolean
1382
+ /** Get the number of registered hooks. */
1383
+ hookCount(): number
1384
+ /** Return the session ID. */
1385
+ get sessionId(): string
1386
+ /** Return the workspace path. */
1387
+ get workspace(): string
1388
+ /** Return any deferred init warning (e.g. memory store failed to initialize). */
1389
+ get initWarning(): string | null
1390
+ /** Save the session to the configured store. */
1391
+ save(): Promise<void>
1392
+ /** Check if memory is configured for this session. */
1393
+ get hasMemory(): boolean
1394
+ /**
1395
+ * Remember a successful task execution.
1396
+ *
1397
+ * @param task - Description of the task
1398
+ * @param tools - List of tool names used
1399
+ * @param result - Summary of the result
1400
+ */
1401
+ rememberSuccess(task: string, tools: Array<string>, result: string): Promise<void>
1402
+ /**
1403
+ * Remember a failed task execution.
1404
+ *
1405
+ * @param task - Description of the task
1406
+ * @param error - Error message
1407
+ * @param tools - List of tool names attempted
1408
+ */
1409
+ rememberFailure(task: string, error: string, tools: Array<string>): Promise<void>
1410
+ /**
1411
+ * Recall memories similar to a query.
1412
+ *
1413
+ * @param query - Search query
1414
+ * @param limit - Maximum number of results (default: 5)
1415
+ * @returns Array of memory items
1416
+ */
1417
+ recallSimilar(query: string, limit?: number | undefined | null): Promise<any>
1418
+ /**
1419
+ * Recall memories by tags.
1420
+ *
1421
+ * @param tags - Tags to search for
1422
+ * @param limit - Maximum number of results (default: 10)
1423
+ * @returns Array of memory items
1424
+ */
1425
+ recallByTags(tags: Array<string>, limit?: number | undefined | null): Promise<any>
1426
+ /**
1427
+ * Get recent memory items.
1428
+ *
1429
+ * @param limit - Maximum number of results (default: 10)
1430
+ * @returns Array of memory items
1431
+ */
1432
+ memoryRecent(limit?: number | undefined | null): Promise<any>
1433
+ /**
1434
+ * Get memory statistics.
1435
+ *
1436
+ * @returns Object with longTermCount, shortTermCount, workingCount
1437
+ */
1438
+ memoryStats(): Promise<any>
1439
+ /**
1440
+ * Get current working memory items.
1441
+ *
1442
+ * Working memory holds the active context items for the current task.
1443
+ *
1444
+ * @returns Array of memory items currently in working memory
1445
+ */
1446
+ getWorking(): Promise<any>
1447
+ /**
1448
+ * Clear working memory.
1449
+ *
1450
+ * Removes all items from working memory without affecting short-term or long-term memory.
1451
+ */
1452
+ clearWorking(): Promise<void>
1453
+ /**
1454
+ * Get current short-term memory items.
1455
+ *
1456
+ * Short-term memory contains items stored during this session.
1457
+ *
1458
+ * @returns Array of memory items in short-term memory
1459
+ */
1460
+ getShortTerm(): Promise<any>
1461
+ /**
1462
+ * Clear short-term memory for this session.
1463
+ *
1464
+ * Removes all session-scoped memory items without affecting long-term or working memory.
1465
+ */
1466
+ clearShortTerm(): Promise<void>
1467
+ /**
1468
+ * Register a custom slash command.
1469
+ *
1470
+ * Slash commands are invoked via `session.send("/command args")` and execute
1471
+ * before the LLM sees the input. The handler receives the command arguments
1472
+ * and a context object with session metadata.
1473
+ *
1474
+ * @param name - Command name without the leading `/` (e.g., `"status"`)
1475
+ * @param description - Short description shown in `/help`
1476
+ * @param handler - Callback `(args: string, ctx: CommandContext) => string`
1477
+ *
1478
+ * @example
1479
+ * ```typescript
1480
+ * session.registerCommand("status", "Show session info", (args, ctx) => {
1481
+ * return `Session ${ctx.sessionId} in ${ctx.workspace}`;
1482
+ * });
1483
+ * await session.send("/status");
1484
+ * ```
1485
+ */
1486
+ registerCommand(name: string, description: string, handler: (args: string, ctx: CommandContext) => string): void
1487
+ /**
1488
+ * List all registered slash commands.
1489
+ *
1490
+ * Returns each command's name, description, and optional usage hint.
1491
+ * Slash commands can be invoked via `session.send("/command args")`.
1492
+ *
1493
+ * @returns Array of CommandInfo objects sorted by name
1494
+ */
1495
+ listCommands(): Array<CommandInfo>
1496
+ /**
1497
+ * Cancel the current ongoing operation (send/stream).
1498
+ *
1499
+ * If an operation is in progress, this will trigger cancellation of the LLM streaming
1500
+ * and tool execution. The operation will terminate as soon as possible.
1501
+ *
1502
+ * @returns `true` if an operation was cancelled, `false` if no operation was in progress
1503
+ */
1504
+ cancel(): boolean
1505
+ /**
1506
+ * Close the session and cancel any active operation.
1507
+ *
1508
+ * Call this when the session will no longer be used so Node.js can exit
1509
+ * cleanly without waiting on session-scoped background workers.
1510
+ */
1511
+ close(): void
1512
+ }