@shuind/dsh-codex-harness 0.1.32 → 0.1.34

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/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  - **后台任务**:`exec_command` 支持 `run_in_background: true`,立即返回 DSH `job_id`;使用 `job_output` 读取输出、`job_kill` 停止任务。任务完成时,忙碌中的 agent 会在下一步收到 inbox 注入;空闲 agent 默认保持安静,等下一次唤醒时再处理完成消息。
10
10
  - **GPT 能力补全**:为 GPT 系列模型补充图片输入和思考强度选项;不会覆盖用户已有的显式配置。
11
11
  - **Fast**:仅在 Codex preset 的模型选择菜单中显示,开启后向 Responses 请求发送 `service_tier: "priority"`。
12
- - **旧版 Web 兼容**:在未提供新版模型设置/上下文设置 slot 的 DSH Web 中,Fast 和上下文容量会自动回退到旧版 composer inline slot;上下文容量使用紧凑按钮和弹层,不占用整行;client 注入不依赖纯类型 slot 包。
12
+ - **Legacy Web compatibility**: The plugin uses only slots present in the legacy host. The context-size control is appended to the host context-usage popup, and the activity line is appended beside `Deep diving...`; no host upgrade is required.
13
13
  - **Responses 原生 apply_patch**:在 GPT Responses 请求的插件传输边界,把普通 JSON function tool 改写为 `type: "custom"` + OpenAI `lark` grammar;下一轮历史同步改写为 `custom_tool_call`。如果中转站拒绝 custom tool,则自动回退到普通 function tool,不改变 DSH 工具执行器。
14
14
  - **远程搜索与压缩**:OpenAI Responses 请求默认优先使用 hosted `web_search` 和 `/responses/compact`;失败时回退到 DSH 的本地实现。
15
15
  - **远程压缩用量**:`/responses/compact` 返回标准 `usage` 时,插件会把 `input_tokens`、缓存读写和 `output_tokens` 原样拆分为 DSH 的用量字段;不再把远程压缩伪造成 `0`。中转站缺失或返回不一致的 usage 时,插件不会编造数字。
@@ -20,7 +20,7 @@
20
20
  ## 安装
21
21
 
22
22
  ```sh
23
- dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.29
23
+ dsh plugin --profile web add @shuind/dsh-codex-harness@0.1.34
24
24
  ```
25
25
 
26
26
  重启 Web,创建新会话,在模式菜单中选择 **Codex 模式**。
@@ -123,7 +123,7 @@ order: 10
123
123
  开启后,Codex preset 会在系统提示词中注入以下协作要求:
124
124
 
125
125
  ```text
126
- Ask, align, and clarify first. Gather enough context from the user then achieve the user's goal through the clearest, most effective path.
126
+ Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
127
127
  Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
128
128
  Convey enough valuable information with as few words as possible. Stay focused on the end goal.
129
129
  Solve problems by thinking from first principles and at a higher level.
package/lib/client.js CHANGED
@@ -9,6 +9,7 @@ window.__ModuleLoader__.load({
9
9
  });
10
10
  let react_jsx_runtime = require("react/jsx-runtime");
11
11
  let react = require("react");
12
+ let react_dom = require("react-dom");
12
13
  //#region lib/types/context.js
13
14
  /** User-selectable Codex context controls use whole K-token units. */
14
15
  const CODEX_CONTEXT_UNIT = 1e3;
@@ -72,10 +73,8 @@ window.__ModuleLoader__.load({
72
73
  /** Browser controls for the Codex request settings mounted by the Host plugin. */
73
74
  const NS = "codex";
74
75
  const SETTINGS_NAMESPACE = "codex";
75
- const ACTIVITY_SLOT = "conversation.chat.status";
76
- const ACTIVITY_FALLBACK_SLOT = "conversation.composer.dock";
77
- const CONTEXT_SETTINGS_SLOT = "conversation.input.context.settings";
78
76
  const FAST_FALLBACK_SLOT = "conversation.input.right";
77
+ const LEGACY_OVERLAY_SLOT = "conversation.input.overlay";
79
78
  const DEFAULT_CONTEXT_WINDOW = 262144;
80
79
  const en = {
81
80
  fast: "Fast mode",
@@ -151,7 +150,7 @@ window.__ModuleLoader__.load({
151
150
  const pressure = useProjection("contextPressure");
152
151
  return pressure?.contextWindow !== void 0 && pressure.contextWindow > 0 ? pressure.contextWindow : DEFAULT_CONTEXT_WINDOW;
153
152
  }
154
- /** Settings form rendered inside the context meter's expanded panel. */
153
+ /** Settings form appended to the old host's context meter panel. */
155
154
  function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings, setSetting, unsetSetting, t }) {
156
155
  const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
157
156
  const snapshot = useSettings((state) => state);
@@ -167,9 +166,11 @@ window.__ModuleLoader__.load({
167
166
  };
168
167
  return (0, react_jsx_runtime.jsxs)("div", {
169
168
  style: {
170
- marginTop: 0,
171
169
  display: "grid",
172
- gap: 8
170
+ gap: 8,
171
+ marginTop: 10,
172
+ paddingTop: 10,
173
+ borderTop: "1px solid var(--dsw-alias-border-l2)"
173
174
  },
174
175
  children: [
175
176
  (0, react_jsx_runtime.jsxs)("div", {
@@ -280,114 +281,6 @@ window.__ModuleLoader__.load({
280
281
  ]
281
282
  });
282
283
  }
283
- /** Compact context-capacity trigger shown beside the bottom activity line. */
284
- function ContextSizeDock({ sessionId, useSessions, useProjection, useSettings, setSetting, unsetSetting, t }) {
285
- const agentPreset = useSessions((state) => state.byId[sessionId]?.agentPreset);
286
- const contextWindow = contextWindowFromProjection(useProjection);
287
- const snapshot = useSettings((state) => state);
288
- const configured = snapshot.value?.contextWindow;
289
- const valueK = Math.min(CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
290
- const [open, setOpen] = (0, react.useState)(false);
291
- const rootRef = (0, react.useRef)(null);
292
- (0, react.useEffect)(() => {
293
- if (!open) return void 0;
294
- const onPointerDown = (event) => {
295
- if (event.target instanceof Node && rootRef.current?.contains(event.target) === true) return;
296
- setOpen(false);
297
- };
298
- const onKeyDown = (event) => {
299
- if (event.key === "Escape") setOpen(false);
300
- };
301
- document.addEventListener("pointerdown", onPointerDown);
302
- document.addEventListener("keydown", onKeyDown);
303
- return () => {
304
- document.removeEventListener("pointerdown", onPointerDown);
305
- document.removeEventListener("keydown", onKeyDown);
306
- };
307
- }, [open]);
308
- if (!isCodexPresetId(agentPreset)) return null;
309
- return (0, react_jsx_runtime.jsxs)("span", {
310
- ref: rootRef,
311
- style: {
312
- position: "relative",
313
- display: "inline-flex",
314
- alignItems: "center"
315
- },
316
- children: [(0, react_jsx_runtime.jsxs)("button", {
317
- type: "button",
318
- "aria-label": `${t("contextSize")}: ${valueK}K`,
319
- "aria-haspopup": "dialog",
320
- "aria-expanded": open,
321
- disabled: snapshot.writable === false,
322
- title: t("contextSize"),
323
- onMouseDown: (event) => {
324
- event.preventDefault();
325
- },
326
- onClick: () => {
327
- setOpen((value) => !value);
328
- },
329
- style: {
330
- boxSizing: "border-box",
331
- display: "inline-flex",
332
- alignItems: "center",
333
- gap: 3,
334
- height: 28,
335
- border: 0,
336
- borderRadius: 7,
337
- padding: "0 6px",
338
- color: configured === void 0 ? "var(--dsw-alias-label-secondary)" : "var(--dsw-static-blue-500)",
339
- background: open ? "var(--dsw-alias-interactive-bg-hover)" : "transparent",
340
- cursor: snapshot.writable === false ? "default" : "pointer",
341
- font: "inherit",
342
- fontSize: 12,
343
- lineHeight: "20px",
344
- fontWeight: configured === void 0 ? 400 : 600,
345
- whiteSpace: "nowrap"
346
- },
347
- children: [(0, react_jsx_runtime.jsxs)("span", { children: [valueK, "K"] }), (0, react_jsx_runtime.jsx)("svg", {
348
- viewBox: "0 0 12 12",
349
- width: "12",
350
- height: "12",
351
- "aria-hidden": true,
352
- children: (0, react_jsx_runtime.jsx)("path", {
353
- d: "M3 4.5 6 7.5 9 4.5",
354
- fill: "none",
355
- stroke: "currentColor",
356
- strokeWidth: "1.25",
357
- strokeLinecap: "round",
358
- strokeLinejoin: "round"
359
- })
360
- })]
361
- }), open && (0, react_jsx_runtime.jsx)("div", {
362
- role: "dialog",
363
- "aria-label": t("contextSize"),
364
- style: {
365
- position: "absolute",
366
- right: 0,
367
- bottom: "calc(100% + 8px)",
368
- zIndex: 20,
369
- boxSizing: "border-box",
370
- width: 300,
371
- maxWidth: "calc(100vw - 24px)",
372
- padding: "10px 12px 12px",
373
- border: "1px solid var(--dsw-alias-border-l2)",
374
- borderRadius: 10,
375
- color: "var(--dsw-alias-label-primary)",
376
- background: "var(--dsw-alias-bg-base)",
377
- boxShadow: "var(--dsw-shadow-lv2)"
378
- },
379
- children: (0, react_jsx_runtime.jsx)(ContextSizeControl, {
380
- contextWindow,
381
- sessionId,
382
- useSessions,
383
- useSettings,
384
- setSetting,
385
- unsetSetting,
386
- t
387
- })
388
- })]
389
- });
390
- }
391
284
  function elapsedSeconds(startedAt, now) {
392
285
  return Math.max(0, Math.floor((now - startedAt) / 1e3));
393
286
  }
@@ -416,18 +309,19 @@ window.__ModuleLoader__.load({
416
309
  if (!isCodexPresetId(agentPreset) || activity === void 0 || activity === null) return null;
417
310
  const label = activity.activity === "compaction" ? t("activityCompacting") : activity.activity === "model-reply" ? t("activityModelReply") : t("activityRequestingModel");
418
311
  return (0, react_jsx_runtime.jsxs)("span", {
419
- id: "codex-activity",
420
- role: "status",
312
+ "data-codex-activity": true,
421
313
  "aria-live": "polite",
422
314
  style: {
423
315
  display: "inline-flex",
424
316
  alignItems: "center",
425
317
  gap: 7,
426
318
  minHeight: 26,
319
+ marginLeft: 10,
427
320
  color: "var(--dsw-alias-label-secondary)",
428
321
  fontSize: 12,
429
322
  lineHeight: "20px",
430
- whiteSpace: "nowrap"
323
+ whiteSpace: "nowrap",
324
+ WebkitTextFillColor: "currentColor"
431
325
  },
432
326
  children: [
433
327
  (0, react_jsx_runtime.jsx)("span", {
@@ -445,7 +339,8 @@ window.__ModuleLoader__.load({
445
339
  (0, react_jsx_runtime.jsxs)("span", {
446
340
  style: { color: "var(--dsw-alias-label-tertiary)" },
447
341
  children: [
448
- "· ",
342
+ "·",
343
+ " ",
449
344
  elapsedSeconds(activity.startedAt, now),
450
345
  "s"
451
346
  ]
@@ -453,18 +348,69 @@ window.__ModuleLoader__.load({
453
348
  ]
454
349
  });
455
350
  }
456
- /** Preserve both legacy controls for hosts without the additive seats. */
457
- function ActivityDock(props) {
458
- return (0, react_jsx_runtime.jsxs)("div", {
459
- style: {
460
- display: "flex",
461
- alignItems: "center",
462
- gap: 8,
463
- minHeight: 28,
464
- padding: "4px 10px"
465
- },
466
- children: [(0, react_jsx_runtime.jsx)(ContextSizeDock, { ...props }), (0, react_jsx_runtime.jsx)(ActivityLine, { ...props })]
351
+ function findContextMeterDialog() {
352
+ const buttons = document.querySelectorAll("button[aria-haspopup=\"dialog\"][aria-expanded=\"true\"]");
353
+ for (const button of buttons) {
354
+ if (button.querySelectorAll("circle").length < 2) continue;
355
+ let ancestor = button;
356
+ for (let depth = 0; ancestor !== null && depth < 5; depth += 1, ancestor = ancestor.parentElement) {
357
+ const dialog = ancestor.querySelector("[role=\"dialog\"]");
358
+ if (dialog !== null) return dialog;
359
+ }
360
+ }
361
+ return null;
362
+ }
363
+ function findTurnStatus() {
364
+ for (const status of document.querySelectorAll("[role=\"status\"]")) if (status.textContent?.includes("Deep diving...") === true && status.closest("[data-chat-flow]") !== null) return status;
365
+ return null;
366
+ }
367
+ function useLegacyHostTargets() {
368
+ const [targets, setTargets] = (0, react.useState)({
369
+ contextDialog: null,
370
+ turnStatus: null
467
371
  });
372
+ (0, react.useEffect)(() => {
373
+ if (typeof document === "undefined" || document.body === null) return void 0;
374
+ const refresh = () => {
375
+ const next = {
376
+ contextDialog: findContextMeterDialog(),
377
+ turnStatus: findTurnStatus()
378
+ };
379
+ setTargets((current) => current.contextDialog === next.contextDialog && current.turnStatus === next.turnStatus ? current : next);
380
+ };
381
+ refresh();
382
+ const observer = new MutationObserver(refresh);
383
+ observer.observe(document.body, {
384
+ subtree: true,
385
+ childList: true,
386
+ attributes: true,
387
+ attributeFilter: ["aria-expanded"]
388
+ });
389
+ return () => observer.disconnect();
390
+ }, []);
391
+ return targets;
392
+ }
393
+ /** Bridges plugin UI into DOM sites rendered by the legacy conversation host. */
394
+ function LegacyOverlay(props) {
395
+ const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t } = props;
396
+ const { contextDialog, turnStatus } = useLegacyHostTargets();
397
+ const contextWindow = contextWindowFromProjection(useProjection);
398
+ if (!isCodexPresetId(useSessions((state) => state.byId[sessionId]?.agentPreset))) return null;
399
+ return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [contextDialog !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ContextSizeControl, {
400
+ contextWindow,
401
+ sessionId,
402
+ useSessions,
403
+ useSettings,
404
+ setSetting,
405
+ unsetSetting,
406
+ t
407
+ }), contextDialog, "codex-context-size"), turnStatus !== null && (0, react_dom.createPortal)((0, react_jsx_runtime.jsx)(ActivityLine, {
408
+ sessionId,
409
+ useSession,
410
+ useSessions,
411
+ useProjection,
412
+ t
413
+ }), turnStatus, "codex-activity")] });
468
414
  }
469
415
  const inject = [
470
416
  "slots",
@@ -490,30 +436,13 @@ window.__ModuleLoader__.load({
490
436
  locale: NS,
491
437
  inject: injected
492
438
  }, FastModeFallback));
493
- ctx.slots.inject(CONTEXT_SETTINGS_SLOT, () => ctx.slots.register({
494
- name: CONTEXT_SETTINGS_SLOT,
495
- id: "codex-context-size",
439
+ ctx.slots.inject(LEGACY_OVERLAY_SLOT, () => ctx.slots.register({
440
+ name: LEGACY_OVERLAY_SLOT,
441
+ id: "codex-legacy-overlay",
496
442
  order: 0,
497
443
  locale: NS,
498
444
  inject: injected
499
- }, ContextSizeControl));
500
- ctx.slots.inject(ACTIVITY_SLOT, () => ctx.slots.register({
501
- name: ACTIVITY_SLOT,
502
- id: "codex-activity",
503
- order: 0,
504
- locale: NS,
505
- inject: injected
506
- }, ActivityLine));
507
- ctx.slots.inject(ACTIVITY_FALLBACK_SLOT, () => {
508
- if (ctx.slots.spec(ACTIVITY_SLOT) !== void 0) return () => {};
509
- return ctx.slots.register({
510
- name: ACTIVITY_FALLBACK_SLOT,
511
- id: "codex-activity",
512
- order: 5,
513
- locale: NS,
514
- inject: injected
515
- }, ActivityDock);
516
- });
445
+ }, LegacyOverlay));
517
446
  }
518
447
  var client_default = {
519
448
  inject,
package/lib/index.js CHANGED
@@ -1284,7 +1284,7 @@ const CODEX_BASE_PROMPT = String.raw`## General
1284
1284
  `;
1285
1285
  const CODEX_COLLABORATION_PROMPT = String.raw`## Collaboration
1286
1286
 
1287
- - Ask, align, and clarify first. Gather enough context from the user then achieve the user's goal through the clearest, most effective path.
1287
+ - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
1288
1288
  - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
1289
1289
  - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
1290
1290
  - Solve problems by thinking from first principles and at a higher level.
@@ -2,7 +2,7 @@
2
2
  import type { HostObservable, InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
3
3
  import type { Context } from '@deepseek-ai/cordis';
4
4
  import type { SettingsScope } from '@deepseek-ai/dsh-client-runtime/client';
5
- declare const ACTIVITY_SLOT: "conversation.chat.status";
5
+ declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
6
6
  interface CodexSettings {
7
7
  fast: boolean;
8
8
  contextWindow?: number;
@@ -27,18 +27,11 @@ declare module '@deepseek-ai/dsh-client-ui-slots' {
27
27
  codex: CodexKey;
28
28
  }
29
29
  interface SlotMap {
30
- 'conversation.chat.status': {
30
+ 'conversation.input.overlay': {
31
31
  kind: 'list';
32
32
  scope: 'session';
33
33
  owner: Record<never, never>;
34
34
  };
35
- 'conversation.input.context.settings': {
36
- kind: 'list';
37
- scope: 'session';
38
- owner: {
39
- contextWindow: number;
40
- };
41
- };
42
35
  }
43
36
  }
44
37
  interface InputSettingsControlInjected {
@@ -48,10 +41,8 @@ interface InputSettingsControlInjected {
48
41
  setSetting: (field: string, value: unknown) => Promise<void>;
49
42
  unsetSetting: (field: string) => Promise<void>;
50
43
  }
51
- type ContextDockProps = PropsRuntime<'conversation.composer.dock'> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
52
- type ActivityDockProps = ContextDockProps & PropsLocale<'codex'>;
53
- type ActivityStatusProps = PropsRuntime<typeof ACTIVITY_SLOT> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
54
- type ActivityProps = ActivityStatusProps | ActivityDockProps;
44
+ type LegacyOverlayProps = PropsRuntime<typeof LEGACY_OVERLAY_SLOT> & InjectFace<InputSettingsControlInjected> & PropsLocale<'codex'>;
45
+ type ActivityProps = Pick<LegacyOverlayProps, 'sessionId' | 'useSession' | 'useSessions' | 'useProjection' | 't'>;
55
46
  export declare function ActivityLine({ sessionId, useSession, useSessions, useProjection, t }: ActivityProps): import("react").JSX.Element | null;
56
47
  export declare const inject: string[];
57
48
  /** Mount all controls through the official composer seats shared by every DSH release. */
@@ -1,14 +1,13 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /** Browser controls for the Codex request settings mounted by the Host plugin. */
3
- import { useEffect, useRef, useState } from 'react';
3
+ import { useEffect, useState } from 'react';
4
+ import { createPortal } from 'react-dom';
4
5
  import { CODEX_CONTEXT_MAX, CODEX_CONTEXT_UNIT, isCodexPresetId } from "../context.js";
5
6
  import { modelActivity, sameModelActivity } from "./activity.js";
6
7
  const NS = 'codex';
7
8
  const SETTINGS_NAMESPACE = 'codex';
8
- const ACTIVITY_SLOT = 'conversation.chat.status';
9
- const ACTIVITY_FALLBACK_SLOT = 'conversation.composer.dock';
10
- const CONTEXT_SETTINGS_SLOT = 'conversation.input.context.settings';
11
9
  const FAST_FALLBACK_SLOT = 'conversation.input.right';
10
+ const LEGACY_OVERLAY_SLOT = 'conversation.input.overlay';
12
11
  const DEFAULT_CONTEXT_WINDOW = 262_144;
13
12
  const en = {
14
13
  fast: 'Fast mode',
@@ -27,14 +26,14 @@ const zh = {
27
26
  fast: 'Fast',
28
27
  fastOn: 'Fast mode on (priority tier)',
29
28
  fastOff: 'Fast mode off',
30
- fastStateOn: '开',
31
- fastStateOff: '关',
32
- contextSize: '上下文大小',
33
- contextSizeDescription: '设置下次请求的上下文容量,单位为 K tokens。',
34
- contextRestore: '恢复模型默认值',
35
- activityCompacting: '正在压缩上下文...',
36
- activityRequestingModel: '请求中...',
37
- activityModelReply: '回复中...',
29
+ fastStateOn: '\u5f00',
30
+ fastStateOff: '\u5173',
31
+ contextSize: '\u4e0a\u4e0b\u6587\u5927\u5c0f',
32
+ contextSizeDescription: '\u8bbe\u7f6e\u4e0b\u6b21\u8bf7\u6c42\u7684\u4e0a\u4e0b\u6587\u5bb9\u91cf\uff0c\u5355\u4f4d\u4e3a K tokens\u3002',
33
+ contextRestore: '\u6062\u590d\u6a21\u578b\u9ed8\u8ba4\u503c',
34
+ activityCompacting: '\u6b63\u5728\u538b\u7f29\u4e0a\u4e0b\u6587...',
35
+ activityRequestingModel: '\u8bf7\u6c42\u4e2d...',
36
+ activityModelReply: '\u56de\u590d\u4e2d...',
38
37
  };
39
38
  /** The legacy composer seat is a compact inline row, not a menu panel. */
40
39
  function FastModeFallback(props) {
@@ -69,7 +68,7 @@ function contextWindowFromProjection(useProjection) {
69
68
  ? pressure.contextWindow
70
69
  : DEFAULT_CONTEXT_WINDOW;
71
70
  }
72
- /** Settings form rendered inside the context meter's expanded panel. */
71
+ /** Settings form appended to the old host's context meter panel. */
73
72
  function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings, setSetting, unsetSetting, t, }) {
74
73
  const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
75
74
  const snapshot = useSettings(state => state);
@@ -88,7 +87,13 @@ function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings
88
87
  else
89
88
  void setSetting('contextWindow', normalized);
90
89
  };
91
- return (_jsxs("div", { style: { marginTop: 0, display: 'grid', gap: 8 }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [_jsx("strong", { style: { color: 'var(--dsw-alias-label-primary)', fontSize: 13 }, children: t('contextSize') }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 12, fontVariantNumeric: 'tabular-nums' }, children: [valueK, "K"] })] }), _jsx("input", { type: "range", min: 1, max: maxK, step: 1, value: valueK, disabled: snapshot.writable === false, "aria-label": t('contextSize'), onChange: event => { setValueK(Number(event.target.value)); }, style: {
90
+ return (_jsxs("div", { style: {
91
+ display: 'grid',
92
+ gap: 8,
93
+ marginTop: 10,
94
+ paddingTop: 10,
95
+ borderTop: '1px solid var(--dsw-alias-border-l2)',
96
+ }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'baseline', justifyContent: 'space-between', gap: 12 }, children: [_jsx("strong", { style: { color: 'var(--dsw-alias-label-primary)', fontSize: 13 }, children: t('contextSize') }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 12, fontVariantNumeric: 'tabular-nums' }, children: [valueK, "K"] })] }), _jsx("input", { type: "range", min: 1, max: maxK, step: 1, value: valueK, disabled: snapshot.writable === false, "aria-label": t('contextSize'), onChange: event => { setValueK(Number(event.target.value)); }, style: {
92
97
  display: 'block',
93
98
  width: '100%',
94
99
  accentColor: 'var(--dsw-static-blue-500)',
@@ -113,71 +118,6 @@ function ContextSizeControl({ contextWindow, sessionId, useSessions, useSettings
113
118
  fontSize: 11,
114
119
  }, children: t('contextRestore') }))] }));
115
120
  }
116
- /** Compact context-capacity trigger shown beside the bottom activity line. */
117
- function ContextSizeDock({ sessionId, useSessions, useProjection, useSettings, setSetting, unsetSetting, t }) {
118
- const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
119
- const contextWindow = contextWindowFromProjection(useProjection);
120
- const snapshot = useSettings(state => state);
121
- const configured = snapshot.value?.contextWindow;
122
- const valueK = Math.min(CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
123
- const [open, setOpen] = useState(false);
124
- const rootRef = useRef(null);
125
- useEffect(() => {
126
- if (!open)
127
- return undefined;
128
- const onPointerDown = (event) => {
129
- if (event.target instanceof Node && rootRef.current?.contains(event.target) === true)
130
- return;
131
- setOpen(false);
132
- };
133
- const onKeyDown = (event) => {
134
- if (event.key === 'Escape')
135
- setOpen(false);
136
- };
137
- document.addEventListener('pointerdown', onPointerDown);
138
- document.addEventListener('keydown', onKeyDown);
139
- return () => {
140
- document.removeEventListener('pointerdown', onPointerDown);
141
- document.removeEventListener('keydown', onKeyDown);
142
- };
143
- }, [open]);
144
- if (!isCodexPresetId(agentPreset))
145
- return null;
146
- return (_jsxs("span", { ref: rootRef, style: { position: 'relative', display: 'inline-flex', alignItems: 'center' }, children: [_jsxs("button", { type: "button", "aria-label": `${t('contextSize')}: ${valueK}K`, "aria-haspopup": "dialog", "aria-expanded": open, disabled: snapshot.writable === false, title: t('contextSize'), onMouseDown: event => { event.preventDefault(); }, onClick: () => { setOpen(value => !value); }, style: {
147
- boxSizing: 'border-box',
148
- display: 'inline-flex',
149
- alignItems: 'center',
150
- gap: 3,
151
- height: 28,
152
- border: 0,
153
- borderRadius: 7,
154
- padding: '0 6px',
155
- color: configured === undefined
156
- ? 'var(--dsw-alias-label-secondary)'
157
- : 'var(--dsw-static-blue-500)',
158
- background: open ? 'var(--dsw-alias-interactive-bg-hover)' : 'transparent',
159
- cursor: snapshot.writable === false ? 'default' : 'pointer',
160
- font: 'inherit',
161
- fontSize: 12,
162
- lineHeight: '20px',
163
- fontWeight: configured === undefined ? 400 : 600,
164
- whiteSpace: 'nowrap',
165
- }, children: [_jsxs("span", { children: [valueK, "K"] }), _jsx("svg", { viewBox: "0 0 12 12", width: "12", height: "12", "aria-hidden": true, children: _jsx("path", { d: "M3 4.5 6 7.5 9 4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.25", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), open && (_jsx("div", { role: "dialog", "aria-label": t('contextSize'), style: {
166
- position: 'absolute',
167
- right: 0,
168
- bottom: 'calc(100% + 8px)',
169
- zIndex: 20,
170
- boxSizing: 'border-box',
171
- width: 300,
172
- maxWidth: 'calc(100vw - 24px)',
173
- padding: '10px 12px 12px',
174
- border: '1px solid var(--dsw-alias-border-l2)',
175
- borderRadius: 10,
176
- color: 'var(--dsw-alias-label-primary)',
177
- background: 'var(--dsw-alias-bg-base)',
178
- boxShadow: 'var(--dsw-shadow-lv2)',
179
- }, children: _jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }) }))] }));
180
- }
181
121
  function elapsedSeconds(startedAt, now) {
182
122
  return Math.max(0, Math.floor((now - startedAt) / 1_000));
183
123
  }
@@ -216,15 +156,17 @@ export function ActivityLine({ sessionId, useSession, useSessions, useProjection
216
156
  : activity.activity === 'model-reply'
217
157
  ? t('activityModelReply')
218
158
  : t('activityRequestingModel');
219
- return (_jsxs("span", { id: "codex-activity", role: "status", "aria-live": "polite", style: {
159
+ return (_jsxs("span", { "data-codex-activity": true, "aria-live": "polite", style: {
220
160
  display: 'inline-flex',
221
161
  alignItems: 'center',
222
162
  gap: 7,
223
163
  minHeight: 26,
164
+ marginLeft: 10,
224
165
  color: 'var(--dsw-alias-label-secondary)',
225
166
  fontSize: 12,
226
167
  lineHeight: '20px',
227
168
  whiteSpace: 'nowrap',
169
+ WebkitTextFillColor: 'currentColor',
228
170
  }, children: [_jsx("span", { "aria-hidden": "true", style: {
229
171
  width: 5,
230
172
  height: 5,
@@ -232,17 +174,64 @@ export function ActivityLine({ sessionId, useSession, useSessions, useProjection
232
174
  borderRadius: '50%',
233
175
  background: 'var(--dsw-static-blue-500)',
234
176
  opacity: 0.55,
235
- } }), _jsx("span", { children: label }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-tertiary)' }, children: ["\u00B7 ", elapsedSeconds(activity.startedAt, now), "s"] })] }));
177
+ } }), _jsx("span", { children: label }), _jsxs("span", { style: { color: 'var(--dsw-alias-label-tertiary)' }, children: ['\u00b7', " ", elapsedSeconds(activity.startedAt, now), "s"] })] }));
236
178
  }
237
- /** Preserve both legacy controls for hosts without the additive seats. */
238
- function ActivityDock(props) {
239
- return (_jsxs("div", { style: {
240
- display: 'flex',
241
- alignItems: 'center',
242
- gap: 8,
243
- minHeight: 28,
244
- padding: '4px 10px',
245
- }, children: [_jsx(ContextSizeDock, { ...props }), _jsx(ActivityLine, { ...props })] }));
179
+ function findContextMeterDialog() {
180
+ const buttons = document.querySelectorAll('button[aria-haspopup="dialog"][aria-expanded="true"]');
181
+ for (const button of buttons) {
182
+ if (button.querySelectorAll('circle').length < 2)
183
+ continue;
184
+ let ancestor = button;
185
+ for (let depth = 0; ancestor !== null && depth < 5; depth += 1, ancestor = ancestor.parentElement) {
186
+ const dialog = ancestor.querySelector('[role="dialog"]');
187
+ if (dialog !== null)
188
+ return dialog;
189
+ }
190
+ }
191
+ return null;
192
+ }
193
+ function findTurnStatus() {
194
+ for (const status of document.querySelectorAll('[role="status"]')) {
195
+ if (status.textContent?.includes('Deep diving...') === true
196
+ && status.closest('[data-chat-flow]') !== null)
197
+ return status;
198
+ }
199
+ return null;
200
+ }
201
+ function useLegacyHostTargets() {
202
+ const [targets, setTargets] = useState({ contextDialog: null, turnStatus: null });
203
+ useEffect(() => {
204
+ if (typeof document === 'undefined' || document.body === null)
205
+ return undefined;
206
+ const refresh = () => {
207
+ const next = {
208
+ contextDialog: findContextMeterDialog(),
209
+ turnStatus: findTurnStatus(),
210
+ };
211
+ setTargets(current => current.contextDialog === next.contextDialog
212
+ && current.turnStatus === next.turnStatus ? current : next);
213
+ };
214
+ refresh();
215
+ const observer = new MutationObserver(refresh);
216
+ observer.observe(document.body, {
217
+ subtree: true,
218
+ childList: true,
219
+ attributes: true,
220
+ attributeFilter: ['aria-expanded'],
221
+ });
222
+ return () => observer.disconnect();
223
+ }, []);
224
+ return targets;
225
+ }
226
+ /** Bridges plugin UI into DOM sites rendered by the legacy conversation host. */
227
+ function LegacyOverlay(props) {
228
+ const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t, } = props;
229
+ const { contextDialog, turnStatus } = useLegacyHostTargets();
230
+ const contextWindow = contextWindowFromProjection(useProjection);
231
+ const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
232
+ if (!isCodexPresetId(agentPreset))
233
+ return null;
234
+ return (_jsxs(_Fragment, { children: [contextDialog !== null && createPortal(_jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }), contextDialog, 'codex-context-size'), turnStatus !== null && createPortal(_jsx(ActivityLine, { sessionId: sessionId, useSession: useSession, useSessions: useSessions, useProjection: useProjection, t: t }), turnStatus, 'codex-activity')] }));
246
235
  }
247
236
  export const inject = ['slots', 'locale', 'settingsScope'];
248
237
  /** Mount all controls through the official composer seats shared by every DSH release. */
@@ -261,31 +250,13 @@ export function apply(ctx) {
261
250
  locale: NS,
262
251
  inject: injected,
263
252
  }, FastModeFallback));
264
- ctx.slots.inject(CONTEXT_SETTINGS_SLOT, () => ctx.slots.register({
265
- name: CONTEXT_SETTINGS_SLOT,
266
- id: 'codex-context-size',
253
+ ctx.slots.inject(LEGACY_OVERLAY_SLOT, () => ctx.slots.register({
254
+ name: LEGACY_OVERLAY_SLOT,
255
+ id: 'codex-legacy-overlay',
267
256
  order: 0,
268
257
  locale: NS,
269
258
  inject: injected,
270
- }, ContextSizeControl));
271
- ctx.slots.inject(ACTIVITY_SLOT, () => ctx.slots.register({
272
- name: ACTIVITY_SLOT,
273
- id: 'codex-activity',
274
- order: 0,
275
- locale: NS,
276
- inject: injected,
277
- }, ActivityLine));
278
- ctx.slots.inject(ACTIVITY_FALLBACK_SLOT, () => {
279
- if (ctx.slots.spec(ACTIVITY_SLOT) !== undefined)
280
- return () => { };
281
- return ctx.slots.register({
282
- name: ACTIVITY_FALLBACK_SLOT,
283
- id: 'codex-activity',
284
- order: 5,
285
- locale: NS,
286
- inject: injected,
287
- }, ActivityDock);
288
- });
259
+ }, LegacyOverlay));
289
260
  }
290
261
  export default { inject, apply };
291
262
  //# sourceMappingURL=index.js.map
@@ -26,7 +26,7 @@ export interface Config {
26
26
  /** Runtime configuration schema for the Codex tool bridge. */
27
27
  export declare const Config: z<Config>;
28
28
  /** Live Codex-only request controls shared by the Web controls and agent layer. */
29
- export declare const CODEX_SETTINGS_NAMESPACE: import("@deepseek-ai/dsh-settings").SettingsNamespace;
29
+ export declare const CODEX_SETTINGS_NAMESPACE: Branded<"SettingsNamespace">;
30
30
  export interface CodexSettings {
31
31
  /** Use the Responses priority service tier for GPT requests. */
32
32
  fast: boolean;
@@ -227,7 +227,7 @@ const CODEX_BASE_PROMPT = String.raw `## General
227
227
  `;
228
228
  const CODEX_COLLABORATION_PROMPT = String.raw `## Collaboration
229
229
 
230
- - Ask, align, and clarify first. Gather enough context from the user then achieve the user's goal through the clearest, most effective path.
230
+ - Ask, align, and clarify first. Gather enough context from the user, then align the approach to achieve the user's goal through the clearest, most effective path.
231
231
  - Keep only the essential logic and core actions. There's no need to explain or test what was removed or why something wasn't done.
232
232
  - Convey enough valuable information with as few words as possible. Stay focused on the end goal.
233
233
  - Solve problems by thinking from first principles and at a higher level.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
4
4
  "description": "A Codex harness with a streamlined system prompt for GPT models that do not fit DSH's native interface, while remaining compatible with the DSH plugin ecosystem.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -45,6 +45,13 @@
45
45
  "README.zh.md",
46
46
  "LICENSE"
47
47
  ],
48
+ "scripts": {
49
+ "build": "tsc --noCheck -p tsconfig.json && tsdown",
50
+ "check": "tsc -p tsconfig.json --noEmit",
51
+ "test": "vitest run",
52
+ "pack:check": "npm pack --dry-run",
53
+ "prepare": "npm run build"
54
+ },
48
55
  "repository": {
49
56
  "type": "git",
50
57
  "url": "git+https://github.com/shuind/dsh-codex-harness.git"
@@ -225,16 +232,12 @@
225
232
  "@deepseek-ai/dsh-tools": "0.1.0-rc.6",
226
233
  "@types/node": "^22.20.0",
227
234
  "@types/react": "~18.3.1",
235
+ "@types/react-dom": "~18.3.0",
228
236
  "react": "^18.3.1",
237
+ "react-dom": "^18.3.1",
229
238
  "tsdown": "^0.22.2",
230
239
  "typescript": "^6.0.3",
231
240
  "unrun": "^0.3.1",
232
241
  "vitest": "^4.1.8"
233
- },
234
- "scripts": {
235
- "build": "tsc --noCheck -p tsconfig.json && tsdown",
236
- "check": "tsc -p tsconfig.json --noEmit",
237
- "test": "vitest run",
238
- "pack:check": "npm pack --dry-run"
239
242
  }
240
- }
243
+ }