akanjs 3.0.0-alpha.8 → 3.0.0-alpha.80
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/CHANGELOG.md +103 -0
- package/README.ko.md +1 -1
- package/README.md +1 -1
- package/base/baseEnv.ts +7 -4
- package/base/primitiveRegistry.ts +59 -12
- package/base/symbols.ts +4 -0
- package/client/capacitor.ts +34 -0
- package/client/clientRuntime.ts +5 -0
- package/client/cookie.ts +21 -34
- package/client/csrTypes.ts +4 -15
- package/client/frameConfig.ts +13 -0
- package/client/index.ts +1 -0
- package/client/locale.ts +2 -2
- package/client/router.ts +7 -7
- package/client/sharedContext.ts +31 -0
- package/client/translator.ts +2 -2
- package/client/types.ts +3 -3
- package/common/Logger.ts +287 -67
- package/common/TrustedProxy.ts +134 -0
- package/common/clamp.ts +2 -0
- package/common/clientAddress.ts +40 -0
- package/common/deepObjectify.ts +3 -2
- package/common/dynamicRecord.ts +12 -0
- package/common/index.ts +47 -2
- package/common/isValidDate.ts +1 -1
- package/common/logContext.ts +27 -0
- package/common/mcpExposure.ts +114 -0
- package/common/pathGetLoose.ts +31 -0
- package/common/plainFieldsOf.ts +13 -0
- package/common/requestOrigin.ts +32 -0
- package/common/{httpClient.ts → restClient.ts} +16 -9
- package/common/routeConvention.ts +22 -12
- package/common/websocketBinaryFrame.ts +46 -0
- package/constant/crystalize.ts +92 -28
- package/constant/dateSlot.ts +62 -0
- package/constant/deserialize.ts +3 -2
- package/constant/fieldInfo.ts +43 -3
- package/constant/fieldQueryMeta.ts +35 -0
- package/constant/getDefault.ts +16 -11
- package/constant/hydrationPlan.ts +72 -0
- package/constant/immerify.ts +4 -6
- package/constant/index.ts +5 -0
- package/constant/labelOf.ts +26 -0
- package/constant/mask.ts +67 -0
- package/constant/purify.ts +17 -11
- package/constant/textFieldPaths.ts +13 -7
- package/constant/types.ts +41 -13
- package/constant/via.ts +24 -17
- 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 +85 -0
- package/dictionary/dictInfo.ts +11 -2
- package/dictionary/dictionary.ts +9 -3
- package/dictionary/index.ts +1 -0
- package/dictionary/trans.ts +26 -7
- package/document/dataLoader.ts +0 -4
- package/document/documentQuery.ts +1 -0
- package/document/filterMeta.ts +79 -14
- package/document/index.ts +1 -0
- package/document/loaderInfo.ts +4 -1
- package/document/noDocumentError.ts +12 -0
- package/document/types.ts +0 -1
- package/fetch/agentTurn.ts +19 -0
- package/fetch/client/fetchClient.ts +166 -89
- package/fetch/client/fetchHandle.ts +57 -0
- package/fetch/client/httpClient.ts +140 -30
- package/fetch/client/sliceInitHandle.ts +101 -0
- package/fetch/client/wsClient.ts +27 -12
- package/fetch/fetchType/appliedReturn.type.ts +126 -42
- package/fetch/fetchType/endpointFetch.type.ts +17 -8
- package/fetch/fetchType/sliceFetch.type.ts +30 -53
- package/fetch/index.ts +1 -0
- package/fetch/requestStorage.ts +19 -5
- package/index.ts +132 -8
- package/local/apps/akan/akan-local.db +0 -0
- package/local/apps/akan/akan-local.db-shm +0 -0
- package/local/apps/akan/akan-local.db-wal +0 -0
- package/local/apps/akan/akan-local_solid.db +0 -0
- package/local/apps/akan/akan-local_solid.db-shm +0 -0
- package/local/apps/akan/akan-local_solid.db-wal +0 -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 +27 -18
- package/server/akanApp.ts +325 -157
- package/server/akanAppHeaders.ts +23 -3
- package/server/akanOption.ts +76 -8
- package/server/akanServer.ts +390 -32
- package/server/animatedImage.ts +83 -0
- package/server/assetEncoding.ts +4 -24
- package/server/binaryPubsub.ts +55 -0
- package/server/cachePolicy.ts +2 -11
- package/server/console.ts +110 -101
- package/server/consoleEvaluator.ts +51 -0
- package/server/consolePasteFilter.ts +91 -0
- package/server/consoleSession.ts +242 -0
- package/server/contentEncoding.ts +83 -0
- package/server/decorators.ts +12 -3
- package/server/devtools/constantSerializer.ts +8 -1
- package/server/devtools/signalSerializer.ts +2 -2
- package/server/devtools/types.ts +4 -4
- package/server/di/diLifecycle.ts +144 -14
- package/server/di/predefinedAdaptor.ts +6 -0
- package/server/di/resolveHierarchy.ts +3 -3
- package/server/di/utils.ts +40 -0
- package/server/hmr/clientScript.ts +1 -1
- package/server/imageOptimizer.ts +156 -74
- package/server/lifecycle/runtimeDir.ts +14 -0
- package/server/lifecycle/shutdownManager.ts +17 -2
- package/server/logging/childOutputReader.ts +137 -0
- package/server/logging/hubFileSink.ts +39 -0
- package/server/logging/logControlSocket.ts +173 -0
- package/server/logging/logForwarder.ts +131 -0
- package/server/logging/logHub.ts +0 -0
- package/server/logging/logQuery.ts +130 -0
- package/server/logging/logStdoutWriter.ts +39 -0
- package/server/logging/logStreamRoute.ts +87 -0
- package/server/logging/logTailClient.ts +161 -0
- package/server/mcp/McpAuth.ts +177 -0
- package/server/mcp/McpDispatcher.ts +295 -0
- package/server/mcp/McpEventStream.ts +24 -0
- package/server/mcp/McpExecutionContext.ts +105 -0
- package/server/mcp/McpRouter.ts +621 -0
- package/server/mcp/index.ts +5 -0
- package/server/processMetricsCollector.ts +1 -1
- package/server/resolver/database.resolver.ts +18 -12
- package/server/resolver/signal.resolver.ts +211 -89
- package/server/routeTreeBuilder.ts +11 -23
- package/server/routing/apiRouter.ts +45 -16
- package/server/routing/appWsData.ts +30 -5
- package/server/routing/eventStream.ts +93 -0
- package/server/routing/soloAppRoutes.ts +50 -0
- package/server/rscWorker.tsx +63 -22
- package/server/rscWorkerHost.ts +59 -8
- package/server/semaphore.ts +22 -0
- package/server/ssrFromRscRenderer.tsx +50 -0
- package/server/staticPath.ts +34 -0
- package/server/subRouteIndexDocument.tsx +61 -0
- package/server/systemPageDocument.tsx +3 -3
- package/server/systemPages.tsx +49 -16
- package/server/types.tsx +28 -0
- package/server/vendor/akanjs-fetch.ts +1 -0
- package/server/webRouter.ts +130 -73
- package/service/adapt.ts +5 -9
- package/service/agent.service.ts +81 -0
- package/service/base.service.ts +2 -1
- package/service/index.ts +1 -0
- package/service/injectInfo.ts +8 -3
- package/service/ipcTypes.ts +6 -0
- package/service/predefinedAdaptor/cache.adaptor.ts +8 -4
- package/service/predefinedAdaptor/compress.adaptor.ts +5 -1
- package/service/predefinedAdaptor/database.adaptor.ts +59 -1757
- package/service/predefinedAdaptor/deepseekLlm.ts +271 -0
- package/service/predefinedAdaptor/index.ts +3 -0
- package/service/predefinedAdaptor/insightQuery.ts +183 -0
- package/service/predefinedAdaptor/llm.adaptor.ts +115 -0
- package/service/predefinedAdaptor/logging.adaptor.ts +1 -1
- package/service/predefinedAdaptor/queue.adaptor.ts +5 -2
- package/service/predefinedAdaptor/role.adaptor.ts +2 -0
- package/service/predefinedAdaptor/schedule.adaptor.ts +12 -5
- package/service/predefinedAdaptor/solidPubsub.adaptor.ts +10 -6
- package/service/predefinedAdaptor/solidQueue.adaptor.ts +6 -2
- package/service/predefinedAdaptor/solidSqlite.ts +11 -9
- package/service/predefinedAdaptor/sql/PendingStoreEnsures.ts +22 -0
- package/service/predefinedAdaptor/sql/QueryCompiler.ts +225 -0
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +812 -0
- package/service/predefinedAdaptor/sql/UpdateCompiler.ts +67 -0
- package/service/predefinedAdaptor/sql/dialect/postgres.ts +151 -0
- package/service/predefinedAdaptor/sql/dialect/sqlite.ts +134 -0
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +29 -0
- package/service/predefinedAdaptor/sql/driver/libsql.ts +37 -0
- package/service/predefinedAdaptor/sql/driver/postgres.ts +42 -0
- package/service/predefinedAdaptor/sql/types.ts +251 -0
- package/service/predefinedAdaptor/sql/values.ts +91 -0
- package/service/predefinedAdaptor/websocket.adaptor.ts +6 -1
- package/service/serve.ts +16 -9
- package/service/toolNames.ts +119 -0
- package/signal/CrossSiteGuard.ts +71 -0
- package/signal/SignalFailure.ts +51 -0
- package/signal/agent/AgentCatalogue.ts +165 -0
- package/signal/agent/index.ts +1 -0
- package/signal/agent.signal.ts +38 -0
- package/signal/agentTurn.ts +8 -0
- package/signal/agentTurnStream.ts +60 -0
- package/signal/base.signal.ts +2 -1
- package/signal/endpoint.ts +2 -2
- package/signal/endpointInfo.ts +38 -2
- package/signal/exception.ts +43 -6
- package/signal/guard.ts +28 -1
- package/signal/guards.ts +49 -1
- package/signal/index.ts +8 -0
- package/signal/intercept.ts +9 -6
- package/signal/internal.ts +10 -2
- package/signal/internalArg.ts +21 -4
- package/signal/mcp/McpDocument.ts +326 -0
- package/signal/mcp/McpProgress.ts +106 -0
- package/signal/mcp/McpUriTemplate.ts +80 -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 +3 -3
- package/signal/openapi/openapi.ts +36 -173
- package/signal/schema/JsonSchemaBuilder.ts +221 -0
- package/signal/schema/index.ts +1 -0
- package/signal/serializer/fetch.serializer.ts +62 -1
- package/signal/signalContext.ts +339 -94
- package/signal/slice.ts +63 -28
- package/signal/trace.ts +268 -9
- package/signal/types.ts +55 -4
- package/store/SliceRequest.ts +23 -0
- package/store/action.ts +210 -154
- package/store/actionTag.ts +33 -0
- package/store/agent/AgentBridge.ts +89 -0
- package/store/agent/AgentContext.ts +71 -0
- package/store/agent/AgentPrompts.ts +111 -0
- package/store/agent/ScreenReader.ts +349 -0
- package/store/agent/ScreenSettle.ts +45 -0
- package/store/agent/ScreenTarget.ts +135 -0
- package/store/agent/StoreCatalogue.ts +116 -0
- package/store/agent/StoreSurfaceSource.ts +225 -0
- package/store/agent/index.ts +13 -0
- package/store/agent/storeSurface.ts +28 -0
- package/store/agent/types.ts +16 -0
- package/store/agentic/AgentValue.ts +119 -0
- package/store/agentic/StExposeBuilder.ts +50 -0
- package/store/agentic/StExposeDraft.ts +24 -0
- package/store/agentic/StStateBuilder.ts +90 -0
- package/store/agentic/StStateDraft.ts +23 -0
- package/store/agentic/StToolBuilder.ts +293 -0
- package/store/agentic/StToolDraft.ts +22 -0
- package/store/agentic/attachAgentic.ts +33 -0
- package/store/agentic/formFields.ts +194 -0
- package/store/agentic/index.ts +12 -0
- package/store/agentic/useFieldTool.ts +183 -0
- package/store/agentic/useFormTools.ts +77 -0
- package/store/agentic/useRelationFieldTool.ts +113 -0
- package/store/baseSt.ts +1 -1
- package/store/databaseStateNames.ts +31 -0
- package/store/formSetterNames.ts +35 -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 +10 -1
- package/store/storeInstance.ts +185 -22
- package/store/storeRegistry.ts +40 -2
- package/store/types.ts +5 -0
- package/store/withSelector.ts +5 -4
- package/test/index.ts +1 -1
- package/test/registerDom.ts +4 -0
- package/test/sampleOf.ts +2 -0
- package/test/signalTestRuntime.ts +5 -5
- package/test/testServer.ts +14 -11
- package/types/base/baseEnv.d.ts +1 -1
- package/types/base/primitiveRegistry.d.ts +20 -8
- package/types/base/symbols.d.ts +4 -0
- package/types/client/capacitor.d.ts +39 -0
- package/types/client/clientRuntime.d.ts +7 -0
- package/types/client/cookie.d.ts +13 -2
- package/types/client/csrTypes.d.ts +0 -1
- package/types/client/frameConfig.d.ts +1 -0
- package/types/client/index.d.ts +1 -0
- package/types/client/sharedContext.d.ts +21 -0
- package/types/client/types.d.ts +5 -3
- package/types/common/Logger.d.ts +88 -6
- package/types/common/TrustedProxy.d.ts +24 -0
- package/types/common/clamp.d.ts +2 -0
- package/types/common/clientAddress.d.ts +19 -0
- package/types/common/dynamicRecord.d.ts +14 -0
- package/types/common/index.d.ts +13 -3
- package/types/common/logContext.d.ts +17 -0
- package/types/common/mcpExposure.d.ts +64 -0
- package/types/common/pathGetLoose.d.ts +8 -0
- package/types/common/plainFieldsOf.d.ts +6 -0
- package/types/common/requestOrigin.d.ts +14 -0
- package/types/common/restClient.d.ts +27 -0
- package/types/common/routeConvention.d.ts +6 -0
- package/types/common/websocketBinaryFrame.d.ts +17 -0
- package/types/constant/constantRegistry.d.ts +2 -10
- package/types/constant/crystalize.d.ts +5 -0
- package/types/constant/dateSlot.d.ts +14 -0
- package/types/constant/fieldInfo.d.ts +20 -3
- package/types/constant/fieldQueryMeta.d.ts +17 -0
- package/types/constant/getDefault.d.ts +8 -0
- package/types/constant/hydrationPlan.d.ts +24 -0
- package/types/constant/index.d.ts +5 -0
- package/types/constant/labelOf.d.ts +7 -0
- package/types/constant/mask.d.ts +41 -0
- package/types/constant/purify.d.ts +2 -2
- package/types/constant/types.d.ts +18 -5
- 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 +7 -1
- package/types/dictionary/dictionary.d.ts +11 -9
- package/types/dictionary/index.d.ts +1 -0
- package/types/document/dataLoader.d.ts +0 -3
- package/types/document/filterMeta.d.ts +26 -6
- package/types/document/index.d.ts +1 -0
- package/types/document/loaderInfo.d.ts +2 -2
- package/types/document/noDocumentError.d.ts +12 -0
- package/types/document/types.d.ts +0 -1
- package/types/fetch/agentTurn.d.ts +475 -0
- package/types/fetch/client/fetchClient.d.ts +12 -0
- package/types/fetch/client/fetchHandle.d.ts +24 -0
- package/types/fetch/client/httpClient.d.ts +10 -4
- package/types/fetch/client/sliceInitHandle.d.ts +29 -0
- package/types/fetch/fetchType/appliedReturn.type.d.ts +71 -15
- package/types/fetch/fetchType/endpointFetch.type.d.ts +8 -5
- package/types/fetch/fetchType/sliceFetch.type.d.ts +14 -18
- package/types/fetch/index.d.ts +1 -0
- package/types/fetch/requestStorage.d.ts +14 -0
- package/types/index.d.ts +124 -12
- package/types/server/akanApp.d.ts +12 -0
- package/types/server/akanAppHeaders.d.ts +7 -1
- package/types/server/akanOption.d.ts +43 -6
- package/types/server/akanServer.d.ts +67 -9
- package/types/server/animatedImage.d.ts +7 -0
- package/types/server/assetEncoding.d.ts +1 -1
- package/types/server/binaryPubsub.d.ts +18 -0
- package/types/server/console.d.ts +11 -1
- package/types/server/consoleEvaluator.d.ts +2 -0
- package/types/server/consolePasteFilter.d.ts +11 -0
- package/types/server/consoleSession.d.ts +22 -0
- package/types/server/contentEncoding.d.ts +28 -0
- package/types/server/decorators.d.ts +12 -2
- package/types/server/devtools/types.d.ts +4 -4
- package/types/server/di/diLifecycle.d.ts +19 -3
- package/types/server/di/predefinedAdaptor.d.ts +4 -1
- package/types/server/di/utils.d.ts +16 -0
- package/types/server/lifecycle/runtimeDir.d.ts +5 -0
- package/types/server/lifecycle/shutdownManager.d.ts +2 -1
- package/types/server/logging/childOutputReader.d.ts +40 -0
- package/types/server/logging/hubFileSink.d.ts +18 -0
- package/types/server/logging/logControlSocket.d.ts +60 -0
- package/types/server/logging/logForwarder.d.ts +37 -0
- package/types/server/logging/logHub.d.ts +70 -0
- package/types/server/logging/logQuery.d.ts +31 -0
- package/types/server/logging/logStdoutWriter.d.ts +35 -0
- package/types/server/logging/logStreamRoute.d.ts +20 -0
- package/types/server/logging/logTailClient.d.ts +42 -0
- package/types/server/mcp/McpAuth.d.ts +62 -0
- package/types/server/mcp/McpDispatcher.d.ts +61 -0
- package/types/server/mcp/McpEventStream.d.ts +17 -0
- package/types/server/mcp/McpExecutionContext.d.ts +44 -0
- package/types/server/mcp/McpRouter.d.ts +65 -0
- package/types/server/mcp/index.d.ts +5 -0
- package/types/server/mcp.d.ts +1 -0
- package/types/server/resolver/signal.resolver.d.ts +7 -4
- package/types/server/routeTreeBuilder.d.ts +1 -2
- package/types/server/routing/apiRouter.d.ts +2 -1
- package/types/server/routing/appWsData.d.ts +19 -3
- package/types/server/routing/eventStream.d.ts +23 -0
- package/types/server/routing/soloAppRoutes.d.ts +17 -0
- package/types/server/rscWorkerHost.d.ts +4 -1
- package/types/server/semaphore.d.ts +5 -0
- package/types/server/ssrFromRscRenderer.d.ts +14 -0
- package/types/server/staticPath.d.ts +17 -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/types.d.ts +16 -0
- package/types/server/vendor/akanjs-fetch.d.ts +1 -0
- package/types/server/webRouter.d.ts +15 -4
- package/types/service/adapt.d.ts +3 -3
- package/types/service/agent.service.d.ts +32 -0
- package/types/service/base.service.d.ts +4 -0
- package/types/service/index.d.ts +1 -0
- package/types/service/injectInfo.d.ts +2 -2
- package/types/service/ipcTypes.d.ts +12 -0
- package/types/service/predefinedAdaptor/compress.adaptor.d.ts +1 -1
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +16 -402
- package/types/service/predefinedAdaptor/deepseekLlm.d.ts +76 -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 +105 -0
- package/types/service/predefinedAdaptor/queue.adaptor.d.ts +3 -2
- package/types/service/predefinedAdaptor/role.adaptor.d.ts +2 -0
- package/types/service/predefinedAdaptor/schedule.adaptor.d.ts +10 -6
- package/types/service/predefinedAdaptor/solidQueue.adaptor.d.ts +6 -2
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +2 -2
- package/types/service/predefinedAdaptor/sql/PendingStoreEnsures.d.ts +6 -0
- package/types/service/predefinedAdaptor/sql/QueryCompiler.d.ts +28 -0
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +127 -0
- package/types/service/predefinedAdaptor/sql/UpdateCompiler.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/dialect/postgres.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/dialect/sqlite.d.ts +27 -0
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +16 -0
- package/types/service/predefinedAdaptor/sql/driver/libsql.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +17 -0
- package/types/service/predefinedAdaptor/sql/types.d.ts +226 -0
- package/types/service/predefinedAdaptor/sql/values.d.ts +13 -0
- package/types/service/serve.d.ts +3 -3
- package/types/service/toolNames.d.ts +35 -0
- package/types/signal/CrossSiteGuard.d.ts +44 -0
- package/types/signal/SignalFailure.d.ts +28 -0
- 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 +24 -0
- package/types/signal/agentTurn.d.ts +9 -0
- package/types/signal/agentTurnStream.d.ts +24 -0
- package/types/signal/base.signal.d.ts +1 -1
- package/types/signal/endpointInfo.d.ts +21 -3
- package/types/signal/exception.d.ts +38 -54774
- package/types/signal/guard.d.ts +12 -0
- package/types/signal/guards.d.ts +23 -1
- package/types/signal/index.d.ts +8 -0
- package/types/signal/intercept.d.ts +5 -5
- package/types/signal/internal.d.ts +5 -1
- package/types/signal/internalArg.d.ts +22 -6
- package/types/signal/mcp/McpDocument.d.ts +84 -0
- package/types/signal/mcp/McpProgress.d.ts +40 -0
- package/types/signal/mcp/McpUriTemplate.d.ts +25 -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/middleware.d.ts +7 -7
- package/types/signal/openapi/openapi.d.ts +3 -3
- package/types/signal/schema/JsonSchemaBuilder.d.ts +51 -0
- package/types/signal/schema/index.d.ts +1 -0
- package/types/signal/schema.d.ts +1 -0
- package/types/signal/serializer/fetch.serializer.d.ts +7 -1
- package/types/signal/signalContext.d.ts +67 -8
- package/types/signal/slice.d.ts +42 -15
- package/types/signal/trace.d.ts +52 -2
- package/types/signal/types.d.ts +53 -4
- package/types/store/SliceRequest.d.ts +16 -0
- package/types/store/action.d.ts +7 -5
- package/types/store/actionTag.d.ts +21 -0
- package/types/store/agent/AgentBridge.d.ts +37 -0
- package/types/store/agent/AgentContext.d.ts +16 -0
- package/types/store/agent/AgentPrompts.d.ts +31 -0
- package/types/store/agent/ScreenReader.d.ts +29 -0
- package/types/store/agent/ScreenSettle.d.ts +22 -0
- package/types/store/agent/ScreenTarget.d.ts +34 -0
- package/types/store/agent/StoreCatalogue.d.ts +26 -0
- package/types/store/agent/StoreSurfaceSource.d.ts +30 -0
- package/types/store/agent/index.d.ts +11 -0
- package/types/store/agent/storeSurface.d.ts +14 -0
- package/types/store/agent/types.d.ts +15 -0
- package/types/store/agent.d.ts +1 -0
- package/types/store/agentic/AgentValue.d.ts +43 -0
- package/types/store/agentic/StExposeBuilder.d.ts +21 -0
- package/types/store/agentic/StExposeDraft.d.ts +13 -0
- package/types/store/agentic/StStateBuilder.d.ts +21 -0
- package/types/store/agentic/StStateDraft.d.ts +12 -0
- package/types/store/agentic/StToolBuilder.d.ts +65 -0
- package/types/store/agentic/StToolDraft.d.ts +13 -0
- package/types/store/agentic/attachAgentic.d.ts +25 -0
- package/types/store/agentic/formFields.d.ts +53 -0
- package/types/store/agentic/index.d.ts +12 -0
- package/types/store/agentic/useFieldTool.d.ts +22 -0
- package/types/store/agentic/useFormTools.d.ts +19 -0
- package/types/store/agentic/useRelationFieldTool.d.ts +27 -0
- package/types/store/agentic.d.ts +1 -0
- package/types/store/baseSt.d.ts +35 -39
- package/types/store/databaseStateNames.d.ts +25 -0
- package/types/store/formSetterNames.d.ts +30 -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 +5 -1
- package/types/store/storeInstance.d.ts +33 -1
- package/types/store/storeRegistry.d.ts +5 -0
- package/types/store/types.d.ts +4 -0
- package/types/store/withSelector.d.ts +5 -4
- package/types/test/index.d.ts +1 -1
- package/types/test/registerDom.d.ts +1 -0
- package/types/test/signalTestRuntime.d.ts +2 -3
- package/types/test/testServer.d.ts +6 -4
- package/types/ui/Agent/Approval.d.ts +8 -0
- package/types/ui/Agent/Attach.d.ts +16 -0
- package/types/ui/Agent/Bubble.d.ts +26 -0
- package/types/ui/Agent/Chat.d.ts +91 -0
- package/types/ui/Agent/ChatCommands.d.ts +34 -0
- package/types/ui/Agent/Composer.d.ts +23 -0
- package/types/ui/Agent/Context.d.ts +13 -0
- package/types/ui/Agent/Dock.d.ts +17 -0
- package/types/ui/Agent/Guide.d.ts +9 -0
- package/types/ui/Agent/History.d.ts +26 -0
- package/types/ui/Agent/Launcher.d.ts +16 -0
- package/types/ui/Agent/Markdown.d.ts +19 -0
- package/types/ui/Agent/Menu.d.ts +18 -0
- package/types/ui/Agent/Mic.d.ts +8 -0
- package/types/ui/Agent/Question.d.ts +14 -0
- package/types/ui/Agent/Section.d.ts +10 -0
- package/types/ui/Agent/Skip.d.ts +22 -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 +48 -0
- package/types/ui/Agent/agentSessionOf.d.ts +27 -0
- package/types/ui/Agent/attachment.d.ts +34 -0
- package/types/ui/Agent/fetchRunner.d.ts +12 -0
- package/types/ui/Agent/index.d.ts +19 -0
- package/types/ui/Agent/index_.d.ts +1 -0
- package/types/ui/Agent/markdownBlocks.d.ts +35 -0
- package/types/ui/Agent/markdownSpans.d.ts +2 -0
- package/types/ui/Agent/markdownTable.d.ts +16 -0
- package/types/ui/Agent/sessionHistory.d.ts +14 -0
- package/types/ui/Agent/sessionView.d.ts +15 -0
- package/types/ui/Agent/tokenCount.d.ts +6 -0
- package/types/ui/Agent/useChatAttachments.d.ts +24 -0
- package/types/ui/Agent/useChatVoice.d.ts +30 -0
- package/types/ui/Agent/useDraftRecall.d.ts +14 -0
- package/types/ui/Agent/useKeyboardInset.d.ts +8 -0
- package/types/ui/Agent/useSlashMenu.d.ts +24 -0
- package/types/ui/Agent/voice.d.ts +71 -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/Constant/Graph.d.ts +10 -0
- package/types/ui/Constant/index.d.ts +2 -1
- package/types/ui/Constant/schemaGraph.d.ts +39 -0
- package/types/ui/Data/Dashboard.d.ts +16 -3
- package/types/ui/Data/Insight.d.ts +1 -1
- package/types/ui/Data/ListContainer.d.ts +15 -7
- package/types/ui/Data/QueryMaker.d.ts +45 -3
- package/types/ui/Data/RefPicker.d.ts +16 -0
- package/types/ui/Data/dataExport.d.ts +5 -0
- package/types/ui/Data/dataText.d.ts +6 -0
- package/types/ui/Data/index.d.ts +2 -0
- package/types/ui/Data/index_.d.ts +1 -0
- package/types/ui/DatePicker.d.ts +15 -11
- package/types/ui/Dialog/LegacyModal.d.ts +13 -0
- package/types/ui/Dialog/Provider.d.ts +3 -1
- package/types/ui/Dialog/context.d.ts +9 -1
- package/types/ui/Dialog/index.d.ts +1 -0
- package/types/ui/DraggableList.d.ts +1 -1
- package/types/ui/Dropdown.d.ts +5 -1
- package/types/ui/Field/Choice.d.ts +52 -0
- package/types/ui/Field/Collection.d.ts +51 -0
- package/types/ui/Field/DateField.d.ts +32 -0
- package/types/ui/Field/Label.d.ts +9 -0
- package/types/ui/Field/NumberField.d.ts +43 -0
- package/types/ui/Field/Relation.d.ts +80 -0
- package/types/ui/Field/Text.d.ts +101 -0
- package/types/ui/Field/index.d.ts +50 -0
- package/types/ui/Field.d.ts +1 -411
- package/types/ui/Layout/BottomTab.d.ts +3 -2
- package/types/ui/LegacyModal.d.ts +24 -0
- package/types/ui/Load/Edit_Client.d.ts +3 -1
- package/types/ui/Load/Stream.d.ts +22 -0
- package/types/ui/Load/index.d.ts +2 -0
- package/types/ui/Loading/ProgressBar.d.ts +4 -0
- package/types/ui/Loading/Spin.d.ts +2 -1
- package/types/ui/Loading/index_.d.ts +13 -0
- package/types/ui/Model/AdminPanel.d.ts +15 -3
- package/types/ui/Model/EditModal.d.ts +1 -1
- package/types/ui/Model/New.d.ts +3 -1
- package/types/ui/Model/NewWrapper.d.ts +2 -0
- package/types/ui/Model/NewWrapper_Client.d.ts +2 -1
- package/types/ui/Pagination.d.ts +2 -2
- package/types/ui/Radio.d.ts +1 -1
- package/types/ui/RecentTime.d.ts +18 -1
- package/types/ui/Reference/Collapse.d.ts +11 -0
- package/types/ui/Reference/Panel.d.ts +29 -0
- package/types/ui/Reference/Segmented.d.ts +17 -0
- package/types/ui/Reference/Summary.d.ts +13 -0
- package/types/ui/Reference/Toolbar.d.ts +21 -0
- package/types/ui/Reference/dictText.d.ts +6 -0
- package/types/ui/Reference/index.d.ts +7 -0
- package/types/ui/Reference/style.d.ts +20 -0
- package/types/ui/Reference.d.ts +1 -0
- package/types/ui/ScreenNavigator.d.ts +3 -1
- package/types/ui/Signal/Arg.d.ts +7 -3
- package/types/ui/Signal/Doc.d.ts +4 -6
- package/types/ui/Signal/Object.d.ts +2 -1
- package/types/ui/Signal/RestApi.d.ts +2 -1
- package/types/ui/Signal/WebSocket.d.ts +2 -1
- package/types/ui/Signal/endpointEntries.d.ts +20 -0
- package/types/ui/Signal/style.d.ts +9 -8
- package/types/ui/System/Client.d.ts +1 -2
- package/types/ui/System/Common.d.ts +3 -4
- package/types/ui/System/Messages.d.ts +1 -1
- package/types/ui/System/Root.d.ts +4 -0
- package/types/ui/Tab/Provider.d.ts +3 -1
- package/types/ui/Tab/context.d.ts +4 -2
- package/types/ui/ToggleSelect.d.ts +1 -0
- package/types/ui/UiOverride/context.d.ts +18 -1
- package/types/ui/agentAttrs.d.ts +14 -0
- package/types/ui/index.d.ts +22 -1
- package/types/ui/overlayLayer.d.ts +13 -0
- package/types/ui/overlayPosition.d.ts +28 -0
- package/types/ui/recipe/badgeRecipe.d.ts +2 -2
- package/types/ui/recipe/buttonRecipe.d.ts +2 -2
- package/types/vendor/use-agentic/AgentAbort.d.ts +17 -0
- package/types/vendor/use-agentic/AgentProgress.d.ts +27 -0
- package/types/vendor/use-agentic/AgentProvider.d.ts +17 -0
- package/types/vendor/use-agentic/AgentScope.d.ts +9 -0
- package/types/vendor/use-agentic/AgentSession.d.ts +163 -0
- package/types/vendor/use-agentic/Agentic.d.ts +21 -0
- package/types/vendor/use-agentic/AgenticSurface.d.ts +58 -0
- package/types/vendor/use-agentic/Compaction.d.ts +48 -0
- package/types/vendor/use-agentic/ToolOutput.d.ts +21 -0
- package/types/vendor/use-agentic/Transcript.d.ts +18 -0
- package/types/vendor/use-agentic/httpRunner.d.ts +15 -0
- package/types/vendor/use-agentic/index.d.ts +19 -0
- package/types/vendor/use-agentic/sharedContext.d.ts +15 -0
- package/types/vendor/use-agentic/surfaceContext.d.ts +5 -0
- package/types/vendor/use-agentic/types.d.ts +182 -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 +12 -0
- package/types/vendor/use-agentic/useAgentState.d.ts +16 -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 +4 -0
- package/types/webkit/useBodyScrollLock.d.ts +2 -0
- package/types/webkit/useCamera.d.ts +10 -1
- package/types/webkit/usePageTool.d.ts +19 -0
- package/types/webkit/usePurchase.d.ts +4 -0
- package/types/webkit/useScreenScope.d.ts +25 -0
- package/ui/Agent/Approval.tsx +32 -0
- package/ui/Agent/Attach.tsx +77 -0
- package/ui/Agent/Bubble.tsx +192 -0
- package/ui/Agent/Chat.tsx +525 -0
- package/ui/Agent/ChatCommands.ts +141 -0
- package/ui/Agent/Composer.tsx +94 -0
- package/ui/Agent/Context.tsx +49 -0
- package/ui/Agent/Dock.tsx +77 -0
- package/ui/Agent/Guide.tsx +16 -0
- package/ui/Agent/History.tsx +49 -0
- package/ui/Agent/Launcher.tsx +60 -0
- package/ui/Agent/Markdown.tsx +142 -0
- package/ui/Agent/Menu.tsx +55 -0
- package/ui/Agent/Mic.tsx +27 -0
- package/ui/Agent/Question.tsx +63 -0
- package/ui/Agent/Section.tsx +24 -0
- package/ui/Agent/Skip.tsx +30 -0
- package/ui/Agent/StateKey.tsx +46 -0
- package/ui/Agent/Tool.tsx +59 -0
- package/ui/Agent/Transcript.tsx +33 -0
- package/ui/Agent/Zone.tsx +116 -0
- package/ui/Agent/agentSessionOf.ts +60 -0
- package/ui/Agent/attachment.ts +73 -0
- package/ui/Agent/fetchRunner.ts +44 -0
- package/ui/Agent/index.ts +27 -0
- package/ui/Agent/index_.tsx +4 -0
- package/ui/Agent/markdownBlocks.ts +137 -0
- package/ui/Agent/markdownSpans.tsx +49 -0
- package/ui/Agent/markdownTable.ts +54 -0
- package/ui/Agent/sessionHistory.ts +62 -0
- package/ui/Agent/sessionView.ts +38 -0
- package/ui/Agent/tokenCount.ts +10 -0
- package/ui/Agent/useChatAttachments.ts +84 -0
- package/ui/Agent/useChatVoice.ts +129 -0
- package/ui/Agent/useDraftRecall.ts +42 -0
- package/ui/Agent/useKeyboardInset.ts +26 -0
- package/ui/Agent/useSlashMenu.ts +58 -0
- package/ui/Agent/voice.ts +177 -0
- package/ui/Badge.tsx +1 -1
- package/ui/BottomSheet.tsx +32 -36
- package/ui/Button.tsx +3 -1
- package/ui/Clipboard.tsx +3 -6
- package/ui/Constant/Doc.tsx +265 -254
- package/ui/Constant/Graph.tsx +151 -0
- package/ui/Constant/index.ts +3 -2
- package/ui/Constant/schemaGraph.ts +232 -0
- package/ui/Data/CardList.tsx +14 -3
- package/ui/Data/Dashboard.tsx +70 -52
- package/ui/Data/Insight.tsx +18 -12
- package/ui/Data/Item.tsx +42 -56
- package/ui/Data/ListContainer.tsx +246 -132
- package/ui/Data/Pagination.tsx +10 -3
- package/ui/Data/QueryMaker.tsx +160 -11
- package/ui/Data/RefPicker.tsx +202 -0
- package/ui/Data/TableList.tsx +22 -13
- package/ui/Data/dataExport.ts +54 -0
- package/ui/Data/dataText.ts +22 -0
- package/ui/Data/index.ts +13 -1
- package/ui/Data/index_.tsx +1 -0
- package/ui/DatePicker.tsx +110 -128
- package/ui/Dialog/Close.tsx +3 -7
- package/ui/Dialog/LegacyModal.tsx +241 -0
- package/ui/Dialog/Modal.tsx +62 -195
- package/ui/Dialog/Provider.tsx +47 -3
- package/ui/Dialog/Trigger.tsx +3 -7
- package/ui/Dialog/context.ts +14 -2
- package/ui/Dialog/index.tsx +2 -0
- package/ui/DragAction.tsx +3 -2
- package/ui/DraggableList.tsx +10 -6
- package/ui/Dropdown.tsx +89 -27
- package/ui/Empty.tsx +6 -4
- package/ui/Field/Choice.tsx +172 -0
- package/ui/Field/Collection.tsx +293 -0
- package/ui/Field/DateField.tsx +138 -0
- package/ui/Field/Label.tsx +31 -0
- package/ui/Field/NumberField.tsx +169 -0
- package/ui/Field/Relation.tsx +387 -0
- package/ui/Field/Text.tsx +360 -0
- package/ui/Field/index.tsx +70 -0
- package/ui/Input.tsx +30 -8
- package/ui/KeyboardAvoiding.tsx +2 -2
- package/ui/Layout/BottomTab.tsx +32 -37
- package/ui/Layout/Sider.tsx +37 -14
- package/ui/LegacyModal.tsx +53 -0
- package/ui/Link/CsrLink.tsx +1 -1
- package/ui/Load/Edit.tsx +2 -2
- package/ui/Load/Edit_Client.tsx +11 -3
- package/ui/Load/Pagination.tsx +35 -28
- package/ui/Load/Stream.tsx +38 -0
- package/ui/Load/Units.tsx +76 -40
- package/ui/Load/View.tsx +34 -19
- package/ui/Load/index.ts +2 -0
- package/ui/Loading/Area.tsx +7 -6
- package/ui/Loading/Button.tsx +7 -9
- package/ui/Loading/Input.tsx +7 -9
- package/ui/Loading/ProgressBar.tsx +16 -7
- package/ui/Loading/Skeleton.tsx +8 -13
- package/ui/Loading/Spin.tsx +20 -14
- package/ui/Loading/index.ts +15 -0
- package/ui/Loading/index_.tsx +22 -0
- package/ui/Menu.tsx +1 -1
- package/ui/Model/AdminPanel.tsx +52 -12
- package/ui/Model/EditModal.tsx +35 -13
- package/ui/Model/EditWrapper.tsx +16 -4
- package/ui/Model/New.tsx +4 -0
- package/ui/Model/NewWrapper.tsx +2 -0
- package/ui/Model/NewWrapper_Client.tsx +20 -6
- package/ui/Model/Remove.tsx +18 -6
- package/ui/Model/RemoveWrapper.tsx +12 -2
- package/ui/Model/SureToRemove.tsx +18 -6
- package/ui/Model/ViewEditModal.tsx +64 -15
- package/ui/Model/ViewModal.tsx +25 -11
- package/ui/Model/ViewWrapper.tsx +15 -4
- package/ui/Model/index_.tsx +1 -1
- package/ui/Pagination.tsx +51 -66
- package/ui/Popconfirm.tsx +88 -78
- package/ui/Radio.tsx +53 -24
- package/ui/RecentTime.tsx +83 -35
- package/ui/Reference/Collapse.tsx +26 -0
- package/ui/Reference/Panel.tsx +79 -0
- package/ui/Reference/Segmented.tsx +41 -0
- package/ui/Reference/Summary.tsx +25 -0
- package/ui/Reference/Toolbar.tsx +44 -0
- package/ui/Reference/dictText.ts +9 -0
- package/ui/Reference/index.ts +7 -0
- package/ui/Reference/style.ts +45 -0
- package/ui/ScreenNavigator.tsx +17 -2
- package/ui/Select.tsx +96 -57
- package/ui/Signal/Arg.tsx +83 -68
- package/ui/Signal/Doc.tsx +163 -129
- package/ui/Signal/Listener.tsx +40 -29
- package/ui/Signal/Message.tsx +94 -142
- package/ui/Signal/Object.tsx +79 -57
- package/ui/Signal/PubSub.tsx +76 -114
- package/ui/Signal/Request.tsx +2 -22
- package/ui/Signal/Response.tsx +19 -45
- package/ui/Signal/RestApi.tsx +170 -200
- package/ui/Signal/WebSocket.tsx +29 -26
- package/ui/Signal/endpointEntries.ts +59 -0
- package/ui/Signal/makeExample.ts +10 -3
- package/ui/Signal/style.ts +34 -29
- package/ui/Switch.tsx +4 -0
- package/ui/System/CSR.tsx +1 -1
- package/ui/System/Client.tsx +31 -17
- package/ui/System/Common.tsx +3 -4
- package/ui/System/DevModeToggle.tsx +1 -1
- package/ui/System/Gtag.tsx +3 -3
- package/ui/System/Messages.tsx +52 -31
- package/ui/System/Reconnect.tsx +22 -56
- package/ui/System/Root.tsx +4 -0
- package/ui/System/SelectLanguage.tsx +24 -15
- package/ui/System/ThemeToggle.tsx +25 -13
- package/ui/Tab/Menu.tsx +24 -12
- package/ui/Tab/Menus.tsx +6 -3
- package/ui/Tab/Provider.tsx +30 -3
- package/ui/Tab/context.ts +8 -4
- package/ui/Table.tsx +66 -60
- package/ui/ToggleSelect.tsx +8 -7
- package/ui/Tooltip.tsx +15 -1
- package/ui/UiOverride/context.ts +21 -2
- package/ui/Unauthorized.tsx +6 -4
- package/ui/agentAttrs.ts +19 -0
- package/ui/index.ts +49 -1
- package/ui/overlayLayer.ts +12 -2
- package/ui/overlayPosition.ts +103 -0
- package/ui/recipe/buttonRecipe.ts +2 -2
- package/ui/styles.css +31 -0
- package/vendor/use-agentic/AgentAbort.ts +29 -0
- package/vendor/use-agentic/AgentProgress.ts +40 -0
- package/vendor/use-agentic/AgentProvider.tsx +39 -0
- package/vendor/use-agentic/AgentScope.tsx +20 -0
- package/vendor/use-agentic/AgentSession.ts +750 -0
- package/vendor/use-agentic/Agentic.tsx +44 -0
- package/vendor/use-agentic/AgenticSurface.ts +333 -0
- package/vendor/use-agentic/Compaction.ts +120 -0
- package/vendor/use-agentic/ToolOutput.ts +60 -0
- package/vendor/use-agentic/Transcript.ts +50 -0
- package/vendor/use-agentic/WIRE.md +86 -0
- package/vendor/use-agentic/httpRunner.ts +131 -0
- package/vendor/use-agentic/index.ts +20 -0
- package/vendor/use-agentic/sharedContext.ts +25 -0
- package/vendor/use-agentic/surfaceContext.ts +10 -0
- package/vendor/use-agentic/types.ts +192 -0
- package/vendor/use-agentic/useAgent.ts +18 -0
- package/vendor/use-agentic/useAgentGuide.ts +16 -0
- package/vendor/use-agentic/useAgentResource.ts +36 -0
- package/vendor/use-agentic/useAgentState.ts +64 -0
- package/vendor/use-agentic/useAgentTool.ts +55 -0
- package/webkit/bootCsr.tsx +10 -8
- package/webkit/index.ts +4 -0
- package/webkit/lazy.tsx +5 -1
- package/webkit/useBodyScrollLock.tsx +29 -0
- package/webkit/useCamera.tsx +22 -6
- package/webkit/useCodepush.tsx +2 -2
- package/webkit/useCsrValues.ts +1 -3
- package/webkit/useFetch.ts +4 -3
- package/webkit/useFrameRuntime.ts +15 -8
- package/webkit/usePageTool.tsx +37 -0
- package/webkit/usePurchase.tsx +4 -1
- package/webkit/useScreenScope.tsx +60 -0
- package/fetch/serializer/fetch.serializer.ts +0 -142
- package/fetch/serializer/index.ts +0 -1
- package/types/common/httpClient.d.ts +0 -20
- package/types/fetch/serializer/fetch.serializer.d.ts +0 -14
- package/types/fetch/serializer/index.d.ts +0 -1
- package/types/fetch/serializer.d.ts +0 -1
- package/types/ui/Constant/Mermaid.d.ts +0 -8
- package/types/ui/Signal/Collapse.d.ts +0 -12
- package/ui/Constant/Mermaid.tsx +0 -149
- package/ui/Field.tsx +0 -1569
- package/ui/Loading/index.tsx +0 -22
- package/ui/Signal/Collapse.tsx +0 -29
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useAgentResource } from "../../vendor/use-agentic";
|
|
2
|
+
|
|
3
|
+
import { useRef } from "../hooks";
|
|
4
|
+
import { type AgentFieldType, AgentValue, type AgentValueOf } from "./AgentValue";
|
|
5
|
+
|
|
6
|
+
export interface StExposeMeta {
|
|
7
|
+
/** `false` keeps the key out of post-call diff reports — for values that change on their own every second. */
|
|
8
|
+
report?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A read-only value past its description, waiting for the value itself. `.value()` is the one hook.
|
|
13
|
+
*
|
|
14
|
+
* The declared type is what makes the read safe: it typechecks what the component hands over and it decides how
|
|
15
|
+
* the value is rendered, so a model's `hidden` and `secret` fields are stripped by the model that was named
|
|
16
|
+
* rather than by whatever class the value still happens to carry.
|
|
17
|
+
*/
|
|
18
|
+
export class StExposeBuilder<T extends AgentFieldType> {
|
|
19
|
+
readonly #name: string | null;
|
|
20
|
+
readonly #type: T;
|
|
21
|
+
readonly #desc: string;
|
|
22
|
+
readonly #meta: StExposeMeta;
|
|
23
|
+
|
|
24
|
+
constructor(name: string | null, type: T, desc: string, meta: StExposeMeta = {}) {
|
|
25
|
+
this.#name = name;
|
|
26
|
+
this.#type = type;
|
|
27
|
+
this.#desc = desc;
|
|
28
|
+
this.#meta = meta;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* A thunk is read when the agent reads, which is the difference that matters for a value assembled out of a ref
|
|
33
|
+
* the children fill in after this render — computing it here would publish whatever was there before they ran.
|
|
34
|
+
*/
|
|
35
|
+
value(value: AgentValueOf<T> | (() => AgentValueOf<T>) | null | undefined): void {
|
|
36
|
+
const declared = useRef<{ key: string | null; name: string | null } | null>(null);
|
|
37
|
+
|
|
38
|
+
if (declared.current?.key !== this.#name)
|
|
39
|
+
declared.current = {
|
|
40
|
+
key: this.#name,
|
|
41
|
+
name: this.#name && AgentValue.publishable(`st.expose("${this.#name}")`, this.#type) ? this.#name : null,
|
|
42
|
+
};
|
|
43
|
+
useAgentResource(declared.current.name, value, {
|
|
44
|
+
description: this.#desc,
|
|
45
|
+
report: this.#meta.report,
|
|
46
|
+
serialize: (current) =>
|
|
47
|
+
AgentValue.serialize(this.#type, typeof current === "function" ? (current as () => unknown)() : current),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AgentFieldType } from "./AgentValue";
|
|
2
|
+
import { StExposeBuilder, type StExposeMeta } from "./StExposeBuilder";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A readable value before it has said what it is: `st.expose("x", ID).desc("…")`.
|
|
6
|
+
*
|
|
7
|
+
* A falsy name declares nothing and publishes nothing, so a component whose publication is conditional keeps a
|
|
8
|
+
* constant hook count instead of branching around the chain.
|
|
9
|
+
*/
|
|
10
|
+
export class StExposeDraft<T extends AgentFieldType> {
|
|
11
|
+
readonly #name: string | null;
|
|
12
|
+
readonly #type: T;
|
|
13
|
+
readonly #meta: StExposeMeta;
|
|
14
|
+
|
|
15
|
+
constructor(name: string | null, type: T, meta: StExposeMeta = {}) {
|
|
16
|
+
this.#name = name;
|
|
17
|
+
this.#type = type;
|
|
18
|
+
this.#meta = meta;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
desc(text: string): StExposeBuilder<T> {
|
|
22
|
+
return new StExposeBuilder(this.#name, this.#type, text, this.#meta);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { capitalize } from "akanjs/common";
|
|
2
|
+
import type { ParamFieldType } from "akanjs/constant";
|
|
3
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
4
|
+
import { type JsonSchema, useAgentState } from "../../vendor/use-agentic";
|
|
5
|
+
|
|
6
|
+
import { useRef } from "../hooks";
|
|
7
|
+
import { type AgentFieldType, AgentValue, type AgentValueOf } from "./AgentValue";
|
|
8
|
+
import { StToolBuilder } from "./StToolBuilder";
|
|
9
|
+
|
|
10
|
+
export interface StStateMeta {
|
|
11
|
+
/** `false` keeps the key out of post-call diff reports — for values that change on their own every second. */
|
|
12
|
+
report?: boolean;
|
|
13
|
+
/** Publishes a `set<Name>` tool writing the type this state declares. Read-only without it. */
|
|
14
|
+
set?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface StStateDeclaration {
|
|
18
|
+
/** The name as written this render, which is what says whether the resolution below still applies. */
|
|
19
|
+
key: string | null;
|
|
20
|
+
name: string | null;
|
|
21
|
+
set: { schema: JsonSchema; type: ParamFieldType } | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Local state past its description, waiting for its initial value. `.init()` is the one hook and returns what
|
|
26
|
+
* `useState` returns.
|
|
27
|
+
*
|
|
28
|
+
* The declared type does both halves: it renders the read, and — with `set` — it is the schema of the setter tool
|
|
29
|
+
* an agent writes through. A type nothing can describe costs the write, not the read and not the render.
|
|
30
|
+
*/
|
|
31
|
+
export class StStateBuilder<T extends AgentFieldType> {
|
|
32
|
+
readonly #name: string | null;
|
|
33
|
+
readonly #type: T;
|
|
34
|
+
readonly #desc: string;
|
|
35
|
+
readonly #meta: StStateMeta;
|
|
36
|
+
|
|
37
|
+
constructor(name: string | null, type: T, desc: string, meta: StStateMeta = {}) {
|
|
38
|
+
this.#name = name;
|
|
39
|
+
this.#type = type;
|
|
40
|
+
this.#desc = desc;
|
|
41
|
+
this.#meta = meta;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
init(
|
|
45
|
+
initial: AgentValueOf<T> | (() => AgentValueOf<T>),
|
|
46
|
+
): [AgentValueOf<T>, Dispatch<SetStateAction<AgentValueOf<T>>>];
|
|
47
|
+
init(
|
|
48
|
+
initial: AgentValueOf<T> | null | (() => AgentValueOf<T> | null),
|
|
49
|
+
): [AgentValueOf<T> | null, Dispatch<SetStateAction<AgentValueOf<T> | null>>];
|
|
50
|
+
|
|
51
|
+
init(initial: AgentValueOf<T> | null | (() => AgentValueOf<T> | null)): unknown {
|
|
52
|
+
type Value = AgentValueOf<T> | null;
|
|
53
|
+
const name = this.#name;
|
|
54
|
+
const type = this.#type;
|
|
55
|
+
const declared = useRef<StStateDeclaration | null>(null);
|
|
56
|
+
|
|
57
|
+
if (declared.current?.key !== name)
|
|
58
|
+
declared.current = {
|
|
59
|
+
key: name,
|
|
60
|
+
name: name && AgentValue.publishable(`st.useState("${name}")`, type) ? name : null,
|
|
61
|
+
set: name && this.#meta.set ? StStateBuilder.#writable(name, type) : null,
|
|
62
|
+
};
|
|
63
|
+
const { set } = declared.current;
|
|
64
|
+
return useAgentState<Value>(declared.current.name, initial, {
|
|
65
|
+
description: this.#desc,
|
|
66
|
+
report: this.#meta.report,
|
|
67
|
+
serialize: (value) => AgentValue.serialize(type, value),
|
|
68
|
+
...(set
|
|
69
|
+
? {
|
|
70
|
+
set: set.schema,
|
|
71
|
+
parse: (value) =>
|
|
72
|
+
StToolBuilder.checkedValue(`set${capitalize(name ?? "")}`, "value", set.type, value) as Value,
|
|
73
|
+
}
|
|
74
|
+
: {}),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** A `set` an agent could only call wrong leaves the key readable — the same trade `st.tool`'s `.arg` makes. */
|
|
79
|
+
static #writable(name: string, type: AgentFieldType): StStateDeclaration["set"] {
|
|
80
|
+
const scalar = type as unknown as ParamFieldType;
|
|
81
|
+
try {
|
|
82
|
+
return { schema: StToolBuilder.schemaOf(scalar), type: scalar };
|
|
83
|
+
} catch (error) {
|
|
84
|
+
console.error(
|
|
85
|
+
`st.useState("${name}") stays read-only: writing ${error instanceof Error ? error.message : String(error)}`,
|
|
86
|
+
);
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { AgentFieldType } from "./AgentValue";
|
|
2
|
+
import { StStateBuilder, type StStateMeta } from "./StStateBuilder";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Local state before it has said what it is: `st.useState("tab", String, { set: true }).desc("…")`.
|
|
6
|
+
*
|
|
7
|
+
* A falsy name keeps the state and publishes nothing, so a conditional surface never changes the hook count.
|
|
8
|
+
*/
|
|
9
|
+
export class StStateDraft<T extends AgentFieldType> {
|
|
10
|
+
readonly #name: string | null;
|
|
11
|
+
readonly #type: T;
|
|
12
|
+
readonly #meta: StStateMeta;
|
|
13
|
+
|
|
14
|
+
constructor(name: string | null, type: T, meta: StStateMeta = {}) {
|
|
15
|
+
this.#name = name;
|
|
16
|
+
this.#type = type;
|
|
17
|
+
this.#meta = meta;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
desc(text: string): StStateBuilder<T> {
|
|
21
|
+
return new StStateBuilder(this.#name, this.#type, text, this.#meta);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CLIENT_VALUE,
|
|
3
|
+
type Cls,
|
|
4
|
+
dayjs,
|
|
5
|
+
type EnumInstance,
|
|
6
|
+
Int,
|
|
7
|
+
isEnum,
|
|
8
|
+
PrimitiveRegistry,
|
|
9
|
+
type PrimitiveScalar,
|
|
10
|
+
} from "akanjs/base";
|
|
11
|
+
import type { ParamFieldType } from "akanjs/constant";
|
|
12
|
+
import {
|
|
13
|
+
AgenticSurface,
|
|
14
|
+
type JsonSchema,
|
|
15
|
+
type ToolConfirm,
|
|
16
|
+
type ToolGuard,
|
|
17
|
+
useScopePath,
|
|
18
|
+
useSurface,
|
|
19
|
+
} from "../../vendor/use-agentic";
|
|
20
|
+
import { tagAction } from "../actionTag";
|
|
21
|
+
|
|
22
|
+
import { useEffect, useRef } from "../hooks";
|
|
23
|
+
|
|
24
|
+
export interface StToolMeta {
|
|
25
|
+
/**
|
|
26
|
+
* Whether the call has to be waited out before what it did to the screen is reported back to the model. `false`
|
|
27
|
+
* is a read that returns what is already there; the default waits, because a write may still be landing when
|
|
28
|
+
* `exec` resolves and a report taken then describes the screen one tick before the call.
|
|
29
|
+
*/
|
|
30
|
+
settle?: boolean;
|
|
31
|
+
confirm?: ToolConfirm;
|
|
32
|
+
guard?: ToolGuard;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface StToolArg {
|
|
36
|
+
name: string;
|
|
37
|
+
type: ParamFieldType;
|
|
38
|
+
optional: boolean;
|
|
39
|
+
oneOf?: readonly (string | number)[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** `oneOf` is the runtime half of `enumOf`: a value set only known once the component renders. */
|
|
43
|
+
export interface StToolArgOption<V> {
|
|
44
|
+
oneOf?: readonly V[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
type ArgValue<T> = T extends EnumInstance<string, infer V> ? V : T extends { [CLIENT_VALUE]: infer V } ? V : never;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A component tool past its description: `.arg()` for what the caller must pass, `.opt()` for what it may, and
|
|
51
|
+
* one `.exec()`.
|
|
52
|
+
*
|
|
53
|
+
* This is not A12's rejected store-action builder — a store action derives its schema from the endpoint it is
|
|
54
|
+
* named after, while a component tool exists nowhere else, so declaring is the only source there is. `.arg()` and
|
|
55
|
+
* `.opt()` only accumulate data; `.exec()` is the one hook, so the chain must complete in one unconditional
|
|
56
|
+
* statement.
|
|
57
|
+
*
|
|
58
|
+
* A falsy name declares the tool without publishing it: the callable still works for the click that a person
|
|
59
|
+
* makes, and nothing reaches the agent. That is how a conditional surface stays writable at all — `.exec()` is a
|
|
60
|
+
* hook, so a component can never skip the declaration, only the publication.
|
|
61
|
+
*/
|
|
62
|
+
export class StToolBuilder<Args extends unknown[] = []> {
|
|
63
|
+
readonly #name: string | null;
|
|
64
|
+
readonly #desc: string;
|
|
65
|
+
readonly #meta: StToolMeta;
|
|
66
|
+
readonly #args: StToolArg[];
|
|
67
|
+
|
|
68
|
+
constructor(name: string | null, desc: string, meta: StToolMeta = {}, args: StToolArg[] = []) {
|
|
69
|
+
|
|
70
|
+
this.#name = name || null;
|
|
71
|
+
this.#desc = desc;
|
|
72
|
+
this.#meta = meta;
|
|
73
|
+
this.#args = args;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
arg<T extends ParamFieldType>(name: string, type: T): StToolBuilder<[...Args, ArgValue<T>]>;
|
|
77
|
+
arg<T extends ParamFieldType, const V extends ArgValue<T>>(
|
|
78
|
+
name: string,
|
|
79
|
+
type: T,
|
|
80
|
+
option: StToolArgOption<V>,
|
|
81
|
+
): StToolBuilder<[...Args, V]>;
|
|
82
|
+
arg<T extends ParamFieldType>(
|
|
83
|
+
name: string,
|
|
84
|
+
type: T,
|
|
85
|
+
option: StToolArgOption<ArgValue<T>> = {},
|
|
86
|
+
): StToolBuilder<[...Args, ArgValue<T>]> {
|
|
87
|
+
return this.#push(name, type, false, option) as StToolBuilder<[...Args, ArgValue<T>]>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
opt<T extends ParamFieldType>(name: string, type: T): StToolBuilder<[...Args, ArgValue<T> | null]>;
|
|
91
|
+
opt<T extends ParamFieldType, const V extends ArgValue<T>>(
|
|
92
|
+
name: string,
|
|
93
|
+
type: T,
|
|
94
|
+
option: StToolArgOption<V>,
|
|
95
|
+
): StToolBuilder<[...Args, V | null]>;
|
|
96
|
+
opt<T extends ParamFieldType>(
|
|
97
|
+
name: string,
|
|
98
|
+
type: T,
|
|
99
|
+
option: StToolArgOption<ArgValue<T>> = {},
|
|
100
|
+
): StToolBuilder<[...Args, ArgValue<T> | null]> {
|
|
101
|
+
return this.#push(name, type, true, option);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
#push<T extends ParamFieldType>(
|
|
105
|
+
name: string,
|
|
106
|
+
type: T,
|
|
107
|
+
optional: boolean,
|
|
108
|
+
option: StToolArgOption<ArgValue<T>>,
|
|
109
|
+
): StToolBuilder<[...Args, ArgValue<T> | null]> {
|
|
110
|
+
|
|
111
|
+
const published = this.#name && StToolBuilder.#describable(this.#name, name, type) ? this.#name : null;
|
|
112
|
+
return new StToolBuilder(published, this.#desc, this.#meta, [
|
|
113
|
+
...this.#args,
|
|
114
|
+
{ name, type, optional, ...(option.oneOf ? { oneOf: option.oneOf } : {}) },
|
|
115
|
+
]);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The only hook in the chain. `run`, `guard`, and `confirm` stay always-latest, and so does the **name** —
|
|
120
|
+
* `desc` and `args` are read once per name because a component that renders once per row declares one tool
|
|
121
|
+
* many times and only its own arguments differ.
|
|
122
|
+
*
|
|
123
|
+
* The name has to follow the render, because withholding it is how a conditional surface is written
|
|
124
|
+
* (`st.tool(canRemove && "removeX")`). Frozen on the first render it failed both ways: a control that appeared
|
|
125
|
+
* later never published, and — worse — one that went away stayed published, leaving an agent a lever the screen
|
|
126
|
+
* no longer offers.
|
|
127
|
+
*/
|
|
128
|
+
exec(run: (...args: Args) => unknown): (...args: Args) => Promise<void> {
|
|
129
|
+
const surface = useSurface();
|
|
130
|
+
const scope = useScopePath();
|
|
131
|
+
const live = useRef({ run, meta: this.#meta });
|
|
132
|
+
live.current = { run, meta: this.#meta };
|
|
133
|
+
const declared = useRef<{ name: string | null; desc: string; meta: StToolMeta; args: StToolArg[] } | null>(null);
|
|
134
|
+
if (declared.current?.name !== this.#name)
|
|
135
|
+
declared.current = { name: this.#name, desc: this.#desc, meta: this.#meta, args: this.#args };
|
|
136
|
+
const callable = useRef<{ name: string | null; fn: (...args: Args) => Promise<void> } | null>(null);
|
|
137
|
+
if (callable.current?.name !== this.#name) {
|
|
138
|
+
const call = async (...args: Args) => {
|
|
139
|
+
await live.current.run(...args);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
callable.current = {
|
|
143
|
+
name: this.#name,
|
|
144
|
+
fn: this.#name ? tagAction(call, { action: AgenticSurface.fullName(scope, this.#name) }) : call,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const scopeKey = scope.join(".");
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
const spec = declared.current;
|
|
150
|
+
const name = spec?.name;
|
|
151
|
+
if (!spec || !name) return;
|
|
152
|
+
return surface.registerTool(scope, {
|
|
153
|
+
name,
|
|
154
|
+
description: spec.desc,
|
|
155
|
+
settle: spec.meta.settle,
|
|
156
|
+
parameters: StToolBuilder.parametersOf(spec.args),
|
|
157
|
+
|
|
158
|
+
...(spec.meta.confirm === undefined && !name.startsWith("remove")
|
|
159
|
+
? {}
|
|
160
|
+
: {
|
|
161
|
+
confirm: (args: Record<string, unknown>) => {
|
|
162
|
+
const confirm = live.current.meta.confirm ?? name.startsWith("remove");
|
|
163
|
+
return typeof confirm === "function" ? confirm(args) : confirm;
|
|
164
|
+
},
|
|
165
|
+
}),
|
|
166
|
+
...(spec.meta.guard === undefined
|
|
167
|
+
? {}
|
|
168
|
+
: { guard: (args: Record<string, unknown>) => live.current.meta.guard?.(args) ?? true }),
|
|
169
|
+
run: (named) => live.current.run(...(StToolBuilder.positionalOf(name, spec.args, named) as Args)),
|
|
170
|
+
});
|
|
171
|
+
}, [surface, scopeKey, this.#name]);
|
|
172
|
+
return callable.current.fn;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
static parametersOf(args: StToolArg[]): JsonSchema | undefined {
|
|
176
|
+
if (!args.length) return undefined;
|
|
177
|
+
const required = args.filter((arg) => !arg.optional).map((arg) => arg.name);
|
|
178
|
+
return {
|
|
179
|
+
type: "object",
|
|
180
|
+
properties: Object.fromEntries(args.map((arg) => [arg.name, StToolBuilder.#argSchemaOf(arg)])),
|
|
181
|
+
...(required.length ? { required } : {}),
|
|
182
|
+
additionalProperties: false,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
static #argSchemaOf(arg: StToolArg): JsonSchema {
|
|
187
|
+
const schema = StToolBuilder.schemaOf(arg.type);
|
|
188
|
+
return arg.oneOf ? { ...schema, enum: [...arg.oneOf] } : schema;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
static #describable(toolName: string, argName: string, type: ParamFieldType): boolean {
|
|
192
|
+
try {
|
|
193
|
+
StToolBuilder.schemaOf(type);
|
|
194
|
+
return true;
|
|
195
|
+
} catch (error) {
|
|
196
|
+
console.error(
|
|
197
|
+
`st.tool("${toolName}") is not published: its "${argName}" argument is ${
|
|
198
|
+
error instanceof Error ? error.message : String(error)
|
|
199
|
+
}`,
|
|
200
|
+
);
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Scalars and enums only — the value arrives as JSON from a model, so a class instance has no way in. */
|
|
206
|
+
static schemaOf(type: ParamFieldType): JsonSchema {
|
|
207
|
+
if (isEnum(type as Cls)) {
|
|
208
|
+
const enumRef = type as EnumInstance;
|
|
209
|
+
const kind = enumRef.type === String ? "string" : enumRef.type === Int ? "integer" : "number";
|
|
210
|
+
return { type: kind, enum: [...enumRef.values] };
|
|
211
|
+
}
|
|
212
|
+
const scalar = type as typeof PrimitiveScalar;
|
|
213
|
+
if (!PrimitiveRegistry.has(scalar as unknown as Cls))
|
|
214
|
+
throw new Error(`${StToolBuilder.#typeName(type)}, and st.tool takes scalar and enum arguments only.`);
|
|
215
|
+
switch (PrimitiveRegistry.getName(scalar)) {
|
|
216
|
+
case "ID":
|
|
217
|
+
case "String":
|
|
218
|
+
return { type: "string" };
|
|
219
|
+
case "Int":
|
|
220
|
+
return { type: "integer" };
|
|
221
|
+
case "Float":
|
|
222
|
+
return { type: "number" };
|
|
223
|
+
case "Boolean":
|
|
224
|
+
return { type: "boolean" };
|
|
225
|
+
case "Date":
|
|
226
|
+
return { type: "string", format: "date-time" };
|
|
227
|
+
default:
|
|
228
|
+
throw new Error(`the scalar ${PrimitiveRegistry.getName(scalar)}, which st.tool cannot describe.`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
static #typeName(type: ParamFieldType): string {
|
|
233
|
+
const named = type as { name?: string } | null | undefined;
|
|
234
|
+
return named?.name ? `the type ${named.name}` : `${String(type)}`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
static positionalOf(toolName: string, args: StToolArg[], named: Record<string, unknown>): unknown[] {
|
|
238
|
+
return args.map((arg) => {
|
|
239
|
+
const value = named[arg.name];
|
|
240
|
+
if (value === undefined || value === null) {
|
|
241
|
+
if (arg.optional) return null;
|
|
242
|
+
throw new Error(`Missing argument "${arg.name}" for ${toolName}.`);
|
|
243
|
+
}
|
|
244
|
+
return StToolBuilder.checkedValue(toolName, arg.name, arg.type, value, arg.oneOf);
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** What `AgentBridge` does for endpoint arguments, for a component tool's own — nothing on the wire enforces the published schema. */
|
|
249
|
+
static checkedValue(
|
|
250
|
+
toolName: string,
|
|
251
|
+
argName: string,
|
|
252
|
+
type: ParamFieldType,
|
|
253
|
+
value: unknown,
|
|
254
|
+
oneOf?: readonly (string | number)[],
|
|
255
|
+
): unknown {
|
|
256
|
+
const checked = StToolBuilder.#checkedScalar(toolName, argName, type, value);
|
|
257
|
+
if (oneOf && !oneOf.includes(checked as string | number))
|
|
258
|
+
throw new Error(`Argument "${argName}" of ${toolName} must be one of: ${oneOf.join(", ")}.`);
|
|
259
|
+
return checked;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
static #checkedScalar(toolName: string, argName: string, type: ParamFieldType, value: unknown): unknown {
|
|
263
|
+
if (isEnum(type as Cls)) {
|
|
264
|
+
const enumRef = type as EnumInstance;
|
|
265
|
+
if (!enumRef.values.includes(value as never))
|
|
266
|
+
throw new Error(`Argument "${argName}" of ${toolName} must be one of: ${[...enumRef.values].join(", ")}.`);
|
|
267
|
+
return value;
|
|
268
|
+
}
|
|
269
|
+
switch (PrimitiveRegistry.getName(type as typeof PrimitiveScalar)) {
|
|
270
|
+
case "ID":
|
|
271
|
+
case "String":
|
|
272
|
+
if (typeof value !== "string") throw new Error(`Argument "${argName}" of ${toolName} must be a string.`);
|
|
273
|
+
return value;
|
|
274
|
+
case "Int":
|
|
275
|
+
if (!Number.isInteger(value)) throw new Error(`Argument "${argName}" of ${toolName} must be a whole number.`);
|
|
276
|
+
return value;
|
|
277
|
+
case "Float":
|
|
278
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
279
|
+
throw new Error(`Argument "${argName}" of ${toolName} must be a finite number.`);
|
|
280
|
+
return value;
|
|
281
|
+
case "Boolean":
|
|
282
|
+
if (typeof value !== "boolean") throw new Error(`Argument "${argName}" of ${toolName} must be a boolean.`);
|
|
283
|
+
return value;
|
|
284
|
+
case "Date": {
|
|
285
|
+
const parsed = dayjs(value as string | number | Date);
|
|
286
|
+
if (!parsed.isValid()) throw new Error(`Argument "${argName}" of ${toolName} must be an ISO 8601 date string.`);
|
|
287
|
+
return parsed;
|
|
288
|
+
}
|
|
289
|
+
default:
|
|
290
|
+
return value;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StToolBuilder, type StToolMeta } from "./StToolBuilder";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A component tool before it has said what it does: `st.tool("x", { confirm }).desc("…")`.
|
|
5
|
+
*
|
|
6
|
+
* The description is the step that has to happen, so it is the one the type insists on. A model picks a tool by
|
|
7
|
+
* that sentence and by nothing else, and the surface reads it a second time to tell fifty rows publishing one
|
|
8
|
+
* interchangeable verb from two components that happened to pick the same name.
|
|
9
|
+
*/
|
|
10
|
+
export class StToolDraft {
|
|
11
|
+
readonly #name: string | null;
|
|
12
|
+
readonly #meta: StToolMeta;
|
|
13
|
+
|
|
14
|
+
constructor(name: string | null, meta: StToolMeta = {}) {
|
|
15
|
+
this.#name = name;
|
|
16
|
+
this.#meta = meta;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
desc(text: string): StToolBuilder {
|
|
20
|
+
return new StToolBuilder(this.#name, text, this.#meta);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AgentFieldType } from "./AgentValue";
|
|
2
|
+
import type { StExposeMeta } from "./StExposeBuilder";
|
|
3
|
+
import { StExposeDraft } from "./StExposeDraft";
|
|
4
|
+
import type { StStateMeta } from "./StStateBuilder";
|
|
5
|
+
import { StStateDraft } from "./StStateDraft";
|
|
6
|
+
import type { StToolMeta } from "./StToolBuilder";
|
|
7
|
+
import { StToolDraft } from "./StToolDraft";
|
|
8
|
+
|
|
9
|
+
export interface StAgentic {
|
|
10
|
+
/**
|
|
11
|
+
* Local state the in-page agent can read: `.desc()` then `.init()`, which is the hook and returns what
|
|
12
|
+
* `useState` returns. Writes need `set: true` and go through the generated `set<Name>` tool.
|
|
13
|
+
*/
|
|
14
|
+
useState: <T extends AgentFieldType>(name: string | null, type: T, meta?: StStateMeta) => StStateDraft<T>;
|
|
15
|
+
/** A read-only derived value the agent can read while the component is mounted: `.desc()` then `.value()`. */
|
|
16
|
+
expose: <T extends AgentFieldType>(name: string | null, type: T, meta?: StExposeMeta) => StExposeDraft<T>;
|
|
17
|
+
/**
|
|
18
|
+
* A component tool: `.desc()`, then `.arg()` / `.opt()`, chained onto one `.exec()` hook.
|
|
19
|
+
*
|
|
20
|
+
* A falsy name declares the tool without publishing it — the callable still drives the click a person makes.
|
|
21
|
+
* Every one of these ends in a hook, so a conditional surface withholds the name rather than skipping the chain.
|
|
22
|
+
*/
|
|
23
|
+
tool: (name: string | null, meta?: StToolMeta) => StToolDraft;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const stAgentic: StAgentic = {
|
|
27
|
+
useState: (name, type, meta) => new StStateDraft(name, type, meta),
|
|
28
|
+
expose: (name, type, meta) => new StExposeDraft(name, type, meta),
|
|
29
|
+
tool: (name, meta) => new StToolDraft(name, meta),
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/** Idempotent — `StoreRegistry.build` runs once per merged root, always onto the one instance. */
|
|
33
|
+
export const attachAgentic = <T extends object>(instance: T): T & StAgentic => Object.assign(instance, stAgentic);
|