dsh-lcx-codex 0.6.0-pre.2 → 0.6.0
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 +45 -26
- package/THIRD_PARTY_NOTICES.md +2 -2
- package/lib/dsh-responses.js +114 -51
- package/lib/index.js +89 -96
- package/lib/native-checkpoint.js +3 -2
- package/lib/pi-responses-runtime.js +621 -131
- package/lib/responses-request.js +26 -3
- package/lib/responses-stream.js +5 -1
- package/lib/route.js +1 -1
- package/lib/search-usage.js +8 -2
- package/lib/tool-surface.js +4 -7
- package/package.json +36 -32
package/lib/responses-request.js
CHANGED
|
@@ -2,6 +2,8 @@ import { clampOpenAIPromptCacheKey } from "./pi-responses-runtime.js";
|
|
|
2
2
|
import { responsesTools } from "./dsh-responses.js";
|
|
3
3
|
import { isRecord } from "./util.js";
|
|
4
4
|
const OPENAI_RESPONSES_MIN_OUTPUT_TOKENS = 16;
|
|
5
|
+
/** Pi's fixed request effort while the real one travels in `configuration_update` input items. */
|
|
6
|
+
const CONFIGURATION_UPDATE_REQUEST_EFFORT = "medium";
|
|
5
7
|
function modelId(model) {
|
|
6
8
|
return typeof model === "string" ? model : model.id;
|
|
7
9
|
}
|
|
@@ -20,10 +22,28 @@ function normalizeCacheRetention(value) {
|
|
|
20
22
|
? normalized
|
|
21
23
|
: "short";
|
|
22
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The effort Pi 1.3.0 sends as `configuration_update` input items instead of `reasoning.effort`, or undefined
|
|
27
|
+
* to send it as `reasoning.effort` (Pi's `getConfigurationUpdateEffort`): only for a model whose compat states
|
|
28
|
+
* `supportsMidConvoEffort`, only with a requested level, and never for a Sign in with ChatGPT key, which rejects
|
|
29
|
+
* those items. The key is read only when that last rule can apply.
|
|
30
|
+
*/
|
|
31
|
+
export async function configurationUpdateEffort(model, reasoningEffort, apiKey) {
|
|
32
|
+
if (model.compat?.supportsMidConvoEffort !== true || reasoningEffort === undefined || reasoningEffort === "off")
|
|
33
|
+
return undefined;
|
|
34
|
+
const requested = String(reasoningEffort);
|
|
35
|
+
const mapped = model.thinkingLevelMap?.[requested];
|
|
36
|
+
// A level the model maps to null is unsupported; DSH refuses it before dispatch, so it never travels here.
|
|
37
|
+
if (mapped === null)
|
|
38
|
+
return undefined;
|
|
39
|
+
if (model.provider === "openai" && model.baseUrl === "https://api.openai.com/v1" && !(await apiKey()).startsWith("sk-"))
|
|
40
|
+
return undefined;
|
|
41
|
+
return mapped ?? requested;
|
|
42
|
+
}
|
|
23
43
|
/**
|
|
24
44
|
* Pi-parity generation controls for OpenAI Responses.
|
|
25
45
|
*/
|
|
26
|
-
export function responsesGenerationEnvelope({ model = "unknown", reasoningEffort, temperature, maxTokens, includeDefaultReasoning = false, } = {}) {
|
|
46
|
+
export function responsesGenerationEnvelope({ model = "unknown", reasoningEffort, temperature, maxTokens, configurationUpdateEffort, includeDefaultReasoning = false, } = {}) {
|
|
27
47
|
const descriptor = modelRecord(model);
|
|
28
48
|
const result = {};
|
|
29
49
|
if (descriptor.reasoning !== false) {
|
|
@@ -37,7 +57,9 @@ export function responsesGenerationEnvelope({ model = "unknown", reasoningEffort
|
|
|
37
57
|
const mapped = descriptor.thinkingLevelMap?.[requested];
|
|
38
58
|
const wire = mapped === undefined ? requested : mapped;
|
|
39
59
|
if (wire !== null) {
|
|
40
|
-
|
|
60
|
+
// With mid-conversation effort the request carries a fixed effort, so an effort change keeps the
|
|
61
|
+
// cached prefix; the level itself is the last `configuration_update` input item.
|
|
62
|
+
result.reasoning = { effort: configurationUpdateEffort === undefined ? wire : CONFIGURATION_UPDATE_REQUEST_EFFORT, summary: "auto" };
|
|
41
63
|
result.include = ["reasoning.encrypted_content"];
|
|
42
64
|
}
|
|
43
65
|
}
|
|
@@ -66,7 +88,7 @@ export function responsesGenerationEnvelope({ model = "unknown", reasoningEffort
|
|
|
66
88
|
* Build the shared LCX-owned request envelope while retaining Pi 0.86.0 Responses semantics.
|
|
67
89
|
* Production LCX ordinary/compact/replay construction places the DSH system prompt in canonical input.
|
|
68
90
|
*/
|
|
69
|
-
export function buildResponsesBody({ model, input, tools, sessionId, promptCacheKey, promptCacheRetention, cacheRetention, reasoningEffort, temperature, maxTokens, samplingParams, }) {
|
|
91
|
+
export function buildResponsesBody({ model, input, tools, sessionId, promptCacheKey, promptCacheRetention, cacheRetention, reasoningEffort, temperature, maxTokens, configurationUpdateEffort, samplingParams, }) {
|
|
70
92
|
if (!Array.isArray(input))
|
|
71
93
|
throw Object.assign(new Error("Responses input must be an array"), {
|
|
72
94
|
code: "LCX_RESPONSES_INVALID_INPUT",
|
|
@@ -105,6 +127,7 @@ export function buildResponsesBody({ model, input, tools, sessionId, promptCache
|
|
|
105
127
|
reasoningEffort,
|
|
106
128
|
temperature,
|
|
107
129
|
maxTokens,
|
|
130
|
+
configurationUpdateEffort,
|
|
108
131
|
includeDefaultReasoning: true,
|
|
109
132
|
}),
|
|
110
133
|
};
|
package/lib/responses-stream.js
CHANGED
|
@@ -1138,6 +1138,9 @@ function replayState(message, nativeOutput, nativeReplayRoute, nativeServerSearc
|
|
|
1138
1138
|
...(typeof message.responseId === "string"
|
|
1139
1139
|
? { responseId: message.responseId }
|
|
1140
1140
|
: {}),
|
|
1141
|
+
...(typeof message.providerThinkingLevel === "string"
|
|
1142
|
+
? { providerThinkingLevel: message.providerThinkingLevel }
|
|
1143
|
+
: {}),
|
|
1141
1144
|
stopReason: message.stopReason,
|
|
1142
1145
|
},
|
|
1143
1146
|
blocks: content.map((block) => {
|
|
@@ -1349,7 +1352,7 @@ async function* toDshChunks(events, signal, wireMeta, nativeReplayRoute) {
|
|
|
1349
1352
|
* Send one LCX-owned OpenAI Responses request. Ordinary and replay use one provider attempt;
|
|
1350
1353
|
* the DSH agent recovery layer remains the visible retry owner.
|
|
1351
1354
|
*/
|
|
1352
|
-
export async function* streamResponsesRequest({ baseURL, provider, model, piModel, body, grammarToolInputProperties, headers, signal, timeoutMs, applyDefaultTimeout = true, streamIdleTimeoutMs, maxAttempts = 1, maxResponseBytes, serverToolTypes, isServerToolItem, declaredToolNames, nativeReplayRoute, onServerToolUsage, onFailure, }) {
|
|
1355
|
+
export async function* streamResponsesRequest({ baseURL, provider, model, piModel, body, grammarToolInputProperties, headers, signal, timeoutMs, applyDefaultTimeout = true, streamIdleTimeoutMs, maxAttempts = 1, maxResponseBytes, serverToolTypes, isServerToolItem, declaredToolNames, nativeReplayRoute, providerThinkingLevel, onServerToolUsage, onFailure, }) {
|
|
1353
1356
|
let contentEmitted = false;
|
|
1354
1357
|
let failureReported = false;
|
|
1355
1358
|
/** One redacted report per request; user aborts are not failures. */
|
|
@@ -1390,6 +1393,7 @@ export async function* streamResponsesRequest({ baseURL, provider, model, piMode
|
|
|
1390
1393
|
api: "openai-responses",
|
|
1391
1394
|
provider,
|
|
1392
1395
|
model,
|
|
1396
|
+
...(providerThinkingLevel === undefined ? {} : { providerThinkingLevel }),
|
|
1393
1397
|
usage: emptyUsage(),
|
|
1394
1398
|
stopReason: "pending",
|
|
1395
1399
|
timestamp: Date.now(),
|
package/lib/route.js
CHANGED
|
@@ -274,7 +274,7 @@ function declaredReasoningControls(profile, modelId) {
|
|
|
274
274
|
if (value === undefined)
|
|
275
275
|
thinkingLevelMap[level] = null;
|
|
276
276
|
else if (value === null) {
|
|
277
|
-
// DSH permits only off:null: it means supported-off by omitting the wire option. Pi 1.
|
|
277
|
+
// DSH permits only off:null: it means supported-off by omitting the wire option. Pi (1.3.0) would
|
|
278
278
|
// read an absent `off` as "send none", so the omission is made explicit here.
|
|
279
279
|
thinkingLevelMap[level] = null;
|
|
280
280
|
if (level === "off")
|
package/lib/search-usage.js
CHANGED
|
@@ -4,10 +4,16 @@ import { addUsage, aggregateContextOf, auxiliaryUsageOf, isSearchTool, providerC
|
|
|
4
4
|
const n = z.number().int().nonnegative();
|
|
5
5
|
const schema = z.object({ auxiliary: z.object({ uncachedInputTokens: n, outputTokens: n, cacheReadTokens: n, cacheWriteTokens: n }).strict(), aggregateContext: z.boolean(),
|
|
6
6
|
contextDetails: z.object({ input_tokens: n, output_tokens: n }).strict().optional(), contextProvenance: z.literal('provider-context-details').optional() }).strict();
|
|
7
|
+
const stateSchema = schema.extend({ pending: z.record(z.string(), z.string()), headerKey: z.string().optional(), sampleHeaderKey: z.string().optional() });
|
|
8
|
+
// DSH (since 0.2.1-alpha.5) pins its own zod, which need not be the one this plugin resolves, and TypeScript
|
|
9
|
+
// cannot relate schemas of two zod copies. The host only calls `parse` on them, so they are checked against
|
|
10
|
+
// the plugin's zod here and handed to the host typed by its own contract.
|
|
11
|
+
const hostStateSchema = stateSchema;
|
|
12
|
+
const hostViewSchema = schema;
|
|
7
13
|
const headerKey = (header) => header === undefined ? undefined : JSON.stringify(canonicalHeader(header));
|
|
8
14
|
/** Separate, durable extension: the host's own usage projection remains primary-call billing. */
|
|
9
15
|
export const searchUsageProjection = {
|
|
10
|
-
key: 'lcxSearchUsage', stateVersion: 3, stateSchema:
|
|
16
|
+
key: 'lcxSearchUsage', stateVersion: 3, stateSchema: hostStateSchema,
|
|
11
17
|
init: () => ({ auxiliary: zeroBuckets(), aggregateContext: false, pending: {} }),
|
|
12
18
|
apply(state, event) {
|
|
13
19
|
// Unit state is checkpointed by the host's projection cache, which refuses any state that is not
|
|
@@ -41,7 +47,7 @@ export const searchUsageProjection = {
|
|
|
41
47
|
return { ...state, auxiliary, aggregateContext, pending: {} };
|
|
42
48
|
return auxiliary === state.auxiliary && aggregateContext === state.aggregateContext ? state : { ...state, auxiliary, aggregateContext };
|
|
43
49
|
},
|
|
44
|
-
wire: { viewSchema:
|
|
50
|
+
wire: { viewSchema: hostViewSchema, view: ({ auxiliary, aggregateContext, contextDetails, contextProvenance }) => ({ auxiliary, aggregateContext, ...(contextDetails ? { contextDetails, contextProvenance } : {}) }) },
|
|
45
51
|
};
|
|
46
52
|
const installed = new WeakMap();
|
|
47
53
|
/** Own a reversible adapter on the public measure method, never a DSH file or private fold. */
|
package/lib/tool-surface.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getResponsesToolSupport } from "./pi-responses-runtime.js";
|
|
1
2
|
import { projectToolUpdates } from "@deepseek-ai/dsh-llm";
|
|
2
3
|
export const DEFAULT_TOOL_UPDATES = "addition-only";
|
|
3
4
|
/** Reason used when the route compat explicitly declines both declaration kinds; a deliberate configuration. */
|
|
@@ -12,11 +13,8 @@ export const COMPAT_SILENT = "route compat does not say whether the model suppor
|
|
|
12
13
|
* own catalog supports one of the two, but only the compat says which.
|
|
13
14
|
*/
|
|
14
15
|
export function declarationKind(compat) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (compat?.supportsToolSearch === true)
|
|
18
|
-
return "tool_search";
|
|
19
|
-
return undefined;
|
|
16
|
+
const support = getResponsesToolSupport({ ...compat, supportsMidConvoSystemMessages: true });
|
|
17
|
+
return support === "changes" ? "additional_tools" : support === "additions" ? "tool_search" : undefined;
|
|
20
18
|
}
|
|
21
19
|
/** Remove the activation marker; the wire never carries it. */
|
|
22
20
|
export function withoutDeferLoading(tool) {
|
|
@@ -39,7 +37,7 @@ function full(messages, tools, toolHistory, fallbackReason, fallbackUnexpected)
|
|
|
39
37
|
/**
|
|
40
38
|
* Decide the tool surface of one GPT Responses request.
|
|
41
39
|
*
|
|
42
|
-
*
|
|
40
|
+
* DSH history projection is used only when every condition holds; Pi owns the wire tool state:
|
|
43
41
|
* the policy is on, DSH reports `toolUpdate: "addition-only"` with an in-history system prompt, the route
|
|
44
42
|
* compat names a supported declaration shape (`additional_tools` or `tool_search`; silence is not guessed
|
|
45
43
|
* at, see `declarationKind`), and DSH supplied its tool history. The host
|
|
@@ -101,6 +99,5 @@ export function planToolSurface(input) {
|
|
|
101
99
|
messages: projected.messages,
|
|
102
100
|
tools: projectedTools,
|
|
103
101
|
anchored: true,
|
|
104
|
-
compat: kind === "additional_tools" ? { supportsAdditionalTools: true } : { supportsAdditionalTools: false, supportsToolSearch: true },
|
|
105
102
|
};
|
|
106
103
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-lcx-codex",
|
|
3
|
-
"version": "0.6.0
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Model-scoped DSH plugin: GPT Responses lifecycle, Native V2 compaction and Hosted/Alpha Search; Grok native Web/X Search",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"keywords": [
|
|
@@ -66,9 +66,9 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@deepseek-ai/dsh": "0.2.1-
|
|
70
|
-
"@earendil-works/pi-ai": "1.
|
|
71
|
-
"@deepseek-ai/schemastery": "~3.18.5-alpha.
|
|
69
|
+
"@deepseek-ai/dsh": "0.2.1-rc.5",
|
|
70
|
+
"@earendil-works/pi-ai": "1.5.0",
|
|
71
|
+
"@deepseek-ai/schemastery": "~3.18.5-alpha.2",
|
|
72
72
|
"@types/node": "^22.20.0",
|
|
73
73
|
"@types/react": "~18.3.1",
|
|
74
74
|
"esbuild": "^0.28.2",
|
|
@@ -76,31 +76,32 @@
|
|
|
76
76
|
"typescript": "7.0.2"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
|
-
"@deepseek-ai/cordis": ">=4.0.5
|
|
80
|
-
"@deepseek-ai/cordis-plugin-loader": ">=1.0.6
|
|
81
|
-
"@deepseek-ai/dsh-agent": ">=0.2.1-
|
|
82
|
-
"@deepseek-ai/dsh-
|
|
83
|
-
"@deepseek-ai/dsh-
|
|
84
|
-
"@deepseek-ai/dsh-client-
|
|
85
|
-
"@deepseek-ai/dsh-client-
|
|
86
|
-
"@deepseek-ai/dsh-client-
|
|
87
|
-
"@deepseek-ai/dsh-client-ui-
|
|
88
|
-
"@deepseek-ai/dsh-client-ui-
|
|
89
|
-
"@deepseek-ai/dsh-client-ui-
|
|
90
|
-
"@deepseek-ai/dsh-
|
|
91
|
-
"@deepseek-ai/dsh-
|
|
92
|
-
"@deepseek-ai/dsh-
|
|
93
|
-
"@deepseek-ai/dsh-
|
|
94
|
-
"@deepseek-ai/dsh-
|
|
95
|
-
"@deepseek-ai/dsh-session
|
|
96
|
-
"@deepseek-ai/dsh-
|
|
97
|
-
"@deepseek-ai/dsh-
|
|
98
|
-
"@deepseek-ai/dsh-
|
|
99
|
-
"@deepseek-ai/dsh-
|
|
100
|
-
"@deepseek-ai/
|
|
79
|
+
"@deepseek-ai/cordis": ">=4.0.5",
|
|
80
|
+
"@deepseek-ai/cordis-plugin-loader": ">=1.0.6",
|
|
81
|
+
"@deepseek-ai/dsh-agent": ">=0.2.1-rc.5 <0.2.2-0",
|
|
82
|
+
"@deepseek-ai/dsh-api-session-controller": ">=0.2.1-rc.5 <0.2.2-0",
|
|
83
|
+
"@deepseek-ai/dsh-attachment": ">=0.2.1-rc.5 <0.2.2-0",
|
|
84
|
+
"@deepseek-ai/dsh-client-locale": ">=0.2.1-rc.5 <0.2.2-0",
|
|
85
|
+
"@deepseek-ai/dsh-client-modules": ">=0.2.1-rc.5 <0.2.2-0",
|
|
86
|
+
"@deepseek-ai/dsh-client-store": ">=0.2.1-rc.5 <0.2.2-0",
|
|
87
|
+
"@deepseek-ai/dsh-client-ui-chat": ">=0.2.1-rc.5 <0.2.2-0",
|
|
88
|
+
"@deepseek-ai/dsh-client-ui-conversation": ">=0.2.1-rc.5 <0.2.2-0",
|
|
89
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager": ">=0.2.1-rc.5 <0.2.2-0",
|
|
90
|
+
"@deepseek-ai/dsh-client-ui-settings": ">=0.2.1-rc.5 <0.2.2-0",
|
|
91
|
+
"@deepseek-ai/dsh-compaction": ">=0.2.1-rc.5 <0.2.2-0",
|
|
92
|
+
"@deepseek-ai/dsh-credentials": ">=0.2.1-rc.5 <0.2.2-0",
|
|
93
|
+
"@deepseek-ai/dsh-fs": ">=0.2.1-rc.5 <0.2.2-0",
|
|
94
|
+
"@deepseek-ai/dsh-llm": ">=0.2.1-rc.5 <0.2.2-0",
|
|
95
|
+
"@deepseek-ai/dsh-session": ">=0.2.1-rc.5 <0.2.2-0",
|
|
96
|
+
"@deepseek-ai/dsh-session-query": ">=0.2.1-rc.5 <0.2.2-0",
|
|
97
|
+
"@deepseek-ai/dsh-settings": ">=0.2.1-rc.5 <0.2.2-0",
|
|
98
|
+
"@deepseek-ai/dsh-tool-web": ">=0.2.1-rc.5 <0.2.2-0",
|
|
99
|
+
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.5 <0.2.2-0",
|
|
100
|
+
"@deepseek-ai/dsh-web": ">=0.2.1-rc.5 <0.2.2-0",
|
|
101
|
+
"@deepseek-ai/schemastery": ">=3.18.5",
|
|
101
102
|
"react": "^18.2.0",
|
|
102
|
-
"@deepseek-ai/dsh-token-meter": ">=0.2.1-
|
|
103
|
-
"@deepseek-ai/dsh-session-projection": ">=0.2.1-
|
|
103
|
+
"@deepseek-ai/dsh-token-meter": ">=0.2.1-rc.5 <0.2.2-0",
|
|
104
|
+
"@deepseek-ai/dsh-session-projection": ">=0.2.1-rc.5 <0.2.2-0",
|
|
104
105
|
"zod": "^4.5.4"
|
|
105
106
|
},
|
|
106
107
|
"peerDependenciesMeta": {
|
|
@@ -110,6 +111,9 @@
|
|
|
110
111
|
"@deepseek-ai/dsh-client-locale": {
|
|
111
112
|
"optional": true
|
|
112
113
|
},
|
|
114
|
+
"@deepseek-ai/dsh-api-session-controller": {
|
|
115
|
+
"optional": true
|
|
116
|
+
},
|
|
113
117
|
"@deepseek-ai/dsh-agent": {
|
|
114
118
|
"optional": true
|
|
115
119
|
},
|
|
@@ -184,9 +188,9 @@
|
|
|
184
188
|
},
|
|
185
189
|
"license": "MIT",
|
|
186
190
|
"lcxCompatibility": {
|
|
187
|
-
"dshInstallRange": ">=0.2.1-
|
|
188
|
-
"verifiedDsh": "0.2.1-
|
|
189
|
-
"verifiedHostPi": "1.
|
|
190
|
-
"verifiedPluginPi": "1.
|
|
191
|
+
"dshInstallRange": ">=0.2.1-rc.5 <0.2.2-0",
|
|
192
|
+
"verifiedDsh": "0.2.1-rc.5",
|
|
193
|
+
"verifiedHostPi": "1.5.0",
|
|
194
|
+
"verifiedPluginPi": "1.5.0"
|
|
191
195
|
}
|
|
192
196
|
}
|