@swarmclawai/swarmclaw 0.7.7 → 0.8.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/README.md +12 -14
- package/next.config.ts +13 -2
- package/package.json +4 -2
- package/src/app/api/agents/[id]/thread/route.ts +9 -0
- package/src/app/api/agents/route.ts +4 -0
- package/src/app/api/agents/thread-route.test.ts +133 -0
- package/src/app/api/approvals/route.test.ts +148 -0
- package/src/app/api/canvas/[sessionId]/route.ts +3 -1
- package/src/app/api/chatrooms/[id]/chat/route.ts +4 -2
- package/src/app/api/chats/[id]/devserver/route.ts +48 -7
- package/src/app/api/chats/[id]/messages/route.ts +42 -18
- package/src/app/api/chats/[id]/route.ts +1 -1
- package/src/app/api/chats/[id]/stop/route.ts +5 -4
- package/src/app/api/chats/route.ts +23 -2
- package/src/app/api/clawhub/install/route.ts +28 -8
- package/src/app/api/connectors/[id]/route.ts +46 -3
- package/src/app/api/connectors/route.ts +12 -8
- package/src/app/api/external-agents/route.test.ts +165 -0
- package/src/app/api/gateways/[id]/health/route.ts +27 -12
- package/src/app/api/gateways/[id]/route.ts +2 -0
- package/src/app/api/gateways/health-route.test.ts +135 -0
- package/src/app/api/gateways/route.ts +2 -0
- package/src/app/api/mcp-servers/route.test.ts +130 -0
- package/src/app/api/openclaw/deploy/route.ts +38 -5
- package/src/app/api/plugins/install/route.ts +46 -6
- package/src/app/api/plugins/marketplace/route.ts +48 -15
- package/src/app/api/preview-server/route.ts +26 -11
- package/src/app/api/projects/[id]/route.ts +6 -2
- package/src/app/api/projects/route.ts +4 -3
- package/src/app/api/schedules/[id]/run/route.ts +4 -0
- package/src/app/api/schedules/route.test.ts +86 -0
- package/src/app/api/schedules/route.ts +6 -1
- package/src/app/api/secrets/[id]/route.ts +1 -0
- package/src/app/api/secrets/route.ts +2 -1
- package/src/app/api/settings/route.ts +2 -0
- package/src/app/api/setup/check-provider/route.test.ts +19 -0
- package/src/app/api/setup/check-provider/route.ts +40 -10
- package/src/app/api/skills/[id]/route.ts +12 -0
- package/src/app/api/skills/import/route.ts +14 -12
- package/src/app/api/skills/route.ts +13 -1
- package/src/app/api/tasks/[id]/route.ts +10 -1
- package/src/app/api/tasks/import/github/route.test.ts +65 -0
- package/src/app/api/tasks/import/github/route.ts +337 -0
- package/src/app/api/wallets/[id]/approve/route.ts +17 -3
- package/src/app/api/wallets/[id]/route.ts +79 -33
- package/src/app/api/wallets/[id]/send/route.ts +19 -33
- package/src/app/api/wallets/route.ts +78 -61
- package/src/app/api/webhooks/[id]/route.ts +33 -6
- package/src/app/api/webhooks/route.test.ts +272 -0
- package/src/cli/index.js +1 -0
- package/src/cli/spec.js +1 -0
- package/src/components/agents/agent-card.tsx +9 -2
- package/src/components/agents/agent-chat-list.tsx +18 -2
- package/src/components/agents/agent-list.tsx +1 -0
- package/src/components/agents/agent-sheet.tsx +257 -38
- package/src/components/agents/inspector-panel.tsx +41 -0
- package/src/components/canvas/canvas-panel.tsx +236 -65
- package/src/components/chat/chat-area.tsx +36 -19
- package/src/components/chat/chat-card.tsx +36 -13
- package/src/components/chat/chat-header.tsx +48 -16
- package/src/components/chat/chat-list.tsx +28 -4
- package/src/components/chat/checkpoint-timeline.tsx +50 -34
- package/src/components/chat/delegation-banner.test.ts +14 -1
- package/src/components/chat/delegation-banner.tsx +1 -1
- package/src/components/chat/message-bubble.tsx +208 -145
- package/src/components/chat/message-list.tsx +48 -19
- package/src/components/chatrooms/chatroom-message.tsx +2 -2
- package/src/components/chatrooms/chatroom-sheet.tsx +16 -2
- package/src/components/connectors/connector-health.tsx +1 -1
- package/src/components/connectors/connector-list.tsx +7 -2
- package/src/components/connectors/connector-sheet.tsx +337 -148
- package/src/components/gateways/gateway-sheet.tsx +2 -2
- package/src/components/layout/app-layout.tsx +40 -23
- package/src/components/mcp-servers/mcp-server-list.tsx +26 -5
- package/src/components/mcp-servers/mcp-server-sheet.tsx +19 -2
- package/src/components/openclaw/openclaw-deploy-panel.tsx +269 -21
- package/src/components/plugins/plugin-list.tsx +45 -9
- package/src/components/plugins/plugin-sheet.tsx +55 -7
- package/src/components/projects/project-detail.tsx +217 -0
- package/src/components/projects/project-sheet.tsx +176 -4
- package/src/components/providers/provider-list.tsx +2 -1
- package/src/components/providers/provider-sheet.tsx +21 -2
- package/src/components/schedules/schedule-card.tsx +25 -1
- package/src/components/schedules/schedule-sheet.tsx +44 -2
- package/src/components/secrets/secret-sheet.tsx +21 -2
- package/src/components/shared/agent-switch-dialog.tsx +12 -1
- package/src/components/shared/bottom-sheet.tsx +13 -3
- package/src/components/shared/command-palette.tsx +8 -1
- package/src/components/shared/confirm-dialog.tsx +19 -4
- package/src/components/shared/connector-platform-icon.test.ts +28 -0
- package/src/components/shared/connector-platform-icon.tsx +39 -6
- package/src/components/shared/settings/plugin-manager.tsx +29 -6
- package/src/components/shared/settings/section-capability-policy.tsx +45 -3
- package/src/components/shared/settings/section-voice.tsx +11 -3
- package/src/components/skills/skill-list.tsx +25 -0
- package/src/components/skills/skill-sheet.tsx +84 -12
- package/src/components/tasks/approvals-panel.tsx +289 -34
- package/src/components/tasks/task-board.tsx +410 -25
- package/src/components/tasks/task-card.tsx +66 -8
- package/src/components/tasks/task-sheet.tsx +16 -4
- package/src/components/ui/dialog.tsx +2 -2
- package/src/components/wallets/wallet-approval-dialog.tsx +4 -2
- package/src/components/wallets/wallet-panel.tsx +435 -90
- package/src/components/wallets/wallet-section.tsx +198 -48
- package/src/components/webhooks/webhook-sheet.tsx +22 -2
- package/src/lib/approval-display.ts +20 -0
- package/src/lib/canvas-content.ts +198 -0
- package/src/lib/chat-artifact-summary.ts +165 -0
- package/src/lib/chat-display.test.ts +91 -0
- package/src/lib/chat-display.ts +58 -0
- package/src/lib/chat-streaming-state.test.ts +47 -1
- package/src/lib/chat-streaming-state.ts +42 -0
- package/src/lib/ollama-model.ts +10 -0
- package/src/lib/openclaw-endpoint.test.ts +8 -0
- package/src/lib/openclaw-endpoint.ts +6 -1
- package/src/lib/plugin-install-cors.ts +46 -0
- package/src/lib/plugin-sources.test.ts +43 -0
- package/src/lib/plugin-sources.ts +77 -0
- package/src/lib/providers/ollama.ts +16 -6
- package/src/lib/providers/openclaw.test.ts +54 -0
- package/src/lib/providers/openclaw.ts +127 -11
- package/src/lib/schedule-dedupe-advanced.test.ts +1335 -0
- package/src/lib/schedule-dedupe.test.ts +66 -1
- package/src/lib/schedule-dedupe.ts +169 -12
- package/src/lib/schedule-origin.test.ts +20 -0
- package/src/lib/schedule-origin.ts +15 -0
- package/src/lib/server/__fixtures__/fake-mcp-stdio-server.mjs +27 -0
- package/src/lib/server/agent-availability.ts +16 -0
- package/src/lib/server/agent-runtime-config.ts +12 -4
- package/src/lib/server/agent-thread-session.test.ts +51 -0
- package/src/lib/server/agent-thread-session.ts +7 -0
- package/src/lib/server/approval-match.ts +205 -0
- package/src/lib/server/approvals-auto-approve.test.ts +538 -1
- package/src/lib/server/approvals.ts +214 -1
- package/src/lib/server/assistant-control.test.ts +29 -0
- package/src/lib/server/assistant-control.ts +23 -0
- package/src/lib/server/build-llm.test.ts +79 -0
- package/src/lib/server/build-llm.ts +14 -4
- package/src/lib/server/canvas-content.test.ts +32 -0
- package/src/lib/server/canvas-content.ts +6 -0
- package/src/lib/server/capability-router.test.ts +33 -0
- package/src/lib/server/capability-router.ts +80 -19
- package/src/lib/server/chat-execution-advanced.test.ts +651 -0
- package/src/lib/server/chat-execution-disabled.test.ts +94 -0
- package/src/lib/server/chat-execution-tool-events.test.ts +157 -0
- package/src/lib/server/chat-execution.ts +378 -73
- package/src/lib/server/clawhub-client.test.ts +14 -8
- package/src/lib/server/connectors/manager-reconnect.test.ts +47 -0
- package/src/lib/server/connectors/manager.test.ts +1147 -0
- package/src/lib/server/connectors/manager.ts +461 -137
- package/src/lib/server/connectors/pairing.ts +26 -5
- package/src/lib/server/connectors/types.ts +2 -0
- package/src/lib/server/connectors/whatsapp.test.ts +134 -0
- package/src/lib/server/connectors/whatsapp.ts +271 -47
- package/src/lib/server/context-manager.ts +6 -1
- package/src/lib/server/daemon-state.ts +84 -47
- package/src/lib/server/data-dir.test.ts +37 -0
- package/src/lib/server/data-dir.ts +20 -1
- package/src/lib/server/delegation-jobs-advanced.test.ts +513 -0
- package/src/lib/server/devserver-launch.test.ts +60 -0
- package/src/lib/server/devserver-launch.ts +85 -0
- package/src/lib/server/elevenlabs.test.ts +247 -1
- package/src/lib/server/elevenlabs.ts +147 -43
- package/src/lib/server/ethereum.ts +590 -0
- package/src/lib/server/eval/agent-regression-advanced.test.ts +302 -0
- package/src/lib/server/eval/agent-regression.test.ts +18 -1
- package/src/lib/server/eval/agent-regression.ts +383 -11
- package/src/lib/server/evm-swap.ts +475 -0
- package/src/lib/server/execution-log.ts +1 -0
- package/src/lib/server/heartbeat-service-timer.test.ts +173 -0
- package/src/lib/server/heartbeat-service.ts +20 -11
- package/src/lib/server/heartbeat-wake.test.ts +112 -0
- package/src/lib/server/heartbeat-wake.ts +338 -57
- package/src/lib/server/main-agent-loop-advanced.test.ts +538 -0
- package/src/lib/server/main-agent-loop.test.ts +260 -0
- package/src/lib/server/main-agent-loop.ts +559 -14
- package/src/lib/server/mcp-client.test.ts +16 -0
- package/src/lib/server/mcp-client.ts +25 -0
- package/src/lib/server/memory-integration.test.ts +719 -0
- package/src/lib/server/memory-policy.test.ts +43 -0
- package/src/lib/server/memory-policy.ts +132 -0
- package/src/lib/server/memory-tiers.test.ts +60 -0
- package/src/lib/server/memory-tiers.ts +16 -0
- package/src/lib/server/ollama-runtime.ts +58 -0
- package/src/lib/server/openclaw-deploy.test.ts +109 -1
- package/src/lib/server/openclaw-deploy.ts +557 -81
- package/src/lib/server/openclaw-gateway.test.ts +131 -0
- package/src/lib/server/openclaw-gateway.ts +10 -4
- package/src/lib/server/openclaw-health.test.ts +35 -0
- package/src/lib/server/openclaw-health.ts +215 -47
- package/src/lib/server/orchestrator-lg.ts +3 -2
- package/src/lib/server/orchestrator.ts +2 -0
- package/src/lib/server/plugins-advanced.test.ts +351 -0
- package/src/lib/server/plugins.ts +211 -6
- package/src/lib/server/project-context.ts +162 -0
- package/src/lib/server/project-utils.ts +150 -0
- package/src/lib/server/queue-advanced.test.ts +528 -0
- package/src/lib/server/queue-followups.test.ts +409 -2
- package/src/lib/server/queue-reconcile.test.ts +128 -0
- package/src/lib/server/queue.ts +527 -68
- package/src/lib/server/scheduler.ts +29 -1
- package/src/lib/server/session-note.test.ts +36 -0
- package/src/lib/server/session-note.ts +42 -0
- package/src/lib/server/session-run-manager.ts +83 -4
- package/src/lib/server/session-tools/canvas.ts +14 -12
- package/src/lib/server/session-tools/connector-inputs.test.ts +37 -0
- package/src/lib/server/session-tools/connector.test.ts +138 -0
- package/src/lib/server/session-tools/connector.ts +366 -54
- package/src/lib/server/session-tools/context.ts +17 -3
- package/src/lib/server/session-tools/crud.ts +484 -84
- package/src/lib/server/session-tools/delegate-fallback.test.ts +103 -0
- package/src/lib/server/session-tools/delegate-resume.test.ts +50 -0
- package/src/lib/server/session-tools/delegate.ts +102 -10
- package/src/lib/server/session-tools/discovery-approvals.test.ts +142 -0
- package/src/lib/server/session-tools/discovery.ts +80 -12
- package/src/lib/server/session-tools/file-normalize.test.ts +36 -0
- package/src/lib/server/session-tools/file.ts +43 -4
- package/src/lib/server/session-tools/human-loop.ts +35 -5
- package/src/lib/server/session-tools/index.ts +44 -9
- package/src/lib/server/session-tools/manage-connectors.test.ts +139 -0
- package/src/lib/server/session-tools/manage-schedules-advanced.test.ts +564 -0
- package/src/lib/server/session-tools/manage-schedules.test.ts +283 -0
- package/src/lib/server/session-tools/manage-tasks-advanced.test.ts +852 -0
- package/src/lib/server/session-tools/manage-tasks.test.ts +114 -0
- package/src/lib/server/session-tools/memory.test.ts +93 -0
- package/src/lib/server/session-tools/memory.ts +554 -75
- package/src/lib/server/session-tools/normalize-tool-args.ts +1 -1
- package/src/lib/server/session-tools/platform-access.test.ts +58 -0
- package/src/lib/server/session-tools/platform.ts +60 -19
- package/src/lib/server/session-tools/plugin-creator.ts +57 -1
- package/src/lib/server/session-tools/primitive-tools.test.ts +6 -0
- package/src/lib/server/session-tools/schedule.ts +6 -1
- package/src/lib/server/session-tools/shell-normalize.test.ts +25 -1
- package/src/lib/server/session-tools/shell.ts +22 -3
- package/src/lib/server/session-tools/wallet-tool.test.ts +254 -0
- package/src/lib/server/session-tools/wallet.ts +1374 -139
- package/src/lib/server/session-tools/web-inputs.test.ts +178 -0
- package/src/lib/server/session-tools/web.ts +621 -70
- package/src/lib/server/skill-discovery.ts +128 -0
- package/src/lib/server/skill-eligibility.test.ts +84 -0
- package/src/lib/server/skill-eligibility.ts +95 -0
- package/src/lib/server/skill-prompt-budget.test.ts +102 -0
- package/src/lib/server/skill-prompt-budget.ts +125 -0
- package/src/lib/server/skills-normalize.test.ts +54 -0
- package/src/lib/server/skills-normalize.ts +372 -26
- package/src/lib/server/solana.ts +214 -29
- package/src/lib/server/storage.ts +65 -36
- package/src/lib/server/stream-agent-chat.test.ts +437 -2
- package/src/lib/server/stream-agent-chat.ts +957 -79
- package/src/lib/server/system-events.ts +1 -1
- package/src/lib/server/tool-aliases.ts +2 -0
- package/src/lib/server/tool-capability-policy-advanced.test.ts +502 -0
- package/src/lib/server/tool-capability-policy.test.ts +24 -0
- package/src/lib/server/tool-capability-policy.ts +29 -1
- package/src/lib/server/tool-loop-detection.test.ts +105 -0
- package/src/lib/server/tool-loop-detection.ts +260 -0
- package/src/lib/server/tool-planning.test.ts +44 -0
- package/src/lib/server/tool-planning.ts +271 -0
- package/src/lib/server/wallet-execution.test.ts +198 -0
- package/src/lib/server/wallet-portfolio.test.ts +98 -0
- package/src/lib/server/wallet-portfolio.ts +724 -0
- package/src/lib/server/wallet-service.test.ts +57 -0
- package/src/lib/server/wallet-service.ts +213 -0
- package/src/lib/server/watch-jobs-advanced.test.ts +594 -0
- package/src/lib/server/watch-jobs.ts +17 -2
- package/src/lib/server/workspace-context.ts +111 -0
- package/src/lib/skill-save-payload.test.ts +39 -0
- package/src/lib/skill-save-payload.ts +37 -0
- package/src/lib/tasks.ts +28 -0
- package/src/lib/tool-definitions.ts +2 -1
- package/src/lib/tool-event-summary.test.ts +30 -0
- package/src/lib/tool-event-summary.ts +37 -0
- package/src/lib/validation/schemas.ts +1 -0
- package/src/lib/wallet-transactions.test.ts +75 -0
- package/src/lib/wallet-transactions.ts +43 -0
- package/src/lib/wallet.test.ts +17 -0
- package/src/lib/wallet.ts +183 -0
- package/src/proxy.test.ts +31 -0
- package/src/proxy.ts +34 -2
- package/src/stores/use-chat-store.ts +15 -1
- package/src/types/index.ts +249 -14
|
@@ -91,6 +91,83 @@ describe('manage_schedules tool', () => {
|
|
|
91
91
|
assert.equal(typeof output.schedule.nextRunAt, 'number')
|
|
92
92
|
})
|
|
93
93
|
|
|
94
|
+
it('stores the current connector recipient on new schedules created from a connector session', () => {
|
|
95
|
+
const output = runWithTempDataDir(`
|
|
96
|
+
const storageMod = await import('./src/lib/server/storage.ts')
|
|
97
|
+
const crudMod = await import('./src/lib/server/session-tools/crud.ts')
|
|
98
|
+
const storage = storageMod.default || storageMod
|
|
99
|
+
const crud = crudMod.default || crudMod
|
|
100
|
+
|
|
101
|
+
const now = Date.now()
|
|
102
|
+
storage.saveAgents({
|
|
103
|
+
default: {
|
|
104
|
+
id: 'default',
|
|
105
|
+
name: 'Molly',
|
|
106
|
+
description: '',
|
|
107
|
+
systemPrompt: '',
|
|
108
|
+
provider: 'openai',
|
|
109
|
+
model: 'gpt-test',
|
|
110
|
+
createdAt: now,
|
|
111
|
+
updatedAt: now,
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
storage.saveSessions({
|
|
115
|
+
'session-wa': {
|
|
116
|
+
id: 'session-wa',
|
|
117
|
+
name: 'connector:whatsapp:gran',
|
|
118
|
+
cwd: process.env.WORKSPACE_DIR,
|
|
119
|
+
user: 'connector',
|
|
120
|
+
provider: 'openai',
|
|
121
|
+
model: 'gpt-test',
|
|
122
|
+
credentialId: null,
|
|
123
|
+
apiEndpoint: null,
|
|
124
|
+
claudeSessionId: null,
|
|
125
|
+
codexThreadId: null,
|
|
126
|
+
opencodeSessionId: null,
|
|
127
|
+
delegateResumeIds: { claudeCode: null, codex: null, opencode: null, gemini: null },
|
|
128
|
+
messages: [],
|
|
129
|
+
createdAt: now,
|
|
130
|
+
lastActiveAt: now,
|
|
131
|
+
sessionType: 'human',
|
|
132
|
+
agentId: 'default',
|
|
133
|
+
plugins: [],
|
|
134
|
+
connectorContext: {
|
|
135
|
+
connectorId: 'conn-wa',
|
|
136
|
+
platform: 'whatsapp',
|
|
137
|
+
channelId: '447700900123@s.whatsapp.net',
|
|
138
|
+
senderId: '447700900123@s.whatsapp.net',
|
|
139
|
+
senderName: 'Wayde',
|
|
140
|
+
threadId: 'thread-7',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
})
|
|
144
|
+
|
|
145
|
+
const tools = crud.buildCrudTools({
|
|
146
|
+
cwd: process.env.WORKSPACE_DIR,
|
|
147
|
+
ctx: { sessionId: 'session-wa', agentId: 'default', platformAssignScope: 'self' },
|
|
148
|
+
hasPlugin: (name) => name === 'manage_schedules',
|
|
149
|
+
})
|
|
150
|
+
const tool = tools.find((entry) => entry.name === 'manage_schedules')
|
|
151
|
+
await tool.invoke({
|
|
152
|
+
action: 'create',
|
|
153
|
+
data: JSON.stringify({
|
|
154
|
+
name: 'Birthday Reminder',
|
|
155
|
+
scheduleType: 'once',
|
|
156
|
+
runAt: now + 60_000,
|
|
157
|
+
taskPrompt: 'Wish me a happy birthday tomorrow.',
|
|
158
|
+
}),
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
const schedule = Object.values(storage.loadSchedules())[0]
|
|
162
|
+
console.log(JSON.stringify({ schedule }))
|
|
163
|
+
`)
|
|
164
|
+
|
|
165
|
+
assert.equal(output.schedule.followupConnectorId, 'conn-wa')
|
|
166
|
+
assert.equal(output.schedule.followupChannelId, '447700900123@s.whatsapp.net')
|
|
167
|
+
assert.equal(output.schedule.followupThreadId, 'thread-7')
|
|
168
|
+
assert.equal(output.schedule.followupSenderName, 'Wayde')
|
|
169
|
+
})
|
|
170
|
+
|
|
94
171
|
it('rejects schedules whose referenced script path does not exist', () => {
|
|
95
172
|
const output = runWithTempDataDir(`
|
|
96
173
|
const storageMod = await import('./src/lib/server/storage.ts')
|
|
@@ -134,4 +211,210 @@ describe('manage_schedules tool', () => {
|
|
|
134
211
|
|
|
135
212
|
assert.match(String(output.raw), /schedule path not found: weather_workspace\/missing\.py/i)
|
|
136
213
|
})
|
|
214
|
+
|
|
215
|
+
it('reuses a same-session recurring reminder instead of creating a near-duplicate', () => {
|
|
216
|
+
const output = runWithTempDataDir(`
|
|
217
|
+
const storageMod = await import('./src/lib/server/storage.ts')
|
|
218
|
+
const crudMod = await import('./src/lib/server/session-tools/crud.ts')
|
|
219
|
+
const storage = storageMod.default || storageMod
|
|
220
|
+
const crud = crudMod.default || crudMod
|
|
221
|
+
|
|
222
|
+
const now = Date.now()
|
|
223
|
+
storage.saveAgents({
|
|
224
|
+
default: {
|
|
225
|
+
id: 'default',
|
|
226
|
+
name: 'Molly',
|
|
227
|
+
description: '',
|
|
228
|
+
systemPrompt: '',
|
|
229
|
+
provider: 'openai',
|
|
230
|
+
model: 'gpt-test',
|
|
231
|
+
createdAt: now,
|
|
232
|
+
updatedAt: now,
|
|
233
|
+
},
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
const tools = crud.buildCrudTools({
|
|
237
|
+
cwd: process.env.WORKSPACE_DIR,
|
|
238
|
+
ctx: { sessionId: 'session-reminder', agentId: 'default', platformAssignScope: 'self' },
|
|
239
|
+
hasPlugin: (name) => name === 'manage_schedules',
|
|
240
|
+
})
|
|
241
|
+
const tool = tools.find((entry) => entry.name === 'manage_schedules')
|
|
242
|
+
await tool.invoke({
|
|
243
|
+
action: 'create',
|
|
244
|
+
data: JSON.stringify({
|
|
245
|
+
name: 'Daily Iran Update',
|
|
246
|
+
agentId: 'default',
|
|
247
|
+
taskPrompt: 'Daily check for updates on US-Iran tensions',
|
|
248
|
+
scheduleType: 'cron',
|
|
249
|
+
cron: '0 9 * * *',
|
|
250
|
+
}),
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
const raw = await tool.invoke({
|
|
254
|
+
action: 'create',
|
|
255
|
+
data: JSON.stringify({
|
|
256
|
+
name: 'Iran Reminder',
|
|
257
|
+
agentId: 'default',
|
|
258
|
+
taskPrompt: 'Periodic update check for US-Iran tensions',
|
|
259
|
+
scheduleType: 'interval',
|
|
260
|
+
intervalMs: 86400000,
|
|
261
|
+
}),
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
console.log(JSON.stringify({
|
|
265
|
+
raw,
|
|
266
|
+
schedules: Object.values(storage.loadSchedules()),
|
|
267
|
+
}))
|
|
268
|
+
`)
|
|
269
|
+
|
|
270
|
+
const parsed = JSON.parse(String(output.raw))
|
|
271
|
+
assert.equal(parsed.deduplicated, true)
|
|
272
|
+
assert.equal(output.schedules.length, 1)
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
it('pauses matching duplicate schedules together when an agent stops a reminder', () => {
|
|
276
|
+
const output = runWithTempDataDir(`
|
|
277
|
+
const storageMod = await import('./src/lib/server/storage.ts')
|
|
278
|
+
const crudMod = await import('./src/lib/server/session-tools/crud.ts')
|
|
279
|
+
const storage = storageMod.default || storageMod
|
|
280
|
+
const crud = crudMod.default || crudMod
|
|
281
|
+
|
|
282
|
+
const now = Date.now()
|
|
283
|
+
storage.saveAgents({
|
|
284
|
+
default: {
|
|
285
|
+
id: 'default',
|
|
286
|
+
name: 'Molly',
|
|
287
|
+
description: '',
|
|
288
|
+
systemPrompt: '',
|
|
289
|
+
provider: 'openai',
|
|
290
|
+
model: 'gpt-test',
|
|
291
|
+
createdAt: now,
|
|
292
|
+
updatedAt: now,
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
storage.saveSchedules({
|
|
297
|
+
one: {
|
|
298
|
+
id: 'one',
|
|
299
|
+
name: 'Iran Update',
|
|
300
|
+
agentId: 'default',
|
|
301
|
+
taskPrompt: 'Daily check for updates on US-Iran tensions',
|
|
302
|
+
scheduleType: 'cron',
|
|
303
|
+
cron: '0 9 * * *',
|
|
304
|
+
status: 'active',
|
|
305
|
+
createdByAgentId: 'default',
|
|
306
|
+
createdInSessionId: 'session-reminder',
|
|
307
|
+
createdAt: now,
|
|
308
|
+
updatedAt: now,
|
|
309
|
+
},
|
|
310
|
+
two: {
|
|
311
|
+
id: 'two',
|
|
312
|
+
name: 'Iran Reminder',
|
|
313
|
+
agentId: 'default',
|
|
314
|
+
taskPrompt: 'Periodic update check for US-Iran tensions',
|
|
315
|
+
scheduleType: 'interval',
|
|
316
|
+
intervalMs: 86400000,
|
|
317
|
+
status: 'active',
|
|
318
|
+
createdByAgentId: 'default',
|
|
319
|
+
createdInSessionId: 'session-reminder',
|
|
320
|
+
createdAt: now + 1,
|
|
321
|
+
updatedAt: now + 1,
|
|
322
|
+
},
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
const tools = crud.buildCrudTools({
|
|
326
|
+
cwd: process.env.WORKSPACE_DIR,
|
|
327
|
+
ctx: { sessionId: 'session-reminder', agentId: 'default', platformAssignScope: 'self' },
|
|
328
|
+
hasPlugin: (name) => name === 'manage_schedules',
|
|
329
|
+
})
|
|
330
|
+
const tool = tools.find((entry) => entry.name === 'manage_schedules')
|
|
331
|
+
const raw = await tool.invoke({
|
|
332
|
+
action: 'update',
|
|
333
|
+
id: 'one',
|
|
334
|
+
data: JSON.stringify({ status: 'paused' }),
|
|
335
|
+
})
|
|
336
|
+
|
|
337
|
+
console.log(JSON.stringify({
|
|
338
|
+
raw,
|
|
339
|
+
schedules: storage.loadSchedules(),
|
|
340
|
+
}))
|
|
341
|
+
`)
|
|
342
|
+
|
|
343
|
+
const parsed = JSON.parse(String(output.raw))
|
|
344
|
+
assert.deepEqual(new Set(parsed.affectedScheduleIds), new Set(['one', 'two']))
|
|
345
|
+
assert.equal(output.schedules.one.status, 'paused')
|
|
346
|
+
assert.equal(output.schedules.two.status, 'paused')
|
|
347
|
+
})
|
|
348
|
+
|
|
349
|
+
it('deletes matching duplicate schedules together when an agent removes a reminder cluster', () => {
|
|
350
|
+
const output = runWithTempDataDir(`
|
|
351
|
+
const storageMod = await import('./src/lib/server/storage.ts')
|
|
352
|
+
const crudMod = await import('./src/lib/server/session-tools/crud.ts')
|
|
353
|
+
const storage = storageMod.default || storageMod
|
|
354
|
+
const crud = crudMod.default || crudMod
|
|
355
|
+
|
|
356
|
+
const now = Date.now()
|
|
357
|
+
storage.saveAgents({
|
|
358
|
+
default: {
|
|
359
|
+
id: 'default',
|
|
360
|
+
name: 'Molly',
|
|
361
|
+
description: '',
|
|
362
|
+
systemPrompt: '',
|
|
363
|
+
provider: 'openai',
|
|
364
|
+
model: 'gpt-test',
|
|
365
|
+
createdAt: now,
|
|
366
|
+
updatedAt: now,
|
|
367
|
+
},
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
storage.saveSchedules({
|
|
371
|
+
one: {
|
|
372
|
+
id: 'one',
|
|
373
|
+
name: 'Iran Update',
|
|
374
|
+
agentId: 'default',
|
|
375
|
+
taskPrompt: 'Daily check for updates on US-Iran tensions',
|
|
376
|
+
scheduleType: 'cron',
|
|
377
|
+
cron: '0 9 * * *',
|
|
378
|
+
status: 'active',
|
|
379
|
+
createdByAgentId: 'default',
|
|
380
|
+
createdInSessionId: 'session-reminder',
|
|
381
|
+
createdAt: now,
|
|
382
|
+
updatedAt: now,
|
|
383
|
+
},
|
|
384
|
+
two: {
|
|
385
|
+
id: 'two',
|
|
386
|
+
name: 'Iran Reminder',
|
|
387
|
+
agentId: 'default',
|
|
388
|
+
taskPrompt: 'Periodic update check for US-Iran tensions',
|
|
389
|
+
scheduleType: 'interval',
|
|
390
|
+
intervalMs: 86400000,
|
|
391
|
+
status: 'active',
|
|
392
|
+
createdByAgentId: 'default',
|
|
393
|
+
createdInSessionId: 'session-reminder',
|
|
394
|
+
createdAt: now + 1,
|
|
395
|
+
updatedAt: now + 1,
|
|
396
|
+
},
|
|
397
|
+
})
|
|
398
|
+
|
|
399
|
+
const tools = crud.buildCrudTools({
|
|
400
|
+
cwd: process.env.WORKSPACE_DIR,
|
|
401
|
+
ctx: { sessionId: 'session-reminder', agentId: 'default', platformAssignScope: 'self' },
|
|
402
|
+
hasPlugin: (name) => name === 'manage_schedules',
|
|
403
|
+
})
|
|
404
|
+
const tool = tools.find((entry) => entry.name === 'manage_schedules')
|
|
405
|
+
const raw = await tool.invoke({
|
|
406
|
+
action: 'delete',
|
|
407
|
+
id: 'one',
|
|
408
|
+
})
|
|
409
|
+
|
|
410
|
+
console.log(JSON.stringify({
|
|
411
|
+
raw,
|
|
412
|
+
schedules: storage.loadSchedules(),
|
|
413
|
+
}))
|
|
414
|
+
`)
|
|
415
|
+
|
|
416
|
+
const parsed = JSON.parse(String(output.raw))
|
|
417
|
+
assert.deepEqual(new Set(parsed.deletedIds), new Set(['one', 'two']))
|
|
418
|
+
assert.deepEqual(output.schedules, {})
|
|
419
|
+
})
|
|
137
420
|
})
|