@shuind/dsh-codex-harness 0.2.9 → 0.2.11
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/index.js +24 -3
- package/lib/types/activity.js +18 -1
- package/lib/types/index.js +10 -2
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -6,7 +6,6 @@ import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
|
6
6
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
7
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { homedir } from "node:os";
|
|
9
|
-
import { isTokenDelta } from "@deepseek-ai/dsh-llm/message";
|
|
10
9
|
import { z as z$1 } from "zod";
|
|
11
10
|
import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
|
|
12
11
|
//#region lib/types/patch.js
|
|
@@ -1107,6 +1106,21 @@ function remoteCompactStream(ctx, options, next, wireOptions = {}) {
|
|
|
1107
1106
|
//#endregion
|
|
1108
1107
|
//#region lib/types/activity.js
|
|
1109
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
|
+
}
|
|
1110
1124
|
/** Only a non-empty model delta starts the reply phase; usage and finish frames do not. */
|
|
1111
1125
|
function startsModelReply(event) {
|
|
1112
1126
|
if (event.type === "assistant/message") return true;
|
|
@@ -1526,9 +1540,16 @@ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, w
|
|
|
1526
1540
|
});
|
|
1527
1541
|
return { current: () => withDefaults(source()) };
|
|
1528
1542
|
}
|
|
1543
|
+
/** Read the event snapshot across the pre- and post-0.1.2 DSH session APIs. */
|
|
1544
|
+
function sessionEvents(session) {
|
|
1545
|
+
const compatible = session;
|
|
1546
|
+
if (typeof compatible.snapshotEvents === "function") return compatible.snapshotEvents();
|
|
1547
|
+
return compatible.events ?? [];
|
|
1548
|
+
}
|
|
1529
1549
|
function hasOpenTurn(session) {
|
|
1530
|
-
const
|
|
1531
|
-
const
|
|
1550
|
+
const events = sessionEvents(session);
|
|
1551
|
+
const start = events.findLast((event) => event.type === "turn/start");
|
|
1552
|
+
const end = events.findLast((event) => event.type === "turn/end");
|
|
1532
1553
|
return start !== void 0 && (end === void 0 || start.seq > end.seq);
|
|
1533
1554
|
}
|
|
1534
1555
|
/**
|
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/index.js
CHANGED
|
@@ -170,9 +170,17 @@ function installCodexSettings(ctx, systemPrompt, persona, harnessSourcePrompt, w
|
|
|
170
170
|
}
|
|
171
171
|
return { current: () => withDefaults(source()) };
|
|
172
172
|
}
|
|
173
|
+
/** Read the event snapshot across the pre- and post-0.1.2 DSH session APIs. */
|
|
174
|
+
function sessionEvents(session) {
|
|
175
|
+
const compatible = session;
|
|
176
|
+
if (typeof compatible.snapshotEvents === 'function')
|
|
177
|
+
return compatible.snapshotEvents();
|
|
178
|
+
return compatible.events ?? [];
|
|
179
|
+
}
|
|
173
180
|
function hasOpenTurn(session) {
|
|
174
|
-
const
|
|
175
|
-
const
|
|
181
|
+
const events = sessionEvents(session);
|
|
182
|
+
const start = events.findLast(event => event.type === 'turn/start');
|
|
183
|
+
const end = events.findLast(event => event.type === 'turn/end');
|
|
176
184
|
return start !== undefined && (end === undefined || start.seq > end.seq);
|
|
177
185
|
}
|
|
178
186
|
/**
|