@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.
Files changed (113) hide show
  1. package/dist/agent/channel-runner.js +137 -61
  2. package/dist/agent/command-extension.js +47 -34
  3. package/dist/agent/job-manager.js +31 -11
  4. package/dist/agent/model-fallback.js +1 -1
  5. package/dist/agent/prompt/manifest.d.ts +6 -1
  6. package/dist/agent/prompt/manifest.js +45 -64
  7. package/dist/agent/prompt/resources.js +4 -1
  8. package/dist/agent/run-queue.js +7 -2
  9. package/dist/agent/session-adapter.js +1 -1
  10. package/dist/agent/session-events.js +17 -6
  11. package/dist/agent/session-resource-gate.js +3 -1
  12. package/dist/agent/status-render.d.ts +0 -1
  13. package/dist/agent/status-render.js +4 -16
  14. package/dist/agent/turn-error.d.ts +31 -0
  15. package/dist/agent/turn-error.js +68 -0
  16. package/dist/app-services.js +7 -4
  17. package/dist/channel/channel-index.js +4 -1
  18. package/dist/channel/project-scope-store.js +1 -1
  19. package/dist/commands/catalog.d.ts +21 -4
  20. package/dist/commands/catalog.js +88 -41
  21. package/dist/commands/reply-limits.d.ts +6 -0
  22. package/dist/commands/reply-limits.js +24 -0
  23. package/dist/events/event-commands.js +94 -44
  24. package/dist/events/event-validation.d.ts +13 -2
  25. package/dist/events/event-validation.js +17 -9
  26. package/dist/events/events.js +77 -32
  27. package/dist/executor.js +2 -2
  28. package/dist/log.d.ts +12 -2
  29. package/dist/log.js +26 -34
  30. package/dist/main.js +1 -1
  31. package/dist/memory/commands.js +29 -23
  32. package/dist/memory/lifecycle.js +26 -5
  33. package/dist/memory/maintenance-state.js +4 -1
  34. package/dist/memory/scheduler.js +3 -1
  35. package/dist/models/auth-cli.js +3 -2
  36. package/dist/paths.d.ts +2 -0
  37. package/dist/paths.js +9 -0
  38. package/dist/playbooks/agent-delegation.md +2 -2
  39. package/dist/runtime/app-home.d.ts +6 -0
  40. package/dist/runtime/app-home.js +21 -3
  41. package/dist/runtime/bootstrap.js +189 -60
  42. package/dist/runtime/channel-queue.js +1 -1
  43. package/dist/runtime/delivery.js +29 -15
  44. package/dist/runtime/dingtalk.js +96 -42
  45. package/dist/runtime/durable-dispatch.d.ts +27 -1
  46. package/dist/runtime/durable-dispatch.js +111 -3
  47. package/dist/runtime/project-commands.js +16 -15
  48. package/dist/runtime/proxy.js +4 -2
  49. package/dist/runtime/report-commands.js +1 -1
  50. package/dist/runtime/skill-commands.d.ts +1 -1
  51. package/dist/runtime/skill-commands.js +17 -10
  52. package/dist/runtime/subagent-commands.d.ts +5 -4
  53. package/dist/runtime/subagent-commands.js +116 -77
  54. package/dist/runtime/task-commands.d.ts +1 -1
  55. package/dist/runtime/task-commands.js +110 -64
  56. package/dist/runtime/task-driver.d.ts +4 -2
  57. package/dist/runtime/task-driver.js +55 -20
  58. package/dist/runtime/task-migration.js +23 -6
  59. package/dist/runtime/task-spawn.js +12 -5
  60. package/dist/runtime/wake-coalescing.d.ts +18 -0
  61. package/dist/runtime/wake-coalescing.js +29 -0
  62. package/dist/security/block-message.d.ts +22 -1
  63. package/dist/security/block-message.js +66 -1
  64. package/dist/security/network.d.ts +2 -1
  65. package/dist/security/network.js +3 -2
  66. package/dist/security/path-guard-check.js +2 -2
  67. package/dist/settings.d.ts +3 -2
  68. package/dist/settings.js +4 -1
  69. package/dist/shared/format.d.ts +12 -0
  70. package/dist/shared/format.js +37 -0
  71. package/dist/shared/host-process.js +15 -3
  72. package/dist/shared/with-timeout.d.ts +3 -2
  73. package/dist/shared/with-timeout.js +14 -3
  74. package/dist/subagents/external/claude-code.js +23 -1
  75. package/dist/subagents/external/progress-tail.d.ts +17 -0
  76. package/dist/subagents/external/progress-tail.js +64 -17
  77. package/dist/subagents/external/run.d.ts +3 -0
  78. package/dist/subagents/external/run.js +21 -7
  79. package/dist/subagents/external/settlement.d.ts +3 -0
  80. package/dist/subagents/external/settlement.js +1 -1
  81. package/dist/subagents/runs.d.ts +21 -1
  82. package/dist/subagents/runs.js +137 -32
  83. package/dist/subagents/tool.d.ts +22 -15
  84. package/dist/subagents/tool.js +226 -32
  85. package/dist/subagents/workspace-summary.d.ts +16 -4
  86. package/dist/subagents/workspace-summary.js +74 -18
  87. package/dist/tasks/board.d.ts +8 -1
  88. package/dist/tasks/board.js +37 -2
  89. package/dist/tasks/frontmatter.d.ts +5 -0
  90. package/dist/tasks/frontmatter.js +8 -0
  91. package/dist/tasks/log.d.ts +11 -1
  92. package/dist/tasks/log.js +58 -2
  93. package/dist/tasks/store.js +4 -2
  94. package/dist/tasks/ticket.d.ts +3 -1
  95. package/dist/tasks/ticket.js +19 -1
  96. package/dist/tools/bash.js +2 -2
  97. package/dist/tools/index.d.ts +2 -0
  98. package/dist/tools/index.js +1 -0
  99. package/dist/tools/memory-manage.js +4 -1
  100. package/dist/tools/subagent-manage.d.ts +1 -1
  101. package/dist/tools/subagent-manage.js +16 -11
  102. package/dist/tools/task-manage/step-end.js +4 -1
  103. package/dist/tools/tool-details.d.ts +10 -2
  104. package/dist/tools/tool-details.js +39 -2
  105. package/dist/tui/cli.js +2 -2
  106. package/dist/tui/commands.js +4 -4
  107. package/dist/tui/pitui-frontend.js +1 -1
  108. package/dist/tui/renderer.js +3 -2
  109. package/dist/tui/turn-controller.d.ts +2 -0
  110. package/dist/tui/turn-controller.js +36 -21
  111. package/dist/usage/ledger.js +3 -1
  112. package/dist/usage/render.js +3 -1
  113. 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 { formatBusyCommandList, formatUnknownCommandMessage, isSessionCommandName, slashCommandName, } from "../commands/catalog.js";
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.logWarning(`[${this.deps.channelId}] TUI submit failed`, errorMessage(err));
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(`当前已有回合在运行。运行中可用:${formatBusyCommandList()}。会话命令(\`/model\`、\`/compact\`、\`/session\`)需要等空闲后再用。`);
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("Queued as steer.");
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("Queued as follow-up.");
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(`Run failed: ${errorMessage(err)}`);
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.logWarning(`[${this.deps.channelId}] TUI turn finalizer failed`, errorMessage(err));
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.logWarning(`[${this.deps.channelId}] Failed to archive user message`, errorMessage(err));
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("Press Ctrl-C again to exit.");
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.logWarning(`[${this.deps.channelId}] TUI shutdown failed`, errorMessage(err));
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
- `${bold("pipiclaw")} ${dim("· terminal chat")}`,
245
- dim(meta),
246
- dim("Type a message to start. /help for commands."),
247
- ].join("\n");
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 += ` · ctx ${((snapshot.contextTokens / snapshot.contextWindow) * 100).toFixed(0)}%`;
266
+ line += ` · 上下文 ${((snapshot.contextTokens / snapshot.contextWindow) * 100).toFixed(0)}%`;
255
267
  }
256
- line += this.deps.runner.isBusy() ? " · running" : " · idle";
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.deps.runner.isBusy() ? "running" : "ready"}`);
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("Saving session memory…\n");
296
+ process.stderr.write("正在保存会话记忆…\n");
285
297
  await Promise.race([
286
298
  this.deps.runner.flushMemoryForShutdown().catch((err) => {
287
- log.logWarning(`[${this.deps.channelId}] Failed to flush memory on exit`, errorMessage(err));
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
  ]);
@@ -83,7 +83,9 @@ export function createUsageLedger(options = {}) {
83
83
  if (!hasKnownSignal && !hasUnknownSignal)
84
84
  return;
85
85
  if (!entry.channelId) {
86
- log.logWarning("Usage ledger entry missing channelId; recording as untracked", `kind=${entry.kind}`);
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(),
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.9.3",
3
+ "version": "0.9.4-beta.1",
4
4
  "description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
5
5
  "type": "module",
6
6
  "bin": {