tellrun 1.3.2 → 1.3.4
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 +14 -11
- package/README.zh-CN.md +4 -1
- package/dist/agents/codex-rpc.js +85 -0
- package/dist/agents/codex-rpc.js.map +1 -0
- package/dist/agents/codex.js +278 -256
- package/dist/agents/codex.js.map +1 -1
- package/dist/core/menus.js +137 -0
- package/dist/core/menus.js.map +1 -0
- package/dist/core/relay.js +35 -5
- package/dist/core/relay.js.map +1 -1
- package/dist/im/telegram.js +58 -56
- package/dist/im/telegram.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/storage/schema.js +48 -9
- package/dist/storage/schema.js.map +1 -1
- package/dist/storage/store.js +45 -66
- package/dist/storage/store.js.map +1 -1
- package/docs/architecture.md +14 -0
- package/docs/prd.md +3 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,20 +49,23 @@ Without `/cwd`, the working directory defaults to the directory where the servic
|
|
|
49
49
|
|
|
50
50
|
At startup, Tellrun registers an English command menu. Use the menu button beside the chat input or type `/` to select a command.
|
|
51
51
|
|
|
52
|
-
| Command | Purpose
|
|
53
|
-
| --------------------- |
|
|
54
|
-
| `/start`, `/help` | Show usage instructions
|
|
55
|
-
| `/cwd` | Show the current working directory
|
|
56
|
-
| `/cwd /absolute/path` | Change the working directory and start a new conversation
|
|
57
|
-
| `/new` | Start a new conversation while keeping the working directory
|
|
58
|
-
| `/
|
|
59
|
-
| `/
|
|
60
|
-
| `/
|
|
61
|
-
| `/
|
|
62
|
-
| `/
|
|
52
|
+
| Command | Purpose |
|
|
53
|
+
| --------------------- | ---------------------------------------------------------------- |
|
|
54
|
+
| `/start`, `/help` | Show usage instructions |
|
|
55
|
+
| `/cwd` | Show the current working directory |
|
|
56
|
+
| `/cwd /absolute/path` | Change the working directory and start a new conversation |
|
|
57
|
+
| `/new` | Start a new conversation while keeping the working directory |
|
|
58
|
+
| `/model` | Show the current selection and choose model and reasoning effort |
|
|
59
|
+
| `/permissions` | Choose the permission mode for subsequent tasks |
|
|
60
|
+
| `/status` | Show connection, directory, model, permissions, and task status |
|
|
61
|
+
| `/last` | Show the latest finished task's status and result |
|
|
62
|
+
| `/stop` | Request that the current task stop and pause new tasks |
|
|
63
|
+
| `/resume` | Accept new tasks again without rerunning an interrupted task |
|
|
63
64
|
|
|
64
65
|
Wait for the current task to finish before changing directories or starting a new conversation. After `/stop`, check the final status, then send `/resume` followed by your next task.
|
|
65
66
|
|
|
67
|
+
In `/status`, `Model` shows the current selection, or `Default` when using the Codex configuration. If the active task uses a different model, `Task model` is also shown.
|
|
68
|
+
|
|
66
69
|
`/permissions` offers the four presets from Codex CLI 0.165.0: Ask for approval (default), Approve for me (Codex automatic review), Full Access (no Codex sandbox or execution approvals), and Read Only (approval required for edits or network access). Full Access remains subject to operating system permissions.
|
|
67
70
|
|
|
68
71
|
Selections apply to subsequently submitted tasks; the current task and its follow-up messages retain their original mode. `/status` shows both modes when they differ. Selections survive service restarts and `/new`; changing the working directory resets the mode to its default. Menus expire after 10 minutes and are invalidated when reopened, on a new conversation, on a directory change, or after a restart. Codex validates the selected mode when starting a task. If it rejects the configuration or returns different settings, the task does not start.
|
package/README.zh-CN.md
CHANGED
|
@@ -55,14 +55,17 @@ tellrun setup
|
|
|
55
55
|
| `/cwd` | 查看当前工作目录 |
|
|
56
56
|
| `/cwd /absolute/path` | 切换工作目录并开始新会话 |
|
|
57
57
|
| `/new` | 开始新会话,保留工作目录 |
|
|
58
|
+
| `/model` | 查看当前选择,通过按钮选择模型和推理强度 |
|
|
58
59
|
| `/permissions` | 选择后续任务的权限模式 |
|
|
59
|
-
| `/status` |
|
|
60
|
+
| `/status` | 查看连接、目录、模型、权限和任务状态 |
|
|
60
61
|
| `/last` | 查看最近已结束任务的状态与结果 |
|
|
61
62
|
| `/stop` | 请求停止当前任务,并暂停接收新任务 |
|
|
62
63
|
| `/resume` | 恢复接收新任务,不会重新执行此前中断的任务 |
|
|
63
64
|
|
|
64
65
|
切换目录或新建会话前,需要等待当前任务结束。使用 `/stop` 后,先检查最终状态,再发送 `/resume` 和新的任务内容。
|
|
65
66
|
|
|
67
|
+
`/status` 的 `Model` 显示当前选择的模型,未选择时显示 `Default`,表示沿用 Codex 配置。执行中的任务使用不同模型时,额外显示 `Task model`。
|
|
68
|
+
|
|
66
69
|
`/permissions` 提供与 Codex CLI 0.165.0 对应的四种模式:Ask for approval(默认,额外权限由你审批)、Approve for me(由 Codex 自动审查)、Full Access(不使用 Codex 沙箱和执行审批)、Read Only(只读,修改或联网时请求审批)。Full Access 仍受系统用户权限约束。
|
|
67
70
|
|
|
68
71
|
选择在下一次提交任务时使用,当前任务及其补充消息保留原权限;`/status` 会在两者不同时分别显示。选择跨服务重启保留,`/new` 沿用选择,切换工作目录恢复默认。菜单有效期为 10 分钟,重新打开、新建会话、切换目录或重启后旧按钮失效。模式受本机 Codex 版本与托管策略限制,启动任务时由 Codex 校验;被拒绝或返回设置不符时不启动任务。
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { createJSONRPCErrorResponse, createJSONRPCSuccessResponse, JSONRPCClient, } from "json-rpc-2.0";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
/** 响应、通知与服务端请求共用边界校验,具体事件内容由 Codex 适配器解释。 */
|
|
5
|
+
const messageSchema = z.object({
|
|
6
|
+
id: z.union([z.number(), z.string()]).optional(),
|
|
7
|
+
method: z.string().optional(),
|
|
8
|
+
params: z.unknown().optional(),
|
|
9
|
+
result: z.unknown().optional(),
|
|
10
|
+
error: z.object({ code: z.number(), message: z.string().optional() }).optional(),
|
|
11
|
+
});
|
|
12
|
+
/** 每条连接独立管理 RPC;关闭只释放连接和等待请求,不取消后台任务。 */
|
|
13
|
+
export function createCodexRpc(socket, handlers = {}) {
|
|
14
|
+
const client = new JSONRPCClient(({ id, method, params }) => write({ id, method, params }));
|
|
15
|
+
/** 查询取消、任务断开和最终清理共用入口,不发送 turn/interrupt。 */
|
|
16
|
+
function close(reason = "Codex connection closed.") {
|
|
17
|
+
client.rejectAllPendingRequests(reason);
|
|
18
|
+
socket.terminate();
|
|
19
|
+
}
|
|
20
|
+
/** 先通知调用方记录连接故障,再释放全部等待,避免把断线当作任务完成。 */
|
|
21
|
+
function fail(text) {
|
|
22
|
+
handlers.onFailure?.(text);
|
|
23
|
+
close(text);
|
|
24
|
+
}
|
|
25
|
+
/** Codex 线上协议省略 jsonrpc 字段;请求、通知与交互应答共用发送入口。 */
|
|
26
|
+
function write(message) {
|
|
27
|
+
try {
|
|
28
|
+
socket.send(JSON.stringify(message), (error) => {
|
|
29
|
+
if (error)
|
|
30
|
+
fail("Codex connection write failed. Task status unknown.");
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
fail("Codex connection write failed. Task status unknown.");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/** 请求超时后结束连接,不自动重发可能已执行的操作。 */
|
|
38
|
+
function request(method, params) {
|
|
39
|
+
return client
|
|
40
|
+
.timeout(30_000, (id) => {
|
|
41
|
+
fail(`Codex ${method} timed out. Not retried.`);
|
|
42
|
+
return createJSONRPCErrorResponse(id, 0, "Codex request timed out.");
|
|
43
|
+
})
|
|
44
|
+
.request(method, params);
|
|
45
|
+
}
|
|
46
|
+
socket.on("error", () => fail("Codex connection failed. Task status unknown."));
|
|
47
|
+
socket.on("close", () => {
|
|
48
|
+
client.rejectAllPendingRequests("Codex connection closed.");
|
|
49
|
+
handlers.onClose?.();
|
|
50
|
+
});
|
|
51
|
+
socket.on("message", (data) => {
|
|
52
|
+
try {
|
|
53
|
+
const message = messageSchema.parse(JSON.parse(data.toString()));
|
|
54
|
+
if (message.method)
|
|
55
|
+
handlers.onMessage?.(message);
|
|
56
|
+
else if (typeof message.id === "number")
|
|
57
|
+
/** 错误来源标记仅供适配器识别;服务端原始错误不能直接转发给用户。 */
|
|
58
|
+
client.receive(message.error
|
|
59
|
+
? createJSONRPCErrorResponse(message.id, message.error.code, message.error.message ?? "", "codex")
|
|
60
|
+
: createJSONRPCSuccessResponse(message.id, message.result));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
fail("Invalid Codex response. Check CLI version and connection.");
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
request,
|
|
68
|
+
write,
|
|
69
|
+
close,
|
|
70
|
+
/** 任务与模型查询使用相同客户端身份;初始化成功后才声明就绪。 */
|
|
71
|
+
async initialize() {
|
|
72
|
+
await request("initialize", {
|
|
73
|
+
clientInfo: {
|
|
74
|
+
name: "tellrun",
|
|
75
|
+
title: "Tellrun",
|
|
76
|
+
version: JSON.parse(readFileSync(new URL("../../package.json", import.meta.url), "utf8"))
|
|
77
|
+
.version,
|
|
78
|
+
},
|
|
79
|
+
capabilities: { experimentalApi: true, requestAttestation: false },
|
|
80
|
+
});
|
|
81
|
+
write({ method: "initialized" });
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=codex-rpc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-rpc.js","sourceRoot":"","sources":["../../src/agents/codex-rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,aAAa,GAEd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6CAA6C;AAC7C,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE;IAChD,MAAM,EAAE,CAAC,CAAC,MAA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