docs(agent): document harness resource types

This commit is contained in:
Mario Zechner
2026-05-07 11:26:15 +02:00
parent af2b3ee243
commit 65206cfba8
2 changed files with 19 additions and 8 deletions

View File

@@ -2,22 +2,35 @@ import type { ImageContent, Model, TextContent } from "@mariozechner/pi-ai";
import type { AgentEvent, AgentMessage, AgentTool, ThinkingLevel } from "../index.js";
import type { Session } from "./session/session.js";
/** Model-visible skill loaded from a `SKILL.md` file or provided by an application. */
export interface Skill {
/** Skill command name. */
name: string;
/** Short model-visible description of when to use the skill. */
description: string;
/** Full skill instructions. */
content: string;
/** Absolute path to the skill file. Used for model-visible location and resolving relative references. */
filePath: string;
/** Exclude this skill from model-visible skill lists while still allowing explicit application invocation. */
disableModelInvocation?: boolean;
}
/** Prompt template that can expand slash-command text before a prompt is sent. */
export interface PromptTemplate {
/** Slash-command name without the leading `/`. */
name: string;
/** Optional description for command lists or autocomplete. */
description?: string;
/** Template content. Argument placeholders are expanded by `expandPromptTemplate`. */
content: string;
}
/** Resources made available to harness prompt expansion and system-prompt callbacks. */
export interface AgentHarnessResources {
/** Prompt templates used to expand `/template args` input. */
promptTemplates?: PromptTemplate[];
/** Skills available to the model and explicit skill invocation. */
skills?: Skill[];
}

View File

@@ -31,19 +31,17 @@ const agent = createAgentHarness({
session,
model: getModel("openai", "gpt-5.5"),
thinkingLevel: "low",
systemPrompt: ({ env, resources }) => {
console.log("Building system prompt");
return [
`You are a helpful assistant.`,
systemPrompt: ({ env, resources }) =>
[
"You are a helpful assistant.",
formatSkillsForSystemPrompt(resources.skills ?? []),
`Current working directory: ${env.cwd}`,
]
.filter((part) => part.length > 0)
.join("\n\n");
},
.join("\n\n"),
resources: {
promptTemplates: sourcedPromptTemplates.map((entry) => entry.promptTemplate),
skills: sourcedSkills.map((entry) => entry.skill),
promptTemplates: sourcedPromptTemplates.map(({ promptTemplate }) => promptTemplate),
skills: sourcedSkills.map(({ skill }) => skill),
},
});