@restregular/dsh-powerup 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -3
- package/client.js +75 -44
- package/lib/direct-ask.js +14 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -470,9 +470,14 @@ generates a new report without dropping the old ones.
|
|
|
470
470
|
|
|
471
471
|
An **icon-only** lightning button in the composer opens a floating DSH-styled
|
|
472
472
|
chat window. Drag the title bar to move it and the bottom-right corner to
|
|
473
|
-
resize it (position and size persist). It supports **continuous multi-turn Q&A
|
|
474
|
-
|
|
475
|
-
|
|
473
|
+
resize it (position and size persist). It supports **continuous multi-turn Q&A**.
|
|
474
|
+
The chat window uses two **tabs** — **Chat** and **History** — instead of
|
|
475
|
+
embedding the history over the conversation. Your message appears in the thread
|
|
476
|
+
immediately as a pending bubble; the answer replaces the pending state in place
|
|
477
|
+
(and failures render there too). Continuous Q&A flattens prior turns into a
|
|
478
|
+
single user message before each call, so no hand-built assistant message ever
|
|
479
|
+
reaches the model adapter — this fixes the "LLM_FAILED" error on the second
|
|
480
|
+
message. "+" starts a new chat. Attach text files with the "+" chip in the
|
|
476
481
|
composer — the native file picker stays hidden. This is deliberately **not an
|
|
477
482
|
Agent**: it uses a single `llm.prepareCall` + stream call per turn with a short
|
|
478
483
|
instruction, so no system prompt sections, tools, skills, memory or background
|
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.
|
|
88
|
+
const VERSION = '0.17.0';
|
|
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. */
|
|
@@ -430,6 +430,8 @@
|
|
|
430
430
|
'directAsk.hide': '隐藏弹窗',
|
|
431
431
|
'directAsk.showHint': '输入问题开始对话;可继续追问,点「+」开启新对话,点「◷」查看历史。拖动标题栏移动窗口。',
|
|
432
432
|
'directAsk.newChat': '新对话',
|
|
433
|
+
'directAsk.tabChat': '问答',
|
|
434
|
+
'directAsk.noAnswer': '(无回答)',
|
|
433
435
|
'directAsk.history': '历史记录',
|
|
434
436
|
'directAsk.historyEmpty': '还没有历史对话',
|
|
435
437
|
'directAsk.clearHistory': '清空历史',
|
|
@@ -824,6 +826,8 @@
|
|
|
824
826
|
'directAsk.hide': 'Hide dialog',
|
|
825
827
|
'directAsk.showHint': 'Type a question to start; follow up anytime, "+" starts a new chat, "◷" shows history. Drag the title bar to move.',
|
|
826
828
|
'directAsk.newChat': 'New chat',
|
|
829
|
+
'directAsk.tabChat': 'Chat',
|
|
830
|
+
'directAsk.noAnswer': '(no answer)',
|
|
827
831
|
'directAsk.history': 'History',
|
|
828
832
|
'directAsk.historyEmpty': 'No saved conversations yet',
|
|
829
833
|
'directAsk.clearHistory': 'Clear history',
|
|
@@ -4467,11 +4471,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
4467
4471
|
.dsh-powerup-tab.on{background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-brand-primary);font-weight:600;box-shadow:0 1px 2px rgba(0,0,0,.10)}
|
|
4468
4472
|
.dsh-powerup-tab:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
4469
4473
|
/* Prompt management: head + cards + fields, styled after dsh-memory setcard/hook-card. */
|
|
4470
|
-
.dsh-powerup-prompt-head{display:flex;align-items:
|
|
4474
|
+
.dsh-powerup-prompt-head{display:flex;align-items:center;gap:12px;padding:0 2px 2px}
|
|
4475
|
+
.dsh-powerup-prompt-head>div:first-child{flex:1 1 auto;min-width:0}
|
|
4471
4476
|
.dsh-powerup-prompt-head-title{font-size:14px;font-weight:600;line-height:1.35}
|
|
4472
4477
|
.dsh-powerup-prompt-head-sub{font-size:11.5px;color:var(--dsw-alias-label-secondary);line-height:1.5;margin-top:2px}
|
|
4473
4478
|
.dsh-powerup-prompt-head .dsh-powerup-prompt-new{margin-left:auto}
|
|
4474
|
-
.dsh-powerup-prompt-new{height:30px;padding:0 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:12.5px;line-height:1.5;cursor:pointer;transition:border-color .12s ease,color .12s ease}
|
|
4479
|
+
.dsh-powerup-prompt-new{flex:none;white-space:nowrap;height:30px;padding:0 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:12.5px;line-height:1.5;cursor:pointer;transition:border-color .12s ease,color .12s ease}
|
|
4475
4480
|
.dsh-powerup-prompt-new:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
|
|
4476
4481
|
.dsh-powerup-prompt-new:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
4477
4482
|
.dsh-powerup-prompt-scopes{display:flex;flex-direction:column;gap:16px;margin-top:14px}
|
|
@@ -4666,6 +4671,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
4666
4671
|
.dsh-powerup-directask-subtitle{flex:1 1 auto;min-width:0;color:var(--dsw-alias-label-tertiary);font-size:10.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
4667
4672
|
.dsh-powerup-directask-titlebtn,.dsh-powerup-directask-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;padding:0;border:0;border-radius:var(--dsw-radius-sm,6px);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:15px;line-height:1;cursor:pointer}
|
|
4668
4673
|
.dsh-powerup-directask-titlebtn:hover,.dsh-powerup-directask-titlebtn.on,.dsh-powerup-directask-close:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
4674
|
+
.dsh-powerup-directask-tabs{display:flex;flex:none;gap:2px;padding:0 12px;border-bottom:.5px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}
|
|
4675
|
+
.dsh-powerup-directask-tab{position:relative;padding:8px 12px;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:11.5px;cursor:pointer}
|
|
4676
|
+
.dsh-powerup-directask-tab:hover{color:var(--dsw-alias-label-primary)}
|
|
4677
|
+
.dsh-powerup-directask-tab.on{color:var(--dsw-alias-brand-primary);font-weight:600}
|
|
4678
|
+
.dsh-powerup-directask-tab.on:after{content:"";position:absolute;left:8px;right:8px;bottom:-1px;height:2px;border-radius:2px;background:var(--dsw-alias-brand-primary)}
|
|
4669
4679
|
.dsh-powerup-directask-history{flex:none;max-height:180px;overflow-y:auto;padding:10px 14px;border-bottom:.5px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}
|
|
4670
4680
|
.dsh-powerup-directask-history-head{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;font-size:11.5px}
|
|
4671
4681
|
.dsh-powerup-directask-history-list{margin:0;padding:0;list-style:none}
|
|
@@ -4680,6 +4690,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
4680
4690
|
.dsh-powerup-directask-msg-body{padding:8px 12px;border-radius:12px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:1.7;white-space:pre-wrap;overflow-wrap:anywhere}
|
|
4681
4691
|
.dsh-powerup-directask-msg.user .dsh-powerup-directask-msg-body{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-primary-foreground,var(--dsw-alias-bg-layer-1));border-bottom-right-radius:3px}
|
|
4682
4692
|
.dsh-powerup-directask-msg.assistant .dsh-powerup-directask-msg-body{border-bottom-left-radius:3px}
|
|
4693
|
+
.dsh-powerup-directask-msg.assistant.is-pending .dsh-powerup-directask-msg-body{color:var(--dsw-alias-label-tertiary);font-style:italic}
|
|
4694
|
+
.dsh-powerup-directask-msg.assistant.is-error .dsh-powerup-directask-msg-body{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 40%,transparent);color:var(--dsw-alias-state-error-primary)}
|
|
4683
4695
|
.dsh-powerup-directask-ctx{display:flex;flex-wrap:wrap;gap:4px;align-self:flex-end}
|
|
4684
4696
|
.dsh-powerup-directask-ctx span{padding:2px 7px;border-radius:999px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-tertiary);font-size:10px}
|
|
4685
4697
|
.dsh-powerup-directask-files{display:flex;flex-wrap:wrap;gap:6px;padding:0 14px 6px}
|
|
@@ -9219,7 +9231,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9219
9231
|
try { return JSON.parse(localStorage.getItem('dsh-powerup:directask:history:v1') || '[]'); }
|
|
9220
9232
|
catch { return []; }
|
|
9221
9233
|
});
|
|
9222
|
-
const [
|
|
9234
|
+
const [activeTab, setActiveTab] = useState('chat');
|
|
9223
9235
|
const [pos, setPos] = useState(() => {
|
|
9224
9236
|
try {
|
|
9225
9237
|
const saved = JSON.parse(localStorage.getItem('dsh-powerup:directask:pos:v1') || 'null');
|
|
@@ -9299,17 +9311,24 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9299
9311
|
const q = question.trim();
|
|
9300
9312
|
if (q === '') { setError(t('directAsk.empty')); return; }
|
|
9301
9313
|
const priorContext = files.map((f) => ({ name: f.name, text: f.text }));
|
|
9302
|
-
// Continuous Q&A:
|
|
9314
|
+
// Continuous Q&A: prior completed turns, in order, as user/assistant pairs.
|
|
9303
9315
|
const historyMsgs = [];
|
|
9304
9316
|
for (const turn of turns) {
|
|
9317
|
+
if (turn.pending || !turn.answer || turn.error) continue;
|
|
9305
9318
|
historyMsgs.push({ role: 'user', text: turn.question });
|
|
9306
|
-
|
|
9319
|
+
historyMsgs.push({ role: 'assistant', text: turn.answer });
|
|
9307
9320
|
}
|
|
9321
|
+
const pendingId = `p-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
9322
|
+
const pending = {
|
|
9323
|
+
id: pendingId, question: q, answer: '', context: priorContext, at: Date.now(), pending: true,
|
|
9324
|
+
};
|
|
9308
9325
|
setBusy(true);
|
|
9309
9326
|
setError('');
|
|
9310
9327
|
setQuestion('');
|
|
9311
9328
|
setFiles([]);
|
|
9312
9329
|
setCopied(false);
|
|
9330
|
+
setTurns((cur) => [...cur, pending]);
|
|
9331
|
+
setActiveTab('chat');
|
|
9313
9332
|
try {
|
|
9314
9333
|
const response = await fetch(DIRECT_ASK_API, {
|
|
9315
9334
|
method: 'POST',
|
|
@@ -9323,13 +9342,14 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9323
9342
|
});
|
|
9324
9343
|
const body = await response.json();
|
|
9325
9344
|
if (!body?.ok) throw new Error(body?.error ?? `HTTP ${response.status}`);
|
|
9326
|
-
setTurns((cur) =>
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
}]);
|
|
9345
|
+
setTurns((cur) => cur.map((t) => (t.id === pendingId
|
|
9346
|
+
? { ...t, answer: typeof body.answer === 'string' ? body.answer : '', pending: false }
|
|
9347
|
+
: t)));
|
|
9330
9348
|
} catch (err) {
|
|
9331
|
-
|
|
9332
|
-
|
|
9349
|
+
// Render the failure in the thread like a normal assistant reply.
|
|
9350
|
+
setTurns((cur) => cur.map((t) => (t.id === pendingId
|
|
9351
|
+
? { ...t, answer: String(err?.message ?? err), pending: false, error: true }
|
|
9352
|
+
: t)));
|
|
9333
9353
|
} finally {
|
|
9334
9354
|
setBusy(false);
|
|
9335
9355
|
}
|
|
@@ -9339,14 +9359,14 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9339
9359
|
if (turns.length > 0) persistHistory([{ id: String(Date.now()), at: Date.now(), turns }, ...history]);
|
|
9340
9360
|
setTurns([]);
|
|
9341
9361
|
setError('');
|
|
9342
|
-
|
|
9362
|
+
setActiveTab('chat');
|
|
9343
9363
|
}, [turns, history, persistHistory]);
|
|
9344
9364
|
|
|
9345
9365
|
const openArchived = useCallback((entry) => {
|
|
9346
9366
|
if (turns.length > 0) persistHistory([{ id: String(Date.now()), at: Date.now(), turns }, ...history.filter((h) => h.id !== entry.id)]);
|
|
9347
9367
|
else persistHistory(history.filter((h) => h.id !== entry.id));
|
|
9348
9368
|
setTurns(Array.isArray(entry.turns) ? entry.turns : []);
|
|
9349
|
-
|
|
9369
|
+
setActiveTab('chat');
|
|
9350
9370
|
}, [turns, history, persistHistory]);
|
|
9351
9371
|
|
|
9352
9372
|
const clearHistory = useCallback(() => {
|
|
@@ -9403,18 +9423,27 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9403
9423
|
type: 'button', className: 'dsh-powerup-directask-titlebtn',
|
|
9404
9424
|
title: t('directAsk.newChat'), onClick: newChat,
|
|
9405
9425
|
}, '+'),
|
|
9406
|
-
h('button', {
|
|
9407
|
-
type: 'button', className: 'dsh-powerup-directask-titlebtn' + (showHistory ? ' on' : ''),
|
|
9408
|
-
title: t('directAsk.history'), onClick: () => setShowHistory((v) => !v),
|
|
9409
|
-
}, '◷'),
|
|
9410
9426
|
h('button', {
|
|
9411
9427
|
type: 'button', className: 'dsh-powerup-directask-close',
|
|
9412
9428
|
'aria-label': t('directAsk.close'), onClick: () => setOpen(false),
|
|
9413
9429
|
}, '×'),
|
|
9414
9430
|
),
|
|
9415
|
-
|
|
9431
|
+
h('div', { className: 'dsh-powerup-directask-tabs', role: 'tablist' },
|
|
9432
|
+
h('button', {
|
|
9433
|
+
type: 'button', role: 'tab',
|
|
9434
|
+
'aria-selected': activeTab === 'chat' ? 'true' : 'false',
|
|
9435
|
+
className: 'dsh-powerup-directask-tab' + (activeTab === 'chat' ? ' on' : ''),
|
|
9436
|
+
onClick: () => setActiveTab('chat'),
|
|
9437
|
+
}, t('directAsk.tabChat')),
|
|
9438
|
+
h('button', {
|
|
9439
|
+
type: 'button', role: 'tab',
|
|
9440
|
+
'aria-selected': activeTab === 'history' ? 'true' : 'false',
|
|
9441
|
+
className: 'dsh-powerup-directask-tab' + (activeTab === 'history' ? ' on' : ''),
|
|
9442
|
+
onClick: () => setActiveTab('history'),
|
|
9443
|
+
}, t('directAsk.history')),
|
|
9444
|
+
),
|
|
9445
|
+
activeTab === 'history' ? h('div', { className: 'dsh-powerup-directask-history' },
|
|
9416
9446
|
h('div', { className: 'dsh-powerup-directask-history-head' },
|
|
9417
|
-
h('strong', null, t('directAsk.history')),
|
|
9418
9447
|
h('button', { type: 'button', className: 'dsh-powerup-progress-mini', onClick: clearHistory }, t('directAsk.clearHistory')),
|
|
9419
9448
|
),
|
|
9420
9449
|
history.length === 0
|
|
@@ -9427,32 +9456,33 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9427
9456
|
),
|
|
9428
9457
|
)),
|
|
9429
9458
|
),
|
|
9430
|
-
) :
|
|
9431
|
-
h('div', { className: 'dsh-powerup-directask-thread' },
|
|
9459
|
+
) : h('div', { className: 'dsh-powerup-directask-thread' },
|
|
9432
9460
|
turns.length === 0 && !busy
|
|
9433
9461
|
? h('p', { className: 'dsh-powerup-directask-welcome' }, t('directAsk.showHint'))
|
|
9434
9462
|
: null,
|
|
9435
|
-
turns.map((turn
|
|
9463
|
+
turns.map((turn) => h('div', { key: turn.id, className: 'dsh-powerup-directask-turn' },
|
|
9436
9464
|
h('div', { className: 'dsh-powerup-directask-msg user' },
|
|
9437
9465
|
h('div', { className: 'dsh-powerup-directask-msg-body' }, turn.question),
|
|
9438
9466
|
),
|
|
9439
9467
|
turn.context?.length ? h('div', { className: 'dsh-powerup-directask-ctx' },
|
|
9440
9468
|
turn.context.map((f, j) => h('span', { key: j }, f.name)),
|
|
9441
9469
|
) : null,
|
|
9442
|
-
h('div', {
|
|
9443
|
-
|
|
9444
|
-
|
|
9470
|
+
h('div', {
|
|
9471
|
+
className: 'dsh-powerup-directask-msg assistant'
|
|
9472
|
+
+ (turn.pending ? ' is-pending' : '') + (turn.error ? ' is-error' : ''),
|
|
9473
|
+
},
|
|
9474
|
+
h('div', { className: 'dsh-powerup-directask-msg-body' },
|
|
9475
|
+
turn.pending ? t('directAsk.sending') : (turn.answer || t('directAsk.noAnswer')),
|
|
9476
|
+
),
|
|
9477
|
+
!turn.pending && turn.answer ? h('button', {
|
|
9445
9478
|
type: 'button', className: 'dsh-powerup-progress-mini',
|
|
9446
9479
|
onClick: async () => {
|
|
9447
9480
|
const ok = await copyText(turn.answer);
|
|
9448
9481
|
if (ok) { setCopied(true); setTimeout(() => setCopied(false), 1500); }
|
|
9449
9482
|
},
|
|
9450
|
-
}, copied ? t('directAsk.copied') : t('directAsk.copy')),
|
|
9483
|
+
}, copied ? t('directAsk.copied') : t('directAsk.copy')) : null,
|
|
9451
9484
|
),
|
|
9452
9485
|
)),
|
|
9453
|
-
busy ? h('div', { className: 'dsh-powerup-directask-msg assistant' },
|
|
9454
|
-
h('div', { className: 'dsh-powerup-directask-msg-body' }, t('directAsk.sending')),
|
|
9455
|
-
) : null,
|
|
9456
9486
|
h('div', { ref: bottomRef }),
|
|
9457
9487
|
),
|
|
9458
9488
|
error ? h('p', { className: 'dsh-powerup-progress-error' }, error) : null,
|
|
@@ -10565,7 +10595,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10565
10595
|
h('div', { className: 'dsh-powerup-prompt-modal-head' },
|
|
10566
10596
|
h('div', null,
|
|
10567
10597
|
h('div', { className: 'dsh-powerup-prompt-modal-heading' }, t('progress.reqNew')),
|
|
10568
|
-
h('p', { className: 'dsh-powerup-prompt-modal-sub' }, t('prompts.createScopeHint')),
|
|
10598
|
+
h('p', { className: 'dsh-powerup-prompt-modal-sub' }, fixedScope ? t('prompts.workspaceNone') : t('prompts.createScopeHint')),
|
|
10569
10599
|
),
|
|
10570
10600
|
h('button', { type: 'button', className: 'dsh-powerup-prompt-modal-close', 'aria-label': t('prompts.cancel'), onClick: requestClose }, '×'),
|
|
10571
10601
|
),
|
|
@@ -10574,19 +10604,20 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10574
10604
|
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.titleLabel')),
|
|
10575
10605
|
h('input', { className: 'dsh-powerup-prompt-input', type: 'text', value: title, placeholder: t('prompts.titlePlaceholder'), onChange: (e) => setTitle(e.target.value) }),
|
|
10576
10606
|
),
|
|
10577
|
-
|
|
10578
|
-
h('
|
|
10579
|
-
|
|
10580
|
-
h(
|
|
10581
|
-
|
|
10582
|
-
|
|
10583
|
-
|
|
10584
|
-
|
|
10585
|
-
|
|
10586
|
-
|
|
10587
|
-
|
|
10588
|
-
|
|
10589
|
-
|
|
10607
|
+
!fixedScope
|
|
10608
|
+
? h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10609
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.workspaceLabel')),
|
|
10610
|
+
h(WorkspaceSelect, {
|
|
10611
|
+
value: scope,
|
|
10612
|
+
options: [
|
|
10613
|
+
{ value: 'current', label: t('prompts.workspaceCurrent'), hint: workspaceTitle },
|
|
10614
|
+
{ value: 'all', label: t('prompts.anyWorkspace') },
|
|
10615
|
+
],
|
|
10616
|
+
onChange: setScope,
|
|
10617
|
+
t,
|
|
10618
|
+
}),
|
|
10619
|
+
)
|
|
10620
|
+
: null,
|
|
10590
10621
|
h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10591
10622
|
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqTextLabel')),
|
|
10592
10623
|
h('textarea', { className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea', value: text, placeholder: t('progress.reqPlaceholder'), onChange: (e) => setText(e.target.value) }),
|
package/lib/direct-ask.js
CHANGED
|
@@ -91,19 +91,27 @@ export async function directAsk({ llm, route, prompt, history, signal, maxTokens
|
|
|
91
91
|
maxTokens: Number.isFinite(maxTokens) ? maxTokens : DIRECT_ASK_MAX_TOKENS,
|
|
92
92
|
};
|
|
93
93
|
const call = await llm.prepareCall(config, signal);
|
|
94
|
-
|
|
94
|
+
// Flatten the whole conversation into ONE user message. DSH's message
|
|
95
|
+
// pipeline requires a full `id`/`role`/`content`/`source` shape on every
|
|
96
|
+
// message; hand-built assistant messages (without a valid model source) are
|
|
97
|
+
// rejected by the adapter on the second turn ("LLM_FAILED"). Sending a single
|
|
98
|
+
// user message with the prior turns as text keeps every call stateless and
|
|
99
|
+
// robust — the same approach the proven progress side-call uses.
|
|
100
|
+
const sections = [];
|
|
95
101
|
for (const turn of Array.isArray(history) ? history : []) {
|
|
96
102
|
if (turn === null || typeof turn !== 'object') continue;
|
|
97
|
-
const
|
|
98
|
-
if (
|
|
103
|
+
const label = turn.role === 'assistant' ? 'Assistant' : turn.role === 'user' ? 'User' : null;
|
|
104
|
+
if (label === null) continue;
|
|
99
105
|
const text = cleanAskText(turn.text);
|
|
100
106
|
if (text === '') continue;
|
|
101
|
-
|
|
107
|
+
sections.push(`${label}: ${text}`);
|
|
102
108
|
}
|
|
103
|
-
|
|
109
|
+
const combined = sections.length > 0
|
|
110
|
+
? `${sections.join('\n\n')}\n\nUser: ${question}`
|
|
111
|
+
: question;
|
|
104
112
|
const options = {
|
|
105
113
|
...call.config,
|
|
106
|
-
messages,
|
|
114
|
+
messages: [{ role: 'user', content: [{ type: 'text', text: combined }] }],
|
|
107
115
|
system: DIRECT_ASK_SYSTEM_PROMPT,
|
|
108
116
|
purpose: 'powerup-direct-ask',
|
|
109
117
|
...(signal === undefined ? {} : { signal }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
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",
|