@huaweidevtools/aishell-dsh-client-credentials 0.0.7 → 0.0.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.
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The `auth` tool — verify the stored credentials and report the account.
3
+ *
4
+ * ## Why this belongs to the credentials package
5
+ *
6
+ * It answers "is this account authenticated, and as whom?" — which is the
7
+ * question this package already owns. The tool belongs beside the form that
8
+ * writes the credentials, not beside the tools that spend them.
9
+ *
10
+ * Keeping it in `aishell-deploy` would split one responsibility across two
11
+ * packages: the form deciding what a valid credential is (via the credential
12
+ * route), and a tool deciding the same thing again (via `verify`). Both go
13
+ * through the same shared verifier, but the *tool* is the part a model sees and
14
+ * names, and "who am I authenticated as" is not a question about cloud tooling
15
+ * — a user asking it may never run terraform at all.
16
+ *
17
+ * ## What the model gets
18
+ *
19
+ * - With valid credentials: the account id, its name, and every visible
20
+ * project (each project's name is a region). That is what a deployment plan
21
+ * needs.
22
+ * - With none stored: a failure that asks, on the model's behalf, for the form
23
+ * to be opened. The form appears in the conversation; the model calls
24
+ * `auth` again after the person is done.
25
+ * - With credentials the service rejects: the failure carries Huawei Cloud's
26
+ * reason, and the form is opened again so the person can correct them.
27
+ * - After the person cancelled: a terminal failure telling the model to stop
28
+ * and say why authentication is needed. Without that, a model whose first
29
+ * call failed has every incentive to retry until the turn ends, and the
30
+ * person has already answered "no".
31
+ *
32
+ * ## How the form is asked for
33
+ *
34
+ * Not by returning a credential — that would put a secret in the transcript.
35
+ * The tool writes a request into this entry's settings document
36
+ * (`./form-request.ts`), the browser half sees it through `configForms`, and the
37
+ * form opens. The credential travels the other way, over the credential route,
38
+ * and never comes back through a tool result.
39
+ *
40
+ * ## What decides "the person cancelled"
41
+ *
42
+ * The form records a cancel in the store, as a sentinel the verifier reads. See
43
+ * `CANCEL_SENTINEL`: it is a marker, never a credential, and `readStoredPair`
44
+ * does not see it.
45
+ *
46
+ * ## Why it does not write the store
47
+ *
48
+ * The credential route verifies *before* it writes, one layer up. Writing from a
49
+ * tool would open a model-triggered path into the credential store, which is
50
+ * exactly what "credentials never enter the tool-call context" protects.
51
+ *
52
+ * ## Soft injection
53
+ *
54
+ * Registered behind `ctx.inject(['tools'])`. A deployment without the tool
55
+ * registry — a headless host that only serves the credential route — should
56
+ * lose the tool, not lose credential management.
57
+ *
58
+ * @module @huaweidevtools/aishell-dsh-client-credentials/auth-tool
59
+ */
60
+ import type { Context } from '@deepseek-ai/cordis';
61
+ import type { FormOutcome } from './form-request.ts';
62
+ import type { CredentialsStore } from '@huaweidevtools/aishell-dsh-credentials-store';
63
+ /** Model-facing name. Prefixed so it cannot collide with another cloud plugin. */
64
+ export declare const AUTH_TOOL_NAME = "aishell__auth";
65
+ /**
66
+ * Host-side controls the tool needs from the plugin that registers it.
67
+ *
68
+ * Injected rather than imported so this module stays a pure function over a
69
+ * store and a writer: the settings document is the registration site's
70
+ * business, and a tool that reached for `ctx.settings` itself could not be
71
+ * called from a test.
72
+ */
73
+ export interface AuthToolDeps {
74
+ /**
75
+ * Open the credential form in one session and wait for the person.
76
+ *
77
+ * Resolves when they submit or cancel — never on a timeout. A person may be
78
+ * fetching a key from the console; a form that gives up while they are typing
79
+ * is worse than a call that waits. The call's own cancellation is the way out,
80
+ * and the caller passes its signal for that.
81
+ *
82
+ * `undefined` when there is no session to render the form in, which is the
83
+ * case a call running outside an agent hits.
84
+ */
85
+ readonly requestForm: (sessionId: string) => Promise<FormOutcome> | undefined;
86
+ /**
87
+ * This call has stopped waiting on the form it asked for.
88
+ *
89
+ * Required, not optional, because the leak it prevents is invisible and
90
+ * permanent: the host shares one pending request between concurrent callers,
91
+ * so a call that walks away without saying so leaves that request in place.
92
+ * The next `auth` then joins a promise nobody will ever settle — no form is
93
+ * written to the document, so none appears, and the call waits until the
94
+ * turn ends.
95
+ *
96
+ * A person who aborts a turn is the ordinary way in. Nothing about that is
97
+ * an error, which is exactly why nothing else remembers to do this.
98
+ */
99
+ readonly releaseForm: () => void;
100
+ }
101
+ /**
102
+ * Register the `auth` tool on the host's tool registry.
103
+ *
104
+ * @param ctx - host context.
105
+ * @param store - the credential store this package owns.
106
+ */
107
+ export declare function registerAuthTool(ctx: Context, store: CredentialsStore, deps: AuthToolDeps): void;
108
+ //# sourceMappingURL=auth-tool.d.ts.map
@@ -10,7 +10,7 @@
10
10
  * chip's place so the user knows to set up credentials before chatting.
11
11
  *
12
12
  * Clicking either posture opens the credential form in this conversation —
13
- * the same surface a blocked MCP call brings up.
13
+ * the same surface a blocked tool call brings up.
14
14
  *
15
15
  * Layout note: the host renders this entry and ContextMeter (the "N turns /
16
16
  * N steps" readout) as siblings inside one block-flow dock container. We
@@ -17,7 +17,7 @@
17
17
  */
18
18
  import type { SessionId } from '@deepseek-ai/dsh-session';
19
19
  /**
20
- * One presentation of "the MCP server needs credentials".
20
+ * One presentation of the credential form.
21
21
  *
22
22
  * The `key` is opaque to the framework and only has to change when the
23
23
  * presentation must remount; `kind` is this domain's own discriminator, which
@@ -39,21 +39,13 @@ export interface CredentialFormInteraction {
39
39
  * string; branded by a cast (see the import note).
40
40
  */
41
41
  readonly sessionId: SessionId;
42
- /**
43
- * Whether a chip opened this form rather than a Host request. Only the
44
- * component reads it: the title and the cancel semantics follow the door
45
- * the form came in by, and the visibility state machine keeps it current
46
- * (a Host request taking over the form clears it).
47
- */
48
- readonly manual: boolean;
49
42
  }
50
43
  /**
51
44
  * Build an interaction for one session.
52
45
  *
53
46
  * @param sessionId - the conversation the form belongs to.
54
- * @param manual - true when a chip opened the form (no request behind it).
55
47
  */
56
- export declare function credentialFormInteraction(sessionId: string, manual: boolean): CredentialFormInteraction;
48
+ export declare function credentialFormInteraction(sessionId: string): CredentialFormInteraction;
57
49
  /**
58
50
  * Test whether a pending interaction is this domain's form.
59
51
  *
@@ -64,13 +56,4 @@ export declare function credentialFormInteraction(sessionId: string, manual: boo
64
56
  * @param value - the session's pending interaction, or `undefined`.
65
57
  */
66
58
  export declare function isCredentialForm(value: unknown): value is CredentialFormInteraction;
67
- /**
68
- * Route the Host exposes to abandon a pending credential request.
69
- *
70
- * Sits with the other credential routes: `clear`, `reset`, and this one all end
71
- * a credential state, and keeping them together is what makes the route table
72
- * readable. Without it a person who does not want to enter credentials would
73
- * leave the blocked tool call waiting until the turn ended.
74
- */
75
- export declare const DISMISS_ROUTE = "api/aishell/credentials/dismiss";
76
59
  //# sourceMappingURL=CredentialFormInteraction.d.ts.map
@@ -2,30 +2,24 @@
2
2
  * The credential form — the one surface where credentials are entered.
3
3
  *
4
4
  * A masked AK/SK form rendered into `conversation.composer`, taking over the
5
- * input box the way the approval panel does. It appears two ways: when
6
- * ops-deploy reports the server is waiting for credentials (a tool call is
7
- * blocked on the answer), and when a credential chip opens it directly (the
8
- * former Settings section is gone; the chips and the blocked-call form are now
9
- * the same surface). Both submit through the same Host credential route — so
10
- * IAM verification, storage, and the account chip behave identically, and
11
- * there is one place where a credential is validated regardless of which door
12
- * it came in by.
5
+ * input box the way the approval panel does. A credential chip opens it; that
6
+ * is the only door, and the form is the only place a credential is entered.
13
7
  *
14
- * The two doors differ in one visible way each: the title (a blocked call
15
- * *requires* credentials; a chip click merely *configures* them), and how the
16
- * form ends — a request-owned form is taken down by the Host once the request
17
- * resolves, while a manually-opened one closes itself after a successful save
18
- * (the chip flipping to the account name is the confirmation, so no "saved"
19
- * banner is needed) or when the person dismisses it.
8
+ * Submitting goes through the Host credential route, which verifies against IAM
9
+ * and writes the store. The form closes itself after a successful save — the
10
+ * chip flipping to the account name is the confirmation, so no "saved" banner
11
+ * is needed — and closes when the person cancels.
12
+ *
13
+ * Nothing here ever receives the stored secret back: the form posts it and the
14
+ * route answers with a verdict, so neither the browser nor the conversation
15
+ * holds the credential afterwards.
20
16
  *
21
17
  * ## Why the composer and not a modal
22
18
  *
23
- * The blocked-call form belongs where the person's attention already is and
24
- * where they act: the composer. It is the same seat the approval panel uses
25
- * for the same reason — an out-of-band request that must be answered before
26
- * work continues. The chip-opened form reuses that seat so there is one shape
27
- * to learn, not two (and the pending-interaction takeover works on the blank
28
- * New-Session page exactly as it does mid-conversation).
19
+ * The form belongs where the person's attention already is and where they act:
20
+ * the composer. It is the same seat the approval panel uses — a surface that
21
+ * takes over the input box while something needs an answer. The takeover works
22
+ * on the blank New-Session page exactly as it does mid-conversation.
29
23
  *
30
24
  * ## Why masked inputs are not optional
31
25
  *
@@ -40,6 +34,8 @@ import { type ReactNode } from 'react';
40
34
  import type { InjectFace, PropsRuntime, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
41
35
  import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
42
36
  import { type CredentialStatus, type SaveVerdict } from './credential-status.ts';
37
+ import type { BrowserLoginHandle } from './login-flow.ts';
38
+ import type { CredentialPrefill } from '../prefill.ts';
43
39
  import type { CredentialFormInteraction } from './CredentialFormInteraction.ts';
44
40
  declare module '@deepseek-ai/dsh-client-ui-session/client' {
45
41
  interface SessionPendingInteractionMap {
@@ -51,31 +47,64 @@ export interface CredentialRequestFormInjected {
51
47
  hooks: {
52
48
  /** Credential presence + account hint, rebound by the renderer as useCredentials. */
53
49
  credentials: SnapshotStore<CredentialStatus>;
50
+ /** The last browser login's outcome, rebound as useLoginOutcome. */
51
+ loginOutcome: SnapshotStore<string>;
54
52
  };
55
53
  /** Store AK/SK/SecurityToken through the Host credential route. */
56
54
  save: (accessKeyId: string, secretAccessKey: string, securityToken?: string) => Promise<SaveVerdict>;
57
55
  /**
58
- * Clear both credential stores (local + MCP server copy).
56
+ * Begin a browser login, if this deployment can complete one.
57
+ *
58
+ * Binds a listener on the host and proves this page can reach it. Resolves
59
+ * `undefined` when it cannot — which is the ordinary answer when the browser
60
+ * runs on a different machine from the host, and the case that hides this
61
+ * entry entirely.
62
+ *
63
+ * The check is re-run every time the form opens: reachability changes with
64
+ * VPNs, tunnels and taken ports, so a remembered answer would keep the entry
65
+ * hidden after someone fixed their setup.
66
+ *
67
+ * @returns a started login, or `undefined` when the path is unavailable.
68
+ */
69
+ startBrowserLogin: () => Promise<BrowserLoginHandle | undefined>; /**
70
+ * Values the host already has, to start the fields with.
71
+ *
72
+ * Fills the inputs; it does not submit, does not hide the form, and every
73
+ * field stays editable. The point is to save the person copying three values
74
+ * out of their shell — not to skip the form.
75
+ */
76
+ readPrefill: () => Promise<CredentialPrefill>;
77
+ /**
78
+ * Clear the stored credentials.
59
79
  *
60
80
  * Only invoked from the clear button, which renders only when credentials
61
81
  * already exist — there is nothing to clear otherwise.
62
82
  */
63
83
  clear: () => Promise<SaveVerdict>;
64
- /** Tell the Host the form is done, so the waiting tool call can resume or fail. */
65
- dismiss: () => void;
66
- /** Close a manually-opened form. A no-op when a Host request owns the form. */
67
- closeManual: () => void;
84
+ /**
85
+ * Withdraw the form after saving — restores the ordinary composer.
86
+ *
87
+ * Used by the success path, where there is nothing to decline.
88
+ */
89
+ close: () => void;
90
+ /**
91
+ * Decline: withdraw the form and tell the host this request was refused.
92
+ *
93
+ * The difference matters. Without it the host cannot tell "the person said
94
+ * no" from "the person has not answered", and a model whose call failed has
95
+ * every reason to ask again until the turn ends.
96
+ */
97
+ cancel: () => void;
68
98
  }
69
99
  /** Full component props: composer owner share + locale seat + inject face. */
70
100
  export type CredentialRequestFormProps = PropsRuntime<'conversation.composer'> & PropsLocale<'aishell'> & InjectFace<CredentialRequestFormInjected>;
71
101
  /**
72
102
  * The masked credential form.
73
103
  *
74
- * Submitting saves through the Host route; the Host then tells the waiting tool
75
- * call there is now a credential, and clears the pending flag this component
76
- * renders from — so a successful submit does not need to unmount itself. A
77
- * manually-opened form has no request behind it, so it closes itself after a
78
- * successful save (the chip flipping to the account name is the feedback).
104
+ * Submitting saves through the Host route; the form then closes itself, and the
105
+ * chip flipping to the account name is the feedback that it worked. There is no
106
+ * request behind an open form — a chip opened it — so nothing else takes it
107
+ * down.
79
108
  */
80
109
  export declare function CredentialRequestForm(props: CredentialRequestFormProps): ReactNode;
81
110
  //# sourceMappingURL=CredentialRequestForm.d.ts.map
@@ -1,46 +1,32 @@
1
1
  /**
2
2
  * Decides when the credential form is up.
3
3
  *
4
- * Kept out of the plugin body because it is the part that is easy to get
5
- * wrong and impossible to see going wrong: an interaction that is published
6
- * and never withdrawn leaves the form on screen over a request that no longer
7
- * exists, and nothing throws. The plugin body wires this to the slot
8
- * registry; this module holds only the decision.
4
+ * Kept out of the plugin body because it is the part that is easy to get wrong
5
+ * and impossible to see going wrong: an interaction that is published and never
6
+ * withdrawn leaves the form on screen, and nothing throws. The plugin body wires
7
+ * this to the slot registry; this module holds only the decision.
9
8
  *
10
- * ## Two ways the form comes up
9
+ * ## One way the form comes up
11
10
  *
12
- * The Host used to be the only source: it publishes which session is waiting
13
- * (`''` when none is), and this mirrored that into the one interaction the
14
- * composer chain selects on. The settings section's removal made the form the
15
- * only credential surface, so the chips now open it directly — a *manual*
16
- * open, with no request behind it. The two sources meet here under one rule
17
- * set:
11
+ * A chip opens it. That is the whole model.
18
12
  *
19
- * - A Host request REPLACES whatever is up, manual or not: a blocked tool
20
- * call outranks a form the person opened to browse, and the request's
21
- * session decides where the form renders. A request landing on the
22
- * manual form's own session takes the form over the same way — by
23
- * republishing with a request-owned interaction, because the manual flag
24
- * lives on the published object and the renderer only re-renders on a new
25
- * reference.
26
- * - A request ending (`''`) takes the form down and does NOT fall back to a
27
- * manual open. The person answered the request (or declined it); the form
28
- * has served its purpose and staying up would be a stale surface.
29
- * - A manual open while a request's form is already up is a no-op — the
30
- * person is already looking at the form, just through the other door.
31
- * - A manual open while no form is up publishes a manual interaction bound
32
- * to the current session, and only a manual close (or dispose) withdraws
33
- * it: no request exists to end it, and the ordinary composer must come
34
- * back when the person is done.
13
+ * There used to be a second source — the Host publishing which session had a
14
+ * tool call blocked on credentials — and this module reconciled the two, with
15
+ * rules about which one owned the form and how a takeover republished the
16
+ * interaction. That request channel is gone: no tool call blocks on credentials
17
+ * any more, so a Host request cannot arrive, and every rule about outranking
18
+ * one describes a situation that cannot happen.
35
19
  *
36
- * The manual interaction needs a session id too — `conversation.composer` is
37
- * session-scoped — but unlike the Host's, it is chosen at click time (the
38
- * chip knows its session) rather than mirrored.
20
+ * The rules that remain are the ones a single door needs:
21
+ *
22
+ * - An open while the form is already up is a no-op. Publishing a second
23
+ * interaction would remount the component and discard what was typed.
24
+ * - A close, or a dispose, withdraws it, and the ordinary composer comes back.
39
25
  *
40
26
  * ## Why a closure and not a class
41
27
  *
42
- * Written as a factory because the browser half is compiled by oxc, and a
43
- * class with private (`#`) fields makes that compiler panic
28
+ * Written as a factory because the browser half is compiled by oxc, and a class
29
+ * with private (`#`) fields makes that compiler panic
44
30
  * (`oxc_transformer ... es2022/class_properties/class_details.rs:138:
45
31
  * internal error: entered unreachable code`), which fails the CJS build and
46
32
  * leaves `lib/client.js` unwritten — DSH then refuses to start. The state here
@@ -51,40 +37,21 @@
51
37
  import { type CredentialFormInteraction } from './CredentialFormInteraction.ts';
52
38
  /** Publishes one interaction and returns the function that withdraws it. */
53
39
  export type PublishInteraction = (interaction: CredentialFormInteraction) => () => void;
54
- /** Mirrors "which session is waiting" and the manual open/close onto the composer's pending interaction. */
40
+ /** Opens and closes the form on the composer's pending interaction. */
55
41
  export interface CredentialFormVisibility {
56
42
  /**
57
- * Apply the Host's current state.
58
- *
59
- * Idempotent: calling it with the state it already reflects changes nothing,
60
- * which is what keeps a re-render from remounting the form and discarding
61
- * what the person typed.
62
- *
63
- * @param sessionId - the session waiting for credentials, or `''` for none.
64
- */
65
- readonly sync: (sessionId: string) => void;
66
- /**
67
- * Open the form manually for one session.
43
+ * Open the form for one session.
68
44
  *
69
- * A no-op while any form is up (manual or Host-driven): the person is
70
- * already looking at the form. Publishing a second interaction for the same
71
- * surface would remount the component and discard what was typed.
45
+ * A no-op while it is already up: the person is looking at it, and a new
46
+ * interaction would remount the component and throw away what they typed.
72
47
  *
73
- * @param sessionId - the conversation the manually-opened form renders in.
48
+ * @param sessionId - the conversation the form renders in.
74
49
  */
75
50
  readonly open: (sessionId: string) => void;
76
- /**
77
- * Close a manually-opened form.
78
- *
79
- * A no-op unless the current form is the manual one: a Host-driven form
80
- * belongs to the waiting request and only the request's end takes it down —
81
- * a chip click must never cancel a blocked tool call's form out from under it.
82
- */
51
+ /** Withdraw the open form, if any, restoring the ordinary composer. */
83
52
  readonly close: () => void;
84
53
  /** The interaction currently published, if any. For tests and diagnostics. */
85
54
  readonly current: () => CredentialFormInteraction | undefined;
86
- /** Whether the current form was opened manually (no Host request behind it). */
87
- readonly manual: () => boolean;
88
55
  /** Withdraw any open form. Called when the plugin fiber is disposed. */
89
56
  readonly dispose: () => void;
90
57
  }
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * There is no Settings section any more: the form is the one credential
13
13
  * surface, opened either by a chip click (the visibility state machine's
14
- * manual posture) or by an MCP call blocked on credentials (the Host-mirrored
14
+ * manual posture) or by a tool call blocked on credentials (the Host-mirrored
15
15
  * posture). Both render the same component in `conversation.composer`.
16
16
  *
17
17
  * @module @huaweidevtools/aishell-dsh-client-credentials/client
@@ -13,15 +13,15 @@ export declare const zh: {
13
13
  readonly 'mode.unavailable': "权限模式不可用";
14
14
  readonly 'mode.readonly.hint': "当前:只读 — 只允许查询云资源,点击切换为读写";
15
15
  readonly 'mode.readwrite.hint': "当前:读写 — 允许变更云资源,点击切换为只读";
16
- readonly 'mode.unavailable.hint': "无法从 MCP 服务器读取权限模式;切换按钮暂不可用";
16
+ readonly 'mode.unavailable.hint': "无法读取权限模式;切换按钮暂不可用";
17
17
  readonly 'mode.switchToReadonly': "切换为只读模式";
18
18
  readonly 'mode.switchToReadwrite': "切换为读写模式";
19
19
  readonly 'section.credentials.hint.prefix': "需要进行华为云 IAM 认证,建议从";
20
20
  readonly 'section.credentials.hint.link': "API Explorer";
21
21
  readonly 'section.credentials.hint.suffix': "获取临时凭据,避免使用永久凭据。";
22
22
  readonly 'section.credentials.saving': "保存中…";
23
- readonly 'form.title': "需要华为云凭据";
24
23
  readonly 'form.title.manual': "配置华为云凭据";
24
+ readonly 'form.prefilledFromEnv': "检测到环境变量,已填入表单";
25
25
  readonly 'form.submit': "提交";
26
26
  readonly 'form.dismiss': "取消";
27
27
  readonly 'form.failed': "保存凭据失败";
@@ -29,8 +29,17 @@ export declare const zh: {
29
29
  readonly 'form.clearing': "清除中…";
30
30
  readonly 'form.clear.failed': "清除凭据失败";
31
31
  readonly 'error.unreachable': "无法连接宿主凭据服务:";
32
- readonly 'error.clear.serverFailed': "本机凭据已清除,但服务端凭据未清除(HTTP {status})";
33
- readonly 'error.clear.serverUnreachable': "本机凭据已清除,但无法连接 MCP 服务器清除服务端凭据:";
32
+ readonly 'form.intro': "需要进行华为云 IAM 认证";
33
+ readonly 'form.checking': "正在检查登录方式…";
34
+ readonly 'form.browser.action': "浏览器登录";
35
+ readonly 'form.browser.aksk': "我有AK/SK";
36
+ readonly 'form.browser.decline': "暂不认证";
37
+ readonly 'form.browser.waiting': "正在等待浏览器完成登录…";
38
+ readonly 'form.browser.countdown': "剩余 {time}";
39
+ readonly 'form.browser.reopen': "重新打开";
40
+ readonly 'form.back': "返回";
41
+ readonly 'form.browser.blocked': "浏览器拦截了新标签页,请允许弹出窗口后重试。";
42
+ readonly 'form.browser.failed': "浏览器登录未完成:";
34
43
  readonly 'section.field.accessKey': "Access Key";
35
44
  readonly 'section.field.accessKey.placeholder': "华为云 Access Key";
36
45
  readonly 'section.field.accessKey.hint': "Access Key 与 Secret Key 须同时填写,只填其一时不会保存。";
@@ -49,15 +58,15 @@ export declare const en: {
49
58
  readonly 'mode.unavailable': "Mode unavailable";
50
59
  readonly 'mode.readonly.hint': "Read-only — cloud queries only. Click for read-write";
51
60
  readonly 'mode.readwrite.hint': "Read-write — cloud changes allowed. Click for read-only";
52
- readonly 'mode.unavailable.hint': "Could not read the permission mode from the MCP server; the toggle is unavailable";
61
+ readonly 'mode.unavailable.hint': "Could not read the permission mode; the toggle is unavailable";
53
62
  readonly 'mode.switchToReadonly': "Switch to read-only mode";
54
63
  readonly 'mode.switchToReadwrite': "Switch to read-write mode";
55
64
  readonly 'section.credentials.hint.prefix': "Authenticate against Huawei Cloud IAM. Obtain temporary credentials from";
56
65
  readonly 'section.credentials.hint.link': "API Explorer";
57
66
  readonly 'section.credentials.hint.suffix': "and avoid permanent ones.";
58
67
  readonly 'section.credentials.saving': "Saving…";
59
- readonly 'form.title': "Huawei Cloud credentials required";
60
68
  readonly 'form.title.manual': "Configure Huawei Cloud credentials";
69
+ readonly 'form.prefilledFromEnv': "Detected environment variables — filled in from them";
61
70
  readonly 'form.submit': "Submit";
62
71
  readonly 'form.dismiss': "Cancel";
63
72
  readonly 'form.failed': "Could not save credentials";
@@ -65,8 +74,17 @@ export declare const en: {
65
74
  readonly 'form.clearing': "Clearing…";
66
75
  readonly 'form.clear.failed': "Could not clear credentials";
67
76
  readonly 'error.unreachable': "Could not reach the host credential service: ";
68
- readonly 'error.clear.serverFailed': "Local credentials were cleared, but the server copy was not (HTTP {status})";
69
- readonly 'error.clear.serverUnreachable': "Local credentials were cleared, but the MCP server could not be reached to clear the server copy: ";
77
+ readonly 'form.intro': "Huawei Cloud IAM authentication is required";
78
+ readonly 'form.checking': "Checking sign-in options…";
79
+ readonly 'form.browser.action': "Sign in with a browser";
80
+ readonly 'form.browser.aksk': "I have one";
81
+ readonly 'form.browser.decline': "Not now";
82
+ readonly 'form.browser.waiting': "Waiting for the browser sign-in to finish…";
83
+ readonly 'form.browser.countdown': "{time} left";
84
+ readonly 'form.browser.reopen': "Reopen";
85
+ readonly 'form.back': "Back";
86
+ readonly 'form.browser.blocked': "The browser blocked the new tab. Allow pop-ups for this page, then try again.";
87
+ readonly 'form.browser.failed': "The browser sign-in did not complete: ";
70
88
  readonly 'section.field.accessKey': "Access Key";
71
89
  readonly 'section.field.accessKey.placeholder': "Huawei Access Key";
72
90
  readonly 'section.field.accessKey.hint': "Access Key and Secret Key are stored as a pair; one without the other is not saved.";
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Browser-login support, as the form sees it.
3
+ *
4
+ * ## What the form needs to know
5
+ *
6
+ * Two things, and they arrive by different routes:
7
+ *
8
+ * - **Can this deployment do it at all?** Answered by the probe, on demand,
9
+ * because only the browser can answer it. See below.
10
+ * - **How did the last attempt end?** Read from the entry's settings
11
+ * document, which the host writes when the credential lands — the person
12
+ * may be at the cloud for minutes, so there is nothing to await.
13
+ *
14
+ * ## Why the capability is probed rather than assumed
15
+ *
16
+ * The cloud posts the credential to `127.0.0.1` *as the browser's machine
17
+ * resolves it*, so the flow only works when the browser and the host are the
18
+ * same machine. That is not knowable from either side: an SSH-forwarded
19
+ * session makes a distant browser look local to the host, and a distant host
20
+ * look local to the page. So the browser asks a question only it can ask —
21
+ * *can I reach the host's listener?* — by fetching it.
22
+ *
23
+ * This is also why the capability is never cached. Reachability depends on
24
+ * things that change under the user's feet (a VPN, a tunnel, a port taken
25
+ * between attempts), and a cached "no" would keep the entry hidden after
26
+ * someone fixed their setup.
27
+ *
28
+ * ## The cost of asking
29
+ *
30
+ * `start` binds a loopback port on the host and fetches the provider's
31
+ * callback plan. That work is not wasted when the answer is yes — it is the
32
+ * login, already begun, and clicking the entry only opens the URL it returned.
33
+ * When the answer is no, the port is released immediately.
34
+ *
35
+ * @module @huaweidevtools/aishell-dsh-client-credentials/client/login-flow
36
+ */
37
+ /**
38
+ * A browser login the host has begun and the browser can reach.
39
+ *
40
+ * Holding this means a listener is bound and waiting, so it must be released —
41
+ * see {@link BrowserLoginHandle.cancel} — when the form closes without using
42
+ * it.
43
+ */
44
+ export interface BrowserLoginHandle {
45
+ /** URL to open when the person chooses this path. */
46
+ readonly loginUrl: string;
47
+ /** Provider's display name, for the copy that names it. */
48
+ readonly providerName: string;
49
+ /**
50
+ * Seconds until the login stops being completable, as the service stated it.
51
+ *
52
+ * The waiting card counts down to this. The host enforces the same number on
53
+ * its listener, so what the person sees and what the port does agree.
54
+ */
55
+ readonly expiresInSeconds: number;
56
+ /** Release the host's listener; the login will not complete. */
57
+ readonly cancel: () => void;
58
+ }
59
+ /**
60
+ * Reachability check, then login.
61
+ *
62
+ * Starts a login on the host and then proves this page can reach the listener
63
+ * it bound. The probe request goes from this browser to loopback, which is the
64
+ * same journey the cloud's callback will make.
65
+ *
66
+ * ## Why the probe is not a plain GET
67
+ *
68
+ * It carries a custom header, which makes it a non-simple request: the browser
69
+ * must send a CORS preflight first, and only proceeds if the answer is right.
70
+ * The cloud's callback is a JSON POST and therefore *always* preflights, so a
71
+ * plain GET would test a path the callback never takes — and could pass on a
72
+ * deployment where the real preflight fails (a missing Private Network Access
73
+ * allow header, say), which is the one wrong answer this check must not give.
74
+ *
75
+ * @returns a handle when the login is reachable, or `undefined` when it is
76
+ * not — the ordinary outcome on a deployment where the browser is elsewhere.
77
+ */
78
+ export declare function startBrowserLogin(): Promise<BrowserLoginHandle | undefined>;
79
+ /**
80
+ * Open a login URL in a new tab.
81
+ *
82
+ * A separate tab rather than a redirect: the form has unsaved state and the
83
+ * person may come back to paste a key instead, and a login that navigated away
84
+ * from the conversation would lose it.
85
+ *
86
+ * ## Why `noopener` is set after opening, not passed in
87
+ *
88
+ * `window.open` returns `null` whenever `noopener` appears in its features
89
+ * string — by specification, not as a failure. Passing it there would make
90
+ * every successful open look blocked, so the tab is opened plainly and the
91
+ * opener reference is severed immediately afterwards, which is the same
92
+ * protection without losing the success signal.
93
+ *
94
+ * @param url - the URL the host returned.
95
+ * @returns whether the browser opened it; a popup blocker says no.
96
+ */
97
+ export declare function openLoginWindow(url: string): boolean;
98
+ //# sourceMappingURL=login-flow.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Client half of the permission-mode switch, shared by both chips.
3
3
  *
4
- * The mode lives in the MCP server process, not in DSH. A Host route relays to
5
- * it over the plugin's own MCP connection; this module owns the fetch and the
6
- * state hook so the composer chip and the hero chip cannot drift apart.
4
+ * The mode lives in the host process (`aishell-deploy`). A Host route reads and
5
+ * writes it; this module owns the fetch and the state hook so the composer chip
6
+ * and the hero chip cannot drift apart.
7
7
  *
8
8
  * @module @huaweidevtools/aishell-dsh-client-credentials/client/permission-mode
9
9
  */
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The waiting spinner's keyframes.
3
+ *
4
+ * ## Why not inline styles
5
+ *
6
+ * A rotation needs `@keyframes`, which no inline style can express. The two
7
+ * options are a CSS module (this package's client build does not run one) or a
8
+ * tag installed at runtime — and this repo already has the second pattern for
9
+ * exactly this: `installChipStyles` in `./huawei-mark.ts`, whose module note
10
+ * records why an `id`-guarded module-level install is wrong (the client loader
11
+ * sweeps `style[data-plugin]` on teardown, so an outliving tag makes a reload
12
+ * keep the *old* rule for the life of the tab).
13
+ *
14
+ * So: one `ctx.effect` per sheet, a disposer that removes the tag, and the
15
+ * same `data-plugin` / `data-plugin-css` markers.
16
+ *
17
+ * @module @huaweidevtools/aishell-dsh-client-credentials/client/spinner
18
+ */
19
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
20
+ /** Class the waiting spinner carries. */
21
+ export declare const SPINNER_CLASS = "aishell-spinner";
22
+ /**
23
+ * Install the spinner keyframes for the lifetime of the plugin fiber.
24
+ *
25
+ * Respects `prefers-reduced-motion`: a continuous rotation is exactly the kind
26
+ * of motion that setting exists to suppress, and the countdown beside it still
27
+ * conveys that work is in progress.
28
+ *
29
+ * @param ctx - the client context, for `ctx.effect`.
30
+ */
31
+ export declare function installSpinnerStyles(ctx: ClientContext): void;
32
+ //# sourceMappingURL=spinner.d.ts.map