Commit 101ea131a820

Vincent Demeester <vincent@sbr.pm>
2026-03-31 12:11:44
fix(pi-ext): migrate deprecated APIs for pi 0.64.0
Adapted extensions to pi 0.63.0+ breaking changes: - handoff, subagent: getApiKey → getApiKeyAndHeaders - custom-header: cmd.source/path/location → sourceInfo
1 parent 15be764
Changed files (3)
dots
pi
dots/pi/agent/extensions/subagent/index.ts
@@ -327,8 +327,8 @@ async function findModelAcrossProviders(
 		if (foundModelId) {
 			const model = modelRegistry.find(providerName, foundModelId);
 			if (model) {
-				const apiKey = await modelRegistry.getApiKey(model);
-				if (apiKey) {
+				const auth = await modelRegistry.getApiKeyAndHeaders(model);
+				if (auth.ok && auth.apiKey) {
 					return { provider: providerName, modelId: foundModelId };
 				}
 			}
@@ -343,8 +343,8 @@ async function findModelAcrossProviders(
 			if (foundModelId) {
 				const model = modelRegistry.find(providerName, foundModelId);
 				if (model) {
-					const apiKey = await modelRegistry.getApiKey(model);
-					if (apiKey) {
+					const auth = await modelRegistry.getApiKeyAndHeaders(model);
+					if (auth.ok && auth.apiKey) {
 						return { provider: providerName, modelId: foundModelId };
 					}
 				}
dots/pi/agent/extensions/custom-header.ts
@@ -92,27 +92,27 @@ export default function (pi: ExtensionAPI) {
 			const commands = pi.getCommands();
 			
 			const extensions = commands
-				.filter(cmd => cmd.source === "extension")
+				.filter(cmd => cmd.sourceInfo?.source === "extension")
 				.map(cmd => ({
 					name: cmd.name,
 					description: cmd.description,
-					path: cmd.path,
+					path: cmd.sourceInfo?.path,
 				}));
 			
 			const skills = commands
-				.filter(cmd => cmd.source === "skill")
+				.filter(cmd => cmd.sourceInfo?.source === "skill")
 				.map(cmd => ({
 					name: cmd.name,
-					location: cmd.location,
-					path: cmd.path,
+					location: cmd.sourceInfo?.path,
+					path: cmd.sourceInfo?.path,
 				}));
 			
 			const prompts = commands
-				.filter(cmd => cmd.source === "prompt")
+				.filter(cmd => cmd.sourceInfo?.source === "prompt")
 				.map(cmd => ({
 					name: cmd.name,
-					location: cmd.location,
-					path: cmd.path,
+					location: cmd.sourceInfo?.path,
+					path: cmd.sourceInfo?.path,
 				}));
 
 			// Get themes
dots/pi/agent/extensions/handoff.ts
@@ -145,7 +145,8 @@ export default function (pi: ExtensionAPI) {
 				loader.onAbort = () => done(null);
 
 				const doGenerate = async () => {
-					const apiKey = await ctx.modelRegistry.getApiKey(ctx.model!);
+					const auth = await ctx.modelRegistry.getApiKeyAndHeaders(ctx.model!);
+					if (!auth.ok) throw new Error(auth.error);
 
 					const userMessage: Message = {
 						role: "user",
@@ -161,7 +162,7 @@ export default function (pi: ExtensionAPI) {
 					const response = await complete(
 						ctx.model!,
 						{ systemPrompt: SYSTEM_PROMPT, messages: [userMessage] },
-						{ apiKey, signal: loader.signal },
+						{ apiKey: auth.apiKey, headers: auth.headers, signal: loader.signal },
 					);
 
 					if (response.stopReason === "aborted") {