@oyasmi/pipiclaw 0.5.2 → 0.5.4

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 (216) hide show
  1. package/README.md +308 -209
  2. package/dist/agent/channel-runner.d.ts +3 -2
  3. package/dist/agent/channel-runner.js +22 -14
  4. package/dist/{command-extension.d.ts → agent/command-extension.d.ts} +0 -1
  5. package/dist/{command-extension.js → agent/command-extension.js} +1 -2
  6. package/dist/{commands.d.ts → agent/commands.d.ts} +0 -1
  7. package/dist/{commands.js → agent/commands.js} +0 -1
  8. package/dist/agent/index.d.ts +0 -1
  9. package/dist/agent/index.js +0 -1
  10. package/dist/agent/progress-formatter.d.ts +0 -1
  11. package/dist/agent/progress-formatter.js +0 -1
  12. package/dist/{prompt-builder.d.ts → agent/prompt-builder.d.ts} +1 -2
  13. package/dist/{prompt-builder.js → agent/prompt-builder.js} +0 -1
  14. package/dist/agent/run-queue.d.ts +0 -1
  15. package/dist/agent/run-queue.js +0 -1
  16. package/dist/agent/runner-factory.d.ts +0 -1
  17. package/dist/agent/runner-factory.js +0 -1
  18. package/dist/agent/session-events.d.ts +0 -1
  19. package/dist/agent/session-events.js +0 -1
  20. package/dist/agent/session-resource-gate.d.ts +10 -0
  21. package/dist/agent/session-resource-gate.js +44 -0
  22. package/dist/agent/type-guards.d.ts +0 -1
  23. package/dist/agent/type-guards.js +1 -2
  24. package/dist/agent/types.d.ts +1 -2
  25. package/dist/agent/types.js +0 -1
  26. package/dist/{config-loader.d.ts → agent/workspace-resources.d.ts} +3 -10
  27. package/dist/{config-loader.js → agent/workspace-resources.js} +3 -19
  28. package/dist/index.d.ts +9 -9
  29. package/dist/index.js +9 -9
  30. package/dist/log.d.ts +0 -1
  31. package/dist/log.js +0 -1
  32. package/dist/main.d.ts +0 -1
  33. package/dist/main.js +0 -1
  34. package/dist/memory/bootstrap.d.ts +0 -1
  35. package/dist/memory/bootstrap.js +0 -1
  36. package/dist/memory/candidates.d.ts +0 -1
  37. package/dist/memory/candidates.js +0 -1
  38. package/dist/memory/chinese-words.d.ts +0 -1
  39. package/dist/memory/chinese-words.js +64 -1
  40. package/dist/memory/consolidation.d.ts +0 -1
  41. package/dist/memory/consolidation.js +2 -3
  42. package/dist/memory/files.d.ts +0 -1
  43. package/dist/memory/files.js +0 -1
  44. package/dist/memory/lifecycle.d.ts +1 -2
  45. package/dist/memory/lifecycle.js +0 -1
  46. package/dist/memory/recall.d.ts +1 -1
  47. package/dist/memory/recall.js +77 -11
  48. package/dist/memory/session.d.ts +0 -1
  49. package/dist/memory/session.js +2 -3
  50. package/dist/{sidecar-worker.d.ts → memory/sidecar-worker.d.ts} +0 -1
  51. package/dist/{sidecar-worker.js → memory/sidecar-worker.js} +1 -2
  52. package/dist/models/api-keys.d.ts +7 -0
  53. package/dist/models/api-keys.js +16 -0
  54. package/dist/{model-utils.d.ts → models/utils.d.ts} +1 -2
  55. package/dist/{model-utils.js → models/utils.js} +0 -1
  56. package/dist/paths.d.ts +0 -1
  57. package/dist/paths.js +0 -1
  58. package/dist/runtime/bootstrap.d.ts +0 -1
  59. package/dist/runtime/bootstrap.js +2 -3
  60. package/dist/runtime/delivery.d.ts +0 -1
  61. package/dist/runtime/delivery.js +0 -1
  62. package/dist/runtime/dingtalk.d.ts +0 -1
  63. package/dist/runtime/dingtalk.js +1 -2
  64. package/dist/runtime/events.d.ts +0 -1
  65. package/dist/runtime/events.js +0 -1
  66. package/dist/runtime/store.d.ts +0 -1
  67. package/dist/runtime/store.js +0 -1
  68. package/dist/sandbox.d.ts +0 -1
  69. package/dist/sandbox.js +1 -2
  70. package/dist/{context.d.ts → settings.d.ts} +1 -2
  71. package/dist/{context.js → settings.js} +1 -2
  72. package/dist/{llm-json.d.ts → shared/llm-json.d.ts} +0 -1
  73. package/dist/{llm-json.js → shared/llm-json.js} +0 -1
  74. package/dist/shared/markdown-sections.d.ts +0 -1
  75. package/dist/shared/markdown-sections.js +0 -1
  76. package/dist/{shell-escape.d.ts → shared/shell-escape.d.ts} +0 -1
  77. package/dist/{shell-escape.js → shared/shell-escape.js} +0 -1
  78. package/dist/shared/text-utils.d.ts +0 -1
  79. package/dist/shared/text-utils.js +0 -1
  80. package/dist/shared/type-guards.d.ts +0 -1
  81. package/dist/shared/type-guards.js +0 -1
  82. package/dist/shared/types.d.ts +0 -1
  83. package/dist/shared/types.js +0 -1
  84. package/dist/subagents/discovery.d.ts +0 -1
  85. package/dist/subagents/discovery.js +1 -2
  86. package/dist/subagents/tool.d.ts +1 -2
  87. package/dist/subagents/tool.js +1 -2
  88. package/dist/tools/attach.d.ts +0 -1
  89. package/dist/tools/attach.js +0 -1
  90. package/dist/tools/bash.d.ts +0 -1
  91. package/dist/tools/bash.js +0 -1
  92. package/dist/tools/edit.d.ts +0 -1
  93. package/dist/tools/edit.js +1 -2
  94. package/dist/tools/index.d.ts +1 -2
  95. package/dist/tools/index.js +0 -1
  96. package/dist/tools/read.d.ts +0 -1
  97. package/dist/tools/read.js +1 -2
  98. package/dist/tools/truncate.d.ts +0 -1
  99. package/dist/tools/truncate.js +0 -1
  100. package/dist/tools/write-content.d.ts +0 -1
  101. package/dist/tools/write-content.js +1 -2
  102. package/dist/tools/write.d.ts +0 -1
  103. package/dist/tools/write.js +0 -1
  104. package/package.json +9 -3
  105. package/CHANGELOG.md +0 -47
  106. package/dist/agent/channel-runner.d.ts.map +0 -1
  107. package/dist/agent/channel-runner.js.map +0 -1
  108. package/dist/agent/index.d.ts.map +0 -1
  109. package/dist/agent/index.js.map +0 -1
  110. package/dist/agent/progress-formatter.d.ts.map +0 -1
  111. package/dist/agent/progress-formatter.js.map +0 -1
  112. package/dist/agent/run-queue.d.ts.map +0 -1
  113. package/dist/agent/run-queue.js.map +0 -1
  114. package/dist/agent/runner-factory.d.ts.map +0 -1
  115. package/dist/agent/runner-factory.js.map +0 -1
  116. package/dist/agent/session-events.d.ts.map +0 -1
  117. package/dist/agent/session-events.js.map +0 -1
  118. package/dist/agent/type-guards.d.ts.map +0 -1
  119. package/dist/agent/type-guards.js.map +0 -1
  120. package/dist/agent/types.d.ts.map +0 -1
  121. package/dist/agent/types.js.map +0 -1
  122. package/dist/agent.d.ts +0 -3
  123. package/dist/agent.d.ts.map +0 -1
  124. package/dist/agent.js +0 -2
  125. package/dist/agent.js.map +0 -1
  126. package/dist/command-extension.d.ts.map +0 -1
  127. package/dist/command-extension.js.map +0 -1
  128. package/dist/commands.d.ts.map +0 -1
  129. package/dist/commands.js.map +0 -1
  130. package/dist/config-loader.d.ts.map +0 -1
  131. package/dist/config-loader.js.map +0 -1
  132. package/dist/context.d.ts.map +0 -1
  133. package/dist/context.js.map +0 -1
  134. package/dist/index.d.ts.map +0 -1
  135. package/dist/index.js.map +0 -1
  136. package/dist/llm-json.d.ts.map +0 -1
  137. package/dist/llm-json.js.map +0 -1
  138. package/dist/log.d.ts.map +0 -1
  139. package/dist/log.js.map +0 -1
  140. package/dist/main.d.ts.map +0 -1
  141. package/dist/main.js.map +0 -1
  142. package/dist/memory/bootstrap.d.ts.map +0 -1
  143. package/dist/memory/bootstrap.js.map +0 -1
  144. package/dist/memory/candidates.d.ts.map +0 -1
  145. package/dist/memory/candidates.js.map +0 -1
  146. package/dist/memory/chinese-words.d.ts.map +0 -1
  147. package/dist/memory/chinese-words.js.map +0 -1
  148. package/dist/memory/consolidation.d.ts.map +0 -1
  149. package/dist/memory/consolidation.js.map +0 -1
  150. package/dist/memory/files.d.ts.map +0 -1
  151. package/dist/memory/files.js.map +0 -1
  152. package/dist/memory/lifecycle.d.ts.map +0 -1
  153. package/dist/memory/lifecycle.js.map +0 -1
  154. package/dist/memory/recall.d.ts.map +0 -1
  155. package/dist/memory/recall.js.map +0 -1
  156. package/dist/memory/session.d.ts.map +0 -1
  157. package/dist/memory/session.js.map +0 -1
  158. package/dist/model-utils.d.ts.map +0 -1
  159. package/dist/model-utils.js.map +0 -1
  160. package/dist/paths.d.ts.map +0 -1
  161. package/dist/paths.js.map +0 -1
  162. package/dist/prompt-builder.d.ts.map +0 -1
  163. package/dist/prompt-builder.js.map +0 -1
  164. package/dist/runtime/bootstrap.d.ts.map +0 -1
  165. package/dist/runtime/bootstrap.js.map +0 -1
  166. package/dist/runtime/delivery.d.ts.map +0 -1
  167. package/dist/runtime/delivery.js.map +0 -1
  168. package/dist/runtime/dingtalk.d.ts.map +0 -1
  169. package/dist/runtime/dingtalk.js.map +0 -1
  170. package/dist/runtime/events.d.ts.map +0 -1
  171. package/dist/runtime/events.js.map +0 -1
  172. package/dist/runtime/store.d.ts.map +0 -1
  173. package/dist/runtime/store.js.map +0 -1
  174. package/dist/sandbox.d.ts.map +0 -1
  175. package/dist/sandbox.js.map +0 -1
  176. package/dist/shared/markdown-sections.d.ts.map +0 -1
  177. package/dist/shared/markdown-sections.js.map +0 -1
  178. package/dist/shared/text-utils.d.ts.map +0 -1
  179. package/dist/shared/text-utils.js.map +0 -1
  180. package/dist/shared/type-guards.d.ts.map +0 -1
  181. package/dist/shared/type-guards.js.map +0 -1
  182. package/dist/shared/types.d.ts.map +0 -1
  183. package/dist/shared/types.js.map +0 -1
  184. package/dist/shell-escape.d.ts.map +0 -1
  185. package/dist/shell-escape.js.map +0 -1
  186. package/dist/sidecar-worker.d.ts.map +0 -1
  187. package/dist/sidecar-worker.js.map +0 -1
  188. package/dist/subagents/discovery.d.ts.map +0 -1
  189. package/dist/subagents/discovery.js.map +0 -1
  190. package/dist/subagents/tool.d.ts.map +0 -1
  191. package/dist/subagents/tool.js.map +0 -1
  192. package/dist/tools/attach.d.ts.map +0 -1
  193. package/dist/tools/attach.js.map +0 -1
  194. package/dist/tools/bash.d.ts.map +0 -1
  195. package/dist/tools/bash.js.map +0 -1
  196. package/dist/tools/edit.d.ts.map +0 -1
  197. package/dist/tools/edit.js.map +0 -1
  198. package/dist/tools/index.d.ts.map +0 -1
  199. package/dist/tools/index.js.map +0 -1
  200. package/dist/tools/read.d.ts.map +0 -1
  201. package/dist/tools/read.js.map +0 -1
  202. package/dist/tools/truncate.d.ts.map +0 -1
  203. package/dist/tools/truncate.js.map +0 -1
  204. package/dist/tools/write-content.d.ts.map +0 -1
  205. package/dist/tools/write-content.js.map +0 -1
  206. package/dist/tools/write.d.ts.map +0 -1
  207. package/dist/tools/write.js.map +0 -1
  208. package/docs/memory-audit.md +0 -330
  209. package/docs/memory-optimization-round2.md +0 -319
  210. package/docs/specs/001-implement-memory/memory-rfc.md +0 -297
  211. package/docs/specs/002-subagent/pi-subagent-analyse.txt +0 -190
  212. package/docs/specs/002-subagent/pi-subagent-design.txt +0 -266
  213. package/docs/specs/002-subagent/pi-subagent-phase1-plan.txt +0 -529
  214. package/docs/specs/003-improve-memory/design.md +0 -537
  215. package/docs/specs/003-improve-memory/interfaces-and-tests.md +0 -473
  216. package/docs/specs/003-improve-memory/spec.md +0 -357
@@ -155,4 +155,3 @@ export async function appendChannelHistoryBlock(channelDir, block) {
155
155
  const renderedBlock = [`## ${block.timestamp}`, trimmedContent].join("\n\n");
156
156
  await writeAtomically(path, `${ensureTrailingNewlines(existing)}${renderedBlock}\n`);
157
157
  }
158
- //# sourceMappingURL=files.js.map
@@ -1,7 +1,7 @@
1
1
  import type { AgentMessage } from "@mariozechner/pi-agent-core";
2
2
  import type { Api, Model } from "@mariozechner/pi-ai";
3
3
  import type { ExtensionFactory, SessionEntry } from "@mariozechner/pi-coding-agent";
4
- import type { PipiclawSessionMemorySettings } from "../context.js";
4
+ import type { PipiclawSessionMemorySettings } from "../settings.js";
5
5
  export type ConsolidationReason = "compaction" | "new-session" | "idle";
6
6
  export interface MemoryLifecycleOptions {
7
7
  channelId: string;
@@ -51,4 +51,3 @@ export declare class MemoryLifecycle {
51
51
  private enqueueBackgroundMaintenance;
52
52
  private logBackgroundResult;
53
53
  }
54
- //# sourceMappingURL=lifecycle.d.ts.map
@@ -244,4 +244,3 @@ export class MemoryLifecycle {
244
244
  log.logInfo(`[${this.options.channelId}] Background memory maintenance complete: ${details}`);
245
245
  }
246
246
  }
247
- //# sourceMappingURL=lifecycle.js.map
@@ -25,5 +25,5 @@ export interface RecallResult {
25
25
  items: RecalledMemory[];
26
26
  renderedText: string;
27
27
  }
28
+ export declare function tokenizeRecallText(text: string): string[];
28
29
  export declare function recallRelevantMemory(request: RecallRequest): Promise<RecallResult>;
29
- //# sourceMappingURL=recall.d.ts.map
@@ -1,8 +1,8 @@
1
- import { parseJsonObject } from "../llm-json.js";
1
+ import { parseJsonObject } from "../shared/llm-json.js";
2
2
  import { HAN_REGEX } from "../shared/text-utils.js";
3
- import { runSidecarTask } from "../sidecar-worker.js";
4
3
  import { buildMemoryCandidates } from "./candidates.js";
5
4
  import { COMMON_CHINESE_WORDS } from "./chinese-words.js";
5
+ import { runSidecarTask } from "./sidecar-worker.js";
6
6
  const RERANK_SYSTEM_PROMPT = `You are selecting which memory snippets are most relevant to the current user turn.
7
7
 
8
8
  Return strict JSON only:
@@ -80,32 +80,96 @@ const LATIN_STOP_WORDS = new Set([
80
80
  "you",
81
81
  "your",
82
82
  ]);
83
+ const CHINESE_STOP_CHARS = new Set([
84
+ "的",
85
+ "了",
86
+ "在",
87
+ "是",
88
+ "有",
89
+ "不",
90
+ "和",
91
+ "与",
92
+ "个",
93
+ "把",
94
+ "被",
95
+ "从",
96
+ "对",
97
+ "而",
98
+ "给",
99
+ "将",
100
+ "就",
101
+ "让",
102
+ "向",
103
+ "也",
104
+ "以",
105
+ "因",
106
+ "又",
107
+ "于",
108
+ "则",
109
+ "之",
110
+ "这",
111
+ "那",
112
+ "其",
113
+ "它",
114
+ "他",
115
+ "她",
116
+ "们",
117
+ "都",
118
+ "要",
119
+ "会",
120
+ "能",
121
+ "很",
122
+ "得",
123
+ "地",
124
+ "着",
125
+ "过",
126
+ "吗",
127
+ "呢",
128
+ "吧",
129
+ "啊",
130
+ "哦",
131
+ "嗯",
132
+ "呀",
133
+ ]);
83
134
  function containsHanText(text) {
84
135
  return HAN_REGEX.test(text);
85
136
  }
86
137
  function tokenizeHanPart(part) {
87
138
  const chars = Array.from(part);
139
+ const covered = new Uint8Array(chars.length);
88
140
  const tokens = [];
89
- for (let index = 0; index < chars.length;) {
90
- let matched = "";
141
+ for (let index = 0; index < chars.length; index++) {
142
+ let matchedLength = 0;
91
143
  const maxLength = Math.min(MAX_HAN_WORD_LENGTH, chars.length - index);
92
144
  for (let size = maxLength; size >= 2; size--) {
93
145
  const candidate = chars.slice(index, index + size).join("");
94
146
  if (COMMON_CHINESE_WORDS.has(candidate)) {
95
- matched = candidate;
147
+ tokens.push(candidate);
148
+ matchedLength = size;
96
149
  break;
97
150
  }
98
151
  }
99
- if (matched) {
100
- tokens.push(matched);
101
- index += Array.from(matched).length;
102
- continue;
152
+ if (matchedLength > 0) {
153
+ for (let coveredIndex = index; coveredIndex < index + matchedLength; coveredIndex++) {
154
+ covered[coveredIndex] = 1;
155
+ }
103
156
  }
104
- index++;
105
157
  }
106
158
  for (let index = 0; index <= chars.length - 2; index++) {
159
+ if (covered[index] || covered[index + 1]) {
160
+ continue;
161
+ }
107
162
  tokens.push(chars.slice(index, index + 2).join(""));
108
163
  }
164
+ for (let index = 0; index < chars.length; index++) {
165
+ if (covered[index]) {
166
+ continue;
167
+ }
168
+ const char = chars[index];
169
+ if (!CHINESE_STOP_CHARS.has(char)) {
170
+ tokens.push(char);
171
+ }
172
+ }
109
173
  return Array.from(new Set(tokens));
110
174
  }
111
175
  function tokenizeAsciiPart(part) {
@@ -134,6 +198,9 @@ function tokenize(text) {
134
198
  }
135
199
  return Array.from(new Set(tokens));
136
200
  }
201
+ export function tokenizeRecallText(text) {
202
+ return tokenize(text);
203
+ }
137
204
  function buildTokenSet(text) {
138
205
  return new Set(tokenize(text));
139
206
  }
@@ -432,4 +499,3 @@ export async function recallRelevantMemory(request) {
432
499
  renderedText: renderRecallResult(items, request.maxChars),
433
500
  };
434
501
  }
435
- //# sourceMappingURL=recall.js.map
@@ -20,4 +20,3 @@ export interface SessionMemoryUpdateOptions {
20
20
  }
21
21
  export declare function renderSessionMemory(state: SessionMemoryState): string;
22
22
  export declare function updateChannelSessionMemory(options: SessionMemoryUpdateOptions): Promise<SessionMemoryState>;
23
- //# sourceMappingURL=session.d.ts.map
@@ -1,12 +1,12 @@
1
1
  import { serializeConversation } from "@mariozechner/pi-coding-agent";
2
2
  import { writeFile } from "fs/promises";
3
3
  import { join } from "path";
4
- import { parseJsonObject } from "../llm-json.js";
4
+ import { parseJsonObject } from "../shared/llm-json.js";
5
5
  import { splitH1Sections } from "../shared/markdown-sections.js";
6
6
  import { clipText } from "../shared/text-utils.js";
7
7
  import { buildStandardMessages, isRecord } from "../shared/type-guards.js";
8
- import { runSidecarTask, SidecarParseError } from "../sidecar-worker.js";
9
8
  import { readChannelMemory, readChannelSession, rewriteChannelSession } from "./files.js";
9
+ import { runSidecarTask, SidecarParseError } from "./sidecar-worker.js";
10
10
  const SESSION_TRANSCRIPT_MAX_CHARS = 20_000;
11
11
  const SESSION_MEMORY_MAX_CHARS = 4_000;
12
12
  const SESSION_ITEM_LIMIT = 12;
@@ -241,4 +241,3 @@ export async function updateChannelSessionMemory(options) {
241
241
  await rewriteChannelSession(options.channelDir, rendered);
242
242
  return parseRenderedSessionMemory(rendered);
243
243
  }
244
- //# sourceMappingURL=session.js.map
@@ -24,4 +24,3 @@ export declare class SidecarParseError extends Error {
24
24
  constructor(taskName: string, rawText: string, cause: unknown);
25
25
  }
26
26
  export declare function runSidecarTask<T>(task: SidecarTask<T>): Promise<SidecarResult<T>>;
27
- //# sourceMappingURL=sidecar-worker.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { Agent } from "@mariozechner/pi-agent-core";
2
2
  import { convertToLlm } from "@mariozechner/pi-coding-agent";
3
- import { extractAssistantText } from "./shared/text-utils.js";
3
+ import { extractAssistantText } from "../shared/text-utils.js";
4
4
  export class SidecarTimeoutError extends Error {
5
5
  constructor(taskName, timeoutMs) {
6
6
  super(`Sidecar task "${taskName}" timed out after ${timeoutMs}ms`);
@@ -96,4 +96,3 @@ export async function runSidecarTask(task) {
96
96
  removeAbortListener();
97
97
  }
98
98
  }
99
- //# sourceMappingURL=sidecar-worker.js.map
@@ -0,0 +1,7 @@
1
+ import type { Api, Model } from "@mariozechner/pi-ai";
2
+ import type { ModelRegistry } from "@mariozechner/pi-coding-agent";
3
+ /**
4
+ * Resolve an API key for the given model's provider.
5
+ * Checks ModelRegistry first, then falls back to ANTHROPIC_API_KEY.
6
+ */
7
+ export declare function getApiKeyForModel(modelRegistry: ModelRegistry, model: Model<Api>): Promise<string>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Resolve an API key for the given model's provider.
3
+ * Checks ModelRegistry first, then falls back to ANTHROPIC_API_KEY.
4
+ */
5
+ export async function getApiKeyForModel(modelRegistry, model) {
6
+ const key = await modelRegistry.getApiKeyForProvider(model.provider);
7
+ if (key) {
8
+ return key;
9
+ }
10
+ const envKey = process.env.ANTHROPIC_API_KEY;
11
+ if (envKey) {
12
+ return envKey;
13
+ }
14
+ throw new Error(`No API key found for provider: ${model.provider}.\n\n` +
15
+ "Configure credentials in ~/.pi/pipiclaw/auth.json or ~/.pi/pipiclaw/models.json, or set the matching provider environment variable.");
16
+ }
@@ -1,6 +1,6 @@
1
1
  import { type Api, type Model } from "@mariozechner/pi-ai";
2
2
  import type { ModelRegistry } from "@mariozechner/pi-coding-agent";
3
- import type { PipiclawSettingsManager } from "./context.js";
3
+ import type { PipiclawSettingsManager } from "../settings.js";
4
4
  export declare function formatModelReference(model: Model<Api>): string;
5
5
  export declare function findExactModelReferenceMatch(modelReference: string, availableModels: Model<Api>[]): {
6
6
  match?: Model<Api>;
@@ -8,4 +8,3 @@ export declare function findExactModelReferenceMatch(modelReference: string, ava
8
8
  };
9
9
  export declare function formatModelList(models: Model<Api>[], currentModel: Model<Api> | undefined, limit?: number): string;
10
10
  export declare function resolveInitialModel(modelRegistry: ModelRegistry, settingsManager: PipiclawSettingsManager): Model<Api>;
11
- //# sourceMappingURL=model-utils.d.ts.map
@@ -70,4 +70,3 @@ export function resolveInitialModel(modelRegistry, settingsManager) {
70
70
  }
71
71
  return defaultModel;
72
72
  }
73
- //# sourceMappingURL=model-utils.js.map
package/dist/paths.d.ts CHANGED
@@ -7,4 +7,3 @@ export declare const CHANNEL_CONFIG_PATH: string;
7
7
  export declare const AUTH_CONFIG_PATH: string;
8
8
  export declare const MODELS_CONFIG_PATH: string;
9
9
  export declare const SETTINGS_CONFIG_PATH: string;
10
- //# sourceMappingURL=paths.d.ts.map
package/dist/paths.js CHANGED
@@ -9,4 +9,3 @@ export const CHANNEL_CONFIG_PATH = join(APP_HOME_DIR, "channel.json");
9
9
  export const AUTH_CONFIG_PATH = join(APP_HOME_DIR, "auth.json");
10
10
  export const MODELS_CONFIG_PATH = join(APP_HOME_DIR, "models.json");
11
11
  export const SETTINGS_CONFIG_PATH = join(APP_HOME_DIR, "settings.json");
12
- //# sourceMappingURL=paths.js.map
@@ -45,4 +45,3 @@ export declare function printBootstrapSummary(result: BootstrapResult, io?: Boot
45
45
  export declare function loadConfig(paths?: BootstrapPaths, io?: BootstrapIO): DingTalkConfig;
46
46
  export declare function parseArgs(argv: string[], paths?: BootstrapPaths, io?: BootstrapIO): ParsedArgs;
47
47
  export declare function bootstrap(argv: string[], options?: BootstrapOptions): Promise<AppContext>;
48
- //# sourceMappingURL=bootstrap.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
2
2
  import { join } from "path";
3
- import { getOrCreateRunner } from "../agent.js";
4
- import { parseBuiltInCommand } from "../commands.js";
3
+ import { parseBuiltInCommand } from "../agent/commands.js";
4
+ import { getOrCreateRunner } from "../agent/index.js";
5
5
  import * as log from "../log.js";
6
6
  import { ensureChannelMemoryFilesSync } from "../memory/files.js";
7
7
  import { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, MODELS_CONFIG_PATH, SETTINGS_CONFIG_PATH, WORKSPACE_DIR, } from "../paths.js";
@@ -448,4 +448,3 @@ export async function bootstrap(argv, options = {}) {
448
448
  },
449
449
  };
450
450
  }
451
- //# sourceMappingURL=bootstrap.js.map
@@ -1,4 +1,3 @@
1
1
  import type { DingTalkBot, DingTalkContext, DingTalkEvent } from "./dingtalk.js";
2
2
  import type { ChannelStore } from "./store.js";
3
3
  export declare function createDingTalkContext(event: DingTalkEvent, bot: DingTalkBot, store: ChannelStore): DingTalkContext;
4
- //# sourceMappingURL=delivery.d.ts.map
@@ -215,4 +215,3 @@ class ChannelDeliveryController {
215
215
  export function createDingTalkContext(event, bot, store) {
216
216
  return new ChannelDeliveryController(event, bot, store).buildContext();
217
217
  }
218
- //# sourceMappingURL=delivery.js.map
@@ -120,4 +120,3 @@ export declare class DingTalkBot {
120
120
  private setConversationMeta;
121
121
  private getConversationMetaPath;
122
122
  }
123
- //# sourceMappingURL=dingtalk.d.ts.map
@@ -11,7 +11,7 @@ import axios from "axios";
11
11
  import { DWClient, TOPIC_ROBOT } from "dingtalk-stream";
12
12
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
13
13
  import { dirname, join } from "path";
14
- import { parseBuiltInCommand, renderBuiltInHelp } from "../commands.js";
14
+ import { parseBuiltInCommand, renderBuiltInHelp } from "../agent/commands.js";
15
15
  import * as log from "../log.js";
16
16
  import { isRecord } from "../shared/type-guards.js";
17
17
  class ChannelQueue {
@@ -764,4 +764,3 @@ export class DingTalkBot {
764
764
  return join(this.config.stateDir, channelId, ".channel-meta.json");
765
765
  }
766
766
  }
767
- //# sourceMappingURL=dingtalk.js.map
@@ -48,4 +48,3 @@ export declare class EventsWatcher {
48
48
  * Create and start an events watcher.
49
49
  */
50
50
  export declare function createEventsWatcher(workspaceDir: string, bot: DingTalkBot): EventsWatcher;
51
- //# sourceMappingURL=events.d.ts.map
@@ -292,4 +292,3 @@ export function createEventsWatcher(workspaceDir, bot) {
292
292
  const eventsDir = join(workspaceDir, "events");
293
293
  return new EventsWatcher(eventsDir, bot);
294
294
  }
295
- //# sourceMappingURL=events.js.map
@@ -77,4 +77,3 @@ export declare class ChannelStore {
77
77
  private startCleanupTimer;
78
78
  private cleanupExpiredEntries;
79
79
  }
80
- //# sourceMappingURL=store.d.ts.map
@@ -194,4 +194,3 @@ export class ChannelStore {
194
194
  }
195
195
  }
196
196
  }
197
- //# sourceMappingURL=store.js.map
package/dist/sandbox.d.ts CHANGED
@@ -32,4 +32,3 @@ export interface ExecResult {
32
32
  stderr: string;
33
33
  code: number;
34
34
  }
35
- //# sourceMappingURL=sandbox.d.ts.map
package/dist/sandbox.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { spawn } from "child_process";
2
- import { shellEscape } from "./shell-escape.js";
2
+ import { shellEscape } from "./shared/shell-escape.js";
3
3
  export function parseSandboxArg(value) {
4
4
  if (value === "host") {
5
5
  return { type: "host" };
@@ -219,4 +219,3 @@ function killProcessTree(pid) {
219
219
  }
220
220
  }
221
221
  }
222
- //# sourceMappingURL=sandbox.js.map
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Context management for pipiclaw.
2
+ * Settings management for pipiclaw.
3
3
  *
4
4
  * `log.jsonl` and `context.jsonl` are treated as raw cold storage.
5
5
  * They are not proactively scanned or loaded as part of the memory model.
@@ -179,4 +179,3 @@ export declare class PipiclawSettingsManager {
179
179
  drainErrors(): SettingsError[];
180
180
  }
181
181
  export {};
182
- //# sourceMappingURL=context.d.ts.map
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Context management for pipiclaw.
2
+ * Settings management for pipiclaw.
3
3
  *
4
4
  * `log.jsonl` and `context.jsonl` are treated as raw cold storage.
5
5
  * They are not proactively scanned or loaded as part of the memory model.
@@ -381,4 +381,3 @@ export class PipiclawSettingsManager {
381
381
  return [];
382
382
  }
383
383
  }
384
- //# sourceMappingURL=context.js.map
@@ -4,4 +4,3 @@ export declare class LlmJsonParseError extends Error {
4
4
  }
5
5
  export declare function extractJsonObject(text: string): string;
6
6
  export declare function parseJsonObject(text: string): unknown;
7
- //# sourceMappingURL=llm-json.d.ts.map
@@ -74,4 +74,3 @@ export function extractJsonObject(text) {
74
74
  export function parseJsonObject(text) {
75
75
  return JSON.parse(extractJsonObject(text));
76
76
  }
77
- //# sourceMappingURL=llm-json.js.map
@@ -4,4 +4,3 @@ export interface MarkdownSection {
4
4
  }
5
5
  export declare function splitH1Sections(content: string): MarkdownSection[];
6
6
  export declare function splitH2Sections(content: string): MarkdownSection[];
7
- //# sourceMappingURL=markdown-sections.d.ts.map
@@ -38,4 +38,3 @@ export function splitH1Sections(content) {
38
38
  export function splitH2Sections(content) {
39
39
  return splitSectionsByHeading(content, "## ");
40
40
  }
41
- //# sourceMappingURL=markdown-sections.js.map
@@ -3,4 +3,3 @@
3
3
  * Wraps in single quotes and escapes internal single quotes.
4
4
  */
5
5
  export declare function shellEscape(s: string): string;
6
- //# sourceMappingURL=shell-escape.d.ts.map
@@ -5,4 +5,3 @@
5
5
  export function shellEscape(s) {
6
6
  return `'${s.replace(/'/g, "'\\''")}'`;
7
7
  }
8
- //# sourceMappingURL=shell-escape.js.map
@@ -7,4 +7,3 @@ export declare function truncate(text: string, maxLen: number): string;
7
7
  export declare const HAN_REGEX: RegExp;
8
8
  export declare function extractLabelFromArgs(args: unknown): string | null;
9
9
  export declare function extractAssistantText(message: AssistantMessage): string;
10
- //# sourceMappingURL=text-utils.d.ts.map
@@ -34,4 +34,3 @@ export function extractAssistantText(message) {
34
34
  .join("\n")
35
35
  .trim();
36
36
  }
37
- //# sourceMappingURL=text-utils.js.map
@@ -3,4 +3,3 @@ import type { Message } from "@mariozechner/pi-ai";
3
3
  export declare function isRecord(value: unknown): value is Record<string, unknown>;
4
4
  export declare function isStandardAgentMessage(message: AgentMessage): message is Message;
5
5
  export declare function buildStandardMessages(messages: AgentMessage[]): Message[];
6
- //# sourceMappingURL=type-guards.d.ts.map
@@ -10,4 +10,3 @@ export function isStandardAgentMessage(message) {
10
10
  export function buildStandardMessages(messages) {
11
11
  return messages.filter(isStandardAgentMessage);
12
12
  }
13
- //# sourceMappingURL=type-guards.js.map
@@ -12,4 +12,3 @@ export interface UsageTotals {
12
12
  total: number;
13
13
  };
14
14
  }
15
- //# sourceMappingURL=types.d.ts.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=types.js.map
@@ -58,4 +58,3 @@ export declare function resolveSubAgentConfig(availableModels: Model<Api>[], cur
58
58
  };
59
59
  export declare function formatSubAgentList(agents: SubAgentConfig[], maxItems?: number): string;
60
60
  export {};
61
- //# sourceMappingURL=discovery.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import { parseFrontmatter } from "@mariozechner/pi-coding-agent";
2
2
  import { existsSync, readdirSync, readFileSync } from "fs";
3
3
  import { join } from "path";
4
- import { findExactModelReferenceMatch, formatModelReference } from "../model-utils.js";
4
+ import { findExactModelReferenceMatch, formatModelReference } from "../models/utils.js";
5
5
  import { SUB_AGENTS_DIR_NAME } from "../paths.js";
6
6
  const ALLOWED_SUB_AGENT_TOOLS = ["read", "bash", "edit", "write"];
7
7
  const DEFAULT_SUB_AGENT_TOOLS = ["read", "bash"];
@@ -366,4 +366,3 @@ export function formatSubAgentList(agents, maxItems = 12) {
366
366
  }
367
367
  return `${listed.join("\n")}\n- ... and ${agents.length - maxItems} more`;
368
368
  }
369
- //# sourceMappingURL=discovery.js.map
@@ -1,7 +1,7 @@
1
1
  import { type AgentEvent, type AgentMessage, type AgentTool } from "@mariozechner/pi-agent-core";
2
2
  import type { Api, Model } from "@mariozechner/pi-ai";
3
- import type { PipiclawMemoryRecallSettings } from "../context.js";
4
3
  import type { Executor } from "../sandbox.js";
4
+ import type { PipiclawMemoryRecallSettings } from "../settings.js";
5
5
  import type { UsageTotals } from "../shared/types.js";
6
6
  import { type ResolvedSubAgentConfig, type SubAgentDiscoveryResult } from "./discovery.js";
7
7
  declare const subagentSchema: import("@sinclair/typebox").TObject<{
@@ -64,4 +64,3 @@ interface SubAgentWorker {
64
64
  }
65
65
  export declare function createSubAgentTool(options: SubAgentToolOptions): AgentTool<typeof subagentSchema, SubAgentToolDetails>;
66
66
  export {};
67
- //# sourceMappingURL=tool.d.ts.map
@@ -4,7 +4,7 @@ import { Type } from "@sinclair/typebox";
4
4
  import { createMemoryCandidateCache } from "../memory/candidates.js";
5
5
  import { readChannelSession } from "../memory/files.js";
6
6
  import { recallRelevantMemory } from "../memory/recall.js";
7
- import { formatModelReference } from "../model-utils.js";
7
+ import { formatModelReference } from "../models/utils.js";
8
8
  import { splitH1Sections } from "../shared/markdown-sections.js";
9
9
  import { clipText, extractAssistantText, extractLabelFromArgs, HAN_REGEX } from "../shared/text-utils.js";
10
10
  import { createBashTool } from "../tools/bash.js";
@@ -373,4 +373,3 @@ export function createSubAgentTool(options) {
373
373
  },
374
374
  };
375
375
  }
376
- //# sourceMappingURL=tool.js.map
@@ -11,4 +11,3 @@ export type UploadFunction = (filePath: string, title?: string) => Promise<void>
11
11
  */
12
12
  export declare function createAttachTool(uploadFn?: UploadFunction): AgentTool<typeof attachSchema>;
13
13
  export {};
14
- //# sourceMappingURL=attach.d.ts.map
@@ -32,4 +32,3 @@ export function createAttachTool(uploadFn) {
32
32
  },
33
33
  };
34
34
  }
35
- //# sourceMappingURL=attach.js.map
@@ -10,4 +10,3 @@ export interface BashToolOptions {
10
10
  }
11
11
  export declare function createBashTool(executor: Executor, options?: BashToolOptions): AgentTool<typeof bashSchema>;
12
12
  export {};
13
- //# sourceMappingURL=bash.d.ts.map
@@ -76,4 +76,3 @@ export function createBashTool(executor, options = {}) {
76
76
  },
77
77
  };
78
78
  }
79
- //# sourceMappingURL=bash.js.map
@@ -8,4 +8,3 @@ declare const editSchema: import("@sinclair/typebox").TObject<{
8
8
  }>;
9
9
  export declare function createEditTool(executor: Executor): AgentTool<typeof editSchema>;
10
10
  export {};
11
- //# sourceMappingURL=edit.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  import * as Diff from "diff";
3
- import { shellEscape } from "../shell-escape.js";
3
+ import { shellEscape } from "../shared/shell-escape.js";
4
4
  import { writeContent } from "./write-content.js";
5
5
  /**
6
6
  * Generate a unified diff string with line numbers and context
@@ -122,4 +122,3 @@ export function createEditTool(executor) {
122
122
  },
123
123
  };
124
124
  }
125
- //# sourceMappingURL=edit.js.map
@@ -1,7 +1,7 @@
1
1
  import type { AgentTool } from "@mariozechner/pi-agent-core";
2
2
  import type { Api, Model } from "@mariozechner/pi-ai";
3
- import type { PipiclawMemoryRecallSettings } from "../context.js";
4
3
  import type { Executor, SandboxConfig } from "../sandbox.js";
4
+ import type { PipiclawMemoryRecallSettings } from "../settings.js";
5
5
  import type { SubAgentDiscoveryResult } from "../subagents/discovery.js";
6
6
  export interface CreatePipiclawToolsOptions {
7
7
  executor: Executor;
@@ -18,4 +18,3 @@ export interface CreatePipiclawToolsOptions {
18
18
  }
19
19
  export declare function createPipiclawBaseTools(executor: Executor): AgentTool<any>[];
20
20
  export declare function createPipiclawTools(options: CreatePipiclawToolsOptions): AgentTool<any>[];
21
- //# sourceMappingURL=index.d.ts.map
@@ -27,4 +27,3 @@ export function createPipiclawTools(options) {
27
27
  }),
28
28
  ];
29
29
  }
30
- //# sourceMappingURL=index.js.map
@@ -8,4 +8,3 @@ declare const readSchema: import("@sinclair/typebox").TObject<{
8
8
  }>;
9
9
  export declare function createReadTool(executor: Executor): AgentTool<typeof readSchema>;
10
10
  export {};
11
- //# sourceMappingURL=read.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { Type } from "@sinclair/typebox";
2
2
  import { extname } from "path";
3
- import { shellEscape } from "../shell-escape.js";
3
+ import { shellEscape } from "../shared/shell-escape.js";
4
4
  import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize, truncateHead } from "./truncate.js";
5
5
  /**
6
6
  * Map of file extensions to MIME types for common image formats
@@ -129,4 +129,3 @@ export function createReadTool(executor) {
129
129
  },
130
130
  };
131
131
  }
132
- //# sourceMappingURL=read.js.map
@@ -54,4 +54,3 @@ export declare function truncateHead(content: string, options?: TruncationOption
54
54
  * May return partial first line if the last line of original content exceeds byte limit.
55
55
  */
56
56
  export declare function truncateTail(content: string, options?: TruncationOptions): TruncationResult;
57
- //# sourceMappingURL=truncate.d.ts.map
@@ -181,4 +181,3 @@ function truncateStringToBytesFromEnd(str, maxBytes) {
181
181
  }
182
182
  return buf.slice(start).toString("utf-8");
183
183
  }
184
- //# sourceMappingURL=truncate.js.map
@@ -2,4 +2,3 @@ import type { Executor } from "../sandbox.js";
2
2
  export declare function writeContent(executor: Executor, path: string, content: string, signal: AbortSignal | undefined, options?: {
3
3
  createParentDir?: boolean;
4
4
  }): Promise<void>;
5
- //# sourceMappingURL=write-content.d.ts.map