@oyasmi/pipiclaw 0.9.1 → 0.9.2-beta.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 (149) hide show
  1. package/dist/agent/channel-runner.d.ts +2 -1
  2. package/dist/agent/channel-runner.js +9 -5
  3. package/dist/agent/effect-ledger.js +9 -2
  4. package/dist/agent/job-manager.d.ts +4 -0
  5. package/dist/agent/job-manager.js +17 -2
  6. package/dist/agent/prompt/manifest.d.ts +1 -1
  7. package/dist/agent/prompt/manifest.js +1 -1
  8. package/dist/agent/prompt/sections.js +8 -5
  9. package/dist/agent/session-events.d.ts +2 -0
  10. package/dist/agent/session-events.js +29 -14
  11. package/dist/agent/turn-recovery.js +2 -2
  12. package/dist/agent/type-guards.js +5 -1
  13. package/dist/agent/workspace-resources.d.ts +2 -2
  14. package/dist/agent/workspace-resources.js +41 -3
  15. package/dist/executor.d.ts +14 -0
  16. package/dist/executor.js +96 -24
  17. package/dist/file-store.d.ts +96 -0
  18. package/dist/file-store.js +189 -0
  19. package/dist/memory/consolidation.js +2 -26
  20. package/dist/memory/files.js +7 -7
  21. package/dist/memory/maintenance-jobs.js +2 -34
  22. package/dist/memory/maintenance-state.js +2 -1
  23. package/dist/memory/recall.d.ts +10 -0
  24. package/dist/memory/recall.js +15 -7
  25. package/dist/memory/session-search.js +6 -22
  26. package/dist/memory/transcript.d.ts +10 -0
  27. package/dist/memory/transcript.js +39 -0
  28. package/dist/playbooks/agent-delegation.md +6 -4
  29. package/dist/playbooks/background-jobs.md +1 -1
  30. package/dist/playbooks/catalog.d.ts +1 -1
  31. package/dist/playbooks/catalog.js +1 -1
  32. package/dist/playbooks/event-scheduling.md +2 -0
  33. package/dist/playbooks/memory-and-learning.md +11 -11
  34. package/dist/playbooks/runtime-orientation.md +3 -3
  35. package/dist/playbooks/task-driving.md +5 -5
  36. package/dist/playbooks/task-planning.md +5 -5
  37. package/dist/runtime/app-home.js +1 -1
  38. package/dist/runtime/bootstrap.js +10 -0
  39. package/dist/runtime/dingtalk.js +3 -2
  40. package/dist/runtime/durable-dispatch.d.ts +26 -1
  41. package/dist/runtime/durable-dispatch.js +51 -5
  42. package/dist/runtime/event-commands.js +7 -16
  43. package/dist/runtime/events.d.ts +4 -2
  44. package/dist/runtime/events.js +15 -20
  45. package/dist/runtime/subagent-commands.js +1 -1
  46. package/dist/runtime/task-commands.d.ts +1 -1
  47. package/dist/runtime/task-commands.js +10 -10
  48. package/dist/runtime/task-driver.js +2 -2
  49. package/dist/security/block-message.d.ts +11 -0
  50. package/dist/security/block-message.js +12 -0
  51. package/dist/security/path-guard-check.d.ts +13 -0
  52. package/dist/security/path-guard-check.js +39 -0
  53. package/dist/security/path-guard.js +32 -14
  54. package/dist/settings.js +3 -2
  55. package/dist/shared/atomic-file.d.ts +17 -1
  56. package/dist/shared/atomic-file.js +50 -3
  57. package/dist/shared/duration.d.ts +2 -0
  58. package/dist/shared/duration.js +7 -0
  59. package/dist/shared/safe-id.d.ts +19 -0
  60. package/dist/shared/safe-id.js +24 -0
  61. package/dist/shared/text-utils.d.ts +1 -1
  62. package/dist/shared/text-utils.js +3 -8
  63. package/dist/shared/type-guards.d.ts +2 -0
  64. package/dist/shared/type-guards.js +4 -0
  65. package/dist/subagents/discovery.d.ts +44 -17
  66. package/dist/subagents/discovery.js +82 -111
  67. package/dist/subagents/external/claude-code.js +1 -3
  68. package/dist/subagents/external/harness.d.ts +1 -1
  69. package/dist/subagents/format.d.ts +3 -2
  70. package/dist/subagents/format.js +3 -7
  71. package/dist/subagents/runs.d.ts +1 -1
  72. package/dist/subagents/runs.js +4 -9
  73. package/dist/subagents/tool.d.ts +31 -19
  74. package/dist/subagents/tool.js +582 -561
  75. package/dist/subagents/workspace-lease.js +1 -1
  76. package/dist/tasks/control.js +7 -9
  77. package/dist/tasks/ledger.d.ts +2 -2
  78. package/dist/tasks/ledger.js +3 -7
  79. package/dist/tasks/transitions.d.ts +5 -1
  80. package/dist/tasks/transitions.js +2 -2
  81. package/dist/tools/bash.d.ts +0 -1
  82. package/dist/tools/bash.js +45 -40
  83. package/dist/tools/config.d.ts +6 -1
  84. package/dist/tools/config.js +9 -0
  85. package/dist/tools/edit.d.ts +2 -3
  86. package/dist/tools/edit.js +274 -86
  87. package/dist/tools/event-manage.d.ts +13 -7
  88. package/dist/tools/event-manage.js +52 -14
  89. package/dist/tools/glob-match.d.ts +11 -0
  90. package/dist/tools/glob-match.js +75 -0
  91. package/dist/tools/glob.d.ts +15 -0
  92. package/dist/tools/glob.js +113 -0
  93. package/dist/tools/grep.d.ts +0 -1
  94. package/dist/tools/grep.js +57 -42
  95. package/dist/tools/ignore-dirs.d.ts +6 -0
  96. package/dist/tools/ignore-dirs.js +15 -0
  97. package/dist/tools/index.d.ts +3 -0
  98. package/dist/tools/index.js +50 -40
  99. package/dist/tools/job.d.ts +0 -1
  100. package/dist/tools/job.js +1 -8
  101. package/dist/tools/line-index.d.ts +16 -0
  102. package/dist/tools/line-index.js +76 -0
  103. package/dist/tools/memory-manage.d.ts +20 -8
  104. package/dist/tools/memory-manage.js +65 -92
  105. package/dist/tools/presentation.d.ts +2 -0
  106. package/dist/tools/presentation.js +109 -0
  107. package/dist/tools/read.d.ts +2 -2
  108. package/dist/tools/read.js +97 -133
  109. package/dist/tools/registry.d.ts +4 -1
  110. package/dist/tools/registry.js +89 -22
  111. package/dist/tools/send-media.d.ts +6 -6
  112. package/dist/tools/send-media.js +16 -49
  113. package/dist/tools/session-search.d.ts +0 -1
  114. package/dist/tools/session-search.js +0 -1
  115. package/dist/tools/skill-security.d.ts +0 -2
  116. package/dist/tools/skill-security.js +0 -24
  117. package/dist/tools/skill.d.ts +31 -0
  118. package/dist/tools/skill.js +153 -0
  119. package/dist/tools/subagent-manage.d.ts +6 -5
  120. package/dist/tools/subagent-manage.js +47 -47
  121. package/dist/tools/task-manage/create.d.ts +2 -2
  122. package/dist/tools/task-manage/create.js +1 -3
  123. package/dist/tools/task-manage/lifecycle.d.ts +9 -6
  124. package/dist/tools/task-manage/lifecycle.js +49 -56
  125. package/dist/tools/task-manage/schema.d.ts +27 -15
  126. package/dist/tools/task-manage/schema.js +58 -74
  127. package/dist/tools/task-manage/shared.d.ts +11 -6
  128. package/dist/tools/task-manage/shared.js +30 -21
  129. package/dist/tools/task-manage/types.d.ts +14 -15
  130. package/dist/tools/task-manage/verification.d.ts +4 -4
  131. package/dist/tools/task-manage/verification.js +6 -8
  132. package/dist/tools/task-manage.d.ts +8 -11
  133. package/dist/tools/task-manage.js +63 -50
  134. package/dist/tools/tool-details.d.ts +17 -1
  135. package/dist/tools/tool-details.js +24 -0
  136. package/dist/tools/truncate.d.ts +5 -5
  137. package/dist/tools/truncate.js +5 -5
  138. package/dist/tools/web-fetch.d.ts +0 -1
  139. package/dist/tools/web-fetch.js +0 -1
  140. package/dist/tools/web-search.d.ts +0 -1
  141. package/dist/tools/web-search.js +0 -1
  142. package/dist/tools/write-content.d.ts +3 -3
  143. package/dist/tools/write-content.js +12 -51
  144. package/dist/tools/write.d.ts +2 -3
  145. package/dist/tools/write.js +3 -4
  146. package/dist/usage/ledger.js +7 -4
  147. package/package.json +1 -1
  148. package/dist/tools/skill-manage.d.ts +0 -41
  149. package/dist/tools/skill-manage.js +0 -232
@@ -9,31 +9,32 @@ import { hashMemoryContent } from "../memory/tombstones.js";
9
9
  import { readOptionalTextFile } from "../shared/fs-utils.js";
10
10
  import { RecoverableToolError } from "../shared/recoverable-error.js";
11
11
  import { errorMessage } from "../shared/text-utils.js";
12
- const memoryManageSchema = Type.Object({
13
- label: Type.String({ description: "Brief description of the memory change (shown to user)" }),
14
- op: Type.Union([Type.Literal("save"), Type.Literal("search"), Type.Literal("forget")], {
15
- description: '"save" a durable fact, "search" this channel\'s stored memory on demand, or "forget" a stored entry the user asked you to drop.',
12
+ /**
13
+ * Spec 047, P4: the old single `memory_manage` routed three fully disjoint payloads through an
14
+ * `op` enum. Splitting into one tool per payload shape drops the `op` routing prose and the
15
+ * "Required for save:" prefixes, and lets each op's one required field be schema-required
16
+ * instead of `Type.Optional` + a hand-rolled `rejectMissingArgument`. The streamed-argument
17
+ * truncation that `rejectMissingArgument` guarded against (M-write-03) is now caught by the SDK
18
+ * validator before `execute`; spec 047 D4.2 makes that rejection surface as a recoverable
19
+ * rejection rather than a user-visible error.
20
+ */
21
+ const memorySaveSchema = Type.Object({
22
+ content: Type.String({
23
+ description: "The durable fact as a single self-contained, keyword-rich sentence on one line, written so future keyword search can find it.",
16
24
  }),
17
- content: Type.Optional(Type.String({
18
- description: "Required for save: the durable fact as a single self-contained, keyword-rich sentence on one line, written so future keyword search can find it. A save without it is rejected and stores nothing.",
19
- })),
20
- query: Type.Optional(Type.String({ description: "For search: what to look for in stored memory." })),
21
- target: Type.Optional(Type.String({
22
- description: "For forget: text identifying the stored entry to remove. Must match exactly one entry; use search first to confirm the wording.",
23
- })),
24
- kind: Type.Optional(Type.Union([
25
- Type.Literal("preference"),
26
- Type.Literal("fact"),
27
- Type.Literal("decision"),
28
- Type.Literal("constraint"),
29
- Type.Literal("open-loop"),
30
- Type.Literal("lesson"),
31
- ], { description: "For save: what kind of durable memory this is." })),
32
25
  supersedes: Type.Optional(Type.String({
33
- description: "For save, only after this tool reported a similar existing entry: the entry id being replaced, " +
26
+ description: "Only after this tool reported a similar existing entry: the entry id being replaced, " +
34
27
  'or "none" to keep both.',
35
28
  })),
36
29
  });
30
+ const memorySearchSchema = Type.Object({
31
+ query: Type.String({ description: "What to look for in this channel's stored memory." }),
32
+ });
33
+ const memoryForgetSchema = Type.Object({
34
+ target: Type.String({
35
+ description: "Text identifying the stored entry to remove. Must match exactly one entry; use memory_search first to confirm the wording.",
36
+ }),
37
+ });
37
38
  /**
38
39
  * Above this recall score, an existing entry is similar enough that saving alongside it — rather
39
40
  * than superseding it — risks two contradictory durable facts competing at recall time. Set high
@@ -43,57 +44,15 @@ const memoryManageSchema = Type.Object({
43
44
  * strong elsewhere in the pipeline is a reasonable place to start being strict here too.
44
45
  */
45
46
  const SAVE_CONFLICT_SCORE = 8;
46
- function normalizeMemoryKind(kind) {
47
- return kind === "preference" ||
48
- kind === "decision" ||
49
- kind === "constraint" ||
50
- kind === "open-loop" ||
51
- kind === "lesson"
52
- ? kind
53
- : "fact";
54
- }
55
47
  function textResult(text, details) {
56
48
  return { content: [{ type: "text", text }], details };
57
49
  }
58
- /**
59
- * Reject a call whose op-specific payload never arrived.
60
- *
61
- * These arguments are `Type.Optional` because each one belongs to exactly one op, so the
62
- * schema cannot express "required for save, absent for search" — which means the SDK
63
- * validator lets a payload-less call straight through. Two failure modes reach here and both
64
- * used to end in a calm `textResult` that read like a completed no-op:
65
- *
66
- * 1. The model genuinely omitted the argument.
67
- * 2. The argument was *lost in transit*. Streamed tool-call arguments are accumulated as
68
- * text and parsed leniently (`parseStreamingJson`): if the provider truncates or
69
- * malforms the tail of the JSON — the common shape with OpenAI-compatible Chinese
70
- * providers on long non-ASCII values — the trailing key is silently dropped and the
71
- * call still executes. The assistant message is then persisted with the *parsed*
72
- * arguments, so on the next turn the model reads back its own call with `content`
73
- * already missing, copies it, and loops forever.
74
- *
75
- * A soft result makes (2) unrecoverable, so reject loudly instead: a `RecoverableToolError`
76
- * surfaces to the model as an error it must fix rather than a saved memory, names the keys
77
- * that actually arrived so a dropped argument is visible rather than inferred, and tells the
78
- * model not to replay the previous call. The warning log is the operator-side evidence —
79
- * `agent.tool.started` carries the raw args but only at debug level.
80
- */
81
- function rejectMissingArgument(op, parameter, args) {
82
- const received = Object.entries(args)
83
- .filter(([, value]) => value !== undefined && value !== "")
84
- .map(([key]) => key);
85
- log.logWarning(`memory_manage ${op} called without "${parameter}"`, `received arguments: ${received.join(", ") || "(none)"}`);
86
- throw new RecoverableToolError(`memory_manage op="${op}" requires a non-empty "${parameter}", but the call arrived with only: ${received.join(", ") || "(no arguments)"}. Nothing was ${op === "forget" ? "removed" : op === "save" ? "saved" : "searched"}. Do not repeat the previous ` +
87
- `call as written — if an earlier call in this conversation is also missing "${parameter}", it was dropped in ` +
88
- `transit, so re-issue it with "${parameter}" set explicitly and keep the value short and on one line.`);
89
- }
90
- export function createMemoryManageTool(options) {
50
+ function buildMemoryClosures(options) {
91
51
  const queue = options.channelMemoryQueue ?? getDefaultChannelMemoryQueue();
92
- async function save(args) {
93
- const { content, kind, supersedes } = args;
94
- const trimmed = (content ?? "").trim();
52
+ async function save({ content, supersedes }) {
53
+ const trimmed = content.trim();
95
54
  if (!trimmed) {
96
- rejectMissingArgument("save", "content", args);
55
+ throw new RecoverableToolError("memory_save requires a non-empty content; nothing was saved.");
97
56
  }
98
57
  if (containsSecret(trimmed)) {
99
58
  return textResult("This content looks like a credential or secret, so it was not saved. Store the secret in an approved secret manager and remember only its location.", { op: "save", saved: false, blockedReason: "secret" });
@@ -124,8 +83,10 @@ export function createMemoryManageTool(options) {
124
83
  '\nRe-issue the save with "supersedes" set to the entry id this replaces, or to "none" if both facts are true at the same time.');
125
84
  }
126
85
  }
86
+ // The model no longer classifies explicit saves (spec 047, P2): background consolidation
87
+ // (`extraction.ts`) still writes real kinds; a model save is recorded as `fact`.
127
88
  const metadata = {
128
- kind: normalizeMemoryKind(kind),
89
+ kind: "fact",
129
90
  sourceType: "user",
130
91
  probationUntil: null,
131
92
  };
@@ -140,17 +101,17 @@ export function createMemoryManageTool(options) {
140
101
  ]));
141
102
  options.memoryCandidateStore.invalidate(getChannelMemoryPath(options.channelDir));
142
103
  const message = result.added > 0 || result.superseded > 0
143
- ? `Saved to channel memory${kind ? ` (${kind})` : ""}.`
104
+ ? "Saved to channel memory."
144
105
  : "That memory is already present; no duplicate was added.";
145
106
  return textResult(message, {
146
107
  op: "save",
147
108
  saved: result.added > 0 || result.superseded > 0 || result.skippedDuplicate > 0,
148
109
  });
149
110
  }
150
- async function search(args) {
151
- const trimmed = (args.query ?? "").trim();
111
+ async function search({ query }) {
112
+ const trimmed = query.trim();
152
113
  if (!trimmed) {
153
- rejectMissingArgument("search", "query", args);
114
+ throw new RecoverableToolError("memory_search requires a non-empty query.");
154
115
  }
155
116
  // Reuse the recall scoring pipeline (single source of scoring truth) but scoped to the
156
117
  // distilled durable files and with model rerank off, so this stays a cheap deterministic
@@ -181,10 +142,10 @@ export function createMemoryManageTool(options) {
181
142
  resultCount: items.length,
182
143
  });
183
144
  }
184
- async function forget(args) {
185
- const trimmed = (args.target ?? "").trim();
145
+ async function forget({ target }) {
146
+ const trimmed = target.trim();
186
147
  if (!trimmed) {
187
- rejectMissingArgument("forget", "target", args);
148
+ throw new RecoverableToolError("memory_forget requires a non-empty target.");
188
149
  }
189
150
  const memoryPath = getChannelMemoryPath(options.channelDir);
190
151
  const existing = await readOptionalTextFile(memoryPath);
@@ -217,24 +178,36 @@ export function createMemoryManageTool(options) {
217
178
  });
218
179
  return textResult("Removed the entry from active channel memory. Its exact content and source transcript window are tombstoned against automatic replay; if the fact is stated again later, it may be learned as new. Original session history and retention backups are unchanged.", { op: "forget", forgotten: true, entryId: removed.id });
219
180
  }
181
+ return { save, search, forget };
182
+ }
183
+ export function createMemorySaveTool(options) {
184
+ const { save } = buildMemoryClosures(options);
220
185
  return {
221
- name: "memory_manage",
222
- label: "memory_manage",
223
- description: "Manage this channel's durable MEMORY.md: save a durable fact the user asks you to remember, search stored " +
224
- "memory on demand mid-task, or forget an entry the user asks you to drop. Prefer this over editing MEMORY.md " +
225
- "directly — it serializes with background consolidation and keeps memory recallable. Not for transient task state.",
226
- parameters: memoryManageSchema,
227
- execute: async (_toolCallId, args) => {
228
- switch (args.op) {
229
- case "save":
230
- return save(args);
231
- case "search":
232
- return search(args);
233
- case "forget":
234
- return forget(args);
235
- default:
236
- throw new RecoverableToolError('Unsupported memory op. Use "save", "search", or "forget".');
237
- }
238
- },
186
+ name: "memory_save",
187
+ label: "memory_save",
188
+ description: "Save a durable fact into this channel's MEMORY.md when the user asks you to remember it. Prefer this over editing " +
189
+ "MEMORY.md directly. Not for transient task state.",
190
+ parameters: memorySaveSchema,
191
+ execute: async (_toolCallId, args) => save(args),
192
+ };
193
+ }
194
+ export function createMemorySearchTool(options) {
195
+ const { search } = buildMemoryClosures(options);
196
+ return {
197
+ name: "memory_search",
198
+ label: "memory_search",
199
+ description: "Search this channel's stored durable memory on demand mid-task.",
200
+ parameters: memorySearchSchema,
201
+ execute: async (_toolCallId, args) => search(args),
202
+ };
203
+ }
204
+ export function createMemoryForgetTool(options) {
205
+ const { forget } = buildMemoryClosures(options);
206
+ return {
207
+ name: "memory_forget",
208
+ label: "memory_forget",
209
+ description: "Forget a stored memory entry the user explicitly asked you to drop. Tombstones it against automatic replay.",
210
+ parameters: memoryForgetSchema,
211
+ execute: async (_toolCallId, args) => forget(args),
239
212
  };
240
213
  }
@@ -0,0 +1,2 @@
1
+ /** Fallback for any tool name without a specific describer (e.g. an unrecognized/future tool). */
2
+ export declare function describeToolCall(toolName: string, args: unknown): string;
@@ -0,0 +1,109 @@
1
+ import { clipText } from "../shared/text-utils.js";
2
+ import { isRecord } from "../shared/type-guards.js";
3
+ /**
4
+ * Runtime-side projection from a tool call's raw arguments to the one-line Chinese progress
5
+ * string shown while it runs (`src/agent/session-events.ts`). Replaces the old model-authored,
6
+ * per-tool-required `label` argument (spec 045): the model no longer pays schema tokens or output
7
+ * tokens for a UI string on every single call, and the wording is deterministic instead of
8
+ * whatever the model happened to write.
9
+ *
10
+ * One function per tool name, keyed in a table rather than spread across each tool's own file:
11
+ * `session-events.ts` has only `toolName` + raw `args`, never the tool instance, so there is no
12
+ * natural per-file seam to hang this on without importing all sixteen modules into the session
13
+ * event handler. `test/tool-presentation.test.ts` is what actually prevents drift — it asserts
14
+ * every registered tool name has a describer and that each survives empty/missing args, since the
15
+ * model's args are not guaranteed well-formed at the moment a call starts.
16
+ */
17
+ function str(args, key) {
18
+ if (!isRecord(args))
19
+ return undefined;
20
+ const value = args[key];
21
+ return typeof value === "string" && value.trim() ? value.trim() : undefined;
22
+ }
23
+ function bool(args, key) {
24
+ return isRecord(args) && args[key] === true;
25
+ }
26
+ function firstLine(text, maxChars) {
27
+ const line = text.split("\n")[0] ?? text;
28
+ return clipText(line, maxChars, { collapseWhitespace: true });
29
+ }
30
+ /** Host + path only, so a long query string never dominates the progress line. */
31
+ function hostAndPath(rawUrl) {
32
+ try {
33
+ const url = new URL(rawUrl);
34
+ return `${url.host}${url.pathname}`;
35
+ }
36
+ catch {
37
+ return clipText(rawUrl, 60, { collapseWhitespace: true });
38
+ }
39
+ }
40
+ const DESCRIBERS = {
41
+ read: (args) => {
42
+ const path = str(args, "path") ?? "?";
43
+ const offset = isRecord(args) && typeof args.offset === "number" ? args.offset : undefined;
44
+ return `读取 ${path}${offset !== undefined ? `:${offset}` : ""}`;
45
+ },
46
+ glob: (args) => {
47
+ const pattern = str(args, "pattern") ?? "?";
48
+ const path = str(args, "path");
49
+ return `查找 ${pattern}${path ? ` · ${path}` : ""}`;
50
+ },
51
+ grep: (args) => {
52
+ const pattern = str(args, "pattern") ?? "?";
53
+ const path = str(args, "path");
54
+ return `搜索 "${clipText(pattern, 40, { collapseWhitespace: true })}"${path ? ` · ${path}` : ""}`;
55
+ },
56
+ edit: (args) => `编辑 ${str(args, "path") ?? "?"}`,
57
+ write: (args) => `写入 ${str(args, "path") ?? "?"}`,
58
+ bash: (args) => {
59
+ const command = clipText(str(args, "command") ?? "?", 60, { collapseWhitespace: true });
60
+ return bool(args, "async") ? `后台执行 ${command}` : `执行 ${command}`;
61
+ },
62
+ web_search: (args) => `搜索 "${clipText(str(args, "query") ?? "?", 60, { collapseWhitespace: true })}"`,
63
+ web_fetch: (args) => `抓取 ${hostAndPath(str(args, "url") ?? "")}`,
64
+ send_media: (args) => `发送 ${str(args, "path") ?? "?"}`,
65
+ job: (args) => {
66
+ const op = str(args, "op") ?? "?";
67
+ const ids = isRecord(args) && Array.isArray(args.ids) ? args.ids.length : 0;
68
+ return `后台作业 ${op}${ids ? ` (${ids})` : ""}`;
69
+ },
70
+ session_search: (args) => `检索历史 "${clipText(str(args, "query") ?? "?", 40, { collapseWhitespace: true })}"`,
71
+ memory_save: (args) => `记忆保存${str(args, "content") ? `:${firstLine(str(args, "content") ?? "", 30)}` : ""}`,
72
+ memory_search: (args) => `记忆检索 "${clipText(str(args, "query") ?? "?", 40, { collapseWhitespace: true })}"`,
73
+ memory_forget: (args) => `记忆删除 "${clipText(str(args, "target") ?? "?", 40, { collapseWhitespace: true })}"`,
74
+ skill: (args) => {
75
+ const action = str(args, "action") ?? "?";
76
+ const name = str(args, "name");
77
+ return action === "read" ? `加载 skill ${name ?? "?"}` : "列出 skills";
78
+ },
79
+ event_manage: (args) => `事件 ${str(args, "action") ?? "?"} ${str(args, "name") ?? ""}`.trim(),
80
+ task_list: () => "列出任务",
81
+ task_create: (args) => `创建任务 ${str(args, "id") ?? "?"}`,
82
+ task_update: (args) => `更新任务 ${str(args, "id") ?? "?"}`,
83
+ task_close: (args) => `关闭任务 ${str(args, "id") ?? "?"}(${str(args, "outcome") ?? "?"})`,
84
+ task_verify: (args) => `导入验收 ${str(args, "id") ?? "?"}`,
85
+ subagent: (args) => {
86
+ const who = str(args, "agent") ?? "?";
87
+ const task = str(args, "task");
88
+ return `委派 ${who}${task ? `:${firstLine(task, 40)}` : ""}`;
89
+ },
90
+ subagent_inline: (args) => {
91
+ const task = str(args, "task");
92
+ return `内联委派${task ? `:${firstLine(task, 40)}` : ""}`;
93
+ },
94
+ subagent_list: () => "委派列表",
95
+ subagent_run: (args) => {
96
+ const op = str(args, "op") ?? "?";
97
+ const runId = str(args, "runId");
98
+ return `委派 ${op}${runId ? ` ${runId}` : ""}`;
99
+ },
100
+ };
101
+ /** Fallback for any tool name without a specific describer (e.g. an unrecognized/future tool). */
102
+ export function describeToolCall(toolName, args) {
103
+ try {
104
+ return DESCRIBERS[toolName]?.(args) || toolName;
105
+ }
106
+ catch {
107
+ return toolName;
108
+ }
109
+ }
@@ -1,9 +1,9 @@
1
1
  import type { AgentTool } from "@earendil-works/pi-agent-core";
2
2
  import { Type } from "typebox";
3
3
  import type { Executor } from "../executor.js";
4
+ import type { FileStore } from "../file-store.js";
4
5
  import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
5
6
  declare const readSchema: Type.TObject<{
6
- label: Type.TString;
7
7
  path: Type.TString;
8
8
  offset: Type.TOptional<Type.TInteger>;
9
9
  limit: Type.TOptional<Type.TInteger>;
@@ -13,5 +13,5 @@ export interface ReadToolOptions {
13
13
  securityContext?: SecurityRuntimeContext;
14
14
  channelId?: string;
15
15
  }
16
- export declare function createReadTool(executor: Executor, options?: ReadToolOptions): AgentTool<typeof readSchema>;
16
+ export declare function createReadTool(executor: Executor, fileStore: FileStore, options?: ReadToolOptions): AgentTool<typeof readSchema>;
17
17
  export {};