@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,45 @@
|
|
|
1
|
+
/** The stable `code` of each failure of a {@link TaServer} call. */
|
|
2
|
+
export const TaErrorCode = {
|
|
3
|
+
SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND',
|
|
4
|
+
SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED',
|
|
5
|
+
TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS',
|
|
6
|
+
MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT',
|
|
7
|
+
MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND',
|
|
8
|
+
INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT',
|
|
9
|
+
COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
|
|
10
|
+
/** Compacting found nothing to compact: the conversation is still short. */
|
|
11
|
+
NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT',
|
|
12
|
+
/** Compacting found nothing to compact: nothing came after the last compaction. */
|
|
13
|
+
ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED',
|
|
14
|
+
/** The session is answering or compacting, which has to end first. */
|
|
15
|
+
SESSION_BUSY: 'CELL_TA_SESSION_BUSY',
|
|
16
|
+
/** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
|
|
17
|
+
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
|
+
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
|
+
ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED',
|
|
22
|
+
/** Behind a gateway: more messages a minute than one may send; try again in a moment. */
|
|
23
|
+
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
|
+
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
|
+
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
|
+
CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
|
|
30
|
+
};
|
|
31
|
+
export var TaErrorUtil;
|
|
32
|
+
(function (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) {
|
|
35
|
+
var _a;
|
|
36
|
+
var _b;
|
|
37
|
+
const failure = error;
|
|
38
|
+
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;
|
|
39
|
+
return typeof code === 'string' ? code : undefined;
|
|
40
|
+
}
|
|
41
|
+
TaErrorUtil.code = code;
|
|
42
|
+
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
43
|
+
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
44
|
+
export const TA_RPC_ERROR_CODE = -32050;
|
|
45
|
+
//# sourceMappingURL=error-protocol.js.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { JsonAgentSessionEvent, RpcExtensionUIRequest } from './pi-types.js';
|
|
2
|
+
import type { TaSessionInfo } from './ta-protocol.js';
|
|
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
|
+
}
|
|
@@ -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,8 +358,19 @@ 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
|
}
|
package/esm/common/index.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export * from './access-protocol.js';
|
|
2
|
+
export * from './app-protocol.js';
|
|
2
3
|
export * from './auth-protocol.js';
|
|
4
|
+
export * from './delegate-protocol.js';
|
|
5
|
+
export * from './deployment-protocol.js';
|
|
6
|
+
export * from './error-protocol.js';
|
|
7
|
+
export * from './event-protocol.js';
|
|
3
8
|
export * from './gateway-protocol.js';
|
|
4
9
|
export * from './language.js';
|
|
5
10
|
export * from './location.js';
|
|
11
|
+
export * from './message-protocol.js';
|
|
6
12
|
export * from './package-protocol.js';
|
|
13
|
+
export * from './page-protocol.js';
|
|
14
|
+
export * from './path-map.js';
|
|
7
15
|
export * from './pi-types.js';
|
|
8
16
|
export * from './presence-protocol.js';
|
|
9
17
|
export * from './relay-protocol.js';
|
|
@@ -14,4 +22,5 @@ export * from './ta-extension-host.js';
|
|
|
14
22
|
export * from './ta-protocol.js';
|
|
15
23
|
export * from './team-protocol.js';
|
|
16
24
|
export * from './usage-protocol.js';
|
|
25
|
+
export * from './voice-protocol.js';
|
|
17
26
|
export * from './workspace-protocol.js';
|
package/esm/common/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
export * from './access-protocol.js';
|
|
2
|
+
export * from './app-protocol.js';
|
|
2
3
|
export * from './auth-protocol.js';
|
|
4
|
+
export * from './delegate-protocol.js';
|
|
5
|
+
export * from './deployment-protocol.js';
|
|
6
|
+
export * from './error-protocol.js';
|
|
7
|
+
export * from './event-protocol.js';
|
|
3
8
|
export * from './gateway-protocol.js';
|
|
4
9
|
export * from './language.js';
|
|
5
10
|
export * from './location.js';
|
|
11
|
+
export * from './message-protocol.js';
|
|
6
12
|
export * from './package-protocol.js';
|
|
13
|
+
export * from './page-protocol.js';
|
|
14
|
+
export * from './path-map.js';
|
|
7
15
|
export * from './pi-types.js';
|
|
8
16
|
export * from './presence-protocol.js';
|
|
9
17
|
export * from './relay-protocol.js';
|
|
@@ -14,5 +22,6 @@ export * from './ta-extension-host.js';
|
|
|
14
22
|
export * from './ta-protocol.js';
|
|
15
23
|
export * from './team-protocol.js';
|
|
16
24
|
export * from './usage-protocol.js';
|
|
25
|
+
export * from './voice-protocol.js';
|
|
17
26
|
export * from './workspace-protocol.js';
|
|
18
27
|
//# sourceMappingURL=index.js.map
|
package/esm/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/esm/common/location.js
CHANGED
|
@@ -7,17 +7,58 @@
|
|
|
7
7
|
export var TaLocation;
|
|
8
8
|
(function (TaLocation) {
|
|
9
9
|
TaLocation.SSH = 'ssh://';
|
|
10
|
+
/**
|
|
11
|
+
* A directory of a cloud workspace: `ta://<name>/<path>`, the sandbox of a Ta gateway (or any Ta service)
|
|
12
|
+
* the user added under that name, reached over its WebSocket (`/api/exec`), not ssh. Its host, as the
|
|
13
|
+
* functions here take it, is `ta://<name>`.
|
|
14
|
+
*/
|
|
15
|
+
TaLocation.CLOUD = 'ta://';
|
|
16
|
+
const CLOUD_NAME = /^[a-z0-9][a-z0-9-]{0,39}$/;
|
|
10
17
|
/** Letters, digits and `_ . @ : % + - [ ]`, not first a `-`: ssh must not read a host as an option. */
|
|
11
18
|
const HOST = /^(?!-)[\w.@:%+[\]-]+$/;
|
|
12
19
|
function isRemote(location) {
|
|
13
|
-
return location.startsWith(TaLocation.SSH);
|
|
20
|
+
return location.startsWith(TaLocation.SSH) || location.startsWith(TaLocation.CLOUD);
|
|
14
21
|
}
|
|
15
22
|
TaLocation.isRemote = isRemote;
|
|
23
|
+
/** Whether a host is a cloud workspace (`ta://<name>`), not one of ssh. */
|
|
24
|
+
function isCloud(host) {
|
|
25
|
+
return !!host && host.startsWith(TaLocation.CLOUD);
|
|
26
|
+
}
|
|
27
|
+
TaLocation.isCloud = isCloud;
|
|
28
|
+
/** Whether a name may name a cloud workspace: lower-case letters, digits and -, 40 at most. */
|
|
29
|
+
function isCloudName(name) {
|
|
30
|
+
return CLOUD_NAME.test(name);
|
|
31
|
+
}
|
|
32
|
+
TaLocation.isCloudName = isCloudName;
|
|
33
|
+
/** `ta://<name><path>`. */
|
|
34
|
+
function cloud(name, path = '') {
|
|
35
|
+
return `${TaLocation.CLOUD}${name}${path ? normalize(path) : ''}`;
|
|
36
|
+
}
|
|
37
|
+
TaLocation.cloud = cloud;
|
|
38
|
+
/** The name of a cloud workspace, of its host or of a location there. */
|
|
39
|
+
function cloudName(hostOrLocation) {
|
|
40
|
+
if (!hostOrLocation.startsWith(TaLocation.CLOUD)) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
const rest = hostOrLocation.slice(TaLocation.CLOUD.length);
|
|
44
|
+
const slash = rest.indexOf('/');
|
|
45
|
+
return slash < 0 ? rest : rest.slice(0, slash);
|
|
46
|
+
}
|
|
47
|
+
TaLocation.cloudName = cloudName;
|
|
16
48
|
/** undefined for a path of the machine of ta serve; throws for an `ssh://` location that is not one. */
|
|
17
49
|
function parse(location) {
|
|
50
|
+
var _a;
|
|
18
51
|
if (!isRemote(location)) {
|
|
19
52
|
return undefined;
|
|
20
53
|
}
|
|
54
|
+
if (location.startsWith(TaLocation.CLOUD)) {
|
|
55
|
+
const name = (_a = cloudName(location)) !== null && _a !== void 0 ? _a : '';
|
|
56
|
+
if (!isCloudName(name)) {
|
|
57
|
+
throw new Error(`${JSON.stringify(location)} names no cloud workspace: write ta://<name>/<path>.`);
|
|
58
|
+
}
|
|
59
|
+
const path = location.slice(TaLocation.CLOUD.length + name.length);
|
|
60
|
+
return { host: `${TaLocation.CLOUD}${name}`, path: path ? normalize(path) : '' };
|
|
61
|
+
}
|
|
21
62
|
const rest = location.slice(TaLocation.SSH.length);
|
|
22
63
|
const slash = rest.indexOf('/');
|
|
23
64
|
const host = slash < 0 ? rest : rest.slice(0, slash);
|
|
@@ -29,7 +70,7 @@ export var TaLocation;
|
|
|
29
70
|
}
|
|
30
71
|
TaLocation.parse = parse;
|
|
31
72
|
function isHost(host) {
|
|
32
|
-
return HOST.test(host);
|
|
73
|
+
return isCloud(host) ? isCloudName(host.slice(TaLocation.CLOUD.length)) : HOST.test(host);
|
|
33
74
|
}
|
|
34
75
|
TaLocation.isHost = isHost;
|
|
35
76
|
/** Options of ssh without a value, which change nothing for Ta. */
|
|
@@ -109,9 +150,12 @@ export var TaLocation;
|
|
|
109
150
|
return isHost(host) ? { host } : { error: 'invalid' };
|
|
110
151
|
}
|
|
111
152
|
TaLocation.readHost = readHost;
|
|
112
|
-
/**
|
|
153
|
+
/**
|
|
154
|
+
* The location of a path on a host: `ssh://<host><path>`, or `ta://<name><path>` for the host of a cloud
|
|
155
|
+
* workspace; `path` absolute, or empty for the home directory.
|
|
156
|
+
*/
|
|
113
157
|
function ssh(host, path = '') {
|
|
114
|
-
return `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
158
|
+
return isCloud(host) ? `${host}${path ? normalize(path) : ''}` : `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
115
159
|
}
|
|
116
160
|
TaLocation.ssh = ssh;
|
|
117
161
|
/**
|
|
@@ -119,6 +163,9 @@ export var TaLocation;
|
|
|
119
163
|
* (`me@dev.example.com:2222` is `dev`); an address whole.
|
|
120
164
|
*/
|
|
121
165
|
function hostLabel(host) {
|
|
166
|
+
if (isCloud(host)) {
|
|
167
|
+
return host.slice(TaLocation.CLOUD.length);
|
|
168
|
+
}
|
|
122
169
|
const name = host
|
|
123
170
|
.replace(/^[^@]*@/, '')
|
|
124
171
|
.replace(/^\[(.*)\](?::\d+)?$/, '$1')
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A message of the user may start with a `<context>` block: what the model reads besides the message
|
|
3
|
+
* (where it is said, who is there, what was said before), which a client leaves out when it shows it.
|
|
4
|
+
*/
|
|
5
|
+
export declare namespace TaMessageContext {
|
|
6
|
+
function wrap(context: string, message: string): string;
|
|
7
|
+
/** The message without its context: what the user sees of it. */
|
|
8
|
+
function strip(message: string): string;
|
|
9
|
+
/** The context of the message, without its tags; undefined without one. */
|
|
10
|
+
function read(message: string): string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/** Where a message of the user came from, when not from what they typed: see {@link TaMessageSource}. */
|
|
13
|
+
export interface TaMessageFrom {
|
|
14
|
+
/** The name of the package that sent it, or TaMessageSource.DOUBLE. */
|
|
15
|
+
from: string;
|
|
16
|
+
/** What the package says of it besides, in a few words (the channel and who spoke in it). */
|
|
17
|
+
detail?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A message a package sends as the user (a choice in a card, a scheduled task, a channel) says so in the last line
|
|
21
|
+
* of its `<context>` block, `[ta:from <name> <detail>]`: a page shows where it came from, the model reads it too,
|
|
22
|
+
* and a page older than it leaves it out with the rest of the context. A command (`/compact`, `!ls`) is not marked.
|
|
23
|
+
*/
|
|
24
|
+
export declare namespace TaMessageSource {
|
|
25
|
+
/** The double of the web page: the tasks it hands out, what it tells them on the way. */
|
|
26
|
+
const DOUBLE = "ta:double";
|
|
27
|
+
/** `message` as sent by `from`; as it was when it is a command or says where it came from already. */
|
|
28
|
+
function mark(message: string, from: string, detail?: string): string;
|
|
29
|
+
function of(message: string): TaMessageFrom | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* pi adds a line to the text of a message of the user for each image it took, for the model's sake: how big
|
|
33
|
+
* the image was before it made it smaller, and what it was converted from. Clients leave them out.
|
|
34
|
+
*/
|
|
35
|
+
export declare namespace TaImageNote {
|
|
36
|
+
/** The text without the notes of its images: what the user sees of it. */
|
|
37
|
+
function strip(text: string): string;
|
|
38
|
+
}
|
|
39
|
+
/** The width and height of an image, read from the start of its bytes (PNG, JPEG, GIF, WebP); undefined for another kind. */
|
|
40
|
+
export declare namespace TaImageSize {
|
|
41
|
+
function of(base64: string): {
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
} | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* An external agent that compacts its own context says the summary it goes on from as text, in tags
|
|
48
|
+
* (`<conversation_history_summary><summary>…`). Clients show it folded, not as what the agent said.
|
|
49
|
+
*/
|
|
50
|
+
export declare namespace TaAgentSummary {
|
|
51
|
+
/** The summary `text` is, without its tags (and the start of a closing tag while it streams); else undefined. */
|
|
52
|
+
function read(text: string): string | undefined;
|
|
53
|
+
/** The text without the summary it starts with. */
|
|
54
|
+
function strip(text: string): string;
|
|
55
|
+
}
|
|
56
|
+
/** A skill the user ran with `/skill:name`, as pi puts it in the message: the skill's file, then what the user wrote. */
|
|
57
|
+
export interface TaSkillUse {
|
|
58
|
+
name: string;
|
|
59
|
+
/** The path of its SKILL.md. */
|
|
60
|
+
location: string;
|
|
61
|
+
/** What pi read of it, for the model. */
|
|
62
|
+
content: string;
|
|
63
|
+
/** What the user wrote after `/skill:name`. */
|
|
64
|
+
message?: string;
|
|
65
|
+
}
|
|
66
|
+
/** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
|
|
67
|
+
export declare namespace TaSkillUse {
|
|
68
|
+
function parse(message: string): TaSkillUse | undefined;
|
|
69
|
+
/** What the user typed: `/skill:name` and what follows. */
|
|
70
|
+
function command(use: TaSkillUse): string;
|
|
71
|
+
}
|
|
72
|
+
/** What a note of the double's tasks is about: how one ended, that the user handed it one, that one has another id now. */
|
|
73
|
+
export type TaTaskNoteKind = 'update' | 'adopted' | 'renamed';
|
|
74
|
+
/** A note of the double's tasks, as {@link TaTaskNote.write} puts it and {@link TaTaskNote.parse} reads it. */
|
|
75
|
+
export interface TaTaskNote {
|
|
76
|
+
kind: TaTaskNoteKind;
|
|
77
|
+
id: string;
|
|
78
|
+
title: string;
|
|
79
|
+
/** How the task stands: running, done, failed, stopped; none in a note of a new id. */
|
|
80
|
+
status?: string;
|
|
81
|
+
/** The id it had, in a note of a new id. */
|
|
82
|
+
was?: string;
|
|
83
|
+
/** What the note says, for the double. */
|
|
84
|
+
body: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The double hears of its tasks in messages of the user (`<task_update id="t1" title="…" status="done">…</task_update>`
|
|
88
|
+
* and the like): notes, not what the user said, which a client shows as the task they are about, and a list of
|
|
89
|
+
* conversations says by the task's title.
|
|
90
|
+
*/
|
|
91
|
+
export declare namespace TaTaskNote {
|
|
92
|
+
function write(note: TaTaskNote): string;
|
|
93
|
+
/** The note `text` is, all of it; undefined for anything else. */
|
|
94
|
+
function parse(text: string): TaTaskNote | undefined;
|
|
95
|
+
}
|