feat(pi): materialize effective plugin worker tools
This commit is contained in:
@@ -26,6 +26,7 @@ import type {
|
||||
PiSubagentChildResult,
|
||||
} from './subagent';
|
||||
import { PiSubagentChildError } from './subagent';
|
||||
import type { CodingCapabilityRegistry, ResolvedWorkerResources } from '../../coding-plugins/registry';
|
||||
import {
|
||||
PiWorkerProcess,
|
||||
type PiWorkerProcessOptions,
|
||||
@@ -61,6 +62,18 @@ export interface PiManagedSubagentChildOpenerOptions {
|
||||
getRevision(): PiManagedInputRevision;
|
||||
getLocalProxyCredential?(): Promise<string | undefined>;
|
||||
createProcess?(options: PiWorkerProcessOptions): PiSubagentProcessAdapter;
|
||||
capabilityRegistry?: CodingCapabilityRegistry;
|
||||
}
|
||||
|
||||
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: [],
|
||||
};
|
||||
}
|
||||
|
||||
function recordValue(value: unknown): Record<string, unknown> | null {
|
||||
@@ -178,12 +191,20 @@ export function createPiManagedSubagentChildOpener(
|
||||
if (!account || !descriptor) throw new PiSubagentChildError('SUBAGENT_MODEL_UNAVAILABLE');
|
||||
const managedPaths = await ensurePiManagedPaths(options.userDataDir);
|
||||
await writePiProviderCatalog(managedPaths.modelsFile, catalog, agent.model);
|
||||
const workerResources = options.capabilityRegistry
|
||||
? await options.capabilityRegistry.resolveWorkerResources({
|
||||
projectPath: project.path,
|
||||
assignedSkillIds: agent.skillIds,
|
||||
role: 'child',
|
||||
})
|
||||
: fallbackWorkerResources(agent.skillIds);
|
||||
const resources = await materializePiAgentResources({
|
||||
userDataDir: options.userDataDir,
|
||||
projectId: input.projectId,
|
||||
agentId: agent.id,
|
||||
prompt: agent.prompt,
|
||||
skillIds: agent.skillIds,
|
||||
skillEntries: workerResources.skillEntries,
|
||||
catalogRevision: workerResources.catalogRevision,
|
||||
bundledSkillsDir: options.bundledSkillsDir,
|
||||
revision: options.getRevision(),
|
||||
});
|
||||
@@ -200,7 +221,9 @@ export function createPiManagedSubagentChildOpener(
|
||||
generation: input.workerGeneration,
|
||||
projectId: input.projectId,
|
||||
projectPath: project.path,
|
||||
skillIds: agent.skillIds,
|
||||
skillEntries: workerResources.skillEntries,
|
||||
catalogRevision: workerResources.catalogRevision,
|
||||
tools: [],
|
||||
extensionsDir: managedPaths.extensionsDir,
|
||||
role: 'child',
|
||||
runId: input.runId,
|
||||
|
||||
Reference in New Issue
Block a user