@qilin-agent/tools 0.0.0-stage → 3.1.3
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/LICENSE +21 -0
- package/README.i18n.yaml +103 -0
- package/README.md +239 -2
- package/README.zh.md +240 -0
- package/lib/index.js +3705 -0
- package/lib/types/index.d.ts +844 -0
- package/lib/types/index.js +1334 -0
- package/lib/types/json-schema.d.ts +106 -0
- package/lib/types/json-schema.js +577 -0
- package/lib/types/presentation.d.ts +367 -0
- package/lib/types/presentation.js +8 -0
- package/lib/types/ptc.d.ts +80 -0
- package/lib/types/ptc.js +660 -0
- package/lib/types/py-types.d.ts +49 -0
- package/lib/types/py-types.js +788 -0
- package/lib/types/schema.d.ts +243 -0
- package/lib/types/schema.js +350 -0
- package/lib/types/testing.d.ts +25 -0
- package/lib/types/testing.js +25 -0
- package/lib/types/ts-types.d.ts +37 -0
- package/lib/types/ts-types.js +291 -0
- package/lib/types/types.d.ts +61 -0
- package/lib/types/types.js +7 -0
- package/package.json +68 -3
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PTC mode codegen — Python flavor. The pure projection from registered tool schemas to the
|
|
3
|
+
* Python SDK text the model programs against under `runtime.language === 'python'`. Sibling of
|
|
4
|
+
* {@link ./ts-types.ts | ts-types.ts}; the two files are two projections of the same registry
|
|
5
|
+
* store, keyed by the loaded {@link @qilin-agent/ptc-runtime#PtcRuntime.language | PTC
|
|
6
|
+
* runtime's language}.
|
|
7
|
+
*
|
|
8
|
+
* Under `mode: 'ptc'` the native tool schemas are omitted from the request, so this generated
|
|
9
|
+
* SDK is the model's ONLY source for each tool's argument names, required fields, types,
|
|
10
|
+
* descriptions, and canonical output shapes; under `mode: 'both'` the native schemas ship
|
|
11
|
+
* alongside it and it is one of two. Object-shaped arguments and outputs therefore render as one
|
|
12
|
+
* named `TypedDict` per tool (and per nested object), not an opaque `dict[str, Any]`, so the
|
|
13
|
+
* shape survives into the program under the mode that has nothing else to carry it.
|
|
14
|
+
* @module @qilin-agent/tools/src/py-types
|
|
15
|
+
*/
|
|
16
|
+
import type { ToolSdkSchema } from './ts-types.ts';
|
|
17
|
+
/**
|
|
18
|
+
* Map one JSON-Schema node to a context-free Python type expression from the
|
|
19
|
+
* `typing` module. Handles every unified schema construct — `object` (degraded
|
|
20
|
+
* to `dict[str, Any]`: naming a `TypedDict` requires the render context that
|
|
21
|
+
* {@link renderToolsSdkPy} supplies), `const`/`enum` (→ `Literal[...]`),
|
|
22
|
+
* `oneOf` (→ union), `string`/`number`/`integer`/`boolean`/`null`, `array`
|
|
23
|
+
* (`items` → `list[T]`) — and returns `Any` for an unsupported or malformed
|
|
24
|
+
* schema, matching the TS flavor's `unknown` fallback. Type annotations in the
|
|
25
|
+
* emitted SDK are advisory: Python does not enforce them at runtime.
|
|
26
|
+
* @param schema - the JSON-Schema node.
|
|
27
|
+
* @returns the Python type text.
|
|
28
|
+
*/
|
|
29
|
+
export declare function jsonSchemaToPy(schema: unknown): string;
|
|
30
|
+
/**
|
|
31
|
+
* Render the full `tools:sdk` prompt section under `runtime.language ===
|
|
32
|
+
* 'python'`: the Python-flavored usage instructions plus one named `TypedDict`
|
|
33
|
+
* per tool argument or output object (and per nested object) and one awaitable
|
|
34
|
+
* method per visible tool on a `Tools` protocol — typed args in, the tool's
|
|
35
|
+
* canonical output value out — with a `tools: Tools` singleton the model calls
|
|
36
|
+
* into. The `typing` import line lists exactly the symbols the render used.
|
|
37
|
+
* Deterministic — tools are emitted in lexicographic name order, and class
|
|
38
|
+
* declarations precede the protocol in that same order (nested classes before
|
|
39
|
+
* the parent that references them), so an unchanged tool set produces
|
|
40
|
+
* byte-identical text across assemblies. The sort is not a total order on
|
|
41
|
+
* byte-equal names, so two schemas sharing a name would render in argument
|
|
42
|
+
* order; the caller's visible-capability map is keyed by name, so the input
|
|
43
|
+
* never carries a duplicate.
|
|
44
|
+
* @param schemas - the tool schemas plus canonical output schemas to declare
|
|
45
|
+
* (the caller excludes `run_code` itself).
|
|
46
|
+
* @returns the complete section text.
|
|
47
|
+
*/
|
|
48
|
+
export declare function renderToolsSdkPy(schemas: ToolSdkSchema[]): string;
|
|
49
|
+
//# sourceMappingURL=py-types.d.ts.map
|