endia 0.0.0-stage → 0.0.2

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 (101) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +34 -2
  3. package/dist/archives/archive-file.d.ts +36 -0
  4. package/dist/archives/archive-file.js +71 -0
  5. package/dist/archives/build-context.d.ts +63 -0
  6. package/dist/archives/build-context.js +132 -0
  7. package/dist/archives/docker-ignore.d.ts +57 -0
  8. package/dist/archives/docker-ignore.js +250 -0
  9. package/dist/archives/fleet-archive.d.ts +33 -0
  10. package/dist/archives/fleet-archive.js +134 -0
  11. package/dist/compose-model.d.ts +32 -0
  12. package/dist/compose-model.js +39 -0
  13. package/dist/contract/archives.d.ts +14 -0
  14. package/dist/contract/archives.js +1 -0
  15. package/dist/contract/bases.d.ts +48 -0
  16. package/dist/contract/bases.js +1 -0
  17. package/dist/contract/clients.d.ts +29 -0
  18. package/dist/contract/clients.js +1 -0
  19. package/dist/contract/common.d.ts +30 -0
  20. package/dist/contract/common.js +1 -0
  21. package/dist/contract/compose.d.ts +27 -0
  22. package/dist/contract/compose.js +1 -0
  23. package/dist/contract/desktop.d.ts +269 -0
  24. package/dist/contract/desktop.js +1 -0
  25. package/dist/contract/execs.d.ts +61 -0
  26. package/dist/contract/execs.js +1 -0
  27. package/dist/contract/fleets.d.ts +136 -0
  28. package/dist/contract/fleets.js +1 -0
  29. package/dist/contract/images.d.ts +130 -0
  30. package/dist/contract/images.js +1 -0
  31. package/dist/contract/machines.d.ts +199 -0
  32. package/dist/contract/machines.js +1 -0
  33. package/dist/contract/operations.d.ts +28 -0
  34. package/dist/contract/operations.js +1 -0
  35. package/dist/contract/processes.d.ts +75 -0
  36. package/dist/contract/processes.js +1 -0
  37. package/dist/contract/purposes.d.ts +62 -0
  38. package/dist/contract/purposes.js +1 -0
  39. package/dist/contract/space.d.ts +114 -0
  40. package/dist/contract/space.js +1 -0
  41. package/dist/contract/stats.d.ts +58 -0
  42. package/dist/contract/stats.js +1 -0
  43. package/dist/contract/status.d.ts +151 -0
  44. package/dist/contract/status.js +1 -0
  45. package/dist/contract/volumes.d.ts +22 -0
  46. package/dist/contract/volumes.js +1 -0
  47. package/dist/eastindia-client.d.ts +118 -0
  48. package/dist/eastindia-client.js +142 -0
  49. package/dist/environment.d.ts +52 -0
  50. package/dist/environment.js +133 -0
  51. package/dist/errors.d.ts +81 -0
  52. package/dist/errors.js +108 -0
  53. package/dist/exec/exec-frame.d.ts +38 -0
  54. package/dist/exec/exec-frame.js +50 -0
  55. package/dist/exec/exec-session.d.ts +64 -0
  56. package/dist/exec/exec-session.js +117 -0
  57. package/dist/groups/archives.d.ts +78 -0
  58. package/dist/groups/archives.js +117 -0
  59. package/dist/groups/bases.d.ts +28 -0
  60. package/dist/groups/bases.js +39 -0
  61. package/dist/groups/certificates.d.ts +32 -0
  62. package/dist/groups/certificates.js +43 -0
  63. package/dist/groups/desktop.d.ts +143 -0
  64. package/dist/groups/desktop.js +182 -0
  65. package/dist/groups/execs.d.ts +110 -0
  66. package/dist/groups/execs.js +119 -0
  67. package/dist/groups/fleets.d.ts +206 -0
  68. package/dist/groups/fleets.js +255 -0
  69. package/dist/groups/images.d.ts +130 -0
  70. package/dist/groups/images.js +109 -0
  71. package/dist/groups/machines.d.ts +124 -0
  72. package/dist/groups/machines.js +127 -0
  73. package/dist/groups/operations.d.ts +127 -0
  74. package/dist/groups/operations.js +174 -0
  75. package/dist/groups/processes.d.ts +77 -0
  76. package/dist/groups/processes.js +75 -0
  77. package/dist/groups/stats.d.ts +29 -0
  78. package/dist/groups/stats.js +33 -0
  79. package/dist/groups/system.d.ts +33 -0
  80. package/dist/groups/system.js +40 -0
  81. package/dist/groups/volumes.d.ts +36 -0
  82. package/dist/groups/volumes.js +40 -0
  83. package/dist/index.d.ts +37 -0
  84. package/dist/index.js +20 -0
  85. package/dist/purposes.d.ts +17 -0
  86. package/dist/purposes.js +21 -0
  87. package/dist/routes.d.ts +71 -0
  88. package/dist/routes.js +73 -0
  89. package/dist/transport/api-connection.d.ts +185 -0
  90. package/dist/transport/api-connection.js +396 -0
  91. package/dist/transport/connection-failures.d.ts +14 -0
  92. package/dist/transport/connection-failures.js +57 -0
  93. package/dist/transport/json-lines.d.ts +10 -0
  94. package/dist/transport/json-lines.js +23 -0
  95. package/dist/transport/query-text.d.ts +49 -0
  96. package/dist/transport/query-text.js +62 -0
  97. package/dist/transport/service-address.d.ts +30 -0
  98. package/dist/transport/service-address.js +37 -0
  99. package/dist/transport/tls-files.d.ts +9 -0
  100. package/dist/transport/tls-files.js +1 -0
  101. package/package.json +44 -5
@@ -0,0 +1,28 @@
1
+ import type { BaseImportRequest, BaseImportResult, BasePrepareRequest } from "../contract/bases.js";
2
+ import type { OperationHandle } from "./operations.js";
3
+ /**
4
+ * The base routes, which make the images that have no parent: import a Windows disk already on the host, or install Windows from an
5
+ * installation disc. The service does this work in the background, so each method returns a handle on the operation, which follows
6
+ * the work and gives its result, the new image's description.
7
+ */
8
+ export declare class BasesClient {
9
+ private readonly connection;
10
+ private readonly operations;
11
+ /**
12
+ * Imports a Windows disk on the host as an image: `endia import`.
13
+ *
14
+ * @param request - The disk's path on the host, the reference the image will carry, and the configuration changes.
15
+ * @param signal - Cancels the request.
16
+ * @returns The import's operation; its result is a `BaseImportResult`.
17
+ */
18
+ import(request: BaseImportRequest, signal?: AbortSignal): Promise<OperationHandle<BaseImportResult>>;
19
+ /**
20
+ * Installs Windows from an installation disc on the host and imports the result: `endia base prepare`. The request carries a
21
+ * password, so it is sent once, without an `Idempotency-Key` and without a retry.
22
+ *
23
+ * @param request - The disc, the tag, the accounts and their password.
24
+ * @param signal - Cancels the request.
25
+ * @returns The preparation's operation; its result is a `BaseImportResult`.
26
+ */
27
+ prepare(request: BasePrepareRequest, signal?: AbortSignal): Promise<OperationHandle<BaseImportResult>>;
28
+ }
@@ -0,0 +1,39 @@
1
+ import { Routes } from "../routes.js";
2
+ import { jsonBody } from "../transport/api-connection.js";
3
+ /**
4
+ * The base routes, which make the images that have no parent: import a Windows disk already on the host, or install Windows from an
5
+ * installation disc. The service does this work in the background, so each method returns a handle on the operation, which follows
6
+ * the work and gives its result, the new image's description.
7
+ */
8
+ export class BasesClient {
9
+ connection;
10
+ operations;
11
+ /** @internal */
12
+ constructor(connection, operations) {
13
+ this.connection = connection;
14
+ this.operations = operations;
15
+ }
16
+ /**
17
+ * Imports a Windows disk on the host as an image: `endia import`.
18
+ *
19
+ * @param request - The disk's path on the host, the reference the image will carry, and the configuration changes.
20
+ * @param signal - Cancels the request.
21
+ * @returns The import's operation; its result is a `BaseImportResult`.
22
+ */
23
+ async import(request, signal) {
24
+ const accepted = await this.connection.change({ method: "POST", path: Routes.baseImport, body: jsonBody(request), signal });
25
+ return this.operations.handle(accepted);
26
+ }
27
+ /**
28
+ * Installs Windows from an installation disc on the host and imports the result: `endia base prepare`. The request carries a
29
+ * password, so it is sent once, without an `Idempotency-Key` and without a retry.
30
+ *
31
+ * @param request - The disc, the tag, the accounts and their password.
32
+ * @param signal - Cancels the request.
33
+ * @returns The preparation's operation; its result is a `BaseImportResult`.
34
+ */
35
+ async prepare(request, signal) {
36
+ const accepted = await this.connection.sendOnce({ method: "POST", path: Routes.basePrepare, body: jsonBody(request), signal });
37
+ return this.operations.handle(accepted);
38
+ }
39
+ }
@@ -0,0 +1,32 @@
1
+ import type { ClientCertificateSummary, IssuedClientCertificate } from "../contract/clients.js";
2
+ /**
3
+ * The client certificate routes: issue, list and revoke the certificates that callers over HTTPS present. The service answers them
4
+ * only on its named pipe, and refuses a caller over HTTPS with `PERMISSION_DENIED`.
5
+ */
6
+ export declare class CertificatesClient {
7
+ private readonly connection;
8
+ /**
9
+ * Issues a client certificate: `endia context export`. The answer holds the new certificate's private key, and the service
10
+ * keeps no copy of it to replay. The request is therefore sent once, without an `Idempotency-Key` and without a retry.
11
+ *
12
+ * @param name - The certificate's name, which the service records as the caller of each request made with it.
13
+ * @param signal - Cancels the request.
14
+ * @returns The authority, the certificate and its private key, as PEM text.
15
+ */
16
+ issue(name: string, signal?: AbortSignal): Promise<IssuedClientCertificate>;
17
+ /**
18
+ * Lists the issued client certificates: `endia cert ls`.
19
+ *
20
+ * @param signal - Cancels the request.
21
+ * @returns The certificates, without their keys.
22
+ */
23
+ list(signal?: AbortSignal): Promise<ClientCertificateSummary[]>;
24
+ /**
25
+ * Revokes a client certificate, after which the service refuses it: `endia cert rm`.
26
+ *
27
+ * @param name - The certificate's name.
28
+ * @param signal - Cancels the request.
29
+ * @returns The certificate as revoked.
30
+ */
31
+ revoke(name: string, signal?: AbortSignal): Promise<ClientCertificateSummary>;
32
+ }
@@ -0,0 +1,43 @@
1
+ import { Routes } from "../routes.js";
2
+ import { jsonBody } from "../transport/api-connection.js";
3
+ /**
4
+ * The client certificate routes: issue, list and revoke the certificates that callers over HTTPS present. The service answers them
5
+ * only on its named pipe, and refuses a caller over HTTPS with `PERMISSION_DENIED`.
6
+ */
7
+ export class CertificatesClient {
8
+ connection;
9
+ /** @internal */
10
+ constructor(connection) {
11
+ this.connection = connection;
12
+ }
13
+ /**
14
+ * Issues a client certificate: `endia context export`. The answer holds the new certificate's private key, and the service
15
+ * keeps no copy of it to replay. The request is therefore sent once, without an `Idempotency-Key` and without a retry.
16
+ *
17
+ * @param name - The certificate's name, which the service records as the caller of each request made with it.
18
+ * @param signal - Cancels the request.
19
+ * @returns The authority, the certificate and its private key, as PEM text.
20
+ */
21
+ issue(name, signal) {
22
+ return this.connection.sendOnce({ method: "POST", path: Routes.clients, body: jsonBody({ name }), signal });
23
+ }
24
+ /**
25
+ * Lists the issued client certificates: `endia cert ls`.
26
+ *
27
+ * @param signal - Cancels the request.
28
+ * @returns The certificates, without their keys.
29
+ */
30
+ list(signal) {
31
+ return this.connection.read(Routes.clients, signal);
32
+ }
33
+ /**
34
+ * Revokes a client certificate, after which the service refuses it: `endia cert rm`.
35
+ *
36
+ * @param name - The certificate's name.
37
+ * @param signal - Cancels the request.
38
+ * @returns The certificate as revoked.
39
+ */
40
+ revoke(name, signal) {
41
+ return this.connection.change({ method: "DELETE", path: Routes.client(name), signal });
42
+ }
43
+ }
@@ -0,0 +1,143 @@
1
+ import type { Timestamp } from "../contract/common.js";
2
+ import type { ClickRequest, DesktopInspectRequest, DesktopInspectResult, DesktopLaunchRequest, DesktopLaunchResult, DesktopWaitRequest, DesktopWaitResult, DesktopWindow, InvokeRequest, InvokeResult, KeysRequest, KeysResult, PointerRequest, PointerResult, SetValueRequest, SetValueResult, TrayClickRequest, TrayClickResult, TrayIcon, UacRequest, UacResult } from "../contract/desktop.js";
3
+ /** A picture of the desktop user's screen, or of one process's windows. */
4
+ export interface DesktopScreenshot {
5
+ /** The picture as PNG bytes. */
6
+ readonly png: Buffer;
7
+ readonly width: number;
8
+ readonly height: number;
9
+ /** The Windows session the picture was taken in. */
10
+ readonly sessionId: number;
11
+ readonly taken: Timestamp;
12
+ }
13
+ /**
14
+ * The desktop routes of a running machine, which drive the signed-in desktop user's session through UI Automation, the Windows
15
+ * interface that reads and operates the controls of other programs' windows. A program is launched with `launch`; its controls are
16
+ * then found by a selector whose first segment names one of the program's top-level windows, and operated with `invoke`, `click`,
17
+ * `setValue` and `keys`.
18
+ */
19
+ export declare class DesktopClient {
20
+ private readonly connection;
21
+ /**
22
+ * Starts a program in the desktop user's session: `endia desktop launch`.
23
+ *
24
+ * @param machine - The machine name or a unique prefix of its ID.
25
+ * @param request - The program, its arguments, and whether to start it elevated.
26
+ * @param signal - Cancels the request.
27
+ * @returns The process and its windows; its `processId` and `started` name the process in the other desktop requests.
28
+ */
29
+ launch(machine: string, request: DesktopLaunchRequest, signal?: AbortSignal): Promise<DesktopLaunchResult>;
30
+ /**
31
+ * Takes a picture of the screen: `endia desktop screenshot`. It changes nothing, so it carries no `Idempotency-Key`.
32
+ *
33
+ * @param machine - The machine name or a unique prefix of its ID.
34
+ * @param options - `processId` limits the picture to that process's windows.
35
+ * @returns The picture.
36
+ */
37
+ screenshot(machine: string, options?: {
38
+ readonly processId?: number;
39
+ readonly signal?: AbortSignal;
40
+ }): Promise<DesktopScreenshot>;
41
+ /**
42
+ * Reads the tree of controls in a process's windows: `endia desktop inspect`.
43
+ *
44
+ * @param machine - The machine name or a unique prefix of its ID.
45
+ * @param request - The process, and optionally one of its windows.
46
+ * @param signal - Cancels the request.
47
+ * @returns Each window with its tree of elements.
48
+ */
49
+ inspect(machine: string, request: DesktopInspectRequest, signal?: AbortSignal): Promise<DesktopInspectResult>;
50
+ /**
51
+ * Waits until a selector names exactly one element, or with `gone` until it names none: `endia desktop wait`. The service
52
+ * answers only when the wait ends, so the client's own time limit does not apply; `timeoutSeconds` limits the wait.
53
+ *
54
+ * @param machine - The machine name or a unique prefix of its ID.
55
+ * @param request - The process, the selector and the longest wait.
56
+ * @param signal - Cancels the request.
57
+ * @returns The element and its window; both null after a wait for `gone`.
58
+ */
59
+ wait(machine: string, request: DesktopWaitRequest, signal?: AbortSignal): Promise<DesktopWaitResult>;
60
+ /**
61
+ * Uses an element's Invoke pattern, as pressing a button does: `endia desktop invoke`.
62
+ *
63
+ * @param machine - The machine name or a unique prefix of its ID.
64
+ * @param request - The process and the selector.
65
+ * @param signal - Cancels the request.
66
+ * @returns Whether the element was invoked.
67
+ */
68
+ invoke(machine: string, request: InvokeRequest, signal?: AbortSignal): Promise<InvokeResult>;
69
+ /**
70
+ * Clicks the pointer at an element's centre: `endia desktop click`.
71
+ *
72
+ * @param machine - The machine name or a unique prefix of its ID.
73
+ * @param request - The process, the selector and the button.
74
+ * @param signal - Cancels the request.
75
+ * @returns The point clicked on the screen.
76
+ */
77
+ click(machine: string, request: ClickRequest, signal?: AbortSignal): Promise<PointerResult>;
78
+ /**
79
+ * Sets an element's value, such as a text box's text: `endia desktop set-value`. A secret value, such as a password, is sent
80
+ * once, without an `Idempotency-Key` and without a retry, so that the service never stores it.
81
+ *
82
+ * @param machine - The machine name or a unique prefix of its ID.
83
+ * @param request - The process, the selector, the value, and whether it is secret.
84
+ * @param signal - Cancels the request.
85
+ * @returns The value read back, or null for a secret value.
86
+ */
87
+ setValue(machine: string, request: SetValueRequest, signal?: AbortSignal): Promise<SetValueResult>;
88
+ /**
89
+ * Types keys or text into a process's main window: `endia desktop keys`. The service brings the window to the foreground and
90
+ * checks that it is there before sending anything; otherwise it refuses the request with `FOCUS_REFUSED`.
91
+ *
92
+ * @param machine - The machine name or a unique prefix of its ID.
93
+ * @param request - The process, and `keys` as space-separated chords such as `ctrl+s`, or `text` to type as it is.
94
+ * @param signal - Cancels the request.
95
+ * @returns The number of input events sent.
96
+ */
97
+ keys(machine: string, request: KeysRequest, signal?: AbortSignal): Promise<KeysResult>;
98
+ /**
99
+ * Moves, clicks or scrolls the pointer at a point: `endia desktop pointer`.
100
+ *
101
+ * @param machine - The machine name or a unique prefix of its ID.
102
+ * @param request - The action, the point, and optionally the process whose window the point is relative to.
103
+ * @param signal - Cancels the request.
104
+ * @returns The point on the screen, and the window under it.
105
+ */
106
+ pointer(machine: string, request: PointerRequest, signal?: AbortSignal): Promise<PointerResult>;
107
+ /**
108
+ * Lists the visible top-level windows of the desktop user's session: `endia desktop windows`.
109
+ *
110
+ * @param machine - The machine name or a unique prefix of its ID.
111
+ * @param signal - Cancels the request.
112
+ * @returns The windows.
113
+ */
114
+ windows(machine: string, signal?: AbortSignal): Promise<DesktopWindow[]>;
115
+ /**
116
+ * Lists the icons of the notification area: `endia desktop tray ls`.
117
+ *
118
+ * @param machine - The machine name or a unique prefix of its ID.
119
+ * @param signal - Cancels the request.
120
+ * @returns The icons.
121
+ */
122
+ tray(machine: string, signal?: AbortSignal): Promise<TrayIcon[]>;
123
+ /**
124
+ * Clicks an icon of the notification area: `endia desktop tray click`.
125
+ *
126
+ * @param machine - The machine name or a unique prefix of its ID.
127
+ * @param request - The icon's name and the button.
128
+ * @param signal - Cancels the request.
129
+ * @returns The icon and the point clicked.
130
+ */
131
+ trayClick(machine: string, request: TrayClickRequest, signal?: AbortSignal): Promise<TrayClickResult>;
132
+ /**
133
+ * Answers an elevation prompt for an expected program: `endia desktop uac`. The request may carry a password, so it is sent
134
+ * once, without an `Idempotency-Key`, without a retry and without the client's time limit.
135
+ *
136
+ * @param machine - The machine name or a unique prefix of its ID.
137
+ * @param request - The program the prompt must name, and how to answer it.
138
+ * @param signal - Cancels the request.
139
+ * @returns The outcome, the prompt as read, and pictures of the screen before and after.
140
+ */
141
+ answerPrompt(machine: string, request: UacRequest, signal?: AbortSignal): Promise<UacResult>;
142
+ private send;
143
+ }
@@ -0,0 +1,182 @@
1
+ import { Headers, Routes } from "../routes.js";
2
+ import { jsonBody } from "../transport/api-connection.js";
3
+ /**
4
+ * The desktop routes of a running machine, which drive the signed-in desktop user's session through UI Automation, the Windows
5
+ * interface that reads and operates the controls of other programs' windows. A program is launched with `launch`; its controls are
6
+ * then found by a selector whose first segment names one of the program's top-level windows, and operated with `invoke`, `click`,
7
+ * `setValue` and `keys`.
8
+ */
9
+ export class DesktopClient {
10
+ connection;
11
+ /** @internal */
12
+ constructor(connection) {
13
+ this.connection = connection;
14
+ }
15
+ /**
16
+ * Starts a program in the desktop user's session: `endia desktop launch`.
17
+ *
18
+ * @param machine - The machine name or a unique prefix of its ID.
19
+ * @param request - The program, its arguments, and whether to start it elevated.
20
+ * @param signal - Cancels the request.
21
+ * @returns The process and its windows; its `processId` and `started` name the process in the other desktop requests.
22
+ */
23
+ launch(machine, request, signal) {
24
+ return this.send(machine, "launch", request, signal);
25
+ }
26
+ /**
27
+ * Takes a picture of the screen: `endia desktop screenshot`. It changes nothing, so it carries no `Idempotency-Key`.
28
+ *
29
+ * @param machine - The machine name or a unique prefix of its ID.
30
+ * @param options - `processId` limits the picture to that process's windows.
31
+ * @returns The picture.
32
+ */
33
+ async screenshot(machine, options = {}) {
34
+ const answer = await this.connection.sendWithoutKey({
35
+ method: "POST",
36
+ path: Routes.desktop(machine, "screenshot"),
37
+ body: jsonBody({ processId: options.processId }),
38
+ signal: options.signal,
39
+ });
40
+ return {
41
+ png: answer.body,
42
+ width: Number(header(answer, Headers.screenshotWidth)),
43
+ height: Number(header(answer, Headers.screenshotHeight)),
44
+ sessionId: Number(header(answer, Headers.screenshotSession)),
45
+ taken: header(answer, Headers.screenshotTaken),
46
+ };
47
+ }
48
+ /**
49
+ * Reads the tree of controls in a process's windows: `endia desktop inspect`.
50
+ *
51
+ * @param machine - The machine name or a unique prefix of its ID.
52
+ * @param request - The process, and optionally one of its windows.
53
+ * @param signal - Cancels the request.
54
+ * @returns Each window with its tree of elements.
55
+ */
56
+ inspect(machine, request, signal) {
57
+ return this.send(machine, "inspect", request, signal);
58
+ }
59
+ /**
60
+ * Waits until a selector names exactly one element, or with `gone` until it names none: `endia desktop wait`. The service
61
+ * answers only when the wait ends, so the client's own time limit does not apply; `timeoutSeconds` limits the wait.
62
+ *
63
+ * @param machine - The machine name or a unique prefix of its ID.
64
+ * @param request - The process, the selector and the longest wait.
65
+ * @param signal - Cancels the request.
66
+ * @returns The element and its window; both null after a wait for `gone`.
67
+ */
68
+ wait(machine, request, signal) {
69
+ return this.connection.change({ method: "POST", path: Routes.desktop(machine, "wait"), body: jsonBody(request), signal }, false);
70
+ }
71
+ /**
72
+ * Uses an element's Invoke pattern, as pressing a button does: `endia desktop invoke`.
73
+ *
74
+ * @param machine - The machine name or a unique prefix of its ID.
75
+ * @param request - The process and the selector.
76
+ * @param signal - Cancels the request.
77
+ * @returns Whether the element was invoked.
78
+ */
79
+ invoke(machine, request, signal) {
80
+ return this.send(machine, "invoke", request, signal);
81
+ }
82
+ /**
83
+ * Clicks the pointer at an element's centre: `endia desktop click`.
84
+ *
85
+ * @param machine - The machine name or a unique prefix of its ID.
86
+ * @param request - The process, the selector and the button.
87
+ * @param signal - Cancels the request.
88
+ * @returns The point clicked on the screen.
89
+ */
90
+ click(machine, request, signal) {
91
+ return this.send(machine, "click", request, signal);
92
+ }
93
+ /**
94
+ * Sets an element's value, such as a text box's text: `endia desktop set-value`. A secret value, such as a password, is sent
95
+ * once, without an `Idempotency-Key` and without a retry, so that the service never stores it.
96
+ *
97
+ * @param machine - The machine name or a unique prefix of its ID.
98
+ * @param request - The process, the selector, the value, and whether it is secret.
99
+ * @param signal - Cancels the request.
100
+ * @returns The value read back, or null for a secret value.
101
+ */
102
+ setValue(machine, request, signal) {
103
+ const exchange = { method: "POST", path: Routes.desktop(machine, "set-value"), body: jsonBody(request), signal };
104
+ return request.secret === true ? this.connection.sendOnce(exchange) : this.connection.change(exchange);
105
+ }
106
+ /**
107
+ * Types keys or text into a process's main window: `endia desktop keys`. The service brings the window to the foreground and
108
+ * checks that it is there before sending anything; otherwise it refuses the request with `FOCUS_REFUSED`.
109
+ *
110
+ * @param machine - The machine name or a unique prefix of its ID.
111
+ * @param request - The process, and `keys` as space-separated chords such as `ctrl+s`, or `text` to type as it is.
112
+ * @param signal - Cancels the request.
113
+ * @returns The number of input events sent.
114
+ */
115
+ keys(machine, request, signal) {
116
+ return this.send(machine, "keys", request, signal);
117
+ }
118
+ /**
119
+ * Moves, clicks or scrolls the pointer at a point: `endia desktop pointer`.
120
+ *
121
+ * @param machine - The machine name or a unique prefix of its ID.
122
+ * @param request - The action, the point, and optionally the process whose window the point is relative to.
123
+ * @param signal - Cancels the request.
124
+ * @returns The point on the screen, and the window under it.
125
+ */
126
+ pointer(machine, request, signal) {
127
+ return this.send(machine, "pointer", request, signal);
128
+ }
129
+ /**
130
+ * Lists the visible top-level windows of the desktop user's session: `endia desktop windows`.
131
+ *
132
+ * @param machine - The machine name or a unique prefix of its ID.
133
+ * @param signal - Cancels the request.
134
+ * @returns The windows.
135
+ */
136
+ windows(machine, signal) {
137
+ return this.connection.read(Routes.desktop(machine, "windows"), signal);
138
+ }
139
+ /**
140
+ * Lists the icons of the notification area: `endia desktop tray ls`.
141
+ *
142
+ * @param machine - The machine name or a unique prefix of its ID.
143
+ * @param signal - Cancels the request.
144
+ * @returns The icons.
145
+ */
146
+ tray(machine, signal) {
147
+ return this.connection.read(Routes.desktop(machine, "tray"), signal);
148
+ }
149
+ /**
150
+ * Clicks an icon of the notification area: `endia desktop tray click`.
151
+ *
152
+ * @param machine - The machine name or a unique prefix of its ID.
153
+ * @param request - The icon's name and the button.
154
+ * @param signal - Cancels the request.
155
+ * @returns The icon and the point clicked.
156
+ */
157
+ trayClick(machine, request, signal) {
158
+ return this.send(machine, "tray/click", request, signal);
159
+ }
160
+ /**
161
+ * Answers an elevation prompt for an expected program: `endia desktop uac`. The request may carry a password, so it is sent
162
+ * once, without an `Idempotency-Key`, without a retry and without the client's time limit.
163
+ *
164
+ * @param machine - The machine name or a unique prefix of its ID.
165
+ * @param request - The program the prompt must name, and how to answer it.
166
+ * @param signal - Cancels the request.
167
+ * @returns The outcome, the prompt as read, and pictures of the screen before and after.
168
+ */
169
+ answerPrompt(machine, request, signal) {
170
+ return this.connection.sendOnce({ method: "POST", path: Routes.desktop(machine, "uac"), body: jsonBody(request), signal });
171
+ }
172
+ send(machine, action, request, signal) {
173
+ return this.connection.change({ method: "POST", path: Routes.desktop(machine, action), body: jsonBody(request), signal });
174
+ }
175
+ }
176
+ function header(answer, name) {
177
+ const value = answer.headers[name.toLowerCase()];
178
+ if (typeof value !== "string") {
179
+ throw new Error(`The service's screenshot came without the header ${name}.`);
180
+ }
181
+ return value;
182
+ }
@@ -0,0 +1,110 @@
1
+ import type { ExecCreated, ExecCreateRequest, ExecDetail, ExecStarted } from "../contract/execs.js";
2
+ import { ExecSession } from "../exec/exec-session.js";
3
+ /** What `ExecsClient.run` sends to the program and how it decodes what the program writes. */
4
+ export interface RunOptions {
5
+ /** Text or bytes sent to the program's standard input, which is then closed. The standard input is attached only when this is given. */
6
+ readonly input?: string | Uint8Array;
7
+ /** Cancels the requests; the program keeps running. */
8
+ readonly signal?: AbortSignal;
9
+ }
10
+ /** A program that has run to its end, with everything it wrote. */
11
+ export interface ExecResult {
12
+ /** The program's exit code in full, such as 3010; null when Windows restarted before the program ended. 127 means the program was not found, and 126 that it was found but could not start. */
13
+ readonly exitCode: number | null;
14
+ /** Why the program could not start, or null. */
15
+ readonly startError: string | null;
16
+ /** Everything the program wrote to standard output, decoded as UTF-8; with a console, all of its output. */
17
+ readonly stdout: string;
18
+ /** Everything the program wrote to standard error, decoded as UTF-8; empty with a console. */
19
+ readonly stderr: string;
20
+ /** The exec as the service recorded it at the end. */
21
+ readonly exec: ExecDetail;
22
+ }
23
+ /** A program started without the caller attached, as `endia exec -d` starts it. */
24
+ export interface DetachedExec extends ExecStarted {
25
+ /** The exec ID, which `inspect` takes. */
26
+ readonly id: string;
27
+ }
28
+ /**
29
+ * The exec routes, which run a program in a running machine as `docker exec` does: create the exec, then start it attached over a
30
+ * WebSocket or detached. `run`, `spawn` and `start` do both steps; `create`, `attach`, `startDetached`, `inspect` and `resize` are the
31
+ * single routes.
32
+ */
33
+ export declare class ExecsClient {
34
+ private readonly connection;
35
+ /**
36
+ * Runs a program to its end and collects its output: `endia exec`.
37
+ *
38
+ * @param machine - The machine name or a unique prefix of its ID.
39
+ * @param request - The program and its arguments in `cmd`, and how to run it.
40
+ * @param options - `input` is sent to the program's standard input.
41
+ * @returns The exit code in full and the output.
42
+ */
43
+ run(machine: string, request: ExecCreateRequest, options?: RunOptions): Promise<ExecResult>;
44
+ /**
45
+ * Starts a program with the caller attached to its streams: `endia exec` without collecting.
46
+ *
47
+ * @param machine - The machine name or a unique prefix of its ID.
48
+ * @param request - The program and its arguments in `cmd`, and how to run it. With `attachStdin`, the session's `stdin` is open.
49
+ * @param signal - Cancels the requests; the program keeps running once it has started.
50
+ * @returns The running program's streams; read both output streams.
51
+ */
52
+ spawn(machine: string, request: ExecCreateRequest, signal?: AbortSignal): Promise<ExecSession>;
53
+ /**
54
+ * Starts a program and returns at once: `endia exec -d`. The program's output is kept in the machine for
55
+ * `ProcessesClient.logs`.
56
+ *
57
+ * @param machine - The machine name or a unique prefix of its ID.
58
+ * @param request - The program and its arguments in `cmd`, and how to run it.
59
+ * @param signal - Cancels the requests.
60
+ * @returns The exec ID and the process the program runs in, which the process routes take.
61
+ */
62
+ start(machine: string, request: ExecCreateRequest, signal?: AbortSignal): Promise<DetachedExec>;
63
+ /**
64
+ * Creates an exec without starting it: `POST /v1/machines/{name}/exec`.
65
+ *
66
+ * @param machine - The machine name or a unique prefix of its ID.
67
+ * @param request - The program and its arguments in `cmd`, and how to run it.
68
+ * @param signal - Cancels the request.
69
+ * @returns The new exec's ID.
70
+ */
71
+ create(machine: string, request: ExecCreateRequest, signal?: AbortSignal): Promise<ExecCreated>;
72
+ /**
73
+ * Starts a created exec with the caller attached, over a WebSocket: `GET /v1/execs/{id}/start`.
74
+ *
75
+ * @param id - The exec ID.
76
+ * @param shape - Whether the exec was created with `tty` and with `attachStdin`, which decides how its messages are read and written.
77
+ * @param signal - Cancels the opening.
78
+ * @returns The running program's streams.
79
+ */
80
+ attach(id: string, shape: {
81
+ readonly tty: boolean;
82
+ readonly attachStdin: boolean;
83
+ }, signal?: AbortSignal): Promise<ExecSession>;
84
+ /**
85
+ * Starts a created exec without the caller attached: `POST /v1/execs/{id}/start` with `{ "detach": true }`.
86
+ *
87
+ * @param id - The exec ID.
88
+ * @param signal - Cancels the request.
89
+ * @returns The process the program runs in.
90
+ */
91
+ startDetached(id: string, signal?: AbortSignal): Promise<ExecStarted>;
92
+ /**
93
+ * Reads an exec: what was asked for, its process, and its exit code once it has ended.
94
+ *
95
+ * @param id - The exec ID.
96
+ * @param signal - Cancels the request.
97
+ * @returns The exec.
98
+ */
99
+ inspect(id: string, signal?: AbortSignal): Promise<ExecDetail>;
100
+ /**
101
+ * Changes the size of an exec's console.
102
+ *
103
+ * @param id - The exec ID.
104
+ * @param rows - The number of rows.
105
+ * @param columns - The number of columns.
106
+ * @param signal - Cancels the request.
107
+ * @returns When the service has resized the console.
108
+ */
109
+ resize(id: string, rows: number, columns: number, signal?: AbortSignal): Promise<void>;
110
+ }