happy2 0.0.12 → 0.0.14
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/package.json +2 -2
- package/packages/happy2-server/PLUGINS.md +281 -39
- package/packages/happy2-server/README.md +8 -7
- package/packages/happy2-server/dist/index.d.ts +3 -1
- package/packages/happy2-server/dist/index.d.ts.map +1 -1
- package/packages/happy2-server/dist/index.js +2 -0
- package/packages/happy2-server/dist/index.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentChatBind.d.ts +1 -0
- package/packages/happy2-server/dist/modules/agent/agentChatBind.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentChatBind.js +4 -0
- package/packages/happy2-server/dist/modules/agent/agentChatBind.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentChatGetContext.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentChatGetContext.js +3 -1
- package/packages/happy2-server/dist/modules/agent/agentChatGetContext.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentCreate.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentCreate.js +1 -0
- package/packages/happy2-server/dist/modules/agent/agentCreate.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentEffortBindingList.d.ts +4 -2
- package/packages/happy2-server/dist/modules/agent/agentEffortBindingList.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentEffortBindingList.js +8 -8
- package/packages/happy2-server/dist/modules/agent/agentEffortBindingList.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentEffortGetContext.d.ts +3 -3
- package/packages/happy2-server/dist/modules/agent/agentEffortGetContext.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentEffortGetContext.js +4 -4
- package/packages/happy2-server/dist/modules/agent/agentEffortGetContext.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentEffortUpdate.d.ts +4 -4
- package/packages/happy2-server/dist/modules/agent/agentEffortUpdate.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentEffortUpdate.js +57 -41
- package/packages/happy2-server/dist/modules/agent/agentEffortUpdate.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageCommitChange.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageCommitChange.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentImageCommitChange.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageCreate.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageCreate.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentImageCreate.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageGet.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageGet.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentImageGet.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageGetChangeContext.d.ts +2 -1
- package/packages/happy2-server/dist/modules/agent/agentImageGetChangeContext.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageGetChangeContext.js +11 -4
- package/packages/happy2-server/dist/modules/agent/agentImageGetChangeContext.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageList.d.ts +2 -2
- package/packages/happy2-server/dist/modules/agent/agentImageList.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageList.js +8 -4
- package/packages/happy2-server/dist/modules/agent/agentImageList.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageRequestBuild.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageRequestBuild.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentImageRequestBuild.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageSetDefault.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentImageSetDefault.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentImageSetDefault.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAssignmentDelete.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAssignmentDelete.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentSecretAssignmentDelete.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAssignmentList.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAssignmentList.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentSecretAssignmentList.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAttachToAgent.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAttachToAgent.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentSecretAttachToAgent.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAttachToChannel.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAttachToChannel.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentSecretAttachToChannel.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAuthorizeManagement.d.ts +4 -3
- package/packages/happy2-server/dist/modules/agent/agentSecretAuthorizeManagement.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretAuthorizeManagement.js +5 -5
- package/packages/happy2-server/dist/modules/agent/agentSecretAuthorizeManagement.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretDetachFromAgent.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretDetachFromAgent.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentSecretDetachFromAgent.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretDetachFromChannel.d.ts +2 -2
- package/packages/happy2-server/dist/modules/agent/agentSecretDetachFromChannel.js +4 -4
- package/packages/happy2-server/dist/modules/agent/agentSecretDetachFromChannel.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretRecordRegistration.d.ts +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSecretRecordRegistration.js +3 -3
- package/packages/happy2-server/dist/modules/agent/agentSecretRecordRegistration.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.d.ts +4 -0
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.js +15 -0
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.js.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.js +17 -0
- package/packages/happy2-server/dist/modules/agent/agentSkillHomeGet.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.d.ts +23 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.js +70 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnGetPluginContext.js.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnStreamReply.d.ts +4 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnStreamReply.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentTurnStreamReply.js +207 -9
- package/packages/happy2-server/dist/modules/agent/agentTurnStreamReply.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceGet.d.ts +8 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceGet.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceGet.js +86 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceGet.js.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceStart.d.ts +19 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceStart.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceStart.js +87 -0
- package/packages/happy2-server/dist/modules/agent/agentTurnTraceStart.js.map +1 -0
- package/packages/happy2-server/dist/modules/agent/impl/agentChatContext.d.ts +2 -1
- package/packages/happy2-server/dist/modules/agent/impl/agentChatContext.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/impl/agentEffortContext.d.ts +4 -1
- package/packages/happy2-server/dist/modules/agent/impl/agentEffortContext.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/impl/agentEffortContextDb.d.ts +3 -3
- package/packages/happy2-server/dist/modules/agent/impl/agentEffortContextDb.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/impl/agentEffortContextDb.js +26 -40
- package/packages/happy2-server/dist/modules/agent/impl/agentEffortContextDb.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/impl/finishAgentTurn.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agent/impl/finishAgentTurn.js +63 -2
- package/packages/happy2-server/dist/modules/agent/impl/finishAgentTurn.js.map +1 -1
- package/packages/happy2-server/dist/modules/agent/types.d.ts +53 -0
- package/packages/happy2-server/dist/modules/agent/types.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agents/daemon.d.ts +31 -2
- package/packages/happy2-server/dist/modules/agents/daemon.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agents/daemon.js +12 -2
- package/packages/happy2-server/dist/modules/agents/daemon.js.map +1 -1
- package/packages/happy2-server/dist/modules/agents/service.d.ts +11 -6
- package/packages/happy2-server/dist/modules/agents/service.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/agents/service.js +498 -50
- package/packages/happy2-server/dist/modules/agents/service.js.map +1 -1
- package/packages/happy2-server/dist/modules/auth/developmentTokenCreate.d.ts +12 -0
- package/packages/happy2-server/dist/modules/auth/developmentTokenCreate.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/auth/developmentTokenCreate.js +27 -0
- package/packages/happy2-server/dist/modules/auth/developmentTokenCreate.js.map +1 -0
- package/packages/happy2-server/dist/modules/auth/developmentTokenFindActive.d.ts +8 -0
- package/packages/happy2-server/dist/modules/auth/developmentTokenFindActive.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/auth/developmentTokenFindActive.js +22 -0
- package/packages/happy2-server/dist/modules/auth/developmentTokenFindActive.js.map +1 -0
- package/packages/happy2-server/dist/modules/auth/methods.d.ts +1 -0
- package/packages/happy2-server/dist/modules/auth/methods.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/auth/methods.js +10 -6
- package/packages/happy2-server/dist/modules/auth/methods.js.map +1 -1
- package/packages/happy2-server/dist/modules/auth/service.d.ts +2 -0
- package/packages/happy2-server/dist/modules/auth/service.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/auth/service.js +26 -0
- package/packages/happy2-server/dist/modules/auth/service.js.map +1 -1
- package/packages/happy2-server/dist/modules/auth/tokens.d.ts +21 -0
- package/packages/happy2-server/dist/modules/auth/tokens.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/auth/tokens.js +97 -3
- package/packages/happy2-server/dist/modules/auth/tokens.js.map +1 -1
- package/packages/happy2-server/dist/modules/auth/tokens.test.js +77 -0
- package/packages/happy2-server/dist/modules/auth/tokens.test.js.map +1 -1
- package/packages/happy2-server/dist/modules/chat/asAgentTurnTrace.d.ts +17 -0
- package/packages/happy2-server/dist/modules/chat/asAgentTurnTrace.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/chat/asAgentTurnTrace.js +98 -0
- package/packages/happy2-server/dist/modules/chat/asAgentTurnTrace.js.map +1 -0
- package/packages/happy2-server/dist/modules/chat/asServiceMessage.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/chat/asServiceMessage.js +13 -5
- package/packages/happy2-server/dist/modules/chat/asServiceMessage.js.map +1 -1
- package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.d.ts +19 -0
- package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.js +87 -0
- package/packages/happy2-server/dist/modules/chat/channelCreateWithMembers.js.map +1 -0
- package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.d.ts +15 -0
- package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.js +38 -0
- package/packages/happy2-server/dist/modules/chat/channelMembersUpdate.js.map +1 -0
- package/packages/happy2-server/dist/modules/chat/chatAppendAudit.d.ts +1 -1
- package/packages/happy2-server/dist/modules/chat/chatAppendAudit.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/chat/chatUpdateMetadata.d.ts +20 -0
- package/packages/happy2-server/dist/modules/chat/chatUpdateMetadata.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/chat/chatUpdateMetadata.js +38 -0
- package/packages/happy2-server/dist/modules/chat/chatUpdateMetadata.js.map +1 -0
- package/packages/happy2-server/dist/modules/chat/types.d.ts +6 -0
- package/packages/happy2-server/dist/modules/chat/types.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/chat/types.js.map +1 -1
- package/packages/happy2-server/dist/modules/chat/userRequireActiveHuman.d.ts +7 -0
- package/packages/happy2-server/dist/modules/chat/userRequireActiveHuman.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/chat/userRequireActiveHuman.js +19 -0
- package/packages/happy2-server/dist/modules/chat/userRequireActiveHuman.js.map +1 -0
- package/packages/happy2-server/dist/modules/chat/userRequireServerAdmin.d.ts +2 -2
- package/packages/happy2-server/dist/modules/chat/userRequireServerAdmin.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/chat/userRequireServerAdmin.js +8 -5
- package/packages/happy2-server/dist/modules/chat/userRequireServerAdmin.js.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 +1 -0
- package/packages/happy2-server/dist/modules/config/defaults.js.map +1 -1
- package/packages/happy2-server/dist/modules/config/defaults.test.js +1 -0
- package/packages/happy2-server/dist/modules/config/defaults.test.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/loader.test.js +12 -0
- package/packages/happy2-server/dist/modules/config/loader.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/message/messageGetProjection.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/message/messageGetProjection.js +28 -0
- package/packages/happy2-server/dist/modules/message/messageGetProjection.js.map +1 -1
- package/packages/happy2-server/dist/modules/permission/impl/permissionEffectiveDb.d.ts +4 -0
- package/packages/happy2-server/dist/modules/permission/impl/permissionEffectiveDb.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/impl/permissionEffectiveDb.js +39 -0
- package/packages/happy2-server/dist/modules/permission/impl/permissionEffectiveDb.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/impl/permissionMutationRecord.d.ts +10 -0
- package/packages/happy2-server/dist/modules/permission/impl/permissionMutationRecord.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/impl/permissionMutationRecord.js +31 -0
- package/packages/happy2-server/dist/modules/permission/impl/permissionMutationRecord.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/permissionGetEffective.d.ts +8 -0
- package/packages/happy2-server/dist/modules/permission/permissionGetEffective.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/permissionGetEffective.js +13 -0
- package/packages/happy2-server/dist/modules/permission/permissionGetEffective.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleCreate.d.ts +16 -0
- package/packages/happy2-server/dist/modules/permission/roleCreate.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleCreate.js +70 -0
- package/packages/happy2-server/dist/modules/permission/roleCreate.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleDelete.d.ts +11 -0
- package/packages/happy2-server/dist/modules/permission/roleDelete.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleDelete.js +41 -0
- package/packages/happy2-server/dist/modules/permission/roleDelete.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleList.d.ts +8 -0
- package/packages/happy2-server/dist/modules/permission/roleList.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleList.js +36 -0
- package/packages/happy2-server/dist/modules/permission/roleList.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleUpdate.d.ts +14 -0
- package/packages/happy2-server/dist/modules/permission/roleUpdate.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/roleUpdate.js +78 -0
- package/packages/happy2-server/dist/modules/permission/roleUpdate.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/types.d.ts +24 -0
- package/packages/happy2-server/dist/modules/permission/types.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/types.js +10 -0
- package/packages/happy2-server/dist/modules/permission/types.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionGet.d.ts +16 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionGet.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionGet.js +33 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionGet.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionUpdate.d.ts +12 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionUpdate.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionUpdate.js +44 -0
- package/packages/happy2-server/dist/modules/permission/userPermissionUpdate.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRequireAnyPermission.d.ts +8 -0
- package/packages/happy2-server/dist/modules/permission/userRequireAnyPermission.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRequireAnyPermission.js +12 -0
- package/packages/happy2-server/dist/modules/permission/userRequireAnyPermission.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRequirePermission.d.ts +8 -0
- package/packages/happy2-server/dist/modules/permission/userRequirePermission.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRequirePermission.js +12 -0
- package/packages/happy2-server/dist/modules/permission/userRequirePermission.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRoleAssign.d.ts +12 -0
- package/packages/happy2-server/dist/modules/permission/userRoleAssign.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRoleAssign.js +46 -0
- package/packages/happy2-server/dist/modules/permission/userRoleAssign.js.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRoleUnassign.d.ts +12 -0
- package/packages/happy2-server/dist/modules/permission/userRoleUnassign.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/permission/userRoleUnassign.js +53 -0
- package/packages/happy2-server/dist/modules/permission/userRoleUnassign.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/archive.d.ts +7 -0
- package/packages/happy2-server/dist/modules/plugin/archive.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/archive.js +222 -0
- package/packages/happy2-server/dist/modules/plugin/archive.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/catalog.d.ts +5 -1
- package/packages/happy2-server/dist/modules/plugin/catalog.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/catalog.js +35 -16
- package/packages/happy2-server/dist/modules/plugin/catalog.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/catalog.test.js +6 -2
- package/packages/happy2-server/dist/modules/plugin/catalog.test.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/httpBridge.d.ts +1 -0
- package/packages/happy2-server/dist/modules/plugin/httpBridge.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/httpBridge.js +7 -0
- package/packages/happy2-server/dist/modules/plugin/httpBridge.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.d.ts +5 -0
- package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.js +106 -0
- package/packages/happy2-server/dist/modules/plugin/impl/apiPermissions.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.js +12 -2
- package/packages/happy2-server/dist/modules/plugin/impl/asInstallation.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.d.ts +3 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.js +68 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asManagementRequest.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.js +12 -3
- package/packages/happy2-server/dist/modules/plugin/impl/asPlugin.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.d.ts +19 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.js +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installationSelection.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.js +4 -2
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.js +14 -0
- package/packages/happy2-server/dist/modules/plugin/impl/installedManifest.test.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.d.ts +345 -0
- package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.js +22 -0
- package/packages/happy2-server/dist/modules/plugin/impl/managementRequestSelection.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSkillSource.d.ts +11 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSkillSource.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSkillSource.js +2 -0
- package/packages/happy2-server/dist/modules/plugin/impl/pluginSkillSource.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.d.ts +16 -0
- package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.js +67 -0
- package/packages/happy2-server/dist/modules/plugin/packageLinkDownloader.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.d.ts +27 -1
- package/packages/happy2-server/dist/modules/plugin/packageStore.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/packageStore.js +234 -15
- package/packages/happy2-server/dist/modules/plugin/packageStore.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/packageStore.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.test.js +50 -0
- package/packages/happy2-server/dist/modules/plugin/packageStore.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.d.ts +5 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.js +26 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAgentCallContextGet.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginAuthorizeManagement.d.ts +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginAuthorizeManagement.js +3 -3
- package/packages/happy2-server/dist/modules/plugin/pluginAuthorizeManagement.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.js +7 -3
- package/packages/happy2-server/dist/modules/plugin/pluginCatalogList.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.d.ts +2 -0
- package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.js +44 -0
- package/packages/happy2-server/dist/modules/plugin/pluginDeveloperServer.test.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.d.ts +3 -1
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.js +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginFindBySource.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginGetImage.d.ts +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginGetImage.js +3 -3
- package/packages/happy2-server/dist/modules/plugin/pluginGetImage.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginGetSource.d.ts +13 -0
- package/packages/happy2-server/dist/modules/plugin/pluginGetSource.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginGetSource.js +37 -0
- package/packages/happy2-server/dist/modules/plugin/pluginGetSource.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.d.ts +4 -2
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.js +36 -5
- package/packages/happy2-server/dist/modules/plugin/pluginInstall.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.d.ts +7 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.js +18 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetContainerName.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.d.ts +13 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.js +35 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRequestUninstallContext.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js +3 -1
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetRuntimeConfiguration.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.d.ts +6 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.js +17 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationGetUninstallContext.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationList.d.ts +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationList.js +3 -3
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationList.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.d.ts +18 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.js +92 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationPermissionsUpdate.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.d.ts +16 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.js +71 -0
- package/packages/happy2-server/dist/modules/plugin/pluginInstallationUninstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginList.d.ts +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginList.js +3 -3
- package/packages/happy2-server/dist/modules/plugin/pluginList.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.d.ts +21 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.js +71 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginInstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.d.ts +12 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.js +56 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestBeginUninstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.d.ts +11 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.js +44 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteInstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.d.ts +10 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.js +41 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCompleteUninstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.d.ts +26 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.js +78 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateInstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.d.ts +25 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.js +76 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestCreateUninstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.d.ts +11 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.js +48 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestDeny.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.d.ts +12 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.js +42 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestGetPackage.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.d.ts +5 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.js +18 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestList.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.d.ts +4 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.js +11 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestListTerminalIds.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.d.ts +5 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.js +75 -0
- package/packages/happy2-server/dist/modules/plugin/pluginManagementRequestRecoverProcessing.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.d.ts +12 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.js +33 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillPackageListReady.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListInstalled.d.ts +8 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListInstalled.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListInstalled.js +24 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListInstalled.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListReady.d.ts +8 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListReady.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListReady.js +25 -0
- package/packages/happy2-server/dist/modules/plugin/pluginSkillsListReady.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginUninstall.d.ts +13 -0
- package/packages/happy2-server/dist/modules/plugin/pluginUninstall.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/pluginUninstall.js +63 -0
- package/packages/happy2-server/dist/modules/plugin/pluginUninstall.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/runtime.d.ts +1 -0
- package/packages/happy2-server/dist/modules/plugin/runtime.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/runtime.js +1 -0
- package/packages/happy2-server/dist/modules/plugin/runtime.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/service.d.ts +157 -5
- package/packages/happy2-server/dist/modules/plugin/service.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/service.js +789 -19
- package/packages/happy2-server/dist/modules/plugin/service.js.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/source.d.ts +35 -0
- package/packages/happy2-server/dist/modules/plugin/source.d.ts.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/source.js +189 -0
- package/packages/happy2-server/dist/modules/plugin/source.js.map +1 -0
- package/packages/happy2-server/dist/modules/plugin/types.d.ts +116 -11
- package/packages/happy2-server/dist/modules/plugin/types.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/plugin/types.js +9 -0
- package/packages/happy2-server/dist/modules/plugin/types.js.map +1 -1
- package/packages/happy2-server/dist/modules/realtime/events.d.ts +3 -0
- package/packages/happy2-server/dist/modules/realtime/events.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/realtime/events.js +37 -5
- package/packages/happy2-server/dist/modules/realtime/events.js.map +1 -1
- package/packages/happy2-server/dist/modules/realtime/local.test.js +2 -0
- package/packages/happy2-server/dist/modules/realtime/local.test.js.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.js +4 -2
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.js.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.test.js +4 -1
- package/packages/happy2-server/dist/modules/sandbox/localOciSandboxProvider.test.js.map +1 -1
- package/packages/happy2-server/dist/modules/sandbox/types.d.ts +1 -0
- package/packages/happy2-server/dist/modules/sandbox/types.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/schema.d.ts +8024 -5446
- package/packages/happy2-server/dist/modules/schema.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/schema.js +140 -0
- 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/modules/user/userAdministrationList.js +2 -2
- package/packages/happy2-server/dist/modules/user/userAdministrationList.js.map +1 -1
- package/packages/happy2-server/dist/modules/user/userAdministrationUpdate.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/user/userAdministrationUpdate.js +49 -6
- package/packages/happy2-server/dist/modules/user/userAdministrationUpdate.js.map +1 -1
- package/packages/happy2-server/dist/modules/user/userCreateProfile.d.ts.map +1 -1
- package/packages/happy2-server/dist/modules/user/userCreateProfile.js +17 -2
- package/packages/happy2-server/dist/modules/user/userCreateProfile.js.map +1 -1
- package/packages/happy2-server/dist/routes/agents.d.ts.map +1 -1
- package/packages/happy2-server/dist/routes/agents.js +4 -2
- package/packages/happy2-server/dist/routes/agents.js.map +1 -1
- package/packages/happy2-server/dist/routes/auth.d.ts.map +1 -1
- package/packages/happy2-server/dist/routes/auth.js +12 -0
- package/packages/happy2-server/dist/routes/auth.js.map +1 -1
- package/packages/happy2-server/dist/routes/collaboration.d.ts.map +1 -1
- package/packages/happy2-server/dist/routes/collaboration.js +7 -0
- package/packages/happy2-server/dist/routes/collaboration.js.map +1 -1
- package/packages/happy2-server/dist/routes/files.d.ts.map +1 -1
- package/packages/happy2-server/dist/routes/files.js +2 -0
- package/packages/happy2-server/dist/routes/files.js.map +1 -1
- package/packages/happy2-server/dist/routes/permissions.d.ts +6 -0
- package/packages/happy2-server/dist/routes/permissions.d.ts.map +1 -0
- package/packages/happy2-server/dist/routes/permissions.js +207 -0
- package/packages/happy2-server/dist/routes/permissions.js.map +1 -0
- package/packages/happy2-server/dist/routes/pluginHost.d.ts +2 -1
- package/packages/happy2-server/dist/routes/pluginHost.d.ts.map +1 -1
- package/packages/happy2-server/dist/routes/pluginHost.js +356 -5
- package/packages/happy2-server/dist/routes/pluginHost.js.map +1 -1
- package/packages/happy2-server/dist/routes/plugins.d.ts.map +1 -1
- package/packages/happy2-server/dist/routes/plugins.js +375 -7
- package/packages/happy2-server/dist/routes/plugins.js.map +1 -1
- package/packages/happy2-server/dist/server.d.ts +4 -0
- package/packages/happy2-server/dist/server.d.ts.map +1 -1
- package/packages/happy2-server/dist/server.js +12 -7
- package/packages/happy2-server/dist/server.js.map +1 -1
- package/packages/happy2-server/dist/web/assets/index-Dn5SZu3y.js +39 -0
- package/packages/happy2-server/dist/web/assets/index-Dys3sWv8.css +2 -0
- package/packages/happy2-server/dist/web/index.html +2 -2
- package/packages/happy2-server/drizzle/0023_roles_and_permissions.sql +82 -0
- package/packages/happy2-server/drizzle/0024_session_bound_dev_tokens.sql +11 -0
- package/packages/happy2-server/drizzle/0025_plugin_skills.sql +8 -0
- package/packages/happy2-server/drizzle/0026_agent_turn_traces.sql +35 -0
- package/packages/happy2-server/drizzle/0027_chat_agent_effort.sql +9 -0
- package/packages/happy2-server/drizzle/0028_plugin_api_permissions.sql +1 -0
- package/packages/happy2-server/drizzle/0029_plugin_management_requests.sql +35 -0
- package/packages/happy2-server/drizzle/meta/_journal.json +49 -0
- package/packages/happy2-server/happy2.example.toml +6 -0
- package/packages/happy2-server/plugins/README.md +7 -1
- package/packages/happy2-server/plugins/chat-management/container/Dockerfile +6 -0
- package/packages/happy2-server/plugins/chat-management/plugin.json +17 -0
- package/packages/happy2-server/plugins/chat-management/plugin.png +0 -0
- package/packages/happy2-server/plugins/chat-management/server.mjs +280 -0
- package/packages/happy2-server/plugins/plugin-developer/container/Dockerfile +6 -0
- package/packages/happy2-server/plugins/plugin-developer/plugin.json +17 -0
- package/packages/happy2-server/plugins/plugin-developer/plugin.png +0 -0
- package/packages/happy2-server/plugins/plugin-developer/server.mjs +155 -0
- package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/SKILL.md +59 -0
- package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/references/host-api.md +63 -0
- package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/references/installing.md +86 -0
- package/packages/happy2-server/plugins/plugin-developer/skills/happy2-plugin-development/references/package-format.md +137 -0
- package/packages/happy2-server/dist/web/assets/index-9SGCQLg7.js +0 -46
- package/packages/happy2-server/dist/web/assets/index-DWXBQDJB.css +0 -2
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { CollaborationError } from "../modules/chat/types.js";
|
|
2
|
+
import { roleCreate } from "../modules/permission/roleCreate.js";
|
|
3
|
+
import { roleDelete } from "../modules/permission/roleDelete.js";
|
|
4
|
+
import { roleList } from "../modules/permission/roleList.js";
|
|
5
|
+
import { roleUpdate } from "../modules/permission/roleUpdate.js";
|
|
6
|
+
import { permissions, } from "../modules/permission/types.js";
|
|
7
|
+
import { userPermissionGet } from "../modules/permission/userPermissionGet.js";
|
|
8
|
+
import { userPermissionUpdate } from "../modules/permission/userPermissionUpdate.js";
|
|
9
|
+
import { userRoleAssign } from "../modules/permission/userRoleAssign.js";
|
|
10
|
+
import { userRoleUnassign } from "../modules/permission/userRoleUnassign.js";
|
|
11
|
+
import { realtimeTopics } from "../modules/realtime/index.js";
|
|
12
|
+
const MAX_ID_LENGTH = 128;
|
|
13
|
+
const MAX_ROLE_NAME_LENGTH = 100;
|
|
14
|
+
const MAX_ROLE_DESCRIPTION_LENGTH = 1_000;
|
|
15
|
+
export function registerPermissionRoutes(app, auth, executor, pubsub) {
|
|
16
|
+
app.get("/v0/admin/roles", authenticated(auth, async (_request, _reply, actorUserId) => ({
|
|
17
|
+
permissions,
|
|
18
|
+
roles: await roleList(executor, actorUserId),
|
|
19
|
+
})));
|
|
20
|
+
app.post("/v0/admin/roles/createRole", authenticated(auth, async (request, reply, actorUserId) => {
|
|
21
|
+
const body = requestBody(request, ["name", "description", "permissions"]);
|
|
22
|
+
const result = await roleCreate(executor, {
|
|
23
|
+
actorUserId,
|
|
24
|
+
name: requiredText(body, "name", MAX_ROLE_NAME_LENGTH),
|
|
25
|
+
description: optionalText(body, "description", MAX_ROLE_DESCRIPTION_LENGTH),
|
|
26
|
+
permissions: permissionList(body, "permissions"),
|
|
27
|
+
});
|
|
28
|
+
await publishPermissionMutation(request, pubsub, actorUserId, result.mutation);
|
|
29
|
+
return reply.code(201).send({ role: result.role, sync: result.mutation.sync });
|
|
30
|
+
}));
|
|
31
|
+
app.post("/v0/admin/roles/:roleId/updateRole", authenticated(auth, async (request, _reply, actorUserId) => {
|
|
32
|
+
const body = requestBody(request, ["name", "description", "permissions"]);
|
|
33
|
+
if (Object.keys(body).length === 0)
|
|
34
|
+
throw new InvalidRequest("At least one role field is required");
|
|
35
|
+
const mutation = await roleUpdate(executor, {
|
|
36
|
+
actorUserId,
|
|
37
|
+
roleId: pathId(request, "roleId"),
|
|
38
|
+
...(has(body, "name")
|
|
39
|
+
? { name: requiredText(body, "name", MAX_ROLE_NAME_LENGTH) }
|
|
40
|
+
: {}),
|
|
41
|
+
...(has(body, "description")
|
|
42
|
+
? {
|
|
43
|
+
description: body.description === null
|
|
44
|
+
? null
|
|
45
|
+
: requiredText(body, "description", MAX_ROLE_DESCRIPTION_LENGTH),
|
|
46
|
+
}
|
|
47
|
+
: {}),
|
|
48
|
+
...(has(body, "permissions")
|
|
49
|
+
? { permissions: permissionList(body, "permissions") }
|
|
50
|
+
: {}),
|
|
51
|
+
});
|
|
52
|
+
await publishPermissionMutation(request, pubsub, actorUserId, mutation);
|
|
53
|
+
return { sync: mutation.sync };
|
|
54
|
+
}));
|
|
55
|
+
app.post("/v0/admin/roles/:roleId/deleteRole", authenticated(auth, async (request, _reply, actorUserId) => {
|
|
56
|
+
emptyBody(request);
|
|
57
|
+
const mutation = await roleDelete(executor, {
|
|
58
|
+
actorUserId,
|
|
59
|
+
roleId: pathId(request, "roleId"),
|
|
60
|
+
});
|
|
61
|
+
await publishPermissionMutation(request, pubsub, actorUserId, mutation);
|
|
62
|
+
return { sync: mutation.sync };
|
|
63
|
+
}));
|
|
64
|
+
app.get("/v0/admin/users/:userId/permissions", authenticated(auth, async (request, _reply, actorUserId) => ({
|
|
65
|
+
permissions: await userPermissionGet(executor, {
|
|
66
|
+
actorUserId,
|
|
67
|
+
userId: pathId(request, "userId"),
|
|
68
|
+
}),
|
|
69
|
+
})));
|
|
70
|
+
app.post("/v0/admin/users/:userId/updatePermissions", authenticated(auth, async (request, _reply, actorUserId) => {
|
|
71
|
+
const body = requestBody(request, ["permissions"]);
|
|
72
|
+
const mutation = await userPermissionUpdate(executor, {
|
|
73
|
+
actorUserId,
|
|
74
|
+
userId: pathId(request, "userId"),
|
|
75
|
+
permissions: permissionList(body, "permissions"),
|
|
76
|
+
});
|
|
77
|
+
await publishPermissionMutation(request, pubsub, actorUserId, mutation);
|
|
78
|
+
return { sync: mutation.sync };
|
|
79
|
+
}));
|
|
80
|
+
app.post("/v0/admin/users/:userId/assignRole", authenticated(auth, async (request, _reply, actorUserId) => {
|
|
81
|
+
const body = requestBody(request, ["roleId"]);
|
|
82
|
+
const mutation = await userRoleAssign(executor, {
|
|
83
|
+
actorUserId,
|
|
84
|
+
userId: pathId(request, "userId"),
|
|
85
|
+
roleId: id(body.roleId, "roleId"),
|
|
86
|
+
});
|
|
87
|
+
await publishPermissionMutation(request, pubsub, actorUserId, mutation);
|
|
88
|
+
return { sync: mutation.sync };
|
|
89
|
+
}));
|
|
90
|
+
app.post("/v0/admin/users/:userId/unassignRole", authenticated(auth, async (request, _reply, actorUserId) => {
|
|
91
|
+
const body = requestBody(request, ["roleId"]);
|
|
92
|
+
const mutation = await userRoleUnassign(executor, {
|
|
93
|
+
actorUserId,
|
|
94
|
+
userId: pathId(request, "userId"),
|
|
95
|
+
roleId: id(body.roleId, "roleId"),
|
|
96
|
+
});
|
|
97
|
+
await publishPermissionMutation(request, pubsub, actorUserId, mutation);
|
|
98
|
+
return { sync: mutation.sync };
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
function authenticated(auth, handler) {
|
|
102
|
+
return async (request, reply) => {
|
|
103
|
+
const current = await auth.authenticate(request);
|
|
104
|
+
if (!current)
|
|
105
|
+
return reply.code(401).send({ error: "unauthorized" });
|
|
106
|
+
try {
|
|
107
|
+
return await handler(request, reply, current.user.id);
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (error instanceof InvalidRequest)
|
|
111
|
+
return reply.code(400).send({ error: "invalid_request", message: error.message });
|
|
112
|
+
if (error instanceof CollaborationError)
|
|
113
|
+
return reply
|
|
114
|
+
.code(error.code === "invalid"
|
|
115
|
+
? 400
|
|
116
|
+
: error.code === "forbidden"
|
|
117
|
+
? 403
|
|
118
|
+
: error.code === "not_found"
|
|
119
|
+
? 404
|
|
120
|
+
: 409)
|
|
121
|
+
.send({ error: error.code, message: error.message });
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async function publishPermissionMutation(request, pubsub, actorUserId, mutation) {
|
|
127
|
+
const event = { type: "sync", ...mutation.sync };
|
|
128
|
+
const topics = mutation.broadcast
|
|
129
|
+
? [realtimeTopics.server]
|
|
130
|
+
: [...new Set([actorUserId, ...mutation.affectedUserIds])].map(realtimeTopics.user);
|
|
131
|
+
const batchSize = 32;
|
|
132
|
+
for (let index = 0; index < topics.length; index += batchSize) {
|
|
133
|
+
const results = await Promise.allSettled(topics.slice(index, index + batchSize).map((topic) => pubsub.publish(topic, event)));
|
|
134
|
+
for (const result of results)
|
|
135
|
+
if (result.status === "rejected")
|
|
136
|
+
request.log.warn({ err: result.reason }, "Could not publish permission sync hint");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function requestBody(request, allowed) {
|
|
140
|
+
const body = record(request.body, "Request body");
|
|
141
|
+
const unexpected = Object.keys(body).find((key) => !allowed.includes(key));
|
|
142
|
+
if (unexpected)
|
|
143
|
+
throw new InvalidRequest(`Unexpected request body field: ${unexpected}`);
|
|
144
|
+
return body;
|
|
145
|
+
}
|
|
146
|
+
function emptyBody(request) {
|
|
147
|
+
if (request.body === undefined || request.body === null)
|
|
148
|
+
return;
|
|
149
|
+
requestBody(request, []);
|
|
150
|
+
}
|
|
151
|
+
function pathId(request, key) {
|
|
152
|
+
return id(record(request.params, "Path parameters")[key], key);
|
|
153
|
+
}
|
|
154
|
+
function permissionList(body, key) {
|
|
155
|
+
const value = body[key];
|
|
156
|
+
if (!Array.isArray(value))
|
|
157
|
+
throw new InvalidRequest(`${key} must be an array`);
|
|
158
|
+
if (new Set(value).size !== value.length)
|
|
159
|
+
throw new InvalidRequest(`${key} must not contain duplicates`);
|
|
160
|
+
for (const permission of value)
|
|
161
|
+
if (typeof permission !== "string" || !permissions.includes(permission))
|
|
162
|
+
throw new InvalidRequest(`${key} contains an unknown permission`);
|
|
163
|
+
const selected = new Set(value);
|
|
164
|
+
return permissions.filter((permission) => selected.has(permission));
|
|
165
|
+
}
|
|
166
|
+
function requiredText(body, key, maximum) {
|
|
167
|
+
const value = body[key];
|
|
168
|
+
if (typeof value !== "string")
|
|
169
|
+
throw new InvalidRequest(`${key} must be a string`);
|
|
170
|
+
const trimmed = value.trim();
|
|
171
|
+
if (!trimmed || trimmed.length > maximum || hasControlCharacters(trimmed))
|
|
172
|
+
throw new InvalidRequest(`${key} must be between 1 and ${maximum} safe characters`);
|
|
173
|
+
return trimmed;
|
|
174
|
+
}
|
|
175
|
+
function optionalText(body, key, maximum) {
|
|
176
|
+
if (!has(body, key) || body[key] === null)
|
|
177
|
+
return undefined;
|
|
178
|
+
return requiredText(body, key, maximum);
|
|
179
|
+
}
|
|
180
|
+
function id(value, name) {
|
|
181
|
+
if (typeof value !== "string" ||
|
|
182
|
+
!value ||
|
|
183
|
+
value.length > MAX_ID_LENGTH ||
|
|
184
|
+
value.trim() !== value ||
|
|
185
|
+
hasControlCharacters(value))
|
|
186
|
+
throw new InvalidRequest(`${name} must be a valid identifier`);
|
|
187
|
+
return value;
|
|
188
|
+
}
|
|
189
|
+
function record(value, name) {
|
|
190
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
191
|
+
throw new InvalidRequest(`${name} must be an object`);
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
function has(body, key) {
|
|
195
|
+
return Object.prototype.hasOwnProperty.call(body, key);
|
|
196
|
+
}
|
|
197
|
+
function hasControlCharacters(value) {
|
|
198
|
+
for (const character of value) {
|
|
199
|
+
const code = character.codePointAt(0);
|
|
200
|
+
if (code < 0x20 || code === 0x7f)
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
class InvalidRequest extends Error {
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=permissions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../sources/routes/permissions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,EACH,WAAW,GAGd,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4CAA4C,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,+CAA+C,CAAC;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAmC,MAAM,8BAA8B,CAAC;AAE/F,MAAM,aAAa,GAAG,GAAG,CAAC;AAC1B,MAAM,oBAAoB,GAAG,GAAG,CAAC;AACjC,MAAM,2BAA2B,GAAG,KAAK,CAAC;AAE1C,MAAM,UAAU,wBAAwB,CACpC,GAAoB,EACpB,IAAiB,EACjB,Q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,SAAS,oBAAoB,CAAC,KAAa;IACvC,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC;QACvC,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;IAClD,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,MAAM,cAAe,SAAQ,KAAK;CAAG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type FastifyInstance } from "fastify";
|
|
2
2
|
import type { DrizzleExecutor } from "../modules/drizzle.js";
|
|
3
3
|
import type { PluginService } from "../modules/plugin/service.js";
|
|
4
|
+
import type { AgentService } from "../modules/agents/index.js";
|
|
4
5
|
/** Builds the capability-only HTTP surface exposed to local plugin containers. */
|
|
5
|
-
export declare function createPluginHostApi(executor: DrizzleExecutor, plugins: PluginService, logger: boolean): FastifyInstance;
|
|
6
|
+
export declare function createPluginHostApi(executor: DrizzleExecutor, plugins: PluginService, logger: boolean, agents?: Pick<AgentService, "prepareTurns" | "startTurn">): FastifyInstance;
|
|
6
7
|
//# sourceMappingURL=pluginHost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginHost.d.ts","sourceRoot":"","sources":["../../sources/routes/pluginHost.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,eAAe,
|
|
1
|
+
{"version":3,"file":"pluginHost.d.ts","sourceRoot":"","sources":["../../sources/routes/pluginHost.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,KAAK,eAAe,EAA0C,MAAM,SAAS,CAAC;AAChG,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAQ/D,kFAAkF;AAClF,wBAAgB,mBAAmB,CAC/B,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,OAAO,EACf,MAAM,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,WAAW,CAAC,GAC1D,eAAe,CAkKjB"}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import Fastify, {} from "fastify";
|
|
2
2
|
import { pluginInstallationListForHost } from "../modules/plugin/pluginInstallationListForHost.js";
|
|
3
|
-
import {
|
|
3
|
+
import { CollaborationError } from "../modules/chat/types.js";
|
|
4
|
+
import { PluginError, pluginHostPermissions, } from "../modules/plugin/types.js";
|
|
4
5
|
/** Builds the capability-only HTTP surface exposed to local plugin containers. */
|
|
5
|
-
export function createPluginHostApi(executor, plugins, logger) {
|
|
6
|
+
export function createPluginHostApi(executor, plugins, logger, agents) {
|
|
6
7
|
const app = Fastify({ logger });
|
|
7
8
|
app.get("/plugins", async (request, reply) => {
|
|
8
9
|
try {
|
|
9
|
-
const
|
|
10
|
+
const claims = await plugins.authorizeHost(bearerToken(request), "plugins:list");
|
|
10
11
|
return {
|
|
11
|
-
installationId,
|
|
12
|
+
installationId: claims.installationId,
|
|
12
13
|
plugins: await pluginInstallationListForHost(executor),
|
|
13
14
|
};
|
|
14
15
|
}
|
|
@@ -18,13 +19,144 @@ export function createPluginHostApi(executor, plugins, logger) {
|
|
|
18
19
|
throw error;
|
|
19
20
|
}
|
|
20
21
|
});
|
|
22
|
+
app.post("/chats/updateChat", async (request, reply) => {
|
|
23
|
+
try {
|
|
24
|
+
return await plugins.chatUpdate(bearerToken(request), requiredHeader(request, "x-happy2-chat-token", "Plugin chat token is required"), chatUpdateInput(request.body));
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
const response = handled(reply, error);
|
|
28
|
+
if (response)
|
|
29
|
+
return response;
|
|
30
|
+
throw error;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
app.post("/plugins/install", async (request, reply) => {
|
|
34
|
+
try {
|
|
35
|
+
const { installationId: actorInstallationId } = await plugins.authorizeHost(bearerToken(request), "plugins:install");
|
|
36
|
+
const body = object(request.body, "Request body");
|
|
37
|
+
only(body, ["shortName", "variables", "containerImageId", "permissions"]);
|
|
38
|
+
const installation = await plugins.install({
|
|
39
|
+
actorInstallationId,
|
|
40
|
+
shortName: shortName(body.shortName),
|
|
41
|
+
variables: variables(body.variables),
|
|
42
|
+
permissions: permissions(body.permissions),
|
|
43
|
+
...(body.containerImageId === undefined
|
|
44
|
+
? {}
|
|
45
|
+
: { containerImageId: identifier(body.containerImageId, "containerImageId") }),
|
|
46
|
+
});
|
|
47
|
+
return reply.code(202).send({ installation });
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
const response = handled(reply, error);
|
|
51
|
+
if (response)
|
|
52
|
+
return response;
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
app.post("/channels/updateMembers", async (request, reply) => {
|
|
57
|
+
try {
|
|
58
|
+
return await plugins.channelMembersUpdate(bearerToken(request), requiredHeader(request, "x-happy2-chat-token", "Plugin chat token is required"), channelMembersUpdateInput(request.body));
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const response = handled(reply, error);
|
|
62
|
+
if (response)
|
|
63
|
+
return response;
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
app.post("/plugins/uninstall", async (request, reply) => {
|
|
68
|
+
try {
|
|
69
|
+
const { installationId: actorInstallationId } = await plugins.authorizeHost(bearerToken(request), "plugins:uninstall");
|
|
70
|
+
const body = object(request.body, "Request body");
|
|
71
|
+
only(body, ["installationId"]);
|
|
72
|
+
await plugins.uninstallInstallation({
|
|
73
|
+
actorInstallationId,
|
|
74
|
+
installationId: identifier(body.installationId, "installationId"),
|
|
75
|
+
});
|
|
76
|
+
return { uninstalled: true };
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
const response = handled(reply, error);
|
|
80
|
+
if (response)
|
|
81
|
+
return response;
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
app.post("/plugin-install-requests", async (request, reply) => {
|
|
86
|
+
try {
|
|
87
|
+
const claims = await plugins.authorizeHost(bearerToken(request), "plugins:request-install");
|
|
88
|
+
if (!claims.agentCall)
|
|
89
|
+
throw new PluginError("forbidden", "Plugin install requests require an active Happy agent call");
|
|
90
|
+
const body = object(request.body, "Request body");
|
|
91
|
+
only(body, ["sourceUrl", "reason"]);
|
|
92
|
+
if (typeof body.sourceUrl !== "string" || body.sourceUrl.length > 4_096)
|
|
93
|
+
throw new PluginError("broken_configuration", "sourceUrl must be a plugin ZIP URL");
|
|
94
|
+
const reason = optionalString(body.reason, "reason", 1_000);
|
|
95
|
+
const approval = await plugins.requestInstallLink({
|
|
96
|
+
requesterInstallationId: claims.installationId,
|
|
97
|
+
agentCall: claims.agentCall,
|
|
98
|
+
url: body.sourceUrl,
|
|
99
|
+
...(reason ? { reason } : {}),
|
|
100
|
+
});
|
|
101
|
+
return reply.code(202).send({ approval });
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
const response = handled(reply, error);
|
|
105
|
+
if (response)
|
|
106
|
+
return response;
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
app.post("/plugin-uninstall-requests", async (request, reply) => {
|
|
111
|
+
try {
|
|
112
|
+
const claims = await plugins.authorizeHost(bearerToken(request), "plugins:request-uninstall");
|
|
113
|
+
if (!claims.agentCall)
|
|
114
|
+
throw new PluginError("forbidden", "Plugin uninstall requests require an active Happy agent call");
|
|
115
|
+
const body = object(request.body, "Request body");
|
|
116
|
+
only(body, ["installationId", "reason"]);
|
|
117
|
+
const installationId = identifier(body.installationId, "installationId");
|
|
118
|
+
const reason = optionalString(body.reason, "reason", 1_000);
|
|
119
|
+
const approval = await plugins.requestUninstall({
|
|
120
|
+
requesterInstallationId: claims.installationId,
|
|
121
|
+
agentCall: claims.agentCall,
|
|
122
|
+
targetInstallationId: installationId,
|
|
123
|
+
...(reason ? { reason } : {}),
|
|
124
|
+
});
|
|
125
|
+
return reply.code(202).send({ approval });
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
const response = handled(reply, error);
|
|
129
|
+
if (response)
|
|
130
|
+
return response;
|
|
131
|
+
throw error;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
app.post("/channels/createChannel", async (request, reply) => {
|
|
135
|
+
try {
|
|
136
|
+
const result = await plugins.channelCreate(bearerToken(request), requiredHeader(request, "x-happy2-chat-token", "Plugin chat token is required"), channelCreateInput(request.body), agents);
|
|
137
|
+
return reply.code(201).send(result);
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
const response = handled(reply, error);
|
|
141
|
+
if (response)
|
|
142
|
+
return response;
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
21
146
|
app.setErrorHandler((error, request, reply) => {
|
|
22
147
|
request.log.error(error);
|
|
23
|
-
if (!reply.sent)
|
|
148
|
+
if (!reply.sent && !handled(reply, error))
|
|
24
149
|
reply.code(500).send({ error: "internal_server_error" });
|
|
25
150
|
});
|
|
26
151
|
return app;
|
|
27
152
|
}
|
|
153
|
+
function optionalString(value, name, maximum) {
|
|
154
|
+
if (value === undefined)
|
|
155
|
+
return undefined;
|
|
156
|
+
if (typeof value !== "string" || !value.trim() || value.length > maximum)
|
|
157
|
+
throw new PluginHostRequestError(`${name} must contain between 1 and ${maximum} characters`);
|
|
158
|
+
return value.trim();
|
|
159
|
+
}
|
|
28
160
|
function bearerToken(request) {
|
|
29
161
|
const authorization = request.headers.authorization;
|
|
30
162
|
if (!authorization?.startsWith("Bearer ") || authorization.length > 4_096)
|
|
@@ -34,4 +166,223 @@ function bearerToken(request) {
|
|
|
34
166
|
throw new PluginError("forbidden", "Plugin runtime token is required");
|
|
35
167
|
return token;
|
|
36
168
|
}
|
|
169
|
+
function requiredHeader(request, name, message) {
|
|
170
|
+
const raw = request.headers[name];
|
|
171
|
+
const value = Array.isArray(raw) ? raw[0] : raw;
|
|
172
|
+
if (!value || value.length > 4_096)
|
|
173
|
+
throw new PluginError("forbidden", message);
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
176
|
+
function chatUpdateInput(value) {
|
|
177
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
178
|
+
throw new PluginHostRequestError("Request body must be an object");
|
|
179
|
+
const body = value;
|
|
180
|
+
if (Object.keys(body).some((key) => key !== "title" && key !== "description"))
|
|
181
|
+
throw new PluginHostRequestError("Request body contains an unknown field");
|
|
182
|
+
if (!("title" in body) && !("description" in body))
|
|
183
|
+
throw new PluginHostRequestError("At least one chat field is required");
|
|
184
|
+
let title;
|
|
185
|
+
if ("title" in body) {
|
|
186
|
+
if (typeof body.title !== "string")
|
|
187
|
+
throw new PluginHostRequestError("title must be a string");
|
|
188
|
+
title = body.title.trim();
|
|
189
|
+
if (!title || title.length > 100)
|
|
190
|
+
throw new PluginHostRequestError("title must contain 1-100 characters");
|
|
191
|
+
}
|
|
192
|
+
let description;
|
|
193
|
+
if ("description" in body) {
|
|
194
|
+
if (body.description === null)
|
|
195
|
+
description = null;
|
|
196
|
+
else {
|
|
197
|
+
if (typeof body.description !== "string")
|
|
198
|
+
throw new PluginHostRequestError("description must be a string or null");
|
|
199
|
+
const normalized = body.description.trim();
|
|
200
|
+
if (normalized.length > 500)
|
|
201
|
+
throw new PluginHostRequestError("description must contain at most 500 characters");
|
|
202
|
+
description = normalized || null;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
...(title === undefined ? {} : { title }),
|
|
207
|
+
...(description === undefined ? {} : { description }),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function shortName(value) {
|
|
211
|
+
if (typeof value !== "string" || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value))
|
|
212
|
+
throw new PluginHostRequestError("shortName is invalid");
|
|
213
|
+
return value;
|
|
214
|
+
}
|
|
215
|
+
function identifier(value, name) {
|
|
216
|
+
if (typeof value !== "string" || !value || value.length > 128 || /\s/.test(value))
|
|
217
|
+
throw new PluginHostRequestError(`${name} must be a valid identifier`);
|
|
218
|
+
return value;
|
|
219
|
+
}
|
|
220
|
+
function variables(value) {
|
|
221
|
+
const record = value === undefined ? {} : object(value, "variables");
|
|
222
|
+
if (Object.keys(record).length > 64)
|
|
223
|
+
throw new PluginHostRequestError("variables has too many entries");
|
|
224
|
+
const result = {};
|
|
225
|
+
for (const [key, item] of Object.entries(record)) {
|
|
226
|
+
if (!/^[A-Z_][A-Z0-9_]*$/.test(key) || typeof item !== "string")
|
|
227
|
+
throw new PluginHostRequestError("variables must map environment keys to string values");
|
|
228
|
+
result[key] = item;
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
function permissions(value) {
|
|
233
|
+
if (value === undefined)
|
|
234
|
+
return [];
|
|
235
|
+
if (!Array.isArray(value) || value.length > pluginHostPermissions.length)
|
|
236
|
+
throw new PluginHostRequestError("permissions must be an array");
|
|
237
|
+
const result = [];
|
|
238
|
+
for (const permission of value) {
|
|
239
|
+
if (typeof permission !== "string" ||
|
|
240
|
+
!pluginHostPermissions.includes(permission))
|
|
241
|
+
throw new PluginHostRequestError("permissions contains an unknown plugin permission");
|
|
242
|
+
if (result.includes(permission))
|
|
243
|
+
throw new PluginHostRequestError(`permissions contains duplicate ${permission}`);
|
|
244
|
+
result.push(permission);
|
|
245
|
+
}
|
|
246
|
+
return result;
|
|
247
|
+
}
|
|
248
|
+
function object(value, name) {
|
|
249
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
250
|
+
throw new PluginHostRequestError(`${name} must be an object`);
|
|
251
|
+
return value;
|
|
252
|
+
}
|
|
253
|
+
function channelMembersUpdateInput(value) {
|
|
254
|
+
const body = bodyRecord(value);
|
|
255
|
+
onlyBodyKeys(body, ["add", "remove"]);
|
|
256
|
+
const add = userCapabilities(body.add, "add");
|
|
257
|
+
const remove = userCapabilities(body.remove, "remove");
|
|
258
|
+
if (!add.length && !remove.length)
|
|
259
|
+
throw new PluginHostRequestError("At least one user must be added or removed");
|
|
260
|
+
const addIds = new Set(add.map(({ id }) => id));
|
|
261
|
+
if (remove.some(({ id }) => addIds.has(id)))
|
|
262
|
+
throw new PluginHostRequestError("A user cannot be both added and removed");
|
|
263
|
+
return { add, remove };
|
|
264
|
+
}
|
|
265
|
+
function channelCreateInput(value) {
|
|
266
|
+
const body = bodyRecord(value);
|
|
267
|
+
onlyBodyKeys(body, ["name", "description", "idempotencyKey", "members", "initialMessage"]);
|
|
268
|
+
const name = requiredTrimmedString(body.name, "name", 100);
|
|
269
|
+
let description;
|
|
270
|
+
if (body.description !== undefined)
|
|
271
|
+
description = requiredTrimmedString(body.description, "description", 500);
|
|
272
|
+
const members = userCapabilities(body.members, "members");
|
|
273
|
+
const idempotencyKey = body.idempotencyKey === undefined
|
|
274
|
+
? undefined
|
|
275
|
+
: requiredToken(body.idempotencyKey, "idempotencyKey", 128);
|
|
276
|
+
let initialMessage;
|
|
277
|
+
if (body.initialMessage !== undefined) {
|
|
278
|
+
const message = bodyRecord(body.initialMessage, "initialMessage");
|
|
279
|
+
onlyBodyKeys(message, ["audience", "text"], "initialMessage");
|
|
280
|
+
if (message.audience !== "agents" && message.audience !== "people")
|
|
281
|
+
throw new PluginHostRequestError("initialMessage.audience must be agents or people");
|
|
282
|
+
initialMessage = {
|
|
283
|
+
audience: message.audience,
|
|
284
|
+
text: requiredMessageText(message.text),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
name,
|
|
289
|
+
...(description ? { description } : {}),
|
|
290
|
+
...(idempotencyKey ? { idempotencyKey } : {}),
|
|
291
|
+
members,
|
|
292
|
+
...(initialMessage ? { initialMessage } : {}),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function userCapabilities(value, name) {
|
|
296
|
+
if (value === undefined)
|
|
297
|
+
return [];
|
|
298
|
+
if (!Array.isArray(value) || value.length > 100)
|
|
299
|
+
throw new PluginHostRequestError(`${name} must be an array of at most 100 users`);
|
|
300
|
+
const result = value.map((entry, index) => {
|
|
301
|
+
const capability = bodyRecord(entry, `${name}[${index}]`);
|
|
302
|
+
onlyBodyKeys(capability, ["id", "token"], `${name}[${index}]`);
|
|
303
|
+
return {
|
|
304
|
+
id: requiredToken(capability.id, `${name}[${index}].id`, 128),
|
|
305
|
+
token: requiredToken(capability.token, `${name}[${index}].token`, 4_096),
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
if (new Set(result.map(({ id }) => id)).size !== result.length)
|
|
309
|
+
throw new PluginHostRequestError(`${name} contains a duplicate user`);
|
|
310
|
+
return result;
|
|
311
|
+
}
|
|
312
|
+
function bodyRecord(value, name = "Request body") {
|
|
313
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
314
|
+
throw new PluginHostRequestError(`${name} must be an object`);
|
|
315
|
+
return value;
|
|
316
|
+
}
|
|
317
|
+
function only(value, allowed) {
|
|
318
|
+
const unexpected = Object.keys(value).find((key) => !allowed.includes(key));
|
|
319
|
+
if (unexpected)
|
|
320
|
+
throw new PluginHostRequestError(`Unexpected request field ${unexpected}`);
|
|
321
|
+
}
|
|
322
|
+
function onlyBodyKeys(body, allowed, name = "Request body") {
|
|
323
|
+
if (Object.keys(body).some((key) => !allowed.includes(key)))
|
|
324
|
+
throw new PluginHostRequestError(`${name} contains an unknown field`);
|
|
325
|
+
}
|
|
326
|
+
function requiredTrimmedString(value, name, maximum) {
|
|
327
|
+
if (typeof value !== "string")
|
|
328
|
+
throw new PluginHostRequestError(`${name} must be a string`);
|
|
329
|
+
const normalized = value.trim();
|
|
330
|
+
if (!normalized || normalized.length > maximum || hasControlCharacters(normalized))
|
|
331
|
+
throw new PluginHostRequestError(`${name} must contain 1-${maximum} characters`);
|
|
332
|
+
return normalized;
|
|
333
|
+
}
|
|
334
|
+
function requiredMessageText(value) {
|
|
335
|
+
if (typeof value !== "string")
|
|
336
|
+
throw new PluginHostRequestError("initialMessage.text must be a string");
|
|
337
|
+
if (value.length > 40_000)
|
|
338
|
+
throw new PluginHostRequestError("initialMessage.text must contain at most 40000 characters");
|
|
339
|
+
if (!value.trim() || hasControlCharacters(value, true))
|
|
340
|
+
throw new PluginHostRequestError("initialMessage.text is empty or contains unsupported characters");
|
|
341
|
+
return value;
|
|
342
|
+
}
|
|
343
|
+
function hasControlCharacters(value, allowLineBreaks = false) {
|
|
344
|
+
for (const character of value) {
|
|
345
|
+
const code = character.charCodeAt(0);
|
|
346
|
+
if (code === 127 || (code < 32 && !(allowLineBreaks && (code === 9 || code === 10))))
|
|
347
|
+
return true;
|
|
348
|
+
}
|
|
349
|
+
return false;
|
|
350
|
+
}
|
|
351
|
+
function requiredToken(value, name, maximum) {
|
|
352
|
+
if (typeof value !== "string" || !value || value.length > maximum)
|
|
353
|
+
throw new PluginHostRequestError(`${name} must contain 1-${maximum} characters`);
|
|
354
|
+
return value;
|
|
355
|
+
}
|
|
356
|
+
function handled(reply, error) {
|
|
357
|
+
if (error instanceof PluginError)
|
|
358
|
+
return reply
|
|
359
|
+
.code(error.code === "not_found"
|
|
360
|
+
? 404
|
|
361
|
+
: error.code === "forbidden"
|
|
362
|
+
? 403
|
|
363
|
+
: error.code === "not_ready"
|
|
364
|
+
? 503
|
|
365
|
+
: error.code === "conflict"
|
|
366
|
+
? 409
|
|
367
|
+
: 400)
|
|
368
|
+
.send({
|
|
369
|
+
error: error.code,
|
|
370
|
+
message: error.message,
|
|
371
|
+
});
|
|
372
|
+
if (error instanceof CollaborationError)
|
|
373
|
+
return reply
|
|
374
|
+
.code(error.code === "not_found"
|
|
375
|
+
? 404
|
|
376
|
+
: error.code === "forbidden"
|
|
377
|
+
? 403
|
|
378
|
+
: error.code === "conflict"
|
|
379
|
+
? 409
|
|
380
|
+
: 400)
|
|
381
|
+
.send({ error: error.code, message: error.message });
|
|
382
|
+
if (error instanceof PluginHostRequestError)
|
|
383
|
+
return reply.code(400).send({ error: "invalid_request", message: error.message });
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
class PluginHostRequestError extends Error {
|
|
387
|
+
}
|
|
37
388
|
//# sourceMappingURL=pluginHost.js.map
|