@restregular/dsh-powerup 0.19.6 → 0.19.8
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/client.js +23 -1
- package/index.js +143 -13
- package/lib/quick-replies.js +3 -3
- package/package.json +2 -1
package/client.js
CHANGED
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
const requirementCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
|
|
86
86
|
/** Fallback bucket when the hero cannot resolve an owning workspace yet. */
|
|
87
87
|
const UNSCOPED_WORKSPACE = '__unscoped__';
|
|
88
|
-
const VERSION = '0.19.
|
|
88
|
+
const VERSION = '0.19.8';
|
|
89
89
|
const MENU_GAP = 8;
|
|
90
90
|
const MENU_WIDTH = 248;
|
|
91
91
|
/** Reference scheme understood by the Host's `powerup_step_read` tool. */
|
|
@@ -1014,6 +1014,9 @@
|
|
|
1014
1014
|
} catch {
|
|
1015
1015
|
/* The in-memory value still works for this page. */
|
|
1016
1016
|
}
|
|
1017
|
+
if (Object.prototype.hasOwnProperty.call(patch, 'quickReplies')) {
|
|
1018
|
+
syncQuickRepliesEnabled(settingsValue.quickReplies);
|
|
1019
|
+
}
|
|
1017
1020
|
for (const listener of [...settingsListeners]) {
|
|
1018
1021
|
try {
|
|
1019
1022
|
listener();
|
|
@@ -10088,6 +10091,22 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10088
10091
|
const QUICK_REPLIES_API = '/dsh-powerup/api/quick-replies';
|
|
10089
10092
|
/** Last state per session, so options survive a component remount. */
|
|
10090
10093
|
const quickRepliesCache = new Map();
|
|
10094
|
+
/** Last flag pushed to the Host, so we only POST on a real change. */
|
|
10095
|
+
let hostQuickRepliesEnabled = null;
|
|
10096
|
+
|
|
10097
|
+
/** Mirror the settings toggle to the Host so it can add/remove the tool and prompt section. */
|
|
10098
|
+
function syncQuickRepliesEnabled(enabled) {
|
|
10099
|
+
const value = enabled !== false;
|
|
10100
|
+
if (hostQuickRepliesEnabled === value) return;
|
|
10101
|
+
hostQuickRepliesEnabled = value;
|
|
10102
|
+
void fetch(QUICK_REPLIES_API, {
|
|
10103
|
+
method: 'POST',
|
|
10104
|
+
headers: { 'content-type': 'application/json' },
|
|
10105
|
+
body: JSON.stringify({ action: 'set-enabled', enabled: value }),
|
|
10106
|
+
}).catch(() => {
|
|
10107
|
+
hostQuickRepliesEnabled = null; // allow a retry after a transient failure
|
|
10108
|
+
});
|
|
10109
|
+
}
|
|
10091
10110
|
|
|
10092
10111
|
async function quickRepliesRequest(sessionId, action, extra = {}) {
|
|
10093
10112
|
const url = action === 'get'
|
|
@@ -12040,6 +12059,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
12040
12059
|
}, 'dsh-powerup: client context');
|
|
12041
12060
|
bindLocale(ctx);
|
|
12042
12061
|
installStyles(ctx);
|
|
12062
|
+
// Align the Host tool/prompt registration with this browser's switch on load.
|
|
12063
|
+
syncQuickRepliesEnabled(settingsValue.quickReplies);
|
|
12043
12064
|
installLauncher(ctx);
|
|
12044
12065
|
installSessionSwitcher(ctx);
|
|
12045
12066
|
installLocateSession(ctx);
|
|
@@ -12329,3 +12350,4 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
12329
12350
|
},
|
|
12330
12351
|
});
|
|
12331
12352
|
})();
|
|
12353
|
+
|
package/index.js
CHANGED
|
@@ -86,6 +86,8 @@ const MASK_RULES_FILE = 'mask-rules.json';
|
|
|
86
86
|
const TASK_RESUME_FILE_NAME = TASK_RESUME_FILE;
|
|
87
87
|
/** Persisted quick-reply options, keyed by session id. */
|
|
88
88
|
const QUICK_REPLIES_FILE = 'quick-replies.json';
|
|
89
|
+
/** Persisted on/off state of the quick-replies feature (driven by the Client settings page). */
|
|
90
|
+
const QUICK_REPLIES_ENABLED_FILE = 'quick-replies-enabled.json';
|
|
89
91
|
/** Persisted progress-generation requirements (global + per workspace/session). */
|
|
90
92
|
const PROGRESS_REQUIREMENTS_FILE = 'progress-requirements.json';
|
|
91
93
|
/** Story of generated progress reports, kept on disk so refreshes never drop history. */
|
|
@@ -246,6 +248,75 @@ function appendSelfUpdateLog(line) {
|
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Brief system-prompt guidance for the quick-replies tool. Registered only
|
|
253
|
+
* while the feature is enabled, then disposed together with the tool.
|
|
254
|
+
* `interpolate: false` keeps any braces literal (the DSL treats {{x}} as a variable).
|
|
255
|
+
*/
|
|
256
|
+
const QUICK_REPLIES_PROMPT_SECTION = [
|
|
257
|
+
'## Quick reply options (dsh-powerup)',
|
|
258
|
+
'When your answer leaves a few obvious next steps, call the `powerup_quick_replies` tool to offer tappable buttons above the composer.',
|
|
259
|
+
'Pass `options` as a list of objects with `label` and `message`: `label` is the short button text, `message` is the full text sent when the user taps it.',
|
|
260
|
+
'Offer at most 8 concise, mutually exclusive choices; prefer 2-4. Use this after answering, not instead of answering.',
|
|
261
|
+
'The options vanish as soon as the user sends any message, so do not repeat them in your reply text.',
|
|
262
|
+
].join('\n');
|
|
263
|
+
|
|
264
|
+
/** Stable section name; a duplicate registration throws, so keep it unique. */
|
|
265
|
+
const QUICK_REPLIES_SECTION_NAME = 'dsh-powerup:quick-replies';
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* In-memory enabled flag plus listeners for the quick-replies feature. The
|
|
269
|
+
* Client settings toggle POSTs changes to the Host route, which calls
|
|
270
|
+
* `setQuickRepliesEnabled` and notifies the registration controller.
|
|
271
|
+
*/
|
|
272
|
+
let quickRepliesEnabled = true;
|
|
273
|
+
const quickRepliesListeners = new Set();
|
|
274
|
+
/** Live registrations owned by the feature; mutated by the apply() controller. */
|
|
275
|
+
const quickRepliesState = {
|
|
276
|
+
toolOff: undefined,
|
|
277
|
+
sectionOff: undefined,
|
|
278
|
+
sync: undefined,
|
|
279
|
+
systemPrompt: undefined,
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
function getQuickRepliesEnabled() {
|
|
283
|
+
return quickRepliesEnabled;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function setQuickRepliesEnabled(value) {
|
|
287
|
+
const next = value !== false;
|
|
288
|
+
if (next === quickRepliesEnabled) return quickRepliesEnabled;
|
|
289
|
+
quickRepliesEnabled = next;
|
|
290
|
+
try {
|
|
291
|
+
mkdirSync(dirname(storePath(QUICK_REPLIES_ENABLED_FILE)), { recursive: true });
|
|
292
|
+
writeFileSync(storePath(QUICK_REPLIES_ENABLED_FILE), JSON.stringify({ enabled: next }) + '\n', 'utf8');
|
|
293
|
+
} catch {
|
|
294
|
+
/* Persistence is best-effort; the in-memory flag still applies. */
|
|
295
|
+
}
|
|
296
|
+
for (const listener of [...quickRepliesListeners]) {
|
|
297
|
+
try { listener(next); } catch { /* one listener must not break the rest */ }
|
|
298
|
+
}
|
|
299
|
+
return next;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function subscribeQuickRepliesEnabled(listener) {
|
|
303
|
+
quickRepliesListeners.add(listener);
|
|
304
|
+
return () => quickRepliesListeners.delete(listener);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** Load persisted quick-replies switch once at module load. */
|
|
308
|
+
function loadQuickRepliesEnabled() {
|
|
309
|
+
try {
|
|
310
|
+
const parsed = JSON.parse(readFileSync(storePath(QUICK_REPLIES_ENABLED_FILE), 'utf8'));
|
|
311
|
+
if (parsed !== null && typeof parsed === 'object' && parsed.enabled !== undefined) {
|
|
312
|
+
quickRepliesEnabled = parsed.enabled !== false;
|
|
313
|
+
}
|
|
314
|
+
} catch {
|
|
315
|
+
/* Missing or corrupt file: keep the default (on). */
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
loadQuickRepliesEnabled();
|
|
319
|
+
|
|
249
320
|
/** The reason core records for a human kill; a custom reason is appended. */
|
|
250
321
|
const HUMAN_KILL_REASON = 'cancelled by the user';
|
|
251
322
|
|
|
@@ -497,14 +568,25 @@ async function handle(req, res, ctx) {
|
|
|
497
568
|
dirname,
|
|
498
569
|
});
|
|
499
570
|
if (req.method === 'GET') {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
571
|
+
// A GET without sessionId reports the feature switch, so the Client can
|
|
572
|
+
// sync the Host even before any options are published.
|
|
573
|
+
const rawSession = url.searchParams.get('sessionId');
|
|
574
|
+
if (rawSession === null) {
|
|
575
|
+
sendJson(res, { ok: true, enabled: getQuickRepliesEnabled() });
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
sendJson(res, { ok: true, enabled: getQuickRepliesEnabled(), ...store.read(rawSession.trim()) });
|
|
503
579
|
return;
|
|
504
580
|
}
|
|
505
581
|
if (req.method === 'POST') {
|
|
506
582
|
try {
|
|
507
583
|
const body = await readJsonBody(req);
|
|
584
|
+
// The settings toggle sends no sessionId and carries an `enabled` flag.
|
|
585
|
+
if (body?.action === 'set-enabled') {
|
|
586
|
+
const enabled = setQuickRepliesEnabled(body.enabled !== false);
|
|
587
|
+
sendJson(res, { ok: true, enabled });
|
|
588
|
+
return;
|
|
589
|
+
}
|
|
508
590
|
const sessionId = typeof body?.sessionId === 'string' ? body.sessionId.trim() : '';
|
|
509
591
|
if (sessionId === '') {
|
|
510
592
|
sendJson(res, { ok: false, code: 'invalid-request', error: 'sessionId is required' }, 400);
|
|
@@ -998,7 +1080,7 @@ export function apply(ctx) {
|
|
|
998
1080
|
'dsh-powerup: restart and self-update routes',
|
|
999
1081
|
);
|
|
1000
1082
|
});
|
|
1001
|
-
ctx.inject(['tools', 'sessionQuery'], (scope) => {
|
|
1083
|
+
ctx.inject(['tools', 'sessionQuery', 'systemPrompt'], (scope) => {
|
|
1002
1084
|
const tools = scope.get('tools');
|
|
1003
1085
|
if (tools === undefined || typeof tools.register !== 'function') return;
|
|
1004
1086
|
scope.effect(
|
|
@@ -1008,8 +1090,9 @@ export function apply(ctx) {
|
|
|
1008
1090
|
})),
|
|
1009
1091
|
'dsh-powerup: step reference reader',
|
|
1010
1092
|
);
|
|
1011
|
-
// Quick replies are keyed by the calling Agent's session id.
|
|
1012
|
-
//
|
|
1093
|
+
// Quick replies are keyed by the calling Agent's session id. Both the tool
|
|
1094
|
+
// and its system-prompt guidance follow the feature switch: when the Client
|
|
1095
|
+
// disables it, the tool is unregistered and the injected section disposed.
|
|
1013
1096
|
const quickStore = createQuickRepliesStore({
|
|
1014
1097
|
file: storePath(QUICK_REPLIES_FILE),
|
|
1015
1098
|
readFile: readFileSync,
|
|
@@ -1017,13 +1100,53 @@ export function apply(ctx) {
|
|
|
1017
1100
|
mkdir: mkdirSync,
|
|
1018
1101
|
dirname,
|
|
1019
1102
|
});
|
|
1020
|
-
|
|
1021
|
-
() =>
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
)
|
|
1103
|
+
const makeTool = () => createQuickRepliesTool(defineTool, {
|
|
1104
|
+
getSessionId: () => '',
|
|
1105
|
+
getStore: () => quickStore,
|
|
1106
|
+
});
|
|
1107
|
+
// `sync` registers or tears down everything the feature owns. It is driven
|
|
1108
|
+
// by the enabled flag and re-run whenever the Client toggles the switch.
|
|
1109
|
+
const sync = () => {
|
|
1110
|
+
if (getQuickRepliesEnabled()) {
|
|
1111
|
+
if (quickRepliesState.toolOff === undefined) {
|
|
1112
|
+
quickRepliesState.toolOff = tools.register(makeTool());
|
|
1113
|
+
}
|
|
1114
|
+
if (quickRepliesState.sectionOff === undefined && quickRepliesState.systemPrompt !== undefined) {
|
|
1115
|
+
quickRepliesState.sectionOff = quickRepliesState.systemPrompt.section({
|
|
1116
|
+
name: QUICK_REPLIES_SECTION_NAME,
|
|
1117
|
+
order: 5001,
|
|
1118
|
+
text: QUICK_REPLIES_PROMPT_SECTION,
|
|
1119
|
+
interpolate: false,
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
} else {
|
|
1123
|
+
if (typeof quickRepliesState.toolOff === 'function') {
|
|
1124
|
+
quickRepliesState.toolOff();
|
|
1125
|
+
quickRepliesState.toolOff = undefined;
|
|
1126
|
+
}
|
|
1127
|
+
if (typeof quickRepliesState.sectionOff === 'function') {
|
|
1128
|
+
quickRepliesState.sectionOff();
|
|
1129
|
+
quickRepliesState.sectionOff = undefined;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
};
|
|
1133
|
+
const off = subscribeQuickRepliesEnabled(() => sync());
|
|
1134
|
+
scope.effect(() => {
|
|
1135
|
+
// `effect` calls this immediately and keeps the RETURNED function as the
|
|
1136
|
+
// real disposer. Doing teardown in the body would unregister on startup.
|
|
1137
|
+
quickRepliesState.systemPrompt = scope.get('systemPrompt');
|
|
1138
|
+
quickRepliesState.sync = sync;
|
|
1139
|
+
sync();
|
|
1140
|
+
return () => {
|
|
1141
|
+
off();
|
|
1142
|
+
if (typeof quickRepliesState.toolOff === 'function') quickRepliesState.toolOff();
|
|
1143
|
+
if (typeof quickRepliesState.sectionOff === 'function') quickRepliesState.sectionOff();
|
|
1144
|
+
quickRepliesState.toolOff = undefined;
|
|
1145
|
+
quickRepliesState.sectionOff = undefined;
|
|
1146
|
+
quickRepliesState.sync = undefined;
|
|
1147
|
+
quickRepliesState.systemPrompt = undefined;
|
|
1148
|
+
};
|
|
1149
|
+
}, 'dsh-powerup: quick replies');
|
|
1027
1150
|
});
|
|
1028
1151
|
// The progress side call needs both `llm` and `sessionQuery`. Wait for them
|
|
1029
1152
|
// through inject so a late-provided service still creates the manager.
|
|
@@ -1190,9 +1313,16 @@ export const __test = {
|
|
|
1190
1313
|
PROGRESS_REQUIREMENTS_FILE,
|
|
1191
1314
|
PROGRESS_HISTORY_FILE,
|
|
1192
1315
|
QUICK_REPLIES_FILE,
|
|
1316
|
+
QUICK_REPLIES_ENABLED_FILE,
|
|
1317
|
+
QUICK_REPLIES_PROMPT_SECTION,
|
|
1318
|
+
QUICK_REPLIES_SECTION_NAME,
|
|
1193
1319
|
createProgressManager,
|
|
1194
1320
|
createQuickRepliesStore,
|
|
1195
1321
|
createQuickRepliesTool,
|
|
1322
|
+
getQuickRepliesEnabled,
|
|
1323
|
+
setQuickRepliesEnabled,
|
|
1324
|
+
subscribeQuickRepliesEnabled,
|
|
1325
|
+
quickRepliesState,
|
|
1196
1326
|
cleanResumePrompt,
|
|
1197
1327
|
readJsonObject,
|
|
1198
1328
|
};
|
package/lib/quick-replies.js
CHANGED
|
@@ -158,17 +158,17 @@ export function createQuickRepliesTool(defineTool, options) {
|
|
|
158
158
|
description: `The reply options to show, 1-${QUICK_REPLIES_LIMIT} items. Pass [] to clear.`,
|
|
159
159
|
items: {
|
|
160
160
|
type: 'object',
|
|
161
|
+
additionalProperties: false,
|
|
161
162
|
properties: {
|
|
162
163
|
label: {
|
|
163
164
|
type: 'string',
|
|
164
|
-
description: `Short text shown on the button (max ${QUICK_LABEL_LIMIT} characters).`,
|
|
165
|
+
description: `Required. Short text shown on the button (max ${QUICK_LABEL_LIMIT} characters).`,
|
|
165
166
|
},
|
|
166
167
|
message: {
|
|
167
168
|
type: 'string',
|
|
168
|
-
description: `Full message sent when the button is tapped (max ${QUICK_MESSAGE_LIMIT} characters).`,
|
|
169
|
+
description: `Required. Full message sent when the button is tapped (max ${QUICK_MESSAGE_LIMIT} characters).`,
|
|
169
170
|
},
|
|
170
171
|
},
|
|
171
|
-
required: ['label', 'message'],
|
|
172
172
|
},
|
|
173
173
|
},
|
|
174
174
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.8",
|
|
4
4
|
"description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词、旁路模型生成的结构化任务进度;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, workspace prompts, and non-blocking model-generated structured task progress — each toggled independently on the Power-Up page.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|
|
@@ -104,3 +104,4 @@
|
|
|
104
104
|
"license": "MIT",
|
|
105
105
|
"author": "RestRegular"
|
|
106
106
|
}
|
|
107
|
+
|