@celljs/ta-host 4.10.0 → 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.
Files changed (83) hide show
  1. package/README.en.md +4 -4
  2. package/README.md +4 -4
  3. package/esm/node/client-tool-broker.d.ts +6 -2
  4. package/esm/node/client-tool-broker.js +11 -4
  5. package/esm/node/host-protocol.d.ts +12 -7
  6. package/esm/node/index.d.ts +1 -0
  7. package/esm/node/index.js +1 -0
  8. package/esm/node/package-hosts.d.ts +6 -0
  9. package/esm/node/package-hosts.js +36 -1
  10. package/esm/node/package-server-impl.d.ts +0 -1
  11. package/esm/node/package-server-impl.js +0 -3
  12. package/esm/node/relay-bridge.d.ts +12 -2
  13. package/esm/node/relay-bridge.js +93 -3
  14. package/esm/node/rooms-bridge.d.ts +60 -0
  15. package/esm/node/rooms-bridge.js +155 -0
  16. package/esm/node/session-catalog.d.ts +7 -3
  17. package/esm/node/session-catalog.js +12 -4
  18. package/esm/node/session-info-util.d.ts +2 -1
  19. package/esm/node/session-info-util.js +34 -7
  20. package/esm/node/session-list-feed.d.ts +28 -0
  21. package/esm/node/session-list-feed.js +62 -0
  22. package/esm/node/sign-in/sign-in-flow.d.ts +2 -0
  23. package/esm/node/sign-in/sign-in-flow.js +9 -0
  24. package/esm/node/sign-in/sign-in-provider.js +3 -2
  25. package/esm/node/slash-command-util.d.ts +43 -0
  26. package/esm/node/slash-command-util.js +105 -0
  27. package/esm/node/ta-event-util.d.ts +9 -2
  28. package/esm/node/ta-event-util.js +31 -5
  29. package/esm/node/ta-server-impl.d.ts +13 -5
  30. package/esm/node/ta-server-impl.js +34 -16
  31. package/esm/node/ta-session-factory.d.ts +16 -1
  32. package/esm/node/ta-session-factory.js +42 -14
  33. package/esm/node/ta-session-registry.d.ts +4 -1
  34. package/esm/node/ta-session-registry.js +8 -0
  35. package/esm/node/ta-session.d.ts +8 -2
  36. package/esm/node/ta-session.js +41 -4
  37. package/esm/node/web-extension-catalog.d.ts +5 -1
  38. package/esm/node/web-extension-catalog.js +15 -19
  39. package/esm/node/web-extension-util.js +7 -3
  40. package/esm/node/workspace-files.d.ts +16 -12
  41. package/esm/node/workspace-files.js +14 -10
  42. package/esm/node/workspace-protocol.d.ts +1 -1
  43. package/lib/node/client-tool-broker.d.ts +6 -2
  44. package/lib/node/client-tool-broker.js +11 -4
  45. package/lib/node/host-protocol.d.ts +12 -7
  46. package/lib/node/index.d.ts +1 -0
  47. package/lib/node/index.js +1 -0
  48. package/lib/node/package-hosts.d.ts +6 -0
  49. package/lib/node/package-hosts.js +35 -0
  50. package/lib/node/package-server-impl.d.ts +0 -1
  51. package/lib/node/package-server-impl.js +0 -3
  52. package/lib/node/relay-bridge.d.ts +12 -2
  53. package/lib/node/relay-bridge.js +91 -1
  54. package/lib/node/rooms-bridge.d.ts +61 -0
  55. package/lib/node/rooms-bridge.js +158 -0
  56. package/lib/node/session-catalog.d.ts +7 -3
  57. package/lib/node/session-catalog.js +12 -4
  58. package/lib/node/session-info-util.d.ts +2 -1
  59. package/lib/node/session-info-util.js +34 -7
  60. package/lib/node/session-list-feed.d.ts +29 -0
  61. package/lib/node/session-list-feed.js +66 -0
  62. package/lib/node/sign-in/sign-in-flow.d.ts +2 -0
  63. package/lib/node/sign-in/sign-in-flow.js +10 -1
  64. package/lib/node/sign-in/sign-in-provider.js +3 -2
  65. package/lib/node/slash-command-util.d.ts +44 -0
  66. package/lib/node/slash-command-util.js +108 -0
  67. package/lib/node/ta-event-util.d.ts +9 -2
  68. package/lib/node/ta-event-util.js +31 -5
  69. package/lib/node/ta-server-impl.d.ts +13 -5
  70. package/lib/node/ta-server-impl.js +32 -14
  71. package/lib/node/ta-session-factory.d.ts +16 -1
  72. package/lib/node/ta-session-factory.js +42 -14
  73. package/lib/node/ta-session-registry.d.ts +4 -1
  74. package/lib/node/ta-session-registry.js +8 -0
  75. package/lib/node/ta-session.d.ts +8 -2
  76. package/lib/node/ta-session.js +41 -4
  77. package/lib/node/web-extension-catalog.d.ts +5 -1
  78. package/lib/node/web-extension-catalog.js +15 -19
  79. package/lib/node/web-extension-util.js +7 -3
  80. package/lib/node/workspace-files.d.ts +16 -12
  81. package/lib/node/workspace-files.js +13 -9
  82. package/lib/node/workspace-protocol.d.ts +1 -1
  83. package/package.json +10 -10
@@ -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
- return entries(pkg.root, manifest).map(entry => { var _a, _b; var _c, _d; return ({
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: (_c = manifest === null || manifest === void 0 ? void 0 : manifest.name) !== null && _c !== void 0 ? _c : (0, node_path_1.basename)(pkg.root),
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: (_d = pkg.enabled) !== null && _d !== void 0 ? _d : true,
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. */
@@ -24,27 +30,24 @@ export declare namespace WorkspaceFilesUtil {
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
32
  * that directory; a directory answers its `index.html`. One range is served, so that videos seek. A file
27
- * outside the directory of the conversation (a picture an agent left in `/tmp`) has the directory it is in
28
- * as its own: who has the token runs programs there anyway, and the pages of the workspace still cannot
29
- * reach it.
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.
30
36
  */
31
37
  export declare class DefaultWorkspaceFiles implements WorkspaceFiles, Middleware {
32
38
  /** Before TaAccess, which turns away `/api` requests without the token. */
33
39
  readonly priority: number;
34
40
  protected readonly environments: ExecEnvironmentFactory;
35
41
  protected readonly host?: string;
36
- /** By id, the directory paths stay in, and the one whose execution environment reads them. */
37
- protected readonly directories: Map<string, {
38
- root: string;
39
- cwd: string;
40
- }>;
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>;
41
47
  protected readonly ids: Map<string, string>;
42
48
  url(cwd: string, path: string): string;
43
49
  handle(ctx: Context, next: () => Promise<void>): Promise<void>;
44
- protected send(request: IncomingMessage, response: ServerResponse, directory: {
45
- root: string;
46
- cwd: string;
47
- }, path: string): Promise<void>;
50
+ protected send(request: IncomingMessage, response: ServerResponse, directory: ServedDirectory, path: string): Promise<void>;
48
51
  /** The file at `path` of `root`, or the `index.html` of the directory there. */
49
52
  protected find(env: ExecEnvironment, root: string, path: string): Promise<{
50
53
  absolute: string;
@@ -55,4 +58,5 @@ export declare class DefaultWorkspaceFiles implements WorkspaceFiles, Middleware
55
58
  protected acceptsHost(request: IncomingMessage): boolean;
56
59
  protected fail(response: ServerResponse, status: number): void;
57
60
  }
61
+ export {};
58
62
  //# sourceMappingURL=workspace-files.d.ts.map
@@ -122,29 +122,33 @@ var WorkspaceFilesUtil;
122
122
  * Answers `GET /api/files/<id>/<path>` with the bytes of a file, without the token of ta serve: `<id>`
123
123
  * stands for one directory, and only who has the token learns it (TaWorkspaceServer.fileUrl). Paths stay inside
124
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 the directory it is in
126
- * as its own: who has the token runs programs there anyway, and the pages of the workspace still cannot
127
- * reach it.
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.
128
128
  */
129
129
  let DefaultWorkspaceFiles = class DefaultWorkspaceFiles {
130
130
  constructor() {
131
131
  /** Before TaAccess, which turns away `/api` requests without the token. */
132
132
  this.priority = ta_access_1.ACCESS_MIDDLEWARE_PRIORITY + 1;
133
- /** By id, the directory paths stay in, and the one whose execution environment reads them. */
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
+ */
134
137
  this.directories = new Map();
135
138
  this.ids = new Map();
136
139
  }
137
140
  url(cwd, path) {
138
141
  const absolute = (0, node_path_1.resolve)(cwd, path || '.');
139
- const root = workspace_util_1.WorkspaceUtil.contains(cwd, absolute) ? cwd : (0, node_path_1.dirname)(absolute);
140
- const key = `${cwd}\0${root}`;
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}`;
141
145
  let id = this.ids.get(key);
142
146
  if (!id) {
143
147
  id = (0, node_crypto_1.randomBytes)(ID_BYTES).toString('base64url');
144
148
  this.ids.set(key, id);
145
- this.directories.set(id, { root, cwd });
149
+ this.directories.set(id, served);
146
150
  }
147
- return WorkspaceFilesUtil.url(id, workspace_util_1.WorkspaceUtil.inside(root, absolute).relative);
151
+ return WorkspaceFilesUtil.url(id, workspace_util_1.WorkspaceUtil.inside(served.root, absolute).relative);
148
152
  }
149
153
  async handle(ctx, next) {
150
154
  const request = ctx.request;
@@ -168,7 +172,7 @@ let DefaultWorkspaceFiles = class DefaultWorkspaceFiles {
168
172
  }
169
173
  async send(request, response, directory, path) {
170
174
  const env = this.environments.create(directory.cwd);
171
- const file = await this.find(env, directory.root, path);
175
+ const file = directory.only === undefined || path === directory.only ? await this.find(env, directory.root, path) : undefined;
172
176
  if (!file) {
173
177
  this.fail(response, 404);
174
178
  return;
@@ -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`; a file outside `cwd` is served from the directory it is in. */
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-host",
3
- "version": "4.10.0",
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,15 +34,15 @@
34
34
  "watch": "tsc -b -w --preserveWatchOutput"
35
35
  },
36
36
  "dependencies": {
37
- "@celljs/ai-agent": "4.10.0",
38
- "@celljs/ai-coding-agent": "4.10.0",
39
- "@celljs/core": "4.10.0",
40
- "@celljs/rpc": "4.10.0",
41
- "@celljs/ta-exec": "4.10.0",
42
- "@celljs/ta-harness": "4.10.0",
43
- "@celljs/ta-protocol": "4.10.0",
44
- "@celljs/ta-relay": "4.10.0",
45
- "@celljs/web": "4.10.0",
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
46
  "@earendil-works/pi-coding-agent": "^1.5.2"
47
47
  },
48
48
  "devDependencies": {