@celljs/ta-protocol 4.8.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 +2 -0
- package/esm/common/ta-extension-host.d.ts +9 -0
- package/esm/common/ta-extension-host.js +6 -0
- package/esm/common/ta-protocol.d.ts +110 -4
- package/esm/common/ta-protocol.js +33 -0
- package/esm/common/workspace-protocol.d.ts +12 -1
- package/esm/common/workspace-protocol.js +16 -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 +2 -0
- package/lib/common/ta-extension-host.d.ts +9 -0
- package/lib/common/ta-extension-host.js +7 -1
- package/lib/common/ta-protocol.d.ts +110 -4
- package/lib/common/ta-protocol.js +34 -1
- package/lib/common/workspace-protocol.d.ts +12 -1
- package/lib/common/workspace-protocol.js +17 -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 -73
- package/src/common/ta-extension-host.ts +0 -97
- package/src/common/ta-protocol.spec.ts +0 -48
- package/src/common/ta-protocol.ts +0 -352
- package/src/common/workspace-protocol.ts +0 -120
package/README.en.md
CHANGED
|
@@ -4,8 +4,8 @@ Protocol between `ta serve` and clients: types and constants only, with no pi or
|
|
|
4
4
|
|
|
5
5
|
- **Transport**: one WebSocket (`TA_WEBSOCKET_PATH`) with JSON-RPC 2.0 messages. Method names are `<service>/<method>`, and the server pushes `TaClient/onEvents` etc. HTTP-based calls are not offered; only workspace file bytes travel HTTP (`TA_FILES_PATH`, for images and iframes in pages to load via relative URLs).
|
|
6
6
|
- **Services**: `TaServer` (sessions—pi's RPC commands), `TaWorkspaceServer` (files and commands in directories), `TaTerminalServer` (terminals), `TaSettingsServer` (pi's `settings.json`), `TaPackageServer` (packages, web extensions, and package data), `TaAuthServer` (login to model services, same as pi's `/login` and `/logout`), `TaRelayServer` (paired devices via Relay, same as `ta pair`), `TaRemoteServer` (hosts for `ssh://` directories, ssh prompts, port forwarding). Capabilities outside sessions split into separate services by responsibility, not added to `TaServer`.
|
|
7
|
-
- **`TaServer` methods**: besides `openSession`, `closeSession`, `listSessions`, `attach`, `detach`, `respondUi`, and `respondClientTool`, the rest are pi RPC mode commands with the same name (snake_case → camelCase, see `PiCommandMethod`). The first parameter is `sessionId`, and return values match pi's; when pi adds an RPC command and `TaServer` lacks the method, this package's tests won't compile. `setWorkingDirectory` sets ta serve's working directory (`TaServerInfo.cwd`, used when clients don't specify one, persists across restarts). Session operations not in pi RPC: `forkToFile` (saves the forked session to a file, current session untouched, then open with `openSession`), `navigateTree` (same as pi's `/tree`, returns `editorText`), `fork` has an optional `position` (`at` keeps the selected item, like pi's `/clone` but optional for any item).
|
|
8
|
-
- **Events**: `TaEventEnvelope { sessionId, seq, event }`, where `event` is a pi JSON/RPC mode event or `extension_ui_request`. Ta adds only `ui_request_resolved`, `extension_error`, `session_replaced`, `session_closed`, and `client_tool_request` (reserved).
|
|
7
|
+
- **`TaServer` methods**: besides `openSession`, `closeSession`, `listSessions`, `attach`, `detach`, `respondUi`, and `respondClientTool`, the rest are pi RPC mode commands with the same name (snake_case → camelCase, see `PiCommandMethod`). The first parameter is `sessionId`, and return values match pi's; when pi adds an RPC command and `TaServer` lacks the method, this package's tests won't compile. `listSavedSessions` lists the conversations in pi's session files that are not open (closed while idle, or before a restart); `openSession` with their `sessionFile` opens them again. A session a package opened for its `group` gets a pi custom entry `ta-group` in its file, so the list carries its `group` and the package reopens it with its role; the role it was opened with (`appendSystemPrompt`) gets an entry `ta-role`, and opened again with only its `sessionFile` (a bot passing a message to a closed conversation of an agent) a session keeps the role and group written there. The page of the double keeps the session file of its conversation in the data `TA_DOUBLE_FILE` (`assistant.file` of `@celljs/ta-web`), by which packages on the server find the double. `setWorkingDirectory` sets ta serve's working directory (`TaServerInfo.cwd`, used when clients don't specify one, persists across restarts). Session operations not in pi RPC: `forkToFile` (saves the forked session to a file, current session untouched, then open with `openSession`), `navigateTree` (same as pi's `/tree`, returns `editorText`), `fork` has an optional `position` (`at` keeps the selected item, like pi's `/clone` but optional for any item).
|
|
8
|
+
- **Events**: `TaEventEnvelope { sessionId, seq, event }`, where `event` is a pi JSON/RPC mode event or `extension_ui_request`. Ta adds only `ui_request_resolved`, `extension_error`, `session_replaced`, `session_reloaded`, `session_closed`, and `client_tool_request` (reserved).
|
|
9
9
|
- **`prompt` / `steer` / `followUp`**: carry client-generated `clientMessageId`. Retrying with the same ID returns `duplicate` and doesn't re-execute. Receipt only means accepted; the round end is marked by the `agent_settled` event.
|
|
10
10
|
- **Locations** (`cwd`): a path is either local or on another machine in the form `ssh://<host>/<absolute-path>` (`TaLocation` parses, handles parent/child, and names).
|
|
11
11
|
- **Errors**: the JSON-RPC error code is `TA_RPC_ERROR_CODE`. The `data` field includes a stable `code` (`TaErrorCode`, e.g., `CELL_TA_SESSION_LOCKED`) and a one-line handling hint. When no model is available or the model service isn't signed in, the code is `CELL_TA_NOT_SIGNED_IN`; clients open the login page accordingly. `CELL_TA_CONNECTION_LOST` is client-generated: the call didn't reach ta serve, or the connection dropped before the result arrived.
|
package/README.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
- 传输:一条 WebSocket(`TA_WEBSOCKET_PATH`)上的 JSON-RPC 2.0,方法名是 `<服务>/<方法>`,服务端推送 `TaClient/onEvents` 等。不提供 HTTP 形式的调用;只有工作区文件的字节走 HTTP(`TA_FILES_PATH`,供页面里的图片、iframe 用相对地址加载)。
|
|
6
6
|
- 服务:`TaServer`(会话,即 pi 的 RPC 命令)、`TaWorkspaceServer`(目录里的文件与命令)、`TaTerminalServer`(终端)、`TaSettingsServer`(pi 的 `settings.json`)、`TaPackageServer`(包、Web 扩展与包的数据)、`TaAuthServer`(登录模型服务,同 pi 的 `/login` `/logout`)、`TaRelayServer`(经 Relay 配对设备,同 `ta pair`)、`TaRemoteServer`(`ssh://` 目录的主机、ssh 的提问、端口转发)。会话之外的能力按职责各成一个服务,不往 `TaServer` 里加。
|
|
7
|
-
- `TaServer` 的方法除了 `openSession` `closeSession` `listSessions` `attach` `detach` `respondUi` `respondClientTool`,其余都是 pi RPC 模式的同名命令(snake_case 改 camelCase,见 `PiCommandMethod`),第一个参数是 `sessionId`,返回值与 pi 相同;pi 新增 RPC 命令而 `TaServer` 没有对应方法时,本包的测试编译不过。`setWorkingDirectory` 设置 ta serve 的工作目录(`TaServerInfo.cwd`,客户端没指定目录时在这里开对话,跨重启保留)。pi RPC 没有的会话操作:`forkToFile`(把 fork 出的对话另存成会话文件,当前会话不动,再用 `openSession` 打开),`navigateTree`(同 pi 的 `/tree`,返回 `editorText`),`fork` 多一个可选的 `position`(`at` 保留所选条目,同 pi 的 `/clone` 但可选任意条目)。
|
|
8
|
-
- 事件:`TaEventEnvelope { sessionId, seq, event }`,`event` 是 pi JSON/RPC 模式的事件或 `extension_ui_request`;Ta 只多了 `ui_request_resolved`、`extension_error`、`session_replaced`、`session_closed`、`client_tool_request`(预留)。
|
|
7
|
+
- `TaServer` 的方法除了 `openSession` `closeSession` `listSessions` `attach` `detach` `respondUi` `respondClientTool`,其余都是 pi RPC 模式的同名命令(snake_case 改 camelCase,见 `PiCommandMethod`),第一个参数是 `sessionId`,返回值与 pi 相同;pi 新增 RPC 命令而 `TaServer` 没有对应方法时,本包的测试编译不过。`listSavedSessions` 列出 pi 会话文件里没打开的对话(空闲回收或重启前关掉的),用其 `sessionFile` 调 `openSession` 即可重新打开;包按分组(`group`)打开的会话会在文件里记一条 pi 的自定义条目 `ta-group`,列表里带上 `group`,由该包自己带着角色重新打开;打开时给的角色(`appendSystemPrompt`)也记一条 `ta-role`,只给 `sessionFile` 重新打开时(如机器人把消息转进一个已关闭的智能体对话)沿用记下的角色和分组。分身的页面把分身对话的会话文件存在包数据 `TA_DOUBLE_FILE`(`@celljs/ta-web` 的 `assistant.file`)里,服务端的包据此找到分身。`setWorkingDirectory` 设置 ta serve 的工作目录(`TaServerInfo.cwd`,客户端没指定目录时在这里开对话,跨重启保留)。pi RPC 没有的会话操作:`forkToFile`(把 fork 出的对话另存成会话文件,当前会话不动,再用 `openSession` 打开),`navigateTree`(同 pi 的 `/tree`,返回 `editorText`),`fork` 多一个可选的 `position`(`at` 保留所选条目,同 pi 的 `/clone` 但可选任意条目)。
|
|
8
|
+
- 事件:`TaEventEnvelope { sessionId, seq, event }`,`event` 是 pi JSON/RPC 模式的事件或 `extension_ui_request`;Ta 只多了 `ui_request_resolved`、`extension_error`、`session_replaced`、`session_reloaded`、`session_closed`、`client_tool_request`(预留)。
|
|
9
9
|
- `prompt` / `steer` / `followUp` 带客户端生成的 `clientMessageId`:重发同一个 id 返回 `duplicate`,不会再执行;回执只表示已受理,回合结束以 `agent_settled` 事件为准。
|
|
10
10
|
- 目录(`cwd`)是位置:本机路径,或另一台机器的 `ssh://<host>/<绝对路径>`(`TaLocation` 解析、上下级、名字)。
|
|
11
11
|
- 失败时 JSON-RPC 错误码为 `TA_RPC_ERROR_CODE`,`data` 里有稳定的 `code`(`TaErrorCode`,如 `CELL_TA_SESSION_LOCKED`)和一句处理建议 `hint`。没有可用的模型或模型服务没登录时是 `CELL_TA_NOT_SIGNED_IN`,客户端据此打开登录页。`CELL_TA_CONNECTION_LOST` 由客户端产生:调用没能送到 ta serve,或连接断开时还没收到结果。
|
|
@@ -0,0 +1,73 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const TaAccessServer = Symbol('TaAccessServer');
|
|
2
|
+
export 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 const TA_SIGN_IN_PATH = '/sign-in';
|
|
9
|
+
//# sourceMappingURL=access-protocol.js.map
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
}
|
package/esm/common/index.d.ts
CHANGED
package/esm/common/index.js
CHANGED
package/esm/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/esm/common/location.js
CHANGED
|
@@ -114,6 +114,18 @@ export var TaLocation;
|
|
|
114
114
|
return `${TaLocation.SSH}${host}${path ? normalize(path) : ''}`;
|
|
115
115
|
}
|
|
116
116
|
TaLocation.ssh = ssh;
|
|
117
|
+
/**
|
|
118
|
+
* A host as a list shows it, short: the name of the machine, without the user, the port and the domain
|
|
119
|
+
* (`me@dev.example.com:2222` is `dev`); an address whole.
|
|
120
|
+
*/
|
|
121
|
+
function hostLabel(host) {
|
|
122
|
+
const name = host
|
|
123
|
+
.replace(/^[^@]*@/, '')
|
|
124
|
+
.replace(/^\[(.*)\](?::\d+)?$/, '$1')
|
|
125
|
+
.replace(/^([^:]*):\d+$/, '$1');
|
|
126
|
+
return /^[\d.]+$/.test(name) || name.includes(':') ? name : name.split('.')[0] || name;
|
|
127
|
+
}
|
|
128
|
+
TaLocation.hostLabel = hostLabel;
|
|
117
129
|
/** The host of a remote location; undefined for this machine. */
|
|
118
130
|
function host(location) {
|
|
119
131
|
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,4 +129,23 @@ 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
|
}
|
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
export const TaPackageServer = Symbol('TaPackageServer');
|
|
2
2
|
export const TA_PACKAGE_SERVICE = 'TaPackageServer';
|
|
3
|
+
export var TaPackageTextUtil;
|
|
4
|
+
(function (TaPackageTextUtil) {
|
|
5
|
+
/** The text in a language such as `zh-CN`: that language, else its first part (`zh`), else English, else the first there is. */
|
|
6
|
+
function pick(text, language) {
|
|
7
|
+
var _a, _b, _c, _d;
|
|
8
|
+
if (text === undefined || typeof text === 'string') {
|
|
9
|
+
return text;
|
|
10
|
+
}
|
|
11
|
+
return (_d = (_c = (_b = (_a = text[language]) !== null && _a !== void 0 ? _a : text[language.split('-')[0]]) !== null && _b !== void 0 ? _b : text.en) !== null && _c !== void 0 ? _c : text['en-US']) !== null && _d !== void 0 ? _d : Object.values(text)[0];
|
|
12
|
+
}
|
|
13
|
+
TaPackageTextUtil.pick = pick;
|
|
14
|
+
})(TaPackageTextUtil || (TaPackageTextUtil = {}));
|
|
3
15
|
//# sourceMappingURL=package-protocol.js.map
|
|
@@ -25,4 +25,21 @@ export interface TaRelayServer {
|
|
|
25
25
|
}>;
|
|
26
26
|
/** The device can no longer reach this ta serve, at once. */
|
|
27
27
|
unpair(deviceId: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* A link of a package of this computer (by its id of listPackages, or of one of its web extensions), for
|
|
30
|
+
* another computer to open it without installing: its files go from here to there through the relay, end to
|
|
31
|
+
* end, while this ta serve runs and the link lasts; nothing is kept on the relay. The link of before while it lasts.
|
|
32
|
+
*/
|
|
33
|
+
sharePackage(id: string): Promise<TaPackageShare>;
|
|
34
|
+
/** The links of a package no longer work. */
|
|
35
|
+
unsharePackage(id: string): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
/** A package handed on by a link (TaRelayServer.sharePackage). */
|
|
38
|
+
export interface TaPackageShare {
|
|
39
|
+
/** `https://<relay>/share#…`, the key in the fragment: what `openTemporaryPackage` takes on the other computer. */
|
|
40
|
+
link: string;
|
|
41
|
+
/** Milliseconds since the epoch. */
|
|
42
|
+
expiresAt: number;
|
|
43
|
+
/** The largest package that goes, in bytes. */
|
|
44
|
+
maxBytes: number;
|
|
28
45
|
}
|
|
@@ -30,6 +30,8 @@ export interface TaSettingsSnapshot {
|
|
|
30
30
|
models: string[];
|
|
31
31
|
/** The names of those of `models` that have one other than their id. */
|
|
32
32
|
modelNames?: Record<string, string>;
|
|
33
|
+
/** By id, the names of the providers of `models` (`Kimi For Coding` for `kimi-coding`), as the lists of models group them. */
|
|
34
|
+
providerNames?: Record<string, string>;
|
|
33
35
|
}
|
|
34
36
|
/** The settings of ta in pi's `settings.json` files, on the same WebSocket as {@link TaServer}. */
|
|
35
37
|
export interface TaSettingsServer {
|
|
@@ -41,6 +41,15 @@ export declare const TA_HOST_EVENT = "ta:host";
|
|
|
41
41
|
* keeps what the file holds then.
|
|
42
42
|
*/
|
|
43
43
|
export declare const TA_FILE_WRITE_EVENT = "ta:file-write";
|
|
44
|
+
/**
|
|
45
|
+
* Where the web client keeps the session file of the double's conversation: in the data of packages
|
|
46
|
+
* (TaExtensionHost.getExtensionData), under this package name and key; a JSON string, empty before the
|
|
47
|
+
* double first opened. The server side of a package that sends to the double reads it there.
|
|
48
|
+
*/
|
|
49
|
+
export declare const TA_DOUBLE_FILE: {
|
|
50
|
+
readonly name: '@celljs/ta-web';
|
|
51
|
+
readonly key: 'assistant.file';
|
|
52
|
+
};
|
|
44
53
|
export interface TaFileWrite {
|
|
45
54
|
/** Absolute, on the machine where the session's tools work. */
|
|
46
55
|
path: string;
|
|
@@ -12,4 +12,10 @@ export const TA_HOST_EVENT = 'ta:host';
|
|
|
12
12
|
* keeps what the file holds then.
|
|
13
13
|
*/
|
|
14
14
|
export const TA_FILE_WRITE_EVENT = 'ta:file-write';
|
|
15
|
+
/**
|
|
16
|
+
* Where the web client keeps the session file of the double's conversation: in the data of packages
|
|
17
|
+
* (TaExtensionHost.getExtensionData), under this package name and key; a JSON string, empty before the
|
|
18
|
+
* double first opened. The server side of a package that sends to the double reads it there.
|
|
19
|
+
*/
|
|
20
|
+
export const TA_DOUBLE_FILE = { name: '@celljs/ta-web', key: 'assistant.file' };
|
|
15
21
|
//# sourceMappingURL=ta-extension-host.js.map
|
|
@@ -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,17 +236,59 @@ 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. */
|
|
@@ -236,11 +327,24 @@ export interface TaServer {
|
|
|
236
327
|
openSession(options: TaOpenSessionOptions): Promise<TaSessionInfo>;
|
|
237
328
|
closeSession(sessionId: string): Promise<void>;
|
|
238
329
|
listSessions(): Promise<TaSessionInfo[]>;
|
|
330
|
+
/** The conversations in pi's session files that are not open, the latest first. */
|
|
331
|
+
listSavedSessions(): Promise<TaSavedSessionInfo[]>;
|
|
239
332
|
/** Starts sending the events of the session to this connection. */
|
|
240
|
-
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>;
|
|
241
339
|
detach(sessionId: string): Promise<void>;
|
|
242
340
|
/** Answers a dialog; false when it was answered before or expired. */
|
|
243
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>;
|
|
244
348
|
/** Answers a call of a client tool; false when nobody waits for it. */
|
|
245
349
|
respondClientTool(sessionId: string, result: TaClientToolResult): Promise<boolean>;
|
|
246
350
|
prompt(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
@@ -248,6 +352,8 @@ export interface TaServer {
|
|
|
248
352
|
followUp(sessionId: string, input: TaPromptInput): Promise<TaPromptReceipt>;
|
|
249
353
|
abort(sessionId: string): Promise<void>;
|
|
250
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>;
|
|
251
357
|
newSession(sessionId: string, parentSession?: string): Promise<TaCommandResult<'new_session'>>;
|
|
252
358
|
getState(sessionId: string): Promise<TaCommandResult<'get_state'>>;
|
|
253
359
|
setModel(sessionId: string, provider: string, modelId: string): Promise<TaCommandResult<'set_model'>>;
|