@exagone313/dsh-podman 1.0.3 → 1.1.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.
Files changed (140) hide show
  1. package/README.md +1 -0
  2. package/README.zh.md +1 -0
  3. package/dist/approval-reasons.d.ts +12 -0
  4. package/dist/approval-reasons.js +15 -0
  5. package/dist/approval.js +21 -0
  6. package/dist/card-route.js +83 -1
  7. package/dist/client/ContainerCard.js +14 -2
  8. package/dist/client/card-protocol.d.ts +16 -1
  9. package/dist/client/container-card-controller.d.ts +8 -2
  10. package/dist/client/container-card-controller.js +21 -0
  11. package/dist/client/container-card-ports.d.ts +13 -0
  12. package/dist/client/container-card-ports.js +74 -0
  13. package/dist/client/container-card-row.d.ts +3 -0
  14. package/dist/client/container-card-row.js +12 -2
  15. package/dist/client/container-card-workspace.d.ts +3 -0
  16. package/dist/client/container-card-workspace.js +2 -2
  17. package/dist/client/index.js +653 -386
  18. package/dist/client/locales.d.ts +1 -1
  19. package/dist/client/locales.js +30 -0
  20. package/dist/client/tool-presentations.d.ts +167 -0
  21. package/dist/client/tool-presentations.js +167 -0
  22. package/dist/client/tool-views.d.ts +1 -2
  23. package/dist/client/tool-views.js +54 -190
  24. package/dist/generated/version.d.ts +2 -2
  25. package/dist/generated/version.js +2 -2
  26. package/dist/grpc/proto/dshctl/v1/control.proto +47 -1
  27. package/dist/grpc/proto/dshgateway/v1/gateway.proto +89 -0
  28. package/dist/grpc/proto/dshguest/v1/guest.proto +17 -0
  29. package/dist/index.d.ts +3 -2
  30. package/dist/index.js +3 -2
  31. package/dist/public.d.ts +1 -0
  32. package/dist/public.js +14 -0
  33. package/dist/publish-port.d.ts +6 -0
  34. package/dist/publish-port.js +37 -0
  35. package/dist/tool-defs.js +15 -1
  36. package/dist/tool-handlers.js +31 -1
  37. package/dist/tool-params.d.ts +48 -0
  38. package/dist/tool-params.js +42 -0
  39. package/docs/architecture.md +44 -7
  40. package/docs/architecture.zh.md +38 -6
  41. package/docs/configuration.md +25 -0
  42. package/docs/configuration.zh.md +23 -0
  43. package/docs/development.md +17 -6
  44. package/docs/development.zh.md +16 -6
  45. package/docs/install-dsh-and-dsh-podman.md +10 -4
  46. package/docs/install-dsh-and-dsh-podman.zh.md +9 -3
  47. package/docs/uninstall.md +4 -3
  48. package/docs/uninstall.zh.md +3 -2
  49. package/docs/update.md +23 -6
  50. package/docs/update.zh.md +23 -6
  51. package/docs/usage.md +48 -13
  52. package/docs/usage.zh.md +31 -2
  53. package/package.json +3 -1
  54. package/quadlet/dsh-podman-gateway.container +23 -0
  55. package/quadlet/dsh-podman-orchestrator.container +1 -1
  56. package/quadlet/dsh.container +1 -1
  57. package/dist/approval-reasons.test.d.ts +0 -1
  58. package/dist/approval-reasons.test.js +0 -143
  59. package/dist/approval.test.d.ts +0 -1
  60. package/dist/approval.test.js +0 -593
  61. package/dist/card-route.test.d.ts +0 -1
  62. package/dist/card-route.test.js +0 -223
  63. package/dist/card-test-support.d.ts +0 -15
  64. package/dist/card-test-support.js +0 -133
  65. package/dist/container-env.test.d.ts +0 -1
  66. package/dist/container-env.test.js +0 -93
  67. package/dist/containers.test.d.ts +0 -1
  68. package/dist/containers.test.js +0 -621
  69. package/dist/daemons.test.d.ts +0 -1
  70. package/dist/daemons.test.js +0 -167
  71. package/dist/dsh-version.test.d.ts +0 -1
  72. package/dist/dsh-version.test.js +0 -25
  73. package/dist/env-rows.test.d.ts +0 -1
  74. package/dist/env-rows.test.js +0 -43
  75. package/dist/fs-provider.test.d.ts +0 -1
  76. package/dist/fs-provider.test.js +0 -301
  77. package/dist/guest-rpc.test.d.ts +0 -1
  78. package/dist/guest-rpc.test.js +0 -241
  79. package/dist/images.test.d.ts +0 -1
  80. package/dist/images.test.js +0 -86
  81. package/dist/locales.test.d.ts +0 -1
  82. package/dist/locales.test.js +0 -34
  83. package/dist/misc.test.d.ts +0 -1
  84. package/dist/misc.test.js +0 -169
  85. package/dist/mounts.test.d.ts +0 -1
  86. package/dist/mounts.test.js +0 -478
  87. package/dist/naming.test.d.ts +0 -1
  88. package/dist/naming.test.js +0 -28
  89. package/dist/package-deps.test.d.ts +0 -1
  90. package/dist/package-deps.test.js +0 -49
  91. package/dist/paths.test.d.ts +0 -1
  92. package/dist/paths.test.js +0 -76
  93. package/dist/plugin-meta.test.d.ts +0 -1
  94. package/dist/plugin-meta.test.js +0 -29
  95. package/dist/project-path.test.d.ts +0 -1
  96. package/dist/project-path.test.js +0 -66
  97. package/dist/read-only-shell.test.d.ts +0 -1
  98. package/dist/read-only-shell.test.js +0 -182
  99. package/dist/runtime-client.test.d.ts +0 -1
  100. package/dist/runtime-client.test.js +0 -53
  101. package/dist/secrets.test.d.ts +0 -1
  102. package/dist/secrets.test.js +0 -196
  103. package/dist/settings-commands.test.d.ts +0 -1
  104. package/dist/settings-commands.test.js +0 -596
  105. package/dist/settings-create.test.d.ts +0 -1
  106. package/dist/settings-create.test.js +0 -416
  107. package/dist/settings-default-env.test.d.ts +0 -1
  108. package/dist/settings-default-env.test.js +0 -175
  109. package/dist/settings-mounts.test.d.ts +0 -1
  110. package/dist/settings-mounts.test.js +0 -506
  111. package/dist/settings-paths.test.d.ts +0 -1
  112. package/dist/settings-paths.test.js +0 -65
  113. package/dist/settings-schema.test.d.ts +0 -1
  114. package/dist/settings-schema.test.js +0 -35
  115. package/dist/settings-workspaces.test.d.ts +0 -1
  116. package/dist/settings-workspaces.test.js +0 -240
  117. package/dist/spill-store.test.d.ts +0 -1
  118. package/dist/spill-store.test.js +0 -82
  119. package/dist/subprocess.test.d.ts +0 -1
  120. package/dist/subprocess.test.js +0 -344
  121. package/dist/terminal-preference.test.d.ts +0 -1
  122. package/dist/terminal-preference.test.js +0 -62
  123. package/dist/terminal-route.test.d.ts +0 -1
  124. package/dist/terminal-route.test.js +0 -265
  125. package/dist/terminal-tab.test.d.ts +0 -1
  126. package/dist/terminal-tab.test.js +0 -58
  127. package/dist/terminal-targets.test.d.ts +0 -1
  128. package/dist/terminal-targets.test.js +0 -43
  129. package/dist/terminal-titles.test.d.ts +0 -1
  130. package/dist/terminal-titles.test.js +0 -36
  131. package/dist/test-support.d.ts +0 -358
  132. package/dist/test-support.js +0 -499
  133. package/dist/version-compat.test.d.ts +0 -1
  134. package/dist/version-compat.test.js +0 -27
  135. package/dist/views.test.d.ts +0 -1
  136. package/dist/views.test.js +0 -23
  137. package/dist/volumes.test.d.ts +0 -1
  138. package/dist/volumes.test.js +0 -40
  139. package/dist/workspace-binding.test.d.ts +0 -1
  140. package/dist/workspace-binding.test.js +0 -523
@@ -1,499 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import { EventEmitter } from "node:events";
5
- import { createFilesystemProvider } from "./index.js";
6
- // WORKSPACE_ID is a valid workspace id: slugs are UUIDs, and the pod/container
7
- // names are derived from one.
8
- export const WORKSPACE_ID = "2c573001-4171-4900-904b-12a5cc02737a";
9
- export class FakeTerminalCall extends EventEmitter {
10
- stdinChunks = [];
11
- resizes = [];
12
- start;
13
- closed = false;
14
- ended = false;
15
- write(message) {
16
- if (message.close) {
17
- this.closed = true;
18
- return;
19
- }
20
- if (message.start) {
21
- this.start = message.start;
22
- queueMicrotask(() => this.emit("data", { started: { pid: 42 } }));
23
- return;
24
- }
25
- if (message.resize) {
26
- this.resizes.push({
27
- rows: message.resize.rows,
28
- cols: message.resize.cols,
29
- });
30
- return;
31
- }
32
- if (message.stdinChunk) {
33
- this.stdinChunks.push(Buffer.from(message.stdinChunk));
34
- return;
35
- }
36
- if (message.inspectRequestId !== undefined) {
37
- const requestId = message.inspectRequestId;
38
- queueMicrotask(() => this.emit("data", {
39
- foreground: {
40
- requestId,
41
- found: true,
42
- processGroupId: 7,
43
- inputWaiting: true,
44
- },
45
- }));
46
- return;
47
- }
48
- if (message.signal) {
49
- const requestId = message.signal.requestId;
50
- queueMicrotask(() => this.emit("data", {
51
- signalled: { requestId, found: true, processGroupId: 7 },
52
- }));
53
- }
54
- }
55
- end() {
56
- this.ended = true;
57
- }
58
- cancel() { }
59
- emitStdout(data) {
60
- this.emit("data", { stdoutChunk: data });
61
- }
62
- emitExit(exitCode = 0, signaled = false) {
63
- this.emit("data", { exit: { exitCode, signaled, signal: "" } });
64
- this.emit("end");
65
- }
66
- }
67
- export const fakeTerminalResolver = (fake) => ({
68
- resolveForPath: async () => ({
69
- guest: { terminal: () => fake },
70
- token: "t",
71
- }),
72
- });
73
- export const stubResolver = {
74
- resolve: async () => ({ kind: "binding" }),
75
- resolveForPath: async () => ({ kind: "binding" }),
76
- };
77
- export const EXPECTED_TOOLS = [
78
- "image_list",
79
- "image_get",
80
- "image_build",
81
- "image_rebuild",
82
- "image_rebuild_all",
83
- "image_remove",
84
- "container_list",
85
- "container_start",
86
- "container_recreate",
87
- "container_remove",
88
- "container_bash",
89
- "container_exec",
90
- "container_read",
91
- "container_write",
92
- "container_edit",
93
- "container_glob",
94
- "container_grep",
95
- "container_mount_list",
96
- "container_mount_add",
97
- "container_mount_remove",
98
- "container_mount_update",
99
- "container_path_set",
100
- "container_path_add",
101
- "container_path_remove",
102
- "volume_list",
103
- "volume_create",
104
- "volume_remove",
105
- "secret_list",
106
- "secret_create",
107
- "secret_remove",
108
- "container_secret_add",
109
- "container_secret_remove",
110
- "daemon_start",
111
- "daemon_list",
112
- "daemon_stop",
113
- "daemon_restart",
114
- "daemon_logs",
115
- ];
116
- export const testReadSession = (session) => session?.facts ?? {};
117
- export const sessionExec = (name, facts = { mode: "read-only" }) => ({
118
- name,
119
- agent: { session: { facts } },
120
- });
121
- export const presetExec = (name, preset, args, facts = {}) => ({
122
- name,
123
- arguments: args,
124
- agent: {
125
- session: { header: { agentPreset: preset }, facts: { ...facts, preset } },
126
- },
127
- });
128
- export const MOUNT_TOOLS = [
129
- "container_mount_list",
130
- "container_mount_add",
131
- "container_mount_remove",
132
- "container_mount_update",
133
- ];
134
- export const VOLUME_TOOLS = ["volume_list", "volume_create", "volume_remove"];
135
- export const SECRET_TOOLS = [
136
- "secret_list",
137
- "secret_create",
138
- "secret_remove",
139
- "container_secret_add",
140
- "container_secret_remove",
141
- ];
142
- export function mountRequestRecorder() {
143
- const requests = [];
144
- const resolver = {
145
- registry: {
146
- resolveByPath: async () => ({ id: WORKSPACE_ID }),
147
- },
148
- getConfig: () => ({ projectsRoot: "/projects" }),
149
- async control(method, request) {
150
- requests.push([method, request]);
151
- return {};
152
- },
153
- };
154
- return { requests, resolver };
155
- }
156
- export const MOUNT_EXEC = { agent: { session: { header: { cwd: "/proj" } } } };
157
- export const DAEMON_TOOLS = [
158
- "daemon_start",
159
- "daemon_list",
160
- "daemon_stop",
161
- "daemon_restart",
162
- "daemon_logs",
163
- ];
164
- export const SECRET_BEARING_CONTAINER = {
165
- workspaceSlug: WORKSPACE_ID,
166
- containerName: "default",
167
- imageId: "img-1",
168
- status: "running",
169
- createdAt: "2026-01-01T00:00:00Z",
170
- podmanName: `dsh-podman-${WORKSPACE_ID}-default`,
171
- agentSocketPath: `/run/dsh-podman/${WORKSPACE_ID}-default/guest.sock`,
172
- agentToken: "super-secret-token",
173
- mounts: [
174
- {
175
- projectName: "team",
176
- mode: "MOUNT_MODE_READ_WRITE",
177
- kind: "MOUNT_KIND_PROJECT",
178
- },
179
- ],
180
- env: { PATH: "/bin", DB_PASSWORD: "hunter2" },
181
- secretEnv: { DB_PASS: "db-pass" },
182
- };
183
- export function secretBearingResolver() {
184
- return {
185
- registry: {
186
- resolveByPath: async () => ({ id: WORKSPACE_ID }),
187
- },
188
- getConfig: () => ({ projectsRoot: "/projects" }),
189
- control: async () => SECRET_BEARING_CONTAINER,
190
- };
191
- }
192
- // Stubs the guest agent's streaming ReadFile/WriteFile calls, recording the
193
- // paths the tools ask for.
194
- export function guestFileRecorder(content = "hello", exists = true) {
195
- const reads = [];
196
- const writes = [];
197
- const mkdirs = [];
198
- const guest = {
199
- readFile: (request) => {
200
- reads.push(request.path);
201
- return {
202
- async *[Symbol.asyncIterator]() {
203
- yield { data: Buffer.from(content) };
204
- },
205
- cancel() { },
206
- };
207
- },
208
- mkdir: (request, _metadata, callback) => {
209
- mkdirs.push(request.path);
210
- callback(null, {});
211
- return { cancel() { } };
212
- },
213
- stat: (_request, _metadata, callback) => {
214
- callback(null, exists
215
- ? {
216
- exists: true,
217
- isDir: false,
218
- size: Buffer.byteLength(content),
219
- modifiedAt: "1",
220
- mode: 0o644,
221
- }
222
- : { exists: false });
223
- return { cancel() { } };
224
- },
225
- writeFile: (_metadata, _options, callback) => {
226
- let path = "";
227
- let body = "";
228
- return {
229
- write(message) {
230
- if (message.start !== undefined)
231
- path = message.start.path;
232
- if (message.dataChunk !== undefined) {
233
- body += String(message.dataChunk);
234
- }
235
- },
236
- end() {
237
- writes.push({ path, content: body });
238
- callback(null, { bytesWritten: body.length });
239
- },
240
- };
241
- },
242
- };
243
- const binding = { guest, token: "t", socket: "/run/x.sock" };
244
- const resolver = {
245
- resolve: async () => binding,
246
- containerBinding: async () => binding,
247
- resolveForPath: async () => binding,
248
- };
249
- return { reads, writes, mkdirs, resolver };
250
- }
251
- // fakeToolContext is the minimal cordis context the container file tools need:
252
- // the plugin's real filesystem provider over the given resolver, the fs
253
- // observation waterfalls stubbed to "no intent" (an unconditional write), and
254
- // an `emit` that records the `fs/observed` events the tools report.
255
- export function fakeToolContext(resolver) {
256
- const observed = [];
257
- return {
258
- fs: createFilesystemProvider(resolver),
259
- observed,
260
- async waterfall(_name, _target, _actor, next) {
261
- return await next();
262
- },
263
- emit(event, target, observation) {
264
- if (event === "fs/observed")
265
- observed.push({ target, observation });
266
- },
267
- };
268
- }
269
- // Stubs the guest agent's streaming Exec call, recording the start message.
270
- export function guestExecRecorder(defaultCwd, stdout) {
271
- const starts = [];
272
- const guest = {
273
- exec: () => {
274
- const handlers = {};
275
- return {
276
- on(event, handler) {
277
- (handlers[event] ??= []).push(handler);
278
- },
279
- write(message) {
280
- starts.push({
281
- argv: message.start.argv,
282
- cwd: message.start.cwd,
283
- env: message.start.env,
284
- ...(message.start.uid !== undefined
285
- ? { uid: message.start.uid.value }
286
- : {}),
287
- ...(message.start.gid !== undefined
288
- ? { gid: message.start.gid.value }
289
- : {}),
290
- ...(message.start.groups !== undefined
291
- ? { groups: message.start.groups }
292
- : {}),
293
- });
294
- },
295
- end() {
296
- for (const handler of handlers.data ?? []) {
297
- if (stdout !== undefined) {
298
- handler({ stdoutChunk: Buffer.from(stdout) });
299
- }
300
- handler({ exit: { exitCode: 0, signaled: false } });
301
- }
302
- },
303
- };
304
- },
305
- };
306
- const binding = {
307
- guest,
308
- token: "t",
309
- socket: "/run/x.sock",
310
- ...(defaultCwd === undefined ? {} : { defaultCwd }),
311
- };
312
- const resolver = {
313
- resolve: async () => binding,
314
- containerBinding: async () => binding,
315
- };
316
- return { starts, resolver };
317
- }
318
- // A resolver for the container_path_* tools: the guest stubs GetPaths/SetPaths
319
- // (the agent's live list) and control records the setContainerPaths call.
320
- export function pathRequestRecorder(options = {}) {
321
- const controlCalls = [];
322
- const setCalls = [];
323
- const defaultPath = options.defaultPath ?? "/usr/bin";
324
- let paths = options.paths ?? [];
325
- const guest = {
326
- getPaths: (_request, _metadata, callback) => callback(null, { paths, defaultPath }),
327
- setPaths: (request, _metadata, callback) => {
328
- setCalls.push(request.paths);
329
- paths = request.paths;
330
- callback(null, { paths, defaultPath });
331
- },
332
- };
333
- const binding = { guest, token: "t", socket: "/run/x.sock" };
334
- const resolver = {
335
- registry: { resolveByPath: async () => ({ id: WORKSPACE_ID }) },
336
- getConfig: () => ({ projectsRoot: "/projects" }),
337
- resolve: async () => binding,
338
- containerBinding: async () => binding,
339
- async control(method, request) {
340
- controlCalls.push([method, request]);
341
- return { paths: request.paths ?? [] };
342
- },
343
- };
344
- return { controlCalls, setCalls, resolver };
345
- }
346
- // A fake guest whose readFile honors offset/length, so the provider's byte
347
- // windowing and text decoding can be exercised without a container.
348
- export function fakeGuest(source) {
349
- const requests = [];
350
- return {
351
- requests,
352
- guest: {
353
- readFile: (request) => {
354
- requests.push(request);
355
- return {
356
- async *[Symbol.asyncIterator]() {
357
- const offset = Number(request.offset ?? 0);
358
- const length = Number(request.length ?? 0);
359
- const slice = length > 0
360
- ? source.subarray(offset, offset + length)
361
- : source.subarray(offset);
362
- yield { data: slice };
363
- },
364
- };
365
- },
366
- },
367
- };
368
- }
369
- export function providerFor(guest) {
370
- return createFilesystemProvider({
371
- resolveForPath: async () => ({ guest, token: "t" }),
372
- });
373
- }
374
- // A fake guest for the text/byte provider methods: a stat result, a one-chunk
375
- // readFile, and a no-op writeFile.
376
- export function editGuest(stat, content = Buffer.alloc(0)) {
377
- const writes = [];
378
- return {
379
- writes,
380
- guest: {
381
- stat: (_request, _metadata, callback) => callback(null, {
382
- exists: true,
383
- isDir: false,
384
- isSymlink: false,
385
- size: String(content.length),
386
- mode: "-rw-r--r--",
387
- modifiedAt: "t",
388
- ...stat,
389
- }),
390
- readFile: () => ({
391
- async *[Symbol.asyncIterator]() {
392
- yield { data: content };
393
- },
394
- }),
395
- writeFile: (_metadata, _options, callback) => {
396
- const call = {
397
- write(message) {
398
- if (message?.dataChunk)
399
- writes.push(Buffer.from(message.dataChunk));
400
- },
401
- end() { },
402
- };
403
- callback(null, { bytesWritten: 0 });
404
- return call;
405
- },
406
- },
407
- token: "t",
408
- };
409
- }
410
- export function editProvider(binding) {
411
- return createFilesystemProvider({
412
- resolveForPath: async () => binding,
413
- });
414
- }
415
- // The guest Exec bidi stream the subprocess provider drives, with the
416
- // backpressure and failure controls its tests need. `write()` records the start
417
- // message; `end()` replays the process id, the configured stdout and (unless
418
- // disabled) the exit message, mirroring a guest that answered immediately.
419
- export class FakeExecStream extends EventEmitter {
420
- starts;
421
- options;
422
- paused = 0;
423
- resumed = 0;
424
- cancelled = false;
425
- constructor(starts, options) {
426
- super();
427
- this.starts = starts;
428
- this.options = options;
429
- }
430
- write(message) {
431
- this.starts.push(message);
432
- return true;
433
- }
434
- end() {
435
- this.emitData({ processId: "7" });
436
- if (this.options.stdout !== undefined) {
437
- this.emitData({ stdoutChunk: Buffer.from(this.options.stdout) });
438
- }
439
- if (this.options.emitExit !== false) {
440
- this.emitData({
441
- exit: { exitCode: 0, signaled: false, ...this.options.exit },
442
- });
443
- }
444
- }
445
- pause() {
446
- this.paused++;
447
- }
448
- resume() {
449
- this.resumed++;
450
- }
451
- cancel() {
452
- this.cancelled = true;
453
- }
454
- emitData(message) {
455
- this.emit("data", message);
456
- }
457
- }
458
- // A fake guest for the subprocess provider: exec emits a process id (and
459
- // optionally an exit), and the unary signal/delete RPCs are recorded.
460
- export function spawnGuest(options = {}) {
461
- const signals = [];
462
- const starts = [];
463
- const deletes = [];
464
- const streams = [];
465
- const guest = {
466
- exec: () => {
467
- const stream = new FakeExecStream(starts, options);
468
- streams.push(stream);
469
- return stream;
470
- },
471
- signal: (request, _metadata, callback) => {
472
- signals.push(request);
473
- callback(null, {});
474
- },
475
- delete: (request, _metadata, callback) => {
476
- deletes.push(request);
477
- callback(null, {});
478
- },
479
- };
480
- return {
481
- signals,
482
- starts,
483
- deletes,
484
- streams,
485
- guest,
486
- resolver: { resolve: async () => ({ guest, token: "t" }) },
487
- };
488
- }
489
- export const spawnSpec = (overrides = {}) => ({
490
- argv: ["sleep", "1"],
491
- cwd: "/projects/team",
492
- stdio: {
493
- stdin: "ignore",
494
- stdout: { maxBytes: 10 },
495
- stderr: { maxBytes: 10 },
496
- },
497
- graceMs: 50,
498
- ...overrides,
499
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { core, major, versionState } from "./version-compat.js";
7
- test("core keeps the leading x.y.z", () => {
8
- assert.equal(core("1.2.3"), "1.2.3");
9
- assert.equal(core("0.2.0-rc.3"), "0.2.0");
10
- assert.equal(core("1.2.3-4-gabc123"), "1.2.3");
11
- assert.equal(core("dev"), "");
12
- assert.equal(core(""), "");
13
- });
14
- test("major reports the leading component", () => {
15
- assert.equal(major("1.2.3"), 1);
16
- assert.equal(major("0.2.0-rc.3"), 0);
17
- assert.equal(major("dev"), -1);
18
- });
19
- test("versionState mirrors the orchestrator's compatibility rule", () => {
20
- assert.equal(versionState("1.2.3", "1.2.3"), "ok");
21
- assert.equal(versionState("1.2.3-4-gabc", "1.2.3"), "ok");
22
- assert.equal(versionState("1.3.0", "1.2.3"), "minor-mismatch");
23
- assert.equal(versionState("1.2.4", "1.2.3"), "minor-mismatch");
24
- assert.equal(versionState("2.0.0", "1.9.0"), "major-mismatch");
25
- assert.equal(versionState("1.9.0", "2.0.0"), "major-mismatch");
26
- assert.equal(versionState("1.2.3", "dev"), "ok", "an orchestrator with no comparable version accepts any plugin");
27
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { SECRET_BEARING_CONTAINER } from "./test-support.js";
7
- import { publicContainer } from "./index.js";
8
- test("publicContainer rebuilds a safe object from an API row", () => {
9
- const out = publicContainer(SECRET_BEARING_CONTAINER);
10
- assert.deepEqual(Object.keys(out).sort(), [
11
- "containerName",
12
- "env",
13
- "imageId",
14
- "mounts",
15
- "paths",
16
- "secretEnv",
17
- "status",
18
- ]);
19
- assert.deepEqual(out.mounts, [
20
- { projectName: "team", mode: "read_write", kind: "project" },
21
- ]);
22
- assert.deepEqual(out.env, { PATH: "/bin", DB_PASSWORD: "hunter2" });
23
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,40 +0,0 @@
1
- // SPDX-FileCopyrightText: 2026 Elouan Martinet <exa@elou.world>
2
- //
3
- // SPDX-License-Identifier: MIT
4
- import test from "node:test";
5
- import assert from "node:assert/strict";
6
- import { VOLUME_TOOLS } from "./test-support.js";
7
- import { toolHandlers, TOOLS } from "./index.js";
8
- test("volume tools are registered with the expected schemas", () => {
9
- for (const name of VOLUME_TOOLS) {
10
- const tool = TOOLS.find((entry) => entry.name === name);
11
- assert.ok(tool, `${name} registered`);
12
- if (name === "volume_remove") {
13
- assert.equal(tool.approval, true, "volume_remove must require approval");
14
- }
15
- else {
16
- assert.notEqual(tool.approval, true, `${name} must not require approval`);
17
- }
18
- assert.equal(tool.parameters.type, "object", `${name} type`);
19
- assert.equal(typeof tool.parameters.properties, "object");
20
- assert.ok(Array.isArray(tool.parameters.required));
21
- }
22
- const listTool = TOOLS.find((entry) => entry.name === "volume_list");
23
- assert.deepEqual(listTool.parameters.required, []);
24
- const createTool = TOOLS.find((entry) => entry.name === "volume_create");
25
- assert.deepEqual(createTool.parameters.required, ["name"]);
26
- assert.equal(createTool.parameters.properties.name.type, "string");
27
- const removeTool = TOOLS.find((entry) => entry.name === "volume_remove");
28
- assert.deepEqual(removeTool.parameters.required, ["name"]);
29
- assert.equal(removeTool.parameters.properties.name.type, "string");
30
- });
31
- test("volume_list and secret_list return name objects", async () => {
32
- const volumeResolver = {
33
- control: async () => ({ volumes: [{ name: "myvol" }] }),
34
- };
35
- assert.deepEqual(await toolHandlers.volume_list(volumeResolver, {}, {}), [{ name: "myvol" }]);
36
- const secretResolver = {
37
- control: async () => ({ secrets: [{ name: "dbpass" }] }),
38
- };
39
- assert.deepEqual(await toolHandlers.secret_list(secretResolver, {}, {}), [{ name: "dbpass" }]);
40
- });
@@ -1 +0,0 @@
1
- export {};