@qilin-agent/tools 3.1.4 → 3.1.6
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.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/index.js +373 -275
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.js +5 -3
- package/lib/types/presentation.d.ts +3 -3
- package/lib/types/ptc-calls.d.ts +24 -0
- package/lib/types/ptc-calls.js +62 -0
- package/lib/types/ptc.d.ts +5 -3
- package/lib/types/ptc.js +363 -342
- package/lib/types/py-types.d.ts +1 -1
- package/lib/types/py-types.js +3 -3
- package/lib/types/ts-types.d.ts +2 -1
- package/lib/types/ts-types.js +26 -9
- package/locale/en.json +5 -0
- package/locale/zh.json +6 -0
- package/package.json +30 -28
package/lib/types/py-types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Under `mode: 'ptc'` the native tool schemas are omitted from the request, so this generated
|
|
9
9
|
* SDK is the model's ONLY source for each tool's argument names, required fields, types,
|
|
10
|
-
* descriptions, and canonical output
|
|
10
|
+
* descriptions, and canonical output types. Object-shaped arguments and outputs render as one
|
|
11
11
|
* named `TypedDict` per tool (and per nested object), not an opaque `dict[str, Any]`, so the
|
|
12
12
|
* shape survives into the program under the mode that has nothing else to carry it.
|
|
13
13
|
* @module @qilin-agent/tools/src/py-types
|
package/lib/types/py-types.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Under `mode: 'ptc'` the native tool schemas are omitted from the request, so this generated
|
|
9
9
|
* SDK is the model's ONLY source for each tool's argument names, required fields, types,
|
|
10
|
-
* descriptions, and canonical output
|
|
10
|
+
* descriptions, and canonical output types. Object-shaped arguments and outputs render as one
|
|
11
11
|
* named `TypedDict` per tool (and per nested object), not an opaque `dict[str, Any]`, so the
|
|
12
12
|
* shape survives into the program under the mode that has nothing else to carry it.
|
|
13
13
|
* @module @qilin-agent/tools/src/py-types
|
|
@@ -700,12 +700,12 @@ export function jsonSchemaToPy(schema) {
|
|
|
700
700
|
/** The fixed model-facing usage contract rendered above the declarations. */
|
|
701
701
|
const SDK_INSTRUCTIONS = `## Writing code for run_code
|
|
702
702
|
|
|
703
|
-
\`run_code\` takes two required arguments: \`description\`, a short summary of what the program does, and \`code
|
|
703
|
+
\`run_code\` takes two required arguments: \`description\`, a short summary of what the program does, and \`code\`, the program to execute. At run time exactly two of the names declared below are bound: \`tools\` and \`ToolCallError\`. Everything else is a STATIC STUB describing argument and return types — in particular the \`TypedDict\` classes do NOT exist at run time, so build arguments as plain \`dict\`/\`list\` JSON values: \`await tools.name({"field": 1})\`, never \`FooArgs(field=1)\`, which raises \`NameError\`. Inside the program:
|
|
704
704
|
|
|
705
705
|
- Call tools as \`await tools.name(args)\` — subscript access for exotic, reserved, or underscore-leading names: \`await tools["my-tool"](args)\`. Every call resolves to the tool's typed canonical JSON value (each method's return type below). Tool arguments must be lossless JSON.
|
|
706
706
|
- A FAILED tool call raises \`ToolCallError\`, whose \`toolName\` identifies the failed tool and whose message is human-readable — wrap in \`try/except\` to handle and continue.
|
|
707
707
|
- Independent read-only calls MAY overlap under \`asyncio.gather\` (safe calls run concurrently; mutating calls run alone, in submission order). Sequence dependent work with \`await\`.
|
|
708
|
-
-
|
|
708
|
+
- Only values emitted as program output enter the conversation. A successful tool result containing an image is attached after the run so you can inspect it on the next step; every other intermediate result stays out of the conversation, so extract just what you need.
|
|
709
709
|
|
|
710
710
|
The available tools:`;
|
|
711
711
|
/**
|
package/lib/types/ts-types.d.ts
CHANGED
|
@@ -31,7 +31,8 @@ export declare function jsonSchemaToTs(schema: unknown, indent?: number): string
|
|
|
31
31
|
* by name, so the input never carries a duplicate.
|
|
32
32
|
* @param schemas - the tool schemas to declare (the caller excludes
|
|
33
33
|
* `run_code` itself).
|
|
34
|
+
* @param programFormat - Runtime syntax; function bodies support returning a result, REPLs print it.
|
|
34
35
|
* @returns the complete section text.
|
|
35
36
|
*/
|
|
36
|
-
export declare function renderToolsSdk(schemas: ToolSdkSchema[]): string;
|
|
37
|
+
export declare function renderToolsSdk(schemas: ToolSdkSchema[], programFormat?: 'function-body' | 'repl'): string;
|
|
37
38
|
//# sourceMappingURL=ts-types.d.ts.map
|
package/lib/types/ts-types.js
CHANGED
|
@@ -218,18 +218,29 @@ export function jsonSchemaToTs(schema, indent = 0) {
|
|
|
218
218
|
return 'unknown';
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
/**
|
|
222
|
-
|
|
221
|
+
/** Render the argument and call instructions for the selected execution syntax. */
|
|
222
|
+
function renderSdkInstructions(programFormat) {
|
|
223
|
+
const programDescription = programFormat === 'function-body'
|
|
224
|
+
? 'the body of an async TypeScript function (erasable syntax only — no `enum` or namespaces; type annotations are advisory, the code runs type-stripped)'
|
|
225
|
+
: 'the program to execute';
|
|
226
|
+
return `## Writing code for run_code
|
|
223
227
|
|
|
224
|
-
\`run_code\` takes two required arguments: \`description\`, a short summary of what the program does, and \`code
|
|
225
|
-
|
|
228
|
+
\`run_code\` takes two required arguments: \`description\`, a short summary of what the program does, and \`code\`, ${programDescription}. The declarations below are SDK bindings for this program. A declaration does not make its name a directly callable tool; only names supplied as separate tool schemas may be called directly.`;
|
|
229
|
+
}
|
|
230
|
+
/** Render tool execution and output instructions for the selected execution syntax. */
|
|
231
|
+
function renderSdkProgramInstructions(programFormat) {
|
|
232
|
+
const outputInstruction = programFormat === 'function-body'
|
|
233
|
+
? 'Emit results with `return` and/or `console.log(...)`. Only what you print or return is program output.'
|
|
234
|
+
: 'Only values emitted as program output enter the conversation.';
|
|
235
|
+
return `Inside the program:
|
|
226
236
|
|
|
227
237
|
- Call tools as \`await tools.name(args)\` — quoted access for exotic names: \`tools["my-tool"](args)\`. Every call resolves to the tool's typed canonical JSON value. Tool arguments must be lossless JSON.
|
|
228
238
|
- A FAILED tool call rejects with \`ToolCallError\`, whose \`toolName\` identifies the failed tool and whose \`message\` is human-readable — \`try/catch\` it to handle and continue.
|
|
229
239
|
- Independent read-only calls MAY overlap under \`Promise.all\` (safe calls run concurrently; mutating calls run alone, in submission order). Sequence dependent work with \`await\`.
|
|
230
|
-
-
|
|
240
|
+
- ${outputInstruction} A successful tool result containing an image is attached after the run so you can inspect it on the next step; every other intermediate result stays out of the conversation, so extract just what you need.
|
|
231
241
|
|
|
232
242
|
Program-only SDK bindings:`;
|
|
243
|
+
}
|
|
233
244
|
/** Whether one string schema accepts the literal used by the bash example. */
|
|
234
245
|
function acceptsExampleString(schema, value) {
|
|
235
246
|
return schema?.type === 'string'
|
|
@@ -237,7 +248,7 @@ function acceptsExampleString(schema, value) {
|
|
|
237
248
|
&& (schema.enum === undefined || schema.enum.includes(value));
|
|
238
249
|
}
|
|
239
250
|
/** Render the bash example only when its literal arguments satisfy the current parameter schema. */
|
|
240
|
-
function renderBashExample(schemas) {
|
|
251
|
+
function renderBashExample(schemas, programFormat) {
|
|
241
252
|
const bash = schemas.find(schema => schema.name === 'bash');
|
|
242
253
|
if (bash === undefined)
|
|
243
254
|
return '';
|
|
@@ -253,7 +264,10 @@ function renderBashExample(schemas) {
|
|
|
253
264
|
if (needsDescription && !acceptsExampleString(parameters.properties?.description, 'Show current directory'))
|
|
254
265
|
return '';
|
|
255
266
|
const description = needsDescription ? "description: 'Show current directory', " : '';
|
|
256
|
-
|
|
267
|
+
const program = programFormat === 'function-body'
|
|
268
|
+
? `return await tools.bash({ ${description}command: 'pwd' })`
|
|
269
|
+
: `console.log(await tools.bash({ ${description}command: 'pwd' }))`;
|
|
270
|
+
return ` When no separate \`bash\` schema is supplied, invoke a declared \`bash\` binding inside \`run_code\`:\n\n\`run_code({ description: "Show current directory", code: "${program}" })\``;
|
|
257
271
|
}
|
|
258
272
|
/**
|
|
259
273
|
* Render the full `tools:sdk` prompt section: the fixed usage instructions
|
|
@@ -265,9 +279,10 @@ function renderBashExample(schemas) {
|
|
|
265
279
|
* by name, so the input never carries a duplicate.
|
|
266
280
|
* @param schemas - the tool schemas to declare (the caller excludes
|
|
267
281
|
* `run_code` itself).
|
|
282
|
+
* @param programFormat - Runtime syntax; function bodies support returning a result, REPLs print it.
|
|
268
283
|
* @returns the complete section text.
|
|
269
284
|
*/
|
|
270
|
-
export function renderToolsSdk(schemas) {
|
|
285
|
+
export function renderToolsSdk(schemas, programFormat = 'function-body') {
|
|
271
286
|
const sorted = [...schemas].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
272
287
|
const argsMembers = [];
|
|
273
288
|
const outputMembers = [];
|
|
@@ -286,6 +301,8 @@ export function renderToolsSdk(schemas) {
|
|
|
286
301
|
['declare const tools: {', ' [K in ToolName]: (args: ToolArgsMap[K]) => Promise<ToolOutputMap[K]>;', '}'].join('\n'),
|
|
287
302
|
].join('\n\n');
|
|
288
303
|
const jsonValue = 'type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue }';
|
|
289
|
-
|
|
304
|
+
const instructions = renderSdkInstructions(programFormat);
|
|
305
|
+
const programInstructions = renderSdkProgramInstructions(programFormat);
|
|
306
|
+
return `${instructions}${renderBashExample(sorted, programFormat)}\n\n${programInstructions}\n\n\`\`\`ts\n${jsonValue}\n\n${declaration}\n\`\`\``;
|
|
290
307
|
}
|
|
291
308
|
//# sourceMappingURL=ts-types.js.map
|
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qilin-agent/tools",
|
|
3
3
|
"description": "Tool registry and execution pipeline for the QiLin",
|
|
4
|
-
"version": "3.1.
|
|
4
|
+
"version": "3.1.6",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -30,44 +30,46 @@
|
|
|
30
30
|
"default": "./lib/types/presentation.js"
|
|
31
31
|
},
|
|
32
32
|
"./src/*": "./src/*",
|
|
33
|
-
"./package.json": "./package.json"
|
|
33
|
+
"./package.json": "./package.json",
|
|
34
|
+
"./locale/*.json": "./locale/*.json"
|
|
34
35
|
},
|
|
35
36
|
"files": [
|
|
37
|
+
"locale/*.json",
|
|
36
38
|
"lib/index.js",
|
|
37
39
|
"lib/types/**/*.js",
|
|
38
40
|
"lib/types/**/*.d.ts"
|
|
39
41
|
],
|
|
40
42
|
"license": "MIT",
|
|
41
43
|
"peerDependencies": {
|
|
42
|
-
"@qilin-agent/kylin": "~4.0.
|
|
43
|
-
"@qilin-agent/
|
|
44
|
-
"@qilin-agent/
|
|
45
|
-
"@qilin-agent/
|
|
46
|
-
"@qilin-agent/
|
|
47
|
-
"@qilin-agent/
|
|
48
|
-
"@qilin-agent/
|
|
49
|
-
"@qilin-agent/
|
|
50
|
-
"@qilin-agent/
|
|
51
|
-
"@qilin-agent/
|
|
52
|
-
"@qilin-agent/
|
|
44
|
+
"@qilin-agent/kylin": "~4.0.5",
|
|
45
|
+
"@qilin-agent/agent": "3.1.6",
|
|
46
|
+
"@qilin-agent/ptc-runtime": "3.1.6",
|
|
47
|
+
"@qilin-agent/llm": "3.1.6",
|
|
48
|
+
"@qilin-agent/scope": "3.1.6",
|
|
49
|
+
"@qilin-agent/system-prompt": "3.1.6",
|
|
50
|
+
"@qilin-agent/session": "3.1.6",
|
|
51
|
+
"@qilin-agent/user-approval": "3.1.6",
|
|
52
|
+
"@qilin-agent/sandbox": "3.1.6",
|
|
53
|
+
"@qilin-agent/working-directory": "3.1.6",
|
|
54
|
+
"@qilin-agent/sandbox-policy": "3.1.6"
|
|
53
55
|
},
|
|
54
56
|
"dependencies": {
|
|
55
|
-
"@qilin-agent/util-values": "3.1.
|
|
56
|
-
"@qilin-agent/
|
|
57
|
-
"@qilin-agent/
|
|
57
|
+
"@qilin-agent/util-values": "3.1.6",
|
|
58
|
+
"@qilin-agent/schemastery": "~3.18.5",
|
|
59
|
+
"@qilin-agent/brand": "3.1.6"
|
|
58
60
|
},
|
|
59
61
|
"devDependencies": {
|
|
60
|
-
"@qilin-agent/kylin": "~4.0.
|
|
61
|
-
"@qilin-agent/agent": "3.1.
|
|
62
|
-
"@qilin-agent/ptc-runtime": "3.1.
|
|
63
|
-
"@qilin-agent/llm": "3.1.
|
|
64
|
-
"@qilin-agent/
|
|
65
|
-
"@qilin-agent/
|
|
66
|
-
"@qilin-agent/session
|
|
67
|
-
"@qilin-agent/
|
|
68
|
-
"@qilin-agent/
|
|
69
|
-
"@qilin-agent/
|
|
70
|
-
"@qilin-agent/
|
|
71
|
-
"@qilin-agent/
|
|
62
|
+
"@qilin-agent/kylin": "~4.0.5",
|
|
63
|
+
"@qilin-agent/agent": "3.1.6",
|
|
64
|
+
"@qilin-agent/ptc-runtime": "3.1.6",
|
|
65
|
+
"@qilin-agent/llm": "3.1.6",
|
|
66
|
+
"@qilin-agent/scope": "3.1.6",
|
|
67
|
+
"@qilin-agent/user-approval": "3.1.6",
|
|
68
|
+
"@qilin-agent/session": "3.1.6",
|
|
69
|
+
"@qilin-agent/system-prompt": "3.1.6",
|
|
70
|
+
"@qilin-agent/sandbox": "3.1.6",
|
|
71
|
+
"@qilin-agent/sandbox-policy": "3.1.6",
|
|
72
|
+
"@qilin-agent/working-directory": "3.1.6",
|
|
73
|
+
"@qilin-agent/session-projection": "3.1.6"
|
|
72
74
|
}
|
|
73
75
|
}
|