@kindgi/tools 0.0.0-bootstrap.0 → 0.1.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/LICENSE +201 -0
- package/README.md +86 -1
- package/dist/define.d.ts +138 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +318 -0
- package/dist/define.js.map +1 -0
- package/dist/errors.d.ts +113 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +4 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +213 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/invoke.d.ts +27 -0
- package/dist/invoke.d.ts.map +1 -0
- package/dist/invoke.js +127 -0
- package/dist/invoke.js.map +1 -0
- package/dist/manifest.d.ts +23 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +37 -0
- package/dist/manifest.js.map +1 -0
- package/dist/precondition.d.ts +25 -0
- package/dist/precondition.d.ts.map +1 -0
- package/dist/precondition.js +34 -0
- package/dist/precondition.js.map +1 -0
- package/dist/registry.d.ts +87 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +171 -0
- package/dist/registry.js.map +1 -0
- package/dist/spec-registry.d.ts +48 -0
- package/dist/spec-registry.d.ts.map +1 -0
- package/dist/spec-registry.js +37 -0
- package/dist/spec-registry.js.map +1 -0
- package/dist/tool.schema.json +297 -0
- package/dist/types.d.ts +508 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -4
- package/src/define.ts +537 -0
- package/src/errors.ts +139 -0
- package/src/http.ts +268 -0
- package/src/index.ts +68 -0
- package/src/invoke.ts +165 -0
- package/src/manifest.ts +40 -0
- package/src/precondition.ts +40 -0
- package/src/registry.ts +262 -0
- package/src/spec-registry.ts +78 -0
- package/src/tool.schema.json +297 -0
- package/src/types.ts +538 -0
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://kindgi.com/schemas/v1/tool.schema.json",
|
|
4
|
+
"$comment": "schema-version: 1.1.0",
|
|
5
|
+
"title": "Tool",
|
|
6
|
+
"description": "A tool definition. Authored once; the runtime picks transport (native in-process for tools built into the runtime, MCP over the wire for cross-process / cross-org / third-party tools). Every tool declares its typed I/O, its context needs (typed DI), and its side-effects — enabling policy enforcement and parallel scheduling by the kernel.",
|
|
7
|
+
"type": "object",
|
|
8
|
+
"required": ["id", "description", "version", "input", "output"],
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"id": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"minLength": 1,
|
|
14
|
+
"description": "Unique tool identifier. Convention: '<pack>.<tool>' (e.g. 'acme.verify-citation') or a bare id for tools built into Kindgi."
|
|
15
|
+
},
|
|
16
|
+
"description": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"minLength": 1,
|
|
19
|
+
"description": "Human- and LLM-readable description of what this tool does. Load-bearing: this is what the LLM sees when deciding to call the tool."
|
|
20
|
+
},
|
|
21
|
+
"version": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
|
|
24
|
+
},
|
|
25
|
+
"input": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"description": "JSON Schema for the tool input. MUST validate under Draft 2020-12."
|
|
28
|
+
},
|
|
29
|
+
"output": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"description": "JSON Schema for the tool output. MUST validate under Draft 2020-12."
|
|
32
|
+
},
|
|
33
|
+
"needs": {
|
|
34
|
+
"type": "array",
|
|
35
|
+
"items": {
|
|
36
|
+
"$ref": "#/$defs/Need"
|
|
37
|
+
},
|
|
38
|
+
"description": "Typed context requirements — named slots (e.g. `tenant`, `run`, `blob`, `memory:facts`) the runtime injects via `ToolContext`. Declarative: not checked when a flow is loaded. `needsSpec` is the typed, discriminated form."
|
|
39
|
+
},
|
|
40
|
+
"effects": {
|
|
41
|
+
"type": "array",
|
|
42
|
+
"items": {
|
|
43
|
+
"$ref": "#/$defs/Effect"
|
|
44
|
+
},
|
|
45
|
+
"description": "Declared side-effects. Enables policy enforcement (can this tool run in this tenant?), safe parallelization (are two calls conflicting?), and causal provenance."
|
|
46
|
+
},
|
|
47
|
+
"transport": {
|
|
48
|
+
"type": "string",
|
|
49
|
+
"enum": ["auto", "native", "mcp"],
|
|
50
|
+
"default": "auto",
|
|
51
|
+
"description": "Transport hint. 'auto' (default) lets the runtime pick native when possible, MCP otherwise. 'native' requires in-process execution. 'mcp' requires MCP execution. Deployment-time concern; authoring is unchanged."
|
|
52
|
+
},
|
|
53
|
+
"mcpEndpoint": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "If transport = 'mcp' (or resolved to MCP by 'auto'), the MCP endpoint URI. Format: 'mcp+stdio://<command>', 'mcp+http://<url>', 'mcp+sse://<url>'."
|
|
56
|
+
},
|
|
57
|
+
"metadata": {
|
|
58
|
+
"type": "object",
|
|
59
|
+
"additionalProperties": true,
|
|
60
|
+
"description": "Free-form annotations (author, docs URL, tags). Not interpreted by the kernel."
|
|
61
|
+
},
|
|
62
|
+
"sandbox": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"enum": ["none", "context-isolated", "strict"],
|
|
65
|
+
"description": "Isolation posture the runtime enforces around the handler. Optional additive field."
|
|
66
|
+
},
|
|
67
|
+
"mutating": {
|
|
68
|
+
"type": "boolean",
|
|
69
|
+
"description": "Semantic marker: `true` when this tool causes observable side effects (writes state, calls external APIs with mutations, sends messages). Read-only tools set `false`. Absent defaults to `true`. Consumed by the HITL default classifier — a read-only tool passes straight through, a mutating tool asks on first use."
|
|
70
|
+
},
|
|
71
|
+
"limits": {
|
|
72
|
+
"type": "object",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"description": "Sandbox-enforced resource caps at dispatch. Optional additive field.",
|
|
75
|
+
"properties": {
|
|
76
|
+
"memMB": { "type": "integer", "minimum": 1 },
|
|
77
|
+
"cpuMs": { "type": "integer", "minimum": 1 }
|
|
78
|
+
},
|
|
79
|
+
"required": ["memMB", "cpuMs"]
|
|
80
|
+
},
|
|
81
|
+
"network": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"description": "Network egress policy. Optional additive field. Discriminated on `kind`.",
|
|
84
|
+
"oneOf": [
|
|
85
|
+
{
|
|
86
|
+
"type": "object",
|
|
87
|
+
"additionalProperties": false,
|
|
88
|
+
"properties": { "kind": { "type": "string", "enum": ["none", "unrestricted"] } },
|
|
89
|
+
"required": ["kind"]
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "object",
|
|
93
|
+
"additionalProperties": false,
|
|
94
|
+
"properties": {
|
|
95
|
+
"kind": { "type": "string", "const": "allowlist" },
|
|
96
|
+
"hosts": { "type": "array", "items": { "type": "string", "minLength": 1 } }
|
|
97
|
+
},
|
|
98
|
+
"required": ["kind", "hosts"]
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"needsSpec": {
|
|
103
|
+
"type": "object",
|
|
104
|
+
"additionalProperties": false,
|
|
105
|
+
"description": "Typed discriminated needs (env / secrets / config / capabilities / bindings). Optional additive field.",
|
|
106
|
+
"properties": {
|
|
107
|
+
"env": { "type": "object", "additionalProperties": { "type": "object" } },
|
|
108
|
+
"secrets": { "type": "object", "additionalProperties": { "type": "object" } },
|
|
109
|
+
"config": { "type": "object", "additionalProperties": { "type": "object" } },
|
|
110
|
+
"capabilities": { "type": "array", "items": { "type": "string", "minLength": 1 } },
|
|
111
|
+
"bindings": { "type": "array", "items": { "type": "string", "minLength": 1 } }
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"codeArtifactRef": {
|
|
115
|
+
"description": "Handler-artifact pointer. Discriminated on `kind`: `oci` is the deploy-pipeline shape (image + module path + artifactVersion); `filesystem` is the local-development shape — absolute host path at the pack's on-disk handler file. Production servers SHOULD reject `filesystem`.",
|
|
116
|
+
"oneOf": [
|
|
117
|
+
{
|
|
118
|
+
"type": "object",
|
|
119
|
+
"additionalProperties": false,
|
|
120
|
+
"properties": {
|
|
121
|
+
"kind": { "const": "oci" },
|
|
122
|
+
"imageRef": { "type": "string", "minLength": 1 },
|
|
123
|
+
"modulePath": { "type": "string", "minLength": 1 },
|
|
124
|
+
"artifactVersion": { "type": "string", "minLength": 1 }
|
|
125
|
+
},
|
|
126
|
+
"required": ["kind", "imageRef", "modulePath", "artifactVersion"]
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"type": "object",
|
|
130
|
+
"additionalProperties": false,
|
|
131
|
+
"properties": {
|
|
132
|
+
"kind": { "const": "filesystem" },
|
|
133
|
+
"modulePath": { "type": "string", "minLength": 1 }
|
|
134
|
+
},
|
|
135
|
+
"required": ["kind", "modulePath"]
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
},
|
|
139
|
+
"spec": {
|
|
140
|
+
"description": "Declarative handler spec. Discriminated on `kind`; the framework's synthesizer registry maps kind → runtime handler. Mutually exclusive with an imperative handler at author time.",
|
|
141
|
+
"oneOf": [{ "$ref": "#/$defs/HttpToolSpec" }]
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"$defs": {
|
|
145
|
+
"Need": {
|
|
146
|
+
"type": "object",
|
|
147
|
+
"required": ["name"],
|
|
148
|
+
"additionalProperties": false,
|
|
149
|
+
"properties": {
|
|
150
|
+
"name": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"minLength": 1,
|
|
153
|
+
"description": "The named context slot (e.g. 'tenant', 'db', 'run', 'provenance', 'memory:facts', 'blob')."
|
|
154
|
+
},
|
|
155
|
+
"optional": {
|
|
156
|
+
"type": "boolean",
|
|
157
|
+
"default": false
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"Effect": {
|
|
162
|
+
"type": "object",
|
|
163
|
+
"required": ["kind"],
|
|
164
|
+
"additionalProperties": false,
|
|
165
|
+
"properties": {
|
|
166
|
+
"kind": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"enum": [
|
|
169
|
+
"reads",
|
|
170
|
+
"writes",
|
|
171
|
+
"deletes",
|
|
172
|
+
"network",
|
|
173
|
+
"spawns-run",
|
|
174
|
+
"emits-event",
|
|
175
|
+
"external-side-effect",
|
|
176
|
+
"sensitive-data-egress"
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
"resource": {
|
|
180
|
+
"type": "string",
|
|
181
|
+
"description": "Resource identifier (e.g. 'memory:facts', 'blob:*', 'external:api.example.com'). Used by the policy engine to authorize the effect."
|
|
182
|
+
},
|
|
183
|
+
"notes": {
|
|
184
|
+
"type": "string"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
"ToolSecretRef": {
|
|
189
|
+
"type": "object",
|
|
190
|
+
"additionalProperties": false,
|
|
191
|
+
"required": ["envName", "name"],
|
|
192
|
+
"properties": {
|
|
193
|
+
"envName": { "type": "string", "minLength": 1 },
|
|
194
|
+
"name": { "type": "string", "minLength": 1 }
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
"HttpHeaderSpec": {
|
|
198
|
+
"type": "object",
|
|
199
|
+
"additionalProperties": false,
|
|
200
|
+
"required": ["name", "value"],
|
|
201
|
+
"properties": {
|
|
202
|
+
"name": { "type": "string", "minLength": 1 },
|
|
203
|
+
"value": { "type": "string" }
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"HttpAuthSpec": {
|
|
207
|
+
"oneOf": [
|
|
208
|
+
{
|
|
209
|
+
"type": "object",
|
|
210
|
+
"additionalProperties": false,
|
|
211
|
+
"required": ["kind", "secretRef"],
|
|
212
|
+
"properties": {
|
|
213
|
+
"kind": { "const": "bearer" },
|
|
214
|
+
"secretRef": { "$ref": "#/$defs/ToolSecretRef" }
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"type": "object",
|
|
219
|
+
"additionalProperties": false,
|
|
220
|
+
"required": ["kind", "headerName", "secretRef"],
|
|
221
|
+
"properties": {
|
|
222
|
+
"kind": { "const": "header" },
|
|
223
|
+
"headerName": { "type": "string", "minLength": 1 },
|
|
224
|
+
"secretRef": { "$ref": "#/$defs/ToolSecretRef" }
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
]
|
|
228
|
+
},
|
|
229
|
+
"HttpRequestBodySpec": {
|
|
230
|
+
"oneOf": [
|
|
231
|
+
{
|
|
232
|
+
"type": "object",
|
|
233
|
+
"additionalProperties": false,
|
|
234
|
+
"required": ["kind"],
|
|
235
|
+
"properties": { "kind": { "const": "json-input" } }
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "object",
|
|
239
|
+
"additionalProperties": false,
|
|
240
|
+
"required": ["kind"],
|
|
241
|
+
"properties": { "kind": { "const": "input-passthrough" } }
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"type": "object",
|
|
245
|
+
"additionalProperties": false,
|
|
246
|
+
"required": ["kind", "template"],
|
|
247
|
+
"properties": {
|
|
248
|
+
"kind": { "const": "text" },
|
|
249
|
+
"template": { "type": "string" }
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
"HttpToolSpec": {
|
|
255
|
+
"type": "object",
|
|
256
|
+
"description": "Declarative HTTP-invocation spec. Attached to `ToolManifest.spec` under the discriminant `kind: 'http'`. The runtime `Tool.handler` is synthesized by the 'http' spec synthesizer to perform URL-template substitution, secret-ref resolution via `ToolContext.resolveSecret`, and the outbound fetch. All fields serialize cleanly to JSON.",
|
|
257
|
+
"additionalProperties": false,
|
|
258
|
+
"required": ["kind", "method", "urlTemplate"],
|
|
259
|
+
"properties": {
|
|
260
|
+
"kind": { "const": "http" },
|
|
261
|
+
"method": {
|
|
262
|
+
"type": "string",
|
|
263
|
+
"enum": ["GET", "POST", "PUT", "PATCH", "DELETE"]
|
|
264
|
+
},
|
|
265
|
+
"urlTemplate": {
|
|
266
|
+
"type": "string",
|
|
267
|
+
"minLength": 1,
|
|
268
|
+
"description": "URL template with `{param}` placeholders substituted from the tool's input at invoke time."
|
|
269
|
+
},
|
|
270
|
+
"headers": {
|
|
271
|
+
"type": "array",
|
|
272
|
+
"items": { "$ref": "#/$defs/HttpHeaderSpec" }
|
|
273
|
+
},
|
|
274
|
+
"authorization": { "$ref": "#/$defs/HttpAuthSpec" },
|
|
275
|
+
"requestBody": { "$ref": "#/$defs/HttpRequestBodySpec" },
|
|
276
|
+
"timeoutMs": {
|
|
277
|
+
"type": "integer",
|
|
278
|
+
"minimum": 1,
|
|
279
|
+
"description": "Wall-clock timeout in ms. Default 30000."
|
|
280
|
+
},
|
|
281
|
+
"parseJson": {
|
|
282
|
+
"type": "boolean",
|
|
283
|
+
"description": "When true (default), the response body is parsed as JSON before returning to the invoker."
|
|
284
|
+
},
|
|
285
|
+
"successStatus": {
|
|
286
|
+
"type": "object",
|
|
287
|
+
"additionalProperties": false,
|
|
288
|
+
"required": ["min", "max"],
|
|
289
|
+
"properties": {
|
|
290
|
+
"min": { "type": "integer", "minimum": 100, "maximum": 599 },
|
|
291
|
+
"max": { "type": "integer", "minimum": 100, "maximum": 599 }
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|