@xyit/wellspring 0.0.0-stage → 1.1.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 +21 -0
- package/README.md +853 -2
- package/dist/agent/pending-asks.d.ts +20 -0
- package/dist/agent/pending-asks.js +70 -0
- package/dist/agent/pending-asks.js.map +1 -0
- package/dist/agent/task-registry.d.ts +14 -0
- package/dist/agent/task-registry.js +80 -0
- package/dist/agent/task-registry.js.map +1 -0
- package/dist/agent/tool-context.d.ts +30 -0
- package/dist/agent/tool-context.js +10 -0
- package/dist/agent/tool-context.js.map +1 -0
- package/dist/agent/usage.d.ts +40 -0
- package/dist/agent/usage.js +122 -0
- package/dist/agent/usage.js.map +1 -0
- package/dist/api/host/agent.d.ts +165 -0
- package/dist/api/host/agent.js +5 -0
- package/dist/api/host/agent.js.map +1 -0
- package/dist/api/host/events.d.ts +2 -0
- package/dist/api/host/events.js +6 -0
- package/dist/api/host/events.js.map +1 -0
- package/dist/api/host/exec.d.ts +36 -0
- package/dist/api/host/exec.js +10 -0
- package/dist/api/host/exec.js.map +1 -0
- package/dist/api/host/fs.d.ts +24 -0
- package/dist/api/host/fs.js +7 -0
- package/dist/api/host/fs.js.map +1 -0
- package/dist/api/host/hooks.d.ts +210 -0
- package/dist/api/host/hooks.js +401 -0
- package/dist/api/host/hooks.js.map +1 -0
- package/dist/api/host/host.d.ts +36 -0
- package/dist/api/host/host.js +53 -0
- package/dist/api/host/host.js.map +1 -0
- package/dist/api/host/http.d.ts +58 -0
- package/dist/api/host/http.js +6 -0
- package/dist/api/host/http.js.map +1 -0
- package/dist/api/host/index.d.ts +15 -0
- package/dist/api/host/index.js +20 -0
- package/dist/api/host/index.js.map +1 -0
- package/dist/api/host/models.d.ts +65 -0
- package/dist/api/host/models.js +8 -0
- package/dist/api/host/models.js.map +1 -0
- package/dist/api/host/network.d.ts +22 -0
- package/dist/api/host/network.js +7 -0
- package/dist/api/host/network.js.map +1 -0
- package/dist/api/host/plugin.d.ts +138 -0
- package/dist/api/host/plugin.js +6 -0
- package/dist/api/host/plugin.js.map +1 -0
- package/dist/api/host/plugins.d.ts +49 -0
- package/dist/api/host/plugins.js +6 -0
- package/dist/api/host/plugins.js.map +1 -0
- package/dist/api/host/pty.d.ts +55 -0
- package/dist/api/host/pty.js +21 -0
- package/dist/api/host/pty.js.map +1 -0
- package/dist/api/host/session.d.ts +5 -0
- package/dist/api/host/session.js +52 -0
- package/dist/api/host/session.js.map +1 -0
- package/dist/api/host/version.d.ts +2 -0
- package/dist/api/host/version.js +3 -0
- package/dist/api/host/version.js.map +1 -0
- package/dist/api/host/workspace.d.ts +38 -0
- package/dist/api/host/workspace.js +9 -0
- package/dist/api/host/workspace.js.map +1 -0
- package/dist/api/plugin/http-client.d.ts +42 -0
- package/dist/api/plugin/http-client.js +364 -0
- package/dist/api/plugin/http-client.js.map +1 -0
- package/dist/api/plugin/http-protocol.d.ts +152 -0
- package/dist/api/plugin/http-protocol.js +49 -0
- package/dist/api/plugin/http-protocol.js.map +1 -0
- package/dist/api/result/result.d.ts +16 -0
- package/dist/api/result/result.js +43 -0
- package/dist/api/result/result.js.map +1 -0
- package/dist/commands/agent-turn.d.ts +63 -0
- package/dist/commands/agent-turn.js +687 -0
- package/dist/commands/agent-turn.js.map +1 -0
- package/dist/commands/ask-prompt.d.ts +6 -0
- package/dist/commands/ask-prompt.js +49 -0
- package/dist/commands/ask-prompt.js.map +1 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.js +283 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/conversation.d.ts +51 -0
- package/dist/commands/conversation.js +630 -0
- package/dist/commands/conversation.js.map +1 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +77 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/exec-approval.d.ts +3 -0
- package/dist/commands/exec-approval.js +80 -0
- package/dist/commands/exec-approval.js.map +1 -0
- package/dist/commands/help.d.ts +2 -0
- package/dist/commands/help.js +35 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/key.d.ts +2 -0
- package/dist/commands/key.js +226 -0
- package/dist/commands/key.js.map +1 -0
- package/dist/commands/plugin.d.ts +2 -0
- package/dist/commands/plugin.js +190 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/session.d.ts +2 -0
- package/dist/commands/session.js +167 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/shared.d.ts +35 -0
- package/dist/commands/shared.js +66 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/start.d.ts +2 -0
- package/dist/commands/start.js +75 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/stop.d.ts +2 -0
- package/dist/commands/stop.js +24 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/version.d.ts +2 -0
- package/dist/commands/version.js +33 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/config/codes.d.ts +13 -0
- package/dist/config/codes.js +15 -0
- package/dist/config/codes.js.map +1 -0
- package/dist/config/credentials.d.ts +67 -0
- package/dist/config/credentials.js +214 -0
- package/dist/config/credentials.js.map +1 -0
- package/dist/config/defaults.d.ts +5 -0
- package/dist/config/defaults.js +31 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.js +10 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/loader.d.ts +10 -0
- package/dist/config/loader.js +68 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/providers.d.ts +30 -0
- package/dist/config/providers.js +97 -0
- package/dist/config/providers.js.map +1 -0
- package/dist/config/types.d.ts +75 -0
- package/dist/config/types.js +4 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/validate.d.ts +4 -0
- package/dist/config/validate.js +391 -0
- package/dist/config/validate.js.map +1 -0
- package/dist/display/markdown.d.ts +7 -0
- package/dist/display/markdown.js +116 -0
- package/dist/display/markdown.js.map +1 -0
- package/dist/display/tool-label.d.ts +6 -0
- package/dist/display/tool-label.js +81 -0
- package/dist/display/tool-label.js.map +1 -0
- package/dist/event/event.d.ts +27 -0
- package/dist/event/event.js +152 -0
- package/dist/event/event.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +308 -0
- package/dist/index.js.map +1 -0
- package/dist/input/codes.d.ts +15 -0
- package/dist/input/codes.js +20 -0
- package/dist/input/codes.js.map +1 -0
- package/dist/input/commands.d.ts +10 -0
- package/dist/input/commands.js +65 -0
- package/dist/input/commands.js.map +1 -0
- package/dist/input/help.d.ts +8 -0
- package/dist/input/help.js +51 -0
- package/dist/input/help.js.map +1 -0
- package/dist/input/index.d.ts +6 -0
- package/dist/input/index.js +10 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/parse-options.d.ts +11 -0
- package/dist/input/parse-options.js +51 -0
- package/dist/input/parse-options.js.map +1 -0
- package/dist/input/parse.d.ts +3 -0
- package/dist/input/parse.js +119 -0
- package/dist/input/parse.js.map +1 -0
- package/dist/input/types.d.ts +17 -0
- package/dist/input/types.js +2 -0
- package/dist/input/types.js.map +1 -0
- package/dist/logger/elog4js.d.ts +65 -0
- package/dist/logger/elog4js.js +305 -0
- package/dist/logger/elog4js.js.map +1 -0
- package/dist/logger/logger.d.ts +37 -0
- package/dist/logger/logger.js +196 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.js +6 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/openai.d.ts +117 -0
- package/dist/network/openai.js +443 -0
- package/dist/network/openai.js.map +1 -0
- package/dist/network/proxy.d.ts +9 -0
- package/dist/network/proxy.js +72 -0
- package/dist/network/proxy.js.map +1 -0
- package/dist/network/web.d.ts +34 -0
- package/dist/network/web.js +152 -0
- package/dist/network/web.js.map +1 -0
- package/dist/platform/clipboard.d.ts +15 -0
- package/dist/platform/clipboard.js +82 -0
- package/dist/platform/clipboard.js.map +1 -0
- package/dist/platform/exec.d.ts +28 -0
- package/dist/platform/exec.js +95 -0
- package/dist/platform/exec.js.map +1 -0
- package/dist/platform/file.d.ts +38 -0
- package/dist/platform/file.js +197 -0
- package/dist/platform/file.js.map +1 -0
- package/dist/platform/index.d.ts +7 -0
- package/dist/platform/index.js +12 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/notification.d.ts +14 -0
- package/dist/platform/notification.js +82 -0
- package/dist/platform/notification.js.map +1 -0
- package/dist/platform/open-external.d.ts +10 -0
- package/dist/platform/open-external.js +105 -0
- package/dist/platform/open-external.js.map +1 -0
- package/dist/platform/os.d.ts +20 -0
- package/dist/platform/os.js +86 -0
- package/dist/platform/os.js.map +1 -0
- package/dist/platform/path.d.ts +32 -0
- package/dist/platform/path.js +154 -0
- package/dist/platform/path.js.map +1 -0
- package/dist/plugin/access-guard.d.ts +1 -0
- package/dist/plugin/access-guard.js +40 -0
- package/dist/plugin/access-guard.js.map +1 -0
- package/dist/plugin/agent-service.d.ts +25 -0
- package/dist/plugin/agent-service.js +809 -0
- package/dist/plugin/agent-service.js.map +1 -0
- package/dist/plugin/agent-tools.d.ts +12 -0
- package/dist/plugin/agent-tools.js +31 -0
- package/dist/plugin/agent-tools.js.map +1 -0
- package/dist/plugin/capabilities.d.ts +26 -0
- package/dist/plugin/capabilities.js +192 -0
- package/dist/plugin/capabilities.js.map +1 -0
- package/dist/plugin/console-guard.d.ts +2 -0
- package/dist/plugin/console-guard.js +52 -0
- package/dist/plugin/console-guard.js.map +1 -0
- package/dist/plugin/data-access.d.ts +15 -0
- package/dist/plugin/data-access.js +57 -0
- package/dist/plugin/data-access.js.map +1 -0
- package/dist/plugin/fs.d.ts +3 -0
- package/dist/plugin/fs.js +93 -0
- package/dist/plugin/fs.js.map +1 -0
- package/dist/plugin/host-alias.d.ts +2 -0
- package/dist/plugin/host-alias.js +57 -0
- package/dist/plugin/host-alias.js.map +1 -0
- package/dist/plugin/index.d.ts +7 -0
- package/dist/plugin/index.js +11 -0
- package/dist/plugin/index.js.map +1 -0
- package/dist/plugin/install.d.ts +17 -0
- package/dist/plugin/install.js +163 -0
- package/dist/plugin/install.js.map +1 -0
- package/dist/plugin/loader.d.ts +45 -0
- package/dist/plugin/loader.js +739 -0
- package/dist/plugin/loader.js.map +1 -0
- package/dist/plugin/manage.d.ts +31 -0
- package/dist/plugin/manage.js +271 -0
- package/dist/plugin/manage.js.map +1 -0
- package/dist/plugin/models-service.d.ts +15 -0
- package/dist/plugin/models-service.js +317 -0
- package/dist/plugin/models-service.js.map +1 -0
- package/dist/plugin/network-service.d.ts +10 -0
- package/dist/plugin/network-service.js +87 -0
- package/dist/plugin/network-service.js.map +1 -0
- package/dist/plugin/package-manager.d.ts +46 -0
- package/dist/plugin/package-manager.js +148 -0
- package/dist/plugin/package-manager.js.map +1 -0
- package/dist/plugin/paths.d.ts +6 -0
- package/dist/plugin/paths.js +15 -0
- package/dist/plugin/paths.js.map +1 -0
- package/dist/plugin/registry.d.ts +17 -0
- package/dist/plugin/registry.js +82 -0
- package/dist/plugin/registry.js.map +1 -0
- package/dist/plugin/runtime.d.ts +9 -0
- package/dist/plugin/runtime.js +43 -0
- package/dist/plugin/runtime.js.map +1 -0
- package/dist/plugin/scaffold.d.ts +13 -0
- package/dist/plugin/scaffold.js +132 -0
- package/dist/plugin/scaffold.js.map +1 -0
- package/dist/plugin/state.d.ts +6 -0
- package/dist/plugin/state.js +38 -0
- package/dist/plugin/state.js.map +1 -0
- package/dist/plugin/zip.d.ts +7 -0
- package/dist/plugin/zip.js +138 -0
- package/dist/plugin/zip.js.map +1 -0
- package/dist/sandbox/audit.d.ts +12 -0
- package/dist/sandbox/audit.js +20 -0
- package/dist/sandbox/audit.js.map +1 -0
- package/dist/sandbox/backends/bwrap.d.ts +28 -0
- package/dist/sandbox/backends/bwrap.js +197 -0
- package/dist/sandbox/backends/bwrap.js.map +1 -0
- package/dist/sandbox/backends/direct.d.ts +7 -0
- package/dist/sandbox/backends/direct.js +32 -0
- package/dist/sandbox/backends/direct.js.map +1 -0
- package/dist/sandbox/bridge-state.d.ts +13 -0
- package/dist/sandbox/bridge-state.js +12 -0
- package/dist/sandbox/bridge-state.js.map +1 -0
- package/dist/sandbox/index.d.ts +5 -0
- package/dist/sandbox/index.js +6 -0
- package/dist/sandbox/index.js.map +1 -0
- package/dist/sandbox/manager.d.ts +8 -0
- package/dist/sandbox/manager.js +325 -0
- package/dist/sandbox/manager.js.map +1 -0
- package/dist/sandbox/memory-limit.d.ts +44 -0
- package/dist/sandbox/memory-limit.js +193 -0
- package/dist/sandbox/memory-limit.js.map +1 -0
- package/dist/sandbox/plugin-client.d.ts +80 -0
- package/dist/sandbox/plugin-client.js +1601 -0
- package/dist/sandbox/plugin-client.js.map +1 -0
- package/dist/sandbox/plugin-host.d.ts +1 -0
- package/dist/sandbox/plugin-host.js +1001 -0
- package/dist/sandbox/plugin-host.js.map +1 -0
- package/dist/sandbox/protocol.d.ts +43 -0
- package/dist/sandbox/protocol.js +96 -0
- package/dist/sandbox/protocol.js.map +1 -0
- package/dist/sandbox/rpc-timeouts.d.ts +28 -0
- package/dist/sandbox/rpc-timeouts.js +15 -0
- package/dist/sandbox/rpc-timeouts.js.map +1 -0
- package/dist/sandbox/supervisor.d.ts +31 -0
- package/dist/sandbox/supervisor.js +114 -0
- package/dist/sandbox/supervisor.js.map +1 -0
- package/dist/sandbox/types.d.ts +124 -0
- package/dist/sandbox/types.js +17 -0
- package/dist/sandbox/types.js.map +1 -0
- package/dist/service/control.d.ts +32 -0
- package/dist/service/control.js +117 -0
- package/dist/service/control.js.map +1 -0
- package/dist/session/compress.d.ts +3 -0
- package/dist/session/compress.js +42 -0
- package/dist/session/compress.js.map +1 -0
- package/dist/session/index.d.ts +4 -0
- package/dist/session/index.js +8 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/registry.d.ts +4 -0
- package/dist/session/registry.js +12 -0
- package/dist/session/registry.js.map +1 -0
- package/dist/session/replay.d.ts +10 -0
- package/dist/session/replay.js +109 -0
- package/dist/session/replay.js.map +1 -0
- package/dist/session/session.d.ts +40 -0
- package/dist/session/session.js +108 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/store.d.ts +58 -0
- package/dist/session/store.js +382 -0
- package/dist/session/store.js.map +1 -0
- package/dist/session/types.d.ts +56 -0
- package/dist/session/types.js +3 -0
- package/dist/session/types.js.map +1 -0
- package/dist/workspace/index.d.ts +7 -0
- package/dist/workspace/index.js +17 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/registry.d.ts +25 -0
- package/dist/workspace/registry.js +293 -0
- package/dist/workspace/registry.js.map +1 -0
- package/package.json +73 -5
- package/scripts/build-node-pty.mjs +55 -0
- package/scripts/rewrite-dts.mjs +36 -0
- package/scripts/run-tests.mjs +41 -0
- package/scripts/verify-sandbox.ts +98 -0
- package/src/agent/pending-asks.ts +88 -0
- package/src/agent/task-registry.ts +108 -0
- package/src/agent/tool-context.ts +47 -0
- package/src/agent/usage.ts +170 -0
- package/src/api/host/agent.ts +162 -0
- package/src/api/host/events.ts +7 -0
- package/src/api/host/exec.ts +47 -0
- package/src/api/host/fs.ts +33 -0
- package/src/api/host/hooks.ts +635 -0
- package/src/api/host/host.ts +99 -0
- package/src/api/host/http.ts +79 -0
- package/src/api/host/index.ts +20 -0
- package/src/api/host/models.ts +81 -0
- package/src/api/host/network.ts +32 -0
- package/src/api/host/plugin.ts +158 -0
- package/src/api/host/plugins.ts +59 -0
- package/src/api/host/pty.ts +73 -0
- package/src/api/host/session.ts +61 -0
- package/src/api/host/version.ts +2 -0
- package/src/api/host/workspace.ts +51 -0
- package/src/api/plugin/http-client.ts +492 -0
- package/src/api/plugin/http-protocol.ts +231 -0
- package/src/api/result/result.ts +52 -0
- package/src/commands/agent-turn.ts +817 -0
- package/src/commands/ask-prompt.ts +52 -0
- package/src/commands/config.ts +306 -0
- package/src/commands/conversation.ts +777 -0
- package/src/commands/doctor.ts +92 -0
- package/src/commands/exec-approval.ts +91 -0
- package/src/commands/help.ts +41 -0
- package/src/commands/key.ts +281 -0
- package/src/commands/plugin.ts +222 -0
- package/src/commands/session.ts +179 -0
- package/src/commands/shared.ts +103 -0
- package/src/commands/start.ts +88 -0
- package/src/commands/stop.ts +24 -0
- package/src/commands/version.ts +40 -0
- package/src/config/codes.ts +17 -0
- package/src/config/credentials.ts +302 -0
- package/src/config/defaults.ts +32 -0
- package/src/config/index.ts +10 -0
- package/src/config/loader.ts +80 -0
- package/src/config/providers.ts +133 -0
- package/src/config/types.ts +88 -0
- package/src/config/validate.ts +458 -0
- package/src/display/markdown.ts +137 -0
- package/src/display/tool-label.ts +87 -0
- package/src/event/event.ts +171 -0
- package/src/index.ts +344 -0
- package/src/input/codes.ts +21 -0
- package/src/input/commands.ts +76 -0
- package/src/input/help.ts +60 -0
- package/src/input/index.ts +10 -0
- package/src/input/parse-options.ts +66 -0
- package/src/input/parse.ts +138 -0
- package/src/input/types.ts +19 -0
- package/src/logger/elog4js.ts +366 -0
- package/src/logger/logger.ts +251 -0
- package/src/network/index.ts +6 -0
- package/src/network/openai.ts +571 -0
- package/src/network/proxy.ts +80 -0
- package/src/network/web.ts +206 -0
- package/src/platform/clipboard.ts +107 -0
- package/src/platform/exec.ts +128 -0
- package/src/platform/file.ts +235 -0
- package/src/platform/index.ts +12 -0
- package/src/platform/notification.ts +108 -0
- package/src/platform/open-external.ts +132 -0
- package/src/platform/os.ts +101 -0
- package/src/platform/path.ts +214 -0
- package/src/plugin/access-guard.ts +46 -0
- package/src/plugin/agent-service.ts +969 -0
- package/src/plugin/agent-tools.ts +43 -0
- package/src/plugin/capabilities.ts +240 -0
- package/src/plugin/console-guard.ts +66 -0
- package/src/plugin/data-access.ts +70 -0
- package/src/plugin/fs.ts +109 -0
- package/src/plugin/host-alias.ts +61 -0
- package/src/plugin/index.ts +11 -0
- package/src/plugin/install.ts +213 -0
- package/src/plugin/loader.ts +952 -0
- package/src/plugin/manage.ts +338 -0
- package/src/plugin/models-service.ts +383 -0
- package/src/plugin/network-service.ts +102 -0
- package/src/plugin/package-manager.ts +214 -0
- package/src/plugin/paths.ts +19 -0
- package/src/plugin/registry.ts +103 -0
- package/src/plugin/runtime.ts +57 -0
- package/src/plugin/scaffold.ts +158 -0
- package/src/plugin/state.ts +52 -0
- package/src/plugin/zip.ts +156 -0
- package/src/sandbox/audit.ts +38 -0
- package/src/sandbox/backends/bwrap.ts +251 -0
- package/src/sandbox/backends/direct.ts +43 -0
- package/src/sandbox/bridge-state.ts +29 -0
- package/src/sandbox/index.ts +5 -0
- package/src/sandbox/manager.ts +406 -0
- package/src/sandbox/memory-limit.ts +245 -0
- package/src/sandbox/plugin-client.ts +1881 -0
- package/src/sandbox/plugin-host.ts +1282 -0
- package/src/sandbox/protocol.ts +142 -0
- package/src/sandbox/pty-bridge.py +154 -0
- package/src/sandbox/rpc-timeouts.ts +43 -0
- package/src/sandbox/supervisor.ts +172 -0
- package/src/sandbox/types.ts +149 -0
- package/src/service/control.ts +155 -0
- package/src/session/compress.ts +47 -0
- package/src/session/index.ts +8 -0
- package/src/session/registry.ts +17 -0
- package/src/session/replay.ts +132 -0
- package/src/session/session.ts +134 -0
- package/src/session/store.ts +468 -0
- package/src/session/types.ts +61 -0
- package/src/workspace/index.ts +21 -0
- package/src/workspace/registry.ts +356 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 插件侧模块别名。
|
|
3
|
+
* 插件不在 wellspring 包的解析路径内,用 Node 的 resolve hook 把
|
|
4
|
+
* "wellspring" / "wellspring/..." 映射到本仓库的 src 目录,
|
|
5
|
+
* 这样插件可以 import { onMessage, getHost } from "wellspring/api/host/index.ts"。
|
|
6
|
+
*/
|
|
7
|
+
import { statSync } from "node:fs";
|
|
8
|
+
import { registerHooks } from "node:module";
|
|
9
|
+
import { join, resolve } from "node:path";
|
|
10
|
+
import { pathToFileURL } from "node:url";
|
|
11
|
+
const PROJECT_ROOT = resolve(import.meta.dirname, "../..");
|
|
12
|
+
const SOURCE_ROOT = join(PROJECT_ROOT, "src");
|
|
13
|
+
const PREFIX = "wellspring/";
|
|
14
|
+
let installed = false;
|
|
15
|
+
function existingFile(path) {
|
|
16
|
+
try {
|
|
17
|
+
const info = statSync(path);
|
|
18
|
+
return info.isFile() ? path : null;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function resolveHostTarget(specifier) {
|
|
25
|
+
if (specifier === "wellspring") {
|
|
26
|
+
return existingFile(join(SOURCE_ROOT, "api", "host", "index.ts"));
|
|
27
|
+
}
|
|
28
|
+
if (!specifier.startsWith(PREFIX)) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const rest = specifier.slice(PREFIX.length);
|
|
32
|
+
if (rest === "" || rest.startsWith("..") || rest.startsWith("/") || rest.includes("\\")) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const direct = existingFile(join(SOURCE_ROOT, rest));
|
|
36
|
+
if (direct !== null) {
|
|
37
|
+
return direct;
|
|
38
|
+
}
|
|
39
|
+
return existingFile(join(SOURCE_ROOT, rest, "index.ts"));
|
|
40
|
+
}
|
|
41
|
+
/** 注册一次即可;在加载插件前调用 */
|
|
42
|
+
export function ensureHostAlias() {
|
|
43
|
+
if (installed) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
installed = true;
|
|
47
|
+
registerHooks({
|
|
48
|
+
resolve(specifier, context, nextResolve) {
|
|
49
|
+
const target = resolveHostTarget(specifier);
|
|
50
|
+
if (target !== null) {
|
|
51
|
+
return { url: pathToFileURL(target).href, shortCircuit: true };
|
|
52
|
+
}
|
|
53
|
+
return nextResolve(specifier, context);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=host-alias.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-alias.js","sourceRoot":"","sources":["../../src/plugin/host-alias.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;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C;QACtF,OAAO,IAAI,CAAA;IACf,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAA;IACpD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,MAAM,CAAA;IACjB,CAAC;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAA;AAC5D,CAAC;AAED,sBAAsB;AACtB,MAAM,UAAU,eAAe;IAC3B,IAAI,SAAS,EAAE,CAAC;QACZ,OAAM;IACV,CAAC;IACD,SAAS,GAAG,IAAI,CAAA;IAChB,aAAa,CAAC;QACV,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW;YACnC,MAAM,MAAM,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAA;YAC3C,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;gBAClB,OAAO,EAAE,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;YAClE,CAAC;YACD,OAAO,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;QAC1C,CAAC;KACJ,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 插件层入口。
|
|
3
|
+
*/
|
|
4
|
+
export * from "./console-guard.js";
|
|
5
|
+
export * from "./host-alias.js";
|
|
6
|
+
export * from "./install.js";
|
|
7
|
+
export * from "./loader.js";
|
|
8
|
+
export * from "./paths.js";
|
|
9
|
+
export * from "./registry.js";
|
|
10
|
+
export * from "./zip.js";
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ResolvedPaths } from "../platform/path.js";
|
|
2
|
+
export interface InstallPluginOptions {
|
|
3
|
+
readonly force?: boolean;
|
|
4
|
+
/** 解析出插件名后、写入磁盘前调用;返回非空字符串表示拒绝安装 */
|
|
5
|
+
readonly validateId?: (id: string) => string | null;
|
|
6
|
+
/** 测试注入;默认使用真实包管理器安装依赖 */
|
|
7
|
+
readonly runInstall?: typeof import("./package-manager.js").runPackageInstall;
|
|
8
|
+
}
|
|
9
|
+
export interface InstallPluginResult {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly target: string;
|
|
12
|
+
/** 实际使用的包管理器(带声明版本,例如 npm@11.20.0);没有安装依赖时为 null */
|
|
13
|
+
readonly packageManager: string | null;
|
|
14
|
+
readonly dependenciesInstalled: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** 安装本地插件目录或 zip 包 */
|
|
17
|
+
export declare function installPlugin(sourcePath: string, paths?: ResolvedPaths, options?: InstallPluginOptions): Promise<InstallPluginResult>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 本地插件安装:目录或 zip 包。
|
|
3
|
+
* zip 在插件根目录下的临时目录解压,校验后再搬到 plugins/<name>。
|
|
4
|
+
*
|
|
5
|
+
* 插件 package.json 可以用 packageManager 声明包管理器;声明了 dependencies 时
|
|
6
|
+
* 安装阶段会调用它自动安装依赖(没有声明则按 lockfile 推断,仍没有则报错)。
|
|
7
|
+
*/
|
|
8
|
+
import { cp, readFile, readdir, rename, stat } from "node:fs/promises";
|
|
9
|
+
import { basename, extname, join, resolve } from "node:path";
|
|
10
|
+
import { ensureDir, readJsonIfExists, removePath, statIfExists } from "../platform/file.js";
|
|
11
|
+
import { getPaths } from "../platform/path.js";
|
|
12
|
+
import { hasPluginDependencies, installPluginDependencies, packageManagerLabel, } from "./package-manager.js";
|
|
13
|
+
import { PLUGIN_NAME, pluginsRoot } from "./paths.js";
|
|
14
|
+
import { extractZip } from "./zip.js";
|
|
15
|
+
const ENTRIES = ["index.ts", "index.js", "index.mjs", "index.mts"];
|
|
16
|
+
async function hasEntry(dir) {
|
|
17
|
+
for (const entry of ENTRIES) {
|
|
18
|
+
if ((await statIfExists(join(dir, entry))) !== null) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const pkg = await readJsonIfExists(join(dir, "package.json"));
|
|
23
|
+
if (pkg === null) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
const candidates = [];
|
|
27
|
+
if (typeof pkg.wellspring?.entry === "string") {
|
|
28
|
+
candidates.push(pkg.wellspring.entry);
|
|
29
|
+
}
|
|
30
|
+
if (typeof pkg.main === "string") {
|
|
31
|
+
candidates.push(pkg.main);
|
|
32
|
+
}
|
|
33
|
+
for (const candidate of candidates) {
|
|
34
|
+
if ((await statIfExists(resolve(dir, candidate))) !== null) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
/** 压缩包常见形态是外面套一层目录;没有根入口时向下找唯一子目录 */
|
|
41
|
+
async function normalizeExtracted(root) {
|
|
42
|
+
if (await hasEntry(root)) {
|
|
43
|
+
return root;
|
|
44
|
+
}
|
|
45
|
+
const entries = await readdir(root, { withFileTypes: true });
|
|
46
|
+
const dirs = entries.filter((entry) => entry.isDirectory());
|
|
47
|
+
if (dirs.length === 1) {
|
|
48
|
+
const child = join(root, dirs[0]?.name ?? "");
|
|
49
|
+
if (await hasEntry(child)) {
|
|
50
|
+
return child;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw new Error("zip 中找不到插件入口(index.ts/js/mjs/mts 或 package.json main)");
|
|
54
|
+
}
|
|
55
|
+
async function resolveSourceName(source, sourceDir, temp) {
|
|
56
|
+
const pkg = await readJsonIfExists(join(sourceDir, "package.json"));
|
|
57
|
+
if (typeof pkg?.name === "string" && pkg.name.trim() !== "") {
|
|
58
|
+
return pkg.name.trim();
|
|
59
|
+
}
|
|
60
|
+
const candidate = basename(source, extname(source));
|
|
61
|
+
return temp ? candidate : basename(sourceDir);
|
|
62
|
+
}
|
|
63
|
+
/** 复制插件目录到暂存区;node_modules 不复制,交给包管理器装 */
|
|
64
|
+
async function copyToStage(source, stage) {
|
|
65
|
+
await cp(source, stage, {
|
|
66
|
+
recursive: true,
|
|
67
|
+
force: true,
|
|
68
|
+
filter: (path) => basename(path) !== "node_modules",
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/** 安装本地插件目录或 zip 包 */
|
|
72
|
+
export async function installPlugin(sourcePath, paths = getPaths(), options = {}) {
|
|
73
|
+
const source = resolve(sourcePath);
|
|
74
|
+
const info = await stat(source);
|
|
75
|
+
const root = pluginsRoot(paths);
|
|
76
|
+
await ensureDir(root);
|
|
77
|
+
const temp = join(root, `.install-${process.pid}-${Date.now().toString(36)}`);
|
|
78
|
+
let sourceDir;
|
|
79
|
+
let fromArchive = false;
|
|
80
|
+
if (info.isDirectory()) {
|
|
81
|
+
sourceDir = source;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const buffer = await readFile(source);
|
|
85
|
+
await removePath(temp);
|
|
86
|
+
await ensureDir(temp);
|
|
87
|
+
await extractZip(buffer, temp);
|
|
88
|
+
sourceDir = await normalizeExtracted(temp);
|
|
89
|
+
fromArchive = true;
|
|
90
|
+
}
|
|
91
|
+
let stage = null;
|
|
92
|
+
let moved = false;
|
|
93
|
+
try {
|
|
94
|
+
if (!(await hasEntry(sourceDir))) {
|
|
95
|
+
throw new Error("插件缺少入口(index.ts/js/mjs/mts 或 package.json main)");
|
|
96
|
+
}
|
|
97
|
+
const name = await resolveSourceName(source, sourceDir, fromArchive);
|
|
98
|
+
if (!PLUGIN_NAME.test(name)) {
|
|
99
|
+
throw new Error(`插件名不合法:${name}`);
|
|
100
|
+
}
|
|
101
|
+
const rejected = options.validateId?.(name) ?? null;
|
|
102
|
+
if (rejected !== null) {
|
|
103
|
+
throw new Error(rejected);
|
|
104
|
+
}
|
|
105
|
+
const target = join(root, name);
|
|
106
|
+
const existing = await statIfExists(target);
|
|
107
|
+
if (existing !== null && options.force !== true) {
|
|
108
|
+
throw new Error(`插件已存在:${name}`);
|
|
109
|
+
}
|
|
110
|
+
const pkg = await readJsonIfExists(join(sourceDir, "package.json"));
|
|
111
|
+
const needsInstall = pkg !== null && hasPluginDependencies(pkg);
|
|
112
|
+
let installDir = sourceDir;
|
|
113
|
+
if (needsInstall && !fromArchive) {
|
|
114
|
+
/*
|
|
115
|
+
* 目录安装不能碰源目录:复制到暂存区后再安装依赖,
|
|
116
|
+
* node_modules 不复制,避免把开发目录里的依赖带进去。
|
|
117
|
+
*/
|
|
118
|
+
stage = join(root, `.install-stage-${process.pid}-${Date.now().toString(36)}`);
|
|
119
|
+
await removePath(stage);
|
|
120
|
+
await copyToStage(sourceDir, stage);
|
|
121
|
+
installDir = stage;
|
|
122
|
+
}
|
|
123
|
+
let dependencies = {
|
|
124
|
+
manager: null,
|
|
125
|
+
installed: false,
|
|
126
|
+
reason: null,
|
|
127
|
+
};
|
|
128
|
+
if (needsInstall) {
|
|
129
|
+
dependencies = await installPluginDependencies(installDir, pkg, {
|
|
130
|
+
...(options.runInstall === undefined ? {} : { run: options.runInstall }),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
if (existing !== null) {
|
|
134
|
+
await removePath(target);
|
|
135
|
+
}
|
|
136
|
+
if (fromArchive) {
|
|
137
|
+
// 与临时目录同根,rename 保持原子
|
|
138
|
+
await rename(sourceDir, target);
|
|
139
|
+
}
|
|
140
|
+
else if (stage !== null) {
|
|
141
|
+
await rename(stage, target);
|
|
142
|
+
moved = true;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
await cp(sourceDir, target, { recursive: true, force: true });
|
|
146
|
+
}
|
|
147
|
+
return {
|
|
148
|
+
id: name,
|
|
149
|
+
target,
|
|
150
|
+
packageManager: dependencies.manager === null ? null : packageManagerLabel(dependencies.manager),
|
|
151
|
+
dependenciesInstalled: dependencies.installed,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
if (fromArchive) {
|
|
156
|
+
await removePath(temp);
|
|
157
|
+
}
|
|
158
|
+
if (stage !== null && !moved) {
|
|
159
|
+
await removePath(stage);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/plugin/install.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAsB,MAAM,qBAAqB,CAAA;AAClE,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,GAGtB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,MAAM,OAAO,GAAG,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,CAAC,CAAA;AA0BlE,KAAK,UAAU,QAAQ,CAAC,GAAW;IAC/B,KAAK,MA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C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Logger } from "pino";
|
|
2
|
+
import type { PluginStatus } from "../api/host/plugin.js";
|
|
3
|
+
import type { AppSetting, SandboxSetting } from "../config/types.js";
|
|
4
|
+
import { type ResolvedPaths } from "../platform/path.js";
|
|
5
|
+
import type { SandboxBackend } from "../sandbox/types.js";
|
|
6
|
+
import { AgentToolRegistry } from "./agent-tools.js";
|
|
7
|
+
import { PluginDataService } from "./data-access.js";
|
|
8
|
+
import { PluginRegistry } from "./registry.js";
|
|
9
|
+
import { type HostAgentService } from "./agent-service.js";
|
|
10
|
+
import { type PluginHotController, type PluginHotOutcome } from "./manage.js";
|
|
11
|
+
export type PluginLoadStatus = PluginStatus | "disabled";
|
|
12
|
+
export type { PluginStatus } from "../api/host/plugin.js";
|
|
13
|
+
export interface LoadedPlugin {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly name: string;
|
|
16
|
+
readonly version: string;
|
|
17
|
+
readonly deps: readonly string[];
|
|
18
|
+
readonly dir: string;
|
|
19
|
+
readonly status: PluginLoadStatus;
|
|
20
|
+
readonly commands: readonly string[];
|
|
21
|
+
readonly error: string | null;
|
|
22
|
+
}
|
|
23
|
+
export interface LoadPluginsOptions {
|
|
24
|
+
readonly paths?: ResolvedPaths;
|
|
25
|
+
readonly config: AppSetting;
|
|
26
|
+
readonly logger: Logger;
|
|
27
|
+
readonly registry: PluginRegistry;
|
|
28
|
+
readonly sandbox?: SandboxSetting;
|
|
29
|
+
readonly agentTools?: AgentToolRegistry;
|
|
30
|
+
/** 测试注入 */
|
|
31
|
+
readonly dataAccess?: PluginDataService;
|
|
32
|
+
/** 测试注入;生产根据 sandbox.mode 探测 */
|
|
33
|
+
readonly sandboxBackend?: SandboxBackend;
|
|
34
|
+
/** 测试注入;默认按 settings 构造 */
|
|
35
|
+
readonly agent?: HostAgentService;
|
|
36
|
+
}
|
|
37
|
+
/** 取当前进程的插件热加载控制器;未经过 loadPlugins 时返回 null */
|
|
38
|
+
export declare function getPluginRuntime(paths?: ResolvedPaths): PluginHotController | null;
|
|
39
|
+
export declare function hotEnablePlugin(id: string, paths?: ResolvedPaths): Promise<PluginHotOutcome>;
|
|
40
|
+
export declare function hotDisablePlugin(id: string, paths?: ResolvedPaths): Promise<PluginHotOutcome>;
|
|
41
|
+
export declare function loadPlugins(options: LoadPluginsOptions): Promise<readonly LoadedPlugin[]>;
|
|
42
|
+
/** 把本地插件目录链接进插件根目录,开发用;没有符号链接权限时退化为复制 */
|
|
43
|
+
export declare function linkPlugin(sourcePath: string, paths?: ResolvedPaths): Promise<string>;
|
|
44
|
+
/** 删除插件目录 */
|
|
45
|
+
export declare function removePlugin(name: string, paths?: ResolvedPaths): Promise<void>;
|