@celljs/ta-protocol 4.16.0 → 4.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/esm/common/access-protocol.d.ts +41 -0
  2. package/esm/common/access-protocol.js +7 -0
  3. package/esm/common/app-protocol.d.ts +120 -0
  4. package/esm/common/app-protocol.js +213 -0
  5. package/esm/common/delegate-protocol.d.ts +30 -0
  6. package/esm/common/delegate-protocol.js +52 -0
  7. package/esm/common/deployment-protocol.d.ts +72 -0
  8. package/esm/common/deployment-protocol.js +171 -0
  9. package/esm/common/error-protocol.d.ts +42 -0
  10. package/esm/common/error-protocol.js +45 -0
  11. package/esm/common/event-protocol.d.ts +63 -0
  12. package/esm/common/event-protocol.js +2 -0
  13. package/esm/common/gateway-protocol.d.ts +29 -0
  14. package/esm/common/index.d.ts +11 -0
  15. package/esm/common/index.js +11 -0
  16. package/esm/common/message-protocol.d.ts +134 -0
  17. package/esm/common/message-protocol.js +322 -0
  18. package/esm/common/page-protocol.d.ts +56 -0
  19. package/esm/common/page-protocol.js +12 -0
  20. package/esm/common/path-map.d.ts +24 -0
  21. package/esm/common/path-map.js +127 -0
  22. package/esm/common/presence-protocol.js +1 -1
  23. package/esm/common/redactor.d.ts +12 -0
  24. package/esm/common/redactor.js +49 -11
  25. package/esm/common/relay-protocol.d.ts +20 -0
  26. package/esm/common/room-protocol.d.ts +52 -1
  27. package/esm/common/said-protocol.d.ts +76 -0
  28. package/esm/common/said-protocol.js +239 -0
  29. package/esm/common/screen-share-protocol.d.ts +304 -0
  30. package/esm/common/screen-share-protocol.js +88 -0
  31. package/esm/common/settings-protocol.d.ts +8 -0
  32. package/esm/common/settings-protocol.js +2 -0
  33. package/esm/common/ta-extension-host.d.ts +64 -1
  34. package/esm/common/ta-extension-host.js +8 -0
  35. package/esm/common/ta-protocol.d.ts +53 -175
  36. package/esm/common/ta-protocol.js +0 -234
  37. package/esm/common/team-protocol.d.ts +13 -2
  38. package/esm/common/team-protocol.js +27 -2
  39. package/esm/common/voice-protocol.d.ts +184 -0
  40. package/esm/common/voice-protocol.js +57 -0
  41. package/lib/common/access-protocol.d.ts +41 -0
  42. package/lib/common/access-protocol.js +8 -1
  43. package/lib/common/app-protocol.d.ts +121 -0
  44. package/lib/common/app-protocol.js +216 -0
  45. package/lib/common/delegate-protocol.d.ts +31 -0
  46. package/lib/common/delegate-protocol.js +55 -0
  47. package/lib/common/deployment-protocol.d.ts +73 -0
  48. package/lib/common/deployment-protocol.js +175 -0
  49. package/lib/common/error-protocol.d.ts +43 -0
  50. package/lib/common/error-protocol.js +48 -0
  51. package/lib/common/event-protocol.d.ts +64 -0
  52. package/lib/common/event-protocol.js +3 -0
  53. package/lib/common/gateway-protocol.d.ts +29 -0
  54. package/lib/common/index.d.ts +11 -0
  55. package/lib/common/index.js +11 -0
  56. package/lib/common/message-protocol.d.ts +135 -0
  57. package/lib/common/message-protocol.js +325 -0
  58. package/lib/common/page-protocol.d.ts +57 -0
  59. package/lib/common/page-protocol.js +15 -0
  60. package/lib/common/path-map.d.ts +25 -0
  61. package/lib/common/path-map.js +130 -0
  62. package/lib/common/presence-protocol.js +7 -7
  63. package/lib/common/redactor.d.ts +12 -0
  64. package/lib/common/redactor.js +49 -11
  65. package/lib/common/relay-protocol.d.ts +20 -0
  66. package/lib/common/room-protocol.d.ts +52 -1
  67. package/lib/common/said-protocol.d.ts +77 -0
  68. package/lib/common/said-protocol.js +242 -0
  69. package/lib/common/screen-share-protocol.d.ts +305 -0
  70. package/lib/common/screen-share-protocol.js +91 -0
  71. package/lib/common/settings-protocol.d.ts +8 -0
  72. package/lib/common/settings-protocol.js +3 -1
  73. package/lib/common/ta-extension-host.d.ts +64 -1
  74. package/lib/common/ta-extension-host.js +9 -1
  75. package/lib/common/ta-protocol.d.ts +53 -175
  76. package/lib/common/ta-protocol.js +1 -235
  77. package/lib/common/team-protocol.d.ts +13 -2
  78. package/lib/common/team-protocol.js +28 -3
  79. package/lib/common/voice-protocol.d.ts +185 -0
  80. package/lib/common/voice-protocol.js +60 -0
  81. package/package.json +1 -1
@@ -0,0 +1,31 @@
1
+ /**
2
+ * How much of the work the double hands out to tasks rather than doing it itself (Settings.delegate): the user's
3
+ * dial. Its role says it, and a guard of ta serve (DelegateExtension) holds it to it, by the mark of the level in
4
+ * the role: the tools that change files are off for it, and the others after a few steps of one run.
5
+ */
6
+ export type TaDelegateLevel = 'less' | 'balanced' | 'more';
7
+ export interface TaDelegateLimits {
8
+ /** Its tools that change files (edit, write) are off. */
9
+ noChanges: boolean;
10
+ /** Of its own tools (TaDelegateUtil.WORK_TOOLS), how many one run may call; undefined for as many as it likes. */
11
+ steps?: number;
12
+ }
13
+ export declare namespace TaDelegateUtil {
14
+ const LEVELS: readonly TaDelegateLevel[];
15
+ const DEFAULT: TaDelegateLevel;
16
+ /** pi's own tools, those with which a session works itself; the tools of extensions (start_task, the team's) are not. */
17
+ const WORK_TOOLS: readonly string[];
18
+ const CHANGE_TOOLS: readonly string[];
19
+ function parse(value: unknown): TaDelegateLevel;
20
+ /** In the role of the double: the guard reads which level it was opened with. */
21
+ function mark(level: TaDelegateLevel): string;
22
+ /** The level of a session's role, by its mark; undefined for a session that is not the double (a task, a chat). */
23
+ function levelOf(systemPrompt: string | undefined): TaDelegateLevel | undefined;
24
+ function limits(level: TaDelegateLevel): TaDelegateLimits;
25
+ /**
26
+ * Why a call of a tool is turned down, or undefined to let it run: `steps`, how many of its own tools the run
27
+ * called before it. What is turned down says what to do instead, for the model to read.
28
+ */
29
+ function refusal(level: TaDelegateLevel, tool: string, steps: number): string | undefined;
30
+ }
31
+ //# sourceMappingURL=delegate-protocol.d.ts.map
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaDelegateUtil = void 0;
4
+ const ta_extension_host_1 = require("./ta-extension-host");
5
+ var TaDelegateUtil;
6
+ (function (TaDelegateUtil) {
7
+ TaDelegateUtil.LEVELS = ['less', 'balanced', 'more'];
8
+ TaDelegateUtil.DEFAULT = 'balanced';
9
+ /** pi's own tools, those with which a session works itself; the tools of extensions (start_task, the team's) are not. */
10
+ TaDelegateUtil.WORK_TOOLS = ['read', 'bash', 'powershell', 'edit', 'write', 'grep', 'find', 'ls'];
11
+ TaDelegateUtil.CHANGE_TOOLS = ['edit', 'write'];
12
+ const LIMITS = {
13
+ less: { noChanges: false },
14
+ balanced: { noChanges: true, steps: 6 },
15
+ more: { noChanges: true, steps: 2 },
16
+ };
17
+ function parse(value) {
18
+ return TaDelegateUtil.LEVELS.includes(value) ? value : TaDelegateUtil.DEFAULT;
19
+ }
20
+ TaDelegateUtil.parse = parse;
21
+ /** In the role of the double: the guard reads which level it was opened with. */
22
+ function mark(level) {
23
+ return `(delegate=${level})`;
24
+ }
25
+ TaDelegateUtil.mark = mark;
26
+ /** The level of a session's role, by its mark; undefined for a session that is not the double (a task, a chat). */
27
+ function levelOf(systemPrompt) {
28
+ const role = ta_extension_host_1.TaHostUtil.role(systemPrompt);
29
+ return TaDelegateUtil.LEVELS.find(level => role.includes(mark(level)));
30
+ }
31
+ TaDelegateUtil.levelOf = levelOf;
32
+ function limits(level) {
33
+ return LIMITS[level];
34
+ }
35
+ TaDelegateUtil.limits = limits;
36
+ /**
37
+ * Why a call of a tool is turned down, or undefined to let it run: `steps`, how many of its own tools the run
38
+ * called before it. What is turned down says what to do instead, for the model to read.
39
+ */
40
+ function refusal(level, tool, steps) {
41
+ if (!TaDelegateUtil.WORK_TOOLS.includes(tool)) {
42
+ return undefined;
43
+ }
44
+ const limit = LIMITS[level];
45
+ if (limit.noChanges && TaDelegateUtil.CHANGE_TOOLS.includes(tool)) {
46
+ return 'You do not change files yourself: hand this to a task with start_task, with instructions complete enough to do it. The user set how much you hand out in the settings of the double.';
47
+ }
48
+ if (limit.steps !== undefined && steps >= limit.steps) {
49
+ return 'You have looked enough for this: hand the work to a task with start_task now, with what you found in its instructions, and tell the user what you started.';
50
+ }
51
+ return undefined;
52
+ }
53
+ TaDelegateUtil.refusal = refusal;
54
+ })(TaDelegateUtil || (exports.TaDelegateUtil = TaDelegateUtil = {}));
55
+ //# sourceMappingURL=delegate-protocol.js.map
@@ -0,0 +1,73 @@
1
+ /**
2
+ * A deployment of Ta: its gateway, its relay, or both, for one group of people (docs/design/ta-deploy.md). Inside and
3
+ * outside a company each have one; nothing passes between them.
4
+ */
5
+ /** What every service of a deployment answers, to anyone (it holds nothing secret). */
6
+ export declare const TA_WELL_KNOWN_PATH = "/.well-known/ta";
7
+ /** What a deployment says of itself at TA_WELL_KNOWN_PATH: where its services are. */
8
+ export interface TaDeployment {
9
+ v: 1;
10
+ /** What its people call it: TA_DEPLOYMENT_NAME. */
11
+ name?: string;
12
+ /** Where its gateway is (cloud-hosted Ta), and its relay (devices, rooms, links). */
13
+ gateway?: string;
14
+ relay?: string;
15
+ version?: string;
16
+ }
17
+ /**
18
+ * What a build of Ta comes with (`distribution.json` beside its `dist/`, docs/design/ta-deploy.md 3): the addresses of the
19
+ * deployment it is for, as defaults of the environment; and where its desktop app updates from.
20
+ */
21
+ export interface TaDistribution {
22
+ name?: string;
23
+ relay?: string;
24
+ gateway?: string;
25
+ updates?: {
26
+ base?: string;
27
+ key?: string;
28
+ };
29
+ /**
30
+ * What a device does to reach the deployment, told when its gateway does not answer: by language (`zh-CN`, `en`,
31
+ * `*` for any), one sentence, as "Turn on Remote Work in your company's VPN app". A gateway on an intranet has one.
32
+ */
33
+ reach?: Record<string, string>;
34
+ /**
35
+ * An address of the company's network that answers without its VPN (its sign-in, as `https://iam.example.com`): a
36
+ * device that reaches it while the gateway does not is the company's, told `reach`; one that reaches neither is
37
+ * someone else's, shown no deployment at all.
38
+ */
39
+ inside?: string;
40
+ }
41
+ /** The environment a deployment is told by: the variables a distribution gives defaults of. */
42
+ export interface TaDeploymentEnv {
43
+ TA_DEPLOYMENT_NAME?: string;
44
+ TA_GATEWAY_URL?: string;
45
+ TA_RELAY_URL?: string;
46
+ }
47
+ export declare class TaDeploymentError extends Error {
48
+ }
49
+ export declare namespace TaDeploymentUtil {
50
+ const DISTRIBUTION_FILE = "distribution.json";
51
+ /** An address of a service as it is kept: http(s), its origin and path, no trailing slash; undefined for what is not one. */
52
+ function url(value: unknown): string | undefined;
53
+ /**
54
+ * What a service answers: `own` its own part (its address, TA_PUBLIC_URL or the origin it was reached at), the rest
55
+ * from the environment.
56
+ */
57
+ function describe(env: TaDeploymentEnv, own: {
58
+ gateway?: string;
59
+ relay?: string;
60
+ }, version?: string): TaDeployment;
61
+ const HEADERS: Readonly<Record<string, string>>;
62
+ /** What a deployment said, kept to what is known; undefined for what is not one. */
63
+ function parse(value: unknown): TaDeployment | undefined;
64
+ /** Asks a service of a deployment what it is part of: rejects with what went wrong. */
65
+ function discover(address: string, timeoutMs?: number): Promise<TaDeployment>;
66
+ /** A distribution as its file holds it: throws on what it cannot be, for a build not to ship a wrong one. */
67
+ function distribution(value: unknown): TaDistribution;
68
+ /** The sentence of `reach` in `language` (`zh-CN`): that language, else another of its kind (`zh`), else any, else English. */
69
+ function reachIn(reach: Record<string, string> | undefined, language: string): string | undefined;
70
+ /** The environment a distribution gives: its defaults, for what `env` does not set already. */
71
+ function apply(distribution: TaDistribution, env: Record<string, string | undefined>): void;
72
+ }
73
+ //# sourceMappingURL=deployment-protocol.d.ts.map
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ /**
3
+ * A deployment of Ta: its gateway, its relay, or both, for one group of people (docs/design/ta-deploy.md). Inside and
4
+ * outside a company each have one; nothing passes between them.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.TaDeploymentUtil = exports.TaDeploymentError = exports.TA_WELL_KNOWN_PATH = void 0;
8
+ /** What every service of a deployment answers, to anyone (it holds nothing secret). */
9
+ exports.TA_WELL_KNOWN_PATH = '/.well-known/ta';
10
+ class TaDeploymentError extends Error {
11
+ }
12
+ exports.TaDeploymentError = TaDeploymentError;
13
+ var TaDeploymentUtil;
14
+ (function (TaDeploymentUtil) {
15
+ TaDeploymentUtil.DISTRIBUTION_FILE = 'distribution.json';
16
+ /** An address of a service as it is kept: http(s), its origin and path, no trailing slash; undefined for what is not one. */
17
+ function url(value) {
18
+ if (typeof value !== 'string' || !value.trim()) {
19
+ return undefined;
20
+ }
21
+ try {
22
+ const parsed = new URL(value.trim());
23
+ if (!/^https?:$/.test(parsed.protocol) || parsed.search || parsed.hash || parsed.username || parsed.password) {
24
+ return undefined;
25
+ }
26
+ return `${parsed.origin}${parsed.pathname}`.replace(/\/+$/, '');
27
+ }
28
+ catch (_a) {
29
+ return undefined;
30
+ }
31
+ }
32
+ TaDeploymentUtil.url = url;
33
+ function name(value) {
34
+ return typeof value === 'string' && value.trim() ? value.trim().slice(0, 80) : undefined;
35
+ }
36
+ /**
37
+ * What a service answers: `own` its own part (its address, TA_PUBLIC_URL or the origin it was reached at), the rest
38
+ * from the environment.
39
+ */
40
+ function describe(env, own, version) {
41
+ var _a, _b;
42
+ const gateway = (_a = url(own.gateway)) !== null && _a !== void 0 ? _a : url(env.TA_GATEWAY_URL);
43
+ const relay = (_b = url(own.relay)) !== null && _b !== void 0 ? _b : url(env.TA_RELAY_URL);
44
+ const called = name(env.TA_DEPLOYMENT_NAME);
45
+ return { v: 1, ...(called ? { name: called } : {}), ...(gateway ? { gateway } : {}), ...(relay ? { relay } : {}), ...(version ? { version } : {}) };
46
+ }
47
+ TaDeploymentUtil.describe = describe;
48
+ TaDeploymentUtil.HEADERS = {
49
+ 'content-type': 'application/json',
50
+ 'access-control-allow-origin': '*',
51
+ 'cache-control': 'no-store',
52
+ };
53
+ /** What a deployment said, kept to what is known; undefined for what is not one. */
54
+ function parse(value) {
55
+ const given = value;
56
+ if (!given || typeof given !== 'object' || given.v !== 1) {
57
+ return undefined;
58
+ }
59
+ const deployment = describe({ TA_DEPLOYMENT_NAME: given.name, TA_GATEWAY_URL: given.gateway, TA_RELAY_URL: given.relay }, {});
60
+ const version = name(given.version);
61
+ return version ? { ...deployment, version } : deployment;
62
+ }
63
+ TaDeploymentUtil.parse = parse;
64
+ /** Asks a service of a deployment what it is part of: rejects with what went wrong. */
65
+ async function discover(address, timeoutMs = 6000) {
66
+ const base = url(address);
67
+ if (!base) {
68
+ throw new TaDeploymentError(`${address} is not an address of http or https.`);
69
+ }
70
+ const controller = new AbortController();
71
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
72
+ try {
73
+ const response = await fetch(`${base}${exports.TA_WELL_KNOWN_PATH}`, { signal: controller.signal, redirect: 'follow' });
74
+ if (!response.ok) {
75
+ throw new TaDeploymentError(`${base} is not a deployment of Ta (${response.status}).`);
76
+ }
77
+ const deployment = parse(await response.json().catch(() => undefined));
78
+ if (!deployment || (!deployment.gateway && !deployment.relay)) {
79
+ throw new TaDeploymentError(`${base} is not a deployment of Ta.`);
80
+ }
81
+ return deployment;
82
+ }
83
+ catch (error) {
84
+ if ((error === null || error === void 0 ? void 0 : error.name) === 'AbortError') {
85
+ throw new TaDeploymentError(`${base} did not answer in time.`);
86
+ }
87
+ throw error;
88
+ }
89
+ finally {
90
+ clearTimeout(timer);
91
+ }
92
+ }
93
+ TaDeploymentUtil.discover = discover;
94
+ /** A distribution as its file holds it: throws on what it cannot be, for a build not to ship a wrong one. */
95
+ function distribution(value) {
96
+ if (!value || typeof value !== 'object' || Array.isArray(value)) {
97
+ throw new TaDeploymentError(`${TaDeploymentUtil.DISTRIBUTION_FILE} holds a JSON object.`);
98
+ }
99
+ const given = value;
100
+ const result = {};
101
+ if (given.name !== undefined) {
102
+ result.name = name(given.name);
103
+ }
104
+ for (const key of ['relay', 'gateway']) {
105
+ if (given[key] !== undefined) {
106
+ const address = url(given[key]);
107
+ if (!address) {
108
+ throw new TaDeploymentError(`"${key}" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not an address of http or https.`);
109
+ }
110
+ result[key] = address;
111
+ }
112
+ }
113
+ if (given.updates !== undefined) {
114
+ const updates = given.updates;
115
+ const base = url(updates === null || updates === void 0 ? void 0 : updates.base);
116
+ if (!base && (updates === null || updates === void 0 ? void 0 : updates.base) !== undefined) {
117
+ throw new TaDeploymentError(`"updates.base" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not an address of http or https.`);
118
+ }
119
+ const key = typeof (updates === null || updates === void 0 ? void 0 : updates.key) === 'string' && updates.key.includes('PUBLIC KEY') ? updates.key : undefined;
120
+ if ((updates === null || updates === void 0 ? void 0 : updates.key) !== undefined && !key) {
121
+ throw new TaDeploymentError(`"updates.key" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is a public key in PEM.`);
122
+ }
123
+ result.updates = { ...(base ? { base } : {}), ...(key ? { key } : {}) };
124
+ }
125
+ if (given.reach !== undefined) {
126
+ result.reach = reach(given.reach);
127
+ }
128
+ if (given.inside !== undefined) {
129
+ const inside = url(given.inside);
130
+ if (!inside) {
131
+ throw new TaDeploymentError(`"inside" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not an address of http or https.`);
132
+ }
133
+ result.inside = inside;
134
+ }
135
+ return result;
136
+ }
137
+ TaDeploymentUtil.distribution = distribution;
138
+ function reach(value) {
139
+ const given = typeof value === 'string' ? { '*': value } : value;
140
+ const entries = given && typeof given === 'object' && !Array.isArray(given) ? Object.entries(given) : [];
141
+ const result = {};
142
+ for (const [language, text] of entries) {
143
+ if (typeof text !== 'string' || !text.trim()) {
144
+ throw new TaDeploymentError(`"reach.${language}" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is not a sentence.`);
145
+ }
146
+ result[language] = text.trim().slice(0, 200);
147
+ }
148
+ if (Object.keys(result).length === 0) {
149
+ throw new TaDeploymentError(`"reach" of ${TaDeploymentUtil.DISTRIBUTION_FILE} is a sentence, or one by language.`);
150
+ }
151
+ return result;
152
+ }
153
+ /** The sentence of `reach` in `language` (`zh-CN`): that language, else another of its kind (`zh`), else any, else English. */
154
+ function reachIn(reach, language) {
155
+ var _a, _b, _c, _d, _e;
156
+ if (!reach) {
157
+ return undefined;
158
+ }
159
+ const base = language.split('-')[0];
160
+ const near = Object.keys(reach).find(key => key.split('-')[0] === base);
161
+ return (_e = (_d = (_c = (_b = (_a = reach[language]) !== null && _a !== void 0 ? _a : reach[base]) !== null && _b !== void 0 ? _b : (near && reach[near])) !== null && _c !== void 0 ? _c : reach['*']) !== null && _d !== void 0 ? _d : reach.en) !== null && _e !== void 0 ? _e : Object.values(reach)[0];
162
+ }
163
+ TaDeploymentUtil.reachIn = reachIn;
164
+ /** The environment a distribution gives: its defaults, for what `env` does not set already. */
165
+ function apply(distribution, env) {
166
+ const defaults = { TA_DEPLOYMENT_NAME: distribution.name, TA_RELAY_URL: distribution.relay, TA_GATEWAY_URL: distribution.gateway };
167
+ for (const [key, value] of Object.entries(defaults)) {
168
+ if (value && !env[key]) {
169
+ env[key] = value;
170
+ }
171
+ }
172
+ }
173
+ TaDeploymentUtil.apply = apply;
174
+ })(TaDeploymentUtil || (exports.TaDeploymentUtil = TaDeploymentUtil = {}));
175
+ //# sourceMappingURL=deployment-protocol.js.map
@@ -0,0 +1,43 @@
1
+ /** The stable `code` of each failure of a {@link TaServer} call. */
2
+ export declare const TaErrorCode: {
3
+ readonly SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND';
4
+ readonly SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED';
5
+ readonly TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS';
6
+ readonly MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT';
7
+ readonly MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND';
8
+ readonly INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT';
9
+ readonly COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED';
10
+ /** Compacting found nothing to compact: the conversation is still short. */
11
+ readonly NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT';
12
+ /** Compacting found nothing to compact: nothing came after the last compaction. */
13
+ readonly ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED';
14
+ /** The session is answering or compacting, which has to end first. */
15
+ readonly SESSION_BUSY: 'CELL_TA_SESSION_BUSY';
16
+ /** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
17
+ readonly CANCELLED: 'CELL_TA_CANCELLED';
18
+ /** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
19
+ readonly NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN';
20
+ /** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
21
+ readonly ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED';
22
+ /** Behind a gateway: more messages a minute than one may send; try again in a moment. */
23
+ readonly RATE_LIMITED: 'CELL_TA_RATE_LIMITED';
24
+ /** One let in by the user (docs/design/ta-team.md) may not do this: `data` says the action it needs (TaForbiddenData). */
25
+ readonly FORBIDDEN: 'CELL_TA_FORBIDDEN';
26
+ /** As many runs of people let in go as the owner lets at once (docs/design/ta-team.md 9): try again once one ended. */
27
+ readonly LIMIT: 'CELL_TA_LIMIT';
28
+ /** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
29
+ readonly CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST';
30
+ };
31
+ export type TaErrorCode = (typeof TaErrorCode)[keyof typeof TaErrorCode];
32
+ export declare namespace TaErrorUtil {
33
+ /** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
34
+ function code(error: unknown): string | undefined;
35
+ }
36
+ /** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
37
+ export declare const TA_RPC_ERROR_CODE = -32050;
38
+ export interface TaErrorData {
39
+ code: TaErrorCode;
40
+ /** One sentence on what to do about it. */
41
+ hint: string;
42
+ }
43
+ //# sourceMappingURL=error-protocol.d.ts.map
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TA_RPC_ERROR_CODE = exports.TaErrorUtil = exports.TaErrorCode = void 0;
4
+ /** The stable `code` of each failure of a {@link TaServer} call. */
5
+ exports.TaErrorCode = {
6
+ SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND',
7
+ SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED',
8
+ TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS',
9
+ MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT',
10
+ MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND',
11
+ INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT',
12
+ COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
13
+ /** Compacting found nothing to compact: the conversation is still short. */
14
+ NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT',
15
+ /** Compacting found nothing to compact: nothing came after the last compaction. */
16
+ ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED',
17
+ /** The session is answering or compacting, which has to end first. */
18
+ SESSION_BUSY: 'CELL_TA_SESSION_BUSY',
19
+ /** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
20
+ CANCELLED: 'CELL_TA_CANCELLED',
21
+ /** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
22
+ NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN',
23
+ /** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
24
+ ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED',
25
+ /** Behind a gateway: more messages a minute than one may send; try again in a moment. */
26
+ RATE_LIMITED: 'CELL_TA_RATE_LIMITED',
27
+ /** One let in by the user (docs/design/ta-team.md) may not do this: `data` says the action it needs (TaForbiddenData). */
28
+ FORBIDDEN: 'CELL_TA_FORBIDDEN',
29
+ /** As many runs of people let in go as the owner lets at once (docs/design/ta-team.md 9): try again once one ended. */
30
+ LIMIT: 'CELL_TA_LIMIT',
31
+ /** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
32
+ CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
33
+ };
34
+ var TaErrorUtil;
35
+ (function (TaErrorUtil) {
36
+ /** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
37
+ function code(error) {
38
+ var _a;
39
+ var _b;
40
+ const failure = error;
41
+ const code = (_b = failure === null || failure === void 0 ? void 0 : failure.code) !== null && _b !== void 0 ? _b : (_a = failure === null || failure === void 0 ? void 0 : failure.data) === null || _a === void 0 ? void 0 : _a.code;
42
+ return typeof code === 'string' ? code : undefined;
43
+ }
44
+ TaErrorUtil.code = code;
45
+ })(TaErrorUtil || (exports.TaErrorUtil = TaErrorUtil = {}));
46
+ /** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
47
+ exports.TA_RPC_ERROR_CODE = -32050;
48
+ //# sourceMappingURL=error-protocol.js.map
@@ -0,0 +1,64 @@
1
+ import type { JsonAgentSessionEvent, RpcExtensionUIRequest } from './pi-types';
2
+ import type { TaSessionInfo } from './ta-protocol';
3
+ /** An extension's dialog was answered by another client, or expired. */
4
+ export interface TaUiRequestResolved {
5
+ type: 'ui_request_resolved';
6
+ id: string;
7
+ }
8
+ /** An extension threw while handling an event. */
9
+ export interface TaExtensionError {
10
+ type: 'extension_error';
11
+ extensionPath: string;
12
+ event: string;
13
+ error: string;
14
+ }
15
+ /** The open session now shows another conversation (`newSession`, `switchSession`, `fork`, `clone`, `navigateTree`): read it again. */
16
+ export interface TaSessionReplaced {
17
+ type: 'session_replaced';
18
+ info: TaSessionInfo;
19
+ }
20
+ /**
21
+ * The session loaded its extensions, skills, prompts and themes again (`reload`, or an extension's
22
+ * `ctx.reload()`): its commands may have changed, read them again (`getCommands`).
23
+ */
24
+ export interface TaSessionReloaded {
25
+ type: 'session_reloaded';
26
+ }
27
+ /** The session was closed; no more events come. */
28
+ export interface TaSessionClosed {
29
+ type: 'session_closed';
30
+ }
31
+ /**
32
+ * What the agent is doing while it works, from an extension (pi's `setWorkingMessage`), as starting the
33
+ * program of an external agent; none: the client's own words again.
34
+ */
35
+ export interface TaWorkingMessage {
36
+ type: 'working_message';
37
+ message?: string;
38
+ }
39
+ /**
40
+ * The model called a tool of `clientTools`: a client that runs it takes it with `claimClientTool`, so
41
+ * that one client runs it, however many are attached, and answers with `respondClientTool`. When that
42
+ * client leaves the session before it answers, the request comes again with the same id, for another.
43
+ * `client_tool_resolved` tells the others it was answered.
44
+ */
45
+ export interface TaClientToolRequest {
46
+ type: 'client_tool_request';
47
+ /** The id of the tool call. */
48
+ id: string;
49
+ toolName: string;
50
+ input: unknown;
51
+ }
52
+ /** A call of a client tool was answered, or ended because the run was aborted or the session closed. */
53
+ export interface TaClientToolResolved {
54
+ type: 'client_tool_resolved';
55
+ id: string;
56
+ }
57
+ export type TaEvent = JsonAgentSessionEvent | RpcExtensionUIRequest | TaUiRequestResolved | TaExtensionError | TaClientToolRequest | TaClientToolResolved | TaSessionReplaced | TaSessionReloaded | TaSessionClosed | TaWorkingMessage;
58
+ export interface TaEventEnvelope {
59
+ sessionId: string;
60
+ /** Increases by one per event of the session. */
61
+ seq: number;
62
+ event: TaEvent;
63
+ }
64
+ //# sourceMappingURL=event-protocol.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=event-protocol.js.map
@@ -28,6 +28,15 @@ export interface TaGatewayLimits {
28
28
  /** Whether they may run their Ta in a Ta service of their own. */
29
29
  own?: boolean | null;
30
30
  }
31
+ /** A connection of a sandbox the proxy of the gateway refused, the latest of its kind: `count` of them lately. */
32
+ export interface TaEgressRefusal {
33
+ /** `host`, or `host:port` for a port other than 80 and 443. */
34
+ host: string;
35
+ /** Not among the hosts of the policy, a port it does not let out, or a private network or the gateway's machine. */
36
+ reason: 'host' | 'port' | 'network';
37
+ at: number;
38
+ count: number;
39
+ }
31
40
  /** Why one's Ta does not start: suspended by an administrator, or this month's free minutes used up. */
32
41
  export type TaQuotaBlock = 'suspended' | 'minutes';
33
42
  /** What one used of what one may, this month (of UTC), as one sees it and administrators do. */
@@ -55,6 +64,11 @@ export interface TaQuotaState {
55
64
  promptsPerMinute?: number;
56
65
  connections?: number;
57
66
  blocked?: TaQuotaBlock;
67
+ /** When the sandboxes go out through the gateway: the bytes moved this month, and the latest connections refused. */
68
+ egress?: {
69
+ bytes: number;
70
+ refused: TaEgressRefusal[];
71
+ };
58
72
  }
59
73
  /** One hour of what agents took: tokens and dollars. */
60
74
  export interface TaUsagePoint {
@@ -99,6 +113,18 @@ export interface TaGatewayAuditEntry {
99
113
  target?: string;
100
114
  detail?: string;
101
115
  }
116
+ /**
117
+ * The way out of the sandboxes: the proxy of the gateway, by which each sandbox goes out with credentials of its
118
+ * own epoch (those of a sandbox made again since stop working).
119
+ */
120
+ export interface TaGatewayEgress {
121
+ /** Whether the sandboxes go out through the gateway (`egress` of sandboxes.json, with the firewall of the machine). */
122
+ enabled: boolean;
123
+ /** The hosts members' sandboxes may reach, set by owners; none: any public host. Owners are not held to them. */
124
+ hosts: string[];
125
+ /** Private networks the sandboxes may reach too (`egress.networks` of sandboxes.json); never the gateway's machine. */
126
+ networks: string[];
127
+ }
102
128
  /** The defaults of the gateway and who manages it. */
103
129
  export interface TaGatewayPolicy {
104
130
  defaults: TaGatewayLimits;
@@ -108,6 +134,7 @@ export interface TaGatewayPolicy {
108
134
  role: 'owner' | 'admin';
109
135
  }[];
110
136
  idleMinutes: number;
137
+ egress: TaGatewayEgress;
111
138
  }
112
139
  /**
113
140
  * Where the Ta of a tenant runs: a sandbox of the gateway's provider (a container, a machine), or a Ta service
@@ -331,6 +358,8 @@ export interface TaGatewayServer {
331
358
  grantMinutes(tenantId: string, minutes: number): Promise<void>;
332
359
  /** For administrators: a suspended account's Ta stops and does not start until it is let go again. */
333
360
  setSuspended(tenantId: string, suspended: boolean): Promise<void>;
361
+ /** For owners: the hosts members' sandboxes may reach through the proxy of the gateway; none: any public host. */
362
+ setEgressHosts(hosts: string[]): Promise<TaGatewayPolicy>;
334
363
  /** For owners: makes an account that signed in an admin, or a member again. Owners stay owners. */
335
364
  setRole(account: string, role: 'admin' | 'member'): Promise<TaGatewayPolicy>;
336
365
  /** For administrators: what administrators did lately, newest first, `limit` at most (100 by default). */
@@ -1,18 +1,29 @@
1
1
  export * from './access-protocol';
2
+ export * from './app-protocol';
2
3
  export * from './auth-protocol';
4
+ export * from './delegate-protocol';
5
+ export * from './deployment-protocol';
6
+ export * from './error-protocol';
7
+ export * from './event-protocol';
3
8
  export * from './gateway-protocol';
4
9
  export * from './language';
5
10
  export * from './location';
11
+ export * from './message-protocol';
6
12
  export * from './package-protocol';
13
+ export * from './page-protocol';
14
+ export * from './path-map';
7
15
  export * from './pi-types';
8
16
  export * from './presence-protocol';
9
17
  export * from './relay-protocol';
10
18
  export * from './remote-protocol';
11
19
  export * from './room-protocol';
20
+ export * from './said-protocol';
21
+ export * from './screen-share-protocol';
12
22
  export * from './settings-protocol';
13
23
  export * from './ta-extension-host';
14
24
  export * from './ta-protocol';
15
25
  export * from './team-protocol';
16
26
  export * from './usage-protocol';
27
+ export * from './voice-protocol';
17
28
  export * from './workspace-protocol';
18
29
  //# sourceMappingURL=index.d.ts.map
@@ -15,20 +15,31 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./access-protocol"), exports);
18
+ __exportStar(require("./app-protocol"), exports);
18
19
  __exportStar(require("./auth-protocol"), exports);
20
+ __exportStar(require("./delegate-protocol"), exports);
21
+ __exportStar(require("./deployment-protocol"), exports);
22
+ __exportStar(require("./error-protocol"), exports);
23
+ __exportStar(require("./event-protocol"), exports);
19
24
  __exportStar(require("./gateway-protocol"), exports);
20
25
  __exportStar(require("./language"), exports);
21
26
  __exportStar(require("./location"), exports);
27
+ __exportStar(require("./message-protocol"), exports);
22
28
  __exportStar(require("./package-protocol"), exports);
29
+ __exportStar(require("./page-protocol"), exports);
30
+ __exportStar(require("./path-map"), exports);
23
31
  __exportStar(require("./pi-types"), exports);
24
32
  __exportStar(require("./presence-protocol"), exports);
25
33
  __exportStar(require("./relay-protocol"), exports);
26
34
  __exportStar(require("./remote-protocol"), exports);
27
35
  __exportStar(require("./room-protocol"), exports);
36
+ __exportStar(require("./said-protocol"), exports);
37
+ __exportStar(require("./screen-share-protocol"), exports);
28
38
  __exportStar(require("./settings-protocol"), exports);
29
39
  __exportStar(require("./ta-extension-host"), exports);
30
40
  __exportStar(require("./ta-protocol"), exports);
31
41
  __exportStar(require("./team-protocol"), exports);
32
42
  __exportStar(require("./usage-protocol"), exports);
43
+ __exportStar(require("./voice-protocol"), exports);
33
44
  __exportStar(require("./workspace-protocol"), exports);
34
45
  //# sourceMappingURL=index.js.map