@huaweidevtools/aishell-dsh-deploy 0.0.37 → 0.0.38

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/README.md CHANGED
@@ -56,10 +56,16 @@ The switch belongs to one Session, read and written directly by
56
56
  starts, not after the one already running. Two conversations open in one window
57
57
  are two decisions: granting write access in one does not widen the other.
58
58
 
59
- Every Session starts in the posture — read-only unless a deployment set
60
- `POST api/aishell/permission/default`. Each Session is pinned to the posture in
61
- force when it was created, so that setting decides what the next conversation
62
- starts in and leaves existing ones as they are.
59
+ Every Session starts in the posture: read-only unless the deployment declares
60
+ `startupPosture: read_write` in its profile patch, or a running process overrides
61
+ it with `POST api/aishell/permission/default`. Each Session is pinned to the
62
+ posture in force when it starts, so a posture change reaches the next
63
+ conversation to begin and leaves one already running as it is.
64
+
65
+ `startupPosture` is a deployment statement, read at every start. The route's
66
+ override is a running decision and ends with the process. A permanent change
67
+ belongs in the patch, which is version-controlled and reviewed with the
68
+ profile.
63
69
 
64
70
  It is enforced in two places, because the tools reach the cloud two ways:
65
71
 
@@ -91,6 +97,7 @@ producing the plan and the exact commands — rather than stopping early.
91
97
  |---|---|---|---|
92
98
  | `defaultRegion` | `string?` | unset | A fallback for a plan that names no region, and the `HW_REGION_NAME` terraform runs under. Unset means each resource's provider block decides. |
93
99
  | `toolCallTimeoutMs` | `number?` | 10 minutes | Per-call budget. A real `terraform_apply` runs for minutes, so the default is above that rather than the seconds a lookup tool would want. |
100
+ | `startupPosture` | `read_only` \| `read_write` | `read_only` | What new Sessions start in. Read-only unless the deployment says otherwise, because a conversation may look at the account before anyone has decided it may change it. |
94
101
 
95
102
  There is no built-in region. A region belongs to each resource, read from the
96
103
  provider block its plan names, so a deployment-wide default would have to be
package/cordis.patch.yml CHANGED
@@ -10,6 +10,12 @@
10
10
  # two never disagree.
11
11
  # - `toolCallTimeoutMs` is 10 minutes: terraform_apply of a real network takes
12
12
  # minutes, and a shorter budget reports a timeout on work still in progress.
13
+ # - `startupPosture` is `read_only`: a new Session may look at the account
14
+ # before anyone has decided it may change it. Set it to `read_write` in a
15
+ # deployment where every new conversation is expected to make changes.
16
+ # It decides what every Session begins with — a new one, or one the host
17
+ # restores at start — so changing it changes what a reopened conversation
18
+ # starts in. Within one run, a Session keeps the answer it was given.
13
19
  #
14
20
  # The credential store is the shared `aishell-dsh` one, read per call.
15
21
  #
package/lib/index.js CHANGED
@@ -1251,15 +1251,21 @@ function installPermissionRecorder(record) {
1251
1251
  };
1252
1252
  }
1253
1253
  /**
1254
- * The posture every Session starts in.
1254
+ * What a module answers before any deployment statement is applied.
1255
1255
  *
1256
- * Read-only unless the deployment asked for otherwise before any conversation
1257
- * opened. A Session is pinned to this value when it is created, so a later
1258
- * change reaches only Sessions that have not started yet.
1256
+ * Read-only, and the value {@link resetMode} restores: a restart must come back
1257
+ * to a state the process can defend without having been told anything, not to
1258
+ * whatever a caller happened to set last.
1259
1259
  */
1260
- const STARTUP_POSTURE = "read_only";
1261
- /** The posture new Sessions are pinned to. Not retroactive — see the module header. */
1262
- let posture = STARTUP_POSTURE;
1260
+ const DEFAULT_POSTURE = "read_only";
1261
+ /**
1262
+ * The posture new Sessions are pinned to.
1263
+ *
1264
+ * Starts at {@link DEFAULT_POSTURE} and is set from the deployment's
1265
+ * `startupPosture` once the plugin mounts, then by a running override
1266
+ * afterwards. Not retroactive — see the module header.
1267
+ */
1268
+ let posture = DEFAULT_POSTURE;
1263
1269
  /** Modes by Session. Every created Session has an entry; `posture` covers the rest. */
1264
1270
  const modes = new Map();
1265
1271
  /** The mode one Session may act under. */
@@ -1325,23 +1331,44 @@ function writesAllowed(session) {
1325
1331
  return getMode(session) === "read_write";
1326
1332
  }
1327
1333
  /**
1328
- * Give one Session its own mode, decided by the posture in force at creation.
1334
+ * Give one Session its own mode, decided by the posture in force at that moment.
1329
1335
  *
1330
- * Every Session carries an entry from the moment it exists, which is what makes
1331
- * a posture change reach only Sessions that have not started. A Session pinned
1332
- * here keeps the answer it was created with, so a conversation on screen is
1333
- * never widened from underneath the person reading it.
1336
+ * Every Session carries an entry from the moment it starts, which is what makes
1337
+ * a posture change reach only Sessions that have not started. A Session that
1338
+ * already has an entry keeps it, so a conversation on screen is never widened
1339
+ * from underneath the person reading it — and a restored one re-enters with no
1340
+ * entry, taking the posture the process started with.
1334
1341
  *
1335
- * @param session - the Session being created.
1342
+ * @param session - the Session being started.
1336
1343
  */
1337
1344
  function pinSession(session) {
1338
1345
  if (!modes.has(session)) modes.set(session, posture);
1339
1346
  }
1340
1347
  /**
1348
+ * Apply the posture a deployment configured, before anything else runs.
1349
+ *
1350
+ * Separate from {@link setDefaultPosture} because it describes two different
1351
+ * acts: this is the value the process starts in, which the plugin records once
1352
+ * as the trail's first entry under the `startup` actor; that one is a switch a
1353
+ * person makes, recorded under `user`. One record per act, and the trail names
1354
+ * who acted.
1355
+ *
1356
+ * Called before Sessions are pinned, so the Sessions already open when the
1357
+ * plugin mounts (and every one created afterwards) start under the value the
1358
+ * deployment declared.
1359
+ *
1360
+ * @param mode - the configured posture.
1361
+ */
1362
+ function applyStartupPosture(mode) {
1363
+ posture = mode;
1364
+ }
1365
+ /**
1341
1366
  * Set the posture new Sessions start in.
1342
1367
  *
1343
1368
  * Every Session already has an entry of its own, so this decides what Sessions
1344
1369
  * created from now on begin with and leaves existing conversations as they are.
1370
+ * It is an override of the deployment's `startupPosture` for this process: the
1371
+ * next start reads the configured value again.
1345
1372
  *
1346
1373
  * @param mode - the posture to apply.
1347
1374
  * @returns the posture it replaced.
@@ -1835,7 +1862,7 @@ function withAnchoredPaths(args, ctx) {
1835
1862
  * written by earlier releases carry it — so it is kept even though there is no
1836
1863
  * server.
1837
1864
  */
1838
- const SERVER_VERSION = "aishell-deploy 0.0.37";
1865
+ const SERVER_VERSION = "aishell-deploy 0.0.38";
1839
1866
 
1840
1867
  //#endregion
1841
1868
  //#region src/deployment-state.ts
@@ -10945,9 +10972,13 @@ function auditSubject(accessKey, name$1) {
10945
10972
  /**
10946
10973
  * Settings schema.
10947
10974
  *
10948
- * Every field is Volatile: each is a deployment fact that may differ between
10949
- * profiles, and a change should apply to the next call rather than require a
10950
- * restart. The bridge reads them through thunks for that reason.
10975
+ * A field is Volatile when its change should apply to the next call rather than
10976
+ * require a restart — a deployment fact that may differ between profiles. The
10977
+ * bridge reads those through thunks for that reason.
10978
+ *
10979
+ * `startupPosture` is plain: a posture is what a Session begins with, and
10980
+ * Sessions that already exist keep the answer they were pinned to, so the field
10981
+ * is read once at mount rather than per call.
10951
10982
  *
10952
10983
  * `defaultRegion` has no `.default()`. A built-in region would be a guess
10953
10984
  * dressed as configuration — the one thing this plugin must not do, because the
@@ -10957,7 +10988,8 @@ function auditSubject(accessKey, name$1) {
10957
10988
  */
10958
10989
  const Config = Schema.object({
10959
10990
  defaultRegion: Schema.string().volatile(),
10960
- toolCallTimeoutMs: Schema.number().step(1).min(1).default(DEFAULT_TOOL_CALL_TIMEOUT_MS).volatile()
10991
+ toolCallTimeoutMs: Schema.number().step(1).min(1).default(DEFAULT_TOOL_CALL_TIMEOUT_MS).volatile(),
10992
+ startupPosture: Schema.union([Schema.const("read_only"), Schema.const("read_write")]).default("read_only")
10961
10993
  });
10962
10994
  const name = "aishell-deploy";
10963
10995
  /**
@@ -10968,8 +11000,8 @@ const name = "aishell-deploy";
10968
11000
  * authenticated fetch registry, and a plugin that silently lost its permission
10969
11001
  * switch would leave every mutation at the default.
10970
11002
  * `sessions` is required because the permission mode is filed per Session: a
10971
- * conversation is pinned to the posture when it is created, and the store is
10972
- * what makes that possible for Sessions that exist before this plugin mounts.
11003
+ * conversation is pinned to the posture when it starts, and the store is what
11004
+ * makes that possible for Sessions that exist before this plugin mounts.
10973
11005
  */
10974
11006
  const inject = [
10975
11007
  "tools",
@@ -11001,7 +11033,19 @@ function apply(ctx, config) {
11001
11033
  for (const dispose of disposers) dispose();
11002
11034
  }, "aishell-deploy: tools");
11003
11035
  log.info(`registered ${disposers.length} Huawei Cloud tool(s)`);
11004
- log.info(`permission posture for new sessions: ${defaultPosture()}`);
11036
+ applyStartupPosture(config.startupPosture);
11037
+ /**
11038
+ * The posture this process started in.
11039
+ *
11040
+ * Captured here, before any switch can be accepted, because the audit trail
11041
+ * records it as its first entry — and that record is written later, when the
11042
+ * audit service becomes available. Reading `defaultPosture()` at that point
11043
+ * would report the posture in force then: a deployment that switched the
11044
+ * posture before the audit plugin mounted would have its switch recorded as
11045
+ * the start, which the trail cannot then tell from a start nobody watched.
11046
+ */
11047
+ const startupPosture = defaultPosture();
11048
+ log.info(`permission posture for new sessions: ${startupPosture}`);
11005
11049
  ctx.effect(() => ctx.on("session/disposed", (session) => {
11006
11050
  forgetSession(session.id);
11007
11051
  }), "aishell-deploy: forget disposed session modes");
@@ -11056,7 +11100,7 @@ function apply(ctx, config) {
11056
11100
  recordChange$1({
11057
11101
  session: void 0,
11058
11102
  previous: void 0,
11059
- mode: defaultPosture(),
11103
+ mode: startupPosture,
11060
11104
  actor: "startup"
11061
11105
  });
11062
11106
  auditCtx.effect(() => installPermissionRecorder(recordChange$1), "aishell-deploy: permission audit recorder");
@@ -38,6 +38,7 @@
38
38
  */
39
39
  import type { Context, Volatile } from '@deepseek-ai/cordis';
40
40
  import z from '@deepseek-ai/schemastery';
41
+ import { type PermissionMode } from './permission/mode.ts';
41
42
  /** Plugin config. */
42
43
  export interface Config {
43
44
  /**
@@ -58,13 +59,31 @@ export interface Config {
58
59
  * lookup-shaped tool would want.
59
60
  */
60
61
  readonly toolCallTimeoutMs: Volatile<number>;
62
+ /**
63
+ * The posture new Sessions start in, as this deployment declares it.
64
+ *
65
+ * Read-only by default. A deployment whose conversations are expected to make
66
+ * changes states it here, in the profile's patch: the patch is
67
+ * version-controlled and visible to whoever reviews the profile, and the
68
+ * declaration is the value every start reads.
69
+ *
70
+ * Not volatile: a posture is what a Session begins with, and Sessions that
71
+ * already exist keep the answer they were pinned to when they started.
72
+ * Editing this between calls leaves them as they are, so the field is a
73
+ * start-up statement rather than a live one.
74
+ */
75
+ readonly startupPosture: PermissionMode;
61
76
  }
62
77
  /**
63
78
  * Settings schema.
64
79
  *
65
- * Every field is Volatile: each is a deployment fact that may differ between
66
- * profiles, and a change should apply to the next call rather than require a
67
- * restart. The bridge reads them through thunks for that reason.
80
+ * A field is Volatile when its change should apply to the next call rather than
81
+ * require a restart — a deployment fact that may differ between profiles. The
82
+ * bridge reads those through thunks for that reason.
83
+ *
84
+ * `startupPosture` is plain: a posture is what a Session begins with, and
85
+ * Sessions that already exist keep the answer they were pinned to, so the field
86
+ * is read once at mount rather than per call.
68
87
  *
69
88
  * `defaultRegion` has no `.default()`. A built-in region would be a guess
70
89
  * dressed as configuration — the one thing this plugin must not do, because the
@@ -75,9 +94,11 @@ export interface Config {
75
94
  export declare const Config: z<Schemastery.ObjectS<NoInfer<{
76
95
  defaultRegion: z<string, string, "volatile">;
77
96
  toolCallTimeoutMs: z<number, number, "volatile-defined">;
97
+ startupPosture: z<"read_only" | "read_write", "read_only" | "read_write", "defined">;
78
98
  }>>, Schemastery.ObjectT<NoInfer<{
79
99
  defaultRegion: z<string, string, "volatile">;
80
100
  toolCallTimeoutMs: z<number, number, "volatile-defined">;
101
+ startupPosture: z<"read_only" | "read_write", "read_only" | "read_write", "defined">;
81
102
  }>>, "plain">;
82
103
  export declare const name = "aishell-deploy";
83
104
  /**
@@ -88,8 +109,8 @@ export declare const name = "aishell-deploy";
88
109
  * authenticated fetch registry, and a plugin that silently lost its permission
89
110
  * switch would leave every mutation at the default.
90
111
  * `sessions` is required because the permission mode is filed per Session: a
91
- * conversation is pinned to the posture when it is created, and the store is
92
- * what makes that possible for Sessions that exist before this plugin mounts.
112
+ * conversation is pinned to the posture when it starts, and the store is what
113
+ * makes that possible for Sessions that exist before this plugin mounts.
93
114
  */
94
115
  export declare const inject: string[];
95
116
  export declare function apply(ctx: Context, config: Config): void;
@@ -44,11 +44,15 @@
44
44
  * ## What a restart guarantees
45
45
  *
46
46
  * Neither a Session's mode nor the posture is persisted, so a restart returns
47
- * both to read-only. A conversation that needs write access is granted it again,
48
- * which is the safe direction to fail. A deployment that wants new Sessions to
49
- * start in write access states that after start-up, over
50
- * `POST api/aishell/permission/default` — the posture is a running decision, not
51
- * a stored one, so nothing survives that would disagree with it.
47
+ * both to `startupPosture`, which defaults to read-only. A conversation that
48
+ * needs write access is granted it again, which is the safe direction to fail.
49
+ *
50
+ * `startupPosture` is a deployment statement — a line in the profile's patch —
51
+ * and `setDefaultPosture` is a running override on top of it. The override
52
+ * ends with the process: the next start reads the deployment's value, so a
53
+ * running process widened for the work at hand comes back the way the
54
+ * deployment configured it. A deployment whose new Sessions start in write
55
+ * access for good says so in `startupPosture`, which every start reads.
52
56
  *
53
57
  * @module permission/mode
54
58
  */
@@ -138,21 +142,40 @@ export declare function setMode(session: SessionKey, mode: PermissionMode, actor
138
142
  */
139
143
  export declare function writesAllowed(session: SessionKey | undefined): boolean;
140
144
  /**
141
- * Give one Session its own mode, decided by the posture in force at creation.
145
+ * Give one Session its own mode, decided by the posture in force at that moment.
142
146
  *
143
- * Every Session carries an entry from the moment it exists, which is what makes
144
- * a posture change reach only Sessions that have not started. A Session pinned
145
- * here keeps the answer it was created with, so a conversation on screen is
146
- * never widened from underneath the person reading it.
147
+ * Every Session carries an entry from the moment it starts, which is what makes
148
+ * a posture change reach only Sessions that have not started. A Session that
149
+ * already has an entry keeps it, so a conversation on screen is never widened
150
+ * from underneath the person reading it — and a restored one re-enters with no
151
+ * entry, taking the posture the process started with.
147
152
  *
148
- * @param session - the Session being created.
153
+ * @param session - the Session being started.
149
154
  */
150
155
  export declare function pinSession(session: SessionKey): void;
156
+ /**
157
+ * Apply the posture a deployment configured, before anything else runs.
158
+ *
159
+ * Separate from {@link setDefaultPosture} because it describes two different
160
+ * acts: this is the value the process starts in, which the plugin records once
161
+ * as the trail's first entry under the `startup` actor; that one is a switch a
162
+ * person makes, recorded under `user`. One record per act, and the trail names
163
+ * who acted.
164
+ *
165
+ * Called before Sessions are pinned, so the Sessions already open when the
166
+ * plugin mounts (and every one created afterwards) start under the value the
167
+ * deployment declared.
168
+ *
169
+ * @param mode - the configured posture.
170
+ */
171
+ export declare function applyStartupPosture(mode: PermissionMode): void;
151
172
  /**
152
173
  * Set the posture new Sessions start in.
153
174
  *
154
175
  * Every Session already has an entry of its own, so this decides what Sessions
155
176
  * created from now on begin with and leaves existing conversations as they are.
177
+ * It is an override of the deployment's `startupPosture` for this process: the
178
+ * next start reads the configured value again.
156
179
  *
157
180
  * @param mode - the posture to apply.
158
181
  * @returns the posture it replaced.
@@ -167,7 +190,7 @@ export declare function setDefaultPosture(mode: PermissionMode): PermissionMode;
167
190
  */
168
191
  export declare function forgetSession(session: SessionKey): void;
169
192
  /**
170
- * Reset to the startup posture, without recording.
193
+ * Reset to the posture the module answers before anything configures it.
171
194
  *
172
195
  * A test affordance: it restores the state the module is initialised with, so
173
196
  * it is not an event in the process's history and there is nothing for an audit
@@ -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.37";
21
+ export declare const SERVER_VERSION = "aishell-deploy 0.0.38";
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.37",
4
+ "version": "0.0.38",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -31,32 +31,32 @@
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.37"
34
+ "@huaweidevtools/aishell-dsh-credentials-store": "0.0.38"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@deepseek-ai/cordis": "^4.1.0",
38
- "@deepseek-ai/dsh-client-connection": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
39
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
40
- "@deepseek-ai/dsh-session": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
41
- "@deepseek-ai/dsh-settings": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
42
- "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
43
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
44
- "@huaweidevtools/aishell-dsh-audit": "0.0.37"
38
+ "@deepseek-ai/dsh-client-connection": "0.2.2-rc.5",
39
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
40
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5",
41
+ "@deepseek-ai/dsh-settings": "0.2.2-rc.5",
42
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.5",
43
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.5",
44
+ "@huaweidevtools/aishell-dsh-audit": "0.0.38"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@deepseek-ai/cordis": "^4.1.0",
48
48
  "@deepseek-ai/cordis-plugin-loader": "^1.1.0",
49
- "@deepseek-ai/dsh-client-connection": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
50
- "@deepseek-ai/dsh-llm": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
51
- "@deepseek-ai/dsh-session": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
52
- "@deepseek-ai/dsh-settings": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
53
- "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
54
- "@deepseek-ai/dsh-tools": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
49
+ "@deepseek-ai/dsh-client-connection": "0.2.2-rc.5",
50
+ "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
51
+ "@deepseek-ai/dsh-session": "0.2.2-rc.5",
52
+ "@deepseek-ai/dsh-settings": "0.2.2-rc.5",
53
+ "@deepseek-ai/dsh-system-prompt": "0.2.2-rc.5",
54
+ "@deepseek-ai/dsh-tools": "0.2.2-rc.5",
55
55
  "@deepseek-ai/schemastery": "3.19.0",
56
56
  "tsdown": "^0.10.0",
57
57
  "typescript": "^5.7.0",
58
58
  "zod": "^4.2.0",
59
- "@huaweidevtools/aishell-dsh-audit": "0.0.37"
59
+ "@huaweidevtools/aishell-dsh-audit": "0.0.38"
60
60
  },
61
61
  "dsh": {
62
62
  "bundle": {