@roj-ai/sdk 0.1.3 → 0.1.4
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.js +191 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/builtin-events.js +8 -0
- package/dist/builtin-events.js.map +1 -0
- package/dist/bun-platform/fs.js +39 -0
- package/dist/bun-platform/fs.js.map +1 -0
- package/dist/bun-platform/index.js +18 -0
- package/dist/bun-platform/index.js.map +1 -0
- package/dist/bun-platform/process.js +21 -0
- package/dist/bun-platform/process.js.map +1 -0
- package/dist/config.js +54 -0
- package/dist/config.js.map +1 -0
- package/dist/config.test.js +155 -0
- package/dist/config.test.js.map +1 -0
- package/dist/core/agent-loop.integration.test.js +414 -0
- package/dist/core/agent-loop.integration.test.js.map +1 -0
- package/dist/core/agents/agent-config.test.js +194 -0
- package/dist/core/agents/agent-config.test.js.map +1 -0
- package/dist/core/agents/agent-roles.js +25 -0
- package/dist/core/agents/agent-roles.js.map +1 -0
- package/dist/core/agents/agent-shutdown.test.js +180 -0
- package/dist/core/agents/agent-shutdown.test.js.map +1 -0
- package/dist/core/agents/agent.js +1205 -0
- package/dist/core/agents/agent.js.map +1 -0
- package/dist/core/agents/agent.test.js +313 -0
- package/dist/core/agents/agent.test.js.map +1 -0
- package/dist/core/agents/communicator.js +13 -0
- package/dist/core/agents/communicator.js.map +1 -0
- package/dist/core/agents/config.js +5 -0
- package/dist/core/agents/config.js.map +1 -0
- package/dist/core/agents/context.js +2 -0
- package/dist/core/agents/context.js.map +1 -0
- package/dist/core/agents/debounce.js +74 -0
- package/dist/core/agents/debounce.js.map +1 -0
- package/dist/core/agents/handler-events.test.js +115 -0
- package/dist/core/agents/handler-events.test.js.map +1 -0
- package/dist/core/agents/index.js +2 -0
- package/dist/core/agents/index.js.map +1 -0
- package/dist/core/agents/response-sanitizer.js +46 -0
- package/dist/core/agents/response-sanitizer.js.map +1 -0
- package/dist/core/agents/response-sanitizer.test.js +101 -0
- package/dist/core/agents/response-sanitizer.test.js.map +1 -0
- package/dist/core/agents/retry.js +105 -0
- package/dist/core/agents/retry.js.map +1 -0
- package/dist/core/agents/schema.js +39 -0
- package/dist/core/agents/schema.js.map +1 -0
- package/dist/core/agents/state.js +90 -0
- package/dist/core/agents/state.js.map +1 -0
- package/dist/core/context/state.js +23 -0
- package/dist/core/context/state.js.map +1 -0
- package/dist/core/errors.js +38 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/event-sourcing.integration.test.js +154 -0
- package/dist/core/event-sourcing.integration.test.js.map +1 -0
- package/dist/core/events/base-event-store.js +201 -0
- package/dist/core/events/base-event-store.js.map +1 -0
- package/dist/core/events/event-store.js +26 -0
- package/dist/core/events/event-store.js.map +1 -0
- package/dist/core/events/file.js +320 -0
- package/dist/core/events/file.js.map +1 -0
- package/dist/core/events/file.test.js +284 -0
- package/dist/core/events/file.test.js.map +1 -0
- package/dist/core/events/index.js +3 -0
- package/dist/core/events/index.js.map +1 -0
- package/dist/core/events/memory.js +101 -0
- package/dist/core/events/memory.js.map +1 -0
- package/dist/core/events/memory.test.js +502 -0
- package/dist/core/events/memory.test.js.map +1 -0
- package/dist/core/events/metadata-utils.js +107 -0
- package/dist/core/events/metadata-utils.js.map +1 -0
- package/dist/core/events/test-helpers.js +15 -0
- package/dist/core/events/test-helpers.js.map +1 -0
- package/dist/core/events/types.js +21 -0
- package/dist/core/events/types.js.map +1 -0
- package/dist/core/file-store/file-store.js +250 -0
- package/dist/core/file-store/file-store.js.map +1 -0
- package/dist/core/file-store/types.js +7 -0
- package/dist/core/file-store/types.js.map +1 -0
- package/dist/core/image/image-processor.js +106 -0
- package/dist/core/image/image-processor.js.map +1 -0
- package/dist/core/image/image-processor.test.js +171 -0
- package/dist/core/image/image-processor.test.js.map +1 -0
- package/dist/core/image/index.js +4 -0
- package/dist/core/image/index.js.map +1 -0
- package/dist/core/image/noop-resizer.js +6 -0
- package/dist/core/image/noop-resizer.js.map +1 -0
- package/dist/core/image/types.js +2 -0
- package/dist/core/image/types.js.map +1 -0
- package/dist/core/image/vips-resizer.js +100 -0
- package/dist/core/image/vips-resizer.js.map +1 -0
- package/dist/core/image/vips-resizer.test.js +324 -0
- package/dist/core/image/vips-resizer.test.js.map +1 -0
- package/dist/core/llm/anthropic.js +396 -0
- package/dist/core/llm/anthropic.js.map +1 -0
- package/dist/core/llm/anthropic.test.js +434 -0
- package/dist/core/llm/anthropic.test.js.map +1 -0
- package/dist/core/llm/cache-breakpoints.js +37 -0
- package/dist/core/llm/cache-breakpoints.js.map +1 -0
- package/dist/core/llm/cache-live.test.js +137 -0
- package/dist/core/llm/cache-live.test.js.map +1 -0
- package/dist/core/llm/index.js +9 -0
- package/dist/core/llm/index.js.map +1 -0
- package/dist/core/llm/llm-log-types.js +12 -0
- package/dist/core/llm/llm-log-types.js.map +1 -0
- package/dist/core/llm/logger.js +241 -0
- package/dist/core/llm/logger.js.map +1 -0
- package/dist/core/llm/logger.test.js +228 -0
- package/dist/core/llm/logger.test.js.map +1 -0
- package/dist/core/llm/logging-provider.js +49 -0
- package/dist/core/llm/logging-provider.js.map +1 -0
- package/dist/core/llm/middleware.js +114 -0
- package/dist/core/llm/middleware.js.map +1 -0
- package/dist/core/llm/mock.js +186 -0
- package/dist/core/llm/mock.js.map +1 -0
- package/dist/core/llm/mock.test.js +318 -0
- package/dist/core/llm/mock.test.js.map +1 -0
- package/dist/core/llm/openrouter-mapping.test.js +125 -0
- package/dist/core/llm/openrouter-mapping.test.js.map +1 -0
- package/dist/core/llm/openrouter.js +298 -0
- package/dist/core/llm/openrouter.js.map +1 -0
- package/dist/core/llm/openrouter.test.js +377 -0
- package/dist/core/llm/openrouter.test.js.map +1 -0
- package/dist/core/llm/provider-integration.test.js +350 -0
- package/dist/core/llm/provider-integration.test.js.map +1 -0
- package/dist/core/llm/provider.js +18 -0
- package/dist/core/llm/provider.js.map +1 -0
- package/dist/core/llm/routing-provider.js +52 -0
- package/dist/core/llm/routing-provider.js.map +1 -0
- package/dist/core/llm/routing-provider.test.js +94 -0
- package/dist/core/llm/routing-provider.test.js.map +1 -0
- package/dist/core/llm/schema.js +31 -0
- package/dist/core/llm/schema.js.map +1 -0
- package/dist/core/llm/snapshot-fetch.js +122 -0
- package/dist/core/llm/snapshot-fetch.js.map +1 -0
- package/dist/core/llm/snapshot-middleware.js +142 -0
- package/dist/core/llm/snapshot-middleware.js.map +1 -0
- package/dist/core/llm/snapshot-middleware.test.js +144 -0
- package/dist/core/llm/snapshot-middleware.test.js.map +1 -0
- package/dist/core/llm/state.js +48 -0
- package/dist/core/llm/state.js.map +1 -0
- package/dist/core/llm/tokens.js +40 -0
- package/dist/core/llm/tokens.js.map +1 -0
- package/dist/core/multi-agent.integration.test.js +298 -0
- package/dist/core/multi-agent.integration.test.js.map +1 -0
- package/dist/core/plugin-hooks.integration.test.js +344 -0
- package/dist/core/plugin-hooks.integration.test.js.map +1 -0
- package/dist/core/plugins/hook-types.js +5 -0
- package/dist/core/plugins/hook-types.js.map +1 -0
- package/dist/core/plugins/index.js +5 -0
- package/dist/core/plugins/index.js.map +1 -0
- package/dist/core/plugins/plugin-builder.js +321 -0
- package/dist/core/plugins/plugin-builder.js.map +1 -0
- package/dist/core/preset/config.js +54 -0
- package/dist/core/preset/config.js.map +1 -0
- package/dist/core/preset/index.js +6 -0
- package/dist/core/preset/index.js.map +1 -0
- package/dist/core/preset/preset-builder.js +63 -0
- package/dist/core/preset/preset-builder.js.map +1 -0
- package/dist/core/session-lifecycle.integration.test.js +159 -0
- package/dist/core/session-lifecycle.integration.test.js.map +1 -0
- package/dist/core/sessions/apply-event.js +41 -0
- package/dist/core/sessions/apply-event.js.map +1 -0
- package/dist/core/sessions/context.js +2 -0
- package/dist/core/sessions/context.js.map +1 -0
- package/dist/core/sessions/fork-utils.js +42 -0
- package/dist/core/sessions/fork-utils.js.map +1 -0
- package/dist/core/sessions/fork-utils.test.js +129 -0
- package/dist/core/sessions/fork-utils.test.js.map +1 -0
- package/dist/core/sessions/reducer.js +55 -0
- package/dist/core/sessions/reducer.js.map +1 -0
- package/dist/core/sessions/schema.js +66 -0
- package/dist/core/sessions/schema.js.map +1 -0
- package/dist/core/sessions/session-environment.js +2 -0
- package/dist/core/sessions/session-environment.js.map +1 -0
- package/dist/core/sessions/session-manager.js +650 -0
- package/dist/core/sessions/session-manager.js.map +1 -0
- package/dist/core/sessions/session-store.js +118 -0
- package/dist/core/sessions/session-store.js.map +1 -0
- package/dist/core/sessions/session.js +675 -0
- package/dist/core/sessions/session.js.map +1 -0
- package/dist/core/sessions/session.test.js +1095 -0
- package/dist/core/sessions/session.test.js.map +1 -0
- package/dist/core/sessions/state.js +377 -0
- package/dist/core/sessions/state.js.map +1 -0
- package/dist/core/system.js +66 -0
- package/dist/core/system.js.map +1 -0
- package/dist/core/tools/context.js +2 -0
- package/dist/core/tools/context.js.map +1 -0
- package/dist/core/tools/definition.js +4 -0
- package/dist/core/tools/definition.js.map +1 -0
- package/dist/core/tools/executor.js +82 -0
- package/dist/core/tools/executor.js.map +1 -0
- package/dist/core/tools/executor.test.js +143 -0
- package/dist/core/tools/executor.test.js.map +1 -0
- package/dist/core/tools/index.js +4 -0
- package/dist/core/tools/index.js.map +1 -0
- package/dist/core/tools/schema.js +20 -0
- package/dist/core/tools/schema.js.map +1 -0
- package/dist/core/tools/state.js +29 -0
- package/dist/core/tools/state.js.map +1 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/json/index.js +5 -0
- package/dist/lib/json/index.js.map +1 -0
- package/dist/lib/logger/console.js +147 -0
- package/dist/lib/logger/console.js.map +1 -0
- package/dist/lib/logger/console.test.js +258 -0
- package/dist/lib/logger/console.test.js.map +1 -0
- package/dist/lib/logger/file.js +54 -0
- package/dist/lib/logger/file.js.map +1 -0
- package/dist/lib/logger/index.js +4 -0
- package/dist/lib/logger/index.js.map +1 -0
- package/dist/lib/logger/logger.js +28 -0
- package/dist/lib/logger/logger.js.map +1 -0
- package/dist/lib/logger/ring-buffer.js +61 -0
- package/dist/lib/logger/ring-buffer.js.map +1 -0
- package/dist/lib/logger/tee.js +43 -0
- package/dist/lib/logger/tee.js.map +1 -0
- package/dist/lib/mime.js +22 -0
- package/dist/lib/mime.js.map +1 -0
- package/dist/lib/never.js +4 -0
- package/dist/lib/never.js.map +1 -0
- package/dist/lib/utils/hash.js +35 -0
- package/dist/lib/utils/hash.js.map +1 -0
- package/dist/lib/utils/result.js +21 -0
- package/dist/lib/utils/result.js.map +1 -0
- package/dist/platform/fs.js +8 -0
- package/dist/platform/fs.js.map +1 -0
- package/dist/platform/index.js +9 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/process.js +8 -0
- package/dist/platform/process.js.map +1 -0
- package/dist/plugins/agent-status/plugin.js +77 -0
- package/dist/plugins/agent-status/plugin.js.map +1 -0
- package/dist/plugins/agents/agents.integration.test.js +683 -0
- package/dist/plugins/agents/agents.integration.test.js.map +1 -0
- package/dist/plugins/agents/index.js +2 -0
- package/dist/plugins/agents/index.js.map +1 -0
- package/dist/plugins/agents/plugin.js +199 -0
- package/dist/plugins/agents/plugin.js.map +1 -0
- package/dist/plugins/context-compact/context-compact.integration.test.js +174 -0
- package/dist/plugins/context-compact/context-compact.integration.test.js.map +1 -0
- package/dist/plugins/context-compact/context-compactor.js +238 -0
- package/dist/plugins/context-compact/context-compactor.js.map +1 -0
- package/dist/plugins/context-compact/context-compactor.test.js +763 -0
- package/dist/plugins/context-compact/context-compactor.test.js.map +1 -0
- package/dist/plugins/context-compact/history-offloader.js +42 -0
- package/dist/plugins/context-compact/history-offloader.js.map +1 -0
- package/dist/plugins/context-compact/history-offloader.test.js +77 -0
- package/dist/plugins/context-compact/history-offloader.test.js.map +1 -0
- package/dist/plugins/context-compact/index.js +4 -0
- package/dist/plugins/context-compact/index.js.map +1 -0
- package/dist/plugins/context-compact/plugin.js +37 -0
- package/dist/plugins/context-compact/plugin.js.map +1 -0
- package/dist/plugins/filesystem/filesystem.integration.test.js +411 -0
- package/dist/plugins/filesystem/filesystem.integration.test.js.map +1 -0
- package/dist/plugins/filesystem/helpers.js +170 -0
- package/dist/plugins/filesystem/helpers.js.map +1 -0
- package/dist/plugins/filesystem/index.js +3 -0
- package/dist/plugins/filesystem/index.js.map +1 -0
- package/dist/plugins/filesystem/listing.js +247 -0
- package/dist/plugins/filesystem/listing.js.map +1 -0
- package/dist/plugins/filesystem/plugin.js +364 -0
- package/dist/plugins/filesystem/plugin.js.map +1 -0
- package/dist/plugins/filesystem/schema.js +2 -0
- package/dist/plugins/filesystem/schema.js.map +1 -0
- package/dist/plugins/git-status/index.js +2 -0
- package/dist/plugins/git-status/index.js.map +1 -0
- package/dist/plugins/git-status/plugin.js +144 -0
- package/dist/plugins/git-status/plugin.js.map +1 -0
- package/dist/plugins/limits-guard/config.js +5 -0
- package/dist/plugins/limits-guard/config.js.map +1 -0
- package/dist/plugins/limits-guard/index.js +3 -0
- package/dist/plugins/limits-guard/index.js.map +1 -0
- package/dist/plugins/limits-guard/limit-guard.js +125 -0
- package/dist/plugins/limits-guard/limit-guard.js.map +1 -0
- package/dist/plugins/limits-guard/limit-guard.test.js +121 -0
- package/dist/plugins/limits-guard/limit-guard.test.js.map +1 -0
- package/dist/plugins/limits-guard/limits-guard.integration.test.js +378 -0
- package/dist/plugins/limits-guard/limits-guard.integration.test.js.map +1 -0
- package/dist/plugins/limits-guard/plugin.js +240 -0
- package/dist/plugins/limits-guard/plugin.js.map +1 -0
- package/dist/plugins/llm-debug/index.js +2 -0
- package/dist/plugins/llm-debug/index.js.map +1 -0
- package/dist/plugins/llm-debug/llm-debug.integration.test.js +157 -0
- package/dist/plugins/llm-debug/llm-debug.integration.test.js.map +1 -0
- package/dist/plugins/llm-debug/plugin.js +148 -0
- package/dist/plugins/llm-debug/plugin.js.map +1 -0
- package/dist/plugins/logs/index.js +2 -0
- package/dist/plugins/logs/index.js.map +1 -0
- package/dist/plugins/logs/plugin.js +38 -0
- package/dist/plugins/logs/plugin.js.map +1 -0
- package/dist/plugins/mailbox/helpers.js +66 -0
- package/dist/plugins/mailbox/helpers.js.map +1 -0
- package/dist/plugins/mailbox/index.js +9 -0
- package/dist/plugins/mailbox/index.js.map +1 -0
- package/dist/plugins/mailbox/mailbox.integration.test.js +605 -0
- package/dist/plugins/mailbox/mailbox.integration.test.js.map +1 -0
- package/dist/plugins/mailbox/plugin.js +204 -0
- package/dist/plugins/mailbox/plugin.js.map +1 -0
- package/dist/plugins/mailbox/prompts.js +93 -0
- package/dist/plugins/mailbox/prompts.js.map +1 -0
- package/dist/plugins/mailbox/query.js +38 -0
- package/dist/plugins/mailbox/query.js.map +1 -0
- package/dist/plugins/mailbox/schema.js +32 -0
- package/dist/plugins/mailbox/schema.js.map +1 -0
- package/dist/plugins/mailbox/state.js +41 -0
- package/dist/plugins/mailbox/state.js.map +1 -0
- package/dist/plugins/resources/index.js +4 -0
- package/dist/plugins/resources/index.js.map +1 -0
- package/dist/plugins/resources/manifest.js +20 -0
- package/dist/plugins/resources/manifest.js.map +1 -0
- package/dist/plugins/resources/plugin.js +171 -0
- package/dist/plugins/resources/plugin.js.map +1 -0
- package/dist/plugins/resources/post-inject.js +32 -0
- package/dist/plugins/resources/post-inject.js.map +1 -0
- package/dist/plugins/resources/state.js +16 -0
- package/dist/plugins/resources/state.js.map +1 -0
- package/dist/plugins/result-eviction/index.js +2 -0
- package/dist/plugins/result-eviction/index.js.map +1 -0
- package/dist/plugins/result-eviction/plugin.js +43 -0
- package/dist/plugins/result-eviction/plugin.js.map +1 -0
- package/dist/plugins/result-eviction/result-eviction.integration.test.js +217 -0
- package/dist/plugins/result-eviction/result-eviction.integration.test.js.map +1 -0
- package/dist/plugins/services/plugin.js +453 -0
- package/dist/plugins/services/plugin.js.map +1 -0
- package/dist/plugins/services/port-pool.js +70 -0
- package/dist/plugins/services/port-pool.js.map +1 -0
- package/dist/plugins/services/prompt.js +40 -0
- package/dist/plugins/services/prompt.js.map +1 -0
- package/dist/plugins/services/schema.js +9 -0
- package/dist/plugins/services/schema.js.map +1 -0
- package/dist/plugins/services/service.js +470 -0
- package/dist/plugins/services/service.js.map +1 -0
- package/dist/plugins/services/services.integration.test.js +485 -0
- package/dist/plugins/services/services.integration.test.js.map +1 -0
- package/dist/plugins/session-lifecycle/index.js +2 -0
- package/dist/plugins/session-lifecycle/index.js.map +1 -0
- package/dist/plugins/session-lifecycle/plugin.js +273 -0
- package/dist/plugins/session-lifecycle/plugin.js.map +1 -0
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.js +498 -0
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.js.map +1 -0
- package/dist/plugins/session-state/plugin.js +159 -0
- package/dist/plugins/session-state/plugin.js.map +1 -0
- package/dist/plugins/session-stats/index.js +3 -0
- package/dist/plugins/session-stats/index.js.map +1 -0
- package/dist/plugins/session-stats/plugin.js +81 -0
- package/dist/plugins/session-stats/plugin.js.map +1 -0
- package/dist/plugins/shell/executor.js +339 -0
- package/dist/plugins/shell/executor.js.map +1 -0
- package/dist/plugins/shell/index.js +6 -0
- package/dist/plugins/shell/index.js.map +1 -0
- package/dist/plugins/shell/plugin.js +66 -0
- package/dist/plugins/shell/plugin.js.map +1 -0
- package/dist/plugins/shell/shell.integration.test.js +234 -0
- package/dist/plugins/shell/shell.integration.test.js.map +1 -0
- package/dist/plugins/shell/shell.test.js +236 -0
- package/dist/plugins/shell/shell.test.js.map +1 -0
- package/dist/plugins/skills/discovery.js +205 -0
- package/dist/plugins/skills/discovery.js.map +1 -0
- package/dist/plugins/skills/discovery.test.js +312 -0
- package/dist/plugins/skills/discovery.test.js.map +1 -0
- package/dist/plugins/skills/index.js +12 -0
- package/dist/plugins/skills/index.js.map +1 -0
- package/dist/plugins/skills/plugin.js +293 -0
- package/dist/plugins/skills/plugin.js.map +1 -0
- package/dist/plugins/skills/prompts.js +70 -0
- package/dist/plugins/skills/prompts.js.map +1 -0
- package/dist/plugins/skills/schema.js +18 -0
- package/dist/plugins/skills/schema.js.map +1 -0
- package/dist/plugins/skills/skills.integration.test.js +475 -0
- package/dist/plugins/skills/skills.integration.test.js.map +1 -0
- package/dist/plugins/snapshotting/index.js +3 -0
- package/dist/plugins/snapshotting/index.js.map +1 -0
- package/dist/plugins/snapshotting/jj-snapshotter.js +106 -0
- package/dist/plugins/snapshotting/jj-snapshotter.js.map +1 -0
- package/dist/plugins/snapshotting/plugin.js +28 -0
- package/dist/plugins/snapshotting/plugin.js.map +1 -0
- package/dist/plugins/snapshotting/snapshotter.js +2 -0
- package/dist/plugins/snapshotting/snapshotter.js.map +1 -0
- package/dist/plugins/todo/index.js +7 -0
- package/dist/plugins/todo/index.js.map +1 -0
- package/dist/plugins/todo/plugin.js +319 -0
- package/dist/plugins/todo/plugin.js.map +1 -0
- package/dist/plugins/todo/prompts.js +54 -0
- package/dist/plugins/todo/prompts.js.map +1 -0
- package/dist/plugins/todo/schema.js +18 -0
- package/dist/plugins/todo/schema.js.map +1 -0
- package/dist/plugins/todo/todo.integration.test.js +605 -0
- package/dist/plugins/todo/todo.integration.test.js.map +1 -0
- package/dist/plugins/uploads/index.js +8 -0
- package/dist/plugins/uploads/index.js.map +1 -0
- package/dist/plugins/uploads/plugin.js +346 -0
- package/dist/plugins/uploads/plugin.js.map +1 -0
- package/dist/plugins/uploads/preprocessor.js +44 -0
- package/dist/plugins/uploads/preprocessor.js.map +1 -0
- package/dist/plugins/uploads/preprocessors/image-classifier.js +127 -0
- package/dist/plugins/uploads/preprocessors/image-classifier.js.map +1 -0
- package/dist/plugins/uploads/preprocessors/index.js +7 -0
- package/dist/plugins/uploads/preprocessors/index.js.map +1 -0
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.js +204 -0
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.js.map +1 -0
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.js +172 -0
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.js.map +1 -0
- package/dist/plugins/uploads/schema.js +20 -0
- package/dist/plugins/uploads/schema.js.map +1 -0
- package/dist/plugins/uploads/state.js +22 -0
- package/dist/plugins/uploads/state.js.map +1 -0
- package/dist/plugins/uploads/uploads.integration.test.js +496 -0
- package/dist/plugins/uploads/uploads.integration.test.js.map +1 -0
- package/dist/plugins/user-chat/index.js +5 -0
- package/dist/plugins/user-chat/index.js.map +1 -0
- package/dist/plugins/user-chat/plugin.js +544 -0
- package/dist/plugins/user-chat/plugin.js.map +1 -0
- package/dist/plugins/user-chat/prompts.js +29 -0
- package/dist/plugins/user-chat/prompts.js.map +1 -0
- package/dist/plugins/user-chat/schema.js +46 -0
- package/dist/plugins/user-chat/schema.js.map +1 -0
- package/dist/plugins/user-chat/user-chat.integration.test.js +668 -0
- package/dist/plugins/user-chat/user-chat.integration.test.js.map +1 -0
- package/dist/plugins/workers/context.js +143 -0
- package/dist/plugins/workers/context.js.map +1 -0
- package/dist/plugins/workers/definition.js +30 -0
- package/dist/plugins/workers/definition.js.map +1 -0
- package/dist/plugins/workers/index.js +7 -0
- package/dist/plugins/workers/index.js.map +1 -0
- package/dist/plugins/workers/plugin.js +578 -0
- package/dist/plugins/workers/plugin.js.map +1 -0
- package/dist/plugins/workers/worker.js +18 -0
- package/dist/plugins/workers/worker.js.map +1 -0
- package/dist/plugins/workers/workers.integration.test.js +629 -0
- package/dist/plugins/workers/workers.integration.test.js.map +1 -0
- package/dist/prompts/base.js +239 -0
- package/dist/prompts/base.js.map +1 -0
- package/dist/prompts/builder.js +131 -0
- package/dist/prompts/builder.js.map +1 -0
- package/dist/prompts/index.js +20 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/macros.js +26 -0
- package/dist/prompts/macros.js.map +1 -0
- package/dist/prompts/macros.test.js +80 -0
- package/dist/prompts/macros.test.js.map +1 -0
- package/dist/testing/bootstrap-for-testing.js +28 -0
- package/dist/testing/bootstrap-for-testing.js.map +1 -0
- package/dist/testing/index.js +7 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/node-platform.js +65 -0
- package/dist/testing/node-platform.js.map +1 -0
- package/dist/testing/notification-collector.js +82 -0
- package/dist/testing/notification-collector.js.map +1 -0
- package/dist/testing/preset-helpers.js +37 -0
- package/dist/testing/preset-helpers.js.map +1 -0
- package/dist/testing/test-harness.js +226 -0
- package/dist/testing/test-harness.js.map +1 -0
- package/dist/testing/test-harness.test.js +51 -0
- package/dist/testing/test-harness.test.js.map +1 -0
- package/dist/testing/wait-helpers.js +64 -0
- package/dist/testing/wait-helpers.js.map +1 -0
- package/dist/transport/adapter/client-adapter.js +64 -0
- package/dist/transport/adapter/client-adapter.js.map +1 -0
- package/dist/transport/adapter/index.js +24 -0
- package/dist/transport/adapter/index.js.map +1 -0
- package/dist/transport/adapter/server-adapter.js +73 -0
- package/dist/transport/adapter/server-adapter.js.map +1 -0
- package/dist/transport/adapter/types.js +8 -0
- package/dist/transport/adapter/types.js.map +1 -0
- package/dist/transport/http/app.js +86 -0
- package/dist/transport/http/app.js.map +1 -0
- package/dist/transport/http/index.js +6 -0
- package/dist/transport/http/index.js.map +1 -0
- package/dist/transport/http/middleware/bearer-auth.js +33 -0
- package/dist/transport/http/middleware/bearer-auth.js.map +1 -0
- package/dist/transport/http/middleware/error-handler.js +56 -0
- package/dist/transport/http/middleware/error-handler.js.map +1 -0
- package/dist/transport/http/routes/files.js +237 -0
- package/dist/transport/http/routes/files.js.map +1 -0
- package/dist/transport/http/routes/resources.js +77 -0
- package/dist/transport/http/routes/resources.js.map +1 -0
- package/dist/transport/http/routes/rpc.integration.test.js +189 -0
- package/dist/transport/http/routes/rpc.integration.test.js.map +1 -0
- package/dist/transport/http/routes/rpc.js +110 -0
- package/dist/transport/http/routes/rpc.js.map +1 -0
- package/dist/transport/http/routes/rpc.test.js +316 -0
- package/dist/transport/http/routes/rpc.test.js.map +1 -0
- package/dist/transport/http/routes/upload.js +205 -0
- package/dist/transport/http/routes/upload.js.map +1 -0
- package/dist/transport/rpc/index.js +7 -0
- package/dist/transport/rpc/index.js.map +1 -0
- package/dist/transport/rpc/methods.js +8 -0
- package/dist/transport/rpc/methods.js.map +1 -0
- package/dist/user-config.js +14 -0
- package/dist/user-config.js.map +1 -0
- package/package.json +47 -57
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-only Platform impl backed by `node:fs/promises` + `node:child_process`.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the production adapter from `@roj-ai/sdk/bun-platform` but lives in this
|
|
5
|
+
* package so tests don't create a workspace cycle. Production SDK code MUST
|
|
6
|
+
* NOT import from here — use injected `Platform` from the caller instead.
|
|
7
|
+
*/
|
|
8
|
+
import { execFile as execFileCb, spawn as nodeSpawn } from 'node:child_process';
|
|
9
|
+
import * as fsp from 'node:fs/promises';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
11
|
+
import { promisify } from 'node:util';
|
|
12
|
+
const execFileP = promisify(execFileCb);
|
|
13
|
+
export function createNodeFileSystem() {
|
|
14
|
+
return {
|
|
15
|
+
readFile: ((path, encoding) => encoding ? fsp.readFile(path, encoding) : fsp.readFile(path)),
|
|
16
|
+
writeFile: (path, data) => fsp.writeFile(path, data),
|
|
17
|
+
appendFile: (path, data) => fsp.appendFile(path, data),
|
|
18
|
+
mkdir: async (path, options) => {
|
|
19
|
+
await fsp.mkdir(path, options);
|
|
20
|
+
},
|
|
21
|
+
readdir: ((path, options) => options?.withFileTypes
|
|
22
|
+
? fsp.readdir(path, { withFileTypes: true })
|
|
23
|
+
: fsp.readdir(path)),
|
|
24
|
+
stat: (path) => fsp.stat(path),
|
|
25
|
+
access: (path, mode) => fsp.access(path, mode),
|
|
26
|
+
unlink: (path) => fsp.unlink(path),
|
|
27
|
+
rm: (path, options) => fsp.rm(path, options),
|
|
28
|
+
cp: async (source, dest, options) => {
|
|
29
|
+
await fsp.cp(source, dest, options);
|
|
30
|
+
},
|
|
31
|
+
open: (path, flags) => fsp.open(path, flags),
|
|
32
|
+
exists: async (path) => {
|
|
33
|
+
try {
|
|
34
|
+
await fsp.access(path);
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
realpath: (path) => fsp.realpath(path),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export function createNodeProcessRunner() {
|
|
45
|
+
return {
|
|
46
|
+
async execFile(file, args, options) {
|
|
47
|
+
const { stdout, stderr } = await execFileP(file, args, options ?? {});
|
|
48
|
+
return {
|
|
49
|
+
stdout: typeof stdout === 'string' ? stdout : Buffer.from(stdout).toString(),
|
|
50
|
+
stderr: typeof stderr === 'string' ? stderr : Buffer.from(stderr).toString(),
|
|
51
|
+
};
|
|
52
|
+
},
|
|
53
|
+
spawn(command, args, options) {
|
|
54
|
+
return nodeSpawn(command, args, options ?? {});
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export function createNodePlatform() {
|
|
59
|
+
return {
|
|
60
|
+
fs: createNodeFileSystem(),
|
|
61
|
+
process: createNodeProcessRunner(),
|
|
62
|
+
tmpDir: tmpdir(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=node-platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-platform.js","sourceRoot":"","sources":["../../src/testing/node-platform.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAqB,QAAQ,IAAI,UAAU,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAClG,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAGrC,MAAM,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;AAEvC,MAAM,UAAU,oBAAoB;IACnC,OAAO;QACN,QAAQ,EAAE,CAAC,CAAC,IAAY,EAAE,QAA2B,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AkB;IACjC,OAAO;QACN,EAAE,EAAE,oBAAoB,EAAE;QAC1B,OAAO,EAAE,uBAAuB,EAAE;QAClC,MAAM,EAAE,MAAM,EAAE;KAChB,CAAA;AACF,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory notification collector for testing.
|
|
3
|
+
* Captures PluginNotification instances emitted during session execution.
|
|
4
|
+
*/
|
|
5
|
+
export class NotificationCollector {
|
|
6
|
+
notifications = [];
|
|
7
|
+
waiters = [];
|
|
8
|
+
/**
|
|
9
|
+
* Push a notification into the collector.
|
|
10
|
+
* Wired to SessionManager's onUserOutput callback.
|
|
11
|
+
*/
|
|
12
|
+
push(notification) {
|
|
13
|
+
this.notifications.push(notification);
|
|
14
|
+
// Check waiters
|
|
15
|
+
for (let i = this.waiters.length - 1; i >= 0; i--) {
|
|
16
|
+
const waiter = this.waiters[i];
|
|
17
|
+
if (waiter.predicate(notification)) {
|
|
18
|
+
clearTimeout(waiter.timer);
|
|
19
|
+
this.waiters.splice(i, 1);
|
|
20
|
+
waiter.resolve(notification);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get all collected notifications.
|
|
26
|
+
*/
|
|
27
|
+
getAll() {
|
|
28
|
+
return [...this.notifications];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get notifications from a specific plugin.
|
|
32
|
+
*/
|
|
33
|
+
getByPlugin(pluginName) {
|
|
34
|
+
return this.notifications.filter((n) => n.pluginName === pluginName);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get notifications matching plugin name and type.
|
|
38
|
+
*/
|
|
39
|
+
getByType(pluginName, type) {
|
|
40
|
+
return this.notifications.filter((n) => n.pluginName === pluginName && n.type === type);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get agent messages (user-chat.agentMessage notifications) with extracted payload.
|
|
44
|
+
*/
|
|
45
|
+
getAgentMessages() {
|
|
46
|
+
return this.getByType('user-chat', 'agentMessage').map((n) => {
|
|
47
|
+
const payload = n.payload;
|
|
48
|
+
return {
|
|
49
|
+
content: payload.content,
|
|
50
|
+
format: payload.format,
|
|
51
|
+
sessionId: payload.sessionId,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Wait for a notification matching the predicate.
|
|
57
|
+
* Checks already-collected notifications first, then waits for new ones.
|
|
58
|
+
*/
|
|
59
|
+
waitFor(predicate, opts) {
|
|
60
|
+
// Check already-collected
|
|
61
|
+
const existing = this.notifications.find(predicate);
|
|
62
|
+
if (existing)
|
|
63
|
+
return Promise.resolve(existing);
|
|
64
|
+
const timeoutMs = opts?.timeoutMs ?? 5000;
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const timer = setTimeout(() => {
|
|
67
|
+
const idx = this.waiters.findIndex((w) => w.resolve === resolve);
|
|
68
|
+
if (idx !== -1)
|
|
69
|
+
this.waiters.splice(idx, 1);
|
|
70
|
+
reject(new Error(`waitFor timed out after ${timeoutMs}ms`));
|
|
71
|
+
}, timeoutMs);
|
|
72
|
+
this.waiters.push({ predicate, resolve, reject, timer });
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Clear all collected notifications.
|
|
77
|
+
*/
|
|
78
|
+
clear() {
|
|
79
|
+
this.notifications = [];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=notification-collector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-collector.js","sourceRoot":"","sources":["../../src/testing/notification-collector.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,OAAO,qBAAqB;IACzB,aAAa,GAAyB,EAAE,CAAA;IACxC,OAAO,GAKV,EAAE,CAAA;IAEP;;;OAGG;IACH,IAAI,CAAC,YAAgC;QACpC,IAAI,CAAC,aAAa,CAAC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ModelId('mock').
|
|
5
|
+
*/
|
|
6
|
+
export function createTestPreset(overrides) {
|
|
7
|
+
const agents = overrides?.agents ?? [];
|
|
8
|
+
return {
|
|
9
|
+
id: overrides?.id ?? 'test',
|
|
10
|
+
name: 'Test Preset',
|
|
11
|
+
orchestrator: {
|
|
12
|
+
system: overrides?.orchestratorSystem ?? 'You are a test agent.',
|
|
13
|
+
model: ModelId('mock'),
|
|
14
|
+
tools: [],
|
|
15
|
+
agents: agents.map((a) => a.name),
|
|
16
|
+
debounceMs: 0,
|
|
17
|
+
plugins: overrides?.orchestratorPlugins,
|
|
18
|
+
},
|
|
19
|
+
agents: agents.map((a) => ({
|
|
20
|
+
...a,
|
|
21
|
+
model: a.model ?? ModelId('mock'),
|
|
22
|
+
debounceMs: a.debounceMs ?? 0,
|
|
23
|
+
})),
|
|
24
|
+
plugins: overrides?.plugins,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Create a multi-agent test preset from agent definitions.
|
|
29
|
+
* The orchestrator can spawn all provided agents.
|
|
30
|
+
*/
|
|
31
|
+
export function createMultiAgentPreset(agents, overrides) {
|
|
32
|
+
return createTestPreset({
|
|
33
|
+
...overrides,
|
|
34
|
+
agents,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=preset-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preset-helpers.js","sourceRoot":"","sources":["../../src/testing/preset-helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAO9C;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,SAMhC;IACA,MAAM,MAAM,GAAG,SAAS,EAAE,MAAM,IAAI,EAAE,CAAA;IAEtC,OAAO;QACN,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,MAAM;QAC3B,IAAI,EAAE,aAAa;QACnB,YAAY,EAAE;YACb,MAAM,EAAE,SAAS,EAAE,kBAAkB,IAAI,uBAAuB;YAChE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;YACtB,KAAK,EAAE,EAAE;YACT,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YACjC,UAAU,EAAE,CAAC;YACb,OAAO,EAAE,SAAS,EAAE,mBAAmB;SACvC;QACD,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1B,GAAG,CAAC;YACJ,KAAK,EAAE,CAAC,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;YACjC,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,CAAC;SAC7B,CAAC,CAAC;QACH,OAAO,EAAE,SAAS,EAAE,OAAO;KAC3B,CAAA;AACF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAA6B,EAC7B,SAGC;IAED,OAAO,gBAAgB,CAAC;QACvB,GAAG,SAAS;QACZ,MAAM;KACN,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { MemoryEventStore } from '../core/events/memory.js';
|
|
2
|
+
import { SessionFileStore } from '../core/file-store/file-store.js';
|
|
3
|
+
import { LoggingLLMProvider } from '../core/llm/logging-provider.js';
|
|
4
|
+
import { MockLLMProvider } from '../core/llm/mock.js';
|
|
5
|
+
import { SessionManager } from '../core/sessions/session-manager.js';
|
|
6
|
+
import { ToolExecutor } from '../core/tools/executor.js';
|
|
7
|
+
import { silentLogger } from '../lib/logger/logger.js';
|
|
8
|
+
import { createNodePlatform } from './node-platform.js';
|
|
9
|
+
import { agentsPlugin } from '../plugins/agents/plugin.js';
|
|
10
|
+
import { filesystemPlugin } from '../plugins/filesystem/index.js';
|
|
11
|
+
import { llmDebugPlugin } from '../plugins/llm-debug/plugin.js';
|
|
12
|
+
import { logsPlugin } from '../plugins/logs/index.js';
|
|
13
|
+
import { mailboxPlugin } from '../plugins/mailbox/plugin.js';
|
|
14
|
+
import { presetsPlugin, sessionLifecyclePlugin } from '../plugins/session-lifecycle/index.js';
|
|
15
|
+
import { uploadsPlugin } from '../plugins/uploads/plugin.js';
|
|
16
|
+
import { userChatPlugin } from '../plugins/user-chat/plugin.js';
|
|
17
|
+
import { NotificationCollector } from './notification-collector.js';
|
|
18
|
+
import { waitForAllAgentsIdle } from './wait-helpers.js';
|
|
19
|
+
/**
|
|
20
|
+
* Default system plugins for testing — same as builtinPlugins in bootstrap.ts.
|
|
21
|
+
*/
|
|
22
|
+
const defaultSystemPlugins = [
|
|
23
|
+
sessionLifecyclePlugin,
|
|
24
|
+
presetsPlugin,
|
|
25
|
+
mailboxPlugin,
|
|
26
|
+
agentsPlugin,
|
|
27
|
+
userChatPlugin,
|
|
28
|
+
uploadsPlugin,
|
|
29
|
+
llmDebugPlugin,
|
|
30
|
+
filesystemPlugin,
|
|
31
|
+
logsPlugin,
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* TestHarness — boots a real SessionManager with MemoryEventStore,
|
|
35
|
+
* MockLLMProvider, and in-memory notification collection.
|
|
36
|
+
*
|
|
37
|
+
* Enables full-flow integration tests without external dependencies.
|
|
38
|
+
*/
|
|
39
|
+
export class TestHarness {
|
|
40
|
+
eventStore;
|
|
41
|
+
llmProvider;
|
|
42
|
+
notifications;
|
|
43
|
+
sessionManager;
|
|
44
|
+
constructor(options) {
|
|
45
|
+
this.eventStore = options.eventStore ?? new MemoryEventStore();
|
|
46
|
+
if (options.llmProvider) {
|
|
47
|
+
this.llmProvider = options.llmProvider;
|
|
48
|
+
}
|
|
49
|
+
else if (options.mockHandler) {
|
|
50
|
+
this.llmProvider = new MockLLMProvider(options.mockHandler);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Default: echo back content with no tool calls
|
|
54
|
+
this.llmProvider = MockLLMProvider.withFixedResponse({
|
|
55
|
+
content: 'Mock response',
|
|
56
|
+
toolCalls: [],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
this.notifications = new NotificationCollector();
|
|
60
|
+
const presetsMap = new Map(options.presets.map((p) => [p.id, p]));
|
|
61
|
+
// Override debounceMs: 0 on all preset agents for instant processing
|
|
62
|
+
for (const preset of presetsMap.values()) {
|
|
63
|
+
preset.orchestrator.debounceMs = 0;
|
|
64
|
+
if (preset.communicator) {
|
|
65
|
+
preset.communicator.debounceMs = 0;
|
|
66
|
+
}
|
|
67
|
+
for (const agent of preset.agents) {
|
|
68
|
+
agent.debounceMs = 0;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const basePath = `/tmp/roj-test-${Math.random().toString(36).slice(2)}`;
|
|
72
|
+
const toolExecutor = new ToolExecutor(silentLogger);
|
|
73
|
+
const platform = createNodePlatform();
|
|
74
|
+
const dataFileStore = new SessionFileStore(basePath, undefined, false, platform.fs, 'session');
|
|
75
|
+
// When llmLogger is provided, wrap the mock provider so calls get logged
|
|
76
|
+
const effectiveProvider = options.llmLogger
|
|
77
|
+
? new LoggingLLMProvider(this.llmProvider, options.llmLogger)
|
|
78
|
+
: this.llmProvider;
|
|
79
|
+
this.sessionManager = new SessionManager({
|
|
80
|
+
eventStore: this.eventStore,
|
|
81
|
+
llmProvider: effectiveProvider,
|
|
82
|
+
toolExecutor,
|
|
83
|
+
presets: presetsMap,
|
|
84
|
+
logger: silentLogger,
|
|
85
|
+
basePath,
|
|
86
|
+
dataFileStore,
|
|
87
|
+
onUserOutput: (n) => this.notifications.push(n),
|
|
88
|
+
llmLogger: options.llmLogger,
|
|
89
|
+
platform,
|
|
90
|
+
systemPlugins: [...defaultSystemPlugins, ...(options.systemPlugins ?? [])],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create a session and return a TestSession wrapper.
|
|
95
|
+
*/
|
|
96
|
+
async createSession(presetId) {
|
|
97
|
+
const result = await this.sessionManager.createSession(presetId);
|
|
98
|
+
if (!result.ok) {
|
|
99
|
+
throw new Error(`Failed to create session: ${result.error.type} — ${result.error.message}`);
|
|
100
|
+
}
|
|
101
|
+
return new TestSession(result.value, this);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Open an existing session from the event store (replays events, runs onSessionReady hooks).
|
|
105
|
+
* Used to simulate server restart by pairing with another harness over the same eventStore.
|
|
106
|
+
*/
|
|
107
|
+
async openSession(sessionId) {
|
|
108
|
+
const result = await this.sessionManager.getSession(sessionId);
|
|
109
|
+
if (!result.ok) {
|
|
110
|
+
throw new Error(`Failed to open session: ${result.error.type} — ${result.error.message}`);
|
|
111
|
+
}
|
|
112
|
+
return new TestSession(result.value, this);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Shutdown all sessions.
|
|
116
|
+
*/
|
|
117
|
+
async shutdown() {
|
|
118
|
+
await this.sessionManager.shutdown();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* TestSession — convenience wrapper around Session for integration tests.
|
|
123
|
+
*/
|
|
124
|
+
export class TestSession {
|
|
125
|
+
session;
|
|
126
|
+
harness;
|
|
127
|
+
sessionId;
|
|
128
|
+
constructor(session, harness) {
|
|
129
|
+
this.session = session;
|
|
130
|
+
this.harness = harness;
|
|
131
|
+
this.sessionId = session.id;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Send a message to the entry agent (communicator or orchestrator).
|
|
135
|
+
*/
|
|
136
|
+
async sendMessage(content) {
|
|
137
|
+
const entryAgentId = this.session.getEntryAgentId();
|
|
138
|
+
if (!entryAgentId) {
|
|
139
|
+
throw new Error('No entry agent found');
|
|
140
|
+
}
|
|
141
|
+
await this.sendMessageToAgent(entryAgentId, content);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Send a message to a specific agent.
|
|
145
|
+
*/
|
|
146
|
+
async sendMessageToAgent(agentId, content) {
|
|
147
|
+
const result = await this.session.callPluginMethod('user-chat.sendMessage', {
|
|
148
|
+
sessionId: String(this.sessionId),
|
|
149
|
+
content,
|
|
150
|
+
agentId: String(agentId),
|
|
151
|
+
});
|
|
152
|
+
if (!result.ok) {
|
|
153
|
+
throw new Error(`sendMessage failed: ${result.error.type} — ${result.error.message}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Wait for all agents to become idle.
|
|
158
|
+
*/
|
|
159
|
+
async waitForIdle(opts) {
|
|
160
|
+
await waitForAllAgentsIdle(this.session, opts);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Send a message and wait for all agents to become idle.
|
|
164
|
+
*/
|
|
165
|
+
async sendAndWaitForIdle(content, opts) {
|
|
166
|
+
await this.sendMessage(content);
|
|
167
|
+
await this.waitForIdle(opts);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get all events from the event store for this session.
|
|
171
|
+
*/
|
|
172
|
+
async getEvents() {
|
|
173
|
+
return this.harness.eventStore.load(this.sessionId);
|
|
174
|
+
}
|
|
175
|
+
async getEventsByType(factoryOrType, maybeType) {
|
|
176
|
+
const type = typeof factoryOrType === 'string' ? factoryOrType : maybeType;
|
|
177
|
+
return this.harness.eventStore.getEventsByType(this.sessionId, type);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Get notifications for this session.
|
|
181
|
+
*/
|
|
182
|
+
getNotifications() {
|
|
183
|
+
return this.harness.notifications.getAll();
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Get the current session state.
|
|
187
|
+
*/
|
|
188
|
+
get state() {
|
|
189
|
+
return this.session.state;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Get the entry agent ID.
|
|
193
|
+
*/
|
|
194
|
+
getEntryAgentId() {
|
|
195
|
+
return this.session.getEntryAgentId();
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Close the session.
|
|
199
|
+
*/
|
|
200
|
+
async close() {
|
|
201
|
+
const result = await this.session.close();
|
|
202
|
+
if (!result.ok) {
|
|
203
|
+
throw new Error(`close failed: ${result.error.type} — ${result.error.message}`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Call a plugin method on the underlying session.
|
|
208
|
+
*/
|
|
209
|
+
async callPluginMethod(method, input) {
|
|
210
|
+
return this.session.callPluginMethod(method, input);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Answer a user-chat question (convenience wrapper around callPluginMethod).
|
|
214
|
+
*/
|
|
215
|
+
async answerQuestion(agentId, questionId, answer) {
|
|
216
|
+
const result = await this.session.callPluginMethod('user-chat.answerQuestion', {
|
|
217
|
+
agentId: String(agentId),
|
|
218
|
+
questionId,
|
|
219
|
+
answer,
|
|
220
|
+
});
|
|
221
|
+
if (!result.ok) {
|
|
222
|
+
throw new Error(`answerQuestion failed: ${result.error.type} — ${result.error.message}`);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=test-harness.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-harness.js","sourceRoot":"","sources":["../../src/testing/test-harness.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAElE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAKpD,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAA;AAGnE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B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,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,OAAgB,EAAE,UAAkB,EAAE,MAAe;QACzE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,0BAA0B,EAAE;YAC9E,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC;YACxB,UAAU;YACV,MAAM;SACN,CAAC,CAAA;QACF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;QACzF,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test';
|
|
2
|
+
import { MockLLMProvider } from '../core/llm/mock.js';
|
|
3
|
+
import { ToolCallId } from '../core/tools/schema.js';
|
|
4
|
+
import { createTestPreset, TestHarness } from './index.js';
|
|
5
|
+
describe('TestHarness', () => {
|
|
6
|
+
it('sendMessage → tell_user → notification', async () => {
|
|
7
|
+
const harness = new TestHarness({
|
|
8
|
+
presets: [createTestPreset()],
|
|
9
|
+
llmProvider: MockLLMProvider.withSequence([
|
|
10
|
+
{
|
|
11
|
+
content: null,
|
|
12
|
+
toolCalls: [{ id: ToolCallId('tc1'), name: 'tell_user', input: { message: 'Hello!' } }],
|
|
13
|
+
},
|
|
14
|
+
{ content: 'Done', toolCalls: [] },
|
|
15
|
+
]),
|
|
16
|
+
});
|
|
17
|
+
const session = await harness.createSession('test');
|
|
18
|
+
await session.sendAndWaitForIdle('Hi');
|
|
19
|
+
const messages = harness.notifications.getAgentMessages();
|
|
20
|
+
expect(messages).toHaveLength(1);
|
|
21
|
+
expect(messages[0].content).toBe('Hello!');
|
|
22
|
+
await harness.shutdown();
|
|
23
|
+
});
|
|
24
|
+
it('creates session with correct state', async () => {
|
|
25
|
+
const harness = new TestHarness({
|
|
26
|
+
presets: [createTestPreset()],
|
|
27
|
+
});
|
|
28
|
+
const session = await harness.createSession('test');
|
|
29
|
+
expect(session.state.status).toBe('active');
|
|
30
|
+
expect(session.state.presetId).toBe('test');
|
|
31
|
+
expect(session.getEntryAgentId()).not.toBeNull();
|
|
32
|
+
await harness.shutdown();
|
|
33
|
+
});
|
|
34
|
+
it('captures events from event store', async () => {
|
|
35
|
+
const harness = new TestHarness({
|
|
36
|
+
presets: [createTestPreset()],
|
|
37
|
+
llmProvider: MockLLMProvider.withFixedResponse({
|
|
38
|
+
content: 'Done',
|
|
39
|
+
toolCalls: [],
|
|
40
|
+
}),
|
|
41
|
+
});
|
|
42
|
+
const session = await harness.createSession('test');
|
|
43
|
+
await session.sendAndWaitForIdle('Test');
|
|
44
|
+
const events = await session.getEvents();
|
|
45
|
+
const sessionCreated = await session.getEventsByType('session_created');
|
|
46
|
+
expect(events.length).toBeGreaterThan(0);
|
|
47
|
+
expect(sessionCreated).toHaveLength(1);
|
|
48
|
+
await harness.shutdown();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=test-harness.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-harness.test.js","sourceRoot":"","sources":["../../src/testing/test-harness.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAE1D,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC5B,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACvD,MAAM,OA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,CAAC,CAAA;QAC3C,MAAM,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAA;QAEhD,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;IACzB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;QACjD,MAAM,OAAO,GAAG,IAAI,WAAW,CAAC;YAC/B,OAAO,EAAE,CAAC,gBAAgB,EAAE,CAAC;YAC7B,WAAW,EAAE,eAAe,CAAC,iBAAiB,CAAC;gBAC9C,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,EAAE;aACb,CAAC;SACF,CAAC,CAAA;QAEF,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA;QACnD,MAAM,OAAO,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;QAExC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,EAAE,CAAA;QACxC,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAA;QAEvE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;QACxC,MAAM,CAAC,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAEtC,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAA;IACzB,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const DEFAULT_TIMEOUT_MS = 5000;
|
|
2
|
+
const POLL_INTERVAL_MS = 10;
|
|
3
|
+
/**
|
|
4
|
+
* Wait for a specific agent to become idle.
|
|
5
|
+
* An agent is "idle" when: status === 'pending', no pendingToolCalls,
|
|
6
|
+
* no pendingToolResults, and not scheduled for processing.
|
|
7
|
+
*/
|
|
8
|
+
export async function waitForAgentIdle(session, agentId, opts) {
|
|
9
|
+
const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
10
|
+
const deadline = Date.now() + timeoutMs;
|
|
11
|
+
while (Date.now() < deadline) {
|
|
12
|
+
if (isAgentIdle(session, agentId)) {
|
|
13
|
+
// Double-check after one poll interval to account for queueMicrotask re-entry
|
|
14
|
+
await sleep(POLL_INTERVAL_MS);
|
|
15
|
+
if (isAgentIdle(session, agentId)) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
await sleep(POLL_INTERVAL_MS);
|
|
20
|
+
}
|
|
21
|
+
throw new Error(`waitForAgentIdle timed out after ${timeoutMs}ms for agent ${agentId}`);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Wait for all agents in a session to become idle.
|
|
25
|
+
*/
|
|
26
|
+
export async function waitForAllAgentsIdle(session, opts) {
|
|
27
|
+
const timeoutMs = opts?.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
28
|
+
const deadline = Date.now() + timeoutMs;
|
|
29
|
+
while (Date.now() < deadline) {
|
|
30
|
+
if (areAllAgentsIdle(session)) {
|
|
31
|
+
// Double-check after one poll interval
|
|
32
|
+
await sleep(POLL_INTERVAL_MS);
|
|
33
|
+
if (areAllAgentsIdle(session)) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
await sleep(POLL_INTERVAL_MS);
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`waitForAllAgentsIdle timed out after ${timeoutMs}ms`);
|
|
40
|
+
}
|
|
41
|
+
function isAgentIdle(session, agentId) {
|
|
42
|
+
const agent = session.getAgent(agentId);
|
|
43
|
+
if (!agent)
|
|
44
|
+
return true; // Agent doesn't exist, consider idle
|
|
45
|
+
const agentState = agent.state;
|
|
46
|
+
if (!agentState)
|
|
47
|
+
return true;
|
|
48
|
+
return (agentState.status === 'pending'
|
|
49
|
+
&& agentState.pendingToolCalls.length === 0
|
|
50
|
+
&& agentState.pendingToolResults.length === 0
|
|
51
|
+
&& !agent.isScheduled());
|
|
52
|
+
}
|
|
53
|
+
function areAllAgentsIdle(session) {
|
|
54
|
+
for (const [agentId] of session.state.agents) {
|
|
55
|
+
if (!isAgentIdle(session, agentId)) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
function sleep(ms) {
|
|
62
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=wait-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-helpers.js","sourceRoot":"","sources":["../../src/testing/wait-helpers.ts"],"names":[],"mappings":"AAGA,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAC/B,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAE3B;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACrC,OAAgB,EAChB,OAAgB,EAChB,IAA6B;IAE7B,MAAM,SAAS,GAAG,IAAI,EAAE,SAAS,IAAI,kBAAkB,CAAA;IACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAA;IAEvC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;QAC9B,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;YACnC,8EAA8E;YAC9E,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAA;YAC7B,IAAI,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;gBACnC,OAAM;YACP,CAAC;QACF,CAAC;QACD,MAAM,KAAK,CAAC,gBAAgB,CAAC,CAAA;IAC9B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,oCAAoC,SAAS,gBAAgB,OAAO,EAAE,CAAC,CAAA;AACxF,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oB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O,KAAK,CAAA;QACb,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAA;AACZ,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACxB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AACzD,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client Adapter
|
|
3
|
+
*
|
|
4
|
+
* Worker mode - agent connects to DO as WebSocket client.
|
|
5
|
+
* Simplified for broadcast-only communication (agent -> DO -> SPA).
|
|
6
|
+
* User messages and answers are handled via REST API.
|
|
7
|
+
*
|
|
8
|
+
* Authentication: Token is passed in the WebSocket URL as query parameter
|
|
9
|
+
* and Authorization header (handled by DO before upgrade).
|
|
10
|
+
*/
|
|
11
|
+
import { ClientConnection } from '@roj-ai/transport/client';
|
|
12
|
+
export class ClientAdapter {
|
|
13
|
+
config;
|
|
14
|
+
connection;
|
|
15
|
+
logger;
|
|
16
|
+
heartbeatTimer = null;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.config = config;
|
|
19
|
+
this.logger = config.logger?.child({ component: 'ClientAdapter' });
|
|
20
|
+
this.connection = new ClientConnection({
|
|
21
|
+
url: config.url,
|
|
22
|
+
wsFactory: config.wsFactory,
|
|
23
|
+
reconnect: config.reconnect ?? {
|
|
24
|
+
baseDelayMs: 1000,
|
|
25
|
+
maxDelayMs: 30000,
|
|
26
|
+
maxAttempts: Infinity,
|
|
27
|
+
jitterFactor: 0.3,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async start() {
|
|
32
|
+
this.logger?.info('Connecting to DO', { url: this.config.url });
|
|
33
|
+
await this.connection.connect();
|
|
34
|
+
this.logger?.info('Connected to DO');
|
|
35
|
+
this.startHeartbeat();
|
|
36
|
+
}
|
|
37
|
+
async stop() {
|
|
38
|
+
this.stopHeartbeat();
|
|
39
|
+
this.logger?.info('Disconnecting from DO');
|
|
40
|
+
await this.connection.disconnect();
|
|
41
|
+
this.logger?.info('Disconnected from DO');
|
|
42
|
+
}
|
|
43
|
+
startHeartbeat() {
|
|
44
|
+
this.stopHeartbeat();
|
|
45
|
+
this.heartbeatTimer = setInterval(() => {
|
|
46
|
+
this.connection.send(JSON.stringify({ type: 'heartbeat', ts: Date.now() }));
|
|
47
|
+
}, 10_000);
|
|
48
|
+
}
|
|
49
|
+
stopHeartbeat() {
|
|
50
|
+
if (this.heartbeatTimer) {
|
|
51
|
+
clearInterval(this.heartbeatTimer);
|
|
52
|
+
this.heartbeatTimer = null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
broadcast(notification) {
|
|
56
|
+
// Send as wire message — protocol validation happens at the DO side
|
|
57
|
+
this.connection.send(JSON.stringify({
|
|
58
|
+
type: notification.type,
|
|
59
|
+
payload: notification.payload,
|
|
60
|
+
ts: Date.now(),
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=client-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-adapter.js","sourceRoot":"","sources":["../../../src/transport/adapter/client-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAW3D,MAAM,OAAO,aAAa;IACR,MAAM,CAAqB;IAC3B,UAAU,CAA4C;IACtD,MAAM,CAAS;IACxB,cAAc,GAA0C,IAAI,CAAA;IAEpE,YAAY,MAA2B;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAA;QAClE,IAAI,CAAC,UAAU,GAAG,IAAI,gBAAgB,CAAC;YACtC,GAAG,EAAE,MAAM,CAAC,GAAG;YACf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,CAAC;IACF,CAAC;IAED,SAAS,CAAC,YAAgC;QACzC,oEAAoE;QACpE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;YACnC,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,OAAO,EAAE,YAAY,CAAC,OAAO;YAC7B,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;SACd,CAAC,CAAC,CAAA;IACJ,CAAC;CACD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport Adapter Module
|
|
3
|
+
*
|
|
4
|
+
* Simplified for broadcast-only WebSocket communication.
|
|
5
|
+
* User messages and answers are handled via REST API.
|
|
6
|
+
*/
|
|
7
|
+
export { ServerAdapter } from './server-adapter.js';
|
|
8
|
+
export { ClientAdapter } from './client-adapter.js';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Factory
|
|
11
|
+
// ============================================================================
|
|
12
|
+
import { ClientAdapter } from './client-adapter.js';
|
|
13
|
+
import { ServerAdapter } from './server-adapter.js';
|
|
14
|
+
export function createAgentTransport(config) {
|
|
15
|
+
if (config.mode === 'standalone') {
|
|
16
|
+
const { mode: _mode, ...rest } = config;
|
|
17
|
+
return new ServerAdapter(rest);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const { mode: _mode, ...rest } = config;
|
|
21
|
+
return new ClientAdapter(rest);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=index.js.map
|