@oyasmi/pipiclaw 0.8.0 → 0.8.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 (100) hide show
  1. package/README.md +14 -0
  2. package/dist/agent/channel-runner.d.ts +1 -4
  3. package/dist/agent/channel-runner.js +18 -22
  4. package/dist/agent/job-manager.d.ts +5 -5
  5. package/dist/agent/prompt-builder.d.ts +3 -13
  6. package/dist/agent/prompt-builder.js +48 -204
  7. package/dist/agent/run-queue.js +2 -1
  8. package/dist/agent/runner-factory.d.ts +1 -2
  9. package/dist/agent/runner-factory.js +2 -2
  10. package/dist/agent/status-render.d.ts +0 -7
  11. package/dist/agent/status-render.js +8 -3
  12. package/dist/agent/workspace-resources.d.ts +1 -1
  13. package/dist/agent/workspace-resources.js +3 -15
  14. package/dist/executor.d.ts +20 -0
  15. package/dist/{sandbox.js → executor.js} +3 -95
  16. package/dist/index.d.ts +1 -1
  17. package/dist/index.js +1 -1
  18. package/dist/log.d.ts +1 -1
  19. package/dist/log.js +1 -2
  20. package/dist/memory/files.js +0 -0
  21. package/dist/memory/lifecycle.js +6 -5
  22. package/dist/memory/maintenance-jobs.d.ts +0 -1
  23. package/dist/memory/maintenance-jobs.js +2 -2
  24. package/dist/memory/maintenance-state.js +2 -1
  25. package/dist/memory/post-turn-review.d.ts +0 -1
  26. package/dist/memory/post-turn-review.js +4 -4
  27. package/dist/memory/scheduler.d.ts +0 -1
  28. package/dist/memory/scheduler.js +2 -2
  29. package/dist/memory/session.js +2 -2
  30. package/dist/paths.d.ts +2 -0
  31. package/dist/paths.js +11 -0
  32. package/dist/playbooks/catalog.d.ts +9 -0
  33. package/dist/playbooks/catalog.js +44 -0
  34. package/dist/playbooks/event-scheduling.md +43 -0
  35. package/dist/playbooks/memory-and-learning.md +45 -0
  36. package/dist/playbooks/runtime-orientation.md +48 -0
  37. package/dist/playbooks/task-closeout.md +45 -0
  38. package/dist/playbooks/task-delegation.md +44 -0
  39. package/dist/playbooks/task-driving.md +43 -0
  40. package/dist/playbooks/task-planning.md +47 -0
  41. package/dist/playbooks/task-recurring.md +42 -0
  42. package/dist/playbooks/task-repair.md +43 -0
  43. package/dist/runtime/bootstrap.d.ts +7 -11
  44. package/dist/runtime/bootstrap.js +24 -55
  45. package/dist/runtime/delivery.js +4 -3
  46. package/dist/runtime/dingtalk.js +15 -14
  47. package/dist/runtime/durable-dispatch.d.ts +2 -0
  48. package/dist/runtime/durable-dispatch.js +29 -1
  49. package/dist/runtime/event-commands.js +4 -4
  50. package/dist/runtime/events.d.ts +1 -1
  51. package/dist/runtime/events.js +5 -5
  52. package/dist/runtime/task-commands.js +9 -4
  53. package/dist/runtime/task-driver.js +12 -14
  54. package/dist/security/config.js +2 -1
  55. package/dist/security/network.js +9 -2
  56. package/dist/security/path-guard.js +12 -24
  57. package/dist/security/types.d.ts +0 -1
  58. package/dist/shared/jsonl-appender.js +2 -1
  59. package/dist/shared/task-ledger.d.ts +9 -1
  60. package/dist/shared/task-ledger.js +28 -14
  61. package/dist/shared/text-utils.d.ts +1 -0
  62. package/dist/shared/text-utils.js +3 -0
  63. package/dist/subagents/discovery.js +3 -2
  64. package/dist/subagents/tool.d.ts +2 -3
  65. package/dist/subagents/tool.js +9 -24
  66. package/dist/tasks/control.js +2 -1
  67. package/dist/tasks/verification.js +2 -1
  68. package/dist/tools/bash.d.ts +1 -1
  69. package/dist/tools/bash.js +3 -5
  70. package/dist/tools/command-optimizer.d.ts +1 -1
  71. package/dist/tools/command-optimizer.js +4 -6
  72. package/dist/tools/config.js +4 -3
  73. package/dist/tools/edit.d.ts +1 -1
  74. package/dist/tools/edit.js +0 -0
  75. package/dist/tools/event-manage.d.ts +0 -1
  76. package/dist/tools/event-manage.js +9 -14
  77. package/dist/tools/grep.d.ts +1 -1
  78. package/dist/tools/grep.js +4 -6
  79. package/dist/tools/index.d.ts +1 -3
  80. package/dist/tools/index.js +1 -4
  81. package/dist/tools/read.d.ts +1 -1
  82. package/dist/tools/read.js +1 -2
  83. package/dist/tools/registry.d.ts +1 -2
  84. package/dist/tools/registry.js +3 -10
  85. package/dist/tools/skill-manage.d.ts +0 -1
  86. package/dist/tools/skill-manage.js +7 -14
  87. package/dist/tools/task-manage.d.ts +0 -1
  88. package/dist/tools/task-manage.js +18 -16
  89. package/dist/tools/write-content.d.ts +1 -1
  90. package/dist/tools/write-content.js +0 -1
  91. package/dist/tools/write.d.ts +1 -1
  92. package/dist/tui/app.d.ts +0 -2
  93. package/dist/tui/app.js +12 -7
  94. package/dist/tui/cli.d.ts +0 -2
  95. package/dist/tui/cli.js +3 -25
  96. package/dist/tui/turn-controller.d.ts +7 -3
  97. package/dist/tui/turn-controller.js +9 -6
  98. package/dist/web/client.js +2 -1
  99. package/package.json +2 -2
  100. package/dist/sandbox.d.ts +0 -42
@@ -24,12 +24,6 @@ const skillManageSchema = Type.Object({
24
24
  find: Type.Optional(Type.String({ description: "Exact text to replace when action is patch." })),
25
25
  replace: Type.Optional(Type.String({ description: "Replacement text when action is patch." })),
26
26
  });
27
- function toWorkspacePath(options, hostPath) {
28
- if (hostPath.startsWith(options.workspaceDir)) {
29
- return `${options.workspacePath}${hostPath.slice(options.workspaceDir.length)}`;
30
- }
31
- return hostPath;
32
- }
33
27
  function isNodeError(error) {
34
28
  return error instanceof Error && "code" in error;
35
29
  }
@@ -88,7 +82,7 @@ export async function listWorkspaceSkills(options) {
88
82
  summaries.push({
89
83
  name,
90
84
  description: extractDescription(content),
91
- path: `${options.workspacePath}/skills/${name}/SKILL.md`,
85
+ path: `${options.workspaceDir}/skills/${name}/SKILL.md`,
92
86
  warning: validation.ok ? undefined : validation.error,
93
87
  });
94
88
  }
@@ -138,7 +132,7 @@ export async function manageWorkspaceSkill(options, request) {
138
132
  return {
139
133
  action: "create",
140
134
  name: request.name,
141
- path: toWorkspacePath(options, skillPath),
135
+ path: skillPath,
142
136
  bytesWritten: Buffer.byteLength(content, "utf-8"),
143
137
  requiresResourceRefresh: true,
144
138
  notice: `已沉淀:创建 workspace skill \`${request.name}\`。`,
@@ -158,7 +152,7 @@ export async function manageWorkspaceSkill(options, request) {
158
152
  return {
159
153
  action: "write_file",
160
154
  name: request.name,
161
- path: toWorkspacePath(options, targetPath),
155
+ path: targetPath,
162
156
  bytesWritten: Buffer.byteLength(content, "utf-8"),
163
157
  requiresResourceRefresh: true,
164
158
  notice: `已沉淀:更新 workspace skill \`${request.name}\` 的支持文件。`,
@@ -178,7 +172,7 @@ export async function manageWorkspaceSkill(options, request) {
178
172
  return {
179
173
  action: "patch",
180
174
  name: request.name,
181
- path: toWorkspacePath(options, targetPath),
175
+ path: targetPath,
182
176
  bytesWritten: Buffer.byteLength(nextContent, "utf-8"),
183
177
  requiresResourceRefresh: true,
184
178
  notice: `已沉淀:更新 workspace skill \`${request.name}\`。`,
@@ -187,17 +181,16 @@ export async function manageWorkspaceSkill(options, request) {
187
181
  async function viewWorkspaceSkill(options, name, filePath) {
188
182
  const skillDir = resolveSkillPath(options.workspaceDir, name);
189
183
  const targetPath = filePath ? resolveSkillSupportingFile(skillDir, filePath) : join(skillDir, "SKILL.md");
190
- const workspacePath = toWorkspacePath(options, targetPath);
191
184
  const content = await readFile(targetPath, "utf-8");
192
185
  // Cap with the shared truncation limits so a large supporting file cannot flood context.
193
186
  const truncation = truncateHead(content);
194
187
  let body = truncation.content;
195
188
  if (truncation.truncated) {
196
- body += `\n\n[Truncated at ${formatSize(DEFAULT_MAX_BYTES)}. Use the read tool on ${workspacePath} to page through the rest.]`;
189
+ body += `\n\n[Truncated at ${formatSize(DEFAULT_MAX_BYTES)}. Use the read tool on ${targetPath} to page through the rest.]`;
197
190
  }
198
191
  return {
199
- content: [{ type: "text", text: `Skill: ${name}\nPath: ${workspacePath}\n\n${body}` }],
200
- details: { kind: "skill_manage", action: "view", name, path: workspacePath, truncated: truncation.truncated },
192
+ content: [{ type: "text", text: `Skill: ${name}\nPath: ${targetPath}\n\n${body}` }],
193
+ details: { kind: "skill_manage", action: "view", name, path: targetPath, truncated: truncation.truncated },
201
194
  };
202
195
  }
203
196
  export function createSkillManageTool(options) {
@@ -80,7 +80,6 @@ export interface TaskManageRequest {
80
80
  }
81
81
  export interface TaskManageToolOptions {
82
82
  workspaceDir: string;
83
- workspacePath: string;
84
83
  channelDir: string;
85
84
  channelId: string;
86
85
  /** Project checkout whose artifact state an independent verifier binds to. */
@@ -57,7 +57,9 @@ const taskManageSchema = Type.Object({
57
57
  id: Type.Optional(Type.String({ description: "Task id (filename without .md). Required for create/progress/set/done." })),
58
58
  title: Type.Optional(Type.String({ description: "Required for create: task title used as the H1 heading." })),
59
59
  goal: Type.Optional(Type.String({ description: "Required for create: concise task goal." })),
60
- dod: Type.Optional(Type.String({ description: "Required for create: acceptance criteria / definition of done." })),
60
+ dod: Type.Optional(Type.String({
61
+ description: 'Required for create: acceptance criteria as Markdown checklist items, one per line, e.g. "- [ ] <criterion>". Plain prose or a numbered list without checkboxes is rejected — candidate/done can only verify items that are checkable.',
62
+ })),
61
63
  manual: Type.Optional(Type.String({ description: "Optional for create: initial operating steps or checklist." })),
62
64
  verificationPlan: Type.Optional(Type.String({ description: "Optional for create: deterministic checks the verifier must perform." })),
63
65
  control: Type.Optional(taskControlSchema),
@@ -92,12 +94,6 @@ function parseAction(action) {
92
94
  }
93
95
  throw new Error("Unsupported task action. Use create, progress, set, verify, done, cancel, start-cycle, or list.");
94
96
  }
95
- function toWorkspacePath(options, hostPath) {
96
- if (hostPath.startsWith(options.workspaceDir)) {
97
- return `${options.workspacePath}${hostPath.slice(options.workspaceDir.length)}`;
98
- }
99
- return hostPath;
100
- }
101
97
  function tasksDir(options) {
102
98
  return join(options.channelDir, "tasks");
103
99
  }
@@ -283,13 +279,16 @@ async function createTask(options, request) {
283
279
  throw new Error(`Archived task "${id}" already exists; choose a new id or restore it manually first.`);
284
280
  }
285
281
  const { fields, body } = renderTaskSkeleton(request);
282
+ const badDod = uncheckedTaskAcceptanceItems(body).find((item) => item.startsWith("DoD has no checklist items"));
283
+ if (badDod)
284
+ throw new Error(badDod);
286
285
  await validateTaskRelations(options, id, fields);
287
286
  await mkdir(dir, { recursive: true });
288
287
  await writeFileAtomically(taskPath, renderTaskFile(fields, body));
289
288
  return {
290
289
  action: "create",
291
290
  id,
292
- path: toWorkspacePath(options, taskPath),
291
+ path: taskPath,
293
292
  status: fields.status,
294
293
  notice: `已创建任务 \`${id}\`(status: ${fields.status})。`,
295
294
  };
@@ -298,7 +297,7 @@ async function createTask(options, request) {
298
297
  * On close-out, keep only the task's recurring cadence event
299
298
  * (`task.<channelId>.<id>.schedule`) and delete every other task-owned event.
300
299
  *
301
- * A task may also own temporary periodic events (for example an agentmux idle sensor).
300
+ * A task may also own temporary periodic sensor/check-in events.
302
301
  * Those are lifecycle check-ins, not proof that the task itself is recurring, so they
303
302
  * must not prevent a one-shot task from being archived.
304
303
  */
@@ -347,7 +346,7 @@ async function setTask(options, request) {
347
346
  return {
348
347
  action: "set",
349
348
  id,
350
- path: toWorkspacePath(options, taskPath),
349
+ path: taskPath,
351
350
  status: nextFields.status,
352
351
  notice: `已更新任务 \`${id}\`(status: ${nextFields.status}${nextFields.wake ? `, wake: ${nextFields.wake}` : ""})。`,
353
352
  };
@@ -359,6 +358,9 @@ async function progressTask(options, request) {
359
358
  const note = requiredField(request.note, "note", "progress");
360
359
  const taskPath = join(tasksDir(options), `${id}.md`);
361
360
  const { fields, body } = await readTaskDocument(taskPath, id);
361
+ if (["done", "cancelled", "escalated", "paused"].includes(fields.status)) {
362
+ throw new Error(`Task "${id}" is ${fields.status} and cannot be progressed.`);
363
+ }
362
364
  const nextFields = applySet(fields, request);
363
365
  await validateTaskRelations(options, id, nextFields);
364
366
  if (nextFields.control) {
@@ -378,7 +380,7 @@ async function progressTask(options, request) {
378
380
  return {
379
381
  action: "progress",
380
382
  id,
381
- path: toWorkspacePath(options, taskPath),
383
+ path: taskPath,
382
384
  status: nextFields.status,
383
385
  notice: `已记录任务 \`${id}\` 的进展(status: ${nextFields.status}${nextFields.wake ? `, wake: ${nextFields.wake}` : ""})。`,
384
386
  };
@@ -412,7 +414,7 @@ async function candidateTask(options, request) {
412
414
  return {
413
415
  action: "candidate",
414
416
  id,
415
- path: toWorkspacePath(options, taskPath),
417
+ path: taskPath,
416
418
  status: "verifying",
417
419
  notice: `任务 \`${id}\` 已进入独立验收队列;driver 将安排 verifier。`,
418
420
  };
@@ -461,7 +463,7 @@ async function verifyTask(options, request) {
461
463
  return {
462
464
  action: "verify",
463
465
  id,
464
- path: toWorkspacePath(options, task.path),
466
+ path: task.path,
465
467
  status: task.fields.status,
466
468
  notice: `任务 \`${id}\` 独立验收结果:${attestation.verdict.toUpperCase()}(run: ${runId})。`,
467
469
  };
@@ -538,7 +540,7 @@ async function doneTask(options, request) {
538
540
  return {
539
541
  action: "done",
540
542
  id,
541
- path: toWorkspacePath(options, finalPath),
543
+ path: finalPath,
542
544
  status: "done",
543
545
  archived,
544
546
  deletedEvents: deleted,
@@ -571,7 +573,7 @@ async function cancelTask(options, request) {
571
573
  return {
572
574
  action: "cancel",
573
575
  id,
574
- path: toWorkspacePath(options, finalPath),
576
+ path: finalPath,
575
577
  status: "cancelled",
576
578
  archived: true,
577
579
  deletedEvents: deleted,
@@ -597,7 +599,7 @@ async function startCycleTask(options, request) {
597
599
  return {
598
600
  action: "start-cycle",
599
601
  id,
600
- path: toWorkspacePath(options, taskPath),
602
+ path: taskPath,
601
603
  status: "in-progress",
602
604
  notice: `已开启周期任务 \`${id}\` 的新周期 \`${cycleId}\`。`,
603
605
  };
@@ -1,4 +1,4 @@
1
- import type { Executor } from "../sandbox.js";
1
+ import type { Executor } from "../executor.js";
2
2
  import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
3
3
  export declare function writeContent(executor: Executor, path: string, content: string, signal: AbortSignal | undefined, options?: {
4
4
  createParentDir?: boolean;
@@ -16,7 +16,6 @@ export async function writeContent(executor, path, content, signal, options) {
16
16
  const securityConfig = options?.securityConfig ?? DEFAULT_SECURITY_CONFIG;
17
17
  const securityContext = options?.securityContext ?? {
18
18
  workspaceDir: process.cwd(),
19
- workspacePath: process.cwd(),
20
19
  cwd: process.cwd(),
21
20
  };
22
21
  if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
@@ -1,6 +1,6 @@
1
1
  import type { AgentTool } from "@earendil-works/pi-agent-core";
2
2
  import { Type } from "typebox";
3
- import type { Executor } from "../sandbox.js";
3
+ import type { Executor } from "../executor.js";
4
4
  import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
5
5
  declare const writeSchema: Type.TObject<{
6
6
  label: Type.TString;
package/dist/tui/app.d.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { type BootstrapIO, type BootstrapPaths } from "../runtime/bootstrap.js";
2
- import type { SandboxConfig } from "../sandbox.js";
3
2
  export interface TuiAppOptions {
4
- sandbox: SandboxConfig;
5
3
  channel?: string;
6
4
  /** One-shot, non-interactive run: process a single prompt then exit. */
7
5
  print?: boolean;
package/dist/tui/app.js CHANGED
@@ -44,7 +44,6 @@ function safeUserName() {
44
44
  export async function runTuiApp(options) {
45
45
  const io = options.io ?? console;
46
46
  const paths = options.paths ?? DEFAULT_BOOTSTRAP_PATHS;
47
- const { sandbox } = options;
48
47
  const channelId = resolveChannelId(options.channel, io);
49
48
  // The pi-tui frontend owns stdout; the plain frontend prints only the final
50
49
  // answer. Either way the human-readable console log sink would corrupt output,
@@ -53,15 +52,15 @@ export async function runTuiApp(options) {
53
52
  log.setConsoleLoggingEnabled(false);
54
53
  // Transport-neutral init. Unlike the DingTalk path, the TUI ignores
55
54
  // channelTemplateCreated (it needs no channel.json) and shares app services
56
- // (settings, diagnostics, sandbox check) with bootstrap via prepareAppServices.
55
+ // (settings, diagnostics) with bootstrap via prepareAppServices.
57
56
  printBootstrapSummary(bootstrapAppHome(paths), io, paths);
58
- const { settingsManager } = await prepareAppServices(sandbox, paths, io);
57
+ const { settingsManager } = prepareAppServices(paths);
59
58
  log.configureLogging(settingsManager.getLoggingSettings());
60
- log.logStartup(paths.workspaceDir, sandbox.type === "host" ? "host" : `docker:${sandbox.container}`);
59
+ log.logStartup(paths.workspaceDir);
61
60
  const channelDir = ensureChannelDir(paths.workspaceDir, channelId);
62
61
  ensureChannelMemoryFilesSync(channelDir);
63
62
  const store = new ChannelStore({ workingDir: paths.workspaceDir });
64
- const runner = getOrCreateRunner(sandbox, channelId, channelDir, {
63
+ const runner = getOrCreateRunner(channelId, channelDir, {
65
64
  appHomeDir: paths.appHomeDir,
66
65
  authConfigPath: paths.authConfigPath,
67
66
  modelsConfigPath: paths.modelsConfigPath,
@@ -89,8 +88,14 @@ export async function runTuiApp(options) {
89
88
  renderHelp: () => renderBuiltInHelp(),
90
89
  renderUsage: (args) => renderUsageReport(getUsageLedger(), channelId, parseUsageMode(args), new Date()),
91
90
  runEvents: (args) => handleEventsCommand({ args, workspaceDir: paths.workspaceDir, historyPath: paths.eventHistoryPath }),
92
- runTasks: (args) => handleTasksCommand({ args, channelDir, workspaceDir: paths.workspaceDir, channelId }),
93
- statusInfo: { version: readCliVersion(), sandbox, startedAt: Date.now() },
91
+ runTasks: (args) => handleTasksCommand({
92
+ args,
93
+ channelDir,
94
+ workspaceDir: paths.workspaceDir,
95
+ channelId,
96
+ approver: safeUserName(),
97
+ }),
98
+ statusInfo: { version: readCliVersion(), startedAt: Date.now() },
94
99
  });
95
100
  try {
96
101
  if (options.print) {
package/dist/tui/cli.d.ts CHANGED
@@ -3,11 +3,9 @@
3
3
  * (`parseTuiArgs`) so it can be unit-tested; `runTui` wires it to `runTuiApp`.
4
4
  */
5
5
  import { type BootstrapIO } from "../runtime/bootstrap.js";
6
- import { type SandboxConfig } from "../sandbox.js";
7
6
  export type ParsedTui = {
8
7
  kind: "run";
9
8
  channel?: string;
10
- sandbox: SandboxConfig;
11
9
  print: boolean;
12
10
  quiet: boolean;
13
11
  plain: boolean;
package/dist/tui/cli.js CHANGED
@@ -2,13 +2,11 @@
2
2
  * `pipiclaw tui` CLI: argument parsing and entry. Parsing is a pure function
3
3
  * (`parseTuiArgs`) so it can be unit-tested; `runTui` wires it to `runTuiApp`.
4
4
  */
5
- import { BootstrapExitError, readCliVersion } from "../runtime/bootstrap.js";
6
- import { parseSandboxArg, SandboxConfigError } from "../sandbox.js";
5
+ import { readCliVersion } from "../runtime/bootstrap.js";
7
6
  import { runTuiApp } from "./app.js";
8
7
  /** Parse `pipiclaw tui` arguments (everything after the `tui` subcommand). */
9
8
  export function parseTuiArgs(args) {
10
9
  let channel;
11
- let sandbox = { type: "host" };
12
10
  let print = false;
13
11
  let quiet = false;
14
12
  let plain = false;
@@ -22,13 +20,6 @@ export function parseTuiArgs(args) {
22
20
  else if (arg.startsWith("--channel=")) {
23
21
  channel = arg.slice("--channel=".length);
24
22
  }
25
- else if (arg === "--sandbox") {
26
- sandbox = parseSandboxArg(args[index + 1] ?? "");
27
- index += 1;
28
- }
29
- else if (arg.startsWith("--sandbox=")) {
30
- sandbox = parseSandboxArg(arg.slice("--sandbox=".length));
31
- }
32
23
  else if (arg === "--print" || arg === "-p") {
33
24
  print = true;
34
25
  }
@@ -48,7 +39,7 @@ export function parseTuiArgs(args) {
48
39
  positional.push(arg);
49
40
  }
50
41
  }
51
- return { kind: "run", channel, sandbox, print, quiet, plain, positional };
42
+ return { kind: "run", channel, print, quiet, plain, positional };
52
43
  }
53
44
  function printTuiHelp(io) {
54
45
  io.log("Usage: pipiclaw tui [options] [prompt]");
@@ -64,8 +55,6 @@ function printTuiHelp(io) {
64
55
  io.log("Options:");
65
56
  io.log(" --channel <id> Channel to attach to (default: tui_local).");
66
57
  io.log(" Use dm_<staffId> to share a DingTalk conversation's memory.");
67
- io.log(" --sandbox=host Run tools on host (default)");
68
- io.log(" --sandbox=docker:<name> Run tools in a Docker container");
69
58
  io.log(" --print, -p One-shot: run [prompt] (or stdin), print the answer, exit");
70
59
  io.log(" --quiet, -q Plain mode: print only the final answer");
71
60
  io.log(" --plain Force the plain frontend (no full-screen UI)");
@@ -81,17 +70,7 @@ async function readStdin() {
81
70
  return Buffer.concat(chunks).toString("utf8");
82
71
  }
83
72
  export async function runTui(argv, io = console) {
84
- let parsed;
85
- try {
86
- parsed = parseTuiArgs(argv.slice(3));
87
- }
88
- catch (err) {
89
- if (err instanceof SandboxConfigError) {
90
- io.error(`Error: ${err.message}`);
91
- throw new BootstrapExitError(1);
92
- }
93
- throw err;
94
- }
73
+ const parsed = parseTuiArgs(argv.slice(3));
95
74
  if (parsed.kind === "help") {
96
75
  printTuiHelp(io);
97
76
  return;
@@ -105,7 +84,6 @@ export async function runTui(argv, io = console) {
105
84
  initialPrompt = (await readStdin()).trim() || undefined;
106
85
  }
107
86
  await runTuiApp({
108
- sandbox: parsed.sandbox,
109
87
  channel: parsed.channel,
110
88
  print: parsed.print,
111
89
  quiet: parsed.quiet,
@@ -8,7 +8,6 @@
8
8
  */
9
9
  import type { AgentRunner } from "../agent/types.js";
10
10
  import type { ChannelStore } from "../runtime/store.js";
11
- import type { SandboxConfig } from "../sandbox.js";
12
11
  import type { Frontend } from "./renderer.js";
13
12
  import { type DeliveryTraits } from "./terminal-context.js";
14
13
  export interface TurnControllerDeps {
@@ -26,7 +25,6 @@ export interface TurnControllerDeps {
26
25
  /** Static bits the status renderer needs alongside the live run state. */
27
26
  statusInfo: {
28
27
  version: string;
29
- sandbox: SandboxConfig;
30
28
  startedAt: number;
31
29
  };
32
30
  /** Injectable clock for deterministic Ctrl-C timing in tests. */
@@ -48,7 +46,13 @@ export declare class TurnController {
48
46
  constructor(deps: TurnControllerDeps);
49
47
  /** Interactive mode: wire input, run an optional first prompt, resolve on exit. */
50
48
  startInteractive(initialPrompt?: string): Promise<void>;
51
- /** One-shot mode: run a single prompt (if any) then shut down. */
49
+ /**
50
+ * One-shot mode: run a single prompt (if any) then shut down.
51
+ *
52
+ * Routed through the same `dispatch()` as interactive input so built-in
53
+ * slash commands (`/tasks`, `/events`, `/status`, ...) resolve zero-LLM here
54
+ * too, instead of falling through to the model as a plain message.
55
+ */
52
56
  runOnce(prompt?: string): Promise<void>;
53
57
  /** Test/observability hook. */
54
58
  isRunning(): boolean;
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import { renderStatus } from "../agent/status-render.js";
10
10
  import * as log from "../log.js";
11
+ import { errorMessage } from "../shared/text-utils.js";
11
12
  import { bold, dim } from "./colors.js";
12
13
  import { dispatch } from "./commands.js";
13
14
  import { createTerminalContext } from "./terminal-context.js";
@@ -15,9 +16,6 @@ const SHUTDOWN_ABORT_WAIT_MS = 5000;
15
16
  // Cap the exit-time memory flush so a slow/stuck LLM consolidation can't trap
16
17
  // the user in a non-responsive process. Memory may be partially saved on timeout.
17
18
  const SHUTDOWN_FLUSH_WAIT_MS = 20_000;
18
- function errorMessage(err) {
19
- return err instanceof Error ? err.message : String(err);
20
- }
21
19
  export class TurnController {
22
20
  constructor(deps) {
23
21
  this.running = false;
@@ -40,7 +38,6 @@ export class TurnController {
40
38
  state: { running: this.running, currentTaskText: this.currentTaskText, runner: this.deps.runner },
41
39
  version: deps.statusInfo.version,
42
40
  uptimeMs: this.now() - deps.statusInfo.startedAt,
43
- sandbox: deps.statusInfo.sandbox,
44
41
  }),
45
42
  };
46
43
  }
@@ -57,11 +54,17 @@ export class TurnController {
57
54
  this.submit(initialPrompt);
58
55
  return this.exitPromise;
59
56
  }
60
- /** One-shot mode: run a single prompt (if any) then shut down. */
57
+ /**
58
+ * One-shot mode: run a single prompt (if any) then shut down.
59
+ *
60
+ * Routed through the same `dispatch()` as interactive input so built-in
61
+ * slash commands (`/tasks`, `/events`, `/status`, ...) resolve zero-LLM here
62
+ * too, instead of falling through to the model as a plain message.
63
+ */
61
64
  async runOnce(prompt) {
62
65
  const trimmed = prompt?.trim();
63
66
  if (trimmed) {
64
- this.beginTurn(trimmed);
67
+ await this.processSubmit(trimmed);
65
68
  await this.currentTurn;
66
69
  }
67
70
  await this.shutdown();
@@ -6,6 +6,7 @@ import { getProxyForUrl } from "proxy-from-env";
6
6
  import { SocksProxyAgent } from "socks-proxy-agent";
7
7
  import { logSecurityEvent } from "../security/logger.js";
8
8
  import { NetworkGuardError, validateNetworkTarget, validateRedirectTarget } from "../security/network.js";
9
+ import { errorMessage } from "../shared/text-utils.js";
9
10
  export const WEB_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Pipiclaw/0.5";
10
11
  const agentCache = new Map();
11
12
  function normalizeHeaders(headers) {
@@ -177,7 +178,7 @@ export class WebHttpClient {
177
178
  };
178
179
  }
179
180
  catch (error) {
180
- throw new Error(`Expected JSON response from ${options.url}, got invalid JSON: ${error instanceof Error ? error.message : String(error)}`);
181
+ throw new Error(`Expected JSON response from ${options.url}, got invalid JSON: ${errorMessage(error)}`);
181
182
  }
182
183
  }
183
184
  async requestText(options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.8.0",
3
+ "version": "0.8.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": {
@@ -22,7 +22,7 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true }); require('node:fs').rmSync('coverage', { recursive: true, force: true });\"",
25
- "build": "tsc -p tsconfig.build.json && node -e \"require('node:fs').chmodSync('dist/main.js', 0o755)\"",
25
+ "build": "tsc -p tsconfig.build.json && node -e \"const fs = require('node:fs'); const src='src/playbooks'; const dst='dist/playbooks'; fs.mkdirSync(dst,{recursive:true}); for (const f of fs.readdirSync(dst)) { if (f.endsWith('.md') || f === 'scripts') fs.rmSync(dst+'/'+f,{recursive:true,force:true}); } for (const f of fs.readdirSync(src)) { if (f.endsWith('.md')) fs.copyFileSync(src+'/'+f,dst+'/'+f); } fs.chmodSync('dist/main.js', 0o755)\"",
26
26
  "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
27
27
  "lint": "biome check .",
28
28
  "typecheck": "tsc --noEmit -p tsconfig.json",
package/dist/sandbox.d.ts DELETED
@@ -1,42 +0,0 @@
1
- export type SandboxConfig = {
2
- type: "host";
3
- } | {
4
- type: "docker";
5
- container: string;
6
- };
7
- /**
8
- * Error raised when sandbox configuration is invalid or the target sandbox is not
9
- * usable. Thrown instead of calling process.exit so callers (bootstrap) decide how
10
- * to surface it and the functions stay testable.
11
- */
12
- export declare class SandboxConfigError extends Error {
13
- constructor(message: string);
14
- }
15
- export declare function parseSandboxArg(value: string): SandboxConfig;
16
- export declare function validateSandbox(config: SandboxConfig): Promise<void>;
17
- /**
18
- * Create an executor that runs commands either on host or in Docker container
19
- */
20
- export declare function createExecutor(config: SandboxConfig): Executor;
21
- export interface Executor {
22
- /**
23
- * Execute a bash command
24
- */
25
- exec(command: string, options?: ExecOptions): Promise<ExecResult>;
26
- /**
27
- * Get the workspace path prefix for this executor
28
- * Host: returns the actual path
29
- * Docker: returns /workspace
30
- */
31
- getWorkspacePath(hostPath: string): string;
32
- }
33
- export interface ExecOptions {
34
- timeout?: number;
35
- signal?: AbortSignal;
36
- stdin?: string;
37
- }
38
- export interface ExecResult {
39
- stdout: string;
40
- stderr: string;
41
- code: number;
42
- }