personal-bot 0.3.6 → 0.4.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -8
- package/README.zh-CN.md +5 -8
- package/bin/pbot-pi-acp.mjs +1 -1
- package/docs/README.md +1 -1
- package/docs/architecture/design.md +2 -2
- package/docs/architecture/extensibility.md +1 -1
- package/docs/architecture/model-context.md +1 -2
- package/docs/guides/capabilities.md +4 -8
- package/docs/guides/cross-harness-workers.md +4 -4
- package/docs/guides/history.md +1 -3
- package/docs/guides/workspace-configuration.md +4 -4
- package/docs/hosts/claude-code.md +2 -2
- package/docs/hosts/codex-qoder.md +1 -1
- package/lib/antigravity-plugin/bin/pbot-pi-acp.mjs +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.d.ts +1 -1
- package/lib/antigravity-plugin/lib/extension/acp/member.js +11 -10
- package/lib/antigravity-plugin/lib/extension/acp-worker.js +348 -203
- package/lib/antigravity-plugin/lib/extension/cli.js +574 -549
- package/lib/antigravity-plugin/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/antigravity-plugin/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/antigravity-plugin/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/antigravity-plugin/lib/extension/mcp.js +462 -326
- package/lib/antigravity-plugin/lib/integrations/agent-resources.js +2 -2
- package/lib/antigravity-plugin/lib/model/acp.d.ts +29 -35
- package/lib/antigravity-plugin/lib/model/agent.d.ts +33 -17
- package/lib/antigravity-plugin/lib/model/agent.js +0 -1
- package/lib/antigravity-plugin/lib/storage/acp-files.d.ts +5 -8
- package/lib/antigravity-plugin/lib/storage/acp-files.js +34 -40
- package/lib/antigravity-plugin/lib/storage/agent-files.d.ts +19 -10
- package/lib/antigravity-plugin/lib/storage/agent-files.js +147 -43
- package/lib/antigravity-plugin/package.json +1 -1
- package/lib/antigravity-plugin/plugin.json +1 -1
- package/lib/antigravity-plugin/resources/agents/coordinator.md +3 -7
- package/lib/antigravity-plugin/resources/agents/general-purpose.md +3 -3
- package/lib/antigravity-plugin/resources/prompts/plugin-coordinator.md +1 -2
- package/lib/antigravity-plugin/resources/prompts/workspace.md +12 -16
- package/lib/antigravity-plugin/resources/skills/provider-connections/SKILL.md +7 -6
- package/lib/antigravity-plugin/resources/templates/workspace-agents.md +0 -4
- package/lib/antigravity-plugin/skills/pbot/SKILL.md +14 -6
- package/lib/antigravity-plugin/skills/provider-connections/SKILL.md +7 -6
- package/lib/codex-marketplace/plugins/personal-bot/.codex-plugin/plugin.json +1 -1
- package/lib/codex-marketplace/plugins/personal-bot/.mcp.json +2 -2
- package/lib/codex-marketplace/plugins/personal-bot/hooks/hooks.json +3 -3
- package/lib/codex-marketplace/plugins/personal-bot/skills/pbot/SKILL.md +2 -2
- package/lib/extension/acp/member.d.ts +1 -1
- package/lib/extension/acp/member.js +11 -10
- package/lib/extension/acp/worker.js +34 -33
- package/lib/extension/acp-worker.js +348 -203
- package/lib/extension/cli.js +574 -549
- package/lib/extension/hosts/dsh/acp-member.js +1 -1
- package/lib/extension/hosts/dsh/command.js +1 -1
- package/lib/extension/hosts/dsh/workspace.js +1 -3
- package/lib/extension/hosts/pi/acp-member.js +3 -4
- package/lib/extension/hosts/plugin-runtime.js +0 -11
- package/lib/extension/mcp/tool-contract.d.ts +8 -50
- package/lib/extension/mcp/tool-contract.js +48 -62
- package/lib/extension/mcp/workers.d.ts +13 -27
- package/lib/extension/mcp/workers.js +60 -25
- package/lib/extension/mcp.js +462 -326
- package/lib/integrations/acp/agents.d.ts +2 -3
- package/lib/integrations/acp/agents.js +22 -22
- package/lib/integrations/acp/harnesses/claude.js +1 -1
- package/lib/integrations/agent-resources.js +2 -2
- package/lib/model/acp.d.ts +29 -35
- package/lib/model/agent.d.ts +33 -17
- package/lib/model/agent.js +0 -1
- package/lib/qoder-plugin/.mcp.json +2 -2
- package/lib/qoder-plugin/.qoder-plugin/plugin.json +1 -1
- package/lib/qoder-plugin/hooks/hooks.json +3 -3
- package/lib/qoder-plugin/skills/pbot/SKILL.md +2 -2
- package/lib/services/agents/acp-run.d.ts +6 -4
- package/lib/services/agents/acp-run.js +62 -43
- package/lib/services/agents/agent-run.d.ts +10 -6
- package/lib/services/agents/agent-run.js +142 -65
- package/lib/services/agents/agent-service.d.ts +3 -21
- package/lib/services/agents/agent-service.js +180 -126
- package/lib/storage/acp-files.d.ts +5 -8
- package/lib/storage/acp-files.js +34 -40
- package/lib/storage/agent-files.d.ts +19 -10
- package/lib/storage/agent-files.js +147 -43
- package/lib/tools/history/contract.js +12 -12
- package/package.json +1 -1
- package/resources/agents/coordinator.md +3 -7
- package/resources/agents/general-purpose.md +3 -3
- package/resources/antigravity/skills/pbot/SKILL.md +14 -6
- package/resources/claude/skills/pbot/SKILL.md +14 -6
- package/resources/plugin/skills/pbot/SKILL.md +2 -2
- package/resources/prompts/history-coordinator.md +1 -2
- package/resources/prompts/plugin-coordinator.md +1 -2
- package/resources/prompts/workspace.md +12 -16
- package/resources/skills/provider-connections/SKILL.md +7 -6
- package/resources/templates/workspace-agents.md +0 -4
- package/src/extension/acp/member.ts +14 -11
- package/src/extension/acp/worker.ts +31 -28
- package/src/extension/cli/commands/upgrade.ts +8 -36
- package/src/extension/cli/commands/workspace.ts +3 -8
- package/src/extension/cli/index.ts +1 -2
- package/src/extension/hosts/dsh/acp-member.ts +1 -1
- package/src/extension/hosts/dsh/command.ts +1 -1
- package/src/extension/hosts/dsh/workspace.ts +1 -3
- package/src/extension/hosts/pi/acp-member.ts +3 -4
- package/src/extension/hosts/pi/command.ts +1 -1
- package/src/extension/hosts/pi/lifecycle.ts +0 -2
- package/src/extension/hosts/plugin-runtime.ts +0 -10
- package/src/extension/mcp/tool-contract.ts +48 -62
- package/src/extension/mcp/workers.ts +66 -27
- package/src/integrations/acp/agents.ts +28 -27
- package/src/integrations/acp/harnesses/claude.ts +1 -1
- package/src/integrations/agent-resources.ts +2 -2
- package/src/integrations/hosts/dsh/session.ts +2 -2
- package/src/integrations/installation/cli-update.ts +2 -2
- package/src/integrations/installation/installers/claude.ts +4 -4
- package/src/integrations/installation/installers/qoder.ts +5 -5
- package/src/integrations/installation/upgraders/antigravity.ts +57 -15
- package/src/integrations/installation/upgraders/claude.ts +1 -4
- package/src/integrations/installation/upgraders/codex.ts +85 -15
- package/src/integrations/installation/upgraders/dsh.ts +46 -24
- package/src/integrations/installation/upgraders/pi.ts +18 -11
- package/src/integrations/installation/upgraders/qoder.ts +95 -20
- package/src/model/acp.ts +27 -29
- package/src/model/agent.ts +80 -16
- package/src/model/installation.ts +0 -2
- package/src/pbot.ts +2 -2
- package/src/services/agents/acp-run.ts +81 -49
- package/src/services/agents/agent-run.ts +154 -56
- package/src/services/agents/agent-service.ts +204 -133
- package/src/services/installation/upgrade-service.ts +1 -5
- package/src/storage/acp-files.ts +50 -45
- package/src/storage/agent-files.ts +159 -46
- package/src/tools/history/contract.ts +12 -12
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/antigravity-plugin/lib/services/workspace/plugin-releases.js +0 -126
- package/lib/antigravity-plugin/resources/references/compute-finance.md +0 -22
- package/lib/antigravity-plugin/resources/references/compute.md +0 -16
- package/lib/antigravity-plugin/resources/references/task-conductor.md +0 -25
- package/lib/services/workspace/plugin-releases.d.ts +0 -15
- package/lib/services/workspace/plugin-releases.js +0 -126
- package/resources/references/compute-finance.md +0 -22
- package/resources/references/compute.md +0 -16
- package/resources/references/task-conductor.md +0 -25
- package/src/services/workspace/plugin-releases.ts +0 -121
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Task Conductor
|
|
2
|
-
|
|
3
|
-
需要周期执行、重复流程、DAG 或离开当前会话后继续运行时使用本文。普通单次协助直接使用当前宿主专家。
|
|
4
|
-
|
|
5
|
-
## 发现与操作
|
|
6
|
-
|
|
7
|
-
在当前宿主原生工具与技能中查找 Task Conductor,先读取 `using-task-conductor` 技能,再按实际 MCP schema 调用(保留工具名中的连字符,如 `mcp__task-conductor__task_list`)。
|
|
8
|
-
|
|
9
|
-
工具或技能未出现时,向用户说明缺失项及对应宿主检查入口(如 Pi/Claude 的 `/mcp`、dsh 的 `/task-conductor status`),不要通过 Bash 代执行宿主聊天命令;继续不受影响的工作。
|
|
10
|
-
|
|
11
|
-
若需要在 dsh 后台执行节点,`executorId` 选择已注册的自定义执行端 `dsh-acp`(不是 `dsh`)。后台节点使用独立的 `acp` profile 运行环境,不继承当前主会话的模型、工具或 Python 配置。
|
|
12
|
-
|
|
13
|
-
## 定义任务
|
|
14
|
-
|
|
15
|
-
提交前写明输入、工作目录、所需工具与模型及预期产物;周期任务另须写明频率、时区、执行范围及每轮数据来源、期间与时点。
|
|
16
|
-
|
|
17
|
-
确认节点具备所需工具、技能、Python 环境和认证。需要人工交互的步骤留在交互会话中完成,节点直接执行分配任务,不递归委派。
|
|
18
|
-
|
|
19
|
-
## 状态与取消
|
|
20
|
-
|
|
21
|
-
任务定义、单次执行和节点分别用 `taskId`、`runId` 和节点 ID 标识。提交结果不明时先按 ID 或任务列表查询,避免重复创建。实时状态查 Task Conductor,项目资料只记录任务定义、标识和产物位置。
|
|
22
|
-
|
|
23
|
-
事件通知回到提交任务的原会话;新会话不代收,但可通过 MCP 查询。
|
|
24
|
-
|
|
25
|
-
取消当前执行与停止未来周期须分别操作并查询确认;停止本地专家或关闭当前会话不会停止 Task Conductor。汇报时区分“调度已创建”和“本轮已完成”,并给出状态与产物路径。
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** Each host owns its file, including when two hosts activate the same canonical workspace concurrently. */
|
|
2
|
-
export declare function bindWorkspacePlugin(root: string, host: string, binding?: string): void;
|
|
3
|
-
export interface WorkspacePluginBinding {
|
|
4
|
-
version: string;
|
|
5
|
-
bindingPath?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface WorkspacePluginDrift {
|
|
8
|
-
outOfSync: boolean;
|
|
9
|
-
highest?: string;
|
|
10
|
-
lowest?: string;
|
|
11
|
-
versions: Record<string, string>;
|
|
12
|
-
}
|
|
13
|
-
export declare function workspacePluginBindings(root: string): Record<string, WorkspacePluginBinding>;
|
|
14
|
-
export declare function workspacePluginReleases(root: string): Record<string, string>;
|
|
15
|
-
export declare function workspacePluginDrift(releases: Record<string, string>): WorkspacePluginDrift;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { mkdirSync, readdirSync, readFileSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
5
|
-
import { object } from "../../common/json.js";
|
|
6
|
-
import { resourceRoot } from "../../common/paths.js";
|
|
7
|
-
import { requireThat } from "../../common/validation.js";
|
|
8
|
-
import { releaseLine } from "../../common/version.js";
|
|
9
|
-
import { readJsonFile, writeJsonFile } from "../../storage/atomic-json.js";
|
|
10
|
-
function compareSemver(a, b) {
|
|
11
|
-
const parse = (value) => {
|
|
12
|
-
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?/.exec(value);
|
|
13
|
-
return match
|
|
14
|
-
? { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), pre: match[4] ?? "" }
|
|
15
|
-
: undefined;
|
|
16
|
-
};
|
|
17
|
-
const left = parse(a);
|
|
18
|
-
const right = parse(b);
|
|
19
|
-
if (!left || !right)
|
|
20
|
-
return a.localeCompare(b);
|
|
21
|
-
if (left.major !== right.major)
|
|
22
|
-
return left.major - right.major;
|
|
23
|
-
if (left.minor !== right.minor)
|
|
24
|
-
return left.minor - right.minor;
|
|
25
|
-
if (left.patch !== right.patch)
|
|
26
|
-
return left.patch - right.patch;
|
|
27
|
-
if (left.pre === right.pre)
|
|
28
|
-
return 0;
|
|
29
|
-
if (!left.pre)
|
|
30
|
-
return 1;
|
|
31
|
-
if (!right.pre)
|
|
32
|
-
return -1;
|
|
33
|
-
return left.pre.localeCompare(right.pre);
|
|
34
|
-
}
|
|
35
|
-
function bindingDirectory(root) {
|
|
36
|
-
const key = createHash("sha256").update(root).digest("hex");
|
|
37
|
-
return join(homedir(), ".pbot", "workspaces", key);
|
|
38
|
-
}
|
|
39
|
-
// Full plugins own a local manifest. Thin clients can supply the release stamped into their cached hooks.
|
|
40
|
-
function pluginBinding(value) {
|
|
41
|
-
requireThat(typeof value === "string", "无效的插件安装记录。");
|
|
42
|
-
if (!isAbsolute(value))
|
|
43
|
-
releaseLine(value);
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
function permissionDenied(error) {
|
|
47
|
-
return ["EACCES", "EPERM", "EROFS"].includes(error.code ?? "");
|
|
48
|
-
}
|
|
49
|
-
/** Each host owns its file, including when two hosts activate the same canonical workspace concurrently. */
|
|
50
|
-
export function bindWorkspacePlugin(root, host, binding = resolve(resourceRoot, "../package.json")) {
|
|
51
|
-
const directory = bindingDirectory(root);
|
|
52
|
-
const file = encodeURIComponent(host) + ".json";
|
|
53
|
-
try {
|
|
54
|
-
if (readJsonFile(directory, file, pluginBinding) === binding)
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
catch (error) {
|
|
58
|
-
if (permissionDenied(error))
|
|
59
|
-
return;
|
|
60
|
-
if (error.code !== "ENOENT")
|
|
61
|
-
throw error;
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
65
|
-
writeJsonFile(directory, file, binding, pluginBinding);
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
if (!permissionDenied(error))
|
|
69
|
-
throw error;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
export function workspacePluginBindings(root) {
|
|
73
|
-
const directory = bindingDirectory(root);
|
|
74
|
-
let files;
|
|
75
|
-
try {
|
|
76
|
-
files = readdirSync(directory);
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
if (error.code === "ENOENT" || permissionDenied(error))
|
|
80
|
-
return {};
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
const bindings = Object.create(null);
|
|
84
|
-
for (const file of files.filter(name => name.endsWith(".json"))) {
|
|
85
|
-
const host = decodeURIComponent(file.slice(0, -5));
|
|
86
|
-
try {
|
|
87
|
-
const binding = readJsonFile(directory, file, pluginBinding);
|
|
88
|
-
if (!isAbsolute(binding)) {
|
|
89
|
-
bindings[host] = { version: binding };
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
const manifest = JSON.parse(readFileSync(binding, "utf8"));
|
|
93
|
-
requireThat(object(manifest) && typeof manifest.version === "string", "无效的插件安装清单:" + binding);
|
|
94
|
-
releaseLine(manifest.version);
|
|
95
|
-
bindings[host] = { version: manifest.version, bindingPath: binding };
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
if (error.code !== "ENOENT" && !permissionDenied(error))
|
|
99
|
-
throw error;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
return bindings;
|
|
103
|
-
}
|
|
104
|
-
export function workspacePluginReleases(root) {
|
|
105
|
-
const bindings = workspacePluginBindings(root);
|
|
106
|
-
const releases = Object.create(null);
|
|
107
|
-
for (const [host, entry] of Object.entries(bindings))
|
|
108
|
-
releases[host] = entry.version;
|
|
109
|
-
return releases;
|
|
110
|
-
}
|
|
111
|
-
export function workspacePluginDrift(releases) {
|
|
112
|
-
let highest;
|
|
113
|
-
let lowest;
|
|
114
|
-
for (const version of Object.values(releases)) {
|
|
115
|
-
if (!highest || compareSemver(version, highest) > 0)
|
|
116
|
-
highest = version;
|
|
117
|
-
if (!lowest || compareSemver(version, lowest) < 0)
|
|
118
|
-
lowest = version;
|
|
119
|
-
}
|
|
120
|
-
return {
|
|
121
|
-
outOfSync: Boolean(highest && lowest && highest !== lowest),
|
|
122
|
-
...(highest ? { highest } : {}),
|
|
123
|
-
...(lowest ? { lowest } : {}),
|
|
124
|
-
versions: releases,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# 指标与回测
|
|
2
|
-
|
|
3
|
-
## TA-Lib
|
|
4
|
-
|
|
5
|
-
通过 `import talib` 使用原生函数。用 `talib.get_function_groups()`、`talib.get_functions()` 和 `help(talib.函数名)` 核对能力、参数与返回值。
|
|
6
|
-
|
|
7
|
-
计算前核对时间顺序、复权、缺失数据、单位与样本长度,多输入 OHLCV 数组必须按同一时间轴对齐。保留影响结果解释的原生规则:
|
|
8
|
-
|
|
9
|
-
- `MACD` 返回 `(macd, signal, hist)`,其中 `hist = macd - signal`,不乘 2。
|
|
10
|
-
- `BBANDS` 返回 `(upper, middle, lower)`,默认使用 SMA 中轨和两倍总体标准差。
|
|
11
|
-
- 暖机期为 NaN,例如 SMA(20) 前 19 根、RSI(14) 前 14 根不可用。EMA、RSI 的种子和平滑规则不等同于直接 pandas ewm;持平序列的 RSI 暖机后为 0,不是 50。
|
|
12
|
-
- NaN 输入可能影响后续输出,不擅自填零或把暖机值当成信号。严格 JSON 中将非有限值转为 null。
|
|
13
|
-
|
|
14
|
-
按需记录参数、库版本和数据来源,便于复现。
|
|
15
|
-
|
|
16
|
-
## backtesting
|
|
17
|
-
|
|
18
|
-
用 `from backtesting import Backtest, Strategy`,通过 Strategy 的 `init()`、`next()` 定义策略,再运行 `Backtest(data, 策略类, ...).run()`。数据为按时间升序的 OHLC DataFrame,可带 Volume;参数以当前版本 API 为准。TA-Lib 指标可用 `self.I(talib.SMA, self.data.Close, 20)` 注册。
|
|
19
|
-
|
|
20
|
-
显式确定资金、手续费、价差、成交时点与仓位假设。原生 Backtest 不自动提供 A 股 T+1、整手买入、涨跌停或交易日历约束;任务需要时明确建模和验证,无法表达时说明限制,不把默认值当作市场规则。
|
|
21
|
-
|
|
22
|
-
按研究问题选择样本内外划分及暖机方法,避免未来数据泄漏。交付时说明参数、版本与限制,按需保留统计和交易记录;导出时处理 Series、DataFrame、时间和非有限值。
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Python 计算
|
|
2
|
-
|
|
3
|
-
## 运行方式
|
|
4
|
-
|
|
5
|
-
通过当前宿主的原生 Bash,沿用项目声明的解释器、依赖、工作目录、入口和输出位置。尚无约定时,先检查可用解释器和所需库再执行。
|
|
6
|
-
|
|
7
|
-
包内相对导入在项目根目录用 `python -m 包.模块`,不靠改 `sys.path` 绕过导入错误。交付时核对结果并给出实际产物路径。
|
|
8
|
-
|
|
9
|
-
解释器或依赖异常时,检查实际路径、导入错误与项目配置,继续不受影响的工作;专家需要主会话协助时交回具体阻碍和所需条件。
|
|
10
|
-
|
|
11
|
-
## 常见约束
|
|
12
|
-
|
|
13
|
-
- 无图形界面绘图:导入 `pyplot`/`seaborn` 前设置 Matplotlib `Agg` 后端,保存文件后关闭 figure。
|
|
14
|
-
- 表格与二进制文件(Excel/Parquet/Feather):核对读写后的字段类型、时间单位与时区;Excel 不直接保存带时区的 `datetime`,转换前先确定目标时区。
|
|
15
|
-
- 统计与建模:记录数据口径和假设;时间序列按时间切分,预处理只在训练集拟合,避免未来数据泄漏。
|
|
16
|
-
- 技术指标或回测:另读同目录 [compute-finance.md](compute-finance.md),显式确定数据口径和交易假设。
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# Task Conductor
|
|
2
|
-
|
|
3
|
-
需要周期执行、重复流程、DAG 或离开当前会话后继续运行时使用本文。普通单次协助直接使用当前宿主专家。
|
|
4
|
-
|
|
5
|
-
## 发现与操作
|
|
6
|
-
|
|
7
|
-
在当前宿主原生工具与技能中查找 Task Conductor,先读取 `using-task-conductor` 技能,再按实际 MCP schema 调用(保留工具名中的连字符,如 `mcp__task-conductor__task_list`)。
|
|
8
|
-
|
|
9
|
-
工具或技能未出现时,向用户说明缺失项及对应宿主检查入口(如 Pi/Claude 的 `/mcp`、dsh 的 `/task-conductor status`),不要通过 Bash 代执行宿主聊天命令;继续不受影响的工作。
|
|
10
|
-
|
|
11
|
-
若需要在 dsh 后台执行节点,`executorId` 选择已注册的自定义执行端 `dsh-acp`(不是 `dsh`)。后台节点使用独立的 `acp` profile 运行环境,不继承当前主会话的模型、工具或 Python 配置。
|
|
12
|
-
|
|
13
|
-
## 定义任务
|
|
14
|
-
|
|
15
|
-
提交前写明输入、工作目录、所需工具与模型及预期产物;周期任务另须写明频率、时区、执行范围及每轮数据来源、期间与时点。
|
|
16
|
-
|
|
17
|
-
确认节点具备所需工具、技能、Python 环境和认证。需要人工交互的步骤留在交互会话中完成,节点直接执行分配任务,不递归委派。
|
|
18
|
-
|
|
19
|
-
## 状态与取消
|
|
20
|
-
|
|
21
|
-
任务定义、单次执行和节点分别用 `taskId`、`runId` 和节点 ID 标识。提交结果不明时先按 ID 或任务列表查询,避免重复创建。实时状态查 Task Conductor,项目资料只记录任务定义、标识和产物位置。
|
|
22
|
-
|
|
23
|
-
事件通知回到提交任务的原会话;新会话不代收,但可通过 MCP 查询。
|
|
24
|
-
|
|
25
|
-
取消当前执行与停止未来周期须分别操作并查询确认;停止本地专家或关闭当前会话不会停止 Task Conductor。汇报时区分“调度已创建”和“本轮已完成”,并给出状态与产物路径。
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
import { mkdirSync, readdirSync, readFileSync } from "node:fs";
|
|
3
|
-
import { homedir } from "node:os";
|
|
4
|
-
import { isAbsolute, join, resolve } from "node:path";
|
|
5
|
-
import { object } from "../../common/json.js";
|
|
6
|
-
import { resourceRoot } from "../../common/paths.js";
|
|
7
|
-
import { requireThat } from "../../common/validation.js";
|
|
8
|
-
import { releaseLine } from "../../common/version.js";
|
|
9
|
-
import { readJsonFile, writeJsonFile } from "../../storage/atomic-json.js";
|
|
10
|
-
|
|
11
|
-
function compareSemver(a: string, b: string): number {
|
|
12
|
-
const parse = (value: string) => {
|
|
13
|
-
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?/.exec(value);
|
|
14
|
-
return match
|
|
15
|
-
? { major: Number(match[1]), minor: Number(match[2]), patch: Number(match[3]), pre: match[4] ?? "" }
|
|
16
|
-
: undefined;
|
|
17
|
-
};
|
|
18
|
-
const left = parse(a);
|
|
19
|
-
const right = parse(b);
|
|
20
|
-
if (!left || !right) return a.localeCompare(b);
|
|
21
|
-
if (left.major !== right.major) return left.major - right.major;
|
|
22
|
-
if (left.minor !== right.minor) return left.minor - right.minor;
|
|
23
|
-
if (left.patch !== right.patch) return left.patch - right.patch;
|
|
24
|
-
if (left.pre === right.pre) return 0;
|
|
25
|
-
if (!left.pre) return 1;
|
|
26
|
-
if (!right.pre) return -1;
|
|
27
|
-
return left.pre.localeCompare(right.pre);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function bindingDirectory(root: string) {
|
|
31
|
-
const key = createHash("sha256").update(root).digest("hex");
|
|
32
|
-
return join(homedir(), ".pbot", "workspaces", key);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Full plugins own a local manifest. Thin clients can supply the release stamped into their cached hooks.
|
|
36
|
-
function pluginBinding(value: unknown): string {
|
|
37
|
-
requireThat(typeof value === "string", "无效的插件安装记录。");
|
|
38
|
-
if (!isAbsolute(value)) releaseLine(value);
|
|
39
|
-
return value;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function permissionDenied(error: unknown): boolean {
|
|
43
|
-
return ["EACCES", "EPERM", "EROFS"].includes((error as NodeJS.ErrnoException).code ?? "");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Each host owns its file, including when two hosts activate the same canonical workspace concurrently. */
|
|
47
|
-
export function bindWorkspacePlugin(root: string, host: string, binding = resolve(resourceRoot, "../package.json")): void {
|
|
48
|
-
const directory = bindingDirectory(root);
|
|
49
|
-
const file = encodeURIComponent(host) + ".json";
|
|
50
|
-
try {
|
|
51
|
-
if (readJsonFile(directory, file, pluginBinding) === binding) return;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
if (permissionDenied(error)) return;
|
|
54
|
-
if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
|
|
55
|
-
}
|
|
56
|
-
try {
|
|
57
|
-
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
58
|
-
writeJsonFile(directory, file, binding, pluginBinding);
|
|
59
|
-
} catch (error) {
|
|
60
|
-
if (!permissionDenied(error)) throw error;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface WorkspacePluginBinding {
|
|
65
|
-
version: string;
|
|
66
|
-
bindingPath?: string;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export interface WorkspacePluginDrift {
|
|
70
|
-
outOfSync: boolean;
|
|
71
|
-
highest?: string;
|
|
72
|
-
lowest?: string;
|
|
73
|
-
versions: Record<string, string>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function workspacePluginBindings(root: string): Record<string, WorkspacePluginBinding> {
|
|
77
|
-
const directory = bindingDirectory(root);
|
|
78
|
-
let files: string[];
|
|
79
|
-
try { files = readdirSync(directory); }
|
|
80
|
-
catch (error) {
|
|
81
|
-
if ((error as NodeJS.ErrnoException).code === "ENOENT" || permissionDenied(error)) return {};
|
|
82
|
-
throw error;
|
|
83
|
-
}
|
|
84
|
-
const bindings: Record<string, WorkspacePluginBinding> = Object.create(null);
|
|
85
|
-
for (const file of files.filter(name => name.endsWith(".json"))) {
|
|
86
|
-
const host = decodeURIComponent(file.slice(0, -5));
|
|
87
|
-
try {
|
|
88
|
-
const binding = readJsonFile(directory, file, pluginBinding);
|
|
89
|
-
if (!isAbsolute(binding)) { bindings[host] = { version: binding }; continue; }
|
|
90
|
-
const manifest: unknown = JSON.parse(readFileSync(binding, "utf8"));
|
|
91
|
-
requireThat(object(manifest) && typeof manifest.version === "string", "无效的插件安装清单:" + binding);
|
|
92
|
-
releaseLine(manifest.version);
|
|
93
|
-
bindings[host] = { version: manifest.version, bindingPath: binding };
|
|
94
|
-
} catch (error) {
|
|
95
|
-
if ((error as NodeJS.ErrnoException).code !== "ENOENT" && !permissionDenied(error)) throw error;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return bindings;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function workspacePluginReleases(root: string): Record<string, string> {
|
|
102
|
-
const bindings = workspacePluginBindings(root);
|
|
103
|
-
const releases: Record<string, string> = Object.create(null);
|
|
104
|
-
for (const [host, entry] of Object.entries(bindings)) releases[host] = entry.version;
|
|
105
|
-
return releases;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
export function workspacePluginDrift(releases: Record<string, string>): WorkspacePluginDrift {
|
|
109
|
-
let highest: string | undefined;
|
|
110
|
-
let lowest: string | undefined;
|
|
111
|
-
for (const version of Object.values(releases)) {
|
|
112
|
-
if (!highest || compareSemver(version, highest) > 0) highest = version;
|
|
113
|
-
if (!lowest || compareSemver(version, lowest) < 0) lowest = version;
|
|
114
|
-
}
|
|
115
|
-
return {
|
|
116
|
-
outOfSync: Boolean(highest && lowest && highest !== lowest),
|
|
117
|
-
...(highest ? { highest } : {}),
|
|
118
|
-
...(lowest ? { lowest } : {}),
|
|
119
|
-
versions: releases,
|
|
120
|
-
};
|
|
121
|
-
}
|