@huaweidevtools/aishell-dsh-deploy 0.0.36 → 0.0.37
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 +26 -9
- package/lib/index.js +342 -128
- package/lib/types/index.d.ts +7 -4
- package/lib/types/permission/call-context.d.ts +65 -0
- package/lib/types/permission/gate.d.ts +9 -1
- package/lib/types/permission/mode.d.ts +92 -27
- package/lib/types/permission-context.d.ts +8 -5
- package/lib/types/permission-route.d.ts +70 -21
- package/lib/types/permission.d.ts +0 -4
- package/lib/types/tools/errors.d.ts +4 -0
- package/lib/types/tools/index.d.ts +4 -2
- package/lib/types/types.d.ts +8 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +6 -4
package/lib/types/index.d.ts
CHANGED
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
*
|
|
23
23
|
* ## The permission switch
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
* and writes it directly, so a switch takes effect before the next
|
|
27
|
-
* starts. The gate itself is enforced in `permission/gate.ts` — a
|
|
28
|
-
* cannot be talked around.
|
|
25
|
+
* One mode per Session, held in this process. The Host route the composer chip
|
|
26
|
+
* calls reads and writes it directly, so a switch takes effect before the next
|
|
27
|
+
* tool call starts. The gate itself is enforced in `permission/gate.ts` — a
|
|
28
|
+
* refusal cannot be talked around.
|
|
29
29
|
*
|
|
30
30
|
* ## What this plugin does not own
|
|
31
31
|
*
|
|
@@ -87,6 +87,9 @@ export declare const name = "aishell-deploy";
|
|
|
87
87
|
* `connection` is required because the permission route registers on the host's
|
|
88
88
|
* authenticated fetch registry, and a plugin that silently lost its permission
|
|
89
89
|
* switch would leave every mutation at the default.
|
|
90
|
+
* `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.
|
|
90
93
|
*/
|
|
91
94
|
export declare const inject: string[];
|
|
92
95
|
export declare function apply(ctx: Context, config: Config): void;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which Session a call is being made for.
|
|
3
|
+
*
|
|
4
|
+
* ## Why the Session travels with the call
|
|
5
|
+
*
|
|
6
|
+
* The mode belongs to a Session, so every gate has to know which one it is
|
|
7
|
+
* gating. The tool registry gate is handed that by the harness: a tool executes
|
|
8
|
+
* with the calling agent, whose id is the Session. The signed-HTTP funnel is
|
|
9
|
+
* not — it sits several layers below the tool, behind helpers that build a
|
|
10
|
+
* request without knowing whose it is.
|
|
11
|
+
*
|
|
12
|
+
* A `session` parameter threaded through those helpers would leave the answer
|
|
13
|
+
* to each one remembering to pass it. A helper that did not would read the
|
|
14
|
+
* posture instead of the Session and permit a call the Session refuses — a gate
|
|
15
|
+
* with a hole in it, silently. So the Session is ambient to the call rather than
|
|
16
|
+
* an argument in it: the funnel cannot be reached without it.
|
|
17
|
+
*
|
|
18
|
+
* ## How it travels
|
|
19
|
+
*
|
|
20
|
+
* A store that follows the asynchronous work a call creates. The tool executor
|
|
21
|
+
* runs each handler inside {@link runForSession}, so everything the handler
|
|
22
|
+
* awaits — the helper that builds the request, the funnel that signs it — reads
|
|
23
|
+
* the same Session without a parameter in sight.
|
|
24
|
+
*
|
|
25
|
+
* The store follows the whole asynchronous resource graph, not only the `await`
|
|
26
|
+
* chain: a timer, a promise chain, a queue callback scheduled during the call
|
|
27
|
+
* all still see its Session. What it does not follow is work detached from the
|
|
28
|
+
* process — a task handed to a worker, or one queued before the call began. A
|
|
29
|
+
* caller that defers a request that far captures the Session itself.
|
|
30
|
+
*
|
|
31
|
+
* @module permission/call-context
|
|
32
|
+
*/
|
|
33
|
+
import type { SessionKey } from "./mode.js";
|
|
34
|
+
/**
|
|
35
|
+
* Run one call with its Session in scope.
|
|
36
|
+
*
|
|
37
|
+
* @param session - the Session the call is made for.
|
|
38
|
+
* @param body - the work; anything it awaits reads the same Session.
|
|
39
|
+
* @returns whatever `body` returns.
|
|
40
|
+
*/
|
|
41
|
+
export declare function runForSession<T>(session: SessionKey, body: () => T): T;
|
|
42
|
+
/**
|
|
43
|
+
* Run one call that belongs to no Session.
|
|
44
|
+
*
|
|
45
|
+
* The store would otherwise be inherited from whatever call is already in
|
|
46
|
+
* scope, which would credit this call to a conversation it is not part of. A
|
|
47
|
+
* call the harness gave no Session belongs to no conversation, and the gates
|
|
48
|
+
* judge it by the posture — the same answer as a call made outside any tool
|
|
49
|
+
* execution.
|
|
50
|
+
*
|
|
51
|
+
* @param body - the work.
|
|
52
|
+
* @returns whatever `body` returns.
|
|
53
|
+
*/
|
|
54
|
+
export declare function runWithoutSession<T>(body: () => T): T;
|
|
55
|
+
/**
|
|
56
|
+
* The Session the current call serves, if any.
|
|
57
|
+
*
|
|
58
|
+
* `undefined` outside any call this plugin placed in scope: at module level, on
|
|
59
|
+
* work detached from the process, or inside a call the harness gave no Session.
|
|
60
|
+
* The gate treats that as a call with no Session rather than inventing one.
|
|
61
|
+
*
|
|
62
|
+
* @returns the Session key, or `undefined`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function currentSession(): SessionKey | undefined;
|
|
65
|
+
//# sourceMappingURL=call-context.d.ts.map
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
*
|
|
50
50
|
* @module permission/gate
|
|
51
51
|
*/
|
|
52
|
+
import { type SessionKey } from "./mode.js";
|
|
52
53
|
/**
|
|
53
54
|
* Tools that change cloud state without going through `signedHttp`.
|
|
54
55
|
*
|
|
@@ -73,12 +74,19 @@ export declare class PermissionRefusalError extends Error {
|
|
|
73
74
|
* Check a tool call against read-only mode.
|
|
74
75
|
*
|
|
75
76
|
* @param toolName - the tool about to run.
|
|
77
|
+
* @param session - the Session it runs for; the executor has it, so it is passed
|
|
78
|
+
* rather than read from the call context.
|
|
76
79
|
* @returns a message to return as a failed tool result, or `undefined` to proceed.
|
|
77
80
|
*/
|
|
78
|
-
export declare function denyTool(toolName: string): string | undefined;
|
|
81
|
+
export declare function denyTool(toolName: string, session: SessionKey | undefined): string | undefined;
|
|
79
82
|
/**
|
|
80
83
|
* Check a signed HTTP request against read-only mode.
|
|
81
84
|
*
|
|
85
|
+
* The Session comes from the call context: every signed request is made inside a
|
|
86
|
+
* tool execution, and the context carries that tool's Session down to this
|
|
87
|
+
* funnel. See `./call-context.ts` for why it travels with the call rather than
|
|
88
|
+
* as an argument.
|
|
89
|
+
*
|
|
82
90
|
* @param method - HTTP method.
|
|
83
91
|
* @param url - the full request URL.
|
|
84
92
|
* @returns a message describing the refusal, or `undefined` to proceed.
|
|
@@ -28,28 +28,56 @@
|
|
|
28
28
|
* observable at the moment it blocks you, and one-way unchangeable — which is
|
|
29
29
|
* the property that matters.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* ## One mode per Session
|
|
32
|
+
*
|
|
33
|
+
* The mode belongs to a Session, not to the process: two conversations open in
|
|
34
|
+
* one window are two decisions, and granting write access to review something
|
|
35
|
+
* here must not widen what an agent is doing there. A Session's mode is the one
|
|
36
|
+
* a person set for it, or — until there is one — the posture this process was
|
|
37
|
+
* asked to give new Sessions.
|
|
38
|
+
*
|
|
39
|
+
* The posture decides what a Session begins with, never what it is later set
|
|
40
|
+
* to. A conversation that is already on screen keeps the answer it started
|
|
41
|
+
* with, so a deployment can raise the posture for work it is about to start
|
|
42
|
+
* without widening one a person is already reading.
|
|
43
|
+
*
|
|
44
|
+
* ## What a restart guarantees
|
|
45
|
+
*
|
|
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.
|
|
34
52
|
*
|
|
35
53
|
* @module permission/mode
|
|
36
54
|
*/
|
|
37
55
|
/** Whether mutations are permitted. */
|
|
38
56
|
export type PermissionMode = "read_only" | "read_write";
|
|
57
|
+
/** One conversation. The key every mode in this module is filed under. */
|
|
58
|
+
export type SessionKey = string;
|
|
39
59
|
/** Who set the mode. */
|
|
40
60
|
export type PermissionActor = "user" | "startup";
|
|
41
|
-
/** One recorded mode change. */
|
|
61
|
+
/** One recorded mode change, and the Session it applies to. */
|
|
42
62
|
export interface PermissionChange {
|
|
43
63
|
/**
|
|
44
|
-
* The
|
|
45
|
-
*
|
|
64
|
+
* The Session whose mode changed, or `undefined` for the posture new Sessions
|
|
65
|
+
* start in.
|
|
66
|
+
*
|
|
67
|
+
* A posture change is not a change to any conversation on screen, so it names
|
|
68
|
+
* no Session — the record's `detail` carries the posture it set instead.
|
|
69
|
+
*/
|
|
70
|
+
readonly session: SessionKey | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* The mode before the change, or `undefined` when there was none to be in.
|
|
46
73
|
*
|
|
47
|
-
* A
|
|
48
|
-
*
|
|
74
|
+
* A Session with no mode of its own was in the posture, and a posture that
|
|
75
|
+
* nothing has changed yet has no predecessor either: naming one would record
|
|
76
|
+
* a transition that never happened.
|
|
49
77
|
*/
|
|
50
78
|
readonly previous: PermissionMode | undefined;
|
|
51
79
|
readonly mode: PermissionMode;
|
|
52
|
-
/** The person at the console, or the
|
|
80
|
+
/** The person at the console, or the posture the process started with. */
|
|
53
81
|
readonly actor: PermissionActor;
|
|
54
82
|
}
|
|
55
83
|
/**
|
|
@@ -64,21 +92,18 @@ export interface PermissionChange {
|
|
|
64
92
|
* installed recorder — a late dispose cannot uninstall a successor.
|
|
65
93
|
*/
|
|
66
94
|
export declare function installPermissionRecorder(record: ((change: PermissionChange) => void) | undefined): () => void;
|
|
95
|
+
/** The mode one Session may act under. */
|
|
96
|
+
export declare function getMode(session: SessionKey | undefined): PermissionMode;
|
|
67
97
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* Accepts the wire spellings plus a few the operator is likely to type in an
|
|
71
|
-
* environment variable. Anything unrecognised yields `undefined` rather than
|
|
72
|
-
* throwing, so a typo degrades to the default instead of failing startup.
|
|
98
|
+
* The posture new Sessions start in.
|
|
73
99
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
100
|
+
* Read through a function rather than exported as a value: the route and the
|
|
101
|
+
* client both report it, and a snapshot taken at import time would go stale the
|
|
102
|
+
* first time a deployment sets it.
|
|
76
103
|
*/
|
|
77
|
-
export declare function
|
|
78
|
-
/** The mode in effect. */
|
|
79
|
-
export declare function getMode(): PermissionMode;
|
|
104
|
+
export declare function defaultPosture(): PermissionMode;
|
|
80
105
|
/**
|
|
81
|
-
* Set
|
|
106
|
+
* Set one Session's mode.
|
|
82
107
|
*
|
|
83
108
|
* ## Why the notification lives here
|
|
84
109
|
*
|
|
@@ -91,22 +116,62 @@ export declare function getMode(): PermissionMode;
|
|
|
91
116
|
* notified: the chip re-reads the state after every call, and recording those
|
|
92
117
|
* would fill the trail with actions nobody took.
|
|
93
118
|
*
|
|
119
|
+
* A mode is stored under its Session for as long as that Session lives, whatever
|
|
120
|
+
* its value. Only a Session that has never been given one follows the posture;
|
|
121
|
+
* once a conversation has an answer of its own, that answer is the one it keeps,
|
|
122
|
+
* so a later posture change cannot revise a decision already made about it.
|
|
123
|
+
*
|
|
124
|
+
* @param session - the Session the mode applies to.
|
|
94
125
|
* @param mode - the mode to apply.
|
|
95
126
|
* @param actor - who is setting it; the route is the only production caller, so
|
|
96
127
|
* the default is the person at the console.
|
|
97
|
-
* @returns the
|
|
128
|
+
* @returns the mode the Session was in, for a change log.
|
|
129
|
+
*/
|
|
130
|
+
export declare function setMode(session: SessionKey, mode: PermissionMode, actor?: PermissionActor): PermissionMode;
|
|
131
|
+
/**
|
|
132
|
+
* Whether one Session may mutate the cloud.
|
|
133
|
+
*
|
|
134
|
+
* `undefined` is "no Session" — a call outside a conversation, which answers
|
|
135
|
+
* with the posture. Every production tool call carries a Session, so that arm
|
|
136
|
+
* describes a call this plugin does not place in any conversation; it is not a
|
|
137
|
+
* separate policy, and a deployment that widened the posture widened it too.
|
|
138
|
+
*/
|
|
139
|
+
export declare function writesAllowed(session: SessionKey | undefined): boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Give one Session its own mode, decided by the posture in force at creation.
|
|
142
|
+
*
|
|
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
|
+
*
|
|
148
|
+
* @param session - the Session being created.
|
|
149
|
+
*/
|
|
150
|
+
export declare function pinSession(session: SessionKey): void;
|
|
151
|
+
/**
|
|
152
|
+
* Set the posture new Sessions start in.
|
|
153
|
+
*
|
|
154
|
+
* Every Session already has an entry of its own, so this decides what Sessions
|
|
155
|
+
* created from now on begin with and leaves existing conversations as they are.
|
|
156
|
+
*
|
|
157
|
+
* @param mode - the posture to apply.
|
|
158
|
+
* @returns the posture it replaced.
|
|
159
|
+
*/
|
|
160
|
+
export declare function setDefaultPosture(mode: PermissionMode): PermissionMode;
|
|
161
|
+
/**
|
|
162
|
+
* Forget one Session's mode.
|
|
163
|
+
*
|
|
164
|
+
* Called when the Session is disposed: the map is keyed by an identity that
|
|
165
|
+
* will not be seen again, and a long-running process opens sessions for as long
|
|
166
|
+
* as it runs.
|
|
98
167
|
*/
|
|
99
|
-
export declare function
|
|
100
|
-
/** Whether mutations are currently permitted. */
|
|
101
|
-
export declare function writesAllowed(): boolean;
|
|
168
|
+
export declare function forgetSession(session: SessionKey): void;
|
|
102
169
|
/**
|
|
103
|
-
* Reset to the startup
|
|
170
|
+
* Reset to the startup posture, without recording.
|
|
104
171
|
*
|
|
105
172
|
* A test affordance: it restores the state the module is initialised with, so
|
|
106
173
|
* it is not an event in the process's history and there is nothing for an audit
|
|
107
174
|
* trail to say about it.
|
|
108
175
|
*/
|
|
109
176
|
export declare function resetMode(): void;
|
|
110
|
-
/** The mode this process started in, for logging and for `permission/get_mode`. */
|
|
111
|
-
export declare function defaultMode(): PermissionMode;
|
|
112
177
|
//# sourceMappingURL=mode.d.ts.map
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
*/
|
|
45
45
|
import type { Context } from '@deepseek-ai/cordis';
|
|
46
46
|
import type { PermissionMode } from './permission.ts';
|
|
47
|
+
import type { SessionKey } from './permission/mode.ts';
|
|
47
48
|
/** Name this contribution registers under; unique across the assembled prompt. */
|
|
48
49
|
export declare const PERMISSION_CONTEXT_NAME = "aishell:permission-policy";
|
|
49
50
|
/**
|
|
@@ -76,12 +77,14 @@ export declare function permissionPolicyText(mode: PermissionMode | undefined):
|
|
|
76
77
|
*
|
|
77
78
|
* Deferred behind `ctx.inject` rather than declared in this plugin's own
|
|
78
79
|
* `inject`: the policy is an enhancement, and a deployment without the system
|
|
79
|
-
* prompt should not lose the tools over it.
|
|
80
|
-
*
|
|
81
|
-
*
|
|
80
|
+
* prompt should not lose the tools over it.
|
|
81
|
+
*
|
|
82
|
+
* `current` is called with the assembling agent's id, which is the Session the
|
|
83
|
+
* prompt is being built for — so a conversation in read-write is not told it is
|
|
84
|
+
* read-only because a neighbouring one is.
|
|
82
85
|
*
|
|
83
86
|
* @param ctx - host context.
|
|
84
|
-
* @param current - the mode
|
|
87
|
+
* @param current - the mode of the Session the assembly is for.
|
|
85
88
|
*/
|
|
86
|
-
export declare function registerPermissionPolicyContext(ctx: Context, current: () => PermissionMode | undefined): void;
|
|
89
|
+
export declare function registerPermissionPolicyContext(ctx: Context, current: (session: SessionKey | undefined) => PermissionMode | undefined): void;
|
|
87
90
|
//# sourceMappingURL=permission-context.d.ts.map
|
|
@@ -7,34 +7,67 @@
|
|
|
7
7
|
* credential route carries secrets: an authenticated browser-to-host HTTP
|
|
8
8
|
* round trip.
|
|
9
9
|
*
|
|
10
|
-
* `GET api/aishell/permission
|
|
11
|
-
* `POST api/aishell/permission`
|
|
10
|
+
* `GET api/aishell/permission?session=<id>` -> that Session's mode
|
|
11
|
+
* `POST api/aishell/permission` { session, mode } -> the applied change
|
|
12
|
+
* `GET api/aishell/permission/default` -> the posture
|
|
13
|
+
* `POST api/aishell/permission/default` { mode } -> the posture
|
|
14
|
+
*
|
|
15
|
+
* ## Why the Session is required and never inferred
|
|
16
|
+
*
|
|
17
|
+
* The mode belongs to one conversation, so a request that does not name one is
|
|
18
|
+
* a request this route cannot answer. A process-wide value would report or apply
|
|
19
|
+
* that value to conversations the caller was not looking at — the one thing
|
|
20
|
+
* per-Session modes exist to prevent. So an absent or unusable Session is
|
|
21
|
+
* refused with a 4xx, and a Session the store does not hold is answered `404`.
|
|
22
|
+
*
|
|
23
|
+
* ## The posture endpoint is separate
|
|
24
|
+
*
|
|
25
|
+
* Setting what new Sessions start in is a deployment decision, not a switch on
|
|
26
|
+
* one conversation; it takes its own path so a caller cannot reach it by
|
|
27
|
+
* omitting a field. It decides what Sessions created from now on begin with and
|
|
28
|
+
* leaves existing ones alone (see `permission/mode.ts`).
|
|
12
29
|
*
|
|
13
30
|
* ## How the mode is reached
|
|
14
31
|
*
|
|
15
|
-
* The deps are
|
|
16
|
-
*
|
|
17
|
-
* trip.
|
|
32
|
+
* The deps are functions over this plugin's own module state, so a switch takes
|
|
33
|
+
* effect before the next tool call starts rather than after a round trip.
|
|
18
34
|
*
|
|
19
35
|
* ## Errors are reported, not thrown
|
|
20
36
|
*
|
|
21
37
|
* The route answers 200 with `{ ok: false, error }` so the chip can show the
|
|
22
|
-
* message.
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
38
|
+
* message. A request the route cannot answer is refused with a 4xx instead:
|
|
39
|
+
* a missing or unusable Session is a malformed request, and one naming a
|
|
40
|
+
* Session the store does not hold is answered `404` rather than given a mode
|
|
41
|
+
* for a conversation that does not exist. The envelope is unchanged, because
|
|
42
|
+
* the client half already renders it and a shape change would be a second
|
|
43
|
+
* thing to keep in step.
|
|
26
44
|
*
|
|
27
45
|
* @module @huaweidevtools/aishell-dsh-deploy/permission-route
|
|
28
46
|
*/
|
|
29
47
|
import { type PermissionMode, type PermissionModeState, type PermissionModeChange } from './permission.ts';
|
|
48
|
+
import type { SessionKey } from './permission/mode.ts';
|
|
30
49
|
/** Route path, mounted under the host's authenticated `/api` fence. */
|
|
31
50
|
export declare const PERMISSION_PATH = "/api/aishell/permission";
|
|
51
|
+
/**
|
|
52
|
+
* Path for the posture new Sessions start in.
|
|
53
|
+
*
|
|
54
|
+
* A child of {@link PERMISSION_PATH}, registered separately: the fetch registry
|
|
55
|
+
* matches whole paths rather than prefixes, so a posture request cannot land on
|
|
56
|
+
* the conversation route by accident.
|
|
57
|
+
*/
|
|
58
|
+
export declare const PERMISSION_DEFAULT_PATH = "/api/aishell/permission/default";
|
|
32
59
|
/** What this route needs: the plugin's own mode state. */
|
|
33
60
|
export interface PermissionRouteDeps {
|
|
34
|
-
/**
|
|
35
|
-
readonly
|
|
36
|
-
/**
|
|
37
|
-
readonly
|
|
61
|
+
/** Whether a Session with this id is live. */
|
|
62
|
+
readonly known: (session: SessionKey) => boolean;
|
|
63
|
+
/** Read one Session's mode. */
|
|
64
|
+
readonly read: (session: SessionKey) => PermissionModeState;
|
|
65
|
+
/** Apply a Session's mode; returns the change so the browser can render it. */
|
|
66
|
+
readonly write: (session: SessionKey, mode: PermissionMode) => PermissionModeChange;
|
|
67
|
+
/** The posture new Sessions start in. */
|
|
68
|
+
readonly readDefault: () => PermissionMode;
|
|
69
|
+
/** Set the posture; returns the one it replaced. */
|
|
70
|
+
readonly writeDefault: (mode: PermissionMode) => PermissionMode;
|
|
38
71
|
}
|
|
39
72
|
/** A successful response: the mode now in effect. */
|
|
40
73
|
export interface PermissionStatus extends PermissionModeState {
|
|
@@ -43,9 +76,9 @@ export interface PermissionStatus extends PermissionModeState {
|
|
|
43
76
|
/**
|
|
44
77
|
* A failed response.
|
|
45
78
|
*
|
|
46
|
-
* Still carries no `mode
|
|
47
|
-
*
|
|
48
|
-
* answered
|
|
79
|
+
* Still carries no `mode`: validation failures are the only remaining source,
|
|
80
|
+
* but the rule stays — a request that could not be answered must not be
|
|
81
|
+
* answered with a guess.
|
|
49
82
|
*/
|
|
50
83
|
export interface PermissionFailure {
|
|
51
84
|
readonly ok: false;
|
|
@@ -53,18 +86,32 @@ export interface PermissionFailure {
|
|
|
53
86
|
readonly error: string;
|
|
54
87
|
}
|
|
55
88
|
/**
|
|
56
|
-
* Report
|
|
89
|
+
* Report one Session's mode.
|
|
90
|
+
*
|
|
91
|
+
* @param deps - route collaborators.
|
|
92
|
+
* @param request - the incoming GET; `session` names the conversation.
|
|
93
|
+
*/
|
|
94
|
+
export declare function handleGet(deps: PermissionRouteDeps, request: Request): Promise<Response>;
|
|
95
|
+
/**
|
|
96
|
+
* Apply one Session's mode.
|
|
97
|
+
*
|
|
98
|
+
* @param deps - route collaborators.
|
|
99
|
+
* @param request - the incoming POST; its body carries `{ session, mode }`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function handleSet(deps: PermissionRouteDeps, request: Request): Promise<Response>;
|
|
102
|
+
/**
|
|
103
|
+
* Report the posture new Sessions start in.
|
|
57
104
|
*
|
|
58
105
|
* @param deps - route collaborators.
|
|
59
106
|
*/
|
|
60
|
-
export declare function
|
|
107
|
+
export declare function handleGetDefault(deps: PermissionRouteDeps): Promise<Response>;
|
|
61
108
|
/**
|
|
62
|
-
*
|
|
109
|
+
* Set the posture new Sessions start in.
|
|
63
110
|
*
|
|
64
111
|
* @param deps - route collaborators.
|
|
65
112
|
* @param request - the incoming POST; its body carries `{ mode }`.
|
|
66
113
|
*/
|
|
67
|
-
export declare function
|
|
114
|
+
export declare function handleSetDefault(deps: PermissionRouteDeps, request: Request): Promise<Response>;
|
|
68
115
|
/**
|
|
69
116
|
* Build the route handlers.
|
|
70
117
|
*
|
|
@@ -72,7 +119,9 @@ export declare function setMode(deps: PermissionRouteDeps, request: Request): Pr
|
|
|
72
119
|
* @returns handlers for the fetch registry.
|
|
73
120
|
*/
|
|
74
121
|
export declare function createPermissionRoutes(deps: PermissionRouteDeps): {
|
|
75
|
-
get: () => Promise<Response>;
|
|
122
|
+
get: (request: Request) => Promise<Response>;
|
|
76
123
|
set: (request: Request) => Promise<Response>;
|
|
124
|
+
getDefault: () => Promise<Response>;
|
|
125
|
+
setDefault: (request: Request) => Promise<Response>;
|
|
77
126
|
};
|
|
78
127
|
//# sourceMappingURL=permission-route.d.ts.map
|
|
@@ -20,10 +20,6 @@ export type PermissionMode = (typeof PERMISSION_MODES)[number];
|
|
|
20
20
|
export interface PermissionModeState {
|
|
21
21
|
/** Mode now in effect. */
|
|
22
22
|
readonly mode: PermissionMode;
|
|
23
|
-
/** Mode this process started in. */
|
|
24
|
-
readonly default: PermissionMode;
|
|
25
|
-
/** Whether mutations are currently permitted. */
|
|
26
|
-
readonly writable: boolean;
|
|
27
23
|
}
|
|
28
24
|
/** Result of `POST api/aishell/permission`. */
|
|
29
25
|
export interface PermissionModeChange {
|
|
@@ -53,6 +53,10 @@ export declare function fail(message: string): CallToolResult;
|
|
|
53
53
|
* not reach any part of its implementation, including argument validation that
|
|
54
54
|
* might touch the filesystem. A tool declared in `CLOUD_MUTATING_TOOLS` is
|
|
55
55
|
* refused here in read-only mode and never starts.
|
|
56
|
+
*
|
|
57
|
+
* The handler then runs inside the Session's call context, so the signed-HTTP
|
|
58
|
+
* funnel — several layers down, with no Session parameter to pass — refuses
|
|
59
|
+
* against the same Session this gate just read.
|
|
56
60
|
*/
|
|
57
61
|
export declare function guard<TArgs extends Record<string, unknown> | undefined>(fn: (args: TArgs, ctx: ToolCtx) => Promise<ToolResult>, toolName?: string): (args: TArgs, ctx: ToolCtx) => Promise<ToolResult>;
|
|
58
62
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -3,9 +3,11 @@ import { z } from "zod";
|
|
|
3
3
|
/**
|
|
4
4
|
* Register this plugin's tools on the DSH tool registry.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
6
|
+
* ## What the set covers
|
|
7
7
|
*
|
|
8
|
-
*
|
|
8
|
+
* A deployment's lifecycle end to end: the workspace, the design check, the
|
|
9
|
+
* flavour and image lookup, the quote, the HuaweiCloud capability surface, and
|
|
10
|
+
* the terraform family that runs it.
|
|
9
11
|
*
|
|
10
12
|
* ## No tool accepts a price
|
|
11
13
|
*
|
package/lib/types/types.d.ts
CHANGED
|
@@ -72,6 +72,14 @@ export interface ToolContext {
|
|
|
72
72
|
* directory when the one the person picked has been removed.
|
|
73
73
|
*/
|
|
74
74
|
readonly sessionDirectory?: string;
|
|
75
|
+
/**
|
|
76
|
+
* The conversation this call is being made for, when the harness supplies one.
|
|
77
|
+
*
|
|
78
|
+
* Absent for a call made outside an agent — a direct invocation. The
|
|
79
|
+
* permission gates then judge it by the posture new Sessions start in, since
|
|
80
|
+
* there is no conversation whose own answer would apply.
|
|
81
|
+
*/
|
|
82
|
+
readonly sessionId?: string;
|
|
75
83
|
}
|
|
76
84
|
/** The context type the tool modules name. */
|
|
77
85
|
export type ToolCtx = ToolContext;
|
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.37";
|
|
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.37",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,22 +31,24 @@
|
|
|
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.37"
|
|
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
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
40
41
|
"@deepseek-ai/dsh-settings": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
41
42
|
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
42
43
|
"@deepseek-ai/dsh-tools": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
43
|
-
"@huaweidevtools/aishell-dsh-audit": "0.0.
|
|
44
|
+
"@huaweidevtools/aishell-dsh-audit": "0.0.37"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@deepseek-ai/cordis": "^4.1.0",
|
|
47
48
|
"@deepseek-ai/cordis-plugin-loader": "^1.1.0",
|
|
48
49
|
"@deepseek-ai/dsh-client-connection": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
49
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",
|
|
50
52
|
"@deepseek-ai/dsh-settings": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
51
53
|
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
52
54
|
"@deepseek-ai/dsh-tools": "0.2.2-rc.1 || 0.2.2-rc.2 || 0.2.2-rc.3",
|
|
@@ -54,7 +56,7 @@
|
|
|
54
56
|
"tsdown": "^0.10.0",
|
|
55
57
|
"typescript": "^5.7.0",
|
|
56
58
|
"zod": "^4.2.0",
|
|
57
|
-
"@huaweidevtools/aishell-dsh-audit": "0.0.
|
|
59
|
+
"@huaweidevtools/aishell-dsh-audit": "0.0.37"
|
|
58
60
|
},
|
|
59
61
|
"dsh": {
|
|
60
62
|
"bundle": {
|