@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,240 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
import type { DebounceContext } from '~/core/agents/debounce.js'
|
|
3
|
+
import {
|
|
4
|
+
aggressiveDebounceCallback,
|
|
5
|
+
batchingDebounceCallback,
|
|
6
|
+
defaultDebounceCallback,
|
|
7
|
+
waitForResponseDebounceCallback,
|
|
8
|
+
} from '~/core/agents/debounce.js'
|
|
9
|
+
import { MailboxMessage, MessageId } from '../../plugins/mailbox/schema'
|
|
10
|
+
import { PendingToolResult, ToolCallId } from '../tools/schema'
|
|
11
|
+
import { AgentId } from './schema'
|
|
12
|
+
|
|
13
|
+
describe('Debounce Callbacks', () => {
|
|
14
|
+
const createMessage = (timestampOffset = 0): MailboxMessage => ({
|
|
15
|
+
id: MessageId('msg-1'),
|
|
16
|
+
from: AgentId('agent-1'),
|
|
17
|
+
content: 'Test message',
|
|
18
|
+
timestamp: Date.now() - timestampOffset,
|
|
19
|
+
consumed: false,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
const createToolResult = (
|
|
23
|
+
toolName: string,
|
|
24
|
+
timestampOffset = 0,
|
|
25
|
+
isError = false,
|
|
26
|
+
): PendingToolResult => ({
|
|
27
|
+
toolCallId: ToolCallId('tc-1'),
|
|
28
|
+
toolName,
|
|
29
|
+
timestamp: Date.now() - timestampOffset,
|
|
30
|
+
isError,
|
|
31
|
+
content: '',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
const createContext = (
|
|
35
|
+
messageCount: number,
|
|
36
|
+
oldestWaitingMs: number,
|
|
37
|
+
pendingToolResults: PendingToolResult[] = [],
|
|
38
|
+
): DebounceContext => ({
|
|
39
|
+
messages: Array.from({ length: messageCount }, () => createMessage()),
|
|
40
|
+
oldestWaitingMs,
|
|
41
|
+
totalPending: messageCount,
|
|
42
|
+
pendingToolResults,
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
describe('defaultDebounceCallback', () => {
|
|
46
|
+
test("returns 'wait' when oldest message is less than 500ms old", () => {
|
|
47
|
+
const context = createContext(1, 400)
|
|
48
|
+
expect(defaultDebounceCallback(context)).toBe('wait')
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test("returns 'wait' when oldest message is exactly 500ms old", () => {
|
|
52
|
+
const context = createContext(1, 500)
|
|
53
|
+
expect(defaultDebounceCallback(context)).toBe('wait')
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test("returns 'process_now' when oldest message is more than 500ms old", () => {
|
|
57
|
+
const context = createContext(1, 501)
|
|
58
|
+
expect(defaultDebounceCallback(context)).toBe('process_now')
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
test("returns 'process_now' regardless of message count", () => {
|
|
62
|
+
const context = createContext(10, 600)
|
|
63
|
+
expect(defaultDebounceCallback(context)).toBe('process_now')
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe('aggressiveDebounceCallback', () => {
|
|
68
|
+
test("returns 'wait' when oldest message is less than 100ms old", () => {
|
|
69
|
+
const context = createContext(1, 50)
|
|
70
|
+
expect(aggressiveDebounceCallback(context)).toBe('wait')
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test("returns 'wait' when oldest message is exactly 100ms old", () => {
|
|
74
|
+
const context = createContext(1, 100)
|
|
75
|
+
expect(aggressiveDebounceCallback(context)).toBe('wait')
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
test("returns 'process_now' when oldest message is more than 100ms old", () => {
|
|
79
|
+
const context = createContext(1, 101)
|
|
80
|
+
expect(aggressiveDebounceCallback(context)).toBe('process_now')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
test('processes faster than default callback', () => {
|
|
84
|
+
const context = createContext(1, 150)
|
|
85
|
+
// Aggressive should process, default should wait
|
|
86
|
+
expect(aggressiveDebounceCallback(context)).toBe('process_now')
|
|
87
|
+
expect(defaultDebounceCallback(context)).toBe('wait')
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
describe('batchingDebounceCallback', () => {
|
|
92
|
+
test("returns 'wait' with few messages and short wait time", () => {
|
|
93
|
+
const context = createContext(2, 500)
|
|
94
|
+
expect(batchingDebounceCallback(context)).toBe('wait')
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
test("returns 'process_now' when 5 or more messages", () => {
|
|
98
|
+
const context = createContext(5, 100)
|
|
99
|
+
expect(batchingDebounceCallback(context)).toBe('process_now')
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test("returns 'process_now' when more than 5 messages", () => {
|
|
103
|
+
const context = createContext(10, 50)
|
|
104
|
+
expect(batchingDebounceCallback(context)).toBe('process_now')
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
test("returns 'wait' when oldest message is exactly 2000ms old with few messages", () => {
|
|
108
|
+
const context = createContext(2, 2000)
|
|
109
|
+
expect(batchingDebounceCallback(context)).toBe('wait')
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test("returns 'process_now' when oldest message is more than 2000ms old", () => {
|
|
113
|
+
const context = createContext(1, 2001)
|
|
114
|
+
expect(batchingDebounceCallback(context)).toBe('process_now')
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
test("returns 'process_now' at threshold of 5 messages", () => {
|
|
118
|
+
const context = createContext(5, 0)
|
|
119
|
+
expect(batchingDebounceCallback(context)).toBe('process_now')
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
test("returns 'wait' just below message threshold", () => {
|
|
123
|
+
const context = createContext(4, 1500)
|
|
124
|
+
expect(batchingDebounceCallback(context)).toBe('wait')
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
describe('waitForResponseDebounceCallback', () => {
|
|
129
|
+
test("returns 'process_now' when there are new mailbox messages", () => {
|
|
130
|
+
const context = createContext(1, 100, [
|
|
131
|
+
createToolResult('send_message', 1000),
|
|
132
|
+
])
|
|
133
|
+
expect(waitForResponseDebounceCallback(context)).toBe('process_now')
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
test("returns 'wait' when all pending tool results are communication tools", () => {
|
|
137
|
+
const context = createContext(0, 0, [
|
|
138
|
+
createToolResult('send_message', 1000),
|
|
139
|
+
])
|
|
140
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
test("returns 'wait' for start_* agent tool", () => {
|
|
144
|
+
const context = createContext(0, 0, [
|
|
145
|
+
createToolResult('start_researcher', 1000),
|
|
146
|
+
])
|
|
147
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test("returns 'wait' for tell_user tool", () => {
|
|
151
|
+
const context = createContext(0, 0, [
|
|
152
|
+
createToolResult('tell_user', 1000),
|
|
153
|
+
])
|
|
154
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
test("returns 'wait' for ask_user tool", () => {
|
|
158
|
+
const context = createContext(0, 0, [
|
|
159
|
+
createToolResult('ask_user', 1000),
|
|
160
|
+
])
|
|
161
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
test("returns 'wait' when multiple communication tools are pending", () => {
|
|
165
|
+
const context = createContext(0, 0, [
|
|
166
|
+
createToolResult('send_message', 1000),
|
|
167
|
+
createToolResult('start_helper', 500),
|
|
168
|
+
])
|
|
169
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
170
|
+
})
|
|
171
|
+
|
|
172
|
+
test("returns 'process_now' when ANY tool result is not a communication tool", () => {
|
|
173
|
+
const context = createContext(0, 0, [
|
|
174
|
+
createToolResult('send_message', 1000),
|
|
175
|
+
createToolResult('reveal_secret', 500), // Not a communication tool
|
|
176
|
+
])
|
|
177
|
+
expect(waitForResponseDebounceCallback(context)).toBe('process_now')
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
test("returns 'process_now' for non-communication tool alone", () => {
|
|
181
|
+
const context = createContext(0, 0, [
|
|
182
|
+
createToolResult('get_my_info', 1000),
|
|
183
|
+
])
|
|
184
|
+
expect(waitForResponseDebounceCallback(context)).toBe('process_now')
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
test("returns 'process_now' when any tool result has isError=true", () => {
|
|
188
|
+
const context = createContext(0, 0, [
|
|
189
|
+
createToolResult('send_message', 1000, true), // Error!
|
|
190
|
+
])
|
|
191
|
+
expect(waitForResponseDebounceCallback(context)).toBe('process_now')
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
test("returns 'process_now' when mixed success and error results", () => {
|
|
195
|
+
const context = createContext(0, 0, [
|
|
196
|
+
createToolResult('send_message', 2000, false), // Success
|
|
197
|
+
createToolResult('start_worker', 1000, true), // Error - should trigger immediate processing
|
|
198
|
+
])
|
|
199
|
+
expect(waitForResponseDebounceCallback(context)).toBe('process_now')
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
test("returns 'process_now' after 60s timeout for communication tools", () => {
|
|
203
|
+
const context = createContext(0, 0, [
|
|
204
|
+
createToolResult('send_message', 61000), // 61 seconds ago
|
|
205
|
+
])
|
|
206
|
+
expect(waitForResponseDebounceCallback(context)).toBe('process_now')
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
test("returns 'wait' just before 60s timeout", () => {
|
|
210
|
+
const context = createContext(0, 0, [
|
|
211
|
+
createToolResult('send_message', 59000), // 59 seconds ago
|
|
212
|
+
])
|
|
213
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
test("returns 'wait' when no messages and no tool results", () => {
|
|
217
|
+
const context = createContext(0, 0, [])
|
|
218
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
test('uses oldest tool result timestamp for timeout calculation', () => {
|
|
222
|
+
// One tool result at 59s, one at 30s - should use 59s (oldest)
|
|
223
|
+
const now = Date.now()
|
|
224
|
+
const context: DebounceContext = {
|
|
225
|
+
messages: [],
|
|
226
|
+
oldestWaitingMs: 0,
|
|
227
|
+
totalPending: 0,
|
|
228
|
+
pendingToolResults: [
|
|
229
|
+
{ toolCallId: ToolCallId('tc-1'), toolName: 'send_message', timestamp: now - 59000, isError: false, content: '' },
|
|
230
|
+
{ toolCallId: ToolCallId('tc-2'), toolName: 'send_message', timestamp: now - 30000, isError: false, content: '' },
|
|
231
|
+
],
|
|
232
|
+
}
|
|
233
|
+
expect(waitForResponseDebounceCallback(context)).toBe('wait')
|
|
234
|
+
|
|
235
|
+
// Now make oldest one 61s old
|
|
236
|
+
context.pendingToolResults[0].timestamp = now - 61000
|
|
237
|
+
expect(waitForResponseDebounceCallback(context)).toBe('process_now')
|
|
238
|
+
})
|
|
239
|
+
})
|
|
240
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent role constants.
|
|
3
|
+
*
|
|
4
|
+
* These constants define the special agent roles in the system:
|
|
5
|
+
* - ORCHESTRATOR: The main agent that coordinates work and spawns sub-agents
|
|
6
|
+
* - COMMUNICATOR: Optional agent that handles user communication in communication-agent mode
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** Orchestrator agent role - the main coordinating agent */
|
|
10
|
+
export const ORCHESTRATOR_ROLE = 'orchestrator' as const
|
|
11
|
+
|
|
12
|
+
/** Communicator agent role - handles user communication */
|
|
13
|
+
export const COMMUNICATOR_ROLE = 'communicator' as const
|
|
14
|
+
|
|
15
|
+
/** Type for special agent roles */
|
|
16
|
+
export type AgentRole = typeof ORCHESTRATOR_ROLE | typeof COMMUNICATOR_ROLE
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Prompt-level role classification for system prompt composition.
|
|
20
|
+
* - 'entry': Orchestrator without communicator (talks to user directly)
|
|
21
|
+
* - 'orchestrator': Orchestrator with communicator (talks to communicator, not user)
|
|
22
|
+
* - 'child': Spawned by parent, reports results back
|
|
23
|
+
* - 'communicator': Handles user communication, relays to orchestrator
|
|
24
|
+
*/
|
|
25
|
+
export type PromptRole = 'entry' | 'orchestrator' | 'child' | 'communicator'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Determine an agent's prompt role from its state and session context.
|
|
29
|
+
*/
|
|
30
|
+
export function getAgentRole(
|
|
31
|
+
agentState: { definitionName: string; parentId: string | null },
|
|
32
|
+
sessionState: { agents: Map<string, { definitionName: string }> },
|
|
33
|
+
): PromptRole {
|
|
34
|
+
if (agentState.definitionName === COMMUNICATOR_ROLE) return 'communicator'
|
|
35
|
+
const hasCommunicator = Array.from(sessionState.agents.values())
|
|
36
|
+
.some(a => a.definitionName === COMMUNICATOR_ROLE)
|
|
37
|
+
if (agentState.definitionName === ORCHESTRATOR_ROLE) {
|
|
38
|
+
return hasCommunicator ? 'orchestrator' : 'entry'
|
|
39
|
+
}
|
|
40
|
+
return 'child'
|
|
41
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for Agent shutdown behavior - verifying that session close
|
|
3
|
+
* prevents re-scheduling and aborts in-flight work.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, it } from 'bun:test'
|
|
7
|
+
import { AgentId } from '~/core/agents/schema.js'
|
|
8
|
+
import { agentEvents } from '~/core/agents/state.js'
|
|
9
|
+
import { MemoryEventStore } from '~/core/events'
|
|
10
|
+
import { withSessionId } from '~/core/events/test-helpers.js'
|
|
11
|
+
import { MockLLMProvider } from '~/core/llm/index.js'
|
|
12
|
+
import type { InferenceResponse } from '~/core/llm/provider.js'
|
|
13
|
+
import { ModelId } from '~/core/llm/schema.js'
|
|
14
|
+
import { createApplyEvent } from '~/core/sessions/apply-event.js'
|
|
15
|
+
import type { SessionContext } from '~/core/sessions/context.js'
|
|
16
|
+
import { SessionId } from '~/core/sessions/schema.js'
|
|
17
|
+
import { sessionEvents } from '~/core/sessions/state.js'
|
|
18
|
+
import { ToolCallId } from '~/core/tools/schema.js'
|
|
19
|
+
import { mailboxPlugin } from '~/plugins/mailbox/plugin.js'
|
|
20
|
+
import { generateTestMessageId } from '~/plugins/mailbox/schema.js'
|
|
21
|
+
import { mailboxEvents } from '~/plugins/mailbox/state.js'
|
|
22
|
+
import { createNodePlatform } from '~/testing/node-platform.js'
|
|
23
|
+
import { ConsoleLogger } from '../../lib/logger/console.js'
|
|
24
|
+
import { SessionFileStore } from '../file-store/file-store.js'
|
|
25
|
+
import { SessionStore } from '../sessions/session-store.js'
|
|
26
|
+
import { ToolExecutor } from '../tools/executor.js'
|
|
27
|
+
import { Agent, type AgentConfig, type AgentDependencies } from './agent.js'
|
|
28
|
+
|
|
29
|
+
// ============================================================================
|
|
30
|
+
// Test Helpers
|
|
31
|
+
// ============================================================================
|
|
32
|
+
|
|
33
|
+
const TEST_SESSION_ID = SessionId('test-session')
|
|
34
|
+
const TEST_AGENT_ID = AgentId('test-agent-1')
|
|
35
|
+
|
|
36
|
+
function createLogger() {
|
|
37
|
+
return new ConsoleLogger({ level: 'error' })
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function createTestAgent(
|
|
41
|
+
config: Partial<AgentConfig> = {},
|
|
42
|
+
llmResponse?: Partial<InferenceResponse>,
|
|
43
|
+
): Promise<{ agent: Agent; store: SessionStore; eventStore: MemoryEventStore; llmProvider: MockLLMProvider }> {
|
|
44
|
+
const eventStore = new MemoryEventStore()
|
|
45
|
+
const logger = createLogger()
|
|
46
|
+
|
|
47
|
+
// Create session
|
|
48
|
+
const sessionCreatedEvent = withSessionId(TEST_SESSION_ID, sessionEvents.create('session_created', { presetId: 'test-preset' }))
|
|
49
|
+
await eventStore.append(TEST_SESSION_ID, sessionCreatedEvent)
|
|
50
|
+
|
|
51
|
+
// Spawn agent
|
|
52
|
+
const agentSpawnedEvent = withSessionId(
|
|
53
|
+
TEST_SESSION_ID,
|
|
54
|
+
agentEvents.create('agent_spawned', {
|
|
55
|
+
agentId: TEST_AGENT_ID,
|
|
56
|
+
definitionName: 'test-agent',
|
|
57
|
+
parentId: null,
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
60
|
+
await eventStore.append(TEST_SESSION_ID, agentSpawnedEvent)
|
|
61
|
+
|
|
62
|
+
const composedReducer = createApplyEvent([mailboxPlugin.create({})])
|
|
63
|
+
const store = await SessionStore.load(TEST_SESSION_ID, eventStore, composedReducer)
|
|
64
|
+
if (!store) {
|
|
65
|
+
throw new Error('Failed to create SessionStore')
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const defaultConfig: AgentConfig = {
|
|
69
|
+
systemPrompt: 'Test system prompt',
|
|
70
|
+
tools: [],
|
|
71
|
+
model: ModelId('test-model'),
|
|
72
|
+
spawnableAgents: [],
|
|
73
|
+
debounceMs: 0,
|
|
74
|
+
...config,
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const llmProvider = MockLLMProvider.withFixedResponse({
|
|
78
|
+
content: llmResponse?.content ?? 'Test response',
|
|
79
|
+
toolCalls: llmResponse?.toolCalls ?? [],
|
|
80
|
+
finishReason: llmResponse?.finishReason ?? 'stop',
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const fileStore = new SessionFileStore('/tmp/test', undefined, false, createNodePlatform().fs)
|
|
84
|
+
|
|
85
|
+
const sessionContext: SessionContext = {
|
|
86
|
+
sessionId: TEST_SESSION_ID,
|
|
87
|
+
sessionState: store.getState(),
|
|
88
|
+
sessionInput: undefined,
|
|
89
|
+
environment: { sessionDir: '/tmp/test', sandboxed: false },
|
|
90
|
+
llm: llmProvider,
|
|
91
|
+
files: fileStore,
|
|
92
|
+
eventStore,
|
|
93
|
+
platform: createNodePlatform(),
|
|
94
|
+
logger,
|
|
95
|
+
emitEvent: async (event) => {
|
|
96
|
+
await store.emit(withSessionId(TEST_SESSION_ID, event))
|
|
97
|
+
},
|
|
98
|
+
notify: () => {},
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const deps: AgentDependencies = {
|
|
102
|
+
id: TEST_AGENT_ID,
|
|
103
|
+
sessionContext,
|
|
104
|
+
store,
|
|
105
|
+
llmProvider,
|
|
106
|
+
toolExecutor: new ToolExecutor(logger),
|
|
107
|
+
logger,
|
|
108
|
+
config: defaultConfig,
|
|
109
|
+
plugins: [mailboxPlugin.create({})],
|
|
110
|
+
environment: { sessionDir: '/tmp/test', sandboxed: false },
|
|
111
|
+
fileStore,
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const agent = new Agent(deps)
|
|
115
|
+
return { agent, store, eventStore, llmProvider }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function addMailboxMessage(store: SessionStore, content: string) {
|
|
119
|
+
await store.emit(withSessionId(
|
|
120
|
+
TEST_SESSION_ID,
|
|
121
|
+
mailboxEvents.create('mailbox_message', {
|
|
122
|
+
toAgentId: TEST_AGENT_ID,
|
|
123
|
+
message: {
|
|
124
|
+
id: generateTestMessageId(),
|
|
125
|
+
from: 'user',
|
|
126
|
+
content,
|
|
127
|
+
timestamp: Date.now(),
|
|
128
|
+
consumed: false,
|
|
129
|
+
},
|
|
130
|
+
}),
|
|
131
|
+
))
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function closeSession(store: SessionStore) {
|
|
135
|
+
await store.emit(withSessionId(TEST_SESSION_ID, sessionEvents.create('session_closed', {})))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Wait for any scheduled timers to fire.
|
|
140
|
+
*/
|
|
141
|
+
async function flushTimers() {
|
|
142
|
+
await new Promise<void>((resolve) => setTimeout(resolve, 10))
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ============================================================================
|
|
146
|
+
// Tests
|
|
147
|
+
// ============================================================================
|
|
148
|
+
|
|
149
|
+
describe('Agent Shutdown', () => {
|
|
150
|
+
it('continue() is no-op when session is closed', async () => {
|
|
151
|
+
const { agent, store, llmProvider, eventStore } = await createTestAgent()
|
|
152
|
+
|
|
153
|
+
await addMailboxMessage(store, 'Hello')
|
|
154
|
+
await closeSession(store)
|
|
155
|
+
|
|
156
|
+
await agent.continue()
|
|
157
|
+
|
|
158
|
+
expect(llmProvider.getCallCount()).toBe(0)
|
|
159
|
+
|
|
160
|
+
const events = await eventStore.load(TEST_SESSION_ID)
|
|
161
|
+
const inferenceStarted = events.filter(e => e.type === 'inference_started')
|
|
162
|
+
expect(inferenceStarted).toHaveLength(0)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
it('agent does not continue after session closes', async () => {
|
|
166
|
+
const { agent, store, llmProvider } = await createTestAgent()
|
|
167
|
+
|
|
168
|
+
await addMailboxMessage(store, 'Hello')
|
|
169
|
+
// While loop runs full cycle: onStart → inference → onComplete
|
|
170
|
+
await agent.continue()
|
|
171
|
+
expect(llmProvider.getCallCount()).toBe(1)
|
|
172
|
+
|
|
173
|
+
// Close session
|
|
174
|
+
await closeSession(store)
|
|
175
|
+
|
|
176
|
+
// Add another message that would trigger work if continue() ran
|
|
177
|
+
await addMailboxMessage(store, 'Another message')
|
|
178
|
+
|
|
179
|
+
// Let any scheduled timers fire
|
|
180
|
+
await flushTimers()
|
|
181
|
+
|
|
182
|
+
// No additional inference should have occurred — isClosed() guard blocks re-entry
|
|
183
|
+
expect(llmProvider.getCallCount()).toBe(1)
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
it('agent does not run additional inference after session is closed', async () => {
|
|
187
|
+
const { agent, store, llmProvider } = await createTestAgent(
|
|
188
|
+
{},
|
|
189
|
+
{ toolCalls: [{ id: ToolCallId('tc-1'), name: 'test_tool', input: {} }] },
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
await addMailboxMessage(store, 'Hello')
|
|
193
|
+
// While loop runs full cycle: inference → tool_exec → scheduleProcessing
|
|
194
|
+
await agent.continue()
|
|
195
|
+
expect(llmProvider.getCallCount()).toBe(1)
|
|
196
|
+
|
|
197
|
+
// Close session — any scheduled timer will find isClosed() and stop
|
|
198
|
+
await closeSession(store)
|
|
199
|
+
|
|
200
|
+
// Calling continue() again is a no-op when session is closed
|
|
201
|
+
await agent.continue()
|
|
202
|
+
|
|
203
|
+
// No additional inference should have occurred
|
|
204
|
+
expect(llmProvider.getCallCount()).toBe(1)
|
|
205
|
+
})
|
|
206
|
+
|
|
207
|
+
it('scheduleProcessing() is no-op when session is closed', async () => {
|
|
208
|
+
const { agent, store } = await createTestAgent()
|
|
209
|
+
|
|
210
|
+
await addMailboxMessage(store, 'Hello')
|
|
211
|
+
await closeSession(store)
|
|
212
|
+
|
|
213
|
+
agent.scheduleProcessing()
|
|
214
|
+
|
|
215
|
+
expect(agent.isScheduled()).toBe(false)
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
it('shutdown() stops scheduled processing', async () => {
|
|
219
|
+
const { agent, store, llmProvider } = await createTestAgent({
|
|
220
|
+
debounceMs: 100,
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
await addMailboxMessage(store, 'Hello')
|
|
224
|
+
agent.scheduleProcessing()
|
|
225
|
+
expect(agent.isScheduled()).toBe(true)
|
|
226
|
+
|
|
227
|
+
agent.shutdown()
|
|
228
|
+
expect(agent.isScheduled()).toBe(false)
|
|
229
|
+
|
|
230
|
+
// Wait longer than the debounce time
|
|
231
|
+
await new Promise<void>((resolve) => setTimeout(resolve, 150))
|
|
232
|
+
|
|
233
|
+
// LLM should never have been called
|
|
234
|
+
expect(llmProvider.getCallCount()).toBe(0)
|
|
235
|
+
})
|
|
236
|
+
})
|