@a3s-lab/code 0.7.2 → 0.8.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/index.d.ts CHANGED
@@ -1,103 +0,0 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- /* auto-generated by NAPI-RS */
5
-
6
- export interface AgentResult {
7
- text: string
8
- toolCallsCount: number
9
- promptTokens: number
10
- completionTokens: number
11
- totalTokens: number
12
- }
13
- export interface AgentEvent {
14
- type: string
15
- text?: string
16
- toolName?: string
17
- toolId?: string
18
- toolOutput?: string
19
- exitCode?: number
20
- turn?: number
21
- prompt?: string
22
- error?: string
23
- totalTokens?: number
24
- }
25
- export interface ToolResult {
26
- name: string
27
- output: string
28
- exitCode: number
29
- }
30
- export interface SessionOptions {
31
- /** Override the default model. Format: "provider/model" (e.g., "openai/gpt-4o"). */
32
- model?: string
33
- /** Extra directories to scan for skill files (.md with YAML frontmatter). */
34
- skillDirs?: Array<string>
35
- /** Extra directories to scan for agent files. */
36
- agentDirs?: Array<string>
37
- }
38
- export interface MessageObject {
39
- role: string
40
- content: Array<ContentBlockObject>
41
- }
42
- export interface ContentBlockObject {
43
- type: string
44
- /** Text content (for "text" blocks). */
45
- text?: string
46
- /** Tool use ID (for "tool_use" blocks). */
47
- id?: string
48
- /** Tool name (for "tool_use" blocks). */
49
- name?: string
50
- /** Tool input (for "tool_use" blocks). */
51
- input?: any
52
- /** Tool use ID reference (for "tool_result" blocks). */
53
- toolUseId?: string
54
- /** Tool result content (for "tool_result" blocks). */
55
- resultContent?: string
56
- /** Whether this is an error result (for "tool_result" blocks). */
57
- isError?: boolean
58
- }
59
- /** AI coding agent. Create with `Agent.create()`, then call `agent.session()`. */
60
- export declare class Agent {
61
- /**
62
- * Create an Agent from a config file path or inline config string.
63
- *
64
- * @param configSource - Path to .hcl/.json file, or inline JSON/HCL string
65
- */
66
- static create(configSource: string): Promise<Agent>
67
- /**
68
- * Bind to a workspace directory, returning a Session.
69
- *
70
- * @param workspace - Path to the workspace directory
71
- * @param options - Optional session overrides (model, skillDirs, agentDirs)
72
- */
73
- session(workspace: string, options?: SessionOptions | undefined | null): Session
74
- }
75
- /** Workspace-bound session. All LLM and tool operations happen here. */
76
- export declare class Session {
77
- /**
78
- * Send a prompt and wait for the complete response.
79
- *
80
- * @param prompt - The prompt to send
81
- * @param history - Optional conversation history
82
- */
83
- send(prompt: string, history?: Array<MessageObject> | undefined | null): Promise<AgentResult>
84
- /**
85
- * Send a prompt and get a stream of events.
86
- *
87
- * @param prompt - The prompt to send
88
- * @param history - Optional conversation history
89
- */
90
- stream(prompt: string, history?: Array<MessageObject> | undefined | null): Promise<Array<AgentEvent>>
91
- /** Return the session's conversation history. */
92
- history(): Array<MessageObject>
93
- /** Execute a tool by name, bypassing the LLM. */
94
- tool(name: string, args: any): Promise<ToolResult>
95
- /** Read a file from the workspace. */
96
- readFile(path: string): Promise<string>
97
- /** Execute a bash command in the workspace. */
98
- bash(command: string): Promise<string>
99
- /** Search for files matching a glob pattern. */
100
- glob(pattern: string): Promise<Array<string>>
101
- /** Search file contents with a regex pattern. */
102
- grep(pattern: string): Promise<string>
103
- }
Binary file
Binary file
package/index.js CHANGED
@@ -310,7 +310,22 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { Agent, Session } = nativeBinding
313
+ const { Agent, Session, EventStream, builtinSkills } = nativeBinding
314
+
315
+ // Add Symbol.asyncIterator to EventStream for `for await...of` support.
316
+ // Each iteration calls .next() until done === true.
317
+ EventStream.prototype[Symbol.asyncIterator] = async function* () {
318
+ while (true) {
319
+ const { value, done } = await this.next()
320
+ if (done) {
321
+ if (value != null) yield value
322
+ return
323
+ }
324
+ yield value
325
+ }
326
+ }
314
327
 
315
328
  module.exports.Agent = Agent
316
329
  module.exports.Session = Session
330
+ module.exports.EventStream = EventStream
331
+ module.exports.builtinSkills = builtinSkills
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a3s-lab/code",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "description": "A3S Code - Native AI coding agent library for Node.js",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",