@oyasmi/pipiclaw 0.6.6-beta.3 → 0.6.7-beta.0
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 +9 -3
- package/dist/agent/channel-runner.js +123 -63
- package/dist/agent/command-extension.js +15 -7
- package/dist/agent/session-events.js +38 -14
- package/dist/memory/lifecycle.d.ts +1 -1
- package/dist/memory/lifecycle.js +3 -3
- package/dist/runtime/bootstrap.js +13 -1
- package/dist/runtime/delivery.js +1 -0
- package/dist/runtime/dingtalk.d.ts +7 -0
- package/dist/runtime/dingtalk.js +22 -1
- package/dist/subagents/tool.d.ts +16 -15
- package/dist/subagents/tool.js +1 -1
- package/dist/tools/attach.d.ts +5 -4
- package/dist/tools/attach.js +1 -1
- package/dist/tools/bash.d.ts +5 -4
- package/dist/tools/bash.js +1 -1
- package/dist/tools/edit.d.ts +6 -5
- package/dist/tools/edit.js +1 -1
- package/dist/tools/read.d.ts +6 -5
- package/dist/tools/read.js +1 -1
- package/dist/tools/session-search.d.ts +6 -5
- package/dist/tools/session-search.js +1 -1
- package/dist/tools/skill-list.d.ts +3 -2
- package/dist/tools/skill-list.js +1 -1
- package/dist/tools/skill-manage.d.ts +9 -8
- package/dist/tools/skill-manage.js +1 -1
- package/dist/tools/skill-view.d.ts +5 -4
- package/dist/tools/skill-view.js +1 -1
- package/dist/tools/web-fetch.d.ts +6 -5
- package/dist/tools/web-fetch.js +1 -1
- package/dist/tools/web-search.d.ts +5 -4
- package/dist/tools/web-search.js +1 -1
- package/dist/tools/write.d.ts +5 -4
- package/dist/tools/write.js +1 -1
- package/package.json +6 -6
|
@@ -11,15 +11,17 @@ export declare class ChannelRunner implements AgentRunner {
|
|
|
11
11
|
private readonly channelDir;
|
|
12
12
|
private readonly workspacePath;
|
|
13
13
|
private readonly workspaceDir;
|
|
14
|
-
private
|
|
15
|
-
private
|
|
16
|
-
private
|
|
14
|
+
private session;
|
|
15
|
+
private agent;
|
|
16
|
+
private sessionManager;
|
|
17
17
|
private readonly settingsManager;
|
|
18
18
|
private readonly modelRegistry;
|
|
19
19
|
private readonly memoryLifecycle;
|
|
20
20
|
private readonly memoryCandidateStore;
|
|
21
21
|
private readonly sessionResourceGate;
|
|
22
22
|
private readonly sessionReady;
|
|
23
|
+
private readonly sessionRuntime;
|
|
24
|
+
private sessionUnsubscribe?;
|
|
23
25
|
private subAgentDiscovery;
|
|
24
26
|
private activeModel;
|
|
25
27
|
private currentSkills;
|
|
@@ -53,6 +55,10 @@ export declare class ChannelRunner implements AgentRunner {
|
|
|
53
55
|
private refreshSubAgentDiscovery;
|
|
54
56
|
private reportSettingsDiagnostics;
|
|
55
57
|
private reportConfigDiagnostics;
|
|
58
|
+
private createResourceLoader;
|
|
59
|
+
private createAgentSessionServices;
|
|
60
|
+
private createEmptyExtensionsResult;
|
|
61
|
+
private createSessionRuntime;
|
|
56
62
|
private buildRuntimeTools;
|
|
57
63
|
private rebuildSessionTools;
|
|
58
64
|
private subscribeToSessionEvents;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Agent } from "@mariozechner/pi-agent-core";
|
|
2
|
-
import { AgentSession, AuthStorage, convertToLlm, DefaultResourceLoader, ModelRegistry, SessionManager, } from "@mariozechner/pi-coding-agent";
|
|
2
|
+
import { AgentSession, AgentSessionRuntime, AuthStorage, convertToLlm, createExtensionRuntime, 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
5
|
import * as log from "../log.js";
|
|
@@ -80,15 +80,14 @@ export class ChannelRunner {
|
|
|
80
80
|
this.activeModel = resolveInitialModel(this.modelRegistry, this.settingsManager);
|
|
81
81
|
log.logInfo(`Using model: ${this.activeModel.provider}/${this.activeModel.id} (${this.activeModel.name})`);
|
|
82
82
|
this.subAgentDiscovery = this.refreshSubAgentDiscovery();
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
// Create agent
|
|
83
|
+
const initialSessionManager = this.sessionManager;
|
|
84
|
+
const initialTools = this.buildRuntimeTools();
|
|
86
85
|
this.agent = new Agent({
|
|
87
86
|
initialState: {
|
|
88
87
|
systemPrompt: "",
|
|
89
88
|
model: this.activeModel,
|
|
90
89
|
thinkingLevel: "off",
|
|
91
|
-
tools,
|
|
90
|
+
tools: initialTools,
|
|
92
91
|
},
|
|
93
92
|
convertToLlm,
|
|
94
93
|
getApiKey: async () => getApiKeyForModel(this.modelRegistry, this.activeModel),
|
|
@@ -105,62 +104,33 @@ export class ChannelRunner {
|
|
|
105
104
|
void this.recordMemoryActivity(event);
|
|
106
105
|
},
|
|
107
106
|
});
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
agentDir: APP_HOME_DIR,
|
|
111
|
-
settingsManager: asSdkSettingsManager(this.settingsManager),
|
|
112
|
-
extensionFactories: [
|
|
113
|
-
this.memoryLifecycle.createExtensionFactory(),
|
|
114
|
-
createCommandExtension({
|
|
115
|
-
getCurrentModel: () => this.session.model ?? this.activeModel,
|
|
116
|
-
getAvailableModels: async () => {
|
|
117
|
-
this.modelRegistry.refresh();
|
|
118
|
-
return await this.modelRegistry.getAvailable();
|
|
119
|
-
},
|
|
120
|
-
getSessionStats: () => this.session.getSessionStats(),
|
|
121
|
-
getThinkingLevel: () => this.session.thinkingLevel,
|
|
122
|
-
switchModel: async (model) => {
|
|
123
|
-
await this.session.setModel(model);
|
|
124
|
-
this.activeModel = model;
|
|
125
|
-
},
|
|
126
|
-
refreshSessionResources: async () => {
|
|
127
|
-
await this.refreshSessionResources();
|
|
128
|
-
},
|
|
129
|
-
}),
|
|
130
|
-
],
|
|
131
|
-
appendSystemPromptOverride: (base) => {
|
|
132
|
-
const soul = getSoul(this.workspaceDir);
|
|
133
|
-
const sections = [...base];
|
|
134
|
-
if (soul) {
|
|
135
|
-
sections.unshift(soul);
|
|
136
|
-
}
|
|
137
|
-
sections.push(buildAppendSystemPrompt(this.workspacePath, this.channelId, this.sandboxConfig, {
|
|
138
|
-
subAgentList: formatSubAgentList(this.subAgentDiscovery.agents),
|
|
139
|
-
}));
|
|
140
|
-
return sections;
|
|
141
|
-
},
|
|
142
|
-
agentsFilesOverride: () => {
|
|
143
|
-
const agentConfig = getAgentConfig(this.channelDir);
|
|
144
|
-
return {
|
|
145
|
-
agentsFiles: agentConfig ? [{ path: `${this.workspacePath}/AGENTS.md`, content: agentConfig }] : [],
|
|
146
|
-
};
|
|
147
|
-
},
|
|
148
|
-
skillsOverride: (base) => ({
|
|
149
|
-
skills: [...base.skills, ...this.currentSkills],
|
|
150
|
-
diagnostics: base.diagnostics,
|
|
151
|
-
}),
|
|
152
|
-
});
|
|
153
|
-
const baseToolsOverride = Object.fromEntries(tools.map((tool) => [tool.name, tool]));
|
|
154
|
-
// Create AgentSession
|
|
107
|
+
const initialResourceLoader = this.createResourceLoader();
|
|
108
|
+
const baseToolsOverride = Object.fromEntries(initialTools.map((tool) => [tool.name, tool]));
|
|
155
109
|
this.session = new AgentSession({
|
|
156
110
|
agent: this.agent,
|
|
157
|
-
sessionManager:
|
|
111
|
+
sessionManager: initialSessionManager,
|
|
158
112
|
settingsManager: asSdkSettingsManager(this.settingsManager),
|
|
159
113
|
cwd: process.cwd(),
|
|
160
114
|
modelRegistry: this.modelRegistry,
|
|
161
|
-
resourceLoader,
|
|
115
|
+
resourceLoader: initialResourceLoader,
|
|
162
116
|
baseToolsOverride,
|
|
163
117
|
});
|
|
118
|
+
this.sessionRuntime = new AgentSessionRuntime(this.session, this.createAgentSessionServices(initialResourceLoader), async ({ sessionManager, sessionStartEvent }) => {
|
|
119
|
+
const next = this.createSessionRuntime(sessionManager, sessionStartEvent);
|
|
120
|
+
return {
|
|
121
|
+
session: next.session,
|
|
122
|
+
extensionsResult: this.createEmptyExtensionsResult(),
|
|
123
|
+
services: this.createAgentSessionServices(next.resourceLoader),
|
|
124
|
+
diagnostics: [],
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
this.sessionRuntime.setRebindSession(async (session) => {
|
|
128
|
+
this.session = session;
|
|
129
|
+
this.agent = session.agent;
|
|
130
|
+
this.sessionManager = session.sessionManager;
|
|
131
|
+
await this.bindSessionExtensions();
|
|
132
|
+
this.subscribeToSessionEvents();
|
|
133
|
+
});
|
|
164
134
|
this.sessionResourceGate = new SessionResourceGate(async () => {
|
|
165
135
|
await this.reloadSessionResources();
|
|
166
136
|
});
|
|
@@ -494,20 +464,18 @@ export class ChannelRunner {
|
|
|
494
464
|
commandContextActions: {
|
|
495
465
|
waitForIdle: () => this.session.agent.waitForIdle(),
|
|
496
466
|
newSession: async (options) => {
|
|
497
|
-
|
|
498
|
-
return { cancelled: !success };
|
|
467
|
+
return await this.sessionRuntime.newSession(options);
|
|
499
468
|
},
|
|
500
|
-
fork: async (entryId) => {
|
|
501
|
-
const result = await this.
|
|
469
|
+
fork: async (entryId, options) => {
|
|
470
|
+
const result = await this.sessionRuntime.fork(entryId, options);
|
|
502
471
|
return { cancelled: result.cancelled };
|
|
503
472
|
},
|
|
504
473
|
navigateTree: async (targetId, options) => {
|
|
505
474
|
const result = await this.session.navigateTree(targetId, options);
|
|
506
475
|
return { cancelled: result.cancelled };
|
|
507
476
|
},
|
|
508
|
-
switchSession: async (sessionPath) => {
|
|
509
|
-
|
|
510
|
-
return { cancelled: !success };
|
|
477
|
+
switchSession: async (sessionPath, options) => {
|
|
478
|
+
return await this.sessionRuntime.switchSession(sessionPath, options);
|
|
511
479
|
},
|
|
512
480
|
reload: async () => {
|
|
513
481
|
await this.refreshSessionResources();
|
|
@@ -557,6 +525,96 @@ export class ChannelRunner {
|
|
|
557
525
|
log.logWarning(`[${this.channelId}] ${formatConfigDiagnostic(diagnostic)}`, diagnostic.path);
|
|
558
526
|
}
|
|
559
527
|
}
|
|
528
|
+
createResourceLoader() {
|
|
529
|
+
return new DefaultResourceLoader({
|
|
530
|
+
cwd: process.cwd(),
|
|
531
|
+
agentDir: APP_HOME_DIR,
|
|
532
|
+
settingsManager: asSdkSettingsManager(this.settingsManager),
|
|
533
|
+
extensionFactories: [
|
|
534
|
+
this.memoryLifecycle.createExtensionFactory(),
|
|
535
|
+
createCommandExtension({
|
|
536
|
+
getCurrentModel: () => this.session.model ?? this.activeModel,
|
|
537
|
+
getAvailableModels: async () => {
|
|
538
|
+
this.modelRegistry.refresh();
|
|
539
|
+
return await this.modelRegistry.getAvailable();
|
|
540
|
+
},
|
|
541
|
+
getSessionStats: () => this.session.getSessionStats(),
|
|
542
|
+
getThinkingLevel: () => this.session.thinkingLevel,
|
|
543
|
+
switchModel: async (model) => {
|
|
544
|
+
await this.session.setModel(model);
|
|
545
|
+
this.activeModel = model;
|
|
546
|
+
},
|
|
547
|
+
refreshSessionResources: async () => {
|
|
548
|
+
await this.refreshSessionResources();
|
|
549
|
+
},
|
|
550
|
+
}),
|
|
551
|
+
],
|
|
552
|
+
appendSystemPromptOverride: (base) => {
|
|
553
|
+
const soul = getSoul(this.workspaceDir);
|
|
554
|
+
const sections = [...base];
|
|
555
|
+
if (soul) {
|
|
556
|
+
sections.unshift(soul);
|
|
557
|
+
}
|
|
558
|
+
sections.push(buildAppendSystemPrompt(this.workspacePath, this.channelId, this.sandboxConfig, {
|
|
559
|
+
subAgentList: formatSubAgentList(this.subAgentDiscovery.agents),
|
|
560
|
+
}));
|
|
561
|
+
return sections;
|
|
562
|
+
},
|
|
563
|
+
agentsFilesOverride: () => {
|
|
564
|
+
const agentConfig = getAgentConfig(this.channelDir);
|
|
565
|
+
return {
|
|
566
|
+
agentsFiles: agentConfig ? [{ path: `${this.workspacePath}/AGENTS.md`, content: agentConfig }] : [],
|
|
567
|
+
};
|
|
568
|
+
},
|
|
569
|
+
skillsOverride: (base) => ({
|
|
570
|
+
skills: [...base.skills, ...this.currentSkills],
|
|
571
|
+
diagnostics: base.diagnostics,
|
|
572
|
+
}),
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
createAgentSessionServices(resourceLoader) {
|
|
576
|
+
return {
|
|
577
|
+
cwd: process.cwd(),
|
|
578
|
+
agentDir: APP_HOME_DIR,
|
|
579
|
+
authStorage: AuthStorage.create(AUTH_CONFIG_PATH),
|
|
580
|
+
settingsManager: asSdkSettingsManager(this.settingsManager),
|
|
581
|
+
modelRegistry: this.modelRegistry,
|
|
582
|
+
resourceLoader,
|
|
583
|
+
diagnostics: [],
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
createEmptyExtensionsResult() {
|
|
587
|
+
return {
|
|
588
|
+
extensions: [],
|
|
589
|
+
errors: [],
|
|
590
|
+
runtime: createExtensionRuntime(),
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
createSessionRuntime(sessionManager, sessionStartEvent) {
|
|
594
|
+
const tools = this.buildRuntimeTools();
|
|
595
|
+
const agent = new Agent({
|
|
596
|
+
initialState: {
|
|
597
|
+
systemPrompt: "",
|
|
598
|
+
model: this.activeModel,
|
|
599
|
+
thinkingLevel: "off",
|
|
600
|
+
tools,
|
|
601
|
+
},
|
|
602
|
+
convertToLlm,
|
|
603
|
+
getApiKey: async () => getApiKeyForModel(this.modelRegistry, this.activeModel),
|
|
604
|
+
});
|
|
605
|
+
const resourceLoader = this.createResourceLoader();
|
|
606
|
+
const session = new AgentSession({
|
|
607
|
+
agent,
|
|
608
|
+
sessionManager,
|
|
609
|
+
settingsManager: asSdkSettingsManager(this.settingsManager),
|
|
610
|
+
cwd: process.cwd(),
|
|
611
|
+
modelRegistry: this.modelRegistry,
|
|
612
|
+
resourceLoader,
|
|
613
|
+
baseToolsOverride: Object.fromEntries(tools.map((tool) => [tool.name, tool])),
|
|
614
|
+
sessionStartEvent,
|
|
615
|
+
});
|
|
616
|
+
return { agent, session, resourceLoader };
|
|
617
|
+
}
|
|
560
618
|
buildRuntimeTools() {
|
|
561
619
|
const securityLoad = loadSecurityConfigWithDiagnostics(APP_HOME_DIR);
|
|
562
620
|
const toolsLoad = loadToolsConfigWithDiagnostics(APP_HOME_DIR);
|
|
@@ -581,13 +639,15 @@ export class ChannelRunner {
|
|
|
581
639
|
}
|
|
582
640
|
rebuildSessionTools() {
|
|
583
641
|
const tools = this.buildRuntimeTools();
|
|
584
|
-
this.agent.setTools(tools);
|
|
585
642
|
this.session._baseToolsOverride =
|
|
586
643
|
Object.fromEntries(tools.map((tool) => [tool.name, tool]));
|
|
644
|
+
this.agent.state.tools = tools;
|
|
645
|
+
this.session.setActiveToolsByName(tools.map((tool) => tool.name));
|
|
587
646
|
}
|
|
588
647
|
// === Session event subscription ===
|
|
589
648
|
subscribeToSessionEvents() {
|
|
590
|
-
this.
|
|
649
|
+
this.sessionUnsubscribe?.();
|
|
650
|
+
this.sessionUnsubscribe = this.session.subscribe(async (event) => {
|
|
591
651
|
if (isRecord(event) && event.type === "message_start") {
|
|
592
652
|
this.agentLoopStarted = true;
|
|
593
653
|
}
|
|
@@ -27,8 +27,8 @@ async function runCompact(ctx, customInstructions) {
|
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
function sendCommandResult(
|
|
31
|
-
|
|
30
|
+
function sendCommandResult(sender, text) {
|
|
31
|
+
return sender.sendMessage({
|
|
32
32
|
customType: COMMAND_RESULT_CUSTOM_TYPE,
|
|
33
33
|
content: text,
|
|
34
34
|
display: true,
|
|
@@ -83,13 +83,21 @@ ${available}`);
|
|
|
83
83
|
pi.registerCommand("new", {
|
|
84
84
|
description: "Start a new session",
|
|
85
85
|
handler: async (_args, ctx) => {
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
let sentFromReplacement = false;
|
|
87
|
+
const result = await ctx.newSession({
|
|
88
|
+
withSession: async (nextCtx) => {
|
|
89
|
+
sentFromReplacement = true;
|
|
90
|
+
await options.refreshSessionResources();
|
|
91
|
+
await sendCommandResult(nextCtx, `已开启新会话。\n\nSession ID: \`${nextCtx.sessionManager.getSessionId()}\``);
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
if (result.cancelled) {
|
|
95
|
+
sendCommandResult(pi, "新会话已取消。");
|
|
96
|
+
}
|
|
97
|
+
else if (!sentFromReplacement) {
|
|
88
98
|
await options.refreshSessionResources();
|
|
99
|
+
sendCommandResult(pi, `已开启新会话。\n\nSession ID: \`${ctx.sessionManager.getSessionId()}\``);
|
|
89
100
|
}
|
|
90
|
-
sendCommandResult(pi, result.cancelled
|
|
91
|
-
? "新会话已取消。"
|
|
92
|
-
: `已开启新会话。\n\nSession ID: \`${ctx.sessionManager.getSessionId()}\``);
|
|
93
101
|
},
|
|
94
102
|
});
|
|
95
103
|
pi.registerCommand("compact", {
|
|
@@ -33,6 +33,7 @@ function mergeAssistantUsage(runState, usage) {
|
|
|
33
33
|
}
|
|
34
34
|
export async function handleSessionEvent(event, context) {
|
|
35
35
|
const { ctx, logCtx, queue, pendingTools, store, runState, memoryLifecycle } = context;
|
|
36
|
+
const finalCardOnly = ctx.responseMode === "final_card_only";
|
|
36
37
|
if (isToolExecutionStartEvent(event)) {
|
|
37
38
|
const label = extractLabelFromArgs(event.args) || event.toolName;
|
|
38
39
|
pendingTools.set(event.toolCallId, {
|
|
@@ -42,7 +43,9 @@ export async function handleSessionEvent(event, context) {
|
|
|
42
43
|
});
|
|
43
44
|
memoryLifecycle.noteToolCall();
|
|
44
45
|
log.logToolStart(logCtx, event.toolName, label, isRecord(event.args) ? event.args : {});
|
|
45
|
-
|
|
46
|
+
if (!finalCardOnly) {
|
|
47
|
+
queue.enqueue(() => ctx.respond(formatProgressEntry("tool", label), false), "tool label");
|
|
48
|
+
}
|
|
46
49
|
return;
|
|
47
50
|
}
|
|
48
51
|
if (isToolExecutionUpdateEvent(event)) {
|
|
@@ -53,7 +56,9 @@ export async function handleSessionEvent(event, context) {
|
|
|
53
56
|
if (!partialText.trim()) {
|
|
54
57
|
return;
|
|
55
58
|
}
|
|
56
|
-
|
|
59
|
+
if (!finalCardOnly) {
|
|
60
|
+
queue.enqueue(() => ctx.respond(formatProgressEntry("tool", partialText), false), "tool update");
|
|
61
|
+
}
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
59
64
|
if (isToolExecutionEndEvent(event)) {
|
|
@@ -112,7 +117,7 @@ export async function handleSessionEvent(event, context) {
|
|
|
112
117
|
else {
|
|
113
118
|
log.logToolSuccess(logCtx, event.toolName, durationMs, resultStr);
|
|
114
119
|
}
|
|
115
|
-
if (treatAsError) {
|
|
120
|
+
if (treatAsError && !finalCardOnly) {
|
|
116
121
|
queue.enqueue(() => ctx.respond(formatProgressEntry("error", truncate(resultStr, 200)), false), "tool error");
|
|
117
122
|
}
|
|
118
123
|
return;
|
|
@@ -129,10 +134,15 @@ export async function handleSessionEvent(event, context) {
|
|
|
129
134
|
runState.finalOutcome = { kind: "final", text: commandResultText };
|
|
130
135
|
log.logResponse(logCtx, commandResultText);
|
|
131
136
|
queue.enqueue(async () => {
|
|
132
|
-
|
|
133
|
-
if (!delivered) {
|
|
137
|
+
if (finalCardOnly) {
|
|
134
138
|
await ctx.replaceMessage(commandResultText);
|
|
135
139
|
}
|
|
140
|
+
else {
|
|
141
|
+
const delivered = await ctx.respondPlain(commandResultText);
|
|
142
|
+
if (!delivered) {
|
|
143
|
+
await ctx.replaceMessage(commandResultText);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
136
146
|
runState.finalResponseDelivered = true;
|
|
137
147
|
}, "command result");
|
|
138
148
|
return;
|
|
@@ -163,11 +173,13 @@ export async function handleSessionEvent(event, context) {
|
|
|
163
173
|
}
|
|
164
174
|
}
|
|
165
175
|
const text = textParts.join("\n");
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
176
|
+
if (!finalCardOnly) {
|
|
177
|
+
for (const thinking of thinkingParts) {
|
|
178
|
+
log.logThinking(logCtx, thinking);
|
|
179
|
+
queue.enqueue(() => ctx.respond(formatProgressEntry("thinking", thinking), false), "thinking");
|
|
180
|
+
}
|
|
169
181
|
}
|
|
170
|
-
if (
|
|
182
|
+
if (text.trim() && (hasToolCalls || finalCardOnly)) {
|
|
171
183
|
queue.enqueue(() => ctx.respond(formatProgressEntry("assistant", text), false), "assistant progress");
|
|
172
184
|
}
|
|
173
185
|
}
|
|
@@ -198,10 +210,16 @@ export async function handleSessionEvent(event, context) {
|
|
|
198
210
|
memoryLifecycle.noteCompletedAssistantTurn();
|
|
199
211
|
log.logResponse(logCtx, finalText);
|
|
200
212
|
queue.enqueue(async () => {
|
|
201
|
-
|
|
202
|
-
|
|
213
|
+
if (finalCardOnly) {
|
|
214
|
+
await ctx.replaceMessage(finalText);
|
|
203
215
|
runState.finalResponseDelivered = true;
|
|
204
216
|
}
|
|
217
|
+
else {
|
|
218
|
+
const delivered = await ctx.respondPlain(finalText);
|
|
219
|
+
if (delivered) {
|
|
220
|
+
runState.finalResponseDelivered = true;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
205
223
|
}, "final response");
|
|
206
224
|
}
|
|
207
225
|
return;
|
|
@@ -209,7 +227,9 @@ export async function handleSessionEvent(event, context) {
|
|
|
209
227
|
if (isAutoCompactionStartEvent(event)) {
|
|
210
228
|
const label = "Compacting context...";
|
|
211
229
|
log.logInfo(`Compaction started (reason: ${event.reason})`);
|
|
212
|
-
|
|
230
|
+
if (!finalCardOnly) {
|
|
231
|
+
queue.enqueue(() => ctx.respond(formatProgressEntry("assistant", label), false), "compaction start");
|
|
232
|
+
}
|
|
213
233
|
return;
|
|
214
234
|
}
|
|
215
235
|
if (isAutoCompactionEndEvent(event)) {
|
|
@@ -223,12 +243,16 @@ export async function handleSessionEvent(event, context) {
|
|
|
223
243
|
else if (event.errorMessage) {
|
|
224
244
|
runState.lastCompactionError = event.errorMessage;
|
|
225
245
|
log.logWarning("Compaction failed", event.errorMessage);
|
|
226
|
-
|
|
246
|
+
if (!finalCardOnly) {
|
|
247
|
+
queue.enqueue(() => ctx.respond(formatProgressEntry("error", truncate(event.errorMessage ?? "Compaction failed", 200)), false), "compaction error");
|
|
248
|
+
}
|
|
227
249
|
}
|
|
228
250
|
return;
|
|
229
251
|
}
|
|
230
252
|
if (isAutoRetryStartEvent(event)) {
|
|
231
253
|
log.logWarning(`Retrying (${event.attempt}/${event.maxAttempts})`, event.errorMessage);
|
|
232
|
-
|
|
254
|
+
if (!finalCardOnly) {
|
|
255
|
+
queue.enqueue(() => ctx.respond(formatProgressEntry("assistant", `Retrying (${event.attempt}/${event.maxAttempts})...`), false), "retry");
|
|
256
|
+
}
|
|
233
257
|
}
|
|
234
258
|
}
|
package/dist/memory/lifecycle.js
CHANGED
|
@@ -33,8 +33,8 @@ export class MemoryLifecycle {
|
|
|
33
33
|
pi.on("session_before_switch", async (event) => {
|
|
34
34
|
await this.handleSessionBeforeSwitch(event);
|
|
35
35
|
});
|
|
36
|
-
pi.on("
|
|
37
|
-
this.
|
|
36
|
+
pi.on("session_start", async (event) => {
|
|
37
|
+
this.handleSessionStart(event);
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -204,7 +204,7 @@ export class MemoryLifecycle {
|
|
|
204
204
|
}
|
|
205
205
|
await this.runPreflightConsolidation("new-session");
|
|
206
206
|
}
|
|
207
|
-
|
|
207
|
+
handleSessionStart(event) {
|
|
208
208
|
if (event.reason !== "new") {
|
|
209
209
|
return;
|
|
210
210
|
}
|
|
@@ -14,7 +14,7 @@ import { formatConfigDiagnostic } from "../shared/config-diagnostics.js";
|
|
|
14
14
|
import { loadToolsConfigWithDiagnostics } from "../tools/config.js";
|
|
15
15
|
import { ensureChannelDir } from "./channel-paths.js";
|
|
16
16
|
import { createDingTalkContext } from "./delivery.js";
|
|
17
|
-
import { DingTalkBot, isBusyMessageDefaultConfig, isProgressDisplayConfig, normalizeBusyMessageDefault, normalizeProgressDisplay, } from "./dingtalk.js";
|
|
17
|
+
import { DingTalkBot, isBusyMessageDefaultConfig, isProgressDisplayConfig, isResponseModeConfig, normalizeBusyMessageDefault, normalizeProgressDisplay, normalizeResponseMode, } from "./dingtalk.js";
|
|
18
18
|
import { createEventsWatcher } from "./events.js";
|
|
19
19
|
import { ChannelStore } from "./store.js";
|
|
20
20
|
const DEFAULT_SOUL = `# SOUL.md
|
|
@@ -104,6 +104,8 @@ const CHANNEL_CONFIG_TEMPLATE = {
|
|
|
104
104
|
allowFrom: ["your-staff-id"],
|
|
105
105
|
busyMessageDefault: "steer",
|
|
106
106
|
progressDisplay: "full",
|
|
107
|
+
responseMode: "progress_then_plain_final",
|
|
108
|
+
cardAutoLayout: true,
|
|
107
109
|
};
|
|
108
110
|
const MODELS_CONFIG_TEMPLATE = { providers: {} };
|
|
109
111
|
const TOOLS_CONFIG_TEMPLATE = {
|
|
@@ -246,6 +248,14 @@ function listChannelConfigIssues(config) {
|
|
|
246
248
|
if (progressDisplay !== undefined && !isProgressDisplayConfig(progressDisplay)) {
|
|
247
249
|
issues.push('Invalid `progressDisplay`: expected "full" or "rolling".');
|
|
248
250
|
}
|
|
251
|
+
const responseMode = config.responseMode;
|
|
252
|
+
if (responseMode !== undefined && !isResponseModeConfig(responseMode)) {
|
|
253
|
+
issues.push('Invalid `responseMode`: expected "progress_then_plain_final" or "final_card_only".');
|
|
254
|
+
}
|
|
255
|
+
const cardAutoLayout = config.cardAutoLayout;
|
|
256
|
+
if (cardAutoLayout !== undefined && typeof cardAutoLayout !== "boolean") {
|
|
257
|
+
issues.push("Invalid `cardAutoLayout`: expected boolean.");
|
|
258
|
+
}
|
|
249
259
|
return issues;
|
|
250
260
|
}
|
|
251
261
|
export function printBootstrapSummary(result, io = console, paths = DEFAULT_BOOTSTRAP_PATHS) {
|
|
@@ -282,6 +292,8 @@ export function loadConfig(paths = DEFAULT_BOOTSTRAP_PATHS, io = console) {
|
|
|
282
292
|
parsed.robotCode = parsed.robotCode?.trim() ? parsed.robotCode : parsed.clientId;
|
|
283
293
|
parsed.busyMessageDefault = normalizeBusyMessageDefault(parsed.busyMessageDefault);
|
|
284
294
|
parsed.progressDisplay = normalizeProgressDisplay(parsed.progressDisplay);
|
|
295
|
+
parsed.responseMode = normalizeResponseMode(parsed.responseMode);
|
|
296
|
+
parsed.cardAutoLayout = parsed.cardAutoLayout ?? true;
|
|
285
297
|
if (Array.isArray(parsed.allowFrom)) {
|
|
286
298
|
parsed.allowFrom = parsed.allowFrom.filter((value) => value.trim().length > 0);
|
|
287
299
|
}
|
package/dist/runtime/delivery.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export type BusyMessageMode = "steer" | "followUp";
|
|
2
2
|
export type BusyMessageDefaultConfig = BusyMessageMode | "followup";
|
|
3
3
|
export type ProgressDisplayMode = "full" | "rolling";
|
|
4
|
+
export type ResponseMode = "progress_then_plain_final" | "final_card_only";
|
|
4
5
|
export declare function isBusyMessageDefaultConfig(value: unknown): value is BusyMessageDefaultConfig;
|
|
5
6
|
export declare function isProgressDisplayConfig(value: unknown): value is ProgressDisplayMode;
|
|
7
|
+
export declare function isResponseModeConfig(value: unknown): value is ResponseMode;
|
|
6
8
|
export declare function normalizeBusyMessageDefault(value: unknown): BusyMessageMode;
|
|
7
9
|
export declare function normalizeProgressDisplay(value: unknown): ProgressDisplayMode;
|
|
10
|
+
export declare function normalizeResponseMode(value: unknown): ResponseMode;
|
|
8
11
|
export interface DingTalkConfig {
|
|
9
12
|
clientId: string;
|
|
10
13
|
clientSecret: string;
|
|
@@ -15,6 +18,8 @@ export interface DingTalkConfig {
|
|
|
15
18
|
stateDir?: string;
|
|
16
19
|
busyMessageDefault?: BusyMessageDefaultConfig;
|
|
17
20
|
progressDisplay?: ProgressDisplayMode;
|
|
21
|
+
responseMode?: ResponseMode;
|
|
22
|
+
cardAutoLayout?: boolean;
|
|
18
23
|
}
|
|
19
24
|
export interface DingTalkEvent {
|
|
20
25
|
type: "dm" | "group";
|
|
@@ -46,6 +51,7 @@ export interface DingTalkContext {
|
|
|
46
51
|
primeCard: (delayMs: number) => void;
|
|
47
52
|
flush: () => Promise<void>;
|
|
48
53
|
close: () => Promise<void>;
|
|
54
|
+
responseMode: ResponseMode;
|
|
49
55
|
}
|
|
50
56
|
export type BusyMessageResult = {
|
|
51
57
|
kind: "handled";
|
|
@@ -82,6 +88,7 @@ export declare class DingTalkBot {
|
|
|
82
88
|
constructor(handler: DingTalkHandler, config: DingTalkConfig);
|
|
83
89
|
get busyMessageDefault(): BusyMessageMode;
|
|
84
90
|
get progressDisplay(): ProgressDisplayMode;
|
|
91
|
+
get responseMode(): ResponseMode;
|
|
85
92
|
/**
|
|
86
93
|
* Mark an ID as processed. Returns true if this is a new ID, false if already seen.
|
|
87
94
|
* Maintains a FIFO buffer of at most 200 entries.
|
package/dist/runtime/dingtalk.js
CHANGED
|
@@ -21,6 +21,9 @@ export function isBusyMessageDefaultConfig(value) {
|
|
|
21
21
|
export function isProgressDisplayConfig(value) {
|
|
22
22
|
return value === "full" || value === "rolling";
|
|
23
23
|
}
|
|
24
|
+
export function isResponseModeConfig(value) {
|
|
25
|
+
return value === "progress_then_plain_final" || value === "final_card_only";
|
|
26
|
+
}
|
|
24
27
|
export function normalizeBusyMessageDefault(value) {
|
|
25
28
|
if (value === undefined) {
|
|
26
29
|
return "steer";
|
|
@@ -42,6 +45,15 @@ export function normalizeProgressDisplay(value) {
|
|
|
42
45
|
}
|
|
43
46
|
throw new Error('Invalid `progressDisplay`: expected "full" or "rolling".');
|
|
44
47
|
}
|
|
48
|
+
export function normalizeResponseMode(value) {
|
|
49
|
+
if (value === undefined) {
|
|
50
|
+
return "progress_then_plain_final";
|
|
51
|
+
}
|
|
52
|
+
if (isResponseModeConfig(value)) {
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
throw new Error('Invalid `responseMode`: expected "progress_then_plain_final" or "final_card_only".');
|
|
56
|
+
}
|
|
45
57
|
class ChannelQueue {
|
|
46
58
|
constructor() {
|
|
47
59
|
this.queue = [];
|
|
@@ -121,6 +133,8 @@ export class DingTalkBot {
|
|
|
121
133
|
...config,
|
|
122
134
|
busyMessageDefault: normalizeBusyMessageDefault(config.busyMessageDefault),
|
|
123
135
|
progressDisplay: normalizeProgressDisplay(config.progressDisplay),
|
|
136
|
+
responseMode: normalizeResponseMode(config.responseMode),
|
|
137
|
+
cardAutoLayout: config.cardAutoLayout ?? true,
|
|
124
138
|
};
|
|
125
139
|
}
|
|
126
140
|
get busyMessageDefault() {
|
|
@@ -129,6 +143,9 @@ export class DingTalkBot {
|
|
|
129
143
|
get progressDisplay() {
|
|
130
144
|
return normalizeProgressDisplay(this.config.progressDisplay);
|
|
131
145
|
}
|
|
146
|
+
get responseMode() {
|
|
147
|
+
return normalizeResponseMode(this.config.responseMode);
|
|
148
|
+
}
|
|
132
149
|
/**
|
|
133
150
|
* Mark an ID as processed. Returns true if this is a new ID, false if already seen.
|
|
134
151
|
* Maintains a FIFO buffer of at most 200 entries.
|
|
@@ -665,7 +682,11 @@ export class DingTalkBot {
|
|
|
665
682
|
const body = {
|
|
666
683
|
cardTemplateId: this.config.cardTemplateId,
|
|
667
684
|
outTrackId: instanceId,
|
|
668
|
-
cardData: {
|
|
685
|
+
cardData: {
|
|
686
|
+
cardParamMap: {
|
|
687
|
+
autoLayout: String(this.config.cardAutoLayout ?? true),
|
|
688
|
+
},
|
|
689
|
+
},
|
|
669
690
|
callbackType: "STREAM",
|
|
670
691
|
imGroupOpenSpaceModel: { supportForward: true },
|
|
671
692
|
imRobotOpenSpaceModel: { supportForward: true },
|
package/dist/subagents/tool.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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 } from "typebox";
|
|
3
4
|
import type { MemoryCandidateStore } from "../memory/candidates.js";
|
|
4
5
|
import type { Executor } from "../sandbox.js";
|
|
5
6
|
import type { SecurityConfig } from "../security/types.js";
|
|
@@ -7,21 +8,21 @@ import type { PipiclawMemoryRecallSettings } from "../settings.js";
|
|
|
7
8
|
import type { UsageTotals } from "../shared/types.js";
|
|
8
9
|
import type { PipiclawWebToolsConfig } from "../tools/config.js";
|
|
9
10
|
import { type ResolvedSubAgentConfig, type SubAgentDiscoveryResult } from "./discovery.js";
|
|
10
|
-
declare const subagentSchema:
|
|
11
|
-
label:
|
|
12
|
-
agent:
|
|
13
|
-
name:
|
|
14
|
-
task:
|
|
15
|
-
systemPrompt:
|
|
16
|
-
tools:
|
|
17
|
-
model:
|
|
18
|
-
maxTurns:
|
|
19
|
-
maxToolCalls:
|
|
20
|
-
maxWallTimeSec:
|
|
21
|
-
bashTimeoutSec:
|
|
22
|
-
contextMode:
|
|
23
|
-
memory:
|
|
24
|
-
paths:
|
|
11
|
+
declare const subagentSchema: Type.TObject<{
|
|
12
|
+
label: Type.TString;
|
|
13
|
+
agent: Type.TOptional<Type.TString>;
|
|
14
|
+
name: Type.TOptional<Type.TString>;
|
|
15
|
+
task: Type.TString;
|
|
16
|
+
systemPrompt: Type.TOptional<Type.TString>;
|
|
17
|
+
tools: Type.TOptional<Type.TArray<Type.TString>>;
|
|
18
|
+
model: Type.TOptional<Type.TString>;
|
|
19
|
+
maxTurns: Type.TOptional<Type.TNumber>;
|
|
20
|
+
maxToolCalls: Type.TOptional<Type.TNumber>;
|
|
21
|
+
maxWallTimeSec: Type.TOptional<Type.TNumber>;
|
|
22
|
+
bashTimeoutSec: Type.TOptional<Type.TNumber>;
|
|
23
|
+
contextMode: Type.TOptional<Type.TString>;
|
|
24
|
+
memory: Type.TOptional<Type.TString>;
|
|
25
|
+
paths: Type.TOptional<Type.TArray<Type.TString>>;
|
|
25
26
|
}>;
|
|
26
27
|
export interface SubAgentToolDetails {
|
|
27
28
|
kind: "subagent";
|
package/dist/subagents/tool.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Agent } from "@mariozechner/pi-agent-core";
|
|
2
2
|
import { convertToLlm } from "@mariozechner/pi-coding-agent";
|
|
3
|
-
import { Type } from "
|
|
3
|
+
import { Type } from "typebox";
|
|
4
4
|
import { readChannelSession } from "../memory/files.js";
|
|
5
5
|
import { recallRelevantMemory } from "../memory/recall.js";
|
|
6
6
|
import { formatModelReference } from "../models/utils.js";
|
package/dist/tools/attach.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
2
3
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
3
|
-
declare const attachSchema:
|
|
4
|
-
label:
|
|
5
|
-
path:
|
|
6
|
-
title:
|
|
4
|
+
declare const attachSchema: Type.TObject<{
|
|
5
|
+
label: Type.TString;
|
|
6
|
+
path: Type.TString;
|
|
7
|
+
title: Type.TOptional<Type.TString>;
|
|
7
8
|
}>;
|
|
8
9
|
export type UploadFunction = (filePath: string, title?: string) => Promise<void>;
|
|
9
10
|
export interface AttachToolOptions {
|
package/dist/tools/attach.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import { basename, resolve as resolvePath } from "path";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
3
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
4
|
import { logSecurityEvent } from "../security/logger.js";
|
|
5
5
|
import { guardPath } from "../security/path-guard.js";
|
package/dist/tools/bash.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
2
3
|
import type { Executor } from "../sandbox.js";
|
|
3
4
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
4
|
-
declare const bashSchema:
|
|
5
|
-
label:
|
|
6
|
-
command:
|
|
7
|
-
timeout:
|
|
5
|
+
declare const bashSchema: Type.TObject<{
|
|
6
|
+
label: Type.TString;
|
|
7
|
+
command: Type.TString;
|
|
8
|
+
timeout: Type.TOptional<Type.TNumber>;
|
|
8
9
|
}>;
|
|
9
10
|
export interface BashToolOptions {
|
|
10
11
|
defaultTimeoutSeconds?: number;
|
package/dist/tools/bash.js
CHANGED
|
@@ -2,7 +2,7 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { createWriteStream } from "node:fs";
|
|
3
3
|
import { tmpdir } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
|
-
import { Type } from "
|
|
5
|
+
import { Type } from "typebox";
|
|
6
6
|
import { guardCommand } from "../security/command-guard.js";
|
|
7
7
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
8
8
|
import { logSecurityEvent } from "../security/logger.js";
|
package/dist/tools/edit.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
2
3
|
import type { Executor } from "../sandbox.js";
|
|
3
4
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
4
|
-
declare const editSchema:
|
|
5
|
-
label:
|
|
6
|
-
path:
|
|
7
|
-
oldText:
|
|
8
|
-
newText:
|
|
5
|
+
declare const editSchema: Type.TObject<{
|
|
6
|
+
label: Type.TString;
|
|
7
|
+
path: Type.TString;
|
|
8
|
+
oldText: Type.TString;
|
|
9
|
+
newText: Type.TString;
|
|
9
10
|
}>;
|
|
10
11
|
export interface EditToolOptions {
|
|
11
12
|
securityConfig?: SecurityConfig;
|
package/dist/tools/edit.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import * as Diff from "diff";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
3
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
4
|
import { logSecurityEvent } from "../security/logger.js";
|
|
5
5
|
import { guardPath } from "../security/path-guard.js";
|
package/dist/tools/read.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
2
3
|
import type { Executor } from "../sandbox.js";
|
|
3
4
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
4
|
-
declare const readSchema:
|
|
5
|
-
label:
|
|
6
|
-
path:
|
|
7
|
-
offset:
|
|
8
|
-
limit:
|
|
5
|
+
declare const readSchema: Type.TObject<{
|
|
6
|
+
label: Type.TString;
|
|
7
|
+
path: Type.TString;
|
|
8
|
+
offset: Type.TOptional<Type.TNumber>;
|
|
9
|
+
limit: Type.TOptional<Type.TNumber>;
|
|
9
10
|
}>;
|
|
10
11
|
export interface ReadToolOptions {
|
|
11
12
|
securityConfig?: SecurityConfig;
|
package/dist/tools/read.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
1
|
import { extname } from "path";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
3
|
import { DEFAULT_SECURITY_CONFIG } from "../security/config.js";
|
|
4
4
|
import { logSecurityEvent } from "../security/logger.js";
|
|
5
5
|
import { guardPath } from "../security/path-guard.js";
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
2
|
import type { Api, Model } from "@mariozechner/pi-ai";
|
|
3
|
+
import { Type } from "typebox";
|
|
3
4
|
import type { PipiclawSessionSearchSettings } from "../settings.js";
|
|
4
|
-
declare const sessionSearchSchema:
|
|
5
|
-
label:
|
|
6
|
-
query:
|
|
7
|
-
limit:
|
|
8
|
-
roleFilter:
|
|
5
|
+
declare const sessionSearchSchema: Type.TObject<{
|
|
6
|
+
label: Type.TString;
|
|
7
|
+
query: Type.TOptional<Type.TString>;
|
|
8
|
+
limit: Type.TOptional<Type.TNumber>;
|
|
9
|
+
roleFilter: Type.TOptional<Type.TArray<Type.TString>>;
|
|
9
10
|
}>;
|
|
10
11
|
export interface SessionSearchToolOptions {
|
|
11
12
|
channelDir: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type } from "
|
|
1
|
+
import { Type } from "typebox";
|
|
2
2
|
import { searchChannelSessions } from "../memory/session-search.js";
|
|
3
3
|
const sessionSearchSchema = Type.Object({
|
|
4
4
|
label: Type.String({ description: "Brief description of what you're searching for and why (shown to user)" }),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
declare const skillListSchema: Type.TObject<{
|
|
4
|
+
label: Type.TString;
|
|
4
5
|
}>;
|
|
5
6
|
export interface WorkspaceSkillSummary {
|
|
6
7
|
name: string;
|
package/dist/tools/skill-list.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readdir, readFile, stat } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { Type } from "
|
|
3
|
+
import { Type } from "typebox";
|
|
4
4
|
import { validateSkillFrontmatter, validateSkillName } from "./skill-security.js";
|
|
5
5
|
const skillListSchema = Type.Object({
|
|
6
6
|
label: Type.String({ description: "Brief description of why you're listing workspace skills (shown to user)" }),
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
declare const skillManageSchema: Type.TObject<{
|
|
4
|
+
label: Type.TString;
|
|
5
|
+
action: Type.TString;
|
|
6
|
+
name: Type.TString;
|
|
7
|
+
content: Type.TOptional<Type.TString>;
|
|
8
|
+
filePath: Type.TOptional<Type.TString>;
|
|
9
|
+
find: Type.TOptional<Type.TString>;
|
|
10
|
+
replace: Type.TOptional<Type.TString>;
|
|
10
11
|
}>;
|
|
11
12
|
export type SkillManageAction = "create" | "patch" | "write_file";
|
|
12
13
|
export interface SkillManageResult {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { Type } from "
|
|
4
|
+
import { Type } from "typebox";
|
|
5
5
|
import { createAtomicTempPath, writeFileAtomically } from "../shared/atomic-file.js";
|
|
6
6
|
import { resolveSkillPath, resolveSkillSupportingFile, scanSkillContent, validateSkillMarkdown, } from "./skill-security.js";
|
|
7
7
|
const skillManageSchema = Type.Object({
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
declare const skillViewSchema: Type.TObject<{
|
|
4
|
+
label: Type.TString;
|
|
5
|
+
name: Type.TString;
|
|
6
|
+
filePath: Type.TOptional<Type.TString>;
|
|
6
7
|
}>;
|
|
7
8
|
export interface SkillViewToolOptions {
|
|
8
9
|
workspaceDir: string;
|
package/dist/tools/skill-view.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { Type } from "
|
|
3
|
+
import { Type } from "typebox";
|
|
4
4
|
import { resolveSkillPath, resolveSkillSupportingFile } from "./skill-security.js";
|
|
5
5
|
const skillViewSchema = Type.Object({
|
|
6
6
|
label: Type.String({ description: "Brief description of why you're viewing this skill (shown to user)" }),
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
2
3
|
import type { SecurityConfig } from "../security/types.js";
|
|
3
4
|
import type { PipiclawWebToolsConfig } from "./config.js";
|
|
4
|
-
declare const webFetchSchema:
|
|
5
|
-
label:
|
|
6
|
-
url:
|
|
7
|
-
extractMode:
|
|
8
|
-
maxChars:
|
|
5
|
+
declare const webFetchSchema: Type.TObject<{
|
|
6
|
+
label: Type.TString;
|
|
7
|
+
url: Type.TString;
|
|
8
|
+
extractMode: Type.TOptional<Type.TUnion<[Type.TLiteral<"markdown">, Type.TLiteral<"text">]>>;
|
|
9
|
+
maxChars: Type.TOptional<Type.TNumber>;
|
|
9
10
|
}>;
|
|
10
11
|
export interface WebFetchToolOptions {
|
|
11
12
|
webConfig: PipiclawWebToolsConfig;
|
package/dist/tools/web-fetch.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
2
3
|
import type { SecurityConfig } from "../security/types.js";
|
|
3
4
|
import type { PipiclawWebToolsConfig } from "./config.js";
|
|
4
|
-
declare const webSearchSchema:
|
|
5
|
-
label:
|
|
6
|
-
query:
|
|
7
|
-
count:
|
|
5
|
+
declare const webSearchSchema: Type.TObject<{
|
|
6
|
+
label: Type.TString;
|
|
7
|
+
query: Type.TString;
|
|
8
|
+
count: Type.TOptional<Type.TNumber>;
|
|
8
9
|
}>;
|
|
9
10
|
export interface WebSearchToolOptions {
|
|
10
11
|
webConfig: PipiclawWebToolsConfig;
|
package/dist/tools/web-search.js
CHANGED
package/dist/tools/write.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { AgentTool } from "@mariozechner/pi-agent-core";
|
|
2
|
+
import { Type } from "typebox";
|
|
2
3
|
import type { Executor } from "../sandbox.js";
|
|
3
4
|
import type { SecurityConfig, SecurityRuntimeContext } from "../security/types.js";
|
|
4
|
-
declare const writeSchema:
|
|
5
|
-
label:
|
|
6
|
-
path:
|
|
7
|
-
content:
|
|
5
|
+
declare const writeSchema: Type.TObject<{
|
|
6
|
+
label: Type.TString;
|
|
7
|
+
path: Type.TString;
|
|
8
|
+
content: Type.TString;
|
|
8
9
|
}>;
|
|
9
10
|
export interface WriteToolOptions {
|
|
10
11
|
securityConfig?: SecurityConfig;
|
package/dist/tools/write.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oyasmi/pipiclaw",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7-beta.0",
|
|
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": {
|
|
@@ -33,11 +33,10 @@
|
|
|
33
33
|
"prepublishOnly": "npm run clean && npm run build && npm run check"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@mariozechner/pi-agent-core": "^0.
|
|
37
|
-
"@mariozechner/pi-ai": "^0.
|
|
38
|
-
"@mariozechner/pi-coding-agent": "^0.
|
|
36
|
+
"@mariozechner/pi-agent-core": "^0.70.2",
|
|
37
|
+
"@mariozechner/pi-ai": "^0.70.2",
|
|
38
|
+
"@mariozechner/pi-coding-agent": "^0.70.2",
|
|
39
39
|
"@mozilla/readability": "^0.6.0",
|
|
40
|
-
"@sinclair/typebox": "^0.34.0",
|
|
41
40
|
"axios": "^1.7.0",
|
|
42
41
|
"croner": "^9.1.0",
|
|
43
42
|
"diff": "^8.0.2",
|
|
@@ -46,7 +45,8 @@
|
|
|
46
45
|
"https-proxy-agent": "^7.0.6",
|
|
47
46
|
"jsdom": "^26.1.0",
|
|
48
47
|
"proxy-from-env": "^1.1.0",
|
|
49
|
-
"socks-proxy-agent": "^8.0.5"
|
|
48
|
+
"socks-proxy-agent": "^8.0.5",
|
|
49
|
+
"typebox": "^1.1.34"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@biomejs/biome": "2.3.5",
|