akanjs 3.0.0-alpha.2 → 3.0.0-alpha.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/README.ko.md +1 -1
- package/README.md +1 -1
- package/base/symbols.ts +4 -0
- package/client/clientRuntime.ts +8 -0
- package/client/cn.ts +7 -0
- package/client/csrTypes.ts +2 -0
- package/client/frameDebug.ts +3 -2
- package/common/Logger.ts +4 -0
- package/common/deepObjectify.ts +21 -7
- package/common/index.ts +14 -0
- package/common/mcpExposure.ts +99 -0
- package/common/pathSet.ts +17 -5
- package/common/routeConvention.ts +30 -0
- package/constant/crystalize.ts +3 -1
- package/constant/fieldInfo.ts +6 -0
- package/constant/getDefault.ts +37 -9
- package/constant/immerify.ts +1 -1
- package/constant/index.ts +2 -0
- package/constant/labelOf.ts +17 -0
- package/constant/mask.ts +60 -0
- package/constant/purify.ts +17 -11
- package/constant/types.ts +14 -12
- package/dictionary/DictionaryLookup.ts +30 -0
- package/dictionary/agent.dictionary.ts +31 -0
- package/dictionary/agentTurn.dictionary.ts +29 -0
- package/dictionary/base.dictionary.ts +8 -0
- package/dictionary/dictInfo.ts +8 -0
- package/dictionary/dictionary.ts +9 -3
- package/dictionary/index.ts +1 -0
- package/document/database.ts +21 -0
- package/document/filterMeta.ts +7 -0
- package/document/index.ts +1 -0
- package/document/into.ts +7 -1
- package/document/noDocumentError.ts +12 -0
- package/fetch/agentTurn.ts +19 -0
- package/fetch/client/fetchClient.ts +71 -13
- package/fetch/client/wsClient.ts +17 -2
- package/fetch/fetchType/endpointFetch.type.ts +10 -4
- package/fetch/index.ts +1 -0
- package/local/apps/serverLifecycle/serverLifecycle-local.db +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local.db-wal +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-wal +0 -0
- package/package.json +11 -9
- package/server/akanApp.ts +30 -34
- package/server/akanOption.ts +65 -7
- package/server/akanServer.ts +172 -7
- package/server/animatedImage.ts +83 -0
- package/server/artifact/routeClientCache.ts +14 -0
- package/server/assetEncoding.ts +47 -0
- package/server/devtools/signalSerializer.ts +2 -2
- package/server/devtools/types.ts +2 -2
- package/server/di/diLifecycle.ts +31 -3
- package/server/di/predefinedAdaptor.ts +6 -0
- package/server/imageOptimizer.ts +33 -46
- package/server/index.ts +1 -2
- package/server/mcp/McpAuth.ts +177 -0
- package/server/mcp/McpDispatcher.ts +245 -0
- package/server/mcp/McpEventStream.ts +76 -0
- package/server/mcp/McpExecutionContext.ts +105 -0
- package/server/mcp/McpRouter.ts +591 -0
- package/server/mcp/index.ts +5 -0
- package/server/resolver/CascadeRunner.ts +1 -1
- package/server/resolver/database.resolver.ts +42 -5
- package/server/resolver/service.resolver.ts +29 -0
- package/server/resolver/signal.resolver.ts +16 -1
- package/server/routeTreeBuilder.ts +2 -44
- package/server/rscWorker.tsx +6 -2
- package/server/subRouteIndexDocument.tsx +61 -0
- package/server/systemPageDocument.tsx +2 -2
- package/server/systemPages.tsx +49 -16
- package/server/vendor/akanjs-fetch.ts +1 -0
- package/server/webRouter.ts +159 -35
- package/service/agent.service.ts +14 -0
- package/service/base.service.ts +2 -1
- package/service/index.ts +1 -0
- package/service/predefinedAdaptor/database.adaptor.ts +78 -24
- package/service/predefinedAdaptor/deepseekLlm.ts +230 -0
- package/service/predefinedAdaptor/index.ts +3 -0
- package/service/predefinedAdaptor/insightQuery.ts +183 -0
- package/service/predefinedAdaptor/llm.adaptor.ts +76 -0
- package/service/predefinedAdaptor/role.adaptor.ts +2 -0
- package/service/predefinedAdaptor/schedule.adaptor.ts +12 -5
- package/service/serviceModule.ts +17 -0
- package/service/types.ts +4 -0
- package/signal/agent/AgentCatalogue.ts +165 -0
- package/signal/agent/index.ts +1 -0
- package/signal/agent.signal.ts +42 -0
- package/signal/agentTurn.ts +8 -0
- package/signal/agentTurnStream.ts +48 -0
- package/signal/base.signal.ts +2 -1
- package/signal/endpointInfo.ts +38 -2
- package/signal/guard.ts +13 -1
- package/signal/guards.ts +52 -1
- package/signal/index.ts +6 -0
- package/signal/mcp/McpDocument.ts +286 -0
- package/signal/mcp/McpProgress.ts +106 -0
- package/signal/mcp/McpUriTemplate.ts +85 -0
- package/signal/mcp/Msg.ts +368 -0
- package/signal/mcp/index.ts +5 -0
- package/signal/mcp/mcpProtocol.ts +120 -0
- package/signal/middleware.ts +7 -3
- package/signal/openapi/openapi.ts +32 -171
- package/signal/schema/JsonSchemaBuilder.ts +211 -0
- package/signal/schema/index.ts +1 -0
- package/signal/signalContext.ts +85 -9
- package/signal/slice.ts +9 -9
- package/signal/types.ts +1 -1
- package/store/action.ts +11 -22
- package/store/actionTag.ts +33 -0
- package/store/agent/AgentBridge.ts +323 -0
- package/store/agent/AgentContext.ts +74 -0
- package/store/agent/AgentPrompts.ts +82 -0
- package/store/agent/AgentVisibility.ts +68 -0
- package/store/agent/ScreenReader.ts +208 -0
- package/store/agent/StoreCatalogue.ts +351 -0
- package/store/agent/StoreSurfaceSource.ts +122 -0
- package/store/agent/index.ts +9 -0
- package/store/agent/storeSurface.ts +28 -0
- package/store/agent/types.ts +50 -0
- package/store/agentic/StToolBuilder.ts +199 -0
- package/store/agentic/attachAgentic.ts +22 -0
- package/store/agentic/index.ts +5 -0
- package/store/agentic/readableValue.ts +17 -0
- package/store/agentic/useStExpose.ts +18 -0
- package/store/agentic/useStState.ts +35 -0
- package/store/baseSt.ts +7 -0
- package/store/databaseStateNames.ts +31 -0
- package/store/formSetterNames.ts +21 -0
- package/store/index.ts +8 -0
- package/store/rootStore.ts +3 -1
- package/store/sliceRole.ts +36 -0
- package/store/state.ts +2 -12
- package/store/store.ts +19 -1
- package/store/storeInstance.ts +165 -20
- package/store/storeRegistry.ts +16 -1
- package/store/types.ts +18 -0
- package/store/withSelector.ts +7 -8
- package/test/registerDom.ts +4 -0
- package/types/base/symbols.d.ts +4 -0
- package/types/client/cn.d.ts +5 -0
- package/types/client/csrTypes.d.ts +2 -0
- package/types/common/Logger.d.ts +2 -0
- package/types/common/deepObjectify.d.ts +4 -2
- package/types/common/index.d.ts +2 -1
- package/types/common/mcpExposure.d.ts +60 -0
- package/types/common/routeConvention.d.ts +8 -0
- package/types/constant/fieldInfo.d.ts +1 -0
- package/types/constant/getDefault.d.ts +5 -0
- package/types/constant/index.d.ts +2 -0
- package/types/constant/labelOf.d.ts +6 -0
- package/types/constant/mask.d.ts +34 -0
- package/types/constant/purify.d.ts +2 -2
- package/types/constant/types.d.ts +2 -2
- package/types/dictionary/DictionaryLookup.d.ts +14 -0
- package/types/dictionary/agent.dictionary.d.ts +1 -0
- package/types/dictionary/agentTurn.dictionary.d.ts +1 -0
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictInfo.d.ts +6 -0
- package/types/dictionary/dictionary.d.ts +11 -9
- package/types/dictionary/index.d.ts +1 -0
- package/types/document/database.d.ts +20 -0
- package/types/document/filterMeta.d.ts +1 -0
- package/types/document/index.d.ts +1 -0
- package/types/document/into.d.ts +6 -1
- package/types/document/noDocumentError.d.ts +12 -0
- package/types/fetch/agentTurn.d.ts +593 -0
- package/types/fetch/client/fetchClient.d.ts +10 -0
- package/types/fetch/fetchType/endpointFetch.type.d.ts +5 -3
- package/types/fetch/index.d.ts +1 -0
- package/types/server/akanOption.d.ts +35 -7
- package/types/server/akanServer.d.ts +44 -1
- package/types/server/animatedImage.d.ts +7 -0
- package/types/server/artifact/routeClientCache.d.ts +6 -0
- package/types/server/assetEncoding.d.ts +7 -0
- package/types/server/devtools/types.d.ts +2 -2
- package/types/server/di/predefinedAdaptor.d.ts +4 -1
- package/types/server/index.d.ts +0 -2
- package/types/server/mcp/McpAuth.d.ts +62 -0
- package/types/server/mcp/McpDispatcher.d.ts +54 -0
- package/types/server/mcp/McpEventStream.d.ts +18 -0
- package/types/server/mcp/McpExecutionContext.d.ts +44 -0
- package/types/server/mcp/McpRouter.d.ts +60 -0
- package/types/server/mcp/index.d.ts +5 -0
- package/types/server/mcp.d.ts +1 -0
- package/types/server/subRouteIndexDocument.d.ts +8 -0
- package/types/server/systemPageDocument.d.ts +1 -0
- package/types/server/systemPages.d.ts +5 -0
- package/types/server/vendor/akanjs-fetch.d.ts +1 -0
- package/types/service/agent.service.d.ts +12 -0
- package/types/service/base.service.d.ts +4 -0
- package/types/service/index.d.ts +1 -0
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +24 -2
- package/types/service/predefinedAdaptor/deepseekLlm.d.ts +64 -0
- package/types/service/predefinedAdaptor/index.d.ts +3 -0
- package/types/service/predefinedAdaptor/insightQuery.d.ts +50 -0
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +68 -0
- package/types/service/predefinedAdaptor/role.adaptor.d.ts +2 -0
- package/types/service/predefinedAdaptor/schedule.adaptor.d.ts +10 -6
- package/types/service/types.d.ts +4 -1
- package/types/signal/agent/AgentCatalogue.d.ts +100 -0
- package/types/signal/agent/index.d.ts +1 -0
- package/types/signal/agent.d.ts +1 -0
- package/types/signal/agent.signal.d.ts +29 -0
- package/types/signal/agentTurn.d.ts +9 -0
- package/types/signal/agentTurnStream.d.ts +16 -0
- package/types/signal/base.signal.d.ts +1 -1
- package/types/signal/endpointInfo.d.ts +21 -3
- package/types/signal/guard.d.ts +11 -0
- package/types/signal/guards.d.ts +22 -1
- package/types/signal/index.d.ts +6 -0
- package/types/signal/mcp/McpDocument.d.ts +65 -0
- package/types/signal/mcp/McpProgress.d.ts +40 -0
- package/types/signal/mcp/McpUriTemplate.d.ts +26 -0
- package/types/signal/mcp/Msg.d.ts +143 -0
- package/types/signal/mcp/index.d.ts +5 -0
- package/types/signal/mcp/mcpProtocol.d.ts +107 -0
- package/types/signal/mcp.d.ts +1 -0
- package/types/signal/openapi/openapi.d.ts +3 -3
- package/types/signal/schema/JsonSchemaBuilder.d.ts +47 -0
- package/types/signal/schema/index.d.ts +1 -0
- package/types/signal/schema.d.ts +1 -0
- package/types/signal/signalContext.d.ts +16 -1
- package/types/signal/slice.d.ts +8 -8
- package/types/signal/types.d.ts +1 -1
- package/types/store/actionTag.d.ts +21 -0
- package/types/store/agent/AgentBridge.d.ts +77 -0
- package/types/store/agent/AgentContext.d.ts +16 -0
- package/types/store/agent/AgentPrompts.d.ts +31 -0
- package/types/store/agent/AgentVisibility.d.ts +21 -0
- package/types/store/agent/ScreenReader.d.ts +11 -0
- package/types/store/agent/StoreCatalogue.d.ts +26 -0
- package/types/store/agent/StoreSurfaceSource.d.ts +18 -0
- package/types/store/agent/index.d.ts +9 -0
- package/types/store/agent/storeSurface.d.ts +14 -0
- package/types/store/agent/types.d.ts +49 -0
- package/types/store/agent.d.ts +1 -0
- package/types/store/agentic/StToolBuilder.d.ts +41 -0
- package/types/store/agentic/attachAgentic.d.ts +14 -0
- package/types/store/agentic/index.d.ts +5 -0
- package/types/store/agentic/readableValue.d.ts +3 -0
- package/types/store/agentic/useStExpose.d.ts +8 -0
- package/types/store/agentic/useStState.d.ts +12 -0
- package/types/store/agentic.d.ts +1 -0
- package/types/store/baseSt.d.ts +29 -22
- package/types/store/databaseStateNames.d.ts +25 -0
- package/types/store/formSetterNames.d.ts +16 -0
- package/types/store/index.d.ts +7 -0
- package/types/store/rootStore.d.ts +5 -1
- package/types/store/sliceRole.d.ts +25 -0
- package/types/store/store.d.ts +7 -2
- package/types/store/storeInstance.d.ts +33 -1
- package/types/store/storeRegistry.d.ts +5 -0
- package/types/store/types.d.ts +15 -0
- package/types/store/withSelector.d.ts +7 -8
- package/types/test/registerDom.d.ts +1 -0
- package/types/ui/Agent/Approval.d.ts +7 -0
- package/types/ui/Agent/Bubble.d.ts +13 -0
- package/types/ui/Agent/Chat.d.ts +24 -0
- package/types/ui/Agent/Context.d.ts +9 -0
- package/types/ui/Agent/Dock.d.ts +16 -0
- package/types/ui/Agent/Guide.d.ts +9 -0
- package/types/ui/Agent/Section.d.ts +10 -0
- package/types/ui/Agent/StateKey.d.ts +16 -0
- package/types/ui/Agent/Tool.d.ts +15 -0
- package/types/ui/Agent/Transcript.d.ts +13 -0
- package/types/ui/Agent/Zone.d.ts +23 -0
- package/types/ui/Agent/fetchRunner.d.ts +12 -0
- package/types/ui/Agent/index.d.ts +17 -0
- package/types/ui/Agent/index_.d.ts +1 -0
- package/types/ui/Agent/sessionHistory.d.ts +12 -0
- package/types/ui/Agent.d.ts +1 -0
- package/types/ui/Badge.d.ts +1 -1
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/CsrImage.d.ts +1 -1
- package/types/ui/Dropdown.d.ts +2 -0
- package/types/ui/Image.d.ts +3 -3
- package/types/ui/Layout/BottomInset.d.ts +2 -1
- package/types/ui/Layout/index.d.ts +1 -1
- package/types/ui/Signal/style.d.ts +4 -1
- package/types/ui/UiOverride/context.d.ts +14 -2
- package/types/ui/agentAttrs.d.ts +14 -0
- package/types/ui/index.d.ts +4 -1
- package/types/ui/overlayLayer.d.ts +24 -0
- package/types/ui/recipe/badgeRecipe.d.ts +7 -3
- package/types/ui/recipe/buttonRecipe.d.ts +7 -3
- package/types/ui/recipe/inputRecipe.d.ts +5 -1
- package/types/vendor/use-agentic/AgentProvider.d.ts +18 -0
- package/types/vendor/use-agentic/AgentScope.d.ts +9 -0
- package/types/vendor/use-agentic/AgentSession.d.ts +50 -0
- package/types/vendor/use-agentic/Agentic.d.ts +21 -0
- package/types/vendor/use-agentic/AgenticSurface.d.ts +44 -0
- package/types/vendor/use-agentic/httpRunner.d.ts +15 -0
- package/types/vendor/use-agentic/index.d.ts +13 -0
- package/types/vendor/use-agentic/surfaceContext.d.ts +5 -0
- package/types/vendor/use-agentic/types.d.ts +133 -0
- package/types/vendor/use-agentic/useAgent.d.ts +4 -0
- package/types/vendor/use-agentic/useAgentGuide.d.ts +6 -0
- package/types/vendor/use-agentic/useAgentResource.d.ts +7 -0
- package/types/vendor/use-agentic/useAgentState.d.ts +13 -0
- package/types/vendor/use-agentic/useAgentTool.d.ts +16 -0
- package/types/vendor/use-agentic.d.ts +1 -0
- package/types/webkit/index.d.ts +3 -0
- package/types/webkit/lazy.d.ts +12 -0
- package/types/webkit/useCsrValues.d.ts +3 -3
- package/types/webkit/useEscapeKey.d.ts +5 -0
- package/types/webkit/useFrameRuntime.d.ts +6 -1
- package/types/webkit/useScreenScope.d.ts +18 -0
- package/ui/Agent/Approval.tsx +29 -0
- package/ui/Agent/Bubble.tsx +74 -0
- package/ui/Agent/Chat.tsx +225 -0
- package/ui/Agent/Context.tsx +38 -0
- package/ui/Agent/Dock.tsx +72 -0
- package/ui/Agent/Guide.tsx +16 -0
- package/ui/Agent/Section.tsx +24 -0
- package/ui/Agent/StateKey.tsx +44 -0
- package/ui/Agent/Tool.tsx +66 -0
- package/ui/Agent/Transcript.tsx +33 -0
- package/ui/Agent/Zone.tsx +48 -0
- package/ui/Agent/fetchRunner.ts +30 -0
- package/ui/Agent/index.ts +12 -0
- package/ui/Agent/index_.tsx +4 -0
- package/ui/Agent/sessionHistory.ts +33 -0
- package/ui/Badge.tsx +3 -3
- package/ui/BottomSheet.tsx +5 -0
- package/ui/Button.tsx +6 -2
- package/ui/Constant/Doc.tsx +1 -1
- package/ui/CsrImage.tsx +1 -1
- package/ui/Data/ListContainer.tsx +1 -1
- package/ui/DatePicker.tsx +5 -4
- package/ui/Dialog/Modal.tsx +12 -15
- package/ui/DraggableList.tsx +3 -1
- package/ui/Dropdown.tsx +33 -11
- package/ui/Field.tsx +30 -16
- package/ui/Image.tsx +3 -3
- package/ui/Input.tsx +14 -5
- package/ui/Layout/BottomInset.tsx +6 -1
- package/ui/Load/Units.tsx +11 -2
- package/ui/Load/View.tsx +7 -2
- package/ui/Loading/ProgressBar.tsx +8 -1
- package/ui/Menu.tsx +7 -8
- package/ui/Model/EditModal.tsx +37 -2
- package/ui/Model/SureToRemove.tsx +2 -1
- package/ui/Model/index_.tsx +42 -15
- package/ui/ObjectId.tsx +3 -4
- package/ui/Pagination.tsx +3 -4
- package/ui/Popconfirm.tsx +8 -7
- package/ui/Select.tsx +6 -4
- package/ui/Signal/RestApi.tsx +43 -16
- package/ui/Signal/WebSocket.tsx +1 -1
- package/ui/Signal/style.ts +6 -1
- package/ui/Switch.tsx +2 -0
- package/ui/System/CSR.tsx +6 -2
- package/ui/System/ThemeToggle.tsx +55 -33
- package/ui/ToggleSelect.tsx +4 -3
- package/ui/Tooltip.tsx +2 -1
- package/ui/UiOverride/context.ts +14 -2
- package/ui/agentAttrs.ts +19 -0
- package/ui/index.ts +10 -1
- package/ui/overlayLayer.ts +39 -0
- package/ui/recipe/badgeRecipe.ts +22 -3
- package/ui/recipe/buttonRecipe.ts +51 -2
- package/ui/recipe/factory.ts +2 -2
- package/ui/recipe/inputRecipe.ts +18 -4
- package/vendor/use-agentic/AgentProvider.tsx +39 -0
- package/vendor/use-agentic/AgentScope.tsx +20 -0
- package/vendor/use-agentic/AgentSession.ts +292 -0
- package/vendor/use-agentic/Agentic.tsx +44 -0
- package/vendor/use-agentic/AgenticSurface.ts +294 -0
- package/vendor/use-agentic/WIRE.md +57 -0
- package/vendor/use-agentic/httpRunner.ts +115 -0
- package/vendor/use-agentic/index.ts +14 -0
- package/vendor/use-agentic/surfaceContext.ts +9 -0
- package/vendor/use-agentic/types.ts +144 -0
- package/vendor/use-agentic/useAgent.ts +17 -0
- package/vendor/use-agentic/useAgentGuide.ts +16 -0
- package/vendor/use-agentic/useAgentResource.ts +30 -0
- package/vendor/use-agentic/useAgentState.ts +61 -0
- package/vendor/use-agentic/useAgentTool.ts +55 -0
- package/webkit/bootCsr.tsx +2 -33
- package/webkit/index.ts +3 -0
- package/webkit/lazy.tsx +27 -3
- package/webkit/useCsrValues.ts +121 -4
- package/webkit/useEscapeKey.tsx +42 -0
- package/webkit/useFrameRuntime.ts +65 -32
- package/webkit/useScreenScope.tsx +49 -0
|
@@ -1,15 +1,43 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { BackendEnv, PromiseOrObject } from "akanjs/base";
|
|
2
|
+
import type { Adaptor, AdaptorCls, LlmOption } from "akanjs/service";
|
|
3
|
+
import type { AgentRelayPolicy, MiddlewareCls } from "akanjs/signal";
|
|
4
|
+
import type { McpServerOption } from "./akanServer.d.ts";
|
|
3
5
|
import type { WebProxyRegistration } from "./proxy.d.ts";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
export interface AdaptorOverride {
|
|
7
|
+
role: AdaptorCls;
|
|
8
|
+
adaptor: AdaptorCls;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* App/library server option builder: use objects, signal middleware, adaptor overrides, web proxies, and the
|
|
12
|
+
* server settings an app owns — MCP, the agent relay's access policy, and the LLM the relay speaks to.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AkanOption<Env = unknown> {
|
|
6
15
|
#private;
|
|
7
16
|
constructor();
|
|
8
|
-
use(fnOrObject: ((env: Env) => Record<string, PromiseOrObject<unknown>>) | Record<string, PromiseOrObject<unknown>>): this;
|
|
17
|
+
use(fnOrObject: ((env: Env & BackendEnv) => Record<string, PromiseOrObject<unknown>>) | Record<string, PromiseOrObject<unknown>>): this;
|
|
9
18
|
applyMiddleware(...middlewares: MiddlewareCls[]): this;
|
|
19
|
+
/** Rebinds a predefined adaptor role (e.g. `LlmAdaptorRole`) to the app's own implementation. Last writer wins. */
|
|
20
|
+
applyAdaptor<T extends Adaptor>(role: AdaptorCls<T>, adaptor: AdaptorCls<T>): this;
|
|
10
21
|
applyWebProxy(...proxies: WebProxyRegistration[]): this;
|
|
11
|
-
|
|
22
|
+
/**
|
|
23
|
+
* MCP server settings for the app mounting this option, merged over the `AKAN_MCP_*` environment and under an
|
|
24
|
+
* option the server is constructed with. The app's own `option.ts` is the last lib the server reads, so it wins
|
|
25
|
+
* over every library it depends on.
|
|
26
|
+
*/
|
|
27
|
+
setMcp(mcp?: boolean | McpServerOption): this;
|
|
28
|
+
/**
|
|
29
|
+
* Who may spend the LLM key through the `runAgentTurn` relay — the `AgentRelayAccess` policy, which defaults to
|
|
30
|
+
* allowing everyone because the framework has no account model to gate on. `null` reopens it.
|
|
31
|
+
*/
|
|
32
|
+
setAgentAccess(policy: AgentRelayPolicy | null): this;
|
|
33
|
+
/** Settings for whichever adaptor fills `LlmAdaptorRole`, injected into it as the `llmOption` use. */
|
|
34
|
+
setLlm(llmOrFn: LlmOption | ((env: Env) => LlmOption)): this;
|
|
35
|
+
getUses(env: Env & BackendEnv): Record<string, PromiseOrObject<unknown>>;
|
|
12
36
|
getMiddlewares(): MiddlewareCls[];
|
|
37
|
+
getAdaptorOverrides(): AdaptorOverride[];
|
|
13
38
|
getWebProxies(): WebProxyRegistration[];
|
|
39
|
+
getMcp(): boolean | McpServerOption | undefined;
|
|
40
|
+
getAgentAccess(): AgentRelayPolicy | null | undefined;
|
|
41
|
+
getLlm(env: Env & BackendEnv): LlmOption;
|
|
14
42
|
}
|
|
15
|
-
export declare function createDefaultAkanOption(): AkanOption<
|
|
43
|
+
export declare function createDefaultAkanOption(): AkanOption<unknown>;
|
|
@@ -3,6 +3,7 @@ import { Logger } from "akanjs/common";
|
|
|
3
3
|
import type { Adaptor, AdaptorCls, DatabaseConfig, Service, ServiceCls, SolidConfig } from "akanjs/service";
|
|
4
4
|
import type { ServerSignal, ServerSignalCls } from "akanjs/signal";
|
|
5
5
|
import type { AkanLib, AkanLibProps } from "./akanLib.d.ts";
|
|
6
|
+
import { type McpAuthOption } from "./mcp.d.ts";
|
|
6
7
|
export interface AkanServerProps extends AkanLibProps {
|
|
7
8
|
env?: BaseEnv;
|
|
8
9
|
prefix?: string;
|
|
@@ -11,6 +12,43 @@ export interface AkanServerProps extends AkanLibProps {
|
|
|
11
12
|
}
|
|
12
13
|
export interface AkanServerOptions {
|
|
13
14
|
openapi?: boolean;
|
|
15
|
+
/** `/mcp` is mounted by default; `false` takes it off, and the object form carries the rest of its settings. */
|
|
16
|
+
mcp?: boolean | McpServerOption;
|
|
17
|
+
}
|
|
18
|
+
export interface McpServerOption {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Drops every mutation from the catalogue whatever its guards allow — for a deployment that must not be able to
|
|
22
|
+
* write, such as a read replica or a demo. Off by default, and reported per endpoint in the boot log, because a
|
|
23
|
+
* switch that silently unlists a published endpoint cannot tell its author why it vanished.
|
|
24
|
+
*/
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Mount path, `/mcp` by default. The published OAuth resource identifier follows it, so changing it changes
|
|
28
|
+
* the `aud` a token has to carry.
|
|
29
|
+
*/
|
|
30
|
+
path?: string;
|
|
31
|
+
/** Reported as `serverInfo.version`. Defaults to `0.0.0`, the same placeholder the OpenAPI document uses. */
|
|
32
|
+
version?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Free-text usage guidance handed to the model alongside the tool list — the one place to say what this app
|
|
35
|
+
* is for and which tool to reach for first. Defaults to a bare one-liner naming the app.
|
|
36
|
+
*/
|
|
37
|
+
instructions?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Extra origins allowed past the DNS-rebinding check, beyond the server's own host. Needed only for a
|
|
40
|
+
* browser-hosted MCP client; native ones send no `Origin` at all.
|
|
41
|
+
*/
|
|
42
|
+
allowedOrigins?: string[];
|
|
43
|
+
/** Entries per catalogue page. A client that wants the whole list follows `nextCursor` until it stops. */
|
|
44
|
+
pageSize?: number;
|
|
45
|
+
/**
|
|
46
|
+
* The one language the catalogue and its error text are written in, `en` by default. Server-wide on purpose:
|
|
47
|
+
* the document is built once at boot and cached by clients, and it is read by a model rather than by a person.
|
|
48
|
+
*/
|
|
49
|
+
language?: string;
|
|
50
|
+
/** OAuth resource-server identity: which issuers a client may authenticate with, and the scopes to demand. */
|
|
51
|
+
auth?: McpAuthOption;
|
|
14
52
|
}
|
|
15
53
|
export interface AkanServerConsoleInfo {
|
|
16
54
|
name: string;
|
|
@@ -37,12 +75,17 @@ export declare class AkanServer {
|
|
|
37
75
|
prefix: string;
|
|
38
76
|
websocketPrefix: string;
|
|
39
77
|
openapi: boolean;
|
|
78
|
+
mcp: boolean;
|
|
79
|
+
mcpReadOnly: boolean;
|
|
80
|
+
mcpAuth: McpAuthOption;
|
|
81
|
+
mcpOption: Omit<McpServerOption, "enabled" | "readOnly" | "auth">;
|
|
40
82
|
serverMode: "federation" | "batch" | "all";
|
|
41
83
|
shutdownTimeoutMs: number;
|
|
42
|
-
constructor(name?: string, env?:
|
|
84
|
+
constructor(name?: string, env?: {}, serverMode?: "federation" | "batch" | "all", ...libsOrOptions: (AkanLib | AkanServerOptions)[]);
|
|
43
85
|
setPrefix(prefix: string): this;
|
|
44
86
|
setWebsocketPrefix(websocketPrefix: string): this;
|
|
45
87
|
setOpenApi(openapi?: boolean): this;
|
|
88
|
+
setMcp(mcp?: boolean | McpServerOption): this;
|
|
46
89
|
setDatabaseConfig(database: DatabaseConfig): this;
|
|
47
90
|
setSolidConfig(solid: SolidConfig): this;
|
|
48
91
|
setShutdownTimeout(timeoutMs: number): this;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Bun.Image.metadata()` reports only `{ width, height, format }` — there is no frame count — and an
|
|
3
|
+
* animated GIF decodes to its first frame without erroring. So an optimizer that re-encodes whatever
|
|
4
|
+
* decodes would silently drop the animation. These readers answer the question from the container bytes
|
|
5
|
+
* instead, so an animated source can be passed through untouched.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isAnimatedImage: (buffer: Buffer, contentType: string) => boolean;
|
|
@@ -35,6 +35,12 @@ export declare class RouteClientCache {
|
|
|
35
35
|
#private;
|
|
36
36
|
merged: MergedManifest;
|
|
37
37
|
constructor({ buildRoute, onMerge }: RouteClientCacheOptions);
|
|
38
|
+
/**
|
|
39
|
+
* Bumped on every mutation of `merged`, including a delta merge that leaves `generation` where it was. It lets a
|
|
40
|
+
* consumer memoize work derived from the manifest — merging the runtime manifest over it, say — without having to
|
|
41
|
+
* copy the manifest to find out whether anything changed. In production nothing after `seed` moves it at all.
|
|
42
|
+
*/
|
|
43
|
+
get revision(): number;
|
|
38
44
|
seed(manifest: RoutesManifest): void;
|
|
39
45
|
ensure(routeId: string, seeds: string[]): Promise<MergedManifest>;
|
|
40
46
|
snapshot(): MergedManifest;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export interface EncodedSidecar {
|
|
2
|
+
bytes: ArrayBuffer;
|
|
3
|
+
encoding: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const isCompressibleContentType: (contentType: string) => boolean;
|
|
6
|
+
/** Picks the best precompressed sidecar the caller accepts, or null to serve the file as-is. */
|
|
7
|
+
export declare const resolveEncodedSidecar: (req: Request, filePath: string, contentType: string) => Promise<EncodedSidecar | null>;
|
|
@@ -137,7 +137,7 @@ export interface ConstantData {
|
|
|
137
137
|
}
|
|
138
138
|
export type { ArgType, SerializedArg, SerializedReturns };
|
|
139
139
|
export interface EndpointNode {
|
|
140
|
-
type: "query" | "mutation" | "pubsub" | "message";
|
|
140
|
+
type: "query" | "mutation" | "pubsub" | "message" | "prompt";
|
|
141
141
|
args: SerializedArg[];
|
|
142
142
|
returns: SerializedReturns;
|
|
143
143
|
path?: string;
|
|
@@ -204,7 +204,7 @@ export interface RouteRow {
|
|
|
204
204
|
signal: string;
|
|
205
205
|
key: string;
|
|
206
206
|
source: "declared" | "crud" | "slice";
|
|
207
|
-
type: "query" | "mutation" | "message" | "pubsub";
|
|
207
|
+
type: "query" | "mutation" | "message" | "pubsub" | "prompt";
|
|
208
208
|
transport: "http" | "ws";
|
|
209
209
|
method: "GET" | "POST" | null;
|
|
210
210
|
/** Fully prefixed, `:param` placeholders intact — e.g. `/api/user/:userId`. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DatabaseMode } from "akanjs";
|
|
2
|
-
import { type AdaptorCls, BlobStorage, type CacheAdaptor, type CompressAdaptor, ConsoleLogger, type DatabaseAdaptor, JsonCompressor, type LoggingAdaptor, type QueueAdaptor, type ScheduleAdaptor, Scheduler, SolidCache, SolidPubSub, SolidQueue, SqliteDatabase, type StorageAdaptor, type WebsocketAdaptor } from "akanjs/service";
|
|
2
|
+
import { type AdaptorCls, BlobStorage, type CacheAdaptor, type CompressAdaptor, ConsoleLogger, type DatabaseAdaptor, DeepseekLlm, JsonCompressor, type LlmAdaptor, type LoggingAdaptor, type QueueAdaptor, type ScheduleAdaptor, Scheduler, SolidCache, SolidPubSub, SolidQueue, SqliteDatabase, type StorageAdaptor, type WebsocketAdaptor } from "akanjs/service";
|
|
3
3
|
export interface PredefinedAdaptor {
|
|
4
4
|
database: AdaptorCls<DatabaseAdaptor>;
|
|
5
5
|
cache: AdaptorCls<CacheAdaptor>;
|
|
@@ -9,6 +9,7 @@ export interface PredefinedAdaptor {
|
|
|
9
9
|
logging: AdaptorCls<LoggingAdaptor>;
|
|
10
10
|
websocket: AdaptorCls<WebsocketAdaptor>;
|
|
11
11
|
compress: AdaptorCls<CompressAdaptor>;
|
|
12
|
+
llm: AdaptorCls<LlmAdaptor>;
|
|
12
13
|
}
|
|
13
14
|
export declare const predefinedAdaptorRole: {
|
|
14
15
|
database: AdaptorCls<DatabaseAdaptor>;
|
|
@@ -19,6 +20,7 @@ export declare const predefinedAdaptorRole: {
|
|
|
19
20
|
logging: AdaptorCls<LoggingAdaptor>;
|
|
20
21
|
websocket: AdaptorCls<WebsocketAdaptor>;
|
|
21
22
|
compress: AdaptorCls<CompressAdaptor>;
|
|
23
|
+
llm: AdaptorCls<LlmAdaptor>;
|
|
22
24
|
};
|
|
23
25
|
export declare const predefinedAdaptor: {
|
|
24
26
|
database: typeof SqliteDatabase;
|
|
@@ -29,5 +31,6 @@ export declare const predefinedAdaptor: {
|
|
|
29
31
|
logging: typeof ConsoleLogger;
|
|
30
32
|
websocket: typeof SolidPubSub;
|
|
31
33
|
compress: typeof JsonCompressor;
|
|
34
|
+
llm: typeof DeepseekLlm;
|
|
32
35
|
};
|
|
33
36
|
export declare const getPredefinedAdaptor: (mode?: DatabaseMode) => PredefinedAdaptor;
|
package/types/server/index.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ export * from "./devtools.d.ts";
|
|
|
9
9
|
export type { ChangeBatch, ChangeKind } from "./hmr/changeBatch.d.ts";
|
|
10
10
|
export * from "./processMetricsCollector.d.ts";
|
|
11
11
|
export * from "./proxy.d.ts";
|
|
12
|
-
export * from "./routeElementComposer.d.ts";
|
|
13
|
-
export * from "./routeTreeBuilder.d.ts";
|
|
14
12
|
export * from "./sitemap.d.ts";
|
|
15
13
|
export type { SsrManifest, SsrManifestEntry } from "./ssrTypes.d.ts";
|
|
16
14
|
export * from "./types.d.ts";
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { HttpRoutes } from "../types.d.ts";
|
|
2
|
+
export interface McpAuthOption {
|
|
3
|
+
/** Where a client may obtain a token, published in the metadata document for it to discover. */
|
|
4
|
+
authorizationServers?: string[];
|
|
5
|
+
/** Scopes every call must carry. Declaring any turns `insufficient_scope` enforcement on. */
|
|
6
|
+
scopes?: string[];
|
|
7
|
+
/** Overrides the resource identifier when the public URL differs from what the request reports. */
|
|
8
|
+
resource?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface McpAuthProps extends McpAuthOption {
|
|
11
|
+
/** Path the MCP endpoint is mounted at. Its absolute URL is this server's OAuth resource identifier. */
|
|
12
|
+
path: string;
|
|
13
|
+
}
|
|
14
|
+
interface McpAuthFailure {
|
|
15
|
+
status: 401 | 403;
|
|
16
|
+
error: "invalid_token" | "insufficient_scope";
|
|
17
|
+
description: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The OAuth 2.1 protected-resource half of the MCP authorization spec: the RFC 9728 metadata document, the
|
|
21
|
+
* `WWW-Authenticate` challenge that points at it, and the token checks that can be made without an issuer.
|
|
22
|
+
*
|
|
23
|
+
* The authorization server itself is a separate project. What lives here is what a resource server owes a
|
|
24
|
+
* client regardless of who mints the tokens, so wiring one up later needs no change on this side.
|
|
25
|
+
*/
|
|
26
|
+
export declare class McpAuth {
|
|
27
|
+
#private;
|
|
28
|
+
static readonly wellKnownPath = "/.well-known/oauth-protected-resource";
|
|
29
|
+
constructor(props: McpAuthProps);
|
|
30
|
+
/**
|
|
31
|
+
* Both spellings of the metadata path. RFC 9728 inserts the resource's path into the well-known URL, and MCP
|
|
32
|
+
* clients try that form first and the bare one second; serving only one leaves half the clients at a 404.
|
|
33
|
+
*/
|
|
34
|
+
createRoutes(): HttpRoutes;
|
|
35
|
+
unauthorized(req: Request, failure?: McpAuthFailure): Response;
|
|
36
|
+
/**
|
|
37
|
+
* Refuses a bearer token that is already provably unusable, before the signal pipeline sees it.
|
|
38
|
+
*
|
|
39
|
+
* The claims are read **without verifying the signature**, which is sound only because every branch below can
|
|
40
|
+
* deny and none can grant: a forged token still has to pass the app's own middleware afterwards, so the worst
|
|
41
|
+
* a crafted payload achieves is refusing itself. What this buys is the failure mode it removes — an expired or
|
|
42
|
+
* foreign token otherwise degrades to an anonymous caller, and the agent is told a tool does not exist rather
|
|
43
|
+
* than that it needs to authenticate.
|
|
44
|
+
*/
|
|
45
|
+
reject(req: Request): Response | null;
|
|
46
|
+
/**
|
|
47
|
+
* The public origin, not the one the request arrived on. Behind a proxy `req.url` names the internal host the
|
|
48
|
+
* proxy dialed, and publishing that as the resource identifier is not cosmetic: an authorization server issues
|
|
49
|
+
* `aud` for the URL the *client* used, so every correctly-issued token would then fail the audience check.
|
|
50
|
+
*
|
|
51
|
+
* `McpRouter` compares an `Origin` header against this too — the same proxy that makes `req.url` wrong for the
|
|
52
|
+
* metadata document makes it wrong for a same-origin check, and there the cost is a flat 403.
|
|
53
|
+
*
|
|
54
|
+
* `x-forwarded-host` is a request header, so this is exactly as trustworthy as the edge that overwrites it, and
|
|
55
|
+
* a deployment whose edge merely appends leaves both the same-origin comparison and the audience a token is
|
|
56
|
+
* checked against to the caller. A browser cannot reach it — a custom header is not on a preflight, and the
|
|
57
|
+
* `OPTIONS` is judged on the real host — but a direct caller can. `AKAN_MCP_RESOURCE` pins the identifier for a
|
|
58
|
+
* deployment that cannot make the guarantee.
|
|
59
|
+
*/
|
|
60
|
+
static origin(req: Request): string;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type BaseEnv } from "akanjs/base";
|
|
2
|
+
import { Logger } from "akanjs/common";
|
|
3
|
+
import type { InjectRegistry, LiveRegistry } from "akanjs/service";
|
|
4
|
+
import { type McpExposedEndpoint, type McpToolResult, type PromptMessage } from "../../signal/mcp.d.ts";
|
|
5
|
+
import type { MiddlewareCls } from "../../signal/middleware.d.ts";
|
|
6
|
+
/** Raised when the caller presented no credential at all, so the client should be told to authenticate. */
|
|
7
|
+
export declare class McpAuthRequiredError extends Error {
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A prompt failure whose message has already been through `#message` and is safe to put on the wire.
|
|
11
|
+
*
|
|
12
|
+
* It carries its JSON-RPC code because a prompt has no `isError` result to put a refusal in, so the code is the
|
|
13
|
+
* only place left to say whose fault it was. Without it a mistyped argument reads as `-32603 internal error`,
|
|
14
|
+
* while the *missing*-argument check `prompts/get` does itself answers `-32602` — the same mistake, two codes.
|
|
15
|
+
*/
|
|
16
|
+
export declare class McpPromptError extends Error {
|
|
17
|
+
readonly code: number;
|
|
18
|
+
constructor(message: string, code: number);
|
|
19
|
+
}
|
|
20
|
+
interface McpDispatcherProps {
|
|
21
|
+
registry: InjectRegistry;
|
|
22
|
+
env: BaseEnv;
|
|
23
|
+
live: LiveRegistry;
|
|
24
|
+
middleware: Map<string, MiddlewareCls>;
|
|
25
|
+
/** The one language error text is resolved in, matching the catalogue the client was handed. */
|
|
26
|
+
language?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Executes one MCP tool call or resource read through the ordinary signal pipeline. */
|
|
29
|
+
export declare class McpDispatcher {
|
|
30
|
+
#private;
|
|
31
|
+
static readonly logger: Logger;
|
|
32
|
+
constructor(props: McpDispatcherProps);
|
|
33
|
+
call(exposed: McpExposedEndpoint, args: Record<string, unknown>, req: Request): Promise<McpToolResult>;
|
|
34
|
+
/**
|
|
35
|
+
* A prompt is user-chosen, not model-chosen, so a failure has nowhere to go but the JSON-RPC error — there is
|
|
36
|
+
* no `isError` result the model could read and recover from. Errors propagate to the router unchanged.
|
|
37
|
+
*
|
|
38
|
+
* The messages arrive already normalized: `SignalContext` does that for every `prompt`, so this route and the
|
|
39
|
+
* plain HTTP one return the same shape.
|
|
40
|
+
*/
|
|
41
|
+
prompt(exposed: McpExposedEndpoint, args: Record<string, unknown>, req: Request): Promise<PromptMessage[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Drops catalogue entries whose account-scoped guards refuse this caller — an anonymous agent should not be
|
|
44
|
+
* offered a shelf of admin tools it can only fail at. Entries with no such guard are kept and stopped at call
|
|
45
|
+
* time instead, so the listing is a UX filter and never the access decision.
|
|
46
|
+
*
|
|
47
|
+
* The context is deliberately not `init()`-ed: parsing arguments that a listing does not have would throw,
|
|
48
|
+
* and a resource guard reached here reads `undefined` and fails closed, which is the behaviour we want.
|
|
49
|
+
*/
|
|
50
|
+
filterForAccount<T extends {
|
|
51
|
+
name: string;
|
|
52
|
+
}>(items: T[], req: Request): Promise<T[]>;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One `text/event-stream` response carrying the notifications a single request produced, ending with that
|
|
3
|
+
* request's own result.
|
|
4
|
+
*
|
|
5
|
+
* This is the only channel a server has for pushing anything: `2026-07-28` removed the GET stream, session
|
|
6
|
+
* resumption and server-initiated requests, so nothing may be sent that is not related to a request in flight.
|
|
7
|
+
* Closing the stream is also how the client cancels — `notifications/cancelled` is stdio-only — which is why
|
|
8
|
+
* `cancel` is a constructor argument rather than something a caller could forget to wire.
|
|
9
|
+
*/
|
|
10
|
+
export declare class McpEventStream {
|
|
11
|
+
#private;
|
|
12
|
+
/** Below any common proxy idle timeout, so a slow tool does not have its connection reaped mid-work. */
|
|
13
|
+
static readonly keepAliveMs = 15000;
|
|
14
|
+
constructor(onCancel: () => void);
|
|
15
|
+
response(): Response;
|
|
16
|
+
write(message: object): void;
|
|
17
|
+
close(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { EndpointInfo } from "../../signal/endpointInfo.d.ts";
|
|
2
|
+
import { HttpExecutionContext } from "../../signal/signalContext.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* An argument the caller can fix, carrying a 400 so the dispatcher reports it as a tool error rather than as a
|
|
5
|
+
* server failure. Everything that rejects an argument — the nullable check, `ID._parse`, a scalar's own
|
|
6
|
+
* validator — throws a bare `Error`, and a bare `Error` is indistinguishable from a crash.
|
|
7
|
+
*/
|
|
8
|
+
export declare class McpArgumentError extends Error {
|
|
9
|
+
readonly statusCode = 400;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Runs an endpoint for an MCP call while staying an HTTP context.
|
|
13
|
+
*
|
|
14
|
+
* MCP arrives over HTTP and the whole authorization stack reads the request through this context —
|
|
15
|
+
* `AccountMiddleware` resolves the bearer token off `getHttpContext().req`, and `Self`/`Me` and every guard read
|
|
16
|
+
* what it left there. A transport of its own would not adapt that stack, it would bypass it.
|
|
17
|
+
*/
|
|
18
|
+
export declare class McpExecutionContext extends HttpExecutionContext {
|
|
19
|
+
#private;
|
|
20
|
+
constructor(req: Request, args: Record<string, unknown>);
|
|
21
|
+
/**
|
|
22
|
+
* MCP passes one flat named object, so `param`/`search`/`body` all resolve by name from the same place. An
|
|
23
|
+
* absent value becomes `null` to match what a missing query string yields, letting `deserialize` apply the
|
|
24
|
+
* same nullability rules an HTTP call gets.
|
|
25
|
+
*
|
|
26
|
+
* A name nobody declared is the caller's mistake and is reported as one. `additionalProperties: false` travels
|
|
27
|
+
* in the published schema, but this server does not validate against it and plenty of clients do not either —
|
|
28
|
+
* so reading only the declared names dropped the rest in silence: `{ category, status }` on a slice that takes
|
|
29
|
+
* only `category` came back as a successful, unfiltered list, which a model reads as the filter having applied.
|
|
30
|
+
*
|
|
31
|
+
* "Declared" means what the *published schema* declares, which is why an `Any` argument counts as absent here.
|
|
32
|
+
* It is deliberately left out of that schema — the empty schema tells a model nothing — and the root list's raw
|
|
33
|
+
* `query` descriptor is the one that matters: read as sent, an agent could hand any model exposed through
|
|
34
|
+
* `mcp: { list: true }` an arbitrary query, which is precisely the narrowing a named filter slice exists to make
|
|
35
|
+
* deliberate. `additionalProperties: false` was never going to stop that on its own.
|
|
36
|
+
*/
|
|
37
|
+
getArgs(endpointInfo: EndpointInfo): Promise<unknown[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the serialized value rather than a `Response`, so the router can put it straight into a JSON-RPC
|
|
40
|
+
* result. The `Response` in the signature is the base class's; `WebSocketExecutionContext` widens it the same
|
|
41
|
+
* way, and `SignalContext` only ever hands this value back to its caller.
|
|
42
|
+
*/
|
|
43
|
+
makeResponse(result: unknown, endpointInfo: EndpointInfo): Response;
|
|
44
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BaseEnv } from "akanjs/base";
|
|
2
|
+
import { Logger } from "akanjs/common";
|
|
3
|
+
import type { InjectRegistry, LiveRegistry } from "akanjs/service";
|
|
4
|
+
import type { MiddlewareCls } from "../../signal/middleware.d.ts";
|
|
5
|
+
import type { HttpRoutes } from "../types.d.ts";
|
|
6
|
+
import { type McpAuthOption } from "./McpAuth.d.ts";
|
|
7
|
+
export interface McpRouterProps {
|
|
8
|
+
registry: InjectRegistry;
|
|
9
|
+
env: BaseEnv;
|
|
10
|
+
live: LiveRegistry;
|
|
11
|
+
middleware: Map<string, MiddlewareCls>;
|
|
12
|
+
path?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
/** Free-text usage guidance handed to the model alongside the tool list. */
|
|
15
|
+
instructions?: string;
|
|
16
|
+
/** Extra origins allowed past the DNS-rebinding check, beyond the server's own host. */
|
|
17
|
+
allowedOrigins?: string[];
|
|
18
|
+
readOnly?: boolean;
|
|
19
|
+
/** Entries per catalogue page. A client that wants the whole list follows `nextCursor` until it stops. */
|
|
20
|
+
pageSize?: number;
|
|
21
|
+
/**
|
|
22
|
+
* The one language every title, description and domain error text is resolved in. The catalogue is built once
|
|
23
|
+
* at boot and cached by clients, so it is a server-wide choice rather than a per-request one: `Accept-Language`
|
|
24
|
+
* would mean a document per language, re-deriving every tool schema, for a surface a model reads and a human
|
|
25
|
+
* rarely sees. Defaults to `en`, falling back to the first registered language when the app has no `en`.
|
|
26
|
+
*/
|
|
27
|
+
language?: string;
|
|
28
|
+
auth?: McpAuthOption;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Serves the app's signals as one MCP endpoint.
|
|
32
|
+
*
|
|
33
|
+
* Answers both protocol eras from the same stateless handler. `2026-07-28` is stateless by design; the legacy
|
|
34
|
+
* revisions only *offer* sessions — a server may decline to issue `Mcp-Session-Id`, and a client that never
|
|
35
|
+
* receives one neither sends one back nor asks to resume a stream. So the legacy era costs an `initialize` reply
|
|
36
|
+
* and a laxer `_meta` check, not a session store. (Measured against Claude Code 2.1.226, which speaks it.)
|
|
37
|
+
*/
|
|
38
|
+
export declare class McpRouter {
|
|
39
|
+
#private;
|
|
40
|
+
static readonly logger: Logger;
|
|
41
|
+
constructor(props: McpRouterProps);
|
|
42
|
+
createRoutes(): HttpRoutes;
|
|
43
|
+
/**
|
|
44
|
+
* Says once, at boot, what this build actually published — and names every endpoint that was kept out.
|
|
45
|
+
*
|
|
46
|
+
* The rejections are fail-closed by design: an endpoint MCP cannot carry, or whose guards do not admit it, is
|
|
47
|
+
* simply not in the catalogue. That is the right default and the wrong silence, and it matters more now that
|
|
48
|
+
* exposure follows the guards — nobody wrote an opt-in whose absence would explain a missing tool, so this log
|
|
49
|
+
* is the only place the answer exists. A refusal turns on a resolved return type and a resolved guard list, so
|
|
50
|
+
* it reads only from here.
|
|
51
|
+
*
|
|
52
|
+
* An entry published with no description rides here for the same reason: the text every generated entry borrows
|
|
53
|
+
* is a *model* `.desc()`, which no source rule would read as that entry's description. This holds the resolved
|
|
54
|
+
* catalogue, so it can simply look.
|
|
55
|
+
*
|
|
56
|
+
* Called by whatever mounts the router rather than from `createRoutes`, so building a router to answer one
|
|
57
|
+
* request — which tests and tooling do — does not narrate a catalogue nobody asked about.
|
|
58
|
+
*/
|
|
59
|
+
report(): void;
|
|
60
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./mcp/index.d.ts";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface SubRouteIndexOptions {
|
|
3
|
+
locale: string;
|
|
4
|
+
basePaths: string[];
|
|
5
|
+
subRoutes?: Record<string, string[]>;
|
|
6
|
+
}
|
|
7
|
+
export declare const getSubRouteIndexHref: (locale: string, basePath: string) => string;
|
|
8
|
+
export declare function createSubRouteIndexDocument({ locale, basePaths, subRoutes }: SubRouteIndexOptions): ReactNode;
|
|
@@ -32,6 +32,7 @@ export declare const SYSTEM_PAGE_STATUS_COPY: {
|
|
|
32
32
|
readonly actionLabel: "Back to safety";
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
+
export declare const SYSTEM_PAGE_STYLE = "\n:root { color-scheme: dark; --akan-primary: #ff493b; --akan-secondary: #2b2e33; --akan-accent: #d1a23b; --akan-foreground: #ffffff; --akan-background: #1a1a1a; --akan-base-200: #2a2a2a; --akan-error: #f02020; }\nbody { margin: 0; min-height: 100vh; font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif; background: var(--akan-background); color: var(--akan-foreground); }\na { color: inherit; }\n.akan-system-page { min-height: 100vh; display: grid; place-items: center; padding: 32px 18px; box-sizing: border-box; background: radial-gradient(circle at top left, rgba(255, 73, 59, 0.16), transparent 34%), linear-gradient(135deg, var(--akan-background), #111); }\n.akan-system-card { width: min(720px, 100%); border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 32px; background: linear-gradient(145deg, rgba(42, 42, 42, 0.96), rgba(43, 46, 51, 0.78)); box-shadow: 0 24px 80px rgba(0, 0, 0, 0.36); padding: clamp(28px, 6vw, 56px); }\n.akan-system-status { margin: 0 0 18px; font-weight: 800; font-size: clamp(4rem, 18vw, 8rem); line-height: 0.85; letter-spacing: -0.08em; color: var(--akan-primary); }\n.akan-system-eyebrow { margin: 0 0 10px; color: var(--akan-accent); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }\n.akan-system-title { margin: 0; max-width: 12ch; font-size: clamp(2rem, 7vw, 4rem); line-height: 0.95; letter-spacing: -0.055em; color: var(--akan-foreground); }\n.akan-system-description { margin: 22px 0 0; max-width: 56ch; color: rgba(255, 255, 255, 0.76); font-size: 1.05rem; line-height: 1.75; }\n.akan-system-path { margin: 22px 0 0; overflow-wrap: anywhere; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 16px; background: rgba(26, 26, 26, 0.72); padding: 12px 14px; color: rgba(255, 255, 255, 0.72); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.88rem; }\n.akan-system-actions { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 12px; }\n.akan-system-action { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 1px solid var(--akan-primary); border-radius: 999px; background: var(--akan-primary); box-shadow: 0 12px 34px rgba(255, 73, 59, 0.26); color: var(--akan-foreground); padding: 0 18px; font-weight: 800; text-decoration: none; }\n.akan-system-secondary { border: 1px solid rgba(255, 255, 255, 0.12); background: var(--akan-secondary); color: var(--akan-foreground); }\n.akan-system-details { margin-top: 28px; max-height: 260px; overflow: auto; border-radius: 18px; background: rgba(26, 26, 26, 0.82); border: 1px solid rgba(240, 32, 32, 0.22); padding: 16px; color: rgba(255, 255, 255, 0.78); font-size: 0.82rem; line-height: 1.55; white-space: pre-wrap; }\n";
|
|
35
36
|
export declare function createSystemPageDocument(options: SystemPageOptions): ReactNode;
|
|
36
37
|
export declare function getSystemPageErrorDetails(error: unknown): string;
|
|
37
38
|
export declare function getSystemPageHomeHref({ pathname, i18n, basePaths, headerBasePath, }: SystemPageHomeHrefOptions): string;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { type SubRouteIndexOptions } from "./subRouteIndexDocument.d.ts";
|
|
1
2
|
import { type SystemPageKind, type SystemPageOptions } from "./systemPageDocument.d.ts";
|
|
2
3
|
export interface SystemPageResponseOptions extends SystemPageOptions {
|
|
3
4
|
method?: string;
|
|
4
5
|
}
|
|
6
|
+
export interface SubRouteIndexResponseOptions extends SubRouteIndexOptions {
|
|
7
|
+
method?: string;
|
|
8
|
+
}
|
|
5
9
|
export { createSystemPageDocument, getSystemPageHomeHref } from "./systemPageDocument.d.ts";
|
|
6
10
|
export declare function createSystemPageResponse(options: SystemPageResponseOptions): Promise<Response>;
|
|
11
|
+
export declare function createSubRouteIndexResponse(options: SubRouteIndexResponseOptions): Promise<Response>;
|
|
7
12
|
export declare function createSystemPageHeaders(): Headers;
|
|
8
13
|
export declare function createSystemPageFallbackText(kind: SystemPageKind): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "akanjs/fetch";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LlmTurnRequest } from "./predefinedAdaptor/llm.adaptor";
|
|
2
|
+
declare const AgentService_base: import("./serve.d.ts").ServiceCls<"agent", {}, {
|
|
3
|
+
llm: import("./injectInfo.d.ts").InjectInfo<"plug", import("./predefinedAdaptor.d.ts").LlmAdaptor, never, never>;
|
|
4
|
+
}>;
|
|
5
|
+
export declare class AgentService extends AgentService_base {
|
|
6
|
+
runTurn(request: LlmTurnRequest, onDelta?: (delta: string) => void): Promise<{
|
|
7
|
+
text: string;
|
|
8
|
+
toolCalls: import("./predefinedAdaptor.d.ts").AgentWireToolCall[];
|
|
9
|
+
stop: "end" | "toolUse";
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Base } from "akanjs/signal";
|
|
2
|
+
import { AgentService } from "./agent.service";
|
|
2
3
|
import { ServiceModel } from "./serviceModule.d.ts";
|
|
3
4
|
declare const BaseService_base: import("./serve.d.ts").ServiceCls<"base", {}, {
|
|
4
5
|
onCleanup: import("./injectInfo.d.ts").InjectInfo<"env", (() => Promise<void>) | undefined, {
|
|
@@ -13,5 +14,8 @@ export declare const srv: {
|
|
|
13
14
|
base: ServiceModel<typeof BaseService, any, any, {
|
|
14
15
|
baseService: BaseService;
|
|
15
16
|
}>;
|
|
17
|
+
agent: ServiceModel<typeof AgentService, any, any, {
|
|
18
|
+
agentService: AgentService;
|
|
19
|
+
}>;
|
|
16
20
|
};
|
|
17
21
|
export {};
|
package/types/service/index.d.ts
CHANGED
|
@@ -61,6 +61,12 @@ export interface DocumentStore {
|
|
|
61
61
|
matchedCount: number;
|
|
62
62
|
modifiedCount: number;
|
|
63
63
|
}>;
|
|
64
|
+
removeOneByQuery(query: DocumentQuery): Promise<{
|
|
65
|
+
acknowledged: boolean;
|
|
66
|
+
matchedCount: number;
|
|
67
|
+
modifiedCount: number;
|
|
68
|
+
upsertedId: string | null;
|
|
69
|
+
}>;
|
|
64
70
|
bulkWrite(operations: {
|
|
65
71
|
updateOne: {
|
|
66
72
|
filter: DocumentQuery;
|
|
@@ -91,7 +97,9 @@ export interface DocumentStore {
|
|
|
91
97
|
exists(query?: DocumentQuery): Promise<string | null>;
|
|
92
98
|
count(query?: DocumentQuery): Promise<number>;
|
|
93
99
|
insight(query?: DocumentQuery): Promise<any>;
|
|
94
|
-
hydrate(data: DocumentRecord, originalData?: DocumentRecord
|
|
100
|
+
hydrate(data: DocumentRecord, originalData?: DocumentRecord, options?: {
|
|
101
|
+
track?: boolean;
|
|
102
|
+
}): any;
|
|
95
103
|
}
|
|
96
104
|
export interface SqlResultRows<Row = Record<string, unknown>> {
|
|
97
105
|
rows: Row[];
|
|
@@ -314,6 +322,12 @@ export declare class SqlDocumentStore {
|
|
|
314
322
|
matchedCount: number;
|
|
315
323
|
modifiedCount: number;
|
|
316
324
|
}>;
|
|
325
|
+
removeOneByQuery(query: DocumentQuery): Promise<{
|
|
326
|
+
acknowledged: boolean;
|
|
327
|
+
matchedCount: number;
|
|
328
|
+
modifiedCount: number;
|
|
329
|
+
upsertedId: any;
|
|
330
|
+
}>;
|
|
317
331
|
private compiledUpdate;
|
|
318
332
|
bulkWrite(operations: {
|
|
319
333
|
updateOne: {
|
|
@@ -372,7 +386,15 @@ export declare class SqlDocumentStore {
|
|
|
372
386
|
private decodeNestedValue;
|
|
373
387
|
private normalizeWriteValue;
|
|
374
388
|
private fillScalarDefaults;
|
|
375
|
-
|
|
389
|
+
/**
|
|
390
|
+
* `track` buys `isModified()` and costs a deep clone of the row, so it is decided per call site rather than
|
|
391
|
+
* paid everywhere. Only the read paths (`find`, and the projected read behind it) opt out — that clone was 42%
|
|
392
|
+
* of a list query, and a listed document is never the one a save hook runs on. Everything else keeps it, so an
|
|
393
|
+
* external caller of `hydrate` sees no change.
|
|
394
|
+
*/
|
|
395
|
+
hydrate(data: DocumentRecord, originalData?: DocumentRecord, { track }?: {
|
|
396
|
+
track?: boolean;
|
|
397
|
+
}): any;
|
|
376
398
|
private runHooks;
|
|
377
399
|
private insertStmt;
|
|
378
400
|
private prepareReadStmt;
|