pi-codex-accounts 0.1.0 → 0.1.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/package.json +2 -2
- package/src/index.ts +9 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-codex-accounts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Use more than one ChatGPT (Codex) subscription in pi, each with its own login and its own entries in /model.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
]
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
|
-
"test": "tsc && node --test test/index.test.ts"
|
|
29
|
+
"test": "tsc && node --test test/index.test.ts && sh scripts/smoke.sh"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@earendil-works/pi-ai": "*",
|
package/src/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
type Model,
|
|
9
9
|
type Provider,
|
|
10
10
|
} from "@earendil-works/pi-ai";
|
|
11
|
-
import {
|
|
11
|
+
import { builtinProviders } from "@earendil-works/pi-ai/providers/all";
|
|
12
12
|
import { type ExtensionAPI, getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
13
13
|
|
|
14
14
|
const CODEX = "openai-codex";
|
|
@@ -29,10 +29,17 @@ export default function codexAccounts(pi: ExtensionAPI) {
|
|
|
29
29
|
} catch (error) {
|
|
30
30
|
throw new Error(`${path}: ${error instanceof Error ? error.message : String(error)}`);
|
|
31
31
|
}
|
|
32
|
-
const codex =
|
|
32
|
+
const codex = builtinCodexProvider();
|
|
33
33
|
for (const account of accounts) pi.registerProvider(createAccountProvider(codex, account));
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/** pi lets extensions import only a few pi-ai entry points; providers/all is the one with the built-in providers. */
|
|
37
|
+
export function builtinCodexProvider(): Provider<CodexApi> {
|
|
38
|
+
const codex = builtinProviders().find((provider) => provider.id === CODEX);
|
|
39
|
+
if (!codex) throw new Error("pi no longer ships a built-in OpenAI Codex provider");
|
|
40
|
+
return codex as Provider<CodexApi>;
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
/** The config file's text, or undefined when there is no config file. */
|
|
37
44
|
function readConfig(path: string): string | undefined {
|
|
38
45
|
try {
|