akanjs 3.2.0-rc.2 → 3.2.0-rc.21
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 +42 -41
- package/CHANGELOG.md +593 -3
- package/CONTRIBUTING.md +26 -0
- package/base/base.ts +2 -1
- package/client/clientRuntime.ts +1 -0
- package/client/cn.ts +2 -2
- package/client/csrTypes.ts +15 -1
- package/client/frameConfig.ts +5 -2
- package/client/index.ts +249 -26
- package/client/locale.ts +1 -0
- package/client/makePageProto.tsx +33 -82
- package/client/nativeThemeColor.ts +51 -0
- package/client/route/RouteDefinition.ts +24 -7
- package/client/route/RouteGuards.ts +2 -1
- package/client/route/RouteHead.ts +11 -2
- package/client/route/routeArgs.ts +7 -0
- package/client/router.ts +25 -6
- package/client/rscNavigation.ts +3 -3
- package/client/rscRoutePatch.ts +42 -0
- package/client/viewportMeta.ts +34 -4
- package/common/CodeTranscript.ts +1 -1
- package/common/PipelinePlanSchema.ts +2 -2
- package/common/akanGraph.ts +1 -1
- package/common/err.ts +122 -0
- package/common/facetBarrel.ts +38 -0
- package/common/failureCode.ts +18 -0
- package/common/index.ts +9 -0
- package/common/isGuardRefusal.ts +14 -0
- package/common/mcpExposure.ts +17 -4
- package/common/mcpFailure.ts +9 -0
- package/common/pipelinePlan.ts +1 -1
- package/common/restartSchedule.ts +55 -0
- 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 +4 -0
- package/dictionary/base.dictionary.ts +1 -0
- package/dictionary/locale.ts +1 -1
- package/dictionary/trans.ts +14 -97
- 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 +87 -270
- package/fetch/client/fetchClientTypes.ts +49 -0
- package/fetch/client/fetchHandle.ts +11 -1
- package/fetch/client/httpClient.ts +14 -2
- package/fetch/client/inflightQueries.ts +17 -0
- package/fetch/client/remoteError.ts +4 -20
- package/fetch/client/requestScope.ts +32 -0
- package/fetch/client/signalCatalog.ts +131 -0
- package/fetch/client/wsClient.ts +11 -0
- package/fetch/index.ts +1 -0
- package/fetch/staleReads.ts +27 -0
- package/fetch/streamedRead.ts +23 -0
- package/package.json +1 -1
- package/server/agentHooks.ts +16 -0
- package/server/akanApp.ts +107 -1272
- package/server/akanOption.ts +17 -4
- package/server/akanServer.ts +167 -675
- package/server/artifact/builderRpc.ts +33 -10
- package/server/artifact/ipcTypes.ts +9 -3
- 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/devtools/README.md +4 -3
- package/server/devtools/devtoolsRouter.ts +9 -5
- package/server/devtools/studio/studioRoute.ts +18 -11
- package/server/di/diLifecycle.ts +24 -35
- package/server/di/predefinedAdaptor.ts +24 -1
- package/server/di/resolveHierarchy.ts +19 -6
- package/server/di/utils.ts +7 -3
- package/server/ed25519Key.ts +31 -15
- package/server/flightRowReader.ts +95 -18
- package/server/gateway/childSupervisor.ts +326 -0
- package/server/gateway/devHostChannel.ts +47 -0
- package/server/gateway/gatewayChildren.ts +135 -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 +116 -0
- package/server/gateway/gatewayStatusPage.ts +54 -0
- package/server/gateway/gatewayWebSocketRelay.ts +149 -0
- package/server/head.tsx +4 -19
- package/server/hmr/devHmrController.ts +10 -1
- package/server/htmlResultCache.ts +234 -0
- package/server/imageOptimizer.ts +4 -1
- package/server/index.ts +257 -17
- package/server/lifecycle/parentChannel.ts +78 -0
- package/server/lifecycle/shutdownManager.ts +6 -3
- package/server/lifecycle/startGuard.ts +90 -0
- package/server/logging/logControlSocket.ts +42 -3
- 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/McpDispatcher.ts +48 -19
- package/server/mcp/McpPages.ts +21 -6
- package/server/mcp/McpRateLimiter.ts +14 -0
- package/server/mcp/McpRouter.ts +52 -23
- package/server/mcp/McpUiSession.ts +2 -1
- package/server/mcp/index.ts +1 -0
- package/server/nativeFile.ts +30 -11
- package/server/nativeSecret.ts +12 -3
- package/server/oauth/OAuthClientIdMetadata.ts +2 -2
- package/server/ops/opsRoute.ts +5 -1
- package/server/ops/opsToken.ts +3 -1
- package/server/resolver/CascadeRunner.ts +10 -4
- package/server/resolver/database.resolver.ts +10 -417
- package/server/resolver/databaseModelInstance.ts +200 -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 +52 -0
- package/server/resolver/modelSchema.ts +52 -0
- package/server/resolver/signal.resolver.ts +92 -116
- package/server/resolver/timedQuery.ts +16 -0
- package/server/resolver/websocketOf.ts +23 -0
- package/server/routeElementComposer.tsx +131 -9
- package/server/routeState.ts +5 -1
- package/server/routeTreeBuilder.ts +22 -9
- package/server/routing/apiRouter.ts +44 -25
- 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 +210 -227
- package/server/rscClientCache.ts +165 -0
- package/server/rscClientChunks.ts +209 -0
- package/server/rscClientFetch.ts +15 -3
- package/server/rscClientPatch.ts +78 -15
- package/server/rscDocumentHead.tsx +170 -0
- package/server/rscFlightRenderer.ts +83 -0
- package/server/rscFlightStream.ts +257 -0
- package/server/rscHeadPatch.ts +17 -56
- 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/rscInlineStream.ts +34 -0
- package/server/rscNavigationState.ts +21 -1
- package/server/rscPagePrompts.ts +11 -5
- package/server/rscParkedRedirect.ts +23 -0
- package/server/rscPatchPlanner.ts +220 -0
- package/server/rscPrefetchCache.ts +68 -32
- package/server/rscRenderControl.ts +33 -0
- package/server/rscRenderFallbacks.ts +297 -0
- package/server/rscRenderHandler.ts +439 -0
- package/server/rscRenderStats.ts +49 -0
- package/server/rscResponse.ts +78 -0
- package/server/rscResultCaches.ts +74 -0
- package/server/rscRouteDocument.tsx +299 -0
- package/server/rscSegmentOutlet.tsx +24 -5
- package/server/rscSegmentOutletReference.ts +14 -12
- package/server/rscWorker.tsx +86 -1392
- package/server/rscWorkerCache.ts +56 -0
- package/server/rscWorkerHost.ts +145 -811
- 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/ssrTypes.ts +9 -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 +126 -1242
- package/server/webRscRoute.ts +155 -0
- package/server/webSiteFiles.ts +139 -0
- package/server/wellKnownRoutes.ts +73 -0
- package/service/agent.service.ts +59 -5
- package/service/agentAccounts.ts +19 -0
- package/service/agentLoop/agentLoop.ts +387 -0
- package/service/agentLoop/agentLoopTypes.ts +112 -0
- package/service/agentLoop/deltaStream.ts +40 -0
- package/service/agentLoop/loopCompaction.ts +135 -0
- package/service/agentLoop/loopRequest.ts +62 -0
- package/service/agentLoop/loopToolOutput.ts +54 -0
- package/service/agentLoop/loopToolkits.ts +107 -0
- package/service/agentLoop/loopTranscript.ts +102 -0
- package/{signal → service}/agentMeter.ts +83 -15
- package/{signal → service}/agentRelayPolicy.ts +30 -7
- package/service/documentStoreError.ts +16 -0
- package/service/index.ts +7 -0
- package/service/injectError.ts +5 -0
- package/service/injectInfo.ts +30 -18
- package/service/insightQueryError.ts +19 -0
- package/service/ipcTypes.ts +3 -1
- package/service/liveSyncHub.ts +5 -2
- package/service/predefinedAdaptor/agentTools.adaptor.ts +34 -0
- package/service/predefinedAdaptor/anthropicLlm.ts +52 -21
- package/service/predefinedAdaptor/cache.adaptor.ts +3 -2
- package/service/predefinedAdaptor/compress.adaptor.ts +7 -3
- package/service/predefinedAdaptor/database.adaptor.ts +3 -1
- package/service/predefinedAdaptor/documentTransfer.ts +2 -1
- package/service/predefinedAdaptor/index.ts +2 -0
- package/service/predefinedAdaptor/insightQuery.ts +35 -11
- package/service/predefinedAdaptor/llm.adaptor.ts +22 -2
- package/service/predefinedAdaptor/llmSpend.ts +80 -0
- package/service/predefinedAdaptor/openaiDialect.ts +52 -17
- package/service/predefinedAdaptor/openaiLlm.ts +17 -9
- package/service/predefinedAdaptor/role.adaptor.ts +2 -0
- package/service/predefinedAdaptor/searchIndex.ts +5 -1
- package/service/predefinedAdaptor/solidPubsub.adaptor.ts +35 -2
- package/service/predefinedAdaptor/solidQueue.adaptor.ts +2 -2
- package/service/predefinedAdaptor/solidSqlite.ts +3 -2
- package/service/predefinedAdaptor/sql/DocumentHydrator.ts +95 -0
- package/service/predefinedAdaptor/sql/DocumentRowCodec.ts +192 -0
- package/service/predefinedAdaptor/sql/DocumentWriter.ts +292 -0
- package/service/predefinedAdaptor/sql/PostgresInsightSession.ts +15 -5
- package/service/predefinedAdaptor/sql/QueryCompiler.ts +29 -13
- package/service/predefinedAdaptor/sql/QueryScope.ts +70 -0
- package/service/predefinedAdaptor/sql/QueryWriter.ts +200 -0
- package/service/predefinedAdaptor/sql/RawDocumentTable.ts +20 -8
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +83 -1124
- package/service/predefinedAdaptor/sql/SqlTableSchema.ts +319 -0
- package/service/predefinedAdaptor/sql/SqliteInsightSession.ts +2 -1
- package/service/predefinedAdaptor/sql/StoredRows.ts +95 -0
- package/service/predefinedAdaptor/sql/UpdateCompiler.ts +6 -2
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +3 -3
- package/service/predefinedAdaptor/sql/driver/postgres.ts +1 -1
- package/service/predefinedAdaptor/sql/fieldValues.ts +74 -0
- package/service/predefinedAdaptor/sql/search/fts5.ts +4 -1
- package/service/predefinedAdaptor/sql/search/postgres.ts +6 -2
- package/service/predefinedAdaptor/sql/values.ts +8 -4
- package/service/predefinedAdaptor/sseData.ts +14 -0
- package/service/predefinedAdaptor/storage.adaptor.ts +9 -4
- package/service/predefinedAdaptor/websocket.adaptor.ts +199 -43
- package/service/serve.ts +3 -2
- package/service/serviceModule.ts +2 -2
- package/service/serviceRegistry.ts +1 -0
- package/signal/SignalFailure.ts +30 -1
- package/signal/agent.signal.ts +30 -9
- package/signal/agentTurnStream.ts +12 -8
- package/signal/byIdRead.ts +18 -0
- package/signal/carriedClientIps.ts +1 -0
- package/signal/endpointErrorContract.ts +20 -2
- package/signal/endpointInfo.ts +6 -5
- package/signal/exception.ts +1 -0
- package/signal/index.ts +314 -30
- package/signal/internalInfo.ts +6 -4
- package/signal/mcp/McpDocument.ts +8 -1
- package/signal/mcp/Msg.ts +23 -10
- package/signal/mcp/index.ts +1 -0
- package/signal/mcp/promptError.ts +9 -0
- package/signal/middleware.ts +12 -3
- package/signal/openapi/openapi.ts +10 -1
- package/signal/resolveFieldContext.ts +34 -0
- package/signal/serializer/fetch.serializer.ts +23 -15
- package/signal/signalContext.ts +24 -57
- package/signal/signalContractError.ts +10 -0
- package/signal/signalDeclarationError.ts +13 -0
- package/signal/signalRegistry.ts +3 -1
- package/signal/slice.ts +24 -20
- package/signal/sliceInfo.ts +12 -9
- package/signal/trace.ts +3 -0
- package/signal/types.ts +35 -6
- package/store/action.ts +44 -1086
- package/store/actionErrorKey.ts +9 -0
- package/store/actionOption.ts +22 -0
- package/store/baseSt.ts +1 -0
- package/store/draftFlush.ts +5 -0
- package/store/draftStore.ts +2 -0
- package/store/formDrafts.ts +115 -0
- package/store/formFieldSetters.ts +229 -0
- package/store/index.ts +125 -17
- package/store/modelActionContext.ts +65 -0
- package/store/modelListPatch.ts +53 -0
- package/store/modelOpenActions.ts +158 -0
- package/store/modelWriteActions.ts +240 -0
- package/store/modelWriteGuard.ts +82 -0
- package/store/openSeq.ts +34 -0
- package/store/rootStore.ts +2 -0
- package/store/sliceListActions.ts +370 -0
- package/store/sliceLiveActions.ts +130 -0
- package/store/stateBuilder.ts +2 -0
- package/store/storeInstance.ts +9 -10
- package/store/uploadPoll.ts +52 -0
- package/store/withSelector.ts +6 -4
- 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 +15 -1
- 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 +28 -26091
- package/types/client/nativeThemeColor.d.ts +6 -0
- package/types/client/route/RouteDefinition.d.ts +2 -2
- package/types/client/route/RouteHead.d.ts +5 -1
- package/types/client/route/routeArgs.d.ts +6 -0
- package/types/client/router.d.ts +6 -3
- package/types/client/rscNavigation.d.ts +3 -2
- package/types/client/rscRoutePatch.d.ts +22 -0
- package/types/client/viewportMeta.d.ts +3 -1
- package/types/common/CodeTranscript.d.ts +1 -1
- package/types/common/akanGraph.d.ts +1 -1
- package/types/common/err.d.ts +48 -0
- package/types/common/facetBarrel.d.ts +4 -0
- package/types/common/failureCode.d.ts +6 -0
- package/types/common/index.d.ts +8 -2
- package/types/common/isGuardRefusal.d.ts +3 -0
- package/types/common/mcpExposure.d.ts +9 -2
- package/types/common/mcpFailure.d.ts +6 -0
- package/types/common/restartSchedule.d.ts +16 -0
- 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/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/fetchHandle.d.ts +1 -0
- package/types/fetch/client/httpClient.d.ts +2 -0
- package/types/fetch/client/inflightQueries.d.ts +2 -0
- package/types/fetch/client/remoteError.d.ts +0 -4
- package/types/fetch/client/requestScope.d.ts +6 -0
- package/types/fetch/client/signalCatalog.d.ts +25 -0
- package/types/fetch/client/wsClient.d.ts +1 -0
- package/types/fetch/index.d.ts +1 -0
- package/types/fetch/staleReads.d.ts +8 -0
- package/types/fetch/streamedRead.d.ts +8 -0
- package/types/server/agentHooks.d.ts +4 -0
- package/types/server/akanApp.d.ts +2 -20
- package/types/server/akanOption.d.ts +9 -3
- package/types/server/akanServer.d.ts +1 -1
- package/types/server/artifact/builderRpc.d.ts +8 -0
- package/types/server/artifact/ipcTypes.d.ts +8 -0
- package/types/server/assetHeaders.d.ts +1 -0
- package/types/server/console.d.ts +4 -3
- package/types/server/devtools/devtoolsRouter.d.ts +4 -1
- package/types/server/devtools/studio/studioRoute.d.ts +2 -1
- package/types/server/di/predefinedAdaptor.d.ts +1 -0
- package/types/server/ed25519Key.d.ts +1 -0
- package/types/server/flightRowReader.d.ts +3 -1
- package/types/server/gateway/childSupervisor.d.ts +33 -0
- package/types/server/gateway/devHostChannel.d.ts +14 -0
- package/types/server/gateway/gatewayChildren.d.ts +47 -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 +62 -0
- package/types/server/gateway/gatewayStatusPage.d.ts +9 -0
- package/types/server/gateway/gatewayWebSocketRelay.d.ts +17 -0
- package/types/server/head.d.ts +2 -2
- package/types/server/htmlResultCache.d.ts +51 -0
- package/types/server/index.d.ts +17 -17
- package/types/server/lifecycle/parentChannel.d.ts +13 -0
- package/types/server/lifecycle/startGuard.d.ts +10 -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/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/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 +9 -0
- package/types/server/resolver/modelSchema.d.ts +6 -0
- package/types/server/resolver/signal.resolver.d.ts +2 -2
- package/types/server/resolver/timedQuery.d.ts +8 -0
- package/types/server/resolver/websocketOf.d.ts +2 -0
- package/types/server/routeElementComposer.d.ts +45 -6
- package/types/server/routeState.d.ts +2 -0
- 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/rscClient.d.ts +1 -5
- package/types/server/rscClientCache.d.ts +34 -0
- package/types/server/rscClientChunks.d.ts +18 -0
- package/types/server/rscClientFetch.d.ts +1 -1
- package/types/server/rscClientPatch.d.ts +12 -1
- package/types/server/rscDocumentHead.d.ts +32 -0
- package/types/server/rscFlightRenderer.d.ts +14 -0
- package/types/server/rscFlightStream.d.ts +52 -0
- package/types/server/rscHeadPatch.d.ts +5 -4
- 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/rscInlineStream.d.ts +9 -0
- package/types/server/rscNavigationState.d.ts +8 -3
- package/types/server/rscParkedRedirect.d.ts +12 -0
- package/types/server/rscPatchPlanner.d.ts +49 -0
- package/types/server/rscPrefetchCache.d.ts +8 -7
- 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/rscResponse.d.ts +9 -0
- package/types/server/rscResultCaches.d.ts +18 -0
- package/types/server/rscRouteDocument.d.ts +52 -0
- package/types/server/rscSegmentOutlet.d.ts +5 -0
- package/types/server/rscSegmentOutletReference.d.ts +2 -1
- package/types/server/rscWorker.d.ts +1 -3
- package/types/server/rscWorkerCache.d.ts +33 -1
- package/types/server/rscWorkerHost.d.ts +9 -76
- 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/ssrTypes.d.ts +8 -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 +4 -35
- package/types/server/webRscRoute.d.ts +24 -0
- package/types/server/webSiteFiles.d.ts +12 -0
- package/types/server/wellKnownRoutes.d.ts +5 -0
- package/types/service/agent.service.d.ts +13 -4
- package/types/service/agentAccounts.d.ts +8 -0
- package/types/service/agentLoop/agentLoop.d.ts +31 -0
- package/types/service/agentLoop/agentLoopTypes.d.ts +126 -0
- package/types/service/agentLoop/deltaStream.d.ts +3 -0
- package/types/service/agentLoop/loopCompaction.d.ts +11 -0
- package/types/service/agentLoop/loopRequest.d.ts +6 -0
- package/types/service/agentLoop/loopToolOutput.d.ts +7 -0
- package/types/service/agentLoop/loopToolkits.d.ts +14 -0
- package/types/service/agentLoop/loopTranscript.d.ts +12 -0
- package/types/service/agentMeter.d.ts +50 -0
- package/types/service/agentRelayPolicy.d.ts +45 -0
- package/types/service/documentStoreError.d.ts +7 -0
- package/types/service/index.d.ts +7 -0
- package/types/service/injectError.d.ts +4 -0
- package/types/service/injectInfo.d.ts +2 -1
- package/types/service/insightQueryError.d.ts +9 -0
- package/types/service/ipcTypes.d.ts +6 -0
- package/types/service/predefinedAdaptor/agentTools.adaptor.d.ts +31 -0
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +2 -2
- package/types/service/predefinedAdaptor/index.d.ts +2 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +18 -2
- package/types/service/predefinedAdaptor/llmSpend.d.ts +22 -0
- package/types/service/predefinedAdaptor/openaiDialect.d.ts +2 -1
- package/types/service/predefinedAdaptor/openaiLlm.d.ts +1 -1
- 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 +24 -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 +1 -32
- package/types/service/predefinedAdaptor/sql/SqlTableSchema.d.ts +20 -0
- package/types/service/predefinedAdaptor/sql/StoredRows.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +1 -14
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +0 -8
- package/types/service/predefinedAdaptor/sql/fieldValues.d.ts +5 -0
- package/types/service/predefinedAdaptor/sseData.d.ts +5 -0
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +14 -5
- package/types/service/serviceModule.d.ts +1 -1
- package/types/service/serviceRegistry.d.ts +1 -0
- package/types/signal/SignalFailure.d.ts +2 -0
- package/types/signal/agentTurnStream.d.ts +2 -1
- package/types/signal/byIdRead.d.ts +7 -0
- package/types/signal/carriedClientIps.d.ts +4 -0
- package/types/signal/endpointErrorContract.d.ts +3 -0
- package/types/signal/exception.d.ts +1 -0
- package/types/signal/index.d.ts +32 -30
- package/types/signal/mcp/McpDocument.d.ts +2 -0
- package/types/signal/mcp/index.d.ts +1 -0
- package/types/signal/mcp/promptError.d.ts +5 -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 +1 -13
- package/types/signal/signalContractError.d.ts +4 -0
- package/types/signal/signalDeclarationError.d.ts +4 -0
- package/types/signal/slice.d.ts +15 -13
- package/types/signal/trace.d.ts +3 -0
- package/types/signal/types.d.ts +33 -6
- package/types/store/action.d.ts +8 -27
- package/types/store/actionErrorKey.d.ts +1 -0
- package/types/store/actionOption.d.ts +24 -0
- package/types/store/baseSt.d.ts +2 -295
- package/types/store/draftFlush.d.ts +4 -0
- package/types/store/formDrafts.d.ts +21 -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/modelListPatch.d.ts +34 -0
- package/types/store/modelOpenActions.d.ts +12 -0
- package/types/store/modelWriteActions.d.ts +16 -0
- package/types/store/modelWriteGuard.d.ts +42 -0
- package/types/store/openSeq.d.ts +17 -0
- package/types/store/rootStore.d.ts +6 -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/store/uploadPoll.d.ts +16 -0
- package/types/store/withSelector.d.ts +1 -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/Field/Choice.d.ts +2 -1
- package/types/ui/Field/index.d.ts +1 -1
- package/types/ui/Link/inputModality.d.ts +5 -0
- package/types/ui/Link/viewportPrefetch.d.ts +4 -0
- package/types/ui/Load/Edit_Client.d.ts +2 -0
- package/types/ui/Load/Pagination.d.ts +4 -1
- package/types/ui/Load/Stream.d.ts +7 -1
- package/types/ui/Load/StreamBoundary.d.ts +20 -0
- package/types/ui/Load/Units.d.ts +2 -0
- package/types/ui/Load/View.d.ts +2 -0
- package/types/ui/Reference/origin.d.ts +1 -0
- package/types/ui/index.d.ts +1 -1
- package/types/ui/overlayLayer.d.ts +6 -1
- 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 +18 -11
- package/types/vendor/use-agentic/AgentClientTools.d.ts +19 -0
- 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 +11 -0
- package/types/webkit/CsrGuards.d.ts +2 -0
- package/types/webkit/RouteLevelBoundary.d.ts +17 -0
- package/types/webkit/nativeCore.d.ts +1 -0
- package/types/webkit/nativePurchase.d.ts +2 -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/useFrameRuntime.d.ts +1 -0
- package/types/webkit/useGeoLocation.d.ts +1 -1
- package/types/webkit/useHistory.d.ts +2 -3
- package/types/webkit/usePurchase.d.ts +1 -1
- package/types/webkit/useResolvedFrame.d.ts +38 -0
- package/types/webkit/useSyncNavigation.d.ts +22 -0
- package/types/webkit/useTransitionStore.d.ts +1 -0
- package/ui/Agent/Chat.tsx +392 -235
- package/ui/Agent/ChatHeader.tsx +59 -0
- package/ui/Agent/ChatPendingCards.tsx +49 -0
- package/ui/Agent/fetchRunner.ts +8 -1
- package/ui/BottomSheet.tsx +1 -1
- package/ui/Button.tsx +1 -0
- 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/Link/inputModality.ts +21 -0
- package/ui/Link/prefetchIntent.ts +7 -25
- package/ui/Link/viewportPrefetch.ts +30 -0
- package/ui/Load/Edit_Client.tsx +7 -1
- package/ui/Load/Pagination.tsx +10 -2
- package/ui/Load/Stream.tsx +24 -4
- package/ui/Load/StreamBoundary.tsx +65 -0
- package/ui/Load/Units.tsx +3 -0
- package/ui/Load/View.tsx +5 -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 +32 -8
- package/ui/index.ts +4 -0
- package/ui/overlayLayer.ts +22 -1
- package/vendor/@akanjs/native/CHANGELOG.md +7 -1
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativeActivity.kt +27 -12
- package/vendor/@akanjs/native/native/android/src/com/akanjs/runtime/AkanNativePlugin.kt +4 -0
- package/vendor/@akanjs/native/native/desktop/src/external.rs +213 -111
- package/vendor/@akanjs/native/native/desktop/src/lib.rs +12 -4
- package/vendor/@akanjs/native/native/desktop/src/linux/external.rs +509 -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 +18 -11
- package/vendor/use-agentic/AgentClientTools.ts +33 -0
- package/vendor/use-agentic/AgentSession.ts +11 -11
- package/vendor/use-agentic/CHANGELOG.md +46 -1
- package/vendor/use-agentic/Compaction.ts +2 -1
- package/vendor/use-agentic/ToolRunner.ts +6 -3
- package/vendor/use-agentic/Transcript.ts +6 -3
- package/vendor/use-agentic/WIRE.md +29 -7
- package/vendor/use-agentic/failureCode.ts +44 -0
- package/vendor/use-agentic/httpRunner.ts +15 -4
- package/vendor/use-agentic/index.ts +1 -0
- package/vendor/use-agentic/types.ts +11 -0
- package/webkit/CsrGuards.ts +7 -2
- package/webkit/McpAppAgent.ts +8 -3
- package/webkit/McpAppFetchBridge.ts +11 -5
- package/webkit/RouteLevelBoundary.tsx +37 -0
- package/webkit/nativeCore.ts +1 -0
- package/webkit/nativePurchase.ts +6 -3
- package/webkit/useCamera.tsx +22 -21
- 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 +69 -1234
- package/webkit/useGeoLocation.tsx +4 -1
- package/webkit/useHistory.ts +2 -2
- package/webkit/useLocation.ts +3 -2
- package/webkit/usePurchase.tsx +4 -2
- package/webkit/useResolvedFrame.ts +116 -0
- package/webkit/useSyncNavigation.ts +109 -0
- package/webkit/useTransitionStore.ts +13 -0
- package/types/signal/agentMeter.d.ts +0 -27
- package/types/signal/agentRelayPolicy.d.ts +0 -25
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { NoDocumentError } from "akanjs/document";
|
|
2
|
+
import type { EndpointInfo } from "./endpointInfo";
|
|
3
|
+
import type { SignalContext } from "./signalContext";
|
|
4
|
+
|
|
5
|
+
export class ByIdRead {
|
|
6
|
+
static readonly #refNames = new WeakMap<EndpointInfo, string>();
|
|
7
|
+
|
|
8
|
+
static mark<Info extends EndpointInfo>(refName: string, endpointInfo: Info): Info {
|
|
9
|
+
ByIdRead.#refNames.set(endpointInfo, refName);
|
|
10
|
+
return endpointInfo;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static missed(context: SignalContext, error: unknown) {
|
|
14
|
+
if (!(error instanceof NoDocumentError) || !error.lookup) return false;
|
|
15
|
+
const { refName, id } = error.lookup;
|
|
16
|
+
return refName === ByIdRead.#refNames.get(context.endpointInfo) && id === context.args[0];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const carriedClientIps = new WeakMap<Request, { ip: string | null; trustedHop: boolean }>();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Adaptor } from "akanjs/service";
|
|
2
2
|
|
|
3
3
|
import type { EndpointInfo } from "./endpointInfo";
|
|
4
|
+
import type { ExceptionLike } from "./exception";
|
|
5
|
+
import { SignalDeclarationError } from "./signalDeclarationError";
|
|
4
6
|
import type { EndpointErrors } from "./types";
|
|
5
7
|
|
|
6
8
|
export class EndpointErrorContract {
|
|
@@ -12,10 +14,16 @@ export class EndpointErrorContract {
|
|
|
12
14
|
for (const [status, keys] of Object.entries(errors) as [string, EndpointErrors[number]][]) {
|
|
13
15
|
const code = Number(status);
|
|
14
16
|
if (!Number.isInteger(code) || code < 400 || code > 599)
|
|
15
|
-
throw new
|
|
17
|
+
throw new SignalDeclarationError(
|
|
18
|
+
"invalidErrors",
|
|
19
|
+
`errors declares status ${status}: an error answers with a 400–599 status`,
|
|
20
|
+
);
|
|
16
21
|
for (const key of keys)
|
|
17
22
|
if (!/^[^.]+\.error\.[^.]+$/.test(key))
|
|
18
|
-
throw new
|
|
23
|
+
throw new SignalDeclarationError(
|
|
24
|
+
"invalidErrors",
|
|
25
|
+
`errors declares "${key}" under ${status}: an error key reads <module>.error.<key>`,
|
|
26
|
+
);
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
|
|
@@ -34,4 +42,14 @@ export class EndpointErrorContract {
|
|
|
34
42
|
`"${key}" threw ${thrownKey}, which its \`errors\` declaration leaves out: OpenAPI and the MCP catalogue do not publish it.`,
|
|
35
43
|
);
|
|
36
44
|
}
|
|
45
|
+
|
|
46
|
+
static promised(endpointInfo: EndpointInfo, error: ExceptionLike) {
|
|
47
|
+
const keys: readonly string[] | undefined = endpointInfo.signalOption.errors?.[error.statusCode];
|
|
48
|
+
return error.statusCode < 500 && keys?.includes(EndpointErrorContract.wireKey(error)) === true;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
static wireKey(error: ExceptionLike): string {
|
|
52
|
+
const wire = (error.toJSON() as { error?: unknown } | null)?.error;
|
|
53
|
+
return typeof wire === "string" ? wire : (error as unknown as Error).message;
|
|
54
|
+
}
|
|
37
55
|
}
|
package/signal/endpointInfo.ts
CHANGED
|
@@ -22,6 +22,7 @@ import type {
|
|
|
22
22
|
import type { ServiceModel } from "akanjs/service";
|
|
23
23
|
import { EndpointErrorContract } from "./endpointErrorContract";
|
|
24
24
|
import type { InternalArgCls } from "./internalArg";
|
|
25
|
+
import { SignalDeclarationError } from "./signalDeclarationError";
|
|
25
26
|
import type { ArgType, SignalOption, SrvMap } from "./types";
|
|
26
27
|
|
|
27
28
|
export type EndpointType = "query" | "mutation" | "pubsub" | "message";
|
|
@@ -112,9 +113,9 @@ export class EndpointInfo<
|
|
|
112
113
|
this.signalOption = signalOption;
|
|
113
114
|
}
|
|
114
115
|
#addArg(type: ArgType, name: string, arg: ConstantFieldTypeInput, option?: EndpointArgProps<boolean>) {
|
|
115
|
-
if (this.execFn) throw new
|
|
116
|
+
if (this.execFn) throw new SignalDeclarationError("handlerAlreadySet", "Query function is already set");
|
|
116
117
|
if (type !== "body" && type !== "search" && this.args.at(-1)?.option?.nullable)
|
|
117
|
-
throw new
|
|
118
|
+
throw new SignalDeclarationError("nullableLastArg", "Last argument is nullable");
|
|
118
119
|
this.argNames.push(name);
|
|
119
120
|
this.args.push(EndpointInfo.getArgInfo(type, name, arg, option));
|
|
120
121
|
}
|
|
@@ -249,7 +250,7 @@ export class EndpointInfo<
|
|
|
249
250
|
this.msg(arg.name, argRef, arg.option);
|
|
250
251
|
break;
|
|
251
252
|
default:
|
|
252
|
-
throw new
|
|
253
|
+
throw new SignalDeclarationError("invalidArgType", `Invalid argument type: ${arg.type}`);
|
|
253
254
|
}
|
|
254
255
|
}
|
|
255
256
|
return this;
|
|
@@ -258,7 +259,7 @@ export class EndpointInfo<
|
|
|
258
259
|
argRef: InternalArgCls<ArgType>,
|
|
259
260
|
option?: InternalArgProps<Optional>,
|
|
260
261
|
) {
|
|
261
|
-
if (this.execFn) throw new
|
|
262
|
+
if (this.execFn) throw new SignalDeclarationError("handlerAlreadySet", "Query function is already set");
|
|
262
263
|
this.internalArgs.push({ argRef, option });
|
|
263
264
|
return this as unknown as EndpointInfo<
|
|
264
265
|
ReqType,
|
|
@@ -306,7 +307,7 @@ export class EndpointInfo<
|
|
|
306
307
|
ReturnType<ExecFn>,
|
|
307
308
|
Nullable
|
|
308
309
|
> {
|
|
309
|
-
if (this.execFn) throw new
|
|
310
|
+
if (this.execFn) throw new SignalDeclarationError("handlerAlreadySet", "Query function is already set");
|
|
310
311
|
this.execFn = execFn;
|
|
311
312
|
return this as unknown as EndpointInfo<
|
|
312
313
|
ReqType,
|
package/signal/exception.ts
CHANGED
package/signal/index.ts
CHANGED
|
@@ -1,32 +1,316 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
export {
|
|
2
|
+
AgentMeter,
|
|
3
|
+
type AgentMeterScope,
|
|
4
|
+
type AgentQuotaCheck,
|
|
5
|
+
type AgentQuotaHook,
|
|
6
|
+
AgentRelayPolicy,
|
|
7
|
+
type AgentRequestContext,
|
|
8
|
+
type AgentRequestLimits,
|
|
9
|
+
type AgentRequestPolicy,
|
|
10
|
+
type AgentTurnContext,
|
|
11
|
+
type AgentTurnOutcome,
|
|
12
|
+
type AgentUsageHook,
|
|
13
|
+
type AgentUsageReport,
|
|
14
|
+
} from "akanjs/service";
|
|
15
|
+
export {
|
|
16
|
+
type AgentBaseVerb,
|
|
17
|
+
type AgentCandidate,
|
|
18
|
+
AgentCatalogue,
|
|
19
|
+
type AgentCatalogueOptions,
|
|
20
|
+
type AgentOrigin,
|
|
21
|
+
type AgentRefusal,
|
|
22
|
+
type AgentUndescribed,
|
|
23
|
+
} from "./agent";
|
|
24
|
+
export { Agent, AgentEndpoint, AgentInternal, agent } from "./agent.signal";
|
|
25
|
+
export { AgentStop, AgentTurn, AgentTurnDocument, agentTurnConstant, agentTurnDocument } from "./agentTurn";
|
|
26
|
+
export { AgentTurnStream } from "./agentTurnStream";
|
|
27
|
+
export { Base, BaseEndpoint, BaseInternal, base, fetch, getSerializedSignal } from "./base.signal";
|
|
8
28
|
export { CrossSiteGuard, type CrossSiteOption } from "./CrossSiteGuard";
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
29
|
+
export {
|
|
30
|
+
type Endpoint,
|
|
31
|
+
type EndpointCls,
|
|
32
|
+
type EndpointDictArgShape,
|
|
33
|
+
type EndpointDictShape,
|
|
34
|
+
endpoint,
|
|
35
|
+
sliceEndpoint,
|
|
36
|
+
} from "./endpoint";
|
|
37
|
+
export { EndpointErrorContract } from "./endpointErrorContract";
|
|
38
|
+
export {
|
|
39
|
+
type ArgInfo,
|
|
40
|
+
type BuildEndpoint,
|
|
41
|
+
buildEndpoint,
|
|
42
|
+
type EndpInfoArgNames,
|
|
43
|
+
type EndpInfoArgs,
|
|
44
|
+
type EndpInfoClientReturns,
|
|
45
|
+
type EndpInfoInternalArgs,
|
|
46
|
+
type EndpInfoNullable,
|
|
47
|
+
type EndpInfoReqType,
|
|
48
|
+
type EndpInfoReturnRef,
|
|
49
|
+
type EndpInfoServerArgs,
|
|
50
|
+
type EndpInfoServerReturns,
|
|
51
|
+
type EndpInfoSrvs,
|
|
52
|
+
type EndpointArgProps,
|
|
53
|
+
type EndpointBuilder,
|
|
54
|
+
EndpointInfo,
|
|
55
|
+
type EndpointInfoParts,
|
|
56
|
+
type EndpointType,
|
|
57
|
+
type InternalArgInfo,
|
|
58
|
+
type InternalArgProps,
|
|
59
|
+
type ReturnInfo,
|
|
60
|
+
} from "./endpointInfo";
|
|
61
|
+
export { EndpointRateLimit, type RateLimitBudget, type RateLimitSetting } from "./endpointRateLimit";
|
|
62
|
+
export { Exception, type ExceptionLike, isExceptionLike, type StatusException } from "./exception";
|
|
63
|
+
export { type Guard, type GuardCls, type GuardScope, guard, guardOf, refusesAgents } from "./guard";
|
|
64
|
+
export { AgentRelayAccess, None, Public } from "./guards";
|
|
65
|
+
export { type InterceptorCls, intercept } from "./intercept";
|
|
66
|
+
export { type Internal, type InternalCls, internal } from "./internal";
|
|
67
|
+
export {
|
|
68
|
+
CallerAccount,
|
|
69
|
+
type InternalArg,
|
|
70
|
+
type InternalArgCls,
|
|
71
|
+
Ip,
|
|
72
|
+
Machine,
|
|
73
|
+
type MachineIdentity,
|
|
74
|
+
Req,
|
|
75
|
+
Res,
|
|
76
|
+
Ws,
|
|
77
|
+
} from "./internalArg";
|
|
78
|
+
export {
|
|
79
|
+
type BuildInternal,
|
|
80
|
+
buildInternal,
|
|
81
|
+
type InternalBuilder,
|
|
82
|
+
InternalInfo,
|
|
83
|
+
type InternalInfoDefaultArgs,
|
|
84
|
+
type InternalInfoInternalArgs,
|
|
85
|
+
type InternalInfoNullable,
|
|
86
|
+
type InternalInfoParts,
|
|
87
|
+
type InternalInfoReqType,
|
|
88
|
+
type InternalInfoReturns,
|
|
89
|
+
type InternalInfoServerArgs,
|
|
90
|
+
type InternalInfoServerReturns,
|
|
91
|
+
type InternalInfoSrvs,
|
|
92
|
+
} from "./internalInfo";
|
|
93
|
+
export {
|
|
94
|
+
MCP_APP_META,
|
|
95
|
+
MCP_LEGACY_PRIOR_VERSION,
|
|
96
|
+
MCP_LEGACY_VERSION,
|
|
97
|
+
MCP_META_CLIENT_CAPABILITIES,
|
|
98
|
+
MCP_META_CLIENT_INFO,
|
|
99
|
+
MCP_META_PREFIX,
|
|
100
|
+
MCP_META_PROTOCOL_VERSION,
|
|
101
|
+
MCP_META_SERVER_INFO,
|
|
102
|
+
MCP_MODERN_VERSION,
|
|
103
|
+
MCP_SCREEN_REFUSAL,
|
|
104
|
+
MCP_SUPPORTED_VERSIONS,
|
|
105
|
+
MCP_UI_EXTENSION,
|
|
106
|
+
MCP_UI_LEGACY_RESOURCE_URI,
|
|
107
|
+
MCP_UI_MIME_TYPE,
|
|
108
|
+
type McpAppSnapshotRecord,
|
|
109
|
+
McpDocument,
|
|
110
|
+
type McpDocumentOptions,
|
|
111
|
+
type McpEra,
|
|
112
|
+
McpErrorCode,
|
|
113
|
+
type McpErrorCodeValue,
|
|
114
|
+
type McpExposedEndpoint,
|
|
115
|
+
type McpImageContent,
|
|
116
|
+
type McpJsonRpcMessage,
|
|
117
|
+
type McpJsonRpcRequest,
|
|
118
|
+
type McpJsonRpcResponse,
|
|
119
|
+
type McpListingCost,
|
|
120
|
+
type McpOutputSchemaMode,
|
|
121
|
+
McpProgress,
|
|
122
|
+
type McpProgressOption,
|
|
123
|
+
type McpProgressReport,
|
|
124
|
+
type McpPrompt,
|
|
125
|
+
type McpPromptArgument,
|
|
126
|
+
type McpProtocolVersion,
|
|
127
|
+
type McpRefusal,
|
|
128
|
+
type McpResource,
|
|
129
|
+
type McpResourceContents,
|
|
130
|
+
type McpResourceTarget,
|
|
131
|
+
type McpResourceTemplate,
|
|
132
|
+
type McpSignalCost,
|
|
133
|
+
type McpTextContent,
|
|
134
|
+
type McpTool,
|
|
135
|
+
type McpToolAnnotations,
|
|
136
|
+
type McpToolResult,
|
|
137
|
+
type McpToolUiMeta,
|
|
138
|
+
type McpUiVisibility,
|
|
139
|
+
type McpUndescribed,
|
|
140
|
+
McpUriTemplate,
|
|
141
|
+
type Msg,
|
|
142
|
+
type PagePromptEntry,
|
|
143
|
+
type PagePromptRecord,
|
|
144
|
+
type PagePromptRefusal,
|
|
145
|
+
type PagePromptRoute,
|
|
146
|
+
type PagePromptRun,
|
|
147
|
+
type PagePromptRunInput,
|
|
148
|
+
type PagePromptSource,
|
|
149
|
+
type PagePromptVisibleInput,
|
|
150
|
+
type PromptAnnotations,
|
|
151
|
+
type PromptBinaryContent,
|
|
152
|
+
type PromptContent,
|
|
153
|
+
type PromptEmbeddedResourceContent,
|
|
154
|
+
PromptError,
|
|
155
|
+
type PromptErrorCode,
|
|
156
|
+
type PromptFileSource,
|
|
157
|
+
type PromptMessage,
|
|
158
|
+
type PromptModel,
|
|
159
|
+
type PromptResourceLinkContent,
|
|
160
|
+
type PromptResult,
|
|
161
|
+
type PromptRole,
|
|
162
|
+
type PromptTextContent,
|
|
163
|
+
} from "./mcp";
|
|
164
|
+
export { Logging, type Middleware, type MiddlewareCls, middleware, Timeout } from "./middleware";
|
|
165
|
+
export { createOpenApiDocument, type OpenApiDocument, type OpenApiDocumentOptions } from "./openapi";
|
|
166
|
+
export { ResolveFieldContext } from "./resolveFieldContext";
|
|
23
167
|
export { SignalFailure } from "./SignalFailure";
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
export
|
|
168
|
+
export {
|
|
169
|
+
type JsonSchema,
|
|
170
|
+
JsonSchemaBuilder,
|
|
171
|
+
type JsonSchemaBuilderOptions,
|
|
172
|
+
type JsonSchemaFace,
|
|
173
|
+
type JsonSchemaModelOptions,
|
|
174
|
+
type JsonSchemaRelations,
|
|
175
|
+
} from "./schema";
|
|
176
|
+
export { FetchSerializer } from "./serializer";
|
|
177
|
+
export {
|
|
178
|
+
type ServerSignal,
|
|
179
|
+
type ServerSignalCls,
|
|
180
|
+
type ServerSignalClsStatics,
|
|
181
|
+
type ServerSignalMethods,
|
|
182
|
+
serverSignal,
|
|
183
|
+
type TypedServerSignalCls,
|
|
184
|
+
} from "./serverSignal";
|
|
185
|
+
export {
|
|
186
|
+
HttpExecutionContext,
|
|
187
|
+
type HttpPeerResolver,
|
|
188
|
+
SignalContext,
|
|
189
|
+
type SignalTransportType,
|
|
190
|
+
type WebSocketEventType,
|
|
191
|
+
WebSocketExecutionContext,
|
|
192
|
+
} from "./signalContext";
|
|
193
|
+
export { SignalContractError, type SignalContractErrorCode } from "./signalContractError";
|
|
194
|
+
export { SignalDeclarationError, type SignalDeclarationErrorCode } from "./signalDeclarationError";
|
|
195
|
+
export { DatabaseSignal, ServiceSignal, SignalRegistry } from "./signalRegistry";
|
|
196
|
+
export {
|
|
197
|
+
type ResolvedSliceCrud,
|
|
198
|
+
type ResolvedSliceMcp,
|
|
199
|
+
type Slice,
|
|
200
|
+
type SliceCls,
|
|
201
|
+
type SliceDictArgShape,
|
|
202
|
+
type SliceDictShape,
|
|
203
|
+
slice,
|
|
204
|
+
} from "./slice";
|
|
205
|
+
export {
|
|
206
|
+
buildSlice,
|
|
207
|
+
type LiveSliceOption,
|
|
208
|
+
type ResolvedLiveSliceOption,
|
|
209
|
+
type SliceBuilder,
|
|
210
|
+
SliceInfo,
|
|
211
|
+
type SliceInfoArgNames,
|
|
212
|
+
type SliceInfoArgs,
|
|
213
|
+
type SliceInfoFilter,
|
|
214
|
+
type SliceInfoFull,
|
|
215
|
+
type SliceInfoInput,
|
|
216
|
+
type SliceInfoInsight,
|
|
217
|
+
type SliceInfoInternalArgs,
|
|
218
|
+
type SliceInfoLight,
|
|
219
|
+
type SliceInfoParts,
|
|
220
|
+
type SliceInfoRefName,
|
|
221
|
+
type SliceInfoServerArgs,
|
|
222
|
+
type SliceInfoSrvs,
|
|
223
|
+
} from "./sliceInfo";
|
|
224
|
+
export {
|
|
225
|
+
type CanonicalLineMode,
|
|
226
|
+
getCanonicalLineMode,
|
|
227
|
+
getCurrentTrace,
|
|
228
|
+
getFlightThresholdMs,
|
|
229
|
+
getTraceSnapshot,
|
|
230
|
+
isDebugHeaderAllowed,
|
|
231
|
+
isFlightRecorderEnabled,
|
|
232
|
+
isLocalDevRuntime,
|
|
233
|
+
isLogContextEnabled,
|
|
234
|
+
isTraceEnabled,
|
|
235
|
+
runTraced,
|
|
236
|
+
runWithTrace,
|
|
237
|
+
SignalTrace,
|
|
238
|
+
type SpanRecord,
|
|
239
|
+
setCanonicalLineMode,
|
|
240
|
+
setFlightRecorderEnabled,
|
|
241
|
+
setFlightThresholdMs,
|
|
242
|
+
setLogContextEnabled,
|
|
243
|
+
setTraceEnabled,
|
|
244
|
+
type TraceMode,
|
|
245
|
+
type TraceOrigin,
|
|
246
|
+
type TraceOutcome,
|
|
247
|
+
traceAggregator,
|
|
248
|
+
traceCache,
|
|
249
|
+
traceDataLoaderBatch,
|
|
250
|
+
traceDbQuery,
|
|
251
|
+
traceSpan,
|
|
252
|
+
} from "./trace";
|
|
253
|
+
export {
|
|
254
|
+
type ArgType,
|
|
255
|
+
argTypes,
|
|
256
|
+
type CnstCapitalizedRefName,
|
|
257
|
+
type CnstDefault,
|
|
258
|
+
type CnstDefaultInput,
|
|
259
|
+
type CnstDefaultState,
|
|
260
|
+
type CnstFull,
|
|
261
|
+
type CnstInput,
|
|
262
|
+
type CnstInsight,
|
|
263
|
+
type CnstLight,
|
|
264
|
+
type CnstOf,
|
|
265
|
+
type CnstPurifiedInput,
|
|
266
|
+
type CnstRefName,
|
|
267
|
+
type CnstStateInsight,
|
|
268
|
+
type CnstStateLight,
|
|
269
|
+
type DbDoc,
|
|
270
|
+
type DbFilter,
|
|
271
|
+
type DbOf,
|
|
272
|
+
type DbQuery,
|
|
273
|
+
type DbSort,
|
|
274
|
+
type EndpointErrorKey,
|
|
275
|
+
type EndpointErrors,
|
|
276
|
+
type HttpMutationMethod,
|
|
277
|
+
type LiveEndpointOption,
|
|
278
|
+
type LiveEventPayload,
|
|
279
|
+
type SerializedArg,
|
|
280
|
+
type SerializedEndpoint,
|
|
281
|
+
type SerializedFilter,
|
|
282
|
+
type SerializedReturns,
|
|
283
|
+
type SerializedSignal,
|
|
284
|
+
type SerializedSignalMcp,
|
|
285
|
+
type SerializedSignalShelf,
|
|
286
|
+
type SerializedSlice,
|
|
287
|
+
type SignalOption,
|
|
288
|
+
type SignalType,
|
|
289
|
+
type SlceCnstCapitalizedRefName,
|
|
290
|
+
type SlceCnstDefault,
|
|
291
|
+
type SlceCnstDefaultInput,
|
|
292
|
+
type SlceCnstDefaultState,
|
|
293
|
+
type SlceCnstFull,
|
|
294
|
+
type SlceCnstInput,
|
|
295
|
+
type SlceCnstInsight,
|
|
296
|
+
type SlceCnstLight,
|
|
297
|
+
type SlceCnstPurifiedInput,
|
|
298
|
+
type SlceCnstRefName,
|
|
299
|
+
type SlceCnstStateInsight,
|
|
300
|
+
type SlceCnstStateLight,
|
|
301
|
+
type SlceDbFilter,
|
|
302
|
+
type SlceDbQuery,
|
|
303
|
+
type SlceDbSort,
|
|
304
|
+
type SlceSrv,
|
|
305
|
+
type SrvMap,
|
|
306
|
+
type SrvOf,
|
|
307
|
+
type SrvRefName,
|
|
308
|
+
type WebsocketAuthAck,
|
|
309
|
+
type WebsocketMessageData,
|
|
310
|
+
type WebsocketPublishData,
|
|
311
|
+
type WebsocketReqData,
|
|
312
|
+
type WebsocketResData,
|
|
313
|
+
type WebsocketResyncData,
|
|
314
|
+
type WebsocketRoomCursor,
|
|
315
|
+
type WebsocketSubscribeAck,
|
|
316
|
+
} from "./types";
|
package/signal/internalInfo.ts
CHANGED
|
@@ -11,6 +11,7 @@ import type {
|
|
|
11
11
|
import type { AkanJob, ServiceModel } from "akanjs/service";
|
|
12
12
|
import { type ArgInfo, EndpointInfo, type InternalArgInfo, type ReturnInfo } from "./endpointInfo";
|
|
13
13
|
import type { InternalArgCls } from "./internalArg";
|
|
14
|
+
import { SignalDeclarationError } from "./signalDeclarationError";
|
|
14
15
|
import type { CnstOf, DbDoc, SignalOption, SrvMap } from "./types";
|
|
15
16
|
|
|
16
17
|
type InternalType = "resolveField" | "interval" | "cron" | "timeout" | "init" | "destroy" | "process";
|
|
@@ -51,8 +52,9 @@ export class InternalInfo<
|
|
|
51
52
|
Nullable extends boolean = false,
|
|
52
53
|
_FieldToValue = FieldToValue<Arg>,
|
|
53
54
|
>(name: string, arg: Arg, option?: InternalArgProps<Nullable>) {
|
|
54
|
-
if (this.execFn) throw new
|
|
55
|
-
else if (this.args.at(-1)?.option?.nullable)
|
|
55
|
+
if (this.execFn) throw new SignalDeclarationError("handlerAlreadySet", "Query function is already set");
|
|
56
|
+
else if (this.args.at(-1)?.option?.nullable)
|
|
57
|
+
throw new SignalDeclarationError("nullableLastArg", "Last argument is nullable");
|
|
56
58
|
this.args.push(EndpointInfo.getArgInfo("msg", name, arg, option));
|
|
57
59
|
return this as unknown as InternalInfo<
|
|
58
60
|
ReqType,
|
|
@@ -69,7 +71,7 @@ export class InternalInfo<
|
|
|
69
71
|
argRef: InternalArgCls<ArgType>,
|
|
70
72
|
option?: InternalArgProps<Optional>,
|
|
71
73
|
) {
|
|
72
|
-
if (this.execFn) throw new
|
|
74
|
+
if (this.execFn) throw new SignalDeclarationError("handlerAlreadySet", "Query function is already set");
|
|
73
75
|
this.internalArgs.push({
|
|
74
76
|
argRef,
|
|
75
77
|
option: { ...option, ...(this.type === "resolveField" ? { nullable: true } : {}) },
|
|
@@ -93,7 +95,7 @@ export class InternalInfo<
|
|
|
93
95
|
? PromiseOrObject<DocumentModel<FieldToValue<Returns>> | (Nullable extends true ? null : never)>
|
|
94
96
|
: PromiseOrObject<void>,
|
|
95
97
|
>(execFn: (this: Srvs, ...args: [...Args, ...DefaultArgs, ...InternalArgs]) => ExecReturn) {
|
|
96
|
-
if (this.execFn) throw new
|
|
98
|
+
if (this.execFn) throw new SignalDeclarationError("handlerAlreadySet", "Query function is already set");
|
|
97
99
|
this.execFn = execFn as unknown as (...args: [...Args, ...DefaultArgs, ...InternalArgs]) => ServerReturns;
|
|
98
100
|
return this as unknown as InternalInfo<
|
|
99
101
|
ReqType,
|
|
@@ -25,6 +25,8 @@ export interface McpDocumentOptions {
|
|
|
25
25
|
* refusal still holds.
|
|
26
26
|
*/
|
|
27
27
|
apps?: boolean;
|
|
28
|
+
/** The in-process agent's catalogue (`AgentToolsRole`), which also lists an endpoint declared `mcp: "agent"`. */
|
|
29
|
+
agent?: boolean;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
export type McpOutputSchemaMode = "full" | "shallow" | "none";
|
|
@@ -154,7 +156,12 @@ export class McpDocument {
|
|
|
154
156
|
this.#catalogue.refuse(key, excluded);
|
|
155
157
|
continue;
|
|
156
158
|
}
|
|
157
|
-
const reason = mcpRefusalOf(endpoint, {
|
|
159
|
+
const reason = mcpRefusalOf(endpoint, {
|
|
160
|
+
refName,
|
|
161
|
+
key,
|
|
162
|
+
readOnly: this.#options.readOnly,
|
|
163
|
+
agent: this.#options.agent,
|
|
164
|
+
});
|
|
158
165
|
if (reason && this.#isAppOnly(item)) {
|
|
159
166
|
appOnly.push({ ...item, reason });
|
|
160
167
|
continue;
|
package/signal/mcp/Msg.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { leakingFieldsOf, type MaskModel, mask } from "akanjs/constant";
|
|
2
2
|
import type { JsonSchema } from "../schema";
|
|
3
|
+
import { PromptError } from "./promptError";
|
|
3
4
|
|
|
4
5
|
export type PromptRole = "user" | "assistant";
|
|
5
6
|
|
|
@@ -184,7 +185,7 @@ export class Msg {
|
|
|
184
185
|
/** Fetched as this process, so a file behind a caller-scoped signed URL needs its bytes passed to `Msg.image`. */
|
|
185
186
|
static async imageOf(file: PromptFileSource, annotations?: PromptAnnotations): Promise<PromptMessage> {
|
|
186
187
|
const response = await fetch(file.url, { signal: AbortSignal.timeout(20_000) });
|
|
187
|
-
if (!response.ok) throw new
|
|
188
|
+
if (!response.ok) throw new PromptError("inlineFailed", `Failed to inline ${file.url}: ${response.status}`);
|
|
188
189
|
const mimeType = file.mimetype ?? response.headers.get("content-type") ?? "application/octet-stream";
|
|
189
190
|
return Msg.image(Buffer.from(await response.arrayBuffer()).toString("base64"), mimeType, annotations);
|
|
190
191
|
}
|
|
@@ -208,7 +209,8 @@ export class Msg {
|
|
|
208
209
|
const model = sample.constructor as PromptModel | undefined;
|
|
209
210
|
const leaking = model ? leakingFieldsOf(model, sample) : [];
|
|
210
211
|
if (!leaking.length) return;
|
|
211
|
-
throw new
|
|
212
|
+
throw new PromptError(
|
|
213
|
+
"unmaskedResource",
|
|
212
214
|
`Msg.resource("${uri}") embeds ${model?.name} with its hidden/secret fields populated: ${leaking.join(", ")}. Name the model so they are stripped — Msg.resource(uri, value, { model: cnst.${model?.name} }), or Msg.mask(cnst.${model?.name}, value) for one piece of an assembled payload.`,
|
|
213
215
|
);
|
|
214
216
|
}
|
|
@@ -217,14 +219,15 @@ export class Msg {
|
|
|
217
219
|
if (!annotations || !Object.keys(annotations).length) return content;
|
|
218
220
|
const { priority } = annotations;
|
|
219
221
|
if (priority !== undefined && (priority < 0 || priority > 1))
|
|
220
|
-
throw new
|
|
222
|
+
throw new PromptError("invalidPrompt", `Prompt annotation priority must be between 0 and 1, got ${priority}`);
|
|
221
223
|
return { ...content, annotations };
|
|
222
224
|
}
|
|
223
225
|
|
|
224
226
|
/** The only runtime check on a prompt's value: `prompt()` carries `Any`, so nothing upstream inspects it. */
|
|
225
227
|
static normalize(value: unknown): PromptMessage[] {
|
|
226
228
|
if (typeof value === "string") return [Msg.user(value)];
|
|
227
|
-
if (!Array.isArray(value))
|
|
229
|
+
if (!Array.isArray(value))
|
|
230
|
+
throw new PromptError("invalidPrompt", `A prompt must return a string or PromptMessage[], got ${typeof value}`);
|
|
228
231
|
value.forEach((message, idx) => {
|
|
229
232
|
Msg.#assertMessage(message, idx);
|
|
230
233
|
});
|
|
@@ -233,27 +236,37 @@ export class Msg {
|
|
|
233
236
|
|
|
234
237
|
static #assertMessage(message: unknown, idx: number) {
|
|
235
238
|
const { role, content } = (message ?? {}) as { role?: unknown; content?: unknown };
|
|
236
|
-
if (role !== "user" && role !== "assistant")
|
|
239
|
+
if (role !== "user" && role !== "assistant")
|
|
240
|
+
throw new PromptError("invalidPrompt", `Prompt message ${idx} has role "${String(role)}"`);
|
|
237
241
|
const block = (content ?? {}) as Record<string, unknown>;
|
|
238
242
|
const fields = typeof block.type === "string" ? contentFields.get(block.type) : undefined;
|
|
239
|
-
if (!fields)
|
|
243
|
+
if (!fields)
|
|
244
|
+
throw new PromptError("invalidPrompt", `Prompt message ${idx} has content type "${String(block.type)}"`);
|
|
240
245
|
const missing = fields.filter((field) => typeof block[field] !== "string" || !block[field]);
|
|
241
|
-
if (missing.length)
|
|
246
|
+
if (missing.length)
|
|
247
|
+
throw new PromptError("invalidPrompt", `Prompt message ${idx} (${block.type}) is missing ${missing.join(", ")}`);
|
|
242
248
|
if (block.type === "resource") Msg.#assertResource(block.resource, idx);
|
|
243
249
|
Msg.#assertPriority(block.annotations, idx);
|
|
244
250
|
}
|
|
245
251
|
|
|
246
252
|
static #assertResource(resource: unknown, idx: number) {
|
|
247
253
|
const { uri, text, blob } = (resource ?? {}) as Record<string, unknown>;
|
|
248
|
-
if (typeof uri !== "string" || !uri)
|
|
254
|
+
if (typeof uri !== "string" || !uri)
|
|
255
|
+
throw new PromptError("invalidPrompt", `Prompt message ${idx} (resource) is missing resource.uri`);
|
|
249
256
|
if (typeof text !== "string" && typeof blob !== "string")
|
|
250
|
-
throw new
|
|
257
|
+
throw new PromptError(
|
|
258
|
+
"invalidPrompt",
|
|
259
|
+
`Prompt message ${idx} (resource) has neither resource.text nor resource.blob`,
|
|
260
|
+
);
|
|
251
261
|
}
|
|
252
262
|
|
|
253
263
|
static #assertPriority(annotations: unknown, idx: number) {
|
|
254
264
|
const priority = (annotations as { priority?: unknown } | null)?.priority;
|
|
255
265
|
if (priority === undefined) return;
|
|
256
266
|
if (typeof priority !== "number" || priority < 0 || priority > 1)
|
|
257
|
-
throw new
|
|
267
|
+
throw new PromptError(
|
|
268
|
+
"invalidPrompt",
|
|
269
|
+
`Prompt message ${idx} has annotations.priority "${String(priority)}", not between 0 and 1`,
|
|
270
|
+
);
|
|
258
271
|
}
|
|
259
272
|
}
|
package/signal/mcp/index.ts
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AkanError } from "akanjs/base";
|
|
2
|
+
|
|
3
|
+
export type PromptErrorCode = "invalidPrompt" | "unmaskedResource" | "inlineFailed";
|
|
4
|
+
|
|
5
|
+
export class PromptError extends AkanError<PromptErrorCode> {
|
|
6
|
+
constructor(code: PromptErrorCode, message: string) {
|
|
7
|
+
super(code, message, { statusCode: code === "inlineFailed" ? 502 : 500 });
|
|
8
|
+
}
|
|
9
|
+
}
|
package/signal/middleware.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { BackendEnv, Cls, PromiseOrObject } from "akanjs/base";
|
|
2
2
|
import { Logger } from "akanjs/common";
|
|
3
|
+
import { ByIdRead } from "./byIdRead";
|
|
4
|
+
import { EndpointErrorContract } from "./endpointErrorContract";
|
|
3
5
|
import { Exception, isExceptionLike } from "./exception";
|
|
6
|
+
import { SignalFailure } from "./SignalFailure";
|
|
4
7
|
import type { SignalContext } from "./signalContext";
|
|
5
8
|
|
|
6
9
|
export interface Middleware<Env extends BackendEnv = BackendEnv> {
|
|
@@ -36,9 +39,15 @@ export class Logging extends middleware("logging") {
|
|
|
36
39
|
} catch (error) {
|
|
37
40
|
|
|
38
41
|
if (context.isBodyReadFailure(error)) throw error;
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const cause = error instanceof Error && error.cause !== undefined ? ` (cause: ${String(error.cause)})` : "";
|
|
43
|
+
const line = `Error ${context.endpointInfo.type}-${context.key} / ${Date.now() - start}ms: ${String(error)}${cause}`;
|
|
44
|
+
const status = isExceptionLike(error) ? error.statusCode : SignalFailure.generalized(error).statusCode;
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
status === 429 ||
|
|
48
|
+
ByIdRead.missed(context, error) ||
|
|
49
|
+
(isExceptionLike(error) && EndpointErrorContract.promised(context.endpointInfo, error))
|
|
50
|
+
) {
|
|
42
51
|
if (debug) context.adaptor.logger.debug(line);
|
|
43
52
|
} else context.adaptor.logger.error(line);
|
|
44
53
|
throw error;
|