@edge-sky/dsh-oauth-adapter 0.1.1-rc.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 edge-sky
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,4 @@
1
+ # Bilingual-pair consistency record: the git blob hash of each side as of the
2
+ # last confirmed-consistent state. Both languages carry equal authority.
3
+ README.md: daae18fd1e5da6e5cd347f1f5a54fe89af9e201a
4
+ README.zh.md: 96548d8ee3ae773c8f3d04af3815b51d3f6d9b2e
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # dsh-oauth-adapter
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ A Cordis plugin that adds model-provider OAuth login entry points to DSH (DeepSeek Harness). It currently supports:
6
+
7
+ - [x] OpenAI Codex
8
+
9
+ - [x] GitHub Copilot
10
+
11
+ ## Getting Started
12
+
13
+ Install the npm package into DSH's `web` profile:
14
+
15
+ ```sh
16
+ dsh plugin --profile web add @edge-sky/dsh-oauth-adapter
17
+ ```
18
+
19
+ After installation, DSH automatically adds the bundle to the profile. Start DSH:
20
+
21
+ ```sh
22
+ dsh web --no-open
23
+ ```
24
+
25
+ The plugin uses the runtime dependencies provided by the current DSH installation. At startup, it reports an incompatible version directly if the OAuth bridge or the Codex/Copilot providers are missing.
26
+
27
+ Once DSH starts, connect Codex or GitHub Copilot under **Settings → Models**.
28
+
29
+ ## How It Works
30
+
31
+ DSH integrates pi-ai through the `@deepseek-ai/dsh-llm-pi-ai` adapter, but does not provide an OAuth entry point. `@edge-sky/dsh-oauth-adapter` registers pi-ai's existing Codex and Copilot login flows with the DSH Authorization Service.
32
+
33
+ The plugin itself does not manage OAuth credentials or maintain login state. Maybe DSH will support these login methods in the future, but for now this plugin provides a way to use them.
package/README.zh.md ADDED
@@ -0,0 +1,33 @@
1
+ # dsh-oauth-adapter
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 为 DSH(DeepSeek Harness)提供模型 OAuth 登录入口的 Cordis 插件。当前支持:
6
+
7
+ - [x] OpenAI Codex
8
+
9
+ - [x] GitHub Copilot
10
+
11
+ ## 开始使用
12
+
13
+ 将 npm 包安装到 DSH 的 `web` profile:
14
+
15
+ ```sh
16
+ dsh plugin --profile web add @edge-sky/dsh-oauth-adapter
17
+ ```
18
+
19
+ 安装后,DSH 会自动将 Bundle 加入该 profile。启动 DSH:
20
+
21
+ ```sh
22
+ dsh web --no-open
23
+ ```
24
+
25
+ 插件使用当前 DSH 安装提供的运行时依赖;启动时若缺少 OAuth bridge 或 Codex/Copilot Provider,会直接报告版本不兼容。
26
+
27
+ 启动后,在**设置 → 模型**中连接 Codex 或 GitHub Copilot。
28
+
29
+ ## 工作原理
30
+
31
+ DSH 通过 `@deepseek-ai/dsh-llm-pi-ai` 适配器接入 pi-ai,但并没有提供 OAuth 的入口。`@edge-sky/dsh-oauth-adapter` 将 pi-ai 已有的 Codex 与 Copilot 登录流程注册到 DSH Authorization Service。
32
+
33
+ 插件本身并不承担 OAuth 凭证管理与维持登录态的职责,或许将来 DSH 会官方支持这一登录方式,但至少现在你可以通过这个插件体验它
@@ -0,0 +1,3 @@
1
+ - insert:
2
+ - id: dsh-oauth-adapter
3
+ name: '@edge-sky/dsh-oauth-adapter'
@@ -0,0 +1,17 @@
1
+ /** Runtime compatibility checks for the DSH-provided pi-ai OAuth bridge. */
2
+ type PiAiModule = typeof import('@deepseek-ai/dsh-llm-pi-ai');
3
+ /** The pi-ai exports this plugin consumes from the active DSH installation. */
4
+ export type PiAiOAuthBridge = Pick<PiAiModule, 'authContextFrom' | 'credentialStoreFrom' | 'piAiOAuthFlow' | 'piAiOAuthProviderIds'>;
5
+ /**
6
+ * Validate the bridge exported by the active DSH installation.
7
+ * @param candidate - dynamically imported module namespace.
8
+ * @returns the compatible OAuth bridge.
9
+ */
10
+ export declare function resolvePiAiOAuthBridge(candidate: unknown): PiAiOAuthBridge;
11
+ /**
12
+ * Load the OAuth bridge through DSH's profile module fallback.
13
+ * @returns the validated bridge supplied by the active DSH installation.
14
+ */
15
+ export declare function loadPiAiOAuthBridge(): Promise<PiAiOAuthBridge>;
16
+ export {};
17
+ //# sourceMappingURL=compat.d.ts.map
package/lib/compat.js ADDED
@@ -0,0 +1,60 @@
1
+ /** Runtime compatibility checks for the DSH-provided pi-ai OAuth bridge. */
2
+ const BRIDGE_PACKAGE = '@deepseek-ai/dsh-llm-pi-ai';
3
+ const PACKAGE_NAME = '@edge-sky/dsh-oauth-adapter';
4
+ const REQUIRED_EXPORTS = [
5
+ 'authContextFrom',
6
+ 'credentialStoreFrom',
7
+ 'piAiOAuthFlow',
8
+ 'piAiOAuthProviderIds',
9
+ ];
10
+ const REQUIRED_PROVIDERS = ['openai-codex', 'github-copilot'];
11
+ /** Whether a dynamically loaded module exposes a callable property. */
12
+ function hasFunction(value, key) {
13
+ return typeof value === 'object' && value !== null
14
+ && typeof value[key] === 'function';
15
+ }
16
+ /**
17
+ * Validate the bridge exported by the active DSH installation.
18
+ * @param candidate - dynamically imported module namespace.
19
+ * @returns the compatible OAuth bridge.
20
+ */
21
+ export function resolvePiAiOAuthBridge(candidate) {
22
+ const missing = REQUIRED_EXPORTS.filter(key => !hasFunction(candidate, key));
23
+ if (missing.length > 0) {
24
+ throw new Error(`${PACKAGE_NAME}: incompatible DSH installation: ${BRIDGE_PACKAGE} does not provide `
25
+ + `${missing.join(', ')}; install a DSH version with the pi-ai OAuth bridge`);
26
+ }
27
+ const bridge = candidate;
28
+ let providers;
29
+ try {
30
+ providers = bridge.piAiOAuthProviderIds();
31
+ }
32
+ catch (cause) {
33
+ throw new Error(`${PACKAGE_NAME}: incompatible DSH installation: ${BRIDGE_PACKAGE} cannot enumerate OAuth providers`, { cause });
34
+ }
35
+ if (!Array.isArray(providers) || !providers.every(provider => typeof provider === 'string')) {
36
+ throw new Error(`${PACKAGE_NAME}: incompatible DSH installation: ${BRIDGE_PACKAGE} returned an invalid OAuth provider directory`);
37
+ }
38
+ const absentProviders = REQUIRED_PROVIDERS.filter(provider => !providers.includes(provider));
39
+ if (absentProviders.length > 0) {
40
+ throw new Error(`${PACKAGE_NAME}: incompatible DSH installation: ${BRIDGE_PACKAGE} does not support OAuth provider(s) `
41
+ + `${absentProviders.join(', ')}`);
42
+ }
43
+ return bridge;
44
+ }
45
+ /**
46
+ * Load the OAuth bridge through DSH's profile module fallback.
47
+ * @returns the validated bridge supplied by the active DSH installation.
48
+ */
49
+ export async function loadPiAiOAuthBridge() {
50
+ let candidate;
51
+ try {
52
+ candidate = await import(BRIDGE_PACKAGE);
53
+ }
54
+ catch (cause) {
55
+ throw new Error(`${PACKAGE_NAME}: incompatible DSH installation: cannot load ${BRIDGE_PACKAGE}; `
56
+ + 'install a DSH version with the pi-ai OAuth bridge', { cause });
57
+ }
58
+ return resolvePiAiOAuthBridge(candidate);
59
+ }
60
+ //# sourceMappingURL=compat.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * OAuth authorization-flow contributions for DSH LLM providers.
3
+ *
4
+ * The plugin owns only the human authorization interaction. Provider request
5
+ * protocols, token refresh, model conversion, tools, and streaming stay with
6
+ * the adapter family whose credential record the flow writes.
7
+ * @module @edge-sky/dsh-oauth-adapter
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ import z from '@deepseek-ai/schemastery';
11
+ import type { AuthorizationService } from '@deepseek-ai/dsh-authorization';
12
+ declare module '@deepseek-ai/dsh-authorization/types' {
13
+ interface AuthorizationSubjectMap {
14
+ /** OAuth flow joined to one DSH LLM provider route. */
15
+ 'llm-provider': {
16
+ kind: 'llm-provider';
17
+ provider: string;
18
+ };
19
+ }
20
+ }
21
+ /** Plugin configuration. */
22
+ export interface Config {
23
+ /** Emit redacted OAuth lifecycle diagnostics to stderr at debug level. */
24
+ debug?: boolean;
25
+ }
26
+ /** Runtime-validated plugin configuration. */
27
+ export declare const Config: z<Config>;
28
+ /** Cordis plugin name. */
29
+ export declare const name = "dsh-oauth-adapter";
30
+ /** Required authorization registry. */
31
+ export declare const inject: string[];
32
+ type OAuthContext = Context & {
33
+ authorization: AuthorizationService;
34
+ };
35
+ /** Register Codex and Copilot OAuth flows. */
36
+ export declare function apply(ctx: OAuthContext, config: Config): Promise<void>;
37
+ export {};
38
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js ADDED
@@ -0,0 +1,48 @@
1
+ /**
2
+ * OAuth authorization-flow contributions for DSH LLM providers.
3
+ *
4
+ * The plugin owns only the human authorization interaction. Provider request
5
+ * protocols, token refresh, model conversion, tools, and streaming stay with
6
+ * the adapter family whose credential record the flow writes.
7
+ * @module @edge-sky/dsh-oauth-adapter
8
+ */
9
+ import { Logger } from '@deepseek-ai/cordis';
10
+ import z from '@deepseek-ai/schemastery';
11
+ import { loadPiAiOAuthBridge } from './compat.js';
12
+ /** Runtime-validated plugin configuration. */
13
+ export const Config = z.object({
14
+ debug: z.boolean().default(false),
15
+ });
16
+ /** Cordis plugin name. */
17
+ export const name = 'dsh-oauth-adapter';
18
+ /** Required authorization registry. */
19
+ export const inject = ['authorization'];
20
+ /** Install the opt-in debug logger and return its secret-free message sink. */
21
+ function debugSink(ctx, enabled) {
22
+ if (!enabled)
23
+ return undefined;
24
+ const loggerName = 'dsh-oauth-adapter';
25
+ const exporter = {
26
+ colors: false,
27
+ levels: { default: -1, [loggerName]: 3 /* LoggerLevel.DEBUG */ },
28
+ export: message => void process.stderr.write(`[D] ${message.name} ${Logger.format(exporter, message)}\n`),
29
+ };
30
+ ctx.logger.exporter(exporter);
31
+ const logger = ctx.logger(loggerName);
32
+ return (message) => { logger.debug('%s', message); };
33
+ }
34
+ /** Register Codex and Copilot OAuth flows. */
35
+ export async function apply(ctx, config) {
36
+ const { authContextFrom, credentialStoreFrom, piAiOAuthFlow, } = await loadPiAiOAuthBridge();
37
+ const debug = debugSink(ctx, config.debug === true);
38
+ debug?.('diagnostics enabled; secret values and provider payloads are redacted');
39
+ const auth = { credentials: credentialStoreFrom(ctx), authContext: authContextFrom(ctx) };
40
+ const diagnosticOptions = debug === undefined ? {} : { debug };
41
+ const register = (provider, flow) => {
42
+ const subject = { kind: 'llm-provider', provider };
43
+ ctx.authorization.registerFlow({ ...flow, subject });
44
+ };
45
+ register('openai-codex', piAiOAuthFlow('openai-codex', auth, diagnosticOptions));
46
+ register('github-copilot', piAiOAuthFlow('github-copilot', auth, diagnosticOptions));
47
+ }
48
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ /** Package-owned invariant companion for `@edge-sky/dsh-oauth-adapter`. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ /** Cordis companion plugin name. */
4
+ export declare const name = "dsh-oauth-adapter-invariant";
5
+ /** Service required before package ownership is registered. */
6
+ export declare const inject: string[];
7
+ /** Register this package's invariant companion. */
8
+ export declare const apply: (ctx: Context) => Promise<() => void>;
9
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,11 @@
1
+ /** Package-owned invariant companion for `@edge-sky/dsh-oauth-adapter`. */
2
+ const PACKAGE_NAME = '@edge-sky/dsh-oauth-adapter';
3
+ /** Cordis companion plugin name. */
4
+ export const name = 'dsh-oauth-adapter-invariant';
5
+ /** Service required before package ownership is registered. */
6
+ export const inject = ['invariants'];
7
+ /** No runtime invariant: dsh-authorization asserts the registered-flow lifecycle. */
8
+ const install = () => { };
9
+ /** Register this package's invariant companion. */
10
+ export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
11
+ //# sourceMappingURL=invariant.js.map
package/package.json ADDED
@@ -0,0 +1,82 @@
1
+ {
2
+ "name": "@edge-sky/dsh-oauth-adapter",
3
+ "description": "OAuth authorization-flow contributions for DSH LLM providers",
4
+ "version": "0.1.1-rc.3",
5
+ "author": {
6
+ "name": "edge-sky",
7
+ "url": "https://github.com/edge-sky"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/edge-sky/dsh-oauth.git"
15
+ },
16
+ "engines": {
17
+ "node": "^22.19.0 || >=24.0.0"
18
+ },
19
+ "type": "module",
20
+ "main": "lib/index.js",
21
+ "types": "lib/index.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "types": "./lib/index.d.ts",
25
+ "default": "./lib/index.js"
26
+ },
27
+ "./invariant": {
28
+ "types": "./lib/invariant.d.ts",
29
+ "default": "./lib/invariant.js"
30
+ },
31
+ "./src/*": "./src/*",
32
+ "./package.json": "./package.json"
33
+ },
34
+ "files": [
35
+ "cordis.patch.yml",
36
+ "lib/**/*.js",
37
+ "lib/**/*.d.ts"
38
+ ],
39
+ "license": "MIT",
40
+ "dsh": {
41
+ "bundle": {
42
+ "patch": "./cordis.patch.yml"
43
+ }
44
+ },
45
+ "peerDependencies": {
46
+ "@deepseek-ai/cordis": "^4.0.1",
47
+ "@deepseek-ai/dsh-authorization": ">=0.1.1-rc.3 <0.2.0",
48
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
49
+ "@deepseek-ai/dsh-llm-pi-ai": ">=0.1.1-rc.3 <0.2.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "@deepseek-ai/cordis": {
53
+ "optional": true
54
+ },
55
+ "@deepseek-ai/dsh-authorization": {
56
+ "optional": true
57
+ },
58
+ "@deepseek-ai/dsh-invariants": {
59
+ "optional": true
60
+ },
61
+ "@deepseek-ai/dsh-llm-pi-ai": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "dependencies": {
66
+ "@deepseek-ai/schemastery": "^3.18.1"
67
+ },
68
+ "devDependencies": {
69
+ "@deepseek-ai/cordis": "^4.0.1",
70
+ "@deepseek-ai/dsh-authorization": ">=0.1.1-rc.3 <0.2.0",
71
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
72
+ "@deepseek-ai/dsh-llm-pi-ai": ">=0.1.1-rc.3 <0.2.0",
73
+ "@types/node": "^22.20.0",
74
+ "typescript": "^6.0.3",
75
+ "vitest": "^4.1.8"
76
+ },
77
+ "scripts": {
78
+ "build": "tsc -p tsconfig.json",
79
+ "test": "pnpm run build && vitest run",
80
+ "typecheck": "tsc -p tsconfig.json --noEmit"
81
+ }
82
+ }