dsh-lcx-codex 0.5.2 → 0.6.0-pre.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.
@@ -0,0 +1,107 @@
1
+ import { projectToolUpdates } from "@deepseek-ai/dsh-llm";
2
+ export const DEFAULT_TOOL_UPDATES = "addition-only";
3
+ /** Reason used when the route compat explicitly declines both declaration kinds; a deliberate configuration. */
4
+ export const COMPAT_OPT_OUT = "route compat opts out of additional_tools and tool_search";
5
+ /**
6
+ * Which declaration item carries a mid-session addition. DSH declares `toolUpdate: "addition-only"` only for
7
+ * models whose host catalog supports `additional_tools` or `tool_search`, so a route compat that says nothing
8
+ * (LCX's frozen Pi 0.86 catalog does not know newer models such as gpt-6-sol) is not evidence against it. Only
9
+ * an explicit `false` on a declaration kind that is not backed by an explicit `true` opts the route out.
10
+ */
11
+ export function declarationKind(compat) {
12
+ const additional = compat?.supportsAdditionalTools;
13
+ const search = compat?.supportsToolSearch;
14
+ if (additional === true)
15
+ return "additional_tools";
16
+ if (search === true)
17
+ return "tool_search";
18
+ if (additional === false || search === false)
19
+ return undefined;
20
+ return "additional_tools";
21
+ }
22
+ /** Remove the activation marker; the wire never carries it. */
23
+ export function withoutDeferLoading(tool) {
24
+ if (!("deferLoading" in tool))
25
+ return tool;
26
+ const { deferLoading: _deferred, ...rest } = tool;
27
+ return rest;
28
+ }
29
+ function full(messages, tools, toolHistory, fallbackReason, fallbackUnexpected) {
30
+ // Same projection DSH applies for a route without `toolUpdate`: developer updates are dropped and
31
+ // `deferLoading` is cleared, so every declared tool is immediately usable.
32
+ const projected = projectToolUpdates(messages, tools, undefined, toolHistory);
33
+ return {
34
+ messages: projected.messages,
35
+ tools: projected.tools,
36
+ anchored: false,
37
+ ...(fallbackReason === undefined ? {} : { fallbackReason, fallbackUnexpected: fallbackUnexpected === true }),
38
+ };
39
+ }
40
+ /**
41
+ * Decide the tool surface of one GPT Responses request.
42
+ *
43
+ * Addition-only is used only when every condition holds, otherwise the full current list is sent:
44
+ * the policy is on, DSH reports `toolUpdate: "addition-only"` with an in-history system prompt, the route
45
+ * compat does not explicitly opt out of `additional_tools`/`tool_search` (silence is accepted: the host
46
+ * declares addition-only only for models that support them), and DSH supplied its tool history. The host
47
+ * projection is then re-verified (LCX-owned self check); any inconsistency falls back to the full list.
48
+ * Removals and same-name redefinitions need no extra handling: the host history fold already yields a
49
+ * shrunken or fully redeclared baseline for them (one-time cache loss), which this function passes through.
50
+ */
51
+ export function planToolSurface(input) {
52
+ const { mode, messages, tools, toolHistory, facts, compat } = input;
53
+ const fallback = (reason) => full(messages, tools, toolHistory, mode === "addition-only" ? reason : undefined, facts.toolUpdate === "addition-only" && reason !== COMPAT_OPT_OUT);
54
+ if (mode !== "addition-only")
55
+ return full(messages, tools, toolHistory);
56
+ if (tools === undefined)
57
+ return fallback("no tools");
58
+ if (!facts.resolved)
59
+ return fallback("model information unavailable");
60
+ if (facts.toolUpdate !== "addition-only")
61
+ return fallback("route does not declare addition-only tool updates");
62
+ if (facts.systemPromptUpdate !== "in-history")
63
+ return fallback("route is not in-history");
64
+ const kind = declarationKind(compat);
65
+ if (kind === undefined)
66
+ return fallback(COMPAT_OPT_OUT);
67
+ if (toolHistory === undefined)
68
+ return fallback("no DSH tool history");
69
+ const projected = projectToolUpdates(messages, tools, "addition-only", toolHistory);
70
+ const projectedTools = projected.tools;
71
+ if (projectedTools === undefined)
72
+ return fallback("host projection returned no tools");
73
+ const added = new Set();
74
+ for (const message of projected.messages) {
75
+ if (message.role !== "developer")
76
+ continue;
77
+ for (const block of message.content) {
78
+ if (block.type !== "tool-addition")
79
+ return fallback(`unsupported developer block ${block.type}`);
80
+ if (added.has(block.toolName))
81
+ return fallback("duplicate tool addition");
82
+ added.add(block.toolName);
83
+ }
84
+ }
85
+ const deferred = new Set();
86
+ for (const tool of projectedTools) {
87
+ if (tool.deferLoading === true)
88
+ deferred.add(tool.name);
89
+ }
90
+ // Without any deferred tool or retained addition the request equals the full list; use the ordinary path
91
+ // so the common no-change turn stays byte-identical with the 0.5.1 behaviour.
92
+ if (deferred.size === 0 && added.size === 0)
93
+ return full(messages, tools, toolHistory);
94
+ if (deferred.size !== added.size || [...deferred].some((name) => !added.has(name)))
95
+ return fallback("deferred tools and retained additions disagree");
96
+ // The declared surface must equal the active surface; a mismatch means the history fold and the live
97
+ // header diverged (restore, fork or migration), where only the full list is known to be correct.
98
+ const active = new Set(tools.map((tool) => tool.name));
99
+ if (active.size !== projectedTools.length || projectedTools.some((tool) => !active.has(tool.name)))
100
+ return fallback("declared tools differ from the active tools");
101
+ return {
102
+ messages: projected.messages,
103
+ tools: projectedTools,
104
+ anchored: true,
105
+ compat: kind === "additional_tools" ? { supportsAdditionalTools: true } : { supportsAdditionalTools: false, supportsToolSearch: true },
106
+ };
107
+ }
@@ -34,6 +34,8 @@ type LiveSettingsConfig = {
34
34
  grokNativeWebSearch: Volatile<boolean>;
35
35
  grokNativeXSearch: Volatile<boolean>;
36
36
  searchMediaPreview: Volatile<boolean>;
37
+ /** Defaults to true: addition-only tool updates on routes that support them. */
38
+ incrementalToolUpdates: Volatile<boolean>;
37
39
  };
38
40
  type HostContext = Context;
39
41
  export declare const Config: z<Schemastery.ObjectS<NoInfer<{
@@ -44,6 +46,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
44
46
  grokNativeWebSearch: z<boolean, boolean, "volatile-defined">;
45
47
  grokNativeXSearch: z<boolean, boolean, "volatile-defined">;
46
48
  searchMediaPreview: z<boolean, boolean, "volatile-defined">;
49
+ incrementalToolUpdates: z<boolean, boolean, "volatile-defined">;
47
50
  supportsLongCacheRetention: z<boolean, boolean, "defined">;
48
51
  supportsExplicitPromptCacheMode: z<boolean, boolean, "defined">;
49
52
  alphaCapabilityPath: z<string, string, "defined">;
@@ -71,6 +74,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
71
74
  grokNativeWebSearch: z<boolean, boolean, "volatile-defined">;
72
75
  grokNativeXSearch: z<boolean, boolean, "volatile-defined">;
73
76
  searchMediaPreview: z<boolean, boolean, "volatile-defined">;
77
+ incrementalToolUpdates: z<boolean, boolean, "volatile-defined">;
74
78
  supportsLongCacheRetention: z<boolean, boolean, "defined">;
75
79
  supportsExplicitPromptCacheMode: z<boolean, boolean, "defined">;
76
80
  alphaCapabilityPath: z<string, string, "defined">;
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "LCX Codex",
4
+ "description": "GPT Responses lifecycle, long-session compaction, web search and Grok native search for DeepSeek Harness."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "LCX Codex",
4
+ "description": "为 DeepSeek Harness 补充 GPT Responses 生命周期、长会话压缩、网页搜索与 Grok 原生搜索。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "dsh-lcx-codex",
3
- "version": "0.5.2",
3
+ "version": "0.6.0-pre.1",
4
4
  "description": "Model-scoped DSH plugin: GPT Responses lifecycle, Native V2 compaction and Hosted/Alpha Search; Grok native Web/X Search",
5
+ "icon": "./icon.svg",
5
6
  "keywords": [
6
7
  "deepseek-harness",
7
8
  "dsh",
@@ -37,9 +38,12 @@
37
38
  "default": "./lib/client.js"
38
39
  },
39
40
  "./cordis.patch.yml": "./cordis.patch.yml",
41
+ "./locale/*.json": "./locale/*.json",
40
42
  "./package.json": "./package.json"
41
43
  },
42
44
  "files": [
45
+ "icon.svg",
46
+ "locale/*.json",
43
47
  "lib/*.js",
44
48
  "lib/types/index.d.ts",
45
49
  "lib/types/client/index.d.ts",
@@ -62,9 +66,9 @@
62
66
  }
63
67
  },
64
68
  "devDependencies": {
65
- "@deepseek-ai/dsh": "0.2.0-rc.2",
69
+ "@deepseek-ai/dsh": "0.2.1-alpha.2",
66
70
  "@earendil-works/pi-ai": "0.87.1",
67
- "@deepseek-ai/schemastery": "^3.18.2",
71
+ "@deepseek-ai/schemastery": "~3.18.5-alpha.1",
68
72
  "@types/node": "^22.20.0",
69
73
  "@types/react": "~18.3.1",
70
74
  "esbuild": "^0.28.2",
@@ -72,31 +76,31 @@
72
76
  "typescript": "7.0.2"
73
77
  },
74
78
  "peerDependencies": {
75
- "@deepseek-ai/cordis": "^4.0.2",
76
- "@deepseek-ai/cordis-plugin-loader": "~1.0.5",
77
- "@deepseek-ai/dsh-agent": ">=0.2.0-rc.2 <0.2.1",
78
- "@deepseek-ai/dsh-attachment": ">=0.2.0-rc.2 <0.2.1",
79
- "@deepseek-ai/dsh-client-locale": ">=0.2.0-rc.2 <0.2.1",
80
- "@deepseek-ai/dsh-client-modules": ">=0.2.0-rc.2 <0.2.1",
81
- "@deepseek-ai/dsh-client-store": ">=0.2.0-rc.2 <0.2.1",
82
- "@deepseek-ai/dsh-client-ui-chat": ">=0.2.0-rc.2 <0.2.1",
83
- "@deepseek-ai/dsh-client-ui-conversation": ">=0.2.0-rc.2 <0.2.1",
84
- "@deepseek-ai/dsh-client-ui-plugin-manager": ">=0.2.0-rc.2 <0.2.1",
85
- "@deepseek-ai/dsh-client-ui-settings": ">=0.2.0-rc.2 <0.2.1",
86
- "@deepseek-ai/dsh-compaction": ">=0.2.0-rc.2 <0.2.1",
87
- "@deepseek-ai/dsh-credentials": ">=0.2.0-rc.2 <0.2.1",
88
- "@deepseek-ai/dsh-fs": ">=0.2.0-rc.2 <0.2.1",
89
- "@deepseek-ai/dsh-llm": ">=0.2.0-rc.2 <0.2.1",
90
- "@deepseek-ai/dsh-session": ">=0.2.0-rc.2 <0.2.1",
91
- "@deepseek-ai/dsh-session-query": ">=0.2.0-rc.2 <0.2.1",
92
- "@deepseek-ai/dsh-settings": ">=0.2.0-rc.2 <0.2.1",
93
- "@deepseek-ai/dsh-tool-web": ">=0.2.0-rc.2 <0.2.1",
94
- "@deepseek-ai/dsh-tools": ">=0.2.0-rc.2 <0.2.1",
95
- "@deepseek-ai/dsh-web": ">=0.2.0-rc.2 <0.2.1",
96
- "@deepseek-ai/schemastery": "^3.18.2",
79
+ "@deepseek-ai/cordis": ">=4.0.5-alpha.1",
80
+ "@deepseek-ai/cordis-plugin-loader": ">=1.0.6-alpha.1",
81
+ "@deepseek-ai/dsh-agent": ">=0.2.1-alpha.2",
82
+ "@deepseek-ai/dsh-attachment": ">=0.2.1-alpha.2",
83
+ "@deepseek-ai/dsh-client-locale": ">=0.2.1-alpha.2",
84
+ "@deepseek-ai/dsh-client-modules": ">=0.2.1-alpha.2",
85
+ "@deepseek-ai/dsh-client-store": ">=0.2.1-alpha.2",
86
+ "@deepseek-ai/dsh-client-ui-chat": ">=0.2.1-alpha.2",
87
+ "@deepseek-ai/dsh-client-ui-conversation": ">=0.2.1-alpha.2",
88
+ "@deepseek-ai/dsh-client-ui-plugin-manager": ">=0.2.1-alpha.2",
89
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.2.1-alpha.2",
90
+ "@deepseek-ai/dsh-compaction": ">=0.2.1-alpha.2",
91
+ "@deepseek-ai/dsh-credentials": ">=0.2.1-alpha.2",
92
+ "@deepseek-ai/dsh-fs": ">=0.2.1-alpha.2",
93
+ "@deepseek-ai/dsh-llm": ">=0.2.1-alpha.2",
94
+ "@deepseek-ai/dsh-session": ">=0.2.1-alpha.2",
95
+ "@deepseek-ai/dsh-session-query": ">=0.2.1-alpha.2",
96
+ "@deepseek-ai/dsh-settings": ">=0.2.1-alpha.2",
97
+ "@deepseek-ai/dsh-tool-web": ">=0.2.1-alpha.2",
98
+ "@deepseek-ai/dsh-tools": ">=0.2.1-alpha.2",
99
+ "@deepseek-ai/dsh-web": ">=0.2.1-alpha.2",
100
+ "@deepseek-ai/schemastery": ">=3.18.5-alpha.1",
97
101
  "react": "^18.2.0",
98
- "@deepseek-ai/dsh-token-meter": ">=0.2.0-rc.2 <0.2.1",
99
- "@deepseek-ai/dsh-session-projection": ">=0.2.0-rc.2 <0.2.1",
102
+ "@deepseek-ai/dsh-token-meter": ">=0.2.1-alpha.2",
103
+ "@deepseek-ai/dsh-session-projection": ">=0.2.1-alpha.2",
100
104
  "zod": "^4.5.4"
101
105
  },
102
106
  "peerDependenciesMeta": {
@@ -168,6 +172,7 @@
168
172
  "test": "node --test tests/*.test.mjs",
169
173
  "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit",
170
174
  "probe:alpha": "node scripts/probe-alpha.mjs",
175
+ "probe:tool-updates": "node scripts/probe-tool-updates.mjs",
171
176
  "pack:local": "npm pack --ignore-scripts",
172
177
  "test:schema": "node scripts/validate-dsh-schema.mjs"
173
178
  },
@@ -179,9 +184,9 @@
179
184
  },
180
185
  "license": "MIT",
181
186
  "lcxCompatibility": {
182
- "dshInstallRange": ">=0.2.0-rc.2 <0.2.1",
183
- "verifiedDsh": "0.2.0-rc.2",
184
- "verifiedHostPi": "0.87.1",
187
+ "dshInstallRange": ">=0.2.1-alpha.2",
188
+ "verifiedDsh": "0.2.1-alpha.2",
189
+ "verifiedHostPi": "1.1.0",
185
190
  "verifiedPluginPi": "0.87.1"
186
191
  }
187
192
  }
@@ -1,48 +0,0 @@
1
- import { getCatalogModels } from "./pi-responses-runtime.js";
2
- import { wasPi086ResponsesModel } from "./pi086-responses-allowlist.js";
3
- const providerDefaultsCache = new Map();
4
- function sharedValue(values) {
5
- const distinct = new Set(values);
6
- const [only] = distinct;
7
- return distinct.size === 1 && typeof only === "string" && only.length > 0 ? only : undefined;
8
- }
9
- function providerDefaults(provider) {
10
- const cached = providerDefaultsCache.get(provider);
11
- if (cached !== undefined)
12
- return cached;
13
- const models = getCatalogModels(provider);
14
- const defaults = {
15
- api: sharedValue(models.map((model) => model.api)),
16
- baseUrl: sharedValue(models.map((model) => model.baseUrl)),
17
- };
18
- providerDefaultsCache.set(provider, defaults);
19
- return defaults;
20
- }
21
- /**
22
- * Resolve a route model's protocol, endpoint and catalog descriptor from the bundled Pi catalog.
23
- * @param declaredByProfile the provider profile lists this model in `models`; only then does DSH serve a model
24
- * its catalog does not describe, so only then may the provider-wide default apply.
25
- */
26
- export function resolveCatalogModel(provider, modelId, declaredByProfile = false) {
27
- const providerName = String(provider ?? "");
28
- const id = String(modelId ?? "");
29
- const exact = getCatalogModels(providerName).find((model) => model.id === id);
30
- if (exact !== undefined)
31
- return {
32
- source: "catalog-model",
33
- api: exact.api,
34
- baseUrl: exact.baseUrl,
35
- descriptor: exact.api === "openai-responses" ? exact : undefined,
36
- };
37
- const defaults = providerDefaults(providerName);
38
- if (declaredByProfile && defaults.api !== undefined)
39
- return {
40
- source: "catalog-provider-default",
41
- api: defaults.api,
42
- baseUrl: defaults.baseUrl,
43
- descriptor: undefined,
44
- };
45
- if (wasPi086ResponsesModel(providerName, id))
46
- return { source: "frozen-pi086", api: "openai-responses", baseUrl: undefined, descriptor: undefined };
47
- return { source: "unknown", api: undefined, baseUrl: undefined, descriptor: undefined };
48
- }