@oyasmi/pipiclaw 0.8.9-beta.1 → 0.8.9-beta.2

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 (90) hide show
  1. package/README.md +8 -3
  2. package/dist/agent/channel-runner.d.ts +1 -0
  3. package/dist/agent/channel-runner.js +3 -2
  4. package/dist/agent/effect-ledger.d.ts +11 -0
  5. package/dist/agent/effect-ledger.js +42 -0
  6. package/dist/agent/job-manager.d.ts +90 -13
  7. package/dist/agent/job-manager.js +235 -20
  8. package/dist/agent/prompt/sections.js +11 -2
  9. package/dist/agent/prompt/types.d.ts +7 -1
  10. package/dist/agent/runner-factory.d.ts +7 -0
  11. package/dist/agent/session-events.js +20 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/log.d.ts +6 -0
  14. package/dist/log.js +12 -0
  15. package/dist/memory/consolidation.d.ts +5 -0
  16. package/dist/memory/consolidation.js +35 -147
  17. package/dist/memory/extraction.d.ts +45 -0
  18. package/dist/memory/extraction.js +227 -0
  19. package/dist/memory/lifecycle.js +5 -0
  20. package/dist/memory/maintenance-jobs.js +7 -0
  21. package/dist/memory/post-turn-review.d.ts +3 -1
  22. package/dist/memory/post-turn-review.js +20 -189
  23. package/dist/memory/recall.d.ts +0 -1
  24. package/dist/memory/recall.js +135 -77
  25. package/dist/memory/sidecar-worker.d.ts +7 -0
  26. package/dist/memory/sidecar-worker.js +23 -5
  27. package/dist/paths.d.ts +1 -0
  28. package/dist/paths.js +11 -0
  29. package/dist/playbooks/background-jobs.md +40 -0
  30. package/dist/playbooks/catalog.d.ts +1 -7
  31. package/dist/playbooks/catalog.js +4 -14
  32. package/dist/playbooks/event-scheduling.md +8 -4
  33. package/dist/playbooks/memory-and-learning.md +1 -1
  34. package/dist/playbooks/outbound-media.md +45 -0
  35. package/dist/playbooks/runtime-orientation.md +1 -1
  36. package/dist/playbooks/task-closeout.md +1 -1
  37. package/dist/playbooks/task-delegation.md +10 -4
  38. package/dist/playbooks/task-driving.md +52 -18
  39. package/dist/playbooks/task-planning.md +43 -18
  40. package/dist/runtime/bootstrap.js +24 -3
  41. package/dist/runtime/channel-context.d.ts +33 -0
  42. package/dist/runtime/dingtalk.d.ts +22 -2
  43. package/dist/runtime/dingtalk.js +141 -0
  44. package/dist/runtime/durable-dispatch.d.ts +10 -0
  45. package/dist/runtime/durable-dispatch.js +42 -1
  46. package/dist/runtime/event-validation.d.ts +48 -0
  47. package/dist/runtime/event-validation.js +81 -0
  48. package/dist/runtime/events.d.ts +17 -8
  49. package/dist/runtime/events.js +96 -22
  50. package/dist/runtime/store.d.ts +1 -1
  51. package/dist/runtime/task-driver.d.ts +5 -0
  52. package/dist/runtime/task-driver.js +38 -12
  53. package/dist/settings.d.ts +11 -0
  54. package/dist/settings.js +12 -0
  55. package/dist/shared/recoverable-error.d.ts +26 -0
  56. package/dist/shared/recoverable-error.js +29 -0
  57. package/dist/shared/task-ledger.d.ts +9 -7
  58. package/dist/shared/task-ledger.js +1 -1
  59. package/dist/subagents/builtin/explorer.md +16 -0
  60. package/dist/subagents/builtin/researcher.md +17 -0
  61. package/dist/subagents/builtin/verifier.md +17 -0
  62. package/dist/subagents/discovery.d.ts +17 -3
  63. package/dist/subagents/discovery.js +88 -15
  64. package/dist/subagents/tool.d.ts +21 -1
  65. package/dist/subagents/tool.js +140 -12
  66. package/dist/tasks/transitions.js +3 -2
  67. package/dist/tools/bash.d.ts +2 -0
  68. package/dist/tools/bash.js +18 -5
  69. package/dist/tools/event-manage.js +28 -77
  70. package/dist/tools/index.d.ts +4 -0
  71. package/dist/tools/index.js +7 -2
  72. package/dist/tools/job.js +2 -2
  73. package/dist/tools/memory-manage.js +0 -1
  74. package/dist/tools/registry.d.ts +29 -8
  75. package/dist/tools/registry.js +39 -22
  76. package/dist/tools/send-media.d.ts +28 -0
  77. package/dist/tools/send-media.js +88 -0
  78. package/dist/tools/task-manage/create.js +5 -4
  79. package/dist/tools/task-manage/lifecycle.js +12 -11
  80. package/dist/tools/task-manage/schema.js +2 -1
  81. package/dist/tools/task-manage/shared.js +13 -12
  82. package/dist/tools/task-manage/verification.js +14 -13
  83. package/dist/tools/tool-details.d.ts +44 -0
  84. package/dist/tools/tool-details.js +62 -0
  85. package/dist/tui/app.js +2 -0
  86. package/dist/tui/terminal-media-sender.d.ts +9 -0
  87. package/dist/tui/terminal-media-sender.js +15 -0
  88. package/package.json +2 -2
  89. package/dist/playbooks/task-recurring.md +0 -44
  90. package/dist/playbooks/task-repair.md +0 -45
@@ -102,7 +102,7 @@ export function parseTaskFrontmatter(content) {
102
102
  /**
103
103
  * The single shared judgement: is there work to do on this task right now?
104
104
  * Unreadable frontmatter is fail-open (actionable) so a corrupt ledger surfaces
105
- * rather than being silently skipped — identical to the sensor's behaviour.
105
+ * rather than being silently skipped.
106
106
  */
107
107
  export function isTaskActionable(frontmatter, now) {
108
108
  if (!frontmatter.readable)
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: explorer
3
+ description: Read-only mapping task — locate an implementation, trace a call chain, or produce a structured summary of how something works.
4
+ tools:
5
+ - read
6
+ - bash
7
+ contextMode: isolated
8
+ ---
9
+
10
+ You are a read-only exploration sub-agent. Your job is to map the codebase, not to change it.
11
+
12
+ - Use `read` and `bash` (grep/find/ls, etc.) only. Never attempt to write or edit files — you do not have those tools.
13
+ - Work from the goal, scope and paths given in the task. If they are missing or too vague to act on, say so instead of guessing.
14
+ - Produce a structured summary: what you found, exact file paths and line numbers, and how the pieces connect. Prefer precise pointers over paraphrase.
15
+ - Distinguish what you directly observed in the code from what you inferred.
16
+ - End with a short, direct answer to the question you were asked before any supporting detail.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: researcher
3
+ description: External information gathering with source attribution — use for questions that need current web knowledge rather than repo contents.
4
+ tools:
5
+ - web_search
6
+ - web_fetch
7
+ - read
8
+ contextMode: isolated
9
+ ---
10
+
11
+ You are a research sub-agent gathering external information for the parent agent.
12
+
13
+ - Use `web_search` and `web_fetch` to find current, relevant information; use `read` only for local files the task explicitly points you at.
14
+ - Attribute every non-obvious claim to its source (URL and, where useful, publication/date). Do not present a single source's claim as settled fact.
15
+ - Prefer primary sources over aggregators when both are available.
16
+ - If sources disagree or the answer is genuinely uncertain, say so instead of picking one silently.
17
+ - Summarize findings concisely before listing supporting detail and sources.
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: verifier
3
+ description: Independent, read-only acceptance check for a task's DoD/verification items. Use with purpose=verify.
4
+ tools:
5
+ - read
6
+ - bash
7
+ contextMode: isolated
8
+ thinkingLevel: medium
9
+ ---
10
+
11
+ You are an independent verifier — the checker, not the maker. You did not write the work under review, and your job is to find out whether it actually satisfies its DoD/verification items, not to fix it.
12
+
13
+ - Inspect the task document named in your runtime context and check every DoD/verification item against concrete evidence: read the actual files, run the actual checks (tests, builds, lints) when available.
14
+ - Do not edit or write files. Do not attempt workarounds for failures — report them.
15
+ - Explicitly separate what you observed (command output, file contents) from what you assumed or inferred.
16
+ - If an item cannot be verified with the tools and access you have, say so plainly instead of assuming pass.
17
+ - End your response with exactly one final line: `VERDICT: PASS` or `VERDICT: FAIL`.
@@ -2,9 +2,11 @@ import type { Api, Model } from "@earendil-works/pi-ai";
2
2
  declare const ALLOWED_SUB_AGENT_TOOLS: readonly ["read", "bash", "edit", "write", "web_search", "web_fetch"];
3
3
  declare const ALLOWED_CONTEXT_MODES: readonly ["isolated", "contextual"];
4
4
  declare const ALLOWED_MEMORY_MODES: readonly ["none", "session", "relevant"];
5
+ declare const ALLOWED_THINKING_LEVELS: readonly ["off", "minimal", "low", "medium", "high", "xhigh"];
5
6
  export type SubAgentToolName = (typeof ALLOWED_SUB_AGENT_TOOLS)[number];
6
7
  export type SubAgentContextMode = (typeof ALLOWED_CONTEXT_MODES)[number];
7
8
  export type SubAgentMemoryMode = (typeof ALLOWED_MEMORY_MODES)[number];
9
+ export type SubAgentThinkingLevel = (typeof ALLOWED_THINKING_LEVELS)[number];
8
10
  export interface SubAgentConfig {
9
11
  name: string;
10
12
  description: string;
@@ -19,12 +21,15 @@ export interface SubAgentConfig {
19
21
  contextMode: SubAgentContextMode;
20
22
  memory: SubAgentMemoryMode;
21
23
  paths: string[];
24
+ /** Unset means "apply the purpose-based default at resolution time" (spec 032 D3). */
25
+ thinkingLevel?: SubAgentThinkingLevel;
22
26
  filePath?: string;
23
- source: "predefined" | "inline";
27
+ source: "predefined" | "inline" | "builtin";
24
28
  }
25
- export interface ResolvedSubAgentConfig extends Omit<SubAgentConfig, "model" | "modelRef"> {
29
+ export interface ResolvedSubAgentConfig extends Omit<SubAgentConfig, "model" | "modelRef" | "thinkingLevel"> {
26
30
  model: Model<Api>;
27
31
  modelRef: string;
32
+ thinkingLevel: SubAgentThinkingLevel;
28
33
  }
29
34
  export interface SubAgentDiscoveryResult {
30
35
  directory: string;
@@ -44,6 +49,9 @@ export interface SubAgentInvocationOverrides {
44
49
  contextMode?: string;
45
50
  memory?: string;
46
51
  paths?: string[];
52
+ thinkingLevel?: string;
53
+ /** Drives the thinkingLevel default: "verify" defaults on, everything else stays off. */
54
+ purpose?: string;
47
55
  }
48
56
  export declare function validateSubAgentTask(task: string): string | undefined;
49
57
  export declare function getSubAgentsDir(workspaceDir: string): string;
@@ -52,7 +60,13 @@ export declare function validateToolNames(values: string[] | undefined): {
52
60
  error?: string;
53
61
  };
54
62
  export declare function discoverSubAgents(workspaceDir: string, availableModels: Model<Api>[]): SubAgentDiscoveryResult;
55
- export declare function resolveSubAgentConfig(availableModels: Model<Api>[], currentModel: Model<Api>, predefinedAgents: SubAgentConfig[], overrides: SubAgentInvocationOverrides): {
63
+ export declare function resolveSubAgentConfig(availableModels: Model<Api>[], currentModel: Model<Api>, predefinedAgents: SubAgentConfig[], overrides: SubAgentInvocationOverrides,
64
+ /**
65
+ * `settings.subagentModel` (spec 032 D5): used only when neither the invocation nor the
66
+ * predefined agent's frontmatter names a model. Unset/blank is "not configured" — the
67
+ * caller (tool.ts) already normalizes that, this function just treats undefined as absent.
68
+ */
69
+ subagentDefaultModelRef?: string): {
56
70
  config?: ResolvedSubAgentConfig;
57
71
  error?: string;
58
72
  };
@@ -2,7 +2,7 @@ import { parseFrontmatter } from "@earendil-works/pi-coding-agent";
2
2
  import { existsSync, readdirSync, readFileSync } from "fs";
3
3
  import { join } from "path";
4
4
  import { findExactModelReferenceMatch, formatModelReference } from "../models/utils.js";
5
- import { SUB_AGENTS_DIR_NAME } from "../paths.js";
5
+ import { BUILTIN_SUB_AGENTS_DIR, SUB_AGENTS_DIR_NAME } from "../paths.js";
6
6
  import { errorMessage } from "../shared/text-utils.js";
7
7
  const ALLOWED_SUB_AGENT_TOOLS = ["read", "bash", "edit", "write", "web_search", "web_fetch"];
8
8
  const DEFAULT_SUB_AGENT_TOOLS = ["read", "bash"];
@@ -14,6 +14,10 @@ const MAX_SUB_AGENT_TASK_CHARS = 12000;
14
14
  const MAX_SUB_AGENT_SYSTEM_PROMPT_CHARS = 16000;
15
15
  const ALLOWED_CONTEXT_MODES = ["isolated", "contextual"];
16
16
  const ALLOWED_MEMORY_MODES = ["none", "session", "relevant"];
17
+ const ALLOWED_THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh"];
18
+ /** verify is the last unattended gate before an attestation is trusted; give it real reasoning by default. */
19
+ const DEFAULT_VERIFY_THINKING_LEVEL = "medium";
20
+ const DEFAULT_WORK_THINKING_LEVEL = "off";
17
21
  function validateTextLength(value, maxChars, label) {
18
22
  if (value.length <= maxChars) {
19
23
  return undefined;
@@ -98,6 +102,18 @@ function parseContextMode(raw) {
98
102
  error: `Unknown contextMode "${normalized}". Allowed values: ${ALLOWED_CONTEXT_MODES.join(", ")}`,
99
103
  };
100
104
  }
105
+ function parseThinkingLevel(raw) {
106
+ const normalized = readOptionalTrimmedString(raw);
107
+ if (!normalized) {
108
+ return {};
109
+ }
110
+ if (ALLOWED_THINKING_LEVELS.includes(normalized)) {
111
+ return { value: normalized };
112
+ }
113
+ return {
114
+ error: `Unknown thinkingLevel "${normalized}". Allowed values: ${ALLOWED_THINKING_LEVELS.join(", ")}`,
115
+ };
116
+ }
101
117
  function parseMemoryMode(raw, contextMode) {
102
118
  const normalized = readOptionalTrimmedString(raw);
103
119
  if (!normalized) {
@@ -161,6 +177,16 @@ function resolvePositiveOverride(value, fallback) {
161
177
  }
162
178
  return Math.floor(value);
163
179
  }
180
+ /** `enabled` defaults to true; only an explicit false (bool or the string "false") turns an agent off. */
181
+ function parseEnabled(raw) {
182
+ if (typeof raw === "boolean") {
183
+ return raw;
184
+ }
185
+ if (typeof raw === "string") {
186
+ return raw.trim().toLowerCase() !== "false";
187
+ }
188
+ return true;
189
+ }
164
190
  function resolveModelReference(modelRef, availableModels) {
165
191
  const { match, ambiguous } = findExactModelReferenceMatch(modelRef, availableModels);
166
192
  if (match) {
@@ -171,14 +197,14 @@ function resolveModelReference(modelRef, availableModels) {
171
197
  }
172
198
  return { error: `Model reference "${modelRef}" was not found among available models.` };
173
199
  }
174
- export function discoverSubAgents(workspaceDir, availableModels) {
175
- const directory = getSubAgentsDir(workspaceDir);
200
+ /** Parses every `*.md` sub-agent definition in `directory`. Shared by the built-in and workspace scans. */
201
+ function loadAgentsFromDir(directory, availableModels, source) {
176
202
  if (!existsSync(directory)) {
177
- return { directory, agents: [], warnings: [] };
203
+ return { agents: [], warnings: [], knownNames: new Set() };
178
204
  }
179
205
  const warnings = [];
180
206
  const agents = [];
181
- const seenNames = new Set();
207
+ const knownNames = new Set();
182
208
  let entries;
183
209
  try {
184
210
  entries = readdirSync(directory, { withFileTypes: true })
@@ -186,11 +212,7 @@ export function discoverSubAgents(workspaceDir, availableModels) {
186
212
  .sort((a, b) => a.name.localeCompare(b.name));
187
213
  }
188
214
  catch (error) {
189
- return {
190
- directory,
191
- agents: [],
192
- warnings: [`Failed to read sub-agents directory (${errorMessage(error)})`],
193
- };
215
+ return { agents: [], warnings: [`Failed to read sub-agents directory (${errorMessage(error)})`], knownNames };
194
216
  }
195
217
  for (const entry of entries) {
196
218
  const filePath = join(directory, entry.name);
@@ -209,10 +231,18 @@ export function discoverSubAgents(workspaceDir, availableModels) {
209
231
  warnings.push(`${entry.name}: missing required frontmatter fields "name" or "description"`);
210
232
  continue;
211
233
  }
212
- if (seenNames.has(name)) {
234
+ if (knownNames.has(name)) {
213
235
  warnings.push(`${entry.name}: duplicate sub-agent name "${name}" ignored`);
214
236
  continue;
215
237
  }
238
+ // Claim the name before the enabled/empty-body checks below, so a workspace file that only
239
+ // disables a built-in agent (or fails later validation) still blocks that built-in default.
240
+ knownNames.add(name);
241
+ // `enabled: false` must win before the empty-body check: an empty-body file that only sets
242
+ // `enabled: false` is a valid "turn off this built-in agent" marker, not a malformed agent.
243
+ if (!parseEnabled(frontmatter.enabled)) {
244
+ continue;
245
+ }
216
246
  const toolParse = parseToolNames(frontmatter.tools);
217
247
  if (toolParse.error) {
218
248
  warnings.push(`${entry.name}: ${toolParse.error}`);
@@ -233,6 +263,11 @@ export function discoverSubAgents(workspaceDir, availableModels) {
233
263
  warnings.push(`${entry.name}: ${parsedPaths.error}`);
234
264
  continue;
235
265
  }
266
+ const thinkingLevel = parseThinkingLevel(frontmatter.thinkingLevel);
267
+ if (thinkingLevel.error) {
268
+ warnings.push(`${entry.name}: ${thinkingLevel.error}`);
269
+ continue;
270
+ }
236
271
  const maxTurns = parsePositiveInteger(frontmatter.maxTurns, DEFAULT_MAX_TURNS);
237
272
  const maxToolCalls = parsePositiveInteger(frontmatter.maxToolCalls, DEFAULT_MAX_TOOL_CALLS);
238
273
  const maxWallTimeSec = parsePositiveInteger(frontmatter.maxWallTimeSec, DEFAULT_MAX_WALL_TIME_SEC);
@@ -262,7 +297,6 @@ export function discoverSubAgents(workspaceDir, availableModels) {
262
297
  warnings.push(`${entry.name}: ${promptLengthError}`);
263
298
  continue;
264
299
  }
265
- seenNames.add(name);
266
300
  agents.push({
267
301
  name,
268
302
  description,
@@ -277,13 +311,35 @@ export function discoverSubAgents(workspaceDir, availableModels) {
277
311
  contextMode: contextMode.value,
278
312
  memory: memoryMode.value,
279
313
  paths: parsedPaths.values,
314
+ thinkingLevel: thinkingLevel.value,
280
315
  filePath,
281
- source: "predefined",
316
+ source,
282
317
  });
283
318
  }
284
- return { directory, agents, warnings };
319
+ return { agents, warnings, knownNames };
320
+ }
321
+ export function discoverSubAgents(workspaceDir, availableModels) {
322
+ const directory = getSubAgentsDir(workspaceDir);
323
+ const workspaceResult = loadAgentsFromDir(directory, availableModels, "predefined");
324
+ const builtinResult = loadAgentsFromDir(BUILTIN_SUB_AGENTS_DIR, availableModels, "builtin");
325
+ const warnings = [...workspaceResult.warnings, ...builtinResult.warnings];
326
+ const builtinAgents = [];
327
+ for (const agent of builtinResult.agents) {
328
+ if (workspaceResult.knownNames.has(agent.name)) {
329
+ warnings.push(`${agent.name}: workspace sub-agent overrides the built-in default`);
330
+ continue;
331
+ }
332
+ builtinAgents.push(agent);
333
+ }
334
+ return { directory, agents: [...workspaceResult.agents, ...builtinAgents], warnings };
285
335
  }
286
- export function resolveSubAgentConfig(availableModels, currentModel, predefinedAgents, overrides) {
336
+ export function resolveSubAgentConfig(availableModels, currentModel, predefinedAgents, overrides,
337
+ /**
338
+ * `settings.subagentModel` (spec 032 D5): used only when neither the invocation nor the
339
+ * predefined agent's frontmatter names a model. Unset/blank is "not configured" — the
340
+ * caller (tool.ts) already normalizes that, this function just treats undefined as absent.
341
+ */
342
+ subagentDefaultModelRef) {
287
343
  const baseConfig = overrides.agent ? predefinedAgents.find((agent) => agent.name === overrides.agent) : undefined;
288
344
  if (overrides.agent && !baseConfig) {
289
345
  const available = predefinedAgents.length > 0 ? predefinedAgents.map((agent) => agent.name).join(", ") : "none";
@@ -308,6 +364,14 @@ export function resolveSubAgentConfig(availableModels, currentModel, predefinedA
308
364
  model = resolved.model;
309
365
  modelRef = formatModelReference(resolved.model);
310
366
  }
367
+ else if (!model && subagentDefaultModelRef) {
368
+ const resolved = resolveModelReference(subagentDefaultModelRef, availableModels);
369
+ if (!resolved.model) {
370
+ return { error: resolved.error };
371
+ }
372
+ model = resolved.model;
373
+ modelRef = formatModelReference(resolved.model);
374
+ }
311
375
  const maxTurns = resolvePositiveOverride(overrides.maxTurns, baseConfig?.maxTurns ?? DEFAULT_MAX_TURNS);
312
376
  const maxToolCalls = resolvePositiveOverride(overrides.maxToolCalls, baseConfig?.maxToolCalls ?? DEFAULT_MAX_TOOL_CALLS);
313
377
  const maxWallTimeSec = resolvePositiveOverride(overrides.maxWallTimeSec, baseConfig?.maxWallTimeSec ?? DEFAULT_MAX_WALL_TIME_SEC);
@@ -327,6 +391,14 @@ export function resolveSubAgentConfig(availableModels, currentModel, predefinedA
327
391
  return { error: pathsOverride.error };
328
392
  }
329
393
  const paths = pathsOverride?.values ?? baseConfig?.paths ?? [];
394
+ const thinkingLevelOverride = overrides.thinkingLevel ? parseThinkingLevel(overrides.thinkingLevel) : undefined;
395
+ if (thinkingLevelOverride?.error) {
396
+ return { error: thinkingLevelOverride.error };
397
+ }
398
+ const purpose = overrides.purpose === "verify" ? "verify" : "work";
399
+ const thinkingLevel = thinkingLevelOverride?.value ??
400
+ baseConfig?.thinkingLevel ??
401
+ (purpose === "verify" ? DEFAULT_VERIFY_THINKING_LEVEL : DEFAULT_WORK_THINKING_LEVEL);
330
402
  const systemPrompt = overrides.systemPrompt?.trim() || baseConfig?.systemPrompt || "";
331
403
  if (!systemPrompt) {
332
404
  return { error: "Sub-agent system prompt cannot be empty." };
@@ -352,6 +424,7 @@ export function resolveSubAgentConfig(availableModels, currentModel, predefinedA
352
424
  contextMode,
353
425
  memory,
354
426
  paths,
427
+ thinkingLevel,
355
428
  filePath: baseConfig?.filePath,
356
429
  source: baseConfig ? "predefined" : "inline",
357
430
  },
@@ -27,11 +27,13 @@ declare const subagentSchema: Type.TObject<{
27
27
  taskId: Type.TOptional<Type.TString>;
28
28
  isolation: Type.TOptional<Type.TUnion<[Type.TLiteral<"shared">, Type.TLiteral<"worktree">]>>;
29
29
  worktreePath: Type.TOptional<Type.TString>;
30
+ returns: Type.TOptional<Type.TUnion<[Type.TLiteral<"text">, Type.TLiteral<"artifact">]>>;
31
+ thinkingLevel: Type.TOptional<Type.TUnion<[Type.TLiteral<"off">, Type.TLiteral<"minimal">, Type.TLiteral<"low">, Type.TLiteral<"medium">, Type.TLiteral<"high">, Type.TLiteral<"xhigh">]>>;
30
32
  }>;
31
33
  export interface SubAgentToolDetails {
32
34
  kind: "subagent";
33
35
  agent: string;
34
- source: "predefined" | "inline";
36
+ source: "predefined" | "inline" | "builtin";
35
37
  model: string;
36
38
  tools: string[];
37
39
  turns: number;
@@ -47,6 +49,12 @@ export interface SubAgentToolDetails {
47
49
  worktreePath?: string;
48
50
  worktreeBranch?: string;
49
51
  verificationVerdict?: "pass" | "fail";
52
+ /** Always populated (spec 032 D4): the full output is saved to `${artifactDir}/output.md` regardless of `returns`. */
53
+ artifactDir: string;
54
+ /** Set only when `returns: "artifact"` and the sub-agent emitted a valid ARTIFACT: marker. */
55
+ artifactPath?: string;
56
+ /** True when the reply text was truncated against MAX_SUBAGENT_RESULT_UNITS; the full text is still on disk. */
57
+ resultTruncated: boolean;
50
58
  }
51
59
  export interface SubAgentToolOptions {
52
60
  executor: Executor;
@@ -59,6 +67,8 @@ export interface SubAgentToolOptions {
59
67
  channelDir: string;
60
68
  getSubAgentDiscovery?: () => SubAgentDiscoveryResult;
61
69
  getMemoryRecallSettings?: () => PipiclawMemoryRecallSettings;
70
+ /** `settings.subagentModel` (spec 032 D5); null/undefined means unset. */
71
+ getSubAgentModelReference?: () => string | null;
62
72
  memoryCandidateStore?: MemoryCandidateStore;
63
73
  securityConfig?: SecurityConfig;
64
74
  webConfig?: PipiclawWebToolsConfig;
@@ -72,15 +82,25 @@ export interface SubAgentToolOptions {
72
82
  apiKey: string;
73
83
  tools: AgentTool<any>[];
74
84
  }) => SubAgentWorker;
85
+ /** Test-only override for the D6 convergence-turn wall clock; defaults to CONVERGENCE_WALL_CLOCK_MS. */
86
+ convergenceWallClockMs?: number;
75
87
  }
76
88
  interface SubAgentWorker {
77
89
  state: {
78
90
  messages: AgentMessage[];
91
+ tools: AgentTool<any>[];
79
92
  };
80
93
  subscribe(listener: (event: AgentEvent) => void): () => void;
81
94
  abort(): void;
82
95
  prompt(input: string): Promise<void>;
83
96
  waitForIdle(): Promise<void>;
84
97
  }
98
+ /**
99
+ * Reply budget for what a sub-agent hands back to its parent (spec 032 D4), measured in the
100
+ * same prompt-unit currency as the system prompt budget (shared/prompt-units.ts). The full
101
+ * output always lands on disk under the artifact directory regardless of this budget — this
102
+ * only caps what gets echoed into the parent's context.
103
+ */
104
+ export declare const MAX_SUBAGENT_RESULT_UNITS = 1200;
85
105
  export declare function createSubAgentTool(options: SubAgentToolOptions): AgentTool<typeof subagentSchema, SubAgentToolDetails>;
86
106
  export {};