@huaweidevtools/aishell-dsh-client-credentials 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +231 -487
- package/lib/index.js +119 -34
- package/lib/types/client/AishellAccountHint.d.ts +10 -3
- package/lib/types/client/AishellHeroChip.d.ts +6 -2
- package/lib/types/client/CredentialFormInteraction.d.ts +12 -3
- package/lib/types/client/CredentialRequestForm.d.ts +46 -12
- package/lib/types/client/credential-form-visibility.d.ts +50 -4
- 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 +16 -12
- package/lib/types/reconcile.d.ts +88 -0
- package/package.json +15 -15
- package/lib/types/client/AishellCredentialsSection.d.ts +0 -34
- package/lib/types/client/open-settings.d.ts +0 -27
package/lib/index.js
CHANGED
|
@@ -893,6 +893,73 @@ defineMethod("transform", [
|
|
|
893
893
|
"preserve"
|
|
894
894
|
], ({ inner }, isInner) => inner.toString(isInner));
|
|
895
895
|
|
|
896
|
+
//#endregion
|
|
897
|
+
//#region src/reconcile.ts
|
|
898
|
+
/**
|
|
899
|
+
* Build the reconcile state machine.
|
|
900
|
+
*
|
|
901
|
+
* Two facts are reconciled independently, because they are independent:
|
|
902
|
+
* - `credentialsStored` — are AK/SK in the store right now?
|
|
903
|
+
* - `accessKeyIdHint` — what account name did IAM verification return?
|
|
904
|
+
*
|
|
905
|
+
* The hint is re-derived only when the credential material changed since the
|
|
906
|
+
* last verification. That single trigger covers both reasons to re-verify — a
|
|
907
|
+
* first-seen credential (the material has never been fingerprinted) and a
|
|
908
|
+
* rotation (the material differs from the last verified set) — and it keeps a
|
|
909
|
+
* failing verification (expired STS, IAM outage) from retrying every tick: the
|
|
910
|
+
* retry keys on the material changing, not on time alone, and a failed verify
|
|
911
|
+
* still records the fingerprint. Cleared by `resetVerifyBaseline` so a
|
|
912
|
+
* clear-then-rotate re-verifies from scratch.
|
|
913
|
+
*
|
|
914
|
+
* @param deps - collaborators. `readStored`/`readHint` read this plugin's own
|
|
915
|
+
* mirror so reconcile never depends on config flow-back timing.
|
|
916
|
+
*/
|
|
917
|
+
function createCredentialReconciler(deps) {
|
|
918
|
+
const { store, verify, recordStatus, readStored, readHint, accounts } = deps;
|
|
919
|
+
let lastVerifyFingerprint = "";
|
|
920
|
+
const materialFingerprint = (ak, sk, token) => `${ak}\n${sk}\n${token ?? ""}`;
|
|
921
|
+
return {
|
|
922
|
+
reconcile: () => {
|
|
923
|
+
const ak = store.get(accounts.accessKey);
|
|
924
|
+
const sk = store.get(accounts.secretKey);
|
|
925
|
+
const haveKeys = Boolean(ak && sk);
|
|
926
|
+
const stored = readStored();
|
|
927
|
+
const hint = readHint();
|
|
928
|
+
if (!haveKeys && (stored || hint !== null)) recordStatus([{
|
|
929
|
+
op: "set",
|
|
930
|
+
path: ["credentialsStored"],
|
|
931
|
+
value: false
|
|
932
|
+
}, {
|
|
933
|
+
op: "unset",
|
|
934
|
+
path: ["accessKeyIdHint"]
|
|
935
|
+
}]);
|
|
936
|
+
else if (haveKeys && !stored) recordStatus([{
|
|
937
|
+
op: "set",
|
|
938
|
+
path: ["credentialsStored"],
|
|
939
|
+
value: true
|
|
940
|
+
}]);
|
|
941
|
+
if (!haveKeys) return;
|
|
942
|
+
const token = store.get(accounts.securityToken);
|
|
943
|
+
const fingerprint = materialFingerprint(ak, sk, token);
|
|
944
|
+
const materialChanged = fingerprint !== lastVerifyFingerprint;
|
|
945
|
+
if (!materialChanged) return;
|
|
946
|
+
lastVerifyFingerprint = fingerprint;
|
|
947
|
+
verify(ak, sk, token).then((accountName) => {
|
|
948
|
+
if (store.get(accounts.accessKey) !== ak) return;
|
|
949
|
+
if (store.get(accounts.secretKey) !== sk) return;
|
|
950
|
+
recordStatus([{
|
|
951
|
+
op: "set",
|
|
952
|
+
path: ["accessKeyIdHint"],
|
|
953
|
+
value: accountName
|
|
954
|
+
}]);
|
|
955
|
+
}).catch(() => {});
|
|
956
|
+
},
|
|
957
|
+
resetVerifyBaseline: () => {
|
|
958
|
+
lastVerifyFingerprint = "";
|
|
959
|
+
}
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
|
|
896
963
|
//#endregion
|
|
897
964
|
//#region src/index.ts
|
|
898
965
|
/**
|
|
@@ -921,7 +988,7 @@ const CLEAR_PATH = "/api/aishell/credentials/clear";
|
|
|
921
988
|
*
|
|
922
989
|
* Separate from `clear`: clearing removes stored credentials, while this ends a
|
|
923
990
|
* request without touching the store — a person who already has credentials for
|
|
924
|
-
* something else, or who would rather
|
|
991
|
+
* something else, or who would rather fill them in later, must be able to
|
|
925
992
|
* say "not now" without wiping anything.
|
|
926
993
|
*/
|
|
927
994
|
const DISMISS_PATH = "/api/aishell/credentials/dismiss";
|
|
@@ -1087,10 +1154,33 @@ const inject = ["settings", "connection"];
|
|
|
1087
1154
|
function apply(ctx, config) {
|
|
1088
1155
|
const store = createCredentialsStore();
|
|
1089
1156
|
const ns = ctx.fiber.entry?.options.id;
|
|
1090
|
-
|
|
1157
|
+
let recordedStored = config.credentialsStored.get() === true;
|
|
1158
|
+
let recordedHint = config.accessKeyIdHint.get() || null;
|
|
1159
|
+
/** Apply one batch of ops to the mirror. */
|
|
1160
|
+
const mirrorOps = (ops) => {
|
|
1161
|
+
for (const op of ops) if (op.path[0] === "credentialsStored") recordedStored = op.op === "set" && op.value === true;
|
|
1162
|
+
else if (op.path[0] === "accessKeyIdHint") recordedHint = op.op === "set" && typeof op.value === "string" && op.value.length > 0 ? op.value : null;
|
|
1163
|
+
};
|
|
1164
|
+
/** Record the non-secret status the browser half reads; a refused write is rolled back. */
|
|
1091
1165
|
const recordStatus = (ops) => {
|
|
1092
|
-
if (ns === void 0)
|
|
1166
|
+
if (ns === void 0) {
|
|
1167
|
+
mirrorOps(ops);
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
const before = {
|
|
1171
|
+
stored: recordedStored,
|
|
1172
|
+
hint: recordedHint
|
|
1173
|
+
};
|
|
1174
|
+
mirrorOps(ops);
|
|
1175
|
+
const after = {
|
|
1176
|
+
stored: recordedStored,
|
|
1177
|
+
hint: recordedHint
|
|
1178
|
+
};
|
|
1093
1179
|
ctx.settings.mutate(ns, ops).catch((error) => {
|
|
1180
|
+
if (recordedStored === after.stored && recordedHint === after.hint) {
|
|
1181
|
+
recordedStored = before.stored;
|
|
1182
|
+
recordedHint = before.hint;
|
|
1183
|
+
}
|
|
1094
1184
|
ctx.logger.warn(error);
|
|
1095
1185
|
});
|
|
1096
1186
|
};
|
|
@@ -1098,11 +1188,23 @@ function apply(ctx, config) {
|
|
|
1098
1188
|
store,
|
|
1099
1189
|
verify: verifyCredentials,
|
|
1100
1190
|
recordStatus,
|
|
1101
|
-
hint: () =>
|
|
1191
|
+
hint: () => recordedHint ?? "",
|
|
1102
1192
|
notifyChanged: () => {
|
|
1103
1193
|
ctx.emit("aishell/credentials-updated");
|
|
1104
1194
|
}
|
|
1105
1195
|
});
|
|
1196
|
+
const reconciler = createCredentialReconciler({
|
|
1197
|
+
store,
|
|
1198
|
+
verify: verifyCredentials,
|
|
1199
|
+
recordStatus,
|
|
1200
|
+
readStored: () => recordedStored,
|
|
1201
|
+
readHint: () => recordedHint,
|
|
1202
|
+
accounts: {
|
|
1203
|
+
accessKey: AK_ACCOUNT,
|
|
1204
|
+
secretKey: SK_ACCOUNT,
|
|
1205
|
+
securityToken: TOKEN_ACCOUNT
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1106
1208
|
let settlePrompt;
|
|
1107
1209
|
/**
|
|
1108
1210
|
* End the open form, if any: clear the flag the browser renders from and
|
|
@@ -1132,13 +1234,13 @@ function apply(ctx, config) {
|
|
|
1132
1234
|
}), "aishell-credentials: credential form requests");
|
|
1133
1235
|
ctx.effect(() => ctx.on("aishell/credentials-updated", () => {
|
|
1134
1236
|
if (settlePrompt === void 0) return;
|
|
1135
|
-
const ak
|
|
1136
|
-
const sk
|
|
1137
|
-
if (!ak
|
|
1237
|
+
const ak = store.get(AK_ACCOUNT);
|
|
1238
|
+
const sk = store.get(SK_ACCOUNT);
|
|
1239
|
+
if (!ak || !sk) return;
|
|
1138
1240
|
const securityToken = store.get(TOKEN_ACCOUNT);
|
|
1139
1241
|
settleCredentialForm({
|
|
1140
|
-
ak
|
|
1141
|
-
sk
|
|
1242
|
+
ak,
|
|
1243
|
+
sk,
|
|
1142
1244
|
...securityToken === void 0 ? {} : { securityToken }
|
|
1143
1245
|
});
|
|
1144
1246
|
}), "aishell-credentials: resume the waiting call");
|
|
@@ -1146,13 +1248,16 @@ function apply(ctx, config) {
|
|
|
1146
1248
|
path: CREDENTIALS_PATH,
|
|
1147
1249
|
methods: ["GET", "POST"],
|
|
1148
1250
|
requestBody: "buffered",
|
|
1149
|
-
fetch: (request) => request.method === "GET" ? routes.get() : routes.save(request)
|
|
1251
|
+
fetch: (request) => request.method === "GET" ? (reconciler.reconcile(), routes.get()) : routes.save(request)
|
|
1150
1252
|
}), "aishell-credentials: credentials route");
|
|
1151
1253
|
ctx.effect(() => ctx.connection.fetch.register({
|
|
1152
1254
|
path: CLEAR_PATH,
|
|
1153
1255
|
methods: ["POST"],
|
|
1154
1256
|
requestBody: "buffered",
|
|
1155
|
-
fetch:
|
|
1257
|
+
fetch: () => {
|
|
1258
|
+
reconciler.resetVerifyBaseline();
|
|
1259
|
+
return routes.clear();
|
|
1260
|
+
}
|
|
1156
1261
|
}), "aishell-credentials: clear route");
|
|
1157
1262
|
ctx.effect(() => ctx.connection.fetch.register({
|
|
1158
1263
|
path: DISMISS_PATH,
|
|
@@ -1163,29 +1268,9 @@ function apply(ctx, config) {
|
|
|
1163
1268
|
return Promise.resolve(Response.json({ ok: true }));
|
|
1164
1269
|
}
|
|
1165
1270
|
}), "aishell-credentials: dismiss route");
|
|
1166
|
-
|
|
1167
|
-
const
|
|
1168
|
-
|
|
1169
|
-
if (stored && !(ak && sk)) recordStatus([{
|
|
1170
|
-
op: "set",
|
|
1171
|
-
path: ["credentialsStored"],
|
|
1172
|
-
value: false
|
|
1173
|
-
}, {
|
|
1174
|
-
op: "unset",
|
|
1175
|
-
path: ["accessKeyIdHint"]
|
|
1176
|
-
}]);
|
|
1177
|
-
else if (!stored && ak && sk) recordStatus([{
|
|
1178
|
-
op: "set",
|
|
1179
|
-
path: ["credentialsStored"],
|
|
1180
|
-
value: true
|
|
1181
|
-
}]);
|
|
1182
|
-
else if (ak && sk && config.accessKeyIdHint.get() === "") verifyCredentials(ak, sk, store.get(TOKEN_ACCOUNT)).then((accountName) => {
|
|
1183
|
-
recordStatus([{
|
|
1184
|
-
op: "set",
|
|
1185
|
-
path: ["accessKeyIdHint"],
|
|
1186
|
-
value: accountName
|
|
1187
|
-
}]);
|
|
1188
|
-
}).catch(() => {});
|
|
1271
|
+
reconciler.reconcile();
|
|
1272
|
+
const reconcileTimer = setInterval(reconciler.reconcile, 3e4);
|
|
1273
|
+
ctx.effect(() => () => clearInterval(reconcileTimer), "aishell-credentials: status reconcile timer");
|
|
1189
1274
|
ctx.effect(() => ctx.settings.configure({ auto: false }, ctx.fiber));
|
|
1190
1275
|
}
|
|
1191
1276
|
|
|
@@ -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 MCP 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
|
*
|
|
@@ -27,8 +27,9 @@
|
|
|
27
27
|
* Both chips report the same two facts — which account the session is signed
|
|
28
28
|
* as, and whether mutations are allowed — and a person should not have to
|
|
29
29
|
* learn two shapes. They carry the same mark, the same colour pair, and the
|
|
30
|
-
* same two affordances (open
|
|
31
|
-
*
|
|
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
|
|
32
33
|
* account name with `maxWidth` instead of letting it run to the row's edge.
|
|
33
34
|
*
|
|
34
35
|
* @module @huaweidevtools/aishell-dsh-client-credentials/client/AishellHeroChip
|
|
@@ -37,12 +38,15 @@ import { type ReactNode } from 'react';
|
|
|
37
38
|
import type { InjectFace, PropsRuntime, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
38
39
|
import type { CredentialStatus } from './credential-status.ts';
|
|
39
40
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
41
|
+
import type { OpenCredentialFormCallback } from './AishellAccountHint.tsx';
|
|
40
42
|
/** Injected handle bound in apply(). */
|
|
41
43
|
export interface AishellHeroChipInjected {
|
|
42
44
|
hooks: {
|
|
43
45
|
/** Credential presence + account hint, rebound by the renderer as useCredentials. */
|
|
44
46
|
credentials: SnapshotStore<CredentialStatus>;
|
|
45
47
|
};
|
|
48
|
+
/** Opens the credential form in this conversation (no-op if already up). */
|
|
49
|
+
openCredentialForm: OpenCredentialFormCallback;
|
|
46
50
|
}
|
|
47
51
|
/** Full component props: slot owner share + locale seat + inject face. */
|
|
48
52
|
export type AishellHeroChipProps = PropsRuntime<'conversation.input.dock'> & PropsLocale<'aishell'> & InjectFace<AishellHeroChipInjected>;
|
|
@@ -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
|
|
@@ -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. */
|
|
@@ -38,13 +39,21 @@ export interface CredentialFormInteraction {
|
|
|
38
39
|
* string; branded by a cast (see the import note).
|
|
39
40
|
*/
|
|
40
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;
|
|
41
49
|
}
|
|
42
50
|
/**
|
|
43
51
|
* Build an interaction for one session.
|
|
44
52
|
*
|
|
45
53
|
* @param sessionId - the conversation the form belongs to.
|
|
54
|
+
* @param manual - true when a chip opened the form (no request behind it).
|
|
46
55
|
*/
|
|
47
|
-
export declare function credentialFormInteraction(sessionId: string): CredentialFormInteraction;
|
|
56
|
+
export declare function credentialFormInteraction(sessionId: string, manual: boolean): CredentialFormInteraction;
|
|
48
57
|
/**
|
|
49
58
|
* Test whether a pending interaction is this domain's form.
|
|
50
59
|
*
|
|
@@ -1,19 +1,31 @@
|
|
|
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. It appears
|
|
6
|
-
* the server is waiting for credentials
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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.
|
|
13
|
+
*
|
|
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.
|
|
10
20
|
*
|
|
11
21
|
* ## Why the composer and not a modal
|
|
12
22
|
*
|
|
13
|
-
* The
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
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).
|
|
17
29
|
*
|
|
18
30
|
* ## Why masked inputs are not optional
|
|
19
31
|
*
|
|
@@ -26,13 +38,33 @@
|
|
|
26
38
|
*/
|
|
27
39
|
import { type ReactNode } from 'react';
|
|
28
40
|
import type { InjectFace, PropsRuntime, PropsLocale } from '@deepseek-ai/dsh-client-ui-slots';
|
|
29
|
-
import {
|
|
41
|
+
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
42
|
+
import { type CredentialStatus, type SaveVerdict } from './credential-status.ts';
|
|
43
|
+
import type { CredentialFormInteraction } from './CredentialFormInteraction.ts';
|
|
44
|
+
declare module '@deepseek-ai/dsh-client-ui-session/client' {
|
|
45
|
+
interface SessionPendingInteractionMap {
|
|
46
|
+
'aishell-credential-form': CredentialFormInteraction;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
30
49
|
/** Injected handle bound in apply(). */
|
|
31
50
|
export interface CredentialRequestFormInjected {
|
|
51
|
+
hooks: {
|
|
52
|
+
/** Credential presence + account hint, rebound by the renderer as useCredentials. */
|
|
53
|
+
credentials: SnapshotStore<CredentialStatus>;
|
|
54
|
+
};
|
|
32
55
|
/** Store AK/SK/SecurityToken through the Host credential route. */
|
|
33
56
|
save: (accessKeyId: string, secretAccessKey: string, securityToken?: string) => Promise<SaveVerdict>;
|
|
57
|
+
/**
|
|
58
|
+
* Clear both credential stores (local + MCP server copy).
|
|
59
|
+
*
|
|
60
|
+
* Only invoked from the clear button, which renders only when credentials
|
|
61
|
+
* already exist — there is nothing to clear otherwise.
|
|
62
|
+
*/
|
|
63
|
+
clear: () => Promise<SaveVerdict>;
|
|
34
64
|
/** Tell the Host the form is done, so the waiting tool call can resume or fail. */
|
|
35
65
|
dismiss: () => void;
|
|
66
|
+
/** Close a manually-opened form. A no-op when a Host request owns the form. */
|
|
67
|
+
closeManual: () => void;
|
|
36
68
|
}
|
|
37
69
|
/** Full component props: composer owner share + locale seat + inject face. */
|
|
38
70
|
export type CredentialRequestFormProps = PropsRuntime<'conversation.composer'> & PropsLocale<'aishell'> & InjectFace<CredentialRequestFormInjected>;
|
|
@@ -41,7 +73,9 @@ export type CredentialRequestFormProps = PropsRuntime<'conversation.composer'> &
|
|
|
41
73
|
*
|
|
42
74
|
* Submitting saves through the Host route; the Host then tells the waiting tool
|
|
43
75
|
* call there is now a credential, and clears the pending flag this component
|
|
44
|
-
* renders from — so a successful submit does not need to unmount itself.
|
|
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).
|
|
45
79
|
*/
|
|
46
80
|
export declare function CredentialRequestForm(props: CredentialRequestFormProps): ReactNode;
|
|
47
81
|
//# sourceMappingURL=CredentialRequestForm.d.ts.map
|
|
@@ -7,9 +7,35 @@
|
|
|
7
7
|
* exists, and nothing throws. The plugin body wires this to the slot
|
|
8
8
|
* registry; this module holds only the decision.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* ## Two ways the form comes up
|
|
11
|
+
*
|
|
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:
|
|
18
|
+
*
|
|
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.
|
|
35
|
+
*
|
|
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.
|
|
13
39
|
*
|
|
14
40
|
* ## Why a closure and not a class
|
|
15
41
|
*
|
|
@@ -25,7 +51,7 @@
|
|
|
25
51
|
import { type CredentialFormInteraction } from './CredentialFormInteraction.ts';
|
|
26
52
|
/** Publishes one interaction and returns the function that withdraws it. */
|
|
27
53
|
export type PublishInteraction = (interaction: CredentialFormInteraction) => () => void;
|
|
28
|
-
/** Mirrors "which session is waiting" onto the composer's pending interaction. */
|
|
54
|
+
/** Mirrors "which session is waiting" and the manual open/close onto the composer's pending interaction. */
|
|
29
55
|
export interface CredentialFormVisibility {
|
|
30
56
|
/**
|
|
31
57
|
* Apply the Host's current state.
|
|
@@ -37,8 +63,28 @@ export interface CredentialFormVisibility {
|
|
|
37
63
|
* @param sessionId - the session waiting for credentials, or `''` for none.
|
|
38
64
|
*/
|
|
39
65
|
readonly sync: (sessionId: string) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Open the form manually for one session.
|
|
68
|
+
*
|
|
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.
|
|
72
|
+
*
|
|
73
|
+
* @param sessionId - the conversation the manually-opened form renders in.
|
|
74
|
+
*/
|
|
75
|
+
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
|
+
*/
|
|
83
|
+
readonly close: () => void;
|
|
40
84
|
/** The interaction currently published, if any. For tests and diagnostics. */
|
|
41
85
|
readonly current: () => CredentialFormInteraction | undefined;
|
|
86
|
+
/** Whether the current form was opened manually (no Host request behind it). */
|
|
87
|
+
readonly manual: () => boolean;
|
|
42
88
|
/** Withdraw any open form. Called when the plugin fiber is disposed. */
|
|
43
89
|
readonly dispose: () => void;
|
|
44
90
|
}
|
|
@@ -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 an MCP 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
|
*/
|