@celljs/ta-protocol 4.15.2 → 4.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/common/app-protocol.d.ts +115 -0
- package/esm/common/app-protocol.js +199 -0
- package/esm/common/delegate-protocol.d.ts +30 -0
- package/esm/common/delegate-protocol.js +52 -0
- package/esm/common/deployment-protocol.d.ts +59 -0
- package/esm/common/deployment-protocol.js +135 -0
- package/esm/common/error-protocol.d.ts +42 -0
- package/esm/common/error-protocol.js +45 -0
- package/esm/common/event-protocol.d.ts +63 -0
- package/esm/common/event-protocol.js +2 -0
- package/esm/common/gateway-protocol.d.ts +54 -2
- package/esm/common/index.d.ts +9 -0
- package/esm/common/index.js +9 -0
- package/esm/common/location.d.ts +18 -1
- package/esm/common/location.js +51 -4
- package/esm/common/message-protocol.d.ts +95 -0
- package/esm/common/message-protocol.js +237 -0
- package/esm/common/page-protocol.d.ts +56 -0
- package/esm/common/page-protocol.js +12 -0
- package/esm/common/path-map.d.ts +24 -0
- package/esm/common/path-map.js +127 -0
- package/esm/common/presence-protocol.js +1 -1
- package/esm/common/redactor.d.ts +12 -0
- package/esm/common/redactor.js +49 -11
- package/esm/common/relay-protocol.d.ts +20 -0
- package/esm/common/remote-protocol.d.ts +12 -4
- package/esm/common/room-protocol.d.ts +7 -1
- package/esm/common/ta-extension-host.d.ts +31 -1
- package/esm/common/ta-extension-host.js +2 -0
- package/esm/common/ta-protocol.d.ts +50 -175
- package/esm/common/ta-protocol.js +0 -234
- package/esm/common/voice-protocol.d.ts +139 -0
- package/esm/common/voice-protocol.js +3 -0
- package/lib/common/app-protocol.d.ts +116 -0
- package/lib/common/app-protocol.js +202 -0
- package/lib/common/delegate-protocol.d.ts +31 -0
- package/lib/common/delegate-protocol.js +55 -0
- package/lib/common/deployment-protocol.d.ts +60 -0
- package/lib/common/deployment-protocol.js +139 -0
- package/lib/common/error-protocol.d.ts +43 -0
- package/lib/common/error-protocol.js +48 -0
- package/lib/common/event-protocol.d.ts +64 -0
- package/lib/common/event-protocol.js +3 -0
- package/lib/common/gateway-protocol.d.ts +54 -2
- package/lib/common/index.d.ts +9 -0
- package/lib/common/index.js +9 -0
- package/lib/common/location.d.ts +18 -1
- package/lib/common/location.js +51 -4
- package/lib/common/message-protocol.d.ts +96 -0
- package/lib/common/message-protocol.js +240 -0
- package/lib/common/page-protocol.d.ts +57 -0
- package/lib/common/page-protocol.js +15 -0
- package/lib/common/path-map.d.ts +25 -0
- package/lib/common/path-map.js +130 -0
- package/lib/common/presence-protocol.js +7 -7
- package/lib/common/redactor.d.ts +12 -0
- package/lib/common/redactor.js +49 -11
- package/lib/common/relay-protocol.d.ts +20 -0
- package/lib/common/remote-protocol.d.ts +12 -4
- package/lib/common/room-protocol.d.ts +7 -1
- package/lib/common/ta-extension-host.d.ts +31 -1
- package/lib/common/ta-extension-host.js +3 -1
- package/lib/common/ta-protocol.d.ts +50 -175
- package/lib/common/ta-protocol.js +1 -235
- package/lib/common/voice-protocol.d.ts +140 -0
- package/lib/common/voice-protocol.js +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
TaDeploymentUtil.distribution = distribution;
|
|
128
|
+
/** The environment a distribution gives: its defaults, for what `env` does not set already. */
|
|
129
|
+
function apply(distribution, env) {
|
|
130
|
+
const defaults = { TA_DEPLOYMENT_NAME: distribution.name, TA_RELAY_URL: distribution.relay, TA_GATEWAY_URL: distribution.gateway };
|
|
131
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
132
|
+
if (value && !env[key]) {
|
|
133
|
+
env[key] = value;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
TaDeploymentUtil.apply = apply;
|
|
138
|
+
})(TaDeploymentUtil || (exports.TaDeploymentUtil = TaDeploymentUtil = {}));
|
|
139
|
+
//# 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
|
|
@@ -14,6 +14,11 @@ export type TaGatewayRole = 'owner' | 'admin' | 'member';
|
|
|
14
14
|
export interface TaGatewayLimits {
|
|
15
15
|
/** Minutes a month their sandbox may run, free. */
|
|
16
16
|
freeMinutes?: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Tokens a month their agents may take through the models of the gateway (models.json of the gateway), counted
|
|
19
|
+
* by the gateway as it passes the calls; past them, calls are refused until the next month.
|
|
20
|
+
*/
|
|
21
|
+
monthlyTokens?: number | null;
|
|
17
22
|
/** Messages a minute they may send their agents (prompts, steering, follow-ups). */
|
|
18
23
|
promptsPerMinute?: number | null;
|
|
19
24
|
/** Pages connected at once. */
|
|
@@ -23,6 +28,15 @@ export interface TaGatewayLimits {
|
|
|
23
28
|
/** Whether they may run their Ta in a Ta service of their own. */
|
|
24
29
|
own?: boolean | null;
|
|
25
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
|
+
}
|
|
26
40
|
/** Why one's Ta does not start: suspended by an administrator, or this month's free minutes used up. */
|
|
27
41
|
export type TaQuotaBlock = 'suspended' | 'minutes';
|
|
28
42
|
/** What one used of what one may, this month (of UTC), as one sees it and administrators do. */
|
|
@@ -38,16 +52,23 @@ export interface TaQuotaState {
|
|
|
38
52
|
bonus: number;
|
|
39
53
|
};
|
|
40
54
|
/**
|
|
41
|
-
* Tokens this month
|
|
42
|
-
*
|
|
55
|
+
* Tokens this month. `metered`: counted by the gateway, whose models the sandbox calls through it, and held to
|
|
56
|
+
* `limit`; else as the agents' sessions say, shown only (the sandbox is the member's, its files too).
|
|
43
57
|
*/
|
|
44
58
|
tokens: {
|
|
45
59
|
used: number;
|
|
46
60
|
cost: number;
|
|
61
|
+
limit?: number;
|
|
62
|
+
metered: boolean;
|
|
47
63
|
};
|
|
48
64
|
promptsPerMinute?: number;
|
|
49
65
|
connections?: number;
|
|
50
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
|
+
};
|
|
51
72
|
}
|
|
52
73
|
/** One hour of what agents took: tokens and dollars. */
|
|
53
74
|
export interface TaUsagePoint {
|
|
@@ -92,6 +113,18 @@ export interface TaGatewayAuditEntry {
|
|
|
92
113
|
target?: string;
|
|
93
114
|
detail?: string;
|
|
94
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
|
+
}
|
|
95
128
|
/** The defaults of the gateway and who manages it. */
|
|
96
129
|
export interface TaGatewayPolicy {
|
|
97
130
|
defaults: TaGatewayLimits;
|
|
@@ -101,6 +134,7 @@ export interface TaGatewayPolicy {
|
|
|
101
134
|
role: 'owner' | 'admin';
|
|
102
135
|
}[];
|
|
103
136
|
idleMinutes: number;
|
|
137
|
+
egress: TaGatewayEgress;
|
|
104
138
|
}
|
|
105
139
|
/**
|
|
106
140
|
* Where the Ta of a tenant runs: a sandbox of the gateway's provider (a container, a machine), or a Ta service
|
|
@@ -269,6 +303,13 @@ export interface TaGatewayConsole {
|
|
|
269
303
|
/** That of the one who looks. */
|
|
270
304
|
role: TaGatewayRole;
|
|
271
305
|
policy: TaGatewayPolicy;
|
|
306
|
+
/** The providers of models the gateway gives its sandboxes (models.json of the gateway), without their keys. */
|
|
307
|
+
models: {
|
|
308
|
+
id: string;
|
|
309
|
+
name?: string;
|
|
310
|
+
api: string;
|
|
311
|
+
models: number;
|
|
312
|
+
}[];
|
|
272
313
|
}
|
|
273
314
|
/**
|
|
274
315
|
* `ta gateway`: each account that signs in is a tenant with a Ta of its own, in a sandbox of its own, which
|
|
@@ -317,9 +358,20 @@ export interface TaGatewayServer {
|
|
|
317
358
|
grantMinutes(tenantId: string, minutes: number): Promise<void>;
|
|
318
359
|
/** For administrators: a suspended account's Ta stops and does not start until it is let go again. */
|
|
319
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>;
|
|
320
363
|
/** For owners: makes an account that signed in an admin, or a member again. Owners stay owners. */
|
|
321
364
|
setRole(account: string, role: 'admin' | 'member'): Promise<TaGatewayPolicy>;
|
|
322
365
|
/** For administrators: what administrators did lately, newest first, `limit` at most (100 by default). */
|
|
323
366
|
getAudit(limit?: number): Promise<TaGatewayAuditEntry[]>;
|
|
367
|
+
/**
|
|
368
|
+
* A token of one's own account for another Ta to use one's sandbox as a cloud workspace (`ta://<name>`, its
|
|
369
|
+
* exec server at `/api/exec` of the gateway) or to open one's Ta: a sign-in, listed with one's browsers in
|
|
370
|
+
* Access, signed out there. `url`: TA_PUBLIC_URL, where the gateway is reached.
|
|
371
|
+
*/
|
|
372
|
+
createAccessToken(label?: string): Promise<{
|
|
373
|
+
token: string;
|
|
374
|
+
url?: string;
|
|
375
|
+
}>;
|
|
324
376
|
}
|
|
325
377
|
//# sourceMappingURL=gateway-protocol.d.ts.map
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
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';
|
|
@@ -14,5 +22,6 @@ export * from './ta-extension-host';
|
|
|
14
22
|
export * from './ta-protocol';
|
|
15
23
|
export * from './team-protocol';
|
|
16
24
|
export * from './usage-protocol';
|
|
25
|
+
export * from './voice-protocol';
|
|
17
26
|
export * from './workspace-protocol';
|
|
18
27
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/common/index.js
CHANGED
|
@@ -15,11 +15,19 @@ 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);
|
|
@@ -30,5 +38,6 @@ __exportStar(require("./ta-extension-host"), exports);
|
|
|
30
38
|
__exportStar(require("./ta-protocol"), exports);
|
|
31
39
|
__exportStar(require("./team-protocol"), exports);
|
|
32
40
|
__exportStar(require("./usage-protocol"), exports);
|
|
41
|
+
__exportStar(require("./voice-protocol"), exports);
|
|
33
42
|
__exportStar(require("./workspace-protocol"), exports);
|
|
34
43
|
//# sourceMappingURL=index.js.map
|
package/lib/common/location.d.ts
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare namespace TaLocation {
|
|
8
8
|
const SSH = "ssh://";
|
|
9
|
+
/**
|
|
10
|
+
* A directory of a cloud workspace: `ta://<name>/<path>`, the sandbox of a Ta gateway (or any Ta service)
|
|
11
|
+
* the user added under that name, reached over its WebSocket (`/api/exec`), not ssh. Its host, as the
|
|
12
|
+
* functions here take it, is `ta://<name>`.
|
|
13
|
+
*/
|
|
14
|
+
const CLOUD = "ta://";
|
|
9
15
|
/** A directory of another machine. */
|
|
10
16
|
interface Remote {
|
|
11
17
|
host: string;
|
|
@@ -13,6 +19,14 @@ export declare namespace TaLocation {
|
|
|
13
19
|
path: string;
|
|
14
20
|
}
|
|
15
21
|
function isRemote(location: string): boolean;
|
|
22
|
+
/** Whether a host is a cloud workspace (`ta://<name>`), not one of ssh. */
|
|
23
|
+
function isCloud(host: string | undefined): boolean;
|
|
24
|
+
/** Whether a name may name a cloud workspace: lower-case letters, digits and -, 40 at most. */
|
|
25
|
+
function isCloudName(name: string): boolean;
|
|
26
|
+
/** `ta://<name><path>`. */
|
|
27
|
+
function cloud(name: string, path?: string): string;
|
|
28
|
+
/** The name of a cloud workspace, of its host or of a location there. */
|
|
29
|
+
function cloudName(hostOrLocation: string): string | undefined;
|
|
16
30
|
/** undefined for a path of the machine of ta serve; throws for an `ssh://` location that is not one. */
|
|
17
31
|
function parse(location: string): Remote | undefined;
|
|
18
32
|
function isHost(host: string): boolean;
|
|
@@ -31,7 +45,10 @@ export declare namespace TaLocation {
|
|
|
31
45
|
* cannot hold (`-i`, `-J`, `-o ProxyCommand=…`) belong in ~/.ssh/config: they come back as `options`.
|
|
32
46
|
*/
|
|
33
47
|
function readHost(input: string): HostInput;
|
|
34
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* The location of a path on a host: `ssh://<host><path>`, or `ta://<name><path>` for the host of a cloud
|
|
50
|
+
* workspace; `path` absolute, or empty for the home directory.
|
|
51
|
+
*/
|
|
35
52
|
function ssh(host: string, path?: string): string;
|
|
36
53
|
/**
|
|
37
54
|
* A host as a list shows it, short: the name of the machine, without the user, the port and the domain
|
package/lib/common/location.js
CHANGED
|
@@ -10,17 +10,58 @@ exports.TaLocation = void 0;
|
|
|
10
10
|
var TaLocation;
|
|
11
11
|
(function (TaLocation) {
|
|
12
12
|
TaLocation.SSH = 'ssh://';
|
|
13
|
+
/**
|
|
14
|
+
* A directory of a cloud workspace: `ta://<name>/<path>`, the sandbox of a Ta gateway (or any Ta service)
|
|
15
|
+
* the user added under that name, reached over its WebSocket (`/api/exec`), not ssh. Its host, as the
|
|
16
|
+
* functions here take it, is `ta://<name>`.
|
|
17
|
+
*/
|
|
18
|
+
TaLocation.CLOUD = 'ta://';
|
|
19
|
+
const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
13
20
|
/** Letters, digits and `_ . @ : % + - [ ]`, not first a `-`: ssh must not read a host as an option. */
|
|
14
21
|
const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
|
|
15
22
|
function isRemote(location) {
|
|
16
|
-
return location.startsWith(TaLocation.SSH);
|
|
23
|
+
return location.startsWith(TaLocation.SSH) || location.startsWith(TaLocation.CLOUD);
|
|
17
24
|
}
|
|
18
25
|
TaLocation.isRemote = isRemote;
|
|
26
|
+
/** Whether a host is a cloud workspace (`ta://<name>`), not one of ssh. */
|
|
27
|
+
function isCloud(host) {
|
|
28
|
+
return !!host && host.startsWith(TaLocation.CLOUD);
|
|
29
|
+
}
|
|
30
|
+
TaLocation.isCloud = isCloud;
|
|
31
|
+
/** Whether a name may name a cloud workspace: lower-case letters, digits and -, 40 at most. */
|
|
32
|
+
function isCloudName(name) {
|
|
33
|
+
return CLOUD_NAME.test(name);
|
|
34
|
+
}
|
|
35
|
+
TaLocation.isCloudName = isCloudName;
|
|
36
|
+
/** `ta://<name><path>`. */
|
|
37
|
+
function cloud(name, path = '') {
|
|
38
|
+
return `${TaLocation.CLOUD}${name}${path ? normalize(path) : ''}`;
|
|
39
|
+
}
|
|
40
|
+
TaLocation.cloud = cloud;
|
|
41
|
+
/** The name of a cloud workspace, of its host or of a location there. */
|
|
42
|
+
function cloudName(hostOrLocation) {
|
|
43
|
+
if (!hostOrLocation.startsWith(TaLocation.CLOUD)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
const rest = hostOrLocation.slice(TaLocation.CLOUD.length);
|
|
47
|
+
const slash = rest.indexOf('/');
|
|
48
|
+
return slash < 0 ? rest : rest.slice(0, slash);
|
|
49
|
+
}
|
|
50
|
+
TaLocation.cloudName = cloudName;
|
|
19
51
|
/** undefined for a path of the machine of ta serve; throws for an `ssh://` location that is not one. */
|
|
20
52
|
function parse(location) {
|
|
53
|
+
var _a;
|
|
21
54
|
if (!isRemote(location)) {
|
|
22
55
|
return undefined;
|
|
23
56
|
}
|
|
57
|
+
if (location.startsWith(TaLocation.CLOUD)) {
|
|
58
|
+
const name = (_a = cloudName(location)) !== null && _a !== void 0 ? _a : '';
|
|
59
|
+
if (!isCloudName(name)) {
|
|
60
|
+
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
61
|
+
}
|
|
62
|
+
const path = location.slice(TaLocation.CLOUD.length + name.length);
|
|
63
|
+
return { host: `${TaLocation.CLOUD}${name}`, path: path ? normalize(path) : '' };
|
|
64
|
+
}
|
|
24
65
|
const rest = location.slice(TaLocation.SSH.length);
|
|
25
66
|
const slash = rest.indexOf('/');
|
|
26
67
|
const host = slash < 0 ? rest : rest.slice(0, slash);
|
|
@@ -32,7 +73,7 @@ var TaLocation;
|
|
|
32
73
|
}
|
|
33
74
|
TaLocation.parse = parse;
|
|
34
75
|
function isHost(host) {
|
|
35
|
-
return HOST.test(host);
|
|
76
|
+
return isCloud(host) ? isCloudName(host.slice(TaLocation.CLOUD.length)) : HOST.test(host);
|
|
36
77
|
}
|
|
37
78
|
TaLocation.isHost = isHost;
|
|
38
79
|
/** Options of ssh without a value, which change nothing for Ta. */
|
|
@@ -112,9 +153,12 @@ var TaLocation;
|
|
|
112
153
|
return isHost(host) ? { host } : { error: 'invalid' };
|
|
113
154
|
}
|
|
114
155
|
TaLocation.readHost = readHost;
|
|
115
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* The location of a path on a host: `ssh://<host><path>`, or `ta://<name><path>` for the host of a cloud
|
|
158
|
+
* workspace; `path` absolute, or empty for the home directory.
|
|
159
|
+
*/
|
|
116
160
|
function ssh(host, path = '') {
|
|
117
|
-
return `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
161
|
+
return isCloud(host) ? `${host}${path ? normalize(path) : ''}` : `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
118
162
|
}
|
|
119
163
|
TaLocation.ssh = ssh;
|
|
120
164
|
/**
|
|
@@ -122,6 +166,9 @@ var TaLocation;
|
|
|
122
166
|
* (`me@dev.example.com:2222` is `dev`); an address whole.
|
|
123
167
|
*/
|
|
124
168
|
function hostLabel(host) {
|
|
169
|
+
if (isCloud(host)) {
|
|
170
|
+
return host.slice(TaLocation.CLOUD.length);
|
|
171
|
+
}
|
|
125
172
|
const name = host
|
|
126
173
|
.replace(/^[^@]*@/, '')
|
|
127
174
|
.replace(/^\[(.*)\](?::\d+)?$/, '$1')
|