@celljs/ta-protocol 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.
@@ -6,6 +6,7 @@ export * from './package-protocol.js';
6
6
  export * from './pi-types.js';
7
7
  export * from './relay-protocol.js';
8
8
  export * from './remote-protocol.js';
9
+ export * from './room-protocol.js';
9
10
  export * from './settings-protocol.js';
10
11
  export * from './ta-extension-host.js';
11
12
  export * from './ta-protocol.js';
@@ -6,6 +6,7 @@ export * from './package-protocol.js';
6
6
  export * from './pi-types.js';
7
7
  export * from './relay-protocol.js';
8
8
  export * from './remote-protocol.js';
9
+ export * from './room-protocol.js';
9
10
  export * from './settings-protocol.js';
10
11
  export * from './ta-extension-host.js';
11
12
  export * from './ta-protocol.js';
@@ -38,6 +38,16 @@ export interface TaWebExtensionInfo {
38
38
  * opens, `pi.webActivation` of its package.json. A temporary one always on `open`.
39
39
  */
40
40
  activation: 'startup' | 'open';
41
+ /**
42
+ * What kind of thing it is, `pi.category` of its package.json, for a page that lists those of a kind:
43
+ * `game` for games and what plays like one (the Games page of @celljs/ta-games lists them).
44
+ */
45
+ category?: string;
46
+ /**
47
+ * The kinds that a page of it lists, `pi.lists` of its package.json (`["game"]` for the Games page): the pages
48
+ * of extensions of those kinds are found there and in Quick open, not under Discover or in the navigation.
49
+ */
50
+ lists?: string[];
41
51
  /** For a temporary package. */
42
52
  temporary?: TaTemporaryInfo;
43
53
  }
@@ -100,12 +110,10 @@ export interface TaPackageServer {
100
110
  /** The web extensions of the packages pi loads in `cwd` (default: the server's directory). */
101
111
  listWebExtensions(cwd?: string): Promise<TaWebExtensionInfo[]>;
102
112
  readWebExtension(id: string, cwd?: string): Promise<TaWebExtensionSource>;
103
- /** Removes the package of a web extension: as `ta remove` for a package, deletes the directory for a directory. */
104
- removeWebExtension(id: string, cwd?: string): Promise<void>;
105
113
  /**
106
114
  * Turns a package on or off, what pi loads of it and its web extension; sessions pick it up on reload.
107
- * A built-in one by its name; another by its id of listPackages, as `ta config` turns each of its
108
- * resources on or off, in the settings of its scope.
115
+ * A built-in one by its name; another by its id (of listPackages, or of one of its web extensions), as
116
+ * `ta config` turns each of its resources on or off, in the settings of its scope.
109
117
  */
110
118
  setPackageEnabled(nameOrId: string, enabled: boolean, cwd?: string): Promise<void>;
111
119
  /** Every package pi loads in `cwd` (default: the server's directory), with a web extension or without. */
@@ -116,7 +124,10 @@ export interface TaPackageServer {
116
124
  * project. Sessions pick it up on reload.
117
125
  */
118
126
  installPackage(source: string, scope: TaSettingsScope, cwd?: string): Promise<void>;
119
- /** Removes a package of listPackages: as `ta remove` for a package of the setting, deletes the directory for a directory. */
127
+ /**
128
+ * Removes a package by its id of listPackages or of one of its web extensions: as `ta remove` for a package of
129
+ * the setting, deletes the directory for a directory, drops a temporary one. A built-in one is turned off instead.
130
+ */
120
131
  removePackage(id: string, cwd?: string): Promise<void>;
121
132
  /**
122
133
  * Calls a method of what the module of `pi.host` of a package that comes with Ta returned
@@ -0,0 +1,18 @@
1
+ /** What a secret is replaced with. */
2
+ export declare const REDACTED = "[redacted]";
3
+ /**
4
+ * What looks like a secret in what is shared (docs/design/ta-link.md 2.8): keys of model services and code hosts,
5
+ * tokens, private keys, passwords in assignments and in URLs. It errs on hiding: a shared conversation is read
6
+ * by others, and what it hides by mistake costs a word.
7
+ */
8
+ export declare class Redactor {
9
+ /** How many places were hidden. */
10
+ count: number;
11
+ text(text: string): string;
12
+ /** Strings of a value, deep, each cut to `max` characters. */
13
+ value(value: unknown, max: number): unknown;
14
+ static cut(text: string, max: number): string;
15
+ protected hide(): string;
16
+ /** What is plainly not a secret: an environment variable, a placeholder, what was hidden already. */
17
+ protected static placeholder(value: string): boolean;
18
+ }
@@ -0,0 +1,66 @@
1
+ /** What a secret is replaced with. */
2
+ export const REDACTED = '[redacted]';
3
+ /** Secrets that have a shape of their own: the whole match goes. */
4
+ const WHOLE = [
5
+ /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g,
6
+ /\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{20,}/g,
7
+ /\bgh[pousr]_[A-Za-z0-9]{30,}\b/g,
8
+ /\bgithub_pat_[A-Za-z0-9_]{40,}\b/g,
9
+ /\bglpat-[A-Za-z0-9_-]{20,}\b/g,
10
+ /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g,
11
+ /\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,
12
+ /\bAIza[0-9A-Za-z_-]{35}\b/g,
13
+ /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}/g,
14
+ ];
15
+ /** Secrets named by what is before them: what is before stays. */
16
+ const NAMED = [
17
+ /(\bBearer\s+)[A-Za-z0-9._~+/-]{16,}=*/gi,
18
+ /(\b[A-Za-z0-9_.-]*(?:password|passwd|pwd|secret|token|api[_-]?key|access[_-]?key|private[_-]?key)[A-Za-z0-9_.-]*["']?\s*[:=]\s*["']?)([^\s"'`,;]{6,})/gi,
19
+ /(:\/\/[^\s:/@]+:)([^\s@/]{3,})(@)/g,
20
+ ];
21
+ /**
22
+ * What looks like a secret in what is shared (docs/design/ta-link.md 2.8): keys of model services and code hosts,
23
+ * tokens, private keys, passwords in assignments and in URLs. It errs on hiding: a shared conversation is read
24
+ * by others, and what it hides by mistake costs a word.
25
+ */
26
+ export class Redactor {
27
+ constructor() {
28
+ /** How many places were hidden. */
29
+ this.count = 0;
30
+ }
31
+ text(text) {
32
+ let out = text;
33
+ for (const pattern of WHOLE) {
34
+ out = out.replace(pattern, () => this.hide());
35
+ }
36
+ out = out.replace(NAMED[0], (_match, before) => before + this.hide());
37
+ out = out.replace(NAMED[1], (match, before, value) => (Redactor.placeholder(value) ? match : before + this.hide()));
38
+ out = out.replace(NAMED[2], (_match, before, _value, after) => before + this.hide() + after);
39
+ return out;
40
+ }
41
+ /** Strings of a value, deep, each cut to `max` characters. */
42
+ value(value, max) {
43
+ if (typeof value === 'string') {
44
+ return Redactor.cut(this.text(value), max);
45
+ }
46
+ if (Array.isArray(value)) {
47
+ return value.map(item => this.value(item, max));
48
+ }
49
+ if (value && typeof value === 'object') {
50
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, this.value(item, max)]));
51
+ }
52
+ return value;
53
+ }
54
+ static cut(text, max) {
55
+ return text.length > max ? `${text.slice(0, max)}…` : text;
56
+ }
57
+ hide() {
58
+ this.count++;
59
+ return REDACTED;
60
+ }
61
+ /** What is plainly not a secret: an environment variable, a placeholder, what was hidden already. */
62
+ static placeholder(value) {
63
+ return /^(?:\$|<|\{|\[redacted|process\.env|os\.environ|xxx|\*{3})/i.test(value) || /^(?:true|false|null|undefined|none|string|number)$/i.test(value);
64
+ }
65
+ }
66
+ //# sourceMappingURL=redactor.js.map
@@ -43,3 +43,63 @@ export interface TaPackageShare {
43
43
  /** The largest package that goes, in bytes. */
44
44
  maxBytes: number;
45
45
  }
46
+ /**
47
+ * Who may open a link of content: anyone with it, anyone with it and its password, the one who shared it, or Ta friends of
48
+ * the one who shared it (`people`, TaRoomServer.listFriends), in their own Ta (docs/design/ta-link.md).
49
+ */
50
+ export type TaShareAccess = 'link' | 'password' | 'self' | 'people';
51
+ /** What is shared by a link: a conversation (`ta-conversation`, JSON) or a file (`file`, with its media type). */
52
+ export interface TaShareInput {
53
+ kind: string;
54
+ title: string;
55
+ /** The media type of a file. */
56
+ type?: string;
57
+ data: Uint8Array;
58
+ access: TaShareAccess;
59
+ /** For `password`; not kept. */
60
+ password?: string;
61
+ /** For `people`: the ids of the Ta friends (TaFriend.id). */
62
+ people?: string[];
63
+ /** None or 0: until stopped. With `offline`, 30 at most. */
64
+ days?: number;
65
+ /** A copy sealed on the relay, for while this computer is off. */
66
+ offline?: boolean;
67
+ }
68
+ /** Content this ta serve shares. */
69
+ export interface TaShareInfo {
70
+ id: string;
71
+ kind: string;
72
+ title: string;
73
+ type?: string;
74
+ access: TaShareAccess;
75
+ size: number;
76
+ createdAt: number;
77
+ expiresAt?: number;
78
+ offline: boolean;
79
+ /** `https://<relay>/s#…`, its key in the fragment. */
80
+ link: string;
81
+ /** For `people`: the names of the Ta friends it is shared with. */
82
+ people?: string[];
83
+ }
84
+ /** What a link shares, opened. */
85
+ export interface TaSharedContent {
86
+ kind: string;
87
+ title: string;
88
+ type?: string;
89
+ createdAt: number;
90
+ data: Uint8Array;
91
+ }
92
+ /**
93
+ * Content shared by links, through the relay (TaExtensionHost.shares): made, listed and stopped here, and opened
94
+ * whoever shared it. `open` rejects with an error whose `reason` says why (RelayContentFailure of @celljs/ta-relay:
95
+ * `password`, `wrong`, `busy`, `gone`, `offline`, `self`, `people`, `invalid`, `timeout`, `large`).
96
+ */
97
+ export interface TaShares {
98
+ create(input: TaShareInput): Promise<TaShareInfo>;
99
+ /** Those still on, the latest first. */
100
+ list(): Promise<TaShareInfo[]>;
101
+ /** Its link no longer works, at once, and its copy on the relay is deleted. False when there was none. */
102
+ remove(id: string): Promise<boolean>;
103
+ /** What a link shares: one of this ta serve read here (a link for `self` too), another fetched through the relay. */
104
+ open(link: string, password?: string): Promise<TaSharedContent>;
105
+ }
@@ -0,0 +1,166 @@
1
+ export declare const TaRoomServer: unique symbol;
2
+ export declare const TA_ROOM_SERVICE = "TaRoomServer";
3
+ /**
4
+ * Rooms of Ta (docs/design/ta-link.md 3): a place several Ta share, through the relay, end to end: they send each other
5
+ * messages and keep a shared state, which the relay keeps sealed. One makes a room and invites by a link; one with the
6
+ * link asks to join, and is in once the owner said so, in their own Ta.
7
+ */
8
+ /** `member` in the room; `waiting` for the owner to answer; `refused` by the owner; `gone`: closed, removed, or the invitation no longer works. */
9
+ export type TaRoomStatus = 'member' | 'waiting' | 'refused' | 'gone';
10
+ /** Who a Ta is to others: the id of its keys, and the name it gives. */
11
+ export interface TaIdentity {
12
+ id: string;
13
+ name: string;
14
+ }
15
+ export interface TaRoomMember {
16
+ /** Its id in this room alone: what messages say they are `from`, and `to` sends to. */
17
+ member: string;
18
+ /** The identity of its Ta. */
19
+ id: string;
20
+ name: string;
21
+ owner: boolean;
22
+ online: boolean;
23
+ self: boolean;
24
+ /** In a browser, without Ta (docs/design/ta-link.md 3.8): it only chats, and is no Ta friend. */
25
+ guest?: boolean;
26
+ }
27
+ export interface TaRoomInfo {
28
+ id: string;
29
+ /** What the extension that made it calls such rooms (`ta-town`): it finds its rooms by it. */
30
+ kind: string;
31
+ title: string;
32
+ /** The view that shows it (`ui.showView`), as the extension that made it said. */
33
+ view?: string;
34
+ /** This Ta made it. */
35
+ owner: boolean;
36
+ ownerName: string;
37
+ status: TaRoomStatus;
38
+ /** Why it is `gone`: `closed` by the owner, `removed` by the owner, the `invite` no longer works. */
39
+ reason?: 'closed' | 'removed' | 'invite';
40
+ /** Connected to the room now. */
41
+ connected: boolean;
42
+ members: TaRoomMember[];
43
+ createdAt: number;
44
+ joinedAt?: number;
45
+ }
46
+ /** One asking to join a room of this Ta: for the user to answer. */
47
+ export interface TaRoomRequest {
48
+ room: string;
49
+ title: string;
50
+ ask: string;
51
+ /** Its identity, and the name it gives. */
52
+ id: string;
53
+ name: string;
54
+ /** Met before, in another room. */
55
+ friend: boolean;
56
+ /** Asks from a browser, without Ta: admitted, it only chats. */
57
+ guest?: boolean;
58
+ at: number;
59
+ }
60
+ /** One met in a room. */
61
+ export interface TaFriend extends TaIdentity {
62
+ /** Titles of rooms shared, the latest last. */
63
+ rooms: string[];
64
+ metAt: number;
65
+ seenAt: number;
66
+ }
67
+ export interface TaRoomValue {
68
+ value: unknown;
69
+ version: number;
70
+ /** The member who wrote it last. */
71
+ by: string;
72
+ }
73
+ /** What happens in the rooms, to the connections that called TaRoomServer.watch. */
74
+ export type TaRoomEvent =
75
+ /** The list, a room's members, who is online, or a room's status changed: read it again. */
76
+ {
77
+ type: 'rooms';
78
+ } | {
79
+ type: 'request';
80
+ request: TaRoomRequest;
81
+ } | {
82
+ type: 'message';
83
+ room: string;
84
+ from: string;
85
+ name: string;
86
+ data: unknown;
87
+ } | {
88
+ type: 'state';
89
+ room: string;
90
+ key: string;
91
+ value: unknown;
92
+ version: number;
93
+ by: string;
94
+ };
95
+ export interface TaRoomServer {
96
+ /** This Ta as others see it; made the first time. */
97
+ getIdentity(): Promise<TaIdentity>;
98
+ setName(name: string): Promise<TaIdentity>;
99
+ listRooms(): Promise<TaRoomInfo[]>;
100
+ createRoom(input: {
101
+ kind: string;
102
+ title: string;
103
+ view?: string;
104
+ }): Promise<TaRoomInfo>;
105
+ /**
106
+ * The link others ask to join by (the owner only): the one of before while it has a day left; else, or with `renew`,
107
+ * a new one for `days` (7 by default, 30 at most), and the links of before stop working.
108
+ */
109
+ invite(room: string, options?: {
110
+ days?: number;
111
+ renew?: boolean;
112
+ }): Promise<{
113
+ link: string;
114
+ expiresAt: number;
115
+ }>;
116
+ /** Asks to join the room of a link: `waiting` till its owner answers. Ask the user first. */
117
+ join(link: string): Promise<TaRoomInfo>;
118
+ /** Those asking to join the rooms of this Ta. */
119
+ listRequests(): Promise<TaRoomRequest[]>;
120
+ /** The user's answer to one asking to join. Only ever on the user's word, never on an agent's. */
121
+ answer(room: string, ask: string, accept: boolean): Promise<void>;
122
+ /** The owner takes a member out. */
123
+ removeMember(room: string, member: string): Promise<void>;
124
+ /** Leaves the room; its owner closes it for everyone. A room asked to join, refused or gone is forgotten. */
125
+ leave(room: string): Promise<void>;
126
+ /** To every other member, or to one (`to`, its member id): JSON, 64 KB at most. */
127
+ send(room: string, data: unknown, to?: string): Promise<void>;
128
+ /** The shared state, by its keys; with `prefix`, only the keys that start with it (`chat:`), not all a game keeps. */
129
+ getState(room: string, prefix?: string): Promise<Record<string, TaRoomValue>>;
130
+ /**
131
+ * Sets a key (`null` clears it); with `version`, only if it is still that version (0: not set), else `ok` is false
132
+ * and `version` says what it is: read it again, and set it again. A value is 64 KB at most.
133
+ */
134
+ setState(room: string, key: string, value: unknown, version?: number): Promise<{
135
+ ok: boolean;
136
+ version: number;
137
+ }>;
138
+ listFriends(): Promise<TaFriend[]>;
139
+ removeFriend(id: string): Promise<boolean>;
140
+ /**
141
+ * This connection hears TaRoomEvent (TaClient.onRoomEvent) from now on; again after it connected again. Without
142
+ * `messages`, only `rooms` and `request`: messages and the state come often (a game's), for a page that shows them;
143
+ * with `state`, also the state of the keys that start with one of them (`chat:`), not the messages, for a list
144
+ * that shows what was said last.
145
+ */
146
+ watch(messages?: boolean, state?: string[]): Promise<void>;
147
+ /** No more: messages of rooms come often (a game's), and need not go to a page that shows none. */
148
+ unwatch(): Promise<void>;
149
+ }
150
+ /** What a connection or a listener hears of the rooms (TaRoomServer.watch). */
151
+ export interface TaRoomWatch {
152
+ messages: boolean;
153
+ /** Prefixes of keys whose state it hears without `messages`. */
154
+ state: string[];
155
+ }
156
+ export declare namespace TaRoomWatchUtil {
157
+ function of(messages: boolean | undefined, state: unknown): TaRoomWatch;
158
+ /** All that several want: messages if one does, the prefixes of all. */
159
+ function union(watches: Iterable<TaRoomWatch>): TaRoomWatch;
160
+ function same(a: TaRoomWatch | undefined, b: TaRoomWatch | undefined): boolean;
161
+ function hears(watch: TaRoomWatch, event: TaRoomEvent): boolean;
162
+ }
163
+ /** The rooms for the server side of packages (TaExtensionHost.rooms): TaRoomServer, its events heard directly. */
164
+ export interface TaRooms extends Omit<TaRoomServer, 'watch' | 'unwatch'> {
165
+ onEvent(listener: (event: TaRoomEvent) => void): () => void;
166
+ }
@@ -0,0 +1,36 @@
1
+ export const TaRoomServer = Symbol('TaRoomServer');
2
+ export const TA_ROOM_SERVICE = 'TaRoomServer';
3
+ export var TaRoomWatchUtil;
4
+ (function (TaRoomWatchUtil) {
5
+ function of(messages, state) {
6
+ const prefixes = Array.isArray(state) ? state.filter((prefix) => typeof prefix === 'string' && prefix.length > 0) : [];
7
+ return { messages: messages !== false, state: [...new Set(prefixes)].sort() };
8
+ }
9
+ TaRoomWatchUtil.of = of;
10
+ /** All that several want: messages if one does, the prefixes of all. */
11
+ function union(watches) {
12
+ let messages = false;
13
+ const state = [];
14
+ for (const watch of watches) {
15
+ messages || (messages = watch.messages);
16
+ state.push(...watch.state);
17
+ }
18
+ return of(messages, messages ? [] : state);
19
+ }
20
+ TaRoomWatchUtil.union = union;
21
+ function same(a, b) {
22
+ return a === b || (!!a && !!b && a.messages === b.messages && a.state.join('\n') === b.state.join('\n'));
23
+ }
24
+ TaRoomWatchUtil.same = same;
25
+ function hears(watch, event) {
26
+ if (event.type === 'message') {
27
+ return watch.messages;
28
+ }
29
+ if (event.type === 'state') {
30
+ return watch.messages || watch.state.some(prefix => event.key.startsWith(prefix));
31
+ }
32
+ return true;
33
+ }
34
+ TaRoomWatchUtil.hears = hears;
35
+ })(TaRoomWatchUtil || (TaRoomWatchUtil = {}));
36
+ //# sourceMappingURL=room-protocol.js.map
@@ -1,4 +1,6 @@
1
1
  import type { TaPackageServer } from './package-protocol.js';
2
+ import type { TaShares } from './relay-protocol.js';
3
+ import type { TaRooms } from './room-protocol.js';
2
4
  import type { TaServer } from './ta-protocol.js';
3
5
  /**
4
6
  * What `ta serve` gives the server side of a package: the sessions and the data of packages, in its own
@@ -10,6 +12,17 @@ export interface TaExtensionHost extends Pick<TaServer, 'getServerInfo' | 'listS
10
12
  readonly agentDir: string;
11
13
  /** Where the conversation of a session file works, as clients name it (a path or an `ssh://` location), without opening it; undefined when it cannot be read. */
12
14
  sessionCwd(sessionFile: string): Promise<string | undefined>;
15
+ /** Content shared by links, through the relay (docs/design/ta-link.md). */
16
+ readonly shares: TaShares;
17
+ /** Rooms shared with other Ta, through the relay (docs/design/ta-link.md 3). */
18
+ readonly rooms: TaRooms;
19
+ /** pi's messages of a session file, of the branch it is on (its first message first), without opening it. */
20
+ sessionMessages(sessionFile: string): Promise<unknown[]>;
21
+ /**
22
+ * A new conversation of `cwd` holding these messages of pi (an assistant's among them), named `name`: its session
23
+ * file, to open with `openSession`. As a conversation brought from elsewhere (a link of another Ta).
24
+ */
25
+ createSession(cwd: string, messages: readonly unknown[], name?: string): Promise<string>;
13
26
  /** Keys of the data of a package that changed, by a page or by the server, as they change; `cwd` for a key of a directory. */
14
27
  onExtensionData(listener: (name: string, key: string, cwd?: string) => void): () => void;
15
28
  }
@@ -34,6 +47,21 @@ export type TaPackageHostFactory = (host: TaExtensionHost) => TaPackageService |
34
47
  * and the extension should say its tools need `ta serve`.
35
48
  */
36
49
  export declare const TA_HOST_EVENT = "ta:host";
50
+ /**
51
+ * How a pi extension reaches the host of its package. Import it from `@celljs/ta-protocol/lib/common/ta-extension-host`
52
+ * in a bundle: this file has nothing else to run, where the whole protocol would come along with its index.
53
+ */
54
+ export declare namespace TaHostUtil {
55
+ /**
56
+ * Under `ta serve` the host answers at once; under `ta` alone nobody answers. The timer also keeps the process
57
+ * alive meanwhile: a tool waiting for the host in `ta -p` would otherwise end it.
58
+ */
59
+ const WAIT_MS = 1000;
60
+ /** Asks for the host of the package `name` (TA_HOST_EVENT); undefined when nobody answers: not under `ta serve`. */
61
+ function reach(events: {
62
+ emit(event: string, data: unknown): void;
63
+ }, name: string, waitMs?: number): Promise<TaHostAnswer | undefined>;
64
+ }
37
65
  /**
38
66
  * The event of pi's `pi.events` by which an extension whose tools change files without pi's `edit` and
39
67
  * `write` (another coding agent's own tools, ta-agents) says which, as soon as it knows and before the
@@ -5,6 +5,33 @@
5
5
  * and the extension should say its tools need `ta serve`.
6
6
  */
7
7
  export const TA_HOST_EVENT = 'ta:host';
8
+ /**
9
+ * How a pi extension reaches the host of its package. Import it from `@celljs/ta-protocol/lib/common/ta-extension-host`
10
+ * in a bundle: this file has nothing else to run, where the whole protocol would come along with its index.
11
+ */
12
+ export var TaHostUtil;
13
+ (function (TaHostUtil) {
14
+ /**
15
+ * Under `ta serve` the host answers at once; under `ta` alone nobody answers. The timer also keeps the process
16
+ * alive meanwhile: a tool waiting for the host in `ta -p` would otherwise end it.
17
+ */
18
+ TaHostUtil.WAIT_MS = 1000;
19
+ /** Asks for the host of the package `name` (TA_HOST_EVENT); undefined when nobody answers: not under `ta serve`. */
20
+ function reach(events, name, waitMs = TaHostUtil.WAIT_MS) {
21
+ return new Promise(resolve => {
22
+ const timer = setTimeout(() => resolve(undefined), waitMs);
23
+ const request = {
24
+ name,
25
+ resolve: answer => {
26
+ clearTimeout(timer);
27
+ resolve(answer);
28
+ },
29
+ };
30
+ events.emit(TA_HOST_EVENT, request);
31
+ });
32
+ }
33
+ TaHostUtil.reach = reach;
34
+ })(TaHostUtil || (TaHostUtil = {}));
8
35
  /**
9
36
  * The event of pi's `pi.events` by which an extension whose tools change files without pi's `edit` and
10
37
  * `write` (another coding agent's own tools, ta-agents) says which, as soon as it knows and before the