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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { AgentWireMessage, LlmAdaptor, LlmOption, LlmTurnAnswer, LlmTurnRequest } from "./llm.adaptor";
|
|
2
|
+
interface DeepseekToolCall {
|
|
3
|
+
id?: string;
|
|
4
|
+
function?: {
|
|
5
|
+
name?: string;
|
|
6
|
+
arguments?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
interface DeepseekAnswer {
|
|
10
|
+
choices?: {
|
|
11
|
+
message?: {
|
|
12
|
+
content?: string | null;
|
|
13
|
+
tool_calls?: DeepseekToolCall[];
|
|
14
|
+
};
|
|
15
|
+
finish_reason?: string;
|
|
16
|
+
}[];
|
|
17
|
+
}
|
|
18
|
+
interface DeepseekMessage {
|
|
19
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
20
|
+
content: string;
|
|
21
|
+
tool_calls?: {
|
|
22
|
+
id: string;
|
|
23
|
+
type: "function";
|
|
24
|
+
function: {
|
|
25
|
+
name: string;
|
|
26
|
+
arguments: string;
|
|
27
|
+
};
|
|
28
|
+
}[];
|
|
29
|
+
tool_call_id?: string;
|
|
30
|
+
}
|
|
31
|
+
declare const DeepseekLlm_base: import("..").AdaptorCls<{}, {
|
|
32
|
+
llmOption: import("..").InjectInfo<"use", LlmOption, never, never>;
|
|
33
|
+
}>;
|
|
34
|
+
export declare class DeepseekLlm extends DeepseekLlm_base implements LlmAdaptor {
|
|
35
|
+
#private;
|
|
36
|
+
chat(request: LlmTurnRequest, onDelta?: (delta: string) => void): Promise<LlmTurnAnswer | null>;
|
|
37
|
+
/**
|
|
38
|
+
* The dialect streams `data: {chunk}` SSE lines ending with `data: [DONE]`. Tool calls arrive fragmented — the
|
|
39
|
+
* first fragment of an index carries id/name, later ones append to the arguments string — so they are assembled
|
|
40
|
+
* by index and parsed once at the end; only assistant text is worth reporting as it arrives.
|
|
41
|
+
*/
|
|
42
|
+
static consumeStream(body: ReadableStream<Uint8Array>, onDelta: (delta: string) => void): Promise<LlmTurnAnswer>;
|
|
43
|
+
/** DeepSeek speaks the OpenAI chat-completions dialect, so the wire→provider mapping lives here in one place. */
|
|
44
|
+
static requestBody(model: string, request: LlmTurnRequest, stream?: boolean): {
|
|
45
|
+
tools?: {
|
|
46
|
+
type: "function";
|
|
47
|
+
function: {
|
|
48
|
+
parameters: Record<string, unknown>;
|
|
49
|
+
description?: string | undefined;
|
|
50
|
+
name: string;
|
|
51
|
+
};
|
|
52
|
+
}[] | undefined;
|
|
53
|
+
messages: DeepseekMessage[];
|
|
54
|
+
stream?: boolean | undefined;
|
|
55
|
+
model: string;
|
|
56
|
+
};
|
|
57
|
+
/** Context rides below the instructions framed as data — screen state must never read as directives. */
|
|
58
|
+
static systemPrompt({ instructions, context }: LlmTurnRequest): string;
|
|
59
|
+
static providerMessages(message: AgentWireMessage): DeepseekMessage[];
|
|
60
|
+
static turnAnswer(answer: DeepseekAnswer): LlmTurnAnswer;
|
|
61
|
+
/** The provider sends arguments as a JSON string; an unparsable one becomes an empty call rather than a crash. */
|
|
62
|
+
static parsedArgs(raw: string | undefined): Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
export * from "./cache.adaptor";
|
|
2
2
|
export * from "./compress.adaptor";
|
|
3
3
|
export * from "./database.adaptor";
|
|
4
|
+
export * from "./deepseekLlm.d.ts";
|
|
5
|
+
export * from "./insightQuery.d.ts";
|
|
6
|
+
export * from "./llm.adaptor";
|
|
4
7
|
export * from "./logging.adaptor";
|
|
5
8
|
export * from "./queue.adaptor";
|
|
6
9
|
export * from "./role.adaptor";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { AkanSqlClient } from "./database.adaptor";
|
|
2
|
+
export interface InsightQueryOptions {
|
|
3
|
+
/** Rows to return at most. Clamped to `InsightQuery.maxRows`, which no caller can raise. */
|
|
4
|
+
limit?: number;
|
|
5
|
+
/** How long to wait for the driver, in ms. See the note on `#raced` for which dialects this can actually stop. */
|
|
6
|
+
timeoutMs?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface InsightQueryResult {
|
|
9
|
+
columns: string[];
|
|
10
|
+
rows: Record<string, unknown>[];
|
|
11
|
+
/** The ceiling cut the answer short, so the caller knows not to read it as complete. */
|
|
12
|
+
truncated: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* One read-only SQL statement, for an agent or an operator asking a question the domain endpoints cannot express.
|
|
16
|
+
*
|
|
17
|
+
* This is the layer-bypassing read, and every safeguard the framework has is bypassed with it — guards, soft delete,
|
|
18
|
+
* cascade, `_postRemove`, and the `hidden`/`secret` masking every other response path performs. So it is read-only
|
|
19
|
+
* by construction rather than by convention, and it is deliberately *not* wired to an endpoint here: the framework
|
|
20
|
+
* owns no guard strong enough to sit in front of it. An app that wants it writes the endpoint with its own
|
|
21
|
+
* `SuperAdmin`, the same way guards ship with the library that owns the model.
|
|
22
|
+
*
|
|
23
|
+
* Three things enforce read-only, and only the third is ours:
|
|
24
|
+
*
|
|
25
|
+
* 1. The statement is wrapped as a derived table — `SELECT * FROM (<sql>) AS "akanInsight" LIMIT ?`. Nothing but a
|
|
26
|
+
* query is legal in that position, in either dialect, so a write is a syntax error from the engine rather than a
|
|
27
|
+
* pattern this code had to recognise. A second statement smuggled behind `;` is a syntax error for the same
|
|
28
|
+
* reason, and the row ceiling rides along on the same wrapper.
|
|
29
|
+
* 2. A rejection before execution, so the caller reads why rather than a syntax error. It runs on the statement with
|
|
30
|
+
* comments and string literals removed, because that is what makes `-- ` and `'…'` unable to hide anything.
|
|
31
|
+
* 3. **`_doc` never crosses the boundary.** Every non-base field lives in that one JSON column, which is where the
|
|
32
|
+
* plan's "re-apply schema-based masking" runs into the fact that an arbitrary SELECT has no model to mask by. So
|
|
33
|
+
* the enforceable rule is the column itself: unnameable in the statement, dropped from the rows, and any cell
|
|
34
|
+
* that still arrives holding a JSON object or array is refused. An insight is made of scalars; a value that is
|
|
35
|
+
* not one is either a document or indistinguishable from it.
|
|
36
|
+
*
|
|
37
|
+
* What that costs is real and worth saying: this answers "how many, since when, grouped how" over base columns and
|
|
38
|
+
* the search mirror, and it cannot read a domain field. Field-level reads go through the domain tools, which mask.
|
|
39
|
+
*/
|
|
40
|
+
export declare class InsightQuery {
|
|
41
|
+
#private;
|
|
42
|
+
/** Not an option. A caller asking for more gets this, because the point is that no caller sets the ceiling. */
|
|
43
|
+
static readonly maxRows = 1000;
|
|
44
|
+
constructor(client: AkanSqlClient);
|
|
45
|
+
run(sql: string, { limit, timeoutMs }?: InsightQueryOptions): Promise<{
|
|
46
|
+
columns: string[];
|
|
47
|
+
rows: Record<string, unknown>[];
|
|
48
|
+
truncated: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface AgentWireToolCall {
|
|
2
|
+
id: string;
|
|
3
|
+
name: string;
|
|
4
|
+
args: Record<string, unknown>;
|
|
5
|
+
}
|
|
6
|
+
export interface AgentWireToolResult {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
result?: unknown;
|
|
10
|
+
changes?: unknown[];
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* One transcript message of the in-page agent wire (`use-agentic`'s WIRE.md), typed at both ends independently —
|
|
15
|
+
* the wire is the contract, so the server never imports the client package.
|
|
16
|
+
*/
|
|
17
|
+
export interface AgentWireMessage {
|
|
18
|
+
role: "user" | "assistant" | "tool";
|
|
19
|
+
text?: string;
|
|
20
|
+
toolCalls?: AgentWireToolCall[];
|
|
21
|
+
toolResults?: AgentWireToolResult[];
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface AgentWireTool {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
parameters?: Record<string, unknown>;
|
|
28
|
+
effect?: string;
|
|
29
|
+
needsConfirm?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface AgentWireContext {
|
|
32
|
+
kind: string;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface LlmTurnRequest {
|
|
36
|
+
messages: AgentWireMessage[];
|
|
37
|
+
tools: AgentWireTool[];
|
|
38
|
+
context: AgentWireContext[];
|
|
39
|
+
instructions?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface LlmTurnAnswer {
|
|
42
|
+
text?: string;
|
|
43
|
+
toolCalls?: AgentWireToolCall[];
|
|
44
|
+
stop: "end" | "toolUse";
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The provider seam for one stateless agent turn: the whole transcript in, one assistant answer out. The server
|
|
48
|
+
* relays — it never executes a client tool — so this is the only surface a provider integration fills. An
|
|
49
|
+
* implementation is an `adapt()` class in a lib's `srvkit/` and follows the adapter convention: failures are
|
|
50
|
+
* logged and answered as `null`, and the calling service decides what that means.
|
|
51
|
+
*/
|
|
52
|
+
export interface LlmAdaptor {
|
|
53
|
+
/**
|
|
54
|
+
* `onDelta` opts into streaming: the adapter reports assistant text as it arrives and still resolves the full
|
|
55
|
+
* answer. An adapter may ignore it — the caller treats zero reported deltas as "answered whole".
|
|
56
|
+
*/
|
|
57
|
+
chat(request: LlmTurnRequest, onDelta?: (delta: string) => void): Promise<LlmTurnAnswer | null>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Settings for whichever adaptor fills `LlmAdaptorRole`, registered with `option.setLlm(...)` and injected as the
|
|
61
|
+
* `llmOption` use. It belongs to the role rather than to one provider: swapping the default for another `adapt()`
|
|
62
|
+
* class re-reads the same three fields under that provider's own defaults.
|
|
63
|
+
*/
|
|
64
|
+
export interface LlmOption {
|
|
65
|
+
apiKey?: string;
|
|
66
|
+
model?: string;
|
|
67
|
+
host?: string;
|
|
68
|
+
}
|
|
@@ -2,6 +2,7 @@ import { type AdaptorCls } from "../adapt.d.ts";
|
|
|
2
2
|
import type { CacheAdaptor } from "./cache.adaptor";
|
|
3
3
|
import type { CompressAdaptor } from "./compress.adaptor";
|
|
4
4
|
import type { DatabaseAdaptor } from "./database.adaptor";
|
|
5
|
+
import type { LlmAdaptor } from "./llm.adaptor";
|
|
5
6
|
import type { LoggingAdaptor } from "./logging.adaptor";
|
|
6
7
|
import type { QueueAdaptor } from "./queue.adaptor";
|
|
7
8
|
import type { ScheduleAdaptor } from "./schedule.adaptor";
|
|
@@ -15,3 +16,4 @@ export declare const ScheduleAdaptorRole: AdaptorCls<ScheduleAdaptor>;
|
|
|
15
16
|
export declare const LoggingAdaptorRole: AdaptorCls<LoggingAdaptor>;
|
|
16
17
|
export declare const WebsocketAdaptorRole: AdaptorCls<WebsocketAdaptor>;
|
|
17
18
|
export declare const CompressAdaptorRole: AdaptorCls<CompressAdaptor>;
|
|
19
|
+
export declare const LlmAdaptorRole: AdaptorCls<LlmAdaptor>;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/** The scheduler's own job handle, so the cron backend stays behind this interface. `Bun.cron` satisfies it. */
|
|
2
|
+
export interface AkanCronJob {
|
|
3
|
+
readonly cron: string;
|
|
4
|
+
stop(): void;
|
|
5
|
+
}
|
|
2
6
|
export interface ScheduleAdaptor {
|
|
3
|
-
getCron(key: string):
|
|
7
|
+
getCron(key: string): AkanCronJob | undefined;
|
|
4
8
|
registerCron(key: string, cronStr: string, callback: () => Promise<void>, option?: {
|
|
5
9
|
lock?: boolean;
|
|
6
|
-
}):
|
|
10
|
+
}): AkanCronJob;
|
|
7
11
|
unregisterCron(key: string): void;
|
|
8
12
|
getInterval(key: string): NodeJS.Timeout | undefined;
|
|
9
13
|
registerInterval(key: string, scheduleTime: number, callback: () => Promise<void>, option?: {
|
|
@@ -29,15 +33,15 @@ declare const Scheduler_base: import("..").AdaptorCls<{}, {
|
|
|
29
33
|
}>;
|
|
30
34
|
export declare class Scheduler extends Scheduler_base implements ScheduleAdaptor {
|
|
31
35
|
readonly lockMap: Map<string, boolean>;
|
|
32
|
-
readonly cronMap: Map<string,
|
|
36
|
+
readonly cronMap: Map<string, AkanCronJob>;
|
|
33
37
|
readonly intervalMap: Map<string, NodeJS.Timeout>;
|
|
34
38
|
readonly timeoutMap: Map<string, NodeJS.Timeout>;
|
|
35
39
|
readonly initMap: Map<string, () => Promise<void>>;
|
|
36
40
|
readonly destroyMap: Map<string, () => Promise<void>>;
|
|
37
|
-
getCron(key: string):
|
|
41
|
+
getCron(key: string): AkanCronJob | undefined;
|
|
38
42
|
registerCron(key: string, cronStr: string, callback: () => Promise<void>, { lock }?: {
|
|
39
43
|
lock?: boolean;
|
|
40
|
-
}):
|
|
44
|
+
}): Bun.CronJob;
|
|
41
45
|
unregisterCron(key: string): void;
|
|
42
46
|
getInterval(key: string): NodeJS.Timeout | undefined;
|
|
43
47
|
registerInterval(key: string, scheduleTime: number, callback: () => Promise<void>, { lock }?: {
|
package/types/service/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Cls, MergeAllTypes, PromiseOrObject } from "akanjs/base";
|
|
2
2
|
import type { Logger } from "akanjs/common";
|
|
3
3
|
import type { QueryOf } from "akanjs/constant";
|
|
4
|
-
import type { CRUDEventType, DatabaseModel, DataInputOf, FilterInstance, FindQueryOption, GetDocObject, ListQueryOption, QueryMethodPart, SaveEventType, UpdateResult } from "akanjs/document";
|
|
4
|
+
import type { CRUDEventType, DatabaseModel, DataInputOf, DocumentUpdateInput, FilterInstance, FindQueryOption, GetDocObject, ListQueryOption, QueryMethodPart, SaveEventType, UpdateResult } from "akanjs/document";
|
|
5
5
|
type ServiceMixinOmitKey = "onInit" | "onDestroy" | "_libsOnInit" | "_libsOnDestroy" | "_preCreate" | "_postCreate" | "_preUpdate" | "_postUpdate" | "_preRemove" | "_postRemove" | "_libsPreCreate" | "_libsPostCreate" | "_libsPreUpdate" | "_libsPostUpdate" | "_libsPreRemove" | "_libsPostRemove";
|
|
6
6
|
type DatabaseQueryMethods<Query, Sort, Obj, Doc, Insight, FindQueryOption, ListQueryOption, DocQuery> = QueryMethodPart<Query, Sort, Obj, Doc, Insight, FindQueryOption, ListQueryOption, DocQuery>;
|
|
7
7
|
type DocumentLike = {
|
|
@@ -32,6 +32,9 @@ export type DatabaseService<T extends string = string, Input = any, Doc = any, O
|
|
|
32
32
|
__update: (id: string, data: Partial<Doc>) => Promise<Doc>;
|
|
33
33
|
__remove: (id: string) => Promise<Doc>;
|
|
34
34
|
__removeMany: (query: _QueryOfDoc) => Promise<UpdateResult>;
|
|
35
|
+
__removeOne: (query: _QueryOfDoc) => Promise<UpdateResult>;
|
|
36
|
+
__updateMany: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
|
|
37
|
+
__updateOne: (query: _QueryOfDoc, update: DocumentUpdateInput<Doc>) => Promise<UpdateResult>;
|
|
35
38
|
__list(query?: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<Doc[]>;
|
|
36
39
|
__listIds(query?: _QueryOfDoc, queryOption?: _ListQueryOption): Promise<string[]>;
|
|
37
40
|
__find(query?: _QueryOfDoc, queryOption?: _FindQueryOption): Promise<Doc | null>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { mcpBaseVerbOf } from "akanjs/common";
|
|
2
|
+
import type { SerializedEndpoint, SerializedSignal, SerializedSlice } from "../types.d.ts";
|
|
3
|
+
/** Where an endpoint came from, which is what decides where an audience's opt-in for it can be written. */
|
|
4
|
+
export type AgentOrigin = "base" | "slice" | "endpoint";
|
|
5
|
+
/** Which generated CRUD verb a `base` candidate is. Its opt-in lives on the signal, not on the endpoint. */
|
|
6
|
+
export type AgentBaseVerb = NonNullable<ReturnType<typeof mcpBaseVerbOf>>;
|
|
7
|
+
/** One endpoint a signal registry holds, before any audience has decided anything about it. */
|
|
8
|
+
export interface AgentCandidate {
|
|
9
|
+
refName: string;
|
|
10
|
+
key: string;
|
|
11
|
+
endpoint: SerializedEndpoint;
|
|
12
|
+
origin: AgentOrigin;
|
|
13
|
+
/** The signal it belongs to. A generated verb carries no option of its own, so its opt-in is written here. */
|
|
14
|
+
signal: SerializedSignal;
|
|
15
|
+
/** The slice this key was generated from, where the opt-in for a `slice` candidate is written. */
|
|
16
|
+
slice?: SerializedSlice;
|
|
17
|
+
baseVerb?: AgentBaseVerb;
|
|
18
|
+
}
|
|
19
|
+
/** An opt-in a catalogue did not honour, with the reason it did not. */
|
|
20
|
+
export interface AgentRefusal {
|
|
21
|
+
key: string;
|
|
22
|
+
reason: string;
|
|
23
|
+
}
|
|
24
|
+
/** A published entry carrying no description its author wrote, and what to write so that it does. */
|
|
25
|
+
export interface AgentUndescribed {
|
|
26
|
+
key: string;
|
|
27
|
+
reason: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AgentCatalogueOptions {
|
|
30
|
+
resolveDescription?: (key: string) => string | undefined;
|
|
31
|
+
excludeSignals?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The half of an agent catalogue that does not depend on who is asking.
|
|
35
|
+
*
|
|
36
|
+
* Enumerating what a signal registry holds, keeping that order stable, holding one name per entry, and resolving
|
|
37
|
+
* the words a module wrote in its dictionary are the same work for every audience — an external MCP client, an
|
|
38
|
+
* in-page agent driving the store, a transport that does not exist yet. What differs is only which option admits
|
|
39
|
+
* an endpoint and what shape it is published in, and both of those stay with the audience that decides them.
|
|
40
|
+
*
|
|
41
|
+
* Separated while exactly one audience existed. The cost then is moving code between two files; the cost later is
|
|
42
|
+
* telling two audiences apart inside one class that never expected a second.
|
|
43
|
+
*/
|
|
44
|
+
export declare class AgentCatalogue {
|
|
45
|
+
#private;
|
|
46
|
+
/**
|
|
47
|
+
* Everything a registry holds, in an order that does not move between boots: clients cache a catalogue, and an
|
|
48
|
+
* LLM prompt cache keys on its exact text, so an order that depends on object iteration is a cache that misses.
|
|
49
|
+
*
|
|
50
|
+
* Every endpoint is listed, including ones no audience will take. Deciding is the caller's half.
|
|
51
|
+
*/
|
|
52
|
+
static candidates(serializedSignal: Record<string, SerializedSignal>, { excludeSignals }?: {
|
|
53
|
+
excludeSignals?: string[];
|
|
54
|
+
}): AgentCandidate[];
|
|
55
|
+
/**
|
|
56
|
+
* What opted in and was refused anyway. Collected rather than merely dropped so a server can say so at boot:
|
|
57
|
+
* the rejections an audience makes are fail-closed by design, and an author whose deliberate opt-in vanished
|
|
58
|
+
* from the catalogue otherwise has nowhere to look but the framework source.
|
|
59
|
+
*/
|
|
60
|
+
readonly refusals: AgentRefusal[];
|
|
61
|
+
constructor(options?: AgentCatalogueOptions);
|
|
62
|
+
/**
|
|
63
|
+
* What is published with no description of its own. Description is the one field a model picks an entry by, so
|
|
64
|
+
* one without it is a broken entry rather than an untidy one — and a source scanner cannot answer this: it
|
|
65
|
+
* reads files, where an opt-in is visible only as a literal in a builder call and where the model `.desc()`
|
|
66
|
+
* every generated entry borrows is not written as a description of the entry at all.
|
|
67
|
+
*/
|
|
68
|
+
get undescribed(): AgentUndescribed[];
|
|
69
|
+
/**
|
|
70
|
+
* Takes the name for this entry, or refuses it because something else already holds it.
|
|
71
|
+
*
|
|
72
|
+
* A name must be unique within a catalogue, across every kind of entry it publishes. Keys are globally unique
|
|
73
|
+
* by construction, so a collision means two signals disagree — the first in candidate order keeps it, which is
|
|
74
|
+
* what makes the catalogue the same on the next boot either way.
|
|
75
|
+
*/
|
|
76
|
+
claim(key: string): boolean;
|
|
77
|
+
refuse(key: string, reason: string): void;
|
|
78
|
+
texts(titleKey: string, descKey?: string): {
|
|
79
|
+
description?: string | undefined;
|
|
80
|
+
title?: string | undefined;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Every entry the framework generates borrows the model's own words, because none of them has any of its own.
|
|
84
|
+
*
|
|
85
|
+
* `slice()` generates the root slice under the empty key and `baseSliceDictionary` fills its text, so
|
|
86
|
+
* `<model>List` and `<model>Insight` publish as "Slice List - Universal" whatever the dictionary says. The five
|
|
87
|
+
* base CRUD entries are no better off: `getBaseSignalDictionary` writes "Get Banner" as both title and
|
|
88
|
+
* description, and both are assigned last, so a module author has nowhere to write over either one.
|
|
89
|
+
*
|
|
90
|
+
* That matters more here than anywhere else — description is the one field a model picks an entry by, and "Get
|
|
91
|
+
* Banner" says nothing about what a Banner is. So the model's `.desc()` is appended rather than substituted:
|
|
92
|
+
* on `removeBanner` a bare model description would read as if the tool returned one. And when the model has no
|
|
93
|
+
* `.desc()` either, the entry is recorded as undescribed — its only possible text is missing, and that is the
|
|
94
|
+
* one thing a source scanner cannot see.
|
|
95
|
+
*/
|
|
96
|
+
entryTexts(refName: string, key: string): {
|
|
97
|
+
description?: string | undefined;
|
|
98
|
+
title?: string | undefined;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AgentCatalogue.d.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./agent/index.d.ts";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Any } from "akanjs/base";
|
|
2
|
+
import { AgentTurn } from "./agentTurn.d.ts";
|
|
3
|
+
declare const AgentInternal_base: import("./internal.d.ts").InternalCls<import("akanjs/service").ServiceModel<typeof import("akanjs/service").AgentService, any, any, {
|
|
4
|
+
agentService: import("akanjs/service").AgentService;
|
|
5
|
+
}>, {
|
|
6
|
+
warnOpenRelay: import("./internalInfo.d.ts").InternalInfo<"init", {
|
|
7
|
+
agentService: import("akanjs/service").AgentService;
|
|
8
|
+
}, [], [], [], typeof Any, void, false>;
|
|
9
|
+
}>;
|
|
10
|
+
export declare class AgentInternal extends AgentInternal_base {
|
|
11
|
+
}
|
|
12
|
+
declare const AgentEndpoint_base: import("./endpoint.d.ts").EndpointCls<import("akanjs/service").ServiceModel<typeof import("akanjs/service").AgentService, any, any, {
|
|
13
|
+
agentService: import("akanjs/service").AgentService;
|
|
14
|
+
}>, {
|
|
15
|
+
runAgentTurn: import("./endpointInfo.d.ts").EndpointInfo<"mutation", {
|
|
16
|
+
agentService: import("akanjs/service").AgentService;
|
|
17
|
+
}, ["messages", "tools", "context", "instructions"], [arg: unknown[], arg: unknown[], arg: unknown[], arg?: string | null | undefined], [arg: Bun.BunRequest<string>], [arg: unknown[], arg: unknown[], arg: unknown[], arg: string | undefined], typeof AgentTurn, AgentTurn, Promise<AgentTurn | {
|
|
18
|
+
text: string;
|
|
19
|
+
toolCalls: import("akanjs/service").AgentWireToolCall[];
|
|
20
|
+
stop: "end" | "toolUse";
|
|
21
|
+
}>, false>;
|
|
22
|
+
}>;
|
|
23
|
+
export declare class AgentEndpoint extends AgentEndpoint_base {
|
|
24
|
+
}
|
|
25
|
+
declare const Agent_base: import("./serverSignal.d.ts").ServerSignalCls<typeof AgentEndpoint, typeof AgentInternal>;
|
|
26
|
+
export declare class Agent extends Agent_base {
|
|
27
|
+
}
|
|
28
|
+
export declare const agent: import("./signalRegistry.d.ts").ServiceSignal<typeof AgentInternal, typeof AgentEndpoint, typeof Agent>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { AgentStop, AgentTurn, agentTurnConstant } from "akanjs/fetch";
|
|
2
|
+
declare const AgentTurnDocument_base: import("akanjs/document").DatabaseCls<{
|
|
3
|
+
text: string;
|
|
4
|
+
toolCalls: unknown[];
|
|
5
|
+
stop: NonNullable<"end" | "toolUse">;
|
|
6
|
+
} & {}>;
|
|
7
|
+
export declare class AgentTurnDocument extends AgentTurnDocument_base {
|
|
8
|
+
}
|
|
9
|
+
export declare const agentTurnDocument: import("akanjs/document").DatabaseCls<AgentTurnDocument>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AgentWireToolCall } from "akanjs/service";
|
|
2
|
+
interface StreamedTurn {
|
|
3
|
+
text?: string;
|
|
4
|
+
toolCalls?: AgentWireToolCall[];
|
|
5
|
+
stop?: "end" | "toolUse";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The streaming half of the agent turn wire (use-agentic WIRE.md): the same endpoint answers `text/event-stream`
|
|
9
|
+
* when the request asks for it, one RunnerEvent JSON per SSE `data:` line, ending with `done`. The signal layer
|
|
10
|
+
* passes a raw `Response` through untouched, which is what lets one mutation serve both shapes.
|
|
11
|
+
*/
|
|
12
|
+
export declare class AgentTurnStream {
|
|
13
|
+
static wants(request: Bun.BunRequest): boolean;
|
|
14
|
+
static response(run: (onDelta: (delta: string) => void) => Promise<StreamedTurn>): Response;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -31,7 +31,7 @@ declare const Base_base: import("./serverSignal.d.ts").ServerSignalCls<typeof Ba
|
|
|
31
31
|
export declare class Base extends Base_base {
|
|
32
32
|
}
|
|
33
33
|
export declare const base: import("./signalRegistry.d.ts").ServiceSignal<typeof BaseInternal, typeof BaseEndpoint, typeof Base>;
|
|
34
|
-
export declare const fetch: import("akanjs/fetch").FetchClientType<[import("./signalRegistry.d.ts").ServiceSignal<typeof BaseInternal, typeof BaseEndpoint, typeof Base>]>;
|
|
34
|
+
export declare const fetch: import("akanjs/fetch").FetchClientType<[import("./signalRegistry.d.ts").ServiceSignal<typeof BaseInternal, typeof BaseEndpoint, typeof Base>, import("./signalRegistry.d.ts").ServiceSignal<typeof import("./agent.signal").AgentInternal, typeof import("./agent.signal").AgentEndpoint, typeof import("./agent.signal").Agent>]>;
|
|
35
35
|
export declare const getSerializedSignal: () => {
|
|
36
36
|
[key: string]: import("./types.d.ts").SerializedSignal;
|
|
37
37
|
};
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
-
import { type Dayjs, type EnumInstance, type PromiseOrObject } from "akanjs/base";
|
|
1
|
+
import { Any, type Dayjs, type EnumInstance, type PromiseOrObject } from "akanjs/base";
|
|
2
2
|
import type { ConstantFieldType, ConstantFieldTypeInput, DocumentModel, FieldToValue, ParamFieldType, PlainTypeToFieldType, PurifiedModel, UploadableClientArg } from "akanjs/constant";
|
|
3
3
|
import type { ServiceModel } from "akanjs/service";
|
|
4
4
|
import type { InternalArgCls } from "./internalArg.d.ts";
|
|
5
|
+
import type { PromptResult } from "./mcp.d.ts";
|
|
5
6
|
import type { ArgType, SignalOption, SrvMap } from "./types.d.ts";
|
|
6
|
-
export type EndpointType = "query" | "mutation" | "pubsub" | "message";
|
|
7
|
+
export type EndpointType = "query" | "mutation" | "pubsub" | "message" | "prompt";
|
|
8
|
+
/**
|
|
9
|
+
* A prompt travels as `Any` because `PrimitiveRegistry.has(Any)` is true, so `resolveReturn` and `makeResponse`
|
|
10
|
+
* hand the messages back untouched. Registering a scalar for `PromptMessage` would buy nothing the builder's
|
|
11
|
+
* `exec` constraint does not already give, and would push a client-side model into every app that never uses one.
|
|
12
|
+
*
|
|
13
|
+
* It does not follow that a prompt's payload is unmasked. What a return ref masks is the value's own fields, and
|
|
14
|
+
* a prompt's are fixed by the protocol; the document inside an attachment is a JSON string by the time any return
|
|
15
|
+
* ref could reach it. So masking is declared at the attachment instead — `Msg.mask` — where the model is named
|
|
16
|
+
* and a payload that lost its class on the way still masks correctly.
|
|
17
|
+
*/
|
|
18
|
+
declare const promptCarrier: typeof Any;
|
|
7
19
|
export interface EndpointArgProps<Optional extends boolean = false> {
|
|
8
20
|
nullable?: Optional;
|
|
9
21
|
example?: string | number | boolean | Dayjs;
|
|
@@ -34,6 +46,7 @@ export declare class EndpointInfo<ReqType extends EndpointType = EndpointType, S
|
|
|
34
46
|
} = {
|
|
35
47
|
[key: string]: any;
|
|
36
48
|
}, ArgNames extends string[] = any, Args extends any[] = any, InternalArgs extends any[] = any, ServerArgs extends any[] = any, Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, ClientReturns = never, ServerReturns = never, Nullable extends boolean = boolean> {
|
|
49
|
+
#private;
|
|
37
50
|
readonly type: ReqType;
|
|
38
51
|
readonly argNames: ArgNames;
|
|
39
52
|
readonly args: ArgInfo<EndpointArgProps<boolean>>[];
|
|
@@ -52,7 +65,7 @@ export declare class EndpointInfo<ReqType extends EndpointType = EndpointType, S
|
|
|
52
65
|
_addArgs(args: ArgInfo<EndpointArgProps<boolean>>[]): this;
|
|
53
66
|
with<ArgType, Optional extends boolean = false>(argRef: InternalArgCls<ArgType>, option?: InternalArgProps<Optional>): EndpointInfo<ReqType, Srvs, ArgNames, Args, [...InternalArgs, arg: NonNullable<ArgType> | (Optional extends true ? null : never)], ServerArgs, Returns, ClientReturns, ServerReturns, Nullable>;
|
|
54
67
|
_addInternalArgs(args: InternalArgInfo<boolean>[]): this;
|
|
55
|
-
exec<ExecFn extends (this: Srvs, ...args: [...ServerArgs, ...InternalArgs]) => ReqType extends "pubsub" ? Promise<void> | void : PromiseOrObject<DocumentModel<FieldToValue<Returns>> | (Nullable extends true ? null | undefined : never)>>(execFn: ExecFn): EndpointInfo<ReqType, Srvs, ArgNames, Args, InternalArgs, ServerArgs, Returns, FieldToValue<Returns>, ReturnType<ExecFn>, Nullable>;
|
|
68
|
+
exec<ExecFn extends (this: Srvs, ...args: [...ServerArgs, ...InternalArgs]) => ReqType extends "pubsub" ? Promise<void> | void : ReqType extends "prompt" ? PromiseOrObject<PromptResult> : PromiseOrObject<DocumentModel<FieldToValue<Returns>> | (Nullable extends true ? null | undefined : never)>>(execFn: ExecFn): EndpointInfo<ReqType, Srvs, ArgNames, Args, InternalArgs, ServerArgs, Returns, FieldToValue<Returns>, ReturnType<ExecFn>, Nullable>;
|
|
56
69
|
getPath(key: string): string;
|
|
57
70
|
}
|
|
58
71
|
export type BuildEndpoint<SrvModule extends ServiceModel = ServiceModel> = {
|
|
@@ -60,6 +73,11 @@ export type BuildEndpoint<SrvModule extends ServiceModel = ServiceModel> = {
|
|
|
60
73
|
mutation: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"mutation", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
|
|
61
74
|
pubsub: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"pubsub", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
|
|
62
75
|
message: <Returns extends ConstantFieldTypeInput = ConstantFieldTypeInput, Nullable extends boolean = false>(returnRef: Returns, signalOption?: SignalOption<Returns, Nullable>) => EndpointInfo<"message", SrvMap<SrvModule>, [], [], [], [], Returns, never, never, Nullable>;
|
|
76
|
+
/**
|
|
77
|
+
* Declares an MCP prompt. It takes no return type because the return is always `PromptMessage[]`, and no
|
|
78
|
+
* `.body()` because `prompts/get` sends its arguments as a flat string map — see `param`.
|
|
79
|
+
*/
|
|
80
|
+
prompt: (signalOption?: SignalOption<typeof promptCarrier, false>) => EndpointInfo<"prompt", SrvMap<SrvModule>, [], [], [], [], typeof promptCarrier, never, never, false>;
|
|
63
81
|
};
|
|
64
82
|
export declare const buildEndpoint: BuildEndpoint<any>;
|
|
65
83
|
export type EndpointBuilder<SrvModule extends ServiceModel = ServiceModel> = (builder: BuildEndpoint<SrvModule>) => {
|
package/types/signal/guard.d.ts
CHANGED
|
@@ -3,8 +3,19 @@ import type { SignalContext } from "./signalContext.d.ts";
|
|
|
3
3
|
export interface Guard {
|
|
4
4
|
canPass(context: SignalContext): PromiseOrObject<boolean>;
|
|
5
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* What a guard needs in order to answer. `account` reads the caller and nothing else, so it can be evaluated
|
|
8
|
+
* with no arguments — which is what lets a catalogue hide what the caller certainly cannot use. `resource` needs
|
|
9
|
+
* the call's arguments and fails closed without them, so evaluating one early would erase legitimate entries.
|
|
10
|
+
*
|
|
11
|
+
* Required, with no default. Exposure is decided by a guard rather than by an opt-in, so an unmarked guard would
|
|
12
|
+
* silently take the `resource` path and list its endpoint to every caller — the whole guarded surface's names,
|
|
13
|
+
* refused only at call time. There is no safe guess here, so the author states it.
|
|
14
|
+
*/
|
|
15
|
+
export type GuardScope = "account" | "resource";
|
|
6
16
|
export type GuardCls<Name extends string = string> = Cls<Guard, {
|
|
7
17
|
readonly name: Name;
|
|
18
|
+
readonly scope: GuardScope;
|
|
8
19
|
}>;
|
|
9
20
|
/** Creates a named guard base class for signal access checks. */
|
|
10
21
|
export declare const guard: <T extends string>(name: T) => GuardCls<T>;
|
package/types/signal/guards.d.ts
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
|
-
import type { Guard } from "./guard.d.ts";
|
|
1
|
+
import type { Guard, GuardScope } from "./guard.d.ts";
|
|
2
2
|
import type { SignalContext } from "./signalContext.d.ts";
|
|
3
3
|
export declare class Public implements Guard {
|
|
4
4
|
static name: string;
|
|
5
|
+
static scope: GuardScope;
|
|
5
6
|
canPass(context: SignalContext): boolean;
|
|
6
7
|
}
|
|
7
8
|
export declare class None implements Guard {
|
|
8
9
|
static name: string;
|
|
10
|
+
static scope: GuardScope;
|
|
9
11
|
canPass(context: SignalContext): boolean;
|
|
10
12
|
}
|
|
13
|
+
export type AgentRelayPolicy = (context: SignalContext) => boolean | Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* Gate for the `runAgentTurn` relay. Every tool runs in the caller's own browser session, so the LLM key is the
|
|
16
|
+
* one thing this endpoint spends — ungated, any visitor can bill the app's provider through fetch alone.
|
|
17
|
+
*
|
|
18
|
+
* The framework has no account model to gate on, so with no policy registered it allows everyone — what `Public`
|
|
19
|
+
* said before, but with a seam: a product hardens it at boot, e.g.
|
|
20
|
+
* `AgentRelayAccess.use((context) => !!context.get("account"))`. The policy is the app's; the framework cannot know it.
|
|
21
|
+
*/
|
|
22
|
+
export declare class AgentRelayAccess implements Guard {
|
|
23
|
+
#private;
|
|
24
|
+
static name: string;
|
|
25
|
+
static scope: GuardScope;
|
|
26
|
+
static use(policy: AgentRelayPolicy | null): void;
|
|
27
|
+
static get hasPolicy(): boolean;
|
|
28
|
+
/** Runs at boot, after the app entry has evaluated — a module-scope check would fire before `use()` could. */
|
|
29
|
+
static warnIfOpen(): void;
|
|
30
|
+
canPass(context: SignalContext): Promise<boolean>;
|
|
31
|
+
}
|
package/types/signal/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export * from "./agent.d.ts";
|
|
2
|
+
export * from "./agent.signal";
|
|
3
|
+
export * from "./agentTurn.d.ts";
|
|
4
|
+
export * from "./agentTurnStream.d.ts";
|
|
1
5
|
export * from "./base.signal";
|
|
2
6
|
export * from "./endpoint.d.ts";
|
|
3
7
|
export * from "./endpointInfo.d.ts";
|
|
@@ -8,8 +12,10 @@ export * from "./intercept.d.ts";
|
|
|
8
12
|
export * from "./internal.d.ts";
|
|
9
13
|
export * from "./internalArg.d.ts";
|
|
10
14
|
export * from "./internalInfo.d.ts";
|
|
15
|
+
export * from "./mcp.d.ts";
|
|
11
16
|
export * from "./middleware.d.ts";
|
|
12
17
|
export * from "./openapi.d.ts";
|
|
18
|
+
export * from "./schema.d.ts";
|
|
13
19
|
export * from "./serializer.d.ts";
|
|
14
20
|
export * from "./serverSignal.d.ts";
|
|
15
21
|
export * from "./signalContext.d.ts";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type AgentRefusal, type AgentUndescribed } from "../agent.d.ts";
|
|
2
|
+
import type { SerializedEndpoint, SerializedSignal } from "../types.d.ts";
|
|
3
|
+
import type { McpPrompt, McpResource, McpResourceTemplate, McpTool } from "./mcpProtocol.d.ts";
|
|
4
|
+
export interface McpDocumentOptions {
|
|
5
|
+
resolveDescription?: (key: string) => string | undefined;
|
|
6
|
+
excludeSignals?: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Drops every mutation from the catalogue regardless of what it opted into. Off by default: the endpoint's own
|
|
9
|
+
* an endpoint's guards are the decision, and a second switch that silently unlists a published endpoint gives
|
|
10
|
+
* its author no way to see why. This is the read-only-deployment valve.
|
|
11
|
+
*/
|
|
12
|
+
readOnly?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface McpExposedEndpoint {
|
|
15
|
+
refName: string;
|
|
16
|
+
key: string;
|
|
17
|
+
endpoint: SerializedEndpoint;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A candidate this catalogue did not publish. The bookkeeping is audience-independent and lives on
|
|
21
|
+
* `AgentCatalogue`; these are the MCP names for it.
|
|
22
|
+
*/
|
|
23
|
+
export type McpRefusal = AgentRefusal;
|
|
24
|
+
export type McpUndescribed = AgentUndescribed;
|
|
25
|
+
/**
|
|
26
|
+
* Turns the serialized signal registry into the three MCP catalogues and answers the lookups `tools/call` and
|
|
27
|
+
* `resources/read` need. Pure: no IO and no DI — the sibling of `createOpenApiDocument`.
|
|
28
|
+
*/
|
|
29
|
+
export declare class McpDocument {
|
|
30
|
+
#private;
|
|
31
|
+
/**
|
|
32
|
+
* An array cannot be `structuredContent` — the spec types it as an object — so a list result is wrapped under
|
|
33
|
+
* this key and `outputSchema` is shaped to match. Both halves must agree, which is why they live together.
|
|
34
|
+
*/
|
|
35
|
+
static readonly listKey = "items";
|
|
36
|
+
readonly tools: McpTool[];
|
|
37
|
+
readonly prompts: McpPrompt[];
|
|
38
|
+
readonly resourceTemplates: McpResourceTemplate[];
|
|
39
|
+
/** Every readable thing is addressed by a template, so there are no fixed resources to enumerate. */
|
|
40
|
+
readonly resources: McpResource[];
|
|
41
|
+
/**
|
|
42
|
+
* Every candidate that was not published, with the sentence saying why — the rejections are fail-closed by
|
|
43
|
+
* design, and an author whose endpoint is missing otherwise has nowhere to look but the framework source.
|
|
44
|
+
*/
|
|
45
|
+
readonly refusals: McpRefusal[];
|
|
46
|
+
/** What is published with no description of its own, which is the field a model picks a tool by. */
|
|
47
|
+
readonly undescribed: McpUndescribed[];
|
|
48
|
+
constructor(serializedSignal: Record<string, SerializedSignal>, options?: McpDocumentOptions);
|
|
49
|
+
findTool(name: string): McpExposedEndpoint | undefined;
|
|
50
|
+
/** Returns the catalogue entry alongside the endpoint: `prompts/get` validates against the published one. */
|
|
51
|
+
findPrompt(name: string): {
|
|
52
|
+
exposed: McpExposedEndpoint;
|
|
53
|
+
prompt: McpPrompt;
|
|
54
|
+
} | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Resolves a URI only when the endpoint behind it was published as a template. An endpoint that was never
|
|
57
|
+
* advertised has to fail here rather than fall through to its guards: opting out of MCP means keeping a thing
|
|
58
|
+
* off the wire entirely, not merely making it refuse.
|
|
59
|
+
*/
|
|
60
|
+
resolveResource(uri: string): {
|
|
61
|
+
exposed: McpExposedEndpoint;
|
|
62
|
+
args: Record<string, string | string[]>;
|
|
63
|
+
} | null;
|
|
64
|
+
static structuredContent(endpoint: SerializedEndpoint, value: unknown): {} | undefined;
|
|
65
|
+
}
|