@roj-ai/sdk 0.1.35 → 0.2.1
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 +420 -26
- package/dist/bootstrap.d.ts.map +1 -1
- package/dist/bootstrap.js +55 -24
- package/dist/bootstrap.js.map +1 -1
- package/dist/bun-platform/fs.d.ts.map +1 -1
- package/dist/bun-platform/fs.js +1 -0
- package/dist/bun-platform/fs.js.map +1 -1
- package/dist/bun-platform/index.d.ts +4 -1
- package/dist/bun-platform/index.d.ts.map +1 -1
- package/dist/bun-platform/index.js +7 -1
- package/dist/bun-platform/index.js.map +1 -1
- package/dist/bun-platform/server-lifecycle.d.ts +30 -0
- package/dist/bun-platform/server-lifecycle.d.ts.map +1 -0
- package/dist/bun-platform/server-lifecycle.js +182 -0
- package/dist/bun-platform/server-lifecycle.js.map +1 -0
- package/dist/bun-platform/shell.d.ts +33 -0
- package/dist/bun-platform/shell.d.ts.map +1 -0
- package/dist/bun-platform/shell.js +322 -0
- package/dist/bun-platform/shell.js.map +1 -0
- package/dist/config.d.ts +34 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +97 -0
- package/dist/config.js.map +1 -1
- package/dist/core/agents/agent.d.ts +42 -7
- package/dist/core/agents/agent.d.ts.map +1 -1
- package/dist/core/agents/agent.js +209 -90
- package/dist/core/agents/agent.js.map +1 -1
- package/dist/core/agents/config.d.ts +8 -1
- package/dist/core/agents/config.d.ts.map +1 -1
- package/dist/core/agents/config.js +5 -1
- package/dist/core/agents/config.js.map +1 -1
- package/dist/core/agents/retry.d.ts +1 -1
- package/dist/core/agents/retry.d.ts.map +1 -1
- package/dist/core/agents/retry.js +14 -16
- package/dist/core/agents/retry.js.map +1 -1
- package/dist/core/agents/state.d.ts +27 -1
- package/dist/core/agents/state.d.ts.map +1 -1
- package/dist/core/agents/state.js +1 -1
- package/dist/core/agents/state.js.map +1 -1
- package/dist/core/context/state.d.ts +3 -3
- package/dist/core/context/state.d.ts.map +1 -1
- package/dist/core/context/state.js +6 -2
- package/dist/core/context/state.js.map +1 -1
- package/dist/core/events/base-event-store.d.ts.map +1 -1
- package/dist/core/events/base-event-store.js +22 -14
- package/dist/core/events/base-event-store.js.map +1 -1
- package/dist/core/events/file.d.ts +39 -1
- package/dist/core/events/file.d.ts.map +1 -1
- package/dist/core/events/file.js +159 -20
- package/dist/core/events/file.js.map +1 -1
- package/dist/core/events/types.d.ts +1 -1
- package/dist/core/file-store/containment.d.ts +19 -0
- package/dist/core/file-store/containment.d.ts.map +1 -0
- package/dist/core/file-store/containment.js +62 -0
- package/dist/core/file-store/containment.js.map +1 -0
- package/dist/core/file-store/file-store.d.ts +22 -2
- package/dist/core/file-store/file-store.d.ts.map +1 -1
- package/dist/core/file-store/file-store.js +88 -20
- package/dist/core/file-store/file-store.js.map +1 -1
- package/dist/core/file-store/types.d.ts +13 -1
- package/dist/core/file-store/types.d.ts.map +1 -1
- package/dist/core/image/image-processor.d.ts.map +1 -1
- package/dist/core/image/image-processor.js +3 -1
- package/dist/core/image/image-processor.js.map +1 -1
- package/dist/core/image/types.d.ts +2 -0
- package/dist/core/image/types.d.ts.map +1 -1
- package/dist/core/image/vips-resizer.d.ts.map +1 -1
- package/dist/core/image/vips-resizer.js +81 -33
- package/dist/core/image/vips-resizer.js.map +1 -1
- package/dist/core/llm/anthropic.d.ts +0 -1
- package/dist/core/llm/anthropic.d.ts.map +1 -1
- package/dist/core/llm/anthropic.js +101 -74
- package/dist/core/llm/anthropic.js.map +1 -1
- package/dist/core/llm/logger.d.ts +14 -2
- package/dist/core/llm/logger.d.ts.map +1 -1
- package/dist/core/llm/logger.js +161 -36
- package/dist/core/llm/logger.js.map +1 -1
- package/dist/core/llm/openrouter.d.ts +0 -1
- package/dist/core/llm/openrouter.d.ts.map +1 -1
- package/dist/core/llm/openrouter.js +70 -74
- package/dist/core/llm/openrouter.js.map +1 -1
- package/dist/core/llm/provider-request.d.ts +10 -0
- package/dist/core/llm/provider-request.d.ts.map +1 -0
- package/dist/core/llm/provider-request.js +41 -0
- package/dist/core/llm/provider-request.js.map +1 -0
- package/dist/core/llm/provider.d.ts +45 -3
- package/dist/core/llm/provider.d.ts.map +1 -1
- package/dist/core/llm/provider.js +26 -0
- package/dist/core/llm/provider.js.map +1 -1
- package/dist/core/llm/state.d.ts +4 -2
- package/dist/core/llm/state.d.ts.map +1 -1
- package/dist/core/llm/state.js +15 -4
- package/dist/core/llm/state.js.map +1 -1
- package/dist/core/plugins/plugin-builder.d.ts +57 -3
- package/dist/core/plugins/plugin-builder.d.ts.map +1 -1
- package/dist/core/plugins/plugin-builder.js +68 -14
- package/dist/core/plugins/plugin-builder.js.map +1 -1
- package/dist/core/preset/preset-builder.d.ts +3 -2
- package/dist/core/preset/preset-builder.d.ts.map +1 -1
- package/dist/core/preset/preset-builder.js +7 -16
- package/dist/core/preset/preset-builder.js.map +1 -1
- package/dist/core/sessions/context.d.ts +23 -5
- package/dist/core/sessions/context.d.ts.map +1 -1
- package/dist/core/sessions/runtime-activity.d.ts +33 -0
- package/dist/core/sessions/runtime-activity.d.ts.map +1 -0
- package/dist/core/sessions/runtime-activity.js +55 -0
- package/dist/core/sessions/runtime-activity.js.map +1 -0
- package/dist/core/sessions/schema.d.ts +23 -2
- package/dist/core/sessions/schema.d.ts.map +1 -1
- package/dist/core/sessions/schema.js +24 -3
- package/dist/core/sessions/schema.js.map +1 -1
- package/dist/core/sessions/session-manager.d.ts +83 -6
- package/dist/core/sessions/session-manager.d.ts.map +1 -1
- package/dist/core/sessions/session-manager.js +517 -118
- package/dist/core/sessions/session-manager.js.map +1 -1
- package/dist/core/sessions/session-store.d.ts +18 -0
- package/dist/core/sessions/session-store.d.ts.map +1 -1
- package/dist/core/sessions/session-store.js +33 -0
- package/dist/core/sessions/session-store.js.map +1 -1
- package/dist/core/sessions/session.d.ts +42 -6
- package/dist/core/sessions/session.d.ts.map +1 -1
- package/dist/core/sessions/session.js +176 -44
- package/dist/core/sessions/session.js.map +1 -1
- package/dist/core/sessions/state.d.ts +10 -1
- package/dist/core/sessions/state.d.ts.map +1 -1
- package/dist/core/sessions/state.js +16 -1
- package/dist/core/sessions/state.js.map +1 -1
- package/dist/core/system.d.ts +9 -0
- package/dist/core/system.d.ts.map +1 -1
- package/dist/core/system.js +4 -1
- package/dist/core/system.js.map +1 -1
- package/dist/core/tools/executor.d.ts +1 -1
- package/dist/core/wake-key.d.ts +34 -0
- package/dist/core/wake-key.d.ts.map +1 -0
- package/dist/core/wake-key.js +51 -0
- package/dist/core/wake-key.js.map +1 -0
- package/dist/index.d.ts +24 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -8
- package/dist/index.js.map +1 -1
- package/dist/lib/archive/archive-inspection.d.ts +48 -0
- package/dist/lib/archive/archive-inspection.d.ts.map +1 -0
- package/dist/lib/archive/archive-inspection.fixtures.d.ts +7 -0
- package/dist/lib/archive/archive-inspection.fixtures.d.ts.map +1 -0
- package/dist/lib/archive/archive-inspection.fixtures.js +134 -0
- package/dist/lib/archive/archive-inspection.fixtures.js.map +1 -0
- package/dist/lib/archive/archive-inspection.js +253 -0
- package/dist/lib/archive/archive-inspection.js.map +1 -0
- package/dist/lib/archive/index.d.ts +3 -0
- package/dist/lib/archive/index.d.ts.map +1 -0
- package/dist/lib/archive/index.js +2 -0
- package/dist/lib/archive/index.js.map +1 -0
- package/dist/lib/logger/console.d.ts +5 -12
- package/dist/lib/logger/console.d.ts.map +1 -1
- package/dist/lib/logger/console.js +5 -47
- package/dist/lib/logger/console.js.map +1 -1
- package/dist/lib/logger/file.d.ts +8 -11
- package/dist/lib/logger/file.d.ts.map +1 -1
- package/dist/lib/logger/file.js +26 -37
- package/dist/lib/logger/file.js.map +1 -1
- package/dist/lib/logger/index.d.ts +3 -1
- package/dist/lib/logger/index.d.ts.map +1 -1
- package/dist/lib/logger/index.js +3 -1
- package/dist/lib/logger/index.js.map +1 -1
- package/dist/lib/logger/jsonl.d.ts +21 -0
- package/dist/lib/logger/jsonl.d.ts.map +1 -0
- package/dist/lib/logger/jsonl.js +29 -0
- package/dist/lib/logger/jsonl.js.map +1 -0
- package/dist/lib/logger/logger.d.ts +22 -0
- package/dist/lib/logger/logger.d.ts.map +1 -1
- package/dist/lib/logger/logger.js +37 -0
- package/dist/lib/logger/logger.js.map +1 -1
- package/dist/lib/logger/session-log.d.ts +21 -0
- package/dist/lib/logger/session-log.d.ts.map +1 -0
- package/dist/lib/logger/session-log.js +37 -0
- package/dist/lib/logger/session-log.js.map +1 -0
- package/dist/lib/utils/concurrency.d.ts +1 -1
- package/dist/lib/utils/concurrency.d.ts.map +1 -1
- package/dist/lib/utils/concurrency.js +30 -7
- package/dist/lib/utils/concurrency.js.map +1 -1
- package/dist/lib/utils/fs-batch.d.ts +17 -0
- package/dist/lib/utils/fs-batch.d.ts.map +1 -0
- package/dist/lib/utils/fs-batch.js +38 -0
- package/dist/lib/utils/fs-batch.js.map +1 -0
- package/dist/lib/utils/result.d.ts +7 -22
- package/dist/lib/utils/result.d.ts.map +1 -1
- package/dist/lib/utils/result.js +6 -17
- package/dist/lib/utils/result.js.map +1 -1
- package/dist/lib/utils/sleep.d.ts +10 -0
- package/dist/lib/utils/sleep.d.ts.map +1 -0
- package/dist/lib/utils/sleep.js +26 -0
- package/dist/lib/utils/sleep.js.map +1 -0
- package/dist/platform/fs-revision.d.ts +21 -0
- package/dist/platform/fs-revision.d.ts.map +1 -0
- package/dist/platform/fs-revision.js +9 -0
- package/dist/platform/fs-revision.js.map +1 -0
- package/dist/platform/fs.d.ts +104 -1
- package/dist/platform/fs.d.ts.map +1 -1
- package/dist/platform/git.d.ts +59 -0
- package/dist/platform/git.d.ts.map +1 -0
- package/dist/platform/git.js +8 -0
- package/dist/platform/git.js.map +1 -0
- package/dist/platform/index.d.ts +40 -1
- package/dist/platform/index.d.ts.map +1 -1
- package/dist/platform/index.js +1 -1
- package/dist/platform/index.js.map +1 -1
- package/dist/platform/llm-call-log.d.ts +80 -0
- package/dist/platform/llm-call-log.d.ts.map +1 -0
- package/dist/platform/llm-call-log.js +12 -0
- package/dist/platform/llm-call-log.js.map +1 -0
- package/dist/platform/scheduler.d.ts +32 -0
- package/dist/platform/scheduler.d.ts.map +1 -0
- package/dist/platform/scheduler.js +46 -0
- package/dist/platform/scheduler.js.map +1 -0
- package/dist/platform/session-log.d.ts +36 -0
- package/dist/platform/session-log.d.ts.map +1 -0
- package/dist/platform/session-log.js +12 -0
- package/dist/platform/session-log.js.map +1 -0
- package/dist/platform/shell.d.ts +83 -0
- package/dist/platform/shell.d.ts.map +1 -0
- package/dist/platform/shell.js +13 -0
- package/dist/platform/shell.js.map +1 -0
- package/dist/plugins/agent-status/plugin.d.ts.map +1 -1
- package/dist/plugins/agent-status/plugin.js +1 -0
- package/dist/plugins/agent-status/plugin.js.map +1 -1
- package/dist/plugins/agents/plugin.d.ts.map +1 -1
- package/dist/plugins/agents/plugin.js +129 -62
- package/dist/plugins/agents/plugin.js.map +1 -1
- package/dist/plugins/filesystem/listing.d.ts +3 -0
- package/dist/plugins/filesystem/listing.d.ts.map +1 -1
- package/dist/plugins/filesystem/listing.js +66 -10
- package/dist/plugins/filesystem/listing.js.map +1 -1
- package/dist/plugins/filesystem/plugin.d.ts.map +1 -1
- package/dist/plugins/filesystem/plugin.js +8 -6
- package/dist/plugins/filesystem/plugin.js.map +1 -1
- package/dist/plugins/git-status/plugin.d.ts +34 -7
- package/dist/plugins/git-status/plugin.d.ts.map +1 -1
- package/dist/plugins/git-status/plugin.js +168 -64
- package/dist/plugins/git-status/plugin.js.map +1 -1
- package/dist/plugins/llm-debug/plugin.d.ts.map +1 -1
- package/dist/plugins/llm-debug/plugin.js +1 -0
- package/dist/plugins/llm-debug/plugin.js.map +1 -1
- package/dist/plugins/logs/plugin.d.ts +1 -4
- package/dist/plugins/logs/plugin.d.ts.map +1 -1
- package/dist/plugins/logs/plugin.js +7 -0
- package/dist/plugins/logs/plugin.js.map +1 -1
- package/dist/plugins/mailbox/helpers.d.ts +2 -2
- package/dist/plugins/mailbox/helpers.js +1 -1
- package/dist/plugins/mailbox/plugin.d.ts.map +1 -1
- package/dist/plugins/mailbox/plugin.js +38 -43
- package/dist/plugins/mailbox/plugin.js.map +1 -1
- package/dist/plugins/mailbox/query.d.ts +7 -2
- package/dist/plugins/mailbox/query.d.ts.map +1 -1
- package/dist/plugins/mailbox/query.js +14 -7
- package/dist/plugins/mailbox/query.js.map +1 -1
- package/dist/plugins/mailbox/state.d.ts +5 -4
- package/dist/plugins/mailbox/state.d.ts.map +1 -1
- package/dist/plugins/mailbox/state.js +6 -5
- package/dist/plugins/mailbox/state.js.map +1 -1
- package/dist/plugins/resources/filename.d.ts +4 -0
- package/dist/plugins/resources/filename.d.ts.map +1 -0
- package/dist/plugins/resources/filename.js +18 -0
- package/dist/plugins/resources/filename.js.map +1 -0
- package/dist/plugins/resources/plugin.d.ts +3 -0
- package/dist/plugins/resources/plugin.d.ts.map +1 -1
- package/dist/plugins/resources/plugin.js +97 -60
- package/dist/plugins/resources/plugin.js.map +1 -1
- package/dist/plugins/resources/state.d.ts +1 -1
- package/dist/plugins/resources/state.js +1 -1
- package/dist/plugins/result-eviction/plugin.d.ts.map +1 -1
- package/dist/plugins/result-eviction/plugin.js +6 -1
- package/dist/plugins/result-eviction/plugin.js.map +1 -1
- package/dist/plugins/services/plugin.d.ts +4 -1
- package/dist/plugins/services/plugin.d.ts.map +1 -1
- package/dist/plugins/services/plugin.js +251 -100
- package/dist/plugins/services/plugin.js.map +1 -1
- package/dist/plugins/services/prompt.d.ts.map +1 -1
- package/dist/plugins/services/prompt.js +1 -4
- package/dist/plugins/services/prompt.js.map +1 -1
- package/dist/plugins/services/schema.d.ts +15 -5
- package/dist/plugins/services/schema.d.ts.map +1 -1
- package/dist/plugins/services/service.d.ts +100 -18
- package/dist/plugins/services/service.d.ts.map +1 -1
- package/dist/plugins/services/service.js +680 -230
- package/dist/plugins/services/service.js.map +1 -1
- package/dist/plugins/session-lifecycle/plugin.d.ts +21 -1
- package/dist/plugins/session-lifecycle/plugin.d.ts.map +1 -1
- package/dist/plugins/session-lifecycle/plugin.js +53 -40
- package/dist/plugins/session-lifecycle/plugin.js.map +1 -1
- package/dist/plugins/session-state/plugin.d.ts +21 -13
- package/dist/plugins/session-state/plugin.d.ts.map +1 -1
- package/dist/plugins/session-state/plugin.js +214 -79
- package/dist/plugins/session-state/plugin.js.map +1 -1
- package/dist/plugins/session-stats/plugin.d.ts.map +1 -1
- package/dist/plugins/session-stats/plugin.js +1 -0
- package/dist/plugins/session-stats/plugin.js.map +1 -1
- package/dist/plugins/shell/executor.d.ts +17 -15
- package/dist/plugins/shell/executor.d.ts.map +1 -1
- package/dist/plugins/shell/executor.js +130 -195
- package/dist/plugins/shell/executor.js.map +1 -1
- package/dist/plugins/shell/index.d.ts +2 -2
- package/dist/plugins/shell/index.d.ts.map +1 -1
- package/dist/plugins/shell/index.js +2 -2
- package/dist/plugins/shell/index.js.map +1 -1
- package/dist/plugins/shell/plugin.d.ts +5 -4
- package/dist/plugins/shell/plugin.d.ts.map +1 -1
- package/dist/plugins/shell/plugin.js +4 -8
- package/dist/plugins/shell/plugin.js.map +1 -1
- package/dist/plugins/skills/discovery.d.ts.map +1 -1
- package/dist/plugins/skills/discovery.js +10 -8
- package/dist/plugins/skills/discovery.js.map +1 -1
- package/dist/plugins/skills/index.d.ts +1 -1
- package/dist/plugins/skills/index.d.ts.map +1 -1
- package/dist/plugins/skills/plugin.d.ts +1 -1
- package/dist/plugins/skills/plugin.d.ts.map +1 -1
- package/dist/plugins/skills/plugin.js +23 -30
- package/dist/plugins/skills/plugin.js.map +1 -1
- package/dist/plugins/skills/prompts.d.ts +3 -3
- package/dist/plugins/skills/prompts.d.ts.map +1 -1
- package/dist/plugins/skills/prompts.js.map +1 -1
- package/dist/plugins/skills/schema.d.ts +4 -2
- package/dist/plugins/skills/schema.d.ts.map +1 -1
- package/dist/plugins/todo/schema.d.ts +1 -1
- package/dist/plugins/uploads/plugin.d.ts +11 -4
- package/dist/plugins/uploads/plugin.d.ts.map +1 -1
- package/dist/plugins/uploads/plugin.js +891 -225
- package/dist/plugins/uploads/plugin.js.map +1 -1
- package/dist/plugins/uploads/preprocessor.d.ts +14 -0
- package/dist/plugins/uploads/preprocessor.d.ts.map +1 -1
- package/dist/plugins/uploads/preprocessor.js +11 -0
- package/dist/plugins/uploads/preprocessor.js.map +1 -1
- package/dist/plugins/uploads/preprocessors/image-classifier.d.ts +1 -1
- package/dist/plugins/uploads/preprocessors/image-classifier.d.ts.map +1 -1
- package/dist/plugins/uploads/preprocessors/image-classifier.js +51 -26
- package/dist/plugins/uploads/preprocessors/image-classifier.js.map +1 -1
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.d.ts +2 -2
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.d.ts.map +1 -1
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.js +41 -16
- package/dist/plugins/uploads/preprocessors/markitdown-preprocessor.js.map +1 -1
- package/dist/plugins/uploads/preprocessors/pdf-preprocessor.d.ts +1 -1
- package/dist/plugins/uploads/preprocessors/pdf-preprocessor.d.ts.map +1 -1
- package/dist/plugins/uploads/preprocessors/pdf-preprocessor.js +29 -14
- package/dist/plugins/uploads/preprocessors/pdf-preprocessor.js.map +1 -1
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.d.ts +1 -1
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.d.ts.map +1 -1
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.js +62 -34
- package/dist/plugins/uploads/preprocessors/zip-preprocessor.js.map +1 -1
- package/dist/plugins/uploads/schema.d.ts +25 -2
- package/dist/plugins/uploads/schema.d.ts.map +1 -1
- package/dist/plugins/uploads/schema.js +24 -3
- package/dist/plugins/uploads/schema.js.map +1 -1
- package/dist/plugins/uploads/state.d.ts +13 -1
- package/dist/plugins/uploads/state.d.ts.map +1 -1
- package/dist/plugins/uploads/state.js +4 -1
- package/dist/plugins/uploads/state.js.map +1 -1
- package/dist/plugins/user-chat/plugin.d.ts +12 -5
- package/dist/plugins/user-chat/plugin.d.ts.map +1 -1
- package/dist/plugins/user-chat/plugin.js +141 -32
- package/dist/plugins/user-chat/plugin.js.map +1 -1
- package/dist/plugins/workers/context.d.ts +35 -13
- package/dist/plugins/workers/context.d.ts.map +1 -1
- package/dist/plugins/workers/context.js +82 -32
- package/dist/plugins/workers/context.js.map +1 -1
- package/dist/plugins/workers/definition.d.ts +7 -0
- package/dist/plugins/workers/definition.d.ts.map +1 -1
- package/dist/plugins/workers/definition.js.map +1 -1
- package/dist/plugins/workers/index.d.ts +4 -4
- package/dist/plugins/workers/index.d.ts.map +1 -1
- package/dist/plugins/workers/index.js +2 -2
- package/dist/plugins/workers/index.js.map +1 -1
- package/dist/plugins/workers/plugin.d.ts +10 -57
- package/dist/plugins/workers/plugin.d.ts.map +1 -1
- package/dist/plugins/workers/plugin.js +385 -123
- package/dist/plugins/workers/plugin.js.map +1 -1
- package/dist/plugins/workers/state.d.ts +69 -0
- package/dist/plugins/workers/state.d.ts.map +1 -0
- package/dist/plugins/workers/state.js +52 -0
- package/dist/plugins/workers/state.js.map +1 -0
- package/dist/plugins/workers/worker.d.ts +15 -4
- package/dist/plugins/workers/worker.d.ts.map +1 -1
- package/dist/testing/conformance.d.ts +106 -0
- package/dist/testing/conformance.d.ts.map +1 -0
- package/dist/testing/conformance.js +1463 -0
- package/dist/testing/conformance.js.map +1 -0
- package/dist/testing/node-platform.d.ts.map +1 -1
- package/dist/testing/node-platform.js +5 -0
- package/dist/testing/node-platform.js.map +1 -1
- package/dist/testing/test-harness.d.ts +11 -1
- package/dist/testing/test-harness.d.ts.map +1 -1
- package/dist/testing/test-harness.js +17 -37
- package/dist/testing/test-harness.js.map +1 -1
- package/dist/testing/wait-helpers.d.ts.map +1 -1
- package/dist/testing/wait-helpers.js +1 -3
- package/dist/testing/wait-helpers.js.map +1 -1
- package/dist/transport/adapter/client-adapter.d.ts +6 -0
- package/dist/transport/adapter/client-adapter.d.ts.map +1 -1
- package/dist/transport/adapter/client-adapter.js +50 -3
- package/dist/transport/adapter/client-adapter.js.map +1 -1
- package/dist/transport/adapter/heartbeat.d.ts +16 -0
- package/dist/transport/adapter/heartbeat.d.ts.map +1 -0
- package/dist/transport/adapter/heartbeat.js +41 -0
- package/dist/transport/adapter/heartbeat.js.map +1 -0
- package/dist/transport/adapter/server-adapter.d.ts.map +1 -1
- package/dist/transport/adapter/server-adapter.js +6 -0
- package/dist/transport/adapter/server-adapter.js.map +1 -1
- package/dist/transport/http/app.d.ts +3 -30
- package/dist/transport/http/app.d.ts.map +1 -1
- package/dist/transport/http/app.js +3 -7
- package/dist/transport/http/app.js.map +1 -1
- package/dist/transport/http/context.d.ts +40 -0
- package/dist/transport/http/context.d.ts.map +1 -0
- package/dist/transport/http/context.js +17 -0
- package/dist/transport/http/context.js.map +1 -0
- package/dist/transport/http/fetch-guard.d.ts +49 -0
- package/dist/transport/http/fetch-guard.d.ts.map +1 -0
- package/dist/transport/http/fetch-guard.js +312 -0
- package/dist/transport/http/fetch-guard.js.map +1 -0
- package/dist/transport/http/index.d.ts +1 -1
- package/dist/transport/http/index.d.ts.map +1 -1
- package/dist/transport/http/middleware/bearer-auth.d.ts +1 -1
- package/dist/transport/http/middleware/bearer-auth.d.ts.map +1 -1
- package/dist/transport/http/middleware/error-handler.d.ts +2 -2
- package/dist/transport/http/middleware/error-handler.d.ts.map +1 -1
- package/dist/transport/http/path-containment.d.ts +20 -0
- package/dist/transport/http/path-containment.d.ts.map +1 -0
- package/dist/transport/http/path-containment.js +31 -0
- package/dist/transport/http/path-containment.js.map +1 -0
- package/dist/transport/http/responses.d.ts +30 -0
- package/dist/transport/http/responses.d.ts.map +1 -0
- package/dist/transport/http/responses.js +5 -0
- package/dist/transport/http/responses.js.map +1 -0
- package/dist/transport/http/routes/files.d.ts +1 -1
- package/dist/transport/http/routes/files.d.ts.map +1 -1
- package/dist/transport/http/routes/files.js +54 -155
- package/dist/transport/http/routes/files.js.map +1 -1
- package/dist/transport/http/routes/resources.d.ts +1 -1
- package/dist/transport/http/routes/resources.d.ts.map +1 -1
- package/dist/transport/http/routes/resources.js +92 -57
- package/dist/transport/http/routes/resources.js.map +1 -1
- package/dist/transport/http/routes/rpc.d.ts +6 -1
- package/dist/transport/http/routes/rpc.d.ts.map +1 -1
- package/dist/transport/http/routes/rpc.js +51 -21
- package/dist/transport/http/routes/rpc.js.map +1 -1
- package/dist/transport/http/routes/upload.d.ts +1 -1
- package/dist/transport/http/routes/upload.d.ts.map +1 -1
- package/dist/transport/http/routes/upload.js +256 -169
- package/dist/transport/http/routes/upload.js.map +1 -1
- package/dist/user-config.d.ts +34 -7
- package/dist/user-config.d.ts.map +1 -1
- package/dist/user-config.js +71 -0
- package/dist/user-config.js.map +1 -1
- package/package.json +18 -8
- package/src/bootstrap.ts +119 -35
- package/src/bun-platform/fs.ts +1 -0
- package/src/bun-platform/index.ts +18 -1
- package/src/bun-platform/server-lifecycle.ts +218 -0
- package/src/bun-platform/shell.ts +362 -0
- package/src/config.ts +130 -0
- package/src/core/agents/agent.ts +219 -95
- package/src/core/agents/config.ts +8 -0
- package/src/core/agents/retry.ts +16 -17
- package/src/core/agents/state.ts +28 -0
- package/src/core/context/state.ts +4 -0
- package/src/core/events/base-event-store.ts +24 -16
- package/src/core/events/file.ts +198 -22
- package/src/core/file-store/containment.ts +75 -0
- package/src/core/file-store/file-store.ts +106 -25
- package/src/core/file-store/types.ts +14 -1
- package/src/core/image/image-processor.ts +3 -1
- package/src/core/image/types.ts +2 -0
- package/src/core/image/vips-resizer.ts +102 -37
- package/src/core/llm/anthropic.ts +127 -82
- package/src/core/llm/logger.ts +175 -37
- package/src/core/llm/openrouter.ts +82 -81
- package/src/core/llm/provider-request.ts +40 -0
- package/src/core/llm/provider.ts +72 -3
- package/src/core/llm/state.ts +12 -0
- package/src/core/plugins/plugin-builder.ts +106 -14
- package/src/core/preset/preset-builder.ts +12 -22
- package/src/core/sessions/context.ts +18 -0
- package/src/core/sessions/runtime-activity.ts +78 -0
- package/src/core/sessions/schema.ts +29 -3
- package/src/core/sessions/session-manager.ts +560 -140
- package/src/core/sessions/session-store.ts +38 -0
- package/src/core/sessions/session.ts +187 -47
- package/src/core/sessions/state.ts +16 -0
- package/src/core/system.ts +15 -0
- package/src/core/wake-key.ts +65 -0
- package/src/index.ts +31 -12
- package/src/lib/archive/archive-inspection.fixtures.ts +138 -0
- package/src/lib/archive/archive-inspection.ts +359 -0
- package/src/lib/archive/index.ts +17 -0
- package/src/lib/logger/console.ts +7 -57
- package/src/lib/logger/file.ts +28 -50
- package/src/lib/logger/index.ts +3 -1
- package/src/lib/logger/jsonl.ts +36 -0
- package/src/lib/logger/logger.ts +48 -0
- package/src/lib/logger/session-log.ts +42 -0
- package/src/lib/utils/concurrency.ts +37 -8
- package/src/lib/utils/fs-batch.ts +49 -0
- package/src/lib/utils/result.ts +7 -31
- package/src/lib/utils/sleep.ts +23 -0
- package/src/platform/fs-revision.ts +21 -0
- package/src/platform/fs.ts +109 -1
- package/src/platform/git.ts +67 -0
- package/src/platform/index.ts +51 -1
- package/src/platform/llm-call-log.ts +86 -0
- package/src/platform/scheduler.ts +71 -0
- package/src/platform/session-log.ts +39 -0
- package/src/platform/shell.ts +89 -0
- package/src/plugins/agent-status/plugin.ts +1 -0
- package/src/plugins/agents/plugin.ts +134 -81
- package/src/plugins/filesystem/listing.ts +70 -12
- package/src/plugins/filesystem/plugin.ts +8 -6
- package/src/plugins/git-status/plugin.ts +204 -77
- package/src/plugins/llm-debug/plugin.ts +1 -0
- package/src/plugins/logs/plugin.ts +9 -0
- package/src/plugins/mailbox/plugin.ts +46 -64
- package/src/plugins/mailbox/query.ts +15 -7
- package/src/plugins/mailbox/state.ts +1 -0
- package/src/plugins/resources/filename.ts +19 -0
- package/src/plugins/resources/plugin.ts +111 -59
- package/src/plugins/result-eviction/plugin.ts +6 -1
- package/src/plugins/services/plugin.ts +254 -98
- package/src/plugins/services/prompt.ts +1 -6
- package/src/plugins/services/schema.ts +17 -3
- package/src/plugins/services/service.ts +702 -252
- package/src/plugins/session-lifecycle/plugin.ts +56 -41
- package/src/plugins/session-state/plugin.ts +242 -88
- package/src/plugins/session-stats/plugin.ts +1 -0
- package/src/plugins/shell/executor.ts +144 -226
- package/src/plugins/shell/index.ts +1 -4
- package/src/plugins/shell/plugin.ts +7 -9
- package/src/plugins/skills/discovery.ts +10 -8
- package/src/plugins/skills/index.ts +1 -1
- package/src/plugins/skills/plugin.ts +19 -27
- package/src/plugins/skills/prompts.ts +3 -3
- package/src/plugins/skills/schema.ts +5 -2
- package/src/plugins/uploads/plugin.ts +991 -273
- package/src/plugins/uploads/preprocessor.ts +25 -0
- package/src/plugins/uploads/preprocessors/image-classifier.ts +56 -25
- package/src/plugins/uploads/preprocessors/markitdown-preprocessor.ts +41 -15
- package/src/plugins/uploads/preprocessors/pdf-preprocessor.ts +32 -16
- package/src/plugins/uploads/preprocessors/zip-preprocessor.ts +67 -38
- package/src/plugins/uploads/schema.ts +30 -3
- package/src/plugins/uploads/state.ts +12 -0
- package/src/plugins/user-chat/plugin.ts +196 -40
- package/src/plugins/workers/context.ts +102 -39
- package/src/plugins/workers/definition.ts +7 -0
- package/src/plugins/workers/index.ts +4 -4
- package/src/plugins/workers/plugin.ts +461 -151
- package/src/plugins/workers/state.ts +64 -0
- package/src/plugins/workers/worker.ts +15 -4
- package/src/testing/conformance.ts +1751 -0
- package/src/testing/node-platform.ts +5 -0
- package/src/testing/test-harness.ts +21 -38
- package/src/testing/wait-helpers.ts +1 -4
- package/src/transport/adapter/client-adapter.ts +60 -3
- package/src/transport/adapter/heartbeat.ts +50 -0
- package/src/transport/adapter/server-adapter.ts +6 -0
- package/src/transport/http/app.ts +7 -35
- package/src/transport/http/context.ts +46 -0
- package/src/transport/http/fetch-guard.ts +318 -0
- package/src/transport/http/index.ts +1 -1
- package/src/transport/http/middleware/bearer-auth.ts +1 -1
- package/src/transport/http/middleware/error-handler.ts +1 -1
- package/src/transport/http/path-containment.ts +44 -0
- package/src/transport/http/responses.ts +20 -0
- package/src/transport/http/routes/files.ts +69 -159
- package/src/transport/http/routes/resources.ts +124 -93
- package/src/transport/http/routes/rpc.ts +63 -26
- package/src/transport/http/routes/upload.ts +327 -258
- package/src/user-config.ts +93 -7
- package/dist/config.test.d.ts +0 -2
- package/dist/config.test.d.ts.map +0 -1
- package/dist/config.test.js +0 -155
- package/dist/config.test.js.map +0 -1
- package/dist/core/agent-loop.integration.test.d.ts +0 -2
- package/dist/core/agent-loop.integration.test.d.ts.map +0 -1
- package/dist/core/agent-loop.integration.test.js +0 -414
- package/dist/core/agent-loop.integration.test.js.map +0 -1
- package/dist/core/agents/agent-config.test.d.ts +0 -2
- package/dist/core/agents/agent-config.test.d.ts.map +0 -1
- package/dist/core/agents/agent-config.test.js +0 -194
- package/dist/core/agents/agent-config.test.js.map +0 -1
- package/dist/core/agents/agent-shutdown.test.d.ts +0 -6
- package/dist/core/agents/agent-shutdown.test.d.ts.map +0 -1
- package/dist/core/agents/agent-shutdown.test.js +0 -180
- package/dist/core/agents/agent-shutdown.test.js.map +0 -1
- package/dist/core/agents/agent.test.d.ts +0 -2
- package/dist/core/agents/agent.test.d.ts.map +0 -1
- package/dist/core/agents/agent.test.js +0 -313
- package/dist/core/agents/agent.test.js.map +0 -1
- package/dist/core/agents/communicator.d.ts +0 -3
- package/dist/core/agents/communicator.d.ts.map +0 -1
- package/dist/core/agents/communicator.js +0 -13
- package/dist/core/agents/communicator.js.map +0 -1
- package/dist/core/agents/handler-events.test.d.ts +0 -5
- package/dist/core/agents/handler-events.test.d.ts.map +0 -1
- package/dist/core/agents/handler-events.test.js +0 -115
- package/dist/core/agents/handler-events.test.js.map +0 -1
- package/dist/core/agents/response-sanitizer.test.d.ts +0 -2
- package/dist/core/agents/response-sanitizer.test.d.ts.map +0 -1
- package/dist/core/agents/response-sanitizer.test.js +0 -101
- package/dist/core/agents/response-sanitizer.test.js.map +0 -1
- package/dist/core/error-recovery.integration.test.d.ts +0 -2
- package/dist/core/error-recovery.integration.test.d.ts.map +0 -1
- package/dist/core/error-recovery.integration.test.js +0 -288
- package/dist/core/error-recovery.integration.test.js.map +0 -1
- package/dist/core/event-sourcing.integration.test.d.ts +0 -2
- package/dist/core/event-sourcing.integration.test.d.ts.map +0 -1
- package/dist/core/event-sourcing.integration.test.js +0 -154
- package/dist/core/event-sourcing.integration.test.js.map +0 -1
- package/dist/core/events/file.test.d.ts +0 -2
- package/dist/core/events/file.test.d.ts.map +0 -1
- package/dist/core/events/file.test.js +0 -284
- package/dist/core/events/file.test.js.map +0 -1
- package/dist/core/events/memory.test.d.ts +0 -2
- package/dist/core/events/memory.test.d.ts.map +0 -1
- package/dist/core/events/memory.test.js +0 -502
- package/dist/core/events/memory.test.js.map +0 -1
- package/dist/core/image/image-processor.test.d.ts +0 -2
- package/dist/core/image/image-processor.test.d.ts.map +0 -1
- package/dist/core/image/image-processor.test.js +0 -171
- package/dist/core/image/image-processor.test.js.map +0 -1
- package/dist/core/image/vips-resizer.test.d.ts +0 -2
- package/dist/core/image/vips-resizer.test.d.ts.map +0 -1
- package/dist/core/image/vips-resizer.test.js +0 -336
- package/dist/core/image/vips-resizer.test.js.map +0 -1
- package/dist/core/llm/anthropic.test.d.ts +0 -2
- package/dist/core/llm/anthropic.test.d.ts.map +0 -1
- package/dist/core/llm/anthropic.test.js +0 -464
- package/dist/core/llm/anthropic.test.js.map +0 -1
- package/dist/core/llm/cache-breakpoints.test.d.ts +0 -2
- package/dist/core/llm/cache-breakpoints.test.d.ts.map +0 -1
- package/dist/core/llm/cache-breakpoints.test.js +0 -69
- package/dist/core/llm/cache-breakpoints.test.js.map +0 -1
- package/dist/core/llm/cache-live.test.d.ts +0 -16
- package/dist/core/llm/cache-live.test.d.ts.map +0 -1
- package/dist/core/llm/cache-live.test.js +0 -137
- package/dist/core/llm/cache-live.test.js.map +0 -1
- package/dist/core/llm/logger.test.d.ts +0 -7
- package/dist/core/llm/logger.test.d.ts.map +0 -1
- package/dist/core/llm/logger.test.js +0 -228
- package/dist/core/llm/logger.test.js.map +0 -1
- package/dist/core/llm/message-sanitization.test.d.ts +0 -2
- package/dist/core/llm/message-sanitization.test.d.ts.map +0 -1
- package/dist/core/llm/message-sanitization.test.js +0 -181
- package/dist/core/llm/message-sanitization.test.js.map +0 -1
- package/dist/core/llm/mock.test.d.ts +0 -2
- package/dist/core/llm/mock.test.d.ts.map +0 -1
- package/dist/core/llm/mock.test.js +0 -318
- package/dist/core/llm/mock.test.js.map +0 -1
- package/dist/core/llm/openrouter-mapping.test.d.ts +0 -2
- package/dist/core/llm/openrouter-mapping.test.d.ts.map +0 -1
- package/dist/core/llm/openrouter-mapping.test.js +0 -172
- package/dist/core/llm/openrouter-mapping.test.js.map +0 -1
- package/dist/core/llm/openrouter.test.d.ts +0 -2
- package/dist/core/llm/openrouter.test.d.ts.map +0 -1
- package/dist/core/llm/openrouter.test.js +0 -377
- package/dist/core/llm/openrouter.test.js.map +0 -1
- package/dist/core/llm/provider-integration.test.d.ts +0 -12
- package/dist/core/llm/provider-integration.test.d.ts.map +0 -1
- package/dist/core/llm/provider-integration.test.js +0 -350
- package/dist/core/llm/provider-integration.test.js.map +0 -1
- package/dist/core/llm/routing-provider.test.d.ts +0 -2
- package/dist/core/llm/routing-provider.test.d.ts.map +0 -1
- package/dist/core/llm/routing-provider.test.js +0 -94
- package/dist/core/llm/routing-provider.test.js.map +0 -1
- package/dist/core/llm/snapshot-middleware.test.d.ts +0 -2
- package/dist/core/llm/snapshot-middleware.test.d.ts.map +0 -1
- package/dist/core/llm/snapshot-middleware.test.js +0 -144
- package/dist/core/llm/snapshot-middleware.test.js.map +0 -1
- package/dist/core/multi-agent.integration.test.d.ts +0 -2
- package/dist/core/multi-agent.integration.test.d.ts.map +0 -1
- package/dist/core/multi-agent.integration.test.js +0 -298
- package/dist/core/multi-agent.integration.test.js.map +0 -1
- package/dist/core/plugin-hooks.integration.test.d.ts +0 -2
- package/dist/core/plugin-hooks.integration.test.d.ts.map +0 -1
- package/dist/core/plugin-hooks.integration.test.js +0 -458
- package/dist/core/plugin-hooks.integration.test.js.map +0 -1
- package/dist/core/session-lifecycle.integration.test.d.ts +0 -2
- package/dist/core/session-lifecycle.integration.test.d.ts.map +0 -1
- package/dist/core/session-lifecycle.integration.test.js +0 -159
- package/dist/core/session-lifecycle.integration.test.js.map +0 -1
- package/dist/core/sessions/fork-utils.test.d.ts +0 -2
- package/dist/core/sessions/fork-utils.test.d.ts.map +0 -1
- package/dist/core/sessions/fork-utils.test.js +0 -129
- package/dist/core/sessions/fork-utils.test.js.map +0 -1
- package/dist/core/sessions/session-overrides.integration.test.d.ts +0 -2
- package/dist/core/sessions/session-overrides.integration.test.d.ts.map +0 -1
- package/dist/core/sessions/session-overrides.integration.test.js +0 -154
- package/dist/core/sessions/session-overrides.integration.test.js.map +0 -1
- package/dist/core/sessions/session.test.d.ts +0 -2
- package/dist/core/sessions/session.test.d.ts.map +0 -1
- package/dist/core/sessions/session.test.js +0 -1100
- package/dist/core/sessions/session.test.js.map +0 -1
- package/dist/core/tools/executor.test.d.ts +0 -2
- package/dist/core/tools/executor.test.d.ts.map +0 -1
- package/dist/core/tools/executor.test.js +0 -144
- package/dist/core/tools/executor.test.js.map +0 -1
- package/dist/lib/logger/console.test.d.ts +0 -2
- package/dist/lib/logger/console.test.d.ts.map +0 -1
- package/dist/lib/logger/console.test.js +0 -258
- package/dist/lib/logger/console.test.js.map +0 -1
- package/dist/lib/never.d.ts +0 -2
- package/dist/lib/never.d.ts.map +0 -1
- package/dist/lib/never.js +0 -4
- package/dist/lib/never.js.map +0 -1
- package/dist/lib/utils/concurrency.test.d.ts +0 -2
- package/dist/lib/utils/concurrency.test.d.ts.map +0 -1
- package/dist/lib/utils/concurrency.test.js +0 -135
- package/dist/lib/utils/concurrency.test.js.map +0 -1
- package/dist/plugins/agent-status/agent-status.test.d.ts +0 -2
- package/dist/plugins/agent-status/agent-status.test.d.ts.map +0 -1
- package/dist/plugins/agent-status/agent-status.test.js +0 -136
- package/dist/plugins/agent-status/agent-status.test.js.map +0 -1
- package/dist/plugins/agents/agents.integration.test.d.ts +0 -2
- package/dist/plugins/agents/agents.integration.test.d.ts.map +0 -1
- package/dist/plugins/agents/agents.integration.test.js +0 -830
- package/dist/plugins/agents/agents.integration.test.js.map +0 -1
- package/dist/plugins/agents/supervision.integration.test.d.ts +0 -2
- package/dist/plugins/agents/supervision.integration.test.d.ts.map +0 -1
- package/dist/plugins/agents/supervision.integration.test.js +0 -215
- package/dist/plugins/agents/supervision.integration.test.js.map +0 -1
- package/dist/plugins/context-compact/compaction-live.test.d.ts +0 -17
- package/dist/plugins/context-compact/compaction-live.test.d.ts.map +0 -1
- package/dist/plugins/context-compact/compaction-live.test.js +0 -177
- package/dist/plugins/context-compact/compaction-live.test.js.map +0 -1
- package/dist/plugins/context-compact/context-compact.integration.test.d.ts +0 -2
- package/dist/plugins/context-compact/context-compact.integration.test.d.ts.map +0 -1
- package/dist/plugins/context-compact/context-compact.integration.test.js +0 -364
- package/dist/plugins/context-compact/context-compact.integration.test.js.map +0 -1
- package/dist/plugins/context-compact/context-compactor.test.d.ts +0 -2
- package/dist/plugins/context-compact/context-compactor.test.d.ts.map +0 -1
- package/dist/plugins/context-compact/context-compactor.test.js +0 -858
- package/dist/plugins/context-compact/context-compactor.test.js.map +0 -1
- package/dist/plugins/context-compact/history-offloader.test.d.ts +0 -2
- package/dist/plugins/context-compact/history-offloader.test.d.ts.map +0 -1
- package/dist/plugins/context-compact/history-offloader.test.js +0 -77
- package/dist/plugins/context-compact/history-offloader.test.js.map +0 -1
- package/dist/plugins/filesystem/filesystem.integration.test.d.ts +0 -2
- package/dist/plugins/filesystem/filesystem.integration.test.d.ts.map +0 -1
- package/dist/plugins/filesystem/filesystem.integration.test.js +0 -447
- package/dist/plugins/filesystem/filesystem.integration.test.js.map +0 -1
- package/dist/plugins/filesystem/schema.d.ts +0 -7
- package/dist/plugins/filesystem/schema.d.ts.map +0 -1
- package/dist/plugins/filesystem/schema.js +0 -2
- package/dist/plugins/filesystem/schema.js.map +0 -1
- package/dist/plugins/limits-guard/limit-guard.test.d.ts +0 -2
- package/dist/plugins/limits-guard/limit-guard.test.d.ts.map +0 -1
- package/dist/plugins/limits-guard/limit-guard.test.js +0 -194
- package/dist/plugins/limits-guard/limit-guard.test.js.map +0 -1
- package/dist/plugins/limits-guard/limits-guard.integration.test.d.ts +0 -2
- package/dist/plugins/limits-guard/limits-guard.integration.test.d.ts.map +0 -1
- package/dist/plugins/limits-guard/limits-guard.integration.test.js +0 -887
- package/dist/plugins/limits-guard/limits-guard.integration.test.js.map +0 -1
- package/dist/plugins/llm-debug/llm-debug.integration.test.d.ts +0 -2
- package/dist/plugins/llm-debug/llm-debug.integration.test.d.ts.map +0 -1
- package/dist/plugins/llm-debug/llm-debug.integration.test.js +0 -157
- package/dist/plugins/llm-debug/llm-debug.integration.test.js.map +0 -1
- package/dist/plugins/mailbox/mailbox.integration.test.d.ts +0 -2
- package/dist/plugins/mailbox/mailbox.integration.test.d.ts.map +0 -1
- package/dist/plugins/mailbox/mailbox.integration.test.js +0 -678
- package/dist/plugins/mailbox/mailbox.integration.test.js.map +0 -1
- package/dist/plugins/resources/resources.integration.test.d.ts +0 -2
- package/dist/plugins/resources/resources.integration.test.d.ts.map +0 -1
- package/dist/plugins/resources/resources.integration.test.js +0 -62
- package/dist/plugins/resources/resources.integration.test.js.map +0 -1
- package/dist/plugins/result-eviction/result-eviction.integration.test.d.ts +0 -2
- package/dist/plugins/result-eviction/result-eviction.integration.test.d.ts.map +0 -1
- package/dist/plugins/result-eviction/result-eviction.integration.test.js +0 -294
- package/dist/plugins/result-eviction/result-eviction.integration.test.js.map +0 -1
- package/dist/plugins/services/pid-registry.test.d.ts +0 -2
- package/dist/plugins/services/pid-registry.test.d.ts.map +0 -1
- package/dist/plugins/services/pid-registry.test.js +0 -161
- package/dist/plugins/services/pid-registry.test.js.map +0 -1
- package/dist/plugins/services/services.integration.test.d.ts +0 -2
- package/dist/plugins/services/services.integration.test.d.ts.map +0 -1
- package/dist/plugins/services/services.integration.test.js +0 -1057
- package/dist/plugins/services/services.integration.test.js.map +0 -1
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.d.ts +0 -2
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.d.ts.map +0 -1
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.js +0 -498
- package/dist/plugins/session-lifecycle/session-lifecycle.integration.test.js.map +0 -1
- package/dist/plugins/session-stats/plugin.test.d.ts +0 -2
- package/dist/plugins/session-stats/plugin.test.d.ts.map +0 -1
- package/dist/plugins/session-stats/plugin.test.js +0 -145
- package/dist/plugins/session-stats/plugin.test.js.map +0 -1
- package/dist/plugins/shell/shell.integration.test.d.ts +0 -2
- package/dist/plugins/shell/shell.integration.test.d.ts.map +0 -1
- package/dist/plugins/shell/shell.integration.test.js +0 -234
- package/dist/plugins/shell/shell.integration.test.js.map +0 -1
- package/dist/plugins/shell/shell.test.d.ts +0 -2
- package/dist/plugins/shell/shell.test.d.ts.map +0 -1
- package/dist/plugins/shell/shell.test.js +0 -236
- package/dist/plugins/shell/shell.test.js.map +0 -1
- package/dist/plugins/skills/discovery.test.d.ts +0 -2
- package/dist/plugins/skills/discovery.test.d.ts.map +0 -1
- package/dist/plugins/skills/discovery.test.js +0 -312
- package/dist/plugins/skills/discovery.test.js.map +0 -1
- package/dist/plugins/skills/skills.integration.test.d.ts +0 -2
- package/dist/plugins/skills/skills.integration.test.d.ts.map +0 -1
- package/dist/plugins/skills/skills.integration.test.js +0 -475
- package/dist/plugins/skills/skills.integration.test.js.map +0 -1
- package/dist/plugins/todo/todo.integration.test.d.ts +0 -2
- package/dist/plugins/todo/todo.integration.test.d.ts.map +0 -1
- package/dist/plugins/todo/todo.integration.test.js +0 -605
- package/dist/plugins/todo/todo.integration.test.js.map +0 -1
- package/dist/plugins/uploads/preprocessors/image-classifier.test.d.ts +0 -2
- package/dist/plugins/uploads/preprocessors/image-classifier.test.d.ts.map +0 -1
- package/dist/plugins/uploads/preprocessors/image-classifier.test.js +0 -113
- package/dist/plugins/uploads/preprocessors/image-classifier.test.js.map +0 -1
- package/dist/plugins/uploads/uploads.integration.test.d.ts +0 -2
- package/dist/plugins/uploads/uploads.integration.test.d.ts.map +0 -1
- package/dist/plugins/uploads/uploads.integration.test.js +0 -639
- package/dist/plugins/uploads/uploads.integration.test.js.map +0 -1
- package/dist/plugins/user-chat/user-chat.integration.test.d.ts +0 -2
- package/dist/plugins/user-chat/user-chat.integration.test.d.ts.map +0 -1
- package/dist/plugins/user-chat/user-chat.integration.test.js +0 -754
- package/dist/plugins/user-chat/user-chat.integration.test.js.map +0 -1
- package/dist/plugins/workers/workers.integration.test.d.ts +0 -2
- package/dist/plugins/workers/workers.integration.test.d.ts.map +0 -1
- package/dist/plugins/workers/workers.integration.test.js +0 -629
- package/dist/plugins/workers/workers.integration.test.js.map +0 -1
- package/dist/prompts/macros.test.d.ts +0 -2
- package/dist/prompts/macros.test.d.ts.map +0 -1
- package/dist/prompts/macros.test.js +0 -80
- package/dist/prompts/macros.test.js.map +0 -1
- package/dist/testing/test-harness.test.d.ts +0 -2
- package/dist/testing/test-harness.test.d.ts.map +0 -1
- package/dist/testing/test-harness.test.js +0 -92
- package/dist/testing/test-harness.test.js.map +0 -1
- package/dist/transport/http/routes/rpc.integration.test.d.ts +0 -2
- package/dist/transport/http/routes/rpc.integration.test.d.ts.map +0 -1
- package/dist/transport/http/routes/rpc.integration.test.js +0 -189
- package/dist/transport/http/routes/rpc.integration.test.js.map +0 -1
- package/dist/transport/http/routes/rpc.test.d.ts +0 -2
- package/dist/transport/http/routes/rpc.test.d.ts.map +0 -1
- package/dist/transport/http/routes/rpc.test.js +0 -316
- package/dist/transport/http/routes/rpc.test.js.map +0 -1
- package/src/config.test.ts +0 -174
- package/src/core/agent-loop.integration.test.ts +0 -503
- package/src/core/agents/agent-config.test.ts +0 -240
- package/src/core/agents/agent-shutdown.test.ts +0 -236
- package/src/core/agents/agent.test.ts +0 -387
- package/src/core/agents/communicator.ts +0 -16
- package/src/core/agents/handler-events.test.ts +0 -167
- package/src/core/agents/response-sanitizer.test.ts +0 -137
- package/src/core/error-recovery.integration.test.ts +0 -343
- package/src/core/event-sourcing.integration.test.ts +0 -191
- package/src/core/events/file.test.ts +0 -436
- package/src/core/events/memory.test.ts +0 -741
- package/src/core/image/image-processor.test.ts +0 -218
- package/src/core/image/vips-resizer.test.ts +0 -388
- package/src/core/llm/anthropic.test.ts +0 -546
- package/src/core/llm/cache-breakpoints.test.ts +0 -85
- package/src/core/llm/cache-live.test.ts +0 -155
- package/src/core/llm/logger.test.ts +0 -270
- package/src/core/llm/message-sanitization.test.ts +0 -217
- package/src/core/llm/mock.test.ts +0 -402
- package/src/core/llm/openrouter-mapping.test.ts +0 -210
- package/src/core/llm/openrouter.test.ts +0 -499
- package/src/core/llm/provider-integration.test.ts +0 -408
- package/src/core/llm/routing-provider.test.ts +0 -113
- package/src/core/llm/snapshot-middleware.test.ts +0 -168
- package/src/core/multi-agent.integration.test.ts +0 -340
- package/src/core/plugin-hooks.integration.test.ts +0 -568
- package/src/core/session-lifecycle.integration.test.ts +0 -202
- package/src/core/sessions/fork-utils.test.ts +0 -158
- package/src/core/sessions/session-overrides.integration.test.ts +0 -210
- package/src/core/sessions/session.test.ts +0 -1736
- package/src/core/tools/executor.test.ts +0 -161
- package/src/lib/logger/console.test.ts +0 -348
- package/src/lib/never.ts +0 -3
- package/src/lib/utils/concurrency.test.ts +0 -169
- package/src/plugins/agent-status/agent-status.test.ts +0 -164
- package/src/plugins/agents/agents.integration.test.ts +0 -976
- package/src/plugins/agents/supervision.integration.test.ts +0 -249
- package/src/plugins/context-compact/compaction-live.test.ts +0 -221
- package/src/plugins/context-compact/context-compact.integration.test.ts +0 -418
- package/src/plugins/context-compact/context-compactor.test.ts +0 -1036
- package/src/plugins/context-compact/history-offloader.test.ts +0 -100
- package/src/plugins/filesystem/filesystem.integration.test.ts +0 -529
- package/src/plugins/filesystem/schema.ts +0 -6
- package/src/plugins/limits-guard/limit-guard.test.ts +0 -253
- package/src/plugins/limits-guard/limits-guard.integration.test.ts +0 -1012
- package/src/plugins/llm-debug/llm-debug.integration.test.ts +0 -192
- package/src/plugins/mailbox/mailbox.integration.test.ts +0 -794
- package/src/plugins/resources/resources.integration.test.ts +0 -68
- package/src/plugins/result-eviction/result-eviction.integration.test.ts +0 -332
- package/src/plugins/services/pid-registry.test.ts +0 -180
- package/src/plugins/services/services.integration.test.ts +0 -1223
- package/src/plugins/session-lifecycle/session-lifecycle.integration.test.ts +0 -639
- package/src/plugins/session-stats/plugin.test.ts +0 -160
- package/src/plugins/shell/shell.integration.test.ts +0 -273
- package/src/plugins/shell/shell.test.ts +0 -314
- package/src/plugins/skills/discovery.test.ts +0 -395
- package/src/plugins/skills/skills.integration.test.ts +0 -580
- package/src/plugins/todo/todo.integration.test.ts +0 -687
- package/src/plugins/uploads/preprocessors/image-classifier.test.ts +0 -142
- package/src/plugins/uploads/uploads.integration.test.ts +0 -831
- package/src/plugins/user-chat/user-chat.integration.test.ts +0 -893
- package/src/plugins/workers/workers.integration.test.ts +0 -778
- package/src/prompts/macros.test.ts +0 -107
- package/src/testing/test-harness.test.ts +0 -114
- package/src/transport/http/routes/rpc.integration.test.ts +0 -243
- package/src/transport/http/routes/rpc.test.ts +0 -372
|
@@ -19,6 +19,15 @@ import { getAgentState, reconstructSessionState } from '~/core/sessions/state.js
|
|
|
19
19
|
// SessionStore
|
|
20
20
|
// ============================================================================
|
|
21
21
|
|
|
22
|
+
/** Thrown when a disposed runtime tries to append — see {@link SessionStore.detach}. */
|
|
23
|
+
export class SessionRuntimeDetachedError extends Error {
|
|
24
|
+
constructor(readonly sessionId: SessionId, events: readonly DomainEvent[]) {
|
|
25
|
+
const types = [...new Set(events.map((event) => event.type))].join(', ')
|
|
26
|
+
super(`Session runtime for '${sessionId}' is disposed and cannot append events: ${types}`)
|
|
27
|
+
this.name = 'SessionRuntimeDetachedError'
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
22
31
|
/**
|
|
23
32
|
* SessionStore wraps EventStore and provides:
|
|
24
33
|
* - Event emission with automatic state updates
|
|
@@ -29,6 +38,7 @@ export class SessionStore {
|
|
|
29
38
|
private _state: SessionState
|
|
30
39
|
private readonly eventListeners: Array<(event: DomainEvent) => void> = []
|
|
31
40
|
private readonly applyEvent: SessionReducer
|
|
41
|
+
private detached = false
|
|
32
42
|
|
|
33
43
|
constructor(
|
|
34
44
|
readonly sessionId: SessionId,
|
|
@@ -59,6 +69,22 @@ export class SessionStore {
|
|
|
59
69
|
this.eventListeners.length = 0
|
|
60
70
|
}
|
|
61
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Fence the store off from its disposed runtime — later emits fail instead of writing.
|
|
74
|
+
*
|
|
75
|
+
* The manager rebuilds an evicted session from the log, so a late write from the
|
|
76
|
+
* old runtime (an abandoned worker, a timer, a settled effect) would land durably
|
|
77
|
+
* while only the dead projection saw it, and the live one would never catch up.
|
|
78
|
+
*/
|
|
79
|
+
detach(): void {
|
|
80
|
+
this.detached = true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** True once the owning runtime was disposed and the store stopped accepting writes. */
|
|
84
|
+
isDetached(): boolean {
|
|
85
|
+
return this.detached
|
|
86
|
+
}
|
|
87
|
+
|
|
62
88
|
/**
|
|
63
89
|
* Create a new SessionStore by loading events from EventStore.
|
|
64
90
|
* Also validates and reconciles metadata if out of sync (e.g., after crash).
|
|
@@ -69,6 +95,16 @@ export class SessionStore {
|
|
|
69
95
|
applyEvent?: SessionReducer,
|
|
70
96
|
): Promise<SessionStore | null> {
|
|
71
97
|
const events = await eventStore.load(sessionId)
|
|
98
|
+
return SessionStore.fromEvents(sessionId, eventStore, events, applyEvent)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Build a store from an event log that the caller already loaded. */
|
|
102
|
+
static async fromEvents(
|
|
103
|
+
sessionId: SessionId,
|
|
104
|
+
eventStore: EventStore,
|
|
105
|
+
events: DomainEvent[],
|
|
106
|
+
applyEvent?: SessionReducer,
|
|
107
|
+
): Promise<SessionStore | null> {
|
|
72
108
|
if (events.length === 0) return null
|
|
73
109
|
|
|
74
110
|
const state = reconstructSessionState(events, applyEvent ?? coreApplyEvent)
|
|
@@ -84,6 +120,7 @@ export class SessionStore {
|
|
|
84
120
|
* Emit a single event - writes to EventStore and applies to state.
|
|
85
121
|
*/
|
|
86
122
|
async emit(event: DomainEvent): Promise<void> {
|
|
123
|
+
if (this.detached) throw new SessionRuntimeDetachedError(this.sessionId, [event])
|
|
87
124
|
await this.eventStore.append(this.sessionId, event)
|
|
88
125
|
this._state = this.applyEvent(this._state, event)
|
|
89
126
|
this.notifyListeners(event)
|
|
@@ -96,6 +133,7 @@ export class SessionStore {
|
|
|
96
133
|
*/
|
|
97
134
|
async emitBatch(events: DomainEvent[]): Promise<void> {
|
|
98
135
|
if (events.length === 0) return
|
|
136
|
+
if (this.detached) throw new SessionRuntimeDetachedError(this.sessionId, events)
|
|
99
137
|
|
|
100
138
|
await this.eventStore.appendBatch(this.sessionId, events)
|
|
101
139
|
for (const event of events) {
|
|
@@ -18,12 +18,12 @@ import type { DomainEvent } from '~/core/events/types.js'
|
|
|
18
18
|
import type { LLMLogger } from '~/core/llm/logger.js'
|
|
19
19
|
import { applyMiddleware, type LLMMiddleware } from '~/core/llm/middleware.js'
|
|
20
20
|
import type { LLMProvider } from '~/core/llm/provider.js'
|
|
21
|
-
import type { AgentPluginConfig, BaseSessionHookContext, CallerContext, ConfiguredPlugin } from '~/core/plugins/plugin-builder.js'
|
|
21
|
+
import type { AgentPluginConfig, BaseSessionHookContext, CallerContext, ConfiguredPlugin, SessionCloseReason } from '~/core/plugins/plugin-builder.js'
|
|
22
22
|
import { AGENT_CALLER, DEFAULT_CALLER, buildPluginDeps, type PluginNotification } from '~/core/plugins/plugin-builder.js'
|
|
23
23
|
import type { Preset } from '~/core/preset/index.js'
|
|
24
24
|
import type { SessionId } from '~/core/sessions/schema.js'
|
|
25
25
|
import type { SessionOverridesPatch, SessionState } from '~/core/sessions/state.js'
|
|
26
|
-
import { getEntryAgentId, getNextAgentSeq, sessionEvents } from '~/core/sessions/state.js'
|
|
26
|
+
import { agentSequenceKey, getEntryAgentId, getNextAgentSeq, sessionEvents } from '~/core/sessions/state.js'
|
|
27
27
|
import type { Logger } from '~/lib/logger/logger.js'
|
|
28
28
|
import type { Platform } from '~/platform/index.js'
|
|
29
29
|
import type { Result } from '~/lib/utils/result.js'
|
|
@@ -40,17 +40,35 @@ import type { SessionContext } from '../sessions/context.js'
|
|
|
40
40
|
import type { SessionEnvironment } from '../sessions/session-environment.js'
|
|
41
41
|
import type { ToolExecutor } from '../tools/executor.js'
|
|
42
42
|
import { SessionStore } from './session-store.js'
|
|
43
|
+
import { type RuntimeLeaseRelease, SessionRuntimeActivityController } from './runtime-activity.js'
|
|
43
44
|
|
|
44
45
|
// ============================================================================
|
|
45
46
|
// Types
|
|
46
47
|
// ============================================================================
|
|
47
48
|
|
|
49
|
+
/** Sequence name behind reserveMailboxMessageSequence. */
|
|
50
|
+
const MAILBOX_MESSAGE_SEQUENCE = 'mailbox.message'
|
|
51
|
+
|
|
52
|
+
/** Disposal waits for aborted turns to unwind, but never pins on a wedged one. */
|
|
53
|
+
const AGENT_DRAIN_TIMEOUT_MS = 5_000
|
|
54
|
+
|
|
48
55
|
/**
|
|
49
56
|
* Callback for user-facing output.
|
|
50
57
|
* Receives plugin notifications that are broadcast to connected clients.
|
|
51
58
|
*/
|
|
52
59
|
export type UserOutputCallback = (notification: PluginNotification) => void
|
|
53
60
|
|
|
61
|
+
export interface SessionReopenRegistration {
|
|
62
|
+
complete(): Promise<void>
|
|
63
|
+
abort(error: unknown): void
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class SessionReopenError extends Error {
|
|
67
|
+
constructor(readonly domainError: DomainError) {
|
|
68
|
+
super(domainError.message)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
/**
|
|
55
73
|
* Dependencies for creating a Session.
|
|
56
74
|
*/
|
|
@@ -73,6 +91,9 @@ export interface SessionDependencies {
|
|
|
73
91
|
llmLogger?: LLMLogger
|
|
74
92
|
/** Host-environment adapters (filesystem, process). */
|
|
75
93
|
platform: Platform
|
|
94
|
+
/** Lifecycle guard shared by the manager, agents, and plugins. */
|
|
95
|
+
runtimeActivity: SessionRuntimeActivityController
|
|
96
|
+
registerReopenedSession?: (session: Session) => Result<SessionReopenRegistration | undefined, DomainError>
|
|
76
97
|
}
|
|
77
98
|
|
|
78
99
|
// ============================================================================
|
|
@@ -96,10 +117,16 @@ export class Session {
|
|
|
96
117
|
private readonly eventStore: EventStore
|
|
97
118
|
private readonly llmLogger?: LLMLogger
|
|
98
119
|
private readonly platform: Platform
|
|
120
|
+
private readonly runtimeActivity: SessionRuntimeActivityController
|
|
121
|
+
private readonly registerReopenedSession?: SessionDependencies['registerReopenedSession']
|
|
122
|
+
/** Named counters, seeded lazily from replayed state — see SessionContext.reserveSequence. */
|
|
123
|
+
private readonly sequences = new Map<string, number>()
|
|
99
124
|
|
|
100
125
|
private readonly agents = new Map<AgentId, Agent>()
|
|
101
126
|
/** Cached plugin contexts created by plugin.createContext() */
|
|
102
127
|
private readonly pluginContexts = new Map<string, unknown>()
|
|
128
|
+
private disposalPromise?: Promise<void>
|
|
129
|
+
private reopenPromise?: Promise<Result<void, DomainError>>
|
|
103
130
|
|
|
104
131
|
constructor(deps: SessionDependencies) {
|
|
105
132
|
this.id = deps.store.sessionId
|
|
@@ -115,6 +142,8 @@ export class Session {
|
|
|
115
142
|
this.eventStore = deps.eventStore
|
|
116
143
|
this.llmLogger = deps.llmLogger
|
|
117
144
|
this.platform = deps.platform
|
|
145
|
+
this.runtimeActivity = deps.runtimeActivity
|
|
146
|
+
this.registerReopenedSession = deps.registerReopenedSession
|
|
118
147
|
// Initialize agents from state
|
|
119
148
|
this.initializeAgents()
|
|
120
149
|
|
|
@@ -189,7 +218,7 @@ export class Session {
|
|
|
189
218
|
|
|
190
219
|
/**
|
|
191
220
|
* Close the session.
|
|
192
|
-
* Emits session_closed
|
|
221
|
+
* Emits session_closed, then awaits the shared runtime disposal path.
|
|
193
222
|
*/
|
|
194
223
|
async close(): Promise<Result<void, DomainError>> {
|
|
195
224
|
if (this.store.isClosed()) {
|
|
@@ -197,6 +226,7 @@ export class Session {
|
|
|
197
226
|
}
|
|
198
227
|
|
|
199
228
|
await this.store.emit(withSessionId(this.id, sessionEvents.create('session_closed', {})))
|
|
229
|
+
await this.dispose('closed')
|
|
200
230
|
|
|
201
231
|
return Ok(undefined)
|
|
202
232
|
}
|
|
@@ -208,10 +238,7 @@ export class Session {
|
|
|
208
238
|
if (!this.store.isClosed()) {
|
|
209
239
|
return Err(ValidationErrors.invalid('Session is not closed'))
|
|
210
240
|
}
|
|
211
|
-
|
|
212
|
-
await this.store.emit(withSessionId(this.id, sessionEvents.create('session_reopened', {})))
|
|
213
|
-
|
|
214
|
-
return Ok(undefined)
|
|
241
|
+
return this.reopenWithEvent(sessionEvents.create('session_reopened', {}))
|
|
215
242
|
}
|
|
216
243
|
|
|
217
244
|
/**
|
|
@@ -379,7 +406,7 @@ export class Session {
|
|
|
379
406
|
}
|
|
380
407
|
}
|
|
381
408
|
|
|
382
|
-
const seq = getNextAgentSeq(this.state, definitionName)
|
|
409
|
+
const seq = this.reserveSequence(agentSequenceKey(definitionName), () => getNextAgentSeq(this.state, definitionName))
|
|
383
410
|
const agentId = generateAgentId(definitionName, seq)
|
|
384
411
|
const now = Date.now()
|
|
385
412
|
|
|
@@ -396,11 +423,13 @@ export class Session {
|
|
|
396
423
|
]
|
|
397
424
|
|
|
398
425
|
if (message) {
|
|
399
|
-
const
|
|
426
|
+
const sequence = this.reserveMailboxMessageSequence()
|
|
427
|
+
const messageId = generateMessageId(sequence)
|
|
400
428
|
events.push(withSessionId(
|
|
401
429
|
this.id,
|
|
402
430
|
mailboxEvents.create('mailbox_message', {
|
|
403
431
|
toAgentId: agentId,
|
|
432
|
+
sequence,
|
|
404
433
|
message: {
|
|
405
434
|
id: messageId,
|
|
406
435
|
from: parentId,
|
|
@@ -425,16 +454,27 @@ export class Session {
|
|
|
425
454
|
}
|
|
426
455
|
|
|
427
456
|
/**
|
|
428
|
-
*
|
|
457
|
+
* Dispose runtime resources without changing persisted session state.
|
|
458
|
+
*
|
|
459
|
+
* `reason` reaches every `onSessionClose` hook, and disposal is idempotent, so
|
|
460
|
+
* the first caller's reason is the one the hooks see. It defaults to `evicted`
|
|
461
|
+
* because a bare dispose only drops the runtime — the session survives and the
|
|
462
|
+
* next access rebuilds it. The paths that really end a session pass `closed`.
|
|
429
463
|
*/
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
464
|
+
dispose(reason: SessionCloseReason = 'evicted'): Promise<void> {
|
|
465
|
+
this.runtimeActivity.beginForcedUnload()
|
|
466
|
+
this.disposalPromise ??= Promise.resolve().then(() => this.performDisposal(reason))
|
|
467
|
+
return this.disposalPromise
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Take a runtime lease from outside the session; the caller must release it.
|
|
472
|
+
*
|
|
473
|
+
* Returns null once the runtime stopped being `ready`, so losing the race with
|
|
474
|
+
* eviction reads as "this runtime is gone" instead of resurrecting it.
|
|
475
|
+
*/
|
|
476
|
+
tryAcquireRuntimeLease(reason: string): RuntimeLeaseRelease | null {
|
|
477
|
+
return this.runtimeActivity.tryAcquire(reason)
|
|
438
478
|
}
|
|
439
479
|
|
|
440
480
|
/**
|
|
@@ -474,6 +514,22 @@ export class Session {
|
|
|
474
514
|
input: unknown,
|
|
475
515
|
agentId?: AgentId,
|
|
476
516
|
caller?: CallerContext,
|
|
517
|
+
): Promise<Result<unknown, DomainError>> {
|
|
518
|
+
if (this.store.isClosed()) return this.executePluginMethod(method, input, agentId, caller)
|
|
519
|
+
const release = this.runtimeActivity.tryAcquire(`plugin:${method}`)
|
|
520
|
+
if (!release) return Err(SessionErrors.notFound(String(this.id)))
|
|
521
|
+
try {
|
|
522
|
+
return await this.executePluginMethod(method, input, agentId, caller)
|
|
523
|
+
} finally {
|
|
524
|
+
release()
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
private async executePluginMethod(
|
|
529
|
+
method: string,
|
|
530
|
+
input: unknown,
|
|
531
|
+
agentId?: AgentId,
|
|
532
|
+
caller?: CallerContext,
|
|
477
533
|
): Promise<Result<unknown, DomainError>> {
|
|
478
534
|
// Find the plugin and method by parsing "pluginName.methodName"
|
|
479
535
|
const dotIndex = method.indexOf('.')
|
|
@@ -539,9 +595,12 @@ export class Session {
|
|
|
539
595
|
deps,
|
|
540
596
|
}
|
|
541
597
|
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
598
|
+
try {
|
|
599
|
+
return await methodDef.handler(ctx, parsed.data)
|
|
600
|
+
} catch (error) {
|
|
601
|
+
if (error instanceof SessionReopenError) return Err(error.domainError)
|
|
602
|
+
throw error
|
|
603
|
+
}
|
|
545
604
|
}
|
|
546
605
|
|
|
547
606
|
// ============================================================================
|
|
@@ -587,24 +646,7 @@ export class Session {
|
|
|
587
646
|
|
|
588
647
|
return new Agent({
|
|
589
648
|
id: agentState.id,
|
|
590
|
-
|
|
591
|
-
sessionId: this.id,
|
|
592
|
-
sessionState: this.store.getState(),
|
|
593
|
-
sessionInput: undefined,
|
|
594
|
-
environment: env,
|
|
595
|
-
llm: this.llmProvider,
|
|
596
|
-
files: fileStore,
|
|
597
|
-
eventStore: this.eventStore,
|
|
598
|
-
llmLogger: this.llmLogger,
|
|
599
|
-
platform: this.platform,
|
|
600
|
-
logger: this.logger,
|
|
601
|
-
emitEvent: async (event) => {
|
|
602
|
-
await this.store.emit(withSessionId(this.id, event))
|
|
603
|
-
},
|
|
604
|
-
notify: (type, payload) => {
|
|
605
|
-
this.onUserOutput?.({ pluginName: '_agent', type, payload })
|
|
606
|
-
},
|
|
607
|
-
},
|
|
649
|
+
getSessionContext: () => this.buildSessionContext('_agent'),
|
|
608
650
|
store: this.store,
|
|
609
651
|
llmProvider,
|
|
610
652
|
llmProviders: this.llmProviders,
|
|
@@ -634,8 +676,8 @@ export class Session {
|
|
|
634
676
|
break
|
|
635
677
|
}
|
|
636
678
|
case 'session_closed': {
|
|
637
|
-
this.
|
|
638
|
-
this.logger.error('Unhandled error in
|
|
679
|
+
this.dispose('closed').catch((err) => {
|
|
680
|
+
this.logger.error('Unhandled error in session disposal', err instanceof Error ? err : undefined, { sessionId: this.id })
|
|
639
681
|
})
|
|
640
682
|
break
|
|
641
683
|
}
|
|
@@ -643,20 +685,20 @@ export class Session {
|
|
|
643
685
|
}
|
|
644
686
|
|
|
645
687
|
/**
|
|
646
|
-
*
|
|
688
|
+
* Call close hooks and release all in-memory runtime state.
|
|
647
689
|
*
|
|
648
690
|
* Unlike onSessionReady (which re-throws), onSessionClose intentionally
|
|
649
691
|
* swallows per-plugin errors so that all plugins get a chance to clean up
|
|
650
692
|
* and agents are always shut down, even if one plugin's close hook fails.
|
|
651
693
|
*/
|
|
652
|
-
private async
|
|
694
|
+
private async performDisposal(reason: SessionCloseReason): Promise<void> {
|
|
653
695
|
// Call onSessionClose for all plugins in REVERSE order (per-plugin isolation)
|
|
654
696
|
const reversedPlugins = [...this.plugins].reverse()
|
|
655
697
|
for (const plugin of reversedPlugins) {
|
|
656
698
|
if (plugin.sessionHooks?.onSessionClose) {
|
|
657
699
|
try {
|
|
658
700
|
const ctx = this.buildSessionHookContext(plugin)
|
|
659
|
-
await plugin.sessionHooks.onSessionClose(ctx)
|
|
701
|
+
await plugin.sessionHooks.onSessionClose({ ...ctx, reason })
|
|
660
702
|
} catch (err) {
|
|
661
703
|
this.logger.error(`Session plugin '${plugin.name}' onSessionClose failed`, err instanceof Error ? err : new Error(String(err)), {
|
|
662
704
|
sessionId: this.id,
|
|
@@ -675,12 +717,43 @@ export class Session {
|
|
|
675
717
|
}
|
|
676
718
|
}
|
|
677
719
|
|
|
720
|
+
// The shutdown above only aborts; a turn still inside a tool call keeps
|
|
721
|
+
// running against the agents and plugin contexts cleared below.
|
|
722
|
+
await this.drainAgents()
|
|
723
|
+
|
|
678
724
|
// Clean up references to prevent memory leaks
|
|
679
725
|
this.agents.clear()
|
|
680
726
|
this.pluginContexts.clear()
|
|
681
727
|
this.store.clearListeners()
|
|
728
|
+
// Fence the log last: everything above may still emit legitimately, but
|
|
729
|
+
// whatever outlives disposal now fails instead of writing behind the
|
|
730
|
+
// replacement runtime the manager builds from the same log.
|
|
731
|
+
this.store.detach()
|
|
732
|
+
this.runtimeActivity.markDisposed()
|
|
682
733
|
|
|
683
|
-
this.logger.info('Session
|
|
734
|
+
this.logger.info('Session runtime disposed', { sessionId: this.id, reason })
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
/** Await every in-flight turn, bounded — a wedged one must not hold disposal open. */
|
|
738
|
+
private async drainAgents(): Promise<void> {
|
|
739
|
+
const drains = [...this.agents.values()].map((agent) => agent.waitForIdle())
|
|
740
|
+
if (drains.length === 0) return
|
|
741
|
+
|
|
742
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
743
|
+
const expiry = new Promise<'expired'>((resolve) => {
|
|
744
|
+
timer = setTimeout(() => resolve('expired'), AGENT_DRAIN_TIMEOUT_MS)
|
|
745
|
+
})
|
|
746
|
+
try {
|
|
747
|
+
const outcome = await Promise.race([Promise.all(drains).then(() => 'drained' as const), expiry])
|
|
748
|
+
if (outcome === 'expired') {
|
|
749
|
+
this.logger.warn('Agent turns did not settle before disposal', {
|
|
750
|
+
sessionId: this.id,
|
|
751
|
+
timeoutMs: AGENT_DRAIN_TIMEOUT_MS,
|
|
752
|
+
})
|
|
753
|
+
}
|
|
754
|
+
} finally {
|
|
755
|
+
if (timer) clearTimeout(timer)
|
|
756
|
+
}
|
|
684
757
|
}
|
|
685
758
|
|
|
686
759
|
/**
|
|
@@ -736,12 +809,13 @@ export class Session {
|
|
|
736
809
|
/**
|
|
737
810
|
* Build a SessionContext from current session state.
|
|
738
811
|
*/
|
|
739
|
-
private buildSessionContext(): SessionContext {
|
|
812
|
+
private buildSessionContext(notificationPluginName = '_session'): SessionContext {
|
|
740
813
|
const env = this.getSessionEnvironment()
|
|
741
814
|
const fileStore = new SessionFileStore(env.sessionDir, env.workspaceDir, env.sandboxed, this.platform.fs)
|
|
742
815
|
return {
|
|
743
816
|
sessionId: this.id,
|
|
744
817
|
sessionState: this.store.getState(),
|
|
818
|
+
getSessionState: () => this.store.getState(),
|
|
745
819
|
sessionInput: undefined,
|
|
746
820
|
environment: env,
|
|
747
821
|
llm: this.llmProvider,
|
|
@@ -750,12 +824,73 @@ export class Session {
|
|
|
750
824
|
llmLogger: this.llmLogger,
|
|
751
825
|
platform: this.platform,
|
|
752
826
|
logger: this.logger,
|
|
827
|
+
runtimeActivity: this.runtimeActivity,
|
|
828
|
+
reserveSequence: (name, seed) => this.reserveSequence(name, seed),
|
|
829
|
+
reserveMailboxMessageSequence: () => this.reserveMailboxMessageSequence(),
|
|
753
830
|
emitEvent: async (event) => {
|
|
831
|
+
if (event.type === 'session_reopened') {
|
|
832
|
+
const reopened = await this.reopenWithEvent(event)
|
|
833
|
+
if (!reopened.ok) throw new SessionReopenError(reopened.error)
|
|
834
|
+
return
|
|
835
|
+
}
|
|
754
836
|
await this.store.emit(withSessionId(this.id, event))
|
|
755
837
|
},
|
|
838
|
+
emitEvents: async (events) => {
|
|
839
|
+
await this.store.emitBatch(events.map((event) => withSessionId(this.id, event)))
|
|
840
|
+
},
|
|
756
841
|
notify: (type, payload) => {
|
|
757
|
-
this.onUserOutput?.({ pluginName:
|
|
842
|
+
this.onUserOutput?.({ pluginName: notificationPluginName, type, payload })
|
|
843
|
+
},
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
private reserveSequence(name: string, seed: () => number): number {
|
|
848
|
+
const activity = this.runtimeActivity.getSnapshot()
|
|
849
|
+
if (this.store.isClosed() || activity.state !== 'ready') {
|
|
850
|
+
throw new Error(`Cannot reserve sequence "${name}" on a closed or disposed session runtime`)
|
|
851
|
+
}
|
|
852
|
+
const sequence = this.sequences.get(name) ?? seed()
|
|
853
|
+
this.sequences.set(name, sequence + 1)
|
|
854
|
+
return sequence
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
private reserveMailboxMessageSequence(): number {
|
|
858
|
+
return this.reserveSequence(MAILBOX_MESSAGE_SEQUENCE, () => getNextMessageSeq(selectMailboxState(this.store.getState())))
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
private reopenWithEvent(event: Omit<BaseEvent<string>, 'sessionId'>): Promise<Result<void, DomainError>> {
|
|
862
|
+
if (this.reopenPromise) return this.reopenPromise
|
|
863
|
+
const operation = this.performReopen(event)
|
|
864
|
+
this.reopenPromise = operation
|
|
865
|
+
void operation.then(
|
|
866
|
+
() => {
|
|
867
|
+
if (this.reopenPromise === operation) this.reopenPromise = undefined
|
|
758
868
|
},
|
|
869
|
+
() => {
|
|
870
|
+
if (this.reopenPromise === operation) this.reopenPromise = undefined
|
|
871
|
+
},
|
|
872
|
+
)
|
|
873
|
+
return operation
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
private async performReopen(event: Omit<BaseEvent<string>, 'sessionId'>): Promise<Result<void, DomainError>> {
|
|
877
|
+
if (!this.store.isClosed()) return Err(ValidationErrors.invalid('Session is not closed'))
|
|
878
|
+
// A disposed runtime cannot host the reopened session — the manager refuses to
|
|
879
|
+
// re-register it — so reopen through a freshly loaded one instead of writing
|
|
880
|
+
// the event from a handle that is already dead.
|
|
881
|
+
if (this.store.isDetached()) {
|
|
882
|
+
return Err(ValidationErrors.invalid('Session runtime is disposed; load the session again to reopen it'))
|
|
883
|
+
}
|
|
884
|
+
const registrationResult = this.registerReopenedSession?.(this) ?? Ok(undefined)
|
|
885
|
+
if (!registrationResult.ok) return registrationResult
|
|
886
|
+
const registration = registrationResult.value
|
|
887
|
+
try {
|
|
888
|
+
await this.store.emit(withSessionId(this.id, event))
|
|
889
|
+
await registration?.complete()
|
|
890
|
+
return Ok(undefined)
|
|
891
|
+
} catch (error) {
|
|
892
|
+
registration?.abort(error)
|
|
893
|
+
throw error
|
|
759
894
|
}
|
|
760
895
|
}
|
|
761
896
|
|
|
@@ -795,6 +930,11 @@ export class Session {
|
|
|
795
930
|
}
|
|
796
931
|
}
|
|
797
932
|
|
|
933
|
+
/** What plugins and tools see. Read-only, so a host can assert the posture it resolved. */
|
|
934
|
+
get environment(): SessionEnvironment {
|
|
935
|
+
return this.getSessionEnvironment()
|
|
936
|
+
}
|
|
937
|
+
|
|
798
938
|
/**
|
|
799
939
|
* Get session environment for tool context.
|
|
800
940
|
*/
|
|
@@ -260,6 +260,8 @@ export const coreReducer = createTypedReducer(
|
|
|
260
260
|
role: 'assistant',
|
|
261
261
|
content: event.response.content ?? '',
|
|
262
262
|
toolCalls: toolCalls.length > 0 ? toolCalls : undefined,
|
|
263
|
+
reasoningDetails: event.response.reasoningDetails,
|
|
264
|
+
thinkingBlocks: event.response.thinkingBlocks,
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
return updateAgent(state, event.agentId, (agent) => {
|
|
@@ -277,6 +279,7 @@ export const coreReducer = createTypedReducer(
|
|
|
277
279
|
lastInferenceMetrics: event.metrics,
|
|
278
280
|
consecutiveInferenceFailures: 0,
|
|
279
281
|
lastInferenceFailureAt: undefined,
|
|
282
|
+
turnNumber: (agent.turnNumber ?? 0) + 1,
|
|
280
283
|
}
|
|
281
284
|
})
|
|
282
285
|
}
|
|
@@ -374,6 +377,9 @@ export const coreReducer = createTypedReducer(
|
|
|
374
377
|
role: 'assistant',
|
|
375
378
|
content: m.content,
|
|
376
379
|
toolCalls: m.toolCalls,
|
|
380
|
+
// Survives compaction: a retained turn keeps the reasoning the provider wants echoed back.
|
|
381
|
+
reasoningDetails: m.reasoningDetails,
|
|
382
|
+
thinkingBlocks: m.thinkingBlocks,
|
|
377
383
|
cacheControl: m.cacheControl,
|
|
378
384
|
}
|
|
379
385
|
case 'tool':
|
|
@@ -638,3 +644,13 @@ export const getAgentState = (state: SessionState, agentId: AgentId): AgentState
|
|
|
638
644
|
export const getNextAgentSeq = (state: SessionState, definitionName: string): number => {
|
|
639
645
|
return (state.agentCounters.get(definitionName) ?? 0) + 1
|
|
640
646
|
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
* Reservation key for the per-definition agent sequence.
|
|
650
|
+
*
|
|
651
|
+
* Both spawn paths reserve through `SessionContext.reserveSequence` — deriving the
|
|
652
|
+
* sequence from the projection instead lets two concurrent spawns read the same
|
|
653
|
+
* counter and mint the same agent id, and the second one then overwrites the first
|
|
654
|
+
* in the agent map while both callers are told they spawned an agent.
|
|
655
|
+
*/
|
|
656
|
+
export const agentSequenceKey = (definitionName: string): string => `agent.${definitionName}`
|
package/src/core/system.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type z4 from 'zod/v4'
|
|
11
11
|
import type { Logger } from '~/lib/logger/logger.js'
|
|
12
|
+
import type { ArchiveLimitOverrides } from '~/lib/archive/index.js'
|
|
12
13
|
import type { Platform } from '~/platform/index.js'
|
|
13
14
|
import type { ServicePidRegistry } from '~/plugins/services/pid-registry.js'
|
|
14
15
|
import type { PortPool } from '~/plugins/services/port-pool.js'
|
|
@@ -119,11 +120,19 @@ export interface CreateSystemOptions<TPlugins extends readonly PluginDefinition<
|
|
|
119
120
|
dataFileStore: FileStore
|
|
120
121
|
onUserOutput?: UserOutputCallback
|
|
121
122
|
preprocessorRegistry?: PreprocessorRegistry
|
|
123
|
+
uploadArchiveLimits?: ArchiveLimitOverrides
|
|
124
|
+
resourceArchiveLimits?: ArchiveLimitOverrides
|
|
122
125
|
llmLogger?: LLMLogger
|
|
123
126
|
portPool?: PortPool
|
|
124
127
|
pidRegistry?: ServicePidRegistry
|
|
125
128
|
/** Host-environment adapters (filesystem, process). */
|
|
126
129
|
platform: Platform
|
|
130
|
+
/**
|
|
131
|
+
* Evict a resident session runtime after this long idle. Absent or `0` keeps
|
|
132
|
+
* every runtime resident, which is the default for programmatic SDK use.
|
|
133
|
+
* An evicted runtime is rebuilt from its event log and re-runs `onSessionReady`.
|
|
134
|
+
*/
|
|
135
|
+
sessionIdleTimeoutMs?: number
|
|
127
136
|
}
|
|
128
137
|
|
|
129
138
|
// ============================================================================
|
|
@@ -145,10 +154,13 @@ export function createSystem<const TPlugins extends readonly PluginDefinition<st
|
|
|
145
154
|
dataFileStore,
|
|
146
155
|
onUserOutput,
|
|
147
156
|
preprocessorRegistry,
|
|
157
|
+
uploadArchiveLimits,
|
|
158
|
+
resourceArchiveLimits,
|
|
148
159
|
llmLogger,
|
|
149
160
|
portPool,
|
|
150
161
|
pidRegistry,
|
|
151
162
|
platform,
|
|
163
|
+
sessionIdleTimeoutMs,
|
|
152
164
|
} = options
|
|
153
165
|
|
|
154
166
|
// Build plugins accessor — typed record keyed by plugin name
|
|
@@ -168,10 +180,13 @@ export function createSystem<const TPlugins extends readonly PluginDefinition<st
|
|
|
168
180
|
dataFileStore,
|
|
169
181
|
onUserOutput,
|
|
170
182
|
preprocessorRegistry,
|
|
183
|
+
uploadArchiveLimits,
|
|
184
|
+
resourceArchiveLimits,
|
|
171
185
|
llmLogger,
|
|
172
186
|
portPool,
|
|
173
187
|
pidRegistry,
|
|
174
188
|
platform,
|
|
189
|
+
sessionIdleTimeoutMs,
|
|
175
190
|
systemPlugins: [...plugins],
|
|
176
191
|
})
|
|
177
192
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Routing keys for scheduler wakes.
|
|
3
|
+
*
|
|
4
|
+
* A wake must be dispatchable after the process that armed it is gone, so it
|
|
5
|
+
* carries no closure: the key is the whole routing table. `SessionManager`
|
|
6
|
+
* mints and reads them, and `dispatchWake` turns one back into a session.
|
|
7
|
+
*
|
|
8
|
+
* Their own module because both the agent loop and the plugins that arm wakes
|
|
9
|
+
* need them, and neither should have to import the other to mint one.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { AgentId } from '~/core/agents/schema.js'
|
|
13
|
+
import { isValidSessionId, SessionId } from '~/core/sessions/schema.js'
|
|
14
|
+
|
|
15
|
+
/** Which delayed re-entry an agent wake stands for. */
|
|
16
|
+
export type AgentWakeKind = 'debounce' | 'retry'
|
|
17
|
+
|
|
18
|
+
export interface AgentWake {
|
|
19
|
+
sessionId: SessionId
|
|
20
|
+
agentId: AgentId
|
|
21
|
+
kind: AgentWakeKind
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface PluginWake {
|
|
25
|
+
sessionId: SessionId
|
|
26
|
+
pluginName: string
|
|
27
|
+
method: string
|
|
28
|
+
agentId: AgentId | undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** `agent:<sessionId>:<agentId>:<kind>` */
|
|
32
|
+
export function agentWakeKey(sessionId: SessionId, agentId: AgentId, kind: AgentWakeKind): string {
|
|
33
|
+
return `agent:${sessionId}:${agentId}:${kind}`
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Read a key back, or null when it is not one `agentWakeKey` minted. */
|
|
37
|
+
export function parseAgentWakeKey(key: string): AgentWake | null {
|
|
38
|
+
const parts = key.split(':')
|
|
39
|
+
if (parts.length !== 4 || parts[0] !== 'agent') return null
|
|
40
|
+
const [, sessionId, agentId, kind] = parts
|
|
41
|
+
if (kind !== 'debounce' && kind !== 'retry') return null
|
|
42
|
+
if (agentId === '' || !isValidSessionId(sessionId)) return null
|
|
43
|
+
return { sessionId: SessionId(sessionId), agentId: AgentId(agentId), kind }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** `plugin:<sessionId>:<pluginName>:<method>[:<agentId>]` */
|
|
47
|
+
export function pluginWakeKey(sessionId: SessionId, pluginName: string, method: string, agentId?: AgentId): string {
|
|
48
|
+
const base = `plugin:${sessionId}:${pluginName}:${method}`
|
|
49
|
+
return agentId === undefined ? base : `${base}:${agentId}`
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Read a key back, or null when it is not one `pluginWakeKey` minted. */
|
|
53
|
+
export function parsePluginWakeKey(key: string): PluginWake | null {
|
|
54
|
+
const parts = key.split(':')
|
|
55
|
+
if (parts.length !== 4 && parts.length !== 5) return null
|
|
56
|
+
const [prefix, sessionId, pluginName, method, agentId] = parts
|
|
57
|
+
if (prefix !== 'plugin' || pluginName === '' || method === '') return null
|
|
58
|
+
if (agentId === '' || !isValidSessionId(sessionId)) return null
|
|
59
|
+
return {
|
|
60
|
+
sessionId: SessionId(sessionId),
|
|
61
|
+
pluginName,
|
|
62
|
+
method,
|
|
63
|
+
agentId: agentId === undefined ? undefined : AgentId(agentId),
|
|
64
|
+
}
|
|
65
|
+
}
|