@jungjaehoon/mama-os 0.28.5 → 0.29.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/dist/agent/agent-loop.d.ts +0 -4
- package/dist/agent/agent-loop.d.ts.map +1 -1
- package/dist/agent/agent-loop.js +44 -12
- package/dist/agent/agent-loop.js.map +1 -1
- package/dist/agent/code-act/host-bridge.d.ts.map +1 -1
- package/dist/agent/code-act/host-bridge.js +53 -3
- package/dist/agent/code-act/host-bridge.js.map +1 -1
- package/dist/agent/code-act/tool-policy.d.ts.map +1 -1
- package/dist/agent/code-act/tool-policy.js +5 -0
- package/dist/agent/code-act/tool-policy.js.map +1 -1
- package/dist/agent/codex-auth.d.ts +0 -1
- package/dist/agent/codex-auth.d.ts.map +1 -1
- package/dist/agent/codex-auth.js +0 -4
- package/dist/agent/codex-auth.js.map +1 -1
- package/dist/agent/codex-home.d.ts +0 -2
- package/dist/agent/codex-home.d.ts.map +1 -1
- package/dist/agent/codex-home.js +0 -66
- package/dist/agent/codex-home.js.map +1 -1
- package/dist/agent/context-compile-service.d.ts +9 -0
- package/dist/agent/context-compile-service.d.ts.map +1 -1
- package/dist/agent/context-compile-service.js +6 -0
- package/dist/agent/context-compile-service.js.map +1 -1
- package/dist/agent/context-prompt-builder.d.ts +0 -6
- package/dist/agent/context-prompt-builder.d.ts.map +1 -1
- package/dist/agent/context-prompt-builder.js +0 -131
- package/dist/agent/context-prompt-builder.js.map +1 -1
- package/dist/agent/contract-extractor.d.ts +0 -4
- package/dist/agent/contract-extractor.d.ts.map +1 -1
- package/dist/agent/contract-extractor.js +0 -68
- package/dist/agent/contract-extractor.js.map +1 -1
- package/dist/agent/gateway-tool-executor.d.ts +20 -15
- package/dist/agent/gateway-tool-executor.d.ts.map +1 -1
- package/dist/agent/gateway-tool-executor.js +236 -90
- package/dist/agent/gateway-tool-executor.js.map +1 -1
- package/dist/agent/gateway-tools.md +7 -4
- package/dist/agent/skill-loader.d.ts +0 -7
- package/dist/agent/skill-loader.d.ts.map +1 -1
- package/dist/agent/skill-loader.js +0 -86
- package/dist/agent/skill-loader.js.map +1 -1
- package/dist/agent/token-estimator.d.ts +0 -8
- package/dist/agent/token-estimator.d.ts.map +1 -1
- package/dist/agent/token-estimator.js +0 -14
- package/dist/agent/token-estimator.js.map +1 -1
- package/dist/agent/tool-registry.d.ts.map +1 -1
- package/dist/agent/tool-registry.js +23 -5
- package/dist/agent/tool-registry.js.map +1 -1
- package/dist/agent/types.d.ts +27 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/api/agent-graph-handler.d.ts +9 -0
- package/dist/api/agent-graph-handler.d.ts.map +1 -1
- package/dist/api/agent-graph-handler.js +27 -1
- package/dist/api/agent-graph-handler.js.map +1 -1
- package/dist/api/entity-audit-handler.d.ts +1 -2
- package/dist/api/entity-audit-handler.d.ts.map +1 -1
- package/dist/api/entity-audit-handler.js +0 -5
- package/dist/api/entity-audit-handler.js.map +1 -1
- package/dist/api/index.d.ts +1 -9
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +4 -17
- package/dist/api/index.js.map +1 -1
- package/dist/api/intelligence-handler.d.ts +0 -5
- package/dist/api/intelligence-handler.d.ts.map +1 -1
- package/dist/api/intelligence-handler.js +0 -15
- package/dist/api/intelligence-handler.js.map +1 -1
- package/dist/api/types.d.ts +1 -5
- package/dist/api/types.d.ts.map +1 -1
- package/dist/api/types.js +0 -14
- package/dist/api/types.js.map +1 -1
- package/dist/cli/commands/start.d.ts +117 -3
- package/dist/cli/commands/start.d.ts.map +1 -1
- package/dist/cli/commands/start.js +223 -62
- package/dist/cli/commands/start.js.map +1 -1
- package/dist/cli/config/config-manager.d.ts +0 -5
- package/dist/cli/config/config-manager.d.ts.map +1 -1
- package/dist/cli/config/config-manager.js +0 -29
- package/dist/cli/config/config-manager.js.map +1 -1
- package/dist/cli/config/types.d.ts.map +1 -1
- package/dist/cli/config/types.js +3 -0
- package/dist/cli/config/types.js.map +1 -1
- package/dist/cli/runtime/agent-loop-init.d.ts.map +1 -1
- package/dist/cli/runtime/agent-loop-init.js +9 -1
- package/dist/cli/runtime/agent-loop-init.js.map +1 -1
- package/dist/cli/runtime/api-routes-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-routes-init.js +32 -5
- package/dist/cli/runtime/api-routes-init.js.map +1 -1
- package/dist/cli/runtime/api-server-init.d.ts.map +1 -1
- package/dist/cli/runtime/api-server-init.js +2 -0
- package/dist/cli/runtime/api-server-init.js.map +1 -1
- package/dist/cli/runtime/gateway-init.d.ts +1 -1
- package/dist/cli/runtime/gateway-init.d.ts.map +1 -1
- package/dist/cli/runtime/gateway-init.js +11 -38
- package/dist/cli/runtime/gateway-init.js.map +1 -1
- package/dist/cli/runtime/gateway-wiring.d.ts.map +1 -1
- package/dist/cli/runtime/gateway-wiring.js +6 -120
- package/dist/cli/runtime/gateway-wiring.js.map +1 -1
- package/dist/cli/utils/pid-manager.d.ts +0 -10
- package/dist/cli/utils/pid-manager.d.ts.map +1 -1
- package/dist/cli/utils/pid-manager.js +0 -26
- package/dist/cli/utils/pid-manager.js.map +1 -1
- package/dist/connectors/framework/polling-scheduler.d.ts +33 -1
- package/dist/connectors/framework/polling-scheduler.d.ts.map +1 -1
- package/dist/connectors/framework/polling-scheduler.js +46 -40
- package/dist/connectors/framework/polling-scheduler.js.map +1 -1
- package/dist/connectors/trello/query-tools.d.ts +32 -5
- package/dist/connectors/trello/query-tools.d.ts.map +1 -1
- package/dist/connectors/trello/query-tools.js +56 -17
- package/dist/connectors/trello/query-tools.js.map +1 -1
- package/dist/db/agent-store.d.ts +0 -4
- package/dist/db/agent-store.d.ts.map +1 -1
- package/dist/db/agent-store.js +0 -65
- package/dist/db/agent-store.js.map +1 -1
- package/dist/envelope/enforcer.d.ts.map +1 -1
- package/dist/envelope/enforcer.js +10 -1
- package/dist/envelope/enforcer.js.map +1 -1
- package/dist/envelope/index.d.ts +0 -1
- package/dist/envelope/index.d.ts.map +1 -1
- package/dist/envelope/index.js +0 -1
- package/dist/envelope/index.js.map +1 -1
- package/dist/envelope/signature.d.ts +0 -1
- package/dist/envelope/signature.d.ts.map +1 -1
- package/dist/envelope/signature.js +0 -7
- package/dist/envelope/signature.js.map +1 -1
- package/dist/envelope/tool-connector-scope.d.ts +35 -0
- package/dist/envelope/tool-connector-scope.d.ts.map +1 -0
- package/dist/envelope/tool-connector-scope.js +57 -0
- package/dist/envelope/tool-connector-scope.js.map +1 -0
- package/dist/evidence/effects.d.ts +107 -0
- package/dist/evidence/effects.d.ts.map +1 -0
- package/dist/evidence/effects.js +281 -0
- package/dist/evidence/effects.js.map +1 -0
- package/dist/evidence/read.d.ts +75 -0
- package/dist/evidence/read.d.ts.map +1 -0
- package/dist/evidence/read.js +105 -0
- package/dist/evidence/read.js.map +1 -0
- package/dist/gateways/base-gateway.d.ts +23 -3
- package/dist/gateways/base-gateway.d.ts.map +1 -1
- package/dist/gateways/base-gateway.js +15 -2
- package/dist/gateways/base-gateway.js.map +1 -1
- package/dist/gateways/discord.d.ts +4 -16
- package/dist/gateways/discord.d.ts.map +1 -1
- package/dist/gateways/discord.js +22 -189
- package/dist/gateways/discord.js.map +1 -1
- package/dist/gateways/index.d.ts +2 -1
- package/dist/gateways/index.d.ts.map +1 -1
- package/dist/gateways/message-router.d.ts +13 -20
- package/dist/gateways/message-router.d.ts.map +1 -1
- package/dist/gateways/message-router.js +32 -3
- package/dist/gateways/message-router.js.map +1 -1
- package/dist/gateways/slack.d.ts +2 -12
- package/dist/gateways/slack.d.ts.map +1 -1
- package/dist/gateways/slack.js +6 -220
- package/dist/gateways/slack.js.map +1 -1
- package/dist/gateways/telegram.d.ts +2 -2
- package/dist/gateways/telegram.d.ts.map +1 -1
- package/dist/gateways/telegram.js +3 -2
- package/dist/gateways/telegram.js.map +1 -1
- package/dist/gateways/turn-contract.d.ts +104 -0
- package/dist/gateways/turn-contract.d.ts.map +1 -0
- package/dist/{memory/consult-contract.js → gateways/turn-contract.js} +1 -1
- package/dist/gateways/turn-contract.js.map +1 -0
- package/dist/memory/provenance-live.d.ts +111 -0
- package/dist/memory/provenance-live.d.ts.map +1 -0
- package/dist/memory/provenance-live.js +381 -0
- package/dist/memory/provenance-live.js.map +1 -0
- package/dist/memory/provenance-resolver.d.ts +184 -0
- package/dist/memory/provenance-resolver.d.ts.map +1 -0
- package/dist/memory/provenance-resolver.js +152 -0
- package/dist/memory/provenance-resolver.js.map +1 -0
- package/dist/multi-agent/agent-event-bus.d.ts +1 -0
- package/dist/multi-agent/agent-event-bus.d.ts.map +1 -1
- package/dist/multi-agent/bmad-templates.d.ts +0 -18
- package/dist/multi-agent/bmad-templates.d.ts.map +1 -1
- package/dist/multi-agent/bmad-templates.js +0 -127
- package/dist/multi-agent/bmad-templates.js.map +1 -1
- package/dist/multi-agent/dashboard-agent-persona.js +3 -3
- package/dist/operator/board-reconcile.d.ts +2 -3
- package/dist/operator/board-reconcile.d.ts.map +1 -1
- package/dist/operator/board-reconcile.js +18 -32
- package/dist/operator/board-reconcile.js.map +1 -1
- package/dist/operator/changes-projection.d.ts +70 -0
- package/dist/operator/changes-projection.d.ts.map +1 -0
- package/dist/operator/changes-projection.js +109 -0
- package/dist/operator/changes-projection.js.map +1 -0
- package/dist/operator/external-correlation.d.ts +94 -0
- package/dist/operator/external-correlation.d.ts.map +1 -0
- package/dist/operator/external-correlation.js +177 -0
- package/dist/operator/external-correlation.js.map +1 -0
- package/dist/operator/operator-trigger-loop.d.ts +9 -1
- package/dist/operator/operator-trigger-loop.d.ts.map +1 -1
- package/dist/operator/operator-trigger-loop.js +8 -4
- package/dist/operator/operator-trigger-loop.js.map +1 -1
- package/dist/operator/provenance-lookup.d.ts +18 -0
- package/dist/operator/provenance-lookup.d.ts.map +1 -0
- package/dist/operator/provenance-lookup.js +54 -0
- package/dist/operator/provenance-lookup.js.map +1 -0
- package/dist/operator/report-carry.d.ts +18 -1
- package/dist/operator/report-carry.d.ts.map +1 -1
- package/dist/operator/report-carry.js +22 -3
- package/dist/operator/report-carry.js.map +1 -1
- package/dist/operator/report-run.d.ts +35 -0
- package/dist/operator/report-run.d.ts.map +1 -1
- package/dist/operator/report-run.js +184 -24
- package/dist/operator/report-run.js.map +1 -1
- package/dist/operator/situation-report.d.ts.map +1 -1
- package/dist/operator/situation-report.js +9 -2
- package/dist/operator/situation-report.js.map +1 -1
- package/dist/operator/task-ledger.d.ts +84 -2
- package/dist/operator/task-ledger.d.ts.map +1 -1
- package/dist/operator/task-ledger.js +274 -31
- package/dist/operator/task-ledger.js.map +1 -1
- package/dist/operator/worker-run.js +1 -1
- package/dist/operator/worker-run.js.map +1 -1
- package/dist/operator/workorder-hooks.d.ts +79 -4
- package/dist/operator/workorder-hooks.d.ts.map +1 -1
- package/dist/operator/workorder-hooks.js +152 -20
- package/dist/operator/workorder-hooks.js.map +1 -1
- package/dist/operator/workorder-publishers.d.ts +2 -0
- package/dist/operator/workorder-publishers.d.ts.map +1 -1
- package/dist/operator/workorder-publishers.js +8 -1
- package/dist/operator/workorder-publishers.js.map +1 -1
- package/dist/utils/untrusted-content.d.ts +11 -0
- package/dist/utils/untrusted-content.d.ts.map +1 -1
- package/dist/utils/untrusted-content.js +20 -0
- package/dist/utils/untrusted-content.js.map +1 -1
- package/package.json +4 -3
- package/scripts/backfill-channel-keys.ts +451 -0
- package/dist/agent/auto-recall.d.ts +0 -48
- package/dist/agent/auto-recall.d.ts.map +0 -1
- package/dist/agent/auto-recall.js +0 -192
- package/dist/agent/auto-recall.js.map +0 -1
- package/dist/agent/claude-client.d.ts +0 -50
- package/dist/agent/claude-client.d.ts.map +0 -1
- package/dist/agent/claude-client.js +0 -219
- package/dist/agent/claude-client.js.map +0 -1
- package/dist/agent/delegation-executor.d.ts +0 -49
- package/dist/agent/delegation-executor.d.ts.map +0 -1
- package/dist/agent/delegation-executor.js +0 -692
- package/dist/agent/delegation-executor.js.map +0 -1
- package/dist/agent/mcp-executor.d.ts +0 -60
- package/dist/agent/mcp-executor.d.ts.map +0 -1
- package/dist/agent/mcp-executor.js +0 -190
- package/dist/agent/mcp-executor.js.map +0 -1
- package/dist/agent/process-tree.d.ts +0 -6
- package/dist/agent/process-tree.d.ts.map +0 -1
- package/dist/agent/process-tree.js +0 -21
- package/dist/agent/process-tree.js.map +0 -1
- package/dist/agent/streaming-callback-manager.d.ts +0 -85
- package/dist/agent/streaming-callback-manager.d.ts.map +0 -1
- package/dist/agent/streaming-callback-manager.js +0 -103
- package/dist/agent/streaming-callback-manager.js.map +0 -1
- package/dist/agent/token-budget.d.ts +0 -49
- package/dist/agent/token-budget.d.ts.map +0 -1
- package/dist/agent/token-budget.js +0 -92
- package/dist/agent/token-budget.js.map +0 -1
- package/dist/connectors/kagemusha/history-compiler.d.ts +0 -18
- package/dist/connectors/kagemusha/history-compiler.d.ts.map +0 -1
- package/dist/connectors/kagemusha/history-compiler.js +0 -35
- package/dist/connectors/kagemusha/history-compiler.js.map +0 -1
- package/dist/db/migrations/wiki-artifacts.d.ts +0 -3
- package/dist/db/migrations/wiki-artifacts.d.ts.map +0 -1
- package/dist/db/migrations/wiki-artifacts.js +0 -24
- package/dist/db/migrations/wiki-artifacts.js.map +0 -1
- package/dist/envelope/subset.d.ts +0 -9
- package/dist/envelope/subset.d.ts.map +0 -1
- package/dist/envelope/subset.js +0 -67
- package/dist/envelope/subset.js.map +0 -1
- package/dist/memory/consult-contract.d.ts +0 -8
- package/dist/memory/consult-contract.d.ts.map +0 -1
- package/dist/memory/consult-contract.js.map +0 -1
- package/dist/multi-agent/agent-message-queue.d.ts +0 -104
- package/dist/multi-agent/agent-message-queue.d.ts.map +0 -1
- package/dist/multi-agent/agent-message-queue.js +0 -227
- package/dist/multi-agent/agent-message-queue.js.map +0 -1
- package/dist/multi-agent/background-task-manager.d.ts +0 -248
- package/dist/multi-agent/background-task-manager.d.ts.map +0 -1
- package/dist/multi-agent/background-task-manager.js +0 -415
- package/dist/multi-agent/background-task-manager.js.map +0 -1
- package/dist/multi-agent/category-router.d.ts +0 -56
- package/dist/multi-agent/category-router.d.ts.map +0 -1
- package/dist/multi-agent/category-router.js +0 -99
- package/dist/multi-agent/category-router.js.map +0 -1
- package/dist/multi-agent/council-engine.d.ts +0 -60
- package/dist/multi-agent/council-engine.d.ts.map +0 -1
- package/dist/multi-agent/council-engine.js +0 -284
- package/dist/multi-agent/council-engine.js.map +0 -1
- package/dist/multi-agent/delegation-format-validator.d.ts +0 -22
- package/dist/multi-agent/delegation-format-validator.d.ts.map +0 -1
- package/dist/multi-agent/delegation-format-validator.js +0 -31
- package/dist/multi-agent/delegation-format-validator.js.map +0 -1
- package/dist/multi-agent/delegation-manager.d.ts +0 -128
- package/dist/multi-agent/delegation-manager.d.ts.map +0 -1
- package/dist/multi-agent/delegation-manager.js +0 -276
- package/dist/multi-agent/delegation-manager.js.map +0 -1
- package/dist/multi-agent/i18n-messages.d.ts +0 -35
- package/dist/multi-agent/i18n-messages.d.ts.map +0 -1
- package/dist/multi-agent/i18n-messages.js +0 -54
- package/dist/multi-agent/i18n-messages.js.map +0 -1
- package/dist/multi-agent/index.d.ts +0 -31
- package/dist/multi-agent/index.d.ts.map +0 -1
- package/dist/multi-agent/index.js +0 -46
- package/dist/multi-agent/index.js.map +0 -1
- package/dist/multi-agent/multi-agent-base.d.ts +0 -223
- package/dist/multi-agent/multi-agent-base.d.ts.map +0 -1
- package/dist/multi-agent/multi-agent-base.js +0 -592
- package/dist/multi-agent/multi-agent-base.js.map +0 -1
- package/dist/multi-agent/multi-agent-discord.d.ts +0 -142
- package/dist/multi-agent/multi-agent-discord.d.ts.map +0 -1
- package/dist/multi-agent/multi-agent-discord.js +0 -1235
- package/dist/multi-agent/multi-agent-discord.js.map +0 -1
- package/dist/multi-agent/multi-agent-slack.d.ts +0 -146
- package/dist/multi-agent/multi-agent-slack.d.ts.map +0 -1
- package/dist/multi-agent/multi-agent-slack.js +0 -953
- package/dist/multi-agent/multi-agent-slack.js.map +0 -1
- package/dist/multi-agent/multi-bot-manager.d.ts +0 -119
- package/dist/multi-agent/multi-bot-manager.d.ts.map +0 -1
- package/dist/multi-agent/multi-bot-manager.js +0 -449
- package/dist/multi-agent/multi-bot-manager.js.map +0 -1
- package/dist/multi-agent/orchestrator.d.ts +0 -110
- package/dist/multi-agent/orchestrator.d.ts.map +0 -1
- package/dist/multi-agent/orchestrator.js +0 -436
- package/dist/multi-agent/orchestrator.js.map +0 -1
- package/dist/multi-agent/rate-limiter.d.ts +0 -76
- package/dist/multi-agent/rate-limiter.d.ts.map +0 -1
- package/dist/multi-agent/rate-limiter.js +0 -128
- package/dist/multi-agent/rate-limiter.js.map +0 -1
- package/dist/multi-agent/shared-context.d.ts +0 -127
- package/dist/multi-agent/shared-context.d.ts.map +0 -1
- package/dist/multi-agent/shared-context.js +0 -239
- package/dist/multi-agent/shared-context.js.map +0 -1
- package/dist/multi-agent/slack-config-validator.d.ts +0 -42
- package/dist/multi-agent/slack-config-validator.d.ts.map +0 -1
- package/dist/multi-agent/slack-config-validator.js +0 -194
- package/dist/multi-agent/slack-config-validator.js.map +0 -1
- package/dist/multi-agent/slack-multi-bot-manager.d.ts +0 -143
- package/dist/multi-agent/slack-multi-bot-manager.d.ts.map +0 -1
- package/dist/multi-agent/slack-multi-bot-manager.js +0 -413
- package/dist/multi-agent/slack-multi-bot-manager.js.map +0 -1
- package/dist/multi-agent/swarm/swarm-anti-pattern-detector.d.ts +0 -98
- package/dist/multi-agent/swarm/swarm-anti-pattern-detector.d.ts.map +0 -1
- package/dist/multi-agent/swarm/swarm-anti-pattern-detector.js +0 -225
- package/dist/multi-agent/swarm/swarm-anti-pattern-detector.js.map +0 -1
- package/dist/multi-agent/swarm/swarm-db.d.ts +0 -175
- package/dist/multi-agent/swarm/swarm-db.d.ts.map +0 -1
- package/dist/multi-agent/swarm/swarm-db.js +0 -313
- package/dist/multi-agent/swarm/swarm-db.js.map +0 -1
- package/dist/multi-agent/swarm/swarm-event-reporter.d.ts +0 -116
- package/dist/multi-agent/swarm/swarm-event-reporter.d.ts.map +0 -1
- package/dist/multi-agent/swarm/swarm-event-reporter.js +0 -243
- package/dist/multi-agent/swarm/swarm-event-reporter.js.map +0 -1
- package/dist/multi-agent/swarm/swarm-mama-adapter.d.ts +0 -57
- package/dist/multi-agent/swarm/swarm-mama-adapter.d.ts.map +0 -1
- package/dist/multi-agent/swarm/swarm-mama-adapter.js +0 -87
- package/dist/multi-agent/swarm/swarm-mama-adapter.js.map +0 -1
- package/dist/multi-agent/swarm/swarm-manager.d.ts +0 -122
- package/dist/multi-agent/swarm/swarm-manager.d.ts.map +0 -1
- package/dist/multi-agent/swarm/swarm-manager.js +0 -199
- package/dist/multi-agent/swarm/swarm-manager.js.map +0 -1
- package/dist/multi-agent/swarm/swarm-task-learner.d.ts +0 -104
- package/dist/multi-agent/swarm/swarm-task-learner.d.ts.map +0 -1
- package/dist/multi-agent/swarm/swarm-task-learner.js +0 -211
- package/dist/multi-agent/swarm/swarm-task-learner.js.map +0 -1
- package/dist/multi-agent/swarm/swarm-task-runner.d.ts +0 -155
- package/dist/multi-agent/swarm/swarm-task-runner.d.ts.map +0 -1
- package/dist/multi-agent/swarm/swarm-task-runner.js +0 -615
- package/dist/multi-agent/swarm/swarm-task-runner.js.map +0 -1
- package/dist/multi-agent/swarm/wave-engine.d.ts +0 -96
- package/dist/multi-agent/swarm/wave-engine.d.ts.map +0 -1
- package/dist/multi-agent/swarm/wave-engine.js +0 -123
- package/dist/multi-agent/swarm/wave-engine.js.map +0 -1
- package/dist/multi-agent/system-reminder.d.ts +0 -206
- package/dist/multi-agent/system-reminder.d.ts.map +0 -1
- package/dist/multi-agent/system-reminder.js +0 -455
- package/dist/multi-agent/system-reminder.js.map +0 -1
- package/dist/multi-agent/task-continuation.d.ts +0 -74
- package/dist/multi-agent/task-continuation.d.ts.map +0 -1
- package/dist/multi-agent/task-continuation.js +0 -172
- package/dist/multi-agent/task-continuation.js.map +0 -1
- package/dist/multi-agent/ultrawork-state.d.ts +0 -57
- package/dist/multi-agent/ultrawork-state.d.ts.map +0 -1
- package/dist/multi-agent/ultrawork-state.js +0 -191
- package/dist/multi-agent/ultrawork-state.js.map +0 -1
- package/dist/multi-agent/ultrawork.d.ts +0 -152
- package/dist/multi-agent/ultrawork.d.ts.map +0 -1
- package/dist/multi-agent/ultrawork.js +0 -879
- package/dist/multi-agent/ultrawork.js.map +0 -1
- package/dist/multi-agent/work-tracker.d.ts +0 -22
- package/dist/multi-agent/work-tracker.d.ts.map +0 -1
- package/dist/multi-agent/work-tracker.js +0 -45
- package/dist/multi-agent/work-tracker.js.map +0 -1
- package/dist/multi-agent/workflow-engine.d.ts +0 -87
- package/dist/multi-agent/workflow-engine.d.ts.map +0 -1
- package/dist/multi-agent/workflow-engine.js +0 -604
- package/dist/multi-agent/workflow-engine.js.map +0 -1
- package/dist/onboarding/all-tools.d.ts +0 -18
- package/dist/onboarding/all-tools.d.ts.map +0 -1
- package/dist/onboarding/all-tools.js +0 -149
- package/dist/onboarding/all-tools.js.map +0 -1
- package/dist/onboarding/autonomous-discovery-tools.d.ts +0 -23
- package/dist/onboarding/autonomous-discovery-tools.d.ts.map +0 -1
- package/dist/onboarding/autonomous-discovery-tools.js +0 -268
- package/dist/onboarding/autonomous-discovery-tools.js.map +0 -1
- package/dist/onboarding/onboarding-state.d.ts +0 -70
- package/dist/onboarding/onboarding-state.d.ts.map +0 -1
- package/dist/onboarding/onboarding-state.js +0 -183
- package/dist/onboarding/onboarding-state.js.map +0 -1
- package/dist/onboarding/personality-quiz.d.ts +0 -35
- package/dist/onboarding/personality-quiz.d.ts.map +0 -1
- package/dist/onboarding/personality-quiz.js +0 -219
- package/dist/onboarding/personality-quiz.js.map +0 -1
- package/dist/onboarding/phase-5-summary.d.ts +0 -26
- package/dist/onboarding/phase-5-summary.d.ts.map +0 -1
- package/dist/onboarding/phase-5-summary.js +0 -153
- package/dist/onboarding/phase-5-summary.js.map +0 -1
- package/dist/onboarding/phase-6-security.d.ts +0 -33
- package/dist/onboarding/phase-6-security.d.ts.map +0 -1
- package/dist/onboarding/phase-6-security.js +0 -473
- package/dist/onboarding/phase-6-security.js.map +0 -1
- package/dist/onboarding/phase-7-integrations.d.ts +0 -91
- package/dist/onboarding/phase-7-integrations.d.ts.map +0 -1
- package/dist/onboarding/phase-7-integrations.js +0 -725
- package/dist/onboarding/phase-7-integrations.js.map +0 -1
- package/dist/onboarding/phase-8-demo.d.ts +0 -43
- package/dist/onboarding/phase-8-demo.d.ts.map +0 -1
- package/dist/onboarding/phase-8-demo.js +0 -346
- package/dist/onboarding/phase-8-demo.js.map +0 -1
- package/dist/onboarding/phase-9-finalization.d.ts +0 -27
- package/dist/onboarding/phase-9-finalization.d.ts.map +0 -1
- package/dist/onboarding/phase-9-finalization.js +0 -417
- package/dist/onboarding/phase-9-finalization.js.map +0 -1
- package/dist/onboarding/ritual-prompt.d.ts +0 -2
- package/dist/onboarding/ritual-prompt.d.ts.map +0 -1
- package/dist/onboarding/ritual-prompt.js +0 -285
- package/dist/onboarding/ritual-prompt.js.map +0 -1
- package/dist/onboarding/ritual-tools.d.ts +0 -17
- package/dist/onboarding/ritual-tools.d.ts.map +0 -1
- package/dist/onboarding/ritual-tools.js +0 -93
- package/dist/onboarding/ritual-tools.js.map +0 -1
- package/dist/setup/setup-tools.d.ts +0 -13
- package/dist/setup/setup-tools.d.ts.map +0 -1
- package/dist/setup/setup-tools.js +0 -106
- package/dist/setup/setup-tools.js.map +0 -1
- package/dist/utils/slack-input-validator.d.ts +0 -74
- package/dist/utils/slack-input-validator.d.ts.map +0 -1
- package/dist/utils/slack-input-validator.js +0 -275
- package/dist/utils/slack-input-validator.js.map +0 -1
- package/dist/utils/slack-rate-limiter.d.ts +0 -139
- package/dist/utils/slack-rate-limiter.d.ts.map +0 -1
- package/dist/utils/slack-rate-limiter.js +0 -324
- package/dist/utils/slack-rate-limiter.js.map +0 -1
- package/dist/wiki/wiki-compiler.d.ts +0 -13
- package/dist/wiki/wiki-compiler.d.ts.map +0 -1
- package/dist/wiki/wiki-compiler.js +0 -82
- package/dist/wiki/wiki-compiler.js.map +0 -1
|
@@ -1,879 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* UltraWork Manager
|
|
4
|
-
*
|
|
5
|
-
* Manages autonomous multi-step work sessions that combine
|
|
6
|
-
* delegation and task continuation for extended workflows.
|
|
7
|
-
*
|
|
8
|
-
* Supports two modes:
|
|
9
|
-
* 1. **Phased Loop** (Ralph Loop, default): Plan -> Build -> Retrospective
|
|
10
|
-
* - File-based state persist for crash recovery
|
|
11
|
-
* - Council integration at plan and retrospective phases
|
|
12
|
-
* - Structured task execution from plan
|
|
13
|
-
* 2. **Freeform Loop** (legacy): Lead agent freely delegates and continues
|
|
14
|
-
*
|
|
15
|
-
* Constraints:
|
|
16
|
-
* - max_duration (default 60 min)
|
|
17
|
-
* - max_steps (default 50)
|
|
18
|
-
* - Lead agent must be Tier 1 with can_delegate
|
|
19
|
-
*/
|
|
20
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
-
if (k2 === undefined) k2 = k;
|
|
22
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
-
}
|
|
26
|
-
Object.defineProperty(o, k2, desc);
|
|
27
|
-
}) : (function(o, m, k, k2) {
|
|
28
|
-
if (k2 === undefined) k2 = k;
|
|
29
|
-
o[k2] = m[k];
|
|
30
|
-
}));
|
|
31
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33
|
-
}) : function(o, v) {
|
|
34
|
-
o["default"] = v;
|
|
35
|
-
});
|
|
36
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
37
|
-
var ownKeys = function(o) {
|
|
38
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
39
|
-
var ar = [];
|
|
40
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
41
|
-
return ar;
|
|
42
|
-
};
|
|
43
|
-
return ownKeys(o);
|
|
44
|
-
};
|
|
45
|
-
return function (mod) {
|
|
46
|
-
if (mod && mod.__esModule) return mod;
|
|
47
|
-
var result = {};
|
|
48
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
49
|
-
__setModuleDefault(result, mod);
|
|
50
|
-
return result;
|
|
51
|
-
};
|
|
52
|
-
})();
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.UltraWorkManager = void 0;
|
|
55
|
-
const tool_permission_manager_js_1 = require("./tool-permission-manager.js");
|
|
56
|
-
const delegation_manager_js_1 = require("./delegation-manager.js");
|
|
57
|
-
const task_continuation_js_1 = require("./task-continuation.js");
|
|
58
|
-
const ultrawork_state_js_1 = require("./ultrawork-state.js");
|
|
59
|
-
const os = __importStar(require("os"));
|
|
60
|
-
const path = __importStar(require("path"));
|
|
61
|
-
const config_manager_js_1 = require("../cli/config/config-manager.js");
|
|
62
|
-
/** Default timeout for executeCallback (5 minutes) */
|
|
63
|
-
const DEFAULT_EXECUTE_TIMEOUT = () => (0, config_manager_js_1.getConfig)().timeouts?.ultrawork_ms ?? 300_000;
|
|
64
|
-
/** Default stall threshold — if response is too short, likely stalled */
|
|
65
|
-
const STALL_MIN_LENGTH = 20;
|
|
66
|
-
/** Max consecutive stalls before forcing a re-prompt */
|
|
67
|
-
const MAX_CONSECUTIVE_STALLS = 2;
|
|
68
|
-
/**
|
|
69
|
-
* Default trigger keywords for UltraWork
|
|
70
|
-
*/
|
|
71
|
-
const DEFAULT_TRIGGER_KEYWORDS = [
|
|
72
|
-
'ultrawork',
|
|
73
|
-
'울트라워크',
|
|
74
|
-
'deep work',
|
|
75
|
-
'autonomous',
|
|
76
|
-
'자율 작업',
|
|
77
|
-
];
|
|
78
|
-
/**
|
|
79
|
-
* UltraWork Manager
|
|
80
|
-
*/
|
|
81
|
-
class UltraWorkManager {
|
|
82
|
-
config;
|
|
83
|
-
permissionManager;
|
|
84
|
-
stateManager = null;
|
|
85
|
-
/** Active sessions per channel */
|
|
86
|
-
sessions = new Map();
|
|
87
|
-
/** Session counter for unique IDs */
|
|
88
|
-
sessionCounter = 0;
|
|
89
|
-
/** Sessions DB for agent_activity logging in delegations */
|
|
90
|
-
sessionsDb = null;
|
|
91
|
-
setSessionsDb(db) {
|
|
92
|
-
this.sessionsDb = db;
|
|
93
|
-
}
|
|
94
|
-
constructor(config, permissionManager) {
|
|
95
|
-
this.config = config;
|
|
96
|
-
this.permissionManager = permissionManager ?? new tool_permission_manager_js_1.ToolPermissionManager();
|
|
97
|
-
if (config.persist_state !== false) {
|
|
98
|
-
this.stateManager = new ultrawork_state_js_1.UltraWorkStateManager(path.join(os.homedir(), '.mama', 'workspace', 'ultrawork'));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Check if a message contains UltraWork trigger keywords.
|
|
103
|
-
*/
|
|
104
|
-
isUltraWorkTrigger(content) {
|
|
105
|
-
if (!this.config.enabled)
|
|
106
|
-
return false;
|
|
107
|
-
const keywords = this.config.trigger_keywords ?? DEFAULT_TRIGGER_KEYWORDS;
|
|
108
|
-
const lower = content.toLowerCase();
|
|
109
|
-
return keywords.some((kw) => lower.includes(kw.toLowerCase()));
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Start a new UltraWork session.
|
|
113
|
-
*/
|
|
114
|
-
async startSession(channelId, leadAgentId, task, agents, executeCallback, notifyCallback, responseInterceptor) {
|
|
115
|
-
// Validate lead agent
|
|
116
|
-
const leadAgent = agents.find((a) => a.id === leadAgentId);
|
|
117
|
-
if (!leadAgent) {
|
|
118
|
-
throw new Error(`Unknown lead agent: ${leadAgentId}`);
|
|
119
|
-
}
|
|
120
|
-
if (!this.permissionManager.canDelegate(leadAgent)) {
|
|
121
|
-
throw new Error(`Lead agent ${leadAgentId} must be Tier 1 with can_delegate=true`);
|
|
122
|
-
}
|
|
123
|
-
// Stop existing session for this channel
|
|
124
|
-
if (this.sessions.has(channelId)) {
|
|
125
|
-
this.stopSession(channelId);
|
|
126
|
-
}
|
|
127
|
-
const session = {
|
|
128
|
-
id: `uw_${++this.sessionCounter}_${Date.now()}`,
|
|
129
|
-
channelId,
|
|
130
|
-
leadAgentId,
|
|
131
|
-
task,
|
|
132
|
-
currentStep: 0,
|
|
133
|
-
maxSteps: this.config.max_steps ?? 50,
|
|
134
|
-
startTime: Date.now(),
|
|
135
|
-
maxDuration: this.config.max_duration ?? 3600000, // 60 min
|
|
136
|
-
active: true,
|
|
137
|
-
steps: [],
|
|
138
|
-
};
|
|
139
|
-
this.sessions.set(channelId, session);
|
|
140
|
-
// Persist session state
|
|
141
|
-
if (this.stateManager) {
|
|
142
|
-
await this.stateManager.createSession(session.id, task, agents.filter((a) => a.enabled !== false).map((a) => a.id));
|
|
143
|
-
}
|
|
144
|
-
const modeLabel = this.config.phased_loop !== false ? 'Phased (Plan->Build->Retro)' : 'Freeform';
|
|
145
|
-
await notifyCallback(`**UltraWork Session Started** (${session.id})\n` +
|
|
146
|
-
`Lead: **${leadAgent.display_name}**\n` +
|
|
147
|
-
`Mode: ${modeLabel}\n` +
|
|
148
|
-
`Task: ${task.substring(0, 200)}${task.length > 200 ? '...' : ''}\n` +
|
|
149
|
-
`Limits: ${session.maxSteps} steps, ${Math.round(session.maxDuration / 60000)} min`);
|
|
150
|
-
// Run the autonomous loop in detached context (non-blocking)
|
|
151
|
-
this.runSessionLoop(session, agents, executeCallback, notifyCallback, responseInterceptor).catch((err) => {
|
|
152
|
-
console.error(`[UltraWork] Session ${session.id} loop error:`, err);
|
|
153
|
-
session.active = false;
|
|
154
|
-
this.sessions.delete(session.channelId);
|
|
155
|
-
notifyCallback(`**UltraWork Session Error** (${session.id}): ${err instanceof Error ? err.message : String(err)}`).catch(() => { });
|
|
156
|
-
});
|
|
157
|
-
return session;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Check if a session should continue.
|
|
161
|
-
*/
|
|
162
|
-
shouldContinue(session) {
|
|
163
|
-
if (!session.active)
|
|
164
|
-
return false;
|
|
165
|
-
if (session.currentStep >= session.maxSteps)
|
|
166
|
-
return false;
|
|
167
|
-
if (Date.now() - session.startTime >= session.maxDuration)
|
|
168
|
-
return false;
|
|
169
|
-
return true;
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Stop an active session.
|
|
173
|
-
*/
|
|
174
|
-
stopSession(channelId) {
|
|
175
|
-
const session = this.sessions.get(channelId);
|
|
176
|
-
if (!session)
|
|
177
|
-
return null;
|
|
178
|
-
session.active = false;
|
|
179
|
-
this.sessions.delete(channelId);
|
|
180
|
-
return session;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Get active session for a channel.
|
|
184
|
-
*/
|
|
185
|
-
getSession(channelId) {
|
|
186
|
-
return this.sessions.get(channelId) ?? null;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Get all active sessions.
|
|
190
|
-
*/
|
|
191
|
-
getActiveSessions() {
|
|
192
|
-
return Array.from(this.sessions.values()).filter((s) => s.active);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Check if UltraWork is enabled.
|
|
196
|
-
*/
|
|
197
|
-
isEnabled() {
|
|
198
|
-
return this.config.enabled;
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* Update configuration.
|
|
202
|
-
*/
|
|
203
|
-
updateConfig(config) {
|
|
204
|
-
this.config = config;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Get the state manager (for testing).
|
|
208
|
-
*/
|
|
209
|
-
getStateManager() {
|
|
210
|
-
return this.stateManager;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Override state manager (for testing with temp dirs).
|
|
214
|
-
*/
|
|
215
|
-
setStateManager(sm) {
|
|
216
|
-
this.stateManager = sm;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Execute callback with timeout protection.
|
|
220
|
-
*/
|
|
221
|
-
async executeWithTimeout(executeCallback, agentId, prompt, timeoutMs = DEFAULT_EXECUTE_TIMEOUT()) {
|
|
222
|
-
let timeoutHandle;
|
|
223
|
-
const result = await Promise.race([
|
|
224
|
-
executeCallback(agentId, prompt),
|
|
225
|
-
new Promise((_, reject) => {
|
|
226
|
-
timeoutHandle = setTimeout(() => reject(new Error(`Agent ${agentId} timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
227
|
-
}),
|
|
228
|
-
]);
|
|
229
|
-
clearTimeout(timeoutHandle);
|
|
230
|
-
return result;
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* Run the autonomous session loop — dispatches to phased or freeform mode.
|
|
234
|
-
*/
|
|
235
|
-
async runSessionLoop(session, agents, executeCallback, notifyCallback, responseInterceptor) {
|
|
236
|
-
if (this.config.phased_loop !== false) {
|
|
237
|
-
await this.runPhasedLoop(session, agents, executeCallback, notifyCallback, responseInterceptor);
|
|
238
|
-
}
|
|
239
|
-
else {
|
|
240
|
-
await this.runFreeformLoop(session, agents, executeCallback, notifyCallback, responseInterceptor);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
// ============================================================================
|
|
244
|
-
// Phase 1: Planning
|
|
245
|
-
// ============================================================================
|
|
246
|
-
async runPlanningPhase(session, agents, executeCallback, notifyCallback, responseInterceptor) {
|
|
247
|
-
await notifyCallback(`**Phase 1: Planning** - Creating implementation plan...`);
|
|
248
|
-
session.currentStep++;
|
|
249
|
-
const planPrompt = this.buildPlanningPrompt(session.task, agents);
|
|
250
|
-
const planResult = await this.executeWithTimeout(executeCallback, session.leadAgentId, planPrompt);
|
|
251
|
-
session.steps.push({
|
|
252
|
-
stepNumber: session.currentStep,
|
|
253
|
-
agentId: session.leadAgentId,
|
|
254
|
-
action: 'planning',
|
|
255
|
-
responseSummary: planResult.response.substring(0, 200),
|
|
256
|
-
isDelegation: false,
|
|
257
|
-
duration: planResult.duration ?? 0,
|
|
258
|
-
timestamp: Date.now(),
|
|
259
|
-
});
|
|
260
|
-
// Council check — if Conductor outputs council_plan, interceptor will handle it
|
|
261
|
-
let councilResult = null;
|
|
262
|
-
if (responseInterceptor) {
|
|
263
|
-
const intercepted = await responseInterceptor(planResult.response, session.channelId);
|
|
264
|
-
if (intercepted?.type === 'council') {
|
|
265
|
-
councilResult = intercepted.result;
|
|
266
|
-
await notifyCallback(councilResult);
|
|
267
|
-
session.currentStep++;
|
|
268
|
-
session.steps.push({
|
|
269
|
-
stepNumber: session.currentStep,
|
|
270
|
-
agentId: session.leadAgentId,
|
|
271
|
-
action: 'council_execution',
|
|
272
|
-
responseSummary: councilResult.substring(0, 200),
|
|
273
|
-
isDelegation: false,
|
|
274
|
-
duration: 0,
|
|
275
|
-
timestamp: Date.now(),
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
// Synthesize final plan (with council input if available)
|
|
280
|
-
let finalPlan;
|
|
281
|
-
if (councilResult) {
|
|
282
|
-
session.currentStep++;
|
|
283
|
-
const synthesisPrompt = `Based on the council discussion:\n---\n${councilResult}\n---\n\n` +
|
|
284
|
-
`Create the final IMPLEMENTATION_PLAN. Format:\n## Tasks\n1. [task description] - assigned to: [agent_id]\n2. ...\n\n` +
|
|
285
|
-
`Include acceptance criteria for each task. End with "PLAN_COMPLETE".`;
|
|
286
|
-
const synthesis = await this.executeWithTimeout(executeCallback, session.leadAgentId, synthesisPrompt);
|
|
287
|
-
finalPlan = synthesis.response;
|
|
288
|
-
session.steps.push({
|
|
289
|
-
stepNumber: session.currentStep,
|
|
290
|
-
agentId: session.leadAgentId,
|
|
291
|
-
action: 'plan_synthesis',
|
|
292
|
-
responseSummary: finalPlan.substring(0, 200),
|
|
293
|
-
isDelegation: false,
|
|
294
|
-
duration: synthesis.duration ?? 0,
|
|
295
|
-
timestamp: Date.now(),
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
finalPlan = planResult.response;
|
|
300
|
-
}
|
|
301
|
-
// Persist plan
|
|
302
|
-
if (this.stateManager) {
|
|
303
|
-
await this.stateManager.savePlan(session.id, finalPlan);
|
|
304
|
-
}
|
|
305
|
-
return finalPlan;
|
|
306
|
-
}
|
|
307
|
-
// ============================================================================
|
|
308
|
-
// Phase 2: Building
|
|
309
|
-
// ============================================================================
|
|
310
|
-
async runBuildingPhase(session, plan, agents, executeCallback, notifyCallback, responseInterceptor) {
|
|
311
|
-
await notifyCallback(`**Phase 2: Building** - Executing plan...`);
|
|
312
|
-
const delegationManager = new delegation_manager_js_1.DelegationManager(agents, this.permissionManager);
|
|
313
|
-
if (this.sessionsDb)
|
|
314
|
-
delegationManager.setSessionsDb(this.sessionsDb);
|
|
315
|
-
const continuationEnforcer = new task_continuation_js_1.TaskContinuationEnforcer({
|
|
316
|
-
enabled: true,
|
|
317
|
-
max_retries: 3,
|
|
318
|
-
});
|
|
319
|
-
let consecutiveStalls = 0;
|
|
320
|
-
let currentPrompt = this.buildBuildingPrompt(plan, agents);
|
|
321
|
-
let currentAgentId = session.leadAgentId;
|
|
322
|
-
while (this.shouldContinue(session)) {
|
|
323
|
-
session.currentStep++;
|
|
324
|
-
const stepStart = Date.now();
|
|
325
|
-
try {
|
|
326
|
-
const result = await this.executeWithTimeout(executeCallback, currentAgentId, currentPrompt);
|
|
327
|
-
const stepDuration = Date.now() - stepStart;
|
|
328
|
-
// Stall detection
|
|
329
|
-
if (result.response.trim().length < STALL_MIN_LENGTH) {
|
|
330
|
-
consecutiveStalls++;
|
|
331
|
-
if (consecutiveStalls >= MAX_CONSECUTIVE_STALLS) {
|
|
332
|
-
consecutiveStalls = 0;
|
|
333
|
-
await notifyCallback(`Agent ${currentAgentId} appears stalled (${MAX_CONSECUTIVE_STALLS} short responses). Re-prompting...`);
|
|
334
|
-
currentPrompt =
|
|
335
|
-
`Your previous responses were too brief. The task is NOT complete yet.\n\n` +
|
|
336
|
-
`Original plan:\n${plan.substring(0, 1000)}\n\n` +
|
|
337
|
-
`Please continue executing the plan. When ALL tasks are done, respond with "BUILD_COMPLETE".`;
|
|
338
|
-
currentAgentId = session.leadAgentId;
|
|
339
|
-
session.steps.push({
|
|
340
|
-
stepNumber: session.currentStep,
|
|
341
|
-
agentId: currentAgentId,
|
|
342
|
-
action: 'stall_detected',
|
|
343
|
-
responseSummary: `Stalled: "${result.response.trim().substring(0, 100)}"`,
|
|
344
|
-
isDelegation: false,
|
|
345
|
-
duration: stepDuration,
|
|
346
|
-
timestamp: Date.now(),
|
|
347
|
-
});
|
|
348
|
-
continue;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
consecutiveStalls = 0;
|
|
353
|
-
}
|
|
354
|
-
// Council/workflow interceptor
|
|
355
|
-
if (responseInterceptor) {
|
|
356
|
-
const intercepted = await responseInterceptor(result.response, session.channelId);
|
|
357
|
-
if (intercepted) {
|
|
358
|
-
session.steps.push({
|
|
359
|
-
stepNumber: session.currentStep,
|
|
360
|
-
agentId: currentAgentId,
|
|
361
|
-
action: intercepted.type === 'council' ? 'council_execution' : 'workflow_execution',
|
|
362
|
-
responseSummary: intercepted.result.substring(0, 200),
|
|
363
|
-
isDelegation: false,
|
|
364
|
-
duration: Date.now() - stepStart,
|
|
365
|
-
timestamp: Date.now(),
|
|
366
|
-
});
|
|
367
|
-
await notifyCallback(intercepted.result);
|
|
368
|
-
currentPrompt =
|
|
369
|
-
`The ${intercepted.type} plan completed. Results:\n---\n${intercepted.result.substring(0, 1000)}\n---\n` +
|
|
370
|
-
`Continue executing the plan. When ALL tasks are done, respond with "BUILD_COMPLETE".`;
|
|
371
|
-
currentAgentId = session.leadAgentId;
|
|
372
|
-
continue;
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// Delegation check
|
|
376
|
-
const delegationRequest = delegationManager.parseDelegation(currentAgentId, result.response);
|
|
377
|
-
if (delegationRequest) {
|
|
378
|
-
session.steps.push({
|
|
379
|
-
stepNumber: session.currentStep,
|
|
380
|
-
agentId: currentAgentId,
|
|
381
|
-
action: 'delegation',
|
|
382
|
-
responseSummary: delegationRequest.originalContent.substring(0, 200),
|
|
383
|
-
isDelegation: true,
|
|
384
|
-
duration: stepDuration,
|
|
385
|
-
timestamp: Date.now(),
|
|
386
|
-
});
|
|
387
|
-
const delegationResult = await delegationManager.executeDelegation(delegationRequest, executeCallback, notifyCallback);
|
|
388
|
-
if (delegationResult.success && delegationResult.response) {
|
|
389
|
-
session.currentStep++;
|
|
390
|
-
session.steps.push({
|
|
391
|
-
stepNumber: session.currentStep,
|
|
392
|
-
agentId: delegationRequest.toAgentId,
|
|
393
|
-
action: 'delegated_task',
|
|
394
|
-
responseSummary: delegationResult.response.substring(0, 200),
|
|
395
|
-
isDelegation: false,
|
|
396
|
-
duration: delegationResult.duration ?? 0,
|
|
397
|
-
timestamp: Date.now(),
|
|
398
|
-
});
|
|
399
|
-
// Persist step
|
|
400
|
-
if (this.stateManager) {
|
|
401
|
-
await this.stateManager.recordStep(session.id, {
|
|
402
|
-
stepNumber: session.currentStep,
|
|
403
|
-
agentId: delegationRequest.toAgentId,
|
|
404
|
-
action: 'delegated_task',
|
|
405
|
-
responseSummary: delegationResult.response.substring(0, 200),
|
|
406
|
-
isDelegation: false,
|
|
407
|
-
duration: delegationResult.duration ?? 0,
|
|
408
|
-
timestamp: Date.now(),
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
currentPrompt = this.buildContinuationAfterDelegation(delegationRequest.toAgentId, delegationResult.response);
|
|
412
|
-
currentAgentId = session.leadAgentId;
|
|
413
|
-
}
|
|
414
|
-
else {
|
|
415
|
-
currentPrompt = `Delegation to ${delegationRequest.toAgentId} failed: ${delegationResult.error}. Please continue the task yourself.`;
|
|
416
|
-
currentAgentId = session.leadAgentId;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
// No delegation — record step, check build completion
|
|
421
|
-
session.steps.push({
|
|
422
|
-
stepNumber: session.currentStep,
|
|
423
|
-
agentId: currentAgentId,
|
|
424
|
-
action: 'direct_work',
|
|
425
|
-
responseSummary: result.response.substring(0, 200),
|
|
426
|
-
isDelegation: false,
|
|
427
|
-
duration: stepDuration,
|
|
428
|
-
timestamp: Date.now(),
|
|
429
|
-
});
|
|
430
|
-
// Persist step
|
|
431
|
-
if (this.stateManager) {
|
|
432
|
-
await this.stateManager.recordStep(session.id, {
|
|
433
|
-
stepNumber: session.currentStep,
|
|
434
|
-
agentId: currentAgentId,
|
|
435
|
-
action: 'direct_work',
|
|
436
|
-
responseSummary: result.response.substring(0, 200),
|
|
437
|
-
isDelegation: false,
|
|
438
|
-
duration: stepDuration,
|
|
439
|
-
timestamp: Date.now(),
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
// Build-phase completion check
|
|
443
|
-
if (this.isBuildComplete(result.response)) {
|
|
444
|
-
return; // Move to retrospective
|
|
445
|
-
}
|
|
446
|
-
// Fallback: use continuation enforcer for "DONE" compat
|
|
447
|
-
const continuation = continuationEnforcer.analyzeResponse(currentAgentId, session.channelId, result.response);
|
|
448
|
-
if (continuation.isComplete) {
|
|
449
|
-
return; // Move to retrospective
|
|
450
|
-
}
|
|
451
|
-
if (continuation.maxRetriesReached) {
|
|
452
|
-
return; // Move to retrospective anyway
|
|
453
|
-
}
|
|
454
|
-
currentPrompt = continuationEnforcer.buildContinuationPrompt(result.response);
|
|
455
|
-
currentAgentId = session.leadAgentId;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
catch (error) {
|
|
459
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
460
|
-
session.steps.push({
|
|
461
|
-
stepNumber: session.currentStep,
|
|
462
|
-
agentId: currentAgentId,
|
|
463
|
-
action: 'error',
|
|
464
|
-
responseSummary: errorMessage.substring(0, 200),
|
|
465
|
-
isDelegation: false,
|
|
466
|
-
duration: Date.now() - stepStart,
|
|
467
|
-
timestamp: Date.now(),
|
|
468
|
-
});
|
|
469
|
-
currentPrompt = `An error occurred: ${errorMessage}. Please assess the situation and decide how to continue.`;
|
|
470
|
-
currentAgentId = session.leadAgentId;
|
|
471
|
-
}
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
// ============================================================================
|
|
475
|
-
// Phase 3: Retrospective
|
|
476
|
-
// ============================================================================
|
|
477
|
-
async runRetrospectivePhase(session, planFromPhase1, _agents, executeCallback, notifyCallback, responseInterceptor) {
|
|
478
|
-
await notifyCallback(`**Phase 3: Retrospective** - Reviewing results...`);
|
|
479
|
-
const steps = this.stateManager
|
|
480
|
-
? await this.stateManager.loadProgress(session.id)
|
|
481
|
-
: session.steps;
|
|
482
|
-
const plan = this.stateManager
|
|
483
|
-
? ((await this.stateManager.loadPlan(session.id)) ?? planFromPhase1)
|
|
484
|
-
: planFromPhase1;
|
|
485
|
-
session.currentStep++;
|
|
486
|
-
const retroPrompt = this.buildRetrospectivePrompt(plan, steps);
|
|
487
|
-
const retroResult = await this.executeWithTimeout(executeCallback, session.leadAgentId, retroPrompt);
|
|
488
|
-
session.steps.push({
|
|
489
|
-
stepNumber: session.currentStep,
|
|
490
|
-
agentId: session.leadAgentId,
|
|
491
|
-
action: 'retrospective',
|
|
492
|
-
responseSummary: retroResult.response.substring(0, 200),
|
|
493
|
-
isDelegation: false,
|
|
494
|
-
duration: retroResult.duration ?? 0,
|
|
495
|
-
timestamp: Date.now(),
|
|
496
|
-
});
|
|
497
|
-
// Council check
|
|
498
|
-
if (responseInterceptor) {
|
|
499
|
-
const intercepted = await responseInterceptor(retroResult.response, session.channelId);
|
|
500
|
-
if (intercepted?.type === 'council') {
|
|
501
|
-
await notifyCallback(intercepted.result);
|
|
502
|
-
session.currentStep++;
|
|
503
|
-
session.steps.push({
|
|
504
|
-
stepNumber: session.currentStep,
|
|
505
|
-
agentId: session.leadAgentId,
|
|
506
|
-
action: 'council_execution',
|
|
507
|
-
responseSummary: intercepted.result.substring(0, 200),
|
|
508
|
-
isDelegation: false,
|
|
509
|
-
duration: 0,
|
|
510
|
-
timestamp: Date.now(),
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
const isComplete = this.isRetroComplete(retroResult.response);
|
|
515
|
-
// Persist retrospective
|
|
516
|
-
if (this.stateManager) {
|
|
517
|
-
await this.stateManager.saveRetrospective(session.id, retroResult.response);
|
|
518
|
-
}
|
|
519
|
-
return { complete: isComplete, retro: retroResult.response };
|
|
520
|
-
}
|
|
521
|
-
// ============================================================================
|
|
522
|
-
// Phased Loop (Ralph Loop): Plan -> Build -> Retrospective
|
|
523
|
-
// ============================================================================
|
|
524
|
-
async runPhasedLoop(session, agents, executeCallback, notifyCallback, responseInterceptor) {
|
|
525
|
-
// Phase 1: Planning + Council
|
|
526
|
-
if (this.stateManager) {
|
|
527
|
-
await this.stateManager.updatePhase(session.id, 'planning');
|
|
528
|
-
}
|
|
529
|
-
const plan = await this.runPlanningPhase(session, agents, executeCallback, notifyCallback, responseInterceptor);
|
|
530
|
-
if (!this.shouldContinue(session)) {
|
|
531
|
-
this.endSession(session, notifyCallback);
|
|
532
|
-
return;
|
|
533
|
-
}
|
|
534
|
-
// Phase 2: Building
|
|
535
|
-
if (this.stateManager) {
|
|
536
|
-
await this.stateManager.updatePhase(session.id, 'building');
|
|
537
|
-
}
|
|
538
|
-
await this.runBuildingPhase(session, plan, agents, executeCallback, notifyCallback, responseInterceptor);
|
|
539
|
-
if (!this.shouldContinue(session)) {
|
|
540
|
-
this.endSession(session, notifyCallback);
|
|
541
|
-
return;
|
|
542
|
-
}
|
|
543
|
-
// Phase 3: Retrospective + Council
|
|
544
|
-
if (this.stateManager) {
|
|
545
|
-
await this.stateManager.updatePhase(session.id, 'retrospective');
|
|
546
|
-
}
|
|
547
|
-
const { complete } = await this.runRetrospectivePhase(session, plan, agents, executeCallback, notifyCallback, responseInterceptor);
|
|
548
|
-
if (!complete && this.shouldContinue(session)) {
|
|
549
|
-
// Incomplete → re-enter Build phase (max 1 retry)
|
|
550
|
-
await notifyCallback(`Retrospective found incomplete items. Re-entering Build phase...`);
|
|
551
|
-
if (this.stateManager) {
|
|
552
|
-
await this.stateManager.updatePhase(session.id, 'building');
|
|
553
|
-
}
|
|
554
|
-
await this.runBuildingPhase(session, plan, agents, executeCallback, notifyCallback, responseInterceptor);
|
|
555
|
-
// Re-run retrospective after retry Build phase
|
|
556
|
-
if (!this.shouldContinue(session)) {
|
|
557
|
-
// Session cancelled or limits exceeded
|
|
558
|
-
session.active = false;
|
|
559
|
-
this.sessions.delete(session.channelId);
|
|
560
|
-
await notifyCallback(`**UltraWork Session Ended** — limits exceeded or cancelled`);
|
|
561
|
-
return;
|
|
562
|
-
}
|
|
563
|
-
if (this.stateManager) {
|
|
564
|
-
await this.stateManager.updatePhase(session.id, 'retrospective');
|
|
565
|
-
}
|
|
566
|
-
const retryRetro = await this.runRetrospectivePhase(session, plan, agents, executeCallback, notifyCallback, responseInterceptor);
|
|
567
|
-
if (!retryRetro.complete) {
|
|
568
|
-
// Still incomplete after retry — end session with warning
|
|
569
|
-
if (this.stateManager) {
|
|
570
|
-
await this.stateManager.updatePhase(session.id, 'completed');
|
|
571
|
-
}
|
|
572
|
-
session.active = false;
|
|
573
|
-
this.sessions.delete(session.channelId);
|
|
574
|
-
await notifyCallback(`**UltraWork Session Complete** (${session.id}) — with incomplete items\n` +
|
|
575
|
-
`Phases: Plan -> Build -> Retro -> Build (retry) -> Retro\n` +
|
|
576
|
-
`Steps: ${session.currentStep} | Duration: ${Math.round((Date.now() - session.startTime) / 1000)}s`);
|
|
577
|
-
return;
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
// Complete
|
|
581
|
-
if (this.stateManager) {
|
|
582
|
-
await this.stateManager.updatePhase(session.id, 'completed');
|
|
583
|
-
}
|
|
584
|
-
session.active = false;
|
|
585
|
-
this.sessions.delete(session.channelId);
|
|
586
|
-
await notifyCallback(`**UltraWork Session Complete** (${session.id})\n` +
|
|
587
|
-
`Phases: Plan -> Build -> Retrospective\n` +
|
|
588
|
-
`Steps: ${session.currentStep} | Duration: ${Math.round((Date.now() - session.startTime) / 1000)}s`);
|
|
589
|
-
}
|
|
590
|
-
// ============================================================================
|
|
591
|
-
// Freeform Loop (Legacy)
|
|
592
|
-
// ============================================================================
|
|
593
|
-
async runFreeformLoop(session, agents, executeCallback, notifyCallback, responseInterceptor) {
|
|
594
|
-
const delegationManager = new delegation_manager_js_1.DelegationManager(agents, this.permissionManager);
|
|
595
|
-
if (this.sessionsDb)
|
|
596
|
-
delegationManager.setSessionsDb(this.sessionsDb);
|
|
597
|
-
const continuationEnforcer = new task_continuation_js_1.TaskContinuationEnforcer({
|
|
598
|
-
enabled: true,
|
|
599
|
-
max_retries: 3,
|
|
600
|
-
});
|
|
601
|
-
let consecutiveStalls = 0;
|
|
602
|
-
let currentPrompt = this.buildInitialPrompt(session.task, agents);
|
|
603
|
-
let currentAgentId = session.leadAgentId;
|
|
604
|
-
while (this.shouldContinue(session)) {
|
|
605
|
-
session.currentStep++;
|
|
606
|
-
const stepStart = Date.now();
|
|
607
|
-
try {
|
|
608
|
-
const result = await this.executeWithTimeout(executeCallback, currentAgentId, currentPrompt);
|
|
609
|
-
const stepDuration = Date.now() - stepStart;
|
|
610
|
-
// Stall detection
|
|
611
|
-
if (result.response.trim().length < STALL_MIN_LENGTH) {
|
|
612
|
-
consecutiveStalls++;
|
|
613
|
-
if (consecutiveStalls >= MAX_CONSECUTIVE_STALLS) {
|
|
614
|
-
consecutiveStalls = 0;
|
|
615
|
-
await notifyCallback(`Agent ${currentAgentId} appears stalled (${MAX_CONSECUTIVE_STALLS} short responses). Re-prompting...`);
|
|
616
|
-
currentPrompt = `Your previous responses were too brief. The task is NOT complete yet.\n\nOriginal task: ${session.task}\n\nPlease take concrete action now. When fully done, respond with "DONE".`;
|
|
617
|
-
currentAgentId = session.leadAgentId;
|
|
618
|
-
session.steps.push({
|
|
619
|
-
stepNumber: session.currentStep,
|
|
620
|
-
agentId: currentAgentId,
|
|
621
|
-
action: 'stall_detected',
|
|
622
|
-
responseSummary: `Stalled: "${result.response.trim().substring(0, 100)}"`,
|
|
623
|
-
isDelegation: false,
|
|
624
|
-
duration: stepDuration,
|
|
625
|
-
timestamp: Date.now(),
|
|
626
|
-
});
|
|
627
|
-
continue;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
else {
|
|
631
|
-
consecutiveStalls = 0;
|
|
632
|
-
}
|
|
633
|
-
// Council/workflow interceptor
|
|
634
|
-
if (responseInterceptor) {
|
|
635
|
-
const intercepted = await responseInterceptor(result.response, session.channelId);
|
|
636
|
-
if (intercepted) {
|
|
637
|
-
session.steps.push({
|
|
638
|
-
stepNumber: session.currentStep,
|
|
639
|
-
agentId: currentAgentId,
|
|
640
|
-
action: intercepted.type === 'council' ? 'council_execution' : 'workflow_execution',
|
|
641
|
-
responseSummary: intercepted.result.substring(0, 200),
|
|
642
|
-
isDelegation: false,
|
|
643
|
-
duration: Date.now() - stepStart,
|
|
644
|
-
timestamp: Date.now(),
|
|
645
|
-
});
|
|
646
|
-
await notifyCallback(intercepted.result);
|
|
647
|
-
currentPrompt = `The ${intercepted.type} plan completed. Results:\n---\n${intercepted.result.substring(0, 1000)}\n---\nContinue with the next step. When done, respond with "DONE".`;
|
|
648
|
-
currentAgentId = session.leadAgentId;
|
|
649
|
-
continue;
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
// Delegation check
|
|
653
|
-
const delegationRequest = delegationManager.parseDelegation(currentAgentId, result.response);
|
|
654
|
-
if (delegationRequest) {
|
|
655
|
-
session.steps.push({
|
|
656
|
-
stepNumber: session.currentStep,
|
|
657
|
-
agentId: currentAgentId,
|
|
658
|
-
action: 'delegation',
|
|
659
|
-
responseSummary: delegationRequest.originalContent.substring(0, 200),
|
|
660
|
-
isDelegation: true,
|
|
661
|
-
duration: stepDuration,
|
|
662
|
-
timestamp: Date.now(),
|
|
663
|
-
});
|
|
664
|
-
const delegationResult = await delegationManager.executeDelegation(delegationRequest, executeCallback, notifyCallback);
|
|
665
|
-
if (delegationResult.success && delegationResult.response) {
|
|
666
|
-
session.currentStep++;
|
|
667
|
-
session.steps.push({
|
|
668
|
-
stepNumber: session.currentStep,
|
|
669
|
-
agentId: delegationRequest.toAgentId,
|
|
670
|
-
action: 'delegated_task',
|
|
671
|
-
responseSummary: delegationResult.response.substring(0, 200),
|
|
672
|
-
isDelegation: false,
|
|
673
|
-
duration: delegationResult.duration ?? 0,
|
|
674
|
-
timestamp: Date.now(),
|
|
675
|
-
});
|
|
676
|
-
currentPrompt = this.buildContinuationAfterDelegation(delegationRequest.toAgentId, delegationResult.response);
|
|
677
|
-
currentAgentId = session.leadAgentId;
|
|
678
|
-
}
|
|
679
|
-
else {
|
|
680
|
-
currentPrompt = `Delegation to ${delegationRequest.toAgentId} failed: ${delegationResult.error}. Please continue the task yourself.`;
|
|
681
|
-
currentAgentId = session.leadAgentId;
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
else {
|
|
685
|
-
session.steps.push({
|
|
686
|
-
stepNumber: session.currentStep,
|
|
687
|
-
agentId: currentAgentId,
|
|
688
|
-
action: 'direct_work',
|
|
689
|
-
responseSummary: result.response.substring(0, 200),
|
|
690
|
-
isDelegation: false,
|
|
691
|
-
duration: stepDuration,
|
|
692
|
-
timestamp: Date.now(),
|
|
693
|
-
});
|
|
694
|
-
const continuation = continuationEnforcer.analyzeResponse(currentAgentId, session.channelId, result.response);
|
|
695
|
-
if (continuation.isComplete) {
|
|
696
|
-
session.active = false;
|
|
697
|
-
this.sessions.delete(session.channelId);
|
|
698
|
-
await notifyCallback(`**UltraWork Session Complete** (${session.id})\n` +
|
|
699
|
-
`Steps: ${session.currentStep} | Duration: ${Math.round((Date.now() - session.startTime) / 1000)}s`);
|
|
700
|
-
break;
|
|
701
|
-
}
|
|
702
|
-
if (continuation.maxRetriesReached) {
|
|
703
|
-
session.active = false;
|
|
704
|
-
this.sessions.delete(session.channelId);
|
|
705
|
-
await notifyCallback(`**UltraWork Session Stopped** (${session.id}): Max continuation retries reached.\n` +
|
|
706
|
-
`Steps: ${session.currentStep}`);
|
|
707
|
-
break;
|
|
708
|
-
}
|
|
709
|
-
currentPrompt = continuationEnforcer.buildContinuationPrompt(result.response);
|
|
710
|
-
currentAgentId = session.leadAgentId;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
catch (error) {
|
|
714
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
715
|
-
session.steps.push({
|
|
716
|
-
stepNumber: session.currentStep,
|
|
717
|
-
agentId: currentAgentId,
|
|
718
|
-
action: 'error',
|
|
719
|
-
responseSummary: errorMessage.substring(0, 200),
|
|
720
|
-
isDelegation: false,
|
|
721
|
-
duration: Date.now() - stepStart,
|
|
722
|
-
timestamp: Date.now(),
|
|
723
|
-
});
|
|
724
|
-
currentPrompt = `An error occurred: ${errorMessage}. Please assess the situation and decide how to continue.`;
|
|
725
|
-
currentAgentId = session.leadAgentId;
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
// Session limits reached
|
|
729
|
-
if (session.active) {
|
|
730
|
-
this.endSession(session, notifyCallback);
|
|
731
|
-
}
|
|
732
|
-
}
|
|
733
|
-
// ============================================================================
|
|
734
|
-
// Prompt builders
|
|
735
|
-
// ============================================================================
|
|
736
|
-
buildPlanningPrompt(task, agents) {
|
|
737
|
-
const agentList = agents
|
|
738
|
-
.filter((a) => a.enabled !== false)
|
|
739
|
-
.map((a) => `- **${a.display_name}** (ID: ${a.id}, Tier ${a.tier ?? 1})`)
|
|
740
|
-
.join('\n');
|
|
741
|
-
return `**UltraWork — Phase 1: Planning**
|
|
742
|
-
|
|
743
|
-
You are leading an autonomous work session. Before implementing, create a detailed plan.
|
|
744
|
-
|
|
745
|
-
**Task:** ${task}
|
|
746
|
-
|
|
747
|
-
**Available agents:**
|
|
748
|
-
${agentList}
|
|
749
|
-
|
|
750
|
-
**Instructions:**
|
|
751
|
-
1. Analyze the task requirements
|
|
752
|
-
2. If multiple perspectives would help, start a council discussion:
|
|
753
|
-
\`\`\`council_plan
|
|
754
|
-
{"name":"plan_review","topic":"Review implementation approach for: ${task.substring(0, 100)}","agents":["developer","reviewer"],"rounds":1}
|
|
755
|
-
\`\`\`
|
|
756
|
-
3. After gathering input, create a structured plan:
|
|
757
|
-
|
|
758
|
-
## Implementation Plan
|
|
759
|
-
### Task 1: [description]
|
|
760
|
-
- Assigned to: [agent_id]
|
|
761
|
-
- Acceptance criteria: [what defines "done"]
|
|
762
|
-
### Task 2: ...
|
|
763
|
-
|
|
764
|
-
4. End with "PLAN_COMPLETE" when the plan is ready.`;
|
|
765
|
-
}
|
|
766
|
-
buildBuildingPrompt(plan, agents) {
|
|
767
|
-
const agentList = agents
|
|
768
|
-
.filter((a) => a.enabled !== false)
|
|
769
|
-
.map((a) => `- ${a.display_name} (ID: ${a.id})`)
|
|
770
|
-
.join('\n');
|
|
771
|
-
return `**UltraWork — Phase 2: Building**
|
|
772
|
-
|
|
773
|
-
Execute the following plan. Delegate tasks to specialists.
|
|
774
|
-
|
|
775
|
-
**Plan:**
|
|
776
|
-
---
|
|
777
|
-
${plan.substring(0, 3000)}
|
|
778
|
-
---
|
|
779
|
-
|
|
780
|
-
**Available agents:**
|
|
781
|
-
${agentList}
|
|
782
|
-
|
|
783
|
-
**Instructions:**
|
|
784
|
-
- Execute tasks in order from the plan
|
|
785
|
-
- Delegate using: DELEGATE::{agent_id}::{task description with acceptance criteria}
|
|
786
|
-
- If a task fails or needs discussion, use council_plan for team input
|
|
787
|
-
- After ALL tasks are done, respond with "BUILD_COMPLETE"
|
|
788
|
-
- Do NOT skip any tasks from the plan`;
|
|
789
|
-
}
|
|
790
|
-
buildRetrospectivePrompt(plan, steps) {
|
|
791
|
-
const stepSummary = steps
|
|
792
|
-
.map((s) => `- Step ${s.stepNumber} [${s.action}] by ${s.agentId}: ${s.responseSummary.substring(0, 100)}`)
|
|
793
|
-
.join('\n');
|
|
794
|
-
return `**UltraWork — Phase 3: Retrospective**
|
|
795
|
-
|
|
796
|
-
Review the completed work against the original plan.
|
|
797
|
-
|
|
798
|
-
**Original Plan:**
|
|
799
|
-
---
|
|
800
|
-
${plan.substring(0, 2000)}
|
|
801
|
-
---
|
|
802
|
-
|
|
803
|
-
**Completed Steps:**
|
|
804
|
-
${stepSummary || '(no steps recorded)'}
|
|
805
|
-
|
|
806
|
-
**Instructions:**
|
|
807
|
-
1. Compare completed work against the plan
|
|
808
|
-
2. If team review would help, start a council discussion:
|
|
809
|
-
\`\`\`council_plan
|
|
810
|
-
{"name":"retrospective","topic":"Review completed work quality and identify gaps","agents":["developer","reviewer"],"rounds":1}
|
|
811
|
-
\`\`\`
|
|
812
|
-
3. After council input, provide final assessment:
|
|
813
|
-
- What was completed successfully
|
|
814
|
-
- What needs additional work (if any)
|
|
815
|
-
- Lessons learned
|
|
816
|
-
4. If ALL tasks are done satisfactorily: respond with "RETRO_COMPLETE"
|
|
817
|
-
5. If tasks remain: respond with "RETRO_INCOMPLETE" and list remaining items`;
|
|
818
|
-
}
|
|
819
|
-
buildInitialPrompt(task, agents) {
|
|
820
|
-
const agentList = agents
|
|
821
|
-
.filter((a) => a.enabled !== false)
|
|
822
|
-
.map((a) => `- ${a.display_name} (ID: ${a.id}, Tier ${a.tier ?? 1})`)
|
|
823
|
-
.join('\n');
|
|
824
|
-
return `**UltraWork Session**
|
|
825
|
-
|
|
826
|
-
You are leading an autonomous work session. Complete the following task:
|
|
827
|
-
|
|
828
|
-
**Task:** ${task}
|
|
829
|
-
|
|
830
|
-
**Available agents for delegation:**
|
|
831
|
-
${agentList}
|
|
832
|
-
|
|
833
|
-
**Instructions:**
|
|
834
|
-
- Break down the task into steps
|
|
835
|
-
- Delegate specialized work using: DELEGATE::{agent_id}::{task description}
|
|
836
|
-
- For independent tasks that don't block you: DELEGATE_BG::{agent_id}::{task description}
|
|
837
|
-
(Background delegation — you continue working, result is notified in chat when done)
|
|
838
|
-
- End your response with "DONE" when the overall task is complete
|
|
839
|
-
- Stay focused on the task and be efficient`;
|
|
840
|
-
}
|
|
841
|
-
buildContinuationAfterDelegation(delegatedAgentId, response) {
|
|
842
|
-
const summary = response.length > 500 ? response.substring(0, 500) + '...' : response;
|
|
843
|
-
return `Agent ${delegatedAgentId} completed the delegated task. Their response:
|
|
844
|
-
---
|
|
845
|
-
${summary}
|
|
846
|
-
---
|
|
847
|
-
Continue with the next step of the overall task. When everything is done, respond with "DONE".`;
|
|
848
|
-
}
|
|
849
|
-
// ============================================================================
|
|
850
|
-
// Completion markers
|
|
851
|
-
// ============================================================================
|
|
852
|
-
isBuildComplete(response) {
|
|
853
|
-
return /\bBUILD_COMPLETE\b/i.test(response);
|
|
854
|
-
}
|
|
855
|
-
isRetroComplete(response) {
|
|
856
|
-
return /\bRETRO_COMPLETE\b/i.test(response);
|
|
857
|
-
}
|
|
858
|
-
// ============================================================================
|
|
859
|
-
// Helpers
|
|
860
|
-
// ============================================================================
|
|
861
|
-
async endSession(session, notifyCallback) {
|
|
862
|
-
let reason;
|
|
863
|
-
if (!session.active) {
|
|
864
|
-
reason = 'cancelled';
|
|
865
|
-
}
|
|
866
|
-
else if (session.currentStep >= session.maxSteps) {
|
|
867
|
-
reason = 'max steps reached';
|
|
868
|
-
}
|
|
869
|
-
else {
|
|
870
|
-
reason = 'max duration reached';
|
|
871
|
-
}
|
|
872
|
-
session.active = false;
|
|
873
|
-
this.sessions.delete(session.channelId);
|
|
874
|
-
await notifyCallback(`**UltraWork Session Ended** (${session.id}): ${reason}.\n` +
|
|
875
|
-
`Steps: ${session.currentStep} | Duration: ${Math.round((Date.now() - session.startTime) / 1000)}s`);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
exports.UltraWorkManager = UltraWorkManager;
|
|
879
|
-
//# sourceMappingURL=ultrawork.js.map
|