@celljs/ta-host 4.16.0 → 4.17.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 +629 -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 +6 -0
- package/esm/node/index.js +6 -0
- package/esm/node/keep-awake.d.ts +5 -1
- package/esm/node/keep-awake.js +18 -2
- package/esm/node/message-page.d.ts +6 -1
- package/esm/node/message-page.js +50 -2
- package/esm/node/package-hosts.d.ts +6 -0
- package/esm/node/package-hosts.js +35 -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 +3 -0
- package/esm/node/rooms-bridge.js +4 -0
- package/esm/node/session-info-util.d.ts +3 -1
- package/esm/node/session-info-util.js +32 -6
- package/esm/node/ta-server-impl.d.ts +5 -1
- package/esm/node/ta-server-impl.js +22 -0
- package/esm/node/ta-session-factory.d.ts +13 -1
- package/esm/node/ta-session-factory.js +39 -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 +22 -0
- package/esm/node/voice-bridge.d.ts +68 -0
- package/esm/node/voice-bridge.js +273 -0
- package/esm/node/voices-file.d.ts +33 -0
- package/esm/node/voices-file.js +89 -0
- package/lib/node/app-commands.d.ts +112 -0
- package/lib/node/app-commands.js +633 -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 +6 -0
- package/lib/node/index.js +6 -0
- package/lib/node/keep-awake.d.ts +5 -1
- package/lib/node/keep-awake.js +18 -2
- package/lib/node/message-page.d.ts +6 -1
- package/lib/node/message-page.js +50 -2
- package/lib/node/package-hosts.d.ts +6 -0
- package/lib/node/package-hosts.js +35 -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 +3 -0
- package/lib/node/rooms-bridge.js +4 -0
- package/lib/node/session-info-util.d.ts +3 -1
- package/lib/node/session-info-util.js +31 -5
- package/lib/node/ta-server-impl.d.ts +5 -1
- package/lib/node/ta-server-impl.js +22 -0
- package/lib/node/ta-session-factory.d.ts +13 -1
- package/lib/node/ta-session-factory.js +38 -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 +22 -0
- package/lib/node/voice-bridge.d.ts +69 -0
- package/lib/node/voice-bridge.js +274 -0
- package/lib/node/voices-file.d.ts +34 -0
- package/lib/node/voices-file.js +93 -0
- package/package.json +10 -10
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { type CodingAgentOptions } from '@celljs/ai-coding-agent';
|
|
2
2
|
import { type Application, ApplicationLifecycle } from '@celljs/core';
|
|
3
3
|
import { type TaExtensionHost, type TaHostAnswer, type TaHostSessionEvent, TaPackageServer, type TaPackageService, TaServer } from '@celljs/ta-protocol';
|
|
4
|
+
import { TaAppCommands } from './app-commands.js';
|
|
4
5
|
import { ExtensionDataStore } from './extension-data.js';
|
|
5
6
|
import { TaPresenceBook, TaSessionRegistry } from './host-protocol.js';
|
|
7
|
+
import { TaPageBook } from './page-book.js';
|
|
6
8
|
import { type RelayBridge } from './relay-bridge.js';
|
|
7
9
|
import { PiDirectories } from './remote/remote-protocol.js';
|
|
8
10
|
import { type RoomsBridge } from './rooms-bridge.js';
|
|
9
11
|
import { TaSettingsStore } from './settings-store.js';
|
|
10
12
|
import { TaHostTeamProvider } from './team/team-protocol.js';
|
|
13
|
+
import { type VoiceBridge } from './voice-bridge.js';
|
|
11
14
|
export declare const PackageHosts: unique symbol;
|
|
12
15
|
/**
|
|
13
16
|
* The server side of built-in packages under `ta serve`: the module a package names in `pi.host` of its
|
|
@@ -54,9 +57,12 @@ export declare class PackageHostsImpl implements PackageHosts, ApplicationLifecy
|
|
|
54
57
|
protected readonly packages: TaPackageServer;
|
|
55
58
|
protected readonly relay: RelayBridge;
|
|
56
59
|
protected readonly roomsBridge: RoomsBridge;
|
|
60
|
+
protected readonly voiceBridge: VoiceBridge;
|
|
57
61
|
protected readonly settings: TaSettingsStore;
|
|
58
62
|
protected readonly sessions: TaSessionRegistry;
|
|
59
63
|
protected readonly presenceBook: TaPresenceBook;
|
|
64
|
+
protected readonly appCommands: TaAppCommands;
|
|
65
|
+
protected readonly pageBook: TaPageBook;
|
|
60
66
|
protected readonly teamProvider: TaHostTeamProvider;
|
|
61
67
|
protected readonly running: Map<string, Running>;
|
|
62
68
|
protected extensionHost?: TaExtensionHost;
|
|
@@ -16,14 +16,18 @@ import { ApplicationLifecycle, Autowired, Component, Value } from '@celljs/core'
|
|
|
16
16
|
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
17
17
|
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
18
18
|
import { TaMessageSource, TaPackageServer, TaServer, } from '@celljs/ta-protocol';
|
|
19
|
+
import { TaAppCommands } from './app-commands.js';
|
|
19
20
|
import { ExtensionDataStore } from './extension-data.js';
|
|
20
21
|
import { TaPresenceBook, TaSessionRegistry } from './host-protocol.js';
|
|
22
|
+
import { TaPageBook } from './page-book.js';
|
|
21
23
|
import { RELAY_BRIDGE } from './relay-bridge.js';
|
|
22
24
|
import { PiDirectories } from './remote/remote-protocol.js';
|
|
23
25
|
import { ROOMS_BRIDGE } from './rooms-bridge.js';
|
|
26
|
+
import { SessionCatalogUtil } from './session-catalog.js';
|
|
24
27
|
import { TaSettingsStore } from './settings-store.js';
|
|
25
28
|
import { TaErrors } from './ta-errors.js';
|
|
26
29
|
import { TaHostTeamProvider } from './team/team-protocol.js';
|
|
30
|
+
import { VOICE_BRIDGE } from './voice-bridge.js';
|
|
27
31
|
export const PackageHosts = Symbol('PackageHosts');
|
|
28
32
|
export var PackageHostUtil;
|
|
29
33
|
(function (PackageHostUtil) {
|
|
@@ -155,6 +159,7 @@ let PackageHostsImpl = class PackageHostsImpl {
|
|
|
155
159
|
var _a, _b;
|
|
156
160
|
const running = this.running.get(name);
|
|
157
161
|
this.running.delete(name);
|
|
162
|
+
this.appCommands.dropOwner(name);
|
|
158
163
|
try {
|
|
159
164
|
await ((_b = (_a = (await (running === null || running === void 0 ? void 0 : running.service))) === null || _a === void 0 ? void 0 : _a.dispose) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
160
165
|
}
|
|
@@ -168,6 +173,12 @@ let PackageHostsImpl = class PackageHostsImpl {
|
|
|
168
173
|
const mark = (input) => ({ ...input, message: TaMessageSource.mark(input.message, name) });
|
|
169
174
|
return {
|
|
170
175
|
...host,
|
|
176
|
+
commands: { ...host.commands, register: command => this.appCommands.registerOf(name, command) },
|
|
177
|
+
// A package asks the requests of its own web extension (`pi.ui.answer`), named after it.
|
|
178
|
+
pages: {
|
|
179
|
+
ask: (kind, payload, options = {}) => this.pageBook.ask(this.pageBook.principalOf(options), `${name}/${kind}`, payload, options.timeoutMs),
|
|
180
|
+
has: (kind, options = {}) => this.pageBook.has(this.pageBook.principalOf(options), `${name}/${kind}`),
|
|
181
|
+
},
|
|
171
182
|
prompt: (sessionId, input) => host.prompt(sessionId, mark(input)),
|
|
172
183
|
followUp: (sessionId, input) => host.followUp(sessionId, mark(input)),
|
|
173
184
|
};
|
|
@@ -188,7 +199,9 @@ let PackageHostsImpl = class PackageHostsImpl {
|
|
|
188
199
|
shares: this.relay.shares,
|
|
189
200
|
rooms: this.roomsBridge.rooms,
|
|
190
201
|
relays: this.relay.extensionRelays,
|
|
202
|
+
voices: this.voiceBridge.extensionVoices,
|
|
191
203
|
sessionMessages: file => this.sessionMessages(file),
|
|
204
|
+
sessionRole: async (file) => SessionCatalogUtil.roleOf((await PiSdkUtil.load()).SessionManager.open(file).getEntries()),
|
|
192
205
|
createSession: (cwd, messages, name) => this.createSession(cwd, messages, name),
|
|
193
206
|
getServerInfo: () => server.getServerInfo(),
|
|
194
207
|
listSessions: () => server.listSessions(),
|
|
@@ -200,6 +213,7 @@ let PackageHostsImpl = class PackageHostsImpl {
|
|
|
200
213
|
abort: sessionId => server.abort(sessionId),
|
|
201
214
|
getState: sessionId => server.getState(sessionId),
|
|
202
215
|
getLastAssistantText: sessionId => server.getLastAssistantText(sessionId),
|
|
216
|
+
relocateDirectory: (from, to) => server.relocateDirectory(from, to),
|
|
203
217
|
getExtensionData: (name, key, cwd) => packages.getExtensionData(name, key, cwd),
|
|
204
218
|
setExtensionData: (name, key, value, cwd) => packages.setExtensionData(name, key, value, cwd),
|
|
205
219
|
onExtensionData: listener => this.data.onChange(listener),
|
|
@@ -211,6 +225,15 @@ let PackageHostsImpl = class PackageHostsImpl {
|
|
|
211
225
|
}),
|
|
212
226
|
presence: () => ({ pages: this.sessions.watching, seenAt: this.sessions.watchedAt, people: this.presenceBook.everyone() }),
|
|
213
227
|
team: this.teamProvider.team,
|
|
228
|
+
commands: {
|
|
229
|
+
list: () => this.appCommands.list(),
|
|
230
|
+
run: (id, input, options) => this.appCommands.run(id, input, options),
|
|
231
|
+
register: command => this.appCommands.register(command),
|
|
232
|
+
},
|
|
233
|
+
pages: {
|
|
234
|
+
ask: () => Promise.reject(new Error('Only a package asks a page: through its own host.')),
|
|
235
|
+
has: () => false,
|
|
236
|
+
},
|
|
214
237
|
installPackage: (source, scope, cwd) => packages.installPackage(source, scope, cwd),
|
|
215
238
|
removePackage: (id, cwd) => packages.removePackage(id, cwd),
|
|
216
239
|
updateSettings: update => this.settings.rewriteUser(update),
|
|
@@ -273,6 +296,10 @@ __decorate([
|
|
|
273
296
|
Autowired({ id: ROOMS_BRIDGE, detached: true }),
|
|
274
297
|
__metadata("design:type", Function)
|
|
275
298
|
], PackageHostsImpl.prototype, "roomsBridge", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
Autowired({ id: VOICE_BRIDGE, detached: true }),
|
|
301
|
+
__metadata("design:type", Function)
|
|
302
|
+
], PackageHostsImpl.prototype, "voiceBridge", void 0);
|
|
276
303
|
__decorate([
|
|
277
304
|
Autowired({ id: TaSettingsStore, detached: true }),
|
|
278
305
|
__metadata("design:type", Object)
|
|
@@ -285,6 +312,14 @@ __decorate([
|
|
|
285
312
|
Autowired({ id: TaPresenceBook, detached: true }),
|
|
286
313
|
__metadata("design:type", Object)
|
|
287
314
|
], PackageHostsImpl.prototype, "presenceBook", void 0);
|
|
315
|
+
__decorate([
|
|
316
|
+
Autowired({ id: TaAppCommands, detached: true }),
|
|
317
|
+
__metadata("design:type", Object)
|
|
318
|
+
], PackageHostsImpl.prototype, "appCommands", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
Autowired({ id: TaPageBook, detached: true }),
|
|
321
|
+
__metadata("design:type", Object)
|
|
322
|
+
], PackageHostsImpl.prototype, "pageBook", void 0);
|
|
288
323
|
__decorate([
|
|
289
324
|
Autowired({ id: TaHostTeamProvider, detached: true }),
|
|
290
325
|
__metadata("design:type", Object)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IncomingMessage } from 'node:http';
|
|
2
|
+
import { type Context, Middleware } from '@celljs/web/lib/node';
|
|
3
|
+
import { PackageHosts } from './package-hosts.js';
|
|
4
|
+
/** Where ta serve takes the webhooks of packages: the directory name of a package, then its own path. */
|
|
5
|
+
export declare const WEBHOOK_PATH = "/api/hooks/";
|
|
6
|
+
export declare namespace PackageWebhookUtil {
|
|
7
|
+
/** The package and its path of a request to a webhook; undefined for another request. */
|
|
8
|
+
function target(request: Pick<IncomingMessage, 'url'>): {
|
|
9
|
+
name: string;
|
|
10
|
+
path: string;
|
|
11
|
+
} | undefined;
|
|
12
|
+
/** The body as text; undefined when it is larger than TA_WEBHOOK_MAX_BYTES. */
|
|
13
|
+
function body(request: IncomingMessage): Promise<string | undefined>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The webhooks of the packages that come with Ta (TaPackageService.webhook): a POST to `/api/hooks/<package>/<path>`
|
|
17
|
+
* goes to its host without the token of ta serve; the package checks the secret of its path. Anything else (another
|
|
18
|
+
* method, a package without a webhook, a secret it does not know) is a 404 that says nothing more.
|
|
19
|
+
*/
|
|
20
|
+
export declare class PackageWebhooks implements Middleware {
|
|
21
|
+
/** Before TaAccess, which would ask for the token. */
|
|
22
|
+
readonly priority: number;
|
|
23
|
+
protected readonly hosts: PackageHosts;
|
|
24
|
+
protected readonly host?: string;
|
|
25
|
+
handle(ctx: Context, next: () => Promise<void>): Promise<void>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Autowired, Component, Value } from '@celljs/core';
|
|
11
|
+
import { TaPackages } from '@celljs/ta-harness/lib/node/ta-packages';
|
|
12
|
+
import { TA_WEBHOOK_MAX_BYTES } from '@celljs/ta-protocol';
|
|
13
|
+
import { Middleware } from '@celljs/web/lib/node';
|
|
14
|
+
import { PackageHosts } from './package-hosts.js';
|
|
15
|
+
import { ACCESS_MIDDLEWARE_PRIORITY, TaAccessUtil } from './ta-access.js';
|
|
16
|
+
/** Where ta serve takes the webhooks of packages: the directory name of a package, then its own path. */
|
|
17
|
+
export const WEBHOOK_PATH = '/api/hooks/';
|
|
18
|
+
export var PackageWebhookUtil;
|
|
19
|
+
(function (PackageWebhookUtil) {
|
|
20
|
+
/** The package and its path of a request to a webhook; undefined for another request. */
|
|
21
|
+
function target(request) {
|
|
22
|
+
var _a;
|
|
23
|
+
const path = ((_a = request.url) !== null && _a !== void 0 ? _a : '/').split('?')[0];
|
|
24
|
+
if (!path.startsWith(WEBHOOK_PATH)) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const [directory, ...rest] = path.slice(WEBHOOK_PATH.length).split('/');
|
|
28
|
+
const name = TaPackages.BUILTIN.find(builtin => TaPackages.directoryName(builtin) === directory);
|
|
29
|
+
return name ? { name, path: rest.map(part => decodeURIComponent(part)).join('/') } : { name: '', path: '' };
|
|
30
|
+
}
|
|
31
|
+
PackageWebhookUtil.target = target;
|
|
32
|
+
/** The body as text; undefined when it is larger than TA_WEBHOOK_MAX_BYTES. */
|
|
33
|
+
async function body(request) {
|
|
34
|
+
const chunks = [];
|
|
35
|
+
let size = 0;
|
|
36
|
+
for await (const chunk of request) {
|
|
37
|
+
size += chunk.length;
|
|
38
|
+
if (size > TA_WEBHOOK_MAX_BYTES) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
chunks.push(chunk);
|
|
42
|
+
}
|
|
43
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
44
|
+
}
|
|
45
|
+
PackageWebhookUtil.body = body;
|
|
46
|
+
})(PackageWebhookUtil || (PackageWebhookUtil = {}));
|
|
47
|
+
function end(response, status, value) {
|
|
48
|
+
response.statusCode = status;
|
|
49
|
+
response.setHeader('Content-Type', 'application/json; charset=utf-8');
|
|
50
|
+
response.end(JSON.stringify(value));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The webhooks of the packages that come with Ta (TaPackageService.webhook): a POST to `/api/hooks/<package>/<path>`
|
|
54
|
+
* goes to its host without the token of ta serve; the package checks the secret of its path. Anything else (another
|
|
55
|
+
* method, a package without a webhook, a secret it does not know) is a 404 that says nothing more.
|
|
56
|
+
*/
|
|
57
|
+
let PackageWebhooks = class PackageWebhooks {
|
|
58
|
+
constructor() {
|
|
59
|
+
/** Before TaAccess, which would ask for the token. */
|
|
60
|
+
this.priority = ACCESS_MIDDLEWARE_PRIORITY + 2;
|
|
61
|
+
}
|
|
62
|
+
async handle(ctx, next) {
|
|
63
|
+
const request = ctx.request;
|
|
64
|
+
const target = PackageWebhookUtil.target(request);
|
|
65
|
+
if (!target) {
|
|
66
|
+
await next();
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
const response = ctx.response;
|
|
70
|
+
// A page that rebinds its domain to a ta serve of 127.0.0.1 reaches nothing, as with TaAccess.
|
|
71
|
+
if (!target.name || request.method !== 'POST' || (TaAccessUtil.isLoopbackHost(this.host) && !TaAccessUtil.isLoopbackHost(request.headers.host))) {
|
|
72
|
+
end(response, 404, { error: 'Not found' });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const body = await PackageWebhookUtil.body(request);
|
|
76
|
+
if (body === undefined) {
|
|
77
|
+
end(response, 413, { error: 'Too large' });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
const answer = await this.hosts.call(target.name, 'webhook', [{ path: target.path, body, contentType: request.headers['content-type'] }]);
|
|
82
|
+
end(response, 202, answer !== null && answer !== void 0 ? answer : { ok: true });
|
|
83
|
+
}
|
|
84
|
+
catch (_a) {
|
|
85
|
+
end(response, 404, { error: 'Not found' });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
__decorate([
|
|
90
|
+
Autowired(PackageHosts),
|
|
91
|
+
__metadata("design:type", Object)
|
|
92
|
+
], PackageWebhooks.prototype, "hosts", void 0);
|
|
93
|
+
__decorate([
|
|
94
|
+
Value('server.host'),
|
|
95
|
+
__metadata("design:type", String)
|
|
96
|
+
], PackageWebhooks.prototype, "host", void 0);
|
|
97
|
+
PackageWebhooks = __decorate([
|
|
98
|
+
Component(Middleware)
|
|
99
|
+
], PackageWebhooks);
|
|
100
|
+
export { PackageWebhooks };
|
|
101
|
+
//# sourceMappingURL=package-webhooks.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type RpcConnection } from '@celljs/rpc/lib/node';
|
|
2
|
+
import { type TaPageAskOptions, type TaPageInfo, TaPageServer } from '@celljs/ta-protocol';
|
|
3
|
+
import { TaHostTeamProvider, TaPrincipals } from './team/team-protocol.js';
|
|
4
|
+
export declare const TaPageBook: unique symbol;
|
|
5
|
+
/** The pages that answer requests (TaPageServer.attach), by connection, in memory only. */
|
|
6
|
+
export interface TaPageBook {
|
|
7
|
+
attach(connection: RpcConnection, info: TaPageInfo): void;
|
|
8
|
+
/** Asks the page of `principal` that answers `kind` (PageChoice.pick) and resolves to its answer. */
|
|
9
|
+
ask(principal: string, kind: string, payload: unknown, timeoutMs?: number): Promise<unknown>;
|
|
10
|
+
has(principal: string, kind: string): boolean;
|
|
11
|
+
/** Whom a package's request is for: who asked the run of the session file, or the principal given. */
|
|
12
|
+
principalOf(options: TaPageAskOptions): string;
|
|
13
|
+
}
|
|
14
|
+
/** A page as the book keeps it. */
|
|
15
|
+
export interface PageEntry {
|
|
16
|
+
principal: string;
|
|
17
|
+
info: TaPageInfo;
|
|
18
|
+
/** `Date.now()` time it was last said active, or attached. */
|
|
19
|
+
activeAt: number;
|
|
20
|
+
}
|
|
21
|
+
export declare namespace PageChoice {
|
|
22
|
+
/**
|
|
23
|
+
* The page to ask among those of one person that answer the kind: the one in front of them, the latest touched of
|
|
24
|
+
* those; else the window of Ta Desktop, kept while closed; else the latest touched.
|
|
25
|
+
*/
|
|
26
|
+
function pick<T extends PageEntry>(entries: readonly T[]): T | undefined;
|
|
27
|
+
/** What a page said of itself, made safe: only strings of kinds, a device it knows. */
|
|
28
|
+
function clean(info: TaPageInfo | undefined): TaPageInfo;
|
|
29
|
+
}
|
|
30
|
+
export declare class DefaultTaPageBook implements TaPageBook {
|
|
31
|
+
protected readonly principals: TaPrincipals;
|
|
32
|
+
protected readonly teamProvider: TaHostTeamProvider;
|
|
33
|
+
protected readonly entries: Map<RpcConnection, PageEntry & {
|
|
34
|
+
connection: RpcConnection;
|
|
35
|
+
}>;
|
|
36
|
+
attach(connection: RpcConnection, info: TaPageInfo): void;
|
|
37
|
+
ask(principal: string, kind: string, payload: unknown, timeoutMs?: number): Promise<unknown>;
|
|
38
|
+
has(principal: string, kind: string): boolean;
|
|
39
|
+
principalOf(options: TaPageAskOptions): string;
|
|
40
|
+
protected of(principal: string, kind: string): (PageEntry & {
|
|
41
|
+
connection: RpcConnection;
|
|
42
|
+
})[];
|
|
43
|
+
}
|
|
44
|
+
/** A page says which requests it answers (TaPageServer). */
|
|
45
|
+
export declare class TaPageServerImpl implements TaPageServer {
|
|
46
|
+
protected readonly book: TaPageBook;
|
|
47
|
+
attach(info: TaPageInfo): Promise<void>;
|
|
48
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Autowired, Component } from '@celljs/core';
|
|
11
|
+
import { Rpc } from '@celljs/rpc';
|
|
12
|
+
import { RpcContext } from '@celljs/rpc/lib/node';
|
|
13
|
+
import { TA_OWNER, TA_PAGE_ASK_MS, TaClient, TaPageServer } from '@celljs/ta-protocol';
|
|
14
|
+
import { TaErrors } from './ta-errors.js';
|
|
15
|
+
import { TaHostTeamProvider, TaPrincipals } from './team/team-protocol.js';
|
|
16
|
+
export const TaPageBook = Symbol('TaPageBook');
|
|
17
|
+
export var PageChoice;
|
|
18
|
+
(function (PageChoice) {
|
|
19
|
+
/**
|
|
20
|
+
* The page to ask among those of one person that answer the kind: the one in front of them, the latest touched of
|
|
21
|
+
* those; else the window of Ta Desktop, kept while closed; else the latest touched.
|
|
22
|
+
*/
|
|
23
|
+
function pick(entries) {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
const latest = (list) => list.reduce((best, one) => (!best || one.activeAt > best.activeAt ? one : best), undefined);
|
|
26
|
+
return (_b = (_a = latest(entries.filter(entry => entry.info.visible))) !== null && _a !== void 0 ? _a : latest(entries.filter(entry => entry.info.desktop))) !== null && _b !== void 0 ? _b : latest(entries);
|
|
27
|
+
}
|
|
28
|
+
PageChoice.pick = pick;
|
|
29
|
+
/** What a page said of itself, made safe: only strings of kinds, a device it knows. */
|
|
30
|
+
function clean(info) {
|
|
31
|
+
const kinds = Array.isArray(info === null || info === void 0 ? void 0 : info.kinds) ? info.kinds.filter(kind => typeof kind === 'string' && kind.length <= 100).slice(0, 100) : [];
|
|
32
|
+
const device = (info === null || info === void 0 ? void 0 : info.device) === 'phone' || (info === null || info === void 0 ? void 0 : info.device) === 'tablet' ? info.device : 'computer';
|
|
33
|
+
return { kinds, device, ...((info === null || info === void 0 ? void 0 : info.desktop) === true ? { desktop: true } : {}), ...((info === null || info === void 0 ? void 0 : info.visible) === true ? { visible: true } : {}) };
|
|
34
|
+
}
|
|
35
|
+
PageChoice.clean = clean;
|
|
36
|
+
})(PageChoice || (PageChoice = {}));
|
|
37
|
+
let DefaultTaPageBook = class DefaultTaPageBook {
|
|
38
|
+
constructor() {
|
|
39
|
+
this.entries = new Map();
|
|
40
|
+
}
|
|
41
|
+
attach(connection, info) {
|
|
42
|
+
if (connection.closed) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const before = this.entries.get(connection);
|
|
46
|
+
const clean = PageChoice.clean(info);
|
|
47
|
+
this.entries.set(connection, {
|
|
48
|
+
connection,
|
|
49
|
+
principal: this.principals.of(connection),
|
|
50
|
+
info: clean,
|
|
51
|
+
activeAt: (info === null || info === void 0 ? void 0 : info.active) === true || !before ? Date.now() : before.activeAt,
|
|
52
|
+
});
|
|
53
|
+
if (!before) {
|
|
54
|
+
connection.onClose(() => this.entries.delete(connection));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async ask(principal, kind, payload, timeoutMs = TA_PAGE_ASK_MS) {
|
|
58
|
+
const page = PageChoice.pick(this.of(principal, kind));
|
|
59
|
+
if (!page) {
|
|
60
|
+
throw TaErrors.invalidArgument('No page of Ta is open for this.', 'The user opens Ta on a phone or a computer; meanwhile do it without the screen.');
|
|
61
|
+
}
|
|
62
|
+
let timer;
|
|
63
|
+
try {
|
|
64
|
+
return await Promise.race([
|
|
65
|
+
page.connection.client(TaClient).onPageAsk(kind, payload),
|
|
66
|
+
new Promise((_resolve, reject) => {
|
|
67
|
+
timer = setTimeout(() => reject(TaErrors.invalidArgument('The page of Ta did not answer in time.', 'Try again in a moment.')), timeoutMs);
|
|
68
|
+
}),
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
clearTimeout(timer);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
has(principal, kind) {
|
|
76
|
+
return this.of(principal, kind).length > 0;
|
|
77
|
+
}
|
|
78
|
+
principalOf(options) {
|
|
79
|
+
var _a;
|
|
80
|
+
if (options.principal) {
|
|
81
|
+
return options.principal;
|
|
82
|
+
}
|
|
83
|
+
const team = this.teamProvider.team;
|
|
84
|
+
const actors = options.sessionFile ? team.actorsOf(options.sessionFile) : [team.current()];
|
|
85
|
+
return (_a = actors.find(actor => actor !== TA_OWNER)) !== null && _a !== void 0 ? _a : TA_OWNER;
|
|
86
|
+
}
|
|
87
|
+
of(principal, kind) {
|
|
88
|
+
return [...this.entries.values()].filter(entry => !entry.connection.closed && entry.principal === principal && entry.info.kinds.includes(kind));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
__decorate([
|
|
92
|
+
Autowired(TaPrincipals),
|
|
93
|
+
__metadata("design:type", Object)
|
|
94
|
+
], DefaultTaPageBook.prototype, "principals", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
Autowired({ id: TaHostTeamProvider, detached: true }),
|
|
97
|
+
__metadata("design:type", Object)
|
|
98
|
+
], DefaultTaPageBook.prototype, "teamProvider", void 0);
|
|
99
|
+
DefaultTaPageBook = __decorate([
|
|
100
|
+
Component(TaPageBook)
|
|
101
|
+
], DefaultTaPageBook);
|
|
102
|
+
export { DefaultTaPageBook };
|
|
103
|
+
/** A page says which requests it answers (TaPageServer). */
|
|
104
|
+
let TaPageServerImpl = class TaPageServerImpl {
|
|
105
|
+
async attach(info) {
|
|
106
|
+
this.book.attach(RpcContext.requireConnection(), info);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
__decorate([
|
|
110
|
+
Autowired(TaPageBook),
|
|
111
|
+
__metadata("design:type", Object)
|
|
112
|
+
], TaPageServerImpl.prototype, "book", void 0);
|
|
113
|
+
TaPageServerImpl = __decorate([
|
|
114
|
+
Rpc(TaPageServer)
|
|
115
|
+
], TaPageServerImpl);
|
|
116
|
+
export { TaPageServerImpl };
|
|
117
|
+
//# sourceMappingURL=page-book.js.map
|
|
@@ -80,6 +80,8 @@ export declare class TaRelayServerImpl implements TaRelayServer {
|
|
|
80
80
|
addStore(type: string, options: Record<string, unknown>, name?: string): Promise<string>;
|
|
81
81
|
removeRelay(id: string): Promise<void>;
|
|
82
82
|
chooseRelay(feature: TaRelayFeature, id: string | null): Promise<TaRelays>;
|
|
83
|
+
joinDeployment(url: string): Promise<TaRelays>;
|
|
84
|
+
leaveDeployment(): Promise<TaRelays>;
|
|
83
85
|
probeRelay(idOrUrl: string): Promise<TaRelayProbe>;
|
|
84
86
|
/** A change of relays.json; what it refuses is said as the errors of Ta. */
|
|
85
87
|
protected relaysCall<T>(change: () => T): T;
|
package/esm/node/relay-bridge.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Rpc } from '@celljs/rpc';
|
|
|
15
15
|
import { ExecEnvironmentFactory } from '@celljs/ta-exec';
|
|
16
16
|
import { PackageArchive } from '@celljs/ta-harness/lib/node/package-archive';
|
|
17
17
|
import { TaBrand } from '@celljs/ta-harness/lib/node/ta-brand';
|
|
18
|
-
import { TA_WEBSOCKET_PATH, TaRelayServer, } from '@celljs/ta-protocol';
|
|
18
|
+
import { TA_WEBSOCKET_PATH, TaDeploymentUtil, TaRelayServer, } from '@celljs/ta-protocol';
|
|
19
19
|
import { RELAY_CONTENT_MAX_BYTES, RELAY_FEATURES, RELAY_SHARE_MAX_BYTES, RelayBlobClient, RelayBytes, RelayContentError, RelayContentUtil, RelayHost, RelayHubFiles, RelayHubs, RelayInfoUtil, RelayPairingUtil, RelayServiceUtil, RelayShareUtil, RelayStore, RelaysConfigError, RelaysFile, RelayTypes, } from '@celljs/ta-relay/lib/node';
|
|
20
20
|
import { ServerAware } from '@celljs/web/lib/node';
|
|
21
21
|
import { KeepAwake, WebExtensionCatalog } from './host-protocol.js';
|
|
@@ -238,6 +238,7 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
238
238
|
const url = RelayServiceUtil.isRelay(service) ? service.url : undefined;
|
|
239
239
|
return [feature, service.id || ((_a = services.find(each => each.type === 'ta-relay' && each.url === url)) === null || _a === void 0 ? void 0 : _a.id) || ''];
|
|
240
240
|
}));
|
|
241
|
+
const deployment = this.relays.deployment(config);
|
|
241
242
|
const drives = RelayServiceUtil.drives().filter(drive => !services.some(service => service.type === 'folder' && service.path === drive.path));
|
|
242
243
|
const types = [...this.types].map(([type, { title, hint, icon, options }]) => ({
|
|
243
244
|
type,
|
|
@@ -253,6 +254,7 @@ let RelayBridge = RelayBridge_1 = class RelayBridge {
|
|
|
253
254
|
...(drives.length ? { drives } : {}),
|
|
254
255
|
...(types.length ? { types } : {}),
|
|
255
256
|
...(error ? { error } : {}),
|
|
257
|
+
...(deployment ? { deployment } : {}),
|
|
256
258
|
};
|
|
257
259
|
}
|
|
258
260
|
/** The store of a service of a type a package registered. */
|
|
@@ -424,6 +426,38 @@ let TaRelayServerImpl = class TaRelayServerImpl {
|
|
|
424
426
|
return this.bridge.listRelays();
|
|
425
427
|
});
|
|
426
428
|
}
|
|
429
|
+
joinDeployment(url) {
|
|
430
|
+
return TaErrors.guard(async () => {
|
|
431
|
+
var _a, _b;
|
|
432
|
+
const address = TaDeploymentUtil.url(url);
|
|
433
|
+
if (!address) {
|
|
434
|
+
throw TaErrors.invalidArgument(`${url} is not an address of http or https.`, 'Pass the address of the gateway or the relay of the deployment, https://….');
|
|
435
|
+
}
|
|
436
|
+
let deployment;
|
|
437
|
+
try {
|
|
438
|
+
deployment = await TaDeploymentUtil.discover(address);
|
|
439
|
+
}
|
|
440
|
+
catch (error) {
|
|
441
|
+
throw TaErrors.invalidArgument(error instanceof Error ? error.message : String(error), 'Check the address: a service of a deployment answers /.well-known/ta. A relay alone is added as a relay.');
|
|
442
|
+
}
|
|
443
|
+
if (deployment.relay) {
|
|
444
|
+
const probe = await RelayInfoUtil.probe(deployment.relay);
|
|
445
|
+
if (!probe.online) {
|
|
446
|
+
throw TaErrors.invalidArgument(`The relay of ${(_a = deployment.name) !== null && _a !== void 0 ? _a : address}, ${deployment.relay}, does not answer: ${(_b = probe.error) !== null && _b !== void 0 ? _b : 'no answer'}.`, 'Ask whoever runs the deployment whether its relay runs.');
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
this.relaysCall(() => this.bridge.relays.join(address, deployment));
|
|
450
|
+
this.bridge.relaysChanged();
|
|
451
|
+
return this.bridge.listRelays();
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
leaveDeployment() {
|
|
455
|
+
return TaErrors.guard(async () => {
|
|
456
|
+
this.relaysCall(() => this.bridge.relays.leave());
|
|
457
|
+
this.bridge.relaysChanged();
|
|
458
|
+
return this.bridge.listRelays();
|
|
459
|
+
});
|
|
460
|
+
}
|
|
427
461
|
async probeRelay(idOrUrl) {
|
|
428
462
|
var _a, _b, _c;
|
|
429
463
|
const text = String(idOrUrl !== null && idOrUrl !== void 0 ? idOrUrl : '');
|
|
@@ -53,6 +53,9 @@ export declare class TaRoomServerImpl implements TaRoomServer {
|
|
|
53
53
|
listRequests(): Promise<TaRoomRequest[]>;
|
|
54
54
|
answer(room: string, ask: string, accept: boolean): Promise<void>;
|
|
55
55
|
removeMember(room: string, member: string): Promise<void>;
|
|
56
|
+
configureRoom(room: string, options: {
|
|
57
|
+
members?: number;
|
|
58
|
+
}): Promise<TaRoomInfo>;
|
|
56
59
|
leave(room: string): Promise<void>;
|
|
57
60
|
send(room: string, data: unknown, to?: string): Promise<void>;
|
|
58
61
|
getState(room: string, prefix?: string): Promise<Record<string, TaRoomValue>>;
|
package/esm/node/rooms-bridge.js
CHANGED
|
@@ -32,6 +32,7 @@ let RoomsBridge = RoomsBridge_1 = class RoomsBridge {
|
|
|
32
32
|
listRooms: async () => this.hubs.list(),
|
|
33
33
|
createRoom: input => this.hubs.create(input),
|
|
34
34
|
invite: (room, options) => this.hubs.invite(room, options !== null && options !== void 0 ? options : {}),
|
|
35
|
+
configureRoom: async (room, options) => this.hubs.configure(room, options !== null && options !== void 0 ? options : {}),
|
|
35
36
|
join: link => this.hubs.join(link),
|
|
36
37
|
listRequests: () => this.hubs.requests(),
|
|
37
38
|
answer: (room, ask, accept) => this.hubs.answer(room, ask, accept),
|
|
@@ -149,6 +150,9 @@ let TaRoomServerImpl = class TaRoomServerImpl {
|
|
|
149
150
|
removeMember(room, member) {
|
|
150
151
|
return TaErrors.guard(() => this.rooms.removeMember(room, member));
|
|
151
152
|
}
|
|
153
|
+
configureRoom(room, options) {
|
|
154
|
+
return TaErrors.guard(() => this.rooms.configureRoom(room, { members: options === null || options === void 0 ? void 0 : options.members }));
|
|
155
|
+
}
|
|
152
156
|
leave(room) {
|
|
153
157
|
return TaErrors.guard(() => this.rooms.leave(room));
|
|
154
158
|
}
|
|
@@ -15,7 +15,9 @@ export declare namespace SessionInfoUtil {
|
|
|
15
15
|
* The text of the last message of the user or the agent that has some, on one line and cut to a preview's
|
|
16
16
|
* length, as a messaging app shows the last thing said under its name: without its context, the marks of
|
|
17
17
|
* markdown at the start of its lines, and the thinking and tool calls of the agent; a skill the user ran is
|
|
18
|
-
* `/skill:name` and what follows, as the title says it, not the skill's file.
|
|
18
|
+
* `/skill:name` and what follows, as the title says it, not the skill's file. A note of the double's tasks
|
|
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.
|
|
19
21
|
*/
|
|
20
22
|
function lastMessage(messages: readonly MessageLike[]): string | undefined;
|
|
21
23
|
/** The time of the last message that has one, else `fallback`. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TaAgentSummary, TaImageNote, TaMessageContext, TaSkillUse } from '@celljs/ta-protocol';
|
|
1
|
+
import { TaAgentSummary, TaImageNote, TaMessageContext, TaSkillUse, TaTaskNote } from '@celljs/ta-protocol';
|
|
2
2
|
/** What a list of conversations shows of one: its first message, as pi's session list does, and when it last changed. */
|
|
3
3
|
export var SessionInfoUtil;
|
|
4
4
|
(function (SessionInfoUtil) {
|
|
@@ -10,11 +10,12 @@ export var SessionInfoUtil;
|
|
|
10
10
|
* a skill the user ran is `/skill:name` and what follows, not the skill's file.
|
|
11
11
|
*/
|
|
12
12
|
function firstMessage(messages) {
|
|
13
|
+
var _a;
|
|
13
14
|
for (const message of messages) {
|
|
14
15
|
if (message.role !== 'user') {
|
|
15
16
|
continue;
|
|
16
17
|
}
|
|
17
|
-
const line = userWords(text(message.content))
|
|
18
|
+
const line = ((_a = noteWords(userWords(text(message.content)))) !== null && _a !== void 0 ? _a : '')
|
|
18
19
|
.split('\n')
|
|
19
20
|
.map(part => part.trim())
|
|
20
21
|
.find(Boolean);
|
|
@@ -29,7 +30,9 @@ export var SessionInfoUtil;
|
|
|
29
30
|
* The text of the last message of the user or the agent that has some, on one line and cut to a preview's
|
|
30
31
|
* length, as a messaging app shows the last thing said under its name: without its context, the marks of
|
|
31
32
|
* markdown at the start of its lines, and the thinking and tool calls of the agent; a skill the user ran is
|
|
32
|
-
* `/skill:name` and what follows, as the title says it, not the skill's file.
|
|
33
|
+
* `/skill:name` and what follows, as the title says it, not the skill's file. A note of the double's tasks
|
|
34
|
+
* (TaTaskNote) says the task: how one ended is its title and what it said, one handed to the double its title,
|
|
35
|
+
* and a note of a new id, for the double only, is passed over.
|
|
33
36
|
*/
|
|
34
37
|
function lastMessage(messages) {
|
|
35
38
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -37,14 +40,17 @@ export var SessionInfoUtil;
|
|
|
37
40
|
if (message.role !== 'user' && message.role !== 'assistant') {
|
|
38
41
|
continue;
|
|
39
42
|
}
|
|
40
|
-
const said = message.role === 'user' ? userWords(text(message.content)) : TaAgentSummary.strip(text(message.content));
|
|
43
|
+
const said = message.role === 'user' ? noteWords(userWords(text(message.content))) : TaAgentSummary.strip(text(message.content));
|
|
44
|
+
if (said === undefined) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
41
47
|
// A list asks for it every few seconds: only the start of a long reply is read, enough for a preview.
|
|
42
48
|
const read = said.slice(0, PREVIEW_READ);
|
|
43
|
-
const line = (withoutFences(read) || read)
|
|
49
|
+
const line = plain(withoutFences(read) || read)
|
|
44
50
|
.split('\n')
|
|
45
51
|
.map(part => part
|
|
46
52
|
.replace(/^\s*(?:#{1,6}\s+|>\s*|[-*+]\s+|\d+\.\s+)/, '')
|
|
47
|
-
.replace(/[
|
|
53
|
+
.replace(/[*`]{1,3}|(?<![\p{L}\p{N}])_{1,3}|_{1,3}(?![\p{L}\p{N}])/gu, '')
|
|
48
54
|
.trim())
|
|
49
55
|
.filter(Boolean)
|
|
50
56
|
.join(' ')
|
|
@@ -78,12 +84,32 @@ export var SessionInfoUtil;
|
|
|
78
84
|
}
|
|
79
85
|
return kept.join('\n').trim();
|
|
80
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Markdown's pictures and links as a messenger says them: a link by its words, pictures left out of a message that
|
|
89
|
+
* says something else, and by the words that name them in one of pictures only.
|
|
90
|
+
*/
|
|
91
|
+
function plain(text) {
|
|
92
|
+
const linked = text.replace(/(?<!!)\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
93
|
+
const words = linked.replace(/!\[[^\]\n]*\]\([^)\n]*\)/g, '').trim();
|
|
94
|
+
return words || linked.replace(/!\[([^\]\n]*)\]\([^)\n]*\)/g, '$1');
|
|
95
|
+
}
|
|
81
96
|
/** What the user typed of a message: without its context and pi's notes of images, a skill as `/skill:name` and what follows. */
|
|
82
97
|
function userWords(content) {
|
|
83
98
|
const said = TaImageNote.strip(TaMessageContext.strip(content));
|
|
84
99
|
const skill = TaSkillUse.parse(said);
|
|
85
100
|
return skill ? TaSkillUse.command(skill) : said;
|
|
86
101
|
}
|
|
102
|
+
/** 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. */
|
|
103
|
+
function noteWords(said) {
|
|
104
|
+
const note = TaTaskNote.parse(said);
|
|
105
|
+
if (!note) {
|
|
106
|
+
return said;
|
|
107
|
+
}
|
|
108
|
+
if (note.kind === 'renamed') {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
return note.kind === 'update' && note.body.trim() ? `${note.title} · ${note.body}` : note.title;
|
|
112
|
+
}
|
|
87
113
|
/** The time of the last message that has one, else `fallback`. */
|
|
88
114
|
function updatedAt(messages, fallback) {
|
|
89
115
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -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.js';
|
|
3
4
|
import { TaSessionCatalog, TaSessionFactory, TaSessionRegistry } from './host-protocol.js';
|
|
4
5
|
import { TaServeUpdates } from './serve-updates.js';
|
|
5
6
|
import type { TaSession } from './ta-session.js';
|
|
@@ -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'>>;
|