akanjs 3.0.0-beta.17 → 3.0.0-beta.19
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/base/base.ts +1 -1
- package/base/baseEnv.ts +12 -3
- package/base/databaseModes.ts +76 -0
- package/base/index.ts +1 -0
- package/base/primitiveRegistry.ts +27 -7
- package/client/csrTypes.ts +1 -31
- package/client/frameConfig.ts +2 -2
- package/client/route/RootLayoutDefinition.ts +0 -6
- package/client/route/RouteDefinition.ts +1 -13
- package/common/CodeTranscript.ts +13 -2
- package/common/codeAgentProfile.ts +36 -0
- package/common/codeAgentWire.ts +17 -3
- package/common/index.ts +3 -0
- package/common/routeConvention.ts +0 -3
- package/constant/constantRegistry.ts +8 -11
- package/constant/getDefault.ts +21 -2
- package/constant/mask.ts +35 -3
- package/dictionary/agent.dictionary.ts +9 -0
- package/dictionary/base.dictionary.ts +5 -0
- package/document/dataLoader.ts +48 -15
- package/document/database.ts +39 -3
- package/document/loaderInfo.ts +28 -7
- package/document/queryEvaluator.ts +10 -1
- package/fetch/client/fetchClient.ts +14 -12
- package/fetch/client/httpClient.ts +1 -1
- package/index.ts +10 -1
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0001.log +44 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0002.log +42 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0003.log +43 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0004.log +44 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0005.log +50 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0006.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0007.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0008.log +47 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0009.log +47 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0010.log +6 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0011.log +14 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0012.log +6 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0013.log +35 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0014.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0015.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0016.log +47 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0017.log +47 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0018.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0019.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0020.log +47 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0021.log +47 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0022.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0023.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0024.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0025.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0026.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0027.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0028.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0029.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0030.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0031.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0032.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0033.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0034.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0035.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0036.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0037.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0038.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0039.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0040.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0041.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0042.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0043.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0044.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0045.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0046.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0047.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0048.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0049.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0050.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0051.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0052.log +46 -0
- package/local/apps/crossTest/runtime/logs/crossTest-testing-local-2026-09-25-all-0053.log +46 -0
- package/local/apps/serverLifecycle/serverLifecycle-local.db-shm +0 -0
- package/local/apps/serverLifecycle/serverLifecycle-local_solid.db-shm +0 -0
- package/package.json +2 -1
- package/server/akanApp.ts +28 -1
- package/server/akanOption.ts +22 -1
- package/server/akanServer.ts +39 -5
- package/server/artifact/builderRpc.ts +7 -2
- package/server/artifact/ipcTypes.ts +1 -0
- package/server/artifact/routeClientCache.ts +5 -1
- package/server/console.ts +9 -9
- package/server/decorators.ts +3 -64
- package/server/devtools/depsSerializer.ts +1 -4
- package/server/di/diLifecycle.ts +32 -6
- package/server/di/predefinedAdaptor.ts +13 -3
- package/server/head.tsx +60 -0
- package/server/hmr/devHmrController.ts +8 -1
- package/server/imageOptimizer.ts +3 -1
- package/server/mcp/McpDispatcher.ts +7 -5
- package/server/mcp/McpRateLimiter.ts +67 -21
- package/server/mcp/McpRouter.ts +14 -8
- package/server/mcp/PagePromptComposer.ts +6 -2
- package/server/ops/ageEncryption.ts +322 -0
- package/server/ops/appInfo.ts +92 -0
- package/server/ops/opsCommand.ts +120 -0
- package/server/ops/opsRoute.ts +155 -0
- package/server/ops/opsToken.ts +97 -0
- package/server/ops/snapshotJobs.ts +137 -0
- package/server/ops/snapshotRestore.ts +127 -0
- package/server/ops/snapshotTypes.ts +54 -0
- package/server/ops/sqliteFiles.ts +43 -0
- package/server/ops/sqliteSnapshot.ts +153 -0
- package/server/resolver/database.resolver.ts +29 -26
- package/server/resolver/signal.resolver.ts +49 -10
- package/server/routeElementComposer.tsx +3 -3
- package/server/routeTreeBuilder.ts +1 -24
- package/server/routing/soloAppRoutes.ts +5 -0
- package/server/rscWorker.tsx +10 -21
- package/server/rscWorkerHost.ts +9 -1
- package/server/webRouter.ts +23 -11
- package/service/agent.service.ts +8 -1
- package/service/injectInfo.ts +105 -73
- package/service/ipcTypes.ts +3 -0
- package/service/predefinedAdaptor/anthropicLlm.ts +36 -10
- package/service/predefinedAdaptor/cache.adaptor.ts +260 -74
- package/service/predefinedAdaptor/database.adaptor.ts +357 -74
- package/service/predefinedAdaptor/documentTransfer.ts +91 -0
- package/service/predefinedAdaptor/index.ts +2 -0
- package/service/predefinedAdaptor/insightQuery.ts +113 -43
- package/service/predefinedAdaptor/llm.adaptor.ts +33 -0
- package/service/predefinedAdaptor/llmOverflow.ts +73 -0
- package/service/predefinedAdaptor/openaiDialect.ts +23 -2
- package/service/predefinedAdaptor/openaiLlm.ts +11 -17
- package/service/predefinedAdaptor/queue.adaptor.ts +40 -21
- package/service/predefinedAdaptor/schedule.adaptor.ts +69 -8
- package/service/predefinedAdaptor/searchIndex.ts +63 -288
- package/service/predefinedAdaptor/solidCache.adaptor.ts +135 -12
- package/service/predefinedAdaptor/solidPubsub.adaptor.ts +27 -12
- package/service/predefinedAdaptor/solidQueue.adaptor.ts +66 -10
- package/service/predefinedAdaptor/solidSqlite.ts +8 -2
- package/service/predefinedAdaptor/sql/PostgresInsightSession.ts +116 -0
- package/service/predefinedAdaptor/sql/QueryCompiler.ts +47 -19
- package/service/predefinedAdaptor/sql/SqlDocumentStore.ts +256 -60
- package/service/predefinedAdaptor/sql/SqliteInsightSession.ts +89 -0
- package/service/predefinedAdaptor/sql/dialect/postgres.ts +139 -51
- package/service/predefinedAdaptor/sql/dialect/sqlite.ts +17 -13
- package/service/predefinedAdaptor/sql/driver/bunSqlite.ts +29 -4
- package/service/predefinedAdaptor/sql/driver/libsql.ts +26 -12
- package/service/predefinedAdaptor/sql/driver/postgres.ts +13 -7
- package/service/predefinedAdaptor/sql/search/fts5.ts +260 -0
- package/service/predefinedAdaptor/sql/search/mirror.ts +76 -0
- package/service/predefinedAdaptor/sql/search/postgres.ts +455 -0
- package/service/predefinedAdaptor/sql/search/types.ts +54 -0
- package/service/predefinedAdaptor/sql/types.ts +79 -16
- package/service/predefinedAdaptor/sql/values.ts +14 -1
- package/service/predefinedAdaptor/storage.adaptor.ts +22 -6
- package/service/predefinedAdaptor/websocket.adaptor.ts +157 -168
- package/signal/agent.signal.ts +8 -4
- package/signal/agentMeter.ts +49 -0
- package/signal/agentTurnStream.ts +18 -7
- package/signal/endpointCache.ts +75 -0
- package/signal/guard.ts +4 -3
- package/signal/index.ts +1 -0
- package/signal/internal.ts +2 -2
- package/signal/internalArg.ts +7 -0
- package/signal/mcp/McpDocument.ts +1 -1
- package/signal/middleware.ts +0 -77
- package/signal/schema/JsonSchemaBuilder.ts +27 -4
- package/signal/signalContext.ts +17 -16
- package/signal/types.ts +10 -5
- package/store/agent/index.ts +1 -1
- package/store/agentic/AgentValue.ts +9 -6
- package/store/agentic/formFields.ts +3 -0
- package/test/conformance.ts +313 -0
- package/test/index.ts +1 -0
- package/test/sampleOf.ts +19 -2
- package/test/signalTestRuntime.ts +2 -2
- package/test/testServer.ts +64 -12
- package/types/base/baseEnv.d.ts +2 -2
- package/types/base/databaseModes.d.ts +29 -0
- package/types/base/index.d.ts +1 -0
- package/types/base/primitiveRegistry.d.ts +21 -4
- package/types/client/csrTypes.d.ts +1 -31
- package/types/client/route/RootLayoutDefinition.d.ts +0 -1
- package/types/client/route/RouteDefinition.d.ts +1 -3
- package/types/common/codeAgentProfile.d.ts +37 -0
- package/types/common/codeAgentWire.d.ts +11 -1
- package/types/common/index.d.ts +1 -1
- package/types/constant/constantRegistry.d.ts +2 -2
- package/types/constant/getDefault.d.ts +10 -1
- package/types/constant/mask.d.ts +10 -1
- package/types/dictionary/agent.dictionary.d.ts +1 -1
- package/types/dictionary/base.dictionary.d.ts +1 -1
- package/types/dictionary/dictionary.d.ts +9 -9
- package/types/document/dataLoader.d.ts +6 -1
- package/types/document/database.d.ts +15 -3
- package/types/document/loaderInfo.d.ts +9 -4
- package/types/index.d.ts +9 -1
- package/types/server/akanOption.d.ts +10 -1
- package/types/server/artifact/builderRpc.d.ts +2 -1
- package/types/server/artifact/ipcTypes.d.ts +1 -0
- package/types/server/console.d.ts +1 -1
- package/types/server/decorators.d.ts +1 -8
- package/types/server/di/predefinedAdaptor.d.ts +5 -0
- package/types/server/head.d.ts +10 -0
- package/types/server/mcp/McpRateLimiter.d.ts +15 -5
- package/types/server/mcp/McpRouter.d.ts +1 -1
- package/types/server/ops/ageEncryption.d.ts +24 -0
- package/types/server/ops/appInfo.d.ts +36 -0
- package/types/server/ops/opsCommand.d.ts +9 -0
- package/types/server/ops/opsRoute.d.ts +28 -0
- package/types/server/ops/opsToken.d.ts +30 -0
- package/types/server/ops/snapshotJobs.d.ts +25 -0
- package/types/server/ops/snapshotRestore.d.ts +24 -0
- package/types/server/ops/snapshotTypes.d.ts +46 -0
- package/types/server/ops/sqliteFiles.d.ts +10 -0
- package/types/server/ops/sqliteSnapshot.d.ts +31 -0
- package/types/server/resolver/signal.resolver.d.ts +5 -0
- package/types/server/routeElementComposer.d.ts +1 -1
- package/types/server/routing/soloAppRoutes.d.ts +2 -1
- package/types/server/rscWorkerHost.d.ts +3 -1
- package/types/service/agent.service.d.ts +3 -0
- package/types/service/injectInfo.d.ts +26 -14
- package/types/service/ipcTypes.d.ts +6 -0
- package/types/service/predefinedAdaptor/anthropicLlm.d.ts +10 -1
- package/types/service/predefinedAdaptor/cache.adaptor.d.ts +46 -12
- package/types/service/predefinedAdaptor/database.adaptor.d.ts +20 -3
- package/types/service/predefinedAdaptor/documentTransfer.d.ts +17 -0
- package/types/service/predefinedAdaptor/index.d.ts +2 -0
- package/types/service/predefinedAdaptor/insightQuery.d.ts +14 -12
- package/types/service/predefinedAdaptor/llm.adaptor.d.ts +31 -0
- package/types/service/predefinedAdaptor/llmOverflow.d.ts +26 -0
- package/types/service/predefinedAdaptor/openaiDialect.d.ts +14 -1
- package/types/service/predefinedAdaptor/openaiLlm.d.ts +3 -1
- package/types/service/predefinedAdaptor/queue.adaptor.d.ts +12 -7
- package/types/service/predefinedAdaptor/schedule.adaptor.d.ts +7 -2
- package/types/service/predefinedAdaptor/searchIndex.d.ts +12 -25
- package/types/service/predefinedAdaptor/solidCache.adaptor.d.ts +15 -6
- package/types/service/predefinedAdaptor/solidPubsub.adaptor.d.ts +6 -4
- package/types/service/predefinedAdaptor/solidSqlite.d.ts +1 -0
- package/types/service/predefinedAdaptor/sql/PostgresInsightSession.d.ts +23 -0
- package/types/service/predefinedAdaptor/sql/QueryCompiler.d.ts +7 -3
- package/types/service/predefinedAdaptor/sql/SqlDocumentStore.d.ts +11 -2
- package/types/service/predefinedAdaptor/sql/SqliteInsightSession.d.ts +19 -0
- package/types/service/predefinedAdaptor/sql/dialect/postgres.d.ts +20 -10
- package/types/service/predefinedAdaptor/sql/dialect/sqlite.d.ts +5 -2
- package/types/service/predefinedAdaptor/sql/driver/bunSqlite.d.ts +9 -3
- package/types/service/predefinedAdaptor/sql/driver/libsql.d.ts +9 -5
- package/types/service/predefinedAdaptor/sql/driver/postgres.d.ts +4 -4
- package/types/service/predefinedAdaptor/sql/search/fts5.d.ts +33 -0
- package/types/service/predefinedAdaptor/sql/search/mirror.d.ts +20 -0
- package/types/service/predefinedAdaptor/sql/search/postgres.d.ts +54 -0
- package/types/service/predefinedAdaptor/sql/search/types.d.ts +49 -0
- package/types/service/predefinedAdaptor/sql/types.d.ts +73 -15
- package/types/service/predefinedAdaptor/sql/values.d.ts +3 -0
- package/types/service/predefinedAdaptor/storage.adaptor.d.ts +7 -2
- package/types/service/predefinedAdaptor/websocket.adaptor.d.ts +29 -13
- package/types/signal/agent.signal.d.ts +4 -1
- package/types/signal/agentMeter.d.ts +28 -0
- package/types/signal/agentTurnStream.d.ts +6 -1
- package/types/signal/endpointCache.d.ts +19 -0
- package/types/signal/guard.d.ts +4 -3
- package/types/signal/index.d.ts +1 -0
- package/types/signal/internalArg.d.ts +4 -0
- package/types/signal/middleware.d.ts +0 -20
- package/types/signal/schema/JsonSchemaBuilder.d.ts +11 -2
- package/types/signal/signalContext.d.ts +1 -6
- package/types/signal/types.d.ts +10 -5
- package/types/store/agent/index.d.ts +1 -1
- package/types/store/agentic/AgentValue.d.ts +3 -3
- package/types/test/conformance.d.ts +87 -0
- package/types/test/index.d.ts +1 -0
- package/types/test/sampleOf.d.ts +1 -1
- package/types/test/signalTestRuntime.d.ts +1 -1
- package/types/test/testServer.d.ts +4 -3
- package/types/ui/Agent/Chat.d.ts +4 -2
- package/types/ui/Agent/Menu.d.ts +2 -2
- package/types/ui/Button.d.ts +1 -1
- package/types/ui/CsrImage.d.ts +2 -1
- package/types/ui/Data/Item.d.ts +1 -1
- package/types/ui/Link/CsrLink.d.ts +1 -1
- package/types/ui/Link/types.d.ts +2 -0
- package/types/ui/System/CSR.d.ts +2 -2
- package/types/ui/System/Client.d.ts +2 -3
- package/types/ui/System/Common.d.ts +0 -2
- package/types/ui/System/SSR.d.ts +2 -2
- package/types/ui/recipe/inputRecipe.d.ts +1 -1
- package/types/vendor/use-agentic/AgentProgress.d.ts +12 -0
- package/types/vendor/use-agentic/AgentSession.d.ts +11 -1
- package/types/vendor/use-agentic/Compaction.d.ts +42 -5
- package/types/vendor/use-agentic/Transcript.d.ts +2 -0
- package/types/vendor/use-agentic/types.d.ts +29 -0
- package/ui/Agent/Bubble.tsx +47 -1
- package/ui/Agent/Chat.tsx +15 -6
- package/ui/Agent/Menu.tsx +2 -2
- package/ui/Agent/fetchRunner.ts +2 -1
- package/ui/Button.tsx +1 -1
- package/ui/Constant/Doc.tsx +121 -77
- package/ui/Constant/Graph.tsx +11 -3
- package/ui/CsrImage.tsx +9 -5
- package/ui/Data/Item.tsx +1 -1
- package/ui/Field/Choice.tsx +1 -1
- package/ui/Field/Collection.tsx +4 -3
- package/ui/Image.tsx +9 -10
- package/ui/Link/CsrLink.tsx +5 -1
- package/ui/Link/types.ts +2 -0
- package/ui/Portal.tsx +2 -3
- package/ui/Refresh.tsx +1 -3
- package/ui/ScreenNavigator.tsx +6 -4
- package/ui/System/CSR.tsx +1 -9
- package/ui/System/Client.tsx +2 -4
- package/ui/System/Common.tsx +0 -2
- package/ui/System/SSR.tsx +9 -14
- package/ui/recipe/inputRecipe.ts +1 -1
- package/vendor/use-agentic/AgentProgress.ts +13 -1
- package/vendor/use-agentic/AgentSession.ts +119 -27
- package/vendor/use-agentic/Compaction.ts +82 -8
- package/vendor/use-agentic/Transcript.ts +6 -1
- package/vendor/use-agentic/WIRE.md +16 -2
- package/vendor/use-agentic/httpRunner.ts +19 -4
- package/vendor/use-agentic/types.ts +33 -2
- package/webkit/bootCsr.tsx +0 -12
- package/webkit/useCamera.tsx +4 -3
- package/webkit/useCsrValues.ts +3 -3
- package/webkit/useFetch.ts +6 -7
- package/server/metadata.tsx +0 -198
- package/types/server/metadata.d.ts +0 -22
- package/types/ui/System/Gtag.d.ts +0 -4
- package/ui/System/Gtag.tsx +0 -69
package/base/base.ts
CHANGED
|
@@ -166,7 +166,7 @@ export class DataList<Light extends { id: string }> {
|
|
|
166
166
|
return this.values.flatMap(fn);
|
|
167
167
|
}
|
|
168
168
|
sort(fn: (a: Light, b: Light) => number) {
|
|
169
|
-
return new DataList(this.values.sort(fn));
|
|
169
|
+
return new DataList([...this.values].sort(fn));
|
|
170
170
|
}
|
|
171
171
|
filter(fn: (value: Light, idx: number) => boolean) {
|
|
172
172
|
return new DataList(this.values.filter(fn));
|
package/base/baseEnv.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DatabaseModes } from "./databaseModes";
|
|
2
|
+
|
|
1
3
|
type ProcessEnvLike = { env?: Record<string, string | undefined> };
|
|
2
4
|
|
|
3
5
|
const globalWithProcess = globalThis as unknown as { process?: ProcessEnvLike };
|
|
@@ -19,8 +21,6 @@ export type BackendEnv = {
|
|
|
19
21
|
hostname?: string | null;
|
|
20
22
|
port?: number;
|
|
21
23
|
database?: {
|
|
22
|
-
mode?: DatabaseMode;
|
|
23
|
-
driver?: "sqlite" | "libsql" | "postgres";
|
|
24
24
|
sqlite?: {
|
|
25
25
|
filePath?: string;
|
|
26
26
|
journalMode?: string;
|
|
@@ -41,6 +41,7 @@ export type BackendEnv = {
|
|
|
41
41
|
database?: string;
|
|
42
42
|
user?: string;
|
|
43
43
|
password?: string;
|
|
44
|
+
insightUrl?: string;
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
solid?: {
|
|
@@ -51,6 +52,7 @@ export type BackendEnv = {
|
|
|
51
52
|
cleanupIntervalMs?: number;
|
|
52
53
|
queuePollIntervalMs?: number;
|
|
53
54
|
queueLeaseMs?: number;
|
|
55
|
+
queueFailedRetentionMs?: number;
|
|
54
56
|
};
|
|
55
57
|
onCleanup?: () => Promise<void>;
|
|
56
58
|
};
|
|
@@ -133,7 +135,14 @@ export const getEnv = (): ClientEnv => {
|
|
|
133
135
|
appName,
|
|
134
136
|
environment,
|
|
135
137
|
operationMode,
|
|
136
|
-
databaseMode:
|
|
138
|
+
databaseMode:
|
|
139
|
+
typeof window === "undefined"
|
|
140
|
+
? DatabaseModes.settle({
|
|
141
|
+
requested: process.env.AKAN_DATABASE_MODE,
|
|
142
|
+
declared: process.env.AKAN_DATABASE_MODES,
|
|
143
|
+
local: environment === "local" || operationMode === "local",
|
|
144
|
+
})
|
|
145
|
+
: undefined,
|
|
137
146
|
} as const;
|
|
138
147
|
const side = typeof window === "undefined" ? "server" : "client";
|
|
139
148
|
const renderMode = (process.env.AKAN_PUBLIC_RENDER_ENV ?? "csr") as ClientEnv["renderMode"];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { DatabaseMode } from "./baseEnv";
|
|
2
|
+
|
|
3
|
+
export interface DatabaseModeRequest {
|
|
4
|
+
/** `AKAN_DATABASE_MODE`: the mode a deployment names. */
|
|
5
|
+
requested: string | undefined;
|
|
6
|
+
/** `AKAN_DATABASE_MODES`: what the build carries drivers for, first one the default. Unset allows any. */
|
|
7
|
+
declared: string | undefined;
|
|
8
|
+
/** A developer machine, which may leave the mode unnamed when the build carries several. */
|
|
9
|
+
local: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** The database modes, what each runs on, and how a process settles on one. The CLI and the server share it. */
|
|
13
|
+
export class DatabaseModes {
|
|
14
|
+
static readonly all = ["single", "multiple", "cluster"] as const satisfies readonly DatabaseMode[];
|
|
15
|
+
/** Packages a mode imports at runtime. A build carries them for every mode the app declares. */
|
|
16
|
+
static readonly drivers: { [mode in DatabaseMode]: readonly string[] } = {
|
|
17
|
+
single: [],
|
|
18
|
+
multiple: ["bullmq", "ioredis"],
|
|
19
|
+
cluster: ["bullmq", "ioredis", "postgres"],
|
|
20
|
+
};
|
|
21
|
+
static readonly #stores: { [mode in DatabaseMode]: string } = {
|
|
22
|
+
single: "sqlite · solid",
|
|
23
|
+
multiple: "sqlite · redis",
|
|
24
|
+
cluster: "postgres · redis",
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
static describe(mode: DatabaseMode) {
|
|
28
|
+
return `${mode} (${DatabaseModes.#stores[mode]})`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
static parse(value: string, source: string): DatabaseMode {
|
|
32
|
+
const mode = value.trim();
|
|
33
|
+
if ((DatabaseModes.all as readonly string[]).includes(mode)) return mode as DatabaseMode;
|
|
34
|
+
throw new Error(`${source} must be one of ${DatabaseModes.all.join(", ")}, not "${value}"`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static parseList(value: string, source: string): DatabaseMode[] {
|
|
38
|
+
const modes = value
|
|
39
|
+
.split(",")
|
|
40
|
+
.filter((mode) => mode.trim())
|
|
41
|
+
.map((mode) => DatabaseModes.parse(mode, source));
|
|
42
|
+
if (!modes.length) throw new Error(`${source} names no database mode`);
|
|
43
|
+
return [...new Set(modes)];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The mode this process runs in, or the reason it cannot pick one. A deployment that names no mode when the build
|
|
48
|
+
* carries several fails rather than falling back: the fallback would be a SQLite file inside each container, which a
|
|
49
|
+
* cluster deployment would find out about only once its instances disagreed.
|
|
50
|
+
*/
|
|
51
|
+
static resolve({ requested, declared, local }: DatabaseModeRequest): DatabaseMode {
|
|
52
|
+
const modes = declared?.trim() ? DatabaseModes.parseList(declared, "AKAN_DATABASE_MODES") : null;
|
|
53
|
+
if (requested?.trim()) {
|
|
54
|
+
const mode = DatabaseModes.parse(requested, "AKAN_DATABASE_MODE");
|
|
55
|
+
if (modes && !modes.includes(mode))
|
|
56
|
+
throw new Error(
|
|
57
|
+
`AKAN_DATABASE_MODE is ${mode}, but this build carries only ${modes.join(", ")}. Add "${mode}" to database.modes in akan.config.ts and rebuild.`,
|
|
58
|
+
);
|
|
59
|
+
return mode;
|
|
60
|
+
}
|
|
61
|
+
if (!modes) return "single";
|
|
62
|
+
if (modes.length === 1 || local) return modes[0] as DatabaseMode;
|
|
63
|
+
throw new Error(
|
|
64
|
+
`This build runs in ${modes.join(" or ")} mode, and AKAN_DATABASE_MODE names neither. Set it to say which this deployment is.`,
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** `resolve` for readers that cannot fail a boot; the boot itself resolves again and reports the reason. */
|
|
69
|
+
static settle(request: DatabaseModeRequest): DatabaseMode | undefined {
|
|
70
|
+
try {
|
|
71
|
+
return DatabaseModes.resolve(request);
|
|
72
|
+
} catch {
|
|
73
|
+
return undefined;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
package/base/index.ts
CHANGED
|
@@ -11,12 +11,8 @@ export const dayjs = dayjsLib;
|
|
|
11
11
|
export class PrimitiveRegistry {
|
|
12
12
|
static readonly #namePrimitiveMap = new Map<string, typeof PrimitiveScalar>();
|
|
13
13
|
static readonly #primitiveNameMap = new Map<typeof PrimitiveScalar, string>();
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
!overwrite &&
|
|
17
|
-
(PrimitiveRegistry.#namePrimitiveMap.has(scalar.refName) || PrimitiveRegistry.#primitiveNameMap.has(scalar))
|
|
18
|
-
)
|
|
19
|
-
throw new Error(`Scalar ${scalar.refName} already registered`);
|
|
14
|
+
|
|
15
|
+
static register(scalar: typeof PrimitiveScalar) {
|
|
20
16
|
PrimitiveRegistry.#namePrimitiveMap.set(scalar.refName, scalar);
|
|
21
17
|
PrimitiveRegistry.#primitiveNameMap.set(scalar, scalar.refName);
|
|
22
18
|
}
|
|
@@ -42,9 +38,29 @@ export class PrimitiveRegistry {
|
|
|
42
38
|
static getAll(): (typeof PrimitiveScalar)[] {
|
|
43
39
|
return [...PrimitiveRegistry.#namePrimitiveMap.values()];
|
|
44
40
|
}
|
|
41
|
+
/** The agent face `modelRef` declares, or null for anything that is not a registered primitive declaring one. */
|
|
42
|
+
static agentOf(modelRef: unknown): PrimitiveAgentFace | null {
|
|
43
|
+
if (!PrimitiveRegistry.#primitiveNameMap.has(modelRef as typeof PrimitiveScalar)) return null;
|
|
44
|
+
return (modelRef as typeof PrimitiveScalar).agent ?? null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PrimitiveJsonSchema {
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* How an agent — an MCP client or the in-page one — sees a primitive whose stored shape is not the one a model
|
|
54
|
+
* should read or write: `schema` is what it is published as on both sides of a call, and `read` turns a stored or
|
|
55
|
+
* wire value into that shape. There is no `write`, because every argument and every input field already runs
|
|
56
|
+
* through `parseValue`; a primitive that accepts the agent's shape there has taken the write.
|
|
57
|
+
*/
|
|
58
|
+
export interface PrimitiveAgentFace<Value = unknown> {
|
|
59
|
+
schema: PrimitiveJsonSchema;
|
|
60
|
+
read(value: Value): unknown;
|
|
45
61
|
}
|
|
46
62
|
|
|
47
|
-
export type PrimitiveValue = string | number | boolean | Dayjs | Date | Uint8Array | null | undefined;
|
|
63
|
+
export type PrimitiveValue = string | number | boolean | Dayjs | Date | Uint8Array | object | null | undefined;
|
|
48
64
|
export class PrimitiveScalar {
|
|
49
65
|
static refName: string;
|
|
50
66
|
static [SERVER_VALUE]: unknown;
|
|
@@ -52,6 +68,10 @@ export class PrimitiveScalar {
|
|
|
52
68
|
static [DEFAULT_VALUE]: unknown = null;
|
|
53
69
|
static [PURIFIED_VALUE]: unknown = null;
|
|
54
70
|
static [EXAMPLE_VALUE]: unknown = null;
|
|
71
|
+
/** The wire shape, for a primitive the built-in schema table cannot know. Absent, it is published as a string. */
|
|
72
|
+
static jsonSchema?: PrimitiveJsonSchema;
|
|
73
|
+
/** Absent, an agent sees the wire shape. See `PrimitiveAgentFace`. */
|
|
74
|
+
static agent?: PrimitiveAgentFace;
|
|
55
75
|
|
|
56
76
|
static validate(value: PrimitiveValue): boolean {
|
|
57
77
|
return true;
|
package/client/csrTypes.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface PageConfig {
|
|
|
46
46
|
ssr?: SsrRenderMode;
|
|
47
47
|
/**
|
|
48
48
|
* Opt in to guarded RSC page suffix commits when the page does not require
|
|
49
|
-
* head
|
|
49
|
+
* head updates and the retained route chain head is invariant for
|
|
50
50
|
* sibling navigations under the same layout.
|
|
51
51
|
*/
|
|
52
52
|
rscPatchHeadSafe?: boolean;
|
|
@@ -109,7 +109,6 @@ export interface AkanHeadSnapshotV1 {
|
|
|
109
109
|
}
|
|
110
110
|
export interface ResolvedHead {
|
|
111
111
|
node: Head | null | undefined;
|
|
112
|
-
hasExplicitLanguageAlternates: boolean;
|
|
113
112
|
headSnapshot?: AkanHeadSnapshotV1;
|
|
114
113
|
}
|
|
115
114
|
export type ResolveHeadResult = Head | ResolvedHead | null | undefined;
|
|
@@ -163,53 +162,24 @@ export interface WebAppManifest {
|
|
|
163
162
|
screenshots?: WebAppManifestIcon[];
|
|
164
163
|
[key: string]: unknown;
|
|
165
164
|
}
|
|
166
|
-
export interface AkanMetadata {
|
|
167
|
-
title?: string;
|
|
168
|
-
description?: string;
|
|
169
|
-
robots?: string;
|
|
170
|
-
openGraph?: {
|
|
171
|
-
title?: string;
|
|
172
|
-
description?: string;
|
|
173
|
-
type?: string;
|
|
174
|
-
url?: string;
|
|
175
|
-
siteName?: string;
|
|
176
|
-
images?: string | string[];
|
|
177
|
-
};
|
|
178
|
-
twitter?: {
|
|
179
|
-
card?: "summary" | "summary_large_image" | "app" | "player" | (string & {});
|
|
180
|
-
title?: string;
|
|
181
|
-
description?: string;
|
|
182
|
-
images?: string | string[];
|
|
183
|
-
};
|
|
184
|
-
alternates?: {
|
|
185
|
-
canonical?: string;
|
|
186
|
-
languages?: Record<string, string>;
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
export type GenerateMetadata = (props: PageProps) => PromiseOrObject<AkanMetadata | null | undefined>;
|
|
190
165
|
export interface PageModule {
|
|
191
166
|
default?: PageRender;
|
|
192
167
|
pageConfig?: PageConfig;
|
|
193
168
|
head?: Head;
|
|
194
|
-
metadata?: AkanMetadata;
|
|
195
169
|
generateHead?: GenerateHead;
|
|
196
|
-
generateMetadata?: GenerateMetadata;
|
|
197
170
|
Loading?: PageLoadingRender;
|
|
198
171
|
}
|
|
199
172
|
export interface LayoutModule {
|
|
200
173
|
default?: LayoutRender;
|
|
201
174
|
pageConfig?: PageConfig;
|
|
202
175
|
head?: Head;
|
|
203
|
-
metadata?: AkanMetadata;
|
|
204
176
|
generateHead?: GenerateHead;
|
|
205
|
-
generateMetadata?: GenerateMetadata;
|
|
206
177
|
fonts?: ReactFont[];
|
|
207
178
|
manifest?: WebAppManifest;
|
|
208
179
|
theme?: string;
|
|
209
180
|
reconnect?: boolean;
|
|
210
181
|
wsConnect?: boolean;
|
|
211
182
|
layoutStyle?: "mobile" | "web";
|
|
212
|
-
gaTrackingId?: string;
|
|
213
183
|
Loading?: LayoutLoadingRender;
|
|
214
184
|
NotFound?: LayoutNotFoundRender;
|
|
215
185
|
Error?: LayoutErrorRender;
|
package/client/frameConfig.ts
CHANGED
|
@@ -165,8 +165,8 @@ export function resolvePageState({
|
|
|
165
165
|
: (config.gesture ?? false),
|
|
166
166
|
cache: config.cache ?? false,
|
|
167
167
|
ssr: config.ssr ?? "stream",
|
|
168
|
-
topSafeAreaColor: config.topSafeAreaColor ??
|
|
169
|
-
bottomSafeAreaColor: config.bottomSafeAreaColor ??
|
|
168
|
+
topSafeAreaColor: config.topSafeAreaColor ?? defaultPageState.topSafeAreaColor,
|
|
169
|
+
bottomSafeAreaColor: config.bottomSafeAreaColor ?? defaultPageState.bottomSafeAreaColor,
|
|
170
170
|
};
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -12,7 +12,6 @@ export class RootLayoutDefinition<Args extends RouteArgsShape = Record<never, ne
|
|
|
12
12
|
#reconnect?: boolean;
|
|
13
13
|
#wsConnect?: boolean;
|
|
14
14
|
#layoutStyle?: "mobile" | "web";
|
|
15
|
-
#gaTrackingId?: string;
|
|
16
15
|
|
|
17
16
|
fonts(fonts: ReactFont[]) {
|
|
18
17
|
this.#fonts = fonts;
|
|
@@ -38,10 +37,6 @@ export class RootLayoutDefinition<Args extends RouteArgsShape = Record<never, ne
|
|
|
38
37
|
this.#layoutStyle = style;
|
|
39
38
|
return this;
|
|
40
39
|
}
|
|
41
|
-
gaTrackingId(id: string) {
|
|
42
|
-
this.#gaTrackingId = id;
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
40
|
|
|
46
41
|
protected override extendModule(module: PageModule & LayoutModule): PageModule & LayoutModule {
|
|
47
42
|
return {
|
|
@@ -52,7 +47,6 @@ export class RootLayoutDefinition<Args extends RouteArgsShape = Record<never, ne
|
|
|
52
47
|
...(this.#reconnect !== undefined ? { reconnect: this.#reconnect } : {}),
|
|
53
48
|
...(this.#wsConnect !== undefined ? { wsConnect: this.#wsConnect } : {}),
|
|
54
49
|
...(this.#layoutStyle ? { layoutStyle: this.#layoutStyle } : {}),
|
|
55
|
-
...(this.#gaTrackingId ? { gaTrackingId: this.#gaTrackingId } : {}),
|
|
56
50
|
};
|
|
57
51
|
}
|
|
58
52
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { parseAkanI18nEnv } from "akanjs/common";
|
|
10
10
|
import { deserialize } from "akanjs/constant";
|
|
11
11
|
import type { ReactNode } from "react";
|
|
12
|
-
import type {
|
|
12
|
+
import type { Head, LayoutModule, PageConfig, PageModule } from "../csrTypes";
|
|
13
13
|
import { AkanNotFoundError } from "../router";
|
|
14
14
|
import { RouteArgError, type RouteArgInfo, type RouteArgInput, type RouteBaseArgs } from "./routeArgs";
|
|
15
15
|
|
|
@@ -19,7 +19,6 @@ export type RouteKind = "page" | "layout" | "rootLayout";
|
|
|
19
19
|
export const routeDefinitionMarker = Symbol.for("akan.routeDefinition");
|
|
20
20
|
|
|
21
21
|
type HeadStage<Args> = Head | ((args: Args) => PromiseOrObject<Head | null | undefined>);
|
|
22
|
-
type MetadataStage<Args> = AkanMetadata | ((args: Args) => PromiseOrObject<AkanMetadata | null | undefined>);
|
|
23
22
|
|
|
24
23
|
interface RouteRenderProps {
|
|
25
24
|
params: Record<string, string>;
|
|
@@ -46,7 +45,6 @@ export abstract class RouteDefinition<
|
|
|
46
45
|
#config?: PageConfig;
|
|
47
46
|
|
|
48
47
|
#head?: HeadStage<never>;
|
|
49
|
-
#metadata?: MetadataStage<never>;
|
|
50
48
|
#loading?: (args: never) => PromiseOrObject<ReactNode>;
|
|
51
49
|
#render?: (args: never) => PromiseOrObject<ReactNode>;
|
|
52
50
|
|
|
@@ -58,10 +56,6 @@ export abstract class RouteDefinition<
|
|
|
58
56
|
this.#head = head as HeadStage<never>;
|
|
59
57
|
return this;
|
|
60
58
|
}
|
|
61
|
-
metadata(metadata: MetadataStage<RouteBaseArgs & Args>) {
|
|
62
|
-
this.#metadata = metadata as MetadataStage<never>;
|
|
63
|
-
return this;
|
|
64
|
-
}
|
|
65
59
|
loading(render: (args: RouteBaseArgs & Args & Extra) => PromiseOrObject<ReactNode>) {
|
|
66
60
|
this.#loading = render as (args: never) => PromiseOrObject<ReactNode>;
|
|
67
61
|
return this;
|
|
@@ -136,7 +130,6 @@ export abstract class RouteDefinition<
|
|
|
136
130
|
if (!render)
|
|
137
131
|
throw new Error(`[route-convention] a ${this.kind}() chain ends with .render(), and this one has none`);
|
|
138
132
|
const head = this.#head;
|
|
139
|
-
const metadata = this.#metadata;
|
|
140
133
|
const loading = this.#loading;
|
|
141
134
|
const module: PageModule & LayoutModule = {
|
|
142
135
|
default: (async (props: RouteRenderProps) => await render(this.#argsOf(props) as never)) as never,
|
|
@@ -146,11 +139,6 @@ export abstract class RouteDefinition<
|
|
|
146
139
|
: typeof head === "function"
|
|
147
140
|
? { generateHead: async (props: RouteRenderProps) => await head(this.#argsOf(props) as never) }
|
|
148
141
|
: { head }),
|
|
149
|
-
...(metadata === undefined
|
|
150
|
-
? {}
|
|
151
|
-
: typeof metadata === "function"
|
|
152
|
-
? { generateMetadata: async (props: RouteRenderProps) => await metadata(this.#argsOf(props) as never) }
|
|
153
|
-
: { metadata }),
|
|
154
142
|
...(loading
|
|
155
143
|
? {
|
|
156
144
|
Loading: ((props: RouteRenderProps) =>
|
package/common/CodeTranscript.ts
CHANGED
|
@@ -179,6 +179,13 @@ export class CodeTranscript {
|
|
|
179
179
|
case "question":
|
|
180
180
|
this.#question = event.question;
|
|
181
181
|
return this.#push({ kind: "question", id: event.question.questionId, question: event.question });
|
|
182
|
+
case "question_skipped":
|
|
183
|
+
return this.#push({
|
|
184
|
+
kind: "question",
|
|
185
|
+
id: event.question.questionId,
|
|
186
|
+
question: event.question,
|
|
187
|
+
rendered: `(${event.reason})`,
|
|
188
|
+
});
|
|
182
189
|
case "question_resolved":
|
|
183
190
|
if (this.#question?.questionId === event.questionId) this.#question = undefined;
|
|
184
191
|
return this.#patch(event.questionId, (part) => {
|
|
@@ -197,8 +204,12 @@ export class CodeTranscript {
|
|
|
197
204
|
return;
|
|
198
205
|
case "compaction":
|
|
199
206
|
this.#compacting = event.phase === "start";
|
|
200
|
-
if (event.phase === "
|
|
201
|
-
|
|
207
|
+
if (event.phase === "start") return;
|
|
208
|
+
|
|
209
|
+
if ((event.error || event.aborted) && event.reason === "manual") return;
|
|
210
|
+
if (event.error) return this.#notice("warning", event.error);
|
|
211
|
+
if (event.aborted) return this.#notice("info", "Compaction cancelled.");
|
|
212
|
+
return this.#notice("info", `Compacted the conversation (${event.reason}).`);
|
|
202
213
|
case "retry":
|
|
203
214
|
return this.#notice(
|
|
204
215
|
"warning",
|
|
@@ -21,6 +21,22 @@ export type CodeAgentApprovalPolicy = "never" | "writes" | "commands" | "all";
|
|
|
21
21
|
*/
|
|
22
22
|
export type CodeAgentInteractionMode = "await" | "suspend";
|
|
23
23
|
|
|
24
|
+
export interface CodeAgentModelInfo {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
contextWindow?: number;
|
|
28
|
+
/** Whether this is the one the session is running on, which a listing has to mark rather than repeat. */
|
|
29
|
+
current: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** One provider of the model catalogue, and whether a credential for it has been configured. */
|
|
33
|
+
export interface CodeAgentProviderInfo {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
authorized: boolean;
|
|
37
|
+
models: CodeAgentModelInfo[];
|
|
38
|
+
}
|
|
39
|
+
|
|
24
40
|
export interface CodeAgentMcpServerRef {
|
|
25
41
|
name: string;
|
|
26
42
|
transport: "stdio" | "http";
|
|
@@ -29,8 +45,26 @@ export interface CodeAgentMcpServerRef {
|
|
|
29
45
|
args?: string[];
|
|
30
46
|
url?: string;
|
|
31
47
|
env?: Record<string, string>;
|
|
48
|
+
/** Sent on every http request. A server behind a static token needs nothing else. */
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
/**
|
|
51
|
+
* What to use when the server answers `401` and asks for OAuth.
|
|
52
|
+
*
|
|
53
|
+
* Everything here is optional because the spec is discoverable: the challenge names the resource metadata,
|
|
54
|
+
* that names the authorization server, and most hosted servers register a client on demand. It is for the
|
|
55
|
+
* ones that do not — a provider issuing client ids by hand, or one whose scopes cannot be guessed.
|
|
56
|
+
*/
|
|
57
|
+
oauth?: { clientId?: string; clientSecret?: string; scope?: string };
|
|
32
58
|
}
|
|
33
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Where a server stands with its credential.
|
|
62
|
+
*
|
|
63
|
+
* `required` is not a failure: it is a server that answered correctly and said who may talk to it. Reporting
|
|
64
|
+
* it as unreachable would send someone to debug a server that is working exactly as designed.
|
|
65
|
+
*/
|
|
66
|
+
export type CodeAgentMcpAuthState = "none" | "authorized" | "required";
|
|
67
|
+
|
|
34
68
|
/**
|
|
35
69
|
* One declared MCP server, as the session found it.
|
|
36
70
|
*
|
|
@@ -47,6 +81,8 @@ export interface CodeAgentMcpStatus {
|
|
|
47
81
|
tools: string[];
|
|
48
82
|
/** Why it published none, when it published none. */
|
|
49
83
|
error?: string;
|
|
84
|
+
/** Whether a credential was needed, and whether one was held. */
|
|
85
|
+
auth?: CodeAgentMcpAuthState;
|
|
50
86
|
}
|
|
51
87
|
|
|
52
88
|
export interface CodeAgentSubagentBudget {
|
package/common/codeAgentWire.ts
CHANGED
|
@@ -190,10 +190,19 @@ export type CodeAgentEventBody =
|
|
|
190
190
|
}
|
|
191
191
|
| { type: "question"; question: CodeAgentQuestion }
|
|
192
192
|
| { type: "question_resolved"; questionId: string; answer: CodeAgentAnswer; rendered: string }
|
|
193
|
+
/** A question nobody could be asked — no host attached — answered with nothing; the model continued on its own. */
|
|
194
|
+
| { type: "question_skipped"; question: CodeAgentQuestion; reason: "no-host" }
|
|
193
195
|
| { type: "approval"; request: CodeAgentApprovalRequest }
|
|
194
196
|
| { type: "approval_resolved"; approvalId: string; approved: boolean }
|
|
195
197
|
| { type: "context"; used: number; max: number | undefined }
|
|
196
|
-
|
|
198
|
+
/** An `end` carrying neither `error` nor `aborted` is the only one that compacted anything. */
|
|
199
|
+
| {
|
|
200
|
+
type: "compaction";
|
|
201
|
+
phase: "start" | "end";
|
|
202
|
+
reason: "manual" | "threshold" | "overflow";
|
|
203
|
+
error?: string;
|
|
204
|
+
aborted?: boolean;
|
|
205
|
+
}
|
|
197
206
|
| { type: "retry"; attempt: number; maxAttempts: number; delayMs: number; message: string }
|
|
198
207
|
| { type: "queue"; steering: string[]; followUp: string[] }
|
|
199
208
|
| { type: "notice"; level: "info" | "warning" | "error"; message: string }
|
|
@@ -255,6 +264,7 @@ export const codeAgentEventPersistence: { [key in CodeAgentEventType]: "live" |
|
|
|
255
264
|
tool_end: "persist",
|
|
256
265
|
question: "persist",
|
|
257
266
|
question_resolved: "persist",
|
|
267
|
+
question_skipped: "persist",
|
|
258
268
|
approval: "live",
|
|
259
269
|
approval_resolved: "live",
|
|
260
270
|
context: "live",
|
|
@@ -393,14 +403,18 @@ export const codeAgentEventLabel = (event: CodeAgentEventBody): string => {
|
|
|
393
403
|
return `? ${event.question.prompt}`;
|
|
394
404
|
case "question_resolved":
|
|
395
405
|
return `= ${event.rendered}`;
|
|
406
|
+
case "question_skipped":
|
|
407
|
+
return `? ${event.question.prompt} (skipped: ${event.reason})`;
|
|
396
408
|
case "approval":
|
|
397
409
|
return `approve? ${event.request.summary}`;
|
|
398
410
|
case "approval_resolved":
|
|
399
411
|
return event.approved ? "approved" : "denied";
|
|
400
412
|
case "context":
|
|
401
413
|
return `context ${event.used}${event.max ? `/${event.max}` : ""}`;
|
|
402
|
-
case "compaction":
|
|
403
|
-
|
|
414
|
+
case "compaction": {
|
|
415
|
+
const outcome = event.error ? ` — ${event.error}` : event.aborted ? " — cancelled" : "";
|
|
416
|
+
return `compaction ${event.phase} (${event.reason})${outcome}`;
|
|
417
|
+
}
|
|
404
418
|
case "retry":
|
|
405
419
|
return `retry ${event.attempt}/${event.maxAttempts} in ${event.delayMs}ms — ${event.message}`;
|
|
406
420
|
case "queue":
|
package/common/index.ts
CHANGED
|
@@ -21,10 +21,13 @@ export {
|
|
|
21
21
|
type CodeAgentApprovalPolicy,
|
|
22
22
|
type CodeAgentBuiltinTool,
|
|
23
23
|
type CodeAgentInteractionMode,
|
|
24
|
+
type CodeAgentMcpAuthState,
|
|
24
25
|
type CodeAgentMcpServerRef,
|
|
25
26
|
type CodeAgentMcpStatus,
|
|
27
|
+
type CodeAgentModelInfo,
|
|
26
28
|
type CodeAgentPresetName,
|
|
27
29
|
type CodeAgentProfile,
|
|
30
|
+
type CodeAgentProviderInfo,
|
|
28
31
|
type CodeAgentSubagentBudget,
|
|
29
32
|
codeAgentDeniedPaths,
|
|
30
33
|
codeAgentPresets,
|
|
@@ -13,9 +13,7 @@ export const PAGE_ROUTE_EXPORTS: ReadonlySet<string> = new Set([
|
|
|
13
13
|
"default",
|
|
14
14
|
"pageConfig",
|
|
15
15
|
"head",
|
|
16
|
-
"metadata",
|
|
17
16
|
"generateHead",
|
|
18
|
-
"generateMetadata",
|
|
19
17
|
"Loading",
|
|
20
18
|
]);
|
|
21
19
|
export const LAYOUT_ROUTE_EXPORTS: ReadonlySet<string> = new Set([...PAGE_ROUTE_EXPORTS, "NotFound", "Error"]);
|
|
@@ -27,7 +25,6 @@ export const ROOT_LAYOUT_ROUTE_EXPORTS: ReadonlySet<string> = new Set([
|
|
|
27
25
|
"reconnect",
|
|
28
26
|
"wsConnect",
|
|
29
27
|
"layoutStyle",
|
|
30
|
-
"gaTrackingId",
|
|
31
28
|
]);
|
|
32
29
|
/** Root-layout exports that are plain config rather than components, so a PascalCase check cannot allow them. */
|
|
33
30
|
export const RESERVED_ROUTE_CONFIG_EXPORTS: ReadonlySet<string> = new Set(
|
|
@@ -238,16 +238,15 @@ export class ConstantRegistry {
|
|
|
238
238
|
PurifiedModel<Model>
|
|
239
239
|
>;
|
|
240
240
|
}
|
|
241
|
-
static serialize<Value>(modelRef: Cls | Cls[], value: Value, nullable: boolean = false): Value {
|
|
241
|
+
static serialize<Value>(modelRef: Cls | Cls[], value: Value, nullable: boolean = false, of?: Cls | Cls[]): Value {
|
|
242
242
|
if (Array.isArray(value) && Array.isArray(modelRef)) {
|
|
243
243
|
const singleModelRef = modelRef.at(0);
|
|
244
244
|
if (!singleModelRef) throw new Error("No model ref found");
|
|
245
245
|
return value.map((v: object) => ConstantRegistry.serialize(singleModelRef as Cls, v)) as unknown as Value;
|
|
246
246
|
} else if (modelRef === Map && value instanceof Map) {
|
|
247
|
+
if (!of) throw new Error("A Map needs its value type (of) to serialize");
|
|
247
248
|
return Object.fromEntries(
|
|
248
|
-
[...value.entries()].map(([key,
|
|
249
|
-
return [key, ConstantRegistry.serialize(value as Cls, value)];
|
|
250
|
-
}),
|
|
249
|
+
[...value.entries()].map(([key, entry]: [string, unknown]) => [key, ConstantRegistry.serialize(of, entry)]),
|
|
251
250
|
) as unknown as Value;
|
|
252
251
|
} else if (PrimitiveRegistry.has(modelRef as Cls)) {
|
|
253
252
|
return (modelRef as typeof PrimitiveScalar)._serialize(value as PrimitiveValue) as unknown as Value;
|
|
@@ -255,17 +254,15 @@ export class ConstantRegistry {
|
|
|
255
254
|
return serialize(modelRef as ConstantCls, 0, value, "object", { nullable }) as unknown as Value;
|
|
256
255
|
} else throw new Error(`No serialize function for modelRef: ${modelRef}`);
|
|
257
256
|
}
|
|
258
|
-
static deserialize<Value>(modelRef: Cls | Cls[], value: Value, nullable: boolean = false): Value {
|
|
257
|
+
static deserialize<Value>(modelRef: Cls | Cls[], value: Value, nullable: boolean = false, of?: Cls | Cls[]): Value {
|
|
259
258
|
if (Array.isArray(value) && Array.isArray(modelRef)) {
|
|
260
259
|
const singleModelRef = modelRef.at(0);
|
|
261
260
|
if (!singleModelRef) throw new Error("No model ref found");
|
|
262
261
|
return value.map((v: object) => ConstantRegistry.deserialize(singleModelRef as Cls, v)) as unknown as Value;
|
|
263
|
-
} else if (modelRef === Map && value
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}),
|
|
268
|
-
) as unknown as Value;
|
|
262
|
+
} else if (modelRef === Map && value !== null && typeof value === "object") {
|
|
263
|
+
if (!of) throw new Error("A Map needs its value type (of) to deserialize");
|
|
264
|
+
const entries: [string, unknown][] = value instanceof Map ? [...value.entries()] : Object.entries(value);
|
|
265
|
+
return new Map(entries.map(([key, entry]) => [key, ConstantRegistry.deserialize(of, entry)])) as unknown as Value;
|
|
269
266
|
} else if (PrimitiveRegistry.has(modelRef as Cls)) {
|
|
270
267
|
return (modelRef as typeof PrimitiveScalar)._parse(value as PrimitiveValue) as unknown as Value;
|
|
271
268
|
} else if (ConstantRegistry.modelRefNameMap.has(modelRef as Cls)) {
|
package/constant/getDefault.ts
CHANGED
|
@@ -5,7 +5,10 @@ import type { DefaultOf } from "./types";
|
|
|
5
5
|
export interface DefaultPlan {
|
|
6
6
|
/** Fields whose default is a value that can be shared: a primitive, `null`, or the field's own literal. */
|
|
7
7
|
shared: Record<string, unknown>;
|
|
8
|
-
/**
|
|
8
|
+
/**
|
|
9
|
+
* Fields that have to be produced per call — a thunk, a fresh array, a nested scalar record, or a primitive's
|
|
10
|
+
* structured default.
|
|
11
|
+
*/
|
|
9
12
|
perCall: Map<string, () => unknown>;
|
|
10
13
|
}
|
|
11
14
|
|
|
@@ -49,7 +52,23 @@ const buildPlan = (fieldObj: FieldObject): DefaultPlan => {
|
|
|
49
52
|
else if (field.isClass) {
|
|
50
53
|
if (field.isScalar) perCall.set(key, () => getDefault(field.modelRef[FIELD_META]));
|
|
51
54
|
else shared[key] = null;
|
|
52
|
-
} else
|
|
55
|
+
} else {
|
|
56
|
+
const primitiveDefault = (field.modelRef as unknown as typeof PrimitiveScalar)[DEFAULT_VALUE];
|
|
57
|
+
if (isStructured(primitiveDefault)) perCall.set(key, () => structuredClone(primitiveDefault));
|
|
58
|
+
else shared[key] = primitiveDefault;
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
return { shared, perCall };
|
|
55
62
|
};
|
|
63
|
+
|
|
64
|
+
const isStructured = (value: unknown): value is object =>
|
|
65
|
+
typeof value === "object" &&
|
|
66
|
+
value !== null &&
|
|
67
|
+
(Array.isArray(value) || Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A primitive's value is never an identity, so a plain object or array — an empty editor document as a primitive's
|
|
71
|
+
* `DEFAULT_VALUE` — is copied for each use, for the reason an array field default is. An instance (a `Dayjs`, a
|
|
72
|
+
* `Uint8Array`) is handed back as is: its own API is how it changes, and a structured copy would drop its prototype.
|
|
73
|
+
*/
|
|
74
|
+
export const freshPrimitiveValue = <T>(value: T): T => (isStructured(value) ? structuredClone(value) : value);
|