@coasys/ad4m 0.12.0 → 0.13.0-postmessage-ws-proxy.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -25
- package/jest-setup.ts +1 -1
- package/lib/index.cjs +7444 -13939
- package/lib/index.js +5322 -11888
- package/lib/src/Ad4mClient.d.ts +9 -3
- package/lib/src/Ad4mClient.js +40 -13
- package/lib/src/Literal.js +6 -5
- package/lib/src/agent/Agent.js +26 -272
- package/lib/src/agent/AgentClient.d.ts +33 -21
- package/lib/src/agent/AgentClient.js +180 -373
- package/lib/src/agent/AgentStatus.js +2 -37
- package/lib/src/ai/AIClient.d.ts +12 -4
- package/lib/src/ai/AIClient.js +81 -285
- package/lib/src/ai/AITypes.d.ts +55 -0
- package/lib/src/ai/AITypes.js +18 -0
- package/lib/src/ai/Tasks.js +10 -133
- package/lib/src/apiClient.d.ts +53 -0
- package/lib/src/apiClient.js +234 -0
- package/lib/src/cache/PersistentCache.d.ts +40 -0
- package/lib/src/cache/PersistentCache.js +139 -0
- package/lib/src/expression/Expression.d.ts +1 -1
- package/lib/src/expression/Expression.js +13 -122
- package/lib/src/expression/ExpressionClient.d.ts +11 -3
- package/lib/src/expression/ExpressionClient.js +120 -75
- package/lib/src/expression/ExpressionRef.js +4 -27
- package/lib/src/generated/api/AIModelLoadingStatus.d.ts +7 -0
- package/lib/src/generated/api/AIModelLoadingStatus.js +2 -0
- package/lib/src/generated/api/AddLinkExpressionRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinkExpressionRequest.js +1 -0
- package/lib/src/generated/api/AddLinkRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinkRequest.js +1 -0
- package/lib/src/generated/api/AddLinksBulkRequest.d.ts +6 -0
- package/lib/src/generated/api/AddLinksBulkRequest.js +1 -0
- package/lib/src/generated/api/AddSdnaRequest.d.ts +6 -0
- package/lib/src/generated/api/AddSdnaRequest.js +2 -0
- package/lib/src/generated/api/ApplyTemplateRequest.d.ts +4 -0
- package/lib/src/generated/api/ApplyTemplateRequest.js +2 -0
- package/lib/src/generated/api/AuthInfoInput.d.ts +10 -0
- package/lib/src/generated/api/AuthInfoInput.js +1 -0
- package/lib/src/generated/api/CapabilityInput.d.ts +5 -0
- package/lib/src/generated/api/CapabilityInput.js +1 -0
- package/lib/src/generated/api/CommitBatchRequest.d.ts +3 -0
- package/lib/src/generated/api/CommitBatchRequest.js +2 -0
- package/lib/src/generated/api/ComputeLogEntry.d.ts +9 -0
- package/lib/src/generated/api/ComputeLogEntry.js +2 -0
- package/lib/src/generated/api/CreateExpressionRequest.d.ts +4 -0
- package/lib/src/generated/api/CreateExpressionRequest.js +2 -0
- package/lib/src/generated/api/CreatePerspectiveRequest.d.ts +3 -0
- package/lib/src/generated/api/CreatePerspectiveRequest.js +2 -0
- package/lib/src/generated/api/CreateSubjectRequest.d.ts +6 -0
- package/lib/src/generated/api/CreateSubjectRequest.js +2 -0
- package/lib/src/generated/api/EmbedRequest.d.ts +4 -0
- package/lib/src/generated/api/EmbedRequest.js +2 -0
- package/lib/src/generated/api/EntanglementProofInput.d.ts +6 -0
- package/lib/src/generated/api/EntanglementProofInput.js +2 -0
- package/lib/src/generated/api/ExecuteCommandsRequest.d.ts +4 -0
- package/lib/src/generated/api/ExecuteCommandsRequest.js +2 -0
- package/lib/src/generated/api/ExportRequest.d.ts +5 -0
- package/lib/src/generated/api/ExportRequest.js +2 -0
- package/lib/src/generated/api/ExpressionManyRequest.d.ts +3 -0
- package/lib/src/generated/api/ExpressionManyRequest.js +2 -0
- package/lib/src/generated/api/ExpressionProof.d.ts +4 -0
- package/lib/src/generated/api/ExpressionProof.js +2 -0
- package/lib/src/generated/api/ExpressionProofInput.d.ts +6 -0
- package/lib/src/generated/api/ExpressionProofInput.js +2 -0
- package/lib/src/generated/api/FriendSendMessageRequest.d.ts +3 -0
- package/lib/src/generated/api/FriendSendMessageRequest.js +2 -0
- package/lib/src/generated/api/FriendsListRequest.d.ts +3 -0
- package/lib/src/generated/api/FriendsListRequest.js +2 -0
- package/lib/src/generated/api/GenerateAgentRequest.d.ts +3 -0
- package/lib/src/generated/api/GenerateAgentRequest.js +2 -0
- package/lib/src/generated/api/GenerateJwtRequest.d.ts +4 -0
- package/lib/src/generated/api/GenerateJwtRequest.js +2 -0
- package/lib/src/generated/api/GetSubjectDataRequest.d.ts +4 -0
- package/lib/src/generated/api/GetSubjectDataRequest.js +2 -0
- package/lib/src/generated/api/ImportAgentRequest.d.ts +6 -0
- package/lib/src/generated/api/ImportAgentRequest.js +2 -0
- package/lib/src/generated/api/ImportRequest.d.ts +4 -0
- package/lib/src/generated/api/ImportRequest.js +2 -0
- package/lib/src/generated/api/JoinNeighbourhoodRequest.d.ts +3 -0
- package/lib/src/generated/api/JoinNeighbourhoodRequest.js +2 -0
- package/lib/src/generated/api/LanguageMetaInput.d.ts +6 -0
- package/lib/src/generated/api/LanguageMetaInput.js +2 -0
- package/lib/src/generated/api/Link.d.ts +5 -0
- package/lib/src/generated/api/Link.js +2 -0
- package/lib/src/generated/api/LinkExpression.d.ts +10 -0
- package/lib/src/generated/api/LinkExpression.js +1 -0
- package/lib/src/generated/api/LinkExpressionInput.d.ts +10 -0
- package/lib/src/generated/api/LinkExpressionInput.js +1 -0
- package/lib/src/generated/api/LinkInput.d.ts +5 -0
- package/lib/src/generated/api/LinkInput.js +2 -0
- package/lib/src/generated/api/LinkLanguageTemplatesRequest.d.ts +3 -0
- package/lib/src/generated/api/LinkLanguageTemplatesRequest.js +2 -0
- package/lib/src/generated/api/LinkMutations.d.ts +6 -0
- package/lib/src/generated/api/LinkMutations.js +1 -0
- package/lib/src/generated/api/LinkStatus.d.ts +1 -0
- package/lib/src/generated/api/LinkStatus.js +2 -0
- package/lib/src/generated/api/LockAgentRequest.d.ts +3 -0
- package/lib/src/generated/api/LockAgentRequest.js +2 -0
- package/lib/src/generated/api/ModelType.d.ts +1 -0
- package/lib/src/generated/api/ModelType.js +2 -0
- package/lib/src/generated/api/NotificationInput.d.ts +10 -0
- package/lib/src/generated/api/NotificationInput.js +2 -0
- package/lib/src/generated/api/OpenLinkRequest.d.ts +3 -0
- package/lib/src/generated/api/OpenLinkRequest.js +2 -0
- package/lib/src/generated/api/PermitCapabilityRequest.d.ts +3 -0
- package/lib/src/generated/api/PermitCapabilityRequest.js +2 -0
- package/lib/src/generated/api/PerspectiveInput.d.ts +4 -0
- package/lib/src/generated/api/PerspectiveInput.js +1 -0
- package/lib/src/generated/api/PromptRequest.d.ts +4 -0
- package/lib/src/generated/api/PromptRequest.js +2 -0
- package/lib/src/generated/api/PublishLanguageRequest.d.ts +5 -0
- package/lib/src/generated/api/PublishLanguageRequest.js +1 -0
- package/lib/src/generated/api/PublishNeighbourhoodRequest.d.ts +6 -0
- package/lib/src/generated/api/PublishNeighbourhoodRequest.js +1 -0
- package/lib/src/generated/api/QueryRequest.d.ts +7 -0
- package/lib/src/generated/api/QueryRequest.js +2 -0
- package/lib/src/generated/api/RemoveLinkRequest.d.ts +5 -0
- package/lib/src/generated/api/RemoveLinkRequest.js +1 -0
- package/lib/src/generated/api/RemoveLinksBulkRequest.d.ts +5 -0
- package/lib/src/generated/api/RemoveLinksBulkRequest.js +1 -0
- package/lib/src/generated/api/ResourceInput.d.ts +4 -0
- package/lib/src/generated/api/ResourceInput.js +2 -0
- package/lib/src/generated/api/SetDefaultModelRequest.d.ts +4 -0
- package/lib/src/generated/api/SetDefaultModelRequest.js +1 -0
- package/lib/src/generated/api/SetFreeHostingEnabledRequest.d.ts +3 -0
- package/lib/src/generated/api/SetFreeHostingEnabledRequest.js +2 -0
- package/lib/src/generated/api/SetMultiUserRequest.d.ts +3 -0
- package/lib/src/generated/api/SetMultiUserRequest.js +2 -0
- package/lib/src/generated/api/SetStatusRequest.d.ts +3 -0
- package/lib/src/generated/api/SetStatusRequest.js +2 -0
- package/lib/src/generated/api/SignMessageRequest.d.ts +3 -0
- package/lib/src/generated/api/SignMessageRequest.js +2 -0
- package/lib/src/generated/api/TrustedAgentsRequest.d.ts +3 -0
- package/lib/src/generated/api/TrustedAgentsRequest.js +2 -0
- package/lib/src/generated/api/UnlockAgentRequest.d.ts +4 -0
- package/lib/src/generated/api/UnlockAgentRequest.js +2 -0
- package/lib/src/generated/api/UpdateLinkRequest.d.ts +7 -0
- package/lib/src/generated/api/UpdateLinkRequest.js +1 -0
- package/lib/src/generated/api/UpdatePerspectiveRequest.d.ts +3 -0
- package/lib/src/generated/api/UpdatePerspectiveRequest.js +2 -0
- package/lib/src/generated/api/UserStatistics.d.ts +9 -0
- package/lib/src/generated/api/UserStatistics.js +2 -0
- package/lib/src/generated/api/VerificationRequestResult.d.ts +6 -0
- package/lib/src/generated/api/VerificationRequestResult.js +2 -0
- package/lib/src/generated/api/VerifySignatureRequest.d.ts +5 -0
- package/lib/src/generated/api/VerifySignatureRequest.js +2 -0
- package/lib/src/generated/api/WriteSettingsRequest.d.ts +3 -0
- package/lib/src/generated/api/WriteSettingsRequest.js +2 -0
- package/lib/src/generated/api/index.d.ts +42 -0
- package/lib/src/generated/api/index.js +7 -0
- package/lib/src/index.d.ts +7 -2
- package/lib/src/index.js +7 -2
- package/lib/src/jestSetup.d.ts +0 -1
- package/lib/src/jestSetup.js +1 -1
- package/lib/src/language/Icon.js +2 -21
- package/lib/src/language/Language.d.ts +26 -176
- package/lib/src/language/Language.js +32 -72
- package/lib/src/language/LanguageClient.d.ts +2 -2
- package/lib/src/language/LanguageClient.js +15 -105
- package/lib/src/language/LanguageHandle.js +2 -41
- package/lib/src/language/LanguageMeta.js +4 -75
- package/lib/src/language/LanguageRef.js +2 -25
- package/lib/src/links/Links.js +14 -111
- package/lib/src/model/Ad4mModel.d.ts +150 -62
- package/lib/src/model/Ad4mModel.js +689 -417
- package/lib/src/model/Ad4mModel.test.js +1434 -688
- package/lib/src/model/ModelQueryBuilder.d.ts +59 -38
- package/lib/src/model/ModelQueryBuilder.js +317 -153
- package/lib/src/model/Subject.js +6 -6
- package/lib/src/model/decorators.d.ts +36 -8
- package/lib/src/model/decorators.js +41 -14
- package/lib/src/model/hydration-batch.d.ts +34 -0
- package/lib/src/model/hydration-batch.js +147 -0
- package/lib/src/model/hydration-batching.test.d.ts +7 -0
- package/lib/src/model/hydration-batching.test.js +456 -0
- package/lib/src/model/hydration.d.ts +3 -92
- package/lib/src/model/hydration.js +3 -691
- package/lib/src/model/index.d.ts +3 -4
- package/lib/src/model/index.js +3 -4
- package/lib/src/model/json-schema.js +2 -2
- package/lib/src/model/model-manifest.d.ts +41 -0
- package/lib/src/model/model-manifest.js +11 -0
- package/lib/src/model/query-cache.d.ts +30 -0
- package/lib/src/model/query-cache.js +66 -0
- package/lib/src/model/query-cache.test.d.ts +1 -0
- package/lib/src/model/query-cache.test.js +43 -0
- package/lib/src/model/query-common.d.ts +1 -1
- package/lib/src/model/query-common.js +1 -1
- package/lib/src/model/query-sparql-batch.d.ts +17 -0
- package/lib/src/model/query-sparql-batch.js +260 -0
- package/lib/src/model/query-sparql.d.ts +51 -0
- package/lib/src/model/query-sparql.js +466 -0
- package/lib/src/model/query-sparql.test.d.ts +1 -0
- package/lib/src/model/query-sparql.test.js +312 -0
- package/lib/src/model/{surreal-utils.d.ts → query-utils.d.ts} +13 -9
- package/lib/src/model/query-utils.js +189 -0
- package/lib/src/model/relation-filtering.test.js +15 -15
- package/lib/src/model/sdna.js +1 -1
- package/lib/src/model/shacl-gen.js +46 -18
- package/lib/src/model/subscription-delta.test.d.ts +24 -0
- package/lib/src/model/subscription-delta.test.js +180 -0
- package/lib/src/model/subscription-pool.d.ts +39 -0
- package/lib/src/model/subscription-pool.js +165 -0
- package/lib/src/model/types.d.ts +60 -5
- package/lib/src/model/types.js +5 -2
- package/lib/src/neighbourhood/Neighbourhood.js +4 -32
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +3 -3
- package/lib/src/neighbourhood/NeighbourhoodClient.js +40 -203
- package/lib/src/perspectives/LinkQuery.js +2 -42
- package/lib/src/perspectives/Perspective.d.ts +1 -1
- package/lib/src/perspectives/Perspective.js +10 -52
- package/lib/src/perspectives/PerspectiveClient.d.ts +22 -32
- package/lib/src/perspectives/PerspectiveClient.js +189 -454
- package/lib/src/perspectives/PerspectiveClient.test.d.ts +1 -0
- package/lib/src/perspectives/PerspectiveClient.test.js +224 -0
- package/lib/src/perspectives/PerspectiveDiff.js +4 -31
- package/lib/src/perspectives/PerspectiveHandle.js +3 -43
- package/lib/src/perspectives/PerspectiveProxy.d.ts +156 -78
- package/lib/src/perspectives/PerspectiveProxy.js +474 -389
- package/lib/src/perspectives/PerspectiveResolver.d.ts +0 -1
- package/lib/src/perspectives/PerspectiveResolver.js +0 -11
- package/lib/src/perspectives/WakerSubscriptionManager.d.ts +3 -3
- package/lib/src/perspectives/WakerSubscriptionManager.js +12 -12
- package/lib/src/runtime/RuntimeClient.d.ts +34 -6
- package/lib/src/runtime/RuntimeClient.js +131 -362
- package/lib/src/runtime/RuntimeResolver.d.ts +28 -1
- package/lib/src/runtime/RuntimeResolver.js +197 -4
- package/lib/src/runtime/RuntimeTypes.d.ts +101 -0
- package/lib/src/runtime/RuntimeTypes.js +45 -0
- package/lib/src/schema.gql +27 -1
- package/lib/src/shacl/SHACLFlow.d.ts +1 -1
- package/lib/src/shacl/SHACLFlow.js +9 -9
- package/lib/src/shacl/SHACLShape.d.ts +8 -1
- package/lib/src/shacl/SHACLShape.js +57 -38
- package/lib/src/shacl/SHACLShape.test.js +82 -0
- package/lib/src/typeDefs.js +3 -602
- package/lib/src/utils.d.ts +6 -6
- package/lib/src/utils.js +6 -6
- package/package.json +6 -18
- package/rollup.config.js +0 -7
- package/src/Ad4mClient.test.ts +1192 -1288
- package/src/Ad4mClient.ts +46 -15
- package/src/Literal.test.ts +10 -5
- package/src/Literal.ts +6 -5
- package/src/agent/Agent.ts +0 -99
- package/src/agent/AgentClient.ts +238 -465
- package/src/agent/AgentStatus.ts +0 -12
- package/src/ai/AIClient.ts +96 -296
- package/src/ai/AITypes.ts +66 -0
- package/src/ai/Tasks.ts +0 -52
- package/src/apiClient.ts +287 -0
- package/src/cache/PersistentCache.ts +145 -0
- package/src/cache/cache.test.ts +713 -0
- package/src/expression/Expression.ts +3 -43
- package/src/expression/ExpressionClient.ts +148 -77
- package/src/expression/ExpressionRef.ts +2 -8
- package/src/generated/api/AIModelLoadingStatus.ts +3 -0
- package/src/generated/api/AddLinkExpressionRequest.ts +4 -0
- package/src/generated/api/AddLinkRequest.ts +4 -0
- package/src/generated/api/AddLinksBulkRequest.ts +4 -0
- package/src/generated/api/AddSdnaRequest.ts +3 -0
- package/src/generated/api/ApplyTemplateRequest.ts +3 -0
- package/src/generated/api/AuthInfoInput.ts +4 -0
- package/src/generated/api/CapabilityInput.ts +4 -0
- package/src/generated/api/CommitBatchRequest.ts +3 -0
- package/src/generated/api/ComputeLogEntry.ts +3 -0
- package/src/generated/api/CreateExpressionRequest.ts +3 -0
- package/src/generated/api/CreatePerspectiveRequest.ts +3 -0
- package/src/generated/api/CreateSubjectRequest.ts +3 -0
- package/src/generated/api/EmbedRequest.ts +3 -0
- package/src/generated/api/EntanglementProofInput.ts +3 -0
- package/src/generated/api/ExecuteCommandsRequest.ts +3 -0
- package/src/generated/api/ExportRequest.ts +3 -0
- package/src/generated/api/ExpressionManyRequest.ts +3 -0
- package/src/generated/api/ExpressionProof.ts +3 -0
- package/src/generated/api/ExpressionProofInput.ts +3 -0
- package/src/generated/api/FriendSendMessageRequest.ts +3 -0
- package/src/generated/api/FriendsListRequest.ts +3 -0
- package/src/generated/api/GenerateAgentRequest.ts +3 -0
- package/src/generated/api/GenerateJwtRequest.ts +3 -0
- package/src/generated/api/GetSubjectDataRequest.ts +3 -0
- package/src/generated/api/ImportAgentRequest.ts +3 -0
- package/src/generated/api/ImportRequest.ts +3 -0
- package/src/generated/api/JoinNeighbourhoodRequest.ts +3 -0
- package/src/generated/api/LanguageMetaInput.ts +3 -0
- package/src/generated/api/Link.ts +3 -0
- package/src/generated/api/LinkExpression.ts +6 -0
- package/src/generated/api/LinkExpressionInput.ts +6 -0
- package/src/generated/api/LinkInput.ts +3 -0
- package/src/generated/api/LinkLanguageTemplatesRequest.ts +3 -0
- package/src/generated/api/LinkMutations.ts +5 -0
- package/src/generated/api/LinkStatus.ts +3 -0
- package/src/generated/api/LockAgentRequest.ts +3 -0
- package/src/generated/api/ModelType.ts +3 -0
- package/src/generated/api/NotificationInput.ts +3 -0
- package/src/generated/api/OpenLinkRequest.ts +3 -0
- package/src/generated/api/PermitCapabilityRequest.ts +3 -0
- package/src/generated/api/PerspectiveInput.ts +4 -0
- package/src/generated/api/PromptRequest.ts +3 -0
- package/src/generated/api/PublishLanguageRequest.ts +4 -0
- package/src/generated/api/PublishNeighbourhoodRequest.ts +4 -0
- package/src/generated/api/QueryRequest.ts +6 -0
- package/src/generated/api/RemoveLinkRequest.ts +4 -0
- package/src/generated/api/RemoveLinksBulkRequest.ts +4 -0
- package/src/generated/api/ResourceInput.ts +3 -0
- package/src/generated/api/SetDefaultModelRequest.ts +4 -0
- package/src/generated/api/SetFreeHostingEnabledRequest.ts +3 -0
- package/src/generated/api/SetMultiUserRequest.ts +3 -0
- package/src/generated/api/SetStatusRequest.ts +3 -0
- package/src/generated/api/SignMessageRequest.ts +3 -0
- package/src/generated/api/TrustedAgentsRequest.ts +3 -0
- package/src/generated/api/UnlockAgentRequest.ts +3 -0
- package/src/generated/api/UpdateLinkRequest.ts +5 -0
- package/src/generated/api/UpdatePerspectiveRequest.ts +3 -0
- package/src/generated/api/UserStatistics.ts +3 -0
- package/src/generated/api/VerificationRequestResult.ts +3 -0
- package/src/generated/api/VerifySignatureRequest.ts +3 -0
- package/src/generated/api/WriteSettingsRequest.ts +3 -0
- package/src/generated/api/index.ts +49 -0
- package/src/index.ts +7 -2
- package/src/jestSetup.ts +1 -1
- package/src/language/Icon.ts +0 -4
- package/src/language/Language.ts +51 -248
- package/src/language/LanguageClient.ts +21 -132
- package/src/language/LanguageHandle.ts +0 -14
- package/src/language/LanguageMeta.ts +0 -29
- package/src/language/LanguageRef.ts +0 -7
- package/src/links/Links.ts +0 -37
- package/src/model/Ad4mModel.test.ts +1690 -777
- package/src/model/Ad4mModel.ts +749 -477
- package/src/model/ModelQueryBuilder.ts +356 -171
- package/src/model/decorators.ts +71 -22
- package/src/model/hydration.ts +3 -772
- package/src/model/index.ts +3 -4
- package/src/model/json-schema.ts +2 -2
- package/src/model/query-cache.test.ts +54 -0
- package/src/model/query-cache.ts +79 -0
- package/src/model/query-common.ts +1 -1
- package/src/model/query-sparql.test.ts +376 -0
- package/src/model/query-sparql.ts +504 -0
- package/src/model/query-utils.ts +209 -0
- package/src/model/relation-filtering.test.ts +15 -15
- package/src/model/sdna.ts +1 -1
- package/src/model/shacl-gen.ts +47 -17
- package/src/model/types.ts +65 -5
- package/src/neighbourhood/Neighbourhood.ts +0 -9
- package/src/neighbourhood/NeighbourhoodClient.ts +42 -207
- package/src/neighbourhood/NeighbourhoodProxy.test.ts +34 -36
- package/src/perspectives/LinkQuery.ts +0 -15
- package/src/perspectives/Perspective.ts +1 -12
- package/src/perspectives/PerspectiveClient.test.ts +262 -0
- package/src/perspectives/PerspectiveClient.ts +254 -468
- package/src/perspectives/PerspectiveDiff.ts +0 -8
- package/src/perspectives/PerspectiveHandle.ts +1 -12
- package/src/perspectives/PerspectiveProxy.test.ts +125 -0
- package/src/perspectives/PerspectiveProxy.ts +522 -434
- package/src/perspectives/WakerSubscriptionManager.ts +13 -13
- package/src/runtime/RuntimeClient.ts +166 -369
- package/src/runtime/RuntimeTypes.ts +144 -0
- package/src/shacl/SHACLFlow.ts +9 -9
- package/src/shacl/SHACLShape.test.ts +94 -0
- package/src/shacl/SHACLShape.ts +66 -39
- package/src/typeDefs.ts +3 -5
- package/src/utils.ts +6 -6
- package/tsconfig.json +3 -7
- package/lib/src/model/query-surreal.d.ts +0 -44
- package/lib/src/model/query-surreal.js +0 -249
- package/lib/src/model/surreal-utils.js +0 -128
- package/shims/reflect-metadata.ts +0 -0
- package/shims/type-graphql.ts +0 -75
- package/src/PubSub.ts +0 -17
- package/src/agent/AgentResolver.ts +0 -263
- package/src/ai/AIResolver.ts +0 -372
- package/src/buildSchema.ts +0 -43
- package/src/expression/ExpressionResolver.ts +0 -64
- package/src/language/LanguageContext.ts +0 -37
- package/src/language/LanguageResolver.ts +0 -98
- package/src/model/Subject.ts +0 -159
- package/src/model/prolog-facts.ts +0 -145
- package/src/model/query-prolog.ts +0 -148
- package/src/model/query-surreal.ts +0 -280
- package/src/model/surreal-utils.ts +0 -147
- package/src/neighbourhood/NeighbourhoodResolver.ts +0 -100
- package/src/perspectives/PerspectiveResolver.ts +0 -372
- package/src/runtime/RuntimeResolver.ts +0 -617
- package/src/unwrapApolloResult.ts +0 -16
- package/tsconfig-browser.json +0 -82
|
@@ -9,170 +9,130 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
import {
|
|
14
|
-
import unwrapApolloResult from "../unwrapApolloResult";
|
|
12
|
+
var _AgentClient_apiClient, _AgentClient_baseUrl, _AgentClient_token, _AgentClient_appsChangedCallback, _AgentClient_updatedCallbacks, _AgentClient_agentStatusChangedCallbacks, _AgentClient_hostingUserInfoChangedCallbacks, _AgentClient_computeLogUpdatedCallbacks, _AgentClient_unsubscribers, _AgentClient_memCache, _AgentClient_persistent, _AgentClient_selfDid;
|
|
13
|
+
import { ApiClient } from "../apiClient";
|
|
15
14
|
import { Agent, } from "./Agent";
|
|
15
|
+
import { HostingUserInfo } from "../runtime/RuntimeTypes";
|
|
16
16
|
import { AgentStatus } from "./AgentStatus";
|
|
17
17
|
import { PerspectiveClient } from "../perspectives/PerspectiveClient";
|
|
18
|
-
|
|
19
|
-
did
|
|
20
|
-
directMessageLanguage
|
|
21
|
-
perspective {
|
|
22
|
-
links {
|
|
23
|
-
author, timestamp,
|
|
24
|
-
proof {
|
|
25
|
-
signature, key, valid, invalid
|
|
26
|
-
}
|
|
27
|
-
data {
|
|
28
|
-
source, predicate, target
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
const Apps_FIELDS = `
|
|
34
|
-
requestId
|
|
35
|
-
revoked
|
|
36
|
-
auth {
|
|
37
|
-
appName
|
|
38
|
-
appDesc
|
|
39
|
-
appUrl
|
|
40
|
-
appIconPath
|
|
41
|
-
capabilities {
|
|
42
|
-
with {
|
|
43
|
-
domain
|
|
44
|
-
pointers
|
|
45
|
-
}
|
|
46
|
-
can
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
`;
|
|
50
|
-
const AGENT_STATUS_FIELDS = `
|
|
51
|
-
isInitialized
|
|
52
|
-
isUnlocked
|
|
53
|
-
did
|
|
54
|
-
didDocument
|
|
55
|
-
error
|
|
56
|
-
`;
|
|
57
|
-
const ENTANGLEMENT_PROOF_FIELDS = `
|
|
58
|
-
did
|
|
59
|
-
didSigningKeyId
|
|
60
|
-
deviceKeyType
|
|
61
|
-
deviceKey
|
|
62
|
-
deviceKeySignedByDid
|
|
63
|
-
didSignedByDeviceKey
|
|
64
|
-
`;
|
|
65
|
-
const AGENT_SIGNATURE_FIELDS = `
|
|
66
|
-
signature
|
|
67
|
-
publicKey
|
|
68
|
-
`;
|
|
69
|
-
/**
|
|
70
|
-
* Provides access to all functions regarding the local agent,
|
|
71
|
-
* such as generating, locking, unlocking, importing the DID keystore,
|
|
72
|
-
* as well as updating the publicly shared Agent expression.
|
|
73
|
-
*/
|
|
18
|
+
import { createPersistentCache } from "../cache/PersistentCache";
|
|
74
19
|
export class AgentClient {
|
|
75
|
-
constructor(
|
|
76
|
-
|
|
20
|
+
constructor(baseUrl, token, subscribe = true, sharedApiClient) {
|
|
21
|
+
_AgentClient_apiClient.set(this, void 0);
|
|
22
|
+
_AgentClient_baseUrl.set(this, void 0);
|
|
23
|
+
_AgentClient_token.set(this, void 0);
|
|
77
24
|
_AgentClient_appsChangedCallback.set(this, void 0);
|
|
78
25
|
_AgentClient_updatedCallbacks.set(this, void 0);
|
|
79
26
|
_AgentClient_agentStatusChangedCallbacks.set(this, void 0);
|
|
80
|
-
|
|
27
|
+
_AgentClient_hostingUserInfoChangedCallbacks.set(this, void 0);
|
|
28
|
+
_AgentClient_computeLogUpdatedCallbacks.set(this, void 0);
|
|
29
|
+
_AgentClient_unsubscribers.set(this, void 0);
|
|
30
|
+
// ── byDID cache ────────────────────────────────────────────────────
|
|
31
|
+
// L1: in-memory promise cache with timestamps for TTL
|
|
32
|
+
_AgentClient_memCache.set(this, new Map());
|
|
33
|
+
// L2: persistent cache (IndexedDB in browser, NullCache in Node)
|
|
34
|
+
_AgentClient_persistent.set(this, void 0);
|
|
35
|
+
// Self-DID for event-driven invalidation (no TTL for own profile)
|
|
36
|
+
_AgentClient_selfDid.set(this, null);
|
|
37
|
+
__classPrivateFieldSet(this, _AgentClient_baseUrl, baseUrl, "f");
|
|
38
|
+
__classPrivateFieldSet(this, _AgentClient_token, token, "f");
|
|
39
|
+
__classPrivateFieldSet(this, _AgentClient_apiClient, sharedApiClient || new ApiClient(baseUrl, token), "f");
|
|
81
40
|
__classPrivateFieldSet(this, _AgentClient_updatedCallbacks, [], "f");
|
|
82
41
|
__classPrivateFieldSet(this, _AgentClient_agentStatusChangedCallbacks, [], "f");
|
|
83
42
|
__classPrivateFieldSet(this, _AgentClient_appsChangedCallback, [], "f");
|
|
43
|
+
__classPrivateFieldSet(this, _AgentClient_hostingUserInfoChangedCallbacks, [], "f");
|
|
44
|
+
__classPrivateFieldSet(this, _AgentClient_computeLogUpdatedCallbacks, [], "f");
|
|
45
|
+
__classPrivateFieldSet(this, _AgentClient_unsubscribers, [], "f");
|
|
46
|
+
__classPrivateFieldSet(this, _AgentClient_persistent, createPersistentCache('ad4m-agent-cache', 'agents'), "f");
|
|
84
47
|
if (subscribe) {
|
|
85
48
|
this.subscribeAgentUpdated();
|
|
86
49
|
this.subscribeAgentStatusChanged();
|
|
87
50
|
this.subscribeAppsChanged();
|
|
88
51
|
}
|
|
89
52
|
}
|
|
90
|
-
/**
|
|
91
|
-
* Returns the Agent expression of the local agent as it is shared
|
|
92
|
-
* publicly via the AgentLanguage.
|
|
93
|
-
*
|
|
94
|
-
* I.e. this is the users profile.
|
|
95
|
-
*/
|
|
96
53
|
async me() {
|
|
97
|
-
const
|
|
98
|
-
query: gql `query agent { agent { ${AGENT_SUBITEMS} } }`,
|
|
99
|
-
}));
|
|
54
|
+
const agent = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.get');
|
|
100
55
|
let agentObject = new Agent(agent.did, agent.perspective);
|
|
101
56
|
agentObject.directMessageLanguage = agent.directMessageLanguage;
|
|
57
|
+
// Auto-set selfDid so event-driven cache invalidation works
|
|
58
|
+
// without requiring apps to call setSelfDid() manually
|
|
59
|
+
if (agentObject.did && !__classPrivateFieldGet(this, _AgentClient_selfDid, "f")) {
|
|
60
|
+
__classPrivateFieldSet(this, _AgentClient_selfDid, agentObject.did, "f");
|
|
61
|
+
}
|
|
102
62
|
return agentObject;
|
|
103
63
|
}
|
|
104
64
|
async status() {
|
|
105
|
-
const
|
|
106
|
-
query: gql `query agentStatus {
|
|
107
|
-
agentStatus {
|
|
108
|
-
${AGENT_STATUS_FIELDS}
|
|
109
|
-
}
|
|
110
|
-
}`,
|
|
111
|
-
}));
|
|
65
|
+
const agentStatus = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.status');
|
|
112
66
|
return new AgentStatus(agentStatus);
|
|
113
67
|
}
|
|
114
68
|
async generate(passphrase) {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
$passphrase: String!
|
|
118
|
-
) {
|
|
119
|
-
agentGenerate(passphrase: $passphrase) {
|
|
120
|
-
${AGENT_STATUS_FIELDS}
|
|
121
|
-
}
|
|
122
|
-
}`,
|
|
123
|
-
variables: { passphrase },
|
|
124
|
-
}));
|
|
125
|
-
return new AgentStatus(agentGenerate);
|
|
69
|
+
const result = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.generate', { passphrase });
|
|
70
|
+
return new AgentStatus(result);
|
|
126
71
|
}
|
|
127
72
|
async import(args) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
mutation: gql `mutation agentImport(
|
|
131
|
-
$did: String!,
|
|
132
|
-
$didDocument: String!,
|
|
133
|
-
$keystore: String!,
|
|
134
|
-
$passphrase: String!
|
|
135
|
-
) {
|
|
136
|
-
agentImport(did: $did, didDocument: $didDocument, keystore: $keystore, passphrase: $passphrase) {
|
|
137
|
-
${AGENT_STATUS_FIELDS}
|
|
138
|
-
}
|
|
139
|
-
}`,
|
|
140
|
-
variables: { did, didDocument, keystore, passphrase },
|
|
141
|
-
}));
|
|
142
|
-
return new AgentStatus(agentImport);
|
|
73
|
+
const result = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.import', { ...args });
|
|
74
|
+
return new AgentStatus(result);
|
|
143
75
|
}
|
|
144
76
|
async lock(passphrase) {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
agentLock(passphrase: $passphrase) {
|
|
148
|
-
${AGENT_STATUS_FIELDS}
|
|
149
|
-
}
|
|
150
|
-
}`,
|
|
151
|
-
variables: { passphrase },
|
|
152
|
-
}));
|
|
153
|
-
return new AgentStatus(agentLock);
|
|
77
|
+
const result = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.lock', { passphrase });
|
|
78
|
+
return new AgentStatus(result);
|
|
154
79
|
}
|
|
155
80
|
async unlock(passphrase, holochain = true) {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
agentUnlock(passphrase: $passphrase, holochain: $holochain) {
|
|
159
|
-
${AGENT_STATUS_FIELDS}
|
|
160
|
-
}
|
|
161
|
-
}`,
|
|
162
|
-
variables: { passphrase, holochain },
|
|
163
|
-
}));
|
|
164
|
-
return new AgentStatus(agentUnlock);
|
|
81
|
+
const result = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.unlock', { passphrase, holochain });
|
|
82
|
+
return new AgentStatus(result);
|
|
165
83
|
}
|
|
166
84
|
async byDID(did) {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
85
|
+
const now = Date.now();
|
|
86
|
+
const cached = __classPrivateFieldGet(this, _AgentClient_memCache, "f").get(did);
|
|
87
|
+
if (cached) {
|
|
88
|
+
const isSelf = did === __classPrivateFieldGet(this, _AgentClient_selfDid, "f");
|
|
89
|
+
// Self-DID: L1 always valid (event-driven invalidation)
|
|
90
|
+
// Remote DID: L1 valid within TTL
|
|
91
|
+
if (isSelf || (now - cached.ts) < AgentClient.REMOTE_AGENT_TTL_MS) {
|
|
92
|
+
return cached.promise;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Deduplicate: store the promise immediately so concurrent calls share one RPC
|
|
96
|
+
const promise = (async () => {
|
|
97
|
+
// L2: check persistent cache before network
|
|
98
|
+
const persisted = await __classPrivateFieldGet(this, _AgentClient_persistent, "f").get(did);
|
|
99
|
+
if (persisted) {
|
|
100
|
+
return persisted;
|
|
101
|
+
}
|
|
102
|
+
// L3: network fetch
|
|
103
|
+
const result = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.byDid', { did });
|
|
104
|
+
__classPrivateFieldGet(this, _AgentClient_persistent, "f").put(did, result); // fire-and-forget write to L2
|
|
105
|
+
return result;
|
|
106
|
+
})();
|
|
107
|
+
__classPrivateFieldGet(this, _AgentClient_memCache, "f").set(did, { promise, ts: now });
|
|
108
|
+
// Clean up on failure so next call retries
|
|
109
|
+
promise.catch(() => {
|
|
110
|
+
if (__classPrivateFieldGet(this, _AgentClient_memCache, "f").get(did)?.promise === promise) {
|
|
111
|
+
__classPrivateFieldGet(this, _AgentClient_memCache, "f").delete(did);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return promise;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Set the current agent's own DID.
|
|
118
|
+
* The self-DID receives event-driven invalidation and is never TTL-expired.
|
|
119
|
+
*/
|
|
120
|
+
setSelfDid(did) {
|
|
121
|
+
__classPrivateFieldSet(this, _AgentClient_selfDid, did, "f");
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Invalidate a specific DID's cache entry in both L1 and L2.
|
|
125
|
+
*/
|
|
126
|
+
invalidateByDid(did) {
|
|
127
|
+
__classPrivateFieldGet(this, _AgentClient_memCache, "f").delete(did);
|
|
128
|
+
__classPrivateFieldGet(this, _AgentClient_persistent, "f").delete(did); // fire-and-forget
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Clear the entire L1 (memory) byDID cache.
|
|
132
|
+
* L2 (IndexedDB) is preserved — agent data remains valid across sessions.
|
|
133
|
+
*/
|
|
134
|
+
clearByDidCache() {
|
|
135
|
+
__classPrivateFieldGet(this, _AgentClient_memCache, "f").clear();
|
|
176
136
|
}
|
|
177
137
|
async updatePublicPerspective(perspective) {
|
|
178
138
|
const cleanedPerspective = JSON.parse(JSON.stringify(perspective));
|
|
@@ -183,99 +143,58 @@ export class AgentClient {
|
|
|
183
143
|
delete link.proof.__typename;
|
|
184
144
|
delete link.status;
|
|
185
145
|
});
|
|
186
|
-
const
|
|
187
|
-
mutation: gql `mutation agentUpdatePublicPerspective($perspective: PerspectiveInput!) {
|
|
188
|
-
agentUpdatePublicPerspective(perspective: $perspective) {
|
|
189
|
-
${AGENT_SUBITEMS}
|
|
190
|
-
}
|
|
191
|
-
}`,
|
|
192
|
-
variables: { perspective: cleanedPerspective },
|
|
193
|
-
}));
|
|
194
|
-
const a = agentUpdatePublicPerspective;
|
|
146
|
+
const a = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { publicPerspective: cleanedPerspective });
|
|
195
147
|
const agent = new Agent(a.did, a.perspective);
|
|
196
148
|
agent.directMessageLanguage = a.directMessageLanguage;
|
|
149
|
+
// Immediately update byDID cache so subsequent byDID() calls
|
|
150
|
+
// return fresh data without waiting for the subscription event
|
|
151
|
+
if (agent.did) {
|
|
152
|
+
__classPrivateFieldGet(this, _AgentClient_memCache, "f").set(agent.did, { promise: Promise.resolve(agent), ts: Date.now() });
|
|
153
|
+
__classPrivateFieldGet(this, _AgentClient_persistent, "f").put(agent.did, agent); // fire-and-forget
|
|
154
|
+
}
|
|
197
155
|
return agent;
|
|
198
156
|
}
|
|
199
157
|
async mutatePublicPerspective(mutations) {
|
|
200
|
-
const perspectiveClient = new PerspectiveClient(__classPrivateFieldGet(this,
|
|
201
|
-
const agentClient = new AgentClient(__classPrivateFieldGet(this, _AgentClient_apolloClient, "f"));
|
|
202
|
-
//Create the proxy perspective and load existing links
|
|
158
|
+
const perspectiveClient = new PerspectiveClient(__classPrivateFieldGet(this, _AgentClient_baseUrl, "f"), __classPrivateFieldGet(this, _AgentClient_token, "f"));
|
|
203
159
|
const proxyPerspective = await perspectiveClient.add("Agent Perspective Proxy");
|
|
204
|
-
const agentMe = await
|
|
160
|
+
const agentMe = await this.me();
|
|
205
161
|
if (agentMe.perspective) {
|
|
206
162
|
await proxyPerspective.loadSnapshot(agentMe.perspective);
|
|
207
163
|
}
|
|
208
|
-
//Make the mutations on the proxy perspective
|
|
209
164
|
for (const addition of mutations.additions) {
|
|
210
165
|
await proxyPerspective.add(addition);
|
|
211
166
|
}
|
|
212
167
|
for (const removal of mutations.removals) {
|
|
213
168
|
await proxyPerspective.remove(removal);
|
|
214
169
|
}
|
|
215
|
-
//Get the snapshot of the proxy perspective
|
|
216
170
|
const snapshot = await proxyPerspective.snapshot();
|
|
217
|
-
//Update the users public perspective
|
|
218
171
|
const agent = await this.updatePublicPerspective(snapshot);
|
|
219
|
-
//Cleanup and return
|
|
220
172
|
await perspectiveClient.remove(proxyPerspective.uuid);
|
|
221
173
|
return agent;
|
|
222
174
|
}
|
|
223
175
|
async updateDirectMessageLanguage(directMessageLanguage) {
|
|
224
|
-
const
|
|
225
|
-
mutation: gql `mutation agentUpdateDirectMessageLanguage($directMessageLanguage: String!) {
|
|
226
|
-
agentUpdateDirectMessageLanguage(directMessageLanguage: $directMessageLanguage) {
|
|
227
|
-
${AGENT_SUBITEMS}
|
|
228
|
-
}
|
|
229
|
-
}`,
|
|
230
|
-
variables: { directMessageLanguage },
|
|
231
|
-
}));
|
|
232
|
-
const a = agentUpdateDirectMessageLanguage;
|
|
176
|
+
const a = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.updateProfile', { dmLanguage: directMessageLanguage });
|
|
233
177
|
const agent = new Agent(a.did, a.perspective);
|
|
234
178
|
agent.directMessageLanguage = a.directMessageLanguage;
|
|
179
|
+
// Immediately update byDID cache so subsequent byDID() calls
|
|
180
|
+
// return fresh data without waiting for the subscription event
|
|
181
|
+
if (agent.did) {
|
|
182
|
+
__classPrivateFieldGet(this, _AgentClient_memCache, "f").set(agent.did, { promise: Promise.resolve(agent), ts: Date.now() });
|
|
183
|
+
__classPrivateFieldGet(this, _AgentClient_persistent, "f").put(agent.did, agent); // fire-and-forget
|
|
184
|
+
}
|
|
235
185
|
return agent;
|
|
236
186
|
}
|
|
237
187
|
async addEntanglementProofs(proofs) {
|
|
238
|
-
|
|
239
|
-
mutation: gql `mutation agentAddEntanglementProofs($proofs: [EntanglementProofInput!]!) {
|
|
240
|
-
agentAddEntanglementProofs(proofs: $proofs) {
|
|
241
|
-
${ENTANGLEMENT_PROOF_FIELDS}
|
|
242
|
-
}
|
|
243
|
-
}`,
|
|
244
|
-
variables: { proofs },
|
|
245
|
-
}));
|
|
246
|
-
return agentAddEntanglementProofs;
|
|
188
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.addEntanglementProofs', { proofs });
|
|
247
189
|
}
|
|
248
190
|
async deleteEntanglementProofs(proofs) {
|
|
249
|
-
|
|
250
|
-
mutation: gql `mutation agentDeleteEntanglementProofs($proofs: [EntanglementProofInput!]!) {
|
|
251
|
-
agentDeleteEntanglementProofs(proofs: $proofs) {
|
|
252
|
-
${ENTANGLEMENT_PROOF_FIELDS}
|
|
253
|
-
}
|
|
254
|
-
}`,
|
|
255
|
-
variables: { proofs },
|
|
256
|
-
}));
|
|
257
|
-
return agentDeleteEntanglementProofs;
|
|
191
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.deleteEntanglementProofs', { proofs });
|
|
258
192
|
}
|
|
259
193
|
async getEntanglementProofs() {
|
|
260
|
-
|
|
261
|
-
query: gql `query agentGetEntanglementProofs {
|
|
262
|
-
agentGetEntanglementProofs {
|
|
263
|
-
${ENTANGLEMENT_PROOF_FIELDS}
|
|
264
|
-
}
|
|
265
|
-
}`,
|
|
266
|
-
}));
|
|
267
|
-
return agentGetEntanglementProofs;
|
|
194
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.getEntanglementProofs');
|
|
268
195
|
}
|
|
269
196
|
async entanglementProofPreFlight(deviceKey, deviceKeyType) {
|
|
270
|
-
|
|
271
|
-
mutation: gql `mutation agentEntanglementProofPreFlight($deviceKey: String!, $deviceKeyType: String!) {
|
|
272
|
-
agentEntanglementProofPreFlight(deviceKey: $deviceKey, deviceKeyType: $deviceKeyType) {
|
|
273
|
-
${ENTANGLEMENT_PROOF_FIELDS}
|
|
274
|
-
}
|
|
275
|
-
}`,
|
|
276
|
-
variables: { deviceKey, deviceKeyType },
|
|
277
|
-
}));
|
|
278
|
-
return agentEntanglementProofPreFlight;
|
|
197
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.entanglementProofPreflight', { deviceKey, deviceKeyType });
|
|
279
198
|
}
|
|
280
199
|
addUpdatedListener(listener) {
|
|
281
200
|
__classPrivateFieldGet(this, _AgentClient_updatedCallbacks, "f").push(listener);
|
|
@@ -284,228 +203,116 @@ export class AgentClient {
|
|
|
284
203
|
__classPrivateFieldGet(this, _AgentClient_appsChangedCallback, "f").push(listener);
|
|
285
204
|
}
|
|
286
205
|
subscribeAgentUpdated() {
|
|
287
|
-
__classPrivateFieldGet(this,
|
|
288
|
-
.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
},
|
|
301
|
-
error: (e) => console.error(e),
|
|
206
|
+
const unsub = __classPrivateFieldGet(this, _AgentClient_apiClient, "f").subscribe((data) => {
|
|
207
|
+
if (data.type === 'agent-updated') {
|
|
208
|
+
const agent = (data.agent || data);
|
|
209
|
+
// Update L1 and L2 cache from the event payload
|
|
210
|
+
if (agent.did) {
|
|
211
|
+
__classPrivateFieldGet(this, _AgentClient_memCache, "f").set(agent.did, {
|
|
212
|
+
promise: Promise.resolve(agent),
|
|
213
|
+
ts: Date.now(),
|
|
214
|
+
});
|
|
215
|
+
__classPrivateFieldGet(this, _AgentClient_persistent, "f").put(agent.did, agent); // fire-and-forget
|
|
216
|
+
}
|
|
217
|
+
__classPrivateFieldGet(this, _AgentClient_updatedCallbacks, "f").forEach((cb) => cb(agent));
|
|
218
|
+
}
|
|
302
219
|
});
|
|
220
|
+
__classPrivateFieldGet(this, _AgentClient_unsubscribers, "f").push(unsub);
|
|
303
221
|
}
|
|
304
222
|
subscribeAppsChanged() {
|
|
305
|
-
__classPrivateFieldGet(this,
|
|
306
|
-
.
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
${Apps_FIELDS}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
`,
|
|
313
|
-
})
|
|
314
|
-
.subscribe({
|
|
315
|
-
next: (result) => {
|
|
316
|
-
__classPrivateFieldGet(this, _AgentClient_appsChangedCallback, "f").forEach((cb) => {
|
|
317
|
-
cb();
|
|
318
|
-
});
|
|
319
|
-
},
|
|
320
|
-
error: (e) => console.error(e),
|
|
223
|
+
const unsub = __classPrivateFieldGet(this, _AgentClient_apiClient, "f").subscribe((data) => {
|
|
224
|
+
if (data.type === 'apps-changed') {
|
|
225
|
+
__classPrivateFieldGet(this, _AgentClient_appsChangedCallback, "f").forEach((cb) => cb());
|
|
226
|
+
}
|
|
321
227
|
});
|
|
228
|
+
__classPrivateFieldGet(this, _AgentClient_unsubscribers, "f").push(unsub);
|
|
322
229
|
}
|
|
323
230
|
addAgentStatusChangedListener(listener) {
|
|
324
231
|
__classPrivateFieldGet(this, _AgentClient_agentStatusChangedCallbacks, "f").push(listener);
|
|
325
232
|
}
|
|
326
233
|
subscribeAgentStatusChanged() {
|
|
327
|
-
__classPrivateFieldGet(this,
|
|
328
|
-
.
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
`,
|
|
333
|
-
})
|
|
334
|
-
.subscribe({
|
|
335
|
-
next: (result) => {
|
|
336
|
-
const agent = result.data.agentStatusChanged;
|
|
337
|
-
__classPrivateFieldGet(this, _AgentClient_agentStatusChangedCallbacks, "f").forEach((cb) => {
|
|
338
|
-
cb(agent);
|
|
339
|
-
});
|
|
340
|
-
},
|
|
341
|
-
error: (e) => console.error(e),
|
|
234
|
+
const unsub = __classPrivateFieldGet(this, _AgentClient_apiClient, "f").subscribe((data) => {
|
|
235
|
+
if (data.type === 'agent-status-changed') {
|
|
236
|
+
__classPrivateFieldGet(this, _AgentClient_agentStatusChangedCallbacks, "f").forEach((cb) => cb((data.agent || data)));
|
|
237
|
+
}
|
|
342
238
|
});
|
|
239
|
+
__classPrivateFieldGet(this, _AgentClient_unsubscribers, "f").push(unsub);
|
|
240
|
+
}
|
|
241
|
+
addHostingUserInfoChangedListener(listener) {
|
|
242
|
+
__classPrivateFieldGet(this, _AgentClient_hostingUserInfoChangedCallbacks, "f").push(listener);
|
|
243
|
+
}
|
|
244
|
+
subscribeHostingUserInfoChanged() {
|
|
245
|
+
const unsub = __classPrivateFieldGet(this, _AgentClient_apiClient, "f").subscribe((data) => {
|
|
246
|
+
if (data.type === 'hosting-user-info-changed') {
|
|
247
|
+
__classPrivateFieldGet(this, _AgentClient_hostingUserInfoChangedCallbacks, "f").forEach((cb) => cb((data.info || data)));
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
__classPrivateFieldGet(this, _AgentClient_unsubscribers, "f").push(unsub);
|
|
251
|
+
}
|
|
252
|
+
addComputeLogUpdatedListener(listener) {
|
|
253
|
+
__classPrivateFieldGet(this, _AgentClient_computeLogUpdatedCallbacks, "f").push(listener);
|
|
254
|
+
}
|
|
255
|
+
subscribeComputeLogUpdated() {
|
|
256
|
+
const unsub = __classPrivateFieldGet(this, _AgentClient_apiClient, "f").subscribe((data) => {
|
|
257
|
+
if (data.type === 'compute-log-updated') {
|
|
258
|
+
__classPrivateFieldGet(this, _AgentClient_computeLogUpdatedCallbacks, "f").forEach((cb) => cb((data.entry || data)));
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
__classPrivateFieldGet(this, _AgentClient_unsubscribers, "f").push(unsub);
|
|
343
262
|
}
|
|
344
263
|
async requestCapability(authInfo) {
|
|
345
|
-
|
|
346
|
-
mutation: gql `
|
|
347
|
-
mutation agentRequestCapability($authInfo: AuthInfoInput!) {
|
|
348
|
-
agentRequestCapability(authInfo: $authInfo)
|
|
349
|
-
}
|
|
350
|
-
`,
|
|
351
|
-
variables: { authInfo },
|
|
352
|
-
}));
|
|
353
|
-
return agentRequestCapability;
|
|
264
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.requestCapability', { authInfo });
|
|
354
265
|
}
|
|
355
266
|
async permitCapability(auth) {
|
|
356
|
-
|
|
357
|
-
mutation: gql `
|
|
358
|
-
mutation agentPermitCapability($auth: String!) {
|
|
359
|
-
agentPermitCapability(auth: $auth)
|
|
360
|
-
}
|
|
361
|
-
`,
|
|
362
|
-
variables: { auth },
|
|
363
|
-
}));
|
|
364
|
-
return agentPermitCapability;
|
|
267
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.permitCapability', { auth });
|
|
365
268
|
}
|
|
366
269
|
async generateJwt(requestId, rand) {
|
|
367
|
-
|
|
368
|
-
mutation: gql `
|
|
369
|
-
mutation agentGenerateJwt($requestId: String!, $rand: String!) {
|
|
370
|
-
agentGenerateJwt(requestId: $requestId, rand: $rand)
|
|
371
|
-
}
|
|
372
|
-
`,
|
|
373
|
-
variables: { requestId, rand },
|
|
374
|
-
}));
|
|
375
|
-
return agentGenerateJwt;
|
|
270
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.generateJwt', { requestId, rand });
|
|
376
271
|
}
|
|
377
272
|
async getApps() {
|
|
378
|
-
|
|
379
|
-
mutation: gql `query agentGetApps {
|
|
380
|
-
agentGetApps {
|
|
381
|
-
${Apps_FIELDS}
|
|
382
|
-
}
|
|
383
|
-
}`,
|
|
384
|
-
}));
|
|
385
|
-
return agentGetApps;
|
|
273
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.getApps');
|
|
386
274
|
}
|
|
387
275
|
async removeApp(requestId) {
|
|
388
|
-
|
|
389
|
-
mutation: gql `mutation agentRemoveApp($requestId: String!) {
|
|
390
|
-
agentRemoveApp(requestId: $requestId) {
|
|
391
|
-
${Apps_FIELDS}
|
|
392
|
-
}
|
|
393
|
-
}`,
|
|
394
|
-
variables: { requestId },
|
|
395
|
-
}));
|
|
396
|
-
return agentRemoveApp;
|
|
276
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.removeApp', { id: requestId });
|
|
397
277
|
}
|
|
398
278
|
async revokeToken(requestId) {
|
|
399
|
-
|
|
400
|
-
mutation: gql `mutation agentRevokeToken($requestId: String!) {
|
|
401
|
-
agentRevokeToken(requestId: $requestId) {
|
|
402
|
-
${Apps_FIELDS}
|
|
403
|
-
}
|
|
404
|
-
}`,
|
|
405
|
-
variables: { requestId },
|
|
406
|
-
}));
|
|
407
|
-
return agentRevokeToken;
|
|
279
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.revokeToken', { token: requestId });
|
|
408
280
|
}
|
|
409
281
|
async isLocked() {
|
|
410
|
-
|
|
411
|
-
mutation: gql `
|
|
412
|
-
query agentIsLocked {
|
|
413
|
-
agentIsLocked
|
|
414
|
-
}
|
|
415
|
-
`,
|
|
416
|
-
}));
|
|
417
|
-
return agentIsLocked;
|
|
282
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.isLocked');
|
|
418
283
|
}
|
|
419
284
|
async signMessage(message) {
|
|
420
|
-
|
|
421
|
-
mutation: gql `mutation agentSignMessage($message: String!) {
|
|
422
|
-
agentSignMessage(message: $message) {
|
|
423
|
-
${AGENT_SIGNATURE_FIELDS}
|
|
424
|
-
}
|
|
425
|
-
}`,
|
|
426
|
-
variables: { message },
|
|
427
|
-
}));
|
|
428
|
-
return agentSignMessage;
|
|
285
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('agent.sign', { message });
|
|
429
286
|
}
|
|
430
287
|
// Multi-user methods
|
|
431
288
|
async createUser(email, password, appInfo) {
|
|
432
|
-
|
|
433
|
-
mutation: gql `mutation runtimeCreateUser($email: String!, $password: String!, $appInfo: AuthInfoInput) {
|
|
434
|
-
runtimeCreateUser(email: $email, password: $password, appInfo: $appInfo) {
|
|
435
|
-
did
|
|
436
|
-
success
|
|
437
|
-
error
|
|
438
|
-
}
|
|
439
|
-
}`,
|
|
440
|
-
variables: { email, password, appInfo },
|
|
441
|
-
}));
|
|
442
|
-
return runtimeCreateUser;
|
|
289
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('user.create', { email, password, appInfo });
|
|
443
290
|
}
|
|
444
291
|
async loginUser(email, password) {
|
|
445
|
-
|
|
446
|
-
mutation: gql `mutation runtimeLoginUser($email: String!, $password: String!) {
|
|
447
|
-
runtimeLoginUser(email: $email, password: $password)
|
|
448
|
-
}`,
|
|
449
|
-
variables: { email, password },
|
|
450
|
-
}));
|
|
451
|
-
return runtimeLoginUser;
|
|
292
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('user.login', { email, password });
|
|
452
293
|
}
|
|
453
294
|
async requestLoginVerification(email, appInfo) {
|
|
454
|
-
|
|
455
|
-
mutation: gql `mutation runtimeRequestLoginVerification($email: String!, $appInfo: AuthInfoInput) {
|
|
456
|
-
runtimeRequestLoginVerification(email: $email, appInfo: $appInfo) {
|
|
457
|
-
success
|
|
458
|
-
message
|
|
459
|
-
requiresPassword
|
|
460
|
-
isExistingUser
|
|
461
|
-
}
|
|
462
|
-
}`,
|
|
463
|
-
variables: { email, appInfo },
|
|
464
|
-
}));
|
|
465
|
-
return runtimeRequestLoginVerification;
|
|
295
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('user.requestVerification', { email, appInfo });
|
|
466
296
|
}
|
|
467
297
|
async verifyEmailCode(email, code, verificationType) {
|
|
468
|
-
|
|
469
|
-
mutation: gql `mutation runtimeVerifyEmailCode($email: String!, $code: String!, $verificationType: String!) {
|
|
470
|
-
runtimeVerifyEmailCode(email: $email, code: $code, verificationType: $verificationType)
|
|
471
|
-
}`,
|
|
472
|
-
variables: { email, code, verificationType },
|
|
473
|
-
}));
|
|
474
|
-
return runtimeVerifyEmailCode;
|
|
298
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('user.verifyEmail', { email, code, verificationType });
|
|
475
299
|
}
|
|
476
300
|
// Hosting methods
|
|
477
301
|
async hostingUserInfo() {
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
}
|
|
485
|
-
}`,
|
|
486
|
-
}));
|
|
487
|
-
return runtimeHostingUserInfo;
|
|
302
|
+
const resp = await __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('hosting.info');
|
|
303
|
+
const info = resp?.userInfo || resp;
|
|
304
|
+
return new HostingUserInfo(info.email || '', info.freeAccess ? 'unlimited' : String(info.credits ?? info.remainingCredits ?? '0'), info.hotWalletAddress || undefined, !!info.freeAccess);
|
|
305
|
+
}
|
|
306
|
+
async computeLog(since, limit, userEmail) {
|
|
307
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('runtime.computeLog', { since, limit, userEmail });
|
|
488
308
|
}
|
|
489
309
|
async setHotWalletAddress(address) {
|
|
490
|
-
|
|
491
|
-
mutation: gql `mutation runtimeSetHotWalletAddress($address: String!) {
|
|
492
|
-
runtimeSetHotWalletAddress(address: $address)
|
|
493
|
-
}`,
|
|
494
|
-
variables: { address },
|
|
495
|
-
}));
|
|
496
|
-
return runtimeSetHotWalletAddress;
|
|
310
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('hosting.setHotWallet', { address });
|
|
497
311
|
}
|
|
498
312
|
async requestPayment(amountHOT) {
|
|
499
|
-
|
|
500
|
-
mutation: gql `mutation runtimeRequestPayment($amountHOT: String!) {
|
|
501
|
-
runtimeRequestPayment(amountHOT: $amountHOT) {
|
|
502
|
-
success
|
|
503
|
-
message
|
|
504
|
-
}
|
|
505
|
-
}`,
|
|
506
|
-
variables: { amountHOT },
|
|
507
|
-
}));
|
|
508
|
-
return runtimeRequestPayment;
|
|
313
|
+
return __classPrivateFieldGet(this, _AgentClient_apiClient, "f").call('hosting.requestPayment', { amountHOT });
|
|
509
314
|
}
|
|
510
315
|
}
|
|
511
|
-
|
|
316
|
+
_AgentClient_apiClient = new WeakMap(), _AgentClient_baseUrl = new WeakMap(), _AgentClient_token = new WeakMap(), _AgentClient_appsChangedCallback = new WeakMap(), _AgentClient_updatedCallbacks = new WeakMap(), _AgentClient_agentStatusChangedCallbacks = new WeakMap(), _AgentClient_hostingUserInfoChangedCallbacks = new WeakMap(), _AgentClient_computeLogUpdatedCallbacks = new WeakMap(), _AgentClient_unsubscribers = new WeakMap(), _AgentClient_memCache = new WeakMap(), _AgentClient_persistent = new WeakMap(), _AgentClient_selfDid = new WeakMap();
|
|
317
|
+
/** TTL for remote (non-self) agent profiles in L1 cache (ms). */
|
|
318
|
+
AgentClient.REMOTE_AGENT_TTL_MS = 5 * 60000; // 5 minutes
|