openloops 0.3.4 → 0.4.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 +9 -8
- package/dist/clients/llm/llm-client.js +6 -5
- package/dist/clients/llm/llm-client.mjs +6 -5
- package/dist/clients/llm/llm-types.d.ts +3 -0
- package/dist/clients/llm/llm-types.js +15 -0
- package/dist/clients/llm/llm-types.mjs +7 -0
- package/dist/db/index.d.ts +1 -0
- package/dist/db/index.js +3 -1
- package/dist/db/index.mjs +1 -0
- package/dist/db/indexes/automation-runs.d.ts +2 -0
- package/dist/db/indexes/automation-runs.js +33 -0
- package/dist/db/indexes/automation-runs.mjs +10 -0
- package/dist/db/indexes/automations.d.ts +2 -0
- package/dist/db/indexes/{agentic-jobs.js → automations.js} +6 -6
- package/dist/db/indexes/{agentic-jobs.mjs → automations.mjs} +2 -2
- package/dist/db/indexes/index.js +6 -4
- package/dist/db/indexes/index.mjs +6 -4
- package/dist/db/indexes/revoked-tokens.d.ts +2 -0
- package/dist/db/indexes/{agentic-job-runs.js → revoked-tokens.js} +8 -9
- package/dist/db/indexes/revoked-tokens.mjs +8 -0
- package/dist/db/migrations/automations.d.ts +12 -0
- package/dist/db/migrations/automations.js +70 -0
- package/dist/db/migrations/automations.mjs +47 -0
- package/dist/harness/agent-loop.d.ts +2 -0
- package/dist/harness/agent.d.ts +1 -0
- package/dist/harness/agent.js +8 -0
- package/dist/harness/agent.mjs +8 -0
- package/dist/loops/agi/loop.js +2 -1
- package/dist/loops/agi/loop.mjs +2 -1
- package/dist/loops/agi/skills/reasoning-engine.js +3 -2
- package/dist/loops/agi/skills/reasoning-engine.mjs +3 -2
- package/dist/loops/shared/skills/fast-responder.js +2 -2
- package/dist/loops/shared/skills/fast-responder.mjs +2 -2
- package/dist/services/authentication/entities/index.d.ts +1 -0
- package/dist/services/authentication/entities/index.js +22 -0
- package/dist/services/authentication/entities/index.mjs +1 -0
- package/dist/services/authentication/entities/revoked-token.entity.d.ts +17 -0
- package/dist/services/authentication/entities/revoked-token.entity.js +67 -0
- package/dist/services/authentication/entities/revoked-token.entity.mjs +44 -0
- package/dist/services/authentication/index.d.ts +1 -0
- package/dist/services/authentication/index.js +3 -1
- package/dist/services/authentication/index.mjs +1 -0
- package/dist/services/authentication/module.d.ts +4 -0
- package/dist/services/authentication/module.js +16 -2
- package/dist/services/authentication/module.mjs +13 -1
- package/dist/services/authentication/repositories/index.d.ts +1 -0
- package/dist/services/{agentic-jobs → authentication}/repositories/index.js +2 -4
- package/dist/services/authentication/repositories/index.mjs +1 -0
- package/dist/services/authentication/repositories/revoked-token.repository.d.ts +7 -0
- package/dist/services/authentication/repositories/revoked-token.repository.js +55 -0
- package/dist/services/authentication/repositories/revoked-token.repository.mjs +26 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.d.ts +15 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.js +55 -0
- package/dist/services/authentication/use-cases/is-token-revoked.use-case.mjs +26 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.d.ts +14 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.js +65 -0
- package/dist/services/authentication/use-cases/revoke-token.use-case.mjs +36 -0
- package/dist/services/automations/entities/automation-run.entity.d.ts +46 -0
- package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.js → automations/entities/automation-run.entity.js} +22 -14
- package/dist/services/{agentic-jobs/entities/agentic-job-run.entity.mjs → automations/entities/automation-run.entity.mjs} +18 -10
- package/dist/services/automations/entities/automation.entity.d.ts +38 -0
- package/dist/services/{agentic-jobs/entities/agentic-job.entity.js → automations/entities/automation.entity.js} +17 -17
- package/dist/services/{agentic-jobs/entities/agentic-job.entity.mjs → automations/entities/automation.entity.mjs} +13 -13
- package/dist/services/automations/entities/index.d.ts +4 -0
- package/dist/services/{agentic-jobs → automations}/entities/index.js +6 -4
- package/dist/services/automations/entities/index.mjs +4 -0
- package/dist/services/automations/entities/trigger.d.ts +11 -0
- package/dist/services/automations/entities/trigger.js +49 -0
- package/dist/services/automations/entities/trigger.mjs +26 -0
- package/dist/services/automations/index.d.ts +5 -0
- package/dist/services/{agentic-jobs → automations}/index.js +9 -7
- package/dist/services/automations/index.mjs +5 -0
- package/dist/services/automations/module.d.ts +41 -0
- package/dist/services/automations/module.js +167 -0
- package/dist/services/automations/module.mjs +125 -0
- package/dist/services/automations/repositories/automation-run.repository.d.ts +14 -0
- package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.js → automations/repositories/automation-run.repository.js} +23 -11
- package/dist/services/{agentic-jobs/repositories/agentic-job-run.repository.mjs → automations/repositories/automation-run.repository.mjs} +19 -7
- package/dist/services/automations/repositories/automation.repository.d.ts +27 -0
- package/dist/services/{agentic-jobs/repositories/agentic-job.repository.js → automations/repositories/automation.repository.js} +17 -17
- package/dist/services/{agentic-jobs/repositories/agentic-job.repository.mjs → automations/repositories/automation.repository.mjs} +13 -13
- package/dist/services/automations/repositories/index.d.ts +2 -0
- package/dist/services/automations/repositories/index.js +24 -0
- package/dist/services/automations/repositories/index.mjs +2 -0
- package/dist/services/automations/runner/automation-runner.d.ts +49 -0
- package/dist/services/{agentic-jobs/runner/agentic-job-runner.js → automations/runner/automation-runner.js} +55 -45
- package/dist/services/{agentic-jobs/runner/agentic-job-runner.mjs → automations/runner/automation-runner.mjs} +50 -40
- package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.d.ts → automations/use-cases/attach-automation-run-chat.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.js → automations/use-cases/attach-automation-run-chat.use-case.js} +14 -14
- package/dist/services/automations/use-cases/attach-automation-run-chat.use-case.mjs +29 -0
- package/dist/services/automations/use-cases/claim-due-automations.use-case.d.ts +28 -0
- package/dist/services/{agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.js → automations/use-cases/claim-due-automations.use-case.js} +32 -43
- package/dist/services/automations/use-cases/claim-due-automations.use-case.mjs +70 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.d.ts +27 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.js +106 -0
- package/dist/services/automations/use-cases/claim-queued-automation-runs.use-case.mjs +77 -0
- package/dist/services/automations/use-cases/create-automation.use-case.d.ts +14 -0
- package/dist/services/{agentic-jobs/use-cases/create-agentic-job.use-case.js → automations/use-cases/create-automation.use-case.js} +24 -25
- package/dist/services/automations/use-cases/create-automation.use-case.mjs +43 -0
- package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.d.ts → automations/use-cases/delete-automation.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/delete-agentic-job.use-case.js → automations/use-cases/delete-automation.use-case.js} +17 -17
- package/dist/services/automations/use-cases/delete-automation.use-case.mjs +36 -0
- package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.d.ts → automations/use-cases/finish-automation-run.use-case.d.ts} +8 -8
- package/dist/services/{agentic-jobs/use-cases/finish-agentic-job-run.use-case.js → automations/use-cases/finish-automation-run.use-case.js} +20 -20
- package/dist/services/automations/use-cases/finish-automation-run.use-case.mjs +46 -0
- package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.d.ts → automations/use-cases/get-automation-by-id.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/get-agentic-job-by-id.use-case.js → automations/use-cases/get-automation-by-id.use-case.js} +13 -13
- package/dist/services/automations/use-cases/get-automation-by-id.use-case.mjs +26 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.d.ts +17 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.js +59 -0
- package/dist/services/automations/use-cases/issue-automation-event-token.use-case.mjs +30 -0
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.d.ts → automations/use-cases/list-automation-runs-by-automation.use-case.d.ts} +7 -7
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.js → automations/use-cases/list-automation-runs-by-automation.use-case.js} +15 -15
- package/dist/services/automations/use-cases/list-automation-runs-by-automation.use-case.mjs +28 -0
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.d.ts → automations/use-cases/list-automation-runs-by-user.use-case.d.ts} +7 -7
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.js → automations/use-cases/list-automation-runs-by-user.use-case.js} +14 -14
- package/dist/services/{agentic-jobs/use-cases/list-agentic-job-runs-by-user.use-case.mjs → automations/use-cases/list-automation-runs-by-user.use-case.mjs} +11 -11
- package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.d.ts → automations/use-cases/list-automations-by-user.use-case.d.ts} +6 -6
- package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.js → automations/use-cases/list-automations-by-user.use-case.js} +14 -14
- package/dist/services/{agentic-jobs/use-cases/list-agentic-jobs-by-user.use-case.mjs → automations/use-cases/list-automations-by-user.use-case.mjs} +11 -11
- package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.d.ts → automations/use-cases/preview-automation-runs.use-case.d.ts} +1 -1
- package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.js → automations/use-cases/preview-automation-runs.use-case.js} +8 -8
- package/dist/services/{agentic-jobs/use-cases/preview-agentic-job-runs.use-case.mjs → automations/use-cases/preview-automation-runs.use-case.mjs} +4 -4
- package/dist/services/automations/use-cases/receive-automation-event.use-case.d.ts +23 -0
- package/dist/services/automations/use-cases/receive-automation-event.use-case.js +97 -0
- package/dist/services/automations/use-cases/receive-automation-event.use-case.mjs +68 -0
- package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.d.ts → automations/use-cases/renew-automation-lease.use-case.d.ts} +5 -5
- package/dist/services/{agentic-jobs/use-cases/renew-agentic-job-lease.use-case.js → automations/use-cases/renew-automation-lease.use-case.js} +15 -15
- package/dist/services/automations/use-cases/renew-automation-lease.use-case.mjs +29 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.d.ts +16 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.js +65 -0
- package/dist/services/automations/use-cases/revoke-automation-event-token.use-case.mjs +36 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.d.ts +14 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.js +63 -0
- package/dist/services/automations/use-cases/rotate-automation-event-tokens.use-case.mjs +34 -0
- package/dist/services/automations/use-cases/start-automation-run.use-case.d.ts +21 -0
- package/dist/services/{agentic-jobs/use-cases/start-agentic-job-run.use-case.js → automations/use-cases/start-automation-run.use-case.js} +24 -24
- package/dist/services/automations/use-cases/start-automation-run.use-case.mjs +38 -0
- package/dist/services/automations/use-cases/sync-automation-run.use-case.d.ts +20 -0
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.js → automations/use-cases/sync-automation-run.use-case.js} +23 -23
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-run.use-case.mjs → automations/use-cases/sync-automation-run.use-case.mjs} +21 -21
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.d.ts → automations/use-cases/sync-automation-runs.use-case.d.ts} +5 -5
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.js → automations/use-cases/sync-automation-runs.use-case.js} +16 -16
- package/dist/services/{agentic-jobs/use-cases/sync-agentic-job-runs.use-case.mjs → automations/use-cases/sync-automation-runs.use-case.mjs} +13 -13
- package/dist/services/automations/use-cases/update-automation.use-case.d.ts +15 -0
- package/dist/services/{agentic-jobs/use-cases/update-agentic-job.use-case.js → automations/use-cases/update-automation.use-case.js} +27 -27
- package/dist/services/automations/use-cases/update-automation.use-case.mjs +54 -0
- package/dist/services/automations/utils/automation-event-error.d.ts +6 -0
- package/dist/services/automations/utils/automation-event-error.js +37 -0
- package/dist/services/automations/utils/automation-event-error.mjs +14 -0
- package/dist/services/automations/utils/automation-fields.d.ts +14 -0
- package/dist/services/{agentic-jobs/utils/job-fields.js → automations/utils/automation-fields.js} +8 -10
- package/dist/services/{agentic-jobs/utils/job-fields.mjs → automations/utils/automation-fields.mjs} +4 -6
- package/dist/services/automations/utils/event-message.d.ts +1 -0
- package/dist/services/automations/utils/event-message.js +37 -0
- package/dist/services/automations/utils/event-message.mjs +14 -0
- package/dist/services/automations/utils/event-token.d.ts +18 -0
- package/dist/services/automations/utils/event-token.js +78 -0
- package/dist/services/automations/utils/event-token.mjs +43 -0
- package/dist/services/automations/utils/open-run.d.ts +14 -0
- package/dist/services/{agentic-jobs → automations}/utils/open-run.js +10 -8
- package/dist/services/automations/utils/open-run.mjs +26 -0
- package/dist/services/automations/utils/previous-run.d.ts +4 -0
- package/dist/services/automations/utils/previous-run.js +42 -0
- package/dist/services/automations/utils/previous-run.mjs +19 -0
- package/dist/services/{agentic-jobs → automations}/utils/settings.d.ts +1 -0
- package/dist/services/{agentic-jobs → automations}/utils/settings.js +6 -2
- package/dist/services/automations/utils/settings.mjs +13 -0
- package/dist/services/chats/entities/chat-settings.entity.d.ts +5 -1
- package/dist/services/chats/entities/chat-settings.entity.js +10 -3
- package/dist/services/chats/entities/chat-settings.entity.mjs +10 -3
- package/dist/skills/skill.d.ts +2 -1
- package/dist/skills/skill.js +4 -3
- package/dist/skills/skill.mjs +4 -3
- package/docs/README.md +1 -1
- package/docs/agent.md +3 -2
- package/docs/authentication.md +18 -1
- package/docs/automations.md +341 -0
- package/docs/chats.md +1 -1
- package/docs/configuration.md +8 -7
- package/docs/harness.md +1 -1
- package/docs/integration-guide.md +22 -18
- package/docs/llms.txt +1 -1
- package/docs/mcp-servers.md +1 -1
- package/docs/skills.md +1 -1
- package/examples/{agentic-jobs/create-agentic-job.ts → automations/create-automation.ts} +10 -7
- package/examples/automations/create-event-automation.ts +24 -0
- package/examples/{agentic-jobs/list-agentic-job-runs.ts → automations/list-automation-runs.ts} +8 -8
- package/examples/automations/list-automations.ts +25 -0
- package/examples/{agentic-jobs/preview-agentic-job-runs.ts → automations/preview-automation-runs.ts} +2 -2
- package/examples/automations/receive-automation-event.ts +26 -0
- package/examples/automations/revoke-automation-event-token.ts +25 -0
- package/examples/{agentic-jobs/run-agentic-job-now.ts → automations/run-automation-now.ts} +3 -3
- package/examples/{agentic-jobs/run-agentic-job-worker.ts → automations/run-automation-worker.ts} +6 -6
- package/examples/{agentic-jobs/update-agentic-job.ts → automations/update-automation.ts} +10 -10
- package/package.json +14 -13
- package/dist/db/indexes/agentic-job-runs.d.ts +0 -2
- package/dist/db/indexes/agentic-job-runs.mjs +0 -9
- package/dist/db/indexes/agentic-jobs.d.ts +0 -2
- package/dist/services/agentic-jobs/entities/agentic-job-run.entity.d.ts +0 -42
- package/dist/services/agentic-jobs/entities/agentic-job.entity.d.ts +0 -39
- package/dist/services/agentic-jobs/entities/index.d.ts +0 -3
- package/dist/services/agentic-jobs/entities/index.mjs +0 -3
- package/dist/services/agentic-jobs/index.d.ts +0 -4
- package/dist/services/agentic-jobs/index.mjs +0 -4
- package/dist/services/agentic-jobs/module.d.ts +0 -31
- package/dist/services/agentic-jobs/module.js +0 -132
- package/dist/services/agentic-jobs/module.mjs +0 -95
- package/dist/services/agentic-jobs/repositories/agentic-job-run.repository.d.ts +0 -11
- package/dist/services/agentic-jobs/repositories/agentic-job.repository.d.ts +0 -27
- package/dist/services/agentic-jobs/repositories/index.d.ts +0 -2
- package/dist/services/agentic-jobs/repositories/index.mjs +0 -2
- package/dist/services/agentic-jobs/runner/agentic-job-runner.d.ts +0 -48
- package/dist/services/agentic-jobs/use-cases/attach-agentic-job-run-chat.use-case.mjs +0 -29
- package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.d.ts +0 -29
- package/dist/services/agentic-jobs/use-cases/claim-due-agentic-jobs.use-case.mjs +0 -81
- package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.d.ts +0 -14
- package/dist/services/agentic-jobs/use-cases/create-agentic-job.use-case.mjs +0 -44
- package/dist/services/agentic-jobs/use-cases/delete-agentic-job.use-case.mjs +0 -36
- package/dist/services/agentic-jobs/use-cases/finish-agentic-job-run.use-case.mjs +0 -46
- package/dist/services/agentic-jobs/use-cases/get-agentic-job-by-id.use-case.mjs +0 -26
- package/dist/services/agentic-jobs/use-cases/list-agentic-job-runs-by-job.use-case.mjs +0 -28
- package/dist/services/agentic-jobs/use-cases/renew-agentic-job-lease.use-case.mjs +0 -29
- package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.d.ts +0 -21
- package/dist/services/agentic-jobs/use-cases/start-agentic-job-run.use-case.mjs +0 -38
- package/dist/services/agentic-jobs/use-cases/sync-agentic-job-run.use-case.d.ts +0 -20
- package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.d.ts +0 -15
- package/dist/services/agentic-jobs/use-cases/update-agentic-job.use-case.mjs +0 -54
- package/dist/services/agentic-jobs/utils/job-fields.d.ts +0 -14
- package/dist/services/agentic-jobs/utils/open-run.d.ts +0 -12
- package/dist/services/agentic-jobs/utils/open-run.mjs +0 -24
- package/dist/services/agentic-jobs/utils/settings.mjs +0 -10
- package/docs/agentic-jobs.md +0 -217
- package/examples/agentic-jobs/list-agentic-jobs.ts +0 -25
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.d.ts +0 -0
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.js +0 -0
- /package/dist/services/{agentic-jobs → automations}/entities/recurrence.mjs +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.d.ts +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.js +0 -0
- /package/dist/services/{agentic-jobs → automations}/utils/next-run.mjs +0 -0
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ A model alone only chats. The harness is what lets it act, safely, for many user
|
|
|
40
40
|
| **Transmission** | Takes the model to the outside world | Your tools and MCP servers, found on demand and validated before they run. See [tools](docs/tools.md) and [MCP servers](docs/mcp-servers.md) |
|
|
41
41
|
| **Brakes** | Stops the agent when it should stop | Confirmation of destructive tools, approval of MCP servers, input guardrails, timeouts and a budget per task. See [guardrails](docs/guardrails.md) and [the harness](docs/harness.md) |
|
|
42
42
|
| **Logbook** | Remembers and records everything | Chats, tasks, every tool call, traces, and usage and cost per call. See [chats](docs/chats.md) and [usage](docs/usage.md) |
|
|
43
|
-
| **Steering** | Decides how the agent is driven | Interactive and autonomous runs, scheduled
|
|
43
|
+
| **Steering** | Decides how the agent is driven | Interactive and autonomous runs, scheduled automations, stopping a run, and the model per chat and per user. See [the Agent](docs/agent.md), [automations](docs/automations.md) and [configuration](docs/configuration.md) |
|
|
44
44
|
|
|
45
45
|
## Why it is a good harness
|
|
46
46
|
|
|
@@ -56,7 +56,7 @@ Not adjectives, mechanisms that you can read in the code and in the tests:
|
|
|
56
56
|
|
|
57
57
|
## Building a backend with it
|
|
58
58
|
|
|
59
|
-
If you or your coding agent are going to build the backend that uses `openloops`, start with the [integration guide](docs/integration-guide.md). It lists which endpoint calls which use case, what authorization is left to you (the package has no HTTP layer), how to run agents and scheduled
|
|
59
|
+
If you or your coding agent are going to build the backend that uses `openloops`, start with the [integration guide](docs/integration-guide.md). It lists which endpoint calls which use case, what authorization is left to you (the package has no HTTP layer), how to run agents and scheduled automations, and a security checklist. The whole documentation is also shipped inside the package, in `node_modules/openloops/docs`, with an index for tools in [`docs/llms.txt`](docs/llms.txt).
|
|
60
60
|
|
|
61
61
|
To make sure that your coding agent reads it in every session, add this to the `CLAUDE.md` or `AGENTS.md` of your backend:
|
|
62
62
|
|
|
@@ -104,7 +104,7 @@ You know the pattern: before you write a single line of what your agent actually
|
|
|
104
104
|
- **Safe tool execution.** Arguments are validated against the tool's schema, destructive tools wait for the user's confirmation, identical failing calls are blocked, identifiers the model invented are rejected before they reach a real system, and large outputs are kept out of the prompt. LLM calls retry with backoff and wait out rate limits.
|
|
105
105
|
- **Native MCP support with a trust flow.** Connect any MCP server and its tools become regular tools. Each server must be approved by the user before its first tool runs, and a server that changes its tools is reviewed again, so a third party cannot quietly change what your agent does.
|
|
106
106
|
- **Autonomous runs.** The same agent can work without a person in the chat, for scheduled tasks. Whatever needs the user pauses the run in the chat, and the user answers there to continue. See [autonomous mode](docs/agent.md#autonomous-mode).
|
|
107
|
-
- **
|
|
107
|
+
- **Automations.** Tasks that the agent runs by itself, on a schedule (daily, weekly, monthly or once, in the timezone of the user) or when another system sends an event, with signed tokens that can be revoked and a queue per automation. A worker runs what is due, safely across several instances, and keeps a history of every run with its chat. See [automations](docs/automations.md).
|
|
108
108
|
- **Guardrails.** Input guards block messages with card numbers, emails, code or anything you define, before the model sees them. See [guardrails](docs/guardrails.md).
|
|
109
109
|
- **Usage and cost tracking.** Every LLM call is recorded. Get the tokens and cost of a chat or an answer, and per-user statistics by model and by period. See [usage](docs/usage.md).
|
|
110
110
|
- **Users and authentication included.** User management and login with tokens, so you don't need a parallel system just to have an identity to hand the `Agent`.
|
|
@@ -219,8 +219,9 @@ LLM_FALLBACK_PROVIDER=
|
|
|
219
219
|
LLM_FALLBACK_MODEL=
|
|
220
220
|
|
|
221
221
|
# Optional, in milliseconds
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
AUTOMATIONS_POLL_INTERVAL_MS=
|
|
223
|
+
AUTOMATIONS_LEASE_MS=
|
|
224
|
+
AUTOMATIONS_MAX_QUEUED_RUNS=
|
|
224
225
|
LLM_CALL_TIMEOUT_MS=
|
|
225
226
|
MCP_TOOL_TIMEOUT_MS=
|
|
226
227
|
|
|
@@ -261,7 +262,7 @@ Neither requires any code changes. They're opt-in purely through environment var
|
|
|
261
262
|
|
|
262
263
|
## More examples
|
|
263
264
|
|
|
264
|
-
Every pattern above, and a lot more, lives as a runnable example in [`examples/`](examples), organized by domain: `run-agent`, `loops`, `tools`, `guardrails`, `
|
|
265
|
+
Every pattern above, and a lot more, lives as a runnable example in [`examples/`](examples), organized by domain: `run-agent`, `loops`, `tools`, `guardrails`, `automations`, `mcps`, `chats`, `usage`, `users`, and `authentication`.
|
|
265
266
|
|
|
266
267
|
## Package structure
|
|
267
268
|
|
|
@@ -275,7 +276,7 @@ Every pattern above, and a lot more, lives as a runnable example in [`examples/`
|
|
|
275
276
|
| `openloops/skills` | `Skill`, for writing LLM-backed reasoning steps inside a loop |
|
|
276
277
|
| `openloops/guardrails` | `Guard` and the ready-made input guards |
|
|
277
278
|
| `openloops/mcps` | MCP server management, connection check and trust decisions |
|
|
278
|
-
| `openloops/
|
|
279
|
+
| `openloops/automations` | Scheduled and event tasks, their runs and the runner that executes them |
|
|
279
280
|
| `openloops/chats` | Chats and their messages: list, read, update, delete |
|
|
280
281
|
| `openloops/users` | User management |
|
|
281
282
|
| `openloops/authentication` | Login and token issuing |
|
|
@@ -295,7 +296,7 @@ Every pattern above, and a lot more, lives as a runnable example in [`examples/`
|
|
|
295
296
|
- [Skills](docs/skills.md)
|
|
296
297
|
- [Guardrails](docs/guardrails.md)
|
|
297
298
|
- [MCP servers](docs/mcp-servers.md)
|
|
298
|
-
- [
|
|
299
|
+
- [Automations](docs/automations.md)
|
|
299
300
|
- [Chats](docs/chats.md)
|
|
300
301
|
- [User management](docs/users.md)
|
|
301
302
|
- [Authentication](docs/authentication.md)
|
|
@@ -45,6 +45,7 @@ const MAX_RETRIES = 4;
|
|
|
45
45
|
const MAX_RATE_LIMIT_WAITS = 2;
|
|
46
46
|
const DEFAULT_CALL_TIMEOUT_MS = 6e4;
|
|
47
47
|
const MAX_TIMEOUT_RETRIES = 2;
|
|
48
|
+
const HIGH_THINKING_TIMEOUT_FACTOR = 2;
|
|
48
49
|
const LANGFUSE_FLUSH_TIMEOUT_MS = 5e3;
|
|
49
50
|
const REQUIRED_TOOL_CHOICE = {
|
|
50
51
|
"anthropic-messages": "any",
|
|
@@ -98,7 +99,7 @@ class LLMClient {
|
|
|
98
99
|
const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
|
|
99
100
|
if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
|
|
100
101
|
const context = (0, import_pi_ai_adapter.toPiContext)({ messages, tools }, model);
|
|
101
|
-
const send = (omitTemperature) => this.withDeadline((signal) => {
|
|
102
|
+
const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
|
|
102
103
|
const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
|
|
103
104
|
const reasoning = thinking && thinking !== "off" ? thinking : void 0;
|
|
104
105
|
return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
|
|
@@ -121,7 +122,7 @@ class LLMClient {
|
|
|
121
122
|
user: (0, import_model_resolution.toModelRef)(currentUser?.preferences?.defaultModel)
|
|
122
123
|
});
|
|
123
124
|
}
|
|
124
|
-
async withDeadline(call) {
|
|
125
|
+
async withDeadline(timeoutMs, call) {
|
|
125
126
|
for (let attempt = 1; attempt <= MAX_TIMEOUT_RETRIES + 1; attempt++) {
|
|
126
127
|
const controller = new AbortController();
|
|
127
128
|
let timer;
|
|
@@ -129,15 +130,15 @@ class LLMClient {
|
|
|
129
130
|
timer = setTimeout(() => {
|
|
130
131
|
controller.abort();
|
|
131
132
|
resolve(void 0);
|
|
132
|
-
},
|
|
133
|
+
}, timeoutMs);
|
|
133
134
|
});
|
|
134
135
|
const pending = call(controller.signal);
|
|
135
136
|
pending.catch(() => void 0);
|
|
136
137
|
const response = await Promise.race([pending, deadline]).finally(() => clearTimeout(timer));
|
|
137
138
|
if (response) return response;
|
|
138
|
-
this.logger.warn({ attempt, timeoutMs
|
|
139
|
+
this.logger.warn({ attempt, timeoutMs }, "[LLM Service] The model did not answer in time");
|
|
139
140
|
}
|
|
140
|
-
throw new import_llm_error.LLMError("LLM_TIMEOUT", `the model did not answer within ${
|
|
141
|
+
throw new import_llm_error.LLMError("LLM_TIMEOUT", `the model did not answer within ${timeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
|
|
141
142
|
}
|
|
142
143
|
async flushLangfuse() {
|
|
143
144
|
if (!this.langfuseEnabled) return;
|
|
@@ -13,6 +13,7 @@ const MAX_RETRIES = 4;
|
|
|
13
13
|
const MAX_RATE_LIMIT_WAITS = 2;
|
|
14
14
|
const DEFAULT_CALL_TIMEOUT_MS = 6e4;
|
|
15
15
|
const MAX_TIMEOUT_RETRIES = 2;
|
|
16
|
+
const HIGH_THINKING_TIMEOUT_FACTOR = 2;
|
|
16
17
|
const LANGFUSE_FLUSH_TIMEOUT_MS = 5e3;
|
|
17
18
|
const REQUIRED_TOOL_CHOICE = {
|
|
18
19
|
"anthropic-messages": "any",
|
|
@@ -66,7 +67,7 @@ class LLMClient {
|
|
|
66
67
|
const resolvedChoice = toolChoice === "required" ? REQUIRED_TOOL_CHOICE[model.api] : toolChoice;
|
|
67
68
|
if (toolChoice === "required" && !resolvedChoice) throw new Error(`[LLM Client] forced tool choice is not supported for api ${model.api}`);
|
|
68
69
|
const context = toPiContext({ messages, tools }, model);
|
|
69
|
-
const send = (omitTemperature) => this.withDeadline((signal) => {
|
|
70
|
+
const send = (omitTemperature) => this.withDeadline(thinking === "high" ? this.callTimeoutMs * HIGH_THINKING_TIMEOUT_FACTOR : this.callTimeoutMs, (signal) => {
|
|
70
71
|
const options = { ...omitTemperature ? {} : { temperature }, maxRetries: MAX_RETRIES, signal, ...sessionId ? { sessionId } : {} };
|
|
71
72
|
const reasoning = thinking && thinking !== "off" ? thinking : void 0;
|
|
72
73
|
return resolvedChoice || thinking ? models.completeSimple(model, context, { ...options, ...resolvedChoice ? { toolChoice: resolvedChoice } : {}, ...reasoning ? { reasoning } : {} }) : models.complete(model, context, options);
|
|
@@ -89,7 +90,7 @@ class LLMClient {
|
|
|
89
90
|
user: toModelRef(currentUser?.preferences?.defaultModel)
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
async withDeadline(call) {
|
|
93
|
+
async withDeadline(timeoutMs, call) {
|
|
93
94
|
for (let attempt = 1; attempt <= MAX_TIMEOUT_RETRIES + 1; attempt++) {
|
|
94
95
|
const controller = new AbortController();
|
|
95
96
|
let timer;
|
|
@@ -97,15 +98,15 @@ class LLMClient {
|
|
|
97
98
|
timer = setTimeout(() => {
|
|
98
99
|
controller.abort();
|
|
99
100
|
resolve(void 0);
|
|
100
|
-
},
|
|
101
|
+
}, timeoutMs);
|
|
101
102
|
});
|
|
102
103
|
const pending = call(controller.signal);
|
|
103
104
|
pending.catch(() => void 0);
|
|
104
105
|
const response = await Promise.race([pending, deadline]).finally(() => clearTimeout(timer));
|
|
105
106
|
if (response) return response;
|
|
106
|
-
this.logger.warn({ attempt, timeoutMs
|
|
107
|
+
this.logger.warn({ attempt, timeoutMs }, "[LLM Service] The model did not answer in time");
|
|
107
108
|
}
|
|
108
|
-
throw new LLMError("LLM_TIMEOUT", `the model did not answer within ${
|
|
109
|
+
throw new LLMError("LLM_TIMEOUT", `the model did not answer within ${timeoutMs} ms in ${MAX_TIMEOUT_RETRIES + 1} attempts`);
|
|
109
110
|
}
|
|
110
111
|
async flushLangfuse() {
|
|
111
112
|
if (!this.langfuseEnabled) return;
|
|
@@ -51,6 +51,9 @@ export interface LLMResponse {
|
|
|
51
51
|
}
|
|
52
52
|
export type LLMToolChoice = 'auto' | 'none' | 'required';
|
|
53
53
|
export type ThinkingEffort = 'off' | 'low' | 'medium' | 'high';
|
|
54
|
+
export declare const SELECTABLE_THINKING_EFFORTS: readonly ["low", "medium", "high"];
|
|
55
|
+
export type SelectableThinkingEffort = typeof SELECTABLE_THINKING_EFFORTS[number];
|
|
56
|
+
export declare const isSelectableThinkingEffort: (value: unknown) => value is SelectableThinkingEffort;
|
|
54
57
|
export interface LLMChatParams {
|
|
55
58
|
origin: string;
|
|
56
59
|
sessionId: string;
|
|
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
6
10
|
var __copyProps = (to, from, except, desc) => {
|
|
7
11
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
12
|
for (let key of __getOwnPropNames(from))
|
|
@@ -13,4 +17,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
17
|
};
|
|
14
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
19
|
var llm_types_exports = {};
|
|
20
|
+
__export(llm_types_exports, {
|
|
21
|
+
SELECTABLE_THINKING_EFFORTS: () => SELECTABLE_THINKING_EFFORTS,
|
|
22
|
+
isSelectableThinkingEffort: () => isSelectableThinkingEffort
|
|
23
|
+
});
|
|
16
24
|
module.exports = __toCommonJS(llm_types_exports);
|
|
25
|
+
const SELECTABLE_THINKING_EFFORTS = ["low", "medium", "high"];
|
|
26
|
+
const isSelectableThinkingEffort = (value) => SELECTABLE_THINKING_EFFORTS.includes(value);
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
SELECTABLE_THINKING_EFFORTS,
|
|
30
|
+
isSelectableThinkingEffort
|
|
31
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "../../chunk-CF3WOMB3.mjs";
|
|
2
|
+
const SELECTABLE_THINKING_EFFORTS = ["low", "medium", "high"];
|
|
3
|
+
const isSelectableThinkingEffort = (value) => SELECTABLE_THINKING_EFFORTS.includes(value);
|
|
4
|
+
export {
|
|
5
|
+
SELECTABLE_THINKING_EFFORTS,
|
|
6
|
+
isSelectableThinkingEffort
|
|
7
|
+
};
|
package/dist/db/index.d.ts
CHANGED
package/dist/db/index.js
CHANGED
|
@@ -16,7 +16,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
16
16
|
var db_exports = {};
|
|
17
17
|
module.exports = __toCommonJS(db_exports);
|
|
18
18
|
__reExport(db_exports, require("./indexes"), module.exports);
|
|
19
|
+
__reExport(db_exports, require("./migrations/automations"), module.exports);
|
|
19
20
|
// Annotate the CommonJS export names for ESM import in node:
|
|
20
21
|
0 && (module.exports = {
|
|
21
|
-
...require("./indexes")
|
|
22
|
+
...require("./indexes"),
|
|
23
|
+
...require("./migrations/automations")
|
|
22
24
|
});
|
package/dist/db/index.mjs
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var automation_runs_exports = {};
|
|
20
|
+
__export(automation_runs_exports, {
|
|
21
|
+
automationRuns: () => automationRuns
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(automation_runs_exports);
|
|
24
|
+
const automationRuns = [
|
|
25
|
+
{ key: { automationId: 1, createdAt: -1 } },
|
|
26
|
+
{ key: { ownerId: 1, createdAt: -1 } },
|
|
27
|
+
{ key: { status: 1, createdAt: 1 } },
|
|
28
|
+
{ key: { automationId: 1, idempotencyKey: 1 }, unique: true, partialFilterExpression: { idempotencyKey: { $exists: true } } }
|
|
29
|
+
];
|
|
30
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
31
|
+
0 && (module.exports = {
|
|
32
|
+
automationRuns
|
|
33
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "../../chunk-CF3WOMB3.mjs";
|
|
2
|
+
const automationRuns = [
|
|
3
|
+
{ key: { automationId: 1, createdAt: -1 } },
|
|
4
|
+
{ key: { ownerId: 1, createdAt: -1 } },
|
|
5
|
+
{ key: { status: 1, createdAt: 1 } },
|
|
6
|
+
{ key: { automationId: 1, idempotencyKey: 1 }, unique: true, partialFilterExpression: { idempotencyKey: { $exists: true } } }
|
|
7
|
+
];
|
|
8
|
+
export {
|
|
9
|
+
automationRuns
|
|
10
|
+
};
|
|
@@ -16,16 +16,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var automations_exports = {};
|
|
20
|
+
__export(automations_exports, {
|
|
21
|
+
automations: () => automations
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
const
|
|
23
|
+
module.exports = __toCommonJS(automations_exports);
|
|
24
|
+
const automations = [
|
|
25
25
|
{ key: { enabled: 1, nextRunAt: 1 } },
|
|
26
26
|
{ key: { ownerId: 1, createdAt: -1 } }
|
|
27
27
|
];
|
|
28
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
29
29
|
0 && (module.exports = {
|
|
30
|
-
|
|
30
|
+
automations
|
|
31
31
|
});
|
package/dist/db/indexes/index.js
CHANGED
|
@@ -29,8 +29,9 @@ var import_agent_actions = require("./agent-actions");
|
|
|
29
29
|
var import_agent_traces = require("./agent-traces");
|
|
30
30
|
var import_workspace_items = require("./workspace-items");
|
|
31
31
|
var import_mcp_servers = require("./mcp-servers");
|
|
32
|
-
var
|
|
33
|
-
var
|
|
32
|
+
var import_automations = require("./automations");
|
|
33
|
+
var import_automation_runs = require("./automation-runs");
|
|
34
|
+
var import_revoked_tokens = require("./revoked-tokens");
|
|
34
35
|
const indexes = {
|
|
35
36
|
llm_calls: import_llm_calls.llmCalls,
|
|
36
37
|
chats: import_chats.chats,
|
|
@@ -39,8 +40,9 @@ const indexes = {
|
|
|
39
40
|
agent_traces: import_agent_traces.agentTraces,
|
|
40
41
|
workspace_items: import_workspace_items.workspaceItems,
|
|
41
42
|
mcp_servers: import_mcp_servers.mcpServers,
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
automations: import_automations.automations,
|
|
44
|
+
automation_runs: import_automation_runs.automationRuns,
|
|
45
|
+
revoked_tokens: import_revoked_tokens.revokedTokens
|
|
44
46
|
};
|
|
45
47
|
async function ensureIndexes(db) {
|
|
46
48
|
const created = {};
|
|
@@ -6,8 +6,9 @@ import { agentActions } from "./agent-actions";
|
|
|
6
6
|
import { agentTraces } from "./agent-traces";
|
|
7
7
|
import { workspaceItems } from "./workspace-items";
|
|
8
8
|
import { mcpServers } from "./mcp-servers";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { automations } from "./automations";
|
|
10
|
+
import { automationRuns } from "./automation-runs";
|
|
11
|
+
import { revokedTokens } from "./revoked-tokens";
|
|
11
12
|
const indexes = {
|
|
12
13
|
llm_calls: llmCalls,
|
|
13
14
|
chats,
|
|
@@ -16,8 +17,9 @@ const indexes = {
|
|
|
16
17
|
agent_traces: agentTraces,
|
|
17
18
|
workspace_items: workspaceItems,
|
|
18
19
|
mcp_servers: mcpServers,
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
automations,
|
|
21
|
+
automation_runs: automationRuns,
|
|
22
|
+
revoked_tokens: revokedTokens
|
|
21
23
|
};
|
|
22
24
|
async function ensureIndexes(db) {
|
|
23
25
|
const created = {};
|
|
@@ -16,17 +16,16 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
21
|
-
|
|
19
|
+
var revoked_tokens_exports = {};
|
|
20
|
+
__export(revoked_tokens_exports, {
|
|
21
|
+
revokedTokens: () => revokedTokens
|
|
22
22
|
});
|
|
23
|
-
module.exports = __toCommonJS(
|
|
24
|
-
const
|
|
25
|
-
{ key: {
|
|
26
|
-
{ key: {
|
|
27
|
-
{ key: { status: 1, createdAt: 1 } }
|
|
23
|
+
module.exports = __toCommonJS(revoked_tokens_exports);
|
|
24
|
+
const revokedTokens = [
|
|
25
|
+
{ key: { jti: 1 }, unique: true },
|
|
26
|
+
{ key: { expiresAt: 1 }, expireAfterSeconds: 0 }
|
|
28
27
|
];
|
|
29
28
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
29
|
0 && (module.exports = {
|
|
31
|
-
|
|
30
|
+
revokedTokens
|
|
32
31
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Db } from 'mongodb';
|
|
2
|
+
export interface AutomationsMigrationOptions {
|
|
3
|
+
dryRun?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface AutomationsMigrationReport {
|
|
6
|
+
dryRun: boolean;
|
|
7
|
+
renamedCollections: string[];
|
|
8
|
+
triggersCreated: number;
|
|
9
|
+
runsUpdated: number;
|
|
10
|
+
droppedIndexes: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function migrateAutomations(db: Db, options?: AutomationsMigrationOptions): Promise<AutomationsMigrationReport>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var automations_exports = {};
|
|
20
|
+
__export(automations_exports, {
|
|
21
|
+
migrateAutomations: () => migrateAutomations
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(automations_exports);
|
|
24
|
+
var import_indexes = require("../indexes");
|
|
25
|
+
const RENAMES = [
|
|
26
|
+
["agentic_jobs", "automations"],
|
|
27
|
+
["agentic_job_runs", "automation_runs"]
|
|
28
|
+
];
|
|
29
|
+
const OLD_RUN_INDEX = "jobId_1_createdAt_-1";
|
|
30
|
+
const exists = async (db, name) => (await db.listCollections({ name }).toArray()).length > 0;
|
|
31
|
+
async function migrateAutomations(db, options = {}) {
|
|
32
|
+
const dryRun = Boolean(options.dryRun);
|
|
33
|
+
const report = { dryRun, renamedCollections: [], triggersCreated: 0, runsUpdated: 0, droppedIndexes: [] };
|
|
34
|
+
for (const [from, to] of RENAMES) {
|
|
35
|
+
if (!await exists(db, from)) continue;
|
|
36
|
+
if (await exists(db, to)) throw new Error(`Cannot rename ${from} to ${to} because ${to} already exists`);
|
|
37
|
+
if (!dryRun) await db.renameCollection(from, to);
|
|
38
|
+
report.renamedCollections.push(`${from} -> ${to}`);
|
|
39
|
+
}
|
|
40
|
+
const automations = db.collection(dryRun && report.renamedCollections.length ? "agentic_jobs" : "automations");
|
|
41
|
+
const runs = db.collection(dryRun && report.renamedCollections.length ? "agentic_job_runs" : "automation_runs");
|
|
42
|
+
const withoutTrigger = { trigger: { $exists: false }, recurrence: { $exists: true } };
|
|
43
|
+
const withJobId = { jobId: { $exists: true } };
|
|
44
|
+
if (dryRun) {
|
|
45
|
+
report.triggersCreated = await automations.countDocuments(withoutTrigger);
|
|
46
|
+
report.runsUpdated = await runs.countDocuments(withJobId);
|
|
47
|
+
} else {
|
|
48
|
+
const triggers = await automations.updateMany(withoutTrigger, [
|
|
49
|
+
{ $set: { trigger: { type: "schedule", recurrence: "$recurrence", timezone: "$timezone" } } },
|
|
50
|
+
{ $unset: ["recurrence", "timezone"] }
|
|
51
|
+
]);
|
|
52
|
+
const moved = await runs.updateMany(withJobId, [
|
|
53
|
+
{ $set: { automationId: "$jobId" } },
|
|
54
|
+
{ $unset: "jobId" }
|
|
55
|
+
]);
|
|
56
|
+
report.triggersCreated = triggers.modifiedCount;
|
|
57
|
+
report.runsUpdated = moved.modifiedCount;
|
|
58
|
+
}
|
|
59
|
+
const indexes = await runs.indexes().catch(() => []);
|
|
60
|
+
if (indexes.some((index) => index.name === OLD_RUN_INDEX)) {
|
|
61
|
+
if (!dryRun) await runs.dropIndex(OLD_RUN_INDEX);
|
|
62
|
+
report.droppedIndexes.push(OLD_RUN_INDEX);
|
|
63
|
+
}
|
|
64
|
+
if (!dryRun) await (0, import_indexes.ensureIndexes)(db);
|
|
65
|
+
return report;
|
|
66
|
+
}
|
|
67
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
+
0 && (module.exports = {
|
|
69
|
+
migrateAutomations
|
|
70
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import "../../chunk-CF3WOMB3.mjs";
|
|
2
|
+
import { ensureIndexes } from "../indexes";
|
|
3
|
+
const RENAMES = [
|
|
4
|
+
["agentic_jobs", "automations"],
|
|
5
|
+
["agentic_job_runs", "automation_runs"]
|
|
6
|
+
];
|
|
7
|
+
const OLD_RUN_INDEX = "jobId_1_createdAt_-1";
|
|
8
|
+
const exists = async (db, name) => (await db.listCollections({ name }).toArray()).length > 0;
|
|
9
|
+
async function migrateAutomations(db, options = {}) {
|
|
10
|
+
const dryRun = Boolean(options.dryRun);
|
|
11
|
+
const report = { dryRun, renamedCollections: [], triggersCreated: 0, runsUpdated: 0, droppedIndexes: [] };
|
|
12
|
+
for (const [from, to] of RENAMES) {
|
|
13
|
+
if (!await exists(db, from)) continue;
|
|
14
|
+
if (await exists(db, to)) throw new Error(`Cannot rename ${from} to ${to} because ${to} already exists`);
|
|
15
|
+
if (!dryRun) await db.renameCollection(from, to);
|
|
16
|
+
report.renamedCollections.push(`${from} -> ${to}`);
|
|
17
|
+
}
|
|
18
|
+
const automations = db.collection(dryRun && report.renamedCollections.length ? "agentic_jobs" : "automations");
|
|
19
|
+
const runs = db.collection(dryRun && report.renamedCollections.length ? "agentic_job_runs" : "automation_runs");
|
|
20
|
+
const withoutTrigger = { trigger: { $exists: false }, recurrence: { $exists: true } };
|
|
21
|
+
const withJobId = { jobId: { $exists: true } };
|
|
22
|
+
if (dryRun) {
|
|
23
|
+
report.triggersCreated = await automations.countDocuments(withoutTrigger);
|
|
24
|
+
report.runsUpdated = await runs.countDocuments(withJobId);
|
|
25
|
+
} else {
|
|
26
|
+
const triggers = await automations.updateMany(withoutTrigger, [
|
|
27
|
+
{ $set: { trigger: { type: "schedule", recurrence: "$recurrence", timezone: "$timezone" } } },
|
|
28
|
+
{ $unset: ["recurrence", "timezone"] }
|
|
29
|
+
]);
|
|
30
|
+
const moved = await runs.updateMany(withJobId, [
|
|
31
|
+
{ $set: { automationId: "$jobId" } },
|
|
32
|
+
{ $unset: "jobId" }
|
|
33
|
+
]);
|
|
34
|
+
report.triggersCreated = triggers.modifiedCount;
|
|
35
|
+
report.runsUpdated = moved.modifiedCount;
|
|
36
|
+
}
|
|
37
|
+
const indexes = await runs.indexes().catch(() => []);
|
|
38
|
+
if (indexes.some((index) => index.name === OLD_RUN_INDEX)) {
|
|
39
|
+
if (!dryRun) await runs.dropIndex(OLD_RUN_INDEX);
|
|
40
|
+
report.droppedIndexes.push(OLD_RUN_INDEX);
|
|
41
|
+
}
|
|
42
|
+
if (!dryRun) await ensureIndexes(db);
|
|
43
|
+
return report;
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
migrateAutomations
|
|
47
|
+
};
|
|
@@ -6,6 +6,7 @@ import { AgentTask } from '../services/tasks/entities/agent-task.entity.js';
|
|
|
6
6
|
import { AgentAction } from '../services/tasks/entities/agent-action.entity.js';
|
|
7
7
|
import { Tool, BaseParams } from '../tools/tool.js';
|
|
8
8
|
import { SkillRunOptions } from '../skills/skill.js';
|
|
9
|
+
import { SelectableThinkingEffort } from '../clients/llm/llm-types.js';
|
|
9
10
|
import { WeightedKeyword, ScoredTool } from './utils/rank-tools-by-keywords';
|
|
10
11
|
import type { ToolCatalog } from './tool-catalog';
|
|
11
12
|
import { Workspace } from './workspace';
|
|
@@ -15,6 +16,7 @@ export interface RunContext {
|
|
|
15
16
|
task?: AgentTask;
|
|
16
17
|
chat: Chat;
|
|
17
18
|
chatOptions?: ChatSettingsProps;
|
|
19
|
+
thinkingEffort?: SelectableThinkingEffort;
|
|
18
20
|
currentUser: CurrentUser;
|
|
19
21
|
currentSession?: CurrentSession;
|
|
20
22
|
currentMessage: string;
|
package/dist/harness/agent.d.ts
CHANGED
package/dist/harness/agent.js
CHANGED
|
@@ -45,6 +45,7 @@ var import_tool_pipeline = require("./tool-pipeline");
|
|
|
45
45
|
var import_native_tools = require("./native-tools");
|
|
46
46
|
var import_tool_catalog = require("./tool-catalog");
|
|
47
47
|
var import_llm_error = require("../clients/llm/llm-error.js");
|
|
48
|
+
var import_llm_types = require("../clients/llm/llm-types.js");
|
|
48
49
|
var import_model_resolution = require("../clients/llm/model-resolution.js");
|
|
49
50
|
const MCP_CONNECT_RETRY_DELAYS_MS = [1e3, 2e3];
|
|
50
51
|
const MCP_DESCRIPTION_CHARS = 300;
|
|
@@ -67,6 +68,7 @@ class Agent {
|
|
|
67
68
|
strictMode;
|
|
68
69
|
fallbackModel;
|
|
69
70
|
model;
|
|
71
|
+
thinkingEffort;
|
|
70
72
|
_tools;
|
|
71
73
|
_internalMcps = [];
|
|
72
74
|
_mcps = [];
|
|
@@ -173,6 +175,8 @@ class Agent {
|
|
|
173
175
|
this.mcpTokens = mcpTokens ?? {};
|
|
174
176
|
this.serviceToken = serviceToken;
|
|
175
177
|
this.model = void 0;
|
|
178
|
+
this.thinkingEffort = void 0;
|
|
179
|
+
if (options?.thinkingEffort !== void 0 && !(0, import_llm_types.isSelectableThinkingEffort)(options.thinkingEffort)) throw new Error(`[AGENT] thinkingEffort must be one of ${import_llm_types.SELECTABLE_THINKING_EFFORTS.join(", ")}`);
|
|
176
180
|
if (Boolean(options?.modelProvider) !== Boolean(options?.modelName)) throw new Error("[AGENT] Set both modelProvider and modelName, or neither");
|
|
177
181
|
this.answerId = new import_mongodb.ObjectId().toString();
|
|
178
182
|
const proceed = await this.preRunner(chatId);
|
|
@@ -260,6 +264,9 @@ class Agent {
|
|
|
260
264
|
});
|
|
261
265
|
this.currentChat.settings?.setModelProvider(this.model.provider);
|
|
262
266
|
this.currentChat.settings?.setModelName(this.model.model);
|
|
267
|
+
if (this.chatOptions?.thinkingEffort) this.currentChat.settings?.setThinkingEffort(this.chatOptions.thinkingEffort);
|
|
268
|
+
const savedEffort = this.currentChat.settings?.thinkingEffort;
|
|
269
|
+
this.thinkingEffort = this.chatOptions?.thinkingEffort ?? ((0, import_llm_types.isSelectableThinkingEffort)(savedEffort) ? savedEffort : void 0);
|
|
263
270
|
if (this.chatOptions?.loopName) this.currentChat.settings?.setLoopName(this.chatOptions.loopName);
|
|
264
271
|
this.awaitingConfirmation = this.currentChat.state?.status === import_agent_state.AgentStatus.AWAITING_USER_CONFIRMATION;
|
|
265
272
|
this.currentChat.state?.setStatus(import_agent_state.AgentStatus.PROCESSING);
|
|
@@ -863,6 +870,7 @@ Ref: ${guard.ref}`, { source: "harness", excludeFromContext: true });
|
|
|
863
870
|
task: this.currentChat.activeTask,
|
|
864
871
|
chat: this.currentChat,
|
|
865
872
|
chatOptions: this.chatOptions,
|
|
873
|
+
thinkingEffort: this.thinkingEffort,
|
|
866
874
|
currentUser: this.currentUser,
|
|
867
875
|
currentSession: this.currentSession,
|
|
868
876
|
currentMessage: this.currentMessage,
|