dsh-aiterm 0.5.1 → 0.5.13
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/CONTRACTS.md +104 -22
- package/README.md +206 -26
- package/client/HistoryPanel.jsx +342 -29
- package/client/api.js +44 -3
- package/client/locale.js +40 -2
- package/cordis.patch.yml +1 -0
- package/lib/client.js +30 -30
- package/lib/host/autolog.js +107 -4
- package/lib/host/config.js +14 -0
- package/lib/host/disclosure.js +357 -0
- package/lib/host/exporter.js +447 -159
- package/lib/host/history-store.js +1735 -295
- package/lib/host/permission.js +13 -0
- package/lib/host/prompt.js +5 -2
- package/lib/host/registry.js +858 -76
- package/lib/host/routes.js +45 -2
- package/lib/host/tools.js +291 -22
- package/lib/index.js +4 -2
- package/package.json +2 -2
- package/scripts/smoke-client.mjs +193 -6
package/lib/host/permission.js
CHANGED
|
@@ -32,6 +32,8 @@
|
|
|
32
32
|
* @property {boolean} humanWriteBlocked derived; the human's keystrokes are refused
|
|
33
33
|
* @property {boolean} aiWriteBlocked derived; the AI's writes are refused
|
|
34
34
|
* @property {number} updatedAt
|
|
35
|
+
* @property {number} revision monotonic change counter (internal)
|
|
36
|
+
* @property {number} readRevision read-authorization revision (internal)
|
|
35
37
|
*/
|
|
36
38
|
|
|
37
39
|
/**
|
|
@@ -66,6 +68,8 @@ export function createPermission(config) {
|
|
|
66
68
|
humanWriteBlocked: false,
|
|
67
69
|
aiWriteBlocked: false,
|
|
68
70
|
updatedAt: Date.now(),
|
|
71
|
+
revision: 0,
|
|
72
|
+
readRevision: 0,
|
|
69
73
|
}
|
|
70
74
|
return derive(state, config)
|
|
71
75
|
}
|
|
@@ -96,6 +100,7 @@ export function expireIfIdle(state, now, config) {
|
|
|
96
100
|
state.lockOwner = null
|
|
97
101
|
state.lockExpiresAt = null
|
|
98
102
|
state.updatedAt = now
|
|
103
|
+
state.revision = (state.revision ?? 0) + 1
|
|
99
104
|
derive(state, config)
|
|
100
105
|
return true
|
|
101
106
|
}
|
|
@@ -165,6 +170,7 @@ export function noteAiWrite(state, config, now = Date.now()) {
|
|
|
165
170
|
if (state.lockOwner === 'ai') {
|
|
166
171
|
state.lockOwner = null
|
|
167
172
|
state.lockExpiresAt = null
|
|
173
|
+
state.revision = (state.revision ?? 0) + 1
|
|
168
174
|
derive(state, config)
|
|
169
175
|
return true
|
|
170
176
|
}
|
|
@@ -172,6 +178,7 @@ export function noteAiWrite(state, config, now = Date.now()) {
|
|
|
172
178
|
}
|
|
173
179
|
state.lockOwner = 'ai'
|
|
174
180
|
state.lockExpiresAt = now + config.aiLockIdleMs
|
|
181
|
+
state.revision = (state.revision ?? 0) + 1
|
|
175
182
|
derive(state, config)
|
|
176
183
|
return true
|
|
177
184
|
}
|
|
@@ -188,6 +195,8 @@ export function takeOver(state, config, now = Date.now()) {
|
|
|
188
195
|
state.lockOwner = 'human'
|
|
189
196
|
state.lockExpiresAt = null
|
|
190
197
|
state.updatedAt = now
|
|
198
|
+
state.revision = (state.revision ?? 0) + 1
|
|
199
|
+
state.readRevision = (state.readRevision ?? 0) + 1
|
|
191
200
|
derive(state, config)
|
|
192
201
|
return true
|
|
193
202
|
}
|
|
@@ -204,6 +213,8 @@ export function releaseLock(state, config, now = Date.now()) {
|
|
|
204
213
|
state.lockOwner = null
|
|
205
214
|
state.lockExpiresAt = null
|
|
206
215
|
state.updatedAt = now
|
|
216
|
+
state.revision = (state.revision ?? 0) + 1
|
|
217
|
+
state.readRevision = (state.readRevision ?? 0) + 1
|
|
207
218
|
derive(state, config)
|
|
208
219
|
return true
|
|
209
220
|
}
|
|
@@ -220,6 +231,8 @@ export function setAiAccess(state, aiAccess, config, now = Date.now()) {
|
|
|
220
231
|
if (state.aiAccess === aiAccess) return false
|
|
221
232
|
state.aiAccess = aiAccess
|
|
222
233
|
state.updatedAt = now
|
|
234
|
+
state.revision = (state.revision ?? 0) + 1
|
|
235
|
+
state.readRevision = (state.readRevision ?? 0) + 1
|
|
223
236
|
derive(state, config)
|
|
224
237
|
return true
|
|
225
238
|
}
|
package/lib/host/prompt.js
CHANGED
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Registered once the `systemPrompt` service exists, at the terminal-tool order
|
|
5
5
|
* so it sits next to the other terminal guidance. Kept short: it ships with
|
|
6
|
-
* every request.
|
|
6
|
+
* every request, so it is registered only in `full` mode. `progressive` mode
|
|
7
|
+
* folds the same rules into the always-resident `aiterm_discover` description
|
|
8
|
+
* (`DISCOVER_TOOL_DESCRIPTION` in `./tools.js`): a separate section there would
|
|
9
|
+
* duplicate guidance the model already receives with the tool schema.
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
12
|
/** Stable prompt section name. */
|
|
10
13
|
export const PROMPT_SECTION_NAME = 'tool:aiterm'
|
|
11
14
|
|
|
12
|
-
/** Guidance text shown to the model. */
|
|
15
|
+
/** Guidance text shown to the model in `full` mode. */
|
|
13
16
|
export const PROMPT_TEXT = [
|
|
14
17
|
'SSH/Telnet sessions opened in the user\'s SSH/Telnet panel are shared with the user: `aiterm_list` shows them with their connection state and the AI permission the user granted.',
|
|
15
18
|
'Each session has its own AI permission: read-only (只读) lets you read output but never send input; write-only (只写) lets you send input but never read output; read-write (读写) allows both. Only the user can change it — a refusal is a policy decision, so report it instead of retrying or working around it.',
|