Files
oh-my-pi/packages/coding-agent/src/tools/context.ts
T
can1357 9afedb591e feat(coding-agent): added opt-in task prewalk and tightened --tools and xdev behavior
- Added a `task.prewalk` option (default `false`), removed default task `prewalk` flags, and updated prewalk resolution so bunded generic task execution only prewalks when explicitly enabled.
- Enforced strict `--tools` validation in CLI parsing, making unknown tool names fail fast with `CliUsageError` instead of being silently filtered.
- Migrated legacy discovery settings (`tools.discoveryMode`, `tools.essentialOverride`, MCP discovery keys) into updated `tools.xdev` handling with preserved explicit override behavior.
- Hardened xdev/ACP execution flow by capping `docsAll` payloads with overflow listing and remapping `xd://` dispatches/approval gating for correct execute/read behavior and reduced duplicate prompts.
2026-07-15 18:39:36 +02:00

45 lines
1.3 KiB
TypeScript

import type { AgentToolContext, ToolCallContext } from "@oh-my-pi/pi-agent-core";
import type { CustomToolContext } from "../extensibility/custom-tools/types";
import type { ExtensionUIContext } from "../extensibility/extensions/types";
declare module "@oh-my-pi/pi-agent-core" {
interface AgentToolContext extends CustomToolContext {
ui?: ExtensionUIContext;
hasUI?: boolean;
toolNames?: string[];
toolCall?: ToolCallContext;
/** Set on `xd://` device dispatches: the write tool's outer approval gate
* already resolved this call at the mounted tool's tier, so the inner
* wrapper must not re-prompt for the same action (explicit per-tool
* policies and overrides still apply). */
xdevApproved?: boolean;
}
}
export class ToolContextStore {
#uiContext: ExtensionUIContext | undefined;
#hasUI = false;
#toolNames: string[] = [];
constructor(private readonly getBaseContext: () => CustomToolContext) {}
getContext(toolCall?: ToolCallContext): AgentToolContext {
return {
...this.getBaseContext(),
ui: this.#uiContext,
hasUI: this.#hasUI,
toolNames: this.#toolNames,
toolCall,
};
}
setUIContext(uiContext: ExtensionUIContext, hasUI: boolean): void {
this.#uiContext = uiContext;
this.#hasUI = hasUI;
}
setToolNames(names: string[]): void {
this.#toolNames = names;
}
}