@pure01fx/dsh-openai-codex-auth 0.9.0 → 0.10.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/CHANGELOG.md +15 -0
- package/CODEX-COMPATIBILITY.md +99 -0
- package/README.md +62 -1
- package/client.js +23 -2
- package/lib/catalog.d.ts +1 -0
- package/lib/catalog.js +5 -0
- package/lib/cloud-context.d.ts +20 -0
- package/lib/cloud-context.js +89 -0
- package/lib/cloud-http.d.ts +28 -0
- package/lib/cloud-http.js +170 -0
- package/lib/cloud-images.d.ts +51 -0
- package/lib/cloud-images.js +122 -0
- package/lib/cloud-media.d.ts +52 -0
- package/lib/cloud-media.js +112 -0
- package/lib/cloud-search.d.ts +31 -0
- package/lib/cloud-search.js +172 -0
- package/lib/cloud-tools.d.ts +25 -0
- package/lib/cloud-tools.js +129 -0
- package/lib/cloud-vision.d.ts +34 -0
- package/lib/cloud-vision.js +108 -0
- package/lib/cloud-web-tool.d.ts +12 -0
- package/lib/cloud-web-tool.js +241 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +45 -22
- package/lib/native-http.d.ts +2 -0
- package/lib/native-http.js +1 -0
- package/lib/native-websocket-socket.js +7 -3
- package/lib/responses.d.ts +4 -2
- package/lib/responses.js +19 -5
- package/lib/upstream.d.ts +2 -0
- package/lib/upstream.js +2 -0
- package/package.json +77 -18
package/lib/native-http.js
CHANGED
|
@@ -119,6 +119,7 @@ async function resolveImage(block, options, signal) {
|
|
|
119
119
|
type: 'image',
|
|
120
120
|
mediaType: block.attachment.mediaType,
|
|
121
121
|
dataBase64: Buffer.from(stored.data).toString('base64'),
|
|
122
|
+
...stored.detail === undefined ? {} : { detail: stored.detail },
|
|
122
123
|
};
|
|
123
124
|
}
|
|
124
125
|
async function resolveToolResult(block, options, signal) {
|
|
@@ -68,11 +68,15 @@ class NodeNativeCodexWebSocket {
|
|
|
68
68
|
this.fail(failure('native Codex WebSocket returned a binary frame', 'WS_PROTOCOL_ERROR'));
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
|
|
71
|
+
const bytes = Array.isArray(data)
|
|
72
|
+
? data.reduce((total, chunk) => total + chunk.byteLength, 0) : data.byteLength;
|
|
73
|
+
if (bytes > maxFrameBytes) {
|
|
72
74
|
this.fail(failure('native Codex WebSocket frame exceeded the size limit', 'WS_FRAME_TOO_LARGE'));
|
|
73
75
|
return;
|
|
74
76
|
}
|
|
75
|
-
|
|
77
|
+
const buffer = Array.isArray(data) ? Buffer.concat(data, bytes)
|
|
78
|
+
: Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
79
|
+
this.push({ type: 'text', text: buffer.toString('utf8') }, bytes);
|
|
76
80
|
});
|
|
77
81
|
socket.on('close', (code, reason) => {
|
|
78
82
|
this.ended = true;
|
|
@@ -124,7 +128,7 @@ class NodeNativeCodexWebSocket {
|
|
|
124
128
|
signal?.addEventListener('abort', abort, { once: true });
|
|
125
129
|
this.socket.send(text, (error) => {
|
|
126
130
|
signal?.removeEventListener('abort', abort);
|
|
127
|
-
if (error === undefined)
|
|
131
|
+
if (error === undefined || error === null)
|
|
128
132
|
resolve();
|
|
129
133
|
else
|
|
130
134
|
reject(failure('native Codex WebSocket send failed', 'WS_RETRYABLE', error));
|
package/lib/responses.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ToolCallId, LlmError, type ContentBlock, type GenerateOptions, type StreamChunk, type TokenUsage, type ToolSchema } from '@deepseek-ai/dsh-llm';
|
|
2
2
|
import { type ParseSseOptions } from './sse.js';
|
|
3
3
|
import { type NativeCodexReplaySource } from './replay.js';
|
|
4
4
|
export declare const DEFAULT_CODEX_INSTRUCTIONS = "You are Codex, an AI coding agent. Help the user with software engineering tasks.";
|
|
5
|
+
export type CodexImageDetail = 'auto' | 'low' | 'high' | 'original';
|
|
5
6
|
export interface ResolvedImagePart {
|
|
6
7
|
type: 'image';
|
|
7
8
|
mediaType: string;
|
|
8
9
|
dataBase64: string;
|
|
10
|
+
detail?: CodexImageDetail;
|
|
9
11
|
}
|
|
10
12
|
export interface ResolvedToolResultPart {
|
|
11
13
|
type: 'tool-result';
|
|
12
|
-
toolCallId:
|
|
14
|
+
toolCallId: ToolCallId;
|
|
13
15
|
content: readonly ResolvedContentPart[];
|
|
14
16
|
isError?: boolean;
|
|
15
17
|
}
|
package/lib/responses.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Pure DSH-to-Codex Responses request and stream translation. */
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
-
import {
|
|
3
|
+
import { ToolCallId, CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, isContextWindowExceededError, isQuotaExceededError, LlmError, QUOTA_EXCEEDED_CODE, } from '@deepseek-ai/dsh-llm';
|
|
4
4
|
import { parseSse } from './sse.js';
|
|
5
5
|
import { NativeCodexReplayCapture, replayAssistantInput, replayableItemId, } from './replay.js';
|
|
6
6
|
export const DEFAULT_CODEX_INSTRUCTIONS = 'You are Codex, an AI coding agent. Help the user with software engineering tasks.';
|
|
@@ -21,7 +21,11 @@ function imageItem(image) {
|
|
|
21
21
|
if (!/^image[/][a-z0-9.+-]+$/i.test(image.mediaType) || image.dataBase64.length === 0) {
|
|
22
22
|
throw fixedError('native Codex request contains invalid resolved image data', 'MALFORMED_REQUEST');
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
if (image.detail !== undefined && !['auto', 'low', 'high', 'original'].includes(image.detail)) {
|
|
25
|
+
throw fixedError('native Codex image detail is invalid', 'MALFORMED_REQUEST');
|
|
26
|
+
}
|
|
27
|
+
return { type: 'input_image', image_url: `data:${image.mediaType};base64,${image.dataBase64}`,
|
|
28
|
+
...image.detail === undefined ? {} : { detail: image.detail } };
|
|
25
29
|
}
|
|
26
30
|
function toolOutput(block) {
|
|
27
31
|
const images = block.content.some(part => part.type === 'image');
|
|
@@ -169,6 +173,16 @@ export function codexRequestBody(options, messages, mode = {}) {
|
|
|
169
173
|
const resolved = toResponsesInput(messages, options.system);
|
|
170
174
|
const instructions = resolved.instructions ?? DEFAULT_CODEX_INSTRUCTIONS;
|
|
171
175
|
const input = normalizeCodexCallIds(resolved.input);
|
|
176
|
+
if (mode.responsesLite !== undefined) {
|
|
177
|
+
for (const item of input) {
|
|
178
|
+
const parts = item.type === 'function_call_output' ? item.output : item.content;
|
|
179
|
+
if (Array.isArray(parts)) {
|
|
180
|
+
for (const part of parts)
|
|
181
|
+
if (part.type === 'input_image')
|
|
182
|
+
delete part.detail;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
172
186
|
const common = {
|
|
173
187
|
model: options.model,
|
|
174
188
|
tool_choice: 'auto',
|
|
@@ -298,7 +312,7 @@ function closeBlock(block) {
|
|
|
298
312
|
return { type: 'text', text: block.text };
|
|
299
313
|
if (block.kind === 'reasoning')
|
|
300
314
|
return { type: 'reasoning', text: block.text };
|
|
301
|
-
return { type: 'tool-call', id:
|
|
315
|
+
return { type: 'tool-call', id: ToolCallId(block.callId), name: block.name ?? '', arguments: block.text };
|
|
302
316
|
}
|
|
303
317
|
/** Stateful, transport-free Responses event to DSH chunk translator. */
|
|
304
318
|
export class ResponsesStreamTranslator {
|
|
@@ -384,7 +398,7 @@ export class ResponsesStreamTranslator {
|
|
|
384
398
|
this.sawToolCall = true;
|
|
385
399
|
const block = this.open(`${item.id}:call`, 'tool-call', chunks, item.call_id, item.name);
|
|
386
400
|
chunks.push({
|
|
387
|
-
type: 'tool-call-delta', index: block.index, id:
|
|
401
|
+
type: 'tool-call-delta', index: block.index, id: ToolCallId(block.callId),
|
|
388
402
|
name: item.name, argumentsDelta: '',
|
|
389
403
|
});
|
|
390
404
|
return chunks;
|
|
@@ -416,7 +430,7 @@ export class ResponsesStreamTranslator {
|
|
|
416
430
|
const delta = eventDelta(event);
|
|
417
431
|
this.append(block, delta);
|
|
418
432
|
chunks.push({
|
|
419
|
-
type: 'tool-call-delta', index: block.index, id:
|
|
433
|
+
type: 'tool-call-delta', index: block.index, id: ToolCallId(block.callId),
|
|
420
434
|
...block.name === undefined ? {} : { name: block.name }, argumentsDelta: delta,
|
|
421
435
|
});
|
|
422
436
|
return chunks;
|
package/lib/upstream.d.ts
CHANGED
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
export declare const TRACKED_CODEX_REPOSITORY = "https://github.com/openai/codex.git";
|
|
3
3
|
export declare const TRACKED_CODEX_COMMIT = "ddf04ad26789d040f9ef6a96736f76602e35a6cc";
|
|
4
4
|
export declare const TRACKED_CODEX_RELEASE = "main@ddf04ad";
|
|
5
|
+
/** Independently audited cloud search/image contracts; not local Codex executor parity. */
|
|
6
|
+
export declare const TRACKED_CODEX_CLOUD_COMMIT = "b348fc26674189f758d5941cdab3f78f258b2aa7";
|
|
5
7
|
/** Whole stable release version sent to the Codex model-catalog endpoint. */
|
|
6
8
|
export declare const CODEX_CLIENT_VERSION = "0.153.4";
|
package/lib/upstream.js
CHANGED
|
@@ -2,5 +2,7 @@
|
|
|
2
2
|
export const TRACKED_CODEX_REPOSITORY = 'https://github.com/openai/codex.git';
|
|
3
3
|
export const TRACKED_CODEX_COMMIT = 'ddf04ad26789d040f9ef6a96736f76602e35a6cc';
|
|
4
4
|
export const TRACKED_CODEX_RELEASE = 'main@ddf04ad';
|
|
5
|
+
/** Independently audited cloud search/image contracts; not local Codex executor parity. */
|
|
6
|
+
export const TRACKED_CODEX_CLOUD_COMMIT = 'b348fc26674189f758d5941cdab3f78f258b2aa7';
|
|
5
7
|
/** Whole stable release version sent to the Codex model-catalog endpoint. */
|
|
6
8
|
export const CODEX_CLIENT_VERSION = '0.153.4';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pure01fx/dsh-openai-codex-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Native ChatGPT Codex provider, device-code-first login, and same-origin Web integration for DeepSeek Harness",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -61,24 +61,47 @@
|
|
|
61
61
|
"lib/sse.d.ts",
|
|
62
62
|
"lib/usage.js",
|
|
63
63
|
"lib/usage.d.ts",
|
|
64
|
+
"lib/cloud-http.js",
|
|
65
|
+
"lib/cloud-http.d.ts",
|
|
66
|
+
"lib/cloud-search.js",
|
|
67
|
+
"lib/cloud-search.d.ts",
|
|
68
|
+
"lib/cloud-images.js",
|
|
69
|
+
"lib/cloud-images.d.ts",
|
|
70
|
+
"lib/cloud-media.js",
|
|
71
|
+
"lib/cloud-media.d.ts",
|
|
72
|
+
"lib/cloud-vision.js",
|
|
73
|
+
"lib/cloud-vision.d.ts",
|
|
74
|
+
"lib/cloud-tools.js",
|
|
75
|
+
"lib/cloud-tools.d.ts",
|
|
76
|
+
"lib/cloud-context.js",
|
|
77
|
+
"lib/cloud-context.d.ts",
|
|
78
|
+
"lib/cloud-web-tool.js",
|
|
79
|
+
"lib/cloud-web-tool.d.ts",
|
|
64
80
|
"client.js",
|
|
65
81
|
"cordis.patch.yml",
|
|
66
82
|
"assets/readme/hero.svg",
|
|
67
83
|
"assets/readme/workflow.svg",
|
|
68
84
|
"README.md",
|
|
69
85
|
"CHANGELOG.md",
|
|
70
|
-
"LICENSE"
|
|
86
|
+
"LICENSE",
|
|
87
|
+
"CODEX-COMPATIBILITY.md"
|
|
71
88
|
],
|
|
89
|
+
"scripts": {
|
|
90
|
+
"build": "tsc",
|
|
91
|
+
"typecheck": "tsc --noEmit",
|
|
92
|
+
"test": "vitest run",
|
|
93
|
+
"prepack": "pnpm build"
|
|
94
|
+
},
|
|
72
95
|
"dsh": {
|
|
73
96
|
"engines": {
|
|
74
|
-
"dsh": "0.1.
|
|
97
|
+
"dsh": "0.1.5-rc.1"
|
|
75
98
|
},
|
|
76
99
|
"bundle": {
|
|
77
100
|
"patch": "./cordis.patch.yml"
|
|
78
101
|
},
|
|
79
102
|
"client": {
|
|
80
103
|
"inject": [
|
|
81
|
-
"@deepseek-ai/dsh-client-
|
|
104
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
82
105
|
"@deepseek-ai/dsh-client-ui-model-selection",
|
|
83
106
|
"@deepseek-ai/dsh-client-ui-conversation",
|
|
84
107
|
"@deepseek-ai/dsh-client-ui-settings"
|
|
@@ -88,32 +111,68 @@
|
|
|
88
111
|
},
|
|
89
112
|
"peerDependencies": {
|
|
90
113
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
91
|
-
"@deepseek-ai/dsh-
|
|
92
|
-
"@deepseek-ai/dsh-
|
|
93
|
-
"@deepseek-ai/dsh-
|
|
114
|
+
"@deepseek-ai/dsh-attachment": "0.1.5-rc.1",
|
|
115
|
+
"@deepseek-ai/dsh-credentials": "0.1.5-rc.1",
|
|
116
|
+
"@deepseek-ai/dsh-fs": "0.1.5-rc.1",
|
|
117
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.5-rc.1",
|
|
118
|
+
"@deepseek-ai/dsh-llm": "0.1.5-rc.1",
|
|
119
|
+
"@deepseek-ai/dsh-sandbox": "0.1.5-rc.1",
|
|
120
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.1.5-rc.1",
|
|
121
|
+
"@deepseek-ai/dsh-shell": "0.1.5-rc.1",
|
|
122
|
+
"@deepseek-ai/dsh-tools": "0.1.5-rc.1"
|
|
94
123
|
},
|
|
95
124
|
"dependencies": {
|
|
96
|
-
"@deepseek-ai/dsh-atomic-write": "0.1.
|
|
97
|
-
"@deepseek-ai/dsh-home-paths": "0.1.
|
|
125
|
+
"@deepseek-ai/dsh-atomic-write": "0.1.5-rc.1",
|
|
126
|
+
"@deepseek-ai/dsh-home-paths": "0.1.5-rc.1",
|
|
98
127
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
99
128
|
"https-proxy-agent": "7.0.6",
|
|
129
|
+
"image-size": "^2.0.2",
|
|
100
130
|
"proxy-from-env": "1.1.0",
|
|
101
131
|
"ws": "8.21.3"
|
|
102
132
|
},
|
|
103
133
|
"devDependencies": {
|
|
134
|
+
"@deepseek-ai/dsh-client-ui-model-selection": "0.1.5-rc.1",
|
|
135
|
+
"@deepseek-ai/dsh-web-frontend": "0.1.5-rc.1",
|
|
104
136
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
105
|
-
"@deepseek-ai/dsh-agent": "0.1.
|
|
106
|
-
"@deepseek-ai/dsh-
|
|
107
|
-
"@deepseek-ai/dsh-
|
|
108
|
-
"@deepseek-ai/dsh-
|
|
109
|
-
"@deepseek-ai/dsh-
|
|
137
|
+
"@deepseek-ai/dsh-agent": "0.1.5-rc.1",
|
|
138
|
+
"@deepseek-ai/dsh-attachment": "0.1.5-rc.1",
|
|
139
|
+
"@deepseek-ai/dsh-attachment-local": "0.1.5-rc.1",
|
|
140
|
+
"@deepseek-ai/dsh-credentials": "0.1.5-rc.1",
|
|
141
|
+
"@deepseek-ai/dsh-fs": "0.1.5-rc.1",
|
|
142
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.5-rc.1",
|
|
143
|
+
"@deepseek-ai/dsh-llm": "0.1.5-rc.1",
|
|
144
|
+
"@deepseek-ai/dsh-sandbox": "0.1.5-rc.1",
|
|
145
|
+
"@deepseek-ai/dsh-sandbox-policy": "0.1.5-rc.1",
|
|
146
|
+
"@deepseek-ai/dsh-scope": "0.1.5-rc.1",
|
|
147
|
+
"@deepseek-ai/dsh-session": "0.1.5-rc.1",
|
|
148
|
+
"@deepseek-ai/dsh-shell": "0.1.5-rc.1",
|
|
149
|
+
"@deepseek-ai/dsh-system-prompt": "0.1.5-rc.1",
|
|
150
|
+
"@deepseek-ai/dsh-tools": "0.1.5-rc.1",
|
|
110
151
|
"@types/node": "^22.20.0",
|
|
111
152
|
"@types/proxy-from-env": "1.0.4",
|
|
153
|
+
"@types/ws": "8.18.1",
|
|
154
|
+
"sharp": "^0.35.4",
|
|
112
155
|
"typescript": "^6.0.3",
|
|
113
156
|
"vitest": "^4.1.8"
|
|
114
157
|
},
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
|
|
158
|
+
"peerDependenciesMeta": {
|
|
159
|
+
"@deepseek-ai/dsh-tools": {
|
|
160
|
+
"optional": true
|
|
161
|
+
},
|
|
162
|
+
"@deepseek-ai/dsh-attachment": {
|
|
163
|
+
"optional": true
|
|
164
|
+
},
|
|
165
|
+
"@deepseek-ai/dsh-fs": {
|
|
166
|
+
"optional": true
|
|
167
|
+
},
|
|
168
|
+
"@deepseek-ai/dsh-shell": {
|
|
169
|
+
"optional": true
|
|
170
|
+
},
|
|
171
|
+
"@deepseek-ai/dsh-sandbox": {
|
|
172
|
+
"optional": true
|
|
173
|
+
},
|
|
174
|
+
"@deepseek-ai/dsh-sandbox-policy": {
|
|
175
|
+
"optional": true
|
|
176
|
+
}
|
|
118
177
|
}
|
|
119
|
-
}
|
|
178
|
+
}
|