@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,191 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
import { agentEvents } from '~/core/agents/state.js'
|
|
3
|
+
import { MockLLMProvider } from '~/core/llm/mock.js'
|
|
4
|
+
import { llmEvents } from '~/core/llm/state.js'
|
|
5
|
+
import { applyEvent } from '~/core/sessions/apply-event.js'
|
|
6
|
+
import { reconstructSessionState } from '~/core/sessions/state.js'
|
|
7
|
+
import { ToolCallId } from '~/core/tools/schema.js'
|
|
8
|
+
import { toolEvents } from '~/core/tools/state.js'
|
|
9
|
+
import { createTestPreset, TestHarness } from '~/testing/index.js'
|
|
10
|
+
|
|
11
|
+
describe('core: event sourcing correctness', () => {
|
|
12
|
+
it('all events from a full flow persisted in event store in correct order', async () => {
|
|
13
|
+
const harness = new TestHarness({
|
|
14
|
+
presets: [createTestPreset()],
|
|
15
|
+
llmProvider: MockLLMProvider.withSequence([
|
|
16
|
+
{
|
|
17
|
+
toolCalls: [{ id: ToolCallId('tc1'), name: 'tell_user', input: { message: 'Hi!' } }],
|
|
18
|
+
},
|
|
19
|
+
{ content: 'Done', toolCalls: [] },
|
|
20
|
+
]),
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const session = await harness.createSession('test')
|
|
24
|
+
await session.sendAndWaitForIdle('Hello')
|
|
25
|
+
|
|
26
|
+
const events = await session.getEvents()
|
|
27
|
+
|
|
28
|
+
// Should start with session_created
|
|
29
|
+
expect(events[0].type).toBe('session_created')
|
|
30
|
+
|
|
31
|
+
// Extract event types in order
|
|
32
|
+
const types = events.map((e) => e.type)
|
|
33
|
+
|
|
34
|
+
// session_created must come first
|
|
35
|
+
expect(types.indexOf('session_created')).toBe(0)
|
|
36
|
+
|
|
37
|
+
// agent_spawned after session_created
|
|
38
|
+
expect(types.indexOf('agent_spawned')).toBeGreaterThan(types.indexOf('session_created'))
|
|
39
|
+
|
|
40
|
+
// inference_started before inference_completed
|
|
41
|
+
const inferStartIdx = types.indexOf('inference_started')
|
|
42
|
+
const inferCompleteIdx = types.indexOf('inference_completed')
|
|
43
|
+
expect(inferStartIdx).toBeGreaterThan(-1)
|
|
44
|
+
expect(inferCompleteIdx).toBeGreaterThan(inferStartIdx)
|
|
45
|
+
|
|
46
|
+
// tool_started before tool_completed
|
|
47
|
+
const toolStartIdx = types.indexOf('tool_started')
|
|
48
|
+
const toolCompleteIdx = types.indexOf('tool_completed')
|
|
49
|
+
expect(toolStartIdx).toBeGreaterThan(-1)
|
|
50
|
+
expect(toolCompleteIdx).toBeGreaterThan(toolStartIdx)
|
|
51
|
+
|
|
52
|
+
// tool events between first and second inference cycles
|
|
53
|
+
expect(toolStartIdx).toBeGreaterThan(inferCompleteIdx)
|
|
54
|
+
|
|
55
|
+
await harness.shutdown()
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('session state after replay matches live state', async () => {
|
|
59
|
+
const harness = new TestHarness({
|
|
60
|
+
presets: [createTestPreset()],
|
|
61
|
+
llmProvider: MockLLMProvider.withSequence([
|
|
62
|
+
{
|
|
63
|
+
toolCalls: [{ id: ToolCallId('tc1'), name: 'tell_user', input: { message: 'Hi!' } }],
|
|
64
|
+
},
|
|
65
|
+
{ content: 'Done', toolCalls: [] },
|
|
66
|
+
]),
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const session = await harness.createSession('test')
|
|
70
|
+
await session.sendAndWaitForIdle('Hello')
|
|
71
|
+
|
|
72
|
+
const liveState = session.state
|
|
73
|
+
const events = await session.getEvents()
|
|
74
|
+
|
|
75
|
+
// Replay state from events using the base reducer (core + mailbox)
|
|
76
|
+
const replayedState = reconstructSessionState(events, applyEvent)
|
|
77
|
+
|
|
78
|
+
expect(replayedState).not.toBeNull()
|
|
79
|
+
expect(replayedState!.id).toEqual(liveState.id)
|
|
80
|
+
expect(replayedState!.presetId).toBe(liveState.presetId)
|
|
81
|
+
expect(replayedState!.status).toBe(liveState.status)
|
|
82
|
+
expect(replayedState!.agents.size).toBe(liveState.agents.size)
|
|
83
|
+
|
|
84
|
+
// Verify each agent's status matches
|
|
85
|
+
for (const [agentId, liveAgent] of liveState.agents) {
|
|
86
|
+
const replayedAgent = replayedState!.agents.get(agentId)
|
|
87
|
+
expect(replayedAgent).toBeDefined()
|
|
88
|
+
expect(replayedAgent!.status).toBe(liveAgent.status)
|
|
89
|
+
expect(replayedAgent!.definitionName).toBe(liveAgent.definitionName)
|
|
90
|
+
expect(replayedAgent!.conversationHistory.length).toBe(liveAgent.conversationHistory.length)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
await harness.shutdown()
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('event types include expected core events from a full flow', async () => {
|
|
97
|
+
const harness = new TestHarness({
|
|
98
|
+
presets: [createTestPreset()],
|
|
99
|
+
llmProvider: MockLLMProvider.withSequence([
|
|
100
|
+
{
|
|
101
|
+
toolCalls: [{ id: ToolCallId('tc1'), name: 'tell_user', input: { message: 'Hi!' } }],
|
|
102
|
+
},
|
|
103
|
+
{ content: 'Done', toolCalls: [] },
|
|
104
|
+
]),
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const session = await harness.createSession('test')
|
|
108
|
+
await session.sendAndWaitForIdle('Hello')
|
|
109
|
+
|
|
110
|
+
const events = await session.getEvents()
|
|
111
|
+
const eventTypes = new Set(events.map((e) => e.type))
|
|
112
|
+
|
|
113
|
+
// Core lifecycle events
|
|
114
|
+
expect(eventTypes.has('session_created')).toBe(true)
|
|
115
|
+
expect(eventTypes.has('agent_spawned')).toBe(true)
|
|
116
|
+
|
|
117
|
+
// LLM events
|
|
118
|
+
expect(eventTypes.has('inference_started')).toBe(true)
|
|
119
|
+
expect(eventTypes.has('inference_completed')).toBe(true)
|
|
120
|
+
|
|
121
|
+
// Tool events
|
|
122
|
+
expect(eventTypes.has('tool_started')).toBe(true)
|
|
123
|
+
expect(eventTypes.has('tool_completed')).toBe(true)
|
|
124
|
+
|
|
125
|
+
// User chat events
|
|
126
|
+
expect(eventTypes.has('user_chat_message_received')).toBe(true)
|
|
127
|
+
|
|
128
|
+
await harness.shutdown()
|
|
129
|
+
})
|
|
130
|
+
|
|
131
|
+
it('event timestamps are monotonically increasing', async () => {
|
|
132
|
+
const harness = new TestHarness({
|
|
133
|
+
presets: [createTestPreset()],
|
|
134
|
+
llmProvider: MockLLMProvider.withSequence([
|
|
135
|
+
{
|
|
136
|
+
toolCalls: [{ id: ToolCallId('tc1'), name: 'tell_user', input: { message: 'Hi!' } }],
|
|
137
|
+
},
|
|
138
|
+
{ content: 'Done', toolCalls: [] },
|
|
139
|
+
]),
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
const session = await harness.createSession('test')
|
|
143
|
+
await session.sendAndWaitForIdle('Hello')
|
|
144
|
+
|
|
145
|
+
const events = await session.getEvents()
|
|
146
|
+
|
|
147
|
+
for (let i = 1; i < events.length; i++) {
|
|
148
|
+
expect(events[i].timestamp).toBeGreaterThanOrEqual(events[i - 1].timestamp)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
await harness.shutdown()
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
it('events have correct agentId references', async () => {
|
|
155
|
+
const harness = new TestHarness({
|
|
156
|
+
presets: [createTestPreset()],
|
|
157
|
+
llmProvider: MockLLMProvider.withSequence([
|
|
158
|
+
{
|
|
159
|
+
toolCalls: [{ id: ToolCallId('tc1'), name: 'tell_user', input: { message: 'Hi!' } }],
|
|
160
|
+
},
|
|
161
|
+
{ content: 'Done', toolCalls: [] },
|
|
162
|
+
]),
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
const session = await harness.createSession('test')
|
|
166
|
+
await session.sendAndWaitForIdle('Hello')
|
|
167
|
+
|
|
168
|
+
const entryAgentId = session.getEntryAgentId()!
|
|
169
|
+
|
|
170
|
+
// All agent-scoped events should reference the entry agent
|
|
171
|
+
const inferenceStarted = await session.getEventsByType(llmEvents, 'inference_started')
|
|
172
|
+
const inferenceCompleted = await session.getEventsByType(llmEvents, 'inference_completed')
|
|
173
|
+
const toolStarted = await session.getEventsByType(toolEvents, 'tool_started')
|
|
174
|
+
const toolCompleted = await session.getEventsByType(toolEvents, 'tool_completed')
|
|
175
|
+
const agentScopedEvents = [...inferenceStarted, ...inferenceCompleted, ...toolStarted, ...toolCompleted]
|
|
176
|
+
|
|
177
|
+
expect(agentScopedEvents.length).toBeGreaterThan(0)
|
|
178
|
+
for (const event of agentScopedEvents) {
|
|
179
|
+
expect(event.agentId).toBe(entryAgentId)
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// agent_spawned should also reference the correct agent
|
|
183
|
+
const spawnedEvents = await session.getEventsByType(agentEvents, 'agent_spawned')
|
|
184
|
+
expect(spawnedEvents.length).toBeGreaterThan(0)
|
|
185
|
+
for (const e of spawnedEvents) {
|
|
186
|
+
expect(session.state.agents.has(e.agentId)).toBe(true)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
await harness.shutdown()
|
|
190
|
+
})
|
|
191
|
+
})
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import type { DomainEvent } from '~/core/events/types.js'
|
|
2
|
+
import type { ListSessionsOptions, SessionId, SessionMetadata } from '~/core/sessions/schema.js'
|
|
3
|
+
import { EventStoreError, type EventStore, type LoadRangeOptions, type LoadRangeResult } from './event-store.js'
|
|
4
|
+
import type { MetadataEvent } from './metadata-utils.js'
|
|
5
|
+
import { computeMetadataFromEvents, needsReconciliation } from './metadata-utils.js'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Event types that must never be emitted on a closed session.
|
|
9
|
+
* See guardWriteToClosed for rationale.
|
|
10
|
+
*/
|
|
11
|
+
function isForbiddenOnClosed(event: DomainEvent): boolean {
|
|
12
|
+
return event.type === 'session_handler_started' || event.type === 'session_handler_completed'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Abstract base class for EventStore implementations.
|
|
17
|
+
*
|
|
18
|
+
* Provides shared logic for metadata processing, filtering/sorting/pagination,
|
|
19
|
+
* and reconciliation. Subclasses only implement storage primitives.
|
|
20
|
+
*/
|
|
21
|
+
export abstract class BaseEventStore implements EventStore {
|
|
22
|
+
// === Public append API (with closed-session guard) ===
|
|
23
|
+
|
|
24
|
+
async append(sessionId: SessionId, event: DomainEvent): Promise<void> {
|
|
25
|
+
if (isForbiddenOnClosed(event)) {
|
|
26
|
+
await this.guardWriteToClosed(sessionId, [event])
|
|
27
|
+
}
|
|
28
|
+
await this.doAppend(sessionId, event)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async appendBatch(sessionId: SessionId, events: DomainEvent[]): Promise<void> {
|
|
32
|
+
if (events.length === 0) return
|
|
33
|
+
if (events.some(isForbiddenOnClosed)) {
|
|
34
|
+
await this.guardWriteToClosed(sessionId, events)
|
|
35
|
+
}
|
|
36
|
+
await this.doAppendBatch(sessionId, events)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// === Storage primitives (subclasses implement) ===
|
|
40
|
+
|
|
41
|
+
protected abstract doAppend(sessionId: SessionId, event: DomainEvent): Promise<void>
|
|
42
|
+
protected abstract doAppendBatch(sessionId: SessionId, events: DomainEvent[]): Promise<void>
|
|
43
|
+
abstract load(sessionId: SessionId): Promise<DomainEvent[]>
|
|
44
|
+
abstract loadRange(sessionId: SessionId, options?: LoadRangeOptions): Promise<LoadRangeResult>
|
|
45
|
+
abstract exists(sessionId: SessionId): Promise<boolean>
|
|
46
|
+
abstract listSessions(): Promise<SessionId[]>
|
|
47
|
+
|
|
48
|
+
// === Metadata storage primitives (subclasses implement) ===
|
|
49
|
+
|
|
50
|
+
protected abstract readMetadata(sessionId: SessionId): Promise<SessionMetadata | null>
|
|
51
|
+
protected abstract writeMetadata(sessionId: SessionId, metadata: SessionMetadata): Promise<void>
|
|
52
|
+
protected abstract getAllSessionMetadata(): Promise<SessionMetadata[]>
|
|
53
|
+
|
|
54
|
+
// === Shared implementations ===
|
|
55
|
+
|
|
56
|
+
async getMetadata(sessionId: SessionId): Promise<SessionMetadata | null> {
|
|
57
|
+
return this.readMetadata(sessionId)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async updateMetadata(
|
|
61
|
+
sessionId: SessionId,
|
|
62
|
+
update: Partial<SessionMetadata>,
|
|
63
|
+
): Promise<void> {
|
|
64
|
+
const existing = await this.readMetadata(sessionId)
|
|
65
|
+
const metadata: SessionMetadata = {
|
|
66
|
+
...existing,
|
|
67
|
+
...update,
|
|
68
|
+
sessionId,
|
|
69
|
+
lastActivityAt: update.lastActivityAt ?? Date.now(),
|
|
70
|
+
} as SessionMetadata
|
|
71
|
+
|
|
72
|
+
await this.writeMetadata(sessionId, metadata)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async listSessionsWithMetadata(
|
|
76
|
+
options?: ListSessionsOptions,
|
|
77
|
+
): Promise<{ sessions: SessionMetadata[]; total: number }> {
|
|
78
|
+
let sessions = await this.getAllSessionMetadata()
|
|
79
|
+
|
|
80
|
+
// Filter by status
|
|
81
|
+
if (options?.status) {
|
|
82
|
+
sessions = sessions.filter((s) => s.status === options.status)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Filter by tags
|
|
86
|
+
if (options?.tags && options.tags.length > 0) {
|
|
87
|
+
sessions = sessions.filter((s) => options.tags!.every((tag) => s.tags?.includes(tag)))
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const total = sessions.length
|
|
91
|
+
|
|
92
|
+
// Sort
|
|
93
|
+
const orderBy = options?.orderBy ?? 'createdAt'
|
|
94
|
+
const order = options?.order ?? 'desc'
|
|
95
|
+
sessions.sort((a, b) => {
|
|
96
|
+
const aVal = a[orderBy] ?? 0
|
|
97
|
+
const bVal = b[orderBy] ?? 0
|
|
98
|
+
return order === 'asc' ? aVal - bVal : bVal - aVal
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
// Pagination
|
|
102
|
+
const offset = options?.offset ?? 0
|
|
103
|
+
const limit = options?.limit ?? sessions.length
|
|
104
|
+
sessions = sessions.slice(offset, offset + limit)
|
|
105
|
+
|
|
106
|
+
return { sessions, total }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async reconcileMetadata(
|
|
110
|
+
sessionId: SessionId,
|
|
111
|
+
events: DomainEvent[],
|
|
112
|
+
): Promise<boolean> {
|
|
113
|
+
if (events.length === 0) return false
|
|
114
|
+
|
|
115
|
+
const computed = computeMetadataFromEvents(sessionId, events)
|
|
116
|
+
if (!computed) return false
|
|
117
|
+
|
|
118
|
+
const stored = await this.readMetadata(sessionId)
|
|
119
|
+
|
|
120
|
+
if (!needsReconciliation(stored, computed)) {
|
|
121
|
+
return false
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Metadata is out of sync - update with computed values
|
|
125
|
+
// Preserve name, tags, and custom data from stored metadata
|
|
126
|
+
const reconciled: SessionMetadata = {
|
|
127
|
+
...computed,
|
|
128
|
+
name: stored?.name,
|
|
129
|
+
tags: stored?.tags,
|
|
130
|
+
custom: stored?.custom,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
await this.writeMetadata(sessionId, reconciled)
|
|
134
|
+
return true
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Update metadata incrementally from events.
|
|
139
|
+
* Aggregates all metric deltas and writes once.
|
|
140
|
+
*/
|
|
141
|
+
protected async updateMetadataFromEvents(
|
|
142
|
+
sessionId: SessionId,
|
|
143
|
+
events: DomainEvent[],
|
|
144
|
+
): Promise<void> {
|
|
145
|
+
if (events.length === 0) return
|
|
146
|
+
|
|
147
|
+
const metadata = await this.readMetadata(sessionId)
|
|
148
|
+
|
|
149
|
+
// Start with current metrics or defaults
|
|
150
|
+
let metrics = metadata?.metrics ?? {
|
|
151
|
+
totalEvents: 0,
|
|
152
|
+
totalAgents: 0,
|
|
153
|
+
totalTokens: 0,
|
|
154
|
+
totalLLMCalls: 0,
|
|
155
|
+
inputTokens: 0,
|
|
156
|
+
outputTokens: 0,
|
|
157
|
+
totalCost: 0,
|
|
158
|
+
totalMessages: 0,
|
|
159
|
+
totalToolCalls: 0,
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const update: Partial<SessionMetadata> = {}
|
|
163
|
+
|
|
164
|
+
// Process all events and aggregate metrics
|
|
165
|
+
for (const event of events as MetadataEvent[]) {
|
|
166
|
+
update.lastActivityAt = event.timestamp
|
|
167
|
+
|
|
168
|
+
switch (event.type) {
|
|
169
|
+
case 'session_created':
|
|
170
|
+
update.createdAt = event.timestamp
|
|
171
|
+
update.presetId = event.presetId
|
|
172
|
+
update.status = 'active'
|
|
173
|
+
metrics = {
|
|
174
|
+
totalEvents: 1,
|
|
175
|
+
totalAgents: 0,
|
|
176
|
+
totalTokens: 0,
|
|
177
|
+
totalLLMCalls: 0,
|
|
178
|
+
inputTokens: 0,
|
|
179
|
+
outputTokens: 0,
|
|
180
|
+
totalCost: 0,
|
|
181
|
+
totalMessages: 0,
|
|
182
|
+
totalToolCalls: 0,
|
|
183
|
+
}
|
|
184
|
+
break
|
|
185
|
+
|
|
186
|
+
case 'session_closed':
|
|
187
|
+
update.status = 'closed'
|
|
188
|
+
metrics.totalEvents += 1
|
|
189
|
+
break
|
|
190
|
+
|
|
191
|
+
case 'session_reopened':
|
|
192
|
+
update.status = 'active'
|
|
193
|
+
metrics.totalEvents += 1
|
|
194
|
+
break
|
|
195
|
+
|
|
196
|
+
case 'agent_spawned':
|
|
197
|
+
metrics.totalAgents += 1
|
|
198
|
+
metrics.totalEvents += 1
|
|
199
|
+
break
|
|
200
|
+
|
|
201
|
+
case 'inference_completed':
|
|
202
|
+
if (event.metrics) {
|
|
203
|
+
metrics.totalTokens += event.metrics.totalTokens ?? 0
|
|
204
|
+
metrics.inputTokens = (metrics.inputTokens ?? 0) + (event.metrics.promptTokens ?? 0)
|
|
205
|
+
metrics.outputTokens = (metrics.outputTokens ?? 0) + (event.metrics.completionTokens ?? 0)
|
|
206
|
+
metrics.totalCost = (metrics.totalCost ?? 0) + (event.metrics.cost ?? 0)
|
|
207
|
+
metrics.totalLLMCalls += 1
|
|
208
|
+
}
|
|
209
|
+
metrics.totalEvents += 1
|
|
210
|
+
break
|
|
211
|
+
|
|
212
|
+
case 'mailbox_message':
|
|
213
|
+
metrics.totalMessages = (metrics.totalMessages ?? 0) + 1
|
|
214
|
+
metrics.totalEvents += 1
|
|
215
|
+
break
|
|
216
|
+
|
|
217
|
+
case 'tool_started':
|
|
218
|
+
metrics.totalToolCalls = (metrics.totalToolCalls ?? 0) + 1
|
|
219
|
+
metrics.totalEvents += 1
|
|
220
|
+
break
|
|
221
|
+
|
|
222
|
+
default:
|
|
223
|
+
metrics.totalEvents += 1
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
update.metrics = metrics
|
|
228
|
+
await this.updateMetadata(sessionId, update)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Reject session-level hook events on closed sessions.
|
|
233
|
+
*
|
|
234
|
+
* Closed sessions must be prevented from re-running session-level plugin hooks
|
|
235
|
+
* (the `session_handler_*` events) because those hooks have no place operating
|
|
236
|
+
* on an immutable artifact — and when they do, every read / restart of the closed
|
|
237
|
+
* session appends two events, which is how we observed 7866 handler_started events
|
|
238
|
+
* on a single closed session over 4.9 days in production.
|
|
239
|
+
*
|
|
240
|
+
* Other event types are deliberately allowed even after session_closed:
|
|
241
|
+
* - in-flight agent events (inference_*, tool_*) finishing after close
|
|
242
|
+
* - mailbox_message deliveries racing close
|
|
243
|
+
* - service_status_changed from cleanup hooks stopping services
|
|
244
|
+
*
|
|
245
|
+
* The invariant we guard is narrow: "session-level plugin hooks never emit on
|
|
246
|
+
* closed sessions." See the loadSession / skipReadyHooks path in session-manager
|
|
247
|
+
* for the primary fix; this is the storage-boundary backup that catches any
|
|
248
|
+
* future code path that somehow slips through.
|
|
249
|
+
*/
|
|
250
|
+
protected async guardWriteToClosed(sessionId: SessionId, events: DomainEvent[]): Promise<void> {
|
|
251
|
+
const forbidden = events.filter(isForbiddenOnClosed)
|
|
252
|
+
if (forbidden.length === 0) return
|
|
253
|
+
|
|
254
|
+
const metadata = await this.readMetadata(sessionId)
|
|
255
|
+
if (metadata?.status !== 'closed') return
|
|
256
|
+
|
|
257
|
+
const forbiddenTypes = forbidden.map((e) => e.type).join(', ')
|
|
258
|
+
throw new EventStoreError(
|
|
259
|
+
`Refusing to append session-level hook event(s) to closed session ${sessionId} (types: ${forbiddenTypes}). `
|
|
260
|
+
+ `Closed sessions must not re-run plugin session hooks — see session-manager.ts:loadSession closed branch.`,
|
|
261
|
+
sessionId,
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { DomainEvent } from '~/core/events/types.js'
|
|
2
|
+
import type { ListSessionsOptions, SessionId, SessionMetadata } from '~/core/sessions/schema.js'
|
|
3
|
+
|
|
4
|
+
export type { ListSessionsOptions, SessionMetadata }
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options for loading a range of events.
|
|
8
|
+
*/
|
|
9
|
+
export interface LoadRangeOptions {
|
|
10
|
+
/** Skip events with index <= since (0-indexed). Default: -1 (load from start) */
|
|
11
|
+
since?: number
|
|
12
|
+
/** Max events to return. Default: no limit */
|
|
13
|
+
limit?: number
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Result of loading a range of events.
|
|
18
|
+
*/
|
|
19
|
+
export interface LoadRangeResult {
|
|
20
|
+
events: DomainEvent[]
|
|
21
|
+
/** Index of first returned event (-1 if no events returned) */
|
|
22
|
+
fromIndex: number
|
|
23
|
+
/** Index of last event in the store, used as cursor for polling (-1 only if store is empty) */
|
|
24
|
+
toIndex: number
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* EventStore interface pro persistenci domain events.
|
|
29
|
+
*
|
|
30
|
+
* Implementace:
|
|
31
|
+
* - FileEventStore - JSONL soubory (production)
|
|
32
|
+
* - MemoryEventStore - in-memory (testy)
|
|
33
|
+
*/
|
|
34
|
+
export interface EventStore {
|
|
35
|
+
/**
|
|
36
|
+
* Přidá jeden event do store.
|
|
37
|
+
*/
|
|
38
|
+
append(sessionId: SessionId, event: DomainEvent): Promise<void>
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Přidá více eventů atomicky.
|
|
42
|
+
* Všechny eventy musí být uloženy, nebo žádný.
|
|
43
|
+
*/
|
|
44
|
+
appendBatch(sessionId: SessionId, events: DomainEvent[]): Promise<void>
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Načte všechny eventy pro session.
|
|
48
|
+
* Eventy jsou vráceny v pořadí jak byly uloženy.
|
|
49
|
+
*/
|
|
50
|
+
load(sessionId: SessionId): Promise<DomainEvent[]>
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Zkontroluje zda session existuje.
|
|
54
|
+
*/
|
|
55
|
+
exists(sessionId: SessionId): Promise<boolean>
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Vrátí seznam všech session IDs.
|
|
59
|
+
* Použito při restartu pro načtení všech sessions.
|
|
60
|
+
*/
|
|
61
|
+
listSessions(): Promise<SessionId[]>
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Načte metadata session.
|
|
65
|
+
* Vrátí null pokud session neexistuje nebo nemá metadata.
|
|
66
|
+
*/
|
|
67
|
+
getMetadata(sessionId: SessionId): Promise<SessionMetadata | null>
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Aktualizuje metadata session.
|
|
71
|
+
* Merge s existujícími hodnotami.
|
|
72
|
+
*/
|
|
73
|
+
updateMetadata(
|
|
74
|
+
sessionId: SessionId,
|
|
75
|
+
update: Partial<SessionMetadata>,
|
|
76
|
+
): Promise<void>
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Vrátí seznam sessions s metadata.
|
|
80
|
+
* Podporuje filtrování, řazení a paginaci.
|
|
81
|
+
*/
|
|
82
|
+
listSessionsWithMetadata(
|
|
83
|
+
options?: ListSessionsOptions,
|
|
84
|
+
): Promise<{ sessions: SessionMetadata[]; total: number }>
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Načte rozsah eventů pro session.
|
|
88
|
+
* Optimalizováno pro polling - čte z konce souboru pokud je to efektivní.
|
|
89
|
+
*/
|
|
90
|
+
loadRange(
|
|
91
|
+
sessionId: SessionId,
|
|
92
|
+
options?: LoadRangeOptions,
|
|
93
|
+
): Promise<LoadRangeResult>
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Validates and reconciles metadata against actual events.
|
|
97
|
+
* If metadata is out of sync (e.g., after crash), recomputes it from events.
|
|
98
|
+
* Returns true if metadata was reconciled (was out of sync).
|
|
99
|
+
*/
|
|
100
|
+
reconcileMetadata(
|
|
101
|
+
sessionId: SessionId,
|
|
102
|
+
events: DomainEvent[],
|
|
103
|
+
): Promise<boolean>
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* EventStore s podporou pro streaming (optional rozšíření).
|
|
108
|
+
*/
|
|
109
|
+
export interface StreamingEventStore extends EventStore {
|
|
110
|
+
/**
|
|
111
|
+
* Streamuje eventy pro session.
|
|
112
|
+
* Užitečné pro velké sessions.
|
|
113
|
+
*/
|
|
114
|
+
stream(sessionId: SessionId): AsyncIterable<DomainEvent>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Error types pro EventStore
|
|
119
|
+
*/
|
|
120
|
+
export class EventStoreError extends Error {
|
|
121
|
+
constructor(
|
|
122
|
+
message: string,
|
|
123
|
+
public readonly sessionId: SessionId,
|
|
124
|
+
public readonly cause?: unknown,
|
|
125
|
+
) {
|
|
126
|
+
super(message)
|
|
127
|
+
this.name = 'EventStoreError'
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export class SessionNotFoundError extends EventStoreError {
|
|
132
|
+
constructor(sessionId: SessionId) {
|
|
133
|
+
super(`Session not found: ${sessionId}`, sessionId)
|
|
134
|
+
this.name = 'SessionNotFoundError'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export class EventAppendError extends EventStoreError {
|
|
139
|
+
constructor(sessionId: SessionId, cause?: unknown) {
|
|
140
|
+
super(`Failed to append event to session: ${sessionId}`, sessionId, cause)
|
|
141
|
+
this.name = 'EventAppendError'
|
|
142
|
+
}
|
|
143
|
+
}
|