@celljs/ta-protocol 4.15.2 → 4.16.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/esm/common/gateway-protocol.d.ts +25 -2
- package/esm/common/location.d.ts +18 -1
- package/esm/common/location.js +51 -4
- package/esm/common/remote-protocol.d.ts +12 -4
- package/lib/common/gateway-protocol.d.ts +25 -2
- package/lib/common/location.d.ts +18 -1
- package/lib/common/location.js +51 -4
- package/lib/common/remote-protocol.d.ts +12 -4
- package/package.json +1 -1
|
@@ -14,6 +14,11 @@ export type TaGatewayRole = 'owner' | 'admin' | 'member';
|
|
|
14
14
|
export interface TaGatewayLimits {
|
|
15
15
|
/** Minutes a month their sandbox may run, free. */
|
|
16
16
|
freeMinutes?: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Tokens a month their agents may take through the models of the gateway (models.json of the gateway), counted
|
|
19
|
+
* by the gateway as it passes the calls; past them, calls are refused until the next month.
|
|
20
|
+
*/
|
|
21
|
+
monthlyTokens?: number | null;
|
|
17
22
|
/** Messages a minute they may send their agents (prompts, steering, follow-ups). */
|
|
18
23
|
promptsPerMinute?: number | null;
|
|
19
24
|
/** Pages connected at once. */
|
|
@@ -38,12 +43,14 @@ export interface TaQuotaState {
|
|
|
38
43
|
bonus: number;
|
|
39
44
|
};
|
|
40
45
|
/**
|
|
41
|
-
* Tokens this month
|
|
42
|
-
*
|
|
46
|
+
* Tokens this month. `metered`: counted by the gateway, whose models the sandbox calls through it, and held to
|
|
47
|
+
* `limit`; else as the agents' sessions say, shown only (the sandbox is the member's, its files too).
|
|
43
48
|
*/
|
|
44
49
|
tokens: {
|
|
45
50
|
used: number;
|
|
46
51
|
cost: number;
|
|
52
|
+
limit?: number;
|
|
53
|
+
metered: boolean;
|
|
47
54
|
};
|
|
48
55
|
promptsPerMinute?: number;
|
|
49
56
|
connections?: number;
|
|
@@ -269,6 +276,13 @@ export interface TaGatewayConsole {
|
|
|
269
276
|
/** That of the one who looks. */
|
|
270
277
|
role: TaGatewayRole;
|
|
271
278
|
policy: TaGatewayPolicy;
|
|
279
|
+
/** The providers of models the gateway gives its sandboxes (models.json of the gateway), without their keys. */
|
|
280
|
+
models: {
|
|
281
|
+
id: string;
|
|
282
|
+
name?: string;
|
|
283
|
+
api: string;
|
|
284
|
+
models: number;
|
|
285
|
+
}[];
|
|
272
286
|
}
|
|
273
287
|
/**
|
|
274
288
|
* `ta gateway`: each account that signs in is a tenant with a Ta of its own, in a sandbox of its own, which
|
|
@@ -321,4 +335,13 @@ export interface TaGatewayServer {
|
|
|
321
335
|
setRole(account: string, role: 'admin' | 'member'): Promise<TaGatewayPolicy>;
|
|
322
336
|
/** For administrators: what administrators did lately, newest first, `limit` at most (100 by default). */
|
|
323
337
|
getAudit(limit?: number): Promise<TaGatewayAuditEntry[]>;
|
|
338
|
+
/**
|
|
339
|
+
* A token of one's own account for another Ta to use one's sandbox as a cloud workspace (`ta://<name>`, its
|
|
340
|
+
* exec server at `/api/exec` of the gateway) or to open one's Ta: a sign-in, listed with one's browsers in
|
|
341
|
+
* Access, signed out there. `url`: TA_PUBLIC_URL, where the gateway is reached.
|
|
342
|
+
*/
|
|
343
|
+
createAccessToken(label?: string): Promise<{
|
|
344
|
+
token: string;
|
|
345
|
+
url?: string;
|
|
346
|
+
}>;
|
|
324
347
|
}
|
package/esm/common/location.d.ts
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace TaLocation {
|
|
8
8
|
const SSH = "ssh://";
|
|
9
|
+
/**
|
|
10
|
+
* A directory of a cloud workspace: `ta://<name>/<path>`, the sandbox of a Ta gateway (or any Ta service)
|
|
11
|
+
* the user added under that name, reached over its WebSocket (`/api/exec`), not ssh. Its host, as the
|
|
12
|
+
* functions here take it, is `ta://<name>`.
|
|
13
|
+
*/
|
|
14
|
+
const CLOUD = "ta://";
|
|
9
15
|
/** A directory of another machine. */
|
|
10
16
|
interface Remote {
|
|
11
17
|
host: string;
|
|
@@ -13,6 +19,14 @@ export declare namespace TaLocation {
|
|
|
13
19
|
path: string;
|
|
14
20
|
}
|
|
15
21
|
function isRemote(location: string): boolean;
|
|
22
|
+
/** Whether a host is a cloud workspace (`ta://<name>`), not one of ssh. */
|
|
23
|
+
function isCloud(host: string | undefined): boolean;
|
|
24
|
+
/** Whether a name may name a cloud workspace: lower-case letters, digits and -, 40 at most. */
|
|
25
|
+
function isCloudName(name: string): boolean;
|
|
26
|
+
/** `ta://<name><path>`. */
|
|
27
|
+
function cloud(name: string, path?: string): string;
|
|
28
|
+
/** The name of a cloud workspace, of its host or of a location there. */
|
|
29
|
+
function cloudName(hostOrLocation: string): string | undefined;
|
|
16
30
|
/** undefined for a path of the machine of ta serve; throws for an `ssh://` location that is not one. */
|
|
17
31
|
function parse(location: string): Remote | undefined;
|
|
18
32
|
function isHost(host: string): boolean;
|
|
@@ -31,7 +45,10 @@ export declare namespace TaLocation {
|
|
|
31
45
|
* cannot hold (`-i`, `-J`, `-o ProxyCommand=…`) belong in ~/.ssh/config: they come back as `options`.
|
|
32
46
|
*/
|
|
33
47
|
function readHost(input: string): HostInput;
|
|
34
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* The location of a path on a host: `ssh://<host><path>`, or `ta://<name><path>` for the host of a cloud
|
|
50
|
+
* workspace; `path` absolute, or empty for the home directory.
|
|
51
|
+
*/
|
|
35
52
|
function ssh(host: string, path?: string): string;
|
|
36
53
|
/**
|
|
37
54
|
* A host as a list shows it, short: the name of the machine, without the user, the port and the domain
|
package/esm/common/location.js
CHANGED
|
@@ -7,17 +7,58 @@
|
|
|
7
7
|
export var TaLocation;
|
|
8
8
|
(function (TaLocation) {
|
|
9
9
|
TaLocation.SSH = 'ssh://';
|
|
10
|
+
/**
|
|
11
|
+
* A directory of a cloud workspace: `ta://<name>/<path>`, the sandbox of a Ta gateway (or any Ta service)
|
|
12
|
+
* the user added under that name, reached over its WebSocket (`/api/exec`), not ssh. Its host, as the
|
|
13
|
+
* functions here take it, is `ta://<name>`.
|
|
14
|
+
*/
|
|
15
|
+
TaLocation.CLOUD = 'ta://';
|
|
16
|
+
const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
10
17
|
/** Letters, digits and `_ . @ : % + - [ ]`, not first a `-`: ssh must not read a host as an option. */
|
|
11
18
|
const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
|
|
12
19
|
function isRemote(location) {
|
|
13
|
-
return location.startsWith(TaLocation.SSH);
|
|
20
|
+
return location.startsWith(TaLocation.SSH) || location.startsWith(TaLocation.CLOUD);
|
|
14
21
|
}
|
|
15
22
|
TaLocation.isRemote = isRemote;
|
|
23
|
+
/** Whether a host is a cloud workspace (`ta://<name>`), not one of ssh. */
|
|
24
|
+
function isCloud(host) {
|
|
25
|
+
return !!host && host.startsWith(TaLocation.CLOUD);
|
|
26
|
+
}
|
|
27
|
+
TaLocation.isCloud = isCloud;
|
|
28
|
+
/** Whether a name may name a cloud workspace: lower-case letters, digits and -, 40 at most. */
|
|
29
|
+
function isCloudName(name) {
|
|
30
|
+
return CLOUD_NAME.test(name);
|
|
31
|
+
}
|
|
32
|
+
TaLocation.isCloudName = isCloudName;
|
|
33
|
+
/** `ta://<name><path>`. */
|
|
34
|
+
function cloud(name, path = '') {
|
|
35
|
+
return `${TaLocation.CLOUD}${name}${path ? normalize(path) : ''}`;
|
|
36
|
+
}
|
|
37
|
+
TaLocation.cloud = cloud;
|
|
38
|
+
/** The name of a cloud workspace, of its host or of a location there. */
|
|
39
|
+
function cloudName(hostOrLocation) {
|
|
40
|
+
if (!hostOrLocation.startsWith(TaLocation.CLOUD)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const rest = hostOrLocation.slice(TaLocation.CLOUD.length);
|
|
44
|
+
const slash = rest.indexOf('/');
|
|
45
|
+
return slash < 0 ? rest : rest.slice(0, slash);
|
|
46
|
+
}
|
|
47
|
+
TaLocation.cloudName = cloudName;
|
|
16
48
|
/** undefined for a path of the machine of ta serve; throws for an `ssh://` location that is not one. */
|
|
17
49
|
function parse(location) {
|
|
50
|
+
var _a;
|
|
18
51
|
if (!isRemote(location)) {
|
|
19
52
|
return undefined;
|
|
20
53
|
}
|
|
54
|
+
if (location.startsWith(TaLocation.CLOUD)) {
|
|
55
|
+
const name = (_a = cloudName(location)) !== null && _a !== void 0 ? _a : '';
|
|
56
|
+
if (!isCloudName(name)) {
|
|
57
|
+
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
58
|
+
}
|
|
59
|
+
const path = location.slice(TaLocation.CLOUD.length + name.length);
|
|
60
|
+
return { host: `${TaLocation.CLOUD}${name}`, path: path ? normalize(path) : '' };
|
|
61
|
+
}
|
|
21
62
|
const rest = location.slice(TaLocation.SSH.length);
|
|
22
63
|
const slash = rest.indexOf('/');
|
|
23
64
|
const host = slash < 0 ? rest : rest.slice(0, slash);
|
|
@@ -29,7 +70,7 @@ export var TaLocation;
|
|
|
29
70
|
}
|
|
30
71
|
TaLocation.parse = parse;
|
|
31
72
|
function isHost(host) {
|
|
32
|
-
return HOST.test(host);
|
|
73
|
+
return isCloud(host) ? isCloudName(host.slice(TaLocation.CLOUD.length)) : HOST.test(host);
|
|
33
74
|
}
|
|
34
75
|
TaLocation.isHost = isHost;
|
|
35
76
|
/** Options of ssh without a value, which change nothing for Ta. */
|
|
@@ -109,9 +150,12 @@ export var TaLocation;
|
|
|
109
150
|
return isHost(host) ? { host } : { error: 'invalid' };
|
|
110
151
|
}
|
|
111
152
|
TaLocation.readHost = readHost;
|
|
112
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* The location of a path on a host: `ssh://<host><path>`, or `ta://<name><path>` for the host of a cloud
|
|
155
|
+
* workspace; `path` absolute, or empty for the home directory.
|
|
156
|
+
*/
|
|
113
157
|
function ssh(host, path = '') {
|
|
114
|
-
return `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
158
|
+
return isCloud(host) ? `${host}${path ? normalize(path) : ''}` : `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
115
159
|
}
|
|
116
160
|
TaLocation.ssh = ssh;
|
|
117
161
|
/**
|
|
@@ -119,6 +163,9 @@ export var TaLocation;
|
|
|
119
163
|
* (`me@dev.example.com:2222` is `dev`); an address whole.
|
|
120
164
|
*/
|
|
121
165
|
function hostLabel(host) {
|
|
166
|
+
if (isCloud(host)) {
|
|
167
|
+
return host.slice(TaLocation.CLOUD.length);
|
|
168
|
+
}
|
|
122
169
|
const name = host
|
|
123
170
|
.replace(/^[^@]*@/, '')
|
|
124
171
|
.replace(/^\[(.*)\](?::\d+)?$/, '$1')
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export declare const TaRemoteServer: unique symbol;
|
|
2
2
|
export declare const TA_REMOTE_SERVICE = "TaRemoteServer";
|
|
3
|
-
/** A machine ta serve can reach with ssh. */
|
|
3
|
+
/** A machine ta serve can reach with ssh, or a cloud workspace it reaches over a WebSocket. */
|
|
4
4
|
export interface TaRemoteHost {
|
|
5
|
-
/** What follows `ssh://` in a location (TaLocation). */
|
|
5
|
+
/** What follows `ssh://` in a location (TaLocation), or `ta://<name>` for a cloud workspace. */
|
|
6
6
|
host: string;
|
|
7
|
-
/** A Host of ~/.ssh/config,
|
|
8
|
-
source: 'config' | 'recent';
|
|
7
|
+
/** A Host of ~/.ssh/config, one opened before, or a cloud workspace added (TaRemoteServer.addCloudHost). */
|
|
8
|
+
source: 'config' | 'recent' | 'cloud';
|
|
9
|
+
/** Of a cloud workspace: the address of its Ta gateway or Ta service, never its token. */
|
|
10
|
+
url?: string;
|
|
9
11
|
/** ta serve is connected to it now. */
|
|
10
12
|
connected: boolean;
|
|
11
13
|
}
|
|
@@ -67,6 +69,12 @@ export interface TaRemoteServer {
|
|
|
67
69
|
addHost(host: string): Promise<void>;
|
|
68
70
|
/** Disconnects from a host and drops it from the list; one of ~/.ssh/config stays there. */
|
|
69
71
|
removeHost(host: string): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* A cloud workspace, `ta://<name>`: the sandbox of the account of `token` on the Ta gateway at `url` (or the
|
|
74
|
+
* machine of a Ta service, with its token), whose directories conversations work in while the agent stays here.
|
|
75
|
+
* Checked by connecting first; kept with its token, which never comes back.
|
|
76
|
+
*/
|
|
77
|
+
addCloudHost(name: string, url: string, token: string): Promise<TaRemoteHost>;
|
|
70
78
|
/**
|
|
71
79
|
* A location as the user wrote it, whole: `~/src`, `ssh://<host>` (its home), `ssh://<host>/~/src`, or a path
|
|
72
80
|
* relative to the default directory; one already whole as it is. Connects to the host when it needs its home.
|
|
@@ -14,6 +14,11 @@ export type TaGatewayRole = 'owner' | 'admin' | 'member';
|
|
|
14
14
|
export interface TaGatewayLimits {
|
|
15
15
|
/** Minutes a month their sandbox may run, free. */
|
|
16
16
|
freeMinutes?: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Tokens a month their agents may take through the models of the gateway (models.json of the gateway), counted
|
|
19
|
+
* by the gateway as it passes the calls; past them, calls are refused until the next month.
|
|
20
|
+
*/
|
|
21
|
+
monthlyTokens?: number | null;
|
|
17
22
|
/** Messages a minute they may send their agents (prompts, steering, follow-ups). */
|
|
18
23
|
promptsPerMinute?: number | null;
|
|
19
24
|
/** Pages connected at once. */
|
|
@@ -38,12 +43,14 @@ export interface TaQuotaState {
|
|
|
38
43
|
bonus: number;
|
|
39
44
|
};
|
|
40
45
|
/**
|
|
41
|
-
* Tokens this month
|
|
42
|
-
*
|
|
46
|
+
* Tokens this month. `metered`: counted by the gateway, whose models the sandbox calls through it, and held to
|
|
47
|
+
* `limit`; else as the agents' sessions say, shown only (the sandbox is the member's, its files too).
|
|
43
48
|
*/
|
|
44
49
|
tokens: {
|
|
45
50
|
used: number;
|
|
46
51
|
cost: number;
|
|
52
|
+
limit?: number;
|
|
53
|
+
metered: boolean;
|
|
47
54
|
};
|
|
48
55
|
promptsPerMinute?: number;
|
|
49
56
|
connections?: number;
|
|
@@ -269,6 +276,13 @@ export interface TaGatewayConsole {
|
|
|
269
276
|
/** That of the one who looks. */
|
|
270
277
|
role: TaGatewayRole;
|
|
271
278
|
policy: TaGatewayPolicy;
|
|
279
|
+
/** The providers of models the gateway gives its sandboxes (models.json of the gateway), without their keys. */
|
|
280
|
+
models: {
|
|
281
|
+
id: string;
|
|
282
|
+
name?: string;
|
|
283
|
+
api: string;
|
|
284
|
+
models: number;
|
|
285
|
+
}[];
|
|
272
286
|
}
|
|
273
287
|
/**
|
|
274
288
|
* `ta gateway`: each account that signs in is a tenant with a Ta of its own, in a sandbox of its own, which
|
|
@@ -321,5 +335,14 @@ export interface TaGatewayServer {
|
|
|
321
335
|
setRole(account: string, role: 'admin' | 'member'): Promise<TaGatewayPolicy>;
|
|
322
336
|
/** For administrators: what administrators did lately, newest first, `limit` at most (100 by default). */
|
|
323
337
|
getAudit(limit?: number): Promise<TaGatewayAuditEntry[]>;
|
|
338
|
+
/**
|
|
339
|
+
* A token of one's own account for another Ta to use one's sandbox as a cloud workspace (`ta://<name>`, its
|
|
340
|
+
* exec server at `/api/exec` of the gateway) or to open one's Ta: a sign-in, listed with one's browsers in
|
|
341
|
+
* Access, signed out there. `url`: TA_PUBLIC_URL, where the gateway is reached.
|
|
342
|
+
*/
|
|
343
|
+
createAccessToken(label?: string): Promise<{
|
|
344
|
+
token: string;
|
|
345
|
+
url?: string;
|
|
346
|
+
}>;
|
|
324
347
|
}
|
|
325
348
|
//# sourceMappingURL=gateway-protocol.d.ts.map
|
package/lib/common/location.d.ts
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace TaLocation {
|
|
8
8
|
const SSH = "ssh://";
|
|
9
|
+
/**
|
|
10
|
+
* A directory of a cloud workspace: `ta://<name>/<path>`, the sandbox of a Ta gateway (or any Ta service)
|
|
11
|
+
* the user added under that name, reached over its WebSocket (`/api/exec`), not ssh. Its host, as the
|
|
12
|
+
* functions here take it, is `ta://<name>`.
|
|
13
|
+
*/
|
|
14
|
+
const CLOUD = "ta://";
|
|
9
15
|
/** A directory of another machine. */
|
|
10
16
|
interface Remote {
|
|
11
17
|
host: string;
|
|
@@ -13,6 +19,14 @@ export declare namespace TaLocation {
|
|
|
13
19
|
path: string;
|
|
14
20
|
}
|
|
15
21
|
function isRemote(location: string): boolean;
|
|
22
|
+
/** Whether a host is a cloud workspace (`ta://<name>`), not one of ssh. */
|
|
23
|
+
function isCloud(host: string | undefined): boolean;
|
|
24
|
+
/** Whether a name may name a cloud workspace: lower-case letters, digits and -, 40 at most. */
|
|
25
|
+
function isCloudName(name: string): boolean;
|
|
26
|
+
/** `ta://<name><path>`. */
|
|
27
|
+
function cloud(name: string, path?: string): string;
|
|
28
|
+
/** The name of a cloud workspace, of its host or of a location there. */
|
|
29
|
+
function cloudName(hostOrLocation: string): string | undefined;
|
|
16
30
|
/** undefined for a path of the machine of ta serve; throws for an `ssh://` location that is not one. */
|
|
17
31
|
function parse(location: string): Remote | undefined;
|
|
18
32
|
function isHost(host: string): boolean;
|
|
@@ -31,7 +45,10 @@ export declare namespace TaLocation {
|
|
|
31
45
|
* cannot hold (`-i`, `-J`, `-o ProxyCommand=…`) belong in ~/.ssh/config: they come back as `options`.
|
|
32
46
|
*/
|
|
33
47
|
function readHost(input: string): HostInput;
|
|
34
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* The location of a path on a host: `ssh://<host><path>`, or `ta://<name><path>` for the host of a cloud
|
|
50
|
+
* workspace; `path` absolute, or empty for the home directory.
|
|
51
|
+
*/
|
|
35
52
|
function ssh(host: string, path?: string): string;
|
|
36
53
|
/**
|
|
37
54
|
* A host as a list shows it, short: the name of the machine, without the user, the port and the domain
|
package/lib/common/location.js
CHANGED
|
@@ -10,17 +10,58 @@ exports.TaLocation = void 0;
|
|
|
10
10
|
var TaLocation;
|
|
11
11
|
(function (TaLocation) {
|
|
12
12
|
TaLocation.SSH = 'ssh://';
|
|
13
|
+
/**
|
|
14
|
+
* A directory of a cloud workspace: `ta://<name>/<path>`, the sandbox of a Ta gateway (or any Ta service)
|
|
15
|
+
* the user added under that name, reached over its WebSocket (`/api/exec`), not ssh. Its host, as the
|
|
16
|
+
* functions here take it, is `ta://<name>`.
|
|
17
|
+
*/
|
|
18
|
+
TaLocation.CLOUD = 'ta://';
|
|
19
|
+
const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
13
20
|
/** Letters, digits and `_ . @ : % + - [ ]`, not first a `-`: ssh must not read a host as an option. */
|
|
14
21
|
const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
|
|
15
22
|
function isRemote(location) {
|
|
16
|
-
return location.startsWith(TaLocation.SSH);
|
|
23
|
+
return location.startsWith(TaLocation.SSH) || location.startsWith(TaLocation.CLOUD);
|
|
17
24
|
}
|
|
18
25
|
TaLocation.isRemote = isRemote;
|
|
26
|
+
/** Whether a host is a cloud workspace (`ta://<name>`), not one of ssh. */
|
|
27
|
+
function isCloud(host) {
|
|
28
|
+
return !!host && host.startsWith(TaLocation.CLOUD);
|
|
29
|
+
}
|
|
30
|
+
TaLocation.isCloud = isCloud;
|
|
31
|
+
/** Whether a name may name a cloud workspace: lower-case letters, digits and -, 40 at most. */
|
|
32
|
+
function isCloudName(name) {
|
|
33
|
+
return CLOUD_NAME.test(name);
|
|
34
|
+
}
|
|
35
|
+
TaLocation.isCloudName = isCloudName;
|
|
36
|
+
/** `ta://<name><path>`. */
|
|
37
|
+
function cloud(name, path = '') {
|
|
38
|
+
return `${TaLocation.CLOUD}${name}${path ? normalize(path) : ''}`;
|
|
39
|
+
}
|
|
40
|
+
TaLocation.cloud = cloud;
|
|
41
|
+
/** The name of a cloud workspace, of its host or of a location there. */
|
|
42
|
+
function cloudName(hostOrLocation) {
|
|
43
|
+
if (!hostOrLocation.startsWith(TaLocation.CLOUD)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const rest = hostOrLocation.slice(TaLocation.CLOUD.length);
|
|
47
|
+
const slash = rest.indexOf('/');
|
|
48
|
+
return slash < 0 ? rest : rest.slice(0, slash);
|
|
49
|
+
}
|
|
50
|
+
TaLocation.cloudName = cloudName;
|
|
19
51
|
/** undefined for a path of the machine of ta serve; throws for an `ssh://` location that is not one. */
|
|
20
52
|
function parse(location) {
|
|
53
|
+
var _a;
|
|
21
54
|
if (!isRemote(location)) {
|
|
22
55
|
return undefined;
|
|
23
56
|
}
|
|
57
|
+
if (location.startsWith(TaLocation.CLOUD)) {
|
|
58
|
+
const name = (_a = cloudName(location)) !== null && _a !== void 0 ? _a : '';
|
|
59
|
+
if (!isCloudName(name)) {
|
|
60
|
+
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
61
|
+
}
|
|
62
|
+
const path = location.slice(TaLocation.CLOUD.length + name.length);
|
|
63
|
+
return { host: `${TaLocation.CLOUD}${name}`, path: path ? normalize(path) : '' };
|
|
64
|
+
}
|
|
24
65
|
const rest = location.slice(TaLocation.SSH.length);
|
|
25
66
|
const slash = rest.indexOf('/');
|
|
26
67
|
const host = slash < 0 ? rest : rest.slice(0, slash);
|
|
@@ -32,7 +73,7 @@ var TaLocation;
|
|
|
32
73
|
}
|
|
33
74
|
TaLocation.parse = parse;
|
|
34
75
|
function isHost(host) {
|
|
35
|
-
return HOST.test(host);
|
|
76
|
+
return isCloud(host) ? isCloudName(host.slice(TaLocation.CLOUD.length)) : HOST.test(host);
|
|
36
77
|
}
|
|
37
78
|
TaLocation.isHost = isHost;
|
|
38
79
|
/** Options of ssh without a value, which change nothing for Ta. */
|
|
@@ -112,9 +153,12 @@ var TaLocation;
|
|
|
112
153
|
return isHost(host) ? { host } : { error: 'invalid' };
|
|
113
154
|
}
|
|
114
155
|
TaLocation.readHost = readHost;
|
|
115
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* The location of a path on a host: `ssh://<host><path>`, or `ta://<name><path>` for the host of a cloud
|
|
158
|
+
* workspace; `path` absolute, or empty for the home directory.
|
|
159
|
+
*/
|
|
116
160
|
function ssh(host, path = '') {
|
|
117
|
-
return `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
161
|
+
return isCloud(host) ? `${host}${path ? normalize(path) : ''}` : `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
118
162
|
}
|
|
119
163
|
TaLocation.ssh = ssh;
|
|
120
164
|
/**
|
|
@@ -122,6 +166,9 @@ var TaLocation;
|
|
|
122
166
|
* (`me@dev.example.com:2222` is `dev`); an address whole.
|
|
123
167
|
*/
|
|
124
168
|
function hostLabel(host) {
|
|
169
|
+
if (isCloud(host)) {
|
|
170
|
+
return host.slice(TaLocation.CLOUD.length);
|
|
171
|
+
}
|
|
125
172
|
const name = host
|
|
126
173
|
.replace(/^[^@]*@/, '')
|
|
127
174
|
.replace(/^\[(.*)\](?::\d+)?$/, '$1')
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export declare const TaRemoteServer: unique symbol;
|
|
2
2
|
export declare const TA_REMOTE_SERVICE = "TaRemoteServer";
|
|
3
|
-
/** A machine ta serve can reach with ssh. */
|
|
3
|
+
/** A machine ta serve can reach with ssh, or a cloud workspace it reaches over a WebSocket. */
|
|
4
4
|
export interface TaRemoteHost {
|
|
5
|
-
/** What follows `ssh://` in a location (TaLocation). */
|
|
5
|
+
/** What follows `ssh://` in a location (TaLocation), or `ta://<name>` for a cloud workspace. */
|
|
6
6
|
host: string;
|
|
7
|
-
/** A Host of ~/.ssh/config,
|
|
8
|
-
source: 'config' | 'recent';
|
|
7
|
+
/** A Host of ~/.ssh/config, one opened before, or a cloud workspace added (TaRemoteServer.addCloudHost). */
|
|
8
|
+
source: 'config' | 'recent' | 'cloud';
|
|
9
|
+
/** Of a cloud workspace: the address of its Ta gateway or Ta service, never its token. */
|
|
10
|
+
url?: string;
|
|
9
11
|
/** ta serve is connected to it now. */
|
|
10
12
|
connected: boolean;
|
|
11
13
|
}
|
|
@@ -67,6 +69,12 @@ export interface TaRemoteServer {
|
|
|
67
69
|
addHost(host: string): Promise<void>;
|
|
68
70
|
/** Disconnects from a host and drops it from the list; one of ~/.ssh/config stays there. */
|
|
69
71
|
removeHost(host: string): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* A cloud workspace, `ta://<name>`: the sandbox of the account of `token` on the Ta gateway at `url` (or the
|
|
74
|
+
* machine of a Ta service, with its token), whose directories conversations work in while the agent stays here.
|
|
75
|
+
* Checked by connecting first; kept with its token, which never comes back.
|
|
76
|
+
*/
|
|
77
|
+
addCloudHost(name: string, url: string, token: string): Promise<TaRemoteHost>;
|
|
70
78
|
/**
|
|
71
79
|
* A location as the user wrote it, whole: `~/src`, `ssh://<host>` (its home), `ssh://<host>/~/src`, or a path
|
|
72
80
|
* relative to the default directory; one already whole as it is. Connects to the host when it needs its home.
|