@huaweidevtools/aishell-dsh-client-credentials 0.0.7 → 0.0.9
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/LICENSE +1 -1
- package/lib/client.js +915 -259
- package/lib/index.js +1577 -109
- package/lib/types/auth-tool.d.ts +108 -0
- package/lib/types/client/AishellAccountHint.d.ts +1 -1
- package/lib/types/client/CredentialFormInteraction.d.ts +2 -19
- package/lib/types/client/CredentialRequestForm.d.ts +64 -41
- package/lib/types/client/card-state.d.ts +58 -0
- package/lib/types/client/credential-form-visibility.d.ts +25 -58
- package/lib/types/client/index.d.ts +1 -1
- package/lib/types/client/locales.d.ts +42 -12
- package/lib/types/client/login-flow.d.ts +134 -0
- package/lib/types/client/permission-mode.d.ts +3 -3
- package/lib/types/form-request.d.ts +118 -0
- package/lib/types/index.d.ts +28 -50
- package/lib/types/login-status.d.ts +62 -0
- package/lib/types/out-of-band/contract.d.ts +199 -0
- package/lib/types/out-of-band/flow.d.ts +101 -0
- package/lib/types/out-of-band/listener.d.ts +233 -0
- package/lib/types/out-of-band/login.d.ts +123 -0
- package/lib/types/out-of-band/routes.d.ts +136 -0
- package/lib/types/prefill.d.ts +78 -0
- package/lib/types/reconcile.d.ts +3 -11
- package/package.json +5 -3
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
@@ -1,38 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The credential
|
|
2
|
+
* The credential card — the one surface where credentials are entered.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
4
|
+
* Rendered into `conversation.composer`, taking over the input box the way the
|
|
5
|
+
* approval panel does. A credential chip opens it, and `aishell__auth` asks for
|
|
6
|
+
* it when a tool call has no usable credential.
|
|
13
7
|
*
|
|
14
|
-
*
|
|
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
|
+
* ## Two states, decided by whether a credential is stored
|
|
20
9
|
*
|
|
21
|
-
*
|
|
10
|
+
* The card shows **one** of two things, and nothing else:
|
|
22
11
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* to learn, not two (and the pending-interaction takeover works on the blank
|
|
28
|
-
* New-Session page exactly as it does mid-conversation).
|
|
12
|
+
* - **Signed in** — the account name and a way out. No inputs, because the
|
|
13
|
+
* question a signed-in person has is "who am I and how do I leave", not
|
|
14
|
+
* "what is your access key".
|
|
15
|
+
* - **Not signed in** — both ways to obtain a credential, side by side.
|
|
29
16
|
*
|
|
30
|
-
*
|
|
17
|
+
* An earlier version spread this across four pages (`choose` / `manual` /
|
|
18
|
+
* `waiting` plus a "deciding" state) and moved between them as the probe
|
|
19
|
+
* answered. The pages were the same card wearing different hats — the person
|
|
20
|
+
* sees one panel either way — and the transitions were visible: fields appeared
|
|
21
|
+
* and were replaced a moment later. One upright card with a button that reports
|
|
22
|
+
* its own state is both smaller and calmer.
|
|
31
23
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
24
|
+
* ## Why the browser route reports itself in place
|
|
25
|
+
*
|
|
26
|
+
* The button is the status: `checking` while the probe runs, `login` once it
|
|
27
|
+
* passes, `unsupported` when it fails, `cancel` while a login is in flight with
|
|
28
|
+
* the countdown beside it. A separate page for "waiting" was a second layout to
|
|
29
|
+
* keep in step with the first for no gain.
|
|
36
30
|
*
|
|
37
31
|
* @module @huaweidevtools/aishell-dsh-client-credentials/client/CredentialRequestForm
|
|
38
32
|
*/
|
|
@@ -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,58 @@ 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
|
-
*
|
|
56
|
+
* Ask whether a browser here can reach a loopback listener.
|
|
57
|
+
*
|
|
58
|
+
* Called on open, so the button can report whether the route exists here
|
|
59
|
+
* before anyone presses it.
|
|
60
|
+
*
|
|
61
|
+
* @param signal - aborts the request when the card goes away.
|
|
62
|
+
* @returns whether the browser route works from where this page is loaded.
|
|
63
|
+
*/
|
|
64
|
+
probeBrowserRoute: (signal?: AbortSignal) => Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Begin a browser login. Called when the person asks for one, not before.
|
|
67
|
+
*
|
|
68
|
+
* Binds its own listener and fetches a URL projected for it at that moment,
|
|
69
|
+
* so the URL is fresh however long the card sat open.
|
|
70
|
+
*
|
|
71
|
+
* @returns a handle for the login in flight, or `undefined` on failure.
|
|
72
|
+
*/
|
|
73
|
+
startBrowserLogin: () => Promise<BrowserLoginHandle | undefined>;
|
|
74
|
+
/**
|
|
75
|
+
* Values the host already has, to start the fields with.
|
|
59
76
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
77
|
+
* Fills the inputs; it does not submit, does not hide the card, and every
|
|
78
|
+
* field stays editable. The point is to save the person copying three values
|
|
79
|
+
* out of their shell — not to skip the form.
|
|
62
80
|
*/
|
|
81
|
+
readPrefill: () => Promise<CredentialPrefill>;
|
|
82
|
+
/** Clear the stored credentials. */
|
|
63
83
|
clear: () => Promise<SaveVerdict>;
|
|
64
|
-
/**
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
|
|
84
|
+
/** Withdraw the card after saving — restores the ordinary composer. */
|
|
85
|
+
close: () => void;
|
|
86
|
+
/**
|
|
87
|
+
* Decline: withdraw the card and tell the host this request was refused.
|
|
88
|
+
*
|
|
89
|
+
* The difference matters. Without it the host cannot tell "the person said
|
|
90
|
+
* no" from "the person has not answered", and a model whose call failed has
|
|
91
|
+
* every reason to ask again until the turn ends.
|
|
92
|
+
*/
|
|
93
|
+
cancel: () => void;
|
|
68
94
|
}
|
|
69
95
|
/** Full component props: composer owner share + locale seat + inject face. */
|
|
70
96
|
export type CredentialRequestFormProps = PropsRuntime<'conversation.composer'> & PropsLocale<'aishell'> & InjectFace<CredentialRequestFormInjected>;
|
|
71
97
|
/**
|
|
72
|
-
* The
|
|
98
|
+
* The credential card.
|
|
73
99
|
*
|
|
74
|
-
* Submitting saves through the Host route; the
|
|
75
|
-
*
|
|
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).
|
|
100
|
+
* Submitting saves through the Host route; the card then closes itself, and the
|
|
101
|
+
* chip flipping to the account name is the feedback that it worked.
|
|
79
102
|
*/
|
|
80
103
|
export declare function CredentialRequestForm(props: CredentialRequestFormProps): ReactNode;
|
|
81
104
|
//# sourceMappingURL=CredentialRequestForm.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the browser-login button says and whether it can be pressed.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this is a module
|
|
5
|
+
*
|
|
6
|
+
* The button is the browser route's whole status display: it reports the probe
|
|
7
|
+
* (`checking`), a refusal (`unsupported`), readiness (`login`), and a login in
|
|
8
|
+
* flight (`cancel`). Four states in one control, decided by two inputs, is
|
|
9
|
+
* exactly the kind of table that reads correctly inline and is wrong at the
|
|
10
|
+
* edges — and this package has no component-rendering test tier, so inline
|
|
11
|
+
* means untested.
|
|
12
|
+
*
|
|
13
|
+
* Split out as a pure function for the same reason
|
|
14
|
+
* `./credential-form-visibility` is: the decision is drivable from a spec.
|
|
15
|
+
*
|
|
16
|
+
* ## The label is a locale key
|
|
17
|
+
*
|
|
18
|
+
* Returned as a key rather than as text so the caller keeps the only `t` — the
|
|
19
|
+
* dictionary is the single place the wording lives, and a function returning
|
|
20
|
+
* English would be a second one.
|
|
21
|
+
*
|
|
22
|
+
* @module @huaweidevtools/aishell-dsh-client-credentials/client/card-state
|
|
23
|
+
*/
|
|
24
|
+
import type { AishellLocaleKey } from './locales.ts';
|
|
25
|
+
/** The button's state: what it says, and whether it does anything. */
|
|
26
|
+
export interface BrowserButtonState {
|
|
27
|
+
/** Locale key for the label. */
|
|
28
|
+
readonly label: AishellLocaleKey;
|
|
29
|
+
/** Whether the press is refused. */
|
|
30
|
+
readonly disabled: boolean;
|
|
31
|
+
}
|
|
32
|
+
/** Where a browser login has got to. Mirrors the component's `LoginPhase`. */
|
|
33
|
+
export type LoginPhase = 'checking' | 'starting' | 'ready' | 'unsupported' | 'running';
|
|
34
|
+
/**
|
|
35
|
+
* The button's label and enabled state.
|
|
36
|
+
*
|
|
37
|
+
* @param phase - the probe's answer and whether a login is in flight.
|
|
38
|
+
* @param hasCountdown - whether a countdown is being shown. Unused by the
|
|
39
|
+
* label, which names the action rather than the remaining time — the
|
|
40
|
+
* countdown sits above the button where it can be read without the label
|
|
41
|
+
* changing under the pointer. Kept in the signature so callers pass the same
|
|
42
|
+
* pair the render does, and so a future state that does depend on it has
|
|
43
|
+
* somewhere to say so.
|
|
44
|
+
* @returns the label key and whether the button is disabled.
|
|
45
|
+
*/
|
|
46
|
+
export declare function browserButton(phase: LoginPhase, hasCountdown: boolean): BrowserButtonState;
|
|
47
|
+
/**
|
|
48
|
+
* Render a countdown as `m:ss`.
|
|
49
|
+
*
|
|
50
|
+
* Language-neutral on purpose: the sentence around it is localised, and a
|
|
51
|
+
* number with a colon needs no translation — spelling out a unit would put a
|
|
52
|
+
* second copy of it in both dictionaries for no gain. Tabular figures are
|
|
53
|
+
* applied at the call site so the digits do not jitter as they change.
|
|
54
|
+
*
|
|
55
|
+
* @param seconds - seconds remaining; negative reads as zero.
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatCountdown(seconds: number): string;
|
|
58
|
+
//# sourceMappingURL=card-state.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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
-
* ##
|
|
9
|
+
* ## One way the form comes up
|
|
11
10
|
*
|
|
12
|
-
*
|
|
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
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
|
37
|
-
*
|
|
38
|
-
*
|
|
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
|
-
*
|
|
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
|
-
/**
|
|
40
|
+
/** Opens and closes the form on the composer's pending interaction. */
|
|
55
41
|
export interface CredentialFormVisibility {
|
|
56
42
|
/**
|
|
57
|
-
*
|
|
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
|
|
70
|
-
*
|
|
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
|
|
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
|
|
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,24 +13,39 @@ 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': "
|
|
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
|
-
readonly 'form.
|
|
23
|
+
readonly 'form.title': "华为云 IAM 认证";
|
|
24
|
+
readonly 'form.or': "或者";
|
|
25
|
+
readonly 'form.signedIn': "已登录";
|
|
26
|
+
readonly 'form.logout': "退出";
|
|
27
|
+
readonly 'form.browser.section': "选项一:浏览器登录";
|
|
28
|
+
readonly 'form.browser.action': "登录";
|
|
29
|
+
readonly 'form.browser.checking': "环境检测中…";
|
|
30
|
+
readonly 'form.browser.unsupported': "当前环境不支持该方式。";
|
|
31
|
+
readonly 'form.browser.unsupportedLabel': "不支持";
|
|
32
|
+
readonly 'form.browser.cancelLabel': "取消登录";
|
|
33
|
+
readonly 'form.browser.running': "登录中({time})";
|
|
34
|
+
readonly 'form.browser.notOpened': "若浏览器未自动打开,请";
|
|
35
|
+
readonly 'form.browser.copyLink': "手动复制链接到浏览器打开";
|
|
36
|
+
readonly 'form.browser.blocked': "浏览器拦截了新标签页,请允许弹出窗口后重试。";
|
|
37
|
+
readonly 'form.browser.copyFailed': "无法复制链接,请手动从浏览器地址栏重试。";
|
|
38
|
+
readonly 'form.browser.failed': "浏览器登录未完成。";
|
|
39
|
+
readonly 'form.browser.startFailed': "无法启动浏览器登录,请改用 AK/SK 或稍后重试。";
|
|
40
|
+
readonly 'form.browser.expired': "登录超时,请重试。";
|
|
41
|
+
readonly 'form.manual.section': "选项二:配置 AK/SK";
|
|
42
|
+
readonly 'form.prefilledFromEnv': "已填入检测到的环境变量";
|
|
25
43
|
readonly 'form.submit': "提交";
|
|
26
44
|
readonly 'form.dismiss': "取消";
|
|
27
45
|
readonly 'form.failed': "保存凭据失败";
|
|
28
|
-
readonly 'form.clear': "清除";
|
|
29
46
|
readonly 'form.clearing': "清除中…";
|
|
30
47
|
readonly 'form.clear.failed': "清除凭据失败";
|
|
31
48
|
readonly 'error.unreachable': "无法连接宿主凭据服务:";
|
|
32
|
-
readonly 'error.clear.serverFailed': "本机凭据已清除,但服务端凭据未清除(HTTP {status})";
|
|
33
|
-
readonly 'error.clear.serverUnreachable': "本机凭据已清除,但无法连接 MCP 服务器清除服务端凭据:";
|
|
34
49
|
readonly 'section.field.accessKey': "Access Key";
|
|
35
50
|
readonly 'section.field.accessKey.placeholder': "华为云 Access Key";
|
|
36
51
|
readonly 'section.field.accessKey.hint': "Access Key 与 Secret Key 须同时填写,只填其一时不会保存。";
|
|
@@ -49,24 +64,39 @@ export declare const en: {
|
|
|
49
64
|
readonly 'mode.unavailable': "Mode unavailable";
|
|
50
65
|
readonly 'mode.readonly.hint': "Read-only — cloud queries only. Click for read-write";
|
|
51
66
|
readonly 'mode.readwrite.hint': "Read-write — cloud changes allowed. Click for read-only";
|
|
52
|
-
readonly 'mode.unavailable.hint': "Could not read the permission mode
|
|
67
|
+
readonly 'mode.unavailable.hint': "Could not read the permission mode; the toggle is unavailable";
|
|
53
68
|
readonly 'mode.switchToReadonly': "Switch to read-only mode";
|
|
54
69
|
readonly 'mode.switchToReadwrite': "Switch to read-write mode";
|
|
55
70
|
readonly 'section.credentials.hint.prefix': "Authenticate against Huawei Cloud IAM. Obtain temporary credentials from";
|
|
56
71
|
readonly 'section.credentials.hint.link': "API Explorer";
|
|
57
72
|
readonly 'section.credentials.hint.suffix': "and avoid permanent ones.";
|
|
58
73
|
readonly 'section.credentials.saving': "Saving…";
|
|
59
|
-
readonly 'form.title': "Huawei Cloud
|
|
60
|
-
readonly 'form.
|
|
74
|
+
readonly 'form.title': "Huawei Cloud IAM authentication";
|
|
75
|
+
readonly 'form.or': "or";
|
|
76
|
+
readonly 'form.signedIn': "Signed in";
|
|
77
|
+
readonly 'form.logout': "Logout";
|
|
78
|
+
readonly 'form.browser.section': "Option 1: sign in with a browser";
|
|
79
|
+
readonly 'form.browser.action': "Sign in";
|
|
80
|
+
readonly 'form.browser.checking': "Checking this environment…";
|
|
81
|
+
readonly 'form.browser.unsupported': "This environment does not support that method.";
|
|
82
|
+
readonly 'form.browser.unsupportedLabel': "Unsupported";
|
|
83
|
+
readonly 'form.browser.cancelLabel': "Cancel sign-in";
|
|
84
|
+
readonly 'form.browser.running': "Signing in ({time})";
|
|
85
|
+
readonly 'form.browser.notOpened': "If the browser did not open,";
|
|
86
|
+
readonly 'form.browser.copyLink': "copy the link into your browser";
|
|
87
|
+
readonly 'form.browser.blocked': "The browser blocked the new tab. Allow pop-ups for this page, then try again.";
|
|
88
|
+
readonly 'form.browser.copyFailed': "Could not copy the link. Try again from the browser address bar.";
|
|
89
|
+
readonly 'form.browser.failed': "The browser sign-in did not complete.";
|
|
90
|
+
readonly 'form.browser.startFailed': "Could not start the browser sign-in. Use an AK/SK instead, or try again.";
|
|
91
|
+
readonly 'form.browser.expired': "The sign-in timed out. Try again.";
|
|
92
|
+
readonly 'form.manual.section': "Option 2: configure an AK/SK";
|
|
93
|
+
readonly 'form.prefilledFromEnv': "Filled in from detected environment variables";
|
|
61
94
|
readonly 'form.submit': "Submit";
|
|
62
95
|
readonly 'form.dismiss': "Cancel";
|
|
63
96
|
readonly 'form.failed': "Could not save credentials";
|
|
64
|
-
readonly 'form.clear': "Clear";
|
|
65
97
|
readonly 'form.clearing': "Clearing…";
|
|
66
98
|
readonly 'form.clear.failed': "Could not clear credentials";
|
|
67
99
|
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: ";
|
|
70
100
|
readonly 'section.field.accessKey': "Access Key";
|
|
71
101
|
readonly 'section.field.accessKey.placeholder': "Huawei Access Key";
|
|
72
102
|
readonly 'section.field.accessKey.hint': "Access Key and Secret Key are stored as a pair; one without the other is not saved.";
|