@huaweidevtools/aishell-dsh-client-credentials 0.0.3 → 0.0.5

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/lib/client.js CHANGED
@@ -28,342 +28,6 @@ const __deepseek_ai_dsh_client_store = __toESM(require("@deepseek-ai/dsh-client-
28
28
  const react = __toESM(require("react"));
29
29
  const react_jsx_runtime = __toESM(require("react/jsx-runtime"));
30
30
 
31
- //#region src/client/credential-status.ts
32
- /**
33
- * Where a user obtains credentials.
34
- *
35
- * API Explorer's page for `CreateTemporaryAccessKeyByToken` — the operation
36
- * that mints a temporary AK/SK/security-token triple from an IAM token. Linked
37
- * from both forms because the alternative, a permanent access key created in
38
- * "My Credentials", has no expiry and cannot be scoped down; steering users to
39
- * the temporary kind is the point of showing this at all.
40
- *
41
- * Not fetched or validated at build time: it is a console URL whose content
42
- * changes independently of this plugin, and a stale check would be worse than
43
- * none.
44
- */
45
- const CREDENTIAL_URL = "https://console.huaweicloud.com/apiexplorer/#/openapi/IAM/doc?version=v3&api=CreateTemporaryAccessKeyByToken";
46
-
47
- //#endregion
48
- //#region src/client/AishellCredentialsSection.tsx
49
- /**
50
- * Status dot for one field label.
51
- *
52
- * Filled and green when the field is stored, hollow and muted when it is not.
53
- * The glyph carries the state as well as the colour, so it survives a
54
- * colour-blind reader and a screenshot.
55
- */
56
- function StatusDot({ present }) {
57
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
58
- "aria-hidden": true,
59
- style: {
60
- color: present ? "var(--dsw-alias-state-success-primary)" : "var(--dsw-alias-label-quaternary)",
61
- flex: "none"
62
- },
63
- children: present ? "●" : "○"
64
- });
65
- }
66
- /** Render the credentials form. */
67
- function AishellCredentialsSection(props) {
68
- const { save, clear } = props;
69
- const status = props.useCredentials((snapshot) => snapshot);
70
- const t = props.t;
71
- const [ak, setAk] = (0, react.useState)("");
72
- const [sk, setSk] = (0, react.useState)("");
73
- const [token, setToken] = (0, react.useState)("");
74
- const [saving, setSaving] = (0, react.useState)(false);
75
- const [error, setError] = (0, react.useState)(void 0);
76
- const [saved, setSaved] = (0, react.useState)(false);
77
- const onSubmit = async (e) => {
78
- e.preventDefault();
79
- if (!ak || !sk) {
80
- setError("Access Key and Secret Key are required");
81
- return;
82
- }
83
- setSaving(true);
84
- setError(void 0);
85
- setSaved(false);
86
- try {
87
- const verdict = await save(ak, sk, token || void 0);
88
- if (verdict.ok) {
89
- setAk("");
90
- setSk("");
91
- setToken("");
92
- setSaved(true);
93
- } else setError(verdict.error ?? "凭据保存失败");
94
- } catch (err) {
95
- setError(err instanceof Error ? err.message : String(err));
96
- } finally {
97
- setSaving(false);
98
- }
99
- };
100
- const onClear = async () => {
101
- setSaving(true);
102
- setError(void 0);
103
- try {
104
- const verdict = await clear();
105
- if (!verdict.ok) setError(verdict.error ?? "清除凭据失败");
106
- else setSaved(false);
107
- } catch (err) {
108
- setError(err instanceof Error ? err.message : String(err));
109
- } finally {
110
- setSaving(false);
111
- }
112
- };
113
- const inputStyle = {
114
- boxSizing: "border-box",
115
- width: "100%",
116
- height: 32,
117
- padding: "0 10px",
118
- border: "0.5px solid var(--dsw-alias-border-l4)",
119
- borderRadius: 8,
120
- font: "inherit",
121
- fontSize: 14,
122
- lineHeight: "22px",
123
- background: "var(--dsw-alias-bg-layer-1)",
124
- color: "var(--dsw-alias-label-primary)"
125
- };
126
- const labelStyle = {
127
- display: "inline-flex",
128
- alignItems: "center",
129
- gap: 10,
130
- fontSize: 12,
131
- lineHeight: "18px",
132
- fontWeight: 500,
133
- color: "var(--dsw-alias-label-secondary)"
134
- };
135
- const fieldStyle = {
136
- display: "flex",
137
- flexDirection: "column",
138
- gap: 6
139
- };
140
- const hintStyle = {
141
- fontSize: 11,
142
- lineHeight: "16px",
143
- color: "var(--dsw-alias-label-quaternary)"
144
- };
145
- const primaryButtonStyle = {
146
- background: "var(--dsw-alias-button-primary-fill)",
147
- color: "var(--dsw-alias-label-primary-foreground)",
148
- border: "none",
149
- borderRadius: 8,
150
- padding: "6px 16px",
151
- fontSize: 14,
152
- cursor: "pointer"
153
- };
154
- const secondaryButtonStyle = {
155
- border: "0.5px solid var(--dsw-alias-border-l3)",
156
- background: "transparent",
157
- color: "var(--dsw-alias-label-primary)",
158
- borderRadius: 8,
159
- padding: "6px 16px",
160
- fontSize: 14,
161
- cursor: "pointer"
162
- };
163
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
164
- style: {
165
- display: "flex",
166
- flexDirection: "column",
167
- gap: 12,
168
- maxWidth: 720,
169
- color: "var(--dsw-alias-label-primary)"
170
- },
171
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
172
- style: {
173
- margin: "0 0 4px",
174
- fontSize: 16,
175
- lineHeight: "24px",
176
- fontWeight: 500,
177
- color: "var(--dsw-alias-label-primary)"
178
- },
179
- children: "AI Shell"
180
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
181
- style: {
182
- margin: 0,
183
- fontSize: 14,
184
- lineHeight: "22px",
185
- color: "var(--dsw-alias-label-tertiary)"
186
- },
187
- children: t("section.settings.summary")
188
- })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
189
- style: {
190
- display: "flex",
191
- flexDirection: "column",
192
- gap: 12,
193
- borderTop: "0.5px solid var(--dsw-alias-border-l4)",
194
- paddingTop: 12
195
- },
196
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
197
- style: {
198
- margin: "0 0 4px",
199
- fontSize: 14,
200
- lineHeight: "20px",
201
- fontWeight: 500,
202
- color: "var(--dsw-alias-label-secondary)"
203
- },
204
- children: t("section.credentials.title")
205
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
206
- style: {
207
- margin: 0,
208
- fontSize: 12,
209
- lineHeight: "18px",
210
- color: "var(--dsw-alias-label-tertiary)"
211
- },
212
- children: [
213
- t("section.credentials.hint.prefix"),
214
- " ",
215
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("a", {
216
- href: CREDENTIAL_URL,
217
- target: "_blank",
218
- rel: "noreferrer noopener",
219
- style: {
220
- color: "var(--dsw-alias-button-primary-fill)",
221
- textDecoration: "underline"
222
- },
223
- children: t("section.credentials.hint.link")
224
- }),
225
- " ",
226
- t("section.credentials.hint.suffix")
227
- ]
228
- })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
229
- onSubmit,
230
- style: {
231
- display: "flex",
232
- flexDirection: "column",
233
- gap: 12
234
- },
235
- children: [
236
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
237
- style: fieldStyle,
238
- children: [
239
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
240
- style: labelStyle,
241
- children: [
242
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, { present: status.hasAccessKey }),
243
- t("section.field.accessKey"),
244
- status.accessKeyIdHint && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
245
- style: {
246
- color: "var(--dsw-alias-label-tertiary)",
247
- fontWeight: 400
248
- },
249
- children: [
250
- "(",
251
- status.accessKeyIdHint,
252
- ")"
253
- ]
254
- })
255
- ]
256
- }),
257
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
258
- type: "password",
259
- value: ak,
260
- onChange: (e) => setAk(e.target.value),
261
- style: inputStyle,
262
- placeholder: t("section.field.accessKey.placeholder"),
263
- "aria-label": t("section.field.accessKey"),
264
- autoComplete: "off"
265
- }),
266
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
267
- style: hintStyle,
268
- children: t("section.field.accessKey.hint")
269
- })
270
- ]
271
- }),
272
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
273
- style: fieldStyle,
274
- children: [
275
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
276
- style: labelStyle,
277
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, { present: status.hasSecretKey }), t("section.field.secretKey")]
278
- }),
279
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
280
- type: "password",
281
- value: sk,
282
- onChange: (e) => setSk(e.target.value),
283
- style: inputStyle,
284
- placeholder: t("section.field.secretKey.placeholder"),
285
- "aria-label": t("section.field.secretKey"),
286
- autoComplete: "off"
287
- }),
288
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
289
- style: hintStyle,
290
- children: t("section.field.secretKey.hint")
291
- })
292
- ]
293
- }),
294
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
295
- style: fieldStyle,
296
- children: [
297
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
298
- style: labelStyle,
299
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(StatusDot, { present: status.hasSecurityToken }), t("section.field.token")]
300
- }),
301
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
302
- type: "password",
303
- value: token,
304
- onChange: (e) => setToken(e.target.value),
305
- style: inputStyle,
306
- placeholder: t("section.field.token.placeholder"),
307
- "aria-label": t("section.field.token"),
308
- autoComplete: "off"
309
- }),
310
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
311
- style: hintStyle,
312
- children: t("section.field.token.hint")
313
- })
314
- ]
315
- }),
316
- error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
317
- style: {
318
- margin: 0,
319
- fontSize: 12,
320
- lineHeight: "18px",
321
- color: "var(--dsw-alias-state-warn-label)"
322
- },
323
- children: error
324
- }),
325
- saved && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
326
- style: {
327
- margin: 0,
328
- fontSize: 12,
329
- lineHeight: "18px",
330
- color: "var(--dsw-alias-state-success-primary)"
331
- },
332
- children: t("section.credentials.saved")
333
- }),
334
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
335
- style: {
336
- display: "flex",
337
- gap: 8
338
- },
339
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
340
- type: "submit",
341
- disabled: saving || !ak || !sk,
342
- style: {
343
- ...primaryButtonStyle,
344
- opacity: saving || !ak || !sk ? .5 : 1,
345
- cursor: saving || !ak || !sk ? "default" : "pointer"
346
- },
347
- children: saving ? t("section.credentials.saving") : t("section.credentials.save")
348
- }), (status.hasAccessKey || status.hasSecretKey) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
349
- type: "button",
350
- onClick: onClear,
351
- disabled: saving,
352
- style: {
353
- ...secondaryButtonStyle,
354
- opacity: saving ? .5 : 1,
355
- cursor: saving ? "default" : "pointer"
356
- },
357
- children: t("section.credentials.clear")
358
- })]
359
- })
360
- ]
361
- })]
362
- })]
363
- });
364
- }
365
-
366
- //#endregion
367
31
  //#region src/client/permission-mode.ts
368
32
  /**
369
33
  * Host permission route, written document-relative for the same reason as the
@@ -454,15 +118,6 @@ function usePermissionMode() {
454
118
 
455
119
  //#endregion
456
120
  //#region src/client/huawei-mark.ts
457
- /**
458
- * The Huawei mark and its brand colour, shared by both credential chips.
459
- *
460
- * Extracted so the composer chip and the hero chip cannot drift apart: they
461
- * report the same thing, and a colour or path change in one must not leave the
462
- * other behind.
463
- *
464
- * @module @huaweidevtools/aishell-dsh-client-credentials/client/huawei-mark
465
- */
466
121
  /** Huawei logo path (from simple-icons/huawei), drawn in a 24×24 viewBox. */
467
122
  const HUAWEI_LOGO_PATH = "M3.67 6.14S1.82 7.91 1.72 9.78v.35c.08 1.51 1.22 2.4 1.22 2.4 1.83 1.79 6.26 4.04 7.3 4.55 0 0 .06.03.1-.01l.02-.04v-.04C7.52 10.8 3.67 6.14 3.67 6.14zM9.65 18.6c-.02-.08-.1-.08-.1-.08l-7.38.26c.8 1.43 2.15 2.53 3.56 2.2.96-.25 3.16-1.78 3.88-2.3.06-.05.04-.09.04-.09zm.08-.78C6.49 15.63.21 12.28.21 12.28c-.15.46-.2.9-.21 1.3v.07c0 1.07.4 1.82.4 1.82.8 1.69 2.34 2.2 2.34 2.2.7.3 1.4.31 1.4.31.12.02 4.4 0 5.54 0 .05 0 .08-.05.08-.05v-.06c0-.03-.03-.05-.03-.05zM9.06 3.19a3.42 3.42 0 00-2.57 3.15v.41c.03.6.16 1.05.16 1.05.66 2.9 3.86 7.65 4.55 8.65.05.05.1.03.1.03a.1.1 0 00.06-.1c1.06-10.6-1.11-13.42-1.11-13.42-.32.02-1.19.23-1.19.23zm8.299 2.27s-.49-1.8-2.44-2.28c0 0-.57-.14-1.17-.22 0 0-2.18 2.81-1.12 13.43.01.07.06.08.06.08.07.03.1-.03.1-.03.72-1.03 3.9-5.76 4.55-8.64 0 0 .36-1.4.02-2.34zm-2.92 13.07s-.07 0-.09.05c0 0-.01.07.03.1.7.51 2.85 2 3.88 2.3 0 0 .16.05.43.06h.14c.69-.02 1.9-.37 3-2.26l-7.4-.25zm7.83-8.41c.14-2.06-1.94-3.97-1.94-3.98 0 0-3.85 4.66-6.67 10.8 0 0-.03.08.02.13l.04.01h.06c1.06-.53 5.46-2.77 7.28-4.54 0 0 1.15-.93 1.21-2.42zm1.52 2.14s-6.28 3.37-9.52 5.55c0 0-.05.04-.03.11 0 0 .03.06.07.06 1.16 0 5.56 0 5.67-.02 0 0 .57-.02 1.27-.29 0 0 1.56-.5 2.37-2.27 0 0 .73-1.45.17-3.14z";
468
123
  /**
@@ -482,67 +137,54 @@ const HUAWEI_RED = "rgb(207, 10, 44)";
482
137
  */
483
138
  const CHIP_CLASS = "aishell-account-hint";
484
139
  /**
485
- * Inject the hover/focus rule once per document.
486
- *
487
- * The background token matches what the ContextMeter trigger and the sidebar
488
- * gear pill use on hover, so the affordance reads the same as the rest of the
489
- * chrome. Guarded by an id check so a second mount (or the other chip) does
490
- * not duplicate the rule.
140
+ * Plugin id stamped on the style tag, and the same marker the build-time CSS
141
+ * modules carry (`shared/tsdown.client.ts` sets `dataset.plugin` + a
142
+ * `dataset.pluginCss` dedupe key). The loader's `removeOwnedStyles` sweeps
143
+ * `style[data-plugin="<id>"]` on module teardown, so a tag written here is
144
+ * reachable by the same mechanism as the generated ones.
491
145
  */
492
- function ensureChipStyles() {
493
- if (typeof document === "undefined") return;
494
- if (document.getElementById("aishell-account-hint-style")) return;
495
- const style = document.createElement("style");
496
- style.id = "aishell-account-hint-style";
497
- style.textContent = `.${CHIP_CLASS}:hover{background:var(--dsw-alias-interactive-bg-hover)}.${CHIP_CLASS}:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}`;
498
- document.head.appendChild(style);
499
- }
500
-
501
- //#endregion
502
- //#region src/client/open-settings.ts
146
+ const PLUGIN_ID = "@huaweidevtools/aishell-dsh-client-credentials";
147
+ /** Dedupe key for the one sheet this module owns. */
148
+ const CHIP_STYLE_KEY = `${PLUGIN_ID}/chip-hover`;
503
149
  /**
504
- * Open DSH's Settings modal.
505
- *
506
- * DSH exposes no service API for this — the modal's open state is
507
- * component-local inside `SettingsRoot`, toggled only by its trigger button.
508
- * The trigger is the `button[aria-haspopup="dialog"]` inside the
509
- * `[data-slot="sidebar.settings"]` outlet, which is a stable, slot-key + ARIA
510
- * based selector rather than a hashed CSS-module class. Clicking it is the
511
- * same gesture the sidebar gear makes.
150
+ * Mount the chips' hover/focus rule for the owning plugin's lifetime.
512
151
  *
513
- * Shared by both credential chips so they cannot diverge; the hero chip opens
514
- * Settings from the same affordance the composer chip uses.
152
+ * The shape follows `dsh-client-ui-theme`'s `installThemeStyles`, which is the
153
+ * framework's own answer for runtime-authored CSS: one `ctx.effect` per sheet,
154
+ * a disposer that removes the tag, and the `data-plugin` markers so
155
+ * `removeOwnedStyles` can also reach it. The disposer is what makes a reload
156
+ * pick up an edited rule — the fiber tears down, the tag goes, and the next
157
+ * materialization writes the new text. A module-level install with an id guard
158
+ * fails exactly there: the tag outlives the module (the loader only sweeps
159
+ * `data-plugin` tags), the guard then sees it and returns, and the old CSS
160
+ * stays in force for the life of the page.
515
161
  *
516
- * @module @huaweidevtools/aishell-dsh-client-credentials/client/open-settings
517
- */
518
- /** The Settings modal's trigger, identified by slot key and ARIA contract. */
519
- const SETTINGS_TRIGGER_SELECTOR = "[data-slot=\"sidebar.settings\"] button[aria-haspopup=\"dialog\"]";
520
- /**
521
- * Click DSH's Settings trigger on the user's behalf.
162
+ * Call once from `apply()`, not from the components: the rule is shared by
163
+ * both chips (they carry the same `CHIP_CLASS`), so one sheet serves them and
164
+ * two installers would fight over the same dedupe key.
522
165
  *
523
- * A missing trigger is reported on the console rather than thrown. There is
524
- * nothing to click when the sidebar has not mounted, and throwing inside a
525
- * click handler would surface as an unhandled rejection; but staying silent
526
- * would make a selector drift indistinguishable from a dead click, since a
527
- * `??=`-style no-op leaves no trace anywhere. The warning is the only signal
528
- * that this selector needs updating.
166
+ * @param ctx - the browser-half plugin context whose effect owns the tag.
529
167
  */
530
- function openSettings() {
531
- const trigger = document.querySelector(SETTINGS_TRIGGER_SELECTOR);
532
- if (trigger === null) {
533
- console.warn(`[aishell] Settings trigger not found (${SETTINGS_TRIGGER_SELECTOR}); DSH's sidebar layout may have changed — the chip's click opens nothing.`);
534
- return;
535
- }
536
- trigger.click();
168
+ function installChipStyles(ctx) {
169
+ if (typeof document === "undefined") return;
170
+ ctx.effect(() => {
171
+ const tag = document.createElement("style");
172
+ tag.dataset.plugin = PLUGIN_ID;
173
+ tag.dataset.pluginCss = CHIP_STYLE_KEY;
174
+ tag.textContent = `.${CHIP_CLASS}:hover{background:var(--dsw-alias-interactive-bg-hover)}.${CHIP_CLASS}:focus-visible{outline:2px solid var(--dsw-alias-label-primary);outline-offset:-2px}`;
175
+ document.head.appendChild(tag);
176
+ return () => {
177
+ tag.remove();
178
+ };
179
+ }, "aishell-credentials: chip hover styles");
537
180
  }
538
181
 
539
182
  //#endregion
540
183
  //#region src/client/AishellAccountHint.tsx
541
- ensureChipStyles();
542
184
  /**
543
185
  * Render the current account hint, or a setup prompt when credentials are
544
186
  * absent. The hooks-compartment subscription keeps the chip live: saving
545
- * credentials in Settings publishes a new snapshot through the shared store,
187
+ * credentials in the form publishes a new snapshot through the shared store,
546
188
  * and the chip updates in place without a remount — the prompt disappears
547
189
  * the moment a hint lands.
548
190
  *
@@ -556,6 +198,7 @@ function AishellAccountHint(props) {
556
198
  const hint = status.accessKeyIdHint;
557
199
  const configured = Boolean(hint);
558
200
  const t = props.t;
201
+ const openCredentialForm = props.openCredentialForm;
559
202
  const { mode, busy, toggle } = usePermissionMode();
560
203
  const ref = (0, react.useRef)(null);
561
204
  (0, react.useEffect)(() => {
@@ -603,7 +246,7 @@ function AishellAccountHint(props) {
603
246
  type: "button",
604
247
  className: CHIP_CLASS,
605
248
  "aria-label": configured ? hint : t("account.unconfigured"),
606
- onClick: openSettings,
249
+ onClick: openCredentialForm,
607
250
  style: {
608
251
  ...pillStyle,
609
252
  color: configured ? "var(--dsw-alias-label-tertiary)" : "var(--dsw-alias-state-warn-label)",
@@ -652,12 +295,12 @@ function AishellAccountHint(props) {
652
295
 
653
296
  //#endregion
654
297
  //#region src/client/AishellHeroChip.tsx
655
- ensureChipStyles();
656
298
  function AishellHeroChip(props) {
657
299
  const blank = props.useSession((session) => session.blank);
658
300
  const status = props.useCredentials((snapshot) => snapshot);
659
301
  const { mode, busy, toggle } = usePermissionMode();
660
302
  const t = props.t;
303
+ const openCredentialForm = props.openCredentialForm;
661
304
  const configured = Boolean(status.accessKeyIdHint);
662
305
  const wrapperRef = (0, react.useRef)(null);
663
306
  const [presetOffset, setPresetOffset] = (0, react.useState)(null);
@@ -751,7 +394,7 @@ function AishellHeroChip(props) {
751
394
  type: "button",
752
395
  className: CHIP_CLASS,
753
396
  "aria-label": configured ? status.accessKeyIdHint : t("account.unconfigured"),
754
- onClick: openSettings,
397
+ onClick: openCredentialForm,
755
398
  style: {
756
399
  ...pillStyle,
757
400
  color: configured ? "var(--dsw-alias-label-tertiary)" : "var(--dsw-alias-state-warn-label)",
@@ -797,6 +440,23 @@ function AishellHeroChip(props) {
797
440
  });
798
441
  }
799
442
 
443
+ //#endregion
444
+ //#region src/client/credential-status.ts
445
+ /**
446
+ * Where a user obtains credentials.
447
+ *
448
+ * API Explorer's page for `CreateTemporaryAccessKeyByToken` — the operation
449
+ * that mints a temporary AK/SK/security-token triple from an IAM token. Linked
450
+ * from both forms because the alternative, a permanent access key created in
451
+ * "My Credentials", has no expiry and cannot be scoped down; steering users to
452
+ * the temporary kind is the point of showing this at all.
453
+ *
454
+ * Not fetched or validated at build time: it is a console URL whose content
455
+ * changes independently of this plugin, and a stale check would be worse than
456
+ * none.
457
+ */
458
+ const CREDENTIAL_URL = "https://console.huaweicloud.com/apiexplorer/#/openapi/IAM/doc?version=v3&api=CreateTemporaryAccessKeyByToken";
459
+
800
460
  //#endregion
801
461
  //#region src/client/CredentialRequestForm.tsx
802
462
  /**
@@ -804,16 +464,22 @@ function AishellHeroChip(props) {
804
464
  *
805
465
  * Submitting saves through the Host route; the Host then tells the waiting tool
806
466
  * call there is now a credential, and clears the pending flag this component
807
- * renders from — so a successful submit does not need to unmount itself.
467
+ * renders from — so a successful submit does not need to unmount itself. A
468
+ * manually-opened form has no request behind it, so it closes itself after a
469
+ * successful save (the chip flipping to the account name is the feedback).
808
470
  */
809
471
  function CredentialRequestForm(props) {
810
472
  const t = props.t;
811
- const { save, dismiss } = props;
473
+ const { save, clear, dismiss, closeManual } = props;
474
+ const status = props.useCredentials((snapshot) => snapshot);
812
475
  const [ak, setAk] = (0, react.useState)("");
813
476
  const [sk, setSk] = (0, react.useState)("");
814
477
  const [token, setToken] = (0, react.useState)("");
815
478
  const [saving, setSaving] = (0, react.useState)(false);
479
+ const [clearing, setClearing] = (0, react.useState)(false);
816
480
  const [error, setError] = (0, react.useState)(void 0);
481
+ const pending = props.pendingInteraction;
482
+ const manual = pending?.manual === true;
817
483
  const onSubmit = async (event) => {
818
484
  event.preventDefault();
819
485
  setSaving(true);
@@ -827,12 +493,32 @@ function CredentialRequestForm(props) {
827
493
  setAk("");
828
494
  setSk("");
829
495
  setToken("");
496
+ if (manual) closeManual();
830
497
  } catch (err) {
831
498
  setError(err instanceof Error ? err.message : String(err));
832
499
  } finally {
833
500
  setSaving(false);
834
501
  }
835
502
  };
503
+ const onClear = async () => {
504
+ setClearing(true);
505
+ setError(void 0);
506
+ try {
507
+ const verdict = await clear();
508
+ if (!verdict.ok) setError(verdict.error ?? t("form.clear.failed"));
509
+ } catch (err) {
510
+ setError(err instanceof Error ? err.message : String(err));
511
+ } finally {
512
+ setClearing(false);
513
+ }
514
+ };
515
+ const onCancel = () => {
516
+ if (manual) {
517
+ closeManual();
518
+ return;
519
+ }
520
+ dismiss();
521
+ };
836
522
  const fieldStyle = {
837
523
  display: "flex",
838
524
  flexDirection: "column",
@@ -870,10 +556,12 @@ function CredentialRequestForm(props) {
870
556
  cursor: disabled$1 ? "default" : "pointer",
871
557
  opacity: disabled$1 ? .5 : 1
872
558
  });
873
- const disabled = saving || !ak || !sk;
559
+ const busy = saving || clearing;
560
+ const disabled = busy || !ak || !sk;
561
+ const hasCredentials = status.hasAccessKey || status.hasSecretKey;
874
562
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
875
563
  role: "group",
876
- "aria-label": t("form.title"),
564
+ "aria-label": t(manual ? "form.title.manual" : "form.title"),
877
565
  style: {
878
566
  padding: "6px calc(var(--dsh-composer-side-clearance) + 16px) 10px",
879
567
  display: "flex",
@@ -906,7 +594,7 @@ function CredentialRequestForm(props) {
906
594
  fontWeight: 500,
907
595
  lineHeight: "22px"
908
596
  },
909
- children: t("form.title")
597
+ children: t(manual ? "form.title.manual" : "form.title")
910
598
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
911
599
  style: {
912
600
  fontSize: 12,
@@ -933,9 +621,19 @@ function CredentialRequestForm(props) {
933
621
  }),
934
622
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
935
623
  style: fieldStyle,
936
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
624
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
937
625
  style: labelStyle,
938
- children: t("section.field.accessKey")
626
+ children: [t("section.field.accessKey"), status.accessKeyIdHint && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
627
+ style: {
628
+ color: "var(--dsw-alias-label-tertiary)",
629
+ fontWeight: 400
630
+ },
631
+ children: [
632
+ "(",
633
+ status.accessKeyIdHint,
634
+ ")"
635
+ ]
636
+ })]
939
637
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
940
638
  type: "password",
941
639
  value: ak,
@@ -991,27 +689,45 @@ function CredentialRequestForm(props) {
991
689
  display: "flex",
992
690
  gap: 8
993
691
  },
994
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
995
- type: "submit",
996
- disabled,
997
- style: {
998
- ...buttonStyle(disabled),
999
- background: "var(--dsw-alias-button-primary-fill)",
1000
- color: "var(--dsw-alias-label-primary-foreground)"
1001
- },
1002
- children: saving ? t("section.credentials.saving") : t("form.submit")
1003
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1004
- type: "button",
1005
- onClick: dismiss,
1006
- disabled: saving,
1007
- style: {
1008
- ...buttonStyle(saving),
1009
- background: "transparent",
1010
- color: "var(--dsw-alias-label-primary)",
1011
- border: "0.5px solid var(--dsw-alias-border-l4)"
1012
- },
1013
- children: t("form.dismiss")
1014
- })]
692
+ children: [
693
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
694
+ type: "submit",
695
+ disabled,
696
+ style: {
697
+ ...buttonStyle(disabled),
698
+ background: "var(--dsw-alias-button-primary-fill)",
699
+ color: "var(--dsw-alias-label-primary-foreground)"
700
+ },
701
+ children: saving ? t("section.credentials.saving") : t("form.submit")
702
+ }),
703
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
704
+ type: "button",
705
+ onClick: onCancel,
706
+ disabled: busy,
707
+ style: {
708
+ ...buttonStyle(busy),
709
+ background: "transparent",
710
+ color: "var(--dsw-alias-label-primary)",
711
+ border: "0.5px solid var(--dsw-alias-border-l4)"
712
+ },
713
+ children: t("form.dismiss")
714
+ }),
715
+ hasCredentials && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
716
+ type: "button",
717
+ onClick: () => {
718
+ onClear();
719
+ },
720
+ disabled: busy,
721
+ style: {
722
+ ...buttonStyle(busy),
723
+ background: "transparent",
724
+ color: "var(--dsw-alias-label-primary)",
725
+ border: "0.5px solid var(--dsw-alias-border-l4)",
726
+ marginLeft: "auto"
727
+ },
728
+ children: clearing ? t("form.clearing") : t("form.clear")
729
+ })
730
+ ]
1015
731
  })
1016
732
  ]
1017
733
  })
@@ -1026,13 +742,15 @@ let nextKey = 0;
1026
742
  * Build an interaction for one session.
1027
743
  *
1028
744
  * @param sessionId - the conversation the form belongs to.
745
+ * @param manual - true when a chip opened the form (no request behind it).
1029
746
  */
1030
- function credentialFormInteraction(sessionId) {
747
+ function credentialFormInteraction(sessionId, manual) {
1031
748
  nextKey += 1;
1032
749
  return {
1033
750
  kind: "aishell-credential-form",
1034
751
  key: `aishell-credential-form:${String(nextKey)}`,
1035
- sessionId
752
+ sessionId,
753
+ manual
1036
754
  };
1037
755
  }
1038
756
  /**
@@ -1067,24 +785,44 @@ const DISMISS_ROUTE = "api/aishell/credentials/dismiss";
1067
785
  function createCredentialFormVisibility(publish) {
1068
786
  let open;
1069
787
  let withdraw;
788
+ let manual = false;
1070
789
  const clear = () => {
1071
790
  withdraw?.();
1072
791
  withdraw = void 0;
1073
792
  open = void 0;
793
+ manual = false;
794
+ };
795
+ const publishFor = (sessionId, isManual) => {
796
+ withdraw?.();
797
+ const interaction = credentialFormInteraction(sessionId, isManual);
798
+ open = interaction;
799
+ manual = isManual;
800
+ withdraw = publish(interaction);
801
+ return interaction;
1074
802
  };
1075
803
  return {
1076
804
  current: () => open,
805
+ manual: () => manual && open !== void 0,
1077
806
  sync: (sessionId) => {
1078
807
  if (sessionId === "") {
1079
808
  if (open === void 0) return;
1080
809
  clear();
1081
810
  return;
1082
811
  }
1083
- if (open?.sessionId === sessionId) return;
1084
- withdraw?.();
1085
- const interaction = credentialFormInteraction(sessionId);
1086
- open = interaction;
1087
- withdraw = publish(interaction);
812
+ if (open?.sessionId === sessionId) {
813
+ if (!manual) return;
814
+ publishFor(sessionId, false);
815
+ return;
816
+ }
817
+ publishFor(sessionId, false);
818
+ },
819
+ open: (sessionId) => {
820
+ if (open !== void 0) return;
821
+ publishFor(sessionId, true);
822
+ },
823
+ close: () => {
824
+ if (open === void 0 || !manual) return;
825
+ clear();
1088
826
  },
1089
827
  dispose: () => {
1090
828
  if (open === void 0) return;
@@ -1104,7 +842,7 @@ function createCredentialFormVisibility(publish) {
1104
842
  const NS = "aishell";
1105
843
  /** Simplified Chinese dictionary (the key-set source of truth). */
1106
844
  const zh = {
1107
- "account.unconfigured": "未配置华为云 IAM 凭据",
845
+ "account.unconfigured": "未配置凭据",
1108
846
  "mode.readonly": "只读",
1109
847
  "mode.readwrite": "读写",
1110
848
  "mode.unavailable": "权限模式不可用",
@@ -1113,19 +851,21 @@ const zh = {
1113
851
  "mode.unavailable.hint": "无法从 MCP 服务器读取权限模式;切换按钮暂不可用",
1114
852
  "mode.switchToReadonly": "切换为只读模式",
1115
853
  "mode.switchToReadwrite": "切换为读写模式",
1116
- "section.settings.summary": "华为云 AI Shell 设置。",
1117
- "section.credentials.title": "凭据",
1118
854
  "section.credentials.hint.prefix": "需要进行华为云 IAM 认证,建议从",
1119
855
  "section.credentials.hint.link": "API Explorer",
1120
856
  "section.credentials.hint.suffix": "获取临时凭据,避免使用永久凭据。",
1121
- "section.credentials.saved": "校验通过,已存入 keyring。",
1122
- "section.credentials.save": "保存",
1123
857
  "section.credentials.saving": "保存中…",
1124
- "section.credentials.clear": "清除",
1125
858
  "form.title": "需要华为云凭据",
859
+ "form.title.manual": "配置华为云凭据",
1126
860
  "form.submit": "提交",
1127
861
  "form.dismiss": "取消",
1128
862
  "form.failed": "保存凭据失败",
863
+ "form.clear": "清除",
864
+ "form.clearing": "清除中…",
865
+ "form.clear.failed": "清除凭据失败",
866
+ "error.unreachable": "无法连接宿主凭据服务:",
867
+ "error.clear.serverFailed": "本机凭据已清除,但服务端凭据未清除(HTTP {status})",
868
+ "error.clear.serverUnreachable": "本机凭据已清除,但无法连接 MCP 服务器清除服务端凭据:",
1129
869
  "section.field.accessKey": "Access Key",
1130
870
  "section.field.accessKey.placeholder": "华为云 Access Key",
1131
871
  "section.field.accessKey.hint": "Access Key 与 Secret Key 须同时填写,只填其一时不会保存。",
@@ -1138,7 +878,7 @@ const zh = {
1138
878
  };
1139
879
  /** English dictionary. */
1140
880
  const en = {
1141
- "account.unconfigured": "No Huawei Cloud IAM credentials",
881
+ "account.unconfigured": "No credentials",
1142
882
  "mode.readonly": "Read-only",
1143
883
  "mode.readwrite": "Read-write",
1144
884
  "mode.unavailable": "Mode unavailable",
@@ -1147,19 +887,21 @@ const en = {
1147
887
  "mode.unavailable.hint": "Could not read the permission mode from the MCP server; the toggle is unavailable",
1148
888
  "mode.switchToReadonly": "Switch to read-only mode",
1149
889
  "mode.switchToReadwrite": "Switch to read-write mode",
1150
- "section.settings.summary": "Huawei Cloud AI Shell settings.",
1151
- "section.credentials.title": "Credentials",
1152
890
  "section.credentials.hint.prefix": "Authenticate against Huawei Cloud IAM. Obtain temporary credentials from",
1153
891
  "section.credentials.hint.link": "API Explorer",
1154
892
  "section.credentials.hint.suffix": "and avoid permanent ones.",
1155
- "section.credentials.saved": "Verified and saved to keyring.",
1156
- "section.credentials.save": "Save",
1157
893
  "section.credentials.saving": "Saving…",
1158
- "section.credentials.clear": "Clear",
1159
894
  "form.title": "Huawei Cloud credentials required",
895
+ "form.title.manual": "Configure Huawei Cloud credentials",
1160
896
  "form.submit": "Submit",
1161
897
  "form.dismiss": "Cancel",
1162
898
  "form.failed": "Could not save credentials",
899
+ "form.clear": "Clear",
900
+ "form.clearing": "Clearing…",
901
+ "form.clear.failed": "Could not clear credentials",
902
+ "error.unreachable": "Could not reach the host credential service: ",
903
+ "error.clear.serverFailed": "Local credentials were cleared, but the server copy was not (HTTP {status})",
904
+ "error.clear.serverUnreachable": "Local credentials were cleared, but the MCP server could not be reached to clear the server copy: ",
1163
905
  "section.field.accessKey": "Access Key",
1164
906
  "section.field.accessKey.placeholder": "Huawei Access Key",
1165
907
  "section.field.accessKey.hint": "Access Key and Secret Key are stored as a pair; one without the other is not saved.",
@@ -1191,7 +933,7 @@ const CLEAR_ROUTE = "api/aishell/credentials/clear";
1191
933
  * Clearing is a two-store operation: this plugin's store (CLEAR_ROUTE) and the
1192
934
  * MCP server's, which keeps its own copy scoped to this client. Only the first
1193
935
  * existed until the scope work made the second reachable, and the half-cleared
1194
- * state it left — Settings showing "no credentials" while cloud calls still
936
+ * state it left — the chip showing "no credentials" while cloud calls still
1195
937
  * worked — is the bug this fixes.
1196
938
  *
1197
939
  * An absolute host route owned by another package, reached the same way the
@@ -1202,8 +944,11 @@ const SERVER_CREDENTIALS_ROUTE = "api/aishell/credentials/reset";
1202
944
  * POST one JSON body to a Host credential route and read back its verdict.
1203
945
  * A non-JSON or unreadable body is reported as a transport failure rather than
1204
946
  * thrown, so the form shows a message instead of an unhandled rejection.
947
+ *
948
+ * @param t - the form's translator; the failure copy is user-visible, so it
949
+ * follows the active locale like every other string in the form.
1205
950
  */
1206
- async function postJson(route, body) {
951
+ async function postJson(route, t, body) {
1207
952
  try {
1208
953
  const response = await fetch(route, {
1209
954
  method: "POST",
@@ -1217,26 +962,22 @@ async function postJson(route, body) {
1217
962
  } catch (error) {
1218
963
  return {
1219
964
  ok: false,
1220
- error: `无法连接宿主凭据服务:${error instanceof Error ? error.message : String(error)}`
965
+ error: t("error.unreachable") + (error instanceof Error ? error.message : String(error))
1221
966
  };
1222
967
  }
1223
968
  }
1224
969
  /**
1225
970
  * Store one credential through the Host route.
1226
971
  *
1227
- * Both surfaces that collect a credential — the Settings section and the
1228
- * composer form shown while an MCP call is blocked — go through this, so a
1229
- * field added to one cannot be silently missing from the other's body. The
1230
- * route is the same one the Settings section has always used, so IAM
1231
- * verification, storage and the account chip behave identically whichever
1232
- * surface collected the value.
972
+ * Both ways the form comes up — a chip click and a blocked MCP call — go
973
+ * through this, so there is exactly one body shape for the credential route.
1233
974
  *
1234
975
  * An absent SecurityToken is omitted rather than sent empty: the Host reads an
1235
976
  * empty string as absent anyway, so sending it would only make the wire shape
1236
977
  * depend on which form was used.
1237
978
  */
1238
- function saveCredential(accessKeyId, secretAccessKey, securityToken) {
1239
- return postJson(CREDENTIALS_ROUTE, {
979
+ function saveCredential(t, accessKeyId, secretAccessKey, securityToken) {
980
+ return postJson(CREDENTIALS_ROUTE, t, {
1240
981
  accessKeyId,
1241
982
  secretAccessKey,
1242
983
  ...securityToken === void 0 ? {} : { securityToken }
@@ -1248,16 +989,18 @@ function saveCredential(accessKeyId, secretAccessKey, securityToken) {
1248
989
  * The order matters: this plugin's store goes first, because it is the one
1249
990
  * whose absence *stops* the chat from authenticating. A failure there leaves
1250
991
  * both stores intact (nothing cleared, nothing to misreport). A failure on the
1251
- * second leaves a state the user can still act on — no credentials in Settings,
1252
- * a server copy that a second attempt or a server restart will clear — which is
992
+ * second leaves a state the user can still act on — no credentials locally, a
993
+ * server copy that a second attempt or a server restart will clear — which is
1253
994
  * why the message names which half failed rather than saying "clear failed".
1254
995
  *
1255
996
  * The second store is best-effort by design: if the MCP server is unreachable
1256
997
  * or older than `credential/reset`, the local clear has already succeeded and
1257
998
  * saying so is more accurate than reporting the whole action as failed.
999
+ *
1000
+ * @param t - the form's translator; the failure copy is user-visible.
1258
1001
  */
1259
- async function clearBothStores() {
1260
- const local = await postJson(CLEAR_ROUTE);
1002
+ async function clearBothStores(t) {
1003
+ const local = await postJson(CLEAR_ROUTE, t);
1261
1004
  if (!local.ok) return local;
1262
1005
  try {
1263
1006
  const response = await fetch(SERVER_CREDENTIALS_ROUTE, { method: "POST" });
@@ -1265,13 +1008,13 @@ async function clearBothStores() {
1265
1008
  const body = await response.json();
1266
1009
  return {
1267
1010
  ok: false,
1268
- error: typeof body.error === "string" ? body.error : `本机凭据已清除,但服务端凭据未清除(HTTP ${response.status})`
1011
+ error: typeof body.error === "string" ? body.error : t("error.clear.serverFailed", { status: String(response.status) })
1269
1012
  };
1270
1013
  }
1271
1014
  } catch (error) {
1272
1015
  return {
1273
1016
  ok: false,
1274
- error: "本机凭据已清除,但无法连接 MCP 服务器清除服务端凭据:" + (error instanceof Error ? error.message : String(error))
1017
+ error: t("error.clear.serverUnreachable") + (error instanceof Error ? error.message : String(error))
1275
1018
  };
1276
1019
  }
1277
1020
  return { ok: true };
@@ -1289,6 +1032,7 @@ function apply(ctx) {
1289
1032
  en
1290
1033
  }), "aishell-credentials: dictionaries");
1291
1034
  const t = ctx.locale.bind(NS);
1035
+ installChipStyles(ctx);
1292
1036
  const form = ctx.configForms.get(AISHELL_CREDENTIALS_NS);
1293
1037
  const status = (0, __deepseek_ai_dsh_client_store.createSnapshotStore)({
1294
1038
  hasAccessKey: false,
@@ -1310,27 +1054,27 @@ function apply(ctx) {
1310
1054
  };
1311
1055
  ctx.effect(() => form.subscribe(derive), "aishell-credentials: credential presence");
1312
1056
  derive();
1313
- ctx.effect(() => ctx.configForms.whileServed([AISHELL_CREDENTIALS_NS], () => ctx.slots.inject("settings.section", () => ctx.slots.register({
1314
- name: "settings.section",
1315
- id: "aishell",
1316
- order: 50,
1317
- label: () => "AI Shell",
1318
- locale: NS,
1319
- inject: () => ({
1320
- hooks: { credentials: status },
1321
- t,
1322
- save: saveCredential,
1323
- clear: () => clearBothStores()
1324
- })
1325
- }, AishellCredentialsSection))), "aishell-credentials: settings section");
1057
+ const publishCredentialForm = ctx.uiSession.registerPendingInteraction(() => 0);
1058
+ const visibility = createCredentialFormVisibility((interaction) => publishCredentialForm(interaction, () => Promise.resolve()));
1059
+ const syncCredentialForm = () => {
1060
+ visibility.sync(form.getSnapshot().value?.credentialRequestSession ?? "");
1061
+ };
1062
+ ctx.effect(() => form.subscribe(syncCredentialForm), "aishell-credentials: credential form visibility");
1063
+ syncCredentialForm();
1064
+ ctx.effect(() => () => {
1065
+ visibility.dispose();
1066
+ }, "aishell-credentials: credential form teardown");
1326
1067
  ctx.effect(() => ctx.slots.inject("conversation.composer.dock", () => ctx.slots.register({
1327
1068
  name: "conversation.composer.dock",
1328
1069
  id: "aishell-account",
1329
1070
  order: 30,
1330
1071
  locale: NS,
1331
- inject: () => ({
1072
+ inject: (sessionId) => ({
1332
1073
  hooks: { credentials: status },
1333
- t
1074
+ t,
1075
+ openCredentialForm: () => {
1076
+ visibility.open(sessionId);
1077
+ }
1334
1078
  })
1335
1079
  }, AishellAccountHint)), "aishell-credentials: account hint chip");
1336
1080
  ctx.effect(() => ctx.slots.inject("conversation.input.dock", () => {
@@ -1339,7 +1083,12 @@ function apply(ctx) {
1339
1083
  id: "aishell-hero",
1340
1084
  order: 10,
1341
1085
  locale: NS,
1342
- inject: () => ({ hooks: { credentials: status } })
1086
+ inject: (sessionId) => ({
1087
+ hooks: { credentials: status },
1088
+ openCredentialForm: () => {
1089
+ visibility.open(sessionId);
1090
+ }
1091
+ })
1343
1092
  }, AishellHeroChip);
1344
1093
  return dispose;
1345
1094
  }), "aishell-credentials: hero account chip");
@@ -1348,22 +1097,17 @@ function apply(ctx) {
1348
1097
  select: ({ pendingInteraction }) => isCredentialForm(pendingInteraction) ? pendingInteraction : null,
1349
1098
  locale: NS,
1350
1099
  inject: () => ({
1351
- save: saveCredential,
1100
+ hooks: { credentials: status },
1101
+ save: (ak, sk, token) => saveCredential(t, ak, sk, token),
1102
+ clear: () => clearBothStores(t),
1352
1103
  dismiss: () => {
1353
1104
  fetch(DISMISS_ROUTE, { method: "POST" });
1105
+ },
1106
+ closeManual: () => {
1107
+ visibility.close();
1354
1108
  }
1355
1109
  })
1356
1110
  }, CredentialRequestForm)), "aishell-credentials: credential form");
1357
- const publishCredentialForm = ctx.uiSession.registerPendingInteraction(() => 0);
1358
- const visibility = createCredentialFormVisibility((interaction) => publishCredentialForm(interaction, () => Promise.resolve()));
1359
- const syncCredentialForm = () => {
1360
- visibility.sync(form.getSnapshot().value?.credentialRequestSession ?? "");
1361
- };
1362
- ctx.effect(() => form.subscribe(syncCredentialForm), "aishell-credentials: credential form visibility");
1363
- syncCredentialForm();
1364
- ctx.effect(() => () => {
1365
- visibility.dispose();
1366
- }, "aishell-credentials: credential form teardown");
1367
1111
  }
1368
1112
 
1369
1113
  //#endregion