@deveye/types 0.21.8 → 0.22.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/deviceLogs.ts +1 -1
- package/src/domain/packages.ts +6 -4
- package/src/domain/syncProtocol.ts +26 -3
- package/src/features/agent.ts +4 -3
- package/src/index.ts +21 -0
- package/src/protocol/agent.ts +133 -8
- package/src/sdk/server.ts +6 -0
package/package.json
CHANGED
package/src/domain/deviceLogs.ts
CHANGED
|
@@ -81,7 +81,7 @@ export const deviceLogFilterSchema = z.object({
|
|
|
81
81
|
search: z.string().max(500).optional(),
|
|
82
82
|
/** Treat `search` as a regular expression. */
|
|
83
83
|
regex: z.boolean().optional(),
|
|
84
|
-
/** Severity floor (inclusive): only lines with level >= this. */
|
|
84
|
+
/** Severity floor (inclusive): only lines with level >= this. A line whose level is unknown counts as `info`. */
|
|
85
85
|
levelMin: deviceLogLevelSchema.optional(),
|
|
86
86
|
/** journald unit / service filter (e.g. `nginx.service`). Ignored by other kinds. */
|
|
87
87
|
unit: z.string().max(256).optional(),
|
package/src/domain/packages.ts
CHANGED
|
@@ -51,13 +51,12 @@ export function isManagedPackageManager(
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
|
-
* One
|
|
55
|
-
*
|
|
54
|
+
* One update tool present on the machine. Presence is a file check, so the
|
|
55
|
+
* list arrives at once; a managed tool's pending count follows on its own
|
|
56
|
+
* (`pendingCountSchema`), as its probe can take a minute.
|
|
56
57
|
*/
|
|
57
58
|
export const packageManagerSchema = z.object({
|
|
58
59
|
id: z.union([packageManagerIdSchema, unmanagedUpdaterIdSchema]),
|
|
59
|
-
/** Pending update count; `null` when unknown (slow/best-effort probe). */
|
|
60
|
-
pendingCount: z.number().int().nonnegative().nullable(),
|
|
61
60
|
/** Applying this manager's updates requires root/admin. */
|
|
62
61
|
needsRoot: z.boolean(),
|
|
63
62
|
/** A reboot is pending for updates this manager already applied. */
|
|
@@ -65,3 +64,6 @@ export const packageManagerSchema = z.object({
|
|
|
65
64
|
});
|
|
66
65
|
|
|
67
66
|
export type PackageManager = z.infer<typeof packageManagerSchema>;
|
|
67
|
+
|
|
68
|
+
/** Pending update count of a managed tool; `null` when it gave none (probe failed or timed out). */
|
|
69
|
+
export const pendingCountSchema = z.number().int().nonnegative().nullable();
|
|
@@ -15,6 +15,14 @@ export const SYNC_STORAGE_PATH_MAX = 1024;
|
|
|
15
15
|
export const SYNC_CHUNK_MAX = 1_400_000;
|
|
16
16
|
/** Nombre max d'entrées d'index par frame `sync.index`. */
|
|
17
17
|
export const SYNC_INDEX_BATCH_MAX = 500;
|
|
18
|
+
/**
|
|
19
|
+
* Blocks of an encrypted partial a resumed push can build on (1 MiB each). The
|
|
20
|
+
* server keeps no more: their nonces must fit in one `sync.push` frame, and
|
|
21
|
+
* past 32 GiB a broken upload restarts from there rather than from zero.
|
|
22
|
+
*/
|
|
23
|
+
export const SYNC_RESUME_MAX_BLOCKS = 32_768;
|
|
24
|
+
/** Base64 length of {@link SYNC_RESUME_MAX_BLOCKS} 12-byte nonces. */
|
|
25
|
+
export const SYNC_RESUME_NONCES_MAX = Math.ceil((SYNC_RESUME_MAX_BLOCKS * 12) / 3) * 4;
|
|
18
26
|
/**
|
|
19
27
|
* Séparateur des champs d'une ligne d'empreinte d'index (voir
|
|
20
28
|
* `src/cloudSync/fingerprint.ts` côté serveur et `sync::fingerprint` côté
|
|
@@ -58,12 +66,27 @@ export type SyncSessionState = z.infer<typeof syncSessionStateSchema>;
|
|
|
58
66
|
*/
|
|
59
67
|
export const syncEntryKindSchema = z.enum(['file', 'dir']);
|
|
60
68
|
export type SyncEntryKind = z.infer<typeof syncEntryKindSchema>;
|
|
69
|
+
/**
|
|
70
|
+
* Why the agent could not index a path. The server treats that path, and
|
|
71
|
+
* anything under it, as UNKNOWN: no deletion, no upload, no download; it
|
|
72
|
+
* enters neither the baseline nor the fingerprint.
|
|
73
|
+
*/
|
|
74
|
+
export const syncSkipReasonSchema = z.enum([
|
|
75
|
+
'unreadable',
|
|
76
|
+
'unportable',
|
|
77
|
+
'symlink',
|
|
78
|
+
'special',
|
|
79
|
+
'nonUtf8'
|
|
80
|
+
]);
|
|
81
|
+
export type SyncSkipReason = z.infer<typeof syncSkipReasonSchema>;
|
|
61
82
|
/** Volumétrie d'un partage (index + versions ; tailles logiques en clair). */
|
|
62
83
|
export const cloudSyncShareStatsSchema = z.object({
|
|
63
84
|
fileCount: z.number().int().nonnegative(),
|
|
64
85
|
liveBytes: z.number().int().nonnegative(),
|
|
65
86
|
versionCount: z.number().int().nonnegative(),
|
|
66
|
-
versionBytes: z.number().int().nonnegative()
|
|
87
|
+
versionBytes: z.number().int().nonnegative(),
|
|
88
|
+
/** Journal errors not yet resolved: what still waits for the user. */
|
|
89
|
+
openProblems: z.number().int().nonnegative()
|
|
67
90
|
});
|
|
68
91
|
export type CloudSyncShareStats = z.infer<typeof cloudSyncShareStatsSchema>;
|
|
69
92
|
/** Sens du transfert en cours (du point de vue de l'appareil). */
|
|
@@ -88,13 +111,13 @@ export const cloudSyncProgressSchema = z.object({
|
|
|
88
111
|
error: z.string().max(500).nullable()
|
|
89
112
|
});
|
|
90
113
|
export type CloudSyncProgress = z.infer<typeof cloudSyncProgressSchema>;
|
|
91
|
-
/** État agrégé d'un partage
|
|
114
|
+
/** État agrégé d'un partage : pilote le héros « Synchronisé » de l'UI. */
|
|
92
115
|
export const cloudSyncShareStateSchema = z.object({
|
|
93
116
|
shareId: z.number().int().positive(),
|
|
94
117
|
state: z.enum(['synced', 'syncing', 'paused', 'offline', 'error']),
|
|
95
118
|
/** Précision facultative (ex. nom de l'appareil hors ligne ou en erreur). */
|
|
96
119
|
detail: z.string().max(200).nullable(),
|
|
97
|
-
/** Volumétrie fraîche
|
|
120
|
+
/** Volumétrie fraîche : l'en-tête de l'UI se met à jour sans re-fetch. */
|
|
98
121
|
stats: cloudSyncShareStatsSchema
|
|
99
122
|
});
|
|
100
123
|
export type CloudSyncShareState = z.infer<typeof cloudSyncShareStateSchema>;
|
package/src/features/agent.ts
CHANGED
|
@@ -116,9 +116,10 @@ export const agentUpdate = {
|
|
|
116
116
|
};
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
|
-
* Ask the agent
|
|
120
|
-
*
|
|
121
|
-
*
|
|
119
|
+
* Ask the agent for its update tools and their pending updates. The tools
|
|
120
|
+
* present arrive as a `package.list` push event, then one `package.count` per
|
|
121
|
+
* managed tool as its probe finishes (the caller must be subscribed to the
|
|
122
|
+
* device). The command itself only acknowledges the request.
|
|
122
123
|
*/
|
|
123
124
|
export const agentListPackages = {
|
|
124
125
|
command: 'agent.listPackages' as const,
|
package/src/index.ts
CHANGED
|
@@ -48,6 +48,7 @@ export {
|
|
|
48
48
|
AGENT_DOCKER_STATS_RESULT,
|
|
49
49
|
AGENT_LOG_SOURCES_RESULT,
|
|
50
50
|
AGENT_METRICS_BATCH,
|
|
51
|
+
AGENT_PKG_COUNT,
|
|
51
52
|
AGENT_PKG_DONE,
|
|
52
53
|
AGENT_PKG_LIST,
|
|
53
54
|
AGENT_PKG_LIST_RESULT,
|
|
@@ -64,6 +65,7 @@ export {
|
|
|
64
65
|
AGENT_SYNC_APPLY_DIR,
|
|
65
66
|
AGENT_SYNC_APPLY_START,
|
|
66
67
|
AGENT_SYNC_APPLY_LOCAL,
|
|
68
|
+
AGENT_SYNC_BUSY,
|
|
67
69
|
AGENT_SYNC_CHANGED,
|
|
68
70
|
AGENT_SYNC_CHUNK,
|
|
69
71
|
AGENT_SYNC_CONFIG,
|
|
@@ -71,6 +73,7 @@ export {
|
|
|
71
73
|
AGENT_SYNC_MOVE,
|
|
72
74
|
AGENT_SYNC_INDEX,
|
|
73
75
|
AGENT_SYNC_OP_RESULT,
|
|
76
|
+
AGENT_SYNC_DEVICE_KEY,
|
|
74
77
|
AGENT_SYNC_PUSH,
|
|
75
78
|
AGENT_SYNC_PUSH_ACK,
|
|
76
79
|
AGENT_SYNC_SCAN,
|
|
@@ -121,6 +124,7 @@ export {
|
|
|
121
124
|
agentDockerProgressPayloadSchema,
|
|
122
125
|
agentDockerStatsResultPayloadSchema,
|
|
123
126
|
agentLogSourcesResultPayloadSchema,
|
|
127
|
+
agentPkgCountPayloadSchema,
|
|
124
128
|
agentPkgDonePayloadSchema,
|
|
125
129
|
agentPkgListResultPayloadSchema,
|
|
126
130
|
agentPkgProgressPayloadSchema,
|
|
@@ -140,6 +144,7 @@ export {
|
|
|
140
144
|
agentSyncApplyDirPayloadSchema,
|
|
141
145
|
agentSyncApplyStartPayloadSchema,
|
|
142
146
|
agentSyncApplyLocalPayloadSchema,
|
|
147
|
+
agentSyncBusyPayloadSchema,
|
|
143
148
|
agentSyncChangedPayloadSchema,
|
|
144
149
|
agentSyncChunkPayloadSchema,
|
|
145
150
|
agentSyncConfigPayloadSchema,
|
|
@@ -147,6 +152,8 @@ export {
|
|
|
147
152
|
agentSyncMovePayloadSchema,
|
|
148
153
|
agentSyncIndexPayloadSchema,
|
|
149
154
|
agentSyncOpResultPayloadSchema,
|
|
155
|
+
agentSyncDeviceKeyPayloadSchema,
|
|
156
|
+
syncDevicePublicKeySchema,
|
|
150
157
|
agentSyncPushPayloadSchema,
|
|
151
158
|
agentSyncPushAckPayloadSchema,
|
|
152
159
|
agentSyncScanPayloadSchema,
|
|
@@ -207,10 +214,12 @@ export {
|
|
|
207
214
|
deviceTermOutputPushSchema,
|
|
208
215
|
METRICS_PUSH_EVENT,
|
|
209
216
|
metricsPushSchema,
|
|
217
|
+
PACKAGE_COUNT_EVENT,
|
|
210
218
|
PACKAGE_DONE_EVENT,
|
|
211
219
|
PACKAGE_LIST_EVENT,
|
|
212
220
|
PACKAGE_PROGRESS_EVENT,
|
|
213
221
|
PACKAGE_STARTED_EVENT,
|
|
222
|
+
packageCountPushSchema,
|
|
214
223
|
packageDonePushSchema,
|
|
215
224
|
packageListPushSchema,
|
|
216
225
|
packageProgressPushSchema,
|
|
@@ -220,6 +229,8 @@ export {
|
|
|
220
229
|
orderSignatureSchema,
|
|
221
230
|
SIGNED_AGENT_COMMANDS,
|
|
222
231
|
syncIndexEntrySchema,
|
|
232
|
+
syncIndexLineSchema,
|
|
233
|
+
syncIndexSkippedEntrySchema,
|
|
223
234
|
syncShareAssignmentSchema
|
|
224
235
|
} from './protocol/agent';
|
|
225
236
|
export type {
|
|
@@ -253,6 +264,7 @@ export type {
|
|
|
253
264
|
AgentSyncApplyDirPayload,
|
|
254
265
|
AgentSyncApplyStartPayload,
|
|
255
266
|
AgentSyncApplyLocalPayload,
|
|
267
|
+
AgentSyncBusyPayload,
|
|
256
268
|
AgentSyncChangedPayload,
|
|
257
269
|
AgentSyncChunkPayload,
|
|
258
270
|
AgentSyncConfigPayload,
|
|
@@ -260,6 +272,7 @@ export type {
|
|
|
260
272
|
AgentSyncIndexPayload,
|
|
261
273
|
AgentSyncMovePayload,
|
|
262
274
|
AgentSyncOpResultPayload,
|
|
275
|
+
AgentSyncDeviceKeyPayload,
|
|
263
276
|
AgentSyncPushPayload,
|
|
264
277
|
AgentSyncPushAckPayload,
|
|
265
278
|
AgentSyncScanPayload,
|
|
@@ -297,11 +310,14 @@ export type {
|
|
|
297
310
|
DeviceTermExitPush,
|
|
298
311
|
DeviceTermOutputPush,
|
|
299
312
|
MetricsPush,
|
|
313
|
+
PackageCountPush,
|
|
300
314
|
PackageDonePush,
|
|
301
315
|
PackageListPush,
|
|
302
316
|
PackageProgressPush,
|
|
303
317
|
PackageStartedPush,
|
|
304
318
|
SyncIndexEntry,
|
|
319
|
+
SyncIndexLine,
|
|
320
|
+
SyncIndexSkippedEntry,
|
|
305
321
|
SyncShareAssignment
|
|
306
322
|
} from './protocol/agent';
|
|
307
323
|
|
|
@@ -411,10 +427,13 @@ export {
|
|
|
411
427
|
SYNC_CHUNK_MAX,
|
|
412
428
|
SYNC_FINGERPRINT_SEP,
|
|
413
429
|
SYNC_INDEX_BATCH_MAX,
|
|
430
|
+
SYNC_RESUME_MAX_BLOCKS,
|
|
431
|
+
SYNC_RESUME_NONCES_MAX,
|
|
414
432
|
SYNC_REL_PATH_MAX,
|
|
415
433
|
SYNC_STORAGE_PATH_MAX,
|
|
416
434
|
syncDirectionSchema,
|
|
417
435
|
syncEntryKindSchema,
|
|
436
|
+
syncSkipReasonSchema,
|
|
418
437
|
syncIndexFingerprintSchema,
|
|
419
438
|
syncScanModeSchema,
|
|
420
439
|
syncSessionStateSchema,
|
|
@@ -434,6 +453,7 @@ export type {
|
|
|
434
453
|
CloudSyncShareStats,
|
|
435
454
|
SyncDirection,
|
|
436
455
|
SyncEntryKind,
|
|
456
|
+
SyncSkipReason,
|
|
437
457
|
SyncScanMode,
|
|
438
458
|
SyncSessionState,
|
|
439
459
|
SyncShareStatus
|
|
@@ -665,6 +685,7 @@ export {
|
|
|
665
685
|
isManagedPackageManager,
|
|
666
686
|
packageManagerIdSchema,
|
|
667
687
|
packageManagerSchema,
|
|
688
|
+
pendingCountSchema,
|
|
668
689
|
unmanagedUpdaterIdSchema
|
|
669
690
|
} from './domain/packages';
|
|
670
691
|
export type { PackageManager, PackageManagerId, UnmanagedUpdaterId } from './domain/packages';
|
package/src/protocol/agent.ts
CHANGED
|
@@ -4,10 +4,12 @@ import {
|
|
|
4
4
|
cloudSyncShareStateSchema,
|
|
5
5
|
sha256HexSchema,
|
|
6
6
|
SYNC_CHUNK_MAX,
|
|
7
|
+
SYNC_RESUME_NONCES_MAX,
|
|
7
8
|
SYNC_INDEX_BATCH_MAX,
|
|
8
9
|
SYNC_REL_PATH_MAX,
|
|
9
10
|
SYNC_STORAGE_PATH_MAX,
|
|
10
11
|
syncEntryKindSchema,
|
|
12
|
+
syncSkipReasonSchema,
|
|
11
13
|
syncIndexFingerprintSchema,
|
|
12
14
|
syncScanModeSchema,
|
|
13
15
|
syncShareStatusSchema
|
|
@@ -33,7 +35,11 @@ import {
|
|
|
33
35
|
dockerStatSchema
|
|
34
36
|
} from '../domain/deviceDocker';
|
|
35
37
|
import { metricsBatchSchema, metricSnapshotSchema } from '../domain/metrics';
|
|
36
|
-
import {
|
|
38
|
+
import {
|
|
39
|
+
packageManagerIdSchema,
|
|
40
|
+
packageManagerSchema,
|
|
41
|
+
pendingCountSchema
|
|
42
|
+
} from '../domain/packages';
|
|
37
43
|
import {
|
|
38
44
|
authWindowSchema,
|
|
39
45
|
deviceReportSchema,
|
|
@@ -101,7 +107,7 @@ export const agentPowerActionSchema = z.enum([
|
|
|
101
107
|
]);
|
|
102
108
|
export type AgentPowerAction = z.infer<typeof agentPowerActionSchema>;
|
|
103
109
|
|
|
104
|
-
/** Agent's reply to `pkg.list`: the
|
|
110
|
+
/** Agent's first reply to `pkg.list`: the update tools present on the host, without counts. */
|
|
105
111
|
export const AGENT_PKG_LIST_RESULT = 'pkg.listResult' as const;
|
|
106
112
|
|
|
107
113
|
export const agentPkgListResultPayloadSchema = z.object({
|
|
@@ -109,6 +115,19 @@ export const agentPkgListResultPayloadSchema = z.object({
|
|
|
109
115
|
managers: z.array(packageManagerSchema)
|
|
110
116
|
});
|
|
111
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Then one per managed tool of that list, as each probe finishes: its pending
|
|
120
|
+
* count. A tool whose probe fails still gets its frame (`null`), so the
|
|
121
|
+
* screen never waits for a count that will not come.
|
|
122
|
+
*/
|
|
123
|
+
export const AGENT_PKG_COUNT = 'pkg.count' as const;
|
|
124
|
+
|
|
125
|
+
export const agentPkgCountPayloadSchema = z.object({
|
|
126
|
+
deviceId: z.uuid(),
|
|
127
|
+
manager: packageManagerIdSchema,
|
|
128
|
+
pendingCount: pendingCountSchema
|
|
129
|
+
});
|
|
130
|
+
|
|
112
131
|
/** Live line of an in-progress `pkg.upgrade`. */
|
|
113
132
|
export const AGENT_PKG_PROGRESS = 'pkg.progress' as const;
|
|
114
133
|
|
|
@@ -410,13 +429,28 @@ export const syncIndexEntrySchema = z.object({
|
|
|
410
429
|
});
|
|
411
430
|
export type SyncIndexEntry = z.infer<typeof syncIndexEntrySchema>;
|
|
412
431
|
|
|
432
|
+
/** A path the agent saw but could not index: the server treats it, and anything under it, as unknown. */
|
|
433
|
+
export const syncIndexSkippedEntrySchema = z.object({
|
|
434
|
+
relPath: syncRelPath,
|
|
435
|
+
kind: z.literal('skipped'),
|
|
436
|
+
reason: syncSkipReasonSchema
|
|
437
|
+
});
|
|
438
|
+
export type SyncIndexSkippedEntry = z.infer<typeof syncIndexSkippedEntrySchema>;
|
|
439
|
+
|
|
440
|
+
/** One line of a `sync.index` batch: an indexed entry, or a skipped path. */
|
|
441
|
+
export const syncIndexLineSchema = z.discriminatedUnion('kind', [
|
|
442
|
+
syncIndexEntrySchema,
|
|
443
|
+
syncIndexSkippedEntrySchema
|
|
444
|
+
]);
|
|
445
|
+
export type SyncIndexLine = z.infer<typeof syncIndexLineSchema>;
|
|
446
|
+
|
|
413
447
|
/** Un lot d'index du scan (réponse à `sync.scan`, dernier lot `done: true`). */
|
|
414
448
|
export const AGENT_SYNC_INDEX = 'sync.index' as const;
|
|
415
449
|
export const agentSyncIndexPayloadSchema = z.object({
|
|
416
450
|
deviceId: z.uuid(),
|
|
417
451
|
sessionId: syncOpId,
|
|
418
452
|
shareId: z.number().int().positive(),
|
|
419
|
-
entries: z.array(
|
|
453
|
+
entries: z.array(syncIndexLineSchema).max(SYNC_INDEX_BATCH_MAX),
|
|
420
454
|
done: z.boolean(),
|
|
421
455
|
/**
|
|
422
456
|
* L'agent a-t-il réellement parcouru le disque ? `false` répond à un
|
|
@@ -429,6 +463,12 @@ export const agentSyncIndexPayloadSchema = z.object({
|
|
|
429
463
|
scanned: z.boolean().default(true),
|
|
430
464
|
/** Empreinte de l'index détenu par l'agent, quand il sait la calculer. */
|
|
431
465
|
fingerprint: syncIndexFingerprintSchema.nullable().default(null),
|
|
466
|
+
/**
|
|
467
|
+
* The hashes are keyed (end-to-end encrypted share), not plain SHA-256. An
|
|
468
|
+
* agent that predates encrypted shares never sets it: the server refuses
|
|
469
|
+
* its index for such a share instead of storing readable content.
|
|
470
|
+
*/
|
|
471
|
+
encrypted: z.boolean().default(false),
|
|
432
472
|
/** Posé sur le lot final quand le scan a échoué (la session est abandonnée). */
|
|
433
473
|
error: z.string().max(500).optional()
|
|
434
474
|
});
|
|
@@ -455,7 +495,13 @@ export const agentSyncChunkPayloadSchema = z.object({
|
|
|
455
495
|
* honours the push's `window`: the server then answers each data frame with
|
|
456
496
|
* `sync.pushAck`. Absent (an older agent), nothing is acknowledged.
|
|
457
497
|
*/
|
|
458
|
-
seq: z.number().int().nonnegative().optional()
|
|
498
|
+
seq: z.number().int().nonnegative().optional(),
|
|
499
|
+
/**
|
|
500
|
+
* Set with `error` on an encrypted push: the blocks the server kept from an
|
|
501
|
+
* earlier attempt do not encrypt the file as it is now. The server drops
|
|
502
|
+
* that partial; the next attempt starts over.
|
|
503
|
+
*/
|
|
504
|
+
stalePartial: z.boolean().optional()
|
|
459
505
|
});
|
|
460
506
|
export type AgentSyncChunkPayload = z.infer<typeof agentSyncChunkPayloadSchema>;
|
|
461
507
|
|
|
@@ -468,6 +514,19 @@ export const agentSyncAckPayloadSchema = z.object({
|
|
|
468
514
|
});
|
|
469
515
|
export type AgentSyncAckPayload = z.infer<typeof agentSyncAckPayloadSchema>;
|
|
470
516
|
|
|
517
|
+
/**
|
|
518
|
+
* Keep-alive for a long local step of `opId` (re-reading a partial download,
|
|
519
|
+
* hashing a large file during a scan or before a local copy/move). The server
|
|
520
|
+
* only re-arms its silence timeout. Sent about every 15 s. For a scan, `opId`
|
|
521
|
+
* is the scan's session id.
|
|
522
|
+
*/
|
|
523
|
+
export const AGENT_SYNC_BUSY = 'sync.busy' as const;
|
|
524
|
+
export const agentSyncBusyPayloadSchema = z.object({
|
|
525
|
+
deviceId: z.uuid(),
|
|
526
|
+
opId: syncOpId
|
|
527
|
+
});
|
|
528
|
+
export type AgentSyncBusyPayload = z.infer<typeof agentSyncBusyPayloadSchema>;
|
|
529
|
+
|
|
471
530
|
/**
|
|
472
531
|
* Issue d'une op locale : install atomique (`apply`), création de dossier vide
|
|
473
532
|
* (`applyDir`), copie locale d'un contenu déjà présent (`applyLocal`), amorce
|
|
@@ -486,6 +545,26 @@ export const agentSyncOpResultPayloadSchema = z.object({
|
|
|
486
545
|
});
|
|
487
546
|
export type AgentSyncOpResultPayload = z.infer<typeof agentSyncOpResultPayloadSchema>;
|
|
488
547
|
|
|
548
|
+
/** Base64 of a raw X25519 public key (32 bytes). */
|
|
549
|
+
export const syncDevicePublicKeySchema = z
|
|
550
|
+
.string()
|
|
551
|
+
.length(44)
|
|
552
|
+
.regex(/^[A-Za-z0-9+/]{43}=$/);
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
* The device's X25519 public key, sent after every `sync.config`. The key of
|
|
556
|
+
* an encrypted share reaches the device sealed for it (see
|
|
557
|
+
* `syncShareAssignmentSchema.encryption`); the private half never leaves the
|
|
558
|
+
* machine. A different key than the last one means the machine lost its
|
|
559
|
+
* private key: whatever was sealed for the old one is unreadable.
|
|
560
|
+
*/
|
|
561
|
+
export const AGENT_SYNC_DEVICE_KEY = 'sync.deviceKey' as const;
|
|
562
|
+
export const agentSyncDeviceKeyPayloadSchema = z.object({
|
|
563
|
+
deviceId: z.uuid(),
|
|
564
|
+
publicKey: syncDevicePublicKeySchema
|
|
565
|
+
});
|
|
566
|
+
export type AgentSyncDeviceKeyPayload = z.infer<typeof agentSyncDeviceKeyPayloadSchema>;
|
|
567
|
+
|
|
489
568
|
export const agentReportMessagePayloadSchema = z.object({
|
|
490
569
|
deviceId: z.uuid(),
|
|
491
570
|
report: deviceReportSchema
|
|
@@ -560,6 +639,10 @@ export const agentClientMessageSchema = z.discriminatedUnion('command', [
|
|
|
560
639
|
command: z.literal(AGENT_PKG_LIST_RESULT),
|
|
561
640
|
payload: agentPkgListResultPayloadSchema
|
|
562
641
|
}),
|
|
642
|
+
z.object({
|
|
643
|
+
command: z.literal(AGENT_PKG_COUNT),
|
|
644
|
+
payload: agentPkgCountPayloadSchema
|
|
645
|
+
}),
|
|
563
646
|
z.object({
|
|
564
647
|
command: z.literal(AGENT_PKG_PROGRESS),
|
|
565
648
|
payload: agentPkgProgressPayloadSchema
|
|
@@ -664,9 +747,17 @@ export const agentClientMessageSchema = z.discriminatedUnion('command', [
|
|
|
664
747
|
command: z.literal(AGENT_SYNC_ACK),
|
|
665
748
|
payload: agentSyncAckPayloadSchema
|
|
666
749
|
}),
|
|
750
|
+
z.object({
|
|
751
|
+
command: z.literal(AGENT_SYNC_BUSY),
|
|
752
|
+
payload: agentSyncBusyPayloadSchema
|
|
753
|
+
}),
|
|
667
754
|
z.object({
|
|
668
755
|
command: z.literal(AGENT_SYNC_OP_RESULT),
|
|
669
756
|
payload: agentSyncOpResultPayloadSchema
|
|
757
|
+
}),
|
|
758
|
+
z.object({
|
|
759
|
+
command: z.literal(AGENT_SYNC_DEVICE_KEY),
|
|
760
|
+
payload: agentSyncDeviceKeyPayloadSchema
|
|
670
761
|
})
|
|
671
762
|
]);
|
|
672
763
|
|
|
@@ -741,7 +832,7 @@ export const AGENT_SERVICE = 'agent.service' as const;
|
|
|
741
832
|
export const agentServicePayloadSchema = z.object({ action: agentServiceActionSchema });
|
|
742
833
|
export type AgentServicePayload = z.infer<typeof agentServicePayloadSchema>;
|
|
743
834
|
|
|
744
|
-
/** Ask the agent
|
|
835
|
+
/** Ask the agent for its update tools (`pkg.listResult`), then their counts (one `pkg.count` each). */
|
|
745
836
|
export const AGENT_PKG_LIST = 'pkg.list' as const;
|
|
746
837
|
|
|
747
838
|
/** Ask the agent to apply all updates of one manager, streaming `pkg.progress`. */
|
|
@@ -971,7 +1062,18 @@ export const syncShareAssignmentSchema = z.object({
|
|
|
971
1062
|
*/
|
|
972
1063
|
rateUpBps: z.number().int().positive().nullable().default(null),
|
|
973
1064
|
/** Rétention de `.deveye-trash/`, en jours. */
|
|
974
|
-
trashKeepDays: z.number().int().positive().max(3650).default(30)
|
|
1065
|
+
trashKeepDays: z.number().int().positive().max(3650).default(30),
|
|
1066
|
+
/**
|
|
1067
|
+
* Set on an end-to-end encrypted share: the agent hashes with a key,
|
|
1068
|
+
* encrypts what it uploads and decrypts what it installs. `wrappedKey` is
|
|
1069
|
+
* the share secret sealed for this device's public key (base64), `null`
|
|
1070
|
+
* while nobody has given it to this device: the agent then refuses every
|
|
1071
|
+
* operation of the share and says why.
|
|
1072
|
+
*/
|
|
1073
|
+
encryption: z
|
|
1074
|
+
.object({ wrappedKey: z.string().max(256).nullable() })
|
|
1075
|
+
.nullable()
|
|
1076
|
+
.default(null)
|
|
975
1077
|
});
|
|
976
1078
|
export type SyncShareAssignment = z.infer<typeof syncShareAssignmentSchema>;
|
|
977
1079
|
|
|
@@ -1015,7 +1117,27 @@ export const agentSyncPushPayloadSchema = z.object({
|
|
|
1015
1117
|
* window. The server acks a frame once written, and paces its acks to cap
|
|
1016
1118
|
* the upload rate. Absent (an older server), the agent streams freely.
|
|
1017
1119
|
*/
|
|
1018
|
-
window: z.number().int().positive().max(64).optional()
|
|
1120
|
+
window: z.number().int().positive().max(64).optional(),
|
|
1121
|
+
/**
|
|
1122
|
+
* The hash the scan announced. An encrypted push binds its blocks to it,
|
|
1123
|
+
* so the server always sends it on an encrypted share.
|
|
1124
|
+
*/
|
|
1125
|
+
hash: sha256HexSchema.optional(),
|
|
1126
|
+
/**
|
|
1127
|
+
* Encrypted share, `startOffset > 0`: what the server kept of an earlier
|
|
1128
|
+
* attempt. `header` is the blob's 17-byte header and `nonces` the 12-byte
|
|
1129
|
+
* nonce of each kept block in order (both base64), `tags` the hex SHA-256
|
|
1130
|
+
* of their 16-byte tags laid end to end. The agent re-encrypts its own
|
|
1131
|
+
* prefix with those nonces and compares before sending anything: content
|
|
1132
|
+
* changed since then is refused (`stalePartial`).
|
|
1133
|
+
*/
|
|
1134
|
+
resume: z
|
|
1135
|
+
.object({
|
|
1136
|
+
header: z.string().max(32),
|
|
1137
|
+
nonces: z.string().max(SYNC_RESUME_NONCES_MAX),
|
|
1138
|
+
tags: sha256HexSchema
|
|
1139
|
+
})
|
|
1140
|
+
.optional()
|
|
1019
1141
|
});
|
|
1020
1142
|
export type AgentSyncPushPayload = z.infer<typeof agentSyncPushPayloadSchema>;
|
|
1021
1143
|
|
|
@@ -1385,8 +1507,9 @@ export const SIGNED_AGENT_COMMANDS: ReadonlySet<string> = new Set([
|
|
|
1385
1507
|
export const METRICS_PUSH_EVENT = 'metrics.push' as const;
|
|
1386
1508
|
export const DEVICE_PRESENCE_EVENT = 'device.presence' as const;
|
|
1387
1509
|
export const DEVICE_REPORT_EVENT = 'device.report' as const;
|
|
1388
|
-
/**
|
|
1510
|
+
/** Update tools present, then one pending count per managed tool (Appareils panel). */
|
|
1389
1511
|
export const PACKAGE_LIST_EVENT = 'package.list' as const;
|
|
1512
|
+
export const PACKAGE_COUNT_EVENT = 'package.count' as const;
|
|
1390
1513
|
/**
|
|
1391
1514
|
* Une mise à jour vient d'être acceptée pour ce gestionnaire. Émis par le
|
|
1392
1515
|
* serveur avant la première ligne de sortie de l'outil, pour que tous les
|
|
@@ -1435,6 +1558,7 @@ export const CLOUD_SYNC_CHUNK_EVENT = 'cloudSync.chunk' as const;
|
|
|
1435
1558
|
export const packageListPushSchema = agentPkgListResultPayloadSchema.extend({
|
|
1436
1559
|
running: z.array(packageManagerIdSchema).default([])
|
|
1437
1560
|
});
|
|
1561
|
+
export const packageCountPushSchema = agentPkgCountPayloadSchema;
|
|
1438
1562
|
|
|
1439
1563
|
export const packageStartedPushSchema = z.object({
|
|
1440
1564
|
deviceId: z.uuid(),
|
|
@@ -1486,6 +1610,7 @@ export type DeviceDockerProgressPush = z.infer<typeof deviceDockerProgressPushSc
|
|
|
1486
1610
|
export type DeviceDockerDonePush = z.infer<typeof deviceDockerDonePushSchema>;
|
|
1487
1611
|
|
|
1488
1612
|
export type PackageListPush = z.infer<typeof packageListPushSchema>;
|
|
1613
|
+
export type PackageCountPush = z.infer<typeof packageCountPushSchema>;
|
|
1489
1614
|
export type PackageStartedPush = z.infer<typeof packageStartedPushSchema>;
|
|
1490
1615
|
export type PackageProgressPush = z.infer<typeof packageProgressPushSchema>;
|
|
1491
1616
|
export type PackageDonePush = z.infer<typeof packageDonePushSchema>;
|
package/src/sdk/server.ts
CHANGED
|
@@ -21,9 +21,11 @@ import type {
|
|
|
21
21
|
AgentSyncApplyDirPayload,
|
|
22
22
|
AgentSyncApplyLocalPayload,
|
|
23
23
|
AgentSyncApplyStartPayload,
|
|
24
|
+
AgentSyncBusyPayload,
|
|
24
25
|
AgentSyncChangedPayload,
|
|
25
26
|
AgentSyncChunkPayload,
|
|
26
27
|
AgentSyncConfigPayload,
|
|
28
|
+
AgentSyncDeviceKeyPayload,
|
|
27
29
|
AgentSyncDeletePayload,
|
|
28
30
|
AgentSyncIndexPayload,
|
|
29
31
|
AgentSyncMovePayload,
|
|
@@ -762,7 +764,11 @@ export interface FeatureAgentHooks {
|
|
|
762
764
|
onSyncIndex?(deviceId: string, payload: AgentSyncIndexPayload): void;
|
|
763
765
|
onSyncChunk?(deviceId: string, payload: AgentSyncChunkPayload): void;
|
|
764
766
|
onSyncAck?(deviceId: string, payload: AgentSyncAckPayload): void;
|
|
767
|
+
/** The agent is still working on an op locally; nothing to do but let the op wait longer. */
|
|
768
|
+
onSyncBusy?(deviceId: string, payload: AgentSyncBusyPayload): void;
|
|
765
769
|
onSyncOpResult?(deviceId: string, payload: AgentSyncOpResultPayload): void;
|
|
770
|
+
/** The agent's X25519 public key, sent after every `sync.config` it receives. */
|
|
771
|
+
onSyncDeviceKey?(deviceId: string, payload: AgentSyncDeviceKeyPayload): void;
|
|
766
772
|
}
|
|
767
773
|
|
|
768
774
|
/**
|