@aliou/pi-ts-aperture 0.2.2 → 0.2.4
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/package.json +5 -5
- package/src/index.ts +12 -10
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aliou/pi-ts-aperture",
|
|
3
3
|
"description": "Route Pi LLM providers through Tailscale Aperture",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"@aliou/pi-utils-settings": "^0.4.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@mariozechner/pi-ai": ">=0.
|
|
36
|
-
"@mariozechner/pi-coding-agent": ">=0.
|
|
37
|
-
"@mariozechner/pi-tui": ">=0.
|
|
35
|
+
"@mariozechner/pi-ai": ">=0.55.3",
|
|
36
|
+
"@mariozechner/pi-coding-agent": ">=0.55.3",
|
|
37
|
+
"@mariozechner/pi-tui": ">=0.55.3"
|
|
38
38
|
},
|
|
39
39
|
"peerDependenciesMeta": {
|
|
40
40
|
"@mariozechner/pi-coding-agent": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@aliou/biome-plugins": "^0.3.2",
|
|
52
52
|
"@biomejs/biome": "^2.3.13",
|
|
53
53
|
"@changesets/cli": "^2.27.11",
|
|
54
|
-
"@mariozechner/pi-coding-agent": "0.
|
|
54
|
+
"@mariozechner/pi-coding-agent": "0.55.3",
|
|
55
55
|
"@sinclair/typebox": "^0.34.48",
|
|
56
56
|
"@types/node": "^25.0.10",
|
|
57
57
|
"@vitest/coverage-v8": "^4.0.18",
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
ExtensionAPI,
|
|
11
11
|
ExtensionContext,
|
|
12
12
|
} from "@mariozechner/pi-coding-agent";
|
|
13
|
+
import { VERSION } from "@mariozechner/pi-coding-agent";
|
|
13
14
|
import { registerApertureSettings } from "./commands/settings";
|
|
14
15
|
import { registerSetupCommand } from "./commands/setup";
|
|
15
16
|
import { configLoader } from "./config";
|
|
@@ -29,6 +30,7 @@ function resolveBaseUrl(): string | null {
|
|
|
29
30
|
* before this runs don't lose them.
|
|
30
31
|
*/
|
|
31
32
|
function overrideProviders(
|
|
33
|
+
pi: ExtensionAPI,
|
|
32
34
|
registry: ExtensionContext["modelRegistry"],
|
|
33
35
|
providers: string[],
|
|
34
36
|
baseUrl: string,
|
|
@@ -36,7 +38,7 @@ function overrideProviders(
|
|
|
36
38
|
for (const provider of providers) {
|
|
37
39
|
const models = registry.getAll().filter((m) => m.provider === provider);
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
pi.registerProvider(provider, {
|
|
40
42
|
baseUrl,
|
|
41
43
|
apiKey: "-",
|
|
42
44
|
...(models.length > 0 && { api: models[0].api, models }),
|
|
@@ -48,12 +50,15 @@ function overrideProviders(
|
|
|
48
50
|
* Apply Aperture configuration to the model registry.
|
|
49
51
|
* Returns the list of providers that were overridden, or empty if no-op.
|
|
50
52
|
*/
|
|
51
|
-
function applyAperture(
|
|
53
|
+
function applyAperture(
|
|
54
|
+
pi: ExtensionAPI,
|
|
55
|
+
registry: ExtensionContext["modelRegistry"],
|
|
56
|
+
): string[] {
|
|
52
57
|
const url = resolveBaseUrl();
|
|
53
58
|
if (!url) return [];
|
|
54
59
|
|
|
55
60
|
const { providers } = configLoader.getConfig();
|
|
56
|
-
overrideProviders(registry, providers, url);
|
|
61
|
+
overrideProviders(pi, registry, providers, url);
|
|
57
62
|
return providers;
|
|
58
63
|
}
|
|
59
64
|
|
|
@@ -66,7 +71,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
66
71
|
pi.events.on("before_agent_start", async (data) => {
|
|
67
72
|
const ctx = data as ExtensionContext;
|
|
68
73
|
if (!ctx?.modelRegistry) return;
|
|
69
|
-
applyAperture(ctx.modelRegistry);
|
|
74
|
+
applyAperture(pi, ctx.modelRegistry);
|
|
70
75
|
});
|
|
71
76
|
|
|
72
77
|
const onSetupComplete = (ctx: ExtensionContext) => {
|
|
@@ -75,7 +80,7 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
75
80
|
(p) => !providers.includes(p),
|
|
76
81
|
);
|
|
77
82
|
|
|
78
|
-
applyAperture(ctx.modelRegistry);
|
|
83
|
+
applyAperture(pi, ctx.modelRegistry);
|
|
79
84
|
lastRegisteredProviders = [...providers];
|
|
80
85
|
|
|
81
86
|
// Re-resolve active model if it belongs to a reconfigured provider.
|
|
@@ -90,11 +95,8 @@ export default async function (pi: ExtensionAPI): Promise<void> {
|
|
|
90
95
|
}
|
|
91
96
|
}
|
|
92
97
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
`Removed providers (${removed.join(", ")}) will revert after /reload`,
|
|
96
|
-
"warning",
|
|
97
|
-
);
|
|
98
|
+
for (const p of removed) {
|
|
99
|
+
pi.unregisterProvider(p);
|
|
98
100
|
}
|
|
99
101
|
};
|
|
100
102
|
|