@oyasmi/pipiclaw 0.8.3 → 0.8.5

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 (63) hide show
  1. package/README.md +2 -1
  2. package/dist/agent/channel-runner.d.ts +45 -3
  3. package/dist/agent/channel-runner.js +200 -77
  4. package/dist/agent/commands.d.ts +2 -2
  5. package/dist/agent/commands.js +10 -1
  6. package/dist/agent/maintenance-context.d.ts +23 -0
  7. package/dist/agent/maintenance-context.js +72 -0
  8. package/dist/agent/prompt/builder.d.ts +32 -0
  9. package/dist/agent/prompt/builder.js +252 -0
  10. package/dist/agent/prompt/extension.d.ts +22 -0
  11. package/dist/agent/prompt/extension.js +24 -0
  12. package/dist/agent/prompt/manifest.d.ts +51 -0
  13. package/dist/agent/prompt/manifest.js +84 -0
  14. package/dist/agent/prompt/resources.d.ts +18 -0
  15. package/dist/agent/prompt/resources.js +61 -0
  16. package/dist/agent/prompt/sections.d.ts +39 -0
  17. package/dist/agent/prompt/sections.js +267 -0
  18. package/dist/agent/prompt/types.d.ts +110 -0
  19. package/dist/agent/prompt/types.js +11 -0
  20. package/dist/agent/status-render.d.ts +3 -7
  21. package/dist/agent/status-render.js +5 -5
  22. package/dist/agent/types.d.ts +33 -0
  23. package/dist/agent/workspace-resources.d.ts +25 -13
  24. package/dist/agent/workspace-resources.js +28 -41
  25. package/dist/index.d.ts +7 -2
  26. package/dist/index.js +6 -2
  27. package/dist/memory/transcript.js +7 -6
  28. package/dist/models/utils.d.ts +3 -1
  29. package/dist/models/utils.js +8 -0
  30. package/dist/playbooks/catalog.d.ts +22 -1
  31. package/dist/playbooks/catalog.js +57 -4
  32. package/dist/playbooks/event-scheduling.md +2 -0
  33. package/dist/playbooks/memory-and-learning.md +2 -0
  34. package/dist/playbooks/runtime-orientation.md +1 -0
  35. package/dist/playbooks/task-closeout.md +3 -1
  36. package/dist/playbooks/task-delegation.md +3 -1
  37. package/dist/playbooks/task-driving.md +2 -0
  38. package/dist/playbooks/task-planning.md +2 -0
  39. package/dist/playbooks/task-recurring.md +2 -0
  40. package/dist/playbooks/task-repair.md +3 -1
  41. package/dist/runtime/bootstrap.js +77 -93
  42. package/dist/runtime/channel-queue.d.ts +17 -0
  43. package/dist/runtime/channel-queue.js +50 -0
  44. package/dist/runtime/dingtalk.d.ts +1 -0
  45. package/dist/runtime/dingtalk.js +6 -42
  46. package/dist/runtime/task-driver.d.ts +2 -0
  47. package/dist/runtime/task-driver.js +3 -26
  48. package/dist/runtime/workspace-templates.d.ts +11 -0
  49. package/dist/runtime/workspace-templates.js +51 -0
  50. package/dist/settings.d.ts +0 -3
  51. package/dist/settings.js +0 -3
  52. package/dist/tools/config.d.ts +6 -22
  53. package/dist/tools/config.js +0 -58
  54. package/dist/tools/index.js +1 -4
  55. package/dist/tools/registry.d.ts +3 -3
  56. package/dist/tools/registry.js +4 -6
  57. package/dist/tui/commands.d.ts +1 -0
  58. package/dist/tui/commands.js +2 -0
  59. package/dist/tui/turn-controller.d.ts +1 -3
  60. package/dist/tui/turn-controller.js +17 -18
  61. package/package.json +1 -1
  62. package/dist/agent/prompt-builder.d.ts +0 -12
  63. package/dist/agent/prompt-builder.js +0 -71
@@ -0,0 +1,50 @@
1
+ import * as log from "../log.js";
2
+ import { errorMessage } from "../shared/text-utils.js";
3
+ /**
4
+ * The per-channel turn serialization point: a channel processes one inbound
5
+ * message at a time; later arrivals wait here. This is runtime policy, not a
6
+ * transport detail — DingTalk consumes it via `DingTalkBot`; busy-state itself
7
+ * is owned by the runner's turn state machine (`AgentRunner.beginTurn`).
8
+ */
9
+ export class ChannelQueue {
10
+ constructor() {
11
+ this.queue = [];
12
+ this.processing = false;
13
+ this.stopped = false;
14
+ }
15
+ enqueue(work) {
16
+ if (this.stopped)
17
+ return;
18
+ this.queue.push(work);
19
+ this.processNext();
20
+ }
21
+ size() {
22
+ return this.queue.length;
23
+ }
24
+ async processNext() {
25
+ if (this.processing || this.stopped || this.queue.length === 0)
26
+ return;
27
+ this.processing = true;
28
+ const work = this.queue.shift();
29
+ try {
30
+ await work();
31
+ }
32
+ catch (err) {
33
+ log.logWarning("Queue error", errorMessage(err));
34
+ }
35
+ this.processing = false;
36
+ this.processNext();
37
+ }
38
+ stop() {
39
+ this.stopped = true;
40
+ this.queue = [];
41
+ }
42
+ // Drop not-yet-started work without disabling the queue. Used by /stop so a
43
+ // burst of queued messages does not keep running after the user asked to halt.
44
+ // The in-flight item (already shifted) is unaffected; the caller aborts it.
45
+ clearPending() {
46
+ const dropped = this.queue.length;
47
+ this.queue = [];
48
+ return dropped;
49
+ }
50
+ }
@@ -46,6 +46,7 @@ export interface DingTalkHandler {
46
46
  handleTasksCommand(event: DingTalkEvent, bot: DingTalkBot, args: string): Promise<void>;
47
47
  handleStatusCommand(event: DingTalkEvent, bot: DingTalkBot): Promise<void>;
48
48
  handleUsageCommand(event: DingTalkEvent, bot: DingTalkBot, args: string): Promise<void>;
49
+ handleContextCommand(event: DingTalkEvent, bot: DingTalkBot, args: string): Promise<void>;
49
50
  handleBusyMessage(event: DingTalkEvent, bot: DingTalkBot, mode: BusyMessageMode, queueText: string): Promise<BusyMessageResult>;
50
51
  }
51
52
  export declare class DingTalkBot {
@@ -16,6 +16,9 @@ import * as log from "../log.js";
16
16
  import { errorMessage } from "../shared/text-utils.js";
17
17
  import { isRecord } from "../shared/type-guards.js";
18
18
  import { getChannelDir } from "./channel-paths.js";
19
+ // Turn serialization is runtime policy; the queue lives in its own module and
20
+ // this transport only consumes it.
21
+ import { ChannelQueue } from "./channel-queue.js";
19
22
  const RESPONSE_MODE_VALUES = [
20
23
  "full_progress_then_plain_final",
21
24
  "rolling_progress_then_plain_final",
@@ -58,48 +61,6 @@ export function normalizeResponseMode(value) {
58
61
  }
59
62
  throw new Error('Invalid `responseMode`: expected "full_progress_then_plain_final", "rolling_progress_then_plain_final", or "final_card_only".');
60
63
  }
61
- class ChannelQueue {
62
- constructor() {
63
- this.queue = [];
64
- this.processing = false;
65
- this.stopped = false;
66
- }
67
- enqueue(work) {
68
- if (this.stopped)
69
- return;
70
- this.queue.push(work);
71
- this.processNext();
72
- }
73
- size() {
74
- return this.queue.length;
75
- }
76
- async processNext() {
77
- if (this.processing || this.stopped || this.queue.length === 0)
78
- return;
79
- this.processing = true;
80
- const work = this.queue.shift();
81
- try {
82
- await work();
83
- }
84
- catch (err) {
85
- log.logWarning("Queue error", errorMessage(err));
86
- }
87
- this.processing = false;
88
- this.processNext();
89
- }
90
- stop() {
91
- this.stopped = true;
92
- this.queue = [];
93
- }
94
- // Drop not-yet-started work without disabling the queue. Used by /stop so a
95
- // burst of queued messages does not keep running after the user asked to halt.
96
- // The in-flight item (already shifted) is unaffected; the caller aborts it.
97
- clearPending() {
98
- const dropped = this.queue.length;
99
- this.queue = [];
100
- return dropped;
101
- }
102
- }
103
64
  // ============================================================================
104
65
  // Constants
105
66
  // ============================================================================
@@ -1007,6 +968,9 @@ export class DingTalkBot {
1007
968
  case "usage":
1008
969
  await this.handler.handleUsageCommand(event, this, builtInCommand.args);
1009
970
  return;
971
+ case "context":
972
+ await this.handler.handleContextCommand(event, this, builtInCommand.args);
973
+ return;
1010
974
  }
1011
975
  }
1012
976
  // Session commands (/model, /new, …) and unknown slash commands cannot
@@ -7,6 +7,8 @@ export interface TaskDriverOptions {
7
7
  isChannelActive: (channelId: string) => boolean;
8
8
  dispatch: (event: DingTalkEvent) => boolean | Promise<boolean>;
9
9
  getSettings: () => PipiclawTaskDriverSettings;
10
+ /** Master autonomy switch (`tools.tasks.enabled`); re-read every tick. Defaults to on. */
11
+ isEnabled?: () => boolean;
10
12
  intervalMs?: number;
11
13
  }
12
14
  export declare function discoverTaskChannels(workspaceDir: string, knownChannelIds?: Iterable<string>): Promise<string[]>;
@@ -1,15 +1,12 @@
1
- import { readdir, readFile } from "node:fs/promises";
1
+ import { readdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
3
  import * as log from "../log.js";
4
4
  import { PLAYBOOKS_DIR } from "../paths.js";
5
- import { taskEventName } from "../shared/task-events.js";
6
5
  import { readActiveTasks } from "../shared/task-ledger.js";
7
6
  import { errorMessage } from "../shared/text-utils.js";
8
7
  import { taskBudgetViolation } from "../tasks/control.js";
9
8
  import { claimTaskAttempt, dependencyState, escalateTask, releaseTaskAttemptClaim } from "../tasks/store.js";
10
- import { parseScheduledEventContent } from "./events.js";
11
9
  const DEFAULT_SCAN_INTERVAL_MS = 60_000;
12
- const LEGACY_CHECKIN_HANDOFF_GRACE_MS = 2 * 60_000;
13
10
  const CHANNEL_ID_PATTERN = /^(dm|group)_[A-Za-z0-9._:-]+$/;
14
11
  function isChannelId(value) {
15
12
  return CHANNEL_ID_PATTERN.test(value);
@@ -59,20 +56,6 @@ function isEligible(attempt, fingerprint, nowMs, settings) {
59
56
  const delayMinutes = changed || !attempt.accepted ? settings.continuationDelayMinutes : settings.stalledRetryMinutes;
60
57
  return nowMs - attempt.atMs >= delayMinutes * 60_000;
61
58
  }
62
- async function hasLiveLegacyCheckin(workspaceDir, channelId, taskId, nowMs) {
63
- const name = taskEventName(channelId, taskId, "checkin");
64
- const path = join(workspaceDir, "events", `${name}.json`);
65
- try {
66
- const event = parseScheduledEventContent(await readFile(path, "utf-8"), `${name}.json`);
67
- if (event.type !== "one-shot")
68
- return false;
69
- const atMs = new Date(event.at).getTime();
70
- return Number.isFinite(atMs) && atMs >= nowMs - LEGACY_CHECKIN_HANDOFF_GRACE_MS;
71
- }
72
- catch {
73
- return false;
74
- }
75
- }
76
59
  export function createTaskDriverEvent(channelId, entry, nowMs) {
77
60
  const verification = entry.frontmatter.control?.verification;
78
61
  const verificationInstruction = entry.frontmatter.status === "verifying"
@@ -161,9 +144,9 @@ export class TaskDriver {
161
144
  this.timer = null;
162
145
  }
163
146
  async runOnce(now = new Date()) {
164
- const settings = this.options.getSettings();
165
- if (!settings.enabled || this.running)
147
+ if (this.options.isEnabled?.() === false || this.running)
166
148
  return;
149
+ const settings = this.options.getSettings();
167
150
  this.running = true;
168
151
  try {
169
152
  const channels = await discoverTaskChannels(this.options.workspaceDir, this.options.getKnownChannelIds?.());
@@ -228,12 +211,6 @@ export class TaskDriver {
228
211
  }
229
212
  if (!entry || dispatched >= settings.maxDispatchesPerTick)
230
213
  continue;
231
- // Upgrade compatibility: while a legacy task-owned one-shot is still
232
- // about to deliver this same wake, let it own the handoff. Once it is
233
- // consumed (or stale for >2m), the native driver becomes the recovery path.
234
- if (await hasLiveLegacyCheckin(this.options.workspaceDir, channelId, entry.id, now.getTime())) {
235
- continue;
236
- }
237
214
  const key = attemptKey(channelId, entry.id);
238
215
  let fingerprint = await taskFingerprint(channelDir, entry);
239
216
  if (!isEligible(this.attempts.get(key), fingerprint, now.getTime(), settings))
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Bootstrap templates for the two workspace files the system prompt injects.
3
+ *
4
+ * They live here rather than inside bootstrap.ts because the prompt builder must
5
+ * recognize an untouched template and skip it: a file that still says "replace
6
+ * this" carries no user intent and only wastes prompt budget (spec 025 §6.9).
7
+ */
8
+ export declare const DEFAULT_SOUL = "# SOUL.md\n\nConfigure Pipiclaw's identity, voice, and communication style here.\n\nSuggested sections:\n\n- Who the assistant is\n- Default language\n- Tone and personality\n- Reply style\n- Formatting preferences\n\nExample topics you may want to define:\n\n- \"Answer in Chinese by default.\"\n- \"Be concise and direct.\"\n- \"Prefer Markdown.\"\n- \"Act as an engineering assistant for our team.\"\n\nReplace this template with your actual identity prompt.\n";
9
+ export declare const DEFAULT_AGENTS = "# AGENTS.md\n\nConfigure Pipiclaw's operating rules here.\n\nThis file should define behavior and workflow. Identity, tone, and personality belong in `SOUL.md`.\n\nSuggested sections:\n\n- Tool usage policy\n- Security constraints\n- Scheduling/reminder policy\n- Project-specific workflows\n- Things the assistant must always or never do\n\nReplace this template with your actual operating instructions.\n";
10
+ /** True when the file is byte-equivalent (modulo trailing whitespace) to the shipped template. */
11
+ export declare function isDefaultWorkspaceTemplate(content: string, template: string): boolean;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Bootstrap templates for the two workspace files the system prompt injects.
3
+ *
4
+ * They live here rather than inside bootstrap.ts because the prompt builder must
5
+ * recognize an untouched template and skip it: a file that still says "replace
6
+ * this" carries no user intent and only wastes prompt budget (spec 025 §6.9).
7
+ */
8
+ export const DEFAULT_SOUL = `# SOUL.md
9
+
10
+ Configure Pipiclaw's identity, voice, and communication style here.
11
+
12
+ Suggested sections:
13
+
14
+ - Who the assistant is
15
+ - Default language
16
+ - Tone and personality
17
+ - Reply style
18
+ - Formatting preferences
19
+
20
+ Example topics you may want to define:
21
+
22
+ - "Answer in Chinese by default."
23
+ - "Be concise and direct."
24
+ - "Prefer Markdown."
25
+ - "Act as an engineering assistant for our team."
26
+
27
+ Replace this template with your actual identity prompt.
28
+ `;
29
+ export const DEFAULT_AGENTS = `# AGENTS.md
30
+
31
+ Configure Pipiclaw's operating rules here.
32
+
33
+ This file should define behavior and workflow. Identity, tone, and personality belong in \`SOUL.md\`.
34
+
35
+ Suggested sections:
36
+
37
+ - Tool usage policy
38
+ - Security constraints
39
+ - Scheduling/reminder policy
40
+ - Project-specific workflows
41
+ - Things the assistant must always or never do
42
+
43
+ Replace this template with your actual operating instructions.
44
+ `;
45
+ function normalize(content) {
46
+ return content.replace(/\r/g, "").trim();
47
+ }
48
+ /** True when the file is byte-equivalent (modulo trailing whitespace) to the shipped template. */
49
+ export function isDefaultWorkspaceTemplate(content, template) {
50
+ return normalize(content) === normalize(template);
51
+ }
@@ -61,13 +61,10 @@ export interface PipiclawMemoryRecallSettings {
61
61
  rerankWithModel: boolean | "auto";
62
62
  }
63
63
  export interface PipiclawTaskDigestSettings {
64
- enabled: boolean;
65
64
  maxTasks: number;
66
65
  maxChars: number;
67
66
  }
68
67
  export interface PipiclawTaskDriverSettings {
69
- /** Native runtime wake-up for actionable task-ledger entries. */
70
- enabled: boolean;
71
68
  /** Earliest continuation after a task changed during its previous run. */
72
69
  continuationDelayMinutes: number;
73
70
  /** Retry delay when a dispatched task made no observable ledger progress. */
package/dist/settings.js CHANGED
@@ -32,7 +32,6 @@ const DEFAULT_MEMORY_RECALL = {
32
32
  // Cheap and high-value: reading a handful of task frontmatters and always surfacing
33
33
  // the in-flight agenda is worth more than the tokens it costs, so it defaults on.
34
34
  const DEFAULT_TASK_DIGEST = {
35
- enabled: true,
36
35
  maxTasks: 8,
37
36
  maxChars: 1000,
38
37
  };
@@ -40,7 +39,6 @@ const DEFAULT_TASK_DIGEST = {
40
39
  // that requires users to install a heartbeat event and sensor script. A changed
41
40
  // task can continue promptly; an unchanged task backs off to avoid token loops.
42
41
  const DEFAULT_TASK_DRIVER = {
43
- enabled: true,
44
42
  continuationDelayMinutes: 5,
45
43
  stalledRetryMinutes: 60,
46
44
  maxDispatchesPerTick: 4,
@@ -204,7 +202,6 @@ export class PipiclawSettingsManager {
204
202
  ? Math.min(20, Math.max(1, Math.floor(configured.maxDispatchesPerTick)))
205
203
  : DEFAULT_TASK_DRIVER.maxDispatchesPerTick;
206
204
  return {
207
- enabled: configured.enabled !== false,
208
205
  continuationDelayMinutes,
209
206
  stalledRetryMinutes,
210
207
  maxDispatchesPerTick,
@@ -25,31 +25,15 @@ export interface PipiclawWebToolsConfig {
25
25
  export interface PipiclawToolsConfig {
26
26
  tools: {
27
27
  web: PipiclawWebToolsConfig;
28
- memory: {
29
- sessionSearch: {
30
- enabled: boolean;
31
- };
32
- save: {
33
- enabled: boolean;
34
- };
35
- };
36
- skills: {
37
- manage: {
38
- enabled: boolean;
39
- };
40
- };
41
- events: {
42
- enabled: boolean;
43
- };
28
+ /**
29
+ * Master switch for the autonomous long-running task mechanism: gates the
30
+ * `task_manage` tool, the native TaskDriver, and the per-turn task digest
31
+ * together. Core capabilities (read/bash/edit/write/grep, memory, skills,
32
+ * events, background jobs) are always on and have no switches.
33
+ */
44
34
  tasks: {
45
35
  enabled: boolean;
46
36
  };
47
- grep: {
48
- enabled: boolean;
49
- };
50
- jobs: {
51
- enabled: boolean;
52
- };
53
37
  bashInterceptor: {
54
38
  enabled: boolean;
55
39
  };
@@ -26,31 +26,9 @@ export const DEFAULT_TOOLS_CONFIG = {
26
26
  defaultExtractMode: "markdown",
27
27
  },
28
28
  },
29
- memory: {
30
- sessionSearch: {
31
- enabled: true,
32
- },
33
- save: {
34
- enabled: true,
35
- },
36
- },
37
- skills: {
38
- manage: {
39
- enabled: true,
40
- },
41
- },
42
- events: {
43
- enabled: true,
44
- },
45
29
  tasks: {
46
30
  enabled: true,
47
31
  },
48
- grep: {
49
- enabled: true,
50
- },
51
- jobs: {
52
- enabled: true,
53
- },
54
32
  bashInterceptor: {
55
33
  enabled: true,
56
34
  },
@@ -100,15 +78,7 @@ function mergeToolsConfig(source, configPath, diagnostics) {
100
78
  }
101
79
  const tools = isRecord(source.tools) ? source.tools : {};
102
80
  const web = isRecord(tools.web) ? tools.web : {};
103
- const memory = isRecord(tools.memory) ? tools.memory : {};
104
- const sessionSearch = isRecord(memory.sessionSearch) ? memory.sessionSearch : {};
105
- const memorySave = isRecord(memory.save) ? memory.save : {};
106
- const skills = isRecord(tools.skills) ? tools.skills : {};
107
- const manage = isRecord(skills.manage) ? skills.manage : {};
108
- const events = isRecord(tools.events) ? tools.events : {};
109
81
  const tasks = isRecord(tools.tasks) ? tools.tasks : {};
110
- const grep = isRecord(tools.grep) ? tools.grep : {};
111
- const jobs = isRecord(tools.jobs) ? tools.jobs : {};
112
82
  const bashInterceptor = isRecord(tools.bashInterceptor) ? tools.bashInterceptor : {};
113
83
  const rtk = isRecord(tools.rtk) ? tools.rtk : {};
114
84
  const search = isRecord(web.search) ? web.search : {};
@@ -175,37 +145,9 @@ function mergeToolsConfig(source, configPath, diagnostics) {
175
145
  : DEFAULT_TOOLS_CONFIG.tools.web.fetch.defaultExtractMode,
176
146
  },
177
147
  },
178
- memory: {
179
- sessionSearch: {
180
- enabled: typeof sessionSearch.enabled === "boolean"
181
- ? sessionSearch.enabled
182
- : DEFAULT_TOOLS_CONFIG.tools.memory.sessionSearch.enabled,
183
- },
184
- save: {
185
- enabled: typeof memorySave.enabled === "boolean"
186
- ? memorySave.enabled
187
- : DEFAULT_TOOLS_CONFIG.tools.memory.save.enabled,
188
- },
189
- },
190
- skills: {
191
- manage: {
192
- enabled: typeof manage.enabled === "boolean"
193
- ? manage.enabled
194
- : DEFAULT_TOOLS_CONFIG.tools.skills.manage.enabled,
195
- },
196
- },
197
- events: {
198
- enabled: typeof events.enabled === "boolean" ? events.enabled : DEFAULT_TOOLS_CONFIG.tools.events.enabled,
199
- },
200
148
  tasks: {
201
149
  enabled: typeof tasks.enabled === "boolean" ? tasks.enabled : DEFAULT_TOOLS_CONFIG.tools.tasks.enabled,
202
150
  },
203
- grep: {
204
- enabled: typeof grep.enabled === "boolean" ? grep.enabled : DEFAULT_TOOLS_CONFIG.tools.grep.enabled,
205
- },
206
- jobs: {
207
- enabled: typeof jobs.enabled === "boolean" ? jobs.enabled : DEFAULT_TOOLS_CONFIG.tools.jobs.enabled,
208
- },
209
151
  bashInterceptor: {
210
152
  enabled: typeof bashInterceptor.enabled === "boolean"
211
153
  ? bashInterceptor.enabled
@@ -25,10 +25,7 @@ export function createPipiclawTools(options) {
25
25
  webConfig: toolsConfig.tools.web,
26
26
  toolsConfig,
27
27
  rtkEnabled: toolsConfig.tools.rtk.enabled,
28
- // Background jobs are opt-in; when off, bash `async` errors and the job tool is not registered.
29
- jobManager: toolsConfig.tools.jobs.enabled
30
- ? getChannelJobManager(options.channelId, options.executor)
31
- : undefined,
28
+ jobManager: getChannelJobManager(options.channelId, options.executor),
32
29
  getCurrentModel: options.getCurrentModel,
33
30
  getAvailableModels: options.getAvailableModels,
34
31
  resolveApiKey: options.resolveApiKey,
@@ -24,15 +24,15 @@ export interface ToolBuildContext {
24
24
  workspaceDir: string;
25
25
  /** Main set: `toolsConfig.tools.web`; sub-agent set: the sub-agent's own webConfig. */
26
26
  webConfig?: PipiclawWebToolsConfig;
27
- /** Present only on the main path; gates session_search / memory_manage / skills. */
27
+ /** Present only on the main path; gates task_manage and the bash interceptor. */
28
28
  toolsConfig?: PipiclawToolsConfig;
29
29
  /** Sub-agent set passes its per-invocation bash timeout; the main set relies on the built-in default. */
30
30
  bashDefaultTimeoutSeconds?: number;
31
31
  /** Gates the bash tool's rtk command optimizer (`tools.rtk.enabled`). Threaded to both sets. */
32
32
  rtkEnabled?: boolean;
33
33
  /**
34
- * Present only on the main path when `tools.jobs.enabled` is on. Enables bash `async` and the
35
- * `job` tool. The sub-agent set never supplies it, so sub-agents get neither.
34
+ * Present only on the main path. Enables bash `async` and the `job` tool.
35
+ * The sub-agent set never supplies it, so sub-agents get neither.
36
36
  */
37
37
  jobManager?: ChannelJobManager;
38
38
  getCurrentModel?: () => Model<Api>;
@@ -64,7 +64,6 @@ export const TOOL_REGISTRY = [
64
64
  name: "grep",
65
65
  promptHint: "Search file contents with a regex; grouped, paginated, token-bounded — prefer over bash grep",
66
66
  availableToSubagents: true,
67
- enabledBy: (ctx) => ctx.toolsConfig?.tools.grep.enabled !== false,
68
67
  create: (ctx) => createGrepTool(ctx.executor, fileToolOptions(ctx)),
69
68
  },
70
69
  {
@@ -102,7 +101,6 @@ export const TOOL_REGISTRY = [
102
101
  name: "session_search",
103
102
  promptHint: "Search current-channel cold transcript storage for older conversation details",
104
103
  availableToSubagents: false,
105
- enabledBy: (ctx) => ctx.toolsConfig?.tools.memory.sessionSearch.enabled !== false,
106
104
  create: (ctx) => createSessionSearchTool({
107
105
  channelId: ctx.channelId,
108
106
  channelDir: ctx.channelDir,
@@ -115,7 +113,6 @@ export const TOOL_REGISTRY = [
115
113
  name: "memory_manage",
116
114
  promptHint: "Save a durable fact, search stored memory on demand, or forget an entry — when the user asks",
117
115
  availableToSubagents: false,
118
- enabledBy: (ctx) => ctx.toolsConfig?.tools.memory.save.enabled !== false,
119
116
  create: (ctx) => createMemoryManageTool({
120
117
  channelId: ctx.channelId,
121
118
  channelDir: ctx.channelDir,
@@ -129,14 +126,12 @@ export const TOOL_REGISTRY = [
129
126
  name: "skill_manage",
130
127
  promptHint: "List, view, create, or maintain workspace-level procedural memory in skills/",
131
128
  availableToSubagents: false,
132
- enabledBy: (ctx) => ctx.toolsConfig?.tools.skills.manage.enabled !== false,
133
129
  create: (ctx) => createSkillManageTool({ workspaceDir: ctx.workspaceDir }),
134
130
  },
135
131
  {
136
132
  name: "event_manage",
137
133
  promptHint: "Create/update/delete validated one-shot reminders, periodic cadences, and preAction-gated sensors",
138
134
  availableToSubagents: false,
139
- enabledBy: (ctx) => ctx.toolsConfig?.tools.events.enabled !== false,
140
135
  create: (ctx) => createEventManageTool({
141
136
  workspaceDir: ctx.workspaceDir,
142
137
  channelId: ctx.channelId,
@@ -147,6 +142,8 @@ export const TOOL_REGISTRY = [
147
142
  name: "task_manage",
148
143
  promptHint: "Create, checkpoint, govern, verify, complete, cancel, or list persistent tasks",
149
144
  availableToSubagents: false,
145
+ // tools.tasks is the master switch for the whole autonomous long-running task
146
+ // mechanism; the TaskDriver and per-turn task digest honor the same flag.
150
147
  enabledBy: (ctx) => ctx.toolsConfig?.tools.tasks.enabled !== false,
151
148
  create: (ctx) => createTaskManageTool({
152
149
  workspaceDir: ctx.workspaceDir,
@@ -159,7 +156,8 @@ export const TOOL_REGISTRY = [
159
156
  name: "job",
160
157
  promptHint: "Inspect/poll/cancel background bash jobs started with bash async:true",
161
158
  availableToSubagents: false,
162
- // Present only when a job manager was supplied (tools.jobs.enabled on the main path).
159
+ // Present only when a job manager was supplied (always on the main path,
160
+ // never for sub-agents).
163
161
  enabledBy: (ctx) => ctx.jobManager !== undefined,
164
162
  create: (ctx) => createJobTool({ jobManager: req(ctx.jobManager, "jobManager") }),
165
163
  },
@@ -35,6 +35,7 @@ export type DispatchOutcome =
35
35
  export interface DispatchDeps {
36
36
  renderHelp(): string;
37
37
  renderStatus(): string;
38
+ renderContext(args: string): string;
38
39
  renderUsage(args: string): string;
39
40
  runEvents(args: string): Promise<string>;
40
41
  runTasks(args: string): Promise<string>;
@@ -31,6 +31,8 @@ export async function dispatch(input, deps) {
31
31
  return { kind: "reply", text: deps.renderHelp() };
32
32
  case "status":
33
33
  return { kind: "reply", text: deps.renderStatus() };
34
+ case "context":
35
+ return { kind: "reply", text: deps.renderContext(command.args) };
34
36
  case "usage":
35
37
  return { kind: "reply", text: deps.renderUsage(command.args) };
36
38
  case "events":
@@ -34,8 +34,6 @@ export declare class TurnController {
34
34
  private readonly deps;
35
35
  private readonly now;
36
36
  private readonly dispatchDeps;
37
- private running;
38
- private currentTaskText;
39
37
  private currentTurn;
40
38
  private readonly followups;
41
39
  private submitChain;
@@ -54,7 +52,7 @@ export declare class TurnController {
54
52
  * too, instead of falling through to the model as a plain message.
55
53
  */
56
54
  runOnce(prompt?: string): Promise<void>;
57
- /** Test/observability hook. */
55
+ /** Test/observability hook. Turn state is owned by the runner. */
58
56
  isRunning(): boolean;
59
57
  submit(text: string): void;
60
58
  private processSubmit;