@taptap/cli 2026.11.12 → 2026.11.14
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/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +12 -0
- package/README.md +2 -0
- package/README.zh.md +2 -0
- package/bin/taptap-cli-darwin-amd64 +0 -0
- package/bin/taptap-cli-darwin-arm64 +0 -0
- package/bin/taptap-cli-linux-amd64 +0 -0
- package/bin/taptap-cli-linux-arm64 +0 -0
- package/bin/taptap-cli-linux-riscv64 +0 -0
- package/bin/taptap-cli-windows-amd64.exe +0 -0
- package/bin/taptap-cli-windows-arm64.exe +0 -0
- package/checksums.txt +7 -7
- package/package.json +2 -2
- package/scripts/bot/agent-turn.mjs +39 -10
- package/scripts/bot/agents/cindy-permissions.mjs +32 -0
- package/scripts/bot/agents/cindy-plugin.mjs +157 -0
- package/scripts/bot/agents/cindy.mjs +37 -11
- package/scripts/bot/agents/codex-permissions.mjs +75 -0
- package/scripts/bot/agents/codex-server.mjs +2 -2
- package/scripts/bot/agents/codex.mjs +30 -15
- package/scripts/bot/agents/index.mjs +2 -0
- package/scripts/bot/cindy-plugin/README.md +73 -0
- package/scripts/bot/cindy-plugin/ghost.json +41 -0
- package/scripts/bot/cindy-plugin/main.js +55 -0
- package/scripts/bot/cindy-plugin/node/bridge.cjs +100 -0
- package/scripts/bot/cli.mjs +96 -23
- package/scripts/bot/entry.cjs +7 -1
- package/scripts/bot/listener.mjs +2 -2
- package/scripts/bot/permissions.mjs +97 -0
- package/scripts/bot/store.mjs +4 -0
- package/scripts/bot/turn-policy.mjs +23 -0
- package/scripts/bot/workspace-tools.mjs +120 -0
|
@@ -10,6 +10,7 @@ export { codexCommand, codexOverrides } from "./codex-server.mjs";
|
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { spawn } from "node:child_process";
|
|
12
12
|
import { run } from "../process.mjs";
|
|
13
|
+
import { codexPermissionConfiguration, verifyMcpConfiguration } from "./codex-permissions.mjs";
|
|
13
14
|
|
|
14
15
|
const tools = [
|
|
15
16
|
contextTool,
|
|
@@ -28,7 +29,7 @@ const instructions =
|
|
|
28
29
|
"You are the local TapTap bot. Use the provided trigger. Call taptap_cli_get_content only if you need forum context. Reply in its language with taptap_cli_reply. The ancestor texts are context only. Never expose credentials, call the TapTap CLI through the shell, or choose another destination. If an operation has an uncertain outcome, do not repeat it.";
|
|
29
30
|
async function runTurn({
|
|
30
31
|
workspace,
|
|
31
|
-
|
|
32
|
+
permissions,
|
|
32
33
|
model,
|
|
33
34
|
options,
|
|
34
35
|
signal,
|
|
@@ -101,15 +102,19 @@ async function runTurn({
|
|
|
101
102
|
}
|
|
102
103
|
const timer = setTimeout(() => fail(Error("Codex 轮次超时")), 15 * 60 * 1000);
|
|
103
104
|
try {
|
|
104
|
-
await withCodexServer({ workspace, options,
|
|
105
|
-
|
|
105
|
+
const source = await withCodexServer({ workspace, options, signal }, rpc =>
|
|
106
|
+
rpc("config/read", { cwd: workspace, includeLayers: true }));
|
|
107
|
+
const policy = codexPermissionConfiguration(source, workspace, permissions);
|
|
108
|
+
await withCodexServer({ workspace, options, allowWrite: true, configOverrides: policy.overrides,
|
|
109
|
+
signal, onMessage, onStop: fail }, async (rpc) => {
|
|
110
|
+
await verifyMcpConfiguration(rpc, workspace, policy);
|
|
106
111
|
const params = {
|
|
107
112
|
cwd: workspace,
|
|
108
113
|
approvalPolicy: "never",
|
|
109
|
-
|
|
110
|
-
developerInstructions: instructions
|
|
111
|
-
|
|
112
|
-
|
|
114
|
+
permissions: policy.profile,
|
|
115
|
+
developerInstructions: instructions + (permissions.mode === "read"
|
|
116
|
+
? " Search and read knowledge in the current workspace using native tools. Do not modify files or request elevated permissions."
|
|
117
|
+
: " You may use native tools within the workspace and the owner's configured MCP permissions. Do not request elevated permissions."),
|
|
113
118
|
...(model ? { model: model } : {}),
|
|
114
119
|
};
|
|
115
120
|
const projectId = options?.projectId;
|
|
@@ -125,13 +130,10 @@ async function runTurn({
|
|
|
125
130
|
if (
|
|
126
131
|
t.approvalPolicy !== "never" ||
|
|
127
132
|
path.resolve(t.cwd ?? t.thread.cwd ?? workspace) !== workspace ||
|
|
128
|
-
|
|
129
|
-
(root) => path.resolve(root) !== workspace,
|
|
130
|
-
) ||
|
|
131
|
-
t.sandbox?.type !== (allowWrite ? "workspaceWrite" : "readOnly") ||
|
|
133
|
+
t.activePermissionProfile?.id !== policy.profile ||
|
|
132
134
|
(previousThread && threadId !== previousThread)
|
|
133
135
|
)
|
|
134
|
-
throw Error("Codex
|
|
136
|
+
throw Error("Codex 未应用机器人目录权限,请升级 Codex 后重新连接");
|
|
135
137
|
const inventory = await rpc("mcpServerStatus/list", {
|
|
136
138
|
threadId,
|
|
137
139
|
limit: 100,
|
|
@@ -141,10 +143,10 @@ async function runTurn({
|
|
|
141
143
|
inventory.data?.some(
|
|
142
144
|
(s) =>
|
|
143
145
|
s.runtimeStatus !== "disabled" &&
|
|
144
|
-
|
|
146
|
+
!Object.hasOwn(policy.mcp, s.name),
|
|
145
147
|
)
|
|
146
148
|
)
|
|
147
|
-
throw Error("
|
|
149
|
+
throw Error("Codex 加载了本次连接未配置的 MCP,已停止执行");
|
|
148
150
|
saveThread(threadId);
|
|
149
151
|
if (t.thread.projectId !== projectId) {
|
|
150
152
|
const updated = await rpc("thread/metadata/update", { threadId, projectId });
|
|
@@ -193,6 +195,19 @@ async function checkReady(options) {
|
|
|
193
195
|
if (result.code !== 0) throw Error("请先运行 taptap-cli bot codex-login");
|
|
194
196
|
}
|
|
195
197
|
|
|
198
|
+
async function checkPermissions(workspace, options, permissions, model) {
|
|
199
|
+
const source = await withCodexServer({ workspace, options }, rpc =>
|
|
200
|
+
rpc("config/read", { cwd: workspace, includeLayers: true }));
|
|
201
|
+
const policy = codexPermissionConfiguration(source, workspace, permissions);
|
|
202
|
+
await withCodexServer({ workspace, options, allowWrite: true, configOverrides: policy.overrides }, async rpc => {
|
|
203
|
+
await verifyMcpConfiguration(rpc, workspace, policy);
|
|
204
|
+
const current = await rpc("thread/start", { cwd: workspace, ephemeral: true,
|
|
205
|
+
permissions: policy.profile, approvalPolicy: "never", model });
|
|
206
|
+
if (current.activePermissionProfile?.id !== policy.profile || current.approvalPolicy !== "never")
|
|
207
|
+
throw Error("Codex 不支持机器人目录权限,请升级 Codex 后重新连接");
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
|
|
196
211
|
async function listModels(options, workspace) {
|
|
197
212
|
await checkReady(options);
|
|
198
213
|
return withCodexServer({ options, workspace }, async (rpc) => {
|
|
@@ -237,4 +252,4 @@ async function prepareProject(workspace, options) {
|
|
|
237
252
|
return ensureProject(root, work => withCodexServer(server, work));
|
|
238
253
|
}
|
|
239
254
|
|
|
240
|
-
export const codex = { name: "codex", runTurn, checkReady, listModels, login, prepareProject };
|
|
255
|
+
export const codex = { name: "codex", runTurn, checkReady, checkPermissions, listModels, login, prepareProject };
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
import { codex } from "./codex.mjs";
|
|
5
5
|
|
|
6
6
|
import { cindy } from "./cindy.mjs";
|
|
7
|
+
import { cindyPlugin } from "./cindy-plugin.mjs";
|
|
7
8
|
|
|
8
9
|
const agents = new Map([
|
|
9
10
|
[codex.name, codex],
|
|
10
11
|
[cindy.name, cindy],
|
|
12
|
+
[cindyPlugin.name, cindyPlugin],
|
|
11
13
|
]);
|
|
12
14
|
|
|
13
15
|
export function getAgent(name = codex.name) {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# TapTap Bot — Cindy plugin integration
|
|
2
|
+
|
|
3
|
+
An additive `.cindy` plugin source package shipped with the CLI npm package.
|
|
4
|
+
The existing `--agent cindy` Local Agent connection remains available. This plugin
|
|
5
|
+
uses the public `cindy.tasks` SDK, never private Electron IPC or the Local Agent API.
|
|
6
|
+
|
|
7
|
+
## Connect
|
|
8
|
+
|
|
9
|
+
1. `taptap-cli bot cindy-plugin-source` locates the author source directory.
|
|
10
|
+
2. Use Cindy's official `ghost_forge_pack` / `ghost_forge_install` workflow on this
|
|
11
|
+
directory. Review the own-task and resident Node permissions. No marketplace
|
|
12
|
+
publication is needed. Source inclusion in npm does not mean installation.
|
|
13
|
+
3. In the plugin detail's task settings, choose the working directory and permission
|
|
14
|
+
ceiling. These remain Cindy-owned settings; the CLI cannot overwrite them.
|
|
15
|
+
4. Run `taptap-cli bot models --agent cindy-plugin` and choose an actual model ID.
|
|
16
|
+
5. Select native permissions explicitly. PUBLIC bots allow only `ask` (read-only prompt plus Host approval, not a filesystem sandbox). MEMBERS/PERSONAL allow `ask`, `auto`, or `bypassPermissions`. For example:
|
|
17
|
+
`taptap-cli bot connect --bot <ID> --reply --agent cindy-plugin --model <ID> --cindy-permission ask`.
|
|
18
|
+
Optionally add `--workspace <directory>` to verify that Cindy created the task
|
|
19
|
+
in that exact directory. A mismatch prevents sending; it does not change Cindy.
|
|
20
|
+
6. Forum events become visible tasks titled from the current question; each reply
|
|
21
|
+
chain reuses its task. The CLI provides the authorized original post/parent chain,
|
|
22
|
+
waits for the exact run's completed output and submits through the ordinary
|
|
23
|
+
forum reply API. Forum moderation status still comes from that API.
|
|
24
|
+
|
|
25
|
+
## Permissions and unsupported capabilities
|
|
26
|
+
|
|
27
|
+
`ask`, `auto`, `bypassPermissions` mean Cindy's default approval, automatic review
|
|
28
|
+
and full access. They are not aliases for Codex's workspace-only read/work. Ask/auto
|
|
29
|
+
may wait for approval in Cindy. The plugin never approves on the user's behalf.
|
|
30
|
+
The Host enforces its configured task permission ceiling. Existing task policy,
|
|
31
|
+
model/Harness and working directory are checked before each send; changed tasks
|
|
32
|
+
are not silently reconfigured or replaced.
|
|
33
|
+
|
|
34
|
+
Native tools and MCP use Cindy's own settings and authorization. The public API
|
|
35
|
+
does not guarantee workspace-only access, never-escalate execution or directory-only
|
|
36
|
+
MCP. PUBLIC bots require an explicit ask selection and a read-only workspace policy in every turn. This is a behavioral fallback plus Host approval, not a hard read-only boundary. For enforced file-tool boundaries use Codex read or the client-only link adapter. MEMBERS/PERSONAL require explicit initial
|
|
37
|
+
selection. The CLI checks authoritative scope every turn and during execution;
|
|
38
|
+
changes invalidate the grant and cancel only the current accepted run.
|
|
39
|
+
|
|
40
|
+
The original link mode supports `client-only` and `native` through its public
|
|
41
|
+
toolPolicy API. Native is full access without interactive approval. It does not
|
|
42
|
+
expose a custom task-title API. Neither mode invents unsupported Host parameters.
|
|
43
|
+
|
|
44
|
+
## Verify and transport
|
|
45
|
+
|
|
46
|
+
Use the same onboarding flow as Codex and the Cindy link adapter: choose the
|
|
47
|
+
working directory, model and permissions once, then connect. Existing settings
|
|
48
|
+
are reused. The assistant handles commands and only asks for missing choices or
|
|
49
|
+
Host-required confirmation. Installation is needed only when the plugin is absent.
|
|
50
|
+
After connecting, send a message in the configuration page's **04 测试消息收发**
|
|
51
|
+
and verify the received event and actual reply in that thread. There is no separate
|
|
52
|
+
plugin self-test command or synthetic conversation in the product flow.
|
|
53
|
+
|
|
54
|
+
The Node bridge binds only 127.0.0.1, rejects browser origins and uses an owner-only
|
|
55
|
+
discovery file with a fresh bearer. It forwards only model/capability queries,
|
|
56
|
+
the documented own-task create/get/send/getRun/readMessages/cancel
|
|
57
|
+
operations. TapTap credentials and reply grants never enter Cindy. Only authorized
|
|
58
|
+
forum content enters the task. Stop uses the exact accepted run ID; uncertain sends
|
|
59
|
+
are not automatically repeated. After an abnormal worker crash, verify the old
|
|
60
|
+
process has exited before removing the stale discovery file and restarting.
|
|
61
|
+
|
|
62
|
+
## Host evidence and verification limits
|
|
63
|
+
|
|
64
|
+
Installed Cindy 0.1.133 reports build source
|
|
65
|
+
`95e70d24407638cac83220f46f0751c42017fe1e`, unavailable in the public repository.
|
|
66
|
+
Its shipped manuals and public tag v0.1.133
|
|
67
|
+
(`4a068d08cf9ea6633f6ee48cea800944bf70f746`) agree on the APIs used. The live Local
|
|
68
|
+
Agent capabilities explicitly report nativeReadOnly:false and no task-title method.
|
|
69
|
+
The public tag is not claimed to be the exact installed build. Plugin operations
|
|
70
|
+
are checked at runtime. Local contract/transport tests do not prove installation,
|
|
71
|
+
actual Host model execution or RND forum delivery; report those separately.
|
|
72
|
+
|
|
73
|
+
Every new or continued turn includes its actual working directory, granted mode and MCP restrictions. `bot events` exposes the question title, visible task ID and observed run status. Queued/running does not prove an approval is pending; the hint asks the owner to inspect Cindy without automatically approving. Timeouts cancel only the accepted run and never automatically resend.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 3,
|
|
3
|
+
"id": "taptap-bot-preview",
|
|
4
|
+
"name": "TapTap Bot 插件接入",
|
|
5
|
+
"description": "通过 CLI 接收机器人的论坛事件,在 Cindy 可见任务中处理并回传回复。使用 Cindy 原生审批、工作目录和 MCP,不保证目录隔离;全论坛仅允许接入者明确选择默认审批,配合每轮只读提示词。模型、动手权限和工作目录在插件「配置 → 模型与任务」中设置。接入后回到开发者后台机器人配置页的「测试消息收发」中验证。",
|
|
6
|
+
"whenToUse": "接入 TapTap Bot 到 Cindy 插件任务,查询模型或检查连接能力。",
|
|
7
|
+
"version": "0.2.1",
|
|
8
|
+
"minCindyVersion": "0.1.133",
|
|
9
|
+
"entry": "main.js",
|
|
10
|
+
"launch": "resident",
|
|
11
|
+
"command": "taptap-bot-preview",
|
|
12
|
+
"showTaskPreferences": true,
|
|
13
|
+
"agent": {
|
|
14
|
+
"tasks": true
|
|
15
|
+
},
|
|
16
|
+
"node": {
|
|
17
|
+
"entry": "node/bridge.cjs",
|
|
18
|
+
"protocol": "json-rpc-stdio",
|
|
19
|
+
"lifecycle": "resident"
|
|
20
|
+
},
|
|
21
|
+
"tools": [
|
|
22
|
+
{
|
|
23
|
+
"name": "diagnose",
|
|
24
|
+
"description": "检查 Cindy 插件接口和 TapTap 权限兼容性。只读,不连接论坛。",
|
|
25
|
+
"parameters": {
|
|
26
|
+
"type": "object",
|
|
27
|
+
"properties": {},
|
|
28
|
+
"additionalProperties": false
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "models",
|
|
33
|
+
"description": "列出 Cindy 插件任务真实可用的模型与 Harness,不能根据模型名称猜 Harness。",
|
|
34
|
+
"parameters": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"properties": {},
|
|
37
|
+
"additionalProperties": false
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Copyright (c) 2026 TapTap
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
// Public Cindy plugin SDK only. No private Electron IPC or Local Agent API.
|
|
4
|
+
(() => {
|
|
5
|
+
let bridgeError;
|
|
6
|
+
const gap = "Cindy 使用原生任务审批和 MCP,不保证目录隔离,ask/auto/完全访问不等于 Codex read/work。全论坛仅允许明确选择 ask,使用每轮只读提示词+宿主审批;不是强制只读沙箱。";
|
|
7
|
+
async function node(method, params = {}) {
|
|
8
|
+
const result = await cindy.node.request({ method, params, timeoutMs: 30000 });
|
|
9
|
+
if (!result.ok) throw Error(result.message || "插件 Node 进程不可用");
|
|
10
|
+
return result.result;
|
|
11
|
+
}
|
|
12
|
+
async function capabilities() {
|
|
13
|
+
if (typeof cindy.tasks?.capabilities !== "function") throw Error("请升级到支持插件任务接口的 Cindy");
|
|
14
|
+
const caps = await cindy.tasks.capabilities();
|
|
15
|
+
return { protocol: 1, mode: "cindy-plugin", host: caps, inheritedTaskSettings: true, executionPolicySupported: false,
|
|
16
|
+
supportedScopes: ["PUBLIC", "MEMBERS", "PERSONAL"], message: gap, ...(bridgeError ? { bridgeError } : {}) };
|
|
17
|
+
}
|
|
18
|
+
async function models() {
|
|
19
|
+
const caps = await capabilities();
|
|
20
|
+
if (!caps.host.operations?.includes("models")) throw Error("当前 Cindy 不支持插件模型查询");
|
|
21
|
+
return cindy.tasks.models();
|
|
22
|
+
}
|
|
23
|
+
async function dispatch(method, params, bridge = false) {
|
|
24
|
+
if (method === "capabilities" || method === "diagnose") return capabilities();
|
|
25
|
+
if (method === "models") return models();
|
|
26
|
+
// The authenticated local bridge exposes only the documented own-task API.
|
|
27
|
+
// No private IPC, generic Host calls, directory overrides or silent fallback.
|
|
28
|
+
const operations = { task_create: "create", task_get: "get", task_send: "send",
|
|
29
|
+
task_run: "getRun", task_messages: "readMessages", task_cancel: "cancel" };
|
|
30
|
+
if (bridge && Object.hasOwn(operations, method)) {
|
|
31
|
+
const { host } = await capabilities();
|
|
32
|
+
const operation = operations[method];
|
|
33
|
+
if (!host.operations?.includes(operation)) throw Error("Cindy 不支持插件任务操作:" + operation);
|
|
34
|
+
if (operation === "create" && ["route", "permissionMode", "workingDir", "cwd", "isolatedWorkspace"].some(key => Object.hasOwn(params ?? {}, key)))
|
|
35
|
+
throw Error("请在插件「配置 → 模型与任务」设置模型、动手权限和工作目录;创建任务不接受覆盖参数");
|
|
36
|
+
return cindy.tasks[operation](params);
|
|
37
|
+
}
|
|
38
|
+
throw Error("不支持的插件方法");
|
|
39
|
+
}
|
|
40
|
+
cindy.onHostMessage(async msg => {
|
|
41
|
+
if (msg.type === "event" && msg.name === "node-notification" && msg.method === "bridge/request") {
|
|
42
|
+
const { id, method, params } = msg.params;
|
|
43
|
+
try { await node("bridge/result", { id, result: await dispatch(method, params, true) }); }
|
|
44
|
+
catch (error) { await node("bridge/result", { id, error: { message: error.message, code: error.code || "CINDY_PLUGIN_FAILED" } }); }
|
|
45
|
+
} else if (msg.type === "tool-call") {
|
|
46
|
+
try {
|
|
47
|
+
const result = await dispatch(msg.tool, msg.args ?? {});
|
|
48
|
+
cindy.send({ type: "tool-result", callId: msg.callId, ok: true, result });
|
|
49
|
+
} catch (error) {
|
|
50
|
+
cindy.send({ type: "tool-result", callId: msg.callId, ok: false, errorCode: "TAPTAP_PLUGIN_FAILED", message: error.message });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
node("bridge/start").catch(error => { bridgeError = error.message; });
|
|
55
|
+
})();
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Copyright (c) 2026 TapTap
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
const http = require("node:http");
|
|
4
|
+
const fs = require("node:fs");
|
|
5
|
+
const path = require("node:path");
|
|
6
|
+
const os = require("node:os");
|
|
7
|
+
const crypto = require("node:crypto");
|
|
8
|
+
const readline = require("node:readline");
|
|
9
|
+
|
|
10
|
+
const root = path.join(process.env.TAPTAP_CLI_CONFIG_DIR || path.join(os.homedir(), ".taptap-cli"), "bot", "cindy-plugin");
|
|
11
|
+
const discovery = path.join(root, "discovery.json");
|
|
12
|
+
const token = crypto.randomBytes(32).toString("hex");
|
|
13
|
+
const instance = crypto.randomUUID();
|
|
14
|
+
const pending = new Map();
|
|
15
|
+
let server, starting, discoveryFd;
|
|
16
|
+
const emit = value => process.stdout.write(JSON.stringify(value) + "\n");
|
|
17
|
+
const json = (response, status, value) => {
|
|
18
|
+
response.writeHead(status, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
19
|
+
response.end(JSON.stringify(value));
|
|
20
|
+
};
|
|
21
|
+
async function start() {
|
|
22
|
+
if (starting) return starting;
|
|
23
|
+
starting = (async () => {
|
|
24
|
+
fs.mkdirSync(root, { recursive: true, mode: 0o700 });
|
|
25
|
+
if (fs.lstatSync(root).isSymbolicLink()) throw Error("插件发现目录不能是软链接");
|
|
26
|
+
// Never replace a running bridge or race another simultaneous startup.
|
|
27
|
+
try { discoveryFd = fs.openSync(discovery, "wx", 0o600); }
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (error.code === "EEXIST") throw Error("插件发现文件已存在,请先停用旧插件;若曾异常退出,确认旧进程退出后移除 discovery.json 再重试");
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
server = http.createServer(async (request, response) => {
|
|
33
|
+
if (request.method !== "POST" || request.url !== "/rpc" || request.headers.origin ||
|
|
34
|
+
request.headers.host !== "127.0.0.1:" + server.address().port || request.headers.authorization !== "Bearer " + token)
|
|
35
|
+
return json(response, 403, { error: { code: "FORBIDDEN", message: "拒绝未授权的插件接入" } });
|
|
36
|
+
if (pending.size >= 8) return json(response, 429, { error: { code: "BUSY", message: "插件请求过多,请稍后重试" } });
|
|
37
|
+
try {
|
|
38
|
+
const chunks = [];
|
|
39
|
+
let bytes = 0;
|
|
40
|
+
for await (const chunk of request) {
|
|
41
|
+
bytes += chunk.length;
|
|
42
|
+
if (bytes > 262144) return json(response, 413, { error: { code: "TOO_LARGE", message: "请求过大" } });
|
|
43
|
+
chunks.push(chunk);
|
|
44
|
+
}
|
|
45
|
+
const message = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
46
|
+
if (pending.size >= 8) return json(response, 429, { error: { code: "BUSY", message: "插件请求过多,请稍后重试" } });
|
|
47
|
+
if (message.instance !== instance || !["capabilities", "models", "task_create", "task_get", "task_send", "task_run", "task_messages", "task_cancel"].includes(message.method))
|
|
48
|
+
return json(response, 400, { error: { code: "INVALID_REQUEST", message: "不支持的插件请求" } });
|
|
49
|
+
const id = crypto.randomUUID();
|
|
50
|
+
const timeout = setTimeout(() => {
|
|
51
|
+
pending.delete(id);
|
|
52
|
+
if (!response.destroyed) json(response, 504, { error: { code: "OUTCOME_UNKNOWN", message: "插件处理结果不明,请保留原请求键核对" } });
|
|
53
|
+
}, 25000);
|
|
54
|
+
pending.set(id, { response, timeout });
|
|
55
|
+
response.on("close", () => { clearTimeout(timeout); pending.delete(id); });
|
|
56
|
+
emit({ jsonrpc: "2.0", method: "bridge/request", params: { id, method: message.method, params: message.params ?? {} } });
|
|
57
|
+
} catch { if (!response.headersSent) json(response, 400, { error: { code: "INVALID_REQUEST", message: "插件请求格式无效" } }); }
|
|
58
|
+
});
|
|
59
|
+
await new Promise((resolve, reject) => { server.once("error", reject); server.listen(0, "127.0.0.1", resolve); });
|
|
60
|
+
fs.writeFileSync(discoveryFd, JSON.stringify({ protocol: 1, instance, token, pid: process.pid, port: server.address().port }));
|
|
61
|
+
return { protocol: 1, discovery, instance };
|
|
62
|
+
})().catch(error => { stop(); throw error; });
|
|
63
|
+
return starting;
|
|
64
|
+
}
|
|
65
|
+
const lines = readline.createInterface({ input: process.stdin });
|
|
66
|
+
lines.on("line", async line => {
|
|
67
|
+
let request;
|
|
68
|
+
try {
|
|
69
|
+
request = JSON.parse(line);
|
|
70
|
+
if (request.id == null) return;
|
|
71
|
+
let result;
|
|
72
|
+
if (request.method === "bridge/start") result = await start();
|
|
73
|
+
else if (request.method === "bridge/result") {
|
|
74
|
+
const item = pending.get(request.params?.id);
|
|
75
|
+
if (item) {
|
|
76
|
+
clearTimeout(item.timeout);
|
|
77
|
+
pending.delete(request.params.id);
|
|
78
|
+
json(item.response, request.params.error ? 422 : 200,
|
|
79
|
+
request.params.error ? { error: request.params.error } : { result: request.params.result });
|
|
80
|
+
}
|
|
81
|
+
result = { accepted: Boolean(item) };
|
|
82
|
+
} else throw Error("不支持的 Node 方法");
|
|
83
|
+
emit({ jsonrpc: "2.0", id: request.id, result });
|
|
84
|
+
} catch (error) { if (request?.id != null) emit({ jsonrpc: "2.0", id: request.id, error: { code: -32000, message: error.message } }); }
|
|
85
|
+
});
|
|
86
|
+
function stop() {
|
|
87
|
+
for (const { response, timeout } of pending.values()) { clearTimeout(timeout); response.destroy(); }
|
|
88
|
+
pending.clear();
|
|
89
|
+
server?.close();
|
|
90
|
+
if (discoveryFd !== undefined) {
|
|
91
|
+
try {
|
|
92
|
+
if (fs.lstatSync(discovery).ino === fs.fstatSync(discoveryFd).ino) fs.unlinkSync(discovery);
|
|
93
|
+
} catch {}
|
|
94
|
+
fs.closeSync(discoveryFd);
|
|
95
|
+
discoveryFd = undefined;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
lines.once("close", stop);
|
|
99
|
+
process.once("exit", stop);
|
|
100
|
+
process.once("SIGTERM", () => { stop(); process.exit(0); });
|
package/scripts/bot/cli.mjs
CHANGED
|
@@ -12,24 +12,37 @@ import { login, loginBinding, assertLoginBinding, tap, nativeCli, servers } from
|
|
|
12
12
|
import { run } from "./process.mjs";
|
|
13
13
|
import { getAgent } from "./agents/index.mjs";
|
|
14
14
|
import { selectModel, saveModel } from "./models.mjs";
|
|
15
|
+
import { connectionScope, selectPermissions, permissionNotice } from "./permissions.mjs";
|
|
16
|
+
import { cindyModes } from "./agents/cindy-permissions.mjs";
|
|
15
17
|
|
|
16
18
|
const help = `taptap-cli bot — TapTap 机器人长连接
|
|
17
19
|
taptap-cli bot connect --bot 2 选择机器人并登录
|
|
18
20
|
taptap-cli bot connect --bot 2 --reply --agent codex --model 模型ID --workspace . 接收事件并用 Codex 回复
|
|
19
21
|
taptap-cli bot connect --bot 2 --reply --agent cindy --model 模型ID 在 Cindy 可见会话里处理论坛 @
|
|
20
|
-
taptap-cli bot
|
|
22
|
+
taptap-cli bot connect --bot 2 --reply --agent cindy-plugin 沿用插件配置创建任务回复
|
|
23
|
+
taptap-cli bot models --agent codex 列出模型,向用户展示名称供选择
|
|
21
24
|
taptap-cli bot models --agent cindy 列出 Cindy 可用模型
|
|
25
|
+
taptap-cli bot models --agent cindy-plugin 列出独立插件模式的模型与 Harness
|
|
26
|
+
taptap-cli bot cindy-plugin-source 查看随 npm 分发的插件源码位置
|
|
22
27
|
taptap-cli bot cindy-login 允许 TapTap Bot 连接本机 Cindy
|
|
23
28
|
taptap-cli bot codex-login 授权本机 Codex
|
|
24
|
-
taptap-cli bot
|
|
29
|
+
taptap-cli bot permissions --bot 2 查询服务端确认的使用范围与可选权限
|
|
25
30
|
taptap-cli bot status 所有本地实例
|
|
26
31
|
taptap-cli bot events --bot 2 [--limit 10] 最近事件及回复回执
|
|
27
32
|
taptap-cli bot stop --bot 2 停止指定实例
|
|
28
33
|
--bot-name 昵称:为未返回昵称的机器人指定 Codex 项目名称中的昵称。
|
|
29
34
|
选项:--profile NAME、--env production|rnd、--cli 绝对路径、--personal、
|
|
30
|
-
--cindy-keepalive-minutes 分钟(默认 30)、--replace-epoch N、--foreground、--codex 可执行文件、--model 模型ID、--
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
--cindy-keepalive-minutes 分钟(默认 30)、--replace-epoch N、--foreground、--codex 可执行文件、--model 模型ID、--permissions read|work
|
|
36
|
+
Codex 首次连接:选定会话目录后确认 --permissions read(只读)或 work(修改目录文件、执行命令及联网)。
|
|
37
|
+
全论坛社区机器人固定只读。指定成员共用接入者电脑;个人机器人仅本人 @ 进入自己的连接。
|
|
38
|
+
社区机器人仅加载当前会话目录 .codex/config.toml 中的 MCP,不继承全局 MCP;需要时请在当前目录配置。
|
|
39
|
+
运行中不弹审批,范围外操作拒绝。--allow-workspace-write 是 --permissions work 的兼容别名。
|
|
40
|
+
Cindy 链接版:--cindy-permission client-only(默认,可搜索和读取会话目录)或 native(原生工具与 MCP,完全访问且不弹审批)。
|
|
41
|
+
Cindy 插件版:模型、动手权限和工作目录均在插件「配置 → 模型与任务」中设置;新任务直接继承,已有会话沿用原任务配置。
|
|
42
|
+
Cindy 插件版 connect 兼容 --model、--cindy-permission 和 --workspace,但会提示并忽略这些参数。
|
|
43
|
+
Cindy 原生工具和 MCP 不保证目录隔离,不能用 --permissions read/work 冒充。全论坛可用链接版 client-only,或明确选择插件版 ask(只读提示词+宿主审批,不是目录沙箱)。
|
|
44
|
+
Codex 和 Cindy 链接版首次 connect --reply 请加 --model 用户确认的模型ID。后续沿用已保存模型。
|
|
45
|
+
Codex 和 Cindy 链接版换模型:先 stop --bot ID,再 connect --bot ID --reply --agent 名称 --model 新模型ID。
|
|
33
46
|
共享机器人签发结果不明时,请先核对绑定,再用 connect --retry-issue 确认重新签发。
|
|
34
47
|
RND 使用与环境匹配的 CLI 构建。--personal 用于论坛个人绑定的续期。
|
|
35
48
|
`;
|
|
@@ -56,8 +69,8 @@ function config(v, requireBot = true) {
|
|
|
56
69
|
throw Error("环境或 profile 无效");
|
|
57
70
|
if (env === "rnd" && !v.cli && requireBot === false)
|
|
58
71
|
throw Error("RND 登录需要 --cli 对应构建");
|
|
59
|
-
if (v.agent
|
|
60
|
-
throw Error("Cindy
|
|
72
|
+
if (cindyModes(v.agent).length && (v.permissions || v["allow-workspace-write"] || v.codex))
|
|
73
|
+
throw Error("Cindy 不支持 Codex read/work 配置,请使用 --cindy-permission 并核对宿主能力");
|
|
61
74
|
const minutes = v["cindy-keepalive-minutes"];
|
|
62
75
|
if (
|
|
63
76
|
minutes !== undefined &&
|
|
@@ -82,13 +95,15 @@ function config(v, requireBot = true) {
|
|
|
82
95
|
workspace,
|
|
83
96
|
reply: !!v.reply,
|
|
84
97
|
write: !!v["allow-workspace-write"],
|
|
98
|
+
permissionMode: v.permissions,
|
|
99
|
+
cindyPermission: v["cindy-permission"],
|
|
85
100
|
model: v.model,
|
|
86
101
|
replace: v["replace-epoch"],
|
|
87
102
|
personal: !!v.personal,
|
|
88
103
|
cli: v.cli && realpathSync(v.cli),
|
|
89
104
|
agent: v.reply ? getAgent(v.agent).name : undefined,
|
|
90
105
|
agentOptions:
|
|
91
|
-
v.agent
|
|
106
|
+
cindyModes(v.agent).length
|
|
92
107
|
? {
|
|
93
108
|
keepAliveMinutes:
|
|
94
109
|
minutes === undefined ? undefined : Number(minutes),
|
|
@@ -137,8 +152,10 @@ function activeAgent(row) {
|
|
|
137
152
|
const config = JSON.parse(row.config);
|
|
138
153
|
return config.reply ? getAgent(config.agent).name : null;
|
|
139
154
|
}
|
|
140
|
-
function runningSummary(row, requestedAgent, requestedModel) {
|
|
141
|
-
if (activeAgent(row) &&
|
|
155
|
+
function runningSummary(row, requestedAgent, requestedModel, requestedPermissions, workspace) {
|
|
156
|
+
if (activeAgent(row) === "cindy-plugin" && JSON.parse(row.config).permissions?.source !== "plugin")
|
|
157
|
+
throw Error("当前 Cindy 插件监听仍使用旧参数,请先 stop 再 connect,以沿用插件配置");
|
|
158
|
+
if (activeAgent(row) && activeAgent(row) !== "cindy-plugin" && !JSON.parse(row.config).model)
|
|
142
159
|
throw Error("当前监听尚未确认模型,请先 stop,再让用户确认模型后带 --model 重新 connect");
|
|
143
160
|
if (requestedAgent && activeAgent(row) !== requestedAgent)
|
|
144
161
|
throw Error(
|
|
@@ -146,13 +163,22 @@ function runningSummary(row, requestedAgent, requestedModel) {
|
|
|
146
163
|
);
|
|
147
164
|
if (requestedModel !== undefined && JSON.parse(row.config).model !== requestedModel)
|
|
148
165
|
throw Error("监听器正在使用其他模型,请先 stop 当前实例,再带 --model 重新 connect");
|
|
166
|
+
const current = JSON.parse(row.config);
|
|
167
|
+
if ((requestedPermissions && current.permissions?.mode !== requestedPermissions) ||
|
|
168
|
+
(workspace && current.workspace !== workspace))
|
|
169
|
+
throw Error("监听器正在使用其他目录或权限,请先 stop 再重新 connect");
|
|
149
170
|
return summary(row);
|
|
150
171
|
}
|
|
151
172
|
function summary(row) {
|
|
173
|
+
const config = JSON.parse(row.config);
|
|
174
|
+
const plugin = activeAgent(row) === "cindy-plugin" && config.permissions?.source === "plugin";
|
|
175
|
+
const settings = plugin && config.pluginTask?.permissions.scope === config.permissions.scope ? config.pluginTask : null;
|
|
152
176
|
return {
|
|
153
177
|
instance: row.id,
|
|
154
178
|
agent: activeAgent(row),
|
|
155
|
-
model:
|
|
179
|
+
model: plugin ? settings?.resolvedConfig.model ?? null : config.model ?? null,
|
|
180
|
+
permissions: plugin ? settings?.permissions ?? config.permissions : config.permissions ?? null,
|
|
181
|
+
...(plugin ? { settingsSource: "plugin", taskSettings: settings } : {}),
|
|
156
182
|
status: alive(row.pid)
|
|
157
183
|
? row.status
|
|
158
184
|
: row.status === "failed"
|
|
@@ -192,7 +218,9 @@ export async function main(argv) {
|
|
|
192
218
|
"agent",
|
|
193
219
|
"cindy-discovery",
|
|
194
220
|
"cindy-keepalive-minutes",
|
|
221
|
+
"cindy-permission",
|
|
195
222
|
"model",
|
|
223
|
+
"permissions",
|
|
196
224
|
"limit",
|
|
197
225
|
"replace-epoch",
|
|
198
226
|
];
|
|
@@ -211,14 +239,26 @@ export async function main(argv) {
|
|
|
211
239
|
]),
|
|
212
240
|
});
|
|
213
241
|
if (v["bot-name"] !== undefined &&
|
|
214
|
-
(cmd !== "connect" || !v.reply || v.agent
|
|
242
|
+
(cmd !== "connect" || !v.reply || cindyModes(v.agent).length || v.workspace || !v["bot-name"].trim()))
|
|
215
243
|
throw Error("--bot-name 仅用于 Codex 的默认项目,请提供机器人昵称");
|
|
216
244
|
if (v["retry-issue"] && (cmd !== "connect" || v.personal || v["replace-epoch"]))
|
|
217
245
|
throw Error("--retry-issue 仅适用于共享机器人的 connect");
|
|
246
|
+
if (cmd === "connect" && v.agent === "cindy-plugin" &&
|
|
247
|
+
["model", "cindy-permission", "workspace"].some(key => v[key] !== undefined)) {
|
|
248
|
+
console.error("Cindy 插件版使用插件「配置 → 模型与任务」中的模型、动手权限和工作目录,本次忽略 CLI 的 --model、--cindy-permission 和 --workspace 参数。");
|
|
249
|
+
delete v.model;
|
|
250
|
+
delete v["cindy-permission"];
|
|
251
|
+
delete v.workspace;
|
|
252
|
+
}
|
|
218
253
|
if (v.model !== undefined && (cmd !== "connect" || !v.reply || !v.model.trim()))
|
|
219
254
|
throw Error("--model 需要与 connect --reply 一起使用,请提供用户确认的模型 ID");
|
|
255
|
+
if (v.permissions !== undefined && (cmd !== "connect" || !v.reply ||
|
|
256
|
+
!["read", "work"].includes(v.permissions) || (v["allow-workspace-write"] && v.permissions !== "work")))
|
|
257
|
+
throw Error("--permissions 需要 connect --reply,值为 read 或 work,且不能与写入选项冲突");
|
|
258
|
+
if (v["cindy-permission"] !== undefined && (cmd !== "connect" || !v.reply || !cindyModes(v.agent).includes(v["cindy-permission"])))
|
|
259
|
+
throw Error("--cindy-permission 需要 connect --reply;cindy 使用 client-only/native,cindy-plugin 使用 ask/auto/bypassPermissions");
|
|
220
260
|
if (cmd === "models") {
|
|
221
|
-
if (!v.agent) throw Error("请使用 models --agent codex 或
|
|
261
|
+
if (!v.agent) throw Error("请使用 models --agent codex、cindy 或 cindy-plugin");
|
|
222
262
|
const agent = getAgent(v.agent);
|
|
223
263
|
const options = {
|
|
224
264
|
executable: v.codex && realpathSync(v.codex),
|
|
@@ -227,8 +267,10 @@ export async function main(argv) {
|
|
|
227
267
|
const workspace = v.workspace ? realpathSync(v.workspace) : process.cwd();
|
|
228
268
|
return output({ agent: agent.name, models: await agent.listModels(options, workspace) });
|
|
229
269
|
}
|
|
230
|
-
if (v.agent !== undefined && (cmd !== "connect" || !v.reply))
|
|
270
|
+
if (v.agent !== undefined && (cmd !== "permissions" && (cmd !== "connect" || !v.reply)))
|
|
231
271
|
throw Error("--agent 需要与 connect --reply 一起使用");
|
|
272
|
+
if (cmd === "cindy-plugin-source") return output({ source: fileURLToPath(new URL("./cindy-plugin/", import.meta.url)),
|
|
273
|
+
status: "local-development", supportedScopes: ["PUBLIC", "MEMBERS", "PERSONAL"], runtimeVerified: false });
|
|
232
274
|
if (cmd === "cindy-login")
|
|
233
275
|
return getAgent("cindy").login({ discovery: v["cindy-discovery"] });
|
|
234
276
|
if (cmd === "codex-login") {
|
|
@@ -244,6 +286,23 @@ export async function main(argv) {
|
|
|
244
286
|
}
|
|
245
287
|
return;
|
|
246
288
|
}
|
|
289
|
+
if (cmd === "permissions") {
|
|
290
|
+
const c = config(v);
|
|
291
|
+
await login(c);
|
|
292
|
+
c.loginBinding = await loginBinding(c);
|
|
293
|
+
const scope = await connectionScope(c);
|
|
294
|
+
if (v.agent && v.agent !== "codex") {
|
|
295
|
+
const agent = getAgent(v.agent);
|
|
296
|
+
const modes = scope === "PUBLIC" ? (v.agent === "cindy" ? ["client-only"] : ["ask"]) : cindyModes(v.agent);
|
|
297
|
+
return output({ agent: v.agent, connection_scope: scope,
|
|
298
|
+
modes,
|
|
299
|
+
notice: "Cindy 原生权限不等于 Codex read/work;原生工具与 MCP 不保证仅访问会话目录。",
|
|
300
|
+
choices: modes.map(mode => ({ mode, notice: agent.permissionNotice({ scope, mode }) })) });
|
|
301
|
+
}
|
|
302
|
+
return output({ connection_scope: scope, modes: scope === "PUBLIC" ? ["read"] : ["read", "work"],
|
|
303
|
+
default: "read", notice: permissionNotice({ scope, mode: "read" }),
|
|
304
|
+
work_notice: scope === "PUBLIC" ? null : permissionNotice({ scope, mode: "work" }) });
|
|
305
|
+
}
|
|
247
306
|
const db = store();
|
|
248
307
|
try {
|
|
249
308
|
if (cmd === "status")
|
|
@@ -263,7 +322,7 @@ export async function main(argv) {
|
|
|
263
322
|
return output(
|
|
264
323
|
db
|
|
265
324
|
.prepare(
|
|
266
|
-
"SELECT frame,at,ack,phase,reply,visibleSession FROM events WHERE id=? ORDER BY rowid DESC LIMIT ?",
|
|
325
|
+
"SELECT frame,at,ack,phase,reply,visibleSession,title,progress FROM events WHERE id=? ORDER BY rowid DESC LIMIT ?",
|
|
267
326
|
)
|
|
268
327
|
.all(inboxId(id, saved), limit)
|
|
269
328
|
.map((r) => {
|
|
@@ -273,6 +332,8 @@ export async function main(argv) {
|
|
|
273
332
|
event: data.event.eventId,
|
|
274
333
|
source: data.event.sourceId,
|
|
275
334
|
body: data.content?.current?.body,
|
|
335
|
+
...(r.title ? { title: r.title } : {}),
|
|
336
|
+
...(r.progress ? { progress: JSON.parse(r.progress) } : {}),
|
|
276
337
|
...(r.visibleSession ? { cindySessionId: r.visibleSession } : {}),
|
|
277
338
|
ack: !!r.ack,
|
|
278
339
|
phase: r.phase,
|
|
@@ -303,22 +364,34 @@ export async function main(argv) {
|
|
|
303
364
|
if (cmd !== "connect") throw Error("未知命令,请运行 taptap-cli bot --help");
|
|
304
365
|
if (alive(row?.pid)) {
|
|
305
366
|
await assertLoginBinding(JSON.parse(row.config));
|
|
306
|
-
return output(runningSummary(row, c.agent, c.model));
|
|
367
|
+
return output(runningSummary(row, c.agent, c.model, c.cindyPermission ?? c.permissionMode ?? (c.write ? "work" : undefined), c.workspace));
|
|
307
368
|
}
|
|
308
369
|
if (c.env === "rnd" && !c.cli) throw Error("RND 需要 --cli 指定 RND 构建");
|
|
309
370
|
const listen = await loadListener();
|
|
310
371
|
await login(c);
|
|
311
372
|
c.loginBinding = await loginBinding(c);
|
|
312
|
-
if (!c.workspace) {
|
|
373
|
+
if (!c.workspace && c.agent !== "cindy-plugin") {
|
|
313
374
|
if (c.agent === "codex") c.nickname = v["bot-name"]?.trim() || await botNickname(c, row && JSON.parse(row.config));
|
|
314
375
|
Object.assign(c, defaultWorkspace(id, c.loginBinding, c));
|
|
315
376
|
}
|
|
316
377
|
if (c.reply) {
|
|
317
378
|
const agent = getAgent(c.agent);
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
379
|
+
if (agent.name === "codex" || agent.selectPermissions) {
|
|
380
|
+
const scope = await connectionScope(c);
|
|
381
|
+
c.permissions = (agent.selectPermissions ?? selectPermissions)(c, scope, row && JSON.parse(row.config));
|
|
382
|
+
c.personal = scope === "PERSONAL";
|
|
383
|
+
delete c.permissionMode;
|
|
384
|
+
delete c.cindyPermission;
|
|
385
|
+
c.write = false;
|
|
386
|
+
console.error((agent.permissionNotice ?? permissionNotice)(c.permissions));
|
|
387
|
+
}
|
|
388
|
+
if (agent.name !== "cindy-plugin") {
|
|
389
|
+
c.model = selectModel(db, id, c, row && JSON.parse(row.config));
|
|
390
|
+
const models = await agent.listModels(c.agentOptions, c.workspace);
|
|
391
|
+
if (!models.some(model => model.id === c.model))
|
|
392
|
+
throw Error("所选模型不可用:" + c.model + "。请运行 bot models --agent " + agent.name + ",让用户重新确认后使用 --model");
|
|
393
|
+
}
|
|
394
|
+
if (agent.checkPermissions) await agent.checkPermissions(c.workspace, c.agentOptions, c.permissions, c.model);
|
|
322
395
|
|
|
323
396
|
if (agent.prepareProject) {
|
|
324
397
|
const projectId = await agent.prepareProject(c.workspace, c.agentOptions);
|
|
@@ -341,7 +414,7 @@ export async function main(argv) {
|
|
|
341
414
|
if (alive(row?.pid)) {
|
|
342
415
|
if (JSON.parse(row.config).loginBinding !== c.loginBinding)
|
|
343
416
|
throw Error("已有不同账号的实例,请先 stop");
|
|
344
|
-
const result = runningSummary(row, c.agent, c.model);
|
|
417
|
+
const result = runningSummary(row, c.agent, c.model, c.permissions?.mode, c.workspace);
|
|
345
418
|
db.exec("COMMIT");
|
|
346
419
|
return output(result);
|
|
347
420
|
}
|
|
@@ -359,7 +432,7 @@ export async function main(argv) {
|
|
|
359
432
|
`INSERT INTO instances(id,config,status,pid,launch) VALUES(?,?,'starting',?,?) ON CONFLICT(id) DO UPDATE SET
|
|
360
433
|
config=excluded.config,pid=excluded.pid,launch=excluded.launch,status='starting',reason=NULL,stop=0`,
|
|
361
434
|
).run(id, JSON.stringify(c), process.pid, ticket);
|
|
362
|
-
if (c.reply) saveModel(db, id, c);
|
|
435
|
+
if (c.reply && c.agent !== "cindy-plugin") saveModel(db, id, c);
|
|
363
436
|
db.exec("COMMIT");
|
|
364
437
|
} catch (e) {
|
|
365
438
|
db.exec("ROLLBACK");
|