@huaweidevtools/aishell-dsh-client-credentials 0.0.1-beta.2 → 0.0.1-beta.4
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 +333 -542
- package/lib/index.js +528 -121
- package/lib/types/auth-tool.d.ts +94 -0
- package/lib/types/client/AishellAccountHint.d.ts +10 -3
- package/lib/types/client/AishellHeroChip.d.ts +22 -11
- package/lib/types/client/CredentialFormInteraction.d.ts +4 -12
- package/lib/types/client/CredentialRequestForm.d.ts +53 -16
- package/lib/types/client/credential-form-visibility.d.ts +30 -17
- package/lib/types/client/credential-status.d.ts +5 -6
- package/lib/types/client/huawei-mark.d.ts +18 -6
- package/lib/types/client/index.d.ts +9 -5
- package/lib/types/client/locales.d.ts +14 -14
- 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 +13 -50
- package/lib/types/reconcile.d.ts +80 -0
- package/package.json +17 -14
- package/lib/types/client/AishellCredentialsSection.d.ts +0 -34
- package/lib/types/client/open-settings.d.ts +0 -27
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
/**
|
|
88
|
+
* Register the `auth` tool on the host's tool registry.
|
|
89
|
+
*
|
|
90
|
+
* @param ctx - host context.
|
|
91
|
+
* @param store - the credential store this package owns.
|
|
92
|
+
*/
|
|
93
|
+
export declare function registerAuthTool(ctx: Context, store: CredentialsStore, deps: AuthToolDeps): void;
|
|
94
|
+
//# sourceMappingURL=auth-tool.d.ts.map
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Account hint chip rendered under the composer — shows the account name the
|
|
3
3
|
* Host's IAM verification wrote, so the user can see at a glance which account
|
|
4
|
-
* their chat is signed as
|
|
4
|
+
* their chat is signed as.
|
|
5
5
|
*
|
|
6
6
|
* Reads the non-secret `accessKeyIdHint` through the shared `credentials`
|
|
7
7
|
* hooks compartment (a snapshot store the browser half derives from the Host
|
|
8
8
|
* entry's config snapshot) — the full AK never reaches the browser. When no
|
|
9
|
-
* credentials are stored, a muted "
|
|
9
|
+
* credentials are stored, a muted "未配置凭据" prompt takes the
|
|
10
10
|
* chip's place so the user knows to set up credentials before chatting.
|
|
11
11
|
*
|
|
12
|
+
* Clicking either posture opens the credential form in this conversation —
|
|
13
|
+
* the same surface a blocked tool call brings up.
|
|
14
|
+
*
|
|
12
15
|
* Layout note: the host renders this entry and ContextMeter (the "N turns /
|
|
13
16
|
* N steps" readout) as siblings inside one block-flow dock container. We
|
|
14
17
|
* promote that container to a flex row with `space-between` via a layout
|
|
@@ -19,6 +22,8 @@ import { type ReactNode } from 'react';
|
|
|
19
22
|
import type { InjectFace, PropsRuntime, PropsLocale, TranslateNS } from '@deepseek-ai/dsh-client-ui-slots';
|
|
20
23
|
import type { CredentialStatus } from './credential-status.ts';
|
|
21
24
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
25
|
+
/** The chip-facing open callback shape (ctx already bound in apply). */
|
|
26
|
+
export type OpenCredentialFormCallback = () => void;
|
|
22
27
|
/** Injected handle bound in apply(). */
|
|
23
28
|
export interface AishellAccountHintInjected {
|
|
24
29
|
hooks: {
|
|
@@ -26,13 +31,15 @@ export interface AishellAccountHintInjected {
|
|
|
26
31
|
credentials: SnapshotStore<CredentialStatus>;
|
|
27
32
|
};
|
|
28
33
|
t: TranslateNS<'aishell'>;
|
|
34
|
+
/** Opens the credential form in this conversation (no-op if already up). */
|
|
35
|
+
openCredentialForm: OpenCredentialFormCallback;
|
|
29
36
|
}
|
|
30
37
|
/** Full component props: dock owner share + locale seat + inject face. */
|
|
31
38
|
export type AishellAccountHintProps = PropsRuntime<'conversation.composer.dock'> & PropsLocale<'aishell'> & InjectFace<AishellAccountHintInjected>;
|
|
32
39
|
/**
|
|
33
40
|
* Render the current account hint, or a setup prompt when credentials are
|
|
34
41
|
* absent. The hooks-compartment subscription keeps the chip live: saving
|
|
35
|
-
* credentials in
|
|
42
|
+
* credentials in the form publishes a new snapshot through the shared store,
|
|
36
43
|
* and the chip updates in place without a remount — the prompt disappears
|
|
37
44
|
* the moment a hint lands.
|
|
38
45
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Compact account + permission chip for the New-Session hero
|
|
2
|
+
* Compact account + permission chip for the New-Session hero.
|
|
3
3
|
*
|
|
4
4
|
* The composer chip lives under the input bar, which DSH does not render until
|
|
5
5
|
* a session exists — its slot is guarded by `variant === "composer" && input
|
|
@@ -7,21 +7,29 @@
|
|
|
7
7
|
* neither the account nor the permission mode, which are exactly the two facts
|
|
8
8
|
* worth checking before sending the first message.
|
|
9
9
|
*
|
|
10
|
-
* This renders into `conversation.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* This renders into `conversation.input.dock`, the band between the hero
|
|
11
|
+
* workspace row and the input card. That band is a `list` slot, chosen over
|
|
12
|
+
* the hero row's `single` seats precisely because both of those are held by
|
|
13
|
+
* official occupants on 0.2.1-alpha.1 — ui-workspace's WorkspacePicker in
|
|
14
|
+
* `conversation.hero.workspace` (shadowing it by `priority: -1` is what
|
|
15
|
+
* silently killed the workspace menu) and ui-agent-preset's seat in
|
|
16
|
+
* `conversation.hero.agentPreset`. A `list` entry composes beside the others
|
|
17
|
+
* (the TodoPanel precedent) instead of competing for a seat, so it cannot
|
|
18
|
+
* collide with an occupant however the base evolves.
|
|
19
|
+
*
|
|
20
|
+
* The dock band renders in BOTH the hero and the session composer (it only
|
|
21
|
+
* needs a live input zone), while the composer-dock chip covers the session
|
|
22
|
+
* posture — so this entry gates itself on `session.blank` and renders nothing
|
|
23
|
+
* once a conversation exists, keeping exactly one chip on screen at a time.
|
|
17
24
|
*
|
|
18
25
|
* ## Relationship to the composer chip
|
|
19
26
|
*
|
|
20
27
|
* Both chips report the same two facts — which account the session is signed
|
|
21
28
|
* as, and whether mutations are allowed — and a person should not have to
|
|
22
29
|
* learn two shapes. They carry the same mark, the same colour pair, and the
|
|
23
|
-
* same two affordances (open
|
|
24
|
-
*
|
|
30
|
+
* same two affordances (open the credential form, toggle the mode); they
|
|
31
|
+
* differ only in the
|
|
32
|
+
* width each surface affords, which is why this chip clamps the
|
|
25
33
|
* account name with `maxWidth` instead of letting it run to the row's edge.
|
|
26
34
|
*
|
|
27
35
|
* @module @huaweidevtools/aishell-dsh-client-credentials/client/AishellHeroChip
|
|
@@ -30,14 +38,17 @@ import { type ReactNode } from 'react';
|
|
|
30
38
|
import type { InjectFace, PropsRuntime, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
31
39
|
import type { CredentialStatus } from './credential-status.ts';
|
|
32
40
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
41
|
+
import type { OpenCredentialFormCallback } from './AishellAccountHint.tsx';
|
|
33
42
|
/** Injected handle bound in apply(). */
|
|
34
43
|
export interface AishellHeroChipInjected {
|
|
35
44
|
hooks: {
|
|
36
45
|
/** Credential presence + account hint, rebound by the renderer as useCredentials. */
|
|
37
46
|
credentials: SnapshotStore<CredentialStatus>;
|
|
38
47
|
};
|
|
48
|
+
/** Opens the credential form in this conversation (no-op if already up). */
|
|
49
|
+
openCredentialForm: OpenCredentialFormCallback;
|
|
39
50
|
}
|
|
40
51
|
/** Full component props: slot owner share + locale seat + inject face. */
|
|
41
|
-
export type AishellHeroChipProps = PropsRuntime<'conversation.
|
|
52
|
+
export type AishellHeroChipProps = PropsRuntime<'conversation.input.dock'> & PropsLocale<'aishell'> & InjectFace<AishellHeroChipInjected>;
|
|
42
53
|
export declare function AishellHeroChip(props: AishellHeroChipProps): ReactNode;
|
|
43
54
|
//# sourceMappingURL=AishellHeroChip.d.ts.map
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* `conversation.composer` is a `chain` slot whose `select` receives the
|
|
5
5
|
* session's `pendingInteraction`, so a component can only take the composer
|
|
6
6
|
* over by publishing one. This is that object: it marks the form as the
|
|
7
|
-
* session's live interaction
|
|
7
|
+
* session's live interaction, whether the form is up because a Host request
|
|
8
|
+
* is waiting or because a chip opened it directly.
|
|
8
9
|
*
|
|
9
10
|
* Modelled on `dsh-client-ui-approval`'s `PendingApproval`: a request that
|
|
10
11
|
* outlives a render needs an identity the framework can key on (`key`), and a
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
*/
|
|
17
18
|
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
18
19
|
/**
|
|
19
|
-
* One presentation of
|
|
20
|
+
* One presentation of the credential form.
|
|
20
21
|
*
|
|
21
22
|
* The `key` is opaque to the framework and only has to change when the
|
|
22
23
|
* presentation must remount; `kind` is this domain's own discriminator, which
|
|
@@ -25,7 +26,7 @@ import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
|
25
26
|
* An interface plus a factory rather than a class: the browser half is
|
|
26
27
|
* compiled by oxc, and class syntax in that half has already tripped a
|
|
27
28
|
* compiler panic once (see `credential-form-visibility.ts`). A plain object
|
|
28
|
-
* carries the same
|
|
29
|
+
* carries the same three fields.
|
|
29
30
|
*/
|
|
30
31
|
export interface CredentialFormInteraction {
|
|
31
32
|
/** Domain discriminator, for consumers that switch on interaction kind. */
|
|
@@ -55,13 +56,4 @@ export declare function credentialFormInteraction(sessionId: string): Credential
|
|
|
55
56
|
* @param value - the session's pending interaction, or `undefined`.
|
|
56
57
|
*/
|
|
57
58
|
export declare function isCredentialForm(value: unknown): value is CredentialFormInteraction;
|
|
58
|
-
/**
|
|
59
|
-
* Route the Host exposes to abandon a pending credential request.
|
|
60
|
-
*
|
|
61
|
-
* Sits with the other credential routes: `clear`, `reset`, and this one all end
|
|
62
|
-
* a credential state, and keeping them together is what makes the route table
|
|
63
|
-
* readable. Without it a person who does not want to enter credentials would
|
|
64
|
-
* leave the blocked tool call waiting until the turn ended.
|
|
65
|
-
*/
|
|
66
|
-
export declare const DISMISS_ROUTE = "api/aishell/credentials/dismiss";
|
|
67
59
|
//# sourceMappingURL=CredentialFormInteraction.d.ts.map
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The credential form
|
|
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.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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.
|
|
7
|
+
*
|
|
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.
|
|
10
16
|
*
|
|
11
17
|
* ## Why the composer and not a modal
|
|
12
18
|
*
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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.
|
|
17
23
|
*
|
|
18
24
|
* ## Why masked inputs are not optional
|
|
19
25
|
*
|
|
@@ -26,22 +32,53 @@
|
|
|
26
32
|
*/
|
|
27
33
|
import { type ReactNode } from 'react';
|
|
28
34
|
import type { InjectFace, PropsRuntime, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
29
|
-
import {
|
|
35
|
+
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
36
|
+
import { type CredentialStatus, type SaveVerdict } from './credential-status.ts';
|
|
37
|
+
import type { CredentialFormInteraction } from './CredentialFormInteraction.ts';
|
|
38
|
+
declare module '@deepseek-ai/dsh-client-ui-session/client' {
|
|
39
|
+
interface SessionPendingInteractionMap {
|
|
40
|
+
'aishell-credential-form': CredentialFormInteraction;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
30
43
|
/** Injected handle bound in apply(). */
|
|
31
44
|
export interface CredentialRequestFormInjected {
|
|
45
|
+
hooks: {
|
|
46
|
+
/** Credential presence + account hint, rebound by the renderer as useCredentials. */
|
|
47
|
+
credentials: SnapshotStore<CredentialStatus>;
|
|
48
|
+
};
|
|
32
49
|
/** Store AK/SK/SecurityToken through the Host credential route. */
|
|
33
50
|
save: (accessKeyId: string, secretAccessKey: string, securityToken?: string) => Promise<SaveVerdict>;
|
|
34
|
-
/**
|
|
35
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Clear the stored credentials.
|
|
53
|
+
*
|
|
54
|
+
* Only invoked from the clear button, which renders only when credentials
|
|
55
|
+
* already exist — there is nothing to clear otherwise.
|
|
56
|
+
*/
|
|
57
|
+
clear: () => Promise<SaveVerdict>;
|
|
58
|
+
/**
|
|
59
|
+
* Withdraw the form after saving — restores the ordinary composer.
|
|
60
|
+
*
|
|
61
|
+
* Used by the success path, where there is nothing to decline.
|
|
62
|
+
*/
|
|
63
|
+
close: () => void;
|
|
64
|
+
/**
|
|
65
|
+
* Decline: withdraw the form and tell the host this request was refused.
|
|
66
|
+
*
|
|
67
|
+
* The difference matters. Without it the host cannot tell "the person said
|
|
68
|
+
* no" from "the person has not answered", and a model whose call failed has
|
|
69
|
+
* every reason to ask again until the turn ends.
|
|
70
|
+
*/
|
|
71
|
+
cancel: () => void;
|
|
36
72
|
}
|
|
37
73
|
/** Full component props: composer owner share + locale seat + inject face. */
|
|
38
74
|
export type CredentialRequestFormProps = PropsRuntime<'conversation.composer'> & PropsLocale<'aishell'> & InjectFace<CredentialRequestFormInjected>;
|
|
39
75
|
/**
|
|
40
76
|
* The masked credential form.
|
|
41
77
|
*
|
|
42
|
-
* Submitting saves through the Host route; the
|
|
43
|
-
*
|
|
44
|
-
*
|
|
78
|
+
* Submitting saves through the Host route; the form then closes itself, and the
|
|
79
|
+
* chip flipping to the account name is the feedback that it worked. There is no
|
|
80
|
+
* request behind an open form — a chip opened it — so nothing else takes it
|
|
81
|
+
* down.
|
|
45
82
|
*/
|
|
46
83
|
export declare function CredentialRequestForm(props: CredentialRequestFormProps): ReactNode;
|
|
47
84
|
//# sourceMappingURL=CredentialRequestForm.d.ts.map
|
|
@@ -1,20 +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
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
9
|
+
* ## One way the form comes up
|
|
10
|
+
*
|
|
11
|
+
* A chip opens it. That is the whole model.
|
|
12
|
+
*
|
|
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.
|
|
19
|
+
*
|
|
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.
|
|
13
25
|
*
|
|
14
26
|
* ## Why a closure and not a class
|
|
15
27
|
*
|
|
16
|
-
* Written as a factory because the browser half is compiled by oxc, and a
|
|
17
|
-
*
|
|
28
|
+
* Written as a factory because the browser half is compiled by oxc, and a class
|
|
29
|
+
* with private (`#`) fields makes that compiler panic
|
|
18
30
|
* (`oxc_transformer ... es2022/class_properties/class_details.rs:138:
|
|
19
31
|
* internal error: entered unreachable code`), which fails the CJS build and
|
|
20
32
|
* leaves `lib/client.js` unwritten — DSH then refuses to start. The state here
|
|
@@ -25,18 +37,19 @@
|
|
|
25
37
|
import { type CredentialFormInteraction } from './CredentialFormInteraction.ts';
|
|
26
38
|
/** Publishes one interaction and returns the function that withdraws it. */
|
|
27
39
|
export type PublishInteraction = (interaction: CredentialFormInteraction) => () => void;
|
|
28
|
-
/**
|
|
40
|
+
/** Opens and closes the form on the composer's pending interaction. */
|
|
29
41
|
export interface CredentialFormVisibility {
|
|
30
42
|
/**
|
|
31
|
-
*
|
|
43
|
+
* Open the form for one session.
|
|
32
44
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* what the person 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.
|
|
36
47
|
*
|
|
37
|
-
* @param sessionId - the
|
|
48
|
+
* @param sessionId - the conversation the form renders in.
|
|
38
49
|
*/
|
|
39
|
-
readonly
|
|
50
|
+
readonly open: (sessionId: string) => void;
|
|
51
|
+
/** Withdraw the open form, if any, restoring the ordinary composer. */
|
|
52
|
+
readonly close: () => void;
|
|
40
53
|
/** The interaction currently published, if any. For tests and diagnostics. */
|
|
41
54
|
readonly current: () => CredentialFormInteraction | undefined;
|
|
42
55
|
/** Withdraw any open form. Called when the plugin fiber is disposed. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Credential vocabulary shared by the
|
|
2
|
+
* Credential vocabulary shared by the surfaces that collect a credential.
|
|
3
3
|
*
|
|
4
4
|
* This module holds the parts of the credential UI that are not one component's
|
|
5
5
|
* presentation: the presence descriptor the Host reports, the verdict its route
|
|
@@ -9,11 +9,10 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Four modules need these, and every one of them used to reach into
|
|
11
11
|
* `AishellCredentialsSection.tsx` for them — two chips and the composer form
|
|
12
|
-
* importing from a component they do not render. That file is
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* the second consumer is when the shared part earns its own module.
|
|
12
|
+
* importing from a component they do not render. That file is gone now (the
|
|
13
|
+
* form replaced it), and the shared contract stays here: a module neither the
|
|
14
|
+
* form nor the chips owns. Same reasoning as `huawei-mark.ts`: the second
|
|
15
|
+
* consumer is when the shared part earns its own module.
|
|
17
16
|
*
|
|
18
17
|
* The paragraph that follows each is the contract the Host half implements; it
|
|
19
18
|
* is stated here because this file is now where both sides read it.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module @huaweidevtools/aishell-dsh-client-credentials/client/huawei-mark
|
|
9
9
|
*/
|
|
10
|
+
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
10
11
|
/** Huawei logo path (from simple-icons/huawei), drawn in a 24×24 viewBox. */
|
|
11
12
|
export declare 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";
|
|
12
13
|
/**
|
|
@@ -26,12 +27,23 @@ export declare const HUAWEI_RED = "rgb(207, 10, 44)";
|
|
|
26
27
|
*/
|
|
27
28
|
export declare const CHIP_CLASS = "aishell-account-hint";
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
+
* Mount the chips' hover/focus rule for the owning plugin's lifetime.
|
|
30
31
|
*
|
|
31
|
-
* The
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* The shape follows `dsh-client-ui-theme`'s `installThemeStyles`, which is the
|
|
33
|
+
* framework's own answer for runtime-authored CSS: one `ctx.effect` per sheet,
|
|
34
|
+
* a disposer that removes the tag, and the `data-plugin` markers so
|
|
35
|
+
* `removeOwnedStyles` can also reach it. The disposer is what makes a reload
|
|
36
|
+
* pick up an edited rule — the fiber tears down, the tag goes, and the next
|
|
37
|
+
* materialization writes the new text. A module-level install with an id guard
|
|
38
|
+
* fails exactly there: the tag outlives the module (the loader only sweeps
|
|
39
|
+
* `data-plugin` tags), the guard then sees it and returns, and the old CSS
|
|
40
|
+
* stays in force for the life of the page.
|
|
41
|
+
*
|
|
42
|
+
* Call once from `apply()`, not from the components: the rule is shared by
|
|
43
|
+
* both chips (they carry the same `CHIP_CLASS`), so one sheet serves them and
|
|
44
|
+
* two installers would fight over the same dedupe key.
|
|
45
|
+
*
|
|
46
|
+
* @param ctx - the browser-half plugin context whose effect owns the tag.
|
|
35
47
|
*/
|
|
36
|
-
export declare function
|
|
48
|
+
export declare function installChipStyles(ctx: ClientContext): void;
|
|
37
49
|
//# sourceMappingURL=huawei-mark.d.ts.map
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser-half entry:
|
|
3
|
-
* web Settings page, plus the account hint chip under the composer.
|
|
2
|
+
* Browser-half entry: the credential form, plus the account hint chips.
|
|
4
3
|
*
|
|
5
|
-
* Secrets never travel through the settings document. The
|
|
4
|
+
* Secrets never travel through the settings document. The form POSTs the
|
|
6
5
|
* plaintext to the Host's authenticated credential route
|
|
7
6
|
* (`api/aishell/credentials`), where it is verified against Huawei Cloud IAM
|
|
8
7
|
* and transferred into the credential store; the route answers with the
|
|
9
8
|
* verdict in the same round trip. Only the non-secret presence flag and the
|
|
10
|
-
* verified account name come back through `ctx.configForms`, which the
|
|
11
|
-
* and the
|
|
9
|
+
* verified account name come back through `ctx.configForms`, which the chips
|
|
10
|
+
* and the form read.
|
|
11
|
+
*
|
|
12
|
+
* There is no Settings section any more: the form is the one credential
|
|
13
|
+
* surface, opened either by a chip click (the visibility state machine's
|
|
14
|
+
* manual posture) or by a tool call blocked on credentials (the Host-mirrored
|
|
15
|
+
* posture). Both render the same component in `conversation.composer`.
|
|
12
16
|
*
|
|
13
17
|
* @module @huaweidevtools/aishell-dsh-client-credentials/client
|
|
14
18
|
*/
|
|
@@ -7,28 +7,28 @@
|
|
|
7
7
|
export declare const NS: "aishell";
|
|
8
8
|
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
9
9
|
export declare const zh: {
|
|
10
|
-
readonly 'account.unconfigured': "
|
|
10
|
+
readonly 'account.unconfigured': "未配置凭据";
|
|
11
11
|
readonly 'mode.readonly': "只读";
|
|
12
12
|
readonly 'mode.readwrite': "读写";
|
|
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
|
-
readonly 'section.settings.summary': "华为云 AI Shell 设置。";
|
|
20
|
-
readonly 'section.credentials.title': "凭据";
|
|
21
19
|
readonly 'section.credentials.hint.prefix': "需要进行华为云 IAM 认证,建议从";
|
|
22
20
|
readonly 'section.credentials.hint.link': "API Explorer";
|
|
23
21
|
readonly 'section.credentials.hint.suffix': "获取临时凭据,避免使用永久凭据。";
|
|
24
|
-
readonly 'section.credentials.saved': "校验通过,已存入 keyring。";
|
|
25
|
-
readonly 'section.credentials.save': "保存";
|
|
26
22
|
readonly 'section.credentials.saving': "保存中…";
|
|
27
|
-
readonly 'section.credentials.clear': "清除";
|
|
28
23
|
readonly 'form.title': "需要华为云凭据";
|
|
24
|
+
readonly 'form.title.manual': "配置华为云凭据";
|
|
29
25
|
readonly 'form.submit': "提交";
|
|
30
26
|
readonly 'form.dismiss': "取消";
|
|
31
27
|
readonly 'form.failed': "保存凭据失败";
|
|
28
|
+
readonly 'form.clear': "清除";
|
|
29
|
+
readonly 'form.clearing': "清除中…";
|
|
30
|
+
readonly 'form.clear.failed': "清除凭据失败";
|
|
31
|
+
readonly 'error.unreachable': "无法连接宿主凭据服务:";
|
|
32
32
|
readonly 'section.field.accessKey': "Access Key";
|
|
33
33
|
readonly 'section.field.accessKey.placeholder': "华为云 Access Key";
|
|
34
34
|
readonly 'section.field.accessKey.hint': "Access Key 与 Secret Key 须同时填写,只填其一时不会保存。";
|
|
@@ -41,28 +41,28 @@ export declare const zh: {
|
|
|
41
41
|
};
|
|
42
42
|
/** English dictionary. */
|
|
43
43
|
export declare const en: {
|
|
44
|
-
readonly 'account.unconfigured': "No
|
|
44
|
+
readonly 'account.unconfigured': "No credentials";
|
|
45
45
|
readonly 'mode.readonly': "Read-only";
|
|
46
46
|
readonly 'mode.readwrite': "Read-write";
|
|
47
47
|
readonly 'mode.unavailable': "Mode unavailable";
|
|
48
48
|
readonly 'mode.readonly.hint': "Read-only — cloud queries only. Click for read-write";
|
|
49
49
|
readonly 'mode.readwrite.hint': "Read-write — cloud changes allowed. Click for read-only";
|
|
50
|
-
readonly 'mode.unavailable.hint': "Could not read the permission mode
|
|
50
|
+
readonly 'mode.unavailable.hint': "Could not read the permission mode; the toggle is unavailable";
|
|
51
51
|
readonly 'mode.switchToReadonly': "Switch to read-only mode";
|
|
52
52
|
readonly 'mode.switchToReadwrite': "Switch to read-write mode";
|
|
53
|
-
readonly 'section.settings.summary': "Huawei Cloud AI Shell settings.";
|
|
54
|
-
readonly 'section.credentials.title': "Credentials";
|
|
55
53
|
readonly 'section.credentials.hint.prefix': "Authenticate against Huawei Cloud IAM. Obtain temporary credentials from";
|
|
56
54
|
readonly 'section.credentials.hint.link': "API Explorer";
|
|
57
55
|
readonly 'section.credentials.hint.suffix': "and avoid permanent ones.";
|
|
58
|
-
readonly 'section.credentials.saved': "Verified and saved to keyring.";
|
|
59
|
-
readonly 'section.credentials.save': "Save";
|
|
60
56
|
readonly 'section.credentials.saving': "Saving…";
|
|
61
|
-
readonly 'section.credentials.clear': "Clear";
|
|
62
57
|
readonly 'form.title': "Huawei Cloud credentials required";
|
|
58
|
+
readonly 'form.title.manual': "Configure Huawei Cloud credentials";
|
|
63
59
|
readonly 'form.submit': "Submit";
|
|
64
60
|
readonly 'form.dismiss': "Cancel";
|
|
65
61
|
readonly 'form.failed': "Could not save credentials";
|
|
62
|
+
readonly 'form.clear': "Clear";
|
|
63
|
+
readonly 'form.clearing': "Clearing…";
|
|
64
|
+
readonly 'form.clear.failed': "Could not clear credentials";
|
|
65
|
+
readonly 'error.unreachable': "Could not reach the host credential service: ";
|
|
66
66
|
readonly 'section.field.accessKey': "Access Key";
|
|
67
67
|
readonly 'section.field.accessKey.placeholder': "Huawei Access Key";
|
|
68
68
|
readonly 'section.field.accessKey.hint': "Access Key and Secret Key are stored as a pair; one without the other is not saved.";
|
|
@@ -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
|
|
5
|
-
* it
|
|
6
|
-
*
|
|
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
|
*/
|