foliko 1.0.53 → 1.0.55
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/.claude/settings.local.json +141 -131
- package/CLAUDE.md +106 -0
- package/Dockerfile +2 -2
- package/cli/src/index.js +6 -3
- package/cli/src/ui/chat-ui.js +1 -1
- package/examples/ambient-example.js +196 -0
- package/package.json +1 -1
- package/plugins/ambient-agent-plugin.js +1134 -0
- package/plugins/default-plugins.js +38 -32
- package/plugins/email.js +484 -25
- package/plugins/feishu-plugin.js +2 -0
- package/plugins/file-system-plugin.js +57 -1
- package/plugins/python-executor-plugin.js +1 -1
- package/plugins/python-plugin-loader.js +2 -2
- package/plugins/subagent-plugin.js +25 -25
- package/plugins/telegram-plugin.js +3 -0
- package/plugins/weixin-plugin.js +2 -0
- package/src/capabilities/skill-manager.js +230 -2
- package/src/core/agent.js +19 -14
- package/src/core/plugin-manager.js +2 -2
- package/src/core/provider.js +0 -1
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient Agent Example
|
|
3
|
+
* Demonstrates how to use the Ambient Agent plugin for autonomous monitoring and actions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { Framework } = require('../src/core/framework')
|
|
7
|
+
|
|
8
|
+
async function main() {
|
|
9
|
+
console.log('=== Ambient Agent Example ===\n')
|
|
10
|
+
|
|
11
|
+
// Create framework
|
|
12
|
+
const framework = new Framework({
|
|
13
|
+
debug: true
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
// Bootstrap with default plugins (including ambient)
|
|
17
|
+
await framework.bootstrap({
|
|
18
|
+
agentDir: './.agent',
|
|
19
|
+
aiConfig: {
|
|
20
|
+
provider: 'deepseek',
|
|
21
|
+
model: 'deepseek-chat',
|
|
22
|
+
apiKey: process.env.DEEPSEEK_API_KEY || 'your-api-key'
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
console.log('\n=== Framework Ready ===\n')
|
|
27
|
+
|
|
28
|
+
// Wait for plugins to start
|
|
29
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
30
|
+
|
|
31
|
+
// Check if ambient plugin is loaded
|
|
32
|
+
const ambientPlugin = framework.pluginManager.get('ambient')
|
|
33
|
+
if (!ambientPlugin) {
|
|
34
|
+
console.error('Ambient plugin not loaded!')
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log('=== Ambient Plugin Tools Available ===')
|
|
39
|
+
const tools = framework.getTools()
|
|
40
|
+
const ambientTools = tools.filter(t => t.name.startsWith('ambient_'))
|
|
41
|
+
console.log('Ambient tools:', ambientTools.map(t => t.name).join(', '))
|
|
42
|
+
|
|
43
|
+
console.log('\n=== Example 1: Create a Goal ===')
|
|
44
|
+
// Use ambient_goals to create a simple goal
|
|
45
|
+
const createResult = await framework.executeTool('ambient_goals', {
|
|
46
|
+
action: 'create',
|
|
47
|
+
title: 'Monitor System Health',
|
|
48
|
+
description: 'Periodically check system information and alert on issues',
|
|
49
|
+
priority: 8,
|
|
50
|
+
actions: [
|
|
51
|
+
{ id: 'check_1', type: 'tool', name: 'system_info', args: {} }
|
|
52
|
+
]
|
|
53
|
+
})
|
|
54
|
+
console.log('Create goal result:', JSON.stringify(createResult, null, 2))
|
|
55
|
+
|
|
56
|
+
console.log('\n=== Example 2: Create a Thinking Goal ===')
|
|
57
|
+
// Create a goal that triggers LLM thinking
|
|
58
|
+
const thinkGoal = await framework.executeTool('ambient_goals', {
|
|
59
|
+
action: 'create',
|
|
60
|
+
title: 'Periodic Reflection',
|
|
61
|
+
description: 'Regularly reflect on system state and suggest improvements',
|
|
62
|
+
priority: 5,
|
|
63
|
+
actions: [
|
|
64
|
+
{ id: 'reflect_1', type: 'think', topic: 'System state review', mode: 'reflect', depth: 3 }
|
|
65
|
+
]
|
|
66
|
+
})
|
|
67
|
+
console.log('Create thinking goal result:', JSON.stringify(thinkGoal, null, 2))
|
|
68
|
+
|
|
69
|
+
console.log('\n=== Example 3: List All Goals ===')
|
|
70
|
+
const listResult = await framework.executeTool('ambient_goals', {
|
|
71
|
+
action: 'list'
|
|
72
|
+
})
|
|
73
|
+
console.log('Goals list:', JSON.stringify(listResult, null, 2))
|
|
74
|
+
|
|
75
|
+
console.log('\n=== Example 4: Get Ambient Status ===')
|
|
76
|
+
const statusResult = await framework.executeTool('ambient_status', {})
|
|
77
|
+
console.log('Status:', JSON.stringify(statusResult, null, 2))
|
|
78
|
+
|
|
79
|
+
console.log('\n=== Example 5: Store a Memory ===')
|
|
80
|
+
const storeResult = await framework.executeTool('ambient_remember', {
|
|
81
|
+
action: 'store',
|
|
82
|
+
content: 'Important: System check showed high CPU usage at 14:30',
|
|
83
|
+
key: 'cpu_alert_1'
|
|
84
|
+
})
|
|
85
|
+
console.log('Store memory result:', JSON.stringify(storeResult, null, 2))
|
|
86
|
+
|
|
87
|
+
console.log('\n=== Example 6: Retrieve Memories ===')
|
|
88
|
+
const retrieveResult = await framework.executeTool('ambient_remember', {
|
|
89
|
+
action: 'retrieve',
|
|
90
|
+
limit: 5
|
|
91
|
+
})
|
|
92
|
+
console.log('Retrieve memories result:', JSON.stringify(retrieveResult, null, 2))
|
|
93
|
+
|
|
94
|
+
console.log('\n=== Example 7: Search Memories ===')
|
|
95
|
+
const searchResult = await framework.executeTool('ambient_remember', {
|
|
96
|
+
action: 'search',
|
|
97
|
+
query: 'CPU'
|
|
98
|
+
})
|
|
99
|
+
console.log('Search memories result:', JSON.stringify(searchResult, null, 2))
|
|
100
|
+
|
|
101
|
+
console.log('\n=== Example 8: Trigger Thinking ===')
|
|
102
|
+
const thinkResult = await framework.executeTool('ambient_think', {
|
|
103
|
+
mode: 'brainstorm',
|
|
104
|
+
topic: 'What improvements could be made to the current system?',
|
|
105
|
+
depth: 3
|
|
106
|
+
})
|
|
107
|
+
console.log('Think result:', JSON.stringify(thinkResult, null, 2))
|
|
108
|
+
|
|
109
|
+
console.log('\n=== Example 9: Control Loop ===')
|
|
110
|
+
console.log('Pausing loop...')
|
|
111
|
+
const pauseResult = await framework.executeTool('ambient_control', {
|
|
112
|
+
action: 'pause'
|
|
113
|
+
})
|
|
114
|
+
console.log('Pause result:', JSON.stringify(pauseResult, null, 2))
|
|
115
|
+
|
|
116
|
+
await new Promise(resolve => setTimeout(resolve, 1000))
|
|
117
|
+
|
|
118
|
+
console.log('Resuming loop...')
|
|
119
|
+
const resumeResult = await framework.executeTool('ambient_control', {
|
|
120
|
+
action: 'resume'
|
|
121
|
+
})
|
|
122
|
+
console.log('Resume result:', JSON.stringify(resumeResult, null, 2))
|
|
123
|
+
|
|
124
|
+
console.log('\n=== Example 10: Adjust Loop Settings ===')
|
|
125
|
+
const adjustResult = await framework.executeTool('ambient_control', {
|
|
126
|
+
action: 'adjust',
|
|
127
|
+
tickInterval: 10000, // 10 seconds
|
|
128
|
+
cooldownPeriod: 5000 // 5 seconds
|
|
129
|
+
})
|
|
130
|
+
console.log('Adjust result:', JSON.stringify(adjustResult, null, 2))
|
|
131
|
+
|
|
132
|
+
console.log('\n=== Example 11: Get Final Status ===')
|
|
133
|
+
const finalStatus = await framework.executeTool('ambient_status', {})
|
|
134
|
+
console.log('Final status:', JSON.stringify(finalStatus, null, 2))
|
|
135
|
+
|
|
136
|
+
console.log('\n=== Example 12: Activate a Pending Goal ===')
|
|
137
|
+
// First create a pending goal (without auto-activation conditions)
|
|
138
|
+
const newGoal = await framework.executeTool('ambient_goals', {
|
|
139
|
+
action: 'create',
|
|
140
|
+
title: 'Inactive Test Goal',
|
|
141
|
+
description: 'A goal that starts inactive',
|
|
142
|
+
priority: 3,
|
|
143
|
+
actions: []
|
|
144
|
+
})
|
|
145
|
+
console.log('Created inactive goal:', newGoal.goal ? newGoal.goal.id : 'N/A')
|
|
146
|
+
|
|
147
|
+
if (newGoal.goal) {
|
|
148
|
+
console.log('Activating goal...')
|
|
149
|
+
const activateResult = await framework.executeTool('ambient_goals', {
|
|
150
|
+
action: 'activate',
|
|
151
|
+
goalId: newGoal.goal.id
|
|
152
|
+
})
|
|
153
|
+
console.log('Activate result:', JSON.stringify(activateResult, null, 2))
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
console.log('\n=== Example 13: Update a Goal ===')
|
|
157
|
+
const goals = await framework.executeTool('ambient_goals', { action: 'list' })
|
|
158
|
+
if (goals.goals && goals.goals.length > 0) {
|
|
159
|
+
const goalToUpdate = goals.goals[0]
|
|
160
|
+
console.log(`Updating goal ${goalToUpdate.id}...`)
|
|
161
|
+
const updateResult = await framework.executeTool('ambient_goals', {
|
|
162
|
+
action: 'update',
|
|
163
|
+
goalId: goalToUpdate.id,
|
|
164
|
+
priority: 10
|
|
165
|
+
})
|
|
166
|
+
console.log('Update result:', JSON.stringify(updateResult, null, 2))
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
console.log('\n=== Example 14: Delete a Goal ===')
|
|
170
|
+
const deleteGoal = await framework.executeTool('ambient_goals', {
|
|
171
|
+
action: 'create',
|
|
172
|
+
title: 'Goal to Delete',
|
|
173
|
+
description: 'This will be deleted',
|
|
174
|
+
priority: 1
|
|
175
|
+
})
|
|
176
|
+
if (deleteGoal.goal) {
|
|
177
|
+
console.log(`Created goal to delete: ${deleteGoal.goal.id}`)
|
|
178
|
+
const deleteResult = await framework.executeTool('ambient_goals', {
|
|
179
|
+
action: 'delete',
|
|
180
|
+
goalId: deleteGoal.goal.id
|
|
181
|
+
})
|
|
182
|
+
console.log('Delete result:', JSON.stringify(deleteResult, null, 2))
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
console.log('\n=== All Examples Completed ===')
|
|
186
|
+
console.log('Check .agent/data/ambient/ for persisted data')
|
|
187
|
+
|
|
188
|
+
// Cleanup
|
|
189
|
+
console.log('\nShutting down...')
|
|
190
|
+
await framework.destroy()
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
main().catch(err => {
|
|
194
|
+
console.error('Example error:', err)
|
|
195
|
+
process.exit(1)
|
|
196
|
+
})
|