happy2 0.0.9 → 0.0.11
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/README.md +19 -0
- package/package.json +7 -3
- package/packages/happy2-server/PLUGINS.md +330 -0
- package/packages/happy2-server/README.md +28 -0
- package/packages/happy2-server/dist/index.d.ts +6 -0
- package/packages/happy2-server/dist/index.d.ts.map +1 -1
- package/packages/happy2-server/dist/index.js +4 -0
- package/packages/happy2-server/dist/index.js.map +1 -1
- package/packages/happy2-server/dist/modules/agents/daemon.d.ts +10 -13
- package/packages/happy2-server/dist/modules/agents/daemon.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agents/daemon.js +19 -5
- package/packages/happy2-server/dist/modules/agents/daemon.js.map +1 -1
- package/packages/happy2-server/dist/modules/agents/service.d.ts +9 -1
- package/packages/happy2-server/dist/modules/agents/service.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agents/service.js +59 -2
- package/packages/happy2-server/dist/modules/agents/service.js.map +1 -1
- package/packages/happy2-server/dist/modules/chat/types.d.ts +1 -1
- package/packages/happy2-server/dist/modules/chat/types.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/config/defaults.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/config/defaults.js +3 -0
- package/packages/happy2-server/dist/modules/config/defaults.js.map +1 -1
- package/packages/happy2-server/dist/modules/config/loader.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/config/loader.js +4 -0
- package/packages/happy2-server/dist/modules/config/loader.js.map +1 -1
- package/packages/happy2-server/dist/modules/config/paths.d.ts +1 -0
- package/packages/happy2-server/dist/modules/config/paths.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/config/paths.js +1 -0
- package/packages/happy2-server/dist/modules/config/paths.js.map +1 -1
- package/packages/happy2-server/dist/modules/config/paths.test.js +1 -0
- package/packages/happy2-server/dist/modules/config/paths.test.js.map +1 -1
- package/packages/happy2-server/dist/modules/config/type.d.ts +3 -0
- package/packages/happy2-server/dist/modules/config/type.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/integrations/transport.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/integrations/transport.js +8 -1
- package/packages/happy2-server/dist/modules/integrations/transport.js.map +1 -1
- package/packages/happy2-server/dist/modules/integrations/types.d.ts +2 -0
- package/packages/happy2-server/dist/modules/integrations/types.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/integrations/types.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/catalog.d.ts +13 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.js +359 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.test.js +139 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/functions.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/functions.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/functions.test.js +123 -0
- package/packages/happy2-server/dist/modules/plugin/functions.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/httpBridge.d.ts +19 -0
- package/packages/happy2-server/dist/modules/plugin/httpBridge.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/httpBridge.js +206 -0
- package/packages/happy2-server/dist/modules/plugin/httpBridge.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.d.ts +3 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.js +47 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.d.ts +3 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.js +69 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.d.ts +288 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.js +19 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.d.ts +3 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.js +52 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.js +17 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginFunctionResult.d.ts +3 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginFunctionResult.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginFunctionResult.js +16 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginFunctionResult.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSelection.d.ts +339 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSelection.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSelection.js +22 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSelection.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/index.d.ts +3 -0
- package/packages/happy2-server/dist/modules/plugin/index.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/index.js +3 -0
- package/packages/happy2-server/dist/modules/plugin/index.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.d.ts +15 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.js +90 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAuthorizeManagement.d.ts +7 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAuthorizeManagement.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAuthorizeManagement.js +9 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAuthorizeManagement.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.d.ts +9 -0
- package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.js +50 -0
- package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.d.ts +9 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.js +15 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultAcquire.d.ts +23 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultAcquire.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultAcquire.js +54 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultAcquire.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultComplete.d.ts +13 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultComplete.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultComplete.js +37 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFunctionResultComplete.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginGetImage.d.ts +17 -0
- package/packages/happy2-server/dist/modules/plugin/pluginGetImage.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginGetImage.js +29 -0
- package/packages/happy2-server/dist/modules/plugin/pluginGetImage.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.d.ts +27 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.js +175 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.d.ts +9 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js +111 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetStatus.d.ts +11 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetStatus.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetStatus.js +18 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetStatus.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationList.d.ts +8 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationList.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationList.js +19 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationList.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListIds.d.ts +7 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListIds.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListIds.js +13 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListIds.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListReadyMcpIds.d.ts +7 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListReadyMcpIds.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListReadyMcpIds.js +16 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationListReadyMcpIds.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUpdateStatus.d.ts +15 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUpdateStatus.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUpdateStatus.js +37 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUpdateStatus.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginList.d.ts +8 -0
- package/packages/happy2-server/dist/modules/plugin/pluginList.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginList.js +17 -0
- package/packages/happy2-server/dist/modules/plugin/pluginList.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginRemoveMissingBuiltins.d.ts +14 -0
- package/packages/happy2-server/dist/modules/plugin/pluginRemoveMissingBuiltins.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginRemoveMissingBuiltins.js +51 -0
- package/packages/happy2-server/dist/modules/plugin/pluginRemoveMissingBuiltins.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/runtime.d.ts +37 -0
- package/packages/happy2-server/dist/modules/plugin/runtime.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/runtime.js +62 -0
- package/packages/happy2-server/dist/modules/plugin/runtime.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.d.ts +17 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.js +56 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.test.js +14 -0
- package/packages/happy2-server/dist/modules/plugin/secrets.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/service.d.ts +52 -0
- package/packages/happy2-server/dist/modules/plugin/service.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/service.js +538 -0
- package/packages/happy2-server/dist/modules/plugin/service.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/types.d.ts +157 -0
- package/packages/happy2-server/dist/modules/plugin/types.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/types.js +9 -0
- package/packages/happy2-server/dist/modules/plugin/types.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.d.ts +19 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.js +97 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.test.js +74 -0
- package/packages/happy2-server/dist/modules/plugin/utils/ndjsonStreamTransport.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.d.ts +29 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.js +126 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.test.js +75 -0
- package/packages/happy2-server/dist/modules/plugin/utils/remoteMcpTransport.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/sandbox/index.d.ts +1 -1
- package/packages/happy2-server/dist/modules/sandbox/index.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.d.ts +2 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.js +117 -3
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.js.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.test.js +81 -2
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.test.js.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/types.d.ts +8 -0
- package/packages/happy2-server/dist/modules/sandbox/types.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/schema.d.ts +7486 -5588
- package/packages/happy2-server/dist/modules/schema.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/schema.js +72 -1
- package/packages/happy2-server/dist/modules/schema.js.map +1 -1
- package/packages/happy2-server/dist/modules/sync/syncGetDifference.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/sync/syncGetDifference.js +2 -0
- package/packages/happy2-server/dist/modules/sync/syncGetDifference.js.map +1 -1
- package/packages/happy2-server/dist/routes/plugins.d.ts +8 -0
- package/packages/happy2-server/dist/routes/plugins.d.ts.map +1 -0
- package/packages/happy2-server/dist/routes/plugins.js +186 -0
- package/packages/happy2-server/dist/routes/plugins.js.map +1 -0
- package/packages/happy2-server/dist/runner.js +45 -19
- package/packages/happy2-server/dist/runner.js.map +1 -1
- package/packages/happy2-server/dist/server.d.ts +6 -0
- package/packages/happy2-server/dist/server.d.ts.map +1 -1
- package/packages/happy2-server/dist/server.js +46 -3
- package/packages/happy2-server/dist/server.js.map +1 -1
- package/packages/happy2-server/dist/systemService.d.ts +48 -0
- package/packages/happy2-server/dist/systemService.d.ts.map +1 -0
- package/packages/happy2-server/dist/systemService.js +308 -0
- package/packages/happy2-server/dist/systemService.js.map +1 -0
- package/packages/happy2-server/dist/systemService.test.d.ts +2 -0
- package/packages/happy2-server/dist/systemService.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/systemService.test.js +266 -0
- package/packages/happy2-server/dist/systemService.test.js.map +1 -0
- package/packages/happy2-server/dist/web/assets/index-9SGCQLg7.js +46 -0
- package/packages/happy2-server/dist/web/assets/{index-DZ1uRLgV.css → index-DWXBQDJB.css} +1 -1
- package/packages/happy2-server/dist/web/index.html +2 -2
- package/packages/happy2-server/drizzle/0020_plugins.sql +61 -0
- package/packages/happy2-server/drizzle/0021_plugin_function_results.sql +11 -0
- package/packages/happy2-server/drizzle/meta/_journal.json +14 -0
- package/packages/happy2-server/happy2.example.toml +5 -0
- package/packages/happy2-server/plugins/README.md +7 -0
- package/packages/happy2-server/plugins/hello/container/Dockerfile +6 -0
- package/packages/happy2-server/plugins/hello/plugin.json +16 -0
- package/packages/happy2-server/plugins/hello/plugin.png +0 -0
- package/packages/happy2-server/plugins/hello/server.mjs +75 -0
- package/packages/happy2-server/plugins/hello/skills/hello/SKILL.md +11 -0
- package/packages/happy2-server/dist/web/assets/index-DH1SOwNV.js +0 -46
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type DrizzleExecutor } from "../drizzle.js";
|
|
2
|
+
import type { PluginFunctionResult } from "./types.js";
|
|
3
|
+
export type PluginFunctionResultAcquireResult = {
|
|
4
|
+
kind: "acquired";
|
|
5
|
+
} | {
|
|
6
|
+
kind: "in_progress";
|
|
7
|
+
retryAt: number;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "replay";
|
|
10
|
+
result: PluginFunctionResult;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Creates, replays, waits for, or conditionally takes over the durable pluginFunctionResults lease for one Rig call.
|
|
14
|
+
* The transaction admits one live MCP executor at a time while retaining a completed outcome indefinitely for event redelivery and restart recovery.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pluginFunctionResultAcquire(executor: DrizzleExecutor, input: {
|
|
17
|
+
callId: string;
|
|
18
|
+
leaseExpiresAt: number;
|
|
19
|
+
leaseToken: string;
|
|
20
|
+
now: number;
|
|
21
|
+
sessionId: string;
|
|
22
|
+
}): Promise<PluginFunctionResultAcquireResult>;
|
|
23
|
+
//# sourceMappingURL=pluginFunctionResultAcquire.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginFunctionResultAcquire.d.ts","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginFunctionResultAcquire.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,eAAe,CAAC;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,MAAM,iCAAiC,GACvC;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAEvD;;;GAGG;AACH,wBAAsB,2BAA2B,CAC7C,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE;IACH,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACrB,GACF,OAAO,CAAC,iCAAiC,CAAC,CAoD5C"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { and, eq, sql } from "drizzle-orm";
|
|
2
|
+
import { withTransaction } from "../drizzle.js";
|
|
3
|
+
import { pluginFunctionResults } from "../schema.js";
|
|
4
|
+
import { parsePluginFunctionResult } from "./impl/pluginFunctionResult.js";
|
|
5
|
+
/**
|
|
6
|
+
* Creates, replays, waits for, or conditionally takes over the durable pluginFunctionResults lease for one Rig call.
|
|
7
|
+
* The transaction admits one live MCP executor at a time while retaining a completed outcome indefinitely for event redelivery and restart recovery.
|
|
8
|
+
*/
|
|
9
|
+
export async function pluginFunctionResultAcquire(executor, input) {
|
|
10
|
+
return withTransaction(executor, async (tx) => {
|
|
11
|
+
const lockedUntil = new Date(input.leaseExpiresAt).toISOString();
|
|
12
|
+
const [inserted] = await tx
|
|
13
|
+
.insert(pluginFunctionResults)
|
|
14
|
+
.values({
|
|
15
|
+
sessionId: input.sessionId,
|
|
16
|
+
callId: input.callId,
|
|
17
|
+
leaseToken: input.leaseToken,
|
|
18
|
+
lockedUntil,
|
|
19
|
+
})
|
|
20
|
+
.onConflictDoNothing()
|
|
21
|
+
.returning({ callId: pluginFunctionResults.callId });
|
|
22
|
+
if (inserted)
|
|
23
|
+
return { kind: "acquired" };
|
|
24
|
+
const [row] = await tx
|
|
25
|
+
.select({
|
|
26
|
+
lockedUntil: pluginFunctionResults.lockedUntil,
|
|
27
|
+
resolutionJson: pluginFunctionResults.resolutionJson,
|
|
28
|
+
status: pluginFunctionResults.status,
|
|
29
|
+
})
|
|
30
|
+
.from(pluginFunctionResults)
|
|
31
|
+
.where(and(eq(pluginFunctionResults.sessionId, input.sessionId), eq(pluginFunctionResults.callId, input.callId)))
|
|
32
|
+
.limit(1);
|
|
33
|
+
if (!row)
|
|
34
|
+
throw new Error("Plugin function result disappeared during acquisition");
|
|
35
|
+
if (row?.status === "completed") {
|
|
36
|
+
if (row.resolutionJson === null)
|
|
37
|
+
throw new Error("Completed plugin function result is missing its resolution");
|
|
38
|
+
return { kind: "replay", result: parsePluginFunctionResult(row.resolutionJson) };
|
|
39
|
+
}
|
|
40
|
+
if (row?.lockedUntil && Date.parse(row.lockedUntil) > input.now)
|
|
41
|
+
return { kind: "in_progress", retryAt: Date.parse(row.lockedUntil) };
|
|
42
|
+
await tx
|
|
43
|
+
.update(pluginFunctionResults)
|
|
44
|
+
.set({
|
|
45
|
+
leaseToken: input.leaseToken,
|
|
46
|
+
lockedUntil,
|
|
47
|
+
status: "in_progress",
|
|
48
|
+
updatedAt: sql `CURRENT_TIMESTAMP`,
|
|
49
|
+
})
|
|
50
|
+
.where(and(eq(pluginFunctionResults.sessionId, input.sessionId), eq(pluginFunctionResults.callId, input.callId)));
|
|
51
|
+
return { kind: "acquired" };
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=pluginFunctionResultAcquire.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginFunctionResultAcquire.js","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginFunctionResultAcquire.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAwB,eAAe,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAQ3E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC7C,QAAyB,EACzB,KAMC;IAED,OAAO,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC1C,MAAM,WAAW,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;QACjE,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,EAAE;aACtB,MAAM,CAAC,qBAAqB,CAAC;aAC7B,MAAM,CAAC;YACJ,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,MAA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C,EAAE,CAAC;QACzE,MAAM,EAAE;aACH,MAAM,CAAC,qBAAqB,CAAC;aAC7B,GAAG,CAAC;YACD,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,WAAW;YACX,MAAM,EAAE,aAAa;YACrB,SAAS,EAAE,GAAG,CAAA,mBAAmB;SACpC,CAAC;aACD,KAAK,CACF,GAAG,CACC,EAAE,CAAC,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,EACpD,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CACjD,CACJ,CAAC;QACN,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type DrizzleExecutor } from "../drizzle.js";
|
|
2
|
+
import type { PluginFunctionResult } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Stores the terminal MCP outcome only while the caller owns the pluginFunctionResults lease for the Rig call.
|
|
5
|
+
* Lease fencing prevents a late or superseded executor from replacing the first durable resolution that Rig and every redelivery must observe.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pluginFunctionResultComplete(executor: DrizzleExecutor, input: {
|
|
8
|
+
callId: string;
|
|
9
|
+
leaseToken: string;
|
|
10
|
+
result: PluginFunctionResult;
|
|
11
|
+
sessionId: string;
|
|
12
|
+
}): Promise<PluginFunctionResult>;
|
|
13
|
+
//# sourceMappingURL=pluginFunctionResultComplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginFunctionResultComplete.d.ts","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginFunctionResultComplete.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,eAAe,CAAC;AAGtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEvD;;;GAGG;AACH,wBAAsB,4BAA4B,CAC9C,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE;IACH,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,oBAAoB,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACrB,GACF,OAAO,CAAC,oBAAoB,CAAC,CAsC/B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { and, eq, sql } from "drizzle-orm";
|
|
2
|
+
import { withTransaction } from "../drizzle.js";
|
|
3
|
+
import { pluginFunctionResults } from "../schema.js";
|
|
4
|
+
import { parsePluginFunctionResult } from "./impl/pluginFunctionResult.js";
|
|
5
|
+
/**
|
|
6
|
+
* Stores the terminal MCP outcome only while the caller owns the pluginFunctionResults lease for the Rig call.
|
|
7
|
+
* Lease fencing prevents a late or superseded executor from replacing the first durable resolution that Rig and every redelivery must observe.
|
|
8
|
+
*/
|
|
9
|
+
export async function pluginFunctionResultComplete(executor, input) {
|
|
10
|
+
return withTransaction(executor, async (tx) => {
|
|
11
|
+
const [completed] = await tx
|
|
12
|
+
.update(pluginFunctionResults)
|
|
13
|
+
.set({
|
|
14
|
+
leaseToken: null,
|
|
15
|
+
lockedUntil: null,
|
|
16
|
+
resolutionJson: JSON.stringify(input.result),
|
|
17
|
+
status: "completed",
|
|
18
|
+
updatedAt: sql `CURRENT_TIMESTAMP`,
|
|
19
|
+
})
|
|
20
|
+
.where(and(eq(pluginFunctionResults.sessionId, input.sessionId), eq(pluginFunctionResults.callId, input.callId), eq(pluginFunctionResults.status, "in_progress"), eq(pluginFunctionResults.leaseToken, input.leaseToken)))
|
|
21
|
+
.returning({ resolutionJson: pluginFunctionResults.resolutionJson });
|
|
22
|
+
if (completed?.resolutionJson)
|
|
23
|
+
return parsePluginFunctionResult(completed.resolutionJson);
|
|
24
|
+
const [winner] = await tx
|
|
25
|
+
.select({
|
|
26
|
+
resolutionJson: pluginFunctionResults.resolutionJson,
|
|
27
|
+
status: pluginFunctionResults.status,
|
|
28
|
+
})
|
|
29
|
+
.from(pluginFunctionResults)
|
|
30
|
+
.where(and(eq(pluginFunctionResults.sessionId, input.sessionId), eq(pluginFunctionResults.callId, input.callId)))
|
|
31
|
+
.limit(1);
|
|
32
|
+
if (winner?.status === "completed" && winner.resolutionJson)
|
|
33
|
+
return parsePluginFunctionResult(winner.resolutionJson);
|
|
34
|
+
throw new Error("Plugin function result lease was lost before completion");
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=pluginFunctionResultComplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginFunctionResultComplete.js","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginFunctionResultComplete.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAwB,eAAe,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAG3E;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAC9C,QAAyB,EACzB,KAKC;IAED,OAAO,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC1C,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,EAAE;aACvB,MAAM,CAAC,qBAAqB,CAAC;aAC7B,GAAG,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,IAAI;YACjB,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;YAC5C,MAAM,EAAE,WAAW;YACnB,SAAS,EAAE,GAAG,CAAA,mBAAmB;SACpC,CAAC;aACD,KAAK,CACF,GAAG,CACC,EAAE,CAAC,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,EACpD,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAC9C,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,aAAa,CAAC,EAC/C,EAAE,CAAC,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CACzD,CACJ;aACA,SAAS,CAAC,EAAE,cAAc,EAAE,qBAAqB,CAAC,cAAc,EAAE,CAAC,CAAC;QACzE,IAAI,SAAS,EAAE,cAAc;YAAE,OAAO,yBAAyB,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAC1F,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE;aACpB,MAAM,CAAC;YACJ,cAAc,EAAE,qBAAqB,CAAC,cAAc;YACpD,MAAM,EAAE,qBAAqB,CAAC,MAAM;SACvC,CAAC;aACD,IAAI,CAAC,qBAAqB,CAAC;aAC3B,KAAK,CACF,GAAG,CACC,EAAE,CAAC,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,EACpD,EAAE,CAAC,qBAAqB,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CACjD,CACJ;aACA,KAAK,CAAC,CAAC,CAAC,CAAC;QACd,IAAI,MAAM,EAAE,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,cAAc;YACvD,OAAO,yBAAyB,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QAC5D,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { DrizzleExecutor } from "../drizzle.js";
|
|
2
|
+
export interface StoredPluginImage {
|
|
3
|
+
pluginId: string;
|
|
4
|
+
shortName: string;
|
|
5
|
+
packageDigest: string;
|
|
6
|
+
packageDirectory: string;
|
|
7
|
+
storageKey: string;
|
|
8
|
+
contentType: string;
|
|
9
|
+
size: number;
|
|
10
|
+
checksumSha256: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Returns the private filesystem locator and public response metadata for one persisted plugin image after administrator authorization.
|
|
14
|
+
* This read-only boundary does not mutate durable state and prevents routes from reading package paths without a durable plugin record.
|
|
15
|
+
*/
|
|
16
|
+
export declare function pluginGetImage(executor: DrizzleExecutor, actorUserId: string, pluginId: string): Promise<StoredPluginImage>;
|
|
17
|
+
//# sourceMappingURL=pluginGetImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginGetImage.d.ts","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginGetImage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAKrD,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAChC,QAAQ,EAAE,eAAe,EACzB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACjB,OAAO,CAAC,iBAAiB,CAAC,CAkB5B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { plugins } from "../schema.js";
|
|
3
|
+
import { userRequireServerAdmin } from "../chat/userRequireServerAdmin.js";
|
|
4
|
+
import { PluginError } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns the private filesystem locator and public response metadata for one persisted plugin image after administrator authorization.
|
|
7
|
+
* This read-only boundary does not mutate durable state and prevents routes from reading package paths without a durable plugin record.
|
|
8
|
+
*/
|
|
9
|
+
export async function pluginGetImage(executor, actorUserId, pluginId) {
|
|
10
|
+
await userRequireServerAdmin(executor, actorUserId);
|
|
11
|
+
const [row] = await executor
|
|
12
|
+
.select({
|
|
13
|
+
pluginId: plugins.id,
|
|
14
|
+
shortName: plugins.shortName,
|
|
15
|
+
packageDigest: plugins.packageDigest,
|
|
16
|
+
packageDirectory: plugins.packageDirectory,
|
|
17
|
+
storageKey: plugins.imageStorageKey,
|
|
18
|
+
contentType: plugins.imageContentType,
|
|
19
|
+
size: plugins.imageSize,
|
|
20
|
+
checksumSha256: plugins.imageChecksumSha256,
|
|
21
|
+
})
|
|
22
|
+
.from(plugins)
|
|
23
|
+
.where(eq(plugins.id, pluginId))
|
|
24
|
+
.limit(1);
|
|
25
|
+
if (!row)
|
|
26
|
+
throw new PluginError("not_found", "System plugin was not found");
|
|
27
|
+
return row;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=pluginGetImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginGetImage.js","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginGetImage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAazC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAChC,QAAyB,EACzB,WAAmB,EACnB,QAAgB;IAEhB,MAAM,sBAAsB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACpD,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,QAAQ;SACvB,MAAM,CAAC;QACJ,QAAQ,EAAE,OAAO,CAAC,EAAE;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;QAC1C,UAAU,EAAE,OAAO,CAAC,eAAe;QACnC,WAAW,EAAE,OAAO,CAAC,gBAAgB;QACrC,IAAI,EAAE,OAAO,CAAC,SAAS;QACvB,cAAc,EAAE,OAAO,CAAC,mBAAmB;KAC9C,CAAC;SACD,IAAI,CAAC,OAAO,CAAC;SACb,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;SAC/B,KAAK,CAAC,CAAC,CAAC,CAAC;IACd,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,WAAW,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC;IAC5E,OAAO,GAAG,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DrizzleExecutor } from "../drizzle.js";
|
|
2
|
+
import type { MutationHint } from "../chat/types.js";
|
|
3
|
+
import type { PluginSecretProtector } from "./secrets.js";
|
|
4
|
+
import { type PluginInstallationSummary, type PluginPackage } from "./types.js";
|
|
5
|
+
export interface PluginPackageCandidate {
|
|
6
|
+
pluginId: string;
|
|
7
|
+
packageDirectory: string;
|
|
8
|
+
imageStorageKey: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Ensures one catalog package has a durable system plugin, then creates an independent installation with its own encrypted variables and container choice.
|
|
12
|
+
* The transaction commits plugins, pluginInstallations, pluginInstallationVariables, audit, and sync evidence together so no installation can reference a partial plugin record.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pluginInstall(executor: DrizzleExecutor, secretProtector: PluginSecretProtector, input: {
|
|
15
|
+
actorUserId: string;
|
|
16
|
+
installationId: string;
|
|
17
|
+
plugin: PluginPackage;
|
|
18
|
+
candidate?: PluginPackageCandidate;
|
|
19
|
+
variables: Readonly<Record<string, string>>;
|
|
20
|
+
containerImageId?: string;
|
|
21
|
+
}): Promise<{
|
|
22
|
+
hint: MutationHint;
|
|
23
|
+
installation: PluginInstallationSummary;
|
|
24
|
+
pluginCreated: boolean;
|
|
25
|
+
pluginId: string;
|
|
26
|
+
}>;
|
|
27
|
+
//# sourceMappingURL=pluginInstall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginInstall.d.ts","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginInstall.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAarD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAEH,KAAK,yBAAyB,EAE9B,KAAK,aAAa,EACrB,MAAM,YAAY,CAAC;AAOpB,MAAM,WAAW,sBAAsB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAC/B,QAAQ,EAAE,eAAe,EACzB,eAAe,EAAE,qBAAqB,EACtC,KAAK,EAAE;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC7B,GACF,OAAO,CAAC;IACP,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,yBAAyB,CAAC;IACxC,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC,CA+JD"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { and, eq } from "drizzle-orm";
|
|
2
|
+
import { withTransaction } from "../drizzle.js";
|
|
3
|
+
import { agentImages, pluginInstallations, pluginInstallationVariables, plugins, } from "../schema.js";
|
|
4
|
+
import { userRequireServerAdmin } from "../chat/userRequireServerAdmin.js";
|
|
5
|
+
import { chatAppendAudit } from "../chat/chatAppendAudit.js";
|
|
6
|
+
import { syncSequenceNext } from "../sync/syncSequenceNext.js";
|
|
7
|
+
import { syncEventInsert } from "../sync/syncEventInsert.js";
|
|
8
|
+
import { areaHint } from "../chat/areaHint.js";
|
|
9
|
+
import { PluginError, } from "./types.js";
|
|
10
|
+
import { pluginInstallationSelection } from "./impl/installationSelection.js";
|
|
11
|
+
import { asPluginInstallation } from "./impl/asInstallation.js";
|
|
12
|
+
import { installedManifest } from "./impl/installedManifest.js";
|
|
13
|
+
const MAX_VARIABLE_BYTES = 64 * 1024;
|
|
14
|
+
/**
|
|
15
|
+
* Ensures one catalog package has a durable system plugin, then creates an independent installation with its own encrypted variables and container choice.
|
|
16
|
+
* The transaction commits plugins, pluginInstallations, pluginInstallationVariables, audit, and sync evidence together so no installation can reference a partial plugin record.
|
|
17
|
+
*/
|
|
18
|
+
export async function pluginInstall(executor, secretProtector, input) {
|
|
19
|
+
return withTransaction(executor, async (tx) => {
|
|
20
|
+
await userRequireServerAdmin(tx, input.actorUserId);
|
|
21
|
+
const [existing] = await tx
|
|
22
|
+
.select({ id: plugins.id, manifestJson: plugins.manifestJson })
|
|
23
|
+
.from(plugins)
|
|
24
|
+
.where(and(eq(plugins.sourceKind, input.plugin.source.kind), eq(plugins.sourceReference, input.plugin.source.reference)))
|
|
25
|
+
.limit(1);
|
|
26
|
+
let pluginId;
|
|
27
|
+
let manifest;
|
|
28
|
+
let pluginCreated = false;
|
|
29
|
+
if (existing) {
|
|
30
|
+
pluginId = existing.id;
|
|
31
|
+
manifest = installedManifest(existing.manifestJson);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
if (!input.candidate)
|
|
35
|
+
throw new Error("A new system plugin requires a persisted package candidate");
|
|
36
|
+
pluginId = input.candidate.pluginId;
|
|
37
|
+
manifest = input.plugin.manifest;
|
|
38
|
+
await tx.insert(plugins).values({
|
|
39
|
+
id: pluginId,
|
|
40
|
+
displayName: manifest.displayName,
|
|
41
|
+
shortName: manifest.shortName,
|
|
42
|
+
description: manifest.description,
|
|
43
|
+
sourceKind: input.plugin.source.kind,
|
|
44
|
+
sourceReference: input.plugin.source.reference,
|
|
45
|
+
sourceVersion: manifest.version,
|
|
46
|
+
packageDigest: input.plugin.packageDigest,
|
|
47
|
+
manifestJson: JSON.stringify(manifest),
|
|
48
|
+
packageDirectory: input.candidate.packageDirectory,
|
|
49
|
+
imageStorageKey: input.candidate.imageStorageKey,
|
|
50
|
+
imageContentType: input.plugin.image.contentType,
|
|
51
|
+
imageSize: input.plugin.image.size,
|
|
52
|
+
imageWidth: input.plugin.image.width,
|
|
53
|
+
imageHeight: input.plugin.image.height,
|
|
54
|
+
imageThumbhash: input.plugin.image.thumbhash,
|
|
55
|
+
imageChecksumSha256: input.plugin.image.checksumSha256,
|
|
56
|
+
installedByUserId: input.actorUserId,
|
|
57
|
+
});
|
|
58
|
+
pluginCreated = true;
|
|
59
|
+
}
|
|
60
|
+
const definitions = manifest.variables;
|
|
61
|
+
const mcp = manifest.mcp;
|
|
62
|
+
validateVariables(definitions, input.variables);
|
|
63
|
+
const selectionRequired = mcp?.type === "stdio" && !mcp.container;
|
|
64
|
+
if (selectionRequired && !input.containerImageId)
|
|
65
|
+
throw new PluginError("broken_configuration", "containerImageId is required for this stdio MCP plugin");
|
|
66
|
+
if (!selectionRequired && input.containerImageId)
|
|
67
|
+
throw new PluginError("broken_configuration", "containerImageId is not accepted for this plugin");
|
|
68
|
+
if (input.containerImageId) {
|
|
69
|
+
const [image] = await tx
|
|
70
|
+
.select({ id: agentImages.id })
|
|
71
|
+
.from(agentImages)
|
|
72
|
+
.where(and(eq(agentImages.id, input.containerImageId), eq(agentImages.status, "ready")))
|
|
73
|
+
.limit(1);
|
|
74
|
+
if (!image)
|
|
75
|
+
throw new PluginError("broken_configuration", "The selected container image does not exist or is not ready");
|
|
76
|
+
}
|
|
77
|
+
const id = input.installationId;
|
|
78
|
+
const status = mcp ? "preparing" : "ready";
|
|
79
|
+
const [created] = await tx
|
|
80
|
+
.insert(pluginInstallations)
|
|
81
|
+
.values({
|
|
82
|
+
id,
|
|
83
|
+
pluginId,
|
|
84
|
+
containerImageId: input.containerImageId,
|
|
85
|
+
containerName: mcp?.type === "stdio" ? `happy2-plugin-${id}` : null,
|
|
86
|
+
status,
|
|
87
|
+
statusDetail: mcp
|
|
88
|
+
? "Plugin runtime is queued for preparation."
|
|
89
|
+
: "Plugin skills are installed.",
|
|
90
|
+
installedByUserId: input.actorUserId,
|
|
91
|
+
readyAt: mcp ? null : new Date().toISOString(),
|
|
92
|
+
})
|
|
93
|
+
.returning({ id: pluginInstallations.id });
|
|
94
|
+
if (!created)
|
|
95
|
+
throw new Error("Plugin installation was not created");
|
|
96
|
+
for (const definition of definitions) {
|
|
97
|
+
const value = input.variables[definition.key];
|
|
98
|
+
await tx.insert(pluginInstallationVariables).values({
|
|
99
|
+
installationId: id,
|
|
100
|
+
key: definition.key,
|
|
101
|
+
kind: definition.kind,
|
|
102
|
+
...(definition.kind === "secret"
|
|
103
|
+
? {
|
|
104
|
+
secretCiphertext: await secretProtector.protect(value, {
|
|
105
|
+
installationId: id,
|
|
106
|
+
key: definition.key,
|
|
107
|
+
}),
|
|
108
|
+
}
|
|
109
|
+
: { textValue: value }),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
await chatAppendAudit(tx, {
|
|
113
|
+
actorUserId: input.actorUserId,
|
|
114
|
+
action: "plugin.installed",
|
|
115
|
+
targetType: "plugin_installation",
|
|
116
|
+
targetId: id,
|
|
117
|
+
after: {
|
|
118
|
+
pluginId,
|
|
119
|
+
shortName: manifest.shortName,
|
|
120
|
+
version: manifest.version,
|
|
121
|
+
mcpType: mcp?.type,
|
|
122
|
+
variableKeys: definitions.map(({ key }) => key),
|
|
123
|
+
containerImageId: input.containerImageId,
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
const sequence = await syncSequenceNext(tx);
|
|
127
|
+
if (pluginCreated)
|
|
128
|
+
await tx
|
|
129
|
+
.update(plugins)
|
|
130
|
+
.set({ syncSequence: sequence })
|
|
131
|
+
.where(eq(plugins.id, pluginId));
|
|
132
|
+
const [updated] = await tx
|
|
133
|
+
.update(pluginInstallations)
|
|
134
|
+
.set({ syncSequence: sequence })
|
|
135
|
+
.where(eq(pluginInstallations.id, id))
|
|
136
|
+
.returning({ id: pluginInstallations.id });
|
|
137
|
+
if (!updated)
|
|
138
|
+
throw new Error("Plugin installation was not updated");
|
|
139
|
+
await syncEventInsert(tx, {
|
|
140
|
+
sequence,
|
|
141
|
+
kind: "plugin.installed",
|
|
142
|
+
entityId: id,
|
|
143
|
+
actorUserId: input.actorUserId,
|
|
144
|
+
});
|
|
145
|
+
const [projection] = await tx
|
|
146
|
+
.select(pluginInstallationSelection)
|
|
147
|
+
.from(pluginInstallations)
|
|
148
|
+
.innerJoin(plugins, eq(pluginInstallations.pluginId, plugins.id))
|
|
149
|
+
.where(eq(pluginInstallations.id, id))
|
|
150
|
+
.limit(1);
|
|
151
|
+
if (!projection)
|
|
152
|
+
throw new Error("Plugin installation projection was not found");
|
|
153
|
+
return {
|
|
154
|
+
hint: areaHint(sequence, "plugins"),
|
|
155
|
+
installation: asPluginInstallation(projection),
|
|
156
|
+
pluginCreated,
|
|
157
|
+
pluginId,
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function validateVariables(definitions, values) {
|
|
162
|
+
const expected = new Set(definitions.map(({ key }) => key));
|
|
163
|
+
const unexpected = Object.keys(values).find((key) => !expected.has(key));
|
|
164
|
+
if (unexpected)
|
|
165
|
+
throw new PluginError("broken_configuration", `Unexpected plugin variable ${unexpected}`);
|
|
166
|
+
for (const definition of definitions) {
|
|
167
|
+
const value = values[definition.key];
|
|
168
|
+
if (typeof value !== "string" ||
|
|
169
|
+
!value ||
|
|
170
|
+
value.includes("\u0000") ||
|
|
171
|
+
Buffer.byteLength(value, "utf8") > MAX_VARIABLE_BYTES)
|
|
172
|
+
throw new PluginError("broken_configuration", `${definition.key} must be a valid environment value between 1 byte and 64 KiB`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=pluginInstall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginInstall.js","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginInstall.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACH,WAAW,EACX,mBAAmB,EACnB,2BAA2B,EAC3B,OAAO,GACV,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,OAAO,EACH,WAAW,GAId,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,MAAM,kBAAkB,GAAG,EAAE,GAAG,IAAI,CAAC;AAQrC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAC/B,QAAyB,EACzB,eAAsC,EACtC,KAOC;IAOD,OAAO,eAAe,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;QAC1C,MAAM,sBAAsB,CAAC,EA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AC;AACP,CAAC;AAED,SAAS,iBAAiB,CACtB,WAAwC,EACxC,MAAwC;IAExC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACzE,IAAI,UAAU;QACV,MAAM,IAAI,WAAW,CAAC,sBAAsB,EAAE,8BAA8B,UAAU,EAAE,CAAC,CAAC;IAC9F,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;QACrC,IACI,OAAO,KAAK,KAAK,QAAQ;YACzB,CAAC,KAAK;YACN,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACxB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,kBAAkB;YAErD,MAAM,IAAI,WAAW,CACjB,sBAAsB,EACtB,GAAG,UAAU,CAAC,GAAG,8DAA8D,CAClF,CAAC;IACV,CAAC;AACL,CAAC"}
|
package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DrizzleExecutor } from "../drizzle.js";
|
|
2
|
+
import type { PluginSecretProtector } from "./secrets.js";
|
|
3
|
+
import { type PluginRuntimeConfiguration } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Resolves one installed manifest into its private runtime configuration, revealing encrypted values only for process environment or remote header materialization.
|
|
6
|
+
* This read-only boundary does not mutate durable state and keeps secret recovery out of routes, catalog projections, and lifecycle orchestration.
|
|
7
|
+
*/
|
|
8
|
+
export declare function pluginInstallationGetRuntimeConfiguration(executor: DrizzleExecutor, secretProtector: PluginSecretProtector, installationId: string): Promise<PluginRuntimeConfiguration>;
|
|
9
|
+
//# sourceMappingURL=pluginInstallationGetRuntimeConfiguration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginInstallationGetRuntimeConfiguration.d.ts","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginInstallationGetRuntimeConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAe,KAAK,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAG1E;;;GAGG;AACH,wBAAsB,yCAAyC,CAC3D,QAAQ,EAAE,eAAe,EACzB,eAAe,EAAE,qBAAqB,EACtC,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,0BAA0B,CAAC,CA0HrC"}
|
package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { agentImages, pluginInstallations, pluginInstallationVariables, plugins, } from "../schema.js";
|
|
3
|
+
import { PluginError } from "./types.js";
|
|
4
|
+
import { installedManifest } from "./impl/installedManifest.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resolves one installed manifest into its private runtime configuration, revealing encrypted values only for process environment or remote header materialization.
|
|
7
|
+
* This read-only boundary does not mutate durable state and keeps secret recovery out of routes, catalog projections, and lifecycle orchestration.
|
|
8
|
+
*/
|
|
9
|
+
export async function pluginInstallationGetRuntimeConfiguration(executor, secretProtector, installationId) {
|
|
10
|
+
const [row] = await executor
|
|
11
|
+
.select({
|
|
12
|
+
id: pluginInstallations.id,
|
|
13
|
+
pluginId: plugins.id,
|
|
14
|
+
shortName: plugins.shortName,
|
|
15
|
+
manifestJson: plugins.manifestJson,
|
|
16
|
+
packageDigest: plugins.packageDigest,
|
|
17
|
+
packageDirectory: plugins.packageDirectory,
|
|
18
|
+
containerName: pluginInstallations.containerName,
|
|
19
|
+
containerImageId: pluginInstallations.containerImageId,
|
|
20
|
+
selectedImageTag: agentImages.dockerTag,
|
|
21
|
+
selectedImageStatus: agentImages.status,
|
|
22
|
+
})
|
|
23
|
+
.from(pluginInstallations)
|
|
24
|
+
.innerJoin(plugins, eq(pluginInstallations.pluginId, plugins.id))
|
|
25
|
+
.leftJoin(agentImages, eq(agentImages.id, pluginInstallations.containerImageId))
|
|
26
|
+
.where(eq(pluginInstallations.id, installationId))
|
|
27
|
+
.limit(1);
|
|
28
|
+
if (!row)
|
|
29
|
+
throw new PluginError("not_found", "Plugin installation was not found");
|
|
30
|
+
const manifest = installedManifest(row.manifestJson);
|
|
31
|
+
const installedPackage = {
|
|
32
|
+
installationId: row.id,
|
|
33
|
+
pluginId: row.pluginId,
|
|
34
|
+
shortName: row.shortName,
|
|
35
|
+
packageDirectory: row.packageDirectory,
|
|
36
|
+
packageDigest: row.packageDigest,
|
|
37
|
+
};
|
|
38
|
+
if (!manifest.mcp)
|
|
39
|
+
return { ...installedPackage, type: "skills_only" };
|
|
40
|
+
const variableRows = await executor
|
|
41
|
+
.select({
|
|
42
|
+
key: pluginInstallationVariables.key,
|
|
43
|
+
kind: pluginInstallationVariables.kind,
|
|
44
|
+
textValue: pluginInstallationVariables.textValue,
|
|
45
|
+
secretCiphertext: pluginInstallationVariables.secretCiphertext,
|
|
46
|
+
})
|
|
47
|
+
.from(pluginInstallationVariables)
|
|
48
|
+
.where(eq(pluginInstallationVariables.installationId, installationId));
|
|
49
|
+
const environment = {};
|
|
50
|
+
for (const definition of manifest.variables) {
|
|
51
|
+
const variable = variableRows.find(({ key }) => key === definition.key);
|
|
52
|
+
if (!variable || variable.kind !== definition.kind)
|
|
53
|
+
throw new PluginError("broken_configuration", `Plugin variable ${definition.key} is missing or has the wrong kind`);
|
|
54
|
+
if (definition.kind === "secret") {
|
|
55
|
+
if (!variable.secretCiphertext)
|
|
56
|
+
throw new PluginError("broken_configuration", `Plugin secret ${definition.key} is missing`);
|
|
57
|
+
try {
|
|
58
|
+
environment[definition.key] = await secretProtector.reveal(variable.secretCiphertext, { installationId, key: definition.key });
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
throw new PluginError("broken_configuration", `Plugin secret ${definition.key} cannot be decrypted`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (!variable.textValue)
|
|
66
|
+
throw new PluginError("broken_configuration", `Plugin variable ${definition.key} is missing`);
|
|
67
|
+
environment[definition.key] = variable.textValue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (manifest.mcp.type === "remote") {
|
|
71
|
+
const headers = Object.fromEntries(Object.entries(manifest.mcp.headers).map(([key, template]) => [
|
|
72
|
+
key,
|
|
73
|
+
template.replace(/\$\{([^}]+)\}/g, (_match, variable) => {
|
|
74
|
+
const value = environment[variable];
|
|
75
|
+
if (value === undefined)
|
|
76
|
+
throw new PluginError("broken_configuration", `Remote MCP header references missing variable ${variable}`);
|
|
77
|
+
return value;
|
|
78
|
+
}),
|
|
79
|
+
]));
|
|
80
|
+
if (Object.values(headers).some((value) => /\r|\n/.test(value)))
|
|
81
|
+
throw new PluginError("broken_configuration", "Resolved remote MCP headers may not contain newlines");
|
|
82
|
+
return {
|
|
83
|
+
...installedPackage,
|
|
84
|
+
type: "remote",
|
|
85
|
+
url: manifest.mcp.url,
|
|
86
|
+
headers,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (!row.containerName)
|
|
90
|
+
throw new PluginError("broken_configuration", "Plugin container name is missing");
|
|
91
|
+
let imageTag;
|
|
92
|
+
if (manifest.mcp.container) {
|
|
93
|
+
imageTag = `happy2-plugin:${row.packageDigest.replace(/^sha256:/, "")}`;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (!row.containerImageId || !row.selectedImageTag || row.selectedImageStatus !== "ready")
|
|
97
|
+
throw new PluginError("broken_configuration", "Selected plugin container image is missing or not ready");
|
|
98
|
+
imageTag = row.selectedImageTag;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
...installedPackage,
|
|
102
|
+
type: "stdio",
|
|
103
|
+
command: manifest.mcp.command,
|
|
104
|
+
args: manifest.mcp.args,
|
|
105
|
+
environment,
|
|
106
|
+
containerName: row.containerName,
|
|
107
|
+
imageTag,
|
|
108
|
+
...(manifest.mcp.container ? { bundledDockerfile: manifest.mcp.container.dockerfile } : {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=pluginInstallationGetRuntimeConfiguration.js.map
|
package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginInstallationGetRuntimeConfiguration.js","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginInstallationGetRuntimeConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EACH,WAAW,EACX,mBAAmB,EACnB,2BAA2B,EAC3B,OAAO,GACV,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAAmC,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yCAAyC,CAC3D,QAAyB,EACzB,eAAsC,EACtC,cAAsB;IAEtB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,QAAQ;SACvB,MAAM,CAAC;QACJ,EAAE,EAAE,mBAAmB,CAAC,EAAE;QAC1B,QAAQ,EAAE,OAAO,CAAC,EAAE;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,YAAY,EAAE,OAAO,CAAC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Q,GAAG,iBAAiB,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC;IAC5E,CAAC;SAAM,CAAC;QACJ,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAI,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC,mBAAmB,KAAK,OAAO;YACrF,MAAM,IAAI,WAAW,CACjB,sBAAsB,EACtB,yDAAyD,CAC5D,CAAC;QACN,QAAQ,GAAG,GAAG,CAAC,gBAAgB,CAAC;IACpC,CAAC;IACD,OAAO;QACH,GAAG,gBAAgB;QACnB,IAAI,EAAE,OAAO;QACb,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO;QAC7B,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;QACvB,WAAW;QACX,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,QAAQ;QACR,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9F,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DrizzleExecutor } from "../drizzle.js";
|
|
2
|
+
import { type PluginInstallationStatus } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Returns the current status and identity needed to authorize one installed plugin MCP connection without exposing its configuration.
|
|
5
|
+
* This read-only lookup does not mutate durable state and keeps MCP readiness enforcement at the installation boundary.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pluginInstallationGetStatus(executor: DrizzleExecutor, installationId: string): Promise<{
|
|
8
|
+
id: string;
|
|
9
|
+
status: PluginInstallationStatus;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=pluginInstallationGetStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginInstallationGetStatus.d.ts","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginInstallationGetStatus.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAe,KAAK,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAExE;;;GAGG;AACH,wBAAsB,2BAA2B,CAC7C,QAAQ,EAAE,eAAe,EACzB,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,wBAAwB,CAAA;CAAE,CAAC,CAQ3D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { eq } from "drizzle-orm";
|
|
2
|
+
import { pluginInstallations } from "../schema.js";
|
|
3
|
+
import { PluginError } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the current status and identity needed to authorize one installed plugin MCP connection without exposing its configuration.
|
|
6
|
+
* This read-only lookup does not mutate durable state and keeps MCP readiness enforcement at the installation boundary.
|
|
7
|
+
*/
|
|
8
|
+
export async function pluginInstallationGetStatus(executor, installationId) {
|
|
9
|
+
const [row] = await executor
|
|
10
|
+
.select({ id: pluginInstallations.id, status: pluginInstallations.status })
|
|
11
|
+
.from(pluginInstallations)
|
|
12
|
+
.where(eq(pluginInstallations.id, installationId))
|
|
13
|
+
.limit(1);
|
|
14
|
+
if (!row)
|
|
15
|
+
throw new PluginError("not_found", "Plugin installation was not found");
|
|
16
|
+
return { id: row.id, status: row.status };
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=pluginInstallationGetStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginInstallationGetStatus.js","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginInstallationGetStatus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,WAAW,EAAiC,MAAM,YAAY,CAAC;AAExE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC7C,QAAyB,EACzB,cAAsB;IAEtB,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,QAAQ;SACvB,MAAM,CAAC,EAAE,EAAE,EAAE,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,CAAC;SAC1E,IAAI,CAAC,mBAAmB,CAAC;SACzB,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;SACjD,KAAK,CAAC,CAAC,CAAC,CAAC;IACd,IAAI,CAAC,GAAG;QAAE,MAAM,IAAI,WAAW,CAAC,WAAW,EAAE,mCAAmC,CAAC,CAAC;IAClF,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAkC,EAAE,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DrizzleExecutor } from "../drizzle.js";
|
|
2
|
+
import type { PluginInstallationSummary } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Lists durable system plugin installations and their latest lifecycle state for an active server administrator.
|
|
5
|
+
* This read-only action does not mutate durable state and centralizes authorization before installation health is joined into the catalog.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pluginInstallationList(executor: DrizzleExecutor, actorUserId: string): Promise<PluginInstallationSummary[]>;
|
|
8
|
+
//# sourceMappingURL=pluginInstallationList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pluginInstallationList.d.ts","sourceRoot":"","sources":["../../../sources/modules/plugin/pluginInstallationList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AAI5D;;;GAGG;AACH,wBAAsB,sBAAsB,CACxC,QAAQ,EAAE,eAAe,EACzB,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,yBAAyB,EAAE,CAAC,CAQtC"}
|