@oyasmi/pipiclaw 0.6.10 → 0.7.0-beta.1
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 +1 -1
- package/dist/agent/channel-runner.d.ts +11 -1
- package/dist/agent/channel-runner.js +39 -3
- package/dist/agent/commands.d.ts +1 -1
- package/dist/agent/commands.js +4 -0
- package/dist/agent/prompt-builder.d.ts +17 -0
- package/dist/agent/prompt-builder.js +42 -23
- package/dist/agent/types.d.ts +7 -0
- package/dist/memory/bootstrap.js +35 -1
- package/dist/memory/candidates.js +21 -3
- package/dist/memory/consolidation.d.ts +6 -1
- package/dist/memory/consolidation.js +99 -33
- package/dist/memory/files.d.ts +40 -0
- package/dist/memory/files.js +0 -0
- package/dist/memory/maintenance-jobs.js +9 -4
- package/dist/memory/post-turn-review.js +3 -2
- package/dist/memory/promotion-signals.js +0 -1
- package/dist/memory/recall.js +10 -2
- package/dist/memory/session.js +43 -13
- package/dist/memory/transcript.d.ts +9 -0
- package/dist/memory/transcript.js +30 -0
- package/dist/runtime/bootstrap.js +140 -15
- package/dist/runtime/delivery.js +17 -0
- package/dist/runtime/dingtalk.d.ts +1 -0
- package/dist/runtime/dingtalk.js +15 -4
- package/dist/sandbox.d.ts +8 -0
- package/dist/sandbox.js +21 -17
- package/dist/settings.d.ts +4 -0
- package/dist/settings.js +2 -0
- package/dist/subagents/tool.d.ts +2 -2
- package/dist/subagents/tool.js +24 -56
- package/dist/tools/bash.d.ts +8 -1
- package/dist/tools/bash.js +46 -21
- package/dist/tools/config.d.ts +3 -0
- package/dist/tools/config.js +9 -0
- package/dist/tools/edit.d.ts +1 -0
- package/dist/tools/edit.js +18 -11
- package/dist/tools/index.js +18 -53
- package/dist/tools/memory-save.d.ts +17 -0
- package/dist/tools/memory-save.js +43 -0
- package/dist/tools/read.d.ts +2 -2
- package/dist/tools/read.js +2 -2
- package/dist/tools/registry.d.ts +63 -0
- package/dist/tools/registry.js +153 -0
- package/dist/tools/session-search.d.ts +2 -2
- package/dist/tools/session-search.js +9 -5
- package/dist/tools/skill-list.js +1 -1
- package/dist/tools/skill-manage.d.ts +1 -1
- package/dist/tools/skill-manage.js +3 -1
- package/dist/tools/skill-view.js +12 -11
- package/dist/tools/web-search.d.ts +1 -1
- package/dist/tools/web-search.js +1 -1
- package/package.json +5 -5
- package/dist/tools/attach.d.ts +0 -20
- package/dist/tools/attach.js +0 -69
|
@@ -5,10 +5,14 @@ const sessionSearchSchema = Type.Object({
|
|
|
5
5
|
query: Type.Optional(Type.String({
|
|
6
6
|
description: "Search query for current-channel transcript cold storage. Empty query returns recent entries.",
|
|
7
7
|
})),
|
|
8
|
-
limit: Type.Optional(Type.
|
|
9
|
-
roleFilter: Type.Optional(Type.Array(Type.
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
limit: Type.Optional(Type.Integer({ minimum: 1, maximum: 5, description: "Maximum results to return (1-5)" })),
|
|
9
|
+
roleFilter: Type.Optional(Type.Array(Type.Union([
|
|
10
|
+
Type.Literal("user"),
|
|
11
|
+
Type.Literal("assistant"),
|
|
12
|
+
Type.Literal("tool"),
|
|
13
|
+
Type.Literal("system"),
|
|
14
|
+
Type.Literal("unknown"),
|
|
15
|
+
]), { description: "Optional roles to include." })),
|
|
12
16
|
});
|
|
13
17
|
function clampLimit(limit) {
|
|
14
18
|
if (typeof limit !== "number" || !Number.isFinite(limit)) {
|
|
@@ -42,7 +46,7 @@ export function createSessionSearchTool(options) {
|
|
|
42
46
|
content: [
|
|
43
47
|
{
|
|
44
48
|
type: "text",
|
|
45
|
-
text: JSON.stringify(response
|
|
49
|
+
text: JSON.stringify(response),
|
|
46
50
|
},
|
|
47
51
|
],
|
|
48
52
|
details: {
|
package/dist/tools/skill-list.js
CHANGED
|
@@ -78,7 +78,7 @@ export function createSkillListTool(options) {
|
|
|
78
78
|
execute: async () => {
|
|
79
79
|
const skills = await listWorkspaceSkills(options);
|
|
80
80
|
return {
|
|
81
|
-
content: [{ type: "text", text: JSON.stringify({ skills }
|
|
81
|
+
content: [{ type: "text", text: JSON.stringify({ skills }) }],
|
|
82
82
|
details: { kind: "skill_list", count: skills.length },
|
|
83
83
|
};
|
|
84
84
|
},
|
|
@@ -2,7 +2,7 @@ import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
|
2
2
|
import { Type } from "typebox";
|
|
3
3
|
declare const skillManageSchema: Type.TObject<{
|
|
4
4
|
label: Type.TString;
|
|
5
|
-
action: Type.
|
|
5
|
+
action: Type.TUnion<[Type.TLiteral<"create">, Type.TLiteral<"patch">, Type.TLiteral<"write_file">]>;
|
|
6
6
|
name: Type.TString;
|
|
7
7
|
content: Type.TOptional<Type.TString>;
|
|
8
8
|
filePath: Type.TOptional<Type.TString>;
|
|
@@ -6,7 +6,9 @@ import { createAtomicTempPath, writeFileAtomically } from "../shared/atomic-file
|
|
|
6
6
|
import { resolveSkillPath, resolveSkillSupportingFile, scanSkillContent, validateSkillMarkdown, } from "./skill-security.js";
|
|
7
7
|
const skillManageSchema = Type.Object({
|
|
8
8
|
label: Type.String({ description: "Brief description of the skill management change (shown to user)" }),
|
|
9
|
-
action: Type.
|
|
9
|
+
action: Type.Union([Type.Literal("create"), Type.Literal("patch"), Type.Literal("write_file")], {
|
|
10
|
+
description: 'The skill management action to perform: "create", "patch", or "write_file".',
|
|
11
|
+
}),
|
|
10
12
|
name: Type.String({ description: "Workspace skill name" }),
|
|
11
13
|
content: Type.Optional(Type.String({ description: "Full content for create/write_file." })),
|
|
12
14
|
filePath: Type.Optional(Type.String({
|
package/dist/tools/skill-view.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readFile } from "node:fs/promises";
|
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { Type } from "typebox";
|
|
4
4
|
import { resolveSkillPath, resolveSkillSupportingFile } from "./skill-security.js";
|
|
5
|
+
import { DEFAULT_MAX_BYTES, formatSize, truncateHead } from "./truncate.js";
|
|
5
6
|
const skillViewSchema = Type.Object({
|
|
6
7
|
label: Type.String({ description: "Brief description of why you're viewing this skill (shown to user)" }),
|
|
7
8
|
name: Type.String({ description: "Workspace skill name" }),
|
|
@@ -24,19 +25,19 @@ export function createSkillViewTool(options) {
|
|
|
24
25
|
execute: async (_toolCallId, { name, filePath }) => {
|
|
25
26
|
const skillDir = resolveSkillPath(options.workspaceDir, name);
|
|
26
27
|
const targetPath = filePath ? resolveSkillSupportingFile(skillDir, filePath) : join(skillDir, "SKILL.md");
|
|
28
|
+
const workspacePath = toWorkspacePath(options, targetPath);
|
|
27
29
|
const content = await readFile(targetPath, "utf-8");
|
|
30
|
+
// Return the raw file content (not JSON-escaped) with a small header, and cap it
|
|
31
|
+
// with the shared truncation limits so a large supporting file cannot flood context.
|
|
32
|
+
const truncation = truncateHead(content);
|
|
33
|
+
let body = truncation.content;
|
|
34
|
+
if (truncation.truncated) {
|
|
35
|
+
body += `\n\n[Truncated at ${formatSize(DEFAULT_MAX_BYTES)}. Use the read tool on ${workspacePath} to page through the rest.]`;
|
|
36
|
+
}
|
|
37
|
+
const text = `Skill: ${name}\nPath: ${workspacePath}\n\n${body}`;
|
|
28
38
|
return {
|
|
29
|
-
content: [
|
|
30
|
-
|
|
31
|
-
type: "text",
|
|
32
|
-
text: JSON.stringify({
|
|
33
|
-
name,
|
|
34
|
-
path: toWorkspacePath(options, targetPath),
|
|
35
|
-
content,
|
|
36
|
-
}, null, 2),
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
details: { kind: "skill_view", name, path: toWorkspacePath(options, targetPath) },
|
|
39
|
+
content: [{ type: "text", text }],
|
|
40
|
+
details: { kind: "skill_view", name, path: workspacePath, truncated: truncation.truncated },
|
|
40
41
|
};
|
|
41
42
|
},
|
|
42
43
|
};
|
|
@@ -5,7 +5,7 @@ import type { PipiclawWebToolsConfig } from "./config.js";
|
|
|
5
5
|
declare const webSearchSchema: Type.TObject<{
|
|
6
6
|
label: Type.TString;
|
|
7
7
|
query: Type.TString;
|
|
8
|
-
count: Type.TOptional<Type.
|
|
8
|
+
count: Type.TOptional<Type.TInteger>;
|
|
9
9
|
}>;
|
|
10
10
|
export interface WebSearchToolOptions {
|
|
11
11
|
webConfig: PipiclawWebToolsConfig;
|
package/dist/tools/web-search.js
CHANGED
|
@@ -4,7 +4,7 @@ import { runWebSearch } from "../web/search.js";
|
|
|
4
4
|
const webSearchSchema = Type.Object({
|
|
5
5
|
label: Type.String({ description: "Brief description of what you're searching for and why (shown to user)" }),
|
|
6
6
|
query: Type.String({ description: "Search query" }),
|
|
7
|
-
count: Type.Optional(Type.
|
|
7
|
+
count: Type.Optional(Type.Integer({ minimum: 1, maximum: 10, description: "Maximum number of results to return (1-10)" })),
|
|
8
8
|
});
|
|
9
9
|
export function createWebSearchTool(options) {
|
|
10
10
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oyasmi/pipiclaw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta.1",
|
|
4
4
|
"description": "An AI assistant runtime for coding and team workflows, with DingTalk AI Cards, sub-agents, memory, and scheduled events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"prepublishOnly": "npm run clean && npm run build && npm run check"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@earendil-works/pi-agent-core": "0.80.
|
|
38
|
-
"@earendil-works/pi-ai": "0.80.
|
|
39
|
-
"@earendil-works/pi-coding-agent": "0.80.
|
|
37
|
+
"@earendil-works/pi-agent-core": "0.80.3",
|
|
38
|
+
"@earendil-works/pi-ai": "0.80.3",
|
|
39
|
+
"@earendil-works/pi-coding-agent": "0.80.3",
|
|
40
40
|
"@mozilla/readability": "^0.6.0",
|
|
41
41
|
"axios": "^1.7.0",
|
|
42
42
|
"croner": "^9.1.0",
|
|
43
43
|
"diff": "^8.0.2",
|
|
44
|
-
"dingtalk-stream": "
|
|
44
|
+
"dingtalk-stream": "2.1.5",
|
|
45
45
|
"http-proxy-agent": "^7.0.2",
|
|
46
46
|
"https-proxy-agent": "^7.0.6",
|
|
47
47
|
"jsdom": "^26.1.0",
|
package/dist/tools/attach.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { AgentTool } from "@earendil-works/pi-agent-core";
|
|
2
|
-
import { Type } from "typebox";
|
|
3
|
-
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
4
|
-
declare const attachSchema: Type.TObject<{
|
|
5
|
-
label: Type.TString;
|
|
6
|
-
path: Type.TString;
|
|
7
|
-
title: Type.TOptional<Type.TString>;
|
|
8
|
-
}>;
|
|
9
|
-
export type UploadFunction = (filePath: string, title?: string) => Promise<void>;
|
|
10
|
-
export interface AttachToolOptions {
|
|
11
|
-
securityConfig?: SecurityConfig;
|
|
12
|
-
securityContext?: SecurityRuntimeContext;
|
|
13
|
-
channelId?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Create the attach tool. If no uploadFn is provided, the tool will throw
|
|
17
|
-
* an informative error guiding the LLM to use alternative approaches.
|
|
18
|
-
*/
|
|
19
|
-
export declare function createAttachTool(uploadFn?: UploadFunction, options?: AttachToolOptions): AgentTool<typeof attachSchema>;
|
|
20
|
-
export {};
|
package/dist/tools/attach.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { basename, resolve as resolvePath } from "path";
|
|
2
|
-
import { Type } from "typebox";
|
|
3
|
-
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
|
-
import { logSecurityEvent } from "../security/logger.js";
|
|
5
|
-
import { guardPath } from "../security/path-guard.js";
|
|
6
|
-
const attachSchema = Type.Object({
|
|
7
|
-
label: Type.String({ description: "Brief description of what you're sharing (shown to user)" }),
|
|
8
|
-
path: Type.String({ description: "Path to the file to attach" }),
|
|
9
|
-
title: Type.Optional(Type.String({ description: "Title for the file (defaults to filename)" })),
|
|
10
|
-
});
|
|
11
|
-
/**
|
|
12
|
-
* Create the attach tool. If no uploadFn is provided, the tool will throw
|
|
13
|
-
* an informative error guiding the LLM to use alternative approaches.
|
|
14
|
-
*/
|
|
15
|
-
export function createAttachTool(uploadFn, options = {}) {
|
|
16
|
-
const securityConfig = options.securityConfig ?? DEFAULT_SECURITY_CONFIG;
|
|
17
|
-
const securityContext = options.securityContext ?? {
|
|
18
|
-
workspaceDir: process.cwd(),
|
|
19
|
-
workspacePath: process.cwd(),
|
|
20
|
-
cwd: process.cwd(),
|
|
21
|
-
};
|
|
22
|
-
return {
|
|
23
|
-
name: "attach",
|
|
24
|
-
label: "attach",
|
|
25
|
-
description: "Attach a file to your response. Use this to share files, images, or documents with the user. Only files from /workspace/ can be attached.",
|
|
26
|
-
parameters: attachSchema,
|
|
27
|
-
execute: async (_toolCallId, { path, title }, signal) => {
|
|
28
|
-
if (!uploadFn) {
|
|
29
|
-
throw new Error("File upload is not supported in DingTalk mode. Output file content as text instead, or use bash to host files.");
|
|
30
|
-
}
|
|
31
|
-
if (signal?.aborted) {
|
|
32
|
-
throw new Error("Operation aborted");
|
|
33
|
-
}
|
|
34
|
-
const absolutePath = resolvePath(path);
|
|
35
|
-
if (securityConfig.enabled && securityConfig.pathGuard.enabled) {
|
|
36
|
-
const readGuard = guardPath(path, "read", { ...securityContext, config: securityConfig.pathGuard });
|
|
37
|
-
if (!readGuard.allowed) {
|
|
38
|
-
logSecurityEvent(securityContext.workspaceDir, securityConfig, {
|
|
39
|
-
type: "path",
|
|
40
|
-
tool: "attach",
|
|
41
|
-
channelId: options.channelId,
|
|
42
|
-
rawPath: path,
|
|
43
|
-
operation: "read",
|
|
44
|
-
resolvedPath: readGuard.resolvedPath,
|
|
45
|
-
category: readGuard.category,
|
|
46
|
-
reason: readGuard.reason,
|
|
47
|
-
});
|
|
48
|
-
throw new Error([
|
|
49
|
-
`Path blocked${readGuard.category ? ` [${readGuard.category}]` : ""}`,
|
|
50
|
-
readGuard.reason ? `Reason: ${readGuard.reason}` : "",
|
|
51
|
-
readGuard.resolvedPath ? `Resolved path: ${readGuard.resolvedPath}` : "",
|
|
52
|
-
]
|
|
53
|
-
.filter(Boolean)
|
|
54
|
-
.join("\n"));
|
|
55
|
-
}
|
|
56
|
-
const workspaceRoot = resolvePath(securityContext.workspaceDir);
|
|
57
|
-
if (absolutePath !== workspaceRoot && !absolutePath.startsWith(`${workspaceRoot}/`)) {
|
|
58
|
-
throw new Error("Attach is limited to files inside the workspace directory.");
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const fileName = title || basename(absolutePath);
|
|
62
|
-
await uploadFn(absolutePath, fileName);
|
|
63
|
-
return {
|
|
64
|
-
content: [{ type: "text", text: `Attached file: ${fileName}` }],
|
|
65
|
-
details: undefined,
|
|
66
|
-
};
|
|
67
|
-
},
|
|
68
|
-
};
|
|
69
|
-
}
|