@shuind/dsh-codex-harness 0.2.6 → 0.2.7

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/client.js CHANGED
@@ -236,11 +236,6 @@ window.__ModuleLoader__.load({
236
236
  activityRequestingModel: "请求中...",
237
237
  activityModelReply: "回复中..."
238
238
  };
239
- function promptFromLayer(layer) {
240
- if (typeof layer !== "object" || layer === null || Array.isArray(layer)) return void 0;
241
- const value = layer["systemPrompt"];
242
- return typeof value === "string" ? value : void 0;
243
- }
244
239
  function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting }) {
245
240
  return (0, react_jsx_runtime.jsxs)("label", {
246
241
  style: {
@@ -441,13 +436,12 @@ window.__ModuleLoader__.load({
441
436
  }
442
437
  /** Full-prompt editor contributed to Settings > Plugins. */
443
438
  function PromptSettingsCard(props) {
444
- const { useSettings, setSetting, unsetSetting, t } = props;
439
+ const { useSettings, setSetting, t } = props;
445
440
  const snapshot = useSettings((state) => state);
446
441
  const currentPersona = snapshot.value?.persona ?? DEFAULT_CODEX_PERSONA;
447
442
  const currentSourcePrompt = snapshot.value?.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT;
448
443
  const currentWebPrompt = snapshot.value?.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT;
449
444
  const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
450
- const inherited = promptFromLayer(snapshot.base) ?? DEFAULT_CODEX_SYSTEM_PROMPT;
451
445
  const codexOnlyCapabilities = [
452
446
  {
453
447
  field: "fastModeControlEnabled",
@@ -542,12 +536,14 @@ window.__ModuleLoader__.load({
542
536
  setPersonaDraft(DEFAULT_CODEX_PERSONA);
543
537
  setSourcePromptDraft(DEFAULT_DSH_CORE_SOURCE_PROMPT);
544
538
  setWebPromptDraft(DEFAULT_DSH_CORE_WEB_PROMPT);
545
- setDraft(inherited);
539
+ setDraft(DEFAULT_CODEX_SYSTEM_PROMPT);
546
540
  try {
547
- await unsetSetting("systemPrompt");
548
- await unsetSetting("persona");
549
- await unsetSetting("harnessSourcePrompt");
550
- await unsetSetting("webSurfacePrompt");
541
+ await Promise.all([
542
+ setSetting("persona", DEFAULT_CODEX_PERSONA),
543
+ setSetting("harnessSourcePrompt", DEFAULT_DSH_CORE_SOURCE_PROMPT),
544
+ setSetting("webSurfacePrompt", DEFAULT_DSH_CORE_WEB_PROMPT),
545
+ setSetting("systemPrompt", DEFAULT_CODEX_SYSTEM_PROMPT)
546
+ ]);
551
547
  } catch {
552
548
  setFailed(true);
553
549
  setPersonaDraft(currentPersona);
@@ -765,6 +761,9 @@ window.__ModuleLoader__.load({
765
761
  type: "button",
766
762
  disabled: !dirty || saving,
767
763
  onClick: () => {
764
+ setPersonaDraft(currentPersona);
765
+ setSourcePromptDraft(currentSourcePrompt);
766
+ setWebPromptDraft(currentWebPrompt);
768
767
  setDraft(current);
769
768
  setFailed(false);
770
769
  },
@@ -1068,14 +1067,20 @@ window.__ModuleLoader__.load({
1068
1067
  }
1069
1068
  return null;
1070
1069
  }
1070
+ function isTurnStatus(status) {
1071
+ return status.textContent?.includes("Deep diving...") === true || status.className.toString().includes("turnStatus");
1072
+ }
1073
+ function hasLayout(status) {
1074
+ const rect = status.getBoundingClientRect();
1075
+ return rect.width > 0 && rect.height > 0;
1076
+ }
1077
+ /** Prefer the actual Core turn status over unrelated global status nodes. */
1078
+ function selectTurnStatus(statuses) {
1079
+ const preferred = statuses.filter(isTurnStatus);
1080
+ return preferred.findLast(hasLayout) ?? preferred.at(-1) ?? statuses.filter((status) => status.closest("[data-chat-flow]") !== null).findLast(hasLayout) ?? statuses.filter((status) => status.closest("[data-chat-flow]") !== null).at(-1) ?? null;
1081
+ }
1071
1082
  function findTurnStatus() {
1072
- let fallback = null;
1073
- for (const status of document.querySelectorAll("[role=\"status\"]")) {
1074
- if (status.closest("[data-chat-flow]") === null) continue;
1075
- fallback ??= status;
1076
- if (status.textContent?.includes("Deep diving...") === true || status.className.toString().includes("turnStatus")) return status;
1077
- }
1078
- return fallback;
1083
+ return selectTurnStatus([...document.querySelectorAll("[role=\"status\"]")]);
1079
1084
  }
1080
1085
  function useTurnStatusPosition(target) {
1081
1086
  const [position, setPosition] = (0, react.useState)(null);
@@ -1240,6 +1245,7 @@ window.__ModuleLoader__.load({
1240
1245
  exports.default = client_default;
1241
1246
  exports.inject = inject;
1242
1247
  exports.resolveActivity = resolveActivity;
1248
+ exports.selectTurnStatus = selectTurnStatus;
1243
1249
  return module.exports;
1244
1250
  }
1245
1251
  });
package/lib/compaction.js CHANGED
@@ -3,7 +3,20 @@ import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
3
3
  import { settingsNamespace } from "@deepseek-ai/dsh-settings";
4
4
  //#region lib/types/compaction.js
5
5
  /** Codex compaction backend that honors the latest durable request capacity. */
6
- const COMPACTION_MODE = new AsyncLocalStorage();
6
+ /**
7
+ * The main plugin entry and the compact-command subpath can be evaluated as
8
+ * separate bundles. Keep their async context carrier on the process global so
9
+ * an explicit command mode reaches the global llm/stream listener.
10
+ */
11
+ const COMPACTION_MODE_KEY = Symbol.for("shuind.dsh-codex-harness.compaction-mode");
12
+ const COMPACTION_MODE = (() => {
13
+ const registry = globalThis;
14
+ const existing = registry[COMPACTION_MODE_KEY];
15
+ if (existing !== void 0) return existing;
16
+ const storage = new AsyncLocalStorage();
17
+ registry[COMPACTION_MODE_KEY] = storage;
18
+ return storage;
19
+ })();
7
20
  /** Run one manual compaction with an explicit local/remote preference. */
8
21
  function runCodexCompactionMode(mode, task) {
9
22
  return COMPACTION_MODE.run(mode, task);
package/lib/index.js CHANGED
@@ -1273,7 +1273,20 @@ const CODEX_SETTINGS_SCHEMA = z.object({
1273
1273
  //#endregion
1274
1274
  //#region lib/types/compaction.js
1275
1275
  /** Codex compaction backend that honors the latest durable request capacity. */
1276
- const COMPACTION_MODE = new AsyncLocalStorage();
1276
+ /**
1277
+ * The main plugin entry and the compact-command subpath can be evaluated as
1278
+ * separate bundles. Keep their async context carrier on the process global so
1279
+ * an explicit command mode reaches the global llm/stream listener.
1280
+ */
1281
+ const COMPACTION_MODE_KEY = Symbol.for("shuind.dsh-codex-harness.compaction-mode");
1282
+ const COMPACTION_MODE = (() => {
1283
+ const registry = globalThis;
1284
+ const existing = registry[COMPACTION_MODE_KEY];
1285
+ if (existing !== void 0) return existing;
1286
+ const storage = new AsyncLocalStorage();
1287
+ registry[COMPACTION_MODE_KEY] = storage;
1288
+ return storage;
1289
+ })();
1277
1290
  /** Read the explicit preference for the current compaction stream, if any. */
1278
1291
  function codexCompactionMode() {
1279
1292
  return COMPACTION_MODE.getStore();
@@ -117,6 +117,8 @@ export declare function ActivityLine({ sessionId: _sessionId, useSession, useSes
117
117
  top: number;
118
118
  };
119
119
  }): import("react").JSX.Element | null;
120
+ /** Prefer the actual Core turn status over unrelated global status nodes. */
121
+ export declare function selectTurnStatus(statuses: readonly HTMLElement[]): HTMLElement | null;
120
122
  export declare const inject: string[];
121
123
  /** Mount request controls and the plugin settings card through shared slots. */
122
124
  export declare function apply(ctx: Context): void;
@@ -121,12 +121,6 @@ const zh = {
121
121
  activityRequestingModel: '\u8bf7\u6c42\u4e2d...',
122
122
  activityModelReply: '\u56de\u590d\u4e2d...',
123
123
  };
124
- function promptFromLayer(layer) {
125
- if (typeof layer !== 'object' || layer === null || Array.isArray(layer))
126
- return undefined;
127
- const value = layer['systemPrompt'];
128
- return typeof value === 'string' ? value : undefined;
129
- }
130
124
  function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }) {
131
125
  return (_jsxs("label", { style: {
132
126
  display: 'flex',
@@ -207,13 +201,12 @@ function PromptEditor({ id, label, hint, value, writable, saving, minHeight, onC
207
201
  }
208
202
  /** Full-prompt editor contributed to Settings > Plugins. */
209
203
  export function PromptSettingsCard(props) {
210
- const { useSettings, setSetting, unsetSetting, t } = props;
204
+ const { useSettings, setSetting, t } = props;
211
205
  const snapshot = useSettings(state => state);
212
206
  const currentPersona = snapshot.value?.persona ?? DEFAULT_CODEX_PERSONA;
213
207
  const currentSourcePrompt = snapshot.value?.harnessSourcePrompt ?? DEFAULT_DSH_CORE_SOURCE_PROMPT;
214
208
  const currentWebPrompt = snapshot.value?.webSurfacePrompt ?? DEFAULT_DSH_CORE_WEB_PROMPT;
215
209
  const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
216
- const inherited = promptFromLayer(snapshot.base) ?? DEFAULT_CODEX_SYSTEM_PROMPT;
217
210
  const codexOnlyCapabilities = [
218
211
  { field: 'fastModeControlEnabled', label: 'capabilityFast', hint: 'capabilityFastHint' },
219
212
  { field: 'promptEnabled', label: 'capabilityPrompt', hint: 'capabilityPromptHint' },
@@ -270,12 +263,14 @@ export function PromptSettingsCard(props) {
270
263
  setPersonaDraft(DEFAULT_CODEX_PERSONA);
271
264
  setSourcePromptDraft(DEFAULT_DSH_CORE_SOURCE_PROMPT);
272
265
  setWebPromptDraft(DEFAULT_DSH_CORE_WEB_PROMPT);
273
- setDraft(inherited);
266
+ setDraft(DEFAULT_CODEX_SYSTEM_PROMPT);
274
267
  try {
275
- await unsetSetting('systemPrompt');
276
- await unsetSetting('persona');
277
- await unsetSetting('harnessSourcePrompt');
278
- await unsetSetting('webSurfacePrompt');
268
+ await Promise.all([
269
+ setSetting('persona', DEFAULT_CODEX_PERSONA),
270
+ setSetting('harnessSourcePrompt', DEFAULT_DSH_CORE_SOURCE_PROMPT),
271
+ setSetting('webSurfacePrompt', DEFAULT_DSH_CORE_WEB_PROMPT),
272
+ setSetting('systemPrompt', DEFAULT_CODEX_SYSTEM_PROMPT),
273
+ ]);
279
274
  }
280
275
  catch {
281
276
  setFailed(true);
@@ -324,7 +319,13 @@ export function PromptSettingsCard(props) {
324
319
  gap: 8,
325
320
  paddingTop: 12,
326
321
  borderTop: '1px solid var(--dsw-alias-border-l2)',
327
- }, children: [failed && (_jsx("span", { role: "status", style: { flex: 1, color: 'var(--dsw-alias-label-error)', fontSize: 12 }, children: t('promptSaveFailed') })), _jsx("button", { type: "button", disabled: !dirty || saving, onClick: () => { setDraft(current); setFailed(false); }, style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8, background: 'none', color: 'inherit', padding: '5px 14px', font: 'inherit', cursor: 'pointer' }, children: t('promptDiscard') }), _jsx("button", { type: "button", disabled: !snapshot.writable || !dirty || saving, onClick: () => { void save(); }, style: { border: 0, borderRadius: 8, background: 'var(--dsw-alias-label-primary)', color: 'var(--dsw-alias-bg-layer-3)', padding: '6px 14px', font: 'inherit', cursor: 'pointer' }, children: saving ? t('promptSaving') : t('promptSave') })] })] }))] }));
322
+ }, children: [failed && (_jsx("span", { role: "status", style: { flex: 1, color: 'var(--dsw-alias-label-error)', fontSize: 12 }, children: t('promptSaveFailed') })), _jsx("button", { type: "button", disabled: !dirty || saving, onClick: () => {
323
+ setPersonaDraft(currentPersona);
324
+ setSourcePromptDraft(currentSourcePrompt);
325
+ setWebPromptDraft(currentWebPrompt);
326
+ setDraft(current);
327
+ setFailed(false);
328
+ }, style: { border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8, background: 'none', color: 'inherit', padding: '5px 14px', font: 'inherit', cursor: 'pointer' }, children: t('promptDiscard') }), _jsx("button", { type: "button", disabled: !snapshot.writable || !dirty || saving, onClick: () => { void save(); }, style: { border: 0, borderRadius: 8, background: 'var(--dsw-alias-label-primary)', color: 'var(--dsw-alias-bg-layer-3)', padding: '6px 14px', font: 'inherit', cursor: 'pointer' }, children: saving ? t('promptSaving') : t('promptSave') })] })] }))] }));
328
329
  }
329
330
  /** The legacy composer seat is a compact inline row, not a menu panel. */
330
331
  function FastModeFallback(props) {
@@ -488,17 +489,25 @@ function findContextMeterDialog() {
488
489
  }
489
490
  return null;
490
491
  }
492
+ function isTurnStatus(status) {
493
+ return status.textContent?.includes('Deep diving...') === true
494
+ || status.className.toString().includes('turnStatus');
495
+ }
496
+ function hasLayout(status) {
497
+ const rect = status.getBoundingClientRect();
498
+ return rect.width > 0 && rect.height > 0;
499
+ }
500
+ /** Prefer the actual Core turn status over unrelated global status nodes. */
501
+ export function selectTurnStatus(statuses) {
502
+ const preferred = statuses.filter(isTurnStatus);
503
+ return preferred.findLast(hasLayout)
504
+ ?? preferred.at(-1)
505
+ ?? statuses.filter(status => status.closest('[data-chat-flow]') !== null).findLast(hasLayout)
506
+ ?? statuses.filter(status => status.closest('[data-chat-flow]') !== null).at(-1)
507
+ ?? null;
508
+ }
491
509
  function findTurnStatus() {
492
- let fallback = null;
493
- for (const status of document.querySelectorAll('[role="status"]')) {
494
- if (status.closest('[data-chat-flow]') === null)
495
- continue;
496
- fallback ??= status;
497
- if (status.textContent?.includes('Deep diving...') === true
498
- || status.className.toString().includes('turnStatus'))
499
- return status;
500
- }
501
- return fallback;
510
+ return selectTurnStatus([...document.querySelectorAll('[role="status"]')]);
502
511
  }
503
512
  function useTurnStatusPosition(target) {
504
513
  const [position, setPosition] = useState(null);
@@ -2,7 +2,21 @@
2
2
  import { AsyncLocalStorage } from 'node:async_hooks';
3
3
  import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
4
4
  import { settingsNamespace } from '@deepseek-ai/dsh-settings';
5
- const COMPACTION_MODE = new AsyncLocalStorage();
5
+ /**
6
+ * The main plugin entry and the compact-command subpath can be evaluated as
7
+ * separate bundles. Keep their async context carrier on the process global so
8
+ * an explicit command mode reaches the global llm/stream listener.
9
+ */
10
+ const COMPACTION_MODE_KEY = Symbol.for('shuind.dsh-codex-harness.compaction-mode');
11
+ const COMPACTION_MODE = (() => {
12
+ const registry = globalThis;
13
+ const existing = registry[COMPACTION_MODE_KEY];
14
+ if (existing !== undefined)
15
+ return existing;
16
+ const storage = new AsyncLocalStorage();
17
+ registry[COMPACTION_MODE_KEY] = storage;
18
+ return storage;
19
+ })();
6
20
  /** Run one manual compaction with an explicit local/remote preference. */
7
21
  export function runCodexCompactionMode(mode, task) {
8
22
  return COMPACTION_MODE.run(mode, task);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Codex coding preset with customizable prompts and tools for DSH.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",