tellrun 1.3.2 → 1.3.3
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 +12 -11
- package/README.zh-CN.md +1 -0
- 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 +33 -4
- 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 +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,17 +49,18 @@ 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, conversation, directory, 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
|
|
package/README.zh-CN.md
CHANGED
|
@@ -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,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC7B,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QA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