@tianshu-ai/tianshu 0.3.0
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/LICENSE +200 -0
- package/README.md +284 -0
- package/README.zh-CN.md +136 -0
- package/bin/tianshu.mjs +32 -0
- package/package.json +60 -0
- package/packages/plugin-sdk/dist/agent-loop.d.ts +96 -0
- package/packages/plugin-sdk/dist/agent-loop.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/agent-loop.js +11 -0
- package/packages/plugin-sdk/dist/agent-loop.js.map +1 -0
- package/packages/plugin-sdk/dist/capabilities.d.ts +48 -0
- package/packages/plugin-sdk/dist/capabilities.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/capabilities.js +61 -0
- package/packages/plugin-sdk/dist/capabilities.js.map +1 -0
- package/packages/plugin-sdk/dist/catalog.d.ts +60 -0
- package/packages/plugin-sdk/dist/catalog.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/catalog.js +11 -0
- package/packages/plugin-sdk/dist/catalog.js.map +1 -0
- package/packages/plugin-sdk/dist/client.d.ts +171 -0
- package/packages/plugin-sdk/dist/client.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/client.js +96 -0
- package/packages/plugin-sdk/dist/client.js.map +1 -0
- package/packages/plugin-sdk/dist/index.d.ts +9 -0
- package/packages/plugin-sdk/dist/index.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/index.js +19 -0
- package/packages/plugin-sdk/dist/index.js.map +1 -0
- package/packages/plugin-sdk/dist/lsp.d.ts +32 -0
- package/packages/plugin-sdk/dist/lsp.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/lsp.js +19 -0
- package/packages/plugin-sdk/dist/lsp.js.map +1 -0
- package/packages/plugin-sdk/dist/manifest.d.ts +423 -0
- package/packages/plugin-sdk/dist/manifest.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/manifest.js +7 -0
- package/packages/plugin-sdk/dist/manifest.js.map +1 -0
- package/packages/plugin-sdk/dist/mcp-client.d.ts +74 -0
- package/packages/plugin-sdk/dist/mcp-client.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/mcp-client.js +226 -0
- package/packages/plugin-sdk/dist/mcp-client.js.map +1 -0
- package/packages/plugin-sdk/dist/mcp-fetch.d.ts +10 -0
- package/packages/plugin-sdk/dist/mcp-fetch.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/mcp-fetch.js +130 -0
- package/packages/plugin-sdk/dist/mcp-fetch.js.map +1 -0
- package/packages/plugin-sdk/dist/mcp-toolset.d.ts +128 -0
- package/packages/plugin-sdk/dist/mcp-toolset.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/mcp-toolset.js +246 -0
- package/packages/plugin-sdk/dist/mcp-toolset.js.map +1 -0
- package/packages/plugin-sdk/dist/server.d.ts +486 -0
- package/packages/plugin-sdk/dist/server.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/server.js +10 -0
- package/packages/plugin-sdk/dist/server.js.map +1 -0
- package/packages/plugin-sdk/dist/session-inbox.d.ts +56 -0
- package/packages/plugin-sdk/dist/session-inbox.d.ts.map +1 -0
- package/packages/plugin-sdk/dist/session-inbox.js +12 -0
- package/packages/plugin-sdk/dist/session-inbox.js.map +1 -0
- package/packages/plugin-sdk/package.json +36 -0
- package/packages/server/builtinConfig/plugins/README.md +1 -0
- package/packages/server/builtinConfig/plugins/files/manifest.json +100 -0
- package/packages/server/builtinConfig/plugins/files/skills/files-workspace-layout.md +29 -0
- package/packages/server/builtinConfig/plugins/microsandbox/manifest.json +177 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-browser-howto.md +155 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-build-use.md +201 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-config.md +38 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-exec-howto.md +144 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-libreoffice.md +159 -0
- package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-main-orchestration.md +75 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/README.md +26 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/browser.yaml +105 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/task-runner-with-browser.yaml +80 -0
- package/packages/server/builtinConfig/plugins/microsandbox/templates/task-runner.yaml +80 -0
- package/packages/server/builtinConfig/plugins/web-search/manifest.json +65 -0
- package/packages/server/builtinConfig/plugins/web-search/skills/web-search-howto.md +69 -0
- package/packages/server/builtinConfig/plugins/workboard/agent-seeds/echo-demo/agent.json +7 -0
- package/packages/server/builtinConfig/plugins/workboard/agent-seeds/llm-default/SOUL.md +53 -0
- package/packages/server/builtinConfig/plugins/workboard/agent-seeds/llm-default/agent.json +7 -0
- package/packages/server/builtinConfig/plugins/workboard/manifest.json +180 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/large-input-large-output.md +185 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/workboard-howto.md +166 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/worker-creator.md +267 -0
- package/packages/server/builtinConfig/plugins/workboard/skills/worker-fleet.md +431 -0
- package/packages/server/dist/catalog.d.ts +52 -0
- package/packages/server/dist/catalog.d.ts.map +1 -0
- package/packages/server/dist/catalog.js +189 -0
- package/packages/server/dist/catalog.js.map +1 -0
- package/packages/server/dist/chat/active-harnesses.d.ts +34 -0
- package/packages/server/dist/chat/active-harnesses.d.ts.map +1 -0
- package/packages/server/dist/chat/active-harnesses.js +118 -0
- package/packages/server/dist/chat/active-harnesses.js.map +1 -0
- package/packages/server/dist/chat/agent-loop.d.ts +64 -0
- package/packages/server/dist/chat/agent-loop.d.ts.map +1 -0
- package/packages/server/dist/chat/agent-loop.js +597 -0
- package/packages/server/dist/chat/agent-loop.js.map +1 -0
- package/packages/server/dist/chat/agent-tool-adapter.d.ts +33 -0
- package/packages/server/dist/chat/agent-tool-adapter.d.ts.map +1 -0
- package/packages/server/dist/chat/agent-tool-adapter.js +260 -0
- package/packages/server/dist/chat/agent-tool-adapter.js.map +1 -0
- package/packages/server/dist/chat/compact.d.ts +52 -0
- package/packages/server/dist/chat/compact.d.ts.map +1 -0
- package/packages/server/dist/chat/compact.js +248 -0
- package/packages/server/dist/chat/compact.js.map +1 -0
- package/packages/server/dist/chat/dump-system-prompt.d.ts +17 -0
- package/packages/server/dist/chat/dump-system-prompt.d.ts.map +1 -0
- package/packages/server/dist/chat/dump-system-prompt.js +58 -0
- package/packages/server/dist/chat/dump-system-prompt.js.map +1 -0
- package/packages/server/dist/chat/handler.d.ts +186 -0
- package/packages/server/dist/chat/handler.d.ts.map +1 -0
- package/packages/server/dist/chat/handler.js +1248 -0
- package/packages/server/dist/chat/handler.js.map +1 -0
- package/packages/server/dist/chat/image-fit.d.ts +34 -0
- package/packages/server/dist/chat/image-fit.d.ts.map +1 -0
- package/packages/server/dist/chat/image-fit.js +157 -0
- package/packages/server/dist/chat/image-fit.js.map +1 -0
- package/packages/server/dist/chat/messages.d.ts +118 -0
- package/packages/server/dist/chat/messages.d.ts.map +1 -0
- package/packages/server/dist/chat/messages.js +341 -0
- package/packages/server/dist/chat/messages.js.map +1 -0
- package/packages/server/dist/chat/session-inbox.d.ts +114 -0
- package/packages/server/dist/chat/session-inbox.d.ts.map +1 -0
- package/packages/server/dist/chat/session-inbox.js +418 -0
- package/packages/server/dist/chat/session-inbox.js.map +1 -0
- package/packages/server/dist/chat/sqlite-session-repo.d.ts +26 -0
- package/packages/server/dist/chat/sqlite-session-repo.d.ts.map +1 -0
- package/packages/server/dist/chat/sqlite-session-repo.js +132 -0
- package/packages/server/dist/chat/sqlite-session-repo.js.map +1 -0
- package/packages/server/dist/chat/sqlite-session-storage.d.ts +83 -0
- package/packages/server/dist/chat/sqlite-session-storage.d.ts.map +1 -0
- package/packages/server/dist/chat/sqlite-session-storage.js +418 -0
- package/packages/server/dist/chat/sqlite-session-storage.js.map +1 -0
- package/packages/server/dist/chat/stub-execution-env.d.ts +3 -0
- package/packages/server/dist/chat/stub-execution-env.d.ts.map +1 -0
- package/packages/server/dist/chat/stub-execution-env.js +87 -0
- package/packages/server/dist/chat/stub-execution-env.js.map +1 -0
- package/packages/server/dist/chat/token-estimate.d.ts +11 -0
- package/packages/server/dist/chat/token-estimate.d.ts.map +1 -0
- package/packages/server/dist/chat/token-estimate.js +67 -0
- package/packages/server/dist/chat/token-estimate.js.map +1 -0
- package/packages/server/dist/chat/ws-protocol.d.ts +244 -0
- package/packages/server/dist/chat/ws-protocol.d.ts.map +1 -0
- package/packages/server/dist/chat/ws-protocol.js +193 -0
- package/packages/server/dist/chat/ws-protocol.js.map +1 -0
- package/packages/server/dist/cli.d.ts +9 -0
- package/packages/server/dist/cli.d.ts.map +1 -0
- package/packages/server/dist/cli.js +329 -0
- package/packages/server/dist/cli.js.map +1 -0
- package/packages/server/dist/core/agent-seeds.d.ts +25 -0
- package/packages/server/dist/core/agent-seeds.d.ts.map +1 -0
- package/packages/server/dist/core/agent-seeds.js +69 -0
- package/packages/server/dist/core/agent-seeds.js.map +1 -0
- package/packages/server/dist/core/config.d.ts +172 -0
- package/packages/server/dist/core/config.d.ts.map +1 -0
- package/packages/server/dist/core/config.js +155 -0
- package/packages/server/dist/core/config.js.map +1 -0
- package/packages/server/dist/core/db-pool.d.ts +32 -0
- package/packages/server/dist/core/db-pool.d.ts.map +1 -0
- package/packages/server/dist/core/db-pool.js +108 -0
- package/packages/server/dist/core/db-pool.js.map +1 -0
- package/packages/server/dist/core/dev-mode.d.ts +13 -0
- package/packages/server/dist/core/dev-mode.d.ts.map +1 -0
- package/packages/server/dist/core/dev-mode.js +51 -0
- package/packages/server/dist/core/dev-mode.js.map +1 -0
- package/packages/server/dist/core/global-ops.d.ts +54 -0
- package/packages/server/dist/core/global-ops.d.ts.map +1 -0
- package/packages/server/dist/core/global-ops.js +143 -0
- package/packages/server/dist/core/global-ops.js.map +1 -0
- package/packages/server/dist/core/identity-resolvers.d.ts +102 -0
- package/packages/server/dist/core/identity-resolvers.d.ts.map +1 -0
- package/packages/server/dist/core/identity-resolvers.js +176 -0
- package/packages/server/dist/core/identity-resolvers.js.map +1 -0
- package/packages/server/dist/core/index.d.ts +13 -0
- package/packages/server/dist/core/index.d.ts.map +1 -0
- package/packages/server/dist/core/index.js +18 -0
- package/packages/server/dist/core/index.js.map +1 -0
- package/packages/server/dist/core/llm.d.ts +45 -0
- package/packages/server/dist/core/llm.d.ts.map +1 -0
- package/packages/server/dist/core/llm.js +140 -0
- package/packages/server/dist/core/llm.js.map +1 -0
- package/packages/server/dist/core/mcp-manager.d.ts +47 -0
- package/packages/server/dist/core/mcp-manager.d.ts.map +1 -0
- package/packages/server/dist/core/mcp-manager.js +129 -0
- package/packages/server/dist/core/mcp-manager.js.map +1 -0
- package/packages/server/dist/core/middleware.d.ts +31 -0
- package/packages/server/dist/core/middleware.d.ts.map +1 -0
- package/packages/server/dist/core/middleware.js +102 -0
- package/packages/server/dist/core/middleware.js.map +1 -0
- package/packages/server/dist/core/migrations/001-initial.d.ts +4 -0
- package/packages/server/dist/core/migrations/001-initial.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/001-initial.js +66 -0
- package/packages/server/dist/core/migrations/001-initial.js.map +1 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.d.ts +4 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.js +20 -0
- package/packages/server/dist/core/migrations/002-task-dependencies.js.map +1 -0
- package/packages/server/dist/core/migrations/003-session-tree.d.ts +4 -0
- package/packages/server/dist/core/migrations/003-session-tree.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/003-session-tree.js +96 -0
- package/packages/server/dist/core/migrations/003-session-tree.js.map +1 -0
- package/packages/server/dist/core/migrations/003-worker-agents.d.ts +4 -0
- package/packages/server/dist/core/migrations/003-worker-agents.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/003-worker-agents.js +65 -0
- package/packages/server/dist/core/migrations/003-worker-agents.js.map +1 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.d.ts +4 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.js +52 -0
- package/packages/server/dist/core/migrations/004-rebuild-message-chain.js.map +1 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.d.ts +4 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.js +64 -0
- package/packages/server/dist/core/migrations/005-task-status-rename.js.map +1 -0
- package/packages/server/dist/core/migrations/006-task-labels.d.ts +4 -0
- package/packages/server/dist/core/migrations/006-task-labels.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/006-task-labels.js +43 -0
- package/packages/server/dist/core/migrations/006-task-labels.js.map +1 -0
- package/packages/server/dist/core/migrations/007-session-inbox.d.ts +4 -0
- package/packages/server/dist/core/migrations/007-session-inbox.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/007-session-inbox.js +67 -0
- package/packages/server/dist/core/migrations/007-session-inbox.js.map +1 -0
- package/packages/server/dist/core/migrations/008-task-intervention.d.ts +4 -0
- package/packages/server/dist/core/migrations/008-task-intervention.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/008-task-intervention.js +60 -0
- package/packages/server/dist/core/migrations/008-task-intervention.js.map +1 -0
- package/packages/server/dist/core/migrations/index.d.ts +12 -0
- package/packages/server/dist/core/migrations/index.d.ts.map +1 -0
- package/packages/server/dist/core/migrations/index.js +58 -0
- package/packages/server/dist/core/migrations/index.js.map +1 -0
- package/packages/server/dist/core/paths.d.ts +53 -0
- package/packages/server/dist/core/paths.d.ts.map +1 -0
- package/packages/server/dist/core/paths.js +125 -0
- package/packages/server/dist/core/paths.js.map +1 -0
- package/packages/server/dist/core/plugins/builtin-loader.d.ts +56 -0
- package/packages/server/dist/core/plugins/builtin-loader.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/builtin-loader.js +153 -0
- package/packages/server/dist/core/plugins/builtin-loader.js.map +1 -0
- package/packages/server/dist/core/plugins/discovery.d.ts +28 -0
- package/packages/server/dist/core/plugins/discovery.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/discovery.js +97 -0
- package/packages/server/dist/core/plugins/discovery.js.map +1 -0
- package/packages/server/dist/core/plugins/index.d.ts +6 -0
- package/packages/server/dist/core/plugins/index.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/index.js +6 -0
- package/packages/server/dist/core/plugins/index.js.map +1 -0
- package/packages/server/dist/core/plugins/manifest.d.ts +9 -0
- package/packages/server/dist/core/plugins/manifest.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/manifest.js +584 -0
- package/packages/server/dist/core/plugins/manifest.js.map +1 -0
- package/packages/server/dist/core/plugins/registry.d.ts +269 -0
- package/packages/server/dist/core/plugins/registry.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/registry.js +1003 -0
- package/packages/server/dist/core/plugins/registry.js.map +1 -0
- package/packages/server/dist/core/plugins/secrets.d.ts +46 -0
- package/packages/server/dist/core/plugins/secrets.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/secrets.js +174 -0
- package/packages/server/dist/core/plugins/secrets.js.map +1 -0
- package/packages/server/dist/core/plugins/skills.d.ts +131 -0
- package/packages/server/dist/core/plugins/skills.d.ts.map +1 -0
- package/packages/server/dist/core/plugins/skills.js +389 -0
- package/packages/server/dist/core/plugins/skills.js.map +1 -0
- package/packages/server/dist/core/templates.d.ts +28 -0
- package/packages/server/dist/core/templates.d.ts.map +1 -0
- package/packages/server/dist/core/templates.js +103 -0
- package/packages/server/dist/core/templates.js.map +1 -0
- package/packages/server/dist/core/tenant-context.d.ts +18 -0
- package/packages/server/dist/core/tenant-context.d.ts.map +1 -0
- package/packages/server/dist/core/tenant-context.js +42 -0
- package/packages/server/dist/core/tenant-context.js.map +1 -0
- package/packages/server/dist/core/tenant-id.d.ts +8 -0
- package/packages/server/dist/core/tenant-id.d.ts.map +1 -0
- package/packages/server/dist/core/tenant-id.js +53 -0
- package/packages/server/dist/core/tenant-id.js.map +1 -0
- package/packages/server/dist/core/tenant-skills.d.ts +29 -0
- package/packages/server/dist/core/tenant-skills.d.ts.map +1 -0
- package/packages/server/dist/core/tenant-skills.js +77 -0
- package/packages/server/dist/core/tenant-skills.js.map +1 -0
- package/packages/server/dist/core/worker-agents-fs.d.ts +44 -0
- package/packages/server/dist/core/worker-agents-fs.d.ts.map +1 -0
- package/packages/server/dist/core/worker-agents-fs.js +86 -0
- package/packages/server/dist/core/worker-agents-fs.js.map +1 -0
- package/packages/server/dist/core/worker-agents.d.ts +77 -0
- package/packages/server/dist/core/worker-agents.d.ts.map +1 -0
- package/packages/server/dist/core/worker-agents.js +191 -0
- package/packages/server/dist/core/worker-agents.js.map +1 -0
- package/packages/server/dist/index.d.ts +2 -0
- package/packages/server/dist/index.d.ts.map +1 -0
- package/packages/server/dist/index.js +623 -0
- package/packages/server/dist/index.js.map +1 -0
- package/packages/server/dist/lsp/client.d.ts +53 -0
- package/packages/server/dist/lsp/client.d.ts.map +1 -0
- package/packages/server/dist/lsp/client.js +258 -0
- package/packages/server/dist/lsp/client.js.map +1 -0
- package/packages/server/dist/lsp/format.d.ts +13 -0
- package/packages/server/dist/lsp/format.d.ts.map +1 -0
- package/packages/server/dist/lsp/format.js +55 -0
- package/packages/server/dist/lsp/format.js.map +1 -0
- package/packages/server/dist/lsp/index.d.ts +20 -0
- package/packages/server/dist/lsp/index.d.ts.map +1 -0
- package/packages/server/dist/lsp/index.js +32 -0
- package/packages/server/dist/lsp/index.js.map +1 -0
- package/packages/server/dist/lsp/language-registry.d.ts +29 -0
- package/packages/server/dist/lsp/language-registry.d.ts.map +1 -0
- package/packages/server/dist/lsp/language-registry.js +62 -0
- package/packages/server/dist/lsp/language-registry.js.map +1 -0
- package/packages/server/dist/lsp/manager.d.ts +77 -0
- package/packages/server/dist/lsp/manager.d.ts.map +1 -0
- package/packages/server/dist/lsp/manager.js +300 -0
- package/packages/server/dist/lsp/manager.js.map +1 -0
- package/packages/server/dist/plugins-routes.d.ts +96 -0
- package/packages/server/dist/plugins-routes.d.ts.map +1 -0
- package/packages/server/dist/plugins-routes.js +627 -0
- package/packages/server/dist/plugins-routes.js.map +1 -0
- package/packages/server/dist/setup/checks/config.d.ts +9 -0
- package/packages/server/dist/setup/checks/config.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/config.js +66 -0
- package/packages/server/dist/setup/checks/config.js.map +1 -0
- package/packages/server/dist/setup/checks/db.d.ts +6 -0
- package/packages/server/dist/setup/checks/db.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/db.js +79 -0
- package/packages/server/dist/setup/checks/db.js.map +1 -0
- package/packages/server/dist/setup/checks/known-models.d.ts +18 -0
- package/packages/server/dist/setup/checks/known-models.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/known-models.js +119 -0
- package/packages/server/dist/setup/checks/known-models.js.map +1 -0
- package/packages/server/dist/setup/checks/network.d.ts +11 -0
- package/packages/server/dist/setup/checks/network.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/network.js +176 -0
- package/packages/server/dist/setup/checks/network.js.map +1 -0
- package/packages/server/dist/setup/checks/plugins.d.ts +9 -0
- package/packages/server/dist/setup/checks/plugins.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/plugins.js +194 -0
- package/packages/server/dist/setup/checks/plugins.js.map +1 -0
- package/packages/server/dist/setup/checks/providers.d.ts +12 -0
- package/packages/server/dist/setup/checks/providers.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/providers.js +368 -0
- package/packages/server/dist/setup/checks/providers.js.map +1 -0
- package/packages/server/dist/setup/checks/runtime.d.ts +3 -0
- package/packages/server/dist/setup/checks/runtime.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/runtime.js +44 -0
- package/packages/server/dist/setup/checks/runtime.js.map +1 -0
- package/packages/server/dist/setup/checks/sandbox.d.ts +9 -0
- package/packages/server/dist/setup/checks/sandbox.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/sandbox.js +110 -0
- package/packages/server/dist/setup/checks/sandbox.js.map +1 -0
- package/packages/server/dist/setup/checks/tenants.d.ts +9 -0
- package/packages/server/dist/setup/checks/tenants.d.ts.map +1 -0
- package/packages/server/dist/setup/checks/tenants.js +509 -0
- package/packages/server/dist/setup/checks/tenants.js.map +1 -0
- package/packages/server/dist/setup/cli-agent.d.ts +39 -0
- package/packages/server/dist/setup/cli-agent.d.ts.map +1 -0
- package/packages/server/dist/setup/cli-agent.js +1353 -0
- package/packages/server/dist/setup/cli-agent.js.map +1 -0
- package/packages/server/dist/setup/doctor.d.ts +32 -0
- package/packages/server/dist/setup/doctor.d.ts.map +1 -0
- package/packages/server/dist/setup/doctor.js +80 -0
- package/packages/server/dist/setup/doctor.js.map +1 -0
- package/packages/server/dist/setup/launchd.d.ts +107 -0
- package/packages/server/dist/setup/launchd.d.ts.map +1 -0
- package/packages/server/dist/setup/launchd.js +309 -0
- package/packages/server/dist/setup/launchd.js.map +1 -0
- package/packages/server/dist/setup/load-env.d.ts +21 -0
- package/packages/server/dist/setup/load-env.d.ts.map +1 -0
- package/packages/server/dist/setup/load-env.js +88 -0
- package/packages/server/dist/setup/load-env.js.map +1 -0
- package/packages/server/dist/setup/probe-default-model.d.ts +28 -0
- package/packages/server/dist/setup/probe-default-model.d.ts.map +1 -0
- package/packages/server/dist/setup/probe-default-model.js +133 -0
- package/packages/server/dist/setup/probe-default-model.js.map +1 -0
- package/packages/server/dist/setup/render.d.ts +28 -0
- package/packages/server/dist/setup/render.d.ts.map +1 -0
- package/packages/server/dist/setup/render.js +60 -0
- package/packages/server/dist/setup/render.js.map +1 -0
- package/packages/server/dist/setup/repo-root.d.ts +3 -0
- package/packages/server/dist/setup/repo-root.d.ts.map +1 -0
- package/packages/server/dist/setup/repo-root.js +43 -0
- package/packages/server/dist/setup/repo-root.js.map +1 -0
- package/packages/server/dist/setup/service.d.ts +60 -0
- package/packages/server/dist/setup/service.d.ts.map +1 -0
- package/packages/server/dist/setup/service.js +345 -0
- package/packages/server/dist/setup/service.js.map +1 -0
- package/packages/server/dist/setup/start-server.d.ts +23 -0
- package/packages/server/dist/setup/start-server.d.ts.map +1 -0
- package/packages/server/dist/setup/start-server.js +465 -0
- package/packages/server/dist/setup/start-server.js.map +1 -0
- package/packages/server/dist/setup/wizard.d.ts +59 -0
- package/packages/server/dist/setup/wizard.d.ts.map +1 -0
- package/packages/server/dist/setup/wizard.js +556 -0
- package/packages/server/dist/setup/wizard.js.map +1 -0
- package/packages/server/dist/tools/edit-file.d.ts +13 -0
- package/packages/server/dist/tools/edit-file.d.ts.map +1 -0
- package/packages/server/dist/tools/edit-file.js +90 -0
- package/packages/server/dist/tools/edit-file.js.map +1 -0
- package/packages/server/dist/tools/glob.d.ts +12 -0
- package/packages/server/dist/tools/glob.d.ts.map +1 -0
- package/packages/server/dist/tools/glob.js +82 -0
- package/packages/server/dist/tools/glob.js.map +1 -0
- package/packages/server/dist/tools/index.d.ts +82 -0
- package/packages/server/dist/tools/index.d.ts.map +1 -0
- package/packages/server/dist/tools/index.js +72 -0
- package/packages/server/dist/tools/index.js.map +1 -0
- package/packages/server/dist/tools/list-dir.d.ts +24 -0
- package/packages/server/dist/tools/list-dir.d.ts.map +1 -0
- package/packages/server/dist/tools/list-dir.js +99 -0
- package/packages/server/dist/tools/list-dir.js.map +1 -0
- package/packages/server/dist/tools/path-helper.d.ts +15 -0
- package/packages/server/dist/tools/path-helper.d.ts.map +1 -0
- package/packages/server/dist/tools/path-helper.js +72 -0
- package/packages/server/dist/tools/path-helper.js.map +1 -0
- package/packages/server/dist/tools/read-file.d.ts +17 -0
- package/packages/server/dist/tools/read-file.d.ts.map +1 -0
- package/packages/server/dist/tools/read-file.js +94 -0
- package/packages/server/dist/tools/read-file.js.map +1 -0
- package/packages/server/dist/tools/sandbox.d.ts +57 -0
- package/packages/server/dist/tools/sandbox.d.ts.map +1 -0
- package/packages/server/dist/tools/sandbox.js +291 -0
- package/packages/server/dist/tools/sandbox.js.map +1 -0
- package/packages/server/dist/tools/write-file.d.ts +12 -0
- package/packages/server/dist/tools/write-file.d.ts.map +1 -0
- package/packages/server/dist/tools/write-file.js +67 -0
- package/packages/server/dist/tools/write-file.js.map +1 -0
- package/packages/server/dist/worker-agents-routes.d.ts +11 -0
- package/packages/server/dist/worker-agents-routes.d.ts.map +1 -0
- package/packages/server/dist/worker-agents-routes.js +253 -0
- package/packages/server/dist/worker-agents-routes.js.map +1 -0
- package/packages/server/package.json +41 -0
- package/packages/web/dist/assets/index-DH-gJ09_.js +60 -0
- package/packages/web/dist/assets/index-xU4lYYqY.css +2 -0
- package/packages/web/dist/index.html +14 -0
- package/packages/web/package.json +36 -0
- package/plugins/README.md +64 -0
- package/plugins/files/dist/client.d.ts +5 -0
- package/plugins/files/dist/client.d.ts.map +1 -0
- package/plugins/files/dist/client.js +354 -0
- package/plugins/files/dist/client.js.map +1 -0
- package/plugins/files/dist/server.d.ts +32 -0
- package/plugins/files/dist/server.d.ts.map +1 -0
- package/plugins/files/dist/server.js +514 -0
- package/plugins/files/dist/server.js.map +1 -0
- package/plugins/files/dist/tools/edit-file.d.ts +29 -0
- package/plugins/files/dist/tools/edit-file.d.ts.map +1 -0
- package/plugins/files/dist/tools/edit-file.js +230 -0
- package/plugins/files/dist/tools/edit-file.js.map +1 -0
- package/plugins/files/dist/tools/edit-file.prompt.md +36 -0
- package/plugins/files/dist/tools/glob.d.ts +12 -0
- package/plugins/files/dist/tools/glob.d.ts.map +1 -0
- package/plugins/files/dist/tools/glob.js +84 -0
- package/plugins/files/dist/tools/glob.js.map +1 -0
- package/plugins/files/dist/tools/index.d.ts +13 -0
- package/plugins/files/dist/tools/index.d.ts.map +1 -0
- package/plugins/files/dist/tools/index.js +158 -0
- package/plugins/files/dist/tools/index.js.map +1 -0
- package/plugins/files/dist/tools/list-dir.d.ts +24 -0
- package/plugins/files/dist/tools/list-dir.d.ts.map +1 -0
- package/plugins/files/dist/tools/list-dir.js +104 -0
- package/plugins/files/dist/tools/list-dir.js.map +1 -0
- package/plugins/files/dist/tools/load-prompt.d.ts +5 -0
- package/plugins/files/dist/tools/load-prompt.d.ts.map +1 -0
- package/plugins/files/dist/tools/load-prompt.js +39 -0
- package/plugins/files/dist/tools/load-prompt.js.map +1 -0
- package/plugins/files/dist/tools/path-helper.d.ts +32 -0
- package/plugins/files/dist/tools/path-helper.d.ts.map +1 -0
- package/plugins/files/dist/tools/path-helper.js +113 -0
- package/plugins/files/dist/tools/path-helper.js.map +1 -0
- package/plugins/files/dist/tools/read-file.d.ts +17 -0
- package/plugins/files/dist/tools/read-file.d.ts.map +1 -0
- package/plugins/files/dist/tools/read-file.js +109 -0
- package/plugins/files/dist/tools/read-file.js.map +1 -0
- package/plugins/files/dist/tools/read-tracker.d.ts +28 -0
- package/plugins/files/dist/tools/read-tracker.d.ts.map +1 -0
- package/plugins/files/dist/tools/read-tracker.js +135 -0
- package/plugins/files/dist/tools/read-tracker.js.map +1 -0
- package/plugins/files/dist/tools/replacers.d.ts +27 -0
- package/plugins/files/dist/tools/replacers.d.ts.map +1 -0
- package/plugins/files/dist/tools/replacers.js +221 -0
- package/plugins/files/dist/tools/replacers.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-delete.d.ts +12 -0
- package/plugins/files/dist/tools/tenant-config-delete.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-delete.js +70 -0
- package/plugins/files/dist/tools/tenant-config-delete.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-edit.d.ts +25 -0
- package/plugins/files/dist/tools/tenant-config-edit.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-edit.js +142 -0
- package/plugins/files/dist/tools/tenant-config-edit.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-glob.d.ts +12 -0
- package/plugins/files/dist/tools/tenant-config-glob.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-glob.js +64 -0
- package/plugins/files/dist/tools/tenant-config-glob.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-helper.d.ts +64 -0
- package/plugins/files/dist/tools/tenant-config-helper.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-helper.js +162 -0
- package/plugins/files/dist/tools/tenant-config-helper.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-list.d.ts +20 -0
- package/plugins/files/dist/tools/tenant-config-list.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-list.js +95 -0
- package/plugins/files/dist/tools/tenant-config-list.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-read.d.ts +17 -0
- package/plugins/files/dist/tools/tenant-config-read.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-read.js +87 -0
- package/plugins/files/dist/tools/tenant-config-read.js.map +1 -0
- package/plugins/files/dist/tools/tenant-config-write.d.ts +14 -0
- package/plugins/files/dist/tools/tenant-config-write.d.ts.map +1 -0
- package/plugins/files/dist/tools/tenant-config-write.js +78 -0
- package/plugins/files/dist/tools/tenant-config-write.js.map +1 -0
- package/plugins/files/dist/tools/text-shape.d.ts +20 -0
- package/plugins/files/dist/tools/text-shape.d.ts.map +1 -0
- package/plugins/files/dist/tools/text-shape.js +57 -0
- package/plugins/files/dist/tools/text-shape.js.map +1 -0
- package/plugins/files/dist/tools/write-file.d.ts +12 -0
- package/plugins/files/dist/tools/write-file.d.ts.map +1 -0
- package/plugins/files/dist/tools/write-file.js +89 -0
- package/plugins/files/dist/tools/write-file.js.map +1 -0
- package/plugins/files/dist/tools/write-file.prompt.md +14 -0
- package/plugins/files/manifest.json +100 -0
- package/plugins/files/package.json +39 -0
- package/plugins/files/skills/files-workspace-layout.md +29 -0
- package/plugins/microsandbox/dist/admin/browser-routes.d.ts +41 -0
- package/plugins/microsandbox/dist/admin/browser-routes.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/browser-routes.js +208 -0
- package/plugins/microsandbox/dist/admin/browser-routes.js.map +1 -0
- package/plugins/microsandbox/dist/admin/preview-exec.d.ts +38 -0
- package/plugins/microsandbox/dist/admin/preview-exec.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/preview-exec.js +185 -0
- package/plugins/microsandbox/dist/admin/preview-exec.js.map +1 -0
- package/plugins/microsandbox/dist/admin/routes.d.ts +35 -0
- package/plugins/microsandbox/dist/admin/routes.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/routes.js +728 -0
- package/plugins/microsandbox/dist/admin/routes.js.map +1 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.d.ts +11 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.js +72 -0
- package/plugins/microsandbox/dist/admin/sandboxfile-io.js.map +1 -0
- package/plugins/microsandbox/dist/admin/templates.d.ts +16 -0
- package/plugins/microsandbox/dist/admin/templates.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin/templates.js +66 -0
- package/plugins/microsandbox/dist/admin/templates.js.map +1 -0
- package/plugins/microsandbox/dist/admin.d.ts +5 -0
- package/plugins/microsandbox/dist/admin.d.ts.map +1 -0
- package/plugins/microsandbox/dist/admin.js +256 -0
- package/plugins/microsandbox/dist/admin.js.map +1 -0
- package/plugins/microsandbox/dist/build/builder.d.ts +69 -0
- package/plugins/microsandbox/dist/build/builder.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/builder.js +257 -0
- package/plugins/microsandbox/dist/build/builder.js.map +1 -0
- package/plugins/microsandbox/dist/build/metadata.d.ts +27 -0
- package/plugins/microsandbox/dist/build/metadata.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/metadata.js +55 -0
- package/plugins/microsandbox/dist/build/metadata.js.map +1 -0
- package/plugins/microsandbox/dist/build/pointer.d.ts +51 -0
- package/plugins/microsandbox/dist/build/pointer.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/pointer.js +130 -0
- package/plugins/microsandbox/dist/build/pointer.js.map +1 -0
- package/plugins/microsandbox/dist/build/sandboxfile.d.ts +15 -0
- package/plugins/microsandbox/dist/build/sandboxfile.d.ts.map +1 -0
- package/plugins/microsandbox/dist/build/sandboxfile.js +176 -0
- package/plugins/microsandbox/dist/build/sandboxfile.js.map +1 -0
- package/plugins/microsandbox/dist/client.d.ts +5 -0
- package/plugins/microsandbox/dist/client.d.ts.map +1 -0
- package/plugins/microsandbox/dist/client.js +941 -0
- package/plugins/microsandbox/dist/client.js.map +1 -0
- package/plugins/microsandbox/dist/runner/browser.d.ts +50 -0
- package/plugins/microsandbox/dist/runner/browser.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/browser.js +142 -0
- package/plugins/microsandbox/dist/runner/browser.js.map +1 -0
- package/plugins/microsandbox/dist/runner/free-port.d.ts +6 -0
- package/plugins/microsandbox/dist/runner/free-port.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/free-port.js +53 -0
- package/plugins/microsandbox/dist/runner/free-port.js.map +1 -0
- package/plugins/microsandbox/dist/runner/index.d.ts +28 -0
- package/plugins/microsandbox/dist/runner/index.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/index.js +72 -0
- package/plugins/microsandbox/dist/runner/index.js.map +1 -0
- package/plugins/microsandbox/dist/runner/microsandbox.d.ts +64 -0
- package/plugins/microsandbox/dist/runner/microsandbox.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/microsandbox.js +668 -0
- package/plugins/microsandbox/dist/runner/microsandbox.js.map +1 -0
- package/plugins/microsandbox/dist/runner/nullable.d.ts +36 -0
- package/plugins/microsandbox/dist/runner/nullable.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/nullable.js +82 -0
- package/plugins/microsandbox/dist/runner/nullable.js.map +1 -0
- package/plugins/microsandbox/dist/runner/pool.d.ts +97 -0
- package/plugins/microsandbox/dist/runner/pool.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/pool.js +494 -0
- package/plugins/microsandbox/dist/runner/pool.js.map +1 -0
- package/plugins/microsandbox/dist/runner/types.d.ts +33 -0
- package/plugins/microsandbox/dist/runner/types.d.ts.map +1 -0
- package/plugins/microsandbox/dist/runner/types.js +79 -0
- package/plugins/microsandbox/dist/runner/types.js.map +1 -0
- package/plugins/microsandbox/dist/server.d.ts +7 -0
- package/plugins/microsandbox/dist/server.d.ts.map +1 -0
- package/plugins/microsandbox/dist/server.js +276 -0
- package/plugins/microsandbox/dist/server.js.map +1 -0
- package/plugins/microsandbox/dist/tools/browser.d.ts +25 -0
- package/plugins/microsandbox/dist/tools/browser.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/browser.js +78 -0
- package/plugins/microsandbox/dist/tools/browser.js.map +1 -0
- package/plugins/microsandbox/dist/tools/build.d.ts +5 -0
- package/plugins/microsandbox/dist/tools/build.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/build.js +243 -0
- package/plugins/microsandbox/dist/tools/build.js.map +1 -0
- package/plugins/microsandbox/dist/tools/index.d.ts +9 -0
- package/plugins/microsandbox/dist/tools/index.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/index.js +430 -0
- package/plugins/microsandbox/dist/tools/index.js.map +1 -0
- package/plugins/microsandbox/dist/tools/mcp-client.d.ts +63 -0
- package/plugins/microsandbox/dist/tools/mcp-client.d.ts.map +1 -0
- package/plugins/microsandbox/dist/tools/mcp-client.js +226 -0
- package/plugins/microsandbox/dist/tools/mcp-client.js.map +1 -0
- package/plugins/microsandbox/manifest.json +177 -0
- package/plugins/microsandbox/package.json +38 -0
- package/plugins/microsandbox/skills/microsandbox-browser-howto.md +155 -0
- package/plugins/microsandbox/skills/microsandbox-build-use.md +201 -0
- package/plugins/microsandbox/skills/microsandbox-config.md +38 -0
- package/plugins/microsandbox/skills/microsandbox-exec-howto.md +144 -0
- package/plugins/microsandbox/skills/microsandbox-libreoffice.md +159 -0
- package/plugins/microsandbox/templates/README.md +26 -0
- package/plugins/web-search/dist/server.d.ts +4 -0
- package/plugins/web-search/dist/server.d.ts.map +1 -0
- package/plugins/web-search/dist/server.js +73 -0
- package/plugins/web-search/dist/server.js.map +1 -0
- package/plugins/web-search/dist/tools/health.d.ts +31 -0
- package/plugins/web-search/dist/tools/health.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/health.js +59 -0
- package/plugins/web-search/dist/tools/health.js.map +1 -0
- package/plugins/web-search/dist/tools/index.d.ts +3 -0
- package/plugins/web-search/dist/tools/index.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/index.js +2 -0
- package/plugins/web-search/dist/tools/index.js.map +1 -0
- package/plugins/web-search/dist/tools/providers.d.ts +43 -0
- package/plugins/web-search/dist/tools/providers.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/providers.js +140 -0
- package/plugins/web-search/dist/tools/providers.js.map +1 -0
- package/plugins/web-search/dist/tools/web-search.d.ts +15 -0
- package/plugins/web-search/dist/tools/web-search.d.ts.map +1 -0
- package/plugins/web-search/dist/tools/web-search.js +244 -0
- package/plugins/web-search/dist/tools/web-search.js.map +1 -0
- package/plugins/web-search/manifest.json +65 -0
- package/plugins/web-search/node_modules/@esbuild/darwin-arm64/README.md +3 -0
- package/plugins/web-search/node_modules/@esbuild/darwin-arm64/package.json +20 -0
- package/plugins/web-search/node_modules/@vitest/expect/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/expect/README.md +21 -0
- package/plugins/web-search/node_modules/@vitest/expect/dist/index.d.ts +808 -0
- package/plugins/web-search/node_modules/@vitest/expect/dist/index.js +1799 -0
- package/plugins/web-search/node_modules/@vitest/expect/package.json +46 -0
- package/plugins/web-search/node_modules/@vitest/mocker/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/mocker/README.md +5 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/auto-register.d.ts +2 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/auto-register.js +9 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/browser.d.ts +53 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/browser.js +91 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-interceptor-native.js +15 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-mocker.js +1602 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-pathe.M-eThtNZ.js +174 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-registry.js +182 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-utils.js +16 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/index.d.ts +21 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/index.js +174 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/mocker.d-Ce9_ySj5.d.ts +83 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/node.d.ts +821 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/node.js +1306 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/redirect.d.ts +3 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/redirect.js +75 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/register.d.ts +9 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/register.js +41 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/registry.d-D765pazg.d.ts +87 -0
- package/plugins/web-search/node_modules/@vitest/mocker/dist/types.d-D_aRZRdy.d.ts +8 -0
- package/plugins/web-search/node_modules/@vitest/mocker/package.json +82 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/dist/index.d.ts +119 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/dist/index.js +1387 -0
- package/plugins/web-search/node_modules/@vitest/pretty-format/package.json +44 -0
- package/plugins/web-search/node_modules/@vitest/runner/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/runner/README.md +5 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/chunk-hooks.js +2254 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/index.d.ts +261 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/index.js +6 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/tasks.d-CkscK4of.d.ts +558 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/types.d.ts +163 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/types.js +1 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/utils.d.ts +47 -0
- package/plugins/web-search/node_modules/@vitest/runner/dist/utils.js +6 -0
- package/plugins/web-search/node_modules/@vitest/runner/package.json +49 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/README.md +84 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.d-DHdQ1Csl.d.ts +22 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.d.ts +16 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.js +40 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/index.d.ts +137 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/index.js +2305 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/manager.d.ts +18 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/manager.js +73 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/dist/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
- package/plugins/web-search/node_modules/@vitest/snapshot/package.json +54 -0
- package/plugins/web-search/node_modules/@vitest/spy/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/spy/README.md +3 -0
- package/plugins/web-search/node_modules/@vitest/spy/dist/index.d.ts +356 -0
- package/plugins/web-search/node_modules/@vitest/spy/dist/index.js +191 -0
- package/plugins/web-search/node_modules/@vitest/spy/package.json +38 -0
- package/plugins/web-search/node_modules/@vitest/utils/LICENSE +21 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +158 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/diff.d.ts +104 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/diff.js +2185 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/error.d.ts +9 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/error.js +162 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/helpers.d.ts +56 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/helpers.js +251 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/index.d.ts +57 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/index.js +633 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/source-map.d.ts +139 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/source-map.js +996 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts +53 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/types.d.ts +53 -0
- package/plugins/web-search/node_modules/@vitest/utils/dist/types.js +1 -0
- package/plugins/web-search/node_modules/@vitest/utils/package.json +77 -0
- package/plugins/web-search/node_modules/chai/LICENSE +21 -0
- package/plugins/web-search/node_modules/chai/README.md +162 -0
- package/plugins/web-search/node_modules/chai/package.json +74 -0
- package/plugins/web-search/node_modules/esbuild/README.md +3 -0
- package/plugins/web-search/node_modules/esbuild/package.json +49 -0
- package/plugins/web-search/node_modules/std-env/README.md +118 -0
- package/plugins/web-search/node_modules/std-env/dist/index.cjs +1 -0
- package/plugins/web-search/node_modules/std-env/dist/index.d.cts +92 -0
- package/plugins/web-search/node_modules/std-env/dist/index.d.mts +92 -0
- package/plugins/web-search/node_modules/std-env/dist/index.d.ts +92 -0
- package/plugins/web-search/node_modules/std-env/dist/index.mjs +1 -0
- package/plugins/web-search/node_modules/std-env/package.json +46 -0
- package/plugins/web-search/node_modules/tinyexec/LICENSE +21 -0
- package/plugins/web-search/node_modules/tinyexec/README.md +256 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.cjs +575 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.d.cts +70 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.d.ts +70 -0
- package/plugins/web-search/node_modules/tinyexec/dist/main.js +578 -0
- package/plugins/web-search/node_modules/tinyexec/package.json +66 -0
- package/plugins/web-search/node_modules/tinyrainbow/README.md +28 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/browser.d.ts +8 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/browser.js +20 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +90 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/index-8b61d5bc.d.ts +59 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/node.d.ts +8 -0
- package/plugins/web-search/node_modules/tinyrainbow/dist/node.js +22 -0
- package/plugins/web-search/node_modules/tinyrainbow/package.json +37 -0
- package/plugins/web-search/node_modules/typescript/README.md +50 -0
- package/plugins/web-search/node_modules/typescript/package.json +120 -0
- package/plugins/web-search/node_modules/vite/README.md +20 -0
- package/plugins/web-search/node_modules/vite/dist/client/client.mjs +1106 -0
- package/plugins/web-search/node_modules/vite/dist/client/env.mjs +19 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/build.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/build2.js +5538 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/chunk.js +48 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/config.js +36065 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/config2.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/dist.js +6758 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/lib.js +377 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/logger.js +329 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +96 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/optimizer.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/postcss-import.js +479 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/preview.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/chunks/server.js +4 -0
- package/plugins/web-search/node_modules/vite/dist/node/cli.js +698 -0
- package/plugins/web-search/node_modules/vite/dist/node/index.d.ts +3717 -0
- package/plugins/web-search/node_modules/vite/dist/node/index.js +30 -0
- package/plugins/web-search/node_modules/vite/dist/node/module-runner.d.ts +311 -0
- package/plugins/web-search/node_modules/vite/dist/node/module-runner.js +1160 -0
- package/plugins/web-search/node_modules/vite/package.json +199 -0
- package/plugins/web-search/node_modules/vite/types/package.json +4 -0
- package/plugins/web-search/node_modules/vitest/README.md +7 -0
- package/plugins/web-search/node_modules/vitest/dist/browser.d.ts +34 -0
- package/plugins/web-search/node_modules/vitest/dist/browser.js +8 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +7 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/base.DfmxU-tU.js +38 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/benchmark.CYdenmiT.js +37 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/benchmark.d.BwvBVTda.d.ts +24 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/cac.0BJqEUeA.js +1469 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/cli-api.DWGBtMmz.js +10660 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/config.d.BKdhh7Zx.d.ts +224 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/console.CtFJOzRO.js +153 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/constants.DnKduX2e.js +44 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.DVF1vEu8.js +25 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.DfSpMS-b.js +4350 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.d.S9RMNXIe.d.ts +35 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/creator.GK6I-cL4.js +640 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +73 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/defaults.B7q_naMc.js +115 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/env.D4Lgay0q.js +8 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/environment.d.cL3nLXbE.d.ts +119 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/execute.B7h3T_Hc.js +708 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/git.BVQ8w_Sw.js +72 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/global.d.MAmajcmJ.d.ts +136 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/globals.DEHgCU4V.js +26 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.B521nVV-.js +157 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.BCWujgDG.js +231 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.CdQS2e2Q.js +37 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.CmSc2RE5.js +587 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.CwejwG0H.js +105 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.D3XRDfWc.js +213 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.VByaPkjc.js +2183 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/index.X0nbfr6-.js +6584 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/inspector.C914Efll.js +57 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/mocker.d.BE_2ls6u.d.ts +17 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/node.fjCdwEIl.js +15 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/reporters.d.BuRON0I0.d.ts +3168 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/rpc.-pEldfrD.js +83 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js +129 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/setup-common.Dd054P77.js +60 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/suite.d.FvehnV49.d.ts +10 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/typechecker.DRKU1-1g.js +874 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/utils.CAioKnHs.js +61 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +65 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +4015 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/vite.d.BnOPPc46.d.ts +25 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/vm.BThCzidc.js +756 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/worker.d.CUgIPz9V.d.ts +176 -0
- package/plugins/web-search/node_modules/vitest/dist/chunks/worker.d.uzWsCv9X.d.ts +8 -0
- package/plugins/web-search/node_modules/vitest/dist/cli.js +27 -0
- package/plugins/web-search/node_modules/vitest/dist/config.cjs +148 -0
- package/plugins/web-search/node_modules/vitest/dist/config.d.ts +100 -0
- package/plugins/web-search/node_modules/vitest/dist/config.js +21 -0
- package/plugins/web-search/node_modules/vitest/dist/coverage.d.ts +108 -0
- package/plugins/web-search/node_modules/vitest/dist/coverage.js +34 -0
- package/plugins/web-search/node_modules/vitest/dist/environments.d.ts +26 -0
- package/plugins/web-search/node_modules/vitest/dist/environments.js +2 -0
- package/plugins/web-search/node_modules/vitest/dist/execute.d.ts +150 -0
- package/plugins/web-search/node_modules/vitest/dist/execute.js +13 -0
- package/plugins/web-search/node_modules/vitest/dist/index.d.ts +651 -0
- package/plugins/web-search/node_modules/vitest/dist/index.js +18 -0
- package/plugins/web-search/node_modules/vitest/dist/mocker.d.ts +1 -0
- package/plugins/web-search/node_modules/vitest/dist/mocker.js +1 -0
- package/plugins/web-search/node_modules/vitest/dist/node.d.ts +158 -0
- package/plugins/web-search/node_modules/vitest/dist/node.js +105 -0
- package/plugins/web-search/node_modules/vitest/dist/path.js +7 -0
- package/plugins/web-search/node_modules/vitest/dist/reporters.d.ts +25 -0
- package/plugins/web-search/node_modules/vitest/dist/reporters.js +23 -0
- package/plugins/web-search/node_modules/vitest/dist/runners.d.ts +46 -0
- package/plugins/web-search/node_modules/vitest/dist/runners.js +235 -0
- package/plugins/web-search/node_modules/vitest/dist/snapshot.d.ts +9 -0
- package/plugins/web-search/node_modules/vitest/dist/snapshot.js +4 -0
- package/plugins/web-search/node_modules/vitest/dist/spy.js +1 -0
- package/plugins/web-search/node_modules/vitest/dist/suite.d.ts +5 -0
- package/plugins/web-search/node_modules/vitest/dist/suite.js +5 -0
- package/plugins/web-search/node_modules/vitest/dist/worker.js +124 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/forks.js +43 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/runVmTests.js +90 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/threads.js +31 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/vmForks.js +47 -0
- package/plugins/web-search/node_modules/vitest/dist/workers/vmThreads.js +37 -0
- package/plugins/web-search/node_modules/vitest/dist/workers.d.ts +40 -0
- package/plugins/web-search/node_modules/vitest/dist/workers.js +30 -0
- package/plugins/web-search/node_modules/vitest/package.json +207 -0
- package/plugins/web-search/package.json +30 -0
- package/plugins/web-search/skills/web-search-howto.md +69 -0
- package/plugins/workboard/agent-seeds/echo-demo/agent.json +7 -0
- package/plugins/workboard/agent-seeds/llm-default/SOUL.md +53 -0
- package/plugins/workboard/agent-seeds/llm-default/agent.json +7 -0
- package/plugins/workboard/dist/client.d.ts +5 -0
- package/plugins/workboard/dist/client.d.ts.map +1 -0
- package/plugins/workboard/dist/client.js +895 -0
- package/plugins/workboard/dist/client.js.map +1 -0
- package/plugins/workboard/dist/db/agents.d.ts +100 -0
- package/plugins/workboard/dist/db/agents.d.ts.map +1 -0
- package/plugins/workboard/dist/db/agents.js +280 -0
- package/plugins/workboard/dist/db/agents.js.map +1 -0
- package/plugins/workboard/dist/db/schema.d.ts +3 -0
- package/plugins/workboard/dist/db/schema.d.ts.map +1 -0
- package/plugins/workboard/dist/db/schema.js +31 -0
- package/plugins/workboard/dist/db/schema.js.map +1 -0
- package/plugins/workboard/dist/db/session-history.d.ts +28 -0
- package/plugins/workboard/dist/db/session-history.d.ts.map +1 -0
- package/plugins/workboard/dist/db/session-history.js +224 -0
- package/plugins/workboard/dist/db/session-history.js.map +1 -0
- package/plugins/workboard/dist/db/tasks.d.ts +260 -0
- package/plugins/workboard/dist/db/tasks.d.ts.map +1 -0
- package/plugins/workboard/dist/db/tasks.js +451 -0
- package/plugins/workboard/dist/db/tasks.js.map +1 -0
- package/plugins/workboard/dist/db/worker-agents.d.ts +16 -0
- package/plugins/workboard/dist/db/worker-agents.d.ts.map +1 -0
- package/plugins/workboard/dist/db/worker-agents.js +62 -0
- package/plugins/workboard/dist/db/worker-agents.js.map +1 -0
- package/plugins/workboard/dist/effective-skills.d.ts +13 -0
- package/plugins/workboard/dist/effective-skills.d.ts.map +1 -0
- package/plugins/workboard/dist/effective-skills.js +126 -0
- package/plugins/workboard/dist/effective-skills.js.map +1 -0
- package/plugins/workboard/dist/fs-worker-agents.d.ts +35 -0
- package/plugins/workboard/dist/fs-worker-agents.d.ts.map +1 -0
- package/plugins/workboard/dist/fs-worker-agents.js +199 -0
- package/plugins/workboard/dist/fs-worker-agents.js.map +1 -0
- package/plugins/workboard/dist/migrate-worker-agents.d.ts +11 -0
- package/plugins/workboard/dist/migrate-worker-agents.d.ts.map +1 -0
- package/plugins/workboard/dist/migrate-worker-agents.js +89 -0
- package/plugins/workboard/dist/migrate-worker-agents.js.map +1 -0
- package/plugins/workboard/dist/routes/handlers.d.ts +106 -0
- package/plugins/workboard/dist/routes/handlers.d.ts.map +1 -0
- package/plugins/workboard/dist/routes/handlers.js +668 -0
- package/plugins/workboard/dist/routes/handlers.js.map +1 -0
- package/plugins/workboard/dist/server.d.ts +6 -0
- package/plugins/workboard/dist/server.d.ts.map +1 -0
- package/plugins/workboard/dist/server.js +368 -0
- package/plugins/workboard/dist/server.js.map +1 -0
- package/plugins/workboard/dist/tools/index.d.ts +70 -0
- package/plugins/workboard/dist/tools/index.d.ts.map +1 -0
- package/plugins/workboard/dist/tools/index.js +963 -0
- package/plugins/workboard/dist/tools/index.js.map +1 -0
- package/plugins/workboard/dist/types.d.ts +27 -0
- package/plugins/workboard/dist/types.d.ts.map +1 -0
- package/plugins/workboard/dist/types.js +16 -0
- package/plugins/workboard/dist/types.js.map +1 -0
- package/plugins/workboard/dist/worker/pool.d.ts +220 -0
- package/plugins/workboard/dist/worker/pool.d.ts.map +1 -0
- package/plugins/workboard/dist/worker/pool.js +866 -0
- package/plugins/workboard/dist/worker/pool.js.map +1 -0
- package/plugins/workboard/dist/worker/tool-policy.d.ts +27 -0
- package/plugins/workboard/dist/worker/tool-policy.d.ts.map +1 -0
- package/plugins/workboard/dist/worker/tool-policy.js +76 -0
- package/plugins/workboard/dist/worker/tool-policy.js.map +1 -0
- package/plugins/workboard/dist/worker-agents-page.d.ts +4 -0
- package/plugins/workboard/dist/worker-agents-page.d.ts.map +1 -0
- package/plugins/workboard/dist/worker-agents-page.js +193 -0
- package/plugins/workboard/dist/worker-agents-page.js.map +1 -0
- package/plugins/workboard/manifest.json +180 -0
- package/plugins/workboard/package.json +37 -0
- package/plugins/workboard/skills/large-input-large-output.md +185 -0
- package/plugins/workboard/skills/workboard-howto.md +166 -0
- package/plugins/workboard/skills/worker-creator.md +267 -0
- package/plugins/workboard/skills/worker-fleet.md +431 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
// Session inbox: persisted bus for messages addressed to a chat
|
|
2
|
+
// session, with a process-local fast path through any active
|
|
3
|
+
// harness.
|
|
4
|
+
//
|
|
5
|
+
// Public surface:
|
|
6
|
+
// - enqueue(ctx, sessionId, message)
|
|
7
|
+
// Persist + try-deliver. Always resolves; persistence
|
|
8
|
+
// failure is logged + swallowed because the caller is
|
|
9
|
+
// usually a worker pool that can't usefully retry.
|
|
10
|
+
// - drainPending(ctx, sessionId)
|
|
11
|
+
// Pop all pending messages for a session. Used by the chat
|
|
12
|
+
// handler before prompt() to inject queued messages as a
|
|
13
|
+
// system-note prefix.
|
|
14
|
+
// - renderForPrompt(messages)
|
|
15
|
+
// Format the drained rows into a single text block ready
|
|
16
|
+
// to be prepended to the user's next prompt. Empty input
|
|
17
|
+
// returns an empty string.
|
|
18
|
+
//
|
|
19
|
+
// Storage shape lives in migrations/007-session-inbox.ts.
|
|
20
|
+
import { randomUUID } from "node:crypto";
|
|
21
|
+
import { getActiveHarness } from "./active-harnesses.js";
|
|
22
|
+
/**
|
|
23
|
+
* How long enqueue() waits before flushing accumulated pending
|
|
24
|
+
* messages to a live harness as a single batched followUp.
|
|
25
|
+
*
|
|
26
|
+
* Why we debounce instead of forwarding immediately:
|
|
27
|
+
* When a chat agent kicks off N parallel tasks (typical:
|
|
28
|
+
* `task_create` with `tasks: [...]` of 4-6 entries), they tend
|
|
29
|
+
* to finish within seconds of each other. Each independent
|
|
30
|
+
* followUp() lands as a separate `user` message in the
|
|
31
|
+
* session, so the agent sees N independent prompts and answers
|
|
32
|
+
* each one in full — read_file, evaluate, summarise. Across 4
|
|
33
|
+
* tasks that's 4 turns of reactive narration before the user
|
|
34
|
+
* gets the floor back, which is the "messy" feeling Yu
|
|
35
|
+
* reported. Debouncing a short window lets the inbox bundle
|
|
36
|
+
* them into one followUp like "4 tasks done, here are the
|
|
37
|
+
* summaries", which the agent can ack in one turn.
|
|
38
|
+
*
|
|
39
|
+
* 1500ms is a guess: long enough to coalesce a parallel batch,
|
|
40
|
+
* short enough that a single isolated done feels live. Tune later.
|
|
41
|
+
*/
|
|
42
|
+
const FLUSH_DEBOUNCE_MS = 1500;
|
|
43
|
+
/**
|
|
44
|
+
* Per-session pending-flush timers. We never queue more than one
|
|
45
|
+
* timer per session; if more inbox rows arrive while the timer
|
|
46
|
+
* is armed, they're picked up by the eventual drainPending in
|
|
47
|
+
* the timer body. The Map is module-scoped because the registry
|
|
48
|
+
* of active harnesses is too — they share the same single-process
|
|
49
|
+
* lifetime.
|
|
50
|
+
*/
|
|
51
|
+
const pendingFlushTimers = new Map();
|
|
52
|
+
/**
|
|
53
|
+
* Sessions for which an idle background turn is currently in
|
|
54
|
+
* flight. Used as a re-entrancy guard: if more inbox rows land
|
|
55
|
+
* while the background turn is mid-LLM-call, we don't kick a
|
|
56
|
+
* second turn — the running turn will see the new pending rows
|
|
57
|
+
* via drainPending at the start of its prompt build.
|
|
58
|
+
*/
|
|
59
|
+
const idleTurnsInFlight = new Set();
|
|
60
|
+
/**
|
|
61
|
+
* Sessions for which a `flushSessionInbox` invocation is
|
|
62
|
+
* currently running (covers both active-harness path and the
|
|
63
|
+
* idle-runner path — they're alternatives, never concurrent for
|
|
64
|
+
* the same session).
|
|
65
|
+
*
|
|
66
|
+
* Without this guard, two in-flight flushes for the same
|
|
67
|
+
* session can each call `drainPendingTentative`, see the same
|
|
68
|
+
* still-pending row (because tentative drain doesn't mark), and
|
|
69
|
+
* each push it to the harness, producing duplicate inbox
|
|
70
|
+
* messages in the chat. The lock means the second flush waits
|
|
71
|
+
* for the first to complete, then runs its own drain on whatever
|
|
72
|
+
* rows remain pending.
|
|
73
|
+
*/
|
|
74
|
+
const flushInFlight = new Set();
|
|
75
|
+
let boundIdleRunner = null;
|
|
76
|
+
/**
|
|
77
|
+
* Host calls this once at startup to wire in the runner. We
|
|
78
|
+
* accept null to support test reset.
|
|
79
|
+
*/
|
|
80
|
+
export function bindIdleRunner(runner) {
|
|
81
|
+
boundIdleRunner = runner;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Persist `message` for `targetSessionId` and arm a debounced
|
|
85
|
+
* flush to the live harness, if one is registered.
|
|
86
|
+
*
|
|
87
|
+
* We always write the DB row first so a process crash never
|
|
88
|
+
* loses a message — the `pending` row will be flushed on the
|
|
89
|
+
* next prompt regardless of what the live deliver does.
|
|
90
|
+
*
|
|
91
|
+
* The flush is debounced (FLUSH_DEBOUNCE_MS) and batched: when
|
|
92
|
+
* a parallel batch of tasks finishes within the window, the
|
|
93
|
+
* timer body drains ALL pending rows for the session and sends
|
|
94
|
+
* them as a single combined followUp. This is the difference
|
|
95
|
+
* between the agent seeing 4 separate "task done" prompts (and
|
|
96
|
+
* answering each in full) vs. one "4 tasks done" prompt it can
|
|
97
|
+
* acknowledge in one turn.
|
|
98
|
+
*/
|
|
99
|
+
export async function enqueue(ctx, targetSessionId, message) {
|
|
100
|
+
const id = `inbox_${randomUUID()}`;
|
|
101
|
+
const now = Date.now();
|
|
102
|
+
const payload = JSON.stringify(message);
|
|
103
|
+
ctx.db
|
|
104
|
+
.prepare(`INSERT INTO session_inbox
|
|
105
|
+
(id, target_session_id, payload, status, created_at)
|
|
106
|
+
VALUES (?, ?, ?, 'pending', ?)`)
|
|
107
|
+
.run(id, targetSessionId, payload, now);
|
|
108
|
+
// Always debounce-and-flush. The flush body picks the right
|
|
109
|
+
// delivery mode based on session state at the time it runs:
|
|
110
|
+
// - active harness → batched harness.followUp(...)
|
|
111
|
+
// - idle session → background runPrompt() turn (so the
|
|
112
|
+
// agent reacts even when the user isn't
|
|
113
|
+
// sending anything)
|
|
114
|
+
// - re-entrant idle → skip; the in-flight turn will pick up
|
|
115
|
+
// new pending rows itself.
|
|
116
|
+
scheduleFlush(ctx, targetSessionId);
|
|
117
|
+
return id;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Schedule a debounced `flushSessionInbox` for `sessionId`. No-op
|
|
121
|
+
* if a timer is already pending. Reused by both the public
|
|
122
|
+
* enqueue path and the post-flush "more arrived while we were
|
|
123
|
+
* working" follow-up.
|
|
124
|
+
*/
|
|
125
|
+
function scheduleFlush(ctx, sessionId) {
|
|
126
|
+
if (pendingFlushTimers.has(sessionId))
|
|
127
|
+
return;
|
|
128
|
+
const timer = setTimeout(() => {
|
|
129
|
+
pendingFlushTimers.delete(sessionId);
|
|
130
|
+
void runFlushWithLock(ctx, sessionId);
|
|
131
|
+
}, FLUSH_DEBOUNCE_MS);
|
|
132
|
+
pendingFlushTimers.set(sessionId, timer);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Wrap `flushSessionInbox` with the per-session lock. If a flush
|
|
136
|
+
* is already running, just re-arm the timer so the next slot
|
|
137
|
+
* picks up whatever is still pending.
|
|
138
|
+
*/
|
|
139
|
+
async function runFlushWithLock(ctx, sessionId) {
|
|
140
|
+
if (flushInFlight.has(sessionId)) {
|
|
141
|
+
scheduleFlush(ctx, sessionId);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
flushInFlight.add(sessionId);
|
|
145
|
+
try {
|
|
146
|
+
await flushSessionInbox(ctx, sessionId, ownerUserId(ctx, sessionId));
|
|
147
|
+
}
|
|
148
|
+
finally {
|
|
149
|
+
flushInFlight.delete(sessionId);
|
|
150
|
+
// Pending arrivals during the flush — schedule another pass.
|
|
151
|
+
if (countPending(ctx, sessionId) > 0) {
|
|
152
|
+
scheduleFlush(ctx, sessionId);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Look up the owner of a session. Used by the idle path to
|
|
157
|
+
* attribute the background turn to the right user. */
|
|
158
|
+
function ownerUserId(ctx, sessionId) {
|
|
159
|
+
const row = ctx.db
|
|
160
|
+
.prepare(`SELECT user_id FROM sessions WHERE id = ?`)
|
|
161
|
+
.get(sessionId);
|
|
162
|
+
return row?.user_id ?? null;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Drain pending inbox rows for `sessionId` and forward them as a
|
|
166
|
+
* single batched `harness.followUp(...)` call.
|
|
167
|
+
*
|
|
168
|
+
* Race notes:
|
|
169
|
+
* - drainPending is its own SQLite transaction (select +
|
|
170
|
+
* update-to-delivered) so two concurrent flushes can't both
|
|
171
|
+
* claim the same row.
|
|
172
|
+
* - If the harness vanished between schedule and fire, we abort
|
|
173
|
+
* before draining — the rows stay pending and the next user
|
|
174
|
+
* prompt picks them up.
|
|
175
|
+
* - If `followUp` throws after we already marked rows
|
|
176
|
+
* delivered (in-band shutdown race), the rows are lost from
|
|
177
|
+
* the inbox surface. The user still sees the task statuses
|
|
178
|
+
* in the kanban, so this is a soft failure.
|
|
179
|
+
*/
|
|
180
|
+
async function flushSessionInbox(ctx, sessionId, userId) {
|
|
181
|
+
// Active harness: try the cheap path — push the rendered batch
|
|
182
|
+
// through `harness.followUp` so pi consumes it on the next
|
|
183
|
+
// provider-turn boundary.
|
|
184
|
+
//
|
|
185
|
+
// CRITICAL: rows stay `pending` here. `harness.followUp(...)`
|
|
186
|
+
// only enqueues the text; pi consumes it at the next turn
|
|
187
|
+
// boundary. If the active turn errors out before that
|
|
188
|
+
// (provider terminated, abort, network blip), the queued text
|
|
189
|
+
// is silently dropped. Marking rows delivered prematurely
|
|
190
|
+
// would lose them forever.
|
|
191
|
+
//
|
|
192
|
+
// The actual marker writeback happens in handler.ts's
|
|
193
|
+
// bridgeHarnessEventToWs when a `user` message_end fires whose
|
|
194
|
+
// content matches an inbox id — that's the only point at which
|
|
195
|
+
// we know pi truly persisted the followUp into the session
|
|
196
|
+
// transcript. See `markDeliveredFromMessage` below.
|
|
197
|
+
//
|
|
198
|
+
// If `followUp` itself throws (harness phase=idle, between
|
|
199
|
+
// turns), we fall through to the idle-runner path so the rows
|
|
200
|
+
// get processed by a fresh background turn.
|
|
201
|
+
const harness = getActiveHarness(sessionId);
|
|
202
|
+
if (harness) {
|
|
203
|
+
const drained = drainPendingTentative(ctx, sessionId);
|
|
204
|
+
if (drained.length === 0)
|
|
205
|
+
return;
|
|
206
|
+
try {
|
|
207
|
+
await harness.followUp(renderForPrompt(drained));
|
|
208
|
+
// No markDelivered here; see comment above.
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
// eslint-disable-next-line no-console
|
|
213
|
+
console.warn(`[session-inbox] live followUp rejected for ${sessionId}, falling back to idle runner:`, err instanceof Error ? err.message : err);
|
|
214
|
+
// Fall through to the idle-runner path. Rows are still
|
|
215
|
+
// pending (we never called markDelivered).
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Idle session: kick a background turn so the agent reacts
|
|
219
|
+
// without waiting for the user to type. Guards:
|
|
220
|
+
// - Need an idle runner (host wires it; tests can leave it
|
|
221
|
+
// null and the rows stay pending).
|
|
222
|
+
// - Need a userId (orphan session w/o user_id row → give up;
|
|
223
|
+
// pending rows will get flushed on next user prompt if
|
|
224
|
+
// anyone ever reconnects).
|
|
225
|
+
// - Need re-entrancy guard so a second enqueue mid-turn
|
|
226
|
+
// doesn't kick a second turn; the running turn sees its
|
|
227
|
+
// own new rows on the next drainPending.
|
|
228
|
+
if (!boundIdleRunner)
|
|
229
|
+
return;
|
|
230
|
+
if (!userId)
|
|
231
|
+
return;
|
|
232
|
+
if (idleTurnsInFlight.has(sessionId))
|
|
233
|
+
return;
|
|
234
|
+
const drained = drainPending(ctx, sessionId);
|
|
235
|
+
if (drained.length === 0)
|
|
236
|
+
return;
|
|
237
|
+
const promptText = renderForPrompt(drained);
|
|
238
|
+
idleTurnsInFlight.add(sessionId);
|
|
239
|
+
try {
|
|
240
|
+
await boundIdleRunner({ sessionId, userId, promptText });
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
// eslint-disable-next-line no-console
|
|
244
|
+
console.warn(`[session-inbox] idle background turn failed for ${sessionId}:`, err instanceof Error ? err.message : err);
|
|
245
|
+
}
|
|
246
|
+
finally {
|
|
247
|
+
idleTurnsInFlight.delete(sessionId);
|
|
248
|
+
}
|
|
249
|
+
// The runFlushWithLock wrapper checks for newly-pending rows
|
|
250
|
+
// after we return and schedules another pass; nothing to do
|
|
251
|
+
// here.
|
|
252
|
+
}
|
|
253
|
+
function countPending(ctx, sessionId) {
|
|
254
|
+
const row = ctx.db
|
|
255
|
+
.prepare(`SELECT count(*) AS n FROM session_inbox
|
|
256
|
+
WHERE target_session_id = ? AND status = 'pending'`)
|
|
257
|
+
.get(sessionId);
|
|
258
|
+
return row?.n ?? 0;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Atomically pop all pending messages for a session, oldest
|
|
262
|
+
* first, marking them as delivered.
|
|
263
|
+
*
|
|
264
|
+
* Used by the prompt path (handler.ts) where the rendered text
|
|
265
|
+
* is appended verbatim to the user's message and the agent sees
|
|
266
|
+
* it for sure. The active-harness flush path uses
|
|
267
|
+
* `drainPendingTentative` + `markDelivered` instead so a failed
|
|
268
|
+
* `harness.followUp` doesn't lose the rows.
|
|
269
|
+
*/
|
|
270
|
+
export function drainPending(ctx, sessionId) {
|
|
271
|
+
const txn = ctx.db.transaction(() => {
|
|
272
|
+
const rows = ctx.db
|
|
273
|
+
.prepare(`SELECT * FROM session_inbox
|
|
274
|
+
WHERE target_session_id = ? AND status = 'pending'
|
|
275
|
+
ORDER BY created_at ASC, rowid ASC`)
|
|
276
|
+
.all(sessionId);
|
|
277
|
+
if (rows.length === 0)
|
|
278
|
+
return [];
|
|
279
|
+
const now = Date.now();
|
|
280
|
+
const update = ctx.db.prepare(`UPDATE session_inbox SET status = 'delivered', delivered_at = ? WHERE id = ?`);
|
|
281
|
+
for (const r of rows)
|
|
282
|
+
update.run(now, r.id);
|
|
283
|
+
return rows;
|
|
284
|
+
});
|
|
285
|
+
const rows = txn();
|
|
286
|
+
return rows.map(rowToDelivered);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Read pending rows WITHOUT marking them delivered. Caller is
|
|
290
|
+
* responsible for `markDelivered(ids)` after the side-effect
|
|
291
|
+
* (e.g. `harness.followUp`) is confirmed to have succeeded.
|
|
292
|
+
*
|
|
293
|
+
* If the side-effect throws and we never call markDelivered, the
|
|
294
|
+
* next flush picks the rows up again — nothing is lost.
|
|
295
|
+
*
|
|
296
|
+
* The previous implementation drained-and-marked atomically,
|
|
297
|
+
* which lost rows when followUp succeeded but the surrounding
|
|
298
|
+
* turn never actually emitted the user message (T4 reproducer
|
|
299
|
+
* 2026-06-12: row marked delivered, content never reached the
|
|
300
|
+
* agent). With tentative + confirm, the worst case is a row
|
|
301
|
+
* delivered twice; that's vastly preferable to silent loss.
|
|
302
|
+
*/
|
|
303
|
+
export function drainPendingTentative(ctx, sessionId) {
|
|
304
|
+
const rows = ctx.db
|
|
305
|
+
.prepare(`SELECT * FROM session_inbox
|
|
306
|
+
WHERE target_session_id = ? AND status = 'pending'
|
|
307
|
+
ORDER BY created_at ASC, rowid ASC`)
|
|
308
|
+
.all(sessionId);
|
|
309
|
+
return rows.map(rowToDelivered);
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Scan a freshly-persisted user message text for inbox markers
|
|
313
|
+
* and mark each matched row delivered. Called by the handler
|
|
314
|
+
* when pi emits message_end for a `user` role row — that's the
|
|
315
|
+
* one event that proves pi has actually consumed a followUp.
|
|
316
|
+
*
|
|
317
|
+
* Markers are emitted by `renderForPrompt` as
|
|
318
|
+
* <inbox kind="..." id="inbox_...">
|
|
319
|
+
*/
|
|
320
|
+
export function markDeliveredFromMessage(ctx, text) {
|
|
321
|
+
if (!text.includes("<inbox kind="))
|
|
322
|
+
return;
|
|
323
|
+
const ids = [];
|
|
324
|
+
const re = /<inbox\s+kind="[^"]*"\s+id="(inbox_[^"]+)"/g;
|
|
325
|
+
let m;
|
|
326
|
+
while ((m = re.exec(text)) !== null) {
|
|
327
|
+
ids.push(m[1]);
|
|
328
|
+
}
|
|
329
|
+
if (ids.length > 0)
|
|
330
|
+
markDelivered(ctx, ids);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Mark the given rows delivered. Idempotent: re-marking a row
|
|
334
|
+
* already delivered is a no-op (the WHERE clause filters by
|
|
335
|
+
* status='pending').
|
|
336
|
+
*/
|
|
337
|
+
export function markDelivered(ctx, ids) {
|
|
338
|
+
if (ids.length === 0)
|
|
339
|
+
return;
|
|
340
|
+
const now = Date.now();
|
|
341
|
+
const update = ctx.db.prepare(`UPDATE session_inbox
|
|
342
|
+
SET status = 'delivered', delivered_at = ?
|
|
343
|
+
WHERE id = ? AND status = 'pending'`);
|
|
344
|
+
const txn = ctx.db.transaction(() => {
|
|
345
|
+
for (const id of ids)
|
|
346
|
+
update.run(now, id);
|
|
347
|
+
});
|
|
348
|
+
txn();
|
|
349
|
+
}
|
|
350
|
+
function rowToDelivered(row) {
|
|
351
|
+
let parsed;
|
|
352
|
+
try {
|
|
353
|
+
parsed = JSON.parse(row.payload);
|
|
354
|
+
}
|
|
355
|
+
catch {
|
|
356
|
+
parsed = { kind: "system_note", text: row.payload };
|
|
357
|
+
}
|
|
358
|
+
return { id: row.id, createdAt: row.created_at, message: parsed };
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Render a list of drained messages into a single text block
|
|
362
|
+
* suitable for prepending to the user's next prompt.
|
|
363
|
+
*
|
|
364
|
+
* Empty input ⇒ empty string (callers can `${rendered}${userText}`
|
|
365
|
+
* unconditionally).
|
|
366
|
+
*
|
|
367
|
+
* Format intentionally uses XML-ish tags so the LLM can tell
|
|
368
|
+
* "messages addressed to me while I was idle" apart from the
|
|
369
|
+
* user's own input. The tags carry the kind so the agent has a
|
|
370
|
+
* hint about what to do:
|
|
371
|
+
* - `task_done` is informational; brief acknowledge.
|
|
372
|
+
* - `task_intervention_required` (post-008) means a worker
|
|
373
|
+
* hit a failure / timeout and the orchestrator NEEDS the
|
|
374
|
+
* main agent to pick: task_continue, task_retry_fresh,
|
|
375
|
+
* task_extend_timeout, or task_abort. Don't just
|
|
376
|
+
* acknowledge — act.
|
|
377
|
+
* - `task_stalled` is the legacy spelling of the above.
|
|
378
|
+
*/
|
|
379
|
+
export function renderForPrompt(messages) {
|
|
380
|
+
if (messages.length === 0)
|
|
381
|
+
return "";
|
|
382
|
+
const blocks = messages.map((m) => {
|
|
383
|
+
return `<inbox kind="${m.message.kind}" id="${m.id}">\n${m.message.text}\n</inbox>`;
|
|
384
|
+
});
|
|
385
|
+
// Framing: tell the agent these are notifications, not user
|
|
386
|
+
// requests. The earlier wording ("Acknowledge them as
|
|
387
|
+
// appropriate") had the agent diving into per-task analysis
|
|
388
|
+
// — reading the result file, evaluating quality — which is
|
|
389
|
+
// useful when the user asks for it but very noisy when 4
|
|
390
|
+
// parallel tasks finish in a row.
|
|
391
|
+
//
|
|
392
|
+
// The new wording: brief acknowledge, then yield. The agent
|
|
393
|
+
// still has the kanban + task_get_history if it wants to dig.
|
|
394
|
+
// Note for the LLM: split guidance by kind so an
|
|
395
|
+
// intervention_required block prompts a decision while a
|
|
396
|
+
// task_done block stays informational.
|
|
397
|
+
const hasIntervention = messages.some((m) => m.message.kind === "task_intervention_required" ||
|
|
398
|
+
m.message.kind === "task_stalled");
|
|
399
|
+
const guidance = hasIntervention
|
|
400
|
+
? `${messages.length} background notification${messages.length === 1 ? "" : "s"} arrived. At least one is a task_intervention_required: read its meta + the task's history if useful, then call ONE of task_continue / task_retry_fresh / task_extend_timeout / task_abort to keep the work moving. For task_done blocks, brief acknowledge is enough.`
|
|
401
|
+
: `${messages.length} background notification${messages.length === 1 ? "" : "s"} arrived while you were idle. Briefly acknowledge them in one short message (one line per notification is enough) and stop \u2014 do NOT investigate, evaluate, or take new action unless the user explicitly asks.`;
|
|
402
|
+
return [
|
|
403
|
+
"<system-note>",
|
|
404
|
+
guidance,
|
|
405
|
+
"",
|
|
406
|
+
...blocks,
|
|
407
|
+
"</system-note>",
|
|
408
|
+
"",
|
|
409
|
+
].join("\n");
|
|
410
|
+
}
|
|
411
|
+
/** Test-only convenience: surface kinds for assertions. */
|
|
412
|
+
export const KNOWN_KINDS = [
|
|
413
|
+
"task_done",
|
|
414
|
+
"task_intervention_required",
|
|
415
|
+
"task_stalled",
|
|
416
|
+
"system_note",
|
|
417
|
+
];
|
|
418
|
+
//# sourceMappingURL=session-inbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-inbox.js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AAC,CAAC,EAAE,EAAE;QAChC,OAAO,gBAAgB,CAAC,CAAC,OAAO,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC;IACtF,CAAC,CAAC,CAAC;IACH,4DAA4D;IAC5D,sDAAsD;IACtD,4DAA4D;IAC5D,2DAA2D;IAC3D,yDAAyD;IACzD,kCAAkC;IAClC,EAAE;IACF,4DAA4D;IAC5D,8DAA8D;IAC9D,iDAAiD;IACjD,yDAAyD;IACzD,uCAAuC;IACvC,MAAM,eAAe,GAAG,QAAQ,CAAC,IAAI,CACnC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,4BAA4B;QAC/C,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,cAAc,CACpC,CAAC;IACF,MAAM,QAAQ,GAAG,eAAe;QAC9B,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,2BAA2B,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,wQAAwQ;QACvV,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,2BAA2B,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,qNAAqN,CAAC;IACvS,OAAO;QACL,eAAe;QACf,QAAQ;QACR,EAAE;QACF,GAAG,MAAM;QACT,gBAAgB;QAChB,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAID,2DAA2D;AAC3D,MAAM,CAAC,MAAM,WAAW,GAAgC;IACtD,WAAW;IACX,4BAA4B;IAC5B,cAAc;IACd,aAAa;CACd,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Session, SessionForkOptions, SessionRepo } from "@earendil-works/pi-agent-core";
|
|
2
|
+
import type { TenantContext } from "../core/index.js";
|
|
3
|
+
import { type SqliteSessionMetadata } from "./sqlite-session-storage.js";
|
|
4
|
+
export interface SqliteSessionCreateOptions {
|
|
5
|
+
/** Optional pre-allocated id; otherwise generated. */
|
|
6
|
+
id?: string;
|
|
7
|
+
userId: string;
|
|
8
|
+
kind?: "user" | "worker" | "system";
|
|
9
|
+
workerRole?: string | null;
|
|
10
|
+
parentSessionId?: string | null;
|
|
11
|
+
title?: string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface SqliteSessionListOptions {
|
|
14
|
+
userId?: string;
|
|
15
|
+
kind?: "user" | "worker" | "system";
|
|
16
|
+
}
|
|
17
|
+
export declare class SqliteSessionRepo implements SessionRepo<SqliteSessionMetadata, SqliteSessionCreateOptions, SqliteSessionListOptions> {
|
|
18
|
+
private readonly ctx;
|
|
19
|
+
constructor(ctx: TenantContext);
|
|
20
|
+
create(options: SqliteSessionCreateOptions): Promise<Session<SqliteSessionMetadata>>;
|
|
21
|
+
open(metadata: SqliteSessionMetadata): Promise<Session<SqliteSessionMetadata>>;
|
|
22
|
+
list(options?: SqliteSessionListOptions): Promise<SqliteSessionMetadata[]>;
|
|
23
|
+
delete(metadata: SqliteSessionMetadata): Promise<void>;
|
|
24
|
+
fork(source: SqliteSessionMetadata, options: SessionForkOptions & SqliteSessionCreateOptions): Promise<Session<SqliteSessionMetadata>>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=sqlite-session-repo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-session-repo.d.ts","sourceRoot":"","sources":["../../src/chat/sqlite-session-repo.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,OAAO,EACP,kBAAkB,EAClB,WAAW,EAEZ,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAEL,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,CAAC;AAErC,MAAM,WAAW,0BAA0B;IACzC,sDAAsD;IACtD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACrC;AAED,qBAAa,iBACX,YACE,WAAW,CACT,qBAAqB,EACrB,0BAA0B,EAC1B,wBAAwB,CACzB;IAES,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,aAAa;IAEzC,MAAM,CACV,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAkCpC,IAAI,CACR,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;IAcpC,IAAI,CACR,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,qBAAqB,EAAE,CAAC;IA2C7B,MAAM,CAAC,QAAQ,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAatD,IAAI,CACR,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,kBAAkB,GAAG,0BAA0B,GACvD,OAAO,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAiC3C"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// SQLite-backed implementation of pi-agent-core's `SessionRepo`.
|
|
2
|
+
//
|
|
3
|
+
// Thin layer on top of `SqliteSessionStorage`: pi's harness only
|
|
4
|
+
// needs `create / open / list / delete / fork`, all of which map
|
|
5
|
+
// cleanly to operations on the existing `sessions` table.
|
|
6
|
+
//
|
|
7
|
+
// Design notes:
|
|
8
|
+
// * `create` and `open` both return a `Session<TMetadata>` whose
|
|
9
|
+
// storage points at the same SQLite db handle in `ctx`.
|
|
10
|
+
// * `fork` is the only one with non-trivial semantics: pi can
|
|
11
|
+
// fork from any entry id (entryId + position="before"|"at").
|
|
12
|
+
// We map this to a new `sessions` row whose `parent_id` points
|
|
13
|
+
// at the source session, then replay the parent's path-to-root
|
|
14
|
+
// up to (or excluding) the chosen entry into the child via
|
|
15
|
+
// fresh appendEntry calls. That keeps fork semantics under our
|
|
16
|
+
// control without `messages` rows being shared across sessions.
|
|
17
|
+
// * `list` is bounded to the calling tenant + an optional kind
|
|
18
|
+
// filter. The harness only calls it from harness-level admin
|
|
19
|
+
// UI, none of which we ship today, but supporting it keeps
|
|
20
|
+
// the interface honest.
|
|
21
|
+
// * `delete` is hard-delete: removes the sessions row + its
|
|
22
|
+
// messages. There's no soft-delete; if a future audit log
|
|
23
|
+
// wants to retain compacted bodies it should hold a separate
|
|
24
|
+
// reference.
|
|
25
|
+
import { randomUUID } from "node:crypto";
|
|
26
|
+
import { Session as PiSession } from "@earendil-works/pi-agent-core";
|
|
27
|
+
import { SqliteSessionStorage, } from "./sqlite-session-storage.js";
|
|
28
|
+
export class SqliteSessionRepo {
|
|
29
|
+
ctx;
|
|
30
|
+
constructor(ctx) {
|
|
31
|
+
this.ctx = ctx;
|
|
32
|
+
}
|
|
33
|
+
async create(options) {
|
|
34
|
+
const id = options.id ?? `session_${randomUUID()}`;
|
|
35
|
+
const now = Date.now();
|
|
36
|
+
this.ctx.db
|
|
37
|
+
.prepare(`INSERT INTO sessions
|
|
38
|
+
(id, user_id, parent_id, status, kind, worker_role, title, created_at)
|
|
39
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`)
|
|
40
|
+
.run(id, options.userId, options.parentSessionId ?? null, "active", options.kind ?? "user", options.workerRole ?? null, options.title ?? null, now);
|
|
41
|
+
return new PiSession(new SqliteSessionStorage(this.ctx, id));
|
|
42
|
+
}
|
|
43
|
+
async open(metadata) {
|
|
44
|
+
// Confirm the row still exists; the storage will throw on its
|
|
45
|
+
// first read otherwise, but a clearer error here helps debug.
|
|
46
|
+
const row = this.ctx.db
|
|
47
|
+
.prepare(`SELECT id FROM sessions WHERE id = ?`)
|
|
48
|
+
.get(metadata.id);
|
|
49
|
+
if (!row) {
|
|
50
|
+
throw new Error(`session not found: ${metadata.id}`);
|
|
51
|
+
}
|
|
52
|
+
return new PiSession(new SqliteSessionStorage(this.ctx, metadata.id));
|
|
53
|
+
}
|
|
54
|
+
async list(options) {
|
|
55
|
+
const filters = [];
|
|
56
|
+
const params = [];
|
|
57
|
+
if (options?.userId) {
|
|
58
|
+
filters.push("user_id = ?");
|
|
59
|
+
params.push(options.userId);
|
|
60
|
+
}
|
|
61
|
+
if (options?.kind) {
|
|
62
|
+
filters.push("kind = ?");
|
|
63
|
+
params.push(options.kind);
|
|
64
|
+
}
|
|
65
|
+
const where = filters.length > 0 ? ` WHERE ${filters.join(" AND ")}` : "";
|
|
66
|
+
const rows = this.ctx.db
|
|
67
|
+
.prepare(`SELECT id, user_id, parent_id, status, kind, worker_role, title, created_at
|
|
68
|
+
FROM sessions${where}
|
|
69
|
+
ORDER BY created_at DESC`)
|
|
70
|
+
.all(...params);
|
|
71
|
+
return rows.map((r) => ({
|
|
72
|
+
id: r.id,
|
|
73
|
+
createdAt: new Date(r.created_at).toISOString(),
|
|
74
|
+
tenantId: this.ctx.tenantId,
|
|
75
|
+
userId: r.user_id,
|
|
76
|
+
kind: r.kind,
|
|
77
|
+
workerRole: r.worker_role,
|
|
78
|
+
parentSessionId: r.parent_id,
|
|
79
|
+
title: r.title,
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
async delete(metadata) {
|
|
83
|
+
// Hard delete. messages have no FK cascade in 001-initial, so
|
|
84
|
+
// we delete them explicitly first.
|
|
85
|
+
this.ctx.db
|
|
86
|
+
.prepare(`DELETE FROM messages WHERE session_id = ?`)
|
|
87
|
+
.run(metadata.id);
|
|
88
|
+
this.ctx.db
|
|
89
|
+
.prepare(`DELETE FROM sessions WHERE id = ?`)
|
|
90
|
+
.run(metadata.id);
|
|
91
|
+
}
|
|
92
|
+
async fork(source, options) {
|
|
93
|
+
// Build the entry-id chain to copy: walk parent's path-to-root,
|
|
94
|
+
// truncate at options.entryId per options.position.
|
|
95
|
+
const sourceStorage = new SqliteSessionStorage(this.ctx, source.id);
|
|
96
|
+
const parentLeaf = await sourceStorage.getLeafId();
|
|
97
|
+
const path = await sourceStorage.getPathToRoot(parentLeaf);
|
|
98
|
+
const cutEntries = sliceForFork(path, options);
|
|
99
|
+
const child = await this.create({
|
|
100
|
+
...options,
|
|
101
|
+
userId: options.userId ?? source.userId,
|
|
102
|
+
kind: options.kind ?? source.kind,
|
|
103
|
+
workerRole: options.workerRole === undefined ? source.workerRole : options.workerRole,
|
|
104
|
+
parentSessionId: source.id,
|
|
105
|
+
title: options.title ?? source.title ?? null,
|
|
106
|
+
});
|
|
107
|
+
const childMeta = await child.getMetadata();
|
|
108
|
+
const childStorage = new SqliteSessionStorage(this.ctx, childMeta.id);
|
|
109
|
+
// Re-append entries with fresh ids; preserve order so parentId
|
|
110
|
+
// chains stay coherent.
|
|
111
|
+
let prev = null;
|
|
112
|
+
for (const entry of cutEntries) {
|
|
113
|
+
const id = await childStorage.createEntryId();
|
|
114
|
+
const cloned = { ...entry, id, parentId: prev };
|
|
115
|
+
await childStorage.appendEntry(cloned);
|
|
116
|
+
prev = id;
|
|
117
|
+
}
|
|
118
|
+
if (prev)
|
|
119
|
+
await childStorage.setLeafId(prev);
|
|
120
|
+
return child;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function sliceForFork(path, options) {
|
|
124
|
+
if (!options.entryId)
|
|
125
|
+
return path;
|
|
126
|
+
const idx = path.findIndex((e) => e.id === options.entryId);
|
|
127
|
+
if (idx < 0)
|
|
128
|
+
return path;
|
|
129
|
+
const position = options.position ?? "at";
|
|
130
|
+
return position === "before" ? path.slice(0, idx) : path.slice(0, idx + 1);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=sqlite-session-repo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite-session-repo.js","sourceRoot":"","sources":["../../src/chat/sqlite-session-repo.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,EAAE;AACF,iEAAiE;AACjE,iEAAiE;AACjE,0DAA0D;AAC1D,EAAE;AACF,gBAAgB;AAChB,mEAAmE;AACnE,4DAA4D;AAC5D,gEAAgE;AAChE,iEAAiE;AACjE,mEAAmE;AACnE,mEAAmE;AACnE,+DAA+D;AAC/D,mEAAmE;AACnE,oEAAoE;AACpE,iEAAiE;AACjE,iEAAiE;AACjE,+DAA+D;AAC/D,4BAA4B;AAC5B,8DAA8D;AAC9D,8DAA8D;AAC9D,iEAAiE;AACjE,iBAAiB;AAEjB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EACL,oBAAoB,GAErB,MAAM,6BAA6B,CAAC;AAiBrC,MAAM,OAAO,iBAAiB;IAQC;IAA7B,YAA6B,GAAkB;QAAlB,QAAG,GAAH,GAAG,CAAe;IAAG,CAAC;IAEnD,KAAK,CAAC,MAAM,CACV,OAAmC;QAEnC,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,WAAW,UAAU,EAAE,EAAE,CAAC;QACnD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,GAAG,CAAC,EAAE;aACR,OAAO,CAaN;;yCAEiC,CAClC;aACA,GAAG,CACF,EAAE,EACF,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,eAAe,IAAI,IAAI,EAC/B,QAAQ,EACR,OAAO,CAAC,IAAI,IAAI,MAAM,EACtB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