@oyasmi/pipiclaw 0.7.7 → 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 (114) hide show
  1. package/README.md +23 -2
  2. package/dist/agent/channel-runner.d.ts +4 -4
  3. package/dist/agent/channel-runner.js +25 -23
  4. package/dist/agent/commands.js +7 -2
  5. package/dist/agent/job-manager.d.ts +5 -5
  6. package/dist/agent/prompt-builder.d.ts +3 -13
  7. package/dist/agent/prompt-builder.js +49 -159
  8. package/dist/agent/run-queue.js +2 -1
  9. package/dist/agent/runner-factory.d.ts +1 -2
  10. package/dist/agent/runner-factory.js +2 -2
  11. package/dist/agent/status-render.d.ts +0 -7
  12. package/dist/agent/status-render.js +8 -3
  13. package/dist/agent/types.d.ts +2 -0
  14. package/dist/agent/workspace-resources.d.ts +1 -1
  15. package/dist/agent/workspace-resources.js +3 -15
  16. package/dist/executor.d.ts +20 -0
  17. package/dist/{sandbox.js → executor.js} +3 -95
  18. package/dist/index.d.ts +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/log.d.ts +1 -1
  21. package/dist/log.js +1 -2
  22. package/dist/memory/files.js +0 -0
  23. package/dist/memory/lifecycle.js +6 -5
  24. package/dist/memory/maintenance-jobs.d.ts +0 -1
  25. package/dist/memory/maintenance-jobs.js +2 -2
  26. package/dist/memory/maintenance-state.js +2 -1
  27. package/dist/memory/post-turn-review.d.ts +0 -1
  28. package/dist/memory/post-turn-review.js +4 -4
  29. package/dist/memory/scheduler.d.ts +0 -1
  30. package/dist/memory/scheduler.js +2 -2
  31. package/dist/memory/session.js +2 -2
  32. package/dist/memory/task-digest.js +17 -0
  33. package/dist/paths.d.ts +2 -0
  34. package/dist/paths.js +11 -0
  35. package/dist/playbooks/catalog.d.ts +9 -0
  36. package/dist/playbooks/catalog.js +44 -0
  37. package/dist/playbooks/event-scheduling.md +43 -0
  38. package/dist/playbooks/memory-and-learning.md +45 -0
  39. package/dist/playbooks/runtime-orientation.md +48 -0
  40. package/dist/playbooks/task-closeout.md +45 -0
  41. package/dist/playbooks/task-delegation.md +44 -0
  42. package/dist/playbooks/task-driving.md +43 -0
  43. package/dist/playbooks/task-planning.md +47 -0
  44. package/dist/playbooks/task-recurring.md +42 -0
  45. package/dist/playbooks/task-repair.md +43 -0
  46. package/dist/runtime/bootstrap.d.ts +12 -11
  47. package/dist/runtime/bootstrap.js +81 -57
  48. package/dist/runtime/delivery.js +4 -3
  49. package/dist/runtime/dingtalk.d.ts +2 -0
  50. package/dist/runtime/dingtalk.js +15 -14
  51. package/dist/runtime/durable-dispatch.d.ts +30 -0
  52. package/dist/runtime/durable-dispatch.js +172 -0
  53. package/dist/runtime/event-commands.js +4 -4
  54. package/dist/runtime/events.d.ts +5 -3
  55. package/dist/runtime/events.js +17 -13
  56. package/dist/runtime/task-commands.d.ts +6 -0
  57. package/dist/runtime/task-commands.js +292 -6
  58. package/dist/runtime/task-driver.d.ts +32 -0
  59. package/dist/runtime/task-driver.js +268 -0
  60. package/dist/security/config.js +2 -1
  61. package/dist/security/network.js +9 -2
  62. package/dist/security/path-guard.js +12 -24
  63. package/dist/security/types.d.ts +0 -1
  64. package/dist/settings.d.ts +12 -0
  65. package/dist/settings.js +30 -0
  66. package/dist/shared/jsonl-appender.js +2 -1
  67. package/dist/shared/task-ledger.d.ts +35 -0
  68. package/dist/shared/task-ledger.js +229 -15
  69. package/dist/shared/text-utils.d.ts +1 -0
  70. package/dist/shared/text-utils.js +3 -0
  71. package/dist/subagents/discovery.js +3 -2
  72. package/dist/subagents/tool.d.ts +15 -3
  73. package/dist/subagents/tool.js +194 -17
  74. package/dist/tasks/artifact-subject.d.ts +6 -0
  75. package/dist/tasks/artifact-subject.js +29 -0
  76. package/dist/tasks/control.d.ts +83 -0
  77. package/dist/tasks/control.js +293 -0
  78. package/dist/tasks/store.d.ts +32 -0
  79. package/dist/tasks/store.js +142 -0
  80. package/dist/tasks/verification.d.ts +23 -0
  81. package/dist/tasks/verification.js +69 -0
  82. package/dist/tools/bash.d.ts +1 -1
  83. package/dist/tools/bash.js +3 -5
  84. package/dist/tools/command-optimizer.d.ts +1 -1
  85. package/dist/tools/command-optimizer.js +4 -6
  86. package/dist/tools/config.js +4 -3
  87. package/dist/tools/edit.d.ts +1 -1
  88. package/dist/tools/edit.js +0 -0
  89. package/dist/tools/event-manage.d.ts +0 -1
  90. package/dist/tools/event-manage.js +9 -14
  91. package/dist/tools/grep.d.ts +1 -1
  92. package/dist/tools/grep.js +4 -6
  93. package/dist/tools/index.d.ts +1 -3
  94. package/dist/tools/index.js +1 -4
  95. package/dist/tools/read.d.ts +1 -1
  96. package/dist/tools/read.js +1 -2
  97. package/dist/tools/registry.d.ts +2 -3
  98. package/dist/tools/registry.js +5 -11
  99. package/dist/tools/skill-manage.d.ts +0 -1
  100. package/dist/tools/skill-manage.js +7 -14
  101. package/dist/tools/task-manage.d.ts +37 -4
  102. package/dist/tools/task-manage.js +398 -39
  103. package/dist/tools/write-content.d.ts +1 -1
  104. package/dist/tools/write-content.js +0 -1
  105. package/dist/tools/write.d.ts +1 -1
  106. package/dist/tui/app.d.ts +0 -2
  107. package/dist/tui/app.js +12 -7
  108. package/dist/tui/cli.d.ts +0 -2
  109. package/dist/tui/cli.js +3 -25
  110. package/dist/tui/turn-controller.d.ts +7 -3
  111. package/dist/tui/turn-controller.js +9 -6
  112. package/dist/web/client.js +2 -1
  113. package/package.json +2 -2
  114. package/dist/sandbox.d.ts +0 -42
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.7.7",
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
- }