dsh-codex-community 0.0.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/CONTRIBUTING.en.md +54 -0
  3. package/CONTRIBUTING.md +54 -0
  4. package/LICENSE +201 -0
  5. package/NOTICE +12 -0
  6. package/README.en.md +98 -0
  7. package/README.md +98 -0
  8. package/SECURITY.md +41 -0
  9. package/SUPPORT.md +17 -0
  10. package/THIRD_PARTY_NOTICES.md +25 -0
  11. package/codex-community.patch.yml +13 -0
  12. package/dist/client/index.js +1037 -0
  13. package/dist/host/index.mjs +98 -0
  14. package/dist/internal/authorization-bridge.mjs +662 -0
  15. package/dist/internal/authorization-commit-tracker.mjs +49 -0
  16. package/dist/internal/codex-authorization.mjs +202 -0
  17. package/dist/internal/codex-credential-store.mjs +164 -0
  18. package/dist/internal/codex-identifiers.mjs +4 -0
  19. package/dist/internal/codex-pi-provider.mjs +137 -0
  20. package/dist/internal/codex-provider-runtime.mjs +256 -0
  21. package/dist/internal/codex-route-adapter.mjs +133 -0
  22. package/dist/internal/codex-session-resources.mjs +64 -0
  23. package/dist/internal/failure-normalizer.mjs +456 -0
  24. package/dist/internal/image-policy.mjs +45 -0
  25. package/dist/internal/quota-observer.mjs +142 -0
  26. package/dist/internal/reliability.mjs +12 -0
  27. package/dist/internal/remote-image-input.mjs +801 -0
  28. package/dist/internal/session-preference-command.mjs +52 -0
  29. package/dist/internal/session-preferences.mjs +93 -0
  30. package/dist/internal/stream-resilience.mjs +273 -0
  31. package/docs/README.en.md +15 -0
  32. package/docs/README.md +15 -0
  33. package/docs/architecture.en.md +106 -0
  34. package/docs/architecture.md +106 -0
  35. package/docs/compatibility.en.md +53 -0
  36. package/docs/compatibility.md +53 -0
  37. package/docs/configuration.en.md +61 -0
  38. package/docs/configuration.md +61 -0
  39. package/docs/contribution-sources.en.md +35 -0
  40. package/docs/contribution-sources.md +35 -0
  41. package/docs/github-about.md +15 -0
  42. package/docs/releases/v0.0.1.acceptance.json +160 -0
  43. package/docs/releases/v0.0.1.md +174 -0
  44. package/docs/releasing.en.md +290 -0
  45. package/docs/releasing.md +290 -0
  46. package/docs/testing.en.md +85 -0
  47. package/docs/testing.md +85 -0
  48. package/docs/troubleshooting.en.md +47 -0
  49. package/docs/troubleshooting.md +47 -0
  50. package/package.json +144 -0
  51. package/types/client.d.ts +160 -0
  52. package/types/index.d.ts +22 -0
  53. package/types/reliability.d.ts +78 -0
package/package.json ADDED
@@ -0,0 +1,144 @@
1
+ {
2
+ "name": "dsh-codex-community",
3
+ "version": "0.0.1",
4
+ "description": "DeepSeek Harness Codex 社区接入 / Community Codex integration for DeepSeek Harness",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "author": "YukiRyou",
8
+ "engines": {
9
+ "node": ">=22.19.0 <25"
10
+ },
11
+ "packageManager": "pnpm@10.34.5",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/yoshino-xiao7/dsh-codex.git"
15
+ },
16
+ "homepage": "https://github.com/yoshino-xiao7/dsh-codex#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/yoshino-xiao7/dsh-codex/issues"
19
+ },
20
+ "keywords": [
21
+ "deepseek-harness",
22
+ "dsh",
23
+ "dsh-plugin",
24
+ "codex",
25
+ "chatgpt",
26
+ "oauth"
27
+ ],
28
+ "exports": {
29
+ ".": {
30
+ "types": "./types/index.d.ts",
31
+ "default": "./dist/host/index.mjs"
32
+ },
33
+ "./client": {
34
+ "types": "./types/client.d.ts",
35
+ "default": "./dist/client/index.js"
36
+ },
37
+ "./reliability": {
38
+ "types": "./types/reliability.d.ts",
39
+ "default": "./dist/internal/reliability.mjs"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
43
+ "dsh": {
44
+ "bundle": {
45
+ "patch": "codex-community.patch.yml"
46
+ },
47
+ "client": {
48
+ "inject": [
49
+ "@deepseek-ai/dsh-client-connection",
50
+ "@deepseek-ai/dsh-client-runtime",
51
+ "@deepseek-ai/dsh-client-ui-settings",
52
+ "@deepseek-ai/dsh-client-locale"
53
+ ],
54
+ "platform": "web"
55
+ }
56
+ },
57
+ "files": [
58
+ "dist",
59
+ "types",
60
+ "docs",
61
+ "codex-community.patch.yml",
62
+ "README.md",
63
+ "README.en.md",
64
+ "CHANGELOG.md",
65
+ "CONTRIBUTING.md",
66
+ "CONTRIBUTING.en.md",
67
+ "SECURITY.md",
68
+ "SUPPORT.md",
69
+ "LICENSE",
70
+ "NOTICE",
71
+ "THIRD_PARTY_NOTICES.md"
72
+ ],
73
+ "scripts": {
74
+ "build": "node scripts/build.mjs",
75
+ "lint": "node scripts/check-syntax.mjs",
76
+ "typecheck": "tsc -p tsconfig.types.json",
77
+ "test": "node --test test/*.test.mjs",
78
+ "test:regression": "node --test test/failure-normalizer.test.mjs test/image-policy.test.mjs test/stream-resilience.test.mjs test/provider-reliability-public-api.test.mjs test/llm-runtime-integration.test.mjs test/codex-session-resources.test.mjs",
79
+ "smoke:dsh-profile": "node scripts/smoke-dsh-profile.mjs",
80
+ "check:i18n": "node scripts/check-i18n.mjs",
81
+ "check:pack": "node scripts/check-pack.mjs",
82
+ "generate:sbom": "node scripts/generate-sbom.mjs",
83
+ "release:prepare": "node scripts/prepare-release.mjs",
84
+ "release:candidate": "node scripts/build-release-candidate.mjs",
85
+ "release:acceptance": "node scripts/record-release-acceptance.mjs",
86
+ "verify:release": "node scripts/verify-release.mjs --mode=draft",
87
+ "verify:release:publish": "node scripts/verify-release.mjs --mode=publish",
88
+ "check": "npm run lint && npm run typecheck && npm run test && npm run build && npm run check:i18n && npm run check:pack",
89
+ "prepack": "npm run build",
90
+ "prepublishOnly": "npm run verify:release:publish"
91
+ },
92
+ "peerDependencies": {
93
+ "@deepseek-ai/cordis": ">=4.0.1 <5",
94
+ "@deepseek-ai/dsh-client-connection": "0.1.1-rc.2",
95
+ "@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
96
+ "@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
97
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.1-rc.2",
98
+ "@deepseek-ai/dsh-commands": "0.1.1-rc.2",
99
+ "@deepseek-ai/dsh-credentials": "0.1.1-rc.2",
100
+ "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
101
+ "@deepseek-ai/dsh-llm-pi-ai": "0.1.1-rc.2",
102
+ "@deepseek-ai/dsh-settings": "0.1.1-rc.2",
103
+ "@deepseek-ai/schemastery": ">=3.18.1 <4"
104
+ },
105
+ "peerDependenciesMeta": {
106
+ "@deepseek-ai/dsh-client-connection": {
107
+ "optional": true
108
+ },
109
+ "@deepseek-ai/dsh-client-locale": {
110
+ "optional": true
111
+ },
112
+ "@deepseek-ai/dsh-client-runtime": {
113
+ "optional": true
114
+ },
115
+ "@deepseek-ai/dsh-client-ui-settings": {
116
+ "optional": true
117
+ },
118
+ "@deepseek-ai/dsh-commands": {
119
+ "optional": true
120
+ }
121
+ },
122
+ "devDependencies": {
123
+ "@deepseek-ai/cordis": "4.0.1",
124
+ "@deepseek-ai/dsh-app-boot": "0.1.1-rc.2",
125
+ "@deepseek-ai/dsh-attachment-local": "0.1.1-rc.2",
126
+ "@deepseek-ai/dsh-llm": "0.1.1-rc.2",
127
+ "@deepseek-ai/dsh-llm-pi-ai": "0.1.1-rc.2",
128
+ "@deepseek-ai/dsh-settings": "0.1.1-rc.2",
129
+ "@deepseek-ai/dsh-system-prompt": "0.1.1-rc.2",
130
+ "@deepseek-ai/dsh-tool-fs": "0.1.1-rc.2",
131
+ "@deepseek-ai/dsh-tools": "0.1.1-rc.2",
132
+ "@deepseek-ai/schemastery": "3.18.1",
133
+ "typescript": "5.9.2"
134
+ },
135
+ "publishConfig": {
136
+ "access": "public",
137
+ "registry": "https://registry.npmjs.org/",
138
+ "provenance": true
139
+ },
140
+ "dependencies": {
141
+ "@deepseek-ai/dsh-authorization": "0.1.1-rc.2",
142
+ "@earendil-works/pi-ai": "0.82.1"
143
+ }
144
+ }
@@ -0,0 +1,160 @@
1
+ export declare const CHANNEL: "/dsh-codex"
2
+ export declare const CODEX_PROVIDER: "dsh-codex"
3
+ export declare const NS: "settings.codex"
4
+ export declare const inject: readonly ["slots", "locale", "connection", "settingsScope"]
5
+
6
+ export interface AuthorizationNotice {
7
+ message: string
8
+ url?: string
9
+ code?: string
10
+ }
11
+
12
+ export type AuthorizationPrompt =
13
+ | { kind: "text" | "secret"; message: string; placeholder?: string }
14
+ | {
15
+ kind: "select"
16
+ message: string
17
+ options: readonly { id: string; label: string; description?: string }[]
18
+ }
19
+
20
+ export type AuthorizationEvent =
21
+ | { seq: number; type: "notice"; notice: AuthorizationNotice }
22
+ | { seq: number; type: "prompt"; promptId: string; prompt: AuthorizationPrompt }
23
+ | { seq: number; type: "prompt-closed"; promptId: string }
24
+ | { seq: number; type: "settled"; status: "authorized" | "cancelled" }
25
+ | { seq: number; type: "failed"; error: { code: string; message: string } }
26
+
27
+ export interface AuthorizationStatus {
28
+ flow?: {
29
+ key: "dsh-codex/openai-codex"
30
+ label: string
31
+ methods: readonly { id: string; label: string }[]
32
+ inFlight: boolean
33
+ }
34
+ credential: {
35
+ configured: boolean
36
+ state: "signed-in" | "signed-out" | "invalid"
37
+ kind?: string
38
+ writable: boolean
39
+ }
40
+ quota:
41
+ | { readonly status: "unknown" }
42
+ | { readonly status: "recent-success"; readonly observedAt: number }
43
+ | {
44
+ readonly status: "exhausted"
45
+ readonly observedAt: number
46
+ readonly resetAt?: number
47
+ }
48
+ }
49
+
50
+ export interface AuthorizationClient {
51
+ describe(signal?: AbortSignal): Promise<AuthorizationStatus>
52
+ watch(attemptId: string, after: number, signal?: AbortSignal): Promise<{
53
+ attemptId: string
54
+ events: readonly AuthorizationEvent[]
55
+ nextSeq: number
56
+ done: boolean
57
+ }>
58
+ start(method?: string, signal?: AbortSignal): Promise<{ attemptId: string }>
59
+ answer(attemptId: string, promptId: string, value: string): Promise<{ accepted: boolean }>
60
+ decline(attemptId: string, promptId: string): Promise<{ accepted: boolean }>
61
+ cancel(attemptId?: string): Promise<{
62
+ accepted: boolean
63
+ reason?: "commit-in-progress"
64
+ }>
65
+ logout(): Promise<{ signedOut: boolean }>
66
+ }
67
+
68
+ export interface CodexModelCatalogEntry {
69
+ id: string
70
+ name?: string
71
+ }
72
+
73
+ export interface CodexModelEnablementSnapshot {
74
+ kind: "ready"
75
+ writable: boolean
76
+ revision: number
77
+ settingsNs: string
78
+ settingsPath: string[]
79
+ models: CodexModelCatalogEntry[]
80
+ catalogIds: string[]
81
+ selectedIds: string[]
82
+ configuredModels: Array<{ id: string; [key: string]: unknown }>
83
+ }
84
+
85
+ export interface ModelEnablementClient {
86
+ readonly available: boolean
87
+ load(signal?: AbortSignal): Promise<CodexModelEnablementSnapshot | { kind: "unavailable" }>
88
+ save(
89
+ snapshot: CodexModelEnablementSnapshot,
90
+ selectedIds: string[],
91
+ signal?: AbortSignal,
92
+ ): Promise<CodexModelEnablementSnapshot>
93
+ subscribe(listener: () => void): () => void
94
+ }
95
+
96
+ export interface SettingsNamespaceMirrorView {
97
+ ns: string
98
+ schema: unknown
99
+ value: unknown
100
+ base?: unknown
101
+ user?: unknown
102
+ applies: "live" | "restart"
103
+ secrets: readonly { path: readonly string[]; set: boolean }[]
104
+ revision: number
105
+ }
106
+
107
+ export interface SettingsDescribeFace {
108
+ getSnapshot(): {
109
+ status: "idle" | "loading" | "ready" | "unavailable"
110
+ view: {
111
+ namespaces: readonly SettingsNamespaceMirrorView[]
112
+ writable: boolean
113
+ hasDocument: boolean
114
+ } | undefined
115
+ error: string | null
116
+ }
117
+ subscribe(listener: () => void): () => void
118
+ ensure(): Promise<void>
119
+ acceptView(view: SettingsNamespaceMirrorView): void
120
+ }
121
+
122
+ export interface RpcConnection {
123
+ rpc: {
124
+ call(
125
+ channel: string,
126
+ endpoint: string,
127
+ payload: Record<string, unknown>,
128
+ signal?: AbortSignal,
129
+ ): Promise<{ ok: true; value: unknown } | { ok: false; error: { code: string; message: string } }>
130
+ }
131
+ }
132
+
133
+ export declare function createAuthorizationClient(connection: RpcConnection): AuthorizationClient
134
+ export declare function createModelEnablementClient(
135
+ connection: unknown,
136
+ settingsFace?: SettingsDescribeFace,
137
+ ): ModelEnablementClient
138
+ export declare function safeQuotaSnapshot(value: unknown, now?: number):
139
+ | { status: "unknown" }
140
+ | { status: "recent-success"; observedAt: number }
141
+ | {
142
+ status: "exhausted"
143
+ observedAt: number
144
+ resetAt?: number
145
+ remainingMinutes?: number
146
+ }
147
+ export declare function AuthorizationSettings(props: {
148
+ client: AuthorizationClient
149
+ t(key: string): string
150
+ }): unknown
151
+ export declare function ModelEnablementSettings(props: {
152
+ client: ModelEnablementClient
153
+ t(key: string): string
154
+ }): unknown
155
+ export declare function CodexSettings(props: {
156
+ client: AuthorizationClient
157
+ modelClient: ModelEnablementClient
158
+ t(key: string): string
159
+ }): unknown
160
+ export declare function apply(ctx: unknown): void
@@ -0,0 +1,22 @@
1
+ import type { Context } from "@deepseek-ai/cordis"
2
+ import type Schema from "@deepseek-ai/schemastery"
3
+
4
+ export interface Config {
5
+ partialResponseRecovery?: boolean
6
+ models?: Array<{
7
+ id: string
8
+ name?: string
9
+ contextWindow?: number
10
+ maxTokens?: number
11
+ }>
12
+ cacheRetention?: "none" | "short" | "long"
13
+ streamIdleTimeoutMs?: number
14
+ maxRequestImageBytes?: number
15
+ requestImagePixelBudget?: number
16
+ requestImageMaxBytes?: number
17
+ }
18
+
19
+ export declare const name: "dsh-codex"
20
+ export declare const inject: readonly ["llm", "authorization", "credentials"]
21
+ export declare const Config: Schema<Config>
22
+ export declare function apply(ctx: Context, config?: Config): void
@@ -0,0 +1,78 @@
1
+ import type { GenerateOptions, LlmFailure, StreamChunk } from "@deepseek-ai/dsh-llm"
2
+
3
+ export interface ResolvedImagePolicy {
4
+ readonly maxRequestImageBytes: number
5
+ readonly requestImagePixelBudget: number
6
+ readonly requestImageMaxBytes: number
7
+ }
8
+
9
+ export interface AttachmentRequestPolicy {
10
+ readonly maxPixels: number
11
+ readonly maxBytes: number
12
+ }
13
+
14
+ export interface CodexFailureFacts {
15
+ readonly kind: "account-quota" | "ambiguous-limit" | "transport" | "other"
16
+ readonly status?: number
17
+ readonly reset?: {
18
+ readonly raw: string
19
+ readonly epochMs?: number
20
+ readonly iso?: string
21
+ }
22
+ readonly requestId?: string
23
+ }
24
+
25
+ export interface NormalizedCodexFailure {
26
+ readonly changed: boolean
27
+ readonly failure: LlmFailure
28
+ readonly facts: CodexFailureFacts
29
+ }
30
+
31
+ export type CodexQuotaSnapshot =
32
+ | { readonly status: "unknown" }
33
+ | { readonly status: "recent-success"; readonly observedAt: number }
34
+ | {
35
+ readonly status: "exhausted"
36
+ readonly observedAt: number
37
+ readonly resetAt?: number
38
+ }
39
+
40
+ export interface CodexQuotaObserver {
41
+ observeSuccess(now: number): CodexQuotaSnapshot
42
+ observeQuota(observation: { observedAt: number; resetAt?: number }): CodexQuotaSnapshot
43
+ snapshot(): CodexQuotaSnapshot
44
+ }
45
+
46
+ export declare const DEFAULT_IMAGE_POLICY: ResolvedImagePolicy
47
+ export declare function resolveImagePolicy(input?: Partial<ResolvedImagePolicy>): ResolvedImagePolicy
48
+ export declare function toAttachmentRequestPolicy(input?: Partial<ResolvedImagePolicy>): AttachmentRequestPolicy
49
+ export declare function parseEmbeddedJsonObjects(text: string): Record<string, unknown>[]
50
+ export declare function inspectCodexFailure(failure: LlmFailure | unknown): CodexFailureFacts
51
+ export declare function normalizeCodexFailure(failure: LlmFailure): NormalizedCodexFailure
52
+ export declare function createQuotaObserver(options?: {
53
+ clock?: () => number
54
+ staleMs?: number
55
+ maxResetHorizonMs?: number
56
+ }): CodexQuotaObserver
57
+ export declare function stabilizeCodexStream(
58
+ options: GenerateOptions,
59
+ next: () => AsyncIterable<StreamChunk>,
60
+ config?: {
61
+ partialResponseRecovery?: boolean
62
+ onRecovery?: (detail: {
63
+ provider: string
64
+ model: string
65
+ code: string
66
+ requestId?: string
67
+ }) => void
68
+ onQuota?: (detail: {
69
+ provider: string
70
+ model: string
71
+ resetAt?: number
72
+ }) => void
73
+ onSuccess?: (detail: {
74
+ provider: string
75
+ model: string
76
+ }) => void
77
+ },
78
+ ): AsyncIterable<StreamChunk>