dsh-deep-ptc-mode 1.8.2 → 1.8.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/CHANGELOG.md +51 -0
- package/LICENSE +0 -0
- package/README.md +43 -10
- package/README.zh.md +43 -10
- package/TEST_REPORT.md +0 -0
- package/assets/icon.png +0 -0
- package/compatibility.json +0 -0
- package/cordis.patch.yml +0 -0
- package/lib/adapt.mjs +0 -0
- package/lib/ask-user.mjs +0 -0
- package/lib/base-snapshot.json +0 -0
- package/lib/client.js +1123 -25
- package/lib/creative.mjs +0 -0
- package/lib/environment.mjs +0 -0
- package/lib/executor.mjs +0 -0
- package/lib/freshness.mjs +31 -0
- package/lib/guard.mjs +0 -0
- package/lib/host.mjs +0 -0
- package/lib/index.mjs +45 -16
- package/lib/jobs-tool.mjs +0 -0
- package/lib/lab.mjs +0 -0
- package/lib/lifecycle.mjs +0 -0
- package/lib/model.mjs +0 -0
- package/lib/official-names.mjs +0 -0
- package/lib/preset-compat.mjs +5 -3
- package/lib/preset.json +2 -2
- package/lib/reachable.mjs +0 -0
- package/lib/resident.mjs +0 -0
- package/lib/rules.mjs +0 -0
- package/lib/shells.mjs +0 -0
- package/lib/skill-card.mjs +217 -0
- package/lib/skill-context.mjs +89 -0
- package/lib/sleep-lint.mjs +0 -0
- package/lib/terminal.mjs +0 -0
- package/lib/tool-catalog.mjs +0 -0
- package/lib/tool-compatibility.mjs +14 -14
- package/lib/tool-policy.mjs +7 -2
- package/lib/tool-state.mjs +51 -0
- package/package.json +2 -1
package/lib/client.js
CHANGED
|
@@ -12,7 +12,6 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
12
12
|
distribution: 'WSL 发行版', distributionHint: '留空使用 Windows 的默认发行版,例如 Ubuntu。',
|
|
13
13
|
shell: 'Shell 版本', shellAuto: '自动(沿用官方查找顺序)',
|
|
14
14
|
shellHint: '只列出本机已发现的常见版本。文件消失后自动回退。WSL 仍只选择发行版。',
|
|
15
|
-
pluginLab: '插件实验台', pluginLabHint: '默认关闭。打开后在内存中检查、定义并经宿主批准后运行插件,不改已发布预设,也不绕过批准。',
|
|
16
15
|
sessions: '保存后请新建一个“深度PTC模式”会话。已有会话与后台任务保留原环境。',
|
|
17
16
|
wslHint: 'WSL 暂不支持 Windows 的受限沙箱;受限调用会明确失败,不会自动切换或绕过限制。',
|
|
18
17
|
save: '保存', saving: '保存中…', saved: '已保存,新会话将使用所选环境。',
|
|
@@ -27,7 +26,6 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
27
26
|
distribution: 'WSL distribution', distributionHint: 'Leave blank for the Windows default distribution, for example Ubuntu.',
|
|
28
27
|
shell: 'Shell version', shellAuto: 'Automatic (official lookup)',
|
|
29
28
|
shellHint: 'Lists common executables found on this machine. A missing file falls back to automatic. WSL still selects a distribution only.',
|
|
30
|
-
pluginLab: 'Plugin lab', pluginLabHint: 'Off by default. When on, inspect, define and run plugins in memory through host approval. Shipped presets stay unchanged.',
|
|
31
29
|
sessions: 'After saving, create a new Deep PTC session. Existing sessions and background jobs keep their environment.',
|
|
32
30
|
wslHint: 'WSL does not support the confined Windows sandbox. Confined calls fail without execution or fallback.',
|
|
33
31
|
save: 'Save', saving: 'Saving…', saved: 'Saved. New sessions will use this environment.',
|
|
@@ -43,7 +41,6 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
43
41
|
const [environment, setEnvironment] = React.useState('auto');
|
|
44
42
|
const [distribution, setDistribution] = React.useState('');
|
|
45
43
|
const [shellExecutable, setShellExecutable] = React.useState('');
|
|
46
|
-
const [pluginLab, setPluginLab] = React.useState(false);
|
|
47
44
|
const [saving, setSaving] = React.useState(false);
|
|
48
45
|
const [message, setMessage] = React.useState('');
|
|
49
46
|
const [failed, setFailed] = React.useState(false);
|
|
@@ -54,7 +51,6 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
54
51
|
setEnvironment(state.value.environment);
|
|
55
52
|
setDistribution(state.value.wslDistribution ?? '');
|
|
56
53
|
setShellExecutable(state.value.shellExecutable ?? '');
|
|
57
|
-
setPluginLab(state.value.pluginLab === true);
|
|
58
54
|
draftRevision.current = state.revision;
|
|
59
55
|
}, [state.value, state.revision]);
|
|
60
56
|
if (view === 'summary') return t('summary');
|
|
@@ -75,7 +71,6 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
75
71
|
{ op: 'set', path: ['environment'], value: environment },
|
|
76
72
|
{ op: 'set', path: ['wslDistribution'], value: distribution.trim() },
|
|
77
73
|
{ op: 'set', path: ['shellExecutable'], value: shellExecutable },
|
|
78
|
-
{ op: 'set', path: ['pluginLab'], value: pluginLab },
|
|
79
74
|
], draftRevision.current);
|
|
80
75
|
if (!ok) throw new Error('Configuration was rejected');
|
|
81
76
|
dirty.current = false;
|
|
@@ -84,7 +79,6 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
84
79
|
setEnvironment(latest.value?.environment ?? environment);
|
|
85
80
|
setDistribution(latest.value?.wslDistribution ?? distribution.trim());
|
|
86
81
|
setShellExecutable(latest.value?.shellExecutable ?? shellExecutable);
|
|
87
|
-
setPluginLab(latest.value?.pluginLab === true);
|
|
88
82
|
setMessage(t('saved'));
|
|
89
83
|
} catch {
|
|
90
84
|
draftRevision.current = form.getSnapshot().revision;
|
|
@@ -117,11 +111,6 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
117
111
|
h('option', { value: '' }, t('shellAuto')),
|
|
118
112
|
...choices.map(item => h('option', { key: item.id, value: item.id }, item.label))),
|
|
119
113
|
h('p', null, t('shellHint'))) : null,
|
|
120
|
-
h('label', { htmlFor: 'deep-ptc-plugin-lab' },
|
|
121
|
-
h('input', { id: 'deep-ptc-plugin-lab', type: 'checkbox', checked: pluginLab, disabled,
|
|
122
|
-
onChange: event => { changed(); setPluginLab(event.target.checked); } }),
|
|
123
|
-
' ', t('pluginLab')),
|
|
124
|
-
h('p', null, t('pluginLabHint')),
|
|
125
114
|
h('p', null, t('sessions')),
|
|
126
115
|
!state.writable ? h('p', { role: 'status' }, t('readOnly')) : null,
|
|
127
116
|
message ? h('p', { role: failed ? 'alert' : 'status' }, message) : null,
|
|
@@ -129,19 +118,20 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
129
118
|
);
|
|
130
119
|
}
|
|
131
120
|
|
|
132
|
-
function ToolStateControls({ useProjection, reset, t }) {
|
|
121
|
+
function ToolStateControls({ sessionId, useProjection, reset, t }) {
|
|
133
122
|
const [busy, setBusy] = React.useState(false);
|
|
134
123
|
const [message, setMessage] = React.useState('');
|
|
135
124
|
const generation = React.useRef(0);
|
|
136
|
-
React.useEffect(() => { generation.current++; setBusy(false); setMessage(''); return () => { generation.current++; }; }, [
|
|
125
|
+
React.useEffect(() => { generation.current++; setBusy(false); setMessage(''); return () => { generation.current++; }; }, [sessionId]);
|
|
137
126
|
let preset, state;
|
|
138
127
|
try {
|
|
139
128
|
if (typeof useProjection !== 'function') return null;
|
|
140
129
|
preset = useProjection('agentPreset');
|
|
141
130
|
state = useProjection('deepPtcTools');
|
|
142
131
|
} catch { return null; }
|
|
143
|
-
if (preset !== 'deep-ptc'
|
|
144
|
-
|
|
132
|
+
if (preset !== 'deep-ptc') return null;
|
|
133
|
+
// The failure list needs the tool-state projection; the reset command does not.
|
|
134
|
+
const failed = state && typeof state === 'object' ? state.report?.tools ?? [] : [];
|
|
145
135
|
async function reload() {
|
|
146
136
|
const current = generation.current;
|
|
147
137
|
setBusy(true); setMessage('');
|
|
@@ -156,14 +146,16 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
156
146
|
} catch (error) { if (current === generation.current) setMessage(t('toolResetFailed') + ': ' + String(error?.message ?? error).slice(0,220)); }
|
|
157
147
|
finally { if (current === generation.current) setBusy(false); }
|
|
158
148
|
}
|
|
159
|
-
return h('
|
|
160
|
-
|
|
161
|
-
h('
|
|
149
|
+
return h('section', { className: 'dpt-side-section dpt-side-tools', 'aria-label': t('toolsSection') },
|
|
150
|
+
h('div', { className: 'dpt-side-label' }, h('span', null, t('toolsSection')),
|
|
151
|
+
failed.length ? h('span', { className: 'dpt-side-hint', 'data-tone': 'warn' }, `${t('toolFailures')} ${failed.length}`) : null),
|
|
152
|
+
failed.length ? h('div', { className: 'dpt-tool-failures', role: 'status' },
|
|
162
153
|
h('p', null, t('toolFailureHint')),
|
|
163
|
-
h('ul', null, ...failed.map(row => h('li', { key: row.name },
|
|
164
|
-
h('button', { type: 'button', onClick: reload, disabled: busy, title: t('toolResetHint'),
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
h('ul', null, ...failed.map(row => h('li', { key: row.name }, h('code', null, row.name), ` — ${row.provider}`)))) : null,
|
|
155
|
+
h('button', { type: 'button', className: 'dpt-btn dpt-btn-block', onClick: reload, disabled: busy, title: t('toolResetHint'), 'aria-busy': busy },
|
|
156
|
+
busy ? t('toolResetBusy') : t('toolReset')),
|
|
157
|
+
h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message ? (message === t('toolResetDone') ? 'ok' : 'error') : undefined },
|
|
158
|
+
message || t('toolResetHint')));
|
|
167
159
|
}
|
|
168
160
|
Object.assign(dictionaries.zh, {
|
|
169
161
|
toolReset: '重载所有工具状态', toolResetBusy: '正在重载…', toolResetDone: '本对话工具状态已重载。',
|
|
@@ -175,20 +167,1126 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
175
167
|
toolResetFailed: 'Reload failed. Check the connection and access permissions.', toolResetHint: 'Clear quarantine and on-demand selections in this conversation. Running jobs continue.',
|
|
176
168
|
toolFailures: 'Tool compatibility notice', toolFailureHint: 'These external tools failed and may have compatibility issues. They are disabled in this conversation. Continue with working alternatives; no root-cause investigation was performed.',
|
|
177
169
|
});
|
|
170
|
+
Object.assign(dictionaries.zh, {
|
|
171
|
+
skillTitle: '当前上下文中的 Skill', skillLoaded: '{count} 个已加载', skillClosing: '{count} 个将在下一条消息后移除',
|
|
172
|
+
skillHint: '关闭的 Skill 会在你发送下一条消息时移出上下文,历史记录不受影响。',
|
|
173
|
+
skillKeepAll: '全部保留', skillCloseAll: '全部关闭', skillNoDescription: '无描述', skillThisTurn: '本轮',
|
|
174
|
+
skillShowAll: '显示全部 {count} 个', skillShowLess: '收起',
|
|
175
|
+
agentsTitle: '子代理', agentsRunning: '{count} 个运行中', agentsCompleted: '{count} 个已完成', agentsIdle: '{count} 个空闲',
|
|
176
|
+
agentRunning: '运行中', agentCompleted: '已完成', agentIdle: '空闲', agentExternal: '外部',
|
|
177
|
+
agentsCollapse: '收起侧边卡片', agentsExpand: '展开侧边卡片', agentOpen: '在右侧栏打开这个子代理的对话',
|
|
178
|
+
sideTitle: '深度 PTC', toolsSection: '工具状态', envAuto: '自动', envForNew: '新会话生效', envThisSession: '本会话保持创建时的环境。',
|
|
179
|
+
envAutoNow: '当前按自动选择:{env}。本会话保持创建时的环境。', envSaved: '已保存,之后新建的会话使用 {env}。',
|
|
180
|
+
envFailed: '未能保存,请检查发行版名称或设置是否已在别处修改。', envDefaultDistribution: '默认发行版',
|
|
181
|
+
durationSeconds: '{s} 秒', durationMinutes: '{m} 分 {s} 秒', durationHours: '{h} 小时 {m} 分', tokens: '{value} tokens',
|
|
182
|
+
palTitle: '命令面板', palPlaceholder: '搜索会话,或输入命令…', palEmpty: '没有匹配的结果', palFoot: '↑↓ 选择 ↵ 打开 Esc 关闭',
|
|
183
|
+
palCommand: '命令', palEffect: '特效', palSession: '会话', palNewSub: '开始一个新的对话', palPluginsSub: '打开插件页面',
|
|
184
|
+
palAutomationSub: '打开自动化任务', palAgents: '侧边卡片:展开 / 收起', palAgentsSub: '执行环境与子代理',
|
|
185
|
+
palFireworks: '放烟花', palFireworksSub: '庆祝一下',
|
|
186
|
+
});
|
|
187
|
+
Object.assign(dictionaries.en, {
|
|
188
|
+
skillTitle: 'Skills in context', skillLoaded: '{count} loaded', skillClosing: '{count} leave after your next message',
|
|
189
|
+
skillHint: 'A closed skill leaves the model context when you send your next message. The history stays complete.',
|
|
190
|
+
skillKeepAll: 'Keep all', skillCloseAll: 'Close all', skillNoDescription: 'No description', skillThisTurn: 'this turn',
|
|
191
|
+
skillShowAll: 'Show all {count}', skillShowLess: 'Show less',
|
|
192
|
+
agentsTitle: 'Subagents', agentsRunning: '{count} running', agentsCompleted: '{count} done', agentsIdle: '{count} idle',
|
|
193
|
+
agentRunning: 'Running', agentCompleted: 'Done', agentIdle: 'Idle', agentExternal: 'External',
|
|
194
|
+
agentsCollapse: 'Collapse the side card', agentsExpand: 'Expand the side card', agentOpen: 'Open this subagent in the right sidebar',
|
|
195
|
+
sideTitle: 'Deep PTC', toolsSection: 'Tool state', envAuto: 'Auto', envForNew: 'for new sessions', envThisSession: 'This session keeps the environment it was created with.',
|
|
196
|
+
envAutoNow: 'Automatic picks {env}. This session keeps the environment it was created with.', envSaved: 'Saved. New sessions use {env}.',
|
|
197
|
+
envFailed: 'Could not save. Check the distribution name, or whether settings changed elsewhere.', envDefaultDistribution: 'Default distribution',
|
|
198
|
+
durationSeconds: '{s}s', durationMinutes: '{m}m {s}s', durationHours: '{h}h {m}m', tokens: '{value} tokens',
|
|
199
|
+
palTitle: 'Command palette', palPlaceholder: 'Search sessions or type a command…', palEmpty: 'No matches', palFoot: '↑↓ select ↵ open Esc close',
|
|
200
|
+
palCommand: 'Command', palEffect: 'Effect', palSession: 'Session', palNewSub: 'Start a new conversation', palPluginsSub: 'Open plugins',
|
|
201
|
+
palAutomationSub: 'Open automations', palAgents: 'Side card: expand / collapse', palAgentsSub: 'Execution environment and subagents',
|
|
202
|
+
palFireworks: 'Fireworks', palFireworksSub: 'Celebrate',
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Placeholders are filled here, so the text is right whether or not the host locale interpolates.
|
|
206
|
+
const fill = (text, values) => String(text).replace(/\{(\w+)\}/gu, (whole, key) => values[key] === undefined ? whole : String(values[key]));
|
|
207
|
+
const tf = (t, key, values) => fill(t(key, values), values);
|
|
208
|
+
let T = key => key;
|
|
209
|
+
let hostCtx;
|
|
210
|
+
let ReactDOM;
|
|
211
|
+
try { ReactDOM = require('react-dom'); } catch { ReactDOM = undefined; }
|
|
212
|
+
const canPortal = () => typeof ReactDOM?.createPortal === 'function' && typeof document !== 'undefined';
|
|
213
|
+
|
|
214
|
+
// ---------------------------------------------------------------------------------------------
|
|
215
|
+
// Stylesheet. The cards are only rendered in Deep PTC sessions. The refined look and its motion
|
|
216
|
+
// (ported from dsh-refined-ui, without its floating task windows) apply only while the
|
|
217
|
+
// conversation on screen is a Deep PTC session: every rule is scoped by body[data-dpt-ui].
|
|
218
|
+
// ---------------------------------------------------------------------------------------------
|
|
219
|
+
const PLUGIN = 'dsh-deep-ptc-mode';
|
|
220
|
+
const ON = 'body[data-dpt-ui]';
|
|
221
|
+
const ON0 = ':where(body[data-dpt-ui])';
|
|
222
|
+
const DARK = 'body[data-ds-dark-theme]:not([data-ds-dark-theme="false"])';
|
|
223
|
+
const ON_DARK = 'body[data-dpt-ui][data-ds-dark-theme]:not([data-ds-dark-theme="false"])';
|
|
224
|
+
const CARD_CSS = `
|
|
225
|
+
.dpt-card,.dpt-agents,.dpt-agents-pill{--dpt-accent:var(--dpt-brand,#3370ff);--dpt-ease:cubic-bezier(.22,1,.36,1)}
|
|
226
|
+
.dpt-card{--dpt-card-fill:var(--dsw-static-neutral-50,#f7f8fa);box-sizing:border-box;width:100%;margin:2px 0 4px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);border-radius:var(--dsw-radius-lg,16px);background:var(--dpt-card-fill);color:var(--dsw-alias-label-primary,#101828);font-size:13px;line-height:20px;overflow:hidden;animation:dpt-rise 220ms var(--dpt-ease) both}
|
|
227
|
+
${DARK} .dpt-card{--dpt-card-fill:var(--dsw-static-neutral-850,#1a1f29)}
|
|
228
|
+
.dpt-card-head{display:flex;align-items:center;gap:10px;padding:10px 12px 6px}
|
|
229
|
+
.dpt-card-icon{flex:none;display:grid;place-items:center;width:32px;height:32px;box-sizing:border-box;border-radius:10px;border:.5px solid color-mix(in srgb,var(--dpt-accent) 22%,transparent);background:color-mix(in srgb,var(--dpt-accent) 10%,transparent);color:var(--dpt-accent)}
|
|
230
|
+
.dpt-card-titles{flex:1;min-width:0;display:flex;flex-direction:column}
|
|
231
|
+
.dpt-card-title{font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
232
|
+
.dpt-card-sub{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
233
|
+
.dpt-card-sub [data-tone="warn"]{color:var(--dsw-alias-state-warn-primary,#b45309)}
|
|
234
|
+
.dpt-card-actions{flex:none;display:flex;gap:6px}
|
|
235
|
+
.dpt-btn{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;height:26px;padding:0 10px;border:.5px solid var(--dsw-alias-border-l3,#c9d0db);border-radius:var(--dsw-radius-sm,8px);background:var(--dsw-alias-button-floating-fill,#fff);color:var(--dsw-alias-label-primary,#101828);font:inherit;font-size:12px;line-height:18px;white-space:nowrap;cursor:pointer;transition:background-color 120ms,border-color 120ms,opacity 120ms}
|
|
236
|
+
.dpt-btn:hover:not(:disabled){background:var(--dsw-alias-button-floating-hover,var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05)))}
|
|
237
|
+
.dpt-btn:disabled{opacity:.45;cursor:default}
|
|
238
|
+
.dpt-btn[aria-busy="true"]{cursor:wait}
|
|
239
|
+
.dpt-btn:focus-visible,.dpt-switch:focus-visible,.dpt-agent:focus-visible,.dpt-icon-btn:focus-visible,.dpt-link:focus-visible,.dpt-agents-pill:focus-visible{outline:2px solid var(--dpt-accent,#3370ff);outline-offset:2px}
|
|
240
|
+
.dpt-skill-list{list-style:none;margin:0;padding:0 4px 4px;display:flex;flex-direction:column;gap:2px}
|
|
241
|
+
.dpt-skill{display:flex;align-items:center;gap:12px;padding:7px 8px 7px 10px;border-radius:10px;transition:background-color 120ms}
|
|
242
|
+
.dpt-skill:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
|
|
243
|
+
.dpt-skill-text{flex:1;min-width:0;display:flex;flex-direction:column;transition:opacity 160ms}
|
|
244
|
+
.dpt-skill[data-off] .dpt-skill-text{opacity:.5}
|
|
245
|
+
.dpt-skill-name{display:flex;align-items:center;gap:6px;min-width:0;font-family:var(--ds-font-family-code,ui-monospace,Consolas,monospace);font-size:12.5px;font-weight:500;line-height:20px}
|
|
246
|
+
.dpt-skill-name>span:first-child{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
247
|
+
.dpt-skill[data-off] .dpt-skill-name>span:first-child{text-decoration:line-through;text-decoration-color:var(--dsw-alias-label-tertiary,#667085)}
|
|
248
|
+
.dpt-tag{flex:none;font-family:var(--ds-font-family,inherit);font-size:10px;line-height:16px;padding:0 6px;border-radius:999px;font-weight:500;background:color-mix(in srgb,var(--dpt-accent) 12%,transparent);color:var(--dpt-accent)}
|
|
249
|
+
.dpt-skill-desc{font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
250
|
+
.dpt-switch{position:relative;flex:none;width:32px;height:18px;padding:0;border:0;border-radius:999px;background:var(--dsw-alias-border-l2,#cfd5df);cursor:pointer;transition:background-color 160ms var(--dpt-ease,ease)}
|
|
251
|
+
.dpt-switch[aria-checked="true"]{background:var(--dpt-accent,#3370ff)}
|
|
252
|
+
.dpt-switch:disabled{opacity:.5;cursor:default}
|
|
253
|
+
.dpt-switch-thumb{position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgba(16,24,40,.28);transition:transform 160ms var(--dpt-ease,ease)}
|
|
254
|
+
.dpt-switch[aria-checked="true"] .dpt-switch-thumb{transform:translateX(14px)}
|
|
255
|
+
.dpt-card-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0;padding:8px 14px 10px;border-top:.5px solid var(--dsw-alias-border-l1,#e3e7ee);font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085)}
|
|
256
|
+
.dpt-link{flex:none;border:0;background:none;padding:0;font:inherit;color:var(--dpt-accent,#3370ff);cursor:pointer}
|
|
257
|
+
.dpt-agents{position:fixed;z-index:40;box-sizing:border-box;width:248px;display:flex;flex-direction:column;border-radius:16px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);background:color-mix(in srgb,var(--dsw-alias-bg-base,#fff) 88%,transparent);-webkit-backdrop-filter:blur(16px) saturate(1.2);backdrop-filter:blur(16px) saturate(1.2);box-shadow:0 10px 30px rgba(16,24,40,.08),0 1px 3px rgba(16,24,40,.06);color:var(--dsw-alias-label-primary,#101828);font-size:13px;line-height:20px;overflow:hidden;animation:dpt-rise 220ms var(--dpt-ease) both}
|
|
258
|
+
${DARK} .dpt-agents,${DARK} .dpt-agents-pill{box-shadow:0 10px 30px rgba(0,0,0,.45),0 1px 3px rgba(0,0,0,.35)}
|
|
259
|
+
.dpt-agents-head{display:flex;align-items:center;gap:8px;padding:10px 8px 6px 14px}
|
|
260
|
+
.dpt-agents-title{flex:none;font-weight:600}
|
|
261
|
+
.dpt-agents-count{flex:1;min-width:0;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
262
|
+
.dpt-icon-btn{flex:none;display:grid;place-items:center;width:24px;height:24px;padding:0;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#4a5565);cursor:pointer}
|
|
263
|
+
.dpt-icon-btn:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
|
|
264
|
+
.dpt-side-body{overflow:auto;min-height:0}
|
|
265
|
+
.dpt-side-section{padding:2px 14px 12px}
|
|
266
|
+
.dpt-side-section+.dpt-side-section{border-top:.5px solid var(--dsw-alias-border-l1,#e3e7ee);padding-top:10px}
|
|
267
|
+
.dpt-side-agents{padding-left:8px;padding-right:8px}
|
|
268
|
+
.dpt-side-agents .dpt-agents-list{display:flex;flex-direction:column;gap:4px;padding:2px 0}
|
|
269
|
+
.dpt-side-agents>.dpt-side-label{padding:0 6px}
|
|
270
|
+
.dpt-side-label{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin-bottom:6px;font-size:12px;line-height:18px;font-weight:600;color:var(--dsw-alias-label-secondary,#4a5565)}
|
|
271
|
+
.dpt-side-hint{min-width:0;font-size:11px;font-weight:400;color:var(--dsw-alias-label-tertiary,#667085);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
272
|
+
.dpt-seg{display:flex;gap:2px;padding:2px;border-radius:10px;background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
|
|
273
|
+
.dpt-seg-btn{flex:1;min-width:0;height:26px;padding:0 6px;border:0;border-radius:8px;background:transparent;color:var(--dsw-alias-label-secondary,#4a5565);font:inherit;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;transition:background-color 120ms,color 120ms,box-shadow 120ms}
|
|
274
|
+
.dpt-seg-btn:hover:not(:disabled):not([aria-checked="true"]){color:var(--dsw-alias-label-primary,#101828)}
|
|
275
|
+
.dpt-seg-btn[aria-checked="true"]{background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary,#101828);font-weight:600;box-shadow:0 1px 2px rgba(16,24,40,.12),0 0 0 .5px var(--dsw-alias-border-l1,#e3e7ee)}
|
|
276
|
+
.dpt-seg-btn:disabled{cursor:default}
|
|
277
|
+
.dpt-seg-btn:focus-visible,.dpt-input:focus-visible,.dpt-select:focus-visible{outline:2px solid var(--dpt-accent,#3370ff);outline-offset:1px}
|
|
278
|
+
.dpt-field{display:flex;gap:6px;margin-top:8px}
|
|
279
|
+
.dpt-input,.dpt-select{flex:1;min-width:0;box-sizing:border-box;height:28px;padding:0 8px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);border-radius:8px;background:var(--dsw-alias-bg-base,#fff);color:inherit;font:inherit;font-size:12px}
|
|
280
|
+
.dpt-btn-block{display:flex;width:100%}
|
|
281
|
+
.dpt-side-hint[data-tone="warn"]{color:var(--dsw-alias-state-warn-primary,#b45309)}
|
|
282
|
+
.dpt-tool-failures{margin:0 0 8px;padding:8px 10px;border-radius:10px;background:color-mix(in srgb,var(--dsw-alias-state-warn-primary,#d97706) 10%,transparent);font-size:11px;line-height:16px;color:var(--dsw-alias-label-secondary,#4a5565)}
|
|
283
|
+
.dpt-tool-failures p{margin:0 0 4px}
|
|
284
|
+
.dpt-tool-failures ul{margin:0;padding-left:16px}
|
|
285
|
+
.dpt-tool-failures code{font-family:var(--ds-font-family-code,ui-monospace,monospace)}
|
|
286
|
+
.dpt-side-note{margin:6px 0 0;font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085)}
|
|
287
|
+
.dpt-side-note[data-tone="ok"]{color:var(--dsw-alias-state-success-primary,#0f7a4f)}
|
|
288
|
+
.dpt-side-note[data-tone="error"]{color:var(--dsw-alias-state-error-primary,#c4321f)}
|
|
289
|
+
.dpt-agents-list{list-style:none;margin:0;padding:0;overflow:visible;min-height:0}
|
|
290
|
+
.dpt-agent{display:flex;align-items:flex-start;gap:10px;width:100%;box-sizing:border-box;padding:7px 8px 7px calc(8px + var(--dpt-depth,0) * 14px);border:0;border-radius:10px;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer;transition:background-color 120ms}
|
|
291
|
+
.dpt-agent:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover,rgba(16,24,40,.05))}
|
|
292
|
+
.dpt-agent:disabled{cursor:default}
|
|
293
|
+
.dpt-agent-dot{flex:none;width:8px;height:8px;margin-top:6px;border-radius:50%;background:var(--dsw-alias-label-tertiary,#98a2b3)}
|
|
294
|
+
.dpt-agent[data-state="running"] .dpt-agent-dot,.dpt-agents-pill[data-state="running"] .dpt-agent-dot{background:var(--dpt-accent,#3370ff);animation:dpt-dot-flash 1.2s ease-in-out infinite}
|
|
295
|
+
@keyframes dpt-dot-flash{0%,100%{opacity:1;box-shadow:0 0 4px 1px color-mix(in srgb,var(--dpt-accent,#3370ff) 55%,transparent)}50%{opacity:.35;box-shadow:0 0 10px 3px color-mix(in srgb,var(--dpt-accent,#3370ff) 75%,transparent)}}
|
|
296
|
+
.dpt-agent[data-state="completed"] .dpt-agent-dot{background:var(--dsw-alias-state-success-primary,#0f7a4f)}
|
|
297
|
+
.dpt-agent-main{flex:1;min-width:0;display:flex;flex-direction:column}
|
|
298
|
+
.dpt-agent-name{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
299
|
+
.dpt-agent-meta{font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary,#667085);font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
300
|
+
.dpt-agents-pill{position:fixed;z-index:40;display:inline-flex;align-items:center;gap:8px;height:30px;padding:0 12px;box-sizing:border-box;border-radius:999px;border:.5px solid var(--dsw-alias-border-l2,#d6dce6);background:color-mix(in srgb,var(--dsw-alias-bg-base,#fff) 88%,transparent);-webkit-backdrop-filter:blur(16px);backdrop-filter:blur(16px);box-shadow:0 6px 20px rgba(16,24,40,.08);color:var(--dsw-alias-label-primary,#101828);font:inherit;font-size:12px;cursor:pointer;animation:dpt-rise 220ms var(--dpt-ease) both}
|
|
301
|
+
.dpt-agents-pill .dpt-agent-dot{margin-top:0}
|
|
302
|
+
.dpt-agents,.dpt-agents-pill{--dpt-line:var(--dsw-alias-border-l1,#e3e7ee)}
|
|
303
|
+
.dpt-agents{background:var(--dsw-alias-bg-base,#fff);-webkit-backdrop-filter:none;backdrop-filter:none;border:1px solid var(--dpt-line);box-shadow:0 12px 32px color-mix(in srgb,var(--dpt-accent) 14%,transparent),0 1px 3px rgba(16,24,40,.06)}
|
|
304
|
+
.dpt-agents-head{margin-bottom:8px;padding-bottom:8px;border-bottom:1px solid var(--dpt-line)}
|
|
305
|
+
.dpt-agents-title{display:flex;align-items:center;gap:8px}
|
|
306
|
+
.dpt-agents-title::before{content:"";width:8px;height:8px;border-radius:50%;background:linear-gradient(135deg,var(--dpt-brand-light,#7fb0ff),var(--dpt-accent));box-shadow:0 0 0 3px color-mix(in srgb,var(--dpt-accent) 15%,transparent)}
|
|
307
|
+
.dpt-agents .dpt-icon-btn{color:var(--dsw-alias-label-secondary,#4a5565)}
|
|
308
|
+
.dpt-agents .dpt-icon-btn:hover{background:color-mix(in srgb,var(--dpt-accent) 10%,transparent)}
|
|
309
|
+
.dpt-agents .dpt-side-section+.dpt-side-section{border-top:1px solid var(--dpt-line)}
|
|
310
|
+
.dpt-agents .dpt-seg{background:color-mix(in srgb,var(--dpt-accent) 9%,transparent)}
|
|
311
|
+
.dpt-agents .dpt-seg-btn{color:var(--dsw-alias-label-secondary,#4a5565)}
|
|
312
|
+
.dpt-agents .dpt-seg-btn[aria-checked="true"]{background:#fff;color:var(--dsw-alias-label-primary,#101828);box-shadow:0 1px 3px color-mix(in srgb,var(--dpt-accent) 25%,transparent),0 0 0 1px color-mix(in srgb,var(--dpt-accent) 35%,transparent)}
|
|
313
|
+
.dpt-agents .dpt-input,.dpt-agents .dpt-select{background:#fff;border:1px solid var(--dpt-line)}
|
|
314
|
+
.dpt-agents .dpt-btn{background:#fff;border:1px solid color-mix(in srgb,var(--dpt-accent) 35%,transparent);color:var(--dsw-alias-label-primary,#101828);font-weight:500}
|
|
315
|
+
.dpt-agents .dpt-btn:hover:not(:disabled){background:color-mix(in srgb,var(--dpt-accent) 8%,#fff)}
|
|
316
|
+
.dpt-agents .dpt-agent:hover:not(:disabled){background:color-mix(in srgb,var(--dpt-accent) 7%,transparent)}
|
|
317
|
+
.dpt-agents-pill{background:var(--dsw-alias-bg-base,#fff);-webkit-backdrop-filter:none;backdrop-filter:none;border:1px solid var(--dpt-line);color:var(--dsw-alias-label-primary,#101828);box-shadow:0 6px 20px color-mix(in srgb,var(--dpt-accent) 18%,transparent)}
|
|
318
|
+
${DARK} .dpt-agents .dpt-seg-btn[aria-checked="true"],${DARK} .dpt-agents .dpt-input,${DARK} .dpt-agents .dpt-select,${DARK} .dpt-agents .dpt-btn{background:var(--dsw-alias-bg-base,#161b24)}
|
|
319
|
+
[data-conversation-region="chat"][data-dpt-docked]{margin-right:272px!important}
|
|
320
|
+
.dpt-agents[data-split]{border:0;border-left:1px solid var(--dpt-line,#e3e7ee);border-radius:0;box-shadow:none;animation:dpt-fade-in 160ms ease-out both}
|
|
321
|
+
@keyframes dpt-fade-in{from{opacity:0}to{opacity:1}}
|
|
322
|
+
[data-chat-flow-kind="command"]:has([data-dpt-hidden-command]){display:none!important}
|
|
323
|
+
.dpt-command-error{padding:4px 2px;font-size:12px;line-height:18px;color:var(--dsw-alias-state-error-primary,#c4321f)}
|
|
324
|
+
@keyframes dpt-rise{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
|
|
325
|
+
@media (prefers-reduced-motion:reduce){.dpt-card,.dpt-agents,.dpt-agents-pill,.dpt-agent-dot,.dpt-switch,.dpt-switch-thumb{animation:none!important;transition:none!important}}
|
|
326
|
+
`;
|
|
327
|
+
const THEME_CSS = `
|
|
328
|
+
${ON}{--dpt-dur-fast:120ms;--dpt-dur-base:200ms;--dpt-ease-out:cubic-bezier(0.22,1,0.36,1);--dpt-brand:#3370ff;--dpt-brand-ink:#1f4fc4;--dpt-brand-light:color-mix(in srgb,var(--dpt-brand) 70%,#7fd0ff)}
|
|
329
|
+
${ON}{
|
|
330
|
+
--dsw-alias-bg-base:#ffffff !important;--dsw-alias-surface-2:#f5f7fa !important;
|
|
331
|
+
--dsw-alias-label-primary:#101828 !important;--dsw-alias-label-secondary:#4a5565 !important;--dsw-alias-label-tertiary:#667085 !important;
|
|
332
|
+
--dsw-alias-text-primary:#101828 !important;--dsw-alias-text-secondary:#4a5565 !important;
|
|
333
|
+
--dsw-alias-border-l1:#e3e7ee !important;--dsw-alias-border-l2:#d6dce6 !important;--dsw-alias-border-l2-darkmode-thin:#d6dce6 !important;
|
|
334
|
+
--dsw-alias-interactive-bg-hover:rgba(16,24,40,0.05) !important;--dsw-alias-bg-hover:rgba(16,24,40,0.05) !important;
|
|
335
|
+
--dsw-alias-interactive-bg-hover-danger:rgba(196,50,31,0.10) !important;--dsw-alias-bg-danger:rgba(196,50,31,0.10) !important;
|
|
336
|
+
--dsw-alias-state-error-primary:#c4321f !important;--dsw-alias-text-danger:#c4321f !important;--dsw-alias-border-danger:#c4321f !important;
|
|
337
|
+
--dsw-alias-state-success-primary:#0f7a4f !important;--dsw-alias-text-success:#0f7a4f !important;
|
|
338
|
+
--dsw-alias-state-warning-primary:#8a5a00 !important;--dsw-alias-text-warning:#8a5a00 !important;
|
|
339
|
+
--dsw-specific-bubble:#eaf1ff !important;--dsw-specific-input-major:#ffffff !important;
|
|
340
|
+
--dsw-shadow-lv1:0 1px 2px rgba(16,24,40,0.06),0 4px 14px rgba(16,24,40,0.06) !important;
|
|
341
|
+
--dsh-scrollbar-thumb:rgba(16,24,40,0.16) !important;--dsh-scrollbar-thumb-hover:rgba(16,24,40,0.32) !important;
|
|
342
|
+
--ds-font-family:"Segoe UI Variable Text","Segoe UI","Microsoft YaHei UI","PingFang SC","HarmonyOS Sans SC",system-ui,sans-serif !important;
|
|
343
|
+
--ds-font-family-code:"JetBrains Mono","Cascadia Code","SF Mono",ui-monospace,Consolas,monospace !important;
|
|
344
|
+
-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;
|
|
345
|
+
}
|
|
346
|
+
${ON_DARK}{
|
|
347
|
+
--dsw-alias-bg-base:#0e1117 !important;--dsw-alias-surface-2:#161b24 !important;
|
|
348
|
+
--dsw-alias-label-primary:#eef2f8 !important;--dsw-alias-label-secondary:#a3adbd !important;--dsw-alias-label-tertiary:#8a94a6 !important;
|
|
349
|
+
--dsw-alias-text-primary:#eef2f8 !important;--dsw-alias-text-secondary:#a3adbd !important;
|
|
350
|
+
--dsw-alias-border-l1:#263041 !important;--dsw-alias-border-l2:#2f3b50 !important;--dsw-alias-border-l2-darkmode-thin:#2f3b50 !important;
|
|
351
|
+
--dsw-alias-interactive-bg-hover:rgba(238,242,248,0.07) !important;--dsw-alias-bg-hover:rgba(238,242,248,0.07) !important;
|
|
352
|
+
--dsw-alias-interactive-bg-hover-danger:rgba(255,123,104,0.14) !important;--dsw-alias-bg-danger:rgba(255,123,104,0.14) !important;
|
|
353
|
+
--dsw-alias-state-error-primary:#ff7b68 !important;--dsw-alias-text-danger:#ff7b68 !important;--dsw-alias-border-danger:#ff7b68 !important;
|
|
354
|
+
--dsw-alias-state-success-primary:#4cc38a !important;--dsw-alias-text-success:#4cc38a !important;
|
|
355
|
+
--dsw-alias-state-warning-primary:#e0a93b !important;--dsw-alias-text-warning:#e0a93b !important;
|
|
356
|
+
--dsw-specific-bubble:#1b2f5c !important;--dsw-specific-input-major:#161b24 !important;
|
|
357
|
+
--dsw-shadow-lv1:0 1px 2px rgba(0,0,0,0.4),0 4px 14px rgba(0,0,0,0.35) !important;
|
|
358
|
+
--dsh-scrollbar-thumb:rgba(238,242,248,0.18) !important;--dsh-scrollbar-thumb-hover:rgba(238,242,248,0.34) !important;
|
|
359
|
+
--dpt-brand:#5b8cff;--dpt-brand-ink:#9dbcff;
|
|
360
|
+
}
|
|
361
|
+
${ON0} :where(button,[role="button"],[role="menuitem"],[role="tab"],a,summary,select,input,textarea){
|
|
362
|
+
transition:background-color var(--dpt-dur-fast) var(--dpt-ease-out),color var(--dpt-dur-fast) var(--dpt-ease-out),border-color var(--dpt-dur-fast) var(--dpt-ease-out),box-shadow var(--dpt-dur-base) var(--dpt-ease-out),opacity var(--dpt-dur-fast) var(--dpt-ease-out);
|
|
363
|
+
}
|
|
364
|
+
${ON0} :where(button:active:not(:disabled),[role="button"]:active:not([aria-disabled="true"])){transform:scale(0.98)}
|
|
365
|
+
${ON} ::selection{background:color-mix(in srgb,var(--dpt-brand) 24%,transparent)}
|
|
366
|
+
${ON} [data-dpt-composer]{box-shadow:0 10px 30px rgba(16,24,40,0.07),0 2px 6px rgba(16,24,40,0.05);transition:border-color var(--dpt-dur-base) var(--dpt-ease-out),box-shadow var(--dpt-dur-base) var(--dpt-ease-out),transform var(--dpt-dur-base) var(--dpt-ease-out)}
|
|
367
|
+
${ON_DARK} [data-dpt-composer]{box-shadow:0 10px 30px rgba(0,0,0,0.45),0 2px 6px rgba(0,0,0,0.35)}
|
|
368
|
+
${ON} [data-dpt-composer]::before{content:"";position:absolute;inset:-1px;border-radius:inherit;padding:1.5px;pointer-events:none;background:linear-gradient(115deg,var(--dpt-brand),var(--dpt-brand-light),var(--dpt-brand),var(--dpt-brand-light));background-size:300% 100%;-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:0;transition:opacity var(--dpt-dur-base) var(--dpt-ease-out)}
|
|
369
|
+
${ON} [data-dpt-composer]:focus-within::before{opacity:1;animation:dpt-sheen 5s linear infinite}
|
|
370
|
+
${ON}:not([data-dpt-busy]) [data-dpt-composer]:focus-within{box-shadow:0 0 0 4px color-mix(in srgb,var(--dpt-brand) 10%,transparent),0 14px 38px color-mix(in srgb,var(--dpt-brand) 16%,transparent) !important}
|
|
371
|
+
${ON} [data-dpt-composer]:hover:not(:focus-within){background-image:radial-gradient(360px circle at var(--dpt-mx,50%) var(--dpt-my,50%),color-mix(in srgb,var(--dpt-brand) 7%,transparent),transparent 70%)}
|
|
372
|
+
@keyframes dpt-sheen{from{background-position:0% 0}to{background-position:300% 0}}
|
|
373
|
+
${ON} [data-dpt-send]:not(:disabled):not([aria-disabled="true"]){background-image:linear-gradient(135deg,var(--dpt-brand-light),var(--dpt-brand)) !important;color:#fff !important;box-shadow:0 4px 14px color-mix(in srgb,var(--dpt-brand) 38%,transparent);transition:transform 160ms var(--dpt-ease-out),box-shadow 160ms var(--dpt-ease-out),filter var(--dpt-dur-fast) var(--dpt-ease-out) !important}
|
|
374
|
+
${ON} [data-dpt-send]:not(:disabled):not([aria-disabled="true"]):hover{transform:translateY(-1px);box-shadow:0 8px 20px color-mix(in srgb,var(--dpt-brand) 46%,transparent);filter:saturate(1.08)}
|
|
375
|
+
${ON} [data-dpt-send]:not(:disabled):not([aria-disabled="true"]):active{transform:translateY(0) scale(0.94);transition-duration:60ms}
|
|
376
|
+
${ON} [data-dpt-bubble]{background-image:linear-gradient(90deg,color-mix(in srgb,var(--dpt-brand) 20%,transparent),color-mix(in srgb,var(--dpt-brand) 7%,transparent)) !important;background-color:transparent !important;color:var(--dsw-alias-label-primary) !important;border-radius:18px 18px 6px 18px !important;box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dpt-brand) 16%,transparent);animation:dpt-bubble-rise var(--dpt-dur-base) var(--dpt-ease-out) both}
|
|
377
|
+
${ON} [data-dpt-bubble] *{color:inherit}
|
|
378
|
+
@keyframes dpt-bubble-rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
|
|
379
|
+
${ON} [data-chat-flow-kind="assistant-step"]{font-size:15px}
|
|
380
|
+
${ON} [data-chat-flow-kind="assistant-step"] :is(p,li){line-height:1.82}
|
|
381
|
+
${ON} [data-chat-flow-kind="assistant-step"] p{margin-block:0.7em}
|
|
382
|
+
${ON} [data-chat-flow-kind="assistant-step"] pre{border-radius:14px;border:1px solid var(--dsw-alias-border-l1);box-shadow:0 1px 2px rgba(16,24,40,0.04)}
|
|
383
|
+
${ON} [data-chat-flow-kind="assistant-step"] blockquote{border-radius:0 10px 10px 0}
|
|
384
|
+
${ON} [data-row-key^="session:"][role="treeitem"]{transition:background-color var(--dpt-dur-fast) var(--dpt-ease-out),color var(--dpt-dur-fast) var(--dpt-ease-out)}
|
|
385
|
+
${ON} [data-row-key^="session:"][role="treeitem"]:hover{background-color:color-mix(in srgb,var(--dpt-brand) 7%,transparent)}
|
|
386
|
+
${ON} [data-row-key^="session:"][role="treeitem"]:hover:not(:is([aria-selected="true"],[aria-current="true"],[data-selected="true"],.ld-row-selected)){background-image:radial-gradient(160px circle at var(--dpt-mx,50%) var(--dpt-my,50%),color-mix(in srgb,var(--dpt-brand) 18%,transparent),transparent 72%)}
|
|
387
|
+
${ON} [data-row-key^="session:"][role="treeitem"]:is([aria-selected="true"],[aria-current="true"],[data-selected="true"],.ld-row-selected){background-image:linear-gradient(90deg,color-mix(in srgb,var(--dpt-brand) 15%,transparent),color-mix(in srgb,var(--dpt-brand) 3%,transparent));font-weight:500}
|
|
388
|
+
${ON}[data-dpt-busy] [data-dpt-composer]::before{opacity:1;padding:2.5px;animation:dpt-sheen 1.6s linear infinite}
|
|
389
|
+
${ON}[data-dpt-busy] [data-dpt-composer]{border-color:color-mix(in srgb,var(--dpt-brand) 55%,transparent) !important;animation:dpt-breathe 1.9s ease-in-out infinite}
|
|
390
|
+
@keyframes dpt-breathe{0%,100%{box-shadow:0 0 0 1px color-mix(in srgb,var(--dpt-brand) 35%,transparent),0 0 16px 2px color-mix(in srgb,var(--dpt-brand) 28%,transparent),0 10px 30px color-mix(in srgb,var(--dpt-brand) 12%,transparent)}50%{box-shadow:0 0 0 4px color-mix(in srgb,var(--dpt-brand) 22%,transparent),0 0 44px 10px color-mix(in srgb,var(--dpt-brand) 50%,transparent),0 14px 44px color-mix(in srgb,var(--dpt-brand) 24%,transparent)}}
|
|
391
|
+
${ON} [data-dpt-composer][data-dpt-done]{animation:dpt-done 900ms var(--dpt-ease-out) 1}
|
|
392
|
+
@keyframes dpt-done{0%{box-shadow:0 0 0 0 color-mix(in srgb,var(--dpt-brand) 60%,transparent)}100%{box-shadow:0 0 0 26px color-mix(in srgb,var(--dpt-brand) 0%,transparent)}}
|
|
393
|
+
${ON}[data-dpt-busy] [data-dpt-send]{position:relative}
|
|
394
|
+
${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-4px;border-radius:50%;padding:2.5px;pointer-events:none;background:conic-gradient(from 0deg,transparent 0 40%,var(--dpt-brand-light) 70%,#fff 100%);-webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);-webkit-mask-composite:xor;mask-composite:exclude;animation:dpt-spin 1.1s linear infinite}
|
|
395
|
+
@keyframes dpt-spin{to{transform:rotate(360deg)}}
|
|
396
|
+
.dpt-pal-backdrop{position:fixed;inset:0;z-index:2147483000;display:flex;justify-content:center;align-items:flex-start;padding-top:14vh;background:color-mix(in srgb,#0b1220 32%,transparent);-webkit-backdrop-filter:blur(8px) saturate(1.1);backdrop-filter:blur(8px) saturate(1.1);animation:dpt-fade 200ms cubic-bezier(.22,1,.36,1) both}
|
|
397
|
+
.dpt-pal{position:relative;width:min(600px,92vw);overflow:hidden;border-radius:20px;background:var(--dsw-alias-bg-base,#fff);color:var(--dsw-alias-label-primary,#101828);border:1px solid var(--dsw-alias-border-l2,#d6dce6);box-shadow:0 24px 70px rgba(11,18,32,0.35);font:14px/1.5 var(--ds-font-family,system-ui,sans-serif);animation:dpt-pop 200ms cubic-bezier(.22,1,.36,1) both}
|
|
398
|
+
.dpt-pal::before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:linear-gradient(90deg,var(--dpt-brand,#3370ff),var(--dpt-brand-light,#7fb0ff),var(--dpt-brand,#3370ff));background-size:200% 100%;animation:dpt-sheen 6s linear infinite}
|
|
399
|
+
.dpt-pal-input{display:block;width:100%;box-sizing:border-box;padding:18px 20px;border:0;outline:0;background:transparent;color:inherit;font:inherit;font-size:16px;border-bottom:1px solid var(--dsw-alias-border-l1,#e3e7ee)}
|
|
400
|
+
.dpt-pal-input::placeholder{color:var(--dsw-alias-label-tertiary,#667085)}
|
|
401
|
+
.dpt-pal-list{max-height:min(52vh,420px);overflow:auto;padding:8px}
|
|
402
|
+
.dpt-pal-item{display:flex;align-items:center;gap:10px;padding:9px 12px;border-radius:12px;cursor:pointer;transition:background-color 120ms}
|
|
403
|
+
.dpt-pal-item[aria-selected="true"]{background-image:linear-gradient(90deg,color-mix(in srgb,var(--dpt-brand,#3370ff) 20%,transparent),color-mix(in srgb,var(--dpt-brand,#3370ff) 7%,transparent))}
|
|
404
|
+
.dpt-pal-kind{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:color-mix(in srgb,var(--dpt-brand,#3370ff) 12%,transparent);color:var(--dpt-brand-ink,#1f4fc4)}
|
|
405
|
+
.dpt-pal-title{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
406
|
+
.dpt-pal-sub{flex:none;font-size:12px;color:var(--dsw-alias-label-tertiary,#667085)}
|
|
407
|
+
.dpt-pal-empty{padding:22px;text-align:center;color:var(--dsw-alias-label-tertiary,#667085)}
|
|
408
|
+
.dpt-pal-foot{display:flex;gap:16px;padding:9px 20px;font-size:12px;color:var(--dsw-alias-label-tertiary,#667085);border-top:1px solid var(--dsw-alias-border-l1,#e3e7ee)}
|
|
409
|
+
@keyframes dpt-fade{from{opacity:0}to{opacity:1}}
|
|
410
|
+
@keyframes dpt-pop{from{opacity:0;transform:translateY(8px) scale(0.98)}to{opacity:1;transform:none}}
|
|
411
|
+
.dpt-ripple{position:fixed;z-index:2147483000;pointer-events:none;width:20px;height:20px;margin:-10px 0 0 -10px;border-radius:50%;border:2px solid color-mix(in srgb,var(--dpt-brand,#3370ff) 75%,transparent);background:radial-gradient(circle,color-mix(in srgb,var(--dpt-brand,#3370ff) 45%,transparent),color-mix(in srgb,var(--dpt-brand,#3370ff) 12%,transparent) 60%,transparent 72%);animation:dpt-ripple 650ms cubic-bezier(.22,1,.36,1) forwards}
|
|
412
|
+
@keyframes dpt-ripple{0%{transform:scale(.3);opacity:1}100%{transform:scale(7);opacity:0}}
|
|
413
|
+
.dpt-fx{position:fixed;inset:0;width:100vw;height:100vh;z-index:2147482000;pointer-events:none}
|
|
414
|
+
@media (prefers-reduced-motion:reduce){
|
|
415
|
+
${ON} *,${ON} *::before,${ON} *::after{animation-duration:0.01ms !important;animation-iteration-count:1 !important;transition-duration:0.01ms !important;scroll-behavior:auto !important}
|
|
416
|
+
}
|
|
417
|
+
`;
|
|
418
|
+
|
|
419
|
+
function injectCss() {
|
|
420
|
+
if (typeof document === 'undefined') return () => {};
|
|
421
|
+
const id = `${PLUGIN}/style.css`;
|
|
422
|
+
document.querySelector(`style[data-plugin-css=${JSON.stringify(id)}]`)?.remove();
|
|
423
|
+
const tag = document.createElement('style');
|
|
424
|
+
tag.dataset.plugin = PLUGIN;
|
|
425
|
+
tag.dataset.pluginCss = id;
|
|
426
|
+
tag.textContent = CARD_CSS + THEME_CSS;
|
|
427
|
+
document.head.appendChild(tag);
|
|
428
|
+
return () => tag.remove();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// ---------------------------------------------------------------------------------------------
|
|
432
|
+
// Which session is on screen. Each conversation header mounts a hidden bridge; the visible one
|
|
433
|
+
// in the main conversation decides whether the refined look is on and whether the agent works.
|
|
434
|
+
// ---------------------------------------------------------------------------------------------
|
|
435
|
+
const SESSIONS = {
|
|
436
|
+
map: new Map(), subs: new Set(),
|
|
437
|
+
// Sessions whose subagents are running, reported by the side card (Deep PTC sessions only).
|
|
438
|
+
working: new Map(),
|
|
439
|
+
setWorking(id, value) { if (this.working.get(id) === value) return; if (value) this.working.set(id, true); else this.working.delete(id); this.emit(); },
|
|
440
|
+
set(id, value) { this.map.set(id, value); this.emit(); },
|
|
441
|
+
del(id) { this.map.delete(id); this.emit(); },
|
|
442
|
+
emit() { for (const listener of this.subs) { try { listener(); } catch (error) { console.warn(`[${PLUGIN}]`, error); } } },
|
|
443
|
+
current() {
|
|
444
|
+
let pick, fallback;
|
|
445
|
+
for (const value of this.map.values()) {
|
|
446
|
+
const shown = value.el?.parentElement?.getClientRects?.().length > 0;
|
|
447
|
+
if (!shown) { fallback ??= value; continue; }
|
|
448
|
+
const main = value.el.closest?.('[data-slot="main.conversation"]');
|
|
449
|
+
if (main || pick === undefined) pick = value;
|
|
450
|
+
}
|
|
451
|
+
return pick ?? fallback;
|
|
452
|
+
},
|
|
453
|
+
};
|
|
454
|
+
const BUSY = { bridge: false, dom: false, was: false, timer: 0 };
|
|
455
|
+
// The standalone dsh-refined-ui draws the same look; never stack both.
|
|
456
|
+
const refinedPresent = () => typeof document !== 'undefined' && document.querySelector('style[data-plugin="dsh-refined-ui"]') !== null;
|
|
457
|
+
const uiOn = () => typeof document !== 'undefined' && document.body?.hasAttribute('data-dpt-ui');
|
|
458
|
+
function applyBusy() {
|
|
459
|
+
if (typeof document === 'undefined') return;
|
|
460
|
+
const busy = uiOn() && (BUSY.bridge || BUSY.dom);
|
|
461
|
+
document.body.toggleAttribute('data-dpt-busy', busy);
|
|
462
|
+
if (BUSY.was && !busy) {
|
|
463
|
+
const card = document.querySelector('[data-dpt-composer]');
|
|
464
|
+
if (card) {
|
|
465
|
+
card.setAttribute('data-dpt-done', '');
|
|
466
|
+
clearTimeout(BUSY.timer);
|
|
467
|
+
BUSY.timer = setTimeout(() => card.removeAttribute('data-dpt-done'), 1000);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
BUSY.was = busy;
|
|
471
|
+
}
|
|
472
|
+
function watchActiveSession() {
|
|
473
|
+
if (typeof document === 'undefined') return () => {};
|
|
474
|
+
const update = () => {
|
|
475
|
+
const current = SESSIONS.current();
|
|
476
|
+
const on = current?.preset === 'deep-ptc' && !refinedPresent();
|
|
477
|
+
document.body.toggleAttribute('data-dpt-ui', on);
|
|
478
|
+
// Like dsh-refined-ui, a running subagent keeps the conversation working.
|
|
479
|
+
BUSY.bridge = on && (current?.busy === true || SESSIONS.working.get(current?.id) === true);
|
|
480
|
+
applyBusy();
|
|
481
|
+
};
|
|
482
|
+
SESSIONS.subs.add(update);
|
|
483
|
+
// Visibility changes without a remount (split views, tab switches) are caught here.
|
|
484
|
+
const timer = setInterval(update, 1000);
|
|
485
|
+
update();
|
|
486
|
+
return () => {
|
|
487
|
+
SESSIONS.subs.delete(update);
|
|
488
|
+
clearInterval(timer);
|
|
489
|
+
document.body.removeAttribute('data-dpt-ui');
|
|
490
|
+
document.body.removeAttribute('data-dpt-busy');
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// Tag the composer card, its send button and the user bubbles so the CSS needs no hashed class
|
|
495
|
+
// names. Only data-dpt-* attributes (and position:relative on a static composer) are written.
|
|
496
|
+
function watchSurfaces() {
|
|
497
|
+
if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') return () => {};
|
|
498
|
+
const tagged = new Set();
|
|
499
|
+
const relativized = new Set();
|
|
500
|
+
let frame = 0;
|
|
501
|
+
const mark = (node, attribute) => { node.setAttribute(attribute, ''); tagged.add([node, attribute]); };
|
|
502
|
+
const findComposer = input => {
|
|
503
|
+
for (let node = input.parentElement, depth = 0; node && node !== document.body && depth < 8; node = node.parentElement, depth++) {
|
|
504
|
+
const style = getComputedStyle(node);
|
|
505
|
+
const round = parseFloat(style.borderTopLeftRadius) >= 14;
|
|
506
|
+
const framed = style.boxShadow !== 'none' || parseFloat(style.borderTopWidth) > 0;
|
|
507
|
+
if (round && framed) return node;
|
|
508
|
+
}
|
|
509
|
+
return null;
|
|
510
|
+
};
|
|
511
|
+
function tagComposer() {
|
|
512
|
+
for (const input of document.querySelectorAll('[data-composer-input]')) {
|
|
513
|
+
let card = input.closest('[data-dpt-composer]');
|
|
514
|
+
if (!card) {
|
|
515
|
+
card = findComposer(input);
|
|
516
|
+
if (!card) continue;
|
|
517
|
+
mark(card, 'data-dpt-composer');
|
|
518
|
+
if (getComputedStyle(card).position === 'static') { card.style.position = 'relative'; relativized.add(card); }
|
|
519
|
+
}
|
|
520
|
+
if (card.querySelector('[data-dpt-send]')) continue;
|
|
521
|
+
// The send button is the right-most button in the card.
|
|
522
|
+
let best = null, bestRight = -1;
|
|
523
|
+
for (const button of card.querySelectorAll('button,[role="button"]')) {
|
|
524
|
+
const rect = button.getBoundingClientRect();
|
|
525
|
+
if (rect.width > 0 && rect.right >= bestRight) { best = button; bestRight = rect.right; }
|
|
526
|
+
}
|
|
527
|
+
if (best) mark(best, 'data-dpt-send');
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
function tagBubbles() {
|
|
531
|
+
for (const row of document.querySelectorAll('[data-chat-flow-kind="user"],[data-chat-flow-kind="steering"]')) {
|
|
532
|
+
if (row.querySelector('[data-dpt-bubble]')) continue;
|
|
533
|
+
const nodes = row.querySelectorAll('*');
|
|
534
|
+
for (let index = 0; index < nodes.length && index < 60; index++) {
|
|
535
|
+
const node = nodes[index];
|
|
536
|
+
if (node.tagName === 'BUTTON' || node.tagName === 'SVG' || !node.textContent?.trim()) continue;
|
|
537
|
+
const style = getComputedStyle(node);
|
|
538
|
+
const filled = style.backgroundColor && style.backgroundColor !== 'transparent' && style.backgroundColor !== 'rgba(0, 0, 0, 0)';
|
|
539
|
+
if (filled && parseFloat(style.borderTopLeftRadius) >= 10) { mark(node, 'data-dpt-bubble'); break; }
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function onMove(event) {
|
|
544
|
+
const host = event.target?.closest?.('[data-row-key^="session:"],[data-dpt-composer]');
|
|
545
|
+
if (!host || !uiOn()) return;
|
|
546
|
+
const rect = host.getBoundingClientRect();
|
|
547
|
+
host.style.setProperty('--dpt-mx', `${event.clientX - rect.left}px`);
|
|
548
|
+
host.style.setProperty('--dpt-my', `${event.clientY - rect.top}px`);
|
|
549
|
+
}
|
|
550
|
+
const run = () => {
|
|
551
|
+
frame = 0;
|
|
552
|
+
tagComposer();
|
|
553
|
+
tagBubbles();
|
|
554
|
+
BUSY.dom = document.querySelector('[data-streaming="true"]') !== null;
|
|
555
|
+
applyBusy();
|
|
556
|
+
};
|
|
557
|
+
const schedule = () => { if (!frame) frame = requestAnimationFrame(run); };
|
|
558
|
+
const observer = new MutationObserver(schedule);
|
|
559
|
+
observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['data-streaming'] });
|
|
560
|
+
document.addEventListener('pointermove', onMove, { capture: true, passive: true });
|
|
561
|
+
schedule();
|
|
562
|
+
return () => {
|
|
563
|
+
observer.disconnect();
|
|
564
|
+
document.removeEventListener('pointermove', onMove, true);
|
|
565
|
+
if (frame) cancelAnimationFrame(frame);
|
|
566
|
+
BUSY.dom = false;
|
|
567
|
+
applyBusy();
|
|
568
|
+
for (const [node, attribute] of tagged) node.removeAttribute(attribute);
|
|
569
|
+
tagged.clear();
|
|
570
|
+
for (const node of relativized) node.style.position = '';
|
|
571
|
+
relativized.clear();
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// Ctrl/Cmd+K palette. It only clicks entries the host already renders.
|
|
576
|
+
const PANEL = { toggle() {}, state: {} };
|
|
577
|
+
const FX = { burst() {} };
|
|
578
|
+
function findClickable(labels) {
|
|
579
|
+
let fallback = null;
|
|
580
|
+
for (const node of document.querySelectorAll('button,[role="button"],[role="treeitem"],[role="menuitem"],a,div,span')) {
|
|
581
|
+
if (!labels.includes((node.textContent ?? '').trim()) || node.closest('[data-dpt-palette]')) continue;
|
|
582
|
+
const role = node.getAttribute('role');
|
|
583
|
+
if (node.tagName === 'BUTTON' || node.tagName === 'A' || role === 'button' || role === 'treeitem' || role === 'menuitem') return node;
|
|
584
|
+
fallback ??= node;
|
|
585
|
+
}
|
|
586
|
+
return fallback;
|
|
587
|
+
}
|
|
588
|
+
function paletteItems() {
|
|
589
|
+
const items = [];
|
|
590
|
+
for (const [labels, sub] of [[['新会话', 'New session'], 'palNewSub'], [['插件', 'Plugins'], 'palPluginsSub'], [['自动化任务', 'Automations'], 'palAutomationSub']]) {
|
|
591
|
+
const node = findClickable(labels);
|
|
592
|
+
if (node) items.push({ kind: T('palCommand'), title: (node.textContent ?? '').trim(), sub: T(sub), run: () => node.click() });
|
|
593
|
+
}
|
|
594
|
+
items.push({ kind: T('palEffect'), title: T('palAgents'), sub: T('palAgentsSub'), run: () => PANEL.toggle() });
|
|
595
|
+
items.push({ kind: T('palEffect'), title: T('palFireworks'), sub: T('palFireworksSub'), run: () => FX.burst() });
|
|
596
|
+
const rows = document.querySelectorAll('[data-row-key^="session:"]');
|
|
597
|
+
for (let index = 0; index < rows.length && index < 80; index++) {
|
|
598
|
+
const row = rows[index];
|
|
599
|
+
const lines = (row.innerText ?? '').split('\n').map(line => line.trim()).filter(Boolean);
|
|
600
|
+
if (lines.length) items.push({ kind: T('palSession'), title: lines[0], sub: lines.length > 1 ? lines.at(-1) : '', run: () => row.click() });
|
|
601
|
+
}
|
|
602
|
+
return items;
|
|
603
|
+
}
|
|
604
|
+
function watchPalette() {
|
|
605
|
+
if (typeof document === 'undefined') return () => {};
|
|
606
|
+
let backdrop = null, input = null, list = null, items = [], shown = [], index = 0;
|
|
607
|
+
const close = () => { backdrop?.remove(); backdrop = null; };
|
|
608
|
+
function mark() {
|
|
609
|
+
for (let at = 0; at < list.children.length; at++) list.children[at].setAttribute('aria-selected', at === index ? 'true' : 'false');
|
|
610
|
+
list.children[index]?.scrollIntoView?.({ block: 'nearest' });
|
|
611
|
+
}
|
|
612
|
+
function render() {
|
|
613
|
+
list.textContent = '';
|
|
614
|
+
if (!shown.length) {
|
|
615
|
+
const empty = document.createElement('div');
|
|
616
|
+
empty.className = 'dpt-pal-empty';
|
|
617
|
+
empty.textContent = T('palEmpty');
|
|
618
|
+
list.appendChild(empty);
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
shown.forEach((item, at) => {
|
|
622
|
+
const row = document.createElement('div');
|
|
623
|
+
row.className = 'dpt-pal-item';
|
|
624
|
+
row.setAttribute('role', 'option');
|
|
625
|
+
const kind = document.createElement('span'); kind.className = 'dpt-pal-kind'; kind.textContent = item.kind;
|
|
626
|
+
const title = document.createElement('span'); title.className = 'dpt-pal-title'; title.textContent = item.title;
|
|
627
|
+
const sub = document.createElement('span'); sub.className = 'dpt-pal-sub'; sub.textContent = item.sub;
|
|
628
|
+
row.append(kind, title, sub);
|
|
629
|
+
row.addEventListener('pointermove', () => { if (index !== at) { index = at; mark(); } });
|
|
630
|
+
row.addEventListener('click', () => choose(at));
|
|
631
|
+
list.appendChild(row);
|
|
632
|
+
});
|
|
633
|
+
mark();
|
|
634
|
+
}
|
|
635
|
+
function filter() {
|
|
636
|
+
const query = input.value.trim().toLowerCase();
|
|
637
|
+
shown = query ? items.filter(item => `${item.title} ${item.kind}`.toLowerCase().includes(query)) : items.slice(0, 12);
|
|
638
|
+
index = 0;
|
|
639
|
+
render();
|
|
640
|
+
}
|
|
641
|
+
function choose(at) {
|
|
642
|
+
const item = shown[at];
|
|
643
|
+
if (!item) return;
|
|
644
|
+
close();
|
|
645
|
+
setTimeout(() => { try { item.run(); } catch (error) { console.warn(`[${PLUGIN}] palette action failed:`, error); } }, 30);
|
|
646
|
+
}
|
|
647
|
+
function open() {
|
|
648
|
+
items = paletteItems();
|
|
649
|
+
backdrop = document.createElement('div');
|
|
650
|
+
backdrop.className = 'dpt-pal-backdrop';
|
|
651
|
+
backdrop.setAttribute('data-dpt-palette', '');
|
|
652
|
+
const panel = document.createElement('div');
|
|
653
|
+
panel.className = 'dpt-pal';
|
|
654
|
+
panel.setAttribute('role', 'dialog');
|
|
655
|
+
panel.setAttribute('aria-label', T('palTitle'));
|
|
656
|
+
input = document.createElement('input');
|
|
657
|
+
input.className = 'dpt-pal-input';
|
|
658
|
+
input.placeholder = T('palPlaceholder');
|
|
659
|
+
input.setAttribute('aria-label', T('palPlaceholder'));
|
|
660
|
+
list = document.createElement('div');
|
|
661
|
+
list.className = 'dpt-pal-list';
|
|
662
|
+
list.setAttribute('role', 'listbox');
|
|
663
|
+
const foot = document.createElement('div');
|
|
664
|
+
foot.className = 'dpt-pal-foot';
|
|
665
|
+
foot.textContent = T('palFoot');
|
|
666
|
+
panel.append(input, list, foot);
|
|
667
|
+
backdrop.appendChild(panel);
|
|
668
|
+
document.body.appendChild(backdrop);
|
|
669
|
+
backdrop.addEventListener('pointerdown', event => { if (event.target === backdrop) close(); });
|
|
670
|
+
input.addEventListener('input', filter);
|
|
671
|
+
input.addEventListener('keydown', event => {
|
|
672
|
+
if (event.isComposing || event.keyCode === 229) return;
|
|
673
|
+
if (event.key === 'ArrowDown') { event.preventDefault(); index = Math.min(index + 1, shown.length - 1); mark(); }
|
|
674
|
+
else if (event.key === 'ArrowUp') { event.preventDefault(); index = Math.max(index - 1, 0); mark(); }
|
|
675
|
+
else if (event.key === 'Enter') { event.preventDefault(); choose(index); }
|
|
676
|
+
else if (event.key === 'Escape') { event.preventDefault(); close(); }
|
|
677
|
+
});
|
|
678
|
+
filter();
|
|
679
|
+
input.focus();
|
|
680
|
+
}
|
|
681
|
+
function onKey(event) {
|
|
682
|
+
if (!(event.ctrlKey || event.metaKey) || event.altKey || event.shiftKey || (event.key !== 'k' && event.key !== 'K')) return;
|
|
683
|
+
if (!backdrop && !uiOn()) return;
|
|
684
|
+
event.preventDefault();
|
|
685
|
+
event.stopPropagation();
|
|
686
|
+
if (backdrop) close(); else open();
|
|
687
|
+
}
|
|
688
|
+
document.addEventListener('keydown', onKey, true);
|
|
689
|
+
return () => { document.removeEventListener('keydown', onKey, true); close(); };
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// Click ripple, magnetic send button, "/" focuses the composer, Alt+Up/Down switches sessions.
|
|
693
|
+
function watchInteractions() {
|
|
694
|
+
if (typeof document === 'undefined') return () => {};
|
|
695
|
+
const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
|
|
696
|
+
let magnet = null;
|
|
697
|
+
const typing = target => target && (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/u.test(target.tagName));
|
|
698
|
+
function onDown(event) {
|
|
699
|
+
if (event.button !== 0 || reduce || !uiOn()) return;
|
|
700
|
+
if (!event.target?.closest?.('button,a,[role=button],[role=treeitem],[role=tab],[role=menuitem],[role=option],summary')) return;
|
|
701
|
+
const ripple = document.createElement('div');
|
|
702
|
+
ripple.className = 'dpt-ripple';
|
|
703
|
+
ripple.style.left = `${event.clientX}px`;
|
|
704
|
+
ripple.style.top = `${event.clientY}px`;
|
|
705
|
+
document.body.appendChild(ripple);
|
|
706
|
+
setTimeout(() => ripple.remove(), 700);
|
|
707
|
+
}
|
|
708
|
+
function onMove(event) {
|
|
709
|
+
const button = uiOn() ? document.querySelector('[data-dpt-send]') : null;
|
|
710
|
+
if (magnet && magnet !== button) { magnet.style.translate = ''; magnet = null; }
|
|
711
|
+
if (!button || reduce) return;
|
|
712
|
+
const rect = button.getBoundingClientRect();
|
|
713
|
+
const dx = event.clientX - (rect.left + rect.width / 2), dy = event.clientY - (rect.top + rect.height / 2);
|
|
714
|
+
if (Math.hypot(dx, dy) < 70) { button.style.translate = `${(dx * 0.18).toFixed(1)}px ${(dy * 0.18).toFixed(1)}px`; magnet = button; }
|
|
715
|
+
else if (magnet) { button.style.translate = ''; magnet = null; }
|
|
716
|
+
}
|
|
717
|
+
function onKey(event) {
|
|
718
|
+
if (event.isComposing || event.keyCode === 229 || !uiOn() || document.querySelector('.dpt-pal-backdrop')) return;
|
|
719
|
+
if (event.key === '/' && !event.ctrlKey && !event.metaKey && !event.altKey && !typing(event.target)) {
|
|
720
|
+
const input = document.querySelector('[data-composer-input]');
|
|
721
|
+
if (input) { event.preventDefault(); input.focus(); }
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
724
|
+
if (event.altKey && !event.ctrlKey && !event.metaKey && (event.key === 'ArrowUp' || event.key === 'ArrowDown')) {
|
|
725
|
+
const rows = [...document.querySelectorAll('[data-row-key^="session:"][role="treeitem"]')];
|
|
726
|
+
if (!rows.length) return;
|
|
727
|
+
const current = rows.findIndex(row => row.matches('[aria-selected="true"],[aria-current="true"],[data-selected="true"]'));
|
|
728
|
+
const next = rows[Math.max(0, Math.min(rows.length - 1, current + (event.key === 'ArrowDown' ? 1 : -1)))];
|
|
729
|
+
if (next && next !== rows[current]) { event.preventDefault(); next.click(); next.scrollIntoView({ block: 'nearest' }); }
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
733
|
+
document.addEventListener('pointermove', onMove, true);
|
|
734
|
+
document.addEventListener('keydown', onKey, true);
|
|
735
|
+
return () => {
|
|
736
|
+
document.removeEventListener('pointerdown', onDown, true);
|
|
737
|
+
document.removeEventListener('pointermove', onMove, true);
|
|
738
|
+
document.removeEventListener('keydown', onKey, true);
|
|
739
|
+
if (magnet) magnet.style.translate = '';
|
|
740
|
+
for (const node of document.querySelectorAll('.dpt-ripple')) node.remove();
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// Send burst, completion sparkle and embers while the agent works.
|
|
745
|
+
function watchFx() {
|
|
746
|
+
if (typeof document === 'undefined' || typeof requestAnimationFrame === 'undefined') return () => {};
|
|
747
|
+
const reduce = window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true;
|
|
748
|
+
const canvas = document.createElement('canvas');
|
|
749
|
+
canvas.className = 'dpt-fx';
|
|
750
|
+
canvas.setAttribute('aria-hidden', 'true');
|
|
751
|
+
const paint = canvas.getContext('2d');
|
|
752
|
+
if (!paint) return () => {};
|
|
753
|
+
document.body.appendChild(canvas);
|
|
754
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
755
|
+
let width = 0, height = 0, parts = [], raf = 0, lastEmber = 0, wasBusy = false;
|
|
756
|
+
const hues = ['#3370ff', '#5b8cff', '#7fd0ff', '#9dbcff', '#b48cff', '#ffffff'];
|
|
757
|
+
const busy = () => document.body.hasAttribute('data-dpt-busy');
|
|
758
|
+
function resize() {
|
|
759
|
+
width = window.innerWidth; height = window.innerHeight;
|
|
760
|
+
canvas.width = width * dpr; canvas.height = height * dpr;
|
|
761
|
+
paint.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
762
|
+
}
|
|
763
|
+
function burst(x, y, count, power) {
|
|
764
|
+
if (reduce || !uiOn()) return;
|
|
765
|
+
for (let index = 0; index < count; index++) {
|
|
766
|
+
const angle = Math.random() * Math.PI * 2, speed = (0.4 + Math.random()) * power;
|
|
767
|
+
parts.push({ x, y, vx: Math.cos(angle) * speed, vy: Math.sin(angle) * speed - power * 0.35, life: 1,
|
|
768
|
+
decay: 0.014 + Math.random() * 0.016, r: 1.4 + Math.random() * 2.4, color: hues[(Math.random() * hues.length) | 0] });
|
|
769
|
+
}
|
|
770
|
+
kick();
|
|
771
|
+
}
|
|
772
|
+
const kick = () => { if (!raf) raf = requestAnimationFrame(frame); };
|
|
773
|
+
function frame() {
|
|
774
|
+
raf = 0;
|
|
775
|
+
paint.clearRect(0, 0, width, height);
|
|
776
|
+
paint.globalCompositeOperation = 'lighter';
|
|
777
|
+
const composer = document.querySelector('[data-dpt-composer]');
|
|
778
|
+
const now = performance.now();
|
|
779
|
+
// Embers rise from the composer while the agent works: twice as often as dsh-refined-ui, slightly larger.
|
|
780
|
+
if (busy() && !reduce && composer && now - lastEmber > 35) {
|
|
781
|
+
lastEmber = now;
|
|
782
|
+
const rect = composer.getBoundingClientRect();
|
|
783
|
+
parts.push({ x: rect.left + 12 + Math.random() * (rect.width - 24), y: rect.top + 2, vx: (Math.random() - 0.5) * 0.5,
|
|
784
|
+
vy: -(0.5 + Math.random() * 1.1), gravity: -0.004, life: 1, decay: 0.009 + Math.random() * 0.01,
|
|
785
|
+
r: 1.8 + Math.random() * 2.4, color: hues[(Math.random() * 4) | 0] });
|
|
786
|
+
}
|
|
787
|
+
parts = parts.filter(part => part.life > 0);
|
|
788
|
+
for (const part of parts) {
|
|
789
|
+
part.x += part.vx; part.y += part.vy; part.vy += part.gravity ?? 0.09; part.vx *= 0.985; part.life -= part.decay;
|
|
790
|
+
paint.globalAlpha = Math.max(part.life, 0);
|
|
791
|
+
paint.fillStyle = part.color;
|
|
792
|
+
paint.beginPath();
|
|
793
|
+
paint.arc(part.x, part.y, part.r * (0.4 + part.life * 0.6), 0, 6.3);
|
|
794
|
+
paint.fill();
|
|
795
|
+
}
|
|
796
|
+
paint.globalAlpha = 1;
|
|
797
|
+
paint.globalCompositeOperation = 'source-over';
|
|
798
|
+
if (parts.length || busy()) kick();
|
|
799
|
+
}
|
|
800
|
+
const center = node => { const rect = node.getBoundingClientRect(); return [rect.left + rect.width / 2, rect.top + rect.height / 2]; };
|
|
801
|
+
function onDown(event) {
|
|
802
|
+
const button = event.target?.closest?.('[data-dpt-send]');
|
|
803
|
+
if (button && event.button === 0) burst(...center(button), 34, 4.2);
|
|
804
|
+
}
|
|
805
|
+
function onKey(event) {
|
|
806
|
+
if (event.key !== 'Enter' || event.shiftKey || event.isComposing || event.keyCode === 229) return;
|
|
807
|
+
if (!event.target?.closest?.('[data-composer-input]')) return;
|
|
808
|
+
const button = document.querySelector('[data-dpt-send]');
|
|
809
|
+
if (button) burst(...center(button), 34, 4.2);
|
|
810
|
+
}
|
|
811
|
+
const observer = new MutationObserver(() => {
|
|
812
|
+
const now = busy();
|
|
813
|
+
if (wasBusy && !now) {
|
|
814
|
+
const composer = document.querySelector('[data-dpt-composer]');
|
|
815
|
+
if (composer) {
|
|
816
|
+
const rect = composer.getBoundingClientRect();
|
|
817
|
+
burst(rect.left + rect.width / 2, rect.top, 22, 3.2);
|
|
818
|
+
burst(rect.left + rect.width * 0.25, rect.top, 10, 2.4);
|
|
819
|
+
burst(rect.left + rect.width * 0.75, rect.top, 10, 2.4);
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
if (now) kick();
|
|
823
|
+
wasBusy = now;
|
|
824
|
+
});
|
|
825
|
+
resize();
|
|
826
|
+
window.addEventListener('resize', resize);
|
|
827
|
+
observer.observe(document.body, { attributes: true, attributeFilter: ['data-dpt-busy'] });
|
|
828
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
829
|
+
document.addEventListener('keydown', onKey, true);
|
|
830
|
+
FX.burst = () => {
|
|
831
|
+
[[0.3, 0.45], [0.5, 0.3], [0.7, 0.45]].forEach(([x, y], index) => setTimeout(() => burst(width * x, height * y, 60, 5.6), index * 220));
|
|
832
|
+
};
|
|
833
|
+
return () => {
|
|
834
|
+
FX.burst = () => {};
|
|
835
|
+
window.removeEventListener('resize', resize);
|
|
836
|
+
document.removeEventListener('pointerdown', onDown, true);
|
|
837
|
+
document.removeEventListener('keydown', onKey, true);
|
|
838
|
+
observer.disconnect();
|
|
839
|
+
if (raf) cancelAnimationFrame(raf);
|
|
840
|
+
canvas.remove();
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
|
|
844
|
+
// Ctrl+Alt+D shows and copies a read-only outline of the markers this plugin relies on.
|
|
845
|
+
function diagnostics() {
|
|
846
|
+
const count = selector => document.querySelectorAll(selector).length;
|
|
847
|
+
const current = SESSIONS.current();
|
|
848
|
+
const lines = [
|
|
849
|
+
`${PLUGIN} client | ui=${uiOn()} busy=${document.body.hasAttribute('data-dpt-busy')} session=${current?.id ?? '-'} preset=${current?.preset ?? '-'} refined-ui=${refinedPresent()}`,
|
|
850
|
+
`tags: composer=${count('[data-dpt-composer]')} send=${count('[data-dpt-send]')} bubble=${count('[data-dpt-bubble]')} docked=${count('[data-dpt-docked]')}`,
|
|
851
|
+
`markers: composer-input=${count('[data-composer-input]')} user-rows=${count('[data-chat-flow-kind="user"]')} assistant=${count('[data-chat-flow-kind="assistant-step"]')} session-rows=${count('[data-row-key^="session:"]')} chat-regions=${count('[data-conversation-region="chat"]')} main=${count('[data-slot="main.conversation"]')}`,
|
|
852
|
+
`cards: skills=${count('.dpt-skills')} side=${count('.dpt-agents')} pill=${count('.dpt-agents-pill')} side-state=${JSON.stringify(PANEL.state)}`,
|
|
853
|
+
];
|
|
854
|
+
return lines.join('\n');
|
|
855
|
+
}
|
|
856
|
+
function watchDiagnostics() {
|
|
857
|
+
if (typeof document === 'undefined') return () => {};
|
|
858
|
+
let panel = null;
|
|
859
|
+
const close = () => { panel?.remove(); panel = null; };
|
|
860
|
+
function onKey(event) {
|
|
861
|
+
if (!(event.ctrlKey && event.altKey && (event.key === 'd' || event.key === 'D'))) return;
|
|
862
|
+
if (!panel && !uiOn()) return;
|
|
863
|
+
event.preventDefault();
|
|
864
|
+
if (panel) { close(); return; }
|
|
865
|
+
const text = diagnostics();
|
|
866
|
+
try { navigator.clipboard?.writeText(text); } catch { /* copying is a convenience */ }
|
|
867
|
+
panel = document.createElement('pre');
|
|
868
|
+
panel.dataset.plugin = PLUGIN;
|
|
869
|
+
panel.textContent = text;
|
|
870
|
+
panel.style.cssText = 'position:fixed;z-index:2147483647;right:12px;bottom:12px;max-width:760px;max-height:70vh;overflow:auto;margin:0;padding:10px 12px;background:#0b1220;color:#dbe7ff;font:11px/1.45 ui-monospace,Consolas,monospace;border-radius:10px;white-space:pre-wrap;box-shadow:0 10px 30px rgba(0,0,0,.4)';
|
|
871
|
+
document.body.appendChild(panel);
|
|
872
|
+
}
|
|
873
|
+
document.addEventListener('keydown', onKey, true);
|
|
874
|
+
return () => { document.removeEventListener('keydown', onKey, true); close(); };
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
// ---------------------------------------------------------------------------------------------
|
|
878
|
+
// Skill card, at the end of the latest turn in the conversation.
|
|
879
|
+
// ---------------------------------------------------------------------------------------------
|
|
880
|
+
const SKILL_ROWS = 4;
|
|
881
|
+
const SkillIcon = () => h('svg', { width: 16, height: 16, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
|
|
882
|
+
h('path', { d: 'M3.5 2.75h6.25L12.5 5.5v7.75H3.5z', stroke: 'currentColor', strokeWidth: 1.3, strokeLinejoin: 'round' }),
|
|
883
|
+
h('path', { d: 'M9.5 2.75V5.75h3M5.75 8.5h4.5M5.75 10.75h3', stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round' }));
|
|
884
|
+
|
|
885
|
+
function SkillSwitch({ on, disabled, label, onChange }) {
|
|
886
|
+
return h('button', { type: 'button', role: 'switch', className: 'dpt-switch', 'aria-checked': on, 'aria-label': label, title: label, disabled,
|
|
887
|
+
onClick: () => { if (!disabled) onChange(!on); } }, h('span', { className: 'dpt-switch-thumb', 'aria-hidden': 'true' }));
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
function SkillCard({ turn, useProjection, useChat, setSkill, setAll, t }) {
|
|
891
|
+
const [busy, setBusy] = React.useState(false);
|
|
892
|
+
const [expanded, setExpanded] = React.useState(false);
|
|
893
|
+
// Projection failures are not caught: a silent null would make a broken card look like "no skills".
|
|
894
|
+
const state = useProjection('deepPtcSkills');
|
|
895
|
+
const lastTurn = typeof useChat === 'function' ? useChat(snapshot => snapshot?.timeline?.turnOrder?.at?.(-1)) : undefined;
|
|
896
|
+
const turnNumber = typeof turn === 'number' ? turn : turn?.turn;
|
|
897
|
+
const latest = turnNumber === undefined || (lastTurn !== undefined ? lastTurn === turnNumber : state?.turn === turnNumber);
|
|
898
|
+
if (!state || state.phase !== 'idle' || !Array.isArray(state.skills) || state.skills.length === 0 || !latest) return null;
|
|
899
|
+
async function run(action) {
|
|
900
|
+
setBusy(true);
|
|
901
|
+
try { await action(); } catch { /* the projection is authoritative */ } finally { setBusy(false); }
|
|
902
|
+
}
|
|
903
|
+
const closing = state.skills.filter(row => !row.enabled).length;
|
|
904
|
+
const rows = expanded ? state.skills : state.skills.slice(0, SKILL_ROWS);
|
|
905
|
+
return h('section', { className: 'dpt-card dpt-skills', 'aria-label': t('skillTitle') },
|
|
906
|
+
h('header', { className: 'dpt-card-head' },
|
|
907
|
+
h('span', { className: 'dpt-card-icon' }, h(SkillIcon)),
|
|
908
|
+
h('div', { className: 'dpt-card-titles' },
|
|
909
|
+
h('span', { className: 'dpt-card-title' }, t('skillTitle')),
|
|
910
|
+
h('span', { className: 'dpt-card-sub' }, tf(t, 'skillLoaded', { count: state.skills.length }),
|
|
911
|
+
closing ? h(React.Fragment, null, ' · ', h('span', { 'data-tone': 'warn' }, tf(t, 'skillClosing', { count: closing }))) : null)),
|
|
912
|
+
h('div', { className: 'dpt-card-actions' },
|
|
913
|
+
h('button', { type: 'button', className: 'dpt-btn', disabled: busy || closing === 0, 'aria-busy': busy,
|
|
914
|
+
onClick: () => { void run(() => setAll(true)); } }, t('skillKeepAll')),
|
|
915
|
+
h('button', { type: 'button', className: 'dpt-btn', disabled: busy || closing === state.skills.length, 'aria-busy': busy,
|
|
916
|
+
onClick: () => { void run(() => setAll(false)); } }, t('skillCloseAll')))),
|
|
917
|
+
h('ul', { className: 'dpt-skill-list' }, ...rows.map(row => h('li', { key: row.name, className: 'dpt-skill', 'data-off': row.enabled ? undefined : '' },
|
|
918
|
+
h('div', { className: 'dpt-skill-text' },
|
|
919
|
+
h('span', { className: 'dpt-skill-name' }, h('span', null, row.name),
|
|
920
|
+
row.loadedTurn === state.turn ? h('span', { className: 'dpt-tag' }, t('skillThisTurn')) : null),
|
|
921
|
+
h('span', { className: 'dpt-skill-desc', title: row.description || t('skillNoDescription') }, row.description || t('skillNoDescription'))),
|
|
922
|
+
h(SkillSwitch, { on: row.enabled, disabled: busy, label: row.name, onChange: value => { void run(() => setSkill(row.name, value)); } })))),
|
|
923
|
+
h('footer', { className: 'dpt-card-foot' }, h('span', null, t('skillHint')),
|
|
924
|
+
state.skills.length > SKILL_ROWS ? h('button', { type: 'button', className: 'dpt-link', onClick: () => setExpanded(!expanded) },
|
|
925
|
+
expanded ? t('skillShowLess') : tf(t, 'skillShowAll', { count: state.skills.length })) : null));
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
function SkillTail(props) {
|
|
929
|
+
// Registered for every session; only Deep PTC sessions read the skill projection.
|
|
930
|
+
let preset;
|
|
931
|
+
try { preset = props.useProjection('agentPreset'); } catch { return null; }
|
|
932
|
+
if (preset !== 'deep-ptc') return null;
|
|
933
|
+
return h(SkillCard, props);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// ---------------------------------------------------------------------------------------------
|
|
937
|
+
// Subagent panel beside the main conversation. Rows follow the official subagent catalog and
|
|
938
|
+
// timing projections; a row opens the official subagent chat in the right sidebar.
|
|
939
|
+
// ---------------------------------------------------------------------------------------------
|
|
940
|
+
const AGENT_ROWS = 24;
|
|
941
|
+
const PANEL_WIDTH = 248;
|
|
942
|
+
// Docked, the card is a column split off the right side of the conversation, flush with its edge.
|
|
943
|
+
const SPLIT_WIDTH = 272;
|
|
944
|
+
const DOCK_MIN_WIDTH = 960;
|
|
945
|
+
const COLLAPSED_KEY = `${PLUGIN}:subagents-collapsed`;
|
|
946
|
+
const readCollapsed = () => { try { return localStorage.getItem(COLLAPSED_KEY) === '1'; } catch { return false; } };
|
|
947
|
+
const writeCollapsed = value => { try { localStorage.setItem(COLLAPSED_KEY, value ? '1' : '0'); } catch { /* per-viewer convenience only */ } };
|
|
948
|
+
|
|
949
|
+
function subagentRows(sessions, rootId, now) {
|
|
950
|
+
const catalogOf = id => {
|
|
951
|
+
const value = sessions?.projectionsBySession?.[id]?.values?.subagentCatalog ?? sessions?.byId?.[id]?.projectionValues?.subagentCatalog;
|
|
952
|
+
return Array.isArray(value) ? value : [];
|
|
953
|
+
};
|
|
954
|
+
const rows = [];
|
|
955
|
+
const seen = new Set([rootId]);
|
|
956
|
+
const visit = (parentId, depth) => {
|
|
957
|
+
if (depth > 2) return;
|
|
958
|
+
for (const entry of catalogOf(parentId)) {
|
|
959
|
+
if (rows.length >= AGENT_ROWS) return;
|
|
960
|
+
if (typeof entry?.id !== 'string' || seen.has(entry.id)) continue;
|
|
961
|
+
seen.add(entry.id);
|
|
962
|
+
const summary = sessions?.byId?.[entry.id];
|
|
963
|
+
const timing = summary?.projectionValues?.subagentTiming;
|
|
964
|
+
const external = entry.mode === 'external';
|
|
965
|
+
// The parent's catalog refreshes only when the official dropdown opens; the session list carries
|
|
966
|
+
// each session's live running flag.
|
|
967
|
+
const running = !external && (entry.activity === 'running' || summary?.running === true);
|
|
968
|
+
const completed = !external && entry.activity === 'inactive' && timing?.lastTurnCompleted === true;
|
|
969
|
+
const duration = timing === undefined || external ? undefined : timing.active === undefined ? timing.settledMs
|
|
970
|
+
: timing.settledMs + Math.max(0, (running ? now : timing.active.through) - timing.active.since);
|
|
971
|
+
const usage = summary?.projectionValues?.tokenUsage;
|
|
972
|
+
const tokens = usage ? usage.uncachedInputTokens + usage.outputTokens + usage.cacheReadTokens + usage.cacheWriteTokens : undefined;
|
|
973
|
+
rows.push({ id: entry.id, parentId, mode: entry.mode, depth,
|
|
974
|
+
label: entry.label ?? summary?.title ?? summary?.displayTitle ?? entry.id,
|
|
975
|
+
state: external ? 'external' : running ? 'running' : completed ? 'completed' : 'idle',
|
|
976
|
+
duration: Number.isFinite(duration) ? duration : undefined, tokens: Number.isFinite(tokens) ? tokens : undefined });
|
|
977
|
+
visit(entry.id, depth + 1);
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
visit(rootId, 0);
|
|
981
|
+
return rows;
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
function formatDuration(ms, t) {
|
|
985
|
+
const total = Math.floor(Math.max(0, ms) / 1000);
|
|
986
|
+
const h = Math.floor(total / 3600), m = Math.floor(total / 60) % 60, s = total % 60;
|
|
987
|
+
if (h > 0) return tf(t, 'durationHours', { h, m });
|
|
988
|
+
if (total >= 60) return tf(t, 'durationMinutes', { m: Math.floor(total / 60), s });
|
|
989
|
+
return tf(t, 'durationSeconds', { s });
|
|
990
|
+
}
|
|
991
|
+
function formatTokens(value) {
|
|
992
|
+
if (value < 1000) return String(value);
|
|
993
|
+
const scaled = value < 1e6 ? value / 1000 : value / 1e6;
|
|
994
|
+
return `${scaled >= 100 ? Math.round(scaled) : Math.round(scaled * 10) / 10}${value < 1e6 ? 'k' : 'M'}`;
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
function openSubagent(row) {
|
|
998
|
+
const sidebar = hostCtx?.get?.('sidebarRight');
|
|
999
|
+
if (typeof sidebar?.openResource === 'function') {
|
|
1000
|
+
const query = new URLSearchParams({ parent: row.parentId, mode: row.mode ?? 'unknown' });
|
|
1001
|
+
sidebar.openResource(`dsh-resource://subagentchat/session/${encodeURIComponent(row.id)}?${query}`, { kind: 'subagentchat', preferNewPane: true });
|
|
1002
|
+
return;
|
|
1003
|
+
}
|
|
1004
|
+
const workspace = hostCtx?.get?.('uiWorkspace');
|
|
1005
|
+
if (typeof workspace?.openSession === 'function') {
|
|
1006
|
+
workspace.openSession({ parentSessionId: row.parentId, childSessionId: row.id, mode: row.mode });
|
|
1007
|
+
return;
|
|
1008
|
+
}
|
|
1009
|
+
const escaped = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(row.id) : row.id;
|
|
1010
|
+
document.querySelector(`[data-row-key="session:${escaped}"]`)?.click();
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
// Where the panel sits: the right edge of this session's chat region, above the composer.
|
|
1014
|
+
function useChatRegion(sessionId, enabled) {
|
|
1015
|
+
const [layout, setLayout] = React.useState(undefined);
|
|
1016
|
+
React.useEffect(() => {
|
|
1017
|
+
if (!enabled || typeof document === 'undefined') { setLayout(undefined); return undefined; }
|
|
1018
|
+
let last = '';
|
|
1019
|
+
let lastRegion;
|
|
1020
|
+
const measure = () => {
|
|
1021
|
+
const escaped = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(sessionId) : sessionId;
|
|
1022
|
+
const regions = [...document.querySelectorAll(`[data-conversation-region="chat"][data-conversation-session="${escaped}"]`)];
|
|
1023
|
+
const anyMain = document.querySelector('[data-slot="main.conversation"]') !== null;
|
|
1024
|
+
const region = regions.find(node => !anyMain || node.closest('[data-slot="main.conversation"]'));
|
|
1025
|
+
const rect = region?.getBoundingClientRect();
|
|
1026
|
+
if (!region || !rect || rect.width === 0) { if (last !== '-') { last = '-'; lastRegion = undefined; setLayout(undefined); } return; }
|
|
1027
|
+
// Docked, the region gives up the column's width, so its parent marks the conversation's right edge.
|
|
1028
|
+
const host = region.parentElement?.getBoundingClientRect() ?? rect;
|
|
1029
|
+
const composer = region.querySelector('[data-composer-seat]')?.getBoundingClientRect();
|
|
1030
|
+
const bottom = composer && composer.top > rect.top ? composer.top - 12 : rect.bottom - 12;
|
|
1031
|
+
const next = { region, top: Math.round(rect.top + 12), right: Math.round(window.innerWidth - rect.right + 16),
|
|
1032
|
+
maxHeight: Math.max(120, Math.round(bottom - rect.top - 12)), wide: host.width >= DOCK_MIN_WIDTH,
|
|
1033
|
+
split: { top: Math.round(rect.top), right: Math.round(window.innerWidth - host.right), height: Math.round(rect.height) } };
|
|
1034
|
+
const key = `${next.top}|${next.right}|${next.maxHeight}|${next.wide}|${next.split.top}|${next.split.right}|${next.split.height}`;
|
|
1035
|
+
if (key !== last || region !== lastRegion) { last = key; lastRegion = region; setLayout(next); }
|
|
1036
|
+
};
|
|
1037
|
+
measure();
|
|
1038
|
+
const timer = setInterval(measure, 400);
|
|
1039
|
+
window.addEventListener('resize', measure);
|
|
1040
|
+
return () => { clearInterval(timer); window.removeEventListener('resize', measure); };
|
|
1041
|
+
}, [sessionId, enabled]);
|
|
1042
|
+
return layout;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
// The execution environment for Deep PTC sessions created from now on. It writes the same host
|
|
1046
|
+
// settings form as the plugin settings page; a session keeps the environment it was created with.
|
|
1047
|
+
const ENV_SHORT = { auto: 'envAuto', wsl: 'WSL', powershell: 'PowerShell', zsh: 'Zsh', bash: 'Bash' };
|
|
1048
|
+
const NO_FORM = { status: 'unavailable' };
|
|
1049
|
+
const noSubscribe = () => () => {};
|
|
1050
|
+
const noSnapshot = () => NO_FORM;
|
|
1051
|
+
const allowedEnvironments = platform => platform === 'win32' ? ['auto', 'wsl', 'powershell'] : ['auto', 'zsh', 'bash'];
|
|
1052
|
+
const effectiveEnvironment = (environment, platform) => environment !== 'auto' ? environment
|
|
1053
|
+
: platform === 'win32' ? 'powershell' : platform === 'darwin' ? 'zsh' : 'bash';
|
|
1054
|
+
const envLabel = (value, t) => value === 'auto' ? t('envAuto') : ENV_SHORT[value] ?? value;
|
|
1055
|
+
|
|
1056
|
+
function useSettingsForm(form) {
|
|
1057
|
+
const subscribe = React.useCallback(listener => form ? form.subscribe(listener) : () => {}, [form]);
|
|
1058
|
+
const read = React.useCallback(() => form ? form.getSnapshot() : NO_FORM, [form]);
|
|
1059
|
+
return React.useSyncExternalStore(form ? subscribe : noSubscribe, form ? read : noSnapshot, form ? read : noSnapshot);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
function EnvironmentSection({ form, t }) {
|
|
1063
|
+
const state = useSettingsForm(form);
|
|
1064
|
+
const [saving, setSaving] = React.useState(false);
|
|
1065
|
+
const [message, setMessage] = React.useState(null);
|
|
1066
|
+
const [distribution, setDistribution] = React.useState(undefined);
|
|
1067
|
+
if (!form || state.status === 'unavailable') return null;
|
|
1068
|
+
if (state.status !== 'ready' || !state.value) return h('section', { className: 'dpt-side-section' }, h('p', { className: 'dpt-side-note' }, t('loading')));
|
|
1069
|
+
const value = state.value;
|
|
1070
|
+
const platform = value.hostPlatform;
|
|
1071
|
+
const environment = value.environment ?? 'auto';
|
|
1072
|
+
const effective = effectiveEnvironment(environment, platform);
|
|
1073
|
+
const choices = (Array.isArray(value.shellChoices) ? value.shellChoices : []).filter(item => item && typeof item.id === 'string');
|
|
1074
|
+
const disabled = !state.writable || saving;
|
|
1075
|
+
const savedDistribution = value.wslDistribution ?? '';
|
|
1076
|
+
const draft = distribution ?? savedDistribution;
|
|
1077
|
+
async function save(ops, label) {
|
|
1078
|
+
setSaving(true); setMessage(null);
|
|
1079
|
+
try {
|
|
1080
|
+
const ok = await form.mutate(ops, form.getSnapshot().revision);
|
|
1081
|
+
if (!ok) throw new Error('rejected');
|
|
1082
|
+
setMessage({ tone: 'ok', text: tf(t, 'envSaved', { env: label }) });
|
|
1083
|
+
return true;
|
|
1084
|
+
} catch {
|
|
1085
|
+
setMessage({ tone: 'error', text: t('envFailed') });
|
|
1086
|
+
return false;
|
|
1087
|
+
} finally { setSaving(false); }
|
|
1088
|
+
}
|
|
1089
|
+
function choose(next) {
|
|
1090
|
+
if (next === environment) return;
|
|
1091
|
+
const family = effectiveEnvironment(next, platform);
|
|
1092
|
+
const current = choices.find(item => item.id === value.shellExecutable);
|
|
1093
|
+
const ops = [{ op: 'set', path: ['environment'], value: next }];
|
|
1094
|
+
// A shell picked for another family would not apply; fall back to the official lookup.
|
|
1095
|
+
if (value.shellExecutable && current?.family !== family) ops.push({ op: 'set', path: ['shellExecutable'], value: '' });
|
|
1096
|
+
void save(ops, envLabel(next, t));
|
|
1097
|
+
}
|
|
1098
|
+
async function saveDistribution(event) {
|
|
1099
|
+
event?.preventDefault?.();
|
|
1100
|
+
const next = draft.trim();
|
|
1101
|
+
if (next === savedDistribution) { setDistribution(undefined); return; }
|
|
1102
|
+
if (await save([{ op: 'set', path: ['wslDistribution'], value: next }], next ? `WSL (${next})` : 'WSL')) setDistribution(undefined);
|
|
1103
|
+
}
|
|
1104
|
+
const familyChoices = choices.filter(item => item.family === effective);
|
|
1105
|
+
return h('section', { className: 'dpt-side-section', 'aria-label': t('environment') },
|
|
1106
|
+
h('div', { className: 'dpt-side-label' }, h('span', null, t('environment')), h('span', { className: 'dpt-side-hint' }, t('envForNew'))),
|
|
1107
|
+
h('div', { className: 'dpt-seg', role: 'radiogroup', 'aria-label': t('environment') },
|
|
1108
|
+
...allowedEnvironments(platform).map(option => h('button', { key: option, type: 'button', role: 'radio', className: 'dpt-seg-btn',
|
|
1109
|
+
'aria-checked': option === environment, disabled, title: t(option), onClick: () => choose(option) }, envLabel(option, t)))),
|
|
1110
|
+
effective === 'wsl' ? h('form', { className: 'dpt-field', onSubmit: saveDistribution },
|
|
1111
|
+
h('input', { className: 'dpt-input', value: draft, disabled, placeholder: t('envDefaultDistribution'), 'aria-label': t('distribution'),
|
|
1112
|
+
title: t('distributionHint'), onChange: event => { setDistribution(event.target.value); setMessage(null); } }),
|
|
1113
|
+
draft.trim() !== savedDistribution ? h('button', { type: 'submit', className: 'dpt-btn', disabled }, t('save')) : null) : null,
|
|
1114
|
+
effective !== 'wsl' && familyChoices.length > 0 ? h('div', { className: 'dpt-field' },
|
|
1115
|
+
h('select', { className: 'dpt-select', value: value.shellExecutable ?? '', disabled, 'aria-label': t('shell'), title: t('shellHint'),
|
|
1116
|
+
onChange: event => { const item = familyChoices.find(choice => choice.id === event.target.value);
|
|
1117
|
+
void save([{ op: 'set', path: ['shellExecutable'], value: event.target.value }], item ? item.label : t('shellAuto')); } },
|
|
1118
|
+
h('option', { value: '' }, t('shellAuto')), ...familyChoices.map(item => h('option', { key: item.id, value: item.id }, item.label)))) : null,
|
|
1119
|
+
h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message?.tone },
|
|
1120
|
+
message ? message.text : !state.writable ? t('readOnly') : environment === 'auto' ? tf(t, 'envAutoNow', { env: envLabel(effective, t) }) : t('envThisSession')));
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
function SidePanel({ sessionId, useSessions, useProjection, reset, form, t }) {
|
|
1124
|
+
const sessions = typeof useSessions === 'function' ? useSessions(state => state) : undefined;
|
|
1125
|
+
let tools;
|
|
1126
|
+
try { tools = typeof useProjection === 'function' ? useProjection('deepPtcTools') : undefined; } catch { tools = undefined; }
|
|
1127
|
+
const hasTools = typeof reset === 'function';
|
|
1128
|
+
const toolFailures = tools && typeof tools === 'object' ? (tools.report?.tools ?? []).length : 0;
|
|
1129
|
+
PANEL.state = { tools: tools === null ? 'null' : typeof tools, reset: typeof reset, form: form ? 'yes' : 'no' };
|
|
1130
|
+
const settings = useSettingsForm(form);
|
|
1131
|
+
const [now, setNow] = React.useState(() => Date.now());
|
|
1132
|
+
const [collapsed, setCollapsed] = React.useState(readCollapsed);
|
|
1133
|
+
const [peek, setPeek] = React.useState(false);
|
|
1134
|
+
const rows = subagentRows(sessions, sessionId, now);
|
|
1135
|
+
const running = rows.filter(row => row.state === 'running').length;
|
|
1136
|
+
const completed = rows.filter(row => row.state === 'completed').length;
|
|
1137
|
+
const hasEnvironment = !!form && settings.status !== 'unavailable';
|
|
1138
|
+
const layout = useChatRegion(sessionId, (rows.length > 0 || hasEnvironment || hasTools) && canPortal());
|
|
1139
|
+
const docked = !!layout && layout.wide && !collapsed;
|
|
1140
|
+
React.useEffect(() => {
|
|
1141
|
+
if (running === 0) return undefined;
|
|
1142
|
+
const timer = setInterval(() => setNow(Date.now()), 1000);
|
|
1143
|
+
return () => clearInterval(timer);
|
|
1144
|
+
}, [running > 0]);
|
|
1145
|
+
React.useEffect(() => {
|
|
1146
|
+
SESSIONS.setWorking(sessionId, running > 0);
|
|
1147
|
+
return () => SESSIONS.setWorking(sessionId, false);
|
|
1148
|
+
}, [sessionId, running > 0]);
|
|
1149
|
+
React.useEffect(() => {
|
|
1150
|
+
const region = layout?.region;
|
|
1151
|
+
if (!region) return undefined;
|
|
1152
|
+
region.toggleAttribute('data-dpt-docked', docked);
|
|
1153
|
+
return () => region.removeAttribute('data-dpt-docked');
|
|
1154
|
+
}, [layout?.region, docked]);
|
|
1155
|
+
React.useEffect(() => {
|
|
1156
|
+
PANEL.toggle = () => {
|
|
1157
|
+
if (layout && !layout.wide) { setPeek(value => !value); return; }
|
|
1158
|
+
setCollapsed(value => { writeCollapsed(!value); return !value; });
|
|
1159
|
+
};
|
|
1160
|
+
return () => { PANEL.toggle = () => {}; };
|
|
1161
|
+
}, [layout?.wide]);
|
|
1162
|
+
if (!layout || (rows.length === 0 && !hasEnvironment && !hasTools) || !canPortal()) return null;
|
|
1163
|
+
const position = { top: `${layout.top}px`, right: `${layout.right}px` };
|
|
1164
|
+
const summary = [running ? tf(t, 'agentsRunning', { count: running }) : null, completed ? tf(t, 'agentsCompleted', { count: completed }) : null,
|
|
1165
|
+
rows.length - running - completed > 0 ? tf(t, 'agentsIdle', { count: rows.length - running - completed }) : null].filter(Boolean).join(' · ');
|
|
1166
|
+
const environment = settings.status === 'ready' && settings.value ? envLabel(settings.value.environment ?? 'auto', t) : undefined;
|
|
1167
|
+
if (!docked && !peek) {
|
|
1168
|
+
const expand = () => { if (layout.wide) { writeCollapsed(false); setCollapsed(false); } else setPeek(true); };
|
|
1169
|
+
const label = [environment, rows.length ? `${t('agentsTitle')} ${rows.length}` : null, toolFailures ? `${t('toolFailures')} ${toolFailures}` : null].filter(Boolean).join(' · ');
|
|
1170
|
+
return ReactDOM.createPortal(h('button', { type: 'button', className: 'dpt-agents-pill', style: position, 'data-state': running ? 'running' : 'idle',
|
|
1171
|
+
'aria-label': t('agentsExpand'), title: summary || t('agentsExpand'), onClick: expand },
|
|
1172
|
+
h('span', { className: 'dpt-agent-dot', 'aria-hidden': 'true' }), label || t('sideTitle')), document.body);
|
|
1173
|
+
}
|
|
1174
|
+
const stateText = row => row.state === 'running' ? t('agentRunning') : row.state === 'completed' ? t('agentCompleted') : row.state === 'external' ? t('agentExternal') : t('agentIdle');
|
|
1175
|
+
const collapse = () => { if (layout.wide) { writeCollapsed(true); setCollapsed(true); } setPeek(false); };
|
|
1176
|
+
const frame = docked
|
|
1177
|
+
? { top: `${layout.split.top}px`, right: `${layout.split.right}px`, height: `${layout.split.height}px`, width: `${SPLIT_WIDTH}px` }
|
|
1178
|
+
: { ...position, maxHeight: `${layout.maxHeight}px`, width: `${PANEL_WIDTH}px` };
|
|
1179
|
+
return ReactDOM.createPortal(h('aside', { className: 'dpt-agents', 'data-split': docked ? '' : undefined, 'aria-label': t('sideTitle'), style: frame },
|
|
1180
|
+
h('header', { className: 'dpt-agents-head' },
|
|
1181
|
+
h('span', { className: 'dpt-agents-title' }, t('sideTitle')),
|
|
1182
|
+
h('span', { className: 'dpt-agents-count' }),
|
|
1183
|
+
h('button', { type: 'button', className: 'dpt-icon-btn', 'aria-label': t('agentsCollapse'), title: t('agentsCollapse'), onClick: collapse },
|
|
1184
|
+
h('svg', { width: 14, height: 14, viewBox: '0 0 16 16', fill: 'none', 'aria-hidden': 'true' },
|
|
1185
|
+
h('path', { d: 'M6 4l4 4-4 4', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round', strokeLinejoin: 'round' })))),
|
|
1186
|
+
h('div', { className: 'dpt-side-body' },
|
|
1187
|
+
hasEnvironment ? h(EnvironmentSection, { form, t }) : null,
|
|
1188
|
+
rows.length ? h('section', { className: 'dpt-side-section dpt-side-agents', 'aria-label': t('agentsTitle') },
|
|
1189
|
+
h('div', { className: 'dpt-side-label' }, h('span', null, t('agentsTitle')), h('span', { className: 'dpt-side-hint', title: summary }, summary)),
|
|
1190
|
+
h('ol', { className: 'dpt-agents-list' }, ...rows.map(row => {
|
|
1191
|
+
const meta = [stateText(row), row.duration !== undefined ? formatDuration(row.duration, t) : null,
|
|
1192
|
+
row.tokens !== undefined ? tf(t, 'tokens', { value: formatTokens(row.tokens) }) : null].filter(Boolean).join(' · ');
|
|
1193
|
+
return h('li', { key: row.id }, h('button', { type: 'button', className: 'dpt-agent', 'data-state': row.state, style: { '--dpt-depth': row.depth },
|
|
1194
|
+
disabled: row.state === 'external', title: t('agentOpen'), onClick: () => openSubagent(row) },
|
|
1195
|
+
h('span', { className: 'dpt-agent-dot', 'aria-hidden': 'true' }),
|
|
1196
|
+
h('span', { className: 'dpt-agent-main' }, h('span', { className: 'dpt-agent-name', title: row.label }, row.label),
|
|
1197
|
+
h('span', { className: 'dpt-agent-meta' }, meta))));
|
|
1198
|
+
}))) : null,
|
|
1199
|
+
hasTools ? h(ToolStateControls, { sessionId, useProjection, reset, t }) : null)), document.body);
|
|
1200
|
+
}
|
|
1201
|
+
|
|
1202
|
+
// A boundary keeps a failing bridge or panel from taking the conversation header with it.
|
|
1203
|
+
class Boundary extends React.Component {
|
|
1204
|
+
constructor(props) { super(props); this.state = { failed: false }; }
|
|
1205
|
+
static getDerivedStateFromError() { return { failed: true }; }
|
|
1206
|
+
componentDidCatch(error) { console.warn(`[${PLUGIN}] conversation extras disabled:`, error); }
|
|
1207
|
+
render() { return this.state.failed ? null : this.props.children; }
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
function SessionBridge(props) {
|
|
1211
|
+
const { sessionId } = props;
|
|
1212
|
+
const marker = React.useRef(null);
|
|
1213
|
+
let preset;
|
|
1214
|
+
try { preset = typeof props.useProjection === 'function' ? props.useProjection('agentPreset') : undefined; } catch { preset = undefined; }
|
|
1215
|
+
const statuses = typeof props.useSessionStatus === 'function' ? props.useSessionStatus(state => state) : undefined;
|
|
1216
|
+
const busy = statuses?.get?.(sessionId)?.running === true;
|
|
1217
|
+
React.useEffect(() => { SESSIONS.set(sessionId, { id: sessionId, preset, busy, el: marker.current }); }, [sessionId, preset, busy]);
|
|
1218
|
+
React.useEffect(() => () => SESSIONS.del(sessionId), [sessionId]);
|
|
1219
|
+
return h('span', { ref: marker, hidden: true, 'aria-hidden': 'true', 'data-dpt-bridge': sessionId });
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
function SideCardHost(props) {
|
|
1223
|
+
// Registered for every session; only Deep PTC sessions read their projections or draw the card.
|
|
1224
|
+
let preset;
|
|
1225
|
+
try { preset = props.useProjection('agentPreset'); } catch { return null; }
|
|
1226
|
+
if (preset !== 'deep-ptc') return null;
|
|
1227
|
+
return h(Boundary, null, h(SidePanel, props));
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// The skill switches run a host command, and the host logs every command. The log keeps it; the
|
|
1231
|
+
// conversation shows nothing for a success and a short line for a failure.
|
|
1232
|
+
function SkillCommandRow({ node }) {
|
|
1233
|
+
const outcome = node?.outcome;
|
|
1234
|
+
if (outcome?.kind === 'error') return h('div', { className: 'dpt-command-error', role: 'status' }, outcome.text);
|
|
1235
|
+
return h('span', { hidden: true, 'data-dpt-hidden-command': SKILL_COMMAND_NAME });
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
const SKILL_COMMAND_NAME = 'deep-ptc-skill-state';
|
|
1239
|
+
function runSkillCommand(child, sessionId, payload) {
|
|
1240
|
+
const execute = child.remote?.commands?.execute;
|
|
1241
|
+
if (typeof execute !== 'function') return Promise.resolve({ ok: false, error: { message: 'unavailable' } });
|
|
1242
|
+
// The remote command API takes the full line plus attachments. The JSON payload is command input.
|
|
1243
|
+
return execute(sessionId, `/${SKILL_COMMAND_NAME} ` + JSON.stringify(payload), []);
|
|
1244
|
+
}
|
|
1245
|
+
|
|
178
1246
|
function apply(ctx) {
|
|
1247
|
+
hostCtx = ctx;
|
|
179
1248
|
const t = ctx.locale.bind('deep-ptc');
|
|
1249
|
+
T = key => t(key);
|
|
180
1250
|
ctx.effect(() => ctx.locale.register('deep-ptc', dictionaries));
|
|
1251
|
+
ctx.effect(() => injectCss(), `${PLUGIN}: style`);
|
|
1252
|
+
ctx.effect(() => watchActiveSession(), `${PLUGIN}: active session`);
|
|
1253
|
+
ctx.effect(() => watchSurfaces(), `${PLUGIN}: surface tags`);
|
|
1254
|
+
ctx.effect(() => watchPalette(), `${PLUGIN}: command palette`);
|
|
1255
|
+
ctx.effect(() => watchInteractions(), `${PLUGIN}: interactions`);
|
|
1256
|
+
ctx.effect(() => watchFx(), `${PLUGIN}: effects`);
|
|
1257
|
+
ctx.effect(() => watchDiagnostics(), `${PLUGIN}: diagnostics`);
|
|
181
1258
|
const form = ctx.configForms.get(NS);
|
|
182
1259
|
ctx.effect(() => ctx.configForms.whileServed([NS], () =>
|
|
183
1260
|
ctx.slots.inject('plugins.item', () => ctx.slots.register({
|
|
184
1261
|
name: 'plugins.item', id: 'deep-ptc', order: 41,
|
|
185
1262
|
label: () => t('title'), locale: 'deep-ptc',
|
|
186
1263
|
}, props => h(Card, { ...props, form, t })))));
|
|
1264
|
+
try {
|
|
1265
|
+
ctx.slots.inject('conversation.chat.commandview', () => ctx.slots.register({
|
|
1266
|
+
name: 'conversation.chat.commandview', key: SKILL_COMMAND_NAME,
|
|
1267
|
+
}, SkillCommandRow));
|
|
1268
|
+
} catch { /* without the renderer the host shows its generic command row */ }
|
|
1269
|
+
try {
|
|
1270
|
+
// Each conversation header reports which session is on screen and whether it works.
|
|
1271
|
+
ctx.slots.inject('conversation.session.header.actions', () => ctx.slots.register({
|
|
1272
|
+
name: 'conversation.session.header.actions', id: 'deep-ptc-session', order: 31,
|
|
1273
|
+
}, props => h(Boundary, null, h(SessionBridge, props))));
|
|
1274
|
+
} catch { /* the conversation keeps working without the look */ }
|
|
187
1275
|
try {
|
|
188
1276
|
ctx.inject?.(['remote', 'remote.commands'], child => {
|
|
189
1277
|
try {
|
|
1278
|
+
child.slots.inject('conversation.chat.turnTail', () => child.slots.register({
|
|
1279
|
+
name: 'conversation.chat.turnTail', id: 'deep-ptc-skills', order: 20,
|
|
1280
|
+
inject: sessionId => ({
|
|
1281
|
+
setSkill: (name, enabled) => runSkillCommand(child, sessionId, { action: 'set', name, enabled }),
|
|
1282
|
+
setAll: enabled => runSkillCommand(child, sessionId, { action: 'all', enabled }),
|
|
1283
|
+
}),
|
|
1284
|
+
}, props => h(SkillTail, { ...props, t })));
|
|
1285
|
+
} catch { /* a broken card must not take the conversation with it */ }
|
|
1286
|
+
try {
|
|
1287
|
+
// The side card draws beside the conversation through a portal; nothing shows under the composer.
|
|
190
1288
|
child.slots.inject('conversation.composer.dock', () => child.slots.register({
|
|
191
|
-
name: 'conversation.composer.dock', id: 'deep-ptc-
|
|
1289
|
+
name: 'conversation.composer.dock', id: 'deep-ptc-side', order: 89,
|
|
192
1290
|
inject: sessionId => ({
|
|
193
1291
|
reset: () => {
|
|
194
1292
|
const execute = child.remote?.commands?.execute;
|
|
@@ -196,8 +1294,8 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
|
196
1294
|
return execute(sessionId, '/deep-ptc-reset-tools', []);
|
|
197
1295
|
},
|
|
198
1296
|
}),
|
|
199
|
-
}, props => h(
|
|
200
|
-
} catch { /*
|
|
1297
|
+
}, props => h(SideCardHost, { ...props, form, t })));
|
|
1298
|
+
} catch { /* the composer stays usable when this slot cannot register */ }
|
|
201
1299
|
});
|
|
202
1300
|
} catch { /* the composer stays usable when this slot cannot register */ }
|
|
203
1301
|
}
|