@celljs/ta-host 4.9.1 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +5 -5
- package/README.md +5 -5
- package/esm/node/client-tool-broker.d.ts +6 -2
- package/esm/node/client-tool-broker.js +11 -4
- package/esm/node/event-log.d.ts +2 -1
- package/esm/node/event-log.js +3 -2
- package/esm/node/exec-environment-factory.d.ts +7 -0
- package/esm/node/exec-environment-factory.js +30 -7
- package/esm/node/host-protocol.d.ts +24 -10
- package/esm/node/index.d.ts +2 -0
- package/esm/node/index.js +2 -0
- package/esm/node/package-hosts.d.ts +6 -0
- package/esm/node/package-hosts.js +36 -1
- package/esm/node/package-server-impl.d.ts +0 -1
- package/esm/node/package-server-impl.js +0 -3
- package/esm/node/relay-bridge.d.ts +12 -2
- package/esm/node/relay-bridge.js +93 -3
- package/esm/node/remote/remote-hosts.d.ts +1 -3
- package/esm/node/remote/remote-hosts.js +0 -15
- package/esm/node/remote/remote-protocol.d.ts +0 -2
- package/esm/node/remote/remote-server-impl.js +1 -1
- package/esm/node/remote-ui-context.d.ts +1 -1
- package/esm/node/remote-ui-context.js +3 -1
- package/esm/node/rooms-bridge.d.ts +60 -0
- package/esm/node/rooms-bridge.js +155 -0
- package/esm/node/session-catalog.d.ts +7 -3
- package/esm/node/session-catalog.js +15 -4
- package/esm/node/session-handles.d.ts +32 -0
- package/esm/node/session-handles.js +86 -0
- package/esm/node/session-info-util.d.ts +7 -0
- package/esm/node/session-info-util.js +63 -4
- package/esm/node/session-list-feed.d.ts +28 -0
- package/esm/node/session-list-feed.js +62 -0
- package/esm/node/sign-in/sign-in-flow.d.ts +2 -0
- package/esm/node/sign-in/sign-in-flow.js +9 -0
- package/esm/node/sign-in/sign-in-provider.js +3 -2
- package/esm/node/slash-command-util.d.ts +43 -0
- package/esm/node/slash-command-util.js +105 -0
- package/esm/node/ta-access.d.ts +11 -0
- package/esm/node/ta-access.js +29 -3
- package/esm/node/ta-errors.js +17 -2
- package/esm/node/ta-event-util.d.ts +19 -2
- package/esm/node/ta-event-util.js +97 -3
- package/esm/node/ta-server-impl.d.ts +13 -7
- package/esm/node/ta-server-impl.js +43 -24
- package/esm/node/ta-session-factory.d.ts +26 -2
- package/esm/node/ta-session-factory.js +64 -16
- package/esm/node/ta-session-registry.d.ts +16 -2
- package/esm/node/ta-session-registry.js +79 -20
- package/esm/node/ta-session.d.ts +16 -6
- package/esm/node/ta-session.js +59 -14
- package/esm/node/web-extension-catalog.d.ts +5 -1
- package/esm/node/web-extension-catalog.js +15 -19
- package/esm/node/web-extension-util.js +7 -3
- package/esm/node/workspace-files.d.ts +19 -5
- package/esm/node/workspace-files.js +26 -15
- package/esm/node/workspace-protocol.d.ts +1 -1
- package/esm/node/workspace-util.d.ts +2 -0
- package/esm/node/workspace-util.js +8 -3
- package/lib/node/client-tool-broker.d.ts +6 -2
- package/lib/node/client-tool-broker.js +11 -4
- package/lib/node/event-log.d.ts +2 -1
- package/lib/node/event-log.js +3 -2
- package/lib/node/exec-environment-factory.d.ts +7 -0
- package/lib/node/exec-environment-factory.js +30 -7
- package/lib/node/host-protocol.d.ts +24 -10
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.js +2 -0
- package/lib/node/package-hosts.d.ts +6 -0
- package/lib/node/package-hosts.js +35 -0
- package/lib/node/package-server-impl.d.ts +0 -1
- package/lib/node/package-server-impl.js +0 -3
- package/lib/node/relay-bridge.d.ts +12 -2
- package/lib/node/relay-bridge.js +91 -1
- package/lib/node/remote/remote-hosts.d.ts +1 -3
- package/lib/node/remote/remote-hosts.js +0 -15
- package/lib/node/remote/remote-protocol.d.ts +0 -2
- package/lib/node/remote/remote-server-impl.js +1 -1
- package/lib/node/remote-ui-context.d.ts +1 -1
- package/lib/node/remote-ui-context.js +3 -1
- package/lib/node/rooms-bridge.d.ts +61 -0
- package/lib/node/rooms-bridge.js +158 -0
- package/lib/node/session-catalog.d.ts +7 -3
- package/lib/node/session-catalog.js +15 -4
- package/lib/node/session-handles.d.ts +33 -0
- package/lib/node/session-handles.js +89 -0
- package/lib/node/session-info-util.d.ts +7 -0
- package/lib/node/session-info-util.js +62 -3
- package/lib/node/session-list-feed.d.ts +29 -0
- package/lib/node/session-list-feed.js +66 -0
- package/lib/node/sign-in/sign-in-flow.d.ts +2 -0
- package/lib/node/sign-in/sign-in-flow.js +10 -1
- package/lib/node/sign-in/sign-in-provider.js +3 -2
- package/lib/node/slash-command-util.d.ts +44 -0
- package/lib/node/slash-command-util.js +108 -0
- package/lib/node/ta-access.d.ts +11 -0
- package/lib/node/ta-access.js +29 -3
- package/lib/node/ta-errors.js +17 -2
- package/lib/node/ta-event-util.d.ts +19 -2
- package/lib/node/ta-event-util.js +97 -3
- package/lib/node/ta-server-impl.d.ts +13 -7
- package/lib/node/ta-server-impl.js +41 -22
- package/lib/node/ta-session-factory.d.ts +26 -2
- package/lib/node/ta-session-factory.js +65 -17
- package/lib/node/ta-session-registry.d.ts +16 -2
- package/lib/node/ta-session-registry.js +79 -20
- package/lib/node/ta-session.d.ts +16 -6
- package/lib/node/ta-session.js +59 -14
- package/lib/node/web-extension-catalog.d.ts +5 -1
- package/lib/node/web-extension-catalog.js +15 -19
- package/lib/node/web-extension-util.js +7 -3
- package/lib/node/workspace-files.d.ts +19 -5
- package/lib/node/workspace-files.js +26 -15
- package/lib/node/workspace-protocol.d.ts +1 -1
- package/lib/node/workspace-util.d.ts +2 -0
- package/lib/node/workspace-util.js +8 -3
- package/package.json +12 -12
|
@@ -130,11 +130,18 @@ let WebExtensionCatalogImpl = class WebExtensionCatalogImpl {
|
|
|
130
130
|
}
|
|
131
131
|
async packageOf(cwd, id) {
|
|
132
132
|
const { packages } = await this.load(cwd);
|
|
133
|
+
return web_extension_util_1.WebExtensionUtil.describePackage(this.findPackage(packages, id));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The package an id names: its id of listPackages, or the id of one of its web extensions. Every method of a
|
|
137
|
+
* package takes either, so that a client holding a web extension never looks for its package first.
|
|
138
|
+
*/
|
|
139
|
+
findPackage(packages, id, kind = 'package') {
|
|
133
140
|
const pkg = packages.find(candidate => web_extension_util_1.WebExtensionUtil.describePackage(candidate).id === id || web_extension_util_1.WebExtensionUtil.describe(candidate).some(info => info.id === id));
|
|
134
141
|
if (!pkg) {
|
|
135
|
-
throw ta_errors_1.TaErrors.invalidArgument(`No
|
|
142
|
+
throw ta_errors_1.TaErrors.invalidArgument(`No ${kind} has the id ${id}.`, 'listPackages lists the ones there are; the package may have moved or gone.');
|
|
136
143
|
}
|
|
137
|
-
return
|
|
144
|
+
return pkg;
|
|
138
145
|
}
|
|
139
146
|
/** A package another computer shared by a link, put in Ta's own temporary directory (RelayShareUtil). */
|
|
140
147
|
async fetchShare(link) {
|
|
@@ -159,12 +166,7 @@ let WebExtensionCatalogImpl = class WebExtensionCatalogImpl {
|
|
|
159
166
|
}
|
|
160
167
|
async findTemporary(cwd, id) {
|
|
161
168
|
const { packages } = await this.load(cwd);
|
|
162
|
-
|
|
163
|
-
(web_extension_util_1.WebExtensionUtil.describePackage(candidate).id === id || web_extension_util_1.WebExtensionUtil.describe(candidate).some(info => info.id === id)));
|
|
164
|
-
if (!pkg) {
|
|
165
|
-
throw ta_errors_1.TaErrors.invalidArgument(`No temporary package has the id ${id}.`, 'listPackages lists the ones there are; it may have been installed, removed or cleared.');
|
|
166
|
-
}
|
|
167
|
-
return pkg;
|
|
169
|
+
return this.findPackage(packages.filter(candidate => candidate.origin === 'temporary'), id, 'temporary package');
|
|
168
170
|
}
|
|
169
171
|
/** Ta's own directory is deleted, what pi fetched removed, a path of the user's only forgotten. */
|
|
170
172
|
async dropTemporary(record, manager) {
|
|
@@ -179,11 +181,7 @@ let WebExtensionCatalogImpl = class WebExtensionCatalogImpl {
|
|
|
179
181
|
}
|
|
180
182
|
async removePackage(cwd, id) {
|
|
181
183
|
const { packages, manager } = await this.load(cwd);
|
|
182
|
-
|
|
183
|
-
if (!pkg) {
|
|
184
|
-
throw ta_errors_1.TaErrors.invalidArgument(`No package has the id ${id}.`, 'listPackages lists the ones there are; the package may have moved or gone.');
|
|
185
|
-
}
|
|
186
|
-
await this.removeRoot(pkg, manager);
|
|
184
|
+
await this.removeRoot(this.findPackage(packages, id), manager);
|
|
187
185
|
}
|
|
188
186
|
async list(cwd) {
|
|
189
187
|
const { packages } = await this.load(cwd);
|
|
@@ -194,19 +192,17 @@ let WebExtensionCatalogImpl = class WebExtensionCatalogImpl {
|
|
|
194
192
|
const code = web_extension_util_1.WebExtensionUtil.read(pkg, info.entry);
|
|
195
193
|
return { id, hash: web_extension_util_1.WebExtensionUtil.hash(code), code };
|
|
196
194
|
}
|
|
197
|
-
async remove(cwd, id) {
|
|
198
|
-
const { pkg } = await this.find(cwd, id);
|
|
199
|
-
await this.removeRoot(pkg, (await this.load(cwd)).manager);
|
|
200
|
-
}
|
|
201
195
|
async setEnabled(cwd, nameOrId, enabled) {
|
|
202
196
|
if (ta_packages_1.TaPackages.builtins().some(pkg => pkg.name === nameOrId)) {
|
|
203
197
|
ta_packages_1.TaPackages.setEnabled(this.agentDir(), nameOrId, enabled);
|
|
204
198
|
return;
|
|
205
199
|
}
|
|
206
200
|
const loaded = await this.load(cwd);
|
|
207
|
-
const pkg = loaded.packages.find(candidate => candidate.origin !== 'builtin' &&
|
|
201
|
+
const pkg = loaded.packages.find(candidate => candidate.origin !== 'builtin' &&
|
|
202
|
+
candidate.origin !== 'temporary' &&
|
|
203
|
+
(web_extension_util_1.WebExtensionUtil.describePackage(candidate).id === nameOrId || web_extension_util_1.WebExtensionUtil.describe(candidate).some(info => info.id === nameOrId)));
|
|
208
204
|
if (!pkg) {
|
|
209
|
-
throw ta_errors_1.TaErrors.invalidArgument(`${nameOrId} is neither a package that comes with Ta nor the id of a package.`, 'Pass the name of a built-in package, or an id of listPackages.');
|
|
205
|
+
throw ta_errors_1.TaErrors.invalidArgument(`${nameOrId} is neither a package that comes with Ta nor the id of a package.`, 'Pass the name of a built-in package, or an id of listPackages or of one of its web extensions.');
|
|
210
206
|
}
|
|
211
207
|
const resources = package_switch_1.PackageSwitch.resourcesOf(await this.resolve(loaded.manager), pkg.root);
|
|
212
208
|
if (resources.length === 0) {
|
|
@@ -13,21 +13,25 @@ const PI_RESOURCES = ['extensions', 'skills', 'prompts', 'themes'];
|
|
|
13
13
|
var WebExtensionUtil;
|
|
14
14
|
(function (WebExtensionUtil) {
|
|
15
15
|
function describe(pkg) {
|
|
16
|
+
var _a;
|
|
16
17
|
const manifest = readManifest(pkg.root);
|
|
17
|
-
|
|
18
|
+
const lists = Array.isArray((_a = manifest === null || manifest === void 0 ? void 0 : manifest.pi) === null || _a === void 0 ? void 0 : _a.lists) ? manifest.pi.lists.filter((kind) => typeof kind === 'string' && kind !== '') : [];
|
|
19
|
+
return entries(pkg.root, manifest).map(entry => { var _a, _b, _c; var _d, _e; return ({
|
|
18
20
|
id: id(pkg, entry),
|
|
19
|
-
name: (
|
|
21
|
+
name: (_d = manifest === null || manifest === void 0 ? void 0 : manifest.name) !== null && _d !== void 0 ? _d : (0, node_path_1.basename)(pkg.root),
|
|
20
22
|
description: manifest === null || manifest === void 0 ? void 0 : manifest.description,
|
|
21
23
|
version: manifest === null || manifest === void 0 ? void 0 : manifest.version,
|
|
22
24
|
scope: pkg.scope,
|
|
23
25
|
origin: pkg.origin,
|
|
24
|
-
enabled: (
|
|
26
|
+
enabled: (_e = pkg.enabled) !== null && _e !== void 0 ? _e : true,
|
|
25
27
|
source: pkg.source,
|
|
26
28
|
entry,
|
|
27
29
|
hash: hash((0, node_fs_1.readFileSync)((0, node_path_1.join)(pkg.root, entry), 'utf8')),
|
|
28
30
|
title: text((_a = manifest === null || manifest === void 0 ? void 0 : manifest.pi) === null || _a === void 0 ? void 0 : _a.title),
|
|
29
31
|
icon: icon(manifest),
|
|
30
32
|
activation: pkg.temporary || ((_b = manifest === null || manifest === void 0 ? void 0 : manifest.pi) === null || _b === void 0 ? void 0 : _b.webActivation) === 'open' ? 'open' : 'startup',
|
|
33
|
+
...(typeof ((_c = manifest === null || manifest === void 0 ? void 0 : manifest.pi) === null || _c === void 0 ? void 0 : _c.category) === 'string' && manifest.pi.category ? { category: manifest.pi.category } : {}),
|
|
34
|
+
...(lists.length > 0 ? { lists } : {}),
|
|
31
35
|
...(pkg.temporary ? { temporary: pkg.temporary } : {}),
|
|
32
36
|
}); });
|
|
33
37
|
}
|
|
@@ -2,6 +2,12 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
|
2
2
|
import { type ExecEnvironment, ExecEnvironmentFactory, type FileStat } from '@celljs/ta-exec';
|
|
3
3
|
import { type Context, Middleware } from '@celljs/web/lib/node';
|
|
4
4
|
import { WorkspaceFiles } from './workspace-protocol';
|
|
5
|
+
interface ServedDirectory {
|
|
6
|
+
root: string;
|
|
7
|
+
cwd: string;
|
|
8
|
+
/** The name of the one file of `root` served: a file outside the directory of the conversation. */
|
|
9
|
+
only?: string;
|
|
10
|
+
}
|
|
5
11
|
export declare namespace WorkspaceFilesUtil {
|
|
6
12
|
function contentType(path: string): string;
|
|
7
13
|
/** `/api/files/<id>/<path>`; undefined for other URLs or a path that does not decode. */
|
|
@@ -23,20 +29,27 @@ export declare namespace WorkspaceFilesUtil {
|
|
|
23
29
|
/**
|
|
24
30
|
* Answers `GET /api/files/<id>/<path>` with the bytes of a file, without the token of ta serve: `<id>`
|
|
25
31
|
* stands for one directory, and only who has the token learns it (TaWorkspaceServer.fileUrl). Paths stay inside
|
|
26
|
-
* that directory; a directory answers its `index.html`. One range is served, so that videos seek.
|
|
32
|
+
* that directory; a directory answers its `index.html`. One range is served, so that videos seek. A file
|
|
33
|
+
* outside the directory of the conversation (a picture an agent left in `/tmp`) has an id of its own that
|
|
34
|
+
* stands for that file alone: the URL needs no token, so it must not open the directory the file is in
|
|
35
|
+
* (the home directory for `~/a.png`, with its keys) nor the pages of the workspace reach it.
|
|
27
36
|
*/
|
|
28
37
|
export declare class DefaultWorkspaceFiles implements WorkspaceFiles, Middleware {
|
|
29
38
|
/** Before TaAccess, which turns away `/api` requests without the token. */
|
|
30
39
|
readonly priority: number;
|
|
31
40
|
protected readonly environments: ExecEnvironmentFactory;
|
|
32
41
|
protected readonly host?: string;
|
|
33
|
-
|
|
42
|
+
/**
|
|
43
|
+
* By id, the directory paths stay in, the one whose execution environment reads them, and for a file
|
|
44
|
+
* outside the conversation's directory, the one path of `root` served.
|
|
45
|
+
*/
|
|
46
|
+
protected readonly directories: Map<string, ServedDirectory>;
|
|
34
47
|
protected readonly ids: Map<string, string>;
|
|
35
48
|
url(cwd: string, path: string): string;
|
|
36
49
|
handle(ctx: Context, next: () => Promise<void>): Promise<void>;
|
|
37
|
-
protected send(request: IncomingMessage, response: ServerResponse,
|
|
38
|
-
/** The file at `path`, or the `index.html` of the directory there. */
|
|
39
|
-
protected find(env: ExecEnvironment, path: string): Promise<{
|
|
50
|
+
protected send(request: IncomingMessage, response: ServerResponse, directory: ServedDirectory, path: string): Promise<void>;
|
|
51
|
+
/** The file at `path` of `root`, or the `index.html` of the directory there. */
|
|
52
|
+
protected find(env: ExecEnvironment, root: string, path: string): Promise<{
|
|
40
53
|
absolute: string;
|
|
41
54
|
stat: FileStat;
|
|
42
55
|
} | undefined>;
|
|
@@ -45,4 +58,5 @@ export declare class DefaultWorkspaceFiles implements WorkspaceFiles, Middleware
|
|
|
45
58
|
protected acceptsHost(request: IncomingMessage): boolean;
|
|
46
59
|
protected fail(response: ServerResponse, status: number): void;
|
|
47
60
|
}
|
|
61
|
+
export {};
|
|
48
62
|
//# sourceMappingURL=workspace-files.d.ts.map
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.DefaultWorkspaceFiles = exports.WorkspaceFilesUtil = void 0;
|
|
13
13
|
const node_crypto_1 = require("node:crypto");
|
|
14
14
|
const node_fs_1 = require("node:fs");
|
|
15
|
+
const node_path_1 = require("node:path");
|
|
15
16
|
const core_1 = require("@celljs/core");
|
|
16
17
|
const ta_exec_1 = require("@celljs/ta-exec");
|
|
17
18
|
const ta_protocol_1 = require("@celljs/ta-protocol");
|
|
@@ -120,24 +121,34 @@ var WorkspaceFilesUtil;
|
|
|
120
121
|
/**
|
|
121
122
|
* Answers `GET /api/files/<id>/<path>` with the bytes of a file, without the token of ta serve: `<id>`
|
|
122
123
|
* stands for one directory, and only who has the token learns it (TaWorkspaceServer.fileUrl). Paths stay inside
|
|
123
|
-
* that directory; a directory answers its `index.html`. One range is served, so that videos seek.
|
|
124
|
+
* that directory; a directory answers its `index.html`. One range is served, so that videos seek. A file
|
|
125
|
+
* outside the directory of the conversation (a picture an agent left in `/tmp`) has an id of its own that
|
|
126
|
+
* stands for that file alone: the URL needs no token, so it must not open the directory the file is in
|
|
127
|
+
* (the home directory for `~/a.png`, with its keys) nor the pages of the workspace reach it.
|
|
124
128
|
*/
|
|
125
129
|
let DefaultWorkspaceFiles = class DefaultWorkspaceFiles {
|
|
126
130
|
constructor() {
|
|
127
131
|
/** Before TaAccess, which turns away `/api` requests without the token. */
|
|
128
132
|
this.priority = ta_access_1.ACCESS_MIDDLEWARE_PRIORITY + 1;
|
|
133
|
+
/**
|
|
134
|
+
* By id, the directory paths stay in, the one whose execution environment reads them, and for a file
|
|
135
|
+
* outside the conversation's directory, the one path of `root` served.
|
|
136
|
+
*/
|
|
129
137
|
this.directories = new Map();
|
|
130
138
|
this.ids = new Map();
|
|
131
139
|
}
|
|
132
140
|
url(cwd, path) {
|
|
133
|
-
const
|
|
134
|
-
|
|
141
|
+
const absolute = (0, node_path_1.resolve)(cwd, path || '.');
|
|
142
|
+
const inside = workspace_util_1.WorkspaceUtil.contains(cwd, absolute);
|
|
143
|
+
const served = inside ? { root: cwd, cwd } : { root: (0, node_path_1.dirname)(absolute), cwd, only: (0, node_path_1.basename)(absolute) };
|
|
144
|
+
const key = `${cwd}\0${inside ? '' : absolute}`;
|
|
145
|
+
let id = this.ids.get(key);
|
|
135
146
|
if (!id) {
|
|
136
147
|
id = (0, node_crypto_1.randomBytes)(ID_BYTES).toString('base64url');
|
|
137
|
-
this.ids.set(
|
|
138
|
-
this.directories.set(id,
|
|
148
|
+
this.ids.set(key, id);
|
|
149
|
+
this.directories.set(id, served);
|
|
139
150
|
}
|
|
140
|
-
return WorkspaceFilesUtil.url(id, relative);
|
|
151
|
+
return WorkspaceFilesUtil.url(id, workspace_util_1.WorkspaceUtil.inside(served.root, absolute).relative);
|
|
141
152
|
}
|
|
142
153
|
async handle(ctx, next) {
|
|
143
154
|
const request = ctx.request;
|
|
@@ -147,8 +158,8 @@ let DefaultWorkspaceFiles = class DefaultWorkspaceFiles {
|
|
|
147
158
|
return;
|
|
148
159
|
}
|
|
149
160
|
const response = ctx.response;
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
161
|
+
const directory = this.directories.get(target.id);
|
|
162
|
+
if (!directory || !this.acceptsHost(request)) {
|
|
152
163
|
this.fail(response, 404);
|
|
153
164
|
return;
|
|
154
165
|
}
|
|
@@ -157,11 +168,11 @@ let DefaultWorkspaceFiles = class DefaultWorkspaceFiles {
|
|
|
157
168
|
this.fail(response, 405);
|
|
158
169
|
return;
|
|
159
170
|
}
|
|
160
|
-
await this.send(request, response,
|
|
171
|
+
await this.send(request, response, directory, target.path);
|
|
161
172
|
}
|
|
162
|
-
async send(request, response,
|
|
163
|
-
const env = this.environments.create(cwd);
|
|
164
|
-
const file = await this.find(env, path);
|
|
173
|
+
async send(request, response, directory, path) {
|
|
174
|
+
const env = this.environments.create(directory.cwd);
|
|
175
|
+
const file = directory.only === undefined || path === directory.only ? await this.find(env, directory.root, path) : undefined;
|
|
165
176
|
if (!file) {
|
|
166
177
|
this.fail(response, 404);
|
|
167
178
|
return;
|
|
@@ -208,11 +219,11 @@ let DefaultWorkspaceFiles = class DefaultWorkspaceFiles {
|
|
|
208
219
|
response.end(await this.read(env, absolute, stat.size, start, end));
|
|
209
220
|
}
|
|
210
221
|
}
|
|
211
|
-
/** The file at `path`, or the `index.html` of the directory there. */
|
|
212
|
-
async find(env, path) {
|
|
222
|
+
/** The file at `path` of `root`, or the `index.html` of the directory there. */
|
|
223
|
+
async find(env, root, path) {
|
|
213
224
|
let absolute;
|
|
214
225
|
try {
|
|
215
|
-
absolute = workspace_util_1.WorkspaceUtil.inside(
|
|
226
|
+
absolute = workspace_util_1.WorkspaceUtil.inside(root, path).absolute;
|
|
216
227
|
}
|
|
217
228
|
catch (_a) {
|
|
218
229
|
return undefined;
|
|
@@ -17,7 +17,7 @@ export interface TaWorkspace {
|
|
|
17
17
|
}
|
|
18
18
|
/** The bytes of workspace files over plain HTTP, for the page to show them as they are (TaWorkspaceServer.fileUrl). */
|
|
19
19
|
export interface WorkspaceFiles {
|
|
20
|
-
/** The URL of `path` of `cwd`;
|
|
20
|
+
/** The URL of `path` of `cwd`; a file outside `cwd` has a URL that serves it alone. */
|
|
21
21
|
url(cwd: string, path: string): string;
|
|
22
22
|
}
|
|
23
23
|
//# sourceMappingURL=workspace-protocol.d.ts.map
|
|
@@ -8,6 +8,8 @@ export declare namespace WorkspaceUtil {
|
|
|
8
8
|
absolute: string;
|
|
9
9
|
relative: string;
|
|
10
10
|
};
|
|
11
|
+
/** Whether `absolute` is `cwd` or inside it. */
|
|
12
|
+
function contains(cwd: string, absolute: string): boolean;
|
|
11
13
|
/** Joins a relative path of a directory with a name, with `/`. */
|
|
12
14
|
function join(dir: string, name: string): string;
|
|
13
15
|
/** Directories first, then by name as people sort (`file2` before `file10`). */
|
|
@@ -12,13 +12,18 @@ var WorkspaceUtil;
|
|
|
12
12
|
/** `path` inside `cwd`, absolute, and relative with `/`; throws when it leaves `cwd`. */
|
|
13
13
|
function inside(cwd, path) {
|
|
14
14
|
const absolute = (0, node_path_1.resolve)(cwd, path || '.');
|
|
15
|
-
|
|
16
|
-
if (rel === '..' || rel.startsWith(`..${node_path_1.sep}`) || (0, node_path_1.isAbsolute)(rel)) {
|
|
15
|
+
if (!contains(cwd, absolute)) {
|
|
17
16
|
throw ta_errors_1.TaErrors.invalidArgument(`The path ${path} is outside of ${cwd}.`, 'Pass a path inside the directory of the workspace.');
|
|
18
17
|
}
|
|
19
|
-
return { absolute, relative:
|
|
18
|
+
return { absolute, relative: (0, node_path_1.relative)(cwd, absolute).split(node_path_1.sep).join('/') };
|
|
20
19
|
}
|
|
21
20
|
WorkspaceUtil.inside = inside;
|
|
21
|
+
/** Whether `absolute` is `cwd` or inside it. */
|
|
22
|
+
function contains(cwd, absolute) {
|
|
23
|
+
const rel = (0, node_path_1.relative)(cwd, absolute);
|
|
24
|
+
return rel !== '..' && !rel.startsWith(`..${node_path_1.sep}`) && !(0, node_path_1.isAbsolute)(rel);
|
|
25
|
+
}
|
|
26
|
+
WorkspaceUtil.contains = contains;
|
|
22
27
|
/** Joins a relative path of a directory with a name, with `/`. */
|
|
23
28
|
function join(dir, name) {
|
|
24
29
|
return dir && dir !== '.' ? node_path_1.posix.join(dir, name) : name;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-host",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.11.0",
|
|
4
4
|
"description": "ta serve: pi sessions for many clients over WebSocket",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cell-component"
|
|
@@ -34,19 +34,19 @@
|
|
|
34
34
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@celljs/ai-agent": "4.
|
|
38
|
-
"@celljs/ai-coding-agent": "4.
|
|
39
|
-
"@celljs/core": "4.
|
|
40
|
-
"@celljs/rpc": "4.
|
|
41
|
-
"@celljs/ta-exec": "4.
|
|
42
|
-
"@celljs/ta-harness": "4.
|
|
43
|
-
"@celljs/ta-protocol": "4.
|
|
44
|
-
"@celljs/ta-relay": "4.
|
|
45
|
-
"@celljs/web": "4.
|
|
46
|
-
"@earendil-works/pi-coding-agent": "^1.5.
|
|
37
|
+
"@celljs/ai-agent": "4.11.0",
|
|
38
|
+
"@celljs/ai-coding-agent": "4.11.0",
|
|
39
|
+
"@celljs/core": "4.11.0",
|
|
40
|
+
"@celljs/rpc": "4.11.0",
|
|
41
|
+
"@celljs/ta-exec": "4.11.0",
|
|
42
|
+
"@celljs/ta-harness": "4.11.0",
|
|
43
|
+
"@celljs/ta-protocol": "4.11.0",
|
|
44
|
+
"@celljs/ta-relay": "4.11.0",
|
|
45
|
+
"@celljs/web": "4.11.0",
|
|
46
|
+
"@earendil-works/pi-coding-agent": "^1.5.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@earendil-works/pi-ai": "^1.5.
|
|
49
|
+
"@earendil-works/pi-ai": "^1.5.2"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|