@oyasmi/pipiclaw 0.5.2 → 0.5.3
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 +2 -1
- package/dist/agent/channel-runner.js +15 -8
- 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/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 +0 -1
- package/dist/agent/types.d.ts +0 -1
- package/dist/agent/types.js +0 -1
- package/dist/agent.d.ts +0 -1
- package/dist/agent.js +0 -1
- package/dist/command-extension.d.ts +0 -1
- package/dist/command-extension.js +0 -1
- package/dist/commands.d.ts +0 -1
- package/dist/commands.js +0 -1
- package/dist/config-loader.d.ts +0 -1
- package/dist/config-loader.js +1 -2
- package/dist/context.d.ts +0 -1
- package/dist/context.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- 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 +1 -2
- package/dist/memory/files.d.ts +0 -1
- package/dist/memory/files.js +0 -1
- package/dist/memory/lifecycle.d.ts +0 -1
- package/dist/memory/lifecycle.js +0 -1
- package/dist/memory/recall.d.ts +1 -1
- package/dist/memory/recall.js +76 -10
- package/dist/memory/session.d.ts +0 -1
- package/dist/memory/session.js +1 -2
- package/dist/model-utils.d.ts +0 -1
- package/dist/model-utils.js +0 -1
- package/dist/paths.d.ts +0 -1
- package/dist/paths.js +0 -1
- package/dist/prompt-builder.d.ts +0 -1
- package/dist/prompt-builder.js +0 -1
- package/dist/runtime/bootstrap.d.ts +0 -1
- package/dist/runtime/bootstrap.js +0 -1
- 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 +0 -1
- 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/{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/sidecar-worker.d.ts +0 -1
- package/dist/sidecar-worker.js +0 -1
- package/dist/subagents/discovery.d.ts +0 -1
- package/dist/subagents/discovery.js +0 -1
- package/dist/subagents/tool.d.ts +0 -1
- package/dist/subagents/tool.js +0 -1
- 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 +0 -1
- 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.map +0 -1
- 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
|
@@ -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
|
|
@@ -23,6 +23,7 @@ import { createPipiclawTools } from "../tools/index.js";
|
|
|
23
23
|
import { clipUserInput } from "./progress-formatter.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";
|
|
28
29
|
function isSilentOutcome(outcome) {
|
|
@@ -158,6 +159,9 @@ export class ChannelRunner {
|
|
|
158
159
|
resourceLoader,
|
|
159
160
|
baseToolsOverride,
|
|
160
161
|
});
|
|
162
|
+
this.sessionResourceGate = new SessionResourceGate(async () => {
|
|
163
|
+
await this.reloadSessionResources();
|
|
164
|
+
});
|
|
161
165
|
// Subscribe to session events
|
|
162
166
|
this.subscribeToSessionEvents();
|
|
163
167
|
this.sessionReady = this.initializeSession();
|
|
@@ -218,7 +222,9 @@ export class ChannelRunner {
|
|
|
218
222
|
};
|
|
219
223
|
await writeFile(join(this.channelDir, "last_prompt.json"), JSON.stringify(debugContext, null, 2));
|
|
220
224
|
}
|
|
221
|
-
await this.
|
|
225
|
+
await this.sessionResourceGate.runPrompt(async () => {
|
|
226
|
+
await this.session.prompt(promptText);
|
|
227
|
+
});
|
|
222
228
|
}
|
|
223
229
|
catch (err) {
|
|
224
230
|
this.runState.stopReason = "error";
|
|
@@ -354,8 +360,10 @@ export class ChannelRunner {
|
|
|
354
360
|
if (clippedText !== text.trim()) {
|
|
355
361
|
log.logWarning(`[${this.channelId}] Queued message exceeded ${MAX_USER_MESSAGE_CHARS} chars and was clipped`);
|
|
356
362
|
}
|
|
357
|
-
await this.
|
|
358
|
-
|
|
363
|
+
await this.sessionResourceGate.runPrompt(async () => {
|
|
364
|
+
await this.session.prompt(this.formatUserMessage(clippedText, userName), {
|
|
365
|
+
streamingBehavior: delivery,
|
|
366
|
+
});
|
|
359
367
|
});
|
|
360
368
|
}
|
|
361
369
|
resetRunState(ctx, store) {
|
|
@@ -370,12 +378,12 @@ export class ChannelRunner {
|
|
|
370
378
|
}
|
|
371
379
|
async refreshSessionResources() {
|
|
372
380
|
await this.ensureSessionReady();
|
|
373
|
-
|
|
374
|
-
this.currentSkills = skills;
|
|
375
|
-
this.subAgentDiscovery = this.refreshSubAgentDiscovery();
|
|
376
|
-
await this.session.reload();
|
|
381
|
+
await this.sessionResourceGate.requestRefresh();
|
|
377
382
|
}
|
|
378
383
|
async initializeSession() {
|
|
384
|
+
await this.reloadSessionResources();
|
|
385
|
+
}
|
|
386
|
+
async reloadSessionResources() {
|
|
379
387
|
const skills = loadPipiclawSkills(this.channelDir, this.workspacePath);
|
|
380
388
|
this.currentSkills = skills;
|
|
381
389
|
this.subAgentDiscovery = this.refreshSubAgentDiscovery();
|
|
@@ -431,4 +439,3 @@ export class ChannelRunner {
|
|
|
431
439
|
});
|
|
432
440
|
}
|
|
433
441
|
}
|
|
434
|
-
//# sourceMappingURL=channel-runner.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
|
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
|
package/dist/agent/types.d.ts
CHANGED
package/dist/agent/types.js
CHANGED
package/dist/agent.d.ts
CHANGED
package/dist/agent.js
CHANGED
package/dist/commands.d.ts
CHANGED
package/dist/commands.js
CHANGED
package/dist/config-loader.d.ts
CHANGED
|
@@ -24,4 +24,3 @@ export declare function loadPipiclawSkills(channelDir: string, workspacePath: st
|
|
|
24
24
|
* Checks ModelRegistry first, then falls back to ANTHROPIC_API_KEY env var.
|
|
25
25
|
*/
|
|
26
26
|
export declare function getApiKeyForModel(modelRegistry: ModelRegistry, model: Model<Api>): Promise<string>;
|
|
27
|
-
//# sourceMappingURL=config-loader.d.ts.map
|
package/dist/config-loader.js
CHANGED
|
@@ -85,6 +85,5 @@ export async function getApiKeyForModel(modelRegistry, model) {
|
|
|
85
85
|
if (envKey)
|
|
86
86
|
return envKey;
|
|
87
87
|
throw new Error(`No API key found for provider: ${model.provider}.\n\n` +
|
|
88
|
-
"Configure
|
|
88
|
+
"Configure credentials in ~/.pi/pipiclaw/auth.json or ~/.pi/pipiclaw/models.json, or set the matching provider environment variable.");
|
|
89
89
|
}
|
|
90
|
-
//# sourceMappingURL=config-loader.js.map
|
package/dist/context.d.ts
CHANGED
package/dist/context.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -21,4 +21,3 @@ export { runSidecarTask, type SidecarResult, type SidecarTask, } from "./sidecar
|
|
|
21
21
|
export { discoverSubAgents, formatSubAgentList, getSubAgentsDir, type ResolvedSubAgentConfig, resolveSubAgentConfig, type SubAgentConfig, type SubAgentContextMode, type SubAgentDiscoveryResult, type SubAgentInvocationOverrides, type SubAgentMemoryMode, type SubAgentToolName, } from "./subagents/discovery.js";
|
|
22
22
|
export { createSubAgentTool, type SubAgentToolDetails, type SubAgentToolOptions, } from "./subagents/tool.js";
|
|
23
23
|
export { type CreatePipiclawToolsOptions, createPipiclawBaseTools, createPipiclawTools, } from "./tools/index.js";
|
|
24
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -21,4 +21,3 @@ export { runSidecarTask, } from "./sidecar-worker.js";
|
|
|
21
21
|
export { discoverSubAgents, formatSubAgentList, getSubAgentsDir, resolveSubAgentConfig, } from "./subagents/discovery.js";
|
|
22
22
|
export { createSubAgentTool, } from "./subagents/tool.js";
|
|
23
23
|
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,5 +1,5 @@
|
|
|
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";
|
|
@@ -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
|
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
|
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,4 +1,4 @@
|
|
|
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
3
|
import { runSidecarTask } from "../sidecar-worker.js";
|
|
4
4
|
import { buildMemoryCandidates } from "./candidates.js";
|
|
@@ -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,7 +1,7 @@
|
|
|
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";
|
|
@@ -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
|
package/dist/model-utils.d.ts
CHANGED
|
@@ -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
|