@solarisdk/core 0.1.0 → 0.1.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.
- package/README.md +1 -1
- package/dist/desktop.d.ts +7 -0
- package/dist/desktop.d.ts.map +1 -1
- package/dist/desktop.js +40 -3
- package/dist/desktop.js.map +1 -1
- package/dist/errors.d.ts +5 -5
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -5
- package/dist/errors.js.map +1 -1
- package/dist/handle.d.ts +43 -1
- package/dist/handle.d.ts.map +1 -1
- package/dist/handle.js +239 -0
- package/dist/handle.js.map +1 -1
- package/dist/http.d.ts +2 -2
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +10 -7
- package/dist/http.js.map +1 -1
- package/dist/image.d.ts +1 -1
- package/dist/image.d.ts.map +1 -1
- package/dist/image.js +1 -1
- package/dist/image.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/template-client.js +6 -6
- package/dist/template-client.js.map +1 -1
- package/dist/transport.d.ts +10 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +57 -10
- package/dist/transport.js.map +1 -1
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/volume-client.d.ts +19 -0
- package/dist/volume-client.d.ts.map +1 -0
- package/dist/volume-client.js +53 -0
- package/dist/volume-client.js.map +1 -0
- package/dist/ws.js +17 -2
- package/dist/ws.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ You usually don't install this directly. Instead install a client package:
|
|
|
11
11
|
```bash
|
|
12
12
|
npm install @solarisdk/desktop # managed virtual desktops
|
|
13
13
|
npm install @solarisdk/sandbox # ephemeral compute sandboxes
|
|
14
|
-
npm install @solarisdk/sdk # unified client + `
|
|
14
|
+
npm install @solarisdk/sdk # unified client + `solari` CLI
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
`@solarisdk/core` is a dependency of all three and is installed automatically.
|
package/dist/desktop.d.ts
CHANGED
|
@@ -11,6 +11,13 @@ export interface DesktopConfig extends SessionConfig {
|
|
|
11
11
|
/** A live desktop session. Construct via {@link DesktopClient}. */
|
|
12
12
|
export declare class Desktop extends SessionHandle {
|
|
13
13
|
readonly streamUrl: string;
|
|
14
|
+
/**
|
|
15
|
+
* Presigned playback URL for the session recording — set when the session was
|
|
16
|
+
* created with `record: true`, `undefined` otherwise. The guest uploads the
|
|
17
|
+
* mp4 on `record.stop()`, so the URL only resolves once a recording has been
|
|
18
|
+
* started and stopped.
|
|
19
|
+
*/
|
|
20
|
+
readonly recordingUrl: string | undefined;
|
|
14
21
|
/** The session id (alias of {@link SessionHandle.id}; back-compat). */
|
|
15
22
|
get sessionId(): string;
|
|
16
23
|
constructor(session: CreateDesktopResponse, config?: DesktopConfig);
|
package/dist/desktop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktop.d.ts","sourceRoot":"","sources":["../src/desktop.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAqB,MAAM,aAAa,CAAC;AAEnF,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,YAAY,EAEZ,WAAW,EACX,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACd,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"desktop.d.ts","sourceRoot":"","sources":["../src/desktop.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAqB,MAAM,aAAa,CAAC;AAEnF,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,WAAW,EACX,UA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@@ -10,9 +10,35 @@
|
|
|
10
10
|
// `process`, `ports`, `pkg`) are kept too.
|
|
11
11
|
import { SessionHandle } from "./handle.js";
|
|
12
12
|
import { base64ToBytes } from "./transport.js";
|
|
13
|
+
/**
|
|
14
|
+
* Map a named {@link MouseButton} to the X11/xdotool button code the guest
|
|
15
|
+
* agent expects (`mouseParams.button` is an `int`): left=1, middle=2, right=3.
|
|
16
|
+
* `undefined` is passed through so the guest applies its own default (left).
|
|
17
|
+
* Without this the wire would carry a raw string and the guest's JSON decode
|
|
18
|
+
* fails with `cannot unmarshal string into ... button of type int`.
|
|
19
|
+
*/
|
|
20
|
+
function buttonToCode(button) {
|
|
21
|
+
if (button === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
switch (button) {
|
|
24
|
+
case "left":
|
|
25
|
+
return 1;
|
|
26
|
+
case "middle":
|
|
27
|
+
return 2;
|
|
28
|
+
case "right":
|
|
29
|
+
return 3;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
13
32
|
/** A live desktop session. Construct via {@link DesktopClient}. */
|
|
14
33
|
export class Desktop extends SessionHandle {
|
|
15
34
|
streamUrl;
|
|
35
|
+
/**
|
|
36
|
+
* Presigned playback URL for the session recording — set when the session was
|
|
37
|
+
* created with `record: true`, `undefined` otherwise. The guest uploads the
|
|
38
|
+
* mp4 on `record.stop()`, so the URL only resolves once a recording has been
|
|
39
|
+
* started and stopped.
|
|
40
|
+
*/
|
|
41
|
+
recordingUrl;
|
|
16
42
|
/** The session id (alias of {@link SessionHandle.id}; back-compat). */
|
|
17
43
|
get sessionId() {
|
|
18
44
|
return this.id;
|
|
@@ -29,6 +55,7 @@ export class Desktop extends SessionHandle {
|
|
|
29
55
|
hooks,
|
|
30
56
|
});
|
|
31
57
|
this.streamUrl = session.streamUrl;
|
|
58
|
+
this.recordingUrl = session.recordingUrl;
|
|
32
59
|
}
|
|
33
60
|
// GUI RPCs go over the shared control channel via the protected `rpc` hook.
|
|
34
61
|
guiCall(method, params) {
|
|
@@ -69,14 +96,24 @@ export class Desktop extends SessionHandle {
|
|
|
69
96
|
mouse = {
|
|
70
97
|
move: (x, y, opts = {}) => this.mouseCall(x, y, "move", undefined, opts.humanize),
|
|
71
98
|
click: (x, y, opts = {}) => this.mouseCall(x, y, "click", opts.button, opts.humanize),
|
|
72
|
-
doubleClick: (x, y, opts = {}) => this.guiCall("input.doubleClick", {
|
|
99
|
+
doubleClick: (x, y, opts = {}) => this.guiCall("input.doubleClick", {
|
|
100
|
+
x,
|
|
101
|
+
y,
|
|
102
|
+
button: buttonToCode(opts.button),
|
|
103
|
+
}).then(() => undefined),
|
|
73
104
|
down: (x, y, button = "left") => this.mouseCall(x, y, "down", button),
|
|
74
105
|
up: (x, y, button = "left") => this.mouseCall(x, y, "up", button),
|
|
75
106
|
scroll: (x, y, opts = {}) => this.mouseCall(x, y, "scroll", opts.button, opts.humanize),
|
|
76
|
-
drag: (from, to, button = "left") => this.guiCall("input.drag", { from, to, button }).then(() => undefined),
|
|
107
|
+
drag: (from, to, button = "left") => this.guiCall("input.drag", { from, to, button: buttonToCode(button) }).then(() => undefined),
|
|
77
108
|
};
|
|
78
109
|
mouseCall(x, y, action, button, humanize) {
|
|
79
|
-
return this.guiCall("input.mouse", {
|
|
110
|
+
return this.guiCall("input.mouse", {
|
|
111
|
+
x,
|
|
112
|
+
y,
|
|
113
|
+
action,
|
|
114
|
+
button: buttonToCode(button),
|
|
115
|
+
humanize,
|
|
116
|
+
}).then(() => undefined);
|
|
80
117
|
}
|
|
81
118
|
// --- keyboard -------------------------------------------------------------
|
|
82
119
|
keyboard = {
|
package/dist/desktop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktop.js","sourceRoot":"","sources":["../src/desktop.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,2EAA2E;AAC3E,qEAAqE;AACrE,yEAAyE;AACzE,yEAAyE;AACzE,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,+EAA+E;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ACH,OAAO,CAAC,CAAC,GAAG,CAAC;QACf,CAAC;QACD,MAAM,EAAE,CAAC,GAAW,EAAE,MAAe,EAAiB,EAAE,CACtD,IAAI,CAAC,OAAO,CAAe,gBAAgB,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;KACtF,CAAC;IAEF,6EAA6E;IAEpE,KAAK,GAAG;QACf,IAAI,EAAE,KAAK,IAAyB,EAAE;YACpC,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,OAAO,CAAwB,YAAY,EAAE,EAAE,CAAC,CAAC;YACtE,OAAO,CAAC,CAAC,KAAK,CAAC;QACjB,CAAC;KACF,CAAC;IAEF,6EAA6E;IAEpE,GAAG,GAAG;QACb,OAAO,EAAE,CAAC,OAAuB,EAAE,QAAkB,EAA6B,EAAE,CAClF,IAAI,CAAC,OAAO,CAAmB,aAAa,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;KACvE,CAAC;IAEF,6EAA6E;IAEpE,MAAM,GAAG;QAChB,KAAK,EAAE,CAAC,OAAyD,EAAE,EAA8B,EAAE,CACjG,IAAI,CAAC,OAAO,CAAoB,cAAc,EAAE,IAAI,CAAC;QACvD,IAAI,EAAE,GAA8B,EAAE,CAAC,IAAI,CAAC,OAAO,CAAmB,aAAa,EAAE,EAAE,CAAC;KACzF,CAAC;CACH"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { GatewayErrorBody } from "./types.js";
|
|
2
2
|
/** Base class for every error thrown by the SDK. */
|
|
3
|
-
export declare class
|
|
3
|
+
export declare class SolariError extends Error {
|
|
4
4
|
constructor(message: string);
|
|
5
5
|
}
|
|
6
6
|
/** Any non-2xx response from the gateway that isn't otherwise specialized. */
|
|
7
|
-
export declare class GatewayError extends
|
|
7
|
+
export declare class GatewayError extends SolariError {
|
|
8
8
|
readonly status: number;
|
|
9
9
|
readonly code?: string;
|
|
10
10
|
readonly body?: GatewayErrorBody;
|
|
@@ -27,19 +27,19 @@ export declare class NoCapacityError extends GatewayError {
|
|
|
27
27
|
constructor(message?: string, body?: GatewayErrorBody);
|
|
28
28
|
}
|
|
29
29
|
/** A computer-use RPC returned `{ok:false}`. */
|
|
30
|
-
export declare class ActionError extends
|
|
30
|
+
export declare class ActionError extends SolariError {
|
|
31
31
|
readonly method: string;
|
|
32
32
|
readonly code?: string;
|
|
33
33
|
constructor(method: string, message: string, code?: string);
|
|
34
34
|
}
|
|
35
35
|
/** An RPC did not receive a reply within the per-call timeout. */
|
|
36
|
-
export declare class TimeoutError extends
|
|
36
|
+
export declare class TimeoutError extends SolariError {
|
|
37
37
|
readonly method: string;
|
|
38
38
|
readonly timeoutMs: number;
|
|
39
39
|
constructor(method: string, timeoutMs: number);
|
|
40
40
|
}
|
|
41
41
|
/** The control WebSocket is not open (never connected, or closed). */
|
|
42
|
-
export declare class ConnectionError extends
|
|
42
|
+
export declare class ConnectionError extends SolariError {
|
|
43
43
|
constructor(message?: string);
|
|
44
44
|
}
|
|
45
45
|
/**
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,oDAAoD;AACpD,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,oDAAoD;AACpD,qBAAa,WAAY,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI5B;AAED,8EAA8E;AAC9E,qBAAa,YAAa,SAAQ,WAAW;IAC3C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EA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1,14 @@
|
|
|
1
1
|
// Typed errors. Gateway HTTP status codes (§1) and control-channel RPC
|
|
2
2
|
// failures (§4) are mapped onto these so callers can branch on `instanceof`.
|
|
3
3
|
/** Base class for every error thrown by the SDK. */
|
|
4
|
-
export class
|
|
4
|
+
export class SolariError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.name = new.target.name;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
/** Any non-2xx response from the gateway that isn't otherwise specialized. */
|
|
11
|
-
export class GatewayError extends
|
|
11
|
+
export class GatewayError extends SolariError {
|
|
12
12
|
status;
|
|
13
13
|
code;
|
|
14
14
|
body;
|
|
@@ -44,7 +44,7 @@ export class NoCapacityError extends GatewayError {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
/** A computer-use RPC returned `{ok:false}`. */
|
|
47
|
-
export class ActionError extends
|
|
47
|
+
export class ActionError extends SolariError {
|
|
48
48
|
method;
|
|
49
49
|
code;
|
|
50
50
|
constructor(method, message, code) {
|
|
@@ -54,7 +54,7 @@ export class ActionError extends PinetreeError {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
/** An RPC did not receive a reply within the per-call timeout. */
|
|
57
|
-
export class TimeoutError extends
|
|
57
|
+
export class TimeoutError extends SolariError {
|
|
58
58
|
method;
|
|
59
59
|
timeoutMs;
|
|
60
60
|
constructor(method, timeoutMs) {
|
|
@@ -64,7 +64,7 @@ export class TimeoutError extends PinetreeError {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
/** The control WebSocket is not open (never connected, or closed). */
|
|
67
|
-
export class ConnectionError extends
|
|
67
|
+
export class ConnectionError extends SolariError {
|
|
68
68
|
constructor(message = "Control channel is not connected") {
|
|
69
69
|
super(message);
|
|
70
70
|
}
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],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AAO,IAAI,qBAAqB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC9C,KAAK,GAAG;YACN,OAAO,IAAI,eAAe,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACxC;YACE,OAAO,IAAI,YAAY,CACrB,MAAM,EACN,GAAG,IAAI,sCAAsC,MAAM,EAAE,EACrD,IAAI,CACL,CAAC;IACN,CAAC;AACH,CAAC"}
|
package/dist/handle.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ControlChannel, type ControlChannelConfig } from "./transport.js";
|
|
2
|
-
import type { CommandHandle, CommandOptions, CommandResult, FsEntry, FsSearchMatch, FsStat, FsWatchEvent, MetricsResult, PtyHandle, PtyOptions, RunCodeOptions, RunCodeResult } from "./types.js";
|
|
2
|
+
import type { CommandHandle, CommandOptions, CommandResult, ExecOneShotRequest, FsEntry, FsSearchMatch, FsStat, FsWatchEvent, GitBranch, GitCloneOptions, GitCommit, GitCommitOptions, GitLogOptions, GitRemoteOptions, GitStatus, MetricsResult, PtyHandle, PtyOptions, RunCodeOptions, RunCodeResult } from "./types.js";
|
|
3
3
|
/** Wiring supplied by the owning sub-client so handle-level admin calls reach
|
|
4
4
|
* the gateway without the handle holding an HTTP client. */
|
|
5
5
|
export interface SessionHooks {
|
|
@@ -36,6 +36,9 @@ export interface SessionHooks {
|
|
|
36
36
|
url: string;
|
|
37
37
|
token?: string;
|
|
38
38
|
}>;
|
|
39
|
+
/** `POST /sandboxes/:id/exec` — one-shot command over the warm REST
|
|
40
|
+
* connection (no control WS). Returns the terminal result directly. */
|
|
41
|
+
exec?(id: string, req: ExecOneShotRequest): Promise<CommandResult>;
|
|
39
42
|
/** `DELETE /sandboxes/:id`. */
|
|
40
43
|
kill?(id: string): Promise<void>;
|
|
41
44
|
}
|
|
@@ -137,6 +140,45 @@ export declare class SessionHandle {
|
|
|
137
140
|
*/
|
|
138
141
|
mount: (volId: string, path: string) => Promise<void>;
|
|
139
142
|
};
|
|
143
|
+
readonly git: {
|
|
144
|
+
/** Clone `url` into `opts.path` (or git's default dir) under `opts.cwd`. */
|
|
145
|
+
clone: (url: string, opts?: GitCloneOptions) => Promise<void>;
|
|
146
|
+
/** Parsed working-tree status (branch, ahead/behind, staged/modified/untracked). */
|
|
147
|
+
status: (cwd?: string) => Promise<GitStatus>;
|
|
148
|
+
/** Stage `paths` (use `["."]` for everything). */
|
|
149
|
+
add: (paths: string[], cwd?: string) => Promise<void>;
|
|
150
|
+
/** Commit staged changes; returns the new commit hash. */
|
|
151
|
+
commit: (message: string, opts?: GitCommitOptions) => Promise<{
|
|
152
|
+
hash: string;
|
|
153
|
+
}>;
|
|
154
|
+
/** Push to a remote (default `origin` + current branch). */
|
|
155
|
+
push: (opts?: GitRemoteOptions) => Promise<void>;
|
|
156
|
+
/** Pull from a remote (default `origin` + current branch). */
|
|
157
|
+
pull: (opts?: GitRemoteOptions) => Promise<void>;
|
|
158
|
+
/** Check out an existing ref, or create a branch with `{ create: true }`. */
|
|
159
|
+
checkout: (ref: string, opts?: {
|
|
160
|
+
cwd?: string;
|
|
161
|
+
create?: boolean;
|
|
162
|
+
}) => Promise<void>;
|
|
163
|
+
/** List local branches (name, short commit, whether it's HEAD). */
|
|
164
|
+
branches: (cwd?: string) => Promise<GitBranch[]>;
|
|
165
|
+
/** Recent commits, newest first. */
|
|
166
|
+
log: (opts?: GitLogOptions) => Promise<GitCommit[]>;
|
|
167
|
+
};
|
|
168
|
+
/** Run `git <args>` in the guest via the command RPC (no shell). */
|
|
169
|
+
private runGit;
|
|
170
|
+
/** Run `git <args>`; throw with the stderr on a non-zero exit. */
|
|
171
|
+
private mustGit;
|
|
172
|
+
/** Splice basic-auth creds into an https remote URL (for private remotes). */
|
|
173
|
+
private authUrl;
|
|
174
|
+
private gitClone;
|
|
175
|
+
private gitStatus;
|
|
176
|
+
private gitAdd;
|
|
177
|
+
private gitCommit;
|
|
178
|
+
private gitPushPull;
|
|
179
|
+
private gitCheckout;
|
|
180
|
+
private gitBranches;
|
|
181
|
+
private gitLog;
|
|
140
182
|
/** Live resource metrics. */
|
|
141
183
|
metrics(): Promise<MetricsResult>;
|
|
142
184
|
/** Checkpoint this RUNNING session; it keeps running. Returns the snapshot id. */
|
package/dist/handle.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"handle.d.ts","sourceRoot":"","sources":["../src/handle.ts"],"names":[],"mappings":"AAcA,OAAO,EAGL,cAAc,EAEd,KAAK,oBAAoB,EAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,kBAAkB,EAGlB,OAAO,EACP,aAAa,EACb,MAAM,EACN,YAAY,EACZ,SAAS,EACT,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,SAAS,EACT,UAAU,EACV,cAAc,EACd,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB;4DAC4D;AAC5D,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,OAAO,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IAC7C,uCAAuC;IACvC,QAAQ,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtE,oCAAoC;IACpC,MAAM,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,mCAAmC;IACnC,KAAK,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,uDAAuD;IACvD,MAAM,CAAC,CAAC,EAAE,EA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FAAkF;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ9C,uEAAuE;IACvE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOzC,4EAA4E;IACtE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ5B,gFAAgF;IAC1E,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAS7B,yCAAyC;IACzC,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IAS7D;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAOlE,oEAAoE;IAC9D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAI5B;AAYD,8EAA8E;AAC9E,KAAK,eAAe,GAAG,QAAQ,GAAG,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,GAAG,CAAC"}
|
package/dist/handle.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// dispatched by the ControlChannel by `type` + the stream's own id, NOT by the
|
|
11
11
|
// originating request id. We register/unregister those frame handlers as
|
|
12
12
|
// commands/ptys/watches are created and torn down.
|
|
13
|
+
import { GatewayError } from "./errors.js";
|
|
13
14
|
import { base64ToBytes, bytesToBase64, ControlChannel, } from "./transport.js";
|
|
14
15
|
export class SessionHandle {
|
|
15
16
|
/** The session id (sandboxId / sessionId). */
|
|
@@ -134,6 +135,39 @@ export class SessionHandle {
|
|
|
134
135
|
};
|
|
135
136
|
}
|
|
136
137
|
async runCommand(cmd, opts) {
|
|
138
|
+
// One-shot HTTP fast path: for a plain run-to-completion (no streaming
|
|
139
|
+
// callbacks, not backgrounded, no per-command env/user) run the command
|
|
140
|
+
// over the already-warm REST connection instead of paying a cold control-WS
|
|
141
|
+
// handshake. That handshake (~180ms TCP+TLS to the gateway) dominates the
|
|
142
|
+
// "create → run one command" latency, so skipping it is the single biggest
|
|
143
|
+
// TTI win. We only take this path when the control channel isn't already
|
|
144
|
+
// open — if it is, the WS is cheaper and streams. env/user are excluded
|
|
145
|
+
// because the one-shot guest path runs under the session env only; routing
|
|
146
|
+
// those through the streaming path keeps behavior identical.
|
|
147
|
+
if (this.hooks.exec &&
|
|
148
|
+
!opts.background &&
|
|
149
|
+
!opts.onStdout &&
|
|
150
|
+
!opts.onStderr &&
|
|
151
|
+
!opts.env &&
|
|
152
|
+
!opts.user &&
|
|
153
|
+
!this.channel.connected) {
|
|
154
|
+
try {
|
|
155
|
+
return await this.hooks.exec(this.id, {
|
|
156
|
+
cmd,
|
|
157
|
+
args: opts.args,
|
|
158
|
+
cwd: opts.cwd,
|
|
159
|
+
timeoutMs: opts.timeoutMs,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
// Fall back to the WS path ONLY when the one-shot route is unavailable
|
|
164
|
+
// (an older gateway without /exec). Any other failure — including a
|
|
165
|
+
// real host/command error — propagates, so we never silently
|
|
166
|
+
// double-execute a command that may have already run guest-side.
|
|
167
|
+
if (!isRouteUnavailable(err))
|
|
168
|
+
throw err;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
137
171
|
const handle = await this.startCommand(cmd, opts);
|
|
138
172
|
let stdout = "";
|
|
139
173
|
let stderr = "";
|
|
@@ -314,6 +348,204 @@ export class SessionHandle {
|
|
|
314
348
|
.call("volume.mount", { volumeId: volId, path })
|
|
315
349
|
.then(() => undefined),
|
|
316
350
|
};
|
|
351
|
+
// --- git ------------------------------------------------------------------
|
|
352
|
+
// A first-class version-control surface (Daytona-parity). Every method is a
|
|
353
|
+
// safe, non-shell `git` invocation over the existing command RPC (`cmd` +
|
|
354
|
+
// `args`, never a shell string), so there is no injection surface and it runs
|
|
355
|
+
// against any guest that has `git` on PATH — which the base image ships. No
|
|
356
|
+
// guest/gateway change is required.
|
|
357
|
+
git = {
|
|
358
|
+
/** Clone `url` into `opts.path` (or git's default dir) under `opts.cwd`. */
|
|
359
|
+
clone: (url, opts = {}) => this.gitClone(url, opts),
|
|
360
|
+
/** Parsed working-tree status (branch, ahead/behind, staged/modified/untracked). */
|
|
361
|
+
status: (cwd) => this.gitStatus(cwd),
|
|
362
|
+
/** Stage `paths` (use `["."]` for everything). */
|
|
363
|
+
add: (paths, cwd) => this.gitAdd(paths, cwd),
|
|
364
|
+
/** Commit staged changes; returns the new commit hash. */
|
|
365
|
+
commit: (message, opts = {}) => this.gitCommit(message, opts),
|
|
366
|
+
/** Push to a remote (default `origin` + current branch). */
|
|
367
|
+
push: (opts = {}) => this.gitPushPull("push", opts),
|
|
368
|
+
/** Pull from a remote (default `origin` + current branch). */
|
|
369
|
+
pull: (opts = {}) => this.gitPushPull("pull", opts),
|
|
370
|
+
/** Check out an existing ref, or create a branch with `{ create: true }`. */
|
|
371
|
+
checkout: (ref, opts = {}) => this.gitCheckout(ref, opts),
|
|
372
|
+
/** List local branches (name, short commit, whether it's HEAD). */
|
|
373
|
+
branches: (cwd) => this.gitBranches(cwd),
|
|
374
|
+
/** Recent commits, newest first. */
|
|
375
|
+
log: (opts = {}) => this.gitLog(opts),
|
|
376
|
+
};
|
|
377
|
+
/** Run `git <args>` in the guest via the command RPC (no shell). */
|
|
378
|
+
async runGit(args, cwd) {
|
|
379
|
+
return this.runCommand("git", { args, ...(cwd ? { cwd } : {}) });
|
|
380
|
+
}
|
|
381
|
+
/** Run `git <args>`; throw with the stderr on a non-zero exit. */
|
|
382
|
+
async mustGit(args, cwd) {
|
|
383
|
+
const r = await this.runGit(args, cwd);
|
|
384
|
+
if (r.exitCode !== 0) {
|
|
385
|
+
const detail = (r.stderr || r.stdout || "").trim();
|
|
386
|
+
throw new Error(`git ${args[0]} failed (exit ${r.exitCode}): ${detail}`);
|
|
387
|
+
}
|
|
388
|
+
return r.stdout;
|
|
389
|
+
}
|
|
390
|
+
/** Splice basic-auth creds into an https remote URL (for private remotes). */
|
|
391
|
+
authUrl(url, username, password) {
|
|
392
|
+
if (!username && !password)
|
|
393
|
+
return url;
|
|
394
|
+
try {
|
|
395
|
+
const u = new URL(url);
|
|
396
|
+
if (username)
|
|
397
|
+
u.username = encodeURIComponent(username);
|
|
398
|
+
if (password)
|
|
399
|
+
u.password = encodeURIComponent(password);
|
|
400
|
+
return u.toString();
|
|
401
|
+
}
|
|
402
|
+
catch {
|
|
403
|
+
return url; // ssh/scp-style or malformed — leave untouched
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
async gitClone(url, opts) {
|
|
407
|
+
const args = ["clone"];
|
|
408
|
+
if (opts.depth && opts.depth > 0)
|
|
409
|
+
args.push("--depth", String(opts.depth));
|
|
410
|
+
if (opts.branch)
|
|
411
|
+
args.push("--branch", opts.branch);
|
|
412
|
+
args.push(this.authUrl(url, opts.username, opts.password));
|
|
413
|
+
if (opts.path)
|
|
414
|
+
args.push(opts.path);
|
|
415
|
+
await this.mustGit(args, opts.cwd);
|
|
416
|
+
}
|
|
417
|
+
async gitStatus(cwd) {
|
|
418
|
+
const out = await this.mustGit(["status", "--porcelain=v1", "--branch"], cwd);
|
|
419
|
+
const lines = out.split("\n").filter((l) => l.length > 0);
|
|
420
|
+
const st = {
|
|
421
|
+
branch: "",
|
|
422
|
+
detached: false,
|
|
423
|
+
ahead: 0,
|
|
424
|
+
behind: 0,
|
|
425
|
+
staged: [],
|
|
426
|
+
modified: [],
|
|
427
|
+
untracked: [],
|
|
428
|
+
clean: true,
|
|
429
|
+
};
|
|
430
|
+
for (const line of lines) {
|
|
431
|
+
if (line.startsWith("## ")) {
|
|
432
|
+
const head = line.slice(3);
|
|
433
|
+
if (head.startsWith("HEAD (no branch)")) {
|
|
434
|
+
st.detached = true;
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
// "main...origin/main [ahead 1, behind 2]" | "main" | "No commits yet on main"
|
|
438
|
+
const noCommits = head.match(/^No commits yet on (.+)$/);
|
|
439
|
+
const body = noCommits?.[1] ?? head;
|
|
440
|
+
st.branch = (body.split("...")[0] ?? "").split(" ")[0] ?? "";
|
|
441
|
+
const ab = head.match(/\[(.*)\]/);
|
|
442
|
+
if (ab) {
|
|
443
|
+
const inner = ab[1] ?? "";
|
|
444
|
+
const a = inner.match(/ahead (\d+)/);
|
|
445
|
+
const b = inner.match(/behind (\d+)/);
|
|
446
|
+
if (a?.[1])
|
|
447
|
+
st.ahead = Number(a[1]);
|
|
448
|
+
if (b?.[1])
|
|
449
|
+
st.behind = Number(b[1]);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
const xy = line.slice(0, 2);
|
|
455
|
+
const path = line.slice(3);
|
|
456
|
+
if (xy === "??") {
|
|
457
|
+
st.untracked.push(path);
|
|
458
|
+
}
|
|
459
|
+
else if (xy.length === 2) {
|
|
460
|
+
const index = xy[0];
|
|
461
|
+
const work = xy[1];
|
|
462
|
+
if (index !== " " && index !== "?")
|
|
463
|
+
st.staged.push(path);
|
|
464
|
+
if (work !== " " && work !== "?")
|
|
465
|
+
st.modified.push(path);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
st.clean = st.staged.length === 0 && st.modified.length === 0 && st.untracked.length === 0;
|
|
469
|
+
return st;
|
|
470
|
+
}
|
|
471
|
+
async gitAdd(paths, cwd) {
|
|
472
|
+
if (paths.length === 0)
|
|
473
|
+
return;
|
|
474
|
+
await this.mustGit(["add", "--", ...paths], cwd);
|
|
475
|
+
}
|
|
476
|
+
async gitCommit(message, opts) {
|
|
477
|
+
// `-c user.name/email` scopes identity to this one commit without mutating
|
|
478
|
+
// the repo/global config — handy in an ephemeral sandbox with no git identity.
|
|
479
|
+
const args = [];
|
|
480
|
+
if (opts.author)
|
|
481
|
+
args.push("-c", `user.name=${opts.author}`);
|
|
482
|
+
if (opts.email)
|
|
483
|
+
args.push("-c", `user.email=${opts.email}`);
|
|
484
|
+
args.push("commit", "-m", message);
|
|
485
|
+
if (opts.all)
|
|
486
|
+
args.push("-a");
|
|
487
|
+
await this.mustGit(args, opts.cwd);
|
|
488
|
+
const hash = (await this.mustGit(["rev-parse", "HEAD"], opts.cwd)).trim();
|
|
489
|
+
return { hash };
|
|
490
|
+
}
|
|
491
|
+
async gitPushPull(op, opts) {
|
|
492
|
+
const remote = opts.remote || "origin";
|
|
493
|
+
// One-off HTTPS auth without persisting a credential: rewrite the remote's
|
|
494
|
+
// URL for just this invocation via `-c url.<authed>.insteadOf=<plain>`.
|
|
495
|
+
const cfg = [];
|
|
496
|
+
if (opts.username || opts.password) {
|
|
497
|
+
const plain = (await this.runGit(["remote", "get-url", remote], opts.cwd)).stdout.trim();
|
|
498
|
+
if (plain) {
|
|
499
|
+
const authed = this.authUrl(plain, opts.username, opts.password);
|
|
500
|
+
if (authed !== plain)
|
|
501
|
+
cfg.push("-c", `url.${authed}.insteadOf=${plain}`);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
const args = [...cfg, op, remote];
|
|
505
|
+
if (opts.branch)
|
|
506
|
+
args.push(opts.branch);
|
|
507
|
+
await this.mustGit(args, opts.cwd);
|
|
508
|
+
}
|
|
509
|
+
async gitCheckout(ref, opts) {
|
|
510
|
+
const args = ["checkout"];
|
|
511
|
+
if (opts.create)
|
|
512
|
+
args.push("-b");
|
|
513
|
+
args.push(ref);
|
|
514
|
+
await this.mustGit(args, opts.cwd);
|
|
515
|
+
}
|
|
516
|
+
async gitBranches(cwd) {
|
|
517
|
+
// A stable, parse-friendly format (unit-separated) instead of the porcelain
|
|
518
|
+
// `* main` layout, so branch names with spaces/`*` never confuse the parser.
|
|
519
|
+
const out = await this.mustGit(["branch", "--format=%(HEAD)%1f%(refname:short)%1f%(objectname:short)"], cwd);
|
|
520
|
+
const branches = [];
|
|
521
|
+
for (const line of out.split("\n")) {
|
|
522
|
+
if (!line.trim())
|
|
523
|
+
continue;
|
|
524
|
+
const [head, name, commit] = line.split("\x1f");
|
|
525
|
+
branches.push({ name: name ?? "", commit: commit ?? "", current: head === "*" });
|
|
526
|
+
}
|
|
527
|
+
return branches;
|
|
528
|
+
}
|
|
529
|
+
async gitLog(opts) {
|
|
530
|
+
const args = ["log", "--format=%H%x1f%an%x1f%ae%x1f%aI%x1f%s"];
|
|
531
|
+
if (opts.maxCount && opts.maxCount > 0)
|
|
532
|
+
args.push(`--max-count=${opts.maxCount}`);
|
|
533
|
+
const out = await this.mustGit(args, opts.cwd);
|
|
534
|
+
const commits = [];
|
|
535
|
+
for (const line of out.split("\n")) {
|
|
536
|
+
if (!line.trim())
|
|
537
|
+
continue;
|
|
538
|
+
const [hash, author, email, date, message] = line.split("\x1f");
|
|
539
|
+
commits.push({
|
|
540
|
+
hash: hash ?? "",
|
|
541
|
+
author: author ?? "",
|
|
542
|
+
email: email ?? "",
|
|
543
|
+
date: date ?? "",
|
|
544
|
+
message: message ?? "",
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
return commits;
|
|
548
|
+
}
|
|
317
549
|
// --- lifecycle / admin (gateway-routed via hooks) -------------------------
|
|
318
550
|
/** Live resource metrics. */
|
|
319
551
|
metrics() {
|
|
@@ -379,6 +611,13 @@ export class SessionHandle {
|
|
|
379
611
|
this.close();
|
|
380
612
|
}
|
|
381
613
|
}
|
|
614
|
+
/** True when an error means the one-shot `/exec` route isn't served (an older
|
|
615
|
+
* gateway) — the only case where `runCommand` retries over the control WS. A
|
|
616
|
+
* real host/command failure is NOT route-unavailable and must propagate. */
|
|
617
|
+
function isRouteUnavailable(err) {
|
|
618
|
+
return (err instanceof GatewayError &&
|
|
619
|
+
(err.status === 404 || err.status === 405 || err.status === 501));
|
|
620
|
+
}
|
|
382
621
|
function toB64(data) {
|
|
383
622
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
384
623
|
return bytesToBase64(bytes);
|