@shuind/dsh-codex-harness 0.2.8 → 0.2.9
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/lib/compaction.js +1 -2
- package/lib/index.js +37 -13
- package/lib/installer.js +1 -2
- package/lib/types/compaction.js +1 -2
- package/lib/types/index.js +35 -12
- package/lib/types/settings.d.ts +2 -1
- package/lib/types/settings.js +1 -2
- package/package.json +1 -1
package/lib/compaction.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
|
3
|
-
import { settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
4
3
|
//#region lib/types/compaction.js
|
|
5
4
|
/** Codex compaction backend that honors the latest durable request capacity. */
|
|
6
5
|
/**
|
|
@@ -25,7 +24,7 @@ function runCodexCompactionMode(mode, task) {
|
|
|
25
24
|
function codexCompactionMode() {
|
|
26
25
|
return COMPACTION_MODE.getStore();
|
|
27
26
|
}
|
|
28
|
-
const CODEX_SETTINGS_NAMESPACE =
|
|
27
|
+
const CODEX_SETTINGS_NAMESPACE = "codex";
|
|
29
28
|
/** Codex context overrides apply only to GPT-compatible model routes. */
|
|
30
29
|
function isGptModel(model) {
|
|
31
30
|
return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
|
-
import { installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
3
2
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
4
3
|
import { randomBytes, randomUUID } from "node:crypto";
|
|
5
4
|
import { join, resolve } from "node:path";
|
|
@@ -1237,7 +1236,7 @@ const CODEX_CONTEXT_MAX = 1e6;
|
|
|
1237
1236
|
//#region lib/types/settings.js
|
|
1238
1237
|
/** Shared host-side Codex settings contract. */
|
|
1239
1238
|
/** Live Codex controls shared by the Web UI and agent layer. */
|
|
1240
|
-
const CODEX_SETTINGS_NAMESPACE =
|
|
1239
|
+
const CODEX_SETTINGS_NAMESPACE = "codex";
|
|
1241
1240
|
/** Default settings exposed even before a Codex session is opened. */
|
|
1242
1241
|
const CODEX_SETTINGS_ENTRY = {
|
|
1243
1242
|
fast: false,
|
|
@@ -1291,7 +1290,7 @@ const COMPACTION_MODE = (() => {
|
|
|
1291
1290
|
function codexCompactionMode() {
|
|
1292
1291
|
return COMPACTION_MODE.getStore();
|
|
1293
1292
|
}
|
|
1294
|
-
const CODEX_SETTINGS_NAMESPACE$1 =
|
|
1293
|
+
const CODEX_SETTINGS_NAMESPACE$1 = "codex";
|
|
1295
1294
|
/** Codex context overrides apply only to GPT-compatible model routes. */
|
|
1296
1295
|
function isGptModel$1(model) {
|
|
1297
1296
|
return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
|
@@ -1394,7 +1393,7 @@ const Config = z.object({
|
|
|
1394
1393
|
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
1395
1394
|
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT)
|
|
1396
1395
|
});
|
|
1397
|
-
const LLM_PI_AI_SETTINGS =
|
|
1396
|
+
const LLM_PI_AI_SETTINGS = "llm-pi-ai";
|
|
1398
1397
|
const GPT_REASONING_EFFORTS = {
|
|
1399
1398
|
low: "low",
|
|
1400
1399
|
medium: "medium",
|
|
@@ -1491,14 +1490,39 @@ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, w
|
|
|
1491
1490
|
...entry,
|
|
1492
1491
|
...value
|
|
1493
1492
|
});
|
|
1494
|
-
const settings = ctx.get("settings");
|
|
1495
|
-
if (settings?.get(CODEX_SETTINGS_NAMESPACE) !== void 0) return { current: () => withDefaults(settings.get(CODEX_SETTINGS_NAMESPACE)) };
|
|
1496
1493
|
let source = () => entry;
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1494
|
+
let attached = false;
|
|
1495
|
+
const attachSettings = (candidate) => {
|
|
1496
|
+
if (attached || candidate === void 0 || candidate === null) return attached;
|
|
1497
|
+
const settings = candidate;
|
|
1498
|
+
if (typeof settings.get === "function") {
|
|
1499
|
+
const get = settings.get.bind(settings);
|
|
1500
|
+
if (get("codex") !== void 0) {
|
|
1501
|
+
source = () => get(CODEX_SETTINGS_NAMESPACE);
|
|
1502
|
+
attached = true;
|
|
1503
|
+
return true;
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
if (typeof settings.installSection === "function") {
|
|
1507
|
+
settings.installSection.call(settings, ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
|
|
1508
|
+
setSource: (current) => {
|
|
1509
|
+
source = current;
|
|
1510
|
+
},
|
|
1511
|
+
onChange: () => {}
|
|
1512
|
+
});
|
|
1513
|
+
attached = true;
|
|
1514
|
+
return true;
|
|
1515
|
+
}
|
|
1516
|
+
if (typeof settings.register === "function") {
|
|
1517
|
+
const scope = settings.register.call(settings, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, { base: entry });
|
|
1518
|
+
source = () => scope.get();
|
|
1519
|
+
attached = true;
|
|
1520
|
+
return true;
|
|
1521
|
+
}
|
|
1522
|
+
return false;
|
|
1523
|
+
};
|
|
1524
|
+
if (!attachSettings(ctx.get("settings"))) ctx.inject(["settings"], (settingsCtx) => {
|
|
1525
|
+
attachSettings(settingsCtx.settings);
|
|
1502
1526
|
});
|
|
1503
1527
|
return { current: () => withDefaults(source()) };
|
|
1504
1528
|
}
|
|
@@ -1555,10 +1579,10 @@ function installCodexContextProjection(ctx, current) {
|
|
|
1555
1579
|
sync(session);
|
|
1556
1580
|
});
|
|
1557
1581
|
ctx.on("settings/updated", (ns, next) => {
|
|
1558
|
-
if (ns ===
|
|
1582
|
+
if (ns === "codex") syncAll(next.contextWindow);
|
|
1559
1583
|
});
|
|
1560
1584
|
ctx.on("settings/document-updated", (ns) => {
|
|
1561
|
-
if (ns ===
|
|
1585
|
+
if (ns === "codex") syncAll();
|
|
1562
1586
|
});
|
|
1563
1587
|
syncAll();
|
|
1564
1588
|
}
|
package/lib/installer.js
CHANGED
|
@@ -4,7 +4,6 @@ import { homedir } from "node:os";
|
|
|
4
4
|
import { dirname, join, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import z from "@deepseek-ai/schemastery";
|
|
7
|
-
import { settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
8
7
|
//#region lib/types/context.js
|
|
9
8
|
const CODEX_CONTEXT_MAX = 1e6;
|
|
10
9
|
//#endregion
|
|
@@ -65,7 +64,7 @@ const DEFAULT_DSH_CORE_WEB_PROMPT = [
|
|
|
65
64
|
//#region lib/types/settings.js
|
|
66
65
|
/** Shared host-side Codex settings contract. */
|
|
67
66
|
/** Live Codex controls shared by the Web UI and agent layer. */
|
|
68
|
-
const CODEX_SETTINGS_NAMESPACE =
|
|
67
|
+
const CODEX_SETTINGS_NAMESPACE = "codex";
|
|
69
68
|
/** Default settings exposed even before a Codex session is opened. */
|
|
70
69
|
const CODEX_SETTINGS_ENTRY = {
|
|
71
70
|
fast: false,
|
package/lib/types/compaction.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** Codex compaction backend that honors the latest durable request capacity. */
|
|
2
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
3
|
import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
|
|
4
|
-
import { settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
5
4
|
/**
|
|
6
5
|
* The main plugin entry and the compact-command subpath can be evaluated as
|
|
7
6
|
* separate bundles. Keep their async context carrier on the process global so
|
|
@@ -25,7 +24,7 @@ export function runCodexCompactionMode(mode, task) {
|
|
|
25
24
|
export function codexCompactionMode() {
|
|
26
25
|
return COMPACTION_MODE.getStore();
|
|
27
26
|
}
|
|
28
|
-
const CODEX_SETTINGS_NAMESPACE =
|
|
27
|
+
const CODEX_SETTINGS_NAMESPACE = 'codex';
|
|
29
28
|
/** Codex context overrides apply only to GPT-compatible model routes. */
|
|
30
29
|
function isGptModel(model) {
|
|
31
30
|
return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
package/lib/types/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** Codex-compatible prompt overlay and core tools for a dsh agent preset. */
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
|
-
import { installSettingsSection, settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
4
3
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
5
4
|
import { APPLY_PATCH_DESCRIPTION, applyPatchHunks, parsePatch } from "./patch.js";
|
|
6
5
|
import { renderExecResult, runExecCommand, runWriteStdin } from "./exec.js";
|
|
@@ -29,7 +28,7 @@ export const Config = z.object({
|
|
|
29
28
|
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
30
29
|
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT),
|
|
31
30
|
});
|
|
32
|
-
const LLM_PI_AI_SETTINGS =
|
|
31
|
+
const LLM_PI_AI_SETTINGS = 'llm-pi-ai';
|
|
33
32
|
const GPT_REASONING_EFFORTS = {
|
|
34
33
|
low: 'low',
|
|
35
34
|
medium: 'medium',
|
|
@@ -134,17 +133,41 @@ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, w
|
|
|
134
133
|
...entry,
|
|
135
134
|
...value,
|
|
136
135
|
});
|
|
137
|
-
const settings = ctx.get('settings');
|
|
138
|
-
if (settings?.get(CODEX_SETTINGS_NAMESPACE) !== undefined) {
|
|
139
|
-
return {
|
|
140
|
-
current: () => withDefaults(settings.get(CODEX_SETTINGS_NAMESPACE)),
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
136
|
let source = () => entry;
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
137
|
+
let attached = false;
|
|
138
|
+
const attachSettings = (candidate) => {
|
|
139
|
+
if (attached || candidate === undefined || candidate === null)
|
|
140
|
+
return attached;
|
|
141
|
+
const settings = candidate;
|
|
142
|
+
if (typeof settings.get === 'function') {
|
|
143
|
+
const get = settings.get.bind(settings);
|
|
144
|
+
if (get(CODEX_SETTINGS_NAMESPACE) !== undefined) {
|
|
145
|
+
source = () => get(CODEX_SETTINGS_NAMESPACE);
|
|
146
|
+
attached = true;
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (typeof settings.installSection === 'function') {
|
|
151
|
+
settings.installSection.call(settings, ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
|
|
152
|
+
setSource: (current) => { source = current; },
|
|
153
|
+
onChange: () => { },
|
|
154
|
+
});
|
|
155
|
+
attached = true;
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
if (typeof settings.register === 'function') {
|
|
159
|
+
const scope = settings.register.call(settings, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, { base: entry });
|
|
160
|
+
source = () => scope.get();
|
|
161
|
+
attached = true;
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
};
|
|
166
|
+
if (!attachSettings(ctx.get('settings'))) {
|
|
167
|
+
ctx.inject(['settings'], (settingsCtx) => {
|
|
168
|
+
attachSettings(settingsCtx.settings);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
148
171
|
return { current: () => withDefaults(source()) };
|
|
149
172
|
}
|
|
150
173
|
function hasOpenTurn(session) {
|
package/lib/types/settings.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** Shared host-side Codex settings contract. */
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
|
+
import type { SettingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
3
4
|
/** Live Codex controls shared by the Web UI and agent layer. */
|
|
4
|
-
export declare const CODEX_SETTINGS_NAMESPACE:
|
|
5
|
+
export declare const CODEX_SETTINGS_NAMESPACE: SettingsNamespace;
|
|
5
6
|
export interface CodexSettings {
|
|
6
7
|
/** Use the Responses priority service tier for GPT requests. */
|
|
7
8
|
fast: boolean;
|
package/lib/types/settings.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/** Shared host-side Codex settings contract. */
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
|
-
import { settingsNamespace } from '@deepseek-ai/dsh-settings';
|
|
4
3
|
import { CODEX_CONTEXT_MAX } from "./context.js";
|
|
5
4
|
import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "./prompt.js";
|
|
6
5
|
/** Live Codex controls shared by the Web UI and agent layer. */
|
|
7
|
-
export const CODEX_SETTINGS_NAMESPACE =
|
|
6
|
+
export const CODEX_SETTINGS_NAMESPACE = 'codex';
|
|
8
7
|
/** Default settings exposed even before a Codex session is opened. */
|
|
9
8
|
export const CODEX_SETTINGS_ENTRY = {
|
|
10
9
|
fast: false,
|