dsh-codex-share 0.4.1 → 0.4.3
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 +42 -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, plus **GLM-5.3 Flash X** (`glm-5.3-flashx`) when upstream does not yet list it. Flash X inherits Flash's 1M context, 128K maximum output, image input, and reasoning capabilities; its cost estimate is left at zero until upstream supplies model-specific pricing (this does not imply free usage). [Z.AI's documentation](https://docs.z.ai/guides/vlm/glm-5.3-flash) currently says FlashX is not yet available on the Coding Plan; it is listed for forward compatibility, but requests may be rejected until your plan supports it.
|
|
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,39 @@ 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 glmCatalog = glmUpstream ? [...glmUpstream.getModels()] : [];
|
|
119
|
+
if (glmUpstream && !glmCatalog.some((model) => model.id === "glm-5.3-flashx")) {
|
|
120
|
+
const flash = glmCatalog.find((model) => model.id === "glm-5.3-flash");
|
|
121
|
+
if (flash === void 0) throw new TypeError("The Z.AI catalog must include GLM-5.3-Flash");
|
|
122
|
+
glmCatalog.push({
|
|
123
|
+
...flash,
|
|
124
|
+
id: "glm-5.3-flashx",
|
|
125
|
+
name: "GLM-5.3 Flash X",
|
|
126
|
+
cost: {
|
|
127
|
+
input: 0,
|
|
128
|
+
output: 0,
|
|
129
|
+
cacheRead: 0,
|
|
130
|
+
cacheWrite: 0
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
const glmProfile = glmUpstream && {
|
|
135
|
+
...profileBase,
|
|
136
|
+
provider: "glm-coding-global",
|
|
137
|
+
displayName: "GLM Coding Plan (global)",
|
|
138
|
+
piProvider: {
|
|
139
|
+
...glmUpstream,
|
|
140
|
+
id: "glm-coding-global",
|
|
141
|
+
name: "GLM Coding Plan (global)",
|
|
142
|
+
auth: { apiKey: envApiKeyAuth("GLM Coding Plan API key", []) },
|
|
143
|
+
getModels: () => glmCatalog.map((model) => ({
|
|
144
|
+
...model,
|
|
145
|
+
provider: "glm-coding-global"
|
|
146
|
+
}))
|
|
147
|
+
}
|
|
148
|
+
};
|
|
112
149
|
const resolveProfiles = () => {
|
|
113
150
|
const configured = config.additionalModelIds.get();
|
|
114
151
|
if (configured === lastIds && profiles !== void 0) return profiles;
|
|
@@ -130,16 +167,16 @@ function apply(ctx, config = Config({})) {
|
|
|
130
167
|
auth: { apiKey: envApiKeyAuth("Codex CLI login", []) },
|
|
131
168
|
getModels: () => models
|
|
132
169
|
};
|
|
133
|
-
profiles =
|
|
170
|
+
profiles = new Map([[PROVIDER, {
|
|
134
171
|
...profileBase,
|
|
135
172
|
piProvider: provider
|
|
136
|
-
}]]);
|
|
173
|
+
}], ...glmProfile === void 0 ? [] : [[GLM_PROVIDER, glmProfile]]]);
|
|
137
174
|
lastIds = configured;
|
|
138
175
|
return profiles;
|
|
139
176
|
};
|
|
140
177
|
const adapter = new PiAiAdapter({
|
|
141
178
|
profiles: resolveProfiles,
|
|
142
|
-
resolveApiKey: async () => readCodexAccessToken(config.codexHome),
|
|
179
|
+
resolveApiKey: async (provider) => provider === "glm-coding-global" ? glmKey : readCodexAccessToken(config.codexHome),
|
|
143
180
|
resolveAttachments: () => ctx.get("attachments"),
|
|
144
181
|
resolveImageAccess: (attachments, ref) => resolveImageAttachmentAccess(attachments, (hostPath) => ctx.get("fs")?.processPathFromHostPath(hostPath), ref),
|
|
145
182
|
auth: {
|
|
@@ -165,7 +202,7 @@ function apply(ctx, config = Config({})) {
|
|
|
165
202
|
settingsNs: SETTINGS_NS,
|
|
166
203
|
settingsPath: []
|
|
167
204
|
}]);
|
|
168
|
-
ctx.llm.registerAdapter([PROVIDER], adapter);
|
|
205
|
+
ctx.llm.registerAdapter(glmProfile === void 0 ? [PROVIDER] : [PROVIDER, GLM_PROVIDER], adapter);
|
|
169
206
|
}
|
|
170
207
|
//#endregion
|
|
171
|
-
export { Config, PROVIDER, SETTINGS_NS, apply, codexAuthPath, inject, name, readCodexAccessToken };
|
|
208
|
+
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.3",
|
|
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",
|