@celljs/ta-host 4.6.1 → 4.8.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/README.en.md +70 -0
- package/README.md +16 -3
- package/cell.schema.json +21 -0
- package/cell.yml +7 -0
- package/esm/node/auth-server-impl.d.ts +2 -0
- package/esm/node/auth-server-impl.js +7 -0
- package/esm/node/auth-server-impl.js.map +1 -1
- package/esm/node/exec-environment-factory.d.ts +8 -4
- package/esm/node/exec-environment-factory.js +28 -6
- package/esm/node/exec-environment-factory.js.map +1 -1
- package/esm/node/extension-providers.d.ts +22 -0
- package/esm/node/extension-providers.js +52 -0
- package/esm/node/extension-providers.js.map +1 -0
- package/esm/node/index.d.ts +3 -0
- package/esm/node/index.js +3 -0
- package/esm/node/index.js.map +1 -1
- package/esm/node/package-host-extension.d.ts +4 -2
- package/esm/node/package-host-extension.js +4 -3
- package/esm/node/package-host-extension.js.map +1 -1
- package/esm/node/package-hosts.d.ts +6 -2
- package/esm/node/package-hosts.js +32 -0
- package/esm/node/package-hosts.js.map +1 -1
- package/esm/node/remote/index.d.ts +5 -0
- package/esm/node/remote/index.js +6 -0
- package/esm/node/remote/index.js.map +1 -0
- package/esm/node/remote/pi-directories.d.ts +14 -0
- package/esm/node/remote/pi-directories.js +64 -0
- package/esm/node/remote/pi-directories.js.map +1 -0
- package/esm/node/remote/port-forwards.d.ts +35 -0
- package/esm/node/remote/port-forwards.js +150 -0
- package/esm/node/remote/port-forwards.js.map +1 -0
- package/esm/node/remote/remote-hosts.d.ts +40 -0
- package/esm/node/remote/remote-hosts.js +170 -0
- package/esm/node/remote/remote-hosts.js.map +1 -0
- package/esm/node/remote/remote-protocol.d.ts +51 -0
- package/esm/node/remote/remote-protocol.js +5 -0
- package/esm/node/remote/remote-protocol.js.map +1 -0
- package/esm/node/remote/remote-server-impl.d.ts +19 -0
- package/esm/node/remote/remote-server-impl.js +66 -0
- package/esm/node/remote/remote-server-impl.js.map +1 -0
- package/esm/node/remote-ui-context.d.ts +6 -1
- package/esm/node/remote-ui-context.js +31 -3
- package/esm/node/remote-ui-context.js.map +1 -1
- package/esm/node/session-files.d.ts +18 -0
- package/esm/node/session-files.js +32 -0
- package/esm/node/session-files.js.map +1 -0
- package/esm/node/settings-server-impl.d.ts +1 -0
- package/esm/node/settings-server-impl.js +8 -0
- package/esm/node/settings-server-impl.js.map +1 -1
- package/esm/node/settings-store.d.ts +9 -2
- package/esm/node/settings-store.js +26 -5
- package/esm/node/settings-store.js.map +1 -1
- package/esm/node/ta-server-impl.d.ts +2 -0
- package/esm/node/ta-server-impl.js +16 -4
- package/esm/node/ta-server-impl.js.map +1 -1
- package/esm/node/ta-session-factory.d.ts +19 -2
- package/esm/node/ta-session-factory.js +54 -11
- package/esm/node/ta-session-factory.js.map +1 -1
- package/esm/node/ta-session.d.ts +4 -0
- package/esm/node/ta-session.js +6 -1
- package/esm/node/ta-session.js.map +1 -1
- package/esm/node/terminal-service.d.ts +18 -2
- package/esm/node/terminal-service.js +46 -10
- package/esm/node/terminal-service.js.map +1 -1
- package/esm/node/terminal-util.d.ts +14 -0
- package/esm/node/terminal-util.js +30 -1
- package/esm/node/terminal-util.js.map +1 -1
- package/esm/node/web-extension-catalog.d.ts +3 -1
- package/esm/node/web-extension-catalog.js +8 -2
- package/esm/node/web-extension-catalog.js.map +1 -1
- package/esm/node/working-directory.d.ts +12 -1
- package/esm/node/working-directory.js +22 -1
- package/esm/node/working-directory.js.map +1 -1
- package/esm/node/workspace-files.d.ts +1 -1
- package/esm/node/workspace-files.js +3 -3
- package/esm/node/workspace-files.js.map +1 -1
- package/esm/node/workspace-protocol.d.ts +2 -0
- package/esm/node/workspace-server-impl.d.ts +2 -1
- package/esm/node/workspace-server-impl.js +13 -1
- package/esm/node/workspace-server-impl.js.map +1 -1
- package/esm/node/workspace-service.d.ts +1 -0
- package/esm/node/workspace-service.js +15 -3
- package/esm/node/workspace-service.js.map +1 -1
- package/lib/node/auth-server-impl.d.ts +2 -0
- package/lib/node/auth-server-impl.d.ts.map +1 -1
- package/lib/node/auth-server-impl.js +7 -0
- package/lib/node/auth-server-impl.js.map +1 -1
- package/lib/node/exec-environment-factory.d.ts +8 -4
- package/lib/node/exec-environment-factory.d.ts.map +1 -1
- package/lib/node/exec-environment-factory.js +28 -6
- package/lib/node/exec-environment-factory.js.map +1 -1
- package/lib/node/extension-providers.d.ts +23 -0
- package/lib/node/extension-providers.d.ts.map +1 -0
- package/lib/node/extension-providers.js +55 -0
- package/lib/node/extension-providers.js.map +1 -0
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +3 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/package-host-extension.d.ts +4 -2
- package/lib/node/package-host-extension.d.ts.map +1 -1
- package/lib/node/package-host-extension.js +4 -3
- package/lib/node/package-host-extension.js.map +1 -1
- package/lib/node/package-hosts.d.ts +6 -2
- package/lib/node/package-hosts.d.ts.map +1 -1
- package/lib/node/package-hosts.js +32 -0
- package/lib/node/package-hosts.js.map +1 -1
- package/lib/node/remote/index.d.ts +6 -0
- package/lib/node/remote/index.d.ts.map +1 -0
- package/lib/node/remote/index.js +22 -0
- package/lib/node/remote/index.js.map +1 -0
- package/lib/node/remote/pi-directories.d.ts +15 -0
- package/lib/node/remote/pi-directories.d.ts.map +1 -0
- package/lib/node/remote/pi-directories.js +67 -0
- package/lib/node/remote/pi-directories.js.map +1 -0
- package/lib/node/remote/port-forwards.d.ts +36 -0
- package/lib/node/remote/port-forwards.d.ts.map +1 -0
- package/lib/node/remote/port-forwards.js +153 -0
- package/lib/node/remote/port-forwards.js.map +1 -0
- package/lib/node/remote/remote-hosts.d.ts +41 -0
- package/lib/node/remote/remote-hosts.d.ts.map +1 -0
- package/lib/node/remote/remote-hosts.js +173 -0
- package/lib/node/remote/remote-hosts.js.map +1 -0
- package/lib/node/remote/remote-protocol.d.ts +52 -0
- package/lib/node/remote/remote-protocol.d.ts.map +1 -0
- package/lib/node/remote/remote-protocol.js +8 -0
- package/lib/node/remote/remote-protocol.js.map +1 -0
- package/lib/node/remote/remote-server-impl.d.ts +20 -0
- package/lib/node/remote/remote-server-impl.d.ts.map +1 -0
- package/lib/node/remote/remote-server-impl.js +69 -0
- package/lib/node/remote/remote-server-impl.js.map +1 -0
- package/lib/node/remote/remote.spec.d.ts +2 -0
- package/lib/node/remote/remote.spec.d.ts.map +1 -0
- package/lib/node/remote/remote.spec.js +130 -0
- package/lib/node/remote/remote.spec.js.map +1 -0
- package/lib/node/remote-ui-context.d.ts +6 -1
- package/lib/node/remote-ui-context.d.ts.map +1 -1
- package/lib/node/remote-ui-context.js +31 -3
- package/lib/node/remote-ui-context.js.map +1 -1
- package/lib/node/remote-ui-context.spec.js +23 -0
- package/lib/node/remote-ui-context.spec.js.map +1 -1
- package/lib/node/session-files.d.ts +19 -0
- package/lib/node/session-files.d.ts.map +1 -0
- package/lib/node/session-files.js +36 -0
- package/lib/node/session-files.js.map +1 -0
- package/lib/node/session-files.spec.d.ts +2 -0
- package/lib/node/session-files.spec.d.ts.map +1 -0
- package/lib/node/session-files.spec.js +51 -0
- package/lib/node/session-files.spec.js.map +1 -0
- package/lib/node/settings-server-impl.d.ts +1 -0
- package/lib/node/settings-server-impl.d.ts.map +1 -1
- package/lib/node/settings-server-impl.js +8 -0
- package/lib/node/settings-server-impl.js.map +1 -1
- package/lib/node/settings-store.d.ts +9 -2
- package/lib/node/settings-store.d.ts.map +1 -1
- package/lib/node/settings-store.js +26 -5
- package/lib/node/settings-store.js.map +1 -1
- package/lib/node/settings-store.spec.js +5 -2
- package/lib/node/settings-store.spec.js.map +1 -1
- package/lib/node/ta-server-impl.d.ts +2 -0
- package/lib/node/ta-server-impl.d.ts.map +1 -1
- package/lib/node/ta-server-impl.js +16 -4
- package/lib/node/ta-server-impl.js.map +1 -1
- package/lib/node/ta-session-factory.d.ts +19 -2
- package/lib/node/ta-session-factory.d.ts.map +1 -1
- package/lib/node/ta-session-factory.js +53 -10
- package/lib/node/ta-session-factory.js.map +1 -1
- package/lib/node/ta-session.d.ts +4 -0
- package/lib/node/ta-session.d.ts.map +1 -1
- package/lib/node/ta-session.js +6 -1
- package/lib/node/ta-session.js.map +1 -1
- package/lib/node/terminal-service.d.ts +18 -2
- package/lib/node/terminal-service.d.ts.map +1 -1
- package/lib/node/terminal-service.js +45 -9
- package/lib/node/terminal-service.js.map +1 -1
- package/lib/node/terminal-service.spec.js +31 -0
- package/lib/node/terminal-service.spec.js.map +1 -1
- package/lib/node/terminal-util.d.ts +14 -0
- package/lib/node/terminal-util.d.ts.map +1 -1
- package/lib/node/terminal-util.js +30 -1
- package/lib/node/terminal-util.js.map +1 -1
- package/lib/node/terminal-util.spec.js +24 -0
- package/lib/node/terminal-util.spec.js.map +1 -1
- package/lib/node/web-extension-catalog.d.ts +3 -1
- package/lib/node/web-extension-catalog.d.ts.map +1 -1
- package/lib/node/web-extension-catalog.js +7 -1
- package/lib/node/web-extension-catalog.js.map +1 -1
- package/lib/node/web-extension-catalog.spec.js +1 -1
- package/lib/node/web-extension-catalog.spec.js.map +1 -1
- package/lib/node/working-directory.d.ts +12 -1
- package/lib/node/working-directory.d.ts.map +1 -1
- package/lib/node/working-directory.js +22 -1
- package/lib/node/working-directory.js.map +1 -1
- package/lib/node/workspace-files.d.ts +1 -1
- package/lib/node/workspace-files.d.ts.map +1 -1
- package/lib/node/workspace-files.js +3 -3
- package/lib/node/workspace-files.js.map +1 -1
- package/lib/node/workspace-protocol.d.ts +2 -0
- package/lib/node/workspace-protocol.d.ts.map +1 -1
- package/lib/node/workspace-server-impl.d.ts +2 -1
- package/lib/node/workspace-server-impl.d.ts.map +1 -1
- package/lib/node/workspace-server-impl.js +12 -0
- package/lib/node/workspace-server-impl.js.map +1 -1
- package/lib/node/workspace-service.d.ts +1 -0
- package/lib/node/workspace-service.d.ts.map +1 -1
- package/lib/node/workspace-service.js +15 -3
- package/lib/node/workspace-service.js.map +1 -1
- package/lib/node/workspace-service.spec.js +9 -0
- package/lib/node/workspace-service.spec.js.map +1 -1
- package/package.json +14 -10
- package/src/node/auth-server-impl.ts +6 -0
- package/src/node/exec-environment-factory.ts +26 -6
- package/src/node/extension-providers.ts +49 -0
- package/src/node/index.ts +3 -0
- package/src/node/package-host-extension.ts +7 -4
- package/src/node/package-hosts.ts +32 -2
- package/src/node/remote/index.ts +5 -0
- package/src/node/remote/pi-directories.ts +49 -0
- package/src/node/remote/port-forwards.ts +148 -0
- package/src/node/remote/remote-hosts.ts +170 -0
- package/src/node/remote/remote-protocol.ts +57 -0
- package/src/node/remote/remote-server-impl.ts +60 -0
- package/src/node/remote/remote.spec.ts +142 -0
- package/src/node/remote-ui-context.spec.ts +25 -0
- package/src/node/remote-ui-context.ts +34 -5
- package/src/node/session-files.spec.ts +52 -0
- package/src/node/session-files.ts +41 -0
- package/src/node/settings-server-impl.ts +9 -0
- package/src/node/settings-store.spec.ts +5 -2
- package/src/node/settings-store.ts +25 -6
- package/src/node/ta-server-impl.ts +18 -4
- package/src/node/ta-session-factory.ts +56 -10
- package/src/node/ta-session.ts +9 -1
- package/src/node/terminal-service.spec.ts +35 -0
- package/src/node/terminal-service.ts +47 -15
- package/src/node/terminal-util.spec.ts +31 -0
- package/src/node/terminal-util.ts +32 -1
- package/src/node/web-extension-catalog.spec.ts +1 -1
- package/src/node/web-extension-catalog.ts +7 -2
- package/src/node/working-directory.ts +35 -2
- package/src/node/workspace-files.ts +3 -3
- package/src/node/workspace-protocol.ts +2 -0
- package/src/node/workspace-server-impl.ts +18 -0
- package/src/node/workspace-service.spec.ts +11 -1
- package/src/node/workspace-service.ts +15 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DefaultPiDirectories = void 0;
|
|
13
|
+
const node_fs_1 = require("node:fs");
|
|
14
|
+
const node_path_1 = require("node:path");
|
|
15
|
+
const ai_coding_agent_1 = require("@celljs/ai-coding-agent");
|
|
16
|
+
const core_1 = require("@celljs/core");
|
|
17
|
+
const ta_brand_1 = require("@celljs/ta-harness/lib/node/ta-brand");
|
|
18
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
19
|
+
const host_protocol_1 = require("../host-protocol");
|
|
20
|
+
const remote_protocol_1 = require("./remote-protocol");
|
|
21
|
+
/**
|
|
22
|
+
* `<agent directory>/remote/ssh/<host>/<path>` for `ssh://<host>/<path>`. With `ta.exec.url` every
|
|
23
|
+
* directory is one of the machine of the exec server: `<agent directory>/remote/exec/<path>`.
|
|
24
|
+
*/
|
|
25
|
+
let DefaultPiDirectories = class DefaultPiDirectories {
|
|
26
|
+
toPi(location) {
|
|
27
|
+
var _a;
|
|
28
|
+
const remote = ta_protocol_1.TaLocation.parse(location);
|
|
29
|
+
const prefix = remote ? (0, node_path_1.join)('ssh', remote.host) : ((_a = this.execOptions) === null || _a === void 0 ? void 0 : _a.url) ? 'exec' : undefined;
|
|
30
|
+
if (!prefix) {
|
|
31
|
+
return location;
|
|
32
|
+
}
|
|
33
|
+
const path = remote ? remote.path : location;
|
|
34
|
+
const cwd = (0, node_path_1.join)(this.root(), prefix, ...path.split('/').filter(Boolean));
|
|
35
|
+
(0, node_fs_1.mkdirSync)(cwd, { recursive: true });
|
|
36
|
+
return cwd;
|
|
37
|
+
}
|
|
38
|
+
fromPi(cwd) {
|
|
39
|
+
const root = this.root() + node_path_1.sep;
|
|
40
|
+
if (!cwd.startsWith(root)) {
|
|
41
|
+
return cwd;
|
|
42
|
+
}
|
|
43
|
+
const [kind, ...rest] = cwd.slice(root.length).split(node_path_1.sep);
|
|
44
|
+
if (kind === 'ssh' && rest.length > 0 && ta_protocol_1.TaLocation.isHost(rest[0])) {
|
|
45
|
+
return ta_protocol_1.TaLocation.ssh(rest[0], `/${rest.slice(1).join('/')}`);
|
|
46
|
+
}
|
|
47
|
+
return kind === 'exec' ? `/${rest.join('/')}` : cwd;
|
|
48
|
+
}
|
|
49
|
+
root() {
|
|
50
|
+
var _a;
|
|
51
|
+
var _b;
|
|
52
|
+
return (0, node_path_1.join)((_b = (_a = this.codingAgentOptions) === null || _a === void 0 ? void 0 : _a.agentDir) !== null && _b !== void 0 ? _b : ta_brand_1.TaBrand.agentDir(), 'remote');
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.DefaultPiDirectories = DefaultPiDirectories;
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, core_1.Value)(ai_coding_agent_1.CODING_AGENT_OPTIONS),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], DefaultPiDirectories.prototype, "codingAgentOptions", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, core_1.Value)(host_protocol_1.TA_EXEC_OPTIONS),
|
|
62
|
+
__metadata("design:type", Object)
|
|
63
|
+
], DefaultPiDirectories.prototype, "execOptions", void 0);
|
|
64
|
+
exports.DefaultPiDirectories = DefaultPiDirectories = __decorate([
|
|
65
|
+
(0, core_1.Component)(remote_protocol_1.PiDirectories)
|
|
66
|
+
], DefaultPiDirectories);
|
|
67
|
+
//# sourceMappingURL=pi-directories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,eAAG,CAAC,CAAC;QAC1D,IAAI,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,wBAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAClE,OAAO,wBAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IACxD,CAAC;IAES,IAAI;;;QACV,OAAO,IAAA,gBAAI,QAAC,MAAA,IAAI,CAAC,kBAAkB,0CAAE,QAAQ,mCAAI,kBAAO,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;IACnF,CAAC;CACJ,CAAA;;AAhCsB;IADlB,IAAA,YAAK,EAAC,sCAAoB,CAAC;;gEAC+B;AAGxC;IADlB,IAAA,YAAK,EAAC,+BAAe,CAAC;;yDACwB;+BALtC,oBAAoB;IADhC,IAAA,gBAAS,EAAC,+BAAa,CAAC;GACZ,oBAAoB,CAkChC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Server, type Socket } from 'node:net';
|
|
2
|
+
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
|
+
import { type ExecEnvironment, ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
4
|
+
import { type TaForwardedPort } from '@celljs/ta-protocol';
|
|
5
|
+
import { PortForwards, RemoteHosts } from './remote-protocol';
|
|
6
|
+
interface Forward {
|
|
7
|
+
info: TaForwardedPort;
|
|
8
|
+
server: Server;
|
|
9
|
+
sockets: Set<Socket>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A port of another machine as a port of 127.0.0.1 here: each connection to it is one from the server
|
|
13
|
+
* of Ta there (ExecEnvironment.connect). The same number when it is free here, as VS Code does, so that
|
|
14
|
+
* the pages of a dev server keep their links.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DefaultPortForwards implements PortForwards, ApplicationLifecycle<Application> {
|
|
17
|
+
protected readonly environments: ExecEnvironmentFactory;
|
|
18
|
+
protected readonly hosts: RemoteHosts;
|
|
19
|
+
protected readonly forwards: Map<string, Promise<Forward>>;
|
|
20
|
+
/** Those open. */
|
|
21
|
+
protected readonly open: Map<string, TaForwardedPort>;
|
|
22
|
+
protected watching: boolean;
|
|
23
|
+
forward(cwd: string, port: number): Promise<TaForwardedPort>;
|
|
24
|
+
list(): TaForwardedPort[];
|
|
25
|
+
close(host: string, remotePort: number): Promise<void>;
|
|
26
|
+
onStop(): Promise<void>;
|
|
27
|
+
protected listenFor(env: ExecEnvironment, host: string, port: number): Promise<Forward>;
|
|
28
|
+
protected listen(server: Server, port: number): Promise<number>;
|
|
29
|
+
/** One connection: data both ways until either side ends it. */
|
|
30
|
+
protected pipe(env: ExecEnvironment, port: number, socket: Socket): Promise<void>;
|
|
31
|
+
/** A host disconnected on purpose takes its ports with it. */
|
|
32
|
+
protected watch(): void;
|
|
33
|
+
protected split(key: string): [string, number];
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=port-forwards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port-forwards.d.ts","sourceRoot":"","sources":["../../../src/node/remote/port-forwards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,KAAK,WAAW,EAAE,oBAAoB,EAAwB,MAAM,cAAc,CAAC;A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AAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BtF;IAED,8DAA8D;IAC9D,SAAS,CAAC,KAAK,IAAI,IAAI,CAWtB;IAED,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAG7C;CACJ"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DefaultPortForwards = void 0;
|
|
13
|
+
const node_net_1 = require("node:net");
|
|
14
|
+
const core_1 = require("@celljs/core");
|
|
15
|
+
const ta_exec_1 = require("@celljs/ta-exec");
|
|
16
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
17
|
+
const ta_errors_1 = require("../ta-errors");
|
|
18
|
+
const remote_protocol_1 = require("./remote-protocol");
|
|
19
|
+
/**
|
|
20
|
+
* A port of another machine as a port of 127.0.0.1 here: each connection to it is one from the server
|
|
21
|
+
* of Ta there (ExecEnvironment.connect). The same number when it is free here, as VS Code does, so that
|
|
22
|
+
* the pages of a dev server keep their links.
|
|
23
|
+
*/
|
|
24
|
+
let DefaultPortForwards = class DefaultPortForwards {
|
|
25
|
+
constructor() {
|
|
26
|
+
this.forwards = new Map();
|
|
27
|
+
/** Those open. */
|
|
28
|
+
this.open = new Map();
|
|
29
|
+
this.watching = false;
|
|
30
|
+
}
|
|
31
|
+
async forward(cwd, port) {
|
|
32
|
+
var _a;
|
|
33
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) {
|
|
34
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${port} is not a port.`, 'Pass a port from 1 to 65535.');
|
|
35
|
+
}
|
|
36
|
+
const env = this.environments.create(cwd);
|
|
37
|
+
const host = (_a = ta_protocol_1.TaLocation.host(cwd)) !== null && _a !== void 0 ? _a : '';
|
|
38
|
+
if (!env.connect) {
|
|
39
|
+
return { host, remotePort: port, localPort: port };
|
|
40
|
+
}
|
|
41
|
+
this.watch();
|
|
42
|
+
const key = `${host}:${port}`;
|
|
43
|
+
let forward = this.forwards.get(key);
|
|
44
|
+
if (!forward) {
|
|
45
|
+
forward = this.listenFor(env, host, port);
|
|
46
|
+
this.forwards.set(key, forward);
|
|
47
|
+
forward.then(({ info }) => this.forwards.has(key) && this.open.set(key, info), () => this.forwards.delete(key));
|
|
48
|
+
}
|
|
49
|
+
return (await forward).info;
|
|
50
|
+
}
|
|
51
|
+
list() {
|
|
52
|
+
return [...this.open.values()];
|
|
53
|
+
}
|
|
54
|
+
async close(host, remotePort) {
|
|
55
|
+
var _a;
|
|
56
|
+
const key = `${host}:${remotePort}`;
|
|
57
|
+
const forward = await ((_a = this.forwards.get(key)) === null || _a === void 0 ? void 0 : _a.catch(() => undefined));
|
|
58
|
+
this.forwards.delete(key);
|
|
59
|
+
this.open.delete(key);
|
|
60
|
+
if (forward) {
|
|
61
|
+
for (const socket of forward.sockets) {
|
|
62
|
+
socket.destroy();
|
|
63
|
+
}
|
|
64
|
+
await new Promise(resolve => forward.server.close(() => resolve()));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
async onStop() {
|
|
68
|
+
await Promise.all([...this.forwards.keys()].map(key => this.close(...this.split(key))));
|
|
69
|
+
}
|
|
70
|
+
async listenFor(env, host, port) {
|
|
71
|
+
const sockets = new Set();
|
|
72
|
+
const server = (0, node_net_1.createServer)(socket => {
|
|
73
|
+
sockets.add(socket);
|
|
74
|
+
socket.once('close', () => sockets.delete(socket));
|
|
75
|
+
void this.pipe(env, port, socket);
|
|
76
|
+
});
|
|
77
|
+
const localPort = await this.listen(server, port).catch(() => this.listen(server, 0));
|
|
78
|
+
return { info: { host, remotePort: port, localPort }, server, sockets };
|
|
79
|
+
}
|
|
80
|
+
listen(server, port) {
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
const failed = (error) => reject(error);
|
|
83
|
+
server.once('error', failed);
|
|
84
|
+
server.listen(port, '127.0.0.1', () => {
|
|
85
|
+
server.removeListener('error', failed);
|
|
86
|
+
resolve(server.address().port);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/** One connection: data both ways until either side ends it. */
|
|
91
|
+
async pipe(env, port, socket) {
|
|
92
|
+
// What comes before the other end is there waits for it.
|
|
93
|
+
const early = [];
|
|
94
|
+
let ended = false;
|
|
95
|
+
let remote;
|
|
96
|
+
const end = () => {
|
|
97
|
+
if (remote) {
|
|
98
|
+
remote.end();
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
ended = true;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
socket.on('data', data => (remote ? remote.write(data) : early.push(data)));
|
|
105
|
+
socket.once('end', end);
|
|
106
|
+
socket.once('error', end);
|
|
107
|
+
try {
|
|
108
|
+
remote = await env.connect(port);
|
|
109
|
+
}
|
|
110
|
+
catch (_a) {
|
|
111
|
+
socket.destroy();
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
remote.onData(data => socket.write(data));
|
|
115
|
+
remote.onClose(() => socket.end());
|
|
116
|
+
for (const data of early) {
|
|
117
|
+
remote.write(data);
|
|
118
|
+
}
|
|
119
|
+
if (ended) {
|
|
120
|
+
remote.end();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** A host disconnected on purpose takes its ports with it. */
|
|
124
|
+
watch() {
|
|
125
|
+
if (!this.watching) {
|
|
126
|
+
this.watching = true;
|
|
127
|
+
this.hosts.onDisconnect(host => {
|
|
128
|
+
for (const key of [...this.forwards.keys()]) {
|
|
129
|
+
if (key.startsWith(`${host}:`)) {
|
|
130
|
+
void this.close(...this.split(key));
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
split(key) {
|
|
137
|
+
const at = key.lastIndexOf(':');
|
|
138
|
+
return [key.slice(0, at), Number(key.slice(at + 1))];
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
exports.DefaultPortForwards = DefaultPortForwards;
|
|
142
|
+
__decorate([
|
|
143
|
+
(0, core_1.Autowired)(ta_exec_1.ExecEnvironmentFactory),
|
|
144
|
+
__metadata("design:type", Object)
|
|
145
|
+
], DefaultPortForwards.prototype, "environments", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, core_1.Autowired)(remote_protocol_1.RemoteHosts),
|
|
148
|
+
__metadata("design:type", Object)
|
|
149
|
+
], DefaultPortForwards.prototype, "hosts", void 0);
|
|
150
|
+
exports.DefaultPortForwards = DefaultPortForwards = __decorate([
|
|
151
|
+
(0, core_1.Component)([remote_protocol_1.PortForwards, core_1.ApplicationLifecycle])
|
|
152
|
+
], DefaultPortForwards);
|
|
153
|
+
//# sourceMappingURL=port-forwards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"port-forwards.js","sourceRoot":"","sources":["../../../src/node/remote/port-forwards.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAkE;AAClE,uCAA4F;AAC5F,6CAAgG;AAChG,qDAAuE;AACvE,4CAAwC;AACxC,uDAA8D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ACD,IAAI,KAAK,EAAE,CAAC;YACR,MAAM,CAAC,GAAG,EAAE,CAAC;QACjB,CAAC;IACL,CAAC;IAED,8DAA8D;IACpD,KAAK;QACX,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;YACrB,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;gBAC3B,KAAK,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;oBAC1C,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;wBAC7B,KAAK,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;oBACxC,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IAES,KAAK,CAAC,GAAW;QACvB,MAAM,EAAE,GAAG,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;;AA9HsB;IADlB,IAAA,gBAAS,EAAC,gCAAsB,CAAC;;yDACsB;AAGrC;IADlB,IAAA,gBAAS,EAAC,6BAAW,CAAC;;kDACe;8BAL7B,mBAAmB;IAD/B,IAAA,gBAAS,EAAC,CAAC,8BAAY,EAAE,2BAAoB,CAAC,CAAC;GACnC,mBAAmB,CAgI/B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type CodingAgentOptions } from '@celljs/ai-coding-agent';
|
|
2
|
+
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
|
+
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
4
|
+
import { type ExecClient, SshHost, type SshQuestion } from '@celljs/ta-exec';
|
|
5
|
+
import { TaLocation, type TaRemoteEvent, type TaRemoteHost, type TaRemotePrompt } from '@celljs/ta-protocol';
|
|
6
|
+
import { TaWorkingDirectory } from '../working-directory';
|
|
7
|
+
import { RemoteHosts, type TaRemoteOptions } from './remote-protocol';
|
|
8
|
+
interface Waiting {
|
|
9
|
+
prompt: TaRemotePrompt;
|
|
10
|
+
settle(value: string | undefined): void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* One SshHost per host, which connects on the first call there and again after a loss. What ssh asks
|
|
14
|
+
* goes to every client that watches, and the first answer counts, as with the dialogs of sessions.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DefaultRemoteHosts implements RemoteHosts, ApplicationLifecycle<Application> {
|
|
17
|
+
protected readonly options?: TaRemoteOptions;
|
|
18
|
+
protected readonly codingAgentOptions?: CodingAgentOptions;
|
|
19
|
+
protected readonly workingDirectory: TaWorkingDirectory;
|
|
20
|
+
protected readonly hosts: Map<string, SshHost>;
|
|
21
|
+
protected readonly waiting: Map<string, Waiting>;
|
|
22
|
+
protected readonly watchers: Set<RpcConnection>;
|
|
23
|
+
protected readonly disconnectListeners: Set<(host: string) => void>;
|
|
24
|
+
client(host: string): ExecClient;
|
|
25
|
+
list(): TaRemoteHost[];
|
|
26
|
+
add(host: string): void;
|
|
27
|
+
remove(host: string): Promise<void>;
|
|
28
|
+
resolve(location: string): Promise<string>;
|
|
29
|
+
disconnect(host: string): Promise<void>;
|
|
30
|
+
onDisconnect(listener: (host: string) => void): () => void;
|
|
31
|
+
watch(connection: RpcConnection): TaRemotePrompt[];
|
|
32
|
+
answer(promptId: string, value: string | null): boolean;
|
|
33
|
+
onStop(): Promise<void>;
|
|
34
|
+
protected ask(host: string, question: SshQuestion): Promise<string | undefined>;
|
|
35
|
+
protected broadcast(event: TaRemoteEvent): void;
|
|
36
|
+
protected check(host: string): string;
|
|
37
|
+
protected connected(host: string): boolean;
|
|
38
|
+
protected parse(location: string): TaLocation.Remote | undefined;
|
|
39
|
+
}
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=remote-hosts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-hosts.d.ts","sourceRoot":"","sources":["../../../src/node/remote/remote-hosts.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EAAE,KAAK,WAAW,EAAE,oBAAoB,EAA+B,MAAM,cAAc,CAAC;AACnG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,KAAK,UAAU,EAAa,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EAAY,UAAU,EAAE,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEvH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAqB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAKzF,UAAU,OAAO;IACb,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC3C;AAED;;;GAGG;AACH,qBACa,kBAAmB,YAAW,WAAW,EAAE,oBAAoB,CAAC,WAAW,CAAC;IAErF,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC;IAG7C,SAAS,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAG3D,SAAS,CAAC,QAAQ,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;IAExD,SAAS,CAAC,QAAQ,CAAC,KAAK,uBAA8B;IACtD,SAAS,CAAC,QAAQ,CAAC,OAAO,uBA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|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DefaultRemoteHosts = void 0;
|
|
13
|
+
const node_crypto_1 = require("node:crypto");
|
|
14
|
+
const ai_coding_agent_1 = require("@celljs/ai-coding-agent");
|
|
15
|
+
const core_1 = require("@celljs/core");
|
|
16
|
+
const ta_exec_1 = require("@celljs/ta-exec");
|
|
17
|
+
const ta_brand_1 = require("@celljs/ta-harness/lib/node/ta-brand");
|
|
18
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
19
|
+
const ta_errors_1 = require("../ta-errors");
|
|
20
|
+
const working_directory_1 = require("../working-directory");
|
|
21
|
+
const remote_protocol_1 = require("./remote-protocol");
|
|
22
|
+
/** A prompt nobody answers is cancelled after this: ssh gives up. */
|
|
23
|
+
const PROMPT_TIMEOUT_MS = 5 * 60 * 1000;
|
|
24
|
+
/**
|
|
25
|
+
* One SshHost per host, which connects on the first call there and again after a loss. What ssh asks
|
|
26
|
+
* goes to every client that watches, and the first answer counts, as with the dialogs of sessions.
|
|
27
|
+
*/
|
|
28
|
+
let DefaultRemoteHosts = class DefaultRemoteHosts {
|
|
29
|
+
constructor() {
|
|
30
|
+
this.hosts = new Map();
|
|
31
|
+
this.waiting = new Map();
|
|
32
|
+
this.watchers = new Set();
|
|
33
|
+
this.disconnectListeners = new Set();
|
|
34
|
+
}
|
|
35
|
+
client(host) {
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
|
+
var _e;
|
|
38
|
+
this.check(host);
|
|
39
|
+
let ssh = this.hosts.get(host);
|
|
40
|
+
if (!ssh) {
|
|
41
|
+
ssh = new ta_exec_1.SshHost({
|
|
42
|
+
host,
|
|
43
|
+
stateDir: (_e = (_a = this.codingAgentOptions) === null || _a === void 0 ? void 0 : _a.agentDir) !== null && _e !== void 0 ? _e : ta_brand_1.TaBrand.agentDir(),
|
|
44
|
+
ssh: ((_b = this.options) === null || _b === void 0 ? void 0 : _b.ssh) || undefined,
|
|
45
|
+
sshArgs: (_c = this.options) === null || _c === void 0 ? void 0 : _c.sshArgs,
|
|
46
|
+
nodeMirror: ((_d = this.options) === null || _d === void 0 ? void 0 : _d.nodeMirror) || undefined,
|
|
47
|
+
ask: question => this.ask(host, question),
|
|
48
|
+
onStep: (step, detail) => this.broadcast({ type: 'progress', host, step, detail }),
|
|
49
|
+
});
|
|
50
|
+
ssh.client.onState((connected, error) => {
|
|
51
|
+
if (connected) {
|
|
52
|
+
this.workingDirectory.addRecentHost(host);
|
|
53
|
+
}
|
|
54
|
+
this.broadcast(error ? { type: 'connection', host, connected, error } : { type: 'connection', host, connected });
|
|
55
|
+
});
|
|
56
|
+
this.hosts.set(host, ssh);
|
|
57
|
+
}
|
|
58
|
+
return ssh.client;
|
|
59
|
+
}
|
|
60
|
+
list() {
|
|
61
|
+
const recent = this.workingDirectory.recentHosts();
|
|
62
|
+
const config = ta_exec_1.SshConfig.hosts().filter(host => ta_protocol_1.TaLocation.isHost(host) && !recent.includes(host));
|
|
63
|
+
return [
|
|
64
|
+
...recent.map(host => ({ host, source: 'recent', connected: this.connected(host) })),
|
|
65
|
+
...config.map(host => ({ host, source: 'config', connected: this.connected(host) })),
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
add(host) {
|
|
69
|
+
this.workingDirectory.addRecentHost(this.check(host));
|
|
70
|
+
}
|
|
71
|
+
async remove(host) {
|
|
72
|
+
await this.disconnect(host);
|
|
73
|
+
this.workingDirectory.removeRecentHost(host);
|
|
74
|
+
}
|
|
75
|
+
async resolve(location) {
|
|
76
|
+
const remote = this.parse(location);
|
|
77
|
+
if (!remote || remote.path) {
|
|
78
|
+
return location;
|
|
79
|
+
}
|
|
80
|
+
return ta_protocol_1.TaLocation.ssh(remote.host, (await this.client(remote.host).info()).cwd);
|
|
81
|
+
}
|
|
82
|
+
async disconnect(host) {
|
|
83
|
+
const ssh = this.hosts.get(host);
|
|
84
|
+
this.hosts.delete(host);
|
|
85
|
+
for (const listener of this.disconnectListeners) {
|
|
86
|
+
listener(host);
|
|
87
|
+
}
|
|
88
|
+
await (ssh === null || ssh === void 0 ? void 0 : ssh.dispose());
|
|
89
|
+
}
|
|
90
|
+
onDisconnect(listener) {
|
|
91
|
+
this.disconnectListeners.add(listener);
|
|
92
|
+
return () => this.disconnectListeners.delete(listener);
|
|
93
|
+
}
|
|
94
|
+
watch(connection) {
|
|
95
|
+
if (!this.watchers.has(connection)) {
|
|
96
|
+
this.watchers.add(connection);
|
|
97
|
+
connection.onClose(() => this.watchers.delete(connection));
|
|
98
|
+
}
|
|
99
|
+
return [...this.waiting.values()].map(({ prompt }) => prompt);
|
|
100
|
+
}
|
|
101
|
+
answer(promptId, value) {
|
|
102
|
+
const waiting = this.waiting.get(promptId);
|
|
103
|
+
waiting === null || waiting === void 0 ? void 0 : waiting.settle(typeof value === 'string' ? value : undefined);
|
|
104
|
+
return waiting !== undefined;
|
|
105
|
+
}
|
|
106
|
+
async onStop() {
|
|
107
|
+
for (const waiting of [...this.waiting.values()]) {
|
|
108
|
+
waiting.settle(undefined);
|
|
109
|
+
}
|
|
110
|
+
await Promise.all([...this.hosts.keys()].map(host => this.disconnect(host)));
|
|
111
|
+
}
|
|
112
|
+
ask(host, question) {
|
|
113
|
+
const prompt = { promptId: (0, node_crypto_1.randomUUID)(), host, ...question };
|
|
114
|
+
return new Promise(resolve => {
|
|
115
|
+
const timer = setTimeout(() => settle(undefined), PROMPT_TIMEOUT_MS);
|
|
116
|
+
const settle = (value) => {
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
if (this.waiting.delete(prompt.promptId)) {
|
|
119
|
+
this.broadcast({ type: 'prompt_closed', promptId: prompt.promptId });
|
|
120
|
+
resolve(value);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
this.waiting.set(prompt.promptId, { prompt, settle });
|
|
124
|
+
this.broadcast({ type: 'prompt', prompt });
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
broadcast(event) {
|
|
128
|
+
for (const connection of this.watchers) {
|
|
129
|
+
if (!connection.closed) {
|
|
130
|
+
connection
|
|
131
|
+
.client(ta_protocol_1.TaClient)
|
|
132
|
+
.onRemoteEvent(event)
|
|
133
|
+
.catch(() => undefined);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
check(host) {
|
|
138
|
+
if (typeof host !== 'string' || !ta_protocol_1.TaLocation.isHost(host)) {
|
|
139
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${JSON.stringify(host)} is not a host.`, 'Name a Host of ~/.ssh/config, or [user@]host[:port].');
|
|
140
|
+
}
|
|
141
|
+
return host;
|
|
142
|
+
}
|
|
143
|
+
connected(host) {
|
|
144
|
+
var _a;
|
|
145
|
+
var _b;
|
|
146
|
+
return (_b = (_a = this.hosts.get(host)) === null || _a === void 0 ? void 0 : _a.client.connected) !== null && _b !== void 0 ? _b : false;
|
|
147
|
+
}
|
|
148
|
+
parse(location) {
|
|
149
|
+
try {
|
|
150
|
+
return ta_protocol_1.TaLocation.parse(location);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
throw ta_errors_1.TaErrors.invalidArgument(error.message, 'Write ssh://<host>/<absolute path>.');
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
exports.DefaultRemoteHosts = DefaultRemoteHosts;
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, core_1.Value)(remote_protocol_1.TA_REMOTE_OPTIONS),
|
|
160
|
+
__metadata("design:type", Object)
|
|
161
|
+
], DefaultRemoteHosts.prototype, "options", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
(0, core_1.Value)(ai_coding_agent_1.CODING_AGENT_OPTIONS),
|
|
164
|
+
__metadata("design:type", Object)
|
|
165
|
+
], DefaultRemoteHosts.prototype, "codingAgentOptions", void 0);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, core_1.Autowired)(working_directory_1.TaWorkingDirectory),
|
|
168
|
+
__metadata("design:type", Object)
|
|
169
|
+
], DefaultRemoteHosts.prototype, "workingDirectory", void 0);
|
|
170
|
+
exports.DefaultRemoteHosts = DefaultRemoteHosts = __decorate([
|
|
171
|
+
(0, core_1.Component)([remote_protocol_1.RemoteHosts, core_1.ApplicationLifecycle])
|
|
172
|
+
], DefaultRemoteHosts);
|
|
173
|
+
//# sourceMappingURL=remote-hosts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-hosts.js","sourceRoot":"","sources":["../../../src/node/remote/remote-hosts.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyC;AACzC,6DAAwF;AACxF,uCAAmG;AAEnG,6CAAwF;AACxF,mEAA+D;AAC/D,qDAAuH;AACvH,4CAAwC;AACxC,4DAA0D;AAC1D,uDAAyF;AAEzF,qEAAqE;AACrE,MAAM,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAOxC;;;GAGG;AAEI,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAAxB;QAUgB,UAAK,GAAG,IAAI,GAAG,EAAmB,CAAC;QACnC,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QACrC,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C,KAAK,CAAC,QAAQ,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,MAAM,oBAAQ,CAAC,eAAe,CAAE,KAAe,CAAC,OAAO,EAAE,qCAAqC,CAAC,CAAC;QACpG,CAAC;IACL,CAAC;CACJ,CAAA;;AA/IsB;IADlB,IAAA,YAAK,EAAC,mCAAiB,CAAC;;mDACoB;AAG1B;IADlB,IAAA,YAAK,EAAC,sCAAoB,CAAC;;8DAC+B;AAGxC;IADlB,IAAA,gBAAS,EAAC,sCAAkB,CAAC;;4DAC0B;6BAR/C,kBAAkB;IAD9B,IAAA,gBAAS,EAAC,CAAC,6BAAW,EAAE,2BAAoB,CAAC,CAAC;GAClC,kBAAkB,CAiJ9B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { RpcConnection } from '@celljs/rpc/lib/node';
|
|
2
|
+
import type { ExecClient } from '@celljs/ta-exec';
|
|
3
|
+
import type { TaForwardedPort, TaRemoteHost, TaRemotePrompt } from '@celljs/ta-protocol';
|
|
4
|
+
export declare const TA_REMOTE_OPTIONS = "ta.remote";
|
|
5
|
+
/** `ta.remote`: how ta serve reaches other machines. */
|
|
6
|
+
export interface TaRemoteOptions {
|
|
7
|
+
/** The ssh command; default `ssh`. */
|
|
8
|
+
ssh?: string;
|
|
9
|
+
/** Before each host, as `-F <file>`. */
|
|
10
|
+
sshArgs?: string[];
|
|
11
|
+
/** Where Node.js comes from for hosts without one; empty: nodejs.org. */
|
|
12
|
+
nodeMirror?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const RemoteHosts: unique symbol;
|
|
15
|
+
export declare const PiDirectories: unique symbol;
|
|
16
|
+
export declare const PortForwards: unique symbol;
|
|
17
|
+
/** The hosts of `ssh://` locations, one connection each, and what their ssh asks the users. */
|
|
18
|
+
export interface RemoteHosts {
|
|
19
|
+
/** The connection to a host, made on its first call. */
|
|
20
|
+
client(host: string): ExecClient;
|
|
21
|
+
list(): TaRemoteHost[];
|
|
22
|
+
/** Keeps a host in the list without connecting; throws for what is not a host. */
|
|
23
|
+
add(host: string): void;
|
|
24
|
+
/** Disconnects and drops it from the list of those opened before. */
|
|
25
|
+
remove(host: string): Promise<void>;
|
|
26
|
+
/** The location with the home directory as its path when it has none. */
|
|
27
|
+
resolve(location: string): Promise<string>;
|
|
28
|
+
disconnect(host: string): Promise<void>;
|
|
29
|
+
/** Runs once a host is disconnected on purpose. */
|
|
30
|
+
onDisconnect(listener: (host: string) => void): () => void;
|
|
31
|
+
/** The connection hears TaClient.onRemoteEvent; the prompts that wait now. */
|
|
32
|
+
watch(connection: RpcConnection): TaRemotePrompt[];
|
|
33
|
+
answer(promptId: string, value: string | null): boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The directory pi works in for a location. pi reads and writes this machine's files in it (its
|
|
37
|
+
* sessions are named after it, the project's settings are there), so a directory of another machine
|
|
38
|
+
* gets one here, empty, under `<agent directory>/remote/`; the agent's tools work there.
|
|
39
|
+
*/
|
|
40
|
+
export interface PiDirectories {
|
|
41
|
+
/** Creates it when it is not there. */
|
|
42
|
+
toPi(location: string): string;
|
|
43
|
+
/** The location of a directory that `toPi` gave; any other is a directory of this machine. */
|
|
44
|
+
fromPi(cwd: string): string;
|
|
45
|
+
}
|
|
46
|
+
/** Ports of other machines, opened on this one. */
|
|
47
|
+
export interface PortForwards {
|
|
48
|
+
forward(cwd: string, port: number): Promise<TaForwardedPort>;
|
|
49
|
+
list(): TaForwardedPort[];
|
|
50
|
+
close(host: string, remotePort: number): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=remote-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-protocol.d.ts","sourceRoot":"","sources":["../../../src/node/remote/remote-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,E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W,aAAa;IAC1B,uCAAuC;IACvC,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,8FAA8F;IAC9F,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC/B;AAED,mDAAmD;AACnD,MAAM,WAAW,YAAY;IACzB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7D,IAAI,IAAI,eAAe,EAAE,CAAC;IAC1B,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PortForwards = exports.PiDirectories = exports.RemoteHosts = exports.TA_REMOTE_OPTIONS = void 0;
|
|
4
|
+
exports.TA_REMOTE_OPTIONS = 'ta.remote';
|
|
5
|
+
exports.RemoteHosts = Symbol('RemoteHosts');
|
|
6
|
+
exports.PiDirectories = Symbol('PiDirectories');
|
|
7
|
+
exports.PortForwards = Symbol('PortForwards');
|
|
8
|
+
//# sourceMappingURL=remote-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-protocol.js","sourceRoot":"","sources":["../../../src/node/remote/remote-protocol.ts"],"names":[],"mappings":";;;AAIa,QAAA,iBAAiB,GAAG,WAAW,CAAC;AAYhC,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AACpC,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AACxC,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
2
|
+
import { type TaForwardedPort, type TaRemoteHost, type TaRemotePrompt, TaRemoteServer } from '@celljs/ta-protocol';
|
|
3
|
+
import { PortForwards, RemoteHosts } from './remote-protocol';
|
|
4
|
+
/** The other machines that conversations work on, for the clients. */
|
|
5
|
+
export declare class TaRemoteServerImpl implements TaRemoteServer {
|
|
6
|
+
protected readonly hosts: RemoteHosts;
|
|
7
|
+
protected readonly ports: PortForwards;
|
|
8
|
+
protected readonly environments: ExecEnvironmentFactory;
|
|
9
|
+
listHosts(): Promise<TaRemoteHost[]>;
|
|
10
|
+
addHost(host: string): Promise<void>;
|
|
11
|
+
removeHost(host: string): Promise<void>;
|
|
12
|
+
resolveLocation(location: string): Promise<string>;
|
|
13
|
+
forwardPort(port: number, cwd?: string): Promise<TaForwardedPort>;
|
|
14
|
+
listForwardedPorts(): Promise<TaForwardedPort[]>;
|
|
15
|
+
closeForwardedPort(host: string, remotePort: number): Promise<void>;
|
|
16
|
+
watch(): Promise<TaRemotePrompt[]>;
|
|
17
|
+
answer(promptId: string, value: string | null): Promise<boolean>;
|
|
18
|
+
disconnect(host: string): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=remote-server-impl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-server-impl.d.ts","sourceRoot":"","sources":["../../../src/node/remote/remote-server-impl.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,cAAc,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAEnH,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE9D,sEAAsE;AACtE,qBACa,kBAAmB,YAAW,cAAc;IAErD,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAGtC,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAGvC,SAA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