summaryrefslogtreecommitdiffhomepage
path: root/packages/kernel/src/contracts/tool.ts
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-27 01:09:39 +0900
committerAdam Malczewski <[email protected]>2026-06-27 01:09:39 +0900
commit61e45e60d699ed1ca46f94a8f181c92a940317c6 (patch)
tree2892d9773c5a8e367e1e58cdb1e88d9c6ad3fe6d /packages/kernel/src/contracts/tool.ts
parent63c7e64532e85e0bbdd6d9ac6825d8f86be98e7a (diff)
parent727c98c9dae516a2070eb950410314380a20c974 (diff)
downloaddispatch-61e45e60d699ed1ca46f94a8f181c92a940317c6.tar.gz
dispatch-61e45e60d699ed1ca46f94a8f181c92a940317c6.zip
Merge branch 'feature/indent-change' into dev
Diffstat (limited to 'packages/kernel/src/contracts/tool.ts')
-rw-r--r--packages/kernel/src/contracts/tool.ts178
1 files changed, 89 insertions, 89 deletions
diff --git a/packages/kernel/src/contracts/tool.ts b/packages/kernel/src/contracts/tool.ts
index 589fbd0..897b86e 100644
--- a/packages/kernel/src/contracts/tool.ts
+++ b/packages/kernel/src/contracts/tool.ts
@@ -16,22 +16,22 @@ import type { Logger } from "./logging.js";
* Using a structural type (not a library) keeps the kernel dependency-free.
*/
export interface ToolParameterSchema {
- readonly type: "object";
- readonly properties?: Readonly<Record<string, JsonSchemaProperty>>;
- readonly required?: readonly string[];
- readonly additionalProperties?: boolean;
- readonly description?: string;
+ readonly type: "object";
+ readonly properties?: Readonly<Record<string, JsonSchemaProperty>>;
+ readonly required?: readonly string[];
+ readonly additionalProperties?: boolean;
+ readonly description?: string;
}
/** A single property within a tool's parameter schema. */
export interface JsonSchemaProperty {
- readonly type?: string;
- readonly description?: string;
- readonly enum?: readonly string[];
- readonly items?: JsonSchemaProperty;
- readonly properties?: Readonly<Record<string, JsonSchemaProperty>>;
- readonly required?: readonly string[];
- readonly default?: unknown;
+ readonly type?: string;
+ readonly description?: string;
+ readonly enum?: readonly string[];
+ readonly items?: JsonSchemaProperty;
+ readonly properties?: Readonly<Record<string, JsonSchemaProperty>>;
+ readonly required?: readonly string[];
+ readonly default?: unknown;
}
/**
@@ -40,56 +40,56 @@ export interface JsonSchemaProperty {
* concurrent tool output is never interleaved ambiguously.
*/
export interface ToolExecuteContext {
- /** Unique id of the tool-call this execution serves. */
- readonly toolCallId: string;
-
- /**
- * Stream output from the tool. The kernel attributes every call to the
- * tool-call id, so concurrent shell output from different tools is
- * correctly separated.
- */
- readonly onOutput: (data: string, stream: "stdout" | "stderr") => void;
-
- /**
- * Cancellation signal. An aborted turn sets this so in-flight tool work
- * can clean up rather than leak.
- */
- readonly signal: AbortSignal;
-
- /**
- * Pre-bound Logger scoped to this tool-call span. Tools log correlated
- * without a global (P3). The kernel stamps extensionId, conversationId,
- * turnId, and spanId automatically.
- */
- readonly log: Logger;
-
- /**
- * Working directory for this turn, forwarded verbatim from `RunTurnInput.cwd`.
- * Tools that touch the filesystem resolve and contain paths against it.
- * Optional: when omitted, a tool falls back to its own configured/default
- * workdir. The kernel never interprets it.
- */
- readonly cwd?: string;
-
- /**
- * The conversation this tool-call belongs to. Tools that maintain
- * per-conversation state (e.g. a todo list) key on this. Forwarded
- * verbatim from `RunTurnInput.conversationId`. Optional: when omitted,
- * a tool has no conversation scope (e.g. a global tool).
- */
- readonly conversationId?: string;
-
- /**
- * The computer this tool-call executes on (SSH support). When
- * omitted/undefined, execution is LOCAL (today's behavior — the tool uses
- * the local node fs/child_process). When set, it is an SSH config alias
- * (see `notes/ssh-support-plan.md` §3); a tool resolves a remote
- * `ExecBackend` for it via its injected resolver. The kernel never
- * interprets it — it forwards the value verbatim from
- * `RunTurnInput.computerId`, exactly like `cwd`. It never enters the model
- * prompt, so it does not affect prompt caching.
- */
- readonly computerId?: string;
+ /** Unique id of the tool-call this execution serves. */
+ readonly toolCallId: string;
+
+ /**
+ * Stream output from the tool. The kernel attributes every call to the
+ * tool-call id, so concurrent shell output from different tools is
+ * correctly separated.
+ */
+ readonly onOutput: (data: string, stream: "stdout" | "stderr") => void;
+
+ /**
+ * Cancellation signal. An aborted turn sets this so in-flight tool work
+ * can clean up rather than leak.
+ */
+ readonly signal: AbortSignal;
+
+ /**
+ * Pre-bound Logger scoped to this tool-call span. Tools log correlated
+ * without a global (P3). The kernel stamps extensionId, conversationId,
+ * turnId, and spanId automatically.
+ */
+ readonly log: Logger;
+
+ /**
+ * Working directory for this turn, forwarded verbatim from `RunTurnInput.cwd`.
+ * Tools that touch the filesystem resolve and contain paths against it.
+ * Optional: when omitted, a tool falls back to its own configured/default
+ * workdir. The kernel never interprets it.
+ */
+ readonly cwd?: string;
+
+ /**
+ * The conversation this tool-call belongs to. Tools that maintain
+ * per-conversation state (e.g. a todo list) key on this. Forwarded
+ * verbatim from `RunTurnInput.conversationId`. Optional: when omitted,
+ * a tool has no conversation scope (e.g. a global tool).
+ */
+ readonly conversationId?: string;
+
+ /**
+ * The computer this tool-call executes on (SSH support). When
+ * omitted/undefined, execution is LOCAL (today's behavior — the tool uses
+ * the local node fs/child_process). When set, it is an SSH config alias
+ * (see `notes/ssh-support-plan.md` §3); a tool resolves a remote
+ * `ExecBackend` for it via its injected resolver. The kernel never
+ * interprets it — it forwards the value verbatim from
+ * `RunTurnInput.computerId`, exactly like `cwd`. It never enters the model
+ * prompt, so it does not affect prompt caching.
+ */
+ readonly computerId?: string;
}
/**
@@ -98,8 +98,8 @@ export interface ToolExecuteContext {
* react without the kernel interpreting the content.
*/
export interface ToolResult {
- readonly content: string;
- readonly isError?: boolean;
+ readonly content: string;
+ readonly isError?: boolean;
}
/**
@@ -108,9 +108,9 @@ export interface ToolResult {
* to the matched tool's `execute`.
*/
export interface ToolCall {
- readonly id: string;
- readonly name: string;
- readonly input: unknown;
+ readonly id: string;
+ readonly name: string;
+ readonly input: unknown;
}
/**
@@ -119,26 +119,26 @@ export interface ToolCall {
* concrete tools exist.
*/
export interface ToolContract {
- /** Unique name the model uses to invoke this tool. */
- readonly name: string;
-
- /** Human-readable description shown to the model. */
- readonly description: string;
-
- /** JSON-Schema-ish parameter declaration (structural, no library dep). */
- readonly parameters: ToolParameterSchema;
-
- /**
- * Execute the tool with parsed input. The kernel provides a per-call
- * context (cancellation, output streaming, attribution).
- */
- readonly execute: (args: unknown, ctx: ToolExecuteContext) => Promise<ToolResult>;
-
- /**
- * Whether this tool is safe to run concurrently with other tools.
- * When `false`, the kernel serializes this tool's calls even when the
- * dispatch policy allows parallelism. Defaults to `true` if omitted.
- * This overrides the global setting downward only (never widens parallelism).
- */
- readonly concurrencySafe?: boolean;
+ /** Unique name the model uses to invoke this tool. */
+ readonly name: string;
+
+ /** Human-readable description shown to the model. */
+ readonly description: string;
+
+ /** JSON-Schema-ish parameter declaration (structural, no library dep). */
+ readonly parameters: ToolParameterSchema;
+
+ /**
+ * Execute the tool with parsed input. The kernel provides a per-call
+ * context (cancellation, output streaming, attribution).
+ */
+ readonly execute: (args: unknown, ctx: ToolExecuteContext) => Promise<ToolResult>;
+
+ /**
+ * Whether this tool is safe to run concurrently with other tools.
+ * When `false`, the kernel serializes this tool's calls even when the
+ * dispatch policy allows parallelism. Defaults to `true` if omitted.
+ * This overrides the global setting downward only (never widens parallelism).
+ */
+ readonly concurrencySafe?: boolean;
}