dipclaw 0.1.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/config.example.json +26 -0
- package/dist/agent/agent.d.ts +85 -0
- package/dist/agent/agent.js +725 -0
- package/dist/agent/agent.js.map +1 -0
- package/dist/agent/memory.d.ts +17 -0
- package/dist/agent/memory.js +92 -0
- package/dist/agent/memory.js.map +1 -0
- package/dist/agent/scheduler.d.ts +35 -0
- package/dist/agent/scheduler.js +154 -0
- package/dist/agent/scheduler.js.map +1 -0
- package/dist/agent/skill-generator.d.ts +37 -0
- package/dist/agent/skill-generator.js +263 -0
- package/dist/agent/skill-generator.js.map +1 -0
- package/dist/agent/task-runner.d.ts +31 -0
- package/dist/agent/task-runner.js +242 -0
- package/dist/agent/task-runner.js.map +1 -0
- package/dist/browser/actions.d.ts +28 -0
- package/dist/browser/actions.js +212 -0
- package/dist/browser/actions.js.map +1 -0
- package/dist/browser/manager.d.ts +17 -0
- package/dist/browser/manager.js +249 -0
- package/dist/browser/manager.js.map +1 -0
- package/dist/browser/script-runner.d.ts +49 -0
- package/dist/browser/script-runner.js +137 -0
- package/dist/browser/script-runner.js.map +1 -0
- package/dist/browser/snapshot.d.ts +15 -0
- package/dist/browser/snapshot.js +38 -0
- package/dist/browser/snapshot.js.map +1 -0
- package/dist/config/types.d.ts +62 -0
- package/dist/config/types.js +47 -0
- package/dist/config/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +219 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/client.d.ts +3 -0
- package/dist/llm/client.js +503 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/tools.d.ts +5 -0
- package/dist/llm/tools.js +94 -0
- package/dist/llm/tools.js.map +1 -0
- package/dist/llm/types.d.ts +49 -0
- package/dist/llm/types.js +2 -0
- package/dist/llm/types.js.map +1 -0
- package/dist/logging/logger.d.ts +17 -0
- package/dist/logging/logger.js +46 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/telegram/bot.d.ts +15 -0
- package/dist/telegram/bot.js +279 -0
- package/dist/telegram/bot.js.map +1 -0
- package/dist/tui/tui.d.ts +12 -0
- package/dist/tui/tui.js +176 -0
- package/dist/tui/tui.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-agent",
|
|
3
|
+
"workspace": "./workspace",
|
|
4
|
+
"llm": {
|
|
5
|
+
"protocol": "openai",
|
|
6
|
+
"baseUrl": "https://api.openai.com",
|
|
7
|
+
"apiKey": "${OPENAI_API_KEY}",
|
|
8
|
+
"model": "gpt-4o"
|
|
9
|
+
},
|
|
10
|
+
"telegram": {
|
|
11
|
+
"botToken": "${TELEGRAM_BOT_TOKEN}",
|
|
12
|
+
"allowedUsers": [123456789]
|
|
13
|
+
},
|
|
14
|
+
"maxIterations": 90,
|
|
15
|
+
"debug": false,
|
|
16
|
+
"browser": {
|
|
17
|
+
"headless": false,
|
|
18
|
+
"proxy": {
|
|
19
|
+
"protocol": "socks5",
|
|
20
|
+
"host": "127.0.0.1",
|
|
21
|
+
"port": 1080,
|
|
22
|
+
"username": "${PROXY_USER}",
|
|
23
|
+
"password": "${PROXY_PASS}"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { DipclawConfig } from "../config/types.js";
|
|
2
|
+
export declare class Agent {
|
|
3
|
+
private config;
|
|
4
|
+
private llmClient;
|
|
5
|
+
private browser;
|
|
6
|
+
private taskRunner;
|
|
7
|
+
private scheduler;
|
|
8
|
+
private memory;
|
|
9
|
+
private skillGenerator;
|
|
10
|
+
private tui;
|
|
11
|
+
private telegramBot;
|
|
12
|
+
private chatHistory;
|
|
13
|
+
private conversationSummary;
|
|
14
|
+
private summarizationCooldown;
|
|
15
|
+
private browserLock;
|
|
16
|
+
constructor(config: DipclawConfig);
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
stop(): Promise<void>;
|
|
19
|
+
getName(): string;
|
|
20
|
+
getWorkspace(): string;
|
|
21
|
+
/** Clear chat history and start a new session */
|
|
22
|
+
clearChat(): void;
|
|
23
|
+
/** Chat with the agent (LLM-driven, with tool use) */
|
|
24
|
+
chat(message: string): Promise<string>;
|
|
25
|
+
private chatInner;
|
|
26
|
+
/**
|
|
27
|
+
* Auto-save a brief memory about a complex chat workflow.
|
|
28
|
+
* Non-blocking — fires and forgets.
|
|
29
|
+
*/
|
|
30
|
+
private autoSaveWorkflowMemory;
|
|
31
|
+
/** Chat with streaming — yields text deltas, handles tool calls internally */
|
|
32
|
+
chatStream(message: string): AsyncIterable<string>;
|
|
33
|
+
private chatStreamInner;
|
|
34
|
+
listTasks(): string;
|
|
35
|
+
addTask(name: string, cron: string, prompt: string): string;
|
|
36
|
+
removeTask(id: string): string;
|
|
37
|
+
toggleTask(id: string, enabled: boolean): string;
|
|
38
|
+
runTaskById(id: string): Promise<string>;
|
|
39
|
+
listSkills(): string;
|
|
40
|
+
generateSkill(logFileName: string): Promise<string>;
|
|
41
|
+
listMemories(): string;
|
|
42
|
+
/**
|
|
43
|
+
* Estimate character count of the chat history (rough proxy for tokens).
|
|
44
|
+
*/
|
|
45
|
+
private estimateHistoryChars;
|
|
46
|
+
/**
|
|
47
|
+
* Compress chat history: try LLM summarization first, fallback to simple trim.
|
|
48
|
+
*/
|
|
49
|
+
private compressHistory;
|
|
50
|
+
/**
|
|
51
|
+
* Summarize old messages via LLM and replace them with a compressed summary.
|
|
52
|
+
*/
|
|
53
|
+
private performSummarization;
|
|
54
|
+
/**
|
|
55
|
+
* Format messages and call LLM to produce a conversation summary.
|
|
56
|
+
*/
|
|
57
|
+
private summarizeMessages;
|
|
58
|
+
/**
|
|
59
|
+
* Format chat messages into readable text for the summarizer.
|
|
60
|
+
* Skips snapshot content (ephemeral page state, too large for summaries).
|
|
61
|
+
*/
|
|
62
|
+
private formatMessagesForSummary;
|
|
63
|
+
/**
|
|
64
|
+
* Simple trim: drop old messages at user-message boundaries to fit budget.
|
|
65
|
+
* Fallback when summarization is unavailable.
|
|
66
|
+
*/
|
|
67
|
+
private simpleTrim;
|
|
68
|
+
/**
|
|
69
|
+
* Build a copy of chatHistory with snapshot results managed:
|
|
70
|
+
* - If the latest user message involves browser activity, keep only the most recent snapshot.
|
|
71
|
+
* - Otherwise, omit all snapshots.
|
|
72
|
+
*/
|
|
73
|
+
private buildMessagesForLlm;
|
|
74
|
+
private executeToolCall;
|
|
75
|
+
private executeBrowserAction;
|
|
76
|
+
private executeMemoryAction;
|
|
77
|
+
private executeSchedulerAction;
|
|
78
|
+
private buildChatSystemPrompt;
|
|
79
|
+
/**
|
|
80
|
+
* Acquire a serialized lock for browser access.
|
|
81
|
+
* All operations that may use the browser (chat, scheduled tasks) must go through this
|
|
82
|
+
* to prevent concurrent browser manipulation.
|
|
83
|
+
*/
|
|
84
|
+
private acquireBrowserLock;
|
|
85
|
+
}
|