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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { dirname, join } from "node:path";
|
|
6
|
+
import { appLauncher } from "./relaunch.ts";
|
|
6
7
|
|
|
7
8
|
type Env = Record<string, string | undefined>;
|
|
8
9
|
type Runner = (argv: string[]) => Promise<{ code: number; stdout: string }>;
|
|
@@ -158,8 +159,7 @@ export async function registerDeepLinks(
|
|
|
158
159
|
const platform = options.platform ?? process.platform;
|
|
159
160
|
if (!schemes.length || (platform !== "win32" && platform !== "linux")) return;
|
|
160
161
|
const env = options.env ?? process.env;
|
|
161
|
-
|
|
162
|
-
const exe = options.exe ?? (env.APPIMAGE || process.execPath);
|
|
162
|
+
const exe = options.exe ?? appLauncher(env);
|
|
163
163
|
const runner = options.run ?? run;
|
|
164
164
|
if (platform === "win32") await registerWindows(app, exe, schemes, runner);
|
|
165
165
|
else await registerLinux(app, exe, schemes, { env, home: options.home ?? homedir(), runner, icon: options.icon });
|
|
@@ -14,7 +14,7 @@ import { cstr, FRAME_EVENT, FRAME_HEADER, FRAME_IPC, openNative, resolvePaths }
|
|
|
14
14
|
import { createLifecycle } from "./lifecycle.ts";
|
|
15
15
|
import { appDataDir, appLocalDataDir, reservedDirs, serverDataDir } from "./paths.ts";
|
|
16
16
|
import { type DesktopPlugin, useShellOpenLimit } from "./plugin.ts";
|
|
17
|
-
import { nextRelaunchDelay, relaunchAfterExit } from "./relaunch.ts";
|
|
17
|
+
import { appLauncher, nextRelaunchDelay, relaunchAfterExit } from "./relaunch.ts";
|
|
18
18
|
import { createSecretStore } from "./secretStore.ts";
|
|
19
19
|
import {
|
|
20
20
|
createDesktopServer,
|
|
@@ -350,7 +350,7 @@ export function startHost(plugins: DesktopPlugin[]): void {
|
|
|
350
350
|
void lifecycle.quit(1);
|
|
351
351
|
return;
|
|
352
352
|
}
|
|
353
|
-
relaunchAfterExit(
|
|
353
|
+
relaunchAfterExit(appLauncher(), [], { delayMs })
|
|
354
354
|
.then(() => lifecycle.quit(0))
|
|
355
355
|
.catch((error: unknown) => console.error("[akan-native] cannot relaunch the app", error));
|
|
356
356
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
5
5
|
import { tmpdir } from "node:os";
|
|
6
|
-
import { dirname } from "node:path";
|
|
6
|
+
import { dirname, resolve } from "node:path";
|
|
7
7
|
|
|
8
8
|
export interface RelaunchOptions {
|
|
9
9
|
/** How long the helper waits after this process exited before it starts the app. */
|
|
@@ -48,6 +48,12 @@ export function recoveryCommand(script: string): string | null {
|
|
|
48
48
|
return command.length <= 260 ? command : null;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
export const appLauncher = (env: NodeJS.ProcessEnv = process.env, exe = process.execPath): string =>
|
|
52
|
+
env.APPIMAGE && env.APPDIR && exe.startsWith(`${resolve(env.APPDIR)}/`) ? env.APPIMAGE : exe;
|
|
53
|
+
|
|
54
|
+
const NOT_INHERITED = new Set(["AKAN_NATIVE_QUIT_ON_STDIN", "APPDIR", "APPIMAGE", "ARGV0", "OWD"]);
|
|
55
|
+
const inheritedEnv = () => Object.fromEntries(Object.entries(process.env).filter(([key]) => !NOT_INHERITED.has(key)));
|
|
56
|
+
|
|
51
57
|
let started: Promise<void> | null = null;
|
|
52
58
|
|
|
53
59
|
/**
|
|
@@ -82,8 +88,7 @@ function startHelper(
|
|
|
82
88
|
recover: RelaunchOptions["recover"],
|
|
83
89
|
start: boolean,
|
|
84
90
|
): Promise<void> {
|
|
85
|
-
|
|
86
|
-
const { AKAN_NATIVE_QUIT_ON_STDIN: _cli, ...inherited } = process.env;
|
|
91
|
+
const inherited = inheritedEnv();
|
|
87
92
|
const delay = (delayMs / 1000).toFixed(3);
|
|
88
93
|
if (process.platform !== "win32") {
|
|
89
94
|
const done: [string, string][] = [];
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
linkClaimed,
|
|
9
9
|
type QuitReason,
|
|
10
10
|
} from "../../../packages/desktop/src/plugin.ts";
|
|
11
|
-
import { relaunchAfterExit } from "../../../packages/desktop/src/relaunch.ts";
|
|
11
|
+
import { appLauncher, relaunchAfterExit } from "../../../packages/desktop/src/relaunch.ts";
|
|
12
12
|
import type { AppApi, AppEvents } from "./index.ts";
|
|
13
13
|
|
|
14
14
|
const quitVeto = createPageVeto<{ reason: QuitReason }>();
|
|
@@ -47,7 +47,7 @@ export default defineDesktopPlugin<AppApi, AppEvents>({
|
|
|
47
47
|
setTimeout(() => ctx.quit(0), 50);
|
|
48
48
|
},
|
|
49
49
|
relaunch: async (_args, ctx) => {
|
|
50
|
-
await relaunchAfterExit(
|
|
50
|
+
await relaunchAfterExit(appLauncher());
|
|
51
51
|
setTimeout(() => ctx.quit(0), 50);
|
|
52
52
|
},
|
|
53
53
|
answerBeforeQuit: (args, ctx) => quitVeto.answer(args, ctx.window),
|
|
@@ -3,6 +3,7 @@ package com.akanjs.plugins.appearance
|
|
|
3
3
|
import android.app.UiModeManager
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.content.res.Configuration
|
|
6
|
+
import android.graphics.Color
|
|
6
7
|
import android.os.Build
|
|
7
8
|
import android.os.Handler
|
|
8
9
|
import android.os.Looper
|
|
@@ -26,6 +27,7 @@ import com.akanjs.runtime.AkanNativeVoidReply
|
|
|
26
27
|
* - mode: the fixed setting, or the configuration's night bit when following the system.
|
|
27
28
|
* - change: onConfigurationChanged, plus a check shortly after set(), since a setting that keeps
|
|
28
29
|
* the drawn scheme (system dark, set dark) changes no configuration. Duplicates are filtered.
|
|
30
|
+
* - setThemeColor: the shell's status bar icons, until the page's document ends.
|
|
29
31
|
* - Below API 31 there is no per-app night mode: the setting goes to AkanNativeCompat.storeNightMode, the
|
|
30
32
|
* shell applies it as an override configuration when the activity starts, and set() recreates the
|
|
31
33
|
* activity when the drawn scheme changes, so the page reloads there.
|
|
@@ -77,6 +79,16 @@ class AppearancePlugin(private val context: AkanNativePluginContext) : Appearanc
|
|
|
77
79
|
if (next != drawn) main.post { activity.recreate() }
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
override fun setThemeColor(args: AppearanceSetThemeColorArgs, reply: AkanNativeVoidReply) {
|
|
83
|
+
val hex = args.color
|
|
84
|
+
if (hex != null && !HEX.matches(hex)) return reply.reject(AkanNativeErrorCode.INVALID_ARGS, "color must be #rrggbb (got $hex)")
|
|
85
|
+
context.setThemeColor(hex?.let(Color::parseColor))
|
|
86
|
+
reply.resolve()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The next page starts from the background color, whether or not it names a theme color. */
|
|
90
|
+
override fun documentEnded(document: String) = context.setThemeColor(null)
|
|
91
|
+
|
|
80
92
|
private fun isNight(config: Configuration) = (config.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES
|
|
81
93
|
|
|
82
94
|
private object Api31 {
|
|
@@ -129,5 +141,6 @@ class AppearancePlugin(private val context: AkanNativePluginContext) : Appearanc
|
|
|
129
141
|
private companion object {
|
|
130
142
|
const val KEY = "setting"
|
|
131
143
|
const val SETTLE_MS = 500L
|
|
144
|
+
val HEX = Regex("#[0-9a-fA-F]{6}")
|
|
132
145
|
}
|
|
133
146
|
}
|
|
@@ -10,6 +10,7 @@ import UIKit
|
|
|
10
10
|
/// - change: a trait registration on the web view sees both system switches and set(). iOS flips
|
|
11
11
|
/// the style of a backgrounded app twice to snapshot both appearances, so changes are only
|
|
12
12
|
/// reported while not in the background, and checked again on the way back to the foreground.
|
|
13
|
+
/// - setThemeColor: the view controller's status bar style, until the page's document ends.
|
|
13
14
|
/// Arguments arrive decoded and checked by the generated AppearancePluginSpec (PL-10).
|
|
14
15
|
final class AppearancePlugin: AppearancePluginSpec {
|
|
15
16
|
static let id = "appearance"
|
|
@@ -47,6 +48,32 @@ final class AppearancePlugin: AppearancePluginSpec {
|
|
|
47
48
|
report()
|
|
48
49
|
}
|
|
49
50
|
|
|
51
|
+
func setThemeColor(_ args: AppearanceSetThemeColorArgs, _ reply: AkanNativeReply<Void>) {
|
|
52
|
+
var style: UIStatusBarStyle?
|
|
53
|
+
if let color = args.color {
|
|
54
|
+
guard let light = Self.isLight(hex: color) else { return reply.reject(.invalidArgs, "color must be #rrggbb (got \(color))") }
|
|
55
|
+
style = light ? .darkContent : .lightContent
|
|
56
|
+
}
|
|
57
|
+
(context.viewController as? AkanNativeViewController)?.statusBarStyle = style
|
|
58
|
+
reply.resolve()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// The next page starts from the appearance, whether or not it names a theme color.
|
|
62
|
+
func documentEnded(_ document: String) {
|
|
63
|
+
(context.viewController as? AkanNativeViewController)?.statusBarStyle = nil
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//? Android's Color.luminance (sRGB relative luminance) over 0.5, so both shells pick the same icons for one color.
|
|
67
|
+
static func isLight(hex: String) -> Bool? {
|
|
68
|
+
let digits = hex.dropFirst()
|
|
69
|
+
guard hex.first == "#", digits.count == 6, digits.allSatisfy(\.isHexDigit), let rgb = UInt32(digits, radix: 16) else { return nil }
|
|
70
|
+
let linear = { (byte: UInt32) -> Double in
|
|
71
|
+
let c = Double(byte & 0xff) / 255
|
|
72
|
+
return c <= 0.04045 ? c / 12.92 : pow((c + 0.055) / 1.055, 2.4)
|
|
73
|
+
}
|
|
74
|
+
return 0.2126 * linear(rgb >> 16) + 0.7152 * linear(rgb >> 8) + 0.0722 * linear(rgb) > 0.5
|
|
75
|
+
}
|
|
76
|
+
|
|
50
77
|
func startListening(_ event: String) {
|
|
51
78
|
guard event == "change", registration == nil, let webView = context.webView else { return }
|
|
52
79
|
last = state()
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "appearance",
|
|
3
3
|
"apiVersion": 1,
|
|
4
|
-
"methods": ["get", "set"],
|
|
4
|
+
"methods": ["get", "set", "setThemeColor"],
|
|
5
5
|
"events": ["change"],
|
|
6
6
|
"codegen": true,
|
|
7
7
|
"web": "./src/web.ts",
|
|
8
|
-
"desktop": "./src/desktop.ts",
|
|
8
|
+
"desktop": { "module": "./src/desktop.ts", "methods": ["get", "set"] },
|
|
9
9
|
"ios": {
|
|
10
10
|
"sources": ["ios/*.swift"],
|
|
11
11
|
"class": "AppearancePlugin",
|
|
@@ -26,6 +26,13 @@ export interface AppearanceApi {
|
|
|
26
26
|
* available on the web (UNSUPPORTED): a page cannot change `prefers-color-scheme`.
|
|
27
27
|
*/
|
|
28
28
|
set(args: { mode: AppearanceSetting }): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* iOS and Android: the color the page paints under the status bar, as `#rrggbb`. The bar's icons turn dark on a light
|
|
31
|
+
* color and light on a dark one; null hands them back to the shell (the appearance on iOS, the app's background color
|
|
32
|
+
* on Android). The page keeps drawing under the bar, so the bar gets no background of its own, and the setting ends
|
|
33
|
+
* with the page's document. Not available on the web or the desktop (UNSUPPORTED).
|
|
34
|
+
*/
|
|
35
|
+
setThemeColor(args: { color: string | null }): Promise<void>;
|
|
29
36
|
}
|
|
30
37
|
|
|
31
38
|
export interface AppearanceEvents {
|
|
@@ -34,7 +41,7 @@ export interface AppearanceEvents {
|
|
|
34
41
|
}
|
|
35
42
|
|
|
36
43
|
export const appearance = definePlugin<AppearanceApi, AppearanceEvents>("appearance", {
|
|
37
|
-
methods: ["get", "set"],
|
|
44
|
+
methods: ["get", "set", "setThemeColor"],
|
|
38
45
|
events: ["change"],
|
|
39
46
|
web,
|
|
40
47
|
});
|
|
@@ -5,6 +5,7 @@ import { homedir } from "node:os";
|
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { AkanNativeError } from "../../../packages/core/src/index.ts";
|
|
7
7
|
import { type DesktopContext, defineDesktopPlugin } from "../../../packages/desktop/src/plugin.ts";
|
|
8
|
+
import { appLauncher } from "../../../packages/desktop/src/relaunch.ts";
|
|
8
9
|
import type { AutostartApi, AutostartState, AutostartStatus } from "./index.ts";
|
|
9
10
|
|
|
10
11
|
export interface ShellError {
|
|
@@ -111,7 +112,7 @@ export function entryStatus(text: string | null): AutostartStatus {
|
|
|
111
112
|
/** `executable`: the file the entry starts; an AppImage's mount point changes at every start, $APPIMAGE does not. */
|
|
112
113
|
export function linuxAutostart(
|
|
113
114
|
dir: () => string = () => autostartDir(),
|
|
114
|
-
executable: () => string = () =>
|
|
115
|
+
executable: () => string = () => appLauncher(),
|
|
115
116
|
) {
|
|
116
117
|
const file = (ctx: DesktopContext) => join(dir(), `${ctx.app.id}.desktop`);
|
|
117
118
|
const read = (ctx: DesktopContext) => (existsSync(file(ctx)) ? readFileSync(file(ctx), "utf8") : null);
|
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
],
|
|
18
18
|
"events": ["load", "loadFailed", "gone", "consoleMessage"],
|
|
19
19
|
"web": null,
|
|
20
|
-
"desktop":
|
|
20
|
+
"desktop": {
|
|
21
|
+
"module": "./src/desktop.ts",
|
|
22
|
+
"unsupported": { "macos": ["sendKey", "setMuted", "capture"] }
|
|
23
|
+
},
|
|
21
24
|
"ios": null,
|
|
22
25
|
"android": null
|
|
23
26
|
}
|
|
@@ -10,8 +10,10 @@ import { definePlugin, type FileRef } from "../../../packages/core/src/index.ts"
|
|
|
10
10
|
* permissions and links another program would open (`mailto:`, a custom scheme) are refused. Listing the plugin in
|
|
11
11
|
* `native.plugins` is what lets an app open one.
|
|
12
12
|
*
|
|
13
|
-
* Windows has every method.
|
|
14
|
-
*
|
|
13
|
+
* Windows has every method. Linux has every method and sends no `consoleMessage`; there the visible view shown last
|
|
14
|
+
* also holds the keyboard focus inside its window, so the user's own keys reach it, until a click on the page takes the
|
|
15
|
+
* focus or the view is hidden or closed. macOS (14 or later, for its separate profile) has all but `sendKey`,
|
|
16
|
+
* `setMuted` and `capture`, and sends no `loadFailed` or `consoleMessage`. iOS and Android: UNSUPPORTED.
|
|
15
17
|
*/
|
|
16
18
|
export type ExternalViewBounds = "fill" | { x: number; y: number; width: number; height: number };
|
|
17
19
|
|
|
@@ -30,7 +32,7 @@ export interface ExternalViewOpenOptions {
|
|
|
30
32
|
* with `evaluate`. It may not declare `__akanTopOnly`, and an empty one registers nothing.
|
|
31
33
|
*/
|
|
32
34
|
initScript?: string;
|
|
33
|
-
/**
|
|
35
|
+
/** macOS refuses `true` as UNSUPPORTED. */
|
|
34
36
|
muted?: boolean;
|
|
35
37
|
/** Media plays with sound without a gesture first (default true): nobody taps a signage screen. */
|
|
36
38
|
autoplay?: boolean;
|
|
@@ -53,7 +55,7 @@ export interface ExternalViewApi {
|
|
|
53
55
|
/**
|
|
54
56
|
* Opens the view, or brings an open one with this id to these options (a page that mounts again finds it). Another
|
|
55
57
|
* `initScript` builds the view again and loads its page anew, as does another `console` on Windows and another
|
|
56
|
-
* `autoplay` on macOS; Windows refuses another `autoplay` as UNSUPPORTED, before anything is built.
|
|
58
|
+
* `autoplay` on macOS and Linux; Windows refuses another `autoplay` as UNSUPPORTED, before anything is built.
|
|
57
59
|
*/
|
|
58
60
|
open(args: ExternalViewOpenOptions): Promise<ExternalViewState>;
|
|
59
61
|
/** Rejects NOT_ALLOWED for a URL on none of its `allowOrigins`. */
|
|
@@ -70,13 +72,16 @@ export interface ExternalViewApi {
|
|
|
70
72
|
* answer within 30 s, as from a page busy in a loop; `sendKey` and `capture` time out the same way.
|
|
71
73
|
*/
|
|
72
74
|
evaluate(args: { id: string; script: string }): Promise<{ value: unknown }>;
|
|
73
|
-
/**
|
|
75
|
+
/**
|
|
76
|
+
* A trusted key press (`{ key: "z", code: "KeyZ" }`), whether or not the view has the focus. Not on macOS; on Linux
|
|
77
|
+
* UNSUPPORTED while the view's window is hidden.
|
|
78
|
+
*/
|
|
74
79
|
sendKey(args: { id: string; key: string; code: string }): Promise<void>;
|
|
75
|
-
/** The view's own sound only; the system volume is the volume plugin's.
|
|
80
|
+
/** The view's own sound only; the system volume is the volume plugin's. Not on macOS. */
|
|
76
81
|
setMuted(args: { id: string; muted: boolean }): Promise<void>;
|
|
77
82
|
/** Clears the view's cookies, storage and cache; the app's own stay. */
|
|
78
83
|
clearData(args: { id: string }): Promise<void>;
|
|
79
|
-
/** A PNG of the view's content (not the screen), kept until its next capture or the next launch.
|
|
84
|
+
/** A PNG of the view's content (not the screen), kept until its next capture or the next launch. Not on macOS. */
|
|
80
85
|
capture(args: { id: string }): Promise<FileRef & { width?: number; height?: number }>;
|
|
81
86
|
}
|
|
82
87
|
|
|
@@ -85,13 +90,15 @@ export interface ExternalViewEvents {
|
|
|
85
90
|
/**
|
|
86
91
|
* A navigation that failed. `errorCode`: `http<status>` for a server's 4xx or 5xx page, else WebView2's own
|
|
87
92
|
* (`hostNameNotResolved`, `cannotConnect`, `timeout`, `certificate`, `disconnected`, …; a refused connection is
|
|
88
|
-
* `unknown`).
|
|
93
|
+
* `unknown`). Linux names the same failures by those names (a refused connection is `cannotConnect`) and any other
|
|
94
|
+
* `unknown`. Not on macOS.
|
|
89
95
|
*/
|
|
90
96
|
loadFailed: { id: string; url: string; errorCode: string };
|
|
91
97
|
/**
|
|
92
|
-
* Its web process ended (`reason`: `crashed`, `unresponsive` or `browserExited` on Windows, `terminated` on macOS
|
|
93
|
-
* the view loads its page again by itself, sooner the first times, and an end
|
|
94
|
-
* again. `rebuildFailed`: after its browser exited the view could not be built
|
|
98
|
+
* Its web process ended (`reason`: `crashed`, `unresponsive` or `browserExited` on Windows, `terminated` on macOS,
|
|
99
|
+
* `crashed`, `killed` or `oom` on Linux); the view loads its page again by itself, sooner the first times, and an end
|
|
100
|
+
* while that waits is not reported again. `rebuildFailed`: after its browser exited the view could not be built
|
|
101
|
+
* again, and is closed; open it again.
|
|
95
102
|
*/
|
|
96
103
|
gone: { id: string; reason: string; restarts: number };
|
|
97
104
|
/** `dropped`: messages left out before this one, past the rate cap. Windows only. */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AgenticSurface } from "./AgenticSurface";
|
|
2
|
+
import { ToolRunner, type ToolRunnerHost } from "./ToolRunner";
|
|
3
|
+
import type { PublishedTool, SurfaceView, ToolCallRequest, ToolCallResult } from "./types";
|
|
4
|
+
|
|
5
|
+
/** `readOnly` is always `false`: a screen tool declares no such flag, so a server loop counts every one as a write. */
|
|
6
|
+
export interface AgentClientToolDefinition extends PublishedTool {
|
|
7
|
+
readOnly: false;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A screen's tools lent to an agent loop that runs on the server: `list()` is what that loop takes as its client
|
|
12
|
+
* tools, and `run(call)` answers a call it parked. A call goes through the same `ToolRunner` as the in-page chat, so a
|
|
13
|
+
* `confirm` still asks through `host.approve` (refused without one), a card needs `host.card`, and the answer is
|
|
14
|
+
* clipped and fenced as the chat's would be.
|
|
15
|
+
*/
|
|
16
|
+
export class AgentClientTools {
|
|
17
|
+
readonly #surface: SurfaceView;
|
|
18
|
+
readonly #runner: ToolRunner;
|
|
19
|
+
|
|
20
|
+
constructor(surface: SurfaceView = AgenticSurface.shared, host: ToolRunnerHost = {}) {
|
|
21
|
+
this.#surface = surface;
|
|
22
|
+
this.#runner = new ToolRunner(surface, host);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
list(): AgentClientToolDefinition[] {
|
|
26
|
+
return this.#surface.snapshot().tools.map((tool) => ({ ...tool, readOnly: false }));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Never throws: a tool no longer on the screen, a refusal and a failure all come back as the result's `error`. */
|
|
30
|
+
async run(call: ToolCallRequest, signal: AbortSignal = new AbortController().signal): Promise<ToolCallResult> {
|
|
31
|
+
return await this.#runner.run(call, signal);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -10,6 +10,7 @@ import type {
|
|
|
10
10
|
ContextBlock,
|
|
11
11
|
MessageReference,
|
|
12
12
|
PublishedTool,
|
|
13
|
+
RunnerEvent,
|
|
13
14
|
RunnerRequest,
|
|
14
15
|
SurfaceView,
|
|
15
16
|
ToolActivity,
|
|
@@ -429,15 +430,15 @@ export class AgentSession {
|
|
|
429
430
|
budget = turn + maxTurns;
|
|
430
431
|
}
|
|
431
432
|
await this.#autoCompact(controller.signal);
|
|
432
|
-
const { toolCalls, stop,
|
|
433
|
+
const { toolCalls, stop, failure } = await this.#assistantTurn(controller.signal);
|
|
433
434
|
|
|
434
435
|
if (controller.signal.aborted) {
|
|
435
436
|
this.#unanswered(toolCalls);
|
|
436
437
|
return;
|
|
437
438
|
}
|
|
438
|
-
if (
|
|
439
|
-
if (recovered || !(await this.#recover(overflow, controller.signal))) {
|
|
440
|
-
if (!controller.signal.aborted) this.#fail(
|
|
439
|
+
if (failure) {
|
|
440
|
+
if (!failure.overflow || recovered || !(await this.#recover(failure.overflow, controller.signal))) {
|
|
441
|
+
if (!controller.signal.aborted) this.#fail(failure.message, failure.code);
|
|
441
442
|
return;
|
|
442
443
|
}
|
|
443
444
|
recovered = true;
|
|
@@ -750,7 +751,7 @@ export class AgentSession {
|
|
|
750
751
|
|
|
751
752
|
async #assistantTurn(
|
|
752
753
|
signal: AbortSignal,
|
|
753
|
-
): Promise<{ toolCalls: ToolCallRequest[]; stop: TurnStop;
|
|
754
|
+
): Promise<{ toolCalls: ToolCallRequest[]; stop: TurnStop; failure?: Extract<RunnerEvent, { type: "error" }> }> {
|
|
754
755
|
const frame = this.#frame();
|
|
755
756
|
this.#overhead = AgentSession.#tokensOfFrame(frame);
|
|
756
757
|
this.#listed = frame.tools.map((tool) => tool.name);
|
|
@@ -770,9 +771,7 @@ export class AgentSession {
|
|
|
770
771
|
stop = event.stop;
|
|
771
772
|
usage = event.usage;
|
|
772
773
|
if (event.limits) this.#limits = { ...this.#limits, ...event.limits };
|
|
773
|
-
} else
|
|
774
|
-
return { toolCalls: [], stop: "end", overflow: { message: event.message, limit: event.overflow.limit } };
|
|
775
|
-
else throw new Error(event.message);
|
|
774
|
+
} else return { toolCalls: [], stop: "end", failure: event };
|
|
776
775
|
}
|
|
777
776
|
if (toolCalls.length || usage)
|
|
778
777
|
this.#patchLast({ ...(toolCalls.length ? { toolCalls } : {}), ...(usage ? { usage } : {}) });
|
|
@@ -907,10 +906,11 @@ export class AgentSession {
|
|
|
907
906
|
}
|
|
908
907
|
|
|
909
908
|
/** Recorded on the open assistant draft when there is one, so a failed turn reads as that turn failing. */
|
|
910
|
-
#fail(message: string) {
|
|
909
|
+
#fail(message: string, code?: string) {
|
|
910
|
+
const failed = { error: message, ...(code ? { errorCode: code } : {}) };
|
|
911
911
|
const last = this.#messages[this.#messages.length - 1];
|
|
912
|
-
if (last?.role === "assistant" && !last.error) this.#patchLast(
|
|
913
|
-
else this.#append({ role: "assistant",
|
|
912
|
+
if (last?.role === "assistant" && !last.error) this.#patchLast(failed);
|
|
913
|
+
else this.#append({ role: "assistant", ...failed });
|
|
914
914
|
}
|
|
915
915
|
|
|
916
916
|
#append(message: ChatMessage) {
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
# use-agentic
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- dcddea0: `agentService.loop` can now call the tools of a screen the member has open, without running them on the server. The run parks each such call, the way an approval parks one, until the page answers it.
|
|
8
|
+
|
|
9
|
+
- **Server.** `clientTools` takes the definitions the open page sent over the app's own transport. They are listed beside the endpoint tools.
|
|
10
|
+
- They are client input. Each definition is rebuilt from `name`, `description`, `parameters`, `readOnly` and `needsConfirm`. A name an endpoint tool holds is dropped, in a closed toolkit too, and so is `openToolkit`.
|
|
11
|
+
- `approve` is still asked about each call. With no approver, a definition that is not `readOnly` counts as a write, and a `needsConfirm` one is refused.
|
|
12
|
+
- An allowed call ends the run as `awaiting`, with `client: true` on the event. Calls written before it in the same batch have already run; calls written after it wait for the resume.
|
|
13
|
+
- The run never waits on a socket. The app delivers the call to the page, appends the page's result to the stored messages (or its own error when no page answers), and resumes. A resume without that result parks the call again. A resume without `clientTools` answers it as an unknown tool.
|
|
14
|
+
- **Browser.** `AgentClientTools` is new in `use-agentic` and re-exported from `akanjs/ui`, along with the `ToolRunnerHost` and `ToolApprovalRequest` types.
|
|
15
|
+
- `new AgentClientTools(surface?, host?).list()` gives the open screen's tools in the shape `clientTools` takes, each with `readOnly: false`.
|
|
16
|
+
- `run(call)` answers a parked call through the same `ToolRunner` as the in-page chat. A `confirm` still asks through `host.approve` and is refused without one, a card tool needs `host.card`, and the answer is clipped and fenced as the chat's would be.
|
|
17
|
+
|
|
18
|
+
Both are new and optional, so no upgrade step is needed.
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
6
21
|
|
|
22
|
+
- 8c70603: A failed agent turn now names a code a host can branch on, beside the message it already sent, which is unchanged. No upgrade step is needed: the fields are new.
|
|
23
|
+
|
|
24
|
+
- The relay's `error` event and `AgentTurnStream.failure` carry `code`, named the way a failed MCP tool call is: by the body the relay would have answered with before its stream opened, so a failure, a 5xx included, reads the same code either side of it. That is the dictionary key in the body, else its code token, else the status's name. The token is an `AkanError`'s own code when its JSON carries it, as a generalized answer always does, or the code a third-party error's own JSON carries. A 401 or 403 takes no key, and a guard's is named by its status alone. `SignalFailure.codeOf(error, status)` holds that rule, and a failed MCP tool call is now named through it too.
|
|
25
|
+
- `use-agentic`'s `RunnerEvent` error gains an optional `code`. `httpRunner` reads it from a stream's error event and keeps it only when it is a dictionary key or one camelCase token. A failure answered before the stream opens is named by its JSON body's bounded code, whether or not the body carries a message, else by its status. A 401 or 403 takes no dictionary key there either, so a refusal or a 5xx reads the code a streamed `error` event names for it. WIRE.md states that rule, and the two cases where the akan server still names a failure differently.
|
|
26
|
+
- The in-page chat keeps the key as `code` after translating the message. The session records it on the failed assistant message as `ChatMessage.errorCode`, which a host reads and the transcript never sends back.
|
|
27
|
+
|
|
7
28
|
- e3de9ef: Tighter defaults for the web client and the in-page agent. Every changed default below names the option that restores the old behaviour.
|
|
8
29
|
|
|
9
30
|
- **Write tools confirm by default.** An `st.tool` whose name starts with `remove`, `delete`, `create`, `update`, `upsert`, `submit`, `save`, `send` or `export` now shows the approval card unless it declares `confirm`. Before, only `remove*` did. This covers `submit<Model>` in `Model.EditModal` and `exportCsvOf<Model>` / `exportJsonOf<Model>` in `Data.ListContainer`. Opt out per tool with `{ confirm: false }`, which also drops the tool's confirm mark in the dock and the screen actions and its MCP `destructiveHint`, or app-wide with `AgentConfirm.set({ byName: (name) => name.startsWith("remove") })`.
|
|
@@ -19,6 +40,30 @@
|
|
|
19
40
|
- **Links in agent markdown.** `isSafeHref` drops tabs, newlines and leading control characters and spaces before it reads the scheme, as a browser does, so a disguised `javascript:` link is refused.
|
|
20
41
|
- **CSV export keeps formulas as text.** A text cell that starts with `=`, `+`, `-`, `@`, a tab or a carriage return gets a leading `'`. Numbers are written unchanged.
|
|
21
42
|
|
|
43
|
+
- 3b7247e: A failed tool call now names a code a client or a model can branch on, beside the text it already sent, which is unchanged. No upgrade step is needed: `AgentWireToolResult` and `use-agentic`'s `ToolCallResult` only gain an optional `code`, and `akanjs/common` adds `MCP_FAILURE_META`, `McpFailure` and `FailureCode`.
|
|
44
|
+
|
|
45
|
+
Every code is a bounded token, a dictionary key (`<module>.error.<key>`) or one camelCase identifier, never prose, so no text can pass for one.
|
|
46
|
+
|
|
47
|
+
- **An app's `/mcp`:**
|
|
48
|
+
- A tool error carries `_meta["akanjs/failure"]: { code, statusCode }`, beside the server's own `_meta` for a 2026-07-28 client. The code is the one an HTTP caller gets:
|
|
49
|
+
- a domain `Err` by its dictionary key, such as `base.error.documentNotFound`;
|
|
50
|
+
- an `AkanError` by its code, such as `invalidArgument` for an argument the call got wrong;
|
|
51
|
+
- a guard's 401 or 403 by its status alone (`unauthorized`, `forbidden`);
|
|
52
|
+
- a 5xx by the dictionary key or code token its HTTP answer carries, else by its status (`internalError`, `serviceUnavailable`). Its text is redacted but its code is not, and the code comes from the error's own JSON when that carries one, which can be a third-party library's.
|
|
53
|
+
- A JSON-RPC error carries `data.code`, which tells apart what `-32602` covers:
|
|
54
|
+
- `unknownTool`, `unknownPrompt` (an unlisted page prompt included) and `unknownResource`;
|
|
55
|
+
- `invalidArgument` for bad arguments or a missing tool name, prompt name or resource uri;
|
|
56
|
+
- a refused screen's `forbidden` or `notFound`.
|
|
57
|
+
A rate-limited call names `tooManyRequests` and the catch-all names `internalError`.
|
|
58
|
+
- An MCP Apps view's call that fails without a domain `Err` restores as an error with that status and code, where it used to be a plain `Error`. A tool the view itself serves to the host names its code in the same `_meta` entry, without a `statusCode`.
|
|
59
|
+
- **`akan mcp`:** a tool error carries the same `_meta["akanjs/failure"]`, with one of these codes:
|
|
60
|
+
- `unknownTool` for a name no mode lists;
|
|
61
|
+
- `toolUnavailable` for a tool outside the server's mode;
|
|
62
|
+
- `invalidArgument` for a missing argument, an unknown guideline name, or a workflow path outside `.akan/workflows/`;
|
|
63
|
+
- `toolFailed` for anything else, with `statusCode` 500. A coded `AkanError` keeps its own code.
|
|
64
|
+
- **The code agent:** an MCP server's tool result keeps the code it named, from `_meta["akanjs/failure"]` or a JSON-RPC error's `data.code`, in the call's `details`.
|
|
65
|
+
- **The in-page agent:** a `toolResults` entry whose tool threw carries `code` beside `error` (see `use-agentic`'s WIRE.md): a dictionary `Err`'s key, else the thrown error's own `code`. A `taint: "source"` tool's result carries none, since its code would travel outside the page-content fence. The bundled Anthropic and OpenAI adaptors send `code` to the model inside the tool result, beside `error`.
|
|
66
|
+
|
|
22
67
|
## 0.3.0
|
|
23
68
|
|
|
24
69
|
### Minor Changes
|
|
@@ -95,7 +95,8 @@ export class Compaction {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
static #charsOf(message: ChatMessage): number {
|
|
98
|
-
const posted =
|
|
98
|
+
const posted =
|
|
99
|
+
message.usage || message.errorCode ? { ...message, usage: undefined, errorCode: undefined } : message;
|
|
99
100
|
const own = Compaction.#blanked(message.attachments);
|
|
100
101
|
let images = own.images;
|
|
101
102
|
const toolResults = message.toolResults?.map((result) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AgentAbort } from "./AgentAbort";
|
|
2
2
|
import { AgentProgress, type AgentProgressReport } from "./AgentProgress";
|
|
3
|
+
import { failureCodeOf, isFailureCode } from "./failureCode";
|
|
3
4
|
import { ToolOutput } from "./ToolOutput";
|
|
4
5
|
import { ToolReturn } from "./ToolReturn";
|
|
5
6
|
import type {
|
|
@@ -124,9 +125,10 @@ export class ToolRunner {
|
|
|
124
125
|
async run(call: ToolCallRequest, signal: AbortSignal): Promise<ToolCallResult> {
|
|
125
126
|
const source = this.#surface.tool(call.name)?.taint === "source";
|
|
126
127
|
|
|
127
|
-
const answered = ToolOutput.clipped(await this.#answer(call, signal));
|
|
128
|
-
if (!source) return answered;
|
|
128
|
+
const { code, ...answered } = ToolOutput.clipped(await this.#answer(call, signal));
|
|
129
|
+
if (!source) return isFailureCode(code) ? { ...answered, code } : answered;
|
|
129
130
|
this.#untrusted = true;
|
|
131
|
+
|
|
130
132
|
return ToolRunner.#framed(answered);
|
|
131
133
|
}
|
|
132
134
|
|
|
@@ -227,7 +229,8 @@ export class ToolRunner {
|
|
|
227
229
|
return ToolRunner.#answered(base, returned, this.#surface.diffSince(before));
|
|
228
230
|
} catch (error) {
|
|
229
231
|
failed = error instanceof Error ? error.message : String(error);
|
|
230
|
-
|
|
232
|
+
const code = failureCodeOf(error);
|
|
233
|
+
return { ...base, error: failed, ...(code ? { code } : {}) };
|
|
231
234
|
} finally {
|
|
232
235
|
this.#host.progress?.({ callId: call.id, report: null });
|
|
233
236
|
this.#host.activity?.({
|
|
@@ -15,9 +15,7 @@ export class Transcript {
|
|
|
15
15
|
|
|
16
16
|
/** What one turn posts: no host-only message, no unanswered call, no result answering a call nobody sees. */
|
|
17
17
|
static wire(messages: readonly ChatMessage[]): ChatMessage[] {
|
|
18
|
-
return Transcript.sanitize(
|
|
19
|
-
Transcript.seen(messages.filter((message) => !message.local)).map(Transcript.unmeasured),
|
|
20
|
-
);
|
|
18
|
+
return Transcript.sanitize(Transcript.seen(messages.filter((message) => !message.local)).map(Transcript.#sent));
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
/**
|
|
@@ -54,6 +52,11 @@ export class Transcript {
|
|
|
54
52
|
return { ...result, attachments };
|
|
55
53
|
}
|
|
56
54
|
|
|
55
|
+
static #sent(message: ChatMessage): ChatMessage {
|
|
56
|
+
const unmeasured = Transcript.unmeasured(message);
|
|
57
|
+
return unmeasured.errorCode ? { ...unmeasured, errorCode: undefined } : unmeasured;
|
|
58
|
+
}
|
|
59
|
+
|
|
57
60
|
/** A message without the provider's count for its turn — what the wire carries and what a compaction keeps. */
|
|
58
61
|
static unmeasured(message: ChatMessage): ChatMessage {
|
|
59
62
|
return message.usage ? { ...message, usage: undefined } : message;
|
|
@@ -35,6 +35,11 @@ tools, and the loop stay in the client; the server serves exactly one stateless
|
|
|
35
35
|
the request carries.** The client holds that invariant (`Transcript.sanitize`) because provider dialects refuse
|
|
36
36
|
a transcript that breaks it; a backend can map calls to results by id without checking for holes. A call the
|
|
37
37
|
client stopped before running arrives answered with an `error`, not missing.
|
|
38
|
+
- A `toolResults` entry whose call threw may carry `code` beside `error`: a dictionary `Err`'s key
|
|
39
|
+
(`<module>.error.<key>`), else the thrown error's own `code` (an `AkanError`'s). It is a bounded token, never
|
|
40
|
+
prose, and never on a `taint: "source"` tool's result. **Send it to the model with `error`**, so the model can tell
|
|
41
|
+
a refusal it can fix from one it cannot by more than the wording. A client that sends no `code` sends what it
|
|
42
|
+
always did.
|
|
38
43
|
- A message may carry `error` — a turn that failed, recorded where every other failure is recorded. No provider
|
|
39
44
|
format has a field for it, so **fold it into the text you send**: an assistant turn that reaches the model
|
|
40
45
|
saying nothing is one the model repeats.
|
|
@@ -105,10 +110,27 @@ outgrows the window, measured by the provider's own count rather than by a chara
|
|
|
105
110
|
falls back to its transcript ceiling alone.
|
|
106
111
|
|
|
107
112
|
Any non-2xx status is surfaced to the session as one error event and ends the turn; a string `message` or
|
|
108
|
-
`error` field in a JSON body becomes that event's message verbatim,
|
|
109
|
-
message that is a code rather than a sentence may be accompanied by a flat `data`
|
|
110
|
-
the values whoever resolves the code interpolates into its text; a host that does
|
|
111
|
-
message as it stands.
|
|
113
|
+
`error` field in a JSON body becomes that event's message verbatim, else the message is
|
|
114
|
+
`Agent turn failed: <status>`. A message that is a code rather than a sentence may be accompanied by a flat `data`
|
|
115
|
+
object of strings and numbers — the values whoever resolves the code interpolates into its text; a host that does
|
|
116
|
+
not know the code shows the message as it stands.
|
|
117
|
+
|
|
118
|
+
The event also carries `code`, read from a JSON body whether or not it has a message: the dictionary key
|
|
119
|
+
(`<module>.error.<key>`) in the body's `error`, `message` or `code`, else its `code` when that is one camelCase
|
|
120
|
+
token, else the status's name (`unauthorized`, `forbidden`, `tooManyRequests`, `internalError`, or `http<status>`
|
|
121
|
+
for a status with no name). A 401 or 403 takes no dictionary key: it is its `code` token, else its status's name. A
|
|
122
|
+
body's `code` shaped otherwise, such as a proxy's `ECONNRESET`, is dropped rather than passed on, and a body that is
|
|
123
|
+
not JSON, such as a proxy's HTML page, leaves the status's name. A 5xx is no exception: its token is taken too, and
|
|
124
|
+
on the akan server it comes from the failed error's own JSON when that carries one, which can be a third-party
|
|
125
|
+
library's rather than the server's own. The bound is what keeps prose out of it.
|
|
126
|
+
|
|
127
|
+
A server names a failure inside the stream by this same rule, applied to the body it would have answered with, so a
|
|
128
|
+
host sees one code whether the failure came before or after the stream opened. The akan server does, with two
|
|
129
|
+
exceptions. In detailed mode (development, or `AKAN_ERROR_DETAIL=1`) a generalized JSON answer's `error` is the raw
|
|
130
|
+
message, which reads as a key over JSON when it is one. And an app's own forwarded `AkanError` 401 or 403 whose
|
|
131
|
+
JSON carries a code is named by that code over JSON but by its status in the stream; none of the framework's own
|
|
132
|
+
errors is such a refusal. The code is what a host branches on, since the message may reach it already translated.
|
|
133
|
+
The session keeps it on the failed assistant message as `errorCode`, which is never sent back.
|
|
112
134
|
|
|
113
135
|
**A refusal because the prompt no longer fits the window carries `"overflow": { "limit": 128000 }`** (`limit` only
|
|
114
136
|
when the provider named it). It is the one refusal a session can answer by itself: it summarizes the transcript and
|
|
@@ -120,6 +142,6 @@ limit flagged as overflow compacts a conversation that fit.
|
|
|
120
142
|
The same endpoint may answer `text/event-stream` instead when the request's `accept` names it: one `RunnerEvent`
|
|
121
143
|
(`types.ts`) JSON object per SSE `data:` line, ending with the `done` event. A failure after the stream opened
|
|
122
144
|
travels as one `error` event — the status line is already gone by then. `usage` and `limits` ride the `done` event
|
|
123
|
-
and `overflow` the `error` event, in the same shapes as above
|
|
124
|
-
`accept: text/event-stream, application/json` and branches on the response's content type, so a
|
|
125
|
-
streams keeps answering the single JSON object above unchanged.
|
|
145
|
+
and `overflow` and `code` the `error` event, in the same shapes and bounds as above, `code` named by the rule above.
|
|
146
|
+
`httpRunner` sends `accept: text/event-stream, application/json` and branches on the response's content type, so a
|
|
147
|
+
server that never streams keeps answering the single JSON object above unchanged.
|