@oyasmi/pipiclaw 0.9.3 → 0.9.4-beta.1
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/agent/channel-runner.js +137 -61
- package/dist/agent/command-extension.js +47 -34
- package/dist/agent/job-manager.js +31 -11
- package/dist/agent/model-fallback.js +1 -1
- package/dist/agent/prompt/manifest.d.ts +6 -1
- package/dist/agent/prompt/manifest.js +45 -64
- package/dist/agent/prompt/resources.js +4 -1
- package/dist/agent/run-queue.js +7 -2
- package/dist/agent/session-adapter.js +1 -1
- package/dist/agent/session-events.js +17 -6
- package/dist/agent/session-resource-gate.js +3 -1
- package/dist/agent/status-render.d.ts +0 -1
- package/dist/agent/status-render.js +4 -16
- package/dist/agent/turn-error.d.ts +31 -0
- package/dist/agent/turn-error.js +68 -0
- package/dist/app-services.js +7 -4
- package/dist/channel/channel-index.js +4 -1
- package/dist/channel/project-scope-store.js +1 -1
- package/dist/commands/catalog.d.ts +21 -4
- package/dist/commands/catalog.js +88 -41
- package/dist/commands/reply-limits.d.ts +6 -0
- package/dist/commands/reply-limits.js +24 -0
- package/dist/events/event-commands.js +94 -44
- package/dist/events/event-validation.d.ts +13 -2
- package/dist/events/event-validation.js +17 -9
- package/dist/events/events.js +77 -32
- package/dist/executor.js +2 -2
- package/dist/log.d.ts +12 -2
- package/dist/log.js +26 -34
- package/dist/main.js +1 -1
- package/dist/memory/commands.js +29 -23
- package/dist/memory/lifecycle.js +26 -5
- package/dist/memory/maintenance-state.js +4 -1
- package/dist/memory/scheduler.js +3 -1
- package/dist/models/auth-cli.js +3 -2
- package/dist/paths.d.ts +2 -0
- package/dist/paths.js +9 -0
- package/dist/playbooks/agent-delegation.md +2 -2
- package/dist/runtime/app-home.d.ts +6 -0
- package/dist/runtime/app-home.js +21 -3
- package/dist/runtime/bootstrap.js +189 -60
- package/dist/runtime/channel-queue.js +1 -1
- package/dist/runtime/delivery.js +29 -15
- package/dist/runtime/dingtalk.js +96 -42
- package/dist/runtime/durable-dispatch.d.ts +27 -1
- package/dist/runtime/durable-dispatch.js +111 -3
- package/dist/runtime/project-commands.js +16 -15
- package/dist/runtime/proxy.js +4 -2
- package/dist/runtime/report-commands.js +1 -1
- package/dist/runtime/skill-commands.d.ts +1 -1
- package/dist/runtime/skill-commands.js +17 -10
- package/dist/runtime/subagent-commands.d.ts +5 -4
- package/dist/runtime/subagent-commands.js +116 -77
- package/dist/runtime/task-commands.d.ts +1 -1
- package/dist/runtime/task-commands.js +110 -64
- package/dist/runtime/task-driver.d.ts +4 -2
- package/dist/runtime/task-driver.js +55 -20
- package/dist/runtime/task-migration.js +23 -6
- package/dist/runtime/task-spawn.js +12 -5
- package/dist/runtime/wake-coalescing.d.ts +18 -0
- package/dist/runtime/wake-coalescing.js +29 -0
- package/dist/security/block-message.d.ts +22 -1
- package/dist/security/block-message.js +66 -1
- package/dist/security/network.d.ts +2 -1
- package/dist/security/network.js +3 -2
- package/dist/security/path-guard-check.js +2 -2
- package/dist/settings.d.ts +3 -2
- package/dist/settings.js +4 -1
- package/dist/shared/format.d.ts +12 -0
- package/dist/shared/format.js +37 -0
- package/dist/shared/host-process.js +15 -3
- package/dist/shared/with-timeout.d.ts +3 -2
- package/dist/shared/with-timeout.js +14 -3
- package/dist/subagents/external/claude-code.js +23 -1
- package/dist/subagents/external/progress-tail.d.ts +17 -0
- package/dist/subagents/external/progress-tail.js +64 -17
- package/dist/subagents/external/run.d.ts +3 -0
- package/dist/subagents/external/run.js +21 -7
- package/dist/subagents/external/settlement.d.ts +3 -0
- package/dist/subagents/external/settlement.js +1 -1
- package/dist/subagents/runs.d.ts +21 -1
- package/dist/subagents/runs.js +137 -32
- package/dist/subagents/tool.d.ts +22 -15
- package/dist/subagents/tool.js +226 -32
- package/dist/subagents/workspace-summary.d.ts +16 -4
- package/dist/subagents/workspace-summary.js +74 -18
- package/dist/tasks/board.d.ts +8 -1
- package/dist/tasks/board.js +37 -2
- package/dist/tasks/frontmatter.d.ts +5 -0
- package/dist/tasks/frontmatter.js +8 -0
- package/dist/tasks/log.d.ts +11 -1
- package/dist/tasks/log.js +58 -2
- package/dist/tasks/store.js +4 -2
- package/dist/tasks/ticket.d.ts +3 -1
- package/dist/tasks/ticket.js +19 -1
- package/dist/tools/bash.js +2 -2
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +1 -0
- package/dist/tools/memory-manage.js +4 -1
- package/dist/tools/subagent-manage.d.ts +1 -1
- package/dist/tools/subagent-manage.js +16 -11
- package/dist/tools/task-manage/step-end.js +4 -1
- package/dist/tools/tool-details.d.ts +10 -2
- package/dist/tools/tool-details.js +39 -2
- package/dist/tui/cli.js +2 -2
- package/dist/tui/commands.js +4 -4
- package/dist/tui/pitui-frontend.js +1 -1
- package/dist/tui/renderer.js +3 -2
- package/dist/tui/turn-controller.d.ts +2 -0
- package/dist/tui/turn-controller.js +36 -21
- package/dist/usage/ledger.js +3 -1
- package/dist/usage/render.js +3 -1
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Collaborators (runner, frontend, store) are injected so the machine can be
|
|
7
7
|
* unit-tested with fakes and a fake clock. `app.ts` builds the real ones.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { formatBusyHint, formatFollowupQueued, formatNoRunningTurn, formatSteerQueued, formatUnknownCommandMessage, isSessionCommandName, slashCommandName, } from "../commands/catalog.js";
|
|
10
10
|
import * as log from "../log.js";
|
|
11
11
|
import { formatLocalTime } from "../shared/local-time.js";
|
|
12
12
|
import { errorMessage } from "../shared/text-utils.js";
|
|
@@ -66,7 +66,10 @@ export class TurnController {
|
|
|
66
66
|
this.submitChain = this.submitChain
|
|
67
67
|
.then(() => this.processSubmit(text))
|
|
68
68
|
.catch((err) => {
|
|
69
|
-
log.
|
|
69
|
+
log.logWarn("tui.submit.failed", "Submit failed", {
|
|
70
|
+
channelId: this.deps.channelId,
|
|
71
|
+
reason: errorMessage(err),
|
|
72
|
+
});
|
|
70
73
|
});
|
|
71
74
|
}
|
|
72
75
|
async processSubmit(text) {
|
|
@@ -92,7 +95,7 @@ export class TurnController {
|
|
|
92
95
|
this.deps.frontend.showNotice("正在停止…");
|
|
93
96
|
}
|
|
94
97
|
else {
|
|
95
|
-
this.deps.frontend.showNotice("
|
|
98
|
+
this.deps.frontend.showNotice(formatNoRunningTurn("stop"));
|
|
96
99
|
}
|
|
97
100
|
return;
|
|
98
101
|
case "followup":
|
|
@@ -114,7 +117,7 @@ export class TurnController {
|
|
|
114
117
|
// steered into the running turn as literal text (review 2026-08-24 §1.6; matches
|
|
115
118
|
// the DingTalk busy refusal in dingtalk.ts).
|
|
116
119
|
if (name && isSessionCommandName(name) && this.deps.runner.isBusy()) {
|
|
117
|
-
this.deps.frontend.showFinal(
|
|
120
|
+
this.deps.frontend.showFinal(formatBusyHint());
|
|
118
121
|
return;
|
|
119
122
|
}
|
|
120
123
|
await this.applyText(outcome.text);
|
|
@@ -127,7 +130,7 @@ export class TurnController {
|
|
|
127
130
|
if (this.deps.runner.isBusy()) {
|
|
128
131
|
try {
|
|
129
132
|
await this.deps.runner.queueSteer(text, this.deps.userName);
|
|
130
|
-
this.deps.frontend.showNotice(
|
|
133
|
+
this.deps.frontend.showNotice(formatSteerQueued(false));
|
|
131
134
|
return;
|
|
132
135
|
}
|
|
133
136
|
catch {
|
|
@@ -139,7 +142,7 @@ export class TurnController {
|
|
|
139
142
|
applyFollowup(text) {
|
|
140
143
|
if (this.deps.runner.isBusy()) {
|
|
141
144
|
this.followups.push(text);
|
|
142
|
-
this.deps.frontend.showNotice(
|
|
145
|
+
this.deps.frontend.showNotice(formatFollowupQueued());
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
148
|
this.beginTurn(text);
|
|
@@ -159,7 +162,7 @@ export class TurnController {
|
|
|
159
162
|
await this.deps.runner.run(ctx, this.deps.store);
|
|
160
163
|
}
|
|
161
164
|
catch (err) {
|
|
162
|
-
this.deps.frontend.showNotice(
|
|
165
|
+
this.deps.frontend.showNotice(`处理失败:${errorMessage(err)}`);
|
|
163
166
|
}
|
|
164
167
|
finally {
|
|
165
168
|
await ctx.close();
|
|
@@ -171,7 +174,10 @@ export class TurnController {
|
|
|
171
174
|
// The turn is over whether it settled or its finally threw (e.g. a frontend
|
|
172
175
|
// method failing); drain either way and never leak an unhandled rejection.
|
|
173
176
|
void this.currentTurn.then(() => this.drainFollowups(), (err) => {
|
|
174
|
-
log.
|
|
177
|
+
log.logWarn("tui.turn.finalizer_failed", "Turn finalizer failed", {
|
|
178
|
+
channelId: this.deps.channelId,
|
|
179
|
+
reason: errorMessage(err),
|
|
180
|
+
});
|
|
175
181
|
this.deps.runner.endTurn();
|
|
176
182
|
this.drainFollowups();
|
|
177
183
|
});
|
|
@@ -204,7 +210,10 @@ export class TurnController {
|
|
|
204
210
|
});
|
|
205
211
|
}
|
|
206
212
|
catch (err) {
|
|
207
|
-
log.
|
|
213
|
+
log.logWarn("channel.archive.write_failed", "User message archive failed", {
|
|
214
|
+
channelId: this.deps.channelId,
|
|
215
|
+
reason: errorMessage(err),
|
|
216
|
+
});
|
|
208
217
|
}
|
|
209
218
|
}
|
|
210
219
|
handleInterrupt() {
|
|
@@ -220,14 +229,17 @@ export class TurnController {
|
|
|
220
229
|
return;
|
|
221
230
|
}
|
|
222
231
|
this.exitArmed = true;
|
|
223
|
-
this.deps.frontend.showNotice("
|
|
232
|
+
this.deps.frontend.showNotice("再按一次 Ctrl-C 退出。");
|
|
224
233
|
}
|
|
225
234
|
requestExit() {
|
|
226
235
|
// shutdown() restores the terminal in a finally, so a rejection here means only
|
|
227
236
|
// the memory-flush bookkeeping failed — log it rather than leak an unhandled
|
|
228
237
|
// rejection that could abort the process before exitResolve runs.
|
|
229
238
|
this.shutdown().catch((err) => {
|
|
230
|
-
log.
|
|
239
|
+
log.logWarn("tui.shutdown.failed", "Shutdown failed", {
|
|
240
|
+
channelId: this.deps.channelId,
|
|
241
|
+
reason: errorMessage(err),
|
|
242
|
+
});
|
|
231
243
|
this.exitResolve();
|
|
232
244
|
});
|
|
233
245
|
}
|
|
@@ -240,24 +252,24 @@ export class TurnController {
|
|
|
240
252
|
// Snapshot may be unavailable before the first turn; omit the model.
|
|
241
253
|
}
|
|
242
254
|
const meta = model ? `${this.deps.channelId} · ${model}` : this.deps.channelId;
|
|
243
|
-
return [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
255
|
+
return [`${bold("pipiclaw")} ${dim("· 终端对话")}`, dim(meta), dim("输入消息开始;/help 查看命令。")].join("\n");
|
|
256
|
+
}
|
|
257
|
+
/** One word per state; `idle` and `ready` used to name the same one. */
|
|
258
|
+
runStateLabel() {
|
|
259
|
+
return this.deps.runner.isBusy() ? "运行中" : "空闲";
|
|
248
260
|
}
|
|
249
261
|
updateStatus() {
|
|
250
262
|
try {
|
|
251
263
|
const snapshot = this.deps.runner.getStatusSnapshot();
|
|
252
264
|
let line = snapshot.model;
|
|
253
265
|
if (snapshot.contextTokens !== undefined && snapshot.contextWindow > 0) {
|
|
254
|
-
line += ` ·
|
|
266
|
+
line += ` · 上下文 ${((snapshot.contextTokens / snapshot.contextWindow) * 100).toFixed(0)}%`;
|
|
255
267
|
}
|
|
256
|
-
line += this.
|
|
268
|
+
line += ` · ${this.runStateLabel()}`;
|
|
257
269
|
this.deps.frontend.setStatus(`${this.deps.channelId} · ${line}`);
|
|
258
270
|
}
|
|
259
271
|
catch {
|
|
260
|
-
this.deps.frontend.setStatus(`${this.deps.channelId} · ${this.
|
|
272
|
+
this.deps.frontend.setStatus(`${this.deps.channelId} · ${this.runStateLabel()}`);
|
|
261
273
|
}
|
|
262
274
|
}
|
|
263
275
|
async shutdown() {
|
|
@@ -281,10 +293,13 @@ export class TurnController {
|
|
|
281
293
|
// pause without polluting stdout (which carries the answer in --print).
|
|
282
294
|
// Guaranteed via finally: a flush failure must not leave the terminal raw.
|
|
283
295
|
this.deps.frontend.stop();
|
|
284
|
-
process.stderr.write("
|
|
296
|
+
process.stderr.write("正在保存会话记忆…\n");
|
|
285
297
|
await Promise.race([
|
|
286
298
|
this.deps.runner.flushMemoryForShutdown().catch((err) => {
|
|
287
|
-
log.
|
|
299
|
+
log.logWarn("memory.flush.failed", "Memory flush on exit failed", {
|
|
300
|
+
channelId: this.deps.channelId,
|
|
301
|
+
reason: errorMessage(err),
|
|
302
|
+
});
|
|
288
303
|
}),
|
|
289
304
|
new Promise((resolve) => setTimeout(resolve, SHUTDOWN_FLUSH_WAIT_MS)),
|
|
290
305
|
]);
|
package/dist/usage/ledger.js
CHANGED
|
@@ -83,7 +83,9 @@ export function createUsageLedger(options = {}) {
|
|
|
83
83
|
if (!hasKnownSignal && !hasUnknownSignal)
|
|
84
84
|
return;
|
|
85
85
|
if (!entry.channelId) {
|
|
86
|
-
log.
|
|
86
|
+
log.logWarn("usage.entry.untracked", "Usage entry missing channelId; recorded as untracked", {
|
|
87
|
+
fields: { kind: entry.kind },
|
|
88
|
+
});
|
|
87
89
|
}
|
|
88
90
|
const full = {
|
|
89
91
|
ts: formatLocalTime(),
|
package/dist/usage/render.js
CHANGED
|
@@ -42,8 +42,10 @@ function topEntries(map, limit) {
|
|
|
42
42
|
.sort((a, b) => b[1] - a[1])
|
|
43
43
|
.slice(0, limit);
|
|
44
44
|
}
|
|
45
|
+
/** The ledger's kinds in the user's terms: a turn is the assistant itself, a sidecar is background memory work. */
|
|
46
|
+
const KIND_LABEL = { turn: "对话", subagent: "委派", sidecar: "后台整理" };
|
|
45
47
|
function renderKindBreakdown(summary) {
|
|
46
|
-
const parts = topEntries(summary.byKind, 3).map(([kind, cost]) => `${kind} ${money(cost)}`);
|
|
48
|
+
const parts = topEntries(summary.byKind, 3).map(([kind, cost]) => `${KIND_LABEL[kind] ?? kind} ${money(cost)}`);
|
|
47
49
|
return parts.length > 0 ? parts.join(" · ") : null;
|
|
48
50
|
}
|
|
49
51
|
/**
|
package/package.json
CHANGED