rookery-agent 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/LICENSE +21 -0
- package/README.md +367 -0
- package/docs/migration.md +88 -0
- package/package.json +39 -0
- package/packages/cli/dist/commands/chat.d.ts +52 -0
- package/packages/cli/dist/commands/chat.d.ts.map +1 -0
- package/packages/cli/dist/commands/chat.js +107 -0
- package/packages/cli/dist/commands/chat.js.map +1 -0
- package/packages/cli/dist/commands/config.d.ts +12 -0
- package/packages/cli/dist/commands/config.d.ts.map +1 -0
- package/packages/cli/dist/commands/config.js +156 -0
- package/packages/cli/dist/commands/config.js.map +1 -0
- package/packages/cli/dist/commands/doctor.d.ts +12 -0
- package/packages/cli/dist/commands/doctor.d.ts.map +1 -0
- package/packages/cli/dist/commands/doctor.js +137 -0
- package/packages/cli/dist/commands/doctor.js.map +1 -0
- package/packages/cli/dist/commands/memory.d.ts +34 -0
- package/packages/cli/dist/commands/memory.d.ts.map +1 -0
- package/packages/cli/dist/commands/memory.js +133 -0
- package/packages/cli/dist/commands/memory.js.map +1 -0
- package/packages/cli/dist/commands/org.d.ts +93 -0
- package/packages/cli/dist/commands/org.d.ts.map +1 -0
- package/packages/cli/dist/commands/org.js +389 -0
- package/packages/cli/dist/commands/org.js.map +1 -0
- package/packages/cli/dist/commands/serve.d.ts +13 -0
- package/packages/cli/dist/commands/serve.d.ts.map +1 -0
- package/packages/cli/dist/commands/serve.js +100 -0
- package/packages/cli/dist/commands/serve.js.map +1 -0
- package/packages/cli/dist/commands/sessions.d.ts +18 -0
- package/packages/cli/dist/commands/sessions.d.ts.map +1 -0
- package/packages/cli/dist/commands/sessions.js +88 -0
- package/packages/cli/dist/commands/sessions.js.map +1 -0
- package/packages/cli/dist/commands/shared.d.ts +59 -0
- package/packages/cli/dist/commands/shared.d.ts.map +1 -0
- package/packages/cli/dist/commands/shared.js +230 -0
- package/packages/cli/dist/commands/shared.js.map +1 -0
- package/packages/cli/dist/commands/tasks.d.ts +62 -0
- package/packages/cli/dist/commands/tasks.d.ts.map +1 -0
- package/packages/cli/dist/commands/tasks.js +262 -0
- package/packages/cli/dist/commands/tasks.js.map +1 -0
- package/packages/cli/dist/commands/tools.d.ts +8 -0
- package/packages/cli/dist/commands/tools.d.ts.map +1 -0
- package/packages/cli/dist/commands/tools.js +65 -0
- package/packages/cli/dist/commands/tools.js.map +1 -0
- package/packages/cli/dist/index.d.ts +15 -0
- package/packages/cli/dist/index.d.ts.map +1 -0
- package/packages/cli/dist/index.js +513 -0
- package/packages/cli/dist/index.js.map +1 -0
- package/packages/cli/dist/repl.d.ts +29 -0
- package/packages/cli/dist/repl.d.ts.map +1 -0
- package/packages/cli/dist/repl.js +634 -0
- package/packages/cli/dist/repl.js.map +1 -0
- package/packages/cli/dist/tui/App.d.ts +51 -0
- package/packages/cli/dist/tui/App.d.ts.map +1 -0
- package/packages/cli/dist/tui/App.js +461 -0
- package/packages/cli/dist/tui/App.js.map +1 -0
- package/packages/cli/dist/tui/commands.d.ts +34 -0
- package/packages/cli/dist/tui/commands.d.ts.map +1 -0
- package/packages/cli/dist/tui/commands.js +367 -0
- package/packages/cli/dist/tui/commands.js.map +1 -0
- package/packages/cli/dist/tui/components/ActivityLine.d.ts +16 -0
- package/packages/cli/dist/tui/components/ActivityLine.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/ActivityLine.js +7 -0
- package/packages/cli/dist/tui/components/ActivityLine.js.map +1 -0
- package/packages/cli/dist/tui/components/AssignmentsView.d.ts +31 -0
- package/packages/cli/dist/tui/components/AssignmentsView.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/AssignmentsView.js +79 -0
- package/packages/cli/dist/tui/components/AssignmentsView.js.map +1 -0
- package/packages/cli/dist/tui/components/Banner.d.ts +18 -0
- package/packages/cli/dist/tui/components/Banner.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Banner.js +16 -0
- package/packages/cli/dist/tui/components/Banner.js.map +1 -0
- package/packages/cli/dist/tui/components/CodeBlock.d.ts +19 -0
- package/packages/cli/dist/tui/components/CodeBlock.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/CodeBlock.js +21 -0
- package/packages/cli/dist/tui/components/CodeBlock.js.map +1 -0
- package/packages/cli/dist/tui/components/InputBox.d.ts +25 -0
- package/packages/cli/dist/tui/components/InputBox.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/InputBox.js +35 -0
- package/packages/cli/dist/tui/components/InputBox.js.map +1 -0
- package/packages/cli/dist/tui/components/Markdown.d.ts +74 -0
- package/packages/cli/dist/tui/components/Markdown.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Markdown.js +293 -0
- package/packages/cli/dist/tui/components/Markdown.js.map +1 -0
- package/packages/cli/dist/tui/components/Message.d.ts +29 -0
- package/packages/cli/dist/tui/components/Message.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Message.js +28 -0
- package/packages/cli/dist/tui/components/Message.js.map +1 -0
- package/packages/cli/dist/tui/components/Scrollback.d.ts +23 -0
- package/packages/cli/dist/tui/components/Scrollback.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Scrollback.js +36 -0
- package/packages/cli/dist/tui/components/Scrollback.js.map +1 -0
- package/packages/cli/dist/tui/components/SlashPalette.d.ts +17 -0
- package/packages/cli/dist/tui/components/SlashPalette.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/SlashPalette.js +19 -0
- package/packages/cli/dist/tui/components/SlashPalette.js.map +1 -0
- package/packages/cli/dist/tui/components/StatusLine.d.ts +61 -0
- package/packages/cli/dist/tui/components/StatusLine.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/StatusLine.js +55 -0
- package/packages/cli/dist/tui/components/StatusLine.js.map +1 -0
- package/packages/cli/dist/tui/components/ToolGroup.d.ts +33 -0
- package/packages/cli/dist/tui/components/ToolGroup.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/ToolGroup.js +52 -0
- package/packages/cli/dist/tui/components/ToolGroup.js.map +1 -0
- package/packages/cli/dist/tui/components/Wordmark.d.ts +35 -0
- package/packages/cli/dist/tui/components/Wordmark.d.ts.map +1 -0
- package/packages/cli/dist/tui/components/Wordmark.js +81 -0
- package/packages/cli/dist/tui/components/Wordmark.js.map +1 -0
- package/packages/cli/dist/tui/highlight.d.ts +29 -0
- package/packages/cli/dist/tui/highlight.d.ts.map +1 -0
- package/packages/cli/dist/tui/highlight.js +137 -0
- package/packages/cli/dist/tui/highlight.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useColumns.d.ts +20 -0
- package/packages/cli/dist/tui/hooks/useColumns.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useColumns.js +38 -0
- package/packages/cli/dist/tui/hooks/useColumns.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useHistory.d.ts +21 -0
- package/packages/cli/dist/tui/hooks/useHistory.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useHistory.js +57 -0
- package/packages/cli/dist/tui/hooks/useHistory.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useSlash.d.ts +38 -0
- package/packages/cli/dist/tui/hooks/useSlash.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useSlash.js +89 -0
- package/packages/cli/dist/tui/hooks/useSlash.js.map +1 -0
- package/packages/cli/dist/tui/hooks/useTurn.d.ts +75 -0
- package/packages/cli/dist/tui/hooks/useTurn.d.ts.map +1 -0
- package/packages/cli/dist/tui/hooks/useTurn.js +396 -0
- package/packages/cli/dist/tui/hooks/useTurn.js.map +1 -0
- package/packages/cli/dist/tui/theme.d.ts +126 -0
- package/packages/cli/dist/tui/theme.d.ts.map +1 -0
- package/packages/cli/dist/tui/theme.js +127 -0
- package/packages/cli/dist/tui/theme.js.map +1 -0
- package/packages/cli/dist/tui/types.d.ts +205 -0
- package/packages/cli/dist/tui/types.d.ts.map +1 -0
- package/packages/cli/dist/tui/types.js +55 -0
- package/packages/cli/dist/tui/types.js.map +1 -0
- package/packages/cli/dist/ui/render.d.ts +74 -0
- package/packages/cli/dist/ui/render.d.ts.map +1 -0
- package/packages/cli/dist/ui/render.js +349 -0
- package/packages/cli/dist/ui/render.js.map +1 -0
- package/packages/cli/dist/ui/speech.d.ts +42 -0
- package/packages/cli/dist/ui/speech.d.ts.map +1 -0
- package/packages/cli/dist/ui/speech.js +257 -0
- package/packages/cli/dist/ui/speech.js.map +1 -0
- package/packages/cli/dist/ui/spinner.d.ts +17 -0
- package/packages/cli/dist/ui/spinner.d.ts.map +1 -0
- package/packages/cli/dist/ui/spinner.js +61 -0
- package/packages/cli/dist/ui/spinner.js.map +1 -0
- package/packages/cli/dist/ui/theme.d.ts +54 -0
- package/packages/cli/dist/ui/theme.d.ts.map +1 -0
- package/packages/cli/dist/ui/theme.js +74 -0
- package/packages/cli/dist/ui/theme.js.map +1 -0
- package/packages/cli/package.json +1 -0
- package/packages/core/dist/agents/legacy-persona.d.ts +4 -0
- package/packages/core/dist/agents/legacy-persona.d.ts.map +1 -0
- package/packages/core/dist/agents/legacy-persona.js +39 -0
- package/packages/core/dist/agents/legacy-persona.js.map +1 -0
- package/packages/core/dist/agents/orchestrator.d.ts +24 -0
- package/packages/core/dist/agents/orchestrator.d.ts.map +1 -0
- package/packages/core/dist/agents/orchestrator.js +88 -0
- package/packages/core/dist/agents/orchestrator.js.map +1 -0
- package/packages/core/dist/agents/persona.d.ts +56 -0
- package/packages/core/dist/agents/persona.d.ts.map +1 -0
- package/packages/core/dist/agents/persona.js +153 -0
- package/packages/core/dist/agents/persona.js.map +1 -0
- package/packages/core/dist/agents/roles.d.ts +21 -0
- package/packages/core/dist/agents/roles.d.ts.map +1 -0
- package/packages/core/dist/agents/roles.js +81 -0
- package/packages/core/dist/agents/roles.js.map +1 -0
- package/packages/core/dist/agents/team.d.ts +105 -0
- package/packages/core/dist/agents/team.d.ts.map +1 -0
- package/packages/core/dist/agents/team.js +623 -0
- package/packages/core/dist/agents/team.js.map +1 -0
- package/packages/core/dist/computer/keys.d.ts +12 -0
- package/packages/core/dist/computer/keys.d.ts.map +1 -0
- package/packages/core/dist/computer/keys.js +56 -0
- package/packages/core/dist/computer/keys.js.map +1 -0
- package/packages/core/dist/computer/mcp-server.d.ts +11 -0
- package/packages/core/dist/computer/mcp-server.d.ts.map +1 -0
- package/packages/core/dist/computer/mcp-server.js +228 -0
- package/packages/core/dist/computer/mcp-server.js.map +1 -0
- package/packages/core/dist/computer/powershell.d.ts +13 -0
- package/packages/core/dist/computer/powershell.d.ts.map +1 -0
- package/packages/core/dist/computer/powershell.js +359 -0
- package/packages/core/dist/computer/powershell.js.map +1 -0
- package/packages/core/dist/computer/tools.d.ts +43 -0
- package/packages/core/dist/computer/tools.d.ts.map +1 -0
- package/packages/core/dist/computer/tools.js +260 -0
- package/packages/core/dist/computer/tools.js.map +1 -0
- package/packages/core/dist/config.d.ts +32 -0
- package/packages/core/dist/config.d.ts.map +1 -0
- package/packages/core/dist/config.js +329 -0
- package/packages/core/dist/config.js.map +1 -0
- package/packages/core/dist/cron/parse.d.ts +52 -0
- package/packages/core/dist/cron/parse.d.ts.map +1 -0
- package/packages/core/dist/cron/parse.js +277 -0
- package/packages/core/dist/cron/parse.js.map +1 -0
- package/packages/core/dist/cron/scheduler.d.ts +102 -0
- package/packages/core/dist/cron/scheduler.d.ts.map +1 -0
- package/packages/core/dist/cron/scheduler.js +334 -0
- package/packages/core/dist/cron/scheduler.js.map +1 -0
- package/packages/core/dist/cron/script.d.ts +9 -0
- package/packages/core/dist/cron/script.d.ts.map +1 -0
- package/packages/core/dist/cron/script.js +113 -0
- package/packages/core/dist/cron/script.js.map +1 -0
- package/packages/core/dist/cron/store.d.ts +77 -0
- package/packages/core/dist/cron/store.d.ts.map +1 -0
- package/packages/core/dist/cron/store.js +229 -0
- package/packages/core/dist/cron/store.js.map +1 -0
- package/packages/core/dist/gateway/policy.d.ts +113 -0
- package/packages/core/dist/gateway/policy.d.ts.map +1 -0
- package/packages/core/dist/gateway/policy.js +373 -0
- package/packages/core/dist/gateway/policy.js.map +1 -0
- package/packages/core/dist/index.d.ts +45 -0
- package/packages/core/dist/index.d.ts.map +1 -0
- package/packages/core/dist/index.js +52 -0
- package/packages/core/dist/index.js.map +1 -0
- package/packages/core/dist/logger.d.ts +21 -0
- package/packages/core/dist/logger.d.ts.map +1 -0
- package/packages/core/dist/logger.js +61 -0
- package/packages/core/dist/logger.js.map +1 -0
- package/packages/core/dist/memory/db.d.ts +12 -0
- package/packages/core/dist/memory/db.d.ts.map +1 -0
- package/packages/core/dist/memory/db.js +414 -0
- package/packages/core/dist/memory/db.js.map +1 -0
- package/packages/core/dist/memory/extractor.d.ts +35 -0
- package/packages/core/dist/memory/extractor.d.ts.map +1 -0
- package/packages/core/dist/memory/extractor.js +159 -0
- package/packages/core/dist/memory/extractor.js.map +1 -0
- package/packages/core/dist/memory/gate.d.ts +68 -0
- package/packages/core/dist/memory/gate.d.ts.map +1 -0
- package/packages/core/dist/memory/gate.js +163 -0
- package/packages/core/dist/memory/gate.js.map +1 -0
- package/packages/core/dist/memory/recall.d.ts +61 -0
- package/packages/core/dist/memory/recall.d.ts.map +1 -0
- package/packages/core/dist/memory/recall.js +342 -0
- package/packages/core/dist/memory/recall.js.map +1 -0
- package/packages/core/dist/memory/sleep.d.ts +105 -0
- package/packages/core/dist/memory/sleep.d.ts.map +1 -0
- package/packages/core/dist/memory/sleep.js +888 -0
- package/packages/core/dist/memory/sleep.js.map +1 -0
- package/packages/core/dist/memory/store.d.ts +263 -0
- package/packages/core/dist/memory/store.d.ts.map +1 -0
- package/packages/core/dist/memory/store.js +999 -0
- package/packages/core/dist/memory/store.js.map +1 -0
- package/packages/core/dist/migration-cron.d.ts +37 -0
- package/packages/core/dist/migration-cron.d.ts.map +1 -0
- package/packages/core/dist/migration-cron.js +257 -0
- package/packages/core/dist/migration-cron.js.map +1 -0
- package/packages/core/dist/migration-scripts.d.ts +15 -0
- package/packages/core/dist/migration-scripts.d.ts.map +1 -0
- package/packages/core/dist/migration-scripts.js +97 -0
- package/packages/core/dist/migration-scripts.js.map +1 -0
- package/packages/core/dist/migration.d.ts +33 -0
- package/packages/core/dist/migration.d.ts.map +1 -0
- package/packages/core/dist/migration.js +296 -0
- package/packages/core/dist/migration.js.map +1 -0
- package/packages/core/dist/org/bridge.d.ts +42 -0
- package/packages/core/dist/org/bridge.d.ts.map +1 -0
- package/packages/core/dist/org/bridge.js +139 -0
- package/packages/core/dist/org/bridge.js.map +1 -0
- package/packages/core/dist/org/controller.d.ts +118 -0
- package/packages/core/dist/org/controller.d.ts.map +1 -0
- package/packages/core/dist/org/controller.js +1431 -0
- package/packages/core/dist/org/controller.js.map +1 -0
- package/packages/core/dist/org/mcp-bridge.d.ts +11 -0
- package/packages/core/dist/org/mcp-bridge.d.ts.map +1 -0
- package/packages/core/dist/org/mcp-bridge.js +148 -0
- package/packages/core/dist/org/mcp-bridge.js.map +1 -0
- package/packages/core/dist/org/planner.d.ts +60 -0
- package/packages/core/dist/org/planner.d.ts.map +1 -0
- package/packages/core/dist/org/planner.js +175 -0
- package/packages/core/dist/org/planner.js.map +1 -0
- package/packages/core/dist/org/ponytail.d.ts +24 -0
- package/packages/core/dist/org/ponytail.d.ts.map +1 -0
- package/packages/core/dist/org/ponytail.js +53 -0
- package/packages/core/dist/org/ponytail.js.map +1 -0
- package/packages/core/dist/org/project-mcp.d.ts +32 -0
- package/packages/core/dist/org/project-mcp.d.ts.map +1 -0
- package/packages/core/dist/org/project-mcp.js +53 -0
- package/packages/core/dist/org/project-mcp.js.map +1 -0
- package/packages/core/dist/org/prompts.d.ts +71 -0
- package/packages/core/dist/org/prompts.d.ts.map +1 -0
- package/packages/core/dist/org/prompts.js +268 -0
- package/packages/core/dist/org/prompts.js.map +1 -0
- package/packages/core/dist/org/store.d.ts +176 -0
- package/packages/core/dist/org/store.d.ts.map +1 -0
- package/packages/core/dist/org/store.js +594 -0
- package/packages/core/dist/org/store.js.map +1 -0
- package/packages/core/dist/org/tools.d.ts +22 -0
- package/packages/core/dist/org/tools.d.ts.map +1 -0
- package/packages/core/dist/org/tools.js +578 -0
- package/packages/core/dist/org/tools.js.map +1 -0
- package/packages/core/dist/profile.d.ts +16 -0
- package/packages/core/dist/profile.d.ts.map +1 -0
- package/packages/core/dist/profile.js +176 -0
- package/packages/core/dist/profile.js.map +1 -0
- package/packages/core/dist/providers/catalogue.d.ts +6 -0
- package/packages/core/dist/providers/catalogue.d.ts.map +1 -0
- package/packages/core/dist/providers/catalogue.js +104 -0
- package/packages/core/dist/providers/catalogue.js.map +1 -0
- package/packages/core/dist/providers/claude-code.d.ts +10 -0
- package/packages/core/dist/providers/claude-code.d.ts.map +1 -0
- package/packages/core/dist/providers/claude-code.js +321 -0
- package/packages/core/dist/providers/claude-code.js.map +1 -0
- package/packages/core/dist/providers/codex.d.ts +10 -0
- package/packages/core/dist/providers/codex.d.ts.map +1 -0
- package/packages/core/dist/providers/codex.js +375 -0
- package/packages/core/dist/providers/codex.js.map +1 -0
- package/packages/core/dist/providers/process.d.ts +48 -0
- package/packages/core/dist/providers/process.d.ts.map +1 -0
- package/packages/core/dist/providers/process.js +165 -0
- package/packages/core/dist/providers/process.js.map +1 -0
- package/packages/core/dist/providers/quota.d.ts +13 -0
- package/packages/core/dist/providers/quota.d.ts.map +1 -0
- package/packages/core/dist/providers/quota.js +231 -0
- package/packages/core/dist/providers/quota.js.map +1 -0
- package/packages/core/dist/providers/registry.d.ts +27 -0
- package/packages/core/dist/providers/registry.d.ts.map +1 -0
- package/packages/core/dist/providers/registry.js +64 -0
- package/packages/core/dist/providers/registry.js.map +1 -0
- package/packages/core/dist/runtime.d.ts +149 -0
- package/packages/core/dist/runtime.d.ts.map +1 -0
- package/packages/core/dist/runtime.js +778 -0
- package/packages/core/dist/runtime.js.map +1 -0
- package/packages/core/dist/skills/import.d.ts +41 -0
- package/packages/core/dist/skills/import.d.ts.map +1 -0
- package/packages/core/dist/skills/import.js +129 -0
- package/packages/core/dist/skills/import.js.map +1 -0
- package/packages/core/dist/skills/store.d.ts +57 -0
- package/packages/core/dist/skills/store.d.ts.map +1 -0
- package/packages/core/dist/skills/store.js +126 -0
- package/packages/core/dist/skills/store.js.map +1 -0
- package/packages/core/dist/tools/browser.d.ts +20 -0
- package/packages/core/dist/tools/browser.d.ts.map +1 -0
- package/packages/core/dist/tools/browser.js +72 -0
- package/packages/core/dist/tools/browser.js.map +1 -0
- package/packages/core/dist/tools/catalog.d.ts +67 -0
- package/packages/core/dist/tools/catalog.d.ts.map +1 -0
- package/packages/core/dist/tools/catalog.js +233 -0
- package/packages/core/dist/tools/catalog.js.map +1 -0
- package/packages/core/dist/tools/hub.d.ts +68 -0
- package/packages/core/dist/tools/hub.d.ts.map +1 -0
- package/packages/core/dist/tools/hub.js +213 -0
- package/packages/core/dist/tools/hub.js.map +1 -0
- package/packages/core/dist/types.d.ts +1031 -0
- package/packages/core/dist/types.d.ts.map +1 -0
- package/packages/core/dist/types.js +22 -0
- package/packages/core/dist/types.js.map +1 -0
- package/packages/core/dist/util/queue.d.ts +25 -0
- package/packages/core/dist/util/queue.d.ts.map +1 -0
- package/packages/core/dist/util/queue.js +64 -0
- package/packages/core/dist/util/queue.js.map +1 -0
- package/packages/core/package.json +1 -0
- package/packages/server/dist/auth.d.ts +12 -0
- package/packages/server/dist/auth.d.ts.map +1 -0
- package/packages/server/dist/auth.js +61 -0
- package/packages/server/dist/auth.js.map +1 -0
- package/packages/server/dist/context.d.ts +29 -0
- package/packages/server/dist/context.d.ts.map +1 -0
- package/packages/server/dist/context.js +46 -0
- package/packages/server/dist/context.js.map +1 -0
- package/packages/server/dist/env.d.ts +8 -0
- package/packages/server/dist/env.d.ts.map +1 -0
- package/packages/server/dist/env.js +36 -0
- package/packages/server/dist/env.js.map +1 -0
- package/packages/server/dist/gateways/push.d.ts +22 -0
- package/packages/server/dist/gateways/push.d.ts.map +1 -0
- package/packages/server/dist/gateways/push.js +267 -0
- package/packages/server/dist/gateways/push.js.map +1 -0
- package/packages/server/dist/gateways/telegram-api.d.ts +82 -0
- package/packages/server/dist/gateways/telegram-api.d.ts.map +1 -0
- package/packages/server/dist/gateways/telegram-api.js +168 -0
- package/packages/server/dist/gateways/telegram-api.js.map +1 -0
- package/packages/server/dist/gateways/telegram.d.ts +32 -0
- package/packages/server/dist/gateways/telegram.d.ts.map +1 -0
- package/packages/server/dist/gateways/telegram.js +583 -0
- package/packages/server/dist/gateways/telegram.js.map +1 -0
- package/packages/server/dist/index.d.ts +12 -0
- package/packages/server/dist/index.d.ts.map +1 -0
- package/packages/server/dist/index.js +12 -0
- package/packages/server/dist/index.js.map +1 -0
- package/packages/server/dist/main.d.ts +2 -0
- package/packages/server/dist/main.d.ts.map +1 -0
- package/packages/server/dist/main.js +74 -0
- package/packages/server/dist/main.js.map +1 -0
- package/packages/server/dist/routes/agents.d.ts +5 -0
- package/packages/server/dist/routes/agents.d.ts.map +1 -0
- package/packages/server/dist/routes/agents.js +6 -0
- package/packages/server/dist/routes/agents.js.map +1 -0
- package/packages/server/dist/routes/chat.d.ts +10 -0
- package/packages/server/dist/routes/chat.d.ts.map +1 -0
- package/packages/server/dist/routes/chat.js +36 -0
- package/packages/server/dist/routes/chat.js.map +1 -0
- package/packages/server/dist/routes/config.d.ts +4 -0
- package/packages/server/dist/routes/config.d.ts.map +1 -0
- package/packages/server/dist/routes/config.js +58 -0
- package/packages/server/dist/routes/config.js.map +1 -0
- package/packages/server/dist/routes/cron.d.ts +10 -0
- package/packages/server/dist/routes/cron.d.ts.map +1 -0
- package/packages/server/dist/routes/cron.js +128 -0
- package/packages/server/dist/routes/cron.js.map +1 -0
- package/packages/server/dist/routes/gateways.d.ts +10 -0
- package/packages/server/dist/routes/gateways.d.ts.map +1 -0
- package/packages/server/dist/routes/gateways.js +32 -0
- package/packages/server/dist/routes/gateways.js.map +1 -0
- package/packages/server/dist/routes/health.d.ts +8 -0
- package/packages/server/dist/routes/health.d.ts.map +1 -0
- package/packages/server/dist/routes/health.js +12 -0
- package/packages/server/dist/routes/health.js.map +1 -0
- package/packages/server/dist/routes/memories.d.ts +11 -0
- package/packages/server/dist/routes/memories.d.ts.map +1 -0
- package/packages/server/dist/routes/memories.js +134 -0
- package/packages/server/dist/routes/memories.js.map +1 -0
- package/packages/server/dist/routes/org.d.ts +13 -0
- package/packages/server/dist/routes/org.d.ts.map +1 -0
- package/packages/server/dist/routes/org.js +316 -0
- package/packages/server/dist/routes/org.js.map +1 -0
- package/packages/server/dist/routes/profile.d.ts +4 -0
- package/packages/server/dist/routes/profile.d.ts.map +1 -0
- package/packages/server/dist/routes/profile.js +51 -0
- package/packages/server/dist/routes/profile.js.map +1 -0
- package/packages/server/dist/routes/providers.d.ts +9 -0
- package/packages/server/dist/routes/providers.d.ts.map +1 -0
- package/packages/server/dist/routes/providers.js +41 -0
- package/packages/server/dist/routes/providers.js.map +1 -0
- package/packages/server/dist/routes/sessions.d.ts +9 -0
- package/packages/server/dist/routes/sessions.d.ts.map +1 -0
- package/packages/server/dist/routes/sessions.js +72 -0
- package/packages/server/dist/routes/sessions.js.map +1 -0
- package/packages/server/dist/routes/sleep.d.ts +12 -0
- package/packages/server/dist/routes/sleep.d.ts.map +1 -0
- package/packages/server/dist/routes/sleep.js +70 -0
- package/packages/server/dist/routes/sleep.js.map +1 -0
- package/packages/server/dist/routes/stats.d.ts +17 -0
- package/packages/server/dist/routes/stats.d.ts.map +1 -0
- package/packages/server/dist/routes/stats.js +57 -0
- package/packages/server/dist/routes/stats.js.map +1 -0
- package/packages/server/dist/routes/team.d.ts +11 -0
- package/packages/server/dist/routes/team.d.ts.map +1 -0
- package/packages/server/dist/routes/team.js +36 -0
- package/packages/server/dist/routes/team.js.map +1 -0
- package/packages/server/dist/routes/tools.d.ts +10 -0
- package/packages/server/dist/routes/tools.d.ts.map +1 -0
- package/packages/server/dist/routes/tools.js +128 -0
- package/packages/server/dist/routes/tools.js.map +1 -0
- package/packages/server/dist/routes/tts.d.ts +12 -0
- package/packages/server/dist/routes/tts.d.ts.map +1 -0
- package/packages/server/dist/routes/tts.js +38 -0
- package/packages/server/dist/routes/tts.js.map +1 -0
- package/packages/server/dist/routes/ws.d.ts +13 -0
- package/packages/server/dist/routes/ws.d.ts.map +1 -0
- package/packages/server/dist/routes/ws.js +96 -0
- package/packages/server/dist/routes/ws.js.map +1 -0
- package/packages/server/dist/schemas.d.ts +981 -0
- package/packages/server/dist/schemas.d.ts.map +1 -0
- package/packages/server/dist/schemas.js +339 -0
- package/packages/server/dist/schemas.js.map +1 -0
- package/packages/server/dist/server.d.ts +20 -0
- package/packages/server/dist/server.d.ts.map +1 -0
- package/packages/server/dist/server.js +234 -0
- package/packages/server/dist/server.js.map +1 -0
- package/packages/server/dist/services/stream.d.ts +77 -0
- package/packages/server/dist/services/stream.d.ts.map +1 -0
- package/packages/server/dist/services/stream.js +84 -0
- package/packages/server/dist/services/stream.js.map +1 -0
- package/packages/server/dist/services/tts.d.ts +53 -0
- package/packages/server/dist/services/tts.d.ts.map +1 -0
- package/packages/server/dist/services/tts.js +281 -0
- package/packages/server/dist/services/tts.js.map +1 -0
- package/packages/server/dist/services/voice-keys.d.ts +26 -0
- package/packages/server/dist/services/voice-keys.d.ts.map +1 -0
- package/packages/server/dist/services/voice-keys.js +51 -0
- package/packages/server/dist/services/voice-keys.js.map +1 -0
- package/packages/server/dist/static.d.ts +12 -0
- package/packages/server/dist/static.d.ts.map +1 -0
- package/packages/server/dist/static.js +63 -0
- package/packages/server/dist/static.js.map +1 -0
- package/packages/server/package.json +1 -0
- package/packages/web/dist/apple-touch-icon.png +0 -0
- package/packages/web/dist/assets/3d-force-graph-BPZmoydi.js +1163 -0
- package/packages/web/dist/assets/bricolage-grotesque-latin-ext-wght-normal-CcLUaPy7.woff2 +0 -0
- package/packages/web/dist/assets/bricolage-grotesque-latin-wght-normal-DLoelf7F.woff2 +0 -0
- package/packages/web/dist/assets/bricolage-grotesque-vietnamese-wght-normal-BUzh504Q.woff2 +0 -0
- package/packages/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/packages/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/packages/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/packages/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/packages/web/dist/assets/geist-mono-cyrillic-ext-wght-normal-X_5orZeX.woff2 +0 -0
- package/packages/web/dist/assets/geist-mono-cyrillic-wght-normal-DiZS0aHC.woff2 +0 -0
- package/packages/web/dist/assets/geist-mono-latin-ext-wght-normal-Bwz-egvJ.woff2 +0 -0
- package/packages/web/dist/assets/geist-mono-latin-wght-normal-XN7g48iV.woff2 +0 -0
- package/packages/web/dist/assets/geist-mono-symbols2-wght-normal-CO5SzqOn.woff2 +0 -0
- package/packages/web/dist/assets/geist-mono-vietnamese-wght-normal-DadHysG0.woff2 +0 -0
- package/packages/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/packages/web/dist/assets/index-IBSTzK7-.js +1255 -0
- package/packages/web/dist/assets/index-qUXUui7W.css +1 -0
- package/packages/web/dist/assets/three-spritetext-B9ZIW7c-.js +4 -0
- package/packages/web/dist/assets/three.module-cmFfBtHS.js +4228 -0
- package/packages/web/dist/favicon.ico +0 -0
- package/packages/web/dist/favicon.svg +2 -0
- package/packages/web/dist/index.html +28 -0
- package/packages/web/dist/logo-light.svg +2 -0
- package/packages/web/dist/logo.svg +2 -0
- package/packages/web/dist/mark-light.svg +2 -0
- package/packages/web/dist/mark.svg +2 -0
- package/packages/web/package.json +1 -0
- package/scripts/rookery.mjs +183 -0
|
@@ -0,0 +1,1431 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { readProfileExcerpt, searchProfile } from '../profile.js';
|
|
4
|
+
import { ASSISTANT_MEMORY_OWNER, EFFORT_LEVELS } from '../types.js';
|
|
5
|
+
import { agentWorkspace, applyConfig } from '../config.js';
|
|
6
|
+
import { silentLogger } from '../logger.js';
|
|
7
|
+
import { coreProfile, recall } from '../memory/recall.js';
|
|
8
|
+
import { extractMemories, smallModelFor } from '../memory/extractor.js';
|
|
9
|
+
import { admitCandidates, linkEntities } from '../memory/gate.js';
|
|
10
|
+
import { clip, shorten, tail } from '../util/queue.js';
|
|
11
|
+
import { buildAgentPrompt, renderBoard, renderOrgOverview, renderSchedules } from './prompts.js';
|
|
12
|
+
import { buildTaskWaves, planTask } from './planner.js';
|
|
13
|
+
import { toolsFor } from './tools.js';
|
|
14
|
+
import { ensureToolServers, renderToolServers, toolServerStates, toolServersFor, withToolServer } from '../tools/hub.js';
|
|
15
|
+
import { SkillStore, projectSkillsDir, renderSkill, renderSkillsIndex } from '../skills/store.js';
|
|
16
|
+
import { describeCronJob } from '../cron/scheduler.js';
|
|
17
|
+
import { describeCron } from '../cron/parse.js';
|
|
18
|
+
import { fingerprintMcpFile, projectMcpStatus, readProjectMcpFile, renderProjectMcpServers, } from './project-mcp.js';
|
|
19
|
+
/** Emit a progress line roughly every this many characters of agent output. */
|
|
20
|
+
const PROGRESS_EVERY = 700;
|
|
21
|
+
/** How much of a result travels back into the caller's tool response. */
|
|
22
|
+
const RESULT_BUDGET = 24000;
|
|
23
|
+
export class OrgController extends EventEmitter {
|
|
24
|
+
#store;
|
|
25
|
+
#registry;
|
|
26
|
+
#config;
|
|
27
|
+
#bridge;
|
|
28
|
+
#log;
|
|
29
|
+
#skills;
|
|
30
|
+
#cron;
|
|
31
|
+
#sleep;
|
|
32
|
+
#canNotify;
|
|
33
|
+
#running = 0;
|
|
34
|
+
#waiting = [];
|
|
35
|
+
/** Cancel hooks of assignments that are queued or running, by assignment id. */
|
|
36
|
+
#active = new Map();
|
|
37
|
+
/** Abort controllers of tasks being run from the board, by task id. */
|
|
38
|
+
#activeTasks = new Map();
|
|
39
|
+
constructor(options) {
|
|
40
|
+
super();
|
|
41
|
+
this.#store = options.store;
|
|
42
|
+
this.#registry = options.registry;
|
|
43
|
+
this.#config = options.config;
|
|
44
|
+
this.#bridge = options.bridge;
|
|
45
|
+
this.#log = options.logger ?? silentLogger;
|
|
46
|
+
this.#skills = new SkillStore(options.config.skillsDir);
|
|
47
|
+
this.#cron = options.cron;
|
|
48
|
+
this.#sleep = options.sleep;
|
|
49
|
+
this.#canNotify = options.canNotify;
|
|
50
|
+
}
|
|
51
|
+
get bridge() {
|
|
52
|
+
return this.#bridge;
|
|
53
|
+
}
|
|
54
|
+
/* ------------------------------ structure ------------------------------ */
|
|
55
|
+
/** The company the assistant runs. Created on first use so there is always one. */
|
|
56
|
+
activeOrganization() {
|
|
57
|
+
const wanted = this.#config.org.activeOrganizationId;
|
|
58
|
+
if (wanted) {
|
|
59
|
+
const chosen = this.#store.org.getOrganization(wanted);
|
|
60
|
+
if (chosen)
|
|
61
|
+
return chosen;
|
|
62
|
+
}
|
|
63
|
+
const existing = this.#store.org.listOrganizations()[0];
|
|
64
|
+
if (existing)
|
|
65
|
+
return existing;
|
|
66
|
+
return this.#store.org.createOrganization({
|
|
67
|
+
name: (this.#config.assistantName || 'Rookery') + ' & Co.',
|
|
68
|
+
mission: 'The personal assistant company.',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
snapshot(orgId) {
|
|
72
|
+
const organization = this.#store.org.getOrganization(orgId);
|
|
73
|
+
if (!organization)
|
|
74
|
+
throw new Error('Unknown organization ' + orgId);
|
|
75
|
+
return {
|
|
76
|
+
organization,
|
|
77
|
+
teams: this.#store.org.listTeams(orgId),
|
|
78
|
+
agents: this.#store.org.listAgents(orgId),
|
|
79
|
+
projects: this.#store.org.listProjects(orgId),
|
|
80
|
+
active: this.#store.org.listAssignments(orgId, { status: ['pending', 'running'], limit: 50 }),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Register a provider process with the bridge and hand back its token. */
|
|
84
|
+
register(context) {
|
|
85
|
+
return this.#bridge.register(toolsFor(context.audience), this.handler(context));
|
|
86
|
+
}
|
|
87
|
+
unregister(token) {
|
|
88
|
+
this.#bridge.unregister(token);
|
|
89
|
+
}
|
|
90
|
+
handler(context) {
|
|
91
|
+
return (name, args) => this.handle(context, name, args);
|
|
92
|
+
}
|
|
93
|
+
/* -------------------------------- tools -------------------------------- */
|
|
94
|
+
async handle(context, name, args) {
|
|
95
|
+
const text = (key) => (typeof args[key] === 'string' ? args[key].trim() : '');
|
|
96
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
97
|
+
switch (name) {
|
|
98
|
+
case 'org_overview':
|
|
99
|
+
return { text: renderOrgOverview(this.snapshot(context.orgId)) };
|
|
100
|
+
case 'assign':
|
|
101
|
+
return this.#assign(context, text('agent'), text('task'), text('project'), args.wait !== false);
|
|
102
|
+
case 'assignment_status': {
|
|
103
|
+
const assignment = this.findAssignment(context.orgId, text('id'));
|
|
104
|
+
if (!assignment)
|
|
105
|
+
return fail('No assignment with that id.');
|
|
106
|
+
return { text: describeAssignment(assignment, this.#store.org.getAgent(assignment.agentId)) };
|
|
107
|
+
}
|
|
108
|
+
case 'cancel_assignment': {
|
|
109
|
+
if (context.audience !== 'assistant')
|
|
110
|
+
return fail('Only the assistant can cancel assignments.');
|
|
111
|
+
const assignment = this.findAssignment(context.orgId, text('id'));
|
|
112
|
+
if (!assignment)
|
|
113
|
+
return fail('No assignment with that id.');
|
|
114
|
+
if (!this.cancel(assignment.id, 'the assistant')) {
|
|
115
|
+
return fail('Assignment ' + assignment.id.slice(0, 8) + ' is not running; it is ' + assignment.status + '.');
|
|
116
|
+
}
|
|
117
|
+
return { text: 'Cancelling assignment ' + assignment.id.slice(0, 8) + '. It ends as cancelled within a moment.' };
|
|
118
|
+
}
|
|
119
|
+
case 'list_assignments': {
|
|
120
|
+
if (context.audience !== 'assistant')
|
|
121
|
+
return fail('Only the assistant can read the history.');
|
|
122
|
+
const agent = text('agent') ? this.#store.org.findAgent(context.orgId, text('agent')) : null;
|
|
123
|
+
if (text('agent') && !agent)
|
|
124
|
+
return fail('No agent "' + text('agent') + '".');
|
|
125
|
+
const project = text('project') ? this.#store.org.findProject(context.orgId, text('project')) : null;
|
|
126
|
+
if (text('project') && !project)
|
|
127
|
+
return fail('No project "' + text('project') + '".');
|
|
128
|
+
const wanted = text('status').split(',').map((v) => v.trim()).filter(Boolean);
|
|
129
|
+
const limit = clampNumber(args.limit, 1, 200, 20);
|
|
130
|
+
const rows = this.#store.org
|
|
131
|
+
.listAssignments(context.orgId, {
|
|
132
|
+
agentId: agent?.id,
|
|
133
|
+
status: wanted.length ? wanted : undefined,
|
|
134
|
+
limit: project ? 500 : limit,
|
|
135
|
+
})
|
|
136
|
+
.filter((entry) => !project || entry.projectId === project.id)
|
|
137
|
+
.slice(0, limit);
|
|
138
|
+
if (!rows.length)
|
|
139
|
+
return { text: 'No assignments match.' };
|
|
140
|
+
const byId = new Map(this.#store.org.listAgents(context.orgId, { includeArchived: true }).map((entry) => [entry.id, entry]));
|
|
141
|
+
return {
|
|
142
|
+
text: rows
|
|
143
|
+
.map((entry) => {
|
|
144
|
+
const who = byId.get(entry.agentId)?.slug ?? '?';
|
|
145
|
+
const when = new Date(entry.createdAt).toISOString().slice(0, 16).replace('T', ' ');
|
|
146
|
+
const took = entry.durationMs ? ' ' + Math.round(entry.durationMs / 1000) + 's' : '';
|
|
147
|
+
return '- ' + entry.id.slice(0, 8) + ' ' + when + ' ' + entry.status + took + ' ' + who + ': ' +
|
|
148
|
+
shorten(entry.task, 100) + (entry.error ? ' [' + shorten(entry.error, 60) + ']' : '');
|
|
149
|
+
})
|
|
150
|
+
.join('\n'),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
case 'update_project': {
|
|
154
|
+
if (context.audience !== 'assistant')
|
|
155
|
+
return fail('Only the assistant can change projects.');
|
|
156
|
+
const project = this.#store.org.findProject(context.orgId, text('project'));
|
|
157
|
+
if (!project)
|
|
158
|
+
return fail('No project "' + text('project') + '".');
|
|
159
|
+
const patch = {};
|
|
160
|
+
if (text('name'))
|
|
161
|
+
patch.name = text('name');
|
|
162
|
+
if (text('description'))
|
|
163
|
+
patch.description = text('description');
|
|
164
|
+
if (text('path')) {
|
|
165
|
+
if (text('path').toLowerCase() === 'none')
|
|
166
|
+
patch.path = null;
|
|
167
|
+
else if (!existsSync(text('path')))
|
|
168
|
+
return fail('The directory ' + text('path') + ' does not exist.');
|
|
169
|
+
else
|
|
170
|
+
patch.path = text('path');
|
|
171
|
+
}
|
|
172
|
+
if (typeof args.archived === 'boolean')
|
|
173
|
+
patch.archived = args.archived;
|
|
174
|
+
if (!Object.keys(patch).length)
|
|
175
|
+
return fail('Nothing to change.');
|
|
176
|
+
this.#store.org.updateProject(project.id, patch);
|
|
177
|
+
this.emit('changed', { kind: 'project', id: project.id });
|
|
178
|
+
return { text: 'Updated project "' + (patch.name ?? project.name) + '": ' + Object.keys(patch).join(', ') + '.' };
|
|
179
|
+
}
|
|
180
|
+
case 'sleep_now': {
|
|
181
|
+
if (context.audience !== 'assistant')
|
|
182
|
+
return fail('Only the assistant has this memory.');
|
|
183
|
+
if (!this.#sleep)
|
|
184
|
+
return fail('The nightly memory run is not available here.');
|
|
185
|
+
if (this.#sleep.isRunning(ASSISTANT_MEMORY_OWNER))
|
|
186
|
+
return { text: 'The memory is already asleep.' };
|
|
187
|
+
// Started, not awaited: a night takes minutes and the turn must not
|
|
188
|
+
// sit and wait for it. The memory page follows it live.
|
|
189
|
+
void this.#sleep.run({ owner: ASSISTANT_MEMORY_OWNER, trigger: 'manual' });
|
|
190
|
+
return {
|
|
191
|
+
text: 'The memory is going to sleep now. It condenses, files and connects; nothing is deleted, ' +
|
|
192
|
+
'and the run can be undone on the memory page.',
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
case 'read_profile': {
|
|
196
|
+
if (context.audience !== 'assistant')
|
|
197
|
+
return fail('Only the assistant has this profile.');
|
|
198
|
+
return { text: readProfileExcerpt(this.#config, text('name'), args.offset === undefined ? 0 : Number(args.offset), args.limit === undefined ? 12000 : Number(args.limit)) };
|
|
199
|
+
}
|
|
200
|
+
case 'search_profile': {
|
|
201
|
+
if (context.audience !== 'assistant')
|
|
202
|
+
return fail('Only the assistant has this profile.');
|
|
203
|
+
return { text: searchProfile(this.#config, text('query')) };
|
|
204
|
+
}
|
|
205
|
+
case 'remember': {
|
|
206
|
+
if (context.audience !== 'assistant')
|
|
207
|
+
return fail('Only the assistant has this memory.');
|
|
208
|
+
if (!text('content'))
|
|
209
|
+
return fail('A memory needs content.');
|
|
210
|
+
const tags = text('tags').split(',').map((v) => v.trim()).filter(Boolean);
|
|
211
|
+
const record = this.#store.upsertMemory({
|
|
212
|
+
kind: asMemoryKind(text('kind')),
|
|
213
|
+
content: text('content'),
|
|
214
|
+
tags,
|
|
215
|
+
importance: clampNumber(args.importance, 0, 1, 0.7),
|
|
216
|
+
owner: ASSISTANT_MEMORY_OWNER,
|
|
217
|
+
sourceSessionId: context.sessionId,
|
|
218
|
+
// Asked for explicitly, so the night never merges it away.
|
|
219
|
+
origin: 'user',
|
|
220
|
+
});
|
|
221
|
+
linkEntities(this.#store, ASSISTANT_MEMORY_OWNER, record.id, tags);
|
|
222
|
+
this.emit('changed', { kind: 'memory', id: record.id });
|
|
223
|
+
return { text: 'Remembered (' + record.id.slice(0, 8) + '): ' + record.content };
|
|
224
|
+
}
|
|
225
|
+
case 'forget': {
|
|
226
|
+
if (context.audience !== 'assistant')
|
|
227
|
+
return fail('Only the assistant has this memory.');
|
|
228
|
+
const ref = text('id');
|
|
229
|
+
if (!ref)
|
|
230
|
+
return fail('Which memory? Give its id.');
|
|
231
|
+
const record = this.#store.getMemory(ref) ??
|
|
232
|
+
this.#store.listMemories({ owner: ASSISTANT_MEMORY_OWNER, limit: 1000 }).find((m) => m.id.startsWith(ref));
|
|
233
|
+
if (!record || record.owner !== ASSISTANT_MEMORY_OWNER)
|
|
234
|
+
return fail('No memory ' + ref + '.');
|
|
235
|
+
this.#store.forgetMemory(record.id);
|
|
236
|
+
this.emit('changed', { kind: 'memory', id: record.id });
|
|
237
|
+
return { text: 'Forgotten: ' + record.content };
|
|
238
|
+
}
|
|
239
|
+
case 'search_memory': {
|
|
240
|
+
if (context.audience !== 'assistant')
|
|
241
|
+
return fail('Only the assistant has this memory.');
|
|
242
|
+
const limit = clampNumber(args.limit, 1, 100, 20);
|
|
243
|
+
const query = text('query');
|
|
244
|
+
const rows = query
|
|
245
|
+
? recall(this.#store, { text: query, limit, owner: ASSISTANT_MEMORY_OWNER, touch: false })
|
|
246
|
+
: this.#store.listMemories({ owner: ASSISTANT_MEMORY_OWNER, limit });
|
|
247
|
+
if (!rows.length)
|
|
248
|
+
return { text: query ? 'Nothing in memory matches.' : 'Memory is empty.' };
|
|
249
|
+
return {
|
|
250
|
+
text: rows
|
|
251
|
+
.map((m) => '- ' + m.id.slice(0, 8) + ' [' + m.kind + ', ' + m.importance.toFixed(2) + '] ' + m.content)
|
|
252
|
+
.join('\n'),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
case 'get_settings':
|
|
256
|
+
if (context.audience !== 'assistant')
|
|
257
|
+
return fail('Only the assistant can read settings.');
|
|
258
|
+
return { text: describeSettings(this.#config) };
|
|
259
|
+
case 'update_settings':
|
|
260
|
+
return this.#updateSettings(context, args);
|
|
261
|
+
case 'send_message':
|
|
262
|
+
return this.#sendMessage(context, text('to'), text('content'));
|
|
263
|
+
case 'read_inbox': {
|
|
264
|
+
const messages = this.#store.org.inbox(context.orgId, context.agentId ?? null, { unreadOnly: true });
|
|
265
|
+
if (!messages.length)
|
|
266
|
+
return { text: 'No unread messages.' };
|
|
267
|
+
this.#store.org.markRead(messages.map((message) => message.id));
|
|
268
|
+
const byId = new Map(this.#store.org.listAgents(context.orgId, { includeArchived: true }).map((agent) => [agent.id, agent]));
|
|
269
|
+
return {
|
|
270
|
+
text: messages
|
|
271
|
+
.map((message) => {
|
|
272
|
+
const from = message.fromAgentId ? (byId.get(message.fromAgentId)?.slug ?? 'unknown') : 'assistant';
|
|
273
|
+
return '- [' + new Date(message.createdAt).toISOString() + '] from ' + from + ': ' + message.content;
|
|
274
|
+
})
|
|
275
|
+
.join('\n'),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
case 'notify': {
|
|
279
|
+
if (context.audience !== 'assistant')
|
|
280
|
+
return fail('Only the assistant can send notifications.');
|
|
281
|
+
if (!text('text'))
|
|
282
|
+
return fail('A notification needs text.');
|
|
283
|
+
if (!this.#canNotify || !this.#canNotify()) {
|
|
284
|
+
return fail('No notification channel can reach the user right now - none is set up, it is ' +
|
|
285
|
+
'switched off, or it has no recipient. Nothing was sent.');
|
|
286
|
+
}
|
|
287
|
+
const urgency = args.urgency === 'high' ? 'high' : 'normal';
|
|
288
|
+
const event = { text: text('text'), urgency, at: Date.now() };
|
|
289
|
+
this.emit('notify', event);
|
|
290
|
+
return { text: 'Sent' + (urgency === 'high' ? ' (high urgency)' : '') + ': ' + event.text };
|
|
291
|
+
}
|
|
292
|
+
case 'use_skill': {
|
|
293
|
+
// An agent's own instructions carry its project's skills too (Befund
|
|
294
|
+
// 4 in the concept doc): the tool must resolve against the running
|
|
295
|
+
// assignment's project, not only the one long-lived home store.
|
|
296
|
+
const project = context.audience === 'agent' && context.projectId ? this.#store.org.getProject(context.projectId) : null;
|
|
297
|
+
const skills = context.audience === 'agent' ? this.#agentSkills(project) : this.#skills.for('assistant');
|
|
298
|
+
const skill = skills.find((entry) => entry.name === text('name').toLowerCase());
|
|
299
|
+
if (!skill)
|
|
300
|
+
return fail('No skill "' + text('name') + '". The list in your instructions is authoritative.');
|
|
301
|
+
return { text: renderSkill(skill) };
|
|
302
|
+
}
|
|
303
|
+
case 'project_mcp_servers': {
|
|
304
|
+
if (context.audience !== 'assistant')
|
|
305
|
+
return fail('Only the assistant reviews project MCP servers.');
|
|
306
|
+
const project = this.#store.org.findProject(context.orgId, text('project'));
|
|
307
|
+
if (!project)
|
|
308
|
+
return fail('No project "' + text('project') + '".');
|
|
309
|
+
if (!project.path)
|
|
310
|
+
return fail('Project "' + project.name + '" has no directory.');
|
|
311
|
+
const file = readProjectMcpFile(project.path);
|
|
312
|
+
if (!file || !file.servers.length)
|
|
313
|
+
return { text: "No MCP servers in this project's .mcp.json." };
|
|
314
|
+
const status = projectMcpStatus(file, project.mcpTrust);
|
|
315
|
+
return {
|
|
316
|
+
text: 'Status: ' + status + '.\n' +
|
|
317
|
+
renderProjectMcpServers(file.servers) +
|
|
318
|
+
(status === 'trusted' ? '' : '\nUse trust_project_mcp to approve before these start for an assignment.'),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
case 'trust_project_mcp': {
|
|
322
|
+
if (context.audience !== 'assistant')
|
|
323
|
+
return fail('Only the assistant decides project trust.');
|
|
324
|
+
const project = this.#store.org.findProject(context.orgId, text('project'));
|
|
325
|
+
if (!project)
|
|
326
|
+
return fail('No project "' + text('project') + '".');
|
|
327
|
+
const decision = text('decision');
|
|
328
|
+
if (decision !== 'approve' && decision !== 'revoke')
|
|
329
|
+
return fail('decision must be approve or revoke.');
|
|
330
|
+
if (decision === 'revoke') {
|
|
331
|
+
this.#store.org.updateProject(project.id, { mcpTrust: null });
|
|
332
|
+
this.emit('changed', { kind: 'project', id: project.id });
|
|
333
|
+
return { text: 'Revoked trust for "' + project.name + '"; its MCP servers no longer start for assignments.' };
|
|
334
|
+
}
|
|
335
|
+
if (!project.path)
|
|
336
|
+
return fail('Project "' + project.name + '" has no directory.');
|
|
337
|
+
const file = readProjectMcpFile(project.path);
|
|
338
|
+
if (!file || !file.servers.length)
|
|
339
|
+
return fail("No MCP servers in this project's .mcp.json.");
|
|
340
|
+
this.#store.org.updateProject(project.id, {
|
|
341
|
+
mcpTrust: { fingerprint: fingerprintMcpFile(file.raw), approvedAt: Date.now() },
|
|
342
|
+
});
|
|
343
|
+
this.emit('changed', { kind: 'project', id: project.id });
|
|
344
|
+
return {
|
|
345
|
+
text: 'Trusted "' + project.name + '": ' + file.servers.length +
|
|
346
|
+
' MCP server(s) start for its assignments from now on.',
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
case 'tool_servers':
|
|
350
|
+
if (context.audience !== 'assistant')
|
|
351
|
+
return fail('Only the assistant sees the hub.');
|
|
352
|
+
return { text: renderToolServers(toolServerStates(this.#config)) };
|
|
353
|
+
case 'set_tool_server': {
|
|
354
|
+
if (context.audience !== 'assistant')
|
|
355
|
+
return fail('Only the assistant can switch tools.');
|
|
356
|
+
const state = toolServerStates(this.#config).find((entry) => entry.id === text('id'));
|
|
357
|
+
if (!state)
|
|
358
|
+
return fail('No tool server "' + text('id') + '".');
|
|
359
|
+
if (typeof args.enabled !== 'boolean')
|
|
360
|
+
return fail('enabled must be true or false.');
|
|
361
|
+
if (args.enabled && !state.installed)
|
|
362
|
+
return fail(state.name + ' is not installed on this machine.');
|
|
363
|
+
if (args.enabled && state.missingEnv.length) {
|
|
364
|
+
return fail(state.name + ' needs ' + state.missingEnv.join(', ') + ' first; the user sets that on the Tools page.');
|
|
365
|
+
}
|
|
366
|
+
const audience = text('audience');
|
|
367
|
+
const tools = withToolServer(this.#config, state.id, {
|
|
368
|
+
enabled: args.enabled,
|
|
369
|
+
...(audience === 'assistant' || audience === 'agents' || audience === 'both' ? { audience } : {}),
|
|
370
|
+
});
|
|
371
|
+
applyConfig(this.#config, { tools });
|
|
372
|
+
this.emit('changed', { kind: 'tools', id: state.id });
|
|
373
|
+
return {
|
|
374
|
+
text: state.name + ' is now ' + (args.enabled ? 'on' : 'off') + ' for ' + (audience || state.audience) + '. ' +
|
|
375
|
+
(args.enabled
|
|
376
|
+
? 'Finish this answer and it is attached; the turn then carries on and you can use it.'
|
|
377
|
+
: 'It is gone from the next turn on.'),
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
case 'hire_agent': {
|
|
381
|
+
if (context.audience !== 'assistant')
|
|
382
|
+
return fail('Only the assistant can hire.');
|
|
383
|
+
const team = text('team') ? this.#store.org.findTeam(context.orgId, text('team')) : null;
|
|
384
|
+
if (text('team') && !team)
|
|
385
|
+
return fail('No team "' + text('team') + '". Create it first.');
|
|
386
|
+
const manager = text('manager') ? this.#store.org.findAgent(context.orgId, text('manager')) : null;
|
|
387
|
+
if (text('manager') && !manager)
|
|
388
|
+
return fail('No agent "' + text('manager') + '" to report to.');
|
|
389
|
+
const agent = this.#store.org.createAgent({
|
|
390
|
+
orgId: context.orgId,
|
|
391
|
+
slug: text('slug') || undefined,
|
|
392
|
+
name: text('name'),
|
|
393
|
+
title: text('title'),
|
|
394
|
+
instructions: text('instructions'),
|
|
395
|
+
teamId: team?.id,
|
|
396
|
+
managerId: manager?.id,
|
|
397
|
+
provider: asProvider(text('provider')),
|
|
398
|
+
model: text('model') || undefined,
|
|
399
|
+
permission: asPermission(text('permission')),
|
|
400
|
+
});
|
|
401
|
+
this.emit('changed', { kind: 'agent', id: agent.id });
|
|
402
|
+
return { text: 'Hired ' + agent.name + ' as ' + agent.title + ' (slug: ' + agent.slug + ').' };
|
|
403
|
+
}
|
|
404
|
+
case 'create_team': {
|
|
405
|
+
if (context.audience !== 'assistant')
|
|
406
|
+
return fail('Only the assistant can create teams.');
|
|
407
|
+
const lead = text('lead') ? this.#store.org.findAgent(context.orgId, text('lead')) : null;
|
|
408
|
+
if (text('lead') && !lead)
|
|
409
|
+
return fail('No agent "' + text('lead') + '" to lead the team.');
|
|
410
|
+
const team = this.#store.org.createTeam({
|
|
411
|
+
orgId: context.orgId,
|
|
412
|
+
name: text('name'),
|
|
413
|
+
purpose: text('purpose') || undefined,
|
|
414
|
+
leadId: lead?.id,
|
|
415
|
+
});
|
|
416
|
+
this.emit('changed', { kind: 'team', id: team.id });
|
|
417
|
+
return { text: 'Created team "' + team.name + '" (id: ' + team.id + ').' };
|
|
418
|
+
}
|
|
419
|
+
case 'create_project': {
|
|
420
|
+
if (context.audience !== 'assistant')
|
|
421
|
+
return fail('Only the assistant can create projects.');
|
|
422
|
+
const path = text('path') || undefined;
|
|
423
|
+
if (path && !existsSync(path))
|
|
424
|
+
return fail('The directory ' + path + ' does not exist.');
|
|
425
|
+
const project = this.#store.org.createProject({
|
|
426
|
+
orgId: context.orgId,
|
|
427
|
+
name: text('name'),
|
|
428
|
+
description: text('description') || undefined,
|
|
429
|
+
path,
|
|
430
|
+
});
|
|
431
|
+
this.emit('changed', { kind: 'project', id: project.id });
|
|
432
|
+
return { text: 'Created project "' + project.name + '" (id: ' + project.id + ').' };
|
|
433
|
+
}
|
|
434
|
+
case 'update_agent':
|
|
435
|
+
return this.#updateAgent(context, args);
|
|
436
|
+
case 'update_team':
|
|
437
|
+
return this.#updateTeam(context, args);
|
|
438
|
+
case 'create_task': {
|
|
439
|
+
if (!text('title') || !text('description'))
|
|
440
|
+
return fail('A task needs a title and a description.');
|
|
441
|
+
const project = text('project') ? this.#store.org.findProject(context.orgId, text('project')) : null;
|
|
442
|
+
if (text('project') && !project)
|
|
443
|
+
return fail('No project "' + text('project') + '".');
|
|
444
|
+
const assignee = text('assignee') ? this.#store.org.findAgent(context.orgId, text('assignee')) : null;
|
|
445
|
+
if (text('assignee') && !assignee)
|
|
446
|
+
return fail('No agent "' + text('assignee') + '".');
|
|
447
|
+
const task = this.#store.org.createTask({
|
|
448
|
+
orgId: context.orgId,
|
|
449
|
+
title: text('title'),
|
|
450
|
+
description: text('description'),
|
|
451
|
+
projectId: project?.id ?? context.projectId,
|
|
452
|
+
priority: asPriority(text('priority')),
|
|
453
|
+
assigneeId: assignee?.id,
|
|
454
|
+
createdBy: context.audience === 'agent' ? 'agent' : 'assistant',
|
|
455
|
+
createdByAgentId: context.agentId,
|
|
456
|
+
});
|
|
457
|
+
this.#announceTask(task, context.emit);
|
|
458
|
+
return { text: 'Task ' + task.id.slice(0, 8) + ' "' + task.title + '" is on the board.' };
|
|
459
|
+
}
|
|
460
|
+
case 'list_tasks': {
|
|
461
|
+
const wanted = text('status').split(',').map((v) => v.trim()).filter(Boolean);
|
|
462
|
+
const tasks = this.#store.org.listTasks(context.orgId, { status: wanted.length ? wanted : undefined });
|
|
463
|
+
return { text: renderBoard(tasks, this.snapshot(context.orgId), this.#store.org) };
|
|
464
|
+
}
|
|
465
|
+
case 'update_task':
|
|
466
|
+
return this.#updateTask(context, args);
|
|
467
|
+
case 'plan_task': {
|
|
468
|
+
const task = this.findTask(context.orgId, text('id'));
|
|
469
|
+
if (!task)
|
|
470
|
+
return fail('No task ' + text('id') + '.');
|
|
471
|
+
const plan = await this.planTask(context, task, text('hint') || undefined);
|
|
472
|
+
return { text: describePlan(plan, this.#store.org.listTasks(context.orgId, { parentId: task.id })) };
|
|
473
|
+
}
|
|
474
|
+
case 'run_task': {
|
|
475
|
+
const task = this.findTask(context.orgId, text('id'));
|
|
476
|
+
if (!task)
|
|
477
|
+
return fail('No task ' + text('id') + '.');
|
|
478
|
+
const finished = await this.runTask(context, task);
|
|
479
|
+
if (finished.status !== 'done') {
|
|
480
|
+
return fail('Task "' + finished.title + '" ' + finished.status + (finished.error ? ': ' + finished.error : '.'));
|
|
481
|
+
}
|
|
482
|
+
return { text: 'Task "' + finished.title + '" is done.\n\n' + clip(finished.result ?? '', RESULT_BUDGET) };
|
|
483
|
+
}
|
|
484
|
+
case 'list_schedules':
|
|
485
|
+
case 'create_schedule':
|
|
486
|
+
case 'update_schedule':
|
|
487
|
+
case 'delete_schedule':
|
|
488
|
+
case 'run_schedule':
|
|
489
|
+
return this.#schedules(context, name, args);
|
|
490
|
+
default:
|
|
491
|
+
return fail('Unknown tool ' + name + '.');
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
/* ------------------------------- schedules ------------------------------ */
|
|
495
|
+
/** The schedule tools: thin validation around the clock, with agents and projects resolved by name. */
|
|
496
|
+
#schedules(context, name, args) {
|
|
497
|
+
const text = (key) => (typeof args[key] === 'string' ? args[key].trim() : '');
|
|
498
|
+
const flag = (key) => (typeof args[key] === 'boolean' ? args[key] : undefined);
|
|
499
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
500
|
+
const cron = this.#cron;
|
|
501
|
+
if (!cron)
|
|
502
|
+
return fail('Schedules are not available in this session.');
|
|
503
|
+
const snapshot = this.snapshot(context.orgId);
|
|
504
|
+
const bySlug = new Map(snapshot.agents.map((agent) => [agent.id, agent.slug]));
|
|
505
|
+
const line = (job) => describeCronJob(job, job.agentId ? bySlug.get(job.agentId) : undefined);
|
|
506
|
+
if (name === 'list_schedules') {
|
|
507
|
+
return { text: renderSchedules(cron.list(context.orgId), snapshot) };
|
|
508
|
+
}
|
|
509
|
+
if (name === 'create_schedule') {
|
|
510
|
+
if (!text('name') || !text('schedule') || !text('prompt')) {
|
|
511
|
+
return fail('A schedule needs a name, a cron expression and a prompt.');
|
|
512
|
+
}
|
|
513
|
+
const agent = text('agent') ? this.#store.org.findAgent(context.orgId, text('agent')) : null;
|
|
514
|
+
if (text('agent') && !agent)
|
|
515
|
+
return fail('No agent "' + text('agent') + '".');
|
|
516
|
+
const project = text('project') ? this.#store.org.findProject(context.orgId, text('project')) : null;
|
|
517
|
+
if (text('project') && !project)
|
|
518
|
+
return fail('No project "' + text('project') + '".');
|
|
519
|
+
try {
|
|
520
|
+
const job = cron.create({
|
|
521
|
+
orgId: context.orgId,
|
|
522
|
+
name: text('name'),
|
|
523
|
+
schedule: text('schedule'),
|
|
524
|
+
prompt: text('prompt'),
|
|
525
|
+
kind: agent ? 'agent' : 'assistant',
|
|
526
|
+
agentId: agent?.id,
|
|
527
|
+
projectId: project?.id ?? context.projectId,
|
|
528
|
+
once: flag('once'),
|
|
529
|
+
enabled: flag('enabled'),
|
|
530
|
+
createdBy: 'assistant',
|
|
531
|
+
});
|
|
532
|
+
return { text: 'Schedule created: ' + describeCron(job.schedule) + '.\n' + line(job) };
|
|
533
|
+
}
|
|
534
|
+
catch (error) {
|
|
535
|
+
return fail(error.message);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
const job = cron.find(context.orgId, text('id'));
|
|
539
|
+
if (!job)
|
|
540
|
+
return fail('No schedule "' + text('id') + '". list_schedules shows the ids.');
|
|
541
|
+
if (name === 'delete_schedule') {
|
|
542
|
+
cron.remove(job.id);
|
|
543
|
+
return { text: 'Deleted schedule "' + job.name + '".' };
|
|
544
|
+
}
|
|
545
|
+
if (name === 'run_schedule') {
|
|
546
|
+
if (cron.isRunning(job.id))
|
|
547
|
+
return { text: 'Schedule "' + job.name + '" is already running.' };
|
|
548
|
+
void cron.runNow(job.id).catch((error) => this.#log.warn('Manual schedule run failed', { error: error.message }));
|
|
549
|
+
return { text: 'Schedule "' + job.name + '" is running now; the result will arrive in your inbox.' };
|
|
550
|
+
}
|
|
551
|
+
// update_schedule
|
|
552
|
+
const patch = {};
|
|
553
|
+
if (text('name'))
|
|
554
|
+
patch.name = text('name');
|
|
555
|
+
if (text('schedule'))
|
|
556
|
+
patch.schedule = text('schedule');
|
|
557
|
+
if (text('prompt'))
|
|
558
|
+
patch.prompt = text('prompt');
|
|
559
|
+
if (text('agent')) {
|
|
560
|
+
const wanted = text('agent').toLowerCase();
|
|
561
|
+
if (wanted === 'assistant' || wanted === 'me' || wanted === 'none')
|
|
562
|
+
patch.agentId = null;
|
|
563
|
+
else {
|
|
564
|
+
const agent = this.#store.org.findAgent(context.orgId, text('agent'));
|
|
565
|
+
if (!agent)
|
|
566
|
+
return fail('No agent "' + text('agent') + '".');
|
|
567
|
+
patch.agentId = agent.id;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (text('project')) {
|
|
571
|
+
if (text('project').toLowerCase() === 'none')
|
|
572
|
+
patch.projectId = null;
|
|
573
|
+
else {
|
|
574
|
+
const project = this.#store.org.findProject(context.orgId, text('project'));
|
|
575
|
+
if (!project)
|
|
576
|
+
return fail('No project "' + text('project') + '".');
|
|
577
|
+
patch.projectId = project.id;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
if (flag('enabled') !== undefined)
|
|
581
|
+
patch.enabled = flag('enabled');
|
|
582
|
+
if (flag('once') !== undefined)
|
|
583
|
+
patch.once = flag('once');
|
|
584
|
+
if (!Object.keys(patch).length)
|
|
585
|
+
return fail('Nothing to change; pass at least one field.');
|
|
586
|
+
try {
|
|
587
|
+
const updated = cron.update(job.id, patch);
|
|
588
|
+
return { text: 'Updated schedule "' + updated.name + '": ' + Object.keys(patch).join(', ') + '.\n' + line(updated) };
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
return fail(error.message);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
async #assign(context, agentRef, task, projectRef, wait = true) {
|
|
595
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
596
|
+
if (!agentRef)
|
|
597
|
+
return fail('Name the agent to assign to.');
|
|
598
|
+
if (!task)
|
|
599
|
+
return fail('The task is empty.');
|
|
600
|
+
const agent = this.#store.org.findAgent(context.orgId, agentRef);
|
|
601
|
+
if (!agent) {
|
|
602
|
+
const known = this.#store.org.listAgents(context.orgId).map((entry) => entry.slug);
|
|
603
|
+
return fail('No agent "' + agentRef + '". ' +
|
|
604
|
+
(known.length ? 'Known agents: ' + known.join(', ') + '.' : 'Nobody is hired yet.'));
|
|
605
|
+
}
|
|
606
|
+
if (context.audience === 'agent') {
|
|
607
|
+
if (agent.id === context.agentId)
|
|
608
|
+
return fail('You cannot assign work to yourself.');
|
|
609
|
+
if (agent.managerId !== context.agentId) {
|
|
610
|
+
const reports = this.#store.org.listAgents(context.orgId, { managerId: context.agentId }).map((r) => r.slug);
|
|
611
|
+
return fail('You may only assign work to your direct reports' +
|
|
612
|
+
(reports.length ? ': ' + reports.join(', ') : ', and you have none') + '.');
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
const depth = context.depth + 1;
|
|
616
|
+
if (depth >= this.#config.org.maxDelegationDepth) {
|
|
617
|
+
return fail('Delegation is nested too deep already. Do this part of the work yourself.');
|
|
618
|
+
}
|
|
619
|
+
let projectId = context.projectId;
|
|
620
|
+
if (projectRef) {
|
|
621
|
+
const project = this.#store.org.findProject(context.orgId, projectRef);
|
|
622
|
+
if (!project)
|
|
623
|
+
return fail('No project "' + projectRef + '".');
|
|
624
|
+
projectId = project.id;
|
|
625
|
+
}
|
|
626
|
+
const runInput = {
|
|
627
|
+
orgId: context.orgId,
|
|
628
|
+
agent,
|
|
629
|
+
task,
|
|
630
|
+
projectId,
|
|
631
|
+
sessionId: context.sessionId,
|
|
632
|
+
parentId: context.parentAssignmentId,
|
|
633
|
+
requesterKind: context.audience === 'agent' ? 'agent' : 'assistant',
|
|
634
|
+
requesterAgentId: context.agentId,
|
|
635
|
+
depth,
|
|
636
|
+
};
|
|
637
|
+
if (!wait) {
|
|
638
|
+
// Detached: the turn ends while the agent works. Its progress reaches
|
|
639
|
+
// every socket through the org-level assignment events; the turn's own
|
|
640
|
+
// stream and abort signal must not be tied to it.
|
|
641
|
+
const started = this.run({ ...runInput, emit: () => undefined });
|
|
642
|
+
started.catch((error) => {
|
|
643
|
+
this.#log.warn('Detached assignment failed', { agent: agent.slug, error: String(error) });
|
|
644
|
+
});
|
|
645
|
+
return {
|
|
646
|
+
text: 'Handed to ' + agent.name + ' (' + agent.slug + '). The assignment runs in the background; ' +
|
|
647
|
+
'assignment_status reports on it, and the user is told when it finishes.',
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
const assignment = await this.run({
|
|
651
|
+
...runInput,
|
|
652
|
+
emit: context.emit,
|
|
653
|
+
signal: context.signal,
|
|
654
|
+
});
|
|
655
|
+
if (assignment.status !== 'done') {
|
|
656
|
+
return fail('Assignment ' + assignment.id.slice(0, 8) + ' to ' + agent.slug + ' ' + assignment.status +
|
|
657
|
+
(assignment.error ? ': ' + assignment.error : '.'));
|
|
658
|
+
}
|
|
659
|
+
return {
|
|
660
|
+
text: 'Report from ' + agent.name + ' (' + agent.slug + '), assignment ' + assignment.id.slice(0, 8) +
|
|
661
|
+
', ' + Math.round((assignment.durationMs ?? 0) / 1000) + ' s:\n\n' +
|
|
662
|
+
clip(assignment.result ?? '', RESULT_BUDGET),
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
async #sendMessage(context, to, content) {
|
|
666
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
667
|
+
if (!content)
|
|
668
|
+
return fail('The message is empty.');
|
|
669
|
+
let toAgentId;
|
|
670
|
+
if (to && to.toLowerCase() !== 'assistant') {
|
|
671
|
+
const recipient = this.#store.org.findAgent(context.orgId, to);
|
|
672
|
+
if (!recipient)
|
|
673
|
+
return fail('No agent "' + to + '".');
|
|
674
|
+
if (context.audience === 'agent') {
|
|
675
|
+
const self = context.agentId ? this.#store.org.getAgent(context.agentId) : null;
|
|
676
|
+
const allowed = recipient.id === self?.managerId ||
|
|
677
|
+
recipient.managerId === context.agentId ||
|
|
678
|
+
(Boolean(self?.teamId) && recipient.teamId === self?.teamId);
|
|
679
|
+
if (!allowed)
|
|
680
|
+
return fail('You may message your manager, your team, your reports, or the assistant.');
|
|
681
|
+
}
|
|
682
|
+
toAgentId = recipient.id;
|
|
683
|
+
}
|
|
684
|
+
const message = this.#store.org.postMessage({
|
|
685
|
+
orgId: context.orgId,
|
|
686
|
+
fromAgentId: context.agentId,
|
|
687
|
+
toAgentId,
|
|
688
|
+
assignmentId: context.parentAssignmentId,
|
|
689
|
+
content,
|
|
690
|
+
});
|
|
691
|
+
this.#announce({ type: 'message', message }, context.emit);
|
|
692
|
+
return { text: 'Message left for ' + (toAgentId ? to : 'the assistant') + '.' };
|
|
693
|
+
}
|
|
694
|
+
/** Emit into the turn that caused an event, and to everyone listening on the controller. */
|
|
695
|
+
#announce(event, emit) {
|
|
696
|
+
emit(event);
|
|
697
|
+
this.emit(event.type, event);
|
|
698
|
+
}
|
|
699
|
+
/* ------------------------------ execution ------------------------------ */
|
|
700
|
+
/**
|
|
701
|
+
* Run one assignment to completion: a fresh provider process with the
|
|
702
|
+
* agent's own prompt, memory, inbox and tools. Never throws; the returned
|
|
703
|
+
* record says how it ended. Events flow to `input.emit` as they happen.
|
|
704
|
+
*/
|
|
705
|
+
async run(input) {
|
|
706
|
+
const { agent } = input;
|
|
707
|
+
const org = this.#store.org;
|
|
708
|
+
const project = input.projectId ? org.getProject(input.projectId) : null;
|
|
709
|
+
let assignment = org.createAssignment({
|
|
710
|
+
orgId: input.orgId,
|
|
711
|
+
agentId: agent.id,
|
|
712
|
+
task: input.task,
|
|
713
|
+
projectId: project?.id,
|
|
714
|
+
sessionId: input.sessionId,
|
|
715
|
+
parentId: input.parentId,
|
|
716
|
+
requesterKind: input.requesterKind,
|
|
717
|
+
requesterAgentId: input.requesterAgentId,
|
|
718
|
+
depth: input.depth,
|
|
719
|
+
});
|
|
720
|
+
const view = (extra = {}) => toView(assignment, agent, extra);
|
|
721
|
+
const announce = (extra = {}) => this.#announce({ type: 'assignment', assignment: view(extra) }, input.emit);
|
|
722
|
+
const finish = (patch, extra = {}) => {
|
|
723
|
+
org.updateAssignment(assignment.id, patch);
|
|
724
|
+
assignment = org.getAssignment(assignment.id) ?? assignment;
|
|
725
|
+
announce(extra);
|
|
726
|
+
return assignment;
|
|
727
|
+
};
|
|
728
|
+
const fail = (error, started) => finish({ status: 'failed', error, finishedAt: Date.now(), durationMs: Date.now() - started }, { error });
|
|
729
|
+
// One abort controller per assignment, live from the moment it is queued:
|
|
730
|
+
// the caller going away, a cancel() by id and the timeout all end in it.
|
|
731
|
+
const controller = new AbortController();
|
|
732
|
+
const onAbort = () => controller.abort();
|
|
733
|
+
input.signal?.addEventListener('abort', onAbort, { once: true });
|
|
734
|
+
let cancelledBy = null;
|
|
735
|
+
this.#active.set(assignment.id, (by) => {
|
|
736
|
+
cancelledBy = by;
|
|
737
|
+
controller.abort();
|
|
738
|
+
});
|
|
739
|
+
const cancelled = () => cancelledBy !== null || Boolean(input.signal?.aborted);
|
|
740
|
+
announce();
|
|
741
|
+
await this.#acquire(controller.signal);
|
|
742
|
+
const started = Date.now();
|
|
743
|
+
try {
|
|
744
|
+
if (controller.signal.aborted)
|
|
745
|
+
return finish({ status: 'cancelled', finishedAt: started, durationMs: 0 });
|
|
746
|
+
const providerId = await this.#registry.resolveUsable(agent.provider ?? this.#config.defaultProvider);
|
|
747
|
+
if (!providerId)
|
|
748
|
+
return fail('No provider is logged in.', started);
|
|
749
|
+
const cwd = project?.path || agentWorkspace(this.#config, agent.id);
|
|
750
|
+
if (!existsSync(cwd))
|
|
751
|
+
return fail('The project directory ' + cwd + ' does not exist.', started);
|
|
752
|
+
finish({ status: 'running', provider: providerId, model: agent.model, startedAt: started });
|
|
753
|
+
const snapshot = this.snapshot(input.orgId);
|
|
754
|
+
const memories = this.#memoriesFor(agent.id, input.task);
|
|
755
|
+
const inbox = org.inbox(input.orgId, agent.id, { unreadOnly: true });
|
|
756
|
+
const requester = input.requesterKind === 'agent'
|
|
757
|
+
? (org.getAgent(input.requesterAgentId ?? '')?.name ?? 'your manager')
|
|
758
|
+
: input.requesterKind === 'user'
|
|
759
|
+
? 'the user, directly'
|
|
760
|
+
: 'the assistant';
|
|
761
|
+
await ensureToolServers(this.#config, 'agent', providerId, project?.id, (id, error) => this.#log.warn('Tool server could not prepare', { id, error: error.message }));
|
|
762
|
+
const extra = toolServersFor(this.#config, 'agent', providerId, project?.id);
|
|
763
|
+
// The project's own MCP servers - read from its `.mcp.json`, the same
|
|
764
|
+
// file a person's own session in that folder would read - only start
|
|
765
|
+
// once the assistant has approved this exact file (see
|
|
766
|
+
// trust_project_mcp). Untrusted or changed, they stay off and the
|
|
767
|
+
// agent is told why instead of silently missing tools it expects.
|
|
768
|
+
const projectMcp = project?.path ? readProjectMcpFile(project.path) : null;
|
|
769
|
+
const projectMcpState = projectMcpStatus(projectMcp, project?.mcpTrust);
|
|
770
|
+
const projectMcpSpecs = projectMcpState === 'trusted' && projectMcp ? projectMcp.servers : [];
|
|
771
|
+
const toolHints = [...extra.hints];
|
|
772
|
+
if (projectMcp?.servers.length && projectMcpState !== 'trusted') {
|
|
773
|
+
toolHints.push("This project's .mcp.json lists " + projectMcp.servers.length + ' MCP server(s) not yet trusted' +
|
|
774
|
+
(projectMcpState === 'changed' ? ' (the file changed since it was approved)' : '') +
|
|
775
|
+
'; the assistant can review them with project_mcp_servers and trust_project_mcp.');
|
|
776
|
+
}
|
|
777
|
+
const systemPrompt = buildAgentPrompt({
|
|
778
|
+
config: this.#config,
|
|
779
|
+
agent,
|
|
780
|
+
snapshot,
|
|
781
|
+
project: project ?? undefined,
|
|
782
|
+
memories,
|
|
783
|
+
inbox,
|
|
784
|
+
assignmentId: assignment.id,
|
|
785
|
+
requestedBy: requester,
|
|
786
|
+
toolHints,
|
|
787
|
+
skillsIndex: renderSkillsIndex(this.#agentSkills(project)),
|
|
788
|
+
});
|
|
789
|
+
if (inbox.length)
|
|
790
|
+
org.markRead(inbox.map((message) => message.id));
|
|
791
|
+
const timer = setTimeout(() => controller.abort(), this.#config.org.assignmentTimeoutMs);
|
|
792
|
+
timer.unref?.();
|
|
793
|
+
const token = this.register({
|
|
794
|
+
orgId: input.orgId,
|
|
795
|
+
audience: 'agent',
|
|
796
|
+
agentId: agent.id,
|
|
797
|
+
sessionId: input.sessionId,
|
|
798
|
+
projectId: project?.id,
|
|
799
|
+
parentAssignmentId: assignment.id,
|
|
800
|
+
depth: input.depth,
|
|
801
|
+
emit: input.emit,
|
|
802
|
+
signal: controller.signal,
|
|
803
|
+
});
|
|
804
|
+
let text = '';
|
|
805
|
+
let sinceProgress = 0;
|
|
806
|
+
let fatal = null;
|
|
807
|
+
try {
|
|
808
|
+
const mcp = await this.#bridge.spec(token);
|
|
809
|
+
const mcpExtra = [...extra.specs, ...projectMcpSpecs];
|
|
810
|
+
for await (const event of this.#registry.get(providerId).run({
|
|
811
|
+
prompt: input.task,
|
|
812
|
+
systemPrompt,
|
|
813
|
+
model: agent.model,
|
|
814
|
+
effort: this.#config.defaultEffort,
|
|
815
|
+
cwd,
|
|
816
|
+
permission: agent.permission ?? this.#config.defaultPermission,
|
|
817
|
+
mcp,
|
|
818
|
+
mcpExtra: mcpExtra.length ? mcpExtra : undefined,
|
|
819
|
+
signal: controller.signal,
|
|
820
|
+
})) {
|
|
821
|
+
if (event.type === 'text') {
|
|
822
|
+
text += event.delta;
|
|
823
|
+
sinceProgress += event.delta.length;
|
|
824
|
+
if (sinceProgress >= PROGRESS_EVERY) {
|
|
825
|
+
sinceProgress = 0;
|
|
826
|
+
org.updateAssignment(assignment.id, { chars: text.length });
|
|
827
|
+
announce({ chars: text.length, preview: shorten(tail(text, 160), 110) });
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
else if (event.type === 'tool') {
|
|
831
|
+
input.emit({ ...event, detail: '[' + agent.slug + '] ' + (event.detail ?? '') });
|
|
832
|
+
}
|
|
833
|
+
else if (event.type === 'done') {
|
|
834
|
+
text = event.text || text;
|
|
835
|
+
}
|
|
836
|
+
else if (event.type === 'error' && event.fatal) {
|
|
837
|
+
fatal = event.message;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
catch (error) {
|
|
842
|
+
fatal = error.message;
|
|
843
|
+
}
|
|
844
|
+
finally {
|
|
845
|
+
clearTimeout(timer);
|
|
846
|
+
this.unregister(token);
|
|
847
|
+
}
|
|
848
|
+
if (cancelled()) {
|
|
849
|
+
return finish({ status: 'cancelled', finishedAt: Date.now(), durationMs: Date.now() - started });
|
|
850
|
+
}
|
|
851
|
+
if (controller.signal.aborted)
|
|
852
|
+
return fail('Timed out.', started);
|
|
853
|
+
if (fatal)
|
|
854
|
+
return fail(fatal, started);
|
|
855
|
+
if (!text.trim())
|
|
856
|
+
return fail('The agent produced no output.', started);
|
|
857
|
+
const done = finish({ status: 'done', result: text, chars: text.length, finishedAt: Date.now(), durationMs: Date.now() - started }, { chars: text.length, preview: shorten(tail(text, 160), 110) });
|
|
858
|
+
if (this.#config.memory.enabled && this.#config.memory.autoExtract) {
|
|
859
|
+
void this.#learn(agent, input.task, text, providerId);
|
|
860
|
+
}
|
|
861
|
+
return done;
|
|
862
|
+
}
|
|
863
|
+
catch (error) {
|
|
864
|
+
this.#log.warn('Assignment failed', { id: assignment.id, error: error.message });
|
|
865
|
+
return fail(error.message, started);
|
|
866
|
+
}
|
|
867
|
+
finally {
|
|
868
|
+
this.#active.delete(assignment.id);
|
|
869
|
+
input.signal?.removeEventListener('abort', onAbort);
|
|
870
|
+
this.#release();
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Stop a queued or running assignment. Returns false when nothing by that
|
|
875
|
+
* id is in flight; the record then already says how it ended.
|
|
876
|
+
*/
|
|
877
|
+
cancel(assignmentId, by = 'the user') {
|
|
878
|
+
const hook = this.#active.get(assignmentId);
|
|
879
|
+
if (!hook)
|
|
880
|
+
return false;
|
|
881
|
+
this.#log.info('Assignment cancelled', { id: assignmentId, by });
|
|
882
|
+
hook(by);
|
|
883
|
+
return true;
|
|
884
|
+
}
|
|
885
|
+
/** Stop a task being run from the board, including every assignment it started. */
|
|
886
|
+
cancelTask(taskId) {
|
|
887
|
+
const controller = this.#activeTasks.get(taskId);
|
|
888
|
+
if (!controller)
|
|
889
|
+
return false;
|
|
890
|
+
controller.abort();
|
|
891
|
+
return true;
|
|
892
|
+
}
|
|
893
|
+
/** An assignment by full id or unique prefix, within one company. */
|
|
894
|
+
findAssignment(orgId, ref) {
|
|
895
|
+
const exact = this.#store.org.getAssignment(ref);
|
|
896
|
+
if (exact && exact.orgId === orgId)
|
|
897
|
+
return exact;
|
|
898
|
+
if (ref.length < 4)
|
|
899
|
+
return null;
|
|
900
|
+
const matches = this.#store.org
|
|
901
|
+
.listAssignments(orgId, { limit: 500 })
|
|
902
|
+
.filter((entry) => entry.id.startsWith(ref));
|
|
903
|
+
return matches.length === 1 ? (matches[0] ?? null) : null;
|
|
904
|
+
}
|
|
905
|
+
/* ------------------------------- settings ------------------------------- */
|
|
906
|
+
#updateSettings(context, args) {
|
|
907
|
+
const text = (key) => (typeof args[key] === 'string' ? args[key].trim() : '');
|
|
908
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
909
|
+
if (context.audience !== 'assistant')
|
|
910
|
+
return fail('Only the assistant can change settings.');
|
|
911
|
+
const patch = {};
|
|
912
|
+
if (text('defaultProvider')) {
|
|
913
|
+
const provider = asProvider(text('defaultProvider'));
|
|
914
|
+
if (!provider)
|
|
915
|
+
return fail('Provider must be claude or codex.');
|
|
916
|
+
patch.defaultProvider = provider;
|
|
917
|
+
}
|
|
918
|
+
// An empty string clears a setting: the merge skips undefined, and
|
|
919
|
+
// loadConfig turns '' back into "unset".
|
|
920
|
+
if (text('defaultModel'))
|
|
921
|
+
patch.defaultModel = text('defaultModel') === 'default' ? '' : text('defaultModel');
|
|
922
|
+
if (text('defaultEffort')) {
|
|
923
|
+
const effort = text('defaultEffort');
|
|
924
|
+
if (effort === 'default')
|
|
925
|
+
patch.defaultEffort = '';
|
|
926
|
+
else if (EFFORT_LEVELS.includes(effort))
|
|
927
|
+
patch.defaultEffort = effort;
|
|
928
|
+
else
|
|
929
|
+
return fail('Effort must be one of ' + EFFORT_LEVELS.join(', ') + ', or default.');
|
|
930
|
+
}
|
|
931
|
+
const org = {};
|
|
932
|
+
if (args.maxConcurrentAssignments !== undefined) {
|
|
933
|
+
org.maxConcurrentAssignments = clampNumber(args.maxConcurrentAssignments, 1, 16, 4);
|
|
934
|
+
}
|
|
935
|
+
if (args.maxDelegationDepth !== undefined)
|
|
936
|
+
org.maxDelegationDepth = clampNumber(args.maxDelegationDepth, 1, 6, 3);
|
|
937
|
+
if (args.assignmentTimeoutMinutes !== undefined) {
|
|
938
|
+
org.assignmentTimeoutMs = clampNumber(args.assignmentTimeoutMinutes, 1, 600, 45) * 60 * 1000;
|
|
939
|
+
}
|
|
940
|
+
if (Object.keys(org).length)
|
|
941
|
+
patch.org = org;
|
|
942
|
+
if (!Object.keys(patch).length)
|
|
943
|
+
return fail('Nothing to change.');
|
|
944
|
+
// applyConfig writes ~/.rookery/config.json and refreshes the one config
|
|
945
|
+
// object the runtime and the server share, dropping the keys a cleared
|
|
946
|
+
// setting leaves behind.
|
|
947
|
+
applyConfig(this.#config, patch);
|
|
948
|
+
this.emit('changed', { kind: 'config', id: 'config' });
|
|
949
|
+
return { text: 'Settings updated.\n' + describeSettings(this.#config) };
|
|
950
|
+
}
|
|
951
|
+
/* ------------------------------- structure ------------------------------ */
|
|
952
|
+
async #updateAgent(context, args) {
|
|
953
|
+
const text = (key) => (typeof args[key] === 'string' ? args[key].trim() : '');
|
|
954
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
955
|
+
if (context.audience !== 'assistant')
|
|
956
|
+
return fail('Only the assistant can change staff.');
|
|
957
|
+
const agent = this.#store.org.findAgent(context.orgId, text('agent'));
|
|
958
|
+
if (!agent)
|
|
959
|
+
return fail('No agent "' + text('agent') + '".');
|
|
960
|
+
const patch = {};
|
|
961
|
+
if (text('name'))
|
|
962
|
+
patch.name = text('name');
|
|
963
|
+
if (text('title'))
|
|
964
|
+
patch.title = text('title');
|
|
965
|
+
if (text('instructions'))
|
|
966
|
+
patch.instructions = text('instructions');
|
|
967
|
+
if (text('team')) {
|
|
968
|
+
if (text('team').toLowerCase() === 'none')
|
|
969
|
+
patch.teamId = null;
|
|
970
|
+
else {
|
|
971
|
+
const team = this.#store.org.findTeam(context.orgId, text('team'));
|
|
972
|
+
if (!team)
|
|
973
|
+
return fail('No team "' + text('team') + '".');
|
|
974
|
+
patch.teamId = team.id;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
if (text('manager')) {
|
|
978
|
+
if (text('manager').toLowerCase() === 'assistant')
|
|
979
|
+
patch.managerId = null;
|
|
980
|
+
else {
|
|
981
|
+
const manager = this.#store.org.findAgent(context.orgId, text('manager'));
|
|
982
|
+
if (!manager)
|
|
983
|
+
return fail('No agent "' + text('manager') + '".');
|
|
984
|
+
if (manager.id === agent.id)
|
|
985
|
+
return fail('An agent cannot be its own manager.');
|
|
986
|
+
patch.managerId = manager.id;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
if (text('provider'))
|
|
990
|
+
patch.provider = asProvider(text('provider')) ?? null;
|
|
991
|
+
if (text('model'))
|
|
992
|
+
patch.model = text('model');
|
|
993
|
+
if (text('permission'))
|
|
994
|
+
patch.permission = asPermission(text('permission')) ?? null;
|
|
995
|
+
if (typeof args.archived === 'boolean')
|
|
996
|
+
patch.archived = args.archived;
|
|
997
|
+
this.#store.org.updateAgent(agent.id, patch);
|
|
998
|
+
this.emit('changed', { kind: 'agent', id: agent.id });
|
|
999
|
+
return { text: 'Updated ' + agent.name + ' (' + agent.slug + '): ' + Object.keys(patch).join(', ') + '.' };
|
|
1000
|
+
}
|
|
1001
|
+
async #updateTeam(context, args) {
|
|
1002
|
+
const text = (key) => (typeof args[key] === 'string' ? args[key].trim() : '');
|
|
1003
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
1004
|
+
if (context.audience !== 'assistant')
|
|
1005
|
+
return fail('Only the assistant can change teams.');
|
|
1006
|
+
const team = this.#store.org.findTeam(context.orgId, text('team'));
|
|
1007
|
+
if (!team)
|
|
1008
|
+
return fail('No team "' + text('team') + '".');
|
|
1009
|
+
const patch = {};
|
|
1010
|
+
if (text('name'))
|
|
1011
|
+
patch.name = text('name');
|
|
1012
|
+
if (text('purpose'))
|
|
1013
|
+
patch.purpose = text('purpose');
|
|
1014
|
+
if (text('lead')) {
|
|
1015
|
+
if (text('lead').toLowerCase() === 'none')
|
|
1016
|
+
patch.leadId = null;
|
|
1017
|
+
else {
|
|
1018
|
+
const lead = this.#store.org.findAgent(context.orgId, text('lead'));
|
|
1019
|
+
if (!lead)
|
|
1020
|
+
return fail('No agent "' + text('lead') + '".');
|
|
1021
|
+
patch.leadId = lead.id;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
this.#store.org.updateTeam(team.id, patch);
|
|
1025
|
+
this.emit('changed', { kind: 'team', id: team.id });
|
|
1026
|
+
return { text: 'Updated team "' + (patch.name ?? team.name) + '".' };
|
|
1027
|
+
}
|
|
1028
|
+
/* --------------------------------- tasks -------------------------------- */
|
|
1029
|
+
/** Find a task by id or unambiguous id prefix within one company. */
|
|
1030
|
+
findTask(orgId, ref) {
|
|
1031
|
+
const wanted = ref.trim();
|
|
1032
|
+
if (!wanted)
|
|
1033
|
+
return null;
|
|
1034
|
+
const exact = this.#store.org.getTask(wanted);
|
|
1035
|
+
if (exact && exact.orgId === orgId)
|
|
1036
|
+
return exact;
|
|
1037
|
+
const matches = this.#store.org.listAllTasks(orgId, 500).filter((task) => task.id.startsWith(wanted));
|
|
1038
|
+
return matches.length === 1 ? (matches[0] ?? null) : null;
|
|
1039
|
+
}
|
|
1040
|
+
async #updateTask(context, args) {
|
|
1041
|
+
const text = (key) => (typeof args[key] === 'string' ? args[key].trim() : '');
|
|
1042
|
+
const fail = (message) => ({ text: message, isError: true });
|
|
1043
|
+
const task = this.findTask(context.orgId, text('id'));
|
|
1044
|
+
if (!task)
|
|
1045
|
+
return fail('No task ' + text('id') + '.');
|
|
1046
|
+
if (task.status === 'running') {
|
|
1047
|
+
// The one edit allowed mid-run: pulling the plug. The run loop writes
|
|
1048
|
+
// the final status itself once its assignments have stopped.
|
|
1049
|
+
if (text('status') === 'cancelled' && this.cancelTask(task.id)) {
|
|
1050
|
+
return { text: 'Cancelling task "' + task.title + '" and everything it started.' };
|
|
1051
|
+
}
|
|
1052
|
+
return fail('The task is running; wait for it to finish, or cancel it with status "cancelled".');
|
|
1053
|
+
}
|
|
1054
|
+
const patch = {};
|
|
1055
|
+
if (text('title'))
|
|
1056
|
+
patch.title = text('title');
|
|
1057
|
+
if (text('description'))
|
|
1058
|
+
patch.description = text('description');
|
|
1059
|
+
if (text('priority'))
|
|
1060
|
+
patch.priority = asPriority(text('priority'));
|
|
1061
|
+
if (text('assignee')) {
|
|
1062
|
+
if (text('assignee').toLowerCase() === 'none')
|
|
1063
|
+
patch.assigneeId = null;
|
|
1064
|
+
else {
|
|
1065
|
+
const agent = this.#store.org.findAgent(context.orgId, text('assignee'));
|
|
1066
|
+
if (!agent)
|
|
1067
|
+
return fail('No agent "' + text('assignee') + '".');
|
|
1068
|
+
patch.assigneeId = agent.id;
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
const status = text('status');
|
|
1072
|
+
if (status === 'open' || status === 'done' || status === 'cancelled') {
|
|
1073
|
+
patch.status = status;
|
|
1074
|
+
if (status !== 'open')
|
|
1075
|
+
patch.finishedAt = Date.now();
|
|
1076
|
+
if (text('result'))
|
|
1077
|
+
patch.result = text('result');
|
|
1078
|
+
}
|
|
1079
|
+
this.#store.org.updateTask(task.id, patch);
|
|
1080
|
+
const updated = this.#store.org.getTask(task.id) ?? task;
|
|
1081
|
+
this.#announceTask(updated, context.emit);
|
|
1082
|
+
return { text: 'Updated task "' + updated.title + '": ' + Object.keys(patch).join(', ') + '.' };
|
|
1083
|
+
}
|
|
1084
|
+
/**
|
|
1085
|
+
* Plan a task: ask the planner, then write the decision to the board as an
|
|
1086
|
+
* assignee or as subtasks. Existing unfinished subtasks are cancelled first,
|
|
1087
|
+
* so re-planning replaces the old split instead of adding to it.
|
|
1088
|
+
*/
|
|
1089
|
+
async planTask(context, task, hint) {
|
|
1090
|
+
const snapshot = this.snapshot(context.orgId);
|
|
1091
|
+
const project = task.projectId ? (this.#store.org.getProject(task.projectId) ?? undefined) : undefined;
|
|
1092
|
+
const plan = await planTask({
|
|
1093
|
+
registry: this.#registry,
|
|
1094
|
+
config: this.#config,
|
|
1095
|
+
snapshot,
|
|
1096
|
+
task,
|
|
1097
|
+
project,
|
|
1098
|
+
hint,
|
|
1099
|
+
signal: context.signal,
|
|
1100
|
+
});
|
|
1101
|
+
for (const child of this.#store.org.listTasks(context.orgId, { parentId: task.id })) {
|
|
1102
|
+
if (child.status === 'open' || child.status === 'planned') {
|
|
1103
|
+
this.#store.org.updateTask(child.id, { status: 'cancelled', finishedAt: Date.now() });
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
const bySlug = new Map(snapshot.agents.map((agent) => [agent.slug, agent]));
|
|
1107
|
+
if (plan.mode === 'split') {
|
|
1108
|
+
const created = [];
|
|
1109
|
+
for (const subtask of plan.subtasks) {
|
|
1110
|
+
const child = this.#store.org.createTask({
|
|
1111
|
+
orgId: context.orgId,
|
|
1112
|
+
parentId: task.id,
|
|
1113
|
+
projectId: task.projectId,
|
|
1114
|
+
title: subtask.title,
|
|
1115
|
+
description: subtask.description,
|
|
1116
|
+
priority: task.priority,
|
|
1117
|
+
assigneeId: bySlug.get(subtask.agent)?.id,
|
|
1118
|
+
createdBy: 'assistant',
|
|
1119
|
+
dependsOn: subtask.dependsOn.map((index) => created[index]?.id ?? '').filter(Boolean),
|
|
1120
|
+
status: 'planned',
|
|
1121
|
+
});
|
|
1122
|
+
created.push(child);
|
|
1123
|
+
this.#announceTask(child, context.emit);
|
|
1124
|
+
}
|
|
1125
|
+
this.#store.org.updateTask(task.id, { status: 'planned', planNote: plan.reason, assigneeId: null });
|
|
1126
|
+
}
|
|
1127
|
+
else {
|
|
1128
|
+
this.#store.org.updateTask(task.id, {
|
|
1129
|
+
status: 'planned',
|
|
1130
|
+
planNote: plan.reason,
|
|
1131
|
+
assigneeId: plan.assignee ? (bySlug.get(plan.assignee)?.id ?? null) : null,
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
this.#announceTask(this.#store.org.getTask(task.id) ?? task, context.emit);
|
|
1135
|
+
return plan;
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Run a task to completion. Unplanned tasks are planned first. Subtasks
|
|
1139
|
+
* run as assignments in dependency waves; the parent collects their
|
|
1140
|
+
* reports. Never throws; the returned task says how it ended.
|
|
1141
|
+
*/
|
|
1142
|
+
async runTask(outer, task) {
|
|
1143
|
+
const org = this.#store.org;
|
|
1144
|
+
const reload = () => org.getTask(task.id) ?? task;
|
|
1145
|
+
if (reload().status === 'running')
|
|
1146
|
+
return reload();
|
|
1147
|
+
// The run gets its own abort controller so cancelTask() can stop it
|
|
1148
|
+
// without touching the caller's turn; the caller's signal feeds into it.
|
|
1149
|
+
const controller = new AbortController();
|
|
1150
|
+
const onAbort = () => controller.abort();
|
|
1151
|
+
outer.signal?.addEventListener('abort', onAbort, { once: true });
|
|
1152
|
+
this.#activeTasks.set(task.id, controller);
|
|
1153
|
+
const context = { ...outer, signal: controller.signal };
|
|
1154
|
+
try {
|
|
1155
|
+
return await this.#runTask(context, task);
|
|
1156
|
+
}
|
|
1157
|
+
finally {
|
|
1158
|
+
this.#activeTasks.delete(task.id);
|
|
1159
|
+
outer.signal?.removeEventListener('abort', onAbort);
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
async #runTask(context, task) {
|
|
1163
|
+
const org = this.#store.org;
|
|
1164
|
+
const reload = () => org.getTask(task.id) ?? task;
|
|
1165
|
+
let children = org.listTasks(context.orgId, { parentId: task.id }).filter((c) => c.status !== 'cancelled');
|
|
1166
|
+
if (!children.length && !reload().assigneeId) {
|
|
1167
|
+
await this.planTask(context, reload());
|
|
1168
|
+
children = org.listTasks(context.orgId, { parentId: task.id }).filter((c) => c.status !== 'cancelled');
|
|
1169
|
+
}
|
|
1170
|
+
const started = Date.now();
|
|
1171
|
+
org.updateTask(task.id, { status: 'running', startedAt: started, error: null });
|
|
1172
|
+
this.#announceTask(reload(), context.emit);
|
|
1173
|
+
const finish = (status, patch) => {
|
|
1174
|
+
org.updateTask(task.id, { status, finishedAt: Date.now(), ...patch });
|
|
1175
|
+
const done = reload();
|
|
1176
|
+
this.#announceTask(done, context.emit);
|
|
1177
|
+
return done;
|
|
1178
|
+
};
|
|
1179
|
+
if (!children.length) {
|
|
1180
|
+
const current = reload();
|
|
1181
|
+
const agent = current.assigneeId ? org.getAgent(current.assigneeId) : null;
|
|
1182
|
+
if (!agent)
|
|
1183
|
+
return finish('failed', { error: 'Nobody is assigned and nobody could be found to do it.' });
|
|
1184
|
+
const outcome = await this.#runTaskLeaf(context, current, agent);
|
|
1185
|
+
return finish(outcome.status === 'done' ? 'done' : outcome.status === 'cancelled' ? 'cancelled' : 'failed', {
|
|
1186
|
+
result: outcome.result,
|
|
1187
|
+
error: outcome.error,
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
const waves = buildTaskWaves(children.filter((c) => c.status !== 'done'));
|
|
1191
|
+
for (const wave of waves) {
|
|
1192
|
+
if (context.signal?.aborted)
|
|
1193
|
+
break;
|
|
1194
|
+
await Promise.all(wave.map((child) => this.#runSubtask(context, child)));
|
|
1195
|
+
}
|
|
1196
|
+
const all = org.listTasks(context.orgId, { parentId: task.id }).filter((c) => c.status !== 'cancelled');
|
|
1197
|
+
const failed = all.filter((c) => c.status === 'failed');
|
|
1198
|
+
const combined = all
|
|
1199
|
+
.map((c) => {
|
|
1200
|
+
const agent = c.assigneeId ? org.getAgent(c.assigneeId) : null;
|
|
1201
|
+
const head = '### ' + c.title + ' (' + (agent?.slug ?? 'unassigned') + ', ' + c.status + ')';
|
|
1202
|
+
return head + '\n' + (c.result ?? (c.error ? 'FAILED: ' + c.error : 'no output'));
|
|
1203
|
+
})
|
|
1204
|
+
.join('\n\n');
|
|
1205
|
+
if (context.signal?.aborted)
|
|
1206
|
+
return finish('cancelled', { result: combined });
|
|
1207
|
+
if (failed.length === all.length)
|
|
1208
|
+
return finish('failed', { error: 'Every subtask failed.', result: combined });
|
|
1209
|
+
return finish('done', {
|
|
1210
|
+
result: combined,
|
|
1211
|
+
error: failed.length ? failed.length + ' of ' + all.length + ' subtasks failed.' : undefined,
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
/** One subtask inside a wave: mark it, run its leaf, record the outcome. */
|
|
1215
|
+
async #runSubtask(context, child) {
|
|
1216
|
+
const org = this.#store.org;
|
|
1217
|
+
const agent = child.assigneeId ? org.getAgent(child.assigneeId) : null;
|
|
1218
|
+
org.updateTask(child.id, { status: 'running', startedAt: Date.now() });
|
|
1219
|
+
this.#announceTask(org.getTask(child.id) ?? child, context.emit);
|
|
1220
|
+
if (!agent) {
|
|
1221
|
+
org.updateTask(child.id, { status: 'failed', error: 'No assignee.', finishedAt: Date.now() });
|
|
1222
|
+
}
|
|
1223
|
+
else {
|
|
1224
|
+
const deps = child.dependsOn.map((id) => org.getTask(id)).filter((t) => Boolean(t?.result));
|
|
1225
|
+
const outcome = await this.#runTaskLeaf(context, child, agent, deps);
|
|
1226
|
+
org.updateTask(child.id, {
|
|
1227
|
+
status: outcome.status === 'done' ? 'done' : outcome.status === 'cancelled' ? 'cancelled' : 'failed',
|
|
1228
|
+
result: outcome.result,
|
|
1229
|
+
error: outcome.error,
|
|
1230
|
+
finishedAt: Date.now(),
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
this.#announceTask(org.getTask(child.id) ?? child, context.emit);
|
|
1234
|
+
}
|
|
1235
|
+
/** One task, one agent, one assignment. */
|
|
1236
|
+
async #runTaskLeaf(context, task, agent, deps = []) {
|
|
1237
|
+
const prior = deps.length
|
|
1238
|
+
? 'Results of the subtasks this one depends on:\n\n' +
|
|
1239
|
+
deps.map((dep) => '### ' + dep.title + '\n' + clip(dep.result ?? '', 6000)).join('\n\n') +
|
|
1240
|
+
'\n\n---\n\n'
|
|
1241
|
+
: '';
|
|
1242
|
+
const assignment = await this.run({
|
|
1243
|
+
orgId: context.orgId,
|
|
1244
|
+
agent,
|
|
1245
|
+
task: prior + 'TASK: ' + task.title + '\n\n' + task.description,
|
|
1246
|
+
projectId: task.projectId ?? context.projectId,
|
|
1247
|
+
sessionId: context.sessionId,
|
|
1248
|
+
parentId: context.parentAssignmentId,
|
|
1249
|
+
requesterKind: context.audience === 'agent' ? 'agent' : 'assistant',
|
|
1250
|
+
requesterAgentId: context.agentId,
|
|
1251
|
+
depth: context.depth + 1,
|
|
1252
|
+
emit: context.emit,
|
|
1253
|
+
signal: context.signal,
|
|
1254
|
+
});
|
|
1255
|
+
this.#store.org.updateTask(task.id, { assignmentId: assignment.id });
|
|
1256
|
+
return { status: assignment.status, result: assignment.result, error: assignment.error, assignmentId: assignment.id };
|
|
1257
|
+
}
|
|
1258
|
+
#announceTask(task, emit) {
|
|
1259
|
+
const event = { type: 'task', task };
|
|
1260
|
+
emit(event);
|
|
1261
|
+
this.emit('task', event);
|
|
1262
|
+
}
|
|
1263
|
+
/* ------------------------------- internals ------------------------------ */
|
|
1264
|
+
/**
|
|
1265
|
+
* Skills for an agent turn: the home skills plus, when the project has a
|
|
1266
|
+
* directory, its own `.claude/skills` - the project wins on a name clash.
|
|
1267
|
+
* A fresh `SkillStore` is cheap (it only reads directories on demand), and
|
|
1268
|
+
* the project changes per assignment, so this cannot be the one long-lived
|
|
1269
|
+
* instance on `this.#skills`.
|
|
1270
|
+
*/
|
|
1271
|
+
#agentSkills(project) {
|
|
1272
|
+
if (!project?.path)
|
|
1273
|
+
return this.#skills.for('agent');
|
|
1274
|
+
return new SkillStore([this.#config.skillsDir, projectSkillsDir(project.path)]).for('agent');
|
|
1275
|
+
}
|
|
1276
|
+
#memoriesFor(agentId, task) {
|
|
1277
|
+
if (!this.#config.memory.enabled)
|
|
1278
|
+
return [];
|
|
1279
|
+
const matched = recall(this.#store, {
|
|
1280
|
+
text: task,
|
|
1281
|
+
owner: agentId,
|
|
1282
|
+
limit: this.#config.memory.recallLimit,
|
|
1283
|
+
threshold: this.#config.memory.recallThreshold,
|
|
1284
|
+
});
|
|
1285
|
+
const profile = coreProfile(this.#store, { owner: agentId, limit: 3 });
|
|
1286
|
+
const byId = new Map(profile.map((memory) => [memory.id, memory]));
|
|
1287
|
+
for (const memory of matched)
|
|
1288
|
+
byId.set(memory.id, memory);
|
|
1289
|
+
return [...byId.values()].sort((a, b) => b.score - a.score);
|
|
1290
|
+
}
|
|
1291
|
+
/** Let an agent keep what it learned, in its own memory bank. */
|
|
1292
|
+
async #learn(agent, task, report, providerId) {
|
|
1293
|
+
try {
|
|
1294
|
+
// The memories relevant to this assignment, not the ones that happen to
|
|
1295
|
+
// rank highest overall - otherwise the model cannot tell that it is
|
|
1296
|
+
// about to write the same sentence for the fourth time.
|
|
1297
|
+
const known = recall(this.#store, {
|
|
1298
|
+
text: task + '\n' + report,
|
|
1299
|
+
owner: agent.id,
|
|
1300
|
+
limit: 20,
|
|
1301
|
+
threshold: 0.05,
|
|
1302
|
+
touch: false,
|
|
1303
|
+
expand: false,
|
|
1304
|
+
}).map((memory) => memory.content);
|
|
1305
|
+
const candidates = await extractMemories(this.#registry.get(providerId), {
|
|
1306
|
+
userText: task,
|
|
1307
|
+
assistantText: report,
|
|
1308
|
+
known,
|
|
1309
|
+
model: smallModelFor(providerId),
|
|
1310
|
+
perspective: 'agent',
|
|
1311
|
+
});
|
|
1312
|
+
admitCandidates(this.#store, {
|
|
1313
|
+
candidates,
|
|
1314
|
+
owner: agent.id,
|
|
1315
|
+
config: this.#config.memory,
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
catch (error) {
|
|
1319
|
+
this.#log.warn('Agent memory extraction failed', { agent: agent.slug, error: error.message });
|
|
1320
|
+
}
|
|
1321
|
+
}
|
|
1322
|
+
/** Concurrency gate: at most `maxConcurrentAssignments` provider processes at once. */
|
|
1323
|
+
#acquire(signal) {
|
|
1324
|
+
if (this.#running < this.#config.org.maxConcurrentAssignments) {
|
|
1325
|
+
this.#running += 1;
|
|
1326
|
+
return Promise.resolve();
|
|
1327
|
+
}
|
|
1328
|
+
return new Promise((resolve) => {
|
|
1329
|
+
const grant = () => {
|
|
1330
|
+
this.#running += 1;
|
|
1331
|
+
resolve();
|
|
1332
|
+
};
|
|
1333
|
+
this.#waiting.push(grant);
|
|
1334
|
+
signal?.addEventListener('abort', () => {
|
|
1335
|
+
const index = this.#waiting.indexOf(grant);
|
|
1336
|
+
if (index !== -1) {
|
|
1337
|
+
this.#waiting.splice(index, 1);
|
|
1338
|
+
grant();
|
|
1339
|
+
}
|
|
1340
|
+
}, { once: true });
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
#release() {
|
|
1344
|
+
this.#running = Math.max(0, this.#running - 1);
|
|
1345
|
+
const next = this.#waiting.shift();
|
|
1346
|
+
if (next)
|
|
1347
|
+
next();
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
/* --------------------------------- helpers --------------------------------- */
|
|
1351
|
+
export function toView(assignment, agent, extra = {}) {
|
|
1352
|
+
return {
|
|
1353
|
+
id: assignment.id,
|
|
1354
|
+
agentId: agent.id,
|
|
1355
|
+
agentSlug: agent.slug,
|
|
1356
|
+
agentName: agent.name,
|
|
1357
|
+
task: assignment.task,
|
|
1358
|
+
status: assignment.status,
|
|
1359
|
+
projectId: assignment.projectId,
|
|
1360
|
+
parentId: assignment.parentId,
|
|
1361
|
+
depth: assignment.depth,
|
|
1362
|
+
provider: assignment.provider,
|
|
1363
|
+
chars: assignment.chars,
|
|
1364
|
+
durationMs: assignment.durationMs,
|
|
1365
|
+
error: assignment.error,
|
|
1366
|
+
...extra,
|
|
1367
|
+
};
|
|
1368
|
+
}
|
|
1369
|
+
export function describeAssignment(assignment, agent) {
|
|
1370
|
+
const lines = [
|
|
1371
|
+
'Assignment ' + assignment.id,
|
|
1372
|
+
'Agent: ' + (agent ? agent.name + ' (' + agent.slug + ')' : assignment.agentId),
|
|
1373
|
+
'Status: ' + assignment.status,
|
|
1374
|
+
'Task: ' + clip(assignment.task, 400),
|
|
1375
|
+
];
|
|
1376
|
+
if (assignment.durationMs !== undefined)
|
|
1377
|
+
lines.push('Duration: ' + Math.round(assignment.durationMs / 1000) + ' s');
|
|
1378
|
+
if (assignment.error)
|
|
1379
|
+
lines.push('Error: ' + assignment.error);
|
|
1380
|
+
if (assignment.result)
|
|
1381
|
+
lines.push('', clip(assignment.result, RESULT_BUDGET));
|
|
1382
|
+
return lines.join('\n');
|
|
1383
|
+
}
|
|
1384
|
+
function asProvider(value) {
|
|
1385
|
+
return value === 'claude' || value === 'codex' ? value : undefined;
|
|
1386
|
+
}
|
|
1387
|
+
function asMemoryKind(value) {
|
|
1388
|
+
return value === 'preference' || value === 'project' || value === 'event' ? value : 'fact';
|
|
1389
|
+
}
|
|
1390
|
+
/** A number argument within bounds; the fallback when it is missing or not a number. */
|
|
1391
|
+
function clampNumber(value, min, max, fallback) {
|
|
1392
|
+
const parsed = typeof value === 'number' ? value : typeof value === 'string' ? Number(value) : NaN;
|
|
1393
|
+
if (!Number.isFinite(parsed))
|
|
1394
|
+
return fallback;
|
|
1395
|
+
return Math.min(max, Math.max(min, parsed));
|
|
1396
|
+
}
|
|
1397
|
+
/** The settings the assistant may see and change, as plain lines. */
|
|
1398
|
+
export function describeSettings(config) {
|
|
1399
|
+
return [
|
|
1400
|
+
'Default provider: ' + config.defaultProvider,
|
|
1401
|
+
'Default model: ' + (config.defaultModel || 'provider default'),
|
|
1402
|
+
'Default effort: ' + (config.defaultEffort ?? 'provider default'),
|
|
1403
|
+
'Parallel assignments: ' + config.org.maxConcurrentAssignments,
|
|
1404
|
+
'Delegation depth: ' + config.org.maxDelegationDepth,
|
|
1405
|
+
'Assignment timeout: ' + Math.round(config.org.assignmentTimeoutMs / 60000) + ' min',
|
|
1406
|
+
].join('\n');
|
|
1407
|
+
}
|
|
1408
|
+
function asPriority(value) {
|
|
1409
|
+
return value === 'low' || value === 'normal' || value === 'high' ? value : undefined;
|
|
1410
|
+
}
|
|
1411
|
+
/** The plan as the assistant reads it back, with the subtask ids it can edit. */
|
|
1412
|
+
export function describePlan(plan, children) {
|
|
1413
|
+
const lines = ['Plan: ' + plan.mode + '. ' + plan.reason];
|
|
1414
|
+
if (plan.mode === 'single')
|
|
1415
|
+
lines.push('Assignee: ' + (plan.assignee ?? 'nobody'));
|
|
1416
|
+
else {
|
|
1417
|
+
lines.push('Subtasks:');
|
|
1418
|
+
for (const [index, subtask] of plan.subtasks.entries()) {
|
|
1419
|
+
const child = children.find((c) => c.title === subtask.title && c.status === 'planned');
|
|
1420
|
+
lines.push('- [' + (child?.id.slice(0, 8) ?? '?') + '] ' + subtask.title + ' → ' + subtask.agent +
|
|
1421
|
+
(subtask.dependsOn.length ? ' (after ' + subtask.dependsOn.map((i) => i + 1).join(', ') + ')' : '') +
|
|
1422
|
+
' #' + (index + 1));
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
lines.push('Use update_task to change assignees or wording, then run_task to execute.');
|
|
1426
|
+
return lines.join('\n');
|
|
1427
|
+
}
|
|
1428
|
+
function asPermission(value) {
|
|
1429
|
+
return value === 'chat' || value === 'read' || value === 'write' || value === 'full' ? value : undefined;
|
|
1430
|
+
}
|
|
1431
|
+
//# sourceMappingURL=controller.js.map
|