@shuind/dsh-codex-harness 0.2.8 → 0.2.10
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 +52 -14
- package/lib/installer.js +1 -2
- package/lib/types/activity.js +18 -1
- 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";
|
|
@@ -7,7 +6,6 @@ import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
|
7
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8
7
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
9
8
|
import { homedir } from "node:os";
|
|
10
|
-
import { isTokenDelta } from "@deepseek-ai/dsh-llm/message";
|
|
11
9
|
import { z as z$1 } from "zod";
|
|
12
10
|
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
|
13
11
|
//#region lib/types/patch.js
|
|
@@ -1108,6 +1106,21 @@ function remoteCompactStream(ctx, options, next, wireOptions = {}) {
|
|
|
1108
1106
|
//#endregion
|
|
1109
1107
|
//#region lib/types/activity.js
|
|
1110
1108
|
/** Host-side activity projection for the Codex status line. */
|
|
1109
|
+
/**
|
|
1110
|
+
* Whether a stream chunk carries visible model output.
|
|
1111
|
+
*
|
|
1112
|
+
* DSH 0.1.2 removed the runtime `isTokenDelta` helper from `dsh-llm/message`
|
|
1113
|
+
* while keeping the StreamChunk vocabulary unchanged. Keep this small
|
|
1114
|
+
* predicate local so the harness works with both the old and new DSH bundles.
|
|
1115
|
+
*/
|
|
1116
|
+
function isTokenDelta(chunk) {
|
|
1117
|
+
switch (chunk.type) {
|
|
1118
|
+
case "text-delta":
|
|
1119
|
+
case "reasoning-delta": return chunk.text !== "";
|
|
1120
|
+
case "tool-call-delta": return chunk.argumentsDelta !== "" || chunk.name !== void 0;
|
|
1121
|
+
default: return false;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1111
1124
|
/** Only a non-empty model delta starts the reply phase; usage and finish frames do not. */
|
|
1112
1125
|
function startsModelReply(event) {
|
|
1113
1126
|
if (event.type === "assistant/message") return true;
|
|
@@ -1237,7 +1250,7 @@ const CODEX_CONTEXT_MAX = 1e6;
|
|
|
1237
1250
|
//#region lib/types/settings.js
|
|
1238
1251
|
/** Shared host-side Codex settings contract. */
|
|
1239
1252
|
/** Live Codex controls shared by the Web UI and agent layer. */
|
|
1240
|
-
const CODEX_SETTINGS_NAMESPACE =
|
|
1253
|
+
const CODEX_SETTINGS_NAMESPACE = "codex";
|
|
1241
1254
|
/** Default settings exposed even before a Codex session is opened. */
|
|
1242
1255
|
const CODEX_SETTINGS_ENTRY = {
|
|
1243
1256
|
fast: false,
|
|
@@ -1291,7 +1304,7 @@ const COMPACTION_MODE = (() => {
|
|
|
1291
1304
|
function codexCompactionMode() {
|
|
1292
1305
|
return COMPACTION_MODE.getStore();
|
|
1293
1306
|
}
|
|
1294
|
-
const CODEX_SETTINGS_NAMESPACE$1 =
|
|
1307
|
+
const CODEX_SETTINGS_NAMESPACE$1 = "codex";
|
|
1295
1308
|
/** Codex context overrides apply only to GPT-compatible model routes. */
|
|
1296
1309
|
function isGptModel$1(model) {
|
|
1297
1310
|
return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
|
|
@@ -1394,7 +1407,7 @@ const Config = z.object({
|
|
|
1394
1407
|
harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
|
|
1395
1408
|
webSurfacePrompt: z.string().default(DEFAULT_DSH_CORE_WEB_PROMPT)
|
|
1396
1409
|
});
|
|
1397
|
-
const LLM_PI_AI_SETTINGS =
|
|
1410
|
+
const LLM_PI_AI_SETTINGS = "llm-pi-ai";
|
|
1398
1411
|
const GPT_REASONING_EFFORTS = {
|
|
1399
1412
|
low: "low",
|
|
1400
1413
|
medium: "medium",
|
|
@@ -1491,14 +1504,39 @@ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, w
|
|
|
1491
1504
|
...entry,
|
|
1492
1505
|
...value
|
|
1493
1506
|
});
|
|
1494
|
-
const settings = ctx.get("settings");
|
|
1495
|
-
if (settings?.get(CODEX_SETTINGS_NAMESPACE) !== void 0) return { current: () => withDefaults(settings.get(CODEX_SETTINGS_NAMESPACE)) };
|
|
1496
1507
|
let source = () => entry;
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1508
|
+
let attached = false;
|
|
1509
|
+
const attachSettings = (candidate) => {
|
|
1510
|
+
if (attached || candidate === void 0 || candidate === null) return attached;
|
|
1511
|
+
const settings = candidate;
|
|
1512
|
+
if (typeof settings.get === "function") {
|
|
1513
|
+
const get = settings.get.bind(settings);
|
|
1514
|
+
if (get("codex") !== void 0) {
|
|
1515
|
+
source = () => get(CODEX_SETTINGS_NAMESPACE);
|
|
1516
|
+
attached = true;
|
|
1517
|
+
return true;
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
if (typeof settings.installSection === "function") {
|
|
1521
|
+
settings.installSection.call(settings, ctx, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, entry, {
|
|
1522
|
+
setSource: (current) => {
|
|
1523
|
+
source = current;
|
|
1524
|
+
},
|
|
1525
|
+
onChange: () => {}
|
|
1526
|
+
});
|
|
1527
|
+
attached = true;
|
|
1528
|
+
return true;
|
|
1529
|
+
}
|
|
1530
|
+
if (typeof settings.register === "function") {
|
|
1531
|
+
const scope = settings.register.call(settings, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, { base: entry });
|
|
1532
|
+
source = () => scope.get();
|
|
1533
|
+
attached = true;
|
|
1534
|
+
return true;
|
|
1535
|
+
}
|
|
1536
|
+
return false;
|
|
1537
|
+
};
|
|
1538
|
+
if (!attachSettings(ctx.get("settings"))) ctx.inject(["settings"], (settingsCtx) => {
|
|
1539
|
+
attachSettings(settingsCtx.settings);
|
|
1502
1540
|
});
|
|
1503
1541
|
return { current: () => withDefaults(source()) };
|
|
1504
1542
|
}
|
|
@@ -1555,10 +1593,10 @@ function installCodexContextProjection(ctx, current) {
|
|
|
1555
1593
|
sync(session);
|
|
1556
1594
|
});
|
|
1557
1595
|
ctx.on("settings/updated", (ns, next) => {
|
|
1558
|
-
if (ns ===
|
|
1596
|
+
if (ns === "codex") syncAll(next.contextWindow);
|
|
1559
1597
|
});
|
|
1560
1598
|
ctx.on("settings/document-updated", (ns) => {
|
|
1561
|
-
if (ns ===
|
|
1599
|
+
if (ns === "codex") syncAll();
|
|
1562
1600
|
});
|
|
1563
1601
|
syncAll();
|
|
1564
1602
|
}
|
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/activity.js
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
/** Host-side activity projection for the Codex status line. */
|
|
2
|
-
import { isTokenDelta } from '@deepseek-ai/dsh-llm/message';
|
|
3
2
|
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Whether a stream chunk carries visible model output.
|
|
5
|
+
*
|
|
6
|
+
* DSH 0.1.2 removed the runtime `isTokenDelta` helper from `dsh-llm/message`
|
|
7
|
+
* while keeping the StreamChunk vocabulary unchanged. Keep this small
|
|
8
|
+
* predicate local so the harness works with both the old and new DSH bundles.
|
|
9
|
+
*/
|
|
10
|
+
function isTokenDelta(chunk) {
|
|
11
|
+
switch (chunk.type) {
|
|
12
|
+
case 'text-delta':
|
|
13
|
+
case 'reasoning-delta':
|
|
14
|
+
return chunk.text !== '';
|
|
15
|
+
case 'tool-call-delta':
|
|
16
|
+
return chunk.argumentsDelta !== '' || chunk.name !== undefined;
|
|
17
|
+
default:
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
4
21
|
/** Only a non-empty model delta starts the reply phase; usage and finish frames do not. */
|
|
5
22
|
function startsModelReply(event) {
|
|
6
23
|
if (event.type === 'assistant/message')
|
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,
|