@celljs/ta-host 4.16.0 → 4.18.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/app-commands.d.ts +111 -0
- package/esm/node/app-commands.js +646 -0
- package/esm/node/credentials.d.ts +12 -0
- package/esm/node/credentials.js +35 -0
- package/esm/node/delegate-extension.d.ts +11 -0
- package/esm/node/delegate-extension.js +33 -0
- package/esm/node/directory-relocator.d.ts +49 -0
- package/esm/node/directory-relocator.js +267 -0
- package/esm/node/extension-providers.d.ts +16 -1
- package/esm/node/extension-providers.js +23 -3
- package/esm/node/index.d.ts +8 -0
- package/esm/node/index.js +8 -0
- package/esm/node/keep-awake.d.ts +8 -1
- package/esm/node/keep-awake.js +24 -3
- package/esm/node/message-page.d.ts +6 -1
- package/esm/node/message-page.js +50 -2
- package/esm/node/package-hosts.d.ts +8 -0
- package/esm/node/package-hosts.js +41 -0
- package/esm/node/package-webhooks.d.ts +26 -0
- package/esm/node/package-webhooks.js +101 -0
- package/esm/node/page-book.d.ts +48 -0
- package/esm/node/page-book.js +117 -0
- package/esm/node/relay-bridge.d.ts +2 -0
- package/esm/node/relay-bridge.js +35 -1
- package/esm/node/rooms-bridge.d.ts +13 -1
- package/esm/node/rooms-bridge.js +29 -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 -9
- package/esm/node/session-info-util.js +16 -68
- 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.d.ts +5 -1
- package/esm/node/ta-server-impl.js +25 -3
- package/esm/node/ta-session-factory.d.ts +13 -1
- package/esm/node/ta-session-factory.js +41 -4
- package/esm/node/ta-session.d.ts +2 -0
- package/esm/node/ta-session.js +1 -0
- package/esm/node/team/team-calls.js +49 -0
- package/esm/node/voice-bridge.d.ts +70 -0
- package/esm/node/voice-bridge.js +280 -0
- package/esm/node/voices-file.d.ts +38 -0
- package/esm/node/voices-file.js +100 -0
- package/esm/node/working-directory.d.ts +8 -2
- package/esm/node/working-directory.js +7 -0
- package/lib/node/app-commands.d.ts +112 -0
- package/lib/node/app-commands.js +650 -0
- package/lib/node/credentials.d.ts +13 -0
- package/lib/node/credentials.js +38 -0
- package/lib/node/delegate-extension.d.ts +12 -0
- package/lib/node/delegate-extension.js +37 -0
- package/lib/node/directory-relocator.d.ts +50 -0
- package/lib/node/directory-relocator.js +270 -0
- package/lib/node/extension-providers.d.ts +16 -1
- package/lib/node/extension-providers.js +23 -3
- package/lib/node/index.d.ts +8 -0
- package/lib/node/index.js +8 -0
- package/lib/node/keep-awake.d.ts +8 -1
- package/lib/node/keep-awake.js +24 -3
- package/lib/node/message-page.d.ts +6 -1
- package/lib/node/message-page.js +50 -2
- package/lib/node/package-hosts.d.ts +8 -0
- package/lib/node/package-hosts.js +41 -0
- package/lib/node/package-webhooks.d.ts +27 -0
- package/lib/node/package-webhooks.js +104 -0
- package/lib/node/page-book.d.ts +49 -0
- package/lib/node/page-book.js +120 -0
- package/lib/node/relay-bridge.d.ts +2 -0
- package/lib/node/relay-bridge.js +34 -0
- package/lib/node/rooms-bridge.d.ts +13 -1
- package/lib/node/rooms-bridge.js +29 -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 -9
- package/lib/node/session-info-util.js +15 -67
- 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.d.ts +5 -1
- package/lib/node/ta-server-impl.js +24 -2
- package/lib/node/ta-session-factory.d.ts +13 -1
- package/lib/node/ta-session-factory.js +40 -3
- package/lib/node/ta-session.d.ts +2 -0
- package/lib/node/ta-session.js +1 -0
- package/lib/node/team/team-calls.js +49 -0
- package/lib/node/voice-bridge.d.ts +71 -0
- package/lib/node/voice-bridge.js +281 -0
- package/lib/node/voices-file.d.ts +39 -0
- package/lib/node/voices-file.js +104 -0
- package/lib/node/working-directory.d.ts +8 -2
- package/lib/node/working-directory.js +7 -0
- package/package.json +14 -10
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SignInPages = exports.SignInPageUtil = void 0;
|
|
4
4
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
5
|
+
const sign_in_devices_1 = require("./sign-in-devices");
|
|
5
6
|
const sign_in_flow_1 = require("./sign-in-flow");
|
|
6
7
|
/** Ties the browser that comes back from the provider to the one that went: login CSRF. */
|
|
7
8
|
const STATE_COOKIE = 'ta_sign_in';
|
|
@@ -29,6 +30,40 @@ var SignInPageUtil;
|
|
|
29
30
|
return `/#${params.toString()}`;
|
|
30
31
|
}
|
|
31
32
|
SignInPageUtil.back = back;
|
|
33
|
+
/**
|
|
34
|
+
* The page of the web client for the device of `code` (TA_DEVICE_SIGN_IN_PATH): where the user lets it in, and after
|
|
35
|
+
* the provider how it went (`done`: it gets its token; `waiting`: once the account is let in; `failed`).
|
|
36
|
+
*/
|
|
37
|
+
function deviceBack(code, outcome, from) {
|
|
38
|
+
return `/#${new URLSearchParams({ device: code, ...(outcome ? { 'device-sign-in': outcome } : {}), ...(from ? { from } : {}) }).toString()}`;
|
|
39
|
+
}
|
|
40
|
+
SignInPageUtil.deviceBack = deviceBack;
|
|
41
|
+
function json(response, status, body) {
|
|
42
|
+
response.statusCode = status;
|
|
43
|
+
response.setHeader('Content-Type', 'application/json');
|
|
44
|
+
response.end(JSON.stringify(body));
|
|
45
|
+
}
|
|
46
|
+
SignInPageUtil.json = json;
|
|
47
|
+
/** A small JSON body; undefined for one too big or not JSON. */
|
|
48
|
+
async function body(request, max = 4096) {
|
|
49
|
+
const chunks = [];
|
|
50
|
+
let size = 0;
|
|
51
|
+
for await (const chunk of request) {
|
|
52
|
+
size += chunk.length;
|
|
53
|
+
if (size > max) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
chunks.push(chunk);
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
const value = JSON.parse(Buffer.concat(chunks).toString('utf8') || '{}');
|
|
60
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
61
|
+
}
|
|
62
|
+
catch (_a) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
SignInPageUtil.body = body;
|
|
32
67
|
function redirect(response, location) {
|
|
33
68
|
response.statusCode = 302;
|
|
34
69
|
response.setHeader('Location', location);
|
|
@@ -55,10 +90,14 @@ var SignInPages;
|
|
|
55
90
|
}
|
|
56
91
|
SignInPages.matches = matches;
|
|
57
92
|
async function handle(request, response, flow, options) {
|
|
58
|
-
var _a, _b;
|
|
93
|
+
var _a, _b, _c, _d;
|
|
59
94
|
const url = new URL((_a = request.url) !== null && _a !== void 0 ? _a : '/', 'http://localhost');
|
|
60
95
|
response.setHeader('Cache-Control', 'no-store');
|
|
61
96
|
response.setHeader('Referrer-Policy', 'no-referrer');
|
|
97
|
+
if (url.pathname === ta_protocol_1.TA_DEVICE_SIGN_IN_PATH || url.pathname.startsWith(`${ta_protocol_1.TA_DEVICE_SIGN_IN_PATH}/`)) {
|
|
98
|
+
await device(request, response, flow, url, options);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
62
101
|
if (request.method !== 'GET' && request.method !== 'HEAD') {
|
|
63
102
|
response.setHeader('Allow', 'GET, HEAD');
|
|
64
103
|
SignInPageUtil.end(response, 405);
|
|
@@ -66,33 +105,56 @@ var SignInPages;
|
|
|
66
105
|
}
|
|
67
106
|
const [providerId, step, ...rest] = url.pathname.slice(ta_protocol_1.TA_SIGN_IN_PATH.length + 1).split('/');
|
|
68
107
|
if (!providerId) {
|
|
69
|
-
const ways = {
|
|
108
|
+
const ways = {
|
|
109
|
+
providers: [
|
|
110
|
+
...flow.providers.map(({ id, name }) => ({ id, name })),
|
|
111
|
+
...flow.polled.map(({ id, name }) => ({ id, name, polled: true })),
|
|
112
|
+
],
|
|
113
|
+
};
|
|
70
114
|
response.setHeader('Content-Type', 'application/json');
|
|
115
|
+
// Which ways there are is no secret: the app and Ta Desktop, of another origin, offer them on their sign-in.
|
|
116
|
+
response.setHeader('Access-Control-Allow-Origin', '*');
|
|
71
117
|
SignInPageUtil.end(response, 200, JSON.stringify(ways));
|
|
72
118
|
return;
|
|
73
119
|
}
|
|
120
|
+
const polled = flow.polled.some(one => one.id === providerId);
|
|
121
|
+
if (polled && !step && rest.length === 0) {
|
|
122
|
+
await goPolled(response, flow, providerId, (_b = url.searchParams.get('device')) !== null && _b !== void 0 ? _b : '', options);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
74
125
|
if (!flow.provider(providerId) || rest.length > 0 || (step && step !== 'callback')) {
|
|
75
126
|
SignInPageUtil.end(response, 404);
|
|
76
127
|
return;
|
|
77
128
|
}
|
|
78
129
|
if (!step) {
|
|
79
|
-
await go(request, response, flow, providerId, (
|
|
130
|
+
await go(request, response, flow, providerId, (_c = url.searchParams.get('bind')) !== null && _c !== void 0 ? _c : undefined, options, (_d = url.searchParams.get('device')) !== null && _d !== void 0 ? _d : undefined);
|
|
80
131
|
return;
|
|
81
132
|
}
|
|
82
133
|
await back(request, response, flow, providerId, url.searchParams, options);
|
|
83
134
|
}
|
|
84
135
|
SignInPages.handle = handle;
|
|
85
|
-
async function go(request, response, flow, providerId, bind, options) {
|
|
136
|
+
async function go(request, response, flow, providerId, bind, options, device) {
|
|
86
137
|
const origin = sign_in_flow_1.SignInUtil.origin(request, flow.publicUrl);
|
|
87
138
|
try {
|
|
88
|
-
const { url, state } = await flow.start(providerId, origin, bind);
|
|
139
|
+
const { url, state } = await flow.start(providerId, origin, bind, Date.now(), device === undefined ? undefined : sign_in_devices_1.SignInDevicesUtil.normalize(device));
|
|
89
140
|
const secure = origin.startsWith('https:') ? '; Secure' : '';
|
|
90
141
|
response.setHeader('Set-Cookie', `${STATE_COOKIE}=${state}; Path=${ta_protocol_1.TA_SIGN_IN_PATH}; Max-Age=600; HttpOnly; SameSite=Lax${secure}`);
|
|
91
142
|
SignInPageUtil.redirect(response, url);
|
|
92
143
|
}
|
|
93
144
|
catch (error) {
|
|
94
145
|
console.warn(`${options.name}: signing in with ${providerId} failed: ${error instanceof Error ? error.message : error}`);
|
|
95
|
-
SignInPageUtil.redirect(response, SignInPageUtil.back({ outcome: 'failed' }));
|
|
146
|
+
SignInPageUtil.redirect(response, device === undefined ? SignInPageUtil.back({ outcome: 'failed' }) : SignInPageUtil.deviceBack(sign_in_devices_1.SignInDevicesUtil.normalize(device), 'failed'));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** To a polled provider for the device of `code`; Ta asks it who agreed. Only for a device: a browser does not come back. */
|
|
150
|
+
async function goPolled(response, flow, providerId, given, options) {
|
|
151
|
+
const code = sign_in_devices_1.SignInDevicesUtil.normalize(given);
|
|
152
|
+
try {
|
|
153
|
+
SignInPageUtil.redirect(response, await flow.startPolled(providerId, code));
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
console.warn(`${options.name}: signing in with ${providerId} failed: ${error instanceof Error ? error.message : error}`);
|
|
157
|
+
SignInPageUtil.redirect(response, SignInPageUtil.deviceBack(code, 'failed'));
|
|
96
158
|
}
|
|
97
159
|
}
|
|
98
160
|
async function back(request, response, flow, providerId, params, options) {
|
|
@@ -108,7 +170,11 @@ var SignInPages;
|
|
|
108
170
|
}
|
|
109
171
|
try {
|
|
110
172
|
const result = await flow.finish(providerId, state, code, request.headers['user-agent']);
|
|
111
|
-
if ('
|
|
173
|
+
if ('device' in result) {
|
|
174
|
+
console.log(`${options.name}: ${result.account.id} signed in for a device${result.allowed ? '' : ', which waits for the account to be let in'}`);
|
|
175
|
+
SignInPageUtil.redirect(response, SignInPageUtil.deviceBack(result.device, result.allowed ? 'done' : 'waiting'));
|
|
176
|
+
}
|
|
177
|
+
else if ('token' in result) {
|
|
112
178
|
console.log(`${options.name}: ${result.account.id} signed in`);
|
|
113
179
|
await ((_a = options.onSignedIn) === null || _a === void 0 ? void 0 : _a.call(options, response, result.token, result.account, sign_in_flow_1.SignInUtil.origin(request, flow.publicUrl)));
|
|
114
180
|
SignInPageUtil.redirect(response, SignInPageUtil.back({ token: result.token }));
|
|
@@ -124,4 +190,67 @@ var SignInPages;
|
|
|
124
190
|
}
|
|
125
191
|
}
|
|
126
192
|
})(SignInPages || (exports.SignInPages = SignInPages = {}));
|
|
193
|
+
/** Answers any origin: what these give goes to who holds the secret of the device, and no cookie is read. */
|
|
194
|
+
const DEVICE_CORS = {
|
|
195
|
+
'Access-Control-Allow-Origin': '*',
|
|
196
|
+
'Access-Control-Allow-Methods': 'POST, OPTIONS',
|
|
197
|
+
'Access-Control-Allow-Headers': 'Content-Type',
|
|
198
|
+
'Access-Control-Max-Age': '600',
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
201
|
+
* TA_DEVICE_SIGN_IN_PATH: `POST` asks for a code, `POST /poll` takes the token once the user let the device in, from any
|
|
202
|
+
* origin; `GET ?code=` is where the user goes, the page of the web client; `POST /approve`, with the token of a browser
|
|
203
|
+
* signed in here, lets the device in as its account, with no provider (a sign-in by `ta gateway link` has none).
|
|
204
|
+
*/
|
|
205
|
+
async function device(request, response, flow, url, options) {
|
|
206
|
+
var _a;
|
|
207
|
+
const step = url.pathname.slice(ta_protocol_1.TA_DEVICE_SIGN_IN_PATH.length);
|
|
208
|
+
if (step !== '/approve') {
|
|
209
|
+
for (const [name, value] of Object.entries(DEVICE_CORS)) {
|
|
210
|
+
response.setHeader(name, value);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
if (request.method === 'OPTIONS') {
|
|
214
|
+
SignInPageUtil.end(response, 204);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (step === '' && request.method === 'GET') {
|
|
218
|
+
const code = sign_in_devices_1.SignInDevicesUtil.normalize((_a = url.searchParams.get('code')) !== null && _a !== void 0 ? _a : '');
|
|
219
|
+
SignInPageUtil.redirect(response, SignInPageUtil.deviceBack(code, undefined, flow.devices.name(code)));
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (request.method !== 'POST' || !['', '/poll', '/approve'].includes(step)) {
|
|
223
|
+
SignInPageUtil.end(response, step === '' || step === '/poll' || step === '/approve' ? 405 : 404);
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const body = await SignInPageUtil.body(request);
|
|
227
|
+
if (!body) {
|
|
228
|
+
SignInPageUtil.end(response, 400);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (step === '') {
|
|
232
|
+
const started = flow.devices.start(typeof body.name === 'string' ? body.name : undefined);
|
|
233
|
+
const origin = sign_in_flow_1.SignInUtil.origin(request, flow.publicUrl);
|
|
234
|
+
const answer = { ...started, url: `${origin}${ta_protocol_1.TA_DEVICE_SIGN_IN_PATH}?code=${started.code}`, interval: sign_in_devices_1.DEVICE_POLL_MS };
|
|
235
|
+
SignInPageUtil.json(response, 200, answer);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (step === '/poll') {
|
|
239
|
+
const state = flow.devices.poll(typeof body.device === 'string' ? body.device : '');
|
|
240
|
+
if (state.status === 'done') {
|
|
241
|
+
console.log(`${options.name}: ${state.account} signed in on a device`);
|
|
242
|
+
}
|
|
243
|
+
SignInPageUtil.json(response, 200, state);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const header = request.headers.authorization;
|
|
247
|
+
const signIn = (header === null || header === void 0 ? void 0 : header.startsWith('Bearer ')) ? flow.store.check(header.slice('Bearer '.length)) : undefined;
|
|
248
|
+
if (!signIn) {
|
|
249
|
+
SignInPageUtil.end(response, 401);
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const code = typeof body.code === 'string' ? body.code : '';
|
|
253
|
+
const ok = flow.devices.signedIn(code, { id: signIn.account, name: signIn.name, avatar: signIn.avatar });
|
|
254
|
+
SignInPageUtil.json(response, ok ? 200 : 404, { ok });
|
|
255
|
+
}
|
|
127
256
|
//# sourceMappingURL=sign-in-pages.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { TaSignInKind, TaSignInProvider, TaSignInSetup } from '@celljs/ta-protocol';
|
|
2
|
+
import { type PolledSignInProvider } from './polled-sign-in';
|
|
2
3
|
/** Who signed in, as the provider says: `id` is the account as TA_ALLOWED_USERS names it (`github:<login>`). */
|
|
3
4
|
export interface SignInAccount {
|
|
4
5
|
id: string;
|
|
@@ -209,6 +210,11 @@ export declare namespace SignInProviders {
|
|
|
209
210
|
* one's own with its device flow on; by default Ta's own, on GitHub.com.
|
|
210
211
|
*/
|
|
211
212
|
function device(env: Record<string, string | undefined>): DeviceSignInProvider | undefined;
|
|
213
|
+
/**
|
|
214
|
+
* The polled providers of the environment (PushedSignIn): `TA_IAM_ISSUER` and `TA_IAM_CLIENT_ID`, a company's sign-in
|
|
215
|
+
* for CLIs, whose accounts are `iam:<sub>`; `TA_IAM_CLI_ID` and `TA_IAM_NAME` (what its button says) optional.
|
|
216
|
+
*/
|
|
217
|
+
function polled(env: Record<string, string | undefined>): PolledSignInProvider[];
|
|
212
218
|
/**
|
|
213
219
|
* The providers the operator configured in the environment of ta serve: a provider is offered when it
|
|
214
220
|
* has its id and its secret.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SignInProviders = exports.WeChatSignIn = exports.OidcSignIn = exports.GitHubDeviceSignIn = exports.GitHubSignIn = exports.SignInHttp = exports.SignInError = void 0;
|
|
4
|
+
const polled_sign_in_1 = require("./polled-sign-in");
|
|
4
5
|
/** A sign-in that failed with the provider (a code refused, an account without what it needs). */
|
|
5
6
|
class SignInError extends Error {
|
|
6
7
|
}
|
|
@@ -390,6 +391,20 @@ var SignInProviders;
|
|
|
390
391
|
return new GitHubDeviceSignIn(clientId || GitHubDeviceSignIn.CLIENT_ID, GitHubSignIn.endpoints(url || undefined));
|
|
391
392
|
}
|
|
392
393
|
SignInProviders.device = device;
|
|
394
|
+
/**
|
|
395
|
+
* The polled providers of the environment (PushedSignIn): `TA_IAM_ISSUER` and `TA_IAM_CLIENT_ID`, a company's sign-in
|
|
396
|
+
* for CLIs, whose accounts are `iam:<sub>`; `TA_IAM_CLI_ID` and `TA_IAM_NAME` (what its button says) optional.
|
|
397
|
+
*/
|
|
398
|
+
function polled(env) {
|
|
399
|
+
var _a, _b, _c, _d;
|
|
400
|
+
const issuer = (_a = env.TA_IAM_ISSUER) === null || _a === void 0 ? void 0 : _a.trim();
|
|
401
|
+
const clientId = (_b = env.TA_IAM_CLIENT_ID) === null || _b === void 0 ? void 0 : _b.trim();
|
|
402
|
+
if (!issuer || !clientId) {
|
|
403
|
+
return [];
|
|
404
|
+
}
|
|
405
|
+
return [new polled_sign_in_1.PushedSignIn({ id: 'iam', name: ((_c = env.TA_IAM_NAME) === null || _c === void 0 ? void 0 : _c.trim()) || 'SSO', issuer, clientId, cliId: ((_d = env.TA_IAM_CLI_ID) === null || _d === void 0 ? void 0 : _d.trim()) || undefined })];
|
|
406
|
+
}
|
|
407
|
+
SignInProviders.polled = polled;
|
|
393
408
|
/**
|
|
394
409
|
* The providers the operator configured in the environment of ta serve: a provider is offered when it
|
|
395
410
|
* has its id and its secret.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ExtensionAPI, TaExtension } from '@celljs/ta-harness';
|
|
2
|
+
/**
|
|
3
|
+
* Tells the model of every session who wrote a message (docs/design/ta-sources.md): the user, a part of Ta for them
|
|
4
|
+
* (`[ta:from …]`), or a notice of a part of Ta (`[ta:notice …]`), which it weighs below what the user said. A section
|
|
5
|
+
* of pi's system prompt of its own (`<ta-sources>`), which other coding agents get with Ta's other notes.
|
|
6
|
+
*/
|
|
7
|
+
export declare class SourcesExtension implements TaExtension {
|
|
8
|
+
readonly name = "ta-sources";
|
|
9
|
+
register(pi: ExtensionAPI): void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=sources-extension.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SourcesExtension = void 0;
|
|
4
|
+
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
5
|
+
/**
|
|
6
|
+
* Tells the model of every session who wrote a message (docs/design/ta-sources.md): the user, a part of Ta for them
|
|
7
|
+
* (`[ta:from …]`), or a notice of a part of Ta (`[ta:notice …]`), which it weighs below what the user said. A section
|
|
8
|
+
* of pi's system prompt of its own (`<ta-sources>`), which other coding agents get with Ta's other notes.
|
|
9
|
+
*/
|
|
10
|
+
class SourcesExtension {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.name = 'ta-sources';
|
|
13
|
+
}
|
|
14
|
+
register(pi) {
|
|
15
|
+
pi.on('before_agent_start', event => {
|
|
16
|
+
const options = event.systemPromptOptions;
|
|
17
|
+
options.sections = { ...options.sections, [ta_protocol_1.TaMessageSource.SECTION]: ta_protocol_1.TaMessageSource.PROMPT };
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.SourcesExtension = SourcesExtension;
|
|
22
|
+
//# sourceMappingURL=sources-extension.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
2
|
-
import { type ImageContent, type RpcExtensionUIResponse, type TaAttachOptions, type TaAttachResult, type TaClientToolResult, type TaCommandResult, type TaForkFileResult, type TaMessagePage, type TaNavigateResult, type TaOpenedSession, type TaOpenSessionOptions, type TaPromptInput, type TaPromptReceipt, type TaSavedSessionInfo, type TaSavedSessionQuery, TaServer, type TaServerInfo, type TaSessionInfo, type TaSlashCommand, type ThinkingLevel } from '@celljs/ta-protocol';
|
|
2
|
+
import { type ImageContent, type RpcExtensionUIResponse, type TaAttachOptions, type TaAttachResult, type TaClientToolResult, type TaCommandResult, type TaForkFileResult, type TaMessagePage, type TaNavigateResult, type TaOpenedSession, type TaOpenSessionOptions, type TaPromptInput, type TaPromptReceipt, type TaRelocateResult, type TaSavedSessionInfo, type TaSavedSessionQuery, TaServer, type TaServerInfo, type TaSessionInfo, type TaSlashCommand, type ThinkingLevel } from '@celljs/ta-protocol';
|
|
3
|
+
import { TaDirectoryRelocator } from './directory-relocator';
|
|
3
4
|
import { TaSessionCatalog, TaSessionFactory, TaSessionRegistry } from './host-protocol';
|
|
4
5
|
import { TaServeUpdates } from './serve-updates';
|
|
5
6
|
import type { TaSession } from './ta-session';
|
|
@@ -21,6 +22,7 @@ export declare class TaServerImpl implements TaServer {
|
|
|
21
22
|
protected readonly authority: TaAuthority;
|
|
22
23
|
protected readonly visibility: TaVisibility;
|
|
23
24
|
protected readonly updates: TaServeUpdates;
|
|
25
|
+
protected readonly relocator: TaDirectoryRelocator;
|
|
24
26
|
getServerInfo(): Promise<TaServerInfo>;
|
|
25
27
|
restartServer(): Promise<void>;
|
|
26
28
|
setWorkingDirectory(cwd: string): Promise<TaServerInfo>;
|
|
@@ -73,6 +75,8 @@ export declare class TaServerImpl implements TaServer {
|
|
|
73
75
|
switchSession(sessionId: string, sessionPath: string): Promise<TaCommandResult<'switch_session'>>;
|
|
74
76
|
fork(sessionId: string, entryId: string, position?: 'before' | 'at'): Promise<TaCommandResult<'fork'>>;
|
|
75
77
|
forkToFile(sessionId: string, entryId: string, position?: 'before' | 'at'): Promise<TaForkFileResult>;
|
|
78
|
+
forkHere(sessionId: string): Promise<TaForkFileResult>;
|
|
79
|
+
relocateDirectory(from: string, to: string): Promise<TaRelocateResult>;
|
|
76
80
|
clone(sessionId: string): Promise<TaCommandResult<'clone'>>;
|
|
77
81
|
getForkMessages(sessionId: string): Promise<TaCommandResult<'get_fork_messages'>>;
|
|
78
82
|
getEntries(sessionId: string, since?: string): Promise<TaCommandResult<'get_entries'>>;
|
|
@@ -19,9 +19,9 @@ const node_1 = require("@celljs/rpc/lib/node");
|
|
|
19
19
|
const ta_exec_1 = require("@celljs/ta-exec");
|
|
20
20
|
const serve_restart_1 = require("@celljs/ta-harness/lib/node/serve-restart");
|
|
21
21
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
22
|
+
const directory_relocator_1 = require("./directory-relocator");
|
|
22
23
|
const host_protocol_1 = require("./host-protocol");
|
|
23
24
|
const serve_updates_1 = require("./serve-updates");
|
|
24
|
-
const session_info_util_1 = require("./session-info-util");
|
|
25
25
|
const slash_command_util_1 = require("./slash-command-util");
|
|
26
26
|
const ta_errors_1 = require("./ta-errors");
|
|
27
27
|
const team_protocol_1 = require("./team/team-protocol");
|
|
@@ -304,7 +304,8 @@ let TaServerImpl = class TaServerImpl {
|
|
|
304
304
|
if (!entry || (position === 'before' && !user)) {
|
|
305
305
|
throw ta_errors_1.TaErrors.invalidArgument(`No entry to fork from has the id ${entryId}.`, 'Pass the id of a message of the user, or position "at".');
|
|
306
306
|
}
|
|
307
|
-
|
|
307
|
+
// What the user typed, to edit again: the marks of the model are made again when it is sent.
|
|
308
|
+
const text = position === 'before' && user ? ta_protocol_1.TaSaid.of(user) : undefined;
|
|
308
309
|
const leafId = position === 'before' ? entry.parentId : entry.id;
|
|
309
310
|
const file = manager.getSessionFile();
|
|
310
311
|
if (!leafId || !file || !(0, node_fs_1.existsSync)(file)) {
|
|
@@ -318,6 +319,23 @@ let TaServerImpl = class TaServerImpl {
|
|
|
318
319
|
return { sessionFile, text };
|
|
319
320
|
});
|
|
320
321
|
}
|
|
322
|
+
forkHere(sessionId) {
|
|
323
|
+
return this.on(sessionId, async ({ pi }) => {
|
|
324
|
+
var _a;
|
|
325
|
+
var _b;
|
|
326
|
+
const file = pi.sessionManager.getSessionFile();
|
|
327
|
+
if (!file || !(0, node_fs_1.existsSync)(file)) {
|
|
328
|
+
return {};
|
|
329
|
+
}
|
|
330
|
+
const sdk = await ai_coding_agent_1.PiSdkUtil.load();
|
|
331
|
+
const sessionFile = sdk.SessionManager.forkFrom(file, pi.sessionManager.getCwd()).getSessionFile();
|
|
332
|
+
this.runs.created(sessionFile, (_b = (_a = this.sessions.locate(sessionId)) === null || _a === void 0 ? void 0 : _a.cwd) !== null && _b !== void 0 ? _b : '');
|
|
333
|
+
return { sessionFile };
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
relocateDirectory(from, to) {
|
|
337
|
+
return this.guard(() => this.relocator.relocate(from, to));
|
|
338
|
+
}
|
|
321
339
|
clone(sessionId) {
|
|
322
340
|
return this.authored(sessionId, async ({ pi, runtime }) => {
|
|
323
341
|
const leafId = pi.sessionManager.getLeafId();
|
|
@@ -439,6 +457,10 @@ __decorate([
|
|
|
439
457
|
(0, core_1.Autowired)(serve_updates_1.TaServeUpdates),
|
|
440
458
|
__metadata("design:type", Object)
|
|
441
459
|
], TaServerImpl.prototype, "updates", void 0);
|
|
460
|
+
__decorate([
|
|
461
|
+
(0, core_1.Autowired)(directory_relocator_1.TaDirectoryRelocator),
|
|
462
|
+
__metadata("design:type", Object)
|
|
463
|
+
], TaServerImpl.prototype, "relocator", void 0);
|
|
442
464
|
exports.TaServerImpl = TaServerImpl = __decorate([
|
|
443
465
|
(0, rpc_1.Rpc)(ta_protocol_1.TaServer)
|
|
444
466
|
], TaServerImpl);
|
|
@@ -7,6 +7,7 @@ import { type TaHostOptions, TaSessionFactory } from './host-protocol';
|
|
|
7
7
|
import { PackageHosts } from './package-hosts';
|
|
8
8
|
import { PiDirectories } from './remote/remote-protocol';
|
|
9
9
|
import { TaSession } from './ta-session';
|
|
10
|
+
import { TaWorkingDirectory } from './working-directory';
|
|
10
11
|
type AgentsFilesOverride = (base: {
|
|
11
12
|
agentsFiles: ContextFile[];
|
|
12
13
|
}) => {
|
|
@@ -20,6 +21,8 @@ export declare namespace SessionFileUtil {
|
|
|
20
21
|
* not there, and pi would take the directory ta serve runs in, the home directory under the desktop app.
|
|
21
22
|
*/
|
|
22
23
|
function cwdOverride(sessionFile: string, cwd: string): string | undefined;
|
|
24
|
+
/** `path` when it is a directory there now. */
|
|
25
|
+
function existing(path: string | undefined): string | undefined;
|
|
23
26
|
}
|
|
24
27
|
type ModelRuntime = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).ModelRuntime;
|
|
25
28
|
type AgentSessionServices = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).AgentSessionServices;
|
|
@@ -43,6 +46,7 @@ export declare class DefaultTaSessionFactory implements TaSessionFactory {
|
|
|
43
46
|
protected readonly tools: AgentTool[];
|
|
44
47
|
protected readonly packageHosts: PackageHosts;
|
|
45
48
|
protected readonly directories: PiDirectories;
|
|
49
|
+
protected readonly workingDirectory?: TaWorkingDirectory;
|
|
46
50
|
protected readonly extensionProviders: ExtensionProviders;
|
|
47
51
|
create(requested: TaOpenSessionOptions, requestClose: (session: TaSession, idle?: boolean) => void, id?: string): Promise<TaSession>;
|
|
48
52
|
commands(cwd: string): Promise<TaSlashCommand[]>;
|
|
@@ -51,7 +55,15 @@ export declare class DefaultTaSessionFactory implements TaSessionFactory {
|
|
|
51
55
|
* those of Ta. `commandsOnly`: for what a session would have, the context files of another machine not read.
|
|
52
56
|
*/
|
|
53
57
|
protected services(sdk: PiSdk, options: ServicesOptions): Promise<AgentSessionServices>;
|
|
54
|
-
|
|
58
|
+
/**
|
|
59
|
+
* pi's manager of the session file asked, or of a new one. A file whose directory is no longer there goes on
|
|
60
|
+
* in the directory of the server (TaWorkingDirectory), else the home directory, as pi's Continue: `movedFrom`, the directory as
|
|
61
|
+
* the file says it.
|
|
62
|
+
*/
|
|
63
|
+
protected openSessionManager(sdk: PiSdk, options: TaOpenSessionOptions): {
|
|
64
|
+
sessionManager: SessionManager;
|
|
65
|
+
movedFrom?: string;
|
|
66
|
+
};
|
|
55
67
|
/**
|
|
56
68
|
* For another machine, its context files (AGENTS.md...) instead of those pi finds above the directory
|
|
57
69
|
* of this machine it works in; the user's own, in the agent directory, stay.
|
|
@@ -11,12 +11,14 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.DefaultTaSessionFactory = exports.SessionFileUtil = void 0;
|
|
13
13
|
const node_fs_1 = require("node:fs");
|
|
14
|
+
const node_os_1 = require("node:os");
|
|
14
15
|
const node_path_1 = require("node:path");
|
|
15
16
|
const ai_coding_agent_1 = require("@celljs/ai-coding-agent");
|
|
16
17
|
const core_1 = require("@celljs/core");
|
|
17
18
|
const ta_exec_1 = require("@celljs/ta-exec");
|
|
18
19
|
const ta_harness_1 = require("@celljs/ta-harness");
|
|
19
20
|
const client_tool_broker_1 = require("./client-tool-broker");
|
|
21
|
+
const delegate_extension_1 = require("./delegate-extension");
|
|
20
22
|
const extension_providers_1 = require("./extension-providers");
|
|
21
23
|
const host_protocol_1 = require("./host-protocol");
|
|
22
24
|
const package_host_extension_1 = require("./package-host-extension");
|
|
@@ -25,8 +27,10 @@ const remote_protocol_1 = require("./remote/remote-protocol");
|
|
|
25
27
|
const session_catalog_1 = require("./session-catalog");
|
|
26
28
|
const session_files_1 = require("./session-files");
|
|
27
29
|
const slash_command_util_1 = require("./slash-command-util");
|
|
30
|
+
const sources_extension_1 = require("./sources-extension");
|
|
28
31
|
const ta_errors_1 = require("./ta-errors");
|
|
29
32
|
const ta_session_1 = require("./ta-session");
|
|
33
|
+
const working_directory_1 = require("./working-directory");
|
|
30
34
|
var SessionFileUtil;
|
|
31
35
|
(function (SessionFileUtil) {
|
|
32
36
|
/**
|
|
@@ -44,6 +48,16 @@ var SessionFileUtil;
|
|
|
44
48
|
}
|
|
45
49
|
}
|
|
46
50
|
SessionFileUtil.cwdOverride = cwdOverride;
|
|
51
|
+
/** `path` when it is a directory there now. */
|
|
52
|
+
function existing(path) {
|
|
53
|
+
try {
|
|
54
|
+
return path && (0, node_fs_1.statSync)(path).isDirectory() ? path : undefined;
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
SessionFileUtil.existing = existing;
|
|
47
61
|
})(SessionFileUtil || (exports.SessionFileUtil = SessionFileUtil = {}));
|
|
48
62
|
/** Sets up pi for each session the way its command does, with one model runtime for all of them. */
|
|
49
63
|
let DefaultTaSessionFactory = class DefaultTaSessionFactory {
|
|
@@ -60,7 +74,7 @@ let DefaultTaSessionFactory = class DefaultTaSessionFactory {
|
|
|
60
74
|
const modelRuntime = await this.modelRuntimeProvider.provide();
|
|
61
75
|
// `options.cwd` is a location; pi works in a directory of this machine (PiDirectories). A session
|
|
62
76
|
// file works where its header says, as pi's `--session` does, whatever `cwd` the caller gave.
|
|
63
|
-
const sessionManager = this.openSessionManager(sdk, { ...requested, cwd: this.directories.toPi(requested.cwd) });
|
|
77
|
+
const { sessionManager, movedFrom } = this.openSessionManager(sdk, { ...requested, cwd: this.directories.toPi(requested.cwd) });
|
|
64
78
|
// Opened again from its file without its role or group (a package relaying a message to it, the list of
|
|
65
79
|
// conversations): those it was opened with before.
|
|
66
80
|
const entries = requested.sessionFile ? sessionManager.getEntries() : [];
|
|
@@ -104,6 +118,7 @@ let DefaultTaSessionFactory = class DefaultTaSessionFactory {
|
|
|
104
118
|
group: options.group,
|
|
105
119
|
role: options.appendSystemPrompt,
|
|
106
120
|
locate: cwd => this.directories.fromPi(cwd),
|
|
121
|
+
movedFrom,
|
|
107
122
|
});
|
|
108
123
|
await session.start();
|
|
109
124
|
return session;
|
|
@@ -156,12 +171,27 @@ let DefaultTaSessionFactory = class DefaultTaSessionFactory {
|
|
|
156
171
|
},
|
|
157
172
|
});
|
|
158
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* pi's manager of the session file asked, or of a new one. A file whose directory is no longer there goes on
|
|
176
|
+
* in the directory of the server (TaWorkingDirectory), else the home directory, as pi's Continue: `movedFrom`, the directory as
|
|
177
|
+
* the file says it.
|
|
178
|
+
*/
|
|
159
179
|
openSessionManager(sdk, options) {
|
|
180
|
+
var _a, _b;
|
|
181
|
+
var _c;
|
|
160
182
|
if (!options.sessionFile) {
|
|
161
|
-
return sdk.SessionManager.create(options.cwd);
|
|
183
|
+
return { sessionManager: sdk.SessionManager.create(options.cwd) };
|
|
162
184
|
}
|
|
163
185
|
try {
|
|
164
|
-
|
|
186
|
+
const sessionManager = sdk.SessionManager.open(options.sessionFile, undefined, SessionFileUtil.cwdOverride(options.sessionFile, options.cwd));
|
|
187
|
+
const cwd = sessionManager.getCwd();
|
|
188
|
+
if ((0, node_fs_1.existsSync)(cwd)) {
|
|
189
|
+
return { sessionManager };
|
|
190
|
+
}
|
|
191
|
+
const here = (_c = SessionFileUtil.existing((_a = this.workingDirectory) === null || _a === void 0 ? void 0 : _a.get())) !== null && _c !== void 0 ? _c : (0, node_os_1.homedir)();
|
|
192
|
+
// As its file says it: pi resolves a path of another system (C:\...) against the directory of ta serve.
|
|
193
|
+
const movedFrom = ((_b = sessionManager.getHeader()) === null || _b === void 0 ? void 0 : _b.cwd) || cwd;
|
|
194
|
+
return { sessionManager: sdk.SessionManager.open(options.sessionFile, undefined, here), movedFrom };
|
|
165
195
|
}
|
|
166
196
|
catch (error) {
|
|
167
197
|
throw ta_errors_1.TaErrors.invalidArgument(`Cannot open the session ${options.sessionFile}: ${error.message}`, 'Pass a session file that exists; listSessions shows the open ones.');
|
|
@@ -185,6 +215,8 @@ let DefaultTaSessionFactory = class DefaultTaSessionFactory {
|
|
|
185
215
|
new ta_harness_1.SessionLockExtension(lock),
|
|
186
216
|
new package_host_extension_1.PackageHostExtension(this.packageHosts, new session_files_1.ExecSessionFiles(environment, piCwd)),
|
|
187
217
|
new ta_harness_1.BrandExtension(sdk),
|
|
218
|
+
new delegate_extension_1.DelegateExtension(),
|
|
219
|
+
new sources_extension_1.SourcesExtension(),
|
|
188
220
|
...(environment.local ? [] : [new ta_harness_1.ExecExtension(environment, sdk, piCwd)]),
|
|
189
221
|
];
|
|
190
222
|
return [
|
|
@@ -262,6 +294,11 @@ __decorate([
|
|
|
262
294
|
(0, core_1.Autowired)(remote_protocol_1.PiDirectories),
|
|
263
295
|
__metadata("design:type", Object)
|
|
264
296
|
], DefaultTaSessionFactory.prototype, "directories", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
(0, core_1.Autowired)(working_directory_1.TaWorkingDirectory),
|
|
299
|
+
(0, core_1.Optional)(),
|
|
300
|
+
__metadata("design:type", Object)
|
|
301
|
+
], DefaultTaSessionFactory.prototype, "workingDirectory", void 0);
|
|
265
302
|
__decorate([
|
|
266
303
|
(0, core_1.Autowired)(extension_providers_1.ExtensionProviders),
|
|
267
304
|
__metadata("design:type", Object)
|
package/lib/node/ta-session.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export interface TaSessionContext {
|
|
|
26
26
|
role?: string;
|
|
27
27
|
/** The location of the directory pi works in (PiDirectories.fromPi); default: that directory. */
|
|
28
28
|
locate?(cwd: string): string;
|
|
29
|
+
/** The directory its file says, no longer there: it works in another (TaSessionInfo.movedFrom). */
|
|
30
|
+
movedFrom?: string;
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
31
33
|
* One open session of `ta serve`: pi's runtime, its event log, and the clients attached to it. Its id
|
package/lib/node/ta-session.js
CHANGED
|
@@ -69,6 +69,7 @@ class TaSession {
|
|
|
69
69
|
sessionName: pi.sessionName,
|
|
70
70
|
firstMessage: session_info_util_1.SessionInfoUtil.firstMessage(pi.messages),
|
|
71
71
|
lastMessage: session_info_util_1.SessionInfoUtil.lastMessage(pi.messages),
|
|
72
|
+
movedFrom: this.context.movedFrom,
|
|
72
73
|
model: model ? `${model.provider}/${model.id}` : undefined,
|
|
73
74
|
isStreaming: pi.isStreaming,
|
|
74
75
|
waiting: this.ui.pendingRequests.length > 0,
|
|
@@ -108,6 +108,8 @@ const RULES = {
|
|
|
108
108
|
switchSession: session('chat.manage'),
|
|
109
109
|
fork: session('chat.create'),
|
|
110
110
|
forkToFile: session('chat.create'),
|
|
111
|
+
forkHere: session('chat.create'),
|
|
112
|
+
relocateDirectory: owner,
|
|
111
113
|
clone: session('chat.create'),
|
|
112
114
|
getForkMessages: session('chat.view'),
|
|
113
115
|
getEntries: session('chat.view'),
|
|
@@ -185,6 +187,8 @@ const RULES = {
|
|
|
185
187
|
addStore: fixed('settings.manage'),
|
|
186
188
|
removeRelay: fixed('settings.manage'),
|
|
187
189
|
chooseRelay: fixed('settings.manage'),
|
|
190
|
+
joinDeployment: fixed('settings.manage'),
|
|
191
|
+
leaveDeployment: fixed('settings.manage'),
|
|
188
192
|
probeRelay: fixed('settings.view'),
|
|
189
193
|
sharePackage: fixed('extensions.install'),
|
|
190
194
|
unsharePackage: fixed('extensions.install'),
|
|
@@ -200,6 +204,7 @@ const RULES = {
|
|
|
200
204
|
'listRooms',
|
|
201
205
|
'createRoom',
|
|
202
206
|
'invite',
|
|
207
|
+
'configureRoom',
|
|
203
208
|
'join',
|
|
204
209
|
'listRequests',
|
|
205
210
|
'answer',
|
|
@@ -212,6 +217,12 @@ const RULES = {
|
|
|
212
217
|
'friendLink',
|
|
213
218
|
'addFriend',
|
|
214
219
|
'offerFriend',
|
|
220
|
+
'inviteFriends',
|
|
221
|
+
'listGroupInvites',
|
|
222
|
+
'answerGroupInvite',
|
|
223
|
+
'sendToFriends',
|
|
224
|
+
'listFriendShares',
|
|
225
|
+
'answerFriendShare',
|
|
215
226
|
'listFriendRequests',
|
|
216
227
|
'answerFriend',
|
|
217
228
|
'removeFriend',
|
|
@@ -219,10 +230,28 @@ const RULES = {
|
|
|
219
230
|
'watch',
|
|
220
231
|
'unwatch',
|
|
221
232
|
].map(method => [method, fixed('settings.manage')])),
|
|
233
|
+
// Calls by a voice service: talking to the models; its services and their keys are settings.
|
|
234
|
+
TaVoiceServer: {
|
|
235
|
+
listVoices: fixed('settings.view'),
|
|
236
|
+
addVoice: fixed('settings.manage'),
|
|
237
|
+
updateVoice: fixed('settings.manage'),
|
|
238
|
+
removeVoice: fixed('settings.manage'),
|
|
239
|
+
chooseVoice: fixed('settings.manage'),
|
|
240
|
+
setBargeIn: fixed('settings.manage'),
|
|
241
|
+
openVoice: fixed('models.use'),
|
|
242
|
+
sendVoice: fixed('models.use'),
|
|
243
|
+
sayVoice: fixed('models.use'),
|
|
244
|
+
hushVoice: fixed('models.use'),
|
|
245
|
+
closeVoice: fixed('models.use'),
|
|
246
|
+
},
|
|
222
247
|
// What a page is at: each page's own, and only of conversations it may see (TaPresenceServerImpl).
|
|
223
248
|
TaPresenceServer: {
|
|
224
249
|
report: anyone,
|
|
225
250
|
},
|
|
251
|
+
// Which requests a page answers: each page's own; ta serve asks only the pages of who asked a run (TaPageBook).
|
|
252
|
+
TaPageServer: {
|
|
253
|
+
attach: anyone,
|
|
254
|
+
},
|
|
226
255
|
TaSettingsServer: {
|
|
227
256
|
getSettings: fixed('settings.view'),
|
|
228
257
|
updateSettings: fixed('settings.manage'),
|
|
@@ -267,6 +296,26 @@ const RULES = {
|
|
|
267
296
|
answer: fixed('hosts.use'),
|
|
268
297
|
disconnect: fixed('hosts.use'),
|
|
269
298
|
},
|
|
299
|
+
// Remote desktops: seeing and working a screen is all the owner can do, and in the first stage only the owner does it
|
|
300
|
+
// (docs/design/ta-desktop-remote.md 6.2); no role or grant gives it.
|
|
301
|
+
TaScreenShareServer: {
|
|
302
|
+
listDesktops: owner,
|
|
303
|
+
listDesktopScreens: owner,
|
|
304
|
+
addDesktop: owner,
|
|
305
|
+
removeDesktop: owner,
|
|
306
|
+
openDesktop: owner,
|
|
307
|
+
closeDesktop: owner,
|
|
308
|
+
readDesktopFrames: owner,
|
|
309
|
+
setDesktopView: owner,
|
|
310
|
+
sendDesktopInput: owner,
|
|
311
|
+
pasteToDesktop: owner,
|
|
312
|
+
readDesktopClipboard: owner,
|
|
313
|
+
takeDesktopControl: owner,
|
|
314
|
+
releaseDesktopControl: owner,
|
|
315
|
+
endAllDesktops: owner,
|
|
316
|
+
watchDesktops: owner,
|
|
317
|
+
answerDesktop: owner,
|
|
318
|
+
},
|
|
270
319
|
};
|
|
271
320
|
/** By name, own keys only: a method such as `toString` is no rule. */
|
|
272
321
|
const BY_SERVICE = new Map(Object.entries(RULES).map(([service, rules]) => [service, new Map(Object.entries(rules))]));
|