feat: added native tool inventory rendering with TypeScript signatures

- Added `jsonSchemaToTypeScript` and `renderToolInventory` to generate tool blocks with TypeScript signatures.
- Added `examples` and `TSchema` fields to dump-tool metadata and passed them through prompt rendering.
- Changed Harmony invocation rendering to omit `<|constrain|>json` markers in tool call payloads.
- Added compact native tool list-mode inventory rendering with full `# Tool:` output elsewhere.
This commit is contained in:
can1357
2026-06-15 08:12:58 +02:00
parent ba82ed6e59
commit 8b7dd10a8a
23 changed files with 603 additions and 100 deletions
@@ -6,7 +6,7 @@
* in-process and sharing auth/model infrastructure across tasks.
*/
import type { AgentEvent, AgentMessage, ResolvedThinkingLevel, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
import type { Model } from "@oh-my-pi/pi-ai";
import type { Model, ToolExample } from "@oh-my-pi/pi-ai";
import type { AgentSession, AgentSessionEvent, AuthStorage, SessionStats } from "@oh-my-pi/pi-coding-agent";
import {
type CreateAgentSessionResult,
@@ -169,7 +169,7 @@ export class InProcessClient {
systemPrompt?: string[];
model?: Model;
thinkingLevel?: ThinkingLevel | undefined;
dumpTools?: Array<{ name: string; description: string; parameters: unknown }>;
dumpTools?: Array<{ name: string; description: string; parameters: unknown; examples?: readonly ToolExample[] }>;
}> {
const session = this.#session!;
return {
@@ -181,6 +181,7 @@ export class InProcessClient {
name: tool.name,
description: tool.description,
parameters: tool.parameters,
examples: tool.examples,
})),
};
}
@@ -9,7 +9,7 @@ import * as fs from "node:fs";
import * as path from "node:path";
import { formatHashlineHeader, InMemorySnapshotStore } from "@oh-my-pi/hashline";
import type { AgentMessage, ResolvedThinkingLevel, ThinkingLevel } from "@oh-my-pi/pi-agent-core";
import type { Model } from "@oh-my-pi/pi-ai";
import type { Model, ToolExample } from "@oh-my-pi/pi-ai";
import { formatSessionDumpText, RpcClient } from "@oh-my-pi/pi-coding-agent";
import { prompt } from "@oh-my-pi/pi-utils";
import { diffLines } from "diff";
@@ -37,7 +37,7 @@ type ConversationDumpSessionState = {
systemPrompt?: string[];
model?: Model;
thinkingLevel?: ThinkingLevel | undefined;
dumpTools?: Array<{ name: string; description: string; parameters: unknown }>;
dumpTools?: Array<{ name: string; description: string; parameters: unknown; examples?: readonly ToolExample[] }>;
};
/** Common interface for both RPC and in-process clients */
@@ -103,7 +103,7 @@ type ConversationDumpSnapshot = {
systemPrompt?: string[];
model?: Model;
thinkingLevel?: ThinkingLevel | undefined;
dumpTools?: Array<{ name: string; description: string; parameters: unknown }>;
dumpTools?: Array<{ name: string; description: string; parameters: unknown; examples?: readonly ToolExample[] }>;
};
function sanitizeDumpPathSegment(value: string): string {