dsh-better-ask-user 0.1.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-better-ask-user",
3
- "version": "0.1.7",
3
+ "version": "0.3.0",
4
4
  "description": "Independent ask_user_question plugin: configurable wait, input-extended countdown, markdown/mobile card, native or default timeout behavior, and PTC deadline exemption.",
5
- "license": "GPL-3.0",
5
+ "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/Menghuan1918/dsh-better-ask-user.git"
@@ -15,8 +15,8 @@
15
15
  "./package.json": "./package.json"
16
16
  },
17
17
  "engines": {
18
- "node": "^22.19.0 || >=24.0.0",
19
- "dsh": ">=0.2.1-rc.2 <0.3.0"
18
+ "node": ">=24.9.0",
19
+ "dsh": "0.2.2-rc.1"
20
20
  },
21
21
  "scripts": {
22
22
  "pretest": "node scripts/build-client.mjs",
@@ -24,20 +24,21 @@
24
24
  "build": "node scripts/build-client.mjs"
25
25
  },
26
26
  "dependencies": {
27
- "@deepseek-ai/schemastery": "~3.18.5",
28
- "dsh-better-ptc": "0.1.0"
27
+ "@deepseek-ai/schemastery": "~3.19.0",
28
+ "dsh-better-ptc": "0.2.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@deepseek-ai/cordis": "~4.0.5",
32
- "@deepseek-ai/dsh-agent": ">=0.2.1-rc.2 <0.3.0",
33
- "@deepseek-ai/dsh-llm": ">=0.2.1-rc.2 <0.3.0",
34
- "@deepseek-ai/dsh-session": ">=0.2.1-rc.2 <0.3.0",
35
- "@deepseek-ai/dsh-system-prompt": ">=0.2.1-rc.2 <0.3.0",
36
- "@deepseek-ai/dsh-tools": ">=0.2.1-rc.2 <0.3.0",
37
- "@deepseek-ai/dsh-user-questions": ">=0.2.1-rc.2 <0.3.0",
31
+ "@deepseek-ai/cordis": "~4.1.0",
32
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.1",
33
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.1",
34
+ "@deepseek-ai/dsh-session": "0.2.2-rc.1",
35
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1",
36
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.1",
37
+ "@deepseek-ai/dsh-user-questions": "0.2.2-rc.1",
38
38
  "react": "^18.2.0"
39
39
  },
40
40
  "devDependencies": {
41
+ "clsx": "^2.1.1",
41
42
  "esbuild": "^0.25.0",
42
43
  "js-yaml": "^4.2.0",
43
44
  "react": "18.3.1",
package/src/ask-tool.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /** ask_user_question scope shadow: official contract plus the plugin-managed wait. */
2
2
  import { ToolArgsError, validateJsonSchemaValue } from '@deepseek-ai/dsh-tools'
3
+ import { TIMED_WAIT_PARAMETER } from '@deepseek-ai/dsh-user-questions'
3
4
  import { buildDefaultAnswer } from './default-answer.js'
4
5
 
5
6
  /** Model-visible notice for the native pending result. */
@@ -44,10 +45,15 @@ function answerResult(result) {
44
45
  }
45
46
  }
46
47
 
47
- /** Add the optional detail field to the model-visible question schema. */
48
+ /** Add detail and the next host marker used to replay pending questions. */
48
49
  function parametersWithDetail(parameters) {
49
50
  if (parameters === undefined) return parameters
50
51
  const next = structuredClone(parameters)
52
+ // DSH classifies logged ask calls by this schema key, not by askTimed usage.
53
+ next.properties[TIMED_WAIT_PARAMETER] = {
54
+ type: 'integer',
55
+ description: 'Host continuation marker; omit. The plugin setting, not this argument, controls foreground wait duration.',
56
+ }
51
57
  const properties = next?.properties?.questions?.items?.properties
52
58
  if (properties !== undefined && properties.detail === undefined) {
53
59
  properties.detail = {
@@ -1,47 +1,23 @@
1
- .row {
2
- display: flex;
3
- align-items: center;
4
- gap: 8px;
5
- min-height: 24px;
1
+ .frame {
2
+ --cfg-line: var(--dsw-alias-border-l2);
3
+ --cfg-ink: var(--dsw-alias-label-primary);
4
+ --cfg-muted: var(--dsw-alias-label-secondary);
5
+ --cfg-accent: #3388bb;
6
+ --cfg-accent-text: #14587f;
7
+ --cfg-hover: var(--dsw-alias-interactive-bg-hover);
6
8
  min-width: 0;
7
- color: var(--dsw-alias-label-secondary);
8
9
  }
9
- .icon {
10
- display: inline-flex;
11
- align-items: center;
12
- flex: none;
13
- color: var(--dsw-alias-label-tertiary);
14
- }
15
- .title {
16
- flex: none;
17
- font: var(--dsw-font-xs-strong-13);
18
- color: var(--dsw-alias-label-secondary);
19
- }
20
- .summary {
21
- min-width: 0;
22
- flex: 1;
23
- overflow: hidden;
24
- text-overflow: ellipsis;
25
- white-space: nowrap;
26
- font: var(--dsw-font-xs-13);
27
- color: var(--dsw-alias-label-tertiary);
28
- }
29
- .open {
30
- flex: none;
31
- cursor: pointer;
32
- border: .5px solid var(--dsw-alias-border-l4);
33
- border-radius: 999px;
34
- background: var(--dsw-alias-bg-base);
35
- color: var(--dsw-alias-label-secondary);
36
- padding: 1px 8px;
37
- font: var(--dsw-font-xxs-12);
38
- line-height: 16px;
39
- }
40
- .open:hover {
41
- background: var(--dsw-alias-interactive-bg-hover-solid);
42
- color: var(--dsw-alias-label-primary);
43
- }
44
- .open:focus-visible {
45
- outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
46
- outline-offset: 1px;
47
- }
10
+ .row { appearance: none; display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; min-width: 0; padding: 4px 8px; border: 0; border-radius: 8px; background: transparent; color: var(--cfg-muted); font: inherit; line-height: 20px; text-align: left; }
11
+ button.row { cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
12
+ button.row:hover { background: var(--cfg-hover); color: var(--cfg-ink); }
13
+ button.row:active { background: color-mix(in srgb, var(--cfg-accent) 9%, transparent); }
14
+ button.row:focus-visible { outline: 2px solid var(--cfg-accent); outline-offset: -2px; }
15
+ .icon { display: inline-flex; flex: none; color: var(--dsw-alias-label-tertiary); }
16
+ .icon svg { width: 14px; height: 14px; }
17
+ .summary { min-width: 0; flex: 1; overflow: hidden; color: var(--cfg-ink); font-size: 13px; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; }
18
+ .open { display: inline-flex; align-items: center; gap: 4px; flex: none; color: var(--cfg-muted); font-size: 11px; line-height: 18px; white-space: nowrap; }
19
+ .error { display: block; padding: 4px 8px 4px 30px; color: var(--dsw-alias-state-error-primary); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
20
+ @media (pointer: coarse) { .row { min-height: 44px; } }
21
+ @media (prefers-reduced-motion: reduce) { button.row { transition: none; } }
22
+
23
+ [data-ds-dark-theme] .frame { --cfg-accent: #4eb0e8; --cfg-accent-text: #6fc0ee; }
@@ -1,9 +1,9 @@
1
1
  /** History row for ask_user_question: compact summary plus a replay button. */
2
- import { IconQuestionOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
2
+ import { useState } from 'react'
3
+ import { IconChevronRightOutlineRegular, IconQuestionOutlineRegular } from '@deepseek-ai/dsh-client-ui-primitives'
3
4
  import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
4
5
  import type { ToolCallViewProps, UserQuestionRecord } from '@deepseek-ai/dsh-client-ui-tool/client'
5
6
  import type { AskUserQuestionItem } from '@deepseek-ai/dsh-user-questions/types'
6
- import type { QuestionKey } from './locales.ts'
7
7
  import css from './AskHistoryRow.module.css'
8
8
 
9
9
  type AskHistoryRowProps = ToolCallViewProps & PropsLocale<'question'> & {
@@ -48,6 +48,7 @@ function questionList(argsRaw: string): AskUserQuestionItem[] | undefined {
48
48
  id: candidate.id,
49
49
  question: candidate.question,
50
50
  ...(typeof candidate.header === 'string' ? { header: candidate.header } : {}),
51
+ ...(typeof candidate.detail === 'string' ? { detail: candidate.detail } : {}),
51
52
  ...(Array.isArray(candidate.options)
52
53
  ? {
53
54
  options: candidate.options.flatMap(option => isRecord(option) && typeof option.label === 'string'
@@ -58,7 +59,7 @@ function questionList(argsRaw: string): AskUserQuestionItem[] | undefined {
58
59
  : []),
59
60
  }
60
61
  : {}),
61
- ...(typeof candidate.multi_select === 'boolean' ? { multi_select: candidate.multi_select } : {}),
62
+ ...(typeof candidate.multi_select === 'boolean' ? { multiSelect: candidate.multi_select } : {}),
62
63
  })
63
64
  }
64
65
  return questions
@@ -99,6 +100,7 @@ export function AskHistoryRow({
99
100
  reviewPanel,
100
101
  t,
101
102
  }: AskHistoryRowProps): React.JSX.Element {
103
+ const [failedAction, setFailedAction] = useState<string | null>(null)
102
104
  const argsRaw = 'kind' in block ? block.call?.argsRaw ?? '' : block.argsRaw
103
105
  const output = 'kind' in block ? resultText(block.content) : undefined
104
106
  const questions = questionList(argsRaw)
@@ -109,26 +111,30 @@ export function AskHistoryRow({
109
111
  const summary = questions?.[0]?.question.split('\n').find(line => line.trim() !== '')?.trim() ?? t('history.title')
110
112
  const review = record !== undefined
111
113
  const action = review
112
- ? () => { reviewPanel(callId, record) }
114
+ ? () => reviewPanel(callId, record)
113
115
  : isPending(output) || phase === 'start'
114
- ? () => { revealPanel(callId) }
116
+ ? () => revealPanel(callId)
115
117
  : undefined
116
118
 
117
- return (
118
- <div className={css.row}>
119
+ const actionKey = `${callId}-${review ? 'review' : 'open'}`
120
+
121
+ const content = (
122
+ <>
119
123
  <span className={css.icon} aria-hidden="true"><IconQuestionOutlineRegular /></span>
120
- <span className={css.title}>{t('history.title')}</span>
121
124
  <span className={css.summary} title={summary}>{summary}</span>
122
- {action !== undefined && (
123
- <button
124
- type="button"
125
- className={css.open}
126
- onClick={action}
127
- aria-label={review ? t('history.review') : t('history.reopen')}
128
- >
129
- {review ? t('history.review') : t('history.reopen')}
130
- </button>
131
- )}
125
+ {action !== undefined && <span className={css.open}>{review ? t('history.review') : t('history.reopen')}<IconChevronRightOutlineRegular size={14} /></span>}
126
+ </>
127
+ )
128
+ return (
129
+ <div className={css.frame} role="group" aria-label={t('history.title')}>
130
+ {action === undefined
131
+ ? <div className={css.row} data-question-history={callId}>{content}</div>
132
+ : <button
133
+ type="button" className={css.row} data-question-history={callId} data-history-action={review ? 'review' : 'open'}
134
+ onClick={() => { setFailedAction(action() ? null : actionKey) }}
135
+ aria-label={`${review ? t('history.review') : t('history.reopen')} · ${summary}`}
136
+ >{content}</button>}
137
+ {failedAction === actionKey && <span className={css.error} role="alert">{t('history.unavailable')}</span>}
132
138
  </div>
133
139
  )
134
- }
140
+ }
@@ -1,23 +1,38 @@
1
1
  .frame {
2
+ --cfg-line: var(--dsw-alias-border-l2);
3
+ --cfg-line-strong: var(--dsw-alias-border-l3);
4
+ --cfg-surface: var(--dsw-alias-bg-layer-2);
5
+ --cfg-sunken: color-mix(in srgb, var(--dsw-alias-label-primary) 4%, var(--dsw-alias-bg-layer-1));
6
+ --cfg-ink: var(--dsw-alias-label-primary);
7
+ --cfg-muted: var(--dsw-alias-label-secondary);
8
+ --cfg-accent: #3388bb;
9
+ --cfg-accent-text: #14587f;
10
+ --cfg-hover: var(--dsw-alias-interactive-bg-hover);
11
+ --cfg-danger: var(--dsw-alias-state-error-primary);
12
+ --cfg-solid: #20709e;
13
+ --cfg-solid-hover: #1c638d;
14
+ --cfg-on-solid: #fff;
2
15
  display: flex;
3
16
  justify-content: center;
4
- /* Sides = clearance + 16px: the card lands on the shared content width
5
- (input card - 32) at every viewport. */
6
- padding: 6px calc(var(--dsh-composer-side-clearance) + 16px) 10px;
17
+ padding: 6px calc(var(--dsh-composer-side-clearance) + 16px) calc(10px + env(safe-area-inset-bottom));
7
18
  }
8
19
 
9
20
  .card {
10
21
  display: flex;
11
- overflow: hidden;
12
22
  flex-direction: column;
13
23
  width: 100%;
24
+ min-width: 0;
14
25
  max-width: var(--dsh-chat-content-width);
15
- --dsw-elevation-stroke-color: var(--dsw-alias-border-l2);
16
- border: 0;
17
- border-radius: var(--dsw-radius-xl);
18
- background: var(--dsw-specific-input-major);
19
- box-shadow: var(--dsw-elevation-panel);
20
- color: var(--dsw-alias-label-primary);
26
+ max-height: min(75vh, 640px);
27
+ max-height: min(75dvh, 640px);
28
+ overflow: hidden;
29
+ border: 1px solid var(--cfg-line);
30
+ border-top-color: var(--cfg-accent);
31
+ border-radius: 12px;
32
+ background: var(--cfg-surface);
33
+ color: var(--cfg-ink);
34
+ --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
35
+ --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
21
36
  }
22
37
 
23
38
  .card,
@@ -25,55 +40,65 @@
25
40
  box-sizing: border-box;
26
41
  }
27
42
 
28
- /* Tinted full-width header band, as on the approval takeover. */
29
43
  .strip {
30
44
  display: flex;
31
45
  align-items: center;
32
46
  flex-shrink: 0;
47
+ flex-wrap: wrap;
33
48
  gap: 8px;
34
- padding: 12px 16px;
35
- background: var(--dsw-alias-state-warn-tertiary);
36
- color: var(--dsw-alias-state-warn-primary);
37
- font-size: 14px;
38
- line-height: 20px;
49
+ min-width: 0;
50
+ padding: 8px 12px 8px 16px;
51
+ border-bottom: 1px solid var(--cfg-line);
39
52
  }
40
53
 
41
- .footer {
42
- display: flex;
54
+ .panelLabel {
55
+ display: inline-flex;
43
56
  align-items: center;
44
- justify-content: space-between;
45
- flex-shrink: 0;
46
- gap: 12px;
47
- padding: 8px 16px 12px;
48
- }
49
-
50
- .feedback {
51
- min-height: 16px;
52
- color: var(--dsw-alias-state-error-primary);
57
+ height: 20px;
58
+ padding: 0 7px;
59
+ border: 1px solid var(--cfg-line);
60
+ border-radius: 999px;
61
+ background: var(--cfg-sunken);
62
+ color: var(--cfg-muted);
53
63
  font-size: 11px;
54
- line-height: 16px;
64
+ line-height: 18px;
65
+ font-weight: 500;
66
+ white-space: nowrap;
55
67
  }
56
68
 
57
- .actions {
69
+ .previewActions {
58
70
  display: flex;
59
71
  align-items: center;
60
- flex-shrink: 0;
61
- gap: 8px;
72
+ flex-wrap: wrap;
73
+ gap: 4px;
74
+ min-width: 0;
75
+ margin-left: auto;
62
76
  }
63
77
 
64
78
  .summary {
65
79
  min-width: 0;
66
- padding: 14px 16px 12px;
80
+ min-height: 0;
81
+ overflow-y: auto;
82
+ overscroll-behavior: contain;
83
+ scrollbar-gutter: stable;
84
+ padding: 12px 16px;
85
+ }
86
+
87
+ .documentHeading { display: flex; align-items: flex-start; gap: 8px; }
88
+ .documentIcon { flex: none; width: 18px; height: 20px; color: var(--dsw-alias-label-tertiary); }
89
+
90
+ .title,
91
+ .description {
92
+ min-width: 0;
93
+ overflow-wrap: anywhere;
94
+ word-break: break-word;
67
95
  }
68
96
 
69
97
  .title {
70
98
  margin: 0;
71
- overflow: hidden;
72
- text-overflow: ellipsis;
73
- white-space: nowrap;
74
- font-size: 15px;
99
+ font-size: 14px;
75
100
  font-weight: 500;
76
- line-height: 22px;
101
+ line-height: 20px;
77
102
  }
78
103
 
79
104
  .description {
@@ -81,46 +106,114 @@
81
106
  -webkit-box-orient: vertical;
82
107
  -webkit-line-clamp: 2;
83
108
  overflow: hidden;
84
- margin: 8px 0 0;
85
- color: var(--dsw-alias-label-secondary);
86
- font-size: 14px;
87
- line-height: 24px;
109
+ margin: 4px 0 0;
110
+ color: var(--cfg-muted);
111
+ font-size: 12px;
112
+ line-height: 18px;
88
113
  }
89
114
 
90
- .discuss {
115
+ .footer {
116
+ display: flex;
117
+ align-items: center;
118
+ justify-content: flex-end;
119
+ flex-shrink: 0;
120
+ flex-wrap: wrap;
121
+ gap: 8px 12px;
122
+ padding: 8px 12px;
123
+ border-top: 1px solid var(--cfg-line);
124
+ }
125
+
126
+ .feedback {
127
+ flex: 1;
128
+ min-width: 0;
129
+ display: flex;
130
+ align-items: center;
91
131
  gap: 6px;
132
+ color: var(--cfg-muted);
133
+ font-size: 12px;
134
+ line-height: 18px;
135
+ overflow-wrap: anywhere;
92
136
  }
93
137
 
94
- @media (max-width: 720px) {
95
- .card {
96
- border-radius: var(--dsw-radius-xl);
97
- }
138
+ .feedback[data-error] { color: var(--cfg-danger); }
98
139
 
99
- .footer {
100
- align-items: flex-end;
101
- padding: 8px 12px 10px;
102
- }
140
+ .discuss, .primary, .decline {
141
+ appearance: none;
142
+ display: inline-flex;
143
+ align-items: center;
144
+ justify-content: center;
145
+ height: 32px;
146
+ padding: 0 12px;
147
+ border: 1px solid var(--cfg-line);
148
+ border-radius: 8px;
149
+ background: var(--cfg-surface);
150
+ color: var(--cfg-ink);
151
+ box-shadow: none;
152
+ font: inherit;
153
+ font-size: 13px;
154
+ font-weight: 500;
155
+ cursor: pointer;
156
+ transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
103
157
  }
158
+ .discuss:hover:not(:disabled) { background: var(--cfg-hover); }
159
+ .primary { border-color: transparent; background: var(--cfg-solid); color: var(--cfg-on-solid); }
160
+ .primary:hover:not(:disabled) { background: var(--cfg-solid-hover); }
161
+ .spinner { flex: none; width: 12px; height: 12px; border: 1px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 800ms linear infinite; }
162
+ @keyframes spin { to { transform: rotate(360deg); } }
104
163
 
105
- .previewActions {
106
- margin-left: auto;
164
+ .feedback:empty {
165
+ display: none;
166
+ }
167
+
168
+ .actions {
107
169
  display: flex;
108
170
  align-items: center;
171
+ flex-wrap: wrap;
172
+ gap: 8px;
109
173
  }
110
174
 
111
- /* Better ask-user: long plan text and narrow screens. */
112
- .title,
113
- .description,
114
- .summary,
115
- .strip {
116
- min-width: 0;
117
- overflow-wrap: anywhere;
118
- word-break: break-word;
175
+ .decline {
176
+ min-height: 32px;
177
+ padding: 0 12px;
178
+ border: 0;
179
+ border-radius: 8px;
180
+ background: transparent;
181
+ color: var(--cfg-muted);
182
+ font: inherit;
183
+ font-size: 13px;
184
+ line-height: 20px;
185
+ cursor: pointer;
119
186
  }
120
187
 
121
- .title {
122
- max-height: 30vh;
123
- overflow-y: auto;
188
+ .decline:hover:not(:disabled),
189
+ .decline:active:not(:disabled) {
190
+ background: var(--cfg-hover);
191
+ color: var(--cfg-ink);
192
+ }
193
+
194
+ .discuss {
195
+ gap: 6px;
196
+ }
197
+
198
+ .card button:focus-visible {
199
+ outline: 2px solid var(--cfg-accent);
200
+ outline-offset: -2px;
201
+ }
202
+
203
+ .card button:disabled {
204
+ opacity: 0.4;
205
+ cursor: default;
206
+ }
207
+
208
+ .srOnly {
209
+ position: absolute;
210
+ width: 1px;
211
+ height: 1px;
212
+ overflow: hidden;
213
+ padding: 0;
214
+ border: 0;
215
+ clip-path: inset(50%);
216
+ white-space: nowrap;
124
217
  }
125
218
 
126
219
  @media (max-width: 720px) {
@@ -129,16 +222,53 @@
129
222
  max-height: calc(100dvh - 160px);
130
223
  }
131
224
 
132
- .title {
133
- max-height: 24vh;
134
- max-height: 24dvh;
225
+ .strip {
226
+ padding: 8px 12px;
227
+ }
228
+
229
+ .summary {
230
+ padding: 12px;
135
231
  }
136
232
 
137
233
  .footer {
138
- flex-wrap: wrap;
234
+ padding: 8px;
139
235
  }
140
236
 
237
+ .feedback {
238
+ flex: 1 1 100%;
239
+ }
240
+ }
241
+
242
+ @media (max-width: 420px) {
141
243
  .actions {
142
- flex-wrap: wrap;
244
+ display: grid;
245
+ grid-template-columns: 1fr 1fr;
246
+ width: 100%;
247
+ gap: 8px;
248
+ }
249
+
250
+ .decline {
251
+ grid-column: 1 / -1;
252
+ justify-content: flex-start;
253
+ }
254
+
255
+ .actions > button {
256
+ flex: none;
257
+ width: 100%;
258
+ }
259
+
260
+ .discuss, .primary, .decline {
261
+ white-space: nowrap;
143
262
  }
144
263
  }
264
+
265
+ @media (pointer: coarse) { .card button { min-height: 44px; } }
266
+ @media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
267
+
268
+ [data-ds-dark-theme] .frame {
269
+ --cfg-accent: #4eb0e8;
270
+ --cfg-accent-text: #6fc0ee;
271
+ --cfg-solid: #4eb0e8;
272
+ --cfg-solid-hover: #6fc0ee;
273
+ --cfg-on-solid: #0e1014;
274
+ }