@celljs/ta-host 4.17.0 → 4.19.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/node/account-service.d.ts +73 -0
- package/esm/node/account-service.js +304 -0
- package/esm/node/app-commands.d.ts +1 -1
- package/esm/node/app-commands.js +46 -29
- package/esm/node/credentials.d.ts +12 -0
- package/esm/node/credentials.js +35 -0
- package/esm/node/host-protocol.d.ts +2 -0
- package/esm/node/host-protocol.js +2 -0
- package/esm/node/index.d.ts +3 -0
- package/esm/node/index.js +3 -0
- package/esm/node/keep-awake.d.ts +3 -0
- package/esm/node/keep-awake.js +6 -1
- package/esm/node/package-hosts.d.ts +4 -0
- package/esm/node/package-hosts.js +18 -1
- package/esm/node/relay-bridge.js +1 -1
- package/esm/node/rooms-bridge.d.ts +10 -1
- package/esm/node/rooms-bridge.js +25 -0
- package/esm/node/screen-share/desktop-picture.d.ts +51 -0
- package/esm/node/screen-share/desktop-picture.js +133 -0
- package/esm/node/screen-share/desktop-session.d.ts +128 -0
- package/esm/node/screen-share/desktop-session.js +437 -0
- package/esm/node/screen-share/desktop-targets.d.ts +24 -0
- package/esm/node/screen-share/desktop-targets.js +80 -0
- package/esm/node/screen-share/desktop-viewer.d.ts +146 -0
- package/esm/node/screen-share/desktop-viewer.js +339 -0
- package/esm/node/screen-share/index.d.ts +8 -0
- package/esm/node/screen-share/index.js +9 -0
- package/esm/node/screen-share/rfb-client.d.ts +54 -0
- package/esm/node/screen-share/rfb-client.js +179 -0
- package/esm/node/screen-share/rfb-des.d.ts +11 -0
- package/esm/node/screen-share/rfb-des.js +143 -0
- package/esm/node/screen-share/rfb-encodings.d.ts +71 -0
- package/esm/node/screen-share/rfb-encodings.js +288 -0
- package/esm/node/screen-share/rfb-framebuffer.d.ts +16 -0
- package/esm/node/screen-share/rfb-framebuffer.js +53 -0
- package/esm/node/screen-share/rfb-protocol.d.ts +90 -0
- package/esm/node/screen-share/rfb-protocol.js +36 -0
- package/esm/node/screen-share/rfb-reader.d.ts +34 -0
- package/esm/node/screen-share/rfb-reader.js +110 -0
- package/esm/node/screen-share/rfb-security.d.ts +30 -0
- package/esm/node/screen-share/rfb-security.js +136 -0
- package/esm/node/screen-share/rfb-test-server.d.ts +37 -0
- package/esm/node/screen-share/rfb-test-server.js +116 -0
- package/esm/node/screen-share/screen-share-server-impl.d.ts +37 -0
- package/esm/node/screen-share/screen-share-server-impl.js +76 -0
- package/esm/node/screen-share/screen-shares.d.ts +123 -0
- package/esm/node/screen-share/screen-shares.js +463 -0
- package/esm/node/session-info-util.d.ts +10 -11
- package/esm/node/session-info-util.js +16 -94
- package/esm/node/settings-store.d.ts +1 -1
- package/esm/node/settings-store.js +7 -4
- package/esm/node/sign-in/access-store.d.ts +1 -1
- package/esm/node/sign-in/access-store.js +4 -1
- package/esm/node/sign-in/index.d.ts +2 -0
- package/esm/node/sign-in/index.js +2 -0
- package/esm/node/sign-in/polled-sign-in.d.ts +50 -0
- package/esm/node/sign-in/polled-sign-in.js +83 -0
- package/esm/node/sign-in/sign-in-devices.d.ts +55 -0
- package/esm/node/sign-in/sign-in-devices.js +113 -0
- package/esm/node/sign-in/sign-in-flow.d.ts +38 -4
- package/esm/node/sign-in/sign-in-flow.js +79 -4
- package/esm/node/sign-in/sign-in-pages.d.ts +8 -0
- package/esm/node/sign-in/sign-in-pages.js +137 -8
- package/esm/node/sign-in/sign-in-provider.d.ts +6 -0
- package/esm/node/sign-in/sign-in-provider.js +15 -0
- package/esm/node/sources-extension.d.ts +10 -0
- package/esm/node/sources-extension.js +18 -0
- package/esm/node/ta-server-impl.js +3 -3
- package/esm/node/ta-session-factory.js +2 -0
- package/esm/node/team/team-calls.js +35 -0
- package/esm/node/voice-bridge.d.ts +3 -1
- package/esm/node/voice-bridge.js +10 -3
- package/esm/node/voices-file.d.ts +5 -0
- package/esm/node/voices-file.js +14 -3
- package/esm/node/working-directory.d.ts +8 -2
- package/esm/node/working-directory.js +7 -0
- package/lib/node/account-service.d.ts +74 -0
- package/lib/node/account-service.js +307 -0
- package/lib/node/app-commands.d.ts +1 -1
- package/lib/node/app-commands.js +46 -29
- package/lib/node/credentials.d.ts +13 -0
- package/lib/node/credentials.js +38 -0
- package/lib/node/host-protocol.d.ts +2 -0
- package/lib/node/host-protocol.js +3 -1
- package/lib/node/index.d.ts +3 -0
- package/lib/node/index.js +3 -0
- package/lib/node/keep-awake.d.ts +3 -0
- package/lib/node/keep-awake.js +6 -1
- package/lib/node/package-hosts.d.ts +4 -0
- package/lib/node/package-hosts.js +17 -0
- package/lib/node/relay-bridge.js +1 -1
- package/lib/node/rooms-bridge.d.ts +10 -1
- package/lib/node/rooms-bridge.js +25 -0
- package/lib/node/screen-share/desktop-picture.d.ts +52 -0
- package/lib/node/screen-share/desktop-picture.js +136 -0
- package/lib/node/screen-share/desktop-session.d.ts +129 -0
- package/lib/node/screen-share/desktop-session.js +442 -0
- package/lib/node/screen-share/desktop-targets.d.ts +25 -0
- package/lib/node/screen-share/desktop-targets.js +84 -0
- package/lib/node/screen-share/desktop-viewer.d.ts +147 -0
- package/lib/node/screen-share/desktop-viewer.js +343 -0
- package/lib/node/screen-share/index.d.ts +9 -0
- package/lib/node/screen-share/index.js +25 -0
- package/lib/node/screen-share/rfb-client.d.ts +55 -0
- package/lib/node/screen-share/rfb-client.js +183 -0
- package/lib/node/screen-share/rfb-des.d.ts +12 -0
- package/lib/node/screen-share/rfb-des.js +146 -0
- package/lib/node/screen-share/rfb-encodings.d.ts +72 -0
- package/lib/node/screen-share/rfb-encodings.js +295 -0
- package/lib/node/screen-share/rfb-framebuffer.d.ts +17 -0
- package/lib/node/screen-share/rfb-framebuffer.js +57 -0
- package/lib/node/screen-share/rfb-protocol.d.ts +91 -0
- package/lib/node/screen-share/rfb-protocol.js +39 -0
- package/lib/node/screen-share/rfb-reader.d.ts +35 -0
- package/lib/node/screen-share/rfb-reader.js +115 -0
- package/lib/node/screen-share/rfb-security.d.ts +31 -0
- package/lib/node/screen-share/rfb-security.js +141 -0
- package/lib/node/screen-share/rfb-test-server.d.ts +38 -0
- package/lib/node/screen-share/rfb-test-server.js +120 -0
- package/lib/node/screen-share/screen-share-server-impl.d.ts +38 -0
- package/lib/node/screen-share/screen-share-server-impl.js +79 -0
- package/lib/node/screen-share/screen-shares.d.ts +124 -0
- package/lib/node/screen-share/screen-shares.js +464 -0
- package/lib/node/session-info-util.d.ts +10 -11
- package/lib/node/session-info-util.js +15 -93
- package/lib/node/settings-store.d.ts +1 -1
- package/lib/node/settings-store.js +6 -3
- package/lib/node/sign-in/access-store.d.ts +1 -1
- package/lib/node/sign-in/access-store.js +4 -1
- package/lib/node/sign-in/index.d.ts +2 -0
- package/lib/node/sign-in/index.js +2 -0
- package/lib/node/sign-in/polled-sign-in.d.ts +51 -0
- package/lib/node/sign-in/polled-sign-in.js +87 -0
- package/lib/node/sign-in/sign-in-devices.d.ts +56 -0
- package/lib/node/sign-in/sign-in-devices.js +117 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +38 -4
- package/lib/node/sign-in/sign-in-flow.js +80 -5
- package/lib/node/sign-in/sign-in-pages.d.ts +8 -0
- package/lib/node/sign-in/sign-in-pages.js +136 -7
- package/lib/node/sign-in/sign-in-provider.d.ts +6 -0
- package/lib/node/sign-in/sign-in-provider.js +15 -0
- package/lib/node/sources-extension.d.ts +11 -0
- package/lib/node/sources-extension.js +22 -0
- package/lib/node/ta-server-impl.js +2 -2
- package/lib/node/ta-session-factory.js +2 -0
- package/lib/node/team/team-calls.js +35 -0
- package/lib/node/voice-bridge.d.ts +3 -1
- package/lib/node/voice-bridge.js +9 -2
- package/lib/node/voices-file.d.ts +5 -0
- package/lib/node/voices-file.js +14 -3
- package/lib/node/working-directory.d.ts +8 -2
- package/lib/node/working-directory.js +7 -0
- package/package.json +14 -10
|
@@ -0,0 +1,464 @@
|
|
|
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
|
+
var ScreenShares_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.ScreenShares = void 0;
|
|
14
|
+
const node_crypto_1 = require("node:crypto");
|
|
15
|
+
const node_net_1 = require("node:net");
|
|
16
|
+
const node_os_1 = require("node:os");
|
|
17
|
+
const core_1 = require("@celljs/core");
|
|
18
|
+
const ta_exec_1 = require("@celljs/ta-exec");
|
|
19
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
20
|
+
const credentials_1 = require("../credentials");
|
|
21
|
+
const remote_protocol_1 = require("../remote/remote-protocol");
|
|
22
|
+
const ta_errors_1 = require("../ta-errors");
|
|
23
|
+
const team_protocol_1 = require("../team/team-protocol");
|
|
24
|
+
const working_directory_1 = require("../working-directory");
|
|
25
|
+
const desktop_session_1 = require("./desktop-session");
|
|
26
|
+
const desktop_targets_1 = require("./desktop-targets");
|
|
27
|
+
const desktop_viewer_1 = require("./desktop-viewer");
|
|
28
|
+
/** A prompt nobody answers is given up after this. */
|
|
29
|
+
const PROMPT_TIMEOUT_MS = 5 * 60000;
|
|
30
|
+
/** Pages that may look at one desktop at once (docs/design/ta-desktop-remote.md 8.3). */
|
|
31
|
+
const MAX_VIEWERS = 4;
|
|
32
|
+
/** What a viewer stays after its connection dropped: a page that comes back within it goes on. */
|
|
33
|
+
const ORPHAN_MS = 30000;
|
|
34
|
+
/** How long listDesktopScreens waits for a desktop to connect. */
|
|
35
|
+
const SCREENS_WAIT_MS = 15000;
|
|
36
|
+
/**
|
|
37
|
+
* The desktops ta serve shows and works for the owner's pages (docs/design/ta-desktop-remote.md): which there are,
|
|
38
|
+
* one DesktopSession for each one looked at, the viewers of the pages, and what a connection asks of whoever is there.
|
|
39
|
+
* Its connections go through the ExecEnvironment of the machine of the desktop, never a socket to a machine of its own
|
|
40
|
+
* choosing; only the desktops of the list are ever reached. In the first stage every call is the owner's
|
|
41
|
+
* (team-calls.ts), so there is no one else to check here.
|
|
42
|
+
*/
|
|
43
|
+
let ScreenShares = ScreenShares_1 = class ScreenShares {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.sessions = new Map();
|
|
46
|
+
this.viewers = new Map();
|
|
47
|
+
this.waiting = new Map();
|
|
48
|
+
this.watchers = new Set();
|
|
49
|
+
this.closing = new WeakSet();
|
|
50
|
+
this.signing = new Map();
|
|
51
|
+
/** Desktops that refused the sign-in kept for them: asked again until one is taken. */
|
|
52
|
+
this.refused = new Set();
|
|
53
|
+
/** The account each desktop was signed in to last, put in the form next time. */
|
|
54
|
+
this.users = new Map();
|
|
55
|
+
}
|
|
56
|
+
get targets() {
|
|
57
|
+
var _a;
|
|
58
|
+
(_a = this.targetsOf) !== null && _a !== void 0 ? _a : (this.targetsOf = new desktop_targets_1.DesktopTargets(this.workingDirectory));
|
|
59
|
+
return this.targetsOf;
|
|
60
|
+
}
|
|
61
|
+
list(connection) {
|
|
62
|
+
const hosts = this.hosts.list().filter(host => !ta_protocol_1.TaLocation.isCloud(host.host));
|
|
63
|
+
return this.targets
|
|
64
|
+
.list((0, node_os_1.hostname)(), hosts.map(host => host.host))
|
|
65
|
+
.map(info => this.described(info, connection));
|
|
66
|
+
}
|
|
67
|
+
add(target) {
|
|
68
|
+
return this.described(this.targets.add(target));
|
|
69
|
+
}
|
|
70
|
+
remove(desktopId) {
|
|
71
|
+
this.targets.remove(desktopId);
|
|
72
|
+
const session = this.sessions.get(desktopId);
|
|
73
|
+
if (session) {
|
|
74
|
+
for (const viewerId of [...session.viewers.keys()]) {
|
|
75
|
+
this.drop(viewerId);
|
|
76
|
+
}
|
|
77
|
+
session.close();
|
|
78
|
+
this.sessions.delete(desktopId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
open(connection, options) {
|
|
82
|
+
const { view, clientMessageId } = options !== null && options !== void 0 ? options : {};
|
|
83
|
+
if (typeof clientMessageId !== 'string' || !clientMessageId || clientMessageId.length > 200) {
|
|
84
|
+
throw ta_errors_1.TaErrors.invalidArgument('openDesktop needs a clientMessageId.', 'Compute one from the page and the desktop.');
|
|
85
|
+
}
|
|
86
|
+
const info = this.find(options.target);
|
|
87
|
+
const principal = this.principals.of(connection);
|
|
88
|
+
// The same page asking again (a lost answer, a new connection after a drop): the same viewer while it lives.
|
|
89
|
+
for (const entry of this.viewers.values()) {
|
|
90
|
+
if (entry.viewer.clientMessageId === clientMessageId && entry.viewer.principal === principal && entry.session.id === info.id) {
|
|
91
|
+
this.adopt(entry, connection);
|
|
92
|
+
entry.viewer.setView(view, entry.session.framebuffer);
|
|
93
|
+
return this.viewerOf(entry);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
let session = this.sessions.get(info.id);
|
|
97
|
+
if (!session) {
|
|
98
|
+
const created = new desktop_session_1.DesktopSession(info.id, info.name, {
|
|
99
|
+
connect: () => this.connect(info.target),
|
|
100
|
+
credentials: need => this.credentials(info, need),
|
|
101
|
+
signedIn: taken => this.signedIn(info, taken),
|
|
102
|
+
nameOf: who => this.nameOf(who),
|
|
103
|
+
idle: () => {
|
|
104
|
+
if (this.sessions.get(info.id) === created) {
|
|
105
|
+
this.sessions.delete(info.id);
|
|
106
|
+
}
|
|
107
|
+
// What it asked and no one answered is asked no more.
|
|
108
|
+
for (const waiting of [...this.waiting.values()].filter(one => one.prompt.desktop === info.id)) {
|
|
109
|
+
waiting.settle(undefined);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
session = created;
|
|
114
|
+
this.sessions.set(info.id, created);
|
|
115
|
+
}
|
|
116
|
+
if (session.viewers.size >= MAX_VIEWERS) {
|
|
117
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${MAX_VIEWERS} pages look at this computer already.`, 'Close one of them first.');
|
|
118
|
+
}
|
|
119
|
+
// Random and never used again: a viewer opened anew counts its frames from 1, and a claim of the old one is unknown.
|
|
120
|
+
const viewer = new desktop_viewer_1.DesktopViewer((0, node_crypto_1.randomBytes)(16).toString('hex'), connection, principal, clientMessageId, ScreenShares_1.device(options.device), view);
|
|
121
|
+
const entry = { viewer, session };
|
|
122
|
+
this.viewers.set(viewer.id, entry);
|
|
123
|
+
this.adopt(entry, connection);
|
|
124
|
+
session.add(viewer);
|
|
125
|
+
// Opening is acting: the owner's page works the desktop at once, taking it from another page of theirs.
|
|
126
|
+
session.take(viewer, holder => holder.principal === ta_protocol_1.TA_OWNER);
|
|
127
|
+
return this.viewerOf(entry);
|
|
128
|
+
}
|
|
129
|
+
close(connection, viewerId) {
|
|
130
|
+
if (this.entryOf(connection, viewerId)) {
|
|
131
|
+
this.drop(viewerId);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async read(connection, viewerId, want) {
|
|
135
|
+
const entry = this.entryOf(connection, viewerId);
|
|
136
|
+
if (!entry) {
|
|
137
|
+
return { seq: 0, unknown: true, waited: 0, tiles: [] };
|
|
138
|
+
}
|
|
139
|
+
this.adopt(entry, connection);
|
|
140
|
+
return entry.session.read(entry.viewer, Number(want));
|
|
141
|
+
}
|
|
142
|
+
setView(connection, viewerId, view) {
|
|
143
|
+
const { viewer, session } = this.require(connection, viewerId);
|
|
144
|
+
viewer.setView(view, session.framebuffer, session.screenOf(view === null || view === void 0 ? void 0 : view.screen));
|
|
145
|
+
}
|
|
146
|
+
input(connection, viewerId, batch) {
|
|
147
|
+
const { viewer, session } = this.require(connection, viewerId);
|
|
148
|
+
session.input(viewer, batch);
|
|
149
|
+
}
|
|
150
|
+
paste(connection, viewerId, input) {
|
|
151
|
+
var _a;
|
|
152
|
+
const { viewer, session } = this.require(connection, viewerId);
|
|
153
|
+
if (typeof (input === null || input === void 0 ? void 0 : input.text) !== 'string' || input.text.length > 64 * 1024) {
|
|
154
|
+
throw ta_errors_1.TaErrors.invalidArgument('The text to paste is too long.', 'Paste at most 64 KB at once.');
|
|
155
|
+
}
|
|
156
|
+
session.paste(viewer, input.text, !!input.press, String((_a = input.clientMessageId) !== null && _a !== void 0 ? _a : ''));
|
|
157
|
+
}
|
|
158
|
+
take(connection, viewerId) {
|
|
159
|
+
const { viewer, session } = this.require(connection, viewerId);
|
|
160
|
+
// Among the pages of one person, whoever takes it has it (docs/design/ta-desktop-remote.md 6.4).
|
|
161
|
+
return { control: session.take(viewer, holder => holder.principal === viewer.principal), asked: false };
|
|
162
|
+
}
|
|
163
|
+
release(connection, viewerId) {
|
|
164
|
+
const { viewer, session } = this.require(connection, viewerId);
|
|
165
|
+
session.release(viewer);
|
|
166
|
+
}
|
|
167
|
+
/** Ends every viewer of every desktop, and their connections. */
|
|
168
|
+
endAll() {
|
|
169
|
+
for (const viewerId of [...this.viewers.keys()]) {
|
|
170
|
+
this.drop(viewerId);
|
|
171
|
+
}
|
|
172
|
+
for (const session of this.sessions.values()) {
|
|
173
|
+
session.close();
|
|
174
|
+
}
|
|
175
|
+
this.sessions.clear();
|
|
176
|
+
}
|
|
177
|
+
/** The screens of a desktop: connecting to it for a while when no page does. */
|
|
178
|
+
async screens(target) {
|
|
179
|
+
const info = this.find(target);
|
|
180
|
+
const session = this.sessions.get(info.id);
|
|
181
|
+
if (session === null || session === void 0 ? void 0 : session.showing) {
|
|
182
|
+
return session.screensOf();
|
|
183
|
+
}
|
|
184
|
+
const probe = session !== null && session !== void 0 ? session : new desktop_session_1.DesktopSession(info.id, info.name, {
|
|
185
|
+
connect: () => this.connect(info.target),
|
|
186
|
+
credentials: need => this.credentials(info, need),
|
|
187
|
+
signedIn: taken => this.signedIn(info, taken),
|
|
188
|
+
nameOf: who => this.nameOf(who),
|
|
189
|
+
idle: () => undefined,
|
|
190
|
+
});
|
|
191
|
+
try {
|
|
192
|
+
await Promise.race([probe.start(), new Promise(resolve => setTimeout(resolve, SCREENS_WAIT_MS))]);
|
|
193
|
+
if (probe.link !== 'live') {
|
|
194
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${info.name} did not connect${probe.error ? `: ${probe.error}` : ''}.`, 'Check that its screen sharing is on.');
|
|
195
|
+
}
|
|
196
|
+
return probe.screensOf();
|
|
197
|
+
}
|
|
198
|
+
finally {
|
|
199
|
+
if (!session) {
|
|
200
|
+
probe.close();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
watch(connection) {
|
|
205
|
+
if (!this.watchers.has(connection)) {
|
|
206
|
+
this.watchers.add(connection);
|
|
207
|
+
connection.onClose(() => this.watchers.delete(connection));
|
|
208
|
+
}
|
|
209
|
+
return [...this.waiting.values()].map(({ prompt }) => prompt);
|
|
210
|
+
}
|
|
211
|
+
answer(promptId, answer, remember = false) {
|
|
212
|
+
const waiting = this.waiting.get(promptId);
|
|
213
|
+
waiting === null || waiting === void 0 ? void 0 : waiting.settle(ScreenShares_1.signInOf(answer), remember);
|
|
214
|
+
return waiting !== undefined;
|
|
215
|
+
}
|
|
216
|
+
/** Whether anyone looks at a desktop now: the computer stays awake meanwhile. */
|
|
217
|
+
get watched() {
|
|
218
|
+
return this.viewers.size > 0;
|
|
219
|
+
}
|
|
220
|
+
dispose() {
|
|
221
|
+
for (const waiting of [...this.waiting.values()]) {
|
|
222
|
+
waiting.settle(undefined);
|
|
223
|
+
}
|
|
224
|
+
this.endAll();
|
|
225
|
+
}
|
|
226
|
+
find(target) {
|
|
227
|
+
const id = target ? ta_protocol_1.TaDesktopUtil.id(target) : '';
|
|
228
|
+
const info = this.list().find(one => one.id === id);
|
|
229
|
+
if (!info) {
|
|
230
|
+
throw ta_errors_1.TaErrors.invalidArgument(`There is no desktop ${id || 'named'}.`, 'Pick one of listDesktops, or add it with addDesktop.');
|
|
231
|
+
}
|
|
232
|
+
return info;
|
|
233
|
+
}
|
|
234
|
+
async connect(target) {
|
|
235
|
+
const env = this.environments.create(target.via ? await this.environments.resolve(target.via) : await this.environments.defaultCwd());
|
|
236
|
+
const port = ta_protocol_1.TaDesktopUtil.port(target);
|
|
237
|
+
const host = ta_protocol_1.TaDesktopUtil.host(target);
|
|
238
|
+
if (env.connect) {
|
|
239
|
+
return env.connect(port, host);
|
|
240
|
+
}
|
|
241
|
+
if (!env.local) {
|
|
242
|
+
throw ta_errors_1.TaErrors.invalidArgument('This machine cannot open connections for Ta.', 'Update Ta on it.');
|
|
243
|
+
}
|
|
244
|
+
// This machine: an environment of it has no connect (PortForwards takes that for "nothing to forward").
|
|
245
|
+
return ScreenShares_1.connectHere(port, host);
|
|
246
|
+
}
|
|
247
|
+
static connectHere(port, host) {
|
|
248
|
+
return new Promise((resolve, reject) => {
|
|
249
|
+
const socket = (0, node_net_1.connect)({ port, host });
|
|
250
|
+
socket.once('error', reject);
|
|
251
|
+
socket.once('connect', () => {
|
|
252
|
+
socket.off('error', reject);
|
|
253
|
+
// Errors once connected end it; onClose tells.
|
|
254
|
+
socket.on('error', () => undefined);
|
|
255
|
+
socket.setNoDelay(true);
|
|
256
|
+
resolve({
|
|
257
|
+
write: data => void socket.write(data),
|
|
258
|
+
end: () => void socket.end(),
|
|
259
|
+
onData: listener => void socket.on('data', listener),
|
|
260
|
+
onClose: listener => (socket.destroyed ? listener() : void socket.once('close', () => listener())),
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* The account of the Screen Sharing of macOS, or the password of VNC: the one kept for the desktop, unless it
|
|
267
|
+
* refused it; else asked of every page of the owner in one form, who may have it kept.
|
|
268
|
+
*/
|
|
269
|
+
async credentials(info, need) {
|
|
270
|
+
var _a, _b;
|
|
271
|
+
const store = this.credentialStores.store;
|
|
272
|
+
let kept;
|
|
273
|
+
if (store) {
|
|
274
|
+
kept = await store.get(ScreenShares_1.credentialId(info.id)).catch(() => undefined);
|
|
275
|
+
if (!need.refused && !this.refused.has(info.id) && (kept === null || kept === void 0 ? void 0 : kept.password) && (!need.username || kept.username !== undefined)) {
|
|
276
|
+
this.signing.set(info.id, { credential: kept, kept: true, remember: false });
|
|
277
|
+
return kept;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const user = need.username ? ((_b = (_a = this.users.get(info.id)) !== null && _a !== void 0 ? _a : kept === null || kept === void 0 ? void 0 : kept.username) !== null && _b !== void 0 ? _b : (info.source === 'this' ? ScreenShares_1.localUser() : undefined)) : undefined;
|
|
281
|
+
const { answer, remember } = await this.ask({
|
|
282
|
+
promptId: (0, node_crypto_1.randomUUID)(),
|
|
283
|
+
desktop: info.id,
|
|
284
|
+
name: info.name,
|
|
285
|
+
account: need.username,
|
|
286
|
+
...(user ? { user } : {}),
|
|
287
|
+
...(need.refused || this.refused.has(info.id) ? { refused: true } : {}),
|
|
288
|
+
...(store ? { remember: true } : {}),
|
|
289
|
+
});
|
|
290
|
+
if (!answer || (need.username && !answer.username)) {
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
const credential = { password: answer.password, ...(need.username ? { username: answer.username } : {}) };
|
|
294
|
+
if (credential.username) {
|
|
295
|
+
this.users.set(info.id, credential.username);
|
|
296
|
+
}
|
|
297
|
+
this.signing.set(info.id, { credential, kept: false, remember: !!store && remember });
|
|
298
|
+
return credential;
|
|
299
|
+
}
|
|
300
|
+
/** A desktop took the sign-in or refused it: one the user asked to keep is kept now, a kept one refused is asked again. */
|
|
301
|
+
signedIn(info, taken) {
|
|
302
|
+
const signing = this.signing.get(info.id);
|
|
303
|
+
this.signing.delete(info.id);
|
|
304
|
+
const store = this.credentialStores.store;
|
|
305
|
+
if (!signing || !store) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (!taken) {
|
|
309
|
+
if (signing.kept) {
|
|
310
|
+
this.refused.add(info.id);
|
|
311
|
+
}
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
this.refused.delete(info.id);
|
|
315
|
+
if (signing.remember) {
|
|
316
|
+
store.set(ScreenShares_1.credentialId(info.id), signing.credential, { feature: 'desktop', name: info.name }).catch(error => {
|
|
317
|
+
console.error(`The sign-in of ${info.name} could not be kept: ${error instanceof Error ? error.message : error}`);
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
ask(prompt) {
|
|
322
|
+
return new Promise(resolve => {
|
|
323
|
+
const timer = setTimeout(() => settle(undefined), PROMPT_TIMEOUT_MS);
|
|
324
|
+
const settle = (answer, keep = false) => {
|
|
325
|
+
clearTimeout(timer);
|
|
326
|
+
if (this.waiting.delete(prompt.promptId)) {
|
|
327
|
+
this.broadcast({ type: 'prompt_closed', promptId: prompt.promptId });
|
|
328
|
+
resolve({ answer, remember: keep && answer !== undefined });
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
this.waiting.set(prompt.promptId, { prompt, settle });
|
|
332
|
+
this.broadcast({ type: 'prompt', prompt });
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
broadcast(event) {
|
|
336
|
+
for (const connection of this.watchers) {
|
|
337
|
+
// Only the owner's pages answer for the passwords of the owner's computers.
|
|
338
|
+
if (!connection.closed && this.principals.of(connection) === ta_protocol_1.TA_OWNER) {
|
|
339
|
+
connection
|
|
340
|
+
.client(ta_protocol_1.TaClient)
|
|
341
|
+
.onScreenShareEvent(event)
|
|
342
|
+
.catch(() => undefined);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
entryOf(connection, viewerId) {
|
|
347
|
+
const entry = this.viewers.get(String(viewerId !== null && viewerId !== void 0 ? viewerId : ''));
|
|
348
|
+
return entry && entry.viewer.principal === this.principals.of(connection) ? entry : undefined;
|
|
349
|
+
}
|
|
350
|
+
require(connection, viewerId) {
|
|
351
|
+
const entry = this.entryOf(connection, viewerId);
|
|
352
|
+
if (!entry) {
|
|
353
|
+
throw ta_errors_1.TaErrors.invalidArgument(`There is no desktop viewer ${viewerId}.`, 'Open the desktop again with openDesktop.');
|
|
354
|
+
}
|
|
355
|
+
// The page of a viewer orphaned by a drop calls on its new connection.
|
|
356
|
+
this.adopt(entry, connection);
|
|
357
|
+
return entry;
|
|
358
|
+
}
|
|
359
|
+
/** A viewer belongs to the connection that calls for it last; when that one drops, it waits ORPHAN_MS for the page. */
|
|
360
|
+
adopt(entry, connection) {
|
|
361
|
+
clearTimeout(entry.orphan);
|
|
362
|
+
entry.orphan = undefined;
|
|
363
|
+
entry.viewer.connection = connection;
|
|
364
|
+
if (!this.closing.has(connection)) {
|
|
365
|
+
this.closing.add(connection);
|
|
366
|
+
connection.onClose(() => {
|
|
367
|
+
for (const [viewerId, each] of this.viewers) {
|
|
368
|
+
if (each.viewer.connection === connection) {
|
|
369
|
+
each.orphan = setTimeout(() => this.drop(viewerId), ORPHAN_MS);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
drop(viewerId) {
|
|
376
|
+
const entry = this.viewers.get(viewerId);
|
|
377
|
+
if (entry) {
|
|
378
|
+
clearTimeout(entry.orphan);
|
|
379
|
+
this.viewers.delete(viewerId);
|
|
380
|
+
entry.session.remove(viewerId);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
viewerOf(entry) {
|
|
384
|
+
const { viewer, session } = entry;
|
|
385
|
+
const { width, height } = session.framebuffer;
|
|
386
|
+
return {
|
|
387
|
+
viewerId: viewer.id,
|
|
388
|
+
next: viewer.built + 1,
|
|
389
|
+
size: { width, height, screens: session.showing ? session.screensOf() : [] },
|
|
390
|
+
control: session.controlFor(viewer.id),
|
|
391
|
+
capabilities: session.capabilities(),
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
described(info, connection) {
|
|
395
|
+
const session = this.sessions.get(info.id);
|
|
396
|
+
if (!session) {
|
|
397
|
+
return info;
|
|
398
|
+
}
|
|
399
|
+
const mine = connection && [...session.viewers.values()].find(viewer => viewer.connection === connection);
|
|
400
|
+
const control = session.controlFor(mine === null || mine === void 0 ? void 0 : mine.id);
|
|
401
|
+
return {
|
|
402
|
+
...info,
|
|
403
|
+
state: session.link !== 'live' ? 'connecting' : session.controlled ? 'controlled' : 'viewing',
|
|
404
|
+
link: session.link,
|
|
405
|
+
...(session.showing ? { screens: session.screensOf(), capabilities: session.capabilities() } : {}),
|
|
406
|
+
control,
|
|
407
|
+
viewers: session.watchers(mine === null || mine === void 0 ? void 0 : mine.id),
|
|
408
|
+
...(mine ? { mine: { viewerId: mine.id, built: mine.built } } : {}),
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
nameOf(principal) {
|
|
412
|
+
return principal === ta_protocol_1.TA_OWNER ? '' : principal;
|
|
413
|
+
}
|
|
414
|
+
/** What a page answered, checked: a password, and an account when one came. */
|
|
415
|
+
static signInOf(answer) {
|
|
416
|
+
const given = answer;
|
|
417
|
+
if (!given || typeof given !== 'object' || typeof given.password !== 'string' || given.password.length > 1024) {
|
|
418
|
+
return undefined;
|
|
419
|
+
}
|
|
420
|
+
const username = typeof given.username === 'string' ? given.username.trim().slice(0, 256) : undefined;
|
|
421
|
+
return { password: given.password, ...(username ? { username } : {}) };
|
|
422
|
+
}
|
|
423
|
+
/** The account of whoever runs ta serve: the one to sign in to this computer with. */
|
|
424
|
+
static localUser() {
|
|
425
|
+
try {
|
|
426
|
+
return (0, node_os_1.userInfo)().username || undefined;
|
|
427
|
+
}
|
|
428
|
+
catch (_a) {
|
|
429
|
+
return undefined;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
/** The id of the sign-in of a desktop in the store. */
|
|
433
|
+
static credentialId(desktopId) {
|
|
434
|
+
return `desktop:${desktopId}`;
|
|
435
|
+
}
|
|
436
|
+
static device(device) {
|
|
437
|
+
return device === 'phone' || device === 'tablet' ? device : 'computer';
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
exports.ScreenShares = ScreenShares;
|
|
441
|
+
__decorate([
|
|
442
|
+
(0, core_1.Autowired)(ta_exec_1.ExecEnvironmentFactory),
|
|
443
|
+
__metadata("design:type", Object)
|
|
444
|
+
], ScreenShares.prototype, "environments", void 0);
|
|
445
|
+
__decorate([
|
|
446
|
+
(0, core_1.Autowired)(remote_protocol_1.RemoteHosts),
|
|
447
|
+
__metadata("design:type", Object)
|
|
448
|
+
], ScreenShares.prototype, "hosts", void 0);
|
|
449
|
+
__decorate([
|
|
450
|
+
(0, core_1.Autowired)(working_directory_1.TaWorkingDirectory),
|
|
451
|
+
__metadata("design:type", Object)
|
|
452
|
+
], ScreenShares.prototype, "workingDirectory", void 0);
|
|
453
|
+
__decorate([
|
|
454
|
+
(0, core_1.Autowired)({ id: team_protocol_1.TaPrincipals, detached: true }),
|
|
455
|
+
__metadata("design:type", Object)
|
|
456
|
+
], ScreenShares.prototype, "principals", void 0);
|
|
457
|
+
__decorate([
|
|
458
|
+
(0, core_1.Autowired)(credentials_1.TaCredentials),
|
|
459
|
+
__metadata("design:type", credentials_1.TaCredentials)
|
|
460
|
+
], ScreenShares.prototype, "credentialStores", void 0);
|
|
461
|
+
exports.ScreenShares = ScreenShares = ScreenShares_1 = __decorate([
|
|
462
|
+
(0, core_1.Component)()
|
|
463
|
+
], ScreenShares);
|
|
464
|
+
//# sourceMappingURL=screen-shares.js.map
|
|
@@ -4,26 +4,25 @@ interface MessageLike {
|
|
|
4
4
|
content?: unknown;
|
|
5
5
|
timestamp?: number;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* What a list of conversations shows of one: its first message, as pi's session list does, and when it last changed.
|
|
9
|
+
* What was said is read by TaSaid, which leaves out every mark of the model.
|
|
10
|
+
*/
|
|
8
11
|
export declare namespace SessionInfoUtil {
|
|
9
12
|
/**
|
|
10
|
-
* The first line of the first message of the user that
|
|
11
|
-
* a skill
|
|
13
|
+
* The first line of the first message of the user that says something, cut to a title's length: what they typed
|
|
14
|
+
* (TaSaid.words), a skill they ran as `/skill:name` and what follows; never a notice of a part of Ta (TaSaid.notice).
|
|
12
15
|
*/
|
|
13
16
|
function firstMessage(messages: readonly MessageLike[]): string | undefined;
|
|
14
17
|
/**
|
|
15
|
-
* The
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* (TaTaskNote) says the task: how one ended is its title and what it said, one handed to the double its title,
|
|
20
|
-
* and a note of a new id, for the double only, is passed over.
|
|
18
|
+
* The last thing the user or the agent said, on one line and cut to a preview's length, as a messaging app shows
|
|
19
|
+
* it under the name of a chat (TaSaid.line of TaSaid.words): without the marks of the model and of Markdown, the
|
|
20
|
+
* thinking and tool calls of the agent; a notice of a part of Ta (TaSaid.notice) and a message that says nothing for a person (the summary an agent compacted
|
|
21
|
+
* its context to, a note of a task's new id) is passed over.
|
|
21
22
|
*/
|
|
22
23
|
function lastMessage(messages: readonly MessageLike[]): string | undefined;
|
|
23
24
|
/** The time of the last message that has one, else `fallback`. */
|
|
24
25
|
function updatedAt(messages: readonly MessageLike[], fallback: number): number;
|
|
25
|
-
/** The text of the content of a message. */
|
|
26
|
-
function text(content: unknown): string;
|
|
27
26
|
}
|
|
28
27
|
export {};
|
|
29
28
|
//# sourceMappingURL=session-info-util.d.ts.map
|
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SessionInfoUtil = void 0;
|
|
4
4
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* What a list of conversations shows of one: its first message, as pi's session list does, and when it last changed.
|
|
7
|
+
* What was said is read by TaSaid, which leaves out every mark of the model.
|
|
8
|
+
*/
|
|
6
9
|
var SessionInfoUtil;
|
|
7
10
|
(function (SessionInfoUtil) {
|
|
8
11
|
const LENGTH = 120;
|
|
9
|
-
/** Of the text of the last message, what lastMessage reads: its lines are joined, many of them empty or marks only. */
|
|
10
|
-
const PREVIEW_READ = 2000;
|
|
11
12
|
/**
|
|
12
|
-
* The first line of the first message of the user that
|
|
13
|
-
* a skill
|
|
13
|
+
* The first line of the first message of the user that says something, cut to a title's length: what they typed
|
|
14
|
+
* (TaSaid.words), a skill they ran as `/skill:name` and what follows; never a notice of a part of Ta (TaSaid.notice).
|
|
14
15
|
*/
|
|
15
16
|
function firstMessage(messages) {
|
|
16
|
-
var _a;
|
|
17
17
|
for (const message of messages) {
|
|
18
|
-
if (message.role !== 'user') {
|
|
18
|
+
if (message.role !== 'user' || ta_protocol_1.TaSaid.notice(message)) {
|
|
19
19
|
continue;
|
|
20
20
|
}
|
|
21
|
-
const line = (
|
|
21
|
+
const line = ta_protocol_1.TaSaid.of(message)
|
|
22
22
|
.split('\n')
|
|
23
23
|
.map(part => part.trim())
|
|
24
24
|
.find(Boolean);
|
|
@@ -30,89 +30,25 @@ var SessionInfoUtil;
|
|
|
30
30
|
}
|
|
31
31
|
SessionInfoUtil.firstMessage = firstMessage;
|
|
32
32
|
/**
|
|
33
|
-
* The
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* (TaTaskNote) says the task: how one ended is its title and what it said, one handed to the double its title,
|
|
38
|
-
* and a note of a new id, for the double only, is passed over.
|
|
33
|
+
* The last thing the user or the agent said, on one line and cut to a preview's length, as a messaging app shows
|
|
34
|
+
* it under the name of a chat (TaSaid.line of TaSaid.words): without the marks of the model and of Markdown, the
|
|
35
|
+
* thinking and tool calls of the agent; a notice of a part of Ta (TaSaid.notice) and a message that says nothing for a person (the summary an agent compacted
|
|
36
|
+
* its context to, a note of a task's new id) is passed over.
|
|
39
37
|
*/
|
|
40
38
|
function lastMessage(messages) {
|
|
41
39
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
42
40
|
const message = messages[i];
|
|
43
|
-
if (message.role !== 'user' && message.role !== 'assistant') {
|
|
41
|
+
if ((message.role !== 'user' && message.role !== 'assistant') || ta_protocol_1.TaSaid.notice(message)) {
|
|
44
42
|
continue;
|
|
45
43
|
}
|
|
46
|
-
const
|
|
47
|
-
if (said === undefined) {
|
|
48
|
-
continue;
|
|
49
|
-
}
|
|
50
|
-
// A list asks for it every few seconds: only the start of a long reply is read, enough for a preview.
|
|
51
|
-
const read = said.slice(0, PREVIEW_READ);
|
|
52
|
-
const line = plain(withoutFences(read) || read)
|
|
53
|
-
.split('\n')
|
|
54
|
-
.map(part => part
|
|
55
|
-
.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+\.\s+)/, '')
|
|
56
|
-
.replace(/[*`]{1,3}|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, '')
|
|
57
|
-
.trim())
|
|
58
|
-
.filter(Boolean)
|
|
59
|
-
.join(' ')
|
|
60
|
-
.replace(/\s+/g, ' ');
|
|
44
|
+
const line = ta_protocol_1.TaSaid.line(ta_protocol_1.TaSaid.of(message), { chars: LENGTH });
|
|
61
45
|
if (line) {
|
|
62
|
-
return line
|
|
46
|
+
return line;
|
|
63
47
|
}
|
|
64
48
|
}
|
|
65
49
|
return undefined;
|
|
66
50
|
}
|
|
67
51
|
SessionInfoUtil.lastMessage = lastMessage;
|
|
68
|
-
/**
|
|
69
|
-
* The text without its fenced blocks, as a messenger says no more than [code] of them: code, and the cards a
|
|
70
|
-
* reply draws (a card's language, as `ta-glance`), are not what was said.
|
|
71
|
-
*/
|
|
72
|
-
function withoutFences(text) {
|
|
73
|
-
var _a;
|
|
74
|
-
const kept = [];
|
|
75
|
-
let fence;
|
|
76
|
-
for (const line of text.split('\n')) {
|
|
77
|
-
const mark = (_a = /^\s*(`{3,}|~{3,})/.exec(line)) === null || _a === void 0 ? void 0 : _a[1];
|
|
78
|
-
if (!fence && mark) {
|
|
79
|
-
fence = mark;
|
|
80
|
-
}
|
|
81
|
-
else if (fence && mark && mark[0] === fence[0] && mark.length >= fence.length && !line.trim().slice(mark.length)) {
|
|
82
|
-
fence = undefined;
|
|
83
|
-
}
|
|
84
|
-
else if (!fence) {
|
|
85
|
-
kept.push(line);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return kept.join('\n').trim();
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Markdown's pictures and links as a messenger says them: a link by its words, pictures left out of a message that
|
|
92
|
-
* says something else, and by the words that name them in one of pictures only.
|
|
93
|
-
*/
|
|
94
|
-
function plain(text) {
|
|
95
|
-
const linked = text.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
96
|
-
const words = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, '').trim();
|
|
97
|
-
return words || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
98
|
-
}
|
|
99
|
-
/** What the user typed of a message: without its context and pi's notes of images, a skill as `/skill:name` and what follows. */
|
|
100
|
-
function userWords(content) {
|
|
101
|
-
const said = ta_protocol_1.TaImageNote.strip(ta_protocol_1.TaMessageContext.strip(content));
|
|
102
|
-
const skill = ta_protocol_1.TaSkillUse.parse(said);
|
|
103
|
-
return skill ? ta_protocol_1.TaSkillUse.command(skill) : said;
|
|
104
|
-
}
|
|
105
|
-
/** What a message of the user says when it is a note of a task: its title and how it ended; undefined for one the double alone reads. */
|
|
106
|
-
function noteWords(said) {
|
|
107
|
-
const note = ta_protocol_1.TaTaskNote.parse(said);
|
|
108
|
-
if (!note) {
|
|
109
|
-
return said;
|
|
110
|
-
}
|
|
111
|
-
if (note.kind === 'renamed') {
|
|
112
|
-
return undefined;
|
|
113
|
-
}
|
|
114
|
-
return note.kind === 'update' && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
115
|
-
}
|
|
116
52
|
/** The time of the last message that has one, else `fallback`. */
|
|
117
53
|
function updatedAt(messages, fallback) {
|
|
118
54
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -124,19 +60,5 @@ var SessionInfoUtil;
|
|
|
124
60
|
return fallback;
|
|
125
61
|
}
|
|
126
62
|
SessionInfoUtil.updatedAt = updatedAt;
|
|
127
|
-
/** The text of the content of a message. */
|
|
128
|
-
function text(content) {
|
|
129
|
-
if (typeof content === 'string') {
|
|
130
|
-
return content;
|
|
131
|
-
}
|
|
132
|
-
if (!Array.isArray(content)) {
|
|
133
|
-
return '';
|
|
134
|
-
}
|
|
135
|
-
return content
|
|
136
|
-
.filter((part) => (part === null || part === void 0 ? void 0 : part.type) === 'text' && typeof part.text === 'string')
|
|
137
|
-
.map(part => part.text)
|
|
138
|
-
.join('\n');
|
|
139
|
-
}
|
|
140
|
-
SessionInfoUtil.text = text;
|
|
141
63
|
})(SessionInfoUtil || (exports.SessionInfoUtil = SessionInfoUtil = {}));
|
|
142
64
|
//# sourceMappingURL=session-info-util.js.map
|
|
@@ -57,7 +57,7 @@ export declare class TaSettingsStoreImpl implements TaSettingsStore {
|
|
|
57
57
|
trust(): void;
|
|
58
58
|
}>;
|
|
59
59
|
protected read(file: string): Promise<Record<string, unknown>>;
|
|
60
|
-
protected models(): Promise<Pick<TaSettingsSnapshot, 'models' | 'modelNames' | 'providerNames'>>;
|
|
60
|
+
protected models(): Promise<Pick<TaSettingsSnapshot, 'models' | 'agents' | 'modelNames' | 'providerNames'>>;
|
|
61
61
|
protected reloadSessions(scope: TaSettingsScope, cwd: string): Promise<void>;
|
|
62
62
|
}
|
|
63
63
|
export {};
|