@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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type BuiltInCommand } from "../commands.js";
|
|
2
1
|
import type { DingTalkContext } from "../runtime/dingtalk.js";
|
|
3
2
|
import type { ChannelStore } from "../runtime/store.js";
|
|
4
3
|
import { type SandboxConfig } from "../sandbox.js";
|
|
4
|
+
import { type BuiltInCommand } from "./commands.js";
|
|
5
5
|
import { type AgentRunner } from "./types.js";
|
|
6
6
|
export declare class ChannelRunner implements AgentRunner {
|
|
7
7
|
private readonly sandboxConfig;
|
|
@@ -15,6 +15,7 @@ export declare class ChannelRunner implements AgentRunner {
|
|
|
15
15
|
private readonly settingsManager;
|
|
16
16
|
private readonly modelRegistry;
|
|
17
17
|
private readonly memoryLifecycle;
|
|
18
|
+
private readonly sessionResourceGate;
|
|
18
19
|
private readonly sessionReady;
|
|
19
20
|
private subAgentDiscovery;
|
|
20
21
|
private activeModel;
|
|
@@ -38,9 +39,9 @@ export declare class ChannelRunner implements AgentRunner {
|
|
|
38
39
|
private resetRunState;
|
|
39
40
|
private refreshSessionResources;
|
|
40
41
|
private initializeSession;
|
|
42
|
+
private reloadSessionResources;
|
|
41
43
|
private ensureSessionReady;
|
|
42
44
|
private refreshSubAgentDiscovery;
|
|
43
45
|
private subscribeToSessionEvents;
|
|
44
46
|
private buildFirstTurnMemoryBootstrap;
|
|
45
47
|
}
|
|
46
|
-
//# sourceMappingURL=channel-runner.d.ts.map
|
|
@@ -2,29 +2,31 @@ import { Agent } from "@mariozechner/pi-agent-core";
|
|
|
2
2
|
import { AgentSession, AuthStorage, convertToLlm, DefaultResourceLoader, ModelRegistry, SessionManager, } from "@mariozechner/pi-coding-agent";
|
|
3
3
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
4
4
|
import { dirname, join, resolve } from "path";
|
|
5
|
-
import { createCommandExtension } from "../command-extension.js";
|
|
6
|
-
import { renderBuiltInHelp } from "../commands.js";
|
|
7
|
-
import { getAgentConfig, getApiKeyForModel, getSoul, loadPipiclawSkills } from "../config-loader.js";
|
|
8
|
-
import { PipiclawSettingsManager } from "../context.js";
|
|
9
5
|
import * as log from "../log.js";
|
|
10
6
|
import { buildFirstTurnMemoryBootstrap as renderFirstTurnMemoryBootstrap } from "../memory/bootstrap.js";
|
|
11
7
|
import { createMemoryCandidateCache } from "../memory/candidates.js";
|
|
12
8
|
import { getChannelMemoryPath } from "../memory/files.js";
|
|
13
9
|
import { MemoryLifecycle } from "../memory/lifecycle.js";
|
|
14
10
|
import { recallRelevantMemory } from "../memory/recall.js";
|
|
15
|
-
import {
|
|
11
|
+
import { getApiKeyForModel } from "../models/api-keys.js";
|
|
12
|
+
import { resolveInitialModel } from "../models/utils.js";
|
|
16
13
|
import { APP_HOME_DIR, AUTH_CONFIG_PATH, MODELS_CONFIG_PATH } from "../paths.js";
|
|
17
|
-
import { buildAppendSystemPrompt } from "../prompt-builder.js";
|
|
18
14
|
import { createExecutor } from "../sandbox.js";
|
|
15
|
+
import { PipiclawSettingsManager } from "../settings.js";
|
|
19
16
|
import { HAN_REGEX } from "../shared/text-utils.js";
|
|
20
17
|
import { isRecord } from "../shared/type-guards.js";
|
|
21
18
|
import { discoverSubAgents, formatSubAgentList } from "../subagents/discovery.js";
|
|
22
19
|
import { createPipiclawTools } from "../tools/index.js";
|
|
20
|
+
import { createCommandExtension } from "./command-extension.js";
|
|
21
|
+
import { renderBuiltInHelp } from "./commands.js";
|
|
23
22
|
import { clipUserInput } from "./progress-formatter.js";
|
|
23
|
+
import { buildAppendSystemPrompt } from "./prompt-builder.js";
|
|
24
24
|
import { createRunQueue } from "./run-queue.js";
|
|
25
25
|
import { handleSessionEvent } from "./session-events.js";
|
|
26
|
+
import { SessionResourceGate } from "./session-resource-gate.js";
|
|
26
27
|
import { getLastAssistantUsage } from "./type-guards.js";
|
|
27
28
|
import { createEmptyRunState, MAX_USER_MESSAGE_CHARS, } from "./types.js";
|
|
29
|
+
import { getAgentConfig, getSoul, loadPipiclawSkills } from "./workspace-resources.js";
|
|
28
30
|
function isSilentOutcome(outcome) {
|
|
29
31
|
return outcome.kind === "silent";
|
|
30
32
|
}
|
|
@@ -158,6 +160,9 @@ export class ChannelRunner {
|
|
|
158
160
|
resourceLoader,
|
|
159
161
|
baseToolsOverride,
|
|
160
162
|
});
|
|
163
|
+
this.sessionResourceGate = new SessionResourceGate(async () => {
|
|
164
|
+
await this.reloadSessionResources();
|
|
165
|
+
});
|
|
161
166
|
// Subscribe to session events
|
|
162
167
|
this.subscribeToSessionEvents();
|
|
163
168
|
this.sessionReady = this.initializeSession();
|
|
@@ -218,7 +223,9 @@ export class ChannelRunner {
|
|
|
218
223
|
};
|
|
219
224
|
await writeFile(join(this.channelDir, "last_prompt.json"), JSON.stringify(debugContext, null, 2));
|
|
220
225
|
}
|
|
221
|
-
await this.
|
|
226
|
+
await this.sessionResourceGate.runPrompt(async () => {
|
|
227
|
+
await this.session.prompt(promptText);
|
|
228
|
+
});
|
|
222
229
|
}
|
|
223
230
|
catch (err) {
|
|
224
231
|
this.runState.stopReason = "error";
|
|
@@ -354,8 +361,10 @@ export class ChannelRunner {
|
|
|
354
361
|
if (clippedText !== text.trim()) {
|
|
355
362
|
log.logWarning(`[${this.channelId}] Queued message exceeded ${MAX_USER_MESSAGE_CHARS} chars and was clipped`);
|
|
356
363
|
}
|
|
357
|
-
await this.
|
|
358
|
-
|
|
364
|
+
await this.sessionResourceGate.runPrompt(async () => {
|
|
365
|
+
await this.session.prompt(this.formatUserMessage(clippedText, userName), {
|
|
366
|
+
streamingBehavior: delivery,
|
|
367
|
+
});
|
|
359
368
|
});
|
|
360
369
|
}
|
|
361
370
|
resetRunState(ctx, store) {
|
|
@@ -370,12 +379,12 @@ export class ChannelRunner {
|
|
|
370
379
|
}
|
|
371
380
|
async refreshSessionResources() {
|
|
372
381
|
await this.ensureSessionReady();
|
|
373
|
-
|
|
374
|
-
this.currentSkills = skills;
|
|
375
|
-
this.subAgentDiscovery = this.refreshSubAgentDiscovery();
|
|
376
|
-
await this.session.reload();
|
|
382
|
+
await this.sessionResourceGate.requestRefresh();
|
|
377
383
|
}
|
|
378
384
|
async initializeSession() {
|
|
385
|
+
await this.reloadSessionResources();
|
|
386
|
+
}
|
|
387
|
+
async reloadSessionResources() {
|
|
379
388
|
const skills = loadPipiclawSkills(this.channelDir, this.workspacePath);
|
|
380
389
|
this.currentSkills = skills;
|
|
381
390
|
this.subAgentDiscovery = this.refreshSubAgentDiscovery();
|
|
@@ -431,4 +440,3 @@ export class ChannelRunner {
|
|
|
431
440
|
});
|
|
432
441
|
}
|
|
433
442
|
}
|
|
434
|
-
//# sourceMappingURL=channel-runner.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { basename } from "path";
|
|
2
|
-
import { findExactModelReferenceMatch, formatModelList, formatModelReference } from "
|
|
2
|
+
import { findExactModelReferenceMatch, formatModelList, formatModelReference } from "../models/utils.js";
|
|
3
3
|
export const COMMAND_RESULT_CUSTOM_TYPE = "pipiclaw.command_result";
|
|
4
4
|
function buildSessionText(stats, currentModel, thinkingLevel) {
|
|
5
5
|
const modelText = currentModel ? `\`${formatModelReference(currentModel)}\`` : "(none)";
|
|
@@ -109,4 +109,3 @@ ${result.summary}
|
|
|
109
109
|
});
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
//# sourceMappingURL=command-extension.js.map
|
package/dist/agent/index.d.ts
CHANGED
package/dist/agent/index.js
CHANGED
|
@@ -2,4 +2,3 @@ import type { ProgressEntryKind } from "./types.js";
|
|
|
2
2
|
export declare function clipUserInput(text: string, maxChars: number): string;
|
|
3
3
|
export declare function formatProgressEntry(kind: ProgressEntryKind, text: string): string;
|
|
4
4
|
export declare function extractToolResultText(result: unknown): string;
|
|
5
|
-
//# sourceMappingURL=progress-formatter.d.ts.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { SandboxConfig } from "
|
|
1
|
+
import type { SandboxConfig } from "../sandbox.js";
|
|
2
2
|
export interface AppendSystemPromptOptions {
|
|
3
3
|
subAgentList?: string;
|
|
4
4
|
}
|
|
5
5
|
export declare function buildAppendSystemPrompt(workspacePath: string, channelId: string, sandboxConfig: SandboxConfig, options?: AppendSystemPromptOptions): string;
|
|
6
|
-
//# sourceMappingURL=prompt-builder.d.ts.map
|
package/dist/agent/run-queue.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { SandboxConfig } from "../sandbox.js";
|
|
2
2
|
import type { AgentRunner } from "./types.js";
|
|
3
3
|
export declare function getOrCreateRunner(sandboxConfig: SandboxConfig, channelId: string, channelDir: string): AgentRunner;
|
|
4
|
-
//# sourceMappingURL=runner-factory.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class SessionResourceGate {
|
|
2
|
+
private readonly reloadSessionResources;
|
|
3
|
+
private activePromptCount;
|
|
4
|
+
private refreshPending;
|
|
5
|
+
private reloadChain;
|
|
6
|
+
constructor(reloadSessionResources: () => Promise<void>);
|
|
7
|
+
runPrompt<T>(operation: () => Promise<T>): Promise<T>;
|
|
8
|
+
requestRefresh(): Promise<void>;
|
|
9
|
+
private flushPendingRefresh;
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class SessionResourceGate {
|
|
2
|
+
constructor(reloadSessionResources) {
|
|
3
|
+
this.reloadSessionResources = reloadSessionResources;
|
|
4
|
+
this.activePromptCount = 0;
|
|
5
|
+
this.refreshPending = false;
|
|
6
|
+
this.reloadChain = Promise.resolve();
|
|
7
|
+
}
|
|
8
|
+
async runPrompt(operation) {
|
|
9
|
+
await this.reloadChain;
|
|
10
|
+
this.activePromptCount++;
|
|
11
|
+
try {
|
|
12
|
+
return await operation();
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
this.activePromptCount--;
|
|
16
|
+
await this.flushPendingRefresh();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
async requestRefresh() {
|
|
20
|
+
this.refreshPending = true;
|
|
21
|
+
if (this.activePromptCount > 0) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
await this.flushPendingRefresh();
|
|
25
|
+
}
|
|
26
|
+
async flushPendingRefresh() {
|
|
27
|
+
if (!this.refreshPending || this.activePromptCount > 0) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
this.refreshPending = false;
|
|
31
|
+
const runReload = async () => {
|
|
32
|
+
if (this.activePromptCount > 0) {
|
|
33
|
+
this.refreshPending = true;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
await this.reloadSessionResources();
|
|
37
|
+
};
|
|
38
|
+
this.reloadChain = this.reloadChain.then(runReload, runReload);
|
|
39
|
+
await this.reloadChain;
|
|
40
|
+
if (this.refreshPending && this.activePromptCount === 0) {
|
|
41
|
+
await this.flushPendingRefresh();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -20,4 +20,3 @@ export declare function isAutoCompactionEndEvent(value: unknown): value is AutoC
|
|
|
20
20
|
export declare function isAutoRetryStartEvent(value: unknown): value is AutoRetryStartEvent;
|
|
21
21
|
export declare function isSubAgentToolDetails(value: unknown): value is SubAgentToolDetails;
|
|
22
22
|
export declare function extractCustomCommandResultText(message: unknown): string | null;
|
|
23
|
-
//# sourceMappingURL=type-guards.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { COMMAND_RESULT_CUSTOM_TYPE } from "../command-extension.js";
|
|
2
1
|
import { isRecord } from "../shared/type-guards.js";
|
|
2
|
+
import { COMMAND_RESULT_CUSTOM_TYPE } from "./command-extension.js";
|
|
3
3
|
function isMessageWithRole(value) {
|
|
4
4
|
return isRecord(value) && typeof value.role === "string";
|
|
5
5
|
}
|
|
@@ -104,4 +104,3 @@ export function extractCustomCommandResultText(message) {
|
|
|
104
104
|
const content = message.content;
|
|
105
105
|
return typeof content === "string" && content.trim() ? content : null;
|
|
106
106
|
}
|
|
107
|
-
//# sourceMappingURL=type-guards.js.map
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { BuiltInCommand } from "../commands.js";
|
|
2
1
|
import type { DingTalkContext } from "../runtime/dingtalk.js";
|
|
3
2
|
import type { ChannelStore } from "../runtime/store.js";
|
|
4
3
|
import type { UsageTotals } from "../shared/types.js";
|
|
4
|
+
import type { BuiltInCommand } from "./commands.js";
|
|
5
5
|
export interface AgentRunner {
|
|
6
6
|
run(ctx: DingTalkContext, store: ChannelStore): Promise<{
|
|
7
7
|
stopReason: string;
|
|
@@ -158,4 +158,3 @@ export type AutoRetryStartEvent = Extract<SessionEvent, {
|
|
|
158
158
|
}>;
|
|
159
159
|
export type ProgressEntryKind = "tool" | "thinking" | "error" | "assistant";
|
|
160
160
|
export declare const MAX_USER_MESSAGE_CHARS = 12000;
|
|
161
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/agent/types.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* SOUL.md, AGENTS.md,
|
|
2
|
+
* Workspace resource loaders for pipiclaw:
|
|
3
|
+
* SOUL.md, AGENTS.md, and workspace/channel skills.
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
6
|
-
import { type ModelRegistry, type Skill } from "@mariozechner/pi-coding-agent";
|
|
5
|
+
import { type Skill } from "@mariozechner/pi-coding-agent";
|
|
7
6
|
/**
|
|
8
7
|
* Load SOUL.md — defines the agent's identity, personality, and communication style.
|
|
9
8
|
* Only loaded from workspace root (global).
|
|
@@ -19,9 +18,3 @@ export declare function getAgentConfig(channelDir: string): string;
|
|
|
19
18
|
* Channel-level skills override global skills with the same name.
|
|
20
19
|
*/
|
|
21
20
|
export declare function loadPipiclawSkills(channelDir: string, workspacePath: string): Skill[];
|
|
22
|
-
/**
|
|
23
|
-
* Resolve an API key for the given model's provider.
|
|
24
|
-
* Checks ModelRegistry first, then falls back to ANTHROPIC_API_KEY env var.
|
|
25
|
-
*/
|
|
26
|
-
export declare function getApiKeyForModel(modelRegistry: ModelRegistry, model: Model<Api>): Promise<string>;
|
|
27
|
-
//# sourceMappingURL=config-loader.d.ts.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* SOUL.md, AGENTS.md,
|
|
2
|
+
* Workspace resource loaders for pipiclaw:
|
|
3
|
+
* SOUL.md, AGENTS.md, and workspace/channel skills.
|
|
4
4
|
*/
|
|
5
5
|
import { loadSkillsFromDir } from "@mariozechner/pi-coding-agent";
|
|
6
6
|
import { existsSync, readFileSync } from "fs";
|
|
7
7
|
import { join } from "path";
|
|
8
|
-
import * as log from "
|
|
8
|
+
import * as log from "../log.js";
|
|
9
9
|
/**
|
|
10
10
|
* Load SOUL.md — defines the agent's identity, personality, and communication style.
|
|
11
11
|
* Only loaded from workspace root (global).
|
|
@@ -72,19 +72,3 @@ export function loadPipiclawSkills(channelDir, workspacePath) {
|
|
|
72
72
|
}
|
|
73
73
|
return Array.from(skillMap.values());
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
* Resolve an API key for the given model's provider.
|
|
77
|
-
* Checks ModelRegistry first, then falls back to ANTHROPIC_API_KEY env var.
|
|
78
|
-
*/
|
|
79
|
-
export async function getApiKeyForModel(modelRegistry, model) {
|
|
80
|
-
const key = await modelRegistry.getApiKeyForProvider(model.provider);
|
|
81
|
-
if (key)
|
|
82
|
-
return key;
|
|
83
|
-
// Fallback: try anthropic env var
|
|
84
|
-
const envKey = process.env.ANTHROPIC_API_KEY;
|
|
85
|
-
if (envKey)
|
|
86
|
-
return envKey;
|
|
87
|
-
throw new Error(`No API key found for provider: ${model.provider}.\n\n` +
|
|
88
|
-
"Configure API key in ~/.pi/agent/models.json or set ANTHROPIC_API_KEY environment variable.");
|
|
89
|
-
}
|
|
90
|
-
//# sourceMappingURL=config-loader.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export { type
|
|
2
|
-
export {
|
|
3
|
-
export { type
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { COMMAND_RESULT_CUSTOM_TYPE, createCommandExtension, type PipiclawCommandExtensionOptions, } from "./agent/command-extension.js";
|
|
2
|
+
export { type BuiltInCommand, type BuiltInCommandName, parseBuiltInCommand, renderBuiltInHelp, } from "./agent/commands.js";
|
|
3
|
+
export { type AgentRunner, getOrCreateRunner } from "./agent/index.js";
|
|
4
|
+
export { type AppendSystemPromptOptions, buildAppendSystemPrompt } from "./agent/prompt-builder.js";
|
|
5
|
+
export { getAgentConfig, getSoul, loadPipiclawSkills, } from "./agent/workspace-resources.js";
|
|
6
6
|
export { type BuildMemoryCandidatesOptions, buildMemoryCandidates, type MemoryCandidate, } from "./memory/candidates.js";
|
|
7
7
|
export { type BackgroundMaintenanceResult, type ConsolidationRunOptions, type InlineConsolidationResult, runBackgroundMaintenance, runInlineConsolidation, } from "./memory/consolidation.js";
|
|
8
8
|
export { ensureChannelMemoryFiles, ensureChannelMemoryFilesSync, getChannelSessionPath, readChannelSession, rewriteChannelSession, } from "./memory/files.js";
|
|
9
9
|
export { type ConsolidationReason, MemoryLifecycle, type MemoryLifecycleOptions } from "./memory/lifecycle.js";
|
|
10
10
|
export { type RecalledMemory, type RecallRequest, type RecallResult, recallRelevantMemory, } from "./memory/recall.js";
|
|
11
11
|
export { renderSessionMemory, type SessionMemoryState, type SessionMemoryUpdateOptions, updateChannelSessionMemory, } from "./memory/session.js";
|
|
12
|
-
export {
|
|
12
|
+
export { runSidecarTask, type SidecarResult, type SidecarTask, } from "./memory/sidecar-worker.js";
|
|
13
|
+
export { getApiKeyForModel } from "./models/api-keys.js";
|
|
14
|
+
export { findExactModelReferenceMatch, formatModelList, formatModelReference, resolveInitialModel, } from "./models/utils.js";
|
|
13
15
|
export { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, MODELS_CONFIG_PATH, SETTINGS_CONFIG_PATH, SUB_AGENTS_DIR, SUB_AGENTS_DIR_NAME, WORKSPACE_DIR, } from "./paths.js";
|
|
14
|
-
export { type AppendSystemPromptOptions, buildAppendSystemPrompt } from "./prompt-builder.js";
|
|
15
16
|
export { createDingTalkContext } from "./runtime/delivery.js";
|
|
16
17
|
export { type BusyMessageMode, DingTalkBot, type DingTalkConfig, type DingTalkContext, type DingTalkEvent, type DingTalkHandler, } from "./runtime/dingtalk.js";
|
|
17
18
|
export { createEventsWatcher, EventsWatcher, type ImmediateEvent, type OneShotEvent, type PeriodicEvent, type ScheduledEvent, } from "./runtime/events.js";
|
|
18
19
|
export { ChannelStore, type LoggedMessage, type LoggedSubAgentRun } from "./runtime/store.js";
|
|
19
20
|
export { createExecutor, type ExecOptions, type ExecResult, type Executor, parseSandboxArg, type SandboxConfig, validateSandbox, } from "./sandbox.js";
|
|
20
|
-
export {
|
|
21
|
+
export { type PipiclawMemoryRecallSettings, type PipiclawSessionMemorySettings, type PipiclawSettings, PipiclawSettingsManager, } from "./settings.js";
|
|
21
22
|
export { discoverSubAgents, formatSubAgentList, getSubAgentsDir, type ResolvedSubAgentConfig, resolveSubAgentConfig, type SubAgentConfig, type SubAgentContextMode, type SubAgentDiscoveryResult, type SubAgentInvocationOverrides, type SubAgentMemoryMode, type SubAgentToolName, } from "./subagents/discovery.js";
|
|
22
23
|
export { createSubAgentTool, type SubAgentToolDetails, type SubAgentToolOptions, } from "./subagents/tool.js";
|
|
23
24
|
export { type CreatePipiclawToolsOptions, createPipiclawBaseTools, createPipiclawTools, } from "./tools/index.js";
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
export { COMMAND_RESULT_CUSTOM_TYPE, createCommandExtension, } from "./agent/command-extension.js";
|
|
2
|
+
export { parseBuiltInCommand, renderBuiltInHelp, } from "./agent/commands.js";
|
|
3
|
+
export { getOrCreateRunner } from "./agent/index.js";
|
|
4
|
+
export { buildAppendSystemPrompt } from "./agent/prompt-builder.js";
|
|
5
|
+
export { getAgentConfig, getSoul, loadPipiclawSkills, } from "./agent/workspace-resources.js";
|
|
6
6
|
export { buildMemoryCandidates, } from "./memory/candidates.js";
|
|
7
7
|
export { runBackgroundMaintenance, runInlineConsolidation, } from "./memory/consolidation.js";
|
|
8
8
|
export { ensureChannelMemoryFiles, ensureChannelMemoryFilesSync, getChannelSessionPath, readChannelSession, rewriteChannelSession, } from "./memory/files.js";
|
|
9
9
|
export { MemoryLifecycle } from "./memory/lifecycle.js";
|
|
10
10
|
export { recallRelevantMemory, } from "./memory/recall.js";
|
|
11
11
|
export { renderSessionMemory, updateChannelSessionMemory, } from "./memory/session.js";
|
|
12
|
-
export {
|
|
12
|
+
export { runSidecarTask, } from "./memory/sidecar-worker.js";
|
|
13
|
+
export { getApiKeyForModel } from "./models/api-keys.js";
|
|
14
|
+
export { findExactModelReferenceMatch, formatModelList, formatModelReference, resolveInitialModel, } from "./models/utils.js";
|
|
13
15
|
export { APP_HOME_DIR, APP_NAME, AUTH_CONFIG_PATH, CHANNEL_CONFIG_PATH, MODELS_CONFIG_PATH, SETTINGS_CONFIG_PATH, SUB_AGENTS_DIR, SUB_AGENTS_DIR_NAME, WORKSPACE_DIR, } from "./paths.js";
|
|
14
|
-
export { buildAppendSystemPrompt } from "./prompt-builder.js";
|
|
15
16
|
export { createDingTalkContext } from "./runtime/delivery.js";
|
|
16
17
|
export { DingTalkBot, } from "./runtime/dingtalk.js";
|
|
17
18
|
export { createEventsWatcher, EventsWatcher, } from "./runtime/events.js";
|
|
18
19
|
export { ChannelStore } from "./runtime/store.js";
|
|
19
20
|
export { createExecutor, parseSandboxArg, validateSandbox, } from "./sandbox.js";
|
|
20
|
-
export {
|
|
21
|
+
export { PipiclawSettingsManager, } from "./settings.js";
|
|
21
22
|
export { discoverSubAgents, formatSubAgentList, getSubAgentsDir, resolveSubAgentConfig, } from "./subagents/discovery.js";
|
|
22
23
|
export { createSubAgentTool, } from "./subagents/tool.js";
|
|
23
24
|
export { createPipiclawBaseTools, createPipiclawTools, } from "./tools/index.js";
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
package/dist/log.d.ts
CHANGED
|
@@ -30,4 +30,3 @@ export declare function logUsageSummary(ctx: LogContext, usage: {
|
|
|
30
30
|
export declare function logStartup(workingDir: string, sandbox: string): void;
|
|
31
31
|
export declare function logConnected(): void;
|
|
32
32
|
export declare function logDisconnected(): void;
|
|
33
|
-
//# sourceMappingURL=log.d.ts.map
|
package/dist/log.js
CHANGED
package/dist/main.d.ts
CHANGED
package/dist/main.js
CHANGED
package/dist/memory/bootstrap.js
CHANGED
|
@@ -19,4 +19,3 @@ export interface MemoryCandidateCache {
|
|
|
19
19
|
}
|
|
20
20
|
export declare function createMemoryCandidateCache(): MemoryCandidateCache;
|
|
21
21
|
export declare function buildMemoryCandidates(options: BuildMemoryCandidatesOptions): Promise<MemoryCandidate[]>;
|
|
22
|
-
//# sourceMappingURL=candidates.d.ts.map
|
|
@@ -131,6 +131,30 @@ export const COMMON_CHINESE_WORDS = new Set([
|
|
|
131
131
|
"状态管理",
|
|
132
132
|
"异常处理",
|
|
133
133
|
"错误处理",
|
|
134
|
+
"管理",
|
|
135
|
+
"优化",
|
|
136
|
+
"系统",
|
|
137
|
+
"设计",
|
|
138
|
+
"开发",
|
|
139
|
+
"测试",
|
|
140
|
+
"部署",
|
|
141
|
+
"修改",
|
|
142
|
+
"创建",
|
|
143
|
+
"删除",
|
|
144
|
+
"更新",
|
|
145
|
+
"查询",
|
|
146
|
+
"提交",
|
|
147
|
+
"调用",
|
|
148
|
+
"启动",
|
|
149
|
+
"停止",
|
|
150
|
+
"迁移",
|
|
151
|
+
"同步",
|
|
152
|
+
"备份",
|
|
153
|
+
"分析",
|
|
154
|
+
"监控",
|
|
155
|
+
"审查",
|
|
156
|
+
"重构",
|
|
157
|
+
"封装",
|
|
134
158
|
"并发控制",
|
|
135
159
|
"并发请求",
|
|
136
160
|
"异步任务",
|
|
@@ -154,6 +178,30 @@ export const COMMON_CHINESE_WORDS = new Set([
|
|
|
154
178
|
"熔断机制",
|
|
155
179
|
"事务处理",
|
|
156
180
|
"事务回滚",
|
|
181
|
+
"异常",
|
|
182
|
+
"错误",
|
|
183
|
+
"日志",
|
|
184
|
+
"线程",
|
|
185
|
+
"进程",
|
|
186
|
+
"端口",
|
|
187
|
+
"协议",
|
|
188
|
+
"路由",
|
|
189
|
+
"索引",
|
|
190
|
+
"事务",
|
|
191
|
+
"连接",
|
|
192
|
+
"超时",
|
|
193
|
+
"重连",
|
|
194
|
+
"校验",
|
|
195
|
+
"加密",
|
|
196
|
+
"解密",
|
|
197
|
+
"分支",
|
|
198
|
+
"合并",
|
|
199
|
+
"冲突",
|
|
200
|
+
"版本",
|
|
201
|
+
"发布",
|
|
202
|
+
"构建",
|
|
203
|
+
"编译",
|
|
204
|
+
"依赖",
|
|
157
205
|
"索引优化",
|
|
158
206
|
"数据迁移",
|
|
159
207
|
"数据同步",
|
|
@@ -200,6 +248,22 @@ export const COMMON_CHINESE_WORDS = new Set([
|
|
|
200
248
|
"修复登录",
|
|
201
249
|
"生产环境",
|
|
202
250
|
"工作区",
|
|
251
|
+
"记忆",
|
|
252
|
+
"会话",
|
|
253
|
+
"频道",
|
|
254
|
+
"模型",
|
|
255
|
+
"提示",
|
|
256
|
+
"工具",
|
|
257
|
+
"代理",
|
|
258
|
+
"任务",
|
|
259
|
+
"调度",
|
|
260
|
+
"排队",
|
|
261
|
+
"响应",
|
|
262
|
+
"请求",
|
|
263
|
+
"回调",
|
|
264
|
+
"订阅",
|
|
265
|
+
"通知",
|
|
266
|
+
"触发",
|
|
203
267
|
"频道记忆",
|
|
204
268
|
"记忆系统",
|
|
205
269
|
"记忆子系统",
|
|
@@ -207,4 +271,3 @@ export const COMMON_CHINESE_WORDS = new Set([
|
|
|
207
271
|
"工作记忆",
|
|
208
272
|
"会话记忆",
|
|
209
273
|
]);
|
|
210
|
-
//# sourceMappingURL=chinese-words.js.map
|
|
@@ -19,4 +19,3 @@ export interface BackgroundMaintenanceResult {
|
|
|
19
19
|
}
|
|
20
20
|
export declare function runInlineConsolidation(options: ConsolidationRunOptions): Promise<InlineConsolidationResult>;
|
|
21
21
|
export declare function runBackgroundMaintenance(options: ConsolidationRunOptions): Promise<BackgroundMaintenanceResult>;
|
|
22
|
-
//# sourceMappingURL=consolidation.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getLatestCompactionEntry, serializeConversation, } from "@mariozechner/pi-coding-agent";
|
|
2
|
-
import { parseJsonObject } from "../llm-json.js";
|
|
2
|
+
import { parseJsonObject } from "../shared/llm-json.js";
|
|
3
3
|
import { splitH2Sections } from "../shared/markdown-sections.js";
|
|
4
4
|
import { clipText } from "../shared/text-utils.js";
|
|
5
5
|
import { buildStandardMessages } from "../shared/type-guards.js";
|
|
6
|
-
import { runSidecarTask } from "../sidecar-worker.js";
|
|
7
6
|
import { appendChannelHistoryBlock, appendChannelMemoryUpdate, readChannelHistory, readChannelMemory, readChannelSession, rewriteChannelHistory, rewriteChannelMemory, } from "./files.js";
|
|
7
|
+
import { runSidecarTask } from "./sidecar-worker.js";
|
|
8
8
|
const INLINE_TRANSCRIPT_MAX_CHARS = 28_000;
|
|
9
9
|
const MEMORY_CLEANUP_LENGTH_THRESHOLD = 5_000;
|
|
10
10
|
const MEMORY_UPDATE_BLOCK_THRESHOLD = 4;
|
|
@@ -226,4 +226,3 @@ export async function runBackgroundMaintenance(options) {
|
|
|
226
226
|
const foldedHistory = await foldChannelHistory(options, currentHistory);
|
|
227
227
|
return { cleanedMemory, foldedHistory };
|
|
228
228
|
}
|
|
229
|
-
//# sourceMappingURL=consolidation.js.map
|
package/dist/memory/files.d.ts
CHANGED
|
@@ -19,4 +19,3 @@ export declare function rewriteChannelHistory(channelDir: string, content: strin
|
|
|
19
19
|
export declare function rewriteChannelSession(channelDir: string, content: string): Promise<void>;
|
|
20
20
|
export declare function appendChannelMemoryUpdate(channelDir: string, block: MemoryUpdateBlock): Promise<void>;
|
|
21
21
|
export declare function appendChannelHistoryBlock(channelDir: string, block: HistoryBlock): Promise<void>;
|
|
22
|
-
//# sourceMappingURL=files.d.ts.map
|