@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.
- package/README.md +308 -209
- package/dist/agent/channel-runner.d.ts +3 -2
- package/dist/agent/channel-runner.js +22 -14
- package/dist/{command-extension.d.ts → agent/command-extension.d.ts} +0 -1
- package/dist/{command-extension.js → agent/command-extension.js} +1 -2
- package/dist/{commands.d.ts → agent/commands.d.ts} +0 -1
- package/dist/{commands.js → agent/commands.js} +0 -1
- package/dist/agent/index.d.ts +0 -1
- package/dist/agent/index.js +0 -1
- package/dist/agent/progress-formatter.d.ts +0 -1
- package/dist/agent/progress-formatter.js +0 -1
- package/dist/{prompt-builder.d.ts → agent/prompt-builder.d.ts} +1 -2
- package/dist/{prompt-builder.js → agent/prompt-builder.js} +0 -1
- package/dist/agent/run-queue.d.ts +0 -1
- package/dist/agent/run-queue.js +0 -1
- package/dist/agent/runner-factory.d.ts +0 -1
- package/dist/agent/runner-factory.js +0 -1
- package/dist/agent/session-events.d.ts +0 -1
- package/dist/agent/session-events.js +0 -1
- package/dist/agent/session-resource-gate.d.ts +10 -0
- package/dist/agent/session-resource-gate.js +44 -0
- package/dist/agent/type-guards.d.ts +0 -1
- package/dist/agent/type-guards.js +1 -2
- package/dist/agent/types.d.ts +1 -2
- package/dist/agent/types.js +0 -1
- package/dist/{config-loader.d.ts → agent/workspace-resources.d.ts} +3 -10
- package/dist/{config-loader.js → agent/workspace-resources.js} +3 -19
- package/dist/index.d.ts +9 -9
- package/dist/index.js +9 -9
- package/dist/log.d.ts +0 -1
- package/dist/log.js +0 -1
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -1
- package/dist/memory/bootstrap.d.ts +0 -1
- package/dist/memory/bootstrap.js +0 -1
- package/dist/memory/candidates.d.ts +0 -1
- package/dist/memory/candidates.js +0 -1
- package/dist/memory/chinese-words.d.ts +0 -1
- package/dist/memory/chinese-words.js +64 -1
- package/dist/memory/consolidation.d.ts +0 -1
- package/dist/memory/consolidation.js +2 -3
- package/dist/memory/files.d.ts +0 -1
- package/dist/memory/files.js +0 -1
- package/dist/memory/lifecycle.d.ts +1 -2
- package/dist/memory/lifecycle.js +0 -1
- package/dist/memory/recall.d.ts +1 -1
- package/dist/memory/recall.js +77 -11
- package/dist/memory/session.d.ts +0 -1
- package/dist/memory/session.js +2 -3
- package/dist/{sidecar-worker.d.ts → memory/sidecar-worker.d.ts} +0 -1
- package/dist/{sidecar-worker.js → memory/sidecar-worker.js} +1 -2
- package/dist/models/api-keys.d.ts +7 -0
- package/dist/models/api-keys.js +16 -0
- package/dist/{model-utils.d.ts → models/utils.d.ts} +1 -2
- package/dist/{model-utils.js → models/utils.js} +0 -1
- package/dist/paths.d.ts +0 -1
- package/dist/paths.js +0 -1
- package/dist/runtime/bootstrap.d.ts +0 -1
- package/dist/runtime/bootstrap.js +2 -3
- package/dist/runtime/delivery.d.ts +0 -1
- package/dist/runtime/delivery.js +0 -1
- package/dist/runtime/dingtalk.d.ts +0 -1
- package/dist/runtime/dingtalk.js +1 -2
- package/dist/runtime/events.d.ts +0 -1
- package/dist/runtime/events.js +0 -1
- package/dist/runtime/store.d.ts +0 -1
- package/dist/runtime/store.js +0 -1
- package/dist/sandbox.d.ts +0 -1
- package/dist/sandbox.js +1 -2
- package/dist/{context.d.ts → settings.d.ts} +1 -2
- package/dist/{context.js → settings.js} +1 -2
- package/dist/{llm-json.d.ts → shared/llm-json.d.ts} +0 -1
- package/dist/{llm-json.js → shared/llm-json.js} +0 -1
- package/dist/shared/markdown-sections.d.ts +0 -1
- package/dist/shared/markdown-sections.js +0 -1
- package/dist/{shell-escape.d.ts → shared/shell-escape.d.ts} +0 -1
- package/dist/{shell-escape.js → shared/shell-escape.js} +0 -1
- package/dist/shared/text-utils.d.ts +0 -1
- package/dist/shared/text-utils.js +0 -1
- package/dist/shared/type-guards.d.ts +0 -1
- package/dist/shared/type-guards.js +0 -1
- package/dist/shared/types.d.ts +0 -1
- package/dist/shared/types.js +0 -1
- package/dist/subagents/discovery.d.ts +0 -1
- package/dist/subagents/discovery.js +1 -2
- package/dist/subagents/tool.d.ts +1 -2
- package/dist/subagents/tool.js +1 -2
- package/dist/tools/attach.d.ts +0 -1
- package/dist/tools/attach.js +0 -1
- package/dist/tools/bash.d.ts +0 -1
- package/dist/tools/bash.js +0 -1
- package/dist/tools/edit.d.ts +0 -1
- package/dist/tools/edit.js +1 -2
- package/dist/tools/index.d.ts +1 -2
- package/dist/tools/index.js +0 -1
- package/dist/tools/read.d.ts +0 -1
- package/dist/tools/read.js +1 -2
- package/dist/tools/truncate.d.ts +0 -1
- package/dist/tools/truncate.js +0 -1
- package/dist/tools/write-content.d.ts +0 -1
- package/dist/tools/write-content.js +1 -2
- package/dist/tools/write.d.ts +0 -1
- package/dist/tools/write.js +0 -1
- package/package.json +9 -3
- package/CHANGELOG.md +0 -47
- package/dist/agent/channel-runner.d.ts.map +0 -1
- package/dist/agent/channel-runner.js.map +0 -1
- package/dist/agent/index.d.ts.map +0 -1
- package/dist/agent/index.js.map +0 -1
- package/dist/agent/progress-formatter.d.ts.map +0 -1
- package/dist/agent/progress-formatter.js.map +0 -1
- package/dist/agent/run-queue.d.ts.map +0 -1
- package/dist/agent/run-queue.js.map +0 -1
- package/dist/agent/runner-factory.d.ts.map +0 -1
- package/dist/agent/runner-factory.js.map +0 -1
- package/dist/agent/session-events.d.ts.map +0 -1
- package/dist/agent/session-events.js.map +0 -1
- package/dist/agent/type-guards.d.ts.map +0 -1
- package/dist/agent/type-guards.js.map +0 -1
- package/dist/agent/types.d.ts.map +0 -1
- package/dist/agent/types.js.map +0 -1
- package/dist/agent.d.ts +0 -3
- package/dist/agent.d.ts.map +0 -1
- package/dist/agent.js +0 -2
- package/dist/agent.js.map +0 -1
- package/dist/command-extension.d.ts.map +0 -1
- package/dist/command-extension.js.map +0 -1
- package/dist/commands.d.ts.map +0 -1
- package/dist/commands.js.map +0 -1
- package/dist/config-loader.d.ts.map +0 -1
- package/dist/config-loader.js.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/llm-json.d.ts.map +0 -1
- package/dist/llm-json.js.map +0 -1
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js.map +0 -1
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js.map +0 -1
- package/dist/memory/bootstrap.d.ts.map +0 -1
- package/dist/memory/bootstrap.js.map +0 -1
- package/dist/memory/candidates.d.ts.map +0 -1
- package/dist/memory/candidates.js.map +0 -1
- package/dist/memory/chinese-words.d.ts.map +0 -1
- package/dist/memory/chinese-words.js.map +0 -1
- package/dist/memory/consolidation.d.ts.map +0 -1
- package/dist/memory/consolidation.js.map +0 -1
- package/dist/memory/files.d.ts.map +0 -1
- package/dist/memory/files.js.map +0 -1
- package/dist/memory/lifecycle.d.ts.map +0 -1
- package/dist/memory/lifecycle.js.map +0 -1
- package/dist/memory/recall.d.ts.map +0 -1
- package/dist/memory/recall.js.map +0 -1
- package/dist/memory/session.d.ts.map +0 -1
- package/dist/memory/session.js.map +0 -1
- package/dist/model-utils.d.ts.map +0 -1
- package/dist/model-utils.js.map +0 -1
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js.map +0 -1
- package/dist/prompt-builder.d.ts.map +0 -1
- package/dist/prompt-builder.js.map +0 -1
- package/dist/runtime/bootstrap.d.ts.map +0 -1
- package/dist/runtime/bootstrap.js.map +0 -1
- package/dist/runtime/delivery.d.ts.map +0 -1
- package/dist/runtime/delivery.js.map +0 -1
- package/dist/runtime/dingtalk.d.ts.map +0 -1
- package/dist/runtime/dingtalk.js.map +0 -1
- package/dist/runtime/events.d.ts.map +0 -1
- package/dist/runtime/events.js.map +0 -1
- package/dist/runtime/store.d.ts.map +0 -1
- package/dist/runtime/store.js.map +0 -1
- package/dist/sandbox.d.ts.map +0 -1
- package/dist/sandbox.js.map +0 -1
- package/dist/shared/markdown-sections.d.ts.map +0 -1
- package/dist/shared/markdown-sections.js.map +0 -1
- package/dist/shared/text-utils.d.ts.map +0 -1
- package/dist/shared/text-utils.js.map +0 -1
- package/dist/shared/type-guards.d.ts.map +0 -1
- package/dist/shared/type-guards.js.map +0 -1
- package/dist/shared/types.d.ts.map +0 -1
- package/dist/shared/types.js.map +0 -1
- package/dist/shell-escape.d.ts.map +0 -1
- package/dist/shell-escape.js.map +0 -1
- package/dist/sidecar-worker.d.ts.map +0 -1
- package/dist/sidecar-worker.js.map +0 -1
- package/dist/subagents/discovery.d.ts.map +0 -1
- package/dist/subagents/discovery.js.map +0 -1
- package/dist/subagents/tool.d.ts.map +0 -1
- package/dist/subagents/tool.js.map +0 -1
- package/dist/tools/attach.d.ts.map +0 -1
- package/dist/tools/attach.js.map +0 -1
- package/dist/tools/bash.d.ts.map +0 -1
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/edit.d.ts.map +0 -1
- package/dist/tools/edit.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/read.d.ts.map +0 -1
- package/dist/tools/read.js.map +0 -1
- package/dist/tools/truncate.d.ts.map +0 -1
- package/dist/tools/truncate.js.map +0 -1
- package/dist/tools/write-content.d.ts.map +0 -1
- package/dist/tools/write-content.js.map +0 -1
- package/dist/tools/write.d.ts.map +0 -1
- package/dist/tools/write.js.map +0 -1
- package/docs/memory-audit.md +0 -330
- package/docs/memory-optimization-round2.md +0 -319
- package/docs/specs/001-implement-memory/memory-rfc.md +0 -297
- package/docs/specs/002-subagent/pi-subagent-analyse.txt +0 -190
- package/docs/specs/002-subagent/pi-subagent-design.txt +0 -266
- package/docs/specs/002-subagent/pi-subagent-phase1-plan.txt +0 -529
- package/docs/specs/003-improve-memory/design.md +0 -537
- package/docs/specs/003-improve-memory/interfaces-and-tests.md +0 -473
- package/docs/specs/003-improve-memory/spec.md +0 -357
package/dist/memory/files.js
CHANGED
|
@@ -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 "../
|
|
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
|
package/dist/memory/lifecycle.js
CHANGED
package/dist/memory/recall.d.ts
CHANGED
|
@@ -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
|
package/dist/memory/recall.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
147
|
+
tokens.push(candidate);
|
|
148
|
+
matchedLength = size;
|
|
96
149
|
break;
|
|
97
150
|
}
|
|
98
151
|
}
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
package/dist/memory/session.d.ts
CHANGED
|
@@ -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
|
package/dist/memory/session.js
CHANGED
|
@@ -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
|
|
@@ -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 "
|
|
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 "
|
|
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
|
package/dist/paths.d.ts
CHANGED
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 {
|
|
4
|
-
import {
|
|
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
|
package/dist/runtime/delivery.js
CHANGED
package/dist/runtime/dingtalk.js
CHANGED
|
@@ -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
|
package/dist/runtime/events.d.ts
CHANGED
package/dist/runtime/events.js
CHANGED
package/dist/runtime/store.d.ts
CHANGED
package/dist/runtime/store.js
CHANGED
package/dist/sandbox.d.ts
CHANGED
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
|
-
*
|
|
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
|
-
*
|
|
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
|
|
@@ -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
|
|
@@ -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
|
package/dist/shared/types.d.ts
CHANGED
package/dist/shared/types.js
CHANGED
|
@@ -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 "../
|
|
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
|
package/dist/subagents/tool.d.ts
CHANGED
|
@@ -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
|
package/dist/subagents/tool.js
CHANGED
|
@@ -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 "../
|
|
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
|
package/dist/tools/attach.d.ts
CHANGED
package/dist/tools/attach.js
CHANGED
package/dist/tools/bash.d.ts
CHANGED
package/dist/tools/bash.js
CHANGED
package/dist/tools/edit.d.ts
CHANGED
package/dist/tools/edit.js
CHANGED
|
@@ -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
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -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
|
package/dist/tools/index.js
CHANGED
package/dist/tools/read.d.ts
CHANGED
package/dist/tools/read.js
CHANGED
|
@@ -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
|
package/dist/tools/truncate.d.ts
CHANGED
|
@@ -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
|
package/dist/tools/truncate.js
CHANGED
|
@@ -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
|