@a3s-lab/code 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -0
- package/index.d.ts +22 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -28,6 +28,32 @@ main().catch(console.error)
|
|
|
28
28
|
|
|
29
29
|
`session.tool(...)` returns a `ToolResult` enriched with parsed metadata helpers.
|
|
30
30
|
|
|
31
|
+
## Programmatic Tool Calling
|
|
32
|
+
|
|
33
|
+
`session.program(...)` runs a bounded JavaScript script in the embedded QuickJS
|
|
34
|
+
runtime. It is the SDK-friendly wrapper around the core `program` tool.
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
const result = await session.program({
|
|
38
|
+
source: `
|
|
39
|
+
export default async function run(ctx, inputs) {
|
|
40
|
+
const hits = await ctx.grep(inputs.query, { glob: '*.ts' })
|
|
41
|
+
const files = await ctx.glob('src/**/*.ts')
|
|
42
|
+
return { hits, files: files.slice(0, 10) }
|
|
43
|
+
}
|
|
44
|
+
`,
|
|
45
|
+
inputs: { query: 'PermissionPolicy' },
|
|
46
|
+
allowedTools: ['grep', 'glob'],
|
|
47
|
+
limits: { timeoutMs: 30000, maxToolCalls: 20, maxOutputBytes: 65536 },
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
console.log(result.output)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Omit `allowedTools` to allow every registered session tool except `program`.
|
|
54
|
+
Scripts can also be loaded from workspace-relative `.js` or `.mjs` files with
|
|
55
|
+
`{ path: 'scripts/ptc/search.js' }`.
|
|
56
|
+
|
|
31
57
|
### Agentic Parse LLM Blocks
|
|
32
58
|
|
|
33
59
|
When `agentic_parse` runs with a query, the SDK exposes the exact structured
|
package/index.d.ts
CHANGED
|
@@ -108,6 +108,26 @@ export interface ToolResult {
|
|
|
108
108
|
/** Convenience JSON view of `metadata.document_runtime` when present. */
|
|
109
109
|
documentRuntimeJson?: string
|
|
110
110
|
}
|
|
111
|
+
export interface ProgramScriptLimits {
|
|
112
|
+
/** Wall-clock timeout for the embedded QuickJS script. */
|
|
113
|
+
timeoutMs?: number
|
|
114
|
+
/** Maximum number of ctx tool calls the script may perform. */
|
|
115
|
+
maxToolCalls?: number
|
|
116
|
+
/** Maximum bytes returned in the program result output. */
|
|
117
|
+
maxOutputBytes?: number
|
|
118
|
+
}
|
|
119
|
+
export interface ProgramScriptOptions {
|
|
120
|
+
/** Inline JavaScript source. Define `async function run(ctx, inputs)` or export it as default. */
|
|
121
|
+
source?: string
|
|
122
|
+
/** Workspace-relative `.js` or `.mjs` script path. */
|
|
123
|
+
path?: string
|
|
124
|
+
/** JSON-serializable inputs passed to `run(ctx, inputs)`. */
|
|
125
|
+
inputs?: any
|
|
126
|
+
/** Optional tool allow-list. Defaults to every registered tool except `program`. */
|
|
127
|
+
allowedTools?: Array<string>
|
|
128
|
+
/** Execution limits for the script. */
|
|
129
|
+
limits?: ProgramScriptLimits
|
|
130
|
+
}
|
|
111
131
|
/** Parameters for the web_search tool. */
|
|
112
132
|
export interface JsWebSearchParams {
|
|
113
133
|
/** The search query. */
|
|
@@ -859,6 +879,8 @@ export declare class Session {
|
|
|
859
879
|
history(): Array<MessageObject>
|
|
860
880
|
/** Execute a tool by name, bypassing the LLM. */
|
|
861
881
|
tool(name: string, args: any): Promise<ToolResult>
|
|
882
|
+
/** Run a bounded JavaScript script through the embedded QuickJS `program` tool. */
|
|
883
|
+
program(options: ProgramScriptOptions): Promise<ToolResult>
|
|
862
884
|
/** Read a file from the workspace. */
|
|
863
885
|
readFile(path: string): Promise<string>
|
|
864
886
|
/** Execute a bash command in the workspace. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a3s-lab/code",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"test:agentic-parse-llm-blocks": "node examples/search/test-agentic-parse-llm-blocks.js"
|
|
44
44
|
},
|
|
45
45
|
"optionalDependencies": {
|
|
46
|
-
"@a3s-lab/code-darwin-arm64": "2.0.
|
|
47
|
-
"@a3s-lab/code-linux-x64-gnu": "2.0.
|
|
48
|
-
"@a3s-lab/code-linux-x64-musl": "2.0.
|
|
49
|
-
"@a3s-lab/code-linux-arm64-gnu": "2.0.
|
|
50
|
-
"@a3s-lab/code-linux-arm64-musl": "2.0.
|
|
51
|
-
"@a3s-lab/code-win32-x64-msvc": "2.0.
|
|
46
|
+
"@a3s-lab/code-darwin-arm64": "2.0.1",
|
|
47
|
+
"@a3s-lab/code-linux-x64-gnu": "2.0.1",
|
|
48
|
+
"@a3s-lab/code-linux-x64-musl": "2.0.1",
|
|
49
|
+
"@a3s-lab/code-linux-arm64-gnu": "2.0.1",
|
|
50
|
+
"@a3s-lab/code-linux-arm64-musl": "2.0.1",
|
|
51
|
+
"@a3s-lab/code-win32-x64-msvc": "2.0.1"
|
|
52
52
|
}
|
|
53
53
|
}
|