@shuind/dsh-codex-harness 0.2.5 → 0.2.6

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
@@ -141,6 +141,12 @@ window.__ModuleLoader__.load({
141
141
  otherCapabilitiesLabel: "Additional capabilities",
142
142
  capabilityPrompt: "Codex operating prompt",
143
143
  capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout.",
144
+ capabilityFast: "Fast mode control",
145
+ capabilityFastHint: "Show the Fast mode switch beside the conversation composer.",
146
+ compactRemote: "Remote compaction",
147
+ compactRemoteHint: "Use the provider remote compaction endpoint first.",
148
+ compactLocal: "Local compaction",
149
+ compactLocalHint: "Use the DSH text-summary compaction engine directly.",
144
150
  capabilityTerminal: "Terminal tools",
145
151
  capabilityTerminalHint: "Expose exec_command and write_stdin.",
146
152
  capabilityPatch: "Patch tool",
@@ -190,6 +196,12 @@ window.__ModuleLoader__.load({
190
196
  otherCapabilitiesLabel: "其他能力",
191
197
  capabilityPrompt: "Codex 操作提示词",
192
198
  capabilityPromptHint: "注入可编辑指令,并将 Persona 放在提示词首位。",
199
+ capabilityFast: "显示 Fast 模式",
200
+ capabilityFastHint: "在对话输入区旁显示 Fast 开关。",
201
+ compactRemote: "远程压缩",
202
+ compactRemoteHint: "优先使用提供商的远程压缩端点。",
203
+ compactLocal: "本地压缩",
204
+ compactLocalHint: "直接使用 DSH 文本摘要压缩引擎。",
193
205
  capabilityTerminal: "终端工具",
194
206
  capabilityTerminalHint: "提供 exec_command 和 write_stdin。",
195
207
  capabilityPatch: "补丁工具",
@@ -276,38 +288,65 @@ window.__ModuleLoader__.load({
276
288
  });
277
289
  }
278
290
  /** Visually separate capability scope while keeping the host's light settings style. */
279
- function CapabilityGroup({ label, children, accent }) {
291
+ function CapabilityGroup({ id, label, children, accent }) {
292
+ const [open, setOpen] = (0, react.useState)(false);
293
+ const panelId = `${id}-panel`;
280
294
  return (0, react_jsx_runtime.jsxs)("section", {
281
295
  style: {
282
296
  display: "grid",
283
- gap: 4
297
+ gap: open ? 4 : 0
284
298
  },
285
- children: [(0, react_jsx_runtime.jsxs)("div", {
299
+ children: [(0, react_jsx_runtime.jsxs)("button", {
300
+ type: "button",
301
+ "aria-expanded": open,
302
+ "aria-controls": panelId,
303
+ onClick: () => {
304
+ setOpen(!open);
305
+ },
286
306
  style: {
287
307
  display: "flex",
288
308
  alignItems: "center",
289
309
  gap: 7,
290
- paddingLeft: 2
310
+ width: "100%",
311
+ padding: 0,
312
+ border: 0,
313
+ background: "none",
314
+ color: "var(--dsw-alias-label-secondary)",
315
+ font: "inherit",
316
+ textAlign: "left",
317
+ cursor: "pointer"
291
318
  },
292
- children: [(0, react_jsx_runtime.jsx)("span", {
293
- "aria-hidden": "true",
294
- style: {
295
- width: 6,
296
- height: 6,
297
- flex: "0 0 auto",
298
- borderRadius: 999,
299
- background: accent
300
- }
301
- }), (0, react_jsx_runtime.jsx)("strong", {
302
- style: {
303
- color: "var(--dsw-alias-label-secondary)",
304
- fontSize: 14,
305
- fontWeight: 600,
306
- letterSpacing: "0.01em"
307
- },
308
- children: label
309
- })]
310
- }), (0, react_jsx_runtime.jsx)("div", {
319
+ children: [
320
+ (0, react_jsx_runtime.jsx)("span", {
321
+ "aria-hidden": "true",
322
+ style: {
323
+ width: 6,
324
+ height: 6,
325
+ flex: "0 0 auto",
326
+ borderRadius: 999,
327
+ background: accent
328
+ }
329
+ }),
330
+ (0, react_jsx_runtime.jsx)("strong", {
331
+ style: {
332
+ color: "var(--dsw-alias-label-secondary)",
333
+ fontSize: 14,
334
+ fontWeight: 600,
335
+ letterSpacing: "0.01em"
336
+ },
337
+ children: label
338
+ }),
339
+ (0, react_jsx_runtime.jsx)("span", {
340
+ "aria-hidden": "true",
341
+ style: {
342
+ color: "var(--dsw-alias-label-tertiary)",
343
+ fontSize: 16
344
+ },
345
+ children: open ? "-" : "+"
346
+ })
347
+ ]
348
+ }), open && (0, react_jsx_runtime.jsx)("div", {
349
+ id: panelId,
311
350
  style: {
312
351
  display: "grid",
313
352
  marginLeft: 5,
@@ -318,22 +357,57 @@ window.__ModuleLoader__.load({
318
357
  });
319
358
  }
320
359
  function PromptEditor({ id, label, hint, value, writable, saving, minHeight, onChange }) {
360
+ const [open, setOpen] = (0, react.useState)(false);
361
+ const labelId = `${id}-label`;
362
+ const panelId = `${id}-panel`;
321
363
  return (0, react_jsx_runtime.jsxs)("div", {
322
364
  style: {
323
365
  display: "grid",
324
- gap: 5
366
+ gap: open ? 8 : 0
325
367
  },
326
- children: [
327
- (0, react_jsx_runtime.jsx)("label", {
328
- htmlFor: id,
368
+ children: [(0, react_jsx_runtime.jsxs)("button", {
369
+ type: "button",
370
+ "aria-expanded": open,
371
+ "aria-controls": panelId,
372
+ onClick: () => {
373
+ setOpen(!open);
374
+ },
375
+ style: {
376
+ display: "flex",
377
+ alignItems: "center",
378
+ gap: 8,
379
+ width: "100%",
380
+ padding: 0,
381
+ border: 0,
382
+ background: "none",
383
+ color: "var(--dsw-alias-label-primary)",
384
+ font: "inherit",
385
+ fontSize: 13,
386
+ fontWeight: 500,
387
+ textAlign: "left",
388
+ cursor: "pointer"
389
+ },
390
+ children: [(0, react_jsx_runtime.jsx)("span", {
391
+ id: labelId,
392
+ style: { flex: 1 },
393
+ children: label
394
+ }), (0, react_jsx_runtime.jsx)("span", {
395
+ "aria-hidden": "true",
329
396
  style: {
330
- fontSize: 13,
331
- fontWeight: 500
397
+ color: "var(--dsw-alias-label-tertiary)",
398
+ fontSize: 16
332
399
  },
333
- children: label
334
- }),
335
- (0, react_jsx_runtime.jsx)("textarea", {
400
+ children: open ? "-" : "+"
401
+ })]
402
+ }), open && (0, react_jsx_runtime.jsxs)("div", {
403
+ id: panelId,
404
+ style: {
405
+ display: "grid",
406
+ gap: 5
407
+ },
408
+ children: [(0, react_jsx_runtime.jsx)("textarea", {
336
409
  id,
410
+ "aria-labelledby": labelId,
337
411
  value,
338
412
  disabled: !writable || saving,
339
413
  onChange: (event) => {
@@ -354,16 +428,15 @@ window.__ModuleLoader__.load({
354
428
  fontSize: 12,
355
429
  lineHeight: 1.5
356
430
  }
357
- }),
358
- (0, react_jsx_runtime.jsx)("span", {
431
+ }), (0, react_jsx_runtime.jsx)("span", {
359
432
  style: {
360
433
  color: "var(--dsw-alias-label-tertiary)",
361
434
  fontSize: 11,
362
435
  lineHeight: 1.45
363
436
  },
364
437
  children: hint
365
- })
366
- ]
438
+ })]
439
+ })]
367
440
  });
368
441
  }
369
442
  /** Full-prompt editor contributed to Settings > Plugins. */
@@ -376,6 +449,11 @@ window.__ModuleLoader__.load({
376
449
  const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
377
450
  const inherited = promptFromLayer(snapshot.base) ?? DEFAULT_CODEX_SYSTEM_PROMPT;
378
451
  const codexOnlyCapabilities = [
452
+ {
453
+ field: "fastModeControlEnabled",
454
+ label: "capabilityFast",
455
+ hint: "capabilityFastHint"
456
+ },
379
457
  {
380
458
  field: "promptEnabled",
381
459
  label: "capabilityPrompt",
@@ -573,10 +651,12 @@ window.__ModuleLoader__.load({
573
651
  marginBottom: 14
574
652
  },
575
653
  children: [(0, react_jsx_runtime.jsx)(CapabilityGroup, {
654
+ id: "codex-only-capabilities",
576
655
  label: t("codexOnlyCapabilitiesLabel"),
577
656
  accent: "var(--dsw-static-blue-500)",
578
657
  children: codexOnlyCapabilities.map(renderCapability)
579
658
  }), (0, react_jsx_runtime.jsx)(CapabilityGroup, {
659
+ id: "other-capabilities",
580
660
  label: t("otherCapabilitiesLabel"),
581
661
  accent: "var(--dsw-alias-label-tertiary)",
582
662
  children: otherCapabilities.map(renderCapability)
@@ -726,7 +806,9 @@ window.__ModuleLoader__.load({
726
806
  function FastModeFallback(props) {
727
807
  const { useSettings, setSetting, t } = props;
728
808
  const snapshot = useSettings((state) => state);
809
+ const visible = snapshot.value?.fastModeControlEnabled ?? true;
729
810
  const fast = snapshot.value?.fast ?? false;
811
+ if (!visible) return null;
730
812
  return (0, react_jsx_runtime.jsxs)("button", {
731
813
  type: "button",
732
814
  role: "switch",
@@ -1081,6 +1163,8 @@ window.__ModuleLoader__.load({
1081
1163
  }), document.body, "codex-activity")] });
1082
1164
  }
1083
1165
  const inject = [
1166
+ "commandUi",
1167
+ "sessions",
1084
1168
  "slots",
1085
1169
  "locale",
1086
1170
  "settingsScope"
@@ -1091,6 +1175,33 @@ window.__ModuleLoader__.load({
1091
1175
  en,
1092
1176
  zh
1093
1177
  }), "codex client: dictionaries");
1178
+ const commandUi = ctx.get("commandUi");
1179
+ const sessions = ctx.get("sessions");
1180
+ const t = ctx.locale.bind(NS);
1181
+ const sessionFor = (session) => sessions.binding(session.sessionId)?.session;
1182
+ ctx.effect(() => commandUi.decorate({
1183
+ name: "compact",
1184
+ available: (session) => sessionFor(session) !== void 0,
1185
+ ui: {
1186
+ kind: "popupSelect",
1187
+ options: async () => [{
1188
+ id: "remote",
1189
+ label: t("compactRemote"),
1190
+ detail: t("compactRemoteHint")
1191
+ }, {
1192
+ id: "local",
1193
+ label: t("compactLocal"),
1194
+ detail: t("compactLocalHint")
1195
+ }],
1196
+ onSelect: async (option, session) => {
1197
+ const live = sessionFor(session);
1198
+ if (live === void 0) throw new Error("this session is not materialized yet");
1199
+ const result = await live.command(`/compact ${option.id}`);
1200
+ if (!result.ok) throw new Error(`compact mode switch failed: ${result.error.code}: ${result.error.message}`);
1201
+ if (!result.value.matched) throw new Error("the host offers no /compact command");
1202
+ }
1203
+ }
1204
+ }), "codex client: /compact mode picker");
1094
1205
  const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
1095
1206
  const injected = () => ({
1096
1207
  hooks: { settings },
package/lib/compaction.js CHANGED
@@ -3,6 +3,15 @@ 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();
7
+ /** Run one manual compaction with an explicit local/remote preference. */
8
+ function runCodexCompactionMode(mode, task) {
9
+ return COMPACTION_MODE.run(mode, task);
10
+ }
11
+ /** Read the explicit preference for the current compaction stream, if any. */
12
+ function codexCompactionMode() {
13
+ return COMPACTION_MODE.getStore();
14
+ }
6
15
  const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
7
16
  /** Codex context overrides apply only to GPT-compatible model routes. */
8
17
  function isGptModel(model) {
@@ -83,4 +92,4 @@ var CodexCompactionEngine = class extends BasicCompactionEngine {
83
92
  }
84
93
  };
85
94
  //#endregion
86
- export { CodexCompactionEngine as default };
95
+ export { codexCompactionMode, CodexCompactionEngine as default, runCodexCompactionMode };
package/lib/index.js CHANGED
@@ -9,6 +9,7 @@ import { mkdirSync, writeFileSync } from "node:fs";
9
9
  import { homedir } from "node:os";
10
10
  import { isTokenDelta } from "@deepseek-ai/dsh-llm/message";
11
11
  import { z as z$1 } from "zod";
12
+ import BasicCompactionEngine from "@deepseek-ai/dsh-compaction-basic";
12
13
  //#region lib/types/patch.js
13
14
  /** Parser and line-oriented applicator for Codex's `apply_patch` language. */
14
15
  const APPLY_PATCH_DESCRIPTION = "Edits files using Codex patch syntax with Begin/End Patch markers and file update directives. In hunk lines, the first character is the operation marker; repeat a source-leading marker when the source line itself starts with one.";
@@ -535,7 +536,7 @@ function serviceTierOf(options) {
535
536
  const value = options.serviceTier;
536
537
  return typeof value === "string" ? value : void 0;
537
538
  }
538
- function isGptModel$1(model) {
539
+ function isGptModel$2(model) {
539
540
  return typeof model === "string" && /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
540
541
  }
541
542
  function settingsOf(ctx) {
@@ -813,11 +814,11 @@ function hasRemoteCompaction(body) {
813
814
  });
814
815
  }
815
816
  function canPatchBody(body, options) {
816
- return isGptModel$1(body.model) && (options.hostedWebSearch !== false && hasWebSearchTool(body) || hasRemoteCompaction(body) || options.customApplyPatch !== false && hasFunctionApplyPatchTool(body) && canRewriteApplyPatchHistory(body));
817
+ return isGptModel$2(body.model) && (options.hostedWebSearch !== false && hasWebSearchTool(body) || hasRemoteCompaction(body) || options.customApplyPatch !== false && hasFunctionApplyPatchTool(body) && canRewriteApplyPatchHistory(body));
817
818
  }
818
819
  /** Add provider options that older pi-ai adapters do not copy themselves. */
819
820
  function applyRequestWireOptions(body, options) {
820
- if (options.serviceTier === void 0 || !isGptModel$1(body.model)) return body;
821
+ if (options.serviceTier === void 0 || !isGptModel$2(body.model)) return body;
821
822
  return {
822
823
  ...body,
823
824
  service_tier: options.serviceTier
@@ -1240,6 +1241,7 @@ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
1240
1241
  /** Default settings exposed even before a Codex session is opened. */
1241
1242
  const CODEX_SETTINGS_ENTRY = {
1242
1243
  fast: false,
1244
+ fastModeControlEnabled: true,
1243
1245
  persona: DEFAULT_CODEX_PERSONA,
1244
1246
  harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
1245
1247
  webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
@@ -1254,6 +1256,7 @@ const CODEX_SETTINGS_ENTRY = {
1254
1256
  };
1255
1257
  const CODEX_SETTINGS_SCHEMA = z.object({
1256
1258
  fast: z.boolean().default(false),
1259
+ fastModeControlEnabled: z.boolean().default(true),
1257
1260
  contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
1258
1261
  persona: z.string().default(DEFAULT_CODEX_PERSONA),
1259
1262
  harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
@@ -1268,6 +1271,88 @@ const CODEX_SETTINGS_SCHEMA = z.object({
1268
1271
  activityIndicatorEnabled: z.boolean().default(true)
1269
1272
  });
1270
1273
  //#endregion
1274
+ //#region lib/types/compaction.js
1275
+ /** Codex compaction backend that honors the latest durable request capacity. */
1276
+ const COMPACTION_MODE = new AsyncLocalStorage();
1277
+ /** Read the explicit preference for the current compaction stream, if any. */
1278
+ function codexCompactionMode() {
1279
+ return COMPACTION_MODE.getStore();
1280
+ }
1281
+ const CODEX_SETTINGS_NAMESPACE$1 = settingsNamespace("codex");
1282
+ /** Codex context overrides apply only to GPT-compatible model routes. */
1283
+ function isGptModel$1(model) {
1284
+ return /(?:^|\/)(?:gpt|chatgpt)(?:[-_.]|\d|$)/i.test(model);
1285
+ }
1286
+ /** Read the live Codex capacity without requiring a custom LLM service API. */
1287
+ function configuredContextWindow(ctx) {
1288
+ const settings = ctx.get("settings");
1289
+ if (settings?.get === void 0) return { available: false };
1290
+ const value = settings?.get?.(CODEX_SETTINGS_NAMESPACE$1);
1291
+ return {
1292
+ available: true,
1293
+ ...value?.contextWindow !== void 0 && Number.isSafeInteger(value.contextWindow) && value.contextWindow > 0 ? { value: value.contextWindow } : {}
1294
+ };
1295
+ }
1296
+ /** Read an explicit capacity persisted in the request header when settings are unavailable. */
1297
+ function requestContextWindow(session, provider, model) {
1298
+ const config = session.requestHeader()?.config;
1299
+ if (config?.provider !== provider || config.model !== model) return void 0;
1300
+ const value = config.contextWindow;
1301
+ return typeof value === "number" && Number.isSafeInteger(value) && value > 0 ? value : void 0;
1302
+ }
1303
+ /** Resolve the capacity currently in force for an active Codex compaction. */
1304
+ function activeContextWindow(ctx, activeSession, provider, model) {
1305
+ const session = activeSession.getStore();
1306
+ const requestContext = session?.requestContext();
1307
+ const configured = isGptModel$1(model) ? configuredContextWindow(ctx) : { available: false };
1308
+ return configured.available ? configured.value : (session === void 0 ? void 0 : requestContextWindow(session, provider, model)) ?? (requestContext?.provider === provider && requestContext.model === model ? requestContext.contextWindow : void 0);
1309
+ }
1310
+ /** Overlay capacity lookup and auxiliary summary requests for compaction. */
1311
+ function withDurableContextCapacity(llm, ctx, activeSession) {
1312
+ return new Proxy(llm, { get(target, property) {
1313
+ if (property === "resolveModelInfo") return async (provider, model, signal) => {
1314
+ const info = await target.resolveModelInfo(provider, model, signal);
1315
+ const contextWindow = activeContextWindow(ctx, activeSession, provider, model);
1316
+ if (contextWindow === void 0) return info;
1317
+ return {
1318
+ ...info,
1319
+ context: {
1320
+ ...info.context,
1321
+ contextWindow
1322
+ }
1323
+ };
1324
+ };
1325
+ if (property === "stream") return (options) => {
1326
+ const contextWindow = activeContextWindow(ctx, activeSession, options.provider, options.model);
1327
+ if (contextWindow === void 0 || options.contextWindow === contextWindow) return target.stream(options);
1328
+ return target.stream({
1329
+ ...options,
1330
+ contextWindow
1331
+ });
1332
+ };
1333
+ const value = Reflect.get(target, property, target);
1334
+ return typeof value === "function" ? value.bind(target) : value;
1335
+ } });
1336
+ }
1337
+ (class extends BasicCompactionEngine {
1338
+ static inject = BasicCompactionEngine.inject;
1339
+ static Config = BasicCompactionEngine.Config;
1340
+ activeSession;
1341
+ constructor(ctx, config = {}) {
1342
+ const activeSession = new AsyncLocalStorage();
1343
+ const llm = ctx.get("llm");
1344
+ if (llm === void 0) throw new Error("codex compaction requires ctx.llm");
1345
+ super(ctx.extend({ llm: withDurableContextCapacity(llm, ctx, activeSession) }), config);
1346
+ this.activeSession = activeSession;
1347
+ }
1348
+ compactIfNeeded(agent, trigger, signal) {
1349
+ return this.activeSession.run(agent.session, () => super.compactIfNeeded(agent, trigger, signal));
1350
+ }
1351
+ compactNow(agent, signal, sourceCommandId) {
1352
+ return this.activeSession.run(agent.session, () => super.compactNow(agent, signal, sourceCommandId));
1353
+ }
1354
+ });
1355
+ //#endregion
1271
1356
  //#region lib/types/index.js
1272
1357
  /** Codex-compatible prompt overlay and core tools for a dsh agent preset. */
1273
1358
  const name = "codex";
@@ -1507,15 +1592,21 @@ function interpolateCodexPrompt(text, variables) {
1507
1592
  }
1508
1593
  /** Apply user-editable Persona and DSH Core runtime prompt templates. */
1509
1594
  function applyCodexPromptOverrides(assembly, settings) {
1510
- const variables = promptVariables(assembly);
1511
1595
  const overrides = {
1512
1596
  "deployment:persona": settings.persona,
1513
1597
  "harness:source": settings.harnessSourcePrompt,
1514
1598
  "app:web-surface": settings.webSurfacePrompt
1515
1599
  };
1600
+ const defaults = {
1601
+ "deployment:persona": DEFAULT_CODEX_PERSONA,
1602
+ "harness:source": DEFAULT_DSH_CORE_SOURCE_PROMPT,
1603
+ "app:web-surface": DEFAULT_DSH_CORE_WEB_PROMPT
1604
+ };
1605
+ if (!Object.entries(overrides).some(([name, text]) => text !== void 0 && text !== defaults[name])) return assembly;
1606
+ const variables = promptVariables(assembly);
1516
1607
  const sections = assembly.sections.map((section) => {
1517
1608
  const template = overrides[section.name];
1518
- return template === void 0 ? section : {
1609
+ return template === void 0 || template === defaults[section.name] ? section : {
1519
1610
  ...section,
1520
1611
  text: interpolateCodexPrompt(template, variables)
1521
1612
  };
@@ -1955,16 +2046,21 @@ function apply(ctx, config = {}) {
1955
2046
  }
1956
2047
  ctx.on("llm/stream", ((options, next) => {
1957
2048
  const settings = codexSettings.current();
1958
- const legacySafeNext = () => repairLegacyPiAiContextOverflow(next(), options.model, options.contextWindow);
1959
- if (resolved.remoteCompact && settings.remoteCompactionEnabled && options.purpose === "compaction" && isGptModel(options.model)) return remoteCompactStream(ctx, options, legacySafeNext, {
1960
- hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
1961
- customApplyPatch: settings.patchToolEnabled
1962
- });
2049
+ const contextWindow = options.contextWindow ?? settings.contextWindow;
2050
+ const compactionMode = codexCompactionMode();
2051
+ const legacySafeNext = () => repairLegacyPiAiContextOverflow(next(), options.model, contextWindow);
2052
+ if (options.purpose === "compaction" && isGptModel(options.model)) {
2053
+ if (compactionMode === "remote" || compactionMode !== "local" && resolved.remoteCompact && settings.remoteCompactionEnabled) return remoteCompactStream(ctx, options, legacySafeNext, {
2054
+ hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
2055
+ customApplyPatch: settings.patchToolEnabled
2056
+ });
2057
+ return legacySafeNext();
2058
+ }
1963
2059
  if (options.purpose === void 0 && isGptModel(options.model)) return repairLegacyPiAiContextOverflow(hostedWebSearchStream(next, {
1964
2060
  serviceTier: options.serviceTier,
1965
2061
  hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
1966
2062
  customApplyPatch: settings.patchToolEnabled
1967
- }), options.model, options.contextWindow);
2063
+ }), options.model, contextWindow);
1968
2064
  return next();
1969
2065
  }));
1970
2066
  }
package/lib/installer.js CHANGED
@@ -69,6 +69,7 @@ const CODEX_SETTINGS_NAMESPACE = settingsNamespace("codex");
69
69
  /** Default settings exposed even before a Codex session is opened. */
70
70
  const CODEX_SETTINGS_ENTRY = {
71
71
  fast: false,
72
+ fastModeControlEnabled: true,
72
73
  persona: DEFAULT_CODEX_PERSONA,
73
74
  harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
74
75
  webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
@@ -83,6 +84,7 @@ const CODEX_SETTINGS_ENTRY = {
83
84
  };
84
85
  const CODEX_SETTINGS_SCHEMA = z.object({
85
86
  fast: z.boolean().default(false),
87
+ fastModeControlEnabled: z.boolean().default(true),
86
88
  contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
87
89
  persona: z.string().default(DEFAULT_CODEX_PERSONA),
88
90
  harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
@@ -7,6 +7,7 @@ import { modelActivity } from './activity.ts';
7
7
  declare const LEGACY_OVERLAY_SLOT: "conversation.input.overlay";
8
8
  interface CodexSettings {
9
9
  fast: boolean;
10
+ fastModeControlEnabled: boolean;
10
11
  contextWindow?: number;
11
12
  persona?: string;
12
13
  harnessSourcePrompt?: string;
@@ -36,6 +37,12 @@ declare const en: {
36
37
  readonly otherCapabilitiesLabel: "Additional capabilities";
37
38
  readonly capabilityPrompt: "Codex operating prompt";
38
39
  readonly capabilityPromptHint: "Inject the editable instructions and persona-first prompt layout.";
40
+ readonly capabilityFast: "Fast mode control";
41
+ readonly capabilityFastHint: "Show the Fast mode switch beside the conversation composer.";
42
+ readonly compactRemote: "Remote compaction";
43
+ readonly compactRemoteHint: "Use the provider remote compaction endpoint first.";
44
+ readonly compactLocal: "Local compaction";
45
+ readonly compactLocalHint: "Use the DSH text-summary compaction engine directly.";
39
46
  readonly capabilityTerminal: "Terminal tools";
40
47
  readonly capabilityTerminalHint: "Expose exec_command and write_stdin.";
41
48
  readonly capabilityPatch: "Patch tool";
@@ -26,6 +26,12 @@ const en = {
26
26
  otherCapabilitiesLabel: 'Additional capabilities',
27
27
  capabilityPrompt: 'Codex operating prompt',
28
28
  capabilityPromptHint: 'Inject the editable instructions and persona-first prompt layout.',
29
+ capabilityFast: 'Fast mode control',
30
+ capabilityFastHint: 'Show the Fast mode switch beside the conversation composer.',
31
+ compactRemote: 'Remote compaction',
32
+ compactRemoteHint: 'Use the provider remote compaction endpoint first.',
33
+ compactLocal: 'Local compaction',
34
+ compactLocalHint: 'Use the DSH text-summary compaction engine directly.',
29
35
  capabilityTerminal: 'Terminal tools',
30
36
  capabilityTerminalHint: 'Expose exec_command and write_stdin.',
31
37
  capabilityPatch: 'Patch tool',
@@ -75,6 +81,12 @@ const zh = {
75
81
  otherCapabilitiesLabel: '\u5176\u4ed6\u80fd\u529b',
76
82
  capabilityPrompt: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
77
83
  capabilityPromptHint: '\u6ce8\u5165\u53ef\u7f16\u8f91\u6307\u4ee4\uff0c\u5e76\u5c06 Persona \u653e\u5728\u63d0\u793a\u8bcd\u9996\u4f4d\u3002',
84
+ capabilityFast: '\u663e\u793a Fast \u6a21\u5f0f',
85
+ capabilityFastHint: '\u5728\u5bf9\u8bdd\u8f93\u5165\u533a\u65c1\u663e\u793a Fast \u5f00\u5173\u3002',
86
+ compactRemote: '\u8fdc\u7a0b\u538b\u7f29',
87
+ compactRemoteHint: '\u4f18\u5148\u4f7f\u7528\u63d0\u4f9b\u5546\u7684\u8fdc\u7a0b\u538b\u7f29\u7aef\u70b9\u3002',
88
+ compactLocal: '\u672c\u5730\u538b\u7f29',
89
+ compactLocalHint: '\u76f4\u63a5\u4f7f\u7528 DSH \u6587\u672c\u6458\u8981\u538b\u7f29\u5f15\u64ce\u3002',
78
90
  capabilityTerminal: '\u7ec8\u7aef\u5de5\u5177',
79
91
  capabilityTerminalHint: '\u63d0\u4f9b exec_command \u548c write_stdin\u3002',
80
92
  capabilityPatch: '\u8865\u4e01\u5de5\u5177',
@@ -125,11 +137,25 @@ function CapabilityToggle({ field, label, hint, enabled, disabled, setSetting, }
125
137
  }, children: [_jsxs("span", { style: { flex: 1, minWidth: 0, display: 'grid', gap: 2 }, children: [_jsx("strong", { style: { fontSize: 13, fontWeight: 500 }, children: label }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 12, lineHeight: 1.45 }, children: hint })] }), _jsx("input", { type: "checkbox", role: "switch", checked: enabled, disabled: disabled, "aria-label": label, onChange: event => { void setSetting(field, event.target.checked); }, style: { marginTop: 3, accentColor: 'var(--dsw-static-blue-500)' } })] }));
126
138
  }
127
139
  /** Visually separate capability scope while keeping the host's light settings style. */
128
- function CapabilityGroup({ label, children, accent }) {
140
+ function CapabilityGroup({ id, label, children, accent }) {
141
+ const [open, setOpen] = useState(false);
142
+ const panelId = `${id}-panel`;
129
143
  return (_jsxs("section", { style: {
130
144
  display: 'grid',
131
- gap: 4,
132
- }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 7, paddingLeft: 2 }, children: [_jsx("span", { "aria-hidden": "true", style: {
145
+ gap: open ? 4 : 0,
146
+ }, children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": panelId, onClick: () => { setOpen(!open); }, style: {
147
+ display: 'flex',
148
+ alignItems: 'center',
149
+ gap: 7,
150
+ width: '100%',
151
+ padding: 0,
152
+ border: 0,
153
+ background: 'none',
154
+ color: 'var(--dsw-alias-label-secondary)',
155
+ font: 'inherit',
156
+ textAlign: 'left',
157
+ cursor: 'pointer',
158
+ }, children: [_jsx("span", { "aria-hidden": "true", style: {
133
159
  width: 6,
134
160
  height: 6,
135
161
  flex: '0 0 auto',
@@ -140,27 +166,44 @@ function CapabilityGroup({ label, children, accent }) {
140
166
  fontSize: 14,
141
167
  fontWeight: 600,
142
168
  letterSpacing: '0.01em',
143
- }, children: label })] }), _jsx("div", { style: {
169
+ }, children: label }), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsx("div", { id: panelId, style: {
144
170
  display: 'grid',
145
171
  marginLeft: 5,
146
172
  paddingLeft: 12,
147
- }, children: children })] }));
173
+ }, children: children }))] }));
148
174
  }
149
175
  function PromptEditor({ id, label, hint, value, writable, saving, minHeight, onChange, }) {
150
- return (_jsxs("div", { style: { display: 'grid', gap: 5 }, children: [_jsx("label", { htmlFor: id, style: { fontSize: 13, fontWeight: 500 }, children: label }), _jsx("textarea", { id: id, value: value, disabled: !writable || saving, onChange: event => { onChange(event.target.value); }, spellCheck: false, style: {
151
- boxSizing: 'border-box',
176
+ const [open, setOpen] = useState(false);
177
+ const labelId = `${id}-label`;
178
+ const panelId = `${id}-panel`;
179
+ return (_jsxs("div", { style: { display: 'grid', gap: open ? 8 : 0 }, children: [_jsxs("button", { type: "button", "aria-expanded": open, "aria-controls": panelId, onClick: () => { setOpen(!open); }, style: {
180
+ display: 'flex',
181
+ alignItems: 'center',
182
+ gap: 8,
152
183
  width: '100%',
153
- minHeight,
154
- resize: 'vertical',
155
- padding: 10,
156
- border: '1px solid var(--dsw-alias-border-l2)',
157
- borderRadius: 8,
158
- background: 'var(--dsw-alias-bg-layer-3)',
184
+ padding: 0,
185
+ border: 0,
186
+ background: 'none',
159
187
  color: 'var(--dsw-alias-label-primary)',
160
188
  font: 'inherit',
161
- fontSize: 12,
162
- lineHeight: 1.5,
163
- } }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11, lineHeight: 1.45 }, children: hint })] }));
189
+ fontSize: 13,
190
+ fontWeight: 500,
191
+ textAlign: 'left',
192
+ cursor: 'pointer',
193
+ }, children: [_jsx("span", { id: labelId, style: { flex: 1 }, children: label }), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { id: panelId, style: { display: 'grid', gap: 5 }, children: [_jsx("textarea", { id: id, "aria-labelledby": labelId, value: value, disabled: !writable || saving, onChange: event => { onChange(event.target.value); }, spellCheck: false, style: {
194
+ boxSizing: 'border-box',
195
+ width: '100%',
196
+ minHeight,
197
+ resize: 'vertical',
198
+ padding: 10,
199
+ border: '1px solid var(--dsw-alias-border-l2)',
200
+ borderRadius: 8,
201
+ background: 'var(--dsw-alias-bg-layer-3)',
202
+ color: 'var(--dsw-alias-label-primary)',
203
+ font: 'inherit',
204
+ fontSize: 12,
205
+ lineHeight: 1.5,
206
+ } }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11, lineHeight: 1.45 }, children: hint })] }))] }));
164
207
  }
165
208
  /** Full-prompt editor contributed to Settings > Plugins. */
166
209
  export function PromptSettingsCard(props) {
@@ -172,6 +215,7 @@ export function PromptSettingsCard(props) {
172
215
  const current = snapshot.value?.systemPrompt ?? DEFAULT_CODEX_SYSTEM_PROMPT;
173
216
  const inherited = promptFromLayer(snapshot.base) ?? DEFAULT_CODEX_SYSTEM_PROMPT;
174
217
  const codexOnlyCapabilities = [
218
+ { field: 'fastModeControlEnabled', label: 'capabilityFast', hint: 'capabilityFastHint' },
175
219
  { field: 'promptEnabled', label: 'capabilityPrompt', hint: 'capabilityPromptHint' },
176
220
  { field: 'terminalToolsEnabled', label: 'capabilityTerminal', hint: 'capabilityTerminalHint' },
177
221
  { field: 'patchToolEnabled', label: 'capabilityPatch', hint: 'capabilityPatchHint' },
@@ -268,7 +312,7 @@ export function PromptSettingsCard(props) {
268
312
  background: 'var(--dsw-alias-bg-module-platform)',
269
313
  color: 'var(--dsw-alias-label-secondary)',
270
314
  fontSize: 11,
271
- }, children: t('promptUnsaved') })), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { style: { borderTop: '1px solid var(--dsw-alias-border-l2)', margin: '0 16px', padding: '12px 0' }, children: [!snapshot.writable && (_jsx("p", { style: { margin: '0 0 10px', color: 'var(--dsw-alias-label-tertiary)', fontSize: 12 }, children: t('promptReadOnly') })), _jsxs("div", { style: { display: 'grid', gap: 16, marginBottom: 14 }, children: [_jsx(CapabilityGroup, { label: t('codexOnlyCapabilitiesLabel'), accent: "var(--dsw-static-blue-500)", children: codexOnlyCapabilities.map(renderCapability) }), _jsx(CapabilityGroup, { label: t('otherCapabilitiesLabel'), accent: "var(--dsw-alias-label-tertiary)", children: otherCapabilities.map(renderCapability) })] }), _jsxs("div", { style: {
315
+ }, children: t('promptUnsaved') })), _jsx("span", { "aria-hidden": "true", style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 16 }, children: open ? '-' : '+' })] }), open && (_jsxs("div", { style: { borderTop: '1px solid var(--dsw-alias-border-l2)', margin: '0 16px', padding: '12px 0' }, children: [!snapshot.writable && (_jsx("p", { style: { margin: '0 0 10px', color: 'var(--dsw-alias-label-tertiary)', fontSize: 12 }, children: t('promptReadOnly') })), _jsxs("div", { style: { display: 'grid', gap: 16, marginBottom: 14 }, children: [_jsx(CapabilityGroup, { id: "codex-only-capabilities", label: t('codexOnlyCapabilitiesLabel'), accent: "var(--dsw-static-blue-500)", children: codexOnlyCapabilities.map(renderCapability) }), _jsx(CapabilityGroup, { id: "other-capabilities", label: t('otherCapabilitiesLabel'), accent: "var(--dsw-alias-label-tertiary)", children: otherCapabilities.map(renderCapability) })] }), _jsxs("div", { style: {
272
316
  display: 'grid',
273
317
  gap: 14,
274
318
  paddingTop: 12,
@@ -286,7 +330,10 @@ export function PromptSettingsCard(props) {
286
330
  function FastModeFallback(props) {
287
331
  const { useSettings, setSetting, t } = props;
288
332
  const snapshot = useSettings(state => state);
333
+ const visible = snapshot.value?.fastModeControlEnabled ?? true;
289
334
  const fast = snapshot.value?.fast ?? false;
335
+ if (!visible)
336
+ return null;
290
337
  return (_jsxs("button", { type: "button", role: "switch", disabled: snapshot.writable === false, "aria-checked": fast, "aria-label": fast ? t('fastOn') : t('fastOff'), title: fast ? t('fastOn') : t('fastOff'), onClick: () => { void setSetting('fast', !fast); }, style: {
291
338
  boxSizing: 'border-box',
292
339
  display: 'inline-flex',
@@ -521,10 +568,35 @@ function LegacyOverlay(props) {
521
568
  const contextWindow = contextWindowFromProjection(useProjection);
522
569
  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'), turnStatusPosition !== null && typeof document !== 'undefined' && document.body !== null && createPortal(_jsx(ActivityLine, { sessionId: sessionId, useSession: useSession, useSessions: useSessions, useProjection: useProjection, useSettings: useSettings, t: t, position: turnStatusPosition }), document.body, 'codex-activity')] }));
523
570
  }
524
- export const inject = ['slots', 'locale', 'settingsScope'];
571
+ export const inject = ['commandUi', 'sessions', 'slots', 'locale', 'settingsScope'];
525
572
  /** Mount request controls and the plugin settings card through shared slots. */
526
573
  export function apply(ctx) {
527
574
  ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'codex client: dictionaries');
575
+ const commandUi = ctx.get('commandUi');
576
+ const sessions = ctx.get('sessions');
577
+ const t = ctx.locale.bind(NS);
578
+ const sessionFor = (session) => sessions.binding(session.sessionId)?.session;
579
+ ctx.effect(() => commandUi.decorate({
580
+ name: 'compact',
581
+ available: session => sessionFor(session) !== undefined,
582
+ ui: {
583
+ kind: 'popupSelect',
584
+ options: async () => [
585
+ { id: 'remote', label: t('compactRemote'), detail: t('compactRemoteHint') },
586
+ { id: 'local', label: t('compactLocal'), detail: t('compactLocalHint') },
587
+ ],
588
+ onSelect: async (option, session) => {
589
+ const live = sessionFor(session);
590
+ if (live === undefined)
591
+ throw new Error('this session is not materialized yet');
592
+ const result = await live.command(`/compact ${option.id}`);
593
+ if (!result.ok)
594
+ throw new Error(`compact mode switch failed: ${result.error.code}: ${result.error.message}`);
595
+ if (!result.value.matched)
596
+ throw new Error('the host offers no /compact command');
597
+ },
598
+ },
599
+ }), 'codex client: /compact mode picker');
528
600
  const settings = ctx.settingsScope.bind({ namespace: SETTINGS_NAMESPACE });
529
601
  const injected = () => ({
530
602
  hooks: { settings },
@@ -0,0 +1,13 @@
1
+ /** Codex-aware `/compact` command with an optional transport preference. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ /** Replace the Core command inside the Codex compaction scope. */
4
+ export declare function apply(ctx: Context): void;
5
+ export declare const name = "compact-command";
6
+ export declare const inject: string[];
7
+ declare const _default: {
8
+ name: string;
9
+ inject: string[];
10
+ apply: typeof apply;
11
+ };
12
+ export default _default;
13
+ //# sourceMappingURL=compact-command.d.ts.map
@@ -0,0 +1,79 @@
1
+ /** Codex-aware `/compact` command with an optional transport preference. */
2
+ import { ManualCompactionError } from '@deepseek-ai/dsh-compaction';
3
+ import { runCodexCompactionMode } from "./compaction.js";
4
+ const USAGE = 'Usage: /compact [remote|local]';
5
+ /** Convert expected backend failures into the same concise command results as DSH Core. */
6
+ function expectedFailure(error) {
7
+ switch (error.code) {
8
+ case 'busy':
9
+ return { kind: 'error', text: 'Compaction is unavailable because this process has an active compaction, or the agent is not idle.' };
10
+ case 'cancelled':
11
+ return { kind: 'error', text: 'Compaction cancelled.' };
12
+ case 'changed':
13
+ return { kind: 'error', text: 'Compaction could not replace the selected history because it changed. The conversation is unchanged.' };
14
+ case 'summary':
15
+ return { kind: 'error', text: 'Compaction could not produce a useful summary. The conversation is unchanged; the attempt is recorded in the session log.' };
16
+ case 'commit':
17
+ return { kind: 'error', text: 'Compaction did not finish cleanly; inspect the current session state before retrying.' };
18
+ case 'persistence':
19
+ return { kind: 'error', text: 'Compaction finished, but the session could not be saved.' };
20
+ default:
21
+ return { kind: 'error', text: `Unknown compaction failure: ${String(error.code)}` };
22
+ }
23
+ }
24
+ function modeOf(rawInput) {
25
+ const value = rawInput.trim().toLowerCase();
26
+ if (value === '')
27
+ return undefined;
28
+ if (value === 'remote' || value === 'local')
29
+ return value;
30
+ return 'invalid';
31
+ }
32
+ async function executeCompact(ctx, invocation) {
33
+ const mode = modeOf(invocation.rawInput);
34
+ if (mode === 'invalid')
35
+ return { kind: 'error', text: USAGE };
36
+ const compact = () => ctx.compaction.compactNow(invocation.agent, invocation.signal, invocation.commandId);
37
+ try {
38
+ const result = mode === undefined ? await compact() : await runCodexCompactionMode(mode, compact);
39
+ if (result === null)
40
+ return { kind: 'success', text: 'No compactable history yet.' };
41
+ return {
42
+ kind: 'success',
43
+ text: `Compacted ${result.shadowedSeqs.length} history items (~${result.shadowedTokenCount} tokens).`,
44
+ sourceEventSeq: result.summarySeq,
45
+ };
46
+ }
47
+ catch (error) {
48
+ if (invocation.signal.aborted)
49
+ return { kind: 'error', text: 'Compaction cancelled.' };
50
+ if (error instanceof ManualCompactionError)
51
+ return expectedFailure(error);
52
+ throw error;
53
+ }
54
+ }
55
+ /** Replace the Core command inside the Codex compaction scope. */
56
+ export function apply(ctx) {
57
+ const commands = ctx.commands;
58
+ const active = new Set();
59
+ const handler = (invocation) => {
60
+ const operation = executeCompact(ctx, invocation);
61
+ active.add(operation);
62
+ const retire = () => { active.delete(operation); };
63
+ operation.then(retire, retire);
64
+ return operation;
65
+ };
66
+ ctx.effect(function* () {
67
+ yield async () => { await Promise.allSettled(active); };
68
+ yield commands.register({
69
+ name: 'compact',
70
+ description: 'Compact older conversation history, optionally using remote or local mode',
71
+ input: { hint: '[remote|local]' },
72
+ handler,
73
+ });
74
+ }, 'codex compact command lifecycle');
75
+ }
76
+ export const name = 'compact-command';
77
+ export const inject = ['commands', 'compaction'];
78
+ export default { name, inject, apply };
79
+ //# sourceMappingURL=compact-command.js.map
@@ -3,6 +3,12 @@ import { Context } from '@deepseek-ai/cordis';
3
3
  import BasicCompactionEngine from '@deepseek-ai/dsh-compaction-basic';
4
4
  import type { CompactionResult, CompactionTrigger } from '@deepseek-ai/dsh-compaction';
5
5
  import type { Agent } from '@deepseek-ai/dsh-agent';
6
+ /** Per-command compaction preference propagated into the LLM stream seam. */
7
+ export type CodexCompactionMode = 'remote' | 'local';
8
+ /** Run one manual compaction with an explicit local/remote preference. */
9
+ export declare function runCodexCompactionMode<T>(mode: CodexCompactionMode, task: () => Promise<T>): Promise<T>;
10
+ /** Read the explicit preference for the current compaction stream, if any. */
11
+ export declare function codexCompactionMode(): CodexCompactionMode | undefined;
6
12
  /**
7
13
  * Keep the upstream compaction policy, retention, overflow recovery, and
8
14
  * transaction implementation intact. The scoped LLM seam changes only the
@@ -2,6 +2,15 @@
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();
6
+ /** Run one manual compaction with an explicit local/remote preference. */
7
+ export function runCodexCompactionMode(mode, task) {
8
+ return COMPACTION_MODE.run(mode, task);
9
+ }
10
+ /** Read the explicit preference for the current compaction stream, if any. */
11
+ export function codexCompactionMode() {
12
+ return COMPACTION_MODE.getStore();
13
+ }
5
14
  const CODEX_SETTINGS_NAMESPACE = settingsNamespace('codex');
6
15
  /** Codex context overrides apply only to GPT-compatible model routes. */
7
16
  function isGptModel(model) {
@@ -8,6 +8,7 @@ import { hostedWebSearchStream, installHostedWebSearch, remoteCompactStream, rep
8
8
  import { registerCodexActivityProjection } from "./activity.js";
9
9
  import { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, resolveCodexSystemPrompt, } from "./prompt.js";
10
10
  import { CODEX_SETTINGS_ENTRY, CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA, } from "./settings.js";
11
+ import { codexCompactionMode } from "./compaction.js";
11
12
  export { DEFAULT_CODEX_PERSONA, DEFAULT_CODEX_SYSTEM_PROMPT, DEFAULT_DSH_CORE_SOURCE_PROMPT, DEFAULT_DSH_CORE_WEB_PROMPT, } from "./prompt.js";
12
13
  export { CODEX_SETTINGS_NAMESPACE, CODEX_SETTINGS_SCHEMA } from "./settings.js";
13
14
  export const name = 'codex';
@@ -275,15 +276,23 @@ function interpolateCodexPrompt(text, variables) {
275
276
  }
276
277
  /** Apply user-editable Persona and DSH Core runtime prompt templates. */
277
278
  function applyCodexPromptOverrides(assembly, settings) {
278
- const variables = promptVariables(assembly);
279
279
  const overrides = {
280
280
  'deployment:persona': settings.persona,
281
281
  'harness:source': settings.harnessSourcePrompt,
282
282
  'app:web-surface': settings.webSurfacePrompt,
283
283
  };
284
+ const defaults = {
285
+ 'deployment:persona': DEFAULT_CODEX_PERSONA,
286
+ 'harness:source': DEFAULT_DSH_CORE_SOURCE_PROMPT,
287
+ 'app:web-surface': DEFAULT_DSH_CORE_WEB_PROMPT,
288
+ };
289
+ const hasCustomOverride = Object.entries(overrides).some(([name, text]) => (text !== undefined && text !== defaults[name]));
290
+ if (!hasCustomOverride)
291
+ return assembly;
292
+ const variables = promptVariables(assembly);
284
293
  const sections = assembly.sections.map(section => {
285
294
  const template = overrides[section.name];
286
- return template === undefined
295
+ return template === undefined || template === defaults[section.name]
287
296
  ? section
288
297
  : { ...section, text: interpolateCodexPrompt(template, variables) };
289
298
  });
@@ -611,22 +620,26 @@ export function apply(ctx, config = {}) {
611
620
  }
612
621
  ctx.on('llm/stream', ((options, next) => {
613
622
  const settings = codexSettings.current();
614
- const legacySafeNext = () => repairLegacyPiAiContextOverflow(next(), options.model, options.contextWindow);
615
- if (resolved.remoteCompact
616
- && settings.remoteCompactionEnabled
617
- && options.purpose === 'compaction'
618
- && isGptModel(options.model)) {
619
- return remoteCompactStream(ctx, options, legacySafeNext, {
620
- hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
621
- customApplyPatch: settings.patchToolEnabled,
622
- });
623
+ const contextWindow = options.contextWindow ?? settings.contextWindow;
624
+ const compactionMode = codexCompactionMode();
625
+ const legacySafeNext = () => repairLegacyPiAiContextOverflow(next(), options.model, contextWindow);
626
+ if (options.purpose === 'compaction' && isGptModel(options.model)) {
627
+ const useRemoteCompaction = compactionMode === 'remote'
628
+ || (compactionMode !== 'local' && resolved.remoteCompact && settings.remoteCompactionEnabled);
629
+ if (useRemoteCompaction) {
630
+ return remoteCompactStream(ctx, options, legacySafeNext, {
631
+ hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
632
+ customApplyPatch: settings.patchToolEnabled,
633
+ });
634
+ }
635
+ return legacySafeNext();
623
636
  }
624
637
  if (options.purpose === undefined && isGptModel(options.model)) {
625
638
  return repairLegacyPiAiContextOverflow(hostedWebSearchStream(next, {
626
639
  serviceTier: options.serviceTier,
627
640
  hostedWebSearch: resolved.hostedWebSearch && settings.hostedWebSearchEnabled,
628
641
  customApplyPatch: settings.patchToolEnabled,
629
- }), options.model, options.contextWindow);
642
+ }), options.model, contextWindow);
630
643
  }
631
644
  return next();
632
645
  }));
@@ -5,6 +5,8 @@ export declare const CODEX_SETTINGS_NAMESPACE: Branded<"SettingsNamespace">;
5
5
  export interface CodexSettings {
6
6
  /** Use the Responses priority service tier for GPT requests. */
7
7
  fast: boolean;
8
+ /** Show the Fast mode switch in the conversation composer. */
9
+ fastModeControlEnabled: boolean;
8
10
  /** Optional context capacity override, in tokens. */
9
11
  contextWindow?: number;
10
12
  /** Deployment Persona template; supports the host's prompt variables. */
@@ -8,6 +8,7 @@ export const CODEX_SETTINGS_NAMESPACE = settingsNamespace('codex');
8
8
  /** Default settings exposed even before a Codex session is opened. */
9
9
  export const CODEX_SETTINGS_ENTRY = {
10
10
  fast: false,
11
+ fastModeControlEnabled: true,
11
12
  persona: DEFAULT_CODEX_PERSONA,
12
13
  harnessSourcePrompt: DEFAULT_DSH_CORE_SOURCE_PROMPT,
13
14
  webSurfacePrompt: DEFAULT_DSH_CORE_WEB_PROMPT,
@@ -22,6 +23,7 @@ export const CODEX_SETTINGS_ENTRY = {
22
23
  };
23
24
  export const CODEX_SETTINGS_SCHEMA = z.object({
24
25
  fast: z.boolean().default(false),
26
+ fastModeControlEnabled: z.boolean().default(true),
25
27
  contextWindow: z.number().step(1).min(1).max(CODEX_CONTEXT_MAX),
26
28
  persona: z.string().default(DEFAULT_CODEX_PERSONA),
27
29
  harnessSourcePrompt: z.string().default(DEFAULT_DSH_CORE_SOURCE_PROMPT),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuind/dsh-codex-harness",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Codex coding preset with customizable prompts and tools for DSH.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -22,6 +22,10 @@
22
22
  "types": "./lib/types/compaction.d.ts",
23
23
  "default": "./lib/compaction.js"
24
24
  },
25
+ "./compact-command": {
26
+ "types": "./lib/types/compact-command.d.ts",
27
+ "default": "./lib/types/compact-command.js"
28
+ },
25
29
  "./client": {
26
30
  "types": "./lib/types/client/index.d.ts",
27
31
  "default": "./lib/client.js"
@@ -74,6 +78,7 @@
74
78
  "@deepseek-ai/dsh-client-locale",
75
79
  "@deepseek-ai/dsh-client-runtime",
76
80
  "@deepseek-ai/dsh-client-ui-conversation",
81
+ "@deepseek-ai/dsh-client-ui-commands",
77
82
  "@deepseek-ai/dsh-client-ui-settings",
78
83
  "@deepseek-ai/dsh-client-ui-settings-plugins"
79
84
  ],
@@ -90,9 +95,11 @@
90
95
  "@deepseek-ai/dsh-client-locale": ">=0.1.0-rc.8",
91
96
  "@deepseek-ai/dsh-client-runtime": ">=0.1.0-rc.8",
92
97
  "@deepseek-ai/dsh-client-ui-conversation": ">=0.1.0-rc.8",
98
+ "@deepseek-ai/dsh-client-ui-commands": ">=0.1.0-rc.8",
93
99
  "@deepseek-ai/dsh-client-ui-settings": ">=0.1.0-rc.8",
94
100
  "@deepseek-ai/dsh-client-ui-settings-plugins": ">=0.1.0-rc.8",
95
101
  "@deepseek-ai/dsh-client-ui-slots": ">=0.1.0-rc.8",
102
+ "@deepseek-ai/dsh-commands": ">=0.1.0-rc.8",
96
103
  "@deepseek-ai/dsh-compaction": ">=0.1.0-rc.8",
97
104
  "@deepseek-ai/dsh-compaction-basic": ">=0.1.0-rc.8",
98
105
  "@deepseek-ai/dsh-compaction-tool-result-pruner": ">=0.1.0-rc.8",
@@ -131,6 +138,12 @@
131
138
  "@deepseek-ai/dsh-client-ui-conversation": {
132
139
  "optional": true
133
140
  },
141
+ "@deepseek-ai/dsh-client-ui-commands": {
142
+ "optional": true
143
+ },
144
+ "@deepseek-ai/dsh-commands": {
145
+ "optional": true
146
+ },
134
147
  "@deepseek-ai/dsh-client-ui-settings": {
135
148
  "optional": true
136
149
  },
@@ -77,7 +77,7 @@
77
77
  thresholdRatio: 0.95
78
78
 
79
79
  - id: command-compact
80
- name: '@deepseek-ai/dsh-command-compact'
80
+ name: '@shuind/dsh-codex-harness/compact-command'
81
81
 
82
82
  - id: tool-result-pruner
83
83
  name: '@deepseek-ai/dsh-compaction-tool-result-pruner'