@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
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
import type { TaAuthEvent } from './auth-protocol';
|
|
2
|
-
import type { ImageContent, JsonAgentSessionEvent, RpcCommand, RpcExtensionUIRequest, RpcExtensionUIResponse, RpcResponse, ThinkingLevel } from './pi-types';
|
|
3
|
-
import type { TaRemoteEvent } from './remote-protocol';
|
|
4
|
-
|
|
5
|
-
export const TaServer = Symbol('TaServer');
|
|
6
|
-
export const TaClient = Symbol('TaClient');
|
|
7
|
-
|
|
8
|
-
/** Path of the WebSocket endpoint of `ta serve`, and the JSON-RPC method prefixes of both sides. */
|
|
9
|
-
export const TA_WEBSOCKET_PATH = '/api/ws';
|
|
10
|
-
export const TA_SERVER_SERVICE = 'TaServer';
|
|
11
|
-
export const TA_CLIENT_SERVICE = 'TaClient';
|
|
12
|
-
|
|
13
|
-
/** The file `ta serve` writes in the agent directory, readable only by its user. */
|
|
14
|
-
export const TA_SERVE_FILE = 'serve.json';
|
|
15
|
-
|
|
16
|
-
/** The contents of {@link TA_SERVE_FILE}: how to reach the running `ta serve`. */
|
|
17
|
-
export interface TaServeInfo {
|
|
18
|
-
url: string;
|
|
19
|
-
token: string;
|
|
20
|
-
pid: number;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** What a client needs to know of the server before it opens a session. */
|
|
24
|
-
export interface TaServerInfo {
|
|
25
|
-
/** The version of ta. */
|
|
26
|
-
version: string;
|
|
27
|
-
/**
|
|
28
|
-
* Where a client opens a session when the user names no directory: the one set with
|
|
29
|
-
* `setWorkingDirectory`, else the working directory of `ta serve`, or of its execution environment.
|
|
30
|
-
*/
|
|
31
|
-
cwd: string;
|
|
32
|
-
/** The user who runs `ta serve`, as the system names them: whose Ta the client is signed in to. */
|
|
33
|
-
user: string;
|
|
34
|
-
/** The name of the machine of `ta serve`, without a `.local` suffix. */
|
|
35
|
-
host: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** The stable `code` of each failure of a {@link TaServer} call. */
|
|
39
|
-
export const TaErrorCode = {
|
|
40
|
-
SESSION_NOT_FOUND: 'CELL_TA_SESSION_NOT_FOUND',
|
|
41
|
-
SESSION_LOCKED: 'CELL_TA_SESSION_LOCKED',
|
|
42
|
-
TOO_MANY_SESSIONS: 'CELL_TA_TOO_MANY_SESSIONS',
|
|
43
|
-
MESSAGE_CONFLICT: 'CELL_TA_MESSAGE_CONFLICT',
|
|
44
|
-
MODEL_NOT_FOUND: 'CELL_TA_MODEL_NOT_FOUND',
|
|
45
|
-
INVALID_ARGUMENT: 'CELL_TA_INVALID_ARGUMENT',
|
|
46
|
-
COMMAND_FAILED: 'CELL_TA_COMMAND_FAILED',
|
|
47
|
-
/** No provider of models is signed in for the model, or there is no model: sign in (TaAuthServer) first. */
|
|
48
|
-
NOT_SIGNED_IN: 'CELL_TA_NOT_SIGNED_IN',
|
|
49
|
-
/** Raised by the client, not the server: the call could not reach ta serve, or its answer was lost with the connection. */
|
|
50
|
-
CONNECTION_LOST: 'CELL_TA_CONNECTION_LOST',
|
|
51
|
-
} as const;
|
|
52
|
-
export type TaErrorCode = (typeof TaErrorCode)[keyof typeof TaErrorCode];
|
|
53
|
-
|
|
54
|
-
/** The JSON-RPC error code of every failure of a {@link TaServer} call; `data.code` tells them apart. */
|
|
55
|
-
export const TA_RPC_ERROR_CODE = -32050;
|
|
56
|
-
|
|
57
|
-
export interface TaErrorData {
|
|
58
|
-
code: TaErrorCode;
|
|
59
|
-
/** One sentence on what to do about it. */
|
|
60
|
-
hint: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/** A command name of pi's RPC mode (`get_state`, `follow_up`, ...). */
|
|
64
|
-
export type TaCommand = Extract<RpcResponse, { success: true }>['command'];
|
|
65
|
-
|
|
66
|
-
/** The answer to `forkToFile`. */
|
|
67
|
-
export interface TaForkFileResult {
|
|
68
|
-
/** The new conversation; none when nothing comes before the message: then a new conversation starts. */
|
|
69
|
-
sessionFile?: string;
|
|
70
|
-
/** The message of the user left out (`before`), for the box of the new conversation. */
|
|
71
|
-
text?: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/** The answer to `navigateTree`, which pi's RPC mode does not have. */
|
|
75
|
-
export interface TaNavigateResult {
|
|
76
|
-
cancelled: boolean;
|
|
77
|
-
editorText?: string;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/** `get_state` → `getState`. */
|
|
81
|
-
type CamelCase<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : S;
|
|
82
|
-
|
|
83
|
-
/** The method of TaServer for each command of pi's RPC mode: TaServer has one for each (see its spec). */
|
|
84
|
-
export type PiCommandMethod = CamelCase<RpcCommand['type']>;
|
|
85
|
-
|
|
86
|
-
/** What pi's RPC mode answers to a command. */
|
|
87
|
-
export type TaCommandResult<C extends TaCommand> = Extract<RpcResponse, { command: C; success: true }> extends { data: infer D } ? D : undefined;
|
|
88
|
-
|
|
89
|
-
/** A tool the client runs: the model calls it like any other tool, the server asks the client for the result. */
|
|
90
|
-
export interface TaClientToolDefinition {
|
|
91
|
-
/** Letters, digits, `_` and `-`, starting with a letter; best not the name of another tool of the session. */
|
|
92
|
-
name: string;
|
|
93
|
-
description: string;
|
|
94
|
-
/** JSON schema of the arguments, an object schema. */
|
|
95
|
-
parameters: Record<string, unknown>;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export interface TaOpenSessionOptions {
|
|
99
|
-
/** Working directory of the session: a path of the machine of the server, or an `ssh://` location of another (TaLocation). */
|
|
100
|
-
cwd: string;
|
|
101
|
-
/** Opens this session file; default: a new session. */
|
|
102
|
-
sessionFile?: string;
|
|
103
|
-
/** `<provider>/<model id>`; default: pi's settings. */
|
|
104
|
-
model?: string;
|
|
105
|
-
thinkingLevel?: ThinkingLevel;
|
|
106
|
-
/** Tools the client runs; fixed when the session opens, so the tool list stays stable for prompt caching. */
|
|
107
|
-
clientTools?: TaClientToolDefinition[];
|
|
108
|
-
/** Added to the system prompt, as pi's `--append-system-prompt`: a role the client gives the agent. */
|
|
109
|
-
appendSystemPrompt?: string;
|
|
110
|
-
/** Sessions a package opens for its own work (the name of the package): clients list them apart, folded. */
|
|
111
|
-
group?: string;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export interface TaSessionInfo {
|
|
115
|
-
/** The id of this open session; stays the same through `newSession`, `switchSession` and `fork`. */
|
|
116
|
-
sessionId: string;
|
|
117
|
-
/** The id of the conversation pi has open now. */
|
|
118
|
-
piSessionId: string;
|
|
119
|
-
cwd: string;
|
|
120
|
-
sessionFile?: string;
|
|
121
|
-
sessionName?: string;
|
|
122
|
-
/** The first line of the first message of the user, which a list shows when the session has no name. */
|
|
123
|
-
firstMessage?: string;
|
|
124
|
-
/** `<provider>/<model id>`. */
|
|
125
|
-
model?: string;
|
|
126
|
-
isStreaming: boolean;
|
|
127
|
-
messageCount: number;
|
|
128
|
-
/** Number of clients attached. */
|
|
129
|
-
attached: number;
|
|
130
|
-
createdAt: number;
|
|
131
|
-
/** When the last message came; `createdAt` before the first. */
|
|
132
|
-
updatedAt: number;
|
|
133
|
-
/** TaOpenSessionOptions.group. */
|
|
134
|
-
group?: string;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export interface TaPromptInput {
|
|
138
|
-
/** May start with a block of context for the model, which clients do not show: see {@link TaMessageContext}. */
|
|
139
|
-
message: string;
|
|
140
|
-
images?: ImageContent[];
|
|
141
|
-
/** Chosen by the client, unique per message: sending the same one again does not run it again. */
|
|
142
|
-
clientMessageId: string;
|
|
143
|
-
/** What to do when the agent is running; only for `prompt`. Default: `followUp`. */
|
|
144
|
-
streamingBehavior?: 'steer' | 'followUp';
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* A message of the user may start with a `<context>` block: what the model reads besides the message
|
|
149
|
-
* (where it is said, who is there, what was said before), which a client leaves out when it shows it.
|
|
150
|
-
*/
|
|
151
|
-
export namespace TaMessageContext {
|
|
152
|
-
const BLOCK = /^<context>\n?[\s\S]*?\n?<\/context>\n?/;
|
|
153
|
-
|
|
154
|
-
export function wrap(context: string, message: string): string {
|
|
155
|
-
return `<context>\n${context}\n</context>\n${message}`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/** The message without its context: what the user sees of it. */
|
|
159
|
-
export function strip(message: string): string {
|
|
160
|
-
return message.replace(BLOCK, '');
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* The server has taken the message; it says nothing about the run. A run is finished at the
|
|
166
|
-
* `agent_settled` event, when its history is on disk.
|
|
167
|
-
*/
|
|
168
|
-
export interface TaPromptReceipt {
|
|
169
|
-
clientMessageId: string;
|
|
170
|
-
/** `accepted`: it runs now; `queued`: after the current work; `duplicate`: this id was taken before. */
|
|
171
|
-
status: 'accepted' | 'queued' | 'duplicate';
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/** An extension's dialog was answered by another client, or expired. */
|
|
175
|
-
export interface TaUiRequestResolved {
|
|
176
|
-
type: 'ui_request_resolved';
|
|
177
|
-
id: string;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/** An extension threw while handling an event. */
|
|
181
|
-
export interface TaExtensionError {
|
|
182
|
-
type: 'extension_error';
|
|
183
|
-
extensionPath: string;
|
|
184
|
-
event: string;
|
|
185
|
-
error: string;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
/** The open session now shows another conversation (`newSession`, `switchSession`, `fork`, `clone`, `navigateTree`): read it again. */
|
|
189
|
-
export interface TaSessionReplaced {
|
|
190
|
-
type: 'session_replaced';
|
|
191
|
-
info: TaSessionInfo;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/** The session was closed; no more events come. */
|
|
195
|
-
export interface TaSessionClosed {
|
|
196
|
-
type: 'session_closed';
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* The model called a tool of `clientTools`: a client that runs it answers with `respondClientTool`.
|
|
201
|
-
* It goes to every attached client; the first answer counts, and `client_tool_resolved` tells the others.
|
|
202
|
-
*/
|
|
203
|
-
export interface TaClientToolRequest {
|
|
204
|
-
type: 'client_tool_request';
|
|
205
|
-
/** The id of the tool call. */
|
|
206
|
-
id: string;
|
|
207
|
-
toolName: string;
|
|
208
|
-
input: unknown;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/** A call of a client tool was answered, or ended because the run was aborted or the session closed. */
|
|
212
|
-
export interface TaClientToolResolved {
|
|
213
|
-
type: 'client_tool_resolved';
|
|
214
|
-
id: string;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
export type TaEvent =
|
|
218
|
-
| JsonAgentSessionEvent
|
|
219
|
-
| RpcExtensionUIRequest
|
|
220
|
-
| TaUiRequestResolved
|
|
221
|
-
| TaExtensionError
|
|
222
|
-
| TaClientToolRequest
|
|
223
|
-
| TaClientToolResolved
|
|
224
|
-
| TaSessionReplaced
|
|
225
|
-
| TaSessionClosed;
|
|
226
|
-
|
|
227
|
-
export interface TaEventEnvelope {
|
|
228
|
-
sessionId: string;
|
|
229
|
-
/** Increases by one per event of the session. */
|
|
230
|
-
seq: number;
|
|
231
|
-
event: TaEvent;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
export interface TaAttachResult {
|
|
235
|
-
info: TaSessionInfo;
|
|
236
|
-
/** The events after `afterSeq`. */
|
|
237
|
-
events: TaEventEnvelope[];
|
|
238
|
-
/** The dialogs still waiting for an answer. */
|
|
239
|
-
pendingUi: RpcExtensionUIRequest[];
|
|
240
|
-
/** The calls of client tools still waiting for a result. */
|
|
241
|
-
pendingClientTools: TaClientToolRequest[];
|
|
242
|
-
/** Seq of the last event of the session. */
|
|
243
|
-
lastSeq: number;
|
|
244
|
-
/** Some events after `afterSeq` are gone: read the conversation again with `getMessages`. */
|
|
245
|
-
gap: boolean;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export interface TaClientToolResult {
|
|
249
|
-
/** The `id` of the request. */
|
|
250
|
-
id: string;
|
|
251
|
-
/** What the model reads. */
|
|
252
|
-
output: string;
|
|
253
|
-
/** The tool failed: `output` says why. */
|
|
254
|
-
isError?: boolean;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
/**
|
|
258
|
-
* The sessions of `ta serve`, over JSON-RPC 2.0 on a WebSocket. Besides opening, attaching and answering,
|
|
259
|
-
* each method is the command of pi's RPC mode with the same name in camelCase, on the open session
|
|
260
|
-
* `sessionId` (see PiCommandMethod). The same WebSocket carries the other services of ta serve, each
|
|
261
|
-
* under its own name: TaWorkspaceServer, TaTerminalServer, TaSettingsServer, TaPackageServer, TaRemoteServer and others.
|
|
262
|
-
*/
|
|
263
|
-
export interface TaServer {
|
|
264
|
-
getServerInfo(): Promise<TaServerInfo>;
|
|
265
|
-
/**
|
|
266
|
-
* Makes `cwd` the working directory of the server (TaServerInfo.cwd), for every client, and across
|
|
267
|
-
* restarts: where conversations open when the user names no directory. Sessions already open stay where they are.
|
|
268
|
-
*/
|
|
269
|
-
setWorkingDirectory(cwd: string): Promise<TaServerInfo>;
|
|
270
|
-
openSession(options: TaOpenSessionOptions): Promise<TaSessionInfo>;
|
|
271
|
-
closeSession(sessionId: string): Promise<void>;
|
|
272
|
-
listSessions(): Promise<TaSessionInfo[]>;
|
|
273
|
-
/** Starts sending the events of the session to this connection. */
|
|
274
|
-
attach(sessionId: string, afterSeq?: number): Promise<TaAttachResult>;
|
|
275
|
-
detach(sessionId: string): Promise<void>;
|
|
276
|
-
/** Answers a dialog; false when it was answered before or expired. */
|
|
277
|
-
respondUi(sessionId: string, response: RpcExtensionUIResponse): Promise<boolean>;
|
|
278
|
-
/** Answers a call of a client tool; false when nobody waits for it. */
|
|
279
|
-
respondClientTool(sessionId: string, result: TaClientToolResult): Promise<boolean>;
|
|
280
|
-
|
|
281
|
-
prompt(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
282
|
-
steer(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
283
|
-
followUp(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
284
|
-
abort(sessionId: string): Promise<void>;
|
|
285
|
-
clearQueue(sessionId: string): Promise<TaCommandResult<'clear_queue'>>;
|
|
286
|
-
newSession(sessionId: string, parentSession?: string): Promise<TaCommandResult<'new_session'>>;
|
|
287
|
-
getState(sessionId: string): Promise<TaCommandResult<'get_state'>>;
|
|
288
|
-
setModel(sessionId: string, provider: string, modelId: string): Promise<TaCommandResult<'set_model'>>;
|
|
289
|
-
cycleModel(sessionId: string): Promise<TaCommandResult<'cycle_model'>>;
|
|
290
|
-
getAvailableModels(sessionId: string): Promise<TaCommandResult<'get_available_models'>>;
|
|
291
|
-
setThinkingLevel(sessionId: string, level: ThinkingLevel): Promise<void>;
|
|
292
|
-
cycleThinkingLevel(sessionId: string): Promise<TaCommandResult<'cycle_thinking_level'>>;
|
|
293
|
-
getAvailableThinkingLevels(sessionId: string): Promise<TaCommandResult<'get_available_thinking_levels'>>;
|
|
294
|
-
setSteeringMode(sessionId: string, mode: 'all' | 'one-at-a-time'): Promise<void>;
|
|
295
|
-
setFollowUpMode(sessionId: string, mode: 'all' | 'one-at-a-time'): Promise<void>;
|
|
296
|
-
compact(sessionId: string, customInstructions?: string): Promise<TaCommandResult<'compact'>>;
|
|
297
|
-
setAutoCompaction(sessionId: string, enabled: boolean): Promise<void>;
|
|
298
|
-
setAutoRetry(sessionId: string, enabled: boolean): Promise<void>;
|
|
299
|
-
abortRetry(sessionId: string): Promise<void>;
|
|
300
|
-
bash(sessionId: string, command: string, excludeFromContext?: boolean): Promise<TaCommandResult<'bash'>>;
|
|
301
|
-
abortBash(sessionId: string): Promise<void>;
|
|
302
|
-
getSessionStats(sessionId: string): Promise<TaCommandResult<'get_session_stats'>>;
|
|
303
|
-
exportHtml(sessionId: string, outputPath?: string): Promise<TaCommandResult<'export_html'>>;
|
|
304
|
-
switchSession(sessionId: string, sessionPath: string): Promise<TaCommandResult<'switch_session'>>;
|
|
305
|
-
/**
|
|
306
|
-
* A new conversation from an entry, as pi's `/fork`: `before` (the default) a message of the user, which
|
|
307
|
-
* it leaves out and gives back as `text`; `at` any entry, which it keeps.
|
|
308
|
-
*/
|
|
309
|
-
fork(sessionId: string, entryId: string, position?: 'before' | 'at'): Promise<TaCommandResult<'fork'>>;
|
|
310
|
-
/**
|
|
311
|
-
* The new conversation of `fork` in a file of its own, with pi's `createBranchedSession`; the session
|
|
312
|
-
* stays where it is. Open the file with `openSession` to go on with it.
|
|
313
|
-
*/
|
|
314
|
-
forkToFile(sessionId: string, entryId: string, position?: 'before' | 'at'): Promise<TaForkFileResult>;
|
|
315
|
-
clone(sessionId: string): Promise<TaCommandResult<'clone'>>;
|
|
316
|
-
getForkMessages(sessionId: string): Promise<TaCommandResult<'get_fork_messages'>>;
|
|
317
|
-
getEntries(sessionId: string, since?: string): Promise<TaCommandResult<'get_entries'>>;
|
|
318
|
-
getTree(sessionId: string): Promise<TaCommandResult<'get_tree'>>;
|
|
319
|
-
/**
|
|
320
|
-
* Goes to an entry in the same conversation, as pi's `/tree`: the branch left stays in the tree. To a
|
|
321
|
-
* message of the user, it goes to what came before and gives the message back as `editorText`.
|
|
322
|
-
*/
|
|
323
|
-
navigateTree(sessionId: string, targetId: string): Promise<TaNavigateResult>;
|
|
324
|
-
getLastAssistantText(sessionId: string): Promise<TaCommandResult<'get_last_assistant_text'>>;
|
|
325
|
-
setSessionName(sessionId: string, name: string): Promise<void>;
|
|
326
|
-
getMessages(sessionId: string): Promise<TaCommandResult<'get_messages'>>;
|
|
327
|
-
getCommands(sessionId: string): Promise<TaCommandResult<'get_commands'>>;
|
|
328
|
-
/** Loads extensions, skills, prompts and themes again, as pi's `/reload` does. */
|
|
329
|
-
reload(sessionId: string): Promise<void>;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/** What a client implements. Events come in batches: one message per frame, however fast the model streams. */
|
|
333
|
-
export interface TaClient {
|
|
334
|
-
onEvents(events: TaEventEnvelope[]): Promise<void>;
|
|
335
|
-
/** Output of a terminal of this connection; with `exitCode`, the terminal has ended. */
|
|
336
|
-
onTerminalData(terminalId: string, data: string, exitCode?: number): Promise<void>;
|
|
337
|
-
/**
|
|
338
|
-
* Keys of the data of a package (setExtensionData) that changed, by this client or another, or by the
|
|
339
|
-
* package on the server; with `cwd`, keys of that directory. It comes for the data this connection
|
|
340
|
-
* read, at most every few hundred milliseconds, with the keys of that time together.
|
|
341
|
-
*/
|
|
342
|
-
onExtensionData(name: string, keys: string[], cwd?: string): Promise<void>;
|
|
343
|
-
/** What happens during a sign-in this connection started (TaAuthServer.login). */
|
|
344
|
-
onAuthEvent(loginId: string, event: TaAuthEvent): Promise<void>;
|
|
345
|
-
/** What happens with the remote machines, once this connection called TaRemoteServer.watch. */
|
|
346
|
-
onRemoteEvent(event: TaRemoteEvent): Promise<void>;
|
|
347
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { TaServer } from './ta-protocol';
|
|
2
|
-
|
|
3
|
-
/** Where the page loads the bytes of workspace files from: see {@link TaWorkspaceServer.fileUrl}. */
|
|
4
|
-
export const TA_FILES_PATH = '/api/files';
|
|
5
|
-
|
|
6
|
-
export const TaWorkspaceServer = Symbol('TaWorkspaceServer');
|
|
7
|
-
export const TA_WORKSPACE_SERVICE = 'TaWorkspaceServer';
|
|
8
|
-
export const TaTerminalServer = Symbol('TaTerminalServer');
|
|
9
|
-
export const TA_TERMINAL_SERVICE = 'TaTerminalServer';
|
|
10
|
-
|
|
11
|
-
/** An entry of a directory of the workspace. */
|
|
12
|
-
export interface TaDirEntry {
|
|
13
|
-
name: string;
|
|
14
|
-
/** Relative to the directory the call names as `cwd`, with `/`. */
|
|
15
|
-
path: string;
|
|
16
|
-
kind: 'file' | 'directory';
|
|
17
|
-
size?: number;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface TaFileContent {
|
|
21
|
-
path: string;
|
|
22
|
-
size: number;
|
|
23
|
-
/** Not text: `text` is left out. */
|
|
24
|
-
binary: boolean;
|
|
25
|
-
/** Larger than the limit (1 MB): `text` holds the start. */
|
|
26
|
-
truncated: boolean;
|
|
27
|
-
text?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface TaRunCommandOptions {
|
|
31
|
-
/** Default: the server's directory. */
|
|
32
|
-
cwd?: string;
|
|
33
|
-
/** Written to the standard input, which is then closed. */
|
|
34
|
-
input?: string;
|
|
35
|
-
/** Default 30 s, at most 120 s; the process is killed then. */
|
|
36
|
-
timeoutMs?: number;
|
|
37
|
-
/** Of each of stdout and stderr; default 1 MB, at most 8 MB. */
|
|
38
|
-
maxBytes?: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface TaCommandOutput {
|
|
42
|
-
stdout: string;
|
|
43
|
-
stderr: string;
|
|
44
|
-
/** null when it was killed (`timedOut`) or ended by a signal. */
|
|
45
|
-
exitCode: number | null;
|
|
46
|
-
/** An output was longer than `maxBytes`: it holds the start. */
|
|
47
|
-
truncated: boolean;
|
|
48
|
-
timedOut: boolean;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* The files of a directory of the machine of `ta serve` and programs run there, on the same WebSocket as
|
|
53
|
-
* {@link TaServer}. Paths are relative to `cwd` (default: the server's directory) and may not leave it;
|
|
54
|
-
* the work runs in the execution environment of `cwd`, as the tools of a session do.
|
|
55
|
-
*/
|
|
56
|
-
export interface TaWorkspaceServer {
|
|
57
|
-
/** Directories first, then by name; `.git` is left out. */
|
|
58
|
-
listDirectory(path: string, cwd?: string): Promise<TaDirEntry[]>;
|
|
59
|
-
readFile(path: string, cwd?: string): Promise<TaFileContent>;
|
|
60
|
-
/** Writes the text of a file; its directory must be there. */
|
|
61
|
-
writeFile(path: string, text: string, cwd?: string): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* A URL of this server, under {@link TA_FILES_PATH}, that answers the bytes of a file of `cwd`, for
|
|
64
|
-
* what the page shows as it is: an image, a video, a page with what it loads next to it. The URL needs
|
|
65
|
-
* no token, so that a page loads the files beside it with relative URLs; each `cwd` has its own
|
|
66
|
-
* secret part. Pages are answered sandboxed: they run in an origin of their own, not the server's.
|
|
67
|
-
*/
|
|
68
|
-
fileUrl(path: string, cwd?: string): Promise<string>;
|
|
69
|
-
/** Paths of files whose name matches `query` loosely, best first; ignored files are left out. */
|
|
70
|
-
findFiles(query: string, cwd?: string, limit?: number): Promise<string[]>;
|
|
71
|
-
/**
|
|
72
|
-
* Runs a program with its arguments, without a shell, in the execution environment of `cwd`, and
|
|
73
|
-
* answers its output once it ends: what packages build on (git, rg) instead of a method each.
|
|
74
|
-
*/
|
|
75
|
-
runCommand(command: string, args: string[], options?: TaRunCommandOptions): Promise<TaCommandOutput>;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export interface TaTerminalInfo {
|
|
79
|
-
terminalId: string;
|
|
80
|
-
cwd: string;
|
|
81
|
-
shell: string;
|
|
82
|
-
/** False: plain pipes (no `script` on the server, or Windows): full-screen programs do not draw right. */
|
|
83
|
-
pty: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export interface TaOpenTerminalOptions {
|
|
87
|
-
/** Default: the server's directory. */
|
|
88
|
-
cwd?: string;
|
|
89
|
-
cols: number;
|
|
90
|
-
rows: number;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/** The shells of a connection, on the same WebSocket as {@link TaServer}. */
|
|
94
|
-
export interface TaTerminalServer {
|
|
95
|
-
/** A shell of this connection; its output comes by TaClient.onTerminalData. It closes 30 s after the connection drops. */
|
|
96
|
-
openTerminal(options: TaOpenTerminalOptions): Promise<TaTerminalInfo>;
|
|
97
|
-
writeTerminal(terminalId: string, data: string): Promise<void>;
|
|
98
|
-
resizeTerminal(terminalId: string, cols: number, rows: number): Promise<void>;
|
|
99
|
-
closeTerminal(terminalId: string): Promise<void>;
|
|
100
|
-
/** The terminals of this connection that are still open. */
|
|
101
|
-
listTerminals(): Promise<TaTerminalInfo[]>;
|
|
102
|
-
}
|