























@@ -418,6 +418,15 @@ export async function runEmbeddedPiAgent(
418418const started = Date.now();
419419const startupStages = createEmbeddedRunStageTracker();
420420let startupStagesEmitted = false;
421+const notifyExecutionPhase = (
422+phase: Parameters<NonNullable<RunEmbeddedPiAgentParams["onExecutionPhase"]>>[0]["phase"],
423+extra?: Omit<
424+Parameters<NonNullable<RunEmbeddedPiAgentParams["onExecutionPhase"]>>[0],
425+"phase"
426+>,
427+) => {
428+params.onExecutionPhase?.({ phase, ...extra });
429+};
421430const emitStartupStageSummary = (phase: string) => {
422431const summary = startupStages.snapshot();
423432const shouldWarn = shouldWarnEmbeddedRunStageSummary(summary);
@@ -435,6 +444,7 @@ export async function runEmbeddedPiAgent(
435444}
436445};
437446params.onExecutionStarted?.();
447+notifyExecutionPhase("runner_entered");
438448const workspaceResolution = resolveRunWorkspaceDir({
439449workspaceDir: params.workspaceDir,
440450sessionKey: params.sessionKey,
@@ -455,12 +465,14 @@ export async function runEmbeddedPiAgent(
455465);
456466}
457467startupStages.mark("workspace");
468+notifyExecutionPhase("workspace");
458469ensureRuntimePluginsLoaded({
459470config: params.config,
460471workspaceDir: resolvedWorkspace,
461472allowGatewaySubagentBinding: params.allowGatewaySubagentBinding,
462473});
463474startupStages.mark("runtime-plugins");
475+notifyExecutionPhase("runtime_plugins");
464476465477let provider = (params.provider ?? DEFAULT_PROVIDER).trim() || DEFAULT_PROVIDER;
466478let modelId = (params.model ?? DEFAULT_MODEL).trim() || DEFAULT_MODEL;
@@ -586,6 +598,7 @@ export async function runEmbeddedPiAgent(
586598const ctxInfo = resolvedRuntimeModel.ctxInfo;
587599let effectiveModel = resolvedRuntimeModel.effectiveModel;
588600startupStages.mark("model-resolution");
601+notifyExecutionPhase("model_resolution", { provider, model: modelId });
589602590603const authStore = pluginHarnessOwnsTransport
591604 ? createEmptyAuthProfileStore()
@@ -796,6 +809,7 @@ export async function runEmbeddedPiAgent(
796809lastProfileId = forwardedPluginHarnessProfileId;
797810}
798811startupStages.mark("auth");
812+notifyExecutionPhase("auth", { provider, model: modelId });
799813const runAttemptAuthProfileStore = pluginHarnessOwnsTransport
800814 ? createScopedAuthProfileStore(attemptAuthProfileStore, lastProfileId)
801815 : attemptAuthProfileStore;
@@ -987,6 +1001,7 @@ export async function runEmbeddedPiAgent(
9871001});
9881002const contextEnginePluginId = resolveContextEngineOwnerPluginId(contextEngine);
9891003startupStages.mark("context-engine");
1004+notifyExecutionPhase("context_engine", { provider, model: modelId });
9901005try {
9911006const resolveActiveHookContext = () => ({
9921007 ...hookCtx,
@@ -1155,6 +1170,7 @@ export async function runEmbeddedPiAgent(
11551170});
11561171if (!startupStagesEmitted) {
11571172startupStages.mark("attempt-dispatch");
1173+notifyExecutionPhase("attempt_dispatch", { provider, model: modelId });
11581174emitStartupStageSummary("attempt-dispatch");
11591175startupStagesEmitted = true;
11601176}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。