@shuind/dsh-codex-harness 0.2.21 → 0.3.0
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/CHANGELOG.md +185 -0
- package/README.md +38 -50
- package/RELEASE.md +61 -0
- package/assets/codex.svg +5 -0
- package/cordis.patch.yml +181 -6
- package/docs/preset-library.md +33 -23
- package/docs/tool-policy-benchmark.json +310 -0
- package/docs/tool-policy.md +148 -0
- package/lib/client.js +4774 -2416
- package/lib/compact-command.js +416 -0
- package/lib/compaction.js +141 -12
- package/lib/hybrid-executor.js +1196 -0
- package/lib/index.js +3658 -2334
- package/lib/preferences.js +117 -0
- package/lib/tool-policy.js +2422 -0
- package/lib/typert.js +86 -79
- package/lib/types/client/activity.d.ts +33 -9
- package/lib/types/client/activity.js +4 -3
- package/lib/types/client/desktop.d.ts +67 -0
- package/lib/types/client/desktop.js +229 -0
- package/lib/types/client/index.d.ts +207 -110
- package/lib/types/client/index.js +99 -492
- package/lib/types/client/policy-drafts.d.ts +25 -0
- package/lib/types/client/policy-drafts.js +47 -0
- package/lib/types/client/policy-locale.d.ts +260 -0
- package/lib/types/client/policy-locale.js +357 -0
- package/lib/types/client/preset-manager.d.ts +38 -10
- package/lib/types/client/preset-manager.js +235 -185
- package/lib/types/client/preset-requests.d.ts +12 -0
- package/lib/types/client/preset-requests.js +101 -0
- package/lib/types/client/tool-policy.d.ts +33 -0
- package/lib/types/client/tool-policy.js +336 -0
- package/lib/types/contracts/preset-editor-schema.d.ts +78 -0
- package/lib/types/contracts/preset-editor-schema.js +95 -0
- package/lib/types/{prompt.js → contracts/prompt.js} +13 -7
- package/lib/types/{settings.d.ts → contracts/settings.d.ts} +11 -4
- package/lib/types/{settings.js → contracts/settings.js} +22 -6
- package/lib/types/contracts/tool-policy-contract.d.ts +63 -0
- package/lib/types/contracts/tool-policy-contract.js +33 -0
- package/lib/types/contracts/ui-contracts.d.ts +92 -0
- package/lib/types/contracts/ui-contracts.js +83 -0
- package/lib/types/entries/client.d.ts +10 -0
- package/lib/types/entries/client.js +10 -0
- package/lib/types/{compact-command.d.ts → entries/compact-command.d.ts} +2 -0
- package/lib/types/entries/compact-command.js +176 -0
- package/lib/types/{compaction.d.ts → entries/compaction.d.ts} +15 -3
- package/lib/types/{compaction.js → entries/compaction.js} +47 -11
- package/lib/types/entries/hybrid-executor.d.ts +19 -0
- package/lib/types/entries/hybrid-executor.js +57 -0
- package/lib/types/entries/index.d.ts +66 -0
- package/lib/types/entries/index.js +192 -0
- package/lib/types/entries/preferences.d.ts +11 -0
- package/lib/types/entries/preferences.js +16 -0
- package/lib/types/entries/tool-policy.d.ts +97 -0
- package/lib/types/entries/tool-policy.js +158 -0
- package/lib/types/entries/typert.host.d.ts +23 -0
- package/lib/types/entries/typert.host.js +24 -0
- package/lib/types/hybrid/codex-hybrid-executor.d.ts +44 -0
- package/lib/types/hybrid/codex-hybrid-executor.js +257 -0
- package/lib/types/hybrid/hybrid-sdk.d.ts +13 -0
- package/lib/types/hybrid/hybrid-sdk.js +196 -0
- package/lib/types/hybrid/program-calls.d.ts +28 -0
- package/lib/types/hybrid/program-calls.js +193 -0
- package/lib/types/hybrid/subcall-scheduler.d.ts +90 -0
- package/lib/types/hybrid/subcall-scheduler.js +343 -0
- package/lib/types/policy/deferred-tools.d.ts +42 -0
- package/lib/types/policy/deferred-tools.js +264 -0
- package/lib/types/policy/overlay-installer.d.ts +12 -0
- package/lib/types/policy/overlay-installer.js +179 -0
- package/lib/types/policy/rule-resolver.d.ts +94 -0
- package/lib/types/policy/rule-resolver.js +114 -0
- package/lib/types/policy/tool-capabilities.d.ts +33 -0
- package/lib/types/policy/tool-capabilities.js +46 -0
- package/lib/types/{activity.d.ts → presets/activity.d.ts} +3 -5
- package/lib/types/{activity.js → presets/activity.js} +51 -27
- package/lib/types/presets/desktop-preset.d.ts +22 -0
- package/lib/types/presets/desktop-preset.js +43 -0
- package/lib/types/presets/preset-editor.d.ts +47 -0
- package/lib/types/presets/preset-editor.js +81 -0
- package/lib/types/presets/preset-prompt-catalog.d.ts +23 -0
- package/lib/types/presets/preset-prompt-catalog.js +215 -0
- package/lib/types/presets/preset-tool-catalog.d.ts +5 -0
- package/lib/types/presets/preset-tool-catalog.js +58 -0
- package/lib/types/presets/runtime-enhancements.d.ts +45 -0
- package/lib/types/presets/runtime-enhancements.js +349 -0
- package/lib/types/presets/small-window-compaction.d.ts +15 -0
- package/lib/types/presets/small-window-compaction.js +121 -0
- package/lib/types/responses/compact-checkpoint.d.ts +27 -0
- package/lib/types/responses/compact-checkpoint.js +257 -0
- package/lib/types/responses/fetch-transport.d.ts +16 -0
- package/lib/types/responses/fetch-transport.js +257 -0
- package/lib/types/responses/remote-compact.d.ts +13 -0
- package/lib/types/responses/remote-compact.js +319 -0
- package/lib/types/responses/sse-diagnostics.d.ts +9 -0
- package/lib/types/responses/sse-diagnostics.js +157 -0
- package/lib/types/responses/wire-rewrite.d.ts +35 -0
- package/lib/types/responses/wire-rewrite.js +237 -0
- package/lib/types/tools/exec-output.d.ts +58 -0
- package/lib/types/tools/exec-output.js +173 -0
- package/lib/types/tools/exec-plan-tools.d.ts +37 -0
- package/lib/types/tools/exec-plan-tools.js +265 -0
- package/lib/types/tools/exec-runner.d.ts +21 -0
- package/lib/types/tools/exec-runner.js +385 -0
- package/lib/types/tools/patch-tool.d.ts +16 -0
- package/lib/types/tools/patch-tool.js +258 -0
- package/lib/types/{patch.d.ts → tools/patch.d.ts} +1 -1
- package/lib/types/{patch.js → tools/patch.js} +96 -21
- package/locale/en.json +6 -0
- package/locale/hybrid-executor/en.json +6 -0
- package/locale/hybrid-executor/zh.json +6 -0
- package/locale/tool-policy/en.json +6 -0
- package/locale/tool-policy/zh.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +297 -299
- package/presets/{codex-collaboration → codex-hybrid}/agent.cordis.yml +45 -48
- package/presets/codex-hybrid/preset.yml +3 -0
- package/scripts/benchmark-tool-policy.mjs +186 -0
- package/scripts/build-preset.mjs +19 -0
- package/scripts/clean-build.mjs +11 -0
- package/src/client/activity.ts +83 -0
- package/src/client/desktop.tsx +276 -0
- package/src/client/index.tsx +391 -0
- package/src/client/policy-drafts.ts +56 -0
- package/src/client/policy-locale.ts +362 -0
- package/src/client/preset-manager.tsx +376 -0
- package/src/client/preset-requests.ts +113 -0
- package/src/client/tool-policy.tsx +402 -0
- package/src/contracts/preset-editor-schema.ts +110 -0
- package/src/contracts/prompt.ts +66 -0
- package/src/contracts/settings.ts +103 -0
- package/src/contracts/tool-policy-contract.ts +93 -0
- package/src/contracts/ui-contracts.ts +173 -0
- package/src/entries/client.tsx +14 -0
- package/src/entries/compact-command.ts +256 -0
- package/src/entries/compaction.ts +218 -0
- package/src/entries/hybrid-executor.ts +76 -0
- package/src/entries/index.ts +298 -0
- package/src/entries/preferences.ts +17 -0
- package/src/entries/tool-policy.ts +162 -0
- package/src/entries/typert.host.ts +29 -0
- package/src/hybrid/codex-hybrid-executor.ts +310 -0
- package/src/hybrid/hybrid-sdk.ts +217 -0
- package/src/hybrid/program-calls.ts +202 -0
- package/src/hybrid/subcall-scheduler.ts +446 -0
- package/src/policy/deferred-tools.ts +331 -0
- package/src/policy/overlay-installer.ts +191 -0
- package/src/policy/rule-resolver.ts +128 -0
- package/src/policy/tool-capabilities.ts +88 -0
- package/src/presets/activity.ts +146 -0
- package/src/presets/desktop-preset.ts +60 -0
- package/src/presets/preset-editor.ts +101 -0
- package/src/presets/preset-prompt-catalog.ts +221 -0
- package/src/presets/preset-tool-catalog.ts +58 -0
- package/src/presets/runtime-enhancements.ts +415 -0
- package/src/presets/small-window-compaction.ts +166 -0
- package/src/responses/compact-checkpoint.ts +264 -0
- package/src/responses/fetch-transport.ts +290 -0
- package/src/responses/remote-compact.ts +393 -0
- package/src/responses/sse-diagnostics.ts +156 -0
- package/src/responses/wire-rewrite.ts +261 -0
- package/src/tools/exec-output.ts +211 -0
- package/src/tools/exec-plan-tools.ts +307 -0
- package/src/tools/exec-runner.ts +445 -0
- package/src/tools/patch-tool.ts +331 -0
- package/src/tools/patch.ts +328 -0
- package/tsconfig.json +29 -0
- package/tsdown.config.ts +110 -0
- package/lib/installer.js +0 -237
- package/lib/invariant.js +0 -23
- package/lib/types/activity-types.d.ts +0 -6
- package/lib/types/activity-types.js +0 -3
- package/lib/types/client/preset-copy.d.ts +0 -42
- package/lib/types/client/preset-copy.js +0 -81
- package/lib/types/compact-command.js +0 -79
- package/lib/types/context.d.ts +0 -8
- package/lib/types/context.js +0 -14
- package/lib/types/exec.d.ts +0 -46
- package/lib/types/exec.js +0 -365
- package/lib/types/index.d.ts +0 -95
- package/lib/types/index.js +0 -738
- package/lib/types/installer.d.ts +0 -27
- package/lib/types/installer.js +0 -146
- package/lib/types/invariant.d.ts +0 -16
- package/lib/types/invariant.js +0 -22
- package/lib/types/preset-contract.d.ts +0 -69
- package/lib/types/preset-contract.js +0 -22
- package/lib/types/preset-editor-remote.d.ts +0 -30
- package/lib/types/preset-editor-remote.js +0 -37
- package/lib/types/preset-editor.d.ts +0 -69
- package/lib/types/preset-editor.js +0 -557
- package/lib/types/preset-templates.d.ts +0 -36
- package/lib/types/preset-templates.js +0 -12
- package/lib/types/prompt-sections.d.ts +0 -15
- package/lib/types/prompt-sections.js +0 -23
- package/lib/types/remote.d.ts +0 -40
- package/lib/types/remote.js +0 -683
- package/lib/types/typert.host.d.ts +0 -47
- package/lib/types/typert.host.js +0 -99
- package/presets/codex-collaboration/preset.yml +0 -3
- /package/lib/types/{prompt.d.ts → contracts/prompt.d.ts} +0 -0
|
@@ -1,337 +1,104 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
/** Browser controls
|
|
3
|
-
import { useEffect,
|
|
4
|
-
import {
|
|
5
|
-
import { CODEX_CONTEXT_MAX, CODEX_CONTEXT_UNIT, isCodexPresetId } from "../context.js";
|
|
2
|
+
/** Browser controls, /compact decorator, and live activity line for Codex Harness. */
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import { OPENAI_CODEX_PROVIDER } from "../contracts/ui-contracts.js";
|
|
6
5
|
import { modelActivity, sameModelActivity } from "./activity.js";
|
|
7
|
-
import presetEditorRemote from "../preset-editor-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import presetEditorRemote from "../contracts/preset-editor-schema.js";
|
|
7
|
+
import { toolPolicyEn, toolPolicyZh } from "./tool-policy.js";
|
|
8
|
+
import { ContextWindowControl, isGptModelName, pillStyle, useModelDirectory } from "./preset-manager.js";
|
|
9
|
+
export { ContextWindowControl };
|
|
10
|
+
function notifyCompactError(sessions, sessionId, text) {
|
|
11
|
+
const actx = sessions.scope?.(sessionId);
|
|
12
|
+
actx?.get?.('conversation')?.input?.for?.(actx)?.notify?.('error', text);
|
|
13
|
+
}
|
|
10
14
|
const NS = 'codex';
|
|
11
|
-
const SETTINGS_NAMESPACE = 'codex';
|
|
12
15
|
const FAST_FALLBACK_SLOT = 'conversation.input.right';
|
|
13
|
-
const LEGACY_OVERLAY_SLOT = 'conversation.input.overlay';
|
|
14
|
-
const PLUGIN_SETTINGS_SLOT = 'settings.plugin.item';
|
|
15
|
-
const DEFAULT_CONTEXT_WINDOW = 262_144;
|
|
16
16
|
const en = {
|
|
17
|
-
...
|
|
17
|
+
...toolPolicyEn,
|
|
18
18
|
fast: 'Fast mode',
|
|
19
|
+
fastModeControl: 'Show fast mode control',
|
|
20
|
+
contextWindowControl: 'Show context window control',
|
|
19
21
|
fastOn: 'Fast mode on (priority tier)',
|
|
20
22
|
fastOff: 'Fast mode off',
|
|
21
23
|
fastStateOn: 'On',
|
|
22
24
|
fastStateOff: 'Off',
|
|
23
25
|
contextSize: 'Context size',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
otherCapabilitiesLabel: 'Global capabilities',
|
|
29
|
-
capabilityPrompt: 'Codex operating prompt',
|
|
30
|
-
capabilityPromptHint: 'Inject the editable instructions and persona-first prompt layout.',
|
|
26
|
+
contextShortDefault: 'Ctx',
|
|
27
|
+
contextDefaultOption: 'Default',
|
|
28
|
+
contextCustomPlaceholder: '≥16k (e.g. 64)',
|
|
29
|
+
contextApply: 'Set',
|
|
31
30
|
compactRemote: 'Remote compaction',
|
|
32
31
|
compactRemoteHint: 'Use the provider remote compaction endpoint first.',
|
|
33
32
|
compactLocal: 'Local compaction',
|
|
34
33
|
compactLocalHint: 'Use the DSH text-summary compaction engine directly.',
|
|
35
|
-
capabilityTerminal: 'Terminal tools',
|
|
36
|
-
capabilityTerminalHint: 'Expose exec_command and write_stdin.',
|
|
37
|
-
capabilityPatch: 'Patch tool',
|
|
38
|
-
capabilityPatchHint: 'Expose apply_patch, using the native Responses grammar when supported.',
|
|
39
|
-
capabilityPlan: 'Plan tool',
|
|
40
|
-
capabilityPlanHint: 'Expose update_plan for implementation task tracking.',
|
|
41
|
-
capabilityWebSearch: 'Hosted web search',
|
|
42
|
-
capabilityWebSearchHint: 'Use the provider-native Responses web_search tool when available.',
|
|
43
|
-
capabilityCompaction: 'Remote compaction',
|
|
44
|
-
capabilityCompactionHint: 'Prefer the provider Responses compact endpoint before local compaction.',
|
|
45
34
|
capabilityActivity: 'Activity indicator',
|
|
46
|
-
capabilityActivityHint: 'Show request, reply, and compaction status beside the conversation.',
|
|
47
|
-
promptCustomizationLabel: 'Prompt customization',
|
|
48
|
-
personaLabel: 'Persona',
|
|
49
|
-
personaHint: 'Deployment identity and role. Supports {{model}} and {{cwd}}.',
|
|
50
|
-
sourcePromptLabel: 'DSH Core source instructions',
|
|
51
|
-
sourcePromptHint: 'Guidance about the DSH checkout and working directory. Supports {{sourceRoot}}.',
|
|
52
|
-
webPromptLabel: 'DSH Core Web instructions',
|
|
53
|
-
webPromptHint: 'Guidance about this Web GUI, HMR, builds, and verification. Supports {{webUrl}}.',
|
|
54
|
-
promptRestoreAll: 'Restore all prompt defaults',
|
|
55
|
-
promptLabel: 'Codex operating prompt',
|
|
56
|
-
promptHint: 'This is the Codex operating prompt. Persona and DSH Core instructions are edited separately above.',
|
|
57
|
-
promptUnsaved: 'Unsaved',
|
|
58
35
|
promptDiscard: 'Discard',
|
|
59
|
-
promptSave: 'Save',
|
|
60
36
|
promptSaving: 'Saving...',
|
|
61
|
-
promptSaveFailed: 'Could not save the prompt.',
|
|
62
|
-
promptExpand: 'Expand settings',
|
|
63
|
-
promptCollapse: 'Collapse settings',
|
|
64
37
|
promptReadOnly: 'This settings document is read-only.',
|
|
65
38
|
activityCompacting: 'Compacting context...',
|
|
66
39
|
activityRequestingModel: 'Requesting model...',
|
|
67
40
|
activityModelReply: 'Model replying...',
|
|
68
41
|
};
|
|
69
42
|
const zh = {
|
|
70
|
-
...
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
capabilityWebSearch: '\u6258\u7ba1\u7f51\u7edc\u641c\u7d22',
|
|
95
|
-
capabilityWebSearchHint: '\u53ef\u7528\u65f6\u4f7f\u7528\u63d0\u4f9b\u5546\u539f\u751f\u7684 Responses web_search \u5de5\u5177\u3002',
|
|
96
|
-
capabilityCompaction: '\u8fdc\u7a0b\u4e0a\u4e0b\u6587\u538b\u7f29',
|
|
97
|
-
capabilityCompactionHint: '\u4f18\u5148\u8c03\u7528\u63d0\u4f9b\u5546\u7684 Responses compact \u7aef\u70b9\uff0c\u5931\u8d25\u65f6\u56de\u9000\u672c\u5730\u538b\u7f29\u3002',
|
|
98
|
-
capabilityActivity: '\u6d3b\u52a8\u72b6\u6001',
|
|
99
|
-
capabilityActivityHint: '\u5728\u5bf9\u8bdd\u65c1\u663e\u793a\u8bf7\u6c42\u3001\u56de\u590d\u548c\u538b\u7f29\u72b6\u6001\u3002',
|
|
100
|
-
promptCustomizationLabel: '\u63d0\u793a\u8bcd\u5b9a\u5236',
|
|
101
|
-
personaLabel: 'Persona',
|
|
102
|
-
personaHint: '\u5b9a\u4e49 Agent \u7684\u8eab\u4efd\u4e0e\u89d2\u8272,\u652f\u6301 {{model}} \u548c {{cwd}}。',
|
|
103
|
-
sourcePromptLabel: 'DSH Core \u6e90\u7801\u8bf4\u660e',
|
|
104
|
-
sourcePromptHint: '\u8bf4\u660e DSH \u6e90\u7801\u68c0\u51fa\u76ee\u5f55\u4e0e\u5de5\u4f5c\u76ee\u5f55,\u652f\u6301 {{sourceRoot}}。',
|
|
105
|
-
webPromptLabel: 'DSH Core Web \u8bf4\u660e',
|
|
106
|
-
webPromptHint: '\u8bf4\u660e Web GUI、HMR、\u6784\u5efa\u4e0e\u9a8c\u8bc1,\u652f\u6301 {{webUrl}}。',
|
|
107
|
-
promptRestoreAll: '\u6062\u590d\u6240\u6709\u63d0\u793a\u8bcd\u9ed8\u8ba4\u503c',
|
|
108
|
-
promptLabel: 'Codex \u64cd\u4f5c\u63d0\u793a\u8bcd',
|
|
109
|
-
promptHint: '\u8fd9\u662f Codex \u64cd\u4f5c\u63d0\u793a\u8bcd。Persona \u548c DSH Core \u8bf4\u660e\u5728\u4e0a\u65b9\u5206\u522b\u7f16\u8f91。',
|
|
110
|
-
promptUnsaved: '\u672a\u4fdd\u5b58',
|
|
111
|
-
promptDiscard: '\u653e\u5f03',
|
|
112
|
-
promptSave: '\u4fdd\u5b58',
|
|
113
|
-
promptSaving: '\u4fdd\u5b58\u4e2d...',
|
|
114
|
-
promptSaveFailed: '\u63d0\u793a\u8bcd\u4fdd\u5b58\u5931\u8d25。',
|
|
115
|
-
promptExpand: '\u5c55\u5f00\u8bbe\u7f6e',
|
|
116
|
-
promptCollapse: '\u6536\u8d77\u8bbe\u7f6e',
|
|
117
|
-
promptReadOnly: '\u5f53\u524d\u8bbe\u7f6e\u6587\u4ef6\u4e3a\u53ea\u8bfb\u3002',
|
|
118
|
-
activityCompacting: '\u6b63\u5728\u538b\u7f29\u4e0a\u4e0b\u6587...',
|
|
119
|
-
activityRequestingModel: '\u8bf7\u6c42\u4e2d...',
|
|
120
|
-
activityModelReply: '\u56de\u590d\u4e2d...',
|
|
43
|
+
...toolPolicyZh,
|
|
44
|
+
fastModeControl: '显示快速模式开关',
|
|
45
|
+
contextWindowControl: '显示上下文大小快捷按钮',
|
|
46
|
+
fast: '快速模式',
|
|
47
|
+
fastOn: '快速模式已开启(优先通道)',
|
|
48
|
+
fastOff: '快速模式已关闭',
|
|
49
|
+
fastStateOn: '开',
|
|
50
|
+
fastStateOff: '关',
|
|
51
|
+
contextSize: '上下文大小',
|
|
52
|
+
contextShortDefault: '上下文',
|
|
53
|
+
contextDefaultOption: '默认',
|
|
54
|
+
contextCustomPlaceholder: '≥16k (如 64)',
|
|
55
|
+
contextApply: '确定',
|
|
56
|
+
compactRemote: '远程压缩',
|
|
57
|
+
compactRemoteHint: '优先使用提供商的远程压缩端点。',
|
|
58
|
+
compactLocal: '本地压缩',
|
|
59
|
+
compactLocalHint: '直接使用 DSH 文本摘要压缩引擎。',
|
|
60
|
+
capabilityActivity: '活动状态',
|
|
61
|
+
promptDiscard: '放弃',
|
|
62
|
+
promptSaving: '保存中...',
|
|
63
|
+
promptReadOnly: '当前设置文件为只读。',
|
|
64
|
+
activityCompacting: '正在压缩上下文...',
|
|
65
|
+
activityRequestingModel: '请求中...',
|
|
66
|
+
activityModelReply: '回复中...',
|
|
121
67
|
};
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}, 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)' } })] }));
|
|
130
|
-
}
|
|
131
|
-
/** One editor per preset; only display preferences are global. */
|
|
132
|
-
export function PromptSettingsCard(props) {
|
|
133
|
-
const { useSettings, setSetting, presetManager, t } = props;
|
|
134
|
-
const snapshot = useSettings(state => state);
|
|
135
|
-
const [open, setOpen] = useState(false);
|
|
136
|
-
if (snapshot.status === 'unavailable')
|
|
137
|
-
return null;
|
|
138
|
-
return _jsxs("li", { style: { listStyle: 'none', border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 12, overflow: 'hidden' }, children: [_jsxs("button", { type: "button", "aria-expanded": open, onClick: () => setOpen(!open), style: { width: '100%', padding: 16, textAlign: 'left', border: 0, background: 'none', color: 'inherit', cursor: 'pointer' }, children: [_jsx("strong", { children: t('promptCardTitle') }), _jsx("span", { style: { float: 'right' }, children: open ? '−' : '+' }), _jsx("p", { style: { marginBottom: 0 }, children: t('promptCardDescription') })] }), open && _jsxs("div", { style: { padding: 16, borderTop: '1px solid var(--dsw-alias-border-l2)' }, children: [_jsx(PresetManagerCard, { presetManager: presetManager, t: t }), _jsxs("details", { style: { marginTop: 22, borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: 14 }, children: [_jsx("summary", { style: { cursor: 'pointer', fontWeight: 600 }, children: t('pmGlobalSettings') }), _jsx(CapabilityToggle, { field: "activityIndicatorEnabled", label: t('capabilityActivity'), hint: t('capabilityActivityHint'), enabled: snapshot.value?.activityIndicatorEnabled ?? true, disabled: !snapshot.writable, setSetting: setSetting })] })] })] });
|
|
68
|
+
/** Show the fallback Fast toggle only when the session uses a non-Codex-Connect GPT model. */
|
|
69
|
+
export function isFallbackFastEligible(snapshot, hasDirectory) {
|
|
70
|
+
if (!hasDirectory)
|
|
71
|
+
return true;
|
|
72
|
+
if (snapshot?.status !== 'ready' || snapshot.current === undefined)
|
|
73
|
+
return false;
|
|
74
|
+
return snapshot.current.provider !== OPENAI_CODEX_PROVIDER && isGptModelName(snapshot.current.model);
|
|
139
75
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const
|
|
76
|
+
export function FastModeFallback(props) {
|
|
77
|
+
const { useSettings, setSetting, modelDirectory, t } = props;
|
|
78
|
+
const dirSnapshot = useModelDirectory(modelDirectory);
|
|
143
79
|
const snapshot = useSettings(state => state);
|
|
144
80
|
const visible = snapshot.value?.fastModeControlEnabled ?? true;
|
|
145
81
|
const fast = snapshot.value?.fast ?? false;
|
|
146
|
-
if (!visible)
|
|
82
|
+
if (!visible || !isFallbackFastEligible(dirSnapshot, modelDirectory !== undefined))
|
|
147
83
|
return null;
|
|
148
|
-
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: {
|
|
149
|
-
boxSizing: 'border-box',
|
|
150
|
-
display: 'inline-flex',
|
|
151
|
-
alignItems: 'center',
|
|
152
|
-
gap: 5,
|
|
153
|
-
height: 28,
|
|
154
|
-
border: 0,
|
|
155
|
-
borderRadius: 7,
|
|
156
|
-
padding: '0 6px',
|
|
157
|
-
color: fast ? 'var(--dsw-static-blue-500)' : 'var(--dsw-alias-label-secondary)',
|
|
158
|
-
background: fast ? 'var(--dsw-alias-interactive-bg-selected)' : 'transparent',
|
|
159
|
-
cursor: snapshot.writable === false ? 'default' : 'pointer',
|
|
160
|
-
font: 'inherit',
|
|
161
|
-
fontSize: 12,
|
|
162
|
-
lineHeight: '20px',
|
|
163
|
-
fontWeight: fast ? 600 : 400,
|
|
164
|
-
whiteSpace: 'nowrap',
|
|
165
|
-
}, children: [_jsx("span", { children: t('fast') }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11 }, children: fast ? t('fastStateOn') : t('fastStateOff') })] }));
|
|
84
|
+
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: pillStyle(fast, snapshot.writable !== false), children: [_jsx("span", { children: t('fast') }), _jsx("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 11 }, children: fast ? t('fastStateOn') : t('fastStateOff') })] }));
|
|
166
85
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
169
|
-
return pressure?.contextWindow !== undefined && pressure.contextWindow > 0
|
|
170
|
-
? pressure.contextWindow
|
|
171
|
-
: DEFAULT_CONTEXT_WINDOW;
|
|
172
|
-
}
|
|
173
|
-
/** Settings form appended to the old host's context meter panel. */
|
|
174
|
-
function ContextSizeControl({ contextWindow, sessionId: _sessionId, useSessions: _useSessions, useSettings, setSetting, unsetSetting, t, }) {
|
|
175
|
-
const snapshot = useSettings(state => state);
|
|
176
|
-
const configured = snapshot.value?.contextWindow;
|
|
177
|
-
const maxK = CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT;
|
|
178
|
-
const valueK = Math.min(maxK, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
|
|
179
|
-
const setValueK = (nextK) => {
|
|
180
|
-
if (!Number.isFinite(nextK))
|
|
181
|
-
return;
|
|
182
|
-
const normalizedK = Math.min(maxK, Math.max(1, Math.trunc(nextK)));
|
|
183
|
-
const normalized = normalizedK * CODEX_CONTEXT_UNIT;
|
|
184
|
-
if (normalized === contextWindow)
|
|
185
|
-
void unsetSetting('contextWindow');
|
|
186
|
-
else
|
|
187
|
-
void setSetting('contextWindow', normalized);
|
|
188
|
-
};
|
|
189
|
-
return (_jsxs("div", { style: {
|
|
190
|
-
display: 'grid',
|
|
191
|
-
gap: 8,
|
|
192
|
-
marginTop: 10,
|
|
193
|
-
paddingTop: 10,
|
|
194
|
-
borderTop: '1px solid var(--dsw-alias-border-l2)',
|
|
195
|
-
}, 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: {
|
|
196
|
-
display: 'block',
|
|
197
|
-
width: '100%',
|
|
198
|
-
accentColor: 'var(--dsw-static-blue-500)',
|
|
199
|
-
} }), _jsxs("div", { style: { display: 'grid', gap: 4 }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 6 }, children: [_jsx("input", { type: "number", min: 1, max: maxK, step: 1, value: valueK, disabled: snapshot.writable === false, "aria-label": t('contextSize'), onChange: event => { setValueK(Number(event.target.value)); }, style: {
|
|
200
|
-
width: 68,
|
|
201
|
-
border: '1px solid var(--dsw-alias-border-primary)',
|
|
202
|
-
borderRadius: 6,
|
|
203
|
-
padding: '4px 6px',
|
|
204
|
-
color: 'var(--dsw-alias-label-primary)',
|
|
205
|
-
background: 'var(--dsw-alias-fill-primary)',
|
|
206
|
-
font: 'inherit',
|
|
207
|
-
fontSize: 12,
|
|
208
|
-
fontVariantNumeric: 'tabular-nums',
|
|
209
|
-
} }), _jsx("span", { style: { color: 'var(--dsw-alias-label-secondary)', fontSize: 11 }, children: "K" })] }), _jsx("span", { style: { color: 'var(--dsw-alias-label-tertiary)', fontSize: 11, lineHeight: '16px' }, children: t('contextSizeDescription') })] }), configured !== undefined && (_jsx("button", { type: "button", onClick: () => { void unsetSetting('contextWindow'); }, style: {
|
|
210
|
-
justifySelf: 'start',
|
|
211
|
-
border: 0,
|
|
212
|
-
padding: 0,
|
|
213
|
-
color: 'var(--dsw-static-blue-500)',
|
|
214
|
-
background: 'transparent',
|
|
215
|
-
cursor: 'pointer',
|
|
216
|
-
font: 'inherit',
|
|
217
|
-
fontSize: 11,
|
|
218
|
-
}, children: t('contextRestore') }))] }));
|
|
219
|
-
}
|
|
220
|
-
/** Detect the host meter so the fallback does not duplicate its ring button. */
|
|
221
|
-
function hasHostContextMeter() {
|
|
222
|
-
if (typeof document === 'undefined')
|
|
223
|
-
return false;
|
|
224
|
-
return [...document.querySelectorAll('button[aria-haspopup="dialog"]')]
|
|
225
|
-
.some(button => button.querySelectorAll('circle').length >= 2);
|
|
226
|
-
}
|
|
227
|
-
function useHostContextMeter() {
|
|
228
|
-
const [available, setAvailable] = useState(false);
|
|
229
|
-
useEffect(() => {
|
|
230
|
-
if (typeof document === 'undefined' || document.body === null)
|
|
231
|
-
return undefined;
|
|
232
|
-
const refresh = () => { setAvailable(hasHostContextMeter()); };
|
|
233
|
-
refresh();
|
|
234
|
-
const observer = new MutationObserver(refresh);
|
|
235
|
-
observer.observe(document.body, {
|
|
236
|
-
subtree: true,
|
|
237
|
-
childList: true,
|
|
238
|
-
attributes: true,
|
|
239
|
-
attributeFilter: ['aria-expanded'],
|
|
240
|
-
});
|
|
241
|
-
return () => observer.disconnect();
|
|
242
|
-
}, []);
|
|
243
|
-
return available;
|
|
244
|
-
}
|
|
245
|
-
/** Keep context configuration reachable before the host has a pressure meter. */
|
|
246
|
-
function ContextSizeFallback({ sessionId, useSessions, useProjection, useSettings, setSetting, unsetSetting, t, }) {
|
|
247
|
-
const agentPreset = useSessions(state => state.byId[sessionId]?.agentPreset);
|
|
248
|
-
const hostMeter = useHostContextMeter();
|
|
249
|
-
const contextWindow = contextWindowFromProjection(useProjection);
|
|
250
|
-
const snapshot = useSettings(state => state);
|
|
251
|
-
const configured = snapshot.value?.contextWindow;
|
|
252
|
-
const valueK = Math.min(CODEX_CONTEXT_MAX / CODEX_CONTEXT_UNIT, Math.max(1, Math.round((configured ?? contextWindow) / CODEX_CONTEXT_UNIT)));
|
|
253
|
-
const [open, setOpen] = useState(false);
|
|
254
|
-
const rootRef = useRef(null);
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
if (!open)
|
|
257
|
-
return undefined;
|
|
258
|
-
const onPointerDown = (event) => {
|
|
259
|
-
if (event.target instanceof Node && rootRef.current?.contains(event.target) === true)
|
|
260
|
-
return;
|
|
261
|
-
setOpen(false);
|
|
262
|
-
};
|
|
263
|
-
const onKeyDown = (event) => {
|
|
264
|
-
if (event.key === 'Escape')
|
|
265
|
-
setOpen(false);
|
|
266
|
-
};
|
|
267
|
-
document.addEventListener('pointerdown', onPointerDown);
|
|
268
|
-
document.addEventListener('keydown', onKeyDown);
|
|
269
|
-
return () => {
|
|
270
|
-
document.removeEventListener('pointerdown', onPointerDown);
|
|
271
|
-
document.removeEventListener('keydown', onKeyDown);
|
|
272
|
-
};
|
|
273
|
-
}, [open]);
|
|
274
|
-
if (!isCodexPresetId(agentPreset) || hostMeter)
|
|
275
|
-
return null;
|
|
276
|
-
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: {
|
|
277
|
-
boxSizing: 'border-box',
|
|
278
|
-
display: 'inline-flex',
|
|
279
|
-
alignItems: 'center',
|
|
280
|
-
gap: 3,
|
|
281
|
-
height: 28,
|
|
282
|
-
border: 0,
|
|
283
|
-
borderRadius: 7,
|
|
284
|
-
padding: '0 6px',
|
|
285
|
-
color: configured === undefined
|
|
286
|
-
? 'var(--dsw-alias-label-secondary)'
|
|
287
|
-
: 'var(--dsw-static-blue-500)',
|
|
288
|
-
background: open ? 'var(--dsw-alias-interactive-bg-hover)' : 'transparent',
|
|
289
|
-
cursor: snapshot.writable === false ? 'default' : 'pointer',
|
|
290
|
-
font: 'inherit',
|
|
291
|
-
fontSize: 12,
|
|
292
|
-
lineHeight: '20px',
|
|
293
|
-
fontWeight: configured === undefined ? 400 : 600,
|
|
294
|
-
whiteSpace: 'nowrap',
|
|
295
|
-
}, 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: {
|
|
296
|
-
position: 'absolute',
|
|
297
|
-
right: 0,
|
|
298
|
-
bottom: 'calc(100% + 8px)',
|
|
299
|
-
zIndex: 20,
|
|
300
|
-
boxSizing: 'border-box',
|
|
301
|
-
width: 300,
|
|
302
|
-
maxWidth: 'calc(100vw - 24px)',
|
|
303
|
-
padding: '10px 12px 12px',
|
|
304
|
-
border: '1px solid var(--dsw-alias-border-l2)',
|
|
305
|
-
borderRadius: 10,
|
|
306
|
-
color: 'var(--dsw-alias-label-primary)',
|
|
307
|
-
background: 'var(--dsw-alias-bg-base)',
|
|
308
|
-
boxShadow: 'var(--dsw-shadow-lv2)',
|
|
309
|
-
}, children: _jsx(ContextSizeControl, { contextWindow: contextWindow, sessionId: sessionId, useSessions: useSessions, useSettings: useSettings, setSetting: setSetting, unsetSetting: unsetSetting, t: t }) }))] }));
|
|
86
|
+
export function ComposerControls(props) {
|
|
87
|
+
return _jsxs(_Fragment, { children: [_jsx(ContextWindowControl, { ...props }), _jsx(FastModeFallback, { ...props })] });
|
|
310
88
|
}
|
|
311
89
|
function elapsedSeconds(startedAt, now) {
|
|
312
90
|
return Math.max(0, Math.floor((now - startedAt) / 1_000));
|
|
313
91
|
}
|
|
314
|
-
/** Prefer the session snapshot when
|
|
92
|
+
/** Prefer the session snapshot when a projection has not emitted an open phase yet. */
|
|
315
93
|
export function resolveActivity(projectedActivity, fallbackActivity) {
|
|
316
|
-
if (projectedActivity?.activity === 'awaiting-model') {
|
|
317
|
-
return {
|
|
318
|
-
activity: fallbackActivity?.activity ?? 'requesting-model',
|
|
319
|
-
startedAt: fallbackActivity?.startedAt ?? projectedActivity.startedAt,
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
94
|
if (projectedActivity === null)
|
|
323
95
|
return fallbackActivity ?? null;
|
|
324
96
|
return projectedActivity ?? fallbackActivity ?? null;
|
|
325
97
|
}
|
|
326
|
-
export function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _useSessions, useProjection, useSettings, t,
|
|
98
|
+
export function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _useSessions, useProjection, useSettings, t, }) {
|
|
327
99
|
const settings = useSettings(state => state);
|
|
328
100
|
const enabled = settings.value?.activityIndicatorEnabled ?? true;
|
|
329
|
-
// Keep the projection seam optional: this package must still load when the
|
|
330
|
-
// host has no session-projection registry or has not carried this key.
|
|
331
101
|
const projectedActivity = useProjection('codexActivity');
|
|
332
|
-
// The projection is the authoritative phase and clock. The session snapshot
|
|
333
|
-
// fallback only covers the short wire gap before the next projection frame;
|
|
334
|
-
// tool calls intentionally remain silent because their cards own the status.
|
|
335
102
|
const fallbackActivity = useSession(modelActivity, sameModelActivity);
|
|
336
103
|
const activity = resolveActivity(projectedActivity, fallbackActivity);
|
|
337
104
|
const [now, setNow] = useState(() => Date.now());
|
|
@@ -350,164 +117,31 @@ export function ActivityLine({ sessionId: _sessionId, useSession, useSessions: _
|
|
|
350
117
|
? t('activityModelReply')
|
|
351
118
|
: t('activityRequestingModel');
|
|
352
119
|
return (_jsxs("span", { "data-codex-activity": true, "aria-live": "polite", style: {
|
|
353
|
-
|
|
120
|
+
boxSizing: 'border-box',
|
|
121
|
+
display: 'flex',
|
|
354
122
|
alignItems: 'center',
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
123
|
+
flex: 'none',
|
|
124
|
+
gap: 6,
|
|
125
|
+
width: 'calc(100% - 2 * var(--dsh-composer-side-clearance, 16px) - 4 * var(--dsh-composer-dock-inset, 8px))',
|
|
126
|
+
maxWidth: 'calc(var(--dsh-composer-card-max-width, 952px) - 4 * var(--dsh-composer-dock-inset, 8px))',
|
|
127
|
+
minWidth: 0,
|
|
128
|
+
minHeight: 22,
|
|
129
|
+
margin: '0 auto',
|
|
130
|
+
padding: '0 4px',
|
|
358
131
|
color: 'var(--dsw-alias-label-secondary)',
|
|
359
132
|
fontSize: 12,
|
|
360
133
|
lineHeight: '20px',
|
|
361
134
|
whiteSpace: 'nowrap',
|
|
362
|
-
|
|
363
|
-
...(position === undefined ? {} : {
|
|
364
|
-
position: 'fixed',
|
|
365
|
-
left: position.left,
|
|
366
|
-
top: position.top,
|
|
367
|
-
// Keep the overlay in the conversation layer. The host composer is
|
|
368
|
-
// sticky at z-index 7, so this follows the same occlusion rule as
|
|
369
|
-
// the native Deep diving status instead of floating above the input.
|
|
370
|
-
zIndex: 0,
|
|
371
|
-
pointerEvents: 'none',
|
|
372
|
-
}),
|
|
135
|
+
pointerEvents: 'none',
|
|
373
136
|
}, children: [_jsx("span", { "aria-hidden": "true", style: {
|
|
374
137
|
width: 5,
|
|
375
138
|
height: 5,
|
|
376
139
|
flex: '0 0 auto',
|
|
377
140
|
borderRadius: '50%',
|
|
378
|
-
background: 'var(--dsw-
|
|
141
|
+
background: 'var(--dsw-alias-brand-primary)',
|
|
379
142
|
opacity: 0.55,
|
|
380
|
-
} }), _jsx("span", { children: label }), _jsxs("span", { style: {
|
|
381
|
-
}
|
|
382
|
-
function findContextMeterDialog() {
|
|
383
|
-
const buttons = document.querySelectorAll('button[aria-haspopup="dialog"][aria-expanded="true"]');
|
|
384
|
-
for (const button of buttons) {
|
|
385
|
-
if (button.querySelectorAll('circle').length < 2)
|
|
386
|
-
continue;
|
|
387
|
-
let ancestor = button;
|
|
388
|
-
for (let depth = 0; ancestor !== null && depth < 5; depth += 1, ancestor = ancestor.parentElement) {
|
|
389
|
-
const dialog = ancestor.querySelector('[role="dialog"]');
|
|
390
|
-
if (dialog !== null)
|
|
391
|
-
return dialog;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
function isTurnStatus(status) {
|
|
397
|
-
return status.textContent?.includes('Deep diving...') === true
|
|
398
|
-
|| status.className.toString().includes('turnStatus');
|
|
399
|
-
}
|
|
400
|
-
function hasLayout(status) {
|
|
401
|
-
const rect = status.getBoundingClientRect();
|
|
402
|
-
return rect.width > 0 && rect.height > 0;
|
|
403
|
-
}
|
|
404
|
-
/** Prefer the actual Core turn status over unrelated global status nodes. */
|
|
405
|
-
export function selectTurnStatus(statuses) {
|
|
406
|
-
const preferred = statuses.filter(isTurnStatus);
|
|
407
|
-
return preferred.findLast(hasLayout)
|
|
408
|
-
?? preferred.at(-1)
|
|
409
|
-
?? statuses.filter(status => status.closest('[data-chat-flow]') !== null).findLast(hasLayout)
|
|
410
|
-
?? statuses.filter(status => status.closest('[data-chat-flow]') !== null).at(-1)
|
|
411
|
-
?? null;
|
|
412
|
-
}
|
|
413
|
-
function findTurnStatus() {
|
|
414
|
-
return selectTurnStatus([...document.querySelectorAll('[role="status"]')]);
|
|
415
|
-
}
|
|
416
|
-
function useTurnStatusPosition(target) {
|
|
417
|
-
const [position, setPosition] = useState(null);
|
|
418
|
-
useLayoutEffect(() => {
|
|
419
|
-
if (target === null) {
|
|
420
|
-
setPosition(null);
|
|
421
|
-
return undefined;
|
|
422
|
-
}
|
|
423
|
-
let frame;
|
|
424
|
-
let previous = null;
|
|
425
|
-
const update = () => {
|
|
426
|
-
if (!target.isConnected) {
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
const rect = target.getBoundingClientRect();
|
|
430
|
-
if (rect.width === 0 && rect.height === 0) {
|
|
431
|
-
if (previous !== null) {
|
|
432
|
-
previous = null;
|
|
433
|
-
setPosition(null);
|
|
434
|
-
}
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
const next = {
|
|
438
|
-
left: Math.round(rect.right + 10),
|
|
439
|
-
top: Math.round(rect.top + (rect.height - 26) / 2),
|
|
440
|
-
};
|
|
441
|
-
if (previous?.left === next.left && previous.top === next.top)
|
|
442
|
-
return;
|
|
443
|
-
previous = next;
|
|
444
|
-
setPosition(next);
|
|
445
|
-
};
|
|
446
|
-
const track = () => {
|
|
447
|
-
if (!target.isConnected) {
|
|
448
|
-
previous = null;
|
|
449
|
-
setPosition(null);
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
// Streaming rows can be inserted above the status without resizing the
|
|
453
|
-
// status element itself; a ResizeObserver alone would leave the overlay
|
|
454
|
-
// at its first position.
|
|
455
|
-
update();
|
|
456
|
-
frame = window.requestAnimationFrame(track);
|
|
457
|
-
};
|
|
458
|
-
update();
|
|
459
|
-
frame = window.requestAnimationFrame(track);
|
|
460
|
-
window.addEventListener('resize', update);
|
|
461
|
-
window.addEventListener('scroll', update, true);
|
|
462
|
-
const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(update);
|
|
463
|
-
observer?.observe(target);
|
|
464
|
-
return () => {
|
|
465
|
-
if (frame !== undefined)
|
|
466
|
-
window.cancelAnimationFrame(frame);
|
|
467
|
-
window.removeEventListener('resize', update);
|
|
468
|
-
window.removeEventListener('scroll', update, true);
|
|
469
|
-
observer?.disconnect();
|
|
470
|
-
};
|
|
471
|
-
}, [target]);
|
|
472
|
-
return position;
|
|
473
|
-
}
|
|
474
|
-
function useLegacyHostTargets() {
|
|
475
|
-
const [targets, setTargets] = useState({ contextDialog: null, turnStatus: null });
|
|
476
|
-
useEffect(() => {
|
|
477
|
-
if (typeof document === 'undefined' || document.body === null)
|
|
478
|
-
return undefined;
|
|
479
|
-
const refresh = () => {
|
|
480
|
-
const next = {
|
|
481
|
-
contextDialog: findContextMeterDialog(),
|
|
482
|
-
turnStatus: findTurnStatus(),
|
|
483
|
-
};
|
|
484
|
-
setTargets(current => current.contextDialog === next.contextDialog
|
|
485
|
-
&& current.turnStatus === next.turnStatus ? current : next);
|
|
486
|
-
};
|
|
487
|
-
refresh();
|
|
488
|
-
const observer = new MutationObserver(refresh);
|
|
489
|
-
observer.observe(document.body, {
|
|
490
|
-
subtree: true,
|
|
491
|
-
childList: true,
|
|
492
|
-
attributes: true,
|
|
493
|
-
attributeFilter: ['aria-expanded'],
|
|
494
|
-
});
|
|
495
|
-
return () => observer.disconnect();
|
|
496
|
-
}, []);
|
|
497
|
-
return targets;
|
|
498
|
-
}
|
|
499
|
-
/** Bridges plugin UI into DOM sites rendered by the legacy conversation host. */
|
|
500
|
-
function LegacyOverlay(props) {
|
|
501
|
-
const { sessionId, useSession, useSessions, useProjection, useSettings, setSetting, unsetSetting, t, } = props;
|
|
502
|
-
const { contextDialog, turnStatus } = useLegacyHostTargets();
|
|
503
|
-
const turnStatusPosition = useTurnStatusPosition(turnStatus);
|
|
504
|
-
const contextWindow = contextWindowFromProjection(useProjection);
|
|
505
|
-
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')] }));
|
|
143
|
+
} }), _jsx("span", { style: { minWidth: 0, overflow: 'hidden', textOverflow: 'ellipsis' }, children: label }), _jsxs("span", { "aria-hidden": "true", style: { flex: '0 0 auto', fontVariantNumeric: 'tabular-nums' }, children: ['\u00b7', " ", elapsedSeconds(activity.startedAt, now), "s"] })] }));
|
|
506
144
|
}
|
|
507
|
-
export const inject = [
|
|
508
|
-
'commandUi', 'sessions', 'slots', 'locale', 'settingsScope',
|
|
509
|
-
'remote', 'remote.agentPresets', 'remote.settings',
|
|
510
|
-
];
|
|
511
145
|
function createPresetManager(ctx) {
|
|
512
146
|
const remote = ctx.remote;
|
|
513
147
|
const ready = remote === undefined
|
|
@@ -515,41 +149,13 @@ function createPresetManager(ctx) {
|
|
|
515
149
|
: remote.$mount(presetEditorRemote).then(dispose => {
|
|
516
150
|
ctx.effect(() => () => { void dispose(); }, 'codex client: preset editor remote');
|
|
517
151
|
});
|
|
518
|
-
// Keep an unavailable optional host remote from becoming an unhandled rejection
|
|
519
|
-
// when the settings card is never opened. The card still awaits the same promise
|
|
520
|
-
// and renders the actual error if the user opens it.
|
|
521
152
|
void ready.catch(() => { });
|
|
522
153
|
return {
|
|
523
154
|
remote: remote,
|
|
524
155
|
ready,
|
|
525
156
|
};
|
|
526
157
|
}
|
|
527
|
-
|
|
528
|
-
* The Codex editor contribution is mounted by this client entry itself. Its
|
|
529
|
-
* namespace therefore cannot be a top-level dependency (that would make the
|
|
530
|
-
* entry wait for the contribution it is responsible for mounting). Wait for
|
|
531
|
-
* the namespace in a child fiber instead, and capture that protected Remote
|
|
532
|
-
* face for the settings card.
|
|
533
|
-
*/
|
|
534
|
-
function registerPresetSettingsCard(ctx, settings, presetManager) {
|
|
535
|
-
const settingsPresetManager = {
|
|
536
|
-
...presetManager,
|
|
537
|
-
remote: ctx.remote,
|
|
538
|
-
};
|
|
539
|
-
return ctx.slots.inject(PLUGIN_SETTINGS_SLOT, () => ctx.slots.register({
|
|
540
|
-
name: PLUGIN_SETTINGS_SLOT,
|
|
541
|
-
key: SETTINGS_NAMESPACE,
|
|
542
|
-
locale: NS,
|
|
543
|
-
inject: () => ({
|
|
544
|
-
hooks: { settings },
|
|
545
|
-
setSetting: (field, value) => settings.set(field, value),
|
|
546
|
-
unsetSetting: (field) => settings.unset(field),
|
|
547
|
-
presetManager: settingsPresetManager,
|
|
548
|
-
}),
|
|
549
|
-
}, PromptSettingsCard));
|
|
550
|
-
}
|
|
551
|
-
/** Mount request controls and the plugin settings card through shared slots. */
|
|
552
|
-
export function apply(ctx) {
|
|
158
|
+
export function applyWithSettingsApi(ctx, api) {
|
|
553
159
|
ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'codex client: dictionaries');
|
|
554
160
|
const commandUi = ctx.get('commandUi');
|
|
555
161
|
const sessions = ctx.get('sessions');
|
|
@@ -564,19 +170,25 @@ export function apply(ctx) {
|
|
|
564
170
|
{ id: 'remote', label: t('compactRemote'), detail: t('compactRemoteHint') },
|
|
565
171
|
{ id: 'local', label: t('compactLocal'), detail: t('compactLocalHint') },
|
|
566
172
|
],
|
|
567
|
-
onSelect:
|
|
173
|
+
onSelect: (option, session) => {
|
|
568
174
|
const live = sessionFor(session);
|
|
569
175
|
if (live === undefined)
|
|
570
176
|
throw new Error('this session is not materialized yet');
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
177
|
+
void live.command(`/compact ${option.id}`).then(result => {
|
|
178
|
+
if (!result.ok) {
|
|
179
|
+
notifyCompactError(sessions, session.sessionId, `compact failed: ${result.error.code}: ${result.error.message}`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (!result.value.matched) {
|
|
183
|
+
notifyCompactError(sessions, session.sessionId, 'the host offers no /compact command');
|
|
184
|
+
}
|
|
185
|
+
}, error => {
|
|
186
|
+
notifyCompactError(sessions, session.sessionId, error instanceof Error ? error.message : String(error));
|
|
187
|
+
});
|
|
576
188
|
},
|
|
577
189
|
},
|
|
578
190
|
}), 'codex client: /compact mode picker');
|
|
579
|
-
const settings =
|
|
191
|
+
const settings = api.bind(ctx);
|
|
580
192
|
const presetManager = createPresetManager(ctx);
|
|
581
193
|
const injected = () => ({
|
|
582
194
|
hooks: { settings },
|
|
@@ -589,26 +201,21 @@ export function apply(ctx) {
|
|
|
589
201
|
id: 'codex-fast',
|
|
590
202
|
order: 0,
|
|
591
203
|
locale: NS,
|
|
592
|
-
inject:
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
order: 0,
|
|
204
|
+
inject: (sessionId) => ({
|
|
205
|
+
...injected(),
|
|
206
|
+
getCodexConnectScope: api.getCodexConnectScope,
|
|
207
|
+
modelDirectory: sessionId === undefined
|
|
208
|
+
? undefined
|
|
209
|
+
: (ctx.get('modelDirectories'))?.directoryFor(sessionId)?.store,
|
|
210
|
+
}),
|
|
211
|
+
}, ComposerControls));
|
|
212
|
+
ctx.slots.inject('conversation.input.dock', () => ctx.slots.register({
|
|
213
|
+
name: 'conversation.input.dock',
|
|
214
|
+
id: 'codex-activity',
|
|
215
|
+
order: -100,
|
|
605
216
|
locale: NS,
|
|
606
217
|
inject: injected,
|
|
607
|
-
},
|
|
608
|
-
|
|
609
|
-
// namespace dependency local to the settings card so the main client entry
|
|
610
|
-
// can start and perform that mount first.
|
|
611
|
-
ctx.inject(['remote', 'remote.agentPresets', 'remote.settings', 'remote.codexPresetEditor'], settingsCtx => registerPresetSettingsCard(settingsCtx, settings, presetManager));
|
|
218
|
+
}, ActivityLine));
|
|
219
|
+
ctx.inject(['remote', 'remote.codexPresetEditor'], settingsCtx => api.register(settingsCtx, settings, presetManager));
|
|
612
220
|
}
|
|
613
|
-
export default { inject, apply };
|
|
614
221
|
//# sourceMappingURL=index.js.map
|