@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.
- package/esm/common/access-protocol.d.ts +41 -0
- package/esm/common/access-protocol.js +7 -0
- package/esm/common/app-protocol.d.ts +120 -0
- package/esm/common/app-protocol.js +213 -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 +72 -0
- package/esm/common/deployment-protocol.js +171 -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 +29 -0
- package/esm/common/index.d.ts +11 -0
- package/esm/common/index.js +11 -0
- package/esm/common/message-protocol.d.ts +134 -0
- package/esm/common/message-protocol.js +322 -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/room-protocol.d.ts +52 -1
- package/esm/common/said-protocol.d.ts +76 -0
- package/esm/common/said-protocol.js +239 -0
- package/esm/common/screen-share-protocol.d.ts +304 -0
- package/esm/common/screen-share-protocol.js +88 -0
- package/esm/common/settings-protocol.d.ts +8 -0
- package/esm/common/settings-protocol.js +2 -0
- package/esm/common/ta-extension-host.d.ts +64 -1
- package/esm/common/ta-extension-host.js +8 -0
- package/esm/common/ta-protocol.d.ts +53 -175
- package/esm/common/ta-protocol.js +0 -234
- package/esm/common/team-protocol.d.ts +13 -2
- package/esm/common/team-protocol.js +27 -2
- package/esm/common/voice-protocol.d.ts +184 -0
- package/esm/common/voice-protocol.js +57 -0
- package/lib/common/access-protocol.d.ts +41 -0
- package/lib/common/access-protocol.js +8 -1
- package/lib/common/app-protocol.d.ts +121 -0
- package/lib/common/app-protocol.js +216 -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 +73 -0
- package/lib/common/deployment-protocol.js +175 -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 +29 -0
- package/lib/common/index.d.ts +11 -0
- package/lib/common/index.js +11 -0
- package/lib/common/message-protocol.d.ts +135 -0
- package/lib/common/message-protocol.js +325 -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/room-protocol.d.ts +52 -1
- package/lib/common/said-protocol.d.ts +77 -0
- package/lib/common/said-protocol.js +242 -0
- package/lib/common/screen-share-protocol.d.ts +305 -0
- package/lib/common/screen-share-protocol.js +91 -0
- package/lib/common/settings-protocol.d.ts +8 -0
- package/lib/common/settings-protocol.js +3 -1
- package/lib/common/ta-extension-host.d.ts +64 -1
- package/lib/common/ta-extension-host.js +9 -1
- package/lib/common/ta-protocol.d.ts +53 -175
- package/lib/common/ta-protocol.js +1 -235
- package/lib/common/team-protocol.d.ts +13 -2
- package/lib/common/team-protocol.js +28 -3
- package/lib/common/voice-protocol.d.ts +185 -0
- package/lib/common/voice-protocol.js +60 -0
- package/package.json +1 -1
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { TaAuthEvent } from './auth-protocol.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TaClientToolRequest, TaEventEnvelope } from './event-protocol.js';
|
|
3
|
+
import type { ImageContent, RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResponse, ThinkingLevel } from './pi-types.js';
|
|
3
4
|
import type { TaSessionPerson } from './presence-protocol.js';
|
|
4
5
|
import type { TaRemoteEvent } from './remote-protocol.js';
|
|
5
6
|
import type { TaRoomEvent } from './room-protocol.js';
|
|
7
|
+
import type { TaDesktopEvent } from './screen-share-protocol.js';
|
|
6
8
|
import type { TaAsking } from './ta-extension-host.js';
|
|
7
9
|
import type { TaMemberInfo } from './team-protocol.js';
|
|
10
|
+
import type { TaVoiceEvent } from './voice-protocol.js';
|
|
8
11
|
export declare const TaServer: unique symbol;
|
|
9
12
|
export declare const TaClient: unique symbol;
|
|
10
13
|
/** Path of the WebSocket endpoint of `ta serve`, and the JSON-RPC method prefixes of both sides. */
|
|
@@ -59,52 +62,21 @@ export interface TaServerUpdate {
|
|
|
59
62
|
/** As TaServerInfo.build. */
|
|
60
63
|
build?: string;
|
|
61
64
|
}
|
|
62
|
-
/** The stable `code` of each failure of a {@link TaServer} call. */
|
|
63
|
-
export declare const TaErrorCode: {
|
|
64
|
-
readonly SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND';
|
|
65
|
-
readonly SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED';
|
|
66
|
-
readonly TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS';
|
|
67
|
-
readonly MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT';
|
|
68
|
-
readonly MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND';
|
|
69
|
-
readonly INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT';
|
|
70
|
-
readonly COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED';
|
|
71
|
-
/** Compacting found nothing to compact: the conversation is still short. */
|
|
72
|
-
readonly NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT';
|
|
73
|
-
/** Compacting found nothing to compact: nothing came after the last compaction. */
|
|
74
|
-
readonly ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED';
|
|
75
|
-
/** The session is answering or compacting, which has to end first. */
|
|
76
|
-
readonly SESSION_BUSY: 'CELL_TA_SESSION_BUSY';
|
|
77
|
-
/** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
|
|
78
|
-
readonly CANCELLED: 'CELL_TA_CANCELLED';
|
|
79
|
-
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
80
|
-
readonly NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN';
|
|
81
|
-
/** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
|
|
82
|
-
readonly ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED';
|
|
83
|
-
/** Behind a gateway: more messages a minute than one may send; try again in a moment. */
|
|
84
|
-
readonly RATE_LIMITED: 'CELL_TA_RATE_LIMITED';
|
|
85
|
-
/** One let in by the user (docs/design/ta-team.md) may not do this: `data` says the action it needs (TaForbiddenData). */
|
|
86
|
-
readonly FORBIDDEN: 'CELL_TA_FORBIDDEN';
|
|
87
|
-
/** 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. */
|
|
88
|
-
readonly LIMIT: 'CELL_TA_LIMIT';
|
|
89
|
-
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
90
|
-
readonly CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST';
|
|
91
|
-
};
|
|
92
|
-
export type TaErrorCode = (typeof TaErrorCode)[keyof typeof TaErrorCode];
|
|
93
|
-
export declare namespace TaErrorUtil {
|
|
94
|
-
/** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
|
|
95
|
-
function code(error: unknown): string | undefined;
|
|
96
|
-
}
|
|
97
|
-
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
98
|
-
export declare const TA_RPC_ERROR_CODE = -32050;
|
|
99
|
-
export interface TaErrorData {
|
|
100
|
-
code: TaErrorCode;
|
|
101
|
-
/** One sentence on what to do about it. */
|
|
102
|
-
hint: string;
|
|
103
|
-
}
|
|
104
65
|
/** A command name of pi's RPC mode (`get_state`, `follow_up`, ...). */
|
|
105
66
|
export type TaCommand = Extract<RpcResponse, {
|
|
106
67
|
success: true;
|
|
107
68
|
}>['command'];
|
|
69
|
+
/** The answer to `relocateDirectory`. */
|
|
70
|
+
export interface TaRelocateResult {
|
|
71
|
+
/** Conversations that work in the new directory now. */
|
|
72
|
+
conversations: number;
|
|
73
|
+
/** Conversations left where they were: running a turn now; move them again once they end. */
|
|
74
|
+
busy: number;
|
|
75
|
+
/** Packages whose data named the old directory. */
|
|
76
|
+
data: number;
|
|
77
|
+
/** The session files that moved, by their old paths: a page goes on with the new one. */
|
|
78
|
+
files: Record<string, string>;
|
|
79
|
+
}
|
|
108
80
|
/** The answer to `forkToFile`. */
|
|
109
81
|
export interface TaForkFileResult {
|
|
110
82
|
/** The new conversation; none when nothing comes before the message: then a new conversation starts. */
|
|
@@ -184,6 +156,11 @@ export interface TaSessionInfo {
|
|
|
184
156
|
firstMessage?: string;
|
|
185
157
|
/** The last thing said in it, by the user or the agent, on one line: what a list shows under its title. */
|
|
186
158
|
lastMessage?: string;
|
|
159
|
+
/**
|
|
160
|
+
* The directory it was in, which is no longer there (moved, renamed, deleted): it goes on in `cwd` instead,
|
|
161
|
+
* as pi's Continue; `forkHere` copies it there for good, as its Fork. None from a Ta service of before.
|
|
162
|
+
*/
|
|
163
|
+
movedFrom?: string;
|
|
187
164
|
/** `<provider>/<model id>`. */
|
|
188
165
|
model?: string;
|
|
189
166
|
isStreaming: boolean;
|
|
@@ -252,77 +229,6 @@ export interface TaPromptInput {
|
|
|
252
229
|
/** What to do when the agent is running; only for `prompt`. Default: `followUp`. */
|
|
253
230
|
streamingBehavior?: 'steer' | 'followUp';
|
|
254
231
|
}
|
|
255
|
-
/**
|
|
256
|
-
* A message of the user may start with a `<context>` block: what the model reads besides the message
|
|
257
|
-
* (where it is said, who is there, what was said before), which a client leaves out when it shows it.
|
|
258
|
-
*/
|
|
259
|
-
export declare namespace TaMessageContext {
|
|
260
|
-
function wrap(context: string, message: string): string;
|
|
261
|
-
/** The message without its context: what the user sees of it. */
|
|
262
|
-
function strip(message: string): string;
|
|
263
|
-
/** The context of the message, without its tags; undefined without one. */
|
|
264
|
-
function read(message: string): string | undefined;
|
|
265
|
-
}
|
|
266
|
-
/** Where a message of the user came from, when not from what they typed: see {@link TaMessageSource}. */
|
|
267
|
-
export interface TaMessageFrom {
|
|
268
|
-
/** The name of the package that sent it, or TaMessageSource.DOUBLE. */
|
|
269
|
-
from: string;
|
|
270
|
-
/** What the package says of it besides, in a few words (the channel and who spoke in it). */
|
|
271
|
-
detail?: string;
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* A message a package sends as the user (a choice in a card, a scheduled task, a channel) says so in the last line
|
|
275
|
-
* of its `<context>` block, `[ta:from <name> <detail>]`: a page shows where it came from, the model reads it too,
|
|
276
|
-
* and a page older than it leaves it out with the rest of the context. A command (`/compact`, `!ls`) is not marked.
|
|
277
|
-
*/
|
|
278
|
-
export declare namespace TaMessageSource {
|
|
279
|
-
/** The double of the web page: the tasks it hands out, what it tells them on the way. */
|
|
280
|
-
const DOUBLE = "ta:double";
|
|
281
|
-
/** `message` as sent by `from`; as it was when it is a command or says where it came from already. */
|
|
282
|
-
function mark(message: string, from: string, detail?: string): string;
|
|
283
|
-
function of(message: string): TaMessageFrom | undefined;
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* 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
|
|
287
|
-
* the image was before it made it smaller, and what it was converted from. Clients leave them out.
|
|
288
|
-
*/
|
|
289
|
-
export declare namespace TaImageNote {
|
|
290
|
-
/** The text without the notes of its images: what the user sees of it. */
|
|
291
|
-
function strip(text: string): string;
|
|
292
|
-
}
|
|
293
|
-
/** The width and height of an image, read from the start of its bytes (PNG, JPEG, GIF, WebP); undefined for another kind. */
|
|
294
|
-
export declare namespace TaImageSize {
|
|
295
|
-
function of(base64: string): {
|
|
296
|
-
width: number;
|
|
297
|
-
height: number;
|
|
298
|
-
} | undefined;
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* An external agent that compacts its own context says the summary it goes on from as text, in tags
|
|
302
|
-
* (`<conversation_history_summary><summary>…`). Clients show it folded, not as what the agent said.
|
|
303
|
-
*/
|
|
304
|
-
export declare namespace TaAgentSummary {
|
|
305
|
-
/** The summary `text` is, without its tags (and the start of a closing tag while it streams); else undefined. */
|
|
306
|
-
function read(text: string): string | undefined;
|
|
307
|
-
/** The text without the summary it starts with. */
|
|
308
|
-
function strip(text: string): string;
|
|
309
|
-
}
|
|
310
|
-
/** A skill the user ran with `/skill:name`, as pi puts it in the message: the skill's file, then what the user wrote. */
|
|
311
|
-
export interface TaSkillUse {
|
|
312
|
-
name: string;
|
|
313
|
-
/** The path of its SKILL.md. */
|
|
314
|
-
location: string;
|
|
315
|
-
/** What pi read of it, for the model. */
|
|
316
|
-
content: string;
|
|
317
|
-
/** What the user wrote after `/skill:name`. */
|
|
318
|
-
message?: string;
|
|
319
|
-
}
|
|
320
|
-
/** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
|
|
321
|
-
export declare namespace TaSkillUse {
|
|
322
|
-
function parse(message: string): TaSkillUse | undefined;
|
|
323
|
-
/** What the user typed: `/skill:name` and what follows. */
|
|
324
|
-
function command(use: TaSkillUse): string;
|
|
325
|
-
}
|
|
326
232
|
/**
|
|
327
233
|
* The server has taken the message; it says nothing about the run. A run is finished at the
|
|
328
234
|
* `agent_settled` event, when its history is on disk.
|
|
@@ -335,67 +241,6 @@ export interface TaPromptReceipt {
|
|
|
335
241
|
*/
|
|
336
242
|
status: 'accepted' | 'queued' | 'duplicate' | 'handled';
|
|
337
243
|
}
|
|
338
|
-
/** An extension's dialog was answered by another client, or expired. */
|
|
339
|
-
export interface TaUiRequestResolved {
|
|
340
|
-
type: 'ui_request_resolved';
|
|
341
|
-
id: string;
|
|
342
|
-
}
|
|
343
|
-
/** An extension threw while handling an event. */
|
|
344
|
-
export interface TaExtensionError {
|
|
345
|
-
type: 'extension_error';
|
|
346
|
-
extensionPath: string;
|
|
347
|
-
event: string;
|
|
348
|
-
error: string;
|
|
349
|
-
}
|
|
350
|
-
/** The open session now shows another conversation (`newSession`, `switchSession`, `fork`, `clone`, `navigateTree`): read it again. */
|
|
351
|
-
export interface TaSessionReplaced {
|
|
352
|
-
type: 'session_replaced';
|
|
353
|
-
info: TaSessionInfo;
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* The session loaded its extensions, skills, prompts and themes again (`reload`, or an extension's
|
|
357
|
-
* `ctx.reload()`): its commands may have changed, read them again (`getCommands`).
|
|
358
|
-
*/
|
|
359
|
-
export interface TaSessionReloaded {
|
|
360
|
-
type: 'session_reloaded';
|
|
361
|
-
}
|
|
362
|
-
/** The session was closed; no more events come. */
|
|
363
|
-
export interface TaSessionClosed {
|
|
364
|
-
type: 'session_closed';
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* What the agent is doing while it works, from an extension (pi's `setWorkingMessage`), as starting the
|
|
368
|
-
* program of an external agent; none: the client's own words again.
|
|
369
|
-
*/
|
|
370
|
-
export interface TaWorkingMessage {
|
|
371
|
-
type: 'working_message';
|
|
372
|
-
message?: string;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* The model called a tool of `clientTools`: a client that runs it takes it with `claimClientTool`, so
|
|
376
|
-
* that one client runs it, however many are attached, and answers with `respondClientTool`. When that
|
|
377
|
-
* client leaves the session before it answers, the request comes again with the same id, for another.
|
|
378
|
-
* `client_tool_resolved` tells the others it was answered.
|
|
379
|
-
*/
|
|
380
|
-
export interface TaClientToolRequest {
|
|
381
|
-
type: 'client_tool_request';
|
|
382
|
-
/** The id of the tool call. */
|
|
383
|
-
id: string;
|
|
384
|
-
toolName: string;
|
|
385
|
-
input: unknown;
|
|
386
|
-
}
|
|
387
|
-
/** A call of a client tool was answered, or ended because the run was aborted or the session closed. */
|
|
388
|
-
export interface TaClientToolResolved {
|
|
389
|
-
type: 'client_tool_resolved';
|
|
390
|
-
id: string;
|
|
391
|
-
}
|
|
392
|
-
export type TaEvent = JsonAgentSessionEvent | RpcExtensionUIRequest | TaUiRequestResolved | TaExtensionError | TaClientToolRequest | TaClientToolResolved | TaSessionReplaced | TaSessionReloaded | TaSessionClosed | TaWorkingMessage;
|
|
393
|
-
export interface TaEventEnvelope {
|
|
394
|
-
sessionId: string;
|
|
395
|
-
/** Increases by one per event of the session. */
|
|
396
|
-
seq: number;
|
|
397
|
-
event: TaEvent;
|
|
398
|
-
}
|
|
399
244
|
/** A message of the conversation, as `getMessages` gives it. */
|
|
400
245
|
export type TaMessage = TaCommandResult<'get_messages'>['messages'][number];
|
|
401
246
|
/** A call of a tool in the run of now, as its events left it. */
|
|
@@ -419,6 +264,17 @@ export interface TaConversation {
|
|
|
419
264
|
* `attach`): those before come with `getEarlierMessages`. None or 0: all of it.
|
|
420
265
|
*/
|
|
421
266
|
start?: number;
|
|
267
|
+
/** When `messages` start in the middle of a turn: the message of the user that asked for it (TaTurnHead). */
|
|
268
|
+
head?: TaTurnHead;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The message of the user that asked for a turn, when only its latest steps came (a turn too long for a page):
|
|
272
|
+
* the conversation shows who asked, above the steps, before the rest of the turn is loaded.
|
|
273
|
+
*/
|
|
274
|
+
export interface TaTurnHead {
|
|
275
|
+
/** Where it is in the whole conversation. */
|
|
276
|
+
index: number;
|
|
277
|
+
message: TaMessage;
|
|
422
278
|
}
|
|
423
279
|
export interface TaAttachOptions {
|
|
424
280
|
/**
|
|
@@ -446,6 +302,8 @@ export interface TaMessagePage {
|
|
|
446
302
|
start: number;
|
|
447
303
|
/** False when the message given is no longer there (the conversation was compacted or moved): read it again. */
|
|
448
304
|
found: boolean;
|
|
305
|
+
/** When they start in the middle of a turn: the message of the user that asked for it. */
|
|
306
|
+
head?: TaTurnHead;
|
|
449
307
|
}
|
|
450
308
|
export interface TaAttachResult {
|
|
451
309
|
info: TaSessionInfo;
|
|
@@ -569,6 +427,17 @@ export interface TaServer {
|
|
|
569
427
|
* stays where it is. Open the file with `openSession` to go on with it.
|
|
570
428
|
*/
|
|
571
429
|
forkToFile(sessionId: string, entryId: string, position?: 'before' | 'at'): Promise<TaForkFileResult>;
|
|
430
|
+
/**
|
|
431
|
+
* The whole conversation copied into the directory it works in now, a new conversation of its own (pi's
|
|
432
|
+
* `SessionManager.forkFrom`): for one whose directory is gone (TaSessionInfo.movedFrom), to go on there.
|
|
433
|
+
*/
|
|
434
|
+
forkHere(sessionId: string): Promise<TaForkFileResult>;
|
|
435
|
+
/**
|
|
436
|
+
* What of Ta names a directory, as it was (moved, renamed, or the path of another computer after a move) and its
|
|
437
|
+
* directories under it: their conversations (pi's session files go to the folder of the new directory), the data
|
|
438
|
+
* packages keep of it and the working directory, all made the directory `to`, which must exist.
|
|
439
|
+
*/
|
|
440
|
+
relocateDirectory(from: string, to: string): Promise<TaRelocateResult>;
|
|
572
441
|
clone(sessionId: string): Promise<TaCommandResult<'clone'>>;
|
|
573
442
|
getForkMessages(sessionId: string): Promise<TaCommandResult<'get_fork_messages'>>;
|
|
574
443
|
getEntries(sessionId: string, since?: string): Promise<TaCommandResult<'get_entries'>>;
|
|
@@ -613,5 +482,14 @@ export interface TaClient {
|
|
|
613
482
|
onRemoteEvent(event: TaRemoteEvent): Promise<void>;
|
|
614
483
|
/** What happens in the rooms, once this connection called TaRoomServer.watch. */
|
|
615
484
|
onRoomEvent(event: TaRoomEvent): Promise<void>;
|
|
485
|
+
/** What a voice this connection opened for a call tells (TaVoiceServer.openVoice). */
|
|
486
|
+
onVoiceEvent(event: TaVoiceEvent): Promise<void>;
|
|
487
|
+
/** What the desktops ask (a password), once this connection called TaScreenShareServer.watchDesktops. */
|
|
488
|
+
onScreenShareEvent(event: TaDesktopEvent): Promise<void>;
|
|
489
|
+
/**
|
|
490
|
+
* ta serve asks this page something (TaPageServer.attach said it answers `kind`): what it answers, or an error. Only
|
|
491
|
+
* a page of the person whose run asks is asked (docs/design/ta-app-use.md 4.1).
|
|
492
|
+
*/
|
|
493
|
+
onPageAsk(kind: string, payload: unknown): Promise<unknown>;
|
|
616
494
|
}
|
|
617
495
|
export {};
|
|
@@ -13,50 +13,6 @@ export const TA_SERVE_RESTART_EXIT_CODE = 75;
|
|
|
13
13
|
* the conversation again and has it carry on (TaSessionResume of ta-host); the web client shows it as a mark.
|
|
14
14
|
*/
|
|
15
15
|
export const TA_RESUME_MESSAGE = 'ta-resume';
|
|
16
|
-
/** The stable `code` of each failure of a {@link TaServer} call. */
|
|
17
|
-
export const TaErrorCode = {
|
|
18
|
-
SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND',
|
|
19
|
-
SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED',
|
|
20
|
-
TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS',
|
|
21
|
-
MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT',
|
|
22
|
-
MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND',
|
|
23
|
-
INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT',
|
|
24
|
-
COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
|
|
25
|
-
/** Compacting found nothing to compact: the conversation is still short. */
|
|
26
|
-
NOTHING_TO_COMPACT: 'CELL_TA_NOTHING_TO_COMPACT',
|
|
27
|
-
/** Compacting found nothing to compact: nothing came after the last compaction. */
|
|
28
|
-
ALREADY_COMPACTED: 'CELL_TA_ALREADY_COMPACTED',
|
|
29
|
-
/** The session is answering or compacting, which has to end first. */
|
|
30
|
-
SESSION_BUSY: 'CELL_TA_SESSION_BUSY',
|
|
31
|
-
/** Stopped before it ended, by the user (abort) or an extension: nothing to report. */
|
|
32
|
-
CANCELLED: 'CELL_TA_CANCELLED',
|
|
33
|
-
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
34
|
-
NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN',
|
|
35
|
-
/** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
|
|
36
|
-
ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED',
|
|
37
|
-
/** Behind a gateway: more messages a minute than one may send; try again in a moment. */
|
|
38
|
-
RATE_LIMITED: 'CELL_TA_RATE_LIMITED',
|
|
39
|
-
/** One let in by the user (docs/design/ta-team.md) may not do this: `data` says the action it needs (TaForbiddenData). */
|
|
40
|
-
FORBIDDEN: 'CELL_TA_FORBIDDEN',
|
|
41
|
-
/** 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. */
|
|
42
|
-
LIMIT: 'CELL_TA_LIMIT',
|
|
43
|
-
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
44
|
-
CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
|
|
45
|
-
};
|
|
46
|
-
export var TaErrorUtil;
|
|
47
|
-
(function (TaErrorUtil) {
|
|
48
|
-
/** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
|
|
49
|
-
function code(error) {
|
|
50
|
-
var _a;
|
|
51
|
-
var _b;
|
|
52
|
-
const failure = error;
|
|
53
|
-
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;
|
|
54
|
-
return typeof code === 'string' ? code : undefined;
|
|
55
|
-
}
|
|
56
|
-
TaErrorUtil.code = code;
|
|
57
|
-
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
58
|
-
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
59
|
-
export const TA_RPC_ERROR_CODE = -32050;
|
|
60
16
|
export var TaSlashCommandUtil;
|
|
61
17
|
(function (TaSlashCommandUtil) {
|
|
62
18
|
/** Its description in a language such as `zh-CN`: in that language, else in its first part (`zh`), else its own. */
|
|
@@ -67,194 +23,4 @@ export var TaSlashCommandUtil;
|
|
|
67
23
|
}
|
|
68
24
|
TaSlashCommandUtil.description = description;
|
|
69
25
|
})(TaSlashCommandUtil || (TaSlashCommandUtil = {}));
|
|
70
|
-
/**
|
|
71
|
-
* A message of the user may start with a `<context>` block: what the model reads besides the message
|
|
72
|
-
* (where it is said, who is there, what was said before), which a client leaves out when it shows it.
|
|
73
|
-
*/
|
|
74
|
-
export var TaMessageContext;
|
|
75
|
-
(function (TaMessageContext) {
|
|
76
|
-
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
77
|
-
function wrap(context, message) {
|
|
78
|
-
return `<context>\n${context}\n</context>\n${message}`;
|
|
79
|
-
}
|
|
80
|
-
TaMessageContext.wrap = wrap;
|
|
81
|
-
/** The message without its context: what the user sees of it. */
|
|
82
|
-
function strip(message) {
|
|
83
|
-
return message.replace(BLOCK, '');
|
|
84
|
-
}
|
|
85
|
-
TaMessageContext.strip = strip;
|
|
86
|
-
/** The context of the message, without its tags; undefined without one. */
|
|
87
|
-
function read(message) {
|
|
88
|
-
var _a;
|
|
89
|
-
const block = (_a = BLOCK.exec(message)) === null || _a === void 0 ? void 0 : _a[0];
|
|
90
|
-
return block === null || block === void 0 ? void 0 : block.replace(/^<context>\n?/, '').replace(/\n?<\/context>\n?$/, '');
|
|
91
|
-
}
|
|
92
|
-
TaMessageContext.read = read;
|
|
93
|
-
})(TaMessageContext || (TaMessageContext = {}));
|
|
94
|
-
/**
|
|
95
|
-
* A message a package sends as the user (a choice in a card, a scheduled task, a channel) says so in the last line
|
|
96
|
-
* of its `<context>` block, `[ta:from <name> <detail>]`: a page shows where it came from, the model reads it too,
|
|
97
|
-
* and a page older than it leaves it out with the rest of the context. A command (`/compact`, `!ls`) is not marked.
|
|
98
|
-
*/
|
|
99
|
-
export var TaMessageSource;
|
|
100
|
-
(function (TaMessageSource) {
|
|
101
|
-
/** The double of the web page: the tasks it hands out, what it tells them on the way. */
|
|
102
|
-
TaMessageSource.DOUBLE = 'ta:double';
|
|
103
|
-
const LINE = /^\[ta:from ([^\s\]]+)(?: ([^\]\n]+))?\]$/m;
|
|
104
|
-
/** `message` as sent by `from`; as it was when it is a command or says where it came from already. */
|
|
105
|
-
function mark(message, from, detail) {
|
|
106
|
-
if (/^[/!]/.test(message) || of(message)) {
|
|
107
|
-
return message;
|
|
108
|
-
}
|
|
109
|
-
const line = `[ta:from ${from}${detail ? ` ${detail.replace(/[\]\n]/g, ' ')}` : ''}]`;
|
|
110
|
-
const context = TaMessageContext.read(message);
|
|
111
|
-
return TaMessageContext.wrap(context === undefined ? line : `${context}\n${line}`, TaMessageContext.strip(message));
|
|
112
|
-
}
|
|
113
|
-
TaMessageSource.mark = mark;
|
|
114
|
-
function of(message) {
|
|
115
|
-
const context = TaMessageContext.read(message);
|
|
116
|
-
const match = context === undefined ? null : LINE.exec(context);
|
|
117
|
-
return match ? { from: match[1], ...(match[2] ? { detail: match[2].trim() } : {}) } : undefined;
|
|
118
|
-
}
|
|
119
|
-
TaMessageSource.of = of;
|
|
120
|
-
})(TaMessageSource || (TaMessageSource = {}));
|
|
121
|
-
/**
|
|
122
|
-
* 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
|
|
123
|
-
* the image was before it made it smaller, and what it was converted from. Clients leave them out.
|
|
124
|
-
*/
|
|
125
|
-
export var TaImageNote;
|
|
126
|
-
(function (TaImageNote) {
|
|
127
|
-
const NOTE = /^\[Image: original \d+x\d+, displayed at \d+x\d+\. Multiply coordinates by [\d.]+ to map to original image\.\]$|^\[Image converted from [^\]]+ to [^\]]+\.\]$/;
|
|
128
|
-
/** The text without the notes of its images: what the user sees of it. */
|
|
129
|
-
function strip(text) {
|
|
130
|
-
const lines = text.split('\n');
|
|
131
|
-
const kept = lines.filter(line => !NOTE.test(line.trim()));
|
|
132
|
-
if (kept.length === lines.length) {
|
|
133
|
-
return text;
|
|
134
|
-
}
|
|
135
|
-
return kept.join('\n').replace(/\n+$/, '').replace(/^\n+/, '');
|
|
136
|
-
}
|
|
137
|
-
TaImageNote.strip = strip;
|
|
138
|
-
})(TaImageNote || (TaImageNote = {}));
|
|
139
|
-
/** The width and height of an image, read from the start of its bytes (PNG, JPEG, GIF, WebP); undefined for another kind. */
|
|
140
|
-
export var TaImageSize;
|
|
141
|
-
(function (TaImageSize) {
|
|
142
|
-
/** How much of a JPEG is read for its size: the frame header follows what the camera wrote, a thumbnail too. */
|
|
143
|
-
const JPEG_BYTES = 256 * 1024;
|
|
144
|
-
function of(base64) {
|
|
145
|
-
var _a, _b, _c;
|
|
146
|
-
let bytes;
|
|
147
|
-
try {
|
|
148
|
-
// Whole groups of four characters only.
|
|
149
|
-
const binary = atob(base64.slice(0, Math.ceil((JPEG_BYTES * 4) / 3 / 4) * 4));
|
|
150
|
-
bytes = Uint8Array.from(binary, char => char.charCodeAt(0));
|
|
151
|
-
}
|
|
152
|
-
catch (_d) {
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
const size = (_c = (_b = (_a = png(bytes)) !== null && _a !== void 0 ? _a : gif(bytes)) !== null && _b !== void 0 ? _b : webp(bytes)) !== null && _c !== void 0 ? _c : jpeg(bytes);
|
|
156
|
-
return size && size.width > 0 && size.height > 0 ? size : undefined;
|
|
157
|
-
}
|
|
158
|
-
TaImageSize.of = of;
|
|
159
|
-
function u16be(bytes, at) {
|
|
160
|
-
return (bytes[at] << 8) | bytes[at + 1];
|
|
161
|
-
}
|
|
162
|
-
function u16le(bytes, at) {
|
|
163
|
-
return bytes[at] | (bytes[at + 1] << 8);
|
|
164
|
-
}
|
|
165
|
-
function u24le(bytes, at) {
|
|
166
|
-
return bytes[at] | (bytes[at + 1] << 8) | (bytes[at + 2] << 16);
|
|
167
|
-
}
|
|
168
|
-
function u32be(bytes, at) {
|
|
169
|
-
return ((bytes[at] << 24) | (bytes[at + 1] << 16) | (bytes[at + 2] << 8) | bytes[at + 3]) >>> 0;
|
|
170
|
-
}
|
|
171
|
-
function text(bytes, at, length) {
|
|
172
|
-
return String.fromCharCode(...bytes.subarray(at, at + length));
|
|
173
|
-
}
|
|
174
|
-
function png(bytes) {
|
|
175
|
-
return bytes.length >= 24 && bytes[0] === 0x89 && text(bytes, 1, 3) === 'PNG' ? { width: u32be(bytes, 16), height: u32be(bytes, 20) } : undefined;
|
|
176
|
-
}
|
|
177
|
-
function gif(bytes) {
|
|
178
|
-
return bytes.length >= 10 && text(bytes, 0, 3) === 'GIF' ? { width: u16le(bytes, 6), height: u16le(bytes, 8) } : undefined;
|
|
179
|
-
}
|
|
180
|
-
function webp(bytes) {
|
|
181
|
-
if (bytes.length < 30 || text(bytes, 0, 4) !== 'RIFF' || text(bytes, 8, 4) !== 'WEBP') {
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
switch (text(bytes, 12, 4)) {
|
|
185
|
-
case 'VP8 ':
|
|
186
|
-
return { width: u16le(bytes, 26) & 0x3fff, height: u16le(bytes, 28) & 0x3fff };
|
|
187
|
-
case 'VP8L': {
|
|
188
|
-
const bits = bytes[21] | (bytes[22] << 8) | (bytes[23] << 16) | (bytes[24] << 24);
|
|
189
|
-
return { width: (bits & 0x3fff) + 1, height: ((bits >> 14) & 0x3fff) + 1 };
|
|
190
|
-
}
|
|
191
|
-
case 'VP8X':
|
|
192
|
-
return { width: u24le(bytes, 24) + 1, height: u24le(bytes, 27) + 1 };
|
|
193
|
-
default:
|
|
194
|
-
return undefined;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
function jpeg(bytes) {
|
|
198
|
-
if (bytes[0] !== 0xff || bytes[1] !== 0xd8) {
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
|
-
let at = 2;
|
|
202
|
-
while (at + 9 < bytes.length) {
|
|
203
|
-
if (bytes[at] !== 0xff) {
|
|
204
|
-
return undefined;
|
|
205
|
-
}
|
|
206
|
-
const marker = bytes[at + 1];
|
|
207
|
-
// A start of frame (not DHT, JPG or DAC, which share the range) says the size.
|
|
208
|
-
if (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {
|
|
209
|
-
return { width: u16be(bytes, at + 7), height: u16be(bytes, at + 5) };
|
|
210
|
-
}
|
|
211
|
-
at += 2 + u16be(bytes, at + 2);
|
|
212
|
-
}
|
|
213
|
-
return undefined;
|
|
214
|
-
}
|
|
215
|
-
})(TaImageSize || (TaImageSize = {}));
|
|
216
|
-
/**
|
|
217
|
-
* An external agent that compacts its own context says the summary it goes on from as text, in tags
|
|
218
|
-
* (`<conversation_history_summary><summary>…`). Clients show it folded, not as what the agent said.
|
|
219
|
-
*/
|
|
220
|
-
export var TaAgentSummary;
|
|
221
|
-
(function (TaAgentSummary) {
|
|
222
|
-
const START = /^\s*<conversation_history_summary>/;
|
|
223
|
-
const BLOCK = /^\s*<conversation_history_summary>[\s\S]*?(?:<\/conversation_history_summary>\s*|$)/;
|
|
224
|
-
/** The summary `text` is, without its tags (and the start of a closing tag while it streams); else undefined. */
|
|
225
|
-
function read(text) {
|
|
226
|
-
if (!START.test(text)) {
|
|
227
|
-
return undefined;
|
|
228
|
-
}
|
|
229
|
-
return text
|
|
230
|
-
.replace(/<\/?(?:conversation_history_summary|summary)>/g, '')
|
|
231
|
-
.replace(/<\/?\w*$/, '')
|
|
232
|
-
.trim();
|
|
233
|
-
}
|
|
234
|
-
TaAgentSummary.read = read;
|
|
235
|
-
/** The text without the summary it starts with. */
|
|
236
|
-
function strip(text) {
|
|
237
|
-
return text.replace(BLOCK, '');
|
|
238
|
-
}
|
|
239
|
-
TaAgentSummary.strip = strip;
|
|
240
|
-
})(TaAgentSummary || (TaAgentSummary = {}));
|
|
241
|
-
/** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
|
|
242
|
-
export var TaSkillUse;
|
|
243
|
-
(function (TaSkillUse) {
|
|
244
|
-
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
245
|
-
function parse(message) {
|
|
246
|
-
var _a;
|
|
247
|
-
const match = BLOCK.exec(message);
|
|
248
|
-
if (!match) {
|
|
249
|
-
return undefined;
|
|
250
|
-
}
|
|
251
|
-
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined };
|
|
252
|
-
}
|
|
253
|
-
TaSkillUse.parse = parse;
|
|
254
|
-
/** What the user typed: `/skill:name` and what follows. */
|
|
255
|
-
function command(use) {
|
|
256
|
-
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
257
|
-
}
|
|
258
|
-
TaSkillUse.command = command;
|
|
259
|
-
})(TaSkillUse || (TaSkillUse = {}));
|
|
260
26
|
//# sourceMappingURL=ta-protocol.js.map
|
|
@@ -16,7 +16,7 @@ export interface TaSharedRef {
|
|
|
16
16
|
/** What an action is done on. */
|
|
17
17
|
export interface TaResource {
|
|
18
18
|
/** `session`: a conversation, by its file; `dir`: a directory or a file in it, by its path; `agent`, `channel`: one of ta-channels, by its id. */
|
|
19
|
-
kind: 'session' | 'dir' | 'agent' | 'channel';
|
|
19
|
+
kind: 'session' | 'dir' | 'agent' | 'channel' | 'desktop';
|
|
20
20
|
/** The session file, the path, or the id of the agent or channel. */
|
|
21
21
|
id: string;
|
|
22
22
|
/** A session: where it works. */
|
|
@@ -128,14 +128,25 @@ export interface TaActionInfo {
|
|
|
128
128
|
scoped?: boolean;
|
|
129
129
|
/** Reaches beyond what Ta checks (a command can touch any file): only for people trusted. */
|
|
130
130
|
risky?: boolean;
|
|
131
|
+
/** `single`: given only on its own to one person, never by a role (docs/design/ta-desktop-remote.md 6.2). */
|
|
132
|
+
grant?: 'role' | 'single';
|
|
131
133
|
}
|
|
132
|
-
export type TaActionArea = 'chat' | 'agent' | 'channel' | 'task' | 'files' | 'commands' | 'hosts' | 'models' | 'cron' | 'extensions' | 'settings' | 'members' | 'audit';
|
|
134
|
+
export type TaActionArea = 'chat' | 'agent' | 'channel' | 'task' | 'files' | 'commands' | 'hosts' | 'models' | 'cron' | 'extensions' | 'settings' | 'members' | 'audit' | 'desktop';
|
|
133
135
|
/** Every action of Ta itself; packages add their own (`pi.permissions` of their package.json). */
|
|
134
136
|
export declare const TA_ACTIONS: readonly TaActionInfo[];
|
|
137
|
+
/**
|
|
138
|
+
* Actions of the owner alone (docs/design/ta-desktop-remote.md 6.2): their words for records and notices, never in
|
|
139
|
+
* TA_ACTIONS, so that no role or grant gives them; TaActionUtil.grantable says no to every one of their areas.
|
|
140
|
+
*/
|
|
141
|
+
export declare const TA_OWNER_ACTIONS: readonly TaActionInfo[];
|
|
135
142
|
export declare namespace TaActionUtil {
|
|
136
143
|
function info(id: string): TaActionInfo | undefined;
|
|
137
144
|
/** Its title in a language such as `zh-CN`; the id for an action of no catalog. */
|
|
138
145
|
function title(id: string, language: string): string;
|
|
146
|
+
/** Whether an action may be given to someone at all, by a role or on its own: one of TA_ACTIONS, of no area of the owner's. */
|
|
147
|
+
function grantable(id: string): boolean;
|
|
148
|
+
/** Whether an action may be in a role: grantable, and not one given only on its own (`grant: 'single'`). */
|
|
149
|
+
function inRoles(id: string): boolean;
|
|
139
150
|
/** Whether `path` is `dir` or inside it; both absolute, `/` separated. */
|
|
140
151
|
function inside(dir: string, path: string): boolean;
|
|
141
152
|
}
|
|
@@ -67,7 +67,8 @@ export const TA_ACTIONS = [
|
|
|
67
67
|
action('commands.terminal', 'Open terminals', '打开终端', '開啟終端機', 'ターミナルを開く', { scoped: true, risky: true }),
|
|
68
68
|
action('hosts.use', 'Use remote hosts', '使用远程主机', '使用遠端主機', 'リモートホストを使用', { risky: true }),
|
|
69
69
|
action('models.use', 'Use the models', '使用模型', '使用模型', 'モデルを使用'),
|
|
70
|
-
|
|
70
|
+
// In no role: who has it may send the owner's conversations to a service of their own (docs/design/ta-desktop-remote.md 6.2).
|
|
71
|
+
action('models.manage', 'Sign in to models', '登录和更换模型账号', '登入和更換模型帳號', 'モデルアカウントにサインイン・変更', { grant: 'single' }),
|
|
71
72
|
action('cron.view', 'See scheduled tasks', '查看定时任务', '檢視定時任務', 'スケジュールタスクを確認'),
|
|
72
73
|
action('cron.manage', 'Change scheduled tasks', '管理定时任务', '管理定時任務', 'スケジュールタスクを管理'),
|
|
73
74
|
action('extensions.use', 'Use extensions', '使用扩展', '使用擴充功能', '拡張機能を使用'),
|
|
@@ -80,9 +81,21 @@ export const TA_ACTIONS = [
|
|
|
80
81
|
action('members.roles', 'Change roles and members', '管理角色和成员', '管理角色和成員', 'ロールとメンバーを管理'),
|
|
81
82
|
action('audit.view', 'See the record', '查看记录', '檢視記錄', 'レコードを確認'),
|
|
82
83
|
];
|
|
84
|
+
/**
|
|
85
|
+
* Actions of the owner alone (docs/design/ta-desktop-remote.md 6.2): their words for records and notices, never in
|
|
86
|
+
* TA_ACTIONS, so that no role or grant gives them; TaActionUtil.grantable says no to every one of their areas.
|
|
87
|
+
*/
|
|
88
|
+
export const TA_OWNER_ACTIONS = [
|
|
89
|
+
action('desktop.view', 'See remote desktops', '查看远程桌面', '檢視遠端桌面', 'リモートデスクトップを見る', { risky: true }),
|
|
90
|
+
action('desktop.control', 'Work remote desktops', '操作远程桌面', '操作遠端桌面', 'リモートデスクトップを操作', { risky: true }),
|
|
91
|
+
];
|
|
92
|
+
/** The areas of TA_OWNER_ACTIONS: nothing of them is given to anyone, whatever a role or team.json says. */
|
|
93
|
+
const OWNER_AREAS = ['desktop'];
|
|
83
94
|
export var TaActionUtil;
|
|
84
95
|
(function (TaActionUtil) {
|
|
85
96
|
const byId = new Map(TA_ACTIONS.map(one => [one.id, one]));
|
|
97
|
+
/** Titles of the owner's actions too, for records and notices. */
|
|
98
|
+
const titled = new Map([...TA_ACTIONS, ...TA_OWNER_ACTIONS].map(one => [one.id, one]));
|
|
86
99
|
function info(id) {
|
|
87
100
|
return byId.get(id);
|
|
88
101
|
}
|
|
@@ -91,7 +104,7 @@ export var TaActionUtil;
|
|
|
91
104
|
function title(id, language) {
|
|
92
105
|
var _a;
|
|
93
106
|
var _b, _c;
|
|
94
|
-
const title = (_a =
|
|
107
|
+
const title = (_a = titled.get(id)) === null || _a === void 0 ? void 0 : _a.title;
|
|
95
108
|
if (!title) {
|
|
96
109
|
return id;
|
|
97
110
|
}
|
|
@@ -103,6 +116,18 @@ export var TaActionUtil;
|
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
TaActionUtil.title = title;
|
|
119
|
+
/** Whether an action may be given to someone at all, by a role or on its own: one of TA_ACTIONS, of no area of the owner's. */
|
|
120
|
+
function grantable(id) {
|
|
121
|
+
const info = byId.get(id);
|
|
122
|
+
return !!info && !OWNER_AREAS.includes(info.area);
|
|
123
|
+
}
|
|
124
|
+
TaActionUtil.grantable = grantable;
|
|
125
|
+
/** Whether an action may be in a role: grantable, and not one given only on its own (`grant: 'single'`). */
|
|
126
|
+
function inRoles(id) {
|
|
127
|
+
var _a;
|
|
128
|
+
return grantable(id) && ((_a = byId.get(id)) === null || _a === void 0 ? void 0 : _a.grant) !== 'single';
|
|
129
|
+
}
|
|
130
|
+
TaActionUtil.inRoles = inRoles;
|
|
106
131
|
/** Whether `path` is `dir` or inside it; both absolute, `/` separated. */
|
|
107
132
|
function inside(dir, path) {
|
|
108
133
|
const base = dir.replace(/\/+$/, '');
|