@deveye/types 0.17.1 → 0.18.0
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/package.json +1 -1
- package/src/domain/deviceDocker.ts +195 -0
- package/src/domain/featureRegistry.ts +61 -0
- package/src/domain/feedback.ts +159 -0
- package/src/features/agent.ts +47 -0
- package/src/features/feedback.ts +86 -0
- package/src/features/live.ts +47 -0
- package/src/features/registry.ts +2 -0
- package/src/http/auth.ts +7 -1
- package/src/index.ts +100 -1
- package/src/protocol/agent.ts +114 -0
- package/src/sdk/client-ambient.d.ts +22 -0
- package/src/sdk/client.ts +13 -0
- package/src/sdk/manifest.test.ts +7 -1
- package/src/sdk/manifest.ts +24 -2
- package/src/sdk/net.test.ts +51 -0
- package/src/sdk/net.ts +76 -0
- package/src/sdk/server.ts +29 -0
- package/src/sdk/testing.ts +13 -1
package/package.json
CHANGED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Container management on a device — entities shared by the agent, server and
|
|
5
|
+
* client.
|
|
6
|
+
*
|
|
7
|
+
* The agent drives the engines through their CLI (`docker` / `podman`), the way
|
|
8
|
+
* it already reads container logs: no daemon socket, no `bollard`, and podman
|
|
9
|
+
* support comes free because both take the same flags. Go templates rather than
|
|
10
|
+
* `--format json`: the JSON field names diverge between the two engines, the
|
|
11
|
+
* templates do not.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** A container engine the agent found on the host. */
|
|
15
|
+
export const containerEngineSchema = z.enum(['docker', 'podman']);
|
|
16
|
+
export type ContainerEngine = z.infer<typeof containerEngineSchema>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Normalised container state. `unknown` covers whatever an engine prints that
|
|
20
|
+
* we do not model, so an unexpected word never drops the container from the
|
|
21
|
+
* inventory.
|
|
22
|
+
*/
|
|
23
|
+
export const containerStateSchema = z.enum([
|
|
24
|
+
'running',
|
|
25
|
+
'exited',
|
|
26
|
+
'paused',
|
|
27
|
+
'created',
|
|
28
|
+
'restarting',
|
|
29
|
+
'removing',
|
|
30
|
+
'dead',
|
|
31
|
+
'unknown'
|
|
32
|
+
]);
|
|
33
|
+
export type ContainerState = z.infer<typeof containerStateSchema>;
|
|
34
|
+
|
|
35
|
+
/** One container, running or not. */
|
|
36
|
+
export const dockerContainerSchema = z.object({
|
|
37
|
+
engine: containerEngineSchema,
|
|
38
|
+
/** Full (untruncated) container id — what every action addresses. */
|
|
39
|
+
id: z.string().min(1).max(128),
|
|
40
|
+
name: z.string().max(256),
|
|
41
|
+
image: z.string().max(512),
|
|
42
|
+
state: containerStateSchema,
|
|
43
|
+
/** The engine's own wording ("Up 3 days", "Exited (0) 2 hours ago"). */
|
|
44
|
+
status: z.string().max(256),
|
|
45
|
+
/** Published port mappings, as the engine prints them. */
|
|
46
|
+
ports: z.string().max(512),
|
|
47
|
+
createdAt: z.string().max(64),
|
|
48
|
+
/**
|
|
49
|
+
* Compose labels, when the container is compose-managed. `recreate` needs
|
|
50
|
+
* the three of them: without a compose project there is no faithful way to
|
|
51
|
+
* rebuild a container's run configuration.
|
|
52
|
+
*/
|
|
53
|
+
composeProject: z.string().max(256).nullable(),
|
|
54
|
+
composeService: z.string().max(256).nullable(),
|
|
55
|
+
composeWorkingDir: z.string().max(1024).nullable()
|
|
56
|
+
});
|
|
57
|
+
export type DockerContainer = z.infer<typeof dockerContainerSchema>;
|
|
58
|
+
|
|
59
|
+
/** One image present on the host. */
|
|
60
|
+
export const dockerImageSchema = z.object({
|
|
61
|
+
engine: containerEngineSchema,
|
|
62
|
+
id: z.string().min(1).max(128),
|
|
63
|
+
/** `repository:tag`, or `<none>:<none>` for a dangling layer. */
|
|
64
|
+
reference: z.string().max(512),
|
|
65
|
+
/** Human size as the engine prints it ("128MB"). */
|
|
66
|
+
size: z.string().max(64),
|
|
67
|
+
createdAt: z.string().max(64),
|
|
68
|
+
/** Untagged leftover: the prime candidate for a cleanup. */
|
|
69
|
+
dangling: z.boolean()
|
|
70
|
+
});
|
|
71
|
+
export type DockerImage = z.infer<typeof dockerImageSchema>;
|
|
72
|
+
|
|
73
|
+
export const dockerVolumeSchema = z.object({
|
|
74
|
+
engine: containerEngineSchema,
|
|
75
|
+
name: z.string().min(1).max(256),
|
|
76
|
+
driver: z.string().max(64),
|
|
77
|
+
mountpoint: z.string().max(1024)
|
|
78
|
+
});
|
|
79
|
+
export type DockerVolume = z.infer<typeof dockerVolumeSchema>;
|
|
80
|
+
|
|
81
|
+
export const dockerNetworkSchema = z.object({
|
|
82
|
+
engine: containerEngineSchema,
|
|
83
|
+
id: z.string().min(1).max(128),
|
|
84
|
+
name: z.string().min(1).max(256),
|
|
85
|
+
driver: z.string().max(64),
|
|
86
|
+
scope: z.string().max(64)
|
|
87
|
+
});
|
|
88
|
+
export type DockerNetwork = z.infer<typeof dockerNetworkSchema>;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* What one engine answered. `reachable` false means its binary is there but the
|
|
92
|
+
* daemon refused (socket permissions, daemon down): the UI must say that rather
|
|
93
|
+
* than "no containers", which is what the user would otherwise read.
|
|
94
|
+
*/
|
|
95
|
+
export const dockerEngineStatusSchema = z.object({
|
|
96
|
+
engine: containerEngineSchema,
|
|
97
|
+
reachable: z.boolean(),
|
|
98
|
+
/** Engine version when reachable, else why it is not. */
|
|
99
|
+
version: z.string().max(128).nullable(),
|
|
100
|
+
error: z.string().max(255).nullable()
|
|
101
|
+
});
|
|
102
|
+
export type DockerEngineStatus = z.infer<typeof dockerEngineStatusSchema>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A device's whole container inventory. Empty `engines` means neither binary is
|
|
106
|
+
* installed — the honest "this host does not do containers".
|
|
107
|
+
*/
|
|
108
|
+
export const dockerInventorySchema = z.object({
|
|
109
|
+
engines: z.array(dockerEngineStatusSchema),
|
|
110
|
+
containers: z.array(dockerContainerSchema),
|
|
111
|
+
images: z.array(dockerImageSchema),
|
|
112
|
+
volumes: z.array(dockerVolumeSchema),
|
|
113
|
+
networks: z.array(dockerNetworkSchema)
|
|
114
|
+
});
|
|
115
|
+
export type DockerInventory = z.infer<typeof dockerInventorySchema>;
|
|
116
|
+
|
|
117
|
+
/** Live resource use of one running container, from `docker stats --no-stream`. */
|
|
118
|
+
export const dockerStatSchema = z.object({
|
|
119
|
+
engine: containerEngineSchema,
|
|
120
|
+
id: z.string().min(1).max(128),
|
|
121
|
+
/** Percent of a host CPU; `null` when the engine printed something unparseable. */
|
|
122
|
+
cpuPercent: z.number().nullable(),
|
|
123
|
+
memUsedBytes: z.number().int().nonnegative().nullable(),
|
|
124
|
+
memLimitBytes: z.number().int().nonnegative().nullable(),
|
|
125
|
+
memPercent: z.number().nullable(),
|
|
126
|
+
netRxBytes: z.number().int().nonnegative().nullable(),
|
|
127
|
+
netTxBytes: z.number().int().nonnegative().nullable(),
|
|
128
|
+
blockReadBytes: z.number().int().nonnegative().nullable(),
|
|
129
|
+
blockWriteBytes: z.number().int().nonnegative().nullable(),
|
|
130
|
+
pids: z.number().int().nonnegative().nullable()
|
|
131
|
+
});
|
|
132
|
+
export type DockerStat = z.infer<typeof dockerStatSchema>;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* What may be asked of an engine. A closed list, mirrored by a `match` in the
|
|
136
|
+
* agent: no argument but the target's identifier ever reaches a command line,
|
|
137
|
+
* and there is no shell. Anything beyond this list is the remote terminal's job,
|
|
138
|
+
* which is a separate permission.
|
|
139
|
+
*/
|
|
140
|
+
export const dockerActionSchema = z.enum([
|
|
141
|
+
// Cycle de vie d'un conteneur.
|
|
142
|
+
'start',
|
|
143
|
+
'stop',
|
|
144
|
+
'restart',
|
|
145
|
+
'pause',
|
|
146
|
+
'unpause',
|
|
147
|
+
'kill',
|
|
148
|
+
// Suppressions, chacune sur sa cible.
|
|
149
|
+
'removeContainer',
|
|
150
|
+
'removeImage',
|
|
151
|
+
'removeVolume',
|
|
152
|
+
'removeNetwork',
|
|
153
|
+
// Nettoyages, sans cible.
|
|
154
|
+
'pruneContainers',
|
|
155
|
+
'pruneImages',
|
|
156
|
+
'pruneVolumes',
|
|
157
|
+
'pruneNetworks',
|
|
158
|
+
'pruneBuildCache',
|
|
159
|
+
// Mise à jour d'un service.
|
|
160
|
+
'pull',
|
|
161
|
+
'recreate'
|
|
162
|
+
]);
|
|
163
|
+
export type DockerAction = z.infer<typeof dockerActionSchema>;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Actions that stream their output and can run for minutes. The server holds a
|
|
167
|
+
* per-device lock on these, and the UI follows them live; the others answer in
|
|
168
|
+
* one frame.
|
|
169
|
+
*/
|
|
170
|
+
export const DOCKER_LONG_ACTIONS = [
|
|
171
|
+
'pull',
|
|
172
|
+
'recreate',
|
|
173
|
+
'pruneContainers',
|
|
174
|
+
'pruneImages',
|
|
175
|
+
'pruneVolumes',
|
|
176
|
+
'pruneNetworks',
|
|
177
|
+
'pruneBuildCache'
|
|
178
|
+
] as const satisfies readonly DockerAction[];
|
|
179
|
+
|
|
180
|
+
/** Actions that need no target: they act on the whole engine. */
|
|
181
|
+
export const DOCKER_UNTARGETED_ACTIONS = [
|
|
182
|
+
'pruneContainers',
|
|
183
|
+
'pruneImages',
|
|
184
|
+
'pruneVolumes',
|
|
185
|
+
'pruneNetworks',
|
|
186
|
+
'pruneBuildCache'
|
|
187
|
+
] as const satisfies readonly DockerAction[];
|
|
188
|
+
|
|
189
|
+
export function isLongDockerAction(action: DockerAction): boolean {
|
|
190
|
+
return (DOCKER_LONG_ACTIONS as readonly DockerAction[]).includes(action);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export function isUntargetedDockerAction(action: DockerAction): boolean {
|
|
194
|
+
return (DOCKER_UNTARGETED_ACTIONS as readonly DockerAction[]).includes(action);
|
|
195
|
+
}
|
|
@@ -39,6 +39,13 @@ export interface FeatureDescriptor {
|
|
|
39
39
|
* d'écran (« Réglages de ce service »). Absent quand `hasItems` est faux.
|
|
40
40
|
*/
|
|
41
41
|
itemNoun?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Le genre de `itemNoun`, sans quoi les intitulés qui le précèdent d'un
|
|
44
|
+
* déterminant ne peuvent pas s'accorder (« cette note » contre « cet
|
|
45
|
+
* appareil »). Masculin par défaut : c'est le cas le plus courant, et un
|
|
46
|
+
* module qui l'omet lit au moins juste la moitié du temps.
|
|
47
|
+
*/
|
|
48
|
+
itemNounGender?: 'm' | 'f';
|
|
42
49
|
/**
|
|
43
50
|
* Les sources de la fonctionnalité : des réglages d'espace réutilisables
|
|
44
51
|
* (un jeton, une destination) que chaque élément ne fait que désigner.
|
|
@@ -117,6 +124,7 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
117
124
|
notifies: false,
|
|
118
125
|
hasItems: true,
|
|
119
126
|
itemNoun: 'note',
|
|
127
|
+
itemNounGender: 'f',
|
|
120
128
|
shareTier: 'perItem'
|
|
121
129
|
},
|
|
122
130
|
{
|
|
@@ -183,6 +191,7 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
183
191
|
notifies: true,
|
|
184
192
|
hasItems: true,
|
|
185
193
|
itemNoun: 'cible',
|
|
194
|
+
itemNounGender: 'f',
|
|
186
195
|
sources: {
|
|
187
196
|
hint: 'Les accès Dokploy de l’espace (adresse de l’instance et clé d’API). Chaque cible en désigne un ; corriger un accès corrige d’un coup toutes les cibles qui s’en servent.'
|
|
188
197
|
},
|
|
@@ -197,6 +206,7 @@ export const FEATURE_REGISTRY: readonly (FeatureDescriptor & { id: WorkspaceFeat
|
|
|
197
206
|
notifies: true,
|
|
198
207
|
hasItems: true,
|
|
199
208
|
itemNoun: 'base',
|
|
209
|
+
itemNounGender: 'f',
|
|
200
210
|
shareTier: 'open'
|
|
201
211
|
},
|
|
202
212
|
{
|
|
@@ -309,6 +319,57 @@ export function featureLabel(id: FeatureId): string {
|
|
|
309
319
|
return featureDescriptor(id).label;
|
|
310
320
|
}
|
|
311
321
|
|
|
322
|
+
/**
|
|
323
|
+
* Élision devant voyelle ou h muet. Le `h` aspiré ferait exception, mais aucun
|
|
324
|
+
* nom d'élément n'en commence, et un module qui en introduirait un lirait mal
|
|
325
|
+
* une fois plutôt que de faire porter le doute à tous les autres.
|
|
326
|
+
*/
|
|
327
|
+
function elides(noun: string): boolean {
|
|
328
|
+
const first = noun
|
|
329
|
+
.normalize('NFD')
|
|
330
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
331
|
+
.charAt(0)
|
|
332
|
+
.toLowerCase();
|
|
333
|
+
return 'aeiouyh'.includes(first);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function capitalise(s: string): string {
|
|
337
|
+
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Le nom d'un élément décliné, pour les intitulés qui le précèdent d'un
|
|
342
|
+
* déterminant : « cet appareil », « cette note », « le dépôt ». Sans ces
|
|
343
|
+
* formes, une phrase écrite une fois pour toutes lit faux dès que le nom
|
|
344
|
+
* change de genre ou commence par une voyelle. Le repli est « élément »,
|
|
345
|
+
* masculin, comme le mot lui-même.
|
|
346
|
+
*/
|
|
347
|
+
export function itemNounForms(id: FeatureId): {
|
|
348
|
+
/** « appareil » */
|
|
349
|
+
noun: string;
|
|
350
|
+
/** « cet appareil » */
|
|
351
|
+
dem: string;
|
|
352
|
+
/** « Cet appareil » */
|
|
353
|
+
Dem: string;
|
|
354
|
+
/** « l'appareil » */
|
|
355
|
+
def: string;
|
|
356
|
+
/** « L'appareil » */
|
|
357
|
+
Def: string;
|
|
358
|
+
/** « de l'appareil » */
|
|
359
|
+
ofThe: string;
|
|
360
|
+
} {
|
|
361
|
+
const d = maybeFeatureDescriptor(id);
|
|
362
|
+
const noun = d?.itemNoun ?? 'élément';
|
|
363
|
+
const feminine = (d?.itemNounGender ?? 'm') === 'f';
|
|
364
|
+
const vowel = elides(noun);
|
|
365
|
+
|
|
366
|
+
const dem = feminine ? `cette ${noun}` : vowel ? `cet ${noun}` : `ce ${noun}`;
|
|
367
|
+
const def = vowel ? `l\u2019${noun}` : `${feminine ? 'la' : 'le'} ${noun}`;
|
|
368
|
+
const ofThe = vowel ? `de l\u2019${noun}` : feminine ? `de la ${noun}` : `du ${noun}`;
|
|
369
|
+
|
|
370
|
+
return { noun, dem, Dem: capitalise(dem), def, Def: capitalise(def), ofThe };
|
|
371
|
+
}
|
|
372
|
+
|
|
312
373
|
/**
|
|
313
374
|
* Les deux `never` : `password` vit toujours à l'étage gardé ; `cloudsync`
|
|
314
375
|
* range ses contenus dans un magasin de blobs chiffrés par la BMK, pas par une
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* User-submitted feedback: a free-form remark, or a bug report carrying the
|
|
5
|
+
* technical snapshot the client assembled at submit time.
|
|
6
|
+
*
|
|
7
|
+
* Stored in the clear, unlike feature data. The reader is the global admin, not
|
|
8
|
+
* the author: sealing a report with the author's key would make it unreadable
|
|
9
|
+
* by the only person meant to act on it.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/** What a report claims to be. Only `bug` carries a snapshot. */
|
|
13
|
+
export const feedbackKindSchema = z.enum(['general', 'bug']);
|
|
14
|
+
export type FeedbackKind = z.infer<typeof feedbackKindSchema>;
|
|
15
|
+
|
|
16
|
+
/** Where a report stands in triage. `new` until an admin touches it. */
|
|
17
|
+
export const feedbackStatusSchema = z.enum(['new', 'open', 'done']);
|
|
18
|
+
export type FeedbackStatus = z.infer<typeof feedbackStatusSchema>;
|
|
19
|
+
|
|
20
|
+
export const FEEDBACK_MESSAGE_MAX = 4000;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Ring sizes the client keeps in memory. Small on purpose: what precedes a bug
|
|
24
|
+
* by more than a handful of steps rarely explains it, and every entry travels.
|
|
25
|
+
*/
|
|
26
|
+
export const FEEDBACK_REQUESTS_KEPT = 30;
|
|
27
|
+
export const FEEDBACK_ERRORS_KEPT = 10;
|
|
28
|
+
export const FEEDBACK_VIEWS_KEPT = 10;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* One request the client saw go by. Neither its body nor its response: only
|
|
32
|
+
* enough to retrace a sequence. Bodies would carry passwords, decrypted content
|
|
33
|
+
* and secrets into a report anyone with the admin role can read.
|
|
34
|
+
*/
|
|
35
|
+
export const feedbackRequestTraceSchema = z.object({
|
|
36
|
+
/** Milliseconds before the report was opened (0 = just now). */
|
|
37
|
+
ago: z.number().int().nonnegative(),
|
|
38
|
+
/** `ws` for a feature command, `http` for an auth route. */
|
|
39
|
+
channel: z.enum(['ws', 'http']),
|
|
40
|
+
/** Command name, or method and path. */
|
|
41
|
+
target: z.string().max(200),
|
|
42
|
+
durationMs: z.number().int().nonnegative(),
|
|
43
|
+
/** `ok`, or the protocol error code that came back. */
|
|
44
|
+
outcome: z.string().max(40)
|
|
45
|
+
});
|
|
46
|
+
export type FeedbackRequestTrace = z.infer<typeof feedbackRequestTraceSchema>;
|
|
47
|
+
|
|
48
|
+
/** An error nothing caught: a render crash, or a rejected promise. */
|
|
49
|
+
export const feedbackErrorTraceSchema = z.object({
|
|
50
|
+
ago: z.number().int().nonnegative(),
|
|
51
|
+
source: z.enum(['error', 'rejection']),
|
|
52
|
+
message: z.string().max(500),
|
|
53
|
+
/** File and position, when the browser gives them. */
|
|
54
|
+
origin: z.string().max(300).nullable(),
|
|
55
|
+
/** Truncated stack; null when the browser exposes none. */
|
|
56
|
+
stack: z.string().max(2000).nullable()
|
|
57
|
+
});
|
|
58
|
+
export type FeedbackErrorTrace = z.infer<typeof feedbackErrorTraceSchema>;
|
|
59
|
+
|
|
60
|
+
/** A view the user opened, in order: the shortest path to a reproduction. */
|
|
61
|
+
export const feedbackViewTraceSchema = z.object({
|
|
62
|
+
ago: z.number().int().nonnegative(),
|
|
63
|
+
/** View id (`logs`, `x-audit`, `device:…`), or `home` when it closed. */
|
|
64
|
+
view: z.string().max(64)
|
|
65
|
+
});
|
|
66
|
+
export type FeedbackViewTrace = z.infer<typeof feedbackViewTraceSchema>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The technical report attached to a bug. Assembled client-side, so every field
|
|
70
|
+
* is what the browser was willing to say — `null` means "not exposed here", not
|
|
71
|
+
* "zero". The server never trusts it for identity: uid, IP and its own version
|
|
72
|
+
* are stamped server-side.
|
|
73
|
+
*/
|
|
74
|
+
export const feedbackSnapshotSchema = z.object({
|
|
75
|
+
browser: z.object({
|
|
76
|
+
/** From `userAgentData` when present; the raw UA is always kept too. */
|
|
77
|
+
name: z.string().max(120).nullable(),
|
|
78
|
+
version: z.string().max(40).nullable(),
|
|
79
|
+
platform: z.string().max(80).nullable(),
|
|
80
|
+
mobile: z.boolean().nullable(),
|
|
81
|
+
userAgent: z.string().max(500),
|
|
82
|
+
language: z.string().max(40),
|
|
83
|
+
timezone: z.string().max(80),
|
|
84
|
+
cores: z.number().int().nonnegative().nullable(),
|
|
85
|
+
/** `navigator.deviceMemory`, in GiB. Chromium only. */
|
|
86
|
+
memoryGb: z.number().nonnegative().nullable(),
|
|
87
|
+
online: z.boolean()
|
|
88
|
+
}),
|
|
89
|
+
viewport: z.object({
|
|
90
|
+
width: z.number().int().nonnegative(),
|
|
91
|
+
height: z.number().int().nonnegative(),
|
|
92
|
+
pixelRatio: z.number().nonnegative(),
|
|
93
|
+
reducedMotion: z.boolean(),
|
|
94
|
+
colorScheme: z.enum(['light', 'dark'])
|
|
95
|
+
}),
|
|
96
|
+
app: z.object({
|
|
97
|
+
/**
|
|
98
|
+
* The bundle the tab is running. Compared to the server's own version
|
|
99
|
+
* on read: a tab left open across a deploy explains a class of bugs by
|
|
100
|
+
* itself.
|
|
101
|
+
*/
|
|
102
|
+
clientVersion: z.string().max(40),
|
|
103
|
+
/** View open when the report was written; null on the dashboard. */
|
|
104
|
+
view: z.string().max(64).nullable(),
|
|
105
|
+
workspaceId: z.number().int().positive().nullable(),
|
|
106
|
+
/** WebSocket state (`open`, `closed`, `error`…). */
|
|
107
|
+
connection: z.string().max(24),
|
|
108
|
+
/** Seconds since this tab loaded. */
|
|
109
|
+
sessionAgeSeconds: z.number().int().nonnegative(),
|
|
110
|
+
/** Path only — the app carries no query but the active workspace. */
|
|
111
|
+
path: z.string().max(300)
|
|
112
|
+
}),
|
|
113
|
+
requests: z.array(feedbackRequestTraceSchema).max(FEEDBACK_REQUESTS_KEPT),
|
|
114
|
+
errors: z.array(feedbackErrorTraceSchema).max(FEEDBACK_ERRORS_KEPT),
|
|
115
|
+
views: z.array(feedbackViewTraceSchema).max(FEEDBACK_VIEWS_KEPT)
|
|
116
|
+
});
|
|
117
|
+
export type FeedbackSnapshot = z.infer<typeof feedbackSnapshotSchema>;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* A report as served to the admin view. `username` and `handledByName` are
|
|
121
|
+
* resolved server-side from the ids (null when the account is gone).
|
|
122
|
+
*/
|
|
123
|
+
export const feedbackEntrySchema = z.object({
|
|
124
|
+
id: z.number().int().positive(),
|
|
125
|
+
/** Submission time, unix epoch seconds. */
|
|
126
|
+
created: z.number().int().nonnegative(),
|
|
127
|
+
kind: feedbackKindSchema,
|
|
128
|
+
status: feedbackStatusSchema,
|
|
129
|
+
uid: z.number().int().nonnegative(),
|
|
130
|
+
username: z.string().nullable(),
|
|
131
|
+
/** Workspace open at submit time — context only, never a scope. */
|
|
132
|
+
workspaceId: z.number().int().positive().nullable(),
|
|
133
|
+
message: z.string(),
|
|
134
|
+
ip: z.string(),
|
|
135
|
+
/** Server version at submit time. */
|
|
136
|
+
appVersion: z.string(),
|
|
137
|
+
/** The bug report; null for a plain remark. */
|
|
138
|
+
snapshot: feedbackSnapshotSchema.nullable(),
|
|
139
|
+
handledAt: z.number().int().nonnegative().nullable(),
|
|
140
|
+
handledBy: z.number().int().positive().nullable(),
|
|
141
|
+
handledByName: z.string().nullable()
|
|
142
|
+
});
|
|
143
|
+
export type FeedbackEntry = z.infer<typeof feedbackEntrySchema>;
|
|
144
|
+
|
|
145
|
+
/** Raw `feedback` row as stored. `snapshot` is MySQL JSON (parsed by the driver). */
|
|
146
|
+
export interface FeedbackRow {
|
|
147
|
+
id: number;
|
|
148
|
+
uid: number;
|
|
149
|
+
workspace_id: number | null;
|
|
150
|
+
kind: string;
|
|
151
|
+
message: string;
|
|
152
|
+
snapshot: unknown;
|
|
153
|
+
status: string;
|
|
154
|
+
ip: string;
|
|
155
|
+
app_version: string;
|
|
156
|
+
created: number;
|
|
157
|
+
handled_at: number | null;
|
|
158
|
+
handled_by: number | null;
|
|
159
|
+
}
|
package/src/features/agent.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { deviceSchema, terminalUser } from '../domain/device';
|
|
3
3
|
import { fileMutateOpSchema, fileSearchFilterSchema } from '../domain/deviceFiles';
|
|
4
|
+
import { containerEngineSchema, dockerActionSchema } from '../domain/deviceDocker';
|
|
4
5
|
import {
|
|
5
6
|
deviceLogAnchorSchema,
|
|
6
7
|
deviceLogFilterSchema,
|
|
@@ -136,6 +137,49 @@ export const agentUpgradePackages = {
|
|
|
136
137
|
output: z.object({ ok: z.boolean() })
|
|
137
138
|
};
|
|
138
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Ask the agent for its container inventory (containers, images, volumes,
|
|
142
|
+
* networks, plus which engines answered). Needs the `docker` permission on
|
|
143
|
+
* Appareils + agent online. The command only acknowledges; the inventory
|
|
144
|
+
* arrives as a `device.dockerInventory` push event (the caller must be
|
|
145
|
+
* subscribed to the device).
|
|
146
|
+
*/
|
|
147
|
+
export const agentDockerInventory = {
|
|
148
|
+
command: 'agent.dockerInventory' as const,
|
|
149
|
+
input: z.object({ deviceId }),
|
|
150
|
+
output: z.object({ ok: z.boolean() })
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Ask the agent for a one-shot resource sample of the running containers. The
|
|
155
|
+
* panel polls it while it is open; nothing is stored, the series lives in the
|
|
156
|
+
* browser. Streams back as `device.dockerStats`.
|
|
157
|
+
*/
|
|
158
|
+
export const agentDockerStats = {
|
|
159
|
+
command: 'agent.dockerStats' as const,
|
|
160
|
+
input: z.object({ deviceId }),
|
|
161
|
+
output: z.object({ ok: z.boolean() })
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Act on a container, image, volume or network. `opId` correlates the streamed
|
|
166
|
+
* output (`device.dockerProgress`) and the outcome (`device.dockerDone`) back
|
|
167
|
+
* to this request. The long actions (pull, recreate, the prunes) take a
|
|
168
|
+
* per-device lock: a second one is refused while the first runs.
|
|
169
|
+
*/
|
|
170
|
+
export const agentDockerAction = {
|
|
171
|
+
command: 'agent.dockerAction' as const,
|
|
172
|
+
input: z.object({
|
|
173
|
+
deviceId,
|
|
174
|
+
opId: z.string().min(1).max(64),
|
|
175
|
+
engine: containerEngineSchema,
|
|
176
|
+
action: dockerActionSchema,
|
|
177
|
+
/** L'identifiant de la cible ; nul pour les nettoyages, qui n'en ont pas. */
|
|
178
|
+
target: z.string().max(512).nullable().optional()
|
|
179
|
+
}),
|
|
180
|
+
output: z.object({ ok: z.boolean() })
|
|
181
|
+
};
|
|
182
|
+
|
|
139
183
|
/**
|
|
140
184
|
* Ask the agent to enumerate the log sources present on the device (system journal,
|
|
141
185
|
* Docker containers, log files…). Needs the `logs` permission on Appareils +
|
|
@@ -295,6 +339,9 @@ export const agentCommands = [
|
|
|
295
339
|
agentElevate,
|
|
296
340
|
agentDropPrivileges,
|
|
297
341
|
agentUpdate,
|
|
342
|
+
agentDockerInventory,
|
|
343
|
+
agentDockerStats,
|
|
344
|
+
agentDockerAction,
|
|
298
345
|
agentListPackages,
|
|
299
346
|
agentUpgradePackages,
|
|
300
347
|
agentLogSources,
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import {
|
|
3
|
+
feedbackEntrySchema,
|
|
4
|
+
feedbackKindSchema,
|
|
5
|
+
feedbackSnapshotSchema,
|
|
6
|
+
feedbackStatusSchema,
|
|
7
|
+
FEEDBACK_MESSAGE_MAX
|
|
8
|
+
} from '../domain/feedback';
|
|
9
|
+
|
|
10
|
+
/** Upper bound on a single page of results (the server clamps to this). */
|
|
11
|
+
export const FEEDBACK_PAGE_MAX = 100;
|
|
12
|
+
export const FEEDBACK_PAGE_DEFAULT = 30;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Submit a report. Open to any signed-in account, and the only command here
|
|
16
|
+
* that is: reading feedback is an admin matter, writing one is not.
|
|
17
|
+
*
|
|
18
|
+
* The snapshot only makes sense on a `bug` — the server drops it otherwise, so
|
|
19
|
+
* a remark can never quietly carry a technical report.
|
|
20
|
+
*/
|
|
21
|
+
export const feedbackSubmit = {
|
|
22
|
+
command: 'feedback.submit' as const,
|
|
23
|
+
input: z.object({
|
|
24
|
+
kind: feedbackKindSchema,
|
|
25
|
+
message: z.string().min(1).max(FEEDBACK_MESSAGE_MAX),
|
|
26
|
+
snapshot: feedbackSnapshotSchema.nullable().default(null)
|
|
27
|
+
}),
|
|
28
|
+
output: z.object({ id: z.number().int().positive() })
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* AND-combined filter for the admin list; every field is optional. All omitted
|
|
33
|
+
* → the unfiltered, newest-first feed.
|
|
34
|
+
*/
|
|
35
|
+
export const feedbackFilterSchema = z.object({
|
|
36
|
+
kind: feedbackKindSchema.optional(),
|
|
37
|
+
status: feedbackStatusSchema.optional(),
|
|
38
|
+
/** Restrict to one author. */
|
|
39
|
+
uid: z.number().int().positive().optional(),
|
|
40
|
+
/** Case-insensitive substring over the message. */
|
|
41
|
+
search: z.string().max(200).optional()
|
|
42
|
+
});
|
|
43
|
+
export type FeedbackFilter = z.infer<typeof feedbackFilterSchema>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Page through reports newest-first. Admin-only. `total` counts what matches
|
|
47
|
+
* the filter, ignoring paging; `hasMore` says whether a page follows.
|
|
48
|
+
*/
|
|
49
|
+
export const feedbackList = {
|
|
50
|
+
command: 'feedback.list' as const,
|
|
51
|
+
input: feedbackFilterSchema.extend({
|
|
52
|
+
limit: z.number().int().positive().max(FEEDBACK_PAGE_MAX).optional(),
|
|
53
|
+
offset: z.number().int().nonnegative().optional()
|
|
54
|
+
}),
|
|
55
|
+
output: z.object({
|
|
56
|
+
entries: z.array(feedbackEntrySchema),
|
|
57
|
+
total: z.number().int().nonnegative(),
|
|
58
|
+
hasMore: z.boolean(),
|
|
59
|
+
/** How many are still untouched, whatever the filter: the badge count. */
|
|
60
|
+
pending: z.number().int().nonnegative()
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** Move a report through triage. Admin-only. */
|
|
65
|
+
export const feedbackSetStatus = {
|
|
66
|
+
command: 'feedback.setStatus' as const,
|
|
67
|
+
input: z.object({
|
|
68
|
+
id: z.number().int().positive(),
|
|
69
|
+
status: feedbackStatusSchema
|
|
70
|
+
}),
|
|
71
|
+
output: z.object({ entry: feedbackEntrySchema })
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** Drop a report for good. Admin-only. */
|
|
75
|
+
export const feedbackDelete = {
|
|
76
|
+
command: 'feedback.delete' as const,
|
|
77
|
+
input: z.object({ id: z.number().int().positive() }),
|
|
78
|
+
output: z.object({ deleted: z.literal(true) })
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const feedbackCommands = [
|
|
82
|
+
feedbackSubmit,
|
|
83
|
+
feedbackList,
|
|
84
|
+
feedbackSetStatus,
|
|
85
|
+
feedbackDelete
|
|
86
|
+
] as const;
|
package/src/features/live.ts
CHANGED
|
@@ -56,6 +56,53 @@ export const liveTypersPushSchema = z.object({
|
|
|
56
56
|
});
|
|
57
57
|
export type LiveTypersPush = z.infer<typeof liveTypersPushSchema>;
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* La bulle : le texte libre qu'un pair écrit à son curseur, à la Figma. Même
|
|
61
|
+
* voie rapide et même projection que les curseurs, mais un canal distinct du
|
|
62
|
+
* leur, parce que `liveCursorSchema` voyage aussi dans le roster, lequel part à
|
|
63
|
+
* tout l'espace alors que seul son `path` est tronqué par droits.
|
|
64
|
+
*
|
|
65
|
+
* `message: null` = plus de bulle. Le client n'émet jamais la chaîne vide.
|
|
66
|
+
*/
|
|
67
|
+
export const LIVE_SAY_COMMAND = 'live.say' as const;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* La voie rapide court-circuite le scope, l'audit et l'autorisation : cette
|
|
71
|
+
* borne est le seul rempart contre une trame abusive.
|
|
72
|
+
*/
|
|
73
|
+
export const SAY_MAX_LENGTH = 140;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Et son plafond en lignes. La longueur seule ne borne pas la hauteur : cent
|
|
77
|
+
* retours à la ligne tiennent dans cent caractères, et la boîte descendrait
|
|
78
|
+
* sous le bas de l'écran. La saisie applique le même plafond.
|
|
79
|
+
*/
|
|
80
|
+
export const SAY_MAX_LINES = 10;
|
|
81
|
+
|
|
82
|
+
const sayTextSchema = z
|
|
83
|
+
.string()
|
|
84
|
+
.max(SAY_MAX_LENGTH)
|
|
85
|
+
.refine((text) => text.split('\n').length <= SAY_MAX_LINES, {
|
|
86
|
+
message: `Au plus ${SAY_MAX_LINES} lignes`
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
export const liveSayFrameSchema = z.object({ message: sayTextSchema.nullable() });
|
|
90
|
+
export type LiveSayFrame = z.infer<typeof liveSayFrameSchema>;
|
|
91
|
+
|
|
92
|
+
/** Ce que disent les pairs situés au **même chemin exactement**. */
|
|
93
|
+
export const LIVE_SAYS_EVENT = 'live.says' as const;
|
|
94
|
+
export const liveSaysPushSchema = z.object({
|
|
95
|
+
workspaceId: z.number().int().positive(),
|
|
96
|
+
says: z.array(
|
|
97
|
+
z.object({
|
|
98
|
+
connId: z.string().min(1),
|
|
99
|
+
userId: z.number().int().positive(),
|
|
100
|
+
text: sayTextSchema
|
|
101
|
+
})
|
|
102
|
+
)
|
|
103
|
+
});
|
|
104
|
+
export type LiveSaysPush = z.infer<typeof liveSaysPushSchema>;
|
|
105
|
+
|
|
59
106
|
/** Roster de la salle. Projeté par destinataire : les chemins y sont tronqués. */
|
|
60
107
|
export const LIVE_PEERS_EVENT = 'live.peers' as const;
|
|
61
108
|
export const livePeersPushSchema = z.object({
|
package/src/features/registry.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { agentCommands } from './agent';
|
|
3
|
+
import { feedbackCommands } from './feedback';
|
|
3
4
|
import { homeCommands } from './home';
|
|
4
5
|
import { liveCommands } from './live';
|
|
5
6
|
import { logsCommands } from './logs';
|
|
@@ -25,6 +26,7 @@ export const featureCommands = [
|
|
|
25
26
|
...twoFactorCommands,
|
|
26
27
|
...secrecyCommands,
|
|
27
28
|
...logsCommands,
|
|
29
|
+
...feedbackCommands,
|
|
28
30
|
...homeCommands,
|
|
29
31
|
...notifyCommands,
|
|
30
32
|
...sharingCommands,
|