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,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serializes what the page is rendering into compact text an agent can answer questions from: headings keep their
|
|
3
|
+
* level, links keep their href, controls keep their value and `data-akan-*` annotation. The agent's own UI is
|
|
4
|
+
* marked `data-agent-ui` and skipped, so a turn never re-reads its own transcript, and a password value is never
|
|
5
|
+
* read — the screen shows dots, so the DOM holds more than the user sees.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ScreenReader {
|
|
8
|
+
#private;
|
|
9
|
+
static readonly limit = 8000;
|
|
10
|
+
static read(root?: HTMLElement | null): string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AgentRefusal, SerializedSignal } from "akanjs/signal";
|
|
2
|
+
import type { StoreInstance } from "../storeInstance.d.ts";
|
|
3
|
+
import { AgentVisibility } from "./AgentVisibility.d.ts";
|
|
4
|
+
import type { SerializedStore } from "./types.d.ts";
|
|
5
|
+
/**
|
|
6
|
+
* What one built store offers an agent, derived from the store the browser is already running.
|
|
7
|
+
*
|
|
8
|
+
* The store is the audience-neutral half of the client surface the way a signal registry is the server's: a key on
|
|
9
|
+
* `st.do` is the same call the user's own click makes, so an agent that drives it cannot reach past what the UI
|
|
10
|
+
* already permits. That is why the default here is the opposite of the MCP catalogue's — every key is published
|
|
11
|
+
* unless something about it cannot be described, and each of those is recorded as a refusal rather than dropped.
|
|
12
|
+
*
|
|
13
|
+
* This is the visible universe, not the live view: a store's own `static agent` declaration is honored here, and
|
|
14
|
+
* the bridge narrows the result to the stores the rendered screen is reading when it answers.
|
|
15
|
+
*
|
|
16
|
+
* Nothing is re-declared. An action's arguments come from the endpoint it is named after, from the field metadata
|
|
17
|
+
* the form setter was generated from, or from the role the store recorded while building the slice; a key that
|
|
18
|
+
* matches none of those three is published only when it takes no arguments at all.
|
|
19
|
+
*/
|
|
20
|
+
export declare class StoreCatalogue {
|
|
21
|
+
#private;
|
|
22
|
+
readonly store: SerializedStore;
|
|
23
|
+
readonly refusals: AgentRefusal[];
|
|
24
|
+
readonly visibility: AgentVisibility;
|
|
25
|
+
constructor(instance: StoreInstance, serializedSignal: Record<string, SerializedSignal>);
|
|
26
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SurfaceSource, ToolEntry } from "../../vendor/use-agentic.d.ts";
|
|
2
|
+
import { AgentBridge } from "./AgentBridge.d.ts";
|
|
3
|
+
/**
|
|
4
|
+
* The store bridge as one surface source: every catalogued action of the stores the rendered screen is reading is
|
|
5
|
+
* a callable tool, executed through `AgentBridge.call` so argument checking, masking, and the transcript stay in
|
|
6
|
+
* one place. Recomputed per snapshot — the bridge's live view changes as components mount and unmount — and
|
|
7
|
+
* per zone view: a zone session sees the stores its own subtree subscribes, and its `readScreen` reads its own
|
|
8
|
+
* `data-agent-zone` container rather than the whole document.
|
|
9
|
+
*
|
|
10
|
+
* `remove*` keys default to a confirm gate — destructiveness derived from the key, the way the MCP hints derive
|
|
11
|
+
* theirs — and a page can still shadow any entry with its own hook registration.
|
|
12
|
+
*/
|
|
13
|
+
export declare class StoreSurfaceSource implements SurfaceSource {
|
|
14
|
+
#private;
|
|
15
|
+
/** Lazy by default: `AgentBridge.of()` walks the whole store, so it waits for the first enumeration. */
|
|
16
|
+
constructor(bridge?: AgentBridge);
|
|
17
|
+
tools: (view?: string[]) => ToolEntry[];
|
|
18
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./AgentBridge.d.ts";
|
|
2
|
+
export * from "./AgentContext.d.ts";
|
|
3
|
+
export * from "./AgentPrompts.d.ts";
|
|
4
|
+
export * from "./AgentVisibility.d.ts";
|
|
5
|
+
export * from "./ScreenReader.d.ts";
|
|
6
|
+
export * from "./StoreCatalogue.d.ts";
|
|
7
|
+
export * from "./StoreSurfaceSource.d.ts";
|
|
8
|
+
export * from "./storeSurface.d.ts";
|
|
9
|
+
export * from "./types.d.ts";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AgenticSurface } from "../../vendor/use-agentic.d.ts";
|
|
2
|
+
import { AgentBridge } from "./AgentBridge.d.ts";
|
|
3
|
+
import { StoreSurfaceSource } from "./StoreSurfaceSource.d.ts";
|
|
4
|
+
export interface StoreSurface {
|
|
5
|
+
bridge: AgentBridge;
|
|
6
|
+
source: StoreSurfaceSource;
|
|
7
|
+
surface: AgenticSurface;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Attaches the app's store catalogue to the shared surface, once per runtime, lazily — nothing pays for the
|
|
11
|
+
* bridge walk until something agent-facing (the dock, a chat) actually asks. On the server it builds but does not
|
|
12
|
+
* attach: a server-global surface would be shared across requests, and no session assembles context there.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ensureStoreSurface: () => StoreSurface;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { SerializedArg } from "akanjs/signal";
|
|
2
|
+
import type { SliceActionKey } from "../sliceRole.d.ts";
|
|
3
|
+
import type { SliceStateKey } from "../state.d.ts";
|
|
4
|
+
/** Which generated form-setter a store key is, when it is one. */
|
|
5
|
+
export type FormSetterRole = "set" | "add" | "sub" | "addOrSub";
|
|
6
|
+
/** What calling a store action reaches. `state` never leaves the browser. */
|
|
7
|
+
export type StoreActionEffect = "state" | "query" | "mutation";
|
|
8
|
+
export interface SerializedStoreAction {
|
|
9
|
+
args: SerializedArg[];
|
|
10
|
+
effect: StoreActionEffect;
|
|
11
|
+
/** The model this key belongs to, when the key identifies one. */
|
|
12
|
+
refName?: string;
|
|
13
|
+
/** The endpoint whose arguments it borrows, when it is named after one. */
|
|
14
|
+
endpoint?: string;
|
|
15
|
+
/** The generated role, absent on an action a module wrote itself. */
|
|
16
|
+
role?: SliceActionKey | FormSetterRole;
|
|
17
|
+
/** The model field it writes, on a form setter. */
|
|
18
|
+
field?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface SerializedStoreState {
|
|
21
|
+
/**
|
|
22
|
+
* What the live value is. A store declares no types — `STATE_META` holds initial values — so this is read off the
|
|
23
|
+
* value the store is holding, and a key initialized to `null` or `[]` says nothing about what may go into it.
|
|
24
|
+
*/
|
|
25
|
+
type: "string" | "number" | "boolean" | "date" | "list" | "map" | "object" | "unknown";
|
|
26
|
+
/** The model this key holds, when it holds one. What a read of it is masked by. */
|
|
27
|
+
refName?: string;
|
|
28
|
+
/** Which of the model's five classes, which is what decides the fields a read may carry. */
|
|
29
|
+
modelType?: "input" | "full" | "light" | "insight";
|
|
30
|
+
/** Materialized from a computation, the URL, or storage. Writing one throws, so it is read-only by construction. */
|
|
31
|
+
derived: boolean;
|
|
32
|
+
role?: SliceStateKey;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* One store instance described for an agent: every key it can read and every action it may call.
|
|
36
|
+
*
|
|
37
|
+
* Flat rather than grouped by model, because that is what the store is — `st.use.x` and `st.do.y` are one namespace,
|
|
38
|
+
* so a key means the same thing to every reader and two models cannot both claim one. It is the store's answer to
|
|
39
|
+
* `SerializedSignal`, and it is derived on the client from the built store rather than shipped from the server: the
|
|
40
|
+
* store classes are in the bundle already, and a second copy over the wire is a second thing to keep in step.
|
|
41
|
+
*/
|
|
42
|
+
export interface SerializedStore {
|
|
43
|
+
state: {
|
|
44
|
+
[key: string]: SerializedStoreState;
|
|
45
|
+
};
|
|
46
|
+
action: {
|
|
47
|
+
[key: string]: SerializedStoreAction;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./agent/index.d.ts";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type CLIENT_VALUE, type EnumInstance } from "akanjs/base";
|
|
2
|
+
import type { ParamFieldType } from "akanjs/constant";
|
|
3
|
+
import { type JsonSchema, type ToolConfirm, type ToolEffect, type ToolGuard } from "../../vendor/use-agentic.d.ts";
|
|
4
|
+
export interface StToolMeta {
|
|
5
|
+
desc?: string;
|
|
6
|
+
effect?: ToolEffect;
|
|
7
|
+
confirm?: ToolConfirm;
|
|
8
|
+
guard?: ToolGuard;
|
|
9
|
+
}
|
|
10
|
+
interface StToolArg {
|
|
11
|
+
name: string;
|
|
12
|
+
type: ParamFieldType;
|
|
13
|
+
optional: boolean;
|
|
14
|
+
}
|
|
15
|
+
type ArgValue<T> = T extends EnumInstance<string, infer V> ? V : T extends {
|
|
16
|
+
[CLIENT_VALUE]: infer V;
|
|
17
|
+
} ? V : never;
|
|
18
|
+
/**
|
|
19
|
+
* A component tool in the signal's vocabulary: `st.tool("x", { desc }).arg("id", ID).exec(fn)`.
|
|
20
|
+
*
|
|
21
|
+
* This is not A12's rejected store-action builder — a store action derives its schema from the endpoint it is
|
|
22
|
+
* named after, while a component tool exists nowhere else, so declaring is the only source there is. `.arg()` only
|
|
23
|
+
* accumulates data; `.exec()` is the one hook, so the chain must complete in one unconditional statement.
|
|
24
|
+
*/
|
|
25
|
+
export declare class StToolBuilder<Args extends unknown[] = []> {
|
|
26
|
+
#private;
|
|
27
|
+
constructor(name: string, meta?: StToolMeta, args?: StToolArg[]);
|
|
28
|
+
arg<T extends ParamFieldType>(name: string, type: T): StToolBuilder<[...Args, ArgValue<T>]>;
|
|
29
|
+
arg<T extends ParamFieldType>(name: string, type: T, option: {
|
|
30
|
+
optional: true;
|
|
31
|
+
}): StToolBuilder<[...Args, ArgValue<T> | null]>;
|
|
32
|
+
/** The only hook in the chain. `run`, `guard`, and `confirm` stay always-latest; the declaration is mount-static. */
|
|
33
|
+
exec(run: (...args: Args) => unknown): (...args: Args) => Promise<void>;
|
|
34
|
+
static parametersOf(args: StToolArg[]): JsonSchema | undefined;
|
|
35
|
+
/** Scalars and enums only — the value arrives as JSON from a model, so a class instance has no way in. */
|
|
36
|
+
static schemaOf(type: ParamFieldType): JsonSchema;
|
|
37
|
+
static positionalOf(toolName: string, args: StToolArg[], named: Record<string, unknown>): unknown[];
|
|
38
|
+
/** What `AgentBridge` does for endpoint arguments, for a component tool's own — nothing on the wire enforces the published schema. */
|
|
39
|
+
static checkedValue(toolName: string, argName: string, type: ParamFieldType, value: unknown): unknown;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
2
|
+
import { StToolBuilder, type StToolMeta } from "./StToolBuilder.d.ts";
|
|
3
|
+
import { type StExposeMeta } from "./useStExpose.d.ts";
|
|
4
|
+
import { type StStateMeta } from "./useStState.d.ts";
|
|
5
|
+
export interface StAgentic {
|
|
6
|
+
/** Local state the in-page agent can read. Writes need a `set` type and go through a named setter tool. */
|
|
7
|
+
useState: <T>(name: string, initial: T | (() => T), meta?: StStateMeta<T>) => [T, Dispatch<SetStateAction<T>>];
|
|
8
|
+
/** A read-only derived value the agent can read while the component is mounted. */
|
|
9
|
+
expose: (name: string, value: unknown, meta?: StExposeMeta) => void;
|
|
10
|
+
/** A component tool: `.arg("id", ID)` chained onto one `.exec()` hook. */
|
|
11
|
+
tool: (name: string, meta?: StToolMeta) => StToolBuilder;
|
|
12
|
+
}
|
|
13
|
+
/** Idempotent — `StoreRegistry.build` runs once per merged root, always onto the one instance. */
|
|
14
|
+
export declare const attachAgentic: <T extends object>(instance: T) => T & StAgentic;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type MaskModel } from "akanjs/constant";
|
|
2
|
+
/** What `AgentBridge.read` does for store keys, for a hook's value: mask by the declared model, pass scalars, refuse the rest. */
|
|
3
|
+
export declare const readableValue: (name: string, value: unknown, model?: MaskModel) => unknown;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MaskModel } from "akanjs/constant";
|
|
2
|
+
export interface StExposeMeta {
|
|
3
|
+
desc?: string;
|
|
4
|
+
mask?: MaskModel;
|
|
5
|
+
serialize?: (value: unknown) => unknown;
|
|
6
|
+
report?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const useStExpose: (name: string, value: unknown, meta?: StExposeMeta) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MaskModel, ParamFieldType } from "akanjs/constant";
|
|
2
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
3
|
+
export interface StStateMeta<T> {
|
|
4
|
+
desc?: string;
|
|
5
|
+
/** The model whose `hidden`/`secret` fields a read strips. An object value with no `mask` and no `serialize` is refused. */
|
|
6
|
+
mask?: MaskModel;
|
|
7
|
+
serialize?: (value: T) => unknown;
|
|
8
|
+
report?: boolean;
|
|
9
|
+
/** The scalar or enum an agent may write through the generated `set<Name>` tool. Read-only without it. */
|
|
10
|
+
set?: ParamFieldType;
|
|
11
|
+
}
|
|
12
|
+
export declare const useStState: <T>(name: string, initial: T | (() => T), meta?: StStateMeta<T>) => [T, Dispatch<SetStateAction<T>>];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./agentic/index.d.ts";
|
package/types/store/baseSt.d.ts
CHANGED
|
@@ -63,7 +63,14 @@ declare const BaseStore_base: import("./store.d.ts").StoreCls<"base", import("./
|
|
|
63
63
|
deviceToken: string;
|
|
64
64
|
currentPath: string;
|
|
65
65
|
}>, any, any, any, any, any, any, any, any>;
|
|
66
|
+
/**
|
|
67
|
+
* `agent: false` keeps the whole base store off the agent surface. Its keys are framework plumbing that other
|
|
68
|
+
* effects write into, so the generated setters are levers that do nothing (`setPath` does not navigate — the
|
|
69
|
+
* router overwrites it) — and `tryJwt`/`tryAccount` hold the caller's credential, which must never reach a model.
|
|
70
|
+
* The route context block carries the three keys an agent legitimately needs.
|
|
71
|
+
*/
|
|
66
72
|
export declare class BaseStore extends BaseStore_base {
|
|
73
|
+
static agent: false;
|
|
67
74
|
setDevMode(value: boolean): void;
|
|
68
75
|
setWindowSize(): void;
|
|
69
76
|
showMessage(message: {
|
|
@@ -131,7 +138,7 @@ declare const RootStore_base: import("./rootStore.d.ts").RootStoreCls<"root", im
|
|
|
131
138
|
}, any>;
|
|
132
139
|
export declare class RootStore extends RootStore_base {
|
|
133
140
|
}
|
|
134
|
-
export declare const st: {
|
|
141
|
+
export declare const st: import("./agentic.d.ts").StAgentic & {
|
|
135
142
|
sub: {
|
|
136
143
|
(listener: (state: import("./stateBuilder.d.ts").WritableStateOf<{
|
|
137
144
|
csrLoaded: boolean;
|
|
@@ -267,37 +274,37 @@ export declare const st: {
|
|
|
267
274
|
currentPath: string;
|
|
268
275
|
}>) => U, equals?: ((a: U, b: U) => boolean) | undefined) => U;
|
|
269
276
|
use: {
|
|
270
|
-
csrLoaded: () => boolean;
|
|
271
|
-
path: () => string;
|
|
272
|
-
pathname: () => string;
|
|
273
|
-
params: () => {
|
|
277
|
+
csrLoaded: (options?: import("./types.d.ts").StoreUseOptions) => boolean;
|
|
278
|
+
path: (options?: import("./types.d.ts").StoreUseOptions) => string;
|
|
279
|
+
pathname: (options?: import("./types.d.ts").StoreUseOptions) => string;
|
|
280
|
+
params: (options?: import("./types.d.ts").StoreUseOptions) => {
|
|
274
281
|
[key: string]: string;
|
|
275
282
|
};
|
|
276
|
-
searchParams: () => BaseSearchParamsState;
|
|
277
|
-
theme: () => string;
|
|
278
|
-
innerWidth: () => number;
|
|
279
|
-
innerHeight: () => number;
|
|
280
|
-
responsive: () => "xl" | "lg" | "md" | "sm" | "xs";
|
|
281
|
-
uiOperation: () => "loading" | "idle" | "sleep";
|
|
282
|
-
messages: () => {
|
|
283
|
+
searchParams: (options?: import("./types.d.ts").StoreUseOptions) => BaseSearchParamsState;
|
|
284
|
+
theme: (options?: import("./types.d.ts").StoreUseOptions) => string;
|
|
285
|
+
innerWidth: (options?: import("./types.d.ts").StoreUseOptions) => number;
|
|
286
|
+
innerHeight: (options?: import("./types.d.ts").StoreUseOptions) => number;
|
|
287
|
+
responsive: (options?: import("./types.d.ts").StoreUseOptions) => "xl" | "lg" | "md" | "sm" | "xs";
|
|
288
|
+
uiOperation: (options?: import("./types.d.ts").StoreUseOptions) => "loading" | "idle" | "sleep";
|
|
289
|
+
messages: (options?: import("./types.d.ts").StoreUseOptions) => {
|
|
283
290
|
type: "info" | "success" | "error" | "warning" | "loading";
|
|
284
291
|
content: string;
|
|
285
292
|
duration: number;
|
|
286
293
|
key: string;
|
|
287
294
|
}[];
|
|
288
|
-
tryJwt: () => string | null;
|
|
289
|
-
trySignalType: () => SignalType;
|
|
290
|
-
tryRoles: () => string[];
|
|
291
|
-
tryAccount: () => Account<{
|
|
295
|
+
tryJwt: (options?: import("./types.d.ts").StoreUseOptions) => string | null;
|
|
296
|
+
trySignalType: (options?: import("./types.d.ts").StoreUseOptions) => SignalType;
|
|
297
|
+
tryRoles: (options?: import("./types.d.ts").StoreUseOptions) => string[];
|
|
298
|
+
tryAccount: (options?: import("./types.d.ts").StoreUseOptions) => Account<{
|
|
292
299
|
[key: string]: string | undefined;
|
|
293
300
|
}>;
|
|
294
|
-
keyboardHeight: () => number;
|
|
295
|
-
pageState: () => PageState;
|
|
296
|
-
devMode: () => boolean;
|
|
297
|
-
deviceToken: () => string;
|
|
298
|
-
currentPath: () => string;
|
|
301
|
+
keyboardHeight: (options?: import("./types.d.ts").StoreUseOptions) => number;
|
|
302
|
+
pageState: (options?: import("./types.d.ts").StoreUseOptions) => PageState;
|
|
303
|
+
devMode: (options?: import("./types.d.ts").StoreUseOptions) => boolean;
|
|
304
|
+
deviceToken: (options?: import("./types.d.ts").StoreUseOptions) => string;
|
|
305
|
+
currentPath: (options?: import("./types.d.ts").StoreUseOptions) => string;
|
|
299
306
|
};
|
|
300
|
-
do: RootStore & {
|
|
307
|
+
do: import("./types.d.ts").VoidActions<RootStore> & {
|
|
301
308
|
setCsrLoaded: (value: boolean) => void;
|
|
302
309
|
setPath: (value: string) => void;
|
|
303
310
|
setPathname: (value: string) => void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The state keys every model store holds, and which of the model's five classes each one is an instance of.
|
|
3
|
+
*
|
|
4
|
+
* Shared with the agent catalogue, which needs the class rather than the key: a value read out of the store is
|
|
5
|
+
* masked by the model it belongs to, and `immerify` drops the constructor, so the live value cannot say what it is.
|
|
6
|
+
* `modelForm` is the one that matters most — it is an `Input` holding whatever the user has typed, credentials
|
|
7
|
+
* included, and it reaches the catalogue as a plain object.
|
|
8
|
+
*/
|
|
9
|
+
export declare const databaseStateNames: (refName: string) => {
|
|
10
|
+
model: string;
|
|
11
|
+
modelLoading: string;
|
|
12
|
+
modelForm: string;
|
|
13
|
+
modelFormLoading: string;
|
|
14
|
+
modelSubmit: string;
|
|
15
|
+
modelViewAt: string;
|
|
16
|
+
modelModal: string;
|
|
17
|
+
modelOperation: string;
|
|
18
|
+
defaultModel: string;
|
|
19
|
+
};
|
|
20
|
+
/** Which of the model's classes each generated state key holds, for the keys that hold one at all. */
|
|
21
|
+
export declare const databaseStateModelTypes: {
|
|
22
|
+
readonly model: "full";
|
|
23
|
+
readonly modelForm: "input";
|
|
24
|
+
readonly defaultModel: "full";
|
|
25
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The keys `makeFormSetter` publishes for one field of one model.
|
|
3
|
+
*
|
|
4
|
+
* Shared with the agent catalogue, which has to answer what `setNameOnUser` takes without parsing the name apart —
|
|
5
|
+
* `set(.+)On(.+)` has more than one reading whenever a field or a model name contains `On`. Computing the same names
|
|
6
|
+
* forward from the same field metadata is unambiguous, and keeps the two from drifting when a name changes here.
|
|
7
|
+
*/
|
|
8
|
+
export declare const formSetterNames: (className: string, key: string) => {
|
|
9
|
+
field: string;
|
|
10
|
+
Field: string;
|
|
11
|
+
setFieldOnModel: string;
|
|
12
|
+
addFieldOnModel: string;
|
|
13
|
+
subFieldOnModel: string;
|
|
14
|
+
addOrSubFieldOnModel: string;
|
|
15
|
+
uploadFieldOnModel: string;
|
|
16
|
+
};
|
package/types/store/index.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
export * from "./action.d.ts";
|
|
2
|
+
export * from "./actionTag.d.ts";
|
|
3
|
+
export * from "./agent.d.ts";
|
|
4
|
+
export * from "./agentic.d.ts";
|
|
2
5
|
export * from "./baseSt.d.ts";
|
|
6
|
+
export * from "./databaseStateNames.d.ts";
|
|
7
|
+
export * from "./formSetterNames.d.ts";
|
|
3
8
|
export * from "./rootStore.d.ts";
|
|
9
|
+
export * from "./sliceRole.d.ts";
|
|
4
10
|
export * from "./state.d.ts";
|
|
5
11
|
export * from "./stateBuilder.d.ts";
|
|
6
12
|
export * from "./store.d.ts";
|
|
13
|
+
export { StoreInstance } from "./storeInstance.d.ts";
|
|
7
14
|
export * from "./storeRegistry.d.ts";
|
|
8
15
|
export * from "./types.d.ts";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { ACTION_META, Cls, STATE_DERIVED_META, STATE_INIT_META, STATE_META } from "akanjs/base";
|
|
1
|
+
import type { ACTION_META, ACTION_OWNER_META, Cls, STATE_DERIVED_META, STATE_INIT_META, STATE_META } from "akanjs/base";
|
|
2
2
|
import type { SerializedSlice } from "akanjs/signal";
|
|
3
|
+
import type { ActionOwner } from "./actionTag.d.ts";
|
|
3
4
|
import type { StateDerivedMeta, StateInitializerMap } from "./stateBuilder.d.ts";
|
|
4
5
|
import type { SetGetWritable } from "./types.d.ts";
|
|
5
6
|
export type RootStoreCls<RefName extends string = any, WritableState = any, Action = any, InternalSliceObj = any, SliceInfoObj = any, DerivedState = unknown, State = WritableState & DerivedState> = Cls<SetGetWritable<WritableState, State> & Action & {
|
|
@@ -13,6 +14,9 @@ export type RootStoreCls<RefName extends string = any, WritableState = any, Acti
|
|
|
13
14
|
[ACTION_META]: {
|
|
14
15
|
[key: string]: (...args: any[]) => any;
|
|
15
16
|
};
|
|
17
|
+
[ACTION_OWNER_META]: {
|
|
18
|
+
[key: string]: ActionOwner;
|
|
19
|
+
};
|
|
16
20
|
slice: {
|
|
17
21
|
[key: string]: {
|
|
18
22
|
[key: string]: SerializedSlice;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SerializedArg } from "akanjs/signal";
|
|
2
|
+
import type { SliceStateKey } from "./state.d.ts";
|
|
3
|
+
/** The generated slice actions, named by what they do rather than by the key any one slice publishes them under. */
|
|
4
|
+
export type SliceActionKey = "initModel" | "refreshModel" | "selectModel" | "setPageOfModel" | "addPageOfModel" | "setLimitOfModel" | "setQueryArgsOfModel" | "setSortOfModel";
|
|
5
|
+
/**
|
|
6
|
+
* What a generated key on `st.do` / `st.use` actually is.
|
|
7
|
+
*
|
|
8
|
+
* A slice publishes its keys with the model and the suffix spliced into the role name — `setPageOfUserInOrg` for the
|
|
9
|
+
* `setPageOfModel` role of `user`'s `inOrg` slice — and the splicing is string replacement over capitalized names.
|
|
10
|
+
* Recording the role while the key is being built is what saves a reader of the finished store from running that
|
|
11
|
+
* replacement backwards, which does not have one answer: on a model named `page`, `setPageOfPage` is both the
|
|
12
|
+
* paging action and a field setter.
|
|
13
|
+
*/
|
|
14
|
+
export interface SliceActionRole {
|
|
15
|
+
role: SliceActionKey;
|
|
16
|
+
refName: string;
|
|
17
|
+
sliceName: string;
|
|
18
|
+
/** The slice's own arguments, which the `initModel` and `setQueryArgsOfModel` roles take positionally. */
|
|
19
|
+
args: SerializedArg[];
|
|
20
|
+
}
|
|
21
|
+
export interface SliceStateRole {
|
|
22
|
+
role: SliceStateKey;
|
|
23
|
+
refName: string;
|
|
24
|
+
sliceName: string;
|
|
25
|
+
}
|
package/types/store/store.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ACTION_META, type Cls, type MergeAllActionTypes, type MergeAllKeyOfObjects, type SLICE_META, STATE_DERIVED_META, STATE_INIT_META, STATE_META } from "akanjs/base";
|
|
1
|
+
import { ACTION_META, ACTION_OWNER_META, type Cls, type MergeAllActionTypes, type MergeAllKeyOfObjects, type SLICE_META, STATE_DERIVED_META, STATE_INIT_META, STATE_META } from "akanjs/base";
|
|
2
2
|
import type { FilterInstance } from "akanjs/document";
|
|
3
3
|
import type { ClientSignal } from "akanjs/fetch";
|
|
4
4
|
import type { SerializedSlice, SlceCnstCapitalizedRefName, SlceCnstDefault, SlceCnstFull, SlceCnstInput, SlceCnstInsight, SlceCnstLight, SlceDbFilter, SlceDbSort, SliceCls } from "akanjs/signal";
|
|
5
5
|
import { type DefaultAction } from "./action.d.ts";
|
|
6
|
+
import type { ActionOwner } from "./actionTag.d.ts";
|
|
6
7
|
import { type DefaultState } from "./state.d.ts";
|
|
7
8
|
import { type DerivedStateBuilder, type DerivedStateOf, type StateDerivedMeta, type StateInitializerMap, type WritableStateBuilder, type WritableStateOf } from "./stateBuilder.d.ts";
|
|
8
|
-
import type { InternalSlice, SetGet, SetGetWritable, StoreSliceMap, StoreSliceName, StoreSliceSuffix } from "./types.d.ts";
|
|
9
|
+
import type { InternalSlice, SetGet, SetGetWritable, StoreAgentExposure, StoreSliceMap, StoreSliceName, StoreSliceSuffix } from "./types.d.ts";
|
|
9
10
|
type _SliceMap<S extends SliceCls> = StoreSliceMap<S>;
|
|
10
11
|
type _StoreInput<S extends SliceCls> = SlceCnstInput<S>;
|
|
11
12
|
type _StoreFull<S extends SliceCls> = SlceCnstFull<S>;
|
|
@@ -33,10 +34,14 @@ export type StoreCls<RefName extends string = string, WritableState = any, Actio
|
|
|
33
34
|
[ACTION_META]: {
|
|
34
35
|
[key: string]: (...args: any[]) => any;
|
|
35
36
|
};
|
|
37
|
+
[ACTION_OWNER_META]: {
|
|
38
|
+
[key: string]: ActionOwner;
|
|
39
|
+
};
|
|
36
40
|
slice: {
|
|
37
41
|
[key: string]: SerializedSlice;
|
|
38
42
|
};
|
|
39
43
|
_slice: SlceCls[typeof SLICE_META];
|
|
44
|
+
agent?: StoreAgentExposure;
|
|
40
45
|
}>;
|
|
41
46
|
export type ModelStore<Sig extends ClientSignal<any, any, any> | string, WritableState, Action, DerivedState = unknown> = Sig extends string ? StoreCls<Sig, WritableState, Action, any, DerivedState> : Sig extends ClientSignal<any, any, any> ? StoreCls<Sig["refName"], WritableState & DefaultState<Sig["_slice"]>, Action & DefaultAction<Sig["_slice"]>, Sig["_slice"], DerivedState> : never;
|
|
42
47
|
export type StoreReturn<Sig extends ClientSignal<any, any, any> | string, WritableState, LibStores extends StoreCls[], // TODO: Change Type for LibStores' state and action
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { RefObject } from "react";
|
|
2
|
+
import { type ActionOwner } from "./actionTag.d.ts";
|
|
2
3
|
import type { RootStoreCls } from "./rootStore.d.ts";
|
|
4
|
+
import type { SliceActionRole, SliceStateRole } from "./sliceRole.d.ts";
|
|
5
|
+
import type { StoreUseOptions } from "./types.d.ts";
|
|
3
6
|
type StoreStateRecord = Record<string, unknown>;
|
|
4
7
|
type StoreAction = (...args: unknown[]) => unknown;
|
|
5
8
|
export type ReactAPI = {
|
|
@@ -22,9 +25,11 @@ export declare class StoreInstance {
|
|
|
22
25
|
}): () => void;
|
|
23
26
|
};
|
|
24
27
|
sel: <U>(selector: (state: StoreStateRecord) => U, equals?: (a: U, b: U) => boolean) => U;
|
|
28
|
+
retainLive: (key: string, scopeKey?: string) => void;
|
|
29
|
+
releaseLive: (key: string, scopeKey?: string) => void;
|
|
25
30
|
ref: <U>(selector: (state: StoreStateRecord) => U) => RefObject<U>;
|
|
26
31
|
use: {
|
|
27
|
-
[key: string]: () => unknown;
|
|
32
|
+
[key: string]: (options?: StoreUseOptions) => unknown;
|
|
28
33
|
};
|
|
29
34
|
do: {
|
|
30
35
|
[key: string]: StoreAction;
|
|
@@ -32,6 +37,33 @@ export declare class StoreInstance {
|
|
|
32
37
|
slice: {
|
|
33
38
|
[key: string]: unknown;
|
|
34
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* How many mounted components are reading each state key right now. `st.use.*` is a hook, so subscription is
|
|
42
|
+
* presence — this is how an agent context knows which keys the screen is actually built from.
|
|
43
|
+
*/
|
|
44
|
+
get liveKeys(): ReadonlyMap<string, number>;
|
|
45
|
+
/**
|
|
46
|
+
* The live keys as one zone view sees them: retentions tagged at the view's scope or below. The empty view is the
|
|
47
|
+
* whole screen. Zones are views, not walls — a key read inside a zone counts for that zone and for the root alike.
|
|
48
|
+
*/
|
|
49
|
+
liveKeysIn(viewKey: string): ReadonlyMap<string, number>;
|
|
50
|
+
/** Which module declared each action. See `ActionOwner`. */
|
|
51
|
+
get actionOwners(): ReadonlyMap<string, ActionOwner>;
|
|
52
|
+
/**
|
|
53
|
+
* How many arguments each action declares.
|
|
54
|
+
*
|
|
55
|
+
* Recorded because `do[key]` is a rest-argument wrapper around the real method, so its own `length` is zero for
|
|
56
|
+
* everything — the arity is gone by the time anyone holding the instance could ask. A rest parameter on the method
|
|
57
|
+
* itself still reads as zero; nothing can recover that.
|
|
58
|
+
*/
|
|
59
|
+
get actionArity(): ReadonlyMap<string, number>;
|
|
60
|
+
/** What each generated slice key is, for a reader that has only the finished store. See `SliceActionRole`. */
|
|
61
|
+
get sliceActionRoles(): ReadonlyMap<string, SliceActionRole>;
|
|
62
|
+
get sliceStateRoles(): ReadonlyMap<string, SliceStateRole>;
|
|
63
|
+
/** Keys the store materializes from a computation, the URL, or storage. `set` throws on them. */
|
|
64
|
+
get derivedKeys(): ReadonlySet<string>;
|
|
65
|
+
/** The `set<Key>` conveniences `#extendAccessors` writes for every plain state key. Their value is untyped. */
|
|
66
|
+
get generatedSetters(): ReadonlySet<string>;
|
|
35
67
|
constructor(store?: RootStoreCls);
|
|
36
68
|
addStore(store: RootStoreCls): this;
|
|
37
69
|
}
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { type MergeAllKeyOfObjects, type MergeAllKeyOfTypes, type MergeAllTypes, STATE_META } from "akanjs/base";
|
|
2
2
|
import type { RootStoreCls } from "./rootStore.d.ts";
|
|
3
3
|
import type { StoreCls } from "./store.d.ts";
|
|
4
|
+
import { StoreInstance } from "./storeInstance.d.ts";
|
|
4
5
|
export type { ReactAPI } from "./storeInstance.d.ts";
|
|
5
6
|
import type { SetGet } from "./types.d.ts";
|
|
6
7
|
import type { WithSelectors } from "./withSelector.d.ts";
|
|
7
8
|
export declare class StoreRegistry {
|
|
8
9
|
#private;
|
|
10
|
+
/** The one store every `st.use` / `st.do` in the process goes through. What an agent bridge drives. */
|
|
11
|
+
static get instance(): StoreInstance;
|
|
9
12
|
static register<StrCls extends StoreCls>(store: StrCls): StrCls;
|
|
10
13
|
static get(refName: string): StoreCls | undefined;
|
|
14
|
+
/** Every registered module store by refName. What the agent surface derives key ownership and exposure from. */
|
|
15
|
+
static get stores(): ReadonlyMap<string, StoreCls>;
|
|
11
16
|
static merge<RefName extends string, StoreClses extends (StoreCls | RootStoreCls)[]>(refName: RefName, ...stores: StoreClses): RootStoreCls<RefName, MergeAllKeyOfObjects<StoreClses, typeof STATE_META>, MergeAllTypes<StoreClses, keyof SetGet | "slice">, MergeAllKeyOfTypes<StoreClses, "slice">, MergeAllKeyOfObjects<StoreClses, "_slice">>;
|
|
12
17
|
static build<RtStoreCls extends RootStoreCls>(store: RtStoreCls): WithSelectors<RtStoreCls>;
|
|
13
18
|
}
|
package/types/store/types.d.ts
CHANGED
|
@@ -9,6 +9,17 @@ export interface Submit {
|
|
|
9
9
|
loading: boolean;
|
|
10
10
|
times: number;
|
|
11
11
|
}
|
|
12
|
+
/** `agent: false` subscribes without joining the agent surface — the read stays out of the live-key derivation. */
|
|
13
|
+
export interface StoreUseOptions {
|
|
14
|
+
agent?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* A store class's own exposure declaration, read off `static agent`. `false` keeps the whole module off the agent
|
|
18
|
+
* surface; `exclude` withholds the named state keys and actions while the rest stay derived. Absent means exposed.
|
|
19
|
+
*/
|
|
20
|
+
export type StoreAgentExposure = false | {
|
|
21
|
+
exclude: string[];
|
|
22
|
+
};
|
|
12
23
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
13
24
|
type PickFunc<State, F extends keyof State = IsAny<State> extends true ? any : keyof State extends never ? any : keyof State> = (...fields: F[]) => {
|
|
14
25
|
[K in (typeof fields)[number]]: Exclude<State[K], null | undefined | "loading">;
|
|
@@ -30,6 +41,10 @@ export interface SetPick<State = any> {
|
|
|
30
41
|
export type Get<State, Actions> = {
|
|
31
42
|
get: () => State & Actions;
|
|
32
43
|
};
|
|
44
|
+
type VoidAction<T> = T extends (...args: infer Args) => infer Ret ? [Ret] extends [PromiseLike<unknown>] ? (...args: Args) => Promise<void> : (...args: Args) => void : T;
|
|
45
|
+
export type VoidActions<Action> = {
|
|
46
|
+
[K in keyof Action]: VoidAction<Action[K]>;
|
|
47
|
+
};
|
|
33
48
|
export type StoreSliceMap<SlceCls extends SliceCls> = SlceCls[typeof SLICE_META];
|
|
34
49
|
export type StoreSliceSuffix<SlceCls extends SliceCls, Suffix extends keyof StoreSliceMap<SlceCls>> = Suffix & string;
|
|
35
50
|
export type StoreSliceSuffixCap<SlceCls extends SliceCls, Suffix extends keyof StoreSliceMap<SlceCls>> = Capitalize<StoreSliceSuffix<SlceCls, Suffix>>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { Prettify } from "akanjs/base";
|
|
2
2
|
import type { FieldState } from "akanjs/constant";
|
|
3
3
|
import type { RefObject } from "react";
|
|
4
|
+
import type { StAgentic } from "./agentic.d.ts";
|
|
4
5
|
import type { RootStoreCls } from "./rootStore.d.ts";
|
|
5
|
-
import type { SliceStateAction } from "./types.d.ts";
|
|
6
|
+
import type { SliceStateAction, StoreUseOptions, VoidActions } from "./types.d.ts";
|
|
6
7
|
type SetKey<Key extends string> = `set${Capitalize<Key>}`;
|
|
7
8
|
export type WithSelectors<RtStoreCls extends RootStoreCls> = RtStoreCls extends RootStoreCls<any, infer WritableState, infer Action, infer InternalSliceObj, any, any, infer State> ? WithSelectorsOf<State, WritableState, Action, InternalSliceObj> : never;
|
|
8
|
-
type WithSelectorsOf<State, WritableState, Action, InternalSliceObj> = {
|
|
9
|
+
type WithSelectorsOf<State, WritableState, Action, InternalSliceObj> = StAgentic & {
|
|
9
10
|
sub: {
|
|
10
11
|
(listener: (state: State, prev: State) => void): () => void;
|
|
11
12
|
<U>(selector: (state: State) => U, listener: (state: U, prev: U) => void, options?: {
|
|
@@ -16,9 +17,9 @@ type WithSelectorsOf<State, WritableState, Action, InternalSliceObj> = {
|
|
|
16
17
|
ref: <U>(selector: (state: State) => U) => RefObject<U>;
|
|
17
18
|
sel: <U>(selector: (state: State) => U, equals?: (a: U, b: U) => boolean) => U;
|
|
18
19
|
use: {
|
|
19
|
-
[K in keyof State]: () => State[K];
|
|
20
|
+
[K in keyof State]: (options?: StoreUseOptions) => State[K];
|
|
20
21
|
};
|
|
21
|
-
do: Action & {
|
|
22
|
+
do: VoidActions<Action> & {
|
|
22
23
|
[K in keyof WritableState as K extends string ? SetKey<K> : never]: (value: FieldState<WritableState[K]>) => void;
|
|
23
24
|
};
|
|
24
25
|
get: () => State;
|
|
@@ -30,11 +31,9 @@ type WithSelectorsOf<State, WritableState, Action, InternalSliceObj> = {
|
|
|
30
31
|
export interface SliceSelectors<RefName extends string, State, Action> {
|
|
31
32
|
refName: RefName;
|
|
32
33
|
use: {
|
|
33
|
-
[K in keyof State]: () => State[K];
|
|
34
|
+
[K in keyof State]: (options?: StoreUseOptions) => State[K];
|
|
34
35
|
};
|
|
35
|
-
do: Prettify<{
|
|
36
|
-
[K in keyof Action]: Action[K];
|
|
37
|
-
} & {
|
|
36
|
+
do: Prettify<VoidActions<Action> & {
|
|
38
37
|
[K in keyof State as K extends string ? SetKey<K> : never]: (value: FieldState<State[K]>) => void;
|
|
39
38
|
}>;
|
|
40
39
|
get: () => State;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PendingApproval } from "../../vendor/use-agentic.d.ts";
|
|
2
|
+
interface ApprovalProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
approval: PendingApproval;
|
|
5
|
+
}
|
|
6
|
+
export default function Approval({ className, approval }: ApprovalProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ChatMessage, ToolCallResult } from "../../vendor/use-agentic.d.ts";
|
|
2
|
+
interface BubbleProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
message: ChatMessage;
|
|
5
|
+
/**
|
|
6
|
+
* Results by call id, gathered across the transcript. A call and its result are two wire messages — the model
|
|
7
|
+
* needs both — but they are one thing that happened, so the call's own row resolves in place instead of the
|
|
8
|
+
* name appearing again as a second row.
|
|
9
|
+
*/
|
|
10
|
+
results?: ReadonlyMap<string, ToolCallResult>;
|
|
11
|
+
}
|
|
12
|
+
export default function Bubble({ className, message, results }: BubbleProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|