@oyasmi/pipiclaw 0.8.6 → 0.8.7-beta.2
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/dist/agent/channel-runner.d.ts +2 -0
- package/dist/agent/channel-runner.js +26 -6
- package/dist/agent/prompt/builder.d.ts +11 -20
- package/dist/agent/prompt/builder.js +40 -87
- package/dist/agent/prompt/manifest.d.ts +28 -2
- package/dist/agent/prompt/manifest.js +50 -11
- package/dist/agent/prompt/resources.d.ts +11 -2
- package/dist/agent/prompt/resources.js +51 -12
- package/dist/agent/prompt/sections.d.ts +9 -10
- package/dist/agent/prompt/sections.js +46 -99
- package/dist/agent/prompt/types.d.ts +14 -0
- package/dist/agent/session-events.js +17 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/log.d.ts +12 -20
- package/dist/log.js +195 -198
- package/dist/memory/bootstrap.d.ts +6 -0
- package/dist/memory/bootstrap.js +53 -21
- package/dist/memory/lifecycle.js +4 -1
- package/dist/memory/recall.d.ts +8 -0
- package/dist/memory/recall.js +19 -13
- package/dist/memory/task-digest.d.ts +4 -0
- package/dist/memory/task-digest.js +9 -3
- package/dist/playbooks/catalog.d.ts +7 -2
- package/dist/playbooks/catalog.js +10 -6
- package/dist/playbooks/event-scheduling.md +1 -1
- package/dist/playbooks/memory-and-learning.md +1 -1
- package/dist/playbooks/runtime-orientation.md +1 -1
- package/dist/playbooks/task-closeout.md +1 -1
- package/dist/playbooks/task-delegation.md +1 -1
- package/dist/playbooks/task-driving.md +1 -1
- package/dist/playbooks/task-planning.md +1 -1
- package/dist/playbooks/task-recurring.md +1 -1
- package/dist/playbooks/task-repair.md +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -0
- package/dist/runtime/bootstrap.js +41 -11
- package/dist/runtime/dingtalk.js +19 -6
- package/dist/runtime/events.d.ts +2 -0
- package/dist/runtime/events.js +20 -8
- package/dist/runtime/store.d.ts +4 -6
- package/dist/runtime/store.js +44 -40
- package/dist/security/logger.d.ts +3 -1
- package/dist/security/logger.js +33 -10
- package/dist/shared/jsonl-appender.d.ts +27 -8
- package/dist/shared/jsonl-appender.js +128 -41
- package/dist/shared/prompt-units.d.ts +46 -0
- package/dist/shared/prompt-units.js +153 -0
- package/dist/tools/bash.js +1 -1
- package/dist/tools/edit.js +1 -1
- package/dist/tools/grep.js +1 -1
- package/dist/tools/read.js +1 -1
- package/dist/tools/write-content.js +1 -1
- package/dist/tui/app.js +17 -0
- package/dist/usage/ledger.d.ts +2 -0
- package/dist/usage/ledger.js +3 -1
- package/dist/web/client.js +3 -3
- package/package.json +1 -1
package/dist/tools/edit.js
CHANGED
|
@@ -128,7 +128,7 @@ export function createEditTool(executor, options = {}) {
|
|
|
128
128
|
if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
|
|
129
129
|
const readGuard = guardPath(path, "read", { ...securityContext, config: securityConfig.pathGuard });
|
|
130
130
|
if (!readGuard.allowed) {
|
|
131
|
-
logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
131
|
+
await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
132
132
|
type: "path",
|
|
133
133
|
tool: "edit",
|
|
134
134
|
channelId: options.channelId,
|
package/dist/tools/grep.js
CHANGED
|
@@ -152,7 +152,7 @@ export function createGrepTool(executor, options = {}) {
|
|
|
152
152
|
if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
|
|
153
153
|
const guardResult = guardPath(searchPath, "read", { ...securityContext, config: securityConfig.pathGuard });
|
|
154
154
|
if (!guardResult.allowed) {
|
|
155
|
-
logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
155
|
+
await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
156
156
|
type: "path",
|
|
157
157
|
tool: "grep",
|
|
158
158
|
channelId: options.channelId,
|
package/dist/tools/read.js
CHANGED
|
@@ -101,7 +101,7 @@ export function createReadTool(executor, options = {}) {
|
|
|
101
101
|
if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
|
|
102
102
|
const guardResult = guardPath(path, "read", { ...securityContext, config: securityConfig.pathGuard });
|
|
103
103
|
if (!guardResult.allowed) {
|
|
104
|
-
logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
104
|
+
await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
105
105
|
type: "path",
|
|
106
106
|
tool: "read",
|
|
107
107
|
channelId: options.channelId,
|
|
@@ -21,7 +21,7 @@ export async function writeContent(executor, path, content, signal, options) {
|
|
|
21
21
|
if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
|
|
22
22
|
const guardResult = guardPath(path, "write", { ...securityContext, config: securityConfig.pathGuard });
|
|
23
23
|
if (!guardResult.allowed) {
|
|
24
|
-
logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
24
|
+
await logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
25
25
|
type: "path",
|
|
26
26
|
tool: options?.toolName ?? "write",
|
|
27
27
|
channelId: options?.channelId,
|
package/dist/tui/app.js
CHANGED
|
@@ -18,6 +18,7 @@ import { finalDeliveryOf, progressStyleOf } from "../runtime/dingtalk.js";
|
|
|
18
18
|
import { handleEventsCommand } from "../runtime/event-commands.js";
|
|
19
19
|
import { ChannelStore } from "../runtime/store.js";
|
|
20
20
|
import { handleTasksCommand } from "../runtime/task-commands.js";
|
|
21
|
+
import { flushSecurityLogs } from "../security/logger.js";
|
|
21
22
|
import { getUsageLedger } from "../usage/ledger.js";
|
|
22
23
|
import { parseUsageMode, renderUsageReport } from "../usage/render.js";
|
|
23
24
|
import { TUI_SLASH_COMMANDS } from "./commands.js";
|
|
@@ -25,6 +26,20 @@ import { createFrontend } from "./renderer.js";
|
|
|
25
26
|
import { TurnController } from "./turn-controller.js";
|
|
26
27
|
const DEFAULT_CHANNEL_ID = "tui_local";
|
|
27
28
|
const CHANNEL_ID_PATTERN = /^[A-Za-z0-9._-]+$/;
|
|
29
|
+
const STORAGE_FLUSH_TIMEOUT_MS = 10_000;
|
|
30
|
+
async function waitForStorageFlush(task) {
|
|
31
|
+
await new Promise((resolve) => {
|
|
32
|
+
const timer = setTimeout(resolve, STORAGE_FLUSH_TIMEOUT_MS);
|
|
33
|
+
timer.unref?.();
|
|
34
|
+
void task.then(() => {
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
resolve();
|
|
37
|
+
}, () => {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
resolve();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
28
43
|
export function resolveChannelId(raw, io = console) {
|
|
29
44
|
const channel = raw?.trim() || DEFAULT_CHANNEL_ID;
|
|
30
45
|
if (!CHANNEL_ID_PATTERN.test(channel)) {
|
|
@@ -107,5 +122,7 @@ export async function runTuiApp(options) {
|
|
|
107
122
|
}
|
|
108
123
|
finally {
|
|
109
124
|
resetRunner(channelId);
|
|
125
|
+
await waitForStorageFlush(Promise.allSettled([store.close(), getUsageLedger().flush?.() ?? Promise.resolve(), flushSecurityLogs()]));
|
|
126
|
+
await waitForStorageFlush(log.flushLogging());
|
|
110
127
|
}
|
|
111
128
|
}
|
package/dist/usage/ledger.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export declare const UNTRACKED_CHANNEL_ID = "(untracked)";
|
|
|
40
40
|
export interface UsageLedger {
|
|
41
41
|
record(entry: Omit<UsageLedgerEntry, "ts">): void;
|
|
42
42
|
summarize(query: UsageSummaryQuery): UsageSummary;
|
|
43
|
+
flush?(): Promise<void>;
|
|
44
|
+
close?(): Promise<void>;
|
|
43
45
|
}
|
|
44
46
|
export interface CreateUsageLedgerOptions {
|
|
45
47
|
baseDir?: string;
|
package/dist/usage/ledger.js
CHANGED
|
@@ -34,8 +34,10 @@ export function createUsageLedger(options = {}) {
|
|
|
34
34
|
...entry,
|
|
35
35
|
channelId: entry.channelId || UNTRACKED_CHANNEL_ID,
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
appender.tryAppend(full);
|
|
38
38
|
},
|
|
39
|
+
flush: () => appender.flush(),
|
|
40
|
+
close: () => appender.close(),
|
|
39
41
|
summarize(query) {
|
|
40
42
|
const until = query.until ?? new Date();
|
|
41
43
|
const sinceMs = query.since.getTime();
|
package/dist/web/client.js
CHANGED
|
@@ -65,8 +65,8 @@ function getProxyAgent(requestUrl, explicitProxy) {
|
|
|
65
65
|
agentCache.set(cacheKey, agent);
|
|
66
66
|
return agent;
|
|
67
67
|
}
|
|
68
|
-
function logBlockedRequest(context, error) {
|
|
69
|
-
logSecurityEvent(context.workspaceDir, context.securityConfig, {
|
|
68
|
+
async function logBlockedRequest(context, error) {
|
|
69
|
+
await logSecurityEvent(context.workspaceDir, context.securityConfig, {
|
|
70
70
|
type: "network",
|
|
71
71
|
tool: "web",
|
|
72
72
|
channelId: context.channelId,
|
|
@@ -104,7 +104,7 @@ export class WebHttpClient {
|
|
|
104
104
|
}
|
|
105
105
|
catch (error) {
|
|
106
106
|
if (error instanceof NetworkGuardError) {
|
|
107
|
-
logBlockedRequest(this.context, error);
|
|
107
|
+
await logBlockedRequest(this.context, error);
|
|
108
108
|
}
|
|
109
109
|
throw error;
|
|
110
110
|
}
|
package/package.json
CHANGED