@celljs/ta-protocol 4.5.1 → 4.6.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.md +6 -5
- package/esm/common/auth-protocol.d.ts +89 -0
- package/esm/common/auth-protocol.js +3 -0
- package/esm/common/auth-protocol.js.map +1 -0
- package/esm/common/index.d.ts +6 -0
- package/esm/common/index.js +6 -0
- package/esm/common/index.js.map +1 -1
- package/esm/common/package-protocol.d.ts +92 -0
- package/esm/common/package-protocol.js +3 -0
- package/esm/common/package-protocol.js.map +1 -0
- package/esm/common/pi-types.d.ts +1 -0
- package/esm/common/relay-protocol.d.ts +28 -0
- package/esm/common/relay-protocol.js +3 -0
- package/esm/common/relay-protocol.js.map +1 -0
- package/esm/common/settings-protocol.d.ts +42 -0
- package/esm/common/settings-protocol.js +22 -0
- package/esm/common/settings-protocol.js.map +1 -0
- package/esm/common/ta-extension-host.d.ts +44 -0
- package/esm/common/ta-extension-host.js +8 -0
- package/esm/common/ta-extension-host.js.map +1 -0
- package/esm/common/ta-protocol.d.ts +110 -8
- package/esm/common/ta-protocol.js +21 -0
- package/esm/common/ta-protocol.js.map +1 -1
- package/esm/common/workspace-protocol.d.ts +91 -0
- package/esm/common/workspace-protocol.js +7 -0
- package/esm/common/workspace-protocol.js.map +1 -0
- package/lib/common/auth-protocol.d.ts +90 -0
- package/lib/common/auth-protocol.d.ts.map +1 -0
- package/lib/common/auth-protocol.js +6 -0
- package/lib/common/auth-protocol.js.map +1 -0
- package/lib/common/index.d.ts +6 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +6 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/package-protocol.d.ts +93 -0
- package/lib/common/package-protocol.d.ts.map +1 -0
- package/lib/common/package-protocol.js +6 -0
- package/lib/common/package-protocol.js.map +1 -0
- package/lib/common/pi-types.d.ts +1 -0
- package/lib/common/pi-types.d.ts.map +1 -1
- package/lib/common/relay-protocol.d.ts +29 -0
- package/lib/common/relay-protocol.d.ts.map +1 -0
- package/lib/common/relay-protocol.js +6 -0
- package/lib/common/relay-protocol.js.map +1 -0
- package/lib/common/settings-protocol.d.ts +43 -0
- package/lib/common/settings-protocol.d.ts.map +1 -0
- package/lib/common/settings-protocol.js +25 -0
- package/lib/common/settings-protocol.js.map +1 -0
- package/lib/common/ta-extension-host.d.ts +45 -0
- package/lib/common/ta-extension-host.d.ts.map +1 -0
- package/lib/common/ta-extension-host.js +11 -0
- package/lib/common/ta-extension-host.js.map +1 -0
- package/lib/common/ta-protocol.d.ts +110 -8
- package/lib/common/ta-protocol.d.ts.map +1 -1
- package/lib/common/ta-protocol.js +22 -1
- package/lib/common/ta-protocol.js.map +1 -1
- package/lib/common/ta-protocol.spec.js +21 -0
- package/lib/common/ta-protocol.spec.js.map +1 -1
- package/lib/common/workspace-protocol.d.ts +92 -0
- package/lib/common/workspace-protocol.d.ts.map +1 -0
- package/lib/common/workspace-protocol.js +10 -0
- package/lib/common/workspace-protocol.js.map +1 -0
- package/package.json +1 -1
- package/src/common/auth-protocol.ts +56 -0
- package/src/common/index.ts +6 -0
- package/src/common/package-protocol.ts +99 -0
- package/src/common/pi-types.ts +1 -0
- package/src/common/relay-protocol.ts +28 -0
- package/src/common/settings-protocol.ts +66 -0
- package/src/common/ta-extension-host.ts +52 -0
- package/src/common/ta-protocol.spec.ts +30 -1
- package/src/common/ta-protocol.ts +123 -7
- package/src/common/workspace-protocol.ts +102 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TaAuthEvent } from './auth-protocol.js';
|
|
2
|
+
import type { ImageContent, JsonAgentSessionEvent, RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResponse, ThinkingLevel } from './pi-types.js';
|
|
2
3
|
export declare const TaServer: unique symbol;
|
|
3
4
|
export declare const TaClient: unique symbol;
|
|
4
5
|
/** Path of the WebSocket endpoint of `ta serve`, and the JSON-RPC method prefixes of both sides. */
|
|
@@ -13,6 +14,16 @@ export interface TaServeInfo {
|
|
|
13
14
|
token: string;
|
|
14
15
|
pid: number;
|
|
15
16
|
}
|
|
17
|
+
/** What a client needs to know of the server before it opens a session. */
|
|
18
|
+
export interface TaServerInfo {
|
|
19
|
+
/** The version of ta. */
|
|
20
|
+
version: string;
|
|
21
|
+
/**
|
|
22
|
+
* Where a client opens a session when the user names no directory: the one set with
|
|
23
|
+
* `setWorkingDirectory`, else the working directory of `ta serve`, or of its execution environment.
|
|
24
|
+
*/
|
|
25
|
+
cwd: string;
|
|
26
|
+
}
|
|
16
27
|
/** The stable `code` of each failure of a {@link TaServer} call. */
|
|
17
28
|
export declare const TaErrorCode: {
|
|
18
29
|
readonly SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND';
|
|
@@ -22,6 +33,10 @@ export declare const TaErrorCode: {
|
|
|
22
33
|
readonly MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND';
|
|
23
34
|
readonly INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT';
|
|
24
35
|
readonly COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED';
|
|
36
|
+
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
37
|
+
readonly NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN';
|
|
38
|
+
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
39
|
+
readonly CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST';
|
|
25
40
|
};
|
|
26
41
|
export type TaErrorCode = (typeof TaErrorCode)[keyof typeof TaErrorCode];
|
|
27
42
|
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
@@ -35,6 +50,22 @@ export interface TaErrorData {
|
|
|
35
50
|
export type TaCommand = Extract<RpcResponse, {
|
|
36
51
|
success: true;
|
|
37
52
|
}>['command'];
|
|
53
|
+
/** The answer to `forkToFile`. */
|
|
54
|
+
export interface TaForkFileResult {
|
|
55
|
+
/** The new conversation; none when nothing comes before the message: then a new conversation starts. */
|
|
56
|
+
sessionFile?: string;
|
|
57
|
+
/** The message of the user left out (`before`), for the box of the new conversation. */
|
|
58
|
+
text?: string;
|
|
59
|
+
}
|
|
60
|
+
/** The answer to `navigateTree`, which pi's RPC mode does not have. */
|
|
61
|
+
export interface TaNavigateResult {
|
|
62
|
+
cancelled: boolean;
|
|
63
|
+
editorText?: string;
|
|
64
|
+
}
|
|
65
|
+
/** `get_state` → `getState`. */
|
|
66
|
+
type CamelCase<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : S;
|
|
67
|
+
/** The method of TaServer for each command of pi's RPC mode: TaServer has one for each (see its spec). */
|
|
68
|
+
export type PiCommandMethod = CamelCase<RpcCommand['type']>;
|
|
38
69
|
/** What pi's RPC mode answers to a command. */
|
|
39
70
|
export type TaCommandResult<C extends TaCommand> = Extract<RpcResponse, {
|
|
40
71
|
command: C;
|
|
@@ -42,10 +73,12 @@ export type TaCommandResult<C extends TaCommand> = Extract<RpcResponse, {
|
|
|
42
73
|
}> extends {
|
|
43
74
|
data: infer D;
|
|
44
75
|
} ? D : undefined;
|
|
76
|
+
/** A tool the client runs: the model calls it like any other tool, the server asks the client for the result. */
|
|
45
77
|
export interface TaClientToolDefinition {
|
|
78
|
+
/** Letters, digits, `_` and `-`, starting with a letter; best not the name of another tool of the session. */
|
|
46
79
|
name: string;
|
|
47
80
|
description: string;
|
|
48
|
-
/** JSON schema of the arguments. */
|
|
81
|
+
/** JSON schema of the arguments, an object schema. */
|
|
49
82
|
parameters: Record<string, unknown>;
|
|
50
83
|
}
|
|
51
84
|
export interface TaOpenSessionOptions {
|
|
@@ -58,6 +91,10 @@ export interface TaOpenSessionOptions {
|
|
|
58
91
|
thinkingLevel?: ThinkingLevel;
|
|
59
92
|
/** Tools the client runs; fixed when the session opens, so the tool list stays stable for prompt caching. */
|
|
60
93
|
clientTools?: TaClientToolDefinition[];
|
|
94
|
+
/** Added to the system prompt, as pi's `--append-system-prompt`: a role the client gives the agent. */
|
|
95
|
+
appendSystemPrompt?: string;
|
|
96
|
+
/** Sessions a package opens for its own work (the name of the package): clients list them apart, folded. */
|
|
97
|
+
group?: string;
|
|
61
98
|
}
|
|
62
99
|
export interface TaSessionInfo {
|
|
63
100
|
/** The id of this open session; stays the same through `newSession`, `switchSession` and `fork`. */
|
|
@@ -67,6 +104,8 @@ export interface TaSessionInfo {
|
|
|
67
104
|
cwd: string;
|
|
68
105
|
sessionFile?: string;
|
|
69
106
|
sessionName?: string;
|
|
107
|
+
/** The first line of the first message of the user, which a list shows when the session has no name. */
|
|
108
|
+
firstMessage?: string;
|
|
70
109
|
/** `<provider>/<model id>`. */
|
|
71
110
|
model?: string;
|
|
72
111
|
isStreaming: boolean;
|
|
@@ -74,8 +113,13 @@ export interface TaSessionInfo {
|
|
|
74
113
|
/** Number of clients attached. */
|
|
75
114
|
attached: number;
|
|
76
115
|
createdAt: number;
|
|
116
|
+
/** When the last message came; `createdAt` before the first. */
|
|
117
|
+
updatedAt: number;
|
|
118
|
+
/** TaOpenSessionOptions.group. */
|
|
119
|
+
group?: string;
|
|
77
120
|
}
|
|
78
121
|
export interface TaPromptInput {
|
|
122
|
+
/** May start with a block of context for the model, which clients do not show: see {@link TaMessageContext}. */
|
|
79
123
|
message: string;
|
|
80
124
|
images?: ImageContent[];
|
|
81
125
|
/** Chosen by the client, unique per message: sending the same one again does not run it again. */
|
|
@@ -83,6 +127,15 @@ export interface TaPromptInput {
|
|
|
83
127
|
/** What to do when the agent is running; only for `prompt`. Default: `followUp`. */
|
|
84
128
|
streamingBehavior?: 'steer' | 'followUp';
|
|
85
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* A message of the user may start with a `<context>` block: what the model reads besides the message
|
|
132
|
+
* (where it is said, who is there, what was said before), which a client leaves out when it shows it.
|
|
133
|
+
*/
|
|
134
|
+
export declare namespace TaMessageContext {
|
|
135
|
+
function wrap(context: string, message: string): string;
|
|
136
|
+
/** The message without its context: what the user sees of it. */
|
|
137
|
+
function strip(message: string): string;
|
|
138
|
+
}
|
|
86
139
|
/**
|
|
87
140
|
* The server has taken the message; it says nothing about the run. A run is finished at the
|
|
88
141
|
* `agent_settled` event, when its history is on disk.
|
|
@@ -104,7 +157,7 @@ export interface TaExtensionError {
|
|
|
104
157
|
event: string;
|
|
105
158
|
error: string;
|
|
106
159
|
}
|
|
107
|
-
/** The open session now shows another conversation (`newSession`, `switchSession`, `fork`, `clone`): read it again. */
|
|
160
|
+
/** The open session now shows another conversation (`newSession`, `switchSession`, `fork`, `clone`, `navigateTree`): read it again. */
|
|
108
161
|
export interface TaSessionReplaced {
|
|
109
162
|
type: 'session_replaced';
|
|
110
163
|
info: TaSessionInfo;
|
|
@@ -113,14 +166,23 @@ export interface TaSessionReplaced {
|
|
|
113
166
|
export interface TaSessionClosed {
|
|
114
167
|
type: 'session_closed';
|
|
115
168
|
}
|
|
116
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* The model called a tool of `clientTools`: a client that runs it answers with `respondClientTool`.
|
|
171
|
+
* It goes to every attached client; the first answer counts, and `client_tool_resolved` tells the others.
|
|
172
|
+
*/
|
|
117
173
|
export interface TaClientToolRequest {
|
|
118
174
|
type: 'client_tool_request';
|
|
175
|
+
/** The id of the tool call. */
|
|
119
176
|
id: string;
|
|
120
177
|
toolName: string;
|
|
121
178
|
input: unknown;
|
|
122
179
|
}
|
|
123
|
-
|
|
180
|
+
/** A call of a client tool was answered, or ended because the run was aborted or the session closed. */
|
|
181
|
+
export interface TaClientToolResolved {
|
|
182
|
+
type: 'client_tool_resolved';
|
|
183
|
+
id: string;
|
|
184
|
+
}
|
|
185
|
+
export type TaEvent = JsonAgentSessionEvent | RpcExtensionUIRequest | TaUiRequestResolved | TaExtensionError | TaClientToolRequest | TaClientToolResolved | TaSessionReplaced | TaSessionClosed;
|
|
124
186
|
export interface TaEventEnvelope {
|
|
125
187
|
sessionId: string;
|
|
126
188
|
/** Increases by one per event of the session. */
|
|
@@ -133,21 +195,34 @@ export interface TaAttachResult {
|
|
|
133
195
|
events: TaEventEnvelope[];
|
|
134
196
|
/** The dialogs still waiting for an answer. */
|
|
135
197
|
pendingUi: RpcExtensionUIRequest[];
|
|
198
|
+
/** The calls of client tools still waiting for a result. */
|
|
199
|
+
pendingClientTools: TaClientToolRequest[];
|
|
136
200
|
/** Seq of the last event of the session. */
|
|
137
201
|
lastSeq: number;
|
|
138
202
|
/** Some events after `afterSeq` are gone: read the conversation again with `getMessages`. */
|
|
139
203
|
gap: boolean;
|
|
140
204
|
}
|
|
141
205
|
export interface TaClientToolResult {
|
|
206
|
+
/** The `id` of the request. */
|
|
142
207
|
id: string;
|
|
208
|
+
/** What the model reads. */
|
|
143
209
|
output: string;
|
|
210
|
+
/** The tool failed: `output` says why. */
|
|
144
211
|
isError?: boolean;
|
|
145
212
|
}
|
|
146
213
|
/**
|
|
147
|
-
* `ta serve`, over JSON-RPC 2.0 on a WebSocket. Besides opening, attaching and answering,
|
|
148
|
-
* is the command of pi's RPC mode with the same name in camelCase, on the open session
|
|
214
|
+
* The sessions of `ta serve`, over JSON-RPC 2.0 on a WebSocket. Besides opening, attaching and answering,
|
|
215
|
+
* each method is the command of pi's RPC mode with the same name in camelCase, on the open session
|
|
216
|
+
* `sessionId` (see PiCommandMethod). The same WebSocket carries the other services of ta serve, each
|
|
217
|
+
* under its own name: TaWorkspaceServer, TaTerminalServer, TaSettingsServer and TaPackageServer.
|
|
149
218
|
*/
|
|
150
219
|
export interface TaServer {
|
|
220
|
+
getServerInfo(): Promise<TaServerInfo>;
|
|
221
|
+
/**
|
|
222
|
+
* Makes `cwd` the working directory of the server (TaServerInfo.cwd), for every client, and across
|
|
223
|
+
* restarts: where conversations open when the user names no directory. Sessions already open stay where they are.
|
|
224
|
+
*/
|
|
225
|
+
setWorkingDirectory(cwd: string): Promise<TaServerInfo>;
|
|
151
226
|
openSession(options: TaOpenSessionOptions): Promise<TaSessionInfo>;
|
|
152
227
|
closeSession(sessionId: string): Promise<void>;
|
|
153
228
|
listSessions(): Promise<TaSessionInfo[]>;
|
|
@@ -182,17 +257,44 @@ export interface TaServer {
|
|
|
182
257
|
getSessionStats(sessionId: string): Promise<TaCommandResult<'get_session_stats'>>;
|
|
183
258
|
exportHtml(sessionId: string, outputPath?: string): Promise<TaCommandResult<'export_html'>>;
|
|
184
259
|
switchSession(sessionId: string, sessionPath: string): Promise<TaCommandResult<'switch_session'>>;
|
|
185
|
-
|
|
260
|
+
/**
|
|
261
|
+
* A new conversation from an entry, as pi's `/fork`: `before` (the default) a message of the user, which
|
|
262
|
+
* it leaves out and gives back as `text`; `at` any entry, which it keeps.
|
|
263
|
+
*/
|
|
264
|
+
fork(sessionId: string, entryId: string, position?: 'before' | 'at'): Promise<TaCommandResult<'fork'>>;
|
|
265
|
+
/**
|
|
266
|
+
* The new conversation of `fork` in a file of its own, with pi's `createBranchedSession`; the session
|
|
267
|
+
* stays where it is. Open the file with `openSession` to go on with it.
|
|
268
|
+
*/
|
|
269
|
+
forkToFile(sessionId: string, entryId: string, position?: 'before' | 'at'): Promise<TaForkFileResult>;
|
|
186
270
|
clone(sessionId: string): Promise<TaCommandResult<'clone'>>;
|
|
187
271
|
getForkMessages(sessionId: string): Promise<TaCommandResult<'get_fork_messages'>>;
|
|
188
272
|
getEntries(sessionId: string, since?: string): Promise<TaCommandResult<'get_entries'>>;
|
|
189
273
|
getTree(sessionId: string): Promise<TaCommandResult<'get_tree'>>;
|
|
274
|
+
/**
|
|
275
|
+
* Goes to an entry in the same conversation, as pi's `/tree`: the branch left stays in the tree. To a
|
|
276
|
+
* message of the user, it goes to what came before and gives the message back as `editorText`.
|
|
277
|
+
*/
|
|
278
|
+
navigateTree(sessionId: string, targetId: string): Promise<TaNavigateResult>;
|
|
190
279
|
getLastAssistantText(sessionId: string): Promise<TaCommandResult<'get_last_assistant_text'>>;
|
|
191
280
|
setSessionName(sessionId: string, name: string): Promise<void>;
|
|
192
281
|
getMessages(sessionId: string): Promise<TaCommandResult<'get_messages'>>;
|
|
193
282
|
getCommands(sessionId: string): Promise<TaCommandResult<'get_commands'>>;
|
|
283
|
+
/** Loads extensions, skills, prompts and themes again, as pi's `/reload` does. */
|
|
284
|
+
reload(sessionId: string): Promise<void>;
|
|
194
285
|
}
|
|
195
286
|
/** What a client implements. Events come in batches: one message per frame, however fast the model streams. */
|
|
196
287
|
export interface TaClient {
|
|
197
288
|
onEvents(events: TaEventEnvelope[]): Promise<void>;
|
|
289
|
+
/** Output of a terminal of this connection; with `exitCode`, the terminal has ended. */
|
|
290
|
+
onTerminalData(terminalId: string, data: string, exitCode?: number): Promise<void>;
|
|
291
|
+
/**
|
|
292
|
+
* Keys of the data of a package (setExtensionData) that changed, by this client or another, or by the
|
|
293
|
+
* package on the server; with `cwd`, keys of that directory. It comes for the data this connection
|
|
294
|
+
* read, at most every few hundred milliseconds, with the keys of that time together.
|
|
295
|
+
*/
|
|
296
|
+
onExtensionData(name: string, keys: string[], cwd?: string): Promise<void>;
|
|
297
|
+
/** What happens during a sign-in this connection started (TaAuthServer.login). */
|
|
298
|
+
onAuthEvent(loginId: string, event: TaAuthEvent): Promise<void>;
|
|
198
299
|
}
|
|
300
|
+
export {};
|
|
@@ -15,7 +15,28 @@ export const TaErrorCode = {
|
|
|
15
15
|
MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND',
|
|
16
16
|
INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT',
|
|
17
17
|
COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
|
|
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
|
+
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
21
|
+
CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
|
|
18
22
|
};
|
|
19
23
|
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
20
24
|
export const TA_RPC_ERROR_CODE = -32050;
|
|
25
|
+
/**
|
|
26
|
+
* A message of the user may start with a `<context>` block: what the model reads besides the message
|
|
27
|
+
* (where it is said, who is there, what was said before), which a client leaves out when it shows it.
|
|
28
|
+
*/
|
|
29
|
+
export var TaMessageContext;
|
|
30
|
+
(function (TaMessageContext) {
|
|
31
|
+
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
32
|
+
function wrap(context, message) {
|
|
33
|
+
return `<context>\n${context}\n</context>\n${message}`;
|
|
34
|
+
}
|
|
35
|
+
TaMessageContext.wrap = wrap;
|
|
36
|
+
/** The message without its context: what the user sees of it. */
|
|
37
|
+
function strip(message) {
|
|
38
|
+
return message.replace(BLOCK, '');
|
|
39
|
+
}
|
|
40
|
+
TaMessageContext.strip = strip;
|
|
41
|
+
})(TaMessageContext || (TaMessageContext = {}));
|
|
21
42
|
//# sourceMappingURL=ta-protocol.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ta-protocol.js","sourceRoot":"","sources":["../../src/common/ta-protocol.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ta-protocol.js","sourceRoot":"","sources":["../../src/common/ta-protocol.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAE3C,oGAAoG;AACpG,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAC3C,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAC5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAE5C,oFAAoF;AACpF,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAoB1C,oEAAoE;AACpE,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,iBAAiB,EAAE,2BAA2B;IAC9C,cAAc,EAAE,wBAAwB;IACxC,iBAAiB,EAAE,2BAA2B;IAC9C,gBAAgB,EAAE,0BAA0B;IAC5C,eAAe,EAAE,yBAAyB;IAC1C,gBAAgB,EAAE,0BAA0B;IAC5C,cAAc,EAAE,wBAAwB;IACxC,4GAA4G;IAC5G,aAAa,EAAE,uBAAuB;IACtC,2HAA2H;IAC3H,eAAe,EAAE,yBAAyB;CACpC,CAAC;AAGX,yGAAyG;AACzG,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAK,CAAC;AA4FxC;;;GAGG;AACH,MAAM,KAAW,gBAAgB,CAWhC;AAXD,WAAiB,gBAAgB;IAC7B,MAAM,KAAK,GAAG,wCAAwC,CAAC;IAEvD,SAAgB,IAAI,CAAC,OAAe,EAAE,OAAe;QACjD,OAAO,cAAc,OAAO,iBAAiB,OAAO,EAAE,CAAC;IAC3D,CAAC;IAFe,iBAAA,IAAI,OAEnB,CAAA;IAED,iEAAiE;IACjE,SAAgB,KAAK,CAAC,OAAe;QACjC,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACtC,CAAC;IAFe,iBAAA,KAAK,QAEpB,CAAA;AACL,CAAC,EAXgB,gBAAgB,KAAhB,gBAAgB,QAWhC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** Where the page loads the bytes of workspace files from: see {@link TaWorkspaceServer.fileUrl}. */
|
|
2
|
+
export declare const TA_FILES_PATH = "/api/files";
|
|
3
|
+
export declare const TaWorkspaceServer: unique symbol;
|
|
4
|
+
export declare const TA_WORKSPACE_SERVICE = "TaWorkspaceServer";
|
|
5
|
+
export declare const TaTerminalServer: unique symbol;
|
|
6
|
+
export declare const TA_TERMINAL_SERVICE = "TaTerminalServer";
|
|
7
|
+
/** An entry of a directory of the workspace. */
|
|
8
|
+
export interface TaDirEntry {
|
|
9
|
+
name: string;
|
|
10
|
+
/** Relative to the directory the call names as `cwd`, with `/`. */
|
|
11
|
+
path: string;
|
|
12
|
+
kind: 'file' | 'directory';
|
|
13
|
+
size?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface TaFileContent {
|
|
16
|
+
path: string;
|
|
17
|
+
size: number;
|
|
18
|
+
/** Not text: `text` is left out. */
|
|
19
|
+
binary: boolean;
|
|
20
|
+
/** Larger than the limit (1 MB): `text` holds the start. */
|
|
21
|
+
truncated: boolean;
|
|
22
|
+
text?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface TaRunCommandOptions {
|
|
25
|
+
/** Default: the server's directory. */
|
|
26
|
+
cwd?: string;
|
|
27
|
+
/** Written to the standard input, which is then closed. */
|
|
28
|
+
input?: string;
|
|
29
|
+
/** Default 30 s, at most 120 s; the process is killed then. */
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
/** Of each of stdout and stderr; default 1 MB, at most 8 MB. */
|
|
32
|
+
maxBytes?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface TaCommandOutput {
|
|
35
|
+
stdout: string;
|
|
36
|
+
stderr: string;
|
|
37
|
+
/** null when it was killed (`timedOut`) or ended by a signal. */
|
|
38
|
+
exitCode: number | null;
|
|
39
|
+
/** An output was longer than `maxBytes`: it holds the start. */
|
|
40
|
+
truncated: boolean;
|
|
41
|
+
timedOut: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The files of a directory of the machine of `ta serve` and programs run there, on the same WebSocket as
|
|
45
|
+
* {@link TaServer}. Paths are relative to `cwd` (default: the server's directory) and may not leave it;
|
|
46
|
+
* the work runs in the execution environment of `cwd`, as the tools of a session do.
|
|
47
|
+
*/
|
|
48
|
+
export interface TaWorkspaceServer {
|
|
49
|
+
/** Directories first, then by name; `.git` is left out. */
|
|
50
|
+
listDirectory(path: string, cwd?: string): Promise<TaDirEntry[]>;
|
|
51
|
+
readFile(path: string, cwd?: string): Promise<TaFileContent>;
|
|
52
|
+
/** Writes the text of a file; its directory must be there. */
|
|
53
|
+
writeFile(path: string, text: string, cwd?: string): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* A URL of this server, under {@link TA_FILES_PATH}, that answers the bytes of a file of `cwd`, for
|
|
56
|
+
* what the page shows as it is: an image, a video, a page with what it loads next to it. The URL needs
|
|
57
|
+
* no token, so that a page loads the files beside it with relative URLs; each `cwd` has its own
|
|
58
|
+
* secret part. Pages are answered sandboxed: they run in an origin of their own, not the server's.
|
|
59
|
+
*/
|
|
60
|
+
fileUrl(path: string, cwd?: string): Promise<string>;
|
|
61
|
+
/** Paths of files whose name matches `query` loosely, best first; ignored files are left out. */
|
|
62
|
+
findFiles(query: string, cwd?: string, limit?: number): Promise<string[]>;
|
|
63
|
+
/**
|
|
64
|
+
* Runs a program with its arguments, without a shell, in the execution environment of `cwd`, and
|
|
65
|
+
* answers its output once it ends: what packages build on (git, rg) instead of a method each.
|
|
66
|
+
*/
|
|
67
|
+
runCommand(command: string, args: string[], options?: TaRunCommandOptions): Promise<TaCommandOutput>;
|
|
68
|
+
}
|
|
69
|
+
export interface TaTerminalInfo {
|
|
70
|
+
terminalId: string;
|
|
71
|
+
cwd: string;
|
|
72
|
+
shell: string;
|
|
73
|
+
/** False: plain pipes (no `script` on the server, or Windows): full-screen programs do not draw right. */
|
|
74
|
+
pty: boolean;
|
|
75
|
+
}
|
|
76
|
+
export interface TaOpenTerminalOptions {
|
|
77
|
+
/** Default: the server's directory. */
|
|
78
|
+
cwd?: string;
|
|
79
|
+
cols: number;
|
|
80
|
+
rows: number;
|
|
81
|
+
}
|
|
82
|
+
/** The shells of a connection, on the same WebSocket as {@link TaServer}. */
|
|
83
|
+
export interface TaTerminalServer {
|
|
84
|
+
/** A shell of this connection; its output comes by TaClient.onTerminalData. It closes 30 s after the connection drops. */
|
|
85
|
+
openTerminal(options: TaOpenTerminalOptions): Promise<TaTerminalInfo>;
|
|
86
|
+
writeTerminal(terminalId: string, data: string): Promise<void>;
|
|
87
|
+
resizeTerminal(terminalId: string, cols: number, rows: number): Promise<void>;
|
|
88
|
+
closeTerminal(terminalId: string): Promise<void>;
|
|
89
|
+
/** The terminals of this connection that are still open. */
|
|
90
|
+
listTerminals(): Promise<TaTerminalInfo[]>;
|
|
91
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Where the page loads the bytes of workspace files from: see {@link TaWorkspaceServer.fileUrl}. */
|
|
2
|
+
export const TA_FILES_PATH = '/api/files';
|
|
3
|
+
export const TaWorkspaceServer = Symbol('TaWorkspaceServer');
|
|
4
|
+
export const TA_WORKSPACE_SERVICE = 'TaWorkspaceServer';
|
|
5
|
+
export const TaTerminalServer = Symbol('TaTerminalServer');
|
|
6
|
+
export const TA_TERMINAL_SERVICE = 'TaTerminalServer';
|
|
7
|
+
//# sourceMappingURL=workspace-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-protocol.js","sourceRoot":"","sources":["../../src/common/workspace-protocol.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAE1C,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAAG,mBAAmB,CAAC;AACxD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAC3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export declare const TaAuthServer: unique symbol;
|
|
2
|
+
export declare const TA_AUTH_SERVICE = "TaAuthServer";
|
|
3
|
+
/** How pi signs in to a provider: an account (OAuth), often a subscription, or an API key. */
|
|
4
|
+
export type TaAuthType = 'oauth' | 'api_key';
|
|
5
|
+
/** One way to sign in to a provider of models, as pi's `/login` lists them: a provider with both is listed twice. */
|
|
6
|
+
export interface TaAuthProvider {
|
|
7
|
+
/** pi's id of the provider, e.g. `anthropic`. */
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
type: TaAuthType;
|
|
11
|
+
/** The account is a subscription (Claude Pro, ChatGPT Plus…), not paid per request. */
|
|
12
|
+
subscription: boolean;
|
|
13
|
+
/** False for a key that only comes from the environment (variables, cloud profiles): there is nothing to type in. */
|
|
14
|
+
interactive: boolean;
|
|
15
|
+
/** How the provider is signed in now, if it is: with which kind, and from where (`stored credential`, an environment variable…). */
|
|
16
|
+
configured?: {
|
|
17
|
+
type: TaAuthType;
|
|
18
|
+
source?: string;
|
|
19
|
+
};
|
|
20
|
+
/** pi keeps a credential of it in auth.json, which `logout` removes. */
|
|
21
|
+
stored: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** What a sign-in asks the user, as pi's AuthPrompt: an answer goes back with `answer`, a choice by its id. */
|
|
24
|
+
export type TaAuthPrompt = {
|
|
25
|
+
type: 'text' | 'secret' | 'manual_code';
|
|
26
|
+
message: string;
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: 'select';
|
|
30
|
+
message: string;
|
|
31
|
+
options: {
|
|
32
|
+
id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
description?: string;
|
|
35
|
+
}[];
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* What happens during a sign-in, to the connection that started it (TaClient.onAuthEvent). The first
|
|
39
|
+
* four are pi's AuthEvent: a page to open, a code to type in elsewhere, what it is doing.
|
|
40
|
+
*/
|
|
41
|
+
export type TaAuthEvent = {
|
|
42
|
+
type: 'info';
|
|
43
|
+
message: string;
|
|
44
|
+
links?: {
|
|
45
|
+
url: string;
|
|
46
|
+
label?: string;
|
|
47
|
+
}[];
|
|
48
|
+
} | {
|
|
49
|
+
type: 'auth_url';
|
|
50
|
+
url: string;
|
|
51
|
+
instructions?: string;
|
|
52
|
+
} | {
|
|
53
|
+
type: 'device_code';
|
|
54
|
+
userCode: string;
|
|
55
|
+
verificationUri: string;
|
|
56
|
+
expiresInSeconds?: number;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'progress';
|
|
59
|
+
message: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'prompt';
|
|
62
|
+
promptId: string;
|
|
63
|
+
prompt: TaAuthPrompt;
|
|
64
|
+
}
|
|
65
|
+
/** The flow no longer waits for that answer: it got what it needed otherwise (a browser came back). */
|
|
66
|
+
| {
|
|
67
|
+
type: 'prompt_closed';
|
|
68
|
+
promptId: string;
|
|
69
|
+
} | {
|
|
70
|
+
type: 'done';
|
|
71
|
+
} | {
|
|
72
|
+
type: 'failed';
|
|
73
|
+
message: string;
|
|
74
|
+
cancelled?: boolean;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Signing in to providers of models from a client, as pi's `/login` and `/logout` do in the terminal.
|
|
78
|
+
* Credentials go to pi's auth.json on the server, for every session; they never come back to a client.
|
|
79
|
+
*/
|
|
80
|
+
export interface TaAuthServer {
|
|
81
|
+
listProviders(): Promise<TaAuthProvider[]>;
|
|
82
|
+
/** Starts a sign-in; its events go to this connection only. Resolves at once with its id. */
|
|
83
|
+
login(providerId: string, type: TaAuthType): Promise<string>;
|
|
84
|
+
/** Answers a prompt of a sign-in of this connection; false when it no longer waits for it. */
|
|
85
|
+
answer(loginId: string, promptId: string, value: string): Promise<boolean>;
|
|
86
|
+
cancel(loginId: string): Promise<void>;
|
|
87
|
+
/** Removes the stored credential of the provider. */
|
|
88
|
+
logout(providerId: string): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=auth-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-protocol.d.ts","sourceRoot":"","sources":["../../src/common/auth-protocol.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,eAAyB,CAAC;AACnD,eAAO,MAAM,eAAe,iBAAiB,CAAC;AAE9C,8FAA8F;AAC9F,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,CAAC;AAE7C,qHAAqH;AACrH,MAAM,WAAW,cAAc;IAC3B,iDAAiD;IACjD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,UAAU,CAAC;IACjB,uFAAuF;IACvF,YAAY,EAAE,OAAO,CAAC;IACtB,qHAAqH;IACrH,WAAW,EAAE,OAAO,CAAC;IACrB,oIAAoI;IACpI,UAAU,CAAC,EAAE;QAAE,IAAI,EAAE,UAAU,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACnD,wEAAwE;IACxE,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,+GAA+G;AAC/G,MAAM,MAAM,YAAY,GAClB;IAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAClF;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC;AAE1G;;;GAGG;AACH,MAAM,MAAM,WAAW,GACjB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,GAC5E;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GACxD;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7F;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE;AAC5D,uGAAuG;GACrG;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GAC3C;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,aAAa,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAC3C,6FAA6F;IAC7F,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7D,8FAA8F;IAC9F,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3E,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,qDAAqD;IACrD,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TA_AUTH_SERVICE = exports.TaAuthServer = void 0;
|
|
4
|
+
exports.TaAuthServer = Symbol('TaAuthServer');
|
|
5
|
+
exports.TA_AUTH_SERVICE = 'TaAuthServer';
|
|
6
|
+
//# sourceMappingURL=auth-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-protocol.js","sourceRoot":"","sources":["../../src/common/auth-protocol.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC;AACtC,QAAA,eAAe,GAAG,cAAc,CAAC"}
|
package/lib/common/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
export * from './auth-protocol';
|
|
2
|
+
export * from './package-protocol';
|
|
1
3
|
export * from './pi-types';
|
|
4
|
+
export * from './relay-protocol';
|
|
5
|
+
export * from './settings-protocol';
|
|
6
|
+
export * from './ta-extension-host';
|
|
2
7
|
export * from './ta-protocol';
|
|
8
|
+
export * from './workspace-protocol';
|
|
3
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,eAAe,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
|
package/lib/common/index.js
CHANGED
|
@@ -14,6 +14,12 @@ 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("./auth-protocol"), exports);
|
|
18
|
+
__exportStar(require("./package-protocol"), exports);
|
|
17
19
|
__exportStar(require("./pi-types"), exports);
|
|
20
|
+
__exportStar(require("./relay-protocol"), exports);
|
|
21
|
+
__exportStar(require("./settings-protocol"), exports);
|
|
22
|
+
__exportStar(require("./ta-extension-host"), exports);
|
|
18
23
|
__exportStar(require("./ta-protocol"), exports);
|
|
24
|
+
__exportStar(require("./workspace-protocol"), exports);
|
|
19
25
|
//# sourceMappingURL=index.js.map
|
package/lib/common/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,gDAA8B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,qDAAmC;AACnC,6CAA2B;AAC3B,mDAAiC;AACjC,sDAAoC;AACpC,sDAAoC;AACpC,gDAA8B;AAC9B,uDAAqC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { TaSettingsScope } from './settings-protocol';
|
|
2
|
+
export declare const TaPackageServer: unique symbol;
|
|
3
|
+
export declare const TA_PACKAGE_SERVICE = "TaPackageServer";
|
|
4
|
+
/**
|
|
5
|
+
* A web extension: the part of a pi package that extends the web client, as `extensions` extend pi. A
|
|
6
|
+
* package declares it in its `package.json`, `"pi": { "web": ["./web.js"] }`, or keeps it in `web/`.
|
|
7
|
+
* It is one ES module, without imports, that exports a function the web client calls with its API.
|
|
8
|
+
*/
|
|
9
|
+
export interface TaWebExtensionInfo {
|
|
10
|
+
/** Stable while the package stays where it is. */
|
|
11
|
+
id: string;
|
|
12
|
+
/** The `name` of the package, or the name of its directory. */
|
|
13
|
+
name: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
version?: string;
|
|
16
|
+
scope: 'user' | 'project';
|
|
17
|
+
/**
|
|
18
|
+
* `package`: a package of pi's `packages` setting (`ta install`). `directory`: a directory in `extensions/`.
|
|
19
|
+
* `builtin`: a package that comes with ta; it can be turned off (setPackageEnabled), not removed.
|
|
20
|
+
*/
|
|
21
|
+
origin: 'package' | 'directory' | 'builtin';
|
|
22
|
+
/** False for a built-in package that is turned off; the others are always on. */
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
/** The source in the `packages` setting, or the directory. */
|
|
25
|
+
source: string;
|
|
26
|
+
/** The file, relative to the package. */
|
|
27
|
+
entry: string;
|
|
28
|
+
/** Changes when the file changes. */
|
|
29
|
+
hash: string;
|
|
30
|
+
}
|
|
31
|
+
/** What a package holds: pi extensions, web extensions, skills, prompt templates, themes. */
|
|
32
|
+
export type TaPackageResource = 'extensions' | 'web' | 'skills' | 'prompts' | 'themes';
|
|
33
|
+
/** A pi package that Ta loads, whether it has a web extension or not. */
|
|
34
|
+
export interface TaPackageInfo {
|
|
35
|
+
/** Stable while the package stays where it is. */
|
|
36
|
+
id: string;
|
|
37
|
+
/** The `name` of its package.json, or the name of its directory. */
|
|
38
|
+
name: string;
|
|
39
|
+
description?: string;
|
|
40
|
+
version?: string;
|
|
41
|
+
scope: 'user' | 'project';
|
|
42
|
+
/** As TaWebExtensionInfo.origin. */
|
|
43
|
+
origin: TaWebExtensionInfo['origin'];
|
|
44
|
+
/** False for a built-in package that is turned off. */
|
|
45
|
+
enabled: boolean;
|
|
46
|
+
/** The source in the `packages` setting, or the directory. */
|
|
47
|
+
source: string;
|
|
48
|
+
/** Its directory, on the machine of the server. */
|
|
49
|
+
root: string;
|
|
50
|
+
/** What it holds, by its package.json or, without `pi` there, by the directories pi looks in. */
|
|
51
|
+
resources: TaPackageResource[];
|
|
52
|
+
}
|
|
53
|
+
export interface TaWebExtensionSource {
|
|
54
|
+
id: string;
|
|
55
|
+
hash: string;
|
|
56
|
+
code: string;
|
|
57
|
+
}
|
|
58
|
+
/** The packages of ta and the data they keep, on the same WebSocket as {@link TaServer}. */
|
|
59
|
+
export interface TaPackageServer {
|
|
60
|
+
/** The web extensions of the packages pi loads in `cwd` (default: the server's directory). */
|
|
61
|
+
listWebExtensions(cwd?: string): Promise<TaWebExtensionInfo[]>;
|
|
62
|
+
readWebExtension(id: string, cwd?: string): Promise<TaWebExtensionSource>;
|
|
63
|
+
/** Removes the package of a web extension: as `ta remove` for a package, deletes the directory for a directory. */
|
|
64
|
+
removeWebExtension(id: string, cwd?: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Turns a package on or off, what pi loads of it and its web extension; sessions pick it up on reload.
|
|
67
|
+
* A built-in one by its name; another by its id of listPackages, as `ta config` turns each of its
|
|
68
|
+
* resources on or off, in the settings of its scope.
|
|
69
|
+
*/
|
|
70
|
+
setPackageEnabled(nameOrId: string, enabled: boolean, cwd?: string): Promise<void>;
|
|
71
|
+
/** Every package pi loads in `cwd` (default: the server's directory), with a web extension or without. */
|
|
72
|
+
listPackages(cwd?: string): Promise<TaPackageInfo[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Installs a package and adds it to pi's `packages` setting, as `ta install` does: `npm:<name>`,
|
|
75
|
+
* `git:<repository>`, a URL of a repository, or a path. `project` as `ta install -l`, in a trusted
|
|
76
|
+
* project. Sessions pick it up on reload.
|
|
77
|
+
*/
|
|
78
|
+
installPackage(source: string, scope: TaSettingsScope, cwd?: string): Promise<void>;
|
|
79
|
+
/** Removes a package of listPackages: as `ta remove` for a package of the setting, deletes the directory for a directory. */
|
|
80
|
+
removePackage(id: string, cwd?: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Calls a method of what the module of `pi.host` of a package that comes with Ta returned
|
|
83
|
+
* (TaPackageService), with JSON values, and answers what it returns: how its web extension reaches it.
|
|
84
|
+
*/
|
|
85
|
+
callPackageHost(name: string, method: string, params?: unknown[]): Promise<unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* A value a package keeps on the server (WebExtensionAPI.storage); undefined when there is none. With
|
|
88
|
+
* `cwd`, a value of that directory, in its execution environment: each directory has its own keys.
|
|
89
|
+
*/
|
|
90
|
+
getExtensionData(name: string, key: string, cwd?: string): Promise<unknown>;
|
|
91
|
+
setExtensionData(name: string, key: string, value: unknown, cwd?: string): Promise<void>;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=package-protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-protocol.d.ts","sourceRoot":"","sources":["../../src/common/package-protocol.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TA_PACKAGE_SERVICE = exports.TaPackageServer = void 0;
|
|
4
|
+
exports.TaPackageServer = Symbol('TaPackageServer');
|
|
5
|
+
exports.TA_PACKAGE_SERVICE = 'TaPackageServer';
|
|
6
|
+
//# sourceMappingURL=package-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"package-protocol.js","sourceRoot":"","sources":["../../src/common/package-protocol.ts"],"names":[],"mappings":";;;AAGa,QAAA,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAC5C,QAAA,kBAAkB,GAAG,iBAAiB,CAAC"}
|
package/lib/common/pi-types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type ImageContent = import('@earendil-works/pi-ai', { with: { 'resolution-mode': 'import' } }).ImageContent;
|
|
2
2
|
export type JsonAgentSessionEvent = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).JsonAgentSessionEvent;
|
|
3
|
+
export type RpcCommand = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).RpcCommand;
|
|
3
4
|
export type RpcExtensionUIRequest = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).RpcExtensionUIRequest;
|
|
4
5
|
export type RpcExtensionUIResponse = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).RpcExtensionUIResponse;
|
|
5
6
|
export type RpcResponse = import('@earendil-works/pi-coding-agent', { with: { 'resolution-mode': 'import' } }).RpcResponse;
|