@henryqw/pi-task-models 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +16 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ Each configured profile needs one primary model and thinking level. Fallback is
|
|
|
67
67
|
|
|
68
68
|
Reads are strict. Malformed or unknown values fail visibly and never rewrite the file. Only explicit `/task-models` actions write config.
|
|
69
69
|
|
|
70
|
-
Consumers can call `resolveConfiguredTaskRoute(ctx, taskId)`
|
|
70
|
+
Consumers can call `resolveConfiguredTaskRoute(ctx, taskId)` for the first usable route or `resolveConfiguredTaskRoutes(ctx, taskId)` for primary and fallback routes. Both read strict shared config and fail with `/task-models` guidance when assignment, profile, or route is unavailable.
|
|
71
71
|
|
|
72
72
|
## Remove
|
|
73
73
|
|
package/dist/index.d.ts
CHANGED
|
@@ -53,6 +53,12 @@ export declare function rememberedThinkingLevel(model: {
|
|
|
53
53
|
id: string;
|
|
54
54
|
} | string, agentDir?: string): ThinkingLevel | undefined;
|
|
55
55
|
export declare function resolveTaskModelRoute(ctx: ExtensionContext, route: TaskModelRoute, agentDir?: string, thinking?: ThinkingLevel): ResolvedTaskRoute | undefined;
|
|
56
|
+
export declare function resolveConfiguredTaskRoutes(ctx: ExtensionContext, task: string, agentDir?: string, thinking?: ThinkingLevel): ResolvedTaskRoute[];
|
|
57
|
+
export type TaskRouteErrorCode = "config-read" | "task-unassigned" | "profile-missing" | "no-route";
|
|
58
|
+
export type TaskRouteError = Error & {
|
|
59
|
+
taskRouteCode: TaskRouteErrorCode;
|
|
60
|
+
profileName?: ProfileName;
|
|
61
|
+
};
|
|
56
62
|
export declare function resolveConfiguredTaskRoute(ctx: ExtensionContext, task: string, agentDir?: string, thinking?: ThinkingLevel): ResolvedTaskRoute;
|
|
57
63
|
export declare function orderedProfileRoutes(profile: TaskModelProfile): TaskModelRoute[];
|
|
58
64
|
export declare function activeTaskPackages(pi: Pick<ExtensionAPI, "getCommands" | "getAllTools">, tasks?: Readonly<Record<string, ProfileName>>): ActiveTaskPackage[];
|
package/dist/index.js
CHANGED
|
@@ -223,26 +223,36 @@ export function resolveTaskModelRoute(ctx, route, agentDir = getAgentDir(), thin
|
|
|
223
223
|
return undefined;
|
|
224
224
|
return { model, thinkingLevel };
|
|
225
225
|
}
|
|
226
|
-
export function
|
|
226
|
+
export function resolveConfiguredTaskRoutes(ctx, task, agentDir = getAgentDir(), thinking) {
|
|
227
227
|
let config;
|
|
228
228
|
try {
|
|
229
229
|
config = readTaskModelsConfig(agentDir);
|
|
230
230
|
}
|
|
231
231
|
catch {
|
|
232
|
-
throw
|
|
232
|
+
throw taskRouteError("config-read", "Couldn't read task model config. Run /task-models.");
|
|
233
233
|
}
|
|
234
234
|
const profileName = config.tasks[task];
|
|
235
235
|
if (!profileName)
|
|
236
|
-
throw
|
|
236
|
+
throw taskRouteError("task-unassigned", `Task ${task} is not assigned to a profile. Run /task-models.`);
|
|
237
237
|
const profile = config.profiles[profileName];
|
|
238
238
|
if (!profile)
|
|
239
|
-
throw
|
|
239
|
+
throw taskRouteError("profile-missing", `Task ${task} profile ${profileName} is not configured. Run /task-models.`, profileName);
|
|
240
|
+
const routes = [];
|
|
240
241
|
for (const route of orderedProfileRoutes(profile)) {
|
|
241
242
|
const resolved = resolveTaskModelRoute(ctx, route, agentDir, thinking);
|
|
242
243
|
if (resolved)
|
|
243
|
-
|
|
244
|
+
routes.push(resolved);
|
|
245
|
+
}
|
|
246
|
+
if (!routes.length) {
|
|
247
|
+
throw taskRouteError("no-route", `Task ${task} profile ${profileName} has no available route${thinking ? ` supporting thinking ${thinking}` : ""}. Run /task-models.`, profileName);
|
|
244
248
|
}
|
|
245
|
-
|
|
249
|
+
return routes;
|
|
250
|
+
}
|
|
251
|
+
function taskRouteError(taskRouteCode, message, profileName) {
|
|
252
|
+
return Object.assign(new Error(message), { taskRouteCode, ...(profileName ? { profileName } : {}) });
|
|
253
|
+
}
|
|
254
|
+
export function resolveConfiguredTaskRoute(ctx, task, agentDir = getAgentDir(), thinking) {
|
|
255
|
+
return resolveConfiguredTaskRoutes(ctx, task, agentDir, thinking)[0];
|
|
246
256
|
}
|
|
247
257
|
export function orderedProfileRoutes(profile) {
|
|
248
258
|
return profile.fallback ? [profile.primary, profile.fallback] : [profile.primary];
|