@roj-ai/sdk 0.0.2
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/bootstrap.d.ts +453 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/builtin-events.d.ts +16 -0
- package/dist/builtin-events.d.ts.map +1 -0
- package/dist/bun-platform/fs.d.ts +9 -0
- package/dist/bun-platform/fs.d.ts.map +1 -0
- package/dist/bun-platform/index.d.ts +12 -0
- package/dist/bun-platform/index.d.ts.map +1 -0
- package/dist/bun-platform/process.d.ts +6 -0
- package/dist/bun-platform/process.d.ts.map +1 -0
- package/dist/config.d.ts +38 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.test.d.ts +2 -0
- package/dist/config.test.d.ts.map +1 -0
- package/dist/core/agent-loop.integration.test.d.ts +2 -0
- package/dist/core/agent-loop.integration.test.d.ts.map +1 -0
- package/dist/core/agents/agent-config.test.d.ts +2 -0
- package/dist/core/agents/agent-config.test.d.ts.map +1 -0
- package/dist/core/agents/agent-roles.d.ts +33 -0
- package/dist/core/agents/agent-roles.d.ts.map +1 -0
- package/dist/core/agents/agent-shutdown.test.d.ts +6 -0
- package/dist/core/agents/agent-shutdown.test.d.ts.map +1 -0
- package/dist/core/agents/agent.d.ts +234 -0
- package/dist/core/agents/agent.d.ts.map +1 -0
- package/dist/core/agents/agent.test.d.ts +2 -0
- package/dist/core/agents/agent.test.d.ts.map +1 -0
- package/dist/core/agents/communicator.d.ts +3 -0
- package/dist/core/agents/communicator.d.ts.map +1 -0
- package/dist/core/agents/config.d.ts +84 -0
- package/dist/core/agents/config.d.ts.map +1 -0
- package/dist/core/agents/context.d.ts +16 -0
- package/dist/core/agents/context.d.ts.map +1 -0
- package/dist/core/agents/debounce.d.ts +52 -0
- package/dist/core/agents/debounce.d.ts.map +1 -0
- package/dist/core/agents/handler-events.test.d.ts +5 -0
- package/dist/core/agents/handler-events.test.d.ts.map +1 -0
- package/dist/core/agents/index.d.ts +2 -0
- package/dist/core/agents/index.d.ts.map +1 -0
- package/dist/core/agents/response-sanitizer.d.ts +25 -0
- package/dist/core/agents/response-sanitizer.d.ts.map +1 -0
- package/dist/core/agents/response-sanitizer.test.d.ts +2 -0
- package/dist/core/agents/response-sanitizer.test.d.ts.map +1 -0
- package/dist/core/agents/retry.d.ts +40 -0
- package/dist/core/agents/retry.d.ts.map +1 -0
- package/dist/core/agents/schema.d.ts +57 -0
- package/dist/core/agents/schema.d.ts.map +1 -0
- package/dist/core/agents/state.d.ts +255 -0
- package/dist/core/agents/state.d.ts.map +1 -0
- package/dist/core/context/state.d.ts +28 -0
- package/dist/core/context/state.d.ts.map +1 -0
- package/dist/core/errors.d.ts +29 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/event-sourcing.integration.test.d.ts +2 -0
- package/dist/core/event-sourcing.integration.test.d.ts.map +1 -0
- package/dist/core/events/base-event-store.d.ts +55 -0
- package/dist/core/events/base-event-store.d.ts.map +1 -0
- package/dist/core/events/event-store.d.ts +108 -0
- package/dist/core/events/event-store.d.ts.map +1 -0
- package/dist/core/events/file.d.ts +50 -0
- package/dist/core/events/file.d.ts.map +1 -0
- package/dist/core/events/file.test.d.ts +2 -0
- package/dist/core/events/file.test.d.ts.map +1 -0
- package/dist/core/events/index.d.ts +4 -0
- package/dist/core/events/index.d.ts.map +1 -0
- package/dist/core/events/memory.d.ts +43 -0
- package/dist/core/events/memory.d.ts.map +1 -0
- package/dist/core/events/memory.test.d.ts +2 -0
- package/dist/core/events/memory.test.d.ts.map +1 -0
- package/dist/core/events/metadata-utils.d.ts +27 -0
- package/dist/core/events/metadata-utils.d.ts.map +1 -0
- package/dist/core/events/test-helpers.d.ts +28 -0
- package/dist/core/events/test-helpers.d.ts.map +1 -0
- package/dist/core/events/types.d.ts +46 -0
- package/dist/core/events/types.d.ts.map +1 -0
- package/dist/core/file-store/file-store.d.ts +56 -0
- package/dist/core/file-store/file-store.d.ts.map +1 -0
- package/dist/core/file-store/types.d.ts +50 -0
- package/dist/core/file-store/types.d.ts.map +1 -0
- package/dist/core/image/image-processor.d.ts +15 -0
- package/dist/core/image/image-processor.d.ts.map +1 -0
- package/dist/core/image/image-processor.test.d.ts +2 -0
- package/dist/core/image/image-processor.test.d.ts.map +1 -0
- package/dist/core/image/index.d.ts +5 -0
- package/dist/core/image/index.d.ts.map +1 -0
- package/dist/core/image/noop-resizer.d.ts +5 -0
- package/dist/core/image/noop-resizer.d.ts.map +1 -0
- package/dist/core/image/types.d.ts +20 -0
- package/dist/core/image/types.d.ts.map +1 -0
- package/dist/core/image/vips-resizer.d.ts +21 -0
- package/dist/core/image/vips-resizer.d.ts.map +1 -0
- package/dist/core/image/vips-resizer.test.d.ts +2 -0
- package/dist/core/image/vips-resizer.test.d.ts.map +1 -0
- package/dist/core/llm/anthropic.d.ts +51 -0
- package/dist/core/llm/anthropic.d.ts.map +1 -0
- package/dist/core/llm/anthropic.test.d.ts +2 -0
- package/dist/core/llm/anthropic.test.d.ts.map +1 -0
- package/dist/core/llm/cache-breakpoints.d.ts +17 -0
- package/dist/core/llm/cache-breakpoints.d.ts.map +1 -0
- package/dist/core/llm/cache-live.test.d.ts +16 -0
- package/dist/core/llm/cache-live.test.d.ts.map +1 -0
- package/dist/core/llm/index.d.ts +16 -0
- package/dist/core/llm/index.d.ts.map +1 -0
- package/dist/core/llm/llm-log-types.d.ts +148 -0
- package/dist/core/llm/llm-log-types.d.ts.map +1 -0
- package/dist/core/llm/logger.d.ts +74 -0
- package/dist/core/llm/logger.d.ts.map +1 -0
- package/dist/core/llm/logger.test.d.ts +7 -0
- package/dist/core/llm/logger.test.d.ts.map +1 -0
- package/dist/core/llm/logging-provider.d.ts +20 -0
- package/dist/core/llm/logging-provider.d.ts.map +1 -0
- package/dist/core/llm/middleware.d.ts +79 -0
- package/dist/core/llm/middleware.d.ts.map +1 -0
- package/dist/core/llm/mock.d.ts +79 -0
- package/dist/core/llm/mock.d.ts.map +1 -0
- package/dist/core/llm/mock.test.d.ts +2 -0
- package/dist/core/llm/mock.test.d.ts.map +1 -0
- package/dist/core/llm/openrouter-mapping.test.d.ts +2 -0
- package/dist/core/llm/openrouter-mapping.test.d.ts.map +1 -0
- package/dist/core/llm/openrouter.d.ts +37 -0
- package/dist/core/llm/openrouter.d.ts.map +1 -0
- package/dist/core/llm/openrouter.test.d.ts +2 -0
- package/dist/core/llm/openrouter.test.d.ts.map +1 -0
- package/dist/core/llm/provider-integration.test.d.ts +12 -0
- package/dist/core/llm/provider-integration.test.d.ts.map +1 -0
- package/dist/core/llm/provider.d.ts +175 -0
- package/dist/core/llm/provider.d.ts.map +1 -0
- package/dist/core/llm/routing-provider.d.ts +31 -0
- package/dist/core/llm/routing-provider.d.ts.map +1 -0
- package/dist/core/llm/routing-provider.test.d.ts +2 -0
- package/dist/core/llm/routing-provider.test.d.ts.map +1 -0
- package/dist/core/llm/schema.d.ts +24 -0
- package/dist/core/llm/schema.d.ts.map +1 -0
- package/dist/core/llm/snapshot-fetch.d.ts +21 -0
- package/dist/core/llm/snapshot-fetch.d.ts.map +1 -0
- package/dist/core/llm/snapshot-middleware.d.ts +71 -0
- package/dist/core/llm/snapshot-middleware.d.ts.map +1 -0
- package/dist/core/llm/snapshot-middleware.test.d.ts +2 -0
- package/dist/core/llm/snapshot-middleware.test.d.ts.map +1 -0
- package/dist/core/llm/state.d.ts +73 -0
- package/dist/core/llm/state.d.ts.map +1 -0
- package/dist/core/llm/tokens.d.ts +36 -0
- package/dist/core/llm/tokens.d.ts.map +1 -0
- package/dist/core/multi-agent.integration.test.d.ts +2 -0
- package/dist/core/multi-agent.integration.test.d.ts.map +1 -0
- package/dist/core/plugin-hooks.integration.test.d.ts +2 -0
- package/dist/core/plugin-hooks.integration.test.d.ts.map +1 -0
- package/dist/core/plugins/hook-types.d.ts +55 -0
- package/dist/core/plugins/hook-types.d.ts.map +1 -0
- package/dist/core/plugins/index.d.ts +23 -0
- package/dist/core/plugins/index.d.ts.map +1 -0
- package/dist/core/plugins/plugin-builder.d.ts +474 -0
- package/dist/core/plugins/plugin-builder.d.ts.map +1 -0
- package/dist/core/preset/config.d.ts +55 -0
- package/dist/core/preset/config.d.ts.map +1 -0
- package/dist/core/preset/index.d.ts +8 -0
- package/dist/core/preset/index.d.ts.map +1 -0
- package/dist/core/preset/preset-builder.d.ts +44 -0
- package/dist/core/preset/preset-builder.d.ts.map +1 -0
- package/dist/core/session-lifecycle.integration.test.d.ts +2 -0
- package/dist/core/session-lifecycle.integration.test.d.ts.map +1 -0
- package/dist/core/sessions/apply-event.d.ts +19 -0
- package/dist/core/sessions/apply-event.d.ts.map +1 -0
- package/dist/core/sessions/context.d.ts +34 -0
- package/dist/core/sessions/context.d.ts.map +1 -0
- package/dist/core/sessions/fork-utils.d.ts +20 -0
- package/dist/core/sessions/fork-utils.d.ts.map +1 -0
- package/dist/core/sessions/fork-utils.test.d.ts +2 -0
- package/dist/core/sessions/fork-utils.test.d.ts.map +1 -0
- package/dist/core/sessions/reducer.d.ts +50 -0
- package/dist/core/sessions/reducer.d.ts.map +1 -0
- package/dist/core/sessions/schema.d.ts +82 -0
- package/dist/core/sessions/schema.d.ts.map +1 -0
- package/dist/core/sessions/session-environment.d.ts +13 -0
- package/dist/core/sessions/session-environment.d.ts.map +1 -0
- package/dist/core/sessions/session-manager.d.ts +183 -0
- package/dist/core/sessions/session-manager.d.ts.map +1 -0
- package/dist/core/sessions/session-store.d.ts +69 -0
- package/dist/core/sessions/session-store.d.ts.map +1 -0
- package/dist/core/sessions/session.d.ts +212 -0
- package/dist/core/sessions/session.d.ts.map +1 -0
- package/dist/core/sessions/session.test.d.ts +2 -0
- package/dist/core/sessions/session.test.d.ts.map +1 -0
- package/dist/core/sessions/state.d.ts +110 -0
- package/dist/core/sessions/state.d.ts.map +1 -0
- package/dist/core/system.d.ts +97 -0
- package/dist/core/system.d.ts.map +1 -0
- package/dist/core/tools/context.d.ts +3 -0
- package/dist/core/tools/context.d.ts.map +1 -0
- package/dist/core/tools/definition.d.ts +10 -0
- package/dist/core/tools/definition.d.ts.map +1 -0
- package/dist/core/tools/executor.d.ts +28 -0
- package/dist/core/tools/executor.d.ts.map +1 -0
- package/dist/core/tools/executor.test.d.ts +2 -0
- package/dist/core/tools/executor.test.d.ts.map +1 -0
- package/dist/core/tools/index.d.ts +4 -0
- package/dist/core/tools/index.d.ts.map +1 -0
- package/dist/core/tools/schema.d.ts +61 -0
- package/dist/core/tools/schema.d.ts.map +1 -0
- package/dist/core/tools/state.d.ts +28 -0
- package/dist/core/tools/state.d.ts.map +1 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/lib/json/index.d.ts +17 -0
- package/dist/lib/json/index.d.ts.map +1 -0
- package/dist/lib/logger/console.d.ts +35 -0
- package/dist/lib/logger/console.d.ts.map +1 -0
- package/dist/lib/logger/console.test.d.ts +2 -0
- package/dist/lib/logger/console.test.d.ts.map +1 -0
- package/dist/lib/logger/file.d.ts +20 -0
- package/dist/lib/logger/file.d.ts.map +1 -0
- package/dist/lib/logger/index.d.ts +5 -0
- package/dist/lib/logger/index.d.ts.map +1 -0
- package/dist/lib/logger/logger.d.ts +87 -0
- package/dist/lib/logger/logger.d.ts.map +1 -0
- package/dist/lib/logger/ring-buffer.d.ts +33 -0
- package/dist/lib/logger/ring-buffer.d.ts.map +1 -0
- package/dist/lib/logger/tee.d.ts +15 -0
- package/dist/lib/logger/tee.d.ts.map +1 -0
- package/dist/lib/mime.d.ts +9 -0
- package/dist/lib/mime.d.ts.map +1 -0
- package/dist/lib/never.d.ts +2 -0
- package/dist/lib/never.d.ts.map +1 -0
- package/dist/lib/utils/hash.d.ts +19 -0
- package/dist/lib/utils/hash.d.ts.map +1 -0
- package/dist/lib/utils/result.d.ts +26 -0
- package/dist/lib/utils/result.d.ts.map +1 -0
- package/dist/platform/fs.d.ts +39 -0
- package/dist/platform/fs.d.ts.map +1 -0
- package/dist/platform/index.d.ts +21 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/process.d.ts +24 -0
- package/dist/platform/process.d.ts.map +1 -0
- package/dist/plugins/agent-status/plugin.d.ts +8 -0
- package/dist/plugins/agent-status/plugin.d.ts.map +1 -0
- package/dist/plugins/agents/agents.integration.test.d.ts +2 -0
- package/dist/plugins/agents/agents.integration.test.d.ts.map +1 -0
- package/dist/plugins/agents/index.d.ts +3 -0
- package/dist/plugins/agents/index.d.ts.map +1 -0
- package/dist/plugins/agents/plugin.d.ts +57 -0
- package/dist/plugins/agents/plugin.d.ts.map +1 -0
- package/dist/plugins/context-compact/context-compact.integration.test.d.ts +2 -0
- package/dist/plugins/context-compact/context-compact.integration.test.d.ts.map +1 -0
- package/dist/plugins/context-compact/context-compactor.d.ts +88 -0
- package/dist/plugins/context-compact/context-compactor.d.ts.map +1 -0
- package/dist/plugins/context-compact/context-compactor.test.d.ts +2 -0
- package/dist/plugins/context-compact/context-compactor.test.d.ts.map +1 -0
- package/dist/plugins/context-compact/history-offloader.d.ts +17 -0
- package/dist/plugins/context-compact/history-offloader.d.ts.map +1 -0
- package/dist/plugins/context-compact/history-offloader.test.d.ts +2 -0
- package/dist/plugins/context-compact/history-offloader.test.d.ts.map +1 -0
- package/dist/plugins/context-compact/index.d.ts +4 -0
- package/dist/plugins/context-compact/index.d.ts.map +1 -0
- package/dist/plugins/context-compact/plugin.d.ts +15 -0
- package/dist/plugins/context-compact/plugin.d.ts.map +1 -0
- package/dist/plugins/filesystem/filesystem.integration.test.d.ts +2 -0
- package/dist/plugins/filesystem/filesystem.integration.test.d.ts.map +1 -0
- package/dist/plugins/filesystem/helpers.d.ts +34 -0
- package/dist/plugins/filesystem/helpers.d.ts.map +1 -0
- package/dist/plugins/filesystem/index.d.ts +5 -0
- package/dist/plugins/filesystem/index.d.ts.map +1 -0
- package/dist/plugins/filesystem/listing.d.ts +38 -0
- package/dist/plugins/filesystem/listing.d.ts.map +1 -0
- package/dist/plugins/filesystem/plugin.d.ts +53 -0
- package/dist/plugins/filesystem/plugin.d.ts.map +1 -0
- package/dist/plugins/filesystem/schema.d.ts +7 -0
- package/dist/plugins/filesystem/schema.d.ts.map +1 -0
- package/dist/plugins/git-status/index.d.ts +2 -0
- package/dist/plugins/git-status/index.d.ts.map +1 -0
- package/dist/plugins/git-status/plugin.d.ts +12 -0
- package/dist/plugins/git-status/plugin.d.ts.map +1 -0
- package/dist/plugins/limits-guard/config.d.ts +23 -0
- package/dist/plugins/limits-guard/config.d.ts.map +1 -0
- package/dist/plugins/limits-guard/index.d.ts +5 -0
- package/dist/plugins/limits-guard/index.d.ts.map +1 -0
- package/dist/plugins/limits-guard/limit-guard.d.ts +40 -0
- package/dist/plugins/limits-guard/limit-guard.d.ts.map +1 -0
- package/dist/plugins/limits-guard/limit-guard.test.d.ts +2 -0
- package/dist/plugins/limits-guard/limit-guard.test.d.ts.map +1 -0
- package/dist/plugins/limits-guard/limits-guard.integration.test.d.ts +2 -0
- package/dist/plugins/limits-guard/limits-guard.integration.test.d.ts.map +1 -0
- package/dist/plugins/limits-guard/plugin.d.ts +39 -0
- package/dist/plugins/limits-guard/plugin.d.ts.map +1 -0
- package/dist/plugins/llm-debug/index.d.ts +2 -0
- package/dist/plugins/llm-debug/index.d.ts.map +1 -0
- package/dist/plugins/llm-debug/llm-debug.integration.test.d.ts +2 -0
- package/dist/plugins/llm-debug/llm-debug.integration.test.d.ts.map +1 -0
- package/dist/plugins/llm-debug/plugin.d.ts +31 -0
- package/dist/plugins/llm-debug/plugin.d.ts.map +1 -0
- package/dist/plugins/logs/index.d.ts +2 -0
- package/dist/plugins/logs/index.d.ts.map +1 -0
- package/dist/plugins/logs/plugin.d.ts +10 -0
- package/dist/plugins/logs/plugin.d.ts.map +1 -0
- package/dist/plugins/mailbox/helpers.d.ts +20 -0
- package/dist/plugins/mailbox/helpers.d.ts.map +1 -0
- package/dist/plugins/mailbox/index.d.ts +9 -0
- package/dist/plugins/mailbox/index.d.ts.map +1 -0
- package/dist/plugins/mailbox/mailbox.integration.test.d.ts +2 -0
- package/dist/plugins/mailbox/mailbox.integration.test.d.ts.map +1 -0
- package/dist/plugins/mailbox/plugin.d.ts +31 -0
- package/dist/plugins/mailbox/plugin.d.ts.map +1 -0
- package/dist/plugins/mailbox/prompts.d.ts +21 -0
- package/dist/plugins/mailbox/prompts.d.ts.map +1 -0
- package/dist/plugins/mailbox/query.d.ts +33 -0
- package/dist/plugins/mailbox/query.d.ts.map +1 -0
- package/dist/plugins/mailbox/schema.d.ts +54 -0
- package/dist/plugins/mailbox/schema.d.ts.map +1 -0
- package/dist/plugins/mailbox/state.d.ts +40 -0
- package/dist/plugins/mailbox/state.d.ts.map +1 -0
- package/dist/plugins/resources/index.d.ts +7 -0
- package/dist/plugins/resources/index.d.ts.map +1 -0
- package/dist/plugins/resources/manifest.d.ts +23 -0
- package/dist/plugins/resources/manifest.d.ts.map +1 -0
- package/dist/plugins/resources/plugin.d.ts +28 -0
- package/dist/plugins/resources/plugin.d.ts.map +1 -0
- package/dist/plugins/resources/post-inject.d.ts +39 -0
- package/dist/plugins/resources/post-inject.d.ts.map +1 -0
- package/dist/plugins/resources/state.d.ts +25 -0
- package/dist/plugins/resources/state.d.ts.map +1 -0
- package/dist/plugins/result-eviction/index.d.ts +3 -0
- package/dist/plugins/result-eviction/index.d.ts.map +1 -0
- package/dist/plugins/result-eviction/plugin.d.ts +19 -0
- package/dist/plugins/result-eviction/plugin.d.ts.map +1 -0
- package/dist/plugins/result-eviction/result-eviction.integration.test.d.ts +2 -0
- package/dist/plugins/result-eviction/result-eviction.integration.test.d.ts.map +1 -0
- package/dist/plugins/services/plugin.d.ts +85 -0
- package/dist/plugins/services/plugin.d.ts.map +1 -0
- package/dist/plugins/services/port-pool.d.ts +32 -0
- package/dist/plugins/services/port-pool.d.ts.map +1 -0
- package/dist/plugins/services/prompt.d.ts +13 -0
- package/dist/plugins/services/prompt.d.ts.map +1 -0
- package/dist/plugins/services/schema.d.ts +70 -0
- package/dist/plugins/services/schema.d.ts.map +1 -0
- package/dist/plugins/services/service.d.ts +86 -0
- package/dist/plugins/services/service.d.ts.map +1 -0
- package/dist/plugins/services/services.integration.test.d.ts +2 -0
- package/dist/plugins/services/services.integration.test.d.ts.map +1 -0
- package/dist/plugins/session-lifecycle/index.d.ts +2 -0
- package/dist/plugins/session-lifecycle/index.d.ts.map +1 -0
- package/dist/plugins/session-lifecycle/plugin.d.ts +97 -0
- package/dist/plugins/session-lifecycle/plugin.d.ts.map +1 -0
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.d.ts +2 -0
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.d.ts.map +1 -0
- package/dist/plugins/session-state/plugin.d.ts +48 -0
- package/dist/plugins/session-state/plugin.d.ts.map +1 -0
- package/dist/plugins/session-stats/index.d.ts +4 -0
- package/dist/plugins/session-stats/index.d.ts.map +1 -0
- package/dist/plugins/session-stats/plugin.d.ts +29 -0
- package/dist/plugins/session-stats/plugin.d.ts.map +1 -0
- package/dist/plugins/shell/executor.d.ts +78 -0
- package/dist/plugins/shell/executor.d.ts.map +1 -0
- package/dist/plugins/shell/index.d.ts +6 -0
- package/dist/plugins/shell/index.d.ts.map +1 -0
- package/dist/plugins/shell/plugin.d.ts +51 -0
- package/dist/plugins/shell/plugin.d.ts.map +1 -0
- package/dist/plugins/shell/shell.integration.test.d.ts +2 -0
- package/dist/plugins/shell/shell.integration.test.d.ts.map +1 -0
- package/dist/plugins/shell/shell.test.d.ts +2 -0
- package/dist/plugins/shell/shell.test.d.ts.map +1 -0
- package/dist/plugins/skills/discovery.d.ts +69 -0
- package/dist/plugins/skills/discovery.d.ts.map +1 -0
- package/dist/plugins/skills/discovery.test.d.ts +2 -0
- package/dist/plugins/skills/discovery.test.d.ts.map +1 -0
- package/dist/plugins/skills/index.d.ts +11 -0
- package/dist/plugins/skills/index.d.ts.map +1 -0
- package/dist/plugins/skills/plugin.d.ts +94 -0
- package/dist/plugins/skills/plugin.d.ts.map +1 -0
- package/dist/plugins/skills/prompts.d.ts +29 -0
- package/dist/plugins/skills/prompts.d.ts.map +1 -0
- package/dist/plugins/skills/schema.d.ts +64 -0
- package/dist/plugins/skills/schema.d.ts.map +1 -0
- package/dist/plugins/skills/skills.integration.test.d.ts +2 -0
- package/dist/plugins/skills/skills.integration.test.d.ts.map +1 -0
- package/dist/plugins/snapshotting/index.d.ts +4 -0
- package/dist/plugins/snapshotting/index.d.ts.map +1 -0
- package/dist/plugins/snapshotting/jj-snapshotter.d.ts +27 -0
- package/dist/plugins/snapshotting/jj-snapshotter.d.ts.map +1 -0
- package/dist/plugins/snapshotting/plugin.d.ts +15 -0
- package/dist/plugins/snapshotting/plugin.d.ts.map +1 -0
- package/dist/plugins/snapshotting/snapshotter.d.ts +19 -0
- package/dist/plugins/snapshotting/snapshotter.d.ts.map +1 -0
- package/dist/plugins/todo/index.d.ts +7 -0
- package/dist/plugins/todo/index.d.ts.map +1 -0
- package/dist/plugins/todo/plugin.d.ts +95 -0
- package/dist/plugins/todo/plugin.d.ts.map +1 -0
- package/dist/plugins/todo/prompts.d.ts +13 -0
- package/dist/plugins/todo/prompts.d.ts.map +1 -0
- package/dist/plugins/todo/schema.d.ts +44 -0
- package/dist/plugins/todo/schema.d.ts.map +1 -0
- package/dist/plugins/todo/todo.integration.test.d.ts +2 -0
- package/dist/plugins/todo/todo.integration.test.d.ts.map +1 -0
- package/dist/plugins/uploads/index.d.ts +9 -0
- package/dist/plugins/uploads/index.d.ts.map +1 -0
- package/dist/plugins/uploads/plugin.d.ts +56 -0
- package/dist/plugins/uploads/plugin.d.ts.map +1 -0
- package/dist/plugins/uploads/preprocessor.d.ts +70 -0
- package/dist/plugins/uploads/preprocessor.d.ts.map +1 -0
- package/dist/plugins/uploads/preprocessors/image-classifier.d.ts +49 -0
- package/dist/plugins/uploads/preprocessors/image-classifier.d.ts.map +1 -0
- package/dist/plugins/uploads/preprocessors/index.d.ts +7 -0
- package/dist/plugins/uploads/preprocessors/index.d.ts.map +1 -0
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.d.ts +43 -0
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.d.ts.map +1 -0
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.d.ts +30 -0
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.d.ts.map +1 -0
- package/dist/plugins/uploads/schema.d.ts +72 -0
- package/dist/plugins/uploads/schema.d.ts.map +1 -0
- package/dist/plugins/uploads/state.d.ts +38 -0
- package/dist/plugins/uploads/state.d.ts.map +1 -0
- package/dist/plugins/uploads/uploads.integration.test.d.ts +2 -0
- package/dist/plugins/uploads/uploads.integration.test.d.ts.map +1 -0
- package/dist/plugins/user-chat/index.d.ts +7 -0
- package/dist/plugins/user-chat/index.d.ts.map +1 -0
- package/dist/plugins/user-chat/plugin.d.ts +221 -0
- package/dist/plugins/user-chat/plugin.d.ts.map +1 -0
- package/dist/plugins/user-chat/prompts.d.ts +13 -0
- package/dist/plugins/user-chat/prompts.d.ts.map +1 -0
- package/dist/plugins/user-chat/schema.d.ts +82 -0
- package/dist/plugins/user-chat/schema.d.ts.map +1 -0
- package/dist/plugins/user-chat/user-chat.integration.test.d.ts +2 -0
- package/dist/plugins/user-chat/user-chat.integration.test.d.ts.map +1 -0
- package/dist/plugins/workers/context.d.ts +159 -0
- package/dist/plugins/workers/context.d.ts.map +1 -0
- package/dist/plugins/workers/definition.d.ts +118 -0
- package/dist/plugins/workers/definition.d.ts.map +1 -0
- package/dist/plugins/workers/index.d.ts +11 -0
- package/dist/plugins/workers/index.d.ts.map +1 -0
- package/dist/plugins/workers/plugin.d.ts +125 -0
- package/dist/plugins/workers/plugin.d.ts.map +1 -0
- package/dist/plugins/workers/worker.d.ts +76 -0
- package/dist/plugins/workers/worker.d.ts.map +1 -0
- package/dist/plugins/workers/workers.integration.test.d.ts +2 -0
- package/dist/plugins/workers/workers.integration.test.d.ts.map +1 -0
- package/dist/prompts/base.d.ts +75 -0
- package/dist/prompts/base.d.ts.map +1 -0
- package/dist/prompts/builder.d.ts +73 -0
- package/dist/prompts/builder.d.ts.map +1 -0
- package/dist/prompts/index.d.ts +10 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/macros.d.ts +15 -0
- package/dist/prompts/macros.d.ts.map +1 -0
- package/dist/prompts/macros.test.d.ts +2 -0
- package/dist/prompts/macros.test.d.ts.map +1 -0
- package/dist/testing/bootstrap-for-testing.d.ts +12 -0
- package/dist/testing/bootstrap-for-testing.d.ts.map +1 -0
- package/dist/testing/index.d.ts +8 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/node-platform.d.ts +12 -0
- package/dist/testing/node-platform.d.ts.map +1 -0
- package/dist/testing/notification-collector.d.ts +46 -0
- package/dist/testing/notification-collector.d.ts.map +1 -0
- package/dist/testing/preset-helpers.d.ts +28 -0
- package/dist/testing/preset-helpers.d.ts.map +1 -0
- package/dist/testing/test-harness.d.ts +117 -0
- package/dist/testing/test-harness.d.ts.map +1 -0
- package/dist/testing/test-harness.test.d.ts +2 -0
- package/dist/testing/test-harness.test.d.ts.map +1 -0
- package/dist/testing/wait-helpers.d.ts +17 -0
- package/dist/testing/wait-helpers.d.ts.map +1 -0
- package/dist/transport/adapter/client-adapter.d.ts +32 -0
- package/dist/transport/adapter/client-adapter.d.ts.map +1 -0
- package/dist/transport/adapter/index.d.ts +23 -0
- package/dist/transport/adapter/index.d.ts.map +1 -0
- package/dist/transport/adapter/server-adapter.d.ts +29 -0
- package/dist/transport/adapter/server-adapter.d.ts.map +1 -0
- package/dist/transport/adapter/types.d.ts +14 -0
- package/dist/transport/adapter/types.d.ts.map +1 -0
- package/dist/transport/http/app.d.ts +41 -0
- package/dist/transport/http/app.d.ts.map +1 -0
- package/dist/transport/http/index.d.ts +7 -0
- package/dist/transport/http/index.d.ts.map +1 -0
- package/dist/transport/http/middleware/bearer-auth.d.ts +16 -0
- package/dist/transport/http/middleware/bearer-auth.d.ts.map +1 -0
- package/dist/transport/http/middleware/error-handler.d.ts +21 -0
- package/dist/transport/http/middleware/error-handler.d.ts.map +1 -0
- package/dist/transport/http/routes/files.d.ts +16 -0
- package/dist/transport/http/routes/files.d.ts.map +1 -0
- package/dist/transport/http/routes/resources.d.ts +12 -0
- package/dist/transport/http/routes/resources.d.ts.map +1 -0
- package/dist/transport/http/routes/rpc.d.ts +22 -0
- package/dist/transport/http/routes/rpc.d.ts.map +1 -0
- package/dist/transport/http/routes/rpc.integration.test.d.ts +2 -0
- package/dist/transport/http/routes/rpc.integration.test.d.ts.map +1 -0
- package/dist/transport/http/routes/rpc.test.d.ts +2 -0
- package/dist/transport/http/routes/rpc.test.d.ts.map +1 -0
- package/dist/transport/http/routes/upload.d.ts +14 -0
- package/dist/transport/http/routes/upload.d.ts.map +1 -0
- package/dist/transport/rpc/index.d.ts +8 -0
- package/dist/transport/rpc/index.d.ts.map +1 -0
- package/dist/transport/rpc/methods.d.ts +25 -0
- package/dist/transport/rpc/methods.d.ts.map +1 -0
- package/dist/user-config.d.ts +29 -0
- package/dist/user-config.d.ts.map +1 -0
- package/package.json +154 -0
- package/src/bootstrap.ts +268 -0
- package/src/builtin-events.ts +25 -0
- package/src/bun-platform/fs.ts +50 -0
- package/src/bun-platform/index.ts +21 -0
- package/src/bun-platform/process.ts +25 -0
- package/src/config.test.ts +174 -0
- package/src/config.ts +103 -0
- package/src/core/agent-loop.integration.test.ts +503 -0
- package/src/core/agents/agent-config.test.ts +240 -0
- package/src/core/agents/agent-roles.ts +41 -0
- package/src/core/agents/agent-shutdown.test.ts +236 -0
- package/src/core/agents/agent.test.ts +387 -0
- package/src/core/agents/agent.ts +1472 -0
- package/src/core/agents/communicator.ts +16 -0
- package/src/core/agents/config.ts +98 -0
- package/src/core/agents/context.ts +19 -0
- package/src/core/agents/debounce.ts +116 -0
- package/src/core/agents/handler-events.test.ts +167 -0
- package/src/core/agents/index.ts +1 -0
- package/src/core/agents/response-sanitizer.test.ts +137 -0
- package/src/core/agents/response-sanitizer.ts +67 -0
- package/src/core/agents/retry.ts +164 -0
- package/src/core/agents/schema.ts +75 -0
- package/src/core/agents/state.ts +272 -0
- package/src/core/context/state.ts +38 -0
- package/src/core/errors.ts +55 -0
- package/src/core/event-sourcing.integration.test.ts +191 -0
- package/src/core/events/base-event-store.ts +264 -0
- package/src/core/events/event-store.ts +143 -0
- package/src/core/events/file.test.ts +436 -0
- package/src/core/events/file.ts +372 -0
- package/src/core/events/index.ts +3 -0
- package/src/core/events/memory.test.ts +741 -0
- package/src/core/events/memory.ts +131 -0
- package/src/core/events/metadata-utils.ts +133 -0
- package/src/core/events/test-helpers.ts +31 -0
- package/src/core/events/types.ts +64 -0
- package/src/core/file-store/file-store.ts +275 -0
- package/src/core/file-store/types.ts +52 -0
- package/src/core/image/image-processor.test.ts +218 -0
- package/src/core/image/image-processor.ts +127 -0
- package/src/core/image/index.ts +4 -0
- package/src/core/image/noop-resizer.ts +7 -0
- package/src/core/image/types.ts +24 -0
- package/src/core/image/vips-resizer.test.ts +377 -0
- package/src/core/image/vips-resizer.ts +124 -0
- package/src/core/llm/__snapshots__/anthropic-assistant-text-with-tool-calls.json +156 -0
- package/src/core/llm/__snapshots__/anthropic-consecutive-tool-results.json +152 -0
- package/src/core/llm/__snapshots__/anthropic-image-data-url.json +105 -0
- package/src/core/llm/__snapshots__/anthropic-image-http-url.json +104 -0
- package/src/core/llm/__snapshots__/anthropic-multiple-images.json +113 -0
- package/src/core/llm/__snapshots__/anthropic-multiple-tool-calls-requested.json +151 -0
- package/src/core/llm/__snapshots__/anthropic-simple-user-message.json +97 -0
- package/src/core/llm/__snapshots__/anthropic-system-message-in-conversation.json +119 -0
- package/src/core/llm/__snapshots__/anthropic-tool-call.json +123 -0
- package/src/core/llm/__snapshots__/anthropic-tool-error-result.json +139 -0
- package/src/core/llm/__snapshots__/anthropic-tool-result-with-image.json +152 -0
- package/src/core/llm/__snapshots__/anthropic-tool-roundtrip.json +139 -0
- package/src/core/llm/__snapshots__/openrouter-assistant-text-with-tool-calls.json +150 -0
- package/src/core/llm/__snapshots__/openrouter-consecutive-tool-results.json +150 -0
- package/src/core/llm/__snapshots__/openrouter-image-data-url.json +107 -0
- package/src/core/llm/__snapshots__/openrouter-image-http-url.json +107 -0
- package/src/core/llm/__snapshots__/openrouter-multiple-images.json +113 -0
- package/src/core/llm/__snapshots__/openrouter-multiple-tool-calls-requested.json +158 -0
- package/src/core/llm/__snapshots__/openrouter-simple-user-message.json +96 -0
- package/src/core/llm/__snapshots__/openrouter-system-message-in-conversation.json +108 -0
- package/src/core/llm/__snapshots__/openrouter-tool-call.json +129 -0
- package/src/core/llm/__snapshots__/openrouter-tool-error-result.json +137 -0
- package/src/core/llm/__snapshots__/openrouter-tool-result-with-image.json +148 -0
- package/src/core/llm/__snapshots__/openrouter-tool-roundtrip.json +137 -0
- package/src/core/llm/anthropic.test.ts +509 -0
- package/src/core/llm/anthropic.ts +578 -0
- package/src/core/llm/cache-breakpoints.ts +38 -0
- package/src/core/llm/cache-live.test.ts +155 -0
- package/src/core/llm/index.ts +30 -0
- package/src/core/llm/llm-log-types.ts +167 -0
- package/src/core/llm/logger.test.ts +270 -0
- package/src/core/llm/logger.ts +306 -0
- package/src/core/llm/logging-provider.ts +73 -0
- package/src/core/llm/middleware.ts +172 -0
- package/src/core/llm/mock.test.ts +402 -0
- package/src/core/llm/mock.ts +234 -0
- package/src/core/llm/openrouter-mapping.test.ts +153 -0
- package/src/core/llm/openrouter.test.ts +499 -0
- package/src/core/llm/openrouter.ts +458 -0
- package/src/core/llm/provider-integration.test.ts +408 -0
- package/src/core/llm/provider.ts +238 -0
- package/src/core/llm/routing-provider.test.ts +113 -0
- package/src/core/llm/routing-provider.ts +86 -0
- package/src/core/llm/schema.ts +47 -0
- package/src/core/llm/snapshot-fetch.ts +158 -0
- package/src/core/llm/snapshot-middleware.test.ts +168 -0
- package/src/core/llm/snapshot-middleware.ts +185 -0
- package/src/core/llm/state.ts +92 -0
- package/src/core/llm/tokens.ts +61 -0
- package/src/core/multi-agent.integration.test.ts +340 -0
- package/src/core/plugin-hooks.integration.test.ts +428 -0
- package/src/core/plugins/hook-types.ts +49 -0
- package/src/core/plugins/index.ts +52 -0
- package/src/core/plugins/plugin-builder.ts +967 -0
- package/src/core/preset/config.ts +110 -0
- package/src/core/preset/index.ts +11 -0
- package/src/core/preset/preset-builder.ts +111 -0
- package/src/core/session-lifecycle.integration.test.ts +202 -0
- package/src/core/sessions/apply-event.ts +46 -0
- package/src/core/sessions/context.ts +36 -0
- package/src/core/sessions/fork-utils.test.ts +158 -0
- package/src/core/sessions/fork-utils.ts +71 -0
- package/src/core/sessions/reducer.ts +95 -0
- package/src/core/sessions/schema.ts +91 -0
- package/src/core/sessions/session-environment.ts +12 -0
- package/src/core/sessions/session-manager.ts +883 -0
- package/src/core/sessions/session-store.ts +141 -0
- package/src/core/sessions/session.test.ts +1730 -0
- package/src/core/sessions/session.ts +833 -0
- package/src/core/sessions/state.ts +520 -0
- package/src/core/system.ts +206 -0
- package/src/core/tools/context.ts +3 -0
- package/src/core/tools/definition.ts +15 -0
- package/src/core/tools/executor.test.ts +160 -0
- package/src/core/tools/executor.ts +117 -0
- package/src/core/tools/index.ts +3 -0
- package/src/core/tools/schema.ts +80 -0
- package/src/core/tools/state.ts +34 -0
- package/src/index.ts +165 -0
- package/src/lib/json/index.ts +20 -0
- package/src/lib/logger/console.test.ts +348 -0
- package/src/lib/logger/console.ts +185 -0
- package/src/lib/logger/file.ts +65 -0
- package/src/lib/logger/index.ts +4 -0
- package/src/lib/logger/logger.ts +114 -0
- package/src/lib/logger/ring-buffer.ts +65 -0
- package/src/lib/logger/tee.ts +51 -0
- package/src/lib/mime.ts +23 -0
- package/src/lib/never.ts +3 -0
- package/src/lib/utils/hash.ts +38 -0
- package/src/lib/utils/result.ts +35 -0
- package/src/platform/fs.ts +38 -0
- package/src/platform/index.ts +23 -0
- package/src/platform/process.ts +28 -0
- package/src/plugins/agent-status/plugin.ts +77 -0
- package/src/plugins/agents/agents.integration.test.ts +808 -0
- package/src/plugins/agents/index.ts +2 -0
- package/src/plugins/agents/plugin.ts +242 -0
- package/src/plugins/context-compact/context-compact.integration.test.ts +207 -0
- package/src/plugins/context-compact/context-compactor.test.ts +923 -0
- package/src/plugins/context-compact/context-compactor.ts +343 -0
- package/src/plugins/context-compact/history-offloader.test.ts +100 -0
- package/src/plugins/context-compact/history-offloader.ts +47 -0
- package/src/plugins/context-compact/index.ts +3 -0
- package/src/plugins/context-compact/plugin.ts +62 -0
- package/src/plugins/filesystem/filesystem.integration.test.ts +485 -0
- package/src/plugins/filesystem/helpers.ts +216 -0
- package/src/plugins/filesystem/index.ts +4 -0
- package/src/plugins/filesystem/listing.ts +276 -0
- package/src/plugins/filesystem/plugin.ts +468 -0
- package/src/plugins/filesystem/schema.ts +6 -0
- package/src/plugins/git-status/index.ts +1 -0
- package/src/plugins/git-status/plugin.ts +166 -0
- package/src/plugins/limits-guard/config.ts +26 -0
- package/src/plugins/limits-guard/index.ts +4 -0
- package/src/plugins/limits-guard/limit-guard.test.ts +161 -0
- package/src/plugins/limits-guard/limit-guard.ts +164 -0
- package/src/plugins/limits-guard/limits-guard.integration.test.ts +437 -0
- package/src/plugins/limits-guard/plugin.ts +306 -0
- package/src/plugins/llm-debug/index.ts +1 -0
- package/src/plugins/llm-debug/llm-debug.integration.test.ts +192 -0
- package/src/plugins/llm-debug/plugin.ts +172 -0
- package/src/plugins/logs/index.ts +1 -0
- package/src/plugins/logs/plugin.ts +39 -0
- package/src/plugins/mailbox/helpers.ts +83 -0
- package/src/plugins/mailbox/index.ts +13 -0
- package/src/plugins/mailbox/mailbox.integration.test.ts +705 -0
- package/src/plugins/mailbox/plugin.ts +270 -0
- package/src/plugins/mailbox/prompts.ts +104 -0
- package/src/plugins/mailbox/query.ts +53 -0
- package/src/plugins/mailbox/schema.ts +81 -0
- package/src/plugins/mailbox/state.ts +52 -0
- package/src/plugins/resources/index.ts +11 -0
- package/src/plugins/resources/manifest.ts +25 -0
- package/src/plugins/resources/plugin.ts +201 -0
- package/src/plugins/resources/post-inject.ts +74 -0
- package/src/plugins/resources/state.ts +30 -0
- package/src/plugins/result-eviction/index.ts +2 -0
- package/src/plugins/result-eviction/plugin.ts +65 -0
- package/src/plugins/result-eviction/result-eviction.integration.test.ts +244 -0
- package/src/plugins/services/plugin.ts +485 -0
- package/src/plugins/services/port-pool.ts +73 -0
- package/src/plugins/services/prompt.ts +53 -0
- package/src/plugins/services/schema.ts +83 -0
- package/src/plugins/services/service.ts +578 -0
- package/src/plugins/services/services.integration.test.ts +595 -0
- package/src/plugins/session-lifecycle/index.ts +1 -0
- package/src/plugins/session-lifecycle/plugin.ts +302 -0
- package/src/plugins/session-lifecycle/session-lifecycle.integration.test.ts +639 -0
- package/src/plugins/session-state/plugin.ts +179 -0
- package/src/plugins/session-stats/index.ts +3 -0
- package/src/plugins/session-stats/plugin.ts +120 -0
- package/src/plugins/shell/executor.ts +462 -0
- package/src/plugins/shell/index.ts +23 -0
- package/src/plugins/shell/plugin.ts +118 -0
- package/src/plugins/shell/shell.integration.test.ts +273 -0
- package/src/plugins/shell/shell.test.ts +314 -0
- package/src/plugins/skills/discovery.test.ts +395 -0
- package/src/plugins/skills/discovery.ts +276 -0
- package/src/plugins/skills/index.ts +32 -0
- package/src/plugins/skills/plugin.ts +381 -0
- package/src/plugins/skills/prompts.ts +84 -0
- package/src/plugins/skills/schema.ts +88 -0
- package/src/plugins/skills/skills.integration.test.ts +580 -0
- package/src/plugins/snapshotting/index.ts +3 -0
- package/src/plugins/snapshotting/jj-snapshotter.ts +122 -0
- package/src/plugins/snapshotting/plugin.ts +36 -0
- package/src/plugins/snapshotting/snapshotter.ts +20 -0
- package/src/plugins/todo/index.ts +11 -0
- package/src/plugins/todo/plugin.ts +363 -0
- package/src/plugins/todo/prompts.ts +63 -0
- package/src/plugins/todo/schema.ts +71 -0
- package/src/plugins/todo/todo.integration.test.ts +687 -0
- package/src/plugins/uploads/index.ts +13 -0
- package/src/plugins/uploads/plugin.ts +406 -0
- package/src/plugins/uploads/preprocessor.ts +111 -0
- package/src/plugins/uploads/preprocessors/image-classifier.ts +176 -0
- package/src/plugins/uploads/preprocessors/index.ts +7 -0
- package/src/plugins/uploads/preprocessors/markitdown-preprocessor.ts +262 -0
- package/src/plugins/uploads/preprocessors/zip-preprocessor.ts +210 -0
- package/src/plugins/uploads/schema.ts +92 -0
- package/src/plugins/uploads/state.ts +42 -0
- package/src/plugins/uploads/uploads.integration.test.ts +654 -0
- package/src/plugins/user-chat/index.ts +17 -0
- package/src/plugins/user-chat/plugin.ts +728 -0
- package/src/plugins/user-chat/prompts.ts +30 -0
- package/src/plugins/user-chat/schema.ts +80 -0
- package/src/plugins/user-chat/user-chat.integration.test.ts +794 -0
- package/src/plugins/workers/context.ts +251 -0
- package/src/plugins/workers/definition.ts +169 -0
- package/src/plugins/workers/index.ts +21 -0
- package/src/plugins/workers/plugin.ts +722 -0
- package/src/plugins/workers/worker.ts +115 -0
- package/src/plugins/workers/workers.integration.test.ts +778 -0
- package/src/prompts/base.ts +266 -0
- package/src/prompts/builder.ts +194 -0
- package/src/prompts/index.ts +36 -0
- package/src/prompts/macros.test.ts +107 -0
- package/src/prompts/macros.ts +27 -0
- package/src/testing/bootstrap-for-testing.ts +39 -0
- package/src/testing/index.ts +7 -0
- package/src/testing/node-platform.ts +80 -0
- package/src/testing/notification-collector.ts +100 -0
- package/src/testing/preset-helpers.ts +57 -0
- package/src/testing/test-harness.test.ts +63 -0
- package/src/testing/test-harness.ts +279 -0
- package/src/testing/wait-helpers.ts +84 -0
- package/src/transport/adapter/client-adapter.ts +81 -0
- package/src/transport/adapter/index.ts +42 -0
- package/src/transport/adapter/server-adapter.ts +93 -0
- package/src/transport/adapter/types.ts +20 -0
- package/src/transport/http/app.ts +129 -0
- package/src/transport/http/index.ts +7 -0
- package/src/transport/http/middleware/bearer-auth.ts +40 -0
- package/src/transport/http/middleware/error-handler.ts +76 -0
- package/src/transport/http/routes/files.ts +274 -0
- package/src/transport/http/routes/resources.ts +115 -0
- package/src/transport/http/routes/rpc.integration.test.ts +243 -0
- package/src/transport/http/routes/rpc.test.ts +372 -0
- package/src/transport/http/routes/rpc.ts +156 -0
- package/src/transport/http/routes/upload.ts +286 -0
- package/src/transport/rpc/index.ts +11 -0
- package/src/transport/rpc/methods.ts +38 -0
- package/src/user-config.ts +33 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mailbox Plugin - Inter-agent communication via message passing
|
|
3
|
+
*
|
|
4
|
+
* Level 1 (Preset): Empty config (mailbox is always enabled)
|
|
5
|
+
* Level 2 (Session): Events factory + state slice + methods + tools
|
|
6
|
+
* Level 3 (Agent): send_message tool for communication
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import z from "zod/v4";
|
|
10
|
+
import { getAgentRole } from "~/core/agents/agent-roles.js";
|
|
11
|
+
import { type AgentId, agentIdSchema } from "~/core/agents/schema.js";
|
|
12
|
+
import { ValidationErrors } from "~/core/errors.js";
|
|
13
|
+
import { definePlugin } from "~/core/plugins/plugin-builder.js";
|
|
14
|
+
import { createTool } from "~/core/tools/definition.js";
|
|
15
|
+
import type { ToolError } from "~/core/tools/index.js";
|
|
16
|
+
import { Err, Ok } from "~/lib/utils/result.js";
|
|
17
|
+
import { canCommunicateWith, getCommunicableAgents } from "./helpers.js";
|
|
18
|
+
import {
|
|
19
|
+
CHILD_REPORTING_SECTION,
|
|
20
|
+
COMMUNICATOR_FLOW_SECTION,
|
|
21
|
+
ENTRY_ROLE_SECTION,
|
|
22
|
+
formatMailboxForLLM,
|
|
23
|
+
ORCHESTRATOR_REPORTING_SECTION,
|
|
24
|
+
} from "./prompts.js";
|
|
25
|
+
import {
|
|
26
|
+
getAgentUnconsumedMailbox,
|
|
27
|
+
getNextMessageSeq,
|
|
28
|
+
type MailboxPluginState,
|
|
29
|
+
} from "./query.js";
|
|
30
|
+
import { generateMessageId, type MessageId } from "./schema.js";
|
|
31
|
+
import type { MailboxMessage } from "./schema.js";
|
|
32
|
+
import { mailboxEvents } from "./state.js";
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Session-wide mailbox configuration.
|
|
36
|
+
*/
|
|
37
|
+
export type MailboxPresetConfig = {};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Agent-specific mailbox configuration.
|
|
41
|
+
*/
|
|
42
|
+
export interface MailboxAgentConfig {
|
|
43
|
+
/** If true, agent sends a completion message to its parent when it has no more work. */
|
|
44
|
+
sendCompletionMessage?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export const mailboxPlugin = definePlugin("mailbox")
|
|
48
|
+
.pluginConfig<MailboxPresetConfig>()
|
|
49
|
+
.agentConfig<MailboxAgentConfig>()
|
|
50
|
+
.events([mailboxEvents])
|
|
51
|
+
.state<MailboxPluginState>({
|
|
52
|
+
key: "mailbox",
|
|
53
|
+
initial: (): MailboxPluginState => ({
|
|
54
|
+
agentMailboxes: new Map(),
|
|
55
|
+
}),
|
|
56
|
+
reduce: (state, event) => {
|
|
57
|
+
switch (event.type) {
|
|
58
|
+
case "mailbox_message": {
|
|
59
|
+
const agentMailbox = state.agentMailboxes.get(event.toAgentId) ?? [];
|
|
60
|
+
const newMailboxes = new Map(state.agentMailboxes);
|
|
61
|
+
newMailboxes.set(event.toAgentId, [...agentMailbox, event.message]);
|
|
62
|
+
return {
|
|
63
|
+
...state,
|
|
64
|
+
agentMailboxes: newMailboxes,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
case "mailbox_consumed": {
|
|
69
|
+
const mailbox = state.agentMailboxes.get(event.agentId);
|
|
70
|
+
if (!mailbox) return state;
|
|
71
|
+
const consumedSet = new Set(event.messageIds);
|
|
72
|
+
const newMailboxes = new Map(state.agentMailboxes);
|
|
73
|
+
newMailboxes.set(
|
|
74
|
+
event.agentId,
|
|
75
|
+
mailbox.map((m) =>
|
|
76
|
+
consumedSet.has(m.id) ? { ...m, consumed: true } : m,
|
|
77
|
+
),
|
|
78
|
+
);
|
|
79
|
+
return { ...state, agentMailboxes: newMailboxes };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
default:
|
|
83
|
+
return state;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
})
|
|
87
|
+
.method("send", {
|
|
88
|
+
input: z.object({
|
|
89
|
+
fromAgentId: agentIdSchema.optional(),
|
|
90
|
+
toAgentId: agentIdSchema,
|
|
91
|
+
content: z.string(),
|
|
92
|
+
debug: z.boolean().optional(),
|
|
93
|
+
}),
|
|
94
|
+
output: z.object({ messageId: z.string() }),
|
|
95
|
+
handler: async (ctx, input) => {
|
|
96
|
+
const { toAgentId, content } = input;
|
|
97
|
+
|
|
98
|
+
if (input.debug) {
|
|
99
|
+
// Debug messages bypass communication validation
|
|
100
|
+
const messageId = generateMessageId(getNextMessageSeq(ctx.pluginState));
|
|
101
|
+
await ctx.emitEvent(
|
|
102
|
+
mailboxEvents.create("mailbox_message", {
|
|
103
|
+
toAgentId,
|
|
104
|
+
message: {
|
|
105
|
+
id: messageId,
|
|
106
|
+
from: "debug",
|
|
107
|
+
content,
|
|
108
|
+
timestamp: Date.now(),
|
|
109
|
+
consumed: false,
|
|
110
|
+
},
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
113
|
+
ctx.scheduleAgent(toAgentId);
|
|
114
|
+
return Ok({ messageId });
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const fromAgentId = input.fromAgentId;
|
|
118
|
+
if (!fromAgentId) {
|
|
119
|
+
return Err(
|
|
120
|
+
ValidationErrors.invalid(
|
|
121
|
+
"fromAgentId is required for non-debug messages",
|
|
122
|
+
),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Validate that the target agent is allowed
|
|
127
|
+
if (!canCommunicateWith(ctx.sessionState, fromAgentId, toAgentId)) {
|
|
128
|
+
const allowed = getCommunicableAgents(ctx.sessionState, fromAgentId);
|
|
129
|
+
const allowedStr = allowed.length > 0 ? allowed.join(", ") : "none";
|
|
130
|
+
return Err(
|
|
131
|
+
ValidationErrors.invalid(
|
|
132
|
+
`Cannot send message to agent ${toAgentId}. You can only communicate with your parent or children. Allowed agents: ${allowedStr}`,
|
|
133
|
+
),
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const messageId = generateMessageId(getNextMessageSeq(ctx.pluginState));
|
|
138
|
+
const now = Date.now();
|
|
139
|
+
|
|
140
|
+
await ctx.emitEvent(
|
|
141
|
+
mailboxEvents.create("mailbox_message", {
|
|
142
|
+
toAgentId,
|
|
143
|
+
message: {
|
|
144
|
+
id: messageId,
|
|
145
|
+
from: fromAgentId,
|
|
146
|
+
content,
|
|
147
|
+
timestamp: now,
|
|
148
|
+
consumed: false,
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
ctx.scheduleAgent(toAgentId);
|
|
154
|
+
|
|
155
|
+
return Ok({ messageId });
|
|
156
|
+
},
|
|
157
|
+
})
|
|
158
|
+
.dequeue({
|
|
159
|
+
hasPendingMessages: (ctx) => {
|
|
160
|
+
return getAgentUnconsumedMailbox(ctx.pluginState, ctx.agentId).length > 0;
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
getPendingMessages: (ctx) => {
|
|
164
|
+
const unconsumed = getAgentUnconsumedMailbox(
|
|
165
|
+
ctx.pluginState,
|
|
166
|
+
ctx.agentId,
|
|
167
|
+
);
|
|
168
|
+
if (unconsumed.length === 0) return null;
|
|
169
|
+
return {
|
|
170
|
+
messages: [
|
|
171
|
+
{
|
|
172
|
+
role: "user",
|
|
173
|
+
content: formatMailboxForLLM(unconsumed, Date.now()),
|
|
174
|
+
sourceMessageIds: unconsumed.map((m: MailboxMessage) => m.id),
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
token: unconsumed.map((m: MailboxMessage) => m.id),
|
|
178
|
+
};
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
markConsumed: async (ctx, token) => {
|
|
182
|
+
await ctx.emitEvent(
|
|
183
|
+
mailboxEvents.create("mailbox_consumed", {
|
|
184
|
+
agentId: ctx.agentId,
|
|
185
|
+
messageIds: token,
|
|
186
|
+
}),
|
|
187
|
+
);
|
|
188
|
+
},
|
|
189
|
+
})
|
|
190
|
+
.hook("onComplete", async (ctx) => {
|
|
191
|
+
if (!ctx.agentState.parentId) return null;
|
|
192
|
+
if (!ctx.pluginAgentConfig?.sendCompletionMessage) return null;
|
|
193
|
+
|
|
194
|
+
await ctx.self.send({
|
|
195
|
+
fromAgentId: ctx.agentId,
|
|
196
|
+
toAgentId: ctx.agentState.parentId,
|
|
197
|
+
content: "Task completed.",
|
|
198
|
+
});
|
|
199
|
+
return null;
|
|
200
|
+
})
|
|
201
|
+
.hook("onError", async (ctx) => {
|
|
202
|
+
if (!ctx.agentState.parentId) return null;
|
|
203
|
+
|
|
204
|
+
await ctx.self.send({
|
|
205
|
+
fromAgentId: ctx.agentId,
|
|
206
|
+
toAgentId: ctx.agentState.parentId,
|
|
207
|
+
content: `Agent encountered an error: ${ctx.error}`,
|
|
208
|
+
});
|
|
209
|
+
return null;
|
|
210
|
+
})
|
|
211
|
+
.systemPrompt((ctx) => {
|
|
212
|
+
const role = getAgentRole(ctx.agentState, ctx.sessionState);
|
|
213
|
+
switch (role) {
|
|
214
|
+
case "child":
|
|
215
|
+
return CHILD_REPORTING_SECTION;
|
|
216
|
+
case "orchestrator":
|
|
217
|
+
return ORCHESTRATOR_REPORTING_SECTION;
|
|
218
|
+
case "communicator":
|
|
219
|
+
return COMMUNICATOR_FLOW_SECTION;
|
|
220
|
+
case "entry":
|
|
221
|
+
return ENTRY_ROLE_SECTION;
|
|
222
|
+
}
|
|
223
|
+
})
|
|
224
|
+
.tools((ctx) => {
|
|
225
|
+
return [
|
|
226
|
+
createTool({
|
|
227
|
+
name: "send_message",
|
|
228
|
+
description:
|
|
229
|
+
'Send a message to another agent. Use to: "parent" to report back to your parent agent, or a specific agent ID for child agents. (async, in response will ONLY confirm sending)',
|
|
230
|
+
input: z.object({
|
|
231
|
+
to: z
|
|
232
|
+
.string()
|
|
233
|
+
.describe(
|
|
234
|
+
'Target agent ID, or "parent" to send to your parent agent',
|
|
235
|
+
),
|
|
236
|
+
message: z.string().describe("Message content to send"),
|
|
237
|
+
}),
|
|
238
|
+
execute: async (input, context) => {
|
|
239
|
+
let toAgentId = input.to as AgentId;
|
|
240
|
+
|
|
241
|
+
// Resolve "parent" alias to actual parentId
|
|
242
|
+
if (toAgentId === ("parent" as AgentId)) {
|
|
243
|
+
const agentState = ctx.sessionState.agents.get(context.agentId);
|
|
244
|
+
if (!agentState?.parentId) {
|
|
245
|
+
return Err({
|
|
246
|
+
message:
|
|
247
|
+
'Cannot send message to "parent": this agent has no parent.',
|
|
248
|
+
recoverable: false,
|
|
249
|
+
} satisfies ToolError);
|
|
250
|
+
}
|
|
251
|
+
toAgentId = agentState.parentId;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
const result = await ctx.self.send({
|
|
255
|
+
fromAgentId: context.agentId,
|
|
256
|
+
toAgentId,
|
|
257
|
+
content: input.message,
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
if (!result.ok)
|
|
261
|
+
return Err({ message: result.error.message, recoverable: false });
|
|
262
|
+
|
|
263
|
+
return Ok(
|
|
264
|
+
`Message sent to ${input.to} (message ID: ${result.value.messageId}).`,
|
|
265
|
+
);
|
|
266
|
+
},
|
|
267
|
+
}),
|
|
268
|
+
];
|
|
269
|
+
})
|
|
270
|
+
.build();
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { MailboxMessage } from './schema.js'
|
|
2
|
+
|
|
3
|
+
// ============================================================================
|
|
4
|
+
// Role briefing sections for system prompt composition
|
|
5
|
+
// ============================================================================
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Briefing for entry agents (orchestrator without communicator).
|
|
9
|
+
* Entry agents can communicate directly with users and orchestrate children.
|
|
10
|
+
*/
|
|
11
|
+
export const ENTRY_ROLE_SECTION = `## Your Role: Entry Agent (Orchestrator)
|
|
12
|
+
|
|
13
|
+
You are the entry point for user communication AND you orchestrate child agents. See your available tools for capabilities.`
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Reporting instructions for child agents.
|
|
17
|
+
* Child agents cannot communicate with users directly.
|
|
18
|
+
*/
|
|
19
|
+
export const CHILD_REPORTING_SECTION = `## Your Role: Child Agent
|
|
20
|
+
|
|
21
|
+
You were spawned by a parent agent to handle a specific task. You CANNOT communicate with users directly. See your available tools for capabilities.
|
|
22
|
+
|
|
23
|
+
Focus on completing your assigned task.
|
|
24
|
+
|
|
25
|
+
## Reporting (MANDATORY)
|
|
26
|
+
|
|
27
|
+
**You MUST always report back to your parent via \`send_message\` with \`to: "parent"\` before stopping.** This is the most important rule — your parent is waiting for your response and cannot proceed without it.
|
|
28
|
+
|
|
29
|
+
- **Task completed**: Call \`send_message\` with \`to: "parent"\` and a structured final result summarizing what you accomplished and any relevant outputs.
|
|
30
|
+
- **Task failed / blocked**: If you encounter an error, are blocked, or cannot complete the task for any reason, you MUST still call \`send_message\` with \`to: "parent"\` explaining what went wrong and what you attempted.
|
|
31
|
+
- **Progress updates**: For long-running tasks, report progress to your parent periodically via \`send_message\` with \`to: "parent"\`.
|
|
32
|
+
|
|
33
|
+
**Never stop without calling \`send_message\` with \`to: "parent"\`.** Silent termination leaves your parent stuck waiting indefinitely.`
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Reporting instructions for orchestrator agents (when there's a communicator).
|
|
37
|
+
*/
|
|
38
|
+
export const ORCHESTRATOR_REPORTING_SECTION = `## Your Role: Orchestrator
|
|
39
|
+
|
|
40
|
+
You coordinate work and spawn child agents to complete tasks. You do NOT communicate directly with users. See your available tools for capabilities.
|
|
41
|
+
|
|
42
|
+
You receive tasks from the communicator via \`send_message\`. The communicator's agent ID is in the \`from\` field of the message you receive.
|
|
43
|
+
|
|
44
|
+
## Reporting (MANDATORY)
|
|
45
|
+
|
|
46
|
+
**You MUST always report back to the communicator via \`send_message\` before stopping.** The communicator is waiting for your response and cannot update the user without it.
|
|
47
|
+
|
|
48
|
+
- **Task completed**: Send a structured result summarizing what was accomplished.
|
|
49
|
+
- **Task failed / blocked**: If you cannot complete the task, you MUST still send a message explaining what went wrong.
|
|
50
|
+
- **Progress updates**: For long-running tasks, report progress to the communicator periodically.
|
|
51
|
+
|
|
52
|
+
**Never stop without sending a message to the communicator.** Silent termination leaves the communicator and user stuck waiting indefinitely.`
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Message flow instructions for communicator agents.
|
|
56
|
+
*/
|
|
57
|
+
export const COMMUNICATOR_FLOW_SECTION = `## Your Role: Communicator
|
|
58
|
+
|
|
59
|
+
You handle user communication and relay messages to/from the orchestrator. See your available tools for capabilities.
|
|
60
|
+
|
|
61
|
+
## Message Flow
|
|
62
|
+
|
|
63
|
+
- User messages arrive to you first
|
|
64
|
+
- Forward tasks to the orchestrator via \`send_message\` (use the orchestrator's agent ID from messages)
|
|
65
|
+
- When the orchestrator reports back, format and relay the results to the user via \`tell_user\``
|
|
66
|
+
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Mailbox formatting
|
|
69
|
+
// ============================================================================
|
|
70
|
+
|
|
71
|
+
export const formatMailboxForLLM = (messages: MailboxMessage[], currentTimestamp?: number): string => {
|
|
72
|
+
const formattedMessages = messages
|
|
73
|
+
.map((m) => {
|
|
74
|
+
const from = m.from === 'user' ? 'user' : m.from
|
|
75
|
+
// Format answer messages with XML wrapper for LLM
|
|
76
|
+
let content = m.answerTo
|
|
77
|
+
? `<answer questionId="${m.answerTo}">\n${JSON.stringify(m.answerValue)}\n</answer>`
|
|
78
|
+
: m.content
|
|
79
|
+
|
|
80
|
+
// Add attachment information if present
|
|
81
|
+
if (m.attachments && m.attachments.length > 0) {
|
|
82
|
+
const attachmentBlocks = m.attachments.map((att) => {
|
|
83
|
+
const innerContent = att.extractedContent
|
|
84
|
+
? att.extractedContent
|
|
85
|
+
: `[File uploaded: ${att.filename}]`
|
|
86
|
+
return `<attachment uploadId="${att.uploadId}" filename="${att.filename}" type="${att.mimeType}" path="${att.path}">\n${innerContent}\n</attachment>`
|
|
87
|
+
})
|
|
88
|
+
content = content + '\n' + attachmentBlocks.join('\n')
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Add context block if present (visible to LLM only)
|
|
92
|
+
if (m.context) {
|
|
93
|
+
content = content + `\n<message-context>\n${m.context}\n</message-context>`
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Add timestamp attribute to message tag
|
|
97
|
+
return `<message from="${from}" timestamp="${m.timestamp}">\n${content}\n</message>`
|
|
98
|
+
})
|
|
99
|
+
.join('\n\n')
|
|
100
|
+
|
|
101
|
+
// Add info block with current timestamp at the end
|
|
102
|
+
const now = currentTimestamp ?? Date.now()
|
|
103
|
+
return formattedMessages + `\n\n<info>\n <currentTime>${new Date(now).toISOString()}</currentTime>\n</info>`
|
|
104
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mailbox plugin query helpers.
|
|
3
|
+
*
|
|
4
|
+
* Query functions accept MailboxPluginState directly.
|
|
5
|
+
* Use selectMailboxState() to extract plugin state from SessionState.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { AgentId } from '~/core/agents/schema.js'
|
|
9
|
+
import { selectPluginState } from '~/core/sessions/reducer.js'
|
|
10
|
+
import type { SessionState } from '~/core/sessions/state.js'
|
|
11
|
+
import type { MailboxMessage } from './schema.js'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Mailbox plugin state — session-level state keyed by agent ID.
|
|
15
|
+
*/
|
|
16
|
+
export interface MailboxPluginState {
|
|
17
|
+
agentMailboxes: Map<AgentId, MailboxMessage[]>
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const defaultState: MailboxPluginState = { agentMailboxes: new Map() }
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Extract MailboxPluginState from SessionState.
|
|
24
|
+
*/
|
|
25
|
+
export function selectMailboxState(sessionState: SessionState): MailboxPluginState {
|
|
26
|
+
return selectPluginState<MailboxPluginState>(sessionState, 'mailbox') ?? defaultState
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get all mailbox messages for a specific agent.
|
|
31
|
+
*/
|
|
32
|
+
export function getAgentMailbox(pluginState: MailboxPluginState, agentId: AgentId): MailboxMessage[] {
|
|
33
|
+
return pluginState.agentMailboxes.get(agentId) ?? []
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Get unconsumed mailbox messages for a specific agent.
|
|
38
|
+
*/
|
|
39
|
+
export function getAgentUnconsumedMailbox(pluginState: MailboxPluginState, agentId: AgentId): MailboxMessage[] {
|
|
40
|
+
return getAgentMailbox(pluginState, agentId).filter((m) => !m.consumed)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the next message sequence number.
|
|
45
|
+
* Derived from total message count across all mailboxes (replay-safe).
|
|
46
|
+
*/
|
|
47
|
+
export function getNextMessageSeq(pluginState: MailboxPluginState): number {
|
|
48
|
+
let total = 0
|
|
49
|
+
for (const messages of pluginState.agentMailboxes.values()) {
|
|
50
|
+
total += messages.length
|
|
51
|
+
}
|
|
52
|
+
return total + 1
|
|
53
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Message domain types and schemas
|
|
3
|
+
*
|
|
4
|
+
* Contains all types related to messages:
|
|
5
|
+
* - Branded ID type and constructor
|
|
6
|
+
* - Mailbox types
|
|
7
|
+
* - AskUser input types
|
|
8
|
+
* - Zod schemas for validation
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import z from 'zod/v4'
|
|
12
|
+
import { COMMUNICATOR_ROLE, ORCHESTRATOR_ROLE } from '../../core/agents/agent-roles.js'
|
|
13
|
+
import type { AgentId } from '../../core/agents/schema.js'
|
|
14
|
+
import type { MessageAttachment } from '../uploads/schema.js'
|
|
15
|
+
import type { WorkerId } from '../workers/worker.js'
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// MessageId - Branded type
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
/** MessageId schema - validates any string and brands as MessageId. */
|
|
22
|
+
export const messageIdSchema = z.string().brand('MessageId')
|
|
23
|
+
|
|
24
|
+
/** Branded MessageId type */
|
|
25
|
+
export type MessageId = z.infer<typeof messageIdSchema>
|
|
26
|
+
|
|
27
|
+
/** Constructor for MessageId */
|
|
28
|
+
export const MessageId = (id: string): MessageId => id as MessageId
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generate a short message ID.
|
|
32
|
+
* Format: m{seq} e.g., "m1", "m42"
|
|
33
|
+
*/
|
|
34
|
+
export const generateMessageId = (seq: number): MessageId => MessageId(`m${seq}`)
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Test helpers
|
|
38
|
+
// ============================================================================
|
|
39
|
+
|
|
40
|
+
let testCounter = 0
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Generate a test message ID (for tests only).
|
|
44
|
+
* Uses incrementing counter for uniqueness.
|
|
45
|
+
*/
|
|
46
|
+
export const generateTestMessageId = (): MessageId => MessageId(`m${++testCounter}`)
|
|
47
|
+
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Mailbox types
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Sender of a mailbox message.
|
|
54
|
+
* Can be an agent, user, system roles, or a worker.
|
|
55
|
+
*/
|
|
56
|
+
export type MailboxMessageSender =
|
|
57
|
+
| AgentId
|
|
58
|
+
| WorkerId
|
|
59
|
+
| 'user'
|
|
60
|
+
| 'debug'
|
|
61
|
+
| typeof ORCHESTRATOR_ROLE
|
|
62
|
+
| typeof COMMUNICATOR_ROLE
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Message in an agent's mailbox.
|
|
66
|
+
*/
|
|
67
|
+
export type MailboxMessage = {
|
|
68
|
+
id: MessageId
|
|
69
|
+
from: MailboxMessageSender
|
|
70
|
+
content: string
|
|
71
|
+
timestamp: number
|
|
72
|
+
consumed: boolean
|
|
73
|
+
/** If this message is an answer to a question, the question's message ID */
|
|
74
|
+
answerTo?: MessageId
|
|
75
|
+
/** The answer value (JSON-serializable), only present when answerTo is set */
|
|
76
|
+
answerValue?: unknown
|
|
77
|
+
/** File attachments uploaded with this message */
|
|
78
|
+
attachments?: MessageAttachment[]
|
|
79
|
+
/** Optional context visible to LLM but not displayed in chat UI */
|
|
80
|
+
context?: string
|
|
81
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import z4 from 'zod/v4'
|
|
2
|
+
import { AgentId, agentIdSchema } from '~/core/agents'
|
|
3
|
+
import { COMMUNICATOR_ROLE, ORCHESTRATOR_ROLE } from '~/core/agents/agent-roles'
|
|
4
|
+
import { createEventsFactory } from '~/core/events/types'
|
|
5
|
+
import { messageIdSchema } from '~/plugins/mailbox/schema'
|
|
6
|
+
import { uploadIdSchema } from '~/plugins/uploads/schema'
|
|
7
|
+
import { WorkerId, workerIdSchema } from '../workers/worker'
|
|
8
|
+
|
|
9
|
+
export type MailboxMessageSender =
|
|
10
|
+
| AgentId
|
|
11
|
+
| WorkerId
|
|
12
|
+
| 'user'
|
|
13
|
+
| 'debug'
|
|
14
|
+
| typeof ORCHESTRATOR_ROLE
|
|
15
|
+
| typeof COMMUNICATOR_ROLE
|
|
16
|
+
|
|
17
|
+
export const mailboxEvents = createEventsFactory({
|
|
18
|
+
events: {
|
|
19
|
+
mailbox_message: z4.object({
|
|
20
|
+
toAgentId: agentIdSchema,
|
|
21
|
+
message: z4.object({
|
|
22
|
+
id: messageIdSchema,
|
|
23
|
+
from: z4.union([
|
|
24
|
+
agentIdSchema,
|
|
25
|
+
workerIdSchema,
|
|
26
|
+
z4.enum(['user', 'debug', COMMUNICATOR_ROLE, ORCHESTRATOR_ROLE]),
|
|
27
|
+
]),
|
|
28
|
+
content: z4.string(),
|
|
29
|
+
timestamp: z4.number(),
|
|
30
|
+
consumed: z4.boolean(),
|
|
31
|
+
answerTo: messageIdSchema.optional(),
|
|
32
|
+
answerValue: z4.unknown().optional(),
|
|
33
|
+
attachments: z4.array(z4.object({
|
|
34
|
+
uploadId: uploadIdSchema,
|
|
35
|
+
filename: z4.string(),
|
|
36
|
+
mimeType: z4.string(),
|
|
37
|
+
size: z4.number(),
|
|
38
|
+
path: z4.string(),
|
|
39
|
+
extractedContent: z4.string().optional(),
|
|
40
|
+
derivedPaths: z4.array(z4.string()).optional(),
|
|
41
|
+
})).optional(),
|
|
42
|
+
}),
|
|
43
|
+
}),
|
|
44
|
+
mailbox_consumed: z4.object({
|
|
45
|
+
agentId: agentIdSchema,
|
|
46
|
+
messageIds: z4.array(messageIdSchema),
|
|
47
|
+
}),
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
export type MailboxMessageEvent = (typeof mailboxEvents)['Events']['mailbox_message']
|
|
52
|
+
export type MailboxConsumedEvent = (typeof mailboxEvents)['Events']['mailbox_consumed']
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { resourcesPlugin } from './plugin.js'
|
|
2
|
+
export type { ResourcesPluginConfig } from './plugin.js'
|
|
3
|
+
export { postInjectRules } from './post-inject.js'
|
|
4
|
+
export type {
|
|
5
|
+
PostInjectContext,
|
|
6
|
+
PostInjectExecOptions,
|
|
7
|
+
PostInjectHook,
|
|
8
|
+
PostInjectRule,
|
|
9
|
+
} from './post-inject.js'
|
|
10
|
+
export { RESOURCE_MANIFEST_FILENAME, ResourceManifestSchema } from './manifest.js'
|
|
11
|
+
export type { ResourceManifest } from './manifest.js'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
import type { PostInjectRule } from './post-inject.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* File at the root of a resource zip that ships template-specific setup
|
|
6
|
+
* instructions (e.g. `bun install` for a JS template). Read by the resources
|
|
7
|
+
* plugin after extraction, then deleted so it doesn't pollute the workspace.
|
|
8
|
+
*/
|
|
9
|
+
export const RESOURCE_MANIFEST_FILENAME = 'roj.resource.json'
|
|
10
|
+
|
|
11
|
+
const PostInjectRuleSchema = z.object({
|
|
12
|
+
name: z.string().optional(),
|
|
13
|
+
when: z.string().optional(),
|
|
14
|
+
cwd: z.enum(['target', 'session']).optional(),
|
|
15
|
+
run: z.tuple([z.string()]).rest(z.string()),
|
|
16
|
+
env: z.record(z.string(), z.string()).optional(),
|
|
17
|
+
timeoutMs: z.number().positive().optional(),
|
|
18
|
+
continueOnError: z.boolean().optional(),
|
|
19
|
+
}) satisfies z.ZodType<PostInjectRule>
|
|
20
|
+
|
|
21
|
+
export const ResourceManifestSchema = z.object({
|
|
22
|
+
postInject: z.array(PostInjectRuleSchema).optional(),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
export type ResourceManifest = z.infer<typeof ResourceManifestSchema>
|