@huaweidevtools/aishell-dsh-deploy 0.0.34 → 0.0.35
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/index.js +139 -5
- package/lib/types/permission/mode.d.ts +47 -4
- package/lib/types/version.d.ts +1 -1
- package/package.json +8 -4
package/lib/index.js
CHANGED
|
@@ -1219,6 +1219,33 @@ const CLOUD_MUTABLE_API = {
|
|
|
1219
1219
|
//#endregion
|
|
1220
1220
|
//#region src/permission/mode.ts
|
|
1221
1221
|
/**
|
|
1222
|
+
* Records one change; installed by the plugin, which owns the audit service.
|
|
1223
|
+
*
|
|
1224
|
+
* A module-level hook rather than an import of the audit service: this module is
|
|
1225
|
+
* pure state with no context, so it cannot reach `ctx.audit` itself. The plugin
|
|
1226
|
+
* installs the recorder at startup, and an uninstalled recorder is silent —
|
|
1227
|
+
* `setMode` runs in tests and before the plugin is applied, neither of which is
|
|
1228
|
+
* a reason for a mode change to fail.
|
|
1229
|
+
*/
|
|
1230
|
+
let recordChange;
|
|
1231
|
+
/**
|
|
1232
|
+
* Install the recorder for mode changes.
|
|
1233
|
+
*
|
|
1234
|
+
* One recorder at a time: a second install replaces the first rather than
|
|
1235
|
+
* joining it. A trail must not depend on how many times a plugin was loaded,
|
|
1236
|
+
* and two recorders would write every change twice.
|
|
1237
|
+
*
|
|
1238
|
+
* @param record - receives every real change, or `undefined` to stop recording.
|
|
1239
|
+
* @returns the disposer, which stops recording only if this is still the
|
|
1240
|
+
* installed recorder — a late dispose cannot uninstall a successor.
|
|
1241
|
+
*/
|
|
1242
|
+
function installPermissionRecorder(record) {
|
|
1243
|
+
recordChange = record;
|
|
1244
|
+
return () => {
|
|
1245
|
+
if (recordChange === record) recordChange = void 0;
|
|
1246
|
+
};
|
|
1247
|
+
}
|
|
1248
|
+
/**
|
|
1222
1249
|
* Environment variable holding the startup default.
|
|
1223
1250
|
*
|
|
1224
1251
|
* Read once at module load and never re-read, so the mode cannot be changed
|
|
@@ -1253,8 +1280,17 @@ function parseMode(value) {
|
|
|
1253
1280
|
default: return void 0;
|
|
1254
1281
|
}
|
|
1255
1282
|
}
|
|
1283
|
+
/**
|
|
1284
|
+
* The mode this process started in.
|
|
1285
|
+
*
|
|
1286
|
+
* Resolved once, at load. The environment variable is an operator's input to a
|
|
1287
|
+
* running process, not a live setting: re-reading it would let a runtime change
|
|
1288
|
+
* of the variable move the "startup default" that `resetMode` restores and that
|
|
1289
|
+
* `/permission/get_mode` reports, which is a fact about the past.
|
|
1290
|
+
*/
|
|
1291
|
+
const STARTUP_MODE = parseMode(process.env[DEFAULT_MODE_ENV]) ?? FALLBACK_MODE;
|
|
1256
1292
|
/** Current mode. Module-level state — one server instance per connection. */
|
|
1257
|
-
let current =
|
|
1293
|
+
let current = STARTUP_MODE;
|
|
1258
1294
|
/** The mode in effect. */
|
|
1259
1295
|
function getMode$1() {
|
|
1260
1296
|
return current;
|
|
@@ -1262,21 +1298,39 @@ function getMode$1() {
|
|
|
1262
1298
|
/**
|
|
1263
1299
|
* Set the mode.
|
|
1264
1300
|
*
|
|
1301
|
+
* ## Why the notification lives here
|
|
1302
|
+
*
|
|
1303
|
+
* Every change passes through this function, so notifying here is what makes
|
|
1304
|
+
* the record gapless. A separate call each caller has to remember would leave a
|
|
1305
|
+
* change unrecorded the first time someone added a caller and forgot — and a
|
|
1306
|
+
* trail with a gap is worse than none, because it reads as complete.
|
|
1307
|
+
*
|
|
1308
|
+
* A re-assertion of the mode already in force is not a change and is not
|
|
1309
|
+
* notified: the chip re-reads the state after every call, and recording those
|
|
1310
|
+
* would fill the trail with actions nobody took.
|
|
1311
|
+
*
|
|
1265
1312
|
* @param mode - the mode to apply.
|
|
1313
|
+
* @param actor - who is setting it; the route is the only production caller, so
|
|
1314
|
+
* the default is the person at the console.
|
|
1266
1315
|
* @returns the previous mode, for a change log.
|
|
1267
1316
|
*/
|
|
1268
|
-
function setMode$1(mode) {
|
|
1317
|
+
function setMode$1(mode, actor = "user") {
|
|
1269
1318
|
const previous = current;
|
|
1270
1319
|
current = mode;
|
|
1320
|
+
if (previous !== mode) recordChange?.({
|
|
1321
|
+
previous,
|
|
1322
|
+
mode,
|
|
1323
|
+
actor
|
|
1324
|
+
});
|
|
1271
1325
|
return previous;
|
|
1272
1326
|
}
|
|
1273
1327
|
/** Whether mutations are currently permitted. */
|
|
1274
1328
|
function writesAllowed() {
|
|
1275
1329
|
return current === "read_write";
|
|
1276
1330
|
}
|
|
1277
|
-
/**
|
|
1331
|
+
/** The mode this process started in, for logging and for `permission/get_mode`. */
|
|
1278
1332
|
function defaultMode() {
|
|
1279
|
-
return
|
|
1333
|
+
return STARTUP_MODE;
|
|
1280
1334
|
}
|
|
1281
1335
|
|
|
1282
1336
|
//#endregion
|
|
@@ -1691,7 +1745,7 @@ function withAnchoredPaths(args, ctx) {
|
|
|
1691
1745
|
* written by earlier releases carry it — so it is kept even though there is no
|
|
1692
1746
|
* server.
|
|
1693
1747
|
*/
|
|
1694
|
-
const SERVER_VERSION = "aishell-deploy 0.0.
|
|
1748
|
+
const SERVER_VERSION = "aishell-deploy 0.0.35";
|
|
1695
1749
|
|
|
1696
1750
|
//#endregion
|
|
1697
1751
|
//#region src/deployment-state.ts
|
|
@@ -10666,6 +10720,40 @@ function registerDeployWorkflow(ctx) {
|
|
|
10666
10720
|
*/
|
|
10667
10721
|
const DEFAULT_TOOL_CALL_TIMEOUT_MS = 10 * 60 * 1e3;
|
|
10668
10722
|
/**
|
|
10723
|
+
* Settings namespace `aishell-credentials` records the verified account name
|
|
10724
|
+
* under.
|
|
10725
|
+
*
|
|
10726
|
+
* Its Loader row id, which is what the settings document keys a profile entry
|
|
10727
|
+
* by. Named here rather than imported: the two plugins share a document, not a
|
|
10728
|
+
* module, and a constant is a smaller coupling than a package dependency.
|
|
10729
|
+
*/
|
|
10730
|
+
const CREDENTIALS_SETTINGS_NS = "aishell-client-credentials";
|
|
10731
|
+
/**
|
|
10732
|
+
* How much of an access key an audit record shows.
|
|
10733
|
+
*
|
|
10734
|
+
* Four characters at each end. Access keys are long and opaque, so the leading
|
|
10735
|
+
* and trailing runs are what a person comparing a record against a console
|
|
10736
|
+
* recognises, while the middle stays out of a file that persists.
|
|
10737
|
+
*/
|
|
10738
|
+
const AK_VISIBLE_HEAD = 4;
|
|
10739
|
+
const AK_VISIBLE_TAIL = 4;
|
|
10740
|
+
/**
|
|
10741
|
+
* The subject an audit record names: the account, with the key masked.
|
|
10742
|
+
*
|
|
10743
|
+
* `name(AKID****WXYZ)`, or `(AKID****WXYZ)` when the account name is not known
|
|
10744
|
+
* — no credentials plugin mounted, or its first verification has not landed.
|
|
10745
|
+
* The masked key alone still identifies the account across records, so the
|
|
10746
|
+
* subject never has to be absent.
|
|
10747
|
+
*
|
|
10748
|
+
* @param accessKey - the stored access key.
|
|
10749
|
+
* @param name - the account name, when one has been verified.
|
|
10750
|
+
* @returns the label.
|
|
10751
|
+
*/
|
|
10752
|
+
function auditSubject(accessKey, name$1) {
|
|
10753
|
+
const masked = accessKey.length > AK_VISIBLE_HEAD + AK_VISIBLE_TAIL ? `${accessKey.slice(0, AK_VISIBLE_HEAD)}****${accessKey.slice(-AK_VISIBLE_TAIL)}` : "****";
|
|
10754
|
+
return name$1 === void 0 ? `(${masked})` : `${name$1}(${masked})`;
|
|
10755
|
+
}
|
|
10756
|
+
/**
|
|
10669
10757
|
* Settings schema.
|
|
10670
10758
|
*
|
|
10671
10759
|
* Every field is Volatile: each is a deployment fact that may differ between
|
|
@@ -10718,6 +10806,52 @@ function apply(ctx, config) {
|
|
|
10718
10806
|
}, "aishell-deploy: tools");
|
|
10719
10807
|
log.info(`registered ${disposers.length} Huawei Cloud tool(s)`);
|
|
10720
10808
|
log.info(`permission mode: ${getMode$1()}`);
|
|
10809
|
+
/**
|
|
10810
|
+
* The account name `aishell-credentials` recorded after verifying the pair
|
|
10811
|
+
* against IAM.
|
|
10812
|
+
*
|
|
10813
|
+
* Read from the settings document rather than by asking IAM: a mode switch is
|
|
10814
|
+
* synchronous, and a label is not worth a round trip inside it. Absent when
|
|
10815
|
+
* that plugin is not mounted, or before its first verification — the subject
|
|
10816
|
+
* then carries only the masked access key, which still identifies the account
|
|
10817
|
+
* across records.
|
|
10818
|
+
*
|
|
10819
|
+
* Read per record rather than captured: a rotation changes the account, and a
|
|
10820
|
+
* captured name would attribute a later switch to the previous one.
|
|
10821
|
+
*/
|
|
10822
|
+
const accountName = () => {
|
|
10823
|
+
const descriptor = ctx.get("settings")?.describe().find((entry) => entry.ns === CREDENTIALS_SETTINGS_NS);
|
|
10824
|
+
const value = descriptor?.value;
|
|
10825
|
+
return typeof value?.accessKeyIdHint === "string" && value.accessKeyIdHint.length > 0 ? value.accessKeyIdHint : void 0;
|
|
10826
|
+
};
|
|
10827
|
+
ctx.inject(["audit"], (auditCtx) => {
|
|
10828
|
+
/**
|
|
10829
|
+
* Record one mode change.
|
|
10830
|
+
*
|
|
10831
|
+
* The account is read here rather than passed in, so a record names the
|
|
10832
|
+
* account in force at that moment: after a rotation, the previous account
|
|
10833
|
+
* would be the wrong attribution.
|
|
10834
|
+
*/
|
|
10835
|
+
const recordChange$1 = (change) => {
|
|
10836
|
+
const ak = readStoredPair(store)?.ak;
|
|
10837
|
+
auditCtx.audit.record({
|
|
10838
|
+
action: "permission.mode",
|
|
10839
|
+
outcome: change.mode === "read_write" ? "granted" : "revoked",
|
|
10840
|
+
...ak === void 0 ? {} : { subject: auditSubject(ak, accountName()) },
|
|
10841
|
+
actor: change.actor,
|
|
10842
|
+
detail: change.previous === void 0 ? { to: change.mode } : {
|
|
10843
|
+
from: change.previous,
|
|
10844
|
+
to: change.mode
|
|
10845
|
+
}
|
|
10846
|
+
});
|
|
10847
|
+
};
|
|
10848
|
+
if (defaultMode() === "read_write") recordChange$1({
|
|
10849
|
+
previous: void 0,
|
|
10850
|
+
mode: "read_write",
|
|
10851
|
+
actor: "startup"
|
|
10852
|
+
});
|
|
10853
|
+
auditCtx.effect(() => installPermissionRecorder(recordChange$1), "aishell-deploy: permission audit recorder");
|
|
10854
|
+
});
|
|
10721
10855
|
const routes = createPermissionRoutes({
|
|
10722
10856
|
read: () => ({
|
|
10723
10857
|
mode: getMode$1(),
|
|
@@ -36,6 +36,34 @@
|
|
|
36
36
|
*/
|
|
37
37
|
/** Whether mutations are permitted. */
|
|
38
38
|
export type PermissionMode = "read_only" | "read_write";
|
|
39
|
+
/** Who set the mode. */
|
|
40
|
+
export type PermissionActor = "user" | "startup";
|
|
41
|
+
/** One recorded mode change. */
|
|
42
|
+
export interface PermissionChange {
|
|
43
|
+
/**
|
|
44
|
+
* The mode before the change, or `undefined` when the process started in
|
|
45
|
+
* this one.
|
|
46
|
+
*
|
|
47
|
+
* A startup mode has no predecessor: it was not reached from another mode,
|
|
48
|
+
* and naming one would record a transition that never happened.
|
|
49
|
+
*/
|
|
50
|
+
readonly previous: PermissionMode | undefined;
|
|
51
|
+
readonly mode: PermissionMode;
|
|
52
|
+
/** The person at the console, or the configuration the process started with. */
|
|
53
|
+
readonly actor: PermissionActor;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Install the recorder for mode changes.
|
|
57
|
+
*
|
|
58
|
+
* One recorder at a time: a second install replaces the first rather than
|
|
59
|
+
* joining it. A trail must not depend on how many times a plugin was loaded,
|
|
60
|
+
* and two recorders would write every change twice.
|
|
61
|
+
*
|
|
62
|
+
* @param record - receives every real change, or `undefined` to stop recording.
|
|
63
|
+
* @returns the disposer, which stops recording only if this is still the
|
|
64
|
+
* installed recorder — a late dispose cannot uninstall a successor.
|
|
65
|
+
*/
|
|
66
|
+
export declare function installPermissionRecorder(record: ((change: PermissionChange) => void) | undefined): () => void;
|
|
39
67
|
/**
|
|
40
68
|
* Parse a mode string.
|
|
41
69
|
*
|
|
@@ -52,18 +80,33 @@ export declare function getMode(): PermissionMode;
|
|
|
52
80
|
/**
|
|
53
81
|
* Set the mode.
|
|
54
82
|
*
|
|
83
|
+
* ## Why the notification lives here
|
|
84
|
+
*
|
|
85
|
+
* Every change passes through this function, so notifying here is what makes
|
|
86
|
+
* the record gapless. A separate call each caller has to remember would leave a
|
|
87
|
+
* change unrecorded the first time someone added a caller and forgot — and a
|
|
88
|
+
* trail with a gap is worse than none, because it reads as complete.
|
|
89
|
+
*
|
|
90
|
+
* A re-assertion of the mode already in force is not a change and is not
|
|
91
|
+
* notified: the chip re-reads the state after every call, and recording those
|
|
92
|
+
* would fill the trail with actions nobody took.
|
|
93
|
+
*
|
|
55
94
|
* @param mode - the mode to apply.
|
|
95
|
+
* @param actor - who is setting it; the route is the only production caller, so
|
|
96
|
+
* the default is the person at the console.
|
|
56
97
|
* @returns the previous mode, for a change log.
|
|
57
98
|
*/
|
|
58
|
-
export declare function setMode(mode: PermissionMode): PermissionMode;
|
|
99
|
+
export declare function setMode(mode: PermissionMode, actor?: PermissionActor): PermissionMode;
|
|
59
100
|
/** Whether mutations are currently permitted. */
|
|
60
101
|
export declare function writesAllowed(): boolean;
|
|
61
102
|
/**
|
|
62
|
-
* Reset to the startup default.
|
|
103
|
+
* Reset to the startup default, without recording.
|
|
63
104
|
*
|
|
64
|
-
*
|
|
105
|
+
* A test affordance: it restores the state the module is initialised with, so
|
|
106
|
+
* it is not an event in the process's history and there is nothing for an audit
|
|
107
|
+
* trail to say about it.
|
|
65
108
|
*/
|
|
66
109
|
export declare function resetMode(): void;
|
|
67
|
-
/**
|
|
110
|
+
/** The mode this process started in, for logging and for `permission/get_mode`. */
|
|
68
111
|
export declare function defaultMode(): PermissionMode;
|
|
69
112
|
//# sourceMappingURL=mode.d.ts.map
|
package/lib/types/version.d.ts
CHANGED
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
* written by earlier releases carry it — so it is kept even though there is no
|
|
19
19
|
* server.
|
|
20
20
|
*/
|
|
21
|
-
export declare const SERVER_VERSION = "aishell-deploy 0.0.
|
|
21
|
+
export declare const SERVER_VERSION = "aishell-deploy 0.0.35";
|
|
22
22
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huaweidevtools/aishell-dsh-deploy",
|
|
3
3
|
"description": "Huawei Cloud infrastructure tools for DSH — Terraform, OpenAPI, resource inventory, cost estimates",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.35",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,14 +31,16 @@
|
|
|
31
31
|
"hcl2-parser": "^1.0.3",
|
|
32
32
|
"jsonpath-plus": "^10.4.0",
|
|
33
33
|
"zod": "^4.2.0",
|
|
34
|
-
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.
|
|
34
|
+
"@huaweidevtools/aishell-dsh-credentials-store": "0.0.35"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
38
38
|
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
39
39
|
"@deepseek-ai/dsh-llm": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
40
40
|
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
41
|
-
"@deepseek-ai/dsh-tools": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3"
|
|
41
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
42
|
+
"@deepseek-ai/dsh-settings": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
43
|
+
"@huaweidevtools/aishell-dsh-audit": "0.0.35"
|
|
42
44
|
},
|
|
43
45
|
"devDependencies": {
|
|
44
46
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
@@ -50,7 +52,9 @@
|
|
|
50
52
|
"@deepseek-ai/schemastery": "3.19.0",
|
|
51
53
|
"tsdown": "^0.10.0",
|
|
52
54
|
"typescript": "^5.7.0",
|
|
53
|
-
"zod": "^4.2.0"
|
|
55
|
+
"zod": "^4.2.0",
|
|
56
|
+
"@deepseek-ai/dsh-settings": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
57
|
+
"@huaweidevtools/aishell-dsh-audit": "0.0.35"
|
|
54
58
|
},
|
|
55
59
|
"dsh": {
|
|
56
60
|
"bundle": {
|