feat: Expose BuildSystemPromptOptions on before-agent-start event. (#3473)
Resolves: #3463
This commit is contained in:
@@ -36,6 +36,7 @@ export type {
|
||||
BeforeAgentStartEventResult,
|
||||
BeforeProviderRequestEvent,
|
||||
BeforeProviderRequestEventResult,
|
||||
BuildSystemPromptOptions,
|
||||
// Context
|
||||
CompactOptions,
|
||||
// Events - Agent
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { ResourceDiagnostic } from "../diagnostics.js";
|
||||
import type { KeybindingsConfig } from "../keybindings.js";
|
||||
import type { ModelRegistry } from "../model-registry.js";
|
||||
import type { SessionManager } from "../session-manager.js";
|
||||
import type { BuildSystemPromptOptions } from "../system-prompt.js";
|
||||
import type {
|
||||
BeforeAgentStartEvent,
|
||||
BeforeAgentStartEventResult,
|
||||
@@ -789,6 +790,7 @@ export class ExtensionRunner {
|
||||
prompt: string,
|
||||
images: ImageContent[] | undefined,
|
||||
systemPrompt: string,
|
||||
systemPromptOptions: BuildSystemPromptOptions,
|
||||
): Promise<BeforeAgentStartCombinedResult | undefined> {
|
||||
const ctx = this.createContext();
|
||||
const messages: NonNullable<BeforeAgentStartEventResult["message"]>[] = [];
|
||||
@@ -806,6 +808,7 @@ export class ExtensionRunner {
|
||||
prompt,
|
||||
images,
|
||||
systemPrompt: currentSystemPrompt,
|
||||
systemPromptOptions,
|
||||
};
|
||||
const handlerResult = await handler(event, ctx);
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ import type {
|
||||
} from "../session-manager.js";
|
||||
import type { SlashCommandInfo } from "../slash-commands.js";
|
||||
import type { SourceInfo } from "../source-info.js";
|
||||
import type { BuildSystemPromptOptions } from "../system-prompt.js";
|
||||
import type { BashOperations } from "../tools/bash.js";
|
||||
import type { EditToolDetails } from "../tools/edit.js";
|
||||
import type {
|
||||
@@ -75,6 +76,7 @@ import type {
|
||||
} from "../tools/index.js";
|
||||
|
||||
export type { ExecOptions, ExecResult } from "../exec.js";
|
||||
export type { BuildSystemPromptOptions } from "../system-prompt.js";
|
||||
export type { AgentToolResult, AgentToolUpdateCallback, ToolExecutionMode };
|
||||
export type { AppKeybinding, KeybindingsManager } from "../keybindings.js";
|
||||
|
||||
@@ -582,9 +584,14 @@ export interface AfterProviderResponseEvent {
|
||||
/** Fired after user submits prompt but before agent loop. */
|
||||
export interface BeforeAgentStartEvent {
|
||||
type: "before_agent_start";
|
||||
/** The raw user prompt text (after expansion). */
|
||||
prompt: string;
|
||||
/** Images attached to the user prompt, if any. */
|
||||
images?: ImageContent[];
|
||||
/** The fully assembled system prompt string. */
|
||||
systemPrompt: string;
|
||||
/** Structured options used to build the system prompt. Extensions can inspect this to understand what Pi loaded without re-discovering resources. */
|
||||
systemPromptOptions: BuildSystemPromptOptions;
|
||||
}
|
||||
|
||||
/** Fired when an agent loop starts */
|
||||
|
||||
Reference in New Issue
Block a user