- Added the `xd://` virtual device protocol (`internal-urls/xd-protocol.ts`, `tools/xdev.ts`): tools declaring `loadMode: "discoverable"` are unmounted from the request tools array and driven via `read xd://` (list/docs+schema) and `write xd://<tool>` (execute), gated by the `tools.xdev` setting (default on) and inlined into the system prompt. - Merged the `irc`, `job`, and `launch` tools into a single `hub` tool (`tools/hub/`, `async/job-manager.ts`): messaging keeps `send`/`inbox`/`list`, job control maps to `wait`/`cancel`/`jobs`, process supervision keeps `start`/`logs`/`stop`/`restart`/`describe` with `ps`, and the unified `wait` races background jobs against peer messages; SDK `IrcTool`/`JobTool`/`LaunchTool` are replaced by `HubTool`. - Removed the hidden `resolve` tool in favor of the `xd://resolve`/`xd://reject`/`xd://propose` resolution devices, auto-including `write` whenever a deferrable tool or plan mode is present. - Removed the BM25 tool-discovery system: the `search_tool_bm25` tool, the `tool-discovery` module, the `tools.discoveryMode`/`mcp.discoveryMode`/`mcp.discoveryDefaultServers`/`tools.essentialOverride` settings, per-tool MCP selection, and the `mcp_tool_selection` message type. - Unified tool presentation on `ToolLoadMode` (`essential`|`discoverable`), replacing the custom-tool `xdev?: boolean` opt-out; custom, extension, MCP, RPC host, image-generation, and TTS tools now default to `discoverable`, and added a `satisfies` predicate to `SoftToolRequirement`. - Removed the standalone `ssh` command tool and `ssh/ssh-executor` (the `ssh://` read/write/search protocol stays), and made `--tools` address hidden built-ins. - Updated collab-web to render `xd://` dispatches and `hub` op families, dropped the `search_tool_bm25`/`ssh`/`report-finding` renderers, refreshed tool docs and prompts, and migrated the affected tests and changelogs.
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
/**
|
|
* CustomToolAdapter wraps CustomTool instances into AgentTool for use with the agent.
|
|
*/
|
|
import type { AgentTool, AgentToolUpdateCallback, ToolLoadMode } from "@oh-my-pi/pi-agent-core";
|
|
import type { Static, TSchema } from "@oh-my-pi/pi-ai";
|
|
import type { Theme } from "../../modes/theme/theme";
|
|
import { applyToolProxy } from "../tool-proxy";
|
|
import type { CustomTool, CustomToolContext } from "./types";
|
|
|
|
export class CustomToolAdapter<TParams extends TSchema = TSchema, TDetails = any, TTheme extends Theme = Theme>
|
|
implements AgentTool<TParams, TDetails, TTheme>
|
|
{
|
|
declare name: string;
|
|
declare label: string;
|
|
declare description: string;
|
|
declare parameters: TParams;
|
|
readonly strict: boolean | undefined;
|
|
readonly loadMode: ToolLoadMode;
|
|
|
|
constructor(
|
|
private tool: CustomTool<TParams, TDetails>,
|
|
private getContext: () => CustomToolContext,
|
|
) {
|
|
applyToolProxy(tool, this);
|
|
this.strict = tool.strict;
|
|
this.loadMode = tool.loadMode ?? "discoverable";
|
|
}
|
|
|
|
execute(
|
|
toolCallId: string,
|
|
params: Static<TParams>,
|
|
signal?: AbortSignal,
|
|
onUpdate?: AgentToolUpdateCallback<TDetails, TParams>,
|
|
context?: CustomToolContext,
|
|
) {
|
|
return this.tool.execute(toolCallId, params, onUpdate, context ?? this.getContext(), signal);
|
|
}
|
|
|
|
/**
|
|
* Backward-compatible export of factory function for existing callers.
|
|
* Prefer CustomToolAdapter constructor directly.
|
|
*/
|
|
static wrap<TParams extends TSchema = TSchema, TDetails = any, TTheme extends Theme = Theme>(
|
|
tool: CustomTool<TParams, TDetails>,
|
|
getContext: () => CustomToolContext,
|
|
): AgentTool<TParams, TDetails, TTheme> {
|
|
return new CustomToolAdapter(tool, getContext);
|
|
}
|
|
}
|