feat(pi): materialize effective plugin worker tools
This commit is contained in:
@@ -60,6 +60,7 @@ import type {
|
||||
} from './rpc-client';
|
||||
import {
|
||||
PiWorkerProcess,
|
||||
PI_CORE_TOOL_NAMES,
|
||||
type PiWorkerProcessOptions,
|
||||
type PiWorkerProofFailure,
|
||||
type PiWorkerStopReason,
|
||||
@@ -84,6 +85,7 @@ import {
|
||||
} from './session-projector';
|
||||
import { PiManagedExtensionHost } from './extension-host';
|
||||
import type { PiSubagentScheduler } from './subagent';
|
||||
import type { CodingCapabilityRegistry, ResolvedWorkerResources } from '../../coding-plugins/registry';
|
||||
import {
|
||||
PiInteractionStore,
|
||||
} from './interaction';
|
||||
@@ -147,6 +149,7 @@ export interface PiManagedWorkerOpenerOptions {
|
||||
now?: () => number;
|
||||
onTelemetry?: (event: PiRuntimeTelemetryEvent) => void;
|
||||
extensionHost: PiManagedExtensionHost;
|
||||
capabilityRegistry?: CodingCapabilityRegistry;
|
||||
}
|
||||
|
||||
interface PiRpcSessionStateProjection {
|
||||
@@ -154,6 +157,17 @@ interface PiRpcSessionStateProjection {
|
||||
sessionFile?: string;
|
||||
}
|
||||
|
||||
function fallbackWorkerResources(skillIds: readonly string[]): ResolvedWorkerResources {
|
||||
const effectiveSkillIds = [...new Set(skillIds.map((id) => id.trim()).filter(Boolean))];
|
||||
return {
|
||||
catalogRevision: 0,
|
||||
pluginIds: [],
|
||||
effectiveSkillIds,
|
||||
skillEntries: effectiveSkillIds.map((id) => ({ id, entryPath: `${id}/SKILL.md` })),
|
||||
tools: [],
|
||||
};
|
||||
}
|
||||
|
||||
class ManagedPiConversationWorker implements PiConversationWorker {
|
||||
constructor(
|
||||
readonly id: string,
|
||||
@@ -229,12 +243,20 @@ export function createPiManagedWorkerOpener(
|
||||
if (!account || !descriptor) throw new Error('Selected Provider account is unavailable');
|
||||
const managedPaths = await ensurePiManagedPaths(options.userDataDir);
|
||||
await writePiProviderCatalog(managedPaths.modelsFile, catalog, model);
|
||||
const workerResources = options.capabilityRegistry
|
||||
? await options.capabilityRegistry.resolveWorkerResources({
|
||||
projectPath: registered.projectPath,
|
||||
assignedSkillIds: registered.agent.skillIds,
|
||||
role: 'parent',
|
||||
})
|
||||
: fallbackWorkerResources(registered.agent.skillIds);
|
||||
const resources = await materializePiAgentResources({
|
||||
userDataDir: options.userDataDir,
|
||||
projectId: input.conversation.projectId,
|
||||
agentId: registered.agent.id,
|
||||
prompt: registered.agent.prompt,
|
||||
skillIds: registered.agent.skillIds,
|
||||
skillEntries: workerResources.skillEntries,
|
||||
catalogRevision: workerResources.catalogRevision,
|
||||
bundledSkillsDir: options.bundledSkillsDir,
|
||||
revision: input.revision,
|
||||
});
|
||||
@@ -251,7 +273,9 @@ export function createPiManagedWorkerOpener(
|
||||
generation: input.generation,
|
||||
projectId: input.conversation.projectId,
|
||||
projectPath: registered.projectPath,
|
||||
skillIds: registered.agent.skillIds,
|
||||
skillEntries: workerResources.skillEntries,
|
||||
catalogRevision: workerResources.catalogRevision,
|
||||
tools: workerResources.tools,
|
||||
extensionsDir: managedPaths.extensionsDir,
|
||||
});
|
||||
recordManagedMilestone(
|
||||
@@ -274,6 +298,10 @@ export function createPiManagedWorkerOpener(
|
||||
cwd: registered.projectPath,
|
||||
configDir: resources.paths.configDir,
|
||||
sessionDir: resources.projectSessionsDir,
|
||||
tools: [...new Set([
|
||||
...PI_CORE_TOOL_NAMES,
|
||||
...extension.allowedToolNames,
|
||||
])],
|
||||
additionalArgs: [
|
||||
...buildPiManagedInputArgs(selection, resources),
|
||||
'--extension', extension.extensionPath,
|
||||
|
||||
Reference in New Issue
Block a user