nolo-cli 0.1.29 → 0.1.31

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.
Files changed (329) hide show
  1. package/agent-runtime/agentRecordConfig.ts +0 -2
  2. package/agent-runtime/hostAdapter.ts +0 -1
  3. package/agent-runtime/hostRuntimeCapabilities.ts +7 -0
  4. package/agent-runtime/hostRuntimeConfig.ts +86 -0
  5. package/agent-runtime/index.ts +13 -0
  6. package/agent-runtime/localToolPolicy.ts +13 -6
  7. package/agent-runtime/localWorkspaceTools.ts +333 -30
  8. package/agent-runtime/platformChatProvider.ts +4 -1
  9. package/agent-runtime/runtimeToolPolicy.ts +32 -47
  10. package/agent-runtime/shellCommandPolicy.ts +117 -0
  11. package/agent-runtime/toolGate.ts +38 -0
  12. package/agentCreateCustomCommands.ts +9 -4
  13. package/agentDialogsCommands.ts +4 -3
  14. package/agentDoctorCommands.ts +3 -3
  15. package/agentListCommands.ts +3 -3
  16. package/agentMachineCommands.ts +6 -6
  17. package/agentPullCommand.ts +4 -12
  18. package/agentRecordCommands.ts +5 -3
  19. package/agentRecordHelpers.ts +42 -23
  20. package/agentRunCommand.ts +2 -6
  21. package/agentRunParsing.ts +18 -5
  22. package/agentRuntimeLocal.ts +10 -0
  23. package/agentUnpublishCommands.ts +3 -2
  24. package/ai/agent/agentRunDialogLineage.ts +56 -0
  25. package/ai/agent/agentSlice.ts +45 -10
  26. package/ai/agent/avatarUtils.ts +1 -1
  27. package/ai/agent/buildSystemPrompt.ts +1 -2
  28. package/ai/agent/cliExecutor.ts +330 -19
  29. package/ai/agent/createAgentSchema.ts +22 -0
  30. package/ai/agent/hooks/fetchPublicAgents.ts +14 -39
  31. package/ai/agent/hooks/usePublicAgents.ts +90 -192
  32. package/ai/agent/publicAgentCatalog.ts +359 -0
  33. package/ai/agent/publicAgentIdentity.ts +76 -0
  34. package/ai/agent/server/fetchPublicAgents.ts +21 -46
  35. package/ai/agent/serverOrigin.ts +7 -0
  36. package/ai/agent/streamAgentChatTurn.ts +23 -21
  37. package/ai/agent/streamAgentChatTurnUtils.ts +292 -6
  38. package/ai/agent/types.ts +2 -0
  39. package/ai/agent/web/agentDisplayUtils.ts +171 -0
  40. package/ai/agent/web/useAgentModelAvatarComponent.ts +32 -0
  41. package/ai/ai.locale.ts +8 -0
  42. package/ai/chat/sendOpenAICompletionsRequest.native.ts +15 -0
  43. package/ai/chat/sendOpenAICompletionsRequest.ts +93 -1
  44. package/ai/chat/sendOpenAIResponseRequest.ts +86 -9
  45. package/ai/chat/updateTotalUsage.ts +7 -0
  46. package/ai/llm/deepinfra.ts +30 -15
  47. package/ai/llm/mistral.ts +3 -4
  48. package/ai/llm/providers.ts +2 -0
  49. package/ai/llm/types.ts +15 -0
  50. package/ai/memory/capture.ts +3 -3
  51. package/ai/memory/consolidate.ts +2 -2
  52. package/ai/memory/delete.ts +4 -3
  53. package/ai/memory/query.ts +3 -3
  54. package/ai/memory/remember.ts +2 -2
  55. package/ai/memory/store.ts +3 -3
  56. package/ai/memory/storeShared.ts +3 -2
  57. package/ai/policy/commercialMultiplier.ts +16 -0
  58. package/ai/token/billingAdminAuditEvent.ts +68 -0
  59. package/ai/token/billingAdminAuditEventWriter.ts +41 -0
  60. package/ai/token/billingAnomaly.ts +90 -0
  61. package/ai/token/billingAnomalyLifecycle.ts +54 -0
  62. package/ai/token/billingAnomalyLifecycleWriter.ts +44 -0
  63. package/ai/token/billingAnomalyWriter.ts +41 -0
  64. package/ai/token/calculatePrice.ts +3 -2
  65. package/ai/token/deepinfraReconciliation.ts +153 -0
  66. package/ai/token/deepinfraRequestIdQuery.ts +92 -0
  67. package/ai/token/externalToolCost.ts +54 -41
  68. package/ai/token/missingUsageEstimate.ts +12 -3
  69. package/ai/token/normalizeUsage.ts +45 -5
  70. package/ai/token/openaiReconciliation.ts +188 -0
  71. package/ai/token/providerBillableEvent.ts +84 -0
  72. package/ai/token/providerBillableEventWriter.ts +36 -0
  73. package/ai/token/providerBillingAnomalyDrilldown.ts +308 -0
  74. package/ai/token/providerBillingDrilldown.ts +361 -0
  75. package/ai/token/providerBillingHealthReport.ts +366 -0
  76. package/ai/token/providerCall.ts +144 -0
  77. package/ai/token/providerCallSweeper.ts +168 -0
  78. package/ai/token/providerCallWriter.ts +33 -0
  79. package/ai/token/providerCredential.ts +89 -0
  80. package/ai/token/providerCredentialAnomaly.ts +154 -0
  81. package/ai/token/providerCredentialLifecycle.ts +59 -0
  82. package/ai/token/providerCredentialLifecycleWriter.ts +44 -0
  83. package/ai/token/providerCredentialRegistry.ts +83 -0
  84. package/ai/token/providerCredentialRegistryCommand.ts +97 -0
  85. package/ai/token/providerCredentialRegistryList.ts +124 -0
  86. package/ai/token/providerCredentialRegistryResolver.ts +150 -0
  87. package/ai/token/providerCredentialRegistryWriter.ts +41 -0
  88. package/ai/token/providerCredentialRotationCommand.ts +102 -0
  89. package/ai/token/providerCredentialRuntime.ts +56 -0
  90. package/ai/token/providerDispatchIntent.ts +67 -0
  91. package/ai/token/providerDispatchIntentWriter.ts +36 -0
  92. package/ai/token/providerGateway.ts +260 -0
  93. package/ai/token/providerReconciliation.ts +148 -0
  94. package/ai/token/providerReconciliationLocal.ts +97 -0
  95. package/ai/token/providerReconciliationRunner.ts +165 -0
  96. package/ai/token/providerReconciliationWriter.ts +41 -0
  97. package/ai/token/ratingResult.ts +202 -0
  98. package/ai/token/ratingResultWriter.ts +33 -0
  99. package/ai/token/serverDialogProjection.ts +5 -3
  100. package/ai/token/serverTokenWriter.ts +11 -3
  101. package/ai/token/types.ts +10 -0
  102. package/ai/tools/agent/callAgentTool.ts +3 -4
  103. package/ai/tools/agent/presets/appBuilderPreset.ts +5 -7
  104. package/ai/tools/agent/runStreamingAgentTool.ts +1 -2
  105. package/ai/tools/agent/streamParallelAgentsTool.ts +2 -3
  106. package/ai/tools/readXPostTool.ts +1 -5
  107. package/app/admin/adminPages.ts +9 -0
  108. package/app/i18n/i18n.config.ts +5 -0
  109. package/app/i18n/translations/pricing.locale.ts +397 -0
  110. package/app/utils/desktopAgentRuntimeStatusClient.ts +5 -4
  111. package/app/utils/desktopAgentRuntimeTurnClient.ts +4 -1
  112. package/app/utils/imageUtils.ts +64 -34
  113. package/auth/adminPermissions.ts +18 -0
  114. package/auth/authSlice.ts +26 -12
  115. package/auth/hooks/useFetchUsers.ts +3 -0
  116. package/auth/routes.ts +46 -0
  117. package/auth/server/accessActivity.ts +4 -3
  118. package/auth/server/adminPermissions.ts +43 -0
  119. package/auth/server/adminUsageReport.ts +375 -0
  120. package/auth/server/billingAnomalies.ts +235 -0
  121. package/auth/server/billingUsageReport.ts +41 -2
  122. package/auth/server/creatorEarningCreditConversion.ts +10 -2
  123. package/auth/server/deduct.ts +14 -7
  124. package/auth/server/delete.ts +10 -2
  125. package/auth/server/disable.ts +4 -3
  126. package/auth/server/emailAutomation.ts +7 -5
  127. package/auth/server/emailDbConfig.ts +4 -2
  128. package/auth/server/emailDelivery.ts +24 -20
  129. package/auth/server/emailDeliveryGuards.ts +10 -7
  130. package/auth/server/emailPreferences.ts +6 -4
  131. package/auth/server/emailReport.ts +6 -4
  132. package/auth/server/emailRuntimeConfig.ts +3 -3
  133. package/auth/server/emailScenarioNotifications.ts +9 -8
  134. package/auth/server/enable.ts +4 -3
  135. package/auth/server/getRechargeHistory.ts +3 -2
  136. package/auth/server/getUser.ts +3 -2
  137. package/auth/server/gptProAccess.ts +44 -0
  138. package/auth/server/inviteReward.ts +10 -7
  139. package/auth/server/listusers.ts +6 -4
  140. package/auth/server/login.ts +2 -2
  141. package/auth/server/productEntitlements.ts +7 -4
  142. package/auth/server/productPurchase.ts +10 -2
  143. package/auth/server/providerBillingDrilldown.ts +47 -0
  144. package/auth/server/providerBillingHealth.ts +71 -0
  145. package/auth/server/providerCredentials.ts +136 -0
  146. package/auth/server/recharge.ts +14 -8
  147. package/auth/server/revokeSessions.ts +4 -3
  148. package/auth/server/route.ts +77 -0
  149. package/auth/server/sendEmail.ts +5 -4
  150. package/auth/server/signup.ts +10 -3
  151. package/auth/server/token.ts +53 -55
  152. package/auth/server/tokenUsageBilling.ts +18 -7
  153. package/auth/server/usageManagementAccess.ts +43 -0
  154. package/auth/server/usageReport.ts +59 -0
  155. package/auth/types.ts +12 -0
  156. package/auth/utils.ts +24 -22
  157. package/authCommands.ts +36 -2
  158. package/buildPublish.ts +3 -1
  159. package/buildPublishArtifactAssembly.ts +62 -1
  160. package/buildPublishImportAnalysis.ts +21 -16
  161. package/chat/dialog/dialogLaunchScope.ts +32 -0
  162. package/chat/dialog/objectAssistantRegistry.ts +2 -2
  163. package/chat/dialog/useCreateDialog.ts +1 -1
  164. package/chat/hooks/useChatInput.ts +41 -10
  165. package/chat/messages/messageSlice.ts +5 -1
  166. package/chat/messages/pendingAttachmentParts.ts +28 -2
  167. package/chat/messages/sendFirstMessage.ts +76 -79
  168. package/chat/messages/types.ts +9 -0
  169. package/chat/messages/web/streamingMarkdownModel.ts +41 -0
  170. package/chat/messages/web/useStreamingReveal.ts +91 -0
  171. package/chat/web/messageInputAgentUi.ts +94 -6
  172. package/cliEnvHelpers.ts +68 -13
  173. package/cliRuntimeDoctorReport.ts +193 -0
  174. package/client/agentConfigResolver.test.ts +0 -2
  175. package/client/agentRun.test.ts +171 -10
  176. package/client/agentRun.ts +44 -637
  177. package/client/agentRunInput.ts +10 -0
  178. package/client/agentRunLocalExecutor.ts +179 -0
  179. package/client/agentRunServerTransport.ts +394 -0
  180. package/client/agentRunTaskRunRecorder.ts +176 -0
  181. package/client/localRuntimeAdapter.test.ts +236 -9
  182. package/client/localRuntimeAdapter.ts +221 -23
  183. package/client/localToolPolicy.test.ts +28 -4
  184. package/connector-experimental/daemonLauncher.ts +38 -4
  185. package/connectorRunArtifact.ts +34 -10
  186. package/connectorWebSocketTarget.ts +40 -15
  187. package/core/builtinAgents.ts +155 -11
  188. package/create/space/contentLabels.ts +1 -1
  189. package/create/space/contentTypeMeta.ts +3 -2
  190. package/create/space/sidebarVisibleTypes.ts +27 -0
  191. package/create/space/space.locale.ts +76 -4
  192. package/database/actions/agentReadResolution.ts +2 -8
  193. package/database/actions/read.ts +11 -9
  194. package/database/actions/readAndWait.ts +10 -5
  195. package/database/server/agentDelegation.ts +3 -2
  196. package/database/server/authorityStoreConformance.ts +209 -0
  197. package/database/server/authorityStoreTypes.ts +31 -0
  198. package/database/server/coreDataProxy.ts +1 -1
  199. package/database/server/dataHandlers.ts +13 -5
  200. package/database/server/db.ts +15 -34
  201. package/database/server/delete.ts +88 -71
  202. package/database/server/emailRepository.ts +11 -9
  203. package/database/server/fileService.ts +2 -1
  204. package/database/server/legacyServerDb.ts +58 -0
  205. package/database/server/levelAuthorityStore.ts +75 -0
  206. package/database/server/memoryAuthorityStore.ts +133 -0
  207. package/database/server/patch.ts +13 -12
  208. package/database/server/query.ts +3 -2
  209. package/database/server/read.ts +33 -30
  210. package/database/server/resourceAccess.ts +7 -5
  211. package/database/server/serverStoreFactory.ts +124 -0
  212. package/database/server/spaceMemberAuthority.ts +3 -2
  213. package/database/server/storeBatchCompat.ts +37 -0
  214. package/database/server/testAuthorityStore.ts +76 -0
  215. package/database/server/write.ts +29 -27
  216. package/dialogReadCommands.ts +2 -1
  217. package/dialogStatusCommands.ts +2 -1
  218. package/integrations/anthropic/anthropicModels.ts +12 -12
  219. package/integrations/deepseek/models.ts +67 -67
  220. package/integrations/google/models.ts +111 -53
  221. package/integrations/openai/models.ts +22 -22
  222. package/integrations/xai/models.ts +1 -1
  223. package/localRuntimeDb.ts +39 -2
  224. package/machineCommandPrompts.ts +2 -0
  225. package/machineCommands.ts +193 -62
  226. package/machineStatusCommands.ts +4 -12
  227. package/machineWsRunDispatch.ts +80 -15
  228. package/machineWsSession.ts +46 -2
  229. package/noloReadBridgePrompt.ts +16 -0
  230. package/package.json +114 -21
  231. package/pageCreateCommands.ts +2 -2
  232. package/pageDeleteCommands.ts +3 -3
  233. package/pageReadCommands.ts +3 -3
  234. package/pageUpdateCommands.ts +3 -3
  235. package/render/layout/mainLayoutViewMode.ts +25 -0
  236. package/render/page/server/createPage.ts +3 -1
  237. package/render/page/server/handleCreatePage.ts +2 -11
  238. package/runtimeDoctorCommands.ts +18 -69
  239. package/server/api/methods.ts +34 -12
  240. package/server/api/tableHandlers.ts +6 -3
  241. package/server/authenticateToken.ts +47 -2
  242. package/server/billingLedgerRoutes.ts +15 -0
  243. package/server/buildManifest.ts +54 -0
  244. package/server/coreReadiness.ts +34 -25
  245. package/server/coreRuntime.ts +15 -10
  246. package/server/handlers/activityStatsHandler.ts +5 -2
  247. package/server/handlers/agentEmailRegistrationE2EHandler.ts +25 -23
  248. package/server/handlers/agentRun/agentLookup.ts +1 -7
  249. package/server/handlers/agentRun/autonomousRuntime.ts +11 -10
  250. package/server/handlers/agentRun/builtinAgents.ts +12 -88
  251. package/server/handlers/agentRun/continueDialogContext.ts +15 -3
  252. package/server/handlers/agentRun/{inheritedDialogPrompt.ts → conversationReference.ts} +3 -3
  253. package/server/handlers/agentRun/dialogLookup.ts +4 -3
  254. package/server/handlers/agentRun/index.ts +864 -404
  255. package/server/handlers/agentRun/localRuntimeBootstrap.ts +17 -1
  256. package/server/handlers/agentRun/loop.ts +920 -508
  257. package/server/handlers/agentRun/machineConnector.ts +56 -8
  258. package/server/handlers/agentRun/machineRunAudit.ts +3 -2
  259. package/server/handlers/agentRun/modelUsageToolHandlers.ts +13 -10
  260. package/server/handlers/agentRun/requestContext.ts +12 -8
  261. package/server/handlers/agentRun/runtimeExecutionContext.ts +15 -3
  262. package/server/handlers/agentRun/runtimePreparation.ts +26 -24
  263. package/server/handlers/agentRun/runtimeRouting.ts +25 -40
  264. package/server/handlers/agentRun/runtimeSystemMessages.ts +65 -0
  265. package/server/handlers/agentRun/saveDialog.ts +97 -87
  266. package/server/handlers/agentRun/taskRunToolHandler.ts +9 -7
  267. package/server/handlers/agentRun/toolExecutor.ts +42 -78
  268. package/server/handlers/agentRun/types.ts +2 -1
  269. package/server/handlers/appDeployStatusStore.ts +17 -10
  270. package/server/handlers/appDomainHandler.ts +21 -15
  271. package/server/handlers/appLegacyInfraCleanup.ts +5 -2
  272. package/server/handlers/appSandboxHandler.ts +29 -8
  273. package/server/handlers/appSpaceAccess.ts +15 -8
  274. package/server/handlers/chatHandler.ts +22 -2
  275. package/server/handlers/chatUpstreamRetry.ts +225 -2
  276. package/server/handlers/connector/connectorConnectionRegistry.ts +55 -7
  277. package/server/handlers/connector/connectorWebSocket.ts +14 -10
  278. package/server/handlers/desktopAgentRuntimeAdapter.ts +4 -4
  279. package/server/handlers/desktopAgentRuntimeHostCapabilities.ts +25 -0
  280. package/server/handlers/desktopAgentRuntimeReadiness.ts +62 -0
  281. package/server/handlers/desktopAgentRuntimeStatusHandler.ts +38 -30
  282. package/server/handlers/desktopAgentRuntimeTurnHandler.ts +7 -3
  283. package/server/handlers/desktopAgentRuntimeTurnService.ts +39 -45
  284. package/server/handlers/desktopLlamaRuntimeHandler.ts +85 -51
  285. package/server/handlers/desktopUpdaterHandler.ts +132 -24
  286. package/server/handlers/favoriteHandlers.ts +8 -2
  287. package/server/handlers/getDialogBillingHandler.ts +4 -3
  288. package/server/handlers/getTransactionsHandler.ts +5 -2
  289. package/server/handlers/machines/machineBinding.ts +1 -0
  290. package/server/handlers/machines/machineHandlers.ts +0 -14
  291. package/server/handlers/machines/machineInstallAssets.ts +4 -2
  292. package/server/handlers/notificationEmitter.ts +5 -3
  293. package/server/handlers/notificationsHandler.ts +5 -2
  294. package/server/handlers/providerCallsRecentHandler.ts +234 -0
  295. package/server/handlers/providerReconciliationRunHandler.ts +180 -0
  296. package/server/handlers/providerRequestIdsHandler.ts +105 -0
  297. package/server/handlers/tableAccess.ts +6 -2
  298. package/server/handlers/tableToolHandlers.ts +28 -14
  299. package/server/handlers/userSecretsHandler.ts +17 -6
  300. package/server/handlers/versionHandler.ts +9 -4
  301. package/server/handlers/versionStore.ts +18 -10
  302. package/server/html/ssrPreload.ts +5 -3
  303. package/server/payments/crypto/cryptoUsdcBasePaymentProvider.ts +11 -8
  304. package/server/payments/crypto/cryptoUsdcBaseScanner.ts +12 -7
  305. package/server/payments/crypto/cryptoUsdtTronPaymentProvider.ts +11 -8
  306. package/server/payments/crypto/cryptoUsdtTronScanner.ts +9 -7
  307. package/server/payments/waffo/waffoPaymentProvider.ts +12 -9
  308. package/server/runtimeRole.ts +15 -0
  309. package/server/scheduler/scheduledTaskRuntime.ts +4 -2
  310. package/server/scheduler/schedulerService.ts +2 -2
  311. package/server/taskRunBridgeRoutes.ts +8 -5
  312. package/share/server/fetchCommunityShares.ts +1 -1
  313. package/share/server/helpers.ts +19 -17
  314. package/share/server/importShare.ts +9 -13
  315. package/share/server/listCommunityShares.ts +4 -4
  316. package/share/server/purchaseDoc.ts +8 -16
  317. package/share/server/readCommunityShareCover.ts +3 -2
  318. package/share/server/readSharedTable.ts +14 -13
  319. package/share/server/tableReplication.ts +42 -39
  320. package/spaceAttachCommands.ts +135 -0
  321. package/spaceCategoryCommands.ts +6 -6
  322. package/spaceCommands.ts +3 -3
  323. package/spaceDeleteCommands.ts +2 -2
  324. package/spaceInternalCommandEntries.ts +2 -0
  325. package/spaceReadCommands.ts +3 -3
  326. package/tableMetaCommands.ts +2 -2
  327. package/taskRunCommand.ts +11 -0
  328. package/ai/agent/runtimeServerBase.ts +0 -37
  329. package/server/handlers/desktopAgentRuntimeHostFacts.ts +0 -40
@@ -0,0 +1,76 @@
1
+ import type {
2
+ AuthorityBatchOperation,
3
+ AuthorityStore,
4
+ } from "./authorityStoreTypes";
5
+
6
+ type BatchWriterLike = {
7
+ put(key: string, value: unknown): void;
8
+ del(key: string): void;
9
+ write(): Promise<void>;
10
+ };
11
+
12
+ type LevelLikeForTests = {
13
+ readonly location?: string;
14
+ readonly status?: string;
15
+ open?(): Promise<void>;
16
+ close?(): Promise<void>;
17
+ get<T = any>(key: string): Promise<T>;
18
+ put(key: string, value: unknown): Promise<void>;
19
+ del(key: string): Promise<void>;
20
+ batch(ops: AuthorityBatchOperation[]): Promise<void>;
21
+ batch(): BatchWriterLike;
22
+ iterator(
23
+ options?: {
24
+ gte?: string;
25
+ lte?: string;
26
+ lt?: string;
27
+ reverse?: boolean;
28
+ }
29
+ ): AsyncIterableIterator<[string, unknown]>;
30
+ };
31
+
32
+ export function createTestAuthorityStore(levelDb: LevelLikeForTests): AuthorityStore {
33
+ return {
34
+ get location() {
35
+ return levelDb.location;
36
+ },
37
+ get status() {
38
+ return levelDb.status;
39
+ },
40
+ async open() {
41
+ await levelDb.open?.();
42
+ },
43
+ async close() {
44
+ await levelDb.close?.();
45
+ },
46
+ async get<T = any>(key: string) {
47
+ return levelDb.get<T>(key);
48
+ },
49
+ async put(key: string, value: unknown) {
50
+ await levelDb.put(key, value);
51
+ },
52
+ async del(key: string) {
53
+ await levelDb.del(key);
54
+ },
55
+ async batchWrite(ops: AuthorityBatchOperation[]) {
56
+ await levelDb.batch(ops);
57
+ },
58
+ createBatch() {
59
+ const batch = levelDb.batch();
60
+ return {
61
+ put(key: string, value: unknown) {
62
+ batch.put(key, value);
63
+ },
64
+ del(key: string) {
65
+ batch.del(key);
66
+ },
67
+ async write() {
68
+ await batch.write();
69
+ },
70
+ };
71
+ },
72
+ iterator(options = {}) {
73
+ return levelDb.iterator(options);
74
+ },
75
+ };
76
+ }
@@ -2,10 +2,10 @@
2
2
 
3
3
  import { logger } from "../../auth/server/shared";
4
4
  import { DataType } from "../../create/types";
5
- import serverDb, { ensureServerDbOpen } from "./db";
6
- import { handleToken, handleCybot } from "./dataHandlers";
7
- import { handleTransaction } from "./handleTransaction";
8
- import { handleToken as handleAuthToken } from "../../auth/server/token";
5
+ import { getServerAuthorityStore } from "./db";
6
+ import { handleToken, handleCybot } from "./dataHandlers";
7
+ import { handleTransaction } from "./handleTransaction";
8
+ import { handleToken as handleAuthToken } from "../../auth/server/token";
9
9
  import {
10
10
  CYBOT_READONLY_MESSAGE,
11
11
  isCybotReadOnlyMutation,
@@ -18,10 +18,11 @@ import { normalizeRecordIdentityForWrite } from "./recordIdentity";
18
18
  import {
19
19
  bootstrapReplicatedTable,
20
20
  findActiveLiveShareByTable,
21
- patchShareMeta,
22
- reconcileReplicaTable,
23
- replicateSharedTableMutation,
24
- } from "../../share/server/tableReplication";
21
+ patchShareMeta,
22
+ reconcileReplicaTable,
23
+ replicateSharedTableMutation,
24
+ } from "../../share/server/tableReplication";
25
+ import { ensureDbOpen } from "./ensureDbOpen";
25
26
 
26
27
  const getRequestOrigin = (req: any): string => {
27
28
  try {
@@ -137,9 +138,10 @@ const bootstrapLiveShareFromWrite = async (
137
138
  });
138
139
  };
139
140
 
140
- export const handleWrite = async (req: any, res: any) => {
141
- // 1. 鉴权:从 token 中还原用户
142
- req.user = await handleAuthToken(req, res);
141
+ export const handleWrite = async (req: any, res: any) => {
142
+ const store = getServerAuthorityStore();
143
+ // 1. 鉴权:从 token 中还原用户
144
+ req.user = await handleAuthToken(req, res);
143
145
 
144
146
  const { user } = req;
145
147
  const actionUserId = user?.userId;
@@ -194,13 +196,13 @@ export const handleWrite = async (req: any, res: any) => {
194
196
  return res.status(400).json({
195
197
  message: "local data is not allowed.",
196
198
  });
197
- }
198
-
199
- // ⭐ 确保 LevelDB 已打开(后面要 get/put)
200
- await ensureServerDbOpen();
201
-
202
- // 校验当前操作用户是否存在
203
- const userExist = await serverDb.get(`user:${actionUserId}`);
199
+ }
200
+
201
+ // ⭐ 确保 LevelDB 已打开(后面要 get/put)
202
+ await ensureDbOpen(store);
203
+
204
+ // 校验当前操作用户是否存在
205
+ const userExist = await store.get(`user:${actionUserId}`);
204
206
  if (!userExist) {
205
207
  logger.warn({
206
208
  event: "write_permission_denied",
@@ -312,15 +314,15 @@ export const handleWrite = async (req: any, res: any) => {
312
314
  }
313
315
  }
314
316
 
315
- const batch = serverDb.batch();
316
- batch.put(customKey, data);
317
- for (const ik of indexKeys) {
318
- batch.put(ik, customKey);
319
- }
320
- await batch.write();
321
- } else {
322
- await serverDb.put(customKey, data);
323
- }
317
+ const batch = store.createBatch();
318
+ batch.put(customKey, data);
319
+ for (const ik of indexKeys) {
320
+ batch.put(ik, customKey);
321
+ }
322
+ await batch.write();
323
+ } else {
324
+ await store.put(customKey, data);
325
+ }
324
326
 
325
327
  if (
326
328
  customKey.startsWith("share-") &&
@@ -60,7 +60,7 @@ export async function runDialogReadCommand(
60
60
  return args[0] ? 0 : 1;
61
61
  }
62
62
 
63
- const authToken = resolveAuthToken(env);
63
+ const authToken = resolveAuthToken(args, env);
64
64
  const fetchImpl = deps.fetchImpl ?? fetch;
65
65
  const fallbackFetchImpl = deps.fallbackFetchImpl;
66
66
 
@@ -68,6 +68,7 @@ export async function runDialogReadCommand(
68
68
  const { base, dialogId, userId, spaceId } = parseDialogInputForCli(parsedArgs.rawInput, env);
69
69
  const dialogKey = `dialog-${userId}-${dialogId}`;
70
70
  const candidateBases = resolveServerCandidates(
71
+ args,
71
72
  {
72
73
  ...env,
73
74
  BASE_URL: env.READ_DIALOG_BASE?.trim() || base || env.BASE_URL,
@@ -31,7 +31,7 @@ export async function runDialogStatusCommand(
31
31
  return rawInput ? 0 : 1;
32
32
  }
33
33
 
34
- const authToken = resolveAuthToken(env);
34
+ const authToken = resolveAuthToken(args, env);
35
35
  const fetchImpl = deps.fetchImpl ?? fetch;
36
36
  const fallbackFetchImpl = deps.fallbackFetchImpl;
37
37
 
@@ -39,6 +39,7 @@ export async function runDialogStatusCommand(
39
39
  const { base, dialogId, userId } = parseDialogInputForCli(rawInput, env);
40
40
  const dialogKey = `dialog-${userId}-${dialogId}`;
41
41
  const candidateBases = resolveServerCandidates(
42
+ args,
42
43
  {
43
44
  ...env,
44
45
  BASE_URL: env.READ_DIALOG_BASE?.trim() || base || env.BASE_URL,
@@ -10,10 +10,10 @@ export const anthropicModels: Model[] = [
10
10
  contextWindow: 200000,
11
11
  maxOutputTokens: 8192,
12
12
  price: {
13
- input: 24.0, // $3/MTok * 8
14
- output: 120.0, // $15/MTok * 8
15
- cachingWrite: 30.0, // $3.75/MTok * 8
16
- cachingRead: 2.4, // $0.30/MTok * 8
13
+ input: 27.0, // $3/MTok * 9
14
+ output: 135.0, // $15/MTok * 9
15
+ cachingWrite: 33.75, // $3.75/MTok * 9
16
+ cachingRead: 2.7, // $0.30/MTok * 9
17
17
  },
18
18
  },
19
19
  {
@@ -24,10 +24,10 @@ export const anthropicModels: Model[] = [
24
24
  contextWindow: 200000,
25
25
  maxOutputTokens: 8192,
26
26
  price: {
27
- input: 24.0, // $3/MTok * 8
28
- output: 120.0, // $15/MTok * 8
29
- cachingWrite: 30.0, // $3.75/MTok * 8
30
- cachingRead: 2.4, // $0.30/MTok * 8
27
+ input: 27.0, // $3/MTok * 9
28
+ output: 135.0, // $15/MTok * 9
29
+ cachingWrite: 33.75, // $3.75/MTok * 9
30
+ cachingRead: 2.7, // $0.30/MTok * 9
31
31
  },
32
32
  },
33
33
  {
@@ -38,10 +38,10 @@ export const anthropicModels: Model[] = [
38
38
  contextWindow: 200000,
39
39
  maxOutputTokens: 8192,
40
40
  price: {
41
- input: 6.4, // $0.80/MTok * 8
42
- output: 32.0, // $4/MTok * 8
43
- cachingWrite: 8.0, // $1/MTok * 8
44
- cachingRead: 0.64, // $0.08/MTok * 8
41
+ input: 7.2, // $0.80/MTok * 9
42
+ output: 36.0, // $4/MTok * 9
43
+ cachingWrite: 9.0, // $1/MTok * 9
44
+ cachingRead: 0.72, // $0.08/MTok * 9
45
45
  },
46
46
  },
47
47
  ];
@@ -1,67 +1,67 @@
1
- import { Model } from "../../ai/llm/types";
2
-
3
- export const deepSeekModels: Model[] = [
4
- {
5
- name: "deepseek-v4-flash",
6
- displayName: "DeepSeek V4 Flash",
7
- hasVision: false,
8
- contextWindow: 1_000_000,
9
- maxOutputTokens: 384_000,
10
- jsonOutput: true,
11
- fnCall: true,
12
- supportsTool: true,
13
- supportsReasoningEffort: true,
14
- price: {
15
- input: 0.14 * 8,
16
- inputCacheHit: 0.0028 * 8,
17
- output: 0.28 * 8,
18
- },
19
- },
20
- {
21
- name: "deepseek-v4-pro",
22
- displayName: "DeepSeek V4 Pro",
23
- hasVision: false,
24
- contextWindow: 1_000_000,
25
- maxOutputTokens: 384_000,
26
- jsonOutput: true,
27
- fnCall: true,
28
- supportsTool: true,
29
- supportsReasoningEffort: true,
30
- price: {
31
- input: 0.435 * 8,
32
- inputCacheHit: 0.003625 * 8,
33
- output: 0.87 * 8,
34
- },
35
- },
36
- {
37
- name: "deepseek-chat",
38
- displayName: "DeepSeek Chat (V4 Flash alias)",
39
- hasVision: false,
40
- contextWindow: 1_000_000,
41
- maxOutputTokens: 384_000,
42
- jsonOutput: true,
43
- fnCall: true,
44
- supportsTool: true,
45
- price: {
46
- input: 0.14 * 8,
47
- inputCacheHit: 0.0028 * 8,
48
- output: 0.28 * 8,
49
- },
50
- },
51
- {
52
- name: "deepseek-reasoner",
53
- displayName: "DeepSeek Reasoner (V4 Flash alias)",
54
- hasVision: false,
55
- contextWindow: 1_000_000,
56
- maxOutputTokens: 384_000,
57
- jsonOutput: true,
58
- fnCall: true,
59
- supportsTool: true,
60
- supportsReasoningEffort: true,
61
- price: {
62
- input: 0.14 * 8,
63
- inputCacheHit: 0.0028 * 8,
64
- output: 0.28 * 8,
65
- },
66
- },
67
- ];
1
+ import { Model } from "../../ai/llm/types";
2
+
3
+ export const deepSeekModels: Model[] = [
4
+ {
5
+ name: "deepseek-v4-flash",
6
+ displayName: "DeepSeek V4 Flash",
7
+ hasVision: false,
8
+ contextWindow: 1_000_000,
9
+ maxOutputTokens: 384_000,
10
+ jsonOutput: true,
11
+ fnCall: true,
12
+ supportsTool: true,
13
+ supportsReasoningEffort: true,
14
+ price: {
15
+ input: 0.14 * 8,
16
+ inputCacheHit: 0.0028 * 8,
17
+ output: 0.28 * 8,
18
+ },
19
+ },
20
+ {
21
+ name: "deepseek-v4-pro",
22
+ displayName: "DeepSeek V4 Pro",
23
+ hasVision: false,
24
+ contextWindow: 1_000_000,
25
+ maxOutputTokens: 384_000,
26
+ jsonOutput: true,
27
+ fnCall: true,
28
+ supportsTool: true,
29
+ supportsReasoningEffort: true,
30
+ price: {
31
+ input: 0.435 * 8,
32
+ inputCacheHit: 0.003625 * 8,
33
+ output: 0.87 * 8,
34
+ },
35
+ },
36
+ {
37
+ name: "deepseek-chat",
38
+ displayName: "DeepSeek Chat (V4 Flash alias)",
39
+ hasVision: false,
40
+ contextWindow: 1_000_000,
41
+ maxOutputTokens: 384_000,
42
+ jsonOutput: true,
43
+ fnCall: true,
44
+ supportsTool: true,
45
+ price: {
46
+ input: 0.14 * 8,
47
+ inputCacheHit: 0.0028 * 8,
48
+ output: 0.28 * 8,
49
+ },
50
+ },
51
+ {
52
+ name: "deepseek-reasoner",
53
+ displayName: "DeepSeek Reasoner (V4 Flash alias)",
54
+ hasVision: false,
55
+ contextWindow: 1_000_000,
56
+ maxOutputTokens: 384_000,
57
+ jsonOutput: true,
58
+ fnCall: true,
59
+ supportsTool: true,
60
+ supportsReasoningEffort: true,
61
+ price: {
62
+ input: 0.14 * 8,
63
+ inputCacheHit: 0.0028 * 8,
64
+ output: 0.28 * 8,
65
+ },
66
+ },
67
+ ];
@@ -25,6 +25,8 @@ const createGoogleImageModel = ({
25
25
  imageOutputTokenEstimateBySize,
26
26
  maxOutputTokens,
27
27
  contextWindow,
28
+ imageGenerationWaitTimeSeconds,
29
+ imageGenerationProfiles,
28
30
  }: {
29
31
  name: string;
30
32
  displayName: string;
@@ -34,6 +36,8 @@ const createGoogleImageModel = ({
34
36
  imageOutputTokenEstimateBySize: NonNullable<Model["imageOutputTokenEstimateBySize"]>;
35
37
  maxOutputTokens: number;
36
38
  contextWindow: number;
39
+ imageGenerationWaitTimeSeconds?: Model["imageGenerationWaitTimeSeconds"];
40
+ imageGenerationProfiles?: Model["imageGenerationProfiles"];
37
41
  }): Model => ({
38
42
  name,
39
43
  displayName,
@@ -54,6 +58,8 @@ const createGoogleImageModel = ({
54
58
  imageOutputTokenEstimateBySize,
55
59
  maxOutputTokens,
56
60
  contextWindow,
61
+ imageGenerationWaitTimeSeconds,
62
+ imageGenerationProfiles,
57
63
  supportsTool: false,
58
64
  });
59
65
 
@@ -70,10 +76,10 @@ export const googleModels: Model[] = [
70
76
  supportsTool: true,
71
77
  supportsReasoningEffort: true,
72
78
  price: {
73
- input: 1.25 * 8,
74
- output: 10 * 8,
75
- cachingWrite: 0.2 * 8,
76
- cachingRead: 0.2 * 8,
79
+ input: 1.25 * 7,
80
+ output: 10 * 7,
81
+ cachingWrite: 0.2 * 7,
82
+ cachingRead: 0.2 * 7,
77
83
  },
78
84
  pricingStrategy: {
79
85
  type: "tiered_context",
@@ -81,10 +87,10 @@ export const googleModels: Model[] = [
81
87
  {
82
88
  minContext: 200001,
83
89
  price: {
84
- input: 2.5 * 8,
85
- output: 15 * 8,
86
- cachingWrite: 0.25 * 8,
87
- cachingRead: 0.25 * 8,
90
+ input: 2.5 * 7,
91
+ output: 15 * 7,
92
+ cachingWrite: 0.25 * 7,
93
+ cachingRead: 0.25 * 7,
88
94
  },
89
95
  },
90
96
  ],
@@ -102,10 +108,10 @@ export const googleModels: Model[] = [
102
108
  supportsTool: true,
103
109
  supportsReasoningEffort: true,
104
110
  price: {
105
- input: 0.3 * 8,
106
- output: 2.5 * 8,
107
- cachingWrite: 0.2 * 8,
108
- cachingRead: 0.2 * 8,
111
+ input: 0.3 * 7,
112
+ output: 2.5 * 7,
113
+ cachingWrite: 0.2 * 7,
114
+ cachingRead: 0.2 * 7,
109
115
  },
110
116
  },
111
117
  {
@@ -120,10 +126,10 @@ export const googleModels: Model[] = [
120
126
  maxOutputTokens: 4096,
121
127
  supportsTool: true,
122
128
  price: {
123
- input: 0.1 * 8,
124
- output: 0.4 * 8,
125
- cachingWrite: 0.2 * 8,
126
- cachingRead: 0.2 * 8,
129
+ input: 0.1 * 7,
130
+ output: 0.4 * 7,
131
+ cachingWrite: 0.2 * 7,
132
+ cachingRead: 0.2 * 7,
127
133
  },
128
134
  },
129
135
  {
@@ -139,10 +145,10 @@ export const googleModels: Model[] = [
139
145
  supportsTool: true,
140
146
  supportsReasoningEffort: true,
141
147
  price: {
142
- input: 1.5 * 8,
143
- output: 9 * 8,
144
- cachingWrite: 0.15 * 8,
145
- cachingRead: 0.15 * 8,
148
+ input: 1.5 * 7,
149
+ output: 9 * 7,
150
+ cachingWrite: 0.15 * 7,
151
+ cachingRead: 0.15 * 7,
146
152
  },
147
153
  serviceTierPriceMultipliers: {
148
154
  batch: { inputOutput: 0.5, cache: 0.5 },
@@ -159,10 +165,10 @@ export const googleModels: Model[] = [
159
165
  maxOutputTokens: 65500,
160
166
  supportsTool: true,
161
167
  price: {
162
- input: 0.25 * 8,
163
- output: 1.5 * 8,
164
- cachingWrite: 0.025 * 8,
165
- cachingRead: 0.025 * 8,
168
+ input: 0.25 * 7,
169
+ output: 1.5 * 7,
170
+ cachingWrite: 0.025 * 7,
171
+ cachingRead: 0.025 * 7,
166
172
  },
167
173
  serviceTierPriceMultipliers: {
168
174
  batch: { inputOutput: 0.5, cache: 0.5 },
@@ -180,10 +186,10 @@ export const googleModels: Model[] = [
180
186
  supportsTool: true,
181
187
  supportsReasoningEffort: true,
182
188
  price: {
183
- input: 0.5 * 8,
184
- output: 3 * 8,
185
- cachingWrite: 0.05 * 8,
186
- cachingRead: 0.05 * 8,
189
+ input: 0.5 * 7,
190
+ output: 3 * 7,
191
+ cachingWrite: 0.05 * 7,
192
+ cachingRead: 0.05 * 7,
187
193
  },
188
194
  serviceTierPriceMultipliers: {
189
195
  priority: { inputOutput: 1.8, cache: 1.8 },
@@ -202,10 +208,10 @@ export const googleModels: Model[] = [
202
208
  supportsTool: true,
203
209
  supportsReasoningEffort: true,
204
210
  price: {
205
- input: 2 * 8,
206
- output: 12 * 8,
207
- cachingWrite: 0.2 * 8,
208
- cachingRead: 0.2 * 8,
211
+ input: 2 * 7,
212
+ output: 12 * 7,
213
+ cachingWrite: 0.2 * 7,
214
+ cachingRead: 0.2 * 7,
209
215
  },
210
216
  pricingStrategy: {
211
217
  type: "tiered_context",
@@ -213,10 +219,10 @@ export const googleModels: Model[] = [
213
219
  {
214
220
  minContext: 200001,
215
221
  price: {
216
- input: 4 * 8,
217
- output: 18 * 8,
218
- cachingWrite: 0.4 * 8,
219
- cachingRead: 0.4 * 8,
222
+ input: 4 * 7,
223
+ output: 18 * 7,
224
+ cachingWrite: 0.4 * 7,
225
+ cachingRead: 0.4 * 7,
220
226
  },
221
227
  },
222
228
  ],
@@ -232,10 +238,10 @@ export const googleModels: Model[] = [
232
238
  supportsTool: true,
233
239
  supportsReasoningEffort: true,
234
240
  price: {
235
- input: 2 * 8,
236
- output: 12 * 8,
237
- cachingRead: 0.2 * 8,
238
- cachingWrite: 0.2 * 8,
241
+ input: 2 * 7,
242
+ output: 12 * 7,
243
+ cachingRead: 0.2 * 7,
244
+ cachingWrite: 0.2 * 7,
239
245
  },
240
246
  serviceTierPriceMultipliers: {
241
247
  priority: { inputOutput: 1.8, cache: 1.8 },
@@ -246,10 +252,10 @@ export const googleModels: Model[] = [
246
252
  {
247
253
  minContext: 200001,
248
254
  price: {
249
- input: 4 * 8,
250
- output: 18 * 8,
251
- cachingRead: 0.4 * 8,
252
- cachingWrite: 0.4 * 8,
255
+ input: 4 * 7,
256
+ output: 18 * 7,
257
+ cachingRead: 0.4 * 7,
258
+ cachingWrite: 0.4 * 7,
253
259
  },
254
260
  },
255
261
  ],
@@ -258,9 +264,9 @@ export const googleModels: Model[] = [
258
264
  createGoogleImageModel({
259
265
  name: "gemini-3-pro-image-preview",
260
266
  displayName: "Nano Banana Pro (Gemini 3 Pro Image Preview)",
261
- inputPrice: 2 * 8,
262
- outputPrice: 12 * 8,
263
- imageTokenPricePerMillion: 120 * 8,
267
+ inputPrice: 2 * 7,
268
+ outputPrice: 12 * 7,
269
+ imageTokenPricePerMillion: 120 * 7,
264
270
  imageOutputTokenEstimateBySize: {
265
271
  "1K": 1120,
266
272
  "2K": 1120,
@@ -268,13 +274,37 @@ export const googleModels: Model[] = [
268
274
  },
269
275
  maxOutputTokens: 8192,
270
276
  contextWindow: 65536,
277
+ imageGenerationWaitTimeSeconds: {
278
+ min: 25,
279
+ max: 60,
280
+ },
281
+ imageGenerationProfiles: [
282
+ {
283
+ key: "speed",
284
+ label: "速度优先",
285
+ imageModel: "gemini-3.1-flash-image-preview",
286
+ waitTimeSeconds: {
287
+ min: 10,
288
+ max: 25,
289
+ },
290
+ },
291
+ {
292
+ key: "quality",
293
+ label: "质量优先",
294
+ imageModel: "gemini-3-pro-image-preview",
295
+ waitTimeSeconds: {
296
+ min: 25,
297
+ max: 60,
298
+ },
299
+ },
300
+ ],
271
301
  }),
272
302
  createGoogleImageModel({
273
303
  name: "gemini-3.1-flash-image-preview",
274
304
  displayName: "Nano Banana 2 (Gemini 3.1 Flash Image Preview)",
275
- inputPrice: 0.5 * 8,
276
- outputPrice: 3 * 8,
277
- imageTokenPricePerMillion: 60 * 8,
305
+ inputPrice: 0.5 * 7,
306
+ outputPrice: 3 * 7,
307
+ imageTokenPricePerMillion: 60 * 7,
278
308
  imageOutputTokenEstimateBySize: {
279
309
  "1K": 1120,
280
310
  "2K": 1680,
@@ -282,17 +312,45 @@ export const googleModels: Model[] = [
282
312
  },
283
313
  maxOutputTokens: 65536,
284
314
  contextWindow: 65536,
315
+ imageGenerationWaitTimeSeconds: {
316
+ min: 10,
317
+ max: 25,
318
+ },
319
+ imageGenerationProfiles: [
320
+ {
321
+ key: "speed",
322
+ label: "速度优先",
323
+ imageModel: "gemini-3.1-flash-image-preview",
324
+ waitTimeSeconds: {
325
+ min: 10,
326
+ max: 25,
327
+ },
328
+ },
329
+ {
330
+ key: "quality",
331
+ label: "质量优先",
332
+ imageModel: "gemini-3-pro-image-preview",
333
+ waitTimeSeconds: {
334
+ min: 25,
335
+ max: 60,
336
+ },
337
+ },
338
+ ],
285
339
  }),
286
340
  createGoogleImageModel({
287
341
  name: "gemini-2.5-flash-image",
288
342
  displayName: "Gemini 2.5 Flash Image (Nano Banana)",
289
- inputPrice: 0.3 * 8,
290
- outputPrice: 2.5 * 8,
291
- imageTokenPricePerMillion: 30 * 8,
343
+ inputPrice: 0.3 * 7,
344
+ outputPrice: 2.5 * 7,
345
+ imageTokenPricePerMillion: 30 * 7,
292
346
  imageOutputTokenEstimateBySize: {
293
347
  "1K": 1290,
294
348
  },
295
349
  maxOutputTokens: 4096,
296
350
  contextWindow: 32768,
351
+ imageGenerationWaitTimeSeconds: {
352
+ min: 8,
353
+ max: 20,
354
+ },
297
355
  }),
298
356
  ];