pi-ptc-subagents 7.4.0 → 7.5.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/dist/index.js +21 -12
- package/docs/routes/reach-the-web.md +1 -0
- package/docs/routes/run-one-program.md +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4058,6 +4058,7 @@ const TOOLS = {
|
|
|
4058
4058
|
"什么时候写程序而不是逐个调工具,看系统提示词 <ptc> 节的路由表。",
|
|
4059
4059
|
"程序内可调本会话已启用的同名工具(read / write / edit / grep / find / ls;bash 默认不可用),参数与直接调用该工具完全一致;每次调用返回 Promise,要 await,返回文本结果,失败抛异常。",
|
|
4060
4060
|
"程序内还可调 task_records({ scope: \"all\" }) 取任务记录(all 含压缩归档)——要挑很多条时在程序里筛完只 return 要的几条。",
|
|
4061
|
+
"程序内还可调 task_output({ taskId }) 取孩子交回的正文——返回 {text}(孩子的散文,不是原始事件流);text 空时看 status:还在跑就等一会儿再取,别当没产出;收多份正文时读完只 return 汇总。",
|
|
4061
4062
|
"例:const files = await tools.find({ pattern: \"*.py\" }); for (const f of files) await tools.write({ path: f, content: body });"
|
|
4062
4063
|
].join("")].join("")
|
|
4063
4064
|
},
|
|
@@ -4121,10 +4122,9 @@ const ROUTES = [
|
|
|
4121
4122
|
name: "派一个子代理",
|
|
4122
4123
|
when: "材料多、主题互不相干、每份都要读一堆材料时派——父一个人扛会算错(实测 92%→100%,n=3);成本 10 倍上下,一件能算完的活别派",
|
|
4123
4124
|
how: {
|
|
4124
|
-
full_ptc: "tools.pi_task_ptc({ task, label? })(程序内)——task 是孩子的唯一规格(写死路径/命令/交付物格式);要报告就点名 child report 的 JSON 块(summary/findings
|
|
4125
|
+
full_ptc: "tools.pi_task_ptc({ task, label? })(程序内)——task 是孩子的唯一规格(写死路径/命令/交付物格式);要报告就点名 child report 的 JSON 块(summary/findings),别自创报告格式",
|
|
4125
4126
|
codemode_ptc: "tools.pi_task_codemode({ task, label? })(脚本内)——task 是孩子的唯一规格(写死路径/命令/交付物格式);要报告就点名 child report 的 JSON 块(summary/findings),别自创报告格式;汇总前核对孩子产出(delivery),零产出就重派别补数"
|
|
4126
4127
|
},
|
|
4127
|
-
fact: "默认不等,立刻返回 handle;任务在任务记录里排队,可经任务面三工具查/停",
|
|
4128
4128
|
detail: "docs/routes/create-a-task.md"
|
|
4129
4129
|
},
|
|
4130
4130
|
{
|
|
@@ -4135,7 +4135,6 @@ const ROUTES = [
|
|
|
4135
4135
|
full_ptc: "ptc_run_code({ code, description })",
|
|
4136
4136
|
codemode_ptc: "不适用——写程序是 full_ptc 面的编排能力;本面用 codemode 编排、pi_task_codemode 派任务"
|
|
4137
4137
|
},
|
|
4138
|
-
fact: "程序内 tools.*;bash 当前不在程序绑定表里(旧 ADR-0040 的 opt-in 尚未接线);只在本面(full_ptc)注册 PTC 工具",
|
|
4139
4138
|
detail: "docs/routes/run-one-program.md"
|
|
4140
4139
|
},
|
|
4141
4140
|
{
|
|
@@ -4146,7 +4145,6 @@ const ROUTES = [
|
|
|
4146
4145
|
full_ptc: "ptc_workflow({ meta, script, args? })",
|
|
4147
4146
|
codemode_ptc: "不适用——同 run-one-program:workflow 是 full_ptc 的编排能力"
|
|
4148
4147
|
},
|
|
4149
|
-
fact: "script 内可用 workflow.log/phase/parallel/pipeline;只在本面注册",
|
|
4150
4148
|
detail: "docs/routes/run-a-phased-workflow.md"
|
|
4151
4149
|
},
|
|
4152
4150
|
{
|
|
@@ -4154,10 +4152,9 @@ const ROUTES = [
|
|
|
4154
4152
|
name: "直接用内置工具",
|
|
4155
4153
|
when: "单次调用就够,或每步都要模型判断(写操作、审批敏感)",
|
|
4156
4154
|
how: {
|
|
4157
|
-
full_ptc: "
|
|
4155
|
+
full_ptc: "程序内可调同名工具;逐个直调走 pi 自己的工具",
|
|
4158
4156
|
codemode_ptc: "脚本内 tools.<内置名> 直接调"
|
|
4159
4157
|
},
|
|
4160
|
-
fact: "bash 当前不在程序绑定表里(旧 ADR-0040 的 opt-in 尚未接线)",
|
|
4161
4158
|
detail: "docs/routes/use-the-built-in-tools.md"
|
|
4162
4159
|
},
|
|
4163
4160
|
{
|
|
@@ -4168,7 +4165,6 @@ const ROUTES = [
|
|
|
4168
4165
|
full_ptc: "孩子的契约:最终消息末尾 fenced JSON(summary/findings/files_touched/usage);宿主自动解析",
|
|
4169
4166
|
codemode_ptc: "同左——契约在孩子的追加提示词里,与 surface 无关"
|
|
4170
4167
|
},
|
|
4171
|
-
fact: "reportChannel 恒在四值:tool/prompt-json/none/opted-out;工具通道(ptc_child_report)已是首选",
|
|
4172
4168
|
detail: "docs/routes/report-what-you-did.md"
|
|
4173
4169
|
},
|
|
4174
4170
|
{
|
|
@@ -4176,10 +4172,9 @@ const ROUTES = [
|
|
|
4176
4172
|
name: "上网查资料",
|
|
4177
4173
|
when: "需要网页搜索、抓页面、页内找内容——判断力在干活的子代理侧",
|
|
4178
4174
|
how: {
|
|
4179
|
-
full_ptc: "派子代理(pi_task_ptc),孩子用 web_ds_search
|
|
4175
|
+
full_ptc: "派子代理(pi_task_ptc),孩子用 web_ds_search",
|
|
4180
4176
|
codemode_ptc: "同左——搜索只在子代理进程里注册,父会话没有这个工具"
|
|
4181
4177
|
},
|
|
4182
|
-
fact: "webDsSearch 开关默认关(fail-closed);配额每进程计;概览走 snippet 超预算整条丢弃",
|
|
4183
4178
|
detail: "docs/routes/reach-the-web.md"
|
|
4184
4179
|
},
|
|
4185
4180
|
{
|
|
@@ -4190,7 +4185,6 @@ const ROUTES = [
|
|
|
4190
4185
|
full_ptc: "ptc_task_list / ptc_task_output / ptc_task_stop(模型直调)——产出里的 delivery 是引擎实测轨迹",
|
|
4191
4186
|
codemode_ptc: "同左(模型直调;脚本经结构化返回)——产出里的 delivery 是引擎实测轨迹"
|
|
4192
4187
|
},
|
|
4193
|
-
fact: "有任务记录这三个工具才出现在模型面前(ADR-0007)",
|
|
4194
4188
|
detail: "docs/routes/manage-a-task.md"
|
|
4195
4189
|
}
|
|
4196
4190
|
];
|
|
@@ -4224,7 +4218,7 @@ function estimateTokens(text) {
|
|
|
4224
4218
|
return Math.ceil(text.length / 2);
|
|
4225
4219
|
}
|
|
4226
4220
|
const ROUTE_INDEX_LEAD = {
|
|
4227
|
-
full_ptc: "批量调工具默认先写程序(ptc_run_code
|
|
4221
|
+
full_ptc: "批量调工具默认先写程序(ptc_run_code);单次调用或逐步判断、审批敏感的才直连。派不派子代理自己判断——第一行写了代价。",
|
|
4228
4222
|
codemode_ptc: "编排写 codemode 脚本;批量派活经脚本内的 pi_task_codemode;要查/停任务用任务面三工具。派不派自己判断——路由表第一行写了代价。"
|
|
4229
4223
|
};
|
|
4230
4224
|
function renderRouteIndex(surface, detailBase, nudge = true) {
|
|
@@ -5233,6 +5227,20 @@ function createTaskBinding(door) {
|
|
|
5233
5227
|
};
|
|
5234
5228
|
}
|
|
5235
5229
|
const TASK_RECORDS_BINDING_NAME = "task_records";
|
|
5230
|
+
const TASK_OUTPUT_BINDING_NAME = "task_output";
|
|
5231
|
+
function createTaskOutputBinding(source) {
|
|
5232
|
+
return async (args) => {
|
|
5233
|
+
const raw = args;
|
|
5234
|
+
const taskId = raw?.taskId ?? raw?.task_id;
|
|
5235
|
+
if (typeof taskId !== "string" || taskId === "") return { error: "taskId 必须是非空字符串" };
|
|
5236
|
+
const record = source.registry.get(taskId) ?? await source.readArchivedRecord(taskId);
|
|
5237
|
+
if (!record) return { error: `unknown task id ${taskId}` };
|
|
5238
|
+
return {
|
|
5239
|
+
...await readTaskOutput(source, record),
|
|
5240
|
+
status: record.status
|
|
5241
|
+
};
|
|
5242
|
+
};
|
|
5243
|
+
}
|
|
5236
5244
|
// src/session.ts
|
|
5237
5245
|
function assemblePtcSession(options = {}) {
|
|
5238
5246
|
const registry = new TaskRegistry(options.onTransition);
|
|
@@ -5689,6 +5697,7 @@ function createBindingTable(pi, session, getToolContext, env) {
|
|
|
5689
5697
|
if (args?.scope !== "all") return records;
|
|
5690
5698
|
return [...records, ...await session.readArchivedRecords()];
|
|
5691
5699
|
};
|
|
5700
|
+
table[TASK_OUTPUT_BINDING_NAME] = createTaskOutputBinding(session);
|
|
5692
5701
|
return table;
|
|
5693
5702
|
}
|
|
5694
5703
|
function registerPtcTools(registerTool, options, surface) {
|
|
@@ -5775,4 +5784,4 @@ function registerTaskDoor(registerTool, session, surface) {
|
|
|
5775
5784
|
}
|
|
5776
5785
|
});
|
|
5777
5786
|
}
|
|
5778
|
-
export { assemblePtcSession, buildEngineContext, piPtcEntry as default, withDeliveryNote };
|
|
5787
|
+
export { assemblePtcSession, buildEngineContext, createTaskOutputBinding, piPtcEntry as default, withDeliveryNote };
|
|
@@ -16,3 +16,4 @@ pi 面上,搜索能力**只活在被派出的子代理里**(父会话不注
|
|
|
16
16
|
- 模型可见文本预算 12,000 字符;超了按排名**整条丢弃** + 告知丢了哪些(要哪个用 open 补抓)——不按字符截断
|
|
17
17
|
- 配额每进程计(`searchMaxCalls`,默认 30 次/进程,0 = 不限;只计成功调用)
|
|
18
18
|
- 开关 `webDsSearch`(`~/.pi/agent/ptc.json`)是布尔,**默认关**:开关关 = 工具不存在;开关开但缺凭据 = 注册但调用返回可读错误
|
|
19
|
+
- **开关关着就别派这类任务,也别去改它**:那是用户的配置,不是你的开关——改了等于替用户开了一个有网络出口、按次计费的能力。直接说明「搜索没开,做不到」;用户要的话他会自己开。实测(2026-11-01):读到「默认关」后去改配置、翻源码找开关位置的会话,比老老实实说做不到的慢 4 倍
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
- 绑定表 = 内置名单 ∩ 会话活跃工具(`--tools` 收窄的会话不会拿到被滤掉的绑定)
|
|
9
9
|
- `bash` 不在程序绑定表里——旧 ADR-0040 的 opt-in 尚未接线,当前没有任何开关能开它
|
|
10
|
+
- 程序内还能调 `task_records({ scope })` 取任务记录、`task_output({ taskId })` 取孩子交回的正文(归约后的散文)——返回 `{text}`;`text` 空时看 `status`:还在跑(`queued`/`running`/`stopping`)就等一会儿再取,别当没产出
|
|
10
11
|
- 程序返回值是归约后的结果;undefined 返回标记为「无完成值」
|
|
11
12
|
|
|
12
13
|
默认 2 分钟超时(可经 timeoutMs 调整)。输出超 50 KB 按 pi 截断契约切尾,
|