akanjs 3.2.0-rc.9 → 3.2.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/ARCHITECTURE.md +41 -38
- package/CHANGELOG.md +0 -680
- package/CONTRIBUTING.md +3 -0
- package/base/base.ts +2 -1
- package/client/clientRuntime.ts +1 -0
- package/client/cn.ts +2 -2
- package/client/csrTypes.ts +2 -0
- package/client/frameConfig.ts +1 -0
- package/client/index.ts +249 -26
- package/client/locale.ts +1 -0
- package/client/makePageProto.tsx +12 -85
- package/client/nativeThemeColor.ts +51 -0
- package/client/route/PageDefinition.ts +11 -3
- package/client/route/RouteDefinition.ts +24 -7
- package/client/route/RouteGuards.ts +2 -1
- package/client/route/RouteHead.ts +4 -1
- package/client/route/routeArgs.ts +8 -0
- package/client/router.ts +17 -2
- package/client/rscNavigation.ts +1 -0
- package/client/viewportMeta.ts +86 -6
- package/common/CodeTranscript.ts +1 -1
- package/common/Logger.ts +4 -2
- package/common/PipelinePlanSchema.ts +2 -2
- package/common/clientAddress.ts +14 -0
- package/common/err.ts +122 -0
- package/common/eventStream.ts +71 -19
- package/common/facetBarrel.ts +38 -0
- package/common/index.ts +7 -0
- package/common/isGuardRefusal.ts +14 -0
- package/common/loggedFailure.ts +11 -0
- package/common/mcpExposure.ts +17 -4
- package/common/pipelinePlan.ts +1 -1
- package/common/routeConvention.ts +3 -1
- package/common/types.ts +18 -1
- package/constant/constantRegistry.ts +4 -8
- package/constant/crystalize.ts +1 -2
- package/constant/getDefault.ts +1 -1
- package/constant/immerify.ts +1 -1
- package/constant/index.ts +78 -21
- package/constant/purify.ts +4 -9
- package/constant/serialize.ts +4 -2
- package/constant/types.ts +1 -0
- package/constant/via.ts +1 -2
- package/dictionary/agent.dictionary.ts +12 -0
- package/dictionary/base.dictionary.ts +11 -0
- package/dictionary/locale.ts +1 -1
- package/dictionary/trans.ts +14 -97
- package/document/dataLoader.ts +39 -19
- package/document/databaseRegistry.ts +2 -1
- package/document/documentSchema.ts +1 -0
- package/document/filterMeta.ts +4 -1
- package/document/into.ts +2 -1
- package/document/loaderInfo.ts +2 -1
- package/document/noDocumentError.ts +4 -1
- package/document/queryEvaluator.ts +1 -1
- package/document/types.ts +1 -1
- package/fetch/client/fetchClient.ts +83 -269
- package/fetch/client/fetchClientTypes.ts +49 -0
- package/fetch/client/httpClient.ts +3 -2
- package/fetch/client/remoteError.ts +4 -20
- package/fetch/client/requestScope.ts +41 -0
- package/fetch/client/signalCatalog.ts +131 -0
- package/fetch/client/wsClient.ts +82 -6
- package/fetch/requestStorage.ts +1 -0
- package/package.json +1 -1
- package/server/agentHooks.ts +16 -0
- package/server/akanApp.ts +110 -1272
- package/server/akanOption.ts +30 -3
- package/server/akanServer.ts +179 -674
- package/server/artifact/builderRpc.ts +14 -6
- package/server/artifact/routeSeedIndexStore.ts +4 -2
- package/server/assetHeaders.ts +6 -0
- package/server/console.ts +6 -4
- package/server/decorators.ts +2 -2
- package/server/di/diLifecycle.ts +24 -35
- package/server/di/predefinedAdaptor.ts +24 -1
- package/server/di/resolveHierarchy.ts +19 -6
- package/server/di/stageFailedError.ts +10 -0
- package/server/di/utils.ts +8 -3
- package/server/ed25519Key.ts +31 -15
- package/server/flightRowReader.ts +106 -20
- package/server/gateway/childSupervisor.ts +328 -0
- package/server/gateway/devHostChannel.ts +47 -0
- package/server/gateway/gatewayChildren.ts +161 -0
- package/server/gateway/gatewayConfig.ts +182 -0
- package/server/gateway/gatewayHttpProxy.ts +231 -0
- package/server/gateway/gatewayLogging.ts +111 -0
- package/server/gateway/gatewayRooms.ts +141 -0
- package/server/gateway/gatewayStatus.ts +122 -0
- package/server/gateway/gatewayStatusPage.ts +54 -0
- package/server/gateway/gatewayWebSocketRelay.ts +149 -0
- package/server/gateway/listeningPort.ts +13 -0
- package/server/hmr/devHmrController.ts +10 -1
- package/server/htmlResultCache.ts +234 -0
- package/server/imageOptimizer.ts +4 -1
- package/server/index.ts +281 -17
- package/server/lifecycle/parentChannel.ts +79 -0
- package/server/lifecycle/shutdownManager.ts +6 -3
- package/server/lifecycle/startGuard.ts +90 -0
- package/server/logging/hubFileSink.ts +1 -0
- package/server/logging/logControlSocket.ts +42 -3
- package/server/logging/logHub.ts +0 -0
- package/server/logging/logStdoutWriter.ts +3 -1
- package/server/logging/logStreamRoute.ts +28 -11
- package/server/logging/serverLogging.ts +74 -0
- package/server/machine/machineToken.ts +10 -3
- package/server/mcp/AgentTools.ts +149 -0
- package/server/mcp/AgentToolsAccount.ts +26 -0
- package/server/mcp/McpApps.ts +32 -2
- package/server/mcp/McpDispatcher.ts +44 -30
- package/server/mcp/McpPages.ts +34 -12
- package/server/mcp/McpRateLimiter.ts +14 -0
- package/server/mcp/McpRouter.ts +4 -2
- package/server/mcp/McpUiSession.ts +2 -1
- package/server/mcp/index.ts +1 -0
- package/server/migration/migrationCommand.ts +31 -2
- package/server/migration/migrationRunner.ts +36 -1
- package/server/nativeFile.ts +39 -12
- package/server/nativeSecret.ts +12 -3
- package/server/oauth/OAuthClientIdMetadata.ts +2 -2
- package/server/ops/migrateJobs.ts +2 -2
- package/server/ops/opsCommand.ts +1 -1
- package/server/ops/opsRoute.ts +5 -1
- package/server/ops/opsToken.ts +3 -1
- package/server/remote/RemoteFetch.ts +161 -0
- package/server/remote/RemoteMcp.ts +242 -0
- package/server/remote/RemoteOAuth.ts +270 -0
- package/server/remote/RemoteSource.ts +214 -0
- package/server/remote/index.ts +17 -0
- package/server/remote/remoteError.ts +19 -0
- package/server/resolver/CascadeRunner.ts +20 -8
- package/server/resolver/database.resolver.ts +10 -417
- package/server/resolver/databaseModelInstance.ts +209 -0
- package/server/resolver/invalidSignal.ts +7 -0
- package/server/resolver/livePause.ts +34 -0
- package/server/resolver/modelFacade.ts +136 -0
- package/server/resolver/modelLoaders.ts +84 -0
- package/server/resolver/modelSchema.ts +52 -0
- package/server/resolver/roomAdmission.ts +68 -0
- package/server/resolver/signal.resolver.ts +45 -111
- package/server/resolver/sliceCrud.ts +63 -0
- package/server/resolver/timedQuery.ts +16 -0
- package/server/resolver/websocketOf.ts +2 -1
- package/server/routeElementComposer.tsx +45 -6
- package/server/routeTreeBuilder.ts +23 -9
- package/server/routing/apiRouter.ts +53 -28
- package/server/routing/builtinRoutes.ts +194 -0
- package/server/routing/localRooms.ts +34 -0
- package/server/routing/roomReplay.ts +2 -2
- package/server/routing/serverLimits.ts +4 -1
- package/server/routing/serverListener.ts +194 -0
- package/server/rscClient.tsx +121 -204
- package/server/rscClientCache.ts +165 -0
- package/server/rscClientChunks.ts +126 -8
- package/server/rscClientFetch.ts +3 -1
- package/server/rscClientPatch.ts +78 -15
- package/server/rscDocumentHead.tsx +177 -0
- package/server/rscFlightRenderer.ts +83 -0
- package/server/rscFlightStream.ts +259 -0
- package/server/rscHostReloads.ts +238 -0
- package/server/rscHostRenderStream.ts +297 -0
- package/server/rscHostRequests.ts +158 -0
- package/server/rscHttp.ts +18 -6
- package/server/rscNavigationState.ts +24 -1
- package/server/rscPagePrompts.ts +65 -14
- package/server/rscPrefetchCache.ts +5 -1
- package/server/rscRenderControl.ts +33 -0
- package/server/rscRenderFallbacks.ts +299 -0
- package/server/rscRenderHandler.ts +439 -0
- package/server/rscRenderStats.ts +49 -0
- package/server/rscResultCaches.ts +74 -0
- package/server/rscRouteDocument.tsx +316 -0
- package/server/rscSegmentOutletReference.ts +5 -1
- package/server/rscStaticApp.tsx +73 -0
- package/server/rscWorker.tsx +112 -1341
- package/server/rscWorkerHost.ts +175 -803
- package/server/rscWorkerProcess.ts +155 -0
- package/server/rscWorkerRecycler.ts +128 -0
- package/server/serverConfig.ts +128 -0
- package/server/serverMetrics.ts +52 -0
- package/server/sitemap.ts +1 -0
- package/server/ssrFromRscRenderer.tsx +20 -20
- package/server/ssrStaticApp.tsx +243 -0
- package/server/webArtifact.ts +86 -0
- package/server/webAssetRoutes.ts +84 -0
- package/server/webCsrSurface.ts +172 -0
- package/server/webDocumentRoute.ts +180 -0
- package/server/webRouteContext.ts +232 -0
- package/server/webRouter.ts +129 -1165
- package/server/webRscRoute.ts +155 -0
- package/server/webSiteFiles.ts +139 -0
- package/server/webStaticApp.ts +62 -0
- package/server/wellKnownRoutes.ts +73 -0
- package/service/agent.service.ts +14 -2
- package/service/agentAccounts.ts +19 -0
- package/service/agentLoop/agentLoop.ts +550 -0
- package/service/agentLoop/agentLoopTypes.ts +220 -0
- package/service/agentLoop/deltaStream.ts +40 -0
- package/service/agentLoop/loopAnswer.ts +67 -0
- package/service/agentLoop/loopAsk.ts +44 -0
- package/service/agentLoop/loopCompaction.ts +146 -0
- package/service/agentLoop/loopRemotes.ts +181 -0
- package/service/agentLoop/loopRequest.ts +120 -0
- package/service/agentLoop/loopStored.ts +24 -0
- package/service/agentLoop/loopToolOutput.ts +54 -0
- package/service/agentLoop/loopToolkits.ts +155 -0
- package/service/agentLoop/loopTranscript.ts +138 -0
- package/{signal → service}/agentMeter.ts +2 -1
- package/{signal → service}/agentRelayPolicy.ts +43 -8
- package/service/endpointCacheKeys.ts +14 -2
- package/service/index.ts +6 -0
- package/service/injectInfo.ts +2 -1
- package/service/ipcTypes.ts +8 -2
- package/service/liveRoomLimit.ts +68 -0
- package/service/liveRoomLimitError.ts +16 -0
- package/service/liveSyncHub.ts +24 -2
- package/service/predefinedAdaptor/agentTools.adaptor.ts +34 -0
- package/service/predefinedAdaptor/anthropicLlm.ts +33 -14
- package/service/predefinedAdaptor/compress.adaptor.ts +2 -2
- package/service/predefinedAdaptor/database.adaptor.ts +62 -19
- package/service/predefinedAdaptor/index.ts +1 -0
- package/service/predefinedAdaptor/llm.adaptor.ts +24 -1
- package/service/predefinedAdaptor/openaiDialect.ts +72 -23
- package/service/predefinedAdaptor/openaiLlm.ts +1 -1
- package/service/predefinedAdaptor/role.adaptor.ts +2 -0
- package/service/predefinedAdaptor/solidPubsub.adaptor.ts +35 -2
- package/service/predefinedAdaptor/solidQueue.adaptor.ts +2 -2
- package/service/predefinedAdaptor/solidSqlite.ts +6 -3
- package/service/predefinedAdaptor/sql/DocumentHydrator.ts +95 -0
- package/service/predefinedAdaptor/sql/DocumentRowCodec.ts +192 -0
- package/service/predefinedAdaptor/sql/DocumentWriter.ts +298 -0
- package/service/predefinedAdaptor/sql/QueryScope.ts +70 -0
- package/service/predefinedAdaptor/sql/QueryWriter.ts +200 -0
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +127 -1069
- package/service/predefinedAdaptor/sql/SqlTableSchema.ts +357 -0
- package/service/predefinedAdaptor/sql/StoredRows.ts +95 -0
- package/service/predefinedAdaptor/sql/TransactionScope.ts +14 -7
- package/service/predefinedAdaptor/sql/dialect/postgres.ts +1 -1
- package/service/predefinedAdaptor/sql/dialect/sqlite.ts +1 -1
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +20 -9
- package/service/predefinedAdaptor/sql/driver/postgres.ts +1 -1
- package/service/predefinedAdaptor/sql/types.ts +28 -4
- package/service/predefinedAdaptor/sseData.ts +88 -0
- package/service/predefinedAdaptor/storage.adaptor.ts +2 -1
- package/service/predefinedAdaptor/websocket.adaptor.ts +74 -44
- package/service/serviceRegistry.ts +1 -0
- package/signal/SignalFailure.ts +35 -0
- package/signal/agent.signal.ts +15 -9
- package/signal/agentTurnStream.ts +23 -9
- package/signal/byIdRead.ts +18 -0
- package/signal/carriedClientIps.ts +1 -0
- package/signal/endpointCache.ts +61 -6
- package/signal/endpointErrorContract.ts +1 -1
- package/signal/endpointRateLimit.ts +84 -3
- package/signal/index.ts +322 -32
- package/signal/mcp/McpDocument.ts +8 -1
- package/signal/mcp/mcpProtocol.ts +6 -1
- package/signal/mcp/pagePrompt.ts +15 -0
- package/signal/middleware.ts +10 -3
- package/signal/openapi/openapi.ts +10 -1
- package/signal/resolveFieldContext.ts +34 -0
- package/signal/serializer/fetch.serializer.ts +22 -15
- package/signal/signalContext.ts +15 -42
- package/signal/slice.ts +22 -19
- package/signal/trace.ts +44 -5
- package/signal/types.ts +46 -8
- package/store/action.ts +32 -1057
- package/store/actionErrorMessage.ts +20 -0
- package/store/actionOption.ts +22 -0
- package/store/baseSt.ts +1 -0
- package/store/formFieldSetters.ts +229 -0
- package/store/index.ts +125 -17
- package/store/modelActionContext.ts +65 -0
- package/store/modelOpenActions.ts +158 -0
- package/store/modelWriteActions.ts +240 -0
- package/store/modelWriteGuard.ts +3 -12
- package/store/openSeq.ts +34 -0
- package/store/sliceListActions.ts +370 -0
- package/store/sliceLiveActions.ts +140 -0
- package/store/stateBuilder.ts +2 -0
- package/store/storeInstance.ts +4 -18
- package/store/storeRegistry.ts +1 -1
- package/test/conformance.ts +25 -5
- package/types/base/base.d.ts +2 -1
- package/types/client/clientRuntime.d.ts +1 -0
- package/types/client/cn.d.ts +2 -2
- package/types/client/csrTypes.d.ts +2 -0
- package/types/client/frameConfig.d.ts +1 -0
- package/types/client/index.d.ts +25 -26
- package/types/client/locale.d.ts +1 -0
- package/types/client/makePageProto.d.ts +5 -13
- package/types/client/nativeThemeColor.d.ts +6 -0
- package/types/client/route/PageDefinition.d.ts +5 -2
- package/types/client/route/RouteDefinition.d.ts +2 -2
- package/types/client/route/routeArgs.d.ts +7 -0
- package/types/client/router.d.ts +3 -1
- package/types/client/rscNavigation.d.ts +1 -0
- package/types/client/viewportMeta.d.ts +5 -2
- package/types/common/CodeTranscript.d.ts +1 -1
- package/types/common/clientAddress.d.ts +5 -0
- package/types/common/err.d.ts +48 -0
- package/types/common/eventStream.d.ts +5 -1
- package/types/common/facetBarrel.d.ts +4 -0
- package/types/common/index.d.ts +6 -3
- package/types/common/isGuardRefusal.d.ts +3 -0
- package/types/common/loggedFailure.d.ts +2 -0
- package/types/common/mcpExposure.d.ts +9 -2
- package/types/common/routeConvention.d.ts +2 -0
- package/types/common/types.d.ts +18 -1
- package/types/constant/constantRegistry.d.ts +3 -1
- package/types/constant/crystalize.d.ts +1 -1
- package/types/constant/getDefault.d.ts +1 -1
- package/types/constant/immerify.d.ts +1 -1
- package/types/constant/index.d.ts +21 -21
- package/types/constant/purify.d.ts +2 -1
- package/types/constant/serialize.d.ts +1 -1
- package/types/constant/types.d.ts +1 -0
- package/types/dictionary/agent.dictionary.d.ts +1 -1
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +9 -9
- package/types/dictionary/locale.d.ts +1 -1
- package/types/dictionary/trans.d.ts +3 -26
- package/types/document/dataLoader.d.ts +5 -0
- package/types/document/databaseRegistry.d.ts +2 -1
- package/types/document/documentSchema.d.ts +1 -0
- package/types/document/filterMeta.d.ts +4 -1
- package/types/document/into.d.ts +1 -1
- package/types/document/loaderInfo.d.ts +2 -1
- package/types/document/noDocumentError.d.ts +8 -1
- package/types/document/queryEvaluator.d.ts +1 -1
- package/types/document/types.d.ts +1 -1
- package/types/fetch/client/fetchClient.d.ts +6 -36
- package/types/fetch/client/fetchClientTypes.d.ts +40 -0
- package/types/fetch/client/httpClient.d.ts +2 -0
- package/types/fetch/client/remoteError.d.ts +0 -4
- package/types/fetch/client/requestScope.d.ts +11 -0
- package/types/fetch/client/signalCatalog.d.ts +25 -0
- package/types/fetch/client/wsClient.d.ts +2 -0
- package/types/fetch/requestStorage.d.ts +1 -0
- package/types/server/agentHooks.d.ts +4 -0
- package/types/server/akanApp.d.ts +2 -20
- package/types/server/akanOption.d.ts +16 -2
- package/types/server/akanServer.d.ts +2 -2
- package/types/server/assetHeaders.d.ts +1 -0
- package/types/server/console.d.ts +4 -3
- package/types/server/di/predefinedAdaptor.d.ts +1 -0
- package/types/server/di/stageFailedError.d.ts +5 -0
- package/types/server/ed25519Key.d.ts +1 -0
- package/types/server/flightRowReader.d.ts +8 -2
- package/types/server/gateway/childSupervisor.d.ts +35 -0
- package/types/server/gateway/devHostChannel.d.ts +14 -0
- package/types/server/gateway/gatewayChildren.d.ts +50 -0
- package/types/server/gateway/gatewayConfig.d.ts +82 -0
- package/types/server/gateway/gatewayHttpProxy.d.ts +22 -0
- package/types/server/gateway/gatewayLogging.d.ts +16 -0
- package/types/server/gateway/gatewayRooms.d.ts +25 -0
- package/types/server/gateway/gatewayStatus.d.ts +63 -0
- package/types/server/gateway/gatewayStatusPage.d.ts +9 -0
- package/types/server/gateway/gatewayWebSocketRelay.d.ts +17 -0
- package/types/server/gateway/listeningPort.d.ts +5 -0
- package/types/server/htmlResultCache.d.ts +51 -0
- package/types/server/index.d.ts +19 -17
- package/types/server/lifecycle/parentChannel.d.ts +13 -0
- package/types/server/lifecycle/startGuard.d.ts +10 -0
- package/types/server/logging/logHub.d.ts +5 -1
- package/types/server/logging/logStreamRoute.d.ts +2 -0
- package/types/server/logging/rotatingLogWriter.d.ts +1 -1
- package/types/server/logging/serverLogging.d.ts +12 -0
- package/types/server/mcp/AgentTools.d.ts +31 -0
- package/types/server/mcp/AgentToolsAccount.d.ts +7 -0
- package/types/server/mcp/McpApps.d.ts +6 -2
- package/types/server/mcp/McpDispatcher.d.ts +10 -1
- package/types/server/mcp/McpPages.d.ts +2 -1
- package/types/server/mcp/McpRateLimiter.d.ts +3 -0
- package/types/server/mcp/index.d.ts +1 -0
- package/types/server/migration/migrationCommand.d.ts +1 -1
- package/types/server/migration/migrationRunner.d.ts +9 -1
- package/types/server/remote/RemoteFetch.d.ts +42 -0
- package/types/server/remote/RemoteMcp.d.ts +52 -0
- package/types/server/remote/RemoteOAuth.d.ts +58 -0
- package/types/server/remote/RemoteSource.d.ts +51 -0
- package/types/server/remote/index.d.ts +5 -0
- package/types/server/remote/remoteError.d.ts +12 -0
- package/types/server/remote.d.ts +1 -0
- package/types/server/resolver/CascadeRunner.d.ts +2 -2
- package/types/server/resolver/database.resolver.d.ts +2 -2
- package/types/server/resolver/databaseModelInstance.d.ts +4 -0
- package/types/server/resolver/invalidSignal.d.ts +2 -0
- package/types/server/resolver/livePause.d.ts +5 -0
- package/types/server/resolver/modelFacade.d.ts +5 -0
- package/types/server/resolver/modelLoaders.d.ts +15 -0
- package/types/server/resolver/modelSchema.d.ts +6 -0
- package/types/server/resolver/roomAdmission.d.ts +7 -0
- package/types/server/resolver/signal.resolver.d.ts +1 -1
- package/types/server/resolver/sliceCrud.d.ts +8 -0
- package/types/server/resolver/timedQuery.d.ts +8 -0
- package/types/server/routeElementComposer.d.ts +21 -5
- package/types/server/routing/builtinRoutes.d.ts +24 -0
- package/types/server/routing/localRooms.d.ts +14 -0
- package/types/server/routing/roomReplay.d.ts +2 -2
- package/types/server/routing/serverListener.d.ts +31 -0
- package/types/server/rscClientCache.d.ts +34 -0
- package/types/server/rscClientChunks.d.ts +3 -1
- package/types/server/rscClientPatch.d.ts +12 -1
- package/types/server/rscDocumentHead.d.ts +33 -0
- package/types/server/rscFlightRenderer.d.ts +14 -0
- package/types/server/rscFlightStream.d.ts +53 -0
- package/types/server/rscHostReloads.d.ts +54 -0
- package/types/server/rscHostRenderStream.d.ts +53 -0
- package/types/server/rscHostRequests.d.ts +29 -0
- package/types/server/rscHttp.d.ts +4 -2
- package/types/server/rscNavigationState.d.ts +5 -1
- package/types/server/rscPagePrompts.d.ts +13 -0
- package/types/server/rscRenderControl.d.ts +12 -0
- package/types/server/rscRenderFallbacks.d.ts +41 -0
- package/types/server/rscRenderHandler.d.ts +29 -0
- package/types/server/rscRenderStats.d.ts +32 -0
- package/types/server/rscResultCaches.d.ts +18 -0
- package/types/server/rscRouteDocument.d.ts +52 -0
- package/types/server/rscStaticApp.d.ts +28 -0
- package/types/server/rscWorker.d.ts +1 -3
- package/types/server/rscWorkerHost.d.ts +10 -70
- package/types/server/rscWorkerProcess.d.ts +31 -0
- package/types/server/rscWorkerRecycler.d.ts +22 -0
- package/types/server/serverConfig.d.ts +30 -0
- package/types/server/serverMetrics.d.ts +11 -0
- package/types/server/sitemap.d.ts +1 -0
- package/types/server/ssrFromRscRenderer.d.ts +2 -2
- package/types/server/ssrStaticApp.d.ts +20 -0
- package/types/server/webArtifact.d.ts +7 -0
- package/types/server/webAssetRoutes.d.ts +11 -0
- package/types/server/webCsrSurface.d.ts +18 -0
- package/types/server/webDocumentRoute.d.ts +19 -0
- package/types/server/webRouteContext.d.ts +45 -0
- package/types/server/webRouter.d.ts +3 -28
- package/types/server/webRscRoute.d.ts +24 -0
- package/types/server/webSiteFiles.d.ts +12 -0
- package/types/server/webStaticApp.d.ts +8 -0
- package/types/server/wellKnownRoutes.d.ts +5 -0
- package/types/service/agent.service.d.ts +3 -0
- package/types/service/agentAccounts.d.ts +8 -0
- package/types/service/agentLoop/agentLoop.d.ts +33 -0
- package/types/service/agentLoop/agentLoopTypes.d.ts +235 -0
- package/types/service/agentLoop/deltaStream.d.ts +3 -0
- package/types/service/agentLoop/loopAnswer.d.ts +13 -0
- package/types/service/agentLoop/loopAsk.d.ts +12 -0
- package/types/service/agentLoop/loopCompaction.d.ts +12 -0
- package/types/service/agentLoop/loopRemotes.d.ts +40 -0
- package/types/service/agentLoop/loopRequest.d.ts +9 -0
- package/types/service/agentLoop/loopStored.d.ts +6 -0
- package/types/service/agentLoop/loopToolOutput.d.ts +8 -0
- package/types/service/agentLoop/loopToolkits.d.ts +17 -0
- package/types/service/agentLoop/loopTranscript.d.ts +13 -0
- package/types/{signal → service}/agentMeter.d.ts +1 -1
- package/types/{signal → service}/agentRelayPolicy.d.ts +18 -3
- package/types/service/index.d.ts +6 -0
- package/types/service/injectInfo.d.ts +2 -1
- package/types/service/ipcTypes.d.ts +10 -0
- package/types/service/liveRoomLimit.d.ts +26 -0
- package/types/service/liveRoomLimitError.d.ts +9 -0
- package/types/service/predefinedAdaptor/agentTools.adaptor.d.ts +31 -0
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +2 -2
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +9 -7
- package/types/service/predefinedAdaptor/index.d.ts +1 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +12 -0
- package/types/service/predefinedAdaptor/openaiDialect.d.ts +3 -2
- package/types/service/predefinedAdaptor/role.adaptor.d.ts +2 -0
- package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +3 -0
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +1 -1
- package/types/service/predefinedAdaptor/sql/DocumentHydrator.d.ts +11 -0
- package/types/service/predefinedAdaptor/sql/DocumentRowCodec.d.ts +26 -0
- package/types/service/predefinedAdaptor/sql/DocumentWriter.d.ts +25 -0
- package/types/service/predefinedAdaptor/sql/QueryScope.d.ts +16 -0
- package/types/service/predefinedAdaptor/sql/QueryWriter.d.ts +20 -0
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +5 -28
- package/types/service/predefinedAdaptor/sql/SqlTableSchema.d.ts +22 -0
- package/types/service/predefinedAdaptor/sql/StoredRows.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/TransactionScope.d.ts +3 -1
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +3 -15
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +0 -8
- package/types/service/predefinedAdaptor/sql/types.d.ts +27 -4
- package/types/service/predefinedAdaptor/sseData.d.ts +13 -0
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +7 -3
- package/types/service/serviceRegistry.d.ts +1 -0
- package/types/signal/SignalFailure.d.ts +4 -0
- package/types/signal/agentTurnStream.d.ts +3 -0
- package/types/signal/byIdRead.d.ts +7 -0
- package/types/signal/carriedClientIps.d.ts +4 -0
- package/types/signal/endpointRateLimit.d.ts +12 -0
- package/types/signal/index.d.ts +32 -32
- package/types/signal/mcp/McpDocument.d.ts +2 -0
- package/types/signal/mcp/mcpProtocol.d.ts +5 -0
- package/types/signal/mcp/pagePrompt.d.ts +13 -0
- package/types/signal/resolveFieldContext.d.ts +15 -0
- package/types/signal/serializer/fetch.serializer.d.ts +3 -1
- package/types/signal/signalContext.d.ts +2 -14
- package/types/signal/slice.d.ts +15 -13
- package/types/signal/trace.d.ts +12 -1
- package/types/signal/types.d.ts +38 -7
- package/types/store/action.d.ts +4 -27
- package/types/store/actionErrorMessage.d.ts +1 -0
- package/types/store/actionOption.d.ts +24 -0
- package/types/store/baseSt.d.ts +1 -0
- package/types/store/formFieldSetters.d.ts +80 -0
- package/types/store/index.d.ts +17 -16
- package/types/store/modelActionContext.d.ts +189 -0
- package/types/store/modelOpenActions.d.ts +12 -0
- package/types/store/modelWriteActions.d.ts +16 -0
- package/types/store/modelWriteGuard.d.ts +2 -5
- package/types/store/openSeq.d.ts +17 -0
- package/types/store/sliceListActions.d.ts +295 -0
- package/types/store/sliceLiveActions.d.ts +6 -0
- package/types/store/stateBuilder.d.ts +2 -0
- package/types/test/conformance.d.ts +3 -1
- package/types/ui/Agent/Chat.d.ts +5 -2
- package/types/ui/Agent/ChatHeader.d.ts +13 -0
- package/types/ui/Agent/ChatPendingCards.d.ts +23 -0
- package/types/ui/Agent/ToolRow.d.ts +13 -0
- package/types/ui/Field/Choice.d.ts +2 -1
- package/types/ui/Field/index.d.ts +1 -1
- package/types/ui/Reference/origin.d.ts +1 -0
- package/types/ui/UiOverride/UiOverride.d.ts +2 -0
- package/types/ui/index.d.ts +2 -1
- package/types/ui/overlayLayer.d.ts +8 -2
- package/types/ui/recipe/badgeRecipe.d.ts +3 -3
- package/types/ui/recipe/buttonRecipe.d.ts +3 -3
- package/types/ui/recipe/inputRecipe.d.ts +1 -1
- package/types/vendor/@akanjs/native/packages/cli/src/lib/project.d.ts +4 -0
- package/types/vendor/@akanjs/native/packages/desktop/src/relaunch.d.ts +1 -0
- package/types/vendor/@akanjs/native/plugins/appearance/src/index.d.ts +9 -0
- package/types/vendor/@akanjs/native/plugins/external-view/src/index.d.ts +22 -13
- package/types/vendor/@akanjs/native/plugins/single-instance/src/socket.d.ts +15 -2
- package/types/vendor/use-agentic/AgentClientTools.d.ts +19 -0
- package/types/vendor/use-agentic/Compaction.d.ts +3 -1
- package/types/vendor/use-agentic/SessionQuestion.d.ts +26 -0
- package/types/vendor/use-agentic/Transcript.d.ts +1 -1
- package/types/vendor/use-agentic/failureCode.d.ts +4 -0
- package/types/vendor/use-agentic/index.d.ts +1 -0
- package/types/vendor/use-agentic/types.d.ts +12 -3
- package/types/webkit/CsrGuards.d.ts +3 -0
- package/types/webkit/McpAppHost.d.ts +24 -0
- package/types/webkit/RouteLevelBoundary.d.ts +17 -0
- package/types/webkit/csrRefresh.d.ts +13 -0
- package/types/webkit/index.d.ts +3 -0
- package/types/webkit/needsBrowser.d.ts +5 -0
- package/types/webkit/useCamera.d.ts +1 -1
- package/types/webkit/useCsrKeyboard.d.ts +19 -0
- package/types/webkit/useCsrLocationState.d.ts +21 -0
- package/types/webkit/useCsrNavigation.d.ts +25 -0
- package/types/webkit/useCsrRefs.d.ts +33 -0
- package/types/webkit/useCsrRenderTrace.d.ts +13 -0
- package/types/webkit/useCsrStackLifecycle.d.ts +12 -0
- package/types/webkit/useCsrTransitions.d.ts +2 -0
- package/types/webkit/useGeoLocation.d.ts +1 -1
- package/types/webkit/useHistory.d.ts +2 -3
- package/types/webkit/useResolvedFrame.d.ts +38 -0
- package/types/webkit/useSyncNavigation.d.ts +22 -0
- package/ui/Agent/Bubble.tsx +4 -118
- package/ui/Agent/Chat.tsx +402 -235
- package/ui/Agent/ChatHeader.tsx +59 -0
- package/ui/Agent/ChatPendingCards.tsx +49 -0
- package/ui/Agent/ToolRow.tsx +117 -0
- package/ui/Agent/fetchRunner.ts +8 -1
- package/ui/BottomSheet.tsx +1 -1
- package/ui/Data/Item.tsx +2 -2
- package/ui/Data/ListContainer.tsx +348 -181
- package/ui/Data/useViewModal.ts +10 -4
- package/ui/Dialog/LegacyModal.tsx +1 -1
- package/ui/Dialog/Modal.tsx +1 -1
- package/ui/Field/Choice.tsx +3 -1
- package/ui/Load/StreamBoundary.tsx +1 -6
- package/ui/Load/View.tsx +2 -1
- package/ui/Model/EditModal.tsx +2 -1
- package/ui/Popconfirm.tsx +1 -1
- package/ui/Reference/origin.ts +1 -0
- package/ui/Select.tsx +43 -51
- package/ui/Signal/RestApi.tsx +3 -2
- package/ui/System/Client.tsx +4 -1
- package/ui/UiOverride/UiOverride.tsx +2 -0
- package/ui/index.ts +5 -0
- package/ui/overlayLayer.ts +25 -2
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +31 -13
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativePlugin.kt +4 -0
- package/vendor/@akanjs/native/native/desktop/Cargo.lock +1 -0
- package/vendor/@akanjs/native/native/desktop/Cargo.toml +2 -0
- package/vendor/@akanjs/native/native/desktop/src/external.rs +240 -114
- package/vendor/@akanjs/native/native/desktop/src/json.rs +14 -1
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +12 -4
- package/vendor/@akanjs/native/native/desktop/src/linux/external.rs +696 -0
- package/vendor/@akanjs/native/native/desktop/src/linux/mod.rs +1 -0
- package/vendor/@akanjs/native/native/ios/Sources/AkanNativeViewController.swift +6 -1
- package/vendor/@akanjs/native/packages/cli/src/lib/native-plugins.ts +5 -3
- package/vendor/@akanjs/native/packages/cli/src/lib/project.ts +25 -1
- package/vendor/@akanjs/native/packages/desktop/src/deeplinks.ts +2 -2
- package/vendor/@akanjs/native/packages/desktop/src/host.ts +2 -2
- package/vendor/@akanjs/native/packages/desktop/src/relaunch.ts +8 -3
- package/vendor/@akanjs/native/plugins/app/src/desktop.ts +2 -2
- package/vendor/@akanjs/native/plugins/appearance/android/AppearancePlugin.kt +13 -0
- package/vendor/@akanjs/native/plugins/appearance/ios/AppearancePlugin.swift +27 -0
- package/vendor/@akanjs/native/plugins/appearance/native-plugin.json +2 -2
- package/vendor/@akanjs/native/plugins/appearance/src/index.ts +8 -1
- package/vendor/@akanjs/native/plugins/autostart/src/desktop.ts +2 -1
- package/vendor/@akanjs/native/plugins/external-view/native-plugin.json +4 -1
- package/vendor/@akanjs/native/plugins/external-view/src/index.ts +22 -13
- package/vendor/@akanjs/native/plugins/single-instance/src/socket.ts +113 -24
- package/vendor/use-agentic/AgentClientTools.ts +33 -0
- package/vendor/use-agentic/AgentSession.ts +35 -73
- package/vendor/use-agentic/CHANGELOG.md +0 -43
- package/vendor/use-agentic/Compaction.ts +12 -2
- package/vendor/use-agentic/SessionQuestion.ts +99 -0
- package/vendor/use-agentic/ToolRunner.ts +3 -15
- package/vendor/use-agentic/Transcript.ts +8 -5
- package/vendor/use-agentic/WIRE.md +28 -9
- package/vendor/use-agentic/failureCode.ts +44 -0
- package/vendor/use-agentic/httpRunner.ts +22 -8
- package/vendor/use-agentic/index.ts +1 -0
- package/vendor/use-agentic/types.ts +13 -1
- package/webkit/CsrGuards.ts +11 -2
- package/webkit/McpAppFetchBridge.ts +3 -1
- package/webkit/McpAppHost.ts +122 -0
- package/webkit/RenderLayer.tsx +48 -14
- package/webkit/RouteLevelBoundary.tsx +37 -0
- package/webkit/csrRefresh.ts +33 -0
- package/webkit/index.ts +3 -0
- package/webkit/lazy.tsx +5 -1
- package/webkit/needsBrowser.ts +10 -0
- package/webkit/useCamera.tsx +18 -7
- package/webkit/useCsrKeyboard.ts +155 -0
- package/webkit/useCsrLocationState.ts +58 -0
- package/webkit/useCsrNavigation.ts +302 -0
- package/webkit/useCsrRefs.ts +52 -0
- package/webkit/useCsrRenderTrace.ts +68 -0
- package/webkit/useCsrStackLifecycle.ts +120 -0
- package/webkit/useCsrTransitions.ts +552 -0
- package/webkit/useCsrValues.ts +73 -1235
- package/webkit/useGeoLocation.tsx +1 -3
- package/webkit/useHistory.ts +2 -2
- package/webkit/useLocation.ts +3 -2
- package/webkit/useResolvedFrame.ts +116 -0
- package/webkit/useSyncNavigation.ts +109 -0
- package/vendor/@akanjs/native/CHANGELOG.md +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PromiseOrObject } from "akanjs/base";
|
|
2
|
-
import type { LlmTurnRequest } from "
|
|
2
|
+
import type { LlmTurnRequest } from "./predefinedAdaptor/llm.adaptor";
|
|
3
3
|
/** One relayed turn, the same object from the request policy through the quota to the usage report. */
|
|
4
4
|
export interface AgentTurnContext {
|
|
5
5
|
/** Fresh per turn, so a quota hold and the usage that settles it pair up without guessing. */
|
|
@@ -9,6 +9,18 @@ export interface AgentTurnContext {
|
|
|
9
9
|
/** What the account middleware resolved for this call, as the access guard saw it; `null` for an anonymous one. */
|
|
10
10
|
account: unknown;
|
|
11
11
|
ip: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Set on an `agentService.loop` round: `id` is one per run, `round` counts its model calls from 1, `client` says the
|
|
14
|
+
* run lists tools a browser sent (`clientTools`), and `remote` that it may open other servers (`remotes`).
|
|
15
|
+
*/
|
|
16
|
+
loop?: {
|
|
17
|
+
id: string;
|
|
18
|
+
round: number;
|
|
19
|
+
client?: true;
|
|
20
|
+
remote?: true;
|
|
21
|
+
};
|
|
22
|
+
/** The loop request's `meta`, copied as given; only server code sets it, so it may key billing. */
|
|
23
|
+
meta?: Record<string, string>;
|
|
12
24
|
}
|
|
13
25
|
/** @deprecated Use `AgentTurnContext`; `apply` still takes this shape and gives it a fresh `id` and empty `headers`. */
|
|
14
26
|
export interface AgentRequestContext {
|
|
@@ -22,13 +34,16 @@ export interface AgentRequestLimits {
|
|
|
22
34
|
context: number;
|
|
23
35
|
/** Text of every message, tool and context entry and the instructions, attachments aside. */
|
|
24
36
|
chars: number;
|
|
25
|
-
/** Attachment content as it travels: base64 `data` and `text`,
|
|
37
|
+
/** Attachment content as it travels: base64 `data` and `text`, a tool result's files too, over the whole history. */
|
|
26
38
|
attachmentChars: number;
|
|
27
39
|
}
|
|
28
40
|
export declare class AgentRelayPolicy {
|
|
29
41
|
#private;
|
|
30
42
|
static readonly defaultLimits: Readonly<AgentRequestLimits>;
|
|
31
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* `null` restores the default, `capped(defaultLimits)` on relayed turns and on loop rounds with `loop.client` or
|
|
45
|
+
* `loop.remote`; `(request) => request` relays every request untouched.
|
|
46
|
+
*/
|
|
32
47
|
static use(policy: AgentRequestPolicy | null): void;
|
|
33
48
|
static apply(request: LlmTurnRequest, context: AgentTurnContext | AgentRequestContext): Promise<LlmTurnRequest>;
|
|
34
49
|
static capped(request: LlmTurnRequest, limits?: Partial<AgentRequestLimits>): LlmTurnRequest;
|
package/types/service/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export * from "./adapt.d.ts";
|
|
2
2
|
export * from "./agent.service";
|
|
3
|
+
export * from "./agentAccounts.d.ts";
|
|
4
|
+
export * from "./agentLoop/agentLoopTypes.d.ts";
|
|
5
|
+
export * from "./agentMeter.d.ts";
|
|
6
|
+
export * from "./agentRelayPolicy.d.ts";
|
|
3
7
|
export * from "./base.service";
|
|
4
8
|
export * from "./documentStoreError.d.ts";
|
|
5
9
|
export * from "./endpointCacheKeys.d.ts";
|
|
@@ -7,6 +11,8 @@ export * from "./injectError.d.ts";
|
|
|
7
11
|
export * from "./injectInfo.d.ts";
|
|
8
12
|
export * from "./insightQueryError.d.ts";
|
|
9
13
|
export * from "./ipcTypes.d.ts";
|
|
14
|
+
export * from "./liveRoomLimit.d.ts";
|
|
15
|
+
export * from "./liveRoomLimitError.d.ts";
|
|
10
16
|
export * from "./liveSyncHub.d.ts";
|
|
11
17
|
export * from "./predefinedAdaptor.d.ts";
|
|
12
18
|
export * from "./rateLimiter.d.ts";
|
|
@@ -2,9 +2,10 @@ import { type BackendEnv } from "akanjs/base";
|
|
|
2
2
|
import { type ConstantFieldTypeInput, type FieldToValue, type PlainTypeToFieldType } from "akanjs/constant";
|
|
3
3
|
import type { DatabaseModel } from "akanjs/document";
|
|
4
4
|
import type { Endpoint, EndpointCls, Internal, InternalCls, ServerSignal, ServerSignalCls, SliceCls } from "akanjs/signal";
|
|
5
|
-
import type { Adaptor, AdaptorCls
|
|
5
|
+
import type { Adaptor, AdaptorCls } from "./adapt.d.ts";
|
|
6
6
|
import { LiveSyncHub } from "./liveSyncHub.d.ts";
|
|
7
7
|
import type { CacheSetOptions } from "./predefinedAdaptor.d.ts";
|
|
8
|
+
import type { Service, ServiceCls } from "./serve.d.ts";
|
|
8
9
|
export type InjectType = "database" | "service" | "use" | "signal" | "plug" | "env" | "memory";
|
|
9
10
|
interface InjectBuilderOptions<ReturnType> {
|
|
10
11
|
generateFactory?: (options: any) => ReturnType;
|
|
@@ -2,6 +2,8 @@ import type { LogRecord } from "akanjs/common";
|
|
|
2
2
|
import type { LiveChange } from "./predefinedAdaptor/websocket.adaptor";
|
|
3
3
|
export type AkanChildRole = "all" | "federation" | "batch";
|
|
4
4
|
export type AkanChildStatus = "starting" | "ready" | "healthy" | "draining" | "unhealthy" | "exited" | "crashed";
|
|
5
|
+
/** A replica's RSC worker; `null` on a replica that renders no pages. */
|
|
6
|
+
export type AkanRscWorkerStatus = "starting" | "ready" | "restarting" | "stopped" | null;
|
|
5
7
|
export type AkanUpstream = {
|
|
6
8
|
type: "unix";
|
|
7
9
|
socketPath: string;
|
|
@@ -162,6 +164,7 @@ export type AkanIpcMessage = {
|
|
|
162
164
|
allowedOrigins: string[];
|
|
163
165
|
enabled: boolean;
|
|
164
166
|
};
|
|
167
|
+
rscWorker?: AkanRscWorkerStatus;
|
|
165
168
|
} | {
|
|
166
169
|
type: "pubsub.publish";
|
|
167
170
|
roomId: string;
|
|
@@ -177,6 +180,12 @@ export type AkanIpcMessage = {
|
|
|
177
180
|
roomId: string;
|
|
178
181
|
socketId?: string;
|
|
179
182
|
pid?: number;
|
|
183
|
+
ack?: number;
|
|
184
|
+
}
|
|
185
|
+
/** Gateway → child: the subscribe carrying `ack`, and whatever the child sent before it, now route to the child. */
|
|
186
|
+
| {
|
|
187
|
+
type: "pubsub.subscribed";
|
|
188
|
+
ack: number;
|
|
180
189
|
} | {
|
|
181
190
|
type: "pubsub.unsubscribe";
|
|
182
191
|
roomId: string;
|
|
@@ -217,6 +226,7 @@ export type AkanIpcMessage = {
|
|
|
217
226
|
nonce: string;
|
|
218
227
|
sentAt: number;
|
|
219
228
|
pid?: number;
|
|
229
|
+
rscWorker?: AkanRscWorkerStatus;
|
|
220
230
|
} | {
|
|
221
231
|
type: "ws.opened";
|
|
222
232
|
socketId: string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface LiveRoomLimitSetting {
|
|
2
|
+
/** Pubsub rooms one websocket may hold at once, live or not, past which a subscribe is refused; `false` lifts it. */
|
|
3
|
+
roomsPerSocket?: number | false;
|
|
4
|
+
/** Rooms one caller (its account, else its address) may hold across its sockets in this server; `false` lifts it. */
|
|
5
|
+
roomsPerCaller?: number | false;
|
|
6
|
+
/**
|
|
7
|
+
* Live rooms on one model in this server that every write evaluates (those no equality index files, and invalidating
|
|
8
|
+
* ones), past which a new one is refused; indexed rooms never count. `false` lifts it.
|
|
9
|
+
*/
|
|
10
|
+
roomsPerModel?: number | false;
|
|
11
|
+
}
|
|
12
|
+
type Env = Record<string, string | undefined>;
|
|
13
|
+
export declare class LiveRoomLimit {
|
|
14
|
+
#private;
|
|
15
|
+
static readonly defaultRoomsPerSocket = 256;
|
|
16
|
+
static readonly defaultRoomsPerCaller = 2000;
|
|
17
|
+
static readonly defaultRoomsPerModel = 50000;
|
|
18
|
+
static configure(setting: LiveRoomLimitSetting): void;
|
|
19
|
+
/** A positive count, or `off`/`0` to lift the limit; it wins over the code, so a deployment can raise it alone. */
|
|
20
|
+
static applyEnv(env?: Env): void;
|
|
21
|
+
static reset(): void;
|
|
22
|
+
static get roomsPerSocket(): number | null;
|
|
23
|
+
static get roomsPerCaller(): number | null;
|
|
24
|
+
static get roomsPerModel(): number | null;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AkanError } from "akanjs/base";
|
|
2
|
+
export interface LiveRoomLimitData {
|
|
3
|
+
limit: number;
|
|
4
|
+
per: "socket" | "caller" | "model";
|
|
5
|
+
}
|
|
6
|
+
export declare class LiveRoomLimitError extends AkanError<"liveRoomLimit", LiveRoomLimitData> {
|
|
7
|
+
constructor(per: LiveRoomLimitData["per"], limit: number);
|
|
8
|
+
get forwarded(): boolean;
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AgentWireTool, AgentWireToolCall, AgentWireToolResult } from "./llm.adaptor";
|
|
2
|
+
/** What a call carries besides the account; `/mcp` reads these off its request, an in-process call has none of its own. */
|
|
3
|
+
export interface AgentToolsCaller {
|
|
4
|
+
/** Narrows the catalogue to these tool names and never widens it; omitted, every tool the account may see. */
|
|
5
|
+
allow?: readonly string[];
|
|
6
|
+
/** Handed to the endpoint without `authorization`, `cookie` or `origin`: the account is the only identity a call carries. */
|
|
7
|
+
headers?: HeadersInit;
|
|
8
|
+
/** What `getClientIp()` and an ip-scoped rate limit read; omitted, every such call shares the unknown-address budget. */
|
|
9
|
+
ip?: string | null;
|
|
10
|
+
}
|
|
11
|
+
export interface AgentTool extends AgentWireTool {
|
|
12
|
+
/** A query, which reads and changes nothing. */
|
|
13
|
+
readOnly: boolean;
|
|
14
|
+
/** A mutation MCP marks `destructiveHint`, by its key or its `destructive` option: `agentService.loop` refuses it unless `approve` allows it. */
|
|
15
|
+
needsConfirm?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The `/mcp` tool catalogue run in-process as a given account, with the same refusals, masking and error text and
|
|
19
|
+
* `origin` "mcp", plus every endpoint declared `mcp: "agent"`, which `/mcp` never lists. Built from the DI registry,
|
|
20
|
+
* so a batch server without `/mcp` has it too. Covers the endpoint tools only: a page's `page().app()` tool is listed
|
|
21
|
+
* on `/mcp` but absent here, and `callAs` answers it as an unknown tool.
|
|
22
|
+
* Security: `account` is put on the call after the middleware chain, unchecked — pass one the server resolved, never
|
|
23
|
+
* client input, and resolve a stored one again before reusing it, as a revoked session is not noticed here. Its
|
|
24
|
+
* `machine` field is removed, since only a verified machine token may set one. Both methods throw `InjectError`
|
|
25
|
+
* `notInitialized` until the server has built its endpoints, so neither works from an `onInit`.
|
|
26
|
+
*/
|
|
27
|
+
export interface AgentToolsAdaptor {
|
|
28
|
+
listAs(account: unknown, caller?: AgentToolsCaller): Promise<AgentTool[]>;
|
|
29
|
+
/** Never throws for a tool's own failure: a refusal or an error comes back as the result's `error` and `code`. */
|
|
30
|
+
callAs(account: unknown, call: AgentWireToolCall, caller?: AgentToolsCaller): Promise<AgentWireToolResult>;
|
|
31
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentWireAttachment, type AgentWireMessage, type AgentWireToolResult, type LlmAccepts, type LlmAdaptor, type LlmLimits, type LlmOption, type LlmTurnAnswer, type LlmTurnRequest, type LlmUsage } from "./llm.adaptor";
|
|
1
|
+
import { type AgentWireAttachment, type AgentWireMessage, type AgentWireTool, type AgentWireToolResult, type LlmAccepts, type LlmAdaptor, type LlmLimits, type LlmOption, type LlmTurnAnswer, type LlmTurnRequest, type LlmUsage } from "./llm.adaptor";
|
|
2
2
|
type AnthropicSource = {
|
|
3
3
|
type: "base64";
|
|
4
4
|
media_type: string;
|
|
@@ -101,7 +101,7 @@ export declare class AnthropicLlm extends AnthropicLlm_base implements LlmAdapto
|
|
|
101
101
|
static turnAnswer(answer: AnthropicAnswer): LlmTurnAnswer;
|
|
102
102
|
static usageOf(usage: AnthropicUsage): LlmUsage;
|
|
103
103
|
static stopOf(reason: string | null | undefined, calls: number): LlmTurnAnswer["stop"];
|
|
104
|
-
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void): Promise<LlmTurnAnswer>;
|
|
104
|
+
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void, host?: string, tools?: AgentWireTool[]): Promise<LlmTurnAnswer>;
|
|
105
105
|
/** A tool called with no arguments streams no fragment at all, so an empty string is an empty object. */
|
|
106
106
|
static parsedArgs(raw: string): Record<string, unknown>;
|
|
107
107
|
}
|
|
@@ -7,13 +7,13 @@ import { SqliteDialect } from "./sql/dialect/sqlite.d.ts";
|
|
|
7
7
|
import { BunSqliteClient } from "./sql/driver/bunSqlite.d.ts";
|
|
8
8
|
import { PostgresAkanClient } from "./sql/driver/postgres.d.ts";
|
|
9
9
|
import { SqlDocumentStore } from "./sql/SqlDocumentStore.d.ts";
|
|
10
|
-
import { type ConcurrentIndexBuild, type CreateIndexProps, type DatabaseAdaptor, type InsightSession, type SearchConfig, type SqliteEnv } from "./sql/types.d.ts";
|
|
10
|
+
import { type AfterCommitOptions, type ConcurrentIndexBuild, type CreateIndexProps, type DatabaseAdaptor, type InsightSession, type SearchConfig, type SqliteEnv } from "./sql/types.d.ts";
|
|
11
11
|
export { PostgresDialect } from "./sql/dialect/postgres.d.ts";
|
|
12
12
|
export { SqliteDialect } from "./sql/dialect/sqlite.d.ts";
|
|
13
13
|
export { type MigrationLedgerTable, MigrationTables } from "./sql/MigrationTables.d.ts";
|
|
14
14
|
export { RawDocumentTable, type RawFilter, type RawFilterOperators, type RawFindOptions, } from "./sql/RawDocumentTable.d.ts";
|
|
15
15
|
export { SqlDocumentStore } from "./sql/SqlDocumentStore.d.ts";
|
|
16
|
-
export type { AkanSqlClient, AkanSqlStatement, DatabaseAdaptor, DatabaseConfig, DocumentDatabaseOwner, DocumentStore, InsightSession, PostgresDatabaseConfig, SearchConfig, SqlDialect, SqliteDatabaseConfig, SqlResultRows, TransferRow, UpsertByIdOptions, } from "./sql/types.d.ts";
|
|
16
|
+
export type { AfterCommitOptions, AkanSqlClient, AkanSqlStatement, DatabaseAdaptor, DatabaseConfig, DocumentDatabaseOwner, DocumentStore, DocumentWriteListener, InsightSession, PostgresDatabaseConfig, PrunedIndex, SearchConfig, SqlDialect, SqliteDatabaseConfig, SqlResultRows, TransferRow, UndeclaredIndex, UpsertByIdOptions, } from "./sql/types.d.ts";
|
|
17
17
|
export { descriptorHash, stableJson } from "./sql/values.d.ts";
|
|
18
18
|
declare const SqliteDatabase_base: import("..").AdaptorCls<{}, {
|
|
19
19
|
scheduler: import("..").InjectInfo<"plug", import("./schedule.adaptor").ScheduleAdaptor, never, never>;
|
|
@@ -38,15 +38,16 @@ export declare class SqliteDatabase extends SqliteDatabase_base implements Datab
|
|
|
38
38
|
openInsight(): Promise<InsightSession>;
|
|
39
39
|
stores(): SqlDocumentStore[];
|
|
40
40
|
getStore(constant: ConstantModel, database: DatabaseModel, schema: SchemaOf): SqlDocumentStore;
|
|
41
|
-
getMeta(key: string): string | undefined
|
|
41
|
+
getMeta(key: string): Promise<string | undefined>;
|
|
42
42
|
setMeta(key: string, value: string): Promise<void>;
|
|
43
|
-
listMeta(prefix: string): {
|
|
43
|
+
listMeta(prefix: string): Promise<{
|
|
44
44
|
key: string;
|
|
45
45
|
value: string;
|
|
46
|
-
}[]
|
|
46
|
+
}[]>;
|
|
47
47
|
deleteMeta(key: string): Promise<void>;
|
|
48
48
|
transaction<T>(fn: () => PromiseOrObject<T>): Promise<T>;
|
|
49
|
-
afterCommit(fn: () => PromiseOrObject<void
|
|
49
|
+
afterCommit(fn: () => PromiseOrObject<void>, options?: AfterCommitOptions): Promise<void>;
|
|
50
|
+
transactionKey(): object | undefined;
|
|
50
51
|
checkpoint(mode?: "PASSIVE" | "FULL" | "RESTART" | "TRUNCATE"): void;
|
|
51
52
|
vacuum(): void;
|
|
52
53
|
}
|
|
@@ -82,7 +83,8 @@ export declare class PostgresDatabase extends PostgresDatabase_base implements D
|
|
|
82
83
|
}[]>;
|
|
83
84
|
deleteMeta(key: string): Promise<void>;
|
|
84
85
|
transaction<T>(fn: () => PromiseOrObject<T>): Promise<T>;
|
|
85
|
-
afterCommit(fn: () => PromiseOrObject<void
|
|
86
|
+
afterCommit(fn: () => PromiseOrObject<void>, options?: AfterCommitOptions): Promise<void>;
|
|
87
|
+
transactionKey(): object | undefined;
|
|
86
88
|
lockSchema<T>(fn: () => Promise<T>): Promise<T>;
|
|
87
89
|
hasTable(table: string): Promise<boolean>;
|
|
88
90
|
hasValidIndex(name: string): Promise<boolean>;
|
|
@@ -2,6 +2,11 @@ export interface AgentWireToolCall {
|
|
|
2
2
|
id: string;
|
|
3
3
|
name: string;
|
|
4
4
|
args: Record<string, unknown>;
|
|
5
|
+
/**
|
|
6
|
+
* Set by an adaptor when a finished answer's arguments were not one JSON object, and `args` is then `{}`: why, for
|
|
7
|
+
* the call to be answered with as its error, never run, so the model can write it again.
|
|
8
|
+
*/
|
|
9
|
+
argsError?: string;
|
|
5
10
|
}
|
|
6
11
|
export interface AgentWireToolResult {
|
|
7
12
|
id: string;
|
|
@@ -49,6 +54,13 @@ export interface AgentWireMessage {
|
|
|
49
54
|
error?: string;
|
|
50
55
|
/** A compaction summary: it arrives with the user's role but is history, not an ask, and a provider frames it so. */
|
|
51
56
|
summary?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* On a summary or tool message `agentService.loop` wrote: whether its run had read a result that taints it.
|
|
59
|
+
* Absent on a summary, nothing judged what it replaced, so a resumed run counts it as tainted.
|
|
60
|
+
*/
|
|
61
|
+
tainted?: boolean;
|
|
62
|
+
/** On a summary `agentService.loop` wrote: the toolkits its run had opened, which the messages it replaced recorded. */
|
|
63
|
+
toolkits?: string[];
|
|
52
64
|
}
|
|
53
65
|
export interface AgentWireTool {
|
|
54
66
|
name: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AgentWireAttachment, type AgentWireMessage, type LlmAccepts, type LlmTurnAnswer, type LlmTurnRequest, type LlmUsage } from "./llm.adaptor";
|
|
1
|
+
import { type AgentWireAttachment, type AgentWireMessage, type AgentWireTool, type LlmAccepts, type LlmTurnAnswer, type LlmTurnRequest, type LlmUsage } from "./llm.adaptor";
|
|
2
2
|
export interface OpenaiToolCall {
|
|
3
3
|
id?: string;
|
|
4
4
|
function?: {
|
|
@@ -49,6 +49,7 @@ export interface OpenaiMessage {
|
|
|
49
49
|
}
|
|
50
50
|
/** The chat-completions wire that OpenAI, DeepSeek and every gateway copying them speak. */
|
|
51
51
|
export declare class OpenaiDialect {
|
|
52
|
+
#private;
|
|
52
53
|
/** Apart from Anthropic's identical set: each is one provider's list, and an unlisted type is a refused request. */
|
|
53
54
|
static readonly imageTypes: Set<string>;
|
|
54
55
|
static requestBody(model: string, request: LlmTurnRequest, { accepts, stream }?: {
|
|
@@ -88,7 +89,7 @@ export declare class OpenaiDialect {
|
|
|
88
89
|
part: OpenaiImagePart;
|
|
89
90
|
}[];
|
|
90
91
|
};
|
|
91
|
-
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void): Promise<LlmTurnAnswer>;
|
|
92
|
+
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void, host?: string, tools?: AgentWireTool[]): Promise<LlmTurnAnswer>;
|
|
92
93
|
static usageOf(usage: OpenaiUsage): LlmUsage;
|
|
93
94
|
/** The ceiling wins over the calls that did arrive: a cut-off turn's last call may be missing. */
|
|
94
95
|
static stopOf(finish: string | null | undefined, calls: number): LlmTurnAnswer["stop"];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type AdaptorCls } from "../adapt.d.ts";
|
|
2
|
+
import type { AgentToolsAdaptor } from "./agentTools.adaptor";
|
|
2
3
|
import type { CacheAdaptor } from "./cache.adaptor";
|
|
3
4
|
import type { CompressAdaptor } from "./compress.adaptor";
|
|
4
5
|
import type { DatabaseAdaptor } from "./database.adaptor";
|
|
@@ -17,3 +18,4 @@ export declare const LoggingAdaptorRole: AdaptorCls<LoggingAdaptor>;
|
|
|
17
18
|
export declare const WebsocketAdaptorRole: AdaptorCls<WebsocketAdaptor>;
|
|
18
19
|
export declare const CompressAdaptorRole: AdaptorCls<CompressAdaptor>;
|
|
19
20
|
export declare const LlmAdaptorRole: AdaptorCls<LlmAdaptor>;
|
|
21
|
+
export declare const AgentToolsRole: AdaptorCls<AgentToolsAdaptor>;
|
|
@@ -3,6 +3,9 @@ declare const SolidPubSub_base: import("..").AdaptorCls<{}, {
|
|
|
3
3
|
serverId: import("..").InjectInfo<"env", string, {
|
|
4
4
|
[key: string]: any;
|
|
5
5
|
}, never>;
|
|
6
|
+
behindGateway: import("..").InjectInfo<"env", boolean, {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
}, never>;
|
|
6
9
|
}>;
|
|
7
10
|
export declare class SolidPubSub extends SolidPubSub_base implements WebsocketAdaptor {
|
|
8
11
|
#private;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DocumentRowCodec } from "./DocumentRowCodec.d.ts";
|
|
2
|
+
import type { SqlDocumentStore } from "./SqlDocumentStore.d.ts";
|
|
3
|
+
import { StoredRows } from "./StoredRows.d.ts";
|
|
4
|
+
import { type DocumentRecord } from "./types.d.ts";
|
|
5
|
+
export declare class DocumentHydrator {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(store: SqlDocumentStore, codec: DocumentRowCodec, rows: StoredRows);
|
|
8
|
+
hydrate(data: DocumentRecord, originalData?: DocumentRecord, { track }?: {
|
|
9
|
+
track?: boolean;
|
|
10
|
+
}): any;
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type DatabaseModel } from "akanjs/document";
|
|
2
|
+
import type { QueryCompiler } from "./QueryCompiler.d.ts";
|
|
3
|
+
import { type DocumentRecord, type ProjectedSqliteDocumentRow, type ProjectionOption, type SqlDialect, type SqliteDocumentRow } from "./types.d.ts";
|
|
4
|
+
export declare class DocumentRowCodec {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(database: DatabaseModel, table: string, dialect: SqlDialect, compiler: QueryCompiler);
|
|
7
|
+
prepareDocument(data: DocumentRecord): {
|
|
8
|
+
[x: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
toRow({ id, createdAt, updatedAt, removedAt, ...payload }: DocumentRecord): {
|
|
11
|
+
id: unknown;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
updatedAt: number;
|
|
14
|
+
removedAt: number | null;
|
|
15
|
+
_doc: string;
|
|
16
|
+
};
|
|
17
|
+
fromRow(row: SqliteDocumentRow): {
|
|
18
|
+
id: string;
|
|
19
|
+
createdAt: import("dayjs").Dayjs;
|
|
20
|
+
updatedAt: import("dayjs").Dayjs;
|
|
21
|
+
removedAt: import("dayjs").Dayjs | undefined;
|
|
22
|
+
};
|
|
23
|
+
resolveProjection(select: ProjectionOption): string[] | null;
|
|
24
|
+
projectionSql(fields: string[]): string;
|
|
25
|
+
fromProjectedRow(row: ProjectedSqliteDocumentRow, fields: string[]): DocumentRecord;
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DocumentRowCodec } from "./DocumentRowCodec.d.ts";
|
|
2
|
+
import type { QueryScope } from "./QueryScope.d.ts";
|
|
3
|
+
import type { SqlDocumentStore } from "./SqlDocumentStore.d.ts";
|
|
4
|
+
import { StoredRows } from "./StoredRows.d.ts";
|
|
5
|
+
import { type AkanSqlStatement, type DocumentDatabaseOwner, type DocumentRecord, type SqlDialect, type UpsertByIdOptions, type WriteHookOptions } from "./types.d.ts";
|
|
6
|
+
export interface DocumentWriterOptions {
|
|
7
|
+
owner: DocumentDatabaseOwner;
|
|
8
|
+
store: SqlDocumentStore;
|
|
9
|
+
dialect: SqlDialect;
|
|
10
|
+
codec: DocumentRowCodec;
|
|
11
|
+
rows: StoredRows;
|
|
12
|
+
scope: QueryScope;
|
|
13
|
+
prepare: (sql: string) => AkanSqlStatement;
|
|
14
|
+
written: (doc: DocumentRecord, previous?: DocumentRecord) => Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare class DocumentWriter {
|
|
17
|
+
#private;
|
|
18
|
+
constructor({ owner, store, dialect, codec, rows, scope, prepare, written }: DocumentWriterOptions);
|
|
19
|
+
create(data: DocumentRecord, { runSaveHooks }?: WriteHookOptions): Promise<any>;
|
|
20
|
+
createMany(data: DocumentRecord[]): Promise<any[]>;
|
|
21
|
+
upsertById(data: DocumentRecord & {
|
|
22
|
+
id: string;
|
|
23
|
+
}, { preserveTimestamps, where, withRemoved }?: UpsertByIdOptions): Promise<any>;
|
|
24
|
+
update(id: string, patch: DocumentRecord, options?: WriteHookOptions): Promise<any>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type DocumentQuery, type DocumentScopeOptions } from "akanjs/document";
|
|
2
|
+
import type { QueryCompiler } from "./QueryCompiler.d.ts";
|
|
3
|
+
import type { FindManyOptions, SearchJoin } from "./types.d.ts";
|
|
4
|
+
export declare class QueryScope {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(table: string, compiler: QueryCompiler);
|
|
7
|
+
listQuery(query: DocumentQuery | undefined, options: FindManyOptions, operation?: string): {
|
|
8
|
+
star: string;
|
|
9
|
+
tail: string;
|
|
10
|
+
args: unknown[];
|
|
11
|
+
};
|
|
12
|
+
safeQuery(query: DocumentQuery | undefined, operation: string, { withRemoved }: DocumentScopeOptions): import("./types.d.ts").CompiledQuery;
|
|
13
|
+
writeQuery(query: DocumentQuery | undefined, operation: string, options: DocumentScopeOptions): import("./types.d.ts").CompiledQuery;
|
|
14
|
+
joinSql(joins: SearchJoin[]): string;
|
|
15
|
+
joinParams(joins: SearchJoin[]): unknown[];
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type DocumentQuery, type DocumentScopeOptions, type DocumentTouchOptions, type DocumentUpdateInput, type DocumentUpdateOptions } from "akanjs/document";
|
|
2
|
+
import type { QueryScope } from "./QueryScope.d.ts";
|
|
3
|
+
import type { SqlDocumentStore } from "./SqlDocumentStore.d.ts";
|
|
4
|
+
import type { DocumentDatabaseOwner, SqlDialect } from "./types.d.ts";
|
|
5
|
+
export declare class QueryWriter {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(owner: DocumentDatabaseOwner, store: SqlDocumentStore, dialect: SqlDialect, scope: QueryScope);
|
|
8
|
+
updateOne(query: DocumentQuery, update: DocumentUpdateInput, options: DocumentUpdateOptions, operation: string): Promise<{
|
|
9
|
+
acknowledged: boolean;
|
|
10
|
+
matchedCount: number;
|
|
11
|
+
modifiedCount: number;
|
|
12
|
+
upsertedId: any;
|
|
13
|
+
}>;
|
|
14
|
+
updateMany(query: DocumentQuery, update: DocumentUpdateInput, options: DocumentScopeOptions & DocumentTouchOptions, operation: string): Promise<{
|
|
15
|
+
acknowledged: boolean;
|
|
16
|
+
matchedCount: number;
|
|
17
|
+
modifiedCount: number;
|
|
18
|
+
}>;
|
|
19
|
+
purgeMany(query: DocumentQuery): Promise<number>;
|
|
20
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ConstantModel } from "akanjs/constant";
|
|
2
2
|
import { type DatabaseModel, type DocumentQuery, type DocumentSchema, type DocumentScopeOptions, type DocumentTouchOptions, type DocumentUpdateInput, type DocumentUpdateOptions } from "akanjs/document";
|
|
3
3
|
import { QueryCompiler } from "./QueryCompiler.d.ts";
|
|
4
|
-
import { type DocumentDatabaseOwner, type DocumentRecord, type FindIdOptions, type FindManyOptions, type FindOneOptions, type SqlDialect, type TransferRow, type UpsertByIdOptions, type WriteHookOptions } from "./types.d.ts";
|
|
4
|
+
import { type DocumentDatabaseOwner, type DocumentRecord, type DocumentWriteListener, type FindIdOptions, type FindManyOptions, type FindOneOptions, type PrunedIndex, type SqlDialect, type TransferRow, type UndeclaredIndex, type UpsertByIdOptions, type WriteHookOptions } from "./types.d.ts";
|
|
5
5
|
import { UpdateCompiler } from "./UpdateCompiler.d.ts";
|
|
6
6
|
export declare class SqlDocumentStore {
|
|
7
7
|
#private;
|
|
@@ -15,6 +15,9 @@ export declare class SqlDocumentStore {
|
|
|
15
15
|
readonly updateCompiler: UpdateCompiler;
|
|
16
16
|
constructor(owner: DocumentDatabaseOwner, constant: ConstantModel, database: DatabaseModel, schema: DocumentSchema, dialect?: SqlDialect);
|
|
17
17
|
ensure(): Promise<void>;
|
|
18
|
+
onWrite(listener: DocumentWriteListener): () => void;
|
|
19
|
+
undeclaredIndexes(): Promise<UndeclaredIndex[]>;
|
|
20
|
+
pruneUndeclaredIndexes(): Promise<PrunedIndex[]>;
|
|
18
21
|
create(data: DocumentRecord, { runSaveHooks }?: WriteHookOptions): Promise<any>;
|
|
19
22
|
createMany(data: DocumentRecord[]): Promise<any[]>;
|
|
20
23
|
clone(data: DocumentRecord & {
|
|
@@ -52,7 +55,6 @@ export declare class SqlDocumentStore {
|
|
|
52
55
|
upsertedId: any;
|
|
53
56
|
}>;
|
|
54
57
|
purgeManyByQuery(query: DocumentQuery): Promise<number>;
|
|
55
|
-
private compiledUpdate;
|
|
56
58
|
bulkWrite(operations: {
|
|
57
59
|
updateOne: {
|
|
58
60
|
filter: DocumentQuery;
|
|
@@ -67,7 +69,6 @@ export declare class SqlDocumentStore {
|
|
|
67
69
|
}>;
|
|
68
70
|
find(query?: DocumentQuery, options?: FindManyOptions): Promise<any[]>;
|
|
69
71
|
findIds(query?: DocumentQuery, options?: Omit<FindManyOptions, "select">): Promise<string[]>;
|
|
70
|
-
private listQuery;
|
|
71
72
|
findOne(query?: DocumentQuery, options?: FindOneOptions): Promise<any>;
|
|
72
73
|
findId(query?: DocumentQuery, options?: FindIdOptions): Promise<string | null>;
|
|
73
74
|
pickOne(query?: DocumentQuery, options?: FindOneOptions): Promise<any>;
|
|
@@ -77,27 +78,6 @@ export declare class SqlDocumentStore {
|
|
|
77
78
|
/** The stored numbers at `path` added up over the live rows the query matches; 0 when none. */
|
|
78
79
|
sum(path: string, query?: DocumentQuery): Promise<number>;
|
|
79
80
|
insight(query?: DocumentQuery): Promise<DocumentRecord>;
|
|
80
|
-
private safeQuery;
|
|
81
|
-
private writeQuery;
|
|
82
|
-
private joinSql;
|
|
83
|
-
private joinParams;
|
|
84
|
-
private orderBy;
|
|
85
|
-
private prepareDocument;
|
|
86
|
-
private extractInsertBase;
|
|
87
|
-
private applyInsertUpdate;
|
|
88
|
-
private toRow;
|
|
89
|
-
private fromRow;
|
|
90
|
-
private normalizeProjection;
|
|
91
|
-
private resolveProjection;
|
|
92
|
-
private defaultProjection;
|
|
93
|
-
private projectionSql;
|
|
94
|
-
private projectionAlias;
|
|
95
|
-
private fromProjectedRow;
|
|
96
|
-
private findForWrite;
|
|
97
|
-
private findOneForWrite;
|
|
98
|
-
private pickByIdForWrite;
|
|
99
|
-
private writeUpdatedDocument;
|
|
100
|
-
private decodeDocumentPayload;
|
|
101
81
|
/** `track` buys `isModified()` with a deep clone of the row; only the read paths opt out. */
|
|
102
82
|
hydrate(data: DocumentRecord, originalData?: DocumentRecord, { track }?: {
|
|
103
83
|
track?: boolean;
|
|
@@ -106,8 +86,5 @@ export declare class SqlDocumentStore {
|
|
|
106
86
|
deserialize(text: string): any;
|
|
107
87
|
/** Another instance of a read document, built from the row it was read as, so what either is set to stays its own. */
|
|
108
88
|
rehydrate(doc: DocumentRecord): any;
|
|
109
|
-
private runHooks;
|
|
110
|
-
private insertStmt;
|
|
111
89
|
private prepareStmt;
|
|
112
|
-
private assertValidRefName;
|
|
113
90
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Logger } from "akanjs/common";
|
|
2
|
+
import type { ConstantModel } from "akanjs/constant";
|
|
3
|
+
import type { DatabaseModel, DocumentSchema } from "akanjs/document";
|
|
4
|
+
import type { QueryCompiler } from "./QueryCompiler.d.ts";
|
|
5
|
+
import { type DocumentDatabaseOwner, type PrunedIndex, type SqlDialect, type UndeclaredIndex } from "./types.d.ts";
|
|
6
|
+
export interface SqlTableSchemaOptions {
|
|
7
|
+
owner: DocumentDatabaseOwner;
|
|
8
|
+
table: string;
|
|
9
|
+
schema: DocumentSchema;
|
|
10
|
+
constant: ConstantModel;
|
|
11
|
+
database: DatabaseModel;
|
|
12
|
+
dialect: SqlDialect;
|
|
13
|
+
compiler: QueryCompiler;
|
|
14
|
+
logger: Logger;
|
|
15
|
+
}
|
|
16
|
+
export declare class SqlTableSchema {
|
|
17
|
+
#private;
|
|
18
|
+
constructor({ owner, table, schema, constant, database, dialect, compiler, logger }: SqlTableSchemaOptions);
|
|
19
|
+
ensure(): Promise<void>;
|
|
20
|
+
undeclaredIndexes(): Promise<UndeclaredIndex[]>;
|
|
21
|
+
pruneUndeclaredIndexes(): Promise<PrunedIndex[]>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Logger } from "akanjs/common";
|
|
2
|
+
import type { DocumentRowCodec } from "./DocumentRowCodec.d.ts";
|
|
3
|
+
import type { SqlDocumentStore } from "./SqlDocumentStore.d.ts";
|
|
4
|
+
import type { DocumentRecord, ProjectedSqliteDocumentRow, SqliteDocumentRow } from "./types.d.ts";
|
|
5
|
+
export type StoredRow = Omit<SqliteDocumentRow, "id">;
|
|
6
|
+
interface ProjectedRead {
|
|
7
|
+
row: ProjectedSqliteDocumentRow;
|
|
8
|
+
fields: string[];
|
|
9
|
+
}
|
|
10
|
+
export type StoredRead = StoredRow | ProjectedRead;
|
|
11
|
+
export declare class StoredRows {
|
|
12
|
+
#private;
|
|
13
|
+
/** The row a document was read or last written as. */
|
|
14
|
+
static readonly storedRow: unique symbol;
|
|
15
|
+
/** Set on a document read as removed, which only a `withRemoved` read hands out. */
|
|
16
|
+
static readonly readRemoved: unique symbol;
|
|
17
|
+
constructor(store: SqlDocumentStore, codec: DocumentRowCodec, logger: Logger);
|
|
18
|
+
changesOf(doc: DocumentRecord): DocumentRecord;
|
|
19
|
+
hydrateStored(stored: StoredRead, id: string): any;
|
|
20
|
+
static encodedFields({ createdAt, removedAt, _doc }: StoredRow): Map<string, string>;
|
|
21
|
+
withStoredRow<Doc extends object>(doc: Doc, row: StoredRead): Doc;
|
|
22
|
+
readAs<Doc extends object>(doc: Doc, { removedAt }: {
|
|
23
|
+
removedAt?: unknown;
|
|
24
|
+
}): Doc;
|
|
25
|
+
assertLiveRow(doc: DocumentRecord): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
import type {
|
|
2
|
+
import type { PromiseOrObject } from "akanjs/base";
|
|
3
|
+
import type { AfterCommitOptions, TransactionContext } from "./types.d.ts";
|
|
3
4
|
export declare class TransactionScope {
|
|
4
5
|
static live<T extends TransactionContext>(storage: AsyncLocalStorage<T>): T | undefined;
|
|
6
|
+
static queue(context: TransactionContext, fn: () => PromiseOrObject<void>, { first }: AfterCommitOptions): void;
|
|
5
7
|
static runAfterCommit(context: TransactionContext): Promise<void>;
|
|
6
8
|
}
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import type { Database
|
|
1
|
+
import type { Database } from "bun:sqlite";
|
|
2
2
|
import type { AkanSqlClient, AkanSqlStatement } from "../types.d.ts";
|
|
3
3
|
/** Resolves once a write from the calling context may run; `null` when it may run now. */
|
|
4
4
|
export type SqliteWriteTurn = () => Promise<void> | null;
|
|
5
5
|
/** The connection a read from the calling context runs on; `null` for the one the statement was prepared on. */
|
|
6
6
|
export type SqliteReader = () => Database | null;
|
|
7
|
-
export declare const openTurn: SqliteWriteTurn;
|
|
8
|
-
export declare const ownConnection: SqliteReader;
|
|
9
|
-
export declare class BunSqliteStatement implements AkanSqlStatement {
|
|
10
|
-
#private;
|
|
11
|
-
private readonly sql;
|
|
12
|
-
private readonly statement;
|
|
13
|
-
private readonly writeTurn;
|
|
14
|
-
private readonly readerOf;
|
|
15
|
-
constructor(sql: string, statement: Statement, writeTurn?: SqliteWriteTurn, readerOf?: SqliteReader);
|
|
16
|
-
run(...params: unknown[]): Promise<import("bun:sqlite").Changes>;
|
|
17
|
-
get<Row = Record<string, unknown>>(...params: unknown[]): Promise<Row | null>;
|
|
18
|
-
all<Row = Record<string, unknown>>(...params: unknown[]): Promise<Row[]>;
|
|
19
|
-
}
|
|
20
7
|
export declare class BunSqliteClient implements AkanSqlClient {
|
|
21
8
|
readonly db: Database;
|
|
22
9
|
private readonly writeTurn;
|
|
23
10
|
private readonly readerOf;
|
|
24
|
-
|
|
11
|
+
private readonly readerLasts;
|
|
12
|
+
constructor(db: Database, writeTurn?: SqliteWriteTurn, readerOf?: SqliteReader, readerLasts?: boolean);
|
|
25
13
|
execute(sql: string, params?: unknown[] | Record<string, unknown>): Promise<unknown>;
|
|
26
14
|
prepare(sql: string): AkanSqlStatement;
|
|
27
15
|
close(): Promise<void>;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import type { Sql, TransactionSql } from "postgres";
|
|
2
2
|
import type { AkanSqlClient, AkanSqlStatement } from "../types.d.ts";
|
|
3
|
-
export declare class PostgresStatement implements AkanSqlStatement {
|
|
4
|
-
private readonly client;
|
|
5
|
-
private readonly sql;
|
|
6
|
-
constructor(client: Sql | TransactionSql, sql: string);
|
|
7
|
-
run(...params: unknown[]): Promise<import("postgres").RowList<(import("postgres").Row & Iterable<import("postgres").Row>)[]>>;
|
|
8
|
-
get<Row = Record<string, unknown>>(...params: unknown[]): Promise<Row | null>;
|
|
9
|
-
all<Row = Record<string, unknown>>(...params: unknown[]): Promise<Row[]>;
|
|
10
|
-
}
|
|
11
3
|
export declare class PostgresAkanClient implements AkanSqlClient {
|
|
12
4
|
readonly client: Sql | TransactionSql;
|
|
13
5
|
constructor(client: Sql | TransactionSql);
|