dsh-codex-share 0.4.1 → 0.4.2
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 +7 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +26 -5
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -28,6 +28,12 @@ Restart the profile after installation or update. The bundle mounts one provider
|
|
|
28
28
|
|
|
29
29
|
The plugin intentionally does not refresh a stale token. When Codex writes a replacement, the next harness request reads it. When Codex's current access token has expired, harness calls fail until Codex refreshes its own login. An API-key-only Codex login is rejected; this route never falls back to `OPENAI_API_KEY`.
|
|
30
30
|
|
|
31
|
+
## Optional GLM Coding Plan (global)
|
|
32
|
+
|
|
33
|
+
When `GLM_API_KEY` is non-empty in the Harness launch environment, this plugin also adds **GLM Coding Plan (global)** to the model picker under the `glm-coding-global` provider route. It uses pi-ai's installed Z.AI model catalog and the global Coding Plan endpoint, `https://api.z.ai/api/coding/paas/v4` (not the China endpoint or the standard pay-as-you-go API).
|
|
34
|
+
|
|
35
|
+
Export your Coding Plan key before launching the Harness, or set it in a Harness launch `.env` file, and restart the profile. No manual model/provider configuration is needed. With no key, or an empty/whitespace-only key, the GLM route is omitted. `ZAI_API_KEY` does not enable this route. GLM requests use only `GLM_API_KEY` and do not require a Codex login; Codex requests continue to use the local Codex credential file. The key is not written to plugin settings. Available models follow the installed pi-ai catalog; endpoint access depends on your plan.
|
|
36
|
+
|
|
31
37
|
## Development
|
|
32
38
|
|
|
33
39
|
```sh
|
|
@@ -38,4 +44,4 @@ pnpm build
|
|
|
38
44
|
pnpm pack
|
|
39
45
|
```
|
|
40
46
|
|
|
41
|
-
The development links in `package.json` and local overrides in `pnpm-workspace.yaml` point to the
|
|
47
|
+
The development links in `package.json` and local overrides in `pnpm-workspace.yaml` point to the `../../deepseek-harness` checkout. Replace those paths when developing elsewhere; consumers of the published package use the versioned runtime dependencies instead.
|
package/dist/index.d.mts
CHANGED
|
@@ -13,6 +13,8 @@ declare function readCodexAccessToken(codexHome?: string): Promise<string>;
|
|
|
13
13
|
//#region src/index.d.ts
|
|
14
14
|
/** Harness route for subscription-backed Codex models. */
|
|
15
15
|
declare const PROVIDER = "openai-codex-local";
|
|
16
|
+
/** Separate route to avoid colliding with the configurable pi-ai Z.AI provider. */
|
|
17
|
+
declare const GLM_PROVIDER = "glm-coding-global";
|
|
16
18
|
declare const name = "llm-codex-share";
|
|
17
19
|
declare const inject: string[];
|
|
18
20
|
/** Settings namespace: the Loader entry id this bundle's patch inserts. */
|
|
@@ -27,4 +29,4 @@ declare const Config: z<Partial<Record<keyof Config, unknown>>, Config>;
|
|
|
27
29
|
/** Register the Codex subscription model catalog and stream adapter. */
|
|
28
30
|
declare function apply(ctx: Context, config?: Config): void;
|
|
29
31
|
//#endregion
|
|
30
|
-
export { Config, PROVIDER, SETTINGS_NS, apply, codexAuthPath, inject, name, readCodexAccessToken };
|
|
32
|
+
export { Config, GLM_PROVIDER, PROVIDER, SETTINGS_NS, apply, codexAuthPath, inject, name, readCodexAccessToken };
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,8 @@ import { LlmError, resolveImageAttachmentAccess } from "@deepseek-ai/dsh-llm";
|
|
|
3
3
|
import { PiAiAdapter } from "@deepseek-ai/dsh-llm-pi-ai";
|
|
4
4
|
import { envApiKeyAuth } from "@earendil-works/pi-ai";
|
|
5
5
|
import { openaiCodexProvider } from "@earendil-works/pi-ai/providers/openai-codex";
|
|
6
|
+
import { zaiProvider } from "@earendil-works/pi-ai/providers/zai";
|
|
7
|
+
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
6
8
|
import { readFile } from "node:fs/promises";
|
|
7
9
|
import { homedir } from "node:os";
|
|
8
10
|
import { isAbsolute, join } from "node:path";
|
|
@@ -40,6 +42,8 @@ async function readCodexAccessToken(codexHome) {
|
|
|
40
42
|
//#region src/index.ts
|
|
41
43
|
/** Harness route for subscription-backed Codex models. */
|
|
42
44
|
const PROVIDER = "openai-codex-local";
|
|
45
|
+
/** Separate route to avoid colliding with the configurable pi-ai Z.AI provider. */
|
|
46
|
+
const GLM_PROVIDER = "glm-coding-global";
|
|
43
47
|
const name = "llm-codex-share";
|
|
44
48
|
const inject = ["llm"];
|
|
45
49
|
/** Settings namespace: the Loader entry id this bundle's patch inserts. */
|
|
@@ -109,6 +113,23 @@ function apply(ctx, config = Config({})) {
|
|
|
109
113
|
jitterRatio: 0
|
|
110
114
|
}
|
|
111
115
|
};
|
|
116
|
+
const glmKey = launchEnvironmentOf(ctx).get("GLM_API_KEY")?.value;
|
|
117
|
+
const glmUpstream = glmKey?.trim() ? zaiProvider() : void 0;
|
|
118
|
+
const glmProfile = glmUpstream && {
|
|
119
|
+
...profileBase,
|
|
120
|
+
provider: "glm-coding-global",
|
|
121
|
+
displayName: "GLM Coding Plan (global)",
|
|
122
|
+
piProvider: {
|
|
123
|
+
...glmUpstream,
|
|
124
|
+
id: "glm-coding-global",
|
|
125
|
+
name: "GLM Coding Plan (global)",
|
|
126
|
+
auth: { apiKey: envApiKeyAuth("GLM Coding Plan API key", []) },
|
|
127
|
+
getModels: () => [...glmUpstream.getModels()].map((model) => ({
|
|
128
|
+
...model,
|
|
129
|
+
provider: "glm-coding-global"
|
|
130
|
+
}))
|
|
131
|
+
}
|
|
132
|
+
};
|
|
112
133
|
const resolveProfiles = () => {
|
|
113
134
|
const configured = config.additionalModelIds.get();
|
|
114
135
|
if (configured === lastIds && profiles !== void 0) return profiles;
|
|
@@ -130,16 +151,16 @@ function apply(ctx, config = Config({})) {
|
|
|
130
151
|
auth: { apiKey: envApiKeyAuth("Codex CLI login", []) },
|
|
131
152
|
getModels: () => models
|
|
132
153
|
};
|
|
133
|
-
profiles =
|
|
154
|
+
profiles = new Map([[PROVIDER, {
|
|
134
155
|
...profileBase,
|
|
135
156
|
piProvider: provider
|
|
136
|
-
}]]);
|
|
157
|
+
}], ...glmProfile === void 0 ? [] : [[GLM_PROVIDER, glmProfile]]]);
|
|
137
158
|
lastIds = configured;
|
|
138
159
|
return profiles;
|
|
139
160
|
};
|
|
140
161
|
const adapter = new PiAiAdapter({
|
|
141
162
|
profiles: resolveProfiles,
|
|
142
|
-
resolveApiKey: async () => readCodexAccessToken(config.codexHome),
|
|
163
|
+
resolveApiKey: async (provider) => provider === "glm-coding-global" ? glmKey : readCodexAccessToken(config.codexHome),
|
|
143
164
|
resolveAttachments: () => ctx.get("attachments"),
|
|
144
165
|
resolveImageAccess: (attachments, ref) => resolveImageAttachmentAccess(attachments, (hostPath) => ctx.get("fs")?.processPathFromHostPath(hostPath), ref),
|
|
145
166
|
auth: {
|
|
@@ -165,7 +186,7 @@ function apply(ctx, config = Config({})) {
|
|
|
165
186
|
settingsNs: SETTINGS_NS,
|
|
166
187
|
settingsPath: []
|
|
167
188
|
}]);
|
|
168
|
-
ctx.llm.registerAdapter([PROVIDER], adapter);
|
|
189
|
+
ctx.llm.registerAdapter(glmProfile === void 0 ? [PROVIDER] : [PROVIDER, GLM_PROVIDER], adapter);
|
|
169
190
|
}
|
|
170
191
|
//#endregion
|
|
171
|
-
export { Config, PROVIDER, SETTINGS_NS, apply, codexAuthPath, inject, name, readCodexAccessToken };
|
|
192
|
+
export { Config, GLM_PROVIDER, PROVIDER, SETTINGS_NS, apply, codexAuthPath, inject, name, readCodexAccessToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-codex-share",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Use the local Codex CLI ChatGPT subscription login as a DeepSeek Harness LLM provider",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -44,19 +44,19 @@
|
|
|
44
44
|
"@earendil-works/pi-ai": "~0.87.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@deepseek-ai/cordis": "link
|
|
48
|
-
"@deepseek-ai/dsh-api-remotes": "link
|
|
49
|
-
"@deepseek-ai/dsh-app-boot": "link
|
|
50
|
-
"@deepseek-ai/dsh-attachment": "link
|
|
51
|
-
"@deepseek-ai/dsh-client-ui-renderer": "link
|
|
52
|
-
"@deepseek-ai/dsh-client-ui-settings": "link
|
|
53
|
-
"@deepseek-ai/dsh-client-ui-settings-models": "link
|
|
54
|
-
"@deepseek-ai/dsh-client-ui-slots": "link
|
|
55
|
-
"@deepseek-ai/dsh-fs": "link
|
|
56
|
-
"@deepseek-ai/dsh-llm": "link
|
|
57
|
-
"@deepseek-ai/dsh-llm-pi-ai": "link
|
|
58
|
-
"@deepseek-ai/dsh-settings": "link
|
|
59
|
-
"@deepseek-ai/schemastery": "link
|
|
47
|
+
"@deepseek-ai/cordis": "link:../../deepseek-harness/vendor/cordis",
|
|
48
|
+
"@deepseek-ai/dsh-api-remotes": "link:../../deepseek-harness/packages/api/remotes",
|
|
49
|
+
"@deepseek-ai/dsh-app-boot": "link:../../deepseek-harness/packages/boot/app-boot",
|
|
50
|
+
"@deepseek-ai/dsh-attachment": "link:../../deepseek-harness/packages/attachment/attachment",
|
|
51
|
+
"@deepseek-ai/dsh-client-ui-renderer": "link:../../deepseek-harness/packages/client/ui-renderer",
|
|
52
|
+
"@deepseek-ai/dsh-client-ui-settings": "link:../../deepseek-harness/packages/client/ui-settings",
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-settings-models": "link:../../deepseek-harness/packages/client/ui-settings-models",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-slots": "link:../../deepseek-harness/packages/client/ui-slots",
|
|
55
|
+
"@deepseek-ai/dsh-fs": "link:../../deepseek-harness/packages/fs/fs",
|
|
56
|
+
"@deepseek-ai/dsh-llm": "link:../../deepseek-harness/packages/llm/llm",
|
|
57
|
+
"@deepseek-ai/dsh-llm-pi-ai": "link:../../deepseek-harness/packages/llm/llm-pi-ai",
|
|
58
|
+
"@deepseek-ai/dsh-settings": "link:../../deepseek-harness/packages/settings/settings",
|
|
59
|
+
"@deepseek-ai/schemastery": "link:../../deepseek-harness/vendor/schemastery",
|
|
60
60
|
"@types/node": "^22.20.0",
|
|
61
61
|
"@types/react": "~18.3.31",
|
|
62
62
|
"react": "^18.3.1",
|