@henryqw/pi-task-models 0.7.3 → 1.0.1
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 +0 -5
- package/dist/index.js +3 -22
- package/extensions/task-models.ts +1 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Package also exports config and route-resolution helpers for consumers.
|
|
|
70
70
|
|
|
71
71
|
Each configured profile needs one primary model and thinking level. Fallback is optional. Model references use canonical `provider/model`; numbered `openai-codex-N` routes store as `openai-codex/model`.
|
|
72
72
|
|
|
73
|
-
Profile thinking is authoritative for task routes.
|
|
73
|
+
Profile thinking is authoritative for task routes.
|
|
74
74
|
|
|
75
75
|
Reads are strict. Malformed or unknown values fail visibly and never rewrite the file. Only explicit `/task-models` actions write config.
|
|
76
76
|
|
package/dist/index.d.ts
CHANGED
|
@@ -45,13 +45,8 @@ export declare function modelReference(model: {
|
|
|
45
45
|
}): string;
|
|
46
46
|
export declare function dedupeAvailableModels(models: readonly AvailableModel[], preferredProvider?: string): AvailableModel[];
|
|
47
47
|
export declare function resolveAvailableModel(models: readonly AvailableModel[], reference: string, preferredProvider?: string): AvailableModel | undefined;
|
|
48
|
-
export declare function supportedThinkingLevels(model: AvailableModel): ThinkingLevel[];
|
|
49
48
|
export declare function availableTaskModels(ctx: ExtensionContext): AvailableModel[];
|
|
50
49
|
export declare function taskThinkingLevels(ctx: ExtensionContext, model: AvailableModel): ThinkingLevel[];
|
|
51
|
-
export declare function rememberedThinkingLevel(model: {
|
|
52
|
-
provider: string;
|
|
53
|
-
id: string;
|
|
54
|
-
} | string, agentDir?: string): ThinkingLevel | undefined;
|
|
55
50
|
export declare function resolveTaskModelRoute(ctx: ExtensionContext, route: TaskModelRoute, agentDir?: string, thinking?: ThinkingLevel): ResolvedTaskRoute | undefined;
|
|
56
51
|
export declare function resolveConfiguredTaskRoutes(ctx: ExtensionContext, task: string, agentDir?: string, thinking?: ThinkingLevel): ResolvedTaskRoute[];
|
|
57
52
|
export type TaskRouteErrorCode = "config-read" | "task-unassigned" | "profile-missing" | "no-route";
|
package/dist/index.js
CHANGED
|
@@ -14,9 +14,6 @@ export const DEFAULT_TASK_ASSIGNMENTS = {
|
|
|
14
14
|
};
|
|
15
15
|
const CODEX_ALIAS = /^openai-codex-(?:[2-9]|[1-9]\d+)$/;
|
|
16
16
|
const CONFIG_FILE = "pi-task-models.json";
|
|
17
|
-
// Owned by @henryqw/pi-model-thinking; keys use the same canonical provider/model form.
|
|
18
|
-
const MODEL_THINKING_CONFIG_FILE = "pi-model-thinking.json";
|
|
19
|
-
const defaultTaskAssignments = () => ({ ...DEFAULT_TASK_ASSIGNMENTS });
|
|
20
17
|
export const configPath = (agentDir = getAgentDir()) => join(agentDir, "config", CONFIG_FILE);
|
|
21
18
|
function isCodexProvider(provider) {
|
|
22
19
|
return provider === "openai-codex" || Boolean(provider && CODEX_ALIAS.test(provider));
|
|
@@ -74,7 +71,7 @@ function parseConfig(value) {
|
|
|
74
71
|
if (!hasOnlyKeys(record, ["profiles", "tasks"]))
|
|
75
72
|
throw new Error("Config contains unknown settings.");
|
|
76
73
|
const profiles = {};
|
|
77
|
-
const tasks =
|
|
74
|
+
const tasks = { ...DEFAULT_TASK_ASSIGNMENTS };
|
|
78
75
|
if (record.profiles !== undefined) {
|
|
79
76
|
if (!record.profiles || typeof record.profiles !== "object" || Array.isArray(record.profiles)) {
|
|
80
77
|
throw new Error("profiles must be an object.");
|
|
@@ -112,7 +109,7 @@ export function readTaskModelsConfig(agentDir = getAgentDir()) {
|
|
|
112
109
|
}
|
|
113
110
|
catch (error) {
|
|
114
111
|
if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
|
|
115
|
-
return { profiles: {}, tasks:
|
|
112
|
+
return { profiles: {}, tasks: { ...DEFAULT_TASK_ASSIGNMENTS } };
|
|
116
113
|
}
|
|
117
114
|
throw error;
|
|
118
115
|
}
|
|
@@ -178,34 +175,18 @@ export function resolveAvailableModel(models, reference, preferredProvider) {
|
|
|
178
175
|
?? models.find((model) => CODEX_ALIAS.test(model.provider) && model.id === id)
|
|
179
176
|
?? models.find((model) => model.provider === "openai-codex" && model.id === id);
|
|
180
177
|
}
|
|
181
|
-
export function supportedThinkingLevels(model) {
|
|
182
|
-
return getSupportedThinkingLevels(model);
|
|
183
|
-
}
|
|
184
178
|
export function availableTaskModels(ctx) {
|
|
185
179
|
const scopedModels = ctx.scopedModels ?? [];
|
|
186
180
|
return dedupeAvailableModels((scopedModels.length ? scopedModels.map(({ model }) => model) : ctx.modelRegistry.getAvailable())
|
|
187
181
|
.filter((model) => model.input.includes("text")), ctx.model?.provider);
|
|
188
182
|
}
|
|
189
183
|
export function taskThinkingLevels(ctx, model) {
|
|
190
|
-
const supported =
|
|
184
|
+
const supported = getSupportedThinkingLevels(model);
|
|
191
185
|
const pinned = (ctx.scopedModels ?? []).find(({ model: scoped }) => scoped.provider === model.provider && scoped.id === model.id)?.thinkingLevel;
|
|
192
186
|
if (!pinned)
|
|
193
187
|
return supported;
|
|
194
188
|
return supported.includes(pinned) ? [pinned] : [];
|
|
195
189
|
}
|
|
196
|
-
// pi-model-thinking's config is untrusted user data; keep only recognized levels for this model.
|
|
197
|
-
export function rememberedThinkingLevel(model, agentDir = getAgentDir()) {
|
|
198
|
-
try {
|
|
199
|
-
const value = JSON.parse(readFileSync(join(agentDir, "config", MODEL_THINKING_CONFIG_FILE), "utf8"));
|
|
200
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
201
|
-
return undefined;
|
|
202
|
-
const level = value[canonicalModelReference(model)];
|
|
203
|
-
return isThinkingLevel(level) ? level : undefined;
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
return undefined;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
190
|
export function resolveTaskModelRoute(ctx, route, agentDir = getAgentDir(), thinking) {
|
|
210
191
|
const model = resolveAvailableModel(availableTaskModels(ctx), route.model, ctx.model?.provider);
|
|
211
192
|
if (!model)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@henryqw/pi-task-models",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Shared task model profiles and routing for HenryQW Pi extensions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"pack:check": "npm pack --dry-run"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@earendil-works/pi-ai": "^0.84.
|
|
39
|
-
"@earendil-works/pi-coding-agent": "^0.84.
|
|
38
|
+
"@earendil-works/pi-ai": "^0.84.3",
|
|
39
|
+
"@earendil-works/pi-coding-agent": "^0.84.3"
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|