routstrd 0.4.3 → 0.4.5
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/bun.lock +316 -2
- package/dist/daemon/index.js +864 -844
- package/dist/index.js +134 -15
- package/package.json +1 -1
- package/src/cli.test.ts +138 -1
- package/src/cli.ts +226 -34
- package/src/integrations/pi.ts +15 -15
package/src/integrations/pi.ts
CHANGED
|
@@ -10,8 +10,10 @@ type PiModelEntry = {
|
|
|
10
10
|
contextWindow?: number;
|
|
11
11
|
name?: string;
|
|
12
12
|
input?: string[];
|
|
13
|
-
//
|
|
14
|
-
|
|
13
|
+
// Thinking/reasoning config is user-curated and preserved across refreshes.
|
|
14
|
+
reasoning?: boolean;
|
|
15
|
+
thinkingLevelMap?: Record<string, string | null>;
|
|
16
|
+
compat?: Record<string, unknown>;
|
|
15
17
|
};
|
|
16
18
|
|
|
17
19
|
type PiProviderConfig = {
|
|
@@ -65,29 +67,24 @@ export async function installPiIntegration(
|
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
70
|
+
// Rebuild every model entry from scratch from the daemon, so the generated
|
|
71
|
+
// models.json is always a faithful projection of the daemon's state. The only
|
|
72
|
+
// exception is thinking/reasoning config (reasoning, thinkingLevelMap, compat),
|
|
73
|
+
// which the daemon does not provide and the user curates by hand — preserve it.
|
|
71
74
|
const existingModels = new Map<string, PiModelEntry>(
|
|
72
75
|
(piConfig.providers["routstr"]?.models ?? []).map((m) => [m.id, m]),
|
|
73
76
|
);
|
|
74
77
|
|
|
75
78
|
const providerModels: PiModelEntry[] = models.map((model) => {
|
|
76
79
|
const previous = existingModels.get(model.id);
|
|
77
|
-
const entry: PiModelEntry =
|
|
78
|
-
|
|
79
|
-
entry.id = model.id;
|
|
80
|
+
const entry: PiModelEntry = { id: model.id };
|
|
80
81
|
|
|
81
82
|
if (model.context_length !== undefined && model.context_length > 0) {
|
|
82
83
|
entry.contextWindow = model.context_length;
|
|
83
|
-
} else {
|
|
84
|
-
delete entry.contextWindow;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
if (model.name) {
|
|
88
87
|
entry.name = model.name;
|
|
89
|
-
} else {
|
|
90
|
-
delete entry.name;
|
|
91
88
|
}
|
|
92
89
|
|
|
93
90
|
// Map the daemon's input modalities to Pi's ["text", "image"] vocabulary.
|
|
@@ -97,13 +94,16 @@ export async function installPiIntegration(
|
|
|
97
94
|
if (mods.includes("image")) input.push("image");
|
|
98
95
|
entry.input = input;
|
|
99
96
|
|
|
97
|
+
// Preserve user-curated thinking fields from the previous entry.
|
|
98
|
+
if (previous?.reasoning !== undefined) entry.reasoning = previous.reasoning;
|
|
99
|
+
if (previous?.thinkingLevelMap !== undefined) entry.thinkingLevelMap = previous.thinkingLevelMap;
|
|
100
|
+
if (previous?.compat !== undefined) entry.compat = previous.compat;
|
|
101
|
+
|
|
100
102
|
return entry;
|
|
101
103
|
});
|
|
102
104
|
|
|
103
|
-
//
|
|
104
|
-
// the routstrd-managed fields below.
|
|
105
|
+
// Rebuild provider from scratch too; only write routstrd-managed fields.
|
|
105
106
|
piConfig.providers["routstr"] = {
|
|
106
|
-
...(piConfig.providers["routstr"] ?? {}),
|
|
107
107
|
baseUrl,
|
|
108
108
|
api: "openai-completions",
|
|
109
109
|
apiKey,
|