@oyasmi/pipiclaw 0.9.0-beta.9 → 0.9.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.
Files changed (40) hide show
  1. package/dist/agent/channel-runner.d.ts +7 -0
  2. package/dist/agent/channel-runner.js +52 -8
  3. package/dist/agent/commands.d.ts +1 -1
  4. package/dist/agent/commands.js +9 -0
  5. package/dist/agent/job-manager.d.ts +20 -0
  6. package/dist/agent/job-manager.js +14 -0
  7. package/dist/agent/turn-recovery.d.ts +72 -0
  8. package/dist/agent/turn-recovery.js +193 -0
  9. package/dist/playbooks/agent-delegation.md +3 -3
  10. package/dist/playbooks/runtime-orientation.md +5 -0
  11. package/dist/runtime/active-session-store.d.ts +42 -0
  12. package/dist/runtime/active-session-store.js +100 -0
  13. package/dist/runtime/bootstrap.js +48 -3
  14. package/dist/runtime/dingtalk.js +2 -1
  15. package/dist/runtime/project-commands.d.ts +16 -0
  16. package/dist/runtime/project-commands.js +112 -0
  17. package/dist/runtime/project-scope-store.d.ts +31 -0
  18. package/dist/runtime/project-scope-store.js +102 -0
  19. package/dist/security/config.js +10 -0
  20. package/dist/security/path-guard.js +34 -9
  21. package/dist/security/project-scope.d.ts +45 -0
  22. package/dist/security/project-scope.js +107 -0
  23. package/dist/security/types.d.ts +20 -2
  24. package/dist/subagents/tool.d.ts +2 -0
  25. package/dist/subagents/tool.js +8 -2
  26. package/dist/tools/bash.js +3 -3
  27. package/dist/tools/edit.js +3 -3
  28. package/dist/tools/grep.js +3 -3
  29. package/dist/tools/index.d.ts +3 -0
  30. package/dist/tools/index.js +7 -2
  31. package/dist/tools/read.js +3 -3
  32. package/dist/tools/registry.js +1 -1
  33. package/dist/tools/send-media.js +2 -2
  34. package/dist/tools/write-content.js +3 -3
  35. package/dist/tui/app.js +47 -1
  36. package/dist/tui/commands.d.ts +1 -0
  37. package/dist/tui/commands.js +2 -0
  38. package/dist/tui/turn-controller.d.ts +1 -0
  39. package/dist/tui/turn-controller.js +1 -0
  40. package/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ import { realpathSync, statSync } from "node:fs";
2
+ import { homedir } from "node:os";
3
+ import { isAbsolute, resolve } from "node:path";
4
+ const DIAGNOSTIC_SOURCE = "security";
5
+ function expandHome(path) {
6
+ if (path === "~")
7
+ return homedir();
8
+ if (path.startsWith("~/"))
9
+ return resolve(homedir(), path.slice(2));
10
+ return path;
11
+ }
12
+ /** Absolute, existing, real directory — or `undefined` if any of that doesn't hold. */
13
+ function canonicalizeRoot(raw) {
14
+ const expanded = expandHome(raw);
15
+ if (!isAbsolute(expanded))
16
+ return undefined;
17
+ try {
18
+ const real = realpathSync(expanded);
19
+ return statSync(real).isDirectory() ? real : undefined;
20
+ }
21
+ catch {
22
+ return undefined;
23
+ }
24
+ }
25
+ function realpathOrResolve(path) {
26
+ try {
27
+ return realpathSync(path);
28
+ }
29
+ catch {
30
+ return resolve(path);
31
+ }
32
+ }
33
+ /**
34
+ * Resolves the app's project-access policy for a fresh runner generation. `startupCwd` is only
35
+ * used as the implicit default when `projectAccess` is configured but omits `defaultRoot` (D3.2
36
+ * row 3) — the unconfigured-compat row (row 1) also uses it, but never persists it as a "chosen"
37
+ * default the way a configured policy's `defaultRoot` is.
38
+ */
39
+ export function resolveProjectAccessPolicy(config, startupCwd) {
40
+ const diagnostics = [];
41
+ const raw = config.projectAccess;
42
+ const fallbackRoot = realpathOrResolve(startupCwd);
43
+ if (!raw) {
44
+ return {
45
+ policy: { defaultRoot: fallbackRoot, allowedRoots: [fallbackRoot] },
46
+ mutable: false,
47
+ configured: false,
48
+ diagnostics,
49
+ };
50
+ }
51
+ const defaultRootRaw = raw.defaultRoot ?? startupCwd;
52
+ const defaultRoot = canonicalizeRoot(defaultRootRaw);
53
+ if (!defaultRoot) {
54
+ diagnostics.push({
55
+ source: DIAGNOSTIC_SOURCE,
56
+ path: "projectAccess.defaultRoot",
57
+ severity: "error",
58
+ message: `${JSON.stringify(defaultRootRaw)} is not an absolute, existing directory; project scope changes are disabled until this is fixed`,
59
+ });
60
+ return {
61
+ policy: { defaultRoot: fallbackRoot, allowedRoots: [fallbackRoot] },
62
+ mutable: false,
63
+ configured: true,
64
+ diagnostics,
65
+ };
66
+ }
67
+ const rawAllowed = raw.allowedRoots && raw.allowedRoots.length > 0 ? raw.allowedRoots : [defaultRootRaw];
68
+ const allowedRoots = new Set([defaultRoot]);
69
+ for (const entry of rawAllowed) {
70
+ const canonical = canonicalizeRoot(entry);
71
+ if (!canonical) {
72
+ diagnostics.push({
73
+ source: DIAGNOSTIC_SOURCE,
74
+ path: "projectAccess.allowedRoots",
75
+ severity: "warning",
76
+ message: `entry ${JSON.stringify(entry)} is not an absolute, existing directory; ignored`,
77
+ });
78
+ continue;
79
+ }
80
+ allowedRoots.add(canonical);
81
+ }
82
+ return {
83
+ policy: { defaultRoot, allowedRoots: [...allowedRoots] },
84
+ mutable: true,
85
+ configured: true,
86
+ diagnostics,
87
+ };
88
+ }
89
+ function withTrailingSlash(path) {
90
+ return path.endsWith("/") ? path : `${path}/`;
91
+ }
92
+ /** Prefix match with a path-separator boundary, so `/repo-ab` is not treated as within `/repo-a`. */
93
+ export function isWithinAllowedRoots(root, policy) {
94
+ return policy.allowedRoots.some((allowed) => root === allowed || root.startsWith(withTrailingSlash(allowed)));
95
+ }
96
+ /** True until a host sandbox injection point exists (D6.3, D9 risk #2) — see `ProjectSandboxStatus`. */
97
+ export function currentProjectSandboxStatus() {
98
+ return {
99
+ level: "application",
100
+ provider: "pipiclaw-path-guard",
101
+ summary: "文件工具被约束在项目目录内;shell 仅设置了 cwd,未受系统沙箱隔离,可通过 cd/绝对路径/子进程逃逸。",
102
+ };
103
+ }
104
+ /** True if `raw` resolves (after `~`-expansion) to an existing directory — used by `/project set` validation. */
105
+ export function resolveExistingDirectory(raw) {
106
+ return canonicalizeRoot(raw);
107
+ }
@@ -24,10 +24,28 @@ export interface SecurityConfig {
24
24
  logBlocked: boolean;
25
25
  logFile?: string;
26
26
  };
27
+ /**
28
+ * Absent (no `projectAccess` key in `security.json` at all) is a distinct, meaningful state
29
+ * from present-with-omitted-fields: absent is the upgrade-compat path (`ProjectScope.boundary`
30
+ * stays `"unbounded"`, `/project set` is disabled); present means the operator has opted into
31
+ * project boundaries (spec 043, D3.2). See `src/security/project-scope.ts` for the resolved,
32
+ * canonicalized policy this raw section feeds into.
33
+ */
34
+ projectAccess?: {
35
+ defaultRoot?: string;
36
+ allowedRoots?: string[];
37
+ };
27
38
  }
28
39
  export interface SecurityRuntimeContext {
29
- workspaceDir: string;
30
- cwd?: string;
40
+ agentWorkspaceDir: string;
41
+ projectRoot?: string;
42
+ /**
43
+ * `"project"`: generic file tools are bounded to `projectRoot`; `security.json`'s configured
44
+ * `readAllow`/`writeAllow` can narrow within it but never widen past it (spec 043, D6.2).
45
+ * `"unbounded"` (the default when omitted, for backward compat): today's global pathGuard
46
+ * defaults — `agentWorkspaceDir` + temp + `homeDir`.
47
+ */
48
+ boundary?: "project" | "unbounded";
31
49
  homeDir?: string;
32
50
  }
33
51
  export interface PathGuardContext extends SecurityRuntimeContext {
@@ -66,6 +66,8 @@ export interface SubAgentToolOptions {
66
66
  executor: Executor;
67
67
  /** Host checkout used as the sub-agent's cwd. Defaults to process.cwd(). */
68
68
  workingDirectory?: string;
69
+ /** Mirrors the parent channel's ProjectScope.boundary onto the sub-agent's own tool set (spec 043, D6.2). */
70
+ projectBoundary?: "project" | "unbounded";
69
71
  getCurrentModel: () => Model<Api>;
70
72
  getAvailableModels: () => Model<Api>[];
71
73
  resolveApiKey: (model: Model<Api>) => Promise<string>;
@@ -138,6 +138,11 @@ function resolveRunWorkingDirectory(requested, options) {
138
138
  if (!existsSync(target) || !statSync(target).isDirectory()) {
139
139
  throw new RecoverableToolError(`workingDirectory "${requested}" is not an existing directory.`);
140
140
  }
141
+ // D6.2: under `boundary: "project"`, an explicit workingDirectory must stay within the parent's
142
+ // ProjectRoot — `resolve(base, trimmed)` alone lets an absolute `trimmed` escape `base` entirely.
143
+ if (options.projectBoundary === "project" && target !== base && !target.startsWith(`${base}/`)) {
144
+ throw new RecoverableToolError(`workingDirectory "${requested}" must be inside the project root (${base}).`);
145
+ }
141
146
  return target;
142
147
  }
143
148
  async function prepareRunContext(runId, params, options) {
@@ -261,8 +266,9 @@ function buildSubagentTools(executor, bashTimeoutSec, options, runContext) {
261
266
  executor,
262
267
  securityConfig,
263
268
  securityContext: {
264
- workspaceDir: options.workspaceDir,
265
- cwd: runContext.workingDirectory,
269
+ agentWorkspaceDir: options.workspaceDir,
270
+ projectRoot: runContext.workingDirectory,
271
+ boundary: options.projectBoundary,
266
272
  },
267
273
  channelId: options.runtimeContext.channelId,
268
274
  channelDir: options.channelDir,
@@ -90,8 +90,8 @@ function formatCommandBlockMessage(command, category, reason, matchedText) {
90
90
  export function createBashTool(executor, options = {}) {
91
91
  const securityConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
92
92
  const securityContext = options.securityContext ?? {
93
- workspaceDir: process.cwd(),
94
- cwd: process.cwd(),
93
+ agentWorkspaceDir: process.cwd(),
94
+ projectRoot: process.cwd(),
95
95
  };
96
96
  return {
97
97
  name: "bash",
@@ -102,7 +102,7 @@ export function createBashTool(executor, options = {}) {
102
102
  if (securityConfig.enabled && securityConfig.commandGuard.enabled) {
103
103
  const guardResult = guardCommand(command, securityConfig.commandGuard);
104
104
  if (!guardResult.allowed) {
105
- await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
105
+ await logSecurityEvent(securityContext.agentWorkspaceDir, securityConfig, {
106
106
  type: "command",
107
107
  tool: "bash",
108
108
  channelId: options.channelId,
@@ -111,8 +111,8 @@ function clampDiffForEcho(diff) {
111
111
  export function createEditTool(executor, options = {}) {
112
112
  const securityConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
113
113
  const securityContext = options.securityContext ?? {
114
- workspaceDir: process.cwd(),
115
- cwd: process.cwd(),
114
+ agentWorkspaceDir: process.cwd(),
115
+ projectRoot: process.cwd(),
116
116
  };
117
117
  // Per-tool-instance counter of consecutive byte-identical no-op edits, keyed by the exact
118
118
  // (path, oldText, newText) payload. A model stuck re-issuing the same no-op edit is chasing a
@@ -128,7 +128,7 @@ export function createEditTool(executor, options = {}) {
128
128
  if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
129
129
  const readGuard = guardPath(path, "read", { ...securityContext, config: securityConfig.pathGuard });
130
130
  if (!readGuard.allowed) {
131
- await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
131
+ await logSecurityEvent(securityContext.agentWorkspaceDir, securityConfig, {
132
132
  type: "path",
133
133
  tool: "edit",
134
134
  channelId: options.channelId,
@@ -134,8 +134,8 @@ function renderFileGroup(file, entries, perFileMatchCap) {
134
134
  export function createGrepTool(executor, options = {}) {
135
135
  const securityConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
136
136
  const securityContext = options.securityContext ?? {
137
- workspaceDir: process.cwd(),
138
- cwd: process.cwd(),
137
+ agentWorkspaceDir: process.cwd(),
138
+ projectRoot: process.cwd(),
139
139
  };
140
140
  return {
141
141
  name: "grep",
@@ -152,7 +152,7 @@ export function createGrepTool(executor, options = {}) {
152
152
  if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
153
153
  const guardResult = guardPath(searchPath, "read", { ...securityContext, config: securityConfig.pathGuard });
154
154
  if (!guardResult.allowed) {
155
- await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
155
+ await logSecurityEvent(securityContext.agentWorkspaceDir, securityConfig, {
156
156
  type: "path",
157
157
  tool: "grep",
158
158
  channelId: options.channelId,
@@ -3,6 +3,7 @@ import type { Api, Model } from "@earendil-works/pi-ai";
3
3
  import type { Executor } from "../executor.js";
4
4
  import type { MemoryCandidateStore } from "../memory/candidates.js";
5
5
  import type { MediaSender } from "../runtime/channel-context.js";
6
+ import type { ProjectScope } from "../security/project-scope.js";
6
7
  import type { SecurityConfig } from "../security/types.js";
7
8
  import type { PipiclawMemoryRecallSettings, PipiclawSessionSearchSettings } from "../settings.js";
8
9
  import { type SubAgentDiscoveryResult } from "../subagents/discovery.js";
@@ -13,6 +14,8 @@ export interface CreatePipiclawToolsOptions {
13
14
  getAvailableModels: () => Model<Api>[];
14
15
  resolveApiKey: (model: Model<Api>) => Promise<string>;
15
16
  workspaceDir: string;
17
+ /** Frozen for this runner generation; bounds generic file tools and sets the shell/subagent cwd (spec 043, D4.2). */
18
+ projectScope: ProjectScope;
16
19
  channelDir: string;
17
20
  channelId: string;
18
21
  getSubAgentDiscovery: () => SubAgentDiscoveryResult;
@@ -13,8 +13,9 @@ export function createPipiclawTools(options) {
13
13
  const securityConfig = withSubAgentsDirWriteDeny(options.securityConfig ?? loadSecurityConfig(APP_HOME_DIR), options.workspaceDir);
14
14
  const toolsConfig = options.toolsConfig ?? loadToolsConfig(APP_HOME_DIR);
15
15
  const securityContext = {
16
- workspaceDir: options.workspaceDir,
17
- cwd: process.cwd(),
16
+ agentWorkspaceDir: options.workspaceDir,
17
+ projectRoot: options.projectScope.projectRoot,
18
+ boundary: options.projectScope.boundary,
18
19
  };
19
20
  // The leaf tools (files, web, memory, skills) come from the single declarative
20
21
  // registry so this set, the sub-agent set, and the prompt hints share one source.
@@ -49,6 +50,10 @@ export function createPipiclawTools(options) {
49
50
  getAvailableModels: options.getAvailableModels,
50
51
  resolveApiKey: options.resolveApiKey,
51
52
  workspaceDir: options.workspaceDir,
53
+ // D6.2: an internal sub-agent defaults to the parent's ProjectRoot; a model-requested
54
+ // explicit workingDirectory is validated (in subagents/tool.ts) to stay within it.
55
+ workingDirectory: options.projectScope.projectRoot,
56
+ projectBoundary: options.projectScope.boundary,
52
57
  channelDir: options.channelDir,
53
58
  getSubAgentDiscovery: options.getSubAgentDiscovery,
54
59
  getMemoryRecallSettings: options.getMemoryRecallSettings,
@@ -93,8 +93,8 @@ function formatPathBlockMessage(resolvedPath, category, reason) {
93
93
  export function createReadTool(executor, options = {}) {
94
94
  const securityConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
95
95
  const securityContext = options.securityContext ?? {
96
- workspaceDir: process.cwd(),
97
- cwd: process.cwd(),
96
+ agentWorkspaceDir: process.cwd(),
97
+ projectRoot: process.cwd(),
98
98
  };
99
99
  return {
100
100
  name: "read",
@@ -105,7 +105,7 @@ export function createReadTool(executor, options = {}) {
105
105
  if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
106
106
  const guardResult = guardPath(path, "read", { ...securityContext, config: securityConfig.pathGuard });
107
107
  if (!guardResult.allowed) {
108
- await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
108
+ await logSecurityEvent(securityContext.agentWorkspaceDir, securityConfig, {
109
109
  type: "path",
110
110
  tool: "read",
111
111
  channelId: options.channelId,
@@ -152,7 +152,7 @@ export const TOOL_REGISTRY = [
152
152
  workspaceDir: ctx.workspaceDir,
153
153
  channelDir: ctx.channelDir,
154
154
  channelId: ctx.channelId,
155
- workingDirectory: ctx.securityContext.cwd,
155
+ workingDirectory: ctx.securityContext.projectRoot,
156
156
  dispatchVerification: ctx.dispatchVerification,
157
157
  }),
158
158
  },
@@ -29,7 +29,7 @@ function formatPathBlockMessage(resolvedPath, category, reason) {
29
29
  */
30
30
  export function createSendMediaTool(executor, options) {
31
31
  const securityConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
32
- const securityContext = options.securityContext ?? { workspaceDir: process.cwd(), cwd: process.cwd() };
32
+ const securityContext = options.securityContext ?? { agentWorkspaceDir: process.cwd(), projectRoot: process.cwd() };
33
33
  return {
34
34
  name: "send_media",
35
35
  label: "send_media",
@@ -41,7 +41,7 @@ export function createSendMediaTool(executor, options) {
41
41
  if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
42
42
  const guardResult = guardPath(path, "read", { ...securityContext, config: securityConfig.pathGuard });
43
43
  if (!guardResult.allowed) {
44
- await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
44
+ await logSecurityEvent(securityContext.agentWorkspaceDir, securityConfig, {
45
45
  type: "path",
46
46
  tool: "send_media",
47
47
  channelId: options.channelId,
@@ -15,13 +15,13 @@ export async function writeContent(executor, path, content, signal, options) {
15
15
  const createParentDir = options?.createParentDir ?? false;
16
16
  const securityConfig = options?.securityConfig ?? DEFAULT_SECURITY_CONFIG;
17
17
  const securityContext = options?.securityContext ?? {
18
- workspaceDir: process.cwd(),
19
- cwd: process.cwd(),
18
+ agentWorkspaceDir: process.cwd(),
19
+ projectRoot: process.cwd(),
20
20
  };
21
21
  if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
22
22
  const guardResult = guardPath(path, "write", { ...securityContext, config: securityConfig.pathGuard });
23
23
  if (!guardResult.allowed) {
24
- await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
24
+ await logSecurityEvent(securityContext.agentWorkspaceDir, securityConfig, {
25
25
  type: "path",
26
26
  tool: options?.toolName ?? "write",
27
27
  channelId: options?.channelId,
package/dist/tui/app.js CHANGED
@@ -9,6 +9,7 @@
9
9
  import { userInfo } from "node:os";
10
10
  import { renderBuiltInHelp } from "../agent/commands.js";
11
11
  import { createRunner } from "../agent/index.js";
12
+ import { channelRunningJobLines } from "../agent/job-manager.js";
12
13
  import * as log from "../log.js";
13
14
  import { ensureChannelMemoryFilesSync } from "../memory/files.js";
14
15
  import { BootstrapExitError, bootstrapAppHome, DEFAULT_BOOTSTRAP_PATHS, printBootstrapSummary, readCliVersion, } from "../runtime/app-home.js";
@@ -16,10 +17,12 @@ import { prepareAppServices } from "../runtime/bootstrap.js";
16
17
  import { ensureChannelDir } from "../runtime/channel-paths.js";
17
18
  import { finalDeliveryOf, progressStyleOf } from "../runtime/dingtalk.js";
18
19
  import { handleEventsCommand } from "../runtime/event-commands.js";
20
+ import { handleProjectCommand } from "../runtime/project-commands.js";
19
21
  import { ChannelStore } from "../runtime/store.js";
20
22
  import { handleSubagentsCommand } from "../runtime/subagent-commands.js";
21
23
  import { handleTasksCommand } from "../runtime/task-commands.js";
22
24
  import { flushSecurityLogs } from "../security/logger.js";
25
+ import { getSubAgentRunManager } from "../subagents/runs.js";
23
26
  import { getUsageLedger } from "../usage/ledger.js";
24
27
  import { parseUsageMode, renderUsageReport } from "../usage/render.js";
25
28
  import { TUI_SLASH_COMMANDS } from "./commands.js";
@@ -42,6 +45,28 @@ async function waitForStorageFlush(task) {
42
45
  });
43
46
  });
44
47
  }
48
+ /**
49
+ * A replaceable `AgentRunner` reference (spec 043, D4.2): `TurnController` holds a single
50
+ * `AgentRunner` for the process's lifetime, but `/project set|reset` needs to dispose the runner
51
+ * built under the old scope and hand the next turn a fresh one built under the new scope. The
52
+ * proxy forwards every call to whichever runner is current, so `TurnController` never needs to
53
+ * know the reference changed.
54
+ */
55
+ function createRunnerSlot(initial) {
56
+ let current = initial;
57
+ const runner = new Proxy({}, {
58
+ get(_target, prop, _receiver) {
59
+ const value = Reflect.get(current, prop);
60
+ return typeof value === "function" ? value.bind(current) : value;
61
+ },
62
+ });
63
+ return {
64
+ runner,
65
+ replace(next) {
66
+ current = next;
67
+ },
68
+ };
69
+ }
45
70
  export function resolveChannelId(raw, io = console) {
46
71
  const channel = raw?.trim() || DEFAULT_CHANNEL_ID;
47
72
  if (!CHANNEL_ID_PATTERN.test(channel)) {
@@ -77,13 +102,15 @@ export async function runTuiApp(options) {
77
102
  const channelDir = ensureChannelDir(paths.workspaceDir, channelId);
78
103
  ensureChannelMemoryFilesSync(channelDir);
79
104
  const store = new ChannelStore({ workingDir: paths.workspaceDir });
80
- const runner = createRunner(channelId, channelDir, {
105
+ const buildRunner = () => createRunner(channelId, channelDir, {
81
106
  appHomeDir: paths.appHomeDir,
82
107
  authConfigPath: paths.authConfigPath,
83
108
  modelsConfigPath: paths.modelsConfigPath,
84
109
  settingsManager,
85
110
  mediaSender: createTerminalMediaSender(io),
86
111
  });
112
+ const runnerSlot = createRunnerSlot(buildRunner());
113
+ const runner = runnerSlot.runner;
87
114
  const tuiSettings = settingsManager.getTuiSettings();
88
115
  const traits = {
89
116
  progressStyle: progressStyleOf(tuiSettings.responseMode),
@@ -114,6 +141,25 @@ export async function runTuiApp(options) {
114
141
  channelId,
115
142
  }),
116
143
  runSubagents: (args) => handleSubagentsCommand({ args, channelId, discovery: runner.getSubAgentDiscoverySnapshot() }),
144
+ runProject: (args) => handleProjectCommand({
145
+ args,
146
+ channelId,
147
+ channelDir,
148
+ appHomeDir: paths.appHomeDir,
149
+ actor: "tui-command",
150
+ isBusy: () => runner.isBusy(),
151
+ listActiveBlockers: () => [
152
+ ...getSubAgentRunManager(channelId)
153
+ .list()
154
+ .filter((record) => record.status === "running")
155
+ .map((record) => `subagent run \`${record.runId}\` (${record.agent})`),
156
+ ...channelRunningJobLines(channelId),
157
+ ],
158
+ onScopeChanged: async () => {
159
+ await runner.dispose();
160
+ runnerSlot.replace(buildRunner());
161
+ },
162
+ }),
117
163
  statusInfo: { version: readCliVersion(), startedAt: Date.now() },
118
164
  });
119
165
  try {
@@ -40,6 +40,7 @@ export interface DispatchDeps {
40
40
  runEvents(args: string): Promise<string>;
41
41
  runTasks(args: string): Promise<string>;
42
42
  runSubagents(args: string): Promise<string>;
43
+ runProject(args: string): Promise<string>;
43
44
  }
44
45
  export declare function dispatch(input: string, deps: DispatchDeps): Promise<DispatchOutcome>;
45
46
  /**
@@ -41,6 +41,8 @@ export async function dispatch(input, deps) {
41
41
  return { kind: "reply", text: await deps.runTasks(command.args) };
42
42
  case "subagents":
43
43
  return { kind: "reply", text: await deps.runSubagents(command.args) };
44
+ case "project":
45
+ return { kind: "reply", text: await deps.runProject(command.args) };
44
46
  case "stop":
45
47
  return { kind: "stop" };
46
48
  case "steer":
@@ -23,6 +23,7 @@ export interface TurnControllerDeps {
23
23
  runEvents: (args: string) => Promise<string>;
24
24
  runTasks: (args: string) => Promise<string>;
25
25
  runSubagents: (args: string) => Promise<string>;
26
+ runProject: (args: string) => Promise<string>;
26
27
  /** Static bits the status renderer needs alongside the live run state. */
27
28
  statusInfo: {
28
29
  version: string;
@@ -36,6 +36,7 @@ export class TurnController {
36
36
  runEvents: deps.runEvents,
37
37
  runTasks: deps.runTasks,
38
38
  runSubagents: deps.runSubagents,
39
+ runProject: deps.runProject,
39
40
  renderContext: (args) => this.deps.runner.renderContextReport(args),
40
41
  renderStatus: () => renderStatus({
41
42
  runner: this.deps.runner,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oyasmi/pipiclaw",
3
- "version": "0.9.0-beta.9",
3
+ "version": "0.9.0",
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": {