@celljs/ta-protocol 4.7.0 → 4.9.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/README.en.md +2 -2
- package/README.md +2 -2
- package/esm/common/access-protocol.d.ts +73 -0
- package/esm/common/access-protocol.js +9 -0
- package/esm/common/gateway-protocol.d.ts +81 -0
- package/esm/common/gateway-protocol.js +3 -0
- package/esm/common/index.d.ts +2 -0
- package/esm/common/index.js +2 -0
- package/esm/common/location.d.ts +5 -0
- package/esm/common/location.js +12 -0
- package/esm/common/package-protocol.d.ts +60 -1
- package/esm/common/package-protocol.js +12 -0
- package/esm/common/relay-protocol.d.ts +17 -0
- package/esm/common/settings-protocol.d.ts +9 -0
- package/esm/common/ta-extension-host.d.ts +40 -3
- package/esm/common/ta-extension-host.js +13 -0
- package/esm/common/ta-protocol.d.ts +115 -4
- package/esm/common/ta-protocol.js +33 -0
- package/esm/common/workspace-protocol.d.ts +28 -1
- package/esm/common/workspace-protocol.js +21 -0
- package/lib/common/access-protocol.d.ts +74 -0
- package/lib/common/access-protocol.js +12 -0
- package/lib/common/gateway-protocol.d.ts +82 -0
- package/lib/common/gateway-protocol.js +6 -0
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/common/location.d.ts +5 -0
- package/lib/common/location.js +12 -0
- package/lib/common/package-protocol.d.ts +60 -1
- package/lib/common/package-protocol.js +13 -1
- package/lib/common/relay-protocol.d.ts +17 -0
- package/lib/common/settings-protocol.d.ts +9 -0
- package/lib/common/ta-extension-host.d.ts +40 -3
- package/lib/common/ta-extension-host.js +14 -1
- package/lib/common/ta-protocol.d.ts +115 -4
- package/lib/common/ta-protocol.js +34 -1
- package/lib/common/workspace-protocol.d.ts +28 -1
- package/lib/common/workspace-protocol.js +22 -1
- package/package.json +3 -2
- package/esm/common/auth-protocol.js.map +0 -1
- package/esm/common/index.js.map +0 -1
- package/esm/common/location.js.map +0 -1
- package/esm/common/package-protocol.js.map +0 -1
- package/esm/common/pi-types.js.map +0 -1
- package/esm/common/relay-protocol.js.map +0 -1
- package/esm/common/remote-protocol.js.map +0 -1
- package/esm/common/settings-protocol.js.map +0 -1
- package/esm/common/ta-extension-host.js.map +0 -1
- package/esm/common/ta-protocol.js.map +0 -1
- package/esm/common/workspace-protocol.js.map +0 -1
- package/lib/common/auth-protocol.d.ts.map +0 -1
- package/lib/common/auth-protocol.js.map +0 -1
- package/lib/common/index.d.ts.map +0 -1
- package/lib/common/index.js.map +0 -1
- package/lib/common/location.d.ts.map +0 -1
- package/lib/common/location.js.map +0 -1
- package/lib/common/location.spec.d.ts +0 -2
- package/lib/common/location.spec.d.ts.map +0 -1
- package/lib/common/location.spec.js +0 -58
- package/lib/common/location.spec.js.map +0 -1
- package/lib/common/package-protocol.d.ts.map +0 -1
- package/lib/common/package-protocol.js.map +0 -1
- package/lib/common/pi-types.d.ts.map +0 -1
- package/lib/common/pi-types.js.map +0 -1
- package/lib/common/relay-protocol.d.ts.map +0 -1
- package/lib/common/relay-protocol.js.map +0 -1
- package/lib/common/remote-protocol.d.ts.map +0 -1
- package/lib/common/remote-protocol.js.map +0 -1
- package/lib/common/settings-protocol.d.ts.map +0 -1
- package/lib/common/settings-protocol.js.map +0 -1
- package/lib/common/ta-extension-host.d.ts.map +0 -1
- package/lib/common/ta-extension-host.js.map +0 -1
- package/lib/common/ta-protocol.d.ts.map +0 -1
- package/lib/common/ta-protocol.js.map +0 -1
- package/lib/common/ta-protocol.spec.d.ts +0 -2
- package/lib/common/ta-protocol.spec.d.ts.map +0 -1
- package/lib/common/ta-protocol.spec.js +0 -41
- package/lib/common/ta-protocol.spec.js.map +0 -1
- package/lib/common/workspace-protocol.d.ts.map +0 -1
- package/lib/common/workspace-protocol.js.map +0 -1
- package/src/common/auth-protocol.ts +0 -56
- package/src/common/index.ts +0 -10
- package/src/common/location.spec.ts +0 -62
- package/src/common/location.ts +0 -177
- package/src/common/package-protocol.ts +0 -99
- package/src/common/pi-types.ts +0 -11
- package/src/common/relay-protocol.ts +0 -28
- package/src/common/remote-protocol.ts +0 -76
- package/src/common/settings-protocol.ts +0 -66
- package/src/common/ta-extension-host.ts +0 -54
- package/src/common/ta-protocol.spec.ts +0 -48
- package/src/common/ta-protocol.ts +0 -347
- package/src/common/workspace-protocol.ts +0 -102
|
@@ -40,10 +40,16 @@ export declare const TaErrorCode: {
|
|
|
40
40
|
readonly COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED';
|
|
41
41
|
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
42
42
|
readonly NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN';
|
|
43
|
+
/** Behind a gateway (`ta gateway`): the environment of the tenant did not start; TaGatewayServer changes or restarts it. */
|
|
44
|
+
readonly ENVIRONMENT_FAILED: 'CELL_TA_ENVIRONMENT_FAILED';
|
|
43
45
|
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
44
46
|
readonly CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST';
|
|
45
47
|
};
|
|
46
48
|
export type TaErrorCode = (typeof TaErrorCode)[keyof typeof TaErrorCode];
|
|
49
|
+
export declare namespace TaErrorUtil {
|
|
50
|
+
/** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
|
|
51
|
+
function code(error: unknown): string | undefined;
|
|
52
|
+
}
|
|
47
53
|
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
48
54
|
export declare const TA_RPC_ERROR_CODE = -32050;
|
|
49
55
|
export interface TaErrorData {
|
|
@@ -123,6 +129,24 @@ export interface TaSessionInfo {
|
|
|
123
129
|
/** TaOpenSessionOptions.group. */
|
|
124
130
|
group?: string;
|
|
125
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* A conversation in a session file of pi that no session has open: the service closed it while idle, or
|
|
134
|
+
* before it restarted. TaServer.openSession with its `sessionFile` opens it again.
|
|
135
|
+
*/
|
|
136
|
+
export interface TaSavedSessionInfo {
|
|
137
|
+
sessionFile: string;
|
|
138
|
+
piSessionId: string;
|
|
139
|
+
cwd: string;
|
|
140
|
+
sessionName?: string;
|
|
141
|
+
/** The first line of the first message of the user. */
|
|
142
|
+
firstMessage?: string;
|
|
143
|
+
messageCount: number;
|
|
144
|
+
createdAt: number;
|
|
145
|
+
/** When the last message came; `createdAt` before the first. */
|
|
146
|
+
updatedAt: number;
|
|
147
|
+
/** The group it was opened for (TaOpenSessionOptions.group): its package opens it again, with its role. */
|
|
148
|
+
group?: string;
|
|
149
|
+
}
|
|
126
150
|
export interface TaPromptInput {
|
|
127
151
|
/** May start with a block of context for the model, which clients do not show: see {@link TaMessageContext}. */
|
|
128
152
|
message: string;
|
|
@@ -141,6 +165,22 @@ export declare namespace TaMessageContext {
|
|
|
141
165
|
/** The message without its context: what the user sees of it. */
|
|
142
166
|
function strip(message: string): string;
|
|
143
167
|
}
|
|
168
|
+
/** A skill the user ran with `/skill:name`, as pi puts it in the message: the skill's file, then what the user wrote. */
|
|
169
|
+
export interface TaSkillUse {
|
|
170
|
+
name: string;
|
|
171
|
+
/** The path of its SKILL.md. */
|
|
172
|
+
location: string;
|
|
173
|
+
/** What pi read of it, for the model. */
|
|
174
|
+
content: string;
|
|
175
|
+
/** What the user wrote after `/skill:name`. */
|
|
176
|
+
message?: string;
|
|
177
|
+
}
|
|
178
|
+
/** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
|
|
179
|
+
export declare namespace TaSkillUse {
|
|
180
|
+
function parse(message: string): TaSkillUse | undefined;
|
|
181
|
+
/** What the user typed: `/skill:name` and what follows. */
|
|
182
|
+
function command(use: TaSkillUse): string;
|
|
183
|
+
}
|
|
144
184
|
/**
|
|
145
185
|
* The server has taken the message; it says nothing about the run. A run is finished at the
|
|
146
186
|
* `agent_settled` event, when its history is on disk.
|
|
@@ -167,13 +207,22 @@ export interface TaSessionReplaced {
|
|
|
167
207
|
type: 'session_replaced';
|
|
168
208
|
info: TaSessionInfo;
|
|
169
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* The session loaded its extensions, skills, prompts and themes again (`reload`, or an extension's
|
|
212
|
+
* `ctx.reload()`): its commands may have changed, read them again (`getCommands`).
|
|
213
|
+
*/
|
|
214
|
+
export interface TaSessionReloaded {
|
|
215
|
+
type: 'session_reloaded';
|
|
216
|
+
}
|
|
170
217
|
/** The session was closed; no more events come. */
|
|
171
218
|
export interface TaSessionClosed {
|
|
172
219
|
type: 'session_closed';
|
|
173
220
|
}
|
|
174
221
|
/**
|
|
175
|
-
* The model called a tool of `clientTools`: a client that runs it
|
|
176
|
-
*
|
|
222
|
+
* The model called a tool of `clientTools`: a client that runs it takes it with `claimClientTool`, so
|
|
223
|
+
* that one client runs it, however many are attached, and answers with `respondClientTool`. When that
|
|
224
|
+
* client leaves the session before it answers, the request comes again with the same id, for another.
|
|
225
|
+
* `client_tool_resolved` tells the others it was answered.
|
|
177
226
|
*/
|
|
178
227
|
export interface TaClientToolRequest {
|
|
179
228
|
type: 'client_tool_request';
|
|
@@ -187,21 +236,68 @@ export interface TaClientToolResolved {
|
|
|
187
236
|
type: 'client_tool_resolved';
|
|
188
237
|
id: string;
|
|
189
238
|
}
|
|
190
|
-
export type TaEvent = JsonAgentSessionEvent | RpcExtensionUIRequest | TaUiRequestResolved | TaExtensionError | TaClientToolRequest | TaClientToolResolved | TaSessionReplaced | TaSessionClosed;
|
|
239
|
+
export type TaEvent = JsonAgentSessionEvent | RpcExtensionUIRequest | TaUiRequestResolved | TaExtensionError | TaClientToolRequest | TaClientToolResolved | TaSessionReplaced | TaSessionReloaded | TaSessionClosed;
|
|
191
240
|
export interface TaEventEnvelope {
|
|
192
241
|
sessionId: string;
|
|
193
242
|
/** Increases by one per event of the session. */
|
|
194
243
|
seq: number;
|
|
195
244
|
event: TaEvent;
|
|
196
245
|
}
|
|
246
|
+
/** A message of the conversation, as `getMessages` gives it. */
|
|
247
|
+
export type TaMessage = TaCommandResult<'get_messages'>['messages'][number];
|
|
248
|
+
/** A call of a tool in the run of now, as its events left it. */
|
|
249
|
+
export interface TaToolRun {
|
|
250
|
+
toolName: string;
|
|
251
|
+
args: unknown;
|
|
252
|
+
/** The latest partial result while it runs, then the result. */
|
|
253
|
+
result?: unknown;
|
|
254
|
+
status: 'running' | 'done' | 'error';
|
|
255
|
+
/** Set for a call another tool made, such as a codemode script. */
|
|
256
|
+
parentToolCallId?: string;
|
|
257
|
+
}
|
|
258
|
+
/** The conversation as the events up to `lastSeq` left it: where a client without them starts. */
|
|
259
|
+
export interface TaConversation {
|
|
260
|
+
/** With the message the model is writing now, last: `getMessages` has it only once it is written. */
|
|
261
|
+
messages: TaMessage[];
|
|
262
|
+
/** The calls of tools of the run of now, by tool call id. */
|
|
263
|
+
tools: Record<string, TaToolRun>;
|
|
264
|
+
/**
|
|
265
|
+
* Where `messages` start in the whole conversation, when only its latest came (`recentBytes` of
|
|
266
|
+
* `attach`): those before come with `getEarlierMessages`. None or 0: all of it.
|
|
267
|
+
*/
|
|
268
|
+
start?: number;
|
|
269
|
+
}
|
|
270
|
+
export interface TaAttachOptions {
|
|
271
|
+
/**
|
|
272
|
+
* Only about this many bytes of the latest messages in `conversation` (at least one, and the start of
|
|
273
|
+
* their turn when it is not much more): a long conversation shows at once, its earlier part loaded as
|
|
274
|
+
* it is scrolled to.
|
|
275
|
+
*/
|
|
276
|
+
recentBytes?: number;
|
|
277
|
+
}
|
|
278
|
+
/** The messages of a conversation before those a client has (`getEarlierMessages`). */
|
|
279
|
+
export interface TaMessagePage {
|
|
280
|
+
messages: TaMessage[];
|
|
281
|
+
/** Where they start in the whole conversation. */
|
|
282
|
+
start: number;
|
|
283
|
+
/** False when the message given is no longer there (the conversation was compacted or moved): read it again. */
|
|
284
|
+
found: boolean;
|
|
285
|
+
}
|
|
197
286
|
export interface TaAttachResult {
|
|
198
287
|
info: TaSessionInfo;
|
|
199
288
|
/** The events after `afterSeq`. */
|
|
200
289
|
events: TaEventEnvelope[];
|
|
290
|
+
/** When there is no `afterSeq`, or a `gap`: start from this, then take the events after `lastSeq`. None from a server before it. */
|
|
291
|
+
conversation?: TaConversation;
|
|
201
292
|
/** The dialogs still waiting for an answer. */
|
|
202
293
|
pendingUi: RpcExtensionUIRequest[];
|
|
203
294
|
/** The calls of client tools still waiting for a result. */
|
|
204
295
|
pendingClientTools: TaClientToolRequest[];
|
|
296
|
+
/**
|
|
297
|
+
* What the extensions show now (`setStatus`, `setWidget`), as a terminal keeps it on screen: a client
|
|
298
|
+
* that attaches draws it, whatever it missed. None from a server before it.
|
|
299
|
+
*/
|
|
300
|
+
shownUi?: RpcExtensionUIRequest[];
|
|
205
301
|
/** Seq of the last event of the session. */
|
|
206
302
|
lastSeq: number;
|
|
207
303
|
/** Some events after `afterSeq` are gone: read the conversation again with `getMessages`. */
|
|
@@ -231,11 +327,24 @@ export interface TaServer {
|
|
|
231
327
|
openSession(options: TaOpenSessionOptions): Promise<TaSessionInfo>;
|
|
232
328
|
closeSession(sessionId: string): Promise<void>;
|
|
233
329
|
listSessions(): Promise<TaSessionInfo[]>;
|
|
330
|
+
/** The conversations in pi's session files that are not open, the latest first. */
|
|
331
|
+
listSavedSessions(): Promise<TaSavedSessionInfo[]>;
|
|
234
332
|
/** Starts sending the events of the session to this connection. */
|
|
235
|
-
attach(sessionId: string, afterSeq?: number): Promise<TaAttachResult>;
|
|
333
|
+
attach(sessionId: string, afterSeq?: number, options?: TaAttachOptions): Promise<TaAttachResult>;
|
|
334
|
+
/**
|
|
335
|
+
* About `budget` bytes of the messages just before message `before` of the conversation (at least one),
|
|
336
|
+
* `timestamp` that of the message there, to know it is still the same; without `before`, the latest.
|
|
337
|
+
*/
|
|
338
|
+
getEarlierMessages(sessionId: string, before: number | undefined, timestamp: number | undefined, budget: number): Promise<TaMessagePage>;
|
|
236
339
|
detach(sessionId: string): Promise<void>;
|
|
237
340
|
/** Answers a dialog; false when it was answered before or expired. */
|
|
238
341
|
respondUi(sessionId: string, response: RpcExtensionUIResponse): Promise<boolean>;
|
|
342
|
+
/**
|
|
343
|
+
* Takes a call of a client tool to run: true for the first client that asks, and for it again; false
|
|
344
|
+
* when another client runs it or nobody waits for it. A client runs a call only once it took it: a tool
|
|
345
|
+
* that does something (opens a session) must not run in every page.
|
|
346
|
+
*/
|
|
347
|
+
claimClientTool(sessionId: string, id: string): Promise<boolean>;
|
|
239
348
|
/** Answers a call of a client tool; false when nobody waits for it. */
|
|
240
349
|
respondClientTool(sessionId: string, result: TaClientToolResult): Promise<boolean>;
|
|
241
350
|
prompt(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
@@ -243,6 +352,8 @@ export interface TaServer {
|
|
|
243
352
|
followUp(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
244
353
|
abort(sessionId: string): Promise<void>;
|
|
245
354
|
clearQueue(sessionId: string): Promise<TaCommandResult<'clear_queue'>>;
|
|
355
|
+
/** Takes one waiting message out, by its place among those of its kind; false when it has gone in already. */
|
|
356
|
+
removeQueued(sessionId: string, kind: 'steering' | 'followUp', index: number): Promise<boolean>;
|
|
246
357
|
newSession(sessionId: string, parentSession?: string): Promise<TaCommandResult<'new_session'>>;
|
|
247
358
|
getState(sessionId: string): Promise<TaCommandResult<'get_state'>>;
|
|
248
359
|
setModel(sessionId: string, provider: string, modelId: string): Promise<TaCommandResult<'set_model'>>;
|
|
@@ -17,9 +17,23 @@ export const TaErrorCode = {
|
|
|
17
17
|
COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
|
|
18
18
|
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
19
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',
|
|
20
22
|
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
21
23
|
CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
|
|
22
24
|
};
|
|
25
|
+
export var TaErrorUtil;
|
|
26
|
+
(function (TaErrorUtil) {
|
|
27
|
+
/** The {@link TaErrorCode} of a failure: `code` of the client's error, `data.code` of the server's own, called in its process. */
|
|
28
|
+
function code(error) {
|
|
29
|
+
var _a;
|
|
30
|
+
var _b;
|
|
31
|
+
const failure = error;
|
|
32
|
+
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;
|
|
33
|
+
return typeof code === 'string' ? code : undefined;
|
|
34
|
+
}
|
|
35
|
+
TaErrorUtil.code = code;
|
|
36
|
+
})(TaErrorUtil || (TaErrorUtil = {}));
|
|
23
37
|
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
24
38
|
export const TA_RPC_ERROR_CODE = -32050;
|
|
25
39
|
/**
|
|
@@ -39,4 +53,23 @@ export var TaMessageContext;
|
|
|
39
53
|
}
|
|
40
54
|
TaMessageContext.strip = strip;
|
|
41
55
|
})(TaMessageContext || (TaMessageContext = {}));
|
|
56
|
+
/** The `<skill>` block pi expands `/skill:name` into (its `parseSkillBlock`), which a client shows as the skill it is. */
|
|
57
|
+
export var TaSkillUse;
|
|
58
|
+
(function (TaSkillUse) {
|
|
59
|
+
const BLOCK = /^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;
|
|
60
|
+
function parse(message) {
|
|
61
|
+
var _a;
|
|
62
|
+
const match = BLOCK.exec(message);
|
|
63
|
+
if (!match) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return { name: match[1], location: match[2], content: match[3], message: ((_a = match[4]) === null || _a === void 0 ? void 0 : _a.trim()) || undefined };
|
|
67
|
+
}
|
|
68
|
+
TaSkillUse.parse = parse;
|
|
69
|
+
/** What the user typed: `/skill:name` and what follows. */
|
|
70
|
+
function command(use) {
|
|
71
|
+
return use.message ? `/skill:${use.name} ${use.message}` : `/skill:${use.name}`;
|
|
72
|
+
}
|
|
73
|
+
TaSkillUse.command = command;
|
|
74
|
+
})(TaSkillUse || (TaSkillUse = {}));
|
|
42
75
|
//# sourceMappingURL=ta-protocol.js.map
|
|
@@ -12,6 +12,17 @@ export interface TaDirEntry {
|
|
|
12
12
|
kind: 'file' | 'directory';
|
|
13
13
|
size?: number;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* What a list of files hides unless asked, by name at any depth, as VS Code's default `files.exclude`:
|
|
17
|
+
* the data of version control and what systems leave in folders.
|
|
18
|
+
*/
|
|
19
|
+
export declare namespace TaExcludedFiles {
|
|
20
|
+
const NAMES: readonly string[];
|
|
21
|
+
function has(name: string): boolean;
|
|
22
|
+
function filter<T extends {
|
|
23
|
+
name: string;
|
|
24
|
+
}>(entries: T[]): T[];
|
|
25
|
+
}
|
|
15
26
|
export interface TaFileContent {
|
|
16
27
|
path: string;
|
|
17
28
|
size: number;
|
|
@@ -31,6 +42,17 @@ export interface TaRunCommandOptions {
|
|
|
31
42
|
/** Of each of stdout and stderr; default 1 MB, at most 8 MB. */
|
|
32
43
|
maxBytes?: number;
|
|
33
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The most bytes of a part of {@link TaWorkspaceServer.uploadFile}: a larger file goes in parts of this size,
|
|
47
|
+
* well within what a message of the WebSocket may hold once in base64.
|
|
48
|
+
*/
|
|
49
|
+
export declare const TA_UPLOAD_PART_BYTES: number;
|
|
50
|
+
export interface TaUploadOptions {
|
|
51
|
+
/** Default: the server's directory. */
|
|
52
|
+
cwd?: string;
|
|
53
|
+
/** After what the file holds: each part of a file sent in parts but the first. */
|
|
54
|
+
append?: boolean;
|
|
55
|
+
}
|
|
34
56
|
export interface TaCommandOutput {
|
|
35
57
|
stdout: string;
|
|
36
58
|
stderr: string;
|
|
@@ -46,11 +68,16 @@ export interface TaCommandOutput {
|
|
|
46
68
|
* the work runs in the execution environment of `cwd`, as the tools of a session do.
|
|
47
69
|
*/
|
|
48
70
|
export interface TaWorkspaceServer {
|
|
49
|
-
/** Directories first, then by name; `.git`
|
|
71
|
+
/** Directories first, then by name; every entry, `.git` too: a client hides what it does not show ({@link TaExcludedFiles}). */
|
|
50
72
|
listDirectory(path: string, cwd?: string): Promise<TaDirEntry[]>;
|
|
51
73
|
readFile(path: string, cwd?: string): Promise<TaFileContent>;
|
|
52
74
|
/** Writes the text of a file; its directory must be there. */
|
|
53
75
|
writeFile(path: string, text: string, cwd?: string): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Writes bytes, in base64, to a file (one uploaded): the folders on its way are made, and a file there is
|
|
78
|
+
* replaced. A file larger than {@link TA_UPLOAD_PART_BYTES} goes in parts, each after the first with `append`.
|
|
79
|
+
*/
|
|
80
|
+
uploadFile(path: string, data: string, options?: TaUploadOptions): Promise<void>;
|
|
54
81
|
/**
|
|
55
82
|
* A URL of this server, under {@link TA_FILES_PATH}, that answers the bytes of a file of `cwd`, for
|
|
56
83
|
* what the page shows as it is: an image, a video, a page with what it loads next to it. The URL needs
|
|
@@ -4,4 +4,25 @@ export const TaWorkspaceServer = Symbol('TaWorkspaceServer');
|
|
|
4
4
|
export const TA_WORKSPACE_SERVICE = 'TaWorkspaceServer';
|
|
5
5
|
export const TaTerminalServer = Symbol('TaTerminalServer');
|
|
6
6
|
export const TA_TERMINAL_SERVICE = 'TaTerminalServer';
|
|
7
|
+
/**
|
|
8
|
+
* What a list of files hides unless asked, by name at any depth, as VS Code's default `files.exclude`:
|
|
9
|
+
* the data of version control and what systems leave in folders.
|
|
10
|
+
*/
|
|
11
|
+
export var TaExcludedFiles;
|
|
12
|
+
(function (TaExcludedFiles) {
|
|
13
|
+
TaExcludedFiles.NAMES = ['.git', '.svn', '.hg', '.DS_Store', 'Thumbs.db'];
|
|
14
|
+
function has(name) {
|
|
15
|
+
return TaExcludedFiles.NAMES.includes(name);
|
|
16
|
+
}
|
|
17
|
+
TaExcludedFiles.has = has;
|
|
18
|
+
function filter(entries) {
|
|
19
|
+
return entries.filter(entry => !has(entry.name));
|
|
20
|
+
}
|
|
21
|
+
TaExcludedFiles.filter = filter;
|
|
22
|
+
})(TaExcludedFiles || (TaExcludedFiles = {}));
|
|
23
|
+
/**
|
|
24
|
+
* The most bytes of a part of {@link TaWorkspaceServer.uploadFile}: a larger file goes in parts of this size,
|
|
25
|
+
* well within what a message of the WebSocket may hold once in base64.
|
|
26
|
+
*/
|
|
27
|
+
export const TA_UPLOAD_PART_BYTES = 4 * 1024 * 1024;
|
|
7
28
|
//# sourceMappingURL=workspace-protocol.js.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare const TaAccessServer: unique symbol;
|
|
2
|
+
export declare const TA_ACCESS_SERVICE = "TaAccessServer";
|
|
3
|
+
/**
|
|
4
|
+
* Where a browser signs in with an account: `GET` it for the ways this ta serve offers ({@link TaSignInWays}),
|
|
5
|
+
* `GET <path>/<provider>` to go to the provider, which comes back to `<path>/<provider>/callback`. These are
|
|
6
|
+
* pages the browser goes to, not calls: they need no token, and give one.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TA_SIGN_IN_PATH = "/sign-in";
|
|
9
|
+
/** What a sign-in that did not let the browser in says in the fragment of the page it comes back to. */
|
|
10
|
+
export type TaSignInOutcome = 'denied' | 'failed';
|
|
11
|
+
/** A way to sign in: `github`, `google`, `wechat`, `oidc` (a provider of the operator's). */
|
|
12
|
+
export interface TaSignInProvider {
|
|
13
|
+
id: string;
|
|
14
|
+
/** What the button says: GitHub, Google, WeChat, or the name of the operator's provider. */
|
|
15
|
+
name: string;
|
|
16
|
+
}
|
|
17
|
+
/** The answer of `GET` {@link TA_SIGN_IN_PATH}. */
|
|
18
|
+
export interface TaSignInWays {
|
|
19
|
+
providers: TaSignInProvider[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* An account let in: `github:<login>`, `google:<email>`, `wechat:<id>`, `oidc:<email>`; `google:*@<domain>`
|
|
23
|
+
* lets in every address of the domain. Those of `TA_ALLOWED_USERS` (`env`) are not removed here.
|
|
24
|
+
*/
|
|
25
|
+
export interface TaAccessAccount {
|
|
26
|
+
id: string;
|
|
27
|
+
name?: string;
|
|
28
|
+
avatar?: string;
|
|
29
|
+
source: 'env' | 'added';
|
|
30
|
+
addedAt?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Someone who signed in and is not let in yet: one tap lets them in. */
|
|
33
|
+
export interface TaAccessRequest {
|
|
34
|
+
id: string;
|
|
35
|
+
name?: string;
|
|
36
|
+
avatar?: string;
|
|
37
|
+
at: number;
|
|
38
|
+
}
|
|
39
|
+
/** A browser signed in with an account; it stays signed in until it is signed out or its account removed. */
|
|
40
|
+
export interface TaAccessSignIn {
|
|
41
|
+
id: string;
|
|
42
|
+
account: string;
|
|
43
|
+
name?: string;
|
|
44
|
+
createdAt: number;
|
|
45
|
+
lastUsedAt: number;
|
|
46
|
+
/** The user agent of the browser it signed in from. */
|
|
47
|
+
device?: string;
|
|
48
|
+
/** The connection that asks. */
|
|
49
|
+
current: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface TaAccessInfo {
|
|
52
|
+
providers: TaSignInProvider[];
|
|
53
|
+
/** May let accounts in and out: anyone in with ta serve, administrators behind a gateway. */
|
|
54
|
+
canManage?: boolean;
|
|
55
|
+
accounts: TaAccessAccount[];
|
|
56
|
+
requests: TaAccessRequest[];
|
|
57
|
+
signIns: TaAccessSignIn[];
|
|
58
|
+
}
|
|
59
|
+
/** Who may reach this ta serve with an account, for whoever is in (with the token, or an account let in). */
|
|
60
|
+
export interface TaAccessServer {
|
|
61
|
+
getAccess(): Promise<TaAccessInfo>;
|
|
62
|
+
/**
|
|
63
|
+
* Where the browser goes to sign in with `provider` and let that account in at once: the owner, in with
|
|
64
|
+
* the token, adds an account of their own. The link works once, for a few minutes.
|
|
65
|
+
*/
|
|
66
|
+
bindUrl(provider: string): Promise<string>;
|
|
67
|
+
/** Lets the account in (a request, or one typed); its request goes. */
|
|
68
|
+
allow(account: string, name?: string): Promise<void>;
|
|
69
|
+
dismiss(account: string): Promise<void>;
|
|
70
|
+
/** An account added here is no longer let in; its browsers are signed out at once. */
|
|
71
|
+
disallow(account: string): Promise<void>;
|
|
72
|
+
signOut(signInId: string): Promise<void>;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=access-protocol.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TA_SIGN_IN_PATH = exports.TA_ACCESS_SERVICE = exports.TaAccessServer = void 0;
|
|
4
|
+
exports.TaAccessServer = Symbol('TaAccessServer');
|
|
5
|
+
exports.TA_ACCESS_SERVICE = 'TaAccessServer';
|
|
6
|
+
/**
|
|
7
|
+
* Where a browser signs in with an account: `GET` it for the ways this ta serve offers ({@link TaSignInWays}),
|
|
8
|
+
* `GET <path>/<provider>` to go to the provider, which comes back to `<path>/<provider>/callback`. These are
|
|
9
|
+
* pages the browser goes to, not calls: they need no token, and give one.
|
|
10
|
+
*/
|
|
11
|
+
exports.TA_SIGN_IN_PATH = '/sign-in';
|
|
12
|
+
//# sourceMappingURL=access-protocol.js.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export declare const TaGatewayServer: unique symbol;
|
|
2
|
+
export declare const TA_GATEWAY_SERVICE = "TaGatewayServer";
|
|
3
|
+
/**
|
|
4
|
+
* Where the Ta of a tenant runs: a sandbox of the gateway's provider (a container, a machine), or a Ta service
|
|
5
|
+
* of the user's own. `starting` until it answers; `failed` with `error` when it did not start.
|
|
6
|
+
*/
|
|
7
|
+
export type TaEnvironmentStatus = 'starting' | 'running' | 'stopped' | 'failed';
|
|
8
|
+
/** A provider of sandboxes of the gateway that a user may run their Ta in (`sandboxes.json`). */
|
|
9
|
+
export interface TaEnvironmentOption {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
/** `docker`, `command`, `local`, or that of a module. */
|
|
13
|
+
type: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The environment a user picks: one of the gateway's providers, or a Ta service of their own, reached at
|
|
17
|
+
* `url` (http or https, as `ta serve` there serves) with its access token, as a model of one's own is an
|
|
18
|
+
* endpoint and a key in pi's models.json.
|
|
19
|
+
*/
|
|
20
|
+
export type TaEnvironmentChoice = {
|
|
21
|
+
provider: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'ta';
|
|
24
|
+
url: string;
|
|
25
|
+
token: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
};
|
|
28
|
+
export interface TaEnvironmentInfo {
|
|
29
|
+
/** The provider of the gateway, or `own` for a Ta service of the user's. */
|
|
30
|
+
provider: string;
|
|
31
|
+
name: string;
|
|
32
|
+
status: TaEnvironmentStatus;
|
|
33
|
+
error?: string;
|
|
34
|
+
/** That of a Ta service of the user's; never its token. */
|
|
35
|
+
url?: string;
|
|
36
|
+
}
|
|
37
|
+
/** A tenant, as an administrator sees it: one per account, its own sandbox. */
|
|
38
|
+
export interface TaGatewayTenant {
|
|
39
|
+
id: string;
|
|
40
|
+
account: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
environment: TaEnvironmentInfo;
|
|
43
|
+
/** Browsers connected now. */
|
|
44
|
+
connections: number;
|
|
45
|
+
createdAt: number;
|
|
46
|
+
lastActiveAt?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface TaGatewayInfo {
|
|
49
|
+
account: {
|
|
50
|
+
id: string;
|
|
51
|
+
name?: string;
|
|
52
|
+
avatar?: string;
|
|
53
|
+
};
|
|
54
|
+
tenant: string;
|
|
55
|
+
environment: TaEnvironmentInfo;
|
|
56
|
+
/** The providers of the gateway one may pick. */
|
|
57
|
+
options: TaEnvironmentOption[];
|
|
58
|
+
/** Whether a Ta service of one's own may be used (`ownEnvironments` of sandboxes.json). */
|
|
59
|
+
own: boolean;
|
|
60
|
+
/** May let accounts in (TA_GATEWAY_ADMINS) and see the tenants. */
|
|
61
|
+
admin: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* `ta gateway`: each account that signs in is a tenant with a Ta of its own, in a sandbox of its own, which
|
|
65
|
+
* the gateway starts on its first connection and to which it forwards the connection. This service is the
|
|
66
|
+
* gateway's own, on the same WebSocket: a Ta service without a gateway does not have it.
|
|
67
|
+
*/
|
|
68
|
+
export interface TaGatewayServer {
|
|
69
|
+
getGateway(): Promise<TaGatewayInfo>;
|
|
70
|
+
/**
|
|
71
|
+
* Runs the Ta of this tenant elsewhere from now on. Its sessions, model accounts and files are those of
|
|
72
|
+
* the environment: another starts without them. The connections of the tenant are closed, to connect again.
|
|
73
|
+
*/
|
|
74
|
+
setEnvironment(choice: TaEnvironmentChoice): Promise<TaGatewayInfo>;
|
|
75
|
+
/** Starts the environment again: stopped first when it runs. */
|
|
76
|
+
restartEnvironment(): Promise<TaGatewayInfo>;
|
|
77
|
+
/** For administrators. */
|
|
78
|
+
listTenants(): Promise<TaGatewayTenant[]>;
|
|
79
|
+
/** For administrators: stops the sandbox of a tenant, which starts again when it connects. */
|
|
80
|
+
stopTenant(tenantId: string): Promise<void>;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=gateway-protocol.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TA_GATEWAY_SERVICE = exports.TaGatewayServer = void 0;
|
|
4
|
+
exports.TaGatewayServer = Symbol('TaGatewayServer');
|
|
5
|
+
exports.TA_GATEWAY_SERVICE = 'TaGatewayServer';
|
|
6
|
+
//# sourceMappingURL=gateway-protocol.js.map
|
package/lib/common/index.d.ts
CHANGED
package/lib/common/index.js
CHANGED
|
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./access-protocol"), exports);
|
|
17
18
|
__exportStar(require("./auth-protocol"), exports);
|
|
19
|
+
__exportStar(require("./gateway-protocol"), exports);
|
|
18
20
|
__exportStar(require("./location"), exports);
|
|
19
21
|
__exportStar(require("./package-protocol"), exports);
|
|
20
22
|
__exportStar(require("./pi-types"), exports);
|
package/lib/common/location.d.ts
CHANGED
|
@@ -33,6 +33,11 @@ export declare namespace TaLocation {
|
|
|
33
33
|
function readHost(input: string): HostInput;
|
|
34
34
|
/** `ssh://<host><path>`; `path` absolute, or empty for the home directory. */
|
|
35
35
|
function ssh(host: string, path?: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* A host as a list shows it, short: the name of the machine, without the user, the port and the domain
|
|
38
|
+
* (`me@dev.example.com:2222` is `dev`); an address whole.
|
|
39
|
+
*/
|
|
40
|
+
function hostLabel(host: string): string;
|
|
36
41
|
/** The host of a remote location; undefined for this machine. */
|
|
37
42
|
function host(location: string): string | undefined;
|
|
38
43
|
/** The path inside its machine. */
|
package/lib/common/location.js
CHANGED
|
@@ -117,6 +117,18 @@ var TaLocation;
|
|
|
117
117
|
return `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
118
118
|
}
|
|
119
119
|
TaLocation.ssh = ssh;
|
|
120
|
+
/**
|
|
121
|
+
* A host as a list shows it, short: the name of the machine, without the user, the port and the domain
|
|
122
|
+
* (`me@dev.example.com:2222` is `dev`); an address whole.
|
|
123
|
+
*/
|
|
124
|
+
function hostLabel(host) {
|
|
125
|
+
const name = host
|
|
126
|
+
.replace(/^[^@]*@/, '')
|
|
127
|
+
.replace(/^\[(.*)\](?::\d+)?$/, '$1')
|
|
128
|
+
.replace(/^([^:]*):\d+$/, '$1');
|
|
129
|
+
return /^[\d.]+$/.test(name) || name.includes(':') ? name : name.split('.')[0] || name;
|
|
130
|
+
}
|
|
131
|
+
TaLocation.hostLabel = hostLabel;
|
|
120
132
|
/** The host of a remote location; undefined for this machine. */
|
|
121
133
|
function host(location) {
|
|
122
134
|
var _a;
|
|
@@ -17,8 +17,10 @@ export interface TaWebExtensionInfo {
|
|
|
17
17
|
/**
|
|
18
18
|
* `package`: a package of pi's `packages` setting (`ta install`). `directory`: a directory in `extensions/`.
|
|
19
19
|
* `builtin`: a package that comes with ta; it can be turned off (setPackageEnabled), not removed.
|
|
20
|
+
* `temporary`: opened without installing (openTemporaryPackage): only its web extension runs, started when
|
|
21
|
+
* one of its pages opens, and it goes after a while unused unless kept (TaTemporaryInfo).
|
|
20
22
|
*/
|
|
21
|
-
origin: 'package' | 'directory' | 'builtin';
|
|
23
|
+
origin: 'package' | 'directory' | 'builtin' | 'temporary';
|
|
22
24
|
/** False for a built-in package that is turned off; the others are always on. */
|
|
23
25
|
enabled: boolean;
|
|
24
26
|
/** The source in the `packages` setting, or the directory. */
|
|
@@ -27,15 +29,51 @@ export interface TaWebExtensionInfo {
|
|
|
27
29
|
entry: string;
|
|
28
30
|
/** Changes when the file changes. */
|
|
29
31
|
hash: string;
|
|
32
|
+
/** What the user calls its package, `pi.title` of its package.json. */
|
|
33
|
+
title?: TaPackageText;
|
|
34
|
+
/** The name of an icon of the web client's `pi.ui.icons`, `pi.icon` of its package.json. */
|
|
35
|
+
icon?: string;
|
|
36
|
+
/**
|
|
37
|
+
* When the web client runs it: `startup` (default) as the page loads; `open` once one of its pages
|
|
38
|
+
* opens, `pi.webActivation` of its package.json. A temporary one always on `open`.
|
|
39
|
+
*/
|
|
40
|
+
activation: 'startup' | 'open';
|
|
41
|
+
/** For a temporary package. */
|
|
42
|
+
temporary?: TaTemporaryInfo;
|
|
43
|
+
}
|
|
44
|
+
/** Where a temporary package came from: the market, a link someone shared, or an agent that made it for the user. */
|
|
45
|
+
export type TaTemporaryFrom = 'market' | 'link' | 'agent';
|
|
46
|
+
/** A package opened without installing (TaWebExtensionInfo.origin `temporary`). */
|
|
47
|
+
export interface TaTemporaryInfo {
|
|
48
|
+
/** What it was opened from: `npm:<name>`, `git:<repository>`, a URL of a repository, a path. */
|
|
49
|
+
source: string;
|
|
50
|
+
from: TaTemporaryFrom;
|
|
51
|
+
/** Milliseconds since the epoch. */
|
|
52
|
+
openedAt: number;
|
|
53
|
+
usedAt: number;
|
|
54
|
+
/** In the user's own (the launcher's `Mine`): never cleared for want of use. */
|
|
55
|
+
kept: boolean;
|
|
30
56
|
}
|
|
31
57
|
/** What a package holds: pi extensions, web extensions, skills, prompt templates, themes. */
|
|
32
58
|
export type TaPackageResource = 'extensions' | 'web' | 'skills' | 'prompts' | 'themes';
|
|
59
|
+
/** Text of a package for people, as `pi.title` and `pi.summary` of its package.json give it: one string, or one per language (`en`, `zh-CN`). */
|
|
60
|
+
export type TaPackageText = string | Readonly<Record<string, string>>;
|
|
61
|
+
export declare namespace TaPackageTextUtil {
|
|
62
|
+
/** The text in a language such as `zh-CN`: that language, else its first part (`zh`), else English, else the first there is. */
|
|
63
|
+
function pick(text: TaPackageText | undefined, language: string): string | undefined;
|
|
64
|
+
}
|
|
33
65
|
/** A pi package that Ta loads, whether it has a web extension or not. */
|
|
34
66
|
export interface TaPackageInfo {
|
|
35
67
|
/** Stable while the package stays where it is. */
|
|
36
68
|
id: string;
|
|
37
69
|
/** The `name` of its package.json, or the name of its directory. */
|
|
38
70
|
name: string;
|
|
71
|
+
/** What the user calls it, `pi.title` of its package.json; lists show {@link name} without it. */
|
|
72
|
+
title?: TaPackageText;
|
|
73
|
+
/** What it does and where it shows, in a sentence for the user, `pi.summary` of its package.json. */
|
|
74
|
+
summary?: TaPackageText;
|
|
75
|
+
/** The name of an icon of the web client's `pi.ui.icons`, `pi.icon` of its package.json. */
|
|
76
|
+
icon?: string;
|
|
39
77
|
description?: string;
|
|
40
78
|
version?: string;
|
|
41
79
|
scope: 'user' | 'project';
|
|
@@ -47,6 +85,8 @@ export interface TaPackageInfo {
|
|
|
47
85
|
source: string;
|
|
48
86
|
/** Its directory, on the machine of the server. */
|
|
49
87
|
root: string;
|
|
88
|
+
/** For a temporary package. */
|
|
89
|
+
temporary?: TaTemporaryInfo;
|
|
50
90
|
/** What it holds, by its package.json or, without `pi` there, by the directories pi looks in. */
|
|
51
91
|
resources: TaPackageResource[];
|
|
52
92
|
}
|
|
@@ -89,5 +129,24 @@ export interface TaPackageServer {
|
|
|
89
129
|
*/
|
|
90
130
|
getExtensionData(name: string, key: string, cwd?: string): Promise<unknown>;
|
|
91
131
|
setExtensionData(name: string, key: string, value: unknown, cwd?: string): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Opens a package without installing it, as a mini program is: fetched as `installPackage` does (a path is
|
|
134
|
+
* only noted), not added to pi's `packages` setting, so that only its web extension runs. Its web
|
|
135
|
+
* extensions, those of a package already installed or open from that source too.
|
|
136
|
+
*/
|
|
137
|
+
openTemporaryPackage(source: string, from: TaTemporaryFrom): Promise<TaWebExtensionInfo[]>;
|
|
138
|
+
/** A temporary package (by its id of listPackages or of one of its web extensions) was used now, or kept or not. */
|
|
139
|
+
updateTemporaryPackage(id: string, change: {
|
|
140
|
+
used?: boolean;
|
|
141
|
+
kept?: boolean;
|
|
142
|
+
}): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Installs a temporary package for the user: its source added to pi's `packages` setting, or, made by an
|
|
145
|
+
* agent, its directory moved to `extensions/`. Sessions pick it up on reload.
|
|
146
|
+
*/
|
|
147
|
+
installTemporaryPackage(id: string): Promise<void>;
|
|
148
|
+
/** After how many days unused a temporary package not kept goes; 0: never. */
|
|
149
|
+
getTemporaryRetention(): Promise<number>;
|
|
150
|
+
setTemporaryRetention(days: number): Promise<void>;
|
|
92
151
|
}
|
|
93
152
|
//# sourceMappingURL=package-protocol.d.ts.map
|