Tool
The runtime object: manifest + local handler. Only exists in-process;
handler is stripped when the tool is projected to a manifest for
serialisation, MCP exposure, or discovery.
Type parameters are caller-asserted — the runtime validates against
input / output JSON Schema, not the TS type — but let authors write
typed handlers when they know the shape.
Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
TInput |
unknown |
TOutput |
unknown |
Properties
Section titled “Properties”| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
codeArtifactRef? |
readonly |
CodeArtifactRef |
Signed pointer at the deploy-time OCI image + module path carrying the handler bytes. Absent for in-process manifests. | ToolManifest.codeArtifactRef |
description |
readonly |
string |
Human-readable one-liner describing what the tool does. Surfaced to the model as part of the tool definition (ModelToolDefinition.description) — the model uses it to decide when to call. Write it for the model: what the tool DOES, what it RETURNS, and when to prefer it over other tools. Skip implementation details. |
ToolManifest.description |
effects? |
readonly |
readonly Effect[] |
Declared side-effects the tool causes — an EFFECT_KINDS kind (writes, network, external-side-effect, …), optionally with the resource it targets. Consumed by policy + audit machinery for effect-based gating (e.g. "block any tool with an external-side-effect in a dry-run"). Distinct from mutating — effects names WHICH effects; mutating is a coarser boolean. |
ToolManifest.effects |
handler |
readonly |
(input, ctx) => Promise<TOutput> |
The runtime handler — the function invokeTool actually calls. Types are caller-asserted (matches the defineTool generics); the runtime validates against input / output JSON Schema at every invocation, not the TS type. |
- |
id |
readonly |
ToolId |
Globally-unique tool identifier. Convention: <pack-id>.<tool-name> (kebab-case, dot-namespaced) — e.g. acme.verify-citation, acme.fetch-order. The <pack-id> prefix scopes the tool to its pack; <tool-name> names the operation. defineTool checks only that the id isn't empty and doesn't start with kindgi_, which is kept for tools built into Kindgi. |
ToolManifest.id |
input |
readonly |
JsonSchema |
JSON Schema Draft 2020-12 for the tool's input. Handed to the model as the tool's parameter schema so it can generate valid calls. invokeTool validates every incoming input against this before invoking the handler — invalid input surfaces as a bad-input error, never reaches the handler. Zod authors: pass a Zod v4 schema to defineTool({input: zSchema}); the framework converts to JSON Schema at author time and preserves the Zod schema on tool.inputZod for TS-side inference. |
ToolManifest.input |
inputZod? |
readonly |
ZodLikeSchema |
The original Zod schema, preserved when the tool was authored with a Zod v4 schema at the input slot. Present iff the author passed a Zod schema to defineTool; otherwise undefined. Wire form is always the converted JSON Schema on input — this field exists so TS callers can z.infer<typeof tool.inputZod> for static types. Explicitly `ZodLikeSchema |
undefined(not a bare optional marker): the more specificDefinedTool<TInSchema, TOutSchema>returned bydefineToolnarrows this to the exact Zod schema type when Zod is used, and toundefinedwhen JSON Schema is used. Consumers reading a heterogeneousAnyToolsee the union and narrow with!== undefined`. |
limits? |
readonly |
RuntimeLimits |
Memory + CPU caps enforced by the sandbox at dispatch. | ToolManifest.limits |
mcpEndpoint? |
readonly |
string |
MCP server URL for transport: 'mcp' tools. Ignored when transport is native. See the Model Context Protocol spec for the expected endpoint shape. |
ToolManifest.mcpEndpoint |
metadata? |
readonly |
Readonly<Record<string, unknown>> |
Free-form key/value metadata that rides along with the manifest. Not interpreted by the framework — passthrough for pack-authored annotations (e.g. {owner: 'team-legal', ticket: 'PROJ-123'}). Surfaced in GET /v1/tools/:id responses for tooling. |
ToolManifest.metadata |
mutating? |
readonly |
boolean |
Semantic marker: true when this tool causes observable side effects (writes state, calls external APIs with mutations, sends messages, etc.). Read-only tools (queries, computations, retrievals) set false. Absent = defaults to true (safer — the framework's never_ask / ask_on_first_use / always_ask policy defaults hinge on this flag; mistakenly marking a mutating tool as read-only would bypass HITL, while the reverse only adds friction). Consumed by @kindgi/agents as the per-tool HITL default when an agent's conversationPolicy.hitl.tools sets neither an override nor a default for the tool — a read-only tool passes straight through, and a mutating tool asks before each call. It also decides what runs together: calls to read-only tools that a model step asks for one after another run at the same time, up to 8 at once, unless the agent sets parallelToolCalls: false; a call to a mutating tool runs on its own, and so does a call to a read-only tool that pauses or declares connections, since it may wait. |
ToolManifest.mutating |
needs? |
readonly |
readonly Need[] |
Named context slots the tool depends on (e.g. tenant, run, blob, memory:facts). Framework-level dependencies the tool expects the runtime to inject via ToolContext. Declarative: not checked when a flow is loaded. needsSpec is the typed, discriminated form (env / secrets / config / capabilities / bindings). |
ToolManifest.needs |
needsApprovalWhenUnattended? |
readonly |
boolean |
true when a person must say yes to every call of this tool in a run no person started: one a schedule, a webhook, an event, a mail or a service account's key started (RunStartedBy other than person, or none). In such a run, an agent's call of the tool waits for a person's yes whatever the agent's conversationPolicy.hitl.tools says (the agent's rules can't lift it), and a flow's tool step that calls it is refused. A webhook trigger, a schedule or a mail trigger whose toolsAllowedUnattended names the tool (a project admin's to set) lifts that, in its own runs only. In a run a person started, the agent's rules decide, as for any tool. Absent = false. A tool that uses a person's connection (a needsSpec.connections entry as: 'person'), reads included, counts as declaring it, whatever this or mutating says: false doesn't lift it. In a run a mail started, so does a tool that isn't read-only (mutating: false), and one that uses a connection of the run's own mailbox. Declare it on a tool that moves money or changes something people rely on, so that an agent reused under a trigger can't run it with no one asked. |
ToolManifest.needsApprovalWhenUnattended |
needsSpec? |
readonly |
TypedNeeds |
Discriminated typed-dependency declarations (env / secrets / config / capabilities / bindings). See TypedNeeds for the shape. |
ToolManifest.needsSpec |
network? |
readonly |
NetworkPolicy |
Network egress policy the sandbox honors. | ToolManifest.network |
output |
readonly |
JsonSchema |
JSON Schema Draft 2020-12 for the tool's output. invokeTool validates the handler's return value against this before surfacing it — a handler that returns off-schema fails with bad-output. Same Zod-conversion story as input. Prefer explicit schemas over type: 'object', additionalProperties: true — the model uses the output schema to interpret tool results downstream. |
ToolManifest.output |
outputZod? |
readonly |
ZodLikeSchema |
Symmetric to inputZod for the output slot. |
- |
pauses? |
readonly |
boolean |
true when the tool may make its run wait for another system's answer. Each call's handler gets ctx.waitToken: it hands the token's link to that system and returns ctx.pause(). The run waits until the system posts its answer, valid against output, which becomes the call's result; or until the pause's time passes (24 hours by default, at most 24 days), which fails the call with wait-token-timed-out. Only a pack tool with a handler can pause: not one with a declarative spec, nor an MCP tool. Absent = false. |
ToolManifest.pauses |
readsFiles? |
readonly |
boolean |
true when the tool may read stored files' bytes, such as a PDF an agent was given, to parse it. Each call's handler gets ctx.files.read, which answers the bytes of a file the call's run may be shown, by its file value's artifactId. Only a tool with a handler can read files: not one with a declarative spec, nor an MCP tool. Absent = false. |
ToolManifest.readsFiles |
resultIsOutsideData? |
readonly |
boolean |
true when the tool's results are text from outside that nobody checked, such as a mail someone sent or a page a search found. An agent reads each result of the tool as data, not instructions: in an <event> block, and so again in every later turn's history. It changes what the model is told, not what the tool may do: pair it with approvals for anything an agent could do with what it read. A tool whose results carry stored files from outside (a mail's attachments) sets it too, so the rule that they're data is in the agent's system message from the turn's start. Absent = false. |
ToolManifest.resultIsOutsideData |
sandbox? |
readonly |
SandboxMode |
Isolation posture — see SandboxMode. |
ToolManifest.sandbox |
spec? |
readonly |
HttpToolSpec |
Declarative handler specification. When present, the runtime Tool.handler is synthesized from this spec — the manifest carries everything needed for a first-party framework synthesizer to build the fetch/query/dispatch call at register time. Author writes the spec; framework owns the correctness bits (timeouts, aborts, secret resolution, retries). Discriminated on spec.kind. The framework ships 'http' (see HttpToolSpec) as the first-party kind; other kinds plug in via registerToolSpecSynthesizer. spec and handler are MUTUALLY EXCLUSIVE at defineTool time — a tool is either declarative or imperative. Mixed usage fails to compile. The full JSON-serializable manifest (spec included) is what POST /v1/tools accepts — declarative tools can be registered from configuration without shipping code. |
ToolManifest.spec |
storesFiles? |
readonly |
boolean |
true when the tool may store files it fetches, such as a mail's attachments, as files its run owns. The handler of each call with an idempotencyKey gets ctx.files.store: it stores a file there and returns the file value it gets back in its result's top-level files, so an agent is shown the file. At most MAX_STORED_FILES_PER_CALL files a call. Only a tool with a handler can store files: not one with a declarative spec, nor an MCP tool. Absent = false. |
ToolManifest.storesFiles |
transport? |
readonly |
"mcp" | "auto" | "native" |
How the tool is dispatched at invoke time. 'native' (default) uses the framework's in-process dispatch; 'mcp' routes through the Model Context Protocol endpoint declared at mcpEndpoint; 'auto' picks native if a handler exists, else mcp. Most pack-authored tools omit this and default to native. |
ToolManifest.transport |
updatesFiles? |
readonly |
boolean |
true when the tool may add versions to files its run has, such as a sheet it fills in. The handler of each call with an idempotencyKey gets ctx.files.update: it sends a file's new bytes with the version it read, and returns the new version it gets back in its result's top-level files. When the file's Latest isn't the version it read, it gets Latest back instead. Only a file of the call's run, and only where the run may write. Only a tool with a handler can update files: not one with a declarative spec, nor an MCP tool. Absent = false. |
ToolManifest.updatesFiles |
version |
readonly |
string |
Semver — REQUIRED. Every tool registered in a Kindgi deployment ships versioned; an agent's tools[].version is a semver range matched against these versions at dispatch time via semver.maxSatisfying. Enforced by defineTool(...) at the API boundary. |
ToolManifest.version |